UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

8 lines (7 loc) • 43.7 kB
import{a as Kt}from"./chunk-SQW7XO2P.mjs";import{d as qt}from"./chunk-VZ26ENTH.mjs";import"./chunk-BZANPUPN.mjs";import{p as Rt}from"./chunk-YF46JFGZ.mjs";import"./chunk-ZZ52EIBP.mjs";import{B as Wt,P as Ft,T as Nt,U as jt,V as Gt,W as Ht,X as $t,Y as Ut,Z as Tt,h as zt,j as Ot,u as ct}from"./chunk-VSAMGZVZ.mjs";import{H as kt,b as ht,n as wt,o as St}from"./chunk-L2B47AAZ.mjs";import{a as s}from"./chunk-QVIEFLGF.mjs";var _t=(function(){var i=s(function(Y,l,c,p){for(c=c||{},p=Y.length;p--;c[Y[p]]=l);return c},"o"),t=[1,10,12,14,16,18,19,21,23],e=[2,6],a=[1,3],n=[1,5],r=[1,6],h=[1,7],f=[1,5,10,12,14,16,18,19,21,23,36,37,38],m=[1,25],u=[1,26],A=[1,28],S=[1,29],_=[1,30],V=[1,31],z=[1,32],E=[1,33],O=[1,34],W=[1,35],F=[1,36],y=[1,37],L=[1,43],g=[1,42],j=[1,47],B=[1,50],D=[1,10,12,14,16,18,19,21,23,36,37,38],G=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38],P=[1,10,12,14,16,18,19,21,23,24,26,28,29,36,37,38,42,43,44,45,46,47,48,49,50,51],K=[1,65],k=[26,28],C={trace:s(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,dataPoints:25,SQUARE_BRACES_END:26,dataPoint:27,COMMA:28,NUMBER_WITH_DECIMAL:29,STR:30,xAxisData:31,bandData:32,ARROW_DELIMITER:33,commaSeparatedTexts:34,yAxisData:35,NEWLINE:36,SEMI:37,EOF:38,alphaNum:39,MD_STR:40,alphaNumToken:41,AMP:42,NUM:43,ALPHA:44,PLUS:45,EQUALS:46,MULT:47,DOT:48,BRKT:49,MINUS:50,UNDERSCORE:51,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",28:"COMMA",29:"NUMBER_WITH_DECIMAL",30:"STR",33:"ARROW_DELIMITER",36:"NEWLINE",37:"SEMI",38:"EOF",40:"MD_STR",42:"AMP",43:"NUM",44:"ALPHA",45:"PLUS",46:"EQUALS",47:"MULT",48:"DOT",49:"BRKT",50:"MINUS",51:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[27,2],[27,1],[13,1],[13,2],[13,1],[31,1],[31,3],[32,3],[34,3],[34,1],[15,1],[15,2],[15,1],[35,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[39,1],[39,2],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1],[41,1]],performAction:s(function(l,c,p,x,T,o,$){var d=o.length-1;switch(T){case 5:x.setOrientation(o[d]);break;case 9:x.setDiagramTitle(o[d].text.trim());break;case 12:x.setLineData({text:"",type:"text"},o[d]);break;case 13:x.setLineData(o[d-1],o[d]);break;case 14:x.setBarData({text:"",type:"text"},o[d]);break;case 15:x.setBarData(o[d-1],o[d]);break;case 16:this.$=o[d].trim(),x.setAccTitle(this.$);break;case 17:case 18:this.$=o[d].trim(),x.setAccDescription(this.$);break;case 19:this.$=o[d-1];break;case 20:case 30:this.$=[o[d-2],...o[d]];break;case 21:case 31:this.$=[o[d]];break;case 22:this.$={value:Number(o[d-1]),label:o[d]};break;case 23:this.$={value:Number(o[d]),label:""};break;case 24:x.setXAxisTitle(o[d]);break;case 25:x.setXAxisTitle(o[d-1]);break;case 26:x.setXAxisTitle({type:"text",text:""});break;case 27:x.setXAxisBand(o[d]);break;case 28:x.setXAxisRangeData(Number(o[d-2]),Number(o[d]));break;case 29:this.$=o[d-1];break;case 32:x.setYAxisTitle(o[d]);break;case 33:x.setYAxisTitle(o[d-1]);break;case 34:x.setYAxisTitle({type:"text",text:""});break;case 35:x.setYAxisRangeData(Number(o[d-2]),Number(o[d]));break;case 39:this.$={text:o[d],type:"text"};break;case 40:this.$={text:o[d],type:"text"};break;case 41:this.$={text:o[d],type:"markdown"};break;case 42:this.$=o[d];break;case 43:this.$=o[d-1]+""+o[d];break}},"anonymous"),table:[i(t,e,{3:1,4:2,7:4,5:a,36:n,37:r,38:h}),{1:[3]},i(t,e,{4:2,7:4,3:8,5:a,36:n,37:r,38:h}),i(t,e,{4:2,7:4,6:9,3:10,5:a,8:[1,11],36:n,37:r,38:h}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},i(f,[2,36]),i(f,[2,37]),i(f,[2,38]),{1:[2,1]},i(t,e,{4:2,7:4,3:21,5:a,36:n,37:r,38:h}),{1:[2,3]},i(f,[2,5]),i(t,[2,7],{4:22,36:n,37:r,38:h}),{11:23,30:m,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:39,13:38,24:L,29:g,30:m,31:40,32:41,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:45,15:44,29:j,30:m,35:46,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:49,17:48,24:B,30:m,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{11:52,17:51,24:B,30:m,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},{20:[1,53]},{22:[1,54]},i(D,[2,18]),{1:[2,2]},i(D,[2,8]),i(D,[2,9]),i(G,[2,39],{41:55,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y}),i(G,[2,40]),i(G,[2,41]),i(P,[2,42]),i(P,[2,44]),i(P,[2,45]),i(P,[2,46]),i(P,[2,47]),i(P,[2,48]),i(P,[2,49]),i(P,[2,50]),i(P,[2,51]),i(P,[2,52]),i(P,[2,53]),i(D,[2,10]),i(D,[2,24],{32:41,31:56,24:L,29:g}),i(D,[2,26]),i(D,[2,27]),{33:[1,57]},{11:59,30:m,34:58,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},i(D,[2,11]),i(D,[2,32],{35:60,29:j}),i(D,[2,34]),{33:[1,61]},i(D,[2,12]),{17:62,24:B},{25:63,27:64,29:K},i(D,[2,14]),{17:66,24:B},i(D,[2,16]),i(D,[2,17]),i(P,[2,43]),i(D,[2,25]),{29:[1,67]},{26:[1,68]},{26:[2,31],28:[1,69]},i(D,[2,33]),{29:[1,70]},i(D,[2,13]),{26:[1,71]},{26:[2,21],28:[1,72]},i(k,[2,23],{30:[1,73]}),i(D,[2,15]),i(D,[2,28]),i(D,[2,29]),{11:59,30:m,34:74,39:24,40:u,41:27,42:A,43:S,44:_,45:V,46:z,47:E,48:O,49:W,50:F,51:y},i(D,[2,35]),i(D,[2,19]),{25:75,27:64,29:K},i(k,[2,22]),{26:[2,30]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],74:[2,30],75:[2,20]},parseError:s(function(l,c){if(c.recoverable)this.trace(l);else{var p=new Error(l);throw p.hash=c,p}},"parseError"),parse:s(function(l){var c=this,p=[0],x=[],T=[null],o=[],$=this.table,d="",ot=0,It=0,Bt=0,ge=2,Mt=1,pe=o.slice.call(arguments,1),R=Object.create(this.lexer),U={yy:{}};for(var bt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,bt)&&(U.yy[bt]=this.yy[bt]);R.setInput(l,U.yy),U.yy.lexer=R,U.yy.parser=this,typeof R.yylloc>"u"&&(R.yylloc={});var yt=R.yylloc;o.push(yt);var ue=R.options&&R.options.ranges;typeof U.yy.parseError=="function"?this.parseError=U.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Xe(X){p.length=p.length-2*X,T.length=T.length-X,o.length=o.length-X}s(Xe,"popStack");function xe(){var X;return X=x.pop()||R.lex()||Mt,typeof X!="number"&&(X instanceof Array&&(x=X,X=x.pop()),X=c.symbols_[X]||X),X}s(xe,"lex");for(var v,Ct,q,I,Ye,At,Q={},rt,N,Vt,lt;;){if(q=p[p.length-1],this.defaultActions[q]?I=this.defaultActions[q]:((v===null||typeof v>"u")&&(v=xe()),I=$[q]&&$[q][v]),typeof I>"u"||!I.length||!I[0]){var Dt="";lt=[];for(rt in $[q])this.terminals_[rt]&&rt>ge&&lt.push("'"+this.terminals_[rt]+"'");R.showPosition?Dt="Parse error on line "+(ot+1)+`: `+R.showPosition()+` Expecting `+lt.join(", ")+", got '"+(this.terminals_[v]||v)+"'":Dt="Parse error on line "+(ot+1)+": Unexpected "+(v==Mt?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(Dt,{text:R.match,token:this.terminals_[v]||v,line:R.yylineno,loc:yt,expected:lt})}if(I[0]instanceof Array&&I.length>1)throw new Error("Parse Error: multiple actions possible at state: "+q+", token: "+v);switch(I[0]){case 1:p.push(v),T.push(R.yytext),o.push(R.yylloc),p.push(I[1]),v=null,Ct?(v=Ct,Ct=null):(It=R.yyleng,d=R.yytext,ot=R.yylineno,yt=R.yylloc,Bt>0&&Bt--);break;case 2:if(N=this.productions_[I[1]][1],Q.$=T[T.length-N],Q._$={first_line:o[o.length-(N||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(N||1)].first_column,last_column:o[o.length-1].last_column},ue&&(Q._$.range=[o[o.length-(N||1)].range[0],o[o.length-1].range[1]]),At=this.performAction.apply(Q,[d,It,ot,U.yy,I[1],T,o].concat(pe)),typeof At<"u")return At;N&&(p=p.slice(0,-1*N*2),T=T.slice(0,-1*N),o=o.slice(0,-1*N)),p.push(this.productions_[I[1]][0]),T.push(Q.$),o.push(Q._$),Vt=$[p[p.length-2]][p[p.length-1]],p.push(Vt);break;case 3:return!0}}return!0},"parse")},M=(function(){var Y={EOF:1,parseError:s(function(c,p){if(this.yy.parser)this.yy.parser.parseError(c,p);else throw new Error(c)},"parseError"),setInput:s(function(l,c){return this.yy=c||this.yy||{},this._input=l,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:s(function(){var l=this._input[0];this.yytext+=l,this.yyleng++,this.offset++,this.match+=l,this.matched+=l;var c=l.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),l},"input"),unput:s(function(l){var c=l.length,p=l.split(/(?:\r\n?|\n)/g);this._input=l+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var x=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),p.length-1&&(this.yylineno-=p.length-1);var T=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:p?(p.length===x.length?this.yylloc.first_column:0)+x[x.length-p.length].length-p[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[T[0],T[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:s(function(){return this._more=!0,this},"more"),reject: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"),less:s(function(l){this.unput(this.match.slice(l))},"less"),pastInput:s(function(){var l=this.matched.substr(0,this.matched.length-this.match.length);return(l.length>20?"...":"")+l.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:s(function(){var l=this.match;return l.length<20&&(l+=this._input.substr(0,20-l.length)),(l.substr(0,20)+(l.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:s(function(){var l=this.pastInput(),c=new Array(l.length+1).join("-");return l+this.upcomingInput()+` `+c+"^"},"showPosition"),test_match:s(function(l,c){var p,x,T;if(this.options.backtrack_lexer&&(T={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&&(T.yylloc.range=this.yylloc.range.slice(0))),x=l[0].match(/(?:\r\n?|\n).*/g),x&&(this.yylineno+=x.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:x?x[x.length-1].length-x[x.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+l[0].length},this.yytext+=l[0],this.match+=l[0],this.matches=l,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(l[0].length),this.matched+=l[0],p=this.performAction.call(this,this.yy,this,c,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),p)return p;if(this._backtrack){for(var o in T)this[o]=T[o];return!1}return!1},"test_match"),next:s(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var l,c,p,x;this._more||(this.yytext="",this.match="");for(var T=this._currentRules(),o=0;o<T.length;o++)if(p=this._input.match(this.rules[T[o]]),p&&(!c||p[0].length>c[0].length)){if(c=p,x=o,this.options.backtrack_lexer){if(l=this.test_match(p,T[o]),l!==!1)return l;if(this._backtrack){c=!1;continue}else return!1}else if(!this.options.flex)break}return c?(l=this.test_match(c,T[x]),l!==!1?l:!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"),lex:s(function(){var c=this.next();return c||this.lex()},"lex"),begin:s(function(c){this.conditionStack.push(c)},"begin"),popState:s(function(){var c=this.conditionStack.length-1;return c>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules: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"),topState:s(function(c){return c=this.conditionStack.length-1-Math.abs(c||0),c>=0?this.conditionStack[c]:"INITIAL"},"topState"),pushState:s(function(c){this.begin(c)},"pushState"),stateStackSize:s(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:s(function(c,p,x,T){var o=T;switch(x){case 0:break;case 1:break;case 2:return this.popState(),36;break;case 3:return this.popState(),36;break;case 4:return 36;case 5:break;case 6:return 10;case 7:return this.pushState("acc_title"),19;break;case 8:return this.popState(),"acc_title_value";break;case 9:return this.pushState("acc_descr"),21;break;case 10:return this.popState(),"acc_descr_value";break;case 11:this.pushState("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:return 5;case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";break;case 18:return this.pushState("axis_data"),"Y_AXIS";break;case 19:return this.pushState("axis_band_data"),24;break;case 20:return 33;case 21:return this.pushState("data"),16;break;case 22:return this.pushState("data"),18;break;case 23:return this.pushState("data_inner"),24;break;case 24:return 29;case 25:return this.popState(),26;break;case 26:this.popState();break;case 27:this.pushState("string");break;case 28:this.popState();break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 44;case 33:return"COLON";case 34:return 45;case 35:return 28;case 36:return 46;case 37:return 47;case 38:return 49;case 39:return 51;case 40:return 48;case 41:return 42;case 42:return 50;case 43:return 43;case 44:break;case 45:return 37;case 46:return 38}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return Y})();C.lexer=M;function w(){this.yy={}}return s(w,"Parser"),w.prototype=C,C.Parser=w,new w})();_t.parser=_t;var Qt=_t;function et(i){return i.type==="bar"}s(et,"isBarPlot");function it(i){return i.type==="band"}s(it,"isBandAxisData");function Z(i){return i.type==="linear"}s(Z,"isLinearAxisData");var H=class{constructor(t){this.parentGroup=t}static{s(this,"TextDimensionCalculatorWithFont")}getMaxDimension(t,e){if(!this.parentGroup)return{width:t.reduce((u,A)=>Math.max(A.length,u),0)*e,height:e};let a={width:0,height:0},n=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",e),r=n.node()?.getScreenCTM?.(),h=s(u=>u&&u>0?u:1,"toScale"),f=h(r?.a),m=h(r?.d);for(let u of t){let A=qt(n,1,u),S=A?A.width/f:u.length*e,_=A?A.height/m:e;a.width=Math.max(a.width,S),a.height=Math.max(a.height,_)}return n.remove(),a}};var J=class{constructor(t,e,a,n){this.axisConfig=t;this.title=e;this.textDimensionCalculator=a;this.axisThemeConfig=n;this.boundingRect={x:0,y:0,width:0,height:0};this.axisPosition="left";this.showTitle=!1;this.showLabel=!1;this.showTick=!1;this.showAxisLine=!1;this.outerPadding=0;this.titleTextHeight=0;this.labelTextHeight=0;this.normalizedLabelRotationInRad=0;this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.normalizedLabelRotationInRad=this.axisConfig.labelRotation>=-90&&this.axisConfig.labelRotation<=90?this.axisConfig.labelRotation*Math.PI/180:0}static{s(this,"BaseAxis")}setRange(t){this.range=t,this.axisPosition==="left"||this.axisPosition==="right"?this.boundingRect.height=t[1]-t[0]:this.boundingRect.width=t[1]-t[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(t){this.axisPosition=t,this.setRange(this.range)}getTickDistance(){let t=this.getRange();return Math.abs(t[0]-t[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(t=>t.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){.7*this.getTickDistance()>this.outerPadding*2&&(this.outerPadding=Math.floor(.7*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(t){let e=t.height;if(this.axisConfig.showAxisLine&&e>this.axisConfig.axisLineWidth&&(e-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let a=this.getLabelDimension(),n=.2*t.width;this.outerPadding=Math.min(a.width/2,n);let r=a.height;this.axisPosition==="bottom"&&this.normalizedLabelRotationInRad!==0&&(r=Math.max(r,Math.abs(Math.sin(this.normalizedLabelRotationInRad)*a.width)+Math.abs(Math.cos(this.normalizedLabelRotationInRad)*a.height))),r+=this.axisConfig.labelPadding*2,this.labelTextHeight=a.height,r<=e&&(e-=r,this.showLabel=!0)}if(this.axisConfig.showTick&&e>=this.axisConfig.tickLength&&(this.showTick=!0,e-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let a=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=a.height+this.axisConfig.titlePadding*2;this.titleTextHeight=a.height,n<=e&&(e-=n,this.showTitle=!0)}this.boundingRect.width=t.width,this.boundingRect.height=t.height-e}calculateSpaceIfDrawnVertical(t){let e=t.width;if(this.axisConfig.showAxisLine&&e>this.axisConfig.axisLineWidth&&(e-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let a=this.getLabelDimension(),n=.2*t.height;this.outerPadding=Math.min(a.height/2,n);let r=a.width+this.axisConfig.labelPadding*2;r<=e&&(e-=r,this.showLabel=!0)}if(this.axisConfig.showTick&&e>=this.axisConfig.tickLength&&(this.showTick=!0,e-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let a=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),n=a.height+this.axisConfig.titlePadding*2;this.titleTextHeight=a.height,n<=e&&(e-=n,this.showTitle=!0)}this.boundingRect.width=t.width-e,this.boundingRect.height=t.height}calculateSpace(t){return this.axisPosition==="left"||this.axisPosition==="right"?this.calculateSpaceIfDrawnVertical(t):this.calculateSpaceIfDrawnHorizontally(t),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateOffsetByRotation(t){let e=this.normalizedLabelRotationInRad;return e===0?0:Math.sin(e)*this.getLabelDimension()[t]/2}getDrawableElementsForLeftAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${e},${this.boundingRect.y} L ${e},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(e),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){let e=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${e},${this.getScaleValue(a)} L ${e-this.axisConfig.tickLength},${this.getScaleValue(a)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForBottomAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.y+this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${e} L ${this.boundingRect.x+this.boundingRect.width},${e}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.getScaleValue(e)+this.calculateOffsetByRotation("height"),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0)+Math.abs(this.calculateOffsetByRotation("width")),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:this.normalizedLabelRotationInRad*180/Math.PI,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let e=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${this.getScaleValue(a)},${e} L ${this.getScaleValue(a)},${e+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForTopAxis(){let t=[];if(this.showAxisLine){let e=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${e} L ${this.boundingRect.x+this.boundingRect.width},${e}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(e=>({text:e.toString(),x:this.getScaleValue(e),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+this.axisConfig.titlePadding*2:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let e=this.boundingRect.y;t.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(a=>({path:`M ${this.getScaleValue(a)},${e+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(a)},${e+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElements(){if(this.axisPosition==="left")return this.getDrawableElementsForLeftAxis();if(this.axisPosition==="right")throw Error("Drawing of right axis is not implemented");return this.axisPosition==="bottom"?this.getDrawableElementsForBottomAxis():this.axisPosition==="top"?this.getDrawableElementsForTopAxis():[]}};var gt=class extends J{static{s(this,"BandAxis")}constructor(t,e,a,n,r){super(t,n,r,e),this.categories=a,this.scale=wt().domain(this.categories).range(this.getRange())}setRange(t){super.setRange(t)}recalculateScale(){this.scale=wt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),ht.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(t){return this.scale(t)??this.getRange()[0]}};var pt=class extends J{static{s(this,"LinearAxis")}constructor(t,e,a,n,r){super(t,n,r,e),this.domain=a,this.scale=St().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){let t=[...this.domain];this.axisPosition==="left"&&t.reverse(),this.scale=St().domain(t).range(this.getRange())}getScaleValue(t){return this.scale(t)}};function Pt(i,t,e,a){let n=new H(a);return it(i)?new gt(t,e,i.categories,i.title,n):new pt(t,e,[i.min,i.max],i.title,n)}s(Pt,"getAxis");var vt=class{constructor(t,e,a,n){this.textDimensionCalculator=t;this.chartConfig=e;this.chartData=a;this.chartThemeConfig=n;this.titleWidth=0;this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}static{s(this,"ChartTitle")}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){let e=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),a=Math.max(e.width,t.width),n=e.height+2*this.chartConfig.titlePadding;return n<=t.height&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=a,this.boundingRect.height=n,this.titleWidth=e.width,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}alignTo(t,e){let a=Math.min(this.titleWidth,this.chartConfig.width)/2,n=Math.min(Math.max((t+e)/2,a),this.chartConfig.width-a);this.boundingRect.x=n-a,this.boundingRect.width=a*2}getDrawableElements(){let t=[];return this.showChartTitle&&t.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),t}};function Zt(i,t,e,a){let n=new H(a);return new vt(n,i,t,e)}s(Zt,"getChartTitleComponent");var me=.75,de=.5,fe=.35;function Jt(i){return{fontSize:i,markerSize:i*me,markerSpacing:i*fe,itemSpacing:i*de}}s(Jt,"getLegendLayout");var Et=class{constructor(t,e,a,n){this.textDimensionCalculator=t;this.chartConfig=e;this.chartData=a;this.chartThemeConfig=n;this.boundingRect={x:0,y:0,width:0,height:0};this.visiblePlots=[]}static{s(this,"ChartLegend")}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){if(this.visiblePlots=this.chartConfig.showLegend?this.chartData.plots.filter(u=>u.title):[],this.visiblePlots.length===0)return this.boundingRect.width=0,this.boundingRect.height=0,{width:0,height:0};let{fontSize:e,markerSize:a,markerSpacing:n,itemSpacing:r}=Jt(this.chartConfig.legendFontSize),h=this.textDimensionCalculator.getMaxDimension(this.visiblePlots.map(u=>u.title),e),f=this.chartConfig.legendPadding*2+a+n+h.width,m=this.chartConfig.legendPadding*2+this.visiblePlots.length*e+(this.visiblePlots.length-1)*r;return f<=t.width&&m<=t.height?(this.boundingRect.width=f,this.boundingRect.height=m):(this.visiblePlots=[],this.boundingRect.width=0,this.boundingRect.height=0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(this.visiblePlots.length===0)return[];let{fontSize:t,markerSize:e,markerSpacing:a,itemSpacing:n}=Jt(this.chartConfig.legendFontSize),r=t+n,h=this.boundingRect.x+this.chartConfig.legendPadding,f=this.boundingRect.y+this.chartConfig.legendPadding,m=[],u=[];for(let[A,S]of this.visiblePlots.entries())if(et(S))m.push({x:h,y:f+A*r,width:e,height:e,fill:S.fill,strokeFill:S.fill,strokeWidth:0});else{let _=f+A*r+e/2;u.push({path:`M ${h},${_} L ${h+e},${_}`,strokeFill:S.strokeFill,strokeWidth:S.strokeWidth})}return[{groupTexts:["legend","markers"],type:"rect",data:m},{groupTexts:["legend","markers"],type:"path",data:u},{groupTexts:["legend","label"],type:"text",data:this.visiblePlots.map((A,S)=>({text:A.title,x:h+e+a,y:f+S*r+e/2,fill:this.chartThemeConfig.legendTextColor,fontSize:t,rotation:0,verticalPos:"middle",horizontalPos:"left"}))}]}};function te(i,t,e,a){let n=new H(a);return new Et(n,i,t,e)}s(te,"getChartLegendComponent");var ut=class{constructor(t,e,a,n,r){this.plotData=t;this.xAxis=e;this.yAxis=a;this.orientation=n;this.plotIndex=r}static{s(this,"LinePlot")}getDrawableElement(){let t=this.plotData.data.map(n=>[this.xAxis.getScaleValue(n[0]),this.yAxis.getScaleValue(n[1])]),e;if(this.orientation==="horizontal"?e=kt().y(n=>n[0]).x(n=>n[1])(t):e=kt().x(n=>n[0]).y(n=>n[1])(t),!e)return[];let a=[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:e,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}];if(this.plotData.pointLabels&&this.plotData.pointLabels.length>0){let h=[];for(let[f,[m,u]]of t.entries()){let A=this.plotData.pointLabels[f];A&&(this.orientation==="horizontal"?h.push({x:u+10,y:m,text:A,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"left",fontSize:12,rotation:0}):h.push({x:m,y:u-10,text:A,fill:this.plotData.strokeFill,verticalPos:"middle",horizontalPos:"center",fontSize:12,rotation:0}))}h.length>0&&a.push({groupTexts:["plot",`line-plot-${this.plotIndex}`,"labels"],type:"text",data:h})}return a}};var xt=class{constructor(t,e,a,n,r,h){this.barData=t;this.boundingRect=e;this.xAxis=a;this.yAxis=n;this.orientation=r;this.plotIndex=h}static{s(this,"BarPlot")}getDrawableElement(){let t=this.barData.data.map(r=>[this.xAxis.getScaleValue(r[0]),this.yAxis.getScaleValue(r[1])]),a=Math.min(this.xAxis.getAxisOuterPadding()*2,this.xAxis.getTickDistance())*(1-.05),n=a/2;return this.orientation==="horizontal"?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(r=>({x:this.boundingRect.x,y:r[0]-n,height:a,width:r[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(r=>({x:r[0]-n,y:r[1],width:a,height:this.boundingRect.y+this.boundingRect.height-r[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}};var Lt=class{constructor(t,e,a){this.chartConfig=t;this.chartData=e;this.chartThemeConfig=a;this.boundingRect={x:0,y:0,width:0,height:0}}static{s(this,"BasePlot")}setAxes(t,e){this.xAxis=t,this.yAxis=e}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){return this.boundingRect.width=t.width,this.boundingRect.height=t.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!(this.xAxis&&this.yAxis))throw Error("Axes must be passed to render Plots");let t=[];for(let[e,a]of this.chartData.plots.entries())switch(a.type){case"line":{let n=new ut(a,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,e);t.push(...n.getDrawableElement())}break;case"bar":{let n=new xt(a,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,e);t.push(...n.getDrawableElement())}break}return t}};function ee(i,t,e){return new Lt(i,t,e)}s(ee,"getPlotComponent");var mt=class{constructor(t,e,a,n){this.chartConfig=t;this.chartData=e;this.componentStore={title:Zt(t,e,a,n),plot:ee(t,e,a),legend:te(t,e,a,n),xAxis:Pt(e.xAxis,t.xAxis,{titleColor:a.xAxisTitleColor,labelColor:a.xAxisLabelColor,tickColor:a.xAxisTickColor,axisLineColor:a.xAxisLineColor},n),yAxis:Pt(e.yAxis,t.yAxis,{titleColor:a.yAxisTitleColor,labelColor:a.yAxisLabelColor,tickColor:a.yAxisTickColor,axisLineColor:a.yAxisLineColor},n)}}static{s(this,"Orchestrator")}calculateVerticalSpace(){let t=this.chartConfig.width,e=this.chartConfig.height,a=0,n=0,r={width:0,height:0},h=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),f=Math.floor(e*this.chartConfig.plotReservedSpacePercent/100),m=this.componentStore.plot.calculateSpace({width:h,height:f});t-=m.width,e-=m.height,m=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:e}),n=m.height,e-=m.height,this.componentStore.xAxis.setAxisPosition("bottom"),m=this.componentStore.xAxis.calculateSpace({width:t,height:e}),e-=m.height,this.componentStore.yAxis.setAxisPosition("left"),m=this.componentStore.yAxis.calculateSpace({width:t,height:e}),a=m.width,t-=m.width,r=this.componentStore.legend.calculateSpace({width:t,height:f}),t-=r.width,t>0&&(h+=t,t=0),e>0&&(f+=e,e=0),this.componentStore.plot.calculateSpace({width:h,height:f}),this.componentStore.plot.setBoundingBoxXY({x:a,y:n}),this.componentStore.title.alignTo(a,a+h),this.componentStore.legend.setBoundingBoxXY({x:a+h,y:n+Math.max((f-r.height)/2,0)}),this.componentStore.xAxis.setRange([a,a+h]),this.componentStore.xAxis.setBoundingBoxXY({x:a,y:n+f}),this.componentStore.yAxis.setRange([n,n+f]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:n}),this.chartData.plots.some(u=>et(u))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let t=this.chartConfig.width,e=this.chartConfig.height,a=0,n=0,r=0,h={width:0,height:0},f=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),m=Math.floor(e*this.chartConfig.plotReservedSpacePercent/100),u=this.componentStore.plot.calculateSpace({width:f,height:m});t-=u.width,e-=u.height,u=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:e}),a=u.height,e-=u.height,this.componentStore.xAxis.setAxisPosition("left"),u=this.componentStore.xAxis.calculateSpace({width:t,height:e}),t-=u.width,n=u.width,this.componentStore.yAxis.setAxisPosition("top"),u=this.componentStore.yAxis.calculateSpace({width:t,height:e}),e-=u.height,r=a+u.height,h=this.componentStore.legend.calculateSpace({width:t,height:m}),t-=h.width,t>0&&(f+=t,t=0),e>0&&(m+=e,e=0),this.componentStore.plot.calculateSpace({width:f,height:m}),this.componentStore.plot.setBoundingBoxXY({x:n,y:r}),this.componentStore.title.alignTo(n,n+f),this.componentStore.legend.setBoundingBoxXY({x:n+f,y:r+Math.max((m-h.height)/2,0)}),this.componentStore.yAxis.setRange([n,n+f]),this.componentStore.yAxis.setBoundingBoxXY({x:n,y:a}),this.componentStore.xAxis.setRange([r,r+m]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:r}),this.chartData.plots.some(A=>et(A))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){this.chartConfig.chartOrientation==="horizontal"?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();let t=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(let e of Object.values(this.componentStore))t.push(...e.getDrawableElements());return t}};var dt=class{static{s(this,"XYChartBuilder")}static build(t,e,a,n){return new mt(t,e,a,n).getDrawableElement()}};var at=0,ie,nt=ne(),st=ae(),b=se(),Xt=st.plotColorPalette.split(",").map(i=>i.trim()),ft=!1,Yt=!1;function ae(){let i=zt(),t=ct();return Rt(i.xyChart,t.themeVariables.xyChart)}s(ae,"getChartDefaultThemeConfig");function ne(){let i=ct();return Rt(Ot.xyChart,i.xyChart)}s(ne,"getChartDefaultConfig");function se(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}s(se,"getChartDefaultData");function tt(i){let t=ct();return Wt(i.trim(),t)}s(tt,"textSanitizer");function be(i){ie=i}s(be,"setTmpSVGG");function ye(i){i==="horizontal"?nt.chartOrientation="horizontal":nt.chartOrientation="vertical"}s(ye,"setOrientation");function Ce(i){b.xAxis.title=tt(i.text)}s(Ce,"setXAxisTitle");function oe(i,t){b.xAxis={type:"linear",title:b.xAxis.title,min:i,max:t},ft=!0}s(oe,"setXAxisRangeData");function Ae(i){b.xAxis={type:"band",title:b.xAxis.title,categories:i.map(t=>tt(t.text))},ft=!0}s(Ae,"setXAxisBand");function De(i){b.yAxis.title=tt(i.text)}s(De,"setYAxisTitle");function Te(i,t){b.yAxis={type:"linear",title:b.yAxis.title,min:i,max:t},Yt=!0}s(Te,"setYAxisRangeData");function we(i){let t=Math.min(...i),e=Math.max(...i),a=Z(b.yAxis)?b.yAxis.min:1/0,n=Z(b.yAxis)?b.yAxis.max:-1/0;b.yAxis={type:"linear",title:b.yAxis.title,min:Math.min(a,t),max:Math.max(n,e)}}s(we,"setYAxisRangeFromPlotData");function re(i){let t=[];if(i.length===0)return t;if(!ft){let e=Z(b.xAxis)?b.xAxis.min:1/0,a=Z(b.xAxis)?b.xAxis.max:-1/0;oe(Math.min(e,1),Math.max(a,i.length))}if(it(b.xAxis)&&i.length>b.xAxis.categories.length&&(i=i.slice(0,b.xAxis.categories.length)),Yt||we(i),it(b.xAxis)&&(t=b.xAxis.categories.map((e,a)=>[e,i[a]])),Z(b.xAxis)){let e=b.xAxis.min,a=b.xAxis.max;if(i.length===1)t=[[`${e}`,i[0]]];else{let n=(a-e)/(i.length-1);t=i.map((r,h)=>[`${e+h*n}`,r])}}return t}s(re,"transformDataWithoutCategory");function le(i){return Xt[i===0?0:i%Xt.length]}s(le,"getPlotColorFromPalette");function Se(i,t){let e=t.map(h=>h.value),a=t.map(h=>h.label?tt(h.label):""),n=re(e),r=a.some(h=>h!=="");b.plots.push({type:"line",title:tt(i.text),strokeFill:le(at),strokeWidth:2,data:n,...r?{pointLabels:a}:{}}),at++}s(Se,"setLineData");function ke(i,t){let e=t.map(n=>n.value),a=re(e);b.plots.push({type:"bar",title:tt(i.text),fill:le(at),data:a}),at++}s(ke,"setBarData");function Re(){if(b.plots.length===0)throw Error("No Plot to render, please provide a plot with some data");return b.title=Tt(),dt.build(nt,b,st,ie)}s(Re,"getDrawableElem");function _e(){return st}s(_e,"getChartThemeConfig");function Pe(){return nt}s(Pe,"getChartConfig");function ve(){return b}s(ve,"getXYChartData");var Ee=s(function(){Nt(),at=0,nt=ne(),b=se(),st=ae(),Xt=st.plotColorPalette.split(",").map(i=>i.trim()),ft=!1,Yt=!1},"clear"),he={getDrawableElem:Re,clear:Ee,setAccTitle:jt,getAccTitle:Gt,setDiagramTitle:Ut,getDiagramTitle:Tt,getAccDescription:$t,setAccDescription:Ht,setOrientation:ye,setXAxisTitle:Ce,setXAxisRangeData:oe,setXAxisBand:Ae,setYAxisTitle:De,setYAxisRangeData:Te,setLineData:Se,setBarData:ke,setTmpSVGG:be,getChartThemeConfig:_e,getChartConfig:Pe,getXYChartData:ve};var Le=s((i,t,e,a)=>{let n=a.db,r=n.getChartThemeConfig(),h=n.getChartConfig(),f=n.getXYChartData().plots[0].data.map(y=>y[1]);function m(y){return y==="top"?"text-before-edge":"middle"}s(m,"getDominantBaseLine");function u(y){return y==="left"?"start":y==="right"?"end":"middle"}s(u,"getTextAnchor");function A(y){return`translate(${y.x}, ${y.y}) rotate(${y.rotation||0})`}s(A,"getTextTransformation"),ht.debug(`Rendering xychart chart `+i);let S=Kt(t),_=S.append("g").attr("class","main"),V=_.append("rect").attr("width",h.width).attr("height",h.height).attr("class","background");Ft(S,h.height,h.width,!0),S.attr("viewBox",`0 0 ${h.width} ${h.height}`),V.attr("fill",r.backgroundColor),n.setTmpSVGG(S.append("g").attr("class","mermaid-tmp-group"));let z=n.getDrawableElem(),E={};function O(y){let L=_,g="";for(let[j]of y.entries()){let B=_;j>0&&E[g]&&(B=E[g]),g+=y[j],L=E[g],L||(L=E[g]=B.append("g").attr("class",y[j]))}return L}s(O,"getGroup");for(let y of z){if(y.data.length===0)continue;let L=O(y.groupTexts);switch(y.type){case"rect":if(L.selectAll("rect").data(y.data).enter().append("rect").attr("x",g=>g.x).attr("y",g=>g.y).attr("width",g=>g.width).attr("height",g=>g.height).attr("fill",g=>g.fill).attr("stroke",g=>g.strokeFill).attr("stroke-width",g=>g.strokeWidth),h.showDataLabel){let g=h.showDataLabelOutsideBar;if(h.chartOrientation==="horizontal"){let G=function(C,M){let{data:w,label:Y}=C;return M*Y.length*.7<=w.width-10};var W=G;s(G,"fitsHorizontally");let j=.7,B=10,D=y.data.map((C,M)=>({data:C,label:f[M].toString()})).filter(C=>C.data.width>0&&C.data.height>0),P=D.map(C=>{let{data:M}=C,w=M.height*.7;for(;!G(C,w)&&w>0;)w-=1;return w}),K=Math.floor(Math.min(...P)),k=s(C=>g?C.data.x+C.data.width+10:C.data.x+C.data.width-10,"determineLabelXPosition");L.selectAll("text").data(D).enter().append("text").attr("x",k).attr("y",C=>C.data.y+C.data.height/2).attr("text-anchor",g?"start":"end").attr("dominant-baseline","middle").attr("fill",r.dataLabelColor).attr("font-size",`${K}px`).text(C=>C.label)}else{let D=function(k,C,M){let{data:w,label:Y}=k,c=C*Y.length*.7,p=w.x+w.width/2,x=p-c/2,T=p+c/2,o=x>=w.x&&T<=w.x+w.width,$=w.y+M+C<=w.y+w.height;return o&&$};var F=D;s(D,"fitsInBar");let j=10,B=y.data.map((k,C)=>({data:k,label:f[C].toString()})).filter(k=>k.data.width>0&&k.data.height>0),G=B.map(k=>{let{data:C,label:M}=k,w=C.width/(M.length*.7);for(;!D(k,w,10)&&w>0;)w-=1;return w}),P=Math.floor(Math.min(...G)),K=s(k=>g?k.data.y-10:k.data.y+10,"determineLabelYPosition");L.selectAll("text").data(B).enter().append("text").attr("x",k=>k.data.x+k.data.width/2).attr("y",K).attr("text-anchor","middle").attr("dominant-baseline",g?"auto":"hanging").attr("fill",r.dataLabelColor).attr("font-size",`${P}px`).text(k=>k.label)}}break;case"text":L.selectAll("text").data(y.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",g=>g.fill).attr("font-size",g=>g.fontSize).attr("dominant-baseline",g=>m(g.verticalPos)).attr("text-anchor",g=>u(g.horizontalPos)).attr("transform",g=>A(g)).text(g=>g.text);break;case"path":L.selectAll("path").data(y.data).enter().append("path").attr("d",g=>g.path).attr("fill",g=>g.fill?g.fill:"none").attr("stroke",g=>g.strokeFill).attr("stroke-width",g=>g.strokeWidth);break}}},"draw"),ce={draw:Le};var qi={parser:Qt,db:he,renderer:ce};export{qi as diagram};