livebook/static/assets/erDiagram-f6946109-VO6THZHE.js
2023-07-19 19:58:40 +00:00

52 lines
31 KiB
JavaScript

import{a as Et,b as gt}from"./chunk-QFWTWYMO.js";import"./chunk-2MTWH372.js";import{Ka as Mt,Na as Dt,b as Ht,c as zt,da as j,ga as xt,h as rt,na as Y,oa as kt,qa as Rt,ra as Ot,sa as bt,ta as Nt,ua as Tt,va as vt,w as _t,wa as At,y as mt,z as Kt}from"./chunk-KU2GO2AH.js";import{h as ot}from"./chunk-2YVZDWG7.js";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 Gt(t){return typeof t=="string"&&It.test(t)}var wt=Gt;var T=[];for(let t=0;t<256;++t)T.push((t+256).toString(16).slice(1));function St(t,r=0){return(T[t[r+0]]+T[t[r+1]]+T[t[r+2]]+T[t[r+3]]+"-"+T[t[r+4]]+T[t[r+5]]+"-"+T[t[r+6]]+T[t[r+7]]+"-"+T[t[r+8]]+T[t[r+9]]+"-"+T[t[r+10]]+T[t[r+11]]+T[t[r+12]]+T[t[r+13]]+T[t[r+14]]+T[t[r+15]]).toLowerCase()}function Xt(t){if(!wt(t))throw TypeError("Invalid UUID");let r,e=new Uint8Array(16);return e[0]=(r=parseInt(t.slice(0,8),16))>>>24,e[1]=r>>>16&255,e[2]=r>>>8&255,e[3]=r&255,e[4]=(r=parseInt(t.slice(9,13),16))>>>8,e[5]=r&255,e[6]=(r=parseInt(t.slice(14,18),16))>>>8,e[7]=r&255,e[8]=(r=parseInt(t.slice(19,23),16))>>>8,e[9]=r&255,e[10]=(r=parseInt(t.slice(24,36),16))/1099511627776&255,e[11]=r/4294967296&255,e[12]=r>>>24&255,e[13]=r>>>16&255,e[14]=r>>>8&255,e[15]=r&255,e}var Lt=Xt;function Qt(t){t=unescape(encodeURIComponent(t));let r=[];for(let e=0;e<t.length;++e)r.push(t.charCodeAt(e));return r}var jt="6ba7b810-9dad-11d1-80b4-00c04fd430c8",qt="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function ct(t,r,e){function n(s,y,u,o){var c;if(typeof s=="string"&&(s=Qt(s)),typeof y=="string"&&(y=Lt(y)),((c=y)===null||c===void 0?void 0:c.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let _=new Uint8Array(16+s.length);if(_.set(y),_.set(s,y.length),_=e(_),_[6]=_[6]&15|r,_[8]=_[8]&63|128,u){o=o||0;for(let m=0;m<16;++m)u[o+m]=_[m];return u}return St(_)}try{n.name=t}catch(s){}return n.DNS=jt,n.URL=qt,n}function Jt(t,r,e,n){switch(t){case 0:return r&e^~r&n;case 1:return r^e^n;case 2:return r&e^r&n^e&n;case 3:return r^e^n}}function lt(t,r){return t<<r|t>>>32-r}function $t(t){let r=[1518500249,1859775393,2400959708,3395469782],e=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof t=="string"){let u=unescape(encodeURIComponent(t));t=[];for(let o=0;o<u.length;++o)t.push(u.charCodeAt(o))}else Array.isArray(t)||(t=Array.prototype.slice.call(t));t.push(128);let n=t.length/4+2,s=Math.ceil(n/16),y=new Array(s);for(let u=0;u<s;++u){let o=new Uint32Array(16);for(let c=0;c<16;++c)o[c]=t[u*64+c*4]<<24|t[u*64+c*4+1]<<16|t[u*64+c*4+2]<<8|t[u*64+c*4+3];y[u]=o}y[s-1][14]=(t.length-1)*8/Math.pow(2,32),y[s-1][14]=Math.floor(y[s-1][14]),y[s-1][15]=(t.length-1)*8&4294967295;for(let u=0;u<s;++u){let o=new Uint32Array(80);for(let p=0;p<16;++p)o[p]=y[u][p];for(let p=16;p<80;++p)o[p]=lt(o[p-3]^o[p-8]^o[p-14]^o[p-16],1);let c=e[0],_=e[1],m=e[2],g=e[3],O=e[4];for(let p=0;p<80;++p){let v=Math.floor(p/20),Z=lt(c,5)+Jt(v,_,m,g)+O+r[v]+o[p]>>>0;O=g,g=m,m=lt(_,30)>>>0,_=c,c=Z}e[0]=e[0]+c>>>0,e[1]=e[1]+_>>>0,e[2]=e[2]+m>>>0,e[3]=e[3]+g>>>0,e[4]=e[4]+O>>>0}return[e[0]>>24&255,e[0]>>16&255,e[0]>>8&255,e[0]&255,e[1]>>24&255,e[1]>>16&255,e[1]>>8&255,e[1]&255,e[2]>>24&255,e[2]>>16&255,e[2]>>8&255,e[2]&255,e[3]>>24&255,e[3]>>16&255,e[3]>>8&255,e[3]&255,e[4]>>24&255,e[4]>>16&255,e[4]>>8&255,e[4]&255]}var Bt=$t;var te=ct("v5",80,Bt),ht=te;var Ke=ot(Ht(),1),Ge=ot(zt(),1),Xe=ot(Kt(),1);var dt=function(){var t=function(A,a,l,d){for(l=l||{},d=A.length;d--;l[A[d]]=a);return l},r=[1,2],e=[1,5],n=[6,9,11,23,25,27,29,30,31,52],s=[1,17],y=[1,18],u=[1,19],o=[1,20],c=[1,21],_=[1,22],m=[1,25],g=[1,30],O=[1,31],p=[1,32],v=[1,33],Z=[1,34],V=[6,9,11,15,20,23,25,27,29,30,31,44,45,46,47,48,52],X=[1,46],w=[30,31,49,50],N=[4,6,9,11,23,25,27,29,30,31,52],M=[44,45,46,47,48],x=[22,37],k=[1,66],P=[1,65],F=[22,37,39,41],I={trace:function(){},yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,directive:7,line:8,SPACE:9,statement:10,NEWLINE:11,openDirective:12,typeDirective:13,closeDirective:14,":":15,argDirective:16,entityName:17,relSpec:18,role:19,BLOCK_START:20,attributes:21,BLOCK_STOP:22,title:23,title_value:24,acc_title:25,acc_title_value:26,acc_descr:27,acc_descr_value:28,acc_descr_multiline_value:29,ALPHANUM:30,ENTITY_NAME:31,attribute:32,attributeType:33,attributeName:34,attributeKeyTypeList:35,attributeComment:36,ATTRIBUTE_WORD:37,attributeKeyType:38,COMMA:39,ATTRIBUTE_KEY:40,COMMENT:41,cardinality:42,relType:43,ZERO_OR_ONE:44,ZERO_OR_MORE:45,ONE_OR_MORE:46,ONLY_ONE:47,MD_PARENT:48,NON_IDENTIFYING:49,IDENTIFYING:50,WORD:51,open_directive:52,type_directive:53,arg_directive:54,close_directive:55,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",9:"SPACE",11:"NEWLINE",15:":",20:"BLOCK_START",22:"BLOCK_STOP",23:"title",24:"title_value",25:"acc_title",26:"acc_title_value",27:"acc_descr",28:"acc_descr_value",29:"acc_descr_multiline_value",30:"ALPHANUM",31:"ENTITY_NAME",37:"ATTRIBUTE_WORD",39:"COMMA",40:"ATTRIBUTE_KEY",41:"COMMENT",44:"ZERO_OR_ONE",45:"ZERO_OR_MORE",46:"ONE_OR_MORE",47:"ONLY_ONE",48:"MD_PARENT",49:"NON_IDENTIFYING",50:"IDENTIFYING",51:"WORD",52:"open_directive",53:"type_directive",54:"arg_directive",55:"close_directive"},productions_:[0,[3,3],[3,2],[5,0],[5,2],[8,2],[8,1],[8,1],[8,1],[7,4],[7,6],[10,1],[10,5],[10,4],[10,3],[10,1],[10,2],[10,2],[10,2],[10,1],[17,1],[17,1],[21,1],[21,2],[32,2],[32,3],[32,3],[32,4],[33,1],[34,1],[35,1],[35,3],[38,1],[36,1],[18,3],[42,1],[42,1],[42,1],[42,1],[42,1],[43,1],[43,1],[19,1],[19,1],[19,1],[12,1],[13,1],[16,1],[14,1]],performAction:function(a,l,d,f,E,i,Q){var h=i.length-1;switch(E){case 1:break;case 3:this.$=[];break;case 4:i[h-1].push(i[h]),this.$=i[h-1];break;case 5:case 6:this.$=i[h];break;case 7:case 8:this.$=[];break;case 12:f.addEntity(i[h-4]),f.addEntity(i[h-2]),f.addRelationship(i[h-4],i[h],i[h-2],i[h-3]);break;case 13:f.addEntity(i[h-3]),f.addAttributes(i[h-3],i[h-1]);break;case 14:f.addEntity(i[h-2]);break;case 15:f.addEntity(i[h]);break;case 16:case 17:this.$=i[h].trim(),f.setAccTitle(this.$);break;case 18:case 19:this.$=i[h].trim(),f.setAccDescription(this.$);break;case 20:case 44:this.$=i[h];break;case 21:case 42:case 43:this.$=i[h].replace(/"/g,"");break;case 22:case 30:this.$=[i[h]];break;case 23:i[h].push(i[h-1]),this.$=i[h];break;case 24:this.$={attributeType:i[h-1],attributeName:i[h]};break;case 25:this.$={attributeType:i[h-2],attributeName:i[h-1],attributeKeyTypeList:i[h]};break;case 26:this.$={attributeType:i[h-2],attributeName:i[h-1],attributeComment:i[h]};break;case 27:this.$={attributeType:i[h-3],attributeName:i[h-2],attributeKeyTypeList:i[h-1],attributeComment:i[h]};break;case 28:case 29:case 32:this.$=i[h];break;case 31:i[h-2].push(i[h]),this.$=i[h-2];break;case 33:this.$=i[h].replace(/"/g,"");break;case 34:this.$={cardA:i[h],relType:i[h-1],cardB:i[h-2]};break;case 35:this.$=f.Cardinality.ZERO_OR_ONE;break;case 36:this.$=f.Cardinality.ZERO_OR_MORE;break;case 37:this.$=f.Cardinality.ONE_OR_MORE;break;case 38:this.$=f.Cardinality.ONLY_ONE;break;case 39:this.$=f.Cardinality.MD_PARENT;break;case 40:this.$=f.Identification.NON_IDENTIFYING;break;case 41:this.$=f.Identification.IDENTIFYING;break;case 45:f.parseDirective("%%{","open_directive");break;case 46:f.parseDirective(i[h],"type_directive");break;case 47:i[h]=i[h].trim().replace(/'/g,'"'),f.parseDirective(i[h],"arg_directive");break;case 48:f.parseDirective("}%%","close_directive","er");break}},table:[{3:1,4:r,7:3,12:4,52:e},{1:[3]},t(n,[2,3],{5:6}),{3:7,4:r,7:3,12:4,52:e},{13:8,53:[1,9]},{53:[2,45]},{6:[1,10],7:15,8:11,9:[1,12],10:13,11:[1,14],12:4,17:16,23:s,25:y,27:u,29:o,30:c,31:_,52:e},{1:[2,2]},{14:23,15:[1,24],55:m},t([15,55],[2,46]),t(n,[2,8],{1:[2,1]}),t(n,[2,4]),{7:15,10:26,12:4,17:16,23:s,25:y,27:u,29:o,30:c,31:_,52:e},t(n,[2,6]),t(n,[2,7]),t(n,[2,11]),t(n,[2,15],{18:27,42:29,20:[1,28],44:g,45:O,46:p,47:v,48:Z}),{24:[1,35]},{26:[1,36]},{28:[1,37]},t(n,[2,19]),t(V,[2,20]),t(V,[2,21]),{11:[1,38]},{16:39,54:[1,40]},{11:[2,48]},t(n,[2,5]),{17:41,30:c,31:_},{21:42,22:[1,43],32:44,33:45,37:X},{43:47,49:[1,48],50:[1,49]},t(w,[2,35]),t(w,[2,36]),t(w,[2,37]),t(w,[2,38]),t(w,[2,39]),t(n,[2,16]),t(n,[2,17]),t(n,[2,18]),t(N,[2,9]),{14:50,55:m},{55:[2,47]},{15:[1,51]},{22:[1,52]},t(n,[2,14]),{21:53,22:[2,22],32:44,33:45,37:X},{34:54,37:[1,55]},{37:[2,28]},{42:56,44:g,45:O,46:p,47:v,48:Z},t(M,[2,40]),t(M,[2,41]),{11:[1,57]},{19:58,30:[1,61],31:[1,60],51:[1,59]},t(n,[2,13]),{22:[2,23]},t(x,[2,24],{35:62,36:63,38:64,40:k,41:P}),t([22,37,40,41],[2,29]),t([30,31],[2,34]),t(N,[2,10]),t(n,[2,12]),t(n,[2,42]),t(n,[2,43]),t(n,[2,44]),t(x,[2,25],{36:67,39:[1,68],41:P}),t(x,[2,26]),t(F,[2,30]),t(x,[2,33]),t(F,[2,32]),t(x,[2,27]),{38:69,40:k},t(F,[2,31])],defaultActions:{5:[2,45],7:[2,2],25:[2,48],40:[2,47],46:[2,28],53:[2,23]},parseError:function(a,l){if(l.recoverable)this.trace(a);else{var d=new Error(a);throw d.hash=l,d}},parse:function(a){var l=this,d=[0],f=[],E=[null],i=[],Q=this.table,h="",$=0,ut=0,Ft=2,pt=1,Wt=i.slice.call(arguments,1),b=Object.create(this.lexer),z={yy:{}};for(var it in this.yy)Object.prototype.hasOwnProperty.call(this.yy,it)&&(z.yy[it]=this.yy[it]);b.setInput(a,z.yy),z.yy.lexer=b,z.yy.parser=this,typeof b.yylloc=="undefined"&&(b.yylloc={});var at=b.yylloc;i.push(at);var Ut=b.options&&b.options.ranges;typeof z.yy.parseError=="function"?this.parseError=z.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function Vt(){var U;return U=f.pop()||b.lex()||pt,typeof U!="number"&&(U instanceof Array&&(f=U,U=f.pop()),U=l.symbols_[U]||U),U}for(var D,K,L,nt,G={},tt,W,yt,et;;){if(K=d[d.length-1],this.defaultActions[K]?L=this.defaultActions[K]:((D===null||typeof D=="undefined")&&(D=Vt()),L=Q[K]&&Q[K][D]),typeof L=="undefined"||!L.length||!L[0]){var st="";et=[];for(tt in Q[K])this.terminals_[tt]&&tt>Ft&&et.push("'"+this.terminals_[tt]+"'");b.showPosition?st="Parse error on line "+($+1)+`:
`+b.showPosition()+`
Expecting `+et.join(", ")+", got '"+(this.terminals_[D]||D)+"'":st="Parse error on line "+($+1)+": Unexpected "+(D==pt?"end of input":"'"+(this.terminals_[D]||D)+"'"),this.parseError(st,{text:b.match,token:this.terminals_[D]||D,line:b.yylineno,loc:at,expected:et})}if(L[0]instanceof Array&&L.length>1)throw new Error("Parse Error: multiple actions possible at state: "+K+", token: "+D);switch(L[0]){case 1:d.push(D),E.push(b.yytext),i.push(b.yylloc),d.push(L[1]),D=null,ut=b.yyleng,h=b.yytext,$=b.yylineno,at=b.yylloc;break;case 2:if(W=this.productions_[L[1]][1],G.$=E[E.length-W],G._$={first_line:i[i.length-(W||1)].first_line,last_line:i[i.length-1].last_line,first_column:i[i.length-(W||1)].first_column,last_column:i[i.length-1].last_column},Ut&&(G._$.range=[i[i.length-(W||1)].range[0],i[i.length-1].range[1]]),nt=this.performAction.apply(G,[h,ut,$,z.yy,L[1],E,i].concat(Wt)),typeof nt!="undefined")return nt;W&&(d=d.slice(0,-1*W*2),E=E.slice(0,-1*W),i=i.slice(0,-1*W)),d.push(this.productions_[L[1]][0]),E.push(G.$),i.push(G._$),yt=Q[d[d.length-2]][d[d.length-1]],d.push(yt);break;case 3:return!0}}return!0}},H=function(){var A={EOF:1,parseError:function(l,d){if(this.yy.parser)this.yy.parser.parseError(l,d);else throw new Error(l)},setInput:function(a,l){return this.yy=l||this.yy||{},this._input=a,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},input:function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var l=a.match(/(?:\r\n?|\n).*/g);return l?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},unput:function(a){var l=a.length,d=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;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),d.length-1&&(this.yylineno-=d.length-1);var E=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===f.length?this.yylloc.first_column:0)+f[f.length-d.length].length-d[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[E[0],E[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject: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},less:function(a){this.unput(this.match.slice(a))},pastInput:function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var a=this.pastInput(),l=new Array(a.length+1).join("-");return a+this.upcomingInput()+`
`+l+"^"},test_match:function(a,l){var d,f,E;if(this.options.backtrack_lexer&&(E={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&&(E.yylloc.range=this.yylloc.range.slice(0))),f=a[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+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,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(a[0].length),this.matched+=a[0],d=this.performAction.call(this,this.yy,this,l,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),d)return d;if(this._backtrack){for(var i in E)this[i]=E[i];return!1}return!1},next:function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,l,d,f;this._more||(this.yytext="",this.match="");for(var E=this._currentRules(),i=0;i<E.length;i++)if(d=this._input.match(this.rules[E[i]]),d&&(!l||d[0].length>l[0].length)){if(l=d,f=i,this.options.backtrack_lexer){if(a=this.test_match(d,E[i]),a!==!1)return a;if(this._backtrack){l=!1;continue}else return!1}else if(!this.options.flex)break}return l?(a=this.test_match(l,E[f]),a!==!1?a:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
`+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var l=this.next();return l||this.lex()},begin:function(l){this.conditionStack.push(l)},popState:function(){var l=this.conditionStack.length-1;return l>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(l){return l=this.conditionStack.length-1-Math.abs(l||0),l>=0?this.conditionStack[l]:"INITIAL"},pushState:function(l){this.begin(l)},stateStackSize:function(){return this.conditionStack.length},options:{"case-insensitive":!0},performAction:function(l,d,f,E){switch(f){case 0:return this.begin("acc_title"),25;case 1:return this.popState(),"acc_title_value";case 2:return this.begin("acc_descr"),27;case 3:return this.popState(),"acc_descr_value";case 4:this.begin("acc_descr_multiline");break;case 5:this.popState();break;case 6:return"acc_descr_multiline_value";case 7:return this.begin("open_directive"),52;case 8:return this.begin("type_directive"),53;case 9:return this.popState(),this.begin("arg_directive"),15;case 10:return this.popState(),this.popState(),55;case 11:return 54;case 12:return 11;case 13:break;case 14:return 9;case 15:return 31;case 16:return 51;case 17:return 4;case 18:return this.begin("block"),20;case 19:return 39;case 20:break;case 21:return 40;case 22:return 37;case 23:return 37;case 24:return 41;case 25:break;case 26:return this.popState(),22;case 27:return d.yytext[0];case 28:return 44;case 29:return 46;case 30:return 46;case 31:return 46;case 32:return 44;case 33:return 44;case 34:return 45;case 35:return 45;case 36:return 45;case 37:return 45;case 38:return 45;case 39:return 46;case 40:return 45;case 41:return 46;case 42:return 47;case 43:return 47;case 44:return 47;case 45:return 47;case 46:return 44;case 47:return 45;case 48:return 46;case 49:return 48;case 50:return 49;case 51:return 50;case 52:return 50;case 53:return 49;case 54:return 49;case 55:return 49;case 56:return 30;case 57:return d.yytext[0];case 58:return 6}},rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:%%\{)/i,/^(?:((?:(?!\}%%)[^:.])*))/i,/^(?::)/i,/^(?:\}%%)/i,/^(?:((?:(?!\}%%).|\n)*))/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,/^(?: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},open_directive:{rules:[8],inclusive:!1},type_directive:{rules:[9,10],inclusive:!1},arg_directive:{rules:[10,11],inclusive:!1},block:{rules:[19,20,21,22,23,24,25,26,27],inclusive:!1},INITIAL:{rules:[0,2,4,7,12,13,14,15,16,17,18,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,56,57,58],inclusive:!0}}};return A}();I.lexer=H;function S(){this.yy={}}return S.prototype=I,I.Parser=S,new S}();dt.parser=dt;var ee=dt,q={},ft=[],re={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"},ie={NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"},ae=function(t,r,e){Dt.parseDirective(this,t,r,e)},Yt=function(t){return q[t]===void 0&&(q[t]={attributes:[]},j.info("Added new entity :",t)),q[t]},ne=()=>q,se=function(t,r){let e=Yt(t),n;for(n=r.length-1;n>=0;n--)e.attributes.push(r[n]),j.debug("Added attribute ",r[n].attributeName)},oe=function(t,r,e,n){let s={entityA:t,roleA:r,entityB:e,relSpec:n};ft.push(s),j.debug("Added new relationship :",s)},ce=()=>ft,le=function(){q={},ft=[],Rt()},he={Cardinality:re,Identification:ie,parseDirective:ae,getConfig:()=>Y().er,addEntity:Yt,addAttributes:se,getEntities:ne,addRelationship:oe,getRelationships:ce,clear:le,setAccTitle:Ot,getAccTitle:bt,setAccDescription:Nt,getAccDescription:Tt,setDiagramTitle:vt,getDiagramTitle:At},B={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"},de=function(t,r){let e;t.append("defs").append("marker").attr("id",B.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",B.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",B.ONLY_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M9,0 L9,18 M15,0 L15,18"),t.append("defs").append("marker").attr("id",B.ONLY_ONE_END).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M3,0 L3,18 M9,0 L9,18"),e=t.append("defs").append("marker").attr("id",B.ZERO_OR_ONE_START).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto"),e.append("circle").attr("stroke",r.stroke).attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),e.append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M9,0 L9,18"),e=t.append("defs").append("marker").attr("id",B.ZERO_OR_ONE_END).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto"),e.append("circle").attr("stroke",r.stroke).attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),e.append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M21,0 L21,18"),t.append("defs").append("marker").attr("id",B.ONE_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",r.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",B.ONE_OR_MORE_END).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18"),e=t.append("defs").append("marker").attr("id",B.ZERO_OR_MORE_START).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto"),e.append("circle").attr("stroke",r.stroke).attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),e.append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18"),e=t.append("defs").append("marker").attr("id",B.ZERO_OR_MORE_END).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto"),e.append("circle").attr("stroke",r.stroke).attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),e.append("path").attr("stroke",r.stroke).attr("fill","none").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},C={ERMarkers:B,insertMarkers:de},fe=/[^\dA-Za-z](\W)*/g,R={},J=new Map,ue=function(t){let r=Object.keys(t);for(let e of r)R[e]=t[e]},pe=(t,r,e)=>{let n=R.entityPadding/3,s=R.entityPadding/3,y=R.fontSize*.85,u=r.node().getBBox(),o=[],c=!1,_=!1,m=0,g=0,O=0,p=0,v=u.height+n*2,Z=1;e.forEach(N=>{N.attributeKeyTypeList!==void 0&&N.attributeKeyTypeList.length>0&&(c=!0),N.attributeComment!==void 0&&(_=!0)}),e.forEach(N=>{let M=`${r.node().id}-attr-${Z}`,x=0,k=xt(N.attributeType),P=t.append("text").classed("er entityLabel",!0).attr("id",`${M}-type`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",Y().fontFamily).style("font-size",y+"px").text(k),F=t.append("text").classed("er entityLabel",!0).attr("id",`${M}-name`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",Y().fontFamily).style("font-size",y+"px").text(N.attributeName),I={};I.tn=P,I.nn=F;let H=P.node().getBBox(),S=F.node().getBBox();if(m=Math.max(m,H.width),g=Math.max(g,S.width),x=Math.max(H.height,S.height),c){let A=N.attributeKeyTypeList!==void 0?N.attributeKeyTypeList.join(","):"",a=t.append("text").classed("er entityLabel",!0).attr("id",`${M}-key`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",Y().fontFamily).style("font-size",y+"px").text(A);I.kn=a;let l=a.node().getBBox();O=Math.max(O,l.width),x=Math.max(x,l.height)}if(_){let A=t.append("text").classed("er entityLabel",!0).attr("id",`${M}-comment`).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","left").style("font-family",Y().fontFamily).style("font-size",y+"px").text(N.attributeComment||"");I.cn=A;let a=A.node().getBBox();p=Math.max(p,a.width),x=Math.max(x,a.height)}I.height=x,o.push(I),v+=x+n*2,Z+=1});let V=4;c&&(V+=2),_&&(V+=2);let X=m+g+O+p,w={width:Math.max(R.minEntityWidth,Math.max(u.width+R.entityPadding*2,X+s*V)),height:e.length>0?v:Math.max(R.minEntityHeight,u.height+R.entityPadding*2)};if(e.length>0){let N=Math.max(0,(w.width-X-s*V)/(V/2));r.attr("transform","translate("+w.width/2+","+(n+u.height/2)+")");let M=u.height+n*2,x="attributeBoxOdd";o.forEach(k=>{let P=M+n+k.height/2;k.tn.attr("transform","translate("+s+","+P+")");let F=t.insert("rect","#"+k.tn.node().id).classed(`er ${x}`,!0).attr("x",0).attr("y",M).attr("width",m+s*2+N).attr("height",k.height+n*2),I=parseFloat(F.attr("x"))+parseFloat(F.attr("width"));k.nn.attr("transform","translate("+(I+s)+","+P+")");let H=t.insert("rect","#"+k.nn.node().id).classed(`er ${x}`,!0).attr("x",I).attr("y",M).attr("width",g+s*2+N).attr("height",k.height+n*2),S=parseFloat(H.attr("x"))+parseFloat(H.attr("width"));if(c){k.kn.attr("transform","translate("+(S+s)+","+P+")");let A=t.insert("rect","#"+k.kn.node().id).classed(`er ${x}`,!0).attr("x",S).attr("y",M).attr("width",O+s*2+N).attr("height",k.height+n*2);S=parseFloat(A.attr("x"))+parseFloat(A.attr("width"))}_&&(k.cn.attr("transform","translate("+(S+s)+","+P+")"),t.insert("rect","#"+k.cn.node().id).classed(`er ${x}`,"true").attr("x",S).attr("y",M).attr("width",p+s*2+N).attr("height",k.height+n*2)),M+=k.height+n*2,x=x==="attributeBoxOdd"?"attributeBoxEven":"attributeBoxOdd"})}else w.height=Math.max(R.minEntityHeight,v),r.attr("transform","translate("+w.width/2+","+w.height/2+")");return w},ye=function(t,r,e){let n=Object.keys(r),s;return n.forEach(function(y){let u=ke(y,"entity");J.set(y,u);let o=t.append("g").attr("id",u);s=s===void 0?u:s;let c="text-"+u,_=o.append("text").classed("er entityLabel",!0).attr("id",c).attr("x",0).attr("y",0).style("dominant-baseline","middle").style("text-anchor","middle").style("font-family",Y().fontFamily).style("font-size",R.fontSize+"px").text(y),{width:m,height:g}=pe(o,_,r[y].attributes),p=o.insert("rect","#"+c).classed("er entityBox",!0).attr("x",0).attr("y",0).attr("width",m).attr("height",g).node().getBBox();e.setNode(u,{width:p.width,height:p.height,shape:"rect",id:u})}),s},_e=function(t,r){r.nodes().forEach(function(e){e!==void 0&&r.node(e)!==void 0&&t.select("#"+e).attr("transform","translate("+(r.node(e).x-r.node(e).width/2)+","+(r.node(e).y-r.node(e).height/2)+" )")})},Zt=function(t){return(t.entityA+t.roleA+t.entityB).replace(/\s/g,"")},me=function(t,r){return t.forEach(function(e){r.setEdge(J.get(e.entityA),J.get(e.entityB),{relationship:e},Zt(e))}),t},Ct=0,Ee=function(t,r,e,n,s){Ct++;let y=e.edge(J.get(r.entityA),J.get(r.entityB),Zt(r)),u=_t().x(function(v){return v.x}).y(function(v){return v.y}).curve(mt),o=t.insert("path","#"+n).classed("er relationshipLine",!0).attr("d",u(y.points)).style("stroke",R.stroke).style("fill","none");r.relSpec.relType===s.db.Identification.NON_IDENTIFYING&&o.attr("stroke-dasharray","8,8");let c="";switch(R.arrowMarkerAbsolute&&(c=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,c=c.replace(/\(/g,"\\("),c=c.replace(/\)/g,"\\)")),r.relSpec.cardA){case s.db.Cardinality.ZERO_OR_ONE:o.attr("marker-end","url("+c+"#"+C.ERMarkers.ZERO_OR_ONE_END+")");break;case s.db.Cardinality.ZERO_OR_MORE:o.attr("marker-end","url("+c+"#"+C.ERMarkers.ZERO_OR_MORE_END+")");break;case s.db.Cardinality.ONE_OR_MORE:o.attr("marker-end","url("+c+"#"+C.ERMarkers.ONE_OR_MORE_END+")");break;case s.db.Cardinality.ONLY_ONE:o.attr("marker-end","url("+c+"#"+C.ERMarkers.ONLY_ONE_END+")");break;case s.db.Cardinality.MD_PARENT:o.attr("marker-end","url("+c+"#"+C.ERMarkers.MD_PARENT_END+")");break}switch(r.relSpec.cardB){case s.db.Cardinality.ZERO_OR_ONE:o.attr("marker-start","url("+c+"#"+C.ERMarkers.ZERO_OR_ONE_START+")");break;case s.db.Cardinality.ZERO_OR_MORE:o.attr("marker-start","url("+c+"#"+C.ERMarkers.ZERO_OR_MORE_START+")");break;case s.db.Cardinality.ONE_OR_MORE:o.attr("marker-start","url("+c+"#"+C.ERMarkers.ONE_OR_MORE_START+")");break;case s.db.Cardinality.ONLY_ONE:o.attr("marker-start","url("+c+"#"+C.ERMarkers.ONLY_ONE_START+")");break;case s.db.Cardinality.MD_PARENT:o.attr("marker-start","url("+c+"#"+C.ERMarkers.MD_PARENT_START+")");break}let _=o.node().getTotalLength(),m=o.node().getPointAtLength(_*.5),g="rel"+Ct,p=t.append("text").classed("er relationshipLabel",!0).attr("id",g).attr("x",m.x).attr("y",m.y).style("text-anchor","middle").style("dominant-baseline","middle").style("font-family",Y().fontFamily).style("font-size",R.fontSize+"px").text(r.roleA).node().getBBox();t.insert("rect","#"+g).classed("er relationshipLabelBox",!0).attr("x",m.x-p.width/2).attr("y",m.y-p.height/2).attr("width",p.width).attr("height",p.height)},ge=function(t,r,e,n){R=Y().er,j.info("Drawing ER diagram");let s=Y().securityLevel,y;s==="sandbox"&&(y=rt("#i"+r));let o=(s==="sandbox"?rt(y.nodes()[0].contentDocument.body):rt("body")).select(`[id='${r}']`);C.insertMarkers(o,R);let c;c=new Et({multigraph:!0,directed:!0,compound:!1}).setGraph({rankdir:R.layoutDirection,marginx:20,marginy:20,nodesep:100,edgesep:100,ranksep:100}).setDefaultEdgeLabel(function(){return{}});let _=ye(o,n.db.getEntities(),c),m=me(n.db.getRelationships(),c);gt(c),_e(o,c),m.forEach(function(Z){Ee(o,Z,c,_,n)});let g=R.diagramPadding;Mt.insertTitle(o,"entityTitleText",R.titleTopMargin,n.db.getDiagramTitle());let O=o.node().getBBox(),p=O.width+g*2,v=O.height+g*2;kt(o,v,p,R.useMaxWidth),o.attr("viewBox",`${O.x-g} ${O.y-g} ${p} ${v}`)},xe="28e9f9db-3c8d-5aa5-9faf-44286ae5937c";function ke(t="",r=""){let e=t.replace(fe,"");return`${Pt(r)}${Pt(e)}${ht(t,xe)}`}function Pt(t=""){return t.length>0?`${t}-`:""}var Re={setConf:ue,draw:ge},Oe=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;
}
`,be=Oe,Qe={parser:ee,db:he,renderer:Re,styles:be};export{Qe as diagram};