UNPKG

mermaid

Version:

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

35 lines (31 loc) 43 kB
import{a as Bt}from"./chunk-6BELYETK.mjs";import{a as Pt}from"./chunk-5IMINLNL.mjs";import{o as Ft}from"./chunk-7CWYLC5S.mjs";import"./chunk-STOV2HOB.mjs";import{O as At,S as Rt,T as Ct,U as Vt,V as Ot,W as Nt,X as jt,Y as Lt,d as Tt,e as Et,f as _t,g as ct,j as zt,t as it}from"./chunk-2AEHWXPW.mjs";import{h as ot}from"./chunk-LIEV3EAG.mjs";import{a as d}from"./chunk-AQ6EADP3.mjs";var ut=(function(){var t=d(function(D,x,b,k){for(b=b||{},k=D.length;k--;b[D[k]]=x);return b},"o"),n=[5,8],s=[7,8,11,12,17,19,22,24],e=[1,17],i=[1,18],o=[7,8,11,12,14,15,16,17,19,20,21,22,24,27],r=[1,31],l=[1,39],f=[7,8,11,12,17,19,22,24,27],u=[1,57],a=[1,56],p=[1,58],g=[1,59],v=[1,60],m=[7,8,11,12,16,17,19,20,22,24,27,31,32,33],S={trace:d(function(){},"trace"),yy:{},symbols_:{error:2,start:3,optNewlines:4,VENN:5,document:6,EOF:7,NEWLINE:8,line:9,statement:10,TITLE:11,SET:12,identifier:13,BRACKET_LABEL:14,COLON:15,NUMERIC:16,UNION:17,identifierList:18,TEXT:19,IDENTIFIER:20,STRING:21,INDENT_TEXT:22,indentedTextTail:23,STYLE:24,stylesOpt:25,styleField:26,COMMA:27,styleValue:28,valueTokens:29,valueToken:30,HEXCOLOR:31,RGBCOLOR:32,RGBACOLOR:33,$accept:0,$end:1},terminals_:{2:"error",5:"VENN",7:"EOF",8:"NEWLINE",11:"TITLE",12:"SET",14:"BRACKET_LABEL",15:"COLON",16:"NUMERIC",17:"UNION",19:"TEXT",20:"IDENTIFIER",21:"STRING",22:"INDENT_TEXT",24:"STYLE",27:"COMMA",31:"HEXCOLOR",32:"RGBCOLOR",33:"RGBACOLOR"},productions_:[0,[3,4],[4,0],[4,2],[6,0],[6,2],[9,1],[9,1],[10,1],[10,2],[10,3],[10,4],[10,5],[10,2],[10,3],[10,4],[10,5],[10,3],[10,3],[10,3],[10,4],[10,4],[10,2],[10,3],[23,1],[23,1],[23,1],[23,2],[23,2],[25,1],[25,3],[26,3],[28,1],[28,1],[29,1],[29,2],[30,1],[30,1],[30,1],[30,1],[30,1],[18,1],[18,3],[13,1],[13,1]],performAction:d(function(x,b,k,c,y,h,A){var I=h.length-1;switch(y){case 1:return h[I-1];case 2:case 3:case 4:this.$=[];break;case 5:h[I-1].push(h[I]),this.$=h[I-1];break;case 6:this.$=[];break;case 7:case 22:case 32:case 36:case 37:case 38:case 39:case 40:this.$=h[I];break;case 8:c.setDiagramTitle(h[I].substr(6)),this.$=h[I].substr(6);break;case 9:c.addSubsetData([h[I]],void 0,void 0),c.setIndentMode&&c.setIndentMode(!0);break;case 10:c.addSubsetData([h[I-1]],h[I],void 0),c.setIndentMode&&c.setIndentMode(!0);break;case 11:c.addSubsetData([h[I-2]],void 0,parseFloat(h[I])),c.setIndentMode&&c.setIndentMode(!0);break;case 12:c.addSubsetData([h[I-3]],h[I-2],parseFloat(h[I])),c.setIndentMode&&c.setIndentMode(!0);break;case 13:if(h[I].length<2)throw new Error("union requires multiple identifiers");c.validateUnionIdentifiers&&c.validateUnionIdentifiers(h[I]),c.addSubsetData(h[I],void 0,void 0),c.setIndentMode&&c.setIndentMode(!0);break;case 14:if(h[I-1].length<2)throw new Error("union requires multiple identifiers");c.validateUnionIdentifiers&&c.validateUnionIdentifiers(h[I-1]),c.addSubsetData(h[I-1],h[I],void 0),c.setIndentMode&&c.setIndentMode(!0);break;case 15:if(h[I-2].length<2)throw new Error("union requires multiple identifiers");c.validateUnionIdentifiers&&c.validateUnionIdentifiers(h[I-2]),c.addSubsetData(h[I-2],void 0,parseFloat(h[I])),c.setIndentMode&&c.setIndentMode(!0);break;case 16:if(h[I-3].length<2)throw new Error("union requires multiple identifiers");c.validateUnionIdentifiers&&c.validateUnionIdentifiers(h[I-3]),c.addSubsetData(h[I-3],h[I-2],parseFloat(h[I])),c.setIndentMode&&c.setIndentMode(!0);break;case 17:case 18:case 19:c.addTextData(h[I-1],h[I],void 0);break;case 20:case 21:c.addTextData(h[I-2],h[I-1],h[I]);break;case 23:c.addStyleData(h[I-1],h[I]);break;case 24:case 25:case 26:var R=c.getCurrentSets();if(!R)throw new Error("text requires set");c.addTextData(R,h[I],void 0);break;case 27:case 28:var R=c.getCurrentSets();if(!R)throw new Error("text requires set");c.addTextData(R,h[I-1],h[I]);break;case 29:case 41:this.$=[h[I]];break;case 30:case 42:this.$=[...h[I-2],h[I]];break;case 31:this.$=[h[I-2],h[I]];break;case 33:this.$=h[I].join(" ");break;case 34:this.$=[h[I]];break;case 35:h[I-1].push(h[I]),this.$=h[I-1];break;case 43:case 44:this.$=h[I];break}},"anonymous"),table:[t(n,[2,2],{3:1,4:2}),{1:[3]},{5:[1,3],8:[1,4]},t(s,[2,4],{6:5}),t(n,[2,3]),{7:[1,6],8:[1,8],9:7,10:9,11:[1,10],12:[1,11],17:[1,12],19:[1,13],22:[1,14],24:[1,15]},{1:[2,1]},t(s,[2,5]),t(s,[2,6]),t(s,[2,7]),t(s,[2,8]),{13:16,20:e,21:i},{13:20,18:19,20:e,21:i},{13:20,18:21,20:e,21:i},{16:[1,25],20:[1,23],21:[1,24],23:22},{13:20,18:26,20:e,21:i},t(s,[2,9],{14:[1,27],15:[1,28]}),t(o,[2,43]),t(o,[2,44]),t(s,[2,13],{14:[1,29],15:[1,30],27:r}),t(o,[2,41]),{16:[1,34],20:[1,32],21:[1,33],27:r},t(s,[2,22]),t(s,[2,24],{14:[1,35]}),t(s,[2,25],{14:[1,36]}),t(s,[2,26]),{20:l,25:37,26:38,27:r},t(s,[2,10],{15:[1,40]}),{16:[1,41]},t(s,[2,14],{15:[1,42]}),{16:[1,43]},{13:44,20:e,21:i},t(s,[2,17],{14:[1,45]}),t(s,[2,18],{14:[1,46]}),t(s,[2,19]),t(s,[2,27]),t(s,[2,28]),t(s,[2,23],{27:[1,47]}),t(f,[2,29]),{15:[1,48]},{16:[1,49]},t(s,[2,11]),{16:[1,50]},t(s,[2,15]),t(o,[2,42]),t(s,[2,20]),t(s,[2,21]),{20:l,26:51},{16:u,20:a,21:[1,53],28:52,29:54,30:55,31:p,32:g,33:v},t(s,[2,12]),t(s,[2,16]),t(f,[2,30]),t(f,[2,31]),t(f,[2,32]),t(f,[2,33],{30:61,16:u,20:a,31:p,32:g,33:v}),t(m,[2,34]),t(m,[2,36]),t(m,[2,37]),t(m,[2,38]),t(m,[2,39]),t(m,[2,40]),t(m,[2,35])],defaultActions:{6:[2,1]},parseError:d(function(x,b){if(b.recoverable)this.trace(x);else{var k=new Error(x);throw k.hash=b,k}},"parseError"),parse:d(function(x){var b=this,k=[0],c=[],y=[null],h=[],A=this.table,I="",R=0,U=0,P=0,V=2,z=1,C=h.slice.call(arguments,1),T=Object.create(this.lexer),O={yy:{}};for(var B in this.yy)Object.prototype.hasOwnProperty.call(this.yy,B)&&(O.yy[B]=this.yy[B]);T.setInput(x,O.yy),O.yy.lexer=T,O.yy.parser=this,typeof T.yylloc>"u"&&(T.yylloc={});var N=T.yylloc;h.push(N);var j=T.options&&T.options.ranges;typeof O.yy.parseError=="function"?this.parseError=O.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function H(K){k.length=k.length-2*K,y.length=y.length-K,h.length=h.length-K}d(H,"popStack");function L(){var K;return K=c.pop()||T.lex()||z,typeof K!="number"&&(K instanceof Array&&(c=K,K=c.pop()),K=b.symbols_[K]||K),K}d(L,"lex");for(var _,X,W,M,F,et,Z={},Y,q,wt,st;;){if(W=k[k.length-1],this.defaultActions[W]?M=this.defaultActions[W]:((_===null||typeof _>"u")&&(_=L()),M=A[W]&&A[W][_]),typeof M>"u"||!M.length||!M[0]){var lt="";st=[];for(Y in A[W])this.terminals_[Y]&&Y>V&&st.push("'"+this.terminals_[Y]+"'");T.showPosition?lt="Parse error on line "+(R+1)+`: `+T.showPosition()+` Expecting `+st.join(", ")+", got '"+(this.terminals_[_]||_)+"'":lt="Parse error on line "+(R+1)+": Unexpected "+(_==z?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(lt,{text:T.match,token:this.terminals_[_]||_,line:T.yylineno,loc:N,expected:st})}if(M[0]instanceof Array&&M.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+_);switch(M[0]){case 1:k.push(_),y.push(T.yytext),h.push(T.yylloc),k.push(M[1]),_=null,X?(_=X,X=null):(U=T.yyleng,I=T.yytext,R=T.yylineno,N=T.yylloc,P>0&&P--);break;case 2:if(q=this.productions_[M[1]][1],Z.$=y[y.length-q],Z._$={first_line:h[h.length-(q||1)].first_line,last_line:h[h.length-1].last_line,first_column:h[h.length-(q||1)].first_column,last_column:h[h.length-1].last_column},j&&(Z._$.range=[h[h.length-(q||1)].range[0],h[h.length-1].range[1]]),et=this.performAction.apply(Z,[I,U,R,O.yy,M[1],y,h].concat(C)),typeof et<"u")return et;q&&(k=k.slice(0,-1*q*2),y=y.slice(0,-1*q),h=h.slice(0,-1*q)),k.push(this.productions_[M[1]][0]),y.push(Z.$),h.push(Z._$),wt=A[k[k.length-2]][k[k.length-1]],k.push(wt);break;case 3:return!0}}return!0},"parse")},E=(function(){var D={EOF:1,parseError:d(function(b,k){if(this.yy.parser)this.yy.parser.parseError(b,k);else throw new Error(b)},"parseError"),setInput:d(function(x,b){return this.yy=b||this.yy||{},this._input=x,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:d(function(){var x=this._input[0];this.yytext+=x,this.yyleng++,this.offset++,this.match+=x,this.matched+=x;var b=x.match(/(?:\r\n?|\n).*/g);return b?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),x},"input"),unput:d(function(x){var b=x.length,k=x.split(/(?:\r\n?|\n)/g);this._input=x+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-b),this.offset-=b;var c=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),k.length-1&&(this.yylineno-=k.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:k?(k.length===c.length?this.yylloc.first_column:0)+c[c.length-k.length].length-k[0].length:this.yylloc.first_column-b},this.options.ranges&&(this.yylloc.range=[y[0],y[0]+this.yyleng-b]),this.yyleng=this.yytext.length,this},"unput"),more:d(function(){return this._more=!0,this},"more"),reject:d(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:d(function(x){this.unput(this.match.slice(x))},"less"),pastInput:d(function(){var x=this.matched.substr(0,this.matched.length-this.match.length);return(x.length>20?"...":"")+x.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:d(function(){var x=this.match;return x.length<20&&(x+=this._input.substr(0,20-x.length)),(x.substr(0,20)+(x.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:d(function(){var x=this.pastInput(),b=new Array(x.length+1).join("-");return x+this.upcomingInput()+` `+b+"^"},"showPosition"),test_match:d(function(x,b){var k,c,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))),c=x[0].match(/(?:\r\n?|\n).*/g),c&&(this.yylineno+=c.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:c?c[c.length-1].length-c[c.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+x[0].length},this.yytext+=x[0],this.match+=x[0],this.matches=x,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(x[0].length),this.matched+=x[0],k=this.performAction.call(this,this.yy,this,b,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),k)return k;if(this._backtrack){for(var h in y)this[h]=y[h];return!1}return!1},"test_match"),next:d(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var x,b,k,c;this._more||(this.yytext="",this.match="");for(var y=this._currentRules(),h=0;h<y.length;h++)if(k=this._input.match(this.rules[y[h]]),k&&(!b||k[0].length>b[0].length)){if(b=k,c=h,this.options.backtrack_lexer){if(x=this.test_match(k,y[h]),x!==!1)return x;if(this._backtrack){b=!1;continue}else return!1}else if(!this.options.flex)break}return b?(x=this.test_match(b,y[c]),x!==!1?x:!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:d(function(){var b=this.next();return b||this.lex()},"lex"),begin:d(function(b){this.conditionStack.push(b)},"begin"),popState:d(function(){var b=this.conditionStack.length-1;return b>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:d(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:d(function(b){return b=this.conditionStack.length-1-Math.abs(b||0),b>=0?this.conditionStack[b]:"INITIAL"},"topState"),pushState:d(function(b){this.begin(b)},"pushState"),stateStackSize:d(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:d(function(b,k,c,y){var h=y;switch(c){case 0:break;case 1:break;case 2:break;case 3:if(b.getIndentMode&&b.getIndentMode())return b.consumeIndentText=!0,this.begin("INITIAL"),22;break;case 4:break;case 5:b.setIndentMode&&b.setIndentMode(!1),this.begin("INITIAL"),this.unput(k.yytext);break;case 6:return this.begin("bol"),8;break;case 7:break;case 8:break;case 9:return 7;case 10:return 11;case 11:return 5;case 12:return 12;case 13:return 17;case 14:if(b.consumeIndentText)b.consumeIndentText=!1;else return 19;break;case 15:return 24;case 16:return k.yytext=k.yytext.slice(2,-2),14;break;case 17:return k.yytext=k.yytext.slice(1,-1).trim(),14;break;case 18:return 16;case 19:return 31;case 20:return 33;case 21:return 32;case 22:return 20;case 23:return 21;case 24:return 27;case 25:return 15}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:[ \t]+(?=[\n\r]))/i,/^(?:[ \t]+(?=text\b))/i,/^(?:[ \t]+)/i,/^(?:[^ \t\n\r])/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:[ \t]+)/i,/^(?:$)/i,/^(?:title\s[^#\n;]+)/i,/^(?:venn-beta\b)/i,/^(?:set\b)/i,/^(?:union\b)/i,/^(?:text\b)/i,/^(?:style\b)/i,/^(?:\["[^\"]*"\])/i,/^(?:\[[^\]\"]+\])/i,/^(?:[+-]?(\d+(\.\d+)?|\.\d+))/i,/^(?:#[0-9a-fA-F]{3,8})/i,/^(?:rgba\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:rgb\(\s*[0-9.]+\s*[,]\s*[0-9.]+\s*[,]\s*[0-9.]+\s*\))/i,/^(?:[A-Za-z_][A-Za-z0-9\-_]*)/i,/^(?:"[^\"]*")/i,/^(?:,)/i,/^(?::)/i],conditions:{bol:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0},INITIAL:{rules:[0,1,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],inclusive:!0}}};return D})();S.lexer=E;function w(){this.yy={}}return d(w,"Parser"),w.prototype=S,S.Parser=w,new w})();ut.parser=ut;var qt=ut;var ft=[],ht=[],dt=[],gt=new Set,xt,yt=!1,ue=d((t,n,s)=>{let e=rt(t).sort(),i=s??10/Math.pow(t.length,2);xt=e,e.length===1&&gt.add(e[0]),ft.push({sets:e,size:i,label:n?nt(n):void 0})},"addSubsetData"),fe=d(()=>ft,"getSubsetData"),nt=d(t=>{let n=t.trim();return n.length>=2&&n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n},"normalizeText"),he=d(t=>t&&nt(t),"normalizeStyleValue"),de=d((t,n,s)=>{let e=nt(n);ht.push({sets:rt(t).sort(),id:e,label:s?nt(s):void 0})},"addTextData"),ge=d((t,n)=>{let s=rt(t).sort(),e={};for(let[i,o]of n)e[i]=he(o)??o;dt.push({targets:s,styles:e})},"addStyleData"),xe=d(()=>dt,"getStyleData"),rt=d(t=>t.map(n=>nt(n)),"normalizeIdentifierList"),ye=d(t=>{let s=rt(t).filter(e=>!gt.has(e));if(s.length>0)throw new Error(`unknown set identifier: ${s.join(", ")}`)},"validateUnionIdentifiers"),pe=d(()=>ht,"getTextData"),me=d(()=>xt,"getCurrentSets"),be=d(()=>yt,"getIndentMode"),ve=d(t=>{yt=t},"setIndentMode"),ke=zt.venn;function Me(){return Ft(ke,it().venn)}d(Me,"getConfig");var Ie=d(()=>{Rt(),ft.length=0,ht.length=0,dt.length=0,gt.clear(),xt=void 0,yt=!1},"customClear"),Gt={getConfig:Me,clear:Ie,setAccTitle:Ct,getAccTitle:Vt,setDiagramTitle:jt,getDiagramTitle:Lt,getAccDescription:Nt,setAccDescription:Ot,addSubsetData:ue,getSubsetData:fe,addTextData:de,addStyleData:ge,validateUnionIdentifiers:ye,getTextData:pe,getStyleData:xe,getCurrentSets:me,getIndentMode:be,setIndentMode:ve};var Se=d(t=>` .venn-title { font-size: 32px; fill: ${t.vennTitleTextColor}; font-family: ${t.fontFamily}; } .venn-circle text { font-size: 48px; font-family: ${t.fontFamily}; } .venn-intersection text { font-size: 48px; fill: ${t.vennSetTextColor}; font-family: ${t.fontFamily}; } .venn-text-node { font-family: ${t.fontFamily}; color: ${t.vennSetTextColor}; } `,"getStyles"),Ut=Se;function at(t,n){let s=we(t),e=s.filter(l=>De(l,t)),i=0,o=0,r=[];if(e.length>1){let l=Yt(e);for(let u=0;u<e.length;++u){let a=e[u];a.angle=Math.atan2(a.x-l.x,a.y-l.y)}e.sort((u,a)=>a.angle-u.angle);let f=e[e.length-1];for(let u=0;u<e.length;++u){let a=e[u];o+=(f.x+a.x)*(a.y-f.y);let p={x:(a.x+f.x)/2,y:(a.y+f.y)/2},g=null;for(let v=0;v<a.parentIndex.length;++v)if(f.parentIndex.includes(a.parentIndex[v])){let m=t[a.parentIndex[v]],S=Math.atan2(a.x-m.x,a.y-m.y),E=Math.atan2(f.x-m.x,f.y-m.y),w=E-S;w<0&&(w+=2*Math.PI);let D=E-w/2,x=G(p,{x:m.x+m.radius*Math.sin(D),y:m.y+m.radius*Math.cos(D)});x>m.radius*2&&(x=m.radius*2),(g==null||g.width>x)&&(g={circle:m,width:x,p1:a,p2:f,large:x>m.radius,sweep:!0})}g!=null&&(r.push(g),i+=bt(g.circle.radius,g.width),f=a)}}else{let l=t[0];for(let u=1;u<t.length;++u)t[u].radius<l.radius&&(l=t[u]);let f=!1;for(let u=0;u<t.length;++u)if(G(t[u],l)>Math.abs(l.radius-t[u].radius)){f=!0;break}f?i=o=0:(i=l.radius*l.radius*Math.PI,r.push({circle:l,p1:{x:l.x,y:l.y+l.radius},p2:{x:l.x-1e-10,y:l.y+l.radius},width:l.radius*2,large:!0,sweep:!0}))}return o/=2,n&&(n.area=i+o,n.arcArea=i,n.polygonArea=o,n.arcs=r,n.innerPoints=e,n.intersectionPoints=s),i+o}d(at,"intersectionArea");function De(t,n){return n.every(s=>G(t,s)<s.radius+1e-10)}d(De,"containedInCircles");function we(t){let n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){let i=Ht(t[s],t[e]);for(let o of i)o.parentIndex=[s,e],n.push(o)}return n}d(we,"getIntersectionPoints");function bt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}d(bt,"circleArea");function G(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}d(G,"distance");function Dt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);let e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return bt(t,e)+bt(n,i)}d(Dt,"circleOverlap");function Ht(t,n){let s=G(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];let o=(e*e-i*i+s*s)/(2*s),r=Math.sqrt(e*e-o*o),l=t.x+o*(n.x-t.x)/s,f=t.y+o*(n.y-t.y)/s,u=-(n.y-t.y)*(r/s),a=-(n.x-t.x)*(r/s);return[{x:l+u,y:f-a},{x:l-u,y:f+a}]}d(Ht,"circleCircleIntersection");function Yt(t){let n={x:0,y:0};for(let s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}d(Yt,"getCenter");function Te(t,n,s,e){e=e||{};let i=e.maxIterations||100,o=e.tolerance||1e-10,r=t(n),l=t(s),f=s-n;if(r*l>0)throw"Initial bisect points must have opposite signs";if(r===0)return n;if(l===0)return s;for(let u=0;u<i;++u){f/=2;let a=n+f,p=t(a);if(p*r>=0&&(n=a),Math.abs(f)<o||p===0)return a}return n+f}d(Te,"bisect");function vt(t){let n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}d(vt,"zeros");function Wt(t,n){return vt(t).map(()=>vt(n))}d(Wt,"zerosM");function $(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}d($,"dot");function kt(t){return Math.sqrt($(t,t))}d(kt,"norm2");function Mt(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}d(Mt,"scale");function J(t,n,s,e,i){for(let o=0;o<t.length;++o)t[o]=n*s[o]+e*i[o]}d(J,"weightedSum");function Xt(t,n,s){s=s||{};let e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,o=s.zeroDelta||.001,r=s.minErrorDelta||1e-6,l=s.minErrorDelta||1e-5,f=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,a=s.psi!==void 0?s.psi:-.5,p=s.sigma!==void 0?s.sigma:.5,g,v=n.length,m=new Array(v+1);m[0]=n,m[0].fx=t(n),m[0].id=0;for(let k=0;k<v;++k){let c=n.slice();c[k]=c[k]?c[k]*i:o,m[k+1]=c,m[k+1].fx=t(c),m[k+1].id=k+1}function S(k){for(let c=0;c<k.length;c++)m[v][c]=k[c];m[v].fx=k.fx}d(S,"updateSimplex");let E=d((k,c)=>k.fx-c.fx,"sortOrder"),w=n.slice(),D=n.slice(),x=n.slice(),b=n.slice();for(let k=0;k<e;++k){if(m.sort(E),s.history){let y=m.map(h=>{let A=h.slice();return A.fx=h.fx,A.id=h.id,A});y.sort((h,A)=>h.id-A.id),s.history.push({x:m[0].slice(),fx:m[0].fx,simplex:y})}g=0;for(let y=0;y<v;++y)g=Math.max(g,Math.abs(m[0][y]-m[1][y]));if(Math.abs(m[0].fx-m[v].fx)<r&&g<l)break;for(let y=0;y<v;++y){w[y]=0;for(let h=0;h<v;++h)w[y]+=m[h][y];w[y]/=v}let c=m[v];if(J(D,1+f,w,-f,c),D.fx=t(D),D.fx<m[0].fx)J(b,1+u,w,-u,c),b.fx=t(b),b.fx<D.fx?S(b):S(D);else if(D.fx>=m[v-1].fx){let y=!1;if(D.fx>c.fx?(J(x,1+a,w,-a,c),x.fx=t(x),x.fx<c.fx?S(x):y=!0):(J(x,1-a*f,w,a*f,c),x.fx=t(x),x.fx<D.fx?S(x):y=!0),y){if(p>=1)break;for(let h=1;h<m.length;++h)J(m[h],1-p,m[0],p,m[h]),m[h].fx=t(m[h])}}else S(D)}return m.sort(E),{fx:m[0].fx,x:m[0]}}d(Xt,"nelderMead");function Ee(t,n,s,e,i,o,r){let l=s.fx,f=$(s.fxprime,n),u=l,a=l,p=f,g=0;i=i||1,o=o||1e-6,r=r||.1;function v(m,S,E){for(let w=0;w<16;++w)if(i=(m+S)/2,J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),p=$(e.fxprime,n),u>l+o*i*f||u>=E)S=i;else{if(Math.abs(p)<=-r*f)return i;p*(S-m)>=0&&(S=m),m=i,E=u}return 0}d(v,"zoom");for(let m=0;m<10;++m){if(J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),p=$(e.fxprime,n),u>l+o*i*f||m&&u>=a)return v(g,i,a);if(Math.abs(p)<=-r*f)return i;if(p>=0)return v(i,g,u);a=u,g=i,i*=2}return i}d(Ee,"wolfeLineSearch");function _e(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()},o=n.slice(),r,l,f=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),r=e.fxprime.slice(),Mt(r,e.fxprime,-1);for(let a=0;a<u;++a){if(f=Ee(t,r,e,i,f),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),!f)Mt(r,e.fxprime,-1);else{J(o,1,i.fxprime,-1,e.fxprime);let p=$(e.fxprime,e.fxprime),g=Math.max(0,$(o,i.fxprime)/p);J(r,g,r,-1,i.fxprime),l=e,e=i,i=l}if(kt(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:f}),e}d(_e,"conjugateGradient");function Zt(t,n={}){n.maxIterations=n.maxIterations||500;let s=n.initialLayout||Ce,e=n.lossFunction||tt,i=ze(t,n),o=s(i,n),r=Object.keys(o),l=[];for(let a of r)l.push(o[a].x),l.push(o[a].y);let u=Xt(a=>{let p={};for(let g=0;g<r.length;++g){let v=r[g];p[v]={x:a[2*g],y:a[2*g+1],radius:o[v].radius}}return e(p,i)},l,n).x;for(let a=0;a<r.length;++a){let p=r[a];o[p].x=u[2*a],o[p].y=u[2*a+1]}return o}d(Zt,"venn");var Jt=1e-10;function It(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Jt?Math.abs(t-n):Te(e=>Dt(t,n,e)-s,0,t+n)}d(It,"distanceFromIntersectArea");function ze(t,n={}){let s=n.distinct,e=t.map(l=>Object.assign({},l));function i(l){return l.join(";")}if(d(i,"toKey"),s){let l=new Map;for(let f of e)for(let u=0;u<f.sets.length;u++){let a=String(f.sets[u]);l.set(a,f.size+(l.get(a)||0));for(let p=u+1;p<f.sets.length;p++){let g=String(f.sets[p]),v=`${a};${g}`,m=`${g};${a}`;l.set(v,f.size+(l.get(v)||0)),l.set(m,f.size+(l.get(m)||0))}}for(let f of e)f.sets.length<3&&(f.size=l.get(i(f.sets)))}let o=[],r=new Set;for(let l of e)if(l.sets.length===1)o.push(l.sets[0]);else if(l.sets.length===2){let f=l.sets[0],u=l.sets[1];r.add(i(l.sets)),r.add(i([u,f]))}o.sort((l,f)=>l===f?0:l<f?-1:1);for(let l=0;l<o.length;++l){let f=o[l];for(let u=l+1;u<o.length;++u){let a=o[u];r.has(i([f,a]))||e.push({sets:[f,a],size:0})}}return e}d(ze,"addMissingAreas");function Ae(t,n,s){let e=Wt(n.length,n.length),i=Wt(n.length,n.length);return t.filter(o=>o.sets.length===2).forEach(o=>{let r=s[o.sets[0]],l=s[o.sets[1]],f=Math.sqrt(n[r].size/Math.PI),u=Math.sqrt(n[l].size/Math.PI),a=It(f,u,o.size);e[r][l]=e[l][r]=a;let p=0;o.size+1e-10>=Math.min(n[r].size,n[l].size)?p=1:o.size<=1e-10&&(p=-1),i[r][l]=i[l][r]=p}),{distances:e,constraints:i}}d(Ae,"getDistanceMatrices");function Re(t,n,s,e){for(let o=0;o<n.length;++o)n[o]=0;let i=0;for(let o=0;o<s.length;++o){let r=t[2*o],l=t[2*o+1];for(let f=o+1;f<s.length;++f){let u=t[2*f],a=t[2*f+1],p=s[o][f],g=e[o][f],v=(u-r)*(u-r)+(a-l)*(a-l),m=Math.sqrt(v),S=v-p*p;g>0&&m<=p||g<0&&m>=p||(i+=2*S*S,n[2*o]+=4*S*(r-u),n[2*o+1]+=4*S*(l-a),n[2*f]+=4*S*(u-r),n[2*f+1]+=4*S*(a-l))}}return i}d(Re,"constrainedMDSGradient");function Ce(t,n={}){let s=Oe(t,n),e=n.lossFunction||tt;if(t.length>=8){let i=Ve(t,n),o=e(i,t),r=e(s,t);o+1e-8<r&&(s=i)}return s}d(Ce,"bestInitialLayout");function Ve(t,n={}){let s=n.restarts||10,e=[],i={};for(let g of t)g.sets.length===1&&(i[g.sets[0]]=e.length,e.push(g));let{distances:o,constraints:r}=Ae(t,e,i),l=kt(o.map(kt))/o.length;o=o.map(g=>g.map(v=>v/l));let f=d((g,v)=>Re(g,v,o,r),"obj"),u=null;for(let g=0;g<s;++g){let v=vt(o.length*2).map(Math.random),m=_e(f,v,n);(!u||m.fx<u.fx)&&(u=m)}let a=u.x,p={};for(let g=0;g<e.length;++g){let v=e[g];p[v.sets[0]]={x:a[2*g]*l,y:a[2*g+1]*l,radius:Math.sqrt(v.size/Math.PI)}}if(n.history)for(let g of n.history)Mt(g.x,l);return p}d(Ve,"constrainedMDSLayout");function Oe(t,n){let s=n&&n.lossFunction?n.lossFunction:tt,e={},i={};for(let p of t)if(p.sets.length===1){let g=p.sets[0];e[g]={x:1e10,y:1e10,rowid:e.length,size:p.size,radius:Math.sqrt(p.size/Math.PI)},i[g]=[]}t=t.filter(p=>p.sets.length===2);for(let p of t){let g=p.weight!=null?p.weight:1,v=p.sets[0],m=p.sets[1];p.size+Jt>=Math.min(e[v].size,e[m].size)&&(g=0),i[v].push({set:m,size:p.size,weight:g}),i[m].push({set:v,size:p.size,weight:g})}let o=[];Object.keys(i).forEach(p=>{let g=0;for(let v=0;v<i[p].length;++v)g+=i[p][v].size*i[p][v].weight;o.push({set:p,size:g})});function r(p,g){return g.size-p.size}d(r,"sortOrder"),o.sort(r);let l={};function f(p){return p.set in l}d(f,"isPositioned");function u(p,g){e[g].x=p.x,e[g].y=p.y,l[g]=!0}d(u,"positionSet"),u({x:0,y:0},o[0].set);for(let p=1;p<o.length;++p){let g=o[p].set,v=i[g].filter(f),m=e[g];if(v.sort(r),v.length===0)throw"ERROR: missing pairwise overlap information";let S=[];for(var a=0;a<v.length;++a){let D=e[v[a].set],x=It(m.radius,D.radius,v[a].size);S.push({x:D.x+x,y:D.y}),S.push({x:D.x-x,y:D.y}),S.push({y:D.y+x,x:D.x}),S.push({y:D.y-x,x:D.x});for(let b=a+1;b<v.length;++b){let k=e[v[b].set],c=It(m.radius,k.radius,v[b].size),y=Ht({x:D.x,y:D.y,radius:x},{x:k.x,y:k.y,radius:c});S.push(...y)}}let E=1e50,w=S[0];for(let D of S){e[g].x=D.x,e[g].y=D.y;let x=s(e,t);x<E&&(E=x,w=D)}u(w,g)}return e}d(Oe,"greedyLayout");function tt(t,n){let s=0;for(let e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){let r=t[e.sets[0]],l=t[e.sets[1]];i=Dt(r.radius,l.radius,G(r,l))}else i=at(e.sets.map(r=>t[r]));let o=e.weight!=null?e.weight:1;s+=o*(i-e.size)*(i-e.size)}return s}d(tt,"lossFunction");function Qt(t,n){let s=0;for(let e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){let l=t[e.sets[0]],f=t[e.sets[1]];i=Dt(l.radius,f.radius,G(l,f))}else i=at(e.sets.map(l=>t[l]));let o=e.weight!=null?e.weight:1,r=Math.log((i+1)/(e.size+1));s+=o*r*r}return s}d(Qt,"logRatioLossFunction");function Ne(t,n,s){if(s==null?t.sort((i,o)=>o.radius-i.radius):t.sort(s),t.length>0){let i=t[0].x,o=t[0].y;for(let r of t)r.x-=i,r.y-=o}if(t.length===2&&G(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){let i=Math.atan2(t[1].x,t[1].y)-n,o=Math.cos(i),r=Math.sin(i);for(let l of t){let f=l.x,u=l.y;l.x=o*f-r*u,l.y=r*f+o*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){let o=t[1].y/(1e-10+t[1].x);for(let r of t){var e=(r.x+o*r.y)/(1+o*o);r.x=2*e-r.x,r.y=2*e*o-r.y}}}}d(Ne,"orientateCircles");function je(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}d(n,"find");function s(i,o){let r=n(i),l=n(o);r.parent=l}d(s,"union");for(let i=0;i<t.length;++i)for(let o=i+1;o<t.length;++o){let r=t[i].radius+t[o].radius;G(t[i],t[o])+1e-10<r&&s(t[o],t[i])}let e=new Map;for(let i=0;i<t.length;++i){let o=n(t[i]).parent.setid;e.has(o)||e.set(o,[]),e.get(o).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}d(je,"disjointCluster");function St(t){let n=d(s=>{let e=t.reduce((o,r)=>Math.max(o,r[s]+r.radius),Number.NEGATIVE_INFINITY),i=t.reduce((o,r)=>Math.min(o,r[s]-r.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}},"minMax");return{xRange:n("x"),yRange:n("y")}}d(St,"getBoundingBox");function $t(t,n,s){n==null&&(n=Math.PI/2);let e=ne(t).map(u=>Object.assign({},u)),i=je(e);for(let u of i){Ne(u,n,s);let a=St(u);u.size=(a.xRange.max-a.xRange.min)*(a.yRange.max-a.yRange.min),u.bounds=a}i.sort((u,a)=>a.size-u.size),e=i[0];let o=e.bounds,r=(o.xRange.max-o.xRange.min)/50;function l(u,a,p){if(!u)return;let g=u.bounds,v,m;if(a)v=o.xRange.max-g.xRange.min+r;else{v=o.xRange.max-g.xRange.max;let S=(g.xRange.max-g.xRange.min)/2-(o.xRange.max-o.xRange.min)/2;S<0&&(v+=S)}if(p)m=o.yRange.max-g.yRange.min+r;else{m=o.yRange.max-g.yRange.max;let S=(g.yRange.max-g.yRange.min)/2-(o.yRange.max-o.yRange.min)/2;S<0&&(m+=S)}for(let S of u)S.x+=v,S.y+=m,e.push(S)}d(l,"addCluster");let f=1;for(;f<i.length;)l(i[f],!0,!1),l(i[f+1],!1,!0),l(i[f+2],!0,!0),f+=3,o=St(e);return ee(e)}d($t,"normalizeSolution");function te(t,n,s,e,i){let o=ne(t);n-=2*e,s-=2*e;let{xRange:r,yRange:l}=St(o);if(r.max===r.min||l.max===l.min)return console.log("not scaling solution: zero size detected"),t;let f,u;if(i){let v=Math.sqrt(i/Math.PI)*2;f=n/v,u=s/v}else f=n/(r.max-r.min),u=s/(l.max-l.min);let a=Math.min(u,f),p=(n-(r.max-r.min)*a)/2,g=(s-(l.max-l.min)*a)/2;return ee(o.map(v=>({radius:a*v.radius,x:e+p+(v.x-r.min)*a,y:e+g+(v.y-l.min)*a,setid:v.setid})))}d(te,"scaleSolution");function ee(t){let n={};for(let s of t)n[s.setid]=s;return n}d(ee,"toObjectNotation");function ne(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}d(ne,"fromObjectNotation");function se(t={}){let n=!1,s=600,e=350,i=15,o=1e3,r=Math.PI/2,l=!0,f=null,u=!0,a=!0,p=null,g=null,v=!1,m=null,S=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,E={},w=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D=0,x=d(function(y){if(y in E)return E[y];var h=E[y]=w[D];return D+=1,D>=w.length&&(D=0),h},"colours"),b=Zt,k=tt;function c(y){let h=y.datum(),A=new Set;h.forEach(M=>{M.size==0&&M.sets.length==1&&A.add(M.sets[0])}),h=h.filter(M=>!M.sets.some(F=>A.has(F)));let I={},R={};if(h.length>0){let M=b(h,{lossFunction:k,distinct:v});l&&(M=$t(M,r,g)),I=te(M,s,e,i,f),R=oe(I,h,S)}let U={};h.forEach(M=>{M.label&&(U[M.sets]=M.label)});function P(M){if(M.sets in U)return U[M.sets];if(M.sets.length==1)return""+M.sets[0]}d(P,"label"),y.selectAll("svg").data([I]).enter().append("svg");let V=y.select("svg");n?V.attr("viewBox",`0 0 ${s} ${e}`):V.attr("width",s).attr("height",e);let z={},C=!1;V.selectAll(".venn-area path").each(function(M){let F=this.getAttribute("d");M.sets.length==1&&F&&!v&&(C=!0,z[M.sets[0]]=Pe(F))});function T(M){return F=>{let et=M.sets.map(Z=>{let Y=z[Z],q=I[Z];return Y||(Y={x:s/2,y:e/2,radius:1}),q||(q={x:s/2,y:e/2,radius:1}),{x:Y.x*(1-F)+q.x*F,y:Y.y*(1-F)+q.y*F,radius:Y.radius*(1-F)+q.radius*F}});return Kt(et,m)}}d(T,"pathTween");let O=V.selectAll(".venn-area").data(h,M=>M.sets),B=O.enter().append("g").attr("class",M=>`venn-area venn-${M.sets.length==1?"circle":"intersection"}${M.colour||M.color?" venn-coloured":""}`).attr("data-venn-sets",M=>M.sets.join("_")),N=B.append("path"),j=B.append("text").attr("class","label").text(M=>P(M)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);a&&(N.style("fill-opacity","0").filter(M=>M.sets.length==1).style("fill",M=>M.colour?M.colour:M.color?M.color:x(M.sets)).style("fill-opacity",".25"),j.style("fill",M=>M.colour||M.color?"#FFF":t.textFill?t.textFill:M.sets.length==1?x(M.sets):"#444"));function H(M){return typeof M.transition=="function"?M.transition("venn").duration(o):M}d(H,"asTransition");let L=y;C&&typeof L.transition=="function"?(L=H(y),L.selectAll("path").attrTween("d",T)):L.selectAll("path").attr("d",M=>Kt(M.sets.map(F=>I[F])),m);let _=L.selectAll("text").filter(M=>M.sets in R).text(M=>P(M)).attr("x",M=>Math.floor(R[M.sets].x)).attr("y",M=>Math.floor(R[M.sets].y));u&&(C?"on"in _?_.on("end",pt(I,P)):_.each("end",pt(I,P)):_.each(pt(I,P)));let X=H(O.exit()).remove();typeof O.transition=="function"&&X.selectAll("path").attrTween("d",T);let W=X.selectAll("text").attr("x",s/2).attr("y",e/2);return p!==null&&(j.style("font-size","0px"),_.style("font-size",p),W.style("font-size","0px")),{circles:I,textCentres:R,nodes:O,enter:B,update:L,exit:X}}return d(c,"chart"),c.wrap=function(y){return arguments.length?(u=y,c):u},c.useViewBox=function(){return n=!0,c},c.width=function(y){return arguments.length?(s=y,c):s},c.height=function(y){return arguments.length?(e=y,c):e},c.padding=function(y){return arguments.length?(i=y,c):i},c.distinct=function(y){return arguments.length?(v=y,c):v},c.colours=function(y){return arguments.length?(x=y,c):x},c.colors=function(y){return arguments.length?(x=y,c):x},c.fontSize=function(y){return arguments.length?(p=y,c):p},c.round=function(y){return arguments.length?(m=y,c):m},c.duration=function(y){return arguments.length?(o=y,c):o},c.layoutFunction=function(y){return arguments.length?(b=y,c):b},c.normalize=function(y){return arguments.length?(l=y,c):l},c.scaleToFit=function(y){return arguments.length?(f=y,c):f},c.styled=function(y){return arguments.length?(a=y,c):a},c.orientation=function(y){return arguments.length?(r=y,c):r},c.orientationOrder=function(y){return arguments.length?(g=y,c):g},c.lossFunction=function(y){return arguments.length?(k=y==="default"?tt:y==="logRatio"?Qt:y,c):k},c}d(se,"VennDiagram");function pt(t,n){return function(s){let e=this,i=t[s.sets[0]].radius||50,o=n(s)||"",r=o.split(/\s+/).reverse(),f=(o.length+r.length)/3,u=r.pop(),a=[u],p=0,g=1.1;e.textContent=null;let v=[];function m(x){let b=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return b.textContent=x,v.push(b),e.append(b),b}d(m,"append");let S=m(u);for(;u=r.pop(),!!u;){a.push(u);let x=a.join(" ");S.textContent=x,x.length>f&&S.getComputedTextLength()>i&&(a.pop(),S.textContent=a.join(" "),a=[u],S=m(u),p++)}let E=.35-p*g/2,w=e.getAttribute("x"),D=e.getAttribute("y");v.forEach((x,b)=>{x.setAttribute("x",w),x.setAttribute("y",D),x.setAttribute("dy",`${E+b*g}em`)})}}d(pt,"wrapText");function mt(t,n,s){let e=n[0].radius-G(n[0],t);for(let i=1;i<n.length;++i){let o=n[i].radius-G(n[i],t);o<=e&&(e=o)}for(let i=0;i<s.length;++i){let o=G(s[i],t)-s[i].radius;o<=e&&(e=o)}return e}d(mt,"circleMargin");function ie(t,n,s){let e=[];for(let a of t)e.push({x:a.x,y:a.y}),e.push({x:a.x+a.radius/2,y:a.y}),e.push({x:a.x-a.radius/2,y:a.y}),e.push({x:a.x,y:a.y+a.radius/2}),e.push({x:a.x,y:a.y-a.radius/2});let i=e[0],o=mt(e[0],t,n);for(let a=1;a<e.length;++a){let p=mt(e[a],t,n);p>=o&&(i=e[a],o=p)}let r=Xt(a=>-1*mt({x:a[0],y:a[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,l={x:s?0:r[0],y:r[1]},f=!0;for(let a of t)if(G(l,a)>a.radius){f=!1;break}for(let a of n)if(G(l,a)<a.radius){f=!1;break}if(f)return l;if(t.length==1)return{x:t[0].x,y:t[0].y};let u={};return at(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?ie(t,[]):Yt(u.arcs.map(a=>a.p1))}d(ie,"computeTextCentre");function Le(t){let n={},s=Object.keys(t);for(let e of s)n[e]=[];for(let e=0;e<s.length;e++){let i=s[e],o=t[i];for(let r=e+1;r<s.length;++r){let l=s[r],f=t[l],u=G(o,f);u+f.radius<=o.radius+1e-10?n[l].push(i):u+o.radius<=f.radius+1e-10&&n[i].push(l)}}return n}d(Le,"getOverlappingCircles");function oe(t,n,s){let e={},i=Le(t);for(let o=0;o<n.length;++o){let r=n[o].sets,l={},f={};for(let g=0;g<r.length;++g){l[r[g]]=!0;let v=i[r[g]];for(let m=0;m<v.length;++m)f[v[m]]=!0}let u=[],a=[];for(let g in t)g in l?u.push(t[g]):g in f||a.push(t[g]);let p=ie(u,a,s);e[r]=p,p.disjoint&&n[o].size>0&&console.log("WARNING: area "+r+" not represented on screen")}return e}d(oe,"computeTextCentres");function Fe(t,n,s){let e=[];return e.push(` M`,t,n),e.push(` m`,-s,0),e.push(` a`,s,s,0,1,0,s*2,0),e.push(` a`,s,s,0,1,0,-s*2,0),e.join(" ")}d(Fe,"circlePath");function Pe(t){let n=t.split(" ");return{x:Number.parseFloat(n[1]),y:Number.parseFloat(n[2]),radius:-Number.parseFloat(n[4])}}d(Pe,"circleFromPath");function re(t){if(t.length===0)return[];let n={};return at(t,n),n.arcs}d(re,"intersectionAreaArcs");function ae(t,n){if(t.length===0)return"M 0 0";let s=Math.pow(10,n||0),e=n!=null?o=>Math.round(o*s)/s:o=>o;if(t.length==1){let o=t[0].circle;return Fe(e(o.x),e(o.y),e(o.radius))}let i=[` M`,e(t[0].p2.x),e(t[0].p2.y)];for(let o of t){let r=e(o.circle.radius);i.push(` A`,r,r,0,o.large?1:0,o.sweep?1:0,e(o.p1.x),e(o.p1.y))}return i.join(" ")}d(ae,"arcsToPath");function Kt(t,n){return ae(re(t),n)}d(Kt,"intersectionAreaPath");function le(t,n={}){let{lossFunction:s,layoutFunction:e=Zt,normalize:i=!0,orientation:o=Math.PI/2,orientationOrder:r,width:l=600,height:f=350,padding:u=15,scaleToFit:a=!1,symmetricalTextCentre:p=!1,distinct:g,round:v=2}=n,m=e(t,{lossFunction:s==="default"||!s?tt:s==="logRatio"?Qt:s,distinct:g});i&&(m=$t(m,o,r));let S=te(m,l,f,u,a),E=oe(S,t,p),w=new Map(Object.keys(S).map(b=>[b,{set:b,x:S[b].x,y:S[b].y,radius:S[b].radius}])),D=t.map(b=>{let k=b.sets.map(h=>w.get(h)),c=re(k),y=ae(c,v);return{circles:k,arcs:c,path:y,area:b,has:new Set(b.sets)}});function x(b){let k="";for(let c of D)c.has.size>b.length&&b.every(y=>c.has.has(y))&&(k+=" "+c.path);return k}return d(x,"genDistinctPath"),D.map(({circles:b,arcs:k,path:c,area:y})=>({data:y,text:E[y.sets],circles:b,arcs:k,path:c,distinctPath:c+x(y.sets)}))}d(le,"layout");function qe(t){let n=new Map;for(let s of t){let e=s.targets.join("|"),i=n.get(e);i?Object.assign(i,s.styles):n.set(e,{...s.styles})}return n}d(qe,"buildStyleByKey");var Ge=d((t,n,s,e)=>{let i=e.db,o=i.getConfig?.(),{themeVariables:r,look:l,handDrawnSeed:f}=it(),u=l==="handDrawn",a=[r.venn1,r.venn2,r.venn3,r.venn4,r.venn5,r.venn6,r.venn7,r.venn8].filter(Boolean),p=i.getDiagramTitle?.(),g=i.getSubsetData(),v=i.getTextData(),m=qe(i.getStyleData()),S=We(g),E=o?.width??800,w=o?.height??450,x=E/1600,b=p?48*x:0,k=r.primaryTextColor??r.textColor,c=Bt(n);c.attr("viewBox",`0 0 ${E} ${w}`),p&&c.append("text").text(p).attr("class","venn-title").attr("font-size",`${32*x}px`).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("x","50%").attr("y",32*x).style("fill",r.vennTitleTextColor||r.titleColor);let y=ot(document.createElement("div")),h=se().width(E).height(w-b);y.datum(S).call(h);let A=u?Pt.svg(y.select("svg").node()):void 0,I=le(S,{width:E,height:w-b,padding:o?.padding??15}),R=new Map;for(let z of I){let C=Q([...z.data.sets].sort());R.set(C,z)}v.length>0&&Ue(o,R,y,v,x,m);let U=Tt(r.background||"#f4f4f4");y.selectAll(".venn-circle").each(function(z,C){let T=ot(this),B=Q([...z.sets].sort()),N=m.get(B),j=N?.fill||a[C%a.length]||r.primaryColor;T.classed(`venn-set-${C%8}`,!0);let H=N?.["fill-opacity"]??.1,L=N?.stroke||j,_=N?.["stroke-width"]||`${5*x}`;if(u&&A){let W=R.get(B);if(W&&W.circles.length>0){let M=W.circles[0],F=A.circle(M.x,M.y,M.radius*2,{roughness:.7,seed:f,fill:ct(j,.7),fillStyle:"hachure",fillWeight:2,hachureGap:8,hachureAngle:-41+C*60,stroke:L,strokeWidth:parseFloat(String(_))});T.select("path").remove(),T.node()?.insertBefore(F,T.select("text").node())}}else T.select("path").style("fill",j).style("fill-opacity",H).style("stroke",L).style("stroke-width",_).style("stroke-opacity",.95);let X=N?.color||(U?Et(j,30):_t(j,30));T.select("text").style("font-size",`${48*x}px`).style("fill",X)}),u&&A?y.selectAll(".venn-intersection").each(function(z){let C=ot(this),O=Q([...z.sets].sort()),B=m.get(O),N=B?.fill;if(N){let j=C.select("path"),H=j.attr("d");if(H){let L=A.path(H,{roughness:.7,seed:f,fill:ct(N,.3),fillStyle:"cross-hatch",fillWeight:2,hachureGap:6,hachureAngle:60,stroke:"none"}),_=j.node();_?.parentNode?.insertBefore(L,_),j.remove()}}else C.select("path").style("fill-opacity",0);C.select("text").style("font-size",`${48*x}px`).style("fill",B?.color??r.vennSetTextColor??k)}):(y.selectAll(".venn-intersection text").style("font-size",`${48*x}px`).style("fill",z=>{let T=Q([...z.sets].sort());return m.get(T)?.color??r.vennSetTextColor??k}),y.selectAll(".venn-intersection path").style("fill-opacity",z=>{let T=Q([...z.sets].sort());return m.get(T)?.fill?1:0}).style("fill",z=>{let T=Q([...z.sets].sort());return m.get(T)?.fill??"transparent"}));let P=c.append("g").attr("transform",`translate(0, ${b})`),V=y.select("svg").node();if(V&&"childNodes"in V)for(let z of[...V.childNodes])P.node()?.appendChild(z);At(c,w,E,o?.useMaxWidth??!0)},"draw");function Q(t){return t.join("|")}d(Q,"stableSetsKey");function Ue(t,n,s,e,i,o){let r=t?.useDebugLayout??!1,f=s.select("svg").append("g").attr("class","venn-text-nodes"),u=new Map;for(let a of e){let p=Q(a.sets),g=u.get(p);g?g.push(a):u.set(p,[a])}for(let[a,p]of u.entries()){let g=n.get(a);if(!g?.text)continue;let v=g.text.x,m=g.text.y,S=Math.min(...g.circles.map(V=>V.radius)),E=Math.min(...g.circles.map(V=>V.radius-Math.hypot(v-V.x,m-V.y))),w=Number.isFinite(E)?Math.max(0,E):0;w===0&&Number.isFinite(S)&&(w=S*.6);let D=f.append("g").attr("class","venn-text-area").attr("font-size",`${40*i}px`);r&&D.append("circle").attr("class","venn-text-debug-circle").attr("cx",v).attr("cy",m).attr("r",w).attr("fill","none").attr("stroke","purple").attr("stroke-width",1.5*i).attr("stroke-dasharray",`${6*i} ${4*i}`);let x=Math.max(80*i,w*2*.95),b=Math.max(60*i,w*2*.95),y=(g.data.label&&g.data.label.length>0?Math.min(32*i,w*.25):0)+(p.length<=2?30*i:0),h=v-x/2,A=m-b/2+y,I=Math.max(1,Math.ceil(Math.sqrt(p.length))),R=Math.max(1,Math.ceil(p.length/I)),U=x/I,P=b/R;for(let[V,z]of p.entries()){let C=V%I,T=Math.floor(V/I),O=h+U*(C+.5),B=A+P*(T+.5);r&&D.append("rect").attr("class","venn-text-debug-cell").attr("x",h+U*C).attr("y",A+P*T).attr("width",U).attr("height",P).attr("fill","none").attr("stroke","teal").attr("stroke-width",1*i).attr("stroke-dasharray",`${4*i} ${3*i}`);let N=U*.9,j=P*.9,H=D.append("foreignObject").attr("class","venn-text-node-fo").attr("width",N).attr("height",j).attr("x",O-N/2).attr("y",B-j/2).attr("overflow","visible"),L=o.get(z.id)?.color,_=H.append("xhtml:span").attr("class","venn-text-node").style("display","flex").style("width","100%").style("height","100%").style("white-space","normal").style("align-items","center").style("justify-content","center").style("text-align","center").style("overflow-wrap","normal").style("word-break","normal").text(z.label??z.id);L&&_.style("color",L)}}}d(Ue,"renderTextNodes");function We(t){let n=new Set(t.map(i=>[...i.sets].sort().join("|"))),s=new Map(t.filter(i=>i.sets.length===1&&i.size!==void 0).map(i=>[i.sets[0],i.size])),e=[];for(let i of t){if(i.sets.length<3)continue;let o=[...i.sets].sort();for(let r=0;r<o.length-1;r++)for(let l=r+1;l<o.length;l++){let f=[o[r],o[l]],u=f.join("|");if(!n.has(u)){n.add(u);let a=s.get(f[0]),p=s.get(f[1]),g=a!==void 0&&p!==void 0?Math.min(a,p)/4:2.5;e.push({sets:f,size:g,label:""})}}}return e.length>0?[...t,...e]:t}d(We,"ensurePairwiseSubsets");var ce={draw:Ge};var yn={parser:qt,db:Gt,renderer:ce,styles:Ut};export{yn as diagram};