Files
build_notes_simengweb/assets/vennDiagram-R4MEU4WM-Dvbyfwqt.js
2026-03-29 16:10:06 +08:00

35 lines
41 KiB
JavaScript

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