@dbml/parse 3.1.5-alpha.0 → 3.1.5

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
- 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 $t(t) {
2
+ var c = /* @__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))(c || {});
3
+ function Xt(t) {
4
4
  switch (t.kind) {
5
5
  case "<newline>":
6
6
  case "<space>":
@@ -36,22 +36,22 @@ function rt(t) {
36
36
  function at(t) {
37
37
  return t !== void 0 && t.kind === "<op>";
38
38
  }
39
- class V {
39
+ class B {
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 V(e, n, s, i, r);
44
+ return new B(e, n, s, i, r);
45
45
  }
46
46
  }
47
47
  function bt(t) {
48
- return t.trailingTrivia.find(({ kind: e }) => e === u.NEWLINE) !== void 0;
48
+ return t.trailingTrivia.find(({ kind: e }) => e === c.NEWLINE) !== void 0;
49
49
  }
50
50
  function ot(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || bt(t);
51
+ return e.leadingTrivia.find(({ kind: s }) => s === c.NEWLINE) !== void 0 || bt(t);
52
52
  }
53
53
  function Ve(t) {
54
- return t.trailingTrivia.find(({ kind: e }) => e === u.SPACE) !== void 0;
54
+ return t.trailingTrivia.find(({ kind: e }) => e === c.SPACE) !== void 0;
55
55
  }
56
56
  function It(t) {
57
57
  return t.trailingTrivia.length === 0 ? t.end : It(I.last(t.trailingTrivia));
@@ -59,12 +59,12 @@ function It(t) {
59
59
  function Lt(t) {
60
60
  return t.leadingTrivia.length === 0 ? t.start : Lt(t.leadingTrivia[0]);
61
61
  }
62
- function Wt(t) {
63
- return [u.SINGLE_LINE_COMMENT, u.MULTILINE_COMMENT].includes(
62
+ function $t(t) {
63
+ return [c.SINGLE_LINE_COMMENT, c.MULTILINE_COMMENT].includes(
64
64
  t.kind
65
65
  );
66
66
  }
67
- class jt {
67
+ class Wt {
68
68
  constructor() {
69
69
  this.id = 0;
70
70
  }
@@ -75,32 +75,32 @@ class jt {
75
75
  return this.id++;
76
76
  }
77
77
  }
78
- class x {
78
+ class y {
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 V ? Lt(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? 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 V ? It(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? It(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
94
94
  }, this.fullEnd = NaN), this.start = this.startPos.offset, this.end = this.endPos.offset;
95
95
  }
96
96
  }
97
- var ue = /* @__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))(ue || {});
98
- class F extends x {
97
+ var he = /* @__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))(he || {});
98
+ class C extends y {
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 _ extends x {
103
+ class _ extends y {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -108,7 +108,7 @@ class _ extends x {
108
108
  alias: i,
109
109
  attributeList: r,
110
110
  bodyColon: a,
111
- body: c
111
+ body: l
112
112
  }, p) {
113
113
  if (super(p, "<element-declaration>", [
114
114
  e,
@@ -117,18 +117,18 @@ class _ extends x {
117
117
  i,
118
118
  r,
119
119
  a,
120
- c
121
- ]), c && a && !(c instanceof v || c instanceof _))
120
+ l
121
+ ]), l && a && !(l instanceof k || l instanceof _))
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 = c;
123
+ this.type = e, this.name = n, this.as = s, this.alias = i, this.attributeList = r, this.bodyColon = a, this.body = l;
124
124
  }
125
125
  }
126
- class te extends x {
126
+ class K extends y {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class ne extends x {
131
+ class ne extends y {
132
132
  constructor({
133
133
  name: e,
134
134
  colon: n,
@@ -137,12 +137,12 @@ class ne extends x {
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 x {
140
+ class Q extends y {
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 q extends x {
145
+ class q extends y {
146
146
  constructor({
147
147
  op: e,
148
148
  leftExpression: n,
@@ -151,22 +151,22 @@ class q extends x {
151
151
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
152
152
  }
153
153
  }
154
- class De extends x {
154
+ class De extends y {
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 K extends x {
159
+ class ee extends y {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class v extends x {
164
+ class k extends y {
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 ee extends x {
169
+ class te extends y {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class ee extends x {
175
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
- class U extends x {
178
+ class U extends y {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -189,7 +189,7 @@ class U extends x {
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
- class J extends x {
192
+ class J extends y {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -220,7 +220,7 @@ class Xe extends J {
220
220
  ), this.kind = "<group-expression>";
221
221
  }
222
222
  }
223
- class H extends x {
223
+ class H extends y {
224
224
  constructor({
225
225
  callee: e,
226
226
  argumentList: n
@@ -228,28 +228,28 @@ class H extends x {
228
228
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class pe extends x {
231
+ class de extends y {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class W extends x {
236
+ class X extends y {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class R extends x {
241
+ class R extends y {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class we extends x {
246
+ class we extends y {
247
247
  constructor({ pre: e }, n) {
248
- const s = V.create(u.SPACE, e.endPos, e.endPos, " ", !1);
248
+ const s = B.create(c.SPACE, e.endPos, e.endPos, " ", !1);
249
249
  super(n, "<dummy>", [s]);
250
250
  }
251
251
  }
252
- class he extends x {
252
+ class fe extends y {
253
253
  constructor({ expression: e, indexer: n }, s) {
254
254
  super(s, "<array>", [e, n]), this.array = e, this.indexer = n;
255
255
  }
@@ -264,12 +264,12 @@ function gt(t, e) {
264
264
  (i) => i !== null
265
265
  );
266
266
  }
267
- function as(t, e = !1) {
267
+ function is(t, e = !1) {
268
268
  return JSON.stringify(
269
269
  t,
270
270
  function(n, s) {
271
271
  var i;
272
- return !(this instanceof F) && n === "symbol" ? s == null ? void 0 : s.id : (
272
+ return !(this instanceof C) && n === "symbol" ? s == null ? void 0 : s.id : (
273
273
  /* this instanceof SyntaxNode && */
274
274
  n === "symbol" ? {
275
275
  symbolTable: s == null ? void 0 : s.symbolTable,
@@ -334,11 +334,11 @@ class A {
334
334
  return !1;
335
335
  }
336
336
  }
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 || {});
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))(m || {});
338
338
  function $e(t) {
339
339
  return `Schema:${t}`;
340
340
  }
341
- function xe(t) {
341
+ function ke(t) {
342
342
  return `Table:${t}`;
343
343
  }
344
344
  function We(t) {
@@ -356,9 +356,6 @@ function ze(t) {
356
356
  function Qe(t) {
357
357
  return `TableGroup field:${t}`;
358
358
  }
359
- function Yt(t) {
360
- return `Note:${t}`;
361
- }
362
359
  function Fe(t, e) {
363
360
  switch (e) {
364
361
  case "Column":
@@ -370,7 +367,7 @@ function Fe(t, e) {
370
367
  case "Schema":
371
368
  return $e(t);
372
369
  case "Table":
373
- return xe(t);
370
+ return ke(t);
374
371
  case "TableGroup":
375
372
  return ze(t);
376
373
  case "TableGroup field":
@@ -386,17 +383,17 @@ function se(t) {
386
383
  kind: e
387
384
  }) : new A();
388
385
  }
389
- function zt(t) {
386
+ function jt(t) {
390
387
  const e = se(t).unwrap_or(void 0);
391
388
  if (!e)
392
389
  return !1;
393
390
  const { kind: n, name: s } = e;
394
391
  return n === "Schema" && s === "public";
395
392
  }
396
- function Qt(t) {
393
+ function Yt(t) {
397
394
  return [
398
395
  $e,
399
- xe,
396
+ ke,
400
397
  je,
401
398
  ze,
402
399
  We,
@@ -408,27 +405,27 @@ function qe(t) {
408
405
  const [e] = t;
409
406
  return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
410
407
  }
411
- function ke(t) {
408
+ function xe(t) {
412
409
  const [e] = t;
413
410
  return e >= "0" && e <= "9";
414
411
  }
415
- function qt(t) {
412
+ function zt(t) {
416
413
  const [e] = t;
417
- return ke(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
414
+ return xe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
418
415
  }
419
- function Ie(t) {
420
- return qe(t) || ke(t);
416
+ function ue(t) {
417
+ return qe(t) || xe(t);
421
418
  }
422
- function ct(t, e) {
419
+ function lt(t, e) {
423
420
  const n = [], s = Math.min(t.length, e.length);
424
421
  for (let i = 0; i < s; i += 1)
425
422
  n.push(t[i], e[i]);
426
423
  return n.push(...t.slice(s), ...e.slice(s)), n;
427
424
  }
428
- function Le(t, e) {
425
+ function Ie(t, e) {
429
426
  return t >= e.start && t < e.end;
430
427
  }
431
- class Ht {
428
+ class Qt {
432
429
  constructor() {
433
430
  this.id = 0;
434
431
  }
@@ -444,12 +441,12 @@ class _t {
444
441
  this.references = [], this.id = n, this.symbolTable = e;
445
442
  }
446
443
  }
447
- class Jt {
444
+ class qt {
448
445
  constructor({ symbolTable: e, declaration: n }, s) {
449
446
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
450
447
  }
451
448
  }
452
- class Zt {
449
+ class Ht {
453
450
  constructor({ declaration: e }, n) {
454
451
  this.references = [], this.id = n, this.declaration = e;
455
452
  }
@@ -459,28 +456,28 @@ class At {
459
456
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
460
457
  }
461
458
  }
462
- class Kt {
459
+ class Jt {
463
460
  constructor({ declaration: e }, n) {
464
461
  this.references = [], this.id = n, this.declaration = e;
465
462
  }
466
463
  }
467
- class en {
464
+ class Zt {
468
465
  constructor({ symbolTable: e, declaration: n }, s) {
469
466
  this.references = [], this.id = s, this.symbolTable = e, this.declaration = n;
470
467
  }
471
468
  }
472
- class tn {
469
+ class Kt {
473
470
  constructor({ declaration: e }, n) {
474
471
  this.references = [], this.id = n, this.declaration = e;
475
472
  }
476
473
  }
477
474
  var o = /* @__PURE__ */ ((t) => (t[t.UNKNOWN_SYMBOL = 1e3] = "UNKNOWN_SYMBOL", t[t.UNEXPECTED_SYMBOL = 1001] = "UNEXPECTED_SYMBOL", t[t.UNEXPECTED_EOF = 1002] = "UNEXPECTED_EOF", t[t.UNEXPECTED_NEWLINE = 1003] = "UNEXPECTED_NEWLINE", t[t.UNKNOWN_TOKEN = 1004] = "UNKNOWN_TOKEN", t[t.UNEXPECTED_TOKEN = 1005] = "UNEXPECTED_TOKEN", t[t.UNEXPECTED_ELEMENT_DECLARATION = 1006] = "UNEXPECTED_ELEMENT_DECLARATION", t[t.MISSING_SPACES = 1007] = "MISSING_SPACES", t[t.UNKNOWN_PREFIX_OP = 1008] = "UNKNOWN_PREFIX_OP", t[t.INVALID_OPERAND = 1009] = "INVALID_OPERAND", t[t.EMPTY_ATTRIBUTE_NAME = 1010] = "EMPTY_ATTRIBUTE_NAME", t[t.INVALID_NAME = 3e3] = "INVALID_NAME", t[t.UNEXPECTED_NAME = 3001] = "UNEXPECTED_NAME", t[t.NAME_NOT_FOUND = 3002] = "NAME_NOT_FOUND", t[t.DUPLICATE_NAME = 3003] = "DUPLICATE_NAME", t[t.INVALID_ALIAS = 3004] = "INVALID_ALIAS", t[t.UNEXPECTED_ALIAS = 3005] = "UNEXPECTED_ALIAS", t[t.UNEXPECTED_SETTINGS = 3006] = "UNEXPECTED_SETTINGS", t[t.INVALID_SETTINGS = 3007] = "INVALID_SETTINGS", t[t.UNEXPECTED_SIMPLE_BODY = 3008] = "UNEXPECTED_SIMPLE_BODY", t[t.UNEXPECTED_COMPLEX_BODY = 3009] = "UNEXPECTED_COMPLEX_BODY", t[t.INVALID_TABLE_CONTEXT = 3010] = "INVALID_TABLE_CONTEXT", t[t.INVALID_TABLE_SETTING = 3011] = "INVALID_TABLE_SETTING", t[t.DUPLICATE_TABLE_SETTING = 3012] = "DUPLICATE_TABLE_SETTING", t[t.INVALID_TABLEGROUP_CONTEXT = 3013] = "INVALID_TABLEGROUP_CONTEXT", t[t.INVALID_TABLEGROUP_ELEMENT_NAME = 3014] = "INVALID_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_ELEMENT_NAME = 3015] = "DUPLICATE_TABLEGROUP_ELEMENT_NAME", t[t.DUPLICATE_TABLEGROUP_FIELD_NAME = 3016] = "DUPLICATE_TABLEGROUP_FIELD_NAME", t[t.INVALID_TABLEGROUP_FIELD = 3017] = "INVALID_TABLEGROUP_FIELD", t[t.EMPTY_TABLE = 3018] = "EMPTY_TABLE", t[t.INVALID_COLUMN = 3019] = "INVALID_COLUMN", t[t.INVALID_COLUMN_NAME = 3020] = "INVALID_COLUMN_NAME", t[t.UNKNOWN_COLUMN_SETTING = 3021] = "UNKNOWN_COLUMN_SETTING", t[t.INVALID_COLUMN_TYPE = 3022] = "INVALID_COLUMN_TYPE", t[t.DUPLICATE_COLUMN_NAME = 3023] = "DUPLICATE_COLUMN_NAME", t[t.DUPLICATE_COLUMN_SETTING = 3024] = "DUPLICATE_COLUMN_SETTING", t[t.INVALID_COLUMN_SETTING_VALUE = 3025] = "INVALID_COLUMN_SETTING_VALUE", t[t.INVALID_ENUM_CONTEXT = 3026] = "INVALID_ENUM_CONTEXT", t[t.INVALID_ENUM_ELEMENT_NAME = 3027] = "INVALID_ENUM_ELEMENT_NAME", t[t.INVALID_ENUM_ELEMENT = 3028] = "INVALID_ENUM_ELEMENT", t[t.DUPLICATE_ENUM_ELEMENT_NAME = 3029] = "DUPLICATE_ENUM_ELEMENT_NAME", t[t.UNKNOWN_ENUM_ELEMENT_SETTING = 3030] = "UNKNOWN_ENUM_ELEMENT_SETTING", t[t.DUPLICATE_ENUM_ELEMENT_SETTING = 3031] = "DUPLICATE_ENUM_ELEMENT_SETTING", t[t.INVALID_ENUM_ELEMENT_SETTING = 3032] = "INVALID_ENUM_ELEMENT_SETTING", t[t.EMPTY_ENUM = 3033] = "EMPTY_ENUM", t[t.INVALID_REF_CONTEXT = 3034] = "INVALID_REF_CONTEXT", t[t.UNKNOWN_REF_SETTING = 3035] = "UNKNOWN_REF_SETTING", t[t.DUPLICATE_REF_SETTING = 3036] = "DUPLICATE_REF_SETTING", t[t.INVALID_REF_SETTING_VALUE = 3037] = "INVALID_REF_SETTING_VALUE", t[t.INVALID_REF_RELATIONSHIP = 3038] = "INVALID_REF_RELATIONSHIP", t[t.INVALID_REF_FIELD = 3039] = "INVALID_REF_FIELD", t[t.EMPTY_REF = 3040] = "EMPTY_REF", t[t.REF_REDEFINED = 3041] = "REF_REDEFINED", t[t.INVALID_NOTE_CONTEXT = 3042] = "INVALID_NOTE_CONTEXT", t[t.INVALID_NOTE = 3043] = "INVALID_NOTE", t[t.NOTE_REDEFINED = 3044] = "NOTE_REDEFINED", t[t.NOTE_CONTENT_REDEFINED = 3045] = "NOTE_CONTENT_REDEFINED", t[t.EMPTY_NOTE = 3046] = "EMPTY_NOTE", t[t.INVALID_INDEXES_CONTEXT = 3047] = "INVALID_INDEXES_CONTEXT", t[t.INVALID_INDEXES_FIELD = 3048] = "INVALID_INDEXES_FIELD", t[t.INVALID_INDEX = 3049] = "INVALID_INDEX", t[t.UNKNOWN_INDEX_SETTING = 3050] = "UNKNOWN_INDEX_SETTING", t[t.DUPLICATE_INDEX_SETTING = 3051] = "DUPLICATE_INDEX_SETTING", t[t.UNEXPECTED_INDEX_SETTING_VALUE = 3052] = "UNEXPECTED_INDEX_SETTING_VALUE", t[t.INVALID_INDEX_SETTING_VALUE = 3053] = "INVALID_INDEX_SETTING_VALUE", t[t.INVALID_PROJECT_CONTEXT = 3054] = "INVALID_PROJECT_CONTEXT", t[t.PROJECT_REDEFINED = 3055] = "PROJECT_REDEFINED", t[t.INVALID_PROJECT_FIELD = 3056] = "INVALID_PROJECT_FIELD", t[t.INVALID_CUSTOM_CONTEXT = 3057] = "INVALID_CUSTOM_CONTEXT", t[t.INVALID_CUSTOM_ELEMENT_VALUE = 3058] = "INVALID_CUSTOM_ELEMENT_VALUE", t[t.INVALID_ELEMENT_IN_SIMPLE_BODY = 3059] = "INVALID_ELEMENT_IN_SIMPLE_BODY", t[t.BINDING_ERROR = 4e3] = "BINDING_ERROR", t[t.UNSUPPORTED = 5e3] = "UNSUPPORTED", t[t.CIRCULAR_REF = 5001] = "CIRCULAR_REF", t[t.SAME_ENDPOINT = 5002] = "SAME_ENDPOINT", t[t.UNEQUAL_FIELDS_BINARY_REF = 5003] = "UNEQUAL_FIELDS_BINARY_REF", t[t.CONFLICTING_SETTING = 5004] = "CONFLICTING_SETTING", t))(o || {});
478
- class l extends Error {
475
+ class u extends Error {
479
476
  constructor(e, n, s) {
480
- 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);
477
+ 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, u.prototype);
481
478
  }
482
479
  }
483
- class B {
480
+ class F {
484
481
  constructor(e, n) {
485
482
  this.value = e, this.errors = n === void 0 ? [] : n;
486
483
  }
@@ -492,17 +489,17 @@ class B {
492
489
  }
493
490
  chain(e) {
494
491
  const n = e(this.value), s = [...this.errors, ...n.errors];
495
- return new B(n.value, s);
492
+ return new F(n.value, s);
496
493
  }
497
494
  map(e) {
498
- return new B(e(this.value), this.errors);
495
+ return new F(e(this.value), this.errors);
499
496
  }
500
497
  }
501
- function nn(t, e, n) {
502
- if (!t || !fe(t) || e.length === 0)
498
+ function en(t, e, n) {
499
+ if (!t || !pe(t) || e.length === 0)
503
500
  return new A();
504
501
  const s = [...e], i = Be(t).unwrap(), r = s.pop();
505
- if (!(r instanceof ee))
502
+ if (!(r instanceof te))
506
503
  return new A();
507
504
  const a = I.last(s) instanceof U ? s.pop() : void 0;
508
505
  return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
@@ -529,19 +526,19 @@ function nn(t, e, n) {
529
526
  })
530
527
  ) : new A();
531
528
  }
532
- function lt(t) {
533
- return t.kind === u.IDENTIFIER && t.value === "as";
529
+ function ct(t) {
530
+ return t.kind === c.IDENTIFIER && t.value === "as";
534
531
  }
535
532
  function E(t) {
536
- t && (t instanceof V ? sn(t) : rn(t));
533
+ t && (t instanceof B ? tn(t) : nn(t));
537
534
  }
538
- function sn(t) {
539
- t.kind !== u.EOF && (t.isInvalid = !0);
535
+ function tn(t) {
536
+ t.kind !== c.EOF && (t.isInvalid = !0);
540
537
  }
541
- function rn(t) {
538
+ function nn(t) {
542
539
  if (t instanceof _)
543
540
  E(t.type), E(t.name), E(t.as), E(t.alias), E(t.bodyColon), E(t.attributeList), E(t.body);
544
- else if (t instanceof te)
541
+ else if (t instanceof K)
545
542
  t.identifiers.forEach(E);
546
543
  else if (t instanceof ne)
547
544
  E(t.name), E(t.colon), E(t.value);
@@ -551,7 +548,7 @@ function rn(t) {
551
548
  E(t.leftExpression), E(t.op), E(t.rightExpression);
552
549
  else if (t instanceof De)
553
550
  E(t.op), E(t.expression);
554
- else if (t instanceof ee)
551
+ else if (t instanceof te)
555
552
  E(t.blockOpenBrace), t.body.forEach(E), E(t.blockCloseBrace);
556
553
  else if (t instanceof U)
557
554
  E(t.listOpenBracket), t.commaList.forEach(E), t.elementList.forEach(E), E(t.listCloseBracket);
@@ -559,15 +556,15 @@ function rn(t) {
559
556
  E(t.tupleOpenParen), t.commaList.forEach(E), t.elementList.forEach(E), E(t.tupleCloseParen);
560
557
  else if (t instanceof H)
561
558
  E(t.callee), E(t.argumentList);
562
- else if (t instanceof v)
559
+ else if (t instanceof k)
563
560
  E(t.callee), t.args.forEach(E);
564
561
  else if (t instanceof R)
565
562
  E(t.expression);
566
- else if (t instanceof K)
563
+ else if (t instanceof ee)
567
564
  E(t.value);
568
- else if (t instanceof W)
565
+ else if (t instanceof X)
569
566
  E(t.variable);
570
- else if (t instanceof pe)
567
+ else if (t instanceof de)
571
568
  E(t.literal);
572
569
  else
573
570
  throw t instanceof Xe ? new Error("This case is handled by the TupleExpressionNode case") : new Error("Unreachable case in markInvalidNode");
@@ -578,8 +575,8 @@ function vt(t) {
578
575
  function P(...t) {
579
576
  return t.filter((e) => e !== void 0);
580
577
  }
581
- function an(t) {
582
- if (t instanceof F)
578
+ function sn(t) {
579
+ if (t instanceof C)
583
580
  return P(...t.body, t.eof);
584
581
  if (t instanceof _)
585
582
  return P(
@@ -593,11 +590,11 @@ function an(t) {
593
590
  );
594
591
  if (t instanceof ne)
595
592
  return P(t.name, t.colon, t.value);
596
- if (t instanceof te)
593
+ if (t instanceof K)
597
594
  return t.identifiers;
598
- if (t instanceof pe)
595
+ if (t instanceof de)
599
596
  return t.literal ? [t.literal] : [];
600
- if (t instanceof W)
597
+ if (t instanceof X)
601
598
  return P(t.variable);
602
599
  if (t instanceof Q)
603
600
  return P(t.op, t.expression);
@@ -605,22 +602,22 @@ function an(t) {
605
602
  return P(t.leftExpression, t.op, t.rightExpression);
606
603
  if (t instanceof De)
607
604
  return P(t.expression, t.op);
608
- if (t instanceof K)
605
+ if (t instanceof ee)
609
606
  return P(t.value);
610
- if (t instanceof v)
607
+ if (t instanceof k)
611
608
  return P(t.callee, ...t.args);
612
- if (t instanceof ee)
609
+ if (t instanceof te)
613
610
  return P(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
614
611
  if (t instanceof U)
615
612
  return P(
616
613
  t.listOpenBracket,
617
- ...ct(t.elementList, t.commaList),
614
+ ...lt(t.elementList, t.commaList),
618
615
  t.listCloseBracket
619
616
  );
620
617
  if (t instanceof J)
621
618
  return P(
622
619
  t.tupleOpenParen,
623
- ...ct(t.elementList, t.commaList),
620
+ ...lt(t.elementList, t.commaList),
624
621
  t.tupleCloseParen
625
622
  );
626
623
  if (t instanceof H)
@@ -632,20 +629,20 @@ function an(t) {
632
629
  function Be(t) {
633
630
  return M(t) ? new S(t.expression.variable) : new A();
634
631
  }
635
- function j(t) {
632
+ function $(t) {
636
633
  var e;
637
- return t instanceof R && (t.expression instanceof W && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
634
+ return t instanceof R && (t.expression instanceof X && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof de && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
638
635
  }
639
636
  function M(t) {
640
- return t instanceof R && t.expression instanceof W && t.expression.variable instanceof V;
637
+ return t instanceof R && t.expression instanceof X && t.expression.variable instanceof B;
641
638
  }
642
- function fe(t) {
639
+ function pe(t) {
643
640
  var e;
644
- return t instanceof R && t.expression instanceof W && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
641
+ return t instanceof R && t.expression instanceof X && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
645
642
  }
646
643
  function He(t) {
647
644
  var e;
648
- return t instanceof q && t.leftExpression instanceof x && t.rightExpression instanceof x && ((e = t.op) == null ? void 0 : e.value) === ".";
645
+ return t instanceof q && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
649
646
  }
650
647
  function Re(t) {
651
648
  if (t === void 0)
@@ -653,7 +650,7 @@ function Re(t) {
653
650
  const e = t.identifiers.map((n) => n.value).join(" ");
654
651
  return e === "" ? new A() : new S(e);
655
652
  }
656
- class on {
653
+ class rn {
657
654
  // list of errors during lexing
658
655
  constructor(e) {
659
656
  this.start = {
@@ -693,7 +690,7 @@ class on {
693
690
  this.tokens.push(this.createToken(e, n));
694
691
  }
695
692
  createToken(e, n = !1) {
696
- return V.create(
693
+ return B.create(
697
694
  e,
698
695
  this.start,
699
696
  this.current,
@@ -702,50 +699,50 @@ class on {
702
699
  );
703
700
  }
704
701
  lex() {
705
- return this.scanTokens(), this.tokens.push(V.create(u.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new B(this.tokens, this.errors);
702
+ return this.scanTokens(), this.tokens.push(B.create(c.EOF, this.start, this.current, "", !1)), this.gatherTrivia(), this.gatherInvalid(), new F(this.tokens, this.errors);
706
703
  }
707
704
  scanTokens() {
708
705
  for (; !this.isAtEnd(); ) {
709
706
  const e = this.advance();
710
707
  switch (e) {
711
708
  case " ":
712
- this.addToken(u.SPACE);
709
+ this.addToken(c.SPACE);
713
710
  break;
714
711
  case "\r":
715
712
  break;
716
713
  case `
717
714
  `:
718
- this.addToken(u.NEWLINE);
715
+ this.addToken(c.NEWLINE);
719
716
  break;
720
717
  case " ":
721
- this.addToken(u.TAB);
718
+ this.addToken(c.TAB);
722
719
  break;
723
720
  case ",":
724
- this.addToken(u.COMMA);
721
+ this.addToken(c.COMMA);
725
722
  break;
726
723
  case "(":
727
- this.addToken(u.LPAREN);
724
+ this.addToken(c.LPAREN);
728
725
  break;
729
726
  case ")":
730
- this.addToken(u.RPAREN);
727
+ this.addToken(c.RPAREN);
731
728
  break;
732
729
  case "[":
733
- this.addToken(u.LBRACKET);
730
+ this.addToken(c.LBRACKET);
734
731
  break;
735
732
  case "]":
736
- this.addToken(u.RBRACKET);
733
+ this.addToken(c.RBRACKET);
737
734
  break;
738
735
  case "{":
739
- this.addToken(u.LBRACE);
736
+ this.addToken(c.LBRACE);
740
737
  break;
741
738
  case "}":
742
- this.addToken(u.RBRACE);
739
+ this.addToken(c.RBRACE);
743
740
  break;
744
741
  case ";":
745
- this.addToken(u.SEMICOLON);
742
+ this.addToken(c.SEMICOLON);
746
743
  break;
747
744
  case ":":
748
- this.addToken(u.COLON);
745
+ this.addToken(c.COLON);
749
746
  break;
750
747
  case "'":
751
748
  this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
@@ -771,15 +768,15 @@ class on {
771
768
  this.identifier();
772
769
  break;
773
770
  }
774
- if (ke(e)) {
775
- this.numericLiteral();
771
+ if (xe(e)) {
772
+ this.numericLiteralOrIdentifier();
776
773
  break;
777
774
  }
778
- this.addToken(u.OP, !0), this.errors.push(
779
- new l(
775
+ this.addToken(c.OP, !0), this.errors.push(
776
+ new u(
780
777
  o.UNKNOWN_SYMBOL,
781
778
  `Unexpected token '${e}'`,
782
- this.createToken(u.OP, !0)
779
+ this.createToken(c.OP, !0)
783
780
  )
784
781
  );
785
782
  break;
@@ -791,7 +788,7 @@ class on {
791
788
  let e = !0, n = [], s;
792
789
  const i = [];
793
790
  for (const r of this.tokens)
794
- $t(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);
791
+ Xt(r) ? (n.push(r), r.kind === c.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);
795
792
  this.tokens = i;
796
793
  }
797
794
  gatherInvalid() {
@@ -816,14 +813,14 @@ class on {
816
813
  // Whether to interpret '\' as a backlash
817
814
  consumeStopSequence: a = !0
818
815
  }) {
819
- let c = "";
816
+ let l = "";
820
817
  for (; !this.isAtEnd() && (s || !this.check(`
821
818
  `)) && !this.check(n); )
822
- this.peek() === "\\" && !r ? (this.advance(), c += this.escapedString()) : c += this.advance();
819
+ this.peek() === "\\" && !r ? (this.advance(), l += this.escapedString()) : l += this.advance();
823
820
  if (this.isAtEnd() && !i) {
824
821
  const p = this.createToken(e, !0);
825
822
  this.tokens.push(p), this.errors.push(
826
- new l(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
823
+ new u(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
827
824
  );
828
825
  return;
829
826
  }
@@ -831,7 +828,7 @@ class on {
831
828
  `) && !s) {
832
829
  const p = this.createToken(e, !0);
833
830
  this.tokens.push(p), this.errors.push(
834
- new l(
831
+ new u(
835
832
  o.UNEXPECTED_NEWLINE,
836
833
  "Invalid newline encountered while parsing",
837
834
  p
@@ -839,38 +836,38 @@ class on {
839
836
  );
840
837
  return;
841
838
  }
842
- a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, c, !1));
839
+ a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
843
840
  }
844
841
  singleLineStringLiteral() {
845
- this.consumeUntil(u.STRING_LITERAL, "'", {
842
+ this.consumeUntil(c.STRING_LITERAL, "'", {
846
843
  allowNewline: !1,
847
844
  allowEof: !1,
848
845
  raw: !1
849
846
  });
850
847
  }
851
848
  multilineStringLiteral() {
852
- this.consumeUntil(u.STRING_LITERAL, "'''", {
849
+ this.consumeUntil(c.STRING_LITERAL, "'''", {
853
850
  allowNewline: !0,
854
851
  allowEof: !1,
855
852
  raw: !1
856
853
  });
857
854
  }
858
855
  functionExpression() {
859
- this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
856
+ this.consumeUntil(c.FUNCTION_EXPRESSION, "`", {
860
857
  allowNewline: !1,
861
858
  allowEof: !1,
862
859
  raw: !0
863
860
  });
864
861
  }
865
862
  quotedVariable() {
866
- this.consumeUntil(u.QUOTED_STRING, '"', {
863
+ this.consumeUntil(c.QUOTED_STRING, '"', {
867
864
  allowNewline: !1,
868
865
  allowEof: !1,
869
866
  raw: !1
870
867
  });
871
868
  }
872
869
  singleLineComment() {
873
- this.consumeUntil(u.SINGLE_LINE_COMMENT, `
870
+ this.consumeUntil(c.SINGLE_LINE_COMMENT, `
874
871
  `, {
875
872
  allowNewline: !0,
876
873
  allowEof: !0,
@@ -879,47 +876,55 @@ class on {
879
876
  });
880
877
  }
881
878
  multilineComment() {
882
- this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
879
+ this.consumeUntil(c.MULTILINE_COMMENT, "*/", {
883
880
  allowNewline: !0,
884
881
  allowEof: !1,
885
882
  raw: !0
886
883
  });
887
884
  }
888
885
  identifier() {
889
- for (; !this.isAtEnd() && Ie(this.peek()); )
886
+ for (; !this.isAtEnd() && ue(this.peek()); )
890
887
  this.advance();
891
- this.addToken(u.IDENTIFIER);
888
+ this.addToken(c.IDENTIFIER);
892
889
  }
893
890
  operator() {
894
891
  for (; rt(this.peek()); )
895
892
  this.advance();
896
- this.addToken(u.OP);
893
+ this.addToken(c.OP);
897
894
  }
898
- numericLiteral() {
895
+ // we accept identifiers starting with digits but must contain at least one char or underscore
896
+ numericLiteralOrIdentifier() {
899
897
  let e = 0;
900
898
  if (this.isAtEnd())
901
- return this.addToken(u.NUMERIC_LITERAL);
899
+ return this.addToken(c.NUMERIC_LITERAL);
902
900
  for (; !this.isAtEnd(); ) {
903
- const s = this.check(".");
904
- if (e += s ? 1 : 0, e > 1)
901
+ const n = this.check(".");
902
+ if (e += n ? 1 : 0, e > 1)
905
903
  break;
906
- if (!s && this.current.offset === this.text.length - 1)
907
- return this.advance(), this.addToken(u.NUMERIC_LITERAL);
908
- if (!s && !Ie(this.peek()))
909
- return this.addToken(u.NUMERIC_LITERAL);
910
- if (!s && !ke(this.peek()))
904
+ if (!n && this.current.offset === this.text.length - 1)
905
+ return this.advance(), this.addToken(c.NUMERIC_LITERAL);
906
+ if (!n && !ue(this.peek()))
907
+ return this.addToken(c.NUMERIC_LITERAL);
908
+ if (!n && !xe(this.peek()))
911
909
  break;
912
910
  this.advance();
913
911
  }
914
- for (; !this.isAtEnd() && (this.check(".") || Ie(this.peek())); )
915
- this.advance();
916
- const n = this.createToken(u.NUMERIC_LITERAL, !0);
917
- this.tokens.push(n), this.errors.push(new l(o.UNKNOWN_TOKEN, "Invalid number", n));
912
+ if (e > 0) {
913
+ for (; !this.isAtEnd() && (this.check(".") || ue(this.peek())); )
914
+ this.advance();
915
+ const n = this.createToken(c.NUMERIC_LITERAL, !0);
916
+ this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
917
+ } else {
918
+ for (; !this.isAtEnd() && ue(this.peek()); )
919
+ this.advance();
920
+ const n = this.createToken(c.IDENTIFIER, !1);
921
+ this.tokens.push(n);
922
+ }
918
923
  }
919
924
  colorLiteral() {
920
- for (; !this.isAtEnd() && Ie(this.peek()); )
925
+ for (; !this.isAtEnd() && ue(this.peek()); )
921
926
  this.advance();
922
- this.addToken(u.COLOR_LITERAL);
927
+ this.addToken(c.COLOR_LITERAL);
923
928
  }
924
929
  escapedString() {
925
930
  if (this.isAtEnd())
@@ -949,7 +954,7 @@ class on {
949
954
  case "u": {
950
955
  let e = "";
951
956
  for (let n = 0; n <= 3; n += 1) {
952
- if (this.isAtEnd() || !Ie(this.peek()))
957
+ if (this.isAtEnd() || !ue(this.peek()))
953
958
  return `\\u${e}`;
954
959
  e += this.advance();
955
960
  }
@@ -961,7 +966,7 @@ class on {
961
966
  }
962
967
  }
963
968
  var ye = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ye || {});
964
- class cn {
969
+ class an {
965
970
  constructor() {
966
971
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
967
972
  }
@@ -1002,7 +1007,7 @@ class cn {
1002
1007
  if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
1003
1008
  for (let s = n; s < e.length - 1; s += 1)
1004
1009
  switch (e[s].kind) {
1005
- case u.COMMA:
1010
+ case c.COMMA:
1006
1011
  if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
1007
1012
  return [...this.stack].reverse().find(
1008
1013
  (r) => [
@@ -1012,22 +1017,22 @@ class cn {
1012
1017
  ].includes(r)
1013
1018
  );
1014
1019
  break;
1015
- case u.RPAREN:
1020
+ case c.RPAREN:
1016
1021
  if (this.isWithinGroupExpressionContext())
1017
1022
  return 1;
1018
1023
  break;
1019
- case u.RBRACE:
1024
+ case c.RBRACE:
1020
1025
  if (this.isWithinBlockExpressionContext())
1021
1026
  return 2;
1022
1027
  break;
1023
- case u.RBRACKET:
1028
+ case c.RBRACKET:
1024
1029
  if (this.isWithinListExpressionContext())
1025
1030
  return 0;
1026
1031
  break;
1027
1032
  }
1028
1033
  }
1029
1034
  }
1030
- class ln {
1035
+ class on {
1031
1036
  constructor(e) {
1032
1037
  this.generator = e;
1033
1038
  }
@@ -1040,29 +1045,29 @@ class d {
1040
1045
  this.token = e, this.partialNode = n, this.handlerContext = s;
1041
1046
  }
1042
1047
  }
1043
- class un {
1048
+ class ln {
1044
1049
  constructor(e, n) {
1045
- this.current = 0, this.errors = [], this.contextStack = new cn(), this.synchronizeProgram = () => {
1050
+ this.current = 0, this.errors = [], this.contextStack = new an(), this.synchronizeProgram = () => {
1046
1051
  const s = this.peek();
1047
- s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1052
+ s.kind !== c.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1048
1053
  }, this.synchronizeElementDeclarationName = () => {
1049
1054
  for (; !this.isAtEnd(); ) {
1050
1055
  const s = this.peek();
1051
- if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1056
+ if (ct(s) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
1052
1057
  break;
1053
1058
  E(s), this.advance();
1054
1059
  }
1055
1060
  }, this.synchronizeElementDeclarationAlias = () => {
1056
1061
  for (; !this.isAtEnd(); ) {
1057
1062
  const s = this.peek();
1058
- if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
1063
+ if (this.check(c.COLON, c.LBRACE, c.LBRACKET))
1059
1064
  break;
1060
1065
  E(s), this.advance();
1061
1066
  }
1062
1067
  }, this.blockExpression = this.contextStack.withContextDo(ye.BlockExpression, () => {
1063
- const s = { body: [] }, i = () => this.nodeFactory.create(ee, s);
1068
+ const s = { body: [] }, i = () => this.nodeFactory.create(te, s);
1064
1069
  try {
1065
- this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
1070
+ this.consume("Expect an opening brace '{'", c.LBRACE), s.blockOpenBrace = this.previous();
1066
1071
  } catch (r) {
1067
1072
  if (!(r instanceof d))
1068
1073
  throw r;
@@ -1070,7 +1075,7 @@ class un {
1070
1075
  throw new d(r.token, i(), r.handlerContext);
1071
1076
  this.synchronizeBlock();
1072
1077
  }
1073
- for (; !this.isAtEnd() && !this.check(u.RBRACE); )
1078
+ for (; !this.isAtEnd() && !this.check(c.RBRACE); )
1074
1079
  try {
1075
1080
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1076
1081
  } catch (r) {
@@ -1081,7 +1086,7 @@ class un {
1081
1086
  this.synchronizeBlock();
1082
1087
  }
1083
1088
  try {
1084
- this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
1089
+ this.consume("Expect a closing brace '}'", c.RBRACE), s.blockCloseBrace = this.previous();
1085
1090
  } catch (r) {
1086
1091
  if (!(r instanceof d))
1087
1092
  throw r;
@@ -1091,10 +1096,10 @@ class un {
1091
1096
  }
1092
1097
  return i();
1093
1098
  }), this.synchronizeBlock = () => {
1094
- if (!this.check(u.RBRACE))
1099
+ if (!this.check(c.RBRACE))
1095
1100
  for (E(this.advance()); !this.isAtEnd(); ) {
1096
1101
  const s = this.peek();
1097
- if (this.check(u.RBRACE) || ot(this.previous(), s))
1102
+ if (this.check(c.RBRACE) || ot(this.previous(), s))
1098
1103
  break;
1099
1104
  E(s), this.advance();
1100
1105
  }
@@ -1105,7 +1110,7 @@ class un {
1105
1110
  expression: s.elementList[0]
1106
1111
  }), r = () => this.nodeFactory.create(J, s);
1107
1112
  try {
1108
- this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
1113
+ this.consume("Expect an opening parenthesis '('", c.LPAREN), s.tupleOpenParen = this.previous();
1109
1114
  } catch (a) {
1110
1115
  if (!(a instanceof d))
1111
1116
  throw a;
@@ -1113,7 +1118,7 @@ class un {
1113
1118
  throw new d(a.token, r(), a.handlerContext);
1114
1119
  this.synchronizeTuple();
1115
1120
  }
1116
- if (!this.isAtEnd() && !this.check(u.RPAREN))
1121
+ if (!this.isAtEnd() && !this.check(c.RPAREN))
1117
1122
  try {
1118
1123
  s.elementList.push(this.normalExpression());
1119
1124
  } catch (a) {
@@ -1123,18 +1128,18 @@ class un {
1123
1128
  throw new d(a.token, i(), a.handlerContext);
1124
1129
  this.synchronizeTuple();
1125
1130
  }
1126
- for (; !this.isAtEnd() && !this.check(u.RPAREN); )
1131
+ for (; !this.isAtEnd() && !this.check(c.RPAREN); )
1127
1132
  try {
1128
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1133
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1129
1134
  } catch (a) {
1130
1135
  if (!(a instanceof d))
1131
1136
  throw a;
1132
- if (a.partialNode instanceof x && s.elementList.push(a.partialNode), !this.canHandle(a))
1137
+ if (a.partialNode instanceof y && s.elementList.push(a.partialNode), !this.canHandle(a))
1133
1138
  throw new d(a.token, r(), a.handlerContext);
1134
1139
  this.synchronizeTuple();
1135
1140
  }
1136
1141
  try {
1137
- this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
1142
+ this.consume("Expect a closing parenthesis ')'", c.RPAREN), s.tupleCloseParen = this.previous();
1138
1143
  } catch (a) {
1139
1144
  if (!(a instanceof d))
1140
1145
  throw a;
@@ -1146,14 +1151,14 @@ class un {
1146
1151
  }), this.synchronizeTuple = () => {
1147
1152
  for (; !this.isAtEnd(); ) {
1148
1153
  const s = this.peek();
1149
- if (this.check(u.RPAREN, u.COMMA))
1154
+ if (this.check(c.RPAREN, c.COMMA))
1150
1155
  break;
1151
1156
  E(s), this.advance();
1152
1157
  }
1153
1158
  }, this.listExpression = this.contextStack.withContextDo(ye.ListExpression, () => {
1154
1159
  const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(U, s);
1155
1160
  try {
1156
- this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1161
+ this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
1157
1162
  } catch (r) {
1158
1163
  if (!(r instanceof d))
1159
1164
  throw r;
@@ -1161,7 +1166,7 @@ class un {
1161
1166
  throw new d(r.token, i(), r.handlerContext);
1162
1167
  this.synchronizeList();
1163
1168
  }
1164
- if (!this.isAtEnd() && !this.check(u.RBRACKET))
1169
+ if (!this.isAtEnd() && !this.check(c.RBRACKET))
1165
1170
  try {
1166
1171
  s.elementList.push(this.attribute());
1167
1172
  } catch (r) {
@@ -1171,18 +1176,18 @@ class un {
1171
1176
  throw new d(r.token, i(), r.handlerContext);
1172
1177
  this.synchronizeList();
1173
1178
  }
1174
- for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
1179
+ for (; !this.isAtEnd() && !this.check(c.RBRACKET); )
1175
1180
  try {
1176
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1181
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1177
1182
  } catch (r) {
1178
1183
  if (!(r instanceof d))
1179
1184
  throw r;
1180
- if (r.partialNode instanceof x && s.elementList.push(r.partialNode), !this.canHandle(r))
1185
+ if (r.partialNode instanceof y && s.elementList.push(r.partialNode), !this.canHandle(r))
1181
1186
  throw new d(r.token, i(), r.handlerContext);
1182
1187
  this.synchronizeList();
1183
1188
  }
1184
1189
  try {
1185
- this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
1190
+ this.consume("Expect a closing bracket ']'", c.RBRACKET), s.listCloseBracket = this.previous();
1186
1191
  } catch (r) {
1187
1192
  if (!(r instanceof d))
1188
1193
  throw r;
@@ -1194,28 +1199,28 @@ class un {
1194
1199
  }), this.synchronizeList = () => {
1195
1200
  for (; !this.isAtEnd(); ) {
1196
1201
  const s = this.peek();
1197
- if (this.check(u.COMMA, u.RBRACKET))
1202
+ if (this.check(c.COMMA, c.RBRACKET))
1198
1203
  break;
1199
1204
  E(s), this.advance();
1200
1205
  }
1201
1206
  }, this.synchronizeAttributeName = () => {
1202
1207
  for (; !this.isAtEnd(); ) {
1203
1208
  const s = this.peek();
1204
- if (this.check(u.COMMA, u.RBRACKET, u.COLON))
1209
+ if (this.check(c.COMMA, c.RBRACKET, c.COLON))
1205
1210
  break;
1206
1211
  E(s), this.advance();
1207
1212
  }
1208
1213
  }, this.synchronizeAttributeValue = () => {
1209
1214
  for (; !this.isAtEnd(); ) {
1210
1215
  const s = this.peek();
1211
- if (this.check(u.COMMA, u.RBRACKET))
1216
+ if (this.check(c.COMMA, c.RBRACKET))
1212
1217
  break;
1213
1218
  E(s), this.advance();
1214
1219
  }
1215
- }, this.tokens = e, this.nodeFactory = new ln(n);
1220
+ }, this.tokens = e, this.nodeFactory = new on(n);
1216
1221
  }
1217
1222
  isAtEnd() {
1218
- return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
1223
+ return this.current >= this.tokens.length || this.tokens[this.current].kind === c.EOF;
1219
1224
  }
1220
1225
  advance() {
1221
1226
  return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
@@ -1268,8 +1273,8 @@ class un {
1268
1273
  this.tokens = e;
1269
1274
  }
1270
1275
  parse() {
1271
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
1272
- return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1276
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(C, { body: e, eof: n });
1277
+ return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
1273
1278
  }
1274
1279
  /* Parsing and synchronizing ProgramNode */
1275
1280
  program() {
@@ -1289,11 +1294,11 @@ class un {
1289
1294
  elementDeclaration() {
1290
1295
  const e = {}, n = () => this.nodeFactory.create(_, e);
1291
1296
  try {
1292
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1297
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1293
1298
  } catch (s) {
1294
1299
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1295
1300
  }
1296
- if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
1301
+ if (!this.check(c.COLON, c.LBRACE, c.LBRACKET))
1297
1302
  try {
1298
1303
  e.name = this.normalExpression();
1299
1304
  } catch (s) {
@@ -1303,8 +1308,8 @@ class un {
1303
1308
  throw new d(s.token, n(), s.handlerContext);
1304
1309
  this.synchronizeElementDeclarationName();
1305
1310
  }
1306
- if (lt(this.peek()))
1307
- if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1311
+ if (ct(this.peek()))
1312
+ if (e.as = this.advance(), this.check(c.COLON, c.LBRACE, c.LBRACKET))
1308
1313
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1309
1314
  else
1310
1315
  try {
@@ -1317,18 +1322,18 @@ class un {
1317
1322
  this.synchronizeElementDeclarationAlias();
1318
1323
  }
1319
1324
  try {
1320
- e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
1325
+ e.attributeList = this.check(c.LBRACKET) ? this.listExpression() : void 0;
1321
1326
  } catch (s) {
1322
1327
  throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1323
1328
  }
1324
1329
  if (!this.discardUntil(
1325
1330
  "Expect an opening brace '{' or a colon ':'",
1326
- u.LBRACE,
1327
- u.COLON
1331
+ c.LBRACE,
1332
+ c.COLON
1328
1333
  ))
1329
1334
  return n();
1330
1335
  try {
1331
- if (this.match(u.COLON)) {
1336
+ if (this.match(c.COLON)) {
1332
1337
  e.bodyColon = this.previous();
1333
1338
  const s = this.expression();
1334
1339
  s instanceof _ ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
@@ -1348,18 +1353,18 @@ class un {
1348
1353
  fieldDeclaration() {
1349
1354
  const e = {}, n = () => this.nodeFactory.create(_, e);
1350
1355
  try {
1351
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1356
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1352
1357
  } catch (s) {
1353
1358
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1354
1359
  }
1355
1360
  try {
1356
- this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
1361
+ this.consume("Expect a colon ':'", c.COLON), e.bodyColon = this.previous();
1357
1362
  } catch (s) {
1358
1363
  throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1359
1364
  }
1360
1365
  try {
1361
1366
  const s = this.expression();
1362
- s instanceof _ ? this.errors.push(new l(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1367
+ s instanceof _ ? this.errors.push(new u(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1363
1368
  } catch (s) {
1364
1369
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1365
1370
  }
@@ -1367,8 +1372,8 @@ class un {
1367
1372
  }
1368
1373
  /* Parsing any ExpressionNode, including non-NormalExpression */
1369
1374
  expression() {
1370
- const e = { args: [] }, n = () => nn(e.callee, e.args, this.nodeFactory).unwrap_or(
1371
- this.nodeFactory.create(v, e)
1375
+ const e = { args: [] }, n = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
1376
+ this.nodeFactory.create(k, e)
1372
1377
  );
1373
1378
  try {
1374
1379
  e.callee = this.normalExpression();
@@ -1392,7 +1397,7 @@ class un {
1392
1397
  if (this.isAtEnd() || bt(this.previous()))
1393
1398
  return !0;
1394
1399
  const e = this.peek().kind;
1395
- return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
1400
+ return e === c.RBRACE || e === c.RBRACKET || e === c.RPAREN || e === c.COMMA || e === c.COLON;
1396
1401
  }
1397
1402
  normalExpression() {
1398
1403
  return this.expression_bp(0);
@@ -1402,7 +1407,7 @@ class un {
1402
1407
  let n = this.leftExpression_bp();
1403
1408
  for (; !this.isAtEnd(); ) {
1404
1409
  const s = this.peek();
1405
- if (s.kind === u.LPAREN) {
1410
+ if (s.kind === c.LPAREN) {
1406
1411
  const { left: i } = ut(s);
1407
1412
  if (i < e || // When '(' is encountered,
1408
1413
  // consider it part of another expression if
@@ -1421,16 +1426,16 @@ class un {
1421
1426
  argumentList: r.partialNode
1422
1427
  }), new d(r.token, n, r.handlerContext)) : r;
1423
1428
  }
1424
- } else if (s.kind === u.LBRACKET) {
1429
+ } else if (s.kind === c.LBRACKET) {
1425
1430
  if (Ve(this.previous()))
1426
1431
  break;
1427
1432
  try {
1428
- n = this.nodeFactory.create(he, {
1433
+ n = this.nodeFactory.create(fe, {
1429
1434
  expression: n,
1430
1435
  indexer: this.listExpression()
1431
1436
  });
1432
1437
  } catch (i) {
1433
- throw i instanceof d ? (n = this.nodeFactory.create(he, {
1438
+ throw i instanceof d ? (n = this.nodeFactory.create(fe, {
1434
1439
  expression: n,
1435
1440
  indexer: i.partialNode
1436
1441
  }), new d(i.token, n, i.handlerContext)) : i;
@@ -1445,7 +1450,7 @@ class un {
1445
1450
  op: i
1446
1451
  });
1447
1452
  } else {
1448
- const a = fn(i);
1453
+ const a = un(i);
1449
1454
  if (a.left === null || a.left <= e)
1450
1455
  break;
1451
1456
  this.advance();
@@ -1455,12 +1460,12 @@ class un {
1455
1460
  op: i,
1456
1461
  rightExpression: i.value === "." ? this.extractOperand() : this.expression_bp(a.right)
1457
1462
  });
1458
- } catch (c) {
1459
- throw c instanceof d ? (n = this.nodeFactory.create(q, {
1463
+ } catch (l) {
1464
+ throw l instanceof d ? (n = this.nodeFactory.create(q, {
1460
1465
  leftExpression: n,
1461
1466
  op: i,
1462
- rightExpression: c.partialNode
1463
- }), new d(c.token, n, c.handlerContext)) : c;
1467
+ rightExpression: l.partialNode
1468
+ }), new d(l.token, n, l.handlerContext)) : l;
1464
1469
  }
1465
1470
  }
1466
1471
  } else
@@ -1473,7 +1478,7 @@ class un {
1473
1478
  if (at(this.peek())) {
1474
1479
  const n = {};
1475
1480
  n.op = this.peek();
1476
- const s = dn(n.op);
1481
+ const s = fn(n.op);
1477
1482
  if (s.right === null)
1478
1483
  throw this.logError(
1479
1484
  n.op,
@@ -1509,12 +1514,12 @@ class un {
1509
1514
  // e.g { ... }
1510
1515
  extractOperand() {
1511
1516
  return this.check(
1512
- u.NUMERIC_LITERAL,
1513
- u.STRING_LITERAL,
1514
- u.COLOR_LITERAL,
1515
- u.QUOTED_STRING,
1516
- u.IDENTIFIER
1517
- ) ? this.primaryExpression() : this.check(u.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(u.LBRACKET) ? this.listExpression() : this.check(u.LBRACE) ? this.blockExpression() : this.check(u.LPAREN) ? this.tupleExpression() : (this.peek().kind === u.EOF ? this.logError(
1517
+ c.NUMERIC_LITERAL,
1518
+ c.STRING_LITERAL,
1519
+ c.COLOR_LITERAL,
1520
+ c.QUOTED_STRING,
1521
+ c.IDENTIFIER
1522
+ ) ? this.primaryExpression() : this.check(c.FUNCTION_EXPRESSION) ? this.functionExpression() : this.check(c.LBRACKET) ? this.listExpression() : this.check(c.LBRACE) ? this.blockExpression() : this.check(c.LPAREN) ? this.tupleExpression() : (this.peek().kind === c.EOF ? this.logError(
1518
1523
  this.peek(),
1519
1524
  o.UNEXPECTED_EOF,
1520
1525
  "Unexpected EOF"
@@ -1528,50 +1533,50 @@ class un {
1528
1533
  functionExpression() {
1529
1534
  const e = {};
1530
1535
  try {
1531
- this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
1536
+ this.consume("Expect a function expression", c.FUNCTION_EXPRESSION), e.value = this.previous();
1532
1537
  } catch (n) {
1533
1538
  throw n instanceof d ? (e.value = n.partialNode, new d(
1534
1539
  n.token,
1535
- this.nodeFactory.create(K, e),
1540
+ this.nodeFactory.create(ee, e),
1536
1541
  n.handlerContext
1537
1542
  )) : n;
1538
1543
  }
1539
- return this.nodeFactory.create(K, e);
1544
+ return this.nodeFactory.create(ee, e);
1540
1545
  }
1541
1546
  canBeField() {
1542
- return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
1547
+ return this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.COLON;
1543
1548
  }
1544
1549
  /* Parsing PrimaryExpression */
1545
1550
  primaryExpression() {
1546
1551
  if (this.match(
1547
- u.COLOR_LITERAL,
1548
- u.STRING_LITERAL,
1549
- u.NUMERIC_LITERAL
1552
+ c.COLOR_LITERAL,
1553
+ c.STRING_LITERAL,
1554
+ c.NUMERIC_LITERAL
1550
1555
  ))
1551
1556
  return this.nodeFactory.create(R, {
1552
- expression: this.nodeFactory.create(pe, { literal: this.previous() })
1557
+ expression: this.nodeFactory.create(de, { literal: this.previous() })
1553
1558
  });
1554
- if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1559
+ if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
1555
1560
  return this.nodeFactory.create(R, {
1556
- expression: this.nodeFactory.create(W, { variable: this.previous() })
1561
+ expression: this.nodeFactory.create(X, { variable: this.previous() })
1557
1562
  });
1558
1563
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1559
1564
  this.peek(),
1560
1565
  this.nodeFactory.create(R, {
1561
- expression: this.nodeFactory.create(W, {})
1566
+ expression: this.nodeFactory.create(X, {})
1562
1567
  }),
1563
1568
  this.contextStack.findHandlerContext(this.tokens, this.current)
1564
1569
  );
1565
1570
  }
1566
1571
  attribute() {
1567
1572
  const e = {};
1568
- if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
1573
+ if (this.check(c.COLON, c.RBRACKET, c.COMMA)) {
1569
1574
  const n = this.peek();
1570
1575
  this.logError(
1571
1576
  n,
1572
1577
  o.EMPTY_ATTRIBUTE_NAME,
1573
1578
  "Expect a non-empty attribute name"
1574
- ), e.name = this.nodeFactory.create(te, { identifiers: [] });
1579
+ ), e.name = this.nodeFactory.create(K, { identifiers: [] });
1575
1580
  } else
1576
1581
  try {
1577
1582
  e.name = this.attributeName();
@@ -1586,12 +1591,12 @@ class un {
1586
1591
  );
1587
1592
  this.synchronizeAttributeName();
1588
1593
  }
1589
- return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
1594
+ return this.match(c.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(ne, e);
1590
1595
  }
1591
1596
  attributeValue() {
1592
1597
  let e;
1593
1598
  try {
1594
- e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
1599
+ e = this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.IDENTIFIER ? this.attributeName() : this.normalExpression();
1595
1600
  } catch (n) {
1596
1601
  if (!(n instanceof d) || !this.canHandle(n))
1597
1602
  throw n;
@@ -1601,25 +1606,25 @@ class un {
1601
1606
  }
1602
1607
  attributeName() {
1603
1608
  const e = [];
1604
- if (this.peek().kind !== u.IDENTIFIER)
1609
+ if (this.peek().kind !== c.IDENTIFIER)
1605
1610
  return this.primaryExpression();
1606
- for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
1611
+ for (; !this.isAtEnd() && !this.check(c.COLON, c.COMMA, c.RBRACKET); )
1607
1612
  try {
1608
- this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
1613
+ this.consume("Expect an identifier", c.IDENTIFIER), e.push(this.previous());
1609
1614
  } catch (n) {
1610
1615
  throw n instanceof d ? new d(
1611
1616
  n.token,
1612
- this.nodeFactory.create(te, { identifiers: e }),
1617
+ this.nodeFactory.create(K, { identifiers: e }),
1613
1618
  n.handlerContext
1614
1619
  ) : n;
1615
1620
  }
1616
- return this.nodeFactory.create(te, { identifiers: e });
1621
+ return this.nodeFactory.create(K, { identifiers: e });
1617
1622
  }
1618
1623
  logError(e, n, s) {
1619
- this.errors.push(new l(n, s, e));
1624
+ this.errors.push(new u(n, s, e));
1620
1625
  }
1621
1626
  }
1622
- const hn = {
1627
+ const cn = {
1623
1628
  "+": { left: 9, right: 10 },
1624
1629
  "*": { left: 11, right: 12 },
1625
1630
  "-": { left: 9, right: 10 },
@@ -1635,10 +1640,10 @@ const hn = {
1635
1640
  "!=": { left: 4, right: 5 },
1636
1641
  ".": { left: 16, right: 17 }
1637
1642
  };
1638
- function fn(t) {
1639
- return hn[t.value] || { left: null, right: null };
1643
+ function un(t) {
1644
+ return cn[t.value] || { left: null, right: null };
1640
1645
  }
1641
- const pn = {
1646
+ const hn = {
1642
1647
  "+": { left: null, right: 15 },
1643
1648
  "-": { left: null, right: 15 },
1644
1649
  "<": { left: null, right: 15 },
@@ -1646,17 +1651,17 @@ const pn = {
1646
1651
  "<>": { left: null, right: 15 },
1647
1652
  "!": { left: null, right: 15 }
1648
1653
  };
1649
- function dn(t) {
1650
- return pn[t.value] || { left: null, right: null };
1654
+ function fn(t) {
1655
+ return hn[t.value] || { left: null, right: null };
1651
1656
  }
1652
- const En = {
1657
+ const pn = {
1653
1658
  "(": { left: 14, right: null }
1654
1659
  };
1655
1660
  function ut(t) {
1656
- return En[t.value] || { left: null, right: null };
1661
+ return pn[t.value] || { left: null, right: null };
1657
1662
  }
1658
1663
  var b = /* @__PURE__ */ ((t) => (t.Table = "table", t.Enum = "enum", t.Ref = "ref", t.Note = "note", t.Project = "project", t.Indexes = "indexes", t.TableGroup = "tablegroup", t))(b || {});
1659
- function de(t) {
1664
+ function Ee(t) {
1660
1665
  var n;
1661
1666
  const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1662
1667
  switch (e) {
@@ -1672,46 +1677,46 @@ function de(t) {
1672
1677
  return new A();
1673
1678
  }
1674
1679
  }
1675
- function Ee(t) {
1680
+ function Ne(t) {
1676
1681
  if (!He(t))
1677
1682
  return new S([t]);
1678
- const e = Ee(t.leftExpression).unwrap_or(void 0);
1683
+ const e = Ne(t.leftExpression).unwrap_or(void 0);
1679
1684
  return e ? (e.push(t.rightExpression), new S(e)) : new A();
1680
1685
  }
1681
- function C(t) {
1686
+ function W(t) {
1682
1687
  if (t === void 0)
1683
1688
  return new A();
1684
- const e = Ee(t).unwrap_or(void 0);
1689
+ const e = Ne(t).unwrap_or(void 0);
1685
1690
  if (!e)
1686
1691
  return new A();
1687
1692
  const n = [];
1688
1693
  for (const s of e) {
1689
- const i = X(s).unwrap_or(void 0);
1694
+ const i = G(s).unwrap_or(void 0);
1690
1695
  if (!i)
1691
1696
  return new A();
1692
1697
  n.push(i);
1693
1698
  }
1694
1699
  return new S(n);
1695
1700
  }
1696
- function ge(t) {
1701
+ function Le(t) {
1697
1702
  if (t === void 0)
1698
1703
  return new A();
1699
- const e = Ee(t).unwrap_or(void 0);
1704
+ const e = Ne(t).unwrap_or(void 0);
1700
1705
  if (!e || e.length === 0)
1701
1706
  return new A();
1702
1707
  const n = [];
1703
1708
  let s;
1704
1709
  if (!M(I.last(e))) {
1705
1710
  const i = e.pop();
1706
- if (xt(i))
1711
+ if (kt(i))
1707
1712
  s = i.elementList.map(
1708
- (r) => G(r).unwrap()
1713
+ (r) => V(r).unwrap()
1709
1714
  );
1710
1715
  else
1711
1716
  return new A();
1712
1717
  }
1713
1718
  for (const i of e) {
1714
- const r = X(i).unwrap_or(void 0);
1719
+ const r = G(i).unwrap_or(void 0);
1715
1720
  if (!r)
1716
1721
  return new A();
1717
1722
  n.push(r);
@@ -1721,57 +1726,57 @@ function ge(t) {
1721
1726
  tupleElements: s
1722
1727
  });
1723
1728
  }
1724
- function X(t) {
1729
+ function G(t) {
1725
1730
  return M(t) ? new S(t.expression.variable.value) : new A();
1726
1731
  }
1727
1732
  function Ge(t) {
1728
1733
  if (ht(t))
1729
- return t instanceof K ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1734
+ return t instanceof ee ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1730
1735
  if (t instanceof J && t.elementList.every(ht)) {
1731
1736
  const e = t.elementList.filter(
1732
- (s) => s instanceof K
1737
+ (s) => s instanceof ee
1733
1738
  ), n = t.elementList.filter(M);
1734
1739
  return new S({ functional: e, nonFunctional: n });
1735
1740
  }
1736
1741
  return new A();
1737
1742
  }
1738
- function G(t) {
1743
+ function V(t) {
1739
1744
  var n;
1740
1745
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1741
1746
  return e === void 0 ? new A() : new S(e);
1742
1747
  }
1743
- function z(t) {
1744
- return j(t) ? t.expression instanceof W ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
1748
+ function Y(t) {
1749
+ return $(t) ? t.expression instanceof X ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new A();
1745
1750
  }
1746
- function Nn(t) {
1751
+ function dn(t) {
1747
1752
  var e;
1748
- return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
1753
+ return !(t instanceof q) || !yt((e = t.op) == null ? void 0 : e.value) ? !1 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
1749
1754
  }
1750
- function mn(t) {
1751
- const e = ge(t.leftExpression), n = ge(t.rightExpression);
1755
+ function En(t) {
1756
+ const e = Le(t.leftExpression), n = Le(t.rightExpression);
1752
1757
  if (!e.isOk() || !n.isOk())
1753
1758
  return !1;
1754
1759
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1755
1760
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1756
1761
  }
1757
1762
  function ht(t) {
1758
- return t instanceof R && t.expression instanceof W || t instanceof K;
1763
+ return t instanceof R && t.expression instanceof X || t instanceof ee;
1759
1764
  }
1760
- function Tn(t, e) {
1761
- var i, r, a, c;
1765
+ function Nn(t, e) {
1766
+ var i, r, a, l;
1762
1767
  let n = e;
1763
- const s = zt(t);
1768
+ const s = jt(t);
1764
1769
  for (; n; ) {
1765
1770
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1766
1771
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1767
- if (((c = n.symbol) == null ? void 0 : c.declaration) instanceof F && s)
1772
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof C && s)
1768
1773
  return n.symbol;
1769
- if (n instanceof F)
1774
+ if (n instanceof C)
1770
1775
  return;
1771
1776
  n = n.parent;
1772
1777
  }
1773
1778
  }
1774
- class bn {
1779
+ class mn {
1775
1780
  constructor(e, n, s) {
1776
1781
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1777
1782
  }
@@ -1779,27 +1784,27 @@ class bn {
1779
1784
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1780
1785
  }
1781
1786
  validateContext() {
1782
- return this.declarationNode.parent instanceof F || de(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)] : [];
1787
+ return this.declarationNode.parent instanceof C || Ee(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new u(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1783
1788
  }
1784
1789
  validateName(e) {
1785
- return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1790
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1786
1791
  }
1787
1792
  validateAlias(e) {
1788
- return e ? [new l(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1793
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1789
1794
  }
1790
1795
  validateSettingList(e) {
1791
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1796
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1792
1797
  }
1793
1798
  validateBody(e) {
1794
1799
  if (!e)
1795
1800
  return [];
1796
- if (e instanceof ee)
1797
- return [new l(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1801
+ if (e instanceof te)
1802
+ return [new u(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1798
1803
  const n = [];
1799
- return j(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;
1804
+ return $(e.callee) || n.push(new u(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 u(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1800
1805
  }
1801
1806
  }
1802
- class Ae {
1807
+ class _e {
1803
1808
  constructor() {
1804
1809
  this.table = /* @__PURE__ */ new Map();
1805
1810
  }
@@ -1816,7 +1821,7 @@ class Ae {
1816
1821
  return this.table.entries();
1817
1822
  }
1818
1823
  }
1819
- class In {
1824
+ class Tn {
1820
1825
  constructor(e, n, s) {
1821
1826
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1822
1827
  }
@@ -1824,53 +1829,53 @@ class In {
1824
1829
  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)];
1825
1830
  }
1826
1831
  validateContext() {
1827
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1832
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1828
1833
  }
1829
1834
  validateName(e) {
1830
- return e ? Je(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)];
1835
+ return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new u(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1831
1836
  }
1832
1837
  validateAlias(e) {
1833
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1838
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1834
1839
  }
1835
1840
  registerElement() {
1836
1841
  const e = [];
1837
- this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new Ae() });
1838
- const { name: n } = this.declarationNode, s = C(n);
1842
+ this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new _e() });
1843
+ const { name: n } = this.declarationNode, s = W(n);
1839
1844
  if (s.isOk()) {
1840
- const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), c = je(r);
1841
- 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);
1845
+ const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
1846
+ a.has(l) && e.push(new u(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1842
1847
  }
1843
1848
  return e;
1844
1849
  }
1845
1850
  validateSettingList(e) {
1846
- return e ? [new l(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1851
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1847
1852
  }
1848
1853
  validateBody(e) {
1849
1854
  if (!e)
1850
1855
  return [];
1851
- if (e instanceof v)
1856
+ if (e instanceof k)
1852
1857
  return this.validateFields([e]);
1853
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
1858
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1854
1859
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1855
1860
  }
1856
1861
  validateFields(e) {
1857
- return e.length === 0 ? [new l(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1862
+ return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1858
1863
  const s = [];
1859
- return 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)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new l(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
1864
+ return n.callee && !M(n.callee) && s.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), I.last(n.args) instanceof U && s.push(...this.validateFieldSetting(I.last(n.args))), n.args.length > 1 && s.push(...n.args.map((i) => new u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", i))), s.push(...this.registerField(n)), s;
1860
1865
  });
1861
1866
  }
1862
1867
  validateFieldSetting(e) {
1863
- const n = $(e), s = n.getErrors(), i = n.getValue();
1868
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1864
1869
  for (const r in i) {
1865
1870
  const a = i[r];
1866
1871
  switch (r) {
1867
1872
  case "note":
1868
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
1869
- j(c.value) || s.push(new l(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", c));
1873
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1874
+ $(l.value) || s.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1870
1875
  });
1871
1876
  break;
1872
1877
  default:
1873
- a.forEach((c) => s.push(new l(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, c)));
1878
+ a.forEach((l) => s.push(new u(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1874
1879
  }
1875
1880
  }
1876
1881
  return s;
@@ -1885,14 +1890,14 @@ class In {
1885
1890
  }
1886
1891
  registerField(e) {
1887
1892
  if (e.callee && M(e.callee)) {
1888
- const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
1893
+ const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Ht, { declaration: e });
1889
1894
  e.symbol = i;
1890
1895
  const r = this.declarationNode.symbol.symbolTable;
1891
1896
  if (r.has(s)) {
1892
1897
  const a = r.get(s);
1893
1898
  return [
1894
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1895
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1899
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1900
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1896
1901
  ];
1897
1902
  }
1898
1903
  r.set(s, i);
@@ -1900,7 +1905,7 @@ class In {
1900
1905
  return [];
1901
1906
  }
1902
1907
  }
1903
- class Ln {
1908
+ class bn {
1904
1909
  constructor(e, n, s) {
1905
1910
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1906
1911
  }
@@ -1908,23 +1913,23 @@ class Ln {
1908
1913
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1909
1914
  }
1910
1915
  validateContext() {
1911
- return this.declarationNode.parent instanceof F || de(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)] : [];
1916
+ return this.declarationNode.parent instanceof C || Ee(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new u(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1912
1917
  }
1913
1918
  validateName(e) {
1914
- return e ? [new l(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1919
+ return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1915
1920
  }
1916
1921
  validateAlias(e) {
1917
- return e ? [new l(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1922
+ return e ? [new u(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1918
1923
  }
1919
1924
  validateSettingList(e) {
1920
- return e ? [new l(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1925
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1921
1926
  }
1922
1927
  validateBody(e) {
1923
1928
  if (!e)
1924
1929
  return [];
1925
- if (e instanceof v)
1926
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1927
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
1930
+ if (e instanceof k)
1931
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1932
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1928
1933
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1929
1934
  }
1930
1935
  validateFields(e) {
@@ -1934,35 +1939,35 @@ class Ln {
1934
1939
  const s = [], i = [n.callee, ...n.args];
1935
1940
  return I.last(i) instanceof U && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1936
1941
  for (; r instanceof H; )
1937
- r.argumentList && !Ge(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;
1938
- Ge(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));
1942
+ r.argumentList && !Ge(r.argumentList).isOk() && s.push(new u(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;
1943
+ Ge(r).isOk() || s.push(new u(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1939
1944
  }), s;
1940
1945
  });
1941
1946
  }
1942
1947
  validateFieldSetting(e) {
1943
- const n = $(e), s = n.getErrors(), i = n.getValue();
1948
+ const n = z(e), s = n.getErrors(), i = n.getValue();
1944
1949
  for (const r in i) {
1945
1950
  const a = i[r];
1946
1951
  switch (r) {
1947
1952
  case "note":
1948
1953
  case "name":
1949
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1950
- j(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, c));
1954
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1955
+ $(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1951
1956
  });
1952
1957
  break;
1953
1958
  case "unique":
1954
1959
  case "pk":
1955
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
1956
- oe(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, c));
1960
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1961
+ oe(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1957
1962
  });
1958
1963
  break;
1959
1964
  case "type":
1960
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", c))), a.forEach((c) => {
1961
- M(c.value) || s.push(new l(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, c));
1965
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1966
+ M(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1962
1967
  });
1963
1968
  break;
1964
1969
  default:
1965
- a.forEach((c) => s.push(new l(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, c)));
1970
+ a.forEach((l) => s.push(new u(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1966
1971
  }
1967
1972
  }
1968
1973
  return s;
@@ -1976,7 +1981,7 @@ class Ln {
1976
1981
  });
1977
1982
  }
1978
1983
  }
1979
- class gn {
1984
+ class In {
1980
1985
  constructor(e, n, s) {
1981
1986
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1982
1987
  }
@@ -1984,36 +1989,28 @@ class gn {
1984
1989
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1985
1990
  }
1986
1991
  validateContext() {
1987
- return !(this.declarationNode.parent instanceof F) && ![b.Table, b.Project].includes(de(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)] : [];
1992
+ return this.declarationNode.parent instanceof C || ![b.Table, b.Project].includes(Ee(this.declarationNode.parent).unwrap_or(void 0)) ? [new u(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project", this.declarationNode)] : [];
1988
1993
  }
1989
1994
  validateName(e) {
1990
- if (!(this.declarationNode.parent instanceof F))
1991
- return e ? [new l(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1992
- if (!e)
1993
- return [new l(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
1994
- const n = C(e);
1995
- if (!n.isOk())
1996
- return [];
1997
- const i = n.unwrap().join("."), r = Yt(i);
1998
- 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), []);
1995
+ return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
1999
1996
  }
2000
1997
  validateAlias(e) {
2001
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1998
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2002
1999
  }
2003
2000
  validateSettingList(e) {
2004
- return e && !(this.declarationNode.parent instanceof F) ? [new l(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2001
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2005
2002
  }
2006
2003
  validateBody(e) {
2007
2004
  if (!e)
2008
2005
  return [];
2009
- if (e instanceof v)
2006
+ if (e instanceof k)
2010
2007
  return this.validateFields([e]);
2011
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2008
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2012
2009
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2013
2010
  }
2014
2011
  validateFields(e) {
2015
2012
  const n = [];
2016
- 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))), j(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);
2013
+ return e.length === 0 ? [new u(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new u(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), $(e[0].callee) || n.push(new u(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 u(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2017
2014
  }
2018
2015
  validateSubElements(e) {
2019
2016
  return e.flatMap((n) => {
@@ -2024,7 +2021,7 @@ class gn {
2024
2021
  });
2025
2022
  }
2026
2023
  }
2027
- class _n {
2024
+ class Ln {
2028
2025
  constructor(e, n, s) {
2029
2026
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2030
2027
  }
@@ -2032,25 +2029,25 @@ class _n {
2032
2029
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2033
2030
  }
2034
2031
  validateContext() {
2035
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2032
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2036
2033
  }
2037
2034
  validateName(e) {
2038
- return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2035
+ return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2039
2036
  }
2040
2037
  validateAlias(e) {
2041
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2038
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2042
2039
  }
2043
2040
  validateSettingList(e) {
2044
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2041
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2045
2042
  }
2046
2043
  validateBody(e) {
2047
2044
  if (!e)
2048
2045
  return [];
2049
- if (e instanceof v)
2050
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2051
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2046
+ if (e instanceof k)
2047
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2048
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2052
2049
  return [
2053
- ...n.map((i) => new l(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2050
+ ...n.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2054
2051
  ...this.validateSubElements(s)
2055
2052
  ];
2056
2053
  }
@@ -2063,7 +2060,7 @@ class _n {
2063
2060
  });
2064
2061
  }
2065
2062
  }
2066
- class An {
2063
+ class gn {
2067
2064
  constructor(e, n, s) {
2068
2065
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2069
2066
  }
@@ -2071,46 +2068,46 @@ class An {
2071
2068
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2072
2069
  }
2073
2070
  validateContext() {
2074
- return this.declarationNode.parent instanceof F || de(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new l(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
2071
+ return this.declarationNode.parent instanceof C || Ee(this.declarationNode.parent).unwrap_or(void 0) === b.Table ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level or inside a table", this.declarationNode)];
2075
2072
  }
2076
2073
  validateName(e) {
2077
- return e ? Pe(e) ? [] : [new l(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2074
+ return e ? Pe(e) ? [] : [new u(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2078
2075
  }
2079
2076
  validateAlias(e) {
2080
- return e ? [new l(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2077
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2081
2078
  }
2082
2079
  validateSettingList(e) {
2083
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2080
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2084
2081
  }
2085
2082
  validateBody(e) {
2086
2083
  if (!e)
2087
2084
  return [];
2088
- if (e instanceof v)
2085
+ if (e instanceof k)
2089
2086
  return this.validateFields([e]);
2090
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2087
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2091
2088
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2092
2089
  }
2093
2090
  validateFields(e) {
2094
2091
  if (e.length === 0)
2095
- return [new l(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2092
+ return [new u(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2096
2093
  const n = [];
2097
- 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) => {
2098
- s.callee && !Nn(s.callee) && n.push(new l(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new l(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new l(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
2094
+ return e.length > 1 && n.push(...e.slice(1).map((s) => new u(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2095
+ s.callee && !dn(s.callee) && n.push(new u(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !En(s.callee) && n.push(new u(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee)), I.last(s.args) instanceof U && this.validateFieldSettings(I.last(s.args)), s.args.length > 1 && n.push(...s.args.map((i) => new u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", i)));
2099
2096
  }), n;
2100
2097
  }
2101
2098
  validateFieldSettings(e) {
2102
- const n = $(e), s = n.getErrors(), i = n.getValue();
2099
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2103
2100
  for (const r in i) {
2104
2101
  const a = i[r];
2105
2102
  switch (r) {
2106
2103
  case "delete":
2107
2104
  case "update":
2108
- a.length > 1 && a.forEach((c) => s.push(new l(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, c))), a.forEach((c) => {
2109
- vn(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));
2105
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2106
+ _n(l.value) || s.push(new u(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2110
2107
  });
2111
2108
  break;
2112
2109
  default:
2113
- a.forEach((c) => s.push(new l(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, c)));
2110
+ a.forEach((l) => s.push(new u(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2114
2111
  }
2115
2112
  }
2116
2113
  return s;
@@ -2124,11 +2121,11 @@ class An {
2124
2121
  });
2125
2122
  }
2126
2123
  }
2127
- function vn(t) {
2128
- if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof te))
2124
+ function _n(t) {
2125
+ if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof K))
2129
2126
  return !1;
2130
2127
  let e;
2131
- if (t instanceof te ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
2128
+ if (t instanceof K ? e = Re(t).unwrap_or("") : e = t.expression.variable.value, e)
2132
2129
  switch (e.toLowerCase()) {
2133
2130
  case "cascade":
2134
2131
  case "no action":
@@ -2141,7 +2138,7 @@ function vn(t) {
2141
2138
  }
2142
2139
  return !1;
2143
2140
  }
2144
- class wn {
2141
+ class An {
2145
2142
  constructor(e, n, s) {
2146
2143
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2147
2144
  }
@@ -2149,77 +2146,77 @@ class wn {
2149
2146
  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)];
2150
2147
  }
2151
2148
  validateContext() {
2152
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2149
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2153
2150
  }
2154
2151
  validateName(e) {
2155
- return e ? e instanceof he ? [new l(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(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)];
2152
+ return e ? e instanceof fe ? [new u(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new u(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new u(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2156
2153
  }
2157
2154
  validateAlias(e) {
2158
- return e ? Sn(e) ? [] : [new l(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2155
+ return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2159
2156
  }
2160
2157
  validateSettingList(e) {
2161
- const n = $(e), s = n.getErrors(), i = n.getValue();
2158
+ const n = z(e), s = n.getErrors(), i = n.getValue();
2162
2159
  for (const r in i) {
2163
2160
  const a = i[r];
2164
2161
  switch (r) {
2165
2162
  case "headercolor":
2166
- a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", c))), a.forEach((c) => {
2167
- On(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", c.value || c.name));
2163
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2164
+ xn(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2168
2165
  });
2169
2166
  break;
2170
2167
  case "note":
2171
- a.length > 1 && s.push(...a.map((c) => new l(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", c))), a.forEach((c) => {
2172
- j(c.value) || s.push(new l(o.INVALID_TABLE_SETTING, "'note' must be a string literal", c.value || c.name));
2168
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2169
+ $(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2173
2170
  });
2174
2171
  break;
2175
2172
  default:
2176
- s.push(...a.map((c) => new l(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, c)));
2173
+ s.push(...a.map((l) => new u(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2177
2174
  }
2178
2175
  }
2179
2176
  return s;
2180
2177
  }
2181
2178
  registerElement() {
2182
2179
  const e = [];
2183
- this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new Ae() });
2184
- const { name: n, alias: s } = this.declarationNode, i = C(n);
2180
+ this.declarationNode.symbol = this.symbolFactory.create(At, { declaration: this.declarationNode, symbolTable: new _e() });
2181
+ const { name: n, alias: s } = this.declarationNode, i = W(n);
2185
2182
  if (i.isOk()) {
2186
- const r = [...i.unwrap()], a = r.pop(), c = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
2187
- 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);
2183
+ const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = ke(a);
2184
+ l.has(p) && e.push(new u(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2188
2185
  }
2189
- if (s && Pe(s) && !xn(s.expression.variable.value, i.unwrap_or([]))) {
2190
- const r = G(s).unwrap(), a = xe(r);
2191
- this.publicSymbolTable.has(a) && e.push(new l(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2186
+ if (s && Pe(s) && !wn(s.expression.variable.value, i.unwrap_or([]))) {
2187
+ const r = V(s).unwrap(), a = ke(r);
2188
+ this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2192
2189
  }
2193
2190
  return e;
2194
2191
  }
2195
2192
  validateBody(e) {
2196
2193
  if (!e)
2197
2194
  return [];
2198
- if (e instanceof v)
2199
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2200
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2195
+ if (e instanceof k)
2196
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2197
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2201
2198
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2202
2199
  }
2203
2200
  validateFields(e) {
2204
- return e.length === 0 ? [new l(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2201
+ return e.length === 0 ? [new u(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2205
2202
  if (!n.callee)
2206
2203
  return [];
2207
2204
  const s = [];
2208
- 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] && !yn(n.args[0]) && s.push(new l(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2205
+ n.args.length === 0 && s.push(new u(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new u(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !vn(n.args[0]) && s.push(new u(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2209
2206
  const i = n.args.slice(1);
2210
2207
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2211
2208
  });
2212
2209
  }
2213
2210
  registerField(e) {
2214
2211
  if (e.callee && M(e.callee)) {
2215
- const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
2212
+ const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Jt, { declaration: e });
2216
2213
  e.symbol = i;
2217
2214
  const r = this.declarationNode.symbol.symbolTable;
2218
2215
  if (r.has(s)) {
2219
2216
  const a = r.get(s);
2220
2217
  return [
2221
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2222
- new l(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2218
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2219
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2223
2220
  ];
2224
2221
  }
2225
2222
  r.set(s, i);
@@ -2228,75 +2225,75 @@ class wn {
2228
2225
  }
2229
2226
  // This is needed to support legacy inline settings
2230
2227
  validateFieldSetting(e) {
2231
- if (!e.slice(0, -1).every(fe) || !e.slice(-1).every((p) => fe(p) || p instanceof U))
2232
- return [...e.map((p) => new l(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2228
+ if (!e.slice(0, -1).every(pe) || !e.slice(-1).every((p) => pe(p) || p instanceof U))
2229
+ return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2233
2230
  if (e.length === 0)
2234
2231
  return [];
2235
2232
  let n;
2236
2233
  I.last(e) instanceof U && (n = e.pop());
2237
- const s = $(n), i = s.getErrors(), r = s.getValue();
2234
+ const s = z(n), i = s.getErrors(), r = s.getValue();
2238
2235
  for (const p of e) {
2239
- const h = G(p).unwrap_or("").toLowerCase();
2236
+ const h = V(p).unwrap_or("").toLowerCase();
2240
2237
  if (h !== "pk" && h !== "unique") {
2241
- i.push(new l(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2238
+ i.push(new u(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2242
2239
  continue;
2243
2240
  }
2244
2241
  r[h] === void 0 ? r[h] = [p] : r[h].push(p);
2245
2242
  }
2246
- const a = r.pk || [], c = r["primary key"] || [];
2247
- 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)));
2243
+ const a = r.pk || [], l = r["primary key"] || [];
2244
+ a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new u(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2248
2245
  for (const p in r) {
2249
2246
  const h = r[p];
2250
2247
  switch (p) {
2251
2248
  case "note":
2252
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2253
- j(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2249
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2250
+ $(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2254
2251
  });
2255
2252
  break;
2256
2253
  case "ref":
2257
2254
  h.forEach((f) => {
2258
- Rn(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2255
+ On(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2259
2256
  });
2260
2257
  break;
2261
2258
  case "primary key":
2262
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2263
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2259
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2260
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2264
2261
  });
2265
2262
  break;
2266
2263
  case "pk":
2267
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2268
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2264
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2265
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2269
2266
  });
2270
2267
  break;
2271
2268
  case "not null":
2272
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2269
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2273
2270
  const T = r.null || [];
2274
- 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) => {
2275
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2271
+ h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new u(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2272
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2276
2273
  });
2277
2274
  break;
2278
2275
  case "null":
2279
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2280
- oe(f.value) || i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2276
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2277
+ oe(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2281
2278
  });
2282
2279
  break;
2283
2280
  case "unique":
2284
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2285
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2281
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2282
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2286
2283
  });
2287
2284
  break;
2288
2285
  case "increment":
2289
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2290
- f instanceof ne && !oe(f.value) && i.push(new l(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2286
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2287
+ f instanceof ne && !oe(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2291
2288
  });
2292
2289
  break;
2293
2290
  case "default":
2294
- h.length > 1 && i.push(...h.map((f) => new l(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2295
- 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));
2291
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2292
+ Sn(f.value) || i.push(new u(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2296
2293
  });
2297
2294
  break;
2298
2295
  default:
2299
- h.forEach((f) => i.push(new l(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2296
+ h.forEach((f) => i.push(new u(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2300
2297
  }
2301
2298
  }
2302
2299
  return i;
@@ -2311,29 +2308,29 @@ class wn {
2311
2308
  var r;
2312
2309
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2313
2310
  });
2314
- return s.length > 1 && (n.push(...s.map((i) => new l(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2311
+ return s.length > 1 && (n.push(...s.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2315
2312
  }
2316
2313
  }
2317
- function yn(t) {
2318
- if (!(t instanceof H || He(t) || t instanceof R || t instanceof he))
2314
+ function vn(t) {
2315
+ if (!(t instanceof H || He(t) || t instanceof R || t instanceof fe))
2319
2316
  return !1;
2320
2317
  if (t instanceof H) {
2321
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ce(n) || j(n) || fe(n)))
2318
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => le(n) || $(n) || pe(n)))
2322
2319
  return !1;
2323
2320
  t = t.callee;
2324
2321
  }
2325
- for (; t instanceof he; ) {
2326
- if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && ce(n.name)))
2322
+ for (; t instanceof fe; ) {
2323
+ if (t.array === void 0 || t.indexer === void 0 || !t.indexer.elementList.every((n) => !n.colon && !n.value && le(n.name)))
2327
2324
  return !1;
2328
2325
  t = t.array;
2329
2326
  }
2330
- const e = C(t).unwrap_or(void 0);
2327
+ const e = W(t).unwrap_or(void 0);
2331
2328
  return e !== void 0 && e.length > 0;
2332
2329
  }
2333
- function xn(t, e) {
2330
+ function wn(t, e) {
2334
2331
  return e.length === 1 && t === e[0];
2335
2332
  }
2336
- class kn {
2333
+ class yn {
2337
2334
  constructor(e, n, s) {
2338
2335
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2339
2336
  }
@@ -2341,41 +2338,41 @@ class kn {
2341
2338
  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)];
2342
2339
  }
2343
2340
  validateContext() {
2344
- return this.declarationNode.parent instanceof _ ? [new l(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2341
+ return this.declarationNode.parent instanceof _ ? [new u(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2345
2342
  }
2346
2343
  validateName(e) {
2347
- return e ? Je(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)];
2344
+ return e ? Je(e) ? [] : [new u(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new u(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2348
2345
  }
2349
2346
  validateAlias(e) {
2350
- return e ? [new l(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2347
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2351
2348
  }
2352
2349
  registerElement() {
2353
2350
  const { name: e } = this.declarationNode;
2354
- this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new Ae() });
2355
- const n = C(e);
2351
+ this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new _e() });
2352
+ const n = W(e);
2356
2353
  if (n.isOk()) {
2357
2354
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2358
2355
  if (r.has(a))
2359
- return [new l(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2356
+ return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2360
2357
  r.set(a, this.declarationNode.symbol);
2361
2358
  }
2362
2359
  return [];
2363
2360
  }
2364
2361
  validateSettingList(e) {
2365
- return e ? [new l(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2362
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2366
2363
  }
2367
2364
  validateBody(e) {
2368
2365
  if (!e)
2369
2366
  return [];
2370
- if (e instanceof v)
2371
- return [new l(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2372
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
2367
+ if (e instanceof k)
2368
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2369
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2373
2370
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2374
2371
  }
2375
2372
  validateFields(e) {
2376
2373
  return e.flatMap((n) => {
2377
2374
  const s = [];
2378
- 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;
2375
+ return n.callee && !W(n.callee).isOk() && s.push(new u(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 u(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2379
2376
  });
2380
2377
  }
2381
2378
  validateSubElements(e) {
@@ -2388,14 +2385,14 @@ class kn {
2388
2385
  }
2389
2386
  registerField(e) {
2390
2387
  if (e.callee && M(e.callee)) {
2391
- const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
2388
+ const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
2392
2389
  e.symbol = i;
2393
2390
  const r = this.declarationNode.symbol.symbolTable;
2394
2391
  if (r.has(s)) {
2395
2392
  const a = r.get(s);
2396
2393
  return [
2397
- new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2398
- new l(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2394
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2395
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2399
2396
  ];
2400
2397
  }
2401
2398
  r.set(s, i);
@@ -2407,31 +2404,31 @@ const wt = ["-", "+"];
2407
2404
  function ie(t) {
2408
2405
  switch (t.type.value.toLowerCase()) {
2409
2406
  case b.Enum:
2410
- return In;
2407
+ return Tn;
2411
2408
  case b.Table:
2412
- return wn;
2409
+ return An;
2413
2410
  case b.TableGroup:
2414
- return kn;
2411
+ return yn;
2415
2412
  case b.Project:
2416
- return _n;
2413
+ return Ln;
2417
2414
  case b.Ref:
2418
- return An;
2419
- case b.Note:
2420
2415
  return gn;
2416
+ case b.Note:
2417
+ return In;
2421
2418
  case b.Indexes:
2422
- return Ln;
2423
- default:
2424
2419
  return bn;
2420
+ default:
2421
+ return mn;
2425
2422
  }
2426
2423
  }
2427
2424
  function Je(t) {
2428
- return !!C(t).unwrap_or(!1);
2425
+ return !!W(t).unwrap_or(!1);
2429
2426
  }
2430
- function Sn(t) {
2427
+ function kn(t) {
2431
2428
  return Pe(t);
2432
2429
  }
2433
2430
  function Pe(t) {
2434
- return t instanceof R && t.expression instanceof W;
2431
+ return t instanceof R && t.expression instanceof X;
2435
2432
  }
2436
2433
  function Ze(t, e, n) {
2437
2434
  var i;
@@ -2439,14 +2436,14 @@ function Ze(t, e, n) {
2439
2436
  let s = e;
2440
2437
  for (const r of t) {
2441
2438
  let a;
2442
- const c = $e(r);
2443
- if (s.has(c)) {
2444
- if (a = (i = s.get(c)) == null ? void 0 : i.symbolTable, !a)
2439
+ const l = $e(r);
2440
+ if (s.has(l)) {
2441
+ if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2445
2442
  throw new Error("Expect a symbol table in a schema symbol");
2446
2443
  } else {
2447
- a = new Ae();
2444
+ a = new _e();
2448
2445
  const p = n.create(_t, { symbolTable: a });
2449
- s.set(c, p);
2446
+ s.set(l, p);
2450
2447
  }
2451
2448
  s = a;
2452
2449
  }
@@ -2455,60 +2452,60 @@ function Ze(t, e, n) {
2455
2452
  function yt(t) {
2456
2453
  return t === "-" || t === "<>" || t === ">" || t === "<";
2457
2454
  }
2458
- function On(t) {
2455
+ function xn(t) {
2459
2456
  var n;
2460
- if (!(t instanceof R) || !(t.expression instanceof pe) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2457
+ if (!(t instanceof R) || !(t.expression instanceof de) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
2461
2458
  return !1;
2462
2459
  const e = t.expression.literal.value;
2463
2460
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2464
2461
  return !1;
2465
2462
  for (let s = 1; s < e.length; s += 1)
2466
- if (!qt(e[s]))
2463
+ if (!zt(e[s]))
2467
2464
  return !1;
2468
2465
  return !0;
2469
2466
  }
2470
2467
  function oe(t) {
2471
2468
  return t === void 0;
2472
2469
  }
2473
- function Dn(t) {
2470
+ function Sn(t) {
2474
2471
  var e;
2475
- return !!(j(t) || ce(t) || fe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression) || t instanceof K);
2472
+ return !!($(t) || le(t) || pe(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression) || t instanceof ee);
2476
2473
  }
2477
- function ce(t) {
2474
+ function le(t) {
2478
2475
  var e;
2479
- return t instanceof R && t.expression instanceof pe && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2476
+ return t instanceof R && t.expression instanceof de && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2480
2477
  }
2481
- function Rn(t) {
2478
+ function On(t) {
2482
2479
  var n;
2483
2480
  if (!(t instanceof Q) || !yt((n = t.op) == null ? void 0 : n.value))
2484
2481
  return !1;
2485
- const e = C(t.expression).unwrap_or(void 0);
2482
+ const e = W(t.expression).unwrap_or(void 0);
2486
2483
  return e !== void 0 && e.length > 0;
2487
2484
  }
2488
- function xt(t) {
2485
+ function kt(t) {
2489
2486
  return t instanceof J && t.elementList.every(M);
2490
2487
  }
2491
- function $(t) {
2488
+ function z(t) {
2492
2489
  var s;
2493
2490
  const e = {}, n = [];
2494
2491
  if (!t)
2495
- return new B({});
2492
+ return new F({});
2496
2493
  for (const i of t.elementList) {
2497
2494
  if (!i.name)
2498
2495
  continue;
2499
2496
  if (i.name instanceof R) {
2500
- n.push(new l(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2497
+ n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2501
2498
  continue;
2502
2499
  }
2503
2500
  const r = (s = Re(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2504
2501
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2505
2502
  }
2506
- return new B(e, n);
2503
+ return new F(e, n);
2507
2504
  }
2508
2505
  class ft {
2509
2506
  constructor(e, n) {
2510
2507
  this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(_t, {
2511
- symbolTable: new Ae()
2508
+ symbolTable: new _e()
2512
2509
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2513
2510
  }
2514
2511
  validate() {
@@ -2523,8 +2520,8 @@ class ft {
2523
2520
  );
2524
2521
  e.push(...r.validate());
2525
2522
  });
2526
- const n = this.ast.body.filter((s) => de(s).unwrap_or(void 0) === b.Project);
2527
- 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);
2523
+ const n = this.ast.body.filter((s) => Ee(s).unwrap_or(void 0) === b.Project);
2524
+ return n.length > 1 && n.forEach((s) => e.push(new u(o.PROJECT_REDEFINED, "Only one project can exist", s))), new F(this.ast, e);
2528
2525
  }
2529
2526
  }
2530
2527
  class re {
@@ -2551,12 +2548,12 @@ class re {
2551
2548
  if (!e.body)
2552
2549
  return;
2553
2550
  const { body: n } = e;
2554
- if (n instanceof ee)
2551
+ if (n instanceof te)
2555
2552
  for (const s of n.body)
2556
2553
  if (s instanceof _) {
2557
2554
  if (!s.type)
2558
2555
  continue;
2559
- const i = kt(s);
2556
+ const i = xt(s);
2560
2557
  new i(s, this.errors).bind();
2561
2558
  } else
2562
2559
  this.bindSubfield(s);
@@ -2575,11 +2572,11 @@ class re {
2575
2572
  var s, i;
2576
2573
  if (e)
2577
2574
  if (e instanceof R) {
2578
- if (e.expression instanceof W && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2575
+ if (e.expression instanceof X && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2579
2576
  return;
2580
2577
  this.bindFragments([e], n);
2581
2578
  } else
2582
- e instanceof q ? He(e) ? this.bindFragments(Ee(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2579
+ e instanceof q ? He(e) ? this.bindFragments(Ne(e).unwrap_or([]), n) : (this.scanAndBind(e.leftExpression, n), this.scanAndBind(e.rightExpression, n)) : e instanceof Q ? this.scanAndBind(e.expression, n) : e instanceof De ? this.scanAndBind(e.expression, n) : e instanceof J && e.elementList.forEach((r) => this.scanAndBind(r, n));
2583
2580
  }
2584
2581
  // Bind the fragments of a member access expression
2585
2582
  // which can be a simple expression like v1.User,
@@ -2587,7 +2584,7 @@ class re {
2587
2584
  bindFragments(e, n) {
2588
2585
  if (e.length === 0)
2589
2586
  return;
2590
- const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), c = r !== -1 && xt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2587
+ const s = [...n.topSubnamesSymbolKind], { remainingSubnamesSymbolKind: i } = n, r = e.findIndex((f) => !M(f)), l = r !== -1 && kt(e[r]) ? e[r] : void 0, p = r >= 0 ? s.pop() : void 0, h = e.slice(
2591
2588
  0,
2592
2589
  r === -1 ? void 0 : r
2593
2590
  );
@@ -2595,26 +2592,26 @@ class re {
2595
2592
  return;
2596
2593
  const T = [];
2597
2594
  for (; s.length && h.length; ) {
2598
- const f = s.pop(), N = h.pop(), g = G(N).unwrap();
2595
+ const f = s.pop(), N = h.pop(), g = V(N).unwrap();
2599
2596
  T.unshift({
2600
2597
  index: Fe(g, f),
2601
2598
  referrer: N
2602
2599
  });
2603
2600
  }
2604
2601
  for (; h.length; ) {
2605
- const f = h.pop(), N = G(f).unwrap();
2602
+ const f = h.pop(), N = V(f).unwrap();
2606
2603
  T.unshift({
2607
2604
  index: Fe(N, i),
2608
2605
  referrer: f
2609
2606
  });
2610
2607
  }
2611
- return c ? c.elementList.forEach(
2608
+ return l ? l.elementList.forEach(
2612
2609
  (f) => this.resolveIndexStack(
2613
2610
  [
2614
2611
  ...T,
2615
2612
  {
2616
2613
  index: Fe(
2617
- G(f).unwrap(),
2614
+ V(f).unwrap(),
2618
2615
  p
2619
2616
  ),
2620
2617
  referrer: f
@@ -2629,34 +2626,34 @@ class re {
2629
2626
  resolveIndexStack(e, n) {
2630
2627
  if (e.length === 0)
2631
2628
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2632
- const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
2629
+ const [s, ...i] = e, r = Nn(s.index, this.declarationNode);
2633
2630
  if (r === void 0) {
2634
2631
  const { kind: h, name: T } = se(s.index).unwrap();
2635
2632
  this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
2636
2633
  return;
2637
2634
  }
2638
2635
  r.references.push(s.referrer), s.referrer.referee = r;
2639
- let a = r.symbolTable, { kind: c, name: p } = se(s.index).unwrap();
2636
+ let a = r.symbolTable, { kind: l, name: p } = se(s.index).unwrap();
2640
2637
  for (const h of i) {
2641
2638
  const { kind: T, name: f } = se(h.index).unwrap(), N = a.get(h.index);
2642
2639
  if (!N) {
2643
2640
  this.logError(
2644
2641
  h.referrer,
2645
- `${c} '${p}' does not have ${T} '${f}'`,
2642
+ `${l} '${p}' does not have ${T} '${f}'`,
2646
2643
  n
2647
2644
  );
2648
2645
  return;
2649
2646
  }
2650
- if (c = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2647
+ if (l = T, p = f, h.referrer.referee = N, N.references.push(h.referrer), !N.symbolTable)
2651
2648
  break;
2652
2649
  a = N.symbolTable;
2653
2650
  }
2654
2651
  }
2655
2652
  logError(e, n, s) {
2656
- s || this.errors.push(new l(o.BINDING_ERROR, n, e));
2653
+ s || this.errors.push(new u(o.BINDING_ERROR, n, e));
2657
2654
  }
2658
2655
  }
2659
- class Pn extends re {
2656
+ class Dn extends re {
2660
2657
  constructor() {
2661
2658
  super(...arguments), this.subfield = {
2662
2659
  arg: {
@@ -2666,7 +2663,7 @@ class Pn extends re {
2666
2663
  }, this.settingList = {};
2667
2664
  }
2668
2665
  }
2669
- class Un extends re {
2666
+ class Rn extends re {
2670
2667
  constructor() {
2671
2668
  super(...arguments), this.subfield = {
2672
2669
  arg: {
@@ -2676,7 +2673,7 @@ class Un extends re {
2676
2673
  }, this.settingList = {};
2677
2674
  }
2678
2675
  }
2679
- class Mn extends re {
2676
+ class Pn extends re {
2680
2677
  constructor() {
2681
2678
  super(...arguments), this.subfield = {
2682
2679
  arg: {
@@ -2711,7 +2708,7 @@ class Mn extends re {
2711
2708
  }, this.settingList = {};
2712
2709
  }
2713
2710
  }
2714
- class Fn extends re {
2711
+ class Un extends re {
2715
2712
  constructor() {
2716
2713
  super(...arguments), this.subfield = {
2717
2714
  arg: {
@@ -2721,7 +2718,7 @@ class Fn extends re {
2721
2718
  }, this.settingList = {};
2722
2719
  }
2723
2720
  }
2724
- class Bn extends re {
2721
+ class Mn extends re {
2725
2722
  constructor() {
2726
2723
  super(...arguments), this.subfield = {
2727
2724
  arg: {
@@ -2731,7 +2728,7 @@ class Bn extends re {
2731
2728
  }, this.settingList = {};
2732
2729
  }
2733
2730
  }
2734
- class Vn extends re {
2731
+ class Fn extends re {
2735
2732
  constructor() {
2736
2733
  super(...arguments), this.subfield = {
2737
2734
  arg: {
@@ -2748,7 +2745,7 @@ class Vn extends re {
2748
2745
  }, this.settingList = {};
2749
2746
  }
2750
2747
  }
2751
- class Gn extends re {
2748
+ class Bn extends re {
2752
2749
  constructor() {
2753
2750
  super(...arguments), this.subfield = {
2754
2751
  arg: {
@@ -2776,7 +2773,7 @@ class Gn extends re {
2776
2773
  }, this.settingList = {};
2777
2774
  }
2778
2775
  }
2779
- class Cn extends re {
2776
+ class Vn extends re {
2780
2777
  constructor() {
2781
2778
  super(...arguments), this.subfield = {
2782
2779
  arg: {
@@ -2793,40 +2790,40 @@ class Cn extends re {
2793
2790
  }, this.settingList = {};
2794
2791
  }
2795
2792
  }
2796
- function kt(t) {
2793
+ function xt(t) {
2797
2794
  switch (t.type.value.toLowerCase()) {
2798
2795
  case b.Enum:
2799
- return Un;
2796
+ return Rn;
2800
2797
  case b.Table:
2801
- return Gn;
2798
+ return Bn;
2802
2799
  case b.TableGroup:
2803
- return Cn;
2800
+ return Vn;
2804
2801
  case b.Project:
2805
- return Bn;
2802
+ return Mn;
2806
2803
  case b.Ref:
2807
- return Vn;
2808
- case b.Note:
2809
2804
  return Fn;
2805
+ case b.Note:
2806
+ return Un;
2810
2807
  case b.Indexes:
2811
- return Mn;
2812
- default:
2813
2808
  return Pn;
2809
+ default:
2810
+ return Dn;
2814
2811
  }
2815
2812
  }
2816
- class Xn {
2813
+ class Gn {
2817
2814
  constructor(e) {
2818
2815
  this.ast = e, this.errors = [];
2819
2816
  }
2820
2817
  resolve() {
2821
2818
  for (const e of this.ast.body)
2822
2819
  if (e.type) {
2823
- const n = kt(e);
2820
+ const n = xt(e);
2824
2821
  new n(e, this.errors).bind();
2825
2822
  }
2826
- return new B(this.ast, this.errors);
2823
+ return new F(this.ast, this.errors);
2827
2824
  }
2828
2825
  }
2829
- class $n {
2826
+ class Cn {
2830
2827
  constructor(e) {
2831
2828
  this.generator = e;
2832
2829
  }
@@ -2834,21 +2831,21 @@ class $n {
2834
2831
  return new e(n, this.generator.nextId());
2835
2832
  }
2836
2833
  }
2837
- class Wn {
2834
+ class Xn {
2838
2835
  constructor(e, n) {
2839
- this.ast = e, this.symbolFactory = new $n(n);
2836
+ this.ast = e, this.symbolFactory = new Cn(n);
2840
2837
  }
2841
2838
  // Analyzing: Invoking both the validator and binder
2842
2839
  analyze() {
2843
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
2840
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new Gn(n).resolve());
2844
2841
  }
2845
2842
  // For invoking the validator only
2846
2843
  validate() {
2847
- return new ft(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2844
+ return new ft(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
2848
2845
  }
2849
2846
  }
2850
2847
  function pt(t, e) {
2851
- const { variables: n, tupleElements: s } = ge(t).unwrap();
2848
+ const { variables: n, tupleElements: s } = Le(t).unwrap();
2852
2849
  return s ? n.length === 0 ? {
2853
2850
  schemaName: e.schemaName,
2854
2851
  tableName: e.name,
@@ -2880,7 +2877,7 @@ function St(t) {
2880
2877
  }
2881
2878
  throw new Error("Invalid relation op");
2882
2879
  }
2883
- function k(t) {
2880
+ function x(t) {
2884
2881
  return {
2885
2882
  start: {
2886
2883
  offset: t.startPos.offset,
@@ -2892,20 +2889,20 @@ function k(t) {
2892
2889
  }
2893
2890
  function Ce(t) {
2894
2891
  var n;
2895
- const e = (n = Ee(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2892
+ const e = (n = Ne(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2896
2893
  return e instanceof J ? e.elementList.map((s) => s.referee) : [e.referee];
2897
2894
  }
2898
- function Ne(t) {
2899
- const e = C(t).unwrap();
2895
+ function Ae(t) {
2896
+ const e = W(t).unwrap();
2900
2897
  return {
2901
2898
  name: e.pop(),
2902
2899
  schemaName: e
2903
2900
  };
2904
2901
  }
2905
- function Ot(t) {
2902
+ function $n(t) {
2906
2903
  return t.expression.literal.value;
2907
2904
  }
2908
- function Dt(t, e) {
2905
+ function Ot(t, e) {
2909
2906
  if (Array.isArray(t)) {
2910
2907
  const i = t.map(({ id: a }) => a).sort().join(","), r = e.map(({ id: a }) => a).sort().join(",");
2911
2908
  return i < r ? `${i}-${r}` : `${i}-${r}`;
@@ -2913,10 +2910,10 @@ function Dt(t, e) {
2913
2910
  const n = t.id, s = e.id;
2914
2911
  return n < s ? `${n}-${s}` : `${s}-${n}`;
2915
2912
  }
2916
- function Rt(t, e) {
2913
+ function Dt(t, e) {
2917
2914
  if (Array.isArray(t)) {
2918
2915
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2919
- return I.zip(i, r).every(([a, c]) => a === c);
2916
+ return I.zip(i, r).every(([a, l]) => a === l);
2920
2917
  }
2921
2918
  const n = t.id, s = e.id;
2922
2919
  return n === s;
@@ -2926,51 +2923,51 @@ class Ke {
2926
2923
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof _ ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
2927
2924
  }
2928
2925
  interpret() {
2929
- return this.ref.token = k(this.declarationNode), this.env.ref.set(this.declarationNode, this.ref), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
2926
+ 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)];
2930
2927
  }
2931
2928
  interpretName(e) {
2932
- const n = [], s = C(this.declarationNode.name).unwrap_or([]);
2933
- 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;
2929
+ const n = [], s = W(this.declarationNode.name).unwrap_or([]);
2930
+ return this.ref.name = s.pop() || null, s.length > 1 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
2934
2931
  }
2935
2932
  interpretBody(e) {
2936
- return e instanceof v ? this.interpretField(e) : this.interpretField(e.body[0]);
2933
+ return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
2937
2934
  }
2938
2935
  interpretField(e) {
2939
2936
  var h, T, f, N;
2940
2937
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
2941
- if (Rt(r, a))
2942
- return [new l(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2943
- const c = Dt(r, a);
2944
- if (this.env.refIds[c])
2938
+ if (Dt(r, a))
2939
+ return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
2940
+ const l = Ot(r, a);
2941
+ if (this.env.refIds[l])
2945
2942
  return [
2946
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
2947
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[c])
2943
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
2944
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
2948
2945
  ];
2949
2946
  if (e.args[0]) {
2950
- const g = $(e.args[0]).getValue();
2951
- this.ref.onDelete = X((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = X((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
2947
+ const g = z(e.args[0]).getValue();
2948
+ this.ref.onDelete = G((T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value).unwrap_or(void 0), this.ref.onDelete = G((N = (f = g.delete) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
2952
2949
  }
2953
2950
  const p = St(n);
2954
2951
  return this.ref.endpoints = [
2955
2952
  {
2956
2953
  ...pt(s, this.container),
2957
2954
  relation: p[0],
2958
- token: k(s)
2955
+ token: x(s)
2959
2956
  },
2960
2957
  {
2961
2958
  ...pt(i, this.container),
2962
2959
  relation: p[1],
2963
- token: k(i)
2960
+ token: x(i)
2964
2961
  }
2965
- ], this.env.refIds[c] = this.declarationNode, [];
2962
+ ], this.env.refIds[l] = this.declarationNode, [];
2966
2963
  }
2967
2964
  }
2968
- class Pt {
2965
+ class Rt {
2969
2966
  constructor(e, n) {
2970
2967
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2971
2968
  }
2972
2969
  interpret() {
2973
- this.table.token = k(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2970
+ this.table.token = x(this.declarationNode), this.env.tables.set(this.declarationNode, this.table);
2974
2971
  const e = [
2975
2972
  ...this.interpretName(this.declarationNode.name),
2976
2973
  ...this.interpretAlias(this.declarationNode.alias),
@@ -2989,13 +2986,13 @@ class Pt {
2989
2986
  }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2990
2987
  }
2991
2988
  interpretName(e) {
2992
- const { name: n, schemaName: s } = Ne(e);
2993
- 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, []);
2989
+ const { name: n, schemaName: s } = Ae(e);
2990
+ return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2994
2991
  }
2995
2992
  interpretAlias(e) {
2996
2993
  if (!e)
2997
2994
  return [];
2998
- const n = G(e).unwrap_or(null);
2995
+ const n = V(e).unwrap_or(null);
2999
2996
  return n && (this.env.aliases.push({
3000
2997
  name: n,
3001
2998
  kind: "table",
@@ -3006,17 +3003,17 @@ class Pt {
3006
3003
  }), this.table.alias = n), [];
3007
3004
  }
3008
3005
  interpretSettingList(e) {
3009
- var r, a, c;
3010
- const n = $(e).getValue();
3011
- this.table.headerColor = (r = n.headercolor) != null && r.length ? Ot((c = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : c.value) : void 0;
3012
- const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
3006
+ var r, a, l;
3007
+ const n = z(e).getValue();
3008
+ this.table.headerColor = (r = n.headercolor) != null && r.length ? $n((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
3009
+ const [s] = n.note || [], i = Y(s == null ? void 0 : s.value).unwrap_or(void 0);
3013
3010
  return this.table.note = s && {
3014
3011
  value: i,
3015
- token: k(s)
3012
+ token: x(s)
3016
3013
  }, [];
3017
3014
  }
3018
3015
  interpretBody(e) {
3019
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
3016
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
3020
3017
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
3021
3018
  }
3022
3019
  interpretSubElements(e) {
@@ -3025,8 +3022,8 @@ class Pt {
3025
3022
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
3026
3023
  case "note":
3027
3024
  return this.table.note = {
3028
- value: z(n.body instanceof ee ? n.body.body[0].callee : n.body.callee).unwrap(),
3029
- token: k(n)
3025
+ value: Y(n.body instanceof te ? n.body.body[0].callee : n.body.callee).unwrap(),
3026
+ token: x(n)
3030
3027
  }, [];
3031
3028
  case "indexes":
3032
3029
  return this.interpretIndexes(n);
@@ -3040,102 +3037,102 @@ class Pt {
3040
3037
  return e.flatMap((n) => this.interpretColumn(n));
3041
3038
  }
3042
3039
  interpretColumn(e) {
3043
- var a, c, p, h, T, f, N, g;
3040
+ var a, l, p, h, T, f, N, g;
3044
3041
  const n = [], s = {};
3045
- s.name = G(e.callee).unwrap();
3046
- const i = jn(e.args[0]);
3047
- s.type = i.getValue(), n.push(...i.getErrors()), s.token = k(e), s.inline_refs = [];
3042
+ s.name = V(e.callee).unwrap();
3043
+ const i = Wn(e.args[0]);
3044
+ s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
3048
3045
  const r = e.args.slice(1);
3049
3046
  if (I.last(r) instanceof U) {
3050
- const w = $(r.pop()).getValue();
3051
- s.pk = !!((a = w.pk) != null && a.length) || !!((c = w["primary key"]) != null && c.length), s.increment = !!((p = w.increment) != null && p.length), s.unique = !!((h = w.unique) != null && h.length), s.not_null = !!((T = w["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = w.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3052
- const me = (g = w.note) == null ? void 0 : g.at(0);
3047
+ const v = z(r.pop()).getValue();
3048
+ s.pk = !!((a = v.pk) != null && a.length) || !!((l = v["primary key"]) != null && l.length), s.increment = !!((p = v.increment) != null && p.length), s.unique = !!((h = v.unique) != null && h.length), s.not_null = !!((T = v["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = v.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3049
+ const me = (g = v.note) == null ? void 0 : g.at(0);
3053
3050
  s.note = me && {
3054
- value: z(me.value).unwrap(),
3055
- token: k(me)
3051
+ value: Y(me.value).unwrap(),
3052
+ token: x(me)
3056
3053
  };
3057
- const Te = w.ref || [];
3058
- s.inline_refs = Te.flatMap((Y) => {
3059
- const [nt] = Ce(Y.value.expression);
3060
- if (Rt(nt, e.symbol))
3061
- return n.push(new l(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
3062
- const ve = Y.value.op, Z = C(Y.value.expression).unwrap();
3063
- let le;
3054
+ const Te = v.ref || [];
3055
+ s.inline_refs = Te.flatMap((j) => {
3056
+ const [nt] = Ce(j.value.expression);
3057
+ if (Dt(nt, e.symbol))
3058
+ return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", j)), [];
3059
+ const ve = j.value.op, Z = W(j.value.expression).unwrap();
3060
+ let ce;
3064
3061
  if (Z.length === 1) {
3065
3062
  const [ae] = Z;
3066
- le = {
3063
+ ce = {
3067
3064
  schemaName: this.table.schemaName,
3068
3065
  tableName: this.table.name,
3069
3066
  fieldNames: [ae],
3070
3067
  relation: ve.value,
3071
- token: k(Y)
3068
+ token: x(j)
3072
3069
  };
3073
3070
  } else if (Z.length === 2) {
3074
3071
  const [ae, be] = Z;
3075
- le = {
3072
+ ce = {
3076
3073
  schemaName: null,
3077
3074
  tableName: ae,
3078
3075
  fieldNames: [be],
3079
3076
  relation: ve.value,
3080
- token: k(Y)
3077
+ token: x(j)
3081
3078
  };
3082
3079
  } else if (Z.length === 3) {
3083
3080
  const [ae, be, it] = Z;
3084
- le = {
3081
+ ce = {
3085
3082
  schemaName: ae,
3086
3083
  tableName: be,
3087
3084
  fieldNames: [it],
3088
3085
  relation: ve.value,
3089
- token: k(Y)
3086
+ token: x(j)
3090
3087
  };
3091
3088
  } else {
3092
- n.push(new l(o.UNSUPPORTED, "Nested schema is not supported", Y));
3089
+ n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", j));
3093
3090
  const ae = Z.pop(), be = Z.pop();
3094
- le = {
3091
+ ce = {
3095
3092
  schemaName: Z.join("."),
3096
3093
  tableName: be,
3097
3094
  fieldNames: [ae],
3098
3095
  relation: ve.value,
3099
- token: k(Y)
3096
+ token: x(j)
3100
3097
  };
3101
3098
  }
3102
- const st = this.registerInlineRefToEnv(e, nt, le, Y);
3103
- return n.push(...st), st.length === 0 ? le : [];
3099
+ const st = this.registerInlineRefToEnv(e, nt, ce, j);
3100
+ return n.push(...st), st.length === 0 ? ce : [];
3104
3101
  });
3105
3102
  }
3106
- return s.pk || (s.pk = r.some((w) => X(w).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((w) => X(w).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3103
+ return s.pk || (s.pk = r.some((v) => G(v).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((v) => G(v).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3107
3104
  }
3108
3105
  interpretIndexes(e) {
3109
3106
  return this.table.indexes.push(...e.body.body.map((n) => {
3110
- var a, c, p, h, T, f, N;
3107
+ var a, l, p, h, T, f, N;
3111
3108
  const s = { columns: [] }, i = n;
3112
- s.token = k(e);
3109
+ s.token = x(e);
3113
3110
  const r = [i.callee, ...i.args];
3114
3111
  if (I.last(r) instanceof U) {
3115
- const g = $(r.pop()).getValue();
3116
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((c = g.unique) != null && c.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3117
- const w = (T = g.note) == null ? void 0 : T.at(0);
3118
- s.note = w && {
3119
- value: z(w.value).unwrap(),
3120
- token: k(w)
3121
- }, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3112
+ const g = z(r.pop()).getValue();
3113
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Y((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3114
+ const v = (T = g.note) == null ? void 0 : T.at(0);
3115
+ s.note = v && {
3116
+ value: Y(v.value).unwrap(),
3117
+ token: x(v)
3118
+ }, s.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3122
3119
  }
3123
3120
  return r.flatMap((g) => {
3124
3121
  if (!(g instanceof H))
3125
3122
  return g;
3126
- const w = [];
3123
+ const v = [];
3127
3124
  for (; g instanceof H; )
3128
- w.push(g.argumentList), g = g.callee;
3129
- return w.push(g), w;
3125
+ v.push(g.argumentList), g = g.callee;
3126
+ return v.push(g), v;
3130
3127
  }).forEach((g) => {
3131
- const { functional: w, nonFunctional: me } = Ge(g).unwrap();
3128
+ const { functional: v, nonFunctional: me } = Ge(g).unwrap();
3132
3129
  s.columns.push(
3133
- ...w.map((Te) => ({
3130
+ ...v.map((Te) => ({
3134
3131
  value: Te.value.value,
3135
3132
  type: "expression"
3136
3133
  })),
3137
3134
  ...me.map((Te) => ({
3138
- value: G(Te).unwrap(),
3135
+ value: V(Te).unwrap(),
3139
3136
  type: "column"
3140
3137
  }))
3141
3138
  );
@@ -3143,11 +3140,11 @@ class Pt {
3143
3140
  })), [];
3144
3141
  }
3145
3142
  registerInlineRefToEnv(e, n, s, i) {
3146
- const r = Dt(e.symbol, n);
3143
+ const r = Ot(e.symbol, n);
3147
3144
  if (this.env.refIds[r])
3148
3145
  return [
3149
- new l(o.CIRCULAR_REF, "References with same endpoints exist", i),
3150
- new l(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3146
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
3147
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3151
3148
  ];
3152
3149
  const a = St(s.relation);
3153
3150
  return this.env.refIds[r] = i, this.env.ref.set(i, {
@@ -3162,60 +3159,60 @@ class Pt {
3162
3159
  {
3163
3160
  schemaName: this.table.schemaName,
3164
3161
  tableName: this.table.name,
3165
- fieldNames: [X(e.callee).unwrap()],
3166
- token: k(e),
3162
+ fieldNames: [G(e.callee).unwrap()],
3163
+ token: x(e),
3167
3164
  relation: a[0]
3168
3165
  }
3169
3166
  ]
3170
3167
  }), [];
3171
3168
  }
3172
3169
  }
3173
- function jn(t) {
3170
+ function Wn(t) {
3174
3171
  let e = null;
3175
- t instanceof H && (e = t.argumentList.elementList.map((r) => ce(r) ? r.expression.literal.value : j(r) ? z(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3172
+ t instanceof H && (e = t.argumentList.elementList.map((r) => le(r) ? r.expression.literal.value : $(r) ? Y(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
3176
3173
  let n = "";
3177
- for (; t instanceof he; )
3174
+ for (; t instanceof fe; )
3178
3175
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3179
- const { name: s, schemaName: i } = Ne(t);
3180
- return i.length > 1 && new B(
3176
+ const { name: s, schemaName: i } = Ae(t);
3177
+ return i.length > 1 ? new F(
3181
3178
  {
3182
3179
  schemaName: i.length === 0 ? null : i[0],
3183
3180
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3184
3181
  args: e
3185
3182
  },
3186
- [new l(o.UNSUPPORTED, "Nested schema is not supported", t)]
3187
- ), new B({
3183
+ [new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
3184
+ ) : new F({
3188
3185
  schemaName: i.length === 0 ? null : i[0],
3189
3186
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3190
3187
  args: e
3191
3188
  });
3192
3189
  }
3193
- function Yn(t) {
3190
+ function jn(t) {
3194
3191
  var e, n, s;
3195
3192
  if (t) {
3196
- if (j(t))
3193
+ if ($(t))
3197
3194
  return {
3198
- value: z(t).unwrap(),
3195
+ value: Y(t).unwrap(),
3199
3196
  type: "string"
3200
3197
  };
3201
- if (ce(t))
3198
+ if (le(t))
3202
3199
  return {
3203
3200
  type: "number",
3204
3201
  value: Number.parseFloat(t.expression.literal.value)
3205
3202
  };
3206
- if (fe(t))
3203
+ if (pe(t))
3207
3204
  return {
3208
3205
  value: t.expression.variable.value.toLowerCase(),
3209
3206
  type: "boolean"
3210
3207
  };
3211
- if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && ce(t.expression)) {
3208
+ if (t instanceof Q && wt.includes((e = t.op) == null ? void 0 : e.value) && le(t.expression)) {
3212
3209
  const i = Number.parseFloat(t.expression.expression.literal.value);
3213
3210
  return {
3214
3211
  value: ((n = t.op) == null ? void 0 : n.value) === "-" ? 0 - i : i,
3215
3212
  type: "number"
3216
3213
  };
3217
3214
  }
3218
- if (t instanceof K)
3215
+ if (t instanceof ee)
3219
3216
  return {
3220
3217
  value: (s = t.value) == null ? void 0 : s.value,
3221
3218
  type: "expression"
@@ -3223,79 +3220,48 @@ function Yn(t) {
3223
3220
  throw new Error("Unreachable");
3224
3221
  }
3225
3222
  }
3226
- class zn {
3227
- constructor(e, n) {
3228
- this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3229
- }
3230
- interpret() {
3231
- return this.note.token = k(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3232
- ...this.interpretName(this.declarationNode.name),
3233
- ...this.interpretSettingList(this.declarationNode.attributeList),
3234
- ...this.interpretBody(this.declarationNode.body)
3235
- ];
3236
- }
3237
- interpretName(e) {
3238
- const { name: n } = Ne(e);
3239
- return this.note.name = n, [];
3240
- }
3241
- interpretSettingList(e) {
3242
- var s, i, r;
3243
- const n = $(e).getValue();
3244
- 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, [];
3245
- }
3246
- interpretBody(e) {
3247
- const [n, s] = I.partition(e.body, (i) => i instanceof v);
3248
- return n.length !== 1 || s.length > 0 ? [
3249
- new l(o.INVALID_NOTE, "Invalid note syntax", e)
3250
- ] : [...this.interpretNote(n[0])];
3251
- }
3252
- interpretNote(e) {
3253
- const n = I.get(e, "callee.expression.literal.value", "");
3254
- return this.note.content = n, [];
3255
- }
3256
- }
3257
- class Ut {
3223
+ class Pt {
3258
3224
  constructor(e, n) {
3259
3225
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3260
3226
  }
3261
3227
  interpret() {
3262
3228
  const e = [];
3263
- this.tableGroup.token = k(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
3264
- const { name: n, schemaName: s } = Ne(this.declarationNode.name);
3265
- return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
3266
- const r = C(i.callee).unwrap();
3267
- return r.length > 2 && e.push(new l(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3229
+ this.tableGroup.token = x(this.declarationNode), this.env.tableGroups.set(this.declarationNode, this.tableGroup);
3230
+ const { name: n, schemaName: s } = Ae(this.declarationNode.name);
3231
+ return s.length >= 2 && (this.tableGroup.name = n, this.tableGroup.schemaName = s.join("."), e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = n, this.tableGroup.schemaName = s[0] || null, this.tableGroup.tables = this.declarationNode.body.body.map((i) => {
3232
+ const r = W(i.callee).unwrap();
3233
+ return r.length > 2 && e.push(new u(o.UNSUPPORTED, "Nested schema is not supported", i)), {
3268
3234
  name: r.pop(),
3269
3235
  schemaName: r.join(".")
3270
3236
  };
3271
3237
  }), e;
3272
3238
  }
3273
3239
  }
3274
- class Mt {
3240
+ class Ut {
3275
3241
  constructor(e, n) {
3276
3242
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3277
3243
  }
3278
3244
  interpret() {
3279
- return this.enum.token = k(this.declarationNode), this.env.enums.set(this.declarationNode, this.enum), [...this.interpretName(this.declarationNode.name), ...this.interpretBody(this.declarationNode.body)];
3245
+ 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)];
3280
3246
  }
3281
3247
  interpretName(e) {
3282
- const { name: n, schemaName: s } = Ne(e);
3283
- 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, []);
3248
+ const { name: n, schemaName: s } = Ae(e);
3249
+ return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new u(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3284
3250
  }
3285
3251
  interpretBody(e) {
3286
3252
  return e.body.flatMap((n) => {
3287
- var c;
3253
+ var l;
3288
3254
  const s = n, i = {};
3289
- i.token = k(s), i.name = X(s.callee).unwrap();
3290
- const a = (c = $(s.args[0]).getValue().note) == null ? void 0 : c.at(0);
3255
+ i.token = x(s), i.name = G(s.callee).unwrap();
3256
+ const a = (l = z(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3291
3257
  return i.note = a && {
3292
- value: z(a.value).unwrap(),
3293
- token: k(a)
3258
+ value: Y(a.value).unwrap(),
3259
+ token: x(a)
3294
3260
  }, this.enum.values.push(i), [];
3295
3261
  });
3296
3262
  }
3297
3263
  }
3298
- class Qn {
3264
+ class Yn {
3299
3265
  constructor(e, n) {
3300
3266
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3301
3267
  }
@@ -3305,7 +3271,7 @@ class Qn {
3305
3271
  interpretName(e) {
3306
3272
  if (!e)
3307
3273
  return this.project.name = null, [];
3308
- const { name: n } = Ne(e);
3274
+ const { name: n } = Ae(e);
3309
3275
  return this.project.name = n, [];
3310
3276
  }
3311
3277
  interpretBody(e) {
@@ -3314,7 +3280,7 @@ class Qn {
3314
3280
  const s = n;
3315
3281
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3316
3282
  case "table": {
3317
- const r = new Pt(s, this.env).interpret();
3283
+ const r = new Rt(s, this.env).interpret();
3318
3284
  return this.project.tables.push(this.env.tables.get(s)), r;
3319
3285
  }
3320
3286
  case "ref": {
@@ -3322,30 +3288,29 @@ class Qn {
3322
3288
  return this.project.refs.push(this.env.ref.get(s)), r;
3323
3289
  }
3324
3290
  case "tablegroup": {
3325
- const r = new Ut(s, this.env).interpret();
3291
+ const r = new Pt(s, this.env).interpret();
3326
3292
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3327
3293
  }
3328
3294
  case "enum": {
3329
- const r = new Mt(s, this.env).interpret();
3295
+ const r = new Ut(s, this.env).interpret();
3330
3296
  return this.project.enums.push(this.env.enums.get(s)), r;
3331
3297
  }
3332
3298
  case "note":
3333
3299
  return this.project.note = {
3334
- value: z(s.body instanceof ee ? s.body.body[0].callee : s.body.callee).unwrap(),
3335
- token: k(s)
3300
+ value: Y(s.body instanceof te ? s.body.body[0].callee : s.body.callee).unwrap(),
3301
+ token: x(s)
3336
3302
  }, [];
3337
3303
  default:
3338
- return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
3304
+ return this.project[s.type.value.toLowerCase()] = Y(s.body.callee).unwrap(), [];
3339
3305
  }
3340
3306
  });
3341
3307
  }
3342
3308
  }
3343
- class qn {
3309
+ class zn {
3344
3310
  constructor(e) {
3345
3311
  this.ast = e, this.env = {
3346
3312
  schema: [],
3347
3313
  tables: /* @__PURE__ */ new Map(),
3348
- notes: /* @__PURE__ */ new Map(),
3349
3314
  refIds: {},
3350
3315
  ref: /* @__PURE__ */ new Map(),
3351
3316
  enums: /* @__PURE__ */ new Map(),
@@ -3356,31 +3321,28 @@ class qn {
3356
3321
  }
3357
3322
  interpret() {
3358
3323
  const e = this.ast.body.flatMap((n) => {
3359
- switch (de(n).unwrap_or(void 0)) {
3324
+ switch (Ee(n).unwrap_or(void 0)) {
3360
3325
  case b.Table:
3361
- return new Pt(n, this.env).interpret();
3362
- case b.Note:
3363
- return new zn(n, this.env).interpret();
3326
+ return new Rt(n, this.env).interpret();
3364
3327
  case b.Ref:
3365
3328
  return new Ke(n, this.env).interpret();
3366
3329
  case b.TableGroup:
3367
- return new Ut(n, this.env).interpret();
3330
+ return new Pt(n, this.env).interpret();
3368
3331
  case b.Enum:
3369
- return new Mt(n, this.env).interpret();
3332
+ return new Ut(n, this.env).interpret();
3370
3333
  case b.Project:
3371
- return new Qn(n, this.env).interpret();
3334
+ return new Yn(n, this.env).interpret();
3372
3335
  default:
3373
3336
  return [];
3374
3337
  }
3375
3338
  });
3376
- return new B(Hn(this.env), e);
3339
+ return new F(Qn(this.env), e);
3377
3340
  }
3378
3341
  }
3379
- function Hn(t) {
3342
+ function Qn(t) {
3380
3343
  return {
3381
3344
  schemas: [],
3382
3345
  tables: Array.from(t.tables.values()),
3383
- notes: Array.from(t.notes.values()),
3384
3346
  refs: Array.from(t.ref.values()),
3385
3347
  enums: Array.from(t.enums.values()),
3386
3348
  tableGroups: Array.from(t.tableGroups.values()),
@@ -3388,8 +3350,8 @@ function Hn(t) {
3388
3350
  project: Array.from(t.project.values())[0] || {}
3389
3351
  };
3390
3352
  }
3391
- 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 || {});
3392
- function _e(t) {
3353
+ var L = /* @__PURE__ */ ((t) => (t[t.Function = 1] = "Function", t[t.Constructor = 2] = "Constructor", t[t.Field = 3] = "Field", t[t.Variable = 4] = "Variable", t[t.Class = 5] = "Class", t[t.Struct = 6] = "Struct", t[t.Interface = 7] = "Interface", t[t.Module = 8] = "Module", t[t.Property = 9] = "Property", t[t.Event = 10] = "Event", t[t.Operator = 11] = "Operator", t[t.Unit = 12] = "Unit", t[t.Value = 13] = "Value", t[t.Constant = 14] = "Constant", t[t.Enum = 15] = "Enum", t[t.EnumMember = 16] = "EnumMember", t[t.Keyword = 17] = "Keyword", t[t.Text = 18] = "Text", t[t.Color = 19] = "Color", t[t.File = 20] = "File", t[t.Reference = 21] = "Reference", t[t.Customcolor = 22] = "Customcolor", t[t.Folder = 23] = "Folder", t[t.TypeParameter = 24] = "TypeParameter", t[t.User = 25] = "User", t[t.Issue = 26] = "Issue", t[t.Snippet = 27] = "Snippet", t))(L || {}), w = /* @__PURE__ */ ((t) => (t[t.None = 0] = "None", t[t.KeepWhitespace = 1] = "KeepWhitespace", t[t.InsertAsSnippet = 4] = "InsertAsSnippet", t))(w || {});
3354
+ function ge(t) {
3393
3355
  switch (t) {
3394
3356
  case m.Schema:
3395
3357
  return L.Module;
@@ -3415,7 +3377,7 @@ function Se(t, e) {
3415
3377
  for (const n of t.trailingTrivia) {
3416
3378
  if (n.start > e)
3417
3379
  break;
3418
- if (n.kind === u.NEWLINE && n.end <= e)
3380
+ if (n.kind === c.NEWLINE && n.end <= e)
3419
3381
  return !1;
3420
3382
  }
3421
3383
  return !0;
@@ -3446,22 +3408,22 @@ function Ue(t) {
3446
3408
  function et(t, e) {
3447
3409
  return t.getOffsetAt(e);
3448
3410
  }
3449
- class Ft {
3411
+ class Mt {
3450
3412
  constructor(e, n = []) {
3451
3413
  this.compiler = e, this.triggerCharacters = n;
3452
3414
  }
3453
3415
  provideCompletionItems(e, n) {
3454
3416
  var T, f;
3455
- 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];
3417
+ 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];
3456
3418
  if ([
3457
3419
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3458
3420
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3459
- ...(c == null ? void 0 : c.leadingTrivia) || []
3460
- ].find((N) => Wt(N) && Le(s, N)))
3421
+ ...(l == null ? void 0 : l.leadingTrivia) || []
3422
+ ].find((N) => $t(N) && Ie(s, N)))
3461
3423
  return O();
3462
3424
  if (a === void 0)
3463
3425
  return Tt();
3464
- if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
3426
+ if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(s, r))
3465
3427
  return O();
3466
3428
  const p = this.compiler.container.element(s);
3467
3429
  if (this.compiler.container.scopeKind(s) === D.TOPLEVEL || p instanceof _ && p.type && p.type.start <= s && p.type.end >= s)
@@ -3492,7 +3454,7 @@ class Ft {
3492
3454
  N
3493
3455
  );
3494
3456
  case ".":
3495
- return Bt(
3457
+ return Ft(
3496
3458
  this.compiler,
3497
3459
  s,
3498
3460
  N
@@ -3504,10 +3466,10 @@ class Ft {
3504
3466
  if (N instanceof U)
3505
3467
  return Et(this.compiler, s, N);
3506
3468
  if (N instanceof J)
3507
- return Jn(this.compiler, s);
3508
- if (N instanceof v)
3469
+ return qn(this.compiler, s);
3470
+ if (N instanceof k)
3509
3471
  return mt(this.compiler, s, N);
3510
- if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
3472
+ if (N instanceof _ && (N.bodyColon && s >= N.bodyColon.end || N.body && Ie(s, N.body)))
3511
3473
  return mt(this.compiler, s, void 0);
3512
3474
  }
3513
3475
  return O();
@@ -3533,14 +3495,14 @@ function Me(t, e, n, s) {
3533
3495
  const r = { suggestions: [] };
3534
3496
  for (; i; ) {
3535
3497
  if ((a = i == null ? void 0 : i.symbol) != null && a.symbolTable) {
3536
- const { symbol: c } = i;
3498
+ const { symbol: l } = i;
3537
3499
  r.suggestions.push(
3538
- ...t.symbol.members(c).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3500
+ ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3539
3501
  label: p,
3540
3502
  insertText: p,
3541
- insertTextRules: y.KeepWhitespace,
3542
- kind: _e(h),
3543
- sortText: _e(h).toString().padStart(2, "0"),
3503
+ insertTextRules: w.KeepWhitespace,
3504
+ kind: ge(h),
3505
+ sortText: ge(h).toString().padStart(2, "0"),
3544
3506
  range: void 0
3545
3507
  }))
3546
3508
  );
@@ -3549,51 +3511,51 @@ function Me(t, e, n, s) {
3549
3511
  }
3550
3512
  return Ue(r);
3551
3513
  }
3552
- function Jn(t, e) {
3514
+ function qn(t, e) {
3553
3515
  var s;
3554
3516
  switch (t.container.scopeKind(e)) {
3555
3517
  case D.INDEXES:
3556
- return Gt(t, e);
3518
+ return Vt(t, e);
3557
3519
  case D.REF:
3558
3520
  {
3559
3521
  const i = [...t.container.stack(e)];
3560
3522
  for (; i.length > 0; ) {
3561
3523
  const r = i.pop();
3562
3524
  if (r instanceof q && ((s = r.op) == null ? void 0 : s.value) === ".")
3563
- return Bt(
3525
+ return Ft(
3564
3526
  t,
3565
3527
  e,
3566
3528
  r
3567
3529
  );
3568
3530
  }
3569
3531
  }
3570
- return Vt(t, e);
3532
+ return Bt(t, e);
3571
3533
  }
3572
3534
  return O();
3573
3535
  }
3574
3536
  function Et(t, e, n) {
3575
3537
  const { token: s } = t.container.token(e);
3576
- if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3538
+ if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3577
3539
  const i = Nt(t, e);
3578
- return (s == null ? void 0 : s.kind) === u.COMMA && Se(s, e) ? Oe(i) : i;
3540
+ return (s == null ? void 0 : s.kind) === c.COMMA && Se(s, e) ? Oe(i) : i;
3579
3541
  }
3580
3542
  if (n.name && n.name.start <= e && n.name.end >= e)
3581
3543
  return Nt(t, e);
3582
- if (n.name) {
3583
- const i = Zn(
3544
+ if (n.name instanceof K) {
3545
+ const i = Hn(
3584
3546
  t,
3585
3547
  e,
3586
3548
  Re(n.name).unwrap()
3587
3549
  );
3588
- return (s == null ? void 0 : s.kind) === u.COLON && Se(s, e) ? Oe(i) : i;
3550
+ return (s == null ? void 0 : s.kind) === c.COLON && Se(s, e) ? Oe(i) : i;
3589
3551
  }
3590
3552
  return O();
3591
3553
  }
3592
3554
  function Nt(t, e) {
3593
3555
  const n = t.container.element(e), s = t.container.scopeKind(e);
3594
- if (n instanceof F)
3556
+ if (n instanceof C)
3595
3557
  return O();
3596
- if (n.body && !Le(e, n.body))
3558
+ if (n.body && !Ie(e, n.body))
3597
3559
  switch (s) {
3598
3560
  case D.TABLE:
3599
3561
  return {
@@ -3602,14 +3564,14 @@ function Nt(t, e) {
3602
3564
  label: "headercolor",
3603
3565
  insertText: "headercolor: ",
3604
3566
  kind: L.Field,
3605
- insertTextRules: y.KeepWhitespace,
3567
+ insertTextRules: w.KeepWhitespace,
3606
3568
  range: void 0
3607
3569
  },
3608
3570
  {
3609
3571
  label: "note",
3610
3572
  insertText: "note: ",
3611
3573
  kind: L.Field,
3612
- insertTextRules: y.KeepWhitespace,
3574
+ insertTextRules: w.KeepWhitespace,
3613
3575
  range: void 0
3614
3576
  }
3615
3577
  ]
@@ -3625,21 +3587,21 @@ function Nt(t, e) {
3625
3587
  label: i,
3626
3588
  insertText: i,
3627
3589
  kind: L.Property,
3628
- insertTextRules: y.KeepWhitespace,
3590
+ insertTextRules: w.KeepWhitespace,
3629
3591
  range: void 0
3630
3592
  })),
3631
3593
  ...["ref", "default"].map((i) => ({
3632
3594
  label: i,
3633
3595
  insertText: `${i}: `,
3634
3596
  kind: L.Property,
3635
- insertTextRules: y.KeepWhitespace,
3597
+ insertTextRules: w.KeepWhitespace,
3636
3598
  range: void 0
3637
3599
  })),
3638
3600
  {
3639
3601
  label: "note",
3640
3602
  insertText: "note: ",
3641
3603
  kind: L.Property,
3642
- insertTextRules: y.KeepWhitespace,
3604
+ insertTextRules: w.KeepWhitespace,
3643
3605
  range: void 0
3644
3606
  }
3645
3607
  ]
@@ -3651,7 +3613,7 @@ function Nt(t, e) {
3651
3613
  label: "note",
3652
3614
  insertText: "note: ",
3653
3615
  kind: L.Property,
3654
- insertTextRules: y.KeepWhitespace,
3616
+ insertTextRules: w.KeepWhitespace,
3655
3617
  range: void 0
3656
3618
  }
3657
3619
  ]
@@ -3662,7 +3624,7 @@ function Nt(t, e) {
3662
3624
  ...["unique", "pk"].map((i) => ({
3663
3625
  label: i,
3664
3626
  insertText: i,
3665
- insertTextRules: y.KeepWhitespace,
3627
+ insertTextRules: w.KeepWhitespace,
3666
3628
  kind: L.Property,
3667
3629
  range: void 0
3668
3630
  })),
@@ -3670,7 +3632,7 @@ function Nt(t, e) {
3670
3632
  label: i,
3671
3633
  insertText: `${i}: `,
3672
3634
  kind: L.Property,
3673
- insertTextRules: y.KeepWhitespace,
3635
+ insertTextRules: w.KeepWhitespace,
3674
3636
  range: void 0
3675
3637
  }))
3676
3638
  ]
@@ -3681,14 +3643,14 @@ function Nt(t, e) {
3681
3643
  label: i,
3682
3644
  insertText: `${i}: `,
3683
3645
  kind: L.Property,
3684
- insertTextRules: y.KeepWhitespace,
3646
+ insertTextRules: w.KeepWhitespace,
3685
3647
  range: void 0
3686
3648
  }))
3687
3649
  };
3688
3650
  }
3689
3651
  return O();
3690
3652
  }
3691
- function Zn(t, e, n) {
3653
+ function Hn(t, e, n) {
3692
3654
  switch (n == null ? void 0 : n.toLowerCase()) {
3693
3655
  case "update":
3694
3656
  case "delete":
@@ -3697,7 +3659,7 @@ function Zn(t, e, n) {
3697
3659
  label: s,
3698
3660
  insertText: s,
3699
3661
  kind: L.Value,
3700
- insertTextRules: y.KeepWhitespace,
3662
+ insertTextRules: w.KeepWhitespace,
3701
3663
  range: void 0
3702
3664
  }))
3703
3665
  };
@@ -3707,23 +3669,23 @@ function Zn(t, e, n) {
3707
3669
  label: s,
3708
3670
  insertText: `${s}`,
3709
3671
  kind: L.Value,
3710
- insertTextRules: y.KeepWhitespace,
3672
+ insertTextRules: w.KeepWhitespace,
3711
3673
  range: void 0
3712
3674
  }))
3713
3675
  };
3714
3676
  }
3715
3677
  return O();
3716
3678
  }
3717
- function Bt(t, e, n) {
3718
- const s = Ee(n).unwrap_or([]);
3679
+ function Ft(t, e, n) {
3680
+ const s = Ne(n).unwrap_or([]);
3719
3681
  if (s.pop(), s.some((r) => !M(r)))
3720
3682
  return O();
3721
- const i = s.map((r) => X(r).unwrap());
3683
+ const i = s.map((r) => G(r).unwrap());
3722
3684
  return Ue({
3723
3685
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3724
3686
  label: a,
3725
3687
  insertText: a,
3726
- kind: _e(r),
3688
+ kind: ge(r),
3727
3689
  range: void 0
3728
3690
  }))
3729
3691
  });
@@ -3732,19 +3694,19 @@ function mt(t, e, n) {
3732
3694
  var i;
3733
3695
  switch (t.container.scopeKind(e)) {
3734
3696
  case D.TABLE:
3735
- return es(t, e, n);
3697
+ return Zn(t, e, n);
3736
3698
  case D.PROJECT:
3737
- return ts(t, e, n);
3699
+ return Kn(t, e, n);
3738
3700
  case D.INDEXES:
3739
- return ss(t, e);
3701
+ return ts(t, e);
3740
3702
  case D.ENUM:
3741
- return Kn(t, e, n);
3703
+ return Jn(t, e, n);
3742
3704
  case D.REF: {
3743
- const r = Vt(t, e);
3744
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
3705
+ const r = Bt(t, e);
3706
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Oe(r) : r;
3745
3707
  }
3746
3708
  case D.TABLEGROUP:
3747
- return ns(t);
3709
+ return es(t);
3748
3710
  default:
3749
3711
  return O();
3750
3712
  }
@@ -3754,26 +3716,26 @@ function Tt() {
3754
3716
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3755
3717
  label: t,
3756
3718
  insertText: t,
3757
- insertTextRules: y.KeepWhitespace,
3719
+ insertTextRules: w.KeepWhitespace,
3758
3720
  kind: L.Keyword,
3759
3721
  range: void 0
3760
3722
  }))
3761
3723
  };
3762
3724
  }
3763
- function Kn(t, e, n) {
3725
+ function Jn(t, e, n) {
3764
3726
  return n != null && n.callee && tt(e, n) === 1 ? Me(t, e, t.container.element(e), [
3765
3727
  m.Schema,
3766
3728
  m.Table,
3767
3729
  m.Column
3768
3730
  ]) : O();
3769
3731
  }
3770
- function es(t, e, n) {
3732
+ function Zn(t, e, n) {
3771
3733
  if (!(n != null && n.callee))
3772
3734
  return {
3773
3735
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3774
3736
  label: i,
3775
3737
  insertText: i,
3776
- insertTextRules: y.KeepWhitespace,
3738
+ insertTextRules: w.KeepWhitespace,
3777
3739
  kind: L.Keyword,
3778
3740
  range: void 0
3779
3741
  }))
@@ -3783,18 +3745,18 @@ function es(t, e, n) {
3783
3745
  suggestions: ["Ref", "Note", "indexes"].map((i) => ({
3784
3746
  label: i,
3785
3747
  insertText: i,
3786
- insertTextRules: y.KeepWhitespace,
3748
+ insertTextRules: w.KeepWhitespace,
3787
3749
  kind: L.Keyword,
3788
3750
  range: void 0
3789
3751
  }))
3790
- } : s === 1 ? is(t, e) : O();
3752
+ } : s === 1 ? ns(t, e) : O();
3791
3753
  }
3792
- function ts(t, e, n) {
3754
+ function Kn(t, e, n) {
3793
3755
  return n != null && n.callee ? tt(e, n) === 0 ? {
3794
3756
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3795
3757
  label: i,
3796
3758
  insertText: i,
3797
- insertTextRules: y.KeepWhitespace,
3759
+ insertTextRules: w.KeepWhitespace,
3798
3760
  kind: L.Keyword,
3799
3761
  range: void 0
3800
3762
  }))
@@ -3802,20 +3764,20 @@ function ts(t, e, n) {
3802
3764
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3803
3765
  label: i,
3804
3766
  insertText: i,
3805
- insertTextRules: y.KeepWhitespace,
3767
+ insertTextRules: w.KeepWhitespace,
3806
3768
  kind: L.Keyword,
3807
3769
  range: void 0
3808
3770
  }))
3809
3771
  };
3810
3772
  }
3811
- function Vt(t, e) {
3773
+ function Bt(t, e) {
3812
3774
  return Me(t, e, t.container.element(e), [
3813
3775
  m.Schema,
3814
3776
  m.Table,
3815
3777
  m.Column
3816
3778
  ]);
3817
3779
  }
3818
- function ns(t) {
3780
+ function es(t) {
3819
3781
  return Ue({
3820
3782
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3821
3783
  const n = se(e).unwrap_or(void 0);
@@ -3825,17 +3787,17 @@ function ns(t) {
3825
3787
  return s !== m.Table && s !== m.Schema ? [] : {
3826
3788
  label: i,
3827
3789
  insertText: i,
3828
- insertTextRules: y.KeepWhitespace,
3829
- kind: _e(s),
3790
+ insertTextRules: w.KeepWhitespace,
3791
+ kind: ge(s),
3830
3792
  range: void 0
3831
3793
  };
3832
3794
  })
3833
3795
  });
3834
3796
  }
3835
- function ss(t, e) {
3836
- return Gt(t, e);
3797
+ function ts(t, e) {
3798
+ return Vt(t, e);
3837
3799
  }
3838
- function is(t, e) {
3800
+ function ns(t, e) {
3839
3801
  return {
3840
3802
  suggestions: [
3841
3803
  ...[
@@ -3898,7 +3860,7 @@ function is(t, e) {
3898
3860
  ].map((n) => ({
3899
3861
  label: n,
3900
3862
  insertText: n,
3901
- insertTextRules: y.KeepWhitespace,
3863
+ insertTextRules: w.KeepWhitespace,
3902
3864
  kind: L.TypeParameter,
3903
3865
  sortText: L.TypeParameter.toString().padStart(2, "0"),
3904
3866
  range: void 0
@@ -3910,8 +3872,8 @@ function is(t, e) {
3910
3872
  ]
3911
3873
  };
3912
3874
  }
3913
- function Gt(t, e) {
3914
- const s = t.container.element(e).parent;
3875
+ function Vt(t, e) {
3876
+ const n = t.container.element(e), s = n == null ? void 0 : n.parent;
3915
3877
  if (!((s == null ? void 0 : s.symbol) instanceof At))
3916
3878
  return O();
3917
3879
  const { symbolTable: i } = s.symbol;
@@ -3920,12 +3882,12 @@ function Gt(t, e) {
3920
3882
  const a = se(r).unwrap_or(void 0);
3921
3883
  if (a === void 0)
3922
3884
  return [];
3923
- const { name: c } = a;
3885
+ const { name: l } = a;
3924
3886
  return {
3925
- label: c,
3926
- insertText: c,
3927
- insertTextRules: y.KeepWhitespace,
3928
- kind: _e(m.Column),
3887
+ label: l,
3888
+ insertText: l,
3889
+ insertTextRules: w.KeepWhitespace,
3890
+ kind: ge(m.Column),
3929
3891
  range: void 0
3930
3892
  };
3931
3893
  })
@@ -3937,7 +3899,7 @@ function tt(t, e) {
3937
3899
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
3938
3900
  return s === -1 ? n.length : s;
3939
3901
  }
3940
- class Ct {
3902
+ class Gt {
3941
3903
  constructor(e) {
3942
3904
  this.compiler = e;
3943
3905
  }
@@ -3945,9 +3907,9 @@ class Ct {
3945
3907
  var a;
3946
3908
  const { uri: s } = e, i = et(e, n), r = [...this.compiler.container.stack(i)];
3947
3909
  for (; r.length !== 0; ) {
3948
- const c = r.pop();
3949
- if ((a = c == null ? void 0 : c.referee) != null && a.declaration && [ue.PRIMARY_EXPRESSION, ue.VARIABLE].includes(c == null ? void 0 : c.kind)) {
3950
- const { startPos: p, endPos: h } = c.referee.declaration;
3910
+ const l = r.pop();
3911
+ if ((a = l == null ? void 0 : l.referee) != null && a.declaration && [he.PRIMARY_EXPRESSION, he.VARIABLE].includes(l == null ? void 0 : l.kind)) {
3912
+ const { startPos: p, endPos: h } = l.referee.declaration;
3951
3913
  return [
3952
3914
  {
3953
3915
  range: {
@@ -3964,7 +3926,7 @@ class Ct {
3964
3926
  return [];
3965
3927
  }
3966
3928
  }
3967
- class Xt {
3929
+ class Ct {
3968
3930
  constructor(e) {
3969
3931
  this.compiler = e;
3970
3932
  }
@@ -3973,13 +3935,13 @@ class Xt {
3973
3935
  for (; r.length !== 0; ) {
3974
3936
  const a = r.pop();
3975
3937
  if (a && [
3976
- ue.ELEMENT_DECLARATION,
3977
- ue.FUNCTION_APPLICATION,
3978
- ue.PRIMARY_EXPRESSION
3938
+ he.ELEMENT_DECLARATION,
3939
+ he.FUNCTION_APPLICATION,
3940
+ he.PRIMARY_EXPRESSION
3979
3941
  ].includes(a == null ? void 0 : a.kind)) {
3980
- const { symbol: c } = a;
3981
- if (c != null && c.references.length)
3982
- return c.references.map(({ startPos: p, endPos: h }) => ({
3942
+ const { symbol: l } = a;
3943
+ if (l != null && l.references.length)
3944
+ return l.references.map(({ startPos: p, endPos: h }) => ({
3983
3945
  range: {
3984
3946
  startColumn: p.column + 1,
3985
3947
  startLineNumber: p.line + 1,
@@ -3993,21 +3955,21 @@ class Xt {
3993
3955
  return [];
3994
3956
  }
3995
3957
  }
3996
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3958
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3997
3959
  __proto__: null,
3998
- CompletionItemInsertTextRule: y,
3960
+ CompletionItemInsertTextRule: w,
3999
3961
  CompletionItemKind: L,
4000
- DBMLCompletionItemProvider: Ft,
4001
- DBMLDefinitionProvider: Ct,
4002
- DBMLReferencesProvider: Xt
3962
+ DBMLCompletionItemProvider: Mt,
3963
+ DBMLDefinitionProvider: Gt,
3964
+ DBMLReferencesProvider: Ct
4003
3965
  }, Symbol.toStringTag, { value: "Module" }));
4004
3966
  var D = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(D || {});
4005
- class cs {
3967
+ class as {
4006
3968
  constructor() {
4007
3969
  this.source = "", this.cache = new Array(
4008
3970
  16
4009
3971
  /* TOTAL_QUERY_COUNT */
4010
- ).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
3972
+ ).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
4011
3973
  invalidStream: this.createQuery(
4012
3974
  6,
4013
3975
  () => this.parse.tokens().filter(vt)
@@ -4022,8 +3984,8 @@ class cs {
4022
3984
  _: this.createQuery(
4023
3985
  0,
4024
3986
  () => {
4025
- const e = new on(this.source).lex().chain((n) => new un(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Wn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
4026
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
3987
+ const e = new rn(this.source).lex().chain((n) => new ln(n, this.nodeIdGenerator).parse()).chain(({ ast: n, tokens: s }) => new Xn(n, this.symbolIdGenerator).analyze().map(() => ({ ast: n, tokens: s })));
3988
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4027
3989
  }
4028
3990
  ),
4029
3991
  ast: this.createQuery(
@@ -4058,33 +4020,33 @@ class cs {
4058
4020
  return [this.parse.ast()];
4059
4021
  const r = n[s].start;
4060
4022
  let a = this.parse.ast();
4061
- const c = [a];
4023
+ const l = [a];
4062
4024
  for (; ; ) {
4063
- const h = an(a).find((T) => Le(r, T));
4064
- if (h === void 0 || h instanceof V)
4025
+ const h = sn(a).find((T) => Ie(r, T));
4026
+ if (h === void 0 || h instanceof B)
4065
4027
  break;
4066
- c.push(h), a = h;
4028
+ l.push(h), a = h;
4067
4029
  }
4068
- if ((i == null ? void 0 : i.kind) === u.COLON)
4069
- return c;
4070
- for (; c.length > 0; ) {
4030
+ if ((i == null ? void 0 : i.kind) === c.COLON)
4031
+ return l;
4032
+ for (; l.length > 0; ) {
4071
4033
  let p = !1;
4072
- const h = I.last(c);
4073
- if (h instanceof v) {
4034
+ const h = I.last(l);
4035
+ if (h instanceof k) {
4074
4036
  const T = this.parse.source();
4075
4037
  for (let f = h.end; f < e; f += 1)
4076
4038
  T[f] === `
4077
- ` && (c.pop(), p = !0);
4039
+ ` && (l.pop(), p = !0);
4078
4040
  } else
4079
- h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (c.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (c.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (c.pop(), p = !0) : h instanceof ee ? h.blockCloseBrace && h.end <= e && (c.pop(), p = !0) : h instanceof te || h.end < e && (c.pop(), p = !0);
4041
+ h instanceof Q || h instanceof q ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof U ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof J ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof te ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof K || h.end < e && (l.pop(), p = !0);
4080
4042
  if (p) {
4081
- const T = I.last(c);
4082
- T instanceof _ && T.end <= e && c.pop();
4043
+ const T = I.last(l);
4044
+ T instanceof _ && T.end <= e && l.pop();
4083
4045
  }
4084
4046
  if (!p)
4085
4047
  break;
4086
4048
  }
4087
- return c;
4049
+ return l;
4088
4050
  }
4089
4051
  ),
4090
4052
  token: this.createQuery(
@@ -4116,7 +4078,7 @@ class cs {
4116
4078
  ),
4117
4079
  scopeKind: this.createQuery(15, (e) => {
4118
4080
  var s;
4119
- if (this.container.element(e) instanceof F)
4081
+ if (this.container.element(e) instanceof C)
4120
4082
  return 8;
4121
4083
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4122
4084
  case "table":
@@ -4156,14 +4118,14 @@ class cs {
4156
4118
  if (!((i = r.symbol) != null && i.symbolTable))
4157
4119
  continue;
4158
4120
  const { symbolTable: a } = r.symbol;
4159
- let c = [a], p = [];
4121
+ let l = [a], p = [];
4160
4122
  for (const h of e)
4161
- p = c.flatMap(
4162
- (T) => Qt(h).flatMap((f) => {
4123
+ p = l.flatMap(
4124
+ (T) => Yt(h).flatMap((f) => {
4163
4125
  const N = T.get(f), g = se(f).unwrap_or(void 0);
4164
4126
  return !N || !g ? [] : { ...g, symbol: N };
4165
4127
  })
4166
- ), c = p.flatMap(
4128
+ ), l = p.flatMap(
4167
4129
  (T) => T.symbol.symbolTable ? T.symbol.symbolTable : []
4168
4130
  );
4169
4131
  s.push(...p);
@@ -4190,8 +4152,8 @@ class cs {
4190
4152
  if (r.has(a))
4191
4153
  return r.get(a);
4192
4154
  }
4193
- const c = n(i);
4194
- 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;
4155
+ const l = n(i);
4156
+ 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;
4195
4157
  };
4196
4158
  }
4197
4159
  setSource(e) {
@@ -4202,14 +4164,14 @@ class cs {
4202
4164
  }
4203
4165
  initMonacoServices() {
4204
4166
  return {
4205
- definitionProvider: new Ct(this),
4206
- referenceProvider: new Xt(this),
4207
- autocompletionProvider: new Ft(this)
4167
+ definitionProvider: new Gt(this),
4168
+ referenceProvider: new Ct(this),
4169
+ autocompletionProvider: new Mt(this)
4208
4170
  };
4209
4171
  }
4210
4172
  }
4211
4173
  export {
4212
- cs as Compiler,
4213
- as as serialize,
4214
- os as services
4174
+ as as Compiler,
4175
+ is as serialize,
4176
+ rs as services
4215
4177
  };