@dbml/parse 3.1.8-alpha.0 → 3.1.8

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 it(t) {
36
36
  function rt(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 Tt(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 at(t, e) {
51
- return e.leadingTrivia.find(({ kind: s }) => s === u.NEWLINE) !== void 0 || Tt(t);
51
+ return e.leadingTrivia.find(({ kind: s }) => s === c.NEWLINE) !== void 0 || Tt(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 bt(t) {
57
57
  return t.trailingTrivia.length === 0 ? t.end : bt(I.last(t.trailingTrivia));
@@ -59,12 +59,12 @@ function bt(t) {
59
59
  function It(t) {
60
60
  return t.leadingTrivia.length === 0 ? t.start : It(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,19 +75,19 @@ class jt {
75
75
  return this.id++;
76
76
  }
77
77
  }
78
- class k {
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 ? It(i) : i.fullStart) : (this.startPos = {
84
+ i ? (this.startPos = i.startPos, this.fullStart = i instanceof B ? It(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 ? bt(r) : r.fullEnd) : (this.endPos = {
90
+ r ? (this.endPos = r.endPos, this.fullEnd = r instanceof B ? bt(r) : r.fullEnd) : (this.endPos = {
91
91
  offset: NaN,
92
92
  column: NaN,
93
93
  line: NaN
@@ -95,12 +95,12 @@ class k {
95
95
  }
96
96
  }
97
97
  var de = /* @__PURE__ */ ((t) => (t.PROGRAM = "<program>", t.ELEMENT_DECLARATION = "<element-declaration>", t.ATTRIBUTE = "<attribute>", t.IDENTIFIER_STREAM = "<identifer-stream>", t.LITERAL = "<literal>", t.VARIABLE = "<variable>", t.PREFIX_EXPRESSION = "<prefix-expression>", t.INFIX_EXPRESSION = "<infix-expression>", t.POSTFIX_EXPRESSION = "<postfix-expression>", t.FUNCTION_EXPRESSION = "<function-expression>", t.FUNCTION_APPLICATION = "<function-application>", t.BLOCK_EXPRESSION = "<block-expression>", t.LIST_EXPRESSION = "<list-expression>", t.TUPLE_EXPRESSION = "<tuple-expression>", t.CALL_EXPRESSION = "<call-expression>", t.PRIMARY_EXPRESSION = "<primary-expression>", t.GROUP_EXPRESSION = "<group-expression>", t.DUMMY = "<dummy>", t.ARRAY = "<array>", t))(de || {});
98
- class F extends k {
98
+ class X 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 A extends k {
103
+ class A extends y {
104
104
  constructor({
105
105
  type: e,
106
106
  name: n,
@@ -118,17 +118,17 @@ class A extends k {
118
118
  r,
119
119
  a,
120
120
  l
121
- ]), l && a && !(l instanceof w || l instanceof A))
121
+ ]), l && a && !(l instanceof k || l instanceof A))
122
122
  throw new Error("If an element has a simple body, it must be a function application node");
123
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 $ extends k {
126
+ class C extends y {
127
127
  constructor({ identifiers: e = [] }, n) {
128
128
  super(n, "<identifer-stream>", e || []), this.identifiers = e;
129
129
  }
130
130
  }
131
- class se extends k {
131
+ class se extends y {
132
132
  constructor({
133
133
  name: e,
134
134
  colon: n,
@@ -137,12 +137,12 @@ class se extends k {
137
137
  super(i, "<attribute>", [e, n, s]), this.name = e, this.value = s, this.colon = n;
138
138
  }
139
139
  }
140
- class q extends k {
140
+ class q extends 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 H extends k {
145
+ class H extends y {
146
146
  constructor({
147
147
  op: e,
148
148
  leftExpression: n,
@@ -151,22 +151,22 @@ class H extends k {
151
151
  super(i, "<infix-expression>", [n, e, s]), this.op = e, this.leftExpression = n, this.rightExpression = s;
152
152
  }
153
153
  }
154
- class De extends k {
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 te extends k {
159
+ class te extends y {
160
160
  constructor({ value: e }, n) {
161
161
  super(n, "<function-expression>", [e]), this.value = e;
162
162
  }
163
163
  }
164
- class w extends k {
164
+ class 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 ne extends k {
169
+ class ne extends y {
170
170
  constructor({
171
171
  blockOpenBrace: e,
172
172
  body: n = [],
@@ -175,7 +175,7 @@ class ne extends k {
175
175
  super(i, "<block-expression>", [e, ...n, s]), this.blockOpenBrace = e, this.body = n, this.blockCloseBrace = s;
176
176
  }
177
177
  }
178
- class P extends k {
178
+ class P extends y {
179
179
  constructor({
180
180
  listOpenBracket: e,
181
181
  elementList: n = [],
@@ -189,7 +189,7 @@ class P extends k {
189
189
  ]), this.listOpenBracket = e, this.elementList = n, this.commaList = s, this.listCloseBracket = i;
190
190
  }
191
191
  }
192
- class Z extends k {
192
+ class Z extends y {
193
193
  constructor({
194
194
  tupleOpenParen: e,
195
195
  elementList: n = [],
@@ -220,7 +220,7 @@ class Xe extends Z {
220
220
  ), this.kind = "<group-expression>";
221
221
  }
222
222
  }
223
- class J extends k {
223
+ class J extends y {
224
224
  constructor({
225
225
  callee: e,
226
226
  argumentList: n
@@ -228,28 +228,28 @@ class J extends k {
228
228
  super(s, "<call-expression>", [e, n]), this.callee = e, this.argumentList = n;
229
229
  }
230
230
  }
231
- class me extends k {
231
+ class me extends y {
232
232
  constructor({ literal: e }, n) {
233
233
  super(n, "<literal>", [e]), this.literal = e;
234
234
  }
235
235
  }
236
- class j extends k {
236
+ class $ extends y {
237
237
  constructor({ variable: e }, n) {
238
238
  super(n, "<variable>", [e]), this.variable = e;
239
239
  }
240
240
  }
241
- class D extends k {
241
+ class D extends y {
242
242
  constructor({ expression: e }, n) {
243
243
  super(n, "<primary-expression>", [e]), this.expression = e;
244
244
  }
245
245
  }
246
- class ye extends k {
246
+ class ye 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 ce extends k {
252
+ class ce 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 Lt(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 X) && 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,
@@ -290,7 +290,7 @@ function as(t, e = !1) {
290
290
  e ? 2 : 0
291
291
  );
292
292
  }
293
- class S {
293
+ class O {
294
294
  constructor(e) {
295
295
  this.value = e;
296
296
  }
@@ -305,7 +305,7 @@ class S {
305
305
  return e(this.value);
306
306
  }
307
307
  map(e) {
308
- return new S(e(this.value));
308
+ return new O(e(this.value));
309
309
  }
310
310
  // eslint-disable-next-line class-methods-use-this
311
311
  isOk() {
@@ -334,7 +334,7 @@ class v {
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
  }
@@ -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":
@@ -381,19 +378,19 @@ function Fe(t, e) {
381
378
  }
382
379
  function ie(t) {
383
380
  const [e, n] = t.split(":");
384
- return Object.values(m).includes(e) ? new S({
381
+ return Object.values(m).includes(e) ? new O({
385
382
  name: n,
386
383
  kind: e
387
384
  }) : new v();
388
385
  }
389
- function zt(t) {
386
+ function jt(t) {
390
387
  const e = ie(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
396
  xe,
@@ -408,16 +405,16 @@ function qe(t) {
408
405
  const [e] = t;
409
406
  return e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "_";
410
407
  }
411
- function Se(t) {
408
+ function Oe(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 Se(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
414
+ return Oe(e) || qe(e) && e.toLowerCase() >= "a" && e.toLowerCase() <= "f";
418
415
  }
419
416
  function pe(t) {
420
- return qe(t) || Se(t);
417
+ return qe(t) || Oe(t);
421
418
  }
422
419
  function ot(t, e) {
423
420
  const n = [], s = Math.min(t.length, e.length);
@@ -425,10 +422,10 @@ function ot(t, e) {
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 gt {
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 _t {
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[t.TABLE_REAPPEAR_IN_TABLEGROUP = 5005] = "TABLE_REAPPEAR_IN_TABLEGROUP", t))(o || {});
478
- class c 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, c.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,20 +489,20 @@ 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) {
498
+ function en(t, e, n) {
502
499
  if (!t || !Ee(t) || e.length === 0)
503
500
  return new v();
504
501
  const s = [...e], i = Be(t).unwrap(), r = s.pop();
505
502
  if (!(r instanceof ne))
506
503
  return new v();
507
504
  const a = I.last(s) instanceof P ? s.pop() : void 0;
508
- return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new S(
505
+ return s.length === 3 && Be(s[1]).unwrap().value === "as" ? new O(
509
506
  n.create(A, {
510
507
  type: i,
511
508
  name: s[0],
@@ -514,14 +511,14 @@ function nn(t, e, n) {
514
511
  attributeList: a,
515
512
  body: r
516
513
  })
517
- ) : s.length === 1 ? new S(
514
+ ) : s.length === 1 ? new O(
518
515
  n.create(A, {
519
516
  type: i,
520
517
  name: s[0],
521
518
  attributeList: a,
522
519
  body: r
523
520
  })
524
- ) : s.length === 0 ? new S(
521
+ ) : s.length === 0 ? new O(
525
522
  n.create(A, {
526
523
  type: i,
527
524
  attributeList: a,
@@ -530,18 +527,18 @@ function nn(t, e, n) {
530
527
  ) : new v();
531
528
  }
532
529
  function lt(t) {
533
- return t.kind === u.IDENTIFIER && t.value === "as";
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 A)
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 $)
541
+ else if (t instanceof C)
545
542
  t.identifiers.forEach(E);
546
543
  else if (t instanceof se)
547
544
  E(t.name), E(t.colon), E(t.value);
@@ -559,13 +556,13 @@ 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 J)
561
558
  E(t.callee), E(t.argumentList);
562
- else if (t instanceof w)
559
+ else if (t instanceof k)
563
560
  E(t.callee), t.args.forEach(E);
564
561
  else if (t instanceof D)
565
562
  E(t.expression);
566
563
  else if (t instanceof te)
567
564
  E(t.value);
568
- else if (t instanceof j)
565
+ else if (t instanceof $)
569
566
  E(t.variable);
570
567
  else if (t instanceof me)
571
568
  E(t.literal);
@@ -578,8 +575,8 @@ function At(t) {
578
575
  function U(...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 X)
583
580
  return U(...t.body, t.eof);
584
581
  if (t instanceof A)
585
582
  return U(
@@ -593,11 +590,11 @@ function an(t) {
593
590
  );
594
591
  if (t instanceof se)
595
592
  return U(t.name, t.colon, t.value);
596
- if (t instanceof $)
593
+ if (t instanceof C)
597
594
  return t.identifiers;
598
595
  if (t instanceof me)
599
596
  return t.literal ? [t.literal] : [];
600
- if (t instanceof j)
597
+ if (t instanceof $)
601
598
  return U(t.variable);
602
599
  if (t instanceof q)
603
600
  return U(t.op, t.expression);
@@ -607,7 +604,7 @@ function an(t) {
607
604
  return U(t.expression, t.op);
608
605
  if (t instanceof te)
609
606
  return U(t.value);
610
- if (t instanceof w)
607
+ if (t instanceof k)
611
608
  return U(t.callee, ...t.args);
612
609
  if (t instanceof ne)
613
610
  return U(t.blockOpenBrace, ...t.body, t.blockCloseBrace);
@@ -635,30 +632,30 @@ function an(t) {
635
632
  throw t instanceof Xe ? new Error("This case is already handled by TupleExpressionNode") : new Error("Unreachable - no other possible cases");
636
633
  }
637
634
  function Be(t) {
638
- return M(t) ? new S(t.expression.variable) : new v();
635
+ return M(t) ? new O(t.expression.variable) : new v();
639
636
  }
640
- function Y(t) {
637
+ function W(t) {
641
638
  var e;
642
- return t instanceof D && (t.expression instanceof j && t.expression.variable instanceof V && t.expression.variable.kind === u.QUOTED_STRING || t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.STRING_LITERAL);
639
+ return t instanceof D && (t.expression instanceof $ && t.expression.variable instanceof B && t.expression.variable.kind === c.QUOTED_STRING || t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.STRING_LITERAL);
643
640
  }
644
641
  function M(t) {
645
- return t instanceof D && t.expression instanceof j && t.expression.variable instanceof V;
642
+ return t instanceof D && t.expression instanceof $ && t.expression.variable instanceof B;
646
643
  }
647
644
  function Ee(t) {
648
645
  var e;
649
- return t instanceof D && t.expression instanceof j && ((e = t.expression.variable) == null ? void 0 : e.kind) === u.IDENTIFIER;
646
+ return t instanceof D && t.expression instanceof $ && ((e = t.expression.variable) == null ? void 0 : e.kind) === c.IDENTIFIER;
650
647
  }
651
648
  function He(t) {
652
649
  var e;
653
- return t instanceof H && t.leftExpression instanceof k && t.rightExpression instanceof k && ((e = t.op) == null ? void 0 : e.value) === ".";
650
+ return t instanceof H && t.leftExpression instanceof y && t.rightExpression instanceof y && ((e = t.op) == null ? void 0 : e.value) === ".";
654
651
  }
655
652
  function Ne(t) {
656
653
  if (t === void 0)
657
654
  return new v();
658
655
  const e = t.identifiers.map((n) => n.value).join(" ");
659
- return e === "" ? new v() : new S(e);
656
+ return e === "" ? new v() : new O(e);
660
657
  }
661
- class on {
658
+ class rn {
662
659
  // list of errors during lexing
663
660
  constructor(e) {
664
661
  this.start = {
@@ -698,7 +695,7 @@ class on {
698
695
  this.tokens.push(this.createToken(e, n));
699
696
  }
700
697
  createToken(e, n = !1) {
701
- return V.create(
698
+ return B.create(
702
699
  e,
703
700
  this.start,
704
701
  this.current,
@@ -707,50 +704,50 @@ class on {
707
704
  );
708
705
  }
709
706
  lex() {
710
- 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);
707
+ 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);
711
708
  }
712
709
  scanTokens() {
713
710
  for (; !this.isAtEnd(); ) {
714
711
  const e = this.advance();
715
712
  switch (e) {
716
713
  case " ":
717
- this.addToken(u.SPACE);
714
+ this.addToken(c.SPACE);
718
715
  break;
719
716
  case "\r":
720
717
  break;
721
718
  case `
722
719
  `:
723
- this.addToken(u.NEWLINE);
720
+ this.addToken(c.NEWLINE);
724
721
  break;
725
722
  case " ":
726
- this.addToken(u.TAB);
723
+ this.addToken(c.TAB);
727
724
  break;
728
725
  case ",":
729
- this.addToken(u.COMMA);
726
+ this.addToken(c.COMMA);
730
727
  break;
731
728
  case "(":
732
- this.addToken(u.LPAREN);
729
+ this.addToken(c.LPAREN);
733
730
  break;
734
731
  case ")":
735
- this.addToken(u.RPAREN);
732
+ this.addToken(c.RPAREN);
736
733
  break;
737
734
  case "[":
738
- this.addToken(u.LBRACKET);
735
+ this.addToken(c.LBRACKET);
739
736
  break;
740
737
  case "]":
741
- this.addToken(u.RBRACKET);
738
+ this.addToken(c.RBRACKET);
742
739
  break;
743
740
  case "{":
744
- this.addToken(u.LBRACE);
741
+ this.addToken(c.LBRACE);
745
742
  break;
746
743
  case "}":
747
- this.addToken(u.RBRACE);
744
+ this.addToken(c.RBRACE);
748
745
  break;
749
746
  case ";":
750
- this.addToken(u.SEMICOLON);
747
+ this.addToken(c.SEMICOLON);
751
748
  break;
752
749
  case ":":
753
- this.addToken(u.COLON);
750
+ this.addToken(c.COLON);
754
751
  break;
755
752
  case "'":
756
753
  this.match("''") ? this.multilineStringLiteral() : this.singleLineStringLiteral();
@@ -776,15 +773,15 @@ class on {
776
773
  this.identifier();
777
774
  break;
778
775
  }
779
- if (Se(e)) {
776
+ if (Oe(e)) {
780
777
  this.numericLiteralOrIdentifier();
781
778
  break;
782
779
  }
783
- this.addToken(u.OP, !0), this.errors.push(
784
- new c(
780
+ this.addToken(c.OP, !0), this.errors.push(
781
+ new u(
785
782
  o.UNKNOWN_SYMBOL,
786
783
  `Unexpected token '${e}'`,
787
- this.createToken(u.OP, !0)
784
+ this.createToken(c.OP, !0)
788
785
  )
789
786
  );
790
787
  break;
@@ -796,7 +793,7 @@ class on {
796
793
  let e = !0, n = [], s;
797
794
  const i = [];
798
795
  for (const r of this.tokens)
799
- $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);
796
+ 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);
800
797
  this.tokens = i;
801
798
  }
802
799
  gatherInvalid() {
@@ -828,7 +825,7 @@ class on {
828
825
  if (this.isAtEnd() && !i) {
829
826
  const p = this.createToken(e, !0);
830
827
  this.tokens.push(p), this.errors.push(
831
- new c(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
828
+ new u(o.UNEXPECTED_EOF, "EOF reached while parsing", p)
832
829
  );
833
830
  return;
834
831
  }
@@ -836,7 +833,7 @@ class on {
836
833
  `) && !s) {
837
834
  const p = this.createToken(e, !0);
838
835
  this.tokens.push(p), this.errors.push(
839
- new c(
836
+ new u(
840
837
  o.UNEXPECTED_NEWLINE,
841
838
  "Invalid newline encountered while parsing",
842
839
  p
@@ -844,38 +841,38 @@ class on {
844
841
  );
845
842
  return;
846
843
  }
847
- a && this.match(n), this.tokens.push(V.create(e, this.start, this.current, l, !1));
844
+ a && this.match(n), this.tokens.push(B.create(e, this.start, this.current, l, !1));
848
845
  }
849
846
  singleLineStringLiteral() {
850
- this.consumeUntil(u.STRING_LITERAL, "'", {
847
+ this.consumeUntil(c.STRING_LITERAL, "'", {
851
848
  allowNewline: !1,
852
849
  allowEof: !1,
853
850
  raw: !1
854
851
  });
855
852
  }
856
853
  multilineStringLiteral() {
857
- this.consumeUntil(u.STRING_LITERAL, "'''", {
854
+ this.consumeUntil(c.STRING_LITERAL, "'''", {
858
855
  allowNewline: !0,
859
856
  allowEof: !1,
860
857
  raw: !1
861
858
  });
862
859
  }
863
860
  functionExpression() {
864
- this.consumeUntil(u.FUNCTION_EXPRESSION, "`", {
861
+ this.consumeUntil(c.FUNCTION_EXPRESSION, "`", {
865
862
  allowNewline: !1,
866
863
  allowEof: !1,
867
864
  raw: !0
868
865
  });
869
866
  }
870
867
  quotedVariable() {
871
- this.consumeUntil(u.QUOTED_STRING, '"', {
868
+ this.consumeUntil(c.QUOTED_STRING, '"', {
872
869
  allowNewline: !1,
873
870
  allowEof: !1,
874
871
  raw: !1
875
872
  });
876
873
  }
877
874
  singleLineComment() {
878
- this.consumeUntil(u.SINGLE_LINE_COMMENT, `
875
+ this.consumeUntil(c.SINGLE_LINE_COMMENT, `
879
876
  `, {
880
877
  allowNewline: !0,
881
878
  allowEof: !0,
@@ -884,7 +881,7 @@ class on {
884
881
  });
885
882
  }
886
883
  multilineComment() {
887
- this.consumeUntil(u.MULTILINE_COMMENT, "*/", {
884
+ this.consumeUntil(c.MULTILINE_COMMENT, "*/", {
888
885
  allowNewline: !0,
889
886
  allowEof: !1,
890
887
  raw: !0
@@ -893,46 +890,46 @@ class on {
893
890
  identifier() {
894
891
  for (; !this.isAtEnd() && pe(this.peek()); )
895
892
  this.advance();
896
- this.addToken(u.IDENTIFIER);
893
+ this.addToken(c.IDENTIFIER);
897
894
  }
898
895
  operator() {
899
896
  for (; it(this.peek()); )
900
897
  this.advance();
901
- this.addToken(u.OP);
898
+ this.addToken(c.OP);
902
899
  }
903
900
  // we accept identifiers starting with digits but must contain at least one char or underscore
904
901
  numericLiteralOrIdentifier() {
905
902
  let e = 0;
906
903
  if (this.isAtEnd())
907
- return this.addToken(u.NUMERIC_LITERAL);
904
+ return this.addToken(c.NUMERIC_LITERAL);
908
905
  for (; !this.isAtEnd(); ) {
909
906
  const n = this.check(".");
910
907
  if (e += n ? 1 : 0, e > 1)
911
908
  break;
912
909
  if (!n && this.current.offset === this.text.length - 1)
913
- return this.advance(), this.addToken(u.NUMERIC_LITERAL);
910
+ return this.advance(), this.addToken(c.NUMERIC_LITERAL);
914
911
  if (!n && !pe(this.peek()))
915
- return this.addToken(u.NUMERIC_LITERAL);
916
- if (!n && !Se(this.peek()))
912
+ return this.addToken(c.NUMERIC_LITERAL);
913
+ if (!n && !Oe(this.peek()))
917
914
  break;
918
915
  this.advance();
919
916
  }
920
917
  if (e > 0) {
921
918
  for (; !this.isAtEnd() && (this.check(".") || pe(this.peek())); )
922
919
  this.advance();
923
- const n = this.createToken(u.NUMERIC_LITERAL, !0);
924
- this.tokens.push(n), this.errors.push(new c(o.UNKNOWN_TOKEN, "Invalid number", n));
920
+ const n = this.createToken(c.NUMERIC_LITERAL, !0);
921
+ this.tokens.push(n), this.errors.push(new u(o.UNKNOWN_TOKEN, "Invalid number", n));
925
922
  } else {
926
923
  for (; !this.isAtEnd() && pe(this.peek()); )
927
924
  this.advance();
928
- const n = this.createToken(u.IDENTIFIER, !1);
925
+ const n = this.createToken(c.IDENTIFIER, !1);
929
926
  this.tokens.push(n);
930
927
  }
931
928
  }
932
929
  colorLiteral() {
933
930
  for (; !this.isAtEnd() && pe(this.peek()); )
934
931
  this.advance();
935
- this.addToken(u.COLOR_LITERAL);
932
+ this.addToken(c.COLOR_LITERAL);
936
933
  }
937
934
  escapedString() {
938
935
  if (this.isAtEnd())
@@ -974,7 +971,7 @@ class on {
974
971
  }
975
972
  }
976
973
  var ke = /* @__PURE__ */ ((t) => (t[t.ListExpression = 0] = "ListExpression", t[t.GroupExpression = 1] = "GroupExpression", t[t.BlockExpression = 2] = "BlockExpression", t))(ke || {});
977
- class ln {
974
+ class an {
978
975
  constructor() {
979
976
  this.stack = [], this.numberOfNestedLParens = 0, this.numberOfNestedLBrackets = 0, this.numberOfNestedLBraces = 0;
980
977
  }
@@ -1015,7 +1012,7 @@ class ln {
1015
1012
  if (!(this.numberOfNestedLBraces <= 0 && this.numberOfNestedLBrackets <= 0 && this.numberOfNestedLParens <= 0))
1016
1013
  for (let s = n; s < e.length - 1; s += 1)
1017
1014
  switch (e[s].kind) {
1018
- case u.COMMA:
1015
+ case c.COMMA:
1019
1016
  if (this.isWithinGroupExpressionContext() || this.isWithinListExpressionContext())
1020
1017
  return [...this.stack].reverse().find(
1021
1018
  (r) => [
@@ -1025,22 +1022,22 @@ class ln {
1025
1022
  ].includes(r)
1026
1023
  );
1027
1024
  break;
1028
- case u.RPAREN:
1025
+ case c.RPAREN:
1029
1026
  if (this.isWithinGroupExpressionContext())
1030
1027
  return 1;
1031
1028
  break;
1032
- case u.RBRACE:
1029
+ case c.RBRACE:
1033
1030
  if (this.isWithinBlockExpressionContext())
1034
1031
  return 2;
1035
1032
  break;
1036
- case u.RBRACKET:
1033
+ case c.RBRACKET:
1037
1034
  if (this.isWithinListExpressionContext())
1038
1035
  return 0;
1039
1036
  break;
1040
1037
  }
1041
1038
  }
1042
1039
  }
1043
- class cn {
1040
+ class on {
1044
1041
  constructor(e) {
1045
1042
  this.generator = e;
1046
1043
  }
@@ -1053,29 +1050,29 @@ class d {
1053
1050
  this.token = e, this.partialNode = n, this.handlerContext = s;
1054
1051
  }
1055
1052
  }
1056
- class un {
1053
+ class ln {
1057
1054
  constructor(e, n) {
1058
- this.current = 0, this.errors = [], this.contextStack = new ln(), this.synchronizeProgram = () => {
1055
+ this.current = 0, this.errors = [], this.contextStack = new an(), this.synchronizeProgram = () => {
1059
1056
  const s = this.peek();
1060
- s.kind !== u.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1057
+ s.kind !== c.EOF ? E(this.advance()) : (E(this.peek()), this.logError(s, o.UNEXPECTED_EOF, "Unexpected EOF"));
1061
1058
  }, this.synchronizeElementDeclarationName = () => {
1062
1059
  for (; !this.isAtEnd(); ) {
1063
1060
  const s = this.peek();
1064
- if (lt(s) || this.check(u.COLON, u.LBRACE, u.LBRACKET))
1061
+ if (lt(s) || this.check(c.COLON, c.LBRACE, c.LBRACKET))
1065
1062
  break;
1066
1063
  E(s), this.advance();
1067
1064
  }
1068
1065
  }, this.synchronizeElementDeclarationAlias = () => {
1069
1066
  for (; !this.isAtEnd(); ) {
1070
1067
  const s = this.peek();
1071
- if (this.check(u.COLON, u.LBRACE, u.LBRACKET))
1068
+ if (this.check(c.COLON, c.LBRACE, c.LBRACKET))
1072
1069
  break;
1073
1070
  E(s), this.advance();
1074
1071
  }
1075
1072
  }, this.blockExpression = this.contextStack.withContextDo(ke.BlockExpression, () => {
1076
1073
  const s = { body: [] }, i = () => this.nodeFactory.create(ne, s);
1077
1074
  try {
1078
- this.consume("Expect an opening brace '{'", u.LBRACE), s.blockOpenBrace = this.previous();
1075
+ this.consume("Expect an opening brace '{'", c.LBRACE), s.blockOpenBrace = this.previous();
1079
1076
  } catch (r) {
1080
1077
  if (!(r instanceof d))
1081
1078
  throw r;
@@ -1083,7 +1080,7 @@ class un {
1083
1080
  throw new d(r.token, i(), r.handlerContext);
1084
1081
  this.synchronizeBlock();
1085
1082
  }
1086
- for (; !this.isAtEnd() && !this.check(u.RBRACE); )
1083
+ for (; !this.isAtEnd() && !this.check(c.RBRACE); )
1087
1084
  try {
1088
1085
  s.body.push(this.canBeField() ? this.fieldDeclaration() : this.expression());
1089
1086
  } catch (r) {
@@ -1094,7 +1091,7 @@ class un {
1094
1091
  this.synchronizeBlock();
1095
1092
  }
1096
1093
  try {
1097
- this.consume("Expect a closing brace '}'", u.RBRACE), s.blockCloseBrace = this.previous();
1094
+ this.consume("Expect a closing brace '}'", c.RBRACE), s.blockCloseBrace = this.previous();
1098
1095
  } catch (r) {
1099
1096
  if (!(r instanceof d))
1100
1097
  throw r;
@@ -1104,10 +1101,10 @@ class un {
1104
1101
  }
1105
1102
  return i();
1106
1103
  }), this.synchronizeBlock = () => {
1107
- if (!this.check(u.RBRACE))
1104
+ if (!this.check(c.RBRACE))
1108
1105
  for (E(this.advance()); !this.isAtEnd(); ) {
1109
1106
  const s = this.peek();
1110
- if (this.check(u.RBRACE) || at(this.previous(), s))
1107
+ if (this.check(c.RBRACE) || at(this.previous(), s))
1111
1108
  break;
1112
1109
  E(s), this.advance();
1113
1110
  }
@@ -1118,7 +1115,7 @@ class un {
1118
1115
  expression: s.elementList[0]
1119
1116
  }), r = () => this.nodeFactory.create(Z, s);
1120
1117
  try {
1121
- this.consume("Expect an opening parenthesis '('", u.LPAREN), s.tupleOpenParen = this.previous();
1118
+ this.consume("Expect an opening parenthesis '('", c.LPAREN), s.tupleOpenParen = this.previous();
1122
1119
  } catch (a) {
1123
1120
  if (!(a instanceof d))
1124
1121
  throw a;
@@ -1126,7 +1123,7 @@ class un {
1126
1123
  throw new d(a.token, r(), a.handlerContext);
1127
1124
  this.synchronizeTuple();
1128
1125
  }
1129
- if (!this.isAtEnd() && !this.check(u.RPAREN))
1126
+ if (!this.isAtEnd() && !this.check(c.RPAREN))
1130
1127
  try {
1131
1128
  s.elementList.push(this.normalExpression());
1132
1129
  } catch (a) {
@@ -1136,18 +1133,18 @@ class un {
1136
1133
  throw new d(a.token, i(), a.handlerContext);
1137
1134
  this.synchronizeTuple();
1138
1135
  }
1139
- for (; !this.isAtEnd() && !this.check(u.RPAREN); )
1136
+ for (; !this.isAtEnd() && !this.check(c.RPAREN); )
1140
1137
  try {
1141
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1138
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.normalExpression());
1142
1139
  } catch (a) {
1143
1140
  if (!(a instanceof d))
1144
1141
  throw a;
1145
- if (a.partialNode instanceof k && s.elementList.push(a.partialNode), !this.canHandle(a))
1142
+ if (a.partialNode instanceof y && s.elementList.push(a.partialNode), !this.canHandle(a))
1146
1143
  throw new d(a.token, r(), a.handlerContext);
1147
1144
  this.synchronizeTuple();
1148
1145
  }
1149
1146
  try {
1150
- this.consume("Expect a closing parenthesis ')'", u.RPAREN), s.tupleCloseParen = this.previous();
1147
+ this.consume("Expect a closing parenthesis ')'", c.RPAREN), s.tupleCloseParen = this.previous();
1151
1148
  } catch (a) {
1152
1149
  if (!(a instanceof d))
1153
1150
  throw a;
@@ -1159,14 +1156,14 @@ class un {
1159
1156
  }), this.synchronizeTuple = () => {
1160
1157
  for (; !this.isAtEnd(); ) {
1161
1158
  const s = this.peek();
1162
- if (this.check(u.RPAREN, u.COMMA))
1159
+ if (this.check(c.RPAREN, c.COMMA))
1163
1160
  break;
1164
1161
  E(s), this.advance();
1165
1162
  }
1166
1163
  }, this.listExpression = this.contextStack.withContextDo(ke.ListExpression, () => {
1167
1164
  const s = { elementList: [], commaList: [] }, i = () => this.nodeFactory.create(P, s);
1168
1165
  try {
1169
- this.consume("Expect an opening bracket '['", u.LBRACKET), s.listOpenBracket = this.previous();
1166
+ this.consume("Expect an opening bracket '['", c.LBRACKET), s.listOpenBracket = this.previous();
1170
1167
  } catch (r) {
1171
1168
  if (!(r instanceof d))
1172
1169
  throw r;
@@ -1174,7 +1171,7 @@ class un {
1174
1171
  throw new d(r.token, i(), r.handlerContext);
1175
1172
  this.synchronizeList();
1176
1173
  }
1177
- if (!this.isAtEnd() && !this.check(u.RBRACKET))
1174
+ if (!this.isAtEnd() && !this.check(c.RBRACKET))
1178
1175
  try {
1179
1176
  s.elementList.push(this.attribute());
1180
1177
  } catch (r) {
@@ -1184,18 +1181,18 @@ class un {
1184
1181
  throw new d(r.token, i(), r.handlerContext);
1185
1182
  this.synchronizeList();
1186
1183
  }
1187
- for (; !this.isAtEnd() && !this.check(u.RBRACKET); )
1184
+ for (; !this.isAtEnd() && !this.check(c.RBRACKET); )
1188
1185
  try {
1189
- this.consume("Expect a comma ','", u.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1186
+ this.consume("Expect a comma ','", c.COMMA), s.commaList.push(this.previous()), s.elementList.push(this.attribute());
1190
1187
  } catch (r) {
1191
1188
  if (!(r instanceof d))
1192
1189
  throw r;
1193
- if (r.partialNode instanceof k && s.elementList.push(r.partialNode), !this.canHandle(r))
1190
+ if (r.partialNode instanceof y && s.elementList.push(r.partialNode), !this.canHandle(r))
1194
1191
  throw new d(r.token, i(), r.handlerContext);
1195
1192
  this.synchronizeList();
1196
1193
  }
1197
1194
  try {
1198
- this.consume("Expect a closing bracket ']'", u.RBRACKET), s.listCloseBracket = this.previous();
1195
+ this.consume("Expect a closing bracket ']'", c.RBRACKET), s.listCloseBracket = this.previous();
1199
1196
  } catch (r) {
1200
1197
  if (!(r instanceof d))
1201
1198
  throw r;
@@ -1207,28 +1204,28 @@ class un {
1207
1204
  }), this.synchronizeList = () => {
1208
1205
  for (; !this.isAtEnd(); ) {
1209
1206
  const s = this.peek();
1210
- if (this.check(u.COMMA, u.RBRACKET))
1207
+ if (this.check(c.COMMA, c.RBRACKET))
1211
1208
  break;
1212
1209
  E(s), this.advance();
1213
1210
  }
1214
1211
  }, this.synchronizeAttributeName = () => {
1215
1212
  for (; !this.isAtEnd(); ) {
1216
1213
  const s = this.peek();
1217
- if (this.check(u.COMMA, u.RBRACKET, u.COLON))
1214
+ if (this.check(c.COMMA, c.RBRACKET, c.COLON))
1218
1215
  break;
1219
1216
  E(s), this.advance();
1220
1217
  }
1221
1218
  }, this.synchronizeAttributeValue = () => {
1222
1219
  for (; !this.isAtEnd(); ) {
1223
1220
  const s = this.peek();
1224
- if (this.check(u.COMMA, u.RBRACKET))
1221
+ if (this.check(c.COMMA, c.RBRACKET))
1225
1222
  break;
1226
1223
  E(s), this.advance();
1227
1224
  }
1228
- }, this.tokens = e, this.nodeFactory = new cn(n);
1225
+ }, this.tokens = e, this.nodeFactory = new on(n);
1229
1226
  }
1230
1227
  isAtEnd() {
1231
- return this.current >= this.tokens.length || this.tokens[this.current].kind === u.EOF;
1228
+ return this.current >= this.tokens.length || this.tokens[this.current].kind === c.EOF;
1232
1229
  }
1233
1230
  advance() {
1234
1231
  return this.isAtEnd() ? I.last(this.tokens) : this.tokens[this.current++];
@@ -1281,8 +1278,8 @@ class un {
1281
1278
  this.tokens = e;
1282
1279
  }
1283
1280
  parse() {
1284
- const e = this.program(), n = this.advance(), s = this.nodeFactory.create(F, { body: e, eof: n });
1285
- return this.gatherInvalid(), new B({ ast: s, tokens: this.tokens }, this.errors);
1281
+ const e = this.program(), n = this.advance(), s = this.nodeFactory.create(X, { body: e, eof: n });
1282
+ return this.gatherInvalid(), new F({ ast: s, tokens: this.tokens }, this.errors);
1286
1283
  }
1287
1284
  /* Parsing and synchronizing ProgramNode */
1288
1285
  program() {
@@ -1302,11 +1299,11 @@ class un {
1302
1299
  elementDeclaration() {
1303
1300
  const e = {}, n = () => this.nodeFactory.create(A, e);
1304
1301
  try {
1305
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1302
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1306
1303
  } catch (s) {
1307
1304
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1308
1305
  }
1309
- if (!this.check(u.COLON, u.LBRACE, u.LBRACKET))
1306
+ if (!this.check(c.COLON, c.LBRACE, c.LBRACKET))
1310
1307
  try {
1311
1308
  e.name = this.normalExpression();
1312
1309
  } catch (s) {
@@ -1317,7 +1314,7 @@ class un {
1317
1314
  this.synchronizeElementDeclarationName();
1318
1315
  }
1319
1316
  if (lt(this.peek()))
1320
- if (e.as = this.advance(), this.check(u.COLON, u.LBRACE, u.LBRACKET))
1317
+ if (e.as = this.advance(), this.check(c.COLON, c.LBRACE, c.LBRACKET))
1321
1318
  this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect an alias");
1322
1319
  else
1323
1320
  try {
@@ -1330,18 +1327,18 @@ class un {
1330
1327
  this.synchronizeElementDeclarationAlias();
1331
1328
  }
1332
1329
  try {
1333
- e.attributeList = this.check(u.LBRACKET) ? this.listExpression() : void 0;
1330
+ e.attributeList = this.check(c.LBRACKET) ? this.listExpression() : void 0;
1334
1331
  } catch (s) {
1335
1332
  throw s instanceof d ? (e.attributeList = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1336
1333
  }
1337
1334
  if (!this.discardUntil(
1338
1335
  "Expect an opening brace '{' or a colon ':'",
1339
- u.LBRACE,
1340
- u.COLON
1336
+ c.LBRACE,
1337
+ c.COLON
1341
1338
  ))
1342
1339
  return n();
1343
1340
  try {
1344
- if (this.match(u.COLON)) {
1341
+ if (this.match(c.COLON)) {
1345
1342
  e.bodyColon = this.previous();
1346
1343
  const s = this.expression();
1347
1344
  s instanceof A ? (E(s), this.logError(s, o.UNEXPECTED_ELEMENT_DECLARATION, "An element's simple body must not be an element declaration")) : e.body = s;
@@ -1361,18 +1358,18 @@ class un {
1361
1358
  fieldDeclaration() {
1362
1359
  const e = {}, n = () => this.nodeFactory.create(A, e);
1363
1360
  try {
1364
- this.consume("Expect an identifier", u.IDENTIFIER), e.type = this.previous();
1361
+ this.consume("Expect an identifier", c.IDENTIFIER), e.type = this.previous();
1365
1362
  } catch (s) {
1366
1363
  throw s instanceof d ? (e.type = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1367
1364
  }
1368
1365
  try {
1369
- this.consume("Expect a colon ':'", u.COLON), e.bodyColon = this.previous();
1366
+ this.consume("Expect a colon ':'", c.COLON), e.bodyColon = this.previous();
1370
1367
  } catch (s) {
1371
1368
  throw s instanceof d ? (e.bodyColon = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1372
1369
  }
1373
1370
  try {
1374
1371
  const s = this.expression();
1375
- s instanceof A ? this.errors.push(new c(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1372
+ s instanceof A ? this.errors.push(new u(o.INVALID_ELEMENT_IN_SIMPLE_BODY, "Simple body cannot be an element declaration", s)) : e.body = s;
1376
1373
  } catch (s) {
1377
1374
  throw s instanceof d ? (e.body = s.partialNode, new d(s.token, n(), s.handlerContext)) : s;
1378
1375
  }
@@ -1380,8 +1377,8 @@ class un {
1380
1377
  }
1381
1378
  /* Parsing any ExpressionNode, including non-NormalExpression */
1382
1379
  expression() {
1383
- const e = { args: [] }, n = () => nn(e.callee, e.args, this.nodeFactory).unwrap_or(
1384
- this.nodeFactory.create(w, e)
1380
+ const e = { args: [] }, n = () => en(e.callee, e.args, this.nodeFactory).unwrap_or(
1381
+ this.nodeFactory.create(k, e)
1385
1382
  );
1386
1383
  try {
1387
1384
  e.callee = this.normalExpression();
@@ -1405,7 +1402,7 @@ class un {
1405
1402
  if (this.isAtEnd() || Tt(this.previous()))
1406
1403
  return !0;
1407
1404
  const e = this.peek().kind;
1408
- return e === u.RBRACE || e === u.RBRACKET || e === u.RPAREN || e === u.COMMA || e === u.COLON;
1405
+ return e === c.RBRACE || e === c.RBRACKET || e === c.RPAREN || e === c.COMMA || e === c.COLON;
1409
1406
  }
1410
1407
  normalExpression() {
1411
1408
  return this.expression_bp(0);
@@ -1415,7 +1412,7 @@ class un {
1415
1412
  let n = this.leftExpression_bp();
1416
1413
  for (; !this.isAtEnd(); ) {
1417
1414
  const s = this.peek();
1418
- if (s.kind === u.LPAREN) {
1415
+ if (s.kind === c.LPAREN) {
1419
1416
  const { left: i } = ct(s);
1420
1417
  if (i < e || // When '(' is encountered,
1421
1418
  // consider it part of another expression if
@@ -1434,7 +1431,7 @@ class un {
1434
1431
  argumentList: r.partialNode
1435
1432
  }), new d(r.token, n, r.handlerContext)) : r;
1436
1433
  }
1437
- } else if (s.kind === u.LBRACKET) {
1434
+ } else if (s.kind === c.LBRACKET) {
1438
1435
  if (Ve(this.previous()))
1439
1436
  break;
1440
1437
  try {
@@ -1458,7 +1455,7 @@ class un {
1458
1455
  op: i
1459
1456
  });
1460
1457
  } else {
1461
- const a = fn(i);
1458
+ const a = un(i);
1462
1459
  if (a.left === null || a.left <= e)
1463
1460
  break;
1464
1461
  this.advance();
@@ -1486,7 +1483,7 @@ class un {
1486
1483
  if (rt(this.peek())) {
1487
1484
  const n = {};
1488
1485
  n.op = this.peek();
1489
- const s = dn(n.op);
1486
+ const s = fn(n.op);
1490
1487
  if (s.right === null)
1491
1488
  throw this.logError(
1492
1489
  n.op,
@@ -1522,12 +1519,12 @@ class un {
1522
1519
  // e.g { ... }
1523
1520
  extractOperand() {
1524
1521
  return this.check(
1525
- u.NUMERIC_LITERAL,
1526
- u.STRING_LITERAL,
1527
- u.COLOR_LITERAL,
1528
- u.QUOTED_STRING,
1529
- u.IDENTIFIER
1530
- ) ? 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(
1522
+ c.NUMERIC_LITERAL,
1523
+ c.STRING_LITERAL,
1524
+ c.COLOR_LITERAL,
1525
+ c.QUOTED_STRING,
1526
+ c.IDENTIFIER
1527
+ ) ? 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(
1531
1528
  this.peek(),
1532
1529
  o.UNEXPECTED_EOF,
1533
1530
  "Unexpected EOF"
@@ -1541,7 +1538,7 @@ class un {
1541
1538
  functionExpression() {
1542
1539
  const e = {};
1543
1540
  try {
1544
- this.consume("Expect a function expression", u.FUNCTION_EXPRESSION), e.value = this.previous();
1541
+ this.consume("Expect a function expression", c.FUNCTION_EXPRESSION), e.value = this.previous();
1545
1542
  } catch (n) {
1546
1543
  throw n instanceof d ? (e.value = n.partialNode, new d(
1547
1544
  n.token,
@@ -1552,39 +1549,39 @@ class un {
1552
1549
  return this.nodeFactory.create(te, e);
1553
1550
  }
1554
1551
  canBeField() {
1555
- return this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.COLON;
1552
+ return this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.COLON;
1556
1553
  }
1557
1554
  /* Parsing PrimaryExpression */
1558
1555
  primaryExpression() {
1559
1556
  if (this.match(
1560
- u.COLOR_LITERAL,
1561
- u.STRING_LITERAL,
1562
- u.NUMERIC_LITERAL
1557
+ c.COLOR_LITERAL,
1558
+ c.STRING_LITERAL,
1559
+ c.NUMERIC_LITERAL
1563
1560
  ))
1564
1561
  return this.nodeFactory.create(D, {
1565
1562
  expression: this.nodeFactory.create(me, { literal: this.previous() })
1566
1563
  });
1567
- if (this.match(u.QUOTED_STRING, u.IDENTIFIER))
1564
+ if (this.match(c.QUOTED_STRING, c.IDENTIFIER))
1568
1565
  return this.nodeFactory.create(D, {
1569
- expression: this.nodeFactory.create(j, { variable: this.previous() })
1566
+ expression: this.nodeFactory.create($, { variable: this.previous() })
1570
1567
  });
1571
1568
  throw this.logError(this.peek(), o.UNEXPECTED_TOKEN, "Expect a variable or literal"), new d(
1572
1569
  this.peek(),
1573
1570
  this.nodeFactory.create(D, {
1574
- expression: this.nodeFactory.create(j, {})
1571
+ expression: this.nodeFactory.create($, {})
1575
1572
  }),
1576
1573
  this.contextStack.findHandlerContext(this.tokens, this.current)
1577
1574
  );
1578
1575
  }
1579
1576
  attribute() {
1580
1577
  const e = {};
1581
- if (this.check(u.COLON, u.RBRACKET, u.COMMA)) {
1578
+ if (this.check(c.COLON, c.RBRACKET, c.COMMA)) {
1582
1579
  const n = this.peek();
1583
1580
  this.logError(
1584
1581
  n,
1585
1582
  o.EMPTY_ATTRIBUTE_NAME,
1586
1583
  "Expect a non-empty attribute name"
1587
- ), e.name = this.nodeFactory.create($, { identifiers: [] });
1584
+ ), e.name = this.nodeFactory.create(C, { identifiers: [] });
1588
1585
  } else
1589
1586
  try {
1590
1587
  e.name = this.attributeName();
@@ -1599,12 +1596,12 @@ class un {
1599
1596
  );
1600
1597
  this.synchronizeAttributeName();
1601
1598
  }
1602
- return this.match(u.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1599
+ return this.match(c.COLON) && (e.colon = this.previous(), e.value = this.attributeValue()), this.nodeFactory.create(se, e);
1603
1600
  }
1604
1601
  attributeValue() {
1605
1602
  let e;
1606
1603
  try {
1607
- e = this.peek().kind === u.IDENTIFIER && this.peek(1).kind === u.IDENTIFIER ? this.attributeName() : this.normalExpression();
1604
+ e = this.peek().kind === c.IDENTIFIER && this.peek(1).kind === c.IDENTIFIER ? this.attributeName() : this.normalExpression();
1608
1605
  } catch (n) {
1609
1606
  if (!(n instanceof d) || !this.canHandle(n))
1610
1607
  throw n;
@@ -1614,25 +1611,25 @@ class un {
1614
1611
  }
1615
1612
  attributeName() {
1616
1613
  const e = [];
1617
- if (this.peek().kind !== u.IDENTIFIER)
1614
+ if (this.peek().kind !== c.IDENTIFIER)
1618
1615
  return this.primaryExpression();
1619
- for (; !this.isAtEnd() && !this.check(u.COLON, u.COMMA, u.RBRACKET); )
1616
+ for (; !this.isAtEnd() && !this.check(c.COLON, c.COMMA, c.RBRACKET); )
1620
1617
  try {
1621
- this.consume("Expect an identifier", u.IDENTIFIER), e.push(this.previous());
1618
+ this.consume("Expect an identifier", c.IDENTIFIER), e.push(this.previous());
1622
1619
  } catch (n) {
1623
1620
  throw n instanceof d ? new d(
1624
1621
  n.token,
1625
- this.nodeFactory.create($, { identifiers: e }),
1622
+ this.nodeFactory.create(C, { identifiers: e }),
1626
1623
  n.handlerContext
1627
1624
  ) : n;
1628
1625
  }
1629
- return this.nodeFactory.create($, { identifiers: e });
1626
+ return this.nodeFactory.create(C, { identifiers: e });
1630
1627
  }
1631
1628
  logError(e, n, s) {
1632
- this.errors.push(new c(n, s, e));
1629
+ this.errors.push(new u(n, s, e));
1633
1630
  }
1634
1631
  }
1635
- const hn = {
1632
+ const cn = {
1636
1633
  "+": { left: 9, right: 10 },
1637
1634
  "*": { left: 11, right: 12 },
1638
1635
  "-": { left: 9, right: 10 },
@@ -1648,10 +1645,10 @@ const hn = {
1648
1645
  "!=": { left: 4, right: 5 },
1649
1646
  ".": { left: 16, right: 17 }
1650
1647
  };
1651
- function fn(t) {
1652
- return hn[t.value] || { left: null, right: null };
1648
+ function un(t) {
1649
+ return cn[t.value] || { left: null, right: null };
1653
1650
  }
1654
- const pn = {
1651
+ const hn = {
1655
1652
  "+": { left: null, right: 15 },
1656
1653
  "-": { left: null, right: 15 },
1657
1654
  "<": { left: null, right: 15 },
@@ -1659,17 +1656,17 @@ const pn = {
1659
1656
  "<>": { left: null, right: 15 },
1660
1657
  "!": { left: null, right: 15 }
1661
1658
  };
1662
- function dn(t) {
1663
- return pn[t.value] || { left: null, right: null };
1659
+ function fn(t) {
1660
+ return hn[t.value] || { left: null, right: null };
1664
1661
  }
1665
- const En = {
1662
+ const pn = {
1666
1663
  "(": { left: 14, right: null }
1667
1664
  };
1668
1665
  function ct(t) {
1669
- return En[t.value] || { left: null, right: null };
1666
+ return pn[t.value] || { left: null, right: null };
1670
1667
  }
1671
1668
  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 || {});
1672
- function Ae(t) {
1669
+ function _e(t) {
1673
1670
  var n;
1674
1671
  const e = (n = t == null ? void 0 : t.type) == null ? void 0 : n.value.toLowerCase();
1675
1672
  switch (e) {
@@ -1680,18 +1677,18 @@ function Ae(t) {
1680
1677
  case b.Project:
1681
1678
  case b.Ref:
1682
1679
  case b.TableGroup:
1683
- return new S(e);
1680
+ return new O(e);
1684
1681
  default:
1685
1682
  return new v();
1686
1683
  }
1687
1684
  }
1688
1685
  function he(t) {
1689
1686
  if (!He(t))
1690
- return new S([t]);
1687
+ return new O([t]);
1691
1688
  const e = he(t.leftExpression).unwrap_or(void 0);
1692
- return e ? (e.push(t.rightExpression), new S(e)) : new v();
1689
+ return e ? (e.push(t.rightExpression), new O(e)) : new v();
1693
1690
  }
1694
- function C(t) {
1691
+ function j(t) {
1695
1692
  if (t === void 0)
1696
1693
  return new v();
1697
1694
  const e = he(t).unwrap_or(void 0);
@@ -1699,14 +1696,14 @@ function C(t) {
1699
1696
  return new v();
1700
1697
  const n = [];
1701
1698
  for (const s of e) {
1702
- const i = X(s).unwrap_or(void 0);
1699
+ const i = G(s).unwrap_or(void 0);
1703
1700
  if (!i)
1704
1701
  return new v();
1705
1702
  n.push(i);
1706
1703
  }
1707
- return new S(n);
1704
+ return new O(n);
1708
1705
  }
1709
- function ge(t) {
1706
+ function Le(t) {
1710
1707
  if (t === void 0)
1711
1708
  return new v();
1712
1709
  const e = he(t).unwrap_or(void 0);
@@ -1718,73 +1715,73 @@ function ge(t) {
1718
1715
  const i = e.pop();
1719
1716
  if (yt(i))
1720
1717
  s = i.elementList.map(
1721
- (r) => G(r).unwrap()
1718
+ (r) => V(r).unwrap()
1722
1719
  );
1723
1720
  else
1724
1721
  return new v();
1725
1722
  }
1726
1723
  for (const i of e) {
1727
- const r = X(i).unwrap_or(void 0);
1724
+ const r = G(i).unwrap_or(void 0);
1728
1725
  if (!r)
1729
1726
  return new v();
1730
1727
  n.push(r);
1731
1728
  }
1732
- return new S({
1729
+ return new O({
1733
1730
  variables: n,
1734
1731
  tupleElements: s
1735
1732
  });
1736
1733
  }
1737
- function X(t) {
1738
- return M(t) ? new S(t.expression.variable.value) : new v();
1734
+ function G(t) {
1735
+ return M(t) ? new O(t.expression.variable.value) : new v();
1739
1736
  }
1740
1737
  function Ge(t) {
1741
1738
  if (ut(t))
1742
- return t instanceof te ? new S({ functional: [t], nonFunctional: [] }) : new S({ functional: [], nonFunctional: [t] });
1739
+ return t instanceof te ? new O({ functional: [t], nonFunctional: [] }) : new O({ functional: [], nonFunctional: [t] });
1743
1740
  if (t instanceof Z && t.elementList.every(ut)) {
1744
1741
  const e = t.elementList.filter(
1745
1742
  (s) => s instanceof te
1746
1743
  ), n = t.elementList.filter(M);
1747
- return new S({ functional: e, nonFunctional: n });
1744
+ return new O({ functional: e, nonFunctional: n });
1748
1745
  }
1749
1746
  return new v();
1750
1747
  }
1751
- function G(t) {
1748
+ function V(t) {
1752
1749
  var n;
1753
1750
  const e = (n = t == null ? void 0 : t.expression.variable) == null ? void 0 : n.value;
1754
- return e === void 0 ? new v() : new S(e);
1751
+ return e === void 0 ? new v() : new O(e);
1755
1752
  }
1756
- function Q(t) {
1757
- return Y(t) ? t.expression instanceof j ? new S(t.expression.variable.value) : new S(t.expression.literal.value) : new v();
1753
+ function z(t) {
1754
+ return W(t) ? t.expression instanceof $ ? new O(t.expression.variable.value) : new O(t.expression.literal.value) : new v();
1758
1755
  }
1759
- function Nn(t) {
1756
+ function dn(t) {
1760
1757
  var e;
1761
- return !(t instanceof H) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : ge(t.leftExpression).and_then(() => ge(t.rightExpression)).unwrap_or(void 0) !== void 0;
1758
+ return !(t instanceof H) || !wt((e = t.op) == null ? void 0 : e.value) ? !1 : Le(t.leftExpression).and_then(() => Le(t.rightExpression)).unwrap_or(void 0) !== void 0;
1762
1759
  }
1763
- function mn(t) {
1764
- const e = ge(t.leftExpression), n = ge(t.rightExpression);
1760
+ function En(t) {
1761
+ const e = Le(t.leftExpression), n = Le(t.rightExpression);
1765
1762
  if (!e.isOk() || !n.isOk())
1766
1763
  return !1;
1767
1764
  const { tupleElements: s } = e.unwrap(), { tupleElements: i } = n.unwrap();
1768
1765
  return (s == null ? void 0 : s.length) === (i == null ? void 0 : i.length);
1769
1766
  }
1770
1767
  function ut(t) {
1771
- return t instanceof D && t.expression instanceof j || t instanceof te;
1768
+ return t instanceof D && t.expression instanceof $ || t instanceof te;
1772
1769
  }
1773
- function Tn(t, e) {
1770
+ function Nn(t, e) {
1774
1771
  var i, r, a, l;
1775
1772
  let n = e;
1776
- const s = zt(t);
1773
+ const s = jt(t);
1777
1774
  for (; n; ) {
1778
1775
  if ((r = (i = n.symbol) == null ? void 0 : i.symbolTable) != null && r.has(t))
1779
1776
  return (a = n.symbol.symbolTable) == null ? void 0 : a.get(t);
1780
- if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof F && s)
1777
+ if (((l = n.symbol) == null ? void 0 : l.declaration) instanceof X && s)
1781
1778
  return n.symbol;
1782
- if (n instanceof F)
1779
+ if (n instanceof X)
1783
1780
  return;
1784
1781
  n = n.parent;
1785
1782
  }
1786
1783
  }
1787
- class bn {
1784
+ class mn {
1788
1785
  constructor(e, n, s) {
1789
1786
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1790
1787
  }
@@ -1792,27 +1789,27 @@ class bn {
1792
1789
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1793
1790
  }
1794
1791
  validateContext() {
1795
- return this.declarationNode.parent instanceof F || Ae(this.declarationNode.parent).unwrap_or(void 0) !== b.Project ? [new c(o.INVALID_CUSTOM_CONTEXT, "A custom element can only appear in a Project", this.declarationNode)] : [];
1792
+ return this.declarationNode.parent instanceof X || _e(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)] : [];
1796
1793
  }
1797
1794
  validateName(e) {
1798
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1795
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have a name", e)] : [];
1799
1796
  }
1800
1797
  validateAlias(e) {
1801
- return e ? [new c(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1798
+ return e ? [new u(o.UNEXPECTED_NAME, "A Custom element shouldn't have an alias", e)] : [];
1802
1799
  }
1803
1800
  validateSettingList(e) {
1804
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1801
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Custom element shouldn't have a setting list", e)] : [];
1805
1802
  }
1806
1803
  validateBody(e) {
1807
1804
  if (!e)
1808
1805
  return [];
1809
1806
  if (e instanceof ne)
1810
- return [new c(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1807
+ return [new u(o.UNEXPECTED_COMPLEX_BODY, "A Custom element can only have an inline field", e)];
1811
1808
  const n = [];
1812
- return Y(e.callee) || n.push(new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", e)), e.args.length > 0 && n.push(...e.args.map((s) => new c(o.INVALID_CUSTOM_ELEMENT_VALUE, "A Custom element value can only be a string", s))), n;
1809
+ return W(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;
1813
1810
  }
1814
1811
  }
1815
- class ve {
1812
+ class Ae {
1816
1813
  constructor() {
1817
1814
  this.table = /* @__PURE__ */ new Map();
1818
1815
  }
@@ -1829,7 +1826,7 @@ class ve {
1829
1826
  return this.table.entries();
1830
1827
  }
1831
1828
  }
1832
- class In {
1829
+ class Tn {
1833
1830
  constructor(e, n, s) {
1834
1831
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1835
1832
  }
@@ -1837,55 +1834,55 @@ class In {
1837
1834
  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)];
1838
1835
  }
1839
1836
  validateContext() {
1840
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1837
+ return this.declarationNode.parent instanceof A ? [new u(o.INVALID_PROJECT_CONTEXT, "An Enum can only appear top-level", this.declarationNode)] : [];
1841
1838
  }
1842
1839
  validateName(e) {
1843
- return e ? Je(e) ? [] : [new c(o.INVALID_NAME, "An Enum name must be of the form <enum> or <schema>.<enum>", e)] : [new c(o.NAME_NOT_FOUND, "An Enum must have a name", this.declarationNode)];
1840
+ 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)];
1844
1841
  }
1845
1842
  validateAlias(e) {
1846
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1843
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
1847
1844
  }
1848
1845
  registerElement() {
1849
1846
  const e = [];
1850
- this.declarationNode.symbol = this.symbolFactory.create(Jt, { declaration: this.declarationNode, symbolTable: new ve() });
1851
- const { name: n } = this.declarationNode, s = C(n);
1847
+ this.declarationNode.symbol = this.symbolFactory.create(qt, { declaration: this.declarationNode, symbolTable: new Ae() });
1848
+ const { name: n } = this.declarationNode, s = j(n);
1852
1849
  if (s.isOk()) {
1853
1850
  const i = s.unwrap(), r = i.pop(), a = Ze(i, this.publicSymbolTable, this.symbolFactory), l = je(r);
1854
- a.has(l) && e.push(new c(o.DUPLICATE_NAME, `Enum name ${r} already exists in schema '${i.join(".") || "public"}'`, n)), a.set(l, this.declarationNode.symbol);
1851
+ 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);
1855
1852
  }
1856
1853
  return e;
1857
1854
  }
1858
1855
  validateSettingList(e) {
1859
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1856
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Enum shouldn't have a setting list", e)] : [];
1860
1857
  }
1861
1858
  validateBody(e) {
1862
1859
  if (!e)
1863
1860
  return [];
1864
- if (e instanceof w)
1861
+ if (e instanceof k)
1865
1862
  return this.validateFields([e]);
1866
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
1863
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1867
1864
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1868
1865
  }
1869
1866
  validateFields(e) {
1870
- return e.length === 0 ? [new c(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1867
+ return e.length === 0 ? [new u(o.EMPTY_ENUM, "An Enum must have at least one element", this.declarationNode)] : e.flatMap((n) => {
1871
1868
  const s = [];
1872
- n.callee && !M(n.callee) && s.push(new c(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1869
+ n.callee && !M(n.callee) && s.push(new u(o.INVALID_ENUM_ELEMENT_NAME, "An enum field must be an identifier or a quoted identifier", n.callee));
1873
1870
  const i = [...n.args];
1874
- return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new c(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1871
+ return I.last(i) instanceof P ? (s.push(...this.validateFieldSettings(I.last(i))), i.pop()) : i[0] instanceof P && (s.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && s.push(...i.map((r) => new u(o.INVALID_ENUM_ELEMENT, "An Enum must have only a field and optionally a setting list", r))), s.push(...this.registerField(n)), s;
1875
1872
  });
1876
1873
  }
1877
1874
  validateFieldSettings(e) {
1878
- const n = W(e), s = n.getErrors(), i = n.getValue();
1875
+ const n = Q(e), s = n.getErrors(), i = n.getValue();
1879
1876
  for (const r in i) {
1880
1877
  const a = i[r];
1881
1878
  switch (r) {
1882
1879
  case "note":
1883
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1884
- Y(l.value) || s.push(new c(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1880
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_ENUM_ELEMENT_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
1881
+ W(l.value) || s.push(new u(o.INVALID_ENUM_ELEMENT_SETTING, "'note' must be a string", l));
1885
1882
  });
1886
1883
  break;
1887
1884
  default:
1888
- a.forEach((l) => s.push(new c(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1885
+ a.forEach((l) => s.push(new u(o.UNKNOWN_ENUM_ELEMENT_SETTING, `Unknown enum field setting '${r}'`, l)));
1889
1886
  }
1890
1887
  }
1891
1888
  return s;
@@ -1900,14 +1897,14 @@ class In {
1900
1897
  }
1901
1898
  registerField(e) {
1902
1899
  if (e.callee && M(e.callee)) {
1903
- const n = G(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Zt, { declaration: e });
1900
+ const n = V(e.callee).unwrap(), s = Ye(n), i = this.symbolFactory.create(Ht, { declaration: e });
1904
1901
  e.symbol = i;
1905
1902
  const r = this.declarationNode.symbol.symbolTable;
1906
1903
  if (r.has(s)) {
1907
1904
  const a = r.get(s);
1908
1905
  return [
1909
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1910
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1906
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, e),
1907
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate enum field ${n}`, a.declaration)
1911
1908
  ];
1912
1909
  }
1913
1910
  r.set(s, i);
@@ -1915,7 +1912,7 @@ class In {
1915
1912
  return [];
1916
1913
  }
1917
1914
  }
1918
- class Ln {
1915
+ class bn {
1919
1916
  constructor(e, n, s) {
1920
1917
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1921
1918
  }
@@ -1923,23 +1920,23 @@ class Ln {
1923
1920
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
1924
1921
  }
1925
1922
  validateContext() {
1926
- return this.declarationNode.parent instanceof F || Ae(this.declarationNode.parent).unwrap_or(void 0) !== b.Table ? [new c(o.INVALID_NOTE_CONTEXT, "An Indexes can only appear inside a Table", this.declarationNode)] : [];
1923
+ return this.declarationNode.parent instanceof X || _e(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)] : [];
1927
1924
  }
1928
1925
  validateName(e) {
1929
- return e ? [new c(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1926
+ return e ? [new u(o.UNEXPECTED_NAME, "An Indexes shouldn't have a name", e)] : [];
1930
1927
  }
1931
1928
  validateAlias(e) {
1932
- return e ? [new c(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1929
+ return e ? [new u(o.UNEXPECTED_ALIAS, "An Indexes shouldn't have an alias", e)] : [];
1933
1930
  }
1934
1931
  validateSettingList(e) {
1935
- return e ? [new c(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1932
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "An Indexes shouldn't have a setting list", e)] : [];
1936
1933
  }
1937
1934
  validateBody(e) {
1938
1935
  if (!e)
1939
1936
  return [];
1940
- if (e instanceof w)
1941
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1942
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
1937
+ if (e instanceof k)
1938
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "An Indexes must have a complex body", e)];
1939
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
1943
1940
  return [...this.validateFields(n), ...this.validateSubElements(s)];
1944
1941
  }
1945
1942
  validateFields(e) {
@@ -1949,35 +1946,35 @@ class Ln {
1949
1946
  const s = [], i = [n.callee, ...n.args];
1950
1947
  return I.last(i) instanceof P && s.push(...this.validateFieldSetting(i.pop())), i.forEach((r) => {
1951
1948
  for (; r instanceof J; )
1952
- r.argumentList && !Ge(r.argumentList).isOk() && s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r.argumentList)), r = r.callee;
1953
- Ge(r).isOk() || s.push(new c(o.INVALID_INDEXES_FIELD, "An index field must be an identifier, a quoted identifier, a functional expression or a tuple of such", r));
1949
+ 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;
1950
+ 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));
1954
1951
  }), s;
1955
1952
  });
1956
1953
  }
1957
1954
  validateFieldSetting(e) {
1958
- const n = W(e), s = n.getErrors(), i = n.getValue();
1955
+ const n = Q(e), s = n.getErrors(), i = n.getValue();
1959
1956
  for (const r in i) {
1960
1957
  const a = i[r];
1961
1958
  switch (r) {
1962
1959
  case "note":
1963
1960
  case "name":
1964
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1965
- Y(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1961
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1962
+ W(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must be a string`, l));
1966
1963
  });
1967
1964
  break;
1968
1965
  case "unique":
1969
1966
  case "pk":
1970
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1971
- le(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1967
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
1968
+ le(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'${r}' must not have a value`, l));
1972
1969
  });
1973
1970
  break;
1974
1971
  case "type":
1975
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1976
- M(l.value) || s.push(new c(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1972
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_INDEX_SETTING, "'type' can only appear once", l))), a.forEach((l) => {
1973
+ M(l.value) || s.push(new u(o.INVALID_INDEX_SETTING_VALUE, `'type' must be "btree" or "hash"`, l));
1977
1974
  });
1978
1975
  break;
1979
1976
  default:
1980
- a.forEach((l) => s.push(new c(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1977
+ a.forEach((l) => s.push(new u(o.UNKNOWN_INDEX_SETTING, `Unknown index setting '${r}'`, l)));
1981
1978
  }
1982
1979
  }
1983
1980
  return s;
@@ -1991,7 +1988,7 @@ class Ln {
1991
1988
  });
1992
1989
  }
1993
1990
  }
1994
- class gn {
1991
+ class In {
1995
1992
  constructor(e, n, s) {
1996
1993
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
1997
1994
  }
@@ -1999,36 +1996,28 @@ class gn {
1999
1996
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2000
1997
  }
2001
1998
  validateContext() {
2002
- return !(this.declarationNode.parent instanceof F) && ![b.Table, b.Project].includes(Ae(this.declarationNode.parent).unwrap_or(void 0)) ? [new c(o.INVALID_NOTE_CONTEXT, "A Note can only appear inside a Table or a Project. Sticky note can only appear at the global scope.", this.declarationNode)] : [];
1999
+ return this.declarationNode.parent instanceof X || ![b.Table, b.Project].includes(_e(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)] : [];
2003
2000
  }
2004
2001
  validateName(e) {
2005
- if (!(this.declarationNode.parent instanceof F))
2006
- return e ? [new c(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2007
- if (!e)
2008
- return [new c(o.INVALID_NAME, "Sticky note must have a name", this.declarationNode)];
2009
- const n = C(e);
2010
- if (!n.isOk())
2011
- return [];
2012
- const i = n.unwrap().join("."), r = Yt(i);
2013
- return this.publicSymbolTable.has(r) ? [new c(o.DUPLICATE_NAME, `Sticky note "${i}" has already been defined`, e)] : (this.publicSymbolTable.set(r, this.declarationNode.symbol), []);
2002
+ return e ? [new u(o.UNEXPECTED_NAME, "A Note shouldn't have a name", e)] : [];
2014
2003
  }
2015
2004
  validateAlias(e) {
2016
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2005
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2017
2006
  }
2018
2007
  validateSettingList(e) {
2019
- return e && !(this.declarationNode.parent instanceof F) ? [new c(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2008
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Note shouldn't have a setting list", e)] : [];
2020
2009
  }
2021
2010
  validateBody(e) {
2022
2011
  if (!e)
2023
2012
  return [];
2024
- if (e instanceof w)
2013
+ if (e instanceof k)
2025
2014
  return this.validateFields([e]);
2026
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2015
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2027
2016
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2028
2017
  }
2029
2018
  validateFields(e) {
2030
2019
  const n = [];
2031
- return e.length === 0 ? [new c(o.EMPTY_NOTE, "A Note must have a content", this.declarationNode)] : (e.length > 1 && e.slice(1).forEach((s) => n.push(new c(o.NOTE_CONTENT_REDEFINED, "A Note can only contain one string", s))), Y(e[0].callee) || n.push(new c(o.INVALID_NOTE, "A Note content must be a quoted string", e[0])), e[0].args.length > 0 && n.push(...e[0].args.map((s) => new c(o.INVALID_NOTE, "A Note can only contain one quoted string", s))), n);
2020
+ 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))), W(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);
2032
2021
  }
2033
2022
  validateSubElements(e) {
2034
2023
  return e.flatMap((n) => {
@@ -2039,7 +2028,7 @@ class gn {
2039
2028
  });
2040
2029
  }
2041
2030
  }
2042
- class _n {
2031
+ class Ln {
2043
2032
  constructor(e, n, s) {
2044
2033
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2045
2034
  }
@@ -2047,25 +2036,25 @@ class _n {
2047
2036
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2048
2037
  }
2049
2038
  validateContext() {
2050
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2039
+ return this.declarationNode.parent instanceof A ? [new u(o.INVALID_PROJECT_CONTEXT, "A Project can only appear top-level", this.declarationNode)] : [];
2051
2040
  }
2052
2041
  validateName(e) {
2053
- return e ? Pe(e) ? [] : [new c(o.INVALID_NAME, "A Project's name is optional or must be an identifier or a quoted identifer", e)] : [];
2042
+ 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)] : [];
2054
2043
  }
2055
2044
  validateAlias(e) {
2056
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2045
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Project shouldn't have an alias", e)] : [];
2057
2046
  }
2058
2047
  validateSettingList(e) {
2059
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2048
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Project shouldn't have a setting list", e)] : [];
2060
2049
  }
2061
2050
  validateBody(e) {
2062
2051
  if (!e)
2063
2052
  return [];
2064
- if (e instanceof w)
2065
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2066
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2053
+ if (e instanceof k)
2054
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Project's body must be a block", e)];
2055
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2067
2056
  return [
2068
- ...n.map((i) => new c(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2057
+ ...n.map((i) => new u(o.INVALID_PROJECT_FIELD, "A Project can not have inline fields", i)),
2069
2058
  ...this.validateSubElements(s)
2070
2059
  ];
2071
2060
  }
@@ -2078,7 +2067,7 @@ class _n {
2078
2067
  });
2079
2068
  }
2080
2069
  }
2081
- class An {
2070
+ class gn {
2082
2071
  constructor(e, n, s) {
2083
2072
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2084
2073
  }
@@ -2086,48 +2075,48 @@ class An {
2086
2075
  return [...this.validateContext(), ...this.validateName(this.declarationNode.name), ...this.validateAlias(this.declarationNode.alias), ...this.validateSettingList(this.declarationNode.attributeList), ...this.validateBody(this.declarationNode.body)];
2087
2076
  }
2088
2077
  validateContext() {
2089
- return this.declarationNode.parent instanceof F ? [] : [new c(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2078
+ return this.declarationNode.parent instanceof X ? [] : [new u(o.INVALID_REF_CONTEXT, "A Ref must appear top-level", this.declarationNode)];
2090
2079
  }
2091
2080
  validateName(e) {
2092
- return e ? Pe(e) ? [] : [new c(o.INVALID_NAME, "A Ref's name is optional or must be an identifier or a quoted identifer", e)] : [];
2081
+ 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)] : [];
2093
2082
  }
2094
2083
  validateAlias(e) {
2095
- return e ? [new c(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2084
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A Ref shouldn't have an alias", e)] : [];
2096
2085
  }
2097
2086
  validateSettingList(e) {
2098
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2087
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A Ref shouldn't have a setting list", e)] : [];
2099
2088
  }
2100
2089
  validateBody(e) {
2101
2090
  if (!e)
2102
2091
  return [];
2103
- if (e instanceof w)
2092
+ if (e instanceof k)
2104
2093
  return this.validateFields([e]);
2105
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2094
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2106
2095
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2107
2096
  }
2108
2097
  validateFields(e) {
2109
2098
  if (e.length === 0)
2110
- return [new c(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2099
+ return [new u(o.EMPTY_REF, "A Ref must have at least one field", this.declarationNode)];
2111
2100
  const n = [];
2112
- return e.length > 1 && n.push(...e.slice(1).map((s) => new c(o.REF_REDEFINED, "A Ref can only contain one binary relationship", s))), e.forEach((s) => {
2113
- s.callee && !Nn(s.callee) && n.push(new c(o.INVALID_REF_FIELD, "A Ref field must be a binary relationship", s.callee)), s.callee && !mn(s.callee) && n.push(new c(o.UNEQUAL_FIELDS_BINARY_REF, "Unequal fields in ref endpoints", s.callee));
2101
+ 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) => {
2102
+ 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));
2114
2103
  const i = [...s.args];
2115
- I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new c(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2104
+ I.last(i) instanceof P ? (this.validateFieldSettings(I.last(i)), i.pop()) : i[0] instanceof P && (n.push(...this.validateFieldSettings(i[0])), i.shift()), i.length > 0 && n.push(...i.map((r) => new u(o.INVALID_REF_FIELD, "A Ref field should only have a single binary relationship", r)));
2116
2105
  }), n;
2117
2106
  }
2118
2107
  validateFieldSettings(e) {
2119
- const n = W(e), s = n.getErrors(), i = n.getValue();
2108
+ const n = Q(e), s = n.getErrors(), i = n.getValue();
2120
2109
  for (const r in i) {
2121
2110
  const a = i[r];
2122
2111
  switch (r) {
2123
2112
  case "delete":
2124
2113
  case "update":
2125
- a.length > 1 && a.forEach((l) => s.push(new c(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2126
- vn(l.value) || s.push(new c(o.INVALID_REF_SETTING_VALUE, `'${r}' can only have values "cascade", "no action", "set null", "set default" or "restrict"`, l));
2114
+ a.length > 1 && a.forEach((l) => s.push(new u(o.DUPLICATE_REF_SETTING, `'${r}' can only appear once`, l))), a.forEach((l) => {
2115
+ _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));
2127
2116
  });
2128
2117
  break;
2129
2118
  default:
2130
- a.forEach((l) => s.push(new c(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2119
+ a.forEach((l) => s.push(new u(o.UNKNOWN_REF_SETTING, `Unknown ref setting '${r}'`, l)));
2131
2120
  }
2132
2121
  }
2133
2122
  return s;
@@ -2141,11 +2130,11 @@ class An {
2141
2130
  });
2142
2131
  }
2143
2132
  }
2144
- function vn(t) {
2145
- if (!(M(t) && t.expression.variable.kind !== u.QUOTED_STRING) && !(t instanceof $))
2133
+ function _n(t) {
2134
+ if (!(M(t) && t.expression.variable.kind !== c.QUOTED_STRING) && !(t instanceof C))
2146
2135
  return !1;
2147
2136
  let e;
2148
- if (t instanceof $ ? e = Ne(t).unwrap_or("") : e = t.expression.variable.value, e)
2137
+ if (t instanceof C ? e = Ne(t).unwrap_or("") : e = t.expression.variable.value, e)
2149
2138
  switch (e.toLowerCase()) {
2150
2139
  case "cascade":
2151
2140
  case "no action":
@@ -2158,7 +2147,7 @@ function vn(t) {
2158
2147
  }
2159
2148
  return !1;
2160
2149
  }
2161
- class wn {
2150
+ class An {
2162
2151
  constructor(e, n, s) {
2163
2152
  this.declarationNode = e, this.symbolFactory = s, this.publicSymbolTable = n;
2164
2153
  }
@@ -2166,77 +2155,77 @@ class wn {
2166
2155
  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)];
2167
2156
  }
2168
2157
  validateContext() {
2169
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2158
+ return this.declarationNode.parent instanceof A ? [new u(o.INVALID_TABLE_CONTEXT, "Table must appear top-level", this.declarationNode)] : [];
2170
2159
  }
2171
2160
  validateName(e) {
2172
- return e ? e instanceof ce ? [new c(o.INVALID_NAME, "Invalid array as Table name, maybe you forget to add a space between the name and the setting list?", e)] : Je(e) ? [] : [new c(o.INVALID_NAME, "A Table name must be of the form <table> or <schema>.<table>", e)] : [new c(o.NAME_NOT_FOUND, "A Table must have a name", this.declarationNode)];
2161
+ return e ? e instanceof ce ? [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)];
2173
2162
  }
2174
2163
  validateAlias(e) {
2175
- return e ? Sn(e) ? [] : [new c(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2164
+ return e ? kn(e) ? [] : [new u(o.INVALID_ALIAS, "Table aliases can only contains alphanumeric and underscore unless surrounded by double quotes", e)] : [];
2176
2165
  }
2177
2166
  validateSettingList(e) {
2178
- const n = W(e), s = n.getErrors(), i = n.getValue();
2167
+ const n = Q(e), s = n.getErrors(), i = n.getValue();
2179
2168
  for (const r in i) {
2180
2169
  const a = i[r];
2181
2170
  switch (r) {
2182
2171
  case "headercolor":
2183
- a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2184
- On(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2172
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'headercolor' can only appear once", l))), a.forEach((l) => {
2173
+ xn(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'headercolor' must be a color literal", l.value || l.name));
2185
2174
  });
2186
2175
  break;
2187
2176
  case "note":
2188
- a.length > 1 && s.push(...a.map((l) => new c(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2189
- Y(l.value) || s.push(new c(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2177
+ a.length > 1 && s.push(...a.map((l) => new u(o.DUPLICATE_TABLE_SETTING, "'note' can only appear once", l))), a.forEach((l) => {
2178
+ W(l.value) || s.push(new u(o.INVALID_TABLE_SETTING, "'note' must be a string literal", l.value || l.name));
2190
2179
  });
2191
2180
  break;
2192
2181
  default:
2193
- s.push(...a.map((l) => new c(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2182
+ s.push(...a.map((l) => new u(o.INVALID_TABLE_SETTING, `Unknown '${r}' setting`, l)));
2194
2183
  }
2195
2184
  }
2196
2185
  return s;
2197
2186
  }
2198
2187
  registerElement() {
2199
2188
  const e = [];
2200
- this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new ve() });
2201
- const { name: n, alias: s } = this.declarationNode, i = C(n);
2189
+ this.declarationNode.symbol = this.symbolFactory.create(_t, { declaration: this.declarationNode, symbolTable: new Ae() });
2190
+ const { name: n, alias: s } = this.declarationNode, i = j(n);
2202
2191
  if (i.isOk()) {
2203
2192
  const r = [...i.unwrap()], a = r.pop(), l = Ze(r, this.publicSymbolTable, this.symbolFactory), p = xe(a);
2204
- l.has(p) && e.push(new c(o.DUPLICATE_NAME, `Table name '${a}' already exists in schema '${r.join(".") || "public"}'`, n)), l.set(p, this.declarationNode.symbol);
2193
+ 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);
2205
2194
  }
2206
- if (s && Pe(s) && !kn(s.expression.variable.value, i.unwrap_or([]))) {
2207
- const r = G(s).unwrap(), a = xe(r);
2208
- this.publicSymbolTable.has(a) && e.push(new c(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2195
+ if (s && Pe(s) && !wn(s.expression.variable.value, i.unwrap_or([]))) {
2196
+ const r = V(s).unwrap(), a = xe(r);
2197
+ this.publicSymbolTable.has(a) && e.push(new u(o.DUPLICATE_NAME, `Table name '${r}' already exists`, n)), this.publicSymbolTable.set(a, this.declarationNode.symbol);
2209
2198
  }
2210
2199
  return e;
2211
2200
  }
2212
2201
  validateBody(e) {
2213
2202
  if (!e)
2214
2203
  return [];
2215
- if (e instanceof w)
2216
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2217
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2204
+ if (e instanceof k)
2205
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A Table's body must be a block", e)];
2206
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2218
2207
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2219
2208
  }
2220
2209
  validateFields(e) {
2221
- return e.length === 0 ? [new c(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2210
+ return e.length === 0 ? [new u(o.EMPTY_TABLE, "A Table must have at least one column", this.declarationNode)] : e.flatMap((n) => {
2222
2211
  if (!n.callee)
2223
2212
  return [];
2224
2213
  const s = [];
2225
- n.args.length === 0 && s.push(new c(o.INVALID_COLUMN, "A column must have a type", n.callee)), M(n.callee) || s.push(new c(o.INVALID_COLUMN_NAME, "A column name must be an identifier or a quoted identifier", n.callee)), n.args[0] && !yn(n.args[0]) && s.push(new c(o.INVALID_COLUMN_TYPE, "Invalid column type", n.args[0]));
2214
+ 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]));
2226
2215
  const i = n.args.slice(1);
2227
2216
  return s.push(...this.validateFieldSetting(i)), s.push(...this.registerField(n)), s;
2228
2217
  });
2229
2218
  }
2230
2219
  registerField(e) {
2231
2220
  if (e.callee && M(e.callee)) {
2232
- const n = G(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Kt, { declaration: e });
2221
+ const n = V(e.callee).unwrap(), s = We(n), i = this.symbolFactory.create(Jt, { declaration: e });
2233
2222
  e.symbol = i;
2234
2223
  const r = this.declarationNode.symbol.symbolTable;
2235
2224
  if (r.has(s)) {
2236
2225
  const a = r.get(s);
2237
2226
  return [
2238
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2239
- new c(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2227
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, e),
2228
+ new u(o.DUPLICATE_COLUMN_NAME, `Duplicate column ${n}`, a.declaration)
2240
2229
  ];
2241
2230
  }
2242
2231
  r.set(s, i);
@@ -2246,74 +2235,74 @@ class wn {
2246
2235
  // This is needed to support legacy inline settings
2247
2236
  validateFieldSetting(e) {
2248
2237
  if (!e.slice(0, -1).every(Ee) || !e.slice(-1).every((p) => Ee(p) || p instanceof P))
2249
- return [...e.map((p) => new c(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2238
+ return [...e.map((p) => new u(o.INVALID_COLUMN, "These fields must be some inline settings optionally ended with a setting list", p))];
2250
2239
  if (e.length === 0)
2251
2240
  return [];
2252
2241
  let n;
2253
2242
  I.last(e) instanceof P && (n = e.pop());
2254
- const s = W(n), i = s.getErrors(), r = s.getValue();
2243
+ const s = Q(n), i = s.getErrors(), r = s.getValue();
2255
2244
  for (const p of e) {
2256
- const h = G(p).unwrap_or("").toLowerCase();
2245
+ const h = V(p).unwrap_or("").toLowerCase();
2257
2246
  if (h !== "pk" && h !== "unique") {
2258
- i.push(new c(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2247
+ i.push(new u(o.INVALID_SETTINGS, "Inline column settings can only be `pk` or `unique`", p));
2259
2248
  continue;
2260
2249
  }
2261
2250
  r[h] === void 0 ? r[h] = [p] : r[h].push(p);
2262
2251
  }
2263
2252
  const a = r.pk || [], l = r["primary key"] || [];
2264
- a.length >= 1 && l.length >= 1 && i.push(...[...a, ...l].map((p) => new c(o.DUPLICATE_COLUMN_SETTING, "Either one of 'primary key' and 'pk' can appear", p)));
2253
+ 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)));
2265
2254
  for (const p in r) {
2266
2255
  const h = r[p];
2267
2256
  switch (p) {
2268
2257
  case "note":
2269
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2270
- Y(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2258
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "note can only appear once", f))), h.forEach((f) => {
2259
+ W(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'note' must be a quoted string", f.value || f.name));
2271
2260
  });
2272
2261
  break;
2273
2262
  case "ref":
2274
2263
  h.forEach((f) => {
2275
- Dn(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2264
+ Sn(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'ref' must be a valid unary relationship", f.value || f.name));
2276
2265
  });
2277
2266
  break;
2278
2267
  case "primary key":
2279
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2280
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2268
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "primary key can only appear once", f))), h.forEach((f) => {
2269
+ le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'primary key' must not have a value", f.value || f.name));
2281
2270
  });
2282
2271
  break;
2283
2272
  case "pk":
2284
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2285
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2273
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'pk' can only appear once", f))), h.forEach((f) => {
2274
+ f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'pk' must not have a value", f.value || f.name));
2286
2275
  });
2287
2276
  break;
2288
2277
  case "not null":
2289
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2278
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'not null' can only appear once", f)));
2290
2279
  const T = r.null || [];
2291
- h.length >= 1 && T.length >= 1 && i.push(...[...h, ...T].map((f) => new c(o.CONFLICTING_SETTING, "'not null' and 'null' can not be set at the same time", f))), h.forEach((f) => {
2292
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2280
+ 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) => {
2281
+ le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'not null' must not have a value", f.value || f.name));
2293
2282
  });
2294
2283
  break;
2295
2284
  case "null":
2296
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2297
- le(f.value) || i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2285
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'null' can only appear once", f))), h.forEach((f) => {
2286
+ le(f.value) || i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'null' must not have a value", f.value || f.name));
2298
2287
  });
2299
2288
  break;
2300
2289
  case "unique":
2301
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2302
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2290
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'unique' can only appear once", f))), h.forEach((f) => {
2291
+ f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'unique' must not have a value", f.value || f.name));
2303
2292
  });
2304
2293
  break;
2305
2294
  case "increment":
2306
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2307
- f instanceof se && !le(f.value) && i.push(new c(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2295
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_COLUMN_SETTING, "'increment' can only appear once", f))), h.forEach((f) => {
2296
+ f instanceof se && !le(f.value) && i.push(new u(o.INVALID_COLUMN_SETTING_VALUE, "'increment' must not have a value", f.value || f.name));
2308
2297
  });
2309
2298
  break;
2310
2299
  case "default":
2311
- h.length > 1 && i.push(...h.map((f) => new c(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2312
- Rn(f.value) || i.push(new c(o.INVALID_TABLE_SETTING, "'default' must be a string literal, number literal, function expression, true, false or null", f.value || f.name));
2300
+ h.length > 1 && i.push(...h.map((f) => new u(o.DUPLICATE_TABLE_SETTING, "'default' can only appear once", f))), h.forEach((f) => {
2301
+ On(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));
2313
2302
  });
2314
2303
  break;
2315
2304
  default:
2316
- h.forEach((f) => i.push(new c(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2305
+ h.forEach((f) => i.push(new u(o.UNKNOWN_COLUMN_SETTING, `Unknown column setting '${p}'`, f)));
2317
2306
  }
2318
2307
  }
2319
2308
  return i;
@@ -2328,14 +2317,14 @@ class wn {
2328
2317
  var r;
2329
2318
  return ((r = i.type) == null ? void 0 : r.value.toLowerCase()) === "note";
2330
2319
  });
2331
- return s.length > 1 && (n.push(...s.map((i) => new c(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2320
+ return s.length > 1 && (n.push(...s.map((i) => new u(o.NOTE_REDEFINED, "Duplicate notes are defined", i))), n.push()), n;
2332
2321
  }
2333
2322
  }
2334
- function yn(t) {
2323
+ function vn(t) {
2335
2324
  if (!(t instanceof J || He(t) || t instanceof D || t instanceof ce))
2336
2325
  return !1;
2337
2326
  if (t instanceof J) {
2338
- if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || Y(n) || Ee(n)))
2327
+ if (t.callee === void 0 || t.argumentList === void 0 || !t.argumentList.elementList.every((n) => ue(n) || W(n) || Ee(n)))
2339
2328
  return !1;
2340
2329
  t = t.callee;
2341
2330
  }
@@ -2344,13 +2333,13 @@ function yn(t) {
2344
2333
  return !1;
2345
2334
  t = t.array;
2346
2335
  }
2347
- const e = C(t).unwrap_or(void 0);
2336
+ const e = j(t).unwrap_or(void 0);
2348
2337
  return e !== void 0 && e.length > 0;
2349
2338
  }
2350
- function kn(t, e) {
2339
+ function wn(t, e) {
2351
2340
  return e.length === 1 && t === e[0];
2352
2341
  }
2353
- class xn {
2342
+ class yn {
2354
2343
  constructor(e, n, s) {
2355
2344
  this.declarationNode = e, this.publicSymbolTable = n, this.symbolFactory = s;
2356
2345
  }
@@ -2358,41 +2347,41 @@ class xn {
2358
2347
  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)];
2359
2348
  }
2360
2349
  validateContext() {
2361
- return this.declarationNode.parent instanceof A ? [new c(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2350
+ return this.declarationNode.parent instanceof A ? [new u(o.INVALID_TABLEGROUP_CONTEXT, "TableGroup must appear top-level", this.declarationNode)] : [];
2362
2351
  }
2363
2352
  validateName(e) {
2364
- return e ? Je(e) ? [] : [new c(o.INVALID_NAME, "A TableGroup name must be of the form <tablegroup> or <schema>.<tablegroup>", e)] : [new c(o.NAME_NOT_FOUND, "A TableGroup must have a name", this.declarationNode)];
2353
+ 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)];
2365
2354
  }
2366
2355
  validateAlias(e) {
2367
- return e ? [new c(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2356
+ return e ? [new u(o.UNEXPECTED_ALIAS, "A TableGroup shouldn't have an alias", e)] : [];
2368
2357
  }
2369
2358
  registerElement() {
2370
2359
  const { name: e } = this.declarationNode;
2371
- this.declarationNode.symbol = this.symbolFactory.create(en, { declaration: this.declarationNode, symbolTable: new ve() });
2372
- const n = C(e);
2360
+ this.declarationNode.symbol = this.symbolFactory.create(Zt, { declaration: this.declarationNode, symbolTable: new Ae() });
2361
+ const n = j(e);
2373
2362
  if (n.isOk()) {
2374
2363
  const s = n.unwrap(), i = s.pop(), r = Ze(s, this.publicSymbolTable, this.symbolFactory), a = ze(i);
2375
2364
  if (r.has(a))
2376
- return [new c(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2365
+ return [new u(o.DUPLICATE_NAME, `TableGroup name '${i}' already exists in schema '${s.join(".") || "public"}'`, e)];
2377
2366
  r.set(a, this.declarationNode.symbol);
2378
2367
  }
2379
2368
  return [];
2380
2369
  }
2381
2370
  validateSettingList(e) {
2382
- return e ? [new c(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2371
+ return e ? [new u(o.UNEXPECTED_SETTINGS, "A TableGroup shouldn't have a setting list", e)] : [];
2383
2372
  }
2384
2373
  validateBody(e) {
2385
2374
  if (!e)
2386
2375
  return [];
2387
- if (e instanceof w)
2388
- return [new c(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2389
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2376
+ if (e instanceof k)
2377
+ return [new u(o.UNEXPECTED_SIMPLE_BODY, "A TableGroup's body must be a block", e)];
2378
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2390
2379
  return [...this.validateFields(n), ...this.validateSubElements(s)];
2391
2380
  }
2392
2381
  validateFields(e) {
2393
2382
  return e.flatMap((n) => {
2394
2383
  const s = [];
2395
- return n.callee && !C(n.callee).isOk() && s.push(new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field must be of the form <table> or <schema>.<table>", n.callee)), this.registerField(n), n.args.length > 0 && s.push(...n.args.map((i) => new c(o.INVALID_TABLEGROUP_FIELD, "A TableGroup field should only have a single Table name", i))), s;
2384
+ return n.callee && !j(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;
2396
2385
  });
2397
2386
  }
2398
2387
  validateSubElements(e) {
@@ -2405,14 +2394,14 @@ class xn {
2405
2394
  }
2406
2395
  registerField(e) {
2407
2396
  if (e.callee && M(e.callee)) {
2408
- const n = G(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(tn, { declaration: e });
2397
+ const n = V(e.callee).unwrap(), s = Qe(n), i = this.symbolFactory.create(Kt, { declaration: e });
2409
2398
  e.symbol = i;
2410
2399
  const r = this.declarationNode.symbol.symbolTable;
2411
2400
  if (r.has(s)) {
2412
2401
  const a = r.get(s);
2413
2402
  return [
2414
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2415
- new c(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2403
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, e),
2404
+ new u(o.DUPLICATE_TABLEGROUP_FIELD_NAME, `${n} already exists in the group`, a.declaration)
2416
2405
  ];
2417
2406
  }
2418
2407
  r.set(s, i);
@@ -2424,31 +2413,31 @@ const vt = ["-", "+"];
2424
2413
  function re(t) {
2425
2414
  switch (t.type.value.toLowerCase()) {
2426
2415
  case b.Enum:
2427
- return In;
2416
+ return Tn;
2428
2417
  case b.Table:
2429
- return wn;
2418
+ return An;
2430
2419
  case b.TableGroup:
2431
- return xn;
2420
+ return yn;
2432
2421
  case b.Project:
2433
- return _n;
2422
+ return Ln;
2434
2423
  case b.Ref:
2435
- return An;
2436
- case b.Note:
2437
2424
  return gn;
2425
+ case b.Note:
2426
+ return In;
2438
2427
  case b.Indexes:
2439
- return Ln;
2440
- default:
2441
2428
  return bn;
2429
+ default:
2430
+ return mn;
2442
2431
  }
2443
2432
  }
2444
2433
  function Je(t) {
2445
- return !!C(t).unwrap_or(!1);
2434
+ return !!j(t).unwrap_or(!1);
2446
2435
  }
2447
- function Sn(t) {
2436
+ function kn(t) {
2448
2437
  return Pe(t);
2449
2438
  }
2450
2439
  function Pe(t) {
2451
- return t instanceof D && t.expression instanceof j;
2440
+ return t instanceof D && t.expression instanceof $;
2452
2441
  }
2453
2442
  function Ze(t, e, n) {
2454
2443
  var i;
@@ -2461,7 +2450,7 @@ function Ze(t, e, n) {
2461
2450
  if (a = (i = s.get(l)) == null ? void 0 : i.symbolTable, !a)
2462
2451
  throw new Error("Expect a symbol table in a schema symbol");
2463
2452
  } else {
2464
- a = new ve();
2453
+ a = new Ae();
2465
2454
  const p = n.create(gt, { symbolTable: a });
2466
2455
  s.set(l, p);
2467
2456
  }
@@ -2472,60 +2461,60 @@ function Ze(t, e, n) {
2472
2461
  function wt(t) {
2473
2462
  return t === "-" || t === "<>" || t === ">" || t === "<";
2474
2463
  }
2475
- function On(t) {
2464
+ function xn(t) {
2476
2465
  var n;
2477
- if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== u.COLOR_LITERAL)
2466
+ if (!(t instanceof D) || !(t.expression instanceof me) || ((n = t.expression.literal) == null ? void 0 : n.kind) !== c.COLOR_LITERAL)
2478
2467
  return !1;
2479
2468
  const e = t.expression.literal.value;
2480
2469
  if (e.length !== 4 && e.length !== 7 || e[0] !== "#")
2481
2470
  return !1;
2482
2471
  for (let s = 1; s < e.length; s += 1)
2483
- if (!qt(e[s]))
2472
+ if (!zt(e[s]))
2484
2473
  return !1;
2485
2474
  return !0;
2486
2475
  }
2487
2476
  function le(t) {
2488
2477
  return t === void 0;
2489
2478
  }
2490
- function Rn(t) {
2479
+ function On(t) {
2491
2480
  var e;
2492
- return !!(Y(t) || ue(t) || Ee(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
2481
+ return !!(W(t) || ue(t) || Ee(t) && ["true", "false", "null"].includes(t.expression.variable.value.toLowerCase()) || t instanceof q && vt.includes((e = t.op) == null ? void 0 : e.value) && ue(t.expression) || t instanceof te);
2493
2482
  }
2494
2483
  function ue(t) {
2495
2484
  var e;
2496
- return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === u.NUMERIC_LITERAL;
2485
+ return t instanceof D && t.expression instanceof me && ((e = t.expression.literal) == null ? void 0 : e.kind) === c.NUMERIC_LITERAL;
2497
2486
  }
2498
- function Dn(t) {
2487
+ function Sn(t) {
2499
2488
  var n;
2500
2489
  if (!(t instanceof q) || !wt((n = t.op) == null ? void 0 : n.value))
2501
2490
  return !1;
2502
- const e = C(t.expression).unwrap_or(void 0);
2491
+ const e = j(t.expression).unwrap_or(void 0);
2503
2492
  return e !== void 0 && e.length > 0;
2504
2493
  }
2505
2494
  function yt(t) {
2506
2495
  return t instanceof Z && t.elementList.every(M);
2507
2496
  }
2508
- function W(t) {
2497
+ function Q(t) {
2509
2498
  var s;
2510
2499
  const e = {}, n = [];
2511
2500
  if (!t)
2512
- return new B({});
2501
+ return new F({});
2513
2502
  for (const i of t.elementList) {
2514
2503
  if (!i.name)
2515
2504
  continue;
2516
2505
  if (i.name instanceof D) {
2517
- n.push(new c(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2506
+ n.push(new u(o.INVALID_SETTINGS, "A setting name must be a stream of identifiers", i.name));
2518
2507
  continue;
2519
2508
  }
2520
2509
  const r = (s = Ne(i.name).unwrap_or(void 0)) == null ? void 0 : s.toLowerCase();
2521
2510
  r && (e[r] === void 0 ? e[r] = [i] : e[r].push(i));
2522
2511
  }
2523
- return new B(e, n);
2512
+ return new F(e, n);
2524
2513
  }
2525
2514
  class ht {
2526
2515
  constructor(e, n) {
2527
2516
  this.ast = e, this.symbolFactory = n, this.publicSchemaSymbol = this.symbolFactory.create(gt, {
2528
- symbolTable: new ve()
2517
+ symbolTable: new Ae()
2529
2518
  }), this.ast.symbol = this.publicSchemaSymbol, this.ast.symbol.declaration = this.ast;
2530
2519
  }
2531
2520
  validate() {
@@ -2540,8 +2529,8 @@ class ht {
2540
2529
  );
2541
2530
  e.push(...r.validate());
2542
2531
  });
2543
- const n = this.ast.body.filter((s) => Ae(s).unwrap_or(void 0) === b.Project);
2544
- return n.length > 1 && n.forEach((s) => e.push(new c(o.PROJECT_REDEFINED, "Only one project can exist", s))), new B(this.ast, e);
2532
+ const n = this.ast.body.filter((s) => _e(s).unwrap_or(void 0) === b.Project);
2533
+ 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);
2545
2534
  }
2546
2535
  }
2547
2536
  class ae {
@@ -2592,7 +2581,7 @@ class ae {
2592
2581
  var s, i;
2593
2582
  if (e)
2594
2583
  if (e instanceof D) {
2595
- if (e.expression instanceof j && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2584
+ if (e.expression instanceof $ && ((i = n.keywords) != null && i.includes((s = e.expression.variable) == null ? void 0 : s.value.toLowerCase())))
2596
2585
  return;
2597
2586
  this.bindFragments([e], n);
2598
2587
  } else
@@ -2612,14 +2601,14 @@ class ae {
2612
2601
  return;
2613
2602
  const T = [];
2614
2603
  for (; s.length && h.length; ) {
2615
- const f = s.pop(), N = h.pop(), g = G(N).unwrap();
2604
+ const f = s.pop(), N = h.pop(), g = V(N).unwrap();
2616
2605
  T.unshift({
2617
2606
  index: Fe(g, f),
2618
2607
  referrer: N
2619
2608
  });
2620
2609
  }
2621
2610
  for (; h.length; ) {
2622
- const f = h.pop(), N = G(f).unwrap();
2611
+ const f = h.pop(), N = V(f).unwrap();
2623
2612
  T.unshift({
2624
2613
  index: Fe(N, i),
2625
2614
  referrer: f
@@ -2631,7 +2620,7 @@ class ae {
2631
2620
  ...T,
2632
2621
  {
2633
2622
  index: Fe(
2634
- G(f).unwrap(),
2623
+ V(f).unwrap(),
2635
2624
  p
2636
2625
  ),
2637
2626
  referrer: f
@@ -2646,7 +2635,7 @@ class ae {
2646
2635
  resolveIndexStack(e, n) {
2647
2636
  if (e.length === 0)
2648
2637
  throw new Error("Unreachable - An unresolved name must have at least one name component");
2649
- const [s, ...i] = e, r = Tn(s.index, this.declarationNode);
2638
+ const [s, ...i] = e, r = Nn(s.index, this.declarationNode);
2650
2639
  if (r === void 0) {
2651
2640
  const { kind: h, name: T } = ie(s.index).unwrap();
2652
2641
  this.logError(s.referrer, `Can not find ${h} '${T}'`, n);
@@ -2670,10 +2659,10 @@ class ae {
2670
2659
  }
2671
2660
  }
2672
2661
  logError(e, n, s) {
2673
- s || this.errors.push(new c(o.BINDING_ERROR, n, e));
2662
+ s || this.errors.push(new u(o.BINDING_ERROR, n, e));
2674
2663
  }
2675
2664
  }
2676
- class Pn extends ae {
2665
+ class Rn extends ae {
2677
2666
  constructor() {
2678
2667
  super(...arguments), this.subfield = {
2679
2668
  arg: {
@@ -2683,7 +2672,7 @@ class Pn extends ae {
2683
2672
  }, this.settingList = {};
2684
2673
  }
2685
2674
  }
2686
- class Un extends ae {
2675
+ class Dn extends ae {
2687
2676
  constructor() {
2688
2677
  super(...arguments), this.subfield = {
2689
2678
  arg: {
@@ -2693,7 +2682,7 @@ class Un extends ae {
2693
2682
  }, this.settingList = {};
2694
2683
  }
2695
2684
  }
2696
- class Mn extends ae {
2685
+ class Pn extends ae {
2697
2686
  constructor() {
2698
2687
  super(...arguments), this.subfield = {
2699
2688
  arg: {
@@ -2728,7 +2717,7 @@ class Mn extends ae {
2728
2717
  }, this.settingList = {};
2729
2718
  }
2730
2719
  }
2731
- class Fn extends ae {
2720
+ class Un extends ae {
2732
2721
  constructor() {
2733
2722
  super(...arguments), this.subfield = {
2734
2723
  arg: {
@@ -2738,7 +2727,7 @@ class Fn extends ae {
2738
2727
  }, this.settingList = {};
2739
2728
  }
2740
2729
  }
2741
- class Bn extends ae {
2730
+ class Mn extends ae {
2742
2731
  constructor() {
2743
2732
  super(...arguments), this.subfield = {
2744
2733
  arg: {
@@ -2748,7 +2737,7 @@ class Bn extends ae {
2748
2737
  }, this.settingList = {};
2749
2738
  }
2750
2739
  }
2751
- class Vn extends ae {
2740
+ class Fn extends ae {
2752
2741
  constructor() {
2753
2742
  super(...arguments), this.subfield = {
2754
2743
  arg: {
@@ -2765,7 +2754,7 @@ class Vn extends ae {
2765
2754
  }, this.settingList = {};
2766
2755
  }
2767
2756
  }
2768
- class Gn extends ae {
2757
+ class Bn extends ae {
2769
2758
  constructor() {
2770
2759
  super(...arguments), this.subfield = {
2771
2760
  arg: {
@@ -2793,7 +2782,7 @@ class Gn extends ae {
2793
2782
  }, this.settingList = {};
2794
2783
  }
2795
2784
  }
2796
- class Cn extends ae {
2785
+ class Vn extends ae {
2797
2786
  constructor() {
2798
2787
  super(...arguments), this.subfield = {
2799
2788
  arg: {
@@ -2813,24 +2802,24 @@ class Cn extends ae {
2813
2802
  function kt(t) {
2814
2803
  switch (t.type.value.toLowerCase()) {
2815
2804
  case b.Enum:
2816
- return Un;
2805
+ return Dn;
2817
2806
  case b.Table:
2818
- return Gn;
2807
+ return Bn;
2819
2808
  case b.TableGroup:
2820
- return Cn;
2809
+ return Vn;
2821
2810
  case b.Project:
2822
- return Bn;
2811
+ return Mn;
2823
2812
  case b.Ref:
2824
- return Vn;
2825
- case b.Note:
2826
2813
  return Fn;
2814
+ case b.Note:
2815
+ return Un;
2827
2816
  case b.Indexes:
2828
- return Mn;
2829
- default:
2830
2817
  return Pn;
2818
+ default:
2819
+ return Rn;
2831
2820
  }
2832
2821
  }
2833
- class Xn {
2822
+ class Gn {
2834
2823
  constructor(e) {
2835
2824
  this.ast = e, this.errors = [];
2836
2825
  }
@@ -2840,10 +2829,10 @@ class Xn {
2840
2829
  const n = kt(e);
2841
2830
  new n(e, this.errors).bind();
2842
2831
  }
2843
- return new B(this.ast, this.errors);
2832
+ return new F(this.ast, this.errors);
2844
2833
  }
2845
2834
  }
2846
- class $n {
2835
+ class Cn {
2847
2836
  constructor(e) {
2848
2837
  this.generator = e;
2849
2838
  }
@@ -2851,21 +2840,21 @@ class $n {
2851
2840
  return new e(n, this.generator.nextId());
2852
2841
  }
2853
2842
  }
2854
- class Wn {
2843
+ class Xn {
2855
2844
  constructor(e, n) {
2856
- this.ast = e, this.symbolFactory = new $n(n);
2845
+ this.ast = e, this.symbolFactory = new Cn(n);
2857
2846
  }
2858
2847
  // Analyzing: Invoking both the validator and binder
2859
2848
  analyze() {
2860
- return new ht(this.ast, this.symbolFactory).validate().chain((n) => new Xn(n).resolve());
2849
+ return new ht(this.ast, this.symbolFactory).validate().chain((n) => new Gn(n).resolve());
2861
2850
  }
2862
2851
  // For invoking the validator only
2863
2852
  validate() {
2864
- return new ht(this.ast, this.symbolFactory).validate().chain((n) => new B(n, []));
2853
+ return new ht(this.ast, this.symbolFactory).validate().chain((n) => new F(n, []));
2865
2854
  }
2866
2855
  }
2867
2856
  function ft(t, e) {
2868
- const { variables: n, tupleElements: s } = ge(t).unwrap();
2857
+ const { variables: n, tupleElements: s } = Le(t).unwrap();
2869
2858
  return s ? n.length === 0 ? {
2870
2859
  schemaName: e.schemaName,
2871
2860
  tableName: e.name,
@@ -2912,14 +2901,14 @@ function Ce(t) {
2912
2901
  const e = (n = he(t).unwrap_or(void 0)) == null ? void 0 : n.pop();
2913
2902
  return e instanceof Z ? e.elementList.map((s) => s.referee) : [e.referee];
2914
2903
  }
2915
- function Te(t) {
2916
- const e = C(t).unwrap();
2904
+ function ve(t) {
2905
+ const e = j(t).unwrap();
2917
2906
  return {
2918
2907
  name: e.pop(),
2919
2908
  schemaName: e
2920
2909
  };
2921
2910
  }
2922
- function St(t) {
2911
+ function $n(t) {
2923
2912
  return t.expression.literal.value;
2924
2913
  }
2925
2914
  function Ot(t, e) {
@@ -2930,7 +2919,7 @@ function Ot(t, e) {
2930
2919
  const n = t.id, s = e.id;
2931
2920
  return n < s ? `${n}-${s}` : `${s}-${n}`;
2932
2921
  }
2933
- function Rt(t, e) {
2922
+ function St(t, e) {
2934
2923
  if (Array.isArray(t)) {
2935
2924
  const i = t.map(({ id: a }) => a).sort(), r = e.map(({ id: a }) => a).sort();
2936
2925
  return I.zip(i, r).every(([a, l]) => a === l);
@@ -2938,7 +2927,7 @@ function Rt(t, e) {
2938
2927
  const n = t.id, s = e.id;
2939
2928
  return n === s;
2940
2929
  }
2941
- class Dt {
2930
+ class Rt {
2942
2931
  constructor(e, n) {
2943
2932
  this.declarationNode = e, this.env = n, this.table = { name: void 0, schemaName: void 0, alias: null, fields: [], token: void 0, indexes: [] }, this.pkColumns = [];
2944
2933
  }
@@ -2962,13 +2951,13 @@ class Dt {
2962
2951
  }), this.pkColumns.forEach((n) => n.pk = !1)), e;
2963
2952
  }
2964
2953
  interpretName(e) {
2965
- const { name: n, schemaName: s } = Te(e);
2966
- return s.length > 1 ? (this.table.name = n, this.table.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.table.name = n, this.table.schemaName = s.length ? s[0] : null, []);
2954
+ const { name: n, schemaName: s } = ve(e);
2955
+ 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, []);
2967
2956
  }
2968
2957
  interpretAlias(e) {
2969
2958
  if (!e)
2970
2959
  return [];
2971
- const n = G(e).unwrap_or(null);
2960
+ const n = V(e).unwrap_or(null);
2972
2961
  return n && (this.env.aliases.push({
2973
2962
  name: n,
2974
2963
  kind: "table",
@@ -2980,16 +2969,16 @@ class Dt {
2980
2969
  }
2981
2970
  interpretSettingList(e) {
2982
2971
  var r, a, l;
2983
- const n = W(e).getValue();
2984
- this.table.headerColor = (r = n.headercolor) != null && r.length ? St((l = (a = n.headercolor) == null ? void 0 : a.at(0)) == null ? void 0 : l.value) : void 0;
2985
- const [s] = n.note || [], i = Q(s == null ? void 0 : s.value).unwrap_or(void 0);
2972
+ const n = Q(e).getValue();
2973
+ 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;
2974
+ const [s] = n.note || [], i = z(s == null ? void 0 : s.value).unwrap_or(void 0);
2986
2975
  return this.table.note = s && {
2987
2976
  value: i,
2988
2977
  token: x(s)
2989
2978
  }, [];
2990
2979
  }
2991
2980
  interpretBody(e) {
2992
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
2981
+ const [n, s] = I.partition(e.body, (i) => i instanceof k);
2993
2982
  return [...this.interpretFields(n), ...this.interpretSubElements(s)];
2994
2983
  }
2995
2984
  interpretSubElements(e) {
@@ -2998,7 +2987,7 @@ class Dt {
2998
2987
  switch ((s = n.type) == null ? void 0 : s.value.toLowerCase()) {
2999
2988
  case "note":
3000
2989
  return this.table.note = {
3001
- value: Q(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).unwrap(),
2990
+ value: z(n.body instanceof ne ? n.body.body[0].callee : n.body.callee).unwrap(),
3002
2991
  token: x(n)
3003
2992
  }, [];
3004
2993
  case "indexes":
@@ -3013,24 +3002,24 @@ class Dt {
3013
3002
  interpretColumn(e) {
3014
3003
  var a, l, p, h, T, f, N, g;
3015
3004
  const n = [], s = {};
3016
- s.name = G(e.callee).unwrap();
3017
- const i = jn(e.args[0]);
3005
+ s.name = V(e.callee).unwrap();
3006
+ const i = Wn(e.args[0]);
3018
3007
  s.type = i.getValue(), n.push(...i.getErrors()), s.token = x(e), s.inline_refs = [];
3019
3008
  const r = e.args.slice(1);
3020
3009
  if (I.last(r) instanceof P) {
3021
- const _ = W(r.pop()).getValue();
3022
- s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = Yn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3010
+ const _ = Q(r.pop()).getValue();
3011
+ s.pk = !!((a = _.pk) != null && a.length) || !!((l = _["primary key"]) != null && l.length), s.increment = !!((p = _.increment) != null && p.length), s.unique = !!((h = _.unique) != null && h.length), s.not_null = !!((T = _["not null"]) != null && T.length) && !0, s.dbdefault = jn((N = (f = _.default) == null ? void 0 : f.at(0)) == null ? void 0 : N.value);
3023
3012
  const K = (g = _.note) == null ? void 0 : g.at(0);
3024
3013
  s.note = K && {
3025
- value: Q(K.value).unwrap(),
3014
+ value: z(K.value).unwrap(),
3026
3015
  token: x(K)
3027
3016
  };
3028
- const be = _.ref || [];
3029
- s.inline_refs = be.flatMap((z) => {
3030
- const [tt] = Ce(z.value.expression);
3031
- if (Rt(tt, e.symbol))
3032
- return n.push(new c(o.SAME_ENDPOINT, "Two endpoints are the same", z)), [];
3033
- const we = z.value.op, ee = C(z.value.expression).unwrap();
3017
+ const Te = _.ref || [];
3018
+ s.inline_refs = Te.flatMap((Y) => {
3019
+ const [tt] = Ce(Y.value.expression);
3020
+ if (St(tt, e.symbol))
3021
+ return n.push(new u(o.SAME_ENDPOINT, "Two endpoints are the same", Y)), [];
3022
+ const we = Y.value.op, ee = j(Y.value.expression).unwrap();
3034
3023
  let fe;
3035
3024
  if (ee.length === 1) {
3036
3025
  const [oe] = ee;
@@ -3039,42 +3028,42 @@ class Dt {
3039
3028
  tableName: this.table.name,
3040
3029
  fieldNames: [oe],
3041
3030
  relation: we.value,
3042
- token: x(z)
3031
+ token: x(Y)
3043
3032
  };
3044
3033
  } else if (ee.length === 2) {
3045
- const [oe, Ie] = ee;
3034
+ const [oe, be] = ee;
3046
3035
  fe = {
3047
3036
  schemaName: null,
3048
3037
  tableName: oe,
3049
- fieldNames: [Ie],
3038
+ fieldNames: [be],
3050
3039
  relation: we.value,
3051
- token: x(z)
3040
+ token: x(Y)
3052
3041
  };
3053
3042
  } else if (ee.length === 3) {
3054
- const [oe, Ie, st] = ee;
3043
+ const [oe, be, st] = ee;
3055
3044
  fe = {
3056
3045
  schemaName: oe,
3057
- tableName: Ie,
3046
+ tableName: be,
3058
3047
  fieldNames: [st],
3059
3048
  relation: we.value,
3060
- token: x(z)
3049
+ token: x(Y)
3061
3050
  };
3062
3051
  } else {
3063
- n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", z));
3064
- const oe = ee.pop(), Ie = ee.pop();
3052
+ n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", Y));
3053
+ const oe = ee.pop(), be = ee.pop();
3065
3054
  fe = {
3066
3055
  schemaName: ee.join("."),
3067
- tableName: Ie,
3056
+ tableName: be,
3068
3057
  fieldNames: [oe],
3069
3058
  relation: we.value,
3070
- token: x(z)
3059
+ token: x(Y)
3071
3060
  };
3072
3061
  }
3073
- const nt = this.registerInlineRefToEnv(e, tt, fe, z);
3062
+ const nt = this.registerInlineRefToEnv(e, tt, fe, Y);
3074
3063
  return n.push(...nt), nt.length === 0 ? fe : [];
3075
3064
  });
3076
3065
  }
3077
- return s.pk || (s.pk = r.some((_) => X(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => X(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3066
+ return s.pk || (s.pk = r.some((_) => G(_).unwrap().toLowerCase() === "pk")), s.unique || (s.unique = r.some((_) => G(_).unwrap().toLowerCase() === "unique")), this.table.fields.push(s), s.pk && this.pkColumns.push(s), n;
3078
3067
  }
3079
3068
  interpretIndexes(e) {
3080
3069
  return this.table.indexes.push(...e.body.body.map((n) => {
@@ -3083,13 +3072,13 @@ class Dt {
3083
3072
  s.token = x(e);
3084
3073
  const r = [i.callee, ...i.args];
3085
3074
  if (I.last(r) instanceof P) {
3086
- const g = W(r.pop()).getValue();
3087
- s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = Q((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3075
+ const g = Q(r.pop()).getValue();
3076
+ s.pk = !!((a = g.pk) != null && a.length), s.unique = !!((l = g.unique) != null && l.length), s.name = z((h = (p = g.name) == null ? void 0 : p.at(0)) == null ? void 0 : h.value).unwrap_or(void 0);
3088
3077
  const _ = (T = g.note) == null ? void 0 : T.at(0);
3089
3078
  s.note = _ && {
3090
- value: Q(_.value).unwrap(),
3079
+ value: z(_.value).unwrap(),
3091
3080
  token: x(_)
3092
- }, s.type = X((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3081
+ }, s.type = G((N = (f = g.type) == null ? void 0 : f.at(0)) == null ? void 0 : N.value).unwrap_or(void 0);
3093
3082
  }
3094
3083
  return r.flatMap((g) => {
3095
3084
  if (!(g instanceof J))
@@ -3101,12 +3090,12 @@ class Dt {
3101
3090
  }).forEach((g) => {
3102
3091
  const { functional: _, nonFunctional: K } = Ge(g).unwrap();
3103
3092
  s.columns.push(
3104
- ..._.map((be) => ({
3105
- value: be.value.value,
3093
+ ..._.map((Te) => ({
3094
+ value: Te.value.value,
3106
3095
  type: "expression"
3107
3096
  })),
3108
- ...K.map((be) => ({
3109
- value: G(be).unwrap(),
3097
+ ...K.map((Te) => ({
3098
+ value: V(Te).unwrap(),
3110
3099
  type: "column"
3111
3100
  }))
3112
3101
  );
@@ -3117,8 +3106,8 @@ class Dt {
3117
3106
  const r = Ot(e.symbol, n);
3118
3107
  if (this.env.refIds[r])
3119
3108
  return [
3120
- new c(o.CIRCULAR_REF, "References with same endpoints exist", i),
3121
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3109
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", i),
3110
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[r])
3122
3111
  ];
3123
3112
  const a = xt(s.relation);
3124
3113
  return this.env.refIds[r] = i, this.env.ref.set(i, {
@@ -3133,7 +3122,7 @@ class Dt {
3133
3122
  {
3134
3123
  schemaName: this.table.schemaName,
3135
3124
  tableName: this.table.name,
3136
- fieldNames: [X(e.callee).unwrap()],
3125
+ fieldNames: [G(e.callee).unwrap()],
3137
3126
  token: x(e),
3138
3127
  relation: a[0]
3139
3128
  }
@@ -3141,32 +3130,32 @@ class Dt {
3141
3130
  }), [];
3142
3131
  }
3143
3132
  }
3144
- function jn(t) {
3133
+ function Wn(t) {
3145
3134
  let e = null;
3146
- t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : Y(r) ? Q(r).unwrap() : X(r).unwrap()).join(","), t = t.callee);
3135
+ t instanceof J && (e = t.argumentList.elementList.map((r) => ue(r) ? r.expression.literal.value : W(r) ? z(r).unwrap() : G(r).unwrap()).join(","), t = t.callee);
3147
3136
  let n = "";
3148
3137
  for (; t instanceof ce; )
3149
3138
  n = `[${t.indexer.elementList.map((r) => r.name.expression.literal.value).join(",")}]${n}`, t = t.array;
3150
- const { name: s, schemaName: i } = Te(t);
3151
- return i.length > 1 ? new B(
3139
+ const { name: s, schemaName: i } = ve(t);
3140
+ return i.length > 1 ? new F(
3152
3141
  {
3153
3142
  schemaName: i.length === 0 ? null : i[0],
3154
3143
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3155
3144
  args: e
3156
3145
  },
3157
- [new c(o.UNSUPPORTED, "Nested schema is not supported", t)]
3158
- ) : new B({
3146
+ [new u(o.UNSUPPORTED, "Nested schema is not supported", t)]
3147
+ ) : new F({
3159
3148
  schemaName: i.length === 0 ? null : i[0],
3160
3149
  type_name: `${s}${n}${e ? `(${e})` : ""}`,
3161
3150
  args: e
3162
3151
  });
3163
3152
  }
3164
- function Yn(t) {
3153
+ function jn(t) {
3165
3154
  var e, n, s;
3166
3155
  if (t) {
3167
- if (Y(t))
3156
+ if (W(t))
3168
3157
  return {
3169
- value: Q(t).unwrap(),
3158
+ value: z(t).unwrap(),
3170
3159
  type: "string"
3171
3160
  };
3172
3161
  if (ue(t))
@@ -3194,38 +3183,7 @@ function Yn(t) {
3194
3183
  throw new Error("Unreachable");
3195
3184
  }
3196
3185
  }
3197
- class zn {
3198
- constructor(e, n) {
3199
- this.declarationNode = e, this.env = n, this.note = { name: void 0, content: void 0, token: void 0 };
3200
- }
3201
- interpret() {
3202
- return this.note.token = x(this.declarationNode), this.env.notes.set(this.declarationNode, this.note), [
3203
- ...this.interpretName(this.declarationNode.name),
3204
- ...this.interpretSettingList(this.declarationNode.attributeList),
3205
- ...this.interpretBody(this.declarationNode.body)
3206
- ];
3207
- }
3208
- interpretName(e) {
3209
- const { name: n } = Te(e);
3210
- return this.note.name = n, [];
3211
- }
3212
- interpretSettingList(e) {
3213
- var s, i, r;
3214
- const n = W(e).getValue();
3215
- return this.note.headerColor = (s = n.headercolor) != null && s.length ? St((r = (i = n.headercolor) == null ? void 0 : i.at(0)) == null ? void 0 : r.value) : void 0, [];
3216
- }
3217
- interpretBody(e) {
3218
- const [n, s] = I.partition(e.body, (i) => i instanceof w);
3219
- return n.length !== 1 || s.length > 0 ? [
3220
- new c(o.INVALID_NOTE, "Invalid note syntax", e)
3221
- ] : [...this.interpretNote(n[0])];
3222
- }
3223
- interpretNote(e) {
3224
- const n = I.get(e, "callee.expression.literal.value", "");
3225
- return this.note.content = n, [];
3226
- }
3227
- }
3228
- class Pt {
3186
+ class Dt {
3229
3187
  constructor(e, n) {
3230
3188
  this.declarationNode = e, this.env = n, this.container = this.declarationNode.parent instanceof A ? this.env.tables.get(this.declarationNode.parent) : void 0, this.ref = {};
3231
3189
  }
@@ -3233,28 +3191,28 @@ class Pt {
3233
3191
  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)];
3234
3192
  }
3235
3193
  interpretName(e) {
3236
- const n = [], s = C(this.declarationNode.name).unwrap_or([]);
3237
- return this.ref.name = s.pop() || null, s.length > 1 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name)), this.ref.schemaName = s.join(".") || null, n;
3194
+ const n = [], s = j(this.declarationNode.name).unwrap_or([]);
3195
+ 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;
3238
3196
  }
3239
3197
  interpretBody(e) {
3240
- return e instanceof w ? this.interpretField(e) : this.interpretField(e.body[0]);
3198
+ return e instanceof k ? this.interpretField(e) : this.interpretField(e.body[0]);
3241
3199
  }
3242
3200
  interpretField(e) {
3243
3201
  var h, T, f, N;
3244
3202
  const n = e.callee.op.value, { leftExpression: s, rightExpression: i } = e.callee, r = Ce(s), a = Ce(i);
3245
- if (Rt(r, a))
3246
- return [new c(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3203
+ if (St(r, a))
3204
+ return [new u(o.SAME_ENDPOINT, "Two endpoints are the same", e)];
3247
3205
  const l = Ot(r, a);
3248
3206
  if (this.env.refIds[l])
3249
3207
  return [
3250
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3251
- new c(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3208
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.declarationNode),
3209
+ new u(o.CIRCULAR_REF, "References with same endpoints exist", this.env.refIds[l])
3252
3210
  ];
3253
3211
  if (e.args[0]) {
3254
- const g = W(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
3255
- this.ref.onDelete = _ instanceof $ ? Ne(_).unwrap_or(void 0) : X(_).unwrap_or(void 0);
3212
+ const g = Q(e.args[0]).getValue(), _ = (T = (h = g.delete) == null ? void 0 : h.at(0)) == null ? void 0 : T.value;
3213
+ this.ref.onDelete = _ instanceof C ? Ne(_).unwrap_or(void 0) : G(_).unwrap_or(void 0);
3256
3214
  const K = (N = (f = g.update) == null ? void 0 : f.at(0)) == null ? void 0 : N.value;
3257
- this.ref.onUpdate = K instanceof $ ? Ne(K).unwrap_or(void 0) : X(K).unwrap_or(void 0);
3215
+ this.ref.onUpdate = K instanceof C ? Ne(K).unwrap_or(void 0) : G(K).unwrap_or(void 0);
3258
3216
  }
3259
3217
  const p = xt(n);
3260
3218
  return this.ref.endpoints = [
@@ -3271,7 +3229,7 @@ class Pt {
3271
3229
  ], this.env.refIds[l] = this.declarationNode, [];
3272
3230
  }
3273
3231
  }
3274
- class Ut {
3232
+ class Pt {
3275
3233
  constructor(e, n) {
3276
3234
  this.declarationNode = e, this.env = n, this.tableGroup = { tables: [] };
3277
3235
  }
@@ -3283,18 +3241,18 @@ class Ut {
3283
3241
  ), e;
3284
3242
  }
3285
3243
  interpretName(e) {
3286
- const n = [], { name: s, schemaName: i } = Te(e);
3287
- return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3244
+ const n = [], { name: s, schemaName: i } = ve(e);
3245
+ return i.length >= 2 && (this.tableGroup.name = s, this.tableGroup.schemaName = i.join("."), n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", this.declarationNode.name))), this.tableGroup.name = s, this.tableGroup.schemaName = i[0] || null, n;
3288
3246
  }
3289
3247
  interpretBody(e) {
3290
3248
  const n = [];
3291
3249
  return this.tableGroup.tables = this.declarationNode.body.body.map((s) => {
3292
- const i = C(s.callee).unwrap();
3293
- i.length > 2 && n.push(new c(o.UNSUPPORTED, "Nested schema is not supported", s));
3250
+ const i = j(s.callee).unwrap();
3251
+ i.length > 2 && n.push(new u(o.UNSUPPORTED, "Nested schema is not supported", s));
3294
3252
  const r = he(s.callee).unwrap().pop().referee.id;
3295
3253
  if (this.env.groupOfTable[r]) {
3296
3254
  const a = this.env.groupOfTable[r], { schemaName: l, name: p } = this.env.tableGroups.get(a), h = l ? `${l}.${p}` : p;
3297
- n.push(new c(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
3255
+ n.push(new u(o.TABLE_REAPPEAR_IN_TABLEGROUP, `Table "${i.join(".")}" already appears in group "${h}"`, s));
3298
3256
  } else
3299
3257
  this.env.groupOfTable[r] = this.declarationNode;
3300
3258
  return {
@@ -3304,7 +3262,7 @@ class Ut {
3304
3262
  }), n;
3305
3263
  }
3306
3264
  }
3307
- class Mt {
3265
+ class Ut {
3308
3266
  constructor(e, n) {
3309
3267
  this.declarationNode = e, this.env = n, this.enum = { values: [] };
3310
3268
  }
@@ -3312,23 +3270,23 @@ class Mt {
3312
3270
  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)];
3313
3271
  }
3314
3272
  interpretName(e) {
3315
- const { name: n, schemaName: s } = Te(e);
3316
- return s.length > 1 ? (this.enum.name = n, this.enum.schemaName = s.join("."), [new c(o.UNSUPPORTED, "Nested schema is not supported", e)]) : (this.enum.name = n, this.enum.schemaName = s.length ? s[0] : null, []);
3273
+ const { name: n, schemaName: s } = ve(e);
3274
+ 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, []);
3317
3275
  }
3318
3276
  interpretBody(e) {
3319
3277
  return e.body.flatMap((n) => {
3320
3278
  var l;
3321
3279
  const s = n, i = {};
3322
- i.token = x(s), i.name = X(s.callee).unwrap();
3323
- const a = (l = W(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3280
+ i.token = x(s), i.name = G(s.callee).unwrap();
3281
+ const a = (l = Q(s.args[0]).getValue().note) == null ? void 0 : l.at(0);
3324
3282
  return i.note = a && {
3325
- value: Q(a.value).unwrap(),
3283
+ value: z(a.value).unwrap(),
3326
3284
  token: x(a)
3327
3285
  }, this.enum.values.push(i), [];
3328
3286
  });
3329
3287
  }
3330
3288
  }
3331
- class Qn {
3289
+ class Yn {
3332
3290
  constructor(e, n) {
3333
3291
  this.declarationNode = e, this.env = n, this.project = { enums: [], refs: [], tableGroups: [], tables: [] };
3334
3292
  }
@@ -3338,7 +3296,7 @@ class Qn {
3338
3296
  interpretName(e) {
3339
3297
  if (!e)
3340
3298
  return this.project.name = null, [];
3341
- const { name: n } = Te(e);
3299
+ const { name: n } = ve(e);
3342
3300
  return this.project.name = n, [];
3343
3301
  }
3344
3302
  interpretBody(e) {
@@ -3347,38 +3305,37 @@ class Qn {
3347
3305
  const s = n;
3348
3306
  switch ((i = s.type) == null ? void 0 : i.value.toLowerCase()) {
3349
3307
  case "table": {
3350
- const r = new Dt(s, this.env).interpret();
3308
+ const r = new Rt(s, this.env).interpret();
3351
3309
  return this.project.tables.push(this.env.tables.get(s)), r;
3352
3310
  }
3353
3311
  case "ref": {
3354
- const r = new Pt(s, this.env).interpret();
3312
+ const r = new Dt(s, this.env).interpret();
3355
3313
  return this.project.refs.push(this.env.ref.get(s)), r;
3356
3314
  }
3357
3315
  case "tablegroup": {
3358
- const r = new Ut(s, this.env).interpret();
3316
+ const r = new Pt(s, this.env).interpret();
3359
3317
  return this.project.tableGroups.push(this.env.tableGroups.get(s)), r;
3360
3318
  }
3361
3319
  case "enum": {
3362
- const r = new Mt(s, this.env).interpret();
3320
+ const r = new Ut(s, this.env).interpret();
3363
3321
  return this.project.enums.push(this.env.enums.get(s)), r;
3364
3322
  }
3365
3323
  case "note":
3366
3324
  return this.project.note = {
3367
- value: Q(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
3325
+ value: z(s.body instanceof ne ? s.body.body[0].callee : s.body.callee).unwrap(),
3368
3326
  token: x(s)
3369
3327
  }, [];
3370
3328
  default:
3371
- return this.project[s.type.value.toLowerCase()] = Q(s.body.callee).unwrap(), [];
3329
+ return this.project[s.type.value.toLowerCase()] = z(s.body.callee).unwrap(), [];
3372
3330
  }
3373
3331
  });
3374
3332
  }
3375
3333
  }
3376
- class qn {
3334
+ class zn {
3377
3335
  constructor(e) {
3378
3336
  this.ast = e, this.env = {
3379
3337
  schema: [],
3380
3338
  tables: /* @__PURE__ */ new Map(),
3381
- notes: /* @__PURE__ */ new Map(),
3382
3339
  refIds: {},
3383
3340
  ref: /* @__PURE__ */ new Map(),
3384
3341
  enums: /* @__PURE__ */ new Map(),
@@ -3390,31 +3347,28 @@ class qn {
3390
3347
  }
3391
3348
  interpret() {
3392
3349
  const e = this.ast.body.flatMap((n) => {
3393
- switch (Ae(n).unwrap_or(void 0)) {
3350
+ switch (_e(n).unwrap_or(void 0)) {
3394
3351
  case b.Table:
3395
- return new Dt(n, this.env).interpret();
3396
- case b.Note:
3397
- return new zn(n, this.env).interpret();
3352
+ return new Rt(n, this.env).interpret();
3398
3353
  case b.Ref:
3399
- return new Pt(n, this.env).interpret();
3354
+ return new Dt(n, this.env).interpret();
3400
3355
  case b.TableGroup:
3401
- return new Ut(n, this.env).interpret();
3356
+ return new Pt(n, this.env).interpret();
3402
3357
  case b.Enum:
3403
- return new Mt(n, this.env).interpret();
3358
+ return new Ut(n, this.env).interpret();
3404
3359
  case b.Project:
3405
- return new Qn(n, this.env).interpret();
3360
+ return new Yn(n, this.env).interpret();
3406
3361
  default:
3407
3362
  return [];
3408
3363
  }
3409
3364
  });
3410
- return new B(Hn(this.env), e);
3365
+ return new F(Qn(this.env), e);
3411
3366
  }
3412
3367
  }
3413
- function Hn(t) {
3368
+ function Qn(t) {
3414
3369
  return {
3415
3370
  schemas: [],
3416
3371
  tables: Array.from(t.tables.values()),
3417
- notes: Array.from(t.notes.values()),
3418
3372
  refs: Array.from(t.ref.values()),
3419
3373
  enums: Array.from(t.enums.values()),
3420
3374
  tableGroups: Array.from(t.tableGroups.values()),
@@ -3422,8 +3376,8 @@ function Hn(t) {
3422
3376
  project: Array.from(t.project.values())[0] || {}
3423
3377
  };
3424
3378
  }
3425
- 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 || {});
3426
- function _e(t) {
3379
+ 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 || {});
3380
+ function ge(t) {
3427
3381
  switch (t) {
3428
3382
  case m.Schema:
3429
3383
  return L.Module;
@@ -3443,18 +3397,18 @@ function _e(t) {
3443
3397
  return L.Text;
3444
3398
  }
3445
3399
  }
3446
- function Oe(t, e) {
3400
+ function Se(t, e) {
3447
3401
  if (!t || Ve(t))
3448
3402
  return !1;
3449
3403
  for (const n of t.trailingTrivia) {
3450
3404
  if (n.start > e)
3451
3405
  break;
3452
- if (n.kind === u.NEWLINE && n.end <= e)
3406
+ if (n.kind === c.NEWLINE && n.end <= e)
3453
3407
  return !1;
3454
3408
  }
3455
3409
  return !0;
3456
3410
  }
3457
- function O() {
3411
+ function S() {
3458
3412
  return {
3459
3413
  suggestions: []
3460
3414
  };
@@ -3480,7 +3434,7 @@ function Ue(t) {
3480
3434
  function Ke(t, e) {
3481
3435
  return t.getOffsetAt(e);
3482
3436
  }
3483
- class Ft {
3437
+ class Mt {
3484
3438
  constructor(e, n = []) {
3485
3439
  this.compiler = e, this.triggerCharacters = n;
3486
3440
  }
@@ -3491,12 +3445,12 @@ class Ft {
3491
3445
  ...(r == null ? void 0 : r.trailingTrivia) || [],
3492
3446
  ...(r == null ? void 0 : r.leadingTrivia) || [],
3493
3447
  ...(l == null ? void 0 : l.leadingTrivia) || []
3494
- ].find((N) => Wt(N) && Le(s, N)))
3495
- return O();
3448
+ ].find((N) => $t(N) && Ie(s, N)))
3449
+ return S();
3496
3450
  if (a === void 0)
3497
3451
  return mt();
3498
- if ([u.STRING_LITERAL, u.QUOTED_STRING].includes(r.kind) && Le(s, r))
3499
- return O();
3452
+ if ([c.STRING_LITERAL, c.QUOTED_STRING].includes(r.kind) && Ie(s, r))
3453
+ return S();
3500
3454
  const p = this.compiler.container.element(s);
3501
3455
  if (this.compiler.container.scopeKind(s) === R.TOPLEVEL || p instanceof A && p.type && p.type.start <= s && p.type.end >= s)
3502
3456
  return mt();
@@ -3526,7 +3480,7 @@ class Ft {
3526
3480
  N
3527
3481
  );
3528
3482
  case ".":
3529
- return Bt(
3483
+ return Ft(
3530
3484
  this.compiler,
3531
3485
  s,
3532
3486
  N
@@ -3538,13 +3492,13 @@ class Ft {
3538
3492
  if (N instanceof P)
3539
3493
  return dt(this.compiler, s, N);
3540
3494
  if (N instanceof Z)
3541
- return Jn(this.compiler, s);
3542
- if (N instanceof w)
3495
+ return qn(this.compiler, s);
3496
+ if (N instanceof k)
3543
3497
  return Nt(this.compiler, s, N);
3544
- if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Le(s, N.body)))
3498
+ if (N instanceof A && (N.bodyColon && s >= N.bodyColon.end || N.body && Ie(s, N.body)))
3545
3499
  return Nt(this.compiler, s, void 0);
3546
3500
  }
3547
- return O();
3501
+ return S();
3548
3502
  }
3549
3503
  }
3550
3504
  function pt(t, e, n) {
@@ -3555,14 +3509,14 @@ function pt(t, e, n) {
3555
3509
  m.Schema,
3556
3510
  m.Column
3557
3511
  ]);
3558
- return Oe(n.op, e) ? Re(i) : i;
3512
+ return Se(n.op, e) ? Re(i) : i;
3559
3513
  }
3560
- return O();
3514
+ return S();
3561
3515
  }
3562
3516
  function Me(t, e, n, s) {
3563
3517
  var a;
3564
3518
  if (n === void 0)
3565
- return O();
3519
+ return S();
3566
3520
  let i = n;
3567
3521
  const r = { suggestions: [] };
3568
3522
  for (; i; ) {
@@ -3572,9 +3526,9 @@ function Me(t, e, n, s) {
3572
3526
  ...t.symbol.members(l).filter(({ kind: p }) => s.includes(p)).map(({ name: p, kind: h }) => ({
3573
3527
  label: p,
3574
3528
  insertText: p,
3575
- insertTextRules: y.KeepWhitespace,
3576
- kind: _e(h),
3577
- sortText: _e(h).toString().padStart(2, "0"),
3529
+ insertTextRules: w.KeepWhitespace,
3530
+ kind: ge(h),
3531
+ sortText: ge(h).toString().padStart(2, "0"),
3578
3532
  range: void 0
3579
3533
  }))
3580
3534
  );
@@ -3583,51 +3537,51 @@ function Me(t, e, n, s) {
3583
3537
  }
3584
3538
  return Ue(r);
3585
3539
  }
3586
- function Jn(t, e) {
3540
+ function qn(t, e) {
3587
3541
  var s;
3588
3542
  switch (t.container.scopeKind(e)) {
3589
3543
  case R.INDEXES:
3590
- return Gt(t, e);
3544
+ return Vt(t, e);
3591
3545
  case R.REF:
3592
3546
  {
3593
3547
  const i = [...t.container.stack(e)];
3594
3548
  for (; i.length > 0; ) {
3595
3549
  const r = i.pop();
3596
3550
  if (r instanceof H && ((s = r.op) == null ? void 0 : s.value) === ".")
3597
- return Bt(
3551
+ return Ft(
3598
3552
  t,
3599
3553
  e,
3600
3554
  r
3601
3555
  );
3602
3556
  }
3603
3557
  }
3604
- return Vt(t, e);
3558
+ return Bt(t, e);
3605
3559
  }
3606
- return O();
3560
+ return S();
3607
3561
  }
3608
3562
  function dt(t, e, n) {
3609
3563
  const { token: s } = t.container.token(e);
3610
- if ([u.COMMA, u.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3564
+ if ([c.COMMA, c.LBRACKET].includes(s == null ? void 0 : s.kind)) {
3611
3565
  const i = Et(t, e);
3612
- return (s == null ? void 0 : s.kind) === u.COMMA && Oe(s, e) ? Re(i) : i;
3566
+ return (s == null ? void 0 : s.kind) === c.COMMA && Se(s, e) ? Re(i) : i;
3613
3567
  }
3614
3568
  if (n.name && n.name.start <= e && n.name.end >= e)
3615
3569
  return Et(t, e);
3616
- if (n.name instanceof $) {
3617
- const i = Zn(
3570
+ if (n.name instanceof C) {
3571
+ const i = Hn(
3618
3572
  t,
3619
3573
  e,
3620
3574
  Ne(n.name).unwrap()
3621
3575
  );
3622
- return (s == null ? void 0 : s.kind) === u.COLON && Oe(s, e) ? Re(i) : i;
3576
+ return (s == null ? void 0 : s.kind) === c.COLON && Se(s, e) ? Re(i) : i;
3623
3577
  }
3624
- return O();
3578
+ return S();
3625
3579
  }
3626
3580
  function Et(t, e) {
3627
3581
  const n = t.container.element(e), s = t.container.scopeKind(e);
3628
- if (n instanceof F)
3629
- return O();
3630
- if (n.body && !Le(e, n.body))
3582
+ if (n instanceof X)
3583
+ return S();
3584
+ if (n.body && !Ie(e, n.body))
3631
3585
  switch (s) {
3632
3586
  case R.TABLE:
3633
3587
  return {
@@ -3636,20 +3590,20 @@ function Et(t, e) {
3636
3590
  label: "headercolor",
3637
3591
  insertText: "headercolor: ",
3638
3592
  kind: L.Field,
3639
- insertTextRules: y.KeepWhitespace,
3593
+ insertTextRules: w.KeepWhitespace,
3640
3594
  range: void 0
3641
3595
  },
3642
3596
  {
3643
3597
  label: "note",
3644
3598
  insertText: "note: ",
3645
3599
  kind: L.Field,
3646
- insertTextRules: y.KeepWhitespace,
3600
+ insertTextRules: w.KeepWhitespace,
3647
3601
  range: void 0
3648
3602
  }
3649
3603
  ]
3650
3604
  };
3651
3605
  default:
3652
- return O();
3606
+ return S();
3653
3607
  }
3654
3608
  switch (s) {
3655
3609
  case R.TABLE:
@@ -3659,21 +3613,21 @@ function Et(t, e) {
3659
3613
  label: i,
3660
3614
  insertText: i,
3661
3615
  kind: L.Property,
3662
- insertTextRules: y.KeepWhitespace,
3616
+ insertTextRules: w.KeepWhitespace,
3663
3617
  range: void 0
3664
3618
  })),
3665
3619
  ...["ref", "default"].map((i) => ({
3666
3620
  label: i,
3667
3621
  insertText: `${i}: `,
3668
3622
  kind: L.Property,
3669
- insertTextRules: y.KeepWhitespace,
3623
+ insertTextRules: w.KeepWhitespace,
3670
3624
  range: void 0
3671
3625
  })),
3672
3626
  {
3673
3627
  label: "note",
3674
3628
  insertText: "note: ",
3675
3629
  kind: L.Property,
3676
- insertTextRules: y.KeepWhitespace,
3630
+ insertTextRules: w.KeepWhitespace,
3677
3631
  range: void 0
3678
3632
  }
3679
3633
  ]
@@ -3685,7 +3639,7 @@ function Et(t, e) {
3685
3639
  label: "note",
3686
3640
  insertText: "note: ",
3687
3641
  kind: L.Property,
3688
- insertTextRules: y.KeepWhitespace,
3642
+ insertTextRules: w.KeepWhitespace,
3689
3643
  range: void 0
3690
3644
  }
3691
3645
  ]
@@ -3696,7 +3650,7 @@ function Et(t, e) {
3696
3650
  ...["unique", "pk"].map((i) => ({
3697
3651
  label: i,
3698
3652
  insertText: i,
3699
- insertTextRules: y.KeepWhitespace,
3653
+ insertTextRules: w.KeepWhitespace,
3700
3654
  kind: L.Property,
3701
3655
  range: void 0
3702
3656
  })),
@@ -3704,7 +3658,7 @@ function Et(t, e) {
3704
3658
  label: i,
3705
3659
  insertText: `${i}: `,
3706
3660
  kind: L.Property,
3707
- insertTextRules: y.KeepWhitespace,
3661
+ insertTextRules: w.KeepWhitespace,
3708
3662
  range: void 0
3709
3663
  }))
3710
3664
  ]
@@ -3715,14 +3669,14 @@ function Et(t, e) {
3715
3669
  label: i,
3716
3670
  insertText: `${i}: `,
3717
3671
  kind: L.Property,
3718
- insertTextRules: y.KeepWhitespace,
3672
+ insertTextRules: w.KeepWhitespace,
3719
3673
  range: void 0
3720
3674
  }))
3721
3675
  };
3722
3676
  }
3723
- return O();
3677
+ return S();
3724
3678
  }
3725
- function Zn(t, e, n) {
3679
+ function Hn(t, e, n) {
3726
3680
  switch (n == null ? void 0 : n.toLowerCase()) {
3727
3681
  case "update":
3728
3682
  case "delete":
@@ -3731,7 +3685,7 @@ function Zn(t, e, n) {
3731
3685
  label: s,
3732
3686
  insertText: s,
3733
3687
  kind: L.Value,
3734
- insertTextRules: y.KeepWhitespace,
3688
+ insertTextRules: w.KeepWhitespace,
3735
3689
  range: void 0
3736
3690
  }))
3737
3691
  };
@@ -3741,23 +3695,23 @@ function Zn(t, e, n) {
3741
3695
  label: s,
3742
3696
  insertText: `${s}`,
3743
3697
  kind: L.Value,
3744
- insertTextRules: y.KeepWhitespace,
3698
+ insertTextRules: w.KeepWhitespace,
3745
3699
  range: void 0
3746
3700
  }))
3747
3701
  };
3748
3702
  }
3749
- return O();
3703
+ return S();
3750
3704
  }
3751
- function Bt(t, e, n) {
3705
+ function Ft(t, e, n) {
3752
3706
  const s = he(n).unwrap_or([]);
3753
3707
  if (s.pop(), s.some((r) => !M(r)))
3754
- return O();
3755
- const i = s.map((r) => X(r).unwrap());
3708
+ return S();
3709
+ const i = s.map((r) => G(r).unwrap());
3756
3710
  return Ue({
3757
3711
  suggestions: t.symbol.ofName({ nameStack: i, owner: t.container.element(e) }).flatMap(({ symbol: r }) => t.symbol.members(r)).map(({ kind: r, name: a }) => ({
3758
3712
  label: a,
3759
3713
  insertText: a,
3760
- kind: _e(r),
3714
+ kind: ge(r),
3761
3715
  range: void 0
3762
3716
  }))
3763
3717
  });
@@ -3766,21 +3720,21 @@ function Nt(t, e, n) {
3766
3720
  var i;
3767
3721
  switch (t.container.scopeKind(e)) {
3768
3722
  case R.TABLE:
3769
- return es(t, e, n);
3723
+ return Zn(t, e, n);
3770
3724
  case R.PROJECT:
3771
- return ts(t, e, n);
3725
+ return Kn(t, e, n);
3772
3726
  case R.INDEXES:
3773
- return ss(t, e);
3727
+ return ts(t, e);
3774
3728
  case R.ENUM:
3775
- return Kn(t, e, n);
3729
+ return Jn(t, e, n);
3776
3730
  case R.REF: {
3777
- const r = Vt(t, e);
3778
- return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === u.COLON && Oe(t.container.token(e).token, e) ? Re(r) : r;
3731
+ const r = Bt(t, e);
3732
+ return ((i = t.container.token(e).token) == null ? void 0 : i.kind) === c.COLON && Se(t.container.token(e).token, e) ? Re(r) : r;
3779
3733
  }
3780
3734
  case R.TABLEGROUP:
3781
- return ns(t);
3735
+ return es(t);
3782
3736
  default:
3783
- return O();
3737
+ return S();
3784
3738
  }
3785
3739
  }
3786
3740
  function mt() {
@@ -3788,26 +3742,26 @@ function mt() {
3788
3742
  suggestions: ["Table", "TableGroup", "Enum", "Project", "Ref"].map((t) => ({
3789
3743
  label: t,
3790
3744
  insertText: t,
3791
- insertTextRules: y.KeepWhitespace,
3745
+ insertTextRules: w.KeepWhitespace,
3792
3746
  kind: L.Keyword,
3793
3747
  range: void 0
3794
3748
  }))
3795
3749
  };
3796
3750
  }
3797
- function Kn(t, e, n) {
3751
+ function Jn(t, e, n) {
3798
3752
  return n != null && n.callee && et(e, n) === 1 ? Me(t, e, t.container.element(e), [
3799
3753
  m.Schema,
3800
3754
  m.Table,
3801
3755
  m.Column
3802
- ]) : O();
3756
+ ]) : S();
3803
3757
  }
3804
- function es(t, e, n) {
3758
+ function Zn(t, e, n) {
3805
3759
  if (!(n != null && n.callee))
3806
3760
  return {
3807
3761
  suggestions: ["Note", "indexes"].map((i) => ({
3808
3762
  label: i,
3809
3763
  insertText: i,
3810
- insertTextRules: y.KeepWhitespace,
3764
+ insertTextRules: w.KeepWhitespace,
3811
3765
  kind: L.Keyword,
3812
3766
  range: void 0
3813
3767
  }))
@@ -3817,39 +3771,39 @@ function es(t, e, n) {
3817
3771
  suggestions: ["Note", "indexes"].map((i) => ({
3818
3772
  label: i,
3819
3773
  insertText: i,
3820
- insertTextRules: y.KeepWhitespace,
3774
+ insertTextRules: w.KeepWhitespace,
3821
3775
  kind: L.Keyword,
3822
3776
  range: void 0
3823
3777
  }))
3824
- } : s === 1 ? is(t, e) : O();
3778
+ } : s === 1 ? ns(t, e) : S();
3825
3779
  }
3826
- function ts(t, e, n) {
3780
+ function Kn(t, e, n) {
3827
3781
  return n != null && n.callee ? et(e, n) === 0 ? {
3828
3782
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3829
3783
  label: i,
3830
3784
  insertText: i,
3831
- insertTextRules: y.KeepWhitespace,
3785
+ insertTextRules: w.KeepWhitespace,
3832
3786
  kind: L.Keyword,
3833
3787
  range: void 0
3834
3788
  }))
3835
- } : O() : {
3789
+ } : S() : {
3836
3790
  suggestions: ["Table", "TableGroup", "Enum", "Note", "Ref"].map((i) => ({
3837
3791
  label: i,
3838
3792
  insertText: i,
3839
- insertTextRules: y.KeepWhitespace,
3793
+ insertTextRules: w.KeepWhitespace,
3840
3794
  kind: L.Keyword,
3841
3795
  range: void 0
3842
3796
  }))
3843
3797
  };
3844
3798
  }
3845
- function Vt(t, e) {
3799
+ function Bt(t, e) {
3846
3800
  return Me(t, e, t.container.element(e), [
3847
3801
  m.Schema,
3848
3802
  m.Table,
3849
3803
  m.Column
3850
3804
  ]);
3851
3805
  }
3852
- function ns(t) {
3806
+ function es(t) {
3853
3807
  return Ue({
3854
3808
  suggestions: [...t.parse.publicSymbolTable().entries()].flatMap(([e]) => {
3855
3809
  const n = ie(e).unwrap_or(void 0);
@@ -3859,17 +3813,17 @@ function ns(t) {
3859
3813
  return s !== m.Table && s !== m.Schema ? [] : {
3860
3814
  label: i,
3861
3815
  insertText: i,
3862
- insertTextRules: y.KeepWhitespace,
3863
- kind: _e(s),
3816
+ insertTextRules: w.KeepWhitespace,
3817
+ kind: ge(s),
3864
3818
  range: void 0
3865
3819
  };
3866
3820
  })
3867
3821
  });
3868
3822
  }
3869
- function ss(t, e) {
3870
- return Gt(t, e);
3823
+ function ts(t, e) {
3824
+ return Vt(t, e);
3871
3825
  }
3872
- function is(t, e) {
3826
+ function ns(t, e) {
3873
3827
  return {
3874
3828
  suggestions: [
3875
3829
  ...[
@@ -3932,7 +3886,7 @@ function is(t, e) {
3932
3886
  ].map((n) => ({
3933
3887
  label: n,
3934
3888
  insertText: n,
3935
- insertTextRules: y.KeepWhitespace,
3889
+ insertTextRules: w.KeepWhitespace,
3936
3890
  kind: L.TypeParameter,
3937
3891
  sortText: L.TypeParameter.toString().padStart(2, "0"),
3938
3892
  range: void 0
@@ -3944,10 +3898,10 @@ function is(t, e) {
3944
3898
  ]
3945
3899
  };
3946
3900
  }
3947
- function Gt(t, e) {
3901
+ function Vt(t, e) {
3948
3902
  const n = t.container.element(e), s = n == null ? void 0 : n.parent;
3949
3903
  if (!((s == null ? void 0 : s.symbol) instanceof _t))
3950
- return O();
3904
+ return S();
3951
3905
  const { symbolTable: i } = s.symbol;
3952
3906
  return Ue({
3953
3907
  suggestions: [...i.entries()].flatMap(([r]) => {
@@ -3958,8 +3912,8 @@ function Gt(t, e) {
3958
3912
  return {
3959
3913
  label: l,
3960
3914
  insertText: l,
3961
- insertTextRules: y.KeepWhitespace,
3962
- kind: _e(m.Column),
3915
+ insertTextRules: w.KeepWhitespace,
3916
+ kind: ge(m.Column),
3963
3917
  range: void 0
3964
3918
  };
3965
3919
  })
@@ -3971,7 +3925,7 @@ function et(t, e) {
3971
3925
  const n = [e.callee, ...e.args], s = n.findIndex((i) => t <= i.end);
3972
3926
  return s === -1 ? n.length : s;
3973
3927
  }
3974
- class Ct {
3928
+ class Gt {
3975
3929
  constructor(e) {
3976
3930
  this.compiler = e;
3977
3931
  }
@@ -3998,7 +3952,7 @@ class Ct {
3998
3952
  return [];
3999
3953
  }
4000
3954
  }
4001
- class Xt {
3955
+ class Ct {
4002
3956
  constructor(e) {
4003
3957
  this.compiler = e;
4004
3958
  }
@@ -4027,21 +3981,21 @@ class Xt {
4027
3981
  return [];
4028
3982
  }
4029
3983
  }
4030
- const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3984
+ const rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4031
3985
  __proto__: null,
4032
- CompletionItemInsertTextRule: y,
3986
+ CompletionItemInsertTextRule: w,
4033
3987
  CompletionItemKind: L,
4034
- DBMLCompletionItemProvider: Ft,
4035
- DBMLDefinitionProvider: Ct,
4036
- DBMLReferencesProvider: Xt
3988
+ DBMLCompletionItemProvider: Mt,
3989
+ DBMLDefinitionProvider: Gt,
3990
+ DBMLReferencesProvider: Ct
4037
3991
  }, Symbol.toStringTag, { value: "Module" }));
4038
3992
  var R = /* @__PURE__ */ ((t) => (t[t.TABLE = 0] = "TABLE", t[t.ENUM = 1] = "ENUM", t[t.TABLEGROUP = 2] = "TABLEGROUP", t[t.INDEXES = 3] = "INDEXES", t[t.NOTE = 4] = "NOTE", t[t.REF = 5] = "REF", t[t.PROJECT = 6] = "PROJECT", t[t.CUSTOM = 7] = "CUSTOM", t[t.TOPLEVEL = 8] = "TOPLEVEL", t))(R || {});
4039
- class ls {
3993
+ class as {
4040
3994
  constructor() {
4041
3995
  this.source = "", this.cache = new Array(
4042
3996
  16
4043
3997
  /* TOTAL_QUERY_COUNT */
4044
- ).fill(null), this.nodeIdGenerator = new jt(), this.symbolIdGenerator = new Ht(), this.token = {
3998
+ ).fill(null), this.nodeIdGenerator = new Wt(), this.symbolIdGenerator = new Qt(), this.token = {
4045
3999
  invalidStream: this.createQuery(
4046
4000
  6,
4047
4001
  () => this.parse.tokens().filter(At)
@@ -4056,8 +4010,8 @@ class ls {
4056
4010
  _: this.createQuery(
4057
4011
  0,
4058
4012
  () => {
4059
- 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 })));
4060
- return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new qn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4013
+ 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 })));
4014
+ return e.getErrors().length > 0 ? e : e.chain(({ ast: n, tokens: s }) => new zn(n).interpret().map((r) => ({ ast: n, tokens: s, rawDb: r })));
4061
4015
  }
4062
4016
  ),
4063
4017
  ast: this.createQuery(
@@ -4094,23 +4048,23 @@ class ls {
4094
4048
  let a = this.parse.ast();
4095
4049
  const l = [a];
4096
4050
  for (; ; ) {
4097
- const h = an(a).find((T) => Le(r, T));
4098
- if (h === void 0 || h instanceof V)
4051
+ const h = sn(a).find((T) => Ie(r, T));
4052
+ if (h === void 0 || h instanceof B)
4099
4053
  break;
4100
4054
  l.push(h), a = h;
4101
4055
  }
4102
- if ((i == null ? void 0 : i.kind) === u.COLON)
4056
+ if ((i == null ? void 0 : i.kind) === c.COLON)
4103
4057
  return l;
4104
4058
  for (; l.length > 0; ) {
4105
4059
  let p = !1;
4106
4060
  const h = I.last(l);
4107
- if (h instanceof w) {
4061
+ if (h instanceof k) {
4108
4062
  const T = this.parse.source();
4109
4063
  for (let f = h.end; f < e; f += 1)
4110
4064
  T[f] === `
4111
4065
  ` && (l.pop(), p = !0);
4112
4066
  } else
4113
- h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof $ || h.end < e && (l.pop(), p = !0);
4067
+ h instanceof q || h instanceof H ? this.container.token(e).token !== h.op && (l.pop(), p = !0) : h instanceof P ? h.listCloseBracket && h.end <= e && (l.pop(), p = !0) : h instanceof Z ? h.tupleCloseParen && h.end <= e && (l.pop(), p = !0) : h instanceof ne ? h.blockCloseBrace && h.end <= e && (l.pop(), p = !0) : h instanceof C || h.end < e && (l.pop(), p = !0);
4114
4068
  if (p) {
4115
4069
  const T = I.last(l);
4116
4070
  T instanceof A && T.end <= e && l.pop();
@@ -4150,7 +4104,7 @@ class ls {
4150
4104
  ),
4151
4105
  scopeKind: this.createQuery(15, (e) => {
4152
4106
  var s;
4153
- if (this.container.element(e) instanceof F)
4107
+ if (this.container.element(e) instanceof X)
4154
4108
  return 8;
4155
4109
  switch ((s = this.container.element(e).type) == null ? void 0 : s.value.toLowerCase()) {
4156
4110
  case "table":
@@ -4193,7 +4147,7 @@ class ls {
4193
4147
  let l = [a], p = [];
4194
4148
  for (const h of e)
4195
4149
  p = l.flatMap(
4196
- (T) => Qt(h).flatMap((f) => {
4150
+ (T) => Yt(h).flatMap((f) => {
4197
4151
  const N = T.get(f), g = ie(f).unwrap_or(void 0);
4198
4152
  return !N || !g ? [] : { ...g, symbol: N };
4199
4153
  })
@@ -4236,14 +4190,14 @@ class ls {
4236
4190
  }
4237
4191
  initMonacoServices() {
4238
4192
  return {
4239
- definitionProvider: new Ct(this),
4240
- referenceProvider: new Xt(this),
4241
- autocompletionProvider: new Ft(this)
4193
+ definitionProvider: new Gt(this),
4194
+ referenceProvider: new Ct(this),
4195
+ autocompletionProvider: new Mt(this)
4242
4196
  };
4243
4197
  }
4244
4198
  }
4245
4199
  export {
4246
- ls as Compiler,
4247
- as as serialize,
4248
- os as services
4200
+ as as Compiler,
4201
+ is as serialize,
4202
+ rs as services
4249
4203
  };