import { d as we } from "./chunk-55IACEB6-FAGpaDxG-BTfPS-CU.js";
import { d as Be } from "./chunk-EDXVE4YY-JJVh1SXw-B-sKHFur.js";
import { _ as l, aa as Fe, a9 as Ye, a7 as Pe, a8 as ze, ao as Ge, ap as Ke, g as te, l as v, av as Ue, at as Ze, ax as je, aA as We, al as Xe, am as Qe, a5 as He, an as qe } from "./index-Bh-wTBlD.js";
import { t as Je } from "./channel-C0HsK-iS-D8tJdRzv.js";
var ge = function() {
  var t = /* @__PURE__ */ l(function(k, r, o, n) {
    for (o = o || {}, n = k.length; n--; o[k[n]] = r) ;
    return o;
  }, "o"), i = [6, 8, 10, 22, 24, 26, 28, 33, 34, 35, 36, 37, 40, 43, 44, 48, 50, 51, 52], c = [1, 10], a = [1, 11], u = [1, 12], h = [1, 13], p = [1, 23], y = [1, 24], E = [1, 25], Z = [1, 26], j = [1, 27], O = [1, 19], ie = [1, 28], M = [1, 29], I = [1, 20], S = [1, 18], R = [1, 21], w = [1, 22], ne = [1, 36], re = [1, 37], ae = [1, 38], oe = [1, 39], ce = [1, 40], B = [6, 8, 10, 13, 15, 17, 20, 21, 22, 24, 26, 28, 33, 34, 35, 36, 37, 40, 43, 44, 48, 50, 51, 52, 65, 66, 67, 68, 69], A = [1, 45], N = [1, 46], F = [1, 55], Y = [40, 48, 50, 51, 52, 70, 71], P = [1, 66], z = [1, 64], $ = [1, 61], G = [1, 65], K = [1, 67], W = [6, 8, 10, 13, 17, 22, 24, 26, 28, 33, 34, 35, 36, 37, 40, 41, 42, 43, 44, 48, 49, 50, 51, 52, 65, 66, 67, 68, 69], fe = [65, 66, 67, 68, 69], be = [1, 84], me = [1, 83], ke = [1, 81], Ee = [1, 82], Te = [6, 10, 42, 47], D = [6, 10, 13, 41, 42, 47, 48, 49], X = [1, 92], Q = [1, 91], H = [1, 90], U = [19, 58], Oe = [1, 101], Se = [1, 100], le = [19, 58, 60, 62], he = {
    trace: /* @__PURE__ */ l(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, ER_DIAGRAM: 4, document: 5, EOF: 6, line: 7, SPACE: 8, statement: 9, NEWLINE: 10, entityName: 11, relSpec: 12, COLON: 13, role: 14, STYLE_SEPARATOR: 15, idList: 16, BLOCK_START: 17, attributes: 18, BLOCK_STOP: 19, SQS: 20, SQE: 21, title: 22, title_value: 23, acc_title: 24, acc_title_value: 25, acc_descr: 26, acc_descr_value: 27, acc_descr_multiline_value: 28, direction: 29, classDefStatement: 30, classStatement: 31, styleStatement: 32, direction_tb: 33, direction_bt: 34, direction_rl: 35, direction_lr: 36, CLASSDEF: 37, stylesOpt: 38, separator: 39, UNICODE_TEXT: 40, STYLE_TEXT: 41, COMMA: 42, CLASS: 43, STYLE: 44, style: 45, styleComponent: 46, SEMI: 47, NUM: 48, BRKT: 49, ENTITY_NAME: 50, DECIMAL_NUM: 51, ENTITY_ONE: 52, attribute: 53, attributeType: 54, attributeName: 55, attributeKeyTypeList: 56, attributeComment: 57, ATTRIBUTE_WORD: 58, attributeKeyType: 59, ",": 60, ATTRIBUTE_KEY: 61, COMMENT: 62, cardinality: 63, relType: 64, ZERO_OR_ONE: 65, ZERO_OR_MORE: 66, ONE_OR_MORE: 67, ONLY_ONE: 68, MD_PARENT: 69, NON_IDENTIFYING: 70, IDENTIFYING: 71, WORD: 72, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "ER_DIAGRAM", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 13: "COLON", 15: "STYLE_SEPARATOR", 17: "BLOCK_START", 19: "BLOCK_STOP", 20: "SQS", 21: "SQE", 22: "title", 23: "title_value", 24: "acc_title", 25: "acc_title_value", 26: "acc_descr", 27: "acc_descr_value", 28: "acc_descr_multiline_value", 33: "direction_tb", 34: "direction_bt", 35: "direction_rl", 36: "direction_lr", 37: "CLASSDEF", 40: "UNICODE_TEXT", 41: "STYLE_TEXT", 42: "COMMA", 43: "CLASS", 44: "STYLE", 47: "SEMI", 48: "NUM", 49: "BRKT", 50: "ENTITY_NAME", 51: "DECIMAL_NUM", 52: "ENTITY_ONE", 58: "ATTRIBUTE_WORD", 60: ",", 61: "ATTRIBUTE_KEY", 62: "COMMENT", 65: "ZERO_OR_ONE", 66: "ZERO_OR_MORE", 67: "ONE_OR_MORE", 68: "ONLY_ONE", 69: "MD_PARENT", 70: "NON_IDENTIFYING", 71: "IDENTIFYING", 72: "WORD" },
    productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 5], [9, 9], [9, 7], [9, 7], [9, 4], [9, 6], [9, 3], [9, 5], [9, 1], [9, 3], [9, 7], [9, 9], [9, 6], [9, 8], [9, 4], [9, 6], [9, 2], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 1], [9, 1], [29, 1], [29, 1], [29, 1], [29, 1], [30, 4], [16, 1], [16, 1], [16, 3], [16, 3], [31, 3], [32, 4], [38, 1], [38, 3], [45, 1], [45, 2], [39, 1], [39, 1], [39, 1], [46, 1], [46, 1], [46, 1], [46, 1], [11, 1], [11, 1], [11, 1], [11, 1], [11, 1], [18, 1], [18, 2], [53, 2], [53, 3], [53, 3], [53, 4], [54, 1], [55, 1], [56, 1], [56, 3], [59, 1], [57, 1], [12, 3], [63, 1], [63, 1], [63, 1], [63, 1], [63, 1], [64, 1], [64, 1], [14, 1], [14, 1], [14, 1]],
    performAction: /* @__PURE__ */ l(function(k, r, o, n, d, e, g) {
      var s = e.length - 1;
      switch (d) {
        case 1:
          break;
        case 2:
          this.$ = [];
          break;
        case 3:
          e[s - 1].push(e[s]), this.$ = e[s - 1];
          break;
        case 4:
        case 5:
          this.$ = e[s];
          break;
        case 6:
        case 7:
          this.$ = [];
          break;
        case 8:
          n.addEntity(e[s - 4]), n.addEntity(e[s - 2]), n.addRelationship(e[s - 4], e[s], e[s - 2], e[s - 3]);
          break;
        case 9:
          n.addEntity(e[s - 8]), n.addEntity(e[s - 4]), n.addRelationship(e[s - 8], e[s], e[s - 4], e[s - 5]), n.setClass([e[s - 8]], e[s - 6]), n.setClass([e[s - 4]], e[s - 2]);
          break;
        case 10:
          n.addEntity(e[s - 6]), n.addEntity(e[s - 2]), n.addRelationship(e[s - 6], e[s], e[s - 2], e[s - 3]), n.setClass([e[s - 6]], e[s - 4]);
          break;
        case 11:
          n.addEntity(e[s - 6]), n.addEntity(e[s - 4]), n.addRelationship(e[s - 6], e[s], e[s - 4], e[s - 5]), n.setClass([e[s - 4]], e[s - 2]);
          break;
        case 12:
          n.addEntity(e[s - 3]), n.addAttributes(e[s - 3], e[s - 1]);
          break;
        case 13:
          n.addEntity(e[s - 5]), n.addAttributes(e[s - 5], e[s - 1]), n.setClass([e[s - 5]], e[s - 3]);
          break;
        case 14:
          n.addEntity(e[s - 2]);
          break;
        case 15:
          n.addEntity(e[s - 4]), n.setClass([e[s - 4]], e[s - 2]);
          break;
        case 16:
          n.addEntity(e[s]);
          break;
        case 17:
          n.addEntity(e[s - 2]), n.setClass([e[s - 2]], e[s]);
          break;
        case 18:
          n.addEntity(e[s - 6], e[s - 4]), n.addAttributes(e[s - 6], e[s - 1]);
          break;
        case 19:
          n.addEntity(e[s - 8], e[s - 6]), n.addAttributes(e[s - 8], e[s - 1]), n.setClass([e[s - 8]], e[s - 3]);
          break;
        case 20:
          n.addEntity(e[s - 5], e[s - 3]);
          break;
        case 21:
          n.addEntity(e[s - 7], e[s - 5]), n.setClass([e[s - 7]], e[s - 2]);
          break;
        case 22:
          n.addEntity(e[s - 3], e[s - 1]);
          break;
        case 23:
          n.addEntity(e[s - 5], e[s - 3]), n.setClass([e[s - 5]], e[s]);
          break;
        case 24:
        case 25:
          this.$ = e[s].trim(), n.setAccTitle(this.$);
          break;
        case 26:
        case 27:
          this.$ = e[s].trim(), n.setAccDescription(this.$);
          break;
        case 32:
          n.setDirection("TB");
          break;
        case 33:
          n.setDirection("BT");
          break;
        case 34:
          n.setDirection("RL");
          break;
        case 35:
          n.setDirection("LR");
          break;
        case 36:
          this.$ = e[s - 3], n.addClass(e[s - 2], e[s - 1]);
          break;
        case 37:
        case 38:
        case 59:
        case 67:
          this.$ = [e[s]];
          break;
        case 39:
        case 40:
          this.$ = e[s - 2].concat([e[s]]);
          break;
        case 41:
          this.$ = e[s - 2], n.setClass(e[s - 1], e[s]);
          break;
        case 42:
          this.$ = e[s - 3], n.addCssStyles(e[s - 2], e[s - 1]);
          break;
        case 43:
          this.$ = [e[s]];
          break;
        case 44:
          e[s - 2].push(e[s]), this.$ = e[s - 2];
          break;
        case 46:
          this.$ = e[s - 1] + e[s];
          break;
        case 54:
        case 79:
        case 80:
          this.$ = e[s].replace(/"/g, "");
          break;
        case 55:
        case 56:
        case 57:
        case 58:
        case 81:
          this.$ = e[s];
          break;
        case 60:
          e[s].push(e[s - 1]), this.$ = e[s];
          break;
        case 61:
          this.$ = { type: e[s - 1], name: e[s] };
          break;
        case 62:
          this.$ = { type: e[s - 2], name: e[s - 1], keys: e[s] };
          break;
        case 63:
          this.$ = { type: e[s - 2], name: e[s - 1], comment: e[s] };
          break;
        case 64:
          this.$ = { type: e[s - 3], name: e[s - 2], keys: e[s - 1], comment: e[s] };
          break;
        case 65:
        case 66:
        case 69:
          this.$ = e[s];
          break;
        case 68:
          e[s - 2].push(e[s]), this.$ = e[s - 2];
          break;
        case 70:
          this.$ = e[s].replace(/"/g, "");
          break;
        case 71:
          this.$ = { cardA: e[s], relType: e[s - 1], cardB: e[s - 2] };
          break;
        case 72:
          this.$ = n.Cardinality.ZERO_OR_ONE;
          break;
        case 73:
          this.$ = n.Cardinality.ZERO_OR_MORE;
          break;
        case 74:
          this.$ = n.Cardinality.ONE_OR_MORE;
          break;
        case 75:
          this.$ = n.Cardinality.ONLY_ONE;
          break;
        case 76:
          this.$ = n.Cardinality.MD_PARENT;
          break;
        case 77:
          this.$ = n.Identification.NON_IDENTIFYING;
          break;
        case 78:
          this.$ = n.Identification.IDENTIFYING;
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, t(i, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: 9, 22: c, 24: a, 26: u, 28: h, 29: 14, 30: 15, 31: 16, 32: 17, 33: p, 34: y, 35: E, 36: Z, 37: j, 40: O, 43: ie, 44: M, 48: I, 50: S, 51: R, 52: w }, t(i, [2, 7], { 1: [2, 1] }), t(i, [2, 3]), { 9: 30, 11: 9, 22: c, 24: a, 26: u, 28: h, 29: 14, 30: 15, 31: 16, 32: 17, 33: p, 34: y, 35: E, 36: Z, 37: j, 40: O, 43: ie, 44: M, 48: I, 50: S, 51: R, 52: w }, t(i, [2, 5]), t(i, [2, 6]), t(i, [2, 16], { 12: 31, 63: 35, 15: [1, 32], 17: [1, 33], 20: [1, 34], 65: ne, 66: re, 67: ae, 68: oe, 69: ce }), { 23: [1, 41] }, { 25: [1, 42] }, { 27: [1, 43] }, t(i, [2, 27]), t(i, [2, 28]), t(i, [2, 29]), t(i, [2, 30]), t(i, [2, 31]), t(B, [2, 54]), t(B, [2, 55]), t(B, [2, 56]), t(B, [2, 57]), t(B, [2, 58]), t(i, [2, 32]), t(i, [2, 33]), t(i, [2, 34]), t(i, [2, 35]), { 16: 44, 40: A, 41: N }, { 16: 47, 40: A, 41: N }, { 16: 48, 40: A, 41: N }, t(i, [2, 4]), { 11: 49, 40: O, 48: I, 50: S, 51: R, 52: w }, { 16: 50, 40: A, 41: N }, { 18: 51, 19: [1, 52], 53: 53, 54: 54, 58: F }, { 11: 56, 40: O, 48: I, 50: S, 51: R, 52: w }, { 64: 57, 70: [1, 58], 71: [1, 59] }, t(Y, [2, 72]), t(Y, [2, 73]), t(Y, [2, 74]), t(Y, [2, 75]), t(Y, [2, 76]), t(i, [2, 24]), t(i, [2, 25]), t(i, [2, 26]), { 13: P, 38: 60, 41: z, 42: $, 45: 62, 46: 63, 48: G, 49: K }, t(W, [2, 37]), t(W, [2, 38]), { 16: 68, 40: A, 41: N, 42: $ }, { 13: P, 38: 69, 41: z, 42: $, 45: 62, 46: 63, 48: G, 49: K }, { 13: [1, 70], 15: [1, 71] }, t(i, [2, 17], { 63: 35, 12: 72, 17: [1, 73], 42: $, 65: ne, 66: re, 67: ae, 68: oe, 69: ce }), { 19: [1, 74] }, t(i, [2, 14]), { 18: 75, 19: [2, 59], 53: 53, 54: 54, 58: F }, { 55: 76, 58: [1, 77] }, { 58: [2, 65] }, { 21: [1, 78] }, { 63: 79, 65: ne, 66: re, 67: ae, 68: oe, 69: ce }, t(fe, [2, 77]), t(fe, [2, 78]), { 6: be, 10: me, 39: 80, 42: ke, 47: Ee }, { 40: [1, 85], 41: [1, 86] }, t(Te, [2, 43], { 46: 87, 13: P, 41: z, 48: G, 49: K }), t(D, [2, 45]), t(D, [2, 50]), t(D, [2, 51]), t(D, [2, 52]), t(D, [2, 53]), t(i, [2, 41], { 42: $ }), { 6: be, 10: me, 39: 88, 42: ke, 47: Ee }, { 14: 89, 40: X, 50: Q, 72: H }, { 16: 93, 40: A, 41: N }, { 11: 94, 40: O, 48: I, 50: S, 51: R, 52: w }, { 18: 95, 19: [1, 96], 53: 53, 54: 54, 58: F }, t(i, [2, 12]), { 19: [2, 60] }, t(U, [2, 61], { 56: 97, 57: 98, 59: 99, 61: Oe, 62: Se }), t([19, 58, 61, 62], [2, 66]), t(i, [2, 22], { 15: [1, 103], 17: [1, 102] }), t([40, 48, 50, 51, 52], [2, 71]), t(i, [2, 36]), { 13: P, 41: z, 45: 104, 46: 63, 48: G, 49: K }, t(i, [2, 47]), t(i, [2, 48]), t(i, [2, 49]), t(W, [2, 39]), t(W, [2, 40]), t(D, [2, 46]), t(i, [2, 42]), t(i, [2, 8]), t(i, [2, 79]), t(i, [2, 80]), t(i, [2, 81]), { 13: [1, 105], 42: $ }, { 13: [1, 107], 15: [1, 106] }, { 19: [1, 108] }, t(i, [2, 15]), t(U, [2, 62], { 57: 109, 60: [1, 110], 62: Se }), t(U, [2, 63]), t(le, [2, 67]), t(U, [2, 70]), t(le, [2, 69]), { 18: 111, 19: [1, 112], 53: 53, 54: 54, 58: F }, { 16: 113, 40: A, 41: N }, t(Te, [2, 44], { 46: 87, 13: P, 41: z, 48: G, 49: K }), { 14: 114, 40: X, 50: Q, 72: H }, { 16: 115, 40: A, 41: N }, { 14: 116, 40: X, 50: Q, 72: H }, t(i, [2, 13]), t(U, [2, 64]), { 59: 117, 61: Oe }, { 19: [1, 118] }, t(i, [2, 20]), t(i, [2, 23], { 17: [1, 119], 42: $ }), t(i, [2, 11]), { 13: [1, 120], 42: $ }, t(i, [2, 10]), t(le, [2, 68]), t(i, [2, 18]), { 18: 121, 19: [1, 122], 53: 53, 54: 54, 58: F }, { 14: 123, 40: X, 50: Q, 72: H }, { 19: [1, 124] }, t(i, [2, 21]), t(i, [2, 9]), t(i, [2, 19])],
    defaultActions: { 55: [2, 65], 75: [2, 60] },
    parseError: /* @__PURE__ */ l(function(k, r) {
      if (r.recoverable)
        this.trace(k);
      else {
        var o = new Error(k);
        throw o.hash = r, o;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ l(function(k) {
      var r = this, o = [0], n = [], d = [null], e = [], g = this.table, s = "", J = 0, Ae = 0, De = 2, Ne = 1, Le = e.slice.call(arguments, 1), _ = Object.create(this.lexer), C = { yy: {} };
      for (var ue in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, ue) && (C.yy[ue] = this.yy[ue]);
      _.setInput(k, C.yy), C.yy.lexer = _, C.yy.parser = this, typeof _.yylloc > "u" && (_.yylloc = {});
      var de = _.yylloc;
      e.push(de);
      var ve = _.options && _.options.ranges;
      typeof C.yy.parseError == "function" ? this.parseError = C.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function Me(b) {
        o.length = o.length - 2 * b, d.length = d.length - b, e.length = e.length - b;
      }
      l(Me, "popStack");
      function $e() {
        var b;
        return b = n.pop() || _.lex() || Ne, typeof b != "number" && (b instanceof Array && (n = b, b = n.pop()), b = r.symbols_[b] || b), b;
      }
      l($e, "lex");
      for (var f, x, m, ye, L = {}, V, T, Ie, ee; ; ) {
        if (x = o[o.length - 1], this.defaultActions[x] ? m = this.defaultActions[x] : ((f === null || typeof f > "u") && (f = $e()), m = g[x] && g[x][f]), typeof m > "u" || !m.length || !m[0]) {
          var pe = "";
          ee = [];
          for (V in g[x])
            this.terminals_[V] && V > De && ee.push("'" + this.terminals_[V] + "'");
          _.showPosition ? pe = "Parse error on line " + (J + 1) + `:
` + _.showPosition() + `
Expecting ` + ee.join(", ") + ", got '" + (this.terminals_[f] || f) + "'" : pe = "Parse error on line " + (J + 1) + ": Unexpected " + (f == Ne ? "end of input" : "'" + (this.terminals_[f] || f) + "'"), this.parseError(pe, {
            text: _.match,
            token: this.terminals_[f] || f,
            line: _.yylineno,
            loc: de,
            expected: ee
          });
        }
        if (m[0] instanceof Array && m.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + x + ", token: " + f);
        switch (m[0]) {
          case 1:
            o.push(f), d.push(_.yytext), e.push(_.yylloc), o.push(m[1]), f = null, Ae = _.yyleng, s = _.yytext, J = _.yylineno, de = _.yylloc;
            break;
          case 2:
            if (T = this.productions_[m[1]][1], L.$ = d[d.length - T], L._$ = {
              first_line: e[e.length - (T || 1)].first_line,
              last_line: e[e.length - 1].last_line,
              first_column: e[e.length - (T || 1)].first_column,
              last_column: e[e.length - 1].last_column
            }, ve && (L._$.range = [
              e[e.length - (T || 1)].range[0],
              e[e.length - 1].range[1]
            ]), ye = this.performAction.apply(L, [
              s,
              Ae,
              J,
              C.yy,
              m[1],
              d,
              e
            ].concat(Le)), typeof ye < "u")
              return ye;
            T && (o = o.slice(0, -1 * T * 2), d = d.slice(0, -1 * T), e = e.slice(0, -1 * T)), o.push(this.productions_[m[1]][0]), d.push(L.$), e.push(L._$), Ie = g[o[o.length - 2]][o[o.length - 1]], o.push(Ie);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, xe = /* @__PURE__ */ function() {
    var k = {
      EOF: 1,
      parseError: /* @__PURE__ */ l(function(r, o) {
        if (this.yy.parser)
          this.yy.parser.parseError(r, o);
        else
          throw new Error(r);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ l(function(r, o) {
        return this.yy = o || this.yy || {}, this._input = r, this._more = this._backtrack = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
          first_line: 1,
          first_column: 0,
          last_line: 1,
          last_column: 0
        }, this.options.ranges && (this.yylloc.range = [0, 0]), this.offset = 0, this;
      }, "setInput"),
      // consumes and returns one char from the input
      input: /* @__PURE__ */ l(function() {
        var r = this._input[0];
        this.yytext += r, this.yyleng++, this.offset++, this.match += r, this.matched += r;
        var o = r.match(/(?:\r\n?|\n).*/g);
        return o ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), r;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ l(function(r) {
        var o = r.length, n = r.split(/(?:\r\n?|\n)/g);
        this._input = r + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - o), this.offset -= o;
        var d = this.match.split(/(?:\r\n?|\n)/g);
        this.match = this.match.substr(0, this.match.length - 1), this.matched = this.matched.substr(0, this.matched.length - 1), n.length - 1 && (this.yylineno -= n.length - 1);
        var e = this.yylloc.range;
        return this.yylloc = {
          first_line: this.yylloc.first_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.first_column,
          last_column: n ? (n.length === d.length ? this.yylloc.first_column : 0) + d[d.length - n.length].length - n[0].length : this.yylloc.first_column - o
        }, this.options.ranges && (this.yylloc.range = [e[0], e[0] + this.yyleng - o]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ l(function() {
        return this._more = !0, this;
      }, "more"),
      // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
      reject: /* @__PURE__ */ l(function() {
        if (this.options.backtrack_lexer)
          this._backtrack = !0;
        else
          return this.parseError("Lexical error on line " + (this.yylineno + 1) + `. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
` + this.showPosition(), {
            text: "",
            token: null,
            line: this.yylineno
          });
        return this;
      }, "reject"),
      // retain first n characters of the match
      less: /* @__PURE__ */ l(function(r) {
        this.unput(this.match.slice(r));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ l(function() {
        var r = this.matched.substr(0, this.matched.length - this.match.length);
        return (r.length > 20 ? "..." : "") + r.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ l(function() {
        var r = this.match;
        return r.length < 20 && (r += this._input.substr(0, 20 - r.length)), (r.substr(0, 20) + (r.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ l(function() {
        var r = this.pastInput(), o = new Array(r.length + 1).join("-");
        return r + this.upcomingInput() + `
` + o + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ l(function(r, o) {
        var n, d, e;
        if (this.options.backtrack_lexer && (e = {
          yylineno: this.yylineno,
          yylloc: {
            first_line: this.yylloc.first_line,
            last_line: this.last_line,
            first_column: this.yylloc.first_column,
            last_column: this.yylloc.last_column
          },
          yytext: this.yytext,
          match: this.match,
          matches: this.matches,
          matched: this.matched,
          yyleng: this.yyleng,
          offset: this.offset,
          _more: this._more,
          _input: this._input,
          yy: this.yy,
          conditionStack: this.conditionStack.slice(0),
          done: this.done
        }, this.options.ranges && (e.yylloc.range = this.yylloc.range.slice(0))), d = r[0].match(/(?:\r\n?|\n).*/g), d && (this.yylineno += d.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: d ? d[d.length - 1].length - d[d.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + r[0].length
        }, this.yytext += r[0], this.match += r[0], this.matches = r, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = !1, this._backtrack = !1, this._input = this._input.slice(r[0].length), this.matched += r[0], n = this.performAction.call(this, this.yy, this, o, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), n)
          return n;
        if (this._backtrack) {
          for (var g in e)
            this[g] = e[g];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ l(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var r, o, n, d;
        this._more || (this.yytext = "", this.match = "");
        for (var e = this._currentRules(), g = 0; g < e.length; g++)
          if (n = this._input.match(this.rules[e[g]]), n && (!o || n[0].length > o[0].length)) {
            if (o = n, d = g, this.options.backtrack_lexer) {
              if (r = this.test_match(n, e[g]), r !== !1)
                return r;
              if (this._backtrack) {
                o = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return o ? (r = this.test_match(o, e[d]), r !== !1 ? r : !1) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      // return next match that has a token
      lex: /* @__PURE__ */ l(function() {
        var r = this.next();
        return r || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ l(function(r) {
        this.conditionStack.push(r);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ l(function() {
        var r = this.conditionStack.length - 1;
        return r > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      // produce the lexer rule set which is active for the currently active lexer condition state
      _currentRules: /* @__PURE__ */ l(function() {
        return this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1] ? this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules : this.conditions.INITIAL.rules;
      }, "_currentRules"),
      // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
      topState: /* @__PURE__ */ l(function(r) {
        return r = this.conditionStack.length - 1 - Math.abs(r || 0), r >= 0 ? this.conditionStack[r] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ l(function(r) {
        this.begin(r);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ l(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ l(function(r, o, n, d) {
        switch (n) {
          case 0:
            return this.begin("acc_title"), 24;
          case 1:
            return this.popState(), "acc_title_value";
          case 2:
            return this.begin("acc_descr"), 26;
          case 3:
            return this.popState(), "acc_descr_value";
          case 4:
            this.begin("acc_descr_multiline");
            break;
          case 5:
            this.popState();
            break;
          case 6:
            return "acc_descr_multiline_value";
          case 7:
            return 33;
          case 8:
            return 34;
          case 9:
            return 35;
          case 10:
            return 36;
          case 11:
            return 10;
          case 12:
            break;
          case 13:
            return 8;
          case 14:
            return 50;
          case 15:
            return 72;
          case 16:
            return 4;
          case 17:
            return this.begin("block"), 17;
          case 18:
            return 49;
          case 19:
            return 49;
          case 20:
            return 42;
          case 21:
            return 15;
          case 22:
            return 13;
          case 23:
            break;
          case 24:
            return 61;
          case 25:
            return 58;
          case 26:
            return 58;
          case 27:
            return 62;
          case 28:
            break;
          case 29:
            return this.popState(), 19;
          case 30:
            return o.yytext[0];
          case 31:
            return 20;
          case 32:
            return 21;
          case 33:
            return this.begin("style"), 44;
          case 34:
            return this.popState(), 10;
          case 35:
            break;
          case 36:
            return 13;
          case 37:
            return 42;
          case 38:
            return 49;
          case 39:
            return this.begin("style"), 37;
          case 40:
            return 43;
          case 41:
            return 65;
          case 42:
            return 67;
          case 43:
            return 67;
          case 44:
            return 67;
          case 45:
            return 65;
          case 46:
            return 65;
          case 47:
            return 66;
          case 48:
            return 66;
          case 49:
            return 66;
          case 50:
            return 66;
          case 51:
            return 66;
          case 52:
            return 67;
          case 53:
            return 66;
          case 54:
            return 67;
          case 55:
            return 68;
          case 56:
            return 68;
          case 57:
            return 51;
          case 58:
            return 68;
          case 59:
            return 68;
          case 60:
            return 68;
          case 61:
            return 52;
          case 62:
            return 48;
          case 63:
            return 68;
          case 64:
            return 65;
          case 65:
            return 66;
          case 66:
            return 67;
          case 67:
            return 69;
          case 68:
            return 70;
          case 69:
            return 71;
          case 70:
            return 71;
          case 71:
            return 70;
          case 72:
            return 70;
          case 73:
            return 70;
          case 74:
            return 41;
          case 75:
            return 47;
          case 76:
            return 40;
          case 77:
            return o.yytext[0];
          case 78:
            return 6;
        }
      }, "anonymous"),
      rules: [/^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:.*direction\s+TB[^\n]*)/i, /^(?:.*direction\s+BT[^\n]*)/i, /^(?:.*direction\s+RL[^\n]*)/i, /^(?:.*direction\s+LR[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:[\s]+)/i, /^(?:"[^"%\r\n\v\b\\]+")/i, /^(?:"[^"]*")/i, /^(?:erDiagram\b)/i, /^(?:\{)/i, /^(?:#)/i, /^(?:#)/i, /^(?:,)/i, /^(?::::)/i, /^(?::)/i, /^(?:\s+)/i, /^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i, /^(?:([^\s]*)[~].*[~]([^\s]*))/i, /^(?:([\*A-Za-z_\u00C0-\uFFFF][A-Za-z0-9\-\_\[\]\(\)\u00C0-\uFFFF\*]*))/i, /^(?:"[^"]*")/i, /^(?:[\n]+)/i, /^(?:\})/i, /^(?:.)/i, /^(?:\[)/i, /^(?:\])/i, /^(?:style\b)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?::)/i, /^(?:,)/i, /^(?:#)/i, /^(?:classDef\b)/i, /^(?:class\b)/i, /^(?:one or zero\b)/i, /^(?:one or more\b)/i, /^(?:one or many\b)/i, /^(?:1\+)/i, /^(?:\|o\b)/i, /^(?:zero or one\b)/i, /^(?:zero or more\b)/i, /^(?:zero or many\b)/i, /^(?:0\+)/i, /^(?:\}o\b)/i, /^(?:many\(0\))/i, /^(?:many\(1\))/i, /^(?:many\b)/i, /^(?:\}\|)/i, /^(?:one\b)/i, /^(?:only one\b)/i, /^(?:[0-9]+\.[0-9]+)/i, /^(?:1(?=\s+[A-Za-z_"']))/i, /^(?:1(?=\s+[0-9]))/i, /^(?:1(?=(--|\.\.|\.-|-\.)))/i, /^(?:1\b)/i, /^(?:[0-9]+)/i, /^(?:\|\|)/i, /^(?:o\|)/i, /^(?:o\{)/i, /^(?:\|\{)/i, /^(?:u(?=[\.\-\|]))/i, /^(?:\.\.)/i, /^(?:--)/i, /^(?:to\b)/i, /^(?:optionally to\b)/i, /^(?:\.-)/i, /^(?:-\.)/i, /^(?:([^\x00-\x7F]|\w|-|\*)+)/i, /^(?:;)/i, /^(?:([^\x00-\x7F]|\w|-|\*|\.)+)/i, /^(?:.)/i, /^(?:$)/i],
      conditions: { style: { rules: [34, 35, 36, 37, 38, 74, 75], inclusive: !1 }, acc_descr_multiline: { rules: [5, 6], inclusive: !1 }, acc_descr: { rules: [3], inclusive: !1 }, acc_title: { rules: [1], inclusive: !1 }, block: { rules: [23, 24, 25, 26, 27, 28, 29, 30], inclusive: !1 }, INITIAL: { rules: [0, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 31, 32, 33, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 76, 77, 78], inclusive: !0 } }
    };
    return k;
  }();
  he.lexer = xe;
  function q() {
    this.yy = {};
  }
  return l(q, "Parser"), q.prototype = he, he.Parser = q, new q();
}();
ge.parser = ge;
var Ve = ge, _e, et = (_e = class {
  constructor() {
    this.entities = /* @__PURE__ */ new Map(), this.relationships = [], this.classes = /* @__PURE__ */ new Map(), this.direction = "TB", this.Cardinality = {
      ZERO_OR_ONE: "ZERO_OR_ONE",
      ZERO_OR_MORE: "ZERO_OR_MORE",
      ONE_OR_MORE: "ONE_OR_MORE",
      ONLY_ONE: "ONLY_ONE",
      MD_PARENT: "MD_PARENT"
    }, this.Identification = {
      NON_IDENTIFYING: "NON_IDENTIFYING",
      IDENTIFYING: "IDENTIFYING"
    }, this.setAccTitle = Fe, this.getAccTitle = Ye, this.setAccDescription = Pe, this.getAccDescription = ze, this.setDiagramTitle = Ge, this.getDiagramTitle = Ke, this.getConfig = /* @__PURE__ */ l(() => te().er, "getConfig"), this.clear(), this.addEntity = this.addEntity.bind(this), this.addAttributes = this.addAttributes.bind(this), this.addRelationship = this.addRelationship.bind(this), this.setDirection = this.setDirection.bind(this), this.addCssStyles = this.addCssStyles.bind(this), this.addClass = this.addClass.bind(this), this.setClass = this.setClass.bind(this), this.setAccTitle = this.setAccTitle.bind(this), this.setAccDescription = this.setAccDescription.bind(this);
  }
  /**
   * Add entity
   * @param name - The name of the entity
   * @param alias - The alias of the entity
   */
  addEntity(t, i = "") {
    var c;
    return this.entities.has(t) ? !((c = this.entities.get(t)) != null && c.alias) && i && (this.entities.get(t).alias = i, v.info(`Add alias '${i}' to entity '${t}'`)) : (this.entities.set(t, {
      id: `entity-${t}-${this.entities.size}`,
      label: t,
      attributes: [],
      alias: i,
      shape: "erBox",
      look: te().look ?? "default",
      cssClasses: "default",
      cssStyles: [],
      labelType: "markdown"
    }), v.info("Added new entity :", t)), this.entities.get(t);
  }
  getEntity(t) {
    return this.entities.get(t);
  }
  getEntities() {
    return this.entities;
  }
  getClasses() {
    return this.classes;
  }
  addAttributes(t, i) {
    const c = this.addEntity(t);
    let a;
    for (a = i.length - 1; a >= 0; a--)
      i[a].keys || (i[a].keys = []), i[a].comment || (i[a].comment = ""), c.attributes.push(i[a]), v.debug("Added attribute ", i[a].name);
  }
  /**
   * Add a relationship
   *
   * @param entA - The first entity in the relationship
   * @param rolA - The role played by the first entity in relation to the second
   * @param entB - The second entity in the relationship
   * @param rSpec - The details of the relationship between the two entities
   */
  addRelationship(t, i, c, a) {
    const u = this.entities.get(t), h = this.entities.get(c);
    if (!u || !h)
      return;
    const p = {
      entityA: u.id,
      roleA: i,
      entityB: h.id,
      relSpec: a
    };
    this.relationships.push(p), v.debug("Added new relationship :", p);
  }
  getRelationships() {
    return this.relationships;
  }
  getDirection() {
    return this.direction;
  }
  setDirection(t) {
    this.direction = t;
  }
  getCompiledStyles(t) {
    let i = [];
    for (const c of t) {
      const a = this.classes.get(c);
      a != null && a.styles && (i = [...i, ...a.styles ?? []].map((u) => u.trim())), a != null && a.textStyles && (i = [...i, ...a.textStyles ?? []].map((u) => u.trim()));
    }
    return i;
  }
  addCssStyles(t, i) {
    for (const c of t) {
      const a = this.entities.get(c);
      if (!i || !a)
        return;
      for (const u of i)
        a.cssStyles.push(u);
    }
  }
  addClass(t, i) {
    t.forEach((c) => {
      let a = this.classes.get(c);
      a === void 0 && (a = { id: c, styles: [], textStyles: [] }, this.classes.set(c, a)), i && i.forEach(function(u) {
        if (/color/.exec(u)) {
          const h = u.replace("fill", "bgFill");
          a.textStyles.push(h);
        }
        a.styles.push(u);
      });
    });
  }
  setClass(t, i) {
    for (const c of t) {
      const a = this.entities.get(c);
      if (a)
        for (const u of i)
          a.cssClasses += " " + u;
    }
  }
  clear() {
    this.entities = /* @__PURE__ */ new Map(), this.classes = /* @__PURE__ */ new Map(), this.relationships = [], Ue();
  }
  getData() {
    const t = [], i = [], c = te();
    let a = 0;
    for (const h of this.entities.keys()) {
      const p = this.entities.get(h);
      p && (p.cssCompiledStyles = this.getCompiledStyles(p.cssClasses.split(" ")), p.colorIndex = a++, t.push(p));
    }
    let u = 0;
    for (const h of this.relationships) {
      const p = {
        id: Ze(h.entityA, h.entityB, {
          prefix: "id",
          counter: u++
        }),
        type: "normal",
        curve: "basis",
        start: h.entityA,
        end: h.entityB,
        label: h.roleA,
        labelpos: "c",
        thickness: "normal",
        classes: "relationshipLine",
        arrowTypeStart: h.relSpec.cardB.toLowerCase(),
        arrowTypeEnd: h.relSpec.cardA.toLowerCase(),
        pattern: h.relSpec.relType == "IDENTIFYING" ? "solid" : "dashed",
        look: c.look,
        labelType: "markdown"
      };
      i.push(p);
    }
    return { nodes: t, edges: i, other: {}, config: c, direction: "TB" };
  }
}, l(_e, "ErDB"), _e), Ce = {};
We(Ce, {
  draw: () => tt
});
var tt = /* @__PURE__ */ l(async function(t, i, c, a) {
  v.info("REF0:"), v.info("Drawing er diagram (unified)", i);
  const { securityLevel: u, er: h, layout: p } = te(), y = a.db.getData(), E = we(i, u);
  y.type = a.type, y.layoutAlgorithm = Xe(p), y.config.flowchart.nodeSpacing = (h == null ? void 0 : h.nodeSpacing) || 140, y.config.flowchart.rankSpacing = (h == null ? void 0 : h.rankSpacing) || 80, y.direction = a.db.getDirection();
  const { config: Z } = y, { look: j } = Z;
  j === "neo" ? y.markers = [
    "only_one_neo",
    "zero_or_one_neo",
    "one_or_more_neo",
    "zero_or_more_neo"
  ] : y.markers = ["only_one", "zero_or_one", "one_or_more", "zero_or_more"], y.diagramId = i, await Qe(y, E), y.layoutAlgorithm === "elk" && E.select(".edges").lower();
  const O = E.selectAll('[id*="-background"]');
  Array.from(O).length > 0 && O.each(function() {
    const M = He(this), I = M.attr("id").replace("-background", ""), S = E.select(`#${CSS.escape(I)}`);
    if (!S.empty()) {
      const R = S.attr("transform");
      M.attr("transform", R);
    }
  }), qe.insertTitle(
    E,
    "erDiagramTitleText",
    (h == null ? void 0 : h.titleTopMargin) ?? 25,
    a.db.getDiagramTitle()
  ), Be(E, 8, "erDiagram", (h == null ? void 0 : h.useMaxWidth) ?? !0);
}, "draw"), Re = /* @__PURE__ */ l((t, i) => {
  const c = Je, a = c(t, "r"), u = c(t, "g"), h = c(t, "b");
  return je(a, u, h, i);
}, "fade"), se = /* @__PURE__ */ new Set(["redux-color", "redux-dark-color"]), st = /* @__PURE__ */ l((t) => {
  const { theme: i, look: c, bkgColorArray: a, borderColorArray: u } = t;
  if (!se.has(i))
    return "";
  const h = (a == null ? void 0 : a.length) > 0;
  let p = "";
  for (let y = 0; y < t.THEME_COLOR_LIMIT; y++)
    p += `

    [data-look="${c}"][data-color-id="color-${y}"].node path {
    stroke: ${u[y]};
    ${h ? `fill: ${a[y]};` : ""}
    }

    [data-look="${c}"][data-color-id="color-${y}"].node  rect {
    stroke: ${u[y]};
    ${h ? `fill: ${a[y]};` : ""}
     }
    `;
  return p;
}, "genColor"), it = /* @__PURE__ */ l((t) => {
  const { look: i, theme: c, erEdgeLabelBackground: a, strokeWidth: u } = t;
  return `
    ${st(t)}
  .entityBox {
    fill: ${t.mainBkg};
    stroke: ${t.nodeBorder};
  }

  .relationshipLabelBox {
    fill: ${t.tertiaryColor};
    opacity: 0.7;
    background-color: ${t.tertiaryColor};
      rect {
        opacity: 0.5;
      }
  }

  .labelBkg {
    background-color: ${se.has(c) && a ? a : Re(t.tertiaryColor, 0.5)};
  }

  .edgeLabel {
    background-color: ${se.has(c) && a ? a : t.edgeLabelBackground};
  }
  .edgeLabel .label rect {
    fill: ${se.has(c) && a ? a : t.edgeLabelBackground};
  }
  .edgeLabel .label text {
    fill: ${t.textColor};
  }

  .edgeLabel .label {
    fill: ${t.nodeBorder};
    font-size: 14px;
  }

  .label {
    font-family: ${t.fontFamily};
    color: ${t.nodeTextColor || t.textColor};
  }

  .edge-pattern-dashed {
    stroke-dasharray: 8,8;
  }

  .node rect,
  .node circle,
  .node ellipse,
  .node polygon
  {
    fill: ${t.mainBkg};
    stroke: ${t.nodeBorder};
    stroke-width: ${i === "neo" ? u : "1px"};
  }

  .relationshipLine {
    stroke: ${t.lineColor};
    stroke-width: ${i === "neo" ? u : "1px"};
    fill: none;
  }

  .marker {
    fill: none !important;
    stroke: ${t.lineColor} !important;
    stroke-width: 1;
  }
  [data-look=neo].labelBkg {
    background-color: ${Re(t.tertiaryColor, 0.5)};
  }
`;
}, "getStyles"), nt = it, lt = {
  parser: Ve,
  get db() {
    return new et();
  },
  renderer: Ce,
  styles: nt
};
export {
  lt as diagram
};
