import { l as pe } from "./chunk-GLLZNHP4-BfObQGbx-D2i6EGF4.js";
import { _ as a, l as ee, g as F, aU as ye, f as fe, i as me, p as be, bm as _e, aB as K, ad as M, ap as Ee, aq as Se, bn as ke, bo as ae, bp as le } from "./index-DeBlJN4f.js";
var Y = function() {
  var i = /* @__PURE__ */ a(function(k, e, n, r) {
    for (n = n || {}, r = k.length; r--; n[k[r]] = e) ;
    return n;
  }, "o"), u = [1, 4], d = [1, 13], s = [1, 12], g = [1, 15], D = [1, 16], S = [1, 20], h = [1, 19], v = [6, 7, 8], b = [1, 26], _ = [1, 24], C = [1, 25], o = [6, 7, 11], j = [1, 31], w = [6, 7, 11, 24], $ = [1, 6, 13, 16, 17, 20, 23], T = [1, 35], H = [1, 36], A = [1, 6, 7, 11, 13, 16, 17, 20, 23], U = [1, 38], y = {
    trace: /* @__PURE__ */ a(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__ */ a(function(k, e, n, r, c, t, m) {
      var l = t.length - 1;
      switch (c) {
        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: ", t[l - 1].id), r.addNode(t[l - 2].length, t[l - 1].id, t[l - 1].descr, t[l - 1].type, t[l]);
          break;
        case 16:
          r.getLogger().info("Node: ", t[l].id), r.addNode(t[l - 1].length, t[l].id, t[l].descr, t[l].type);
          break;
        case 17:
          r.getLogger().trace("Icon: ", t[l]), r.decorateNode({ icon: t[l] });
          break;
        case 18:
        case 23:
          r.decorateNode({ class: t[l] });
          break;
        case 19:
          r.getLogger().trace("SPACELIST");
          break;
        case 20:
          r.getLogger().trace("Node: ", t[l - 1].id), r.addNode(0, t[l - 1].id, t[l - 1].descr, t[l - 1].type, t[l]);
          break;
        case 21:
          r.getLogger().trace("Node: ", t[l].id), r.addNode(0, t[l].id, t[l].descr, t[l].type);
          break;
        case 22:
          r.decorateNode({ icon: t[l] });
          break;
        case 27:
          r.getLogger().trace("node found ..", t[l - 2]), this.$ = { id: t[l - 1], descr: t[l - 1], type: r.getType(t[l - 2], t[l]) };
          break;
        case 28:
          this.$ = { id: t[l], descr: t[l], type: 0 };
          break;
        case 29:
          r.getLogger().trace("node found ..", t[l - 3]), this.$ = { id: t[l - 3], descr: t[l - 1], type: r.getType(t[l - 2], t[l]) };
          break;
        case 30:
          this.$ = t[l - 1] + t[l];
          break;
        case 31:
          this.$ = t[l];
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: u }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: u }, { 6: d, 7: [1, 10], 9: 9, 12: 11, 13: s, 14: 14, 16: g, 17: D, 18: 17, 19: 18, 20: S, 23: h }, i(v, [2, 3]), { 1: [2, 2] }, i(v, [2, 4]), i(v, [2, 5]), { 1: [2, 6], 6: d, 12: 21, 13: s, 14: 14, 16: g, 17: D, 18: 17, 19: 18, 20: S, 23: h }, { 6: d, 9: 22, 12: 11, 13: s, 14: 14, 16: g, 17: D, 18: 17, 19: 18, 20: S, 23: h }, { 6: b, 7: _, 10: 23, 11: C }, i(o, [2, 24], { 18: 17, 19: 18, 14: 27, 16: [1, 28], 17: [1, 29], 20: S, 23: h }), i(o, [2, 19]), i(o, [2, 21], { 15: 30, 24: j }), i(o, [2, 22]), i(o, [2, 23]), i(w, [2, 25]), i(w, [2, 26]), i(w, [2, 28], { 20: [1, 32] }), { 21: [1, 33] }, { 6: b, 7: _, 10: 34, 11: C }, { 1: [2, 7], 6: d, 12: 21, 13: s, 14: 14, 16: g, 17: D, 18: 17, 19: 18, 20: S, 23: h }, i($, [2, 14], { 7: T, 11: H }), i(A, [2, 8]), i(A, [2, 9]), i(A, [2, 10]), i(o, [2, 16], { 15: 37, 24: j }), i(o, [2, 17]), i(o, [2, 18]), i(o, [2, 20], { 24: U }), i(w, [2, 31]), { 21: [1, 39] }, { 22: [1, 40] }, i($, [2, 13], { 7: T, 11: H }), i(A, [2, 11]), i(A, [2, 12]), i(o, [2, 15], { 24: U }), i(w, [2, 30]), { 22: [1, 41] }, i(w, [2, 27]), i(w, [2, 29])],
    defaultActions: { 2: [2, 1], 6: [2, 2] },
    parseError: /* @__PURE__ */ a(function(k, e) {
      if (e.recoverable)
        this.trace(k);
      else {
        var n = new Error(k);
        throw n.hash = e, n;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ a(function(k) {
      var e = this, n = [0], r = [], c = [null], t = [], m = this.table, l = "", W = 0, ne = 0, he = 2, se = 1, ue = t.slice.call(arguments, 1), f = Object.create(this.lexer), P = { yy: {} };
      for (var q in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, q) && (P.yy[q] = this.yy[q]);
      f.setInput(k, P.yy), P.yy.lexer = f, P.yy.parser = this, typeof f.yylloc > "u" && (f.yylloc = {});
      var X = f.yylloc;
      t.push(X);
      var ge = f.options && f.options.ranges;
      typeof P.yy.parseError == "function" ? this.parseError = P.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function de(N) {
        n.length = n.length - 2 * N, c.length = c.length - N, t.length = t.length - N;
      }
      a(de, "popStack");
      function re() {
        var N;
        return N = r.pop() || f.lex() || se, typeof N != "number" && (N instanceof Array && (r = N, N = r.pop()), N = e.symbols_[N] || N), N;
      }
      a(re, "lex");
      for (var E, B, x, J, G = {}, z, I, oe, V; ; ) {
        if (B = n[n.length - 1], this.defaultActions[B] ? x = this.defaultActions[B] : ((E === null || typeof E > "u") && (E = re()), x = m[B] && m[B][E]), typeof x > "u" || !x.length || !x[0]) {
          var Q = "";
          V = [];
          for (z in m[B])
            this.terminals_[z] && z > he && V.push("'" + this.terminals_[z] + "'");
          f.showPosition ? Q = "Parse error on line " + (W + 1) + `:
` + f.showPosition() + `
Expecting ` + V.join(", ") + ", got '" + (this.terminals_[E] || E) + "'" : Q = "Parse error on line " + (W + 1) + ": Unexpected " + (E == se ? "end of input" : "'" + (this.terminals_[E] || E) + "'"), this.parseError(Q, {
            text: f.match,
            token: this.terminals_[E] || E,
            line: f.yylineno,
            loc: X,
            expected: V
          });
        }
        if (x[0] instanceof Array && x.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + B + ", token: " + E);
        switch (x[0]) {
          case 1:
            n.push(E), c.push(f.yytext), t.push(f.yylloc), n.push(x[1]), E = null, ne = f.yyleng, l = f.yytext, W = f.yylineno, X = f.yylloc;
            break;
          case 2:
            if (I = this.productions_[x[1]][1], G.$ = c[c.length - I], G._$ = {
              first_line: t[t.length - (I || 1)].first_line,
              last_line: t[t.length - 1].last_line,
              first_column: t[t.length - (I || 1)].first_column,
              last_column: t[t.length - 1].last_column
            }, ge && (G._$.range = [
              t[t.length - (I || 1)].range[0],
              t[t.length - 1].range[1]
            ]), J = this.performAction.apply(G, [
              l,
              ne,
              W,
              P.yy,
              x[1],
              c,
              t
            ].concat(ue)), typeof J < "u")
              return J;
            I && (n = n.slice(0, -1 * I * 2), c = c.slice(0, -1 * I), t = t.slice(0, -1 * I)), n.push(this.productions_[x[1]][0]), c.push(G.$), t.push(G._$), oe = m[n[n.length - 2]][n[n.length - 1]], n.push(oe);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, R = /* @__PURE__ */ function() {
    var k = {
      EOF: 1,
      parseError: /* @__PURE__ */ a(function(e, n) {
        if (this.yy.parser)
          this.yy.parser.parseError(e, n);
        else
          throw new Error(e);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ a(function(e, n) {
        return this.yy = n || this.yy || {}, this._input = e, 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__ */ a(function() {
        var e = this._input[0];
        this.yytext += e, this.yyleng++, this.offset++, this.match += e, this.matched += e;
        var n = e.match(/(?:\r\n?|\n).*/g);
        return n ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), e;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ a(function(e) {
        var n = e.length, r = e.split(/(?:\r\n?|\n)/g);
        this._input = e + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - n), this.offset -= n;
        var c = 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), r.length - 1 && (this.yylineno -= r.length - 1);
        var t = 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: r ? (r.length === c.length ? this.yylloc.first_column : 0) + c[c.length - r.length].length - r[0].length : this.yylloc.first_column - n
        }, this.options.ranges && (this.yylloc.range = [t[0], t[0] + this.yyleng - n]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ a(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__ */ a(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__ */ a(function(e) {
        this.unput(this.match.slice(e));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ a(function() {
        var e = this.matched.substr(0, this.matched.length - this.match.length);
        return (e.length > 20 ? "..." : "") + e.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ a(function() {
        var e = this.match;
        return e.length < 20 && (e += this._input.substr(0, 20 - e.length)), (e.substr(0, 20) + (e.length > 20 ? "..." : "")).replace(/\n/g, "");
      }, "upcomingInput"),
      // displays the character position where the lexing error occurred, i.e. for error messages
      showPosition: /* @__PURE__ */ a(function() {
        var e = this.pastInput(), n = new Array(e.length + 1).join("-");
        return e + this.upcomingInput() + `
` + n + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ a(function(e, n) {
        var r, c, t;
        if (this.options.backtrack_lexer && (t = {
          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 && (t.yylloc.range = this.yylloc.range.slice(0))), c = e[0].match(/(?:\r\n?|\n).*/g), c && (this.yylineno += c.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: c ? c[c.length - 1].length - c[c.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + e[0].length
        }, this.yytext += e[0], this.match += e[0], this.matches = e, 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(e[0].length), this.matched += e[0], r = this.performAction.call(this, this.yy, this, n, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), r)
          return r;
        if (this._backtrack) {
          for (var m in t)
            this[m] = t[m];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ a(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var e, n, r, c;
        this._more || (this.yytext = "", this.match = "");
        for (var t = this._currentRules(), m = 0; m < t.length; m++)
          if (r = this._input.match(this.rules[t[m]]), r && (!n || r[0].length > n[0].length)) {
            if (n = r, c = m, this.options.backtrack_lexer) {
              if (e = this.test_match(r, t[m]), e !== !1)
                return e;
              if (this._backtrack) {
                n = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return n ? (e = this.test_match(n, t[c]), e !== !1 ? e : !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__ */ a(function() {
        var e = this.next();
        return e || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ a(function(e) {
        this.conditionStack.push(e);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ a(function() {
        var e = this.conditionStack.length - 1;
        return e > 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__ */ a(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__ */ a(function(e) {
        return e = this.conditionStack.length - 1 - Math.abs(e || 0), e >= 0 ? this.conditionStack[e] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ a(function(e) {
        this.begin(e);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ a(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ a(function(e, n, r, c) {
        switch (r) {
          case 0:
            return this.pushState("shapeData"), n.yytext = "", 24;
          case 1:
            return this.pushState("shapeDataStr"), 24;
          case 2:
            return this.popState(), 24;
          case 3:
            const t = /\n\s*/g;
            return n.yytext = n.yytext.replace(t, "<br/>"), 24;
          case 4:
            return 24;
          case 5:
            this.popState();
            break;
          case 6:
            return e.getLogger().trace("Found comment", n.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:
            e.getLogger().trace("Begin icon"), this.begin("ICON");
            break;
          case 12:
            return e.getLogger().trace("SPACELINE"), 6;
          case 13:
            return 7;
          case 14:
            return 16;
          case 15:
            e.getLogger().trace("end icon"), this.popState();
            break;
          case 16:
            return e.getLogger().trace("Exploding node"), this.begin("NODE"), 20;
          case 17:
            return e.getLogger().trace("Cloud"), this.begin("NODE"), 20;
          case 18:
            return e.getLogger().trace("Explosion Bang"), this.begin("NODE"), 20;
          case 19:
            return e.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:
            e.getLogger().trace("Starting NSTR"), this.begin("NSTR");
            break;
          case 31:
            return e.getLogger().trace("description:", n.yytext), "NODE_DESCR";
          case 32:
            this.popState();
            break;
          case 33:
            return this.popState(), e.getLogger().trace("node end ))"), "NODE_DEND";
          case 34:
            return this.popState(), e.getLogger().trace("node end )"), "NODE_DEND";
          case 35:
            return this.popState(), e.getLogger().trace("node end ...", n.yytext), "NODE_DEND";
          case 36:
            return this.popState(), e.getLogger().trace("node end (("), "NODE_DEND";
          case 37:
            return this.popState(), e.getLogger().trace("node end (-"), "NODE_DEND";
          case 38:
            return this.popState(), e.getLogger().trace("node end (-"), "NODE_DEND";
          case 39:
            return this.popState(), e.getLogger().trace("node end (("), "NODE_DEND";
          case 40:
            return this.popState(), e.getLogger().trace("node end (("), "NODE_DEND";
          case 41:
            return e.getLogger().trace("Long description:", n.yytext), 21;
          case 42:
            return e.getLogger().trace("Long description:", n.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 } }
    };
    return k;
  }();
  y.lexer = R;
  function O() {
    this.yy = {};
  }
  return a(O, "Parser"), O.prototype = y, y.Parser = O, new O();
}();
Y.parser = Y;
var Ne = Y, L = [], te = [], Z = 0, ie = {}, De = /* @__PURE__ */ a(() => {
  L = [], te = [], Z = 0, ie = {};
}, "clear"), xe = /* @__PURE__ */ a((i) => {
  if (L.length === 0)
    return null;
  const u = L[0].level;
  let d = null;
  for (let s = L.length - 1; s >= 0; s--)
    if (L[s].level === u && !d && (d = L[s]), L[s].level < u)
      throw new Error('Items without section detected, found section ("' + L[s].label + '")');
  return i === (d == null ? void 0 : d.level) ? null : d;
}, "getSection"), ce = /* @__PURE__ */ a(function() {
  return te;
}, "getSections"), Le = /* @__PURE__ */ a(function() {
  const i = [], u = [], d = ce(), s = F();
  for (const g of d) {
    const D = {
      id: g.id,
      label: M(g.label ?? "", s),
      isGroup: !0,
      ticket: g.ticket,
      shape: "kanbanSection",
      level: g.level,
      look: s.look
    };
    u.push(D);
    const S = L.filter((h) => h.parentId === g.id);
    for (const h of S) {
      const v = {
        id: h.id,
        parentId: g.id,
        label: M(h.label ?? "", s),
        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"]
      };
      u.push(v);
    }
  }
  return { nodes: u, edges: i, other: {}, config: F() };
}, "getData"), ve = /* @__PURE__ */ a((i, u, d, s, g) => {
  var D, S;
  const h = F();
  let v = ((D = h.mindmap) == null ? void 0 : D.padding) ?? K.mindmap.padding;
  switch (s) {
    case p.ROUNDED_RECT:
    case p.RECT:
    case p.HEXAGON:
      v *= 2;
  }
  const b = {
    id: M(u, h) || "kbn" + Z++,
    level: i,
    label: M(d, h),
    width: ((S = h.mindmap) == null ? void 0 : S.maxNodeWidth) ?? K.mindmap.maxNodeWidth,
    padding: v,
    isGroup: !1
  };
  if (g !== void 0) {
    let C;
    g.includes(`
`) ? C = g + `
` : C = `{
` + g + `
}`;
    const o = Ee(C, { schema: Se });
    if (o.shape && (o.shape !== o.shape.toLowerCase() || o.shape.includes("_")))
      throw new Error(`No such shape: ${o.shape}. Shape names should be lowercase.`);
    o != null && o.shape && o.shape === "kanbanItem" && (b.shape = o == null ? void 0 : o.shape), o != null && o.label && (b.label = o == null ? void 0 : o.label), o != null && o.icon && (b.icon = o == null ? void 0 : o.icon.toString()), o != null && o.assigned && (b.assigned = o == null ? void 0 : o.assigned.toString()), o != null && o.ticket && (b.ticket = o == null ? void 0 : o.ticket.toString()), o != null && o.priority && (b.priority = o == null ? void 0 : o.priority);
  }
  const _ = xe(i);
  _ ? b.parentId = _.id || "kbn" + Z++ : te.push(b), L.push(b);
}, "addNode"), p = {
  DEFAULT: 0,
  NO_BORDER: 0,
  ROUNDED_RECT: 1,
  RECT: 2,
  CIRCLE: 3,
  CLOUD: 4,
  BANG: 5,
  HEXAGON: 6
}, Oe = /* @__PURE__ */ a((i, u) => {
  switch (ee.debug("In get type", i, u), i) {
    case "[":
      return p.RECT;
    case "(":
      return u === ")" ? p.ROUNDED_RECT : p.CLOUD;
    case "((":
      return p.CIRCLE;
    case ")":
      return p.CLOUD;
    case "))":
      return p.BANG;
    case "{{":
      return p.HEXAGON;
    default:
      return p.DEFAULT;
  }
}, "getType"), Ce = /* @__PURE__ */ a((i, u) => {
  ie[i] = u;
}, "setElementForId"), we = /* @__PURE__ */ a((i) => {
  if (!i)
    return;
  const u = F(), d = L[L.length - 1];
  i.icon && (d.icon = M(i.icon, u)), i.class && (d.cssClasses = M(i.class, u));
}, "decorateNode"), Ae = /* @__PURE__ */ a((i) => {
  switch (i) {
    case p.DEFAULT:
      return "no-border";
    case p.RECT:
      return "rect";
    case p.ROUNDED_RECT:
      return "rounded-rect";
    case p.CIRCLE:
      return "circle";
    case p.CLOUD:
      return "cloud";
    case p.BANG:
      return "bang";
    case p.HEXAGON:
      return "hexgon";
    default:
      return "no-border";
  }
}, "type2Str"), Ie = /* @__PURE__ */ a(() => ee, "getLogger"), $e = /* @__PURE__ */ a((i) => ie[i], "getElementById"), Te = {
  clear: De,
  addNode: ve,
  getSections: ce,
  getData: Le,
  nodeType: p,
  getType: Oe,
  setElementForId: Ce,
  decorateNode: we,
  type2Str: Ae,
  getLogger: Ie,
  getElementById: $e
}, Re = Te, Pe = /* @__PURE__ */ a(async (i, u, d, s) => {
  var g, D, S, h, v;
  ee.debug(`Rendering kanban diagram
` + i);
  const b = s.db.getData(), _ = F();
  _.htmlLabels = !1;
  const C = ye(u), o = C.append("g");
  o.attr("class", "sections");
  const j = C.append("g");
  j.attr("class", "items");
  const w = b.nodes.filter(
    // TODO: TypeScript 5.5 will infer this predicate automatically
    (y) => y.isGroup
  );
  let $ = 0;
  const T = 10, H = [];
  let A = 25;
  for (const y of w) {
    const R = ((g = _ == null ? void 0 : _.kanban) == null ? void 0 : g.sectionWidth) || 200;
    $ = $ + 1, y.x = R * $ + ($ - 1) * T / 2, y.width = R, y.y = 0, y.height = R * 3, y.rx = 5, y.ry = 5, y.cssClasses = y.cssClasses + " section-" + $;
    const O = await fe(o, y);
    A = Math.max(A, (D = O == null ? void 0 : O.labelBBox) == null ? void 0 : D.height), H.push(O);
  }
  let U = 0;
  for (const y of w) {
    const R = H[U];
    U = U + 1;
    const O = ((S = _ == null ? void 0 : _.kanban) == null ? void 0 : S.sectionWidth) || 200, k = -O * 3 / 2 + A;
    let e = k;
    const n = b.nodes.filter((t) => t.parentId === y.id);
    for (const t of n) {
      if (t.isGroup)
        throw new Error("Groups within groups are not allowed in Kanban diagrams");
      t.x = y.x, t.width = O - 1.5 * T;
      const m = (await me(j, t, { config: _ })).node().getBBox();
      t.y = e + m.height / 2, await be(t), e = t.y + m.height / 2 + T / 2;
    }
    const r = R.cluster.select("rect"), c = Math.max(e - k + 3 * T, 50) + (A - 25);
    r.attr("height", c);
  }
  _e(
    void 0,
    C,
    ((h = _.mindmap) == null ? void 0 : h.padding) ?? K.kanban.padding,
    ((v = _.mindmap) == null ? void 0 : v.useMaxWidth) ?? K.kanban.useMaxWidth
  );
}, "draw"), Be = {
  draw: Pe
}, Ue = /* @__PURE__ */ a((i) => {
  let u = "";
  for (let s = 0; s < i.THEME_COLOR_LIMIT; s++)
    i["lineColor" + s] = i["lineColor" + s] || i["cScaleInv" + s], ke(i["lineColor" + s]) ? i["lineColor" + s] = ae(i["lineColor" + s], 20) : i["lineColor" + s] = le(i["lineColor" + s], 20);
  const d = /* @__PURE__ */ a((s, g) => i.darkMode ? le(s, g) : ae(s, g), "adjuster");
  for (let s = 0; s < i.THEME_COLOR_LIMIT; s++) {
    const g = "" + (17 - 3 * s);
    u += `
    .section-${s - 1} rect, .section-${s - 1} path, .section-${s - 1} circle, .section-${s - 1} polygon, .section-${s - 1} path  {
      fill: ${d(i["cScale" + s], 10)};
      stroke: ${d(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: ${g};
    }
    .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 u;
}, "genSections"), Ge = /* @__PURE__ */ a((i) => `
  .edge {
    stroke-width: 3;
  }
  ${Ue(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;
  }
    ${pe()}
`, "getStyles"), Me = Ge, Fe = {
  db: Re,
  renderer: Be,
  parser: Ne,
  styles: Me
};
export {
  Fe as diagram
};
