import { l as ft } from "./chunk-FMBD7UC4-CAMVhC3j-oHcHavNU.js";
import { p as gt, h as rt, y as mt, x as xt } from "./chunk-YZCP3GAM-D78rBxvk-E0y6EYmh.js";
import { a8 as kt, a7 as _t, a9 as bt, aa as vt, ap as wt, ao as $t, _ as a, g as B, a5 as X, ab as St, av as Tt } from "./index-Bh-wTBlD.js";
import { h as et } from "./arc-Da5qnJCa-D1fJq9Ga.js";
var U = function() {
  var e = /* @__PURE__ */ a(function(d, i, n, y) {
    for (n = n || {}, y = d.length; y--; n[d[y]] = i) ;
    return n;
  }, "o"), t = [6, 8, 10, 11, 12, 14, 16, 17, 18], o = [1, 9], p = [1, 10], s = [1, 11], l = [1, 12], c = [1, 13], h = [1, 14], f = {
    trace: /* @__PURE__ */ a(function() {
    }, "trace"),
    yy: {},
    symbols_: { error: 2, start: 3, journey: 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, taskName: 18, taskData: 19, $accept: 0, $end: 1 },
    terminals_: { 2: "error", 4: "journey", 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", 18: "taskName", 19: "taskData" },
    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, 2]],
    performAction: /* @__PURE__ */ a(function(d, i, n, y, u, r, k) {
      var x = r.length - 1;
      switch (u) {
        case 1:
          return r[x - 1];
        case 2:
          this.$ = [];
          break;
        case 3:
          r[x - 1].push(r[x]), this.$ = r[x - 1];
          break;
        case 4:
        case 5:
          this.$ = r[x];
          break;
        case 6:
        case 7:
          this.$ = [];
          break;
        case 8:
          y.setDiagramTitle(r[x].substr(6)), this.$ = r[x].substr(6);
          break;
        case 9:
          this.$ = r[x].trim(), y.setAccTitle(this.$);
          break;
        case 10:
        case 11:
          this.$ = r[x].trim(), y.setAccDescription(this.$);
          break;
        case 12:
          y.addSection(r[x].substr(8)), this.$ = r[x].substr(8);
          break;
        case 13:
          y.addTask(r[x - 1], r[x]), this.$ = "task";
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, e(t, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: o, 12: p, 14: s, 16: l, 17: c, 18: h }, e(t, [2, 7], { 1: [2, 1] }), e(t, [2, 3]), { 9: 15, 11: o, 12: p, 14: s, 16: l, 17: c, 18: h }, e(t, [2, 5]), e(t, [2, 6]), e(t, [2, 8]), { 13: [1, 16] }, { 15: [1, 17] }, e(t, [2, 11]), e(t, [2, 12]), { 19: [1, 18] }, e(t, [2, 4]), e(t, [2, 9]), e(t, [2, 10]), e(t, [2, 13])],
    defaultActions: {},
    parseError: /* @__PURE__ */ a(function(d, i) {
      if (i.recoverable)
        this.trace(d);
      else {
        var n = new Error(d);
        throw n.hash = i, n;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ a(function(d) {
      var i = this, n = [0], y = [], u = [null], r = [], k = this.table, x = "", E = 0, A = 0, ut = 2, K = 1, pt = r.slice.call(arguments, 1), _ = Object.create(this.lexer), I = { yy: {} };
      for (var z in this.yy)
        Object.prototype.hasOwnProperty.call(this.yy, z) && (I.yy[z] = this.yy[z]);
      _.setInput(d, I.yy), I.yy.lexer = _, I.yy.parser = this, typeof _.yylloc > "u" && (_.yylloc = {});
      var Y = _.yylloc;
      r.push(Y);
      var yt = _.options && _.options.ranges;
      typeof I.yy.parseError == "function" ? this.parseError = I.yy.parseError : this.parseError = Object.getPrototypeOf(this).parseError;
      function dt(v) {
        n.length = n.length - 2 * v, u.length = u.length - v, r.length = r.length - v;
      }
      a(dt, "popStack");
      function H() {
        var v;
        return v = y.pop() || _.lex() || K, typeof v != "number" && (v instanceof Array && (y = v, v = y.pop()), v = i.symbols_[v] || v), v;
      }
      a(H, "lex");
      for (var b, P, w, W, j = {}, F, T, tt, O; ; ) {
        if (P = n[n.length - 1], this.defaultActions[P] ? w = this.defaultActions[P] : ((b === null || typeof b > "u") && (b = H()), w = k[P] && k[P][b]), typeof w > "u" || !w.length || !w[0]) {
          var G = "";
          O = [];
          for (F in k[P])
            this.terminals_[F] && F > ut && O.push("'" + this.terminals_[F] + "'");
          _.showPosition ? G = "Parse error on line " + (E + 1) + `:
` + _.showPosition() + `
Expecting ` + O.join(", ") + ", got '" + (this.terminals_[b] || b) + "'" : G = "Parse error on line " + (E + 1) + ": Unexpected " + (b == K ? "end of input" : "'" + (this.terminals_[b] || b) + "'"), this.parseError(G, {
            text: _.match,
            token: this.terminals_[b] || b,
            line: _.yylineno,
            loc: Y,
            expected: O
          });
        }
        if (w[0] instanceof Array && w.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + P + ", token: " + b);
        switch (w[0]) {
          case 1:
            n.push(b), u.push(_.yytext), r.push(_.yylloc), n.push(w[1]), b = null, A = _.yyleng, x = _.yytext, E = _.yylineno, Y = _.yylloc;
            break;
          case 2:
            if (T = this.productions_[w[1]][1], j.$ = u[u.length - T], j._$ = {
              first_line: r[r.length - (T || 1)].first_line,
              last_line: r[r.length - 1].last_line,
              first_column: r[r.length - (T || 1)].first_column,
              last_column: r[r.length - 1].last_column
            }, yt && (j._$.range = [
              r[r.length - (T || 1)].range[0],
              r[r.length - 1].range[1]
            ]), W = this.performAction.apply(j, [
              x,
              A,
              E,
              I.yy,
              w[1],
              u,
              r
            ].concat(pt)), typeof W < "u")
              return W;
            T && (n = n.slice(0, -1 * T * 2), u = u.slice(0, -1 * T), r = r.slice(0, -1 * T)), n.push(this.productions_[w[1]][0]), u.push(j.$), r.push(j._$), tt = k[n[n.length - 2]][n[n.length - 1]], n.push(tt);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, m = /* @__PURE__ */ function() {
    var d = {
      EOF: 1,
      parseError: /* @__PURE__ */ a(function(i, n) {
        if (this.yy.parser)
          this.yy.parser.parseError(i, n);
        else
          throw new Error(i);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ a(function(i, n) {
        return this.yy = n || 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 n = i.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), i;
      }, "input"),
      // unshifts one char (or a string) into the input
      unput: /* @__PURE__ */ a(function(i) {
        var n = i.length, y = i.split(/(?:\r\n?|\n)/g);
        this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - n), this.offset -= n;
        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), y.length - 1 && (this.yylineno -= y.length - 1);
        var r = 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: y ? (y.length === u.length ? this.yylloc.first_column : 0) + u[u.length - y.length].length - y[0].length : this.yylloc.first_column - n
        }, this.options.ranges && (this.yylloc.range = [r[0], r[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(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(), n = new Array(i.length + 1).join("-");
        return i + this.upcomingInput() + `
` + n + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ a(function(i, n) {
        var y, u, r;
        if (this.options.backtrack_lexer && (r = {
          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 && (r.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], y = this.performAction.call(this, this.yy, this, n, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), y)
          return y;
        if (this._backtrack) {
          for (var k in r)
            this[k] = r[k];
          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, n, y, u;
        this._more || (this.yytext = "", this.match = "");
        for (var r = this._currentRules(), k = 0; k < r.length; k++)
          if (y = this._input.match(this.rules[r[k]]), y && (!n || y[0].length > n[0].length)) {
            if (n = y, u = k, this.options.backtrack_lexer) {
              if (i = this.test_match(y, r[k]), i !== !1)
                return i;
              if (this._backtrack) {
                n = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return n ? (i = this.test_match(n, r[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, n, y, u) {
        switch (y) {
          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 18;
          case 16:
            return 19;
          case 17:
            return ":";
          case 18:
            return 6;
          case 19:
            return "INVALID";
        }
      }, "anonymous"),
      rules: [/^(?:%(?!\{)[^\n]*)/i, /^(?:[^\}]%%[^\n]*)/i, /^(?:[\n]+)/i, /^(?:\s+)/i, /^(?:#[^\n]*)/i, /^(?:journey\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, /^(?:[^#:\n;]+)/i, /^(?::[^#\n;]+)/i, /^(?::)/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, 19], inclusive: !0 } }
    };
    return d;
  }();
  f.lexer = m;
  function g() {
    this.yy = {};
  }
  return a(g, "Parser"), g.prototype = f, f.Parser = g, new g();
}();
U.parser = U;
var Ct = U, V = "", Z = [], D = [], L = [], Mt = /* @__PURE__ */ a(function() {
  Z.length = 0, D.length = 0, V = "", L.length = 0, Tt();
}, "clear"), Et = /* @__PURE__ */ a(function(e) {
  V = e, Z.push(e);
}, "addSection"), It = /* @__PURE__ */ a(function() {
  return Z;
}, "getSections"), Pt = /* @__PURE__ */ a(function() {
  let e = it();
  const t = 100;
  let o = 0;
  for (; !e && o < t; )
    e = it(), o++;
  return D.push(...L), D;
}, "getTasks"), At = /* @__PURE__ */ a(function() {
  const e = [];
  return D.forEach((t) => {
    t.people && e.push(...t.people);
  }), [...new Set(e)].sort();
}, "updateActors"), jt = /* @__PURE__ */ a(function(e, t) {
  const o = t.substr(1).split(":");
  let p = 0, s = [];
  o.length === 1 ? (p = Number(o[0]), s = []) : (p = Number(o[0]), s = o[1].split(","));
  const l = s.map((h) => h.trim()), c = {
    section: V,
    type: V,
    people: l,
    task: e,
    score: p
  };
  L.push(c);
}, "addTask"), Vt = /* @__PURE__ */ a(function(e) {
  const t = {
    section: V,
    type: V,
    description: e,
    task: e,
    classes: []
  };
  D.push(t);
}, "addTaskOrg"), it = /* @__PURE__ */ a(function() {
  const e = /* @__PURE__ */ a(function(o) {
    return L[o].processed;
  }, "compileTask");
  let t = !0;
  for (const [o, p] of L.entries())
    e(o), t = t && p.processed;
  return t;
}, "compileTasks"), Bt = /* @__PURE__ */ a(function() {
  return At();
}, "getActors"), nt = {
  getConfig: /* @__PURE__ */ a(() => B().journey, "getConfig"),
  clear: Mt,
  setDiagramTitle: $t,
  getDiagramTitle: wt,
  setAccTitle: vt,
  getAccTitle: bt,
  setAccDescription: _t,
  getAccDescription: kt,
  addSection: Et,
  getSections: It,
  getTasks: Pt,
  addTask: jt,
  addTaskOrg: Vt,
  getActors: Bt
}, Dt = /* @__PURE__ */ a((e) => `.label {
    font-family: ${e.fontFamily};
    color: ${e.textColor};
  }
  .mouth {
    stroke: #666;
  }

  line {
    stroke: ${e.textColor}
  }

  .legend {
    fill: ${e.textColor};
    font-family: ${e.fontFamily};
  }

  .label text {
    fill: #333;
  }
  .label {
    color: ${e.textColor}
  }

  .face {
    ${e.faceColor ? `fill: ${e.faceColor}` : "fill: #FFF8DC"};
    stroke: #999;
  }

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

  .node .label {
    text-align: center;
  }
  .node.clickable {
    cursor: pointer;
  }

  .arrowheadPath {
    fill: ${e.arrowheadColor};
  }

  .edgePath .path {
    stroke: ${e.lineColor};
    stroke-width: 1.5px;
  }

  .flowchart-link {
    stroke: ${e.lineColor};
    fill: none;
  }

  .edgeLabel {
    background-color: ${e.edgeLabelBackground};
    rect {
      opacity: 0.5;
    }
    text-align: center;
  }

  .cluster rect {
  }

  .cluster text {
    fill: ${e.titleColor};
  }

  div.mermaidTooltip {
    position: absolute;
    text-align: center;
    max-width: 200px;
    padding: 2px;
    font-family: ${e.fontFamily};
    font-size: 12px;
    background: ${e.tertiaryColor};
    border: 1px solid ${e.border2};
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
  }

  .task-type-0, .section-type-0  {
    ${e.fillType0 ? `fill: ${e.fillType0}` : ""};
  }
  .task-type-1, .section-type-1  {
    ${e.fillType0 ? `fill: ${e.fillType1}` : ""};
  }
  .task-type-2, .section-type-2  {
    ${e.fillType0 ? `fill: ${e.fillType2}` : ""};
  }
  .task-type-3, .section-type-3  {
    ${e.fillType0 ? `fill: ${e.fillType3}` : ""};
  }
  .task-type-4, .section-type-4  {
    ${e.fillType0 ? `fill: ${e.fillType4}` : ""};
  }
  .task-type-5, .section-type-5  {
    ${e.fillType0 ? `fill: ${e.fillType5}` : ""};
  }
  .task-type-6, .section-type-6  {
    ${e.fillType0 ? `fill: ${e.fillType6}` : ""};
  }
  .task-type-7, .section-type-7  {
    ${e.fillType0 ? `fill: ${e.fillType7}` : ""};
  }

  .actor-0 {
    ${e.actor0 ? `fill: ${e.actor0}` : ""};
  }
  .actor-1 {
    ${e.actor1 ? `fill: ${e.actor1}` : ""};
  }
  .actor-2 {
    ${e.actor2 ? `fill: ${e.actor2}` : ""};
  }
  .actor-3 {
    ${e.actor3 ? `fill: ${e.actor3}` : ""};
  }
  .actor-4 {
    ${e.actor4 ? `fill: ${e.actor4}` : ""};
  }
  .actor-5 {
    ${e.actor5 ? `fill: ${e.actor5}` : ""};
  }
  ${ft()}
`, "getStyles"), Lt = Dt, J = /* @__PURE__ */ a(function(e, t) {
  return xt(e, t);
}, "drawRect"), Rt = /* @__PURE__ */ a(function(e, t) {
  const o = e.append("circle").attr("cx", t.cx).attr("cy", t.cy).attr("class", "face").attr("r", 15).attr("stroke-width", 2).attr("overflow", "visible"), p = e.append("g");
  p.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"), p.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(h) {
    const f = et().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(7.5).outerRadius(6.8181818181818175);
    h.append("path").attr("class", "mouth").attr("d", f).attr("transform", "translate(" + t.cx + "," + (t.cy + 2) + ")");
  }
  a(s, "smile");
  function l(h) {
    const f = et().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(7.5).outerRadius(6.8181818181818175);
    h.append("path").attr("class", "mouth").attr("d", f).attr("transform", "translate(" + t.cx + "," + (t.cy + 7) + ")");
  }
  a(l, "sad");
  function c(h) {
    h.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(c, "ambivalent"), t.score > 3 ? s(p) : t.score < 3 ? l(p) : c(p), o;
}, "drawFace"), ot = /* @__PURE__ */ a(function(e, t) {
  const o = e.append("circle");
  return o.attr("cx", t.cx), o.attr("cy", t.cy), o.attr("class", "actor-" + t.pos), o.attr("fill", t.fill), o.attr("stroke", t.stroke), o.attr("r", t.r), o.class !== void 0 && o.attr("class", o.class), t.title !== void 0 && o.append("title").text(t.title), o;
}, "drawCircle"), lt = /* @__PURE__ */ a(function(e, t) {
  return mt(e, t);
}, "drawText"), Ft = /* @__PURE__ */ a(function(e, t) {
  function o(s, l, c, h, f) {
    return s + "," + l + " " + (s + c) + "," + l + " " + (s + c) + "," + (l + h - f) + " " + (s + c - f * 1.2) + "," + (l + h) + " " + s + "," + (l + h);
  }
  a(o, "genPoints");
  const p = e.append("polygon");
  p.attr("points", o(t.x, t.y, 50, 20, 7)), p.attr("class", "labelBox"), t.y = t.y + t.labelMargin, t.x = t.x + 0.5 * t.labelMargin, lt(e, t);
}, "drawLabel"), Ot = /* @__PURE__ */ a(function(e, t, o) {
  const p = e.append("g"), s = rt();
  s.x = t.x, s.y = t.y, s.fill = t.fill, s.width = o.width * t.taskCount + // width of the tasks
  o.diagramMarginX * (t.taskCount - 1), s.height = o.height, s.class = "journey-section section-type-" + t.num, s.rx = 3, s.ry = 3, J(p, s), ct(o)(
    t.text,
    p,
    s.x,
    s.y,
    s.width,
    s.height,
    { class: "journey-section section-type-" + t.num },
    o,
    t.colour
  );
}, "drawSection"), Q = -1, Nt = /* @__PURE__ */ a(function(e, t, o, p) {
  const s = t.x + o.width / 2, l = e.append("g");
  Q++, l.append("line").attr("id", p + "-task" + Q).attr("x1", s).attr("y1", t.y).attr("x2", s).attr("y2", 450).attr("class", "task-line").attr("stroke-width", "1px").attr("stroke-dasharray", "4 2").attr("stroke", "#666"), Rt(l, {
    cx: s,
    cy: 300 + (5 - t.score) * 30,
    score: t.score
  });
  const c = rt();
  c.x = t.x, c.y = t.y, c.fill = t.fill, c.width = o.width, c.height = o.height, c.class = "task task-type-" + t.num, c.rx = 3, c.ry = 3, J(l, c);
  let h = t.x + 14;
  t.people.forEach((f) => {
    const m = t.actors[f].color, g = {
      cx: h,
      cy: t.y,
      r: 7,
      fill: m,
      stroke: "#000",
      title: f,
      pos: t.actors[f].position
    };
    ot(l, g), h += 10;
  }), ct(o)(
    t.task,
    l,
    c.x,
    c.y,
    c.width,
    c.height,
    { class: "task" },
    o,
    t.colour
  );
}, "drawTask"), zt = /* @__PURE__ */ a(function(e, t) {
  gt(e, t);
}, "drawBackgroundRect"), ct = /* @__PURE__ */ function() {
  function e(s, l, c, h, f, m, g, d) {
    const i = l.append("text").attr("x", c + f / 2).attr("y", h + m / 2 + 5).style("font-color", d).style("text-anchor", "middle").text(s);
    p(i, g);
  }
  a(e, "byText");
  function t(s, l, c, h, f, m, g, d, i) {
    const { taskFontSize: n, taskFontFamily: y } = d, u = s.split(/<br\s*\/?>/gi);
    for (let r = 0; r < u.length; r++) {
      const k = r * n - n * (u.length - 1) / 2, x = l.append("text").attr("x", c + f / 2).attr("y", h).attr("fill", i).style("text-anchor", "middle").style("font-size", n).style("font-family", y);
      x.append("tspan").attr("x", c + f / 2).attr("dy", k).text(u[r]), x.attr("y", h + m / 2).attr("dominant-baseline", "central").attr("alignment-baseline", "central"), p(x, g);
    }
  }
  a(t, "byTspan");
  function o(s, l, c, h, f, m, g, d) {
    const i = l.append("switch"), n = i.append("foreignObject").attr("x", c).attr("y", h).attr("width", f).attr("height", m).attr("position", "fixed").append("xhtml:div").style("display", "table").style("height", "100%").style("width", "100%");
    n.append("div").attr("class", "label").style("display", "table-cell").style("text-align", "center").style("vertical-align", "middle").text(s), t(s, i, c, h, f, m, g, d), p(n, g);
  }
  a(o, "byFo");
  function p(s, l) {
    for (const c in l)
      c in l && s.attr(c, l[c]);
  }
  return a(p, "_setTextAttrs"), function(s) {
    return s.textPlacement === "fo" ? o : s.textPlacement === "old" ? e : t;
  };
}(), Yt = /* @__PURE__ */ a(function(e, t) {
  Q = -1, e.append("defs").append("marker").attr("id", t + "-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"), R = {
  drawRect: J,
  drawCircle: ot,
  drawSection: Ot,
  drawText: lt,
  drawLabel: Ft,
  drawTask: Nt,
  drawBackgroundRect: zt,
  initGraphics: Yt
}, Wt = /* @__PURE__ */ a(function(e) {
  Object.keys(e).forEach(function(t) {
    S[t] = e[t];
  });
}, "setConf"), C = {}, N = 0;
function ht(e) {
  const t = B().journey, o = t.maxLabelWidth;
  N = 0;
  let p = 60;
  Object.keys(C).forEach((s) => {
    const l = C[s].color, c = {
      cx: 20,
      cy: p,
      r: 7,
      fill: l,
      stroke: "#000",
      pos: C[s].position
    };
    R.drawCircle(e, c);
    let h = e.append("text").attr("visibility", "hidden").text(s);
    const f = h.node().getBoundingClientRect().width;
    h.remove();
    let m = [];
    if (f <= o)
      m = [s];
    else {
      const g = s.split(" ");
      let d = "";
      h = e.append("text").attr("visibility", "hidden"), g.forEach((i) => {
        const n = d ? `${d} ${i}` : i;
        if (h.text(n), h.node().getBoundingClientRect().width > o) {
          if (d && m.push(d), d = i, h.text(i), h.node().getBoundingClientRect().width > o) {
            let y = "";
            for (const u of i)
              y += u, h.text(y + "-"), h.node().getBoundingClientRect().width > o && (m.push(y.slice(0, -1) + "-"), y = u);
            d = y;
          }
        } else
          d = n;
      }), d && m.push(d), h.remove();
    }
    m.forEach((g, d) => {
      const i = {
        x: 40,
        y: p + 7 + d * 20,
        fill: "#666",
        text: g,
        textMargin: t.boxTextMargin ?? 5
      }, n = R.drawText(e, i).node().getBoundingClientRect().width;
      n > N && n > t.leftMargin - n && (N = n);
    }), p += Math.max(20, m.length * 20);
  });
}
a(ht, "drawActorLegend");
var S = B().journey, M = 0, Gt = /* @__PURE__ */ a(function(e, t, o, p) {
  const s = B(), l = s.journey.titleColor, c = s.journey.titleFontSize, h = s.journey.titleFontFamily, f = s.securityLevel;
  let m;
  f === "sandbox" && (m = X("#i" + t));
  const g = f === "sandbox" ? X(m.nodes()[0].contentDocument.body) : X("body");
  $.init();
  const d = g.select("#" + t);
  R.initGraphics(d, t);
  const i = p.db.getTasks(), n = p.db.getDiagramTitle(), y = p.db.getActors();
  for (const A in C)
    delete C[A];
  let u = 0;
  y.forEach((A) => {
    C[A] = {
      color: S.actorColours[u % S.actorColours.length],
      position: u
    }, u++;
  }), ht(d), M = S.leftMargin + N, $.insert(0, 0, M, Object.keys(C).length * 50), Xt(d, i, 0, t);
  const r = $.getBounds();
  n && d.append("text").text(n).attr("x", M).attr("font-size", c).attr("font-weight", "bold").attr("y", 25).attr("fill", l).attr("font-family", h);
  const k = r.stopy - r.starty + 2 * S.diagramMarginY, x = M + r.stopx + 2 * S.diagramMarginX;
  St(d, k, x, S.useMaxWidth), d.append("line").attr("x1", M).attr("y1", S.height * 4).attr("x2", x - M - 4).attr("y2", S.height * 4).attr("stroke-width", 4).attr("stroke", "black").attr("marker-end", "url(#" + t + "-arrowhead)");
  const E = n ? 70 : 0;
  d.attr("viewBox", `${r.startx} -25 ${x} ${k + E}`), d.attr("preserveAspectRatio", "xMinYMin meet"), d.attr("height", k + E + 25);
}, "draw"), $ = {
  data: {
    startx: void 0,
    stopx: void 0,
    starty: void 0,
    stopy: void 0
  },
  verticalPos: 0,
  sequenceItems: [],
  init: /* @__PURE__ */ a(function() {
    this.sequenceItems = [], this.data = {
      startx: void 0,
      stopx: void 0,
      starty: void 0,
      stopy: void 0
    }, this.verticalPos = 0;
  }, "init"),
  updateVal: /* @__PURE__ */ a(function(e, t, o, p) {
    e[t] === void 0 ? e[t] = o : e[t] = p(o, e[t]);
  }, "updateVal"),
  updateBounds: /* @__PURE__ */ a(function(e, t, o, p) {
    const s = B().journey, l = this;
    let c = 0;
    function h(f) {
      return /* @__PURE__ */ a(function(m) {
        c++;
        const g = l.sequenceItems.length - c + 1;
        l.updateVal(m, "starty", t - g * s.boxMargin, Math.min), l.updateVal(m, "stopy", p + g * s.boxMargin, Math.max), l.updateVal($.data, "startx", e - g * s.boxMargin, Math.min), l.updateVal($.data, "stopx", o + g * s.boxMargin, Math.max), f !== "activation" && (l.updateVal(m, "startx", e - g * s.boxMargin, Math.min), l.updateVal(m, "stopx", o + g * s.boxMargin, Math.max), l.updateVal($.data, "starty", t - g * s.boxMargin, Math.min), l.updateVal($.data, "stopy", p + g * s.boxMargin, Math.max));
      }, "updateItemBounds");
    }
    a(h, "updateFn"), this.sequenceItems.forEach(h());
  }, "updateBounds"),
  insert: /* @__PURE__ */ a(function(e, t, o, p) {
    const s = Math.min(e, o), l = Math.max(e, o), c = Math.min(t, p), h = Math.max(t, p);
    this.updateVal($.data, "startx", s, Math.min), this.updateVal($.data, "starty", c, Math.min), this.updateVal($.data, "stopx", l, Math.max), this.updateVal($.data, "stopy", h, Math.max), this.updateBounds(s, c, l, h);
  }, "insert"),
  bumpVerticalPos: /* @__PURE__ */ a(function(e) {
    this.verticalPos = this.verticalPos + e, this.data.stopy = this.verticalPos;
  }, "bumpVerticalPos"),
  getVerticalPos: /* @__PURE__ */ a(function() {
    return this.verticalPos;
  }, "getVerticalPos"),
  getBounds: /* @__PURE__ */ a(function() {
    return this.data;
  }, "getBounds")
}, q = S.sectionFills, st = S.sectionColours, Xt = /* @__PURE__ */ a(function(e, t, o, p) {
  const s = B().journey;
  let l = "";
  const c = s.height * 2 + s.diagramMarginY, h = o + c;
  let f = 0, m = "#CCC", g = "black", d = 0;
  for (const [i, n] of t.entries()) {
    if (l !== n.section) {
      m = q[f % q.length], d = f % q.length, g = st[f % st.length];
      let u = 0;
      const r = n.section;
      for (let x = i; x < t.length && t[x].section == r; x++)
        u = u + 1;
      const k = {
        x: i * s.taskMargin + i * s.width + M,
        y: 50,
        text: n.section,
        fill: m,
        num: d,
        colour: g,
        taskCount: u
      };
      R.drawSection(e, k, s), l = n.section, f++;
    }
    const y = n.people.reduce((u, r) => (C[r] && (u[r] = C[r]), u), {});
    n.x = i * s.taskMargin + i * s.width + M, n.y = h, n.width = s.diagramMarginX, n.height = s.diagramMarginY, n.colour = g, n.fill = m, n.num = d, n.actors = y, R.drawTask(e, n, s, p), $.insert(n.x, n.y, n.x + n.width + s.taskMargin, 450);
  }
}, "drawTasks"), at = {
  setConf: Wt,
  draw: Gt
}, Jt = {
  parser: Ct,
  db: nt,
  renderer: at,
  styles: Lt,
  init: /* @__PURE__ */ a((e) => {
    at.setConf(e.journey), nt.clear();
  }, "init")
};
export {
  Jt as diagram
};
