import { _ as a, g as mt, l as S, a9 as V, bk as xt, bl as bt, bm as kt, bn as _t, bo as vt, bp as wt, aq as St } from "./index-CMZig9xg.js";
import { h as et } from "./arc-CK9P6CkJ-DVgfRhzX.js";
var J = function() {
  var n = /* @__PURE__ */ a(function(x, i, c, d) {
    for (c = c || {}, d = x.length; d--; c[x[d]] = i) ;
    return c;
  }, "o"), t = [6, 8, 10, 11, 12, 14, 16, 17, 20, 21], e = [1, 9], r = [1, 10], s = [1, 11], h = [1, 12], o = [1, 13], p = [1, 16], g = [1, 17], f = {
    trace: /* @__PURE__ */ a(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, timeline: 4, document: 5, EOF: 6, line: 7, SPACE: 8, statement: 9, NEWLINE: 10, title: 11, acc_title: 12, acc_title_value: 13, acc_descr: 14, acc_descr_value: 15, acc_descr_multiline_value: 16, section: 17, period_statement: 18, event_statement: 19, period: 20, event: 21, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "timeline", 6: "EOF", 8: "SPACE", 10: "NEWLINE", 11: "title", 12: "acc_title", 13: "acc_title_value", 14: "acc_descr", 15: "acc_descr_value", 16: "acc_descr_multiline_value", 17: "section", 20: "period", 21: "event" },
    productions_: [0, [3, 3], [5, 0], [5, 2], [7, 2], [7, 1], [7, 1], [7, 1], [9, 1], [9, 2], [9, 2], [9, 1], [9, 1], [9, 1], [9, 1], [18, 1], [19, 1]],
    performAction: /* @__PURE__ */ a(function(x, i, c, d, u, l, b) {
      var k = l.length - 1;
      switch (u) {
        case 1:
          return l[k - 1];
        case 2:
          this.$ = [];
          break;
        case 3:
          l[k - 1].push(l[k]), this.$ = l[k - 1];
          break;
        case 4:
        case 5:
          this.$ = l[k];
          break;
        case 6:
        case 7:
          this.$ = [];
          break;
        case 8:
          d.getCommonDb().setDiagramTitle(l[k].substr(6)), this.$ = l[k].substr(6);
          break;
        case 9:
          this.$ = l[k].trim(), d.getCommonDb().setAccTitle(this.$);
          break;
        case 10:
        case 11:
          this.$ = l[k].trim(), d.getCommonDb().setAccDescription(this.$);
          break;
        case 12:
          d.addSection(l[k].substr(8)), this.$ = l[k].substr(8);
          break;
        case 15:
          d.addTask(l[k], 0, ""), this.$ = l[k];
          break;
        case 16:
          d.addEvent(l[k].substr(2)), this.$ = l[k];
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, n(t, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: e, 12: r, 14: s, 16: h, 17: o, 18: 14, 19: 15, 20: p, 21: g }, n(t, [2, 7], { 1: [2, 1] }), n(t, [2, 3]), { 9: 18, 11: e, 12: r, 14: s, 16: h, 17: o, 18: 14, 19: 15, 20: p, 21: g }, n(t, [2, 5]), n(t, [2, 6]), n(t, [2, 8]), { 13: [1, 19] }, { 15: [1, 20] }, n(t, [2, 11]), n(t, [2, 12]), n(t, [2, 13]), n(t, [2, 14]), n(t, [2, 15]), n(t, [2, 16]), n(t, [2, 4]), n(t, [2, 9]), n(t, [2, 10])],
    defaultActions: {},
    parseError: /* @__PURE__ */ a(function(x, i) {
      if (i.recoverable)
        this.trace(x);
      else {
        var c = new Error(x);
        throw c.hash = i, c;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ a(function(x) {
      var i = this, c = [0], d = [], u = [null], l = [], b = this.table, k = "", $ = 0, N = 0, O = 2, L = 1, j = l.slice.call(arguments, 1), m = Object.create(this.lexer), v = { yy: {} };
      for (var I in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, I) && (v.yy[I] = this.yy[I]);
      m.setInput(x, v.yy), v.yy.lexer = m, v.yy.parser = this, typeof m.yylloc > "u" && (m.yylloc = {});
      var M = m.yylloc;
      l.push(M);
      var C = m.options && m.options.ranges;
      typeof v.yy.parseError == "function" ? this.parseError = v.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function B(E) {
        c.length = c.length - 2 * E, u.length = u.length - E, l.length = l.length - E;
      }
      a(B, "popStack");
      function F() {
        var E;
        return E = d.pop() || m.lex() || L, typeof E != "number" && (E instanceof Array && (d = E, E = d.pop()), E = i.symbols_[E] || E), E;
      }
      a(F, "lex");
      for (var w, P, T, Z, R = {}, W, A, tt, q; ; ) {
        if (P = c[c.length - 1], this.defaultActions[P] ? T = this.defaultActions[P] : ((w === null || typeof w > "u") && (w = F()), T = b[P] && b[P][w]), typeof T > "u" || !T.length || !T[0]) {
          var G = "";
          q = [];
          for (W in b[P])
            this.terminals_[W] && W > O && q.push("'" + this.terminals_[W] + "'");
          m.showPosition ? G = "Parse error on line " + ($ + 1) + `:
` + m.showPosition() + `
Expecting ` + q.join(", ") + ", got '" + (this.terminals_[w] || w) + "'" : G = "Parse error on line " + ($ + 1) + ": Unexpected " + (w == L ? "end of input" : "'" + (this.terminals_[w] || w) + "'"), this.parseError(G, {
            text: m.match,
            token: this.terminals_[w] || w,
            line: m.yylineno,
            loc: M,
            expected: q
          });
        }
        if (T[0] instanceof Array && T.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + P + ", token: " + w);
        switch (T[0]) {
          case 1:
            c.push(w), u.push(m.yytext), l.push(m.yylloc), c.push(T[1]), w = null, N = m.yyleng, k = m.yytext, $ = m.yylineno, M = m.yylloc;
            break;
          case 2:
            if (A = this.productions_[T[1]][1], R.$ = u[u.length - A], R._$ = {
              first_line: l[l.length - (A || 1)].first_line,
              last_line: l[l.length - 1].last_line,
              first_column: l[l.length - (A || 1)].first_column,
              last_column: l[l.length - 1].last_column
            }, C && (R._$.range = [
              l[l.length - (A || 1)].range[0],
              l[l.length - 1].range[1]
            ]), Z = this.performAction.apply(R, [
              k,
              N,
              $,
              v.yy,
              T[1],
              u,
              l
            ].concat(j)), typeof Z < "u")
              return Z;
            A && (c = c.slice(0, -1 * A * 2), u = u.slice(0, -1 * A), l = l.slice(0, -1 * A)), c.push(this.productions_[T[1]][0]), u.push(R.$), l.push(R._$), tt = b[c[c.length - 2]][c[c.length - 1]], c.push(tt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, y = /* @__PURE__ */ function() {
    var x = {
      EOF: 1,
      parseError: /* @__PURE__ */ a(function(i, c) {
        if (this.yy.parser)
          this.yy.parser.parseError(i, c);
        else
          throw new Error(i);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ a(function(i, c) {
        return this.yy = c || this.yy || {}, this._input = i, 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 i = this._input[0];
        this.yytext += i, this.yyleng++, this.offset++, this.match += i, this.matched += i;
        var c = i.match(/(?:\r\n?|\n).*/g);
        return c ? (this.yylineno++, this.yylloc.last_line++) : this.yylloc.last_column++, this.options.ranges && this.yylloc.range[1]++, this._input = this._input.slice(1), i;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ a(function(i) {
        var c = i.length, d = i.split(/(?:\r\n?|\n)/g);
        this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - c), this.offset -= c;
        var u = 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), d.length - 1 && (this.yylineno -= d.length - 1);
        var l = 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: d ? (d.length === u.length ? this.yylloc.first_column : 0) + u[u.length - d.length].length - d[0].length : this.yylloc.first_column - c
        }, this.options.ranges && (this.yylloc.range = [l[0], l[0] + this.yyleng - c]), 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(i) {
        this.unput(this.match.slice(i));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ a(function() {
        var i = this.matched.substr(0, this.matched.length - this.match.length);
        return (i.length > 20 ? "..." : "") + i.substr(-20).replace(/\n/g, "");
      }, "pastInput"),
      // displays upcoming input, i.e. for error messages
      upcomingInput: /* @__PURE__ */ a(function() {
        var i = this.match;
        return i.length < 20 && (i += this._input.substr(0, 20 - i.length)), (i.substr(0, 20) + (i.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 i = this.pastInput(), c = new Array(i.length + 1).join("-");
        return i + this.upcomingInput() + `
` + c + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ a(function(i, c) {
        var d, u, l;
        if (this.options.backtrack_lexer && (l = {
          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 && (l.yylloc.range = this.yylloc.range.slice(0))), u = i[0].match(/(?:\r\n?|\n).*/g), u && (this.yylineno += u.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: u ? u[u.length - 1].length - u[u.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + i[0].length
        }, this.yytext += i[0], this.match += i[0], this.matches = i, 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(i[0].length), this.matched += i[0], d = this.performAction.call(this, this.yy, this, c, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), d)
          return d;
        if (this._backtrack) {
          for (var b in l)
            this[b] = l[b];
          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 i, c, d, u;
        this._more || (this.yytext = "", this.match = "");
        for (var l = this._currentRules(), b = 0; b < l.length; b++)
          if (d = this._input.match(this.rules[l[b]]), d && (!c || d[0].length > c[0].length)) {
            if (c = d, u = b, this.options.backtrack_lexer) {
              if (i = this.test_match(d, l[b]), i !== !1)
                return i;
              if (this._backtrack) {
                c = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return c ? (i = this.test_match(c, l[u]), i !== !1 ? i : !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 i = this.next();
        return i || this.lex();
      }, "lex"),
      // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
      begin: /* @__PURE__ */ a(function(i) {
        this.conditionStack.push(i);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ a(function() {
        var i = this.conditionStack.length - 1;
        return i > 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(i) {
        return i = this.conditionStack.length - 1 - Math.abs(i || 0), i >= 0 ? this.conditionStack[i] : "INITIAL";
      }, "topState"),
      // alias for begin(condition)
      pushState: /* @__PURE__ */ a(function(i) {
        this.begin(i);
      }, "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(i, c, d, u) {
        switch (d) {
          case 0:
            break;
          case 1:
            break;
          case 2:
            return 10;
          case 3:
            break;
          case 4:
            break;
          case 5:
            return 4;
          case 6:
            return 11;
          case 7:
            return this.begin("acc_title"), 12;
          case 8:
            return this.popState(), "acc_title_value";
          case 9:
            return this.begin("acc_descr"), 14;
          case 10:
            return this.popState(), "acc_descr_value";
          case 11:
            this.begin("acc_descr_multiline");
            break;
          case 12:
            this.popState();
            break;
          case 13:
            return "acc_descr_multiline_value";
          case 14:
            return 17;
          case 15:
            return 21;
          case 16:
            return 20;
          case 17:
            return 6;
          case 18:
            return "INVALID";
        }
      }, "anonymous"),
      rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:timeline\b)/i, /^(?:title\s[^\n]+)/i, /^(?:accTitle\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*:\s*)/i, /^(?:(?!\n||)*[^\n]*)/i, /^(?:accDescr\s*\{\s*)/i, /^(?:[\}])/i, /^(?:[^\}]*)/i, /^(?:section\s[^:\n]+)/i, /^(?::\s[^:\n]+)/i, /^(?:[^#:\n]+)/i, /^(?:$)/i, /^(?:.)/i],
      conditions: { acc_descr_multiline: { rules: [12, 13], inclusive: !1 }, acc_descr: { rules: [10], inclusive: !1 }, acc_title: { rules: [8], inclusive: !1 }, INITIAL: { rules: [0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 14, 15, 16, 17, 18], inclusive: !0 } }
    };
    return x;
  }();
  f.lexer = y;
  function _() {
    this.yy = {};
  }
  return a(_, "Parser"), _.prototype = f, f.Parser = _, new _();
}();
J.parser = J;
var $t = J, at = {};
vt(at, {
  addEvent: () => pt,
  addSection: () => lt,
  addTask: () => ut,
  addTaskOrg: () => yt,
  clear: () => ct,
  default: () => Et,
  getCommonDb: () => ot,
  getSections: () => ht,
  getTasks: () => dt
});
var D = "", rt = 0, X = [], U = [], z = [], ot = /* @__PURE__ */ a(() => wt, "getCommonDb"), ct = /* @__PURE__ */ a(function() {
  X.length = 0, U.length = 0, D = "", z.length = 0, St();
}, "clear"), lt = /* @__PURE__ */ a(function(n) {
  D = n, X.push(n);
}, "addSection"), ht = /* @__PURE__ */ a(function() {
  return X;
}, "getSections"), dt = /* @__PURE__ */ a(function() {
  let n = nt();
  const t = 100;
  let e = 0;
  for (; !n && e < t; )
    n = nt(), e++;
  return U.push(...z), U;
}, "getTasks"), ut = /* @__PURE__ */ a(function(n, t, e) {
  const r = {
    id: rt++,
    section: D,
    type: D,
    task: n,
    score: t || 0,
    //if event is defined, then add it the events array
    events: e ? [e] : []
  };
  z.push(r);
}, "addTask"), pt = /* @__PURE__ */ a(function(n) {
  z.find((t) => t.id === rt - 1).events.push(n);
}, "addEvent"), yt = /* @__PURE__ */ a(function(n) {
  const t = {
    section: D,
    type: D,
    description: n,
    task: n,
    classes: []
  };
  U.push(t);
}, "addTaskOrg"), nt = /* @__PURE__ */ a(function() {
  const n = /* @__PURE__ */ a(function(e) {
    return z[e].processed;
  }, "compileTask");
  let t = !0;
  for (const [e, r] of z.entries())
    n(e), t = t && r.processed;
  return t;
}, "compileTasks"), Et = {
  clear: ct,
  getCommonDb: ot,
  addSection: lt,
  getSections: ht,
  getTasks: dt,
  addTask: ut,
  addTaskOrg: yt,
  addEvent: pt
}, Tt = 12, Y = /* @__PURE__ */ a(function(n, t) {
  const e = n.append("rect");
  return e.attr("x", t.x), e.attr("y", t.y), e.attr("fill", t.fill), e.attr("stroke", t.stroke), e.attr("width", t.width), e.attr("height", t.height), e.attr("rx", t.rx), e.attr("ry", t.ry), t.class !== void 0 && e.attr("class", t.class), e;
}, "drawRect"), It = /* @__PURE__ */ a(function(n, t) {
  const e = n.append("circle").attr("cx", t.cx).attr("cy", t.cy).attr("class", "face").attr("r", 15).attr("stroke-width", 2).attr("overflow", "visible"), r = n.append("g");
  r.append("circle").attr("cx", t.cx - 15 / 3).attr("cy", t.cy - 15 / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666"), r.append("circle").attr("cx", t.cx + 15 / 3).attr("cy", t.cy - 15 / 3).attr("r", 1.5).attr("stroke-width", 2).attr("fill", "#666").attr("stroke", "#666");
  function s(p) {
    const g = et().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(7.5).outerRadius(6.8181818181818175);
    p.append("path").attr("class", "mouth").attr("d", g).attr("transform", "translate(" + t.cx + "," + (t.cy + 2) + ")");
  }
  a(s, "smile");
  function h(p) {
    const g = et().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(7.5).outerRadius(6.8181818181818175);
    p.append("path").attr("class", "mouth").attr("d", g).attr("transform", "translate(" + t.cx + "," + (t.cy + 7) + ")");
  }
  a(h, "sad");
  function o(p) {
    p.append("line").attr("class", "mouth").attr("stroke", 2).attr("x1", t.cx - 5).attr("y1", t.cy + 7).attr("x2", t.cx + 5).attr("y2", t.cy + 7).attr("class", "mouth").attr("stroke-width", "1px").attr("stroke", "#666");
  }
  return a(o, "ambivalent"), t.score > 3 ? s(r) : t.score < 3 ? h(r) : o(r), e;
}, "drawFace"), Mt = /* @__PURE__ */ a(function(n, t) {
  const e = n.append("circle");
  return e.attr("cx", t.cx), e.attr("cy", t.cy), e.attr("class", "actor-" + t.pos), e.attr("fill", t.fill), e.attr("stroke", t.stroke), e.attr("r", t.r), e.class !== void 0 && e.attr("class", e.class), t.title !== void 0 && e.append("title").text(t.title), e;
}, "drawCircle"), gt = /* @__PURE__ */ a(function(n, t) {
  const e = t.text.replace(/<br\s*\/?>/gi, " "), r = n.append("text");
  r.attr("x", t.x), r.attr("y", t.y), r.attr("class", "legend"), r.style("text-anchor", t.anchor), t.class !== void 0 && r.attr("class", t.class);
  const s = r.append("tspan");
  return s.attr("x", t.x + t.textMargin * 2), s.text(e), r;
}, "drawText"), At = /* @__PURE__ */ a(function(n, t) {
  function e(s, h, o, p, g) {
    return s + "," + h + " " + (s + o) + "," + h + " " + (s + o) + "," + (h + p - g) + " " + (s + o - g * 1.2) + "," + (h + p) + " " + s + "," + (h + p);
  }
  a(e, "genPoints");
  const r = n.append("polygon");
  r.attr("points", e(t.x, t.y, 50, 20, 7)), r.attr("class", "labelBox"), t.y = t.y + t.labelMargin, t.x = t.x + 0.5 * t.labelMargin, gt(n, t);
}, "drawLabel"), Lt = /* @__PURE__ */ a(function(n, t, e) {
  const r = n.append("g"), s = K();
  s.x = t.x, s.y = t.y, s.fill = t.fill, s.width = e.width, s.height = e.height, s.class = "journey-section section-type-" + t.num, s.rx = 3, s.ry = 3, Y(r, s), ft(e)(
    t.text,
    r,
    s.x,
    s.y,
    s.width,
    s.height,
    { class: "journey-section section-type-" + t.num },
    e,
    t.colour
  );
}, "drawSection"), it = -1, Pt = /* @__PURE__ */ a(function(n, t, e) {
  const r = t.x + e.width / 2, s = n.append("g");
  it++;
  const h = 300 + 5 * 30;
  s.append("line").attr("id", "task" + it).attr("x1", r).attr("y1", t.y).attr("x2", r).attr("y2", h).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"), It(s, {
    cx: r,
    cy: 300 + (5 - t.score) * 30,
    score: t.score
  });
  const o = K();
  o.x = t.x, o.y = t.y, o.fill = t.fill, o.width = e.width, o.height = e.height, o.class = "task task-type-" + t.num, o.rx = 3, o.ry = 3, Y(s, o), ft(e)(
    t.task,
    s,
    o.x,
    o.y,
    o.width,
    o.height,
    { class: "task" },
    e,
    t.colour
  );
}, "drawTask"), Ht = /* @__PURE__ */ a(function(n, t) {
  Y(n, {
    x: t.startx,
    y: t.starty,
    width: t.stopx - t.startx,
    height: t.stopy - t.starty,
    fill: t.fill,
    class: "rect"
  }).lower();
}, "drawBackgroundRect"), Ot = /* @__PURE__ */ a(function() {
  return {
    x: 0,
    y: 0,
    fill: void 0,
    "text-anchor": "start",
    width: 100,
    height: 100,
    textMargin: 0,
    rx: 0,
    ry: 0
  };
}, "getTextObj"), K = /* @__PURE__ */ a(function() {
  return {
    x: 0,
    y: 0,
    width: 100,
    anchor: "start",
    height: 100,
    rx: 0,
    ry: 0
  };
}, "getNoteRect"), ft = /* @__PURE__ */ function() {
  function n(s, h, o, p, g, f, y, _) {
    const x = h.append("text").attr("x", o + g / 2).attr("y", p + f / 2 + 5).style("font-color", _).style("text-anchor", "middle").text(s);
    r(x, y);
  }
  a(n, "byText");
  function t(s, h, o, p, g, f, y, _, x) {
    const { taskFontSize: i, taskFontFamily: c } = _, d = s.split(/<br\s*\/?>/gi);
    for (let u = 0; u < d.length; u++) {
      const l = u * i - i * (d.length - 1) / 2, b = h.append("text").attr("x", o + g / 2).attr("y", p).attr("fill", x).style("text-anchor", "middle").style("font-size", i).style("font-family", c);
      b.append("tspan").attr("x", o + g / 2).attr("dy", l).text(d[u]), b.attr("y", p + f / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"), r(b, y);
    }
  }
  a(t, "byTspan");
  function e(s, h, o, p, g, f, y, _) {
    const x = h.append("switch"), i = x.append("foreignObject").attr("x", o).attr("y", p).attr("width", g).attr("height", f).attr("position", "fixed").append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
    i.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(s), t(s, x, o, p, g, f, y, _), r(i, y);
  }
  a(e, "byFo");
  function r(s, h) {
    for (const o in h)
      o in h && s.attr(o, h[o]);
  }
  return a(r, "_setTextAttrs"), function(s) {
    return s.textPlacement === "fo" ? e : s.textPlacement === "old" ? n : t;
  };
}(), Ct = /* @__PURE__ */ a(function(n) {
  n.append("defs").append("marker").attr("id", "arrowhead").attr("refX", 5).attr("refY", 2).attr("markerWidth", 6).attr("markerHeight", 4).attr("orient", "auto").append("path").attr("d", "M 0,0 V 4 L6,2 Z");
}, "initGraphics");
function Q(n, t) {
  n.each(function() {
    var e = V(this), r = e.text().split(/(\s+|<br>)/).reverse(), s, h = [], o = 1.1, p = e.attr("y"), g = parseFloat(e.attr("dy")), f = e.text(null).append("tspan").attr("x", 0).attr("y", p).attr("dy", g + "em");
    for (let y = 0; y < r.length; y++)
      s = r[r.length - 1 - y], h.push(s), f.text(h.join(" ").trim()), (f.node().getComputedTextLength() > t || s === "<br>") && (h.pop(), f.text(h.join(" ").trim()), s === "<br>" ? h = [""] : h = [s], f = e.append("tspan").attr("x", 0).attr("y", p).attr("dy", o + "em").text(s));
  });
}
a(Q, "wrap");
var Rt = /* @__PURE__ */ a(function(n, t, e, r) {
  var s;
  const h = e % Tt - 1, o = n.append("g");
  t.section = h, o.attr(
    "class",
    (t.class ? t.class + " " : "") + "timeline-node " + ("section-" + h)
  );
  const p = o.append("g"), g = o.append("g"), f = g.append("text").text(t.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(Q, t.width).node().getBBox(), y = (s = r.fontSize) != null && s.replace ? r.fontSize.replace("px", "") : r.fontSize;
  return t.height = f.height + y * 1.1 * 0.5 + t.padding, t.height = Math.max(t.height, t.maxHeight), t.width = t.width + 2 * t.padding, g.attr("transform", "translate(" + t.width / 2 + ", " + t.padding / 2 + ")"), zt(p, t, h, r), t;
}, "drawNode"), Dt = /* @__PURE__ */ a(function(n, t, e) {
  var r;
  const s = n.append("g"), h = s.append("text").text(t.descr).attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle").call(Q, t.width).node().getBBox(), o = (r = e.fontSize) != null && r.replace ? e.fontSize.replace("px", "") : e.fontSize;
  return s.remove(), h.height + o * 1.1 * 0.5 + t.padding;
}, "getVirtualNodeHeight"), zt = /* @__PURE__ */ a(function(n, t, e) {
  n.append("path").attr("id", "node-" + t.id).attr("class", "node-bkg node-" + t.type).attr(
    "d",
    `M0 ${t.height - 5} v${-t.height + 2 * 5} q0,-5 5,-5 h${t.width - 2 * 5} q5,0 5,5 v${t.height - 5} H0 Z`
  ), n.append("line").attr("class", "node-line-" + e).attr("x1", 0).attr("y1", t.height).attr("x2", t.width).attr("y2", t.height);
}, "defaultBkg"), H = {
  drawRect: Y,
  drawCircle: Mt,
  drawSection: Lt,
  drawText: gt,
  drawLabel: At,
  drawTask: Pt,
  drawBackgroundRect: Ht,
  getTextObj: Ot,
  getNoteRect: K,
  initGraphics: Ct,
  drawNode: Rt,
  getVirtualNodeHeight: Dt
}, Nt = /* @__PURE__ */ a(function(n, t, e, r) {
  var s, h;
  const o = mt(), p = o.leftMargin ?? 50;
  S.debug("timeline", r.db);
  const g = o.securityLevel;
  let f;
  g === "sandbox" && (f = V("#i" + t));
  const y = (g === "sandbox" ? V(f.nodes()[0].contentDocument.body) : V("body")).select("#" + t);
  y.append("g");
  const _ = r.db.getTasks(), x = r.db.getCommonDb().getDiagramTitle();
  S.debug("task", _), H.initGraphics(y);
  const i = r.db.getSections();
  S.debug("sections", i);
  let c = 0, d = 0, u = 0, l = 0, b = 50 + p, k = 50;
  l = 50;
  let $ = 0, N = !0;
  i.forEach(function(m) {
    const v = {
      number: $,
      descr: m,
      section: $,
      width: 150,
      padding: 20,
      maxHeight: c
    }, I = H.getVirtualNodeHeight(y, v, o);
    S.debug("sectionHeight before draw", I), c = Math.max(c, I + 20);
  });
  let O = 0, L = 0;
  S.debug("tasks.length", _.length);
  for (const [m, v] of _.entries()) {
    const I = {
      number: m,
      descr: v,
      section: v.section,
      width: 150,
      padding: 20,
      maxHeight: d
    }, M = H.getVirtualNodeHeight(y, I, o);
    S.debug("taskHeight before draw", M), d = Math.max(d, M + 20), O = Math.max(O, v.events.length);
    let C = 0;
    for (const B of v.events) {
      const F = {
        descr: B,
        section: v.section,
        number: v.section,
        width: 150,
        padding: 20,
        maxHeight: 50
      };
      C += H.getVirtualNodeHeight(y, F, o);
    }
    L = Math.max(L, C);
  }
  S.debug("maxSectionHeight before draw", c), S.debug("maxTaskHeight before draw", d), i && i.length > 0 ? i.forEach((m) => {
    const v = _.filter((B) => B.section === m), I = {
      number: $,
      descr: m,
      section: $,
      width: 200 * Math.max(v.length, 1) - 50,
      padding: 20,
      maxHeight: c
    };
    S.debug("sectionNode", I);
    const M = y.append("g"), C = H.drawNode(M, I, $, o);
    S.debug("sectionNode output", C), M.attr("transform", `translate(${b}, ${l})`), k += c + 50, v.length > 0 && st(
      y,
      v,
      $,
      b,
      k,
      d,
      o,
      O,
      L,
      c,
      !1
    ), b += 200 * Math.max(v.length, 1), k = l, $++;
  }) : (N = !1, st(
    y,
    _,
    $,
    b,
    k,
    d,
    o,
    O,
    L,
    c,
    !0
  ));
  const j = y.node().getBBox();
  S.debug("bounds", j), x && y.append("text").text(x).attr("x", j.width / 2 - p).attr("font-size", "4ex").attr("font-weight", "bold").attr("y", 20), u = N ? c + d + 150 : d + 100, y.append("g").attr("class", "lineWrapper").append("line").attr("x1", p).attr("y1", u).attr("x2", j.width + 3 * p).attr("y2", u).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#arrowhead)"), xt(
    void 0,
    y,
    ((s = o.timeline) == null ? void 0 : s.padding) ?? 50,
    ((h = o.timeline) == null ? void 0 : h.useMaxWidth) ?? !1
  );
}, "draw"), st = /* @__PURE__ */ a(function(n, t, e, r, s, h, o, p, g, f, y) {
  var _;
  for (const x of t) {
    const i = {
      descr: x.task,
      section: e,
      number: e,
      width: 150,
      padding: 20,
      maxHeight: h
    };
    S.debug("taskNode", i);
    const c = n.append("g").attr("class", "taskWrapper"), d = H.drawNode(c, i, e, o).height;
    if (S.debug("taskHeight after draw", d), c.attr("transform", `translate(${r}, ${s})`), h = Math.max(h, d), x.events) {
      const u = n.append("g").attr("class", "lineWrapper");
      let l = h;
      s += 100, l = l + jt(n, x.events, e, r, s, o), s -= 100, u.append("line").attr("x1", r + 190 / 2).attr("y1", s + h).attr("x2", r + 190 / 2).attr(
        "y2",
        s + h + (y ? h : f) + g + 120
      ).attr("stroke-width", 2).attr("stroke", "black").attr("marker-end", "url(#arrowhead)").attr("stroke-dasharray", "5,5");
    }
    r = r + 200, y && !((_ = o.timeline) != null && _.disableMulticolor) && e++;
  }
  s = s - 10;
}, "drawTasks"), jt = /* @__PURE__ */ a(function(n, t, e, r, s, h) {
  let o = 0;
  const p = s;
  s = s + 100;
  for (const g of t) {
    const f = {
      descr: g,
      section: e,
      number: e,
      width: 150,
      padding: 20,
      maxHeight: 50
    };
    S.debug("eventNode", f);
    const y = n.append("g").attr("class", "eventWrapper"), _ = H.drawNode(y, f, e, h).height;
    o = o + _, y.attr("transform", `translate(${r}, ${s})`), s = s + 10 + _;
  }
  return s = p, o;
}, "drawEvents"), Bt = {
  setConf: /* @__PURE__ */ a(() => {
  }, "setConf"),
  draw: Nt
}, Ft = /* @__PURE__ */ a((n) => {
  let t = "";
  for (let e = 0; e < n.THEME_COLOR_LIMIT; e++)
    n["lineColor" + e] = n["lineColor" + e] || n["cScaleInv" + e], bt(n["lineColor" + e]) ? n["lineColor" + e] = kt(n["lineColor" + e], 20) : n["lineColor" + e] = _t(n["lineColor" + e], 20);
  for (let e = 0; e < n.THEME_COLOR_LIMIT; e++) {
    const r = "" + (17 - 3 * e);
    t += `
    .section-${e - 1} rect, .section-${e - 1} path, .section-${e - 1} circle, .section-${e - 1} path  {
      fill: ${n["cScale" + e]};
    }
    .section-${e - 1} text {
     fill: ${n["cScaleLabel" + e]};
    }
    .node-icon-${e - 1} {
      font-size: 40px;
      color: ${n["cScaleLabel" + e]};
    }
    .section-edge-${e - 1}{
      stroke: ${n["cScale" + e]};
    }
    .edge-depth-${e - 1}{
      stroke-width: ${r};
    }
    .section-${e - 1} line {
      stroke: ${n["cScaleInv" + e]} ;
      stroke-width: 3;
    }

    .lineWrapper line{
      stroke: ${n["cScaleLabel" + e]} ;
    }

    .disabled, .disabled circle, .disabled text {
      fill: lightgray;
    }
    .disabled text {
      fill: #efefef;
    }
    `;
  }
  return t;
}, "genSections"), Wt = /* @__PURE__ */ a((n) => `
  .edge {
    stroke-width: 3;
  }
  ${Ft(n)}
  .section-root rect, .section-root path, .section-root circle  {
    fill: ${n.git0};
  }
  .section-root text {
    fill: ${n.gitBranchLabel0};
  }
  .icon-container {
    height:100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .edge {
    fill: none;
  }
  .eventWrapper  {
   filter: brightness(120%);
  }
`, "getStyles"), qt = Wt, Yt = {
  db: at,
  renderer: Bt,
  parser: $t,
  styles: qt
};
export {
  Yt as diagram
};
