@dbml/parse 3.7.2 → 3.7.3

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.
@@ -108,7 +108,7 @@ class v extends x {
108
108
  alias: i,
109
109
  attributeList: r,
110
110
  bodyColon: a,
111
- body: l
111
+ body: c
112
112
  }, p) {
113
113
  if (super(p, "<element-declaration>", [
114
114
  e,
@@ -117,10 +117,10 @@ class v extends x {
117
117
  i,
118
118
  r,
119
119
  a,
120
- l
121
- ]), l && a && !(l instanceof w || l instanceof v))
120
+ c
121
+ ]), c && a && !(c instanceof y || c 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 = l;
123
+ this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = c;
124
124
  }
125
125
  }
126
126
  class Y extends x {
@@ -161,7 +161,7 @@ class ne extends x {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class w extends x {
164
+ class y 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
  }
@@ -175,7 +175,7 @@ class J 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 R extends x {
178
+ class D extends x {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -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() {
@@ -384,7 +384,7 @@ 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
389
  function Jt(t) {
390
390
  const e = ie(t).unwrap_or(void 0);
@@ -407,18 +407,18 @@ function Zt(t) {
407
407
  function Me(t) {
408
408
  return !!t.match(/(\p{L}|_|\p{M})/gu);
409
409
  }
410
- function De(t) {
410
+ function Re(t) {
411
411
  const [e] = t;
412
412
  return e >= "0" && e <= "9";
413
413
  }
414
414
  function Kt(t) {
415
415
  const [e] = t;
416
- return De(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
416
+ return Re(e) || Me(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
417
417
  }
418
418
  function Ee(t) {
419
- return Me(t) || De(t);
419
+ return Me(t) || Re(t);
420
420
  }
421
- function ct(t, e) {
421
+ function lt(t, e) {
422
422
  const n = [], s = Math.min(t.length, e.length);
423
423
  for (let i = 0; i < s; i += 1)
424
424
  n.push(t[i], e[i]);
@@ -474,9 +474,9 @@ class an {
474
474
  }
475
475
  }
476
476
  var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_ESCAPE_SEQUENCE = 1011] = "INVALID_ESCAPE_SEQUENCE", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
477
- class c extends Error {
477
+ class l extends Error {
478
478
  constructor(e, n, s) {
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);
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, l.prototype);
480
480
  }
481
481
  }
482
482
  class V {
@@ -499,11 +499,11 @@ class V {
499
499
  }
500
500
  function on(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();
506
- const a = I.last(s) instanceof R ? s.pop() : void 0;
505
+ return new k();
506
+ const a = I.last(s) instanceof D ? s.pop() : void 0;
507
507
  return s.length === 3 && Ge(s[1]).unwrap().value === "as" ? new S(
508
508
  n.create(v, {
509
509
  type: i,
@@ -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 ct(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 ? ln(t) : cn(t));
536
536
  }
537
- function cn(t) {
537
+ function ln(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
539
539
  }
540
- function ln(t) {
540
+ function cn(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)
@@ -552,13 +552,13 @@ function ln(t) {
552
552
  N(t.op), N(t.expression);
553
553
  else if (t instanceof J)
554
554
  N(t.blockOpenBrace), t.body.forEach(N), N(t.blockCloseBrace);
555
- else if (t instanceof R)
555
+ else if (t instanceof D)
556
556
  N(t.listOpenBracket), t.commaList.forEach(N), t.elementList.forEach(N), N(t.listCloseBracket);
557
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 w)
561
+ else if (t instanceof y)
562
562
  N(t.callee), t.args.forEach(N);
563
563
  else if (t instanceof U)
564
564
  N(t.expression);
@@ -606,20 +606,20 @@ function un(t) {
606
606
  return P(t.expression, t.op);
607
607
  if (t instanceof ne)
608
608
  return P(t.value);
609
- if (t instanceof w)
609
+ if (t instanceof y)
610
610
  return P(t.callee, ...t.args);
611
611
  if (t instanceof J)
612
612
  return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
613
- if (t instanceof R)
613
+ if (t instanceof D)
614
614
  return P(
615
615
  t.listOpenBracket,
616
- ...ct(t.elementList, t.commaList),
616
+ ...lt(t.elementList, t.commaList),
617
617
  t.listCloseBracket
618
618
  );
619
619
  if (t instanceof Z)
620
620
  return P(
621
621
  t.tupleOpenParen,
622
- ...ct(t.elementList, t.commaList),
622
+ ...lt(t.elementList, t.commaList),
623
623
  t.tupleCloseParen
624
624
  );
625
625
  if (t instanceof H)
@@ -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,9 +653,9 @@ 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
660
  class hn {
661
661
  // list of errors during lexing
@@ -775,12 +775,12 @@ class hn {
775
775
  this.identifier();
776
776
  break;
777
777
  }
778
- if (De(e)) {
778
+ if (Re(e)) {
779
779
  this.numericLiteralOrIdentifier();
780
780
  break;
781
781
  }
782
782
  this.addToken(u.OP, !0), this.errors.push(
783
- new c(
783
+ new l(
784
784
  o.UNKNOWN_SYMBOL,
785
785
  `Unexpected token '${e}'`,
786
786
  this.createToken(u.OP, !0)
@@ -820,14 +820,14 @@ class hn {
820
820
  // Whether to interpret '\' as a backlash
821
821
  consumeStopSequence: a = !0
822
822
  }) {
823
- let l = "";
823
+ let c = "";
824
824
  for (; !this.isAtEnd() && (s || !this.check(`
825
825
  `)) && !this.check(n); )
826
- this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
826
+ this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += 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(
830
- new c(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
830
+ new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
831
831
  );
832
832
  return;
833
833
  }
@@ -835,7 +835,7 @@ class hn {
835
835
  `) && !s) {
836
836
  const p = this.createToken(e, !0);
837
837
  this.tokens.push(p), this.errors.push(
838
- new c(
838
+ new l(
839
839
  o.UNEXPECTED_NEWLINE,
840
840
  "Invalid newline encountered while parsing",
841
841
  p
@@ -843,7 +843,7 @@ class hn {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, l, !1));
846
+ a && this.match(n), this.tokens.push(F.create(e, this.start, this.current, c, !1));
847
847
  }
848
848
  singleLineStringLiteral() {
849
849
  this.consumeUntil(u.STRING_LITERAL, "'", {
@@ -912,7 +912,7 @@ class hn {
912
912
  return this.advance(), this.addToken(u.NUMERIC_LITERAL);
913
913
  if (!n && !Ee(this.peek()))
914
914
  return this.addToken(u.NUMERIC_LITERAL);
915
- if (!n && !De(this.peek()))
915
+ if (!n && !Re(this.peek()))
916
916
  break;
917
917
  this.advance();
918
918
  }
@@ -920,7 +920,7 @@ class hn {
920
920
  for (; !this.isAtEnd() && (this.check(".") || Ee(this.peek())); )
921
921
  this.advance();
922
922
  const n = this.createToken(u.NUMERIC_LITERAL, !0);
923
- this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
923
+ this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
924
924
  } else {
925
925
  for (; !this.isAtEnd() && Ee(this.peek()); )
926
926
  this.advance();
@@ -971,7 +971,7 @@ class hn {
971
971
  let n = "";
972
972
  for (let s = 0; s <= 3; s += 1) {
973
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}`;
974
+ return this.errors.push(new l(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));
@@ -1069,7 +1069,7 @@ class dn {
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 (ct(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1073
1073
  break;
1074
1074
  N(s), this.advance();
1075
1075
  }
@@ -1172,7 +1172,7 @@ class dn {
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(R, s);
1175
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(D, s);
1176
1176
  try {
1177
1177
  this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1178
1178
  } catch (r) {
@@ -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 (ct(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
@@ -1380,7 +1380,7 @@ class dn {
1380
1380
  }
1381
1381
  try {
1382
1382
  const s = this.expression();
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;
1383
+ s instanceof v ? this.errors.push(new l(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
  }
@@ -1389,7 +1389,7 @@ class dn {
1389
1389
  /* Parsing any ExpressionNode, including non-NormalExpression */
1390
1390
  expression() {
1391
1391
  const e = { args: [] }, n = () => on(e.callee, e.args, this.nodeFactory).unwrap_or(
1392
- this.nodeFactory.create(w, e)
1392
+ this.nodeFactory.create(y, e)
1393
1393
  );
1394
1394
  try {
1395
1395
  e.callee = this.normalExpression();
@@ -1476,12 +1476,12 @@ class dn {
1476
1476
  op: i,
1477
1477
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1478
1478
  });
1479
- } catch (l) {
1480
- throw l instanceof d ? (n = this.nodeFactory.create(q, {
1479
+ } catch (c) {
1480
+ throw c instanceof d ? (n = this.nodeFactory.create(q, {
1481
1481
  leftExpression: n,
1482
1482
  op: i,
1483
- rightExpression: l.partialNode
1484
- }), new d(l.token, n, l.handlerContext)) : l;
1483
+ rightExpression: c.partialNode
1484
+ }), new d(c.token, n, c.handlerContext)) : c;
1485
1485
  }
1486
1486
  }
1487
1487
  } else
@@ -1635,7 +1635,7 @@ class dn {
1635
1635
  return this.nodeFactory.create(Y, { identifiers: e });
1636
1636
  }
1637
1637
  logError(e, n, s) {
1638
- this.errors.push(new c(n, s, e));
1638
+ this.errors.push(new l(n, s, e));
1639
1639
  }
1640
1640
  }
1641
1641
  const En = {
@@ -1688,36 +1688,36 @@ 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))) {
@@ -1727,12 +1727,12 @@ function _e(t) {
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,7 +1741,7 @@ 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
1747
  if (ht(t))
@@ -1752,15 +1752,15 @@ function Xe(t) {
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
1765
  function In(t) {
1766
1766
  var e;
@@ -1777,13 +1777,13 @@ function ht(t) {
1777
1777
  return t instanceof U && t.expression instanceof K || t instanceof ne;
1778
1778
  }
1779
1779
  function gn(t, e) {
1780
- var i, r, a, l;
1780
+ var i, r, a, c;
1781
1781
  let n = e;
1782
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 (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
1786
+ if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof X && s)
1787
1787
  return n.symbol;
1788
1788
  if (n instanceof X)
1789
1789
  return;
@@ -1798,24 +1798,24 @@ class _n {
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 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)] : [];
1801
+ return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new l(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1802
1802
  }
1803
1803
  validateName(e) {
1804
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1804
+ return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1805
1805
  }
1806
1806
  validateAlias(e) {
1807
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1807
+ return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1808
1808
  }
1809
1809
  validateSettingList(e) {
1810
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1810
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1811
1811
  }
1812
1812
  validateBody(e) {
1813
1813
  if (!e)
1814
1814
  return [];
1815
1815
  if (e instanceof J)
1816
- return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1816
+ return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1817
1817
  const 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;
1818
+ return $(e.callee) || n.push(new l(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 l(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1819
1819
  }
1820
1820
  }
1821
1821
  class we {
@@ -1843,41 +1843,41 @@ class An {
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 v ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1846
+ return this.declarationNode.parent instanceof v ? [new l(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 ? yt(e) ? [] : [new l(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new l(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1850
1850
  }
1851
1851
  validateAlias(e) {
1852
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1852
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1853
1853
  }
1854
1854
  registerElement() {
1855
1855
  const e = [];
1856
1856
  this.declarationNode.symbol = this.symbolFactory.create(tn, { declaration: this.declarationNode, symbolTable: new we() });
1857
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), 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);
1859
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = ze(r);
1860
+ a.has(c) && e.push(new l(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(c, this.declarationNode.symbol);
1861
1861
  }
1862
1862
  return e;
1863
1863
  }
1864
1864
  validateSettingList(e) {
1865
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1865
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1866
1866
  }
1867
1867
  validateBody(e) {
1868
1868
  if (!e)
1869
1869
  return [];
1870
- if (e instanceof w)
1870
+ if (e instanceof y)
1871
1871
  return this.validateFields([e]);
1872
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
1872
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
1873
1873
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1874
1874
  }
1875
1875
  validateFields(e) {
1876
- return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1876
+ return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1877
1877
  const s = [];
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));
1878
+ n.callee && !M(n.callee) && s.push(new l(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 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;
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 l(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) {
@@ -1886,12 +1886,12 @@ class An {
1886
1886
  const a = i[r];
1887
1887
  switch (r) {
1888
1888
  case "note":
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));
1889
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
1890
+ $(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1891
1891
  });
1892
1892
  break;
1893
1893
  default:
1894
- a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1894
+ a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
1895
1895
  }
1896
1896
  }
1897
1897
  return s;
@@ -1912,8 +1912,8 @@ class An {
1912
1912
  if (r.has(s)) {
1913
1913
  const a = r.get(s);
1914
1914
  return [
1915
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1916
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1915
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1916
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1917
1917
  ];
1918
1918
  }
1919
1919
  r.set(s, i);
@@ -1929,23 +1929,23 @@ class vn {
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 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)] : [];
1932
+ return this.declarationNode.parent instanceof X || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new l(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1933
1933
  }
1934
1934
  validateName(e) {
1935
- return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1935
+ return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1936
1936
  }
1937
1937
  validateAlias(e) {
1938
- return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1938
+ return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1939
1939
  }
1940
1940
  validateSettingList(e) {
1941
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1941
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1942
1942
  }
1943
1943
  validateBody(e) {
1944
1944
  if (!e)
1945
1945
  return [];
1946
- if (e instanceof w)
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 w);
1946
+ if (e instanceof y)
1947
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1948
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
1949
1949
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1950
1950
  }
1951
1951
  validateFields(e) {
@@ -1953,10 +1953,10 @@ class vn {
1953
1953
  if (!n.callee)
1954
1954
  return [];
1955
1955
  const s = [], i = [n.callee, ...n.args];
1956
- return I.last(i) instanceof R && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1956
+ return I.last(i) instanceof D && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1957
1957
  for (; r instanceof H; )
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
- 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));
1958
+ r.argumentList && !Xe(r.argumentList).isOk() && s.push(new l(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
+ Xe(r).isOk() || s.push(new l(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1960
1960
  }), s;
1961
1961
  });
1962
1962
  }
@@ -1967,23 +1967,23 @@ class vn {
1967
1967
  switch (r) {
1968
1968
  case "note":
1969
1969
  case "name":
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));
1970
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1971
+ $(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
1972
1972
  });
1973
1973
  break;
1974
1974
  case "unique":
1975
1975
  case "pk":
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));
1976
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1977
+ ue(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
1978
1978
  });
1979
1979
  break;
1980
1980
  case "type":
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));
1981
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
1982
+ M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
1983
1983
  });
1984
1984
  break;
1985
1985
  default:
1986
- a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1986
+ a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
1987
1987
  }
1988
1988
  }
1989
1989
  return s;
@@ -2015,7 +2015,7 @@ class wn {
2015
2015
  b.Table,
2016
2016
  b.TableGroup,
2017
2017
  b.Project
2018
- ].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(
2018
+ ].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(
2019
2019
  o.INVALID_NOTE_CONTEXT,
2020
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
2021
  this.declarationNode
@@ -2023,32 +2023,32 @@ class wn {
2023
2023
  }
2024
2024
  validateName(e) {
2025
2025
  if (!(this.declarationNode.parent instanceof X))
2026
- return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2026
+ return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2027
2027
  if (!e)
2028
- return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2028
+ return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2029
2029
  const n = W(e);
2030
2030
  if (!n.isOk())
2031
- return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2031
+ return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2032
2032
  const i = n.unwrap().join("."), r = Ht(i);
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), []);
2033
+ return this.publicSymbolTable.has(r) ? [new l(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
2034
2034
  }
2035
2035
  validateAlias(e) {
2036
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2036
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2037
2037
  }
2038
2038
  validateSettingList(e) {
2039
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2039
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2040
2040
  }
2041
2041
  validateBody(e) {
2042
2042
  if (!e)
2043
2043
  return [];
2044
- if (e instanceof w)
2044
+ if (e instanceof y)
2045
2045
  return this.validateFields([e]);
2046
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2046
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
2047
2047
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2048
2048
  }
2049
2049
  validateFields(e) {
2050
2050
  const 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);
2051
+ return e.length === 0 ? [new l(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new l(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new l(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 l(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2052
2052
  }
2053
2053
  validateSubElements(e) {
2054
2054
  return e.flatMap((n) => {
@@ -2067,25 +2067,25 @@ class yn {
2067
2067
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2068
2068
  }
2069
2069
  validateContext() {
2070
- return this.declarationNode.parent instanceof v ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2070
+ return this.declarationNode.parent instanceof v ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2071
2071
  }
2072
2072
  validateName(e) {
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)] : [];
2073
+ return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2074
2074
  }
2075
2075
  validateAlias(e) {
2076
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2076
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2077
2077
  }
2078
2078
  validateSettingList(e) {
2079
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2079
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2080
2080
  }
2081
2081
  validateBody(e) {
2082
2082
  if (!e)
2083
2083
  return [];
2084
- if (e instanceof w)
2085
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2086
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2084
+ if (e instanceof y)
2085
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2086
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
2087
2087
  return [
2088
- ...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2088
+ ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2089
2089
  ...this.validateSubElements(s)
2090
2090
  ];
2091
2091
  }
@@ -2106,33 +2106,33 @@ class kn {
2106
2106
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2107
2107
  }
2108
2108
  validateContext() {
2109
- return this.declarationNode.parent instanceof X ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2109
+ return this.declarationNode.parent instanceof X ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2110
2110
  }
2111
2111
  validateName(e) {
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)] : [];
2112
+ return e ? ye(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2113
2113
  }
2114
2114
  validateAlias(e) {
2115
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2115
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2116
2116
  }
2117
2117
  validateSettingList(e) {
2118
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2118
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2119
2119
  }
2120
2120
  validateBody(e) {
2121
2121
  if (!e)
2122
2122
  return [];
2123
- if (e instanceof w)
2123
+ if (e instanceof y)
2124
2124
  return this.validateFields([e]);
2125
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2125
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
2126
2126
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2127
2127
  }
2128
2128
  validateFields(e) {
2129
2129
  if (e.length === 0)
2130
- return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2130
+ return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2131
2131
  const n = [];
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));
2132
+ return e.length > 1 && n.push(...e.slice(1).map((s) => new l(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2133
+ s.callee && !In(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Ln(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2134
2134
  const i = [...s.args];
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)));
2135
+ 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 l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2136
2136
  }), n;
2137
2137
  }
2138
2138
  validateFieldSettings(e) {
@@ -2142,12 +2142,12 @@ class kn {
2142
2142
  switch (r) {
2143
2143
  case "delete":
2144
2144
  case "update":
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));
2145
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
2146
+ xn(c.value) || s.push(new l(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, c));
2147
2147
  });
2148
2148
  break;
2149
2149
  default:
2150
- a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2150
+ a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
2151
2151
  }
2152
2152
  }
2153
2153
  return s;
@@ -2186,13 +2186,13 @@ class Sn {
2186
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)];
2187
2187
  }
2188
2188
  validateContext() {
2189
- return this.declarationNode.parent instanceof v ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2189
+ return this.declarationNode.parent instanceof v ? [new l(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 l(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 l(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new l(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 ? Pn(e) ? [] : [new l(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();
@@ -2200,17 +2200,17 @@ class Sn {
2200
2200
  const a = i[r];
2201
2201
  switch (r) {
2202
2202
  case "headercolor":
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));
2203
+ a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
2204
+ Un(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2205
2205
  });
2206
2206
  break;
2207
2207
  case "note":
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));
2208
+ a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
2209
+ $(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2210
2210
  });
2211
2211
  break;
2212
2212
  default:
2213
- s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2213
+ s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
2214
2214
  }
2215
2215
  }
2216
2216
  return s;
@@ -2220,29 +2220,29 @@ class Sn {
2220
2220
  this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
2221
2221
  const { name: n, alias: s } = this.declarationNode, i = W(n);
2222
2222
  if (i.isOk()) {
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);
2223
+ const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = Oe(a);
2224
+ c.has(p) && e.push(new l(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), c.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
- this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2228
+ this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2229
2229
  }
2230
2230
  return e;
2231
2231
  }
2232
2232
  validateBody(e) {
2233
2233
  if (!e)
2234
2234
  return [];
2235
- if (e instanceof w)
2236
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2237
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2235
+ if (e instanceof y)
2236
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2237
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
2238
2238
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2239
2239
  }
2240
2240
  validateFields(e) {
2241
- return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2241
+ return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
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 l(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new l(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 l(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
  });
@@ -2255,8 +2255,8 @@ class Sn {
2255
2255
  if (r.has(s)) {
2256
2256
  const a = r.get(s);
2257
2257
  return [
2258
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2259
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2258
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2259
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2260
2260
  ];
2261
2261
  }
2262
2262
  r.set(s, i);
@@ -2265,75 +2265,75 @@ class Sn {
2265
2265
  }
2266
2266
  // This is needed to support legacy inline settings
2267
2267
  validateFieldSetting(e) {
2268
- if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof R))
2269
- return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2268
+ if (!e.slice(0, -1).every(me) || !e.slice(-1).every((p) => me(p) || p instanceof D))
2269
+ return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2270
2270
  if (e.length === 0)
2271
2271
  return [];
2272
2272
  let n;
2273
- I.last(e) instanceof R && (n = e.pop());
2273
+ I.last(e) instanceof D && (n = e.pop());
2274
2274
  const s = B(n), i = s.getErrors(), r = s.getValue();
2275
2275
  for (const p of e) {
2276
2276
  const f = C(p).unwrap_or("").toLowerCase();
2277
2277
  if (f !== "pk" && f !== "unique") {
2278
- i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2278
+ i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2279
2279
  continue;
2280
2280
  }
2281
2281
  r[f] === void 0 ? r[f] = [p] : r[f].push(p);
2282
2282
  }
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)));
2283
+ const a = r.pk || [], c = r["primary key"] || [];
2284
+ a.length >= 1 && c.length >= 1 && i.push(...[...a, ...c].map((p) => new l(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2285
2285
  for (const p in r) {
2286
2286
  const f = r[p];
2287
2287
  switch (p) {
2288
2288
  case "note":
2289
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
2290
- $(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2289
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", h))), f.forEach((h) => {
2290
+ $(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", h.value || h.name));
2291
2291
  });
2292
2292
  break;
2293
2293
  case "ref":
2294
2294
  f.forEach((h) => {
2295
- Fn(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 l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", h.value || h.name));
2296
2296
  });
2297
2297
  break;
2298
2298
  case "primary key":
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) => {
2300
- ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
2299
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", h))), f.forEach((h) => {
2300
+ ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", h.value || h.name));
2301
2301
  });
2302
2302
  break;
2303
2303
  case "pk":
2304
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
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));
2304
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", h))), f.forEach((h) => {
2305
+ h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", h.value || h.name));
2306
2306
  });
2307
2307
  break;
2308
2308
  case "not null":
2309
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
2309
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", h)));
2310
2310
  const E = r.null || [];
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) => {
2312
- ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
2311
+ f.length >= 1 && E.length >= 1 && i.push(...[...f, ...E].map((h) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", h))), f.forEach((h) => {
2312
+ ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", h.value || h.name));
2313
2313
  });
2314
2314
  break;
2315
2315
  case "null":
2316
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
2317
- ue(h.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
2316
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", h))), f.forEach((h) => {
2317
+ ue(h.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", h.value || h.name));
2318
2318
  });
2319
2319
  break;
2320
2320
  case "unique":
2321
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
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));
2321
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", h))), f.forEach((h) => {
2322
+ h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", h.value || h.name));
2323
2323
  });
2324
2324
  break;
2325
2325
  case "increment":
2326
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
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));
2326
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", h))), f.forEach((h) => {
2327
+ h instanceof se && !ue(h.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", h.value || h.name));
2328
2328
  });
2329
2329
  break;
2330
2330
  case "default":
2331
- f.length > 1 && i.push(...f.map((h) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
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));
2331
+ f.length > 1 && i.push(...f.map((h) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", h))), f.forEach((h) => {
2332
+ Mn(h.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", h.value || h.name));
2333
2333
  });
2334
2334
  break;
2335
2335
  default:
2336
- f.forEach((h) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
2336
+ f.forEach((h) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, h)));
2337
2337
  }
2338
2338
  }
2339
2339
  return i;
@@ -2348,7 +2348,7 @@ class Sn {
2348
2348
  var r;
2349
2349
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2350
2350
  });
2351
- return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2351
+ return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2352
2352
  }
2353
2353
  }
2354
2354
  function On(t) {
@@ -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 Dn {
2374
2374
  constructor(e, n, s) {
2375
2375
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2376
2376
  }
@@ -2385,25 +2385,25 @@ class Rn {
2385
2385
  ];
2386
2386
  }
2387
2387
  validateContext() {
2388
- return this.declarationNode.parent instanceof v ? [new c(
2388
+ return this.declarationNode.parent instanceof v ? [new l(
2389
2389
  o.INVALID_TABLEGROUP_CONTEXT,
2390
2390
  "TableGroup must appear top-level",
2391
2391
  this.declarationNode
2392
2392
  )] : [];
2393
2393
  }
2394
2394
  validateName(e) {
2395
- return e ? ye(e) ? [] : [new c(
2395
+ return e ? ye(e) ? [] : [new l(
2396
2396
  o.INVALID_NAME,
2397
2397
  "A TableGroup name must be a single identifier",
2398
2398
  e
2399
- )] : [new c(
2399
+ )] : [new l(
2400
2400
  o.NAME_NOT_FOUND,
2401
2401
  "A TableGroup must have a name",
2402
2402
  this.declarationNode
2403
2403
  )];
2404
2404
  }
2405
2405
  validateAlias(e) {
2406
- return e ? [new c(
2406
+ return e ? [new l(
2407
2407
  o.UNEXPECTED_ALIAS,
2408
2408
  "A TableGroup shouldn't have an alias",
2409
2409
  e
@@ -2416,7 +2416,7 @@ class Rn {
2416
2416
  if (n.isOk()) {
2417
2417
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
2418
2418
  if (r.has(a))
2419
- return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2419
+ return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists`, e)];
2420
2420
  r.set(a, this.declarationNode.symbol);
2421
2421
  }
2422
2422
  return [];
@@ -2426,30 +2426,30 @@ class Rn {
2426
2426
  return I.forIn(i, (r, a) => {
2427
2427
  switch (a) {
2428
2428
  case "headercolor":
2429
- s.push(...r.map((l) => new c(
2429
+ s.push(...r.map((c) => new l(
2430
2430
  o.INVALID_TABLE_SETTING,
2431
2431
  "'headercolor' is not supported",
2432
- l
2432
+ c
2433
2433
  )));
2434
2434
  break;
2435
2435
  case "note":
2436
- r.length > 1 && s.push(...r.map((l) => new c(
2436
+ r.length > 1 && s.push(...r.map((c) => new l(
2437
2437
  o.DUPLICATE_TABLE_SETTING,
2438
2438
  "'note' can only appear once",
2439
- l
2440
- ))), r.filter((l) => !$(l.value)).forEach((l) => {
2441
- s.push(new c(
2439
+ c
2440
+ ))), r.filter((c) => !$(c.value)).forEach((c) => {
2441
+ s.push(new l(
2442
2442
  o.INVALID_TABLE_SETTING,
2443
2443
  "'note' must be a string literal",
2444
- l.value || l.name
2444
+ c.value || c.name
2445
2445
  ));
2446
2446
  });
2447
2447
  break;
2448
2448
  default:
2449
- s.push(...r.map((l) => new c(
2449
+ s.push(...r.map((c) => new l(
2450
2450
  o.INVALID_TABLE_SETTING,
2451
2451
  `Unknown '${a}' setting`,
2452
- l
2452
+ c
2453
2453
  )));
2454
2454
  break;
2455
2455
  }
@@ -2458,13 +2458,13 @@ class Rn {
2458
2458
  validateBody(e) {
2459
2459
  if (!e)
2460
2460
  return [];
2461
- if (e instanceof w)
2462
- return [new c(
2461
+ if (e instanceof y)
2462
+ return [new l(
2463
2463
  o.UNEXPECTED_SIMPLE_BODY,
2464
2464
  "A TableGroup's body must be a block",
2465
2465
  e
2466
2466
  )];
2467
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2467
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
2468
2468
  return [
2469
2469
  ...this.validateFields(n),
2470
2470
  ...this.validateSubElements(s)
@@ -2473,7 +2473,7 @@ class Rn {
2473
2473
  validateFields(e) {
2474
2474
  return e.flatMap((n) => {
2475
2475
  const 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;
2476
+ return n.callee && !W(n.callee).isOk() && s.push(new l(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 l(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2477
2477
  });
2478
2478
  }
2479
2479
  validateSubElements(e) {
@@ -2486,7 +2486,7 @@ class Rn {
2486
2486
  var r;
2487
2487
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2488
2488
  });
2489
- return s.length > 1 && n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2489
+ return s.length > 1 && n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n;
2490
2490
  }
2491
2491
  registerField(e) {
2492
2492
  if (e.callee && M(e.callee)) {
@@ -2496,8 +2496,8 @@ class Rn {
2496
2496
  if (r.has(s)) {
2497
2497
  const a = r.get(s);
2498
2498
  return [
2499
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2500
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2499
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2500
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2501
2501
  ];
2502
2502
  }
2503
2503
  r.set(s, i);
@@ -2513,7 +2513,7 @@ function ae(t) {
2513
2513
  case b.Table:
2514
2514
  return Sn;
2515
2515
  case b.TableGroup:
2516
- return Rn;
2516
+ return Dn;
2517
2517
  case b.Project:
2518
2518
  return yn;
2519
2519
  case b.Ref:
@@ -2541,14 +2541,14 @@ function Ze(t, e, n) {
2541
2541
  let s = e;
2542
2542
  for (const r of t) {
2543
2543
  let a;
2544
- const l = je(r);
2545
- if (s.has(l)) {
2546
- if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2544
+ const c = je(r);
2545
+ if (s.has(c)) {
2546
+ if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
2547
2547
  throw new Error("Expect a symbol table in a schema symbol");
2548
2548
  } else {
2549
2549
  a = new we();
2550
2550
  const p = n.create(_t, { symbolTable: a });
2551
- s.set(l, p);
2551
+ s.set(c, p);
2552
2552
  }
2553
2553
  s = a;
2554
2554
  }
@@ -2599,7 +2599,7 @@ function B(t) {
2599
2599
  if (!i.name)
2600
2600
  continue;
2601
2601
  if (i.name instanceof U) {
2602
- n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2602
+ n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2603
2603
  continue;
2604
2604
  }
2605
2605
  const r = (s = Te(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
@@ -2626,7 +2626,7 @@ class ft {
2626
2626
  e.push(...r.validate());
2627
2627
  });
2628
2628
  const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
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);
2629
+ return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new V(this.ast, e);
2630
2630
  }
2631
2631
  }
2632
2632
  class oe {
@@ -2667,7 +2667,7 @@ class oe {
2667
2667
  }
2668
2668
  bindSubfield(e) {
2669
2669
  const n = [e.callee, ...e.args], s = I.last(n);
2670
- s instanceof R && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2670
+ s instanceof D && (n.pop(), this.bindSettingList(s, this.subfield.settingList));
2671
2671
  const { argBinderRules: i } = this.subfield.arg;
2672
2672
  for (let r = 0; r < Math.min(n.length, i.length); r += 1)
2673
2673
  i[r].shouldBind && this.scanAndBind(n[r], i[r]);
@@ -2689,7 +2689,7 @@ class oe {
2689
2689
  bindFragments(e, n) {
2690
2690
  if (e.length === 0)
2691
2691
  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(
2692
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((h) => !M(h)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, f = e.slice(
2693
2693
  0,
2694
2694
  r === -1 ? void 0 : r
2695
2695
  );
@@ -2710,7 +2710,7 @@ class oe {
2710
2710
  referrer: h
2711
2711
  });
2712
2712
  }
2713
- return l ? l.elementList.forEach(
2713
+ return c ? c.elementList.forEach(
2714
2714
  (h) => this.resolveIndexStack(
2715
2715
  [
2716
2716
  ...E,
@@ -2738,24 +2738,24 @@ class oe {
2738
2738
  return;
2739
2739
  }
2740
2740
  r.references.push(s.referrer), s.referrer.referee = r;
2741
- let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
2741
+ let a = r.symbolTable, { kind: c, name: p } = ie(s.index).unwrap();
2742
2742
  for (const f of i) {
2743
2743
  const { kind: E, name: h } = ie(f.index).unwrap(), m = a.get(f.index);
2744
2744
  if (!m) {
2745
2745
  this.logError(
2746
2746
  f.referrer,
2747
- `${l} '${p}' does not have ${E} '${h}'`,
2747
+ `${c} '${p}' does not have ${E} '${h}'`,
2748
2748
  n
2749
2749
  );
2750
2750
  return;
2751
2751
  }
2752
- if (l = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
2752
+ if (c = E, p = h, f.referrer.referee = m, m.references.push(f.referrer), !m.symbolTable)
2753
2753
  break;
2754
2754
  a = m.symbolTable;
2755
2755
  }
2756
2756
  }
2757
2757
  logError(e, n, s) {
2758
- s || this.errors.push(new c(o.BINDING_ERROR, n, e));
2758
+ s || this.errors.push(new l(o.BINDING_ERROR, n, e));
2759
2759
  }
2760
2760
  }
2761
2761
  class Bn extends oe {
@@ -3004,10 +3004,10 @@ function Ie(t) {
3004
3004
  schemaName: e
3005
3005
  };
3006
3006
  }
3007
- function Dt(t) {
3007
+ function Rt(t) {
3008
3008
  return t.expression.literal.value;
3009
3009
  }
3010
- function Rt(t, e) {
3010
+ function Dt(t, e) {
3011
3011
  if (Array.isArray(t)) {
3012
3012
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
3013
3013
  return i < r ? `${i}-${r}` : `${r}-${i}`;
@@ -3018,7 +3018,7 @@ function Rt(t, e) {
3018
3018
  function Pt(t, e) {
3019
3019
  if (Array.isArray(t)) {
3020
3020
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
3021
- return I.zip(i, r).every(([a, l]) => a === l);
3021
+ return I.zip(i, r).every(([a, c]) => a === c);
3022
3022
  }
3023
3023
  const n = t.id, s = e.id;
3024
3024
  return n === s;
@@ -3054,7 +3054,7 @@ class Ut {
3054
3054
  }
3055
3055
  interpretName(e) {
3056
3056
  const { name: n, schemaName: s } = Ie(e);
3057
- return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
3057
+ return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
3058
3058
  }
3059
3059
  interpretAlias(e) {
3060
3060
  if (!e)
@@ -3072,7 +3072,7 @@ class Ut {
3072
3072
  interpretSettingList(e) {
3073
3073
  var i, r, a;
3074
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;
3075
+ 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;
3076
3076
  const [s] = n.note || [];
3077
3077
  return this.table.note = s && {
3078
3078
  value: G(s == null ? void 0 : s.value).map(re).unwrap(),
@@ -3080,7 +3080,7 @@ class Ut {
3080
3080
  }, [];
3081
3081
  }
3082
3082
  interpretBody(e) {
3083
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
3083
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
3084
3084
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3085
3085
  }
3086
3086
  interpretSubElements(e) {
@@ -3102,61 +3102,61 @@ class Ut {
3102
3102
  return e.flatMap((n) => this.interpretColumn(n));
3103
3103
  }
3104
3104
  interpretColumn(e) {
3105
- var a, l, p, f, E, h, m, g;
3105
+ var a, c, p, f, E, h, m, g;
3106
3106
  const n = [], s = {};
3107
3107
  s.name = C(e.callee).unwrap();
3108
3108
  const i = qn(e.args[0]);
3109
3109
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = A(e), s.inline_refs = [];
3110
3110
  const r = e.args.slice(1);
3111
- if (I.last(r) instanceof R) {
3111
+ if (I.last(r) instanceof D) {
3112
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);
3113
+ s.pk = !!((a = _.pk) != null && a.length) || !!((c = _["primary key"]) != null && c.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
3114
  const ee = (g = _.note) == null ? void 0 : g.at(0);
3115
3115
  s.note = ee && {
3116
3116
  value: G(ee.value).map(re).unwrap(),
3117
3117
  token: A(ee)
3118
3118
  };
3119
- const ce = _.ref || [];
3120
- s.inline_refs = ce.flatMap((z) => {
3119
+ const le = _.ref || [];
3120
+ s.inline_refs = le.flatMap((z) => {
3121
3121
  const [tt] = $e(z.value.expression);
3122
3122
  if (Pt(tt, e.symbol))
3123
- return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3123
+ return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3124
3124
  const ke = z.value.op, te = W(z.value.expression).unwrap();
3125
3125
  let de;
3126
3126
  if (te.length === 1) {
3127
- const [le] = te;
3127
+ const [ce] = te;
3128
3128
  de = {
3129
3129
  schemaName: this.table.schemaName,
3130
3130
  tableName: this.table.name,
3131
- fieldNames: [le],
3131
+ fieldNames: [ce],
3132
3132
  relation: ke.value,
3133
3133
  token: A(z)
3134
3134
  };
3135
3135
  } else if (te.length === 2) {
3136
- const [le, Le] = te;
3136
+ const [ce, Le] = te;
3137
3137
  de = {
3138
3138
  schemaName: null,
3139
- tableName: le,
3139
+ tableName: ce,
3140
3140
  fieldNames: [Le],
3141
3141
  relation: ke.value,
3142
3142
  token: A(z)
3143
3143
  };
3144
3144
  } else if (te.length === 3) {
3145
- const [le, Le, st] = te;
3145
+ const [ce, Le, st] = te;
3146
3146
  de = {
3147
- schemaName: le,
3147
+ schemaName: ce,
3148
3148
  tableName: Le,
3149
3149
  fieldNames: [st],
3150
3150
  relation: ke.value,
3151
3151
  token: A(z)
3152
3152
  };
3153
3153
  } else {
3154
- n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3155
- const le = te.pop(), Le = te.pop();
3154
+ n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", z));
3155
+ const ce = te.pop(), Le = te.pop();
3156
3156
  de = {
3157
3157
  schemaName: te.join("."),
3158
3158
  tableName: Le,
3159
- fieldNames: [le],
3159
+ fieldNames: [ce],
3160
3160
  relation: ke.value,
3161
3161
  token: A(z)
3162
3162
  };
@@ -3169,13 +3169,13 @@ class Ut {
3169
3169
  }
3170
3170
  interpretIndexes(e) {
3171
3171
  return this.table.indexes.push(...e.body.body.map((n) => {
3172
- var a, l, p, f, E, h, m;
3172
+ var a, c, p, f, E, h, m;
3173
3173
  const s = { columns: [] }, i = n;
3174
- s.token = A(e);
3174
+ s.token = A(i);
3175
3175
  const r = [i.callee, ...i.args];
3176
- if (I.last(r) instanceof R) {
3176
+ if (I.last(r) instanceof D) {
3177
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);
3178
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = G((f = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : f.value).unwrap_or(void 0);
3179
3179
  const _ = (E = g.note) == null ? void 0 : E.at(0);
3180
3180
  s.note = _ && {
3181
3181
  value: G(_.value).unwrap(),
@@ -3192,26 +3192,26 @@ class Ut {
3192
3192
  }).forEach((g) => {
3193
3193
  const { functional: _, nonFunctional: ee } = Xe(g).unwrap();
3194
3194
  s.columns.push(
3195
- ..._.map((ce) => ({
3196
- value: ce.value.value,
3195
+ ..._.map((le) => ({
3196
+ value: le.value.value,
3197
3197
  type: "expression",
3198
- token: A(ce)
3198
+ token: A(le)
3199
3199
  })),
3200
- ...ee.map((ce) => ({
3201
- value: C(ce).unwrap(),
3200
+ ...ee.map((le) => ({
3201
+ value: C(le).unwrap(),
3202
3202
  type: "column",
3203
- token: A(ce)
3203
+ token: A(le)
3204
3204
  }))
3205
3205
  );
3206
3206
  }), s;
3207
3207
  })), [];
3208
3208
  }
3209
3209
  registerInlineRefToEnv(e, n, s, i) {
3210
- const r = Rt(e.symbol, n);
3210
+ const r = Dt(e.symbol, n);
3211
3211
  if (this.env.refIds[r])
3212
3212
  return [
3213
- new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
3214
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3213
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3214
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3215
3215
  ];
3216
3216
  const a = Ot(s.relation);
3217
3217
  return this.env.refIds[r] = i, this.env.ref.set(i, {
@@ -3247,7 +3247,7 @@ function qn(t) {
3247
3247
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3248
3248
  args: e
3249
3249
  },
3250
- [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3250
+ [new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
3251
3251
  ) : new V({
3252
3252
  schemaName: i.length === 0 ? null : i[0],
3253
3253
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
@@ -3305,12 +3305,12 @@ class Jn {
3305
3305
  interpretSettingList(e) {
3306
3306
  var s, i, r;
3307
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, [];
3308
+ 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, [];
3309
3309
  }
3310
3310
  interpretBody(e) {
3311
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
3311
+ const [n, s] = I.partition(e.body, (i) => i instanceof y);
3312
3312
  return n.length !== 1 || s.length > 0 ? [
3313
- new c(o.INVALID_NOTE, "Invalid note syntax", e)
3313
+ new l(o.INVALID_NOTE, "Invalid note syntax", e)
3314
3314
  ] : [...this.interpretNote(n[0])];
3315
3315
  }
3316
3316
  interpretNote(e) {
@@ -3327,21 +3327,21 @@ class Mt {
3327
3327
  }
3328
3328
  interpretName(e) {
3329
3329
  const n = [], s = W(this.declarationNode.name).unwrap_or([]);
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;
3330
+ return this.ref.name = s.pop() || null, s.length > 1 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3331
3331
  }
3332
3332
  interpretBody(e) {
3333
- return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3333
+ return e instanceof y ? this.interpretField(e) : this.interpretField(e.body[0]);
3334
3334
  }
3335
3335
  interpretField(e) {
3336
3336
  var f, E, h, m;
3337
3337
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
3338
3338
  if (Pt(r, a))
3339
- return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3340
- const l = Rt(r, a);
3341
- if (this.env.refIds[l])
3339
+ return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3340
+ const c = Dt(r, a);
3341
+ if (this.env.refIds[c])
3342
3342
  return [
3343
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3344
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3343
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3344
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
3345
3345
  ];
3346
3346
  if (e.args[0]) {
3347
3347
  const g = B(e.args[0]).getValue(), _ = (E = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : E.value;
@@ -3361,7 +3361,7 @@ class Mt {
3361
3361
  relation: p[1],
3362
3362
  token: A(i)
3363
3363
  }
3364
- ], this.env.refIds[l] = this.declarationNode, [];
3364
+ ], this.env.refIds[c] = this.declarationNode, [];
3365
3365
  }
3366
3366
  }
3367
3367
  class Ft {
@@ -3378,10 +3378,10 @@ class Ft {
3378
3378
  }
3379
3379
  interpretName(e) {
3380
3380
  const n = [], { name: s, schemaName: i } = Ie(e);
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;
3381
+ return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3382
3382
  }
3383
3383
  interpretBody(e) {
3384
- const [n, s] = jt(e.body, (i) => i instanceof w);
3384
+ const [n, s] = jt(e.body, (i) => i instanceof y);
3385
3385
  return [
3386
3386
  ...this.interpretFields(n),
3387
3387
  ...this.interpretSubElements(s)
@@ -3407,11 +3407,11 @@ class Ft {
3407
3407
  const n = [];
3408
3408
  return this.tableGroup.tables = e.map((s) => {
3409
3409
  const i = W(s.callee).unwrap();
3410
- i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
3410
+ i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
3411
3411
  const r = pe(s.callee).unwrap().pop().referee.id;
3412
3412
  if (this.env.groupOfTable[r]) {
3413
- const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), f = l ? `${l}.${p}` : p;
3414
- n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
3413
+ const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), f = c ? `${c}.${p}` : p;
3414
+ n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${f}"`, s));
3415
3415
  } else
3416
3416
  this.env.groupOfTable[r] = this.declarationNode;
3417
3417
  return {
@@ -3437,14 +3437,14 @@ class Bt {
3437
3437
  }
3438
3438
  interpretName(e) {
3439
3439
  const { name: n, schemaName: s } = Ie(e);
3440
- return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3440
+ return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new l(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3441
3441
  }
3442
3442
  interpretBody(e) {
3443
3443
  return e.body.flatMap((n) => {
3444
- var l;
3444
+ var c;
3445
3445
  const s = n, i = {};
3446
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);
3447
+ const a = (c = B(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3448
3448
  return i.note = a && {
3449
3449
  value: G(a.value).map(re).unwrap(),
3450
3450
  token: A(a)
@@ -3546,7 +3546,7 @@ function es(t) {
3546
3546
  project: Array.from(t.project.values())[0] || {}
3547
3547
  };
3548
3548
  }
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 || {});
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 || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
3550
3550
  function Ae(t) {
3551
3551
  switch (t) {
3552
3552
  case T.Schema:
@@ -3567,7 +3567,7 @@ function Ae(t) {
3567
3567
  return L.Text;
3568
3568
  }
3569
3569
  }
3570
- function Re(t, e) {
3570
+ function De(t, e) {
3571
3571
  if (!t || Ce(t))
3572
3572
  return !1;
3573
3573
  for (const n of t.trailingTrivia) {
@@ -3578,7 +3578,7 @@ function Re(t, e) {
3578
3578
  }
3579
3579
  return !0;
3580
3580
  }
3581
- function O() {
3581
+ function R() {
3582
3582
  return {
3583
3583
  suggestions: []
3584
3584
  };
@@ -3610,19 +3610,19 @@ class Vt {
3610
3610
  }
3611
3611
  provideCompletionItems(e, n) {
3612
3612
  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];
3613
+ const s = Ke(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), c = a === void 0 ? i[0] : i[a + 1];
3614
3614
  if ([
3615
3615
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3616
3616
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3617
- ...(l == null ? void 0 : l.leadingTrivia) || []
3617
+ ...(c == null ? void 0 : c.leadingTrivia) || []
3618
3618
  ].find((m) => Qt(m) && ge(s, m)))
3619
- return O();
3619
+ return R();
3620
3620
  if (a === void 0)
3621
3621
  return Tt();
3622
3622
  if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3623
- return O();
3623
+ return R();
3624
3624
  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)
3625
+ if (this.compiler.container.scopeKind(s) === O.TOPLEVEL || p instanceof v && p.type && p.type.start <= s && p.type.end >= s)
3626
3626
  return Tt();
3627
3627
  const f = [...this.compiler.container.stack(s)].reverse();
3628
3628
  for (const m of f)
@@ -3659,44 +3659,44 @@ class Vt {
3659
3659
  else {
3660
3660
  if (m instanceof se)
3661
3661
  return Et(this.compiler, s, m);
3662
- if (m instanceof R)
3662
+ if (m instanceof D)
3663
3663
  return Et(this.compiler, s, m);
3664
3664
  if (m instanceof Z)
3665
3665
  return ts(this.compiler, s);
3666
- if (m instanceof w)
3666
+ if (m instanceof y)
3667
3667
  return mt(this.compiler, s, m);
3668
3668
  if (m instanceof v && (m.bodyColon && s >= m.bodyColon.end || m.body && ge(s, m.body)))
3669
3669
  return mt(this.compiler, s, void 0);
3670
3670
  }
3671
- return O();
3671
+ return R();
3672
3672
  }
3673
3673
  }
3674
3674
  function dt(t, e, n) {
3675
3675
  const s = t.container.scopeKind(e);
3676
- if ([D.REF, D.TABLE].includes(s)) {
3676
+ if ([O.REF, O.TABLE].includes(s)) {
3677
3677
  const i = Be(t, e, t.container.element(e), [
3678
3678
  T.Table,
3679
3679
  T.Schema,
3680
3680
  T.Column
3681
3681
  ]);
3682
- return Re(n.op, e) ? Pe(i) : i;
3682
+ return De(n.op, e) ? Pe(i) : i;
3683
3683
  }
3684
- return O();
3684
+ return R();
3685
3685
  }
3686
3686
  function Be(t, e, n, s) {
3687
3687
  var a;
3688
3688
  if (n === void 0)
3689
- return O();
3689
+ return R();
3690
3690
  let i = n;
3691
3691
  const r = { suggestions: [] };
3692
3692
  for (; i; ) {
3693
3693
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3694
- const { symbol: l } = i;
3694
+ const { symbol: c } = i;
3695
3695
  r.suggestions.push(
3696
- ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3696
+ ...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: f }) => ({
3697
3697
  label: p,
3698
3698
  insertText: p,
3699
- insertTextRules: k.KeepWhitespace,
3699
+ insertTextRules: w.KeepWhitespace,
3700
3700
  kind: Ae(f),
3701
3701
  sortText: Ae(f).toString().padStart(2, "0"),
3702
3702
  range: void 0
@@ -3710,9 +3710,9 @@ function Be(t, e, n, s) {
3710
3710
  function ts(t, e) {
3711
3711
  var s;
3712
3712
  switch (t.container.scopeKind(e)) {
3713
- case D.INDEXES:
3713
+ case O.INDEXES:
3714
3714
  return Xt(t, e);
3715
- case D.REF:
3715
+ case O.REF:
3716
3716
  {
3717
3717
  const i = [...t.container.stack(e)];
3718
3718
  for (; i.length > 0; ) {
@@ -3727,13 +3727,13 @@ function ts(t, e) {
3727
3727
  }
3728
3728
  return Ct(t, e);
3729
3729
  }
3730
- return O();
3730
+ return R();
3731
3731
  }
3732
3732
  function Et(t, e, n) {
3733
3733
  const { token: s } = t.container.token(e);
3734
3734
  if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3735
3735
  const i = Nt(t, e);
3736
- return (s == null ? void 0 : s.kind) === u.COMMA && Re(s, e) ? Pe(i) : i;
3736
+ return (s == null ? void 0 : s.kind) === u.COMMA && De(s, e) ? Pe(i) : i;
3737
3737
  }
3738
3738
  if (n.name && n.name.start <= e && n.name.end >= e)
3739
3739
  return Nt(t, e);
@@ -3743,84 +3743,96 @@ function Et(t, e, n) {
3743
3743
  e,
3744
3744
  Te(n.name).unwrap_or("")
3745
3745
  );
3746
- return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? Pe(i) : i;
3746
+ return (s == null ? void 0 : s.kind) === u.COLON && De(s, e) ? Pe(i) : i;
3747
3747
  }
3748
- return O();
3748
+ return R();
3749
3749
  }
3750
3750
  function Nt(t, e) {
3751
3751
  const n = t.container.element(e), s = t.container.scopeKind(e);
3752
3752
  if (n instanceof X)
3753
- return O();
3753
+ return R();
3754
3754
  if (n.body && !ge(e, n.body))
3755
3755
  switch (s) {
3756
- case D.TABLE:
3756
+ case O.TABLE:
3757
3757
  return {
3758
3758
  suggestions: [
3759
3759
  {
3760
3760
  label: "headercolor",
3761
3761
  insertText: "headercolor: ",
3762
3762
  kind: L.Field,
3763
- insertTextRules: k.KeepWhitespace,
3763
+ insertTextRules: w.KeepWhitespace,
3764
3764
  range: void 0
3765
3765
  },
3766
3766
  {
3767
3767
  label: "note",
3768
3768
  insertText: "note: ",
3769
3769
  kind: L.Field,
3770
- insertTextRules: k.KeepWhitespace,
3770
+ insertTextRules: w.KeepWhitespace,
3771
+ range: void 0
3772
+ }
3773
+ ]
3774
+ };
3775
+ case O.TABLEGROUP:
3776
+ return {
3777
+ suggestions: [
3778
+ {
3779
+ label: "note",
3780
+ insertText: "note: ",
3781
+ kind: L.Field,
3782
+ insertTextRules: w.KeepWhitespace,
3771
3783
  range: void 0
3772
3784
  }
3773
3785
  ]
3774
3786
  };
3775
3787
  default:
3776
- return O();
3788
+ return R();
3777
3789
  }
3778
3790
  switch (s) {
3779
- case D.TABLE:
3791
+ case O.TABLE:
3780
3792
  return {
3781
3793
  suggestions: [
3782
3794
  ...["primary key", "null", "not null", "increment", "pk", "unique"].map((i) => ({
3783
3795
  label: i,
3784
3796
  insertText: i,
3785
3797
  kind: L.Property,
3786
- insertTextRules: k.KeepWhitespace,
3798
+ insertTextRules: w.KeepWhitespace,
3787
3799
  range: void 0
3788
3800
  })),
3789
3801
  ...["ref", "default"].map((i) => ({
3790
3802
  label: i,
3791
3803
  insertText: `${i}: `,
3792
3804
  kind: L.Property,
3793
- insertTextRules: k.KeepWhitespace,
3805
+ insertTextRules: w.KeepWhitespace,
3794
3806
  range: void 0
3795
3807
  })),
3796
3808
  {
3797
3809
  label: "note",
3798
3810
  insertText: "note: ",
3799
3811
  kind: L.Property,
3800
- insertTextRules: k.KeepWhitespace,
3812
+ insertTextRules: w.KeepWhitespace,
3801
3813
  range: void 0
3802
3814
  }
3803
3815
  ]
3804
3816
  };
3805
- case D.ENUM:
3817
+ case O.ENUM:
3806
3818
  return {
3807
3819
  suggestions: [
3808
3820
  {
3809
3821
  label: "note",
3810
3822
  insertText: "note: ",
3811
3823
  kind: L.Property,
3812
- insertTextRules: k.KeepWhitespace,
3824
+ insertTextRules: w.KeepWhitespace,
3813
3825
  range: void 0
3814
3826
  }
3815
3827
  ]
3816
3828
  };
3817
- case D.INDEXES:
3829
+ case O.INDEXES:
3818
3830
  return {
3819
3831
  suggestions: [
3820
3832
  ...["unique", "pk"].map((i) => ({
3821
3833
  label: i,
3822
3834
  insertText: i,
3823
- insertTextRules: k.KeepWhitespace,
3835
+ insertTextRules: w.KeepWhitespace,
3824
3836
  kind: L.Property,
3825
3837
  range: void 0
3826
3838
  })),
@@ -3828,23 +3840,23 @@ function Nt(t, e) {
3828
3840
  label: i,
3829
3841
  insertText: `${i}: `,
3830
3842
  kind: L.Property,
3831
- insertTextRules: k.KeepWhitespace,
3843
+ insertTextRules: w.KeepWhitespace,
3832
3844
  range: void 0
3833
3845
  }))
3834
3846
  ]
3835
3847
  };
3836
- case D.REF:
3848
+ case O.REF:
3837
3849
  return {
3838
3850
  suggestions: ["update", "delete"].map((i) => ({
3839
3851
  label: i,
3840
3852
  insertText: `${i}: `,
3841
3853
  kind: L.Property,
3842
- insertTextRules: k.KeepWhitespace,
3854
+ insertTextRules: w.KeepWhitespace,
3843
3855
  range: void 0
3844
3856
  }))
3845
3857
  };
3846
3858
  }
3847
- return O();
3859
+ return R();
3848
3860
  }
3849
3861
  function ns(t, e, n) {
3850
3862
  switch (n == null ? void 0 : n.toLowerCase()) {
@@ -3855,7 +3867,7 @@ function ns(t, e, n) {
3855
3867
  label: s,
3856
3868
  insertText: s,
3857
3869
  kind: L.Value,
3858
- insertTextRules: k.KeepWhitespace,
3870
+ insertTextRules: w.KeepWhitespace,
3859
3871
  range: void 0
3860
3872
  }))
3861
3873
  };
@@ -3865,17 +3877,17 @@ function ns(t, e, n) {
3865
3877
  label: s,
3866
3878
  insertText: `${s}`,
3867
3879
  kind: L.Value,
3868
- insertTextRules: k.KeepWhitespace,
3880
+ insertTextRules: w.KeepWhitespace,
3869
3881
  range: void 0
3870
3882
  }))
3871
3883
  };
3872
3884
  }
3873
- return O();
3885
+ return R();
3874
3886
  }
3875
3887
  function Gt(t, e, n) {
3876
3888
  const s = pe(n).unwrap_or([]);
3877
3889
  if (s.pop(), s.some((r) => !M(r)))
3878
- return O();
3890
+ return R();
3879
3891
  const i = s.map((r) => j(r).unwrap());
3880
3892
  return Fe({
3881
3893
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
@@ -3889,22 +3901,22 @@ function Gt(t, e, n) {
3889
3901
  function mt(t, e, n) {
3890
3902
  var i;
3891
3903
  switch (t.container.scopeKind(e)) {
3892
- case D.TABLE:
3904
+ case O.TABLE:
3893
3905
  return is(t, e, n);
3894
- case D.PROJECT:
3906
+ case O.PROJECT:
3895
3907
  return rs(t, e, n);
3896
- case D.INDEXES:
3908
+ case O.INDEXES:
3897
3909
  return os(t, e);
3898
- case D.ENUM:
3910
+ case O.ENUM:
3899
3911
  return ss(t, e, n);
3900
- case D.REF: {
3912
+ case O.REF: {
3901
3913
  const r = Ct(t, e);
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;
3914
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && De(t.container.token(e).token, e) ? Pe(r) : r;
3903
3915
  }
3904
- case D.TABLEGROUP:
3916
+ case O.TABLEGROUP:
3905
3917
  return as(t);
3906
3918
  default:
3907
- return O();
3919
+ return R();
3908
3920
  }
3909
3921
  }
3910
3922
  function Tt() {
@@ -3912,7 +3924,7 @@ function Tt() {
3912
3924
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3913
3925
  label: t,
3914
3926
  insertText: t,
3915
- insertTextRules: k.KeepWhitespace,
3927
+ insertTextRules: w.KeepWhitespace,
3916
3928
  kind: L.Keyword,
3917
3929
  range: void 0
3918
3930
  }))
@@ -3923,7 +3935,7 @@ function ss(t, e, n) {
3923
3935
  T.Schema,
3924
3936
  T.Table,
3925
3937
  T.Column
3926
- ]) : O();
3938
+ ]) : R();
3927
3939
  }
3928
3940
  function is(t, e, n) {
3929
3941
  if (!(n != null && n.callee))
@@ -3931,7 +3943,7 @@ function is(t, e, n) {
3931
3943
  suggestions: ["Note", "indexes"].map((i) => ({
3932
3944
  label: i,
3933
3945
  insertText: i,
3934
- insertTextRules: k.KeepWhitespace,
3946
+ insertTextRules: w.KeepWhitespace,
3935
3947
  kind: L.Keyword,
3936
3948
  range: void 0
3937
3949
  }))
@@ -3941,26 +3953,26 @@ function is(t, e, n) {
3941
3953
  suggestions: ["Note", "indexes"].map((i) => ({
3942
3954
  label: i,
3943
3955
  insertText: i,
3944
- insertTextRules: k.KeepWhitespace,
3956
+ insertTextRules: w.KeepWhitespace,
3945
3957
  kind: L.Keyword,
3946
3958
  range: void 0
3947
3959
  }))
3948
- } : s === 1 ? cs(t, e) : O();
3960
+ } : s === 1 ? ls(t, e) : R();
3949
3961
  }
3950
3962
  function rs(t, e, n) {
3951
3963
  return n != null && n.callee ? et(e, n) === 0 ? {
3952
3964
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3953
3965
  label: i,
3954
3966
  insertText: i,
3955
- insertTextRules: k.KeepWhitespace,
3967
+ insertTextRules: w.KeepWhitespace,
3956
3968
  kind: L.Keyword,
3957
3969
  range: void 0
3958
3970
  }))
3959
- } : O() : {
3971
+ } : R() : {
3960
3972
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3961
3973
  label: i,
3962
3974
  insertText: i,
3963
- insertTextRules: k.KeepWhitespace,
3975
+ insertTextRules: w.KeepWhitespace,
3964
3976
  kind: L.Keyword,
3965
3977
  range: void 0
3966
3978
  }))
@@ -3974,26 +3986,37 @@ function Ct(t, e) {
3974
3986
  ]);
3975
3987
  }
3976
3988
  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),
3989
+ return {
3990
+ suggestions: [
3991
+ ...Fe({
3992
+ suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3993
+ const n = ie(e).unwrap_or(void 0);
3994
+ if (n === void 0)
3995
+ return [];
3996
+ const { kind: s, name: i } = n;
3997
+ return s !== T.Table && s !== T.Schema ? [] : {
3998
+ label: i,
3999
+ insertText: i,
4000
+ insertTextRules: w.KeepWhitespace,
4001
+ kind: Ae(s),
4002
+ range: void 0
4003
+ };
4004
+ })
4005
+ }).suggestions,
4006
+ ...["Note"].map((e) => ({
4007
+ label: e,
4008
+ insertText: e,
4009
+ insertTextRules: w.KeepWhitespace,
4010
+ kind: L.Keyword,
3988
4011
  range: void 0
3989
- };
3990
- })
3991
- });
4012
+ }))
4013
+ ]
4014
+ };
3992
4015
  }
3993
4016
  function os(t, e) {
3994
4017
  return Xt(t, e);
3995
4018
  }
3996
- function cs(t, e) {
4019
+ function ls(t, e) {
3997
4020
  return {
3998
4021
  suggestions: [
3999
4022
  ...[
@@ -4056,7 +4079,7 @@ function cs(t, e) {
4056
4079
  ].map((n) => ({
4057
4080
  label: n,
4058
4081
  insertText: n,
4059
- insertTextRules: k.KeepWhitespace,
4082
+ insertTextRules: w.KeepWhitespace,
4060
4083
  kind: L.TypeParameter,
4061
4084
  sortText: L.TypeParameter.toString().padStart(2, "0"),
4062
4085
  range: void 0
@@ -4071,18 +4094,18 @@ function cs(t, e) {
4071
4094
  function Xt(t, e) {
4072
4095
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
4073
4096
  if (!((s == null ? void 0 : s.symbol) instanceof At))
4074
- return O();
4097
+ return R();
4075
4098
  const { symbolTable: i } = s.symbol;
4076
4099
  return Fe({
4077
4100
  suggestions: [...i.entries()].flatMap(([r]) => {
4078
4101
  const a = ie(r).unwrap_or(void 0);
4079
4102
  if (a === void 0)
4080
4103
  return [];
4081
- const { name: l } = a;
4104
+ const { name: c } = a;
4082
4105
  return {
4083
- label: l,
4084
- insertText: l,
4085
- insertTextRules: k.KeepWhitespace,
4106
+ label: c,
4107
+ insertText: c,
4108
+ insertTextRules: w.KeepWhitespace,
4086
4109
  kind: Ae(T.Column),
4087
4110
  range: void 0
4088
4111
  };
@@ -4103,9 +4126,9 @@ class $t {
4103
4126
  var a;
4104
4127
  const { uri: s } = e, i = Ke(e, n), r = [...this.compiler.container.stack(i)];
4105
4128
  for (; r.length !== 0; ) {
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;
4129
+ const c = r.pop();
4130
+ if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [Ne.PRIMARY_EXPRESSION, Ne.VARIABLE].includes(c == null ? void 0 : c.kind)) {
4131
+ const { startPos: p, endPos: f } = c.referee.declaration;
4109
4132
  return [
4110
4133
  {
4111
4134
  range: {
@@ -4135,9 +4158,9 @@ class Wt {
4135
4158
  Ne.FUNCTION_APPLICATION,
4136
4159
  Ne.PRIMARY_EXPRESSION
4137
4160
  ].includes(a == null ? void 0 : a.kind)) {
4138
- const { symbol: l } = a;
4139
- if (l != null && l.references.length)
4140
- return l.references.map(({ startPos: p, endPos: f }) => ({
4161
+ const { symbol: c } = a;
4162
+ if (c != null && c.references.length)
4163
+ return c.references.map(({ startPos: p, endPos: f }) => ({
4141
4164
  range: {
4142
4165
  startColumn: p.column + 1,
4143
4166
  startLineNumber: p.line + 1,
@@ -4153,13 +4176,13 @@ class Wt {
4153
4176
  }
4154
4177
  const hs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4155
4178
  __proto__: null,
4156
- CompletionItemInsertTextRule: k,
4179
+ CompletionItemInsertTextRule: w,
4157
4180
  CompletionItemKind: L,
4158
4181
  DBMLCompletionItemProvider: Vt,
4159
4182
  DBMLDefinitionProvider: $t,
4160
4183
  DBMLReferencesProvider: Wt
4161
4184
  }, 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 || {});
4185
+ 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
4186
  class fs {
4164
4187
  constructor() {
4165
4188
  this.source = "", this.cache = new Array(
@@ -4209,26 +4232,26 @@ class fs {
4209
4232
  if (r === -1)
4210
4233
  return [this.parse.ast()];
4211
4234
  const a = n[r].start;
4212
- let l = this.parse.ast();
4213
- const p = [l];
4235
+ let c = this.parse.ast();
4236
+ const p = [c];
4214
4237
  for (; ; ) {
4215
- const E = un(l).find((h) => ge(a, h));
4238
+ const E = un(c).find((h) => ge(a, h));
4216
4239
  if (E === void 0 || E instanceof F)
4217
4240
  break;
4218
- p.push(E), l = E;
4241
+ p.push(E), c = E;
4219
4242
  }
4220
4243
  if ((i == null ? void 0 : i.kind) === u.COLON)
4221
4244
  return p;
4222
4245
  for (; p.length > 0; ) {
4223
4246
  let f = !1;
4224
4247
  const E = it(p);
4225
- if (E instanceof w) {
4248
+ if (E instanceof y) {
4226
4249
  const h = this.parse.source();
4227
4250
  for (let m = E.end; m < e; m += 1)
4228
4251
  h[m] === `
4229
4252
  ` && (p.pop(), f = !0);
4230
4253
  } else
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);
4254
+ 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 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
4255
  if (f) {
4233
4256
  const h = it(p);
4234
4257
  h instanceof v && h.end <= e && p.pop();
@@ -4308,14 +4331,14 @@ class fs {
4308
4331
  if (!((i = r.symbol) != null && i.symbolTable))
4309
4332
  continue;
4310
4333
  const { symbolTable: a } = r.symbol;
4311
- let l = [a], p = [];
4334
+ let c = [a], p = [];
4312
4335
  for (const f of e)
4313
- p = l.flatMap(
4336
+ p = c.flatMap(
4314
4337
  (E) => Zt(f).flatMap((h) => {
4315
4338
  const m = E.get(h), g = ie(h).unwrap_or(void 0);
4316
4339
  return !m || !g ? [] : { ...g, symbol: m };
4317
4340
  })
4318
- ), l = p.flatMap(
4341
+ ), c = p.flatMap(
4319
4342
  (E) => E.symbol.symbolTable ? E.symbol.symbolTable : []
4320
4343
  );
4321
4344
  s.push(...p);
@@ -4342,8 +4365,8 @@ class fs {
4342
4365
  if (r.has(a))
4343
4366
  return r.get(a);
4344
4367
  }
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;
4368
+ const c = n(i);
4369
+ return i !== void 0 ? r instanceof Map ? r.set(a, c) : (this.cache[e] = /* @__PURE__ */ new Map(), this.cache[e].set(a, c)) : this.cache[e] = c, c;
4347
4370
  };
4348
4371
  }
4349
4372
  setSource(e) {