UNPKG

chartjs-chart-venn

Version:
3 lines (2 loc) 39.3 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("chart.js")):"function"==typeof define&&define.amd?define(["exports","chart.js"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ChartVenn={},e.Chart)}(this,(function(e,t){"use strict";function r(e){return"number"==typeof e.rx}function s(e,t){return r=e.cx-t.cx,s=e.cy-t.cy,Math.sqrt(r*r+s*s);var r,s}const o=1/180*Math.PI;function a(e,t,r,s){return{x:e+Math.cos(s*o)*r,y:t+Math.sin(s*o)*r}}class n extends t.Element{inRange(e,t){var a;const n=this.getProps(["arcs","refs","sets"]),i=new Set(n.sets);function x(e,t,a){if(r(t)){const r=t.rotation*o,s=e.cx-t.cx,n=e.cy-t.cy,i=(s*Math.cos(r)+n*Math.sin(r))**2/t.rx**2+(s*Math.sin(r)-n*Math.cos(r))**2/t.ry**2;if(a&&i>1||!a&&i<1)return!1}else{const r=s(e,t);if(a&&r>t.r||!a&&r<t.r)return!1}return!0}for(const r of null!==(a=n.arcs)&&void 0!==a?a:[]){const s=n.refs[r.ref],o={cx:Number.isNaN(e)?s.cx:e,cy:Number.isNaN(t)?s.cy:t};if(i.delete(r.ref),!x(o,s,"i"===r.mode))return!1}const l=Array.from(i);for(let r=0;r<l.length;r+=1){const s=n.refs[l[r]];if(!x({cx:Number.isNaN(e)?s.cx:e,cy:Number.isNaN(t)?s.cy:t},s,!0))return!1}return!0}inXRange(e){return this.inRange(e,Number.NaN)}inYRange(e){return this.inRange(Number.NaN,e)}getCenterPoint(){return this.getProps(["text"]).text}tooltipPosition(){return this.getCenterPoint()}hasValue(){return!0}draw(e){e.save();const t=this.options,s=this.getProps(["x1","y1","arcs","refs"]);let o;if(e.beginPath(),window.Path2D)o=new Path2D(function(e,t,s=0){return e.path?e.path:`M ${e.x1-s},${e.y1-s} ${e.arcs.map((e=>{const o=t[e.ref],a=r(o)?o.rx:o.r,n=r(o)?o.ry:o.r,i=r(o)?o.rotation:0;return`A ${a-s} ${n-s} ${i} ${e.large?1:0} ${e.sweep?1:0} ${e.x2-s} ${e.y2-s}`})).join(" ")}`}(s,s.refs));else{e.beginPath(),e.moveTo(s.x1,s.y1);for(const t of s.arcs){const o=s.refs[t.ref],a=r(o)?o.rx:o.r,n=r(o)?o.ry:o.r,i=r(o)?o.rotation:0;e.ellipse(o.cx,o.cy,a,n,i,0,2*Math.PI,!t.sweep)}e.closePath()}t.backgroundColor&&(e.fillStyle=t.backgroundColor,o?e.fill(o):e.fill()),t.borderColor&&(e.strokeStyle=t.borderColor,e.lineWidth=t.borderWidth,o?e.stroke(o):e.stroke()),e.restore()}}n.id="arcSlice",n.defaults={...t.BarElement.defaults,backgroundColor:"#efefef"},n.defaultRoutes={borderColor:"borderColor"};var i={sets:[],intersections:[],bb:{x:0,y:0,width:10,height:10}},x={sets:[{cx:0,cy:0,r:5,text:{x:3.5,y:-4},align:"start",verticalAlign:"bottom"}],intersections:[{sets:[0],x1:0,y1:5,arcs:[{mode:"i",ref:0,x2:0,y2:-5,sweep:!1,large:!1},{mode:"i",ref:0,x2:0,y2:5,sweep:!1,large:!1}],text:{x:0,y:0}}],bb:{x:-5,y:-5,width:10,height:10}},l={sets:[{cx:-4,cy:0,r:5,text:{x:-7.5,y:4},align:"end",verticalAlign:"top"},{cx:4,cy:0,r:5,text:{x:7.5,y:-4},align:"start",verticalAlign:"bottom"}],intersections:[{sets:[0],x1:0,y1:-3,arcs:[{mode:"i",ref:0,x2:0,y2:3,sweep:!1,large:!0},{mode:"o",ref:1,x2:0,y2:-3,sweep:!0,large:!1}],text:{x:-4,y:0}},{sets:[1],x1:0,y1:3,arcs:[{mode:"i",ref:1,x2:0,y2:-3,sweep:!1,large:!0},{mode:"o",ref:0,x2:0,y2:3,sweep:!0,large:!1}],text:{x:4,y:0}},{sets:[0,1],x1:0,y1:3,arcs:[{mode:"i",ref:0,x2:0,y2:-3,sweep:!1,large:!1},{mode:"i",ref:1,x2:0,y2:3,sweep:!1,large:!1}],text:{x:0,y:0}}],bb:{x:-9,y:-5,width:18,height:10}},c={sets:[{cx:-3.464,cy:-2,r:5,text:{x:-7,y:-6},align:"end"},{cx:3.464,cy:-2,r:5,text:{x:7,y:-6},align:"start"},{cx:0,cy:4,r:5,text:{x:4,y:7.5},align:"start",verticalAlign:"top"}],intersections:[{sets:[0],x1:-4.855,y1:2.803,arcs:[{mode:"o",ref:2,x2:-1.39,y2:-.803,sweep:!0,large:!1},{mode:"o",ref:1,x2:0,y2:-5.606,sweep:!0,large:!1},{mode:"i",ref:0,x2:-4.855,y2:2.803,sweep:!1,large:!0}],text:{x:-4.216,y:-2.434}},{sets:[1],x1:0,y1:-5.606,arcs:[{mode:"o",ref:0,x2:1.39,y2:-.803,sweep:!0,large:!1},{mode:"o",ref:2,x2:4.855,y2:2.803,sweep:!0,large:!1},{mode:"i",ref:1,x2:0,y2:-5.606,sweep:!1,large:!0}],text:{x:4.216,y:-2.434}},{sets:[2],x1:-4.855,y1:2.803,arcs:[{mode:"o",ref:0,x2:0,y2:1.606,sweep:!1,large:!1},{mode:"o",ref:1,x2:4.855,y2:2.803,sweep:!1,large:!1},{mode:"i",ref:2,x2:-4.855,y2:2.803,sweep:!0,large:!0}],text:{x:0,y:4.869}},{sets:[0,1],x1:0,y1:-5.606,arcs:[{mode:"i",ref:1,x2:-1.39,y2:-.803,sweep:!1,large:!1},{mode:"o",ref:2,x2:1.39,y2:-.803,sweep:!0,large:!1},{mode:"i",ref:0,x2:0,y2:-5.606,sweep:!1,large:!1}],text:{x:0,y:-2.404}},{sets:[0,2],x1:-4.855,y1:2.803,arcs:[{mode:"i",ref:2,x2:-1.39,y2:-.803,sweep:!0,large:!1},{mode:"o",ref:1,x2:0,y2:1.606,sweep:!1,large:!1},{mode:"i",ref:0,x2:-4.855,y2:2.803,sweep:!0,large:!1}],text:{x:-2.082,y:1.202}},{sets:[1,2],x1:4.855,y1:2.803,arcs:[{mode:"i",ref:2,x2:1.39,y2:-.803,sweep:!1,large:!1},{mode:"o",ref:0,x2:0,y2:1.606,sweep:!0,large:!1},{mode:"i",ref:1,x2:4.855,y2:2.803,sweep:!1,large:!1}],text:{x:2.082,y:1.202}},{sets:[0,1,2],x1:1.39,y1:-.803,arcs:[{mode:"i",ref:0,x2:0,y2:1.606,sweep:!0,large:!1},{mode:"i",ref:1,x2:-1.39,y2:-.803,sweep:!0,large:!1},{mode:"i",ref:2,x2:1.39,y2:-.803,sweep:!0,large:!1}],text:{x:0,y:0}}],bb:{x:-8.464,y:-7,width:16.928,height:16}},y={sets:[{cx:.439,cy:-1.061,rx:2.5,ry:5,rotation:45,text:{x:4.5,y:-4.5},align:"start",verticalAlign:"bottom"},{cx:2.561,cy:1.061,rx:2.5,ry:5,rotation:45,text:{x:4,y:3.75},align:"start",verticalAlign:"top"},{cx:-2.561,cy:1.061,rx:2.5,ry:5,rotation:-45,text:{x:-4,y:3.7},align:"end",verticalAlign:"top"},{cx:-.439,cy:-1.061,rx:2.5,ry:5,rotation:-45,text:{x:-4.5,y:-4.5},align:"end",verticalAlign:"bottom"}],intersections:[{sets:[0],x1:0,y1:-3.94,arcs:[{ref:0,mode:"i",x2:4.328,y2:-2.828,sweep:!0,large:!1},{ref:1,mode:"o",x2:2.179,y2:-1.858,large:!1},{ref:3,mode:"o",x2:0,y2:-3.94,large:!1}],text:{x:2.914,y:-3.536}},{sets:[1],x1:4.328,y1:-2.828,arcs:[{ref:1,mode:"i",x2:0,y2:5.006,sweep:!0,large:!0},{ref:2,mode:"o",x2:1.328,y2:2.828},{ref:3,mode:"o",x2:3.108,y2:-.328},{ref:0,mode:"o",x2:4.328,y2:-2.828}],text:{x:5.036,y:-1.414}},{sets:[2],x1:0,y1:5.006,arcs:[{ref:2,mode:"i",x2:-4.328,y2:-2.828,sweep:!0,large:!0},{ref:3,mode:"o",x2:-3.108,y2:-.328},{ref:0,mode:"o",x2:-1.328,y2:2.828},{ref:1,mode:"o",x2:0,y2:5.006}],text:{x:-5.036,y:-1.414}},{sets:[3],x1:-4.328,y1:-2.828,arcs:[{ref:3,mode:"i",x2:0,y2:-3.94,sweep:!0,large:!1},{ref:0,mode:"o",x2:-2.179,y2:-1.858,large:!1},{ref:2,mode:"o",x2:-4.328,y2:-2.828,large:!1}],text:{x:-2.914,y:-3.536}},{sets:[0,1],x1:4.328,y1:-2.828,arcs:[{ref:1,mode:"i",x2:3.108,y2:-.328,sweep:!0,large:!1},{ref:3,mode:"o",x2:2.179,y2:-1.858,sweep:!1,large:!1},{ref:0,mode:"i",x2:4.328,y2:-2.828,sweep:!0,large:!1}],text:{x:3.205,y:-1.672}},{sets:[0,2],x1:-1.328,y1:2.828,arcs:[{ref:0,mode:"i",x2:-3.108,y2:-.328,sweep:!0,large:!1},{ref:3,mode:"o",x2:-.969,y2:1.755,large:!1},{ref:1,mode:"o",x2:-1.328,y2:2.828,large:!1}],text:{x:-2.212,y:1.591}},{sets:[0,3],x1:0,y1:-3.94,arcs:[{ref:3,mode:"i",x2:2.179,y2:-1.858,sweep:!0,large:!1},{ref:1,mode:"o",x2:0,y2:.188,sweep:!1,large:!1},{ref:2,mode:"o",x2:-2.179,y2:-1.858,sweep:!1,large:!1},{ref:0,mode:"i",x2:0,y2:-3.94,sweep:!0}],text:{x:0,y:-1.87}},{sets:[1,2],x1:1.328,y1:2.828,arcs:[{ref:2,mode:"i",x2:0,y2:5.006,sweep:!0,large:!1},{ref:1,mode:"i",x2:-1.328,y2:2.828,sweep:!0,large:!1},{ref:0,mode:"o",x2:0,y2:2.346,large:!1},{ref:3,mode:"o",x2:1.328,y2:2.828}],text:{x:0,y:3.393}},{sets:[1,3],x1:3.108,y1:-.328,arcs:[{ref:3,mode:"i",x2:1.328,y2:2.828,sweep:!0,large:!1},{ref:2,mode:"o",x2:.969,y2:1.755,large:!1},{ref:1,mode:"i",x2:3.108,y2:-.328,large:!1}],text:{x:2.212,y:1.591}},{sets:[2,3],x1:-3.108,y1:-.328,arcs:[{ref:3,mode:"i",x2:-4.328,y2:-2.828,sweep:!0,large:!1},{ref:2,mode:"i",x2:-2.179,y2:-1.858,sweep:!0,large:!1},{ref:0,mode:"o",x2:-3.108,y2:-.328,large:!1}],text:{x:-3.205,y:-1.672}},{sets:[0,1,2],x1:0,y1:2.346,arcs:[{ref:0,mode:"i",x2:-1.328,y2:2.828,sweep:!0,large:!1},{ref:1,mode:"i",x2:-.969,y2:1.755,sweep:!0,large:!1},{ref:3,mode:"o",x2:0,y2:2.346,large:!1}],text:{x:-.766,y:2.31}},{sets:[0,1,3],x1:2.179,y1:-1.858,arcs:[{ref:3,mode:"i",x2:3.108,y2:-.328,sweep:!0,large:!1},{ref:0,mode:"i",x2:.969,y2:1.755,sweep:!0,large:!1},{ref:2,mode:"o",x2:0,y2:.188,sweep:!1,large:!1},{ref:1,mode:"i",x2:2.179,y2:-1.858,sweep:!0}],text:{x:1.558,y:-.056}},{sets:[0,2,3],x1:-.969,y1:1.755,arcs:[{ref:3,mode:"i",x2:-3.108,y2:-.328,sweep:!0,large:!1},{ref:0,mode:"i",x2:-2.179,y2:-1.858,sweep:!0,large:!1},{ref:2,mode:"i",x2:0,y2:.188,sweep:!0,large:!1},{ref:1,mode:"o",x2:-.969,y2:1.755}],text:{x:-1.558,y:-.056}},{sets:[1,2,3],x1:1.328,y1:2.828,arcs:[{ref:3,mode:"i",x2:0,y2:2.346,sweep:!0,large:!1},{ref:0,mode:"o",x2:.969,y2:1.755,sweep:!1,large:!1},{ref:2,mode:"i",x2:1.328,y2:2.828,sweep:!0,large:!1}],text:{x:.766,y:2.31}},{sets:[0,1,2,3],x1:0,y1:.188,arcs:[{ref:2,mode:"i",x2:.969,y2:1.755,sweep:!0,large:!1},{ref:0,mode:"i",x2:0,y2:2.346,sweep:!0,large:!1},{ref:3,mode:"i",x2:-.969,y2:1.755,sweep:!0,large:!1},{ref:1,mode:"i",x2:0,y2:.188,sweep:!0}],text:{x:0,y:1.43}}],bb:{x:-6.5,y:-5,width:13,height:10}},f={sets:[{cx:.5,cy:-1,rx:2.5,ry:5,rotation:0,text:{x:2.25,y:-5},align:"start",verticalAlign:"bottom"},{cx:1.106,cy:.167,rx:2.5,ry:5,rotation:72,text:{x:4.5,y:1.5},align:"start",verticalAlign:"top"},{cx:.183,cy:1.103,rx:2.5,ry:5,rotation:144,text:{x:4,y:4},align:"start",verticalAlign:"bottom"},{cx:-.992,cy:.515,rx:2.5,ry:5,rotation:216,text:{x:-4.7,y:2},align:"end",verticalAlign:"bottom"},{cx:-.797,cy:-.785,rx:2.5,ry:5,rotation:288,text:{x:-4,y:-3.6},align:"end",verticalAlign:"bottom"}],intersections:[{sets:[0],x1:-1.653,y1:-3.541,arcs:[{ref:0,mode:"i",x2:2.857,y2:-2.666,sweep:!0,large:!1},{ref:1,mode:"o",x2:2.5,y2:-2.648,large:!1},{ref:3,mode:"o",x2:-.495,y2:-3.303,large:!1},{ref:4,mode:"o",x2:-1.653,y2:-3.541}],text:{x:.5,y:-5}},{sets:[1],x1:2.857,y1:-2.666,arcs:[{ref:1,mode:"i",x2:3.419,y2:1.893,sweep:!0,large:!1},{ref:2,mode:"o",x2:3.291,y2:1.559,large:!1},{ref:4,mode:"o",x2:2.988,y2:-1.492,large:!1},{ref:0,mode:"o",x2:2.857,y2:-2.666}],text:{x:4.91,y:-1.07}},{sets:[2],x1:3.419,y1:1.893,arcs:[{ref:2,mode:"i",x2:-.744,y2:3.837,sweep:!0,large:!1},{ref:3,mode:"o",x2:-.466,y2:3.612,large:!1},{ref:0,mode:"o",x2:2.342,y2:2.381,large:!1},{ref:1,mode:"o",x2:3.419,y2:1.893}],text:{x:2.534,y:4.339}},{sets:[3],x1:-.744,y1:3.837,arcs:[{ref:3,mode:"i",x2:-3.879,y2:.478,sweep:!0,large:!1},{ref:4,mode:"o",x2:-3.579,y2:.673,large:!1},{ref:1,mode:"o",x2:-1.54,y2:2.963,large:!1},{ref:2,mode:"o",x2:-.744,y2:3.837}],text:{x:-3.343,y:3.751}},{sets:[4],x1:-3.879,y1:.478,arcs:[{ref:4,mode:"i",x2:-1.653,y2:-3.541,sweep:!0,large:!1},{ref:0,mode:"o",x2:-1.746,y2:-3.196,large:!1},{ref:2,mode:"o",x2:-3.294,y2:-.549,large:!1},{ref:3,mode:"o",x2:-3.879,y2:.478}],text:{x:-4.601,y:-2.021}},{sets:[0,1],x1:2.5,y1:-2.648,arcs:[{ref:1,mode:"i",x2:2.857,y2:-2.666,sweep:!0,large:!1},{ref:0,mode:"i",x2:2.988,y2:-1.492,sweep:!0,large:!1},{ref:4,mode:"o",x2:2.572,y2:-1.839,large:!1},{ref:3,mode:"o",x2:2.5,y2:-2.648}],text:{x:2.741,y:-2.152}},{sets:[0,2],x1:2.342,y1:2.381,arcs:[{ref:0,mode:"i",x2:-.466,y2:3.612,sweep:!0,large:!1},{ref:3,mode:"o",x2:.257,y2:2.922,large:!1},{ref:1,mode:"o",x2:2.342,y2:2.381,large:!1}],text:{x:.5,y:3.5}},{sets:[0,3],x1:-.495,y1:-3.303,arcs:[{ref:3,mode:"i",x2:2.5,y2:-2.648,sweep:!0,large:!1},{ref:1,mode:"o",x2:1.51,y2:-2.515,large:!1},{ref:4,mode:"o",x2:-.495,y2:-3.303,large:!1}],text:{x:1.653,y:-3.125}},{sets:[0,4],x1:-1.653,y1:-3.541,arcs:[{ref:4,mode:"i",x2:-.495,y2:-3.303,sweep:!0,large:!1},{ref:3,mode:"o",x2:-.954,y2:-3.015,large:!1},{ref:2,mode:"o",x2:-1.746,y2:-3.196,large:!1},{ref:0,mode:"i",x2:-1.653,y2:-3.541}],text:{x:-1.199,y:-3.272}},{sets:[1,2],x1:3.291,y1:1.559,arcs:[{ref:2,mode:"i",x2:3.419,y2:1.893,sweep:!0,large:!1},{ref:1,mode:"i",x2:2.342,y2:2.381,sweep:!0,large:!1},{ref:0,mode:"o",x2:2.544,y2:1.878,large:!1},{ref:4,mode:"o",x2:3.291,y2:1.559}],text:{x:2.894,y:1.942}},{sets:[1,3],x1:-1.54,y1:2.963,arcs:[{ref:1,mode:"i",x2:-3.579,y2:.673,sweep:!0,large:!1},{ref:4,mode:"o",x2:-2.7,y2:1.147,large:!1},{ref:2,mode:"o",x2:-1.54,y2:2.963,large:!1}],text:{x:-3.174,y:1.557}},{sets:[1,4],x1:2.988,y1:-1.492,arcs:[{ref:4,mode:"i",x2:3.291,y2:1.559,sweep:!0,large:!1},{ref:2,mode:"o",x2:2.858,y2:.659,large:!1},{ref:0,mode:"o",x2:2.988,y2:-1.492,large:!1}],text:{x:3.483,y:.606}},{sets:[2,3],x1:-.466,y1:3.612,arcs:[{ref:3,mode:"i",x2:-.744,y2:3.837,sweep:!0,large:!1},{ref:2,mode:"i",x2:-1.54,y2:2.963,sweep:!0,large:!1},{ref:1,mode:"o",x2:-1,y2:3,large:!1},{ref:0,mode:"o",x2:-.466,y2:3.612}],text:{x:-.953,y:3.352}},{sets:[2,4],x1:-3.294,y1:-.549,arcs:[{ref:2,mode:"i",x2:-1.746,y2:-3.196,sweep:!0},{ref:0,mode:"o",x2:-1.925,y2:-2.213},{ref:3,mode:"o",x2:-3.294,y2:-.549}],text:{x:-2.462,y:-2.538}},{sets:[3,4],x1:-3.579,y1:.673,arcs:[{ref:4,mode:"i",x2:-3.879,y2:.478,sweep:!0,large:!1},{ref:3,mode:"i",x2:-3.294,y2:-.549,sweep:!0,large:!1},{ref:2,mode:"o",x2:-3.162,y2:-.024,large:!1},{ref:1,mode:"o",x2:-3.579,y2:.673}],text:{x:-3.483,y:.13}},{sets:[0,1,2],x1:2.544,y1:1.878,arcs:[{ref:0,mode:"i",x2:2.342,y2:2.381,sweep:!0,large:!1},{ref:1,mode:"i",x2:.257,y2:2.922,sweep:!0,large:!1},{ref:3,mode:"o",x2:.983,y2:2.049,large:!1},{ref:4,mode:"o",x2:2.544,y2:1.878}],text:{x:1.457,y:2.331}},{sets:[0,1,3],x1:1.51,y1:-2.515,arcs:[{ref:1,mode:"i",x2:2.5,y2:-2.648,sweep:!0,large:!1},{ref:3,mode:"i",x2:2.572,y2:-1.839,sweep:!0,large:!1},{ref:4,mode:"o",x2:1.51,y2:-2.515,large:!1}],text:{x:2.194,y:-2.334}},{sets:[0,1,4],x1:2.572,y1:-1.839,arcs:[{ref:4,mode:"i",x2:2.988,y2:-1.492,sweep:!0,large:!1},{ref:0,mode:"i",x2:2.858,y2:.659,sweep:!0,large:!1},{ref:2,mode:"o",x2:2.253,y2:-.302,large:!1},{ref:3,mode:"o",x2:2.572,y2:-1.839}],text:{x:2.667,y:-.665}},{sets:[0,2,3],x1:.257,y1:2.922,arcs:[{ref:3,mode:"i",x2:-.466,y2:3.612,sweep:!0,large:!1},{ref:0,mode:"i",x2:-1,y2:3,sweep:!0,large:!1},{ref:1,mode:"o",x2:.257,y2:2.922,large:!1}],text:{x:-.403,y:3.178}},{sets:[0,2,4],x1:-1.746,y1:-3.196,arcs:[{ref:2,mode:"i",x2:-.954,y2:-3.015,sweep:!0,large:!1},{ref:3,mode:"o",x2:-1.925,y2:-2.213,sweep:!1,large:!1},{ref:0,mode:"i",x2:-1.746,y2:-3.196,sweep:!0,large:!1}],text:{x:-1.542,y:-2.808}},{sets:[0,3,4],x1:-.495,y1:-3.303,arcs:[{ref:4,mode:"i",x2:1.51,y2:-2.515,sweep:!0,large:!1},{ref:1,mode:"o",x2:.409,y2:-2.236,large:!1},{ref:2,mode:"o",x2:-.954,y2:-3.015,large:!1},{ref:3,mode:"i",x2:-.495,y2:-3.303}],text:{x:.192,y:-2.742}},{sets:[1,2,3],x1:-1.54,y1:2.963,arcs:[{ref:2,mode:"i",x2:-2.7,y2:1.147,sweep:!0,large:!1},{ref:4,mode:"o",x2:-1.645,y2:1.568,large:!1},{ref:0,mode:"o",x2:-1,y2:3,large:!1},{ref:1,mode:"i",x2:-1.54,y2:2.963}],text:{x:-1.767,y:2.106}},{sets:[1,2,4],x1:2.858,y1:.659,arcs:[{ref:2,mode:"i",x2:3.291,y2:1.559,sweep:!0,large:!1},{ref:4,mode:"i",x2:2.544,y2:1.878,sweep:!0,large:!1},{ref:0,mode:"o",x2:2.858,y2:.659,large:!1}],text:{x:2.898,y:1.365}},{sets:[1,3,4],x1:-2.7,y1:1.147,arcs:[{ref:4,mode:"i",x2:-3.579,y2:.673,sweep:!0,large:!1},{ref:1,mode:"i",x2:-3.162,y2:-.024,sweep:!0,large:!1},{ref:2,mode:"o",x2:-2.7,y2:1.147,large:!1}],text:{x:-3.147,y:.599}},{sets:[2,3,4],x1:-3.294,y1:-.549,arcs:[{ref:3,mode:"i",x2:-1.925,y2:-2.213,sweep:!0,large:!1},{ref:0,mode:"o",x2:-2,y2:-1.08,large:!1},{ref:1,mode:"o",x2:-3.162,y2:-.024,large:!1},{ref:2,mode:"i",x2:-3.294,y2:-.549}],text:{x:-2.548,y:-1.029}},{sets:[0,1,2,3],x1:.983,y1:2.049,arcs:[{ref:3,mode:"i",x2:.257,y2:2.922,sweep:!0,large:!1},{ref:1,mode:"i",x2:-1,y2:3,sweep:!0,large:!1},{ref:0,mode:"i",x2:-1.645,y2:1.568,sweep:!0,large:!1},{ref:4,mode:"o",x2:.983,y2:2.049}],text:{x:-.407,y:2.31}},{sets:[0,1,2,4],x1:2.253,y1:-.302,arcs:[{ref:2,mode:"i",x2:2.858,y2:.659,sweep:!0,large:!1},{ref:0,mode:"i",x2:2.544,y2:1.878,sweep:!0,large:!1},{ref:4,mode:"i",x2:.983,y2:2.049,sweep:!0,large:!1},{ref:3,mode:"o",x2:2.253,y2:-.302}],text:{x:2.071,y:1.101}},{sets:[0,1,3,4],x1:1.51,y1:-2.515,arcs:[{ref:4,mode:"i",x2:2.572,y2:-1.839,sweep:!0,large:!1},{ref:3,mode:"i",x2:2.253,y2:-.302,sweep:!0,large:!1},{ref:2,mode:"o",x2:.409,y2:-2.236,sweep:!1,large:!1},{ref:1,mode:"i",x2:1.51,y2:-2.515,sweep:!0}],text:{x:1.687,y:-1.63}},{sets:[0,2,3,4],x1:-2,y1:-1.08,arcs:[{ref:0,mode:"i",x2:-1.925,y2:-2.213,sweep:!0,large:!1},{ref:3,mode:"i",x2:-.954,y2:-3.015,sweep:!0,large:!1},{ref:2,mode:"i",x2:.409,y2:-2.236,sweep:!0,large:!1},{ref:1,mode:"o",x2:-2,y2:-1.08}],text:{x:-1.028,y:-2.108}},{sets:[1,2,3,4],x1:-1.645,y1:1.568,arcs:[{ref:4,mode:"i",x2:-2.7,y2:1.147,sweep:!0,large:!1},{ref:2,mode:"i",x2:-3.162,y2:-.024,sweep:!0,large:!1},{ref:1,mode:"i",x2:-2,y2:-1.08,sweep:!0,large:!1},{ref:0,mode:"o",x2:-1.645,y2:1.568}],text:{x:-2.323,y:.327}},{sets:[0,1,2,3,4],x1:.409,y1:-2.236,arcs:[{ref:2,mode:"i",x2:2.253,y2:-.302,sweep:!0,large:!1},{ref:3,mode:"i",x2:.983,y2:2.049,sweep:!0,large:!1},{ref:4,mode:"i",x2:-1.645,y2:1.568,sweep:!0,large:!1},{ref:0,mode:"i",x2:-2,y2:-1.08,sweep:!0},{ref:1,mode:"i",x2:.409,y2:-2.236,sweep:!0}],text:{x:0,y:0}}],bb:{x:-5.5,y:-6,width:11.6,height:11.8}};function d(e,r,s,o=[],a=[]){t.registry.addControllers(s),Array.isArray(o)?t.registry.addElements(...o):t.registry.addElements(o),Array.isArray(a)?t.registry.addScales(...a):t.registry.addScales(a);const n=r;return n.type=e,n}class g extends t.DatasetController{initialize(){super.initialize(),this.enableOptionSharing=!0}update(e){super.update(e);const t=this._cachedMeta.data||[];this.updateElements(t,0,t.length,e)}computeLayout(e){return function(e,t){const s=[i,x,l,c,y,f],o=s[Math.min(s.length-1,e)],a=Math.min(t.width/o.bb.width,t.height/o.bb.height),n=a*-o.bb.x+(t.width-a*o.bb.width)/2+t.x,d=a*-o.bb.y+(t.height-a*o.bb.height)/2+t.y,g=e=>n+a*e,u=e=>d+a*e;return{sets:o.sets.map((e=>({...e,cx:g(e.cx),cy:u(e.cy),text:{x:g(e.text.x),y:u(e.text.y)},...r(e)?{rx:e.rx*a,ry:e.ry*a}:{r:e.r*a}}))),intersections:o.intersections.map((e=>({text:{x:g(e.text.x),y:u(e.text.y)},x1:g(e.x1),y1:u(e.y1),sets:e.sets,arcs:e.arcs.map((e=>({...e,x2:g(e.x2),y2:u(e.y2)})))})))}}(Math.log2(this._cachedMeta.data.length+1),e)}updateElements(e,t,r,s){const o=this._cachedMeta.xScale,a=this._cachedMeta.yScale,n=o.right-o.left,i=a.bottom-a.top,x=this.computeLayout({x:o.left,y:a.top,width:n,height:i});this._cachedMeta._layout=x,this._cachedMeta._setLayoutFont={...o._resolveTickFontOptions(0),color:o.options.ticks.color},this._cachedMeta._labelLayoutFont={...a._resolveTickFontOptions(0),color:a.options.ticks.color};const l=this.resolveDataElementOptions(t,s),c=this.getSharedOptions(l),y=this.includeOptions(s,c);for(let o=t;o<t+r;o+=1){const t=e[o],r={refs:x.sets,...x.intersections[o]};y&&(r.options=c||this.resolveDataElementOptions(o,s)),this.updateElement(t,o,r,s)}this.updateSharedOptions(c,s,l)}draw(){const e=this._cachedMeta.data,{ctx:t}=this.chart;e.forEach((e=>e.draw(t))),this.drawLabels(t)}drawLabels(e){const t=this._cachedMeta;e.save();const r=t._layout,s=t.xScale,o=t._setLayoutFont,a=t.yScale,n=t._labelLayoutFont;if(null==a?void 0:a.options.ticks.display){e.font=n.string,e.fillStyle=n.color,e.textBaseline="middle";const t=this.chart.data.labels;r.sets.forEach(((r,s)=>{e.textAlign="middle"===r.align?"center":r.align,e.textBaseline=r.verticalAlign,e.fillText(t[s],r.text.x,r.text.y)}))}if(null==s?void 0:s.options.ticks.display){e.font=o.string,e.fillStyle=o.color,e.textBaseline="middle",e.textAlign="center",e.textBaseline="middle";const t=this.getDataset().data;r.intersections.forEach(((r,s)=>{e.fillText(t[s].value.toLocaleString(),r.text.x,r.text.y)}))}e.restore()}}g.id="venn",g.defaults={dataElementType:n.id},g.overrides={plugins:{tooltip:{callbacks:{title:()=>"",label(e){var t,r;const s=e.chart.data.labels,o=null===(r=null===(t=e.chart.data.datasets)||void 0===t?void 0:t[e.datasetIndex].data)||void 0===r?void 0:r[e.dataIndex];return`${s[e.dataIndex]}: ${o?o.values||o.value.toLocaleString():""}`}}}},scales:{x:{type:"linear",min:-1,max:1,display:!1},y:{type:"linear",min:-1,max:1,display:!1}}};class u extends t.Chart{constructor(e,r){super(e,d("venn",r,g,n,[t.LinearScale]))}}u.id=g.id;const m=1e-10;function h(e,t){const r=function(e){const t=[];for(let r=0;r<e.length;++r)for(let s=r+1;s<e.length;++s){const o=M(e[r],e[s]);for(const e of o)e.parentIndex=[r,s],t.push(e)}return t}(e),s=r.filter((t=>function(e,t){return t.every((t=>w(e,t)<t.radius+m))}(t,e)));let o=0,a=0;const n=[];if(s.length>1){const t=v(s);for(let e=0;e<s.length;++e){const r=s[e];r.angle=Math.atan2(r.x-t.x,r.y-t.y)}s.sort(((e,t)=>t.angle-e.angle));let r=s[s.length-1];for(let t=0;t<s.length;++t){const i=s[t];a+=(r.x+i.x)*(i.y-r.y);const x={x:(i.x+r.x)/2,y:(i.y+r.y)/2};let l=null;for(let t=0;t<i.parentIndex.length;++t)if(r.parentIndex.includes(i.parentIndex[t])){const s=e[i.parentIndex[t]],o=Math.atan2(i.x-s.x,i.y-s.y),a=Math.atan2(r.x-s.x,r.y-s.y);let n=a-o;n<0&&(n+=2*Math.PI);const c=a-n/2;let y=w(x,{x:s.x+s.radius*Math.sin(c),y:s.y+s.radius*Math.cos(c)});y>2*s.radius&&(y=2*s.radius),(null==l||l.width>y)&&(l={circle:s,width:y,p1:i,p2:r,large:y>s.radius,sweep:!0})}null!=l&&(n.push(l),o+=p(l.circle.radius,l.width),r=i)}}else{let t=e[0];for(let r=1;r<e.length;++r)e[r].radius<t.radius&&(t=e[r]);let r=!1;for(let s=0;s<e.length;++s)if(w(e[s],t)>Math.abs(t.radius-e[s].radius)){r=!0;break}r?o=a=0:(o=t.radius*t.radius*Math.PI,n.push({circle:t,p1:{x:t.x,y:t.y+t.radius},p2:{x:t.x-m,y:t.y+t.radius},width:2*t.radius,large:!0,sweep:!0}))}return a/=2,t&&(t.area=o+a,t.arcArea=o,t.polygonArea=a,t.arcs=n,t.innerPoints=s,t.intersectionPoints=r),o+a}function p(e,t){return e*e*Math.acos(1-t/e)-(e-t)*Math.sqrt(t*(2*e-t))}function w(e,t){return Math.sqrt((e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y))}function b(e,t,r){if(r>=e+t)return 0;if(r<=Math.abs(e-t))return Math.PI*Math.min(e,t)*Math.min(e,t);const s=t-(r*r-e*e+t*t)/(2*r);return p(e,e-(r*r-t*t+e*e)/(2*r))+p(t,s)}function M(e,t){const r=w(e,t),s=e.radius,o=t.radius;if(r>=s+o||r<=Math.abs(s-o))return[];const a=(s*s-o*o+r*r)/(2*r),n=Math.sqrt(s*s-a*a),i=e.x+a*(t.x-e.x)/r,x=e.y+a*(t.y-e.y)/r,l=-(t.y-e.y)*(n/r),c=-(t.x-e.x)*(n/r);return[{x:i+l,y:x-c},{x:i-l,y:x+c}]}function v(e){const t={x:0,y:0};for(const r of e)t.x+=r.x,t.y+=r.y;return t.x/=e.length,t.y/=e.length,t}function z(e){const t=new Array(e);for(let r=0;r<e;++r)t[r]=0;return t}function I(e,t){return z(e).map((()=>z(t)))}function R(e,t){let r=0;for(let s=0;s<e.length;++s)r+=e[s]*t[s];return r}function P(e){return Math.sqrt(R(e,e))}function A(e,t,r){for(let s=0;s<t.length;++s)e[s]=t[s]*r}function N(e,t,r,s,o){for(let a=0;a<e.length;++a)e[a]=t*r[a]+s*o[a]}function k(e,t,r){const s=(r=r||{}).maxIterations||200*t.length,o=r.nonZeroDelta||1.05,a=r.zeroDelta||.001,n=r.minErrorDelta||1e-6,i=r.minErrorDelta||1e-5,x=void 0!==r.rho?r.rho:1,l=void 0!==r.chi?r.chi:2,c=void 0!==r.psi?r.psi:-.5,y=void 0!==r.sigma?r.sigma:.5;let f;const d=t.length,g=new Array(d+1);g[0]=t,g[0].fx=e(t),g[0].id=0;for(let r=0;r<d;++r){const s=t.slice();s[r]=s[r]?s[r]*o:a,g[r+1]=s,g[r+1].fx=e(s),g[r+1].id=r+1}function u(e){for(let t=0;t<e.length;t++)g[d][t]=e[t];g[d].fx=e.fx}const m=(e,t)=>e.fx-t.fx,h=t.slice(),p=t.slice(),w=t.slice(),b=t.slice();for(let t=0;t<s;++t){if(g.sort(m),r.history){const e=g.map((e=>{const t=e.slice();return t.fx=e.fx,t.id=e.id,t}));e.sort(((e,t)=>e.id-t.id)),r.history.push({x:g[0].slice(),fx:g[0].fx,simplex:e})}f=0;for(let e=0;e<d;++e)f=Math.max(f,Math.abs(g[0][e]-g[1][e]));if(Math.abs(g[0].fx-g[d].fx)<n&&f<i)break;for(let e=0;e<d;++e){h[e]=0;for(let t=0;t<d;++t)h[e]+=g[t][e];h[e]/=d}const t=g[d];if(N(p,1+x,h,-x,t),p.fx=e(p),p.fx<g[0].fx)N(b,1+l,h,-l,t),b.fx=e(b),b.fx<p.fx?u(b):u(p);else if(p.fx>=g[d-1].fx){let r=!1;if(p.fx>t.fx?(N(w,1+c,h,-c,t),w.fx=e(w),w.fx<t.fx?u(w):r=!0):(N(w,1-c*x,h,c*x,t),w.fx=e(w),w.fx<p.fx?u(w):r=!0),r){if(y>=1)break;for(let t=1;t<g.length;++t)N(g[t],1-y,g[0],y,g[t]),g[t].fx=e(g[t])}}else u(p)}return g.sort(m),{fx:g[0].fx,x:g[0]}}function S(e,t,r,s,o,a,n){const i=r.fx,x=R(r.fxprime,t);let l=i,c=i,y=x,f=0;function d(c,f,d){for(let g=0;g<16;++g)if(o=(c+f)/2,N(s.x,1,r.x,o,t),l=s.fx=e(s.x,s.fxprime),y=R(s.fxprime,t),l>i+a*o*x||l>=d)f=o;else{if(Math.abs(y)<=-n*x)return o;y*(f-c)>=0&&(f=c),c=o,d=l}return 0}o=o||1,a=a||1e-6,n=n||.1;for(let g=0;g<10;++g){if(N(s.x,1,r.x,o,t),l=s.fx=e(s.x,s.fxprime),y=R(s.fxprime,t),l>i+a*o*x||g&&l>=c)return d(f,o,c);if(Math.abs(y)<=-n*x)return o;if(y>=0)return d(o,f,l);c=l,f=o,o*=2}return o}function E(e,t,r){let s={x:t.slice(),fx:0,fxprime:t.slice()},o={x:t.slice(),fx:0,fxprime:t.slice()};const a=t.slice();let n,i,x,l=1;x=(r=r||{}).maxIterations||20*t.length,s.fx=e(s.x,s.fxprime),n=s.fxprime.slice(),A(n,s.fxprime,-1);for(let t=0;t<x;++t){if(l=S(e,n,s,o,l),r.history&&r.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:l}),l){N(a,1,o.fxprime,-1,s.fxprime);const e=R(s.fxprime,s.fxprime);N(n,Math.max(0,R(a,o.fxprime)/e),n,-1,o.fxprime),i=s,s=o,o=i}else A(n,s.fxprime,-1);if(P(s.fxprime)<=1e-5)break}return r.history&&r.history.push({x:s.x.slice(),fx:s.fx,fxprime:s.fxprime.slice(),alpha:l}),s}function $(e,t={}){t.maxIterations=t.maxIterations||500;const r=t.initialLayout||O,s=t.lossFunction||_,o=function(e,t={}){const r=t.distinct,s=e.map((e=>Object.assign({},e)));function o(e){return e.join(";")}if(r){const e=new Map;for(const t of s)for(let r=0;r<t.sets.length;r++){const s=String(t.sets[r]);e.set(s,t.size+(e.get(s)||0));for(let o=r+1;o<t.sets.length;o++){const r=String(t.sets[o]),a=`${s};${r}`,n=`${r};${s}`;e.set(a,t.size+(e.get(a)||0)),e.set(n,t.size+(e.get(n)||0))}}for(const t of s)t.sets.length<3&&(t.size=e.get(o(t.sets)))}const a=[],n=new Set;for(const e of s)if(1===e.sets.length)a.push(e.sets[0]);else if(2===e.sets.length){const t=e.sets[0],r=e.sets[1];n.add(o(e.sets)),n.add(o([r,t]))}a.sort(((e,t)=>e===t?0:e<t?-1:1));for(let e=0;e<a.length;++e){const t=a[e];for(let r=e+1;r<a.length;++r){const e=a[r];n.has(o([t,e]))||s.push({sets:[t,e],size:0})}}return s}(e,t),a=r(o,t),n=Object.keys(a),i=[];for(const e of n)i.push(a[e].x),i.push(a[e].y);const x=k((e=>{const t={};for(let r=0;r<n.length;++r){const s=n[r];t[s]={x:e[2*r],y:e[2*r+1],radius:a[s].radius}}return s(t,o)}),i,t).x;for(let e=0;e<n.length;++e){const t=n[e];a[t].x=x[2*e],a[t].y=x[2*e+1]}return a}const j=1e-10;function C(e,t,r){return Math.min(e,t)*Math.min(e,t)*Math.PI<=r+j?Math.abs(e-t):function(e,t,r,s){const o=(s=s||{}).maxIterations||100,a=s.tolerance||1e-10,n=e(t),i=e(r);let x=r-t;if(n*i>0)throw"Initial bisect points must have opposite signs";if(0===n)return t;if(0===i)return r;for(let r=0;r<o;++r){x/=2;const r=t+x,s=e(r);if(s*n>=0&&(t=r),Math.abs(x)<a||0===s)return r}return t+x}((s=>b(e,t,s)-r),0,e+t)}function O(e,t={}){let r=function(e,t){const r=t&&t.lossFunction?t.lossFunction:_,s={},o={};for(const t of e)if(1===t.sets.length){const e=t.sets[0];s[e]={x:1e10,y:1e10,rowid:s.length,size:t.size,radius:Math.sqrt(t.size/Math.PI)},o[e]=[]}e=e.filter((e=>2===e.sets.length));for(const t of e){let e=null!=t.weight?t.weight:1;const r=t.sets[0],a=t.sets[1];t.size+j>=Math.min(s[r].size,s[a].size)&&(e=0),o[r].push({set:a,size:t.size,weight:e}),o[a].push({set:r,size:t.size,weight:e})}const a=[];function n(e,t){return t.size-e.size}Object.keys(o).forEach((e=>{let t=0;for(let r=0;r<o[e].length;++r)t+=o[e][r].size*o[e][r].weight;a.push({set:e,size:t})})),a.sort(n);const i={};function x(e){return e.set in i}function l(e,t){s[t].x=e.x,s[t].y=e.y,i[t]=!0}l({x:0,y:0},a[0].set);for(let t=1;t<a.length;++t){const i=a[t].set,y=o[i].filter(x),f=s[i];if(y.sort(n),0===y.length)throw"ERROR: missing pairwise overlap information";const d=[];for(var c=0;c<y.length;++c){const e=s[y[c].set],t=C(f.radius,e.radius,y[c].size);d.push({x:e.x+t,y:e.y}),d.push({x:e.x-t,y:e.y}),d.push({y:e.y+t,x:e.x}),d.push({y:e.y-t,x:e.x});for(let r=c+1;r<y.length;++r){const o=s[y[r].set],a=C(f.radius,o.radius,y[r].size),n=M({x:e.x,y:e.y,radius:t},{x:o.x,y:o.y,radius:a});d.push(...n)}}let g=1e50,u=d[0];for(const t of d){s[i].x=t.x,s[i].y=t.y;const o=r(s,e);o<g&&(g=o,u=t)}l(u,i)}return s}(e,t);const s=t.lossFunction||_;if(e.length>=8){const o=function(e,t={}){const r=t.restarts||10,s=[],o={};for(const t of e)1===t.sets.length&&(o[t.sets[0]]=s.length,s.push(t));let{distances:a,constraints:n}=function(e,t,r){const s=I(t.length,t.length),o=I(t.length,t.length);return e.filter((e=>2===e.sets.length)).forEach((e=>{const a=r[e.sets[0]],n=r[e.sets[1]],i=C(Math.sqrt(t[a].size/Math.PI),Math.sqrt(t[n].size/Math.PI),e.size);s[a][n]=s[n][a]=i;let x=0;e.size+1e-10>=Math.min(t[a].size,t[n].size)?x=1:e.size<=1e-10&&(x=-1),o[a][n]=o[n][a]=x})),{distances:s,constraints:o}}(e,s,o);const i=P(a.map(P))/a.length;a=a.map((e=>e.map((e=>e/i))));const x=(e,t)=>function(e,t,r,s){for(let e=0;e<t.length;++e)t[e]=0;let o=0;for(let a=0;a<r.length;++a){const n=e[2*a],i=e[2*a+1];for(let x=a+1;x<r.length;++x){const l=e[2*x],c=e[2*x+1],y=r[a][x],f=s[a][x],d=(l-n)*(l-n)+(c-i)*(c-i),g=Math.sqrt(d),u=d-y*y;f>0&&g<=y||f<0&&g>=y||(o+=2*u*u,t[2*a]+=4*u*(n-l),t[2*a+1]+=4*u*(i-c),t[2*x]+=4*u*(l-n),t[2*x+1]+=4*u*(c-i))}}return o}(e,t,a,n);let l=null;for(let e=0;e<r;++e){const e=E(x,z(2*a.length).map(Math.random),t);(!l||e.fx<l.fx)&&(l=e)}const c=l.x,y={};for(let e=0;e<s.length;++e){const t=s[e];y[t.sets[0]]={x:c[2*e]*i,y:c[2*e+1]*i,radius:Math.sqrt(t.size/Math.PI)}}if(t.history)for(const e of t.history)A(e.x,i);return y}(e,t);s(o,e)+1e-8<s(r,e)&&(r=o)}return r}function _(e,t){let r=0;for(const s of t){if(1===s.sets.length)continue;let t;if(2===s.sets.length){const r=e[s.sets[0]],o=e[s.sets[1]];t=b(r.radius,o.radius,w(r,o))}else t=h(s.sets.map((t=>e[t])));r+=(null!=s.weight?s.weight:1)*(t-s.size)*(t-s.size)}return r}function F(e,t){let r=0;for(const s of t){if(1===s.sets.length)continue;let t;if(2===s.sets.length){const r=e[s.sets[0]],o=e[s.sets[1]];t=b(r.radius,o.radius,w(r,o))}else t=h(s.sets.map((t=>e[t])));const o=null!=s.weight?s.weight:1,a=Math.log((t+1)/(s.size+1));r+=o*a*a}return r}function D(e,t,r){if(null==r?e.sort(((e,t)=>t.radius-e.radius)):e.sort(r),e.length>0){const t=e[0].x,r=e[0].y;for(const s of e)s.x-=t,s.y-=r}if(2===e.length){w(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)}if(e.length>1){const r=Math.atan2(e[1].x,e[1].y)-t,s=Math.cos(r),o=Math.sin(r);for(const t of e){const e=t.x,r=t.y;t.x=s*e-o*r,t.y=o*e+s*r}}if(e.length>2){let r=Math.atan2(e[2].x,e[2].y)-t;for(;r<0;)r+=2*Math.PI;for(;r>2*Math.PI;)r-=2*Math.PI;if(r>Math.PI){const t=e[1].y/(1e-10+e[1].x);for(const r of e){var s=(r.x+t*r.y)/(1+t*t);r.x=2*s-r.x,r.y=2*s*t-r.y}}}}function T(e){const t=t=>({max:e.reduce(((e,r)=>Math.max(e,r[t]+r.radius)),Number.NEGATIVE_INFINITY),min:e.reduce(((e,r)=>Math.min(e,r[t]-r.radius)),Number.POSITIVE_INFINITY)});return{xRange:t("x"),yRange:t("y")}}function L(e,t,r){null==t&&(t=Math.PI/2);let s=V(e).map((e=>Object.assign({},e)));const o=function(e){function t(e){return e.parent!==e&&(e.parent=t(e.parent)),e.parent}function r(e,r){const s=t(e),o=t(r);s.parent=o}e.forEach((e=>{e.parent=e}));for(let t=0;t<e.length;++t)for(let s=t+1;s<e.length;++s){const o=e[t].radius+e[s].radius;w(e[t],e[s])+1e-10<o&&r(e[s],e[t])}const s=new Map;for(let r=0;r<e.length;++r){const o=t(e[r]).parent.setid;s.has(o)||s.set(o,[]),s.get(o).push(e[r])}return e.forEach((e=>{delete e.parent})),Array.from(s.values())}(s);for(const e of o){D(e,t,r);const s=T(e);e.size=(s.xRange.max-s.xRange.min)*(s.yRange.max-s.yRange.min),e.bounds=s}o.sort(((e,t)=>t.size-e.size)),s=o[0];let a=s.bounds;const n=(a.xRange.max-a.xRange.min)/50;function i(e,t,r){if(!e)return;const o=e.bounds;let i,x;if(t)i=a.xRange.max-o.xRange.min+n;else{i=a.xRange.max-o.xRange.max;const e=(o.xRange.max-o.xRange.min)/2-(a.xRange.max-a.xRange.min)/2;e<0&&(i+=e)}if(r)x=a.yRange.max-o.yRange.min+n;else{x=a.yRange.max-o.yRange.max;const e=(o.yRange.max-o.yRange.min)/2-(a.yRange.max-a.yRange.min)/2;e<0&&(x+=e)}for(const t of e)t.x+=i,t.y+=x,s.push(t)}let x=1;for(;x<o.length;)i(o[x],!0,!1),i(o[x+1],!1,!0),i(o[x+2],!0,!0),x+=3,a=T(s);return q(s)}function q(e){const t={};for(const r of e)t[r.setid]=r;return t}function V(e){return Object.keys(e).map((t=>Object.assign(e[t],{setid:t})))}function B(e,t,r){let s=t[0].radius-w(t[0],e);for(let r=1;r<t.length;++r){const o=t[r].radius-w(t[r],e);o<=s&&(s=o)}for(let t=0;t<r.length;++t){const o=w(r[t],e)-r[t].radius;o<=s&&(s=o)}return s}function W(e,t,r){const s=[];for(const t of e)s.push({x:t.x,y:t.y}),s.push({x:t.x+t.radius/2,y:t.y}),s.push({x:t.x-t.radius/2,y:t.y}),s.push({x:t.x,y:t.y+t.radius/2}),s.push({x:t.x,y:t.y-t.radius/2});let o=s[0],a=B(s[0],e,t);for(let r=1;r<s.length;++r){const n=B(s[r],e,t);n>=a&&(o=s[r],a=n)}const n=k((r=>-1*B({x:r[0],y:r[1]},e,t)),[o.x,o.y],{maxIterations:500,minErrorDelta:1e-10}).x,i={x:r?0:n[0],y:n[1]};let x=!0;for(const t of e)if(w(i,t)>t.radius){x=!1;break}for(const e of t)if(w(i,e)<e.radius){x=!1;break}if(x)return i;if(1==e.length)return{x:e[0].x,y:e[0].y};const l={};return h(e,l),0===l.arcs.length?{x:0,y:-1e3,disjoint:!0}:1==l.arcs.length?{x:l.arcs[0].circle.x,y:l.arcs[0].circle.y}:t.length?W(e,[]):v(l.arcs.map((e=>e.p1)))}function Y(e,t,r){const s={},o=function(e){const t={},r=Object.keys(e);for(const e of r)t[e]=[];for(let s=0;s<r.length;s++){const o=r[s],a=e[o];for(let n=s+1;n<r.length;++n){const s=r[n],i=e[s],x=w(a,i);x+i.radius<=a.radius+1e-10?t[s].push(o):x+a.radius<=i.radius+1e-10&&t[o].push(s)}}return t}(e);for(let a=0;a<t.length;++a){const n=t[a].sets,i={},x={};for(let e=0;e<n.length;++e){i[n[e]]=!0;const t=o[n[e]];for(let e=0;e<t.length;++e)x[t[e]]=!0}const l=[],c=[];for(let t in e)t in i?l.push(e[t]):t in x||c.push(e[t]);const y=W(l,c,r);s[n]=y,y.disjoint&&t[a].size>0&&console.log("WARNING: area "+n+" not represented on screen")}return s}function G(e,t={}){const{lossFunction:r,layoutFunction:s=$,normalize:o=!0,orientation:a=Math.PI/2,orientationOrder:n,width:i=600,height:x=350,padding:l=15,scaleToFit:c=!1,symmetricalTextCentre:y=!1,distinct:f,round:d=2}=t;let g=s(e,{lossFunction:"default"!==r&&r?"logRatio"===r?F:r:_,distinct:f});o&&(g=L(g,a,n));const u=function(e,t,r,s,o){const a=V(e);t-=2*s,r-=2*s;const{xRange:n,yRange:i}=T(a);if(n.max===n.min||i.max===i.min)return console.log("not scaling solution: zero size detected"),e;let x,l;if(o){const e=2*Math.sqrt(o/Math.PI);x=t/e,l=r/e}else x=t/(n.max-n.min),l=r/(i.max-i.min);const c=Math.min(l,x),y=(t-(n.max-n.min)*c)/2,f=(r-(i.max-i.min)*c)/2;return q(a.map((e=>({radius:c*e.radius,x:s+y+(e.x-n.min)*c,y:s+f+(e.y-i.min)*c,setid:e.setid}))))}(g,i,x,l,c),m=Y(u,e,y),p=new Map(Object.keys(u).map((e=>[e,{set:e,x:u[e].x,y:u[e].y,radius:u[e].radius}]))),w=e.map((e=>{const t=e.sets.map((e=>p.get(e))),r=function(e){if(0===e.length)return[];const t={};return h(e,t),t.arcs}(t),s=function(e,t){if(0===e.length)return"M 0 0";const r=Math.pow(10,t||0),s=null!=t?e=>Math.round(e*r)/r:e=>e;if(1==e.length){const t=e[0].circle;return function(e,t,r){const s=[];return s.push("\nM",e,t),s.push("\nm",-r,0),s.push("\na",r,r,0,1,0,2*r,0),s.push("\na",r,r,0,1,0,2*-r,0),s.join(" ")}(s(t.x),s(t.y),s(t.radius))}const o=["\nM",s(e[0].p2.x),s(e[0].p2.y)];for(const t of e){const e=s(t.circle.radius);o.push("\nA",e,e,0,t.large?1:0,t.sweep?1:0,s(t.p1.x),s(t.p1.y))}return o.join(" ")}(r,d);return{circles:t,arcs:r,path:s,area:e,has:new Set(e.sets)}}));function b(e){let t="";for(const r of w)r.has.size>e.length&&e.every((e=>r.has.has(e)))&&(t+=" "+r.path);return t}return w.map((({circles:e,arcs:t,path:r,area:s})=>({data:s,text:m[s.sets],circles:e,arcs:t,path:r,distinctPath:r+b(s.sets)})))}function X(e,t,r){if(!e)return e;const s=e=>t(Number.parseFloat(e)).toString(),o=e=>r(Number.parseFloat(e)).toString();return e.split("\n").map((e=>{const t=e.trim().split(/[ ,]/);return"M"===t[0]?`${t[0]} ${s(t[1])} ${o(t[2])}`:"A"===t[0]?`${t.slice(0,6).join(" ")} ${s(t[6])} ${o(t[7])}`:e})).join("\n")}function Z(e,t){const r=G(e.map((e=>({sets:e.sets,size:e.value}))),{width:t.width,height:t.height,distinct:!0}),s=r.filter((e=>1===e.data.sets.length)),o=s.map((e=>e.data.sets[0])),n=s.map((e=>e.circles[0])),i=function(e){const t=e.reduce(((e,t)=>e+t.x),0),r=e.reduce(((e,t)=>e+t.y),0);return{x:t/e.length,y:r/e.length}}(s.map((e=>e.circles[0]))),x=s.map((e=>{const r=e.circles[0],s=function(e,t){const r=e.x-t.x,s=e.y-t.y;return Math.atan2(s,r)/Math.PI*180}(r,i);return{cx:r.x+t.x,cy:r.y+t.y,r:r.radius,align:s>90?"end":"start",verticalAlign:"bottom",text:a(r.x+t.x,r.y+t.y,1.1*r.radius,s)}})),l=e=>({x2:e.p1.x+t.x,y2:e.p1.y+t.y,ref:n.findIndex((t=>Math.abs(t.x-e.circle.x)<.05&&Math.abs(t.y-e.circle.y)<.05)),sweep:!0,large:e.width>e.circle.radius,mode:"i"});return{sets:x,intersections:r.map((e=>{const{arcs:r}=e,s={x:e.text.x+t.x,y:e.text.y+t.y},a=e.data.sets.map((e=>o.indexOf(e)));if(0===r.length)return{sets:a,text:s,x1:0,y1:0,arcs:[]};if(1===r.length){const r=e.arcs[0].circle;return{sets:a,text:s,x1:e.arcs[0].p2.x+t.x,y1:r.y-r.radius+t.y,arcs:[l(e.arcs[0]),Object.assign(l(e.arcs[0]),{y2:r.y-r.radius+t.y})],path:X(e.distinctPath||e.path,(e=>e+t.x),(e=>e+t.y))}}return{text:s,sets:a,x1:e.arcs[0].p2.x+t.x,y1:e.arcs[0].p2.y+t.y,arcs:e.arcs.map((e=>l(e))),path:X(e.distinctPath||e.path,(e=>e+t.x),(e=>e+t.y))}}))}}class H extends g{computeLayout(e){return Z(this._data,e)}}H.id="euler",H.defaults=g.defaults;class J extends t.Chart{constructor(e,t){super(e,d("euler",t,H,n))}}function K(e,t,r){const s=e.map((e=>e.label)),o=s.join(" ∩ "),a=e.slice(1).map((e=>r.get(e))),n=t.map((e=>r.get(e))),i=e[0].values.filter((e=>a.every((t=>null!=t&&t.has(e)))&&n.every((t=>null!=t&&!t.has(e)))));return{sets:s,label:o,value:i.length,values:i,degree:s.length}}J.id=H.id,t.registry.addControllers(g,H),t.registry.addElements(n),e.ArcSlice=n,e.EulerDiagramChart=J,e.EulerDiagramController=H,e.VennDiagramChart=u,e.VennDiagramController=g,e.extractSets=function(e,t={}){const r=[],s=new Map(e.map((e=>[e,new Set(e.values)]))),o=e.slice(0,5);switch(o.length){case 1:r.push(K([o[0]],[],s));break;case 2:r.push(K([o[0]],[o[1]],s),K([o[1]],[o[0]],s),K([o[0],o[1]],[],s));break;case 3:r.push(K([o[0]],[o[1],o[2]],s),K([o[1]],[o[0],o[2]],s),K([o[2]],[o[0],o[1]],s),K([o[0],o[1]],[o[2]],s),K([o[0],o[2]],[o[1]],s),K([o[1],o[2]],[o[0]],s),K([o[0],o[1],o[2]],[],s));break;case 4:r.push(K([o[0]],[o[1],o[2],o[3]],s),K([o[1]],[o[0],o[2],o[3]],s),K([o[2]],[o[0],o[1],o[3]],s),K([o[3]],[o[0],o[1],o[2]],s),K([o[0],o[1]],[o[2],o[3]],s),K([o[0],o[2]],[o[1],o[3]],s),K([o[0],o[3]],[o[1],o[2]],s),K([o[1],o[2]],[o[0],o[3]],s),K([o[1],o[3]],[o[0],o[2]],s),K([o[2],o[3]],[o[0],o[1]],s),K([o[0],o[1],o[2]],[o[3]],s),K([o[0],o[1],o[3]],[o[2]],s),K([o[0],o[2],o[3]],[o[1]],s),K([o[1],o[2],o[3]],[o[0]],s),K([o[0],o[1],o[2],o[3]],[],s));break;case 5:r.push(K([o[0]],[o[1],o[2],o[3],o[4]],s),K([o[1]],[o[0],o[2],o[3],o[4]],s),K([o[2]],[o[0],o[1],o[3],o[4]],s),K([o[3]],[o[0],o[1],o[2],o[4]],s),K([o[4]],[o[0],o[1],o[2],o[3]],s),K([o[0],o[1]],[o[2],o[3],o[4]],s),K([o[0],o[2]],[o[1],o[3],o[4]],s),K([o[0],o[3]],[o[1],o[2],o[4]],s),K([o[0],o[4]],[o[1],o[2],o[3]],s),K([o[1],o[2]],[o[0],o[3],o[4]],s),K([o[1],o[3]],[o[0],o[2],o[4]],s),K([o[1],o[4]],[o[0],o[2],o[3]],s),K([o[2],o[3]],[o[0],o[1],o[4]],s),K([o[2],o[4]],[o[0],o[1],o[3]],s),K([o[3],o[4]],[o[0],o[1],o[2]],s),K([o[0],o[1],o[2]],[o[3],o[4]],s),K([o[0],o[1],o[3]],[o[2],o[4]],s),K([o[0],o[1],o[4]],[o[2],o[3]],s),K([o[0],o[2],o[3]],[o[1],o[4]],s),K([o[0],o[2],o[4]],[o[1],o[3]],s),K([o[0],o[3],o[4]],[o[1],o[2]],s),K([o[1],o[2],o[3]],[o[0],o[4]],s),K([o[1],o[2],o[4]],[o[0],o[3]],s),K([o[1],o[3],o[4]],[o[0],o[2]],s),K([o[2],o[3],o[4]],[o[0],o[1]],s),K([o[0],o[1],o[2],o[3]],[o[4]],s),K([o[0],o[1],o[2],o[4]],[o[3]],s),K([o[0],o[1],o[3],o[4]],[o[2]],s),K([o[0],o[2],o[3],o[4]],[o[1]],s),K([o[1],o[2],o[3],o[4]],[o[0]],s),K([o[0],o[1],o[2],o[3],o[4]],[],s))}return{labels:r.map((e=>e.label)),datasets:[{label:t.label||"Venn Diagram",data:r}]}}})); //# sourceMappingURL=index.umd.min.js.map