@dbml/parse 3.3.0 → 3.4.1-alpha.0

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.
@@ -36,12 +36,12 @@ function rt(t) {
36
36
  function at(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
- class B {
39
+ class M {
40
40
  constructor(e, n, s, i, r) {
41
41
  this.kind = e, this.startPos = n, this.endPos = s, this.value = i, this.leadingTrivia = [], this.trailingTrivia = [], this.leadingInvalid = [], this.trailingInvalid = [], this.isInvalid = r, this.start = n.offset, this.end = s.offset;
42
42
  }
43
43
  static create(e, n, s, i, r) {
44
- return new B(e, n, s, i, r);
44
+ return new M(e, n, s, i, r);
45
45
  }
46
46
  }
47
47
  function bt(t) {
@@ -81,13 +81,13 @@ class k {
81
81
  constructor(e, n, s) {
82
82
  this.id = e, this.kind = n;
83
83
  const i = s.find((a) => a !== void 0 && !Number.isNaN(a.start));
84
- i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? Lt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof M ? Lt(i) : i.fullStart) : (this.startPos = {
85
85
  offset: NaN,
86
86
  column: NaN,
87
87
  line: NaN
88
88
  }, this.fullStart = NaN);
89
89
  const r = [...s].reverse().find((a) => a !== void 0 && !Number.isNaN(a.end));
90
- r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? It(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof M ? It(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -228,7 +228,7 @@ class J extends k {
228
228
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class me extends k {
231
+ class Te extends k {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
@@ -245,11 +245,11 @@ class D extends k {
245
245
  }
246
246
  class ke extends k {
247
247
  constructor({ pre: e }, n) {
248
- const s = B.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = M.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class ce extends k {
252
+ class le extends k {
253
253
  constructor({ expression: e, indexer: n }, s) {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
@@ -418,13 +418,13 @@ function Ht(t) {
418
418
  function pe(t) {
419
419
  return Ue(t) || Oe(t);
420
420
  }
421
- function lt(t, e) {
421
+ function ct(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]);
425
425
  return n.push(...t.slice(s), ...e.slice(s)), n;
426
426
  }
427
- function Le(t, e) {
427
+ function ge(t, e) {
428
428
  return t >= e.start && t < e.end;
429
429
  }
430
430
  class Jt {
@@ -473,13 +473,13 @@ class nn {
473
473
  this.references = [], this.id = n, this.declaration = e;
474
474
  }
475
475
  }
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_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 || {});
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
477
  class c extends Error {
478
478
  constructor(e, n, s) {
479
479
  super(n), this.code = e, this.diagnostic = n, this.nodeOrToken = s, this.start = s.start, this.end = s.end, this.name = this.constructor.name, Object.setPrototypeOf(this, c.prototype);
480
480
  }
481
481
  }
482
- class F {
482
+ class B {
483
483
  constructor(e, n) {
484
484
  this.value = e, this.errors = n === void 0 ? [] : n;
485
485
  }
@@ -491,14 +491,14 @@ class F {
491
491
  }
492
492
  chain(e) {
493
493
  const n = e(this.value), s = [...this.errors, ...n.errors];
494
- return new F(n.value, s);
494
+ return new B(n.value, s);
495
495
  }
496
496
  map(e) {
497
- return new F(e(this.value), this.errors);
497
+ return new B(e(this.value), this.errors);
498
498
  }
499
499
  }
500
500
  function sn(t, e, n) {
501
- if (!t || !Ee(t) || e.length === 0)
501
+ if (!t || !Ne(t) || e.length === 0)
502
502
  return new v();
503
503
  const s = [...e], i = Ge(t).unwrap(), r = s.pop();
504
504
  if (!(r instanceof ne))
@@ -528,11 +528,11 @@ function sn(t, e, n) {
528
528
  })
529
529
  ) : new v();
530
530
  }
531
- function ct(t) {
531
+ function lt(t) {
532
532
  return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function E(t) {
535
- t && (t instanceof B ? rn(t) : an(t));
535
+ t && (t instanceof M ? rn(t) : an(t));
536
536
  }
537
537
  function rn(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
@@ -566,7 +566,7 @@ function an(t) {
566
566
  E(t.value);
567
567
  else if (t instanceof j)
568
568
  E(t.variable);
569
- else if (t instanceof me)
569
+ else if (t instanceof Te)
570
570
  E(t.literal);
571
571
  else
572
572
  throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
@@ -594,7 +594,7 @@ function on(t) {
594
594
  return U(t.name, t.colon, t.value);
595
595
  if (t instanceof $)
596
596
  return t.identifiers;
597
- if (t instanceof me)
597
+ if (t instanceof Te)
598
598
  return t.literal ? [t.literal] : [];
599
599
  if (t instanceof j)
600
600
  return U(t.variable);
@@ -613,20 +613,20 @@ function on(t) {
613
613
  if (t instanceof P)
614
614
  return U(
615
615
  t.listOpenBracket,
616
- ...lt(t.elementList, t.commaList),
616
+ ...ct(t.elementList, t.commaList),
617
617
  t.listCloseBracket
618
618
  );
619
619
  if (t instanceof Z)
620
620
  return U(
621
621
  t.tupleOpenParen,
622
- ...lt(t.elementList, t.commaList),
622
+ ...ct(t.elementList, t.commaList),
623
623
  t.tupleCloseParen
624
624
  );
625
625
  if (t instanceof J)
626
626
  return U(t.callee, t.argumentList);
627
627
  if (t instanceof D)
628
628
  return U(t.expression);
629
- if (t instanceof ce)
629
+ if (t instanceof le)
630
630
  return U(
631
631
  t.array,
632
632
  t.indexer
@@ -634,16 +634,16 @@ function on(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 v();
637
+ return F(t) ? new S(t.expression.variable) : new v();
638
638
  }
639
639
  function Y(t) {
640
640
  var e;
641
- return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof B && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
641
+ return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof M && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
642
642
  }
643
- function M(t) {
644
- return t instanceof D && t.expression instanceof j && t.expression.variable instanceof B;
643
+ function F(t) {
644
+ return t instanceof D && t.expression instanceof j && t.expression.variable instanceof M;
645
645
  }
646
- function Ee(t) {
646
+ function Ne(t) {
647
647
  var e;
648
648
  return t instanceof D && t.expression instanceof j && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
649
649
  }
@@ -651,13 +651,13 @@ function Je(t) {
651
651
  var e;
652
652
  return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
653
653
  }
654
- function Ne(t) {
654
+ function me(t) {
655
655
  if (t === void 0)
656
656
  return new v();
657
657
  const e = t.identifiers.map((n) => n.value).join(" ");
658
658
  return e === "" ? new v() : new S(e);
659
659
  }
660
- class ln {
660
+ class cn {
661
661
  // list of errors during lexing
662
662
  constructor(e) {
663
663
  this.start = {
@@ -697,7 +697,7 @@ class ln {
697
697
  this.tokens.push(this.createToken(e, n));
698
698
  }
699
699
  createToken(e, n = !1) {
700
- return B.create(
700
+ return M.create(
701
701
  e,
702
702
  this.start,
703
703
  this.current,
@@ -706,7 +706,7 @@ class ln {
706
706
  );
707
707
  }
708
708
  lex() {
709
- return this.scanTokens(), this.tokens.push(B.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
709
+ return this.scanTokens(), this.tokens.push(M.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
710
710
  }
711
711
  scanTokens() {
712
712
  for (; !this.isAtEnd(); ) {
@@ -843,7 +843,7 @@ class ln {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
846
+ a && this.match(n), this.tokens.push(M.create(e, this.start, this.current, l, !1));
847
847
  }
848
848
  singleLineStringLiteral() {
849
849
  this.consumeUntil(u.STRING_LITERAL, "'", {
@@ -934,9 +934,16 @@ class ln {
934
934
  this.addToken(u.COLOR_LITERAL);
935
935
  }
936
936
  escapedString() {
937
+ const e = { column: this.current.column - 1, offset: this.current.offset - 1, line: this.current.line };
937
938
  if (this.isAtEnd())
938
939
  return "\\";
939
940
  switch (this.advance()) {
941
+ case "\r":
942
+ return this.check(`
943
+ `) && this.advance(), "";
944
+ case `
945
+ `:
946
+ return "";
940
947
  case "t":
941
948
  return " ";
942
949
  case "n":
@@ -947,7 +954,7 @@ class ln {
947
954
  case "r":
948
955
  return "\r";
949
956
  case "'":
950
- return "'";
957
+ return this.peek() === "'" && this.peek(1) === "'" ? (this.advance(), this.advance(), "'''") : "'";
951
958
  case '"':
952
959
  return '"';
953
960
  case "0":
@@ -958,22 +965,26 @@ class ln {
958
965
  return "\v";
959
966
  case "f":
960
967
  return "\f";
968
+ case " ":
969
+ return "\\ ";
961
970
  case "u": {
962
- let e = "";
963
- for (let n = 0; n <= 3; n += 1) {
971
+ let n = "";
972
+ for (let s = 0; s <= 3; s += 1) {
964
973
  if (this.isAtEnd() || !pe(this.peek()))
965
- return `\\u${e}`;
966
- e += this.advance();
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`, M.create(u.STRING_LITERAL, e, this.current, `\\u${n}`, !0))), `\\u${n}`;
975
+ n += this.advance();
967
976
  }
968
- return String.fromCharCode(parseInt(e, 16));
977
+ return String.fromCharCode(parseInt(n, 16));
978
+ }
979
+ default: {
980
+ const n = `\\${this.text[this.current.offset - 1]}`;
981
+ return this.errors.push(new c(o.INVALID_ESCAPE_SEQUENCE, `Invalid escape sequence '${n}'`, M.create(u.STRING_LITERAL, e, this.current, n, !0))), n;
969
982
  }
970
- default:
971
- return `\\${this.tokens[this.current.offset - 1]}`;
972
983
  }
973
984
  }
974
985
  }
975
986
  var xe = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(xe || {});
976
- class cn {
987
+ class ln {
977
988
  constructor() {
978
989
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
979
990
  }
@@ -1054,13 +1065,13 @@ class d {
1054
1065
  }
1055
1066
  class hn {
1056
1067
  constructor(e, n) {
1057
- this.current = 0, this.errors = [], this.contextStack = new cn(), this.synchronizeProgram = () => {
1068
+ this.current = 0, this.errors = [], this.contextStack = new ln(), this.synchronizeProgram = () => {
1058
1069
  const s = this.peek();
1059
1070
  s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1060
1071
  }, this.synchronizeElementDeclarationName = () => {
1061
1072
  for (; !this.isAtEnd(); ) {
1062
1073
  const s = this.peek();
1063
- if (ct(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1074
+ if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1064
1075
  break;
1065
1076
  E(s), this.advance();
1066
1077
  }
@@ -1281,7 +1292,7 @@ class hn {
1281
1292
  }
1282
1293
  parse() {
1283
1294
  const e = this.program(), n = this.advance(), s = this.nodeFactory.create(G, { body: e, eof: n });
1284
- return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
1295
+ return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1285
1296
  }
1286
1297
  /* Parsing and synchronizing ProgramNode */
1287
1298
  program() {
@@ -1315,7 +1326,7 @@ class hn {
1315
1326
  throw new d(s.token, n(), s.handlerContext);
1316
1327
  this.synchronizeElementDeclarationName();
1317
1328
  }
1318
- if (ct(this.peek()))
1329
+ if (lt(this.peek()))
1319
1330
  if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1320
1331
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1321
1332
  else
@@ -1437,12 +1448,12 @@ class hn {
1437
1448
  if (Ce(this.previous()))
1438
1449
  break;
1439
1450
  try {
1440
- n = this.nodeFactory.create(ce, {
1451
+ n = this.nodeFactory.create(le, {
1441
1452
  expression: n,
1442
1453
  indexer: this.listExpression()
1443
1454
  });
1444
1455
  } catch (i) {
1445
- throw i instanceof d ? (n = this.nodeFactory.create(ce, {
1456
+ throw i instanceof d ? (n = this.nodeFactory.create(le, {
1446
1457
  expression: n,
1447
1458
  indexer: i.partialNode
1448
1459
  }), new d(i.token, n, i.handlerContext)) : i;
@@ -1561,7 +1572,7 @@ class hn {
1561
1572
  u.NUMERIC_LITERAL
1562
1573
  ))
1563
1574
  return this.nodeFactory.create(D, {
1564
- expression: this.nodeFactory.create(me, { literal: this.previous() })
1575
+ expression: this.nodeFactory.create(Te, { literal: this.previous() })
1565
1576
  });
1566
1577
  if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1567
1578
  return this.nodeFactory.create(D, {
@@ -1713,7 +1724,7 @@ function _e(t) {
1713
1724
  return new v();
1714
1725
  const n = [];
1715
1726
  let s;
1716
- if (!M(I.last(e))) {
1727
+ if (!F(I.last(e))) {
1717
1728
  const i = e.pop();
1718
1729
  if (kt(i))
1719
1730
  s = i.elementList.map(
@@ -1734,7 +1745,7 @@ function _e(t) {
1734
1745
  });
1735
1746
  }
1736
1747
  function X(t) {
1737
- return M(t) ? new S(t.expression.variable.value) : new v();
1748
+ return F(t) ? new S(t.expression.variable.value) : new v();
1738
1749
  }
1739
1750
  function Xe(t) {
1740
1751
  if (ht(t))
@@ -1742,7 +1753,7 @@ function Xe(t) {
1742
1753
  if (t instanceof Z && t.elementList.every(ht)) {
1743
1754
  const e = t.elementList.filter(
1744
1755
  (s) => s instanceof te
1745
- ), n = t.elementList.filter(M);
1756
+ ), n = t.elementList.filter(F);
1746
1757
  return new S({ functional: e, nonFunctional: n });
1747
1758
  }
1748
1759
  return new v();
@@ -1868,7 +1879,7 @@ class Ln {
1868
1879
  validateFields(e) {
1869
1880
  return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1870
1881
  const s = [];
1871
- 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));
1882
+ n.callee && !F(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1872
1883
  const i = [...n.args];
1873
1884
  return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (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;
1874
1885
  });
@@ -1898,7 +1909,7 @@ class Ln {
1898
1909
  });
1899
1910
  }
1900
1911
  registerField(e) {
1901
- if (e.callee && M(e.callee)) {
1912
+ if (e.callee && F(e.callee)) {
1902
1913
  const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
1903
1914
  e.symbol = i;
1904
1915
  const r = this.declarationNode.symbol.symbolTable;
@@ -1967,12 +1978,12 @@ class gn {
1967
1978
  case "unique":
1968
1979
  case "pk":
1969
1980
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1970
- le(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1981
+ ce(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1971
1982
  });
1972
1983
  break;
1973
1984
  case "type":
1974
1985
  a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1975
- M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1986
+ F(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1976
1987
  });
1977
1988
  break;
1978
1989
  default:
@@ -2141,10 +2152,10 @@ class vn {
2141
2152
  }
2142
2153
  }
2143
2154
  function wn(t) {
2144
- if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
2155
+ if (!(F(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
2145
2156
  return !1;
2146
2157
  let e;
2147
- if (t instanceof $ ? e = Ne(t).unwrap_or("") : e = t.expression.variable.value, e)
2158
+ if (t instanceof $ ? e = me(t).unwrap_or("") : e = t.expression.variable.value, e)
2148
2159
  switch (e.toLowerCase()) {
2149
2160
  case "cascade":
2150
2161
  case "no action":
@@ -2168,7 +2179,7 @@ class yn {
2168
2179
  return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2169
2180
  }
2170
2181
  validateName(e) {
2171
- return e ? e instanceof ce ? [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)] : Ze(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)];
2182
+ return e ? e instanceof le ? [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)] : Ze(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)];
2172
2183
  }
2173
2184
  validateAlias(e) {
2174
2185
  return e ? On(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
@@ -2221,13 +2232,13 @@ class yn {
2221
2232
  if (!n.callee)
2222
2233
  return [];
2223
2234
  const s = [];
2224
- 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] && !kn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2235
+ n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), F(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] && !kn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2225
2236
  const i = n.args.slice(1);
2226
2237
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2227
2238
  });
2228
2239
  }
2229
2240
  registerField(e) {
2230
- if (e.callee && M(e.callee)) {
2241
+ if (e.callee && F(e.callee)) {
2231
2242
  const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(en, { declaration: e });
2232
2243
  e.symbol = i;
2233
2244
  const r = this.declarationNode.symbol.symbolTable;
@@ -2244,7 +2255,7 @@ class yn {
2244
2255
  }
2245
2256
  // This is needed to support legacy inline settings
2246
2257
  validateFieldSetting(e) {
2247
- if (!e.slice(0, -1).every(Ee) || !e.slice(-1).every((p) => Ee(p) || p instanceof P))
2258
+ if (!e.slice(0, -1).every(Ne) || !e.slice(-1).every((p) => Ne(p) || p instanceof P))
2248
2259
  return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2249
2260
  if (e.length === 0)
2250
2261
  return [];
@@ -2276,34 +2287,34 @@ class yn {
2276
2287
  break;
2277
2288
  case "primary key":
2278
2289
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2279
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2290
+ ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2280
2291
  });
2281
2292
  break;
2282
2293
  case "pk":
2283
2294
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2284
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2295
+ f instanceof se && !ce(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2285
2296
  });
2286
2297
  break;
2287
2298
  case "not null":
2288
2299
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2289
2300
  const T = r.null || [];
2290
2301
  h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2291
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2302
+ ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2292
2303
  });
2293
2304
  break;
2294
2305
  case "null":
2295
2306
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2296
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2307
+ ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2297
2308
  });
2298
2309
  break;
2299
2310
  case "unique":
2300
2311
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2301
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2312
+ f instanceof se && !ce(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2302
2313
  });
2303
2314
  break;
2304
2315
  case "increment":
2305
2316
  h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2306
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2317
+ f instanceof se && !ce(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2307
2318
  });
2308
2319
  break;
2309
2320
  case "default":
@@ -2331,14 +2342,14 @@ class yn {
2331
2342
  }
2332
2343
  }
2333
2344
  function kn(t) {
2334
- if (!(t instanceof J || Je(t) || t instanceof D || t instanceof ce))
2345
+ if (!(t instanceof J || Je(t) || t instanceof D || t instanceof le))
2335
2346
  return !1;
2336
2347
  if (t instanceof J) {
2337
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ee(n)))
2348
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ne(n)))
2338
2349
  return !1;
2339
2350
  t = t.callee;
2340
2351
  }
2341
- for (; t instanceof ce; ) {
2352
+ for (; t instanceof le; ) {
2342
2353
  if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ue(n.name)))
2343
2354
  return !1;
2344
2355
  t = t.array;
@@ -2403,7 +2414,7 @@ class Sn {
2403
2414
  });
2404
2415
  }
2405
2416
  registerField(e) {
2406
- if (e.callee && M(e.callee)) {
2417
+ if (e.callee && F(e.callee)) {
2407
2418
  const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(nn, { declaration: e });
2408
2419
  e.symbol = i;
2409
2420
  const r = this.declarationNode.symbol.symbolTable;
@@ -2473,7 +2484,7 @@ function yt(t) {
2473
2484
  }
2474
2485
  function Rn(t) {
2475
2486
  var n;
2476
- if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2487
+ if (!(t instanceof D) || !(t.expression instanceof Te) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2477
2488
  return !1;
2478
2489
  const e = t.expression.literal.value;
2479
2490
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
@@ -2483,16 +2494,16 @@ function Rn(t) {
2483
2494
  return !1;
2484
2495
  return !0;
2485
2496
  }
2486
- function le(t) {
2497
+ function ce(t) {
2487
2498
  return t === void 0;
2488
2499
  }
2489
2500
  function Dn(t) {
2490
2501
  var e;
2491
- return !!(Y(t) || ue(t) || Ee(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && wt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
2502
+ return !!(Y(t) || ue(t) || Ne(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && wt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
2492
2503
  }
2493
2504
  function ue(t) {
2494
2505
  var e;
2495
- return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2506
+ return t instanceof D && t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2496
2507
  }
2497
2508
  function Pn(t) {
2498
2509
  var n;
@@ -2502,13 +2513,13 @@ function Pn(t) {
2502
2513
  return e !== void 0 && e.length > 0;
2503
2514
  }
2504
2515
  function kt(t) {
2505
- return t instanceof Z && t.elementList.every(M);
2516
+ return t instanceof Z && t.elementList.every(F);
2506
2517
  }
2507
2518
  function W(t) {
2508
2519
  var s;
2509
2520
  const e = {}, n = [];
2510
2521
  if (!t)
2511
- return new F({});
2522
+ return new B({});
2512
2523
  for (const i of t.elementList) {
2513
2524
  if (!i.name)
2514
2525
  continue;
@@ -2516,10 +2527,10 @@ function W(t) {
2516
2527
  n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2517
2528
  continue;
2518
2529
  }
2519
- const r = (s = Ne(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2530
+ const r = (s = me(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2520
2531
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2521
2532
  }
2522
- return new F(e, n);
2533
+ return new B(e, n);
2523
2534
  }
2524
2535
  class ft {
2525
2536
  constructor(e, n) {
@@ -2540,7 +2551,7 @@ class ft {
2540
2551
  e.push(...r.validate());
2541
2552
  });
2542
2553
  const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
2543
- return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
2554
+ return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2544
2555
  }
2545
2556
  }
2546
2557
  class ae {
@@ -2555,7 +2566,7 @@ class ae {
2555
2566
  for (const s of e.elementList) {
2556
2567
  if (s.name instanceof D)
2557
2568
  continue;
2558
- const i = Ne(s.name).unwrap_or(void 0);
2569
+ const i = me(s.name).unwrap_or(void 0);
2559
2570
  if (!i)
2560
2571
  continue;
2561
2572
  const r = n[i.toLowerCase()];
@@ -2603,7 +2614,7 @@ class ae {
2603
2614
  bindFragments(e, n) {
2604
2615
  if (e.length === 0)
2605
2616
  return;
2606
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2617
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !F(f)), l = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2607
2618
  0,
2608
2619
  r === -1 ? void 0 : r
2609
2620
  );
@@ -2839,7 +2850,7 @@ class $n {
2839
2850
  const n = xt(e);
2840
2851
  new n(e, this.errors).bind();
2841
2852
  }
2842
- return new F(this.ast, this.errors);
2853
+ return new B(this.ast, this.errors);
2843
2854
  }
2844
2855
  }
2845
2856
  class Wn {
@@ -2860,7 +2871,7 @@ class jn {
2860
2871
  }
2861
2872
  // For invoking the validator only
2862
2873
  validate() {
2863
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
2874
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2864
2875
  }
2865
2876
  }
2866
2877
  function pt(t, e) {
@@ -2911,7 +2922,7 @@ function $e(t) {
2911
2922
  const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2912
2923
  return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
2913
2924
  }
2914
- function Te(t) {
2925
+ function be(t) {
2915
2926
  const e = C(t).unwrap();
2916
2927
  return {
2917
2928
  name: e.pop(),
@@ -2937,10 +2948,10 @@ function Dt(t, e) {
2937
2948
  const n = t.id, s = e.id;
2938
2949
  return n === s;
2939
2950
  }
2940
- function ge(t) {
2951
+ function Ee(t) {
2941
2952
  const e = t.split(`
2942
- `), n = e.filter((i) => i.trimStart()), s = Math.min(...n.map((i) => i.length - i.trimStart().length));
2943
- return e.map((i) => i.slice(s)).join(`
2953
+ `), n = e.slice(e.findIndex((r) => r.trimStart() !== "")), s = n.filter((r) => r.trimStart()), i = Math.min(...s.map((r) => r.length - r.trimStart().length));
2954
+ return n.map((r) => r.slice(i)).join(`
2944
2955
  `);
2945
2956
  }
2946
2957
  class Pt {
@@ -2967,7 +2978,7 @@ class Pt {
2967
2978
  }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2968
2979
  }
2969
2980
  interpretName(e) {
2970
- const { name: n, schemaName: s } = Te(e);
2981
+ const { name: n, schemaName: s } = be(e);
2971
2982
  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, []);
2972
2983
  }
2973
2984
  interpretAlias(e) {
@@ -2989,7 +3000,7 @@ class Pt {
2989
3000
  this.table.headerColor = (i = n.headercolor) != null && i.length ? Ot((a = (r = n.headercolor) == null ? void 0 : r.at(0)) == null ? void 0 : a.value) : void 0;
2990
3001
  const [s] = n.note || [];
2991
3002
  return this.table.note = s && {
2992
- value: Q(s == null ? void 0 : s.value).map(ge).unwrap(),
3003
+ value: Q(s == null ? void 0 : s.value).map(Ee).unwrap(),
2993
3004
  token: x(s)
2994
3005
  }, [];
2995
3006
  }
@@ -3003,7 +3014,7 @@ class Pt {
3003
3014
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3004
3015
  case "note":
3005
3016
  return this.table.note = {
3006
- value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(ge).unwrap(),
3017
+ value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ee).unwrap(),
3007
3018
  token: x(n)
3008
3019
  }, [];
3009
3020
  case "indexes":
@@ -3027,11 +3038,11 @@ class Pt {
3027
3038
  s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = zn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3028
3039
  const K = (g = _.note) == null ? void 0 : g.at(0);
3029
3040
  s.note = K && {
3030
- value: Q(K.value).map(ge).unwrap(),
3041
+ value: Q(K.value).map(Ee).unwrap(),
3031
3042
  token: x(K)
3032
3043
  };
3033
- const be = _.ref || [];
3034
- s.inline_refs = be.flatMap((z) => {
3044
+ const Ie = _.ref || [];
3045
+ s.inline_refs = Ie.flatMap((z) => {
3035
3046
  const [nt] = $e(z.value.expression);
3036
3047
  if (Dt(nt, e.symbol))
3037
3048
  return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
@@ -3047,29 +3058,29 @@ class Pt {
3047
3058
  token: x(z)
3048
3059
  };
3049
3060
  } else if (ee.length === 2) {
3050
- const [oe, Ie] = ee;
3061
+ const [oe, Le] = ee;
3051
3062
  fe = {
3052
3063
  schemaName: null,
3053
3064
  tableName: oe,
3054
- fieldNames: [Ie],
3065
+ fieldNames: [Le],
3055
3066
  relation: ye.value,
3056
3067
  token: x(z)
3057
3068
  };
3058
3069
  } else if (ee.length === 3) {
3059
- const [oe, Ie, it] = ee;
3070
+ const [oe, Le, it] = ee;
3060
3071
  fe = {
3061
3072
  schemaName: oe,
3062
- tableName: Ie,
3073
+ tableName: Le,
3063
3074
  fieldNames: [it],
3064
3075
  relation: ye.value,
3065
3076
  token: x(z)
3066
3077
  };
3067
3078
  } else {
3068
3079
  n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3069
- const oe = ee.pop(), Ie = ee.pop();
3080
+ const oe = ee.pop(), Le = ee.pop();
3070
3081
  fe = {
3071
3082
  schemaName: ee.join("."),
3072
- tableName: Ie,
3083
+ tableName: Le,
3073
3084
  fieldNames: [oe],
3074
3085
  relation: ye.value,
3075
3086
  token: x(z)
@@ -3106,12 +3117,12 @@ class Pt {
3106
3117
  }).forEach((g) => {
3107
3118
  const { functional: _, nonFunctional: K } = Xe(g).unwrap();
3108
3119
  s.columns.push(
3109
- ..._.map((be) => ({
3110
- value: be.value.value,
3120
+ ..._.map((Ie) => ({
3121
+ value: Ie.value.value,
3111
3122
  type: "expression"
3112
3123
  })),
3113
- ...K.map((be) => ({
3114
- value: V(be).unwrap(),
3124
+ ...K.map((Ie) => ({
3125
+ value: V(Ie).unwrap(),
3115
3126
  type: "column"
3116
3127
  }))
3117
3128
  );
@@ -3150,17 +3161,17 @@ function Yn(t) {
3150
3161
  let e = null;
3151
3162
  t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : Y(r) ? Q(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3152
3163
  let n = "";
3153
- for (; t instanceof ce; )
3164
+ for (; t instanceof le; )
3154
3165
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3155
- const { name: s, schemaName: i } = Te(t);
3156
- return i.length > 1 ? new F(
3166
+ const { name: s, schemaName: i } = be(t);
3167
+ return i.length > 1 ? new B(
3157
3168
  {
3158
3169
  schemaName: i.length === 0 ? null : i[0],
3159
3170
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3160
3171
  args: e
3161
3172
  },
3162
3173
  [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3163
- ) : new F({
3174
+ ) : new B({
3164
3175
  schemaName: i.length === 0 ? null : i[0],
3165
3176
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3166
3177
  args: e
@@ -3179,7 +3190,7 @@ function zn(t) {
3179
3190
  type: "number",
3180
3191
  value: Number.parseFloat(t.expression.literal.value)
3181
3192
  };
3182
- if (Ee(t))
3193
+ if (Ne(t))
3183
3194
  return {
3184
3195
  value: t.expression.variable.value.toLowerCase(),
3185
3196
  type: "boolean"
@@ -3211,7 +3222,7 @@ class Qn {
3211
3222
  ];
3212
3223
  }
3213
3224
  interpretName(e) {
3214
- const { name: n } = Te(e);
3225
+ const { name: n } = be(e);
3215
3226
  return this.note.name = n, [];
3216
3227
  }
3217
3228
  interpretSettingList(e) {
@@ -3227,7 +3238,7 @@ class Qn {
3227
3238
  }
3228
3239
  interpretNote(e) {
3229
3240
  const n = I.get(e, "callee.expression.literal.value", "");
3230
- return this.note.content = ge(n), [];
3241
+ return this.note.content = Ee(n), [];
3231
3242
  }
3232
3243
  }
3233
3244
  class Ut {
@@ -3257,9 +3268,9 @@ class Ut {
3257
3268
  ];
3258
3269
  if (e.args[0]) {
3259
3270
  const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
3260
- this.ref.onDelete = _ instanceof $ ? Ne(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
3271
+ this.ref.onDelete = _ instanceof $ ? me(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
3261
3272
  const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
3262
- this.ref.onUpdate = K instanceof $ ? Ne(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
3273
+ this.ref.onUpdate = K instanceof $ ? me(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
3263
3274
  }
3264
3275
  const p = St(n);
3265
3276
  return this.ref.endpoints = [
@@ -3288,7 +3299,7 @@ class Mt {
3288
3299
  ), e;
3289
3300
  }
3290
3301
  interpretName(e) {
3291
- const n = [], { name: s, schemaName: i } = Te(e);
3302
+ const n = [], { name: s, schemaName: i } = be(e);
3292
3303
  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;
3293
3304
  }
3294
3305
  interpretBody(e) {
@@ -3317,7 +3328,7 @@ class Ft {
3317
3328
  return this.enum.token = x(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3318
3329
  }
3319
3330
  interpretName(e) {
3320
- const { name: n, schemaName: s } = Te(e);
3331
+ const { name: n, schemaName: s } = be(e);
3321
3332
  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, []);
3322
3333
  }
3323
3334
  interpretBody(e) {
@@ -3327,7 +3338,7 @@ class Ft {
3327
3338
  i.token = x(s), i.name = X(s.callee).unwrap();
3328
3339
  const a = (l = W(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3329
3340
  return i.note = a && {
3330
- value: Q(a.value).map(ge).unwrap(),
3341
+ value: Q(a.value).map(Ee).unwrap(),
3331
3342
  token: x(a)
3332
3343
  }, this.enum.values.push(i), [];
3333
3344
  });
@@ -3343,7 +3354,7 @@ class qn {
3343
3354
  interpretName(e) {
3344
3355
  if (!e)
3345
3356
  return this.project.name = null, [];
3346
- const { name: n } = Te(e);
3357
+ const { name: n } = be(e);
3347
3358
  return this.project.name = n, [];
3348
3359
  }
3349
3360
  interpretBody(e) {
@@ -3369,7 +3380,7 @@ class qn {
3369
3380
  }
3370
3381
  case "note":
3371
3382
  return this.project.note = {
3372
- value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
3383
+ value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ee).unwrap(),
3373
3384
  token: x(s)
3374
3385
  }, [];
3375
3386
  default:
@@ -3412,7 +3423,7 @@ class Hn {
3412
3423
  return [];
3413
3424
  }
3414
3425
  });
3415
- return new F(Jn(this.env), e);
3426
+ return new B(Jn(this.env), e);
3416
3427
  }
3417
3428
  }
3418
3429
  function Jn(t) {
@@ -3496,11 +3507,11 @@ class Bt {
3496
3507
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3497
3508
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3498
3509
  ...(l == null ? void 0 : l.leadingTrivia) || []
3499
- ].find((N) => jt(N) && Le(s, N)))
3510
+ ].find((N) => jt(N) && ge(s, N)))
3500
3511
  return O();
3501
3512
  if (a === void 0)
3502
3513
  return Tt();
3503
- if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
3514
+ if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && ge(s, r))
3504
3515
  return O();
3505
3516
  const p = this.compiler.container.element(s);
3506
3517
  if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
@@ -3546,7 +3557,7 @@ class Bt {
3546
3557
  return Zn(this.compiler, s);
3547
3558
  if (N instanceof w)
3548
3559
  return mt(this.compiler, s, N);
3549
- if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
3560
+ if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && ge(s, N.body)))
3550
3561
  return mt(this.compiler, s, void 0);
3551
3562
  }
3552
3563
  return O();
@@ -3622,7 +3633,7 @@ function Et(t, e, n) {
3622
3633
  const i = Kn(
3623
3634
  t,
3624
3635
  e,
3625
- Ne(n.name).unwrap()
3636
+ me(n.name).unwrap()
3626
3637
  );
3627
3638
  return (s == null ? void 0 : s.kind) === u.COLON && Re(s, e) ? De(i) : i;
3628
3639
  }
@@ -3632,7 +3643,7 @@ function Nt(t, e) {
3632
3643
  const n = t.container.element(e), s = t.container.scopeKind(e);
3633
3644
  if (n instanceof G)
3634
3645
  return O();
3635
- if (n.body && !Le(e, n.body))
3646
+ if (n.body && !ge(e, n.body))
3636
3647
  switch (s) {
3637
3648
  case R.TABLE:
3638
3649
  return {
@@ -3755,7 +3766,7 @@ function Kn(t, e, n) {
3755
3766
  }
3756
3767
  function Vt(t, e, n) {
3757
3768
  const s = he(n).unwrap_or([]);
3758
- if (s.pop(), s.some((r) => !M(r)))
3769
+ if (s.pop(), s.some((r) => !F(r)))
3759
3770
  return O();
3760
3771
  const i = s.map((r) => X(r).unwrap());
3761
3772
  return Fe({
@@ -4032,7 +4043,7 @@ class $t {
4032
4043
  return [];
4033
4044
  }
4034
4045
  }
4035
- const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4046
+ const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4036
4047
  __proto__: null,
4037
4048
  CompletionItemInsertTextRule: y,
4038
4049
  CompletionItemKind: L,
@@ -4041,7 +4052,7 @@ const ls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4041
4052
  DBMLReferencesProvider: $t
4042
4053
  }, Symbol.toStringTag, { value: "Module" }));
4043
4054
  var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
4044
- class cs {
4055
+ class ls {
4045
4056
  constructor() {
4046
4057
  this.source = "", this.cache = new Array(
4047
4058
  16
@@ -4061,7 +4072,7 @@ class cs {
4061
4072
  _: this.createQuery(
4062
4073
  0,
4063
4074
  () => {
4064
- const e = new ln(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new jn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4075
+ const e = new cn(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new jn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4065
4076
  return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Hn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4066
4077
  }
4067
4078
  ),
@@ -4099,8 +4110,8 @@ class cs {
4099
4110
  let a = this.parse.ast();
4100
4111
  const l = [a];
4101
4112
  for (; ; ) {
4102
- const h = on(a).find((T) => Le(r, T));
4103
- if (h === void 0 || h instanceof B)
4113
+ const h = on(a).find((T) => ge(r, T));
4114
+ if (h === void 0 || h instanceof M)
4104
4115
  break;
4105
4116
  l.push(h), a = h;
4106
4117
  }
@@ -4248,7 +4259,7 @@ class cs {
4248
4259
  }
4249
4260
  }
4250
4261
  export {
4251
- cs as Compiler,
4262
+ ls as Compiler,
4252
4263
  os as serialize,
4253
- ls as services
4264
+ cs as services
4254
4265
  };