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

    }
    .section-${i - 1} text {
     fill: ${e["cScaleLabel" + i]};
    }
    .node-icon-${i - 1} {
      font-size: 40px;
      color: ${e["cScaleLabel" + i]};
    }
    .section-edge-${i - 1}{
      stroke: ${e["cScale" + i]};
    }
    .edge-depth-${i - 1}{
      stroke-width: ${d};
    }
    .section-${i - 1} line {
      stroke: ${e["cScaleInv" + i]} ;
      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 h;
}, "genSections"), Ge = /* @__PURE__ */ o((e) => `
  .edge {
    stroke-width: 3;
  }
  ${Fe(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;
  }
    ${Ne()}
`, "getStyles"), Me = Ge, We = {
  db: Ve,
  renderer: je,
  parser: xe,
  styles: Me
};
export {
  We as diagram
};
