@dbml/parse 3.4.1-alpha.0 → 3.4.1-project-token.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.
@@ -1,6 +1,6 @@
1
1
  import I from "lodash";
2
2
  var u = /* @__PURE__ */ ((t) => (t.SPACE = "<space>", t.TAB = "<tab>", t.NEWLINE = "<newline>", t.COMMA = "<comma>", t.LPAREN = "<lparen>", t.RPAREN = "<rparen>", t.LBRACE = "<lbrace>", t.RBRACE = "<rbrace>", t.LBRACKET = "<lbracket>", t.RBRACKET = "<rbracket>", t.LANGLE = "<langle>", t.RANGLE = "<rangle>", t.OP = "<op>", t.EOF = "<eof>", t.NUMERIC_LITERAL = "<number>", t.STRING_LITERAL = "<string>", t.COLOR_LITERAL = "<color>", t.FUNCTION_EXPRESSION = "<function-expression>", t.QUOTED_STRING = "<variable>", t.IDENTIFIER = "<identifier>", t.SEMICOLON = "<semicolon>", t.COLON = "<colon>", t.SINGLE_LINE_COMMENT = "<single-line-comment>", t.MULTILINE_COMMENT = "<multiline-comment>", t))(u || {});
3
- function Wt(t) {
3
+ function jt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -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 M {
39
+ class F {
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 M(e, n, s, i, r);
44
+ return new F(e, n, s, i, r);
45
45
  }
46
46
  }
47
47
  function bt(t) {
@@ -59,7 +59,7 @@ function It(t) {
59
59
  function Lt(t) {
60
60
  return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
61
61
  }
62
- function jt(t) {
62
+ function Wt(t) {
63
63
  return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
@@ -75,19 +75,19 @@ class Yt {
75
75
  return this.id++;
76
76
  }
77
77
  }
78
- class k {
78
+ class x {
79
79
  // The symbol that this syntax node refers to
80
80
  // args must be passed in order of appearance in the node
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 M ? Lt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof F ? 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 M ? It(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof F ? It(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -95,12 +95,12 @@ class k {
95
95
  }
96
96
  }
97
97
  var de = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(de || {});
98
- class G extends k {
98
+ class G extends x {
99
99
  constructor({ body: e = [], eof: n }, s) {
100
100
  super(s, "<program>", [...e, n]), this.body = e, this.eof = n;
101
101
  }
102
102
  }
103
- class A extends k {
103
+ class A extends x {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -108,7 +108,7 @@ class A extends k {
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,18 +117,18 @@ class A extends k {
117
117
  i,
118
118
  r,
119
119
  a,
120
- l
121
- ]), l && a && !(l instanceof w || l instanceof A))
120
+ c
121
+ ]), c && a && !(c instanceof w || c instanceof A))
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
- class $ extends k {
126
+ class $ extends x {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class se extends k {
131
+ class se extends x {
132
132
  constructor({
133
133
  name: e,
134
134
  colon: n,
@@ -137,12 +137,12 @@ class se extends k {
137
137
  super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
138
138
  }
139
139
  }
140
- class q extends k {
140
+ class q extends x {
141
141
  constructor({ op: e, expression: n }, s) {
142
142
  super(s, "<prefix-expression>", [e, n]), this.op = e, this.expression = n;
143
143
  }
144
144
  }
145
- class H extends k {
145
+ class H extends x {
146
146
  constructor({
147
147
  op: e,
148
148
  leftExpression: n,
@@ -151,22 +151,22 @@ class H extends k {
151
151
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
152
152
  }
153
153
  }
154
- class Pe extends k {
154
+ class Pe extends x {
155
155
  constructor({ op: e, expression: n }, s) {
156
156
  super(s, "<postfix-expression>", [n, e]), this.op = e, this.expression = n;
157
157
  }
158
158
  }
159
- class te extends k {
159
+ class te extends x {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class w extends k {
164
+ class w extends x {
165
165
  constructor({ callee: e, args: n = [] }, s) {
166
166
  super(s, "<function-application>", [e, ...n]), this.callee = e, this.args = n;
167
167
  }
168
168
  }
169
- class ne extends k {
169
+ class ne extends x {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class ne extends k {
175
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
- class P extends k {
178
+ class P extends x {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -189,7 +189,7 @@ class P extends k {
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
- class Z extends k {
192
+ class Z extends x {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -203,7 +203,7 @@ class Z extends k {
203
203
  ]), this.tupleOpenParen = e, this.elementList = n, this.commaList = s, this.tupleCloseParen = i;
204
204
  }
205
205
  }
206
- class We extends Z {
206
+ class je extends Z {
207
207
  constructor({
208
208
  groupOpenParen: e,
209
209
  expression: n,
@@ -220,7 +220,7 @@ class We extends Z {
220
220
  ), this.kind = "<group-expression>";
221
221
  }
222
222
  }
223
- class J extends k {
223
+ class J extends x {
224
224
  constructor({
225
225
  callee: e,
226
226
  argumentList: n
@@ -228,28 +228,28 @@ class J extends k {
228
228
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class Te extends k {
231
+ class Te extends x {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class j extends k {
236
+ class W extends x {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class D extends k {
241
+ class D extends x {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class ke extends k {
246
+ class ke extends x {
247
247
  constructor({ pre: e }, n) {
248
- const s = M.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = F.create(u.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class le extends k {
252
+ class le extends x {
253
253
  constructor({ expression: e, indexer: n }, s) {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
@@ -335,7 +335,7 @@ class v {
335
335
  }
336
336
  }
337
337
  var m = /* @__PURE__ */ ((t) => (t.Schema = "Schema", t.Table = "Table", t.Column = "Column", t.TableGroup = "TableGroup", t.TableGroupField = "TableGroup field", t.Enum = "Enum", t.EnumField = "Enum field", t.Note = "Note", t))(m || {});
338
- function je(t) {
338
+ function We(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
341
  function Se(t) {
@@ -368,7 +368,7 @@ function Ve(t, e) {
368
368
  case "Enum field":
369
369
  return Qe(t);
370
370
  case "Schema":
371
- return je(t);
371
+ return We(t);
372
372
  case "Table":
373
373
  return Se(t);
374
374
  case "TableGroup":
@@ -395,7 +395,7 @@ function Qt(t) {
395
395
  }
396
396
  function qt(t) {
397
397
  return [
398
- je,
398
+ We,
399
399
  Se,
400
400
  ze,
401
401
  qe,
@@ -474,9 +474,9 @@ class nn {
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 B {
@@ -532,7 +532,7 @@ function lt(t) {
532
532
  return t.kind === u.IDENTIFIER && t.value === "as";
533
533
  }
534
534
  function E(t) {
535
- t && (t instanceof M ? rn(t) : an(t));
535
+ t && (t instanceof F ? rn(t) : an(t));
536
536
  }
537
537
  function rn(t) {
538
538
  t.kind !== u.EOF && (t.isInvalid = !0);
@@ -564,12 +564,12 @@ function an(t) {
564
564
  E(t.expression);
565
565
  else if (t instanceof te)
566
566
  E(t.value);
567
- else if (t instanceof j)
567
+ else if (t instanceof W)
568
568
  E(t.variable);
569
569
  else if (t instanceof Te)
570
570
  E(t.literal);
571
571
  else
572
- throw t instanceof We ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
572
+ throw t instanceof je ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
573
573
  }
574
574
  function vt(t) {
575
575
  return !!(t != null && t.isInvalid);
@@ -596,7 +596,7 @@ function on(t) {
596
596
  return t.identifiers;
597
597
  if (t instanceof Te)
598
598
  return t.literal ? [t.literal] : [];
599
- if (t instanceof j)
599
+ if (t instanceof W)
600
600
  return U(t.variable);
601
601
  if (t instanceof q)
602
602
  return U(t.op, t.expression);
@@ -631,25 +631,25 @@ function on(t) {
631
631
  t.array,
632
632
  t.indexer
633
633
  );
634
- throw t instanceof We ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
634
+ throw t instanceof je ? 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 F(t) ? new S(t.expression.variable) : new v();
637
+ return M(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 M && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof Te && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
641
+ return t instanceof D && (t.expression instanceof W && t.expression.variable instanceof F && 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 F(t) {
644
- return t instanceof D && t.expression instanceof j && t.expression.variable instanceof M;
643
+ function M(t) {
644
+ return t instanceof D && t.expression instanceof W && t.expression.variable instanceof F;
645
645
  }
646
646
  function Ne(t) {
647
647
  var e;
648
- return t instanceof D && t.expression instanceof j && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
648
+ return t instanceof D && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
649
649
  }
650
650
  function Je(t) {
651
651
  var e;
652
- return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
652
+ return t instanceof H && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
653
653
  }
654
654
  function me(t) {
655
655
  if (t === void 0)
@@ -697,7 +697,7 @@ class cn {
697
697
  this.tokens.push(this.createToken(e, n));
698
698
  }
699
699
  createToken(e, n = !1) {
700
- return M.create(
700
+ return F.create(
701
701
  e,
702
702
  this.start,
703
703
  this.current,
@@ -706,7 +706,7 @@ class cn {
706
706
  );
707
707
  }
708
708
  lex() {
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);
709
+ return this.scanTokens(), this.tokens.push(F.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(); ) {
@@ -780,7 +780,7 @@ class cn {
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)
@@ -795,7 +795,7 @@ class cn {
795
795
  let e = !0, n = [], s;
796
796
  const i = [];
797
797
  for (const r of this.tokens)
798
- Wt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
798
+ jt(r) ? (n.push(r), r.kind === u.NEWLINE && s && (s.trailingTrivia = n, e = !0, s = void 0, n = [])) : (e ? r.leadingTrivia = n : s.trailingTrivia = n, i.push(r), n = [], s = r, e = !1);
799
799
  this.tokens = i;
800
800
  }
801
801
  gatherInvalid() {
@@ -820,14 +820,14 @@ class cn {
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 cn {
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 cn {
843
843
  );
844
844
  return;
845
845
  }
846
- a && this.match(n), this.tokens.push(M.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, "'", {
@@ -920,7 +920,7 @@ class cn {
920
920
  for (; !this.isAtEnd() && (this.check(".") || pe(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() && pe(this.peek()); )
926
926
  this.advance();
@@ -971,15 +971,13 @@ class cn {
971
971
  let n = "";
972
972
  for (let s = 0; s <= 3; s += 1) {
973
973
  if (this.isAtEnd() || !pe(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`, M.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));
978
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;
982
- }
979
+ default:
980
+ return this.text[this.current.offset - 1];
983
981
  }
984
982
  }
985
983
  }
@@ -1122,7 +1120,7 @@ class hn {
1122
1120
  E(s), this.advance();
1123
1121
  }
1124
1122
  }, this.tupleExpression = this.contextStack.withContextDo(xe.GroupExpression, () => {
1125
- const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(We, {
1123
+ const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(je, {
1126
1124
  groupOpenParen: s.tupleOpenParen,
1127
1125
  groupCloseParen: s.tupleCloseParen,
1128
1126
  expression: s.elementList[0]
@@ -1152,7 +1150,7 @@ class hn {
1152
1150
  } catch (a) {
1153
1151
  if (!(a instanceof d))
1154
1152
  throw a;
1155
- if (a.partialNode instanceof k && s.elementList.push(a.partialNode), !this.canHandle(a))
1153
+ if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1156
1154
  throw new d(a.token, r(), a.handlerContext);
1157
1155
  this.synchronizeTuple();
1158
1156
  }
@@ -1200,7 +1198,7 @@ class hn {
1200
1198
  } catch (r) {
1201
1199
  if (!(r instanceof d))
1202
1200
  throw r;
1203
- if (r.partialNode instanceof k && s.elementList.push(r.partialNode), !this.canHandle(r))
1201
+ if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1204
1202
  throw new d(r.token, i(), r.handlerContext);
1205
1203
  this.synchronizeList();
1206
1204
  }
@@ -1382,7 +1380,7 @@ class hn {
1382
1380
  }
1383
1381
  try {
1384
1382
  const s = this.expression();
1385
- s instanceof A ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1383
+ s instanceof A ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1386
1384
  } catch (s) {
1387
1385
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1388
1386
  }
@@ -1478,12 +1476,12 @@ class hn {
1478
1476
  op: i,
1479
1477
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1480
1478
  });
1481
- } catch (l) {
1482
- throw l instanceof d ? (n = this.nodeFactory.create(H, {
1479
+ } catch (c) {
1480
+ throw c instanceof d ? (n = this.nodeFactory.create(H, {
1483
1481
  leftExpression: n,
1484
1482
  op: i,
1485
- rightExpression: l.partialNode
1486
- }), new d(l.token, n, l.handlerContext)) : l;
1483
+ rightExpression: c.partialNode
1484
+ }), new d(c.token, n, c.handlerContext)) : c;
1487
1485
  }
1488
1486
  }
1489
1487
  } else
@@ -1576,12 +1574,12 @@ class hn {
1576
1574
  });
1577
1575
  if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1578
1576
  return this.nodeFactory.create(D, {
1579
- expression: this.nodeFactory.create(j, { variable: this.previous() })
1577
+ expression: this.nodeFactory.create(W, { variable: this.previous() })
1580
1578
  });
1581
1579
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1582
1580
  this.peek(),
1583
1581
  this.nodeFactory.create(D, {
1584
- expression: this.nodeFactory.create(j, {})
1582
+ expression: this.nodeFactory.create(W, {})
1585
1583
  }),
1586
1584
  this.contextStack.findHandlerContext(this.tokens, this.current)
1587
1585
  );
@@ -1639,7 +1637,7 @@ class hn {
1639
1637
  return this.nodeFactory.create($, { identifiers: e });
1640
1638
  }
1641
1639
  logError(e, n, s) {
1642
- this.errors.push(new c(n, s, e));
1640
+ this.errors.push(new l(n, s, e));
1643
1641
  }
1644
1642
  }
1645
1643
  const fn = {
@@ -1724,7 +1722,7 @@ function _e(t) {
1724
1722
  return new v();
1725
1723
  const n = [];
1726
1724
  let s;
1727
- if (!F(I.last(e))) {
1725
+ if (!M(I.last(e))) {
1728
1726
  const i = e.pop();
1729
1727
  if (kt(i))
1730
1728
  s = i.elementList.map(
@@ -1745,7 +1743,7 @@ function _e(t) {
1745
1743
  });
1746
1744
  }
1747
1745
  function X(t) {
1748
- return F(t) ? new S(t.expression.variable.value) : new v();
1746
+ return M(t) ? new S(t.expression.variable.value) : new v();
1749
1747
  }
1750
1748
  function Xe(t) {
1751
1749
  if (ht(t))
@@ -1753,7 +1751,7 @@ function Xe(t) {
1753
1751
  if (t instanceof Z && t.elementList.every(ht)) {
1754
1752
  const e = t.elementList.filter(
1755
1753
  (s) => s instanceof te
1756
- ), n = t.elementList.filter(F);
1754
+ ), n = t.elementList.filter(M);
1757
1755
  return new S({ functional: e, nonFunctional: n });
1758
1756
  }
1759
1757
  return new v();
@@ -1764,7 +1762,7 @@ function V(t) {
1764
1762
  return e === void 0 ? new v() : new S(e);
1765
1763
  }
1766
1764
  function Q(t) {
1767
- return Y(t) ? t.expression instanceof j ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
1765
+ return Y(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
1768
1766
  }
1769
1767
  function mn(t) {
1770
1768
  var e;
@@ -1778,16 +1776,16 @@ function Tn(t) {
1778
1776
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1779
1777
  }
1780
1778
  function ht(t) {
1781
- return t instanceof D && t.expression instanceof j || t instanceof te;
1779
+ return t instanceof D && t.expression instanceof W || t instanceof te;
1782
1780
  }
1783
1781
  function bn(t, e) {
1784
- var i, r, a, l;
1782
+ var i, r, a, c;
1785
1783
  let n = e;
1786
1784
  const s = Qt(t);
1787
1785
  for (; n; ) {
1788
1786
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1789
1787
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1790
- if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof G && s)
1788
+ if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof G && s)
1791
1789
  return n.symbol;
1792
1790
  if (n instanceof G)
1793
1791
  return;
@@ -1802,24 +1800,24 @@ class In {
1802
1800
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1803
1801
  }
1804
1802
  validateContext() {
1805
- return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1803
+ return this.declarationNode.parent instanceof G || 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)] : [];
1806
1804
  }
1807
1805
  validateName(e) {
1808
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1806
+ return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1809
1807
  }
1810
1808
  validateAlias(e) {
1811
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1809
+ return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1812
1810
  }
1813
1811
  validateSettingList(e) {
1814
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1812
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1815
1813
  }
1816
1814
  validateBody(e) {
1817
1815
  if (!e)
1818
1816
  return [];
1819
1817
  if (e instanceof ne)
1820
- return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1818
+ return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1821
1819
  const n = [];
1822
- return Y(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;
1820
+ return Y(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;
1823
1821
  }
1824
1822
  }
1825
1823
  class we {
@@ -1847,26 +1845,26 @@ class Ln {
1847
1845
  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)];
1848
1846
  }
1849
1847
  validateContext() {
1850
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1848
+ return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1851
1849
  }
1852
1850
  validateName(e) {
1853
- return e ? Ze(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)];
1851
+ return e ? Ze(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)];
1854
1852
  }
1855
1853
  validateAlias(e) {
1856
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1854
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1857
1855
  }
1858
1856
  registerElement() {
1859
1857
  const e = [];
1860
1858
  this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new we() });
1861
1859
  const { name: n } = this.declarationNode, s = C(n);
1862
1860
  if (s.isOk()) {
1863
- const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory), l = ze(r);
1864
- a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1861
+ const i = s.unwrap(), r = i.pop(), a = Ke(i, this.publicSymbolTable, this.symbolFactory), c = ze(r);
1862
+ 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);
1865
1863
  }
1866
1864
  return e;
1867
1865
  }
1868
1866
  validateSettingList(e) {
1869
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1867
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1870
1868
  }
1871
1869
  validateBody(e) {
1872
1870
  if (!e)
@@ -1877,25 +1875,25 @@ class Ln {
1877
1875
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1878
1876
  }
1879
1877
  validateFields(e) {
1880
- return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1878
+ return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1881
1879
  const s = [];
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));
1880
+ 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));
1883
1881
  const i = [...n.args];
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;
1882
+ 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 l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1885
1883
  });
1886
1884
  }
1887
1885
  validateFieldSettings(e) {
1888
- const n = W(e), s = n.getErrors(), i = n.getValue();
1886
+ const n = j(e), s = n.getErrors(), i = n.getValue();
1889
1887
  for (const r in i) {
1890
1888
  const a = i[r];
1891
1889
  switch (r) {
1892
1890
  case "note":
1893
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1894
- Y(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1891
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
1892
+ Y(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1895
1893
  });
1896
1894
  break;
1897
1895
  default:
1898
- a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1896
+ a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
1899
1897
  }
1900
1898
  }
1901
1899
  return s;
@@ -1909,15 +1907,15 @@ class Ln {
1909
1907
  });
1910
1908
  }
1911
1909
  registerField(e) {
1912
- if (e.callee && F(e.callee)) {
1910
+ if (e.callee && M(e.callee)) {
1913
1911
  const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
1914
1912
  e.symbol = i;
1915
1913
  const r = this.declarationNode.symbol.symbolTable;
1916
1914
  if (r.has(s)) {
1917
1915
  const a = r.get(s);
1918
1916
  return [
1919
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1920
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1917
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1918
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1921
1919
  ];
1922
1920
  }
1923
1921
  r.set(s, i);
@@ -1933,22 +1931,22 @@ class gn {
1933
1931
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1934
1932
  }
1935
1933
  validateContext() {
1936
- return this.declarationNode.parent instanceof G || ve(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1934
+ return this.declarationNode.parent instanceof G || 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)] : [];
1937
1935
  }
1938
1936
  validateName(e) {
1939
- return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1937
+ return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1940
1938
  }
1941
1939
  validateAlias(e) {
1942
- return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1940
+ return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1943
1941
  }
1944
1942
  validateSettingList(e) {
1945
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1943
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1946
1944
  }
1947
1945
  validateBody(e) {
1948
1946
  if (!e)
1949
1947
  return [];
1950
1948
  if (e instanceof w)
1951
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1949
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1952
1950
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
1953
1951
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1954
1952
  }
@@ -1959,35 +1957,35 @@ class gn {
1959
1957
  const s = [], i = [n.callee, ...n.args];
1960
1958
  return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1961
1959
  for (; r instanceof J; )
1962
- 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;
1963
- 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));
1960
+ 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;
1961
+ 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));
1964
1962
  }), s;
1965
1963
  });
1966
1964
  }
1967
1965
  validateFieldSetting(e) {
1968
- const n = W(e), s = n.getErrors(), i = n.getValue();
1966
+ const n = j(e), s = n.getErrors(), i = n.getValue();
1969
1967
  for (const r in i) {
1970
1968
  const a = i[r];
1971
1969
  switch (r) {
1972
1970
  case "note":
1973
1971
  case "name":
1974
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1975
- Y(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1972
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1973
+ Y(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
1976
1974
  });
1977
1975
  break;
1978
1976
  case "unique":
1979
1977
  case "pk":
1980
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1981
- ce(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1978
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1979
+ ce(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
1982
1980
  });
1983
1981
  break;
1984
1982
  case "type":
1985
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1986
- F(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1983
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
1984
+ M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
1987
1985
  });
1988
1986
  break;
1989
1987
  default:
1990
- a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1988
+ a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
1991
1989
  }
1992
1990
  }
1993
1991
  return s;
@@ -2009,24 +2007,24 @@ class _n {
2009
2007
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2010
2008
  }
2011
2009
  validateContext() {
2012
- return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
2010
+ return !(this.declarationNode.parent instanceof G) && ![b.Table, b.Project].includes(ve(this.declarationNode.parent).unwrap_or(void 0)) ? [new l(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
2013
2011
  }
2014
2012
  validateName(e) {
2015
2013
  if (!(this.declarationNode.parent instanceof G))
2016
- return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2014
+ return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2017
2015
  if (!e)
2018
- return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2016
+ return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2019
2017
  const n = C(e);
2020
2018
  if (!n.isOk())
2021
- return [new c(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2019
+ return [new l(o.INVALID_NAME, "Invalid name for sticky note ", this.declarationNode)];
2022
2020
  const i = n.unwrap().join("."), r = zt(i);
2023
- 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), []);
2021
+ 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), []);
2024
2022
  }
2025
2023
  validateAlias(e) {
2026
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2024
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2027
2025
  }
2028
2026
  validateSettingList(e) {
2029
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2027
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2030
2028
  }
2031
2029
  validateBody(e) {
2032
2030
  if (!e)
@@ -2038,7 +2036,7 @@ class _n {
2038
2036
  }
2039
2037
  validateFields(e) {
2040
2038
  const n = [];
2041
- 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))), Y(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);
2039
+ 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))), Y(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);
2042
2040
  }
2043
2041
  validateSubElements(e) {
2044
2042
  return e.flatMap((n) => {
@@ -2057,25 +2055,25 @@ class An {
2057
2055
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2058
2056
  }
2059
2057
  validateContext() {
2060
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2058
+ return this.declarationNode.parent instanceof A ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2061
2059
  }
2062
2060
  validateName(e) {
2063
- return e ? Me(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2061
+ return e ? Me(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2064
2062
  }
2065
2063
  validateAlias(e) {
2066
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2064
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2067
2065
  }
2068
2066
  validateSettingList(e) {
2069
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2067
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2070
2068
  }
2071
2069
  validateBody(e) {
2072
2070
  if (!e)
2073
2071
  return [];
2074
2072
  if (e instanceof w)
2075
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2073
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2076
2074
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
2077
2075
  return [
2078
- ...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2076
+ ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2079
2077
  ...this.validateSubElements(s)
2080
2078
  ];
2081
2079
  }
@@ -2096,16 +2094,16 @@ class vn {
2096
2094
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2097
2095
  }
2098
2096
  validateContext() {
2099
- return this.declarationNode.parent instanceof G ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2097
+ return this.declarationNode.parent instanceof G ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2100
2098
  }
2101
2099
  validateName(e) {
2102
- return e ? Me(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2100
+ return e ? Me(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2103
2101
  }
2104
2102
  validateAlias(e) {
2105
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2103
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2106
2104
  }
2107
2105
  validateSettingList(e) {
2108
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2106
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2109
2107
  }
2110
2108
  validateBody(e) {
2111
2109
  if (!e)
@@ -2117,27 +2115,27 @@ class vn {
2117
2115
  }
2118
2116
  validateFields(e) {
2119
2117
  if (e.length === 0)
2120
- return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2118
+ return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2121
2119
  const n = [];
2122
- 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) => {
2123
- s.callee && !mn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Tn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2120
+ 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) => {
2121
+ s.callee && !mn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !Tn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2124
2122
  const i = [...s.args];
2125
- I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (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)));
2123
+ I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (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)));
2126
2124
  }), n;
2127
2125
  }
2128
2126
  validateFieldSettings(e) {
2129
- const n = W(e), s = n.getErrors(), i = n.getValue();
2127
+ const n = j(e), s = n.getErrors(), i = n.getValue();
2130
2128
  for (const r in i) {
2131
2129
  const a = i[r];
2132
2130
  switch (r) {
2133
2131
  case "delete":
2134
2132
  case "update":
2135
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2136
- wn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2133
+ a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
2134
+ wn(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));
2137
2135
  });
2138
2136
  break;
2139
2137
  default:
2140
- a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2138
+ a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
2141
2139
  }
2142
2140
  }
2143
2141
  return s;
@@ -2152,7 +2150,7 @@ class vn {
2152
2150
  }
2153
2151
  }
2154
2152
  function wn(t) {
2155
- if (!(F(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
2153
+ if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
2156
2154
  return !1;
2157
2155
  let e;
2158
2156
  if (t instanceof $ ? e = me(t).unwrap_or("") : e = t.expression.variable.value, e)
@@ -2176,31 +2174,31 @@ class yn {
2176
2174
  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)];
2177
2175
  }
2178
2176
  validateContext() {
2179
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2177
+ return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2180
2178
  }
2181
2179
  validateName(e) {
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)];
2180
+ return e ? e instanceof le ? [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)] : Ze(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)];
2183
2181
  }
2184
2182
  validateAlias(e) {
2185
- return e ? On(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2183
+ return e ? On(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2186
2184
  }
2187
2185
  validateSettingList(e) {
2188
- const n = W(e), s = n.getErrors(), i = n.getValue();
2186
+ const n = j(e), s = n.getErrors(), i = n.getValue();
2189
2187
  for (const r in i) {
2190
2188
  const a = i[r];
2191
2189
  switch (r) {
2192
2190
  case "headercolor":
2193
- a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2194
- Rn(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2191
+ a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
2192
+ Rn(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2195
2193
  });
2196
2194
  break;
2197
2195
  case "note":
2198
- a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2199
- Y(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2196
+ a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
2197
+ Y(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2200
2198
  });
2201
2199
  break;
2202
2200
  default:
2203
- s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2201
+ s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
2204
2202
  }
2205
2203
  }
2206
2204
  return s;
@@ -2210,12 +2208,12 @@ class yn {
2210
2208
  this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new we() });
2211
2209
  const { name: n, alias: s } = this.declarationNode, i = C(n);
2212
2210
  if (i.isOk()) {
2213
- const r = [...i.unwrap()], a = r.pop(), l = Ke(r, this.publicSymbolTable, this.symbolFactory), p = Se(a);
2214
- l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2211
+ const r = [...i.unwrap()], a = r.pop(), c = Ke(r, this.publicSymbolTable, this.symbolFactory), p = Se(a);
2212
+ 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);
2215
2213
  }
2216
2214
  if (s && Me(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
2217
2215
  const r = V(s).unwrap(), a = Se(r);
2218
- this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2216
+ this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2219
2217
  }
2220
2218
  return e;
2221
2219
  }
@@ -2223,30 +2221,30 @@ class yn {
2223
2221
  if (!e)
2224
2222
  return [];
2225
2223
  if (e instanceof w)
2226
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2224
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2227
2225
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
2228
2226
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2229
2227
  }
2230
2228
  validateFields(e) {
2231
- return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2229
+ return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2232
2230
  if (!n.callee)
2233
2231
  return [];
2234
2232
  const s = [];
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]));
2233
+ 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] && !kn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2236
2234
  const i = n.args.slice(1);
2237
2235
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2238
2236
  });
2239
2237
  }
2240
2238
  registerField(e) {
2241
- if (e.callee && F(e.callee)) {
2239
+ if (e.callee && M(e.callee)) {
2242
2240
  const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(en, { declaration: e });
2243
2241
  e.symbol = i;
2244
2242
  const r = this.declarationNode.symbol.symbolTable;
2245
2243
  if (r.has(s)) {
2246
2244
  const a = r.get(s);
2247
2245
  return [
2248
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2249
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2246
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2247
+ new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2250
2248
  ];
2251
2249
  }
2252
2250
  r.set(s, i);
@@ -2256,74 +2254,74 @@ class yn {
2256
2254
  // This is needed to support legacy inline settings
2257
2255
  validateFieldSetting(e) {
2258
2256
  if (!e.slice(0, -1).every(Ne) || !e.slice(-1).every((p) => Ne(p) || p instanceof P))
2259
- return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2257
+ return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2260
2258
  if (e.length === 0)
2261
2259
  return [];
2262
2260
  let n;
2263
2261
  I.last(e) instanceof P && (n = e.pop());
2264
- const s = W(n), i = s.getErrors(), r = s.getValue();
2262
+ const s = j(n), i = s.getErrors(), r = s.getValue();
2265
2263
  for (const p of e) {
2266
2264
  const h = V(p).unwrap_or("").toLowerCase();
2267
2265
  if (h !== "pk" && h !== "unique") {
2268
- i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2266
+ i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2269
2267
  continue;
2270
2268
  }
2271
2269
  r[h] === void 0 ? r[h] = [p] : r[h].push(p);
2272
2270
  }
2273
- const a = r.pk || [], l = r["primary key"] || [];
2274
- a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2271
+ const a = r.pk || [], c = r["primary key"] || [];
2272
+ 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)));
2275
2273
  for (const p in r) {
2276
2274
  const h = r[p];
2277
2275
  switch (p) {
2278
2276
  case "note":
2279
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2280
- Y(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2277
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2278
+ Y(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2281
2279
  });
2282
2280
  break;
2283
2281
  case "ref":
2284
2282
  h.forEach((f) => {
2285
- Pn(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2283
+ Pn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2286
2284
  });
2287
2285
  break;
2288
2286
  case "primary key":
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) => {
2290
- ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2287
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2288
+ ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2291
2289
  });
2292
2290
  break;
2293
2291
  case "pk":
2294
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
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));
2292
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2293
+ f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2296
2294
  });
2297
2295
  break;
2298
2296
  case "not null":
2299
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2297
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2300
2298
  const T = r.null || [];
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) => {
2302
- ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2299
+ h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new l(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2300
+ ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2303
2301
  });
2304
2302
  break;
2305
2303
  case "null":
2306
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2307
- ce(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2304
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2305
+ ce(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2308
2306
  });
2309
2307
  break;
2310
2308
  case "unique":
2311
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
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));
2309
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2310
+ f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2313
2311
  });
2314
2312
  break;
2315
2313
  case "increment":
2316
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
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));
2314
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2315
+ f instanceof se && !ce(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2318
2316
  });
2319
2317
  break;
2320
2318
  case "default":
2321
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2322
- Dn(f.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2319
+ h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2320
+ Dn(f.value) || i.push(new l(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2323
2321
  });
2324
2322
  break;
2325
2323
  default:
2326
- h.forEach((f) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2324
+ h.forEach((f) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2327
2325
  }
2328
2326
  }
2329
2327
  return i;
@@ -2338,7 +2336,7 @@ class yn {
2338
2336
  var r;
2339
2337
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2340
2338
  });
2341
- return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2339
+ return s.length > 1 && (n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2342
2340
  }
2343
2341
  }
2344
2342
  function kn(t) {
@@ -2368,13 +2366,13 @@ class Sn {
2368
2366
  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)];
2369
2367
  }
2370
2368
  validateContext() {
2371
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2369
+ return this.declarationNode.parent instanceof A ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2372
2370
  }
2373
2371
  validateName(e) {
2374
- return e ? Ze(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2372
+ return e ? Ze(e) ? [] : [new l(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new l(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2375
2373
  }
2376
2374
  validateAlias(e) {
2377
- return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2375
+ return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2378
2376
  }
2379
2377
  registerElement() {
2380
2378
  const { name: e } = this.declarationNode;
@@ -2383,26 +2381,26 @@ class Sn {
2383
2381
  if (n.isOk()) {
2384
2382
  const s = n.unwrap(), i = s.pop(), r = Ke(s, this.publicSymbolTable, this.symbolFactory), a = qe(i);
2385
2383
  if (r.has(a))
2386
- return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2384
+ return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2387
2385
  r.set(a, this.declarationNode.symbol);
2388
2386
  }
2389
2387
  return [];
2390
2388
  }
2391
2389
  validateSettingList(e) {
2392
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2390
+ return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2393
2391
  }
2394
2392
  validateBody(e) {
2395
2393
  if (!e)
2396
2394
  return [];
2397
2395
  if (e instanceof w)
2398
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2396
+ return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2399
2397
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
2400
2398
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2401
2399
  }
2402
2400
  validateFields(e) {
2403
2401
  return e.flatMap((n) => {
2404
2402
  const s = [];
2405
- return n.callee && !C(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2403
+ return n.callee && !C(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;
2406
2404
  });
2407
2405
  }
2408
2406
  validateSubElements(e) {
@@ -2414,15 +2412,15 @@ class Sn {
2414
2412
  });
2415
2413
  }
2416
2414
  registerField(e) {
2417
- if (e.callee && F(e.callee)) {
2415
+ if (e.callee && M(e.callee)) {
2418
2416
  const n = V(e.callee).unwrap(), s = He(n), i = this.symbolFactory.create(nn, { declaration: e });
2419
2417
  e.symbol = i;
2420
2418
  const r = this.declarationNode.symbol.symbolTable;
2421
2419
  if (r.has(s)) {
2422
2420
  const a = r.get(s);
2423
2421
  return [
2424
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2425
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2422
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2423
+ new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2426
2424
  ];
2427
2425
  }
2428
2426
  r.set(s, i);
@@ -2458,7 +2456,7 @@ function On(t) {
2458
2456
  return Me(t);
2459
2457
  }
2460
2458
  function Me(t) {
2461
- return t instanceof D && t.expression instanceof j;
2459
+ return t instanceof D && t.expression instanceof W;
2462
2460
  }
2463
2461
  function Ke(t, e, n) {
2464
2462
  var i;
@@ -2466,14 +2464,14 @@ function Ke(t, e, n) {
2466
2464
  let s = e;
2467
2465
  for (const r of t) {
2468
2466
  let a;
2469
- const l = je(r);
2470
- if (s.has(l)) {
2471
- if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2467
+ const c = We(r);
2468
+ if (s.has(c)) {
2469
+ if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
2472
2470
  throw new Error("Expect a symbol table in a schema symbol");
2473
2471
  } else {
2474
2472
  a = new we();
2475
2473
  const p = n.create(_t, { symbolTable: a });
2476
- s.set(l, p);
2474
+ s.set(c, p);
2477
2475
  }
2478
2476
  s = a;
2479
2477
  }
@@ -2513,9 +2511,9 @@ function Pn(t) {
2513
2511
  return e !== void 0 && e.length > 0;
2514
2512
  }
2515
2513
  function kt(t) {
2516
- return t instanceof Z && t.elementList.every(F);
2514
+ return t instanceof Z && t.elementList.every(M);
2517
2515
  }
2518
- function W(t) {
2516
+ function j(t) {
2519
2517
  var s;
2520
2518
  const e = {}, n = [];
2521
2519
  if (!t)
@@ -2524,7 +2522,7 @@ function W(t) {
2524
2522
  if (!i.name)
2525
2523
  continue;
2526
2524
  if (i.name instanceof D) {
2527
- n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2525
+ n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2528
2526
  continue;
2529
2527
  }
2530
2528
  const r = (s = me(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
@@ -2551,7 +2549,7 @@ class ft {
2551
2549
  e.push(...r.validate());
2552
2550
  });
2553
2551
  const n = this.ast.body.filter((s) => ve(s).unwrap_or(void 0) === b.Project);
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);
2552
+ return n.length > 1 && n.forEach((s) => e.push(new l(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2555
2553
  }
2556
2554
  }
2557
2555
  class ae {
@@ -2602,7 +2600,7 @@ class ae {
2602
2600
  var s, i;
2603
2601
  if (e)
2604
2602
  if (e instanceof D) {
2605
- if (e.expression instanceof j && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2603
+ if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2606
2604
  return;
2607
2605
  this.bindFragments([e], n);
2608
2606
  } else
@@ -2614,7 +2612,7 @@ class ae {
2614
2612
  bindFragments(e, n) {
2615
2613
  if (e.length === 0)
2616
2614
  return;
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(
2615
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2618
2616
  0,
2619
2617
  r === -1 ? void 0 : r
2620
2618
  );
@@ -2635,7 +2633,7 @@ class ae {
2635
2633
  referrer: f
2636
2634
  });
2637
2635
  }
2638
- return l ? l.elementList.forEach(
2636
+ return c ? c.elementList.forEach(
2639
2637
  (f) => this.resolveIndexStack(
2640
2638
  [
2641
2639
  ...T,
@@ -2663,24 +2661,24 @@ class ae {
2663
2661
  return;
2664
2662
  }
2665
2663
  r.references.push(s.referrer), s.referrer.referee = r;
2666
- let a = r.symbolTable, { kind: l, name: p } = ie(s.index).unwrap();
2664
+ let a = r.symbolTable, { kind: c, name: p } = ie(s.index).unwrap();
2667
2665
  for (const h of i) {
2668
2666
  const { kind: T, name: f } = ie(h.index).unwrap(), N = a.get(h.index);
2669
2667
  if (!N) {
2670
2668
  this.logError(
2671
2669
  h.referrer,
2672
- `${l} '${p}' does not have ${T} '${f}'`,
2670
+ `${c} '${p}' does not have ${T} '${f}'`,
2673
2671
  n
2674
2672
  );
2675
2673
  return;
2676
2674
  }
2677
- if (l = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2675
+ if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2678
2676
  break;
2679
2677
  a = N.symbolTable;
2680
2678
  }
2681
2679
  }
2682
2680
  logError(e, n, s) {
2683
- s || this.errors.push(new c(o.BINDING_ERROR, n, e));
2681
+ s || this.errors.push(new l(o.BINDING_ERROR, n, e));
2684
2682
  }
2685
2683
  }
2686
2684
  class Un extends ae {
@@ -2853,7 +2851,7 @@ class $n {
2853
2851
  return new B(this.ast, this.errors);
2854
2852
  }
2855
2853
  }
2856
- class Wn {
2854
+ class jn {
2857
2855
  constructor(e) {
2858
2856
  this.generator = e;
2859
2857
  }
@@ -2861,9 +2859,9 @@ class Wn {
2861
2859
  return new e(n, this.generator.nextId());
2862
2860
  }
2863
2861
  }
2864
- class jn {
2862
+ class Wn {
2865
2863
  constructor(e, n) {
2866
- this.ast = e, this.symbolFactory = new Wn(n);
2864
+ this.ast = e, this.symbolFactory = new jn(n);
2867
2865
  }
2868
2866
  // Analyzing: Invoking both the validator and binder
2869
2867
  analyze() {
@@ -2907,7 +2905,7 @@ function St(t) {
2907
2905
  }
2908
2906
  throw new Error("Invalid relation op");
2909
2907
  }
2910
- function x(t) {
2908
+ function y(t) {
2911
2909
  return {
2912
2910
  start: {
2913
2911
  offset: t.startPos.offset,
@@ -2943,7 +2941,7 @@ function Rt(t, e) {
2943
2941
  function Dt(t, e) {
2944
2942
  if (Array.isArray(t)) {
2945
2943
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2946
- return I.zip(i, r).every(([a, l]) => a === l);
2944
+ return I.zip(i, r).every(([a, c]) => a === c);
2947
2945
  }
2948
2946
  const n = t.id, s = e.id;
2949
2947
  return n === s;
@@ -2959,7 +2957,7 @@ class Pt {
2959
2957
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2960
2958
  }
2961
2959
  interpret() {
2962
- this.table.token = x(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2960
+ this.table.token = y(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2963
2961
  const e = [
2964
2962
  ...this.interpretName(this.declarationNode.name),
2965
2963
  ...this.interpretAlias(this.declarationNode.alias),
@@ -2979,7 +2977,7 @@ class Pt {
2979
2977
  }
2980
2978
  interpretName(e) {
2981
2979
  const { name: n, schemaName: s } = be(e);
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, []);
2980
+ 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, []);
2983
2981
  }
2984
2982
  interpretAlias(e) {
2985
2983
  if (!e)
@@ -2996,12 +2994,12 @@ class Pt {
2996
2994
  }
2997
2995
  interpretSettingList(e) {
2998
2996
  var i, r, a;
2999
- const n = W(e).getValue();
2997
+ const n = j(e).getValue();
3000
2998
  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;
3001
2999
  const [s] = n.note || [];
3002
3000
  return this.table.note = s && {
3003
3001
  value: Q(s == null ? void 0 : s.value).map(Ee).unwrap(),
3004
- token: x(s)
3002
+ token: y(s)
3005
3003
  }, [];
3006
3004
  }
3007
3005
  interpretBody(e) {
@@ -3015,7 +3013,7 @@ class Pt {
3015
3013
  case "note":
3016
3014
  return this.table.note = {
3017
3015
  value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).map(Ee).unwrap(),
3018
- token: x(n)
3016
+ token: y(n)
3019
3017
  }, [];
3020
3018
  case "indexes":
3021
3019
  return this.interpretIndexes(n);
@@ -3027,25 +3025,25 @@ class Pt {
3027
3025
  return e.flatMap((n) => this.interpretColumn(n));
3028
3026
  }
3029
3027
  interpretColumn(e) {
3030
- var a, l, p, h, T, f, N, g;
3028
+ var a, c, p, h, T, f, N, g;
3031
3029
  const n = [], s = {};
3032
3030
  s.name = V(e.callee).unwrap();
3033
3031
  const i = Yn(e.args[0]);
3034
- s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
3032
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = y(e), s.inline_refs = [];
3035
3033
  const r = e.args.slice(1);
3036
3034
  if (I.last(r) instanceof P) {
3037
- const _ = W(r.pop()).getValue();
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);
3035
+ const _ = j(r.pop()).getValue();
3036
+ s.pk = !!((a = _.pk) != null && a.length) || !!((c = _["primary key"]) != null && c.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);
3039
3037
  const K = (g = _.note) == null ? void 0 : g.at(0);
3040
3038
  s.note = K && {
3041
3039
  value: Q(K.value).map(Ee).unwrap(),
3042
- token: x(K)
3040
+ token: y(K)
3043
3041
  };
3044
3042
  const Ie = _.ref || [];
3045
3043
  s.inline_refs = Ie.flatMap((z) => {
3046
3044
  const [nt] = $e(z.value.expression);
3047
3045
  if (Dt(nt, e.symbol))
3048
- return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3046
+ return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3049
3047
  const ye = z.value.op, ee = C(z.value.expression).unwrap();
3050
3048
  let fe;
3051
3049
  if (ee.length === 1) {
@@ -3055,7 +3053,7 @@ class Pt {
3055
3053
  tableName: this.table.name,
3056
3054
  fieldNames: [oe],
3057
3055
  relation: ye.value,
3058
- token: x(z)
3056
+ token: y(z)
3059
3057
  };
3060
3058
  } else if (ee.length === 2) {
3061
3059
  const [oe, Le] = ee;
@@ -3064,7 +3062,7 @@ class Pt {
3064
3062
  tableName: oe,
3065
3063
  fieldNames: [Le],
3066
3064
  relation: ye.value,
3067
- token: x(z)
3065
+ token: y(z)
3068
3066
  };
3069
3067
  } else if (ee.length === 3) {
3070
3068
  const [oe, Le, it] = ee;
@@ -3073,17 +3071,17 @@ class Pt {
3073
3071
  tableName: Le,
3074
3072
  fieldNames: [it],
3075
3073
  relation: ye.value,
3076
- token: x(z)
3074
+ token: y(z)
3077
3075
  };
3078
3076
  } else {
3079
- n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3077
+ n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", z));
3080
3078
  const oe = ee.pop(), Le = ee.pop();
3081
3079
  fe = {
3082
3080
  schemaName: ee.join("."),
3083
3081
  tableName: Le,
3084
3082
  fieldNames: [oe],
3085
3083
  relation: ye.value,
3086
- token: x(z)
3084
+ token: y(z)
3087
3085
  };
3088
3086
  }
3089
3087
  const st = this.registerInlineRefToEnv(e, nt, fe, z);
@@ -3094,17 +3092,17 @@ class Pt {
3094
3092
  }
3095
3093
  interpretIndexes(e) {
3096
3094
  return this.table.indexes.push(...e.body.body.map((n) => {
3097
- var a, l, p, h, T, f, N;
3095
+ var a, c, p, h, T, f, N;
3098
3096
  const s = { columns: [] }, i = n;
3099
- s.token = x(e);
3097
+ s.token = y(e);
3100
3098
  const r = [i.callee, ...i.args];
3101
3099
  if (I.last(r) instanceof P) {
3102
- const g = W(r.pop()).getValue();
3103
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Q((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3100
+ const g = j(r.pop()).getValue();
3101
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = Q((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3104
3102
  const _ = (T = g.note) == null ? void 0 : T.at(0);
3105
3103
  s.note = _ && {
3106
3104
  value: Q(_.value).unwrap(),
3107
- token: x(_)
3105
+ token: y(_)
3108
3106
  }, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3109
3107
  }
3110
3108
  return r.flatMap((g) => {
@@ -3133,8 +3131,8 @@ class Pt {
3133
3131
  const r = Rt(e.symbol, n);
3134
3132
  if (this.env.refIds[r])
3135
3133
  return [
3136
- new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
3137
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3134
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3135
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3138
3136
  ];
3139
3137
  const a = St(s.relation);
3140
3138
  return this.env.refIds[r] = i, this.env.ref.set(i, {
@@ -3150,7 +3148,7 @@ class Pt {
3150
3148
  schemaName: this.table.schemaName,
3151
3149
  tableName: this.table.name,
3152
3150
  fieldNames: [X(e.callee).unwrap()],
3153
- token: x(e),
3151
+ token: y(e),
3154
3152
  relation: a[0]
3155
3153
  }
3156
3154
  ]
@@ -3170,7 +3168,7 @@ function Yn(t) {
3170
3168
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3171
3169
  args: e
3172
3170
  },
3173
- [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3171
+ [new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
3174
3172
  ) : new B({
3175
3173
  schemaName: i.length === 0 ? null : i[0],
3176
3174
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
@@ -3215,7 +3213,7 @@ class Qn {
3215
3213
  this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3216
3214
  }
3217
3215
  interpret() {
3218
- return this.note.token = x(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3216
+ return this.note.token = y(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3219
3217
  ...this.interpretName(this.declarationNode.name),
3220
3218
  ...this.interpretSettingList(this.declarationNode.attributeList),
3221
3219
  ...this.interpretBody(this.declarationNode.body)
@@ -3227,13 +3225,13 @@ class Qn {
3227
3225
  }
3228
3226
  interpretSettingList(e) {
3229
3227
  var s, i, r;
3230
- const n = W(e).getValue();
3228
+ const n = j(e).getValue();
3231
3229
  return this.note.headerColor = (s = n.headercolor) != null && s.length ? Ot((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3232
3230
  }
3233
3231
  interpretBody(e) {
3234
3232
  const [n, s] = I.partition(e.body, (i) => i instanceof w);
3235
3233
  return n.length !== 1 || s.length > 0 ? [
3236
- new c(o.INVALID_NOTE, "Invalid note syntax", e)
3234
+ new l(o.INVALID_NOTE, "Invalid note syntax", e)
3237
3235
  ] : [...this.interpretNote(n[0])];
3238
3236
  }
3239
3237
  interpretNote(e) {
@@ -3246,11 +3244,11 @@ class Ut {
3246
3244
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3247
3245
  }
3248
3246
  interpret() {
3249
- return this.ref.token = x(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3247
+ return this.ref.token = y(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3250
3248
  }
3251
3249
  interpretName(e) {
3252
3250
  const n = [], s = C(this.declarationNode.name).unwrap_or([]);
3253
- 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;
3251
+ 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;
3254
3252
  }
3255
3253
  interpretBody(e) {
3256
3254
  return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
@@ -3259,15 +3257,15 @@ class Ut {
3259
3257
  var h, T, f, N;
3260
3258
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = $e(s), a = $e(i);
3261
3259
  if (Dt(r, a))
3262
- return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3263
- const l = Rt(r, a);
3264
- if (this.env.refIds[l])
3260
+ return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3261
+ const c = Rt(r, a);
3262
+ if (this.env.refIds[c])
3265
3263
  return [
3266
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3267
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3264
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3265
+ new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
3268
3266
  ];
3269
3267
  if (e.args[0]) {
3270
- const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
3268
+ const g = j(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
3271
3269
  this.ref.onDelete = _ instanceof $ ? me(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
3272
3270
  const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
3273
3271
  this.ref.onUpdate = K instanceof $ ? me(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
@@ -3277,14 +3275,14 @@ class Ut {
3277
3275
  {
3278
3276
  ...pt(s, this.container),
3279
3277
  relation: p[0],
3280
- token: x(s)
3278
+ token: y(s)
3281
3279
  },
3282
3280
  {
3283
3281
  ...pt(i, this.container),
3284
3282
  relation: p[1],
3285
- token: x(i)
3283
+ token: y(i)
3286
3284
  }
3287
- ], this.env.refIds[l] = this.declarationNode, [];
3285
+ ], this.env.refIds[c] = this.declarationNode, [];
3288
3286
  }
3289
3287
  }
3290
3288
  class Mt {
@@ -3293,24 +3291,24 @@ class Mt {
3293
3291
  }
3294
3292
  interpret() {
3295
3293
  const e = [];
3296
- return this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3294
+ return this.tableGroup.token = y(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup), e.push(
3297
3295
  ...this.interpretName(this.declarationNode.name),
3298
3296
  ...this.interpretBody(this.declarationNode.body)
3299
3297
  ), e;
3300
3298
  }
3301
3299
  interpretName(e) {
3302
3300
  const n = [], { name: s, schemaName: i } = be(e);
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;
3301
+ 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;
3304
3302
  }
3305
3303
  interpretBody(e) {
3306
3304
  const n = [];
3307
3305
  return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
3308
3306
  const i = C(s.callee).unwrap();
3309
- i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
3307
+ i.length > 2 && n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", s));
3310
3308
  const r = he(s.callee).unwrap().pop().referee.id;
3311
3309
  if (this.env.groupOfTable[r]) {
3312
- const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
3313
- n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
3310
+ const a = this.env.groupOfTable[r], { schemaName: c, name: p } = this.env.tableGroups.get(a), h = c ? `${c}.${p}` : p;
3311
+ n.push(new l(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
3314
3312
  } else
3315
3313
  this.env.groupOfTable[r] = this.declarationNode;
3316
3314
  return {
@@ -3325,21 +3323,21 @@ class Ft {
3325
3323
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3326
3324
  }
3327
3325
  interpret() {
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)];
3326
+ return this.enum.token = y(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3329
3327
  }
3330
3328
  interpretName(e) {
3331
3329
  const { name: n, schemaName: s } = be(e);
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, []);
3330
+ 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, []);
3333
3331
  }
3334
3332
  interpretBody(e) {
3335
3333
  return e.body.flatMap((n) => {
3336
- var l;
3334
+ var c;
3337
3335
  const s = n, i = {};
3338
- i.token = x(s), i.name = X(s.callee).unwrap();
3339
- const a = (l = W(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3336
+ i.token = y(s), i.name = X(s.callee).unwrap();
3337
+ const a = (c = j(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3340
3338
  return i.note = a && {
3341
3339
  value: Q(a.value).map(Ee).unwrap(),
3342
- token: x(a)
3340
+ token: y(a)
3343
3341
  }, this.enum.values.push(i), [];
3344
3342
  });
3345
3343
  }
@@ -3349,7 +3347,7 @@ class qn {
3349
3347
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3350
3348
  }
3351
3349
  interpret() {
3352
- return this.env.project.set(this.declarationNode, this.project), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3350
+ return this.env.project.set(this.declarationNode, this.project), this.project.token = y(this.declarationNode), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3353
3351
  }
3354
3352
  interpretName(e) {
3355
3353
  if (!e)
@@ -3381,7 +3379,7 @@ class qn {
3381
3379
  case "note":
3382
3380
  return this.project.note = {
3383
3381
  value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).map(Ee).unwrap(),
3384
- token: x(s)
3382
+ token: y(s)
3385
3383
  }, [];
3386
3384
  default:
3387
3385
  return this.project[s.type.value.toLowerCase()] = Q(s.body.callee).unwrap(), [];
@@ -3438,7 +3436,7 @@ function Jn(t) {
3438
3436
  project: Array.from(t.project.values())[0] || {}
3439
3437
  };
3440
3438
  }
3441
- var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), y = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(y || {});
3439
+ 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 || {});
3442
3440
  function Ae(t) {
3443
3441
  switch (t) {
3444
3442
  case m.Schema:
@@ -3502,12 +3500,12 @@ class Bt {
3502
3500
  }
3503
3501
  provideCompletionItems(e, n) {
3504
3502
  var T, f;
3505
- const s = et(e, n), i = this.compiler.token.flatStream(), { token: r, index: a } = this.compiler.container.token(s), l = a === void 0 ? i[0] : i[a + 1];
3503
+ const s = et(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];
3506
3504
  if ([
3507
3505
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3508
3506
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3509
- ...(l == null ? void 0 : l.leadingTrivia) || []
3510
- ].find((N) => jt(N) && ge(s, N)))
3507
+ ...(c == null ? void 0 : c.leadingTrivia) || []
3508
+ ].find((N) => Wt(N) && ge(s, N)))
3511
3509
  return O();
3512
3510
  if (a === void 0)
3513
3511
  return Tt();
@@ -3583,12 +3581,12 @@ function Be(t, e, n, s) {
3583
3581
  const r = { suggestions: [] };
3584
3582
  for (; i; ) {
3585
3583
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3586
- const { symbol: l } = i;
3584
+ const { symbol: c } = i;
3587
3585
  r.suggestions.push(
3588
- ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3586
+ ...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3589
3587
  label: p,
3590
3588
  insertText: p,
3591
- insertTextRules: y.KeepWhitespace,
3589
+ insertTextRules: k.KeepWhitespace,
3592
3590
  kind: Ae(h),
3593
3591
  sortText: Ae(h).toString().padStart(2, "0"),
3594
3592
  range: void 0
@@ -3652,14 +3650,14 @@ function Nt(t, e) {
3652
3650
  label: "headercolor",
3653
3651
  insertText: "headercolor: ",
3654
3652
  kind: L.Field,
3655
- insertTextRules: y.KeepWhitespace,
3653
+ insertTextRules: k.KeepWhitespace,
3656
3654
  range: void 0
3657
3655
  },
3658
3656
  {
3659
3657
  label: "note",
3660
3658
  insertText: "note: ",
3661
3659
  kind: L.Field,
3662
- insertTextRules: y.KeepWhitespace,
3660
+ insertTextRules: k.KeepWhitespace,
3663
3661
  range: void 0
3664
3662
  }
3665
3663
  ]
@@ -3675,21 +3673,21 @@ function Nt(t, e) {
3675
3673
  label: i,
3676
3674
  insertText: i,
3677
3675
  kind: L.Property,
3678
- insertTextRules: y.KeepWhitespace,
3676
+ insertTextRules: k.KeepWhitespace,
3679
3677
  range: void 0
3680
3678
  })),
3681
3679
  ...["ref", "default"].map((i) => ({
3682
3680
  label: i,
3683
3681
  insertText: `${i}: `,
3684
3682
  kind: L.Property,
3685
- insertTextRules: y.KeepWhitespace,
3683
+ insertTextRules: k.KeepWhitespace,
3686
3684
  range: void 0
3687
3685
  })),
3688
3686
  {
3689
3687
  label: "note",
3690
3688
  insertText: "note: ",
3691
3689
  kind: L.Property,
3692
- insertTextRules: y.KeepWhitespace,
3690
+ insertTextRules: k.KeepWhitespace,
3693
3691
  range: void 0
3694
3692
  }
3695
3693
  ]
@@ -3701,7 +3699,7 @@ function Nt(t, e) {
3701
3699
  label: "note",
3702
3700
  insertText: "note: ",
3703
3701
  kind: L.Property,
3704
- insertTextRules: y.KeepWhitespace,
3702
+ insertTextRules: k.KeepWhitespace,
3705
3703
  range: void 0
3706
3704
  }
3707
3705
  ]
@@ -3712,7 +3710,7 @@ function Nt(t, e) {
3712
3710
  ...["unique", "pk"].map((i) => ({
3713
3711
  label: i,
3714
3712
  insertText: i,
3715
- insertTextRules: y.KeepWhitespace,
3713
+ insertTextRules: k.KeepWhitespace,
3716
3714
  kind: L.Property,
3717
3715
  range: void 0
3718
3716
  })),
@@ -3720,7 +3718,7 @@ function Nt(t, e) {
3720
3718
  label: i,
3721
3719
  insertText: `${i}: `,
3722
3720
  kind: L.Property,
3723
- insertTextRules: y.KeepWhitespace,
3721
+ insertTextRules: k.KeepWhitespace,
3724
3722
  range: void 0
3725
3723
  }))
3726
3724
  ]
@@ -3731,7 +3729,7 @@ function Nt(t, e) {
3731
3729
  label: i,
3732
3730
  insertText: `${i}: `,
3733
3731
  kind: L.Property,
3734
- insertTextRules: y.KeepWhitespace,
3732
+ insertTextRules: k.KeepWhitespace,
3735
3733
  range: void 0
3736
3734
  }))
3737
3735
  };
@@ -3747,7 +3745,7 @@ function Kn(t, e, n) {
3747
3745
  label: s,
3748
3746
  insertText: s,
3749
3747
  kind: L.Value,
3750
- insertTextRules: y.KeepWhitespace,
3748
+ insertTextRules: k.KeepWhitespace,
3751
3749
  range: void 0
3752
3750
  }))
3753
3751
  };
@@ -3757,7 +3755,7 @@ function Kn(t, e, n) {
3757
3755
  label: s,
3758
3756
  insertText: `${s}`,
3759
3757
  kind: L.Value,
3760
- insertTextRules: y.KeepWhitespace,
3758
+ insertTextRules: k.KeepWhitespace,
3761
3759
  range: void 0
3762
3760
  }))
3763
3761
  };
@@ -3766,7 +3764,7 @@ function Kn(t, e, n) {
3766
3764
  }
3767
3765
  function Vt(t, e, n) {
3768
3766
  const s = he(n).unwrap_or([]);
3769
- if (s.pop(), s.some((r) => !F(r)))
3767
+ if (s.pop(), s.some((r) => !M(r)))
3770
3768
  return O();
3771
3769
  const i = s.map((r) => X(r).unwrap());
3772
3770
  return Fe({
@@ -3804,7 +3802,7 @@ function Tt() {
3804
3802
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3805
3803
  label: t,
3806
3804
  insertText: t,
3807
- insertTextRules: y.KeepWhitespace,
3805
+ insertTextRules: k.KeepWhitespace,
3808
3806
  kind: L.Keyword,
3809
3807
  range: void 0
3810
3808
  }))
@@ -3823,7 +3821,7 @@ function ts(t, e, n) {
3823
3821
  suggestions: ["Note", "indexes"].map((i) => ({
3824
3822
  label: i,
3825
3823
  insertText: i,
3826
- insertTextRules: y.KeepWhitespace,
3824
+ insertTextRules: k.KeepWhitespace,
3827
3825
  kind: L.Keyword,
3828
3826
  range: void 0
3829
3827
  }))
@@ -3833,7 +3831,7 @@ function ts(t, e, n) {
3833
3831
  suggestions: ["Note", "indexes"].map((i) => ({
3834
3832
  label: i,
3835
3833
  insertText: i,
3836
- insertTextRules: y.KeepWhitespace,
3834
+ insertTextRules: k.KeepWhitespace,
3837
3835
  kind: L.Keyword,
3838
3836
  range: void 0
3839
3837
  }))
@@ -3844,7 +3842,7 @@ function ns(t, e, n) {
3844
3842
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3845
3843
  label: i,
3846
3844
  insertText: i,
3847
- insertTextRules: y.KeepWhitespace,
3845
+ insertTextRules: k.KeepWhitespace,
3848
3846
  kind: L.Keyword,
3849
3847
  range: void 0
3850
3848
  }))
@@ -3852,7 +3850,7 @@ function ns(t, e, n) {
3852
3850
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3853
3851
  label: i,
3854
3852
  insertText: i,
3855
- insertTextRules: y.KeepWhitespace,
3853
+ insertTextRules: k.KeepWhitespace,
3856
3854
  kind: L.Keyword,
3857
3855
  range: void 0
3858
3856
  }))
@@ -3875,7 +3873,7 @@ function ss(t) {
3875
3873
  return s !== m.Table && s !== m.Schema ? [] : {
3876
3874
  label: i,
3877
3875
  insertText: i,
3878
- insertTextRules: y.KeepWhitespace,
3876
+ insertTextRules: k.KeepWhitespace,
3879
3877
  kind: Ae(s),
3880
3878
  range: void 0
3881
3879
  };
@@ -3948,7 +3946,7 @@ function rs(t, e) {
3948
3946
  ].map((n) => ({
3949
3947
  label: n,
3950
3948
  insertText: n,
3951
- insertTextRules: y.KeepWhitespace,
3949
+ insertTextRules: k.KeepWhitespace,
3952
3950
  kind: L.TypeParameter,
3953
3951
  sortText: L.TypeParameter.toString().padStart(2, "0"),
3954
3952
  range: void 0
@@ -3970,11 +3968,11 @@ function Ct(t, e) {
3970
3968
  const a = ie(r).unwrap_or(void 0);
3971
3969
  if (a === void 0)
3972
3970
  return [];
3973
- const { name: l } = a;
3971
+ const { name: c } = a;
3974
3972
  return {
3975
- label: l,
3976
- insertText: l,
3977
- insertTextRules: y.KeepWhitespace,
3973
+ label: c,
3974
+ insertText: c,
3975
+ insertTextRules: k.KeepWhitespace,
3978
3976
  kind: Ae(m.Column),
3979
3977
  range: void 0
3980
3978
  };
@@ -3995,9 +3993,9 @@ class Xt {
3995
3993
  var a;
3996
3994
  const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3997
3995
  for (; r.length !== 0; ) {
3998
- const l = r.pop();
3999
- if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(l == null ? void 0 : l.kind)) {
4000
- const { startPos: p, endPos: h } = l.referee.declaration;
3996
+ const c = r.pop();
3997
+ if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [de.PRIMARY_EXPRESSION, de.VARIABLE].includes(c == null ? void 0 : c.kind)) {
3998
+ const { startPos: p, endPos: h } = c.referee.declaration;
4001
3999
  return [
4002
4000
  {
4003
4001
  range: {
@@ -4027,9 +4025,9 @@ class $t {
4027
4025
  de.FUNCTION_APPLICATION,
4028
4026
  de.PRIMARY_EXPRESSION
4029
4027
  ].includes(a == null ? void 0 : a.kind)) {
4030
- const { symbol: l } = a;
4031
- if (l != null && l.references.length)
4032
- return l.references.map(({ startPos: p, endPos: h }) => ({
4028
+ const { symbol: c } = a;
4029
+ if (c != null && c.references.length)
4030
+ return c.references.map(({ startPos: p, endPos: h }) => ({
4033
4031
  range: {
4034
4032
  startColumn: p.column + 1,
4035
4033
  startLineNumber: p.line + 1,
@@ -4045,7 +4043,7 @@ class $t {
4045
4043
  }
4046
4044
  const cs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4047
4045
  __proto__: null,
4048
- CompletionItemInsertTextRule: y,
4046
+ CompletionItemInsertTextRule: k,
4049
4047
  CompletionItemKind: L,
4050
4048
  DBMLCompletionItemProvider: Bt,
4051
4049
  DBMLDefinitionProvider: Xt,
@@ -4072,7 +4070,7 @@ class ls {
4072
4070
  _: this.createQuery(
4073
4071
  0,
4074
4072
  () => {
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 })));
4073
+ const e = new cn(this.source).lex().chain((n) => new hn(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4076
4074
  return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new Hn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4077
4075
  }
4078
4076
  ),
@@ -4108,33 +4106,33 @@ class ls {
4108
4106
  return [this.parse.ast()];
4109
4107
  const r = n[s].start;
4110
4108
  let a = this.parse.ast();
4111
- const l = [a];
4109
+ const c = [a];
4112
4110
  for (; ; ) {
4113
4111
  const h = on(a).find((T) => ge(r, T));
4114
- if (h === void 0 || h instanceof M)
4112
+ if (h === void 0 || h instanceof F)
4115
4113
  break;
4116
- l.push(h), a = h;
4114
+ c.push(h), a = h;
4117
4115
  }
4118
4116
  if ((i == null ? void 0 : i.kind) === u.COLON)
4119
- return l;
4120
- for (; l.length > 0; ) {
4117
+ return c;
4118
+ for (; c.length > 0; ) {
4121
4119
  let p = !1;
4122
- const h = I.last(l);
4120
+ const h = I.last(c);
4123
4121
  if (h instanceof w) {
4124
4122
  const T = this.parse.source();
4125
4123
  for (let f = h.end; f < e; f += 1)
4126
4124
  T[f] === `
4127
- ` && (l.pop(), p = !0);
4125
+ ` && (c.pop(), p = !0);
4128
4126
  } else
4129
- h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof $ || h.end < e && (l.pop(), p = !0);
4127
+ h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof $ || h.end < e && (c.pop(), p = !0);
4130
4128
  if (p) {
4131
- const T = I.last(l);
4132
- T instanceof A && T.end <= e && l.pop();
4129
+ const T = I.last(c);
4130
+ T instanceof A && T.end <= e && c.pop();
4133
4131
  }
4134
4132
  if (!p)
4135
4133
  break;
4136
4134
  }
4137
- return l;
4135
+ return c;
4138
4136
  }
4139
4137
  ),
4140
4138
  token: this.createQuery(
@@ -4206,14 +4204,14 @@ class ls {
4206
4204
  if (!((i = r.symbol) != null && i.symbolTable))
4207
4205
  continue;
4208
4206
  const { symbolTable: a } = r.symbol;
4209
- let l = [a], p = [];
4207
+ let c = [a], p = [];
4210
4208
  for (const h of e)
4211
- p = l.flatMap(
4209
+ p = c.flatMap(
4212
4210
  (T) => qt(h).flatMap((f) => {
4213
4211
  const N = T.get(f), g = ie(f).unwrap_or(void 0);
4214
4212
  return !N || !g ? [] : { ...g, symbol: N };
4215
4213
  })
4216
- ), l = p.flatMap(
4214
+ ), c = p.flatMap(
4217
4215
  (T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
4218
4216
  );
4219
4217
  s.push(...p);
@@ -4240,8 +4238,8 @@ class ls {
4240
4238
  if (r.has(a))
4241
4239
  return r.get(a);
4242
4240
  }
4243
- const l = n(i);
4244
- 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;
4241
+ const c = n(i);
4242
+ 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;
4245
4243
  };
4246
4244
  }
4247
4245
  setSource(e) {