import "./purify.es-DT70lfR0.js";
import "./chunk-S3R3BYOJ-mQeCz5CE.js";
import { i as log, r as __name } from "./src-Bf2iLOlr.js";
import { G as setupGraphViewbox, I as sanitizeText, Q as is_dark_default, X as darken_default, Z as lighten_default, b as getConfig2, d as defaultConfig_default } from "./chunk-ABZYJK2D-D0cLy8Bb.js";
import { t as selectSvgElement } from "./chunk-EXTU4WIE-BKNXdLmD.js";
import { n as load, t as JSON_SCHEMA } from "./chunk-MI3HLSF2-CUYEasXO.js";
import "./chunk-CVBHYZKI-B_c5YBcW.js";
import "./chunk-ATLVNIR6-BXsEjlHF.js";
import "./dist-BGdYVvOu.js";
import "./chunk-JA3XYJ7Z-D6c6cOBG.js";
import { a as insertNode, c as positionNode, i as insertCluster } from "./chunk-JZLCHNYA-BvsPHJmL.js";
import { t as getIconStyles } from "./chunk-FMBD7UC4-Ie8M9q0W.js";
var parser = (function() {
  var e = /* @__PURE__ */ __name(function(e2, t, n2, r2) {
    for (n2 || (n2 = {}), r2 = e2.length; r2--; n2[e2[r2]] = t) ;
    return n2;
  }, "o"), n = [1, 4], r = [1, 13], i = [1, 12], a = [1, 15], o = [1, 16], s = [1, 20], c = [1, 19], l = [
    6,
    7,
    8
  ], u = [1, 26], d = [1, 24], f = [1, 25], p = [
    6,
    7,
    11
  ], m = [1, 31], h = [
    6,
    7,
    11,
    24
  ], g = [
    1,
    6,
    13,
    16,
    17,
    20,
    23
  ], _ = [1, 35], v = [1, 36], y = [
    1,
    6,
    7,
    11,
    13,
    16,
    17,
    20,
    23
  ], b = [1, 38], x = {
    trace: /* @__PURE__ */ __name(function() {
    }, "trace"),
    yy: {},
    symbols_: {
      error: 2,
      start: 3,
      mindMap: 4,
      spaceLines: 5,
      SPACELINE: 6,
      NL: 7,
      KANBAN: 8,
      document: 9,
      stop: 10,
      EOF: 11,
      statement: 12,
      SPACELIST: 13,
      node: 14,
      shapeData: 15,
      ICON: 16,
      CLASS: 17,
      nodeWithId: 18,
      nodeWithoutId: 19,
      NODE_DSTART: 20,
      NODE_DESCR: 21,
      NODE_DEND: 22,
      NODE_ID: 23,
      SHAPE_DATA: 24,
      $accept: 0,
      $end: 1
    },
    terminals_: {
      2: "error",
      6: "SPACELINE",
      7: "NL",
      8: "KANBAN",
      11: "EOF",
      13: "SPACELIST",
      16: "ICON",
      17: "CLASS",
      20: "NODE_DSTART",
      21: "NODE_DESCR",
      22: "NODE_DEND",
      23: "NODE_ID",
      24: "SHAPE_DATA"
    },
    productions_: [
      0,
      [3, 1],
      [3, 2],
      [5, 1],
      [5, 2],
      [5, 2],
      [4, 2],
      [4, 3],
      [10, 1],
      [10, 1],
      [10, 1],
      [10, 2],
      [10, 2],
      [9, 3],
      [9, 2],
      [12, 3],
      [12, 2],
      [12, 2],
      [12, 2],
      [12, 1],
      [12, 2],
      [12, 1],
      [12, 1],
      [12, 1],
      [12, 1],
      [14, 1],
      [14, 1],
      [19, 3],
      [18, 1],
      [18, 4],
      [15, 2],
      [15, 1]
    ],
    performAction: /* @__PURE__ */ __name(function(e2, t, n2, r2, i2, a2, o2) {
      var s2 = a2.length - 1;
      switch (i2) {
        case 6:
        case 7:
          return r2;
        case 8:
          r2.getLogger().trace("Stop NL ");
          break;
        case 9:
          r2.getLogger().trace("Stop EOF ");
          break;
        case 11:
          r2.getLogger().trace("Stop NL2 ");
          break;
        case 12:
          r2.getLogger().trace("Stop EOF2 ");
          break;
        case 15:
          r2.getLogger().info("Node: ", a2[s2 - 1].id), r2.addNode(a2[s2 - 2].length, a2[s2 - 1].id, a2[s2 - 1].descr, a2[s2 - 1].type, a2[s2]);
          break;
        case 16:
          r2.getLogger().info("Node: ", a2[s2].id), r2.addNode(a2[s2 - 1].length, a2[s2].id, a2[s2].descr, a2[s2].type);
          break;
        case 17:
          r2.getLogger().trace("Icon: ", a2[s2]), r2.decorateNode({ icon: a2[s2] });
          break;
        case 18:
        case 23:
          r2.decorateNode({ class: a2[s2] });
          break;
        case 19:
          r2.getLogger().trace("SPACELIST");
          break;
        case 20:
          r2.getLogger().trace("Node: ", a2[s2 - 1].id), r2.addNode(0, a2[s2 - 1].id, a2[s2 - 1].descr, a2[s2 - 1].type, a2[s2]);
          break;
        case 21:
          r2.getLogger().trace("Node: ", a2[s2].id), r2.addNode(0, a2[s2].id, a2[s2].descr, a2[s2].type);
          break;
        case 22:
          r2.decorateNode({ icon: a2[s2] });
          break;
        case 27:
          r2.getLogger().trace("node found ..", a2[s2 - 2]), this.$ = {
            id: a2[s2 - 1],
            descr: a2[s2 - 1],
            type: r2.getType(a2[s2 - 2], a2[s2])
          };
          break;
        case 28:
          this.$ = {
            id: a2[s2],
            descr: a2[s2],
            type: 0
          };
          break;
        case 29:
          r2.getLogger().trace("node found ..", a2[s2 - 3]), this.$ = {
            id: a2[s2 - 3],
            descr: a2[s2 - 1],
            type: r2.getType(a2[s2 - 2], a2[s2])
          };
          break;
        case 30:
          this.$ = a2[s2 - 1] + a2[s2];
          break;
        case 31:
          this.$ = a2[s2];
          break;
      }
    }, "anonymous"),
    table: [
      {
        3: 1,
        4: 2,
        5: 3,
        6: [1, 5],
        8: n
      },
      { 1: [3] },
      { 1: [2, 1] },
      {
        4: 6,
        6: [1, 7],
        7: [1, 8],
        8: n
      },
      {
        6: r,
        7: [1, 10],
        9: 9,
        12: 11,
        13: i,
        14: 14,
        16: a,
        17: o,
        18: 17,
        19: 18,
        20: s,
        23: c
      },
      e(l, [2, 3]),
      { 1: [2, 2] },
      e(l, [2, 4]),
      e(l, [2, 5]),
      {
        1: [2, 6],
        6: r,
        12: 21,
        13: i,
        14: 14,
        16: a,
        17: o,
        18: 17,
        19: 18,
        20: s,
        23: c
      },
      {
        6: r,
        9: 22,
        12: 11,
        13: i,
        14: 14,
        16: a,
        17: o,
        18: 17,
        19: 18,
        20: s,
        23: c
      },
      {
        6: u,
        7: d,
        10: 23,
        11: f
      },
      e(p, [2, 24], {
        18: 17,
        19: 18,
        14: 27,
        16: [1, 28],
        17: [1, 29],
        20: s,
        23: c
      }),
      e(p, [2, 19]),
      e(p, [2, 21], {
        15: 30,
        24: m
      }),
      e(p, [2, 22]),
      e(p, [2, 23]),
      e(h, [2, 25]),
      e(h, [2, 26]),
      e(h, [2, 28], { 20: [1, 32] }),
      { 21: [1, 33] },
      {
        6: u,
        7: d,
        10: 34,
        11: f
      },
      {
        1: [2, 7],
        6: r,
        12: 21,
        13: i,
        14: 14,
        16: a,
        17: o,
        18: 17,
        19: 18,
        20: s,
        23: c
      },
      e(g, [2, 14], {
        7: _,
        11: v
      }),
      e(y, [2, 8]),
      e(y, [2, 9]),
      e(y, [2, 10]),
      e(p, [2, 16], {
        15: 37,
        24: m
      }),
      e(p, [2, 17]),
      e(p, [2, 18]),
      e(p, [2, 20], { 24: b }),
      e(h, [2, 31]),
      { 21: [1, 39] },
      { 22: [1, 40] },
      e(g, [2, 13], {
        7: _,
        11: v
      }),
      e(y, [2, 11]),
      e(y, [2, 12]),
      e(p, [2, 15], { 24: b }),
      e(h, [2, 30]),
      { 22: [1, 41] },
      e(h, [2, 27]),
      e(h, [2, 29])
    ],
    defaultActions: {
      2: [2, 1],
      6: [2, 2]
    },
    parseError: /* @__PURE__ */ __name(function(e2, t) {
      if (t.recoverable) this.trace(e2);
      else {
        var n2 = Error(e2);
        throw n2.hash = t, n2;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ __name(function(e2) {
      var n2 = this, r2 = [0], i2 = [], a2 = [null], o2 = [], s2 = this.table, c2 = "", l2 = 0, u2 = 0, d2 = 0, f2 = 2, p2 = 1, m2 = o2.slice.call(arguments, 1), h2 = Object.create(this.lexer), g2 = { yy: {} };
      for (var _2 in this.yy) Object.prototype.hasOwnProperty.call(this.yy, _2) && (g2.yy[_2] = this.yy[_2]);
      h2.setInput(e2, g2.yy), g2.yy.lexer = h2, g2.yy.parser = this, h2.yylloc === void 0 && (h2.yylloc = {});
      var v2 = h2.yylloc;
      o2.push(v2);
      var y2 = h2.options && h2.options.ranges;
      typeof g2.yy.parseError == "function" ? this.parseError = g2.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function b2(e3) {
        r2.length -= 2 * e3, a2.length -= e3, o2.length -= e3;
      }
      __name(b2, "popStack");
      function x2() {
        var e3 = i2.pop() || h2.lex() || p2;
        return typeof e3 != "number" && (e3 instanceof Array && (i2 = e3, e3 = i2.pop()), e3 = n2.symbols_[e3] || e3), e3;
      }
      __name(x2, "lex");
      for (var S2, C, w, T, E, D = {}, O, k, A, j; ; ) {
        if (w = r2[r2.length - 1], this.defaultActions[w] ? T = this.defaultActions[w] : (S2 ?? (S2 = x2()), T = s2[w] && s2[w][S2]), T === void 0 || !T.length || !T[0]) {
          var M = "";
          for (O in j = [], s2[w]) this.terminals_[O] && O > f2 && j.push("'" + this.terminals_[O] + "'");
          M = h2.showPosition ? "Parse error on line " + (l2 + 1) + ":\n" + h2.showPosition() + "\nExpecting " + j.join(", ") + ", got '" + (this.terminals_[S2] || S2) + "'" : "Parse error on line " + (l2 + 1) + ": Unexpected " + (S2 == p2 ? "end of input" : "'" + (this.terminals_[S2] || S2) + "'"), this.parseError(M, {
            text: h2.match,
            token: this.terminals_[S2] || S2,
            line: h2.yylineno,
            loc: v2,
            expected: j
          });
        }
        if (T[0] instanceof Array && T.length > 1) throw Error("Parse Error: multiple actions possible at state: " + w + ", token: " + S2);
        switch (T[0]) {
          case 1:
            r2.push(S2), a2.push(h2.yytext), o2.push(h2.yylloc), r2.push(T[1]), S2 = null, C ? (S2 = C, C = null) : (u2 = h2.yyleng, c2 = h2.yytext, l2 = h2.yylineno, v2 = h2.yylloc, d2 > 0 && d2--);
            break;
          case 2:
            if (k = this.productions_[T[1]][1], D.$ = a2[a2.length - k], D._$ = {
              first_line: o2[o2.length - (k || 1)].first_line,
              last_line: o2[o2.length - 1].last_line,
              first_column: o2[o2.length - (k || 1)].first_column,
              last_column: o2[o2.length - 1].last_column
            }, y2 && (D._$.range = [o2[o2.length - (k || 1)].range[0], o2[o2.length - 1].range[1]]), E = this.performAction.apply(D, [
              c2,
              u2,
              l2,
              g2.yy,
              T[1],
              a2,
              o2
            ].concat(m2)), E !== void 0) return E;
            k && (r2 = r2.slice(0, -1 * k * 2), a2 = a2.slice(0, -1 * k), o2 = o2.slice(0, -1 * k)), r2.push(this.productions_[T[1]][0]), a2.push(D.$), o2.push(D._$), A = s2[r2[r2.length - 2]][r2[r2.length - 1]], r2.push(A);
            break;
          case 3:
            return true;
        }
      }
      return true;
    }, "parse")
  };
  x.lexer = /* @__PURE__ */ (function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ __name(function(e2, t) {
        if (this.yy.parser) this.yy.parser.parseError(e2, t);
        else throw Error(e2);
      }, "parseError"),
      setInput: /* @__PURE__ */ __name(function(e2, t) {
        return this.yy = t || this.yy || {}, this._input = e2, this._more = this._backtrack = this.done = false, 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"),
      input: /* @__PURE__ */ __name(function() {
        var e2 = this._input[0];
        return this.yytext += e2, this.yyleng++, this.offset++, this.match += e2, this.matched += e2, e2.match(/(?:\r\n?|\n).*/g) ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), e2;
      }, "input"),
      unput: /* @__PURE__ */ __name(function(e2) {
        var t = e2.length, n2 = e2.split(/(?:\r\n?|\n)/g);
        this._input = e2 + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - t), this.offset -= t;
        var r2 = 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), n2.length - 1 && (this.yylineno -= n2.length - 1);
        var i2 = 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: n2 ? (n2.length === r2.length ? this.yylloc.first_column : 0) + r2[r2.length - n2.length].length - n2[0].length : this.yylloc.first_column - t
        }, this.options.ranges && (this.yylloc.range = [i2[0], i2[0] + this.yyleng - t]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ __name(function() {
        return this._more = true, this;
      }, "more"),
      reject: /* @__PURE__ */ __name(function() {
        if (this.options.backtrack_lexer) this._backtrack = true;
        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).\n" + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
        return this;
      }, "reject"),
      less: /* @__PURE__ */ __name(function(e2) {
        this.unput(this.match.slice(e2));
      }, "less"),
      pastInput: /* @__PURE__ */ __name(function() {
        var e2 = this.matched.substr(0, this.matched.length - this.match.length);
        return (e2.length > 20 ? "..." : "") + e2.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ __name(function() {
        var e2 = this.match;
        return e2.length < 20 && (e2 += this._input.substr(0, 20 - e2.length)), (e2.substr(0, 20) + (e2.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ __name(function() {
        var e2 = this.pastInput(), t = Array(e2.length + 1).join("-");
        return e2 + this.upcomingInput() + "\n" + t + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ __name(function(e2, t) {
        var n2, r2, i2;
        if (this.options.backtrack_lexer && (i2 = {
          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 && (i2.yylloc.range = this.yylloc.range.slice(0))), r2 = e2[0].match(/(?:\r\n?|\n).*/g), r2 && (this.yylineno += r2.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: r2 ? r2[r2.length - 1].length - r2[r2.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + e2[0].length
        }, this.yytext += e2[0], this.match += e2[0], this.matches = e2, this.yyleng = this.yytext.length, this.options.ranges && (this.yylloc.range = [this.offset, this.offset += this.yyleng]), this._more = false, this._backtrack = false, this._input = this._input.slice(e2[0].length), this.matched += e2[0], n2 = this.performAction.call(this, this.yy, this, t, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = false), n2) return n2;
        if (this._backtrack) {
          for (var a2 in i2) this[a2] = i2[a2];
          return false;
        }
        return false;
      }, "test_match"),
      next: /* @__PURE__ */ __name(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = true);
        var e2, t, n2, r2;
        this._more || (this.yytext = "", this.match = "");
        for (var i2 = this._currentRules(), a2 = 0; a2 < i2.length; a2++) if (n2 = this._input.match(this.rules[i2[a2]]), n2 && (!t || n2[0].length > t[0].length)) {
          if (t = n2, r2 = a2, this.options.backtrack_lexer) {
            if (e2 = this.test_match(n2, i2[a2]), e2 !== false) return e2;
            if (this._backtrack) {
              t = false;
              continue;
            } else return false;
          } else if (!this.options.flex) break;
        }
        return t ? (e2 = this.test_match(t, i2[r2]), e2 === false ? false : e2) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      lex: /* @__PURE__ */ __name(function() {
        return this.next() || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ __name(function(e2) {
        this.conditionStack.push(e2);
      }, "begin"),
      popState: /* @__PURE__ */ __name(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ __name(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"),
      topState: /* @__PURE__ */ __name(function(e2) {
        return e2 = this.conditionStack.length - 1 - Math.abs(e2 || 0), e2 >= 0 ? this.conditionStack[e2] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ __name(function(e2) {
        this.begin(e2);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ __name(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": true },
      performAction: /* @__PURE__ */ __name(function(e2, t, n2, r2) {
        switch (n2) {
          case 0:
            return this.pushState("shapeData"), t.yytext = "", 24;
          case 1:
            return this.pushState("shapeDataStr"), 24;
          case 2:
            return this.popState(), 24;
          case 3:
            return t.yytext = t.yytext.replace(/\n\s*/g, "<br/>"), 24;
          case 4:
            return 24;
          case 5:
            this.popState();
            break;
          case 6:
            return e2.getLogger().trace("Found comment", t.yytext), 6;
          case 7:
            return 8;
          case 8:
            this.begin("CLASS");
            break;
          case 9:
            return this.popState(), 17;
          case 10:
            this.popState();
            break;
          case 11:
            e2.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 12:
            return e2.getLogger().trace("SPACELINE"), 6;
          case 13:
            return 7;
          case 14:
            return 16;
          case 15:
            e2.getLogger().trace("end icon"), this.popState();
            break;
          case 16:
            return e2.getLogger().trace("Exploding node"), this.begin("NODE"), 20;
          case 17:
            return e2.getLogger().trace("Cloud"), this.begin("NODE"), 20;
          case 18:
            return e2.getLogger().trace("Explosion Bang"), this.begin("NODE"), 20;
          case 19:
            return e2.getLogger().trace("Cloud Bang"), this.begin("NODE"), 20;
          case 20:
            return this.begin("NODE"), 20;
          case 21:
            return this.begin("NODE"), 20;
          case 22:
            return this.begin("NODE"), 20;
          case 23:
            return this.begin("NODE"), 20;
          case 24:
            return 13;
          case 25:
            return 23;
          case 26:
            return 11;
          case 27:
            this.begin("NSTR2");
            break;
          case 28:
            return "NODE_DESCR";
          case 29:
            this.popState();
            break;
          case 30:
            e2.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 31:
            return e2.getLogger().trace("description:", t.yytext), "NODE_DESCR";
          case 32:
            this.popState();
            break;
          case 33:
            return this.popState(), e2.getLogger().trace("node end ))"), "NODE_DEND";
          case 34:
            return this.popState(), e2.getLogger().trace("node end )"), "NODE_DEND";
          case 35:
            return this.popState(), e2.getLogger().trace("node end ...", t.yytext), "NODE_DEND";
          case 36:
            return this.popState(), e2.getLogger().trace("node end (("), "NODE_DEND";
          case 37:
            return this.popState(), e2.getLogger().trace("node end (-"), "NODE_DEND";
          case 38:
            return this.popState(), e2.getLogger().trace("node end (-"), "NODE_DEND";
          case 39:
            return this.popState(), e2.getLogger().trace("node end (("), "NODE_DEND";
          case 40:
            return this.popState(), e2.getLogger().trace("node end (("), "NODE_DEND";
          case 41:
            return e2.getLogger().trace("Long description:", t.yytext), 21;
          case 42:
            return e2.getLogger().trace("Long description:", t.yytext), 21;
        }
      }, "anonymous"),
      rules: [
        /^(?:@\{)/i,
        /^(?:["])/i,
        /^(?:["])/i,
        /^(?:[^\"]+)/i,
        /^(?:[^}^"]+)/i,
        /^(?:\})/i,
        /^(?:\s*%%.*)/i,
        /^(?:kanban\b)/i,
        /^(?::::)/i,
        /^(?:.+)/i,
        /^(?:\n)/i,
        /^(?:::icon\()/i,
        /^(?:[\s]+[\n])/i,
        /^(?:[\n]+)/i,
        /^(?:[^\)]+)/i,
        /^(?:\))/i,
        /^(?:-\))/i,
        /^(?:\(-)/i,
        /^(?:\)\))/i,
        /^(?:\))/i,
        /^(?:\(\()/i,
        /^(?:\{\{)/i,
        /^(?:\()/i,
        /^(?:\[)/i,
        /^(?:[\s]+)/i,
        /^(?:[^\(\[\n\)\{\}@]+)/i,
        /^(?:$)/i,
        /^(?:["][`])/i,
        /^(?:[^`"]+)/i,
        /^(?:[`]["])/i,
        /^(?:["])/i,
        /^(?:[^"]+)/i,
        /^(?:["])/i,
        /^(?:[\)]\))/i,
        /^(?:[\)])/i,
        /^(?:[\]])/i,
        /^(?:\}\})/i,
        /^(?:\(-)/i,
        /^(?:-\))/i,
        /^(?:\(\()/i,
        /^(?:\()/i,
        /^(?:[^\)\]\(\}]+)/i,
        /^(?:.+(?!\(\())/i
      ],
      conditions: {
        shapeDataEndBracket: {
          rules: [],
          inclusive: false
        },
        shapeDataStr: {
          rules: [2, 3],
          inclusive: false
        },
        shapeData: {
          rules: [
            1,
            4,
            5
          ],
          inclusive: false
        },
        CLASS: {
          rules: [9, 10],
          inclusive: false
        },
        ICON: {
          rules: [14, 15],
          inclusive: false
        },
        NSTR2: {
          rules: [28, 29],
          inclusive: false
        },
        NSTR: {
          rules: [31, 32],
          inclusive: false
        },
        NODE: {
          rules: [
            27,
            30,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42
          ],
          inclusive: false
        },
        INITIAL: {
          rules: [
            0,
            6,
            7,
            8,
            11,
            12,
            13,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ],
          inclusive: true
        }
      }
    };
  })();
  function S() {
    this.yy = {};
  }
  return __name(S, "Parser"), S.prototype = x, x.Parser = S, new S();
})();
parser.parser = parser;
var kanban_default = parser, nodes = [], sections = [], cnt = 0, elements = {}, clear = /* @__PURE__ */ __name(() => {
  nodes = [], sections = [], cnt = 0, elements = {};
}, "clear"), getSection = /* @__PURE__ */ __name((e) => {
  if (nodes.length === 0) return null;
  let t = nodes[0].level, n = null;
  for (let e2 = nodes.length - 1; e2 >= 0; e2--) if (nodes[e2].level === t && !n && (n = nodes[e2]), nodes[e2].level < t) throw Error('Items without section detected, found section ("' + nodes[e2].label + '")');
  return e === (n == null ? void 0 : n.level) ? null : n;
}, "getSection"), getSections = /* @__PURE__ */ __name(function() {
  return sections;
}, "getSections"), getData = /* @__PURE__ */ __name(function() {
  let e = [], t = [], n = getSections(), i = getConfig2();
  for (let e2 of n) {
    let n2 = {
      id: e2.id,
      label: sanitizeText(e2.label ?? "", i),
      isGroup: true,
      ticket: e2.ticket,
      shape: "kanbanSection",
      level: e2.level,
      look: i.look
    };
    t.push(n2);
    let a = nodes.filter((t2) => t2.parentId === e2.id);
    for (let n3 of a) {
      let a2 = {
        id: n3.id,
        parentId: e2.id,
        label: sanitizeText(n3.label ?? "", i),
        isGroup: false,
        ticket: n3 == null ? void 0 : n3.ticket,
        priority: n3 == null ? void 0 : n3.priority,
        assigned: n3 == null ? void 0 : n3.assigned,
        icon: n3 == null ? void 0 : n3.icon,
        shape: "kanbanItem",
        level: n3.level,
        rx: 5,
        ry: 5,
        cssStyles: ["text-align: left"]
      };
      t.push(a2);
    }
  }
  return {
    nodes: t,
    edges: e,
    other: {},
    config: getConfig2()
  };
}, "getData"), addNode = /* @__PURE__ */ __name((e, t, n, i, a) => {
  var _a, _b;
  let o = getConfig2(), l = ((_a = o.mindmap) == null ? void 0 : _a.padding) ?? defaultConfig_default.mindmap.padding;
  switch (i) {
    case nodeType.ROUNDED_RECT:
    case nodeType.RECT:
    case nodeType.HEXAGON:
      l *= 2;
  }
  let f = {
    id: sanitizeText(t, o) || "kbn" + cnt++,
    level: e,
    label: sanitizeText(n, o),
    width: ((_b = o.mindmap) == null ? void 0 : _b.maxNodeWidth) ?? defaultConfig_default.mindmap.maxNodeWidth,
    padding: l,
    isGroup: false
  };
  if (a !== void 0) {
    let e2;
    e2 = a.includes("\n") ? a + "\n" : "{\n" + a + "\n}";
    let t2 = load(e2, { schema: JSON_SCHEMA });
    if (t2.shape && (t2.shape !== t2.shape.toLowerCase() || t2.shape.includes("_"))) throw Error(`No such shape: ${t2.shape}. Shape names should be lowercase.`);
    (t2 == null ? void 0 : t2.shape) && t2.shape === "kanbanItem" && (f.shape = t2 == null ? void 0 : t2.shape), (t2 == null ? void 0 : t2.label) && (f.label = t2 == null ? void 0 : t2.label), (t2 == null ? void 0 : t2.icon) && (f.icon = t2 == null ? void 0 : t2.icon.toString()), (t2 == null ? void 0 : t2.assigned) && (f.assigned = t2 == null ? void 0 : t2.assigned.toString()), (t2 == null ? void 0 : t2.ticket) && (f.ticket = t2 == null ? void 0 : t2.ticket.toString()), (t2 == null ? void 0 : t2.priority) && (f.priority = t2 == null ? void 0 : t2.priority);
  }
  let p = getSection(e);
  p ? f.parentId = p.id || "kbn" + cnt++ : sections.push(f), nodes.push(f);
}, "addNode"), nodeType = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, kanbanDb_default = {
  clear,
  addNode,
  getSections,
  getData,
  nodeType,
  getType: /* @__PURE__ */ __name((t, n) => {
    switch (log.debug("In get type", t, n), t) {
      case "[":
        return nodeType.RECT;
      case "(":
        return n === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD;
      case "((":
        return nodeType.CIRCLE;
      case ")":
        return nodeType.CLOUD;
      case "))":
        return nodeType.BANG;
      case "{{":
        return nodeType.HEXAGON;
      default:
        return nodeType.DEFAULT;
    }
  }, "getType"),
  setElementForId: /* @__PURE__ */ __name((e, t) => {
    elements[e] = t;
  }, "setElementForId"),
  decorateNode: /* @__PURE__ */ __name((e) => {
    if (!e) return;
    let t = getConfig2(), n = nodes[nodes.length - 1];
    e.icon && (n.icon = sanitizeText(e.icon, t)), e.class && (n.cssClasses = sanitizeText(e.class, t));
  }, "decorateNode"),
  type2Str: /* @__PURE__ */ __name((e) => {
    switch (e) {
      case nodeType.DEFAULT:
        return "no-border";
      case nodeType.RECT:
        return "rect";
      case nodeType.ROUNDED_RECT:
        return "rounded-rect";
      case nodeType.CIRCLE:
        return "circle";
      case nodeType.CLOUD:
        return "cloud";
      case nodeType.BANG:
        return "bang";
      case nodeType.HEXAGON:
        return "hexgon";
      default:
        return "no-border";
    }
  }, "type2Str"),
  getLogger: /* @__PURE__ */ __name(() => log, "getLogger"),
  getElementById: /* @__PURE__ */ __name((e) => elements[e], "getElementById")
}, kanbanRenderer_default = { draw: /* @__PURE__ */ __name(async (t, r, i, a) => {
  var _a, _b, _c, _d, _e;
  log.debug("Rendering kanban diagram\n" + t);
  let o = a.db.getData(), u = getConfig2();
  u.htmlLabels = false;
  let d = selectSvgElement(r), h = d.append("g");
  h.attr("class", "sections");
  let g = d.append("g");
  g.attr("class", "items");
  let _ = o.nodes.filter((e) => e.isGroup), v = 0, y = [], b = 25;
  for (let e of _) {
    let t2 = ((_a = u == null ? void 0 : u.kanban) == null ? void 0 : _a.sectionWidth) || 200;
    v += 1, e.x = t2 * v + (v - 1) * 10 / 2, e.width = t2, e.y = 0, e.height = t2 * 3, e.rx = 5, e.ry = 5, e.cssClasses = e.cssClasses + " section-" + v;
    let n = await insertCluster(h, e);
    b = Math.max(b, (_b = n == null ? void 0 : n.labelBBox) == null ? void 0 : _b.height), y.push(n);
  }
  let x = 0;
  for (let e of _) {
    let t2 = y[x];
    x += 1;
    let n = ((_c = u == null ? void 0 : u.kanban) == null ? void 0 : _c.sectionWidth) || 200, r2 = -n * 3 / 2 + b, i2 = r2, a2 = o.nodes.filter((t3) => t3.parentId === e.id);
    for (let t3 of a2) {
      if (t3.isGroup) throw Error("Groups within groups are not allowed in Kanban diagrams");
      t3.x = e.x, t3.width = n - 1.5 * 10;
      let r3 = (await insertNode(g, t3, { config: u })).node().getBBox();
      t3.y = i2 + r3.height / 2, await positionNode(t3), i2 = t3.y + r3.height / 2 + 10 / 2;
    }
    let s = t2.cluster.select("rect"), c = Math.max(i2 - r2 + 30, 50) + (b - 25);
    s.attr("height", c);
  }
  setupGraphViewbox(void 0, d, ((_d = u.mindmap) == null ? void 0 : _d.padding) ?? defaultConfig_default.kanban.padding, ((_e = u.mindmap) == null ? void 0 : _e.useMaxWidth) ?? defaultConfig_default.kanban.useMaxWidth);
}, "draw") }, genSections = /* @__PURE__ */ __name((e) => {
  let n = "";
  for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) e["lineColor" + t] = e["lineColor" + t] || e["cScaleInv" + t], is_dark_default(e["lineColor" + t]) ? e["lineColor" + t] = lighten_default(e["lineColor" + t], 20) : e["lineColor" + t] = darken_default(e["lineColor" + t], 20);
  let r = /* @__PURE__ */ __name((t, n2) => e.darkMode ? darken_default(t, n2) : lighten_default(t, n2), "adjuster");
  for (let t = 0; t < e.THEME_COLOR_LIMIT; t++) {
    let i = "" + (17 - 3 * t);
    n += `
    .section-${t - 1} rect, .section-${t - 1} path, .section-${t - 1} circle, .section-${t - 1} polygon, .section-${t - 1} path  {
      fill: ${r(e["cScale" + t], 10)};
      stroke: ${r(e["cScale" + t], 10)};

    }
    .section-${t - 1} text {
     fill: ${e["cScaleLabel" + t]};
    }
    .node-icon-${t - 1} {
      font-size: 40px;
      color: ${e["cScaleLabel" + t]};
    }
    .section-edge-${t - 1}{
      stroke: ${e["cScale" + t]};
    }
    .edge-depth-${t - 1}{
      stroke-width: ${i};
    }
    .section-${t - 1} line {
      stroke: ${e["cScaleInv" + t]} ;
      stroke-width: 3;
    }

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }

  .node rect,
  .node circle,
  .node ellipse,
  .node polygon,
  .node path {
    fill: ${e.background};
    stroke: ${e.nodeBorder};
    stroke-width: 1px;
  }

  .kanban-ticket-link {
    fill: ${e.background};
    stroke: ${e.nodeBorder};
    text-decoration: underline;
  }
    `;
  }
  return n;
}, "genSections"), diagram = {
  db: kanbanDb_default,
  renderer: kanbanRenderer_default,
  parser: kanban_default,
  styles: /* @__PURE__ */ __name((e) => `
  .edge {
    stroke-width: 3;
  }
  ${genSections(e)}
  .section-root rect, .section-root path, .section-root circle, .section-root polygon  {
    fill: ${e.git0};
  }
  .section-root text {
    fill: ${e.gitBranchLabel0};
  }
  .icon-container {
    height:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edge {
    fill: none;
  }
  .cluster-label, .label {
    color: ${e.textColor};
    fill: ${e.textColor};
    }
  .kanban-label {
    dy: 1em;
    alignment-baseline: middle;
    text-anchor: middle;
    dominant-baseline: middle;
    text-align: center;
  }
    ${getIconStyles()}
`, "getStyles")
};
export {
  diagram
};
