/*
 Highcharts JS v10.2.1 (2022-08-29)

 (c) 2017-2021 Highsoft AS
 Authors: Jon Arild Nygard

 License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/venn",["highcharts"],function(p){a(p);a.Highcharts=p;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function p(a,q,m,g){a.hasOwnProperty(q)||(a[q]=g.apply(null,m),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:q,module:a[q]}})))}a=a?a._modules:{};p(a,"Core/Geometry/GeometryUtilities.js",
[],function(){var a;(function(a){a.getCenterOfPoints=function(a){var g=a.reduce(function(a,g){a.x+=g.x;a.y+=g.y;return a},{x:0,y:0});return{x:g.x/a.length,y:g.y/a.length}};a.getDistanceBetweenPoints=function(a,g){return Math.sqrt(Math.pow(g.x-a.x,2)+Math.pow(g.y-a.y,2))};a.getAngleBetweenPoints=function(a,g){return Math.atan2(g.x-a.x,g.y-a.y)}})(a||(a={}));return a});p(a,"Core/Geometry/CircleUtilities.js",[a["Core/Geometry/GeometryUtilities.js"]],function(a){var q=a.getAngleBetweenPoints,m=a.getCenterOfPoints,
g=a.getDistanceBetweenPoints,f;(function(a){function f(a,e){e=Math.pow(10,e);return Math.round(a*e)/e}function l(a){if(0>=a)throw Error("radius of circle must be a positive number.");return Math.PI*a*a}function k(a,e){return a*a*Math.acos(1-e/a)-(a-e)*Math.sqrt(e*(2*a-e))}function x(a,e){var t=g(a,e),n=a.r,r=e.r,k=[];if(t<n+r&&t>Math.abs(n-r)){n*=n;var v=(n-r*r+t*t)/(2*t);r=Math.sqrt(n-v*v);n=a.x;k=e.x;a=a.y;var l=e.y;e=n+v*(k-n)/t;v=a+v*(l-a)/t;a=r/t*-(l-a);t=r/t*-(k-n);k=[{x:f(e+a,14),y:f(v-t,14)},
{x:f(e-a,14),y:f(v+t,14)}]}return k}function u(a){return a.reduce(function(a,g,f,r){r=r.slice(f+1).reduce(function(a,e,r,k){var t=[f,r+f+1];return a.concat(x(g,e).map(function(a){a.indexes=t;return a}))},[]);return a.concat(r)},[])}function w(a,e){return g(a,e)<=e.r+1e-10}function p(a,e){return!e.some(function(e){return!w(a,e)})}function D(a){return u(a).filter(function(e){return p(e,a)})}a.round=f;a.getAreaOfCircle=l;a.getCircularSegmentArea=k;a.getOverlapBetweenCircles=function(a,e,g){var n=0;g<
a+e&&(g<=Math.abs(e-a)?n=l(a<e?a:e):(n=(a*a-e*e+g*g)/(2*g),g-=n,n=k(a,a-n)+k(e,e-g)),n=f(n,14));return n};a.getCircleCircleIntersection=x;a.getCirclesIntersectionPoints=u;a.isCircle1CompletelyOverlappingCircle2=function(a,e){return g(a,e)+e.r<a.r+1e-10};a.isPointInsideCircle=w;a.isPointInsideAllCircles=p;a.isPointOutsideAllCircles=function(a,e){return!e.some(function(e){return w(a,e)})};a.getCirclesIntersectionPolygon=D;a.getAreaOfIntersectionBetweenCircles=function(a){var e=D(a);if(1<e.length){var f=
m(e);e=e.map(function(a){a.angle=q(f,a);return a}).sort(function(a,e){return e.angle-a.angle});var k=e[e.length-1];e=e.reduce(function(e,f){var k=e.startPoint,l=m([k,f]),x=f.indexes.filter(function(a){return-1<k.indexes.indexOf(a)}).reduce(function(c,b){b=a[b];var d=q(b,f),h=q(b,k);d=h-(h-d+(h<d?2*Math.PI:0))/2;d=g(l,{x:b.x+b.r*Math.sin(d),y:b.y+b.r*Math.cos(d)});b=b.r;d>2*b&&(d=2*b);if(!c||c.width>d)c={r:b,largeArc:d>b?1:0,width:d,x:f.x,y:f.y};return c},null);if(x){var C=x.r;e.arcs.push(["A",C,C,
0,x.largeArc,1,x.x,x.y]);e.startPoint=f}return e},{startPoint:k,arcs:[]}).arcs;if(0!==e.length&&1!==e.length){e.unshift(["M",k.x,k.y]);var l={center:f,d:e}}}return l}})(f||(f={}));return f});p(a,"Series/DrawPointUtilities.js",[a["Core/Utilities.js"]],function(a){function q(a){switch(a.series&&a.series.type){case "treemap":return m(a.plotY)&&null!==a.y;default:return!a.isNull}}var m=a.isNumber;return{draw:function(a,f){var g=f.animatableAttribs,m=f.onComplete,l=f.css,k=f.renderer,w=a.series&&a.series.chart.hasRendered?
void 0:a.series&&a.series.options.animation,u=a.graphic;f.attribs=f.attribs||{};f.attribs["class"]=a.getClassName();if(q(a))u||(a.graphic=u="text"===f.shapeType?k.text():k[f.shapeType](f.shapeArgs||{}),u.add(f.group)),l&&u.css(l),u.attr(f.attribs).animate(g,f.isNew?!1:w,m);else if(u){var p=function(){a.graphic=u=u&&u.destroy();"function"===typeof m&&m()};Object.keys(g).length?u.animate(g,void 0,function(){return p()}):p()}},shouldDraw:q}});p(a,"Series/Venn/VennPoint.js",[a["Core/Series/SeriesRegistry.js"],
a["Core/Utilities.js"]],function(a,q){var m=this&&this.__extends||function(){var a=function(f,g){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,f){a.__proto__=f}||function(a,f){for(var g in f)f.hasOwnProperty(g)&&(a[g]=f[g])};return a(f,g)};return function(f,g){function l(){this.constructor=f}a(f,g);f.prototype=null===g?Object.create(g):(l.prototype=g.prototype,new l)}}(),g=q.isNumber;return function(a){function f(){var f=null!==a&&a.apply(this,arguments)||this;f.options=void 0;
f.series=void 0;return f}m(f,a);f.prototype.isValid=function(){return g(this.value)};f.prototype.shouldDraw=function(){return!!this.shapeArgs};return f}(a.seriesTypes.scatter.prototype.pointClass)});p(a,"Series/Venn/VennUtils.js",[a["Core/Geometry/CircleUtilities.js"],a["Core/Geometry/GeometryUtilities.js"],a["Core/Utilities.js"]],function(a,q,m){function g(a){var c=a.filter(function(a){return 2===a.sets.length}).reduce(function(a,d){d.sets.forEach(function(b,c,z){G(a[b])||(a[b]={overlapping:{},totalOverlap:0});
a[b].totalOverlap+=d.value;a[b].overlapping[z[1-c]]=d.value});return a},{});a.filter(k).forEach(function(a){F(a,c[a.sets[0]])});return a}function f(a,c,b,d,h){var e=a(c),z=a(b);h=h||100;d=d||1e-10;var C=b-c,f=1;if(c>=b)throw Error("a must be smaller than b.");if(0<e*z)throw Error("f(a) and f(b) must have opposite signs.");if(0===e)var g=c;else if(0===z)g=b;else for(;f++<=h&&0!==k&&C>d;){C=(b-c)/2;g=c+C;var k=a(g);0<e*k?c=g:b=g}return g}function p(a){a=a.slice(0,-1);for(var c=a.length,b=[],d=function(a,
b){a.sum+=b[a.i];return a},h=0;h<c;h++)b[h]=a.reduce(d,{sum:0,i:h}).sum/c;return b}function w(a,c,b){var d=a+c;return 0>=b?d:I(a<c?a:c)<=b?0:f(function(d){d=r(a,c,d);return b-d},0,d)}function l(a){var c=0;2===a.length&&(c=a[0],a=a[1],c=r(c.r,a.r,B(c,a)));return c}function k(a){return v(a.sets)&&1===a.sets.length}function K(a){var c={};return G(a)&&A(a.value)&&-1<a.value&&v(a.sets)&&0<a.sets.length&&!a.sets.some(function(a){var b=!1;!c[a]&&E(a)?c[a]=!0:b=!0;return b})}function u(a,c){return c.reduce(function(b,
d){var h=0;1<d.sets.length&&(h=d.value,d=l(d.sets.map(function(b){return a[b]})),d=h-d,h=Math.round(d*d*1E11)/1E11);return b+h},0)}function L(a,c){return c.totalOverlap-a.totalOverlap}var I=a.getAreaOfCircle,D=a.getCircleCircleIntersection,r=a.getOverlapBetweenCircles,e=a.isPointInsideAllCircles,t=a.isPointInsideCircle,n=a.isPointOutsideAllCircles,B=q.getDistanceBetweenPoints,F=m.extend,v=m.isArray,A=m.isNumber,G=m.isObject,E=m.isString;return{geometry:q,geometryCircles:a,addOverlapToSets:g,getCentroid:p,
getDistanceBetweenCirclesByOverlap:w,getLabelWidth:function(a,c,b){var d=c.reduce(function(a,b){return Math.min(b.r,a)},Infinity),h=b.filter(function(b){return!t(a,b)});b=function(b,d){return f(function(z){var f={x:a.x+d*z,y:a.y};f=e(f,c)&&n(f,h);return-(b-z)+(f?0:Number.MAX_VALUE)},0,b)};return 2*Math.min(b(d,-1),b(d,1))},getMarginFromCircles:function(a,c,b){c=c.reduce(function(b,h){h=h.r-B(a,h);return h<=b?h:b},Number.MAX_VALUE);return c=b.reduce(function(b,h){h=B(a,h)-h.r;return h<=b?h:b},c)},
isSet:k,layoutGreedyVenn:function(a){var c=[],b={};a.filter(function(a){return 1===a.sets.length}).forEach(function(a){b[a.sets[0]]=a.circle={x:Number.MAX_VALUE,y:Number.MAX_VALUE,r:Math.sqrt(a.value/Math.PI)}});var d=function(a,b){var d=a.circle;d.x=b.x;d.y=b.y;c.push(a)};g(a);var h=a.filter(k).sort(L);d(h.shift(),{x:0,y:0});var e=a.filter(function(a){return 2===a.sets.length});h.forEach(function(a){var h=a.circle,f=h.r,z=a.overlapping,g=c.reduce(function(a,d,g){var y=d.circle,k=w(f,y.r,z[d.sets[0]]),
J=[{x:y.x+k,y:y.y},{x:y.x-k,y:y.y},{x:y.x,y:y.y+k},{x:y.x,y:y.y-k}];c.slice(g+1).forEach(function(a){var b=a.circle;a=w(f,b.r,z[a.sets[0]]);J=J.concat(D({x:y.x,y:y.y,r:k},{x:b.x,y:b.y,r:a}))});J.forEach(function(d){h.x=d.x;h.y=d.y;var c=u(b,e);c<a.loss&&(a.loss=c,a.coordinates=d)});return a},{loss:Number.MAX_VALUE,coordinates:void 0});d(a,g.coordinates)});return b},loss:u,nelderMead:function(a,c){var b=function(a,b){return a.fx-b.fx},d=function(a,b,d,h){return b.map(function(b,c){return a*b+d*h[c]})},
h=function(b,d){d.fx=a(d);b[b.length-1]=d;return b},f=function(b){var h=b[0];return b.map(function(b){b=d(.5,h,.5,b);b.fx=a(b);return b})},e=function(b,h,c,e){b=d(c,b,e,h);b.fx=a(b);return b};c=function(b){var d=b.length,h=Array(d+1);h[0]=b;h[0].fx=a(b);for(var c=0;c<d;++c){var e=b.slice();e[c]=e[c]?1.05*e[c]:.001;e.fx=a(e);h[c+1]=e}return h}(c);for(var g=0;100>g;g++){c.sort(b);var k=c[c.length-1],H=p(c),l=e(H,k,2,-1);if(l.fx<c[0].fx)k=e(H,k,3,-2),c=h(c,k.fx<l.fx?k:l);else if(l.fx>=c[c.length-2].fx){var m=
void 0;l.fx>k.fx?(m=e(H,k,.5,.5),c=m.fx<k.fx?h(c,m):f(c)):(m=e(H,k,1.5,-.5),c=m.fx<l.fx?h(c,m):f(c))}else c=h(c,l)}return c[0]},processVennData:function(a){a=v(a)?a:[];var c=a.reduce(function(a,b){K(b)&&k(b)&&0<b.value&&-1===a.indexOf(b.sets[0])&&a.push(b.sets[0]);return a},[]).sort(),b=a.reduce(function(a,b){K(b)&&!b.sets.some(function(a){return-1===c.indexOf(a)})&&(a[b.sets.sort().join()]=b);return a},{});c.reduce(function(a,b,c,e){e.slice(c+1).forEach(function(d){a.push(b+","+d)});return a},[]).forEach(function(a){if(!b[a]){var d=
{sets:a.split(","),value:0};b[a]=d}});return Object.keys(b).map(function(a){return b[a]})},sortByTotalOverlap:L}});p(a,"Series/Venn/VennSeries.js",[a["Core/Animation/AnimationUtilities.js"],a["Core/Color/Color.js"],a["Core/Geometry/CircleUtilities.js"],a["Series/DrawPointUtilities.js"],a["Core/Geometry/GeometryUtilities.js"],a["Core/Series/SeriesRegistry.js"],a["Series/Venn/VennPoint.js"],a["Series/Venn/VennUtils.js"],a["Core/Utilities.js"]],function(a,p,m,g,f,x,M,l,k){var q=this&&this.__extends||
function(){var a=function(c,b){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return a(c,b)};return function(c,b){function d(){this.constructor=c}a(c,b);c.prototype=null===b?Object.create(b):(d.prototype=b.prototype,new d)}}(),u=a.animObject,w=p.parse,I=m.getAreaOfIntersectionBetweenCircles,D=m.getCirclesIntersectionPolygon,r=m.isCircle1CompletelyOverlappingCircle2,e=m.isPointInsideAllCircles,t=
m.isPointOutsideAllCircles,n=f.getCenterOfPoints,B=x.seriesTypes.scatter;a=k.addEvent;var F=k.extend,v=k.isArray,A=k.isNumber,G=k.isObject,E=k.merge;k=function(a){function c(){var b=null!==a&&a.apply(this,arguments)||this;b.data=void 0;b.mapOfIdToRelation=void 0;b.options=void 0;b.points=void 0;return b}q(c,a);c.getLabelPosition=function(a,c){var b=a.reduce(function(b,d){var e=d.r/2;return[{x:d.x,y:d.y},{x:d.x+e,y:d.y},{x:d.x-e,y:d.y},{x:d.x,y:d.y+e},{x:d.x,y:d.y-e}].reduce(function(b,d){var e=l.getMarginFromCircles(d,
a,c);b.margin<e&&(b.point=d,b.margin=e);return b},b)},{point:void 0,margin:-Number.MAX_VALUE}).point;b=l.nelderMead(function(b){return-l.getMarginFromCircles({x:b[0],y:b[1]},a,c)},[b.x,b.y]);b={x:b[0],y:b[1]};e(b,a)&&t(b,c)||(b=1<a.length?n(D(a)):{x:a[0].x,y:a[0].y});return b};c.getLabelValues=function(a,d){var b=a.sets,e=d.reduce(function(a,d){var c=-1<b.indexOf(d.sets[0]);a[c?"internal":"external"].push(d.circle);return a},{internal:[],external:[]});e.external=e.external.filter(function(a){return e.internal.some(function(b){return!r(a,
b)})});a=c.getLabelPosition(e.internal,e.external);d=l.getLabelWidth(a,e.internal,e.external);return{position:a,width:d}};c.layout=function(a){var b={},e={};if(0<a.length){var f=l.layoutGreedyVenn(a),g=a.filter(l.isSet);a.forEach(function(a){var d=a.sets,h=d.join();if(d=l.isSet(a)?f[h]:I(d.map(function(a){return f[a]})))b[h]=d,e[h]=c.getLabelValues(a,g)})}return{mapOfIdToShape:b,mapOfIdToLabelValues:e}};c.getScale=function(a,d,c){var b=c.bottom-c.top,e=c.right-c.left;b=Math.min(0<e?1/e*a:1,0<b?1/
b*d:1);return{scale:b,centerX:a/2-(c.right+c.left)/2*b,centerY:d/2-(c.top+c.bottom)/2*b}};c.updateFieldBoundaries=function(a,c){var b=c.x-c.r,d=c.x+c.r,e=c.y+c.r;c=c.y-c.r;if(!A(a.left)||a.left>b)a.left=b;if(!A(a.right)||a.right<d)a.right=d;if(!A(a.top)||a.top>c)a.top=c;if(!A(a.bottom)||a.bottom<e)a.bottom=e;return a};c.prototype.animate=function(a){if(!a){var b=u(this.options.animation);this.points.forEach(function(a){var c=a.shapeArgs;if(a.graphic&&c){var d={},e={};c.d?d.opacity=.001:(d.r=0,e.r=
c.r);a.graphic.attr(d).animate(e,b);c.d&&setTimeout(function(){a&&a.graphic&&a.graphic.animate({opacity:1})},b.duration)}},this)}};c.prototype.drawPoints=function(){var a=this,c=a.chart,e=a.group,f=c.renderer;(a.points||[]).forEach(function(b){var d={zIndex:v(b.sets)?b.sets.length:0},h=b.shapeArgs;c.styledMode||F(d,a.pointAttribs(b,b.state));g.draw(b,{isNew:!b.graphic,animatableAttribs:h,attribs:d,group:e,renderer:f,shapeType:h&&h.d?"path":"circle"})})};c.prototype.init=function(){B.prototype.init.apply(this,
arguments);delete this.opacity};c.prototype.pointAttribs=function(a,c){var b=this.options||{};a=E(b,{color:a&&a.color},a&&a.options||{},c&&b.states[c]||{});return{fill:w(a.color).brighten(a.brightness).get(),opacity:a.opacity,stroke:a.borderColor,"stroke-width":a.borderWidth,dashstyle:a.borderDashStyle}};c.prototype.translate=function(){var a=this.chart;this.processedXData=this.xData;this.generatePoints();var d=l.processVennData(this.options.data);d=c.layout(d);var e=d.mapOfIdToShape,f=d.mapOfIdToLabelValues;
d=Object.keys(e).filter(function(a){return(a=e[a])&&A(a.r)}).reduce(function(a,b){return c.updateFieldBoundaries(a,e[b])},{top:0,bottom:0,left:0,right:0});a=c.getScale(a.plotWidth,a.plotHeight,d);var g=a.scale,k=a.centerX,m=a.centerY;this.points.forEach(function(a){var b=v(a.sets)?a.sets:[],c=b.join(),d=e[c],h=f[c]||{};c=h.width;h=h.position;var l=a.options&&a.options.dataLabels;if(d){if(d.r)var n={x:k+d.x*g,y:m+d.y*g,r:d.r*g};else d.d&&(d=d.d,d.forEach(function(a){"M"===a[0]?(a[1]=k+a[1]*g,a[2]=
m+a[2]*g):"A"===a[0]&&(a[1]*=g,a[2]*=g,a[6]=k+a[6]*g,a[7]=m+a[7]*g)}),n={d:d});h?(h.x=k+h.x*g,h.y=m+h.y*g):h={};A(c)&&(c=Math.round(c*g))}a.shapeArgs=n;h&&n&&(a.plotX=h.x,a.plotY=h.y);c&&n&&(a.dlOptions=E(!0,{style:{width:c}},G(l,!0)?l:void 0));a.name=a.options.name||b.join("\u2229")})};c.defaultOptions=E(B.defaultOptions,{borderColor:"#cccccc",borderDashStyle:"solid",borderWidth:1,brighten:0,clip:!1,colorByPoint:!0,dataLabels:{enabled:!0,verticalAlign:"middle",formatter:function(){return this.point.name}},
inactiveOtherPoints:!0,marker:!1,opacity:.75,showInLegend:!1,states:{hover:{opacity:1,borderColor:"#333333"},select:{color:"#cccccc",borderColor:"#000000",animation:!1},inactive:{opacity:.075}},tooltip:{pointFormat:"{point.name}: {point.value}"}});return c}(B);F(k.prototype,{axisTypes:[],directTouch:!0,isCartesian:!1,pointArrayMap:["value"],pointClass:M,utils:l});x.registerSeriesType("venn",k);"";a(k,"afterSetOptions",function(a){var c=a.options.states;this.is("venn")&&Object.keys(c).forEach(function(a){c[a].halo=
!1})});return k});p(a,"masters/modules/venn.src.js",[],function(){})});
//# sourceMappingURL=venn.js.map