UNPKG

mermaid

Version:

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

100 lines (85 loc) 31.1 kB
import{a as Xe}from"./chunk-RCXAM2GK.mjs";import{a as et}from"./chunk-VTHDQ7BV.mjs";import{b as Je,c as $e}from"./chunk-YDMLL4PJ.mjs";import"./chunk-ZQN7UHIL.mjs";import"./chunk-4OADUZ5Q.mjs";import"./chunk-VRZKL3EH.mjs";import"./chunk-Z6V44ARX.mjs";import"./chunk-5IMINLNL.mjs";import"./chunk-ZNLK7HRR.mjs";import"./chunk-DZP67EKU.mjs";import"./chunk-2NMSUPJH.mjs";import{p as He,s as Qe}from"./chunk-VY2OSTJR.mjs";import"./chunk-STOV2HOB.mjs";import{G as Ye,S as Pe,T as ze,U as Ue,V as je,W as Ke,X as Ze,Y as We,_ as z,b as Be,c as Fe}from"./chunk-QJSWEUOL.mjs";import{b as C,h as qe}from"./chunk-H7VHZCWX.mjs";import{a as p,c as ct}from"./chunk-AQ6EADP3.mjs";var xe=(function(){var s=p(function(F,n,c,d){for(c=c||{},d=F.length;d--;c[F[d]]=n);return c},"o"),a=[6,9,21,23,25,27,34,37,38,39,40,41,43,46,47,51,53,54,55],o=[2,2],l=[1,7],r=[1,9],h=[1,10],k=[1,11],f=[1,12],m=[1,30],I=[1,23],b=[1,24],g=[1,25],A=[1,26],D=[1,27],N=[1,19],x=[1,28],v=[1,29],O=[1,20],L=[1,18],w=[1,21],V=[1,22],Ce=[2,6],u=[6,9,21,23,25,27,33,34,37,38,39,40,41,43,46,47,51,53,54,55],de=[1,36],pe=[1,37],be=[1,38],fe=[1,39],ge=[1,40],K=[6,9,12,14,16,19,20,21,23,25,27,33,34,37,38,39,40,41,43,46,47,50,51,53,54,55,69,70,71,72,73],G=[1,46],M=[1,47],Z=[1,57],W=[43,51,53,54,55,74,75],q=[1,70],H=[1,68],B=[1,65],Q=[1,69],X=[1,71],ee=[6,9,12,16,21,23,25,27,33,34,37,38,39,40,41,43,44,45,46,47,51,52,53,54,55,69,70,71,72,73],te=[1,78],se=[1,77],ie=[1,76],Ae=[69,70,71,72,73],ve=[1,91],Re=[6,9,45,50],U=[6,9,12,44,45,50,51,52],re=[1,101],ae=[1,100],ne=[1,99],J=[18,61],Ie=[1,110],De=[1,109],Le=[20,43,51,53,54,55],ke=[18,61,64,66],ye={trace:p(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,statement:8,NEWLINE:9,entityName:10,relSpec:11,COLON:12,role:13,STYLE_SEPARATOR:14,idList:15,BLOCK_START:16,attributes:17,BLOCK_STOP:18,SQS:19,SQE:20,title:21,title_value:22,acc_title:23,acc_title_value:24,acc_descr:25,acc_descr_value:26,acc_descr_multiline_value:27,direction:28,classDefStatement:29,classStatement:30,styleStatement:31,subgraphHeader:32,END:33,SUBGRAPH:34,separator:35,subgraphTitle:36,direction_tb:37,direction_bt:38,direction_rl:39,direction_lr:40,CLASSDEF:41,stylesOpt:42,UNICODE_TEXT:43,STYLE_TEXT:44,COMMA:45,CLASS:46,STYLE:47,style:48,styleComponent:49,SEMI:50,NUM:51,BRKT:52,ENTITY_NAME:53,DECIMAL_NUM:54,ENTITY_ONE:55,attribute:56,attributeType:57,attributeName:58,attributeKeyTypeList:59,attributeComment:60,ATTRIBUTE_WORD:61,"?":62,attributeKeyType:63,",":64,ATTRIBUTE_KEY:65,COMMENT:66,cardinality:67,relType:68,ZERO_OR_ONE:69,ZERO_OR_MORE:70,ONE_OR_MORE:71,ONLY_ONE:72,MD_PARENT:73,NON_IDENTIFYING:74,IDENTIFYING:75,WORD:76,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",9:"NEWLINE",12:"COLON",14:"STYLE_SEPARATOR",16:"BLOCK_START",18:"BLOCK_STOP",19:"SQS",20:"SQE",21:"title",22:"title_value",23:"acc_title",24:"acc_title_value",25:"acc_descr",26:"acc_descr_value",27:"acc_descr_multiline_value",33:"END",34:"SUBGRAPH",37:"direction_tb",38:"direction_bt",39:"direction_rl",40:"direction_lr",41:"CLASSDEF",43:"UNICODE_TEXT",44:"STYLE_TEXT",45:"COMMA",46:"CLASS",47:"STYLE",50:"SEMI",51:"NUM",52:"BRKT",53:"ENTITY_NAME",54:"DECIMAL_NUM",55:"ENTITY_ONE",61:"ATTRIBUTE_WORD",62:"?",64:",",65:"ATTRIBUTE_KEY",66:"COMMENT",69:"ZERO_OR_ONE",70:"ZERO_OR_MORE",71:"ONE_OR_MORE",72:"ONLY_ONE",73:"MD_PARENT",74:"NON_IDENTIFYING",75:"IDENTIFYING",76:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,1],[7,1],[7,1],[8,5],[8,9],[8,7],[8,7],[8,4],[8,6],[8,3],[8,5],[8,1],[8,3],[8,7],[8,9],[8,6],[8,8],[8,4],[8,6],[8,2],[8,2],[8,2],[8,1],[8,1],[8,1],[8,1],[8,1],[8,3],[32,3],[32,6],[36,1],[36,2],[28,1],[28,1],[28,1],[28,1],[29,4],[15,1],[15,1],[15,3],[15,3],[30,3],[31,4],[42,1],[42,3],[48,1],[48,2],[35,1],[35,1],[35,1],[49,1],[49,1],[49,1],[49,1],[10,1],[10,1],[10,1],[10,1],[10,1],[17,1],[17,2],[56,2],[56,3],[56,3],[56,4],[57,1],[57,2],[58,1],[59,1],[59,3],[63,1],[60,1],[11,3],[67,1],[67,1],[67,1],[67,1],[67,1],[68,1],[68,1],[13,1],[13,1],[13,1]],performAction:p(function(n,c,d,i,y,e,$){var t=e.length-1;switch(y){case 1:break;case 2:this.$=[];break;case 3:this.$=e[t-1].concat(e[t]);break;case 4:this.$=e[t];break;case 5:case 6:this.$=[];break;case 7:i.addEntity(e[t-4]),i.addEntity(e[t-2]),i.addRelationship(e[t-4],e[t],e[t-2],e[t-3]),this.$=[e[t-4],e[t-2]];break;case 8:i.addEntity(e[t-8]),i.addEntity(e[t-4]),i.addRelationship(e[t-8],e[t],e[t-4],e[t-5]),i.setClass([e[t-8]],e[t-6]),i.setClass([e[t-4]],e[t-2]),this.$=[e[t-8],e[t-4]];break;case 9:i.addEntity(e[t-6]),i.addEntity(e[t-2]),i.addRelationship(e[t-6],e[t],e[t-2],e[t-3]),i.setClass([e[t-6]],e[t-4]),this.$=[e[t-6],e[t-2]];break;case 10:i.addEntity(e[t-6]),i.addEntity(e[t-4]),i.addRelationship(e[t-6],e[t],e[t-4],e[t-5]),i.setClass([e[t-4]],e[t-2]),this.$=[e[t-6],e[t-4]];break;case 11:i.addEntity(e[t-3]),i.addAttributes(e[t-3],e[t-1]),this.$=[e[t-3]];break;case 12:i.addEntity(e[t-5]),i.addAttributes(e[t-5],e[t-1]),i.setClass([e[t-5]],e[t-3]),this.$=[e[t-5]];break;case 13:i.addEntity(e[t-2]),this.$=[e[t-2]];break;case 14:i.addEntity(e[t-4]),i.setClass([e[t-4]],e[t-2]),this.$=[e[t-4]];break;case 15:i.addEntity(e[t]),this.$=[e[t]];break;case 16:i.addEntity(e[t-2]),i.setClass([e[t-2]],e[t]),this.$=[e[t-2]];break;case 17:i.addEntity(e[t-6],e[t-4]),i.addAttributes(e[t-6],e[t-1]),this.$=[e[t-6]];break;case 18:i.addEntity(e[t-8],e[t-6]),i.addAttributes(e[t-8],e[t-1]),i.setClass([e[t-8]],e[t-3]),this.$=[e[t-8]];break;case 19:i.addEntity(e[t-5],e[t-3]),this.$=[e[t-5]];break;case 20:i.addEntity(e[t-7],e[t-5]),i.setClass([e[t-7]],e[t-2]),this.$=[e[t-7]];break;case 21:i.addEntity(e[t-3],e[t-1]);break;case 22:i.addEntity(e[t-5],e[t-3]),i.setClass([e[t-5]],e[t]);break;case 23:case 24:this.$=e[t].trim(),i.setAccTitle(this.$);break;case 25:case 26:this.$=e[t].trim(),i.setAccDescription(this.$);break;case 27:i.subgraphDepth?this.$=e[t]:(i.setDirection(e[t].value),this.$=[]);break;case 31:i.subgraphDepth=(i.subgraphDepth||1)-1,this.$=i.addSubGraph({text:e[t-2].id},e[t-1],{text:e[t-2].text});break;case 32:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:e[t-1],text:e[t-1]};break;case 33:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:e[t-4],text:e[t-2]};break;case 34:case 59:case 60:case 61:case 62:case 86:this.$=e[t];break;case 35:this.$=e[t-1]+" "+e[t];break;case 36:this.$={stmt:"dir",value:"TB"};break;case 37:this.$={stmt:"dir",value:"BT"};break;case 38:this.$={stmt:"dir",value:"RL"};break;case 39:this.$={stmt:"dir",value:"LR"};break;case 40:this.$=e[t-3],i.addClass(e[t-2],e[t-1]);break;case 41:case 42:case 63:case 72:this.$=[e[t]];break;case 43:case 44:this.$=e[t-2].concat([e[t]]);break;case 45:this.$=e[t-2],i.setClass(e[t-1],e[t]);break;case 46:this.$=e[t-3],i.addCssStyles(e[t-2],e[t-1]);break;case 47:this.$=[e[t]];break;case 48:e[t-2].push(e[t]),this.$=e[t-2];break;case 50:this.$=e[t-1]+e[t];break;case 58:case 84:case 85:this.$=e[t].replace(/"/g,"");break;case 64:e[t].push(e[t-1]),this.$=e[t];break;case 65:this.$={type:e[t-1],name:e[t]};break;case 66:this.$={type:e[t-2],name:e[t-1],keys:e[t]};break;case 67:this.$={type:e[t-2],name:e[t-1],comment:e[t]};break;case 68:this.$={type:e[t-3],name:e[t-2],keys:e[t-1],comment:e[t]};break;case 69:case 71:case 74:this.$=e[t];break;case 70:this.$=e[t-1]+e[t];break;case 73:e[t-2].push(e[t]),this.$=e[t-2];break;case 75:this.$=e[t].replace(/"/g,"");break;case 76:this.$={cardA:e[t],relType:e[t-1],cardB:e[t-2]};break;case 77:this.$=i.Cardinality.ZERO_OR_ONE;break;case 78:this.$=i.Cardinality.ZERO_OR_MORE;break;case 79:this.$=i.Cardinality.ONE_OR_MORE;break;case 80:this.$=i.Cardinality.ONLY_ONE;break;case 81:this.$=i.Cardinality.MD_PARENT;break;case 82:this.$=i.Identification.NON_IDENTIFYING;break;case 83:this.$=i.Identification.IDENTIFYING;break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},s(a,o,{5:3}),{6:[1,4],7:5,8:6,9:l,10:8,21:r,23:h,25:k,27:f,28:13,29:14,30:15,31:16,32:17,34:m,37:I,38:b,39:g,40:A,41:D,43:N,46:x,47:v,51:O,53:L,54:w,55:V},s(a,Ce,{1:[2,1]}),s(u,[2,3]),s(u,[2,4]),s(u,[2,5]),s(u,[2,15],{11:31,67:35,14:[1,32],16:[1,33],19:[1,34],69:de,70:pe,71:be,72:fe,73:ge}),{22:[1,41]},{24:[1,42]},{26:[1,43]},s(u,[2,26]),s(u,[2,27]),s(u,[2,28]),s(u,[2,29]),s(u,[2,30]),s(u,o,{5:44}),s(K,[2,58]),s(K,[2,59]),s(K,[2,60]),s(K,[2,61]),s(K,[2,62]),s(u,[2,36]),s(u,[2,37]),s(u,[2,38]),s(u,[2,39]),{15:45,43:G,44:M},{15:48,43:G,44:M},{15:49,43:G,44:M},{10:50,43:N,51:O,53:L,54:w,55:V},{10:51,43:N,51:O,53:L,54:w,55:V},{15:52,43:G,44:M},{17:53,18:[1,54],56:55,57:56,61:Z},{10:58,43:N,51:O,53:L,54:w,55:V},{68:59,74:[1,60],75:[1,61]},s(W,[2,77]),s(W,[2,78]),s(W,[2,79]),s(W,[2,80]),s(W,[2,81]),s(u,[2,23]),s(u,[2,24]),s(u,[2,25]),{6:[1,63],7:5,8:6,9:l,10:8,21:r,23:h,25:k,27:f,28:13,29:14,30:15,31:16,32:17,33:[1,62],34:m,37:I,38:b,39:g,40:A,41:D,43:N,46:x,47:v,51:O,53:L,54:w,55:V},{12:q,42:64,44:H,45:B,48:66,49:67,51:Q,52:X},s(ee,[2,41]),s(ee,[2,42]),{15:72,43:G,44:M,45:B},{12:q,42:73,44:H,45:B,48:66,49:67,51:Q,52:X},{6:te,9:se,19:[1,75],35:74,50:ie},{12:[1,79],14:[1,80]},s(u,[2,16],{67:35,11:81,16:[1,82],45:B,69:de,70:pe,71:be,72:fe,73:ge}),{18:[1,83]},s(u,[2,13]),{17:84,18:[2,63],56:55,57:56,61:Z},{58:85,61:[1,86]},{61:[2,69],62:[1,87]},{20:[1,88]},{67:89,69:de,70:pe,71:be,72:fe,73:ge},s(Ae,[2,82]),s(Ae,[2,83]),s(u,[2,31]),s(u,Ce),{6:te,9:se,35:90,45:ve,50:ie},{43:[1,92],44:[1,93]},s(Re,[2,47],{49:94,12:q,44:H,51:Q,52:X}),s(U,[2,49]),s(U,[2,54]),s(U,[2,55]),s(U,[2,56]),s(U,[2,57]),s(u,[2,45],{45:B}),{6:te,9:se,35:95,45:ve,50:ie},s(u,[2,32]),{10:97,36:96,43:N,51:O,53:L,54:w,55:V},s(u,[2,51]),s(u,[2,52]),s(u,[2,53]),{13:98,43:re,53:ae,76:ne},{15:102,43:G,44:M},{10:103,43:N,51:O,53:L,54:w,55:V},{17:104,18:[1,105],56:55,57:56,61:Z},s(u,[2,11]),{18:[2,64]},s(J,[2,65],{59:106,60:107,63:108,65:Ie,66:De}),s([18,61,65,66],[2,71]),{61:[2,70]},s(u,[2,21],{14:[1,112],16:[1,111]}),s([43,51,53,54,55],[2,76]),s(u,[2,40]),{12:q,44:H,48:113,49:67,51:Q,52:X},s(ee,[2,43]),s(ee,[2,44]),s(U,[2,50]),s(u,[2,46]),{10:115,20:[1,114],43:N,51:O,53:L,54:w,55:V},s(Le,[2,34]),s(u,[2,7]),s(u,[2,84]),s(u,[2,85]),s(u,[2,86]),{12:[1,116],45:B},{12:[1,118],14:[1,117]},{18:[1,119]},s(u,[2,14]),s(J,[2,66],{60:120,64:[1,121],66:De}),s(J,[2,67]),s(ke,[2,72]),s(J,[2,75]),s(ke,[2,74]),{17:122,18:[1,123],56:55,57:56,61:Z},{15:124,43:G,44:M},s(Re,[2,48],{49:94,12:q,44:H,51:Q,52:X}),{6:te,9:se,35:125,50:ie},s(Le,[2,35]),{13:126,43:re,53:ae,76:ne},{15:127,43:G,44:M},{13:128,43:re,53:ae,76:ne},s(u,[2,12]),s(J,[2,68]),{63:129,65:Ie},{18:[1,130]},s(u,[2,19]),s(u,[2,22],{16:[1,131],45:B}),s(u,[2,33]),s(u,[2,10]),{12:[1,132],45:B},s(u,[2,9]),s(ke,[2,73]),s(u,[2,17]),{17:133,18:[1,134],56:55,57:56,61:Z},{13:135,43:re,53:ae,76:ne},{18:[1,136]},s(u,[2,20]),s(u,[2,8]),s(u,[2,18])],defaultActions:{84:[2,64],87:[2,70]},parseError:p(function(n,c){if(c.recoverable)this.trace(n);else{var d=new Error(n);throw d.hash=c,d}},"parseError"),parse:p(function(n){var c=this,d=[0],i=[],y=[null],e=[],$=this.table,t="",oe=0,we=0,Ve=0,at=2,Ge=1,nt=e.slice.call(arguments,1),_=Object.create(this.lexer),Y={yy:{}};for(var _e in this.yy)Object.prototype.hasOwnProperty.call(this.yy,_e)&&(Y.yy[_e]=this.yy[_e]);_.setInput(n,Y.yy),Y.yy.lexer=_,Y.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Ee=_.yylloc;e.push(Ee);var ot=_.options&&_.options.ranges;typeof Y.yy.parseError=="function"?this.parseError=Y.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(S){d.length=d.length-2*S,y.length=y.length-S,e.length=e.length-S}p(pt,"popStack");function lt(){var S;return S=i.pop()||_.lex()||Ge,typeof S!="number"&&(S instanceof Array&&(i=S,S=i.pop()),S=c.symbols_[S]||S),S}p(lt,"lex");for(var E,Se,P,T,bt,Te,j={},le,R,Me,ce;;){if(P=d[d.length-1],this.defaultActions[P]?T=this.defaultActions[P]:((E===null||typeof E>"u")&&(E=lt()),T=$[P]&&$[P][E]),typeof T>"u"||!T.length||!T[0]){var Ne="";ce=[];for(le in $[P])this.terminals_[le]&&le>at&&ce.push("'"+this.terminals_[le]+"'");_.showPosition?Ne="Parse error on line "+(oe+1)+`: `+_.showPosition()+` Expecting `+ce.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Ne="Parse error on line "+(oe+1)+": Unexpected "+(E==Ge?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Ne,{text:_.match,token:this.terminals_[E]||E,line:_.yylineno,loc:Ee,expected:ce})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+P+", token: "+E);switch(T[0]){case 1:d.push(E),y.push(_.yytext),e.push(_.yylloc),d.push(T[1]),E=null,Se?(E=Se,Se=null):(we=_.yyleng,t=_.yytext,oe=_.yylineno,Ee=_.yylloc,Ve>0&&Ve--);break;case 2:if(R=this.productions_[T[1]][1],j.$=y[y.length-R],j._$={first_line:e[e.length-(R||1)].first_line,last_line:e[e.length-1].last_line,first_column:e[e.length-(R||1)].first_column,last_column:e[e.length-1].last_column},ot&&(j._$.range=[e[e.length-(R||1)].range[0],e[e.length-1].range[1]]),Te=this.performAction.apply(j,[t,we,oe,Y.yy,T[1],y,e].concat(nt)),typeof Te<"u")return Te;R&&(d=d.slice(0,-1*R*2),y=y.slice(0,-1*R),e=e.slice(0,-1*R)),d.push(this.productions_[T[1]][0]),y.push(j.$),e.push(j._$),Me=$[d[d.length-2]][d[d.length-1]],d.push(Me);break;case 3:return!0}}return!0},"parse")},rt=(function(){var F={EOF:1,parseError:p(function(c,d){if(this.yy.parser)this.yy.parser.parseError(c,d);else throw new Error(c)},"parseError"),setInput:p(function(n,c){return this.yy=c||this.yy||{},this._input=n,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:p(function(){var n=this._input[0];this.yytext+=n,this.yyleng++,this.offset++,this.match+=n,this.matched+=n;var c=n.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),n},"input"),unput:p(function(n){var c=n.length,d=n.split(/(?:\r\n?|\n)/g);this._input=n+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var i=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),d.length-1&&(this.yylineno-=d.length-1);var 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:d?(d.length===i.length?this.yylloc.first_column:0)+i[i.length-d.length].length-d[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:p(function(){return this._more=!0,this},"more"),reject:p(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:p(function(n){this.unput(this.match.slice(n))},"less"),pastInput:p(function(){var n=this.matched.substr(0,this.matched.length-this.match.length);return(n.length>20?"...":"")+n.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:p(function(){var n=this.match;return n.length<20&&(n+=this._input.substr(0,20-n.length)),(n.substr(0,20)+(n.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:p(function(){var n=this.pastInput(),c=new Array(n.length+1).join("-");return n+this.upcomingInput()+` `+c+"^"},"showPosition"),test_match:p(function(n,c){var d,i,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))),i=n[0].match(/(?:\r\n?|\n).*/g),i&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+n[0].length},this.yytext+=n[0],this.match+=n[0],this.matches=n,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(n[0].length),this.matched+=n[0],d=this.performAction.call(this,this.yy,this,c,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),d)return d;if(this._backtrack){for(var e in y)this[e]=y[e];return!1}return!1},"test_match"),next:p(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var n,c,d,i;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),e=0;e<y.length;e++)if(d=this._input.match(this.rules[y[e]]),d&&(!c||d[0].length>c[0].length)){if(c=d,i=e,this.options.backtrack_lexer){if(n=this.test_match(d,y[e]),n!==!1)return n;if(this._backtrack){c=!1;continue}else return!1}else if(!this.options.flex)break}return c?(n=this.test_match(c,y[i]),n!==!1?n:!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:p(function(){var c=this.next();return c||this.lex()},"lex"),begin:p(function(c){this.conditionStack.push(c)},"begin"),popState:p(function(){var c=this.conditionStack.length-1;return c>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:p(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:p(function(c){return c=this.conditionStack.length-1-Math.abs(c||0),c>=0?this.conditionStack[c]:"INITIAL"},"topState"),pushState:p(function(c){this.begin(c)},"pushState"),stateStackSize:p(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:p(function(c,d,i,y){var e=y;switch(i){case 0:return this.begin("acc_title"),23;break;case 1:return this.popState(),"acc_title_value";break;case 2:return this.begin("acc_descr"),25;break;case 3:return this.popState(),"acc_descr_value";break;case 4:this.begin("acc_descr_multiline");break;case 5:this.popState();break;case 6:return"acc_descr_multiline_value";case 7:return 37;case 8:return 38;case 9:return 39;case 10:return 40;case 11:break;case 12:return 9;case 13:return 53;case 14:return 76;case 15:return 4;case 16:return this.begin("block"),16;break;case 17:return 52;case 18:return 52;case 19:return 45;case 20:return 14;case 21:return 12;case 22:break;case 23:return 65;case 24:return 61;case 25:return 61;case 26:this.begin("block_bq");break;case 27:return 61;case 28:this.popState();break;case 29:return 66;case 30:break;case 31:return this.popState(),18;break;case 32:return d.yytext[0];case 33:return 19;case 34:return 20;case 35:return this.begin("style"),47;break;case 36:return this.popState(),9;break;case 37:break;case 38:return 12;case 39:return 45;case 40:return 52;case 41:return this.begin("style"),41;break;case 42:return 46;case 43:return 34;case 44:return 33;case 45:return 69;case 46:return 71;case 47:return 71;case 48:return 71;case 49:return 69;case 50:return 69;case 51:return 70;case 52:return 70;case 53:return 70;case 54:return 70;case 55:return 70;case 56:return 71;case 57:return 70;case 58:return 71;case 59:return 72;case 60:return 72;case 61:return 54;case 62:return 72;case 63:return 72;case 64:return 72;case 65:return 55;case 66:return 51;case 67:return 72;case 68:return 69;case 69:return 70;case 70:return 71;case 71:return 73;case 72:return 74;case 73:return 75;case 74:return 75;case 75:return 74;case 76:return 74;case 77:return 74;case 78:return 44;case 79:return 50;case 80:return 43;case 81:return d.yytext[0];case 82:return 6}},"anonymous"),rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[ \t\r]+)/i,/^(?:[\n]+)/i,/^(?:"[^"%\r\n\v\b\\]+")/i,/^(?:"[^"]*")/i,/^(?:erDiagram\b)/i,/^(?:\{)/i,/^(?:#)/i,/^(?:#)/i,/^(?:,)/i,/^(?::::)/i,/^(?::)/i,/^(?:\s+)/i,/^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i,/^(?:([^\s]*)[~].*[~]([^\s]*))/i,/^(?:([\*A-Za-z_\u00C0-\uFFFF][A-Za-z0-9\-\_\[\]\(\)\.,\u00C0-\uFFFF\*]*))/i,/^(?:[`])/i,/^(?:[^`]+)/i,/^(?:[`])/i,/^(?:"[^"]*")/i,/^(?:[\n]+)/i,/^(?:\})/i,/^(?:.)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:style\b)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?::)/i,/^(?:,)/i,/^(?:#)/i,/^(?:classDef\b)/i,/^(?:class\b)/i,/^(?:subgraph\b)/i,/^(?:end\b\s*)/i,/^(?:one or zero\b)/i,/^(?:one or more\b)/i,/^(?:one or many\b)/i,/^(?:1\+)/i,/^(?:\|o\b)/i,/^(?:zero or one\b)/i,/^(?:zero or more\b)/i,/^(?:zero or many\b)/i,/^(?:0\+)/i,/^(?:\}o\b)/i,/^(?:many\(0\))/i,/^(?:many\(1\))/i,/^(?:many\b)/i,/^(?:\}\|)/i,/^(?:one\b)/i,/^(?:only one\b)/i,/^(?:[0-9]+\.[0-9]+)/i,/^(?:1(?=\s+[A-Za-z_"']))/i,/^(?:1(?=\s+[0-9]))/i,/^(?:1(?=(--|\.\.|\.-|-\.)))/i,/^(?:1\b)/i,/^(?:[0-9]+)/i,/^(?:\|\|)/i,/^(?:o\|)/i,/^(?:o\{)/i,/^(?:\|\{)/i,/^(?:u(?=[\.\-\|]))/i,/^(?:\.\.)/i,/^(?:--)/i,/^(?:to\b)/i,/^(?:optionally to\b)/i,/^(?:\.-)/i,/^(?:-\.)/i,/^(?:([^\x00-\x7F]|\w|-|\*)+)/i,/^(?:;)/i,/^(?:([^\x00-\x7F]|\w|-|\*|\.)+)/i,/^(?:.)/i,/^(?:$)/i],conditions:{style:{rules:[36,37,38,39,40,78,79],inclusive:!1},acc_descr_multiline:{rules:[5,6],inclusive:!1},acc_descr:{rules:[3],inclusive:!1},acc_title:{rules:[1],inclusive:!1},block_bq:{rules:[27,28],inclusive:!1},block:{rules:[22,23,24,25,26,29,30,31,32],inclusive:!1},INITIAL:{rules:[0,2,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,33,34,35,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,80,81,82],inclusive:!0}}};return F})();ye.lexer=rt;function me(){this.yy={}}return p(me,"Parser"),me.prototype=ye,ye.Parser=me,new me})();xe.parser=xe;var tt=xe;var he=class{constructor(){this.entities=new Map;this.relationships=[];this.classes=new Map;this.subgraphDepth=0;this.subGraphs=[];this.subGraphLookup=new Map;this.subCount=0;this.direction="TB";this.Cardinality={ZERO_OR_ONE:"ZERO_OR_ONE",ZERO_OR_MORE:"ZERO_OR_MORE",ONE_OR_MORE:"ONE_OR_MORE",ONLY_ONE:"ONLY_ONE",MD_PARENT:"MD_PARENT"};this.Identification={NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"};this.setAccTitle=ze;this.getAccTitle=Ue;this.setAccDescription=je;this.getAccDescription=Ke;this.setDiagramTitle=Ze;this.getDiagramTitle=We;this.getConfig=p(()=>z().er,"getConfig");this.clear(),this.addEntity=this.addEntity.bind(this),this.addAttributes=this.addAttributes.bind(this),this.addRelationship=this.addRelationship.bind(this),this.setDirection=this.setDirection.bind(this),this.addCssStyles=this.addCssStyles.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.setAccTitle=this.setAccTitle.bind(this),this.setAccDescription=this.setAccDescription.bind(this),this.addSubGraph=this.addSubGraph.bind(this)}static{p(this,"ErDB")}addEntity(a,o=""){return this.entities.has(a)?!this.entities.get(a)?.alias&&o&&(this.entities.get(a).alias=o,C.info(`Add alias '${o}' to entity '${a}'`)):(this.entities.set(a,{id:`entity-${a}-${this.entities.size}`,label:a,attributes:[],alias:o,shape:"erBox",look:z().look??"default",cssClasses:"default",cssStyles:[],labelType:"markdown"}),C.info("Added new entity :",a)),this.entities.get(a)}getEntity(a){return this.entities.get(a)}getEntities(){return this.entities}getClasses(){return this.classes}addAttributes(a,o){let l=this.addEntity(a),r;for(r=o.length-1;r>=0;r--)o[r].keys||(o[r].keys=[]),o[r].comment||(o[r].comment=""),l.attributes.push(o[r]),C.debug("Added attribute ",o[r].name)}addRelationship(a,o,l,r){let h;if(this.subGraphLookup.has(a))h=a;else{let m=this.addEntity(a);if(!m)return;h=m.id}let k;if(this.subGraphLookup.has(l))k=l;else{let m=this.addEntity(l);if(!m)return;k=m.id}let f={entityA:h,roleA:o,entityB:k,relSpec:r};this.relationships.push(f),C.debug("Added new relationship :",f)}getRelationships(){return this.relationships}getDirection(){return this.direction}setDirection(a){this.direction=a}getCompiledStyles(a){let o=[];for(let l of a){let r=this.classes.get(l);r?.styles&&(o=[...o,...r.styles??[]].map(h=>h.trim())),r?.textStyles&&(o=[...o,...r.textStyles??[]].map(h=>h.trim()))}return o}addCssStyles(a,o){for(let l of a){let r=this.entities.get(l),h=this.subGraphLookup.get(l);if(o){if(r)for(let k of o)r.cssStyles.push(k);if(h){h.cssStyles||(h.cssStyles=[]);for(let k of o)h.cssStyles.push(k)}}}}addClass(a,o){a.forEach(l=>{let r=this.classes.get(l);r===void 0&&(r={id:l,styles:[],textStyles:[]},this.classes.set(l,r)),o&&o.forEach(function(h){if(/color/.exec(h)){let k=h.replace("fill","bgFill");r.textStyles.push(k)}r.styles.push(h)})})}addSubGraph(a,o,l){let r=a.text.trim(),h=l.text,f=p(g=>{let A=new Set,D;return{nodeList:g.filter(x=>{if(x?.stmt)return x.stmt==="dir"&&(D=x.value),!1;if(typeof x!="string")return!1;let v=x.trim();return!v||A.has(v)?!1:(A.add(v),!0)}),dir:D}},"uniq")(o.flat()),m=f.nodeList,I=f.dir;r=r??"subGraph"+this.subCount,h=h||"",h=this.sanitizeText(h),this.subCount=this.subCount+1;let b={id:r,nodes:m,title:h.trim(),classes:[],cssStyles:[],dir:I,labelType:this.sanitizeNodeLabelType(l?.type)};return C.info("Adding",b.id,b.nodes,b.dir),b.nodes=this.makeUniq(b,this.subGraphs).nodes,this.subGraphs.push(b),this.subGraphLookup.set(r,b),r}getSubGraphs(){return this.subGraphs}setClass(a,o){for(let l of a){let r=this.entities.get(l);if(r)for(let k of o)r.cssClasses+=" "+k;let h=this.subGraphLookup.get(l);if(h)for(let k of o)h.classes.push(k)}}subgraphNodeCache(a){let o=new Set;for(let l of a)for(let r of l.nodes)o.add(r);return o}makeUniq(a,o){let l=this.subgraphNodeCache(o),r=[];return a.nodes.forEach((h,k)=>{l.has(h)?C.warn(`Entity '${h}' already belongs to another subgraph and will be ignored`):r.push(a.nodes[k])}),{nodes:r}}sanitizeText(a){return Ye.sanitizeText(a,z())}sanitizeNodeLabelType(a){switch(a){case"markdown":case"string":case"text":return a;default:return"markdown"}}clear(){this.entities=new Map,this.classes=new Map,this.relationships=[],this.subGraphs=[],this.subGraphLookup=new Map,this.subCount=0,this.subgraphDepth=0,Pe()}getData(){let a=[],o=[],l=z(),r=this.getSubGraphs(),h=new Map,k=new Map;for(let b=r.length-1;b>=0;b--){let g=r[b];g.nodes.length>0&&k.set(g.id,!0);for(let A of g.nodes)h.set(A,g.id)}for(let b=r.length-1;b>=0;b--){let g=r[b];a.push({id:g.id,label:g.title,labelStyle:"",labelType:g.labelType,parentId:h.get(g.id),padding:8,cssCompiledStyles:this.getCompiledStyles(g.classes),cssStyles:g.cssStyles,cssClasses:g.classes.join(" "),shape:"rect",dir:g.dir,isGroup:!0,look:l.look})}let f=new Set(r.map(b=>b.id)),m=0;for(let b of this.entities.keys()){if(f.has(b))continue;let g=this.entities.get(b);g&&(g.cssCompiledStyles=this.getCompiledStyles(g.cssClasses.split(" ")),g.colorIndex=m++,a.push({...g,parentId:h.get(b),isGroup:!1}))}let I=0;for(let b of this.relationships){let g={id:Qe(b.entityA,b.entityB,{prefix:"id",counter:I++}),type:"normal",curve:"basis",start:b.entityA,end:b.entityB,label:b.roleA,labelpos:"c",thickness:"normal",classes:"relationshipLine",arrowTypeStart:b.relSpec.cardB.toLowerCase(),arrowTypeEnd:b.relSpec.cardA.toLowerCase(),pattern:b.relSpec.relType=="IDENTIFYING"?"solid":"dashed",look:l.look,labelType:"markdown"};o.push(g)}return{nodes:a,edges:o,other:{},config:l,direction:this.direction}}};var Oe={};ct(Oe,{draw:()=>ht});var ht=p(async function(s,a,o,l){C.info("REF0:"),C.info("Drawing er diagram (unified)",a);let{securityLevel:r,er:h,layout:k}=z(),f=l.db.getData(),m=Xe(a,r);f.type=l.type,f.layoutAlgorithm=$e(k),f.config.flowchart.nodeSpacing=h?.nodeSpacing||140,f.config.flowchart.rankSpacing=h?.rankSpacing||80,f.direction=l.db.getDirection();let{config:I}=f,{look:b}=I;b==="neo"?f.markers=["only_one_neo","zero_or_one_neo","one_or_more_neo","zero_or_more_neo"]:f.markers=["only_one","zero_or_one","one_or_more","zero_or_more"],f.diagramId=a,await Je(f,m),f.layoutAlgorithm==="elk"&&m.select(".edges").lower();let g=m.selectAll('[id*="-background"]');Array.from(g).length>0&&g.each(function(){let D=qe(this),x=D.attr("id").replace("-background",""),v=m.select(`#${CSS.escape(x)}`);if(!v.empty()){let O=v.attr("transform");D.attr("transform",O)}});let A=8;He.insertTitle(m,"erDiagramTitleText",h?.titleTopMargin??25,l.db.getDiagramTitle()),et(m,A,"erDiagram",h?.useMaxWidth??!0)},"draw");var st=p((s,a)=>{let o=Fe,l=o(s,"r"),r=o(s,"g"),h=o(s,"b");return Be(l,r,h,a)},"fade"),ue=new Set(["redux-color","redux-dark-color"]),ut=p(s=>{let{theme:a,look:o,bkgColorArray:l,borderColorArray:r}=s;if(!ue.has(a))return"";let h=l?.length>0,k="";for(let f=0;f<s.THEME_COLOR_LIMIT;f++)k+=` [data-look="${o}"][data-color-id="color-${f}"].node path { stroke: ${r[f]}; ${h?`fill: ${l[f]};`:""} } [data-look="${o}"][data-color-id="color-${f}"].node rect { stroke: ${r[f]}; ${h?`fill: ${l[f]};`:""} } `;return k},"genColor"),dt=p(s=>{let{look:a,theme:o,erEdgeLabelBackground:l,strokeWidth:r}=s;return` ${ut(s)} .entityBox { fill: ${s.mainBkg}; stroke: ${s.nodeBorder}; } .relationshipLabelBox { fill: ${s.tertiaryColor}; opacity: 0.7; background-color: ${s.tertiaryColor}; rect { opacity: 0.5; } } .labelBkg { background-color: ${ue.has(o)&&l?l:st(s.tertiaryColor,.5)}; } .edgeLabel { background-color: ${ue.has(o)&&l?l:s.edgeLabelBackground}; } .edgeLabel .label rect { fill: ${ue.has(o)&&l?l:s.edgeLabelBackground}; } .edgeLabel .label text { fill: ${s.textColor}; } .edgeLabel .label { fill: ${s.nodeBorder}; font-size: 14px; } .label { font-family: ${s.fontFamily}; color: ${s.nodeTextColor||s.textColor}; } .edge-pattern-dashed { stroke-dasharray: 8,8; } .node rect, .node circle, .node ellipse, .node polygon { fill: ${s.mainBkg}; stroke: ${s.nodeBorder}; stroke-width: ${a==="neo"?r:"1px"}; } .relationshipLine { stroke: ${s.lineColor}; stroke-width: ${a==="neo"?r:"1px"}; fill: none; } .marker { fill: none !important; stroke: ${s.lineColor} !important; stroke-width: 1; } [data-look=neo].labelBkg { background-color: ${st(s.tertiaryColor,.5)}; } .cluster rect { fill: ${s.clusterBkg??s.mainBkg}; stroke: ${s.clusterBorder??s.nodeBorder}; stroke-width: 1px; } .cluster text { fill: ${s.titleColor??s.textColor}; } .cluster-label text { fill: ${s.titleColor??s.textColor}; } `},"getStyles"),it=dt;var Bt={parser:tt,get db(){return new he},renderer:Oe,styles:it};export{Bt as diagram};