import { d as ft, y as rt, g as gt, x as mt } from "./chunk-OMD6QJNC-_VI6zVGr-Bb4P7zNG.js";
import { l as xt } from "./chunk-GLLZNHP4-DgwBbAOT-BUrsAxH8.js";
import { _ as s, a6 as kt, a5 as _t, a7 as bt, a8 as wt, ao as $t, an as vt, g as B, a9 as X, aa as St, at as Tt } from "./index-BDD0CD9m.js";
import { h as tt } from "./arc-DYb5Ak6k-js8YHzj6.js";
var U = function() {
  var t = /* @__PURE__ */ s(function(y, i, a, u) {
    for (a = a || {}, u = y.length; u--; a[y[u]] = i) ;
    return a;
  }, "o"), e = [6, 8, 10, 11, 12, 14, 16, 17, 18], r = [1, 9], l = [1, 10], n = [1, 11], c = [1, 12], d = [1, 13], h = [1, 14], f = {
    trace: /* @__PURE__ */ s(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__ */ s(function(y, i, a, u, p, o, x) {
      var k = o.length - 1;
      switch (p) {
        case 1:
          return o[k - 1];
        case 2:
          this.$ = [];
          break;
        case 3:
          o[k - 1].push(o[k]), this.$ = o[k - 1];
          break;
        case 4:
        case 5:
          this.$ = o[k];
          break;
        case 6:
        case 7:
          this.$ = [];
          break;
        case 8:
          u.setDiagramTitle(o[k].substr(6)), this.$ = o[k].substr(6);
          break;
        case 9:
          this.$ = o[k].trim(), u.setAccTitle(this.$);
          break;
        case 10:
        case 11:
          this.$ = o[k].trim(), u.setAccDescription(this.$);
          break;
        case 12:
          u.addSection(o[k].substr(8)), this.$ = o[k].substr(8);
          break;
        case 13:
          u.addTask(o[k - 1], o[k]), this.$ = "task";
          break;
      }
    }, "anonymous"),
    table: [{ 3: 1, 4: [1, 2] }, { 1: [3] }, t(e, [2, 2], { 5: 3 }), { 6: [1, 4], 7: 5, 8: [1, 6], 9: 7, 10: [1, 8], 11: r, 12: l, 14: n, 16: c, 17: d, 18: h }, t(e, [2, 7], { 1: [2, 1] }), t(e, [2, 3]), { 9: 15, 11: r, 12: l, 14: n, 16: c, 17: d, 18: h }, t(e, [2, 5]), t(e, [2, 6]), t(e, [2, 8]), { 13: [1, 16] }, { 15: [1, 17] }, t(e, [2, 11]), t(e, [2, 12]), { 19: [1, 18] }, t(e, [2, 4]), t(e, [2, 9]), t(e, [2, 10]), t(e, [2, 13])],
    defaultActions: {},
    parseError: /* @__PURE__ */ s(function(y, i) {
      if (i.recoverable)
        this.trace(y);
      else {
        var a = new Error(y);
        throw a.hash = i, a;
      }
    }, "parseError"),
    parse: /* @__PURE__ */ s(function(y) {
      var i = this, a = [0], u = [], p = [null], o = [], x = this.table, k = "", E = 0, A = 0, ut = 2, J = 1, pt = o.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(y, I.yy), I.yy.lexer = _, I.yy.parser = this, typeof _.yylloc > "u" && (_.yylloc = {});
      var Y = _.yylloc;
      o.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(w) {
        a.length = a.length - 2 * w, p.length = p.length - w, o.length = o.length - w;
      }
      s(dt, "popStack");
      function K() {
        var w;
        return w = u.pop() || _.lex() || J, typeof w != "number" && (w instanceof Array && (u = w, w = u.pop()), w = i.symbols_[w] || w), w;
      }
      s(K, "lex");
      for (var b, P, $, W, j = {}, F, T, H, O; ; ) {
        if (P = a[a.length - 1], this.defaultActions[P] ? $ = this.defaultActions[P] : ((b === null || typeof b > "u") && (b = K()), $ = x[P] && x[P][b]), typeof $ > "u" || !$.length || !$[0]) {
          var G = "";
          O = [];
          for (F in x[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 == J ? "end of input" : "'" + (this.terminals_[b] || b) + "'"), this.parseError(G, {
            text: _.match,
            token: this.terminals_[b] || b,
            line: _.yylineno,
            loc: Y,
            expected: O
          });
        }
        if ($[0] instanceof Array && $.length > 1)
          throw new Error("Parse Error: multiple actions possible at state: " + P + ", token: " + b);
        switch ($[0]) {
          case 1:
            a.push(b), p.push(_.yytext), o.push(_.yylloc), a.push($[1]), b = null, A = _.yyleng, k = _.yytext, E = _.yylineno, Y = _.yylloc;
            break;
          case 2:
            if (T = this.productions_[$[1]][1], j.$ = p[p.length - T], j._$ = {
              first_line: o[o.length - (T || 1)].first_line,
              last_line: o[o.length - 1].last_line,
              first_column: o[o.length - (T || 1)].first_column,
              last_column: o[o.length - 1].last_column
            }, yt && (j._$.range = [
              o[o.length - (T || 1)].range[0],
              o[o.length - 1].range[1]
            ]), W = this.performAction.apply(j, [
              k,
              A,
              E,
              I.yy,
              $[1],
              p,
              o
            ].concat(pt)), typeof W < "u")
              return W;
            T && (a = a.slice(0, -1 * T * 2), p = p.slice(0, -1 * T), o = o.slice(0, -1 * T)), a.push(this.productions_[$[1]][0]), p.push(j.$), o.push(j._$), H = x[a[a.length - 2]][a[a.length - 1]], a.push(H);
            break;
          case 3:
            return !0;
        }
      }
      return !0;
    }, "parse")
  }, m = /* @__PURE__ */ function() {
    var y = {
      EOF: 1,
      parseError: /* @__PURE__ */ s(function(i, a) {
        if (this.yy.parser)
          this.yy.parser.parseError(i, a);
        else
          throw new Error(i);
      }, "parseError"),
      // resets the lexer, sets new input
      setInput: /* @__PURE__ */ s(function(i, a) {
        return this.yy = a || 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__ */ s(function() {
        var i = this._input[0];
        this.yytext += i, this.yyleng++, this.offset++, this.match += i, this.matched += i;
        var a = i.match(/(?:\r\n?|\n).*/g);
        return a ? (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__ */ s(function(i) {
        var a = i.length, u = i.split(/(?:\r\n?|\n)/g);
        this._input = i + this._input, this.yytext = this.yytext.substr(0, this.yytext.length - a), this.offset -= a;
        var p = 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), u.length - 1 && (this.yylineno -= u.length - 1);
        var o = 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: u ? (u.length === p.length ? this.yylloc.first_column : 0) + p[p.length - u.length].length - u[0].length : this.yylloc.first_column - a
        }, this.options.ranges && (this.yylloc.range = [o[0], o[0] + this.yyleng - a]), this.yyleng = this.yytext.length, this;
      }, "unput"),
      // When called from action, caches matched text and appends it on next action
      more: /* @__PURE__ */ s(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__ */ s(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__ */ s(function(i) {
        this.unput(this.match.slice(i));
      }, "less"),
      // displays already matched input, i.e. for error messages
      pastInput: /* @__PURE__ */ s(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__ */ s(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__ */ s(function() {
        var i = this.pastInput(), a = new Array(i.length + 1).join("-");
        return i + this.upcomingInput() + `
` + a + "^";
      }, "showPosition"),
      // test the lexed token: return FALSE when not a match, otherwise return token
      test_match: /* @__PURE__ */ s(function(i, a) {
        var u, p, o;
        if (this.options.backtrack_lexer && (o = {
          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 && (o.yylloc.range = this.yylloc.range.slice(0))), p = i[0].match(/(?:\r\n?|\n).*/g), p && (this.yylineno += p.length), this.yylloc = {
          first_line: this.yylloc.last_line,
          last_line: this.yylineno + 1,
          first_column: this.yylloc.last_column,
          last_column: p ? p[p.length - 1].length - p[p.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], u = this.performAction.call(this, this.yy, this, a, this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1), u)
          return u;
        if (this._backtrack) {
          for (var x in o)
            this[x] = o[x];
          return !1;
        }
        return !1;
      }, "test_match"),
      // return next match in input
      next: /* @__PURE__ */ s(function() {
        if (this.done)
          return this.EOF;
        this._input || (this.done = !0);
        var i, a, u, p;
        this._more || (this.yytext = "", this.match = "");
        for (var o = this._currentRules(), x = 0; x < o.length; x++)
          if (u = this._input.match(this.rules[o[x]]), u && (!a || u[0].length > a[0].length)) {
            if (a = u, p = x, this.options.backtrack_lexer) {
              if (i = this.test_match(u, o[x]), i !== !1)
                return i;
              if (this._backtrack) {
                a = !1;
                continue;
              } else
                return !1;
            } else if (!this.options.flex)
              break;
          }
        return a ? (i = this.test_match(a, o[p]), 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__ */ s(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__ */ s(function(i) {
        this.conditionStack.push(i);
      }, "begin"),
      // pop the previously active lexer condition state off the condition stack
      popState: /* @__PURE__ */ s(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__ */ s(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__ */ s(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__ */ s(function(i) {
        this.begin(i);
      }, "pushState"),
      // return the number of states currently on the stack
      stateStackSize: /* @__PURE__ */ s(function() {
        return this.conditionStack.length;
      }, "stateStackSize"),
      options: { "case-insensitive": !0 },
      performAction: /* @__PURE__ */ s(function(i, a, u, p) {
        switch (u) {
          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 y;
  }();
  f.lexer = m;
  function g() {
    this.yy = {};
  }
  return s(g, "Parser"), g.prototype = f, f.Parser = g, new g();
}();
U.parser = U;
var Ct = U, V = "", Q = [], D = [], L = [], Mt = /* @__PURE__ */ s(function() {
  Q.length = 0, D.length = 0, V = "", L.length = 0, Tt();
}, "clear"), Et = /* @__PURE__ */ s(function(t) {
  V = t, Q.push(t);
}, "addSection"), It = /* @__PURE__ */ s(function() {
  return Q;
}, "getSections"), Pt = /* @__PURE__ */ s(function() {
  let t = et();
  const e = 100;
  let r = 0;
  for (; !t && r < e; )
    t = et(), r++;
  return D.push(...L), D;
}, "getTasks"), At = /* @__PURE__ */ s(function() {
  const t = [];
  return D.forEach((e) => {
    e.people && t.push(...e.people);
  }), [...new Set(t)].sort();
}, "updateActors"), jt = /* @__PURE__ */ s(function(t, e) {
  const r = e.substr(1).split(":");
  let l = 0, n = [];
  r.length === 1 ? (l = Number(r[0]), n = []) : (l = Number(r[0]), n = r[1].split(","));
  const c = n.map((h) => h.trim()), d = {
    section: V,
    type: V,
    people: c,
    task: t,
    score: l
  };
  L.push(d);
}, "addTask"), Vt = /* @__PURE__ */ s(function(t) {
  const e = {
    section: V,
    type: V,
    description: t,
    task: t,
    classes: []
  };
  D.push(e);
}, "addTaskOrg"), et = /* @__PURE__ */ s(function() {
  const t = /* @__PURE__ */ s(function(r) {
    return L[r].processed;
  }, "compileTask");
  let e = !0;
  for (const [r, l] of L.entries())
    t(r), e = e && l.processed;
  return e;
}, "compileTasks"), Bt = /* @__PURE__ */ s(function() {
  return At();
}, "getActors"), it = {
  getConfig: /* @__PURE__ */ s(() => B().journey, "getConfig"),
  clear: Mt,
  setDiagramTitle: vt,
  getDiagramTitle: $t,
  setAccTitle: wt,
  getAccTitle: bt,
  setAccDescription: _t,
  getAccDescription: kt,
  addSection: Et,
  getSections: It,
  getTasks: Pt,
  addTask: jt,
  addTaskOrg: Vt,
  getActors: Bt
}, Dt = /* @__PURE__ */ s((t) => `.label {
    font-family: ${t.fontFamily};
    color: ${t.textColor};
  }
  .mouth {
    stroke: #666;
  }

  line {
    stroke: ${t.textColor}
  }

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

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

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

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

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

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

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

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

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

  .cluster rect {
  }

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

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

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

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