import"./index.es.min.CZjstcJ6.js";import{g as gt,s as mt,a as xt,b as kt,v as _t,t as bt,_ as r,c as F,d as tt,e as wt,A as vt}from"./katex-D8o5-F7C.d_mIDReB.js";import{a as et}from"./arc-BqlAOiZb.BxhGD7fv.js";import{g as $t}from"./chunk-FMBD7UC4-PFlLPz_s.BYbQdEYw.js";import{a as Tt,g as ot,f as Mt,d as At}from"./chunk-TZMSLE5B-C5ccYWGN.BkNnokGr.js";import"./framework.Cre9sSJa.js";import"./index.BYYR_MCp.js";import"./index.Dyt75KH8.js";var Z=function(){var t=r(function(i,a,l,u){for(l||(l={}),u=i.length;u--;l[i[u]]=a);return l},"o"),e=[6,8,10,11,12,14,16,17,18],s=[1,9],o=[1,10],n=[1,11],h=[1,12],d=[1,13],p=[1,14],f={trace:r(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:r(function(i,a,l,u,y,c,x){var m=c.length-1;switch(y){case 1:return c[m-1];case 2:this.$=[];break;case 3:c[m-1].push(c[m]),this.$=c[m-1];break;case 4:case 5:this.$=c[m];break;case 6:case 7:this.$=[];break;case 8:u.setDiagramTitle(c[m].substr(6)),this.$=c[m].substr(6);break;case 9:this.$=c[m].trim(),u.setAccTitle(this.$);break;case 10:case 11:this.$=c[m].trim(),u.setAccDescription(this.$);break;case 12:u.addSection(c[m].substr(8)),this.$=c[m].substr(8);break;case 13:u.addTask(c[m-1],c[m]),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:s,12:o,14:n,16:h,17:d,18:p},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:s,12:o,14:n,16:h,17:d,18:p},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:r(function(i,a){if(a.recoverable)this.trace(i);else{var l=Error(i);throw l.hash=a,l}},"parseError"),parse:r(function(i){var a=this,l=[0],u=[],y=[null],c=[],x=this.table,m="",b=0,B=0,O=0,pt=2,X=1,dt=c.slice.call(arguments,1),k=Object.create(this.lexer),P={yy:{}};for(var z in this.yy)Object.prototype.hasOwnProperty.call(this.yy,z)&&(P.yy[z]=this.yy[z]);k.setInput(i,P.yy),P.yy.lexer=k,P.yy.parser=this,k.yylloc===void 0&&(k.yylloc={});var W=k.yylloc;c.push(W);var yt=k.options&&k.options.ranges;typeof P.yy.parseError=="function"?this.parseError=P.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ft(v){l.length-=2*v,y.length-=v,c.length-=v}r(ft,"popStack");function J(){var v=u.pop()||k.lex()||X;return typeof v!="number"&&(v instanceof Array&&(u=v,v=u.pop()),v=a.symbols_[v]||v),v}r(J,"lex");for(var _,H,j,w,Y,E={},N,M,U,C;;){if(j=l[l.length-1],this.defaultActions[j]?w=this.defaultActions[j]:(_??(_=J()),w=x[j]&&x[j][_]),w===void 0||!w.length||!w[0]){var K="";for(N in C=[],x[j])this.terminals_[N]&&N>pt&&C.push("'"+this.terminals_[N]+"'");K=k.showPosition?"Parse error on line "+(b+1)+`:
`+k.showPosition()+`
Expecting `+C.join(", ")+", got '"+(this.terminals_[_]||_)+"'":"Parse error on line "+(b+1)+": Unexpected "+(_==X?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(K,{text:k.match,token:this.terminals_[_]||_,line:k.yylineno,loc:W,expected:C})}if(w[0]instanceof Array&&w.length>1)throw Error("Parse Error: multiple actions possible at state: "+j+", token: "+_);switch(w[0]){case 1:l.push(_),y.push(k.yytext),c.push(k.yylloc),l.push(w[1]),_=null,H?(_=H,H=null):(B=k.yyleng,m=k.yytext,b=k.yylineno,W=k.yylloc,O>0);break;case 2:if(M=this.productions_[w[1]][1],E.$=y[y.length-M],E._$={first_line:c[c.length-(M||1)].first_line,last_line:c[c.length-1].last_line,first_column:c[c.length-(M||1)].first_column,last_column:c[c.length-1].last_column},yt&&(E._$.range=[c[c.length-(M||1)].range[0],c[c.length-1].range[1]]),Y=this.performAction.apply(E,[m,B,b,P.yy,w[1],y,c].concat(dt)),Y!==void 0)return Y;M&&(l=l.slice(0,-1*M*2),y=y.slice(0,-1*M),c=c.slice(0,-1*M)),l.push(this.productions_[w[1]][0]),y.push(E.$),c.push(E._$),U=x[l[l.length-2]][l[l.length-1]],l.push(U);break;case 3:return!0}}return!0},"parse")};f.lexer=function(){return{EOF:1,parseError:r(function(i,a){if(this.yy.parser)this.yy.parser.parseError(i,a);else throw Error(i)},"parseError"),setInput:r(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"),input:r(function(){var i=this._input[0];return this.yytext+=i,this.yyleng++,this.offset++,this.match+=i,this.matched+=i,i.match(/(?:\r\n?|\n).*/g)?(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"),unput:r(function(i){var a=i.length,l=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 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),l.length-1&&(this.yylineno-=l.length-1);var y=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:l?(l.length===u.length?this.yylloc.first_column:0)+u[u.length-l.length].length-l[0].length:this.yylloc.first_column-a},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-a]),this.yyleng=this.yytext.length,this},"unput"),more:r(function(){return this._more=!0,this},"more"),reject:r(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"),less:r(function(i){this.unput(this.match.slice(i))},"less"),pastInput:r(function(){var i=this.matched.substr(0,this.matched.length-this.match.length);return(i.length>20?"...":"")+i.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:r(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"),showPosition:r(function(){var i=this.pastInput(),a=Array(i.length+1).join("-");return i+this.upcomingInput()+`
`+a+"^"},"showPosition"),test_match:r(function(i,a){var l,u,y;if(this.options.backtrack_lexer&&(y={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&&(y.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],l=this.performAction.call(this,this.yy,this,a,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),l)return l;if(this._backtrack){for(var c in y)this[c]=y[c];return!1}return!1},"test_match"),next:r(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var i,a,l,u;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),c=0;c<y.length;c++)if(l=this._input.match(this.rules[y[c]]),l&&(!a||l[0].length>a[0].length)){if(a=l,u=c,this.options.backtrack_lexer){if(i=this.test_match(l,y[c]),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,y[u]),i===!1?!1:i):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:r(function(){return this.next()||this.lex()},"lex"),begin:r(function(i){this.conditionStack.push(i)},"begin"),popState:r(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:r(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"),topState:r(function(i){return i=this.conditionStack.length-1-Math.abs(i||0),i>=0?this.conditionStack[i]:"INITIAL"},"topState"),pushState:r(function(i){this.begin(i)},"pushState"),stateStackSize:r(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:r(function(i,a,l,u){switch(l){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}}}}();function g(){this.yy={}}return r(g,"Parser"),g.prototype=f,f.Parser=g,new g}();Z.parser=Z;var It=Z,D="",G=[],R=[],V=[],Pt=r(function(){G.length=0,R.length=0,D="",V.length=0,vt()},"clear"),jt=r(function(t){D=t,G.push(t)},"addSection"),Et=r(function(){return G},"getSections"),Dt=r(function(){let t=it(),e=0;for(;!t&&e<100;)t=it(),e++;return R.push(...V),R},"getTasks"),Ft=r(function(){let t=[];return R.forEach(e=>{e.people&&t.push(...e.people)}),[...new Set(t)].sort()},"updateActors"),Bt=r(function(t,e){let s=e.substr(1).split(":"),o=0,n=[];s.length===1?(o=Number(s[0]),n=[]):(o=Number(s[0]),n=s[1].split(","));let h=n.map(p=>p.trim()),d={section:D,type:D,people:h,task:t,score:o};V.push(d)},"addTask"),Ot=r(function(t){let e={section:D,type:D,description:t,task:t,classes:[]};R.push(e)},"addTaskOrg"),it=r(function(){let t=r(function(s){return V[s].processed},"compileTask"),e=!0;for(let[s,o]of V.entries())t(s),e&&(e=o.processed);return e},"compileTasks"),at={getConfig:r(()=>F().journey,"getConfig"),clear:Pt,setDiagramTitle:bt,getDiagramTitle:_t,setAccTitle:kt,getAccTitle:xt,setAccDescription:mt,getAccDescription:gt,addSection:jt,getSections:Et,getTasks:Dt,addTask:Bt,addTaskOrg:Ot,getActors:r(function(){return Ft()},"getActors")},Rt=r(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}`:""};
  }
  ${$t()}
`,"getStyles"),Q=r(function(t,e){return At(t,e)},"drawRect"),Vt=r(function(t,e){let s=t.append("circle").attr("cx",e.cx).attr("cy",e.cy).attr("class","face").attr("r",15).attr("stroke-width",2).attr("overflow","visible"),o=t.append("g");o.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"),o.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(p){let f=et().startAngle(Math.PI/2).endAngle(3*(Math.PI/2)).innerRadius(7.5).outerRadius(6.8181818181818175);p.append("path").attr("class","mouth").attr("d",f).attr("transform","translate("+e.cx+","+(e.cy+2)+")")}r(n,"smile");function h(p){let f=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",f).attr("transform","translate("+e.cx+","+(e.cy+7)+")")}r(h,"sad");function d(p){p.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 r(d,"ambivalent"),e.score>3?n(o):e.score<3?h(o):d(o),s},"drawFace"),lt=r(function(t,e){let s=t.append("circle");return s.attr("cx",e.cx),s.attr("cy",e.cy),s.attr("class","actor-"+e.pos),s.attr("fill",e.fill),s.attr("stroke",e.stroke),s.attr("r",e.r),s.class!==void 0&&s.attr("class",s.class),e.title!==void 0&&s.append("title").text(e.title),s},"drawCircle"),ct=r(function(t,e){return Mt(t,e)},"drawText"),Lt=r(function(t,e){function s(n,h,d,p,f){return n+","+h+" "+(n+d)+","+h+" "+(n+d)+","+(h+p-f)+" "+(n+d-f*1.2)+","+(h+p)+" "+n+","+(h+p)}r(s,"genPoints");let o=t.append("polygon");o.attr("points",s(e.x,e.y,50,20,7)),o.attr("class","labelBox"),e.y+=e.labelMargin,e.x+=.5*e.labelMargin,ct(t,e)},"drawLabel"),Nt=r(function(t,e,s){let o=t.append("g"),n=ot();n.x=e.x,n.y=e.y,n.fill=e.fill,n.width=s.width*e.taskCount+s.diagramMarginX*(e.taskCount-1),n.height=s.height,n.class="journey-section section-type-"+e.num,n.rx=3,n.ry=3,Q(o,n),ht(s)(e.text,o,n.x,n.y,n.width,n.height,{class:"journey-section section-type-"+e.num},s,e.colour)},"drawSection"),nt=-1,Ct=r(function(t,e,s){let o=e.x+s.width/2,n=t.append("g");nt++,n.append("line").attr("id","task"+nt).attr("x1",o).attr("y1",e.y).attr("x2",o).attr("y2",450).attr("class","task-line").attr("stroke-width","1px").attr("stroke-dasharray","4 2").attr("stroke","#666"),Vt(n,{cx:o,cy:300+(5-e.score)*30,score:e.score});let h=ot();h.x=e.x,h.y=e.y,h.fill=e.fill,h.width=s.width,h.height=s.height,h.class="task task-type-"+e.num,h.rx=3,h.ry=3,Q(n,h);let d=e.x+14;e.people.forEach(p=>{let f=e.actors[p].color;lt(n,{cx:d,cy:e.y,r:7,fill:f,stroke:"#000",title:p,pos:e.actors[p].position}),d+=10}),ht(s)(e.task,n,h.x,h.y,h.width,h.height,{class:"task"},s,e.colour)},"drawTask"),St=r(function(t,e){Tt(t,e)},"drawBackgroundRect"),ht=function(){function t(n,h,d,p,f,g,i,a){o(h.append("text").attr("x",d+f/2).attr("y",p+g/2+5).style("font-color",a).style("text-anchor","middle").text(n),i)}r(t,"byText");function e(n,h,d,p,f,g,i,a,l){let{taskFontSize:u,taskFontFamily:y}=a,c=n.split(/<br\s*\/?>/gi);for(let x=0;x<c.length;x++){let m=x*u-u*(c.length-1)/2,b=h.append("text").attr("x",d+f/2).attr("y",p).attr("fill",l).style("text-anchor","middle").style("font-size",u).style("font-family",y);b.append("tspan").attr("x",d+f/2).attr("dy",m).text(c[x]),b.attr("y",p+g/2).attr("dominant-baseline","central").attr("alignment-baseline","central"),o(b,i)}}r(e,"byTspan");function s(n,h,d,p,f,g,i,a){let l=h.append("switch"),u=l.append("foreignObject").attr("x",d).attr("y",p).attr("width",f).attr("height",g).attr("position","fixed").append("xhtml:div").style("display","table").style("height","100%").style("width","100%");u.append("div").attr("class","label").style("display","table-cell").style("text-align","center").style("vertical-align","middle").text(n),e(n,l,d,p,f,g,i,a),o(u,i)}r(s,"byFo");function o(n,h){for(let d in h)d in h&&n.attr(d,h[d])}return r(o,"_setTextAttrs"),function(n){return n.textPlacement==="fo"?s:n.textPlacement==="old"?t:e}}(),L={drawRect:Q,drawCircle:lt,drawSection:Nt,drawText:ct,drawLabel:Lt,drawTask:Ct,drawBackgroundRect:St,initGraphics:r(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")},zt=r(function(t){Object.keys(t).forEach(function(e){T[e]=t[e]})},"setConf"),A={},S=0;function ut(t){let e=F().journey,s=e.maxLabelWidth;S=0;let o=60;Object.keys(A).forEach(n=>{let h=A[n].color,d={cx:20,cy:o,r:7,fill:h,stroke:"#000",pos:A[n].position};L.drawCircle(t,d);let p=t.append("text").attr("visibility","hidden").text(n),f=p.node().getBoundingClientRect().width;p.remove();let g=[];if(f<=s)g=[n];else{let i=n.split(" "),a="";p=t.append("text").attr("visibility","hidden"),i.forEach(l=>{let u=a?`${a} ${l}`:l;if(p.text(u),p.node().getBoundingClientRect().width>s){if(a&&g.push(a),a=l,p.text(l),p.node().getBoundingClientRect().width>s){let y="";for(let c of l)y+=c,p.text(y+"-"),p.node().getBoundingClientRect().width>s&&(g.push(y.slice(0,-1)+"-"),y=c);a=y}}else a=u}),a&&g.push(a),p.remove()}g.forEach((i,a)=>{let l={x:40,y:o+7+a*20,fill:"#666",text:i,textMargin:e.boxTextMargin??5},u=L.drawText(t,l).node().getBoundingClientRect().width;u>S&&u>e.leftMargin-u&&(S=u)}),o+=Math.max(20,g.length*20)})}r(ut,"drawActorLegend");var T=F().journey,I=0,Wt=r(function(t,e,s,o){let n=F(),h=n.journey.titleColor,d=n.journey.titleFontSize,p=n.journey.titleFontFamily,f=n.securityLevel,g;f==="sandbox"&&(g=tt("#i"+e));let i=tt(f==="sandbox"?g.nodes()[0].contentDocument.body:"body");$.init();let a=i.select("#"+e);L.initGraphics(a);let l=o.db.getTasks(),u=o.db.getDiagramTitle(),y=o.db.getActors();for(let O in A)delete A[O];let c=0;y.forEach(O=>{A[O]={color:T.actorColours[c%T.actorColours.length],position:c},c++}),ut(a),I=T.leftMargin+S,$.insert(0,0,I,Object.keys(A).length*50),Ht(a,l,0);let x=$.getBounds();u&&a.append("text").text(u).attr("x",I).attr("font-size",d).attr("font-weight","bold").attr("y",25).attr("fill",h).attr("font-family",p);let m=x.stopy-x.starty+2*T.diagramMarginY,b=I+x.stopx+2*T.diagramMarginX;wt(a,m,b,T.useMaxWidth),a.append("line").attr("x1",I).attr("y1",T.height*4).attr("x2",b-I-4).attr("y2",T.height*4).attr("stroke-width",4).attr("stroke","black").attr("marker-end","url(#arrowhead)");let B=u?70:0;a.attr("viewBox",`${x.startx} -25 ${b} ${m+B}`),a.attr("preserveAspectRatio","xMinYMin meet"),a.attr("height",m+B+25)},"draw"),$={data:{startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},verticalPos:0,sequenceItems:[],init:r(function(){this.sequenceItems=[],this.data={startx:void 0,stopx:void 0,starty:void 0,stopy:void 0},this.verticalPos=0},"init"),updateVal:r(function(t,e,s,o){t[e]===void 0?t[e]=s:t[e]=o(s,t[e])},"updateVal"),updateBounds:r(function(t,e,s,o){let n=F().journey,h=this,d=0;function p(f){return r(function(g){d++;let i=h.sequenceItems.length-d+1;h.updateVal(g,"starty",e-i*n.boxMargin,Math.min),h.updateVal(g,"stopy",o+i*n.boxMargin,Math.max),h.updateVal($.data,"startx",t-i*n.boxMargin,Math.min),h.updateVal($.data,"stopx",s+i*n.boxMargin,Math.max),f!=="activation"&&(h.updateVal(g,"startx",t-i*n.boxMargin,Math.min),h.updateVal(g,"stopx",s+i*n.boxMargin,Math.max),h.updateVal($.data,"starty",e-i*n.boxMargin,Math.min),h.updateVal($.data,"stopy",o+i*n.boxMargin,Math.max))},"updateItemBounds")}r(p,"updateFn"),this.sequenceItems.forEach(p())},"updateBounds"),insert:r(function(t,e,s,o){let n=Math.min(t,s),h=Math.max(t,s),d=Math.min(e,o),p=Math.max(e,o);this.updateVal($.data,"startx",n,Math.min),this.updateVal($.data,"starty",d,Math.min),this.updateVal($.data,"stopx",h,Math.max),this.updateVal($.data,"stopy",p,Math.max),this.updateBounds(n,d,h,p)},"insert"),bumpVerticalPos:r(function(t){this.verticalPos+=t,this.data.stopy=this.verticalPos},"bumpVerticalPos"),getVerticalPos:r(function(){return this.verticalPos},"getVerticalPos"),getBounds:r(function(){return this.data},"getBounds")},q=T.sectionFills,rt=T.sectionColours,Ht=r(function(t,e,s){let o=F().journey,n="",h=s+(o.height*2+o.diagramMarginY),d=0,p="#CCC",f="black",g=0;for(let[i,a]of e.entries()){if(n!==a.section){p=q[d%q.length],g=d%q.length,f=rt[d%rt.length];let u=0,y=a.section;for(let x=i;x<e.length&&e[x].section==y;x++)u+=1;let c={x:i*o.taskMargin+i*o.width+I,y:50,text:a.section,fill:p,num:g,colour:f,taskCount:u};L.drawSection(t,c,o),n=a.section,d++}let l=a.people.reduce((u,y)=>(A[y]&&(u[y]=A[y]),u),{});a.x=i*o.taskMargin+i*o.width+I,a.y=h,a.width=o.diagramMarginX,a.height=o.diagramMarginY,a.colour=f,a.fill=p,a.num=g,a.actors=l,L.drawTask(t,a,o),$.insert(a.x,a.y,a.x+a.width+o.taskMargin,450)}},"drawTasks"),st={setConf:zt,draw:Wt},Kt={parser:It,db:at,renderer:st,styles:Rt,init:r(t=>{st.setConf(t.journey),at.clear()},"init")};export{Kt as diagram};
