/*
 Highcharts JS v8.2.0 (2020-08-20)

 Sankey diagram module

 (c) 2010-2019 Torstein Honsi

 License: www.highcharts.com/license
*/
(function(b){"object"===typeof module&&module.exports?(b["default"]=b,module.exports=b):"function"===typeof define&&define.amd?define("highcharts/modules/sankey",["highcharts"],function(k){b(k);b.Highcharts=k;return b}):b("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(b){function k(b,e,m,u){b.hasOwnProperty(e)||(b[e]=u.apply(null,m))}b=b?b._modules:{};k(b,"Mixins/Nodes.js",[b["Core/Globals.js"],b["Core/Series/Point.js"],b["Core/Utilities.js"]],function(b,e,m){var u=m.defined,n=m.extend,
p=m.find,w=m.pick;return b.NodesMixin={createNode:function(b){function d(a,d){return p(a,function(a){return a.id===d})}var a=d(this.nodes,b),r=this.pointClass;if(!a){var e=this.options.nodes&&d(this.options.nodes,b);a=(new r).init(this,n({className:"highcharts-node",isNode:!0,id:b,y:1},e));a.linksTo=[];a.linksFrom=[];a.formatPrefix="node";a.name=a.name||a.options.id||"";a.mass=w(a.options.mass,a.options.marker&&a.options.marker.radius,this.options.marker&&this.options.marker.radius,4);a.getSum=function(){var d=
0,b=0;a.linksTo.forEach(function(a){d+=a.weight});a.linksFrom.forEach(function(a){b+=a.weight});return Math.max(d,b)};a.offset=function(d,b){for(var r=0,c=0;c<a[b].length;c++){if(a[b][c]===d)return r;r+=a[b][c].weight}};a.hasShape=function(){var d=0;a.linksTo.forEach(function(a){a.outgoing&&d++});return!a.linksTo.length||d!==a.linksTo.length};this.nodes.push(a)}return a},generatePoints:function(){var e=this.chart,d={};b.Series.prototype.generatePoints.call(this);this.nodes||(this.nodes=[]);this.colorCounter=
0;this.nodes.forEach(function(a){a.linksFrom.length=0;a.linksTo.length=0;a.level=a.options.level});this.points.forEach(function(a){u(a.from)&&(d[a.from]||(d[a.from]=this.createNode(a.from)),d[a.from].linksFrom.push(a),a.fromNode=d[a.from],e.styledMode?a.colorIndex=w(a.options.colorIndex,d[a.from].colorIndex):a.color=a.options.color||d[a.from].color);u(a.to)&&(d[a.to]||(d[a.to]=this.createNode(a.to)),d[a.to].linksTo.push(a),a.toNode=d[a.to]);a.name=a.name||a.id},this);this.nodeLookup=d},setData:function(){this.nodes&&
(this.nodes.forEach(function(b){b.destroy()}),this.nodes.length=0);b.Series.prototype.setData.apply(this,arguments)},destroy:function(){this.data=[].concat(this.points||[],this.nodes);return b.Series.prototype.destroy.apply(this,arguments)},setNodeState:function(b){var d=arguments,a=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==b&&a.forEach(function(a){a&&a.series&&(e.prototype.setState.apply(a,d),a.isNode||(a.fromNode.graphic&&e.prototype.setState.apply(a.fromNode,
d),a.toNode&&a.toNode.graphic&&e.prototype.setState.apply(a.toNode,d)))});e.prototype.setState.apply(this,d)}}});k(b,"Mixins/TreeSeries.js",[b["Core/Color.js"],b["Core/Utilities.js"]],function(b,e){var m=e.extend,u=e.isArray,n=e.isNumber,p=e.isObject,w=e.merge,k=e.pick;return{getColor:function(d,a){var r=a.index,e=a.mapOptionsToLevel,m=a.parentColor,n=a.parentColorIndex,v=a.series,c=a.colors,g=a.siblings,l=v.points,x=v.chart.options.chart,h;if(d){l=l[d.i];d=e[d.level]||{};if(e=l&&d.colorByPoint){var G=
l.index%(c?c.length:x.colorCount);var f=c&&c[G]}if(!v.chart.styledMode){c=l&&l.options.color;x=d&&d.color;if(h=m)h=(h=d&&d.colorVariation)&&"brightness"===h.key?b.parse(m).brighten(r/g*h.to).get():m;h=k(c,x,f,h,v.color)}var q=k(l&&l.options.colorIndex,d&&d.colorIndex,G,n,a.colorIndex)}return{color:h,colorIndex:q}},getLevelOptions:function(d){var a=null;if(p(d)){a={};var b=n(d.from)?d.from:1;var e=d.levels;var k={};var z=p(d.defaults)?d.defaults:{};u(e)&&(k=e.reduce(function(a,c){if(p(c)&&n(c.level)){var g=
w({},c);var l="boolean"===typeof g.levelIsConstant?g.levelIsConstant:z.levelIsConstant;delete g.levelIsConstant;delete g.level;c=c.level+(l?0:b-1);p(a[c])?m(a[c],g):a[c]=g}return a},{}));e=n(d.to)?d.to:1;for(d=0;d<=e;d++)a[d]=w({},z,p(k[d])?k[d]:{})}return a},setTreeValues:function y(a,b){var e=b.before,n=b.idRoot,r=b.mapIdToNode[n],c=b.points[a.i],g=c&&c.options||{},l=0,x=[];m(a,{levelDynamic:a.level-(("boolean"===typeof b.levelIsConstant?b.levelIsConstant:1)?0:r.level),name:k(c&&c.name,""),visible:n===
a.id||("boolean"===typeof b.visible?b.visible:!1)});"function"===typeof e&&(a=e(a,b));a.children.forEach(function(c,g){var h=m({},b);m(h,{index:g,siblings:a.children.length,visible:a.visible});c=y(c,h);x.push(c);c.visible&&(l+=c.val)});a.visible=0<l||a.visible;e=k(g.value,l);m(a,{children:x,childrenTotal:l,isLeaf:a.visible&&!l,val:e});return a},updateRootId:function(a){if(p(a)){var b=p(a.options)?a.options:{};b=k(a.rootNode,b.rootId,"");p(a.userOptions)&&(a.userOptions.rootId=b);a.rootNode=b}return b}}});
k(b,"Series/SankeySeries.js",[b["Core/Globals.js"],b["Mixins/Nodes.js"],b["Core/Color.js"],b["Core/Series/Point.js"],b["Core/Utilities.js"],b["Mixins/TreeSeries.js"]],function(b,e,m,k,n,p){var w=n.defined,u=n.find,d=n.isObject,a=n.merge,r=n.pick,y=n.relativeLength,L=n.seriesType,z=n.stableSort,v=p.getLevelOptions;L("sankey","column",{borderWidth:0,colorByPoint:!0,curveFactor:.33,dataLabels:{enabled:!0,backgroundColor:"none",crop:!1,nodeFormat:void 0,nodeFormatter:function(){return this.point.name},
format:void 0,formatter:function(){},inside:!0},inactiveOtherPoints:!0,linkOpacity:.5,minLinkWidth:0,nodeWidth:20,nodePadding:10,showInLegend:!1,states:{hover:{linkOpacity:1},inactive:{linkOpacity:.1,opacity:.1,animation:{duration:50}}},tooltip:{followPointer:!0,headerFormat:'<span style="font-size: 10px">{series.name}</span><br/>',pointFormat:"{point.fromNode.name} \u2192 {point.toNode.name}: <b>{point.weight}</b><br/>",nodeFormat:"{point.name}: <b>{point.sum}</b><br/>"}},{isCartesian:!1,invertable:!0,
forceDL:!0,orderNodes:!0,pointArrayMap:["from","to"],createNode:e.createNode,searchPoint:b.noop,setData:e.setData,destroy:e.destroy,getNodePadding:function(){var a=this.options.nodePadding||0;if(this.nodeColumns){var b=this.nodeColumns.reduce(function(a,c){return Math.max(a,c.length)},0);b*a>this.chart.plotSizeY&&(a=this.chart.plotSizeY/b)}return a},createNodeColumn:function(){var a=this,b=this.chart,l=[];l.sum=function(){return this.reduce(function(a,c){return a+c.getSum()},0)};l.offset=function(c,
b){for(var g=0,d,h=a.nodePadding,x=0;x<l.length;x++){d=l[x].getSum();var e=Math.max(d*b,a.options.minLinkWidth);d=d?e+h:0;if(l[x]===c)return{relativeTop:g+y(c.options.offset||0,d)};g+=d}};l.top=function(c){var d=a.nodePadding,g=this.reduce(function(b,g){0<b&&(b+=d);g=Math.max(g.getSum()*c,a.options.minLinkWidth);return b+g},0);return(b.plotSizeY-g)/2};return l},createNodeColumns:function(){var a=[];this.nodes.forEach(function(c){var b=-1,d;if(!w(c.options.column))if(0===c.linksTo.length)c.column=
0;else{for(d=0;d<c.linksTo.length;d++){var g=c.linksTo[0];if(g.fromNode.column>b){var l=g.fromNode;b=l.column}}c.column=b+1;l&&"hanging"===l.options.layout&&(c.hangsFrom=l,d=-1,u(l.linksFrom,function(a,b){(a=a.toNode===c)&&(d=b);return a}),c.column+=d)}a[c.column]||(a[c.column]=this.createNodeColumn());a[c.column].push(c)},this);for(var b=0;b<a.length;b++)"undefined"===typeof a[b]&&(a[b]=this.createNodeColumn());return a},hasData:function(){return!!this.processedXData.length},pointAttribs:function(a,
b){var c=this,d=c.mapOptionsToLevel[(a.isNode?a.level:a.fromNode.level)||0]||{},g=a.options,e=d.states&&d.states[b]||{};b=["colorByPoint","borderColor","borderWidth","linkOpacity"].reduce(function(a,b){a[b]=r(e[b],g[b],d[b],c.options[b]);return a},{});var f=r(e.color,g.color,b.colorByPoint?a.color:d.color);return a.isNode?{fill:f,stroke:b.borderColor,"stroke-width":b.borderWidth}:{fill:m.parse(f).setOpacity(b.linkOpacity).get()}},generatePoints:function(){function a(c,b){"undefined"===typeof c.level&&
(c.level=b,c.linksFrom.forEach(function(c){c.toNode&&a(c.toNode,b+1)}))}e.generatePoints.apply(this,arguments);this.orderNodes&&(this.nodes.filter(function(a){return 0===a.linksTo.length}).forEach(function(c){a(c,0)}),z(this.nodes,function(a,c){return a.level-c.level}))},translateNode:function(c,b){var g=this.translationFactor,e=this.chart,h=this.options,k=c.getSum(),f=Math.max(Math.round(k*g),this.options.minLinkWidth),q=Math.round(h.borderWidth)%2/2,t=b.offset(c,g);b=Math.floor(r(t.absoluteTop,
b.top(g)+t.relativeTop))+q;q=Math.floor(this.colDistance*c.column+h.borderWidth/2)+q;q=e.inverted?e.plotSizeX-q:q;g=Math.round(this.nodeWidth);(c.sum=k)?(c.shapeType="rect",c.nodeX=q,c.nodeY=b,c.shapeArgs=e.inverted?{x:q-g,y:e.plotSizeY-b-f,width:c.options.height||h.height||g,height:c.options.width||h.width||f}:{x:q,y:b,width:c.options.width||h.width||g,height:c.options.height||h.height||f},c.shapeArgs.display=c.hasShape()?"":"none",h=this.mapOptionsToLevel[c.level],k=c.options,k=d(k)?k.dataLabels:
{},h=d(h)?h.dataLabels:{},h=a({style:{}},h,k),c.dlOptions=h,c.plotY=1,c.tooltipPos=e.inverted?[e.plotSizeY-c.shapeArgs.y-c.shapeArgs.height/2,e.plotSizeX-c.shapeArgs.x-c.shapeArgs.width/2]:[c.shapeArgs.x+c.shapeArgs.width/2,c.shapeArgs.y+c.shapeArgs.height/2]):c.dlOptions={enabled:!1}},translateLink:function(a){var b=function(b,c){var d;c=b.offset(a,c)*k;return Math.min(b.nodeY+c,b.nodeY+(null===(d=b.shapeArgs)||void 0===d?void 0:d.height)-f)},c=a.fromNode,d=a.toNode,e=this.chart,k=this.translationFactor,
f=Math.max(a.weight*k,this.options.minLinkWidth),q=(e.inverted?-this.colDistance:this.colDistance)*this.options.curveFactor,t=b(c,"linksFrom");b=b(d,"linksTo");var n=c.nodeX,m=this.nodeWidth;d=d.column*this.colDistance;var p=a.outgoing,A=d>n+m;e.inverted&&(t=e.plotSizeY-t,b=(e.plotSizeY||0)-b,d=e.plotSizeX-d,m=-m,f=-f,A=n>d);a.shapeType="path";a.linkBase=[t,t+f,b,b+f];if(A&&"number"===typeof b)a.shapeArgs={d:[["M",n+m,t],["C",n+m+q,t,d-q,b,d,b],["L",d+(p?m:0),b+f/2],["L",d,b+f],["C",d-q,b+f,n+m+q,
t+f,n+m,t+f],["Z"]]};else if("number"===typeof b){q=d-20-f;p=d-20;A=d;var r=n+m,C=r+20,u=C+f,w=t,v=t+f,z=v+20,D=z+(e.plotHeight-t-f),B=D+20,y=B+f,F=b,E=F+f,H=E+20,I=B+.7*f,J=A-.7*f,K=r+.7*f;a.shapeArgs={d:[["M",r,w],["C",K,w,u,v-.7*f,u,z],["L",u,D],["C",u,I,K,y,r,y],["L",A,y],["C",J,y,q,I,q,D],["L",q,H],["C",q,E-.7*f,J,F,A,F],["L",A,E],["C",p,E,p,E,p,H],["L",p,D],["C",p,B,p,B,A,B],["L",r,B],["C",C,B,C,B,C,D],["L",C,z],["C",C,v,C,v,r,v],["Z"]]}}a.dlBox={x:n+(d-n+m)/2,y:t+(b-t)/2,height:f,width:0};
a.tooltipPos=e.inverted?[e.plotSizeY-a.dlBox.y-f/2,e.plotSizeX-a.dlBox.x]:[a.dlBox.x,a.dlBox.y+f/2];a.y=a.plotY=1;a.color||(a.color=c.color)},translate:function(){var a=this,b=function(b){for(var c=b.slice(),f=a.options.minLinkWidth||0,g,k=0,l,m=e.plotSizeY-h.borderWidth-(b.length-1)*d.nodePadding;b.length;){k=m/b.sum();g=!1;for(l=b.length;l--;)b[l].getSum()*k<f&&(b.splice(l,1),m-=f,g=!0);if(!g)break}b.length=0;c.forEach(function(a){return b.push(a)});return k};this.processedXData||this.processData();
this.generatePoints();this.nodeColumns=this.createNodeColumns();this.nodeWidth=y(this.options.nodeWidth,this.chart.plotSizeX);var d=this,e=this.chart,h=this.options,k=this.nodeWidth,f=this.nodeColumns;this.nodePadding=this.getNodePadding();this.translationFactor=f.reduce(function(a,c){return Math.min(a,b(c))},Infinity);this.colDistance=(e.plotSizeX-k-h.borderWidth)/Math.max(1,f.length-1);d.mapOptionsToLevel=v({from:1,levels:h.levels,to:f.length-1,defaults:{borderColor:h.borderColor,borderRadius:h.borderRadius,
borderWidth:h.borderWidth,color:d.color,colorByPoint:h.colorByPoint,levelIsConstant:!0,linkColor:h.linkColor,linkLineWidth:h.linkLineWidth,linkOpacity:h.linkOpacity,states:h.states}});f.forEach(function(a){a.forEach(function(b){d.translateNode(b,a)})},this);this.nodes.forEach(function(a){a.linksFrom.forEach(function(a){(a.weight||a.isNull)&&a.to&&(d.translateLink(a),a.allowShadow=!1)})})},render:function(){var a=this.points;this.points=this.points.concat(this.nodes||[]);b.seriesTypes.column.prototype.render.call(this);
this.points=a},animate:b.Series.prototype.animate},{applyOptions:function(a,b){k.prototype.applyOptions.call(this,a,b);w(this.options.level)&&(this.options.column=this.column=this.options.level);return this},setState:e.setNodeState,getClassName:function(){return(this.isNode?"highcharts-node ":"highcharts-link ")+k.prototype.getClassName.call(this)},isValid:function(){return this.isNode||"number"===typeof this.weight}});""});k(b,"masters/modules/sankey.src.js",[],function(){})});
//# sourceMappingURL=sankey.js.map