package.dist.chunks.mermaid.esm.min.erDiagram-SZV2UBQT.mjs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mermaid Show documentation
Show all versions of mermaid Show documentation
Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.
The newest version!
import{a as At}from"./chunk-FASC7IG4.mjs";import{a as Tt}from"./chunk-ZN7TASNU.mjs";import{m as Nt}from"./chunk-2XY5F2HY.mjs";import"./chunk-TI4EEUUG.mjs";import{Da as Rt,H as pt,Ha as Ot,M as yt,P as _t,Q as mt,R as kt,S as Et,T as gt,U as bt,V as xt,X as P,b as K,ga as $}from"./chunk-ITX3UAHE.mjs";import"./chunk-5ZJXQJOJ.mjs";import"./chunk-YPUTD6PB.mjs";import"./chunk-6BY5RJGC.mjs";import{a as n}from"./chunk-GTKDMUJJ.mjs";var nt=function(){var t=n(function(v,i,s,c){for(s=s||{},c=v.length;c--;s[v[c]]=i);return s},"o"),e=[6,8,10,20,22,24,26,27,28],r=[1,10],u=[1,11],h=[1,12],_=[1,13],p=[1,14],l=[1,15],d=[1,21],k=[1,22],E=[1,23],g=[1,24],b=[1,25],y=[6,8,10,13,15,18,19,20,22,24,26,27,28,41,42,43,44,45],R=[1,34],O=[27,28,46,47],Z=[41,42,43,44,45],F=[17,34],W=[1,54],M=[1,53],w=[17,34,36,38],N={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,entityName:11,relSpec:12,":":13,role:14,BLOCK_START:15,attributes:16,BLOCK_STOP:17,SQS:18,SQE:19,title:20,title_value:21,acc_title:22,acc_title_value:23,acc_descr:24,acc_descr_value:25,acc_descr_multiline_value:26,ALPHANUM:27,ENTITY_NAME:28,attribute:29,attributeType:30,attributeName:31,attributeKeyTypeList:32,attributeComment:33,ATTRIBUTE_WORD:34,attributeKeyType:35,COMMA:36,ATTRIBUTE_KEY:37,COMMENT:38,cardinality:39,relType:40,ZERO_OR_ONE:41,ZERO_OR_MORE:42,ONE_OR_MORE:43,ONLY_ONE:44,MD_PARENT:45,NON_IDENTIFYING:46,IDENTIFYING:47,WORD:48,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",8:"SPACE",10:"NEWLINE",13:":",15:"BLOCK_START",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:"ALPHANUM",28:"ENTITY_NAME",34:"ATTRIBUTE_WORD",36:"COMMA",37:"ATTRIBUTE_KEY",38:"COMMENT",41:"ZERO_OR_ONE",42:"ZERO_OR_MORE",43:"ONE_OR_MORE",44:"ONLY_ONE",45:"MD_PARENT",46:"NON_IDENTIFYING",47:"IDENTIFYING",48:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,5],[9,4],[9,3],[9,1],[9,7],[9,6],[9,4],[9,2],[9,2],[9,2],[9,1],[11,1],[11,1],[16,1],[16,2],[29,2],[29,3],[29,3],[29,4],[30,1],[31,1],[32,1],[32,3],[35,1],[33,1],[12,3],[39,1],[39,1],[39,1],[39,1],[39,1],[40,1],[40,1],[14,1],[14,1],[14,1]],performAction:n(function(i,s,c,f,m,a,X){var o=a.length-1;switch(m){case 1:break;case 2:this.$=[];break;case 3:a[o-1].push(a[o]),this.$=a[o-1];break;case 4:case 5:this.$=a[o];break;case 6:case 7:this.$=[];break;case 8:f.addEntity(a[o-4]),f.addEntity(a[o-2]),f.addRelationship(a[o-4],a[o],a[o-2],a[o-3]);break;case 9:f.addEntity(a[o-3]),f.addAttributes(a[o-3],a[o-1]);break;case 10:f.addEntity(a[o-2]);break;case 11:f.addEntity(a[o]);break;case 12:f.addEntity(a[o-6],a[o-4]),f.addAttributes(a[o-6],a[o-1]);break;case 13:f.addEntity(a[o-5],a[o-3]);break;case 14:f.addEntity(a[o-3],a[o-1]);break;case 15:case 16:this.$=a[o].trim(),f.setAccTitle(this.$);break;case 17:case 18:this.$=a[o].trim(),f.setAccDescription(this.$);break;case 19:case 43:this.$=a[o];break;case 20:case 41:case 42:this.$=a[o].replace(/"/g,"");break;case 21:case 29:this.$=[a[o]];break;case 22:a[o].push(a[o-1]),this.$=a[o];break;case 23:this.$={attributeType:a[o-1],attributeName:a[o]};break;case 24:this.$={attributeType:a[o-2],attributeName:a[o-1],attributeKeyTypeList:a[o]};break;case 25:this.$={attributeType:a[o-2],attributeName:a[o-1],attributeComment:a[o]};break;case 26:this.$={attributeType:a[o-3],attributeName:a[o-2],attributeKeyTypeList:a[o-1],attributeComment:a[o]};break;case 27:case 28:case 31:this.$=a[o];break;case 30:a[o-2].push(a[o]),this.$=a[o-2];break;case 32:this.$=a[o].replace(/"/g,"");break;case 33:this.$={cardA:a[o],relType:a[o-1],cardB:a[o-2]};break;case 34:this.$=f.Cardinality.ZERO_OR_ONE;break;case 35:this.$=f.Cardinality.ZERO_OR_MORE;break;case 36:this.$=f.Cardinality.ONE_OR_MORE;break;case 37:this.$=f.Cardinality.ONLY_ONE;break;case 38:this.$=f.Cardinality.MD_PARENT;break;case 39:this.$=f.Identification.NON_IDENTIFYING;break;case 40:this.$=f.Identification.IDENTIFYING;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:9,20:r,22:u,24:h,26:_,27:p,28:l},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:16,11:9,20:r,22:u,24:h,26:_,27:p,28:l},t(e,[2,5]),t(e,[2,6]),t(e,[2,11],{12:17,39:20,15:[1,18],18:[1,19],41:d,42:k,43:E,44:g,45:b}),{21:[1,26]},{23:[1,27]},{25:[1,28]},t(e,[2,18]),t(y,[2,19]),t(y,[2,20]),t(e,[2,4]),{11:29,27:p,28:l},{16:30,17:[1,31],29:32,30:33,34:R},{11:35,27:p,28:l},{40:36,46:[1,37],47:[1,38]},t(O,[2,34]),t(O,[2,35]),t(O,[2,36]),t(O,[2,37]),t(O,[2,38]),t(e,[2,15]),t(e,[2,16]),t(e,[2,17]),{13:[1,39]},{17:[1,40]},t(e,[2,10]),{16:41,17:[2,21],29:32,30:33,34:R},{31:42,34:[1,43]},{34:[2,27]},{19:[1,44]},{39:45,41:d,42:k,43:E,44:g,45:b},t(Z,[2,39]),t(Z,[2,40]),{14:46,27:[1,49],28:[1,48],48:[1,47]},t(e,[2,9]),{17:[2,22]},t(F,[2,23],{32:50,33:51,35:52,37:W,38:M}),t([17,34,37,38],[2,28]),t(e,[2,14],{15:[1,55]}),t([27,28],[2,33]),t(e,[2,8]),t(e,[2,41]),t(e,[2,42]),t(e,[2,43]),t(F,[2,24],{33:56,36:[1,57],38:M}),t(F,[2,25]),t(w,[2,29]),t(F,[2,32]),t(w,[2,31]),{16:58,17:[1,59],29:32,30:33,34:R},t(F,[2,26]),{35:60,37:W},{17:[1,61]},t(e,[2,13]),t(w,[2,30]),t(e,[2,12])],defaultActions:{34:[2,27],41:[2,22]},parseError:n(function(i,s){if(s.recoverable)this.trace(i);else{var c=new Error(i);throw c.hash=s,c}},"parseError"),parse:n(function(i){var s=this,c=[0],f=[],m=[null],a=[],X=this.table,o="",q=0,ht=0,dt=0,Wt=2,ft=1,Ut=a.slice.call(arguments,1),A=Object.create(this.lexer),H={yy:{}};for(var tt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,tt)&&(H.yy[tt]=this.yy[tt]);A.setInput(i,H.yy),H.yy.lexer=A,H.yy.parser=this,typeof A.yylloc>"u"&&(A.yylloc={});var et=A.yylloc;a.push(et);var Ht=A.options&&A.options.ranges;typeof H.yy.parseError=="function"?this.parseError=H.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ke(D){c.length=c.length-2*D,m.length=m.length-D,a.length=a.length-D}n(ke,"popStack");function zt(){var D;return D=f.pop()||A.lex()||ft,typeof D!="number"&&(D instanceof Array&&(f=D,D=f.pop()),D=s.symbols_[D]||D),D}n(zt,"lex");for(var I,rt,z,L,Ee,at,G={},J,U,ut,j;;){if(z=c[c.length-1],this.defaultActions[z]?L=this.defaultActions[z]:((I===null||typeof I>"u")&&(I=zt()),L=X[z]&&X[z][I]),typeof L>"u"||!L.length||!L[0]){var it="";j=[];for(J in X[z])this.terminals_[J]&&J>Wt&&j.push("'"+this.terminals_[J]+"'");A.showPosition?it="Parse error on line "+(q+1)+`:
`+A.showPosition()+`
Expecting `+j.join(", ")+", got '"+(this.terminals_[I]||I)+"'":it="Parse error on line "+(q+1)+": Unexpected "+(I==ft?"end of input":"'"+(this.terminals_[I]||I)+"'"),this.parseError(it,{text:A.match,token:this.terminals_[I]||I,line:A.yylineno,loc:et,expected:j})}if(L[0]instanceof Array&&L.length>1)throw new Error("Parse Error: multiple actions possible at state: "+z+", token: "+I);switch(L[0]){case 1:c.push(I),m.push(A.yytext),a.push(A.yylloc),c.push(L[1]),I=null,rt?(I=rt,rt=null):(ht=A.yyleng,o=A.yytext,q=A.yylineno,et=A.yylloc,dt>0&&dt--);break;case 2:if(U=this.productions_[L[1]][1],G.$=m[m.length-U],G._$={first_line:a[a.length-(U||1)].first_line,last_line:a[a.length-1].last_line,first_column:a[a.length-(U||1)].first_column,last_column:a[a.length-1].last_column},Ht&&(G._$.range=[a[a.length-(U||1)].range[0],a[a.length-1].range[1]]),at=this.performAction.apply(G,[o,ht,q,H.yy,L[1],m,a].concat(Ut)),typeof at<"u")return at;U&&(c=c.slice(0,-1*U*2),m=m.slice(0,-1*U),a=a.slice(0,-1*U)),c.push(this.productions_[L[1]][0]),m.push(G.$),a.push(G._$),ut=X[c[c.length-2]][c[c.length-1]],c.push(ut);break;case 3:return!0}}return!0},"parse")},T=function(){var v={EOF:1,parseError:n(function(s,c){if(this.yy.parser)this.yy.parser.parseError(s,c);else throw new Error(s)},"parseError"),setInput:n(function(i,s){return this.yy=s||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:n(function(){var i=this._input[0];this.yytext+=i,this.yyleng++,this.offset++,this.match+=i,this.matched+=i;var s=i.match(/(?:\r\n?|\n).*/g);return s?(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:n(function(i){var s=i.length,c=i.split(/(?:\r\n?|\n)/g);this._input=i+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var f=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),c.length-1&&(this.yylineno-=c.length-1);var m=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:c?(c.length===f.length?this.yylloc.first_column:0)+f[f.length-c.length].length-c[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[m[0],m[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(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:n(function(i){this.unput(this.match.slice(i))},"less"),pastInput:n(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:n(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:n(function(){var i=this.pastInput(),s=new Array(i.length+1).join("-");return i+this.upcomingInput()+`
`+s+"^"},"showPosition"),test_match:n(function(i,s){var c,f,m;if(this.options.backtrack_lexer&&(m={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&&(m.yylloc.range=this.yylloc.range.slice(0))),f=i[0].match(/(?:\r\n?|\n).*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-f[f.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],c=this.performAction.call(this,this.yy,this,s,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var a in m)this[a]=m[a];return!1}return!1},"test_match"),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var i,s,c,f;this._more||(this.yytext="",this.match="");for(var m=this._currentRules(),a=0;as[0].length)){if(s=c,f=a,this.options.backtrack_lexer){if(i=this.test_match(c,m[a]),i!==!1)return i;if(this._backtrack){s=!1;continue}else return!1}else if(!this.options.flex)break}return s?(i=this.test_match(s,m[f]),i!==!1?i:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:n(function(){var s=this.next();return s||this.lex()},"lex"),begin:n(function(s){this.conditionStack.push(s)},"begin"),popState:n(function(){var s=this.conditionStack.length-1;return s>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:n(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:n(function(s){return s=this.conditionStack.length-1-Math.abs(s||0),s>=0?this.conditionStack[s]:"INITIAL"},"topState"),pushState:n(function(s){this.begin(s)},"pushState"),stateStackSize:n(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:n(function(s,c,f,m){var a=m;switch(f){case 0:return this.begin("acc_title"),22;break;case 1:return this.popState(),"acc_title_value";break;case 2:return this.begin("acc_descr"),24;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 10;case 8:break;case 9:return 8;case 10:return 28;case 11:return 48;case 12:return 4;case 13:return this.begin("block"),15;break;case 14:return 36;case 15:break;case 16:return 37;case 17:return 34;case 18:return 34;case 19:return 38;case 20:break;case 21:return this.popState(),17;break;case 22:return c.yytext[0];case 23:return 18;case 24:return 19;case 25:return 41;case 26:return 43;case 27:return 43;case 28:return 43;case 29:return 41;case 30:return 41;case 31:return 42;case 32:return 42;case 33:return 42;case 34:return 42;case 35:return 42;case 36:return 43;case 37:return 42;case 38:return 43;case 39:return 44;case 40:return 44;case 41:return 44;case 42:return 44;case 43:return 41;case 44:return 42;case 45:return 43;case 46:return 45;case 47:return 46;case 48:return 47;case 49:return 47;case 50:return 46;case 51:return 46;case 52:return 46;case 53:return 27;case 54:return c.yytext[0];case 55:return 6}},"anonymous"),rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:[\s]+)/i,/^(?:"[^"%\r\n\v\b\\]+")/i,/^(?:"[^"]*")/i,/^(?:erDiagram\b)/i,/^(?:\{)/i,/^(?:,)/i,/^(?:\s+)/i,/^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i,/^(?:(.*?)[~](.*?)*[~])/i,/^(?:[\*A-Za-z_][A-Za-z0-9\-_\[\]\(\)]*)/i,/^(?:"[^"]*")/i,/^(?:[\n]+)/i,/^(?:\})/i,/^(?:.)/i,/^(?:\[)/i,/^(?:\])/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,/^(?:1\b)/i,/^(?:\|\|)/i,/^(?:o\|)/i,/^(?:o\{)/i,/^(?:\|\{)/i,/^(?:\s*u\b)/i,/^(?:\.\.)/i,/^(?:--)/i,/^(?:to\b)/i,/^(?:optionally to\b)/i,/^(?:\.-)/i,/^(?:-\.)/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:.)/i,/^(?:$)/i],conditions:{acc_descr_multiline:{rules:[5,6],inclusive:!1},acc_descr:{rules:[3],inclusive:!1},acc_title:{rules:[1],inclusive:!1},block:{rules:[14,15,16,17,18,19,20,21,22],inclusive:!1},INITIAL:{rules:[0,2,4,7,8,9,10,11,12,13,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55],inclusive:!0}}};return v}();N.lexer=T;function C(){this.yy={}}return n(C,"Parser"),C.prototype=N,N.Parser=C,new C}();nt.parser=nt;var Mt=nt;var V=new Map,st=[],Kt={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"},Vt={NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"},St=n(function(t,e=void 0){return V.has(t)?!V.get(t).alias&&e&&(V.get(t).alias=e,K.info(`Add alias '${e}' to entity '${t}'`)):(V.set(t,{attributes:[],alias:e}),K.info("Added new entity :",t)),V.get(t)},"addEntity"),Gt=n(()=>V,"getEntities"),Xt=n(function(t,e){let r=St(t),u;for(u=e.length-1;u>=0;u--)r.attributes.push(e[u]),K.debug("Added attribute ",e[u].attributeName)},"addAttributes"),Qt=n(function(t,e,r,u){let h={entityA:t,roleA:e,entityB:r,relSpec:u};st.push(h),K.debug("Added new relationship :",h)},"addRelationship"),qt=n(()=>st,"getRelationships"),Jt=n(function(){V=new Map,st=[],_t()},"clear"),wt={Cardinality:Kt,Identification:Vt,getConfig:n(()=>P().er,"getConfig"),addEntity:St,addAttributes:Xt,getEntities:Gt,addRelationship:Qt,getRelationships:qt,clear:Jt,setAccTitle:mt,getAccTitle:kt,setAccDescription:Et,getAccDescription:gt,setDiagramTitle:bt,getDiagramTitle:xt};var Y={ONLY_ONE_START:"ONLY_ONE_START",ONLY_ONE_END:"ONLY_ONE_END",ZERO_OR_ONE_START:"ZERO_OR_ONE_START",ZERO_OR_ONE_END:"ZERO_OR_ONE_END",ONE_OR_MORE_START:"ONE_OR_MORE_START",ONE_OR_MORE_END:"ONE_OR_MORE_END",ZERO_OR_MORE_START:"ZERO_OR_MORE_START",ZERO_OR_MORE_END:"ZERO_OR_MORE_END",MD_PARENT_END:"MD_PARENT_END",MD_PARENT_START:"MD_PARENT_START"},jt=n(function(t,e){let r;t.append("defs").append("marker").attr("id",Y.MD_PARENT_START).attr("refX",0).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",Y.MD_PARENT_END).attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),t.append("defs").append("marker").attr("id",Y.ONLY_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M9,0 L9,18 M15,0 L15,18"),t.append("defs").append("marker").attr("id",Y.ONLY_ONE_END).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M3,0 L3,18 M9,0 L9,18"),r=t.append("defs").append("marker").attr("id",Y.ZERO_OR_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto"),r.append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),r.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M9,0 L9,18"),r=t.append("defs").append("marker").attr("id",Y.ZERO_OR_ONE_END).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto"),r.append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),r.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M21,0 L21,18"),t.append("defs").append("marker").attr("id",Y.ONE_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),t.append("defs").append("marker").attr("id",Y.ONE_OR_MORE_END).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"),r=t.append("defs").append("marker").attr("id",Y.ZERO_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto"),r.append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),r.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18"),r=t.append("defs").append("marker").attr("id",Y.ZERO_OR_MORE_END).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto"),r.append("circle").attr("stroke",e.stroke).attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),r.append("path").attr("stroke",e.stroke).attr("fill","none").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"insertMarkers"),B={ERMarkers:Y,insertMarkers:jt};var It=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function $t(t){return typeof t=="string"&&It.test(t)}n($t,"validate");var vt=$t;var S=[];for(let t=0;t<256;++t)S.push((t+256).toString(16).slice(1));function Dt(t,e=0){return S[t[e+0]]+S[t[e+1]]+S[t[e+2]]+S[t[e+3]]+"-"+S[t[e+4]]+S[t[e+5]]+"-"+S[t[e+6]]+S[t[e+7]]+"-"+S[t[e+8]]+S[t[e+9]]+"-"+S[t[e+10]]+S[t[e+11]]+S[t[e+12]]+S[t[e+13]]+S[t[e+14]]+S[t[e+15]]}n(Dt,"unsafeStringify");function te(t){if(!vt(t))throw TypeError("Invalid UUID");let e,r=new Uint8Array(16);return r[0]=(e=parseInt(t.slice(0,8),16))>>>24,r[1]=e>>>16&255,r[2]=e>>>8&255,r[3]=e&255,r[4]=(e=parseInt(t.slice(9,13),16))>>>8,r[5]=e&255,r[6]=(e=parseInt(t.slice(14,18),16))>>>8,r[7]=e&255,r[8]=(e=parseInt(t.slice(19,23),16))>>>8,r[9]=e&255,r[10]=(e=parseInt(t.slice(24,36),16))/1099511627776&255,r[11]=e/4294967296&255,r[12]=e>>>24&255,r[13]=e>>>16&255,r[14]=e>>>8&255,r[15]=e&255,r}n(te,"parse");var Lt=te;function ee(t){t=unescape(encodeURIComponent(t));let e=[];for(let r=0;r>>32-e}n(lt,"ROTL");function ne(t){let e=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){let p=unescape(encodeURIComponent(t));t=[];for(let l=0;l>>0;b=g,g=E,E=lt(k,30)>>>0,k=d,d=O}r[0]=r[0]+d>>>0,r[1]=r[1]+k>>>0,r[2]=r[2]+E>>>0,r[3]=r[3]+g>>>0,r[4]=r[4]+b>>>0}return[r[0]>>24&255,r[0]>>16&255,r[0]>>8&255,r[0]&255,r[1]>>24&255,r[1]>>16&255,r[1]>>8&255,r[1]&255,r[2]>>24&255,r[2]>>16&255,r[2]>>8&255,r[2]&255,r[3]>>24&255,r[3]>>16&255,r[3]>>8&255,r[3]&255,r[4]>>24&255,r[4]>>16&255,r[4]>>8&255,r[4]&255]}n(ne,"sha1");var Bt=ne;var se=ot("v5",80,Bt),ct=se;var oe=/[^\dA-Za-z](\W)*/g,x={},Q=new Map,le=n(function(t){let e=Object.keys(t);for(let r of e)x[r]=t[r]},"setConf"),ce=n((t,e,r)=>{let u=x.entityPadding/3,h=x.entityPadding/3,_=x.fontSize*.85,p=e.node().getBBox(),l=[],d=!1,k=!1,E=0,g=0,b=0,y=0,R=p.height+u*2,O=1;r.forEach(M=>{M.attributeKeyTypeList!==void 0&&M.attributeKeyTypeList.length>0&&(d=!0),M.attributeComment!==void 0&&(k=!0)}),r.forEach(M=>{let w=`${e.node().id}-attr-${O}`,N=0,T=pt(M.attributeType),C=t.append("text").classed("er entityLabel",!0).attr("id",`${w}-type`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",P().fontFamily).style("font-size",_+"px").text(T),v=t.append("text").classed("er entityLabel",!0).attr("id",`${w}-name`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",P().fontFamily).style("font-size",_+"px").text(M.attributeName),i={};i.tn=C,i.nn=v;let s=C.node().getBBox(),c=v.node().getBBox();if(E=Math.max(E,s.width),g=Math.max(g,c.width),N=Math.max(s.height,c.height),d){let f=M.attributeKeyTypeList!==void 0?M.attributeKeyTypeList.join(","):"",m=t.append("text").classed("er entityLabel",!0).attr("id",`${w}-key`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",P().fontFamily).style("font-size",_+"px").text(f);i.kn=m;let a=m.node().getBBox();b=Math.max(b,a.width),N=Math.max(N,a.height)}if(k){let f=t.append("text").classed("er entityLabel",!0).attr("id",`${w}-comment`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",P().fontFamily).style("font-size",_+"px").text(M.attributeComment||"");i.cn=f;let m=f.node().getBBox();y=Math.max(y,m.width),N=Math.max(N,m.height)}i.height=N,l.push(i),R+=N+u*2,O+=1});let Z=4;d&&(Z+=2),k&&(Z+=2);let F=E+g+b+y,W={width:Math.max(x.minEntityWidth,Math.max(p.width+x.entityPadding*2,F+h*Z)),height:r.length>0?R:Math.max(x.minEntityHeight,p.height+x.entityPadding*2)};if(r.length>0){let M=Math.max(0,(W.width-F-h*Z)/(Z/2));e.attr("transform","translate("+W.width/2+","+(u+p.height/2)+")");let w=p.height+u*2,N="attributeBoxOdd";l.forEach(T=>{let C=w+u+T.height/2;T.tn.attr("transform","translate("+h+","+C+")");let v=t.insert("rect","#"+T.tn.node().id).classed(`er ${N}`,!0).attr("x",0).attr("y",w).attr("width",E+h*2+M).attr("height",T.height+u*2),i=parseFloat(v.attr("x"))+parseFloat(v.attr("width"));T.nn.attr("transform","translate("+(i+h)+","+C+")");let s=t.insert("rect","#"+T.nn.node().id).classed(`er ${N}`,!0).attr("x",i).attr("y",w).attr("width",g+h*2+M).attr("height",T.height+u*2),c=parseFloat(s.attr("x"))+parseFloat(s.attr("width"));if(d){T.kn.attr("transform","translate("+(c+h)+","+C+")");let f=t.insert("rect","#"+T.kn.node().id).classed(`er ${N}`,!0).attr("x",c).attr("y",w).attr("width",b+h*2+M).attr("height",T.height+u*2);c=parseFloat(f.attr("x"))+parseFloat(f.attr("width"))}k&&(T.cn.attr("transform","translate("+(c+h)+","+C+")"),t.insert("rect","#"+T.cn.node().id).classed(`er ${N}`,"true").attr("x",c).attr("y",w).attr("width",y+h*2+M).attr("height",T.height+u*2)),w+=T.height+u*2,N=N==="attributeBoxOdd"?"attributeBoxEven":"attributeBoxOdd"})}else W.height=Math.max(x.minEntityHeight,R),e.attr("transform","translate("+W.width/2+","+W.height/2+")");return W},"drawAttributes"),he=n(function(t,e,r){let u=[...e.keys()],h;return u.forEach(function(_){let p=_e(_,"entity");Q.set(_,p);let l=t.append("g").attr("id",p);h=h===void 0?p:h;let d="text-"+p,k=l.append("text").classed("er entityLabel",!0).attr("id",d).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","middle").style("font-family",P().fontFamily).style("font-size",x.fontSize+"px").text(e.get(_).alias??_),{width:E,height:g}=ce(l,k,e.get(_).attributes),y=l.insert("rect","#"+d).classed("er entityBox",!0).attr("x",0).attr("y",0).attr("width",E).attr("height",g).node().getBBox();r.setNode(p,{width:y.width,height:y.height,shape:"rect",id:p})}),h},"drawEntities"),de=n(function(t,e){e.nodes().forEach(function(r){r!==void 0&&e.node(r)!==void 0&&t.select("#"+r).attr("transform","translate("+(e.node(r).x-e.node(r).width/2)+","+(e.node(r).y-e.node(r).height/2)+" )")})},"adjustEntities"),Yt=n(function(t){return(t.entityA+t.roleA+t.entityB).replace(/\s/g,"")},"getEdgeName"),fe=n(function(t,e){return t.forEach(function(r){e.setEdge(Q.get(r.entityA),Q.get(r.entityB),{relationship:r},Yt(r))}),t},"addRelationships"),Ct=0,ue=n(function(t,e,r,u,h){Ct++;let _=r.edge(Q.get(e.entityA),Q.get(e.entityB),Yt(e)),p=Rt().x(function(O){return O.x}).y(function(O){return O.y}).curve(Ot),l=t.insert("path","#"+u).classed("er relationshipLine",!0).attr("d",p(_.points)).style("stroke",x.stroke).style("fill","none");e.relSpec.relType===h.db.Identification.NON_IDENTIFYING&&l.attr("stroke-dasharray","8,8");let d="";switch(x.arrowMarkerAbsolute&&(d=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,d=d.replace(/\(/g,"\\("),d=d.replace(/\)/g,"\\)")),e.relSpec.cardA){case h.db.Cardinality.ZERO_OR_ONE:l.attr("marker-end","url("+d+"#"+B.ERMarkers.ZERO_OR_ONE_END+")");break;case h.db.Cardinality.ZERO_OR_MORE:l.attr("marker-end","url("+d+"#"+B.ERMarkers.ZERO_OR_MORE_END+")");break;case h.db.Cardinality.ONE_OR_MORE:l.attr("marker-end","url("+d+"#"+B.ERMarkers.ONE_OR_MORE_END+")");break;case h.db.Cardinality.ONLY_ONE:l.attr("marker-end","url("+d+"#"+B.ERMarkers.ONLY_ONE_END+")");break;case h.db.Cardinality.MD_PARENT:l.attr("marker-end","url("+d+"#"+B.ERMarkers.MD_PARENT_END+")");break}switch(e.relSpec.cardB){case h.db.Cardinality.ZERO_OR_ONE:l.attr("marker-start","url("+d+"#"+B.ERMarkers.ZERO_OR_ONE_START+")");break;case h.db.Cardinality.ZERO_OR_MORE:l.attr("marker-start","url("+d+"#"+B.ERMarkers.ZERO_OR_MORE_START+")");break;case h.db.Cardinality.ONE_OR_MORE:l.attr("marker-start","url("+d+"#"+B.ERMarkers.ONE_OR_MORE_START+")");break;case h.db.Cardinality.ONLY_ONE:l.attr("marker-start","url("+d+"#"+B.ERMarkers.ONLY_ONE_START+")");break;case h.db.Cardinality.MD_PARENT:l.attr("marker-start","url("+d+"#"+B.ERMarkers.MD_PARENT_START+")");break}let k=l.node().getTotalLength(),E=l.node().getPointAtLength(k*.5),g="rel"+Ct,b=e.roleA.split(/
/g),y=t.append("text").classed("er relationshipLabel",!0).attr("id",g).attr("x",E.x).attr("y",E.y).style("text-anchor","middle").style("dominant-baseline","middle").style("font-family",P().fontFamily).style("font-size",x.fontSize+"px");if(b.length==1)y.text(e.roleA);else{let O=-(b.length-1)*.5;b.forEach((Z,F)=>{y.append("tspan").attr("x",E.x).attr("dy",`${F===0?O:1}em`).text(Z)})}let R=y.node().getBBox();t.insert("rect","#"+g).classed("er relationshipLabelBox",!0).attr("x",E.x-R.width/2).attr("y",E.y-R.height/2).attr("width",R.width).attr("height",R.height)},"drawRelationshipFromLayout"),pe=n(function(t,e,r,u){x=P().er,K.info("Drawing ER diagram");let h=P().securityLevel,_;h==="sandbox"&&(_=$("#i"+e));let l=(h==="sandbox"?$(_.nodes()[0].contentDocument.body):$("body")).select(`[id='${e}']`);B.insertMarkers(l,x);let d;d=new Tt({multigraph:!0,directed:!0,compound:!1}).setGraph({rankdir:x.layoutDirection,marginx:20,marginy:20,nodesep:100,edgesep:100,ranksep:100}).setDefaultEdgeLabel(function(){return{}});let k=he(l,u.db.getEntities(),d),E=fe(u.db.getRelationships(),d);At(d),de(l,d),E.forEach(function(O){ue(l,O,d,k,u)});let g=x.diagramPadding;Nt.insertTitle(l,"entityTitleText",x.titleTopMargin,u.db.getDiagramTitle());let b=l.node().getBBox(),y=b.width+g*2,R=b.height+g*2;yt(l,R,y,x.useMaxWidth),l.attr("viewBox",`${b.x-g} ${b.y-g} ${y} ${R}`)},"draw"),ye="28e9f9db-3c8d-5aa5-9faf-44286ae5937c";function _e(t="",e=""){let r=t.replace(oe,"");return`${Pt(e)}${Pt(r)}${ct(t,ye)}`}n(_e,"generateId");function Pt(t=""){return t.length>0?`${t}-`:""}n(Pt,"strWithHyphen");var Zt={setConf:le,draw:pe};var me=n(t=>`
.entityBox {
fill: ${t.mainBkg};
stroke: ${t.nodeBorder};
}
.attributeBoxOdd {
fill: ${t.attributeBackgroundColorOdd};
stroke: ${t.nodeBorder};
}
.attributeBoxEven {
fill: ${t.attributeBackgroundColorEven};
stroke: ${t.nodeBorder};
}
.relationshipLabelBox {
fill: ${t.tertiaryColor};
opacity: 0.7;
background-color: ${t.tertiaryColor};
rect {
opacity: 0.5;
}
}
.relationshipLine {
stroke: ${t.lineColor};
}
.entityTitleText {
text-anchor: middle;
font-size: 18px;
fill: ${t.textColor};
}
#MD_PARENT_START {
fill: #f5f5f5 !important;
stroke: ${t.lineColor} !important;
stroke-width: 1;
}
#MD_PARENT_END {
fill: #f5f5f5 !important;
stroke: ${t.lineColor} !important;
stroke-width: 1;
}
`,"getStyles"),Ft=me;var ur={parser:Mt,db:wt,renderer:Zt,styles:Ft};export{ur as diagram};