import { p as o, g as J, Z as M, a0 as yt, ay as ft, az as mt, aA as bt, au as _t, F as X, c as B, j as Et, z as kt, ar as Nt, as as at, at as lt } from "./index-CNUFa5l3.js";
import { t as St } from "./chunk-FMBD7UC4-D_tZ4Dxg-sYcun2W0.js";
var Q = function() {
  var i = /* @__PURE__ */ o(function(t, c, a, r) {
    for (a || (a = {}), r = t.length; r--; a[t[r]] = c) ;
    return a;
  }, "o"), g = [1, 4], p = [1, 13], s = [1, 12], u = [1, 15], y = [1, 16], _ = [1, 20], h = [1, 19], D = [
    6,
    7,
    8
  ], C = [1, 26], L = [1, 24], $ = [1, 25], n = [
    6,
    7,
    11
  ], F = [1, 31], O = [
    6,
    7,
    11,
    24
  ], G = [
    1,
    6,
    13,
    16,
    17,
    20,
    23
  ], U = [1, 35], j = [1, 36], A = [
    1,
    6,
    7,
    11,
    13,
    16,
    17,
    20,
    23
  ], f = [1, 38], I = {
    trace: /* @__PURE__ */ o(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__ */ o(function(t, c, a, r, d, e, w) {
      var l = e.length - 1;
      switch (d) {
        case 6:
        case 7:
          return r;
        case 8:
          r.getLogger().trace("Stop NL ");
          break;
        case 9:
          r.getLogger().trace("Stop EOF ");
          break;
        case 11:
          r.getLogger().trace("Stop NL2 ");
          break;
        case 12:
          r.getLogger().trace("Stop EOF2 ");
          break;
        case 15:
          r.getLogger().info("Node: ", e[l - 1].id), r.addNode(e[l - 2].length, e[l - 1].id, e[l - 1].descr, e[l - 1].type, e[l]);
          break;
        case 16:
          r.getLogger().info("Node: ", e[l].id), r.addNode(e[l - 1].length, e[l].id, e[l].descr, e[l].type);
          break;
        case 17:
          r.getLogger().trace("Icon: ", e[l]), r.decorateNode({ icon: e[l] });
          break;
        case 18:
        case 23:
          r.decorateNode({ class: e[l] });
          break;
        case 19:
          r.getLogger().trace("SPACELIST");
          break;
        case 20:
          r.getLogger().trace("Node: ", e[l - 1].id), r.addNode(0, e[l - 1].id, e[l - 1].descr, e[l - 1].type, e[l]);
          break;
        case 21:
          r.getLogger().trace("Node: ", e[l].id), r.addNode(0, e[l].id, e[l].descr, e[l].type);
          break;
        case 22:
          r.decorateNode({ icon: e[l] });
          break;
        case 27:
          r.getLogger().trace("node found ..", e[l - 2]), this.$ = {
            id: e[l - 1],
            descr: e[l - 1],
            type: r.getType(e[l - 2], e[l])
          };
          break;
        case 28:
          this.$ = {
            id: e[l],
            descr: e[l],
            type: 0
          };
          break;
        case 29:
          r.getLogger().trace("node found ..", e[l - 3]), this.$ = {
            id: e[l - 3],
            descr: e[l - 1],
            type: r.getType(e[l - 2], e[l])
          };
          break;
        case 30:
          this.$ = e[l - 1] + e[l];
          break;
        case 31:
          this.$ = e[l];
          break;
      }
    }, "anonymous"),
    table: [
      {
        3: 1,
        4: 2,
        5: 3,
        6: [1, 5],
        8: g
      },
      { 1: [3] },
      { 1: [2, 1] },
      {
        4: 6,
        6: [1, 7],
        7: [1, 8],
        8: g
      },
      {
        6: p,
        7: [1, 10],
        9: 9,
        12: 11,
        13: s,
        14: 14,
        16: u,
        17: y,
        18: 17,
        19: 18,
        20: _,
        23: h
      },
      i(D, [2, 3]),
      { 1: [2, 2] },
      i(D, [2, 4]),
      i(D, [2, 5]),
      {
        1: [2, 6],
        6: p,
        12: 21,
        13: s,
        14: 14,
        16: u,
        17: y,
        18: 17,
        19: 18,
        20: _,
        23: h
      },
      {
        6: p,
        9: 22,
        12: 11,
        13: s,
        14: 14,
        16: u,
        17: y,
        18: 17,
        19: 18,
        20: _,
        23: h
      },
      {
        6: C,
        7: L,
        10: 23,
        11: $
      },
      i(n, [2, 24], {
        18: 17,
        19: 18,
        14: 27,
        16: [1, 28],
        17: [1, 29],
        20: _,
        23: h
      }),
      i(n, [2, 19]),
      i(n, [2, 21], {
        15: 30,
        24: F
      }),
      i(n, [2, 22]),
      i(n, [2, 23]),
      i(O, [2, 25]),
      i(O, [2, 26]),
      i(O, [2, 28], { 20: [1, 32] }),
      { 21: [1, 33] },
      {
        6: C,
        7: L,
        10: 34,
        11: $
      },
      {
        1: [2, 7],
        6: p,
        12: 21,
        13: s,
        14: 14,
        16: u,
        17: y,
        18: 17,
        19: 18,
        20: _,
        23: h
      },
      i(G, [2, 14], {
        7: U,
        11: j
      }),
      i(A, [2, 8]),
      i(A, [2, 9]),
      i(A, [2, 10]),
      i(n, [2, 16], {
        15: 37,
        24: F
      }),
      i(n, [2, 17]),
      i(n, [2, 18]),
      i(n, [2, 20], { 24: f }),
      i(O, [2, 31]),
      { 21: [1, 39] },
      { 22: [1, 40] },
      i(G, [2, 13], {
        7: U,
        11: j
      }),
      i(A, [2, 11]),
      i(A, [2, 12]),
      i(n, [2, 15], { 24: f }),
      i(O, [2, 30]),
      { 22: [1, 41] },
      i(O, [2, 27]),
      i(O, [2, 29])
    ],
    defaultActions: {
      2: [2, 1],
      6: [2, 2]
    },
    parseError: /* @__PURE__ */ o(function(t, c) {
      if (c.recoverable) this.trace(t);
      else {
        var a = Error(t);
        throw a.hash = c, a;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ o(function(t) {
      var c = this, a = [0], r = [], d = [null], e = [], w = this.table, l = "", H = 0, it = 0, ht = 0, gt = 2, nt = 1, ut = e.slice.call(arguments, 1), b = Object.create(this.lexer), R = { yy: {} };
      for (var K in this.yy) Object.prototype.hasOwnProperty.call(this.yy, K) && (R.yy[K] = this.yy[K]);
      b.setInput(t, R.yy), R.yy.lexer = b, R.yy.parser = this, b.yylloc === void 0 && (b.yylloc = {});
      var Z = b.yylloc;
      e.push(Z);
      var dt = b.options && b.options.ranges;
      typeof R.yy.parseError == "function" ? this.parseError = R.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function pt(S) {
        a.length -= 2 * S, d.length -= S, e.length -= S;
      }
      o(pt, "popStack");
      function st() {
        var S = r.pop() || b.lex() || nt;
        return typeof S != "number" && (S instanceof Array && (r = S, S = r.pop()), S = c.symbols_[S] || S), S;
      }
      o(st, "lex");
      for (var E, Y, T, N, q, P = {}, W, v, rt, z; ; ) {
        if (T = a[a.length - 1], this.defaultActions[T] ? N = this.defaultActions[T] : (E ?? (E = st()), N = w[T] && w[T][E]), N === void 0 || !N.length || !N[0]) {
          var ot = "";
          for (W in z = [], w[T]) this.terminals_[W] && W > gt && z.push("'" + this.terminals_[W] + "'");
          ot = b.showPosition ? "Parse error on line " + (H + 1) + `:
` + b.showPosition() + `
Expecting ` + z.join(", ") + ", got '" + (this.terminals_[E] || E) + "'" : "Parse error on line " + (H + 1) + ": Unexpected " + (E == nt ? "end of input" : "'" + (this.terminals_[E] || E) + "'"), this.parseError(ot, {
            text: b.match,
            token: this.terminals_[E] || E,
            line: b.yylineno,
            loc: Z,
            expected: z
          });
        }
        if (N[0] instanceof Array && N.length > 1) throw Error("Parse Error: multiple actions possible at state: " + T + ", token: " + E);
        switch (N[0]) {
          case 1:
            a.push(E), d.push(b.yytext), e.push(b.yylloc), a.push(N[1]), E = null, Y ? (E = Y, Y = null) : (it = b.yyleng, l = b.yytext, H = b.yylineno, Z = b.yylloc, ht > 0);
            break;
          case 2:
            if (v = this.productions_[N[1]][1], P.$ = d[d.length - v], P._$ = {
              first_line: e[e.length - (v || 1)].first_line,
              last_line: e[e.length - 1].last_line,
              first_column: e[e.length - (v || 1)].first_column,
              last_column: e[e.length - 1].last_column
            }, dt && (P._$.range = [e[e.length - (v || 1)].range[0], e[e.length - 1].range[1]]), q = this.performAction.apply(P, [
              l,
              it,
              H,
              R.yy,
              N[1],
              d,
              e
            ].concat(ut)), q !== void 0) return q;
            v && (a = a.slice(0, -1 * v * 2), d = d.slice(0, -1 * v), e = e.slice(0, -1 * v)), a.push(this.productions_[N[1]][0]), d.push(P.$), e.push(P._$), rt = w[a[a.length - 2]][a[a.length - 1]], a.push(rt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  };
  I.lexer = /* @__PURE__ */ function() {
    return {
      EOF: 1,
      parseError: /* @__PURE__ */ o(function(t, c) {
        if (this.yy.parser) this.yy.parser.parseError(t, c);
        else throw Error(t);
      }, "parseError"),
      setInput: /* @__PURE__ */ o(function(t, c) {
        return this.yy = c || this.yy || {}, this._input = t, 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"),
      input: /* @__PURE__ */ o(function() {
        var t = this._input[0];
        return this.yytext += t, this.yyleng++, this.offset++, this.match += t, this.matched += t, t.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), t;
      }, "input"),
      unput: /* @__PURE__ */ o(function(t) {
        var c = t.length, a = t.split(/(?:\r\n?|\n)/g);
        this._input = t + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - c), this.offset -= c;
        var r = 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), a.length - 1 && (this.yylineno -= a.length - 1);
        var d = 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: a ? (a.length === r.length ? this.yylloc.first_column : 0) + r[r.length - a.length].length - a[0].length : this.yylloc.first_column - c
        }, this.options.ranges && (this.yylloc.range = [d[0], d[0] + this.yyleng - c]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      more: /* @__PURE__ */ o(function() {
        return this._more = !0, this;
      }, "more"),
      reject: /* @__PURE__ */ o(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"),
      less: /* @__PURE__ */ o(function(t) {
        this.unput(this.match.slice(t));
      }, "less"),
      pastInput: /* @__PURE__ */ o(function() {
        var t = this.matched.substr(0, this.matched.length - this.match.length);
        return (t.length > 20 ? "..." : "") + t.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      upcomingInput: /* @__PURE__ */ o(function() {
        var t = this.match;
        return t.length < 20 && (t += this._input.substr(0, 20 - t.length)), (t.substr(0, 20) + (t.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      showPosition: /* @__PURE__ */ o(function() {
        var t = this.pastInput(), c = Array(t.length + 1).join("-");
        return t + this.upcomingInput() + `
` + c + "^";
      }, "showPosition"),
      test_match: /* @__PURE__ */ o(function(t, c) {
        var a, r, d;
        if (this.options.backtrack_lexer && (d = {
          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 && (d.yylloc.range = this.yylloc.range.slice(0))), r = t[0].match(/(?:\r\n?|\n).*/g), r && (this.yylineno += r.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: r ? r[r.length - 1].length - r[r.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + t[0].length
        }, this.yytext += t[0], this.match += t[0], this.matches = t, 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(t[0].length), this.matched += t[0], a = this.performAction.call(this, this.yy, this, c, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), a) return a;
        if (this._backtrack) {
          for (var e in d) this[e] = d[e];
          return !1;
        }
        return !1;
      }, "test_match"),
      next: /* @__PURE__ */ o(function() {
        if (this.done) return this.EOF;
        this._input || (this.done = !0);
        var t, c, a, r;
        this._more || (this.yytext = "", this.match = "");
        for (var d = this._currentRules(), e = 0; e < d.length; e++) if (a = this._input.match(this.rules[d[e]]), a && (!c || a[0].length > c[0].length)) {
          if (c = a, r = e, this.options.backtrack_lexer) {
            if (t = this.test_match(a, d[e]), t !== !1) return t;
            if (this._backtrack) {
              c = !1;
              continue;
            } else return !1;
          } else if (!this.options.flex) break;
        }
        return c ? (t = this.test_match(c, d[r]), t === !1 ? !1 : t) : this._input === "" ? this.EOF : this.parseError("Lexical error on line " + (this.yylineno + 1) + `. Unrecognized text.
` + this.showPosition(), {
          text: "",
          token: null,
          line: this.yylineno
        });
      }, "next"),
      lex: /* @__PURE__ */ o(function() {
        return this.next() || this.lex();
      }, "lex"),
      begin: /* @__PURE__ */ o(function(t) {
        this.conditionStack.push(t);
      }, "begin"),
      popState: /* @__PURE__ */ o(function() {
        return this.conditionStack.length - 1 > 0 ? this.conditionStack.pop() : this.conditionStack[0];
      }, "popState"),
      _currentRules: /* @__PURE__ */ o(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__ */ o(function(t) {
        return t = this.conditionStack.length - 1 - Math.abs(t || 0), t >= 0 ? this.conditionStack[t] : "INITIAL";
      }, "topState"),
      pushState: /* @__PURE__ */ o(function(t) {
        this.begin(t);
      }, "pushState"),
      stateStackSize: /* @__PURE__ */ o(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ o(function(t, c, a, r) {
        switch (a) {
          case 0:
            return this.pushState("shapeData"), c.yytext = "", 24;
          case 1:
            return this.pushState("shapeDataStr"), 24;
          case 2:
            return this.popState(), 24;
          case 3:
            return c.yytext = c.yytext.replace(/\n\s*/g, "<br/>"), 24;
          case 4:
            return 24;
          case 5:
            this.popState();
            break;
          case 6:
            return t.getLogger().trace("Found comment", c.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:
            t.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 12:
            return t.getLogger().trace("SPACELINE"), 6;
          case 13:
            return 7;
          case 14:
            return 16;
          case 15:
            t.getLogger().trace("end icon"), this.popState();
            break;
          case 16:
            return t.getLogger().trace("Exploding node"), this.begin("NODE"), 20;
          case 17:
            return t.getLogger().trace("Cloud"), this.begin("NODE"), 20;
          case 18:
            return t.getLogger().trace("Explosion Bang"), this.begin("NODE"), 20;
          case 19:
            return t.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:
            t.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 31:
            return t.getLogger().trace("description:", c.yytext), "NODE_DESCR";
          case 32:
            this.popState();
            break;
          case 33:
            return this.popState(), t.getLogger().trace("node end ))"), "NODE_DEND";
          case 34:
            return this.popState(), t.getLogger().trace("node end )"), "NODE_DEND";
          case 35:
            return this.popState(), t.getLogger().trace("node end ...", c.yytext), "NODE_DEND";
          case 36:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 37:
            return this.popState(), t.getLogger().trace("node end (-"), "NODE_DEND";
          case 38:
            return this.popState(), t.getLogger().trace("node end (-"), "NODE_DEND";
          case 39:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 40:
            return this.popState(), t.getLogger().trace("node end (("), "NODE_DEND";
          case 41:
            return t.getLogger().trace("Long description:", c.yytext), 21;
          case 42:
            return t.getLogger().trace("Long description:", c.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: !1
        },
        shapeDataStr: {
          rules: [2, 3],
          inclusive: !1
        },
        shapeData: {
          rules: [
            1,
            4,
            5
          ],
          inclusive: !1
        },
        CLASS: {
          rules: [9, 10],
          inclusive: !1
        },
        ICON: {
          rules: [14, 15],
          inclusive: !1
        },
        NSTR2: {
          rules: [28, 29],
          inclusive: !1
        },
        NSTR: {
          rules: [31, 32],
          inclusive: !1
        },
        NODE: {
          rules: [
            27,
            30,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42
          ],
          inclusive: !1
        },
        INITIAL: {
          rules: [
            0,
            6,
            7,
            8,
            11,
            12,
            13,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26
          ],
          inclusive: !0
        }
      }
    };
  }();
  function k() {
    this.yy = {};
  }
  return o(k, "Parser"), k.prototype = I, I.Parser = k, new k();
}();
Q.parser = Q;
var xt = Q, x = [], et = [], V = 0, tt = {}, Dt = /* @__PURE__ */ o(() => {
  x = [], et = [], V = 0, tt = {};
}, "clear"), Lt = /* @__PURE__ */ o((i) => {
  if (x.length === 0) return null;
  let g = x[0].level, p = null;
  for (let s = x.length - 1; s >= 0; s--) if (x[s].level === g && !p && (p = x[s]), x[s].level < g) throw Error('Items without section detected, found section ("' + x[s].label + '")');
  return i === (p == null ? void 0 : p.level) ? null : p;
}, "getSection"), ct = /* @__PURE__ */ o(function() {
  return et;
}, "getSections"), Ot = /* @__PURE__ */ o(function() {
  let i = [], g = [], p = ct(), s = M();
  for (let u of p) {
    let y = {
      id: u.id,
      label: B(u.label ?? "", s),
      labelType: "markdown",
      isGroup: !0,
      ticket: u.ticket,
      shape: "kanbanSection",
      level: u.level,
      look: s.look
    };
    g.push(y);
    let _ = x.filter((h) => h.parentId === u.id);
    for (let h of _) {
      let D = {
        id: h.id,
        parentId: u.id,
        label: B(h.label ?? "", s),
        labelType: "markdown",
        isGroup: !1,
        ticket: h == null ? void 0 : h.ticket,
        priority: h == null ? void 0 : h.priority,
        assigned: h == null ? void 0 : h.assigned,
        icon: h == null ? void 0 : h.icon,
        shape: "kanbanItem",
        level: h.level,
        rx: 5,
        ry: 5,
        cssStyles: ["text-align: left"]
      };
      g.push(D);
    }
  }
  return {
    nodes: g,
    edges: i,
    other: {},
    config: M()
  };
}, "getData"), It = /* @__PURE__ */ o((i, g, p, s, u) => {
  var C, L;
  let y = M(), _ = ((C = y.mindmap) == null ? void 0 : C.padding) ?? X.mindmap.padding;
  switch (s) {
    case m.ROUNDED_RECT:
    case m.RECT:
    case m.HEXAGON:
      _ *= 2;
  }
  let h = {
    id: B(g, y) || "kbn" + V++,
    level: i,
    label: B(p, y),
    width: ((L = y.mindmap) == null ? void 0 : L.maxNodeWidth) ?? X.mindmap.maxNodeWidth,
    padding: _,
    isGroup: !1
  };
  if (u !== void 0) {
    let $;
    $ = u.includes(`
`) ? u + `
` : `{
` + u + `
}`;
    let n = Et($, { schema: kt });
    if (n.shape && (n.shape !== n.shape.toLowerCase() || n.shape.includes("_"))) throw Error(`No such shape: ${n.shape}. Shape names should be lowercase.`);
    n != null && n.shape && n.shape === "kanbanItem" && (h.shape = n == null ? void 0 : n.shape), n != null && n.label && (h.label = n == null ? void 0 : n.label), n != null && n.icon && (h.icon = n == null ? void 0 : n.icon.toString()), n != null && n.assigned && (h.assigned = n == null ? void 0 : n.assigned.toString()), n != null && n.ticket && (h.ticket = n == null ? void 0 : n.ticket.toString()), n != null && n.priority && (h.priority = n == null ? void 0 : n.priority);
  }
  let D = Lt(i);
  D ? h.parentId = D.id || "kbn" + V++ : et.push(h), x.push(h);
}, "addNode"), m = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, vt = {
  clear: Dt,
  addNode: It,
  getSections: ct,
  getData: Ot,
  nodeType: m,
  getType: /* @__PURE__ */ o((i, g) => {
    switch (J.debug("In get type", i, g), i) {
      case "[":
        return m.RECT;
      case "(":
        return g === ")" ? m.ROUNDED_RECT : m.CLOUD;
      case "((":
        return m.CIRCLE;
      case ")":
        return m.CLOUD;
      case "))":
        return m.BANG;
      case "{{":
        return m.HEXAGON;
      default:
        return m.DEFAULT;
    }
  }, "getType"),
  setElementForId: /* @__PURE__ */ o((i, g) => {
    tt[i] = g;
  }, "setElementForId"),
  decorateNode: /* @__PURE__ */ o((i) => {
    if (!i) return;
    let g = M(), p = x[x.length - 1];
    i.icon && (p.icon = B(i.icon, g)), i.class && (p.cssClasses = B(i.class, g));
  }, "decorateNode"),
  type2Str: /* @__PURE__ */ o((i) => {
    switch (i) {
      case m.DEFAULT:
        return "no-border";
      case m.RECT:
        return "rect";
      case m.ROUNDED_RECT:
        return "rounded-rect";
      case m.CIRCLE:
        return "circle";
      case m.CLOUD:
        return "cloud";
      case m.BANG:
        return "bang";
      case m.HEXAGON:
        return "hexgon";
      default:
        return "no-border";
    }
  }, "type2Str"),
  getLogger: /* @__PURE__ */ o(() => J, "getLogger"),
  getElementById: /* @__PURE__ */ o((i) => tt[i], "getElementById")
}, Ct = { draw: /* @__PURE__ */ o(async (i, g, p, s) => {
  var O, G, U, j, A;
  J.debug(`Rendering kanban diagram
` + i);
  let u = s.db.getData(), y = M();
  y.htmlLabels = !1;
  let _ = yt(g);
  for (let f of u.nodes) f.domId = `${g}-${f.id}`;
  let h = _.append("g");
  h.attr("class", "sections");
  let D = _.append("g");
  D.attr("class", "items");
  let C = u.nodes.filter((f) => f.isGroup), L = 0, $ = [], n = 25;
  for (let f of C) {
    let I = ((O = y == null ? void 0 : y.kanban) == null ? void 0 : O.sectionWidth) || 200;
    L += 1, f.x = I * L + (L - 1) * 10 / 2, f.width = I, f.y = 0, f.height = I * 3, f.rx = 5, f.ry = 5, f.cssClasses = f.cssClasses + " section-" + L;
    let k = await ft(h, f);
    n = Math.max(n, (G = k == null ? void 0 : k.labelBBox) == null ? void 0 : G.height), $.push(k);
  }
  let F = 0;
  for (let f of C) {
    let I = $[F];
    F += 1;
    let k = ((U = y == null ? void 0 : y.kanban) == null ? void 0 : U.sectionWidth) || 200, t = -k * 3 / 2 + n, c = t, a = u.nodes.filter((e) => e.parentId === f.id);
    for (let e of a) {
      if (e.isGroup) throw Error("Groups within groups are not allowed in Kanban diagrams");
      e.x = f.x, e.width = k - 1.5 * 10;
      let w = (await mt(D, e, { config: y })).node().getBBox();
      e.y = c + w.height / 2, await bt(e), c = e.y + w.height / 2 + 10 / 2;
    }
    let r = I.cluster.select("rect"), d = Math.max(c - t + 30, 50) + (n - 25);
    r.attr("height", d);
  }
  _t(void 0, _, ((j = y.mindmap) == null ? void 0 : j.padding) ?? X.kanban.padding, ((A = y.mindmap) == null ? void 0 : A.useMaxWidth) ?? X.kanban.useMaxWidth);
}, "draw") }, $t = /* @__PURE__ */ o((i) => {
  let g = "";
  for (let s = 0; s < i.THEME_COLOR_LIMIT; s++) i["lineColor" + s] = i["lineColor" + s] || i["cScaleInv" + s], Nt(i["lineColor" + s]) ? i["lineColor" + s] = at(i["lineColor" + s], 20) : i["lineColor" + s] = lt(i["lineColor" + s], 20);
  let p = /* @__PURE__ */ o((s, u) => i.darkMode ? lt(s, u) : at(s, u), "adjuster");
  for (let s = 0; s < i.THEME_COLOR_LIMIT; s++) {
    let u = "" + (17 - 3 * s);
    g += `
    .section-${s - 1} rect, .section-${s - 1} path, .section-${s - 1} circle, .section-${s - 1} polygon, .section-${s - 1} path  {
      fill: ${p(i["cScale" + s], 10)};
      stroke: ${p(i["cScale" + s], 10)};

    }
    .section-${s - 1} text {
     fill: ${i["cScaleLabel" + s]};
    }
    .node-icon-${s - 1} {
      font-size: 40px;
      color: ${i["cScaleLabel" + s]};
    }
    .section-edge-${s - 1}{
      stroke: ${i["cScale" + s]};
    }
    .edge-depth-${s - 1}{
      stroke-width: ${u};
    }
    .section-${s - 1} line {
      stroke: ${i["cScaleInv" + s]} ;
      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: ${i.background};
    stroke: ${i.nodeBorder};
    stroke-width: 1px;
  }

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