katucharts.js 0.2.21 → 0.2.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- (function(_t,Te){typeof exports=="object"&&typeof module<"u"?Te(exports):typeof define=="function"&&define.amd?define(["exports"],Te):(_t=typeof globalThis<"u"?globalThis:_t||self,Te(_t.KatuCharts={}))})(this,function(_t){"use strict";var s5=Object.defineProperty;var a5=(_t,Te,oi)=>Te in _t?s5(_t,Te,{enumerable:!0,configurable:!0,writable:!0,value:oi}):_t[Te]=oi;var vt=(_t,Te,oi)=>a5(_t,typeof Te!="symbol"?Te+"":Te,oi);function Te(n,t,e){n.prototype=t.prototype=e,e.constructor=n}function oi(n,t){var e=Object.create(n.prototype);for(var i in t)e[i]=t[i];return e}function sr(){}var ar=.7,ro=1/ar,Ei="\\s*([+-]?\\d+)\\s*",cr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",kn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",tg=/^#([0-9a-f]{3,8})$/,eg=new RegExp(`^rgb\\(${Ei},${Ei},${Ei}\\)$`),ng=new RegExp(`^rgb\\(${kn},${kn},${kn}\\)$`),ig=new RegExp(`^rgba\\(${Ei},${Ei},${Ei},${cr}\\)$`),rg=new RegExp(`^rgba\\(${kn},${kn},${kn},${cr}\\)$`),og=new RegExp(`^hsl\\(${cr},${kn},${kn}\\)$`),sg=new RegExp(`^hsla\\(${cr},${kn},${kn},${cr}\\)$`),Cl={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Te(sr,ce,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Pl,formatHex:Pl,formatHex8:ag,formatHsl:cg,formatRgb:El,toString:El});function Pl(){return this.rgb().formatHex()}function ag(){return this.rgb().formatHex8()}function cg(){return Fl(this).formatHsl()}function El(){return this.rgb().formatRgb()}function ce(n){var t,e;return n=(n+"").trim().toLowerCase(),(t=tg.exec(n))?(e=t[1].length,t=parseInt(t[1],16),e===6?Tl(t):e===3?new We(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?oo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?oo(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=eg.exec(n))?new We(t[1],t[2],t[3],1):(t=ng.exec(n))?new We(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ig.exec(n))?oo(t[1],t[2],t[3],t[4]):(t=rg.exec(n))?oo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=og.exec(n))?Il(t[1],t[2]/100,t[3]/100,1):(t=sg.exec(n))?Il(t[1],t[2]/100,t[3]/100,t[4]):Cl.hasOwnProperty(n)?Tl(Cl[n]):n==="transparent"?new We(NaN,NaN,NaN,0):null}function Tl(n){return new We(n>>16&255,n>>8&255,n&255,1)}function oo(n,t,e,i){return i<=0&&(n=t=e=NaN),new We(n,t,e,i)}function lg(n){return n instanceof sr||(n=ce(n)),n?(n=n.rgb(),new We(n.r,n.g,n.b,n.opacity)):new We}function je(n,t,e,i){return arguments.length===1?lg(n):new We(n,t,e,i??1)}function We(n,t,e,i){this.r=+n,this.g=+t,this.b=+e,this.opacity=+i}Te(We,je,oi(sr,{brighter(n){return n=n==null?ro:Math.pow(ro,n),new We(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?ar:Math.pow(ar,n),new We(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new We(si(this.r),si(this.g),si(this.b),so(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ll,formatHex:Ll,formatHex8:hg,formatRgb:$l,toString:$l}));function Ll(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}`}function hg(){return`#${ai(this.r)}${ai(this.g)}${ai(this.b)}${ai((isNaN(this.opacity)?1:this.opacity)*255)}`}function $l(){const n=so(this.opacity);return`${n===1?"rgb(":"rgba("}${si(this.r)}, ${si(this.g)}, ${si(this.b)}${n===1?")":`, ${n})`}`}function so(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function si(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function ai(n){return n=si(n),(n<16?"0":"")+n.toString(16)}function Il(n,t,e,i){return i<=0?n=t=e=NaN:e<=0||e>=1?n=t=NaN:t<=0&&(n=NaN),new pn(n,t,e,i)}function Fl(n){if(n instanceof pn)return new pn(n.h,n.s,n.l,n.opacity);if(n instanceof sr||(n=ce(n)),!n)return new pn;if(n instanceof pn)return n;n=n.rgb();var t=n.r/255,e=n.g/255,i=n.b/255,r=Math.min(t,e,i),o=Math.max(t,e,i),s=NaN,a=o-r,c=(o+r)/2;return a?(t===o?s=(e-i)/a+(e<i)*6:e===o?s=(i-t)/a+2:s=(t-e)/a+4,a/=c<.5?o+r:2-o-r,s*=60):a=c>0&&c<1?0:s,new pn(s,a,c,n.opacity)}function ci(n,t,e,i){return arguments.length===1?Fl(n):new pn(n,t,e,i??1)}function pn(n,t,e,i){this.h=+n,this.s=+t,this.l=+e,this.opacity=+i}Te(pn,ci,oi(sr,{brighter(n){return n=n==null?ro:Math.pow(ro,n),new pn(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?ar:Math.pow(ar,n),new pn(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,t=isNaN(n)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*t,r=2*e-i;return new We(Us(n>=240?n-240:n+120,r,i),Us(n,r,i),Us(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new pn(Rl(this.h),ao(this.s),ao(this.l),so(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=so(this.opacity);return`${n===1?"hsl(":"hsla("}${Rl(this.h)}, ${ao(this.s)*100}%, ${ao(this.l)*100}%${n===1?")":`, ${n})`}`}}));function Rl(n){return n=(n||0)%360,n<0?n+360:n}function ao(n){return Math.max(0,Math.min(1,n||0))}function Us(n,t,e){return(n<60?t+(e-t)*n/60:n<180?e:n<240?t+(e-t)*(240-n)/60:t)*255}const co=new Map,ug=256;function lo(n){const t=n||"rgba(0,0,0,0)",e=co.get(t);if(e)return e;const i="rgba(0,0,0,0)",r=ce(n||i),o=je(r||i),s={r:Math.round(o.r),g:Math.round(o.g),b:Math.round(o.b),a:o.opacity,get(a){return a==="rgba"?this.toString():this.toString()},brighten(a){const c=ci(je(this.r,this.g,this.b,this.a));c.l+=a*.1,c.l=Math.max(0,Math.min(1,c.l));const l=je(c);return lo(l.formatRgb())},setOpacity(a){return lo(`rgba(${this.r},${this.g},${this.b},${a})`)},toString(){return this.a<1?`rgba(${this.r},${this.g},${this.b},${this.a})`:je(this.r,this.g,this.b).formatHex()}};return co.size>=ug&&co.clear(),co.set(t,s),s}const ho={default:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],tableau10:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],d3classic:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],brewer:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],google:["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395"],ocean:["#003f5c","#2f4b7c","#665191","#a05195","#d45087","#f95d6a","#ff7c43","#ffa600","#58508d","#bc5090"],sunset:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],earth:["#8c510a","#bf812d","#dfc27d","#c7eae5","#80cdc1","#35978f","#01665e","#543005","#003c30","#f6e8c3"],forest:["#2d6a4f","#40916c","#52b788","#74c69d","#95d5b2","#1b4332","#081c15","#b7e4c7","#d8f3dc","#344e41"],berry:["#7b2cbf","#9d4edd","#c77dff","#e0aaff","#5a189a","#3c096c","#240046","#10002b","#e2afff","#deaaff"],corporate:["#2c3e50","#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085"],minimal:["#264653","#2a9d8f","#e9c46a","#f4a261","#e76f51","#606c38","#283618","#dda15e","#bc6c25","#fefae0"],nordic:["#5e81ac","#81a1c1","#88c0d0","#8fbcbb","#bf616a","#d08770","#ebcb8b","#a3be8c","#b48ead","#4c566a"],darkMode:["#2ecc71","#3498db","#e74c3c","#f1c40f","#9b59b6","#1abc9c","#e67e22","#ecf0f1","#e91e63","#00bcd4"],neon:["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff","#06d6a0","#118ab2","#ef476f","#ffd166","#073b4c"],pastel:["#a8e6cf","#dcedc1","#ffd3b6","#ffaaa5","#ff8b94","#b5ead7","#c7ceea","#e2f0cb","#fceaea","#d4a5a5"],soft:["#6c9bd2","#e6a756","#d46a6a","#7cc5a8","#b28fce","#e8937f","#6bb8a0","#d4b56a","#8e9cc2","#c2847a"],classic:["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"],tupi:["#b43417","#1b1a15","#a85429","#ce9a3a","#33503a","#8c2810","#6b6a45","#d97b3f","#5b5240","#7a3b2e"],monochrome:["#1f2933","#3e4c59","#52606d","#7b8794","#9aa5b1","#616e7c","#cbd2d9","#323f4b","#7b8794","#b8c0c9"]};function Dl(n){return ho[n]||ho.default}const fg=ho.default,dg={textStrong:"#1f2933",textSoft:"#52606d",axis:"#6b7280",line:"#c8ccd2",grid:"#e6e8eb",tooltipBg:"rgba(255,255,255,0.96)",tooltipBorder:"#d8dce0",legend:"#52606d"},pg={textStrong:"#f3f4f6",textSoft:"#b8bfc7",axis:"#9aa3ad",line:"#3a414a",grid:"rgba(255,255,255,0.08)",tooltipBg:"#20262e",tooltipBorder:"#39414b",legend:"#c2c9d1"};function zl(n,t,e){const i={gridLineColor:e.grid,lineColor:e.line,tickColor:e.line,labels:{style:{color:e.axis}},title:{style:{color:e.axis}}};return{colors:n,chart:{backgroundColor:t},title:{style:{color:e.textStrong}},subtitle:{style:{color:e.textSoft}},xAxis:i,yAxis:i,tooltip:{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,style:{color:e.textStrong}},legend:{itemStyle:{color:e.legend},itemHoverStyle:{color:e.textStrong}}}}const js={tupi:{light:["#b43417","#1b1a15","#a85429","#ce9a3a","#33503a","#8c2810","#6b6a45","#d97b3f","#5b5240","#7a3b2e"],dark:["#e0673f","#e7dbc0","#d08a4e","#e8c45f","#6fa37a","#c84c2c","#c9b27a","#f0a06a","#a9a07e","#d98b6a"]},ocean:{light:["#0466c8","#0353a4","#3a86ff","#00b4d8","#0096c7","#48cae4","#023e8a","#5e60ce","#0077b6","#90e0ef"],dark:["#48cae4","#4895ef","#56cfe1","#64dfdf","#80ffdb","#5390d9","#7400b8","#4cc9f0","#56cfe1","#72efdd"]},sunset:{light:["#ff6b35","#f7522f","#ff9e00","#ffbf69","#e85d75","#d1495b","#ffd166","#9e2a2b","#f3722c","#bc4749"],dark:["#ff7b54","#ffb26b","#ffd56b","#ff9e7d","#ff6b6b","#feca57","#ff9ff3","#f368e0","#ffa07a","#ffd56b"]},forest:{light:["#2d6a4f","#40916c","#52b788","#74c69d","#1b4332","#95d5b2","#b7e4c7","#344e41","#588157","#a3b18a"],dark:["#74c69d","#52b788","#95d5b2","#40916c","#b7e4c7","#2d6a4f","#d8f3dc","#588157","#a3b18a","#80ed99"]},corporate:{light:["#2c3e50","#3498db","#16a085","#f39c12","#8e44ad","#e74c3c","#34495e","#27ae60","#2980b9","#d35400"],dark:["#5dade2","#48c9b0","#f5b041","#bb8fce","#ec7063","#58d68d","#85c1e9","#76d7c4","#f8c471","#aed6f1"]},vivid:{light:["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff","#06d6a0","#ef476f","#118ab2","#ff70a6","#9b5de5"],dark:["#ff5d8f","#ff7b00","#ffd60a","#9d4edd","#4cc9f0","#06d6a0","#ff70a6","#48cae4","#fb5607","#b5179e"]},monochrome:{light:["#1f2933","#3e4c59","#52606d","#7b8794","#9aa5b1","#616e7c","#cbd2d9","#323f4b","#46545f","#a7b0b8"],dark:["#e4e7eb","#cbd2d9","#9aa5b1","#7b8794","#616e7c","#b8c0c9","#52606d","#d3d9de","#8a949e","#3e4c59"]},nordic:{light:["#5e81ac","#81a1c1","#88c0d0","#8fbcbb","#bf616a","#d08770","#ebcb8b","#a3be8c","#b48ead","#4c566a"],dark:["#88c0d0","#81a1c1","#8fbcbb","#a3be8c","#ebcb8b","#d08770","#bf616a","#b48ead","#5e81ac","#d8dee9"]},pastel:{light:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"],dark:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"]}},Bl={tupi:{light:"#ecdfc4",dark:"#1c1814"},ocean:{light:"#ffffff",dark:"#0b1622"},sunset:{light:"#ffffff",dark:"#1f1410"},forest:{light:"#ffffff",dark:"#0f1f17"},corporate:{light:"#ffffff",dark:"#1a1f26"},vivid:{light:"#ffffff",dark:"#14101c"},monochrome:{light:"#ffffff",dark:"#1a1f24"},nordic:{light:"#eceff4",dark:"#2e3440"},pastel:{light:"#ffffff",dark:"#232026"}},uo=(()=>{const n={};for(const t of Object.keys(js))n[t]=zl(js[t].light,Bl[t].light,dg),n[`${t}-dark`]=zl(js[t].dark,Bl[t].dark,pg);return n.light=n.monochrome,n.dark=n["monochrome-dark"],n})(),gg=Object.keys(uo);function Ol(n){return uo[n]}const kt="12px",Le="#000000",Nl="#1a1a1a",mg="#ffffff",yg=3;function qs(n){const t=n/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Wl(n,t,e){return .2126*qs(n)+.7152*qs(t)+.0722*qs(e)}function Hl(n,t){return(Math.max(n,t)+.05)/(Math.min(n,t)+.05)}const xg=Wl(26,26,26);function gn(n,t){var s;if(t)return t;const e=n?(s=ce(n))==null?void 0:s.rgb():null;if(!e||isNaN(e.r)||e.opacity===0)return Le;const i=Wl(e.r,e.g,e.b),r=Hl(i,xg);return r>=yg?Nl:Hl(i,1)>=r?mg:Nl}function Vl(){if(typeof document>"u")return 16;const n=parseFloat(getComputedStyle(document.documentElement).fontSize);return n>0?n:16}function me(n){if(!n)return 12;const t=n.trim();if(/^(clamp|min|max)\s*\(/i.test(t)){const r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).match(/-?\d*\.?\d+\s*(px|rem|em)/gi)||[];let o=0;for(const s of r){const a=me(s.trim());a>o&&(o=a)}return o>0?o:12}if(t.endsWith("px"))return parseFloat(t)||12;if(t.endsWith("rem")||t.endsWith("em"))return(parseFloat(t)||1)*Vl();const e=parseFloat(t);return isNaN(e)?12:e}let fo=null;function bg(){return fo||(typeof document>"u"?null:(fo=document.createElement("canvas").getContext("2d"),fo))}function He(n,t,e="normal",i="sans-serif"){const r=bg();return r?(r.font=`${e} ${t}px ${i}`,r.measureText(n).width):n.length*t*.62}const Zs={chart:{type:"line",backgroundColor:"#ffffff",borderWidth:0,borderRadius:0,borderColor:"#335cad",spacing:[10,10,15,10],style:{fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',fontSize:"12px"},animation:!0,zoomType:void 0,panning:!1,inverted:!1,polar:!1,reflow:!0},title:{text:void 0,align:"center",margin:15,style:{color:"#333333",fontSize:"18px",fontWeight:"bold"},widthAdjust:-44},subtitle:{text:void 0,align:"center",style:{color:"#666666",fontSize:"12px"},widthAdjust:-44},xAxis:{type:"linear",title:{text:null,style:{fontSize:kt}},labels:{enabled:!0,style:{fontSize:kt},autoRotation:[-45],autoRotationLimit:80,padding:5},tickLength:10,tickWidth:1,tickColor:"#999999",gridLineWidth:1,gridLineColor:"#e6e6e6",lineWidth:1,lineColor:"#999999",offset:0,opposite:!1,reversed:!1,visible:!0,startOnTick:!1,endOnTick:!1,showFirstLabel:!0,showLastLabel:!0,allowDecimals:!0,maxPadding:.01,minPadding:.01,crosshair:!1},yAxis:{type:"linear",title:{text:null,style:{fontSize:kt}},labels:{enabled:!0,style:{fontSize:kt},padding:5},tickLength:10,tickWidth:1,gridLineWidth:1,gridLineColor:"#e6e6e6",lineWidth:1,lineColor:"#999999",offset:0,opposite:!1,reversed:!1,visible:!0,startOnTick:!0,endOnTick:!0,showFirstLabel:!0,showLastLabel:!0,allowDecimals:!0,maxPadding:.05,minPadding:.05,crosshair:!1},colorAxis:void 0,series:[],tooltip:{enabled:!0,shared:!1,split:!1,useHTML:!1,followPointer:!1,headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.y}</b><br/>',footerFormat:"",backgroundColor:"rgba(247,247,247,0.85)",borderColor:void 0,borderWidth:1,borderRadius:3,padding:8,shadow:!0,animation:!0,hideDelay:500,snap:10,outside:!1,style:{color:"#333333",fontSize:"12px"}},legend:{enabled:!0,layout:"horizontal",align:"center",verticalAlign:"bottom",floating:!1,x:0,y:0,margin:15,padding:8,itemMarginTop:0,itemMarginBottom:0,itemDistance:20,itemStyle:{cursor:"pointer",fontSize:kt,fontWeight:"normal"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#cccccc"},symbolWidth:12,symbolHeight:12,symbolRadius:2,symbolPadding:5,squareSymbol:!0,borderWidth:0,borderRadius:0,borderColor:"#999999",reversed:!1},plotOptions:{series:{lineWidth:2,marker:{enabled:null,radius:4,symbol:"circle",lineWidth:0,states:{hover:{enabled:!0,radius:6,lineWidth:1}}},states:{hover:{enabled:!0,lineWidthPlus:1},inactive:{opacity:.2}},animation:{duration:1e3},enableMouseTracking:!0,stickyTracking:!0,allowPointSelect:!1,turboThreshold:1e3,dataLabels:{enabled:!1},showInLegend:!0,threshold:0,connectNulls:!1,clip:!0},bubble:{lineWidth:1},scatter:{marker:{symbol:null}},pie:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.percentage:.1f}%</b><br/>'},dataLabels:{enabled:!0},showInLegend:!1},item:{marker:{radius:null}},classroom:{marker:{radius:null}},candlestick:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},ohlc:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},heikinashi:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},hollowcandlestick:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},arearange:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'}},donut:{showInLegend:!1},sankey:{dataLabels:{enabled:!0},showInLegend:!1},dependencywheel:{dataLabels:{enabled:!0},showInLegend:!1},networkgraph:{dataLabels:{enabled:!0}},treemap:{dataLabels:{enabled:!0}},gauge:{dataLabels:{enabled:!0}},solidgauge:{dataLabels:{enabled:!0}},timeline:{dataLabels:{enabled:!0}},gantt:{dataLabels:{enabled:!0}},barchartrace:{dataLabels:{enabled:!0}},venn:{dataLabels:{enabled:!0}}},credits:{enabled:!0,text:"Powered by: KatuCharts",href:"https://charts.katudv.com",position:{align:"right",verticalAlign:"bottom",x:-10,y:-5},style:{cursor:"pointer",fontSize:"9px"}},exporting:{enabled:!0,filename:"chart",type:"image/png",scale:2,printMaxWidth:780,buttons:{contextButton:{enabled:!0,symbol:"gear",symbolFill:"#666666",symbolStroke:"#666666",symbolStrokeWidth:3,x:-10,y:10,menuItems:["downloadPNG","downloadJPEG","downloadSVG","downloadPDF","separator","viewFullScreen","printChart"]}}},loading:{hideDuration:100,showDuration:100,labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},navigator:{enabled:!1},rangeSelector:{enabled:!1},drilldown:{animation:!0,series:[]},responsive:{rules:[{condition:{maxWidth:500},chartOptions:{chart:{spacing:[5,5,10,5]},title:{style:{fontSize:"14px"},margin:8},subtitle:{style:{fontSize:"10px"}},legend:{itemStyle:{fontSize:"10px"},itemDistance:10,margin:8,symbolWidth:12,symbolHeight:8},yAxis:{title:{text:null},labels:{style:{fontSize:"9px"}}},xAxis:{labels:{style:{fontSize:"9px"},autoRotation:[-45,-90]}},plotOptions:{pie:{size:"65%",dataLabels:{distance:10,style:{fontSize:"9px"},connectorPadding:3}}}}},{condition:{maxWidth:260},chartOptions:{subtitle:{text:null},legend:{enabled:!1},credits:{enabled:!1},plotOptions:{pie:{size:"55%",dataLabels:{distance:5,style:{fontSize:"8px"},connectorWidth:0}}}}}]},accessibility:{enabled:!0},colors:fg},Ti=new Set(["pie","donut","sunburst","treemap","treegraph","wordcloud","sankey","dependencywheel","networkgraph","gauge","solidgauge","polar","radar","funnel","pyramid","timeline","map","mappoint","flowmap","barchartrace","venn","clusteredheatmap","phylotree","circos","circosHeatmap","circosComparative","circosSpiral","item","classroom"]),vg=new Set(["pie","donut","funnel","pyramid","sankey","dependencywheel","networkgraph","treemap","sunburst","gauge","solidgauge","timeline","gantt","map","mappoint","flowmap","heatmap","polar","radar","barchartrace","venn","clusteredheatmap","phylotree","circos","item","classroom"]),wg=new Set(["line","spline","column","bar","scatter","bubble","area","areaspline","boxplot","waterfall","volume"]),kg=new Set(["pie","venn","forestplot","pcoa","item","classroom"]),Mg=new Set(["column","bar","area","areaspline","waterfall"]);function Ks(n){return n.length>0&&n.every(t=>Ti.has(t._internalType))}const Gl=20;function Yl(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function fe(n,...t){return Xl(n,t,0)}function Xl(n,t,e){if(e>Gl)return n;const i={...n};for(const r of t)if(r)for(const o of Object.keys(r)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;const s=r[o],a=i[o];s!==void 0&&(s===null?i[o]=null:Yl(s)&&Yl(a)?i[o]=Xl(a,[s],e+1):Array.isArray(s)?i[o]=[...s]:i[o]=s)}return i}function po(n){return Js(n,new WeakSet,0)}function Js(n,t,e){if(n===null||typeof n!="object"||e>Gl||t.has(n))return n;if(t.add(n),Array.isArray(n))return n.map(r=>Js(r,t,e+1));if(n instanceof Date)return new Date(n.getTime());const i={};for(const r of Object.keys(n))i[r]=Js(n[r],t,e+1);return i}function Ul(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in n&&n.BYTES_PER_ELEMENT===1}function Qs(n,t=""){if(typeof n!="number"){const e=t&&`"${t}" `;throw new TypeError(`${e}expected number, got ${typeof n}`)}if(!Number.isSafeInteger(n)||n<0){const e=t&&`"${t}" `;throw new RangeError(`${e}expected integer >= 0, got ${n}`)}}function li(n,t,e=""){const i=Ul(n),r=n==null?void 0:n.length,o=t!==void 0;if(!i||o&&r!==t){const s=e&&`"${e}" `,a=o?` of length ${t}`:"",c=i?`length=${r}`:`type=${typeof n}`,l=s+"expected Uint8Array"+a+", got "+c;throw i?new RangeError(l):new TypeError(l)}return n}function jl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Ag(n,t){li(n,void 0,"digestInto() output");const e=t.outputLen;if(n.length<e)throw new RangeError('"digestInto() output" expected to be of length >='+e)}function ta(...n){for(let t=0;t<n.length;t++)n[t].fill(0)}function ea(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}const ql=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Sg=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function na(n){if(li(n),ql)return n.toHex();let t="";for(let e=0;e<n.length;e++)t+=Sg[n[e]];return t}const Ln={_0:48,_9:57,A:65,F:70,a:97,f:102};function Zl(n){if(n>=Ln._0&&n<=Ln._9)return n-Ln._0;if(n>=Ln.A&&n<=Ln.F)return n-(Ln.A-10);if(n>=Ln.a&&n<=Ln.f)return n-(Ln.a-10)}function ia(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);if(ql)try{return Uint8Array.fromHex(n)}catch(r){throw r instanceof SyntaxError?new RangeError(r.message):r}const t=n.length,e=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(e);for(let r=0,o=0;r<e;r++,o+=2){const s=Zl(n.charCodeAt(o)),a=Zl(n.charCodeAt(o+1));if(s===void 0||a===void 0){const c=n[o]+n[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[r]=s*16+a}return i}function _g(...n){let t=0;for(let i=0;i<n.length;i++){const r=n[i];li(r),t+=r.length}const e=new Uint8Array(t);for(let i=0,r=0;i<n.length;i++){const o=n[i];e.set(o,r),r+=o.length}return e}function Cg(n,t={}){const e=(r,o)=>n(o).update(r).digest(),i=n(void 0);return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.canXOF=i.canXOF,e.create=r=>n(r),Object.assign(e,t),Object.freeze(e)}function Pg(n=32){Qs(n,"bytesLength");const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(t==null?void 0:t.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");if(n>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${n}`);return t.getRandomValues(new Uint8Array(n))}const Eg=n=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,n])});class Tg{constructor(t,e,i,r){vt(this,"blockLen");vt(this,"outputLen");vt(this,"canXOF",!1);vt(this,"padOffset");vt(this,"isLE");vt(this,"buffer");vt(this,"view");vt(this,"finished",!1);vt(this,"length",0);vt(this,"pos",0);vt(this,"destroyed",!1);this.blockLen=t,this.outputLen=e,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(t),this.view=ea(this.buffer)}update(t){jl(this),li(t);const{view:e,buffer:i,blockLen:r}=this,o=t.length;for(let s=0;s<o;){const a=Math.min(r-this.pos,o-s);if(a===r){const c=ea(t);for(;r<=o-s;s+=r)this.process(c,s);continue}i.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){jl(this),Ag(t,this),this.finished=!0;const{buffer:e,view:i,blockLen:r,isLE:o}=this;let{pos:s}=this;e[s++]=128,ta(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(i,0),s=0);for(let f=s;f<r;f++)e[f]=0;i.setBigUint64(r-8,BigInt(this.length*8),o),this.process(i,0);const a=ea(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,h[f],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const i=t.slice(0,e);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:i,length:r,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=r,t.pos=a,r%e&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const ve=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),go=BigInt(2**32-1),Kl=BigInt(32);function Lg(n,t=!1){return t?{h:Number(n&go),l:Number(n>>Kl&go)}:{h:Number(n>>Kl&go)|0,l:Number(n&go)|0}}function $g(n,t=!1){const e=n.length;let i=new Uint32Array(e),r=new Uint32Array(e);for(let o=0;o<e;o++){const{h:s,l:a}=Lg(n[o],t);[i[o],r[o]]=[s,a]}return[i,r]}const Jl=(n,t,e)=>n>>>e,Ql=(n,t,e)=>n<<32-e|t>>>e,Li=(n,t,e)=>n>>>e|t<<32-e,$i=(n,t,e)=>n<<32-e|t>>>e,mo=(n,t,e)=>n<<64-e|t>>>e-32,yo=(n,t,e)=>n>>>e-32|t<<64-e;function $n(n,t,e,i){const r=(t>>>0)+(i>>>0);return{h:n+e+(r/2**32|0)|0,l:r|0}}const Ig=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),Fg=(n,t,e,i)=>t+e+i+(n/2**32|0)|0,Rg=(n,t,e,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(i>>>0),Dg=(n,t,e,i,r)=>t+e+i+r+(n/2**32|0)|0,zg=(n,t,e,i,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(i>>>0)+(r>>>0),Bg=(n,t,e,i,r,o)=>t+e+i+r+o+(n/2**32|0)|0,th=$g(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Og=th[0],Ng=th[1],jn=new Uint32Array(80),qn=new Uint32Array(80);class Wg extends Tg{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:e,Bh:i,Bl:r,Ch:o,Cl:s,Dh:a,Dl:c,Eh:l,El:h,Fh:f,Fl:u,Gh:d,Gl:p,Hh:y,Hl:g}=this;return[t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g]}set(t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g){this.Ah=t|0,this.Al=e|0,this.Bh=i|0,this.Bl=r|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=f|0,this.Fl=u|0,this.Gh=d|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(t,e){for(let v=0;v<16;v++,e+=4)jn[v]=t.getUint32(e),qn[v]=t.getUint32(e+=4);for(let v=16;v<80;v++){const b=jn[v-15]|0,k=qn[v-15]|0,M=Li(b,k,1)^Li(b,k,8)^Jl(b,k,7),C=$i(b,k,1)^$i(b,k,8)^Ql(b,k,7),E=jn[v-2]|0,_=qn[v-2]|0,T=Li(E,_,19)^mo(E,_,61)^Jl(E,_,6),I=$i(E,_,19)^yo(E,_,61)^Ql(E,_,6),L=Rg(C,I,qn[v-7],qn[v-16]),P=Dg(L,M,T,jn[v-7],jn[v-16]);jn[v]=P|0,qn[v]=L|0}let{Ah:i,Al:r,Bh:o,Bl:s,Ch:a,Cl:c,Dh:l,Dl:h,Eh:f,El:u,Fh:d,Fl:p,Gh:y,Gl:g,Hh:m,Hl:x}=this;for(let v=0;v<80;v++){const b=Li(f,u,14)^Li(f,u,18)^mo(f,u,41),k=$i(f,u,14)^$i(f,u,18)^yo(f,u,41),M=f&d^~f&y,C=u&p^~u&g,E=zg(x,k,C,Ng[v],qn[v]),_=Bg(E,m,b,M,Og[v],jn[v]),T=E|0,I=Li(i,r,28)^mo(i,r,34)^mo(i,r,39),L=$i(i,r,28)^yo(i,r,34)^yo(i,r,39),P=i&o^i&a^o&a,A=r&s^r&c^s&c;m=y|0,x=g|0,y=d|0,g=p|0,d=f|0,p=u|0,{h:f,l:u}=$n(l|0,h|0,_|0,T|0),l=a|0,h=c|0,a=o|0,c=s|0,o=i|0,s=r|0;const w=Ig(T,L,A);i=Fg(w,_,I,P),r=w|0}({h:i,l:r}=$n(this.Ah|0,this.Al|0,i|0,r|0)),{h:o,l:s}=$n(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=$n(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=$n(this.Dh|0,this.Dl|0,l|0,h|0),{h:f,l:u}=$n(this.Eh|0,this.El|0,f|0,u|0),{h:d,l:p}=$n(this.Fh|0,this.Fl|0,d|0,p|0),{h:y,l:g}=$n(this.Gh|0,this.Gl|0,y|0,g|0),{h:m,l:x}=$n(this.Hh|0,this.Hl|0,m|0,x|0),this.set(i,r,o,s,a,c,l,h,f,u,d,p,y,g,m,x)}roundClean(){ta(jn,qn)}destroy(){this.destroyed=!0,ta(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Hg extends Wg{constructor(){super(64);vt(this,"Ah",ve[0]|0);vt(this,"Al",ve[1]|0);vt(this,"Bh",ve[2]|0);vt(this,"Bl",ve[3]|0);vt(this,"Ch",ve[4]|0);vt(this,"Cl",ve[5]|0);vt(this,"Dh",ve[6]|0);vt(this,"Dl",ve[7]|0);vt(this,"Eh",ve[8]|0);vt(this,"El",ve[9]|0);vt(this,"Fh",ve[10]|0);vt(this,"Fl",ve[11]|0);vt(this,"Gh",ve[12]|0);vt(this,"Gl",ve[13]|0);vt(this,"Hh",ve[14]|0);vt(this,"Hl",ve[15]|0)}}const Vg=Cg(()=>new Hg,Eg(3));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $e=(n,t,e)=>li(n,t,e),eh=Qs,nh=na,ih=(...n)=>_g(...n),Gg=n=>ia(n),Yg=Ul,Xg=n=>Pg(n),xo=BigInt(0),ra=BigInt(1);function bo(n,t=""){if(typeof n!="boolean"){const e=t&&`"${t}" `;throw new TypeError(e+"expected boolean, got type="+typeof n)}return n}function Ug(n){if(typeof n=="bigint"){if(!vo(n))throw new RangeError("positive bigint expected, got "+n)}else eh(n);return n}function oa(n,t=""){if(typeof n!="number"){const e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof n)}if(!Number.isSafeInteger(n)){const e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+n)}}function rh(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);return n===""?xo:BigInt("0x"+n)}function jg(n){return rh(na(n))}function lr(n){return rh(na(sa(li(n)).reverse()))}function oh(n,t){if(Qs(t),t===0)throw new RangeError("zero length");n=Ug(n);const e=n.toString(16);if(e.length>t*2)throw new RangeError("number too large");return ia(e.padStart(t*2,"0"))}function qg(n,t){return oh(n,t).reverse()}function Zg(n,t){if(n=$e(n),t=$e(t),n.length!==t.length)return!1;let e=0;for(let i=0;i<n.length;i++)e|=n[i]^t[i];return e===0}function sa(n){return Uint8Array.from($e(n))}const vo=n=>typeof n=="bigint"&&xo<=n;function Kg(n,t,e){return vo(n)&&vo(t)&&vo(e)&&t<=n&&n<e}function sh(n,t,e,i){if(!Kg(t,e,i))throw new RangeError("expected valid "+n+": "+e+" <= n < "+i+", got "+t)}function Jg(n){if(n<xo)throw new Error("expected non-negative bigint, got "+n);let t;for(t=0;n>xo;n>>=ra,t+=1);return t}const Qg=n=>(ra<<BigInt(n))-ra;function aa(n,t={},e={}){if(Object.prototype.toString.call(n)!=="[object Object]")throw new TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(n,o))throw new TypeError(`param "${o}" is invalid: expected own property`);const c=n[o];if(a&&c===void 0)return;const l=typeof c;if(l!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}const r=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));r(t,!1),r(e,!0)}const ah=()=>{throw new Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const we=BigInt(0),ye=BigInt(1),hi=BigInt(2),ch=BigInt(3),lh=BigInt(4),hh=BigInt(5),t0=BigInt(7),uh=BigInt(8),e0=BigInt(9),fh=BigInt(16);function le(n,t){if(t<=we)throw new Error("mod: expected positive modulus, got "+t);const e=n%t;return e>=we?e:t+e}function Mn(n,t,e){if(t<we)throw new Error("pow2: expected non-negative exponent, got "+t);let i=n;for(;t-- >we;)i*=i,i%=e;return i}function dh(n,t){if(n===we)throw new Error("invert: expected non-zero number");if(t<=we)throw new Error("invert: expected positive modulus, got "+t);let e=le(n,t),i=t,r=we,o=ye;for(;e!==we;){const a=i/e,c=i-e*a,l=r-o*a;i=e,e=c,r=o,o=l}if(i!==ye)throw new Error("invert: does not exist");return le(r,t)}function ca(n,t,e){const i=n;if(!i.eql(i.sqr(t),e))throw new Error("Cannot find square root")}function ph(n,t){const e=n,i=(e.ORDER+ye)/lh,r=e.pow(t,i);return ca(e,r,t),r}function n0(n,t){const e=n,i=(e.ORDER-hh)/uh,r=e.mul(t,hi),o=e.pow(r,i),s=e.mul(t,o),a=e.mul(e.mul(s,hi),o),c=e.mul(s,e.sub(a,e.ONE));return ca(e,c,t),c}function i0(n){const t=la(n),e=gh(n),i=e(t,t.neg(t.ONE)),r=e(t,i),o=e(t,t.neg(i)),s=(n+t0)/fh;return(a,c)=>{const l=a;let h=l.pow(c,s),f=l.mul(h,i);const u=l.mul(h,r),d=l.mul(h,o),p=l.eql(l.sqr(f),c),y=l.eql(l.sqr(u),c);h=l.cmov(h,f,p),f=l.cmov(d,u,y);const g=l.eql(l.sqr(f),c),m=l.cmov(h,f,g);return ca(l,m,c),m}}function gh(n){if(n<ch)throw new Error("sqrt is not defined for small field");let t=n-ye,e=0;for(;t%hi===we;)t/=hi,e++;let i=hi;const r=la(n);for(;yh(r,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return ph;let o=r.pow(i,t);const s=(t+ye)/hi;return function(c,l){const h=c;if(h.is0(l))return l;if(yh(h,l)!==1)throw new Error("Cannot find square root");let f=e,u=h.mul(h.ONE,o),d=h.pow(l,t),p=h.pow(l,s);for(;!h.eql(d,h.ONE);){if(h.is0(d))return h.ZERO;let y=1,g=h.sqr(d);for(;!h.eql(g,h.ONE);)if(y++,g=h.sqr(g),y===f)throw new Error("Cannot find square root");const m=ye<<BigInt(f-y-1),x=h.pow(u,m);f=y,u=h.sqr(x),d=h.mul(d,u),p=h.mul(p,x)}return p}}function r0(n){return n%lh===ch?ph:n%uh===hh?n0:n%fh===e0?i0(n):gh(n)}const ui=(n,t)=>(le(n,t)&ye)===ye,o0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function s0(n){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},e=o0.reduce((i,r)=>(i[r]="function",i),t);if(aa(n,e),oa(n.BYTES,"BYTES"),oa(n.BITS,"BITS"),n.BYTES<1||n.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(n.ORDER<=ye)throw new Error("invalid field: expected ORDER > 1, got "+n.ORDER);return n}function a0(n,t,e){const i=n;if(e<we)throw new Error("invalid exponent, negatives unsupported");if(e===we)return i.ONE;if(e===ye)return t;let r=i.ONE,o=t;for(;e>we;)e&ye&&(r=i.mul(r,o)),o=i.sqr(o),e>>=ye;return r}function mh(n,t,e=!1){const i=n,r=new Array(t.length).fill(e?i.ZERO:void 0),o=t.reduce((a,c,l)=>i.is0(c)?a:(r[l]=a,i.mul(a,c)),i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>i.is0(c)?a:(r[l]=i.mul(a,r[l]),i.mul(a,c)),s),r}function yh(n,t){const e=n,i=(e.ORDER-ye)/hi,r=e.pow(t,i),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function c0(n,t){if(t!==void 0&&eh(t),n<=we)throw new Error("invalid n length: expected positive n, got "+n);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);const e=Jg(n);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${t})`);const i=t!==void 0?t:e,r=Math.ceil(i/8);return{nBitLength:i,nByteLength:r}}const xh=new WeakMap;class bh{constructor(t,e={}){vt(this,"ORDER");vt(this,"BITS");vt(this,"BYTES");vt(this,"isLE");vt(this,"ZERO",we);vt(this,"ONE",ye);vt(this,"_lengths");vt(this,"_mod");if(t<=ye)throw new Error("invalid field: expected ORDER > 1, got "+t);let i;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(i=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));const{nBitLength:r,nByteLength:o}=c0(t,i);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=o,Object.freeze(this)}create(t){return le(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return we<=t&&t<this.ORDER}is0(t){return t===we}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&ye)===ye}neg(t){return le(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return le(t*t,this.ORDER)}add(t,e){return le(t+e,this.ORDER)}sub(t,e){return le(t-e,this.ORDER)}mul(t,e){return le(t*e,this.ORDER)}pow(t,e){return a0(this,t,e)}div(t,e){return le(t*dh(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return dh(t,this.ORDER)}sqrt(t){let e=xh.get(this);return e||xh.set(this,e=r0(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?qg(t,this.BYTES):oh(t,this.BYTES)}fromBytes(t,e=!1){$e(t);const{_lengths:i,BYTES:r,isLE:o,ORDER:s,_mod:a}=this;if(i){if(t.length<1||!i.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);const l=new Uint8Array(r);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let c=o?lr(t):jg(t);if(a&&(c=le(c,s)),!e&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return mh(this,t)}cmov(t,e,i){return bo(i,"condition"),i?e:t}}Object.freeze(bh.prototype);function la(n,t={}){return new bh(n,t)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const wo=BigInt(0),ha=BigInt(1);function vh(n,t){const e=t.negate();return n?e:t}function ua(n,t){const e=mh(n.Fp,t.map(i=>i.Z));return t.map((i,r)=>n.fromAffine(i.toAffine(e[r])))}function wh(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function fa(n,t){wh(n,t);const e=Math.ceil(t/n)+1,i=2**(n-1),r=2**n,o=Qg(n),s=BigInt(n);return{windows:e,windowSize:i,mask:o,maxNumber:r,shiftBy:s}}function kh(n,t,e){const{windowSize:i,mask:r,maxNumber:o,shiftBy:s}=e;let a=Number(n&r),c=n>>s;a>i&&(a-=o,c+=ha);const l=t*i,h=l+Math.abs(a)-1,f=a===0,u=a<0,d=t%2!==0;return{nextN:c,offset:h,isZero:f,isNeg:u,isNegF:d,offsetF:l}}const da=new WeakMap,Mh=new WeakMap;function pa(n){return Mh.get(n)||1}function Ah(n){if(n!==wo)throw new Error("invalid wNAF")}class l0{constructor(t,e){vt(this,"BASE");vt(this,"ZERO");vt(this,"Fn");vt(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,i=this.ZERO){let r=t;for(;e>wo;)e&ha&&(i=i.add(r)),r=r.double(),e>>=ha;return i}precomputeWindow(t,e){const{windows:i,windowSize:r}=fa(e,this.bits),o=[];let s=t,a=s;for(let c=0;c<i;c++){a=s,o.push(a);for(let l=1;l<r;l++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,e,i){if(!this.Fn.isValid(i))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=fa(t,this.bits);for(let a=0;a<s.windows;a++){const{nextN:c,offset:l,isZero:h,isNeg:f,isNegF:u,offsetF:d}=kh(i,a,s);i=c,h?o=o.add(vh(u,e[d])):r=r.add(vh(f,e[l]))}return Ah(i),{p:r,f:o}}wNAFUnsafe(t,e,i,r=this.ZERO){const o=fa(t,this.bits);for(let s=0;s<o.windows&&i!==wo;s++){const{nextN:a,offset:c,isZero:l,isNeg:h}=kh(i,s,o);if(i=a,!l){const f=e[c];r=r.add(h?f.negate():f)}}return Ah(i),r}getPrecomputes(t,e,i){let r=da.get(e);return r||(r=this.precomputeWindow(e,t),t!==1&&(typeof i=="function"&&(r=i(r)),da.set(e,r))),r}cached(t,e,i){const r=pa(t);return this.wNAF(r,this.getPrecomputes(r,t,i),e)}unsafe(t,e,i,r){const o=pa(t);return o===1?this._unsafeLadder(t,e,r):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),e,r)}createCache(t,e){wh(e,this.bits),Mh.set(t,e),da.delete(t)}hasCache(t){return pa(t)!==1}}function Sh(n,t,e){if(t){if(t.ORDER!==n)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return s0(t),t}else return la(n,{isLE:e})}function h0(n,t,e={},i){if(i===void 0&&(i=n==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${n} CURVE object`);for(const c of["p","n","h"]){const l=t[c];if(!(typeof l=="bigint"&&l>wo))throw new Error(`CURVE.${c} must be positive bigint`)}const r=Sh(t.p,e.Fp,i),o=Sh(t.n,e.Fn,i),a=["Gx","Gy","a","d"];for(const c of a)if(!r.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:r,Fn:o}}function u0(n,t){return function(i){const r=n(i);return{secretKey:r,publicKey:t(r)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Zn=BigInt(0),de=BigInt(1),ga=BigInt(2),f0=BigInt(8);function d0(n,t,e,i){const r=n.sqr(e),o=n.sqr(i),s=n.add(n.mul(t.a,r),o),a=n.add(n.ONE,n.mul(t.d,n.mul(r,o)));return n.eql(s,a)}function p0(n,t={}){const e=t,i=h0("edwards",n,e,e.FpFnLE),{Fp:r,Fn:o}=i;let s=i.CURVE;const{h:a}=s;aa(e,{},{uvRatio:"function"});const c=ga<<BigInt(o.BYTES*8)-de,l=g=>r.create(g),h=e.uvRatio===void 0?(g,m)=>{try{return{isValid:!0,value:r.sqrt(r.div(g,m))}}catch{return{isValid:!1,value:Zn}}}:e.uvRatio;if(!d0(r,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function f(g,m,x=!1){const v=x?de:Zn;return sh("coordinate "+g,m,v,c),m}function u(g){if(!(g instanceof d))throw new Error("EdwardsPoint expected")}const y=class y{constructor(m,x,v,b){vt(this,"X");vt(this,"Y");vt(this,"Z");vt(this,"T");this.X=f("x",m),this.Y=f("y",x),this.Z=f("z",v,!0),this.T=f("t",b),Object.freeze(this)}static CURVE(){return s}static fromAffine(m){if(m instanceof y)throw new Error("extended point not allowed");const{x,y:v}=m||{};return f("x",x),f("y",v),new y(x,v,de,l(x*v))}static fromBytes(m,x=!1){const v=r.BYTES,{a:b,d:k}=s;m=sa($e(m,v,"point")),bo(x,"zip215");const M=sa(m),C=m[v-1];M[v-1]=C&-129;const E=lr(M),_=x?c:r.ORDER;sh("point.y",E,Zn,_);const T=l(E*E),I=l(T-de),L=l(k*T-b);let{isValid:P,value:A}=h(I,L);if(!P)throw new Error("bad point: invalid y coordinate");const w=(A&de)===de,S=(C&128)!==0;if(!x&&A===Zn&&S)throw new Error("bad point: x=0 and x_0=1");return S!==w&&(A=l(-A)),y.fromAffine({x:A,y:E})}static fromHex(m,x=!1){return y.fromBytes(Gg(m),x)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,x=!0){return p.createCache(this,m),x||this.multiply(ga),this}assertValidity(){const m=this,{a:x,d:v}=s;if(m.is0())throw new Error("bad point: ZERO");const{X:b,Y:k,Z:M,T:C}=m,E=l(b*b),_=l(k*k),T=l(M*M),I=l(T*T),L=l(E*x),P=l(T*l(L+_)),A=l(I+l(v*l(E*_)));if(P!==A)throw new Error("bad point: equation left != right (1)");const w=l(b*k),S=l(M*C);if(w!==S)throw new Error("bad point: equation left != right (2)")}equals(m){u(m);const{X:x,Y:v,Z:b}=this,{X:k,Y:M,Z:C}=m,E=l(x*C),_=l(k*b),T=l(v*C),I=l(M*b);return E===_&&T===I}is0(){return this.equals(y.ZERO)}negate(){return new y(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:m}=s,{X:x,Y:v,Z:b}=this,k=l(x*x),M=l(v*v),C=l(ga*l(b*b)),E=l(m*k),_=x+v,T=l(l(_*_)-k-M),I=E+M,L=I-C,P=E-M,A=l(T*L),w=l(I*P),S=l(T*P),$=l(L*I);return new y(A,w,$,S)}add(m){u(m);const{a:x,d:v}=s,{X:b,Y:k,Z:M,T:C}=this,{X:E,Y:_,Z:T,T:I}=m,L=l(b*E),P=l(k*_),A=l(C*v*I),w=l(M*T),S=l((b+k)*(E+_)-L-P),$=w-A,R=w+A,F=l(P-x*L),D=l(S*$),z=l(R*F),B=l(S*F),W=l($*R);return new y(D,z,W,B)}subtract(m){return u(m),this.add(m.negate())}multiply(m){if(!o.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");const{p:x,f:v}=p.cached(this,m,b=>ua(y,b));return ua(y,[x,v])[0]}multiplyUnsafe(m){if(!o.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===Zn?y.ZERO:this.is0()||m===de?this:p.unsafe(this,m,x=>ua(y,x))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return p.unsafe(this,s.n).is0()}toAffine(m){const x=this;let v=m;const{X:b,Y:k,Z:M}=x,C=x.is0();v==null&&(v=C?f0:r.inv(M));const E=l(b*v),_=l(k*v),T=r.mul(M,v);if(C)return{x:Zn,y:de};if(T!==de)throw new Error("invZ was invalid");return{x:E,y:_}}clearCofactor(){return a===de?this:this.multiplyUnsafe(a)}toBytes(){const{x:m,y:x}=this.toAffine(),v=r.toBytes(x);return v[v.length-1]|=m&de?128:0,v}toHex(){return nh(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};vt(y,"BASE",new y(s.Gx,s.Gy,de,l(s.Gx*s.Gy))),vt(y,"ZERO",new y(Zn,de,de,Zn)),vt(y,"Fp",r),vt(y,"Fn",o);let d=y;const p=new l0(d,o.BITS);return o.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}class hr{constructor(t){vt(this,"ep");this.ep=t}static fromBytes(t){ah()}static fromHex(t){ah()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return nh(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.ep.precompute(t,e),this}}vt(hr,"BASE"),vt(hr,"ZERO"),vt(hr,"Fp"),vt(hr,"Fn");function g0(n,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');const i=t,r=e;aa(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});const{prehash:o}=r,{BASE:s,Fp:a,Fn:c}=n,l=i.outputLen,h=2*a.BYTES;if(l!==void 0&&(oa(l,"hash.outputLen"),l!==h))throw new Error(`hash.outputLen must be ${h}, got ${l}`);const f=r.randomBytes===void 0?Xg:r.randomBytes,u=r.adjustScalarBytes===void 0?L=>L:r.adjustScalarBytes,d=r.domain===void 0?(L,P,A)=>{if(bo(A,"phflag"),P.length||A)throw new Error("Contexts/pre-hash are not supported");return L}:r.domain;function p(L){return c.create(lr(L))}function y(L){const P=C.secretKey;$e(L,C.secretKey,"secretKey");const A=$e(i(L),2*P,"hashedSecretKey"),w=u(A.slice(0,P)),S=A.slice(P,2*P),$=p(w);return{head:w,prefix:S,scalar:$}}function g(L){const{head:P,prefix:A,scalar:w}=y(L),S=s.multiply(w),$=S.toBytes();return{head:P,prefix:A,scalar:w,point:S,pointBytes:$}}function m(L){return g(L).pointBytes}function x(L=Uint8Array.of(),...P){const A=ih(...P);return p(i(d(A,$e(L,void 0,"context"),!!o)))}function v(L,P,A={}){L=$e(L,void 0,"message"),o&&(L=o(L));const{prefix:w,scalar:S,pointBytes:$}=g(P),R=x(A.context,w,L),F=s.multiply(R).toBytes(),D=x(A.context,F,$,L),z=c.create(R+D*S);if(!c.isValid(z))throw new Error("sign failed: invalid s");const B=ih(F,c.toBytes(z));return $e(B,C.signature,"result")}const b={zip215:r.zip215};function k(L,P,A,w=b){const{context:S}=w,$=w.zip215===void 0?!!b.zip215:w.zip215,R=C.signature;L=$e(L,R,"signature"),P=$e(P,void 0,"message"),A=$e(A,C.publicKey,"publicKey"),$!==void 0&&bo($,"zip215"),o&&(P=o(P));const F=R/2,D=L.subarray(0,F),z=lr(L.subarray(F,R));let B,W,K;try{B=n.fromBytes(A,$),W=n.fromBytes(D,$),K=s.multiplyUnsafe(z)}catch{return!1}if(!$&&B.isSmallOrder())return!1;const X=x(S,D,A,P);return W.add(B.multiplyUnsafe(X)).subtract(K).clearCofactor().is0()}const M=a.BYTES,C={secretKey:M,publicKey:M,signature:2*M,seed:M};function E(L){return L=L===void 0?f(C.seed):L,$e(L,C.seed,"seed")}function _(L){return Yg(L)&&L.length===C.secretKey}function T(L,P){try{return!!n.fromBytes(L,P===void 0?b.zip215:P)}catch{return!1}}const I={getExtendedPublicKey:g,randomSecretKey:E,isValidSecretKey:_,isValidPublicKey:T,toMontgomery(L){const{y:P}=n.fromBytes(L),A=C.publicKey,w=A===32;if(!w&&A!==57)throw new Error("only defined for 25519 and 448");const S=w?a.div(de+P,de-P):a.div(P-de,P+de);return a.toBytes(S)},toMontgomerySecret(L){const P=C.secretKey;$e(L,P);const A=i(L.subarray(0,P));return u(A).subarray(0,P)}};return Object.freeze(C),Object.freeze(I),Object.freeze({keygen:u0(E,m),getPublicKey:m,sign:v,verify:k,utils:I,Point:n,lengths:C})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const m0=BigInt(0),ur=BigInt(1),_h=BigInt(2),y0=BigInt(5),x0=BigInt(8),fr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Ch={p:fr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:x0,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function b0(n){const t=BigInt(10),e=BigInt(20),i=BigInt(40),r=BigInt(80),o=fr,a=n*n%o*n%o,c=Mn(a,_h,o)*a%o,l=Mn(c,ur,o)*n%o,h=Mn(l,y0,o)*l%o,f=Mn(h,t,o)*h%o,u=Mn(f,e,o)*f%o,d=Mn(u,i,o)*u%o,p=Mn(d,r,o)*d%o,y=Mn(p,r,o)*d%o,g=Mn(y,t,o)*h%o;return{pow_p_5_8:Mn(g,_h,o)*n%o,b2:a}}function v0(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}const ma=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Ph(n,t){const e=fr,i=le(t*t*t,e),r=le(i*i*t,e),o=b0(n*r).pow_p_5_8;let s=le(n*i*o,e);const a=le(t*s*s,e),c=s,l=le(s*ma,e),h=a===n,f=a===le(-n,e),u=a===le(-n*ma,e);return h&&(s=c),(f||u)&&(s=l),ui(s,e)&&(s=le(-s,e)),{isValid:h||f,value:s}}const fi=p0(Ch,{uvRatio:Ph}),di=fi.Fp,w0=fi.Fn;function k0(n){return g0(fi,Vg,Object.assign({adjustScalarBytes:v0,zip215:!0},n))}const M0=k0({}),Eh=ma,A0=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Th=n=>Ph(ur,n),S0=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),_0=n=>di.create(lr(n)&S0),Ye=class Ye extends hr{constructor(t){super(t)}static fromAffine(t){return new Ye(fi.fromAffine(t))}assertSame(t){if(!(t instanceof Ye))throw new Error("RistrettoPoint expected")}init(t){return new Ye(t)}static fromBytes(t){li(t,32);const{a:e,d:i}=Ch,r=fr,o=b=>di.create(b),s=_0(t);if(!Zg(di.toBytes(s),t)||ui(s,r))throw new Error("invalid ristretto255 encoding 1");const a=o(s*s),c=o(ur+e*a),l=o(ur-e*a),h=o(c*c),f=o(l*l),u=o(e*i*h-f),{isValid:d,value:p}=Th(o(u*f)),y=o(p*l),g=o(p*y*u);let m=o((s+s)*y);ui(m,r)&&(m=o(-m));const x=o(c*g),v=o(m*x);if(!d||ui(v,r)||x===m0)throw new Error("invalid ristretto255 encoding 2");return new Ye(new fi(m,x,ur,v))}static fromHex(t){return Ye.fromBytes(ia(t))}toBytes(){let{X:t,Y:e,Z:i,T:r}=this.ep;const o=fr,s=g=>di.create(g),a=s(s(i+e)*s(i-e)),c=s(t*e),l=s(c*c),{value:h}=Th(s(a*l)),f=s(h*a),u=s(h*c),d=s(f*u*r);let p;if(ui(r*d,o)){let g=s(e*Eh),m=s(t*Eh);t=g,e=m,p=s(f*A0)}else p=u;ui(t*d,o)&&(e=s(-e));let y=s((i-e)*p);return ui(y,o)&&(y=s(-y)),di.toBytes(y)}equals(t){this.assertSame(t);const{X:e,Y:i}=this.ep,{X:r,Y:o}=t.ep,s=l=>di.create(l),a=s(e*o)===s(i*r),c=s(i*o)===s(e*r);return a||c}is0(){return this.equals(Ye.ZERO)}};vt(Ye,"BASE",new Ye(fi.BASE)),vt(Ye,"ZERO",new Ye(fi.ZERO)),vt(Ye,"Fp",di),vt(Ye,"Fn",w0);let Ii=Ye;Object.freeze(Ii.BASE),Object.freeze(Ii.ZERO),Object.freeze(Ii.prototype),Object.freeze(Ii);const Lh="katucharts_license",C0=7*24*60*60*1e3,P0=60*60*1e3,E0=8e3,c5="3ab57dfcba56a3c6b1949906ef075ff6536f2a40b328a77733e4d8d837cb6abe",T0="https://charts.katudv.com/api/v1/license/verify";class L0{constructor(){this.licenseKey=null,this.payload=null,this.offlineValid=!1,this.verifyUrl=T0,this.mode="lenient",this.gracePeriodMs=C0,this.recheckIntervalMs=P0,this.cache=null,this.pending=!1,this.timer=null,this.listeners=new Set,this.lastEmitted=null}configure(t){t.verifyUrl!==void 0&&(this.verifyUrl=t.verifyUrl||null),t.mode&&(this.mode=t.mode),t.gracePeriodMs!==void 0&&(this.gracePeriodMs=t.gracePeriodMs),t.recheckIntervalMs!==void 0&&(this.recheckIntervalMs=t.recheckIntervalMs),this.offlineValid&&this.verifyUrl&&this.startOnlineChecks(),this.emit()}setKey(t){this.licenseKey=t,this.payload=null,this.offlineValid=!1,this.cache=null;const e=this.validate(t);return e&&(this.payload=e,this.offlineValid=!0,this.cache=this.loadCache(e.kid)),this.offlineValid&&this.verifyUrl&&this.startOnlineChecks(),this.emit(),this.isLicensed()}isLicensed(){var t;return this.offlineValid?this.verifyUrl?((t=this.cache)==null?void 0:t.lastResult)==="invalid"?!1:this.cache&&this.cache.lastValidAt>0&&ya()-this.cache.lastValidAt<this.gracePeriodMs||this.pending?!0:this.mode!=="strict":!0:!1}getPayload(){return this.payload}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}startOnlineChecks(){var t,e;this.verifyOnline(),this.timer==null&&typeof setInterval<"u"&&this.recheckIntervalMs>0&&(this.timer=setInterval(()=>void this.verifyOnline(),this.recheckIntervalMs),(e=(t=this.timer)==null?void 0:t.unref)==null||e.call(t))}async verifyOnline(){if(!this.verifyUrl||!this.licenseKey||!this.payload||typeof fetch>"u")return;this.pending=!0;const t=this.payload.kid??"",e=typeof window<"u"?window.location.hostname:"";let i="unreachable";try{const r=typeof AbortController<"u"?new AbortController:null,o=r?setTimeout(()=>r.abort(),E0):null,s=await fetch(this.verifyUrl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:this.licenseKey,domain:e,kid:t}),signal:r==null?void 0:r.signal});o&&clearTimeout(o),s.ok?i=(await s.json()).valid?"valid":"invalid":s.status>=400&&s.status<500&&(i="invalid")}catch{i="unreachable"}this.pending=!1,this.applyResult(t,i)}applyResult(t,e){const i=this.cache,r={kid:t,lastResult:e,lastValidAt:e==="valid"?ya():(i==null?void 0:i.lastValidAt)??0,updatedAt:ya()};this.cache=r,this.saveCache(r),this.emit()}emit(){const t=this.isLicensed();t!==this.lastEmitted&&(this.lastEmitted=t,this.listeners.forEach(e=>{try{e(t)}catch{}}))}loadCache(t){if(!t||typeof localStorage>"u")return null;try{const e=localStorage.getItem(Lh);if(!e)return null;const i=JSON.parse(e);return i.kid===t?i:null}catch{return null}}saveCache(t){if(!(typeof localStorage>"u"))try{localStorage.setItem(Lh,JSON.stringify(t))}catch{}}validate(t){try{const e=t.indexOf(".");if(e===-1)return null;const i=t.substring(0,e),r=t.substring(e+1),o="3ab57dfcba56a3c6b1949906ef075ff6536f2a40b328a77733e4d8d837cb6abe",s=new TextEncoder().encode(i);if(!M0.verify($h(r),s,$h(o)))return null;const a=atob(i),c=JSON.parse(a);return!c.customer||!this.checkExpiry(c.expiry)||!this.checkDomain(c.domains)?null:c}catch{return null}}checkExpiry(t){if(!t)return!0;try{return new Date(t).getTime()>=Date.now()}catch{return!1}}checkDomain(t){if(!t||t.length===0||typeof window>"u")return!0;const e=window.location.hostname;return t.some(i=>{if(i.startsWith("*.")){const r=i.substring(1);return e.endsWith(r)||e===i.substring(2)}return e===i})}}function ya(){return Date.now()}function $h(n){if(n.length%2!==0)throw new Error("invalid hex length");const t=new Uint8Array(n.length/2);for(let e=0;e<t.length;e++)t[e]=parseInt(n.slice(e*2,e*2+2),16);return t}const tn=new L0;class $0{constructor(){this.indicators=new Map}register(t){this.indicators.set(t.name.toLowerCase(),t)}get(t){return this.indicators.get(t.toLowerCase())}getAll(){return new Map(this.indicators)}}const Ih=globalThis,I0=Ih.__katuIndicatorRegistry||(Ih.__katuIndicatorRegistry=new $0),xa={sma:"sma",ema:"ema",wma:"wma",rsi:"rsi",macd:"macd",stochastic:"stochastic",stoch:"stochastic",bb:"bollingerbands",bollinger:"bollingerbands",bollingerbands:"bollingerbands",atr:"atr",vwap:"vwap",obv:"obv",vbp:"vbp",ichimoku:"ichimoku",ikh:"ichimoku",cci:"cci",roc:"roc",momentum:"momentum",mom:"momentum",dema:"dema",tema:"tema",adx:"adx",psar:"psar"},F0=new Set(Object.keys(xa));function ba(n){return!!n&&F0.has(n.toLowerCase())}const Fh="#7798BF",va="#f15c80",R0="#90ed7d";function D0(n){return n.map((t,e)=>{const i=t.close??t.y??0;return{x:t.x??e,open:t.open??i,high:t.high??i,low:t.low??i,close:i,volume:t.volume??t.z}})}function z0(n,t){const e=n.linkedTo;if(typeof e=="string"){const i=t.find(r=>r.id===e);if(i)return i}return typeof e=="number"&&t[e]?t[e]:t.find(i=>i!==n&&!ba(i._internalType))??null}const B0={sma:"SMA",ema:"EMA",wma:"WMA",rsi:"RSI",macd:"MACD",stochastic:"Stochastic",bollingerbands:"Bollinger Bands",atr:"ATR",vwap:"VWAP",obv:"OBV",ichimoku:"Ichimoku",cci:"CCI",roc:"ROC",momentum:"Momentum",dema:"DEMA",tema:"TEMA",adx:"ADX",psar:"PSAR"};function O0(n,t){const e=B0[n]||n.toUpperCase(),i=t.period;return i?`${e} (${i})`:e}function en(n,t,e,i){return{...n,type:t,_internalType:t,_processedData:e,data:e,params:void 0,linkedTo:void 0,...i}}function N0(n,t){return n.map((e,i)=>{var r;return{x:e.x,low:((r=t[i])==null?void 0:r.y)??null,high:e.y??null}})}function W0(n,t,e,i){const r=[],o=n.color||Fh,s=n.lineWidth??1.5,a=n.name||O0(t,i);if(e.bands){if(r.push(en(n,"arearange",N0(e.bands.upper,e.bands.lower),{name:`${a} band`,color:n.color||Fh,fillOpacity:n.fillOpacity??.15,lineWidth:0,showInLegend:!1,enableMouseTracking:!1})),t==="ichimoku")r.push(en(n,"line",e.values,{name:`${a} Tenkan`,color:o,lineWidth:s,marker:{enabled:!1}})),e.signal&&r.push(en(n,"line",e.signal,{name:`${a} Kijun`,color:va,lineWidth:s,marker:{enabled:!1}}));else{const c=e.bands.middle??e.values;r.push(en(n,"line",c,{name:a,color:o,lineWidth:s,marker:{enabled:!1}}))}return r}return e.histogram?(r.push(en(n,"column",e.histogram,{name:`${a} Histogram`,color:R0,showInLegend:!1,enableMouseTracking:!1})),r.push(en(n,"line",e.values,{name:a,color:o,lineWidth:s,marker:{enabled:!1}})),e.signal&&r.push(en(n,"line",e.signal,{name:`${a} Signal`,color:va,lineWidth:s,marker:{enabled:!1}})),r):e.signal?(r.push(en(n,"line",e.values,{name:`${a} %K`,color:o,lineWidth:s,marker:{enabled:!1}})),r.push(en(n,"line",e.signal,{name:`${a} %D`,color:va,lineWidth:s,marker:{enabled:!1}})),r):t==="vbp"?(r.push(en(n,"vbp",e.values,{name:a,showInLegend:n.showInLegend??!1})),r):t==="psar"?(r.push(en(n,"scatter",e.values,{name:a,color:o,marker:{enabled:!0,radius:2,symbol:"circle"}})),r):(r.push(en(n,"line",e.values,{name:a,color:o,lineWidth:s,marker:{enabled:!1}})),r)}function H0(n){if(!n.some(e=>ba(e._internalType)))return n;const t=[];for(const e of n){const i=(e._internalType||"").toLowerCase();if(!ba(i)){t.push(e);continue}const r=I0.get(xa[i]),o=z0(e,n);if(!r||!o){t.push({...e,type:"line",_internalType:"line",_processedData:[],data:[]});continue}const s=e.params||{},a=r.calculate(D0(o._processedData||[]),s);t.push(...W0(e,xa[i],a,s))}return t.map((e,i)=>({...e,index:i}))}let ko={};function wa(n){ko=fe(ko,n)}function Rh(){return ko}const ni=class ni{parse(t){var o;(o=t.chart)!=null&&o.palette&&!t.colors&&(t={...t,colors:Dl(t.chart.palette)});const e=t.theme?Ol(t.theme):void 0,i=this.mergeWithDefaults(t,e),r=this.normalize(i);return this.toInternal(r)}mergeWithDefaults(t,e){return fe(fe({},Zs),ko,e??{},t)}normalize(t){var l,h,f;const e={...t};e.xAxis&&!Array.isArray(e.xAxis)&&(e.xAxis=[e.xAxis]),e.yAxis&&!Array.isArray(e.yAxis)&&(e.yAxis=[e.yAxis]),e.colorAxis&&!Array.isArray(e.colorAxis)&&(e.colorAxis=[e.colorAxis]),(!e.xAxis||Array.isArray(e.xAxis)&&e.xAxis.length===0)&&(e.xAxis=[fe({},Zs.xAxis)]),(!e.yAxis||Array.isArray(e.yAxis)&&e.yAxis.length===0)&&(e.yAxis=[fe({},Zs.yAxis)]);for(const u of[e.xAxis,e.yAxis])if(Array.isArray(u))for(const d of u)d.categories&&d.categories.length>0&&(d.type="category");e.series&&!Array.isArray(e.series)&&(e.series=[e.series]);const i=((l=e.chart)==null?void 0:l.type)||"line",r=i==="bar"||Array.isArray(e.series)&&e.series.some(u=>u.type==="bar");if(e.chart&&(r?(e.chart.inverted=!0,e.chart._invertedFromBar=!0):e.chart._invertedFromBar&&(e.chart.inverted=!1,delete e.chart._invertedFromBar)),(i==="manhattan"||Array.isArray(e.series)&&e.series.some(u=>u.type==="manhattan"))&&Array.isArray(e.xAxis)&&(!Array.isArray(e.series)||e.series.some(d=>(d.type==="manhattan"||!d.type&&i==="manhattan")&&d.showChromosomeLabels!==!1)))for(const d of e.xAxis)d.labels={...d.labels,enabled:!1},d.tickLength=0;const s=!!((h=e.chart)!=null&&h.polar),a=(f=e.chart)==null?void 0:f.type;s&&Array.isArray(e.series)&&(e.series=e.series.map(u=>{const d=u.type||a||"line",p=!u.type||u.type==="line"||u.type==="spline",y=!u.type&&(a==="line"||a==="spline"),g={...u,type:p?"radar":u.type};return u.type==="line"||u.type==="spline"||y?g._polarSubType="line":(d==="column"||d==="bar")&&(g._polarSubType="column"),g}));const c=Array.isArray(e.colorAxis)?e.colorAxis[0]:e.colorAxis;return Array.isArray(e.series)&&(e.series=e.series.map(u=>{const d=this.normalizeSeries(u,s&&(!u.type||u.type==="line"||u.type==="spline")?"radar":i,e.plotOptions);return(d.type==="heatmap"||d.type==="treemap")&&c&&!d.colorAxis&&(d.colorAxis=c),(d.type==="map"||d.type==="mappoint"||d.type==="flowmap")&&this.applyMapTopLevelOptions(d,e,c),d})),this.applyAutoHeight(e),e}applyAutoHeight(t){var i;const e=t.chart;if(e){if(e._autoScrollMinHeight!=null){const r=e.scrollablePlotArea;if(r&&typeof r=="object"&&r.minHeight===e._autoScrollMinHeight){const o={...r};delete o.minHeight,e.scrollablePlotArea=Object.keys(o).length?o:void 0}delete e._autoScrollMinHeight}if(e.height==null&&e.inverted){const r=Array.isArray(t.xAxis)?t.xAxis:t.xAxis?[t.xAxis]:[];let o=0;for(const s of r){const a=((i=s==null?void 0:s.categories)==null?void 0:i.length)??0;a>o&&(o=a)}if(o>12){const s=Math.min(o*26+130,9e3),a=e.scrollablePlotArea&&typeof e.scrollablePlotArea=="object"?e.scrollablePlotArea:{};e.scrollablePlotArea={...a,minHeight:s},e._autoScrollMinHeight=s;return}}}}applyMapTopLevelOptions(t,e,i){var r,o;i&&(!t.colorAxis||typeof t.colorAxis!="object")&&(t.colorAxis=i),t.mapNavigation==null&&e.mapNavigation!=null&&(t.mapNavigation=e.mapNavigation),t.projection==null&&((r=e.mapView)==null?void 0:r.projection)!=null&&(t.projection=e.mapView.projection),t.mapData==null&&((o=e.chart)==null?void 0:o.map)!=null&&(t.mapData=e.chart.map)}static mergeDataLabels(t){let e;for(const i of t)i!==void 0&&(e=ni.mergeTwoDataLabels(e,i));return e}static mergeTwoDataLabels(t,e){if(t===void 0)return e;if(e===void 0)return t;const i=Array.isArray(t)?t:[t],r=Array.isArray(e)?e:[e],o=Math.max(i.length,r.length),s=[];for(let a=0;a<o;a++){const c=i[a]??i[0]??{},l=r[a]??r[0]??{};s.push(fe({},c,l))}return s.length===1&&!Array.isArray(t)&&!Array.isArray(e)?s[0]:s}normalizeSeries(t,e,i){let r={...t};if(r.type?delete r._typeFromChart:(r.type=e,r._typeFromChart=!0),i){const o=i.series||{},s=i[r.type]||{},a=r._polarSubType,c=a?i[a]||{}:{},l=ni.mergeDataLabels([o,c,s,r].map(h=>h.dataLabels));r=fe({},o,c,s,r),l!==void 0&&(r.dataLabels=l)}if(Array.isArray(r.data)){const o=r.turboThreshold??1e3;if(r.data.length>o){const s=r.data[0];if(s!==null&&typeof s=="object"&&!Array.isArray(s)&&console.warn(`KatuCharts: series data length (${r.data.length}) exceeds turboThreshold (${o}). Use array format (numbers or [x,y] pairs) for better performance.`),typeof s=="number"||Array.isArray(s)&&typeof s[0]=="number")return r.data=this.normalizeDataBulk(r.data,r),r}r.data=r.data.map((s,a)=>this.normalizeDataPoint(s,a,r))}else r.data!=null&&(r.data=[]);return r}defaultArrayKeys(t,e){return t?ni.OHLC_TYPES.has(t)?e>=5?["x","open","high","low","close"]:["open","high","low","close"]:ni.RANGE_TYPES.has(t)?e>=3?["x","low","high"]:["low","high"]:null:null}normalizeDataPoint(t,e,i){if(t===null)return{x:(i.pointStart??0)+e*(i.pointInterval??1),y:null};if(typeof t=="number")return{x:(i.pointStart??0)+e*(i.pointInterval??1),y:t};if(Array.isArray(t)&&t.length===5&&i.type==="boxplot"){const r=t;return{x:(i.pointStart??0)+e*(i.pointInterval??1),low:r[0],q1:r[1],median:r[2],q3:r[3],high:r[4]}}if(Array.isArray(t)&&i.type==="flowmap")return{from:t[0],to:t[1],weight:t[2]};if(Array.isArray(t)){if(i.keys&&i.keys.length>0){const o={};for(let s=0;s<i.keys.length&&s<t.length;s++)o[i.keys[s]]=t[s];return o.x===void 0&&(!Ti.has(i.type)||!o.name)&&(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o}const r=this.defaultArrayKeys(i.type,t.length);if(r){const o={};for(let s=0;s<r.length&&s<t.length;s++)o[r[s]]=t[s];return o.x===void 0&&(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o.close!==void 0&&o.y===void 0&&(o.y=o.close),o}if(typeof t[0]=="string"){const o={name:t[0],y:t[1]};return Ti.has(i.type)||(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o}return t.length>=3?{x:t[0],y:t[1],z:t[2]}:{x:t[0],y:t[1]}}if(typeof t=="object"){const r={...t},o=i.type==="map"||i.type==="mappoint"||i.type==="flowmap",s=!Ti.has(i.type);return!o&&r.x===void 0&&(s||!r.name)&&(r.x=(i.pointStart??0)+e*(i.pointInterval??1)),r}return{y:null}}normalizeDataBulk(t,e){const i=t.length,r=new Array(i),o=e.pointStart??0,s=e.pointInterval??1,a=t[0];if(typeof a=="number")for(let c=0;c<i;c++)r[c]={x:o+c*s,y:t[c]};else{const c=Array.isArray(a)?this.defaultArrayKeys(e.type,a.length):null;if(c)for(let l=0;l<i;l++){const h=t[l],f={};for(let u=0;u<c.length&&u<h.length;u++)f[c[u]]=h[u];f.x===void 0&&(f.x=o+l*s),f.close!==void 0&&f.y===void 0&&(f.y=f.close),r[l]=f}else for(let l=0;l<i;l++){const h=t[l];h.length>=3?r[l]={x:h[0],y:h[1],z:h[2]}:r[l]={x:h[0],y:h[1]}}}return r}enforceCredits(t){return tn.isLicensed()?t:{...t,enabled:!0,text:!t.text||!t.text.trim()?"Powered by: KatuCharts":t.text}}toInternal(t){var c,l,h;const e=!!((c=t.chart)!=null&&c.inverted),i=(l=t.chart)==null?void 0:l.backgroundColor,r=t.xAxis.map((f,u)=>({...f,index:u,isX:!0,_inverted:e,_backgroundColor:i})),o=t.yAxis.map((f,u)=>({...f,index:u,isX:!1,_inverted:e,_backgroundColor:i})),s=(t.series||[]).map((f,u)=>{var m;const d=typeof f.xAxis=="number"?f.xAxis:0,p=typeof f.yAxis=="number"?f.yAxis:0,y=f.type||((m=t.chart)==null?void 0:m.type)||"line",g=y==="pie"||y==="donut"||y==="sankey";return{...f,index:u,_internalType:y,_xAxisIndex:d,_yAxisIndex:p,_xAxis:r[d]||r[0],_yAxis:o[p]||o[0],_processedData:f.data||[],...g&&f.showInLegend===void 0?{showInLegend:!1}:{}}}),a=H0(s);return{chart:{width:null,height:null,backgroundColor:"#ffffff",animation:!0,reflow:!0,...t.chart},title:t.title||{},subtitle:t.subtitle||{},xAxis:r,yAxis:o,colorAxis:t.colorAxis||[],series:a,tooltip:t.tooltip||{},legend:{...t.legend||{},_backgroundColor:(h=t.chart)==null?void 0:h.backgroundColor},plotOptions:t.plotOptions||{},credits:this.enforceCredits(t.credits||{}),exporting:t.exporting||{},loading:t.loading||{},navigator:t.navigator||{},rangeSelector:t.rangeSelector||{},drilldown:t.drilldown||{},responsive:t.responsive||{},accessibility:t.accessibility||{},colors:t.colors||[],time:t.time||{}}}};ni.OHLC_TYPES=new Set(["candlestick","ohlc","heikinashi","hollowcandlestick"]),ni.RANGE_TYPES=new Set(["arearange","areasplinerange","columnrange"]);let Kn=ni;var ka="http://www.w3.org/1999/xhtml";const Dh={svg:"http://www.w3.org/2000/svg",xhtml:ka,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mo(n){var t=n+="",e=t.indexOf(":");return e>=0&&(t=n.slice(0,e))!=="xmlns"&&(n=n.slice(e+1)),Dh.hasOwnProperty(t)?{space:Dh[t],local:n}:n}function V0(n){return function(){var t=this.ownerDocument,e=this.namespaceURI;return e===ka&&t.documentElement.namespaceURI===ka?t.createElement(n):t.createElementNS(e,n)}}function G0(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function zh(n){var t=Mo(n);return(t.local?G0:V0)(t)}function Y0(){}function Ma(n){return n==null?Y0:function(){return this.querySelector(n)}}function X0(n){typeof n!="function"&&(n=Ma(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=new Array(s),c,l,h=0;h<s;++h)(c=o[h])&&(l=n.call(c,c.__data__,h,o))&&("__data__"in c&&(l.__data__=c.__data__),a[h]=l);return new qe(i,this._parents)}function U0(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function j0(){return[]}function Bh(n){return n==null?j0:function(){return this.querySelectorAll(n)}}function q0(n){return function(){return U0(n.apply(this,arguments))}}function Z0(n){typeof n=="function"?n=q0(n):n=Bh(n);for(var t=this._groups,e=t.length,i=[],r=[],o=0;o<e;++o)for(var s=t[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(i.push(n.call(c,c.__data__,l,s)),r.push(c));return new qe(i,r)}function Oh(n){return function(){return this.matches(n)}}function Nh(n){return function(t){return t.matches(n)}}var K0=Array.prototype.find;function J0(n){return function(){return K0.call(this.children,n)}}function Q0(){return this.firstElementChild}function tm(n){return this.select(n==null?Q0:J0(typeof n=="function"?n:Nh(n)))}var em=Array.prototype.filter;function nm(){return Array.from(this.children)}function im(n){return function(){return em.call(this.children,n)}}function rm(n){return this.selectAll(n==null?nm:im(typeof n=="function"?n:Nh(n)))}function om(n){typeof n!="function"&&(n=Oh(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=[],c,l=0;l<s;++l)(c=o[l])&&n.call(c,c.__data__,l,o)&&a.push(c);return new qe(i,this._parents)}function Wh(n){return new Array(n.length)}function sm(){return new qe(this._enter||this._groups.map(Wh),this._parents)}function Ao(n,t){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=t}Ao.prototype={constructor:Ao,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,t){return this._parent.insertBefore(n,t)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function am(n){return function(){return n}}function cm(n,t,e,i,r,o){for(var s=0,a,c=t.length,l=o.length;s<l;++s)(a=t[s])?(a.__data__=o[s],i[s]=a):e[s]=new Ao(n,o[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function lm(n,t,e,i,r,o,s){var a,c,l=new Map,h=t.length,f=o.length,u=new Array(h),d;for(a=0;a<h;++a)(c=t[a])&&(u[a]=d=s.call(c,c.__data__,a,t)+"",l.has(d)?r[a]=c:l.set(d,c));for(a=0;a<f;++a)d=s.call(n,o[a],a,o)+"",(c=l.get(d))?(i[a]=c,c.__data__=o[a],l.delete(d)):e[a]=new Ao(n,o[a]);for(a=0;a<h;++a)(c=t[a])&&l.get(u[a])===c&&(r[a]=c)}function hm(n){return n.__data__}function um(n,t){if(!arguments.length)return Array.from(this,hm);var e=t?lm:cm,i=this._parents,r=this._groups;typeof n!="function"&&(n=am(n));for(var o=r.length,s=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var h=i[l],f=r[l],u=f.length,d=fm(n.call(h,h&&h.__data__,l,i)),p=d.length,y=a[l]=new Array(p),g=s[l]=new Array(p),m=c[l]=new Array(u);e(h,f,y,g,m,d,t);for(var x=0,v=0,b,k;x<p;++x)if(b=y[x]){for(x>=v&&(v=x+1);!(k=g[v])&&++v<p;);b._next=k||null}}return s=new qe(s,i),s._enter=a,s._exit=c,s}function fm(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function dm(){return new qe(this._exit||this._groups.map(Wh),this._parents)}function pm(n,t,e){var i=this.enter(),r=this,o=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),t!=null&&(r=t(r),r&&(r=r.selection())),e==null?o.remove():e(o),i&&r?i.merge(r).order():r}function gm(n){for(var t=n.selection?n.selection():n,e=this._groups,i=t._groups,r=e.length,o=i.length,s=Math.min(r,o),a=new Array(r),c=0;c<s;++c)for(var l=e[c],h=i[c],f=l.length,u=a[c]=new Array(f),d,p=0;p<f;++p)(d=l[p]||h[p])&&(u[p]=d);for(;c<r;++c)a[c]=e[c];return new qe(a,this._parents)}function mm(){for(var n=this._groups,t=-1,e=n.length;++t<e;)for(var i=n[t],r=i.length-1,o=i[r],s;--r>=0;)(s=i[r])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function ym(n){n||(n=xm);function t(f,u){return f&&u?n(f.__data__,u.__data__):!f-!u}for(var e=this._groups,i=e.length,r=new Array(i),o=0;o<i;++o){for(var s=e[o],a=s.length,c=r[o]=new Array(a),l,h=0;h<a;++h)(l=s[h])&&(c[h]=l);c.sort(t)}return new qe(r,this._parents).order()}function xm(n,t){return n<t?-1:n>t?1:n>=t?0:NaN}function bm(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function vm(){return Array.from(this)}function wm(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var i=n[t],r=0,o=i.length;r<o;++r){var s=i[r];if(s)return s}return null}function km(){let n=0;for(const t of this)++n;return n}function Mm(){return!this.node()}function Am(n){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var r=t[e],o=0,s=r.length,a;o<s;++o)(a=r[o])&&n.call(a,a.__data__,o,r);return this}function Sm(n){return function(){this.removeAttribute(n)}}function _m(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Cm(n,t){return function(){this.setAttribute(n,t)}}function Pm(n,t){return function(){this.setAttributeNS(n.space,n.local,t)}}function Em(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttribute(n):this.setAttribute(n,e)}}function Tm(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}}function Lm(n,t){var e=Mo(n);if(arguments.length<2){var i=this.node();return e.local?i.getAttributeNS(e.space,e.local):i.getAttribute(e)}return this.each((t==null?e.local?_m:Sm:typeof t=="function"?e.local?Tm:Em:e.local?Pm:Cm)(e,t))}function Hh(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function $m(n){return function(){this.style.removeProperty(n)}}function Im(n,t,e){return function(){this.style.setProperty(n,t,e)}}function Fm(n,t,e){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,e)}}function Rm(n,t,e){return arguments.length>1?this.each((t==null?$m:typeof t=="function"?Fm:Im)(n,t,e??"")):Fi(this.node(),n)}function Fi(n,t){return n.style.getPropertyValue(t)||Hh(n).getComputedStyle(n,null).getPropertyValue(t)}function Dm(n){return function(){delete this[n]}}function zm(n,t){return function(){this[n]=t}}function Bm(n,t){return function(){var e=t.apply(this,arguments);e==null?delete this[n]:this[n]=e}}function Om(n,t){return arguments.length>1?this.each((t==null?Dm:typeof t=="function"?Bm:zm)(n,t)):this.node()[n]}function Vh(n){return n.trim().split(/^|\s+/)}function Aa(n){return n.classList||new Gh(n)}function Gh(n){this._node=n,this._names=Vh(n.getAttribute("class")||"")}Gh.prototype={add:function(n){var t=this._names.indexOf(n);t<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var t=this._names.indexOf(n);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Yh(n,t){for(var e=Aa(n),i=-1,r=t.length;++i<r;)e.add(t[i])}function Xh(n,t){for(var e=Aa(n),i=-1,r=t.length;++i<r;)e.remove(t[i])}function Nm(n){return function(){Yh(this,n)}}function Wm(n){return function(){Xh(this,n)}}function Hm(n,t){return function(){(t.apply(this,arguments)?Yh:Xh)(this,n)}}function Vm(n,t){var e=Vh(n+"");if(arguments.length<2){for(var i=Aa(this.node()),r=-1,o=e.length;++r<o;)if(!i.contains(e[r]))return!1;return!0}return this.each((typeof t=="function"?Hm:t?Nm:Wm)(e,t))}function Gm(){this.textContent=""}function Ym(n){return function(){this.textContent=n}}function Xm(n){return function(){var t=n.apply(this,arguments);this.textContent=t??""}}function Um(n){return arguments.length?this.each(n==null?Gm:(typeof n=="function"?Xm:Ym)(n)):this.node().textContent}function jm(){this.innerHTML=""}function qm(n){return function(){this.innerHTML=n}}function Zm(n){return function(){var t=n.apply(this,arguments);this.innerHTML=t??""}}function Km(n){return arguments.length?this.each(n==null?jm:(typeof n=="function"?Zm:qm)(n)):this.node().innerHTML}function Jm(){this.nextSibling&&this.parentNode.appendChild(this)}function Qm(){return this.each(Jm)}function ty(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ey(){return this.each(ty)}function ny(n){var t=typeof n=="function"?n:zh(n);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function iy(){return null}function ry(n,t){var e=typeof n=="function"?n:zh(n),i=t==null?iy:typeof t=="function"?t:Ma(t);return this.select(function(){return this.insertBefore(e.apply(this,arguments),i.apply(this,arguments)||null)})}function oy(){var n=this.parentNode;n&&n.removeChild(this)}function sy(){return this.each(oy)}function ay(){var n=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function cy(){var n=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function ly(n){return this.select(n?cy:ay)}function hy(n){return arguments.length?this.property("__data__",n):this.node().__data__}function uy(n){return function(t){n.call(this,t,this.__data__)}}function fy(n){return n.trim().split(/^|\s+/).map(function(t){var e="",i=t.indexOf(".");return i>=0&&(e=t.slice(i+1),t=t.slice(0,i)),{type:t,name:e}})}function dy(n){return function(){var t=this.__on;if(t){for(var e=0,i=-1,r=t.length,o;e<r;++e)o=t[e],(!n.type||o.type===n.type)&&o.name===n.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function py(n,t,e){return function(){var i=this.__on,r,o=uy(t);if(i){for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=e),r.value=t;return}}this.addEventListener(n.type,o,e),r={type:n.type,name:n.name,value:t,listener:o,options:e},i?i.push(r):this.__on=[r]}}function gy(n,t,e){var i=fy(n+""),r,o=i.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,h;c<l;++c)for(r=0,h=a[c];r<o;++r)if((s=i[r]).type===h.type&&s.name===h.name)return h.value}return}for(a=t?py:dy,r=0;r<o;++r)this.each(a(i[r],t,e));return this}function Uh(n,t,e){var i=Hh(n),r=i.CustomEvent;typeof r=="function"?r=new r(t,e):(r=i.document.createEvent("Event"),e?(r.initEvent(t,e.bubbles,e.cancelable),r.detail=e.detail):r.initEvent(t,!1,!1)),n.dispatchEvent(r)}function my(n,t){return function(){return Uh(this,n,t)}}function yy(n,t){return function(){return Uh(this,n,t.apply(this,arguments))}}function xy(n,t){return this.each((typeof t=="function"?yy:my)(n,t))}function*by(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var i=n[t],r=0,o=i.length,s;r<o;++r)(s=i[r])&&(yield s)}var jh=[null];function qe(n,t){this._groups=n,this._parents=t}function dr(){return new qe([[document.documentElement]],jh)}function vy(){return this}qe.prototype=dr.prototype={constructor:qe,select:X0,selectAll:Z0,selectChild:tm,selectChildren:rm,filter:om,data:um,enter:sm,exit:dm,join:pm,merge:gm,selection:vy,order:mm,sort:ym,call:bm,nodes:vm,node:wm,size:km,empty:Mm,each:Am,attr:Lm,style:Rm,property:Om,classed:Vm,text:Um,html:Km,raise:Qm,lower:ey,append:ny,insert:ry,remove:sy,clone:ly,datum:hy,on:gy,dispatch:xy,[Symbol.iterator]:by};function st(n){return typeof n=="string"?new qe([[document.querySelector(n)]],[document.documentElement]):new qe([[n]],jh)}function wy(n){let t;for(;t=n.sourceEvent;)n=t;return n}function mn(n,t){if(n=wy(n),t===void 0&&(t=n.currentTarget),t){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var i=e.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[n.clientX-r.left-t.clientLeft,n.clientY-r.top-t.clientTop]}}return[n.pageX,n.pageY]}class ky{constructor(t){this.el=t}attr(t){for(const[e,i]of Object.entries(t))e!=="zIndex"&&this.el.attr(e,i);return this}css(t){for(const[e,i]of Object.entries(t)){const r=e.replace(/[A-Z]/g,o=>"-"+o.toLowerCase());this.el.style(r,i),e==="color"&&this.el.attr("fill",i)}return this}add(){return this}getBBox(){const t=this.el.node();if(!t||typeof t.getBBox!="function")return{x:0,y:0,width:0,height:0};try{return t.getBBox()}catch{return{x:0,y:0,width:0,height:0}}}destroy(){this.el.remove()}}const rr=class rr{constructor(t,e,i){this.svg=st(t).append("svg").attr("class","katucharts-root").attr("xmlns","http://www.w3.org/2000/svg").attr("width",e).attr("height",i).style("overflow","hidden").style("outline","none").style("display","block").style("max-width","100%"),this.defs=this.svg.append("defs")}setSize(t,e){this.svg.attr("width",t).attr("height",e)}createGroup(t,e){const r=(e||this.svg).append("g");return t&&r.attr("class",t),r}text(t,e,i){const r=this.svg.append("text").attr("x",e).attr("y",i).style("pointer-events","none").text(t);return new ky(r)}createClipPath(t,e,i,r){const o=`katucharts-clip-${++rr.clipPathCounter}`;return this.defs.append("clipPath").attr("id",o).append("rect").attr("x",t).attr("y",e).attr("width",i).attr("height",r),o}updateClipPath(t,e,i,r,o){this.defs.select(`#${t} rect`).attr("x",e).attr("y",i).attr("width",r).attr("height",o)}createLinearGradient(t,e,i,r,o,s){const a=t||`katucharts-grad-${++rr.gradientCounter}`,c=this.defs.append("linearGradient").attr("id",a).attr("x1",e).attr("y1",i).attr("x2",r).attr("y2",o);for(const l of s)c.append("stop").attr("offset",l.offset).attr("stop-color",l.color).attr("stop-opacity",l.opacity??1);return a}getSVGNode(){return this.svg.node()}destroy(){this.svg.remove()}getSerializedSVG(){const t=this.svg.node();return t?new XMLSerializer().serializeToString(t):""}};rr.clipPathCounter=0,rr.gradientCounter=0;let So=rr;class qh{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push({callback:e,once:!1}),this}once(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push({callback:e,once:!0}),this}off(t,e){if(!e)return this.listeners.delete(t),this;const i=this.listeners.get(t);return i&&this.listeners.set(t,i.filter(r=>r.callback!==e)),this}emit(t,...e){const i=this.listeners.get(t);if(!i)return this;const r=[];for(const o of i)o.callback(...e),o.once&&r.push(o);return r.length&&this.listeners.set(t,i.filter(o=>!r.includes(o))),this}removeAllListeners(){this.listeners.clear()}static mapEvent(t,e){return`${t}:${e.toLowerCase()}`}}class My{constructor(t,e){this.config=t,this.events=e}getConfig(){return this.config}updateConfig(t){this.config=fe(this.config,t),this.events.emit("state:configChanged",this.config)}getSeries(){return this.config.series}getSeriesById(t){return this.config.series.find(e=>e.id===t)}getSeriesByIndex(t){return this.config.series[t]}addSeries(t){this.config.series=[...this.config.series,t],this.events.emit("state:seriesAdded",t)}removeSeries(t){const e=this.config.series[t];return e&&(this.config.series=this.config.series.filter((i,r)=>r!==t),this.events.emit("state:seriesRemoved",e,t)),e}updateSeries(t,e){const i=this.config.series[t];i&&(this.config.series[t]=fe(i,e),this.events.emit("state:seriesUpdated",this.config.series[t],t))}getXAxes(){return this.config.xAxis}getYAxes(){return this.config.yAxis}updateAxis(t,e,i){const r=t?this.config.xAxis:this.config.yAxis;r[e]&&(r[e]=fe(r[e],i),this.events.emit("state:axisUpdated",{isX:t,index:e,config:r[e]}))}}class Ay{constructor(){this.types=new Map}registerType(t,e){this.types.set(t,e)}getType(t){return this.types.get(t)}hasType(t){return this.types.has(t)}getRegisteredTypes(){return Array.from(this.types.keys())}}const Zh=globalThis,Tt=Zh.__katuChartRegistry||(Zh.__katuChartRegistry=new Ay);class Sy{constructor(){this.modules=new Map}register(t){this.modules.set(t.name,t)}get(t){return this.modules.get(t)}getAll(){return Array.from(this.modules.values())}}const Kh=new Sy;class _y{compute(t,e,i){var F,D,z,B,W,K,X,q,N,H,Y,G,Q,O,it;const r=this.getSpacing(t);let o=r.top,s=r.bottom;const a=r.left,c=r.right,l=((F=t.title)==null?void 0:F.widthAdjust)??-44,h=e+l,f=(z=(D=t.title)==null?void 0:D.style)!=null&&z.fontSize?t.title.style:{...(B=t.title)==null?void 0:B.style,fontSize:"18px"},u=(W=t.title)!=null&&W.text?this.estimateWrappedTextHeight(t.title.text,f,h):0,d=((K=t.title)==null?void 0:K.margin)??8,p=(X=t.subtitle)!=null&&X.text?this.estimateWrappedTextHeight(t.subtitle.text,t.subtitle.style,h):0;u>0&&(o=r.top+u+(p>0?3:d)),p>0&&(o+=p+d);const y=t.series.some(et=>et._internalType==="heatmap"),g=((q=t.legend)==null?void 0:q.align)||"center",m=!y&&((N=t.legend)==null?void 0:N.enabled)!==!1&&((H=t.legend)==null?void 0:H.layout)==="vertical"&&(g==="left"||g==="right"),x=y||m?0:this.estimateLegendHeight(t,e),v=((Y=t.legend)==null?void 0:Y.verticalAlign)||"bottom";!m&&v==="bottom"?s=Math.max(s,r.bottom)+x:!m&&v==="top"&&(o+=x);const b=m?this.estimateLegendWidth(t):0,k=m&&g==="left"?b:0,M=m&&g==="right"?b:0;if((G=t.navigator)!=null&&G.enabled){const et=t.navigator;s+=(et.height??40)+(et.margin??20)}const C=this.isNonCartesian(t),_=!!t.chart.inverted?{...t,xAxis:t.yAxis,yAxis:t.xAxis}:t,T=C?0:this.estimateAxisWidth(_,!0,i,e),I=C?0:this.estimateAxisWidth(_,!1,i,e),L=C?0:this.estimateAxisHeight(_);let P=0;y&&((Q=t.colorAxis)==null?void 0:Q.length)>0&&((O=t.legend)==null?void 0:O.layout)==="vertical"&&(P=55);const A=a+T+k,w=o,S=Math.max(0,e-a-c-T-I-P-k-M),$=((it=t.chart)==null?void 0:it.marginBottom)!==void 0,R=Math.max(0,i-o-s-($?0:L));return{plotArea:{x:A,y:w,width:S,height:R},titleArea:{x:r.left,y:r.top,width:e-r.left-r.right,height:u+d},subtitleArea:{x:r.left,y:r.top+u+d,width:e-r.left-r.right,height:p},legendArea:m?{x:g==="right"?e-c-M:a,y:w,width:b,height:R}:{x:0,y:v==="top"?o-x:i-s,width:e,height:x}}}isNonCartesian(t){return t.series.length>0&&t.series.every(e=>Ti.has(e._internalType))}getSpacing(t){var s;const e=t.chart;if(e.margin!==void 0){const a=e.margin;if(typeof a=="number")return{top:a,right:a,bottom:a,left:a};if(Array.isArray(a))return{top:a[0]??10,right:a[1]??10,bottom:a[2]??15,left:a[3]??10}}const i=e.spacing||[10,10,15,10],o=((s=t.exporting)==null?void 0:s.enabled)!==!1&&!this.isNonCartesian(t)?40:i[1]??10;return{top:e.marginTop??e.spacingTop??i[0],right:e.marginRight??e.spacingRight??o,bottom:e.marginBottom??e.spacingBottom??i[2],left:e.marginLeft??e.spacingLeft??i[3]}}estimateTextHeight(t){return me(t==null?void 0:t.fontSize)*1.4}estimateWrappedTextHeight(t,e,i){const r=me(e==null?void 0:e.fontSize),o=r*1.4;if(!i||i<=0)return o;const s=r*.55,a=Math.floor(i/s);if(a<=0)return o;const c=Math.ceil(t.length/a);return o*Math.max(c,1)}computeAutoFontSize(t,e){return e||"12px"}estimateLegendHeight(t,e){var r,o;const i=this.estimateSeriesLegendHeight(t,e);if((r=t.legend)!=null&&r.enabled&&((o=t.legend.bubbleLegend)!=null&&o.enabled)){const s=t.series.find(a=>a._internalType==="bubble");if(s){const a=t.legend.margin??8,l=(t.legend.bubbleLegend.maxSize??(typeof s.maxSize=="number"?s.maxSize:30))*2+16+a;return(t.legend.layout||"horizontal")==="horizontal"&&t.legend.bubbleLegend.layout==="separate"?i+l:Math.max(i,l)}}return i}estimateLegendWidth(t){var u;const e=t.legend;if(!e)return 0;const i=t.series.filter(d=>d.showInLegend!==!1),r=e.itemStyle||{},o=me(r.fontSize||kt),s=e.symbolWidth??12,a=e.symbolPadding??5,c=e.padding??8;let l=0;i.forEach((d,p)=>{const y=d._internalType==="pie"&&Array.isArray(d.data)?d.data.map(g=>(g&&typeof g=="object"?g.name:void 0)||""):[d.name||`Series ${p+1}`];for(const g of y){const m=He(g,o);m>l&&(l=m)}});let h=s+a+l;if((u=e.bubbleLegend)!=null&&u.enabled){const d=t.series.find(p=>p._internalType==="bubble");if(d){const p=e.bubbleLegend.maxSize??(typeof d.maxSize=="number"?d.maxSize:30),y=e.bubbleLegend.connectorDistance??16;h=Math.max(h,p*2+y+30)}}const f=e.margin??12;return h+c*2+f}estimateSeriesLegendHeight(t,e){var p;if(!((p=t.legend)!=null&&p.enabled))return 0;const i=t.series.filter(y=>y.showInLegend!==!1),r=i.length;if(r===0)return 0;const o=t.legend.margin??8,s=t.legend.layout||"horizontal",c=(t.legend.itemStyle||{}).fontSize||kt,l=this.computeAutoFontSize(r,c),h=t.legend.lineHeight??16,f=t.legend.itemMarginBottom??2,u=t.legend.itemMarginTop??0,d=h+f+u;if(s==="horizontal"){const y=t.legend.padding??4,g=t.legend.symbolWidth??10,m=t.legend.symbolPadding??5,x=t.legend.itemDistance??20,v=this.getSpacing(t),b=t.legend.width||e-v.left-v.right-y*2,k=me(l),M=i.map((P,A)=>P.name||`Series ${A+1}`);let C=0;for(let P=0;P<M.length;P++){const A=t.legend.itemWidth||He(M[P],k),w=g+m+A;C+=w+(P<M.length-1?x:0)}if(r>8&&C>b){let P=0;for(const F of M){const D=He(F,k);D>P&&(P=D)}let A,w;if(t.legend.itemWidth)A=t.legend.itemWidth,w=Math.max(2,Math.floor(b/A));else{const F=g+m+P+8;w=Math.max(1,Math.floor(b/F)),A=b/w}const $=Math.ceil(r/w)*d+y*2,R=t.legend.maxHeight;return(R?Math.min($,R):$)+o}let _=y,T=1;for(let P=0;P<r;P++){const A=t.legend.itemWidth||He(M[P],k),w=g+m+A;P>0&&_+w>b&&(T++,_=y),_+=w+x}const I=T*d+y*2,L=t.legend.maxHeight;return(L?Math.min(I,L):I)+o}return r*d+(t.legend.padding??8)*2+o}estimateAxisWidth(t,e,i,r){var a,c;const o=t.yAxis.filter(l=>e?!l.opposite:l.opposite);if(o.length===0)return 0;let s=0;for(const l of o){if(l.visible===!1)continue;const h=((a=l.labels)==null?void 0:a.enabled)!==!1,f=(c=l.title)==null?void 0:c.text,u=h?this.estimateLabelWidth(l,i,r):0;s+=u+(f?30:0)+(l.offset||0)}return s||30}estimateLabelWidth(t,e,i){var s,a,c,l;if(t.categories&&t.categories.length>0){const h=me(((a=(s=t.labels)==null?void 0:s.style)==null?void 0:a.fontSize)||kt);let f=h;if(e&&t.categories.length>1){const m=e*.8/t.categories.length*.7;h>m&&(f=Math.min(h,Math.max(5,Math.round(m*1.1))))}const u=((l=(c=t.labels)==null?void 0:c.style)==null?void 0:l.fontWeight)||"normal";let d=0;for(const y of t.categories){const g=He(y,f,u);g>d&&(d=g)}const p=i?Math.max(120,i*.3):460;return Math.max(25,Math.min(d*1.3+16,p))}const r=t.min??null,o=t.max??null;if(r!=null&&o!=null){const f=String(Math.round(Math.max(Math.abs(r),Math.abs(o)))).length+(r<0?1:0);return Math.max(20,f*7+10)}return 25}estimateAxisHeight(t){var r,o,s,a,c,l,h;const e=t.xAxis.filter(f=>!f.opposite);if(e.length===0)return 0;let i=0;for(const f of e){if(f.visible===!1)continue;const u=((r=f.labels)==null?void 0:r.enabled)!==!1,d=(o=f.title)==null?void 0:o.text,p=!!((s=f.labels)!=null&&s.rotation);let y=30;if(u){if(p&&f.categories&&f.categories.length>0){let m=0;for(const k of f.categories)k.length>m&&(m=k.length);const x=me(((c=(a=f.labels)==null?void 0:a.style)==null?void 0:c.fontSize)||kt),v=Math.abs(f.labels.rotation)*(Math.PI/180),b=Math.min(m*x*.62*Math.sin(v),150);y=Math.max(30,b)}else if(p)y=45;else if(f.categories&&f.categories.length>0){const m=me(((h=(l=f.labels)==null?void 0:l.style)==null?void 0:h.fontSize)||kt);y=Math.max(m+8,20)}}else y=0;const g=u?f.tickLength||10:5;i+=y+(d?25:0)+g}return i||40}}function _o(n,t){return n==null||t==null?NaN:n<t?-1:n>t?1:n>=t?0:NaN}function Cy(n,t){return n==null||t==null?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function Sa(n){let t,e,i;n.length!==2?(t=_o,e=(a,c)=>_o(n(a),c),i=(a,c)=>n(a)-c):(t=n===_o||n===Cy?n:Py,e=n,i=n);function r(a,c,l=0,h=a.length){if(l<h){if(t(c,c)!==0)return h;do{const f=l+h>>>1;e(a[f],c)<0?l=f+1:h=f}while(l<h)}return l}function o(a,c,l=0,h=a.length){if(l<h){if(t(c,c)!==0)return h;do{const f=l+h>>>1;e(a[f],c)<=0?l=f+1:h=f}while(l<h)}return l}function s(a,c,l=0,h=a.length){const f=r(a,c,l,h-1);return f>l&&i(a[f-1],c)>-i(a[f],c)?f-1:f}return{left:r,center:s,right:o}}function Py(){return 0}function Ey(n){return n===null?NaN:+n}const Ty=Sa(_o).right;Sa(Ey).center;class pi{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let i=0;for(let r=0;r<this._n&&r<32;r++){const o=e[r],s=t+o,a=Math.abs(t)<Math.abs(o)?t-(s-o):o-(s-t);a&&(e[i++]=a),t=s}return e[i]=t,this._n=i+1,this}valueOf(){const t=this._partials;let e=this._n,i,r,o,s=0;if(e>0){for(s=t[--e];e>0&&(i=s,r=t[--e],s=i+r,o=r-(s-i),!o););e>0&&(o<0&&t[e-1]<0||o>0&&t[e-1]>0)&&(r=o*2,i=s+r,r==i-s&&(s=i))}return s}}class Jh extends Map{constructor(t,e=Iy){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(Qh(this,t))}has(t){return super.has(Qh(this,t))}set(t,e){return super.set(Ly(this,t),e)}delete(t){return super.delete($y(this,t))}}function Qh({_intern:n,_key:t},e){const i=t(e);return n.has(i)?n.get(i):e}function Ly({_intern:n,_key:t},e){const i=t(e);return n.has(i)?n.get(i):(n.set(i,e),e)}function $y({_intern:n,_key:t},e){const i=t(e);return n.has(i)&&(e=n.get(i),n.delete(i)),e}function Iy(n){return n!==null&&typeof n=="object"?n.valueOf():n}const Fy=Math.sqrt(50),Ry=Math.sqrt(10),Dy=Math.sqrt(2);function Co(n,t,e){const i=(t-n)/Math.max(0,e),r=Math.floor(Math.log10(i)),o=i/Math.pow(10,r),s=o>=Fy?10:o>=Ry?5:o>=Dy?2:1;let a,c,l;return r<0?(l=Math.pow(10,-r)/s,a=Math.round(n*l),c=Math.round(t*l),a/l<n&&++a,c/l>t&&--c,l=-l):(l=Math.pow(10,r)*s,a=Math.round(n/l),c=Math.round(t/l),a*l<n&&++a,c*l>t&&--c),c<a&&.5<=e&&e<2?Co(n,t,e*2):[a,c,l]}function _a(n,t,e){if(t=+t,n=+n,e=+e,!(e>0))return[];if(n===t)return[n];const i=t<n,[r,o,s]=i?Co(t,n,e):Co(n,t,e);if(!(o>=r))return[];const a=o-r+1,c=new Array(a);if(i)if(s<0)for(let l=0;l<a;++l)c[l]=(o-l)/-s;else for(let l=0;l<a;++l)c[l]=(o-l)*s;else if(s<0)for(let l=0;l<a;++l)c[l]=(r+l)/-s;else for(let l=0;l<a;++l)c[l]=(r+l)*s;return c}function Ca(n,t,e){return t=+t,n=+n,e=+e,Co(n,t,e)[2]}function Pa(n,t,e){t=+t,n=+n,e=+e;const i=t<n,r=i?Ca(t,n,e):Ca(n,t,e);return(i?-1:1)*(r<0?1/-r:r)}function*zy(n){for(const t of n)yield*t}function tu(n){return Array.from(zy(n))}function gi(n,t,e){n=+n,t=+t,e=(r=arguments.length)<2?(t=n,n=0,1):r<3?1:+e;for(var i=-1,r=Math.max(0,Math.ceil((t-n)/e))|0,o=new Array(r);++i<r;)o[i]=n+i*e;return o}function mi(n,t){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(t).domain(n);break}return this}function By(n,t){switch(arguments.length){case 0:break;case 1:{typeof n=="function"?this.interpolator(n):this.range(n);break}default:{this.domain(n),typeof t=="function"?this.interpolator(t):this.range(t);break}}return this}const eu=Symbol("implicit");function nu(){var n=new Jh,t=[],e=[],i=eu;function r(o){let s=n.get(o);if(s===void 0){if(i!==eu)return i;n.set(o,s=t.push(o)-1)}return e[s%e.length]}return r.domain=function(o){if(!arguments.length)return t.slice();t=[],n=new Jh;for(const s of o)n.has(s)||n.set(s,t.push(s)-1);return r},r.range=function(o){return arguments.length?(e=Array.from(o),r):e.slice()},r.unknown=function(o){return arguments.length?(i=o,r):i},r.copy=function(){return nu(t,e).unknown(i)},mi.apply(r,arguments),r}function iu(){var n=nu().unknown(void 0),t=n.domain,e=n.range,i=0,r=1,o,s,a=!1,c=0,l=0,h=.5;delete n.unknown;function f(){var u=t().length,d=r<i,p=d?r:i,y=d?i:r;o=(y-p)/Math.max(1,u-c+l*2),a&&(o=Math.floor(o)),p+=(y-p-o*(u-c))*h,s=o*(1-c),a&&(p=Math.round(p),s=Math.round(s));var g=gi(u).map(function(m){return p+o*m});return e(d?g.reverse():g)}return n.domain=function(u){return arguments.length?(t(u),f()):t()},n.range=function(u){return arguments.length?([i,r]=u,i=+i,r=+r,f()):[i,r]},n.rangeRound=function(u){return[i,r]=u,i=+i,r=+r,a=!0,f()},n.bandwidth=function(){return s},n.step=function(){return o},n.round=function(u){return arguments.length?(a=!!u,f()):a},n.padding=function(u){return arguments.length?(c=Math.min(1,l=+u),f()):c},n.paddingInner=function(u){return arguments.length?(c=Math.min(1,u),f()):c},n.paddingOuter=function(u){return arguments.length?(l=+u,f()):l},n.align=function(u){return arguments.length?(h=Math.max(0,Math.min(1,u)),f()):h},n.copy=function(){return iu(t(),[i,r]).round(a).paddingInner(c).paddingOuter(l).align(h)},mi.apply(f(),arguments)}function Oy(n,t,e,i,r){var o=n*n,s=o*n;return((1-3*n+3*o-s)*t+(4-6*o+3*s)*e+(1+3*n+3*o-3*s)*i+s*r)/6}function Ny(n){var t=n.length-1;return function(e){var i=e<=0?e=0:e>=1?(e=1,t-1):Math.floor(e*t),r=n[i],o=n[i+1],s=i>0?n[i-1]:2*r-o,a=i<t-1?n[i+2]:2*o-r;return Oy((e-i/t)*t,s,r,o,a)}}const Ea=n=>()=>n;function Wy(n,t){return function(e){return n+e*t}}function Hy(n,t,e){return n=Math.pow(n,e),t=Math.pow(t,e)-n,e=1/e,function(i){return Math.pow(n+i*t,e)}}function Vy(n){return(n=+n)==1?ru:function(t,e){return e-t?Hy(t,e,n):Ea(isNaN(t)?e:t)}}function ru(n,t){var e=t-n;return e?Wy(n,e):Ea(isNaN(n)?t:n)}const yi=function n(t){var e=Vy(t);function i(r,o){var s=e((r=je(r)).r,(o=je(o)).r),a=e(r.g,o.g),c=e(r.b,o.b),l=ru(r.opacity,o.opacity);return function(h){return r.r=s(h),r.g=a(h),r.b=c(h),r.opacity=l(h),r+""}}return i.gamma=n,i}(1);function Gy(n){return function(t){var e=t.length,i=new Array(e),r=new Array(e),o=new Array(e),s,a;for(s=0;s<e;++s)a=je(t[s]),i[s]=a.r||0,r[s]=a.g||0,o[s]=a.b||0;return i=n(i),r=n(r),o=n(o),a.opacity=1,function(c){return a.r=i(c),a.g=r(c),a.b=o(c),a+""}}}var Yy=Gy(Ny);function Xy(n,t){t||(t=[]);var e=n?Math.min(t.length,n.length):0,i=t.slice(),r;return function(o){for(r=0;r<e;++r)i[r]=n[r]*(1-o)+t[r]*o;return i}}function Uy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function jy(n,t){var e=t?t.length:0,i=n?Math.min(e,n.length):0,r=new Array(i),o=new Array(e),s;for(s=0;s<i;++s)r[s]=he(n[s],t[s]);for(;s<e;++s)o[s]=t[s];return function(a){for(s=0;s<i;++s)o[s]=r[s](a);return o}}function qy(n,t){var e=new Date;return n=+n,t=+t,function(i){return e.setTime(n*(1-i)+t*i),e}}function yn(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function Zy(n,t){var e={},i={},r;(n===null||typeof n!="object")&&(n={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in n?e[r]=he(n[r],t[r]):i[r]=t[r];return function(o){for(r in e)i[r]=e[r](o);return i}}var Ta=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,La=new RegExp(Ta.source,"g");function Ky(n){return function(){return n}}function Jy(n){return function(t){return n(t)+""}}function ou(n,t){var e=Ta.lastIndex=La.lastIndex=0,i,r,o,s=-1,a=[],c=[];for(n=n+"",t=t+"";(i=Ta.exec(n))&&(r=La.exec(t));)(o=r.index)>e&&(o=t.slice(e,o),a[s]?a[s]+=o:a[++s]=o),(i=i[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:yn(i,r)})),e=La.lastIndex;return e<t.length&&(o=t.slice(e),a[s]?a[s]+=o:a[++s]=o),a.length<2?c[0]?Jy(c[0].x):Ky(t):(t=c.length,function(l){for(var h=0,f;h<t;++h)a[(f=c[h]).i]=f.x(l);return a.join("")})}function he(n,t){var e=typeof t,i;return t==null||e==="boolean"?Ea(t):(e==="number"?yn:e==="string"?(i=ce(t))?(t=i,yi):ou:t instanceof ce?yi:t instanceof Date?qy:Uy(t)?Xy:Array.isArray(t)?jy:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Zy:yn)(n,t)}function su(n,t){return n=+n,t=+t,function(e){return Math.round(n*(1-e)+t*e)}}var au=180/Math.PI,$a={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cu(n,t,e,i,r,o){var s,a,c;return(s=Math.sqrt(n*n+t*t))&&(n/=s,t/=s),(c=n*e+t*i)&&(e-=n*c,i-=t*c),(a=Math.sqrt(e*e+i*i))&&(e/=a,i/=a,c/=a),n*i<t*e&&(n=-n,t=-t,c=-c,s=-s),{translateX:r,translateY:o,rotate:Math.atan2(t,n)*au,skewX:Math.atan(c)*au,scaleX:s,scaleY:a}}var Po;function Qy(n){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return t.isIdentity?$a:cu(t.a,t.b,t.c,t.d,t.e,t.f)}function tx(n){return n==null||(Po||(Po=document.createElementNS("http://www.w3.org/2000/svg","g")),Po.setAttribute("transform",n),!(n=Po.transform.baseVal.consolidate()))?$a:(n=n.matrix,cu(n.a,n.b,n.c,n.d,n.e,n.f))}function lu(n,t,e,i){function r(l){return l.length?l.pop()+" ":""}function o(l,h,f,u,d,p){if(l!==f||h!==u){var y=d.push("translate(",null,t,null,e);p.push({i:y-4,x:yn(l,f)},{i:y-2,x:yn(h,u)})}else(f||u)&&d.push("translate("+f+t+u+e)}function s(l,h,f,u){l!==h?(l-h>180?h+=360:h-l>180&&(l+=360),u.push({i:f.push(r(f)+"rotate(",null,i)-2,x:yn(l,h)})):h&&f.push(r(f)+"rotate("+h+i)}function a(l,h,f,u){l!==h?u.push({i:f.push(r(f)+"skewX(",null,i)-2,x:yn(l,h)}):h&&f.push(r(f)+"skewX("+h+i)}function c(l,h,f,u,d,p){if(l!==f||h!==u){var y=d.push(r(d)+"scale(",null,",",null,")");p.push({i:y-4,x:yn(l,f)},{i:y-2,x:yn(h,u)})}else(f!==1||u!==1)&&d.push(r(d)+"scale("+f+","+u+")")}return function(l,h){var f=[],u=[];return l=n(l),h=n(h),o(l.translateX,l.translateY,h.translateX,h.translateY,f,u),s(l.rotate,h.rotate,f,u),a(l.skewX,h.skewX,f,u),c(l.scaleX,l.scaleY,h.scaleX,h.scaleY,f,u),l=h=null,function(d){for(var p=-1,y=u.length,g;++p<y;)f[(g=u[p]).i]=g.x(d);return f.join("")}}}var ex=lu(Qy,"px, ","px)","deg)"),nx=lu(tx,", ",")",")"),ix=1e-12;function hu(n){return((n=Math.exp(n))+1/n)/2}function rx(n){return((n=Math.exp(n))-1/n)/2}function ox(n){return((n=Math.exp(2*n))-1)/(n+1)}const sx=function n(t,e,i){function r(o,s){var a=o[0],c=o[1],l=o[2],h=s[0],f=s[1],u=s[2],d=h-a,p=f-c,y=d*d+p*p,g,m;if(y<ix)m=Math.log(u/l)/t,g=function(C){return[a+C*d,c+C*p,l*Math.exp(t*C*m)]};else{var x=Math.sqrt(y),v=(u*u-l*l+i*y)/(2*l*e*x),b=(u*u-l*l-i*y)/(2*u*e*x),k=Math.log(Math.sqrt(v*v+1)-v),M=Math.log(Math.sqrt(b*b+1)-b);m=(M-k)/t,g=function(C){var E=C*m,_=hu(k),T=l/(e*x)*(_*ox(t*E+k)-rx(k));return[a+T*d,c+T*p,l*_/hu(t*E+k)]}}return g.duration=m*1e3*t/Math.SQRT2,g}return r.rho=function(o){var s=Math.max(.001,+o),a=s*s,c=a*a;return n(s,a,c)},r}(Math.SQRT2,2,4);function ax(n){return function(){return n}}function cx(n){return+n}var uu=[0,1];function nn(n){return n}function Ia(n,t){return(t-=n=+n)?function(e){return(e-n)/t}:ax(isNaN(t)?NaN:.5)}function lx(n,t){var e;return n>t&&(e=n,n=t,t=e),function(i){return Math.max(n,Math.min(t,i))}}function hx(n,t,e){var i=n[0],r=n[1],o=t[0],s=t[1];return r<i?(i=Ia(r,i),o=e(s,o)):(i=Ia(i,r),o=e(o,s)),function(a){return o(i(a))}}function ux(n,t,e){var i=Math.min(n.length,t.length)-1,r=new Array(i),o=new Array(i),s=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),t=t.slice().reverse());++s<i;)r[s]=Ia(n[s],n[s+1]),o[s]=e(t[s],t[s+1]);return function(a){var c=Ty(n,a,1,i)-1;return o[c](r[c](a))}}function Eo(n,t){return t.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Fa(){var n=uu,t=uu,e=he,i,r,o,s=nn,a,c,l;function h(){var u=Math.min(n.length,t.length);return s!==nn&&(s=lx(n[0],n[u-1])),a=u>2?ux:hx,c=l=null,f}function f(u){return u==null||isNaN(u=+u)?o:(c||(c=a(n.map(i),t,e)))(i(s(u)))}return f.invert=function(u){return s(r((l||(l=a(t,n.map(i),yn)))(u)))},f.domain=function(u){return arguments.length?(n=Array.from(u,cx),h()):n.slice()},f.range=function(u){return arguments.length?(t=Array.from(u),h()):t.slice()},f.rangeRound=function(u){return t=Array.from(u),e=su,h()},f.clamp=function(u){return arguments.length?(s=u?!0:nn,h()):s!==nn},f.interpolate=function(u){return arguments.length?(e=u,h()):e},f.unknown=function(u){return arguments.length?(o=u,f):o},function(u,d){return i=u,r=d,h()}}function fu(){return Fa()(nn,nn)}function fx(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function To(n,t){if(!isFinite(n)||n===0)return null;var e=(n=t?n.toExponential(t-1):n.toExponential()).indexOf("e"),i=n.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+n.slice(e+1)]}function Ri(n){return n=To(Math.abs(n)),n?n[1]:NaN}function dx(n,t){return function(e,i){for(var r=e.length,o=[],s=0,a=n[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),o.push(e.substring(r-=a,r+a)),!((c+=a+1)>i));)a=n[s=(s+1)%n.length];return o.reverse().join(t)}}function px(n){return function(t){return t.replace(/[0-9]/g,function(e){return n[+e]})}}var gx=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function pr(n){if(!(t=gx.exec(n)))throw new Error("invalid format: "+n);var t;return new Ra({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}pr.prototype=Ra.prototype;function Ra(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Ra.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function mx(n){t:for(var t=n.length,e=1,i=-1,r;e<t;++e)switch(n[e]){case".":i=r=e;break;case"0":i===0&&(i=e),r=e;break;default:if(!+n[e])break t;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var Lo;function yx(n,t){var e=To(n,t);if(!e)return Lo=void 0,n.toPrecision(t);var i=e[0],r=e[1],o=r-(Lo=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+To(n,Math.max(0,t+o-1))[0]}function du(n,t){var e=To(n,t);if(!e)return n+"";var i=e[0],r=e[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const pu={"%":(n,t)=>(n*100).toFixed(t),b:n=>Math.round(n).toString(2),c:n=>n+"",d:fx,e:(n,t)=>n.toExponential(t),f:(n,t)=>n.toFixed(t),g:(n,t)=>n.toPrecision(t),o:n=>Math.round(n).toString(8),p:(n,t)=>du(n*100,t),r:du,s:yx,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function gu(n){return n}var mu=Array.prototype.map,yu=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function xx(n){var t=n.grouping===void 0||n.thousands===void 0?gu:dx(mu.call(n.grouping,Number),n.thousands+""),e=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",o=n.numerals===void 0?gu:px(mu.call(n.numerals,String)),s=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",c=n.nan===void 0?"NaN":n.nan+"";function l(f,u){f=pr(f);var d=f.fill,p=f.align,y=f.sign,g=f.symbol,m=f.zero,x=f.width,v=f.comma,b=f.precision,k=f.trim,M=f.type;M==="n"?(v=!0,M="g"):pu[M]||(b===void 0&&(b=12),k=!0,M="g"),(m||d==="0"&&p==="=")&&(m=!0,d="0",p="=");var C=(u&&u.prefix!==void 0?u.prefix:"")+(g==="$"?e:g==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():""),E=(g==="$"?i:/[%p]/.test(M)?s:"")+(u&&u.suffix!==void 0?u.suffix:""),_=pu[M],T=/[defgprs%]/.test(M);b=b===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function I(L){var P=C,A=E,w,S,$;if(M==="c")A=_(L)+A,L="";else{L=+L;var R=L<0||1/L<0;if(L=isNaN(L)?c:_(Math.abs(L),b),k&&(L=mx(L)),R&&+L==0&&y!=="+"&&(R=!1),P=(R?y==="("?y:a:y==="-"||y==="("?"":y)+P,A=(M==="s"&&!isNaN(L)&&Lo!==void 0?yu[8+Lo/3]:"")+A+(R&&y==="("?")":""),T){for(w=-1,S=L.length;++w<S;)if($=L.charCodeAt(w),48>$||$>57){A=($===46?r+L.slice(w+1):L.slice(w))+A,L=L.slice(0,w);break}}}v&&!m&&(L=t(L,1/0));var F=P.length+L.length+A.length,D=F<x?new Array(x-F+1).join(d):"";switch(v&&m&&(L=t(D+L,D.length?x-A.length:1/0),D=""),p){case"<":L=P+L+A+D;break;case"=":L=P+D+L+A;break;case"^":L=D.slice(0,F=D.length>>1)+P+L+A+D.slice(F);break;default:L=D+P+L+A;break}return o(L)}return I.toString=function(){return f+""},I}function h(f,u){var d=Math.max(-8,Math.min(8,Math.floor(Ri(u)/3)))*3,p=Math.pow(10,-d),y=l((f=pr(f),f.type="f",f),{suffix:yu[8+d/3]});return function(g){return y(p*g)}}return{format:l,formatPrefix:h}}var $o,gr,xu;bx({thousands:",",grouping:[3],currency:["$",""]});function bx(n){return $o=xx(n),gr=$o.format,xu=$o.formatPrefix,$o}function vx(n){return Math.max(0,-Ri(Math.abs(n)))}function wx(n,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Ri(t)/3)))*3-Ri(Math.abs(n)))}function kx(n,t){return n=Math.abs(n),t=Math.abs(t)-n,Math.max(0,Ri(t)-Ri(n))+1}function Mx(n,t,e,i){var r=Pa(n,t,e),o;switch(i=pr(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(n),Math.abs(t));return i.precision==null&&!isNaN(o=wx(r,s))&&(i.precision=o),xu(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(o=kx(r,Math.max(Math.abs(n),Math.abs(t))))&&(i.precision=o-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(o=vx(r))&&(i.precision=o-(i.type==="%")*2);break}}return gr(i)}function Da(n){var t=n.domain;return n.ticks=function(e){var i=t();return _a(i[0],i[i.length-1],e??10)},n.tickFormat=function(e,i){var r=t();return Mx(r[0],r[r.length-1],e??10,i)},n.nice=function(e){e==null&&(e=10);var i=t(),r=0,o=i.length-1,s=i[r],a=i[o],c,l,h=10;for(a<s&&(l=s,s=a,a=l,l=r,r=o,o=l);h-- >0;){if(l=Ca(s,a,e),l===c)return i[r]=s,i[o]=a,t(i);if(l>0)s=Math.floor(s/l)*l,a=Math.ceil(a/l)*l;else if(l<0)s=Math.ceil(s*l)/l,a=Math.floor(a*l)/l;else break;c=l}return n},n}function ke(){var n=fu();return n.copy=function(){return Eo(n,ke())},mi.apply(n,arguments),Da(n)}function bu(n,t){n=n.slice();var e=0,i=n.length-1,r=n[e],o=n[i],s;return o<r&&(s=e,e=i,i=s,s=r,r=o,o=s),n[e]=t.floor(r),n[i]=t.ceil(o),n}function vu(n){return Math.log(n)}function wu(n){return Math.exp(n)}function Ax(n){return-Math.log(-n)}function Sx(n){return-Math.exp(-n)}function _x(n){return isFinite(n)?+("1e"+n):n<0?0:n}function Cx(n){return n===10?_x:n===Math.E?Math.exp:t=>Math.pow(n,t)}function Px(n){return n===Math.E?Math.log:n===10&&Math.log10||n===2&&Math.log2||(n=Math.log(n),t=>Math.log(t)/n)}function ku(n){return(t,e)=>-n(-t,e)}function Ex(n){const t=n(vu,wu),e=t.domain;let i=10,r,o;function s(){return r=Px(i),o=Cx(i),e()[0]<0?(r=ku(r),o=ku(o),n(Ax,Sx)):n(vu,wu),t}return t.base=function(a){return arguments.length?(i=+a,s()):i},t.domain=function(a){return arguments.length?(e(a),s()):e()},t.ticks=a=>{const c=e();let l=c[0],h=c[c.length-1];const f=h<l;f&&([l,h]=[h,l]);let u=r(l),d=r(h),p,y;const g=a==null?10:+a;let m=[];if(!(i%1)&&d-u<g){if(u=Math.floor(u),d=Math.ceil(d),l>0){for(;u<=d;++u)for(p=1;p<i;++p)if(y=u<0?p/o(-u):p*o(u),!(y<l)){if(y>h)break;m.push(y)}}else for(;u<=d;++u)for(p=i-1;p>=1;--p)if(y=u>0?p/o(-u):p*o(u),!(y<l)){if(y>h)break;m.push(y)}m.length*2<g&&(m=_a(l,h,g))}else m=_a(u,d,Math.min(d-u,g)).map(o);return f?m.reverse():m},t.tickFormat=(a,c)=>{if(a==null&&(a=10),c==null&&(c=i===10?"s":","),typeof c!="function"&&(!(i%1)&&(c=pr(c)).precision==null&&(c.trim=!0),c=gr(c)),a===1/0)return c;const l=Math.max(1,i*a/t.ticks().length);return h=>{let f=h/o(Math.round(r(h)));return f*i<i-.5&&(f*=i),f<=l?c(h):""}},t.nice=()=>e(bu(e(),{floor:a=>o(Math.floor(r(a))),ceil:a=>o(Math.ceil(r(a)))})),t}function Io(){const n=Ex(Fa()).domain([1,10]);return n.copy=()=>Eo(n,Io()).base(n.base()),mi.apply(n,arguments),n}function Mu(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function Tx(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function Lx(n){return n<0?-n*n:n*n}function $x(n){var t=n(nn,nn),e=1;function i(){return e===1?n(nn,nn):e===.5?n(Tx,Lx):n(Mu(e),Mu(1/e))}return t.exponent=function(r){return arguments.length?(e=+r,i()):e},Da(t)}function Au(){var n=$x(Fa());return n.copy=function(){return Eo(n,Au()).exponent(n.exponent())},mi.apply(n,arguments),n}function Ix(){return Au.apply(null,arguments).exponent(.5)}const za=new Date,Ba=new Date;function ue(n,t,e,i){function r(o){return n(o=arguments.length===0?new Date:new Date(+o)),o}return r.floor=o=>(n(o=new Date(+o)),o),r.ceil=o=>(n(o=new Date(o-1)),t(o,1),n(o),o),r.round=o=>{const s=r(o),a=r.ceil(o);return o-s<a-o?s:a},r.offset=(o,s)=>(t(o=new Date(+o),s==null?1:Math.floor(s)),o),r.range=(o,s,a)=>{const c=[];if(o=r.ceil(o),a=a==null?1:Math.floor(a),!(o<s)||!(a>0))return c;let l;do c.push(l=new Date(+o)),t(o,a),n(o);while(l<o&&o<s);return c},r.filter=o=>ue(s=>{if(s>=s)for(;n(s),!o(s);)s.setTime(s-1)},(s,a)=>{if(s>=s)if(a<0)for(;++a<=0;)for(;t(s,-1),!o(s););else for(;--a>=0;)for(;t(s,1),!o(s););}),e&&(r.count=(o,s)=>(za.setTime(+o),Ba.setTime(+s),n(za),n(Ba),Math.floor(e(za,Ba))),r.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?r.filter(i?s=>i(s)%o===0:s=>r.count(0,s)%o===0):r)),r}const Fo=ue(()=>{},(n,t)=>{n.setTime(+n+t)},(n,t)=>t-n);Fo.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?ue(t=>{t.setTime(Math.floor(t/n)*n)},(t,e)=>{t.setTime(+t+e*n)},(t,e)=>(e-t)/n):Fo),Fo.range;const In=1e3,rn=In*60,Fn=rn*60,Rn=Fn*24,Oa=Rn*7,Su=Rn*30,Na=Rn*365,xi=ue(n=>{n.setTime(n-n.getMilliseconds())},(n,t)=>{n.setTime(+n+t*In)},(n,t)=>(t-n)/In,n=>n.getUTCSeconds());xi.range;const Wa=ue(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*In)},(n,t)=>{n.setTime(+n+t*rn)},(n,t)=>(t-n)/rn,n=>n.getMinutes());Wa.range;const Ha=ue(n=>{n.setUTCSeconds(0,0)},(n,t)=>{n.setTime(+n+t*rn)},(n,t)=>(t-n)/rn,n=>n.getUTCMinutes());Ha.range;const Va=ue(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*In-n.getMinutes()*rn)},(n,t)=>{n.setTime(+n+t*Fn)},(n,t)=>(t-n)/Fn,n=>n.getHours());Va.range;const Ga=ue(n=>{n.setUTCMinutes(0,0,0)},(n,t)=>{n.setTime(+n+t*Fn)},(n,t)=>(t-n)/Fn,n=>n.getUTCHours());Ga.range;const mr=ue(n=>n.setHours(0,0,0,0),(n,t)=>n.setDate(n.getDate()+t),(n,t)=>(t-n-(t.getTimezoneOffset()-n.getTimezoneOffset())*rn)/Rn,n=>n.getDate()-1);mr.range;const Ro=ue(n=>{n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCDate(n.getUTCDate()+t)},(n,t)=>(t-n)/Rn,n=>n.getUTCDate()-1);Ro.range;const _u=ue(n=>{n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCDate(n.getUTCDate()+t)},(n,t)=>(t-n)/Rn,n=>Math.floor(n/Rn));_u.range;function bi(n){return ue(t=>{t.setDate(t.getDate()-(t.getDay()+7-n)%7),t.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+e*7)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*rn)/Oa)}const Do=bi(0),zo=bi(1),Fx=bi(2),Rx=bi(3),Di=bi(4),Dx=bi(5),zx=bi(6);Do.range,zo.range,Fx.range,Rx.range,Di.range,Dx.range,zx.range;function vi(n){return ue(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-n)%7),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e*7)},(t,e)=>(e-t)/Oa)}const Bo=vi(0),Oo=vi(1),Bx=vi(2),Ox=vi(3),zi=vi(4),Nx=vi(5),Wx=vi(6);Bo.range,Oo.range,Bx.range,Ox.range,zi.range,Nx.range,Wx.range;const Ya=ue(n=>{n.setDate(1),n.setHours(0,0,0,0)},(n,t)=>{n.setMonth(n.getMonth()+t)},(n,t)=>t.getMonth()-n.getMonth()+(t.getFullYear()-n.getFullYear())*12,n=>n.getMonth());Ya.range;const Xa=ue(n=>{n.setUTCDate(1),n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCMonth(n.getUTCMonth()+t)},(n,t)=>t.getUTCMonth()-n.getUTCMonth()+(t.getUTCFullYear()-n.getUTCFullYear())*12,n=>n.getUTCMonth());Xa.range;const Dn=ue(n=>{n.setMonth(0,1),n.setHours(0,0,0,0)},(n,t)=>{n.setFullYear(n.getFullYear()+t)},(n,t)=>t.getFullYear()-n.getFullYear(),n=>n.getFullYear());Dn.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:ue(t=>{t.setFullYear(Math.floor(t.getFullYear()/n)*n),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e*n)}),Dn.range;const zn=ue(n=>{n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCFullYear(n.getUTCFullYear()+t)},(n,t)=>t.getUTCFullYear()-n.getUTCFullYear(),n=>n.getUTCFullYear());zn.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:ue(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/n)*n),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e*n)}),zn.range;function Cu(n,t,e,i,r,o){const s=[[xi,1,In],[xi,5,5*In],[xi,15,15*In],[xi,30,30*In],[o,1,rn],[o,5,5*rn],[o,15,15*rn],[o,30,30*rn],[r,1,Fn],[r,3,3*Fn],[r,6,6*Fn],[r,12,12*Fn],[i,1,Rn],[i,2,2*Rn],[e,1,Oa],[t,1,Su],[t,3,3*Su],[n,1,Na]];function a(l,h,f){const u=h<l;u&&([l,h]=[h,l]);const d=f&&typeof f.range=="function"?f:c(l,h,f),p=d?d.range(l,+h+1):[];return u?p.reverse():p}function c(l,h,f){const u=Math.abs(h-l)/f,d=Sa(([,,g])=>g).right(s,u);if(d===s.length)return n.every(Pa(l/Na,h/Na,f));if(d===0)return Fo.every(Math.max(Pa(l,h,f),1));const[p,y]=s[u/s[d-1][2]<s[d][2]/u?d-1:d];return p.every(y)}return[a,c]}const[Hx,Vx]=Cu(zn,Xa,Bo,_u,Ga,Ha),[Gx,Yx]=Cu(Dn,Ya,Do,mr,Va,Wa);function Ua(n){if(0<=n.y&&n.y<100){var t=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return t.setFullYear(n.y),t}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function ja(n){if(0<=n.y&&n.y<100){var t=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return t.setUTCFullYear(n.y),t}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function yr(n,t,e){return{y:n,m:t,d:e,H:0,M:0,S:0,L:0}}function Xx(n){var t=n.dateTime,e=n.date,i=n.time,r=n.periods,o=n.days,s=n.shortDays,a=n.months,c=n.shortMonths,l=xr(r),h=br(r),f=xr(o),u=br(o),d=xr(s),p=br(s),y=xr(a),g=br(a),m=xr(c),x=br(c),v={a:$,A:R,b:F,B:D,c:null,d:Iu,e:Iu,f:gb,g:Sb,G:Cb,H:fb,I:db,j:pb,L:Fu,m:mb,M:yb,p:z,q:B,Q:Nu,s:Wu,S:xb,u:bb,U:vb,V:wb,w:kb,W:Mb,x:null,X:null,y:Ab,Y:_b,Z:Pb,"%":Ou},b={a:W,A:K,b:X,B:q,c:null,d:Du,e:Du,f:$b,g:Hb,G:Gb,H:Eb,I:Tb,j:Lb,L:zu,m:Ib,M:Fb,p:N,q:H,Q:Nu,s:Wu,S:Rb,u:Db,U:zb,V:Bb,w:Ob,W:Nb,x:null,X:null,y:Wb,Y:Vb,Z:Yb,"%":Ou},k={a:T,A:I,b:L,B:P,c:A,d:Lu,e:Lu,f:cb,g:Tu,G:Eu,H:$u,I:$u,j:rb,L:ab,m:ib,M:ob,p:_,q:nb,Q:hb,s:ub,S:sb,u:Kx,U:Jx,V:Qx,w:Zx,W:tb,x:w,X:S,y:Tu,Y:Eu,Z:eb,"%":lb};v.x=M(e,v),v.X=M(i,v),v.c=M(t,v),b.x=M(e,b),b.X=M(i,b),b.c=M(t,b);function M(Y,G){return function(Q){var O=[],it=-1,et=0,ht=Y.length,ft,ct,nt;for(Q instanceof Date||(Q=new Date(+Q));++it<ht;)Y.charCodeAt(it)===37&&(O.push(Y.slice(et,it)),(ct=Pu[ft=Y.charAt(++it)])!=null?ft=Y.charAt(++it):ct=ft==="e"?" ":"0",(nt=G[ft])&&(ft=nt(Q,ct)),O.push(ft),et=it+1);return O.push(Y.slice(et,it)),O.join("")}}function C(Y,G){return function(Q){var O=yr(1900,void 0,1),it=E(O,Y,Q+="",0),et,ht;if(it!=Q.length)return null;if("Q"in O)return new Date(O.Q);if("s"in O)return new Date(O.s*1e3+("L"in O?O.L:0));if(G&&!("Z"in O)&&(O.Z=0),"p"in O&&(O.H=O.H%12+O.p*12),O.m===void 0&&(O.m="q"in O?O.q:0),"V"in O){if(O.V<1||O.V>53)return null;"w"in O||(O.w=1),"Z"in O?(et=ja(yr(O.y,0,1)),ht=et.getUTCDay(),et=ht>4||ht===0?Oo.ceil(et):Oo(et),et=Ro.offset(et,(O.V-1)*7),O.y=et.getUTCFullYear(),O.m=et.getUTCMonth(),O.d=et.getUTCDate()+(O.w+6)%7):(et=Ua(yr(O.y,0,1)),ht=et.getDay(),et=ht>4||ht===0?zo.ceil(et):zo(et),et=mr.offset(et,(O.V-1)*7),O.y=et.getFullYear(),O.m=et.getMonth(),O.d=et.getDate()+(O.w+6)%7)}else("W"in O||"U"in O)&&("w"in O||(O.w="u"in O?O.u%7:"W"in O?1:0),ht="Z"in O?ja(yr(O.y,0,1)).getUTCDay():Ua(yr(O.y,0,1)).getDay(),O.m=0,O.d="W"in O?(O.w+6)%7+O.W*7-(ht+5)%7:O.w+O.U*7-(ht+6)%7);return"Z"in O?(O.H+=O.Z/100|0,O.M+=O.Z%100,ja(O)):Ua(O)}}function E(Y,G,Q,O){for(var it=0,et=G.length,ht=Q.length,ft,ct;it<et;){if(O>=ht)return-1;if(ft=G.charCodeAt(it++),ft===37){if(ft=G.charAt(it++),ct=k[ft in Pu?G.charAt(it++):ft],!ct||(O=ct(Y,Q,O))<0)return-1}else if(ft!=Q.charCodeAt(O++))return-1}return O}function _(Y,G,Q){var O=l.exec(G.slice(Q));return O?(Y.p=h.get(O[0].toLowerCase()),Q+O[0].length):-1}function T(Y,G,Q){var O=d.exec(G.slice(Q));return O?(Y.w=p.get(O[0].toLowerCase()),Q+O[0].length):-1}function I(Y,G,Q){var O=f.exec(G.slice(Q));return O?(Y.w=u.get(O[0].toLowerCase()),Q+O[0].length):-1}function L(Y,G,Q){var O=m.exec(G.slice(Q));return O?(Y.m=x.get(O[0].toLowerCase()),Q+O[0].length):-1}function P(Y,G,Q){var O=y.exec(G.slice(Q));return O?(Y.m=g.get(O[0].toLowerCase()),Q+O[0].length):-1}function A(Y,G,Q){return E(Y,t,G,Q)}function w(Y,G,Q){return E(Y,e,G,Q)}function S(Y,G,Q){return E(Y,i,G,Q)}function $(Y){return s[Y.getDay()]}function R(Y){return o[Y.getDay()]}function F(Y){return c[Y.getMonth()]}function D(Y){return a[Y.getMonth()]}function z(Y){return r[+(Y.getHours()>=12)]}function B(Y){return 1+~~(Y.getMonth()/3)}function W(Y){return s[Y.getUTCDay()]}function K(Y){return o[Y.getUTCDay()]}function X(Y){return c[Y.getUTCMonth()]}function q(Y){return a[Y.getUTCMonth()]}function N(Y){return r[+(Y.getUTCHours()>=12)]}function H(Y){return 1+~~(Y.getUTCMonth()/3)}return{format:function(Y){var G=M(Y+="",v);return G.toString=function(){return Y},G},parse:function(Y){var G=C(Y+="",!1);return G.toString=function(){return Y},G},utcFormat:function(Y){var G=M(Y+="",b);return G.toString=function(){return Y},G},utcParse:function(Y){var G=C(Y+="",!0);return G.toString=function(){return Y},G}}}var Pu={"-":"",_:" ",0:"0"},pe=/^\s*\d+/,Ux=/^%/,jx=/[\\^$*+?|[\]().{}]/g;function Gt(n,t,e){var i=n<0?"-":"",r=(i?-n:n)+"",o=r.length;return i+(o<e?new Array(e-o+1).join(t)+r:r)}function qx(n){return n.replace(jx,"\\$&")}function xr(n){return new RegExp("^(?:"+n.map(qx).join("|")+")","i")}function br(n){return new Map(n.map((t,e)=>[t.toLowerCase(),e]))}function Zx(n,t,e){var i=pe.exec(t.slice(e,e+1));return i?(n.w=+i[0],e+i[0].length):-1}function Kx(n,t,e){var i=pe.exec(t.slice(e,e+1));return i?(n.u=+i[0],e+i[0].length):-1}function Jx(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.U=+i[0],e+i[0].length):-1}function Qx(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.V=+i[0],e+i[0].length):-1}function tb(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.W=+i[0],e+i[0].length):-1}function Eu(n,t,e){var i=pe.exec(t.slice(e,e+4));return i?(n.y=+i[0],e+i[0].length):-1}function Tu(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.y=+i[0]+(+i[0]>68?1900:2e3),e+i[0].length):-1}function eb(n,t,e){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(e,e+6));return i?(n.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function nb(n,t,e){var i=pe.exec(t.slice(e,e+1));return i?(n.q=i[0]*3-3,e+i[0].length):-1}function ib(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.m=i[0]-1,e+i[0].length):-1}function Lu(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.d=+i[0],e+i[0].length):-1}function rb(n,t,e){var i=pe.exec(t.slice(e,e+3));return i?(n.m=0,n.d=+i[0],e+i[0].length):-1}function $u(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.H=+i[0],e+i[0].length):-1}function ob(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.M=+i[0],e+i[0].length):-1}function sb(n,t,e){var i=pe.exec(t.slice(e,e+2));return i?(n.S=+i[0],e+i[0].length):-1}function ab(n,t,e){var i=pe.exec(t.slice(e,e+3));return i?(n.L=+i[0],e+i[0].length):-1}function cb(n,t,e){var i=pe.exec(t.slice(e,e+6));return i?(n.L=Math.floor(i[0]/1e3),e+i[0].length):-1}function lb(n,t,e){var i=Ux.exec(t.slice(e,e+1));return i?e+i[0].length:-1}function hb(n,t,e){var i=pe.exec(t.slice(e));return i?(n.Q=+i[0],e+i[0].length):-1}function ub(n,t,e){var i=pe.exec(t.slice(e));return i?(n.s=+i[0],e+i[0].length):-1}function Iu(n,t){return Gt(n.getDate(),t,2)}function fb(n,t){return Gt(n.getHours(),t,2)}function db(n,t){return Gt(n.getHours()%12||12,t,2)}function pb(n,t){return Gt(1+mr.count(Dn(n),n),t,3)}function Fu(n,t){return Gt(n.getMilliseconds(),t,3)}function gb(n,t){return Fu(n,t)+"000"}function mb(n,t){return Gt(n.getMonth()+1,t,2)}function yb(n,t){return Gt(n.getMinutes(),t,2)}function xb(n,t){return Gt(n.getSeconds(),t,2)}function bb(n){var t=n.getDay();return t===0?7:t}function vb(n,t){return Gt(Do.count(Dn(n)-1,n),t,2)}function Ru(n){var t=n.getDay();return t>=4||t===0?Di(n):Di.ceil(n)}function wb(n,t){return n=Ru(n),Gt(Di.count(Dn(n),n)+(Dn(n).getDay()===4),t,2)}function kb(n){return n.getDay()}function Mb(n,t){return Gt(zo.count(Dn(n)-1,n),t,2)}function Ab(n,t){return Gt(n.getFullYear()%100,t,2)}function Sb(n,t){return n=Ru(n),Gt(n.getFullYear()%100,t,2)}function _b(n,t){return Gt(n.getFullYear()%1e4,t,4)}function Cb(n,t){var e=n.getDay();return n=e>=4||e===0?Di(n):Di.ceil(n),Gt(n.getFullYear()%1e4,t,4)}function Pb(n){var t=n.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Gt(t/60|0,"0",2)+Gt(t%60,"0",2)}function Du(n,t){return Gt(n.getUTCDate(),t,2)}function Eb(n,t){return Gt(n.getUTCHours(),t,2)}function Tb(n,t){return Gt(n.getUTCHours()%12||12,t,2)}function Lb(n,t){return Gt(1+Ro.count(zn(n),n),t,3)}function zu(n,t){return Gt(n.getUTCMilliseconds(),t,3)}function $b(n,t){return zu(n,t)+"000"}function Ib(n,t){return Gt(n.getUTCMonth()+1,t,2)}function Fb(n,t){return Gt(n.getUTCMinutes(),t,2)}function Rb(n,t){return Gt(n.getUTCSeconds(),t,2)}function Db(n){var t=n.getUTCDay();return t===0?7:t}function zb(n,t){return Gt(Bo.count(zn(n)-1,n),t,2)}function Bu(n){var t=n.getUTCDay();return t>=4||t===0?zi(n):zi.ceil(n)}function Bb(n,t){return n=Bu(n),Gt(zi.count(zn(n),n)+(zn(n).getUTCDay()===4),t,2)}function Ob(n){return n.getUTCDay()}function Nb(n,t){return Gt(Oo.count(zn(n)-1,n),t,2)}function Wb(n,t){return Gt(n.getUTCFullYear()%100,t,2)}function Hb(n,t){return n=Bu(n),Gt(n.getUTCFullYear()%100,t,2)}function Vb(n,t){return Gt(n.getUTCFullYear()%1e4,t,4)}function Gb(n,t){var e=n.getUTCDay();return n=e>=4||e===0?zi(n):zi.ceil(n),Gt(n.getUTCFullYear()%1e4,t,4)}function Yb(){return"+0000"}function Ou(){return"%"}function Nu(n){return+n}function Wu(n){return Math.floor(+n/1e3)}var Bi,No,Wo;Xb({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Xb(n){return Bi=Xx(n),No=Bi.format,Bi.parse,Wo=Bi.utcFormat,Bi.utcParse,Bi}function Ub(n){return new Date(n)}function jb(n){return n instanceof Date?+n:+new Date(+n)}function qa(n,t,e,i,r,o,s,a,c,l){var h=fu(),f=h.invert,u=h.domain,d=l(".%L"),p=l(":%S"),y=l("%I:%M"),g=l("%I %p"),m=l("%a %d"),x=l("%b %d"),v=l("%B"),b=l("%Y");function k(M){return(c(M)<M?d:a(M)<M?p:s(M)<M?y:o(M)<M?g:i(M)<M?r(M)<M?m:x:e(M)<M?v:b)(M)}return h.invert=function(M){return new Date(f(M))},h.domain=function(M){return arguments.length?u(Array.from(M,jb)):u().map(Ub)},h.ticks=function(M){var C=u();return n(C[0],C[C.length-1],M??10)},h.tickFormat=function(M,C){return C==null?k:l(C)},h.nice=function(M){var C=u();return(!M||typeof M.range!="function")&&(M=t(C[0],C[C.length-1],M??10)),M?u(bu(C,M)):h},h.copy=function(){return Eo(h,qa(n,t,e,i,r,o,s,a,c,l))},h}function qb(){return mi.apply(qa(Gx,Yx,Dn,Ya,Do,mr,Va,Wa,xi,No).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Zb(){return mi.apply(qa(Hx,Vx,zn,Xa,Bo,Ro,Ga,Ha,xi,Wo).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Kb(){var n=0,t=1,e,i,r,o,s=nn,a=!1,c;function l(f){return f==null||isNaN(f=+f)?c:s(r===0?.5:(f=(o(f)-e)*r,a?Math.max(0,Math.min(1,f)):f))}l.domain=function(f){return arguments.length?([n,t]=f,e=o(n=+n),i=o(t=+t),r=e===i?0:1/(i-e),l):[n,t]},l.clamp=function(f){return arguments.length?(a=!!f,l):a},l.interpolator=function(f){return arguments.length?(s=f,l):s};function h(f){return function(u){var d,p;return arguments.length?([d,p]=u,s=f(d,p),l):[s(0),s(1)]}}return l.range=h(he),l.rangeRound=h(su),l.unknown=function(f){return arguments.length?(c=f,l):c},function(f){return o=f,e=f(n),i=f(t),r=e===i?0:1/(i-e),l}}function Jb(n,t){return t.domain(n.domain()).interpolator(n.interpolator()).clamp(n.clamp()).unknown(n.unknown())}function Hu(){var n=Da(Kb()(nn));return n.copy=function(){return Jb(n,Hu())},By.apply(n,arguments)}function Qb(n){return n}var Ho=1,Vo=2,Za=3,vr=4,Vu=1e-6;function t1(n){return"translate("+n+",0)"}function e1(n){return"translate(0,"+n+")"}function n1(n){return t=>+n(t)}function i1(n,t){return t=Math.max(0,n.bandwidth()-t*2)/2,n.round()&&(t=Math.round(t)),e=>+n(e)+t}function r1(){return!this.__axis}function Go(n,t){var e=[],i=null,r=null,o=6,s=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,l=n===Ho||n===vr?-1:1,h=n===vr||n===Vo?"x":"y",f=n===Ho||n===Za?t1:e1;function u(d){var p=i??(t.ticks?t.ticks.apply(t,e):t.domain()),y=r??(t.tickFormat?t.tickFormat.apply(t,e):Qb),g=Math.max(o,0)+a,m=t.range(),x=+m[0]+c,v=+m[m.length-1]+c,b=(t.bandwidth?i1:n1)(t.copy(),c),k=d.selection?d.selection():d,M=k.selectAll(".domain").data([null]),C=k.selectAll(".tick").data(p,t).order(),E=C.exit(),_=C.enter().append("g").attr("class","tick"),T=C.select("line"),I=C.select("text");M=M.merge(M.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),C=C.merge(_),T=T.merge(_.append("line").attr("stroke","currentColor").attr(h+"2",l*o)),I=I.merge(_.append("text").attr("fill","currentColor").attr(h,l*g).attr("dy",n===Ho?"0em":n===Za?"0.71em":"0.32em")),d!==k&&(M=M.transition(d),C=C.transition(d),T=T.transition(d),I=I.transition(d),E=E.transition(d).attr("opacity",Vu).attr("transform",function(L){return isFinite(L=b(L))?f(L+c):this.getAttribute("transform")}),_.attr("opacity",Vu).attr("transform",function(L){var P=this.parentNode.__axis;return f((P&&isFinite(P=P(L))?P:b(L))+c)})),E.remove(),M.attr("d",n===vr||n===Vo?s?"M"+l*s+","+x+"H"+c+"V"+v+"H"+l*s:"M"+c+","+x+"V"+v:s?"M"+x+","+l*s+"V"+c+"H"+v+"V"+l*s:"M"+x+","+c+"H"+v),C.attr("opacity",1).attr("transform",function(L){return f(b(L)+c)}),T.attr(h+"2",l*o),I.attr(h,l*g).text(y),k.filter(r1).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",n===Vo?"start":n===vr?"end":"middle"),k.each(function(){this.__axis=b})}return u.scale=function(d){return arguments.length?(t=d,u):t},u.ticks=function(){return e=Array.from(arguments),u},u.tickArguments=function(d){return arguments.length?(e=d==null?[]:Array.from(d),u):e.slice()},u.tickValues=function(d){return arguments.length?(i=d==null?null:Array.from(d),u):i&&i.slice()},u.tickFormat=function(d){return arguments.length?(r=d,u):r},u.tickSize=function(d){return arguments.length?(o=s=+d,u):o},u.tickSizeInner=function(d){return arguments.length?(o=+d,u):o},u.tickSizeOuter=function(d){return arguments.length?(s=+d,u):s},u.tickPadding=function(d){return arguments.length?(a=+d,u):a},u.offset=function(d){return arguments.length?(c=+d,u):c},u}function Ka(n){return Go(Ho,n)}function Gu(n){return Go(Vo,n)}function Yu(n){return Go(Za,n)}function Xu(n){return Go(vr,n)}var o1={value:()=>{}};function Oi(){for(var n=0,t=arguments.length,e={},i;n<t;++n){if(!(i=arguments[n]+"")||i in e||/[\s.]/.test(i))throw new Error("illegal type: "+i);e[i]=[]}return new Yo(e)}function Yo(n){this._=n}function s1(n,t){return n.trim().split(/^|\s+/).map(function(e){var i="",r=e.indexOf(".");if(r>=0&&(i=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:i}})}Yo.prototype=Oi.prototype={constructor:Yo,on:function(n,t){var e=this._,i=s1(n+"",e),r,o=-1,s=i.length;if(arguments.length<2){for(;++o<s;)if((r=(n=i[o]).type)&&(r=a1(e[r],n.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(r=(n=i[o]).type)e[r]=Uu(e[r],n.name,t);else if(t==null)for(r in e)e[r]=Uu(e[r],n.name,null);return this},copy:function(){var n={},t=this._;for(var e in t)n[e]=t[e].slice();return new Yo(n)},call:function(n,t){if((r=arguments.length-2)>0)for(var e=new Array(r),i=0,r,o;i<r;++i)e[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(o=this._[n],i=0,r=o.length;i<r;++i)o[i].value.apply(t,e)},apply:function(n,t,e){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,o=i.length;r<o;++r)i[r].value.apply(t,e)}};function a1(n,t){for(var e=0,i=n.length,r;e<i;++e)if((r=n[e]).name===t)return r.value}function Uu(n,t,e){for(var i=0,r=n.length;i<r;++i)if(n[i].name===t){n[i]=o1,n=n.slice(0,i).concat(n.slice(i+1));break}return e!=null&&n.push({name:t,value:e}),n}var Ni=0,wr=0,kr=0,ju=1e3,Xo,Mr,Uo=0,wi=0,jo=0,Ar=typeof performance=="object"&&performance.now?performance:Date,qu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Ja(){return wi||(qu(c1),wi=Ar.now()+jo)}function c1(){wi=0}function qo(){this._call=this._time=this._next=null}qo.prototype=Zo.prototype={constructor:qo,restart:function(n,t,e){if(typeof n!="function")throw new TypeError("callback is not a function");e=(e==null?Ja():+e)+(t==null?0:+t),!this._next&&Mr!==this&&(Mr?Mr._next=this:Xo=this,Mr=this),this._call=n,this._time=e,Qa()},stop:function(){this._call&&(this._call=null,this._time=1/0,Qa())}};function Zo(n,t,e){var i=new qo;return i.restart(n,t,e),i}function l1(){Ja(),++Ni;for(var n=Xo,t;n;)(t=wi-n._time)>=0&&n._call.call(void 0,t),n=n._next;--Ni}function Zu(){wi=(Uo=Ar.now())+jo,Ni=wr=0;try{l1()}finally{Ni=0,u1(),wi=0}}function h1(){var n=Ar.now(),t=n-Uo;t>ju&&(jo-=t,Uo=n)}function u1(){for(var n,t=Xo,e,i=1/0;t;)t._call?(i>t._time&&(i=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:Xo=e);Mr=n,Qa(i)}function Qa(n){if(!Ni){wr&&(wr=clearTimeout(wr));var t=n-wi;t>24?(n<1/0&&(wr=setTimeout(Zu,n-Ar.now()-jo)),kr&&(kr=clearInterval(kr))):(kr||(Uo=Ar.now(),kr=setInterval(h1,ju)),Ni=1,qu(Zu))}}function Ku(n,t,e){var i=new qo;return t=t==null?0:+t,i.restart(r=>{i.stop(),n(r+t)},t,e),i}var f1=Oi("start","end","cancel","interrupt"),d1=[],Ju=0,Qu=1,tc=2,Ko=3,tf=4,ec=5,Jo=6;function Qo(n,t,e,i,r,o){var s=n.__transition;if(!s)n.__transition={};else if(e in s)return;p1(n,e,{name:t,index:i,group:r,on:f1,tween:d1,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ju})}function nc(n,t){var e=xn(n,t);if(e.state>Ju)throw new Error("too late; already scheduled");return e}function An(n,t){var e=xn(n,t);if(e.state>Ko)throw new Error("too late; already running");return e}function xn(n,t){var e=n.__transition;if(!e||!(e=e[t]))throw new Error("transition not found");return e}function p1(n,t,e){var i=n.__transition,r;i[t]=e,e.timer=Zo(o,0,e.time);function o(l){e.state=Qu,e.timer.restart(s,e.delay,e.time),e.delay<=l&&s(l-e.delay)}function s(l){var h,f,u,d;if(e.state!==Qu)return c();for(h in i)if(d=i[h],d.name===e.name){if(d.state===Ko)return Ku(s);d.state===tf?(d.state=Jo,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[h]):+h<t&&(d.state=Jo,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[h])}if(Ku(function(){e.state===Ko&&(e.state=tf,e.timer.restart(a,e.delay,e.time),a(l))}),e.state=tc,e.on.call("start",n,n.__data__,e.index,e.group),e.state===tc){for(e.state=Ko,r=new Array(u=e.tween.length),h=0,f=-1;h<u;++h)(d=e.tween[h].value.call(n,n.__data__,e.index,e.group))&&(r[++f]=d);r.length=f+1}}function a(l){for(var h=l<e.duration?e.ease.call(null,l/e.duration):(e.timer.restart(c),e.state=ec,1),f=-1,u=r.length;++f<u;)r[f].call(n,h);e.state===ec&&(e.on.call("end",n,n.__data__,e.index,e.group),c())}function c(){e.state=Jo,e.timer.stop(),delete i[t];for(var l in i)return;delete n.__transition}}function Wi(n,t){var e=n.__transition,i,r,o=!0,s;if(e){t=t==null?null:t+"";for(s in e){if((i=e[s]).name!==t){o=!1;continue}r=i.state>tc&&i.state<ec,i.state=Jo,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete e[s]}o&&delete n.__transition}}function g1(n){return this.each(function(){Wi(this,n)})}function m1(n,t){var e,i;return function(){var r=An(this,n),o=r.tween;if(o!==e){i=e=o;for(var s=0,a=i.length;s<a;++s)if(i[s].name===t){i=i.slice(),i.splice(s,1);break}}r.tween=i}}function y1(n,t,e){var i,r;if(typeof e!="function")throw new Error;return function(){var o=An(this,n),s=o.tween;if(s!==i){r=(i=s).slice();for(var a={name:t,value:e},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}o.tween=r}}function x1(n,t){var e=this._id;if(n+="",arguments.length<2){for(var i=xn(this.node(),e).tween,r=0,o=i.length,s;r<o;++r)if((s=i[r]).name===n)return s.value;return null}return this.each((t==null?m1:y1)(e,n,t))}function ic(n,t,e){var i=n._id;return n.each(function(){var r=An(this,i);(r.value||(r.value={}))[t]=e.apply(this,arguments)}),function(r){return xn(r,i).value[t]}}function ef(n,t){var e;return(typeof t=="number"?yn:t instanceof ce?yi:(e=ce(t))?(t=e,yi):ou)(n,t)}function b1(n){return function(){this.removeAttribute(n)}}function v1(n){return function(){this.removeAttributeNS(n.space,n.local)}}function w1(n,t,e){var i,r=e+"",o;return function(){var s=this.getAttribute(n);return s===r?null:s===i?o:o=t(i=s,e)}}function k1(n,t,e){var i,r=e+"",o;return function(){var s=this.getAttributeNS(n.space,n.local);return s===r?null:s===i?o:o=t(i=s,e)}}function M1(n,t,e){var i,r,o;return function(){var s,a=e(this),c;return a==null?void this.removeAttribute(n):(s=this.getAttribute(n),c=a+"",s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a)))}}function A1(n,t,e){var i,r,o;return function(){var s,a=e(this),c;return a==null?void this.removeAttributeNS(n.space,n.local):(s=this.getAttributeNS(n.space,n.local),c=a+"",s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a)))}}function S1(n,t){var e=Mo(n),i=e==="transform"?nx:ef;return this.attrTween(n,typeof t=="function"?(e.local?A1:M1)(e,i,ic(this,"attr."+n,t)):t==null?(e.local?v1:b1)(e):(e.local?k1:w1)(e,i,t))}function _1(n,t){return function(e){this.setAttribute(n,t.call(this,e))}}function C1(n,t){return function(e){this.setAttributeNS(n.space,n.local,t.call(this,e))}}function P1(n,t){var e,i;function r(){var o=t.apply(this,arguments);return o!==i&&(e=(i=o)&&C1(n,o)),e}return r._value=t,r}function E1(n,t){var e,i;function r(){var o=t.apply(this,arguments);return o!==i&&(e=(i=o)&&_1(n,o)),e}return r._value=t,r}function T1(n,t){var e="attr."+n;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;var i=Mo(n);return this.tween(e,(i.local?P1:E1)(i,t))}function L1(n,t){return function(){nc(this,n).delay=+t.apply(this,arguments)}}function $1(n,t){return t=+t,function(){nc(this,n).delay=t}}function I1(n){var t=this._id;return arguments.length?this.each((typeof n=="function"?L1:$1)(t,n)):xn(this.node(),t).delay}function F1(n,t){return function(){An(this,n).duration=+t.apply(this,arguments)}}function R1(n,t){return t=+t,function(){An(this,n).duration=t}}function D1(n){var t=this._id;return arguments.length?this.each((typeof n=="function"?F1:R1)(t,n)):xn(this.node(),t).duration}function z1(n,t){if(typeof t!="function")throw new Error;return function(){An(this,n).ease=t}}function B1(n){var t=this._id;return arguments.length?this.each(z1(t,n)):xn(this.node(),t).ease}function O1(n,t){return function(){var e=t.apply(this,arguments);if(typeof e!="function")throw new Error;An(this,n).ease=e}}function N1(n){if(typeof n!="function")throw new Error;return this.each(O1(this._id,n))}function W1(n){typeof n!="function"&&(n=Oh(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=[],c,l=0;l<s;++l)(c=o[l])&&n.call(c,c.__data__,l,o)&&a.push(c);return new Bn(i,this._parents,this._name,this._id)}function H1(n){if(n._id!==this._id)throw new Error;for(var t=this._groups,e=n._groups,i=t.length,r=e.length,o=Math.min(i,r),s=new Array(i),a=0;a<o;++a)for(var c=t[a],l=e[a],h=c.length,f=s[a]=new Array(h),u,d=0;d<h;++d)(u=c[d]||l[d])&&(f[d]=u);for(;a<i;++a)s[a]=t[a];return new Bn(s,this._parents,this._name,this._id)}function V1(n){return(n+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||t==="start"})}function G1(n,t,e){var i,r,o=V1(t)?nc:An;return function(){var s=o(this,n),a=s.on;a!==i&&(r=(i=a).copy()).on(t,e),s.on=r}}function Y1(n,t){var e=this._id;return arguments.length<2?xn(this.node(),e).on.on(n):this.each(G1(e,n,t))}function X1(n){return function(){var t=this.parentNode;for(var e in this.__transition)if(+e!==n)return;t&&t.removeChild(this)}}function U1(){return this.on("end.remove",X1(this._id))}function j1(n){var t=this._name,e=this._id;typeof n!="function"&&(n=Ma(n));for(var i=this._groups,r=i.length,o=new Array(r),s=0;s<r;++s)for(var a=i[s],c=a.length,l=o[s]=new Array(c),h,f,u=0;u<c;++u)(h=a[u])&&(f=n.call(h,h.__data__,u,a))&&("__data__"in h&&(f.__data__=h.__data__),l[u]=f,Qo(l[u],t,e,u,l,xn(h,e)));return new Bn(o,this._parents,t,e)}function q1(n){var t=this._name,e=this._id;typeof n!="function"&&(n=Bh(n));for(var i=this._groups,r=i.length,o=[],s=[],a=0;a<r;++a)for(var c=i[a],l=c.length,h,f=0;f<l;++f)if(h=c[f]){for(var u=n.call(h,h.__data__,f,c),d,p=xn(h,e),y=0,g=u.length;y<g;++y)(d=u[y])&&Qo(d,t,e,y,u,p);o.push(u),s.push(h)}return new Bn(o,s,t,e)}var Z1=dr.prototype.constructor;function K1(){return new Z1(this._groups,this._parents)}function J1(n,t){var e,i,r;return function(){var o=Fi(this,n),s=(this.style.removeProperty(n),Fi(this,n));return o===s?null:o===e&&s===i?r:r=t(e=o,i=s)}}function nf(n){return function(){this.style.removeProperty(n)}}function Q1(n,t,e){var i,r=e+"",o;return function(){var s=Fi(this,n);return s===r?null:s===i?o:o=t(i=s,e)}}function tv(n,t,e){var i,r,o;return function(){var s=Fi(this,n),a=e(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(n),Fi(this,n))),s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a))}}function ev(n,t){var e,i,r,o="style."+t,s="end."+o,a;return function(){var c=An(this,n),l=c.on,h=c.value[o]==null?a||(a=nf(t)):void 0;(l!==e||r!==h)&&(i=(e=l).copy()).on(s,r=h),c.on=i}}function nv(n,t,e){var i=(n+="")=="transform"?ex:ef;return t==null?this.styleTween(n,J1(n,i)).on("end.style."+n,nf(n)):typeof t=="function"?this.styleTween(n,tv(n,i,ic(this,"style."+n,t))).each(ev(this._id,n)):this.styleTween(n,Q1(n,i,t),e).on("end.style."+n,null)}function iv(n,t,e){return function(i){this.style.setProperty(n,t.call(this,i),e)}}function rv(n,t,e){var i,r;function o(){var s=t.apply(this,arguments);return s!==r&&(i=(r=s)&&iv(n,s,e)),i}return o._value=t,o}function ov(n,t,e){var i="style."+(n+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,rv(n,t,e??""))}function sv(n){return function(){this.textContent=n}}function av(n){return function(){var t=n(this);this.textContent=t??""}}function cv(n){return this.tween("text",typeof n=="function"?av(ic(this,"text",n)):sv(n==null?"":n+""))}function lv(n){return function(t){this.textContent=n.call(this,t)}}function hv(n){var t,e;function i(){var r=n.apply(this,arguments);return r!==e&&(t=(e=r)&&lv(r)),t}return i._value=n,i}function uv(n){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(n==null)return this.tween(t,null);if(typeof n!="function")throw new Error;return this.tween(t,hv(n))}function fv(){for(var n=this._name,t=this._id,e=rf(),i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var h=xn(c,t);Qo(c,n,e,l,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Bn(i,this._parents,n,e)}function dv(){var n,t,e=this,i=e._id,r=e.size();return new Promise(function(o,s){var a={value:s},c={value:function(){--r===0&&o()}};e.each(function(){var l=An(this,i),h=l.on;h!==n&&(t=(n=h).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&o()})}var pv=0;function Bn(n,t,e,i){this._groups=n,this._parents=t,this._name=e,this._id=i}function rf(){return++pv}var On=dr.prototype;Bn.prototype={constructor:Bn,select:j1,selectAll:q1,selectChild:On.selectChild,selectChildren:On.selectChildren,filter:W1,merge:H1,selection:K1,transition:fv,call:On.call,nodes:On.nodes,node:On.node,size:On.size,empty:On.empty,each:On.each,on:Y1,attr:S1,attrTween:T1,style:nv,styleTween:ov,text:cv,textTween:uv,remove:U1,tween:x1,delay:I1,duration:D1,ease:B1,easeVarying:N1,end:dv,[Symbol.iterator]:On[Symbol.iterator]};const Sr=n=>+n;function of(n){return--n*n*n+1}function gv(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var mv={time:null,delay:0,duration:250,ease:gv};function yv(n,t){for(var e;!(e=n.__transition)||!(e=e[t]);)if(!(n=n.parentNode))throw new Error(`transition ${t} not found`);return e}function xv(n){var t,e;n instanceof Bn?(t=n._id,n=n._name):(t=rf(),(e=mv).time=Ja(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&Qo(c,n,t,l,s,e||yv(c,t));return new Bn(i,this._parents,n,t)}dr.prototype.interrupt=g1,dr.prototype.transition=xv;let rc=!0;function bv(n){rc=n}function oc(){return rc}const vv=Object.entries({"%A":"%A","%a":"%a","%d":"%d","%e":"%-d","%b":"%b","%B":"%B","%m":"%m","%y":"%y","%Y":"%Y","%H":"%H","%I":"%I","%k":"%-H","%l":"%-I","%M":"%M","%p":"%p","%P":"%p","%S":"%S","%L":"%L"}).map(([n,t])=>[new RegExp(n.replace("%","\\%"),"g"),t]),sf=new Map;function sc(n,t){let e=sf.get(n);if(!e){e=n;for(const[r,o]of vv)e=e.replace(r,o);sf.set(n,e)}return(rc?Wo(e):No(e))(new Date(t))}function ts(n,t=-1,e=".",i=","){if(!Number.isFinite(n))return"0";if(t===-1){const c=n.toString(),l=c.indexOf(".");t=l===-1?0:c.length-l-1}const r=n.toFixed(t),[o,s]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,i);return s?`${a}${e}${s}`:a}const wv=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"]];function ac(n){const t=Math.abs(n);if(t<1e3)return t===Math.floor(t)?ts(n,0,".",","):n.toPrecision(4).replace(/\.?0+$/,"");for(const[e,i]of wv)if(t>=e){const r=n/e;return(r===Math.floor(r)?String(r):r.toPrecision(4).replace(/\.?0+$/,""))+i}return String(n)}const kv=/\{([^}]+)\}/g;function Kt(n,t,e=!1){return n.replace(kv,(i,r)=>{const o=r.indexOf(":");let s=r,a=null;o!==-1&&(s=r.slice(0,o),a=r.slice(o+1));const c=s.trim().split(".");let l=t;for(const f of c){if(l==null)return"";l=l[f]}if(l==null)return"";let h;if(a){const f=typeof l=="number"?l:parseFloat(String(l));if(isNaN(f))h=String(l);else try{h=gr(a)(f)}catch{h=String(l)}}else h=String(l);return e?Jn(h):h})}const Mv=/[&<>"']/g,Av={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Jn(n){return String(n).replace(Mv,t=>Av[t])}const Sv=/^[=+\-@\t\r]/,_v=/^-?\d+(?:[.,]\d+)?$/;function es(n,t=","){let e=n==null?"":String(n);return Sv.test(e)&&!_v.test(e)&&(e="'"+e),(e.includes(t)||e.includes('"')||e.includes(`
2
- `)||e.includes("\r"))&&(e='"'+e.replace(/"/g,'""')+'"'),e}const Cv=/^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla)\([\d.,%\s/]+\)|[a-z]+)$/i;function af(n,t="#333"){const e=String(n).trim();return Cv.test(e)?e:t}const Pv=/<\/?[^>]+(>|$)/g,Ev=/<br\s*\/?>/gi;function oe(n){return n.replace(Ev," ").replace(Pv,"").trim()}function cc(n,t){switch(n.type||"linear"){case"logarithmic":return new Lv(n,t);case"datetime":return new $v(n,t);case"category":return new cf(n,t);default:return new Tv(n,t)}}class ns{constructor(t,e){this.config=t,this.plotArea=e}autoText(){return gn(this.config._backgroundColor)}getRange(){const t=this.config._inverted;if(this.config.isX){if(t){const s=this.plotArea.height;return this.config.reversed?[s,0]:[0,s]}const o=this.plotArea.width;return this.config.reversed?[o,0]:[0,o]}if(t){const o=this.plotArea.width;return this.config.reversed?[o,0]:[0,o]}const e=this.getPaneBand(),i=e.top,r=e.top+e.height;return this.config.reversed?[i,r]:[r,i]}getPaneBand(){const t=this.plotArea.height,e=o=>{if(o==null)return null;if(typeof o=="number")return o;if(typeof o=="string"&&o.trim().endsWith("%"))return parseFloat(o)/100*t;const s=parseFloat(o);return Number.isFinite(s)?s:null},i=e(this.config.top)??0,r=e(this.config.height)??t-i;return{top:i,height:r}}createD3Axis(t){const e=this.config.isX,i=this.config.opposite,r=this.config._inverted;return e?r?i?Gu(t):Xu(t):i?Ka(t):Yu(t):r?i?Ka(t):Yu(t):i?Gu(t):Xu(t)}applyAxisStyles(t,e){var s,a,c,l,h,f,u,d,p;const i=this.config,r=i.tickLength??10,o=i.tickPosition||"outside";if(t.selectAll(".tick line").attr("stroke",i.tickColor||"#ccd6eb").attr("stroke-width",i.tickWidth??1),(r!==10||o==="inside")&&t.selectAll(".tick line").each(function(){const y=st(this);if(i.isX){const g=i.opposite?-1:1;o==="inside"?y.attr("y1",0).attr("y2",-g*r):y.attr("y1",0).attr("y2",g*r)}else{const g=i.opposite?1:-1;o==="inside"?y.attr("x1",0).attr("x2",-g*r):y.attr("x1",0).attr("x2",g*r)}}),t.selectAll(".domain").attr("stroke",i.lineColor||"#ccd6eb").attr("stroke-width",i.lineWidth??1),((s=i.labels)==null?void 0:s.enabled)===!1)t.selectAll(".tick text").remove();else{const y=((a=i.labels)==null?void 0:a.style)||{};if(t.selectAll(".tick text").attr("fill",y.color||this.autoText()).style("font-size",y.fontSize||kt),((c=i.labels)==null?void 0:c.x)!==void 0||((l=i.labels)==null?void 0:l.y)!==void 0){const g=((h=i.labels)==null?void 0:h.x)??0,m=((f=i.labels)==null?void 0:f.y)??0;t.selectAll(".tick text").attr("dx",g).attr("dy",parseFloat(t.select(".tick text").attr("dy")||"0")+m)}if((u=i.labels)!=null&&u.step&&i.labels.step>1&&t.selectAll(".tick text").each(function(g,m){m%i.labels.step!==0&&st(this).remove()}),i.showFirstLabel===!1){const g=t.selectAll(".tick text").nodes();g.length>0&&st(g[0]).remove()}if(i.showLastLabel===!1){const g=t.selectAll(".tick text").nodes();g.length>0&&st(g[g.length-1]).remove()}if((d=i.labels)!=null&&d.rotation)t.selectAll(".tick text").attr("transform",`rotate(${i.labels.rotation})`).style("text-anchor",i.labels.rotation<0?"end":"start");else if((i.isX?!i._inverted:i._inverted)&&((p=i.labels)!=null&&p.autoRotation))this.applyAutoRotation(t,i.labels.autoRotation,e);else if((i.isX?i._inverted:!i._inverted)&&!i.opposite&&Array.isArray(i.categories)&&i.categories.length>0){const g=i.tickLength??10;this.truncateSideLabels(t,e.x-g-4)}}i.visible===!1&&t.style("display","none")}truncateSideLabels(t,e){if(!(e>12))return;const i="…";t.selectAll(".tick text").each(function(){const r=this,o=r.textContent||"";if(!o)return;const s=r.getComputedTextLength();if(s<=e)return;let a=Math.max(1,Math.min(o.length,Math.ceil(o.length*e/s)));for(r.textContent=o.slice(0,a).replace(/\s+$/,"")+i;a>1&&r.getComputedTextLength()>e;)a--,r.textContent=o.slice(0,a).replace(/\s+$/,"")+i;const c=st(r);c.select("title").remove(),c.append("title").text(o)})}applyAutoRotation(t,e,i){const r=t.selectAll(".tick text").nodes();if(r.length<2||!this.hasLabelOverlap(r))return;this.applyAutoStep(t,r);const o=r.filter(s=>s.style.display!=="none");if(this.hasLabelOverlap(o))for(const s of e.length>0?e:[-45]){r.forEach(a=>{a.style.display=""}),t.selectAll(".tick text").attr("transform",`rotate(${s})`).style("text-anchor",s<0?"end":"start");break}}hasLabelOverlap(t,e=!1){for(let i=1;i<t.length;i++)try{const r=t[i-1].getBoundingClientRect(),o=t[i].getBoundingClientRect(),s=e?-4:2;if(r.right+s>o.left&&r.left<o.right)if(e){if(r.bottom+s>o.top&&r.top<o.bottom)return!0}else return!0}catch{return!1}return!1}applyAutoStep(t,e){const i=e.length;for(let r=2;r<=i;r++){e.forEach((s,a)=>{st(s).style("display",a%r===0?"":"none")});const o=e.filter((s,a)=>a%r===0);if(!this.hasLabelOverlap(o))return}}renderGridLines(t,e,i,r){const o=this.config.gridLineWidth;if(!o||o<=0)return;const s=r||(e.ticks?e.ticks():e.domain()),a=t.append("g").attr("class","katucharts-grid");this.config.alternateGridColor&&this.renderAlternateGridColor(a,s,e,i);const c=this.config.isX?!this.config._inverted:!!this.config._inverted;for(const l of s){const h=e(l);c?a.append("line").attr("x1",h).attr("x2",h).attr("y1",0).attr("y2",i.height).attr("stroke",this.config.gridLineColor||"#e6e6e6").attr("stroke-width",o).attr("stroke-dasharray",this.getDashArray(this.config.gridLineDashStyle)):a.append("line").attr("x1",0).attr("x2",i.width).attr("y1",h).attr("y2",h).attr("stroke",this.config.gridLineColor||"#e6e6e6").attr("stroke-width",o).attr("stroke-dasharray",this.getDashArray(this.config.gridLineDashStyle))}this.renderMinorGridLines(a,s,e,i)}renderAlternateGridColor(t,e,i,r){const o=this.config.alternateGridColor,s=this.config.isX?!this.config._inverted:!!this.config._inverted;for(let a=0;a<e.length-1;a+=2){const c=i(e[a]),l=i(e[a+1]);s?t.insert("rect",":first-child").attr("x",Math.min(c,l)).attr("y",0).attr("width",Math.abs(l-c)).attr("height",r.height).attr("fill",o):t.insert("rect",":first-child").attr("x",0).attr("y",Math.min(c,l)).attr("width",r.width).attr("height",Math.abs(l-c)).attr("fill",o)}}renderMinorGridLines(t,e,i,r){const o=this.config.minorTickInterval,s=this.config.minorGridLineWidth??1,a=this.config.minorGridLineColor||"#f2f2f2";if(!o||o==="auto"||s<=0||typeof o!="number"||e.length<2)return;const c=i.domain?i.domain():[0,1],l=typeof c[0]=="number"?c[0]:0,h=typeof c[c.length-1]=="number"?c[c.length-1]:1,f=new Set(e.map(d=>Number(d))),u=this.config.isX?!this.config._inverted:!!this.config._inverted;for(let d=l;d<=h;d+=o){if(f.has(d))continue;const p=i(d);u?t.append("line").attr("x1",p).attr("x2",p).attr("y1",0).attr("y2",r.height).attr("stroke",a).attr("stroke-width",s).attr("class","katucharts-minor-grid"):t.append("line").attr("x1",0).attr("x2",r.width).attr("y1",p).attr("y2",p).attr("stroke",a).attr("stroke-width",s).attr("class","katucharts-minor-grid")}}renderPlotBands(t,e,i){var r,o,s,a;if((r=this.config.plotBands)!=null&&r.length)for(const c of this.config.plotBands){const l=e(c.from??0),h=e(c.to??0);let f,u,d,p;(this.config.isX?!this.config._inverted:!!this.config._inverted)?(f=Math.min(l,h),u=0,d=Math.abs(h-l),p=i.height):(f=0,u=Math.min(l,h),d=i.width,p=Math.abs(h-l));const g=t.append("rect").attr("x",f).attr("y",u).attr("width",d).attr("height",p).attr("fill",c.color||"rgba(0,0,0,0.05)").attr("class",`katucharts-plot-band${c.className?" "+c.className:""}`);if(c.borderColor&&g.attr("stroke",c.borderColor).attr("stroke-width",c.borderWidth??0),c.borderRadius&&g.attr("rx",c.borderRadius),c.zIndex!==void 0&&g.style("z-index",c.zIndex),c.events&&(c.events.click&&g.on("click",m=>c.events.click.call(c,m)),c.events.mouseover&&g.on("mouseover",m=>c.events.mouseover.call(c,m)),c.events.mouseout&&g.on("mouseout",m=>c.events.mouseout.call(c,m)),c.events.mousemove&&g.on("mousemove",m=>c.events.mousemove.call(c,m)),g.style("cursor","pointer")),(o=c.label)!=null&&o.text){const m=c.label,x=m.align||"center",v=m.verticalAlign||"top";let b=x==="left"?f+4:x==="right"?f+d-4:f+d/2,k=v==="top"?u+12:v==="bottom"?u+p-4:u+p/2;b+=m.x??0,k+=m.y??0;const M=x==="left"?"start":x==="right"?"end":"middle";t.append("text").attr("x",b).attr("y",k).attr("text-anchor",M).attr("font-size",((s=m.style)==null?void 0:s.fontSize)||kt).attr("fill",((a=m.style)==null?void 0:a.color)||this.autoText()).attr("transform",m.rotation?`rotate(${m.rotation},${b},${k})`:"").style("pointer-events","none").attr("class","katucharts-plot-band-label").text(m.text||"")}}}renderPlotLines(t,e,i){var r,o,s,a;if((r=this.config.plotLines)!=null&&r.length)for(const c of this.config.plotLines){const l=e(c.value??0),h=this.config.isX?!this.config._inverted:!!this.config._inverted;let f;if(h?f=t.append("line").attr("x1",l).attr("x2",l).attr("y1",0).attr("y2",i.height).attr("stroke",c.color||"#999").attr("stroke-width",c.width||1).attr("stroke-dasharray",this.getDashArray(c.dashStyle)).attr("class",`katucharts-plot-line${c.className?" "+c.className:""}`):f=t.append("line").attr("x1",0).attr("x2",i.width).attr("y1",l).attr("y2",l).attr("stroke",c.color||"#999").attr("stroke-width",c.width||1).attr("stroke-dasharray",this.getDashArray(c.dashStyle)).attr("class",`katucharts-plot-line${c.className?" "+c.className:""}`),c.zIndex!==void 0&&f.style("z-index",c.zIndex),c.events&&(f.style("pointer-events","stroke"),c.events.click&&f.on("click",u=>c.events.click.call(c,u)),c.events.mouseover&&f.on("mouseover",u=>c.events.mouseover.call(c,u)),c.events.mouseout&&f.on("mouseout",u=>c.events.mouseout.call(c,u)),c.events.mousemove&&f.on("mousemove",u=>c.events.mousemove.call(c,u)),f.style("cursor","pointer")),(o=c.label)!=null&&o.text){const u=c.label,d=u.align||(this.config.isX?"left":"right"),p=u.verticalAlign||(this.config.isX?"top":"middle");let y,g;this.config.isX?(y=l+(u.x??4),g=p==="top"?u.y??12:p==="bottom"?i.height+(u.y??-4):i.height/2+(u.y??0)):(y=d==="left"?u.x??4:d==="right"?i.width+(u.x??-4):i.width/2+(u.x??0),g=l+(u.y??-6));const m=d==="left"?"start":d==="right"?"end":"middle";t.append("text").attr("x",y).attr("y",g).attr("text-anchor",m).attr("font-size",((s=u.style)==null?void 0:s.fontSize)||kt).attr("fill",((a=u.style)==null?void 0:a.color)||this.autoText()).attr("transform",u.rotation?`rotate(${u.rotation},${y},${g})`:"").style("pointer-events","none").attr("class","katucharts-plot-line-label").text(u.text||"")}}}applyAxisBreaks(t){var a;if(!((a=this.config.breaks)!=null&&a.length))return;const e=t.copy(),i=e.domain(),r=e.range(),o=Math.abs(i[1]-i[0]);let s=0;for(const c of this.config.breaks){const l=c.from??0,h=c.to??0;s+=Math.abs(h-l)}if(o>0&&s>0){const c=(o-s)/o,l=[r[0],r[0]+(r[1]-r[0])*c];t.range(l)}}renderTitle(t,e){var c,l,h,f,u,d,p;if(!((c=this.config.title)!=null&&c.text))return;const i=this.config.title,r=i.offset??0,o=i.margin??0,s=i.rotation;if(this.config.isX?!this.config._inverted:!!this.config._inverted){const y=((l=this.config.labels)==null?void 0:l.enabled)!==!1;let g=(y?45:33)+o+r;if(y&&t.selectAll(".tick text").nodes().length>0)try{const M=t.node().getBBox();g=Math.max(g,M.height+10+o+r)}catch{}const m=this.config,x=m._centerTitleOnChart&&m._chartWidth!=null?m._chartWidth/2-e.x:e.width/2,v=t.append("text").attr("class","katucharts-axis-title").attr("x",x).attr("y",g).attr("text-anchor","middle").attr("font-size",((h=i.style)==null?void 0:h.fontSize)||kt).attr("fill",((f=i.style)==null?void 0:f.color)||this.autoText()).text(i.text);s!==void 0&&v.attr("transform",`rotate(${s}, ${x}, ${g})`)}else{const y=((u=this.config.labels)==null?void 0:u.enabled)!==!1;let g=(this.config.opposite?e.width+45:-45)+r;if(y)try{const k=t.node().getBBox();this.config.opposite?g=Math.max(g,k.x+k.width+10+o+r):g=Math.min(g,k.x-10-o-r)}catch{}const m=this.getPaneBand(),x=m.top+m.height/2,v=s??-90;t.append("text").attr("class","katucharts-axis-title").attr("x",g).attr("y",x).attr("text-anchor","middle").attr("transform",`rotate(${v}, ${g}, ${x})`).attr("font-size",((d=i.style)==null?void 0:d.fontSize)||kt).attr("fill",((p=i.style)==null?void 0:p.color)||this.autoText()).text(i.text)}}animateAxis(t,e,i){var c;this.plotArea=e;const r=this.scale;if(!r)return;r.range(this.getRange()),this.applyAxisBreaks(r);const o=this.createD3Axis(r);if(this.config.tickPositions)o.tickValues(this.config.tickPositions);else if(this.config.tickInterval){const l=r.domain(),h=[];for(let f=l[0];f<=l[1];f+=this.config.tickInterval)h.push(f);o.tickValues(h)}else if(r.domain&&typeof r.ticks=="function"){const l=this.config._inverted,h=this.config.isX?l?e.height:e.width:l?e.width:e.height;this.config.isX;const f=this.config.tickPixelInterval??72,u=Math.min(20,Math.max(2,Math.round(h/f))),d=r.domain();if(this.computeNiceTicks){const p=this.computeNiceTicks(d[0],d[1],u);o.tickValues(p)}else if(this.computeLogTicks){const p=this.computeLogTicks(d,e);o.tickValues(p)}}if((c=this.config.labels)!=null&&c.formatter){const l=this.config.labels.formatter;o.tickFormat(h=>l.call({value:h,axis:this}))}else this.linearTickFormat?o.tickFormat(l=>this.linearTickFormat(l,o)):o.tickFormat(l=>ac(l));const s=`katucharts-axis-${this.config.isX?"x":"y"}`,a=t.select(`.${s}`);a.empty()||(a.transition().duration(i).call(o),this.animateGridLines(t,r,e,i))}animateGridLines(t,e,i,r){const o=this.config.gridLineWidth;!o||o<=0||(t.selectAll(".katucharts-grid").remove(),this.renderGridLines(t,e,i))}getDashArray(t){return{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t||"Solid"]||"none"}destroy(){}}class Tv extends ns{constructor(t,e){super(t,e),this.scale=ke().range(this.getRange()).domain([0,1])}updateDomain(t){let{min:e,max:i}=t;const r=this.config.min!==void 0&&this.config.min!==null,o=this.config.max!==void 0&&this.config.max!==null;r&&(e=this.config.min),o&&(i=this.config.max),this.config.softMin!==void 0&&e>this.config.softMin&&(e=this.config.softMin),this.config.softMax!==void 0&&i<this.config.softMax&&(i=this.config.softMax),this.config.floor!==void 0&&(e=Math.max(e,this.config.floor)),this.config.ceiling!==void 0&&(i=Math.min(i,this.config.ceiling));const s=this.config.isX?this.config.maxPadding||.01:this.config.maxPadding||.05,a=i-e||1,c=e,l=(this.config.minPadding??s)+(t.extraMinPadding??0),h=s+(t.extraMaxPadding??0);r||(e-=a*l),o||(i+=a*h);const f=(t.extraMinPadding??0)>0;if(c>=0&&e<0&&!f&&(e=0),this.config.floor!==void 0&&(e=Math.max(e,this.config.floor)),this.config.ceiling!==void 0&&(i=Math.min(i,this.config.ceiling)),this.config.minRange!==void 0&&i-e<this.config.minRange){const p=(e+i)/2;e=p-this.config.minRange/2,i=p+this.config.minRange/2}if(this.config.maxRange!==void 0&&i-e>this.config.maxRange&&(i=e+this.config.maxRange),this.scale.domain([e,i]).range(this.getRange()),!(r&&o)&&(this.config.startOnTick||this.config.endOnTick||!this.config.isX&&this.config.startOnTick!==!1&&this.config.endOnTick!==!1)&&(this.scale.nice(),r||o)){const[p,y]=this.scale.domain();this.scale.domain([r?this.config.min:p,o?this.config.max:y])}}render(t,e){var o;this.plotArea=e,this.scale.range(this.getRange()),this.applyAxisBreaks(this.scale);const i=this.createD3Axis(this.scale);if(this.config.tickPositions)i.tickValues(this.config.tickPositions);else if(this.config.tickInterval){const s=this.scale.domain(),a=[];for(let c=s[0];c<=s[1];c+=this.config.tickInterval)a.push(c);i.tickValues(a)}else if(this.config.tickAmount)i.ticks(this.config.tickAmount);else{const s=this.config._inverted,a=this.config.isX?s?e.height:e.width:s?e.width:e.height;this.config.isX;const c=this.config.tickPixelInterval??72,l=Math.min(20,Math.max(2,Math.round(a/c))),h=this.scale.domain(),f=this.computeNiceTicks(h[0],h[1],l),u=this.config.max!==void 0&&this.config.max!==null,d=this.config.min!==void 0&&this.config.min!==null,p=!this.config.isX&&this.config.endOnTick!==!1;if(f.length>0&&p&&!u){const y=f.length>1?f[1]-f[0]:f[0]||1;let g=f[f.length-1];g<h[1]&&(f.push(g+y),g=f[f.length-1]);let m=f[0];m>h[0]&&(f.unshift(m-y),m=f[0]);const x=u?h[1]:Math.max(h[1],g),v=d?h[0]:Math.min(h[0],m);this.scale.domain([v,x])}i.tickValues(f)}if((o=this.config.labels)!=null&&o.formatter){const s=this.config.labels.formatter;i.tickFormat(a=>s.call({value:a,axis:this}))}else i.tickFormat(s=>this.linearTickFormat(s,i));const r=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",this.getTransform(e));this.renderGridLines(t,this.scale,e),this.renderPlotBands(t,this.scale,e),this.renderPlotLines(t,this.scale,e),r.call(i),this.applyAxisStyles(r,e),this.renderTitle(r,e),this.renderStackLabels(t,this.scale,e)}renderStackLabels(t,e,i){var r;!((r=this.config.stackLabels)!=null&&r.enabled)||this.config.isX}computeNiceTicks(t,e,i){const r=e-t;if(r<=0)return[t];const o=r/i,s=Math.pow(10,Math.floor(Math.log10(o))),a=o/s;let c;a<=Math.SQRT2?c=s:a<=Math.sqrt(2*2.5)?c=2*s:a<=Math.sqrt(2.5*5)?c=2.5*s:a<=Math.sqrt(5*10)?c=5*s:c=10*s;const l=c.toString(),h=l.includes(".")?l.split(".")[1].length:0,f=Math.pow(10,h),u=g=>Math.round(g*f)/f,d=u(Math.ceil(t/c)*c),p=[],y=c*1e-6;for(let g=0;g<i+3;g++){const m=u(d+g*c);if(m>e+y)break;p.push(m)}return p}getPixelForValue(t){return this.scale(t)}getValueForPixel(t){return this.scale.invert(t)}linearTickFormat(t,e){var r;const i=(r=e.tickValues)==null?void 0:r.call(e);if(i&&i.length>=2){const o=Math.abs(i[1]-i[0]),s=parseFloat(o.toPrecision(6));if(s<1e3){const a=s.toString(),c=a.includes(".")?a.split(".")[1].length:0,l=ts(t,c);return c===0?l:l.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")}}return ac(t)}getTransform(t){const e=this.config._inverted;return this.config.isX?e?this.config.opposite?`translate(${t.width},0)`:"":this.config.opposite?"":`translate(0,${t.height})`:e?this.config.opposite?"":`translate(0,${t.height})`:this.config.opposite?`translate(${t.width},0)`:""}}class Lv extends ns{constructor(t,e){super(t,e),this.scale=Io().range(this.getRange()).domain([1,10])}updateDomain(t){let{min:e,max:i}=t;e=Math.max(e,.001),this.config.min!==void 0&&this.config.min!==null&&(e=Math.max(this.config.min,.001)),this.config.max!==void 0&&this.config.max!==null&&(i=this.config.max);const r=Math.log10(Math.max(e,1e-10)),o=Math.log10(Math.max(i,1e-10)),s=Math.abs(o-r)||1,a=this.config.isX?this.config.minPadding??.01:this.config.minPadding??.05;(this.config.min===void 0||this.config.min===null)&&(e=Math.pow(10,r-s*a)),(this.config.max===void 0||this.config.max===null)&&(i=Math.pow(10,o+s*a)),this.config.startOnTick&&(e=Math.pow(10,Math.floor(Math.log10(Math.max(e,1e-10))))),this.config.endOnTick&&(i=Math.pow(10,Math.ceil(Math.log10(Math.max(i,1e-10))))),this.scale.domain([e,i]).range(this.getRange())}computeLogTicks(){const t=this.scale.domain(),e=Math.log10(Math.max(t[0],1e-10)),i=Math.log10(Math.max(t[1],1e-10));if(this.config.tickPositions)return this.config.tickPositions;let r;if(this.config.tickInterval)r=this.config.tickInterval;else{r=1;const c=Math.abs(i-e);if(c>12){const l=this.config.isX?this.plotArea.width:this.plotArea.height,f=Math.max(2,Math.floor(l/20));r=Math.max(1,Math.ceil(c/f))}}const o=Math.floor(e),s=Math.ceil(i),a=[];for(let c=o;c<=s;c+=r){const l=Math.pow(10,c);l>=t[0]*.999&&l<=t[1]*1.001&&a.push(l)}return a.length===0?a.push(t[0],t[1]):a.length===1&&(a[0]>t[0]*1.5&&a.unshift(t[0]),a[0]<t[1]/1.5&&a.push(t[1])),a}render(t,e){var a;this.plotArea=e,this.scale.range(this.getRange());const i=this.createD3Axis(this.scale),r=this.computeLogTicks();if(i.tickValues(r),(a=this.config.labels)!=null&&a.formatter){const c=this.config.labels.formatter;i.tickFormat(l=>c.call({value:l,axis:this}))}else i.tickFormat(c=>ac(c));const o=this.config.isX?!this.config._inverted:!!this.config._inverted,s=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",o?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e,r),s.call(i),this.applyAxisStyles(s,e),this.renderTitle(s,e)}getPixelForValue(t){return this.scale(Math.max(t,.001))}getValueForPixel(t){return this.scale.invert(t)}}class $v extends ns{constructor(t,e){super(t,e);const i=oc()?Zb:qb;this.scale=i().range(this.getRange()).domain([new Date,new Date])}updateDomain(t){const e=this.config.min??t.min,i=this.config.max??t.max;this.scale.domain([new Date(e),new Date(i)]).range(this.getRange())}render(t,e){var s;this.plotArea=e,this.scale.range(this.getRange());const i=this.createD3Axis(this.scale);if((s=this.config.labels)!=null&&s.formatter){const a=this.config.labels.formatter;i.tickFormat(c=>a.call({value:c.getTime(),axis:this}))}else if(this.config.dateTimeLabelFormats){const a=this.config.dateTimeLabelFormats,c=oc()?Wo:No;i.tickFormat(l=>{const h=l,f=this.pickDateFormat(h,a);return c(f)(h)})}const r=this.config.isX?!this.config._inverted:!!this.config._inverted,o=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",r?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e),o.call(i),this.applyAxisStyles(o,e),this.renderTitle(o,e)}pickDateFormat(t,e){const i=oc(),r=i?t.getUTCMilliseconds():t.getMilliseconds(),o=i?t.getUTCSeconds():t.getSeconds(),s=i?t.getUTCMinutes():t.getMinutes(),a=i?t.getUTCHours():t.getHours(),c=i?t.getUTCDate():t.getDate(),l=i?t.getUTCMonth():t.getMonth();return r!==0&&e.millisecond?e.millisecond:o!==0&&e.second?e.second:s!==0&&e.minute?e.minute:a!==0&&e.hour?e.hour:c!==1&&e.day?e.day:l!==0&&e.month?e.month:e.year?e.year:e.day||"%b %d"}getPixelForValue(t){return this.scale(new Date(t))}getValueForPixel(t){return this.scale.invert(t).getTime()}}class cf extends ns{constructor(t,e){super(t,e),this.scale=iu().range(this.getRange()).paddingInner(.3).paddingOuter(.05),t.categories&&this.scale.domain(t.categories)}updateDomain(t){Array.isArray(t)&&this.scale.domain(t).range(this.getRange())}render(t,e){this.plotArea=e;const i=this.getRange();if(isNaN(i[0])||isNaN(i[1])||i[0]===i[1])return;this.scale.range(i);const r=this.createD3Axis(this.scale),o=this.config.isX?!this.config._inverted:!!this.config._inverted,s=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",o?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e),s.call(r),this.applyAxisStyles(s,e),this.renderTitle(s,e),this.applyAutoStepIfNeeded(s)}applyAutoStepIfNeeded(t){var s,a,c;if(((s=this.config.labels)==null?void 0:s.enabled)===!1)return;const e=this.scale.bandwidth();if(e<=0)return;const i=me(((c=(a=this.config.labels)==null?void 0:a.style)==null?void 0:c.fontSize)||kt);if(i<=e)return;const o=Math.min(i,Math.max(5,Math.round(e*1.1)));t.selectAll(".tick text").style("font-size",`${o}px`)}getPixelForValue(t){const e=this.scale.domain();let i;if(typeof t=="number"){const r=Math.round(t);if(r>=0&&r<e.length){i=e[r];const o=(this.scale(i)??0)+this.scale.bandwidth()/2,s=(t-r)*this.scale.bandwidth();return o+s}i=String(t)}else i=String(t);return(this.scale(i)??0)+this.scale.bandwidth()/2}getBandwidth(){return this.scale.bandwidth()}getValueForPixel(t){const e=this.scale.domain(),i=this.scale.step(),r=Math.floor(t/i);return e[Math.min(r,e.length-1)]}}class is{static render(t,e,i,r,o,s){if(!i.enabled)return;const a=t.append("g").attr("class","katucharts-data-labels");i.zIndex!==void 0&&a.style("z-index",i.zIndex),e.forEach((c,l)=>{var p,y,g,m,x,v;if(c.y===null||c.y===void 0)return;if(i.filter){const b=i.filter.property,k=i.filter.operator||">",M=i.filter.value??0,C=b?c[b]:c.y;if(!is.matchesFilter(C,k,M))return}let h;i.formatter?h=i.formatter.call({point:{...c,index:l},series:{name:s},x:c.x,y:c.y,percentage:c.percentage}):i.format?h=oe(Kt(i.format,{point:c,series:{name:s},x:c.x,y:c.y})):h=String(c.y);const f=r.getPixelForValue(c.x??l)+(i.x??0),u=o.getPixelForValue(c.y)+(i.y??-8),d=a.append("text").attr("x",f).attr("y",u).attr("text-anchor",i.align||"center").attr("dominant-baseline","auto").attr("font-size",((p=i.style)==null?void 0:p.fontSize)||kt).attr("fill",i.color||((y=i.style)==null?void 0:y.color)||Le).attr("font-weight",((g=i.style)==null?void 0:g.fontWeight)||"normal").text(h);if(i.className&&d.attr("class",i.className),i.rotation&&d.attr("transform",`rotate(${i.rotation},${f},${u})`),i.shadow&&d.attr("filter","drop-shadow(1px 1px 2px rgba(0,0,0,0.3))"),(m=i.textPath)!=null&&m.enabled){const b=i.textPath.attributes||{};d.selectAll("*").remove();const k=d.append("textPath");for(const[M,C]of Object.entries(b))k.attr(M,C);k.text(h)}if(i.backgroundColor){const b=(v=(x=d.node())==null?void 0:x.getBBox)==null?void 0:v.call(x);if(b){const k=i.padding??2,M=a.insert("rect","text").attr("x",b.x-k).attr("y",b.y-k).attr("width",b.width+k*2).attr("height",b.height+k*2).attr("fill",i.backgroundColor).attr("rx",i.borderRadius??0).attr("stroke",i.borderColor||"none").attr("stroke-width",i.borderWidth??0);i.shadow&&M.attr("filter","drop-shadow(1px 1px 2px rgba(0,0,0,0.3))")}}}),i.defer&&(a.style("opacity","0"),a.transition().delay(1e3).duration(200).style("opacity","1"))}static matchesFilter(t,e,i){const r=Number(t);if(isNaN(r))return!1;switch(e){case">":return r>i;case"<":return r<i;case">=":return r>=i;case"<=":return r<=i;case"==":return r===i;case"!=":return r!==i;default:return!0}}}function Iv(n){if(typeof n=="string"){const t=document.getElementById(n);if(!t)throw new Error(`KatuCharts: container element "${n}" not found`);return t}return n}function lf(n,t=.5){const e=getComputedStyle(n),i=parseFloat(e.paddingLeft)||0,r=parseFloat(e.paddingRight)||0,o=parseFloat(e.paddingTop)||0,s=parseFloat(e.paddingBottom)||0,a=n.getBoundingClientRect(),c=a.width-i-r||n.clientWidth-i-r||600,l=a.height-o-s||n.clientHeight-o-s,h=l>0,f=h?l:Math.round(c*t);return{width:c,height:f,heightMeasured:h}}function lc(n,t){const e=document.createElement("div");return n&&(e.className=n),t&&t.appendChild(e),e}function hf(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function hc(n,t){let e=0,i=null;return function(...r){const o=Date.now(),s=t-(o-e);s<=0?(i&&(clearTimeout(i),i=null),e=o,n.apply(this,r)):i||(i=setTimeout(()=>{e=Date.now(),i=null,n.apply(this,r)},s))}}function Fv(n,t){let e=null;return function(...i){e&&clearTimeout(e),e=setTimeout(()=>{n.apply(this,i)},t)}}const qr=class qr{constructor(t,e,i,r){if(this.element=null,this.splitElements=[],this.hideTimeout=null,this.categories=null,this.isDatetime=!1,this.sharedPoints=[],this.sharedProvider=null,this.lastMouseEvent=null,this.boundHandlers=[],this.config=t,this.container=t.outside?document.body:e,this.plotArea=i,t.enabled!==!1){if(r.on("point:mouseover",o=>this.show(o)),r.on("point:mouseout",o=>{var s,a,c;if(this.config.shared&&(o!=null&&o.series)){const l=((a=(s=o.series)==null?void 0:s.config)==null?void 0:a.name)??((c=o.series)==null?void 0:c.name)??"";this.sharedPoints=this.sharedPoints.filter(h=>h.series.name!==l)}this.scheduleHide()}),t.followPointer){const o=hc(s=>{this.lastMouseEvent=s,this.element&&this.element.style.display!=="none"&&this.positionAtMouse(s)},16);e.addEventListener("mousemove",o),this.boundHandlers.push({el:e,type:"mousemove",fn:o})}if(t.stickOnContact){const o=hc(s=>{if(this.element&&this.element.style.display!=="none"){const a=this.element.getBoundingClientRect();s.clientX>=a.left&&s.clientX<=a.right&&s.clientY>=a.top&&s.clientY<=a.bottom&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}},16);e.addEventListener("mousemove",o),this.boundHandlers.push({el:e,type:"mousemove",fn:o})}if(t.followTouchMove!==!1){const o=hc(s=>{if(this.element&&this.element.style.display!=="none"&&s.touches.length===1){const a=s.touches[0],c=e.getBoundingClientRect(),l=this.config.distance??16;let h=a.clientX-c.left+l,f=a.clientY-c.top-10;const u=this.element.offsetWidth||120;h+u>c.width&&(h=a.clientX-c.left-u-l),f<0&&(f=5),this.element.style.left=`${h}px`,this.element.style.top=`${f}px`}},16);e.addEventListener("touchmove",o,{passive:!0}),this.boundHandlers.push({el:e,type:"touchmove",fn:o})}}}show(t){var r,o,s,a,c,l,h;if(this.config.enabled===!1)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i={point:t.index!==void 0?{...t.point,index:t.index}:t.point,plotX:t.plotX,plotY:t.plotY,series:{name:((o=(r=t.series)==null?void 0:r.config)==null?void 0:o.name)??((s=t.series)==null?void 0:s.name)??"",color:((c=(a=t.series)==null?void 0:a.getColor)==null?void 0:c.call(a))??((l=t.series)==null?void 0:l.color)??"#333",config:(h=t.series)==null?void 0:h.config}};if(this.config.shared){const f=i.point.x??i.plotX;if(this.sharedProvider){const u=this.sharedProvider(f);this.sharedPoints=u.length>0?u:[i]}else{this.sharedPoints.length>0&&(this.sharedPoints[0].point.x??this.sharedPoints[0].plotX)!==f&&(this.sharedPoints=[]);const d=this.sharedPoints.findIndex(p=>p.series.name===i.series.name);d>=0?this.sharedPoints[d]=i:this.sharedPoints.push(i)}}if(this.config.split){this.showSplit(i);return}if(this.element||(this.element=this.createElement()),this.config.stickOnContact&&(this.element.style.pointerEvents="auto"),this.config.borderColor===void 0){const f=i.point.color||i.series.color||"#333";this.element.style.borderColor=f}this.config.shared&&this.sharedPoints.length>0?this.element.innerHTML=this.formatSharedContent(this.sharedPoints):this.element.innerHTML=this.formatContent(i),this.config.followPointer&&this.lastMouseEvent?this.positionAtMouse(this.lastMouseEvent):this.position(i),this.element.style.display="block",this.config.animation!==!1?this.element.style.opacity="1":(this.element.style.transition="none",this.element.style.opacity="1")}hide(){this.element&&(this.element.style.opacity="0",this.element.style.display="none"),this.hideSplitElements(),this.sharedPoints=[]}scheduleHide(){const t=this.config.hideDelay??500;this.hideTimeout=setTimeout(()=>this.hide(),t)}showSplit(t){this.hideSplitElements();const e=this.formatContent(t);if(!e)return;const i=this.createSplitElement(t.series.color||"#333");i.innerHTML=e;const r=this.config.distance??16,o=this.plotArea,s=o.x+t.plotX+r,a=o.y+t.plotY;i.style.left=`${s}px`,i.style.top=`${a}px`,i.style.display="block",i.style.opacity="1",this.splitElements.push(i)}hideSplitElements(){for(const t of this.splitElements)hf(t);this.splitElements=[]}createSplitElement(t){var s,a;const e=lc("katucharts-tooltip-split",this.container),i=this.config.backgroundColor||"rgba(247,247,247,0.85)",r=this.config.borderRadius??3,o=this.config.padding??8;return Object.assign(e.style,{position:"absolute",pointerEvents:"none",zIndex:String(this.config.zIndex??10),backgroundColor:i,border:`${this.config.borderWidth??1}px solid ${t}`,borderRadius:`${r}px`,padding:`${o}px`,fontSize:((s=this.config.style)==null?void 0:s.fontSize)||"12px",color:((a=this.config.style)==null?void 0:a.color)||"#333333",boxShadow:this.config.shadow!==!1?"2px 2px 6px rgba(0,0,0,0.15)":"none",transition:this.config.animation!==!1?"opacity 0.15s":"none",whiteSpace:"nowrap",display:"none"}),e}createElement(){var a,c;const t=lc(`katucharts-tooltip${this.config.className?" "+this.config.className:""}`,this.container),e=this.config.backgroundColor||"rgba(247,247,247,0.85)",i=this.config.borderRadius??3,r=this.config.padding??8,o=this.config.shape||"callout";let s=`${i}px`;return o==="circle"&&(s="50%"),Object.assign(t.style,{position:this.config.outside?"fixed":"absolute",pointerEvents:this.config.stickOnContact?"auto":"none",zIndex:String(this.config.zIndex??10),backgroundColor:e,border:`${this.config.borderWidth??1}px solid ${this.config.borderColor||"#ccc"}`,borderRadius:s,padding:`${r}px`,fontSize:((a=this.config.style)==null?void 0:a.fontSize)||"12px",color:((c=this.config.style)==null?void 0:c.color)||"#333333",boxShadow:this.config.shadow!==!1?"2px 2px 6px rgba(0,0,0,0.15)":"none",transition:this.config.animation!==!1?"opacity 0.15s":"none",whiteSpace:"nowrap",display:"none"}),t}formatValue(t){if(t==null)return"";let e;this.config.valueDecimals!==void 0?e=t.toFixed(this.config.valueDecimals):e=String(t);const i=this.config.valuePrefix||"",r=this.config.valueSuffix||"";return`${i}${e}${r}`}resolveKey(t){let e=t.point.name??t.point.x??"";return this.categories&&typeof t.point.x=="number"&&this.categories[t.point.x]&&(e=this.categories[t.point.x]),e}getPointCategory(t){return t.category!==void 0?t.category:this.categories&&typeof t.x=="number"&&this.categories[t.x]!==void 0?this.categories[t.x]:t.name}buildFormatterPoint(t,e={}){const i=this.resolveKey(t),r=this.getPointCategory(t.point);return{...t.point,...e,key:i,category:r,color:t.point.color||t.series.color||"#333",series:{name:t.series.name||"",color:t.series.color||"#333"}}}buildFormatterContext(t,e={}){const i=this.resolveKey(t);return{point:this.buildFormatterPoint(t),series:t.series,x:t.point.x,y:t.point.y,percentage:t.point.percentage,total:t.point.total,key:i,color:t.point.color||t.series.color,...e}}formatContent(t){var k;const e=(k=t.series.config)==null?void 0:k.tooltip;if(t.point.y===null||t.point.y===void 0){const M=(e==null?void 0:e.nullFormatter)??this.config.nullFormatter,C=(e==null?void 0:e.nullFormat)??this.config.nullFormat;if(M)return M.call({point:t.point,series:t.series});if(C)return C}if(this.config.formatter){const M=this.config.formatter.call(this.buildFormatterContext(t));return M===!1?"":M}const i=this.resolveKey(t),r=t.point.name??(this.categories&&typeof t.point.x=="number"?this.categories[t.point.x]:void 0)??i,o=(e==null?void 0:e.valueDecimals)??this.config.valueDecimals,s=(e==null?void 0:e.valuePrefix)??this.config.valuePrefix??"",a=(e==null?void 0:e.valueSuffix)??this.config.valueSuffix??"",c=this.formatValueWith(t.point.y,o,s,a);let l=r;const h=(e==null?void 0:e.xDateFormat)??this.config.xDateFormat??(this.isDatetime?qr.DEFAULT_DATE_FORMAT:void 0);h&&typeof t.point.x=="number"&&t.point.name===void 0&&(l=sc(h,t.point.x));const f={point:this.buildFormatterPoint(t,{name:r,key:l,y:c||t.point.y}),series:{...t.series,name:t.series.name||""}},u=(e==null?void 0:e.pointFormatter)??this.config.pointFormatter;if(u){const M=u.call(this.buildFormatterContext(t)),C=(e==null?void 0:e.headerFormat)??this.config.headerFormat??"",E=(e==null?void 0:e.footerFormat)??this.config.footerFormat??"";return Kt(C,f,!0)+M+Kt(E,f,!0)}if(this.config.format)return Kt(this.config.format,f,!0);const d=(e==null?void 0:e.headerFormat)??this.config.headerFormat??"",p=(e==null?void 0:e.pointFormat)??this.config.pointFormat??"",y=(e==null?void 0:e.footerFormat)??this.config.footerFormat??"",g=Kt(d,f,!0),m=Kt(p,f,!0),x=Kt(y,f,!0);let v="";const b=!!((e==null?void 0:e.pointFormat)??this.config.pointFormat);if(t.point.total!==void 0&&!y&&!b){const M=t.point.total,C=Math.round(M*1e6)/1e6;v=`<span style="font-size:10px">Total: <b>${this.formatValue(C)}</b></span><br/>`}return g+m+x+v}formatValueWith(t,e,i,r){if(t==null)return"";let o;return e!==void 0?o=t.toFixed(e):o=String(t),`${i||""}${o}${r||""}`}formatSharedContent(t){var r,o,s,a;if(this.config.formatter){const c=t[0],l=c?this.resolveKey(c):"",h=this.config.formatter.call({point:c?this.buildFormatterPoint(c):void 0,series:c==null?void 0:c.series,x:c==null?void 0:c.point.x,y:c==null?void 0:c.point.y,key:l,color:(c==null?void 0:c.point.color)||(c==null?void 0:c.series.color),points:t.map(f=>({point:this.buildFormatterPoint(f),series:f.series,x:f.point.x,y:f.point.y,percentage:f.point.percentage,total:f.point.total,key:this.resolveKey(f),color:f.point.color||f.series.color}))});return h===!1?"":h}const e=[],i=this.formatXKey((r=t[0])==null?void 0:r.point,(s=(o=t[0])==null?void 0:o.series.config)==null?void 0:s.tooltip);i!==""&&e.push(`<span style="font-size:10px">${Jn(String(i))}</span><br/>`);for(const c of t){const l=(a=c.series.config)==null?void 0:a.tooltip,h=l==null?void 0:l.pointFormat;if(h){const p={point:this.buildFormatterPoint(c),series:{...c.series,name:c.series.name||""}};e.push(Kt(h,p,!0));continue}const f=af(c.point.color||c.series.color||"#333"),u=Jn(c.series.name||""),d=this.formatValue(c.point.y);e.push(`<span style="color:${f}">●</span> ${u}: <b>${d}</b><br/>`)}return e.join("")}position(t){var h,f;if(!this.element)return;if(this.config.positioner){const u=this.config.positioner(this.element.offsetWidth,this.element.offsetHeight,t);this.element.style.left=`${u.x}px`,this.element.style.top=`${u.y}px`;return}const e=this.config.distance??16,i=this.plotArea;let r=i.x+t.plotX+e,o=i.y+t.plotY-10;const s=this.element.offsetWidth||120,a=this.element.offsetHeight||50,c=this.config.outside?window.innerWidth:this.container.offsetWidth||((h=this.container.parentElement)==null?void 0:h.offsetWidth)||800,l=this.config.outside?window.innerHeight:this.container.offsetHeight||((f=this.container.parentElement)==null?void 0:f.offsetHeight)||600;r+s>c&&(r=i.x+t.plotX-s-e),o+a>l&&(o=l-a-5),o<0&&(o=5),r<0&&(r=5),this.element.style.left=`${r}px`,this.element.style.top=`${o}px`}positionAtMouse(t){if(!this.element)return;const e=this.config.distance??16;if(this.config.outside){let c=t.clientX+e,l=t.clientY-10;const h=this.element.offsetWidth||120,f=this.element.offsetHeight||50;c+h>window.innerWidth&&(c=t.clientX-h-e),l+f>window.innerHeight&&(l=window.innerHeight-f-5),l<0&&(l=5),c<0&&(c=5),this.element.style.left=`${c}px`,this.element.style.top=`${l}px`;return}const i=this.container.getBoundingClientRect();let r=t.clientX-i.left+e,o=t.clientY-i.top-10;const s=this.element.offsetWidth||120,a=this.element.offsetHeight||50;r+s>i.width&&(r=t.clientX-i.left-s-e),o+a>i.height&&(o=i.height-a-5),o<0&&(o=5),r<0&&(r=5),this.element.style.left=`${r}px`,this.element.style.top=`${o}px`}updatePlotArea(t){this.plotArea=t}setCategories(t){this.categories=t}setDatetimeAxis(t){this.isDatetime=t}setSharedPointsProvider(t){this.sharedProvider=t}formatXKey(t,e){if(!t)return"";if(this.categories&&typeof t.x=="number"&&this.categories[t.x]!==void 0)return this.categories[t.x];if(t.name!==void 0&&t.name!==null)return t.name;const i=t.x;if(typeof i=="number"){const r=(e==null?void 0:e.xDateFormat)??this.config.xDateFormat??(this.isDatetime?qr.DEFAULT_DATE_FORMAT:void 0);if(r)return sc(r,i)}return i??""}destroy(){this.hideTimeout&&clearTimeout(this.hideTimeout);for(const{el:t,type:e,fn:i}of this.boundHandlers)t.removeEventListener(e,i);this.boundHandlers=[],hf(this.element),this.element=null,this.hideSplitElements()}};qr.DEFAULT_DATE_FORMAT="%A, %b %e, %Y";let rs=qr;class os{constructor(t,e,i){this.series=[],this.scrollOffset=0,this.contentHeight=0,this.visibleHeight=0,this.config=t,this.events=i,t.enabled!==!1&&(this.group=e.append("g").attr("class",`katucharts-legend${t.className?" "+t.className:""}`))}autoText(){return gn(this.config._backgroundColor)}resolveLabel(t){var r;const e=t.getColor();let i;if(this.config.labelFormatter)i=this.config.labelFormatter.call({name:t.config.name||"",color:e,percentage:t.percentage,total:t.total,index:t.config.index,legendIndex:t.config.legendIndex,options:t.config});else if(this.config.labelFormat){const o={name:t.config.name||"",color:e,index:t.config.index,legendIndex:t.config.legendIndex};i=oe(Kt(this.config.labelFormat,o))}else i=t.config.name||`Series ${t.config.index+1}`;if(this.config.valueSuffix&&(i+=` ${this.config.valueSuffix}`),this.config.valueDecimals!==void 0&&this.config.valueDecimals>=0){const o=t.data.length>0?(r=t.data[t.data.length-1])==null?void 0:r.y:void 0;typeof o=="number"&&(i+=`: ${o.toFixed(this.config.valueDecimals)}`)}return i}computeAutoFontSize(t,e){return e||kt}estimateTextWidth(t,e){const i=me(e);return t.length*i*.62}static computeGridLayout(t,e,i,r){if(r.itemWidth)return{columns:Math.max(2,Math.floor(i/r.itemWidth)),itemWidth:r.itemWidth};const o=me(r.fontSize);let s=0;for(const l of e){const h=l.length*o*.62;h>s&&(s=h)}const a=r.symbolWidth+r.symbolPadding+s+8;return{columns:Math.max(1,Math.floor(i/a)),itemWidth:a}}render(t,e){var et,ht,ft,ct;if(this.config.enabled===!1||!this.group)return;this.series=t,this.group.selectAll("*").remove();let i=t.filter(nt=>nt.config.showInLegend!==!1);if(i.length===0)return;this.config.reversed&&(i=[...i].reverse());const r=this.config.layout||"horizontal",o=this.config.padding??8,s=this.config.symbolWidth??12,a=this.config.symbolHeight??12,c=this.config.symbolPadding??5,l=this.config.symbolRadius??2,h=this.config.squareSymbol!==!1,f=this.config.itemDistance??20,u=this.config.itemStyle||{},d=this.config.itemMarginTop??0,p=this.config.itemMarginBottom??4,y=this.config.lineHeight??16,g=this.config.maxHeight,m=this.config.width,x=u.fontSize||kt,v=this.computeAutoFontSize(i.length,x);let b=o,k=o,M=0;if((et=this.config.title)!=null&&et.text){const nt=this.config.title.style||{};this.group.append("text").attr("class","katucharts-legend-title").attr("x",o).attr("y",o+10).attr("font-size",nt.fontSize||kt).attr("font-weight",nt.fontWeight||"bold").attr("fill",nt.color||"#333").text(this.config.title.text),k+=20}const C=k,E=m||e.width-o*2,_=y+p+d,T=[];for(const nt of i){const U=nt.getMultiLegendItems(),at=["line","spline","area","areaspline","radar","polar"].includes(nt.config._internalType);U?U.forEach((yt,St)=>{T.push({label:yt.label,color:yt.color,series:nt,isLine:at,multiIndex:St,visible:yt.visible!==!1})}):T.push({label:this.resolveLabel(nt),color:nt.getColor(),series:nt,isLine:at,visible:nt.visible})}const I=T.map(nt=>nt.label);let L=0;if(r==="horizontal")for(let nt=0;nt<I.length;nt++){const U=s+c+this.estimateTextWidth(I[nt],v);L+=U+(nt<I.length-1?f:0)}const P=r==="horizontal"&&T.length>8&&L>E;let A=0,w=0;const S=6;let $=0,R=0;if(P){const nt=os.computeGridLayout(T.length,I,E,{symbolWidth:s,symbolPadding:c,fontSize:v,itemDistance:f,padding:o,itemWidth:this.config.itemWidth});A=nt.columns,w=nt.itemWidth,R=Math.ceil(T.length/A)}const F=[];T.forEach((nt,U)=>{var ge;const at=nt.series,yt=nt.color,St=nt.isLine,Mt=nt.label;let Et=nt.visible,Ht,ne;if(P){const Vt=U%A,Ut=Math.floor(U/A),Xe=A*w,se=Math.max(0,(E-Xe)/2);Ht=o+se+Vt*w,ne=C+Ut*_+d}else if(r==="horizontal"){const Vt=this.config.itemWidth||this.estimateTextWidth(Mt,v),Ut=s+c+Vt;U>0&&b+Ut>E&&(b=o,k+=_),Ht=b,ne=k+d,M=Math.max(M,b+Ut),b+=Ut+f}else{const Vt=this.config.itemWidth||this.estimateTextWidth(Mt,v),Ut=s+c+Vt;Ht=b,ne=k+d,M=Math.max(M,b+Ut),b=o,k+=_}const Ct=this.group.append("g").attr("class","katucharts-legend-item").attr("transform",`translate(${Ht},${ne})`).style("cursor","pointer"),Zt=at.getLegendSymbolShape();if(St)Ct.append("line").attr("x1",0).attr("x2",s).attr("y1",6).attr("y2",6).attr("stroke",yt).attr("stroke-width",2),Ct.append("circle").attr("cx",s/2).attr("cy",6).attr("r",3).attr("fill",yt);else if(Zt){const Vt=s/2,Ut=a/2,Xe=Math.min(s,a)/2;Zt==="circle"?Ct.append("circle").attr("cx",Vt).attr("cy",Ut).attr("r",Xe).attr("fill",yt):Zt==="square"?Ct.append("rect").attr("x",0).attr("y",0).attr("width",s).attr("height",a).attr("fill",yt):Zt==="diamond"?Ct.append("path").attr("d",`M ${Vt} 0 L ${s} ${Ut} L ${Vt} ${a} L 0 ${Ut} Z`).attr("fill",yt):Zt==="triangle"?Ct.append("path").attr("d",`M ${Vt} 0 L ${s} ${a} L 0 ${a} Z`).attr("fill",yt):Zt==="triangle-down"?Ct.append("path").attr("d",`M 0 0 L ${s} 0 L ${Vt} ${a} Z`).attr("fill",yt):Zt==="cross"?Ct.append("path").attr("d",`M 0 ${Ut} L ${s} ${Ut} M ${Vt} 0 L ${Vt} ${a}`).attr("stroke",yt).attr("stroke-width",2):Ct.append("circle").attr("cx",Vt).attr("cy",Ut).attr("r",Xe).attr("fill",yt)}else h?Ct.append("rect").attr("x",0).attr("y",0).attr("width",s).attr("height",a).attr("rx",l).attr("fill",yt):Ct.append("circle").attr("cx",s/2).attr("cy",a/2).attr("r",Math.min(s,a)/2).attr("fill",yt);const Qt=Ct.append("text").attr("x",s+c).attr("y",10).attr("fill",Et?u.color||this.autoText():((ge=this.config.itemHiddenStyle)==null?void 0:ge.color)||"#cccccc").attr("font-size",v).attr("font-weight",u.fontWeight||"normal").text(Mt);this.config.rtl&&(Qt.attr("text-anchor","end").attr("x",-c),Ct.select("rect, circle, line").attr("transform",`translate(${-(s+c)}, 0)`)),Ct.on("click",()=>{var se,hn,vn;const Vt=this.config.events;if(Vt!=null&&Vt.itemClick&&Vt.itemClick.call(at,new Event("legendItemClick"))===!1)return;const Ut=nt.multiIndex!==void 0?at.toggleLegendItem(nt.multiIndex):null;Ut===null?(at.toggleVisible(),Et=at.visible):Et=Ut,Qt.attr("fill",Et?u.color||this.autoText():((se=this.config.itemHiddenStyle)==null?void 0:se.color)||"#cccccc"),((vn=(hn=at.config.events)==null?void 0:hn.legendItemClick)==null?void 0:vn.call(at,new Event("legendItemClick")))!==!1&&this.events.emit("legend:itemClick",at,U)}),Ct.on("mouseover",()=>{var Vt;Qt.attr("fill",((Vt=this.config.itemHoverStyle)==null?void 0:Vt.color)||this.autoText()),this.events.emit("legend:itemHover",at)}),Ct.on("mouseout",()=>{var Vt;Qt.attr("fill",Et?u.color||this.autoText():((Vt=this.config.itemHiddenStyle)==null?void 0:Vt.color)||"#cccccc"),this.events.emit("legend:itemLeave")}),F.push(Ct)});let D=0,z=0,B=0,W=0;const K=(ht=this.config.bubbleLegend)!=null&&ht.enabled?t.map(nt=>nt.getBubbleLegendInfo()).find(nt=>!!nt):void 0;if(K)if(r==="horizontal"&&((ft=this.config.bubbleLegend)==null?void 0:ft.layout)==="separate"){W=T.length?k+_:C;const U=this.renderBubbleLegend(K,0,W);D=U.width,z=U.height;const at=T.length?Math.max(0,M-o):0,yt=Math.max(at,D);B=o+Math.max(0,(yt-D)/2),this.group.select(".katucharts-bubble-legend").attr("transform",`translate(${B},0)`);const St=Math.max(0,(yt-at)/2);if(St>0)for(const Mt of F){const Et=/translate\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)/.exec(Mt.attr("transform")||"");Et&&Mt.attr("transform",`translate(${parseFloat(Et[1])+St},${Et[2]})`)}}else{r==="horizontal"?(B=T.length?M+f:o,W=C):(B=o,W=T.length?k+6:C);const U=this.renderBubbleLegend(K,B,W);D=U.width,z=U.height}const X=(nt,U=!1)=>{const at=nt*S,yt=at+S;F.forEach((St,Mt)=>{const Et=Math.floor(Mt/A);if(Et>=at&&Et<yt){const ne=Mt%A,Ct=A*w,Zt=Math.max(0,(E-Ct)/2),Qt=o+Zt+ne*w,ge=C+(Et-at)*_+(this.config.itemMarginTop??0);St.style("display","block"),U?St.style("opacity","0").attr("transform",`translate(${Qt},${ge})`).transition().duration(250).style("opacity","1"):St.attr("transform",`translate(${Qt},${ge})`).style("opacity","1")}else U?St.transition().duration(150).style("opacity","0").on("end",function(){St.style("display","none")}):St.style("display","none")})};let q,N;if(P){const nt=Math.min(R,S);if(q=E+o*2,N=C+nt*_+o,R>S){X(0);const U=Math.ceil(R/S),at=E-20,yt=C+Math.min(R,S)*_/2,St=this.group.append("g").attr("class","katucharts-legend-nav"),Mt=22,Et=St.append("g").attr("transform",`translate(${at},${yt-Mt-2})`).style("cursor","pointer").style("opacity","0.3");Et.append("rect").attr("x",0).attr("y",0).attr("width",Mt).attr("height",Mt).attr("rx",4).attr("fill","#f0f0f0").attr("stroke","#ccc").attr("stroke-width",1),Et.append("path").attr("d",`M${Mt/2-5},${Mt/2+2} L${Mt/2},${Mt/2-4} L${Mt/2+5},${Mt/2+2}`).attr("fill","none").attr("stroke","#555").attr("stroke-width",2).attr("stroke-linecap","round"),Et.on("mouseover",function(){Et.select("rect").attr("fill","#e0e0e0")}),Et.on("mouseout",function(){Et.select("rect").attr("fill","#f0f0f0")});const Ht=St.append("g").attr("transform",`translate(${at},${yt+2})`).style("cursor","pointer");Ht.append("rect").attr("x",0).attr("y",0).attr("width",Mt).attr("height",Mt).attr("rx",4).attr("fill","#f0f0f0").attr("stroke","#ccc").attr("stroke-width",1),Ht.append("path").attr("d",`M${Mt/2-5},${Mt/2-2} L${Mt/2},${Mt/2+4} L${Mt/2+5},${Mt/2-2}`).attr("fill","none").attr("stroke","#555").attr("stroke-width",2).attr("stroke-linecap","round"),Ht.on("mouseover",function(){Ht.select("rect").attr("fill","#e0e0e0")}),Ht.on("mouseout",function(){Ht.select("rect").attr("fill","#f0f0f0")}),Et.on("click",()=>{$>0&&($--,X($,!0),Et.style("opacity",$===0?"0.3":"1"),Ht.style("opacity",$>=U-1?"0.3":"1"))}),Ht.on("click",()=>{$<U-1&&($++,X($,!0),Et.style("opacity",$===0?"0.3":"1"),Ht.style("opacity",$>=U-1?"0.3":"1"))})}}else r==="horizontal"?(q=M+o,N=k+y+o):(q=m||M+o||150,N=k+y+o);if(K&&(q=Math.max(q,B+D+o),N=Math.max(N,W+z+o)),this.contentHeight=N,this.config.backgroundColor||this.config.borderWidth||this.config.shadow){const nt=this.group.insert("rect",":first-child").attr("class","katucharts-legend-bg").attr("x",0).attr("y",0).attr("width",q).attr("height",g?Math.min(N,g):N).attr("rx",this.config.borderRadius??0).attr("fill",this.config.backgroundColor||"none").attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0);this.config.shadow&&nt.attr("filter","drop-shadow(2px 2px 4px rgba(0,0,0,0.15))")}if(g&&N>g){this.visibleHeight=g;const nt=`katucharts-legend-clip-${Math.random().toString(36).slice(2,8)}`;this.group.append("defs").append("clipPath").attr("id",nt).append("rect").attr("width",q).attr("height",g),this.group.attr("clip-path",`url(#${nt})`),((ct=this.config.navigation)==null?void 0:ct.enabled)!==!1&&this.renderNavigationArrows(q,g)}const H=this.config.maxWidth?Math.min(q,this.config.maxWidth):q,Y=this.config.align||"center",G=r==="vertical"&&(Y==="left"||Y==="right");let Q;G?Q=e.x+2:Y==="center"?Q=e.x+(e.width-H)/2:Y==="right"?Q=e.x+e.width-H:Q=e.x;let O=e.y+(this.config.y||0);(G||this.config.verticalAlign==="middle")&&(O=e.y+Math.max(0,(e.height-N)/2)+(this.config.y||0));const it=Q+(this.config.x||0);this.group.attr("transform",`translate(${it},${O})`),this.config.floating&&this.group.style("pointer-events","all")}renderNavigationArrows(t,e){const i=this.config.navigation||{},r=i.activeColor||"#003399",o=i.inactiveColor||"#cccccc",s=i.arrowSize??12,a=this.group.append("g").attr("class","katucharts-legend-nav-up").attr("transform",`translate(${t/2},2)`).style("cursor","pointer");a.append("path").attr("d",`M${-s/2},${s/2} L0,${-s/2} L${s/2},${s/2}`).attr("fill",this.scrollOffset>0?r:o).attr("stroke","none"),a.on("click",()=>{this.scrollOffset>0&&(this.scrollOffset=Math.max(0,this.scrollOffset-40),this.applyScroll())});const c=this.group.append("g").attr("class","katucharts-legend-nav-down").attr("transform",`translate(${t/2},${e-2})`).style("cursor","pointer");c.append("path").attr("d",`M${-s/2},${-s/2} L0,${s/2} L${s/2},${-s/2}`).attr("fill",this.contentHeight>e+this.scrollOffset?r:o).attr("stroke","none"),c.on("click",()=>{const l=this.contentHeight-this.visibleHeight;this.scrollOffset<l&&(this.scrollOffset=Math.min(l,this.scrollOffset+40),this.applyScroll())})}applyScroll(){const t=this.scrollOffset;this.group.selectAll(".katucharts-legend-item").each(function(){const e=this,r=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);if(r){const o=parseFloat(e.getAttribute("data-orig-y")||r[2]);e.hasAttribute("data-orig-y")||e.setAttribute("data-orig-y",r[2]),e.setAttribute("transform",`translate(${r[1]},${o-t})`)}})}renderBubbleLegend(t,e,i){var b,k,M,C,E,_;const r=this.config.bubbleLegend||{};if(r.layout==="separate")return this.renderBubbleLegendSeparate(t,e,i);const o=[...t.ranges].sort((T,I)=>I.radius-T.radius),s=o[0].radius;if(!(s>0))return{width:0,height:0};const a=((k=(b=r.labels)==null?void 0:b.style)==null?void 0:k.fontSize)||kt,c=r.borderColor||t.color,l=r.borderWidth??1.5,h=r.color||"rgba(0,0,0,0)",f=r.connectorColor||c,u=r.connectorWidth??1,d=r.connectorDistance??16,p=((C=(M=r.labels)==null?void 0:M.style)==null?void 0:C.color)||Le,y=this.group.append("g").attr("class","katucharts-bubble-legend"),g=e+s,m=i+2*s,x=e+2*s+d;let v=0;for(const T of o){const I=m-2*T.radius;y.append("circle").attr("cx",g).attr("cy",m-T.radius).attr("r",T.radius).attr("fill",h).attr("stroke",c).attr("stroke-width",l),y.append("line").attr("x1",g).attr("y1",I).attr("x2",x).attr("y2",I).attr("stroke",f).attr("stroke-width",u).attr("stroke-dasharray","2,2");let L;(E=r.labels)!=null&&E.formatter?L=r.labels.formatter.call({value:T.value}):(_=r.labels)!=null&&_.format?L=oe(Kt(r.labels.format,{value:T.value})):L=String(T.value),y.append("text").attr("x",x+4).attr("y",I).attr("dominant-baseline","middle").attr("font-size",a).attr("fill",p).text(L),v=Math.max(v,this.estimateTextWidth(L,a))}return{width:2*s+d+v+8,height:2*s}}renderBubbleLegendSeparate(t,e,i){var M,C,E,_;const r=this.config.bubbleLegend||{},o=[...t.ranges].sort((T,I)=>T.radius-I.radius),s=o[o.length-1].radius;if(!(s>0))return{width:0,height:0};const a=((C=(M=r.labels)==null?void 0:M.style)==null?void 0:C.fontSize)||kt,c=parseFloat(a)||12,l=r.borderColor||t.color,h=r.borderWidth??1.5,f=r.color||"rgba(0,0,0,0)",u=((_=(E=r.labels)==null?void 0:E.style)==null?void 0:_.color)||Le,d=r.connectorDistance??8,p=T=>{var I,L;return(I=r.labels)!=null&&I.formatter?r.labels.formatter.call({value:T}):(L=r.labels)!=null&&L.format?oe(Kt(r.labels.format,{value:T})):String(T)},y=this.group.append("g").attr("class","katucharts-bubble-legend"),g=(T,I,L)=>y.append("circle").attr("cx",T).attr("cy",I).attr("r",L).attr("fill",f).attr("stroke",l).attr("stroke-width",h);if(this.config.layout==="horizontal"){const T=c+6,I=i+T+2*s;let L=e;for(const P of o){const A=L+P.radius,w=I-2*P.radius;g(A,I-P.radius,P.radius);const S=p(P.value);y.append("text").attr("x",A).attr("y",w-4).attr("text-anchor","middle").attr("font-size",a).attr("fill",u).text(S);const $=Math.max(2*P.radius,this.estimateTextWidth(S,a));L+=$+d+6}return{width:Math.max(0,L-e-(d+6)),height:T+2*s}}const m=e+s,x=e+2*s+d;let v=i,b=0;const k=10;for(const T of o){const I=v+T.radius;g(m,I,T.radius);const L=p(T.value);y.append("text").attr("x",x).attr("y",I).attr("dominant-baseline","middle").attr("font-size",a).attr("fill",u).text(L),b=Math.max(b,this.estimateTextWidth(L,a)),v+=2*T.radius+k}return{width:2*s+d+b+8,height:Math.max(0,v-i-k)}}destroy(){this.group&&this.group.remove()}}class uf{constructor(t,e,i,r,o){var h,f;if(this.xLine=null,this.yLine=null,this.xLabel=null,this.yLabel=null,this.plotArea=r,t){const u=typeof t=="object"?t:{},d=this.getDashArray(u.dashStyle);this.xLine=i.append("line").attr("class",`katucharts-crosshair-x${u.className?" "+u.className:""}`).attr("y1",0).attr("y2",r.height).attr("stroke",u.color||"#ccc").attr("stroke-width",u.width||1).attr("stroke-dasharray",d).style("display","none"),u.zIndex!==void 0&&this.xLine.style("z-index",u.zIndex),(h=u.label)!=null&&h.enabled&&(this.xLabel=this.createLabel(i,u.label,"x"))}if(e){const u=typeof e=="object"?e:{},d=this.getDashArray(u.dashStyle);this.yLine=i.append("line").attr("class",`katucharts-crosshair-y${u.className?" "+u.className:""}`).attr("x1",0).attr("x2",r.width).attr("stroke",u.color||"#ccc").attr("stroke-width",u.width||1).attr("stroke-dasharray",d).style("display","none"),u.zIndex!==void 0&&this.yLine.style("z-index",u.zIndex),(f=u.label)!=null&&f.enabled&&(this.yLabel=this.createLabel(i,u.label,"y"))}const s=typeof t=="object"?t:{},a=typeof e=="object"?e:{},c=s.snap!==!1,l=a.snap!==!1;o.on("point:mouseover",u=>{var d,p,y,g;if(this.xLine){const m=c?u.plotX:((d=u.event)==null?void 0:d.offsetX)??u.plotX;this.xLine.attr("x1",m).attr("x2",m).style("display",null),this.xLabel&&this.updateLabel(this.xLabel,s.label,((p=u.point)==null?void 0:p.x)??u.plotX,m,r.height+2,"x")}if(this.yLine){const m=l?u.plotY:((y=u.event)==null?void 0:y.offsetY)??u.plotY;this.yLine.attr("y1",m).attr("y2",m).style("display",null),this.yLabel&&this.updateLabel(this.yLabel,a.label,((g=u.point)==null?void 0:g.y)??u.plotY,-2,m,"y")}}),o.on("point:mouseout",()=>{this.xLine&&this.xLine.style("display","none"),this.yLine&&this.yLine.style("display","none"),this.xLabel&&this.xLabel.style("display","none"),this.yLabel&&this.yLabel.style("display","none")})}getDashArray(t){return t&&{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t]||"none"}createLabel(t,e,i){var o,s;const r=t.append("g").attr("class",`katucharts-crosshair-label-${i}`).style("display","none");return r.append("rect").attr("rx",e.borderRadius??3).attr("fill",e.backgroundColor||"rgba(0,0,0,0.75)").attr("stroke",e.borderColor||"none").attr("stroke-width",e.borderWidth??0),r.append("text").attr("fill",((o=e.style)==null?void 0:o.color)||"#fff").attr("font-size",((s=e.style)==null?void 0:s.fontSize)||"10px").attr("text-anchor","middle").attr("dominant-baseline","central"),r}updateLabel(t,e,i,r,o,s){var f;t.style("display",null);let a;e.formatter?a=e.formatter.call({value:i}):e.format?a=e.format.replace("{value}",String(i)):a=typeof i=="number"?i.toFixed(2):String(i);const c=e.padding??4,l=t.select("text");l.text(a).attr("x",r).attr("y",o);const h=(f=l.node())==null?void 0:f.getBBox();h&&t.select("rect").attr("x",h.x-c).attr("y",h.y-c).attr("width",h.width+c*2).attr("height",h.height+c*2)}destroy(){this.xLine&&this.xLine.remove(),this.yLine&&this.yLine.remove(),this.xLabel&&this.xLabel.remove(),this.yLabel&&this.yLabel.remove()}}const ff="Powered by: KatuCharts",Rv="https://charts.katudv.com",df="#707070",Dv="#b0b0b0";function zv(n){return gn(n)==="#ffffff"?Dv:df}class Bv{constructor(t,e,i,r){this.element=null,this.observer=null,this.intervalId=null,this.unsubscribe=null,this.svg=e,this.chartWidth=i,this.chartHeight=r,this.config=t,this.apply(),this.unsubscribe=tn.onChange(()=>this.apply())}apply(){const t=tn.isLicensed();if(this.config.enabled===!1&&t){this.stopProtection(),this.element&&(this.element.remove(),this.element=null);return}this.render(this.config),t?this.stopProtection():this.startProtection()}updatePosition(t,e){this.chartWidth=t,this.chartHeight=e,!(this.config.enabled===!1&&tn.isLicensed())&&this.render(this.config)}render(t){var u,d;this.element&&(this.element.remove(),this.element=null);const i=!tn.isLicensed()&&(!(t!=null&&t.text)||!t.text.trim())?ff:(t==null?void 0:t.text)||ff,r=(t==null?void 0:t.href)??Rv,o=(t==null?void 0:t.position)||{},s=o.align||"right",a=o.verticalAlign||"bottom";let c,l;s==="left"?(c=o.x??10,l="start"):s==="center"?(c=this.chartWidth/2+(o.x??0),l="middle"):(c=this.chartWidth+(o.x??-10),l="end");let h;a==="top"?h=o.y??15:a==="middle"?h=this.chartHeight/2+(o.y??0):h=this.chartHeight+(o.y??-5);const f=(u=t==null?void 0:t.style)==null?void 0:u.color;if(this.element=this.svg.append("text").attr("class","katucharts-credits").attr("x",c).attr("y",h).attr("text-anchor",l).attr("fill",f||df).attr("font-size",((d=t==null?void 0:t.style)==null?void 0:d.fontSize)||"9px").style("cursor",r?"pointer":"default").text(i),t!=null&&t.style){const p=t.style;p.fontFamily&&this.element.attr("font-family",p.fontFamily),p.fontWeight&&this.element.attr("font-weight",p.fontWeight),p.textDecoration&&this.element.style("text-decoration",p.textDecoration)}if(!f){const p=this.resolveBehindColor()||this.resolvePageBackground();this.element.attr("fill",zv(p))}r&&this.element.on("click",()=>{/^https?:\/\//i.test(r)&&window.open(r,"_blank","noopener,noreferrer")})}refresh(){this.config.enabled===!1&&tn.isLicensed()||this.render(this.config)}resolveBehindColor(){var t;try{const e=(t=this.element)==null?void 0:t.node(),i=this.svg.node();if(!e||!i)return null;const r=e.getBoundingClientRect();if(!r.width||!r.height)return null;const o=r.left+r.width/2,s=r.top+r.height/2;let a=null;return i.querySelectorAll("rect, path, circle, polygon, ellipse").forEach(c=>{const l=c.getAttribute("class")||"";if(/katucharts-(credits|export|border)/.test(l))return;const h=this.elementFill(c);if(!h)return;const f=c.getBoundingClientRect();o>=f.left&&o<=f.right&&s>=f.top&&s<=f.bottom&&(a=h)}),a}catch{return null}}resolvePageBackground(){try{let t=this.svg.node();for(;t;){if(typeof getComputedStyle=="function"){const e=getComputedStyle(t).backgroundColor,i=e?ce(e):null;if(i&&i.opacity>0)return e}t=t.parentElement}}catch{}return"#ffffff"}elementFill(t){var o;const e=t.tagName.toLowerCase();if(e==="text"||e==="tspan")return null;let i=t.getAttribute("fill");if(!i||i==="none"){const s=(o=t.style)==null?void 0:o.fill;i=s&&s!=="none"?s:null}if(!i||i==="none"||i.indexOf("url(")===0)return null;const r=ce(i);return!r||r.opacity===0?null:i}startProtection(){if(tn.isLicensed()||this.observer||this.intervalId!=null||typeof MutationObserver>"u")return;const t=this.svg.node();t&&(this.observer=new MutationObserver(()=>{t.querySelector(".katucharts-credits")||this.render()}),this.observer.observe(t,{childList:!0}),typeof window<"u"&&(this.intervalId=window.setInterval(()=>{t.querySelector(".katucharts-credits")||this.render()},3e3)))}stopProtection(){var t;(t=this.observer)==null||t.disconnect(),this.observer=null,this.intervalId!=null&&(clearInterval(this.intervalId),this.intervalId=null)}destroy(){var t;(t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.stopProtection(),this.element&&this.element.remove(),this.element=null}}const Hi=["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5"],Ov={downloadPNG:Hi,downloadJPEG:Hi,downloadSVG:Hi,downloadPDF:Hi,downloadCSV:Hi,downloadXLS:Hi,viewDataTable:["M3 3h18v18H3z","M12 3v18","M3 9h18","M3 15h18"],viewFullScreen:["M8 3H5a2 2 0 0 0-2 2v3","M21 8V5a2 2 0 0 0-2-2h-3","M3 16v3a2 2 0 0 0 2 2h3","M16 21h3a2 2 0 0 0 2-2v-3"],printChart:["M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2","M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6","M6 14h12v8H6z"]},Nv={downloadPNG:"PNG",downloadJPEG:"JPG",downloadSVG:"SVG",downloadPDF:"PDF",downloadCSV:"CSV",downloadXLS:"XLS"},Wv={downloadPNG:"Download PNG",downloadJPEG:"Download JPEG",downloadSVG:"Download SVG",downloadPDF:"Download PDF",downloadCSV:"Download CSV",downloadXLS:"Download XLS",viewDataTable:"Data table",viewFullScreen:"Fullscreen",printChart:"Print"};class pf{constructor(t,e,i,r,o,s){var b;this.group=null,this.gearGroup=null,this.radialContainer=null,this.isOpen=!1,this.outsideClickHandler=null,this.scrollHandler=null,this.btnCenterX=0,this.btnCenterY=0,this.config=t,this.container=i,this.chartWidth=r,this.chartHeight=o,this.onExport=s;const a=(b=t.buttons)==null?void 0:b.contextButton;if((a==null?void 0:a.enabled)===!1)return;const c=(a==null?void 0:a.theme)||{},l=c.width??28,h=c.height??22,f=r+((a==null?void 0:a.x)??-10)-l,u=(a==null?void 0:a.y)??10,d=(a==null?void 0:a.symbolStroke)??"#666666",p=(a==null?void 0:a.symbolStrokeWidth)??3,y=(a==null?void 0:a.symbolFill)??d,g=c.fill??"transparent",m=c.stroke??"none",x=c.r??3;c["states.hover.fill"],this.btnCenterX=f+l/2,this.btnCenterY=u+h/2,this.group=e.append("g").attr("class","katucharts-export-button-group").attr("transform",`translate(${f},${u})`).style("cursor","pointer"),this.group.append("rect").attr("class","katucharts-export-btn-bg").attr("width",l).attr("height",h).attr("rx",x).attr("fill",g).attr("stroke",m),c.padding!==void 0&&this.group.select(".katucharts-export-btn-bg").attr("x",-c.padding).attr("y",-c.padding).attr("width",l+c.padding*2).attr("height",h+c.padding*2);const v=a==null?void 0:a.symbol;if(this.gearGroup=this.group.append("g").attr("class","katucharts-gear-icon").style("transform-origin",`${l/2}px ${h/2}px`).style("transition","transform 0.4s cubic-bezier(0.4, 0, 0.2, 1)"),v==="circle")this.gearGroup.append("circle").attr("cx",l/2).attr("cy",h/2).attr("r",Math.min(l,h)/3).attr("fill",y).attr("stroke",d).attr("stroke-width",p);else if(v==="menu"){const k=Math.round(l*.21),M=Math.round(l*.79);for(let C=0;C<3;C++)this.gearGroup.append("line").attr("x1",k).attr("x2",M).attr("y1",Math.round(h*.27)+C*Math.round(h*.23)).attr("y2",Math.round(h*.27)+C*Math.round(h*.23)).attr("stroke",d).attr("stroke-width",p).attr("stroke-linecap","round")}else{const k=Math.min(l,h),M=l/2,C=h/2,E=8,_=k*.44,T=k*.3,I=k*.12,L=Math.PI/(E*1.6);let P="";for(let F=0;F<E;F++){const D=F/E*Math.PI*2-Math.PI/2,z=[[T,D-L*1.2],[_+I,D-L],[_+I,D+L],[T,D+L*1.2]];for(const[B,W]of z){const K=M+Math.cos(W)*B,X=C+Math.sin(W)*B;P+=(P===""?"M":"L")+K.toFixed(2)+","+X.toFixed(2)}}P+="Z";const A=e.select("defs").empty()?e.append("defs"):e.select("defs"),w=A.append("linearGradient").attr("id","katu-gear-glass").attr("x1","0").attr("y1","0").attr("x2","1").attr("y2","1");w.append("stop").attr("offset","0%").attr("stop-color","#aaa").attr("stop-opacity","0.7"),w.append("stop").attr("offset","45%").attr("stop-color","#999").attr("stop-opacity","0.45"),w.append("stop").attr("offset","100%").attr("stop-color","#888").attr("stop-opacity","0.35");const S=A.append("radialGradient").attr("id","katu-gear-highlight").attr("cx","0.35").attr("cy","0.3").attr("r","0.65");S.append("stop").attr("offset","0%").attr("stop-color","#fff").attr("stop-opacity","0.6"),S.append("stop").attr("offset","50%").attr("stop-color","#fff").attr("stop-opacity","0.1"),S.append("stop").attr("offset","100%").attr("stop-color","#fff").attr("stop-opacity","0"),this.gearGroup.append("path").attr("d",P).attr("fill","url(#katu-gear-glass)").attr("stroke","rgba(255,255,255,0.5)").attr("stroke-width",p*.4).attr("stroke-linejoin","round").style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.15))"),this.gearGroup.append("path").attr("d",P).attr("fill","url(#katu-gear-highlight)").attr("stroke","none").style("pointer-events","none"),this.gearGroup.append("circle").attr("cx",M).attr("cy",C).attr("r",k*.15).attr("fill","rgba(255,255,255,0.6)").attr("stroke","rgba(255,255,255,0.4)").attr("stroke-width","0.5");const $=A.append("radialGradient").attr("id","katu-gear-hover-bg").attr("cx","0.4").attr("cy","0.35").attr("r","0.65");$.append("stop").attr("offset","0%").attr("stop-color","#fff").attr("stop-opacity","0.35"),$.append("stop").attr("offset","50%").attr("stop-color","#eef2ff").attr("stop-opacity","0.15"),$.append("stop").attr("offset","100%").attr("stop-color","#dde6ff").attr("stop-opacity","0.08");const R=k*.85;this.group.insert("circle",".katucharts-gear-icon").attr("class","katucharts-gear-hover-bg").attr("cx",l/2).attr("cy",h/2).attr("r",R).attr("fill","url(#katu-gear-hover-bg)").attr("stroke","rgba(255,255,255,0.6)").attr("stroke-width","1.5").style("filter","drop-shadow(0 0 10px rgba(200,225,255,0.5)) drop-shadow(0 2px 6px rgba(0,0,0,0.08))").style("opacity","0").style("transition","opacity 0.25s ease"),this.group.insert("circle",".katucharts-gear-icon").attr("class","katucharts-gear-hover-highlight").attr("cx",l/2).attr("cy",h/2).attr("r",R).attr("fill","none").attr("stroke","rgba(255,255,255,0.8)").attr("stroke-width","1.5").style("filter","drop-shadow(0 0 4px rgba(255,255,255,0.4))").style("opacity","0").style("transition","opacity 0.25s ease")}this.group.on("mouseenter",()=>{this.group.select(".katucharts-gear-hover-bg").style("opacity","1"),this.group.select(".katucharts-gear-hover-highlight").style("opacity","1")}).on("mouseleave",()=>{this.group.select(".katucharts-gear-hover-bg").style("opacity","0"),this.group.select(".katucharts-gear-hover-highlight").style("opacity","0")}).on("click",k=>{k.stopPropagation(),this.toggle()})}toggle(){this.isOpen?this.closeMenu():this.openMenu()}repositionCenter(t,e){this.btnCenterX=t,this.btnCenterY=e}openMenu(){var I;this.isOpen=!0,this.gearGroup&&this.gearGroup.style("transform","rotate(90deg)");const t=(I=this.config.buttons)==null?void 0:I.contextButton,i=((t==null?void 0:t.menuItems)??["downloadPNG","downloadJPEG","downloadSVG","downloadPDF","separator","viewFullScreen","printChart"]).filter(L=>L!=="separator").map(L=>({key:L,label:Wv[L]||L,icon:Ov[L]||[]}));this.radialContainer=document.createElement("div"),Object.assign(this.radialContainer.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",pointerEvents:"none",zIndex:"1000"});const r=64,o=document.createElement("canvas");o.width=r,o.height=r;const s=o.getContext("2d"),a=s.createImageData(r,r),c=a.data;let l=0;const h=[];for(let L=0;L<c.length;L+=4){const P=L/4%r,A=Math.floor(L/4/r),w=P/r-.5,S=A/r-.5,$=Math.sqrt(w*w+S*S),R=Math.max(0,Math.min(1,(.48-$)/.15)),F=R*R*(3-2*R),D=w*F*r,z=S*F*r;l=Math.max(l,Math.abs(D),Math.abs(z)),h.push(D,z)}l*=.5;let f=0;for(let L=0;L<c.length;L+=4)c[L]=(h[f++]/l+.5)*255,c[L+1]=(h[f++]/l+.5)*255,c[L+2]=0,c[L+3]=255;s.putImageData(a,0,0);const u=o.toDataURL(),d="http://www.w3.org/2000/svg",p=document.createElementNS(d,"svg");p.setAttribute("width","0"),p.setAttribute("height","0"),p.style.position="absolute";const y=document.createElementNS(d,"defs"),g=document.createElementNS(d,"filter");g.setAttribute("id","katu-glass-lens"),g.setAttribute("filterUnits","userSpaceOnUse"),g.setAttribute("color-interpolation-filters","sRGB"),g.setAttribute("x","0"),g.setAttribute("y","0"),g.setAttribute("width","44"),g.setAttribute("height","44");const m=document.createElementNS(d,"feImage");m.setAttributeNS("http://www.w3.org/1999/xlink","href",u),m.setAttribute("width","44"),m.setAttribute("height","44"),m.setAttribute("result","lens_map");const x=document.createElementNS(d,"feDisplacementMap");x.setAttribute("in","SourceGraphic"),x.setAttribute("in2","lens_map"),x.setAttribute("scale",String(Math.round(l/1))),x.setAttribute("xChannelSelector","R"),x.setAttribute("yChannelSelector","G"),g.appendChild(m),g.appendChild(x),y.appendChild(g),p.appendChild(y),this.radialContainer.appendChild(p),document.body.appendChild(this.radialContainer);const v=this.container.getBoundingClientRect(),b=v.left+this.btnCenterX,k=v.top+this.btnCenterY,M=76,C=i.length,E=100*(Math.PI/180),_=280*(Math.PI/180),T=this.config.menuItemDefinitions||{};i.forEach((L,P)=>{const A=C>1?E+(_-E)*(P/(C-1)):Math.PI,w=b+Math.cos(A)*M,S=k+Math.sin(A)*M,$=w-b,R=S-k,F=document.createElement("div");F.className="katucharts-radial-btn",Object.assign(F.style,{position:"absolute",left:`${b}px`,top:`${k}px`,width:"44px",height:"44px",marginLeft:"-22px",marginTop:"-22px",borderRadius:"50%",background:"linear-gradient(160deg, rgba(255,255,255,0.92) 0%, rgba(240,240,255,0.82) 40%, rgba(255,255,255,0.75) 100%)",backdropFilter:"url(#katu-glass-lens) blur(0.5px) contrast(1.15) brightness(1.05) saturate(1.2)",WebkitBackdropFilter:"url(#katu-glass-lens) blur(0.5px) contrast(1.15) brightness(1.05) saturate(1.2)",border:"1.5px solid rgba(255, 255, 255, 0.4)",borderTopColor:"rgba(255, 255, 255, 0.8)",borderLeftColor:"rgba(255, 255, 255, 0.55)",borderBottomColor:"rgba(0, 0, 0, 0.04)",borderRightColor:"rgba(0, 0, 0, 0.02)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transform:"translate(0px, 0px) scale(0.3)",opacity:"0",willChange:"transform, opacity",transition:`transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) ${P*40}ms, opacity 0.2s ease ${P*40}ms, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease`,boxShadow:"0 4px 8px rgba(0,0,0,0.2), inset 0 -6px 12px rgba(0,0,0,0.1), inset 0 2px 4px rgba(255,255,255,0.4)"}),F.dataset.dx=String($),F.dataset.dy=String(R);const D=document.createElement("div");Object.assign(D.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",borderRadius:"50%",background:"radial-gradient(ellipse 70% 50% at 35% 25%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 70%), radial-gradient(ellipse 60% 40% at 70% 80%, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 70%)",boxShadow:"inset 1.5px 1.5px 3px rgba(255,255,255,0.5), inset -0.5px -0.5px 2px rgba(0,0,0,0.06)",pointerEvents:"none",overflow:"hidden"}),F.appendChild(D);const z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("viewBox","0 0 24 24"),z.setAttribute("width","30"),z.setAttribute("height","30"),z.style.overflow="visible",z.style.position="relative",z.style.zIndex="1";const B=[],W=[];for(const G of L.icon){const Q=document.createElementNS("http://www.w3.org/2000/svg","path");Q.setAttribute("d",G),Q.setAttribute("fill","none"),Q.setAttribute("stroke","#333333"),Q.setAttribute("stroke-width","2"),Q.setAttribute("stroke-linecap","round"),Q.setAttribute("stroke-linejoin","round"),z.appendChild(Q),B.push(Q)}const K=Nv[L.key];if(K){const G=document.createElementNS("http://www.w3.org/2000/svg","text");G.setAttribute("x","12"),G.setAttribute("y","16.5"),G.setAttribute("text-anchor","middle"),G.setAttribute("font-size","5.5"),G.setAttribute("font-family",'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'),G.setAttribute("font-weight","700"),G.setAttribute("fill","#333333"),G.setAttribute("stroke","none"),G.textContent=K,z.appendChild(G),W.push(G)}F.appendChild(z);const X=document.createElement("div");X.textContent=L.label;const q=A*(180/Math.PI),N={position:"absolute",backgroundColor:"rgba(30, 30, 30, 0.45)",backdropFilter:"blur(20px) saturate(1.4)",WebkitBackdropFilter:"blur(20px) saturate(1.4)",color:"#ffffff",padding:"4px 10px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.12)",fontSize:"11px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontWeight:"500",letterSpacing:"0.2px",boxShadow:"0 2px 12px rgba(0,0,0,0.12), inset 0 0.5px 0 rgba(255,255,255,0.1)",whiteSpace:"nowrap",pointerEvents:"none",opacity:"0",transition:"opacity 0.15s ease, transform 0.15s ease"};q>60&&q<120?(N.top="calc(100% + 6px)",N.left="50%",N.transform="translateX(-50%) scale(0.8)"):q>=120&&q<=240?(N.right="calc(100% + 6px)",N.top="50%",N.transform="translateY(-50%) scale(0.8)"):q>240&&q<300?(N.bottom="calc(100% + 6px)",N.left="50%",N.transform="translateX(-50%) scale(0.8)"):(N.left="calc(100% + 6px)",N.top="50%",N.transform="translateY(-50%) scale(0.8)"),Object.assign(X.style,N),F.appendChild(X);const H=N.transform.replace("scale(0.8)","scale(1)"),Y=N.transform;F.addEventListener("mouseenter",()=>{F.style.background="linear-gradient(160deg, rgba(210,230,255,0.9) 0%, rgba(200,225,255,0.8) 40%, rgba(195,220,255,0.72) 100%)",F.style.borderColor="rgba(210, 230, 255, 0.85)",F.style.boxShadow="0 0 20px rgba(200,225,255,0.7), 0 0 8px rgba(200,225,255,0.5), 0 4px 12px rgba(0,0,0,0.06), 0 0 0 1px rgba(210,230,255,0.35), inset 0 2px 4px rgba(255,255,255,0.6), inset 0 -1px 2px rgba(0,0,0,0.02)",B.forEach(G=>G.setAttribute("stroke","#1a4a8a")),W.forEach(G=>G.setAttribute("fill","#1a4a8a")),X.style.opacity="1",X.style.transform=H}),F.addEventListener("mouseleave",()=>{F.style.background="linear-gradient(160deg, rgba(255,255,255,0.72) 0%, rgba(240,240,255,0.45) 40%, rgba(255,255,255,0.35) 100%)",F.style.borderColor="rgba(255, 255, 255, 0.4)",F.style.boxShadow="0 4px 8px rgba(0,0,0,0.2), inset 0 -6px 12px rgba(0,0,0,0.1), inset 0 2px 4px rgba(255,255,255,0.4)",B.forEach(G=>G.setAttribute("stroke","#333333")),W.forEach(G=>G.setAttribute("fill","#333333")),X.style.opacity="0",X.style.transform=Y}),F.addEventListener("click",G=>{G.stopPropagation(),this.closeMenu();const Q=T[L.key];Q!=null&&Q.onclick?Q.onclick():this.onExport(L.key)}),this.radialContainer.appendChild(F),requestAnimationFrame(()=>{requestAnimationFrame(()=>{F.style.transform=`translate(${$}px, ${R}px) scale(1)`,F.style.opacity="1"})})}),this.outsideClickHandler=L=>{this.radialContainer&&!this.radialContainer.contains(L.target)&&this.closeMenu()},setTimeout(()=>{document.addEventListener("click",this.outsideClickHandler)},0),this.scrollHandler=()=>this.closeMenu(),window.addEventListener("scroll",this.scrollHandler,{once:!0,capture:!0})}closeMenu(){if(this.isOpen=!1,this.gearGroup&&this.gearGroup.style("transform","rotate(0deg)"),this.radialContainer){this.btnCenterX,this.btnCenterY,this.radialContainer.querySelectorAll(".katucharts-radial-btn").forEach((i,r)=>{i.style.transition=`transform 0.25s cubic-bezier(0.4, 0, 1, 1) ${r*20}ms, opacity 0.2s ease ${r*20}ms`,i.style.transform="translate(0px, 0px) scale(0.3)",i.style.opacity="0"});const e=this.radialContainer;setTimeout(()=>{e.remove()},400),this.radialContainer=null}this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,!0),this.scrollHandler=null)}updatePosition(t,e){var l;if(this.chartWidth=t,this.chartHeight=e,!this.group)return;const i=(l=this.config.buttons)==null?void 0:l.contextButton,r=(i==null?void 0:i.theme)||{},o=r.width??28,s=r.height??22,a=t+((i==null?void 0:i.x)??-10)-o,c=(i==null?void 0:i.y)??10;this.group.attr("transform",`translate(${a},${c})`),this.btnCenterX=a+o/2,this.btnCenterY=c+s/2,this.isOpen&&this.closeMenu()}destroy(){this.closeMenu(),this.group&&(this.group.remove(),this.group=null)}}class gf{constructor(t){this.activeIndices=new Set,this.rules=t.rules||[]}evaluate(t,e){const i=new Set;for(let o=0;o<this.rules.length;o++)this.matchesCondition(this.rules[o].condition,t,e)&&i.add(o);const r=!this.setsEqual(i,this.activeIndices);return this.activeIndices=i,{changed:r,matchingIndices:Array.from(i)}}getRules(){return this.rules}getCurrentActiveIndices(){return Array.from(this.activeIndices)}reset(){this.activeIndices.clear()}setsEqual(t,e){if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0}matchesCondition(t,e,i){return t.callback?t.callback():!(t.maxWidth!==void 0&&e>t.maxWidth||t.minWidth!==void 0&&e<t.minWidth||t.maxHeight!==void 0&&i>t.maxHeight||t.minHeight!==void 0&&i<t.minHeight)}}function ss(n){return`${n._internalType}__${n.stack??"_default"}`}function Vi(n,t){for(const e of n){const i=e.x??0;t.set(i,(t.get(i)||0)+(e.y??0))}return t}function mf(n,t){return t==="left"?n.layout.titleArea.x:t==="right"?n.layout.titleArea.x+n.layout.titleArea.width:n.chartWidth/2}function yf(n){return n==="left"?"start":n==="right"?"end":"middle"}function xf(n,t,e,i){const r=n.node();if(!r||t<=0)return;try{if(r.getComputedTextLength()<=t)return}catch{return}const s=n.text().split(/\s+/);if(s.length<=1)return;const a=i*1.3;n.text(null);let c=[],l=n.append("tspan").attr("x",e).attr("dy",0);for(const h of s){c.push(h),l.text(c.join(" "));try{l.node().getComputedTextLength()>t&&c.length>1&&(c.pop(),l.text(c.join(" ")),c=[h],l=n.append("tspan").attr("x",e).attr("dy",a).text(h))}catch{break}}}function Hv(n){var s,a,c,l,h,f,u,d,p,y;const{titleGroup:t,container:e,options:i,layout:r,chartWidth:o}=n;if(t.selectAll("*").remove(),e.querySelectorAll(".katucharts-title-html, .katucharts-subtitle-html").forEach(g=>g.remove()),(s=i.title)!=null&&s.text){const g=i.title,m=((a=g.style)==null?void 0:a.fontSize)||"18px";if(g.useHTML){const x=document.createElement("div");x.className="katucharts-title-html",x.innerHTML=g.text,x.style.cssText=`position:absolute;top:${r.titleArea.y+5}px;left:0;width:100%;text-align:${g.align||"center"};color:${((c=g.style)==null?void 0:c.color)||"#333333"};font-size:${m};font-weight:${((l=g.style)==null?void 0:l.fontWeight)||"bold"};pointer-events:none;box-sizing:border-box;padding:0 22px;`,e.appendChild(x)}else{const x=mf(n,g.align),v=o+(g.widthAdjust??-44),b=t.append("text").attr("class","katucharts-chart-title").attr("x",x).attr("y",r.titleArea.y+20).attr("text-anchor",yf(g.align)).attr("fill",((h=g.style)==null?void 0:h.color)||"#333333").attr("font-size",m).attr("font-weight",((f=g.style)==null?void 0:f.fontWeight)||"bold").text(g.text);xf(b,v,x,me(m))}}if((u=i.subtitle)!=null&&u.text){const g=i.subtitle,m=((d=g.style)==null?void 0:d.fontSize)||"12px";if(g.useHTML){const x=document.createElement("div");x.className="katucharts-subtitle-html",x.innerHTML=g.text,x.style.cssText=`position:absolute;top:${r.subtitleArea.y+5}px;left:0;width:100%;text-align:${g.align||"center"};color:${((p=g.style)==null?void 0:p.color)||"#666666"};font-size:${m};pointer-events:none;box-sizing:border-box;padding:0 22px;`,e.appendChild(x)}else{const x=mf(n,g.align),v=o+(g.widthAdjust??-44),b=t.append("text").attr("class","katucharts-chart-subtitle").attr("x",x).attr("y",r.subtitleArea.y+15).attr("text-anchor",yf(g.align)).attr("fill",((y=g.style)==null?void 0:y.color)||"#666666").attr("font-size",m).text(g.text);xf(b,v,x,me(m))}}}function Vv(n){var Q;const{container:t,renderer:e,options:i,plotGroup:r,layout:o,chartWidth:s,chartHeight:a,scrollableInner:c,scrollableOuterWidth:l,scrollableOuterHeight:h,useVerticalScroll:f,useHorizontalScroll:u,exportButton:d,previousOverlay:p}=n;if(!c)return null;const y=e.getSVGNode();if(!y)return null;const g=O=>{const it=O==null?void 0:O.querySelector(".katucharts-export-button-group");it&&y.appendChild(it)};p&&p.parentElement&&(g(p),p.parentElement.removeChild(p)),t.querySelectorAll(":scope > svg[data-katu-fixed-overlay]").forEach(O=>{var it;g(O),(it=O.parentElement)==null||it.removeChild(O)});const x="http://www.w3.org/2000/svg",v=c.offsetWidth-c.clientWidth,b=c.offsetHeight-c.clientHeight,k=l-v,M=h-b,C=document.createElementNS(x,"svg");C.setAttribute("data-katu-fixed-overlay","1"),C.setAttribute("width",k.toString()),C.setAttribute("height",M.toString()),C.style.position="absolute",C.style.top="0",C.style.left="0",C.style.pointerEvents="none",C.style.overflow="visible";const E=i.chart.backgroundColor||"#ffffff",T=(r.attr("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),I=T?parseFloat(T[1]):0,L=T?parseFloat(T[2]):0,P=!!i.chart.inverted,A=P?".katucharts-axis-y":".katucharts-axis-x",w=P?".katucharts-axis-x":".katucharts-axis-y",S=document.createElementNS(x,"defs"),$=`katucharts-fixed-grad-${Math.random().toString(36).slice(2,8)}`,R=(O,it,et,ht,ft,ct)=>{const nt=document.createElementNS(x,"linearGradient");nt.setAttribute("id",O),nt.setAttribute("x1",it),nt.setAttribute("y1",et),nt.setAttribute("x2",ht),nt.setAttribute("y2",ft),ct.forEach(([U,at])=>{const yt=document.createElementNS(x,"stop");yt.setAttribute("offset",U),yt.setAttribute("stop-color",E),yt.setAttribute("stop-opacity",at),nt.appendChild(yt)}),S.appendChild(nt)},F=o.titleArea,D=o.subtitleArea,z=Math.max(((F==null?void 0:F.y)??0)+((F==null?void 0:F.height)??0),((D==null?void 0:D.y)??0)+((D==null?void 0:D.height)??0)),W=Math.max(0,Math.min(z+30,L)),K=W>0?Math.max(0,Math.min(100,z/W*100)):100;if(R(`${$}-top`,"0%","0%","0%","100%",[["0%","1"],[`${K}%`,"1"],["100%","0"]]),R(`${$}-bottom`,"0%","0%","0%","100%",[["0%","0"],["30%","1"],["100%","1"]]),R(`${$}-left`,"0%","0%","100%","0%",[["0%","1"],["70%","1"],["100%","0"]]),C.appendChild(S),f&&W>0){const O=document.createElementNS(x,"rect");O.setAttribute("x","0"),O.setAttribute("y","0"),O.setAttribute("width",k.toString()),O.setAttribute("height",W.toString()),O.setAttribute("fill",`url(#${$}-top)`),C.appendChild(O)}if(y.querySelectorAll(".katucharts-title-group").forEach(O=>{O.style.visibility="hidden";const it=O.cloneNode(!0);it.style.visibility="visible";const et=(s-k)/2;et!==0&&it.setAttribute("transform",`translate(${-et}, 0)`),C.appendChild(it)}),f){const O=L+o.plotArea.height,it=a-O+10,et=document.createElementNS(x,"rect");et.setAttribute("x","0"),et.setAttribute("y",(M-it).toString()),et.setAttribute("width",k.toString()),et.setAttribute("height",it.toString()),et.setAttribute("fill",`url(#${$}-bottom)`),C.appendChild(et),y.querySelectorAll(A).forEach(ft=>{ft.style.visibility="hidden";const ct=document.createElementNS(x,"g"),nt=M-(a-O);ct.setAttribute("transform",`translate(${I}, ${nt})`);const U=ft.cloneNode(!0);U.removeAttribute("transform"),U.style.visibility="visible",ct.appendChild(U),C.appendChild(ct)})}if(u){const O=I+5,it=document.createElementNS(x,"rect");it.setAttribute("x","0"),it.setAttribute("y","0"),it.setAttribute("width",O.toString()),it.setAttribute("height",M.toString()),it.setAttribute("fill",`url(#${$}-left)`),C.appendChild(it),y.querySelectorAll(w).forEach(ht=>{ht.style.visibility="hidden";const ft=document.createElementNS(x,"g");ft.setAttribute("transform",`translate(${I}, ${L})`);const ct=ht.cloneNode(!0);ct.removeAttribute("transform"),ct.style.visibility="visible",ft.appendChild(ct),C.appendChild(ft)})}const q=((Q=o.legendArea)==null?void 0:Q.height)??0;(!f||q<=M*.3)&&y.querySelectorAll(".katucharts-legend").forEach(it=>{const ht=(it.getAttribute("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),ft=ht?parseFloat(ht[1]):0,ct=ht?parseFloat(ht[2]):0,nt=(s-k)/2,U=f?a-M:0,at=ft-nt,yt=ct-U;it.style.visibility="hidden";const St=it.cloneNode(!0);St.style.visibility="visible",St.setAttribute("transform",`translate(${at}, ${yt})`),C.appendChild(St)});const H=y.querySelector(".katucharts-export-button-group");if(H&&d){const it=(H.getAttribute("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),et=it?parseFloat(it[1]):0,ht=it?parseFloat(it[2]):0,ft=et-(s-k);H.setAttribute("transform",`translate(${ft},${ht})`),H.style.pointerEvents="auto",C.appendChild(H),d.repositionCenter(ft+28/2,ht+22/2)}y.querySelectorAll(".katucharts-color-axis").forEach(O=>{O.style.visibility="hidden";const it=O.cloneNode(!0);it.style.visibility="visible";const et=document.createElementNS(x,"g"),ht=k/2-o.plotArea.width/2;et.setAttribute("transform",`translate(${ht},${L})`),et.appendChild(it),C.appendChild(et)});const G=y.querySelector(".katucharts-credits");if(G){const O=parseFloat(G.getAttribute("x")||"0"),it=parseFloat(G.getAttribute("y")||"0");G.style.visibility="hidden";const et=G.cloneNode(!0);et.style.visibility="visible",et.setAttribute("x",String(k-(s-O))),et.setAttribute("y",String(M-(a-it))),C.appendChild(et)}return t.appendChild(C),C}const Jt=class Jt{static inlineStyles(t){const e=t.cloneNode(!0),i=e.querySelectorAll("*"),r=t.querySelectorAll("*");for(let a=0;a<i.length&&a<r.length;a++){const c=i[a],l=r[a];try{const h=window.getComputedStyle(l);for(const f of Jt.INLINE_PROPS){const u=h.getPropertyValue(f);u&&u!==""&&u!=="none"&&u!=="normal"&&u!=="0"&&c.style.setProperty(f,u)}}catch{}}const o=e.querySelector(".katucharts-export-button-group");return o&&o.remove(),tn.isLicensed()||Jt.stampWatermark(e),new XMLSerializer().serializeToString(e)}static stampWatermark(t){t.querySelectorAll(".katucharts-credits, .katucharts-export-watermark").forEach(s=>s.remove());const e=(t.getAttribute("viewBox")||"").split(/[\s,]+/).map(Number),i=parseFloat(t.getAttribute("width")||"")||e[2]||600,r=parseFloat(t.getAttribute("height")||"")||e[3]||400,o=document.createElementNS("http://www.w3.org/2000/svg","text");o.setAttribute("class","katucharts-export-watermark"),o.setAttribute("x",String(i-8)),o.setAttribute("y",String(r-8)),o.setAttribute("text-anchor","end"),o.setAttribute("font-family","Arial, Helvetica, sans-serif"),o.setAttribute("font-size","11px"),o.setAttribute("font-weight","normal"),o.setAttribute("fill","#8a8a8a"),o.style.setProperty("fill","#8a8a8a"),o.textContent="Powered by: KatuCharts",t.appendChild(o)}static svgToCanvas(t,e,i){return new Promise((r,o)=>{const s=new Image;s.onload=()=>{const a=document.createElement("canvas");a.width=s.width*e,a.height=s.height*e;const c=a.getContext("2d");if(!c){o(new Error("Canvas context unavailable"));return}c.scale(e,e),i&&(c.fillStyle=i,c.fillRect(0,0,s.width,s.height)),c.drawImage(s,0,0),r(a)},s.onerror=()=>o(new Error("Failed to load SVG into image")),s.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t)))})}static exportSVG(t,e="chart"){const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"});Jt.downloadBlob(i,`${e}.svg`)}static async exportPNG(t,e="chart",i=2){const r=await Jt.svgToCanvas(t,i);return new Promise((o,s)=>{r.toBlob(a=>{a?(Jt.downloadBlob(a,`${e}.png`),o()):s(new Error("Failed to generate PNG"))},"image/png")})}static async exportJPEG(t,e="chart",i=2,r=.95){const o=await Jt.svgToCanvas(t,i,"#ffffff");return new Promise((s,a)=>{o.toBlob(c=>{c?(Jt.downloadBlob(c,`${e}.jpeg`),s()):a(new Error("Failed to generate JPEG"))},"image/jpeg",r)})}static loadJsPDF(){return Jt.jsPDFLoader||(Jt.jsPDFLoader=(async()=>{var r;const t=()=>{var s;const o=((s=globalThis.jspdf)==null?void 0:s.jsPDF)??globalThis.jsPDF;return typeof o=="function"?o:null},e=t();if(e)return e;try{const o=await Promise.resolve().then(()=>e5),s=o.jsPDF??((r=o.default)==null?void 0:r.jsPDF)??o.default;if(typeof s=="function")return s}catch{}await Jt.injectScript(Jt.JSPDF_CDN_URL);const i=t();if(i)return i;throw new Error("jsPDF unavailable")})().catch(t=>{throw Jt.jsPDFLoader=null,t})),Jt.jsPDFLoader}static injectScript(t){return new Promise((e,i)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.onload=()=>e(),r.onerror=()=>{r.remove(),i(new Error(`Failed to load ${t}`))},document.head.appendChild(r)})}static async exportPDF(t,e="chart",i=2){let r;try{r=await Jt.loadJsPDF()}catch{console.warn("KatuCharts: jspdf could not be loaded. Install it with `npm install jspdf`, expose it as a global, or allow the CDN fallback to enable PDF export.");return}const o=await Jt.svgToCanvas(t,i,"#ffffff"),s=o.toDataURL("image/jpeg",.95),a=o.width/i,c=o.height/i,l=a>c?"landscape":"portrait",h=new r({orientation:l,unit:"px",format:[a,c]});h.addImage(s,"JPEG",0,0,a,c),h.save(`${e}.pdf`)}static print(t,e){var c;const i=document.createElement("iframe");Object.assign(i.style,{position:"fixed",left:"-9999px",top:"-9999px",width:"0",height:"0",border:"none"}),document.body.appendChild(i);const r=i.contentDocument||((c=i.contentWindow)==null?void 0:c.document);if(!r){i.remove();return}const o=e??780;r.open(),r.write(`<!DOCTYPE html><html><head><style>
1
+ (function(_t,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports):typeof define=="function"&&define.amd?define(["exports"],Ie):(_t=typeof globalThis<"u"?globalThis:_t||self,Ie(_t.KatuCharts={}))})(this,function(_t){"use strict";var d5=Object.defineProperty;var p5=(_t,Ie,si)=>Ie in _t?d5(_t,Ie,{enumerable:!0,configurable:!0,writable:!0,value:si}):_t[Ie]=si;var bt=(_t,Ie,si)=>p5(_t,typeof Ie!="symbol"?Ie+"":Ie,si);function Ie(n,t,e){n.prototype=t.prototype=e,e.constructor=n}function si(n,t){var e=Object.create(n.prototype);for(var i in t)e[i]=t[i];return e}function or(){}var sr=.7,so=1/sr,Ti="\\s*([+-]?\\d+)\\s*",ar="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",eg=/^#([0-9a-f]{3,8})$/,ng=new RegExp(`^rgb\\(${Ti},${Ti},${Ti}\\)$`),ig=new RegExp(`^rgb\\(${wn},${wn},${wn}\\)$`),rg=new RegExp(`^rgba\\(${Ti},${Ti},${Ti},${ar}\\)$`),og=new RegExp(`^rgba\\(${wn},${wn},${wn},${ar}\\)$`),sg=new RegExp(`^hsl\\(${ar},${wn},${wn}\\)$`),ag=new RegExp(`^hsla\\(${ar},${wn},${wn},${ar}\\)$`),El={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ie(or,le,{copy(n){return Object.assign(new this.constructor,this,n)},displayable(){return this.rgb().displayable()},hex:Tl,formatHex:Tl,formatHex8:cg,formatHsl:lg,formatRgb:Ll,toString:Ll});function Tl(){return this.rgb().formatHex()}function cg(){return this.rgb().formatHex8()}function lg(){return Dl(this).formatHsl()}function Ll(){return this.rgb().formatRgb()}function le(n){var t,e;return n=(n+"").trim().toLowerCase(),(t=eg.exec(n))?(e=t[1].length,t=parseInt(t[1],16),e===6?$l(t):e===3?new He(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):e===8?ao(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):e===4?ao(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ng.exec(n))?new He(t[1],t[2],t[3],1):(t=ig.exec(n))?new He(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=rg.exec(n))?ao(t[1],t[2],t[3],t[4]):(t=og.exec(n))?ao(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=sg.exec(n))?Rl(t[1],t[2]/100,t[3]/100,1):(t=ag.exec(n))?Rl(t[1],t[2]/100,t[3]/100,t[4]):El.hasOwnProperty(n)?$l(El[n]):n==="transparent"?new He(NaN,NaN,NaN,0):null}function $l(n){return new He(n>>16&255,n>>8&255,n&255,1)}function ao(n,t,e,i){return i<=0&&(n=t=e=NaN),new He(n,t,e,i)}function hg(n){return n instanceof or||(n=le(n)),n?(n=n.rgb(),new He(n.r,n.g,n.b,n.opacity)):new He}function je(n,t,e,i){return arguments.length===1?hg(n):new He(n,t,e,i??1)}function He(n,t,e,i){this.r=+n,this.g=+t,this.b=+e,this.opacity=+i}Ie(He,je,si(or,{brighter(n){return n=n==null?so:Math.pow(so,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},darker(n){return n=n==null?sr:Math.pow(sr,n),new He(this.r*n,this.g*n,this.b*n,this.opacity)},rgb(){return this},clamp(){return new He(ai(this.r),ai(this.g),ai(this.b),co(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Il,formatHex:Il,formatHex8:ug,formatRgb:Fl,toString:Fl}));function Il(){return`#${ci(this.r)}${ci(this.g)}${ci(this.b)}`}function ug(){return`#${ci(this.r)}${ci(this.g)}${ci(this.b)}${ci((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fl(){const n=co(this.opacity);return`${n===1?"rgb(":"rgba("}${ai(this.r)}, ${ai(this.g)}, ${ai(this.b)}${n===1?")":`, ${n})`}`}function co(n){return isNaN(n)?1:Math.max(0,Math.min(1,n))}function ai(n){return Math.max(0,Math.min(255,Math.round(n)||0))}function ci(n){return n=ai(n),(n<16?"0":"")+n.toString(16)}function Rl(n,t,e,i){return i<=0?n=t=e=NaN:e<=0||e>=1?n=t=NaN:t<=0&&(n=NaN),new pn(n,t,e,i)}function Dl(n){if(n instanceof pn)return new pn(n.h,n.s,n.l,n.opacity);if(n instanceof or||(n=le(n)),!n)return new pn;if(n instanceof pn)return n;n=n.rgb();var t=n.r/255,e=n.g/255,i=n.b/255,r=Math.min(t,e,i),o=Math.max(t,e,i),s=NaN,a=o-r,c=(o+r)/2;return a?(t===o?s=(e-i)/a+(e<i)*6:e===o?s=(i-t)/a+2:s=(t-e)/a+4,a/=c<.5?o+r:2-o-r,s*=60):a=c>0&&c<1?0:s,new pn(s,a,c,n.opacity)}function li(n,t,e,i){return arguments.length===1?Dl(n):new pn(n,t,e,i??1)}function pn(n,t,e,i){this.h=+n,this.s=+t,this.l=+e,this.opacity=+i}Ie(pn,li,si(or,{brighter(n){return n=n==null?so:Math.pow(so,n),new pn(this.h,this.s,this.l*n,this.opacity)},darker(n){return n=n==null?sr:Math.pow(sr,n),new pn(this.h,this.s,this.l*n,this.opacity)},rgb(){var n=this.h%360+(this.h<0)*360,t=isNaN(n)||isNaN(this.s)?0:this.s,e=this.l,i=e+(e<.5?e:1-e)*t,r=2*e-i;return new He(js(n>=240?n-240:n+120,r,i),js(n,r,i),js(n<120?n+240:n-120,r,i),this.opacity)},clamp(){return new pn(zl(this.h),lo(this.s),lo(this.l),co(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const n=co(this.opacity);return`${n===1?"hsl(":"hsla("}${zl(this.h)}, ${lo(this.s)*100}%, ${lo(this.l)*100}%${n===1?")":`, ${n})`}`}}));function zl(n){return n=(n||0)%360,n<0?n+360:n}function lo(n){return Math.max(0,Math.min(1,n||0))}function js(n,t,e){return(n<60?t+(e-t)*n/60:n<180?e:n<240?t+(e-t)*(240-n)/60:t)*255}const ho=new Map,fg=256;function cr(n){const t=n||"rgba(0,0,0,0)",e=ho.get(t);if(e)return e;const i="rgba(0,0,0,0)",r=le(n||i),o=je(r||i),s={r:Math.round(o.r),g:Math.round(o.g),b:Math.round(o.b),a:o.opacity,get(a){return a==="rgba"?this.toString():this.toString()},brighten(a){const c=li(je(this.r,this.g,this.b,this.a));c.l+=a*.1,c.l=Math.max(0,Math.min(1,c.l));const l=je(c);return cr(l.formatRgb())},setOpacity(a){return cr(`rgba(${this.r},${this.g},${this.b},${a})`)},toString(){return this.a<1?`rgba(${this.r},${this.g},${this.b},${this.a})`:je(this.r,this.g,this.b).formatHex()}};return ho.size>=fg&&ho.clear(),ho.set(t,s),s}const uo={default:["#2caffe","#544fc5","#00e272","#fe6a35","#6b8abc","#d568fb","#2ee0ca","#fa4b42","#feb56a","#91e8e1"],tableau10:["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],d3classic:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],brewer:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],google:["#3366cc","#dc3912","#ff9900","#109618","#990099","#0099c6","#dd4477","#66aa00","#b82e2e","#316395"],ocean:["#003f5c","#2f4b7c","#665191","#a05195","#d45087","#f95d6a","#ff7c43","#ffa600","#58508d","#bc5090"],sunset:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],earth:["#8c510a","#bf812d","#dfc27d","#c7eae5","#80cdc1","#35978f","#01665e","#543005","#003c30","#f6e8c3"],forest:["#2d6a4f","#40916c","#52b788","#74c69d","#95d5b2","#1b4332","#081c15","#b7e4c7","#d8f3dc","#344e41"],berry:["#7b2cbf","#9d4edd","#c77dff","#e0aaff","#5a189a","#3c096c","#240046","#10002b","#e2afff","#deaaff"],corporate:["#2c3e50","#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085"],minimal:["#264653","#2a9d8f","#e9c46a","#f4a261","#e76f51","#606c38","#283618","#dda15e","#bc6c25","#fefae0"],nordic:["#5e81ac","#81a1c1","#88c0d0","#8fbcbb","#bf616a","#d08770","#ebcb8b","#a3be8c","#b48ead","#4c566a"],darkMode:["#2ecc71","#3498db","#e74c3c","#f1c40f","#9b59b6","#1abc9c","#e67e22","#ecf0f1","#e91e63","#00bcd4"],neon:["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff","#06d6a0","#118ab2","#ef476f","#ffd166","#073b4c"],pastel:["#a8e6cf","#dcedc1","#ffd3b6","#ffaaa5","#ff8b94","#b5ead7","#c7ceea","#e2f0cb","#fceaea","#d4a5a5"],soft:["#6c9bd2","#e6a756","#d46a6a","#7cc5a8","#b28fce","#e8937f","#6bb8a0","#d4b56a","#8e9cc2","#c2847a"],classic:["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1"],tupi:["#b43417","#1b1a15","#a85429","#ce9a3a","#33503a","#8c2810","#6b6a45","#d97b3f","#5b5240","#7a3b2e"],monochrome:["#1f2933","#3e4c59","#52606d","#7b8794","#9aa5b1","#616e7c","#cbd2d9","#323f4b","#7b8794","#b8c0c9"]};function Bl(n){return uo[n]||uo.default}const dg=uo.default,pg={textStrong:"#1f2933",textSoft:"#52606d",axis:"#6b7280",line:"#c8ccd2",grid:"#e6e8eb",tooltipBg:"rgba(255,255,255,0.96)",tooltipBorder:"#d8dce0",legend:"#52606d"},gg={textStrong:"#f3f4f6",textSoft:"#b8bfc7",axis:"#9aa3ad",line:"#3a414a",grid:"rgba(255,255,255,0.08)",tooltipBg:"#20262e",tooltipBorder:"#39414b",legend:"#c2c9d1"};function Ol(n,t,e){const i={gridLineColor:e.grid,lineColor:e.line,tickColor:e.line,labels:{style:{color:e.axis}},title:{style:{color:e.axis}}};return{colors:n,chart:{backgroundColor:t},title:{style:{color:e.textStrong}},subtitle:{style:{color:e.textSoft}},xAxis:i,yAxis:i,tooltip:{backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,style:{color:e.textStrong}},legend:{itemStyle:{color:e.legend},itemHoverStyle:{color:e.textStrong}}}}const qs={tupi:{light:["#b43417","#1b1a15","#a85429","#ce9a3a","#33503a","#8c2810","#6b6a45","#d97b3f","#5b5240","#7a3b2e"],dark:["#e0673f","#e7dbc0","#d08a4e","#e8c45f","#6fa37a","#c84c2c","#c9b27a","#f0a06a","#a9a07e","#d98b6a"]},ocean:{light:["#0466c8","#0353a4","#3a86ff","#00b4d8","#0096c7","#48cae4","#023e8a","#5e60ce","#0077b6","#90e0ef"],dark:["#48cae4","#4895ef","#56cfe1","#64dfdf","#80ffdb","#5390d9","#7400b8","#4cc9f0","#56cfe1","#72efdd"]},sunset:{light:["#ff6b35","#f7522f","#ff9e00","#ffbf69","#e85d75","#d1495b","#ffd166","#9e2a2b","#f3722c","#bc4749"],dark:["#ff7b54","#ffb26b","#ffd56b","#ff9e7d","#ff6b6b","#feca57","#ff9ff3","#f368e0","#ffa07a","#ffd56b"]},forest:{light:["#2d6a4f","#40916c","#52b788","#74c69d","#1b4332","#95d5b2","#b7e4c7","#344e41","#588157","#a3b18a"],dark:["#74c69d","#52b788","#95d5b2","#40916c","#b7e4c7","#2d6a4f","#d8f3dc","#588157","#a3b18a","#80ed99"]},corporate:{light:["#2c3e50","#3498db","#16a085","#f39c12","#8e44ad","#e74c3c","#34495e","#27ae60","#2980b9","#d35400"],dark:["#5dade2","#48c9b0","#f5b041","#bb8fce","#ec7063","#58d68d","#85c1e9","#76d7c4","#f8c471","#aed6f1"]},vivid:{light:["#ff006e","#fb5607","#ffbe0b","#8338ec","#3a86ff","#06d6a0","#ef476f","#118ab2","#ff70a6","#9b5de5"],dark:["#ff5d8f","#ff7b00","#ffd60a","#9d4edd","#4cc9f0","#06d6a0","#ff70a6","#48cae4","#fb5607","#b5179e"]},monochrome:{light:["#1f2933","#3e4c59","#52606d","#7b8794","#9aa5b1","#616e7c","#cbd2d9","#323f4b","#46545f","#a7b0b8"],dark:["#e4e7eb","#cbd2d9","#9aa5b1","#7b8794","#616e7c","#b8c0c9","#52606d","#d3d9de","#8a949e","#3e4c59"]},nordic:{light:["#5e81ac","#81a1c1","#88c0d0","#8fbcbb","#bf616a","#d08770","#ebcb8b","#a3be8c","#b48ead","#4c566a"],dark:["#88c0d0","#81a1c1","#8fbcbb","#a3be8c","#ebcb8b","#d08770","#bf616a","#b48ead","#5e81ac","#d8dee9"]},pastel:{light:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"],dark:["#a8e6cf","#ffd3b6","#ffaaa5","#c7ceea","#b5ead7","#ff8b94","#dcedc1","#e2afff","#ffdac1","#b5c7ed"]}},Nl={tupi:{light:"#ecdfc4",dark:"#1c1814"},ocean:{light:"#ffffff",dark:"#0b1622"},sunset:{light:"#ffffff",dark:"#1f1410"},forest:{light:"#ffffff",dark:"#0f1f17"},corporate:{light:"#ffffff",dark:"#1a1f26"},vivid:{light:"#ffffff",dark:"#14101c"},monochrome:{light:"#ffffff",dark:"#1a1f24"},nordic:{light:"#eceff4",dark:"#2e3440"},pastel:{light:"#ffffff",dark:"#232026"}},fo=(()=>{const n={};for(const t of Object.keys(qs))n[t]=Ol(qs[t].light,Nl[t].light,pg),n[`${t}-dark`]=Ol(qs[t].dark,Nl[t].dark,gg);return n.light=n.monochrome,n.dark=n["monochrome-dark"],n})(),mg=Object.keys(fo);function Wl(n){return fo[n]}const kt="12px",Fe="#000000",Hl="#1a1a1a",yg="#ffffff",xg=3;function Zs(n){const t=n/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Vl(n,t,e){return .2126*Zs(n)+.7152*Zs(t)+.0722*Zs(e)}function Gl(n,t){return(Math.max(n,t)+.05)/(Math.min(n,t)+.05)}const bg=Vl(26,26,26);function gn(n,t){var s;if(t)return t;const e=n?(s=le(n))==null?void 0:s.rgb():null;if(!e||isNaN(e.r)||e.opacity===0)return Fe;const i=Vl(e.r,e.g,e.b),r=Gl(i,bg);return r>=xg?Hl:Gl(i,1)>=r?yg:Hl}function Yl(){if(typeof document>"u")return 16;const n=parseFloat(getComputedStyle(document.documentElement).fontSize);return n>0?n:16}function se(n){if(!n)return 12;const t=n.trim();if(/^(clamp|min|max)\s*\(/i.test(t)){const r=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).match(/-?\d*\.?\d+\s*(px|rem|em)/gi)||[];let o=0;for(const s of r){const a=se(s.trim());a>o&&(o=a)}return o>0?o:12}if(t.endsWith("px"))return parseFloat(t)||12;if(t.endsWith("rem")||t.endsWith("em"))return(parseFloat(t)||1)*Yl();const e=parseFloat(t);return isNaN(e)?12:e}let po=null;function vg(){return po||(typeof document>"u"?null:(po=document.createElement("canvas").getContext("2d"),po))}function pe(n,t,e="normal",i="sans-serif"){const r=vg();return r?(r.font=`${e} ${t}px ${i}`,r.measureText(n).width):n.length*t*.62}const Ks={chart:{type:"line",backgroundColor:"#ffffff",borderWidth:0,borderRadius:0,borderColor:"#335cad",spacing:[10,10,15,10],style:{fontFamily:'"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif',fontSize:"12px"},animation:!0,zoomType:void 0,panning:!1,inverted:!1,polar:!1,reflow:!0},title:{text:void 0,align:"center",margin:15,style:{color:"#333333",fontSize:"18px",fontWeight:"bold"},widthAdjust:-44},subtitle:{text:void 0,align:"center",style:{color:"#666666",fontSize:"12px"},widthAdjust:-44},xAxis:{type:"linear",title:{text:null,style:{fontSize:kt}},labels:{enabled:!0,style:{fontSize:kt},autoRotation:[-45],autoRotationLimit:80,padding:5},tickLength:10,tickWidth:1,tickColor:"#999999",gridLineWidth:0,gridLineColor:"#e6e6e6",lineWidth:1,lineColor:"#999999",offset:0,opposite:!1,reversed:!1,visible:!0,startOnTick:!1,endOnTick:!1,showFirstLabel:!0,showLastLabel:!0,allowDecimals:!0,maxPadding:.01,minPadding:.01,crosshair:!1},yAxis:{type:"linear",title:{text:null,style:{fontSize:kt}},labels:{enabled:!0,style:{fontSize:kt},padding:5},tickLength:10,tickWidth:1,gridLineWidth:1,gridLineColor:"#e6e6e6",lineWidth:1,lineColor:"#999999",offset:0,opposite:!1,reversed:!1,visible:!0,startOnTick:!0,endOnTick:!0,showFirstLabel:!0,showLastLabel:!0,allowDecimals:!0,maxPadding:.05,minPadding:.05,crosshair:!1},colorAxis:void 0,series:[],tooltip:{enabled:!0,shared:!1,split:!1,useHTML:!1,followPointer:!1,headerFormat:'<span style="font-size: 10px">{point.key}</span><br/>',pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.y}</b><br/>',footerFormat:"",backgroundColor:"rgba(247,247,247,0.85)",borderColor:void 0,borderWidth:1,borderRadius:3,padding:8,shadow:!0,animation:!0,hideDelay:500,snap:10,outside:!1,style:{color:"#333333",fontSize:"12px"}},legend:{enabled:!0,layout:"horizontal",align:"center",verticalAlign:"bottom",floating:!1,x:0,y:0,margin:15,padding:8,itemMarginTop:0,itemMarginBottom:0,itemDistance:20,itemStyle:{cursor:"pointer",fontSize:kt,fontWeight:"normal"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#cccccc"},symbolWidth:12,symbolHeight:12,symbolRadius:2,symbolPadding:5,squareSymbol:!0,borderWidth:0,borderRadius:0,borderColor:"#999999",reversed:!1},plotOptions:{series:{lineWidth:2,marker:{enabled:null,radius:4,symbol:"circle",lineWidth:0,states:{hover:{enabled:!0,radius:6,lineWidth:1}}},states:{hover:{enabled:!0,lineWidthPlus:1},inactive:{opacity:.2}},animation:{duration:1e3},enableMouseTracking:!0,stickyTracking:!0,allowPointSelect:!1,turboThreshold:1e3,dataLabels:{enabled:!1},showInLegend:!0,threshold:0,connectNulls:!1,clip:!0},bubble:{lineWidth:1},scatter:{marker:{symbol:null}},pie:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.percentage:.1f}%</b><br/>'},dataLabels:{enabled:!0},showInLegend:!1},item:{marker:{radius:null}},classroom:{marker:{radius:null}},candlestick:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},ohlc:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},heikinashi:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},hollowcandlestick:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b>{series.name}</b><br/>Open: <b>{point.open}</b><br/>High: <b>{point.high}</b><br/>Low: <b>{point.low}</b><br/>Close: <b>{point.close}</b><br/>'}},arearange:{tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'}},donut:{showInLegend:!1},sankey:{dataLabels:{enabled:!0},showInLegend:!1},dependencywheel:{dataLabels:{enabled:!0},showInLegend:!1},treegraph:{dataLabels:{enabled:!0},showInLegend:!1},networkgraph:{dataLabels:{enabled:!0}},treemap:{dataLabels:{enabled:!0}},gauge:{dataLabels:{enabled:!0}},solidgauge:{dataLabels:{enabled:!0}},timeline:{dataLabels:{enabled:!0}},gantt:{dataLabels:{enabled:!0}},barchartrace:{dataLabels:{enabled:!0}},venn:{dataLabels:{enabled:!0}}},credits:{enabled:!0,text:"Powered by: KatuCharts",href:"https://charts.katudv.com",position:{align:"right",verticalAlign:"bottom",x:-10,y:-5},style:{cursor:"pointer",fontSize:"9px"}},exporting:{enabled:!0,filename:"chart",type:"image/png",scale:2,printMaxWidth:780,buttons:{contextButton:{enabled:!0,symbol:"gear",symbolFill:"#666666",symbolStroke:"#666666",symbolStrokeWidth:3,x:-10,y:10,menuItems:["downloadPNG","downloadJPEG","downloadSVG","downloadPDF","separator","viewFullScreen","printChart"]}}},loading:{hideDuration:100,showDuration:100,labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},navigator:{enabled:!1},rangeSelector:{enabled:!1},drilldown:{animation:!0,series:[]},responsive:{rules:[{condition:{maxWidth:500},chartOptions:{chart:{spacing:[5,5,10,5]},title:{style:{fontSize:"14px"},margin:8},subtitle:{style:{fontSize:"10px"}},legend:{itemStyle:{fontSize:"10px"},itemDistance:10,margin:8,symbolWidth:12,symbolHeight:8},yAxis:{title:{text:null},labels:{style:{fontSize:"9px"}}},xAxis:{labels:{style:{fontSize:"9px"},autoRotation:[-45,-90]}},plotOptions:{pie:{size:"65%",dataLabels:{distance:10,style:{fontSize:"9px"},connectorPadding:3}}}}},{condition:{maxWidth:260},chartOptions:{subtitle:{text:null},legend:{enabled:!1},credits:{enabled:!1},plotOptions:{pie:{size:"55%",dataLabels:{distance:5,style:{fontSize:"8px"},connectorWidth:0}}}}}]},accessibility:{enabled:!0},colors:dg},Li=new Set(["pie","donut","sunburst","treemap","treegraph","wordcloud","sankey","dependencywheel","networkgraph","gauge","solidgauge","polar","radar","funnel","pyramid","timeline","map","mappoint","flowmap","barchartrace","venn","clusteredheatmap","phylotree","circos","circosHeatmap","circosComparative","circosSpiral","item","classroom"]),wg=new Set(["pie","donut","funnel","pyramid","sankey","dependencywheel","networkgraph","treemap","sunburst","gauge","solidgauge","timeline","gantt","map","mappoint","flowmap","heatmap","polar","radar","barchartrace","venn","clusteredheatmap","phylotree","circos","item","classroom"]),kg=new Set(["line","spline","column","bar","scatter","bubble","area","areaspline","boxplot","waterfall","volume","pictorial"]),Mg=new Set(["pie","venn","forestplot","pcoa","item","classroom","pictorial"]),Ag=new Set(["column","bar","area","areaspline","waterfall","pictorial"]);function Js(n){return n.length>0&&n.every(t=>Li.has(t._internalType))}const Xl=20;function Ul(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&Object.getPrototypeOf(n)===Object.prototype}function ge(n,...t){return jl(n,t,0)}function jl(n,t,e){if(e>Xl)return n;const i={...n};for(const r of t)if(r)for(const o of Object.keys(r)){if(o==="__proto__"||o==="constructor"||o==="prototype")continue;const s=r[o],a=i[o];s!==void 0&&(s===null?i[o]=null:Ul(s)&&Ul(a)?i[o]=jl(a,[s],e+1):Array.isArray(s)?i[o]=[...s]:i[o]=s)}return i}function go(n){return Qs(n,new WeakSet,0)}function Qs(n,t,e){if(n===null||typeof n!="object"||e>Xl||t.has(n))return n;if(t.add(n),Array.isArray(n))return n.map(r=>Qs(r,t,e+1));if(n instanceof Date)return new Date(n.getTime());const i={};for(const r of Object.keys(n))i[r]=Qs(n[r],t,e+1);return i}function ql(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in n&&n.BYTES_PER_ELEMENT===1}function ta(n,t=""){if(typeof n!="number"){const e=t&&`"${t}" `;throw new TypeError(`${e}expected number, got ${typeof n}`)}if(!Number.isSafeInteger(n)||n<0){const e=t&&`"${t}" `;throw new RangeError(`${e}expected integer >= 0, got ${n}`)}}function hi(n,t,e=""){const i=ql(n),r=n==null?void 0:n.length,o=t!==void 0;if(!i||o&&r!==t){const s=e&&`"${e}" `,a=o?` of length ${t}`:"",c=i?`length=${r}`:`type=${typeof n}`,l=s+"expected Uint8Array"+a+", got "+c;throw i?new RangeError(l):new TypeError(l)}return n}function Zl(n,t=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(t&&n.finished)throw new Error("Hash#digest() has already been called")}function Sg(n,t){hi(n,void 0,"digestInto() output");const e=t.outputLen;if(n.length<e)throw new RangeError('"digestInto() output" expected to be of length >='+e)}function ea(...n){for(let t=0;t<n.length;t++)n[t].fill(0)}function na(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}const Kl=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",_g=Array.from({length:256},(n,t)=>t.toString(16).padStart(2,"0"));function ia(n){if(hi(n),Kl)return n.toHex();let t="";for(let e=0;e<n.length;e++)t+=_g[n[e]];return t}const Ln={_0:48,_9:57,A:65,F:70,a:97,f:102};function Jl(n){if(n>=Ln._0&&n<=Ln._9)return n-Ln._0;if(n>=Ln.A&&n<=Ln.F)return n-(Ln.A-10);if(n>=Ln.a&&n<=Ln.f)return n-(Ln.a-10)}function ra(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);if(Kl)try{return Uint8Array.fromHex(n)}catch(r){throw r instanceof SyntaxError?new RangeError(r.message):r}const t=n.length,e=t/2;if(t%2)throw new RangeError("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(e);for(let r=0,o=0;r<e;r++,o+=2){const s=Jl(n.charCodeAt(o)),a=Jl(n.charCodeAt(o+1));if(s===void 0||a===void 0){const c=n[o]+n[o+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+o)}i[r]=s*16+a}return i}function Cg(...n){let t=0;for(let i=0;i<n.length;i++){const r=n[i];hi(r),t+=r.length}const e=new Uint8Array(t);for(let i=0,r=0;i<n.length;i++){const o=n[i];e.set(o,r),r+=o.length}return e}function Pg(n,t={}){const e=(r,o)=>n(o).update(r).digest(),i=n(void 0);return e.outputLen=i.outputLen,e.blockLen=i.blockLen,e.canXOF=i.canXOF,e.create=r=>n(r),Object.assign(e,t),Object.freeze(e)}function Eg(n=32){ta(n,"bytesLength");const t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(t==null?void 0:t.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");if(n>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${n}`);return t.getRandomValues(new Uint8Array(n))}const Tg=n=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,n])});class Lg{constructor(t,e,i,r){bt(this,"blockLen");bt(this,"outputLen");bt(this,"canXOF",!1);bt(this,"padOffset");bt(this,"isLE");bt(this,"buffer");bt(this,"view");bt(this,"finished",!1);bt(this,"length",0);bt(this,"pos",0);bt(this,"destroyed",!1);this.blockLen=t,this.outputLen=e,this.padOffset=i,this.isLE=r,this.buffer=new Uint8Array(t),this.view=na(this.buffer)}update(t){Zl(this),hi(t);const{view:e,buffer:i,blockLen:r}=this,o=t.length;for(let s=0;s<o;){const a=Math.min(r-this.pos,o-s);if(a===r){const c=na(t);for(;r<=o-s;s+=r)this.process(c,s);continue}i.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Zl(this),Sg(t,this),this.finished=!0;const{buffer:e,view:i,blockLen:r,isLE:o}=this;let{pos:s}=this;e[s++]=128,ea(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(i,0),s=0);for(let f=s;f<r;f++)e[f]=0;i.setBigUint64(r-8,BigInt(this.length*8),o),this.process(i,0);const a=na(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,h[f],o)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const i=t.slice(0,e);return this.destroy(),i}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:i,length:r,finished:o,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=o,t.length=r,t.pos=a,r%e&&t.buffer.set(i),t}clone(){return this._cloneInto()}}const we=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),mo=BigInt(2**32-1),Ql=BigInt(32);function $g(n,t=!1){return t?{h:Number(n&mo),l:Number(n>>Ql&mo)}:{h:Number(n>>Ql&mo)|0,l:Number(n&mo)|0}}function Ig(n,t=!1){const e=n.length;let i=new Uint32Array(e),r=new Uint32Array(e);for(let o=0;o<e;o++){const{h:s,l:a}=$g(n[o],t);[i[o],r[o]]=[s,a]}return[i,r]}const th=(n,t,e)=>n>>>e,eh=(n,t,e)=>n<<32-e|t>>>e,$i=(n,t,e)=>n>>>e|t<<32-e,Ii=(n,t,e)=>n<<32-e|t>>>e,yo=(n,t,e)=>n<<64-e|t>>>e-32,xo=(n,t,e)=>n>>>e-32|t<<64-e;function $n(n,t,e,i){const r=(t>>>0)+(i>>>0);return{h:n+e+(r/2**32|0)|0,l:r|0}}const Fg=(n,t,e)=>(n>>>0)+(t>>>0)+(e>>>0),Rg=(n,t,e,i)=>t+e+i+(n/2**32|0)|0,Dg=(n,t,e,i)=>(n>>>0)+(t>>>0)+(e>>>0)+(i>>>0),zg=(n,t,e,i,r)=>t+e+i+r+(n/2**32|0)|0,Bg=(n,t,e,i,r)=>(n>>>0)+(t>>>0)+(e>>>0)+(i>>>0)+(r>>>0),Og=(n,t,e,i,r,o)=>t+e+i+r+o+(n/2**32|0)|0,nh=Ig(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),Ng=nh[0],Wg=nh[1],qn=new Uint32Array(80),Zn=new Uint32Array(80);class Hg extends Lg{constructor(t){super(128,t,16,!1)}get(){const{Ah:t,Al:e,Bh:i,Bl:r,Ch:o,Cl:s,Dh:a,Dl:c,Eh:l,El:h,Fh:f,Fl:u,Gh:d,Gl:p,Hh:y,Hl:g}=this;return[t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g]}set(t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g){this.Ah=t|0,this.Al=e|0,this.Bh=i|0,this.Bl=r|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=f|0,this.Fl=u|0,this.Gh=d|0,this.Gl=p|0,this.Hh=y|0,this.Hl=g|0}process(t,e){for(let x=0;x<16;x++,e+=4)qn[x]=t.getUint32(e),Zn[x]=t.getUint32(e+=4);for(let x=16;x<80;x++){const v=qn[x-15]|0,k=Zn[x-15]|0,M=$i(v,k,1)^$i(v,k,8)^th(v,k,7),C=Ii(v,k,1)^Ii(v,k,8)^eh(v,k,7),E=qn[x-2]|0,_=Zn[x-2]|0,T=$i(E,_,19)^yo(E,_,61)^th(E,_,6),I=Ii(E,_,19)^xo(E,_,61)^eh(E,_,6),L=Dg(C,I,Zn[x-7],Zn[x-16]),P=zg(L,M,T,qn[x-7],qn[x-16]);qn[x]=P|0,Zn[x]=L|0}let{Ah:i,Al:r,Bh:o,Bl:s,Ch:a,Cl:c,Dh:l,Dl:h,Eh:f,El:u,Fh:d,Fl:p,Gh:y,Gl:g,Hh:m,Hl:b}=this;for(let x=0;x<80;x++){const v=$i(f,u,14)^$i(f,u,18)^yo(f,u,41),k=Ii(f,u,14)^Ii(f,u,18)^xo(f,u,41),M=f&d^~f&y,C=u&p^~u&g,E=Bg(b,k,C,Wg[x],Zn[x]),_=Og(E,m,v,M,Ng[x],qn[x]),T=E|0,I=$i(i,r,28)^yo(i,r,34)^yo(i,r,39),L=Ii(i,r,28)^xo(i,r,34)^xo(i,r,39),P=i&o^i&a^o&a,A=r&s^r&c^s&c;m=y|0,b=g|0,y=d|0,g=p|0,d=f|0,p=u|0,{h:f,l:u}=$n(l|0,h|0,_|0,T|0),l=a|0,h=c|0,a=o|0,c=s|0,o=i|0,s=r|0;const w=Fg(T,L,A);i=Rg(w,_,I,P),r=w|0}({h:i,l:r}=$n(this.Ah|0,this.Al|0,i|0,r|0)),{h:o,l:s}=$n(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l:c}=$n(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=$n(this.Dh|0,this.Dl|0,l|0,h|0),{h:f,l:u}=$n(this.Eh|0,this.El|0,f|0,u|0),{h:d,l:p}=$n(this.Fh|0,this.Fl|0,d|0,p|0),{h:y,l:g}=$n(this.Gh|0,this.Gl|0,y|0,g|0),{h:m,l:b}=$n(this.Hh|0,this.Hl|0,m|0,b|0),this.set(i,r,o,s,a,c,l,h,f,u,d,p,y,g,m,b)}roundClean(){ea(qn,Zn)}destroy(){this.destroyed=!0,ea(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Vg extends Hg{constructor(){super(64);bt(this,"Ah",we[0]|0);bt(this,"Al",we[1]|0);bt(this,"Bh",we[2]|0);bt(this,"Bl",we[3]|0);bt(this,"Ch",we[4]|0);bt(this,"Cl",we[5]|0);bt(this,"Dh",we[6]|0);bt(this,"Dl",we[7]|0);bt(this,"Eh",we[8]|0);bt(this,"El",we[9]|0);bt(this,"Fh",we[10]|0);bt(this,"Fl",we[11]|0);bt(this,"Gh",we[12]|0);bt(this,"Gl",we[13]|0);bt(this,"Hh",we[14]|0);bt(this,"Hl",we[15]|0)}}const Gg=Pg(()=>new Vg,Tg(3));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Re=(n,t,e)=>hi(n,t,e),ih=ta,rh=ia,oh=(...n)=>Cg(...n),Yg=n=>ra(n),Xg=ql,Ug=n=>Eg(n),bo=BigInt(0),oa=BigInt(1);function vo(n,t=""){if(typeof n!="boolean"){const e=t&&`"${t}" `;throw new TypeError(e+"expected boolean, got type="+typeof n)}return n}function jg(n){if(typeof n=="bigint"){if(!wo(n))throw new RangeError("positive bigint expected, got "+n)}else ih(n);return n}function sa(n,t=""){if(typeof n!="number"){const e=t&&`"${t}" `;throw new TypeError(e+"expected number, got type="+typeof n)}if(!Number.isSafeInteger(n)){const e=t&&`"${t}" `;throw new RangeError(e+"expected safe integer, got "+n)}}function sh(n){if(typeof n!="string")throw new TypeError("hex string expected, got "+typeof n);return n===""?bo:BigInt("0x"+n)}function qg(n){return sh(ia(n))}function lr(n){return sh(ia(aa(hi(n)).reverse()))}function ah(n,t){if(ta(t),t===0)throw new RangeError("zero length");n=jg(n);const e=n.toString(16);if(e.length>t*2)throw new RangeError("number too large");return ra(e.padStart(t*2,"0"))}function Zg(n,t){return ah(n,t).reverse()}function Kg(n,t){if(n=Re(n),t=Re(t),n.length!==t.length)return!1;let e=0;for(let i=0;i<n.length;i++)e|=n[i]^t[i];return e===0}function aa(n){return Uint8Array.from(Re(n))}const wo=n=>typeof n=="bigint"&&bo<=n;function Jg(n,t,e){return wo(n)&&wo(t)&&wo(e)&&t<=n&&n<e}function ch(n,t,e,i){if(!Jg(t,e,i))throw new RangeError("expected valid "+n+": "+e+" <= n < "+i+", got "+t)}function Qg(n){if(n<bo)throw new Error("expected non-negative bigint, got "+n);let t;for(t=0;n>bo;n>>=oa,t+=1);return t}const t0=n=>(oa<<BigInt(n))-oa;function ca(n,t={},e={}){if(Object.prototype.toString.call(n)!=="[object Object]")throw new TypeError("expected valid options object");function i(o,s,a){if(!a&&s!=="function"&&!Object.hasOwn(n,o))throw new TypeError(`param "${o}" is invalid: expected own property`);const c=n[o];if(a&&c===void 0)return;const l=typeof c;if(l!==s||c===null)throw new TypeError(`param "${o}" is invalid: expected ${s}, got ${l}`)}const r=(o,s)=>Object.entries(o).forEach(([a,c])=>i(a,c,s));r(t,!1),r(e,!0)}const lh=()=>{throw new Error("not implemented")};/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ke=BigInt(0),be=BigInt(1),ui=BigInt(2),hh=BigInt(3),uh=BigInt(4),fh=BigInt(5),e0=BigInt(7),dh=BigInt(8),n0=BigInt(9),ph=BigInt(16);function he(n,t){if(t<=ke)throw new Error("mod: expected positive modulus, got "+t);const e=n%t;return e>=ke?e:t+e}function kn(n,t,e){if(t<ke)throw new Error("pow2: expected non-negative exponent, got "+t);let i=n;for(;t-- >ke;)i*=i,i%=e;return i}function gh(n,t){if(n===ke)throw new Error("invert: expected non-zero number");if(t<=ke)throw new Error("invert: expected positive modulus, got "+t);let e=he(n,t),i=t,r=ke,o=be;for(;e!==ke;){const a=i/e,c=i-e*a,l=r-o*a;i=e,e=c,r=o,o=l}if(i!==be)throw new Error("invert: does not exist");return he(r,t)}function la(n,t,e){const i=n;if(!i.eql(i.sqr(t),e))throw new Error("Cannot find square root")}function mh(n,t){const e=n,i=(e.ORDER+be)/uh,r=e.pow(t,i);return la(e,r,t),r}function i0(n,t){const e=n,i=(e.ORDER-fh)/dh,r=e.mul(t,ui),o=e.pow(r,i),s=e.mul(t,o),a=e.mul(e.mul(s,ui),o),c=e.mul(s,e.sub(a,e.ONE));return la(e,c,t),c}function r0(n){const t=ha(n),e=yh(n),i=e(t,t.neg(t.ONE)),r=e(t,i),o=e(t,t.neg(i)),s=(n+e0)/ph;return(a,c)=>{const l=a;let h=l.pow(c,s),f=l.mul(h,i);const u=l.mul(h,r),d=l.mul(h,o),p=l.eql(l.sqr(f),c),y=l.eql(l.sqr(u),c);h=l.cmov(h,f,p),f=l.cmov(d,u,y);const g=l.eql(l.sqr(f),c),m=l.cmov(h,f,g);return la(l,m,c),m}}function yh(n){if(n<hh)throw new Error("sqrt is not defined for small field");let t=n-be,e=0;for(;t%ui===ke;)t/=ui,e++;let i=ui;const r=ha(n);for(;bh(r,i)===1;)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(e===1)return mh;let o=r.pow(i,t);const s=(t+be)/ui;return function(c,l){const h=c;if(h.is0(l))return l;if(bh(h,l)!==1)throw new Error("Cannot find square root");let f=e,u=h.mul(h.ONE,o),d=h.pow(l,t),p=h.pow(l,s);for(;!h.eql(d,h.ONE);){if(h.is0(d))return h.ZERO;let y=1,g=h.sqr(d);for(;!h.eql(g,h.ONE);)if(y++,g=h.sqr(g),y===f)throw new Error("Cannot find square root");const m=be<<BigInt(f-y-1),b=h.pow(u,m);f=y,u=h.sqr(b),d=h.mul(d,u),p=h.mul(p,b)}return p}}function o0(n){return n%uh===hh?mh:n%dh===fh?i0:n%ph===n0?r0(n):yh(n)}const fi=(n,t)=>(he(n,t)&be)===be,s0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function a0(n){const t={ORDER:"bigint",BYTES:"number",BITS:"number"},e=s0.reduce((i,r)=>(i[r]="function",i),t);if(ca(n,e),sa(n.BYTES,"BYTES"),sa(n.BITS,"BITS"),n.BYTES<1||n.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(n.ORDER<=be)throw new Error("invalid field: expected ORDER > 1, got "+n.ORDER);return n}function c0(n,t,e){const i=n;if(e<ke)throw new Error("invalid exponent, negatives unsupported");if(e===ke)return i.ONE;if(e===be)return t;let r=i.ONE,o=t;for(;e>ke;)e&be&&(r=i.mul(r,o)),o=i.sqr(o),e>>=be;return r}function xh(n,t,e=!1){const i=n,r=new Array(t.length).fill(e?i.ZERO:void 0),o=t.reduce((a,c,l)=>i.is0(c)?a:(r[l]=a,i.mul(a,c)),i.ONE),s=i.inv(o);return t.reduceRight((a,c,l)=>i.is0(c)?a:(r[l]=i.mul(a,r[l]),i.mul(a,c)),s),r}function bh(n,t){const e=n,i=(e.ORDER-be)/ui,r=e.pow(t,i),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),a=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!a)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function l0(n,t){if(t!==void 0&&ih(t),n<=ke)throw new Error("invalid n length: expected positive n, got "+n);if(t!==void 0&&t<1)throw new Error("invalid n length: expected positive bit length, got "+t);const e=Qg(n);if(t!==void 0&&t<e)throw new Error(`invalid n length: expected bit length (${e}) >= n.length (${t})`);const i=t!==void 0?t:e,r=Math.ceil(i/8);return{nBitLength:i,nByteLength:r}}const vh=new WeakMap;class wh{constructor(t,e={}){bt(this,"ORDER");bt(this,"BITS");bt(this,"BYTES");bt(this,"isLE");bt(this,"ZERO",ke);bt(this,"ONE",be);bt(this,"_lengths");bt(this,"_mod");if(t<=be)throw new Error("invalid field: expected ORDER > 1, got "+t);let i;this.isLE=!1,e!=null&&typeof e=="object"&&(typeof e.BITS=="number"&&(i=e.BITS),typeof e.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:e.sqrt,enumerable:!0}),typeof e.isLE=="boolean"&&(this.isLE=e.isLE),e.allowedLengths&&(this._lengths=Object.freeze(e.allowedLengths.slice())),typeof e.modFromBytes=="boolean"&&(this._mod=e.modFromBytes));const{nBitLength:r,nByteLength:o}=l0(t,i);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=r,this.BYTES=o,Object.freeze(this)}create(t){return he(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof t);return ke<=t&&t<this.ORDER}is0(t){return t===ke}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&be)===be}neg(t){return he(-t,this.ORDER)}eql(t,e){return t===e}sqr(t){return he(t*t,this.ORDER)}add(t,e){return he(t+e,this.ORDER)}sub(t,e){return he(t-e,this.ORDER)}mul(t,e){return he(t*e,this.ORDER)}pow(t,e){return c0(this,t,e)}div(t,e){return he(t*gh(e,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,e){return t+e}subN(t,e){return t-e}mulN(t,e){return t*e}inv(t){return gh(t,this.ORDER)}sqrt(t){let e=vh.get(this);return e||vh.set(this,e=o0(this.ORDER)),e(this,t)}toBytes(t){return this.isLE?Zg(t,this.BYTES):ah(t,this.BYTES)}fromBytes(t,e=!1){Re(t);const{_lengths:i,BYTES:r,isLE:o,ORDER:s,_mod:a}=this;if(i){if(t.length<1||!i.includes(t.length)||t.length>r)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+t.length);const l=new Uint8Array(r);l.set(t,o?0:l.length-t.length),t=l}if(t.length!==r)throw new Error("Field.fromBytes: expected "+r+" bytes, got "+t.length);let c=o?lr(t):qg(t);if(a&&(c=he(c,s)),!e&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return xh(this,t)}cmov(t,e,i){return vo(i,"condition"),i?e:t}}Object.freeze(wh.prototype);function ha(n,t={}){return new wh(n,t)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const ko=BigInt(0),ua=BigInt(1);function kh(n,t){const e=t.negate();return n?e:t}function fa(n,t){const e=xh(n.Fp,t.map(i=>i.Z));return t.map((i,r)=>n.fromAffine(i.toAffine(e[r])))}function Mh(n,t){if(!Number.isSafeInteger(n)||n<=0||n>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+n)}function da(n,t){Mh(n,t);const e=Math.ceil(t/n)+1,i=2**(n-1),r=2**n,o=t0(n),s=BigInt(n);return{windows:e,windowSize:i,mask:o,maxNumber:r,shiftBy:s}}function Ah(n,t,e){const{windowSize:i,mask:r,maxNumber:o,shiftBy:s}=e;let a=Number(n&r),c=n>>s;a>i&&(a-=o,c+=ua);const l=t*i,h=l+Math.abs(a)-1,f=a===0,u=a<0,d=t%2!==0;return{nextN:c,offset:h,isZero:f,isNeg:u,isNegF:d,offsetF:l}}const pa=new WeakMap,Sh=new WeakMap;function ga(n){return Sh.get(n)||1}function _h(n){if(n!==ko)throw new Error("invalid wNAF")}class h0{constructor(t,e){bt(this,"BASE");bt(this,"ZERO");bt(this,"Fn");bt(this,"bits");this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=e}_unsafeLadder(t,e,i=this.ZERO){let r=t;for(;e>ko;)e&ua&&(i=i.add(r)),r=r.double(),e>>=ua;return i}precomputeWindow(t,e){const{windows:i,windowSize:r}=da(e,this.bits),o=[];let s=t,a=s;for(let c=0;c<i;c++){a=s,o.push(a);for(let l=1;l<r;l++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(t,e,i){if(!this.Fn.isValid(i))throw new Error("invalid scalar");let r=this.ZERO,o=this.BASE;const s=da(t,this.bits);for(let a=0;a<s.windows;a++){const{nextN:c,offset:l,isZero:h,isNeg:f,isNegF:u,offsetF:d}=Ah(i,a,s);i=c,h?o=o.add(kh(u,e[d])):r=r.add(kh(f,e[l]))}return _h(i),{p:r,f:o}}wNAFUnsafe(t,e,i,r=this.ZERO){const o=da(t,this.bits);for(let s=0;s<o.windows&&i!==ko;s++){const{nextN:a,offset:c,isZero:l,isNeg:h}=Ah(i,s,o);if(i=a,!l){const f=e[c];r=r.add(h?f.negate():f)}}return _h(i),r}getPrecomputes(t,e,i){let r=pa.get(e);return r||(r=this.precomputeWindow(e,t),t!==1&&(typeof i=="function"&&(r=i(r)),pa.set(e,r))),r}cached(t,e,i){const r=ga(t);return this.wNAF(r,this.getPrecomputes(r,t,i),e)}unsafe(t,e,i,r){const o=ga(t);return o===1?this._unsafeLadder(t,e,r):this.wNAFUnsafe(o,this.getPrecomputes(o,t,i),e,r)}createCache(t,e){Mh(e,this.bits),Sh.set(t,e),pa.delete(t)}hasCache(t){return ga(t)!==1}}function Ch(n,t,e){if(t){if(t.ORDER!==n)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return a0(t),t}else return ha(n,{isLE:e})}function u0(n,t,e={},i){if(i===void 0&&(i=n==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${n} CURVE object`);for(const c of["p","n","h"]){const l=t[c];if(!(typeof l=="bigint"&&l>ko))throw new Error(`CURVE.${c} must be positive bigint`)}const r=Ch(t.p,e.Fp,i),o=Ch(t.n,e.Fn,i),a=["Gx","Gy","a","d"];for(const c of a)if(!r.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:r,Fn:o}}function f0(n,t){return function(i){const r=n(i);return{secretKey:r,publicKey:t(r)}}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kn=BigInt(0),me=BigInt(1),ma=BigInt(2),d0=BigInt(8);function p0(n,t,e,i){const r=n.sqr(e),o=n.sqr(i),s=n.add(n.mul(t.a,r),o),a=n.add(n.ONE,n.mul(t.d,n.mul(r,o)));return n.eql(s,a)}function g0(n,t={}){const e=t,i=u0("edwards",n,e,e.FpFnLE),{Fp:r,Fn:o}=i;let s=i.CURVE;const{h:a}=s;ca(e,{},{uvRatio:"function"});const c=ma<<BigInt(o.BYTES*8)-me,l=g=>r.create(g),h=e.uvRatio===void 0?(g,m)=>{try{return{isValid:!0,value:r.sqrt(r.div(g,m))}}catch{return{isValid:!1,value:Kn}}}:e.uvRatio;if(!p0(r,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function f(g,m,b=!1){const x=b?me:Kn;return ch("coordinate "+g,m,x,c),m}function u(g){if(!(g instanceof d))throw new Error("EdwardsPoint expected")}const y=class y{constructor(m,b,x,v){bt(this,"X");bt(this,"Y");bt(this,"Z");bt(this,"T");this.X=f("x",m),this.Y=f("y",b),this.Z=f("z",x,!0),this.T=f("t",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(m){if(m instanceof y)throw new Error("extended point not allowed");const{x:b,y:x}=m||{};return f("x",b),f("y",x),new y(b,x,me,l(b*x))}static fromBytes(m,b=!1){const x=r.BYTES,{a:v,d:k}=s;m=aa(Re(m,x,"point")),vo(b,"zip215");const M=aa(m),C=m[x-1];M[x-1]=C&-129;const E=lr(M),_=b?c:r.ORDER;ch("point.y",E,Kn,_);const T=l(E*E),I=l(T-me),L=l(k*T-v);let{isValid:P,value:A}=h(I,L);if(!P)throw new Error("bad point: invalid y coordinate");const w=(A&me)===me,S=(C&128)!==0;if(!b&&A===Kn&&S)throw new Error("bad point: x=0 and x_0=1");return S!==w&&(A=l(-A)),y.fromAffine({x:A,y:E})}static fromHex(m,b=!1){return y.fromBytes(Yg(m),b)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=8,b=!0){return p.createCache(this,m),b||this.multiply(ma),this}assertValidity(){const m=this,{a:b,d:x}=s;if(m.is0())throw new Error("bad point: ZERO");const{X:v,Y:k,Z:M,T:C}=m,E=l(v*v),_=l(k*k),T=l(M*M),I=l(T*T),L=l(E*b),P=l(T*l(L+_)),A=l(I+l(x*l(E*_)));if(P!==A)throw new Error("bad point: equation left != right (1)");const w=l(v*k),S=l(M*C);if(w!==S)throw new Error("bad point: equation left != right (2)")}equals(m){u(m);const{X:b,Y:x,Z:v}=this,{X:k,Y:M,Z:C}=m,E=l(b*C),_=l(k*v),T=l(x*C),I=l(M*v);return E===_&&T===I}is0(){return this.equals(y.ZERO)}negate(){return new y(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:m}=s,{X:b,Y:x,Z:v}=this,k=l(b*b),M=l(x*x),C=l(ma*l(v*v)),E=l(m*k),_=b+x,T=l(l(_*_)-k-M),I=E+M,L=I-C,P=E-M,A=l(T*L),w=l(I*P),S=l(T*P),$=l(L*I);return new y(A,w,$,S)}add(m){u(m);const{a:b,d:x}=s,{X:v,Y:k,Z:M,T:C}=this,{X:E,Y:_,Z:T,T:I}=m,L=l(v*E),P=l(k*_),A=l(C*x*I),w=l(M*T),S=l((v+k)*(E+_)-L-P),$=w-A,R=w+A,F=l(P-b*L),D=l(S*$),z=l(R*F),B=l(S*F),N=l($*R);return new y(D,z,N,B)}subtract(m){return u(m),this.add(m.negate())}multiply(m){if(!o.isValidNot0(m))throw new RangeError("invalid scalar: expected 1 <= sc < curve.n");const{p:b,f:x}=p.cached(this,m,v=>fa(y,v));return fa(y,[b,x])[0]}multiplyUnsafe(m){if(!o.isValid(m))throw new RangeError("invalid scalar: expected 0 <= sc < curve.n");return m===Kn?y.ZERO:this.is0()||m===me?this:p.unsafe(this,m,b=>fa(y,b))}isSmallOrder(){return this.clearCofactor().is0()}isTorsionFree(){return p.unsafe(this,s.n).is0()}toAffine(m){const b=this;let x=m;const{X:v,Y:k,Z:M}=b,C=b.is0();x==null&&(x=C?d0:r.inv(M));const E=l(v*x),_=l(k*x),T=r.mul(M,x);if(C)return{x:Kn,y:me};if(T!==me)throw new Error("invZ was invalid");return{x:E,y:_}}clearCofactor(){return a===me?this:this.multiplyUnsafe(a)}toBytes(){const{x:m,y:b}=this.toAffine(),x=r.toBytes(b);return x[x.length-1]|=m&me?128:0,x}toHex(){return rh(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}};bt(y,"BASE",new y(s.Gx,s.Gy,me,l(s.Gx*s.Gy))),bt(y,"ZERO",new y(Kn,me,me,Kn)),bt(y,"Fp",r),bt(y,"Fn",o);let d=y;const p=new h0(d,o.BITS);return o.BITS>=8&&d.BASE.precompute(8),Object.freeze(d.prototype),Object.freeze(d),d}class hr{constructor(t){bt(this,"ep");this.ep=t}static fromBytes(t){lh()}static fromHex(t){lh()}get x(){return this.toAffine().x}get y(){return this.toAffine().y}clearCofactor(){return this}assertValidity(){this.ep.assertValidity()}toAffine(t){return this.ep.toAffine(t)}toHex(){return rh(this.toBytes())}toString(){return this.toHex()}isTorsionFree(){return!0}isSmallOrder(){return!1}add(t){return this.assertSame(t),this.init(this.ep.add(t.ep))}subtract(t){return this.assertSame(t),this.init(this.ep.subtract(t.ep))}multiply(t){return this.init(this.ep.multiply(t))}multiplyUnsafe(t){return this.init(this.ep.multiplyUnsafe(t))}double(){return this.init(this.ep.double())}negate(){return this.init(this.ep.negate())}precompute(t,e){return this.ep.precompute(t,e),this}}bt(hr,"BASE"),bt(hr,"ZERO"),bt(hr,"Fp"),bt(hr,"Fn");function m0(n,t,e={}){if(typeof t!="function")throw new Error('"hash" function param is required');const i=t,r=e;ca(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",zip215:"boolean",mapToCurve:"function"});const{prehash:o}=r,{BASE:s,Fp:a,Fn:c}=n,l=i.outputLen,h=2*a.BYTES;if(l!==void 0&&(sa(l,"hash.outputLen"),l!==h))throw new Error(`hash.outputLen must be ${h}, got ${l}`);const f=r.randomBytes===void 0?Ug:r.randomBytes,u=r.adjustScalarBytes===void 0?L=>L:r.adjustScalarBytes,d=r.domain===void 0?(L,P,A)=>{if(vo(A,"phflag"),P.length||A)throw new Error("Contexts/pre-hash are not supported");return L}:r.domain;function p(L){return c.create(lr(L))}function y(L){const P=C.secretKey;Re(L,C.secretKey,"secretKey");const A=Re(i(L),2*P,"hashedSecretKey"),w=u(A.slice(0,P)),S=A.slice(P,2*P),$=p(w);return{head:w,prefix:S,scalar:$}}function g(L){const{head:P,prefix:A,scalar:w}=y(L),S=s.multiply(w),$=S.toBytes();return{head:P,prefix:A,scalar:w,point:S,pointBytes:$}}function m(L){return g(L).pointBytes}function b(L=Uint8Array.of(),...P){const A=oh(...P);return p(i(d(A,Re(L,void 0,"context"),!!o)))}function x(L,P,A={}){L=Re(L,void 0,"message"),o&&(L=o(L));const{prefix:w,scalar:S,pointBytes:$}=g(P),R=b(A.context,w,L),F=s.multiply(R).toBytes(),D=b(A.context,F,$,L),z=c.create(R+D*S);if(!c.isValid(z))throw new Error("sign failed: invalid s");const B=oh(F,c.toBytes(z));return Re(B,C.signature,"result")}const v={zip215:r.zip215};function k(L,P,A,w=v){const{context:S}=w,$=w.zip215===void 0?!!v.zip215:w.zip215,R=C.signature;L=Re(L,R,"signature"),P=Re(P,void 0,"message"),A=Re(A,C.publicKey,"publicKey"),$!==void 0&&vo($,"zip215"),o&&(P=o(P));const F=R/2,D=L.subarray(0,F),z=lr(L.subarray(F,R));let B,N,K;try{B=n.fromBytes(A,$),N=n.fromBytes(D,$),K=s.multiplyUnsafe(z)}catch{return!1}if(!$&&B.isSmallOrder())return!1;const V=b(S,D,A,P);return N.add(B.multiplyUnsafe(V)).subtract(K).clearCofactor().is0()}const M=a.BYTES,C={secretKey:M,publicKey:M,signature:2*M,seed:M};function E(L){return L=L===void 0?f(C.seed):L,Re(L,C.seed,"seed")}function _(L){return Xg(L)&&L.length===C.secretKey}function T(L,P){try{return!!n.fromBytes(L,P===void 0?v.zip215:P)}catch{return!1}}const I={getExtendedPublicKey:g,randomSecretKey:E,isValidSecretKey:_,isValidPublicKey:T,toMontgomery(L){const{y:P}=n.fromBytes(L),A=C.publicKey,w=A===32;if(!w&&A!==57)throw new Error("only defined for 25519 and 448");const S=w?a.div(me+P,me-P):a.div(P-me,P+me);return a.toBytes(S)},toMontgomerySecret(L){const P=C.secretKey;Re(L,P);const A=i(L.subarray(0,P));return u(A).subarray(0,P)}};return Object.freeze(C),Object.freeze(I),Object.freeze({keygen:f0(E,m),getPublicKey:m,sign:x,verify:k,utils:I,Point:n,lengths:C})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const y0=BigInt(0),ur=BigInt(1),Ph=BigInt(2),x0=BigInt(5),b0=BigInt(8),fr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Eh={p:fr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:b0,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function v0(n){const t=BigInt(10),e=BigInt(20),i=BigInt(40),r=BigInt(80),o=fr,a=n*n%o*n%o,c=kn(a,Ph,o)*a%o,l=kn(c,ur,o)*n%o,h=kn(l,x0,o)*l%o,f=kn(h,t,o)*h%o,u=kn(f,e,o)*f%o,d=kn(u,i,o)*u%o,p=kn(d,r,o)*d%o,y=kn(p,r,o)*d%o,g=kn(y,t,o)*h%o;return{pow_p_5_8:kn(g,Ph,o)*n%o,b2:a}}function w0(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}const ya=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Th(n,t){const e=fr,i=he(t*t*t,e),r=he(i*i*t,e),o=v0(n*r).pow_p_5_8;let s=he(n*i*o,e);const a=he(t*s*s,e),c=s,l=he(s*ya,e),h=a===n,f=a===he(-n,e),u=a===he(-n*ya,e);return h&&(s=c),(f||u)&&(s=l),fi(s,e)&&(s=he(-s,e)),{isValid:h||f,value:s}}const di=g0(Eh,{uvRatio:Th}),pi=di.Fp,k0=di.Fn;function M0(n){return m0(di,Gg,Object.assign({adjustScalarBytes:w0,zip215:!0},n))}const A0=M0({}),Lh=ya,S0=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),$h=n=>Th(ur,n),_0=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),C0=n=>pi.create(lr(n)&_0),Ye=class Ye extends hr{constructor(t){super(t)}static fromAffine(t){return new Ye(di.fromAffine(t))}assertSame(t){if(!(t instanceof Ye))throw new Error("RistrettoPoint expected")}init(t){return new Ye(t)}static fromBytes(t){hi(t,32);const{a:e,d:i}=Eh,r=fr,o=v=>pi.create(v),s=C0(t);if(!Kg(pi.toBytes(s),t)||fi(s,r))throw new Error("invalid ristretto255 encoding 1");const a=o(s*s),c=o(ur+e*a),l=o(ur-e*a),h=o(c*c),f=o(l*l),u=o(e*i*h-f),{isValid:d,value:p}=$h(o(u*f)),y=o(p*l),g=o(p*y*u);let m=o((s+s)*y);fi(m,r)&&(m=o(-m));const b=o(c*g),x=o(m*b);if(!d||fi(x,r)||b===y0)throw new Error("invalid ristretto255 encoding 2");return new Ye(new di(m,b,ur,x))}static fromHex(t){return Ye.fromBytes(ra(t))}toBytes(){let{X:t,Y:e,Z:i,T:r}=this.ep;const o=fr,s=g=>pi.create(g),a=s(s(i+e)*s(i-e)),c=s(t*e),l=s(c*c),{value:h}=$h(s(a*l)),f=s(h*a),u=s(h*c),d=s(f*u*r);let p;if(fi(r*d,o)){let g=s(e*Lh),m=s(t*Lh);t=g,e=m,p=s(f*S0)}else p=u;fi(t*d,o)&&(e=s(-e));let y=s((i-e)*p);return fi(y,o)&&(y=s(-y)),pi.toBytes(y)}equals(t){this.assertSame(t);const{X:e,Y:i}=this.ep,{X:r,Y:o}=t.ep,s=l=>pi.create(l),a=s(e*o)===s(i*r),c=s(i*o)===s(e*r);return a||c}is0(){return this.equals(Ye.ZERO)}};bt(Ye,"BASE",new Ye(di.BASE)),bt(Ye,"ZERO",new Ye(di.ZERO)),bt(Ye,"Fp",pi),bt(Ye,"Fn",k0);let Fi=Ye;Object.freeze(Fi.BASE),Object.freeze(Fi.ZERO),Object.freeze(Fi.prototype),Object.freeze(Fi);const Ih="katucharts_license",P0=7*24*60*60*1e3,E0=60*60*1e3,T0=8e3,g5="3ab57dfcba56a3c6b1949906ef075ff6536f2a40b328a77733e4d8d837cb6abe",L0="https://charts.katudv.com/api/v1/license/verify";class $0{constructor(){this.licenseKey=null,this.payload=null,this.offlineValid=!1,this.verifyUrl=L0,this.mode="lenient",this.gracePeriodMs=P0,this.recheckIntervalMs=E0,this.cache=null,this.pending=!1,this.timer=null,this.listeners=new Set,this.lastEmitted=null}configure(t){t.verifyUrl!==void 0&&(this.verifyUrl=t.verifyUrl||null),t.mode&&(this.mode=t.mode),t.gracePeriodMs!==void 0&&(this.gracePeriodMs=t.gracePeriodMs),t.recheckIntervalMs!==void 0&&(this.recheckIntervalMs=t.recheckIntervalMs),this.offlineValid&&this.verifyUrl&&this.startOnlineChecks(),this.emit()}setKey(t){this.licenseKey=t,this.payload=null,this.offlineValid=!1,this.cache=null;const e=this.validate(t);return e&&(this.payload=e,this.offlineValid=!0,this.cache=this.loadCache(e.kid)),this.offlineValid&&this.verifyUrl&&this.startOnlineChecks(),this.emit(),this.isLicensed()}isLicensed(){var t;return this.offlineValid?this.verifyUrl?((t=this.cache)==null?void 0:t.lastResult)==="invalid"?!1:this.cache&&this.cache.lastValidAt>0&&xa()-this.cache.lastValidAt<this.gracePeriodMs||this.pending?!0:this.mode!=="strict":!0:!1}getPayload(){return this.payload}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}startOnlineChecks(){var t,e;this.verifyOnline(),this.timer==null&&typeof setInterval<"u"&&this.recheckIntervalMs>0&&(this.timer=setInterval(()=>void this.verifyOnline(),this.recheckIntervalMs),(e=(t=this.timer)==null?void 0:t.unref)==null||e.call(t))}async verifyOnline(){if(!this.verifyUrl||!this.licenseKey||!this.payload||typeof fetch>"u")return;this.pending=!0;const t=this.payload.kid??"",e=typeof window<"u"?window.location.hostname:"";let i="unreachable";try{const r=typeof AbortController<"u"?new AbortController:null,o=r?setTimeout(()=>r.abort(),T0):null,s=await fetch(this.verifyUrl,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:this.licenseKey,domain:e,kid:t}),signal:r==null?void 0:r.signal});o&&clearTimeout(o),s.ok?i=(await s.json()).valid?"valid":"invalid":s.status>=400&&s.status<500&&(i="invalid")}catch{i="unreachable"}this.pending=!1,this.applyResult(t,i)}applyResult(t,e){const i=this.cache,r={kid:t,lastResult:e,lastValidAt:e==="valid"?xa():(i==null?void 0:i.lastValidAt)??0,updatedAt:xa()};this.cache=r,this.saveCache(r),this.emit()}emit(){const t=this.isLicensed();t!==this.lastEmitted&&(this.lastEmitted=t,this.listeners.forEach(e=>{try{e(t)}catch{}}))}loadCache(t){if(!t||typeof localStorage>"u")return null;try{const e=localStorage.getItem(Ih);if(!e)return null;const i=JSON.parse(e);return i.kid===t?i:null}catch{return null}}saveCache(t){if(!(typeof localStorage>"u"))try{localStorage.setItem(Ih,JSON.stringify(t))}catch{}}validate(t){try{const e=t.indexOf(".");if(e===-1)return null;const i=t.substring(0,e),r=t.substring(e+1),o="3ab57dfcba56a3c6b1949906ef075ff6536f2a40b328a77733e4d8d837cb6abe",s=new TextEncoder().encode(i);if(!A0.verify(Fh(r),s,Fh(o)))return null;const a=atob(i),c=JSON.parse(a);return!c.customer||!this.checkExpiry(c.expiry)||!this.checkDomain(c.domains)?null:c}catch{return null}}checkExpiry(t){if(!t)return!0;try{return new Date(t).getTime()>=Date.now()}catch{return!1}}checkDomain(t){if(!t||t.length===0||typeof window>"u")return!0;const e=window.location.hostname;return t.some(i=>{if(i.startsWith("*.")){const r=i.substring(1);return e.endsWith(r)||e===i.substring(2)}return e===i})}}function xa(){return Date.now()}function Fh(n){if(n.length%2!==0)throw new Error("invalid hex length");const t=new Uint8Array(n.length/2);for(let e=0;e<t.length;e++)t[e]=parseInt(n.slice(e*2,e*2+2),16);return t}const tn=new $0;class I0{constructor(){this.indicators=new Map}register(t){this.indicators.set(t.name.toLowerCase(),t)}get(t){return this.indicators.get(t.toLowerCase())}getAll(){return new Map(this.indicators)}}const Rh=globalThis,F0=Rh.__katuIndicatorRegistry||(Rh.__katuIndicatorRegistry=new I0),ba={sma:"sma",ema:"ema",wma:"wma",rsi:"rsi",macd:"macd",stochastic:"stochastic",stoch:"stochastic",bb:"bollingerbands",bollinger:"bollingerbands",bollingerbands:"bollingerbands",atr:"atr",vwap:"vwap",obv:"obv",vbp:"vbp",ichimoku:"ichimoku",ikh:"ichimoku",cci:"cci",roc:"roc",momentum:"momentum",mom:"momentum",dema:"dema",tema:"tema",adx:"adx",psar:"psar"},R0=new Set(Object.keys(ba));function va(n){return!!n&&R0.has(n.toLowerCase())}const Dh="#7798BF",wa="#f15c80",D0="#90ed7d";function z0(n){return n.map((t,e)=>{const i=t.close??t.y??0;return{x:t.x??e,open:t.open??i,high:t.high??i,low:t.low??i,close:i,volume:t.volume??t.z}})}function B0(n,t){const e=n.linkedTo;if(typeof e=="string"){const i=t.find(r=>r.id===e);if(i)return i}return typeof e=="number"&&t[e]?t[e]:t.find(i=>i!==n&&!va(i._internalType))??null}const O0={sma:"SMA",ema:"EMA",wma:"WMA",rsi:"RSI",macd:"MACD",stochastic:"Stochastic",bollingerbands:"Bollinger Bands",atr:"ATR",vwap:"VWAP",obv:"OBV",ichimoku:"Ichimoku",cci:"CCI",roc:"ROC",momentum:"Momentum",dema:"DEMA",tema:"TEMA",adx:"ADX",psar:"PSAR"};function N0(n,t){const e=O0[n]||n.toUpperCase(),i=t.period;return i?`${e} (${i})`:e}function en(n,t,e,i){return{...n,type:t,_internalType:t,_processedData:e,data:e,params:void 0,linkedTo:void 0,...i}}function W0(n,t){return n.map((e,i)=>{var r;return{x:e.x,low:((r=t[i])==null?void 0:r.y)??null,high:e.y??null}})}function H0(n,t,e,i){const r=[],o=n.color||Dh,s=n.lineWidth??1.5,a=n.name||N0(t,i);if(e.bands){if(r.push(en(n,"arearange",W0(e.bands.upper,e.bands.lower),{name:`${a} band`,color:n.color||Dh,fillOpacity:n.fillOpacity??.15,lineWidth:0,showInLegend:!1,enableMouseTracking:!1})),t==="ichimoku")r.push(en(n,"line",e.values,{name:`${a} Tenkan`,color:o,lineWidth:s,marker:{enabled:!1}})),e.signal&&r.push(en(n,"line",e.signal,{name:`${a} Kijun`,color:wa,lineWidth:s,marker:{enabled:!1}}));else{const c=e.bands.middle??e.values;r.push(en(n,"line",c,{name:a,color:o,lineWidth:s,marker:{enabled:!1}}))}return r}return e.histogram?(r.push(en(n,"column",e.histogram,{name:`${a} Histogram`,color:D0,showInLegend:!1,enableMouseTracking:!1})),r.push(en(n,"line",e.values,{name:a,color:o,lineWidth:s,marker:{enabled:!1}})),e.signal&&r.push(en(n,"line",e.signal,{name:`${a} Signal`,color:wa,lineWidth:s,marker:{enabled:!1}})),r):e.signal?(r.push(en(n,"line",e.values,{name:`${a} %K`,color:o,lineWidth:s,marker:{enabled:!1}})),r.push(en(n,"line",e.signal,{name:`${a} %D`,color:wa,lineWidth:s,marker:{enabled:!1}})),r):t==="vbp"?(r.push(en(n,"vbp",e.values,{name:a,showInLegend:n.showInLegend??!1})),r):t==="psar"?(r.push(en(n,"scatter",e.values,{name:a,color:o,marker:{enabled:!0,radius:2,symbol:"circle"}})),r):(r.push(en(n,"line",e.values,{name:a,color:o,lineWidth:s,marker:{enabled:!1}})),r)}function V0(n){if(!n.some(e=>va(e._internalType)))return n;const t=[];for(const e of n){const i=(e._internalType||"").toLowerCase();if(!va(i)){t.push(e);continue}const r=F0.get(ba[i]),o=B0(e,n);if(!r||!o){t.push({...e,type:"line",_internalType:"line",_processedData:[],data:[]});continue}const s=e.params||{},a=r.calculate(z0(o._processedData||[]),s);t.push(...H0(e,ba[i],a,s))}return t.map((e,i)=>({...e,index:i}))}let Mo={};function ka(n){Mo=ge(Mo,n)}function zh(){return Mo}const ii=class ii{parse(t){var o;(o=t.chart)!=null&&o.palette&&!t.colors&&(t={...t,colors:Bl(t.chart.palette)});const e=t.theme?Wl(t.theme):void 0,i=this.mergeWithDefaults(t,e),r=this.normalize(i);return this.toInternal(r)}mergeWithDefaults(t,e){return ge(ge({},Ks),Mo,e??{},t)}normalize(t){var h,f,u;const e={...t};e.xAxis&&!Array.isArray(e.xAxis)&&(e.xAxis=[e.xAxis]),e.yAxis&&!Array.isArray(e.yAxis)&&(e.yAxis=[e.yAxis]),e.colorAxis&&!Array.isArray(e.colorAxis)&&(e.colorAxis=[e.colorAxis]),(!e.xAxis||Array.isArray(e.xAxis)&&e.xAxis.length===0)&&(e.xAxis=[ge({},Ks.xAxis)]),(!e.yAxis||Array.isArray(e.yAxis)&&e.yAxis.length===0)&&(e.yAxis=[ge({},Ks.yAxis)]);for(const d of[e.xAxis,e.yAxis])if(Array.isArray(d))for(const p of d)p.categories&&p.categories.length>0&&(p.type="category");e.series&&!Array.isArray(e.series)&&(e.series=[e.series]);const i=((h=e.chart)==null?void 0:h.type)||"line",r=i==="bar"||Array.isArray(e.series)&&e.series.some(d=>d.type==="bar");if(e.chart&&(r?(e.chart.inverted=!0,e.chart._invertedFromBar=!0):e.chart._invertedFromBar&&(e.chart.inverted=!1,delete e.chart._invertedFromBar)),(i==="manhattan"||Array.isArray(e.series)&&e.series.some(d=>d.type==="manhattan"))&&Array.isArray(e.xAxis)&&(!Array.isArray(e.series)||e.series.some(p=>(p.type==="manhattan"||!p.type&&i==="manhattan")&&p.showChromosomeLabels!==!1)))for(const p of e.xAxis)p.labels={...p.labels,enabled:!1},p.tickLength=0;if(i==="pictorial"||Array.isArray(e.series)&&e.series.some(d=>d.type==="pictorial")){for(const d of[e.xAxis,e.yAxis])if(Array.isArray(d))for(const p of d)p.gridLineWidth=0}const a=!!((f=e.chart)!=null&&f.polar),c=(u=e.chart)==null?void 0:u.type;a&&Array.isArray(e.series)&&(e.series=e.series.map(d=>{const p=d.type||c||"line",y=!d.type||d.type==="line"||d.type==="spline",g=!d.type&&(c==="line"||c==="spline"),m={...d,type:y?"radar":d.type};return d.type==="line"||d.type==="spline"||g?m._polarSubType="line":(p==="column"||p==="bar")&&(m._polarSubType="column"),m}));const l=Array.isArray(e.colorAxis)?e.colorAxis[0]:e.colorAxis;return Array.isArray(e.series)&&(e.series=e.series.map(d=>{const p=this.normalizeSeries(d,a&&(!d.type||d.type==="line"||d.type==="spline")?"radar":i,e.plotOptions);return(p.type==="heatmap"||p.type==="treemap")&&l&&!p.colorAxis&&(p.colorAxis=l),(p.type==="map"||p.type==="mappoint"||p.type==="flowmap")&&this.applyMapTopLevelOptions(p,e,l),p})),this.applyAutoHeight(e),e}applyAutoHeight(t){var i;const e=t.chart;if(e){if(e._autoScrollMinHeight!=null){const r=e.scrollablePlotArea;if(r&&typeof r=="object"&&r.minHeight===e._autoScrollMinHeight){const o={...r};delete o.minHeight,e.scrollablePlotArea=Object.keys(o).length?o:void 0}delete e._autoScrollMinHeight}if(e.height==null&&e.inverted){const r=Array.isArray(t.xAxis)?t.xAxis:t.xAxis?[t.xAxis]:[];let o=0;for(const s of r){const a=((i=s==null?void 0:s.categories)==null?void 0:i.length)??0;a>o&&(o=a)}if(o>12){const s=Math.min(o*26+130,9e3),a=e.scrollablePlotArea&&typeof e.scrollablePlotArea=="object"?e.scrollablePlotArea:{};e.scrollablePlotArea={...a,minHeight:s},e._autoScrollMinHeight=s;return}}}}applyMapTopLevelOptions(t,e,i){var r,o;i&&(!t.colorAxis||typeof t.colorAxis!="object")&&(t.colorAxis=i),t.mapNavigation==null&&e.mapNavigation!=null&&(t.mapNavigation=e.mapNavigation),t.projection==null&&((r=e.mapView)==null?void 0:r.projection)!=null&&(t.projection=e.mapView.projection),t.mapData==null&&((o=e.chart)==null?void 0:o.map)!=null&&(t.mapData=e.chart.map)}static mergeDataLabels(t){let e;for(const i of t)i!==void 0&&(e=ii.mergeTwoDataLabels(e,i));return e}static mergeTwoDataLabels(t,e){if(t===void 0)return e;if(e===void 0)return t;const i=Array.isArray(t)?t:[t],r=Array.isArray(e)?e:[e],o=Math.max(i.length,r.length),s=[];for(let a=0;a<o;a++){const c=i[a]??i[0]??{},l=r[a]??r[0]??{};s.push(ge({},c,l))}return s.length===1&&!Array.isArray(t)&&!Array.isArray(e)?s[0]:s}normalizeSeries(t,e,i){let r={...t};if(r.type?delete r._typeFromChart:(r.type=e,r._typeFromChart=!0),i){const o=i.series||{},s=i[r.type]||{},a=r._polarSubType,c=a?i[a]||{}:{},l=ii.mergeDataLabels([o,c,s,r].map(h=>h.dataLabels));r=ge({},o,c,s,r),l!==void 0&&(r.dataLabels=l)}if(Array.isArray(r.data)){const o=r.turboThreshold??1e3;if(r.data.length>o){const s=r.data[0];if(s!==null&&typeof s=="object"&&!Array.isArray(s)&&console.warn(`KatuCharts: series data length (${r.data.length}) exceeds turboThreshold (${o}). Use array format (numbers or [x,y] pairs) for better performance.`),typeof s=="number"||Array.isArray(s)&&typeof s[0]=="number")return r.data=this.normalizeDataBulk(r.data,r),r}r.data=r.data.map((s,a)=>this.normalizeDataPoint(s,a,r))}else r.data!=null&&(r.data=[]);return r}defaultArrayKeys(t,e){return t?ii.OHLC_TYPES.has(t)?e>=5?["x","open","high","low","close"]:["open","high","low","close"]:ii.RANGE_TYPES.has(t)?e>=3?["x","low","high"]:["low","high"]:null:null}normalizeDataPoint(t,e,i){if(t===null)return{x:(i.pointStart??0)+e*(i.pointInterval??1),y:null};if(typeof t=="number")return{x:(i.pointStart??0)+e*(i.pointInterval??1),y:t};if(Array.isArray(t)&&t.length===5&&i.type==="boxplot"){const r=t;return{x:(i.pointStart??0)+e*(i.pointInterval??1),low:r[0],q1:r[1],median:r[2],q3:r[3],high:r[4]}}if(Array.isArray(t)&&i.type==="flowmap")return{from:t[0],to:t[1],weight:t[2]};if(Array.isArray(t)){if(i.keys&&i.keys.length>0){const o={};for(let s=0;s<i.keys.length&&s<t.length;s++)o[i.keys[s]]=t[s];return o.x===void 0&&(!Li.has(i.type)||!o.name)&&(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o}const r=this.defaultArrayKeys(i.type,t.length);if(r){const o={};for(let s=0;s<r.length&&s<t.length;s++)o[r[s]]=t[s];return o.x===void 0&&(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o.close!==void 0&&o.y===void 0&&(o.y=o.close),o}if(typeof t[0]=="string"){const o={name:t[0],y:t[1]};return Li.has(i.type)||(o.x=(i.pointStart??0)+e*(i.pointInterval??1)),o}return t.length>=3?{x:t[0],y:t[1],z:t[2]}:{x:t[0],y:t[1]}}if(typeof t=="object"){const r={...t},o=i.type==="map"||i.type==="mappoint"||i.type==="flowmap",s=!Li.has(i.type);return!o&&r.x===void 0&&(s||!r.name)&&(r.x=(i.pointStart??0)+e*(i.pointInterval??1)),r}return{y:null}}normalizeDataBulk(t,e){const i=t.length,r=new Array(i),o=e.pointStart??0,s=e.pointInterval??1,a=t[0];if(typeof a=="number")for(let c=0;c<i;c++)r[c]={x:o+c*s,y:t[c]};else{const c=Array.isArray(a)?this.defaultArrayKeys(e.type,a.length):null;if(c)for(let l=0;l<i;l++){const h=t[l],f={};for(let u=0;u<c.length&&u<h.length;u++)f[c[u]]=h[u];f.x===void 0&&(f.x=o+l*s),f.close!==void 0&&f.y===void 0&&(f.y=f.close),r[l]=f}else for(let l=0;l<i;l++){const h=t[l];h.length>=3?r[l]={x:h[0],y:h[1],z:h[2]}:r[l]={x:h[0],y:h[1]}}}return r}enforceCredits(t){return tn.isLicensed()?t:{...t,enabled:!0,text:!t.text||!t.text.trim()?"Powered by: KatuCharts":t.text}}toInternal(t){var c,l,h;const e=!!((c=t.chart)!=null&&c.inverted),i=(l=t.chart)==null?void 0:l.backgroundColor,r=t.xAxis.map((f,u)=>({...f,index:u,isX:!0,_inverted:e,_backgroundColor:i})),o=t.yAxis.map((f,u)=>({...f,index:u,isX:!1,_inverted:e,_backgroundColor:i})),s=(t.series||[]).map((f,u)=>{var m;const d=typeof f.xAxis=="number"?f.xAxis:0,p=typeof f.yAxis=="number"?f.yAxis:0,y=f.type||((m=t.chart)==null?void 0:m.type)||"line",g=y==="pie"||y==="donut"||y==="sankey";return{...f,index:u,_internalType:y,_xAxisIndex:d,_yAxisIndex:p,_xAxis:r[d]||r[0],_yAxis:o[p]||o[0],_processedData:f.data||[],...g&&f.showInLegend===void 0?{showInLegend:!1}:{}}}),a=V0(s);return{chart:{width:null,height:null,backgroundColor:"#ffffff",animation:!0,reflow:!0,...t.chart},title:t.title||{},subtitle:t.subtitle||{},caption:t.caption||{},xAxis:r,yAxis:o,colorAxis:t.colorAxis||[],series:a,tooltip:t.tooltip||{},legend:{...t.legend||{},_backgroundColor:(h=t.chart)==null?void 0:h.backgroundColor},plotOptions:t.plotOptions||{},credits:this.enforceCredits(t.credits||{}),exporting:t.exporting||{},loading:t.loading||{},navigator:t.navigator||{},rangeSelector:t.rangeSelector||{},drilldown:t.drilldown||{},responsive:t.responsive||{},accessibility:t.accessibility||{},colors:t.colors||[],time:t.time||{}}}};ii.OHLC_TYPES=new Set(["candlestick","ohlc","heikinashi","hollowcandlestick"]),ii.RANGE_TYPES=new Set(["arearange","areasplinerange","columnrange"]);let Jn=ii;var Ma="http://www.w3.org/1999/xhtml";const Bh={svg:"http://www.w3.org/2000/svg",xhtml:Ma,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ao(n){var t=n+="",e=t.indexOf(":");return e>=0&&(t=n.slice(0,e))!=="xmlns"&&(n=n.slice(e+1)),Bh.hasOwnProperty(t)?{space:Bh[t],local:n}:n}function G0(n){return function(){var t=this.ownerDocument,e=this.namespaceURI;return e===Ma&&t.documentElement.namespaceURI===Ma?t.createElement(n):t.createElementNS(e,n)}}function Y0(n){return function(){return this.ownerDocument.createElementNS(n.space,n.local)}}function Oh(n){var t=Ao(n);return(t.local?Y0:G0)(t)}function X0(){}function Aa(n){return n==null?X0:function(){return this.querySelector(n)}}function U0(n){typeof n!="function"&&(n=Aa(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=new Array(s),c,l,h=0;h<s;++h)(c=o[h])&&(l=n.call(c,c.__data__,h,o))&&("__data__"in c&&(l.__data__=c.__data__),a[h]=l);return new qe(i,this._parents)}function j0(n){return n==null?[]:Array.isArray(n)?n:Array.from(n)}function q0(){return[]}function Nh(n){return n==null?q0:function(){return this.querySelectorAll(n)}}function Z0(n){return function(){return j0(n.apply(this,arguments))}}function K0(n){typeof n=="function"?n=Z0(n):n=Nh(n);for(var t=this._groups,e=t.length,i=[],r=[],o=0;o<e;++o)for(var s=t[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(i.push(n.call(c,c.__data__,l,s)),r.push(c));return new qe(i,r)}function Wh(n){return function(){return this.matches(n)}}function Hh(n){return function(t){return t.matches(n)}}var J0=Array.prototype.find;function Q0(n){return function(){return J0.call(this.children,n)}}function tm(){return this.firstElementChild}function em(n){return this.select(n==null?tm:Q0(typeof n=="function"?n:Hh(n)))}var nm=Array.prototype.filter;function im(){return Array.from(this.children)}function rm(n){return function(){return nm.call(this.children,n)}}function om(n){return this.selectAll(n==null?im:rm(typeof n=="function"?n:Hh(n)))}function sm(n){typeof n!="function"&&(n=Wh(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=[],c,l=0;l<s;++l)(c=o[l])&&n.call(c,c.__data__,l,o)&&a.push(c);return new qe(i,this._parents)}function Vh(n){return new Array(n.length)}function am(){return new qe(this._enter||this._groups.map(Vh),this._parents)}function So(n,t){this.ownerDocument=n.ownerDocument,this.namespaceURI=n.namespaceURI,this._next=null,this._parent=n,this.__data__=t}So.prototype={constructor:So,appendChild:function(n){return this._parent.insertBefore(n,this._next)},insertBefore:function(n,t){return this._parent.insertBefore(n,t)},querySelector:function(n){return this._parent.querySelector(n)},querySelectorAll:function(n){return this._parent.querySelectorAll(n)}};function cm(n){return function(){return n}}function lm(n,t,e,i,r,o){for(var s=0,a,c=t.length,l=o.length;s<l;++s)(a=t[s])?(a.__data__=o[s],i[s]=a):e[s]=new So(n,o[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function hm(n,t,e,i,r,o,s){var a,c,l=new Map,h=t.length,f=o.length,u=new Array(h),d;for(a=0;a<h;++a)(c=t[a])&&(u[a]=d=s.call(c,c.__data__,a,t)+"",l.has(d)?r[a]=c:l.set(d,c));for(a=0;a<f;++a)d=s.call(n,o[a],a,o)+"",(c=l.get(d))?(i[a]=c,c.__data__=o[a],l.delete(d)):e[a]=new So(n,o[a]);for(a=0;a<h;++a)(c=t[a])&&l.get(u[a])===c&&(r[a]=c)}function um(n){return n.__data__}function fm(n,t){if(!arguments.length)return Array.from(this,um);var e=t?hm:lm,i=this._parents,r=this._groups;typeof n!="function"&&(n=cm(n));for(var o=r.length,s=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var h=i[l],f=r[l],u=f.length,d=dm(n.call(h,h&&h.__data__,l,i)),p=d.length,y=a[l]=new Array(p),g=s[l]=new Array(p),m=c[l]=new Array(u);e(h,f,y,g,m,d,t);for(var b=0,x=0,v,k;b<p;++b)if(v=y[b]){for(b>=x&&(x=b+1);!(k=g[x])&&++x<p;);v._next=k||null}}return s=new qe(s,i),s._enter=a,s._exit=c,s}function dm(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function pm(){return new qe(this._exit||this._groups.map(Vh),this._parents)}function gm(n,t,e){var i=this.enter(),r=this,o=this.exit();return typeof n=="function"?(i=n(i),i&&(i=i.selection())):i=i.append(n+""),t!=null&&(r=t(r),r&&(r=r.selection())),e==null?o.remove():e(o),i&&r?i.merge(r).order():r}function mm(n){for(var t=n.selection?n.selection():n,e=this._groups,i=t._groups,r=e.length,o=i.length,s=Math.min(r,o),a=new Array(r),c=0;c<s;++c)for(var l=e[c],h=i[c],f=l.length,u=a[c]=new Array(f),d,p=0;p<f;++p)(d=l[p]||h[p])&&(u[p]=d);for(;c<r;++c)a[c]=e[c];return new qe(a,this._parents)}function ym(){for(var n=this._groups,t=-1,e=n.length;++t<e;)for(var i=n[t],r=i.length-1,o=i[r],s;--r>=0;)(s=i[r])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function xm(n){n||(n=bm);function t(f,u){return f&&u?n(f.__data__,u.__data__):!f-!u}for(var e=this._groups,i=e.length,r=new Array(i),o=0;o<i;++o){for(var s=e[o],a=s.length,c=r[o]=new Array(a),l,h=0;h<a;++h)(l=s[h])&&(c[h]=l);c.sort(t)}return new qe(r,this._parents).order()}function bm(n,t){return n<t?-1:n>t?1:n>=t?0:NaN}function vm(){var n=arguments[0];return arguments[0]=this,n.apply(null,arguments),this}function wm(){return Array.from(this)}function km(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var i=n[t],r=0,o=i.length;r<o;++r){var s=i[r];if(s)return s}return null}function Mm(){let n=0;for(const t of this)++n;return n}function Am(){return!this.node()}function Sm(n){for(var t=this._groups,e=0,i=t.length;e<i;++e)for(var r=t[e],o=0,s=r.length,a;o<s;++o)(a=r[o])&&n.call(a,a.__data__,o,r);return this}function _m(n){return function(){this.removeAttribute(n)}}function Cm(n){return function(){this.removeAttributeNS(n.space,n.local)}}function Pm(n,t){return function(){this.setAttribute(n,t)}}function Em(n,t){return function(){this.setAttributeNS(n.space,n.local,t)}}function Tm(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttribute(n):this.setAttribute(n,e)}}function Lm(n,t){return function(){var e=t.apply(this,arguments);e==null?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}}function $m(n,t){var e=Ao(n);if(arguments.length<2){var i=this.node();return e.local?i.getAttributeNS(e.space,e.local):i.getAttribute(e)}return this.each((t==null?e.local?Cm:_m:typeof t=="function"?e.local?Lm:Tm:e.local?Em:Pm)(e,t))}function Gh(n){return n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView}function Im(n){return function(){this.style.removeProperty(n)}}function Fm(n,t,e){return function(){this.style.setProperty(n,t,e)}}function Rm(n,t,e){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(n):this.style.setProperty(n,i,e)}}function Dm(n,t,e){return arguments.length>1?this.each((t==null?Im:typeof t=="function"?Rm:Fm)(n,t,e??"")):Ri(this.node(),n)}function Ri(n,t){return n.style.getPropertyValue(t)||Gh(n).getComputedStyle(n,null).getPropertyValue(t)}function zm(n){return function(){delete this[n]}}function Bm(n,t){return function(){this[n]=t}}function Om(n,t){return function(){var e=t.apply(this,arguments);e==null?delete this[n]:this[n]=e}}function Nm(n,t){return arguments.length>1?this.each((t==null?zm:typeof t=="function"?Om:Bm)(n,t)):this.node()[n]}function Yh(n){return n.trim().split(/^|\s+/)}function Sa(n){return n.classList||new Xh(n)}function Xh(n){this._node=n,this._names=Yh(n.getAttribute("class")||"")}Xh.prototype={add:function(n){var t=this._names.indexOf(n);t<0&&(this._names.push(n),this._node.setAttribute("class",this._names.join(" ")))},remove:function(n){var t=this._names.indexOf(n);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(n){return this._names.indexOf(n)>=0}};function Uh(n,t){for(var e=Sa(n),i=-1,r=t.length;++i<r;)e.add(t[i])}function jh(n,t){for(var e=Sa(n),i=-1,r=t.length;++i<r;)e.remove(t[i])}function Wm(n){return function(){Uh(this,n)}}function Hm(n){return function(){jh(this,n)}}function Vm(n,t){return function(){(t.apply(this,arguments)?Uh:jh)(this,n)}}function Gm(n,t){var e=Yh(n+"");if(arguments.length<2){for(var i=Sa(this.node()),r=-1,o=e.length;++r<o;)if(!i.contains(e[r]))return!1;return!0}return this.each((typeof t=="function"?Vm:t?Wm:Hm)(e,t))}function Ym(){this.textContent=""}function Xm(n){return function(){this.textContent=n}}function Um(n){return function(){var t=n.apply(this,arguments);this.textContent=t??""}}function jm(n){return arguments.length?this.each(n==null?Ym:(typeof n=="function"?Um:Xm)(n)):this.node().textContent}function qm(){this.innerHTML=""}function Zm(n){return function(){this.innerHTML=n}}function Km(n){return function(){var t=n.apply(this,arguments);this.innerHTML=t??""}}function Jm(n){return arguments.length?this.each(n==null?qm:(typeof n=="function"?Km:Zm)(n)):this.node().innerHTML}function Qm(){this.nextSibling&&this.parentNode.appendChild(this)}function ty(){return this.each(Qm)}function ey(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function ny(){return this.each(ey)}function iy(n){var t=typeof n=="function"?n:Oh(n);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function ry(){return null}function oy(n,t){var e=typeof n=="function"?n:Oh(n),i=t==null?ry:typeof t=="function"?t:Aa(t);return this.select(function(){return this.insertBefore(e.apply(this,arguments),i.apply(this,arguments)||null)})}function sy(){var n=this.parentNode;n&&n.removeChild(this)}function ay(){return this.each(sy)}function cy(){var n=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function ly(){var n=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(n,this.nextSibling):n}function hy(n){return this.select(n?ly:cy)}function uy(n){return arguments.length?this.property("__data__",n):this.node().__data__}function fy(n){return function(t){n.call(this,t,this.__data__)}}function dy(n){return n.trim().split(/^|\s+/).map(function(t){var e="",i=t.indexOf(".");return i>=0&&(e=t.slice(i+1),t=t.slice(0,i)),{type:t,name:e}})}function py(n){return function(){var t=this.__on;if(t){for(var e=0,i=-1,r=t.length,o;e<r;++e)o=t[e],(!n.type||o.type===n.type)&&o.name===n.name?this.removeEventListener(o.type,o.listener,o.options):t[++i]=o;++i?t.length=i:delete this.__on}}}function gy(n,t,e){return function(){var i=this.__on,r,o=fy(t);if(i){for(var s=0,a=i.length;s<a;++s)if((r=i[s]).type===n.type&&r.name===n.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=e),r.value=t;return}}this.addEventListener(n.type,o,e),r={type:n.type,name:n.name,value:t,listener:o,options:e},i?i.push(r):this.__on=[r]}}function my(n,t,e){var i=dy(n+""),r,o=i.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,h;c<l;++c)for(r=0,h=a[c];r<o;++r)if((s=i[r]).type===h.type&&s.name===h.name)return h.value}return}for(a=t?gy:py,r=0;r<o;++r)this.each(a(i[r],t,e));return this}function qh(n,t,e){var i=Gh(n),r=i.CustomEvent;typeof r=="function"?r=new r(t,e):(r=i.document.createEvent("Event"),e?(r.initEvent(t,e.bubbles,e.cancelable),r.detail=e.detail):r.initEvent(t,!1,!1)),n.dispatchEvent(r)}function yy(n,t){return function(){return qh(this,n,t)}}function xy(n,t){return function(){return qh(this,n,t.apply(this,arguments))}}function by(n,t){return this.each((typeof t=="function"?xy:yy)(n,t))}function*vy(){for(var n=this._groups,t=0,e=n.length;t<e;++t)for(var i=n[t],r=0,o=i.length,s;r<o;++r)(s=i[r])&&(yield s)}var Zh=[null];function qe(n,t){this._groups=n,this._parents=t}function dr(){return new qe([[document.documentElement]],Zh)}function wy(){return this}qe.prototype=dr.prototype={constructor:qe,select:U0,selectAll:K0,selectChild:em,selectChildren:om,filter:sm,data:fm,enter:am,exit:pm,join:gm,merge:mm,selection:wy,order:ym,sort:xm,call:vm,nodes:wm,node:km,size:Mm,empty:Am,each:Sm,attr:$m,style:Dm,property:Nm,classed:Gm,text:jm,html:Jm,raise:ty,lower:ny,append:iy,insert:oy,remove:ay,clone:hy,datum:uy,on:my,dispatch:by,[Symbol.iterator]:vy};function st(n){return typeof n=="string"?new qe([[document.querySelector(n)]],[document.documentElement]):new qe([[n]],Zh)}function ky(n){let t;for(;t=n.sourceEvent;)n=t;return n}function mn(n,t){if(n=ky(n),t===void 0&&(t=n.currentTarget),t){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var i=e.createSVGPoint();return i.x=n.clientX,i.y=n.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[n.clientX-r.left-t.clientLeft,n.clientY-r.top-t.clientTop]}}return[n.pageX,n.pageY]}class My{constructor(t){this.el=t}attr(t){for(const[e,i]of Object.entries(t))e!=="zIndex"&&this.el.attr(e,i);return this}css(t){for(const[e,i]of Object.entries(t)){const r=e.replace(/[A-Z]/g,o=>"-"+o.toLowerCase());this.el.style(r,i),e==="color"&&this.el.attr("fill",i)}return this}add(){return this}getBBox(){const t=this.el.node();if(!t||typeof t.getBBox!="function")return{x:0,y:0,width:0,height:0};try{return t.getBBox()}catch{return{x:0,y:0,width:0,height:0}}}destroy(){this.el.remove()}}const ir=class ir{constructor(t,e,i){this.svg=st(t).append("svg").attr("class","katucharts-root").attr("xmlns","http://www.w3.org/2000/svg").attr("width",e).attr("height",i).style("overflow","hidden").style("outline","none").style("display","block").style("max-width","100%"),this.defs=this.svg.append("defs")}setSize(t,e){this.svg.attr("width",t).attr("height",e)}createGroup(t,e){const r=(e||this.svg).append("g");return t&&r.attr("class",t),r}text(t,e,i){const r=this.svg.append("text").attr("x",e).attr("y",i).style("pointer-events","none").text(t);return new My(r)}createClipPath(t,e,i,r){const o=`katucharts-clip-${++ir.clipPathCounter}`;return this.defs.append("clipPath").attr("id",o).append("rect").attr("x",t).attr("y",e).attr("width",i).attr("height",r),o}updateClipPath(t,e,i,r,o){this.defs.select(`#${t} rect`).attr("x",e).attr("y",i).attr("width",r).attr("height",o)}createLinearGradient(t,e,i,r,o,s){const a=t||`katucharts-grad-${++ir.gradientCounter}`,c=this.defs.append("linearGradient").attr("id",a).attr("x1",e).attr("y1",i).attr("x2",r).attr("y2",o);for(const l of s)c.append("stop").attr("offset",l.offset).attr("stop-color",l.color).attr("stop-opacity",l.opacity??1);return a}getSVGNode(){return this.svg.node()}destroy(){this.svg.remove()}getSerializedSVG(){const t=this.svg.node();return t?new XMLSerializer().serializeToString(t):""}};ir.clipPathCounter=0,ir.gradientCounter=0;let _o=ir;class Kh{constructor(){this.listeners=new Map}on(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push({callback:e,once:!1}),this}once(t,e){return this.listeners.has(t)||this.listeners.set(t,[]),this.listeners.get(t).push({callback:e,once:!0}),this}off(t,e){if(!e)return this.listeners.delete(t),this;const i=this.listeners.get(t);return i&&this.listeners.set(t,i.filter(r=>r.callback!==e)),this}emit(t,...e){const i=this.listeners.get(t);if(!i)return this;const r=[];for(const o of i)o.callback(...e),o.once&&r.push(o);return r.length&&this.listeners.set(t,i.filter(o=>!r.includes(o))),this}removeAllListeners(){this.listeners.clear()}static mapEvent(t,e){return`${t}:${e.toLowerCase()}`}}class Ay{constructor(t,e){this.config=t,this.events=e}getConfig(){return this.config}updateConfig(t){this.config=ge(this.config,t),this.events.emit("state:configChanged",this.config)}getSeries(){return this.config.series}getSeriesById(t){return this.config.series.find(e=>e.id===t)}getSeriesByIndex(t){return this.config.series[t]}addSeries(t){this.config.series=[...this.config.series,t],this.events.emit("state:seriesAdded",t)}removeSeries(t){const e=this.config.series[t];return e&&(this.config.series=this.config.series.filter((i,r)=>r!==t),this.events.emit("state:seriesRemoved",e,t)),e}updateSeries(t,e){const i=this.config.series[t];i&&(this.config.series[t]=ge(i,e),this.events.emit("state:seriesUpdated",this.config.series[t],t))}getXAxes(){return this.config.xAxis}getYAxes(){return this.config.yAxis}updateAxis(t,e,i){const r=t?this.config.xAxis:this.config.yAxis;r[e]&&(r[e]=ge(r[e],i),this.events.emit("state:axisUpdated",{isX:t,index:e,config:r[e]}))}}class Sy{constructor(){this.types=new Map}registerType(t,e){this.types.set(t,e)}getType(t){return this.types.get(t)}hasType(t){return this.types.has(t)}getRegisteredTypes(){return Array.from(this.types.keys())}}const Jh=globalThis,St=Jh.__katuChartRegistry||(Jh.__katuChartRegistry=new Sy);class _y{constructor(){this.modules=new Map}register(t){this.modules.set(t.name,t)}get(t){return this.modules.get(t)}getAll(){return Array.from(this.modules.values())}}const Qh=new _y;class Cy{compute(t,e,i){var z,B,N,K,V,G,H,j,U,X,tt,O,it,nt,lt,ht,at;const r=this.getSpacing(t);let o=r.top,s=r.bottom;const a=r.left,c=r.right,l=((z=t.title)==null?void 0:z.widthAdjust)??-44,h=e+l,f=(N=(B=t.title)==null?void 0:B.style)!=null&&N.fontSize?t.title.style:{...(K=t.title)==null?void 0:K.style,fontSize:"18px"},u=(V=t.title)!=null&&V.text?this.estimateWrappedTextHeight(t.title.text,f,h):0,d=((G=t.title)==null?void 0:G.margin)??8,p=(H=t.subtitle)!=null&&H.text?this.estimateWrappedTextHeight(t.subtitle.text,t.subtitle.style,h):0;u>0&&(o=r.top+u+(p>0?3:d)),p>0&&(o+=p+d);const y=t.series.some(W=>W._internalType==="heatmap"),g=((j=t.legend)==null?void 0:j.align)||"center",m=!y&&((U=t.legend)==null?void 0:U.enabled)!==!1&&((X=t.legend)==null?void 0:X.layout)==="vertical"&&(g==="left"||g==="right"),b=y||m?0:this.estimateLegendHeight(t,e),x=((tt=t.legend)==null?void 0:tt.verticalAlign)||"bottom";!m&&x==="bottom"?s=Math.max(s,r.bottom)+b:!m&&x==="top"&&(o+=b);const v=m?this.estimateLegendWidth(t):0,k=m&&g==="left"?v:0,M=m&&g==="right"?v:0;if((O=t.navigator)!=null&&O.enabled){const W=t.navigator;s+=(W.height??40)+(W.margin??20)}const C=(it=t.caption)!=null&&it.text?t.caption.text.replace(/<[^>]*>/g,""):"",E=C?this.estimateWrappedTextHeight(C,(nt=t.caption)==null?void 0:nt.style,e-24):0;E>0&&(s+=E+8);const _=this.isNonCartesian(t),I=!!t.chart.inverted?{...t,xAxis:t.yAxis,yAxis:t.xAxis}:t,L=_?0:this.estimateAxisWidth(I,!0,i,e),P=_?0:this.estimateAxisWidth(I,!1,i,e),A=_?0:this.estimateAxisHeight(I,e);let w=0;y&&((lt=t.colorAxis)==null?void 0:lt.length)>0&&((ht=t.legend)==null?void 0:ht.layout)==="vertical"&&(w=55);const S=a+L+k,$=o,R=Math.max(0,e-a-c-L-P-w-k-M),F=((at=t.chart)==null?void 0:at.marginBottom)!==void 0,D=Math.max(0,i-o-s-(F?0:A));return{plotArea:{x:S,y:$,width:R,height:D},titleArea:{x:r.left,y:r.top,width:e-r.left-r.right,height:u+d},subtitleArea:{x:r.left,y:r.top+u+d,width:e-r.left-r.right,height:p},legendArea:m?{x:g==="right"?e-c-M:a,y:$,width:v,height:D}:{x:0,y:x==="top"?o-b:i-s,width:e,height:b},captionArea:{x:r.left,y:i-r.bottom-E,width:e-r.left-r.right,height:E}}}isNonCartesian(t){return t.series.length>0&&t.series.every(e=>Li.has(e._internalType))}getSpacing(t){var s;const e=t.chart;if(e.margin!==void 0){const a=e.margin;if(typeof a=="number")return{top:a,right:a,bottom:a,left:a};if(Array.isArray(a))return{top:a[0]??10,right:a[1]??10,bottom:a[2]??15,left:a[3]??10}}const i=e.spacing||[10,10,15,10],o=((s=t.exporting)==null?void 0:s.enabled)!==!1&&!this.isNonCartesian(t)?40:i[1]??10;return{top:e.marginTop??e.spacingTop??i[0],right:e.marginRight??e.spacingRight??o,bottom:e.marginBottom??e.spacingBottom??i[2],left:e.marginLeft??e.spacingLeft??i[3]}}estimateTextHeight(t){return se(t==null?void 0:t.fontSize)*1.4}estimateWrappedTextHeight(t,e,i){const r=se(e==null?void 0:e.fontSize),o=r*1.4;if(!i||i<=0)return o;const s=r*.55,a=Math.floor(i/s);if(a<=0)return o;const c=Math.ceil(t.length/a);return o*Math.max(c,1)}computeAutoFontSize(t,e){return e||"12px"}estimateLegendHeight(t,e){var r,o;const i=this.estimateSeriesLegendHeight(t,e);if((r=t.legend)!=null&&r.enabled&&((o=t.legend.bubbleLegend)!=null&&o.enabled)){const s=t.series.find(a=>a._internalType==="bubble");if(s){const a=t.legend.margin??8,l=(t.legend.bubbleLegend.maxSize??(typeof s.maxSize=="number"?s.maxSize:30))*2+16+a;return(t.legend.layout||"horizontal")==="horizontal"&&t.legend.bubbleLegend.layout==="separate"?i+l:Math.max(i,l)}}return i}estimateLegendWidth(t){var u;const e=t.legend;if(!e)return 0;const i=t.series.filter(d=>d.showInLegend!==!1),r=e.itemStyle||{},o=se(r.fontSize||kt),s=e.symbolWidth??12,a=e.symbolPadding??5,c=e.padding??8;let l=0;i.forEach((d,p)=>{const y=d._internalType==="pie"&&Array.isArray(d.data)?d.data.map(g=>(g&&typeof g=="object"?g.name:void 0)||""):[d.name||`Series ${p+1}`];for(const g of y){const m=pe(g,o);m>l&&(l=m)}});let h=s+a+l;if((u=e.bubbleLegend)!=null&&u.enabled){const d=t.series.find(p=>p._internalType==="bubble");if(d){const p=e.bubbleLegend.maxSize??(typeof d.maxSize=="number"?d.maxSize:30),y=e.bubbleLegend.connectorDistance??16;h=Math.max(h,p*2+y+30)}}const f=e.margin??12;return h+c*2+f}estimateSeriesLegendHeight(t,e){var p;if(!((p=t.legend)!=null&&p.enabled))return 0;const i=t.series.filter(y=>y.showInLegend!==!1),r=i.length;if(r===0)return 0;const o=t.legend.margin??8,s=t.legend.layout||"horizontal",c=(t.legend.itemStyle||{}).fontSize||kt,l=this.computeAutoFontSize(r,c),h=t.legend.lineHeight??16,f=t.legend.itemMarginBottom??2,u=t.legend.itemMarginTop??0,d=h+f+u;if(s==="horizontal"){const y=t.legend.padding??4,g=t.legend.symbolWidth??10,m=t.legend.symbolPadding??5,b=t.legend.itemDistance??20,x=this.getSpacing(t),v=t.legend.width||e-x.left-x.right-y*2,k=se(l),M=i.map((P,A)=>P.name||`Series ${A+1}`);let C=0;for(let P=0;P<M.length;P++){const A=t.legend.itemWidth||pe(M[P],k),w=g+m+A;C+=w+(P<M.length-1?b:0)}if(r>8&&C>v){let P=0;for(const F of M){const D=pe(F,k);D>P&&(P=D)}let A,w;if(t.legend.itemWidth)A=t.legend.itemWidth,w=Math.max(2,Math.floor(v/A));else{const F=g+m+P+8;w=Math.max(1,Math.floor(v/F)),A=v/w}const $=Math.ceil(r/w)*d+y*2,R=t.legend.maxHeight;return(R?Math.min($,R):$)+o}let _=y,T=1;for(let P=0;P<r;P++){const A=t.legend.itemWidth||pe(M[P],k),w=g+m+A;P>0&&_+w>v&&(T++,_=y),_+=w+b}const I=T*d+y*2,L=t.legend.maxHeight;return(L?Math.min(I,L):I)+o}return r*d+(t.legend.padding??8)*2+o}estimateAxisWidth(t,e,i,r){var a,c;const o=t.yAxis.filter(l=>e?!l.opposite:l.opposite);if(o.length===0)return 0;let s=0;for(const l of o){if(l.visible===!1)continue;const h=((a=l.labels)==null?void 0:a.enabled)!==!1,f=(c=l.title)==null?void 0:c.text,u=h?this.estimateLabelWidth(l,i,r):0;s+=u+(f?30:0)+(l.offset||0)}return s||30}estimateLabelWidth(t,e,i){var s,a,c,l;if(t.categories&&t.categories.length>0){const h=se(((a=(s=t.labels)==null?void 0:s.style)==null?void 0:a.fontSize)||kt);let f=h;if(e&&t.categories.length>1){const m=e*.8/t.categories.length*.7;h>m&&(f=Math.min(h,Math.max(5,Math.round(m*1.1))))}const u=((l=(c=t.labels)==null?void 0:c.style)==null?void 0:l.fontWeight)||"normal";let d=0;for(const y of t.categories){const g=pe(y,f,u);g>d&&(d=g)}const p=i?Math.max(120,i*.3):460;return Math.max(25,Math.min(d*1.3+16,p))}const r=t.min??null,o=t.max??null;if(r!=null&&o!=null){const f=String(Math.round(Math.max(Math.abs(r),Math.abs(o)))).length+(r<0?1:0);return Math.max(20,f*7+10)}return 25}estimateAxisHeight(t,e=600){var o,s,a,c,l,h,f,u;const i=t.xAxis.filter(d=>!d.opposite);if(i.length===0)return 0;let r=0;for(const d of i){if(d.visible===!1)continue;const p=((o=d.labels)==null?void 0:o.enabled)!==!1,y=(s=d.title)==null?void 0:s.text,g=!!((a=d.labels)!=null&&a.rotation);let m=30;if(p){if(g&&d.categories&&d.categories.length>0){let x=0;for(const C of d.categories)C.length>x&&(x=C.length);const v=se(((l=(c=d.labels)==null?void 0:c.style)==null?void 0:l.fontSize)||kt),k=Math.abs(d.labels.rotation)*(Math.PI/180),M=Math.min(x*v*.62*Math.sin(k),150);m=Math.max(30,M)}else if(g)m=45;else if(d.categories&&d.categories.length>0){const x=se(((f=(h=d.labels)==null?void 0:h.style)==null?void 0:f.fontSize)||kt),v=Array.isArray((u=d.labels)==null?void 0:u.autoRotation)&&d.labels.autoRotation.length>0;let k=0;for(const E of d.categories)E.length>k&&(k=E.length);const M=e*.85/d.categories.length,C=k*x*.6+4>M;if(v&&C){const E=Math.abs(d.labels.autoRotation[0]||45)*(Math.PI/180);m=Math.max(30,Math.min(k*x*.62*Math.sin(E),150))}else m=Math.max(x+8,20)}}else m=0;const b=p?d.tickLength||10:5;r+=m+(y?25:0)+b}return r||40}}function Co(n,t){return n==null||t==null?NaN:n<t?-1:n>t?1:n>=t?0:NaN}function Py(n,t){return n==null||t==null?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function _a(n){let t,e,i;n.length!==2?(t=Co,e=(a,c)=>Co(n(a),c),i=(a,c)=>n(a)-c):(t=n===Co||n===Py?n:Ey,e=n,i=n);function r(a,c,l=0,h=a.length){if(l<h){if(t(c,c)!==0)return h;do{const f=l+h>>>1;e(a[f],c)<0?l=f+1:h=f}while(l<h)}return l}function o(a,c,l=0,h=a.length){if(l<h){if(t(c,c)!==0)return h;do{const f=l+h>>>1;e(a[f],c)<=0?l=f+1:h=f}while(l<h)}return l}function s(a,c,l=0,h=a.length){const f=r(a,c,l,h-1);return f>l&&i(a[f-1],c)>-i(a[f],c)?f-1:f}return{left:r,center:s,right:o}}function Ey(){return 0}function Ty(n){return n===null?NaN:+n}const Ly=_a(Co).right;_a(Ty).center;class gi{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const e=this._partials;let i=0;for(let r=0;r<this._n&&r<32;r++){const o=e[r],s=t+o,a=Math.abs(t)<Math.abs(o)?t-(s-o):o-(s-t);a&&(e[i++]=a),t=s}return e[i]=t,this._n=i+1,this}valueOf(){const t=this._partials;let e=this._n,i,r,o,s=0;if(e>0){for(s=t[--e];e>0&&(i=s,r=t[--e],s=i+r,o=r-(s-i),!o););e>0&&(o<0&&t[e-1]<0||o>0&&t[e-1]>0)&&(r=o*2,i=s+r,r==i-s&&(s=i))}return s}}class tu extends Map{constructor(t,e=Fy){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(eu(this,t))}has(t){return super.has(eu(this,t))}set(t,e){return super.set($y(this,t),e)}delete(t){return super.delete(Iy(this,t))}}function eu({_intern:n,_key:t},e){const i=t(e);return n.has(i)?n.get(i):e}function $y({_intern:n,_key:t},e){const i=t(e);return n.has(i)?n.get(i):(n.set(i,e),e)}function Iy({_intern:n,_key:t},e){const i=t(e);return n.has(i)&&(e=n.get(i),n.delete(i)),e}function Fy(n){return n!==null&&typeof n=="object"?n.valueOf():n}const Ry=Math.sqrt(50),Dy=Math.sqrt(10),zy=Math.sqrt(2);function Po(n,t,e){const i=(t-n)/Math.max(0,e),r=Math.floor(Math.log10(i)),o=i/Math.pow(10,r),s=o>=Ry?10:o>=Dy?5:o>=zy?2:1;let a,c,l;return r<0?(l=Math.pow(10,-r)/s,a=Math.round(n*l),c=Math.round(t*l),a/l<n&&++a,c/l>t&&--c,l=-l):(l=Math.pow(10,r)*s,a=Math.round(n/l),c=Math.round(t/l),a*l<n&&++a,c*l>t&&--c),c<a&&.5<=e&&e<2?Po(n,t,e*2):[a,c,l]}function Ca(n,t,e){if(t=+t,n=+n,e=+e,!(e>0))return[];if(n===t)return[n];const i=t<n,[r,o,s]=i?Po(t,n,e):Po(n,t,e);if(!(o>=r))return[];const a=o-r+1,c=new Array(a);if(i)if(s<0)for(let l=0;l<a;++l)c[l]=(o-l)/-s;else for(let l=0;l<a;++l)c[l]=(o-l)*s;else if(s<0)for(let l=0;l<a;++l)c[l]=(r+l)/-s;else for(let l=0;l<a;++l)c[l]=(r+l)*s;return c}function Pa(n,t,e){return t=+t,n=+n,e=+e,Po(n,t,e)[2]}function Ea(n,t,e){t=+t,n=+n,e=+e;const i=t<n,r=i?Pa(t,n,e):Pa(n,t,e);return(i?-1:1)*(r<0?1/-r:r)}function*By(n){for(const t of n)yield*t}function nu(n){return Array.from(By(n))}function mi(n,t,e){n=+n,t=+t,e=(r=arguments.length)<2?(t=n,n=0,1):r<3?1:+e;for(var i=-1,r=Math.max(0,Math.ceil((t-n)/e))|0,o=new Array(r);++i<r;)o[i]=n+i*e;return o}function yi(n,t){switch(arguments.length){case 0:break;case 1:this.range(n);break;default:this.range(t).domain(n);break}return this}function Oy(n,t){switch(arguments.length){case 0:break;case 1:{typeof n=="function"?this.interpolator(n):this.range(n);break}default:{this.domain(n),typeof t=="function"?this.interpolator(t):this.range(t);break}}return this}const iu=Symbol("implicit");function ru(){var n=new tu,t=[],e=[],i=iu;function r(o){let s=n.get(o);if(s===void 0){if(i!==iu)return i;n.set(o,s=t.push(o)-1)}return e[s%e.length]}return r.domain=function(o){if(!arguments.length)return t.slice();t=[],n=new tu;for(const s of o)n.has(s)||n.set(s,t.push(s)-1);return r},r.range=function(o){return arguments.length?(e=Array.from(o),r):e.slice()},r.unknown=function(o){return arguments.length?(i=o,r):i},r.copy=function(){return ru(t,e).unknown(i)},yi.apply(r,arguments),r}function ou(){var n=ru().unknown(void 0),t=n.domain,e=n.range,i=0,r=1,o,s,a=!1,c=0,l=0,h=.5;delete n.unknown;function f(){var u=t().length,d=r<i,p=d?r:i,y=d?i:r;o=(y-p)/Math.max(1,u-c+l*2),a&&(o=Math.floor(o)),p+=(y-p-o*(u-c))*h,s=o*(1-c),a&&(p=Math.round(p),s=Math.round(s));var g=mi(u).map(function(m){return p+o*m});return e(d?g.reverse():g)}return n.domain=function(u){return arguments.length?(t(u),f()):t()},n.range=function(u){return arguments.length?([i,r]=u,i=+i,r=+r,f()):[i,r]},n.rangeRound=function(u){return[i,r]=u,i=+i,r=+r,a=!0,f()},n.bandwidth=function(){return s},n.step=function(){return o},n.round=function(u){return arguments.length?(a=!!u,f()):a},n.padding=function(u){return arguments.length?(c=Math.min(1,l=+u),f()):c},n.paddingInner=function(u){return arguments.length?(c=Math.min(1,u),f()):c},n.paddingOuter=function(u){return arguments.length?(l=+u,f()):l},n.align=function(u){return arguments.length?(h=Math.max(0,Math.min(1,u)),f()):h},n.copy=function(){return ou(t(),[i,r]).round(a).paddingInner(c).paddingOuter(l).align(h)},yi.apply(f(),arguments)}function Ny(n,t,e,i,r){var o=n*n,s=o*n;return((1-3*n+3*o-s)*t+(4-6*o+3*s)*e+(1+3*n+3*o-3*s)*i+s*r)/6}function Wy(n){var t=n.length-1;return function(e){var i=e<=0?e=0:e>=1?(e=1,t-1):Math.floor(e*t),r=n[i],o=n[i+1],s=i>0?n[i-1]:2*r-o,a=i<t-1?n[i+2]:2*o-r;return Ny((e-i/t)*t,s,r,o,a)}}const Ta=n=>()=>n;function Hy(n,t){return function(e){return n+e*t}}function Vy(n,t,e){return n=Math.pow(n,e),t=Math.pow(t,e)-n,e=1/e,function(i){return Math.pow(n+i*t,e)}}function Gy(n){return(n=+n)==1?su:function(t,e){return e-t?Vy(t,e,n):Ta(isNaN(t)?e:t)}}function su(n,t){var e=t-n;return e?Hy(n,e):Ta(isNaN(n)?t:n)}const xi=function n(t){var e=Gy(t);function i(r,o){var s=e((r=je(r)).r,(o=je(o)).r),a=e(r.g,o.g),c=e(r.b,o.b),l=su(r.opacity,o.opacity);return function(h){return r.r=s(h),r.g=a(h),r.b=c(h),r.opacity=l(h),r+""}}return i.gamma=n,i}(1);function Yy(n){return function(t){var e=t.length,i=new Array(e),r=new Array(e),o=new Array(e),s,a;for(s=0;s<e;++s)a=je(t[s]),i[s]=a.r||0,r[s]=a.g||0,o[s]=a.b||0;return i=n(i),r=n(r),o=n(o),a.opacity=1,function(c){return a.r=i(c),a.g=r(c),a.b=o(c),a+""}}}var Xy=Yy(Wy);function Uy(n,t){t||(t=[]);var e=n?Math.min(t.length,n.length):0,i=t.slice(),r;return function(o){for(r=0;r<e;++r)i[r]=n[r]*(1-o)+t[r]*o;return i}}function jy(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}function qy(n,t){var e=t?t.length:0,i=n?Math.min(e,n.length):0,r=new Array(i),o=new Array(e),s;for(s=0;s<i;++s)r[s]=ue(n[s],t[s]);for(;s<e;++s)o[s]=t[s];return function(a){for(s=0;s<i;++s)o[s]=r[s](a);return o}}function Zy(n,t){var e=new Date;return n=+n,t=+t,function(i){return e.setTime(n*(1-i)+t*i),e}}function yn(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function Ky(n,t){var e={},i={},r;(n===null||typeof n!="object")&&(n={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in n?e[r]=ue(n[r],t[r]):i[r]=t[r];return function(o){for(r in e)i[r]=e[r](o);return i}}var La=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$a=new RegExp(La.source,"g");function Jy(n){return function(){return n}}function Qy(n){return function(t){return n(t)+""}}function au(n,t){var e=La.lastIndex=$a.lastIndex=0,i,r,o,s=-1,a=[],c=[];for(n=n+"",t=t+"";(i=La.exec(n))&&(r=$a.exec(t));)(o=r.index)>e&&(o=t.slice(e,o),a[s]?a[s]+=o:a[++s]=o),(i=i[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:yn(i,r)})),e=$a.lastIndex;return e<t.length&&(o=t.slice(e),a[s]?a[s]+=o:a[++s]=o),a.length<2?c[0]?Qy(c[0].x):Jy(t):(t=c.length,function(l){for(var h=0,f;h<t;++h)a[(f=c[h]).i]=f.x(l);return a.join("")})}function ue(n,t){var e=typeof t,i;return t==null||e==="boolean"?Ta(t):(e==="number"?yn:e==="string"?(i=le(t))?(t=i,xi):au:t instanceof le?xi:t instanceof Date?Zy:jy(t)?Uy:Array.isArray(t)?qy:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ky:yn)(n,t)}function cu(n,t){return n=+n,t=+t,function(e){return Math.round(n*(1-e)+t*e)}}var lu=180/Math.PI,Ia={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function hu(n,t,e,i,r,o){var s,a,c;return(s=Math.sqrt(n*n+t*t))&&(n/=s,t/=s),(c=n*e+t*i)&&(e-=n*c,i-=t*c),(a=Math.sqrt(e*e+i*i))&&(e/=a,i/=a,c/=a),n*i<t*e&&(n=-n,t=-t,c=-c,s=-s),{translateX:r,translateY:o,rotate:Math.atan2(t,n)*lu,skewX:Math.atan(c)*lu,scaleX:s,scaleY:a}}var Eo;function tx(n){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(n+"");return t.isIdentity?Ia:hu(t.a,t.b,t.c,t.d,t.e,t.f)}function ex(n){return n==null||(Eo||(Eo=document.createElementNS("http://www.w3.org/2000/svg","g")),Eo.setAttribute("transform",n),!(n=Eo.transform.baseVal.consolidate()))?Ia:(n=n.matrix,hu(n.a,n.b,n.c,n.d,n.e,n.f))}function uu(n,t,e,i){function r(l){return l.length?l.pop()+" ":""}function o(l,h,f,u,d,p){if(l!==f||h!==u){var y=d.push("translate(",null,t,null,e);p.push({i:y-4,x:yn(l,f)},{i:y-2,x:yn(h,u)})}else(f||u)&&d.push("translate("+f+t+u+e)}function s(l,h,f,u){l!==h?(l-h>180?h+=360:h-l>180&&(l+=360),u.push({i:f.push(r(f)+"rotate(",null,i)-2,x:yn(l,h)})):h&&f.push(r(f)+"rotate("+h+i)}function a(l,h,f,u){l!==h?u.push({i:f.push(r(f)+"skewX(",null,i)-2,x:yn(l,h)}):h&&f.push(r(f)+"skewX("+h+i)}function c(l,h,f,u,d,p){if(l!==f||h!==u){var y=d.push(r(d)+"scale(",null,",",null,")");p.push({i:y-4,x:yn(l,f)},{i:y-2,x:yn(h,u)})}else(f!==1||u!==1)&&d.push(r(d)+"scale("+f+","+u+")")}return function(l,h){var f=[],u=[];return l=n(l),h=n(h),o(l.translateX,l.translateY,h.translateX,h.translateY,f,u),s(l.rotate,h.rotate,f,u),a(l.skewX,h.skewX,f,u),c(l.scaleX,l.scaleY,h.scaleX,h.scaleY,f,u),l=h=null,function(d){for(var p=-1,y=u.length,g;++p<y;)f[(g=u[p]).i]=g.x(d);return f.join("")}}}var nx=uu(tx,"px, ","px)","deg)"),ix=uu(ex,", ",")",")"),rx=1e-12;function fu(n){return((n=Math.exp(n))+1/n)/2}function ox(n){return((n=Math.exp(n))-1/n)/2}function sx(n){return((n=Math.exp(2*n))-1)/(n+1)}const ax=function n(t,e,i){function r(o,s){var a=o[0],c=o[1],l=o[2],h=s[0],f=s[1],u=s[2],d=h-a,p=f-c,y=d*d+p*p,g,m;if(y<rx)m=Math.log(u/l)/t,g=function(C){return[a+C*d,c+C*p,l*Math.exp(t*C*m)]};else{var b=Math.sqrt(y),x=(u*u-l*l+i*y)/(2*l*e*b),v=(u*u-l*l-i*y)/(2*u*e*b),k=Math.log(Math.sqrt(x*x+1)-x),M=Math.log(Math.sqrt(v*v+1)-v);m=(M-k)/t,g=function(C){var E=C*m,_=fu(k),T=l/(e*b)*(_*sx(t*E+k)-ox(k));return[a+T*d,c+T*p,l*_/fu(t*E+k)]}}return g.duration=m*1e3*t/Math.SQRT2,g}return r.rho=function(o){var s=Math.max(.001,+o),a=s*s,c=a*a;return n(s,a,c)},r}(Math.SQRT2,2,4);function cx(n){return function(){return n}}function lx(n){return+n}var du=[0,1];function nn(n){return n}function Fa(n,t){return(t-=n=+n)?function(e){return(e-n)/t}:cx(isNaN(t)?NaN:.5)}function hx(n,t){var e;return n>t&&(e=n,n=t,t=e),function(i){return Math.max(n,Math.min(t,i))}}function ux(n,t,e){var i=n[0],r=n[1],o=t[0],s=t[1];return r<i?(i=Fa(r,i),o=e(s,o)):(i=Fa(i,r),o=e(o,s)),function(a){return o(i(a))}}function fx(n,t,e){var i=Math.min(n.length,t.length)-1,r=new Array(i),o=new Array(i),s=-1;for(n[i]<n[0]&&(n=n.slice().reverse(),t=t.slice().reverse());++s<i;)r[s]=Fa(n[s],n[s+1]),o[s]=e(t[s],t[s+1]);return function(a){var c=Ly(n,a,1,i)-1;return o[c](r[c](a))}}function To(n,t){return t.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown())}function Ra(){var n=du,t=du,e=ue,i,r,o,s=nn,a,c,l;function h(){var u=Math.min(n.length,t.length);return s!==nn&&(s=hx(n[0],n[u-1])),a=u>2?fx:ux,c=l=null,f}function f(u){return u==null||isNaN(u=+u)?o:(c||(c=a(n.map(i),t,e)))(i(s(u)))}return f.invert=function(u){return s(r((l||(l=a(t,n.map(i),yn)))(u)))},f.domain=function(u){return arguments.length?(n=Array.from(u,lx),h()):n.slice()},f.range=function(u){return arguments.length?(t=Array.from(u),h()):t.slice()},f.rangeRound=function(u){return t=Array.from(u),e=cu,h()},f.clamp=function(u){return arguments.length?(s=u?!0:nn,h()):s!==nn},f.interpolate=function(u){return arguments.length?(e=u,h()):e},f.unknown=function(u){return arguments.length?(o=u,f):o},function(u,d){return i=u,r=d,h()}}function pu(){return Ra()(nn,nn)}function dx(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function Lo(n,t){if(!isFinite(n)||n===0)return null;var e=(n=t?n.toExponential(t-1):n.toExponential()).indexOf("e"),i=n.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+n.slice(e+1)]}function Di(n){return n=Lo(Math.abs(n)),n?n[1]:NaN}function px(n,t){return function(e,i){for(var r=e.length,o=[],s=0,a=n[0],c=0;r>0&&a>0&&(c+a+1>i&&(a=Math.max(1,i-c)),o.push(e.substring(r-=a,r+a)),!((c+=a+1)>i));)a=n[s=(s+1)%n.length];return o.reverse().join(t)}}function gx(n){return function(t){return t.replace(/[0-9]/g,function(e){return n[+e]})}}var mx=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function pr(n){if(!(t=mx.exec(n)))throw new Error("invalid format: "+n);var t;return new Da({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}pr.prototype=Da.prototype;function Da(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}Da.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function yx(n){t:for(var t=n.length,e=1,i=-1,r;e<t;++e)switch(n[e]){case".":i=r=e;break;case"0":i===0&&(i=e),r=e;break;default:if(!+n[e])break t;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(r+1):n}var $o;function xx(n,t){var e=Lo(n,t);if(!e)return $o=void 0,n.toPrecision(t);var i=e[0],r=e[1],o=r-($o=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+Lo(n,Math.max(0,t+o-1))[0]}function gu(n,t){var e=Lo(n,t);if(!e)return n+"";var i=e[0],r=e[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const mu={"%":(n,t)=>(n*100).toFixed(t),b:n=>Math.round(n).toString(2),c:n=>n+"",d:dx,e:(n,t)=>n.toExponential(t),f:(n,t)=>n.toFixed(t),g:(n,t)=>n.toPrecision(t),o:n=>Math.round(n).toString(8),p:(n,t)=>gu(n*100,t),r:gu,s:xx,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function yu(n){return n}var xu=Array.prototype.map,bu=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function bx(n){var t=n.grouping===void 0||n.thousands===void 0?yu:px(xu.call(n.grouping,Number),n.thousands+""),e=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",r=n.decimal===void 0?".":n.decimal+"",o=n.numerals===void 0?yu:gx(xu.call(n.numerals,String)),s=n.percent===void 0?"%":n.percent+"",a=n.minus===void 0?"−":n.minus+"",c=n.nan===void 0?"NaN":n.nan+"";function l(f,u){f=pr(f);var d=f.fill,p=f.align,y=f.sign,g=f.symbol,m=f.zero,b=f.width,x=f.comma,v=f.precision,k=f.trim,M=f.type;M==="n"?(x=!0,M="g"):mu[M]||(v===void 0&&(v=12),k=!0,M="g"),(m||d==="0"&&p==="=")&&(m=!0,d="0",p="=");var C=(u&&u.prefix!==void 0?u.prefix:"")+(g==="$"?e:g==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():""),E=(g==="$"?i:/[%p]/.test(M)?s:"")+(u&&u.suffix!==void 0?u.suffix:""),_=mu[M],T=/[defgprs%]/.test(M);v=v===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v));function I(L){var P=C,A=E,w,S,$;if(M==="c")A=_(L)+A,L="";else{L=+L;var R=L<0||1/L<0;if(L=isNaN(L)?c:_(Math.abs(L),v),k&&(L=yx(L)),R&&+L==0&&y!=="+"&&(R=!1),P=(R?y==="("?y:a:y==="-"||y==="("?"":y)+P,A=(M==="s"&&!isNaN(L)&&$o!==void 0?bu[8+$o/3]:"")+A+(R&&y==="("?")":""),T){for(w=-1,S=L.length;++w<S;)if($=L.charCodeAt(w),48>$||$>57){A=($===46?r+L.slice(w+1):L.slice(w))+A,L=L.slice(0,w);break}}}x&&!m&&(L=t(L,1/0));var F=P.length+L.length+A.length,D=F<b?new Array(b-F+1).join(d):"";switch(x&&m&&(L=t(D+L,D.length?b-A.length:1/0),D=""),p){case"<":L=P+L+A+D;break;case"=":L=P+D+L+A;break;case"^":L=D.slice(0,F=D.length>>1)+P+L+A+D.slice(F);break;default:L=D+P+L+A;break}return o(L)}return I.toString=function(){return f+""},I}function h(f,u){var d=Math.max(-8,Math.min(8,Math.floor(Di(u)/3)))*3,p=Math.pow(10,-d),y=l((f=pr(f),f.type="f",f),{suffix:bu[8+d/3]});return function(g){return y(p*g)}}return{format:l,formatPrefix:h}}var Io,gr,vu;vx({thousands:",",grouping:[3],currency:["$",""]});function vx(n){return Io=bx(n),gr=Io.format,vu=Io.formatPrefix,Io}function wx(n){return Math.max(0,-Di(Math.abs(n)))}function kx(n,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Di(t)/3)))*3-Di(Math.abs(n)))}function Mx(n,t){return n=Math.abs(n),t=Math.abs(t)-n,Math.max(0,Di(t)-Di(n))+1}function Ax(n,t,e,i){var r=Ea(n,t,e),o;switch(i=pr(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(n),Math.abs(t));return i.precision==null&&!isNaN(o=kx(r,s))&&(i.precision=o),vu(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(o=Mx(r,Math.max(Math.abs(n),Math.abs(t))))&&(i.precision=o-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(o=wx(r))&&(i.precision=o-(i.type==="%")*2);break}}return gr(i)}function za(n){var t=n.domain;return n.ticks=function(e){var i=t();return Ca(i[0],i[i.length-1],e??10)},n.tickFormat=function(e,i){var r=t();return Ax(r[0],r[r.length-1],e??10,i)},n.nice=function(e){e==null&&(e=10);var i=t(),r=0,o=i.length-1,s=i[r],a=i[o],c,l,h=10;for(a<s&&(l=s,s=a,a=l,l=r,r=o,o=l);h-- >0;){if(l=Pa(s,a,e),l===c)return i[r]=s,i[o]=a,t(i);if(l>0)s=Math.floor(s/l)*l,a=Math.ceil(a/l)*l;else if(l<0)s=Math.ceil(s*l)/l,a=Math.floor(a*l)/l;else break;c=l}return n},n}function Me(){var n=pu();return n.copy=function(){return To(n,Me())},yi.apply(n,arguments),za(n)}function wu(n,t){n=n.slice();var e=0,i=n.length-1,r=n[e],o=n[i],s;return o<r&&(s=e,e=i,i=s,s=r,r=o,o=s),n[e]=t.floor(r),n[i]=t.ceil(o),n}function ku(n){return Math.log(n)}function Mu(n){return Math.exp(n)}function Sx(n){return-Math.log(-n)}function _x(n){return-Math.exp(-n)}function Cx(n){return isFinite(n)?+("1e"+n):n<0?0:n}function Px(n){return n===10?Cx:n===Math.E?Math.exp:t=>Math.pow(n,t)}function Ex(n){return n===Math.E?Math.log:n===10&&Math.log10||n===2&&Math.log2||(n=Math.log(n),t=>Math.log(t)/n)}function Au(n){return(t,e)=>-n(-t,e)}function Tx(n){const t=n(ku,Mu),e=t.domain;let i=10,r,o;function s(){return r=Ex(i),o=Px(i),e()[0]<0?(r=Au(r),o=Au(o),n(Sx,_x)):n(ku,Mu),t}return t.base=function(a){return arguments.length?(i=+a,s()):i},t.domain=function(a){return arguments.length?(e(a),s()):e()},t.ticks=a=>{const c=e();let l=c[0],h=c[c.length-1];const f=h<l;f&&([l,h]=[h,l]);let u=r(l),d=r(h),p,y;const g=a==null?10:+a;let m=[];if(!(i%1)&&d-u<g){if(u=Math.floor(u),d=Math.ceil(d),l>0){for(;u<=d;++u)for(p=1;p<i;++p)if(y=u<0?p/o(-u):p*o(u),!(y<l)){if(y>h)break;m.push(y)}}else for(;u<=d;++u)for(p=i-1;p>=1;--p)if(y=u>0?p/o(-u):p*o(u),!(y<l)){if(y>h)break;m.push(y)}m.length*2<g&&(m=Ca(l,h,g))}else m=Ca(u,d,Math.min(d-u,g)).map(o);return f?m.reverse():m},t.tickFormat=(a,c)=>{if(a==null&&(a=10),c==null&&(c=i===10?"s":","),typeof c!="function"&&(!(i%1)&&(c=pr(c)).precision==null&&(c.trim=!0),c=gr(c)),a===1/0)return c;const l=Math.max(1,i*a/t.ticks().length);return h=>{let f=h/o(Math.round(r(h)));return f*i<i-.5&&(f*=i),f<=l?c(h):""}},t.nice=()=>e(wu(e(),{floor:a=>o(Math.floor(r(a))),ceil:a=>o(Math.ceil(r(a)))})),t}function Fo(){const n=Tx(Ra()).domain([1,10]);return n.copy=()=>To(n,Fo()).base(n.base()),yi.apply(n,arguments),n}function Su(n){return function(t){return t<0?-Math.pow(-t,n):Math.pow(t,n)}}function Lx(n){return n<0?-Math.sqrt(-n):Math.sqrt(n)}function $x(n){return n<0?-n*n:n*n}function Ix(n){var t=n(nn,nn),e=1;function i(){return e===1?n(nn,nn):e===.5?n(Lx,$x):n(Su(e),Su(1/e))}return t.exponent=function(r){return arguments.length?(e=+r,i()):e},za(t)}function _u(){var n=Ix(Ra());return n.copy=function(){return To(n,_u()).exponent(n.exponent())},yi.apply(n,arguments),n}function Fx(){return _u.apply(null,arguments).exponent(.5)}const Ba=new Date,Oa=new Date;function fe(n,t,e,i){function r(o){return n(o=arguments.length===0?new Date:new Date(+o)),o}return r.floor=o=>(n(o=new Date(+o)),o),r.ceil=o=>(n(o=new Date(o-1)),t(o,1),n(o),o),r.round=o=>{const s=r(o),a=r.ceil(o);return o-s<a-o?s:a},r.offset=(o,s)=>(t(o=new Date(+o),s==null?1:Math.floor(s)),o),r.range=(o,s,a)=>{const c=[];if(o=r.ceil(o),a=a==null?1:Math.floor(a),!(o<s)||!(a>0))return c;let l;do c.push(l=new Date(+o)),t(o,a),n(o);while(l<o&&o<s);return c},r.filter=o=>fe(s=>{if(s>=s)for(;n(s),!o(s);)s.setTime(s-1)},(s,a)=>{if(s>=s)if(a<0)for(;++a<=0;)for(;t(s,-1),!o(s););else for(;--a>=0;)for(;t(s,1),!o(s););}),e&&(r.count=(o,s)=>(Ba.setTime(+o),Oa.setTime(+s),n(Ba),n(Oa),Math.floor(e(Ba,Oa))),r.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?r.filter(i?s=>i(s)%o===0:s=>r.count(0,s)%o===0):r)),r}const Ro=fe(()=>{},(n,t)=>{n.setTime(+n+t)},(n,t)=>t-n);Ro.every=n=>(n=Math.floor(n),!isFinite(n)||!(n>0)?null:n>1?fe(t=>{t.setTime(Math.floor(t/n)*n)},(t,e)=>{t.setTime(+t+e*n)},(t,e)=>(e-t)/n):Ro),Ro.range;const In=1e3,rn=In*60,Fn=rn*60,Rn=Fn*24,Na=Rn*7,Cu=Rn*30,Wa=Rn*365,bi=fe(n=>{n.setTime(n-n.getMilliseconds())},(n,t)=>{n.setTime(+n+t*In)},(n,t)=>(t-n)/In,n=>n.getUTCSeconds());bi.range;const Ha=fe(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*In)},(n,t)=>{n.setTime(+n+t*rn)},(n,t)=>(t-n)/rn,n=>n.getMinutes());Ha.range;const Va=fe(n=>{n.setUTCSeconds(0,0)},(n,t)=>{n.setTime(+n+t*rn)},(n,t)=>(t-n)/rn,n=>n.getUTCMinutes());Va.range;const Ga=fe(n=>{n.setTime(n-n.getMilliseconds()-n.getSeconds()*In-n.getMinutes()*rn)},(n,t)=>{n.setTime(+n+t*Fn)},(n,t)=>(t-n)/Fn,n=>n.getHours());Ga.range;const Ya=fe(n=>{n.setUTCMinutes(0,0,0)},(n,t)=>{n.setTime(+n+t*Fn)},(n,t)=>(t-n)/Fn,n=>n.getUTCHours());Ya.range;const mr=fe(n=>n.setHours(0,0,0,0),(n,t)=>n.setDate(n.getDate()+t),(n,t)=>(t-n-(t.getTimezoneOffset()-n.getTimezoneOffset())*rn)/Rn,n=>n.getDate()-1);mr.range;const Do=fe(n=>{n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCDate(n.getUTCDate()+t)},(n,t)=>(t-n)/Rn,n=>n.getUTCDate()-1);Do.range;const Pu=fe(n=>{n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCDate(n.getUTCDate()+t)},(n,t)=>(t-n)/Rn,n=>Math.floor(n/Rn));Pu.range;function vi(n){return fe(t=>{t.setDate(t.getDate()-(t.getDay()+7-n)%7),t.setHours(0,0,0,0)},(t,e)=>{t.setDate(t.getDate()+e*7)},(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*rn)/Na)}const zo=vi(0),Bo=vi(1),Rx=vi(2),Dx=vi(3),zi=vi(4),zx=vi(5),Bx=vi(6);zo.range,Bo.range,Rx.range,Dx.range,zi.range,zx.range,Bx.range;function wi(n){return fe(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-n)%7),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e*7)},(t,e)=>(e-t)/Na)}const Oo=wi(0),No=wi(1),Ox=wi(2),Nx=wi(3),Bi=wi(4),Wx=wi(5),Hx=wi(6);Oo.range,No.range,Ox.range,Nx.range,Bi.range,Wx.range,Hx.range;const Xa=fe(n=>{n.setDate(1),n.setHours(0,0,0,0)},(n,t)=>{n.setMonth(n.getMonth()+t)},(n,t)=>t.getMonth()-n.getMonth()+(t.getFullYear()-n.getFullYear())*12,n=>n.getMonth());Xa.range;const Ua=fe(n=>{n.setUTCDate(1),n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCMonth(n.getUTCMonth()+t)},(n,t)=>t.getUTCMonth()-n.getUTCMonth()+(t.getUTCFullYear()-n.getUTCFullYear())*12,n=>n.getUTCMonth());Ua.range;const Dn=fe(n=>{n.setMonth(0,1),n.setHours(0,0,0,0)},(n,t)=>{n.setFullYear(n.getFullYear()+t)},(n,t)=>t.getFullYear()-n.getFullYear(),n=>n.getFullYear());Dn.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:fe(t=>{t.setFullYear(Math.floor(t.getFullYear()/n)*n),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,e)=>{t.setFullYear(t.getFullYear()+e*n)}),Dn.range;const zn=fe(n=>{n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},(n,t)=>{n.setUTCFullYear(n.getUTCFullYear()+t)},(n,t)=>t.getUTCFullYear()-n.getUTCFullYear(),n=>n.getUTCFullYear());zn.every=n=>!isFinite(n=Math.floor(n))||!(n>0)?null:fe(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/n)*n),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCFullYear(t.getUTCFullYear()+e*n)}),zn.range;function Eu(n,t,e,i,r,o){const s=[[bi,1,In],[bi,5,5*In],[bi,15,15*In],[bi,30,30*In],[o,1,rn],[o,5,5*rn],[o,15,15*rn],[o,30,30*rn],[r,1,Fn],[r,3,3*Fn],[r,6,6*Fn],[r,12,12*Fn],[i,1,Rn],[i,2,2*Rn],[e,1,Na],[t,1,Cu],[t,3,3*Cu],[n,1,Wa]];function a(l,h,f){const u=h<l;u&&([l,h]=[h,l]);const d=f&&typeof f.range=="function"?f:c(l,h,f),p=d?d.range(l,+h+1):[];return u?p.reverse():p}function c(l,h,f){const u=Math.abs(h-l)/f,d=_a(([,,g])=>g).right(s,u);if(d===s.length)return n.every(Ea(l/Wa,h/Wa,f));if(d===0)return Ro.every(Math.max(Ea(l,h,f),1));const[p,y]=s[u/s[d-1][2]<s[d][2]/u?d-1:d];return p.every(y)}return[a,c]}const[Vx,Gx]=Eu(zn,Ua,Oo,Pu,Ya,Va),[Yx,Xx]=Eu(Dn,Xa,zo,mr,Ga,Ha);function ja(n){if(0<=n.y&&n.y<100){var t=new Date(-1,n.m,n.d,n.H,n.M,n.S,n.L);return t.setFullYear(n.y),t}return new Date(n.y,n.m,n.d,n.H,n.M,n.S,n.L)}function qa(n){if(0<=n.y&&n.y<100){var t=new Date(Date.UTC(-1,n.m,n.d,n.H,n.M,n.S,n.L));return t.setUTCFullYear(n.y),t}return new Date(Date.UTC(n.y,n.m,n.d,n.H,n.M,n.S,n.L))}function yr(n,t,e){return{y:n,m:t,d:e,H:0,M:0,S:0,L:0}}function Ux(n){var t=n.dateTime,e=n.date,i=n.time,r=n.periods,o=n.days,s=n.shortDays,a=n.months,c=n.shortMonths,l=xr(r),h=br(r),f=xr(o),u=br(o),d=xr(s),p=br(s),y=xr(a),g=br(a),m=xr(c),b=br(c),x={a:$,A:R,b:F,B:D,c:null,d:Ru,e:Ru,f:mb,g:_b,G:Pb,H:db,I:pb,j:gb,L:Du,m:yb,M:xb,p:z,q:B,Q:Hu,s:Vu,S:bb,u:vb,U:wb,V:kb,w:Mb,W:Ab,x:null,X:null,y:Sb,Y:Cb,Z:Eb,"%":Wu},v={a:N,A:K,b:V,B:G,c:null,d:Bu,e:Bu,f:Ib,g:Vb,G:Yb,H:Tb,I:Lb,j:$b,L:Ou,m:Fb,M:Rb,p:H,q:j,Q:Hu,s:Vu,S:Db,u:zb,U:Bb,V:Ob,w:Nb,W:Wb,x:null,X:null,y:Hb,Y:Gb,Z:Xb,"%":Wu},k={a:T,A:I,b:L,B:P,c:A,d:Iu,e:Iu,f:lb,g:$u,G:Lu,H:Fu,I:Fu,j:ob,L:cb,m:rb,M:sb,p:_,q:ib,Q:ub,s:fb,S:ab,u:Jx,U:Qx,V:tb,w:Kx,W:eb,x:w,X:S,y:$u,Y:Lu,Z:nb,"%":hb};x.x=M(e,x),x.X=M(i,x),x.c=M(t,x),v.x=M(e,v),v.X=M(i,v),v.c=M(t,v);function M(U,X){return function(tt){var O=[],it=-1,nt=0,lt=U.length,ht,at,W;for(tt instanceof Date||(tt=new Date(+tt));++it<lt;)U.charCodeAt(it)===37&&(O.push(U.slice(nt,it)),(at=Tu[ht=U.charAt(++it)])!=null?ht=U.charAt(++it):at=ht==="e"?" ":"0",(W=X[ht])&&(ht=W(tt,at)),O.push(ht),nt=it+1);return O.push(U.slice(nt,it)),O.join("")}}function C(U,X){return function(tt){var O=yr(1900,void 0,1),it=E(O,U,tt+="",0),nt,lt;if(it!=tt.length)return null;if("Q"in O)return new Date(O.Q);if("s"in O)return new Date(O.s*1e3+("L"in O?O.L:0));if(X&&!("Z"in O)&&(O.Z=0),"p"in O&&(O.H=O.H%12+O.p*12),O.m===void 0&&(O.m="q"in O?O.q:0),"V"in O){if(O.V<1||O.V>53)return null;"w"in O||(O.w=1),"Z"in O?(nt=qa(yr(O.y,0,1)),lt=nt.getUTCDay(),nt=lt>4||lt===0?No.ceil(nt):No(nt),nt=Do.offset(nt,(O.V-1)*7),O.y=nt.getUTCFullYear(),O.m=nt.getUTCMonth(),O.d=nt.getUTCDate()+(O.w+6)%7):(nt=ja(yr(O.y,0,1)),lt=nt.getDay(),nt=lt>4||lt===0?Bo.ceil(nt):Bo(nt),nt=mr.offset(nt,(O.V-1)*7),O.y=nt.getFullYear(),O.m=nt.getMonth(),O.d=nt.getDate()+(O.w+6)%7)}else("W"in O||"U"in O)&&("w"in O||(O.w="u"in O?O.u%7:"W"in O?1:0),lt="Z"in O?qa(yr(O.y,0,1)).getUTCDay():ja(yr(O.y,0,1)).getDay(),O.m=0,O.d="W"in O?(O.w+6)%7+O.W*7-(lt+5)%7:O.w+O.U*7-(lt+6)%7);return"Z"in O?(O.H+=O.Z/100|0,O.M+=O.Z%100,qa(O)):ja(O)}}function E(U,X,tt,O){for(var it=0,nt=X.length,lt=tt.length,ht,at;it<nt;){if(O>=lt)return-1;if(ht=X.charCodeAt(it++),ht===37){if(ht=X.charAt(it++),at=k[ht in Tu?X.charAt(it++):ht],!at||(O=at(U,tt,O))<0)return-1}else if(ht!=tt.charCodeAt(O++))return-1}return O}function _(U,X,tt){var O=l.exec(X.slice(tt));return O?(U.p=h.get(O[0].toLowerCase()),tt+O[0].length):-1}function T(U,X,tt){var O=d.exec(X.slice(tt));return O?(U.w=p.get(O[0].toLowerCase()),tt+O[0].length):-1}function I(U,X,tt){var O=f.exec(X.slice(tt));return O?(U.w=u.get(O[0].toLowerCase()),tt+O[0].length):-1}function L(U,X,tt){var O=m.exec(X.slice(tt));return O?(U.m=b.get(O[0].toLowerCase()),tt+O[0].length):-1}function P(U,X,tt){var O=y.exec(X.slice(tt));return O?(U.m=g.get(O[0].toLowerCase()),tt+O[0].length):-1}function A(U,X,tt){return E(U,t,X,tt)}function w(U,X,tt){return E(U,e,X,tt)}function S(U,X,tt){return E(U,i,X,tt)}function $(U){return s[U.getDay()]}function R(U){return o[U.getDay()]}function F(U){return c[U.getMonth()]}function D(U){return a[U.getMonth()]}function z(U){return r[+(U.getHours()>=12)]}function B(U){return 1+~~(U.getMonth()/3)}function N(U){return s[U.getUTCDay()]}function K(U){return o[U.getUTCDay()]}function V(U){return c[U.getUTCMonth()]}function G(U){return a[U.getUTCMonth()]}function H(U){return r[+(U.getUTCHours()>=12)]}function j(U){return 1+~~(U.getUTCMonth()/3)}return{format:function(U){var X=M(U+="",x);return X.toString=function(){return U},X},parse:function(U){var X=C(U+="",!1);return X.toString=function(){return U},X},utcFormat:function(U){var X=M(U+="",v);return X.toString=function(){return U},X},utcParse:function(U){var X=C(U+="",!0);return X.toString=function(){return U},X}}}var Tu={"-":"",_:" ",0:"0"},ye=/^\s*\d+/,jx=/^%/,qx=/[\\^$*+?|[\]().{}]/g;function Yt(n,t,e){var i=n<0?"-":"",r=(i?-n:n)+"",o=r.length;return i+(o<e?new Array(e-o+1).join(t)+r:r)}function Zx(n){return n.replace(qx,"\\$&")}function xr(n){return new RegExp("^(?:"+n.map(Zx).join("|")+")","i")}function br(n){return new Map(n.map((t,e)=>[t.toLowerCase(),e]))}function Kx(n,t,e){var i=ye.exec(t.slice(e,e+1));return i?(n.w=+i[0],e+i[0].length):-1}function Jx(n,t,e){var i=ye.exec(t.slice(e,e+1));return i?(n.u=+i[0],e+i[0].length):-1}function Qx(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.U=+i[0],e+i[0].length):-1}function tb(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.V=+i[0],e+i[0].length):-1}function eb(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.W=+i[0],e+i[0].length):-1}function Lu(n,t,e){var i=ye.exec(t.slice(e,e+4));return i?(n.y=+i[0],e+i[0].length):-1}function $u(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.y=+i[0]+(+i[0]>68?1900:2e3),e+i[0].length):-1}function nb(n,t,e){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(e,e+6));return i?(n.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function ib(n,t,e){var i=ye.exec(t.slice(e,e+1));return i?(n.q=i[0]*3-3,e+i[0].length):-1}function rb(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.m=i[0]-1,e+i[0].length):-1}function Iu(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.d=+i[0],e+i[0].length):-1}function ob(n,t,e){var i=ye.exec(t.slice(e,e+3));return i?(n.m=0,n.d=+i[0],e+i[0].length):-1}function Fu(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.H=+i[0],e+i[0].length):-1}function sb(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.M=+i[0],e+i[0].length):-1}function ab(n,t,e){var i=ye.exec(t.slice(e,e+2));return i?(n.S=+i[0],e+i[0].length):-1}function cb(n,t,e){var i=ye.exec(t.slice(e,e+3));return i?(n.L=+i[0],e+i[0].length):-1}function lb(n,t,e){var i=ye.exec(t.slice(e,e+6));return i?(n.L=Math.floor(i[0]/1e3),e+i[0].length):-1}function hb(n,t,e){var i=jx.exec(t.slice(e,e+1));return i?e+i[0].length:-1}function ub(n,t,e){var i=ye.exec(t.slice(e));return i?(n.Q=+i[0],e+i[0].length):-1}function fb(n,t,e){var i=ye.exec(t.slice(e));return i?(n.s=+i[0],e+i[0].length):-1}function Ru(n,t){return Yt(n.getDate(),t,2)}function db(n,t){return Yt(n.getHours(),t,2)}function pb(n,t){return Yt(n.getHours()%12||12,t,2)}function gb(n,t){return Yt(1+mr.count(Dn(n),n),t,3)}function Du(n,t){return Yt(n.getMilliseconds(),t,3)}function mb(n,t){return Du(n,t)+"000"}function yb(n,t){return Yt(n.getMonth()+1,t,2)}function xb(n,t){return Yt(n.getMinutes(),t,2)}function bb(n,t){return Yt(n.getSeconds(),t,2)}function vb(n){var t=n.getDay();return t===0?7:t}function wb(n,t){return Yt(zo.count(Dn(n)-1,n),t,2)}function zu(n){var t=n.getDay();return t>=4||t===0?zi(n):zi.ceil(n)}function kb(n,t){return n=zu(n),Yt(zi.count(Dn(n),n)+(Dn(n).getDay()===4),t,2)}function Mb(n){return n.getDay()}function Ab(n,t){return Yt(Bo.count(Dn(n)-1,n),t,2)}function Sb(n,t){return Yt(n.getFullYear()%100,t,2)}function _b(n,t){return n=zu(n),Yt(n.getFullYear()%100,t,2)}function Cb(n,t){return Yt(n.getFullYear()%1e4,t,4)}function Pb(n,t){var e=n.getDay();return n=e>=4||e===0?zi(n):zi.ceil(n),Yt(n.getFullYear()%1e4,t,4)}function Eb(n){var t=n.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Yt(t/60|0,"0",2)+Yt(t%60,"0",2)}function Bu(n,t){return Yt(n.getUTCDate(),t,2)}function Tb(n,t){return Yt(n.getUTCHours(),t,2)}function Lb(n,t){return Yt(n.getUTCHours()%12||12,t,2)}function $b(n,t){return Yt(1+Do.count(zn(n),n),t,3)}function Ou(n,t){return Yt(n.getUTCMilliseconds(),t,3)}function Ib(n,t){return Ou(n,t)+"000"}function Fb(n,t){return Yt(n.getUTCMonth()+1,t,2)}function Rb(n,t){return Yt(n.getUTCMinutes(),t,2)}function Db(n,t){return Yt(n.getUTCSeconds(),t,2)}function zb(n){var t=n.getUTCDay();return t===0?7:t}function Bb(n,t){return Yt(Oo.count(zn(n)-1,n),t,2)}function Nu(n){var t=n.getUTCDay();return t>=4||t===0?Bi(n):Bi.ceil(n)}function Ob(n,t){return n=Nu(n),Yt(Bi.count(zn(n),n)+(zn(n).getUTCDay()===4),t,2)}function Nb(n){return n.getUTCDay()}function Wb(n,t){return Yt(No.count(zn(n)-1,n),t,2)}function Hb(n,t){return Yt(n.getUTCFullYear()%100,t,2)}function Vb(n,t){return n=Nu(n),Yt(n.getUTCFullYear()%100,t,2)}function Gb(n,t){return Yt(n.getUTCFullYear()%1e4,t,4)}function Yb(n,t){var e=n.getUTCDay();return n=e>=4||e===0?Bi(n):Bi.ceil(n),Yt(n.getUTCFullYear()%1e4,t,4)}function Xb(){return"+0000"}function Wu(){return"%"}function Hu(n){return+n}function Vu(n){return Math.floor(+n/1e3)}var Oi,Wo,Ho;Ub({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Ub(n){return Oi=Ux(n),Wo=Oi.format,Oi.parse,Ho=Oi.utcFormat,Oi.utcParse,Oi}function jb(n){return new Date(n)}function qb(n){return n instanceof Date?+n:+new Date(+n)}function Za(n,t,e,i,r,o,s,a,c,l){var h=pu(),f=h.invert,u=h.domain,d=l(".%L"),p=l(":%S"),y=l("%I:%M"),g=l("%I %p"),m=l("%a %d"),b=l("%b %d"),x=l("%B"),v=l("%Y");function k(M){return(c(M)<M?d:a(M)<M?p:s(M)<M?y:o(M)<M?g:i(M)<M?r(M)<M?m:b:e(M)<M?x:v)(M)}return h.invert=function(M){return new Date(f(M))},h.domain=function(M){return arguments.length?u(Array.from(M,qb)):u().map(jb)},h.ticks=function(M){var C=u();return n(C[0],C[C.length-1],M??10)},h.tickFormat=function(M,C){return C==null?k:l(C)},h.nice=function(M){var C=u();return(!M||typeof M.range!="function")&&(M=t(C[0],C[C.length-1],M??10)),M?u(wu(C,M)):h},h.copy=function(){return To(h,Za(n,t,e,i,r,o,s,a,c,l))},h}function Zb(){return yi.apply(Za(Yx,Xx,Dn,Xa,zo,mr,Ga,Ha,bi,Wo).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Kb(){return yi.apply(Za(Vx,Gx,zn,Ua,Oo,Do,Ya,Va,bi,Ho).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Jb(){var n=0,t=1,e,i,r,o,s=nn,a=!1,c;function l(f){return f==null||isNaN(f=+f)?c:s(r===0?.5:(f=(o(f)-e)*r,a?Math.max(0,Math.min(1,f)):f))}l.domain=function(f){return arguments.length?([n,t]=f,e=o(n=+n),i=o(t=+t),r=e===i?0:1/(i-e),l):[n,t]},l.clamp=function(f){return arguments.length?(a=!!f,l):a},l.interpolator=function(f){return arguments.length?(s=f,l):s};function h(f){return function(u){var d,p;return arguments.length?([d,p]=u,s=f(d,p),l):[s(0),s(1)]}}return l.range=h(ue),l.rangeRound=h(cu),l.unknown=function(f){return arguments.length?(c=f,l):c},function(f){return o=f,e=f(n),i=f(t),r=e===i?0:1/(i-e),l}}function Qb(n,t){return t.domain(n.domain()).interpolator(n.interpolator()).clamp(n.clamp()).unknown(n.unknown())}function Gu(){var n=za(Jb()(nn));return n.copy=function(){return Qb(n,Gu())},Oy.apply(n,arguments)}function t1(n){return n}var Vo=1,Go=2,Ka=3,vr=4,Yu=1e-6;function e1(n){return"translate("+n+",0)"}function n1(n){return"translate(0,"+n+")"}function i1(n){return t=>+n(t)}function r1(n,t){return t=Math.max(0,n.bandwidth()-t*2)/2,n.round()&&(t=Math.round(t)),e=>+n(e)+t}function o1(){return!this.__axis}function Yo(n,t){var e=[],i=null,r=null,o=6,s=6,a=3,c=typeof window<"u"&&window.devicePixelRatio>1?0:.5,l=n===Vo||n===vr?-1:1,h=n===vr||n===Go?"x":"y",f=n===Vo||n===Ka?e1:n1;function u(d){var p=i??(t.ticks?t.ticks.apply(t,e):t.domain()),y=r??(t.tickFormat?t.tickFormat.apply(t,e):t1),g=Math.max(o,0)+a,m=t.range(),b=+m[0]+c,x=+m[m.length-1]+c,v=(t.bandwidth?r1:i1)(t.copy(),c),k=d.selection?d.selection():d,M=k.selectAll(".domain").data([null]),C=k.selectAll(".tick").data(p,t).order(),E=C.exit(),_=C.enter().append("g").attr("class","tick"),T=C.select("line"),I=C.select("text");M=M.merge(M.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),C=C.merge(_),T=T.merge(_.append("line").attr("stroke","currentColor").attr(h+"2",l*o)),I=I.merge(_.append("text").attr("fill","currentColor").attr(h,l*g).attr("dy",n===Vo?"0em":n===Ka?"0.71em":"0.32em")),d!==k&&(M=M.transition(d),C=C.transition(d),T=T.transition(d),I=I.transition(d),E=E.transition(d).attr("opacity",Yu).attr("transform",function(L){return isFinite(L=v(L))?f(L+c):this.getAttribute("transform")}),_.attr("opacity",Yu).attr("transform",function(L){var P=this.parentNode.__axis;return f((P&&isFinite(P=P(L))?P:v(L))+c)})),E.remove(),M.attr("d",n===vr||n===Go?s?"M"+l*s+","+b+"H"+c+"V"+x+"H"+l*s:"M"+c+","+b+"V"+x:s?"M"+b+","+l*s+"V"+c+"H"+x+"V"+l*s:"M"+b+","+c+"H"+x),C.attr("opacity",1).attr("transform",function(L){return f(v(L)+c)}),T.attr(h+"2",l*o),I.attr(h,l*g).text(y),k.filter(o1).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",n===Go?"start":n===vr?"end":"middle"),k.each(function(){this.__axis=v})}return u.scale=function(d){return arguments.length?(t=d,u):t},u.ticks=function(){return e=Array.from(arguments),u},u.tickArguments=function(d){return arguments.length?(e=d==null?[]:Array.from(d),u):e.slice()},u.tickValues=function(d){return arguments.length?(i=d==null?null:Array.from(d),u):i&&i.slice()},u.tickFormat=function(d){return arguments.length?(r=d,u):r},u.tickSize=function(d){return arguments.length?(o=s=+d,u):o},u.tickSizeInner=function(d){return arguments.length?(o=+d,u):o},u.tickSizeOuter=function(d){return arguments.length?(s=+d,u):s},u.tickPadding=function(d){return arguments.length?(a=+d,u):a},u.offset=function(d){return arguments.length?(c=+d,u):c},u}function Ja(n){return Yo(Vo,n)}function Xu(n){return Yo(Go,n)}function Uu(n){return Yo(Ka,n)}function ju(n){return Yo(vr,n)}var s1={value:()=>{}};function Ni(){for(var n=0,t=arguments.length,e={},i;n<t;++n){if(!(i=arguments[n]+"")||i in e||/[\s.]/.test(i))throw new Error("illegal type: "+i);e[i]=[]}return new Xo(e)}function Xo(n){this._=n}function a1(n,t){return n.trim().split(/^|\s+/).map(function(e){var i="",r=e.indexOf(".");if(r>=0&&(i=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:i}})}Xo.prototype=Ni.prototype={constructor:Xo,on:function(n,t){var e=this._,i=a1(n+"",e),r,o=-1,s=i.length;if(arguments.length<2){for(;++o<s;)if((r=(n=i[o]).type)&&(r=c1(e[r],n.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(r=(n=i[o]).type)e[r]=qu(e[r],n.name,t);else if(t==null)for(r in e)e[r]=qu(e[r],n.name,null);return this},copy:function(){var n={},t=this._;for(var e in t)n[e]=t[e].slice();return new Xo(n)},call:function(n,t){if((r=arguments.length-2)>0)for(var e=new Array(r),i=0,r,o;i<r;++i)e[i]=arguments[i+2];if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(o=this._[n],i=0,r=o.length;i<r;++i)o[i].value.apply(t,e)},apply:function(n,t,e){if(!this._.hasOwnProperty(n))throw new Error("unknown type: "+n);for(var i=this._[n],r=0,o=i.length;r<o;++r)i[r].value.apply(t,e)}};function c1(n,t){for(var e=0,i=n.length,r;e<i;++e)if((r=n[e]).name===t)return r.value}function qu(n,t,e){for(var i=0,r=n.length;i<r;++i)if(n[i].name===t){n[i]=s1,n=n.slice(0,i).concat(n.slice(i+1));break}return e!=null&&n.push({name:t,value:e}),n}var Wi=0,wr=0,kr=0,Zu=1e3,Uo,Mr,jo=0,ki=0,qo=0,Ar=typeof performance=="object"&&performance.now?performance:Date,Ku=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(n){setTimeout(n,17)};function Qa(){return ki||(Ku(l1),ki=Ar.now()+qo)}function l1(){ki=0}function Zo(){this._call=this._time=this._next=null}Zo.prototype=Ko.prototype={constructor:Zo,restart:function(n,t,e){if(typeof n!="function")throw new TypeError("callback is not a function");e=(e==null?Qa():+e)+(t==null?0:+t),!this._next&&Mr!==this&&(Mr?Mr._next=this:Uo=this,Mr=this),this._call=n,this._time=e,tc()},stop:function(){this._call&&(this._call=null,this._time=1/0,tc())}};function Ko(n,t,e){var i=new Zo;return i.restart(n,t,e),i}function h1(){Qa(),++Wi;for(var n=Uo,t;n;)(t=ki-n._time)>=0&&n._call.call(void 0,t),n=n._next;--Wi}function Ju(){ki=(jo=Ar.now())+qo,Wi=wr=0;try{h1()}finally{Wi=0,f1(),ki=0}}function u1(){var n=Ar.now(),t=n-jo;t>Zu&&(qo-=t,jo=n)}function f1(){for(var n,t=Uo,e,i=1/0;t;)t._call?(i>t._time&&(i=t._time),n=t,t=t._next):(e=t._next,t._next=null,t=n?n._next=e:Uo=e);Mr=n,tc(i)}function tc(n){if(!Wi){wr&&(wr=clearTimeout(wr));var t=n-ki;t>24?(n<1/0&&(wr=setTimeout(Ju,n-Ar.now()-qo)),kr&&(kr=clearInterval(kr))):(kr||(jo=Ar.now(),kr=setInterval(u1,Zu)),Wi=1,Ku(Ju))}}function Qu(n,t,e){var i=new Zo;return t=t==null?0:+t,i.restart(r=>{i.stop(),n(r+t)},t,e),i}var d1=Ni("start","end","cancel","interrupt"),p1=[],tf=0,ef=1,ec=2,Jo=3,nf=4,nc=5,Qo=6;function ts(n,t,e,i,r,o){var s=n.__transition;if(!s)n.__transition={};else if(e in s)return;g1(n,e,{name:t,index:i,group:r,on:d1,tween:p1,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:tf})}function ic(n,t){var e=xn(n,t);if(e.state>tf)throw new Error("too late; already scheduled");return e}function Mn(n,t){var e=xn(n,t);if(e.state>Jo)throw new Error("too late; already running");return e}function xn(n,t){var e=n.__transition;if(!e||!(e=e[t]))throw new Error("transition not found");return e}function g1(n,t,e){var i=n.__transition,r;i[t]=e,e.timer=Ko(o,0,e.time);function o(l){e.state=ef,e.timer.restart(s,e.delay,e.time),e.delay<=l&&s(l-e.delay)}function s(l){var h,f,u,d;if(e.state!==ef)return c();for(h in i)if(d=i[h],d.name===e.name){if(d.state===Jo)return Qu(s);d.state===nf?(d.state=Qo,d.timer.stop(),d.on.call("interrupt",n,n.__data__,d.index,d.group),delete i[h]):+h<t&&(d.state=Qo,d.timer.stop(),d.on.call("cancel",n,n.__data__,d.index,d.group),delete i[h])}if(Qu(function(){e.state===Jo&&(e.state=nf,e.timer.restart(a,e.delay,e.time),a(l))}),e.state=ec,e.on.call("start",n,n.__data__,e.index,e.group),e.state===ec){for(e.state=Jo,r=new Array(u=e.tween.length),h=0,f=-1;h<u;++h)(d=e.tween[h].value.call(n,n.__data__,e.index,e.group))&&(r[++f]=d);r.length=f+1}}function a(l){for(var h=l<e.duration?e.ease.call(null,l/e.duration):(e.timer.restart(c),e.state=nc,1),f=-1,u=r.length;++f<u;)r[f].call(n,h);e.state===nc&&(e.on.call("end",n,n.__data__,e.index,e.group),c())}function c(){e.state=Qo,e.timer.stop(),delete i[t];for(var l in i)return;delete n.__transition}}function Hi(n,t){var e=n.__transition,i,r,o=!0,s;if(e){t=t==null?null:t+"";for(s in e){if((i=e[s]).name!==t){o=!1;continue}r=i.state>ec&&i.state<nc,i.state=Qo,i.timer.stop(),i.on.call(r?"interrupt":"cancel",n,n.__data__,i.index,i.group),delete e[s]}o&&delete n.__transition}}function m1(n){return this.each(function(){Hi(this,n)})}function y1(n,t){var e,i;return function(){var r=Mn(this,n),o=r.tween;if(o!==e){i=e=o;for(var s=0,a=i.length;s<a;++s)if(i[s].name===t){i=i.slice(),i.splice(s,1);break}}r.tween=i}}function x1(n,t,e){var i,r;if(typeof e!="function")throw new Error;return function(){var o=Mn(this,n),s=o.tween;if(s!==i){r=(i=s).slice();for(var a={name:t,value:e},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}o.tween=r}}function b1(n,t){var e=this._id;if(n+="",arguments.length<2){for(var i=xn(this.node(),e).tween,r=0,o=i.length,s;r<o;++r)if((s=i[r]).name===n)return s.value;return null}return this.each((t==null?y1:x1)(e,n,t))}function rc(n,t,e){var i=n._id;return n.each(function(){var r=Mn(this,i);(r.value||(r.value={}))[t]=e.apply(this,arguments)}),function(r){return xn(r,i).value[t]}}function rf(n,t){var e;return(typeof t=="number"?yn:t instanceof le?xi:(e=le(t))?(t=e,xi):au)(n,t)}function v1(n){return function(){this.removeAttribute(n)}}function w1(n){return function(){this.removeAttributeNS(n.space,n.local)}}function k1(n,t,e){var i,r=e+"",o;return function(){var s=this.getAttribute(n);return s===r?null:s===i?o:o=t(i=s,e)}}function M1(n,t,e){var i,r=e+"",o;return function(){var s=this.getAttributeNS(n.space,n.local);return s===r?null:s===i?o:o=t(i=s,e)}}function A1(n,t,e){var i,r,o;return function(){var s,a=e(this),c;return a==null?void this.removeAttribute(n):(s=this.getAttribute(n),c=a+"",s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a)))}}function S1(n,t,e){var i,r,o;return function(){var s,a=e(this),c;return a==null?void this.removeAttributeNS(n.space,n.local):(s=this.getAttributeNS(n.space,n.local),c=a+"",s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a)))}}function _1(n,t){var e=Ao(n),i=e==="transform"?ix:rf;return this.attrTween(n,typeof t=="function"?(e.local?S1:A1)(e,i,rc(this,"attr."+n,t)):t==null?(e.local?w1:v1)(e):(e.local?M1:k1)(e,i,t))}function C1(n,t){return function(e){this.setAttribute(n,t.call(this,e))}}function P1(n,t){return function(e){this.setAttributeNS(n.space,n.local,t.call(this,e))}}function E1(n,t){var e,i;function r(){var o=t.apply(this,arguments);return o!==i&&(e=(i=o)&&P1(n,o)),e}return r._value=t,r}function T1(n,t){var e,i;function r(){var o=t.apply(this,arguments);return o!==i&&(e=(i=o)&&C1(n,o)),e}return r._value=t,r}function L1(n,t){var e="attr."+n;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(t==null)return this.tween(e,null);if(typeof t!="function")throw new Error;var i=Ao(n);return this.tween(e,(i.local?E1:T1)(i,t))}function $1(n,t){return function(){ic(this,n).delay=+t.apply(this,arguments)}}function I1(n,t){return t=+t,function(){ic(this,n).delay=t}}function F1(n){var t=this._id;return arguments.length?this.each((typeof n=="function"?$1:I1)(t,n)):xn(this.node(),t).delay}function R1(n,t){return function(){Mn(this,n).duration=+t.apply(this,arguments)}}function D1(n,t){return t=+t,function(){Mn(this,n).duration=t}}function z1(n){var t=this._id;return arguments.length?this.each((typeof n=="function"?R1:D1)(t,n)):xn(this.node(),t).duration}function B1(n,t){if(typeof t!="function")throw new Error;return function(){Mn(this,n).ease=t}}function O1(n){var t=this._id;return arguments.length?this.each(B1(t,n)):xn(this.node(),t).ease}function N1(n,t){return function(){var e=t.apply(this,arguments);if(typeof e!="function")throw new Error;Mn(this,n).ease=e}}function W1(n){if(typeof n!="function")throw new Error;return this.each(N1(this._id,n))}function H1(n){typeof n!="function"&&(n=Wh(n));for(var t=this._groups,e=t.length,i=new Array(e),r=0;r<e;++r)for(var o=t[r],s=o.length,a=i[r]=[],c,l=0;l<s;++l)(c=o[l])&&n.call(c,c.__data__,l,o)&&a.push(c);return new Bn(i,this._parents,this._name,this._id)}function V1(n){if(n._id!==this._id)throw new Error;for(var t=this._groups,e=n._groups,i=t.length,r=e.length,o=Math.min(i,r),s=new Array(i),a=0;a<o;++a)for(var c=t[a],l=e[a],h=c.length,f=s[a]=new Array(h),u,d=0;d<h;++d)(u=c[d]||l[d])&&(f[d]=u);for(;a<i;++a)s[a]=t[a];return new Bn(s,this._parents,this._name,this._id)}function G1(n){return(n+"").trim().split(/^|\s+/).every(function(t){var e=t.indexOf(".");return e>=0&&(t=t.slice(0,e)),!t||t==="start"})}function Y1(n,t,e){var i,r,o=G1(t)?ic:Mn;return function(){var s=o(this,n),a=s.on;a!==i&&(r=(i=a).copy()).on(t,e),s.on=r}}function X1(n,t){var e=this._id;return arguments.length<2?xn(this.node(),e).on.on(n):this.each(Y1(e,n,t))}function U1(n){return function(){var t=this.parentNode;for(var e in this.__transition)if(+e!==n)return;t&&t.removeChild(this)}}function j1(){return this.on("end.remove",U1(this._id))}function q1(n){var t=this._name,e=this._id;typeof n!="function"&&(n=Aa(n));for(var i=this._groups,r=i.length,o=new Array(r),s=0;s<r;++s)for(var a=i[s],c=a.length,l=o[s]=new Array(c),h,f,u=0;u<c;++u)(h=a[u])&&(f=n.call(h,h.__data__,u,a))&&("__data__"in h&&(f.__data__=h.__data__),l[u]=f,ts(l[u],t,e,u,l,xn(h,e)));return new Bn(o,this._parents,t,e)}function Z1(n){var t=this._name,e=this._id;typeof n!="function"&&(n=Nh(n));for(var i=this._groups,r=i.length,o=[],s=[],a=0;a<r;++a)for(var c=i[a],l=c.length,h,f=0;f<l;++f)if(h=c[f]){for(var u=n.call(h,h.__data__,f,c),d,p=xn(h,e),y=0,g=u.length;y<g;++y)(d=u[y])&&ts(d,t,e,y,u,p);o.push(u),s.push(h)}return new Bn(o,s,t,e)}var K1=dr.prototype.constructor;function J1(){return new K1(this._groups,this._parents)}function Q1(n,t){var e,i,r;return function(){var o=Ri(this,n),s=(this.style.removeProperty(n),Ri(this,n));return o===s?null:o===e&&s===i?r:r=t(e=o,i=s)}}function of(n){return function(){this.style.removeProperty(n)}}function tv(n,t,e){var i,r=e+"",o;return function(){var s=Ri(this,n);return s===r?null:s===i?o:o=t(i=s,e)}}function ev(n,t,e){var i,r,o;return function(){var s=Ri(this,n),a=e(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(n),Ri(this,n))),s===c?null:s===i&&c===r?o:(r=c,o=t(i=s,a))}}function nv(n,t){var e,i,r,o="style."+t,s="end."+o,a;return function(){var c=Mn(this,n),l=c.on,h=c.value[o]==null?a||(a=of(t)):void 0;(l!==e||r!==h)&&(i=(e=l).copy()).on(s,r=h),c.on=i}}function iv(n,t,e){var i=(n+="")=="transform"?nx:rf;return t==null?this.styleTween(n,Q1(n,i)).on("end.style."+n,of(n)):typeof t=="function"?this.styleTween(n,ev(n,i,rc(this,"style."+n,t))).each(nv(this._id,n)):this.styleTween(n,tv(n,i,t),e).on("end.style."+n,null)}function rv(n,t,e){return function(i){this.style.setProperty(n,t.call(this,i),e)}}function ov(n,t,e){var i,r;function o(){var s=t.apply(this,arguments);return s!==r&&(i=(r=s)&&rv(n,s,e)),i}return o._value=t,o}function sv(n,t,e){var i="style."+(n+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,ov(n,t,e??""))}function av(n){return function(){this.textContent=n}}function cv(n){return function(){var t=n(this);this.textContent=t??""}}function lv(n){return this.tween("text",typeof n=="function"?cv(rc(this,"text",n)):av(n==null?"":n+""))}function hv(n){return function(t){this.textContent=n.call(this,t)}}function uv(n){var t,e;function i(){var r=n.apply(this,arguments);return r!==e&&(t=(e=r)&&hv(r)),t}return i._value=n,i}function fv(n){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(n==null)return this.tween(t,null);if(typeof n!="function")throw new Error;return this.tween(t,uv(n))}function dv(){for(var n=this._name,t=this._id,e=sf(),i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var h=xn(c,t);ts(c,n,e,l,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new Bn(i,this._parents,n,e)}function pv(){var n,t,e=this,i=e._id,r=e.size();return new Promise(function(o,s){var a={value:s},c={value:function(){--r===0&&o()}};e.each(function(){var l=Mn(this,i),h=l.on;h!==n&&(t=(n=h).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&o()})}var gv=0;function Bn(n,t,e,i){this._groups=n,this._parents=t,this._name=e,this._id=i}function sf(){return++gv}var On=dr.prototype;Bn.prototype={constructor:Bn,select:q1,selectAll:Z1,selectChild:On.selectChild,selectChildren:On.selectChildren,filter:H1,merge:V1,selection:J1,transition:dv,call:On.call,nodes:On.nodes,node:On.node,size:On.size,empty:On.empty,each:On.each,on:X1,attr:_1,attrTween:L1,style:iv,styleTween:sv,text:lv,textTween:fv,remove:j1,tween:b1,delay:F1,duration:z1,ease:O1,easeVarying:W1,end:pv,[Symbol.iterator]:On[Symbol.iterator]};const Sr=n=>+n;function af(n){return--n*n*n+1}function mv(n){return((n*=2)<=1?n*n*n:(n-=2)*n*n+2)/2}var yv={time:null,delay:0,duration:250,ease:mv};function xv(n,t){for(var e;!(e=n.__transition)||!(e=e[t]);)if(!(n=n.parentNode))throw new Error(`transition ${t} not found`);return e}function bv(n){var t,e;n instanceof Bn?(t=n._id,n=n._name):(t=sf(),(e=yv).time=Qa(),n=n==null?null:n+"");for(var i=this._groups,r=i.length,o=0;o<r;++o)for(var s=i[o],a=s.length,c,l=0;l<a;++l)(c=s[l])&&ts(c,n,t,l,s,e||xv(c,t));return new Bn(i,this._parents,n,t)}dr.prototype.interrupt=m1,dr.prototype.transition=bv;let oc=!0;function vv(n){oc=n}function sc(){return oc}const wv=Object.entries({"%A":"%A","%a":"%a","%d":"%d","%e":"%-d","%b":"%b","%B":"%B","%m":"%m","%y":"%y","%Y":"%Y","%H":"%H","%I":"%I","%k":"%-H","%l":"%-I","%M":"%M","%p":"%p","%P":"%p","%S":"%S","%L":"%L"}).map(([n,t])=>[new RegExp(n.replace("%","\\%"),"g"),t]),cf=new Map;function ac(n,t){let e=cf.get(n);if(!e){e=n;for(const[r,o]of wv)e=e.replace(r,o);cf.set(n,e)}return(oc?Ho(e):Wo(e))(new Date(t))}function es(n,t=-1,e=".",i=","){if(!Number.isFinite(n))return"0";if(t===-1){const c=n.toString(),l=c.indexOf(".");t=l===-1?0:c.length-l-1}const r=n.toFixed(t),[o,s]=r.split("."),a=o.replace(/\B(?=(\d{3})+(?!\d))/g,i);return s?`${a}${e}${s}`:a}const kv=[[1e12,"T"],[1e9,"G"],[1e6,"M"],[1e3,"k"]];function cc(n){const t=Math.abs(n);if(t<1e3)return t===Math.floor(t)?es(n,0,".",","):n.toPrecision(4).replace(/\.?0+$/,"");for(const[e,i]of kv)if(t>=e){const r=n/e;return(r===Math.floor(r)?String(r):r.toPrecision(4).replace(/\.?0+$/,""))+i}return String(n)}const Mv=/\{([^}]+)\}/g;function Zt(n,t,e=!1){return n.replace(Mv,(i,r)=>{const o=r.indexOf(":");let s=r,a=null;o!==-1&&(s=r.slice(0,o),a=r.slice(o+1));const c=s.trim().split(".");let l=t;for(const f of c){if(l==null)return"";l=l[f]}if(l==null)return"";let h;if(a){const f=typeof l=="number"?l:parseFloat(String(l));if(isNaN(f))h=String(l);else try{h=gr(a)(f)}catch{h=String(l)}}else h=String(l);return e?Qn(h):h})}const Av=/[&<>"']/g,Sv={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function Qn(n){return String(n).replace(Av,t=>Sv[t])}const _v=/^[=+\-@\t\r]/,Cv=/^-?\d+(?:[.,]\d+)?$/;function ns(n,t=","){let e=n==null?"":String(n);return _v.test(e)&&!Cv.test(e)&&(e="'"+e),(e.includes(t)||e.includes('"')||e.includes(`
2
+ `)||e.includes("\r"))&&(e='"'+e.replace(/"/g,'""')+'"'),e}const Pv=/^(#[0-9a-f]{3,8}|(rgb|rgba|hsl|hsla)\([\d.,%\s/]+\)|[a-z]+)$/i;function lf(n,t="#333"){const e=String(n).trim();return Pv.test(e)?e:t}const Ev=/<\/?[^>]+(>|$)/g,Tv=/<br\s*\/?>/gi;function re(n){return n.replace(Tv," ").replace(Ev,"").trim()}function lc(n,t){switch(n.type||"linear"){case"logarithmic":return new $v(n,t);case"datetime":return new Iv(n,t);case"category":return new hf(n,t);default:return new Lv(n,t)}}class is{constructor(t,e){this.config=t,this.plotArea=e}autoText(){return gn(this.config._backgroundColor)}getRange(){const t=this.config._inverted;if(this.config.isX){if(t){const s=this.plotArea.height;return this.config.reversed?[s,0]:[0,s]}const o=this.plotArea.width;return this.config.reversed?[o,0]:[0,o]}if(t){const o=this.plotArea.width;return this.config.reversed?[o,0]:[0,o]}const e=this.getPaneBand(),i=e.top,r=e.top+e.height;return this.config.reversed?[i,r]:[r,i]}getPaneBand(){const t=this.plotArea.height,e=o=>{if(o==null)return null;if(typeof o=="number")return o;if(typeof o=="string"&&o.trim().endsWith("%"))return parseFloat(o)/100*t;const s=parseFloat(o);return Number.isFinite(s)?s:null},i=e(this.config.top)??0,r=e(this.config.height)??t-i;return{top:i,height:r}}createD3Axis(t){const e=this.config.isX,i=this.config.opposite,r=this.config._inverted;return e?r?i?Xu(t):ju(t):i?Ja(t):Uu(t):r?i?Ja(t):Uu(t):i?Xu(t):ju(t)}applyAxisStyles(t,e){var s,a,c,l,h,f,u,d,p;const i=this.config,r=i.tickLength??10,o=i.tickPosition||"outside";if(t.selectAll(".tick line").attr("stroke",i.tickColor||"#ccd6eb").attr("stroke-width",i.tickWidth??1),(r!==10||o==="inside")&&t.selectAll(".tick line").each(function(){const y=st(this);if(i.isX){const g=i.opposite?-1:1;o==="inside"?y.attr("y1",0).attr("y2",-g*r):y.attr("y1",0).attr("y2",g*r)}else{const g=i.opposite?1:-1;o==="inside"?y.attr("x1",0).attr("x2",-g*r):y.attr("x1",0).attr("x2",g*r)}}),t.selectAll(".domain").attr("stroke",i.lineColor||"#ccd6eb").attr("stroke-width",i.lineWidth??1),((s=i.labels)==null?void 0:s.enabled)===!1)t.selectAll(".tick text").remove();else{const y=((a=i.labels)==null?void 0:a.style)||{};if(t.selectAll(".tick text").attr("fill",y.color||this.autoText()).style("font-size",y.fontSize||kt).style("font-weight",y.fontWeight||null).style("font-family",y.fontFamily||null).style("font-style",y.fontStyle||null),((c=i.labels)==null?void 0:c.x)!==void 0||((l=i.labels)==null?void 0:l.y)!==void 0){const g=((h=i.labels)==null?void 0:h.x)??0,m=((f=i.labels)==null?void 0:f.y)??0;t.selectAll(".tick text").attr("dx",g).attr("dy",parseFloat(t.select(".tick text").attr("dy")||"0")+m)}if((u=i.labels)!=null&&u.step&&i.labels.step>1&&t.selectAll(".tick text").each(function(g,m){m%i.labels.step!==0&&st(this).remove()}),i.showFirstLabel===!1){const g=t.selectAll(".tick text").nodes();g.length>0&&st(g[0]).remove()}if(i.showLastLabel===!1){const g=t.selectAll(".tick text").nodes();g.length>0&&st(g[g.length-1]).remove()}if((d=i.labels)!=null&&d.rotation)t.selectAll(".tick text").attr("transform",`rotate(${i.labels.rotation})`).style("text-anchor",i.labels.rotation<0?"end":"start");else if((i.isX?!i._inverted:i._inverted)&&((p=i.labels)!=null&&p.autoRotation))this.applyAutoRotation(t,i.labels.autoRotation,e);else if((i.isX?i._inverted:!i._inverted)&&!i.opposite&&Array.isArray(i.categories)&&i.categories.length>0){const g=i.tickLength??10;this.truncateSideLabels(t,e.x-g-4)}}i.visible===!1&&t.style("display","none")}truncateSideLabels(t,e){if(!(e>12))return;const i="…";t.selectAll(".tick text").each(function(){const r=this,o=r.textContent||"";if(!o)return;const s=r.getComputedTextLength();if(s<=e)return;let a=Math.max(1,Math.min(o.length,Math.ceil(o.length*e/s)));for(r.textContent=o.slice(0,a).replace(/\s+$/,"")+i;a>1&&r.getComputedTextLength()>e;)a--,r.textContent=o.slice(0,a).replace(/\s+$/,"")+i;const c=st(r);c.select("title").remove(),c.append("title").text(o)})}applyAutoRotation(t,e,i){const r=t.selectAll(".tick text").nodes();if(r.length<2||!this.hasLabelOverlap(r))return;const o=e.length>0?e[0]:-45;r.forEach(l=>{l.style.display=""}),t.selectAll(".tick text").attr("transform",`rotate(${o})`).style("text-anchor",o<0?"end":"start");const s=this.getRange();Math.abs(s[1]-s[0])/Math.max(1,r.length-1)<6&&this.applyAutoStep(t,r)}hasLabelOverlap(t,e=!1){for(let i=1;i<t.length;i++)try{const r=t[i-1].getBoundingClientRect(),o=t[i].getBoundingClientRect(),s=e?-4:2;if(r.right+s>o.left&&r.left<o.right)if(e){if(r.bottom+s>o.top&&r.top<o.bottom)return!0}else return!0}catch{return!1}return!1}applyAutoStep(t,e){const i=e.length;for(let r=2;r<=i;r++){e.forEach((s,a)=>{st(s).style("display",a%r===0?"":"none")});const o=e.filter((s,a)=>a%r===0);if(!this.hasLabelOverlap(o))return}}renderGridLines(t,e,i,r){if(this.config.visible===!1)return;const o=this.config.gridLineWidth;if(!o||o<=0)return;const s=r||(e.ticks?e.ticks():e.domain()),a=t.append("g").attr("class","katucharts-grid");this.config.alternateGridColor&&this.renderAlternateGridColor(a,s,e,i);const c=this.config.isX?!this.config._inverted:!!this.config._inverted;for(const l of s){const h=e(l);c?a.append("line").attr("x1",h).attr("x2",h).attr("y1",0).attr("y2",i.height).attr("stroke",this.config.gridLineColor||"#e6e6e6").attr("stroke-width",o).attr("stroke-dasharray",this.getDashArray(this.config.gridLineDashStyle)):a.append("line").attr("x1",0).attr("x2",i.width).attr("y1",h).attr("y2",h).attr("stroke",this.config.gridLineColor||"#e6e6e6").attr("stroke-width",o).attr("stroke-dasharray",this.getDashArray(this.config.gridLineDashStyle))}this.renderMinorGridLines(a,s,e,i)}renderAlternateGridColor(t,e,i,r){const o=this.config.alternateGridColor,s=this.config.isX?!this.config._inverted:!!this.config._inverted;for(let a=0;a<e.length-1;a+=2){const c=i(e[a]),l=i(e[a+1]);s?t.insert("rect",":first-child").attr("x",Math.min(c,l)).attr("y",0).attr("width",Math.abs(l-c)).attr("height",r.height).attr("fill",o):t.insert("rect",":first-child").attr("x",0).attr("y",Math.min(c,l)).attr("width",r.width).attr("height",Math.abs(l-c)).attr("fill",o)}}renderMinorGridLines(t,e,i,r){const o=this.config.minorTickInterval,s=this.config.minorGridLineWidth??1,a=this.config.minorGridLineColor||"#f2f2f2";if(!o||o==="auto"||s<=0||typeof o!="number"||e.length<2)return;const c=i.domain?i.domain():[0,1],l=typeof c[0]=="number"?c[0]:0,h=typeof c[c.length-1]=="number"?c[c.length-1]:1,f=new Set(e.map(d=>Number(d))),u=this.config.isX?!this.config._inverted:!!this.config._inverted;for(let d=l;d<=h;d+=o){if(f.has(d))continue;const p=i(d);u?t.append("line").attr("x1",p).attr("x2",p).attr("y1",0).attr("y2",r.height).attr("stroke",a).attr("stroke-width",s).attr("class","katucharts-minor-grid"):t.append("line").attr("x1",0).attr("x2",r.width).attr("y1",p).attr("y2",p).attr("stroke",a).attr("stroke-width",s).attr("class","katucharts-minor-grid")}}renderPlotBands(t,e,i){var r,o,s,a;if((r=this.config.plotBands)!=null&&r.length)for(const c of this.config.plotBands){const l=e(c.from??0),h=e(c.to??0);let f,u,d,p;(this.config.isX?!this.config._inverted:!!this.config._inverted)?(f=Math.min(l,h),u=0,d=Math.abs(h-l),p=i.height):(f=0,u=Math.min(l,h),d=i.width,p=Math.abs(h-l));const g=t.append("rect").attr("x",f).attr("y",u).attr("width",d).attr("height",p).attr("fill",c.color||"rgba(0,0,0,0.05)").attr("class",`katucharts-plot-band${c.className?" "+c.className:""}`);if(c.borderColor&&g.attr("stroke",c.borderColor).attr("stroke-width",c.borderWidth??0),c.borderRadius&&g.attr("rx",c.borderRadius),c.zIndex!==void 0&&g.style("z-index",c.zIndex),c.events&&(c.events.click&&g.on("click",m=>c.events.click.call(c,m)),c.events.mouseover&&g.on("mouseover",m=>c.events.mouseover.call(c,m)),c.events.mouseout&&g.on("mouseout",m=>c.events.mouseout.call(c,m)),c.events.mousemove&&g.on("mousemove",m=>c.events.mousemove.call(c,m)),g.style("cursor","pointer")),(o=c.label)!=null&&o.text){const m=c.label,b=m.align||"center",x=m.verticalAlign||"top";let v=b==="left"?f+4:b==="right"?f+d-4:f+d/2,k=x==="top"?u+12:x==="bottom"?u+p-4:u+p/2;v+=m.x??0,k+=m.y??0;const M=b==="left"?"start":b==="right"?"end":"middle";t.append("text").attr("x",v).attr("y",k).attr("text-anchor",M).attr("font-size",((s=m.style)==null?void 0:s.fontSize)||kt).attr("fill",((a=m.style)==null?void 0:a.color)||this.autoText()).attr("transform",m.rotation?`rotate(${m.rotation},${v},${k})`:"").style("pointer-events","none").attr("class","katucharts-plot-band-label").text(m.text||"")}}}renderPlotLines(t,e,i){var r,o,s,a;if((r=this.config.plotLines)!=null&&r.length)for(const c of this.config.plotLines){const l=e(c.value??0),h=this.config.isX?!this.config._inverted:!!this.config._inverted;let f;if(h?f=t.append("line").attr("x1",l).attr("x2",l).attr("y1",0).attr("y2",i.height).attr("stroke",c.color||"#999").attr("stroke-width",c.width||1).attr("stroke-dasharray",this.getDashArray(c.dashStyle)).attr("class",`katucharts-plot-line${c.className?" "+c.className:""}`):f=t.append("line").attr("x1",0).attr("x2",i.width).attr("y1",l).attr("y2",l).attr("stroke",c.color||"#999").attr("stroke-width",c.width||1).attr("stroke-dasharray",this.getDashArray(c.dashStyle)).attr("class",`katucharts-plot-line${c.className?" "+c.className:""}`),c.zIndex!==void 0&&f.style("z-index",c.zIndex),c.events&&(f.style("pointer-events","stroke"),c.events.click&&f.on("click",u=>c.events.click.call(c,u)),c.events.mouseover&&f.on("mouseover",u=>c.events.mouseover.call(c,u)),c.events.mouseout&&f.on("mouseout",u=>c.events.mouseout.call(c,u)),c.events.mousemove&&f.on("mousemove",u=>c.events.mousemove.call(c,u)),f.style("cursor","pointer")),(o=c.label)!=null&&o.text){const u=c.label,d=u.align||(this.config.isX?"left":"right"),p=u.verticalAlign||(this.config.isX?"top":"middle");let y,g;this.config.isX?(y=l+(u.x??4),g=p==="top"?u.y??12:p==="bottom"?i.height+(u.y??-4):i.height/2+(u.y??0)):(y=d==="left"?u.x??4:d==="right"?i.width+(u.x??-4):i.width/2+(u.x??0),g=l+(u.y??-6));const m=d==="left"?"start":d==="right"?"end":"middle";t.append("text").attr("x",y).attr("y",g).attr("text-anchor",m).attr("font-size",((s=u.style)==null?void 0:s.fontSize)||kt).attr("fill",((a=u.style)==null?void 0:a.color)||this.autoText()).attr("transform",u.rotation?`rotate(${u.rotation},${y},${g})`:"").style("pointer-events","none").attr("class","katucharts-plot-line-label").text(u.text||"")}}}applyAxisBreaks(t){var a;if(!((a=this.config.breaks)!=null&&a.length))return;const e=t.copy(),i=e.domain(),r=e.range(),o=Math.abs(i[1]-i[0]);let s=0;for(const c of this.config.breaks){const l=c.from??0,h=c.to??0;s+=Math.abs(h-l)}if(o>0&&s>0){const c=(o-s)/o,l=[r[0],r[0]+(r[1]-r[0])*c];t.range(l)}}renderTitle(t,e){var c,l,h,f,u,d,p;if(!((c=this.config.title)!=null&&c.text))return;const i=this.config.title,r=i.offset??0,o=i.margin??0,s=i.rotation;if(this.config.isX?!this.config._inverted:!!this.config._inverted){const y=((l=this.config.labels)==null?void 0:l.enabled)!==!1;let g=(y?45:33)+o+r;if(y&&t.selectAll(".tick text").nodes().length>0)try{const M=t.node().getBBox();g=Math.max(g,M.height+10+o+r)}catch{}const m=this.config,b=m._centerTitleOnChart&&m._chartWidth!=null?m._chartWidth/2-e.x:e.width/2,x=t.append("text").attr("class","katucharts-axis-title").attr("x",b).attr("y",g).attr("text-anchor","middle").attr("font-size",((h=i.style)==null?void 0:h.fontSize)||kt).attr("fill",((f=i.style)==null?void 0:f.color)||this.autoText()).text(i.text);s!==void 0&&x.attr("transform",`rotate(${s}, ${b}, ${g})`)}else{const y=((u=this.config.labels)==null?void 0:u.enabled)!==!1;let g=(this.config.opposite?e.width+45:-45)+r;if(y)try{const k=t.node().getBBox();this.config.opposite?g=Math.max(g,k.x+k.width+10+o+r):g=Math.min(g,k.x-10-o-r)}catch{}const m=this.getPaneBand(),b=m.top+m.height/2,x=s??-90;t.append("text").attr("class","katucharts-axis-title").attr("x",g).attr("y",b).attr("text-anchor","middle").attr("transform",`rotate(${x}, ${g}, ${b})`).attr("font-size",((d=i.style)==null?void 0:d.fontSize)||kt).attr("fill",((p=i.style)==null?void 0:p.color)||this.autoText()).text(i.text)}}animateAxis(t,e,i){var c;this.plotArea=e;const r=this.scale;if(!r)return;r.range(this.getRange()),this.applyAxisBreaks(r);const o=this.createD3Axis(r);if(this.config.tickPositions)o.tickValues(this.config.tickPositions);else if(this.config.tickInterval){const l=r.domain(),h=[];for(let f=l[0];f<=l[1];f+=this.config.tickInterval)h.push(f);o.tickValues(h)}else if(r.domain&&typeof r.ticks=="function"){const l=this.config._inverted,h=this.config.isX?l?e.height:e.width:l?e.width:e.height;this.config.isX;const f=this.config.tickPixelInterval??72,u=Math.min(20,Math.max(2,Math.round(h/f))),d=r.domain();if(this.computeNiceTicks){const p=this.computeNiceTicks(d[0],d[1],u);o.tickValues(p)}else if(this.computeLogTicks){const p=this.computeLogTicks(d,e);o.tickValues(p)}}if((c=this.config.labels)!=null&&c.formatter){const l=this.config.labels.formatter;o.tickFormat(h=>l.call({value:h,axis:this}))}else this.linearTickFormat?o.tickFormat(l=>this.linearTickFormat(l,o)):o.tickFormat(l=>cc(l));const s=`katucharts-axis-${this.config.isX?"x":"y"}`,a=t.select(`.${s}`);a.empty()||(a.transition().duration(i).call(o),this.animateGridLines(t,r,e,i))}animateGridLines(t,e,i,r){const o=this.config.gridLineWidth;!o||o<=0||(t.selectAll(".katucharts-grid").remove(),this.renderGridLines(t,e,i))}getDashArray(t){return{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t||"Solid"]||"none"}destroy(){}}class Lv extends is{constructor(t,e){super(t,e),this.scale=Me().range(this.getRange()).domain([0,1])}updateDomain(t){let{min:e,max:i}=t;const r=this.config.min!==void 0&&this.config.min!==null,o=this.config.max!==void 0&&this.config.max!==null;r&&(e=this.config.min),o&&(i=this.config.max),this.config.softMin!==void 0&&e>this.config.softMin&&(e=this.config.softMin),this.config.softMax!==void 0&&i<this.config.softMax&&(i=this.config.softMax),this.config.floor!==void 0&&(e=Math.max(e,this.config.floor)),this.config.ceiling!==void 0&&(i=Math.min(i,this.config.ceiling));const s=this.config.isX?this.config.maxPadding||.01:this.config.maxPadding||.05,a=i-e||1,c=e,l=(this.config.minPadding??s)+(t.extraMinPadding??0),h=s+(t.extraMaxPadding??0);r||(e-=a*l),o||(i+=a*h);const f=(t.extraMinPadding??0)>0;if(c>=0&&e<0&&!f&&(e=0),this.config.floor!==void 0&&(e=Math.max(e,this.config.floor)),this.config.ceiling!==void 0&&(i=Math.min(i,this.config.ceiling)),this.config.minRange!==void 0&&i-e<this.config.minRange){const p=(e+i)/2;e=p-this.config.minRange/2,i=p+this.config.minRange/2}if(this.config.maxRange!==void 0&&i-e>this.config.maxRange&&(i=e+this.config.maxRange),this.scale.domain([e,i]).range(this.getRange()),!(r&&o)&&(this.config.startOnTick||this.config.endOnTick||!this.config.isX&&this.config.startOnTick!==!1&&this.config.endOnTick!==!1)&&(this.scale.nice(),r||o)){const[p,y]=this.scale.domain();this.scale.domain([r?this.config.min:p,o?this.config.max:y])}}render(t,e){var o;this.plotArea=e,this.scale.range(this.getRange()),this.applyAxisBreaks(this.scale);const i=this.createD3Axis(this.scale);if(this.config.tickPositions)i.tickValues(this.config.tickPositions);else if(this.config.tickInterval){const s=this.scale.domain(),a=[];for(let c=s[0];c<=s[1];c+=this.config.tickInterval)a.push(c);i.tickValues(a)}else if(this.config.tickAmount)i.ticks(this.config.tickAmount);else{const s=this.config._inverted,a=this.config.isX?s?e.height:e.width:s?e.width:e.height;this.config.isX;const c=this.config.tickPixelInterval??72,l=Math.min(20,Math.max(2,Math.round(a/c))),h=this.scale.domain(),f=this.computeNiceTicks(h[0],h[1],l),u=this.config.max!==void 0&&this.config.max!==null,d=this.config.min!==void 0&&this.config.min!==null,p=!this.config.isX&&this.config.endOnTick!==!1;if(f.length>0&&p&&!u){const y=f.length>1?f[1]-f[0]:f[0]||1;let g=f[f.length-1];g<h[1]&&(f.push(g+y),g=f[f.length-1]);let m=f[0];m>h[0]&&(f.unshift(m-y),m=f[0]);const b=u?h[1]:Math.max(h[1],g),x=d?h[0]:Math.min(h[0],m);this.scale.domain([x,b])}i.tickValues(f)}if((o=this.config.labels)!=null&&o.formatter){const s=this.config.labels.formatter;i.tickFormat(a=>s.call({value:a,axis:this}))}else i.tickFormat(s=>this.linearTickFormat(s,i));const r=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",this.getTransform(e));this.renderGridLines(t,this.scale,e),this.renderPlotBands(t,this.scale,e),this.renderPlotLines(t,this.scale,e),r.call(i),this.applyAxisStyles(r,e),this.renderTitle(r,e),this.renderStackLabels(t,this.scale,e)}renderStackLabels(t,e,i){var r;!((r=this.config.stackLabels)!=null&&r.enabled)||this.config.isX}computeNiceTicks(t,e,i){const r=e-t;if(r<=0)return[t];const o=r/i,s=Math.pow(10,Math.floor(Math.log10(o))),a=o/s;let c;a<=Math.SQRT2?c=s:a<=Math.sqrt(2*2.5)?c=2*s:a<=Math.sqrt(2.5*5)?c=2.5*s:a<=Math.sqrt(5*10)?c=5*s:c=10*s;const l=c.toString(),h=l.includes(".")?l.split(".")[1].length:0,f=Math.pow(10,h),u=g=>Math.round(g*f)/f,d=u(Math.ceil(t/c)*c),p=[],y=c*1e-6;for(let g=0;g<i+3;g++){const m=u(d+g*c);if(m>e+y)break;p.push(m)}return p}getPixelForValue(t){return this.scale(t)}getValueForPixel(t){return this.scale.invert(t)}linearTickFormat(t,e){var r;const i=(r=e.tickValues)==null?void 0:r.call(e);if(i&&i.length>=2){const o=Math.abs(i[1]-i[0]),s=parseFloat(o.toPrecision(6));if(s<1e3){const a=s.toString(),c=a.includes(".")?a.split(".")[1].length:0,l=es(t,c);return c===0?l:l.replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")}}return cc(t)}getTransform(t){const e=this.config._inverted;return this.config.isX?e?this.config.opposite?`translate(${t.width},0)`:"":this.config.opposite?"":`translate(0,${t.height})`:e?this.config.opposite?"":`translate(0,${t.height})`:this.config.opposite?`translate(${t.width},0)`:""}}class $v extends is{constructor(t,e){super(t,e),this.scale=Fo().range(this.getRange()).domain([1,10])}updateDomain(t){let{min:e,max:i}=t;e=Math.max(e,.001),this.config.min!==void 0&&this.config.min!==null&&(e=Math.max(this.config.min,.001)),this.config.max!==void 0&&this.config.max!==null&&(i=this.config.max);const r=Math.log10(Math.max(e,1e-10)),o=Math.log10(Math.max(i,1e-10)),s=Math.abs(o-r)||1,a=this.config.isX?this.config.minPadding??.01:this.config.minPadding??.05;(this.config.min===void 0||this.config.min===null)&&(e=Math.pow(10,r-s*a)),(this.config.max===void 0||this.config.max===null)&&(i=Math.pow(10,o+s*a)),this.config.startOnTick&&(e=Math.pow(10,Math.floor(Math.log10(Math.max(e,1e-10))))),this.config.endOnTick&&(i=Math.pow(10,Math.ceil(Math.log10(Math.max(i,1e-10))))),this.scale.domain([e,i]).range(this.getRange())}computeLogTicks(){const t=this.scale.domain(),e=Math.log10(Math.max(t[0],1e-10)),i=Math.log10(Math.max(t[1],1e-10));if(this.config.tickPositions)return this.config.tickPositions;let r;if(this.config.tickInterval)r=this.config.tickInterval;else{r=1;const c=Math.abs(i-e);if(c>12){const l=this.config.isX?this.plotArea.width:this.plotArea.height,f=Math.max(2,Math.floor(l/20));r=Math.max(1,Math.ceil(c/f))}}const o=Math.floor(e),s=Math.ceil(i),a=[];for(let c=o;c<=s;c+=r){const l=Math.pow(10,c);l>=t[0]*.999&&l<=t[1]*1.001&&a.push(l)}return a.length===0?a.push(t[0],t[1]):a.length===1&&(a[0]>t[0]*1.5&&a.unshift(t[0]),a[0]<t[1]/1.5&&a.push(t[1])),a}render(t,e){var a;this.plotArea=e,this.scale.range(this.getRange());const i=this.createD3Axis(this.scale),r=this.computeLogTicks();if(i.tickValues(r),(a=this.config.labels)!=null&&a.formatter){const c=this.config.labels.formatter;i.tickFormat(l=>c.call({value:l,axis:this}))}else i.tickFormat(c=>cc(c));const o=this.config.isX?!this.config._inverted:!!this.config._inverted,s=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",o?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e,r),s.call(i),this.applyAxisStyles(s,e),this.renderTitle(s,e)}getPixelForValue(t){return this.scale(Math.max(t,.001))}getValueForPixel(t){return this.scale.invert(t)}}class Iv extends is{constructor(t,e){super(t,e);const i=sc()?Kb:Zb;this.scale=i().range(this.getRange()).domain([new Date,new Date])}updateDomain(t){const e=this.config.min??t.min,i=this.config.max??t.max;this.scale.domain([new Date(e),new Date(i)]).range(this.getRange())}render(t,e){var s;this.plotArea=e,this.scale.range(this.getRange());const i=this.createD3Axis(this.scale);if((s=this.config.labels)!=null&&s.formatter){const a=this.config.labels.formatter;i.tickFormat(c=>a.call({value:c.getTime(),axis:this}))}else if(this.config.dateTimeLabelFormats){const a=this.config.dateTimeLabelFormats,c=sc()?Ho:Wo;i.tickFormat(l=>{const h=l,f=this.pickDateFormat(h,a);return c(f)(h)})}const r=this.config.isX?!this.config._inverted:!!this.config._inverted,o=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",r?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e),o.call(i),this.applyAxisStyles(o,e),this.renderTitle(o,e)}pickDateFormat(t,e){const i=sc(),r=i?t.getUTCMilliseconds():t.getMilliseconds(),o=i?t.getUTCSeconds():t.getSeconds(),s=i?t.getUTCMinutes():t.getMinutes(),a=i?t.getUTCHours():t.getHours(),c=i?t.getUTCDate():t.getDate(),l=i?t.getUTCMonth():t.getMonth();return r!==0&&e.millisecond?e.millisecond:o!==0&&e.second?e.second:s!==0&&e.minute?e.minute:a!==0&&e.hour?e.hour:c!==1&&e.day?e.day:l!==0&&e.month?e.month:e.year?e.year:e.day||"%b %d"}getPixelForValue(t){return this.scale(new Date(t))}getValueForPixel(t){return this.scale.invert(t).getTime()}}class hf extends is{constructor(t,e){super(t,e),this.scale=ou().range(this.getRange()).paddingInner(.3).paddingOuter(.05),t.categories&&this.scale.domain(t.categories)}updateDomain(t){Array.isArray(t)&&this.scale.domain(t).range(this.getRange())}render(t,e){this.plotArea=e;const i=this.getRange();if(isNaN(i[0])||isNaN(i[1])||i[0]===i[1])return;this.scale.range(i);const r=this.createD3Axis(this.scale),o=this.config.isX?!this.config._inverted:!!this.config._inverted,s=t.append("g").attr("class",`katucharts-axis katucharts-axis-${this.config.isX?"x":"y"}`).attr("transform",o?`translate(0,${e.height})`:"");this.renderGridLines(t,this.scale,e),s.call(r),this.applyAxisStyles(s,e),this.renderTitle(s,e),this.applyAutoStepIfNeeded(s)}applyAutoStepIfNeeded(t){var s,a,c;if(((s=this.config.labels)==null?void 0:s.enabled)===!1)return;const e=this.scale.bandwidth();if(e<=0)return;const i=se(((c=(a=this.config.labels)==null?void 0:a.style)==null?void 0:c.fontSize)||kt);if(i<=e)return;const o=Math.min(i,Math.max(5,Math.round(e*1.1)));t.selectAll(".tick text").style("font-size",`${o}px`)}getPixelForValue(t){const e=this.scale.domain();let i;if(typeof t=="number"){const r=Math.round(t);if(r>=0&&r<e.length){i=e[r];const o=(this.scale(i)??0)+this.scale.bandwidth()/2,s=(t-r)*this.scale.bandwidth();return o+s}i=String(t)}else i=String(t);return(this.scale(i)??0)+this.scale.bandwidth()/2}getBandwidth(){return this.scale.bandwidth()}getValueForPixel(t){const e=this.scale.domain(),i=this.scale.step(),r=Math.floor(t/i);return e[Math.min(r,e.length-1)]}}class rs{static render(t,e,i,r,o,s){if(!i.enabled)return;const a=t.append("g").attr("class","katucharts-data-labels");i.zIndex!==void 0&&a.style("z-index",i.zIndex),e.forEach((c,l)=>{var p,y,g,m,b,x;if(c.y===null||c.y===void 0)return;if(i.filter){const v=i.filter.property,k=i.filter.operator||">",M=i.filter.value??0,C=v?c[v]:c.y;if(!rs.matchesFilter(C,k,M))return}let h;i.formatter?h=i.formatter.call({point:{...c,index:l},series:{name:s},x:c.x,y:c.y,percentage:c.percentage}):i.format?h=re(Zt(i.format,{point:c,series:{name:s},x:c.x,y:c.y})):h=String(c.y);const f=r.getPixelForValue(c.x??l)+(i.x??0),u=o.getPixelForValue(c.y)+(i.y??-8),d=a.append("text").attr("x",f).attr("y",u).attr("text-anchor",i.align||"center").attr("dominant-baseline","auto").attr("font-size",((p=i.style)==null?void 0:p.fontSize)||kt).attr("fill",i.color||((y=i.style)==null?void 0:y.color)||Fe).attr("font-weight",((g=i.style)==null?void 0:g.fontWeight)||"normal").text(h);if(i.className&&d.attr("class",i.className),i.rotation&&d.attr("transform",`rotate(${i.rotation},${f},${u})`),i.shadow&&d.attr("filter","drop-shadow(1px 1px 2px rgba(0,0,0,0.3))"),(m=i.textPath)!=null&&m.enabled){const v=i.textPath.attributes||{};d.selectAll("*").remove();const k=d.append("textPath");for(const[M,C]of Object.entries(v))k.attr(M,C);k.text(h)}if(i.backgroundColor){const v=(x=(b=d.node())==null?void 0:b.getBBox)==null?void 0:x.call(b);if(v){const k=i.padding??2,M=a.insert("rect","text").attr("x",v.x-k).attr("y",v.y-k).attr("width",v.width+k*2).attr("height",v.height+k*2).attr("fill",i.backgroundColor).attr("rx",i.borderRadius??0).attr("stroke",i.borderColor||"none").attr("stroke-width",i.borderWidth??0);i.shadow&&M.attr("filter","drop-shadow(1px 1px 2px rgba(0,0,0,0.3))")}}}),i.defer&&(a.style("opacity","0"),a.transition().delay(1e3).duration(200).style("opacity","1"))}static matchesFilter(t,e,i){const r=Number(t);if(isNaN(r))return!1;switch(e){case">":return r>i;case"<":return r<i;case">=":return r>=i;case"<=":return r<=i;case"==":return r===i;case"!=":return r!==i;default:return!0}}}function Fv(n){if(typeof n=="string"){const t=document.getElementById(n);if(!t)throw new Error(`KatuCharts: container element "${n}" not found`);return t}return n}function uf(n,t=.5){const e=getComputedStyle(n),i=parseFloat(e.paddingLeft)||0,r=parseFloat(e.paddingRight)||0,o=parseFloat(e.paddingTop)||0,s=parseFloat(e.paddingBottom)||0,a=n.getBoundingClientRect(),c=a.width-i-r||n.clientWidth-i-r||600,l=a.height-o-s||n.clientHeight-o-s,h=l>0,f=h?l:Math.round(c*t);return{width:c,height:f,heightMeasured:h}}function hc(n,t){const e=document.createElement("div");return n&&(e.className=n),t&&t.appendChild(e),e}function ff(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function uc(n,t){let e=0,i=null;return function(...r){const o=Date.now(),s=t-(o-e);s<=0?(i&&(clearTimeout(i),i=null),e=o,n.apply(this,r)):i||(i=setTimeout(()=>{e=Date.now(),i=null,n.apply(this,r)},s))}}function Rv(n,t){let e=null;return function(...i){e&&clearTimeout(e),e=setTimeout(()=>{n.apply(this,i)},t)}}const Zr=class Zr{constructor(t,e,i,r){if(this.element=null,this.splitElements=[],this.hideTimeout=null,this.categories=null,this.isDatetime=!1,this.sharedPoints=[],this.sharedProvider=null,this.lastMouseEvent=null,this.boundHandlers=[],this.config=t,this.container=t.outside?document.body:e,this.plotArea=i,t.enabled!==!1){if(r.on("point:mouseover",o=>this.show(o)),r.on("point:mouseout",o=>{var s,a,c;if(this.config.shared&&(o!=null&&o.series)){const l=((a=(s=o.series)==null?void 0:s.config)==null?void 0:a.name)??((c=o.series)==null?void 0:c.name)??"";this.sharedPoints=this.sharedPoints.filter(h=>h.series.name!==l)}this.scheduleHide()}),t.followPointer){const o=uc(s=>{this.lastMouseEvent=s,this.element&&this.element.style.display!=="none"&&this.positionAtMouse(s)},16);e.addEventListener("mousemove",o),this.boundHandlers.push({el:e,type:"mousemove",fn:o})}if(t.stickOnContact){const o=uc(s=>{if(this.element&&this.element.style.display!=="none"){const a=this.element.getBoundingClientRect();s.clientX>=a.left&&s.clientX<=a.right&&s.clientY>=a.top&&s.clientY<=a.bottom&&this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}},16);e.addEventListener("mousemove",o),this.boundHandlers.push({el:e,type:"mousemove",fn:o})}if(t.followTouchMove!==!1){const o=uc(s=>{if(this.element&&this.element.style.display!=="none"&&s.touches.length===1){const a=s.touches[0],c=e.getBoundingClientRect(),l=this.config.distance??16;let h=a.clientX-c.left+l,f=a.clientY-c.top-10;const u=this.element.offsetWidth||120;h+u>c.width&&(h=a.clientX-c.left-u-l),f<0&&(f=5),this.element.style.left=`${h}px`,this.element.style.top=`${f}px`}},16);e.addEventListener("touchmove",o,{passive:!0}),this.boundHandlers.push({el:e,type:"touchmove",fn:o})}}}show(t){var r,o,s,a,c,l,h;if(this.config.enabled===!1)return;this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null);const i={point:t.index!==void 0?{...t.point,index:t.index}:t.point,plotX:t.plotX,plotY:t.plotY,series:{name:((o=(r=t.series)==null?void 0:r.config)==null?void 0:o.name)??((s=t.series)==null?void 0:s.name)??"",color:((c=(a=t.series)==null?void 0:a.getColor)==null?void 0:c.call(a))??((l=t.series)==null?void 0:l.color)??"#333",config:(h=t.series)==null?void 0:h.config}};if(this.config.shared){const f=i.point.x??i.plotX;if(this.sharedProvider){const u=this.sharedProvider(f);this.sharedPoints=u.length>0?u:[i]}else{this.sharedPoints.length>0&&(this.sharedPoints[0].point.x??this.sharedPoints[0].plotX)!==f&&(this.sharedPoints=[]);const d=this.sharedPoints.findIndex(p=>p.series.name===i.series.name);d>=0?this.sharedPoints[d]=i:this.sharedPoints.push(i)}}if(this.config.split){this.showSplit(i);return}if(this.element||(this.element=this.createElement()),this.config.stickOnContact&&(this.element.style.pointerEvents="auto"),this.config.borderColor===void 0){const f=i.point.color||i.series.color||"#333";this.element.style.borderColor=f}this.config.shared&&this.sharedPoints.length>0?this.element.innerHTML=this.formatSharedContent(this.sharedPoints):this.element.innerHTML=this.formatContent(i),this.config.followPointer&&this.lastMouseEvent?this.positionAtMouse(this.lastMouseEvent):this.position(i),this.element.style.display="block",this.config.animation!==!1?this.element.style.opacity="1":(this.element.style.transition="none",this.element.style.opacity="1")}hide(){this.element&&(this.element.style.opacity="0",this.element.style.display="none"),this.hideSplitElements(),this.sharedPoints=[]}scheduleHide(){const t=this.config.hideDelay??500;this.hideTimeout=setTimeout(()=>this.hide(),t)}showSplit(t){this.hideSplitElements();const e=this.formatContent(t);if(!e)return;const i=this.createSplitElement(t.series.color||"#333");i.innerHTML=e;const r=this.config.distance??16,o=this.plotArea,s=o.x+t.plotX+r,a=o.y+t.plotY;i.style.left=`${s}px`,i.style.top=`${a}px`,i.style.display="block",i.style.opacity="1",this.splitElements.push(i)}hideSplitElements(){for(const t of this.splitElements)ff(t);this.splitElements=[]}createSplitElement(t){var s,a;const e=hc("katucharts-tooltip-split",this.container),i=this.config.backgroundColor||"rgba(247,247,247,0.85)",r=this.config.borderRadius??3,o=this.config.padding??8;return Object.assign(e.style,{position:"absolute",pointerEvents:"none",zIndex:String(this.config.zIndex??10),backgroundColor:i,border:`${this.config.borderWidth??1}px solid ${t}`,borderRadius:`${r}px`,padding:`${o}px`,fontSize:((s=this.config.style)==null?void 0:s.fontSize)||"12px",color:((a=this.config.style)==null?void 0:a.color)||"#333333",boxShadow:this.config.shadow!==!1?"2px 2px 6px rgba(0,0,0,0.15)":"none",transition:this.config.animation!==!1?"opacity 0.15s":"none",whiteSpace:"nowrap",display:"none"}),e}createElement(){var a,c;const t=hc(`katucharts-tooltip${this.config.className?" "+this.config.className:""}`,this.container),e=this.config.backgroundColor||"rgba(247,247,247,0.85)",i=this.config.borderRadius??3,r=this.config.padding??8,o=this.config.shape||"callout";let s=`${i}px`;return o==="circle"&&(s="50%"),Object.assign(t.style,{position:this.config.outside?"fixed":"absolute",pointerEvents:this.config.stickOnContact?"auto":"none",zIndex:String(this.config.zIndex??10),backgroundColor:e,border:`${this.config.borderWidth??1}px solid ${this.config.borderColor||"#ccc"}`,borderRadius:s,padding:`${r}px`,fontSize:((a=this.config.style)==null?void 0:a.fontSize)||"12px",color:((c=this.config.style)==null?void 0:c.color)||"#333333",boxShadow:this.config.shadow!==!1?"2px 2px 6px rgba(0,0,0,0.15)":"none",transition:this.config.animation!==!1?"opacity 0.15s":"none",whiteSpace:"nowrap",display:"none"}),t}formatValue(t){if(t==null)return"";let e;this.config.valueDecimals!==void 0?e=t.toFixed(this.config.valueDecimals):e=String(t);const i=this.config.valuePrefix||"",r=this.config.valueSuffix||"";return`${i}${e}${r}`}resolveKey(t){let e=t.point.name??t.point.x??"";return this.categories&&typeof t.point.x=="number"&&this.categories[t.point.x]&&(e=this.categories[t.point.x]),e}getPointCategory(t){return t.category!==void 0?t.category:this.categories&&typeof t.x=="number"&&this.categories[t.x]!==void 0?this.categories[t.x]:t.name}buildFormatterPoint(t,e={}){const i=this.resolveKey(t),r=this.getPointCategory(t.point);return{...t.point,...e,key:i,category:r,color:t.point.color||t.series.color||"#333",series:{name:t.series.name||"",color:t.series.color||"#333"}}}buildFormatterContext(t,e={}){const i=this.resolveKey(t);return{point:this.buildFormatterPoint(t),series:t.series,x:t.point.x,y:t.point.y,percentage:t.point.percentage,total:t.point.total,key:i,color:t.point.color||t.series.color,...e}}formatContent(t){var k;const e=(k=t.series.config)==null?void 0:k.tooltip;if(t.point.y===null||t.point.y===void 0){const M=(e==null?void 0:e.nullFormatter)??this.config.nullFormatter,C=(e==null?void 0:e.nullFormat)??this.config.nullFormat;if(M)return M.call({point:t.point,series:t.series});if(C)return C}if(this.config.formatter){const M=this.config.formatter.call(this.buildFormatterContext(t));return M===!1?"":M}const i=this.resolveKey(t),r=t.point.name??(this.categories&&typeof t.point.x=="number"?this.categories[t.point.x]:void 0)??i,o=(e==null?void 0:e.valueDecimals)??this.config.valueDecimals,s=(e==null?void 0:e.valuePrefix)??this.config.valuePrefix??"",a=(e==null?void 0:e.valueSuffix)??this.config.valueSuffix??"",c=this.formatValueWith(t.point.y,o,s,a);let l=r;const h=(e==null?void 0:e.xDateFormat)??this.config.xDateFormat??(this.isDatetime?Zr.DEFAULT_DATE_FORMAT:void 0);h&&typeof t.point.x=="number"&&t.point.name===void 0&&(l=ac(h,t.point.x));const f={point:this.buildFormatterPoint(t,{name:r,key:l,y:c||t.point.y}),series:{...t.series,name:t.series.name||""}},u=(e==null?void 0:e.pointFormatter)??this.config.pointFormatter;if(u){const M=u.call(this.buildFormatterContext(t)),C=(e==null?void 0:e.headerFormat)??this.config.headerFormat??"",E=(e==null?void 0:e.footerFormat)??this.config.footerFormat??"";return Zt(C,f,!0)+M+Zt(E,f,!0)}if(this.config.format)return Zt(this.config.format,f,!0);const d=(e==null?void 0:e.headerFormat)??this.config.headerFormat??"",p=(e==null?void 0:e.pointFormat)??this.config.pointFormat??"",y=(e==null?void 0:e.footerFormat)??this.config.footerFormat??"",g=Zt(d,f,!0),m=Zt(p,f,!0),b=Zt(y,f,!0);let x="";const v=!!((e==null?void 0:e.pointFormat)??this.config.pointFormat);if(t.point.total!==void 0&&!y&&!v){const M=t.point.total,C=Math.round(M*1e6)/1e6;x=`<span style="font-size:10px">Total: <b>${this.formatValue(C)}</b></span><br/>`}return g+m+b+x}formatValueWith(t,e,i,r){if(t==null)return"";let o;return e!==void 0?o=t.toFixed(e):o=String(t),`${i||""}${o}${r||""}`}formatSharedContent(t){var r,o,s,a;if(this.config.formatter){const c=t[0],l=c?this.resolveKey(c):"",h=this.config.formatter.call({point:c?this.buildFormatterPoint(c):void 0,series:c==null?void 0:c.series,x:c==null?void 0:c.point.x,y:c==null?void 0:c.point.y,key:l,color:(c==null?void 0:c.point.color)||(c==null?void 0:c.series.color),points:t.map(f=>({point:this.buildFormatterPoint(f),series:f.series,x:f.point.x,y:f.point.y,percentage:f.point.percentage,total:f.point.total,key:this.resolveKey(f),color:f.point.color||f.series.color}))});return h===!1?"":h}const e=[],i=this.formatXKey((r=t[0])==null?void 0:r.point,(s=(o=t[0])==null?void 0:o.series.config)==null?void 0:s.tooltip);i!==""&&e.push(`<span style="font-size:10px">${Qn(String(i))}</span><br/>`);for(const c of t){const l=(a=c.series.config)==null?void 0:a.tooltip,h=l==null?void 0:l.pointFormat;if(h){const p={point:this.buildFormatterPoint(c),series:{...c.series,name:c.series.name||""}};e.push(Zt(h,p,!0));continue}const f=lf(c.point.color||c.series.color||"#333"),u=Qn(c.series.name||""),d=this.formatValue(c.point.y);e.push(`<span style="color:${f}">●</span> ${u}: <b>${d}</b><br/>`)}return e.join("")}position(t){var h,f;if(!this.element)return;if(this.config.positioner){const u=this.config.positioner(this.element.offsetWidth,this.element.offsetHeight,t);this.element.style.left=`${u.x}px`,this.element.style.top=`${u.y}px`;return}const e=this.config.distance??16,i=this.plotArea;let r=i.x+t.plotX+e,o=i.y+t.plotY-10;const s=this.element.offsetWidth||120,a=this.element.offsetHeight||50,c=this.config.outside?window.innerWidth:this.container.offsetWidth||((h=this.container.parentElement)==null?void 0:h.offsetWidth)||800,l=this.config.outside?window.innerHeight:this.container.offsetHeight||((f=this.container.parentElement)==null?void 0:f.offsetHeight)||600;r+s>c&&(r=i.x+t.plotX-s-e),o+a>l&&(o=l-a-5),o<0&&(o=5),r<0&&(r=5),this.element.style.left=`${r}px`,this.element.style.top=`${o}px`}positionAtMouse(t){if(!this.element)return;const e=this.config.distance??16;if(this.config.outside){let c=t.clientX+e,l=t.clientY-10;const h=this.element.offsetWidth||120,f=this.element.offsetHeight||50;c+h>window.innerWidth&&(c=t.clientX-h-e),l+f>window.innerHeight&&(l=window.innerHeight-f-5),l<0&&(l=5),c<0&&(c=5),this.element.style.left=`${c}px`,this.element.style.top=`${l}px`;return}const i=this.container.getBoundingClientRect();let r=t.clientX-i.left+e,o=t.clientY-i.top-10;const s=this.element.offsetWidth||120,a=this.element.offsetHeight||50;r+s>i.width&&(r=t.clientX-i.left-s-e),o+a>i.height&&(o=i.height-a-5),o<0&&(o=5),r<0&&(r=5),this.element.style.left=`${r}px`,this.element.style.top=`${o}px`}updatePlotArea(t){this.plotArea=t}setCategories(t){this.categories=t}setDatetimeAxis(t){this.isDatetime=t}setSharedPointsProvider(t){this.sharedProvider=t}formatXKey(t,e){if(!t)return"";if(this.categories&&typeof t.x=="number"&&this.categories[t.x]!==void 0)return this.categories[t.x];if(t.name!==void 0&&t.name!==null)return t.name;const i=t.x;if(typeof i=="number"){const r=(e==null?void 0:e.xDateFormat)??this.config.xDateFormat??(this.isDatetime?Zr.DEFAULT_DATE_FORMAT:void 0);if(r)return ac(r,i)}return i??""}destroy(){this.hideTimeout&&clearTimeout(this.hideTimeout);for(const{el:t,type:e,fn:i}of this.boundHandlers)t.removeEventListener(e,i);this.boundHandlers=[],ff(this.element),this.element=null,this.hideSplitElements()}};Zr.DEFAULT_DATE_FORMAT="%A, %b %e, %Y";let os=Zr;class ss{constructor(t,e,i){this.series=[],this.scrollOffset=0,this.contentHeight=0,this.visibleHeight=0,this.config=t,this.events=i,t.enabled!==!1&&(this.group=e.append("g").attr("class",`katucharts-legend${t.className?" "+t.className:""}`))}autoText(){return gn(this.config._backgroundColor)}resolveLabel(t){var r;const e=t.getColor();let i;if(this.config.labelFormatter)i=this.config.labelFormatter.call({name:t.config.name||"",color:e,percentage:t.percentage,total:t.total,index:t.config.index,legendIndex:t.config.legendIndex,options:t.config});else if(this.config.labelFormat){const o={name:t.config.name||"",color:e,index:t.config.index,legendIndex:t.config.legendIndex};i=re(Zt(this.config.labelFormat,o))}else i=t.config.name||`Series ${t.config.index+1}`;if(this.config.valueSuffix&&(i+=` ${this.config.valueSuffix}`),this.config.valueDecimals!==void 0&&this.config.valueDecimals>=0){const o=t.data.length>0?(r=t.data[t.data.length-1])==null?void 0:r.y:void 0;typeof o=="number"&&(i+=`: ${o.toFixed(this.config.valueDecimals)}`)}return i}computeAutoFontSize(t,e){return e||kt}estimateTextWidth(t,e){const i=se(e);return t.length*i*.62}static computeGridLayout(t,e,i,r){if(r.itemWidth)return{columns:Math.max(2,Math.floor(i/r.itemWidth)),itemWidth:r.itemWidth};const o=se(r.fontSize);let s=0;for(const l of e){const h=l.length*o*.62;h>s&&(s=h)}const a=r.symbolWidth+r.symbolPadding+s+8;return{columns:Math.max(1,Math.floor(i/a)),itemWidth:a}}render(t,e){var nt,lt,ht,at;if(this.config.enabled===!1||!this.group)return;this.series=t,this.group.selectAll("*").remove();let i=t.filter(W=>W.config.showInLegend!==!1&&!W.config.linkedTo);if(i.length===0)return;this.config.reversed&&(i=[...i].reverse());const r=this.config.layout||"horizontal",o=this.config.padding??8,s=this.config.symbolWidth??12,a=this.config.symbolHeight??12,c=this.config.symbolPadding??5,l=this.config.symbolRadius??2,h=this.config.squareSymbol!==!1,f=this.config.itemDistance??20,u=this.config.itemStyle||{},d=this.config.itemMarginTop??0,p=this.config.itemMarginBottom??4,y=this.config.lineHeight??16,g=this.config.maxHeight,m=this.config.width,b=u.fontSize||kt,x=this.computeAutoFontSize(i.length,b);let v=o,k=o,M=0;if((nt=this.config.title)!=null&&nt.text){const W=this.config.title.style||{};this.group.append("text").attr("class","katucharts-legend-title").attr("x",o).attr("y",o+10).attr("font-size",W.fontSize||kt).attr("font-weight",W.fontWeight||"bold").attr("fill",W.color||"#333").text(this.config.title.text),k+=20}const C=k,E=m||e.width-o*2,_=y+p+d,T=[];for(const W of i){const J=W.getMultiLegendItems(),ut=["line","spline","area","areaspline","radar","polar"].includes(W.config._internalType);J?J.forEach((vt,Lt)=>{T.push({label:vt.label,color:vt.color,series:W,isLine:ut,multiIndex:Lt,visible:vt.visible!==!1})}):T.push({label:this.resolveLabel(W),color:W.getColor(),series:W,isLine:ut,visible:W.visible})}const I=T.map(W=>W.label);let L=0;if(r==="horizontal")for(let W=0;W<I.length;W++){const J=s+c+this.estimateTextWidth(I[W],x);L+=J+(W<I.length-1?f:0)}const P=r==="horizontal"&&T.length>8&&L>E;let A=0,w=0;const S=6;let $=0,R=0;if(P){const W=ss.computeGridLayout(T.length,I,E,{symbolWidth:s,symbolPadding:c,fontSize:x,itemDistance:f,padding:o,itemWidth:this.config.itemWidth});A=W.columns,w=W.itemWidth,R=Math.ceil(T.length/A)}const F=[];T.forEach((W,J)=>{var Ee;const ut=W.series,vt=W.color,Lt=W.isLine,wt=W.label;let $t=W.visible,Vt,ee;if(P){const Gt=J%A,Ut=Math.floor(J/A),Xe=A*w,ae=Math.max(0,(E-Xe)/2);Vt=o+ae+Gt*w,ee=C+Ut*_+d}else if(r==="horizontal"){const Gt=this.config.itemWidth||this.estimateTextWidth(wt,x),Ut=s+c+Gt;J>0&&v+Ut>E&&(v=o,k+=_),Vt=v,ee=k+d,M=Math.max(M,v+Ut),v+=Ut+f}else{const Gt=this.config.itemWidth||this.estimateTextWidth(wt,x),Ut=s+c+Gt;Vt=v,ee=k+d,M=Math.max(M,v+Ut),v=o,k+=_}const Ct=this.group.append("g").attr("class","katucharts-legend-item").attr("transform",`translate(${Vt},${ee})`).style("cursor","pointer"),Jt=ut.getLegendSymbolShape();if(Lt)Ct.append("line").attr("x1",0).attr("x2",s).attr("y1",6).attr("y2",6).attr("stroke",vt).attr("stroke-width",2),Ct.append("circle").attr("cx",s/2).attr("cy",6).attr("r",3).attr("fill",vt);else if(Jt){const Gt=s/2,Ut=a/2,Xe=Math.min(s,a)/2;Jt==="circle"?Ct.append("circle").attr("cx",Gt).attr("cy",Ut).attr("r",Xe).attr("fill",vt):Jt==="square"?Ct.append("rect").attr("x",0).attr("y",0).attr("width",s).attr("height",a).attr("fill",vt):Jt==="diamond"?Ct.append("path").attr("d",`M ${Gt} 0 L ${s} ${Ut} L ${Gt} ${a} L 0 ${Ut} Z`).attr("fill",vt):Jt==="triangle"?Ct.append("path").attr("d",`M ${Gt} 0 L ${s} ${a} L 0 ${a} Z`).attr("fill",vt):Jt==="triangle-down"?Ct.append("path").attr("d",`M 0 0 L ${s} 0 L ${Gt} ${a} Z`).attr("fill",vt):Jt==="cross"?Ct.append("path").attr("d",`M 0 ${Ut} L ${s} ${Ut} M ${Gt} 0 L ${Gt} ${a}`).attr("stroke",vt).attr("stroke-width",2):Ct.append("circle").attr("cx",Gt).attr("cy",Ut).attr("r",Xe).attr("fill",vt)}else h?Ct.append("rect").attr("x",0).attr("y",0).attr("width",s).attr("height",a).attr("rx",l).attr("fill",vt):Ct.append("circle").attr("cx",s/2).attr("cy",a/2).attr("r",Math.min(s,a)/2).attr("fill",vt);const ne=Ct.append("text").attr("x",s+c).attr("y",10).attr("fill",$t?u.color||this.autoText():((Ee=this.config.itemHiddenStyle)==null?void 0:Ee.color)||"#cccccc").attr("font-size",x).attr("font-weight",u.fontWeight||"normal").text(wt);this.config.rtl&&(ne.attr("text-anchor","end").attr("x",-c),Ct.select("rect, circle, line").attr("transform",`translate(${-(s+c)}, 0)`)),Ct.on("click",()=>{var ae,Pn,un;const Gt=this.config.events;if(Gt!=null&&Gt.itemClick&&Gt.itemClick.call(ut,new Event("legendItemClick"))===!1)return;const Ut=W.multiIndex!==void 0?ut.toggleLegendItem(W.multiIndex):null;Ut===null?(ut.toggleVisible(),$t=ut.visible):$t=Ut,ne.attr("fill",$t?u.color||this.autoText():((ae=this.config.itemHiddenStyle)==null?void 0:ae.color)||"#cccccc"),((un=(Pn=ut.config.events)==null?void 0:Pn.legendItemClick)==null?void 0:un.call(ut,new Event("legendItemClick")))!==!1&&this.events.emit("legend:itemClick",ut,J)}),Ct.on("mouseover",()=>{var Gt;ne.attr("fill",((Gt=this.config.itemHoverStyle)==null?void 0:Gt.color)||this.autoText()),this.events.emit("legend:itemHover",ut)}),Ct.on("mouseout",()=>{var Gt;ne.attr("fill",$t?u.color||this.autoText():((Gt=this.config.itemHiddenStyle)==null?void 0:Gt.color)||"#cccccc"),this.events.emit("legend:itemLeave")}),F.push(Ct)});let D=0,z=0,B=0,N=0;const K=(lt=this.config.bubbleLegend)!=null&&lt.enabled?t.map(W=>W.getBubbleLegendInfo()).find(W=>!!W):void 0;if(K)if(r==="horizontal"&&((ht=this.config.bubbleLegend)==null?void 0:ht.layout)==="separate"){N=T.length?k+_:C;const J=this.renderBubbleLegend(K,0,N);D=J.width,z=J.height;const ut=T.length?Math.max(0,M-o):0,vt=Math.max(ut,D);B=o+Math.max(0,(vt-D)/2),this.group.select(".katucharts-bubble-legend").attr("transform",`translate(${B},0)`);const Lt=Math.max(0,(vt-ut)/2);if(Lt>0)for(const wt of F){const $t=/translate\(\s*([-\d.]+)\s*,\s*([-\d.]+)\s*\)/.exec(wt.attr("transform")||"");$t&&wt.attr("transform",`translate(${parseFloat($t[1])+Lt},${$t[2]})`)}}else{r==="horizontal"?(B=T.length?M+f:o,N=C):(B=o,N=T.length?k+6:C);const J=this.renderBubbleLegend(K,B,N);D=J.width,z=J.height}const V=(W,J=!1)=>{const ut=W*S,vt=ut+S;F.forEach((Lt,wt)=>{const $t=Math.floor(wt/A);if($t>=ut&&$t<vt){const ee=wt%A,Ct=A*w,Jt=Math.max(0,(E-Ct)/2),ne=o+Jt+ee*w,Ee=C+($t-ut)*_+(this.config.itemMarginTop??0);Lt.style("display","block"),J?Lt.style("opacity","0").attr("transform",`translate(${ne},${Ee})`).transition().duration(250).style("opacity","1"):Lt.attr("transform",`translate(${ne},${Ee})`).style("opacity","1")}else J?Lt.transition().duration(150).style("opacity","0").on("end",function(){Lt.style("display","none")}):Lt.style("display","none")})};let G,H;if(P){const W=Math.min(R,S);if(G=E+o*2,H=C+W*_+o,R>S){V(0);const J=Math.ceil(R/S),ut=E-20,vt=C+Math.min(R,S)*_/2,Lt=this.group.append("g").attr("class","katucharts-legend-nav"),wt=22,$t=Lt.append("g").attr("transform",`translate(${ut},${vt-wt-2})`).style("cursor","pointer").style("opacity","0.3");$t.append("rect").attr("x",0).attr("y",0).attr("width",wt).attr("height",wt).attr("rx",4).attr("fill","#f0f0f0").attr("stroke","#ccc").attr("stroke-width",1),$t.append("path").attr("d",`M${wt/2-5},${wt/2+2} L${wt/2},${wt/2-4} L${wt/2+5},${wt/2+2}`).attr("fill","none").attr("stroke","#555").attr("stroke-width",2).attr("stroke-linecap","round"),$t.on("mouseover",function(){$t.select("rect").attr("fill","#e0e0e0")}),$t.on("mouseout",function(){$t.select("rect").attr("fill","#f0f0f0")});const Vt=Lt.append("g").attr("transform",`translate(${ut},${vt+2})`).style("cursor","pointer");Vt.append("rect").attr("x",0).attr("y",0).attr("width",wt).attr("height",wt).attr("rx",4).attr("fill","#f0f0f0").attr("stroke","#ccc").attr("stroke-width",1),Vt.append("path").attr("d",`M${wt/2-5},${wt/2-2} L${wt/2},${wt/2+4} L${wt/2+5},${wt/2-2}`).attr("fill","none").attr("stroke","#555").attr("stroke-width",2).attr("stroke-linecap","round"),Vt.on("mouseover",function(){Vt.select("rect").attr("fill","#e0e0e0")}),Vt.on("mouseout",function(){Vt.select("rect").attr("fill","#f0f0f0")}),$t.on("click",()=>{$>0&&($--,V($,!0),$t.style("opacity",$===0?"0.3":"1"),Vt.style("opacity",$>=J-1?"0.3":"1"))}),Vt.on("click",()=>{$<J-1&&($++,V($,!0),$t.style("opacity",$===0?"0.3":"1"),Vt.style("opacity",$>=J-1?"0.3":"1"))})}}else r==="horizontal"?(G=M+o,H=k+y+o):(G=m||M+o||150,H=k+y+o);if(K&&(G=Math.max(G,B+D+o),H=Math.max(H,N+z+o)),this.contentHeight=H,this.config.backgroundColor||this.config.borderWidth||this.config.shadow){const W=this.group.insert("rect",":first-child").attr("class","katucharts-legend-bg").attr("x",0).attr("y",0).attr("width",G).attr("height",g?Math.min(H,g):H).attr("rx",this.config.borderRadius??0).attr("fill",this.config.backgroundColor||"none").attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0);this.config.shadow&&W.attr("filter","drop-shadow(2px 2px 4px rgba(0,0,0,0.15))")}if(g&&H>g){this.visibleHeight=g;const W=`katucharts-legend-clip-${Math.random().toString(36).slice(2,8)}`;this.group.append("defs").append("clipPath").attr("id",W).append("rect").attr("width",G).attr("height",g),this.group.attr("clip-path",`url(#${W})`),((at=this.config.navigation)==null?void 0:at.enabled)!==!1&&this.renderNavigationArrows(G,g)}const j=this.config.maxWidth?Math.min(G,this.config.maxWidth):G,U=this.config.align||"center",X=r==="vertical"&&(U==="left"||U==="right");let tt;X?tt=e.x+2:U==="center"?tt=e.x+(e.width-j)/2:U==="right"?tt=e.x+e.width-j:tt=e.x;let O=e.y+(this.config.y||0);(X||this.config.verticalAlign==="middle")&&(O=e.y+Math.max(0,(e.height-H)/2)+(this.config.y||0));const it=tt+(this.config.x||0);this.group.attr("transform",`translate(${it},${O})`),this.config.floating&&this.group.style("pointer-events","all")}renderNavigationArrows(t,e){const i=this.config.navigation||{},r=i.activeColor||"#003399",o=i.inactiveColor||"#cccccc",s=i.arrowSize??12,a=this.group.append("g").attr("class","katucharts-legend-nav-up").attr("transform",`translate(${t/2},2)`).style("cursor","pointer");a.append("path").attr("d",`M${-s/2},${s/2} L0,${-s/2} L${s/2},${s/2}`).attr("fill",this.scrollOffset>0?r:o).attr("stroke","none"),a.on("click",()=>{this.scrollOffset>0&&(this.scrollOffset=Math.max(0,this.scrollOffset-40),this.applyScroll())});const c=this.group.append("g").attr("class","katucharts-legend-nav-down").attr("transform",`translate(${t/2},${e-2})`).style("cursor","pointer");c.append("path").attr("d",`M${-s/2},${-s/2} L0,${s/2} L${s/2},${-s/2}`).attr("fill",this.contentHeight>e+this.scrollOffset?r:o).attr("stroke","none"),c.on("click",()=>{const l=this.contentHeight-this.visibleHeight;this.scrollOffset<l&&(this.scrollOffset=Math.min(l,this.scrollOffset+40),this.applyScroll())})}applyScroll(){const t=this.scrollOffset;this.group.selectAll(".katucharts-legend-item").each(function(){const e=this,r=(e.getAttribute("transform")||"").match(/translate\(([^,]+),([^)]+)\)/);if(r){const o=parseFloat(e.getAttribute("data-orig-y")||r[2]);e.hasAttribute("data-orig-y")||e.setAttribute("data-orig-y",r[2]),e.setAttribute("transform",`translate(${r[1]},${o-t})`)}})}renderBubbleLegend(t,e,i){var v,k,M,C,E,_;const r=this.config.bubbleLegend||{};if(r.layout==="separate")return this.renderBubbleLegendSeparate(t,e,i);const o=[...t.ranges].sort((T,I)=>I.radius-T.radius),s=o[0].radius;if(!(s>0))return{width:0,height:0};const a=((k=(v=r.labels)==null?void 0:v.style)==null?void 0:k.fontSize)||kt,c=r.borderColor||t.color,l=r.borderWidth??1.5,h=r.color||"rgba(0,0,0,0)",f=r.connectorColor||c,u=r.connectorWidth??1,d=r.connectorDistance??16,p=((C=(M=r.labels)==null?void 0:M.style)==null?void 0:C.color)||Fe,y=this.group.append("g").attr("class","katucharts-bubble-legend"),g=e+s,m=i+2*s,b=e+2*s+d;let x=0;for(const T of o){const I=m-2*T.radius;y.append("circle").attr("cx",g).attr("cy",m-T.radius).attr("r",T.radius).attr("fill",h).attr("stroke",c).attr("stroke-width",l),y.append("line").attr("x1",g).attr("y1",I).attr("x2",b).attr("y2",I).attr("stroke",f).attr("stroke-width",u).attr("stroke-dasharray","2,2");let L;(E=r.labels)!=null&&E.formatter?L=r.labels.formatter.call({value:T.value}):(_=r.labels)!=null&&_.format?L=re(Zt(r.labels.format,{value:T.value})):L=String(T.value),y.append("text").attr("x",b+4).attr("y",I).attr("dominant-baseline","middle").attr("font-size",a).attr("fill",p).text(L),x=Math.max(x,this.estimateTextWidth(L,a))}return{width:2*s+d+x+8,height:2*s}}renderBubbleLegendSeparate(t,e,i){var M,C,E,_;const r=this.config.bubbleLegend||{},o=[...t.ranges].sort((T,I)=>T.radius-I.radius),s=o[o.length-1].radius;if(!(s>0))return{width:0,height:0};const a=((C=(M=r.labels)==null?void 0:M.style)==null?void 0:C.fontSize)||kt,c=parseFloat(a)||12,l=r.borderColor||t.color,h=r.borderWidth??1.5,f=r.color||"rgba(0,0,0,0)",u=((_=(E=r.labels)==null?void 0:E.style)==null?void 0:_.color)||Fe,d=r.connectorDistance??8,p=T=>{var I,L;return(I=r.labels)!=null&&I.formatter?r.labels.formatter.call({value:T}):(L=r.labels)!=null&&L.format?re(Zt(r.labels.format,{value:T})):String(T)},y=this.group.append("g").attr("class","katucharts-bubble-legend"),g=(T,I,L)=>y.append("circle").attr("cx",T).attr("cy",I).attr("r",L).attr("fill",f).attr("stroke",l).attr("stroke-width",h);if(this.config.layout==="horizontal"){const T=c+6,I=i+T+2*s;let L=e;for(const P of o){const A=L+P.radius,w=I-2*P.radius;g(A,I-P.radius,P.radius);const S=p(P.value);y.append("text").attr("x",A).attr("y",w-4).attr("text-anchor","middle").attr("font-size",a).attr("fill",u).text(S);const $=Math.max(2*P.radius,this.estimateTextWidth(S,a));L+=$+d+6}return{width:Math.max(0,L-e-(d+6)),height:T+2*s}}const m=e+s,b=e+2*s+d;let x=i,v=0;const k=10;for(const T of o){const I=x+T.radius;g(m,I,T.radius);const L=p(T.value);y.append("text").attr("x",b).attr("y",I).attr("dominant-baseline","middle").attr("font-size",a).attr("fill",u).text(L),v=Math.max(v,this.estimateTextWidth(L,a)),x+=2*T.radius+k}return{width:2*s+d+v+8,height:Math.max(0,x-i-k)}}destroy(){this.group&&this.group.remove()}}class df{constructor(t,e,i,r,o){var h,f;if(this.xLine=null,this.yLine=null,this.xLabel=null,this.yLabel=null,this.plotArea=r,t){const u=typeof t=="object"?t:{},d=this.getDashArray(u.dashStyle);this.xLine=i.append("line").attr("class",`katucharts-crosshair-x${u.className?" "+u.className:""}`).attr("y1",0).attr("y2",r.height).attr("stroke",u.color||"#ccc").attr("stroke-width",u.width||1).attr("stroke-dasharray",d).style("display","none"),u.zIndex!==void 0&&this.xLine.style("z-index",u.zIndex),(h=u.label)!=null&&h.enabled&&(this.xLabel=this.createLabel(i,u.label,"x"))}if(e){const u=typeof e=="object"?e:{},d=this.getDashArray(u.dashStyle);this.yLine=i.append("line").attr("class",`katucharts-crosshair-y${u.className?" "+u.className:""}`).attr("x1",0).attr("x2",r.width).attr("stroke",u.color||"#ccc").attr("stroke-width",u.width||1).attr("stroke-dasharray",d).style("display","none"),u.zIndex!==void 0&&this.yLine.style("z-index",u.zIndex),(f=u.label)!=null&&f.enabled&&(this.yLabel=this.createLabel(i,u.label,"y"))}const s=typeof t=="object"?t:{},a=typeof e=="object"?e:{},c=s.snap!==!1,l=a.snap!==!1;o.on("point:mouseover",u=>{var d,p,y,g;if(this.xLine){const m=c?u.plotX:((d=u.event)==null?void 0:d.offsetX)??u.plotX;this.xLine.attr("x1",m).attr("x2",m).style("display",null),this.xLabel&&this.updateLabel(this.xLabel,s.label,((p=u.point)==null?void 0:p.x)??u.plotX,m,r.height+2,"x")}if(this.yLine){const m=l?u.plotY:((y=u.event)==null?void 0:y.offsetY)??u.plotY;this.yLine.attr("y1",m).attr("y2",m).style("display",null),this.yLabel&&this.updateLabel(this.yLabel,a.label,((g=u.point)==null?void 0:g.y)??u.plotY,-2,m,"y")}}),o.on("point:mouseout",()=>{this.xLine&&this.xLine.style("display","none"),this.yLine&&this.yLine.style("display","none"),this.xLabel&&this.xLabel.style("display","none"),this.yLabel&&this.yLabel.style("display","none")})}getDashArray(t){return t&&{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t]||"none"}createLabel(t,e,i){var o,s;const r=t.append("g").attr("class",`katucharts-crosshair-label-${i}`).style("display","none");return r.append("rect").attr("rx",e.borderRadius??3).attr("fill",e.backgroundColor||"rgba(0,0,0,0.75)").attr("stroke",e.borderColor||"none").attr("stroke-width",e.borderWidth??0),r.append("text").attr("fill",((o=e.style)==null?void 0:o.color)||"#fff").attr("font-size",((s=e.style)==null?void 0:s.fontSize)||"10px").attr("text-anchor","middle").attr("dominant-baseline","central"),r}updateLabel(t,e,i,r,o,s){var f;t.style("display",null);let a;e.formatter?a=e.formatter.call({value:i}):e.format?a=e.format.replace("{value}",String(i)):a=typeof i=="number"?i.toFixed(2):String(i);const c=e.padding??4,l=t.select("text");l.text(a).attr("x",r).attr("y",o);const h=(f=l.node())==null?void 0:f.getBBox();h&&t.select("rect").attr("x",h.x-c).attr("y",h.y-c).attr("width",h.width+c*2).attr("height",h.height+c*2)}destroy(){this.xLine&&this.xLine.remove(),this.yLine&&this.yLine.remove(),this.xLabel&&this.xLabel.remove(),this.yLabel&&this.yLabel.remove()}}const pf="Powered by: KatuCharts",Dv="https://charts.katudv.com",gf="#707070",zv="#b0b0b0";function Bv(n){return gn(n)==="#ffffff"?zv:gf}class Ov{constructor(t,e,i,r){this.element=null,this.observer=null,this.intervalId=null,this.unsubscribe=null,this.svg=e,this.chartWidth=i,this.chartHeight=r,this.config=t,this.apply(),this.unsubscribe=tn.onChange(()=>this.apply())}apply(){const t=tn.isLicensed();if(this.config.enabled===!1&&t){this.stopProtection(),this.element&&(this.element.remove(),this.element=null);return}this.render(this.config),t?this.stopProtection():this.startProtection()}updatePosition(t,e){this.chartWidth=t,this.chartHeight=e,!(this.config.enabled===!1&&tn.isLicensed())&&this.render(this.config)}render(t){var u,d;this.element&&(this.element.remove(),this.element=null);const i=!tn.isLicensed()&&(!(t!=null&&t.text)||!t.text.trim())?pf:(t==null?void 0:t.text)||pf,r=(t==null?void 0:t.href)??Dv,o=(t==null?void 0:t.position)||{},s=o.align||"right",a=o.verticalAlign||"bottom";let c,l;s==="left"?(c=o.x??10,l="start"):s==="center"?(c=this.chartWidth/2+(o.x??0),l="middle"):(c=this.chartWidth+(o.x??-10),l="end");let h;a==="top"?h=o.y??15:a==="middle"?h=this.chartHeight/2+(o.y??0):h=this.chartHeight+(o.y??-5);const f=(u=t==null?void 0:t.style)==null?void 0:u.color;if(this.element=this.svg.append("text").attr("class","katucharts-credits").attr("x",c).attr("y",h).attr("text-anchor",l).attr("fill",f||gf).attr("font-size",((d=t==null?void 0:t.style)==null?void 0:d.fontSize)||"9px").style("cursor",r?"pointer":"default").text(i),t!=null&&t.style){const p=t.style;p.fontFamily&&this.element.attr("font-family",p.fontFamily),p.fontWeight&&this.element.attr("font-weight",p.fontWeight),p.textDecoration&&this.element.style("text-decoration",p.textDecoration)}if(!f){const p=this.resolveBehindColor()||this.resolvePageBackground();this.element.attr("fill",Bv(p))}r&&this.element.on("click",()=>{/^https?:\/\//i.test(r)&&window.open(r,"_blank","noopener,noreferrer")})}refresh(){this.config.enabled===!1&&tn.isLicensed()||this.render(this.config)}resolveBehindColor(){var t;try{const e=(t=this.element)==null?void 0:t.node(),i=this.svg.node();if(!e||!i)return null;const r=e.getBoundingClientRect();if(!r.width||!r.height)return null;const o=r.left+r.width/2,s=r.top+r.height/2;let a=null;return i.querySelectorAll("rect, path, circle, polygon, ellipse").forEach(c=>{const l=c.getAttribute("class")||"";if(/katucharts-(credits|export|border)/.test(l))return;const h=this.elementFill(c);if(!h)return;const f=c.getBoundingClientRect();o>=f.left&&o<=f.right&&s>=f.top&&s<=f.bottom&&(a=h)}),a}catch{return null}}resolvePageBackground(){try{let t=this.svg.node();for(;t;){if(typeof getComputedStyle=="function"){const e=getComputedStyle(t).backgroundColor,i=e?le(e):null;if(i&&i.opacity>0)return e}t=t.parentElement}}catch{}return"#ffffff"}elementFill(t){var o;const e=t.tagName.toLowerCase();if(e==="text"||e==="tspan")return null;let i=t.getAttribute("fill");if(!i||i==="none"){const s=(o=t.style)==null?void 0:o.fill;i=s&&s!=="none"?s:null}if(!i||i==="none"||i.indexOf("url(")===0)return null;const r=le(i);return!r||r.opacity===0?null:i}startProtection(){if(tn.isLicensed()||this.observer||this.intervalId!=null||typeof MutationObserver>"u")return;const t=this.svg.node();t&&(this.observer=new MutationObserver(()=>{t.querySelector(".katucharts-credits")||this.render()}),this.observer.observe(t,{childList:!0}),typeof window<"u"&&(this.intervalId=window.setInterval(()=>{t.querySelector(".katucharts-credits")||this.render()},3e3)))}stopProtection(){var t;(t=this.observer)==null||t.disconnect(),this.observer=null,this.intervalId!=null&&(clearInterval(this.intervalId),this.intervalId=null)}destroy(){var t;(t=this.unsubscribe)==null||t.call(this),this.unsubscribe=null,this.stopProtection(),this.element&&this.element.remove(),this.element=null}}const Vi=["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5"],Nv={downloadPNG:Vi,downloadJPEG:Vi,downloadSVG:Vi,downloadPDF:Vi,downloadCSV:Vi,downloadXLS:Vi,viewDataTable:["M3 3h18v18H3z","M12 3v18","M3 9h18","M3 15h18"],viewFullScreen:["M8 3H5a2 2 0 0 0-2 2v3","M21 8V5a2 2 0 0 0-2-2h-3","M3 16v3a2 2 0 0 0 2 2h3","M16 21h3a2 2 0 0 0 2-2v-3"],printChart:["M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2","M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6","M6 14h12v8H6z"]},Wv={downloadPNG:"PNG",downloadJPEG:"JPG",downloadSVG:"SVG",downloadPDF:"PDF",downloadCSV:"CSV",downloadXLS:"XLS"},Hv={downloadPNG:"Download PNG",downloadJPEG:"Download JPEG",downloadSVG:"Download SVG",downloadPDF:"Download PDF",downloadCSV:"Download CSV",downloadXLS:"Download XLS",viewDataTable:"Data table",viewFullScreen:"Fullscreen",printChart:"Print"};class mf{constructor(t,e,i,r,o,s){var v;this.group=null,this.gearGroup=null,this.radialContainer=null,this.isOpen=!1,this.outsideClickHandler=null,this.scrollHandler=null,this.btnCenterX=0,this.btnCenterY=0,this.config=t,this.container=i,this.chartWidth=r,this.chartHeight=o,this.onExport=s;const a=(v=t.buttons)==null?void 0:v.contextButton;if((a==null?void 0:a.enabled)===!1)return;const c=(a==null?void 0:a.theme)||{},l=c.width??28,h=c.height??22,f=r+((a==null?void 0:a.x)??-10)-l,u=(a==null?void 0:a.y)??10,d=(a==null?void 0:a.symbolStroke)??"#666666",p=(a==null?void 0:a.symbolStrokeWidth)??3,y=(a==null?void 0:a.symbolFill)??d,g=c.fill??"transparent",m=c.stroke??"none",b=c.r??3;c["states.hover.fill"],this.btnCenterX=f+l/2,this.btnCenterY=u+h/2,this.group=e.append("g").attr("class","katucharts-export-button-group").attr("transform",`translate(${f},${u})`).style("cursor","pointer"),this.group.append("rect").attr("class","katucharts-export-btn-bg").attr("width",l).attr("height",h).attr("rx",b).attr("fill",g).attr("stroke",m),c.padding!==void 0&&this.group.select(".katucharts-export-btn-bg").attr("x",-c.padding).attr("y",-c.padding).attr("width",l+c.padding*2).attr("height",h+c.padding*2);const x=a==null?void 0:a.symbol;if(this.gearGroup=this.group.append("g").attr("class","katucharts-gear-icon").style("transform-origin",`${l/2}px ${h/2}px`).style("transition","transform 0.4s cubic-bezier(0.4, 0, 0.2, 1)"),x==="circle")this.gearGroup.append("circle").attr("cx",l/2).attr("cy",h/2).attr("r",Math.min(l,h)/3).attr("fill",y).attr("stroke",d).attr("stroke-width",p);else if(x==="menu"){const k=Math.round(l*.21),M=Math.round(l*.79);for(let C=0;C<3;C++)this.gearGroup.append("line").attr("x1",k).attr("x2",M).attr("y1",Math.round(h*.27)+C*Math.round(h*.23)).attr("y2",Math.round(h*.27)+C*Math.round(h*.23)).attr("stroke",d).attr("stroke-width",p).attr("stroke-linecap","round")}else{const k=Math.min(l,h),M=l/2,C=h/2,E=8,_=k*.44,T=k*.3,I=k*.12,L=Math.PI/(E*1.6);let P="";for(let F=0;F<E;F++){const D=F/E*Math.PI*2-Math.PI/2,z=[[T,D-L*1.2],[_+I,D-L],[_+I,D+L],[T,D+L*1.2]];for(const[B,N]of z){const K=M+Math.cos(N)*B,V=C+Math.sin(N)*B;P+=(P===""?"M":"L")+K.toFixed(2)+","+V.toFixed(2)}}P+="Z";const A=e.select("defs").empty()?e.append("defs"):e.select("defs"),w=A.append("linearGradient").attr("id","katu-gear-glass").attr("x1","0").attr("y1","0").attr("x2","1").attr("y2","1");w.append("stop").attr("offset","0%").attr("stop-color","#aaa").attr("stop-opacity","0.7"),w.append("stop").attr("offset","45%").attr("stop-color","#999").attr("stop-opacity","0.45"),w.append("stop").attr("offset","100%").attr("stop-color","#888").attr("stop-opacity","0.35");const S=A.append("radialGradient").attr("id","katu-gear-highlight").attr("cx","0.35").attr("cy","0.3").attr("r","0.65");S.append("stop").attr("offset","0%").attr("stop-color","#fff").attr("stop-opacity","0.6"),S.append("stop").attr("offset","50%").attr("stop-color","#fff").attr("stop-opacity","0.1"),S.append("stop").attr("offset","100%").attr("stop-color","#fff").attr("stop-opacity","0"),this.gearGroup.append("path").attr("d",P).attr("fill","url(#katu-gear-glass)").attr("stroke","rgba(255,255,255,0.5)").attr("stroke-width",p*.4).attr("stroke-linejoin","round").style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.15))"),this.gearGroup.append("path").attr("d",P).attr("fill","url(#katu-gear-highlight)").attr("stroke","none").style("pointer-events","none"),this.gearGroup.append("circle").attr("cx",M).attr("cy",C).attr("r",k*.15).attr("fill","rgba(255,255,255,0.6)").attr("stroke","rgba(255,255,255,0.4)").attr("stroke-width","0.5");const $=A.append("radialGradient").attr("id","katu-gear-hover-bg").attr("cx","0.4").attr("cy","0.35").attr("r","0.65");$.append("stop").attr("offset","0%").attr("stop-color","#fff").attr("stop-opacity","0.35"),$.append("stop").attr("offset","50%").attr("stop-color","#eef2ff").attr("stop-opacity","0.15"),$.append("stop").attr("offset","100%").attr("stop-color","#dde6ff").attr("stop-opacity","0.08");const R=k*.85;this.group.insert("circle",".katucharts-gear-icon").attr("class","katucharts-gear-hover-bg").attr("cx",l/2).attr("cy",h/2).attr("r",R).attr("fill","url(#katu-gear-hover-bg)").attr("stroke","rgba(255,255,255,0.6)").attr("stroke-width","1.5").style("filter","drop-shadow(0 0 10px rgba(200,225,255,0.5)) drop-shadow(0 2px 6px rgba(0,0,0,0.08))").style("opacity","0").style("transition","opacity 0.25s ease"),this.group.insert("circle",".katucharts-gear-icon").attr("class","katucharts-gear-hover-highlight").attr("cx",l/2).attr("cy",h/2).attr("r",R).attr("fill","none").attr("stroke","rgba(255,255,255,0.8)").attr("stroke-width","1.5").style("filter","drop-shadow(0 0 4px rgba(255,255,255,0.4))").style("opacity","0").style("transition","opacity 0.25s ease")}this.group.on("mouseenter",()=>{this.group.select(".katucharts-gear-hover-bg").style("opacity","1"),this.group.select(".katucharts-gear-hover-highlight").style("opacity","1")}).on("mouseleave",()=>{this.group.select(".katucharts-gear-hover-bg").style("opacity","0"),this.group.select(".katucharts-gear-hover-highlight").style("opacity","0")}).on("click",k=>{k.stopPropagation(),this.toggle()})}toggle(){this.isOpen?this.closeMenu():this.openMenu()}repositionCenter(t,e){this.btnCenterX=t,this.btnCenterY=e}openMenu(){var I;this.isOpen=!0,this.gearGroup&&this.gearGroup.style("transform","rotate(90deg)");const t=(I=this.config.buttons)==null?void 0:I.contextButton,i=((t==null?void 0:t.menuItems)??["downloadPNG","downloadJPEG","downloadSVG","downloadPDF","separator","viewFullScreen","printChart"]).filter(L=>L!=="separator").map(L=>({key:L,label:Hv[L]||L,icon:Nv[L]||[]}));this.radialContainer=document.createElement("div"),Object.assign(this.radialContainer.style,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",pointerEvents:"none",zIndex:"1000"});const r=64,o=document.createElement("canvas");o.width=r,o.height=r;const s=o.getContext("2d"),a=s.createImageData(r,r),c=a.data;let l=0;const h=[];for(let L=0;L<c.length;L+=4){const P=L/4%r,A=Math.floor(L/4/r),w=P/r-.5,S=A/r-.5,$=Math.sqrt(w*w+S*S),R=Math.max(0,Math.min(1,(.48-$)/.15)),F=R*R*(3-2*R),D=w*F*r,z=S*F*r;l=Math.max(l,Math.abs(D),Math.abs(z)),h.push(D,z)}l*=.5;let f=0;for(let L=0;L<c.length;L+=4)c[L]=(h[f++]/l+.5)*255,c[L+1]=(h[f++]/l+.5)*255,c[L+2]=0,c[L+3]=255;s.putImageData(a,0,0);const u=o.toDataURL(),d="http://www.w3.org/2000/svg",p=document.createElementNS(d,"svg");p.setAttribute("width","0"),p.setAttribute("height","0"),p.style.position="absolute";const y=document.createElementNS(d,"defs"),g=document.createElementNS(d,"filter");g.setAttribute("id","katu-glass-lens"),g.setAttribute("filterUnits","userSpaceOnUse"),g.setAttribute("color-interpolation-filters","sRGB"),g.setAttribute("x","0"),g.setAttribute("y","0"),g.setAttribute("width","44"),g.setAttribute("height","44");const m=document.createElementNS(d,"feImage");m.setAttributeNS("http://www.w3.org/1999/xlink","href",u),m.setAttribute("width","44"),m.setAttribute("height","44"),m.setAttribute("result","lens_map");const b=document.createElementNS(d,"feDisplacementMap");b.setAttribute("in","SourceGraphic"),b.setAttribute("in2","lens_map"),b.setAttribute("scale",String(Math.round(l/1))),b.setAttribute("xChannelSelector","R"),b.setAttribute("yChannelSelector","G"),g.appendChild(m),g.appendChild(b),y.appendChild(g),p.appendChild(y),this.radialContainer.appendChild(p),document.body.appendChild(this.radialContainer);const x=this.container.getBoundingClientRect(),v=x.left+this.btnCenterX,k=x.top+this.btnCenterY,M=76,C=i.length,E=100*(Math.PI/180),_=280*(Math.PI/180),T=this.config.menuItemDefinitions||{};i.forEach((L,P)=>{const A=C>1?E+(_-E)*(P/(C-1)):Math.PI,w=v+Math.cos(A)*M,S=k+Math.sin(A)*M,$=w-v,R=S-k,F=document.createElement("div");F.className="katucharts-radial-btn",Object.assign(F.style,{position:"absolute",left:`${v}px`,top:`${k}px`,width:"44px",height:"44px",marginLeft:"-22px",marginTop:"-22px",borderRadius:"50%",background:"linear-gradient(160deg, rgba(255,255,255,0.92) 0%, rgba(240,240,255,0.82) 40%, rgba(255,255,255,0.75) 100%)",backdropFilter:"url(#katu-glass-lens) blur(0.5px) contrast(1.15) brightness(1.05) saturate(1.2)",WebkitBackdropFilter:"url(#katu-glass-lens) blur(0.5px) contrast(1.15) brightness(1.05) saturate(1.2)",border:"1.5px solid rgba(255, 255, 255, 0.4)",borderTopColor:"rgba(255, 255, 255, 0.8)",borderLeftColor:"rgba(255, 255, 255, 0.55)",borderBottomColor:"rgba(0, 0, 0, 0.04)",borderRightColor:"rgba(0, 0, 0, 0.02)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",pointerEvents:"auto",transform:"translate(0px, 0px) scale(0.3)",opacity:"0",willChange:"transform, opacity",transition:`transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) ${P*40}ms, opacity 0.2s ease ${P*40}ms, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease`,boxShadow:"0 4px 8px rgba(0,0,0,0.2), inset 0 -6px 12px rgba(0,0,0,0.1), inset 0 2px 4px rgba(255,255,255,0.4)"}),F.dataset.dx=String($),F.dataset.dy=String(R);const D=document.createElement("div");Object.assign(D.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",borderRadius:"50%",background:"radial-gradient(ellipse 70% 50% at 35% 25%, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0) 70%), radial-gradient(ellipse 60% 40% at 70% 80%, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 70%)",boxShadow:"inset 1.5px 1.5px 3px rgba(255,255,255,0.5), inset -0.5px -0.5px 2px rgba(0,0,0,0.06)",pointerEvents:"none",overflow:"hidden"}),F.appendChild(D);const z=document.createElementNS("http://www.w3.org/2000/svg","svg");z.setAttribute("viewBox","0 0 24 24"),z.setAttribute("width","30"),z.setAttribute("height","30"),z.style.overflow="visible",z.style.position="relative",z.style.zIndex="1";const B=[],N=[];for(const X of L.icon){const tt=document.createElementNS("http://www.w3.org/2000/svg","path");tt.setAttribute("d",X),tt.setAttribute("fill","none"),tt.setAttribute("stroke","#333333"),tt.setAttribute("stroke-width","2"),tt.setAttribute("stroke-linecap","round"),tt.setAttribute("stroke-linejoin","round"),z.appendChild(tt),B.push(tt)}const K=Wv[L.key];if(K){const X=document.createElementNS("http://www.w3.org/2000/svg","text");X.setAttribute("x","12"),X.setAttribute("y","16.5"),X.setAttribute("text-anchor","middle"),X.setAttribute("font-size","5.5"),X.setAttribute("font-family",'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'),X.setAttribute("font-weight","700"),X.setAttribute("fill","#333333"),X.setAttribute("stroke","none"),X.textContent=K,z.appendChild(X),N.push(X)}F.appendChild(z);const V=document.createElement("div");V.textContent=L.label;const G=A*(180/Math.PI),H={position:"absolute",backgroundColor:"rgba(30, 30, 30, 0.45)",backdropFilter:"blur(20px) saturate(1.4)",WebkitBackdropFilter:"blur(20px) saturate(1.4)",color:"#ffffff",padding:"4px 10px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.12)",fontSize:"11px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',fontWeight:"500",letterSpacing:"0.2px",boxShadow:"0 2px 12px rgba(0,0,0,0.12), inset 0 0.5px 0 rgba(255,255,255,0.1)",whiteSpace:"nowrap",pointerEvents:"none",opacity:"0",transition:"opacity 0.15s ease, transform 0.15s ease"};G>60&&G<120?(H.top="calc(100% + 6px)",H.left="50%",H.transform="translateX(-50%) scale(0.8)"):G>=120&&G<=240?(H.right="calc(100% + 6px)",H.top="50%",H.transform="translateY(-50%) scale(0.8)"):G>240&&G<300?(H.bottom="calc(100% + 6px)",H.left="50%",H.transform="translateX(-50%) scale(0.8)"):(H.left="calc(100% + 6px)",H.top="50%",H.transform="translateY(-50%) scale(0.8)"),Object.assign(V.style,H),F.appendChild(V);const j=H.transform.replace("scale(0.8)","scale(1)"),U=H.transform;F.addEventListener("mouseenter",()=>{F.style.background="linear-gradient(160deg, rgba(210,230,255,0.9) 0%, rgba(200,225,255,0.8) 40%, rgba(195,220,255,0.72) 100%)",F.style.borderColor="rgba(210, 230, 255, 0.85)",F.style.boxShadow="0 0 20px rgba(200,225,255,0.7), 0 0 8px rgba(200,225,255,0.5), 0 4px 12px rgba(0,0,0,0.06), 0 0 0 1px rgba(210,230,255,0.35), inset 0 2px 4px rgba(255,255,255,0.6), inset 0 -1px 2px rgba(0,0,0,0.02)",B.forEach(X=>X.setAttribute("stroke","#1a4a8a")),N.forEach(X=>X.setAttribute("fill","#1a4a8a")),V.style.opacity="1",V.style.transform=j}),F.addEventListener("mouseleave",()=>{F.style.background="linear-gradient(160deg, rgba(255,255,255,0.72) 0%, rgba(240,240,255,0.45) 40%, rgba(255,255,255,0.35) 100%)",F.style.borderColor="rgba(255, 255, 255, 0.4)",F.style.boxShadow="0 4px 8px rgba(0,0,0,0.2), inset 0 -6px 12px rgba(0,0,0,0.1), inset 0 2px 4px rgba(255,255,255,0.4)",B.forEach(X=>X.setAttribute("stroke","#333333")),N.forEach(X=>X.setAttribute("fill","#333333")),V.style.opacity="0",V.style.transform=U}),F.addEventListener("click",X=>{X.stopPropagation(),this.closeMenu();const tt=T[L.key];tt!=null&&tt.onclick?tt.onclick():this.onExport(L.key)}),this.radialContainer.appendChild(F),requestAnimationFrame(()=>{requestAnimationFrame(()=>{F.style.transform=`translate(${$}px, ${R}px) scale(1)`,F.style.opacity="1"})})}),this.outsideClickHandler=L=>{this.radialContainer&&!this.radialContainer.contains(L.target)&&this.closeMenu()},setTimeout(()=>{document.addEventListener("click",this.outsideClickHandler)},0),this.scrollHandler=()=>this.closeMenu(),window.addEventListener("scroll",this.scrollHandler,{once:!0,capture:!0})}closeMenu(){if(this.isOpen=!1,this.gearGroup&&this.gearGroup.style("transform","rotate(0deg)"),this.radialContainer){this.btnCenterX,this.btnCenterY,this.radialContainer.querySelectorAll(".katucharts-radial-btn").forEach((i,r)=>{i.style.transition=`transform 0.25s cubic-bezier(0.4, 0, 1, 1) ${r*20}ms, opacity 0.2s ease ${r*20}ms`,i.style.transform="translate(0px, 0px) scale(0.3)",i.style.opacity="0"});const e=this.radialContainer;setTimeout(()=>{e.remove()},400),this.radialContainer=null}this.outsideClickHandler&&(document.removeEventListener("click",this.outsideClickHandler),this.outsideClickHandler=null),this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler,!0),this.scrollHandler=null)}updatePosition(t,e){var l;if(this.chartWidth=t,this.chartHeight=e,!this.group)return;const i=(l=this.config.buttons)==null?void 0:l.contextButton,r=(i==null?void 0:i.theme)||{},o=r.width??28,s=r.height??22,a=t+((i==null?void 0:i.x)??-10)-o,c=(i==null?void 0:i.y)??10;this.group.attr("transform",`translate(${a},${c})`),this.btnCenterX=a+o/2,this.btnCenterY=c+s/2,this.isOpen&&this.closeMenu()}destroy(){this.closeMenu(),this.group&&(this.group.remove(),this.group=null)}}class yf{constructor(t){this.activeIndices=new Set,this.rules=t.rules||[]}evaluate(t,e){const i=new Set;for(let o=0;o<this.rules.length;o++)this.matchesCondition(this.rules[o].condition,t,e)&&i.add(o);const r=!this.setsEqual(i,this.activeIndices);return this.activeIndices=i,{changed:r,matchingIndices:Array.from(i)}}getRules(){return this.rules}getCurrentActiveIndices(){return Array.from(this.activeIndices)}reset(){this.activeIndices.clear()}setsEqual(t,e){if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0}matchesCondition(t,e,i){return t.callback?t.callback():!(t.maxWidth!==void 0&&e>t.maxWidth||t.minWidth!==void 0&&e<t.minWidth||t.maxHeight!==void 0&&i>t.maxHeight||t.minHeight!==void 0&&i<t.minHeight)}}function as(n){return`${n._internalType}__${n.stack??"_default"}`}function Vv(n,t){for(const e of n){const i=e.x??0;t.set(i,(t.get(i)||0)+(e.y??0))}return t}function _r(n,t,e){for(const i of n){const r=i.x??0,o=i.y??0;o<0?e.set(r,(e.get(r)||0)+o):t.set(r,(t.get(r)||0)+o)}}function Gv(n,t,e){return(t.get(n)||0)+Math.abs(e.get(n)||0)}function xf(n,t){return t==="left"?n.layout.titleArea.x:t==="right"?n.layout.titleArea.x+n.layout.titleArea.width:n.chartWidth/2}function bf(n){return n==="left"?"start":n==="right"?"end":"middle"}function vf(n,t,e,i){const r=n.node();if(!r||t<=0)return;try{if(r.getComputedTextLength()<=t)return}catch{return}const s=n.text().split(/\s+/);if(s.length<=1)return;const a=i*1.3;n.text(null);let c=[],l=n.append("tspan").attr("x",e).attr("dy",0);for(const h of s){c.push(h),l.text(c.join(" "));try{l.node().getComputedTextLength()>t&&c.length>1&&(c.pop(),l.text(c.join(" ")),c=[h],l=n.append("tspan").attr("x",e).attr("dy",a).text(h))}catch{break}}}function Yv(n){var s,a,c,l,h,f,u,d,p,y,g,m,b;const{titleGroup:t,container:e,options:i,layout:r,chartWidth:o}=n;if(t.selectAll("*").remove(),e.querySelectorAll(".katucharts-title-html, .katucharts-subtitle-html, .katucharts-caption-html").forEach(x=>x.remove()),(s=i.title)!=null&&s.text){const x=i.title,v=((a=x.style)==null?void 0:a.fontSize)||"18px";if(x.useHTML){const k=document.createElement("div");k.className="katucharts-title-html",k.innerHTML=x.text,k.style.cssText=`position:absolute;top:${r.titleArea.y+5}px;left:0;width:100%;text-align:${x.align||"center"};color:${((c=x.style)==null?void 0:c.color)||"#333333"};font-size:${v};font-weight:${((l=x.style)==null?void 0:l.fontWeight)||"bold"};pointer-events:none;box-sizing:border-box;padding:0 22px;`,e.appendChild(k)}else{const k=xf(n,x.align),M=o+(x.widthAdjust??-44),C=t.append("text").attr("class","katucharts-chart-title").attr("x",k).attr("y",r.titleArea.y+20).attr("text-anchor",bf(x.align)).attr("fill",((h=x.style)==null?void 0:h.color)||"#333333").attr("font-size",v).attr("font-weight",((f=x.style)==null?void 0:f.fontWeight)||"bold").text(x.text);vf(C,M,k,se(v))}}if((u=i.subtitle)!=null&&u.text){const x=i.subtitle,v=((d=x.style)==null?void 0:d.fontSize)||"12px";if(x.useHTML){const k=document.createElement("div");k.className="katucharts-subtitle-html",k.innerHTML=x.text,k.style.cssText=`position:absolute;top:${r.subtitleArea.y+5}px;left:0;width:100%;text-align:${x.align||"center"};color:${((p=x.style)==null?void 0:p.color)||"#666666"};font-size:${v};pointer-events:none;box-sizing:border-box;padding:0 22px;`,e.appendChild(k)}else{const k=xf(n,x.align),M=o+(x.widthAdjust??-44),C=t.append("text").attr("class","katucharts-chart-subtitle").attr("x",k).attr("y",r.subtitleArea.y+15).attr("text-anchor",bf(x.align)).attr("fill",((y=x.style)==null?void 0:y.color)||"#666666").attr("font-size",v).text(x.text);vf(C,M,k,se(v))}}if((g=i.caption)!=null&&g.text){const x=i.caption,v=((m=x.style)==null?void 0:m.fontSize)||"11px",k=document.createElement("div");k.className="katucharts-caption-html",k.innerHTML=x.text,k.style.cssText=`position:absolute;top:${r.captionArea.y}px;left:0;width:100%;text-align:${x.align||"left"};color:${((b=x.style)==null?void 0:b.color)||"#666666"};font-size:${v};line-height:1.25;box-sizing:border-box;padding:0 12px;pointer-events:none;`,e.appendChild(k)}}function Xv(n){var tt;const{container:t,renderer:e,options:i,plotGroup:r,layout:o,chartWidth:s,chartHeight:a,scrollableInner:c,scrollableOuterWidth:l,scrollableOuterHeight:h,useVerticalScroll:f,useHorizontalScroll:u,exportButton:d,previousOverlay:p}=n;if(!c)return null;const y=e.getSVGNode();if(!y)return null;const g=O=>{const it=O==null?void 0:O.querySelector(".katucharts-export-button-group");it&&y.appendChild(it)};p&&p.parentElement&&(g(p),p.parentElement.removeChild(p)),t.querySelectorAll(":scope > svg[data-katu-fixed-overlay]").forEach(O=>{var it;g(O),(it=O.parentElement)==null||it.removeChild(O)});const b="http://www.w3.org/2000/svg",x=c.offsetWidth-c.clientWidth,v=c.offsetHeight-c.clientHeight,k=l-x,M=h-v,C=document.createElementNS(b,"svg");C.setAttribute("data-katu-fixed-overlay","1"),C.setAttribute("width",k.toString()),C.setAttribute("height",M.toString()),C.style.position="absolute",C.style.top="0",C.style.left="0",C.style.pointerEvents="none",C.style.overflow="visible";const E=i.chart.backgroundColor||"#ffffff",T=(r.attr("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),I=T?parseFloat(T[1]):0,L=T?parseFloat(T[2]):0,P=!!i.chart.inverted,A=P?".katucharts-axis-y":".katucharts-axis-x",w=P?".katucharts-axis-x":".katucharts-axis-y",S=document.createElementNS(b,"defs"),$=`katucharts-fixed-grad-${Math.random().toString(36).slice(2,8)}`,R=(O,it,nt,lt,ht,at)=>{const W=document.createElementNS(b,"linearGradient");W.setAttribute("id",O),W.setAttribute("x1",it),W.setAttribute("y1",nt),W.setAttribute("x2",lt),W.setAttribute("y2",ht),at.forEach(([J,ut])=>{const vt=document.createElementNS(b,"stop");vt.setAttribute("offset",J),vt.setAttribute("stop-color",E),vt.setAttribute("stop-opacity",ut),W.appendChild(vt)}),S.appendChild(W)},F=o.titleArea,D=o.subtitleArea,z=Math.max(((F==null?void 0:F.y)??0)+((F==null?void 0:F.height)??0),((D==null?void 0:D.y)??0)+((D==null?void 0:D.height)??0)),N=Math.max(0,Math.min(z+30,L)),K=N>0?Math.max(0,Math.min(100,z/N*100)):100;if(R(`${$}-top`,"0%","0%","0%","100%",[["0%","1"],[`${K}%`,"1"],["100%","0"]]),R(`${$}-bottom`,"0%","0%","0%","100%",[["0%","0"],["30%","1"],["100%","1"]]),R(`${$}-left`,"0%","0%","100%","0%",[["0%","1"],["70%","1"],["100%","0"]]),C.appendChild(S),f&&N>0){const O=document.createElementNS(b,"rect");O.setAttribute("x","0"),O.setAttribute("y","0"),O.setAttribute("width",k.toString()),O.setAttribute("height",N.toString()),O.setAttribute("fill",`url(#${$}-top)`),C.appendChild(O)}if(y.querySelectorAll(".katucharts-title-group").forEach(O=>{O.style.visibility="hidden";const it=O.cloneNode(!0);it.style.visibility="visible";const nt=(s-k)/2;nt!==0&&it.setAttribute("transform",`translate(${-nt}, 0)`),C.appendChild(it)}),f){const O=L+o.plotArea.height,it=a-O+10,nt=document.createElementNS(b,"rect");nt.setAttribute("x","0"),nt.setAttribute("y",(M-it).toString()),nt.setAttribute("width",k.toString()),nt.setAttribute("height",it.toString()),nt.setAttribute("fill",`url(#${$}-bottom)`),C.appendChild(nt),y.querySelectorAll(A).forEach(ht=>{ht.style.visibility="hidden";const at=document.createElementNS(b,"g"),W=M-(a-O);at.setAttribute("transform",`translate(${I}, ${W})`);const J=ht.cloneNode(!0);J.removeAttribute("transform"),J.style.visibility="visible",at.appendChild(J),C.appendChild(at)})}if(u){const O=I+5,it=document.createElementNS(b,"rect");it.setAttribute("x","0"),it.setAttribute("y","0"),it.setAttribute("width",O.toString()),it.setAttribute("height",M.toString()),it.setAttribute("fill",`url(#${$}-left)`),C.appendChild(it),y.querySelectorAll(w).forEach(lt=>{lt.style.visibility="hidden";const ht=document.createElementNS(b,"g");ht.setAttribute("transform",`translate(${I}, ${L})`);const at=lt.cloneNode(!0);at.removeAttribute("transform"),at.style.visibility="visible",ht.appendChild(at),C.appendChild(ht)})}const G=((tt=o.legendArea)==null?void 0:tt.height)??0;(!f||G<=M*.3)&&y.querySelectorAll(".katucharts-legend").forEach(it=>{const lt=(it.getAttribute("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),ht=lt?parseFloat(lt[1]):0,at=lt?parseFloat(lt[2]):0,W=(s-k)/2,J=f?a-M:0,ut=ht-W,vt=at-J;it.style.visibility="hidden";const Lt=it.cloneNode(!0);Lt.style.visibility="visible",Lt.setAttribute("transform",`translate(${ut}, ${vt})`),C.appendChild(Lt)});const j=y.querySelector(".katucharts-export-button-group");if(j&&d){const it=(j.getAttribute("transform")||"").match(/translate\(([^,]+),\s*([^)]+)\)/),nt=it?parseFloat(it[1]):0,lt=it?parseFloat(it[2]):0,ht=nt-(s-k);j.setAttribute("transform",`translate(${ht},${lt})`),j.style.pointerEvents="auto",C.appendChild(j),d.repositionCenter(ht+28/2,lt+22/2)}y.querySelectorAll(".katucharts-color-axis").forEach(O=>{O.style.visibility="hidden";const it=O.cloneNode(!0);it.style.visibility="visible";const nt=document.createElementNS(b,"g"),lt=k/2-o.plotArea.width/2;nt.setAttribute("transform",`translate(${lt},${L})`),nt.appendChild(it),C.appendChild(nt)});const X=y.querySelector(".katucharts-credits");if(X){const O=parseFloat(X.getAttribute("x")||"0"),it=parseFloat(X.getAttribute("y")||"0");X.style.visibility="hidden";const nt=X.cloneNode(!0);nt.style.visibility="visible",nt.setAttribute("x",String(k-(s-O))),nt.setAttribute("y",String(M-(a-it))),C.appendChild(nt)}return t.appendChild(C),C}const Kt=class Kt{static inlineStyles(t){const e=t.cloneNode(!0),i=e.querySelectorAll("*"),r=t.querySelectorAll("*");for(let a=0;a<i.length&&a<r.length;a++){const c=i[a],l=r[a];try{const h=window.getComputedStyle(l);for(const f of Kt.INLINE_PROPS){const u=h.getPropertyValue(f);u&&u!==""&&u!=="none"&&u!=="normal"&&u!=="0"&&c.style.setProperty(f,u)}}catch{}}const o=e.querySelector(".katucharts-export-button-group");return o&&o.remove(),tn.isLicensed()||Kt.stampWatermark(e),new XMLSerializer().serializeToString(e)}static stampWatermark(t){t.querySelectorAll(".katucharts-credits, .katucharts-export-watermark").forEach(s=>s.remove());const e=(t.getAttribute("viewBox")||"").split(/[\s,]+/).map(Number),i=parseFloat(t.getAttribute("width")||"")||e[2]||600,r=parseFloat(t.getAttribute("height")||"")||e[3]||400,o=document.createElementNS("http://www.w3.org/2000/svg","text");o.setAttribute("class","katucharts-export-watermark"),o.setAttribute("x",String(i-8)),o.setAttribute("y",String(r-8)),o.setAttribute("text-anchor","end"),o.setAttribute("font-family","Arial, Helvetica, sans-serif"),o.setAttribute("font-size","11px"),o.setAttribute("font-weight","normal"),o.setAttribute("fill","#8a8a8a"),o.style.setProperty("fill","#8a8a8a"),o.textContent="Powered by: KatuCharts",t.appendChild(o)}static svgToCanvas(t,e,i){return new Promise((r,o)=>{const s=new Image;s.onload=()=>{const a=document.createElement("canvas");a.width=s.width*e,a.height=s.height*e;const c=a.getContext("2d");if(!c){o(new Error("Canvas context unavailable"));return}c.scale(e,e),i&&(c.fillStyle=i,c.fillRect(0,0,s.width,s.height)),c.drawImage(s,0,0),r(a)},s.onerror=()=>o(new Error("Failed to load SVG into image")),s.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t)))})}static exportSVG(t,e="chart"){const i=new Blob([t],{type:"image/svg+xml;charset=utf-8"});Kt.downloadBlob(i,`${e}.svg`)}static async exportPNG(t,e="chart",i=2){const r=await Kt.svgToCanvas(t,i);return new Promise((o,s)=>{r.toBlob(a=>{a?(Kt.downloadBlob(a,`${e}.png`),o()):s(new Error("Failed to generate PNG"))},"image/png")})}static async exportJPEG(t,e="chart",i=2,r=.95){const o=await Kt.svgToCanvas(t,i,"#ffffff");return new Promise((s,a)=>{o.toBlob(c=>{c?(Kt.downloadBlob(c,`${e}.jpeg`),s()):a(new Error("Failed to generate JPEG"))},"image/jpeg",r)})}static loadJsPDF(){return Kt.jsPDFLoader||(Kt.jsPDFLoader=(async()=>{var r;const t=()=>{var s;const o=((s=globalThis.jspdf)==null?void 0:s.jsPDF)??globalThis.jsPDF;return typeof o=="function"?o:null},e=t();if(e)return e;try{const o=await Promise.resolve().then(()=>c5),s=o.jsPDF??((r=o.default)==null?void 0:r.jsPDF)??o.default;if(typeof s=="function")return s}catch{}await Kt.injectScript(Kt.JSPDF_CDN_URL);const i=t();if(i)return i;throw new Error("jsPDF unavailable")})().catch(t=>{throw Kt.jsPDFLoader=null,t})),Kt.jsPDFLoader}static injectScript(t){return new Promise((e,i)=>{const r=document.createElement("script");r.src=t,r.async=!0,r.onload=()=>e(),r.onerror=()=>{r.remove(),i(new Error(`Failed to load ${t}`))},document.head.appendChild(r)})}static async exportPDF(t,e="chart",i=2){let r;try{r=await Kt.loadJsPDF()}catch{console.warn("KatuCharts: jspdf could not be loaded. Install it with `npm install jspdf`, expose it as a global, or allow the CDN fallback to enable PDF export.");return}const o=await Kt.svgToCanvas(t,i,"#ffffff"),s=o.toDataURL("image/jpeg",.95),a=o.width/i,c=o.height/i,l=a>c?"landscape":"portrait",h=new r({orientation:l,unit:"px",format:[a,c]});h.addImage(s,"JPEG",0,0,a,c),h.save(`${e}.pdf`)}static print(t,e){var c;const i=document.createElement("iframe");Object.assign(i.style,{position:"fixed",left:"-9999px",top:"-9999px",width:"0",height:"0",border:"none"}),document.body.appendChild(i);const r=i.contentDocument||((c=i.contentWindow)==null?void 0:c.document);if(!r){i.remove();return}const o=e??780;r.open(),r.write(`<!DOCTYPE html><html><head><style>
3
3
  body { margin: 0; padding: 20px; display: flex; justify-content: center; }
4
4
  svg { max-width: ${o}px; height: auto; }
5
5
  </style></head><body>${t}</body></html>`),r.close();const s=()=>{try{i.remove()}catch{}},a=i.contentWindow;if(!a){s();return}a.onafterprint=s,setTimeout(()=>{a.focus(),a.print(),setTimeout(s,3e3)},250)}static exportCSV(t,e="chart",i){const r=(i==null?void 0:i.itemDelimiter)??",",o=(i==null?void 0:i.lineDelimiter)??`
6
- `,s=(i==null?void 0:i.decimalPoint)??".",a=["Category"];t.forEach(d=>{if(i!=null&&i.columnHeaderFormatter){const p=i.columnHeaderFormatter(d,"y",1);a.push(p===!1?d.name||"Series":p)}else a.push(d.name||"Series")});const c=new Set;for(const d of t)for(const p of d.data)c.add(p.name??p.x??"");const l=d=>{if(d==null)return"";const p=String(d);return s!=="."&&typeof d=="number"?p.replace(".",s):p},h=[];for(const d of c){const p=[String(d)];for(const y of t){const g=y.data.find(m=>(m.name??m.x)===d);p.push((g==null?void 0:g.y)!==void 0&&g.y!==null?l(g.y):"")}h.push(p)}const f=[a.map(d=>es(d,r)).join(r),...h.map(d=>d.map(p=>es(p,r)).join(r))].join(o),u=new Blob([f],{type:"text/csv;charset=utf-8"});Jt.downloadBlob(u,`${e}.csv`)}static getCSV(t,e){const i=(e==null?void 0:e.itemDelimiter)??",",r=(e==null?void 0:e.lineDelimiter)??`
7
- `,o=(e==null?void 0:e.decimalPoint)??".",s=["Category"];t.forEach(h=>{if(e!=null&&e.columnHeaderFormatter){const f=e.columnHeaderFormatter(h,"y",1);s.push(f===!1?h.name||"Series":f)}else s.push(h.name||"Series")});const a=new Set;for(const h of t)for(const f of h.data)a.add(f.name??f.x??"");const c=h=>{if(h==null)return"";const f=String(h);return o!=="."&&typeof h=="number"?f.replace(".",o):f},l=[];for(const h of a){const f=[String(h)];for(const u of t){const d=u.data.find(p=>(p.name??p.x)===h);f.push((d==null?void 0:d.y)!==void 0&&d.y!==null?c(d.y):"")}l.push(f)}return[s.map(h=>es(h,i)).join(i),...l.map(h=>h.map(f=>es(f,i)).join(i))].join(r)}static getDataRows(t){const e=["Category"];t.forEach(o=>e.push(o.name||"Series"));const i=new Set;for(const o of t)for(const s of o.data)i.add(s.name??s.x??"");const r=[e];for(const o of i){const s=[o!=null?String(o):""];for(const a of t){const c=a.data.find(l=>(l.name??l.x)===o);s.push((c==null?void 0:c.y)??null)}r.push(s)}return r}static getTable(t,e){const i=Jt.getDataRows(t);if(i.length===0)return"<table></table>";const r=i[0],o=i.slice(1);let s='<table class="katucharts-data-table">';e&&typeof e=="string"&&(s+=`<caption>${Jn(e)}</caption>`),s+="<thead><tr>";for(const a of r)s+=`<th>${Jn(a??"")}</th>`;s+="</tr></thead><tbody>";for(const a of o){s+="<tr>";for(const c of a)s+=`<td>${Jn(c??"")}</td>`;s+="</tr>"}return s+="</tbody></table>",s}static viewDataTable(t,e,i){let r=e.querySelector(".katucharts-data-table-container");if(r)return r.remove(),null;r=document.createElement("div"),r.className="katucharts-data-table-container",Object.assign(r.style,{position:"relative",maxHeight:"300px",overflow:"auto",border:"1px solid #ccc",marginTop:"10px",fontSize:"11px"});const o=Jt.getTable(t,i);r.innerHTML=o;const s=r.querySelector("table");return s&&(Object.assign(s.style,{width:"100%",borderCollapse:"collapse"}),s.querySelectorAll("th, td").forEach(a=>{Object.assign(a.style,{padding:"4px 8px",borderBottom:"1px solid #e6e6e6",textAlign:"left"})}),s.querySelectorAll("th").forEach(a=>{Object.assign(a.style,{backgroundColor:"#f7f7f7",fontWeight:"bold"})})),e.appendChild(r),r}static downloadBlob(t,e){const i=URL.createObjectURL(t),r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}};Jt.INLINE_PROPS=["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","text-decoration","visibility","display"],Jt.JSPDF_CDN_URL="https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js",Jt.jsPDFLoader=null;let re=Jt;class Gv{constructor(t){this.host=t}getSVG(){return this.host.getRenderer().getSerializedSVG()}getInlinedSVG(){const t=this.host.getRenderer(),e=t.getSVGNode();return e?re.inlineStyles(e):t.getSerializedSVG()}handleExportAction(t){const e=this.host.getOptions(),i=this.getInlinedSVG(),r=e.exporting.filename??"chart",o=e.exporting.scale??2;switch(t){case"downloadPNG":re.exportPNG(i,r,o).catch(s=>console.warn("KatuCharts: PNG export failed.",s));break;case"downloadJPEG":re.exportJPEG(i,r,o).catch(s=>console.warn("KatuCharts: JPEG export failed.",s));break;case"downloadSVG":re.exportSVG(i,r);break;case"downloadPDF":re.exportPDF(i,r,o).catch(s=>console.warn("KatuCharts: PDF export failed.",s));break;case"downloadCSV":re.exportCSV(this.getSeriesDataForExport(),r,e.exporting.csv);break;case"downloadXLS":this.exportXLS(r);break;case"viewDataTable":re.viewDataTable(this.getSeriesDataForExport(),this.host.getContainer(),e.exporting.tableCaption);break;case"viewFullScreen":this.toggleFullScreen();break;case"printChart":this.host.fireEvent("beforePrint"),re.print(i,e.exporting.printMaxWidth),this.host.fireEvent("afterPrint");break}}toggleFullScreen(){var m;const t=this.host.getContainer();if(!t)return;const e=t.ownerDocument,i=e.defaultView||window;if(e.fullscreenElement===t||e.webkitFullscreenElement===t){e.exitFullscreen?e.exitFullscreen():e.webkitExitFullscreen&&e.webkitExitFullscreen();return}const o=t.style,s={width:o.width,height:o.height,maxWidth:o.maxWidth,maxHeight:o.maxHeight,background:o.background},a=this.host.getOptions().chart.backgroundColor||"#fff";o.background=a,o.width="100vw",o.height="100vh",o.maxWidth="none",o.maxHeight="none",this.host.disconnectResizeObserver();const c=this.host.getViewportSize(),l=()=>{o.width=s.width,o.height=s.height,o.maxWidth=s.maxWidth,o.maxHeight=s.maxHeight,o.background=s.background},h=()=>{this.host.fitToViewport(c.width,c.height)};let f=null;const u=()=>{const x=i.innerWidth,v=i.innerHeight;!x||!v||this.host.fitToViewport(x,v)},d=()=>{e.exitFullscreen?e.exitFullscreen():e.webkitExitFullscreen&&e.webkitExitFullscreen()},p=()=>{i.removeEventListener("resize",u),e.removeEventListener("fullscreenchange",y),e.removeEventListener("webkitfullscreenchange",y)},y=()=>{e.fullscreenElement===t||e.webkitFullscreenElement===t?(f=e.createElement("button"),f.textContent="✕",Object.assign(f.style,{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)",zIndex:"10000",width:"32px",height:"32px",border:"none",borderRadius:"50%",background:"rgba(0,0,0,0.4)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",padding:"0"}),f.addEventListener("mouseenter",()=>{f&&(f.style.background="rgba(0,0,0,0.7)")}),f.addEventListener("mouseleave",()=>{f&&(f.style.background="rgba(0,0,0,0.4)")}),f.addEventListener("click",d),t.appendChild(f),u(),requestAnimationFrame(u),i.addEventListener("resize",u)):(p(),f&&(f.remove(),f=null),l(),h(),requestAnimationFrame(()=>{this.host.observeResizeObserver(),this.host.fireEvent("exitFullScreen")}))};e.addEventListener("fullscreenchange",y),e.addEventListener("webkitfullscreenchange",y);const g=()=>{p(),l(),this.host.getRenderer().svg.style("width",null).style("height",null),h(),this.host.observeResizeObserver()};try{const x=t.requestFullscreen?t.requestFullscreen():(m=t.webkitRequestFullscreen)==null?void 0:m.call(t);x&&typeof x.catch=="function"&&x.catch(g),this.host.fireEvent("enterFullScreen")}catch{g()}}getSeriesDataForExport(){return this.host.getSeriesInstances().map(t=>({name:t.config.name||`Series ${t.config.index+1}`,data:t.data.map(e=>({x:e.x,y:e.y,name:e.name}))}))}exportXLS(t){const e=re.getDataRows(this.getSeriesDataForExport());let i='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:spreadsheet" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"/></head><body><table>';for(const o of e){i+="<tr>";for(const s of o)i+=`<td>${s??""}</td>`;i+="</tr>"}i+="</table></body></html>";const r=new Blob([i],{type:"application/vnd.ms-excel"});re.downloadBlob(r,`${t}.xls`)}getCSV(){return re.getCSV(this.getSeriesDataForExport(),this.host.getOptions().exporting.csv)}getTable(){return re.getTable(this.getSeriesDataForExport(),this.host.getOptions().exporting.tableCaption)}getDataRows(){return re.getDataRows(this.getSeriesDataForExport())}exportChart(t){const e={...this.host.getOptions().exporting,...t},i=this.getInlinedSVG(),r=e.filename??"chart",o=e.scale??2;switch(e.type){case"image/jpeg":re.exportJPEG(i,r,o);break;case"image/svg+xml":re.exportSVG(i,r);break;case"application/pdf":re.exportPDF(i,r,o);break;case"image/png":default:re.exportPNG(i,r,o);break}}print(){this.host.fireEvent("beforePrint");const t=this.getInlinedSVG();re.print(t,this.host.getOptions().exporting.printMaxWidth),this.host.fireEvent("afterPrint")}optionsToExternal(){const t=this.host.getOptions();return{chart:t.chart,title:t.title,subtitle:t.subtitle,xAxis:t.xAxis,yAxis:t.yAxis,colorAxis:t.colorAxis,series:t.series,tooltip:t.tooltip,legend:t.legend,plotOptions:t.plotOptions,credits:t.credits,colors:t.colors}}}class Yv{constructor(t){this.host=t}updateTooltipCategories(){const t=this.host.getTooltip();if(!t)return;const e=this.host.getXAxes()[0];e&&(e.config.type==="category"||e.config.categories)&&t.setCategories(e.config.categories||[]),t.setDatetimeAxis(!!e&&e.config.type==="datetime")}updateAxesDomains(){const t=Ti,e=this.host.getOptions(),i=this.host.getLayout(),r=this.host.getSeriesInstances(),o=this.host.getXAxes(),s=this.host.getYAxes();for(let a=0;a<o.length;a++){const c=o[a];if(c.config.type==="category"||c.config.categories&&c.config.categories.length>0){const u=r.filter((p,y)=>p.visible&&e.series[y]._xAxisIndex===a&&!t.has(p.config._internalType)),d=(c.config.categories&&c.config.categories.length>0?c.config.categories:null)||(u.length>0?u[0].getCategories():void 0);d&&d.length>0&&c.updateDomain(d);continue}const l=r.filter((u,d)=>u.visible&&e.series[d]._xAxisIndex===a&&!t.has(u.config._internalType));if(l.length===0)continue;let h=1/0,f=-1/0;for(const u of l){const d=u.getDataExtents();h=Math.min(h,d.xMin),f=Math.max(f,d.xMax)}if(isFinite(h)&&isFinite(f)){const u=e.series.filter((p,y)=>{var g;return((g=r[y])==null?void 0:g.visible)&&p._xAxisIndex===a&&!t.has(p._internalType)}),d=this.computeBubbleRadiusPadding(u,i.plotArea.width);c.updateDomain({min:h,max:f,extraMinPadding:d,extraMaxPadding:d})}}for(let a=0;a<s.length;a++){const c=s[a],l=e.series.filter((g,m)=>{var x;return((x=r[m])==null?void 0:x.visible)&&g._yAxisIndex===a&&!t.has(g._internalType)}),h=r.filter((g,m)=>g.visible&&e.series[m]._yAxisIndex===a&&!t.has(g.config._internalType));if(h.length===0)continue;let f=1/0,u=-1/0;const d=new Map;for(let g=0;g<h.length;g++){const m=h[g],x=l[g];if(x!=null&&x.stacking){const v=ss(x);d.has(v)||d.set(v,new Map),Vi(m.data,d.get(v))}else{const v=m.getDataExtents();f=Math.min(f,v.yMin),u=Math.max(u,v.yMax)}}const p=l.some(g=>(g==null?void 0:g.stacking)==="percent");p&&(f=0,u=100,c.config.min=0,c.config.max=100);for(const g of d.values())if(!p)for(const m of g.values())f=Math.min(f,0),u=Math.max(u,m);if(l.some(g=>Mg.has(g._internalType))&&c.config.min===void 0&&(f=Math.min(f,0),u=Math.max(u,0)),isFinite(f)&&isFinite(u)){const g=this.computeBubbleRadiusPadding(l,i.plotArea.height);c.updateDomain({min:f,max:u,extraMinPadding:g,extraMaxPadding:g})}}}computeBubbleRadiusPadding(t,e){const i=t.filter(s=>s&&s._internalType==="bubble");if(i.length===0||e<=0)return 0;const r=this.host.getLayout().plotArea;let o=0;for(const s of i){const a=s.maxSize;let c;typeof a=="number"?c=a:typeof a=="string"&&a.endsWith("%")?c=Math.min(r.width,r.height)*parseFloat(a)/100/2:c=30,o=Math.max(o,c)}return o/Math.max(e-2*o,1)}renderAxes(){const t=this.host.getAxisGroup(),e=this.host.getLayout();if(t.selectAll("*").remove(),!Ks(this.host.getOptions().series)){for(const i of this.host.getXAxes())i.config.showEmpty===!1&&!this.hasSeriesForAxis(i,!0)||i.render(t,e.plotArea);for(const i of this.host.getYAxes())i.config.showEmpty===!1&&!this.hasSeriesForAxis(i,!1)||i.render(t,e.plotArea);this.setupAxisLabelHover()}}setupAxisLabelHover(){const t=this.host.getXAxes()[0];if(!t)return;const i=this.host.getAxisGroup().select(".katucharts-axis-x");if(i.empty())return;const r=i.selectAll(".tick"),o=this.host.getOptions(),s=this.host.getSeriesInstances(),a=this.host.getYAxes(),c=this.host.getEvents();r.each(function(){const l=st(this),h=l.select("text");if(h.empty())return;const f=h.node().getBBox();l.insert("rect","text").attr("x",f.x-4).attr("y",f.y-2).attr("width",f.width+8).attr("height",f.height+4).attr("fill","transparent").attr("class","katucharts-tick-hitarea")}),r.style("cursor","pointer").on("mouseover",function(l){var y;const h=this.__data__,f=typeof h=="string"?((y=t.config.categories)==null?void 0:y.indexOf(h))??-1:typeof h=="number"?h:-1;if(f<0)return;const u=!!o.chart.inverted,d=t.getPixelForValue(h),p=[];for(const g of s){if(!g.visible)continue;const m=g.data.find(x=>(x.x??0)===f);if(m&&m.y!==null&&m.y!==void 0){const v=a[0].getPixelForValue(m.y??0);p.push({point:m,series:g,plotX:u?v:d,plotY:u?d:v})}}if(p.length>0){const g=p[0];c.emit("point:mouseover",{point:{...g.point,matchingPoints:p},index:f,series:g.series,event:l,plotX:g.plotX,plotY:g.plotY})}for(const g of s){if(!g.visible)continue;const m=g.group;if(!m)continue;m.selectAll(".katucharts-column, .katucharts-bar, .katucharts-marker, .katucharts-bubble, .katucharts-scatter-point").each(function(v){const b=st(this);((v==null?void 0:v.x)??-1)===f?b.attr("filter","brightness(1.15)"):b.transition().duration(100).attr("opacity",.3)})}}).on("mouseout",function(){for(const l of s){if(!l.visible)continue;const h=l.group;h&&h.selectAll(".katucharts-column, .katucharts-bar, .katucharts-marker, .katucharts-bubble, .katucharts-scatter-point").interrupt().attr("opacity",null).attr("filter",null)}c.emit("point:mouseout",{point:{},index:-1,series:null,event:null})})}hasSeriesForAxis(t,e){const i=this.host.getOptions();return this.host.getSeriesInstances().some((r,o)=>{const s=i.series[o],a=e?s._xAxisIndex:s._yAxisIndex;return r.visible&&a===t.config.index})}}class bf{constructor(t,e,i){if(this.stack=[],this.breadcrumbsEl=null,this.container=null,this.config=t,this.events=e,this.container=i||null,this.drilldownMap=new Map,t.series)for(const r of t.series)r.id&&this.drilldownMap.set(r.id,r);this.pointClickHandler=r=>{const o=r.point.drilldown;o&&this.drilldownMap.has(o)&&this.drillDown(o,r)},e.on("point:click",this.pointClickHandler)}addSeriesAsDrilldown(t,e){e.id&&this.drilldownMap.set(e.id,e);const i=t.drilldown||e.id;i&&this.drillDown(i,{point:t,series:{}})}drillDown(t,e){var r,o;const i=this.drilldownMap.get(t);i&&(this.stack.push({seriesOptions:(r=e.series)!=null&&r.config?[e.series.config]:[],title:(o=e.point)==null?void 0:o.name}),this.events.emit("drilldown:drilldown",{point:e.point,seriesOptions:i}),this.updateBreadcrumbs())}drillUp(){const t=this.stack.pop();t&&(this.events.emit("drilldown:drillup",t),this.updateBreadcrumbs())}drillUpToLevel(t){for(;this.stack.length>t;)this.drillUp()}hasLevels(){return this.stack.length>0}getCurrentLevel(){return this.stack.length}get breadcrumbsConfig(){const t=this.config.breadcrumbs;return t&&typeof t=="object"?t:{}}isBreadcrumbsEnabled(){const t=this.config.breadcrumbs;return!(t===!1||t&&typeof t=="object"&&t.enabled===!1)}updateBreadcrumbs(){var u,d,p,y,g,m,x,v;if(!this.container||!this.isBreadcrumbsEnabled())return;const t=this.breadcrumbsConfig,e=t.floating!==!1;if(!this.breadcrumbsEl){this.breadcrumbsEl=document.createElement("div"),this.breadcrumbsEl.className="katucharts-breadcrumbs";const b=t.position||{};e&&getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),Object.assign(this.breadcrumbsEl.style,{position:e?"absolute":"relative",display:"flex",alignItems:"center",gap:"6px",padding:"3px 10px",borderRadius:"999px",fontSize:((u=t.style)==null?void 0:u.fontSize)||"12px",fontWeight:((d=t.style)==null?void 0:d.fontWeight)||"500",lineHeight:"1.4",color:((p=t.style)==null?void 0:p.color)||"#1b1a15",background:((y=t.style)==null?void 0:y.background)||"rgba(255,255,255,0.86)",boxShadow:((g=t.style)==null?void 0:g.boxShadow)||"0 1px 3px rgba(27,26,21,0.18)",zIndex:"10",top:e?`${b.y??8}px`:"",left:e?`${b.x??8}px`:"",userSelect:"none"}),this.container.appendChild(this.breadcrumbsEl)}if(this.breadcrumbsEl.innerHTML="",this.stack.length===0){this.breadcrumbsEl.style.display="none";return}this.breadcrumbsEl.style.display="flex";const i=((m=t.style)==null?void 0:m.linkColor)||"#003399",r=((x=t.separator)==null?void 0:x.text)??"/",o=((v=t.separator)==null?void 0:v.style)||{},s=t.showFullPath!==!1,a=t.showBackButton!==!1,c=t.rootText??"Main",l=b=>{const k=document.createElement("span");k.textContent="◀",k.setAttribute("role","button"),k.setAttribute("aria-label","Drill up"),Object.assign(k.style,{cursor:"pointer",color:i,fontSize:"0.8em",lineHeight:"1",transition:"opacity 120ms ease"}),k.addEventListener("mouseenter",()=>{k.style.opacity="0.55"}),k.addEventListener("mouseleave",()=>{k.style.opacity="1"}),k.addEventListener("click",b),this.breadcrumbsEl.appendChild(k)},h=(b,k,M)=>{const C=document.createElement("span");C.textContent=b,M&&(Object.assign(C.style,{cursor:"pointer",color:i,transition:"opacity 120ms ease"}),C.addEventListener("mouseenter",()=>{C.style.textDecoration="underline"}),C.addEventListener("mouseleave",()=>{C.style.textDecoration="none"}),C.addEventListener("click",()=>{var E;(E=t.events)!=null&&E.click&&t.events.click.call(this,{level:k}),this.drillUpToLevel(k)})),this.breadcrumbsEl.appendChild(C)},f=()=>{const b=document.createElement("span");b.textContent=r,b.style.opacity="0.55",o.color&&(b.style.color=o.color),this.breadcrumbsEl.appendChild(b)};if(s){a&&l(()=>this.drillUp()),h(c,0,!0);for(let b=0;b<this.stack.length;b++){f();const k=b===this.stack.length-1,M=this.getCrumbLabel(b);h(M,b+1,!k)}}else{l(()=>this.drillUp());const b=document.createElement("span");b.textContent="Back",b.style.cursor="pointer",b.style.color=i,b.addEventListener("click",()=>this.drillUp()),this.breadcrumbsEl.appendChild(b)}}getCrumbLabel(t){const e=this.stack[t],i=this.breadcrumbsConfig;return i.formatter?i.formatter.call({level:t,levelOptions:e}):e.title||`Level ${t+1}`}destroy(){this.events.off("point:click",this.pointClickHandler),this.breadcrumbsEl&&(this.breadcrumbsEl.remove(),this.breadcrumbsEl=null)}}const Xv={passive:!1},_r={capture:!0,passive:!1};function uc(n){n.stopImmediatePropagation()}function Gi(n){n.preventDefault(),n.stopImmediatePropagation()}function fc(n){var t=n.document.documentElement,e=st(n).on("dragstart.drag",Gi,_r);"onselectstart"in t?e.on("selectstart.drag",Gi,_r):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function dc(n,t){var e=n.document.documentElement,i=st(n).on("dragstart.drag",null);t&&(i.on("click.drag",Gi,_r),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in e?i.on("selectstart.drag",null):(e.style.MozUserSelect=e.__noselect,delete e.__noselect)}const as=n=>()=>n;function pc(n,{sourceEvent:t,subject:e,target:i,identifier:r,active:o,x:s,y:a,dx:c,dy:l,dispatch:h}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:h}})}pc.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Uv(n){return!n.ctrlKey&&!n.button}function jv(){return this.parentNode}function qv(n,t){return t??{x:n.x,y:n.y}}function Zv(){return navigator.maxTouchPoints||"ontouchstart"in this}function vf(){var n=Uv,t=jv,e=qv,i=Zv,r={},o=Oi("start","drag","end"),s=0,a,c,l,h,f=0;function u(b){b.on("mousedown.drag",d).filter(i).on("touchstart.drag",g).on("touchmove.drag",m,Xv).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(b,k){if(!(h||!n.call(this,b,k))){var M=v(this,t.call(this,b,k),b,k,"mouse");M&&(st(b.view).on("mousemove.drag",p,_r).on("mouseup.drag",y,_r),fc(b.view),uc(b),l=!1,a=b.clientX,c=b.clientY,M("start",b))}}function p(b){if(Gi(b),!l){var k=b.clientX-a,M=b.clientY-c;l=k*k+M*M>f}r.mouse("drag",b)}function y(b){st(b.view).on("mousemove.drag mouseup.drag",null),dc(b.view,l),Gi(b),r.mouse("end",b)}function g(b,k){if(n.call(this,b,k)){var M=b.changedTouches,C=t.call(this,b,k),E=M.length,_,T;for(_=0;_<E;++_)(T=v(this,C,b,k,M[_].identifier,M[_]))&&(uc(b),T("start",b,M[_]))}}function m(b){var k=b.changedTouches,M=k.length,C,E;for(C=0;C<M;++C)(E=r[k[C].identifier])&&(Gi(b),E("drag",b,k[C]))}function x(b){var k=b.changedTouches,M=k.length,C,E;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),C=0;C<M;++C)(E=r[k[C].identifier])&&(uc(b),E("end",b,k[C]))}function v(b,k,M,C,E,_){var T=o.copy(),I=mn(_||M,k),L,P,A;if((A=e.call(b,new pc("beforestart",{sourceEvent:M,target:u,identifier:E,active:s,x:I[0],y:I[1],dx:0,dy:0,dispatch:T}),C))!=null)return L=A.x-I[0]||0,P=A.y-I[1]||0,function w(S,$,R){var F=I,D;switch(S){case"start":r[E]=w,D=s++;break;case"end":delete r[E],--s;case"drag":I=mn(R||$,k),D=s;break}T.call(S,b,new pc(S,{sourceEvent:$,subject:A,target:u,identifier:E,active:D,x:I[0]+L,y:I[1]+P,dx:I[0]-F[0],dy:I[1]-F[1],dispatch:T}),C)}}return u.filter=function(b){return arguments.length?(n=typeof b=="function"?b:as(!!b),u):n},u.container=function(b){return arguments.length?(t=typeof b=="function"?b:as(b),u):t},u.subject=function(b){return arguments.length?(e=typeof b=="function"?b:as(b),u):e},u.touchable=function(b){return arguments.length?(i=typeof b=="function"?b:as(!!b),u):i},u.on=function(){var b=o.on.apply(o,arguments);return b===o?u:b},u.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,u):Math.sqrt(f)},u}const cs=n=>()=>n;function Kv(n,{sourceEvent:t,target:e,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Nn(n,t,e){this.k=n,this.x=t,this.y=e}Nn.prototype={constructor:Nn,scale:function(n){return n===1?this:new Nn(this.k*n,this.x,this.y)},translate:function(n,t){return n===0&t===0?this:new Nn(this.k,this.x+this.k*n,this.y+this.k*t)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Cr=new Nn(1,0,0);Nn.prototype;function gc(n){n.stopImmediatePropagation()}function Pr(n){n.preventDefault(),n.stopImmediatePropagation()}function Jv(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function Qv(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function wf(){return this.__zoom||Cr}function t2(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function e2(){return navigator.maxTouchPoints||"ontouchstart"in this}function n2(n,t,e){var i=n.invertX(t[0][0])-e[0][0],r=n.invertX(t[1][0])-e[1][0],o=n.invertY(t[0][1])-e[0][1],s=n.invertY(t[1][1])-e[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function kf(){var n=Jv,t=Qv,e=n2,i=t2,r=e2,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=sx,l=Oi("start","zoom","end"),h,f,u,d=500,p=150,y=0,g=10;function m(A){A.property("__zoom",wf).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",T).filter(r).on("touchstart.zoom",I).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(A,w,S,$){var R=A.selection?A.selection():A;R.property("__zoom",wf),A!==R?k(A,w,S,$):R.interrupt().each(function(){M(this,arguments).event($).start().zoom(null,typeof w=="function"?w.apply(this,arguments):w).end()})},m.scaleBy=function(A,w,S,$){m.scaleTo(A,function(){var R=this.__zoom.k,F=typeof w=="function"?w.apply(this,arguments):w;return R*F},S,$)},m.scaleTo=function(A,w,S,$){m.transform(A,function(){var R=t.apply(this,arguments),F=this.__zoom,D=S==null?b(R):typeof S=="function"?S.apply(this,arguments):S,z=F.invert(D),B=typeof w=="function"?w.apply(this,arguments):w;return e(v(x(F,B),D,z),R,s)},S,$)},m.translateBy=function(A,w,S,$){m.transform(A,function(){return e(this.__zoom.translate(typeof w=="function"?w.apply(this,arguments):w,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),s)},null,$)},m.translateTo=function(A,w,S,$,R){m.transform(A,function(){var F=t.apply(this,arguments),D=this.__zoom,z=$==null?b(F):typeof $=="function"?$.apply(this,arguments):$;return e(Cr.translate(z[0],z[1]).scale(D.k).translate(typeof w=="function"?-w.apply(this,arguments):-w,typeof S=="function"?-S.apply(this,arguments):-S),F,s)},$,R)};function x(A,w){return w=Math.max(o[0],Math.min(o[1],w)),w===A.k?A:new Nn(w,A.x,A.y)}function v(A,w,S){var $=w[0]-S[0]*A.k,R=w[1]-S[1]*A.k;return $===A.x&&R===A.y?A:new Nn(A.k,$,R)}function b(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function k(A,w,S,$){A.on("start.zoom",function(){M(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event($).end()}).tween("zoom",function(){var R=this,F=arguments,D=M(R,F).event($),z=t.apply(R,F),B=S==null?b(z):typeof S=="function"?S.apply(R,F):S,W=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),K=R.__zoom,X=typeof w=="function"?w.apply(R,F):w,q=c(K.invert(B).concat(W/K.k),X.invert(B).concat(W/X.k));return function(N){if(N===1)N=X;else{var H=q(N),Y=W/H[2];N=new Nn(Y,B[0]-H[0]*Y,B[1]-H[1]*Y)}D.zoom(null,N)}})}function M(A,w,S){return!S&&A.__zooming||new C(A,w)}function C(A,w){this.that=A,this.args=w,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,w),this.taps=0}C.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,w){return this.mouse&&A!=="mouse"&&(this.mouse[1]=w.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=w.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=w.invert(this.touch1[0])),this.that.__zoom=w,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var w=st(this.that).datum();l.call(A,this.that,new Kv(A,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),w)}};function E(A,...w){if(!n.apply(this,arguments))return;var S=M(this,w).event(A),$=this.__zoom,R=Math.max(o[0],Math.min(o[1],$.k*Math.pow(2,i.apply(this,arguments)))),F=mn(A);if(S.wheel)(S.mouse[0][0]!==F[0]||S.mouse[0][1]!==F[1])&&(S.mouse[1]=$.invert(S.mouse[0]=F)),clearTimeout(S.wheel);else{if($.k===R)return;S.mouse=[F,$.invert(F)],Wi(this),S.start()}Pr(A),S.wheel=setTimeout(D,p),S.zoom("mouse",e(v(x($,R),S.mouse[0],S.mouse[1]),S.extent,s));function D(){S.wheel=null,S.end()}}function _(A,...w){if(u||!n.apply(this,arguments))return;var S=A.currentTarget,$=M(this,w,!0).event(A),R=st(A.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",W,!0),F=mn(A,S),D=A.clientX,z=A.clientY;fc(A.view),gc(A),$.mouse=[F,this.__zoom.invert(F)],Wi(this),$.start();function B(K){if(Pr(K),!$.moved){var X=K.clientX-D,q=K.clientY-z;$.moved=X*X+q*q>y}$.event(K).zoom("mouse",e(v($.that.__zoom,$.mouse[0]=mn(K,S),$.mouse[1]),$.extent,s))}function W(K){R.on("mousemove.zoom mouseup.zoom",null),dc(K.view,$.moved),Pr(K),$.event(K).end()}}function T(A,...w){if(n.apply(this,arguments)){var S=this.__zoom,$=mn(A.changedTouches?A.changedTouches[0]:A,this),R=S.invert($),F=S.k*(A.shiftKey?.5:2),D=e(v(x(S,F),$,R),t.apply(this,w),s);Pr(A),a>0?st(this).transition().duration(a).call(k,D,$,A):st(this).call(m.transform,D,$,A)}}function I(A,...w){if(n.apply(this,arguments)){var S=A.touches,$=S.length,R=M(this,w,A.changedTouches.length===$).event(A),F,D,z,B;for(gc(A),D=0;D<$;++D)z=S[D],B=mn(z,this),B=[B,this.__zoom.invert(B),z.identifier],R.touch0?!R.touch1&&R.touch0[2]!==B[2]&&(R.touch1=B,R.taps=0):(R.touch0=B,F=!0,R.taps=1+!!h);h&&(h=clearTimeout(h)),F&&(R.taps<2&&(f=B[0],h=setTimeout(function(){h=null},d)),Wi(this),R.start())}}function L(A,...w){if(this.__zooming){var S=M(this,w).event(A),$=A.changedTouches,R=$.length,F,D,z,B;for(Pr(A),F=0;F<R;++F)D=$[F],z=mn(D,this),S.touch0&&S.touch0[2]===D.identifier?S.touch0[0]=z:S.touch1&&S.touch1[2]===D.identifier&&(S.touch1[0]=z);if(D=S.that.__zoom,S.touch1){var W=S.touch0[0],K=S.touch0[1],X=S.touch1[0],q=S.touch1[1],N=(N=X[0]-W[0])*N+(N=X[1]-W[1])*N,H=(H=q[0]-K[0])*H+(H=q[1]-K[1])*H;D=x(D,Math.sqrt(N/H)),z=[(W[0]+X[0])/2,(W[1]+X[1])/2],B=[(K[0]+q[0])/2,(K[1]+q[1])/2]}else if(S.touch0)z=S.touch0[0],B=S.touch0[1];else return;S.zoom("touch",e(v(D,z,B),S.extent,s))}}function P(A,...w){if(this.__zooming){var S=M(this,w).event(A),$=A.changedTouches,R=$.length,F,D;for(gc(A),u&&clearTimeout(u),u=setTimeout(function(){u=null},d),F=0;F<R;++F)D=$[F],S.touch0&&S.touch0[2]===D.identifier?delete S.touch0:S.touch1&&S.touch1[2]===D.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(D=mn(D,this),Math.hypot(f[0]-D[0],f[1]-D[1])<g)){var z=st(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return m.wheelDelta=function(A){return arguments.length?(i=typeof A=="function"?A:cs(+A),m):i},m.filter=function(A){return arguments.length?(n=typeof A=="function"?A:cs(!!A),m):n},m.touchable=function(A){return arguments.length?(r=typeof A=="function"?A:cs(!!A),m):r},m.extent=function(A){return arguments.length?(t=typeof A=="function"?A:cs([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),m):t},m.scaleExtent=function(A){return arguments.length?(o[0]=+A[0],o[1]=+A[1],m):[o[0],o[1]]},m.translateExtent=function(A){return arguments.length?(s[0][0]=+A[0][0],s[1][0]=+A[1][0],s[0][1]=+A[0][1],s[1][1]=+A[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(A){return arguments.length?(e=A,m):e},m.duration=function(A){return arguments.length?(a=+A,m):a},m.interpolate=function(A){return arguments.length?(c=A,m):c},m.on=function(){var A=l.on.apply(l,arguments);return A===l?m:A},m.clickDistance=function(A){return arguments.length?(y=(A=+A)*A,m):Math.sqrt(y)},m.tapDistance=function(A){return arguments.length?(g=+A,m):g},m}class Mf{constructor(t,e,i,r,o){this.resetButton=null,this.selectionRect=null,this.selectionStart=null,this.resetClickHandler=null;const s=typeof t=="string"?{type:t}:t;this.zoomKey=s.key,this.panKey=s.panKey,this.plotGroup=e;const a=s.panning;typeof a=="object"?(this.panningEnabled=a.enabled!==!1,this.panningType=a.type||s.type):(this.panningEnabled=a===!0,this.panningType=s.type);const c=this.isMouseWheelEnabled(s.mouseWheel),l=this.getMouseWheelSensitivity(s.mouseWheel);this.zoomBehavior=kf().scaleExtent([1,20]).extent([[0,0],[i.width,i.height]]).translateExtent([[0,0],[i.width,i.height]]).on("zoom",f=>{const u=f.transform;o.emit("zoom:changed",{type:s.type,transform:u})});const h=!!s.selectionHandler;this.zoomBehavior.filter(f=>f.type==="wheel"?c:f.type==="mousedown"||f.type==="touchstart"?h?!1:this.zoomKey?this.isKeyPressed(f,this.zoomKey):!0:!0),e.call(this.zoomBehavior),l!==1&&c&&e.on("wheel.zoom",f=>{f.preventDefault();const u=e.node().__zoom||Cr,d=f.deltaY>0?1/(1+.1*l):1+.1*l,p=Math.max(1,Math.min(20,u.k*d));e.transition().duration(100).call(this.zoomBehavior.scaleTo,p)}),s.selectionHandler&&this.setupSelectionZoom(e,i,s,o),this.panningEnabled&&this.panKey&&this.setupPanning(e,i,o),this.resetButton=this.createResetButton(s.resetButton),this.resetClickHandler=()=>{e.transition().duration(300).call(this.zoomBehavior.transform,Cr),this.resetButton.style.display="none"},this.resetButton.addEventListener("click",this.resetClickHandler),r.appendChild(this.resetButton),o.on("zoom:changed",()=>{this.resetButton&&(this.resetButton.style.display="block")})}setupSelectionZoom(t,e,i,r){t.on("mousedown.selection",o=>{if(this.zoomKey&&!this.isKeyPressed(o,this.zoomKey)||this.panKey&&this.isKeyPressed(o,this.panKey))return;const s=t.node().getBoundingClientRect();this.selectionStart={x:o.clientX-s.left,y:o.clientY-s.top};const a=i.selectionMarkerFill||"rgba(51,92,173,0.25)";this.selectionRect=t.append("rect").attr("class","katucharts-selection").attr("fill",a).attr("stroke","#4572a7").attr("stroke-width",1).attr("x",this.selectionStart.x).attr("y",0).attr("width",0).attr("height",e.height)}),t.on("mousemove.selection",o=>{if(!this.selectionStart||!this.selectionRect)return;const s=t.node().getBoundingClientRect(),a=o.clientX-s.left,c=Math.min(this.selectionStart.x,a),l=Math.abs(a-this.selectionStart.x);if(this.selectionRect.attr("x",c).attr("width",l),i.type==="xy"||i.type==="y"){const h=o.clientY-s.top,f=Math.min(this.selectionStart.y,h),u=Math.abs(h-this.selectionStart.y);this.selectionRect.attr("y",f).attr("height",u)}}),t.on("mouseup.selection",o=>{if(!this.selectionStart||!this.selectionRect)return;const s=t.node().getBoundingClientRect(),a=o.clientX-s.left,c=o.clientY-s.top;if(this.selectionRect.remove(),this.selectionRect=null,Math.abs(a-this.selectionStart.x)<5){this.selectionStart=null;return}let l=!1;const h={xAxis:[{min:Math.min(this.selectionStart.x,a),max:Math.max(this.selectionStart.x,a)}],yAxis:[{min:Math.min(this.selectionStart.y,c),max:Math.max(this.selectionStart.y,c)}],originalEvent:o,preventDefault:()=>{l=!0}};i.selectionHandler&&i.selectionHandler(h),l||r.emit("chart:selection",h),this.selectionStart=null})}setupPanning(t,e,i){let r=null,o={x:0,y:0};t.on("mousedown.pan",s=>{!this.panKey||!this.isKeyPressed(s,this.panKey)||(s.preventDefault(),r={x:s.clientX-o.x,y:s.clientY-o.y},t.style("cursor","grabbing"))}),t.on("mousemove.pan",s=>{if(!r)return;let a=s.clientX-r.x,c=s.clientY-r.y;this.panningType==="x"&&(c=0),this.panningType==="y"&&(a=0),o={x:a,y:c},i.emit("zoom:panned",{dx:a,dy:c,type:this.panningType})}),t.on("mouseup.pan",()=>{r&&(r=null,t.style("cursor",""))})}isKeyPressed(t,e){switch(e){case"ctrl":return t.ctrlKey;case"alt":return t.altKey;case"shift":return t.shiftKey;case"meta":return t.metaKey;default:return!0}}isMouseWheelEnabled(t){return t===!0||typeof t=="object"&&t.enabled!==!1}getMouseWheelSensitivity(t){return typeof t=="object"&&t.sensitivity!==void 0?t.sensitivity:1}createResetButton(t){const e=document.createElement("button");e.textContent="Reset zoom";const i=(t==null?void 0:t.theme)||{},r=(t==null?void 0:t.position)||{},o=r.y??5,s=r.x!==void 0?`${r.x}px`:"5px";return Object.assign(e.style,{position:"absolute",top:`${o}px`,right:s,padding:i.padding||"3px 8px",fontSize:i.fontSize||"11px",border:i.border||"1px solid #ccc",borderRadius:i.borderRadius||"3px",backgroundColor:i.backgroundColor||"#f9f9f9",color:i.color||"#333",cursor:"pointer",display:"none",zIndex:"5"}),e}setResetHandler(t){this.resetButton&&(this.resetClickHandler&&this.resetButton.removeEventListener("click",this.resetClickHandler),this.resetClickHandler=t,this.resetButton.addEventListener("click",this.resetClickHandler))}setResetButtonVisible(t){this.resetButton&&(this.resetButton.style.display=t?"block":"none")}resetTransform(){const t=this.plotGroup.node();t&&(t.__zoom=Cr)}destroy(){this.resetButton&&(this.resetClickHandler&&this.resetButton.removeEventListener("click",this.resetClickHandler),this.resetButton.remove())}}class Af{constructor(t){this.lastSeriesCount=0,this.lastPointCounts=[],this.config=t}apply(t,e,i){var s,a;if(this.config.enabled===!1)return;const r=this.config.landmarkVerbosity||"all";t.attr("role","img"),i&&t.attr("aria-label",this.config.description||`Chart: ${i}`);const o="katucharts-desc-"+Math.random().toString(36).slice(2,8);t.append("desc").attr("id",o).text(this.config.description||this.generateDescription(e,i)),t.attr("aria-describedby",o),t.attr("tabindex","0"),t.style("outline","none"),this.renderScreenReaderSections(t,e,i),this.applyLandmarks(t,e,r),((s=this.config.keyboardNavigation)==null?void 0:s.enabled)!==!1&&this.setupKeyboardNav(t,e),(a=this.config.announceNewData)!=null&&a.enabled&&this.setupAnnounceNewData(e)}setupAnnounceNewData(t){var o;const e=((o=this.config.announceNewData)==null?void 0:o.minAnnounceInterval)??5e3;let i=0;this.lastSeriesCount=t.length,this.lastPointCounts=t.map(s=>s.data.length),setInterval(()=>{const s=Date.now();if(s-i<e)return;let a=!1,c="";if(t.length!==this.lastSeriesCount)a=!0,c=`Chart updated. Now showing ${t.length} data series.`;else for(let l=0;l<t.length;l++){const h=t[l].data.length,f=this.lastPointCounts[l]??0;if(h!==f){a=!0;const u=h-f;c=`${t[l].config.name||"Series"} updated with ${Math.abs(u)} ${u>0?"new":"fewer"} point${Math.abs(u)!==1?"s":""}. Total: ${h}.`;break}}a&&(this.announce(c),i=s,this.lastSeriesCount=t.length,this.lastPointCounts=t.map(l=>l.data.length))},Math.max(1e3,e/2))}renderScreenReaderSections(t,e,i){var s;const r=this.config.screenReaderSection,o=(s=t.node())==null?void 0:s.parentElement;if(o){if(r!=null&&r.beforeChartFormat){const a=this.createScreenReaderDiv(this.formatSectionTemplate(r.beforeChartFormat,e,i));o.insertBefore(a,t.node())}if(r!=null&&r.afterChartFormat){const a=this.createScreenReaderDiv(this.formatSectionTemplate(r.afterChartFormat,e,i));o.appendChild(a)}}}createScreenReaderDiv(t){const e=document.createElement("div");return e.className="katucharts-screen-reader-region",e.setAttribute("role","region"),e.setAttribute("aria-label","Chart information"),e.innerHTML=t,Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"}),e}formatSectionTemplate(t,e,i){return t.replace("{chartTitle}",Jn(i||"Chart")).replace("{numSeries}",String(e.length)).replace("{seriesList}",e.map(r=>Jn(r.config.name||"Series")).join(", "))}applyLandmarks(t,e,i){if(i==="disabled")return;if(i==="one"){t.attr("role","region");return}t.selectAll(".katucharts-legend").attr("role","region").attr("aria-label","Chart legend");const r=this.config.series,o=(r==null?void 0:r.describeSingleSeries)??!1;e.length===1&&!o||e.forEach((s,a)=>{const c=s.group;if(c){const l=s.config.name||`Series ${a+1}`,h=r==null?void 0:r.descriptionFormat,f=h?h.replace("{name}",l).replace("{index}",String(a)):`${l}, ${s.data.length} data points`;c.attr("role","region").attr("aria-label",f)}})}generateDescription(t,e){const i=[];e&&i.push(`${e}.`),i.push(`Chart with ${t.length} data series.`);for(const r of t){const o=r.config.name||`Series ${r.config.index+1}`,s=r.data.length;i.push(`${o}: ${s} data points.`)}return i.join(" ")}setupKeyboardNav(t,e){let i=0,r=0;t.on("keydown",o=>{const s=e[i];if(s)switch(o.key){case"ArrowRight":o.preventDefault(),r=Math.min(r+1,s.data.length-1),this.announcePoint(s,r);break;case"ArrowLeft":o.preventDefault(),r=Math.max(r-1,0),this.announcePoint(s,r);break;case"ArrowUp":o.preventDefault(),i=Math.max(i-1,0),r=0,this.announceSeries(e[i]);break;case"ArrowDown":o.preventDefault(),i=Math.min(i+1,e.length-1),r=0,this.announceSeries(e[i]);break;case"Enter":case" ":o.preventDefault(),this.announcePoint(s,r);break}})}announcePoint(t,e){var o,s;const i=t.data[e];if(!i)return;let r;(o=this.config.point)!=null&&o.descriptionFormatter?r=this.config.point.descriptionFormatter(i):(s=this.config.point)!=null&&s.valueDescriptionFormat?r=this.config.point.valueDescriptionFormat.replace("{index}",String(e+1)).replace("{value}",String(i.y??"")).replace("{xDescription}",i.name||String(i.x??"")).replace("{point.name}",i.name||"").replace("{point.y}",String(i.y??"")).replace("{point.x}",String(i.x??"")).replace("{series.name}",t.config.name||"Series"):r=`${t.config.name||"Series"}, point ${e+1}: ${i.name?i.name+", ":""}value ${i.y}`,this.announce(r)}announceSeries(t){const e=`${t.config.name||"Series"}, ${t.data.length} points`;this.announce(e)}announce(t){let e=document.getElementById("katucharts-announcer");e||(e=document.createElement("div"),e.id="katucharts-announcer",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"}),document.body.appendChild(e)),e.textContent=t}}class i2{constructor(t){this.host=t,this.drilldown=null,this.zoom=null,this.a11yModule=null,this.origXDomains=[],this.origYDomains=[],this.isBoxZoomed=!1}setup(){this.setupSeriesDimming(),this.setupDrilldown(),this.setupZoom(),this.setupAccessibility()}destroy(){var t,e;(t=this.drilldown)==null||t.destroy(),(e=this.zoom)==null||e.destroy()}setupSeriesDimming(){var s,a,c,l;const t=this.host.getEvents(),e=((l=(c=(a=(s=this.host.getOptions().plotOptions)==null?void 0:s.series)==null?void 0:a.states)==null?void 0:c.inactive)==null?void 0:l.opacity)??.2;let i=null;const r=h=>{var f,u,d,p,y,g,m,x,v,b;i&&(clearTimeout(i),i=null);for(const k of this.host.getSeriesInstances())(u=(f=k.group)==null?void 0:f.interrupt)==null||u.call(f,"seriesDim"),k!==h&&k.visible?(x=(m=(g=(y=(p=(d=k.group)==null?void 0:d.transition)==null?void 0:p.call(d,"seriesDim"))==null?void 0:y.duration)==null?void 0:g.call(y,200))==null?void 0:m.attr)==null||x.call(m,"opacity",e):(b=(v=k.group)==null?void 0:v.attr)==null||b.call(v,"opacity",k.config.opacity??1)},o=()=>{i&&clearTimeout(i),i=setTimeout(()=>{var h,f,u,d,p,y,g,m;for(const x of this.host.getSeriesInstances())(f=(h=x.group)==null?void 0:h.interrupt)==null||f.call(h,"seriesDim"),(m=(g=(y=(p=(d=(u=x.group)==null?void 0:u.transition)==null?void 0:d.call(u,"seriesDim"))==null?void 0:p.duration)==null?void 0:y.call(p,200))==null?void 0:g.attr)==null||m.call(g,"opacity",x.config.opacity??1);i=null},50)};t.on("series:mouseenter",r),t.on("series:mouseleave",o),t.on("legend:itemHover",r),t.on("legend:itemLeave",o)}setupDrilldown(){var l;const e=this.host.getOptions().drilldown;if(!((l=e==null?void 0:e.series)!=null&&l.length))return;const i=this.host.getEvents(),r=this.host.getSeriesGroup();this.drilldown=new bf(e,i,this.host.getContainer());const o=[],s=new Kn,a=e.animation,c=typeof a=="object"?a.duration??400:a!==!1?400:0;i.on("drilldown:drilldown",h=>{o.push([...this.host.getOptions().series]),c>0?r.transition().duration(c/2).style("opacity","0").on("end",()=>{this.performDrillSwap(h,s),r.style("opacity","0").transition().duration(c/2).style("opacity","1")}):this.performDrillSwap(h,s),this.host.fireEvent("drilldown",h)}),i.on("drilldown:drillup",()=>{const h=o.pop();h&&this.host.setSeries(h),c>0?r.transition().duration(c/2).style("opacity","0").on("end",()=>{this.host.rebuild(),r.style("opacity","0").transition().duration(c/2).style("opacity","1")}):this.host.rebuild(),this.host.fireEvent("drillup")})}performDrillSwap(t,e){const i=this.host.getOptions(),r=t.seriesOptions,o=e.parse({chart:i.chart,xAxis:i.xAxis,yAxis:i.yAxis,series:[r]});this.host.setSeries(o.series),this.host.rebuild()}setupZoom(){const t=this.host.getOptions(),e=t.chart.zooming||t.chart.zoomType;if(!e)return;const i=typeof e=="string"?e:e.type||"x",r={type:i,key:typeof e=="object"?e.key:void 0,mouseWheel:typeof e=="object"?e.mouseWheel:void 0,resetButton:typeof e=="object"?e.resetButton:void 0,panning:typeof e=="object"?e.panning:void 0,panKey:typeof e=="object"?e.panKey:void 0,pinchType:typeof e=="object"?e.pinchType:void 0,selectionMarkerFill:t.chart.selectionMarkerFill,selectionHandler:s=>this.applyBoxZoom(s,i)},o=this.host.getEvents();t.chart.scrollablePlotArea&&(r.mouseWheel=!1),this.zoom=new Mf(r,this.host.getPlotGroup(),this.host.getLayout().plotArea,this.host.getContainer(),o),this.zoom.setResetHandler(()=>this.resetBoxZoom()),o.on("zoom:changed",s=>{var f;const a=s.transform,c=s.type,l=this.host.getLayout().plotArea,h=!this.isBoxZoomed;(c==="x"||c==="xy")&&this.host.getXAxes().forEach((u,d)=>{h&&(this.origXDomains[d]=u.scale.domain());const p=this.origXDomains[d];if(!p||typeof p[0]!="number"||typeof p[1]!="number")return;const y=p[1]-p[0],g=(0-a.x)/a.k,m=(l.width-a.x)/a.k;u.updateDomain({min:p[0]+g/l.width*y,max:p[0]+m/l.width*y})}),(c==="y"||c==="xy")&&this.host.getYAxes().forEach((u,d)=>{h&&(this.origYDomains[d]=u.scale.domain());const p=this.origYDomains[d];if(!p||typeof p[0]!="number"||typeof p[1]!="number")return;const y=p[1]-p[0],g=(0-a.y)/a.k,m=(l.height-a.y)/a.k;u.updateDomain({max:p[1]-g/l.height*y,min:p[1]-m/l.height*y})}),this.isBoxZoomed=!0,(f=this.zoom)==null||f.setResetButtonVisible(!0),this.host.renderAfterZoom()})}applyBoxZoom(t,e){var r;const i=!this.isBoxZoomed;return(e==="x"||e==="xy")&&this.host.getXAxes().forEach((s,a)=>{i&&(this.origXDomains[a]=s.scale.domain());const c=s.getValueForPixel(t.xAxis[0].min),l=s.getValueForPixel(t.xAxis[0].max);c==null||l==null||!Number.isFinite(+c)||!Number.isFinite(+l)||s.updateDomain({min:Math.min(+c,+l),max:Math.max(+c,+l)})}),(e==="y"||e==="xy")&&this.host.getYAxes().forEach((s,a)=>{i&&(this.origYDomains[a]=s.scale.domain());const c=s.getValueForPixel(t.yAxis[0].min),l=s.getValueForPixel(t.yAxis[0].max);c==null||l==null||!Number.isFinite(+c)||!Number.isFinite(+l)||s.updateDomain({min:Math.min(+c,+l),max:Math.max(+c,+l)})}),this.isBoxZoomed=!0,(r=this.zoom)==null||r.setResetButtonVisible(!0),this.host.renderAfterZoom(),this.host.getEvents().emit("chart:afterZoom"),!0}resetBoxZoom(){var t,e;this.isBoxZoomed&&(this.host.getXAxes().forEach((i,r)=>{const o=this.origXDomains[r];o&&i.updateDomain({min:o[0],max:o[1]})}),this.host.getYAxes().forEach((i,r)=>{const o=this.origYDomains[r];o&&i.updateDomain({min:o[0],max:o[1]})}),this.isBoxZoomed=!1,this.origXDomains=[],this.origYDomains=[],(t=this.zoom)==null||t.resetTransform(),(e=this.zoom)==null||e.setResetButtonVisible(!1),this.host.renderAfterZoom(),this.host.getEvents().emit("chart:afterZoom"))}setupAccessibility(){var i;const t=this.host.getOptions(),e=t.accessibility;!e||e.enabled===!1||(this.a11yModule=new Af(e),this.a11yModule.apply(this.host.getRenderer().svg,this.host.getSeriesInstances(),((i=t.title)==null?void 0:i.text)??void 0))}}const mc=n=>()=>n;function r2(n,{sourceEvent:t,target:e,selection:i,mode:r,dispatch:o}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:i,enumerable:!0,configurable:!0},mode:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function o2(n){n.stopImmediatePropagation()}function yc(n){n.preventDefault(),n.stopImmediatePropagation()}var Sf={name:"drag"},xc={name:"space"},Yi={name:"handle"},Xi={name:"center"};const{abs:_f,max:Me,min:Ae}=Math;function Cf(n){return[+n[0],+n[1]]}function Pf(n){return[Cf(n[0]),Cf(n[1])]}var ls={name:"x",handles:["w","e"].map(vc),input:function(n,t){return n==null?null:[[+n[0],t[0][1]],[+n[1],t[1][1]]]},output:function(n){return n&&[n[0][0],n[1][0]]}},bc={},Wn={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ef={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},Tf={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},s2={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},a2={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function vc(n){return{type:n}}function c2(n){return!n.ctrlKey&&!n.button}function l2(){var n=this.ownerSVGElement||this;return n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]}function h2(){return navigator.maxTouchPoints||"ontouchstart"in this}function wc(n){for(;!n.__brush;)if(!(n=n.parentNode))return;return n.__brush}function u2(n){return n[0][0]===n[1][0]||n[0][1]===n[1][1]}function f2(){return d2(ls)}function d2(n){var t=l2,e=c2,i=h2,r=!0,o=Oi("start","brush","end"),s=6,a;function c(g){var m=g.property("__brush",y).selectAll(".overlay").data([vc("overlay")]);m.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Wn.overlay).merge(m).each(function(){var v=wc(this).extent;st(this).attr("x",v[0][0]).attr("y",v[0][1]).attr("width",v[1][0]-v[0][0]).attr("height",v[1][1]-v[0][1])}),g.selectAll(".selection").data([vc("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Wn.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var x=g.selectAll(".handle").data(n.handles,function(v){return v.type});x.exit().remove(),x.enter().append("rect").attr("class",function(v){return"handle handle--"+v.type}).attr("cursor",function(v){return Wn[v.type]}),g.each(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",u).filter(i).on("touchstart.brush",u).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}c.move=function(g,m,x){g.tween?g.on("start.brush",function(v){h(this,arguments).beforestart().start(v)}).on("interrupt.brush end.brush",function(v){h(this,arguments).end(v)}).tween("brush",function(){var v=this,b=v.__brush,k=h(v,arguments),M=b.selection,C=n.input(typeof m=="function"?m.apply(this,arguments):m,b.extent),E=he(M,C);function _(T){b.selection=T===1&&C===null?null:E(T),l.call(v),k.brush()}return M!==null&&C!==null?_:_(1)}):g.each(function(){var v=this,b=arguments,k=v.__brush,M=n.input(typeof m=="function"?m.apply(v,b):m,k.extent),C=h(v,b).beforestart();Wi(v),k.selection=M===null?null:M,l.call(v),C.start(x).brush(x).end(x)})},c.clear=function(g,m){c.move(g,null,m)};function l(){var g=st(this),m=wc(this).selection;m?(g.selectAll(".selection").style("display",null).attr("x",m[0][0]).attr("y",m[0][1]).attr("width",m[1][0]-m[0][0]).attr("height",m[1][1]-m[0][1]),g.selectAll(".handle").style("display",null).attr("x",function(x){return x.type[x.type.length-1]==="e"?m[1][0]-s/2:m[0][0]-s/2}).attr("y",function(x){return x.type[0]==="s"?m[1][1]-s/2:m[0][1]-s/2}).attr("width",function(x){return x.type==="n"||x.type==="s"?m[1][0]-m[0][0]+s:s}).attr("height",function(x){return x.type==="e"||x.type==="w"?m[1][1]-m[0][1]+s:s})):g.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function h(g,m,x){var v=g.__brush.emitter;return v&&(!x||!v.clean)?v:new f(g,m,x)}function f(g,m,x){this.that=g,this.args=m,this.state=g.__brush,this.active=0,this.clean=x}f.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(g,m){return this.starting?(this.starting=!1,this.emit("start",g,m)):this.emit("brush",g),this},brush:function(g,m){return this.emit("brush",g,m),this},end:function(g,m){return--this.active===0&&(delete this.state.emitter,this.emit("end",g,m)),this},emit:function(g,m,x){var v=st(this.that).datum();o.call(g,this.that,new r2(g,{sourceEvent:m,target:c,selection:n.output(this.state.selection),mode:x,dispatch:o}),v)}};function u(g){if(a&&!g.touches||!e.apply(this,arguments))return;var m=this,x=g.target.__data__.type,v=(r&&g.metaKey?x="overlay":x)==="selection"?Sf:r&&g.altKey?Xi:Yi,b=n===bc?null:s2[x],k=n===ls?null:a2[x],M=wc(m),C=M.extent,E=M.selection,_=C[0][0],T,I,L=C[0][1],P,A,w=C[1][0],S,$,R=C[1][1],F,D,z=0,B=0,W,K=b&&k&&r&&g.shiftKey,X,q,N=Array.from(g.touches||[g],ct=>{const nt=ct.identifier;return ct=mn(ct,m),ct.point0=ct.slice(),ct.identifier=nt,ct});Wi(m);var H=h(m,arguments,!0).beforestart();if(x==="overlay"){E&&(W=!0);const ct=[N[0],N[1]||N[0]];M.selection=E=[[T=n===bc?_:Ae(ct[0][0],ct[1][0]),P=n===ls?L:Ae(ct[0][1],ct[1][1])],[S=n===bc?w:Me(ct[0][0],ct[1][0]),F=n===ls?R:Me(ct[0][1],ct[1][1])]],N.length>1&&it(g)}else T=E[0][0],P=E[0][1],S=E[1][0],F=E[1][1];I=T,A=P,$=S,D=F;var Y=st(m).attr("pointer-events","none"),G=Y.selectAll(".overlay").attr("cursor",Wn[x]);if(g.touches)H.moved=O,H.ended=et;else{var Q=st(g.view).on("mousemove.brush",O,!0).on("mouseup.brush",et,!0);r&&Q.on("keydown.brush",ht,!0).on("keyup.brush",ft,!0),fc(g.view)}l.call(m),H.start(g,v.name);function O(ct){for(const nt of ct.changedTouches||[ct])for(const U of N)U.identifier===nt.identifier&&(U.cur=mn(nt,m));if(K&&!X&&!q&&N.length===1){const nt=N[0];_f(nt.cur[0]-nt[0])>_f(nt.cur[1]-nt[1])?q=!0:X=!0}for(const nt of N)nt.cur&&(nt[0]=nt.cur[0],nt[1]=nt.cur[1]);W=!0,yc(ct),it(ct)}function it(ct){const nt=N[0],U=nt.point0;var at;switch(z=nt[0]-U[0],B=nt[1]-U[1],v){case xc:case Sf:{b&&(z=Me(_-T,Ae(w-S,z)),I=T+z,$=S+z),k&&(B=Me(L-P,Ae(R-F,B)),A=P+B,D=F+B);break}case Yi:{N[1]?(b&&(I=Me(_,Ae(w,N[0][0])),$=Me(_,Ae(w,N[1][0])),b=1),k&&(A=Me(L,Ae(R,N[0][1])),D=Me(L,Ae(R,N[1][1])),k=1)):(b<0?(z=Me(_-T,Ae(w-T,z)),I=T+z,$=S):b>0&&(z=Me(_-S,Ae(w-S,z)),I=T,$=S+z),k<0?(B=Me(L-P,Ae(R-P,B)),A=P+B,D=F):k>0&&(B=Me(L-F,Ae(R-F,B)),A=P,D=F+B));break}case Xi:{b&&(I=Me(_,Ae(w,T-z*b)),$=Me(_,Ae(w,S+z*b))),k&&(A=Me(L,Ae(R,P-B*k)),D=Me(L,Ae(R,F+B*k)));break}}$<I&&(b*=-1,at=T,T=S,S=at,at=I,I=$,$=at,x in Ef&&G.attr("cursor",Wn[x=Ef[x]])),D<A&&(k*=-1,at=P,P=F,F=at,at=A,A=D,D=at,x in Tf&&G.attr("cursor",Wn[x=Tf[x]])),M.selection&&(E=M.selection),X&&(I=E[0][0],$=E[1][0]),q&&(A=E[0][1],D=E[1][1]),(E[0][0]!==I||E[0][1]!==A||E[1][0]!==$||E[1][1]!==D)&&(M.selection=[[I,A],[$,D]],l.call(m),H.brush(ct,v.name))}function et(ct){if(o2(ct),ct.touches){if(ct.touches.length)return;a&&clearTimeout(a),a=setTimeout(function(){a=null},500)}else dc(ct.view,W),Q.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);Y.attr("pointer-events","all"),G.attr("cursor",Wn.overlay),M.selection&&(E=M.selection),u2(E)&&(M.selection=null,l.call(m)),H.end(ct,v.name)}function ht(ct){switch(ct.keyCode){case 16:{K=b&&k;break}case 18:{v===Yi&&(b&&(S=$-z*b,T=I+z*b),k&&(F=D-B*k,P=A+B*k),v=Xi,it(ct));break}case 32:{(v===Yi||v===Xi)&&(b<0?S=$-z:b>0&&(T=I-z),k<0?F=D-B:k>0&&(P=A-B),v=xc,G.attr("cursor",Wn.selection),it(ct));break}default:return}yc(ct)}function ft(ct){switch(ct.keyCode){case 16:{K&&(X=q=K=!1,it(ct));break}case 18:{v===Xi&&(b<0?S=$:b>0&&(T=I),k<0?F=D:k>0&&(P=A),v=Yi,it(ct));break}case 32:{v===xc&&(ct.altKey?(b&&(S=$-z*b,T=I+z*b),k&&(F=D-B*k,P=A+B*k),v=Xi):(b<0?S=$:b>0&&(T=I),k<0?F=D:k>0&&(P=A),v=Yi),G.attr("cursor",Wn[x]),it(ct));break}default:return}yc(ct)}}function d(g){h(this,arguments).moved(g)}function p(g){h(this,arguments).ended(g)}function y(){var g=this.__brush||{selection:null};return g.extent=Pf(t.apply(this,arguments)),g.dim=n,g}return c.extent=function(g){return arguments.length?(t=typeof g=="function"?g:mc(Pf(g)),c):t},c.filter=function(g){return arguments.length?(e=typeof g=="function"?g:mc(!!g),c):e},c.touchable=function(g){return arguments.length?(i=typeof g=="function"?g:mc(!!g),c):i},c.handleSize=function(g){return arguments.length?(s=+g,c):s},c.keyModifiers=function(g){return arguments.length?(r=!!g,c):r},c.on=function(){var g=o.on.apply(o,arguments);return g===o?c:g},c}function Rt(n){return function(){return n}}const Lf=Math.abs,Se=Math.atan2,ki=Math.cos,p2=Math.max,kc=Math.min,Sn=Math.sin,Ie=Math.sqrt,_e=1e-12,Ui=Math.PI,hs=Ui/2,Er=2*Ui;function g2(n){return n>1?0:n<-1?Ui:Math.acos(n)}function $f(n){return n>=1?hs:n<=-1?-hs:Math.asin(n)}const Mc=Math.PI,Ac=2*Mc,Mi=1e-6,m2=Ac-Mi;function If(n){this._+=n[0];for(let t=1,e=n.length;t<e;++t)this._+=arguments[t]+n[t]}function y2(n){let t=Math.floor(n);if(!(t>=0))throw new Error(`invalid digits: ${n}`);if(t>15)return If;const e=10**t;return function(i){this._+=i[0];for(let r=1,o=i.length;r<o;++r)this._+=Math.round(arguments[r]*e)/e+i[r]}}let x2=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?If:y2(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,i,r){this._append`Q${+t},${+e},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,e,i,r,o,s){this._append`C${+t},${+e},${+i},${+r},${this._x1=+o},${this._y1=+s}`}arcTo(t,e,i,r,o){if(t=+t,e=+e,i=+i,r=+r,o=+o,o<0)throw new Error(`negative radius: ${o}`);let s=this._x1,a=this._y1,c=i-t,l=r-e,h=s-t,f=a-e,u=h*h+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=e}`;else if(u>Mi)if(!(Math.abs(f*c-l*h)>Mi)||!o)this._append`L${this._x1=t},${this._y1=e}`;else{let d=i-s,p=r-a,y=c*c+l*l,g=d*d+p*p,m=Math.sqrt(y),x=Math.sqrt(u),v=o*Math.tan((Mc-Math.acos((y+u-g)/(2*m*x)))/2),b=v/x,k=v/m;Math.abs(b-1)>Mi&&this._append`L${t+b*h},${e+b*f}`,this._append`A${o},${o},0,0,${+(f*d>h*p)},${this._x1=t+k*c},${this._y1=e+k*l}`}}arc(t,e,i,r,o,s){if(t=+t,e=+e,i=+i,s=!!s,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),l=t+a,h=e+c,f=1^s,u=s?r-o:o-r;this._x1===null?this._append`M${l},${h}`:(Math.abs(this._x1-l)>Mi||Math.abs(this._y1-h)>Mi)&&this._append`L${l},${h}`,i&&(u<0&&(u=u%Ac+Ac),u>m2?this._append`A${i},${i},0,1,${f},${t-a},${e-c}A${i},${i},0,1,${f},${this._x1=l},${this._y1=h}`:u>Mi&&this._append`A${i},${i},0,${+(u>=Mc)},${f},${this._x1=t+i*Math.cos(o)},${this._y1=e+i*Math.sin(o)}`)}rect(t,e,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}};function Tr(n){let t=3;return n.digits=function(e){if(!arguments.length)return t;if(e==null)t=null;else{const i=Math.floor(e);if(!(i>=0))throw new RangeError(`invalid digits: ${e}`);t=i}return n},()=>new x2(t)}function b2(n){return n.innerRadius}function v2(n){return n.outerRadius}function w2(n){return n.startAngle}function k2(n){return n.endAngle}function M2(n){return n&&n.padAngle}function A2(n,t,e,i,r,o,s,a){var c=e-n,l=i-t,h=s-r,f=a-o,u=f*c-h*l;if(!(u*u<_e))return u=(h*(t-o)-f*(n-r))/u,[n+u*c,t+u*l]}function us(n,t,e,i,r,o,s){var a=n-e,c=t-i,l=(s?o:-o)/Ie(a*a+c*c),h=l*c,f=-l*a,u=n+h,d=t+f,p=e+h,y=i+f,g=(u+p)/2,m=(d+y)/2,x=p-u,v=y-d,b=x*x+v*v,k=r-o,M=u*y-p*d,C=(v<0?-1:1)*Ie(p2(0,k*k*b-M*M)),E=(M*v-x*C)/b,_=(-M*x-v*C)/b,T=(M*v+x*C)/b,I=(-M*x+v*C)/b,L=E-g,P=_-m,A=T-g,w=I-m;return L*L+P*P>A*A+w*w&&(E=T,_=I),{cx:E,cy:_,x01:-h,y01:-f,x11:E*(r/k-1),y11:_*(r/k-1)}}function Ce(){var n=b2,t=v2,e=Rt(0),i=null,r=w2,o=k2,s=M2,a=null,c=Tr(l);function l(){var h,f,u=+n.apply(this,arguments),d=+t.apply(this,arguments),p=r.apply(this,arguments)-hs,y=o.apply(this,arguments)-hs,g=Lf(y-p),m=y>p;if(a||(a=h=c()),d<u&&(f=d,d=u,u=f),!(d>_e))a.moveTo(0,0);else if(g>Er-_e)a.moveTo(d*ki(p),d*Sn(p)),a.arc(0,0,d,p,y,!m),u>_e&&(a.moveTo(u*ki(y),u*Sn(y)),a.arc(0,0,u,y,p,m));else{var x=p,v=y,b=p,k=y,M=g,C=g,E=s.apply(this,arguments)/2,_=E>_e&&(i?+i.apply(this,arguments):Ie(u*u+d*d)),T=kc(Lf(d-u)/2,+e.apply(this,arguments)),I=T,L=T,P,A;if(_>_e){var w=$f(_/u*Sn(E)),S=$f(_/d*Sn(E));(M-=w*2)>_e?(w*=m?1:-1,b+=w,k-=w):(M=0,b=k=(p+y)/2),(C-=S*2)>_e?(S*=m?1:-1,x+=S,v-=S):(C=0,x=v=(p+y)/2)}var $=d*ki(x),R=d*Sn(x),F=u*ki(k),D=u*Sn(k);if(T>_e){var z=d*ki(v),B=d*Sn(v),W=u*ki(b),K=u*Sn(b),X;if(g<Ui)if(X=A2($,R,W,K,z,B,F,D)){var q=$-X[0],N=R-X[1],H=z-X[0],Y=B-X[1],G=1/Sn(g2((q*H+N*Y)/(Ie(q*q+N*N)*Ie(H*H+Y*Y)))/2),Q=Ie(X[0]*X[0]+X[1]*X[1]);I=kc(T,(u-Q)/(G-1)),L=kc(T,(d-Q)/(G+1))}else I=L=0}C>_e?L>_e?(P=us(W,K,$,R,d,L,m),A=us(z,B,F,D,d,L,m),a.moveTo(P.cx+P.x01,P.cy+P.y01),L<T?a.arc(P.cx,P.cy,L,Se(P.y01,P.x01),Se(A.y01,A.x01),!m):(a.arc(P.cx,P.cy,L,Se(P.y01,P.x01),Se(P.y11,P.x11),!m),a.arc(0,0,d,Se(P.cy+P.y11,P.cx+P.x11),Se(A.cy+A.y11,A.cx+A.x11),!m),a.arc(A.cx,A.cy,L,Se(A.y11,A.x11),Se(A.y01,A.x01),!m))):(a.moveTo($,R),a.arc(0,0,d,x,v,!m)):a.moveTo($,R),!(u>_e)||!(M>_e)?a.lineTo(F,D):I>_e?(P=us(F,D,z,B,u,-I,m),A=us($,R,W,K,u,-I,m),a.lineTo(P.cx+P.x01,P.cy+P.y01),I<T?a.arc(P.cx,P.cy,I,Se(P.y01,P.x01),Se(A.y01,A.x01),!m):(a.arc(P.cx,P.cy,I,Se(P.y01,P.x01),Se(P.y11,P.x11),!m),a.arc(0,0,u,Se(P.cy+P.y11,P.cx+P.x11),Se(A.cy+A.y11,A.cx+A.x11),m),a.arc(A.cx,A.cy,I,Se(A.y11,A.x11),Se(A.y01,A.x01),!m))):a.arc(0,0,u,k,b,m)}if(a.closePath(),h)return a=null,h+""||null}return l.centroid=function(){var h=(+n.apply(this,arguments)+ +t.apply(this,arguments))/2,f=(+r.apply(this,arguments)+ +o.apply(this,arguments))/2-Ui/2;return[ki(f)*h,Sn(f)*h]},l.innerRadius=function(h){return arguments.length?(n=typeof h=="function"?h:Rt(+h),l):n},l.outerRadius=function(h){return arguments.length?(t=typeof h=="function"?h:Rt(+h),l):t},l.cornerRadius=function(h){return arguments.length?(e=typeof h=="function"?h:Rt(+h),l):e},l.padRadius=function(h){return arguments.length?(i=h==null?null:typeof h=="function"?h:Rt(+h),l):i},l.startAngle=function(h){return arguments.length?(r=typeof h=="function"?h:Rt(+h),l):r},l.endAngle=function(h){return arguments.length?(o=typeof h=="function"?h:Rt(+h),l):o},l.padAngle=function(h){return arguments.length?(s=typeof h=="function"?h:Rt(+h),l):s},l.context=function(h){return arguments.length?(a=h??null,l):a},l}var S2=Array.prototype.slice;function Sc(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function Ff(n){this._context=n}Ff.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;default:this._context.lineTo(n,t);break}}};function ji(n){return new Ff(n)}function _c(n){return n[0]}function Cc(n){return n[1]}function Ai(n,t){var e=Rt(!0),i=null,r=ji,o=null,s=Tr(a);n=typeof n=="function"?n:n===void 0?_c:Rt(n),t=typeof t=="function"?t:t===void 0?Cc:Rt(t);function a(c){var l,h=(c=Sc(c)).length,f,u=!1,d;for(i==null&&(o=r(d=s())),l=0;l<=h;++l)!(l<h&&e(f=c[l],l,c))===u&&((u=!u)?o.lineStart():o.lineEnd()),u&&o.point(+n(f,l,c),+t(f,l,c));if(d)return o=null,d+""||null}return a.x=function(c){return arguments.length?(n=typeof c=="function"?c:Rt(+c),a):n},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Rt(+c),a):t},a.defined=function(c){return arguments.length?(e=typeof c=="function"?c:Rt(!!c),a):e},a.curve=function(c){return arguments.length?(r=c,i!=null&&(o=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=o=null:o=r(i=c),a):i},a}function qi(n,t,e){var i=null,r=Rt(!0),o=null,s=ji,a=null,c=Tr(l);n=typeof n=="function"?n:n===void 0?_c:Rt(+n),t=typeof t=="function"?t:Rt(t===void 0?0:+t),e=typeof e=="function"?e:e===void 0?Cc:Rt(+e);function l(f){var u,d,p,y=(f=Sc(f)).length,g,m=!1,x,v=new Array(y),b=new Array(y);for(o==null&&(a=s(x=c())),u=0;u<=y;++u){if(!(u<y&&r(g=f[u],u,f))===m)if(m=!m)d=u,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),p=u-1;p>=d;--p)a.point(v[p],b[p]);a.lineEnd(),a.areaEnd()}m&&(v[u]=+n(g,u,f),b[u]=+t(g,u,f),a.point(i?+i(g,u,f):v[u],e?+e(g,u,f):b[u]))}if(x)return a=null,x+""||null}function h(){return Ai().defined(r).curve(s).context(o)}return l.x=function(f){return arguments.length?(n=typeof f=="function"?f:Rt(+f),i=null,l):n},l.x0=function(f){return arguments.length?(n=typeof f=="function"?f:Rt(+f),l):n},l.x1=function(f){return arguments.length?(i=f==null?null:typeof f=="function"?f:Rt(+f),l):i},l.y=function(f){return arguments.length?(t=typeof f=="function"?f:Rt(+f),e=null,l):t},l.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Rt(+f),l):t},l.y1=function(f){return arguments.length?(e=f==null?null:typeof f=="function"?f:Rt(+f),l):e},l.lineX0=l.lineY0=function(){return h().x(n).y(t)},l.lineY1=function(){return h().x(n).y(e)},l.lineX1=function(){return h().x(i).y(t)},l.defined=function(f){return arguments.length?(r=typeof f=="function"?f:Rt(!!f),l):r},l.curve=function(f){return arguments.length?(s=f,o!=null&&(a=s(o)),l):s},l.context=function(f){return arguments.length?(f==null?o=a=null:a=s(o=f),l):o},l}function _2(n,t){return t<n?-1:t>n?1:t>=n?0:NaN}function C2(n){return n}function P2(){var n=C2,t=_2,e=null,i=Rt(0),r=Rt(Er),o=Rt(0);function s(a){var c,l=(a=Sc(a)).length,h,f,u=0,d=new Array(l),p=new Array(l),y=+i.apply(this,arguments),g=Math.min(Er,Math.max(-Er,r.apply(this,arguments)-y)),m,x=Math.min(Math.abs(g)/l,o.apply(this,arguments)),v=x*(g<0?-1:1),b;for(c=0;c<l;++c)(b=p[d[c]=c]=+n(a[c],c,a))>0&&(u+=b);for(t!=null?d.sort(function(k,M){return t(p[k],p[M])}):e!=null&&d.sort(function(k,M){return e(a[k],a[M])}),c=0,f=u?(g-l*v)/u:0;c<l;++c,y=m)h=d[c],b=p[h],m=y+(b>0?b*f:0)+v,p[h]={data:a[h],index:c,value:b,startAngle:y,endAngle:m,padAngle:x};return p}return s.value=function(a){return arguments.length?(n=typeof a=="function"?a:Rt(+a),s):n},s.sortValues=function(a){return arguments.length?(t=a,e=null,s):t},s.sort=function(a){return arguments.length?(e=a,t=null,s):e},s.startAngle=function(a){return arguments.length?(i=typeof a=="function"?a:Rt(+a),s):i},s.endAngle=function(a){return arguments.length?(r=typeof a=="function"?a:Rt(+a),s):r},s.padAngle=function(a){return arguments.length?(o=typeof a=="function"?a:Rt(+a),s):o},s}var Rf=Pc(ji);function Df(n){this._curve=n}Df.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(n,t){this._curve.point(t*Math.sin(n),t*-Math.cos(n))}};function Pc(n){function t(e){return new Df(n(e))}return t._curve=n,t}function Lr(n){var t=n.curve;return n.angle=n.x,delete n.x,n.radius=n.y,delete n.y,n.curve=function(e){return arguments.length?t(Pc(e)):t()._curve},n}function E2(){return Lr(Ai().curve(Rf))}function T2(){var n=qi().curve(Rf),t=n.curve,e=n.lineX0,i=n.lineX1,r=n.lineY0,o=n.lineY1;return n.angle=n.x,delete n.x,n.startAngle=n.x0,delete n.x0,n.endAngle=n.x1,delete n.x1,n.radius=n.y,delete n.y,n.innerRadius=n.y0,delete n.y0,n.outerRadius=n.y1,delete n.y1,n.lineStartAngle=function(){return Lr(e())},delete n.lineX0,n.lineEndAngle=function(){return Lr(i())},delete n.lineX1,n.lineInnerRadius=function(){return Lr(r())},delete n.lineY0,n.lineOuterRadius=function(){return Lr(o())},delete n.lineY1,n.curve=function(s){return arguments.length?t(Pc(s)):t()._curve},n}class zf{constructor(t,e){this._context=t,this._x=e}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,e){switch(t=+t,e=+e,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e);break}}this._x0=t,this._y0=e}}function L2(n){return new zf(n,!0)}function $2(n){return new zf(n,!1)}function I2(n){return n.source}function F2(n){return n.target}function Bf(n){let t=I2,e=F2,i=_c,r=Cc,o=null,s=null,a=Tr(c);function c(){let l;const h=S2.call(arguments),f=t.apply(this,h),u=e.apply(this,h);if(o==null&&(s=n(l=a())),s.lineStart(),h[0]=f,s.point(+i.apply(this,h),+r.apply(this,h)),h[0]=u,s.point(+i.apply(this,h),+r.apply(this,h)),s.lineEnd(),l)return s=null,l+""||null}return c.source=function(l){return arguments.length?(t=l,c):t},c.target=function(l){return arguments.length?(e=l,c):e},c.x=function(l){return arguments.length?(i=typeof l=="function"?l:Rt(+l),c):i},c.y=function(l){return arguments.length?(r=typeof l=="function"?l:Rt(+l),c):r},c.context=function(l){return arguments.length?(l==null?o=s=null:s=n(o=l),c):o},c}function R2(){return Bf(L2)}function D2(){return Bf($2)}const bn={draw(n,t){const e=Ie(t/Ui);n.moveTo(e,0),n.arc(0,0,e,0,Er)}},fs={draw(n,t){const e=Ie(t/5)/2;n.moveTo(-3*e,-e),n.lineTo(-e,-e),n.lineTo(-e,-3*e),n.lineTo(e,-3*e),n.lineTo(e,-e),n.lineTo(3*e,-e),n.lineTo(3*e,e),n.lineTo(e,e),n.lineTo(e,3*e),n.lineTo(-e,3*e),n.lineTo(-e,e),n.lineTo(-3*e,e),n.closePath()}},Of=Ie(1/3),z2=Of*2,ds={draw(n,t){const e=Ie(t/z2),i=e*Of;n.moveTo(0,-e),n.lineTo(i,0),n.lineTo(0,e),n.lineTo(-i,0),n.closePath()}},ps={draw(n,t){const e=Ie(t),i=-e/2;n.rect(i,i,e,e)}},Ec=Ie(3),gs={draw(n,t){const e=-Ie(t/(Ec*3));n.moveTo(0,e*2),n.lineTo(-Ec*e,-e),n.lineTo(Ec*e,-e),n.closePath()}},B2=Ie(3),ms={draw(n,t){const e=Ie(t)*.6824,i=e/2,r=e*B2/2;n.moveTo(0,-e),n.lineTo(r,i),n.lineTo(-r,i),n.closePath()}};function Ve(n,t){let e=null,i=Tr(r);n=typeof n=="function"?n:Rt(n||bn),t=typeof t=="function"?t:Rt(t===void 0?64:+t);function r(){let o;if(e||(e=o=i()),n.apply(this,arguments).draw(e,+t.apply(this,arguments)),o)return e=null,o+""||null}return r.type=function(o){return arguments.length?(n=typeof o=="function"?o:Rt(o),r):n},r.size=function(o){return arguments.length?(t=typeof o=="function"?o:Rt(+o),r):t},r.context=function(o){return arguments.length?(e=o??null,r):e},r}function Nf(){}function Wf(n,t,e){n._context.bezierCurveTo(n._x1+n._k*(n._x2-n._x0),n._y1+n._k*(n._y2-n._y0),n._x2+n._k*(n._x1-t),n._y2+n._k*(n._y1-e),n._x2,n._y2)}function Tc(n,t){this._context=n,this._k=(1-t)/6}Tc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Wf(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2,this._x1=n,this._y1=t;break;case 2:this._point=3;default:Wf(this,n,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=n,this._y0=this._y1,this._y1=this._y2,this._y2=t}},function n(t){function e(i){return new Tc(i,t)}return e.tension=function(i){return n(+i)},e}(0);function O2(n,t,e){var i=n._x1,r=n._y1,o=n._x2,s=n._y2;if(n._l01_a>_e){var a=2*n._l01_2a+3*n._l01_a*n._l12_a+n._l12_2a,c=3*n._l01_a*(n._l01_a+n._l12_a);i=(i*a-n._x0*n._l12_2a+n._x2*n._l01_2a)/c,r=(r*a-n._y0*n._l12_2a+n._y2*n._l01_2a)/c}if(n._l23_a>_e){var l=2*n._l23_2a+3*n._l23_a*n._l12_a+n._l12_2a,h=3*n._l23_a*(n._l23_a+n._l12_a);o=(o*l+n._x1*n._l23_2a-t*n._l12_2a)/h,s=(s*l+n._y1*n._l23_2a-e*n._l12_2a)/h}n._context.bezierCurveTo(i,r,o,s,n._x2,n._y2)}function Hf(n,t){this._context=n,this._alpha=t}Hf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){if(n=+n,t=+t,this._point){var e=this._x2-n,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;break;case 2:this._point=3;default:O2(this,n,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=n,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Vf=function n(t){function e(i){return t?new Hf(i,t):new Tc(i,0)}return e.alpha=function(i){return n(+i)},e}(.5);function Gf(n){this._context=n}Gf.prototype={areaStart:Nf,areaEnd:Nf,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(n,t){n=+n,t=+t,this._point?this._context.lineTo(n,t):(this._point=1,this._context.moveTo(n,t))}};function N2(n){return new Gf(n)}function ys(n,t){this._context=n,this._t=t}ys.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(n,t);else{var e=this._x*(1-this._t)+n*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,t)}break}}this._x=n,this._y=t}};function Yf(n){return new ys(n,.5)}function Xf(n){return new ys(n,0)}function Uf(n){return new ys(n,1)}class jf{constructor(t,e,i,r,o,s){var m;if(this.width=0,this.height=0,this.brush=null,this.brushGroup=null,this.programmatic=!1,this.config=t,this.events=o,!t.enabled){this.group=e.append("g").style("display","none");return}this.height=t.height||40,t.margin;const a=r-this.height-10;this.width=i.width,this.group=e.append("g").attr("class","katucharts-navigator").attr("transform",`translate(${i.x},${a})`);const c=t.maskFill??"rgba(102,133,194,0.3)",l=t.maskInside??!0,h=((m=t.series)==null?void 0:m.color)??"#6699cc",f=t.handles||{},u=f.backgroundColor??"#f2f2f2",d=f.borderColor??"#999999",p=f.enabled!==!1;this.group.append("rect").attr("width",this.width).attr("height",this.height).attr("fill","#f2f2f2").attr("stroke",t.outlineColor||"#cccccc").attr("stroke-width",t.outlineWidth||1),this.renderSeriesLine(s,h);const y=f2().extent([[0,0],[this.width,this.height]]).on("end",x=>{if(this.programmatic||!x.selection)return;const[v,b]=x.selection;o.emit("navigator:brushed",{x0:v/this.width,x1:b/this.width})});this.brush=y;const g=this.group.append("g").attr("class","katucharts-navigator-brush").call(y);this.brushGroup=g,g.selectAll(".selection").attr("fill",l?c:"none").attr("stroke","none"),p?g.selectAll(".handle").attr("fill",u).attr("stroke",d).attr("stroke-width",f.lineWidth??1):g.selectAll(".handle").style("display","none"),t.adaptToUpdatedData!==!1&&o.on("series:dataUpdated",x=>{this.updateSeriesLine(x,h)})}renderSeriesLine(t,e){if(t.length===0)return;const i=[Math.min(...t.map(c=>c.x)),Math.max(...t.map(c=>c.x))],r=[Math.min(...t.map(c=>c.y)),Math.max(...t.map(c=>c.y))],o=ke().domain(i).range([0,this.width]),s=ke().domain(r).range([this.height-2,2]),a=Ai().x(c=>o(c.x)).y(c=>s(c.y));this.group.selectAll(".katucharts-navigator-line").remove(),this.group.append("path").datum(t).attr("class","katucharts-navigator-line").attr("d",a).attr("fill","none").attr("stroke",e).attr("stroke-width",1)}updateSeriesLine(t,e){this.renderSeriesLine(t,e)}setSelection(t,e){if(!(!this.brush||!this.brushGroup)){if(this.programmatic=!0,t<=5e-4&&e>=.9995)this.brush.move(this.brushGroup,null);else{const i=Math.max(0,Math.min(1,t))*this.width,r=Math.max(0,Math.min(1,e))*this.width;this.brush.move(this.brushGroup,[Math.min(i,r),Math.max(i,r)])}this.programmatic=!1}}destroy(){this.group.remove()}}class qf{constructor(t,e,i){if(this.container=null,this.config=t,this.events=i,!t.enabled)return;this.container=lc("katucharts-range-selector",e),Object.assign(this.container.style,{display:"flex",gap:`${t.buttonSpacing??4}px`,padding:"5px",alignItems:"center",flexWrap:"wrap",fontSize:"12px"}),t.floating&&(this.container.style.position="absolute",this.container.style.zIndex="10"),t.x!==void 0&&(this.container.style.left=`${t.x}px`),t.y!==void 0&&(this.container.style.top=`${t.y}px`);const r=t.buttonPosition||{};r.align==="right"?this.container.style.justifyContent="flex-end":r.align==="center"&&(this.container.style.justifyContent="center");const o=t.buttons||[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],s=t.buttonTheme||{},a=t.allButtonsEnabled??!1;if(o.forEach((c,l)=>{const h=document.createElement("button");h.textContent=c.text||c.type||"",h.title=c.title||"";const f=l===(t.selected??0),u=s["states.select.fill"]||s.fill||"#e0e0e0",d=s.fill||"#fff";Object.assign(h.style,{padding:s.padding||"3px 8px",border:`1px solid ${s.stroke||"#ccc"}`,borderRadius:`${s.r??3}px`,backgroundColor:f?u:d,cursor:"pointer",fontSize:s["style.fontSize"]||"11px",fontWeight:s["style.fontWeight"]||"normal",color:s["style.color"]||"#333"}),!a&&!f&&(h.style.opacity="0.8"),h.addEventListener("click",()=>{var p;(p=c.events)!=null&&p.click&&c.events.click.call(c,new Event("click")),this.container.querySelectorAll("button").forEach(y=>{y.style.backgroundColor=d,y.style.opacity=a?"1":"0.8"}),h.style.backgroundColor=u,h.style.opacity="1",i.emit("rangeSelector:selected",{type:c.type,count:c.count,index:l})}),this.container.appendChild(h)}),t.inputEnabled!==!1){const c=t.inputPosition||{},l=document.createElement("div");l.style.display="flex",l.style.alignItems="center",l.style.gap="4px",l.style.marginLeft=c.x!==void 0?`${c.x}px`:"10px";const h=t.inputStyle||{},f=t.inputBoxBorderColor||"#ccc",u=t.inputBoxHeight??22,d=t.inputBoxWidth??90,p=document.createElement("input");p.type="date",Object.assign(p.style,{fontSize:h.fontSize||"11px",border:`1px solid ${f}`,height:`${u}px`,width:`${d}px`,padding:"0 4px",color:h.color||"#333"});const y=document.createElement("input");y.type="date",Object.assign(y.style,{fontSize:h.fontSize||"11px",border:`1px solid ${f}`,height:`${u}px`,width:`${d}px`,padding:"0 4px",color:h.color||"#333"});const g=()=>{p.value&&y.value&&i.emit("rangeSelector:dateRange",{from:new Date(p.value).getTime(),to:new Date(y.value).getTime()})};p.addEventListener("change",g),y.addEventListener("change",g);const m=t.labelStyle||{},x=document.createElement("span");x.textContent=" to ",x.style.fontSize=m.fontSize||"11px",x.style.color=m.color||"#666",l.appendChild(p),l.appendChild(x),l.appendChild(y),this.container.appendChild(l)}}destroy(){this.container&&this.container.remove()}}const W2=[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],H2={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6};class V2{constructor(t){this.host=t,this.navigator=null,this.rangeSelector=null,this.xMin=0,this.xMax=0}setup(){var a,c;const t=this.host.getOptions(),e=(a=t.navigator)==null?void 0:a.enabled,i=(c=t.rangeSelector)==null?void 0:c.enabled;if(!e&&!i)return;const r=this.getBaseSeriesData();r.length>0&&(this.xMin=r[0].x,this.xMax=r[r.length-1].x);const o=this.host.getEvents(),s=t.rangeSelector;if(i&&(this.rangeSelector=new qf(s,this.host.getContainer(),o),this.placeRangeSelectorOnTop(),o.on("rangeSelector:selected",l=>this.applyButton(l)),o.on("rangeSelector:dateRange",l=>this.applyXRange(l.from,l.to))),e&&(this.navigator=new jf(t.navigator,this.host.getSvg(),this.host.getLayout().plotArea,this.host.getChartHeight(),o,r),o.on("navigator:brushed",l=>{const h=this.xMax-this.xMin;this.applyXRange(this.xMin+l.x0*h,this.xMin+l.x1*h)})),i){const l=s.selected;if(l!=null){const h=(s.buttons||W2)[l];h&&this.applyButton(h)}}o.on("chart:afterZoom",()=>{const l=this.host.getXAxes()[0];if(l){const[h,f]=l.scale.domain();this.syncNavigator(+h,+f)}})}getBaseSeriesData(){const t=this.host.getSeriesInstances();return t.length===0?[]:t[0].data.map(i=>({x:i.x??0,y:i.close??i.y??0})).filter(i=>i.y!==null&&i.y!==void 0&&Number.isFinite(i.x))}placeRangeSelectorOnTop(){const t=this.host.getContainer(),e=t.querySelector(".katucharts-range-selector");e&&t.firstChild&&e!==t.firstChild&&t.insertBefore(e,t.firstChild)}applyButton(t){const e=t.type,i=t.count??1;if(e==="all"){this.applyXRange(this.xMin,this.xMax);return}if(e==="ytd"){const o=new Date(this.xMax),s=Date.UTC(o.getUTCFullYear(),0,1);this.applyXRange(Math.max(this.xMin,s),this.xMax);return}const r=H2[e];r&&this.applyXRange(Math.max(this.xMin,this.xMax-i*r),this.xMax)}applyXRange(t,e){if(!(!Number.isFinite(t)||!Number.isFinite(e)||e<=t)){for(const i of this.host.getXAxes())i.updateDomain({min:t,max:e});this.host.rerender(),this.syncNavigator(t,e)}}syncNavigator(t,e){if(!this.navigator)return;const i=this.xMax-this.xMin;i<=0||this.navigator.setSelection((t-this.xMin)/i,(e-this.xMin)/i)}destroy(){var t,e;(t=this.navigator)==null||t.destroy(),(e=this.rangeSelector)==null||e.destroy()}}const G2=22,Yn=class Yn{constructor(t,e){var h,f;this.xAxes=[],this.yAxes=[],this.seriesInstances=[],this.tooltip=null,this.legend=null,this.crosshair=null,this.credits=null,this.exportButton=null,this.responsiveEngine=null,this.stock=null,this.clipPathId="",this.clipMargin=0,this.autoHeight=!1,this.resizeObserver=null,this.isResponsiveUpdate=!1,this.scrollableInner=null,this.scrollableOuterWidth=0,this.scrollableOuterHeight=0,this.useVerticalScroll=!1,this.useHorizontalScroll=!1,this.fixedAxisOverlay=null,this.container=Iv(t),this.container.style.position="relative";const i=new Kn;this.options=i.parse(e),this.originalUserOptions=po(e),bv(((h=this.options.time)==null?void 0:h.useUTC)!==!1),this.events=new qh,this.state=new My(this.options,this.events),this.layoutEngine=new _y;const r=lf(this.container,this.getDefaultHeightAspectRatio()),o=this.options.chart.width||r.width||600;let s=this.resolveHeight(this.options.chart.height,r.height);const a=this.options.chart.scrollablePlotArea,c=(a==null?void 0:a.minWidth)&&a.minWidth>o;if(this.autoHeight=this.options.chart.height==null&&!r.heightMeasured,this.chartWidth=c?a.minWidth:o,this.autoHeight){const u=a!=null&&a.minHeight?Math.min(a.minHeight,Yn.MAX_AUTO_HEIGHT):0;s=Math.max(this.fitHeightToContent(s),u)}const l=(a==null?void 0:a.minHeight)&&a.minHeight>s;this.chartHeight=l?a.minHeight:s,this.scrollableOuterWidth=o,this.scrollableOuterHeight=s,this.useVerticalScroll=!!l,this.useHorizontalScroll=!!c,(l||c)&&(this.container.style.position="relative",this.container.querySelectorAll(":scope > [data-katu-scrollable-inner]").forEach(p=>{var y;return(y=p.parentElement)==null?void 0:y.removeChild(p)}),this.container.querySelectorAll(":scope > svg[data-katu-fixed-overlay]").forEach(p=>{var y;return(y=p.parentElement)==null?void 0:y.removeChild(p)}),this.scrollableInner=document.createElement("div"),this.scrollableInner.setAttribute("data-katu-scrollable-inner","1"),this.scrollableInner.style.overflowX=c?"auto":"hidden",this.scrollableInner.style.overflowY=l?"auto":"hidden",this.scrollableInner.style.width=o+"px",this.scrollableInner.style.height=s+"px",this.container.appendChild(this.scrollableInner)),this.setupResponsive(),this.applyInitialResponsiveRules(),this.autoHeight&&!this.useVerticalScroll&&(this.chartHeight=this.fitHeightToContent(this.chartHeight),this.scrollableOuterHeight=this.chartHeight),this.renderer=new So(this.scrollableInner||this.container,this.chartWidth,this.chartHeight),this.scrollableInner&&this.renderer.svg.style("max-width","none"),this.exporter=new Gv({getRenderer:()=>this.renderer,getOptions:()=>this.options,getContainer:()=>this.container,getSeriesInstances:()=>this.seriesInstances,setSize:(u,d)=>this.setSize(u,d),fireEvent:(u,...d)=>this.fireEvent(u,...d),getDefaultHeightAspectRatio:()=>this.getDefaultHeightAspectRatio(),disconnectResizeObserver:()=>{var u;return(u=this.resizeObserver)==null?void 0:u.disconnect()},observeResizeObserver:()=>{var u;return(u=this.resizeObserver)==null?void 0:u.observe(this.container)},getViewportSize:()=>this.getViewportSize(),fitToViewport:(u,d)=>this.fitToViewport(u,d)}),this.axes=new Yv({getOptions:()=>this.options,getLayout:()=>this.layout,getSeriesInstances:()=>this.seriesInstances,getXAxes:()=>this.xAxes,getYAxes:()=>this.yAxes,getAxisGroup:()=>this.axisGroup,getEvents:()=>this.events,getTooltip:()=>this.tooltip}),this.interactions=new i2({getOptions:()=>this.options,getContainer:()=>this.container,getEvents:()=>this.events,getRenderer:()=>this.renderer,getSeriesGroup:()=>this.seriesGroup,getPlotGroup:()=>this.plotGroup,getLayout:()=>this.layout,getXAxes:()=>this.xAxes,getYAxes:()=>this.yAxes,getSeriesInstances:()=>this.seriesInstances,setSeries:u=>{this.options.series=u},rebuild:()=>{var u;this.seriesInstances.forEach(d=>d.destroy()),this.seriesInstances=[],this.buildAxes(),this.buildSeries(),this.renderAll(),(u=this.credits)==null||u.refresh()},renderAfterZoom:()=>{this.renderAxes(),this.renderSeriesInstances(),this.renderLegend()},fireEvent:(u,...d)=>this.fireEvent(u,...d)}),this.applyChartStyles(),this.computeLayout(),this.createStructuralGroups(),this.buildAxes(),this.buildSeries(),this.renderAll(),(f=this.credits)==null||f.refresh(),(l||c)&&this.createFixedAxisOverlay(),this.options.chart.reflow&&this.setupReflow(),this.interactions.setup(),this.stock=new V2({getOptions:()=>this.options,getContainer:()=>this.container,getEvents:()=>this.events,getSvg:()=>this.renderer.svg,getLayout:()=>this.layout,getChartHeight:()=>this.chartHeight,getXAxes:()=>this.xAxes,getSeriesInstances:()=>this.seriesInstances,rerender:()=>{this.renderAxes(),this.renderSeriesInstances(),this.renderLegend()}}),this.stock.setup(),this.fireEvent("load")}createFixedAxisOverlay(){const t=Vv({container:this.container,renderer:this.renderer,options:this.options,plotGroup:this.plotGroup,layout:this.layout,chartWidth:this.chartWidth,chartHeight:this.chartHeight,scrollableInner:this.scrollableInner,scrollableOuterWidth:this.scrollableOuterWidth,scrollableOuterHeight:this.scrollableOuterHeight,useVerticalScroll:this.useVerticalScroll,useHorizontalScroll:this.useHorizontalScroll,exportButton:this.exportButton,previousOverlay:this.fixedAxisOverlay});t&&(this.fixedAxisOverlay=t)}getDefaultHeightAspectRatio(){var i;const t=((i=this.options)==null?void 0:i.series)||[],e=new Set(t.map(r=>{var o,s;return(r==null?void 0:r.type)||((s=(o=this.options)==null?void 0:o.chart)==null?void 0:s.type)}));return e.has("dependencywheel")||e.has("networkgraph")?1:e.has("treemap")||e.has("sankey")?.3:e.has("pie")||e.has("donut")||e.has("radar")?.6:.5}fitHeightToContent(t){const r=4e3-this.layoutEngine.compute(this.options,this.chartWidth,4e3).plotArea.height,o=Math.max(Yn.MIN_AUTO_PLOT_HEIGHT,this.verticalCategoryCount()*Yn.MIN_CATEGORY_ROW_HEIGHT),s=Math.ceil(r+o);return s<=t?t:Math.min(s,Math.max(t,Yn.MAX_AUTO_HEIGHT))}verticalCategoryCount(){var o;const i=(this.options.series||[]).some(s=>s._internalType==="heatmap")?this.options.yAxis:this.options.chart.inverted?this.options.xAxis:null;if(!i)return 0;let r=0;for(const s of i){const a=((o=s.categories)==null?void 0:o.length)??0;a>r&&(r=a)}return r}resolveHeight(t,e){if(typeof t=="number")return t;if(typeof t=="string"){if(t.endsWith("%"))return parseFloat(t)/100*e;const i=parseFloat(t);if(!isNaN(i)&&i>0)return i}return e||400}applyChartStyles(){const t=this.options.chart.backgroundColor;t&&this.renderer.svg.append("rect").attr("class","katucharts-background").attr("width",this.chartWidth).attr("height",this.chartHeight).attr("fill",t).attr("rx",this.options.chart.borderRadius??0),this.options.chart.borderWidth&&this.renderer.svg.append("rect").attr("class","katucharts-border").attr("width",this.chartWidth).attr("height",this.chartHeight).attr("fill","none").attr("stroke",this.options.chart.borderColor||"#335cad").attr("stroke-width",this.options.chart.borderWidth).attr("rx",this.options.chart.borderRadius??0)}computeLayout(){this.layout=this.layoutEngine.compute(this.options,this.chartWidth,this.chartHeight)}createStructuralGroups(){var s,a,c,l;this.titleGroup=this.renderer.createGroup("katucharts-title-group"),this.renderTitles(),this.plotGroup=this.renderer.createGroup("katucharts-plot-group"),this.plotGroup.attr("transform",`translate(${this.layout.plotArea.x},${this.layout.plotArea.y})`);const t=this.options.chart.plotBackgroundColor;t&&this.plotGroup.append("rect").attr("class","katucharts-plot-background").attr("width",this.layout.plotArea.width).attr("height",this.layout.plotArea.height).attr("fill",t);const e=this.options.chart.plotBorderWidth;e&&this.plotGroup.append("rect").attr("class","katucharts-plot-border").attr("width",this.layout.plotArea.width).attr("height",this.layout.plotArea.height).attr("fill","none").attr("stroke",this.options.chart.plotBorderColor||"#cccccc").attr("stroke-width",e),this.options.chart.plotShadow&&((s=this.plotGroup.node())==null||s.setAttribute("filter","drop-shadow(3px 3px 6px rgba(0,0,0,0.15))")),this.axisGroup=this.renderer.createGroup("katucharts-axis-group",this.plotGroup),this.seriesGroup=this.renderer.createGroup("katucharts-series-group",this.plotGroup),this.stackLabelsGroup=this.renderer.createGroup("katucharts-stack-labels-group",this.plotGroup);const i=this.options.series.some(h=>h.clip===!1||kg.has(h._internalType));this.clipMargin=!Ks(this.options.series)&&!i?G2:0,this.clipPathId=this.renderer.createClipPath(-this.clipMargin,-this.clipMargin,this.layout.plotArea.width+2*this.clipMargin,this.layout.plotArea.height+2*this.clipMargin),!Ks(this.options.series)&&!i&&this.seriesGroup.attr("clip-path",`url(#${this.clipPathId})`),this.tooltip=new rs(this.options.tooltip,this.container,this.layout.plotArea,this.events),(a=this.options.tooltip)!=null&&a.shared&&this.tooltip.setSharedPointsProvider(h=>this.collectSharedPointsAt(h)),this.legend=new os({...this.options.legend,_backgroundColor:this.options.chart.backgroundColor},this.renderer.svg,this.events),this.credits=new Bv(this.options.credits,this.renderer.svg,this.chartWidth,this.chartHeight),this.options.exporting.enabled!==!1&&(this.exportButton=new pf(this.options.exporting,this.renderer.svg,this.container,this.chartWidth,this.chartHeight,h=>this.handleExportAction(h)));const r=(c=this.options.xAxis[0])==null?void 0:c.crosshair,o=(l=this.options.yAxis[0])==null?void 0:l.crosshair;(r||o)&&(this.crosshair=new uf(r,o,this.plotGroup,this.layout.plotArea,this.events))}renderTitles(){Hv({titleGroup:this.titleGroup,container:this.container,options:this.options,layout:this.layout,chartWidth:this.chartWidth})}buildAxes(){const t=this.options.series.some(e=>e._internalType==="heatmap");this.xAxes=this.options.xAxis.map(e=>cc(t?{...e,_centerTitleOnChart:!0,_chartWidth:this.chartWidth}:e,this.layout.plotArea)),this.yAxes=this.options.yAxis.map(e=>cc(e,this.layout.plotArea))}buildSeries(){const t=this.options;this.seriesInstances=t.series.map((e,i)=>{const r=e._internalType,o=Tt.getType(r);if(!o){console.warn(`KatuCharts: unknown series type "${r}", falling back to line`);const s=Tt.getType("line");if(!s)throw new Error("KatuCharts: line series type not registered");return new s(e)}return new o(e)})}collectSharedPointsAt(t){var r;const e=[],i=typeof t=="number"?t:NaN;for(let o=0;o<this.seriesInstances.length;o++){const s=this.seriesInstances[o],a=this.options.series[o];if(!s.visible||a.enableMouseTracking===!1)continue;const c=s.data;if(!c||c.length===0)continue;let l=null,h=1/0;for(const p of c){if(p.x===void 0||p.x===null)continue;const y=Math.abs(p.x-i);y<h&&(h=y,l=p)}if(!l)continue;const f=l.close??l.y??l.high;if(f==null)continue;const u=this.xAxes[a._xAxisIndex]||this.xAxes[0],d=this.yAxes[a._yAxisIndex]||this.yAxes[0];e.push({point:l,plotX:u.getPixelForValue(l.x),plotY:d.getPixelForValue(f),series:{name:a.name??"",color:((r=s.getColor)==null?void 0:r.call(s))??a.color??"#333",config:a}})}return e}renderAll(){this.updateAxesDomains(),this.updateTooltipCategories(),this.renderAxes(),this.renderSeriesInstances(),this.renderStackLabels(),this.raiseplotLineLabels(),this.renderLegend(),this.fireEvent("render")}formatStackLabel(t,e){return e.formatter?e.formatter.call({total:t}):e.format?oe(Kt(e.format,{total:t})):this.options.chart.numberFormatter?this.options.chart.numberFormatter(t):ts(t,0,".",",")}renderStackLabels(){if(this.stackLabelsGroup){this.stackLabelsGroup.selectAll("*").remove();for(let t=0;t<this.yAxes.length;t++){const i=this.yAxes[t].config.stackLabels;if(!(i!=null&&i.enabled))continue;const r=this.seriesInstances.map((a,c)=>({series:a,cfg:this.options.series[c]})).filter(({series:a,cfg:c})=>a.visible&&c._yAxisIndex===t&&(c._internalType==="column"||c._internalType==="bar")&&c.stacking&&c.stacking!=="percent");if(r.length===0)continue;const o=new Map;for(const{series:a,cfg:c}of r){const l=ss(c);o.has(l)||o.set(l,{totals:new Map,series:[],type:c._internalType,xAxis:this.xAxes[c._xAxisIndex]||this.xAxes[0],yAxis:this.yAxes[c._yAxisIndex]||this.yAxes[0]});const h=o.get(l);h.series.push(a),Vi(a.data,h.totals)}const s=this.stackLabelsGroup.append("g").attr("class",`katucharts-stack-labels katucharts-stack-labels-axis-${t}`);for(const[a,c]of o){const l=s.append("g").attr("class","katucharts-stack-labels-stack").attr("data-stack-key",a);for(const[h,f]of c.totals.entries()){if(!isFinite(f)||f===0)continue;const u=this.formatStackLabel(f,i),d=c.type==="bar",p=f<0,y=c.xAxis.getPixelForValue(h),g=c.yAxis.getPixelForValue(f),m=d?p?"end":"start":"middle",x=d?"central":p?"hanging":"auto",v=d?g+(p?-6:6):y,b=d?y:g+(p?6:-6),k=v+(i.x??0),M=b+(i.y??0),C=l.append("text").attr("class","katucharts-stack-label").attr("x",k).attr("y",M).attr("text-anchor",i.align==="left"?"start":i.align==="right"?"end":m).text(u);i.verticalAlign==="middle"||d?C.attr("dominant-baseline",x):i.verticalAlign==="bottom"&&C.attr("dominant-baseline","hanging");const E=i.style||{};C.style("fill",E.color??"#000000").style("font-size",E.fontSize??"11px").style("font-weight",E.fontWeight??"bold"),E.textOutline&&C.style("text-shadow",E.textOutline),i.rotation&&C.attr("transform",`rotate(${i.rotation},${k},${M})`)}}}}}raiseplotLineLabels(){const t=this.plotGroup.node();t&&this.axisGroup.selectAll(".katucharts-plot-line-label").each(function(){t.appendChild(this)})}updateTooltipCategories(){this.axes.updateTooltipCategories()}updateAxesDomains(){this.axes.updateAxesDomains()}renderAxes(){this.axes.renderAxes()}renderSeriesInstances(){var h;this.seriesGroup.selectAll("*").remove();const t=new Map,e=new Map;for(const f of this.options.series){const u=f._internalType;t.set(u,(t.get(u)||0)+1),e.set(u,0)}const i=this.options.chart.animation!==!1,r=ss,o=new Map,s=new Map,a=new Map,c=new Map;for(let f=0;f<this.options.series.length;f++){const u=this.options.series[f];if(u.stacking){const d=r(u);o.set(d,(o.get(d)||0)+1),a.has(d)||a.set(d,new Map);const p=a.get(d),y=this.seriesInstances[f];y.processData(),Vi(y.data,p)}}const l=new Map;for(let f=0;f<this.options.series.length;f++){const u=this.options.series[f];if(!u.stacking)continue;const d=r(u);l.has(d)||l.set(d,new Map);const p=l.get(d);c.set(f,new Map(p)),Vi(this.seriesInstances[f].data,p)}for(let f=0;f<this.seriesInstances.length;f++){const u=this.seriesInstances[f],d=this.options.series[f],p=this.xAxes[d._xAxisIndex]||this.xAxes[0],y=this.yAxes[d._yAxisIndex]||this.yAxes[0],g=d._internalType,m=e.get(g)||0;e.set(g,m+1);let x;d.stacking&&(x=c.get(f)||new Map);const v={plotArea:this.layout.plotArea,chartWidth:this.chartWidth,xAxis:p,yAxis:y,colorIndex:f,colors:this.options.colors,events:this.events,chartGroup:this.seriesGroup,plotGroup:this.plotGroup,totalSeriesOfType:d.stacking?o.get(r(d))||1:t.get(g)||1,indexInType:d.stacking?s.get(r(d))||0:m,animate:i&&d.animation!==!1,stackOffsets:x,stackTotals:d.stacking?a.get(r(d)):void 0,allSeries:this.seriesInstances,inverted:!!this.options.chart.inverted,legendConfig:this.options.legend,pane:this.options.pane,backgroundColor:this.options.chart.backgroundColor};if(u.processData(),u.init(v),u.render(),d.stacking){const b=r(d);s.set(b,(s.get(b)||0)+1)}u.setOnVisibilityChange(b=>this.animatedRedraw(b)),(h=d.dataLabels)!=null&&h.enabled&&!vg.has(d._internalType)&&!wg.has(d._internalType)&&is.render(u.group,u.data,d.dataLabels,p,y,d.name||"")}}renderLegend(){this.legend&&this.legend.render(this.seriesInstances,this.layout.legendArea)}setupReflow(){if(typeof ResizeObserver>"u")return;const t=Fv(()=>this.reflow(),100);this.resizeObserver=new ResizeObserver(t),this.resizeObserver.observe(this.container)}fireEvent(t,...e){var r;this.events.emit(`chart:${t}`,this,...e);const i=(r=this.options.chart.events)==null?void 0:r[t];typeof i=="function"&&i.call(this,...e)}get plotLeft(){return this.layout.plotArea.x}get plotTop(){return this.layout.plotArea.y}get plotWidth(){return this.layout.plotArea.width}get plotHeight(){return this.layout.plotArea.height}get plotRenderer(){const t=this.seriesGroup,e=this.xAxes,i=this.yAxes,r=this.layout.plotArea;return{rect(o,s,a,c){return t.insert("rect",":first-child").attr("x",o).attr("y",s).attr("width",a).attr("height",c)},circle(o,s,a){return t.insert("circle",":first-child").attr("cx",o).attr("cy",s).attr("r",a)},ellipse(o,s,a,c){return t.insert("ellipse",":first-child").attr("cx",o).attr("cy",s).attr("rx",a).attr("ry",c)},path(o){return t.insert("path",":first-child").attr("d",o)},line(o,s,a,c){return t.insert("line",":first-child").attr("x1",o).attr("y1",s).attr("x2",a).attr("y2",c)},text(o,s,a){return t.append("text").attr("x",s).attr("y",a).text(o)},group(o){const s=t.insert("g",":first-child");return o&&s.attr("class",o),s.style("pointer-events","none"),s},get plotArea(){return{x:0,y:0,width:r.width,height:r.height}},get localPlotArea(){return{x:0,y:0,width:r.width,height:r.height}},xAxis:{toPixels(o,s=0){var a;return((a=e[s])==null?void 0:a.getPixelForValue(o))??0}},yAxis:{toPixels(o,s=0){var a;return((a=i[s])==null?void 0:a.getPixelForValue(o))??0}}}}setupResponsive(){var t,e;(e=(t=this.options.responsive)==null?void 0:t.rules)!=null&&e.length&&(this.responsiveEngine=new gf(this.options.responsive))}applyInitialResponsiveRules(){if(!this.responsiveEngine)return;const t=this.responsiveEngine.evaluate(this.chartWidth,this.chartHeight);if(t.changed&&t.matchingIndices.length>0){const e=this.responsiveEngine.getRules();let i=po(this.originalUserOptions);for(const o of t.matchingIndices)i=fe(i,e[o].chartOptions);const r=new Kn;this.options=r.parse(i),this.state.updateConfig(this.options)}}addSeries(t,e=!0){this.originalUserOptions.series||(this.originalUserOptions.series=[]),this.originalUserOptions.series.push(t);const o={...new Kn().parse({series:[t]}).series[0],index:this.options.series.length};this.state.addSeries(o),this.options=this.state.getConfig();const s=Tt.getType(o._internalType)||Tt.getType("line");if(!s)throw new Error("KatuCharts: no series type registered");const a=new s(o);return this.seriesInstances.push(a),e&&this.redraw(),a}get(t){const e=this.seriesInstances.find(r=>r.config.id===t);if(e)return e;const i=this.xAxes.find(r=>r.config.id===t);return i||this.yAxes.find(r=>r.config.id===t)}canReuseSeriesInstances(t){return this.seriesInstances.length!==t.series.length?!1:this.seriesInstances.every((e,i)=>{var r;return e.config._internalType===((r=t.series[i])==null?void 0:r._internalType)})}syncSeriesInstances(t){for(let e=0;e<this.seriesInstances.length;e++){const i=this.seriesInstances[e],r={...t.series[e],visible:i.visible};this.options.series[e]=r,i.config=r,i.visible=r.visible!==!1,i.processData()}}update(t,e=!0){var a;this.isResponsiveUpdate||(this.originalUserOptions=fe(po(this.originalUserOptions),t));const i=new Kn,r=fe(this.optionsToExternal(),t);(a=t.chart)!=null&&a.type&&Array.isArray(r.series)&&r.series.forEach((c,l)=>{var f,u;const h=Array.isArray(t.series)?(f=t.series[l])==null?void 0:f.type:void 0;(u=this.options.series[l])!=null&&u._typeFromChart&&!h&&delete c.type});const o=i.parse(r),s=this.canReuseSeriesInstances(o);if(this.state.updateConfig(o),this.options=this.state.getConfig(),e)if(!s)this.redraw();else{this.buildAxes(),this.syncSeriesInstances(o);try{this.animatedRedraw(300)}catch{this.redraw()}}}animatedRedraw(t=500){this.updateAxesDomains(),this.updateTooltipCategories();for(const l of this.xAxes)l.animateAxis(this.axisGroup,this.layout.plotArea,t);for(const l of this.yAxes)l.animateAxis(this.axisGroup,this.layout.plotArea,t);const e=new Map,i=new Map,r=new Map,o=new Map,s=new Map,a=ss,c=new Map;for(const l of this.seriesInstances){if(!l.visible)continue;const h=l.config._internalType;if(e.set(h,(e.get(h)||0)+1),l.config.stacking){const f=a(l.config);r.set(f,(r.get(f)||0)+1),s.has(f)||s.set(f,new Map),c.has(f)||c.set(f,new Map),Vi(l.data,c.get(f))}}for(let l=0;l<this.seriesInstances.length;l++){const h=this.seriesInstances[l];if(!h.visible)continue;const f=this.options.series[l],u=f._internalType,d=i.get(u)||0;i.set(u,d+1);let p,y,g,m;if(f.stacking){const x=a(f);p=r.get(x)||1,y=o.get(x)||0,o.set(x,y+1),g=new Map(s.get(x)),m=c.get(x)}else p=e.get(u)||1,y=d;h.updateContext({xAxis:this.xAxes[f._xAxisIndex]||this.xAxes[0],yAxis:this.yAxes[f._yAxisIndex]||this.yAxes[0],totalSeriesOfType:p,indexInType:y,stackOffsets:g,stackTotals:m}),h.animateUpdate(t),f.stacking&&Vi(h.data,s.get(a(f)))}this.renderStackLabels(),this.renderTitles(),this.renderLegend(),this.fireEvent("render")}redraw(){this.computeLayout(),this.plotGroup.attr("transform",`translate(${this.layout.plotArea.x},${this.layout.plotArea.y})`),this.renderer.updateClipPath(this.clipPathId,-this.clipMargin,-this.clipMargin,this.layout.plotArea.width+2*this.clipMargin,this.layout.plotArea.height+2*this.clipMargin),this.buildAxes(),this.seriesInstances.forEach(t=>t.destroy()),this.seriesInstances=[],this.buildSeries(),this.renderAll(),this.tooltip&&this.tooltip.updatePlotArea(this.layout.plotArea),this.renderTitles(),this.fireEvent("redraw")}reflow(){if(this.options.chart.width)return;const t=lf(this.container,this.getDefaultHeightAspectRatio());let e=t.width,i=this.resolveHeight(this.options.chart.height,t.height);const r=this.options.chart.scrollablePlotArea;if(r!=null&&r.minWidth&&r.minWidth>e&&(e=r.minWidth),r!=null&&r.minHeight&&r.minHeight>i&&(i=r.minHeight),this.autoHeight&&!(r!=null&&r.minHeight)){const o=this.chartWidth;this.chartWidth=e,i=this.fitHeightToContent(i),this.chartWidth=o}if(!(e===this.chartWidth&&i===this.chartHeight)){if(this.responsiveEngine){const o=this.responsiveEngine.evaluate(e,i);if(o.changed){const s=this.responsiveEngine.getRules();let a=po(this.originalUserOptions);for(const c of o.matchingIndices)a=fe(a,s[c].chartOptions);this.isResponsiveUpdate=!0,this.update(a,!1),this.isResponsiveUpdate=!1}}this.setSize(e,i)}}setSize(t,e){var i,r;this.chartWidth=t,this.chartHeight=e,this.renderer.setSize(t,e),this.renderer.svg.select(".katucharts-background").attr("width",t).attr("height",e),this.renderer.svg.select(".katucharts-border").attr("width",t).attr("height",e),(i=this.exportButton)==null||i.updatePosition(t,e),(r=this.credits)==null||r.updatePosition(t,e),this.redraw()}getViewportSize(){return this.scrollableInner?{width:this.scrollableOuterWidth,height:this.scrollableOuterHeight}:{width:this.chartWidth,height:this.chartHeight}}fitToViewport(t,e){if(!this.scrollableInner){this.setSize(t,e);return}const i=this.options.chart.scrollablePlotArea;this.scrollableOuterWidth=t,this.scrollableOuterHeight=e,this.scrollableInner.style.width=t+"px",this.scrollableInner.style.height=e+"px";const r=Math.max((i==null?void 0:i.minWidth)||0,t),o=Math.max((i==null?void 0:i.minHeight)||0,e);this.setSize(r,o),this.createFixedAxisOverlay()}setTitle(t,e){t&&(this.options.title=fe(this.options.title,t),this.originalUserOptions.title=fe(this.originalUserOptions.title||{},t)),e&&(this.options.subtitle=fe(this.options.subtitle,e),this.originalUserOptions.subtitle=fe(this.originalUserOptions.subtitle||{},e)),this.renderTitles()}addAxis(t,e=!0,i=!0){const r=e?this.options.xAxis:this.options.yAxis,o={...t,index:r.length,isX:e};r.push(o);const s=cc(o,this.layout.plotArea);return(e?this.xAxes:this.yAxes).push(s),i&&this.redraw(),s}showLoading(t){let e=this.container.querySelector(".katucharts-loading");e||(e=document.createElement("div"),e.className="katucharts-loading",Object.assign(e.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.75)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"bold",color:"#666",zIndex:"20"}),this.container.appendChild(e)),e.textContent=t||"Loading...",e.style.display="flex"}hideLoading(){const t=this.container.querySelector(".katucharts-loading");t&&(t.style.display="none")}destroy(){var i,r,o,s,a,c,l;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.seriesInstances.forEach(h=>h.destroy()),(i=this.tooltip)==null||i.destroy(),(r=this.legend)==null||r.destroy(),(o=this.crosshair)==null||o.destroy(),(s=this.credits)==null||s.destroy(),(a=this.exportButton)==null||a.destroy(),this.interactions.destroy(),(c=this.stock)==null||c.destroy(),(l=this.responsiveEngine)==null||l.reset(),this.events.removeAllListeners(),this.renderer.destroy();const t=this.container.querySelector(".katucharts-loading");t&&t.remove();const e=this.container.querySelector(".katucharts-tooltip");e&&e.remove(),this.container.querySelectorAll(".katucharts-title-html, .katucharts-subtitle-html").forEach(h=>h.remove())}getSVG(){return this.exporter.getSVG()}getSeriesInstances(){return this.seriesInstances}get series(){return this.seriesInstances}getXAxes(){return this.xAxes}getYAxes(){return this.yAxes}handleExportAction(t){this.exporter.handleExportAction(t)}getCSV(){return this.exporter.getCSV()}getTable(){return this.exporter.getTable()}getDataRows(){return this.exporter.getDataRows()}exportChart(t,e){this.exporter.exportChart(t)}print(){this.exporter.print()}optionsToExternal(){return this.exporter.optionsToExternal()}};Yn.MIN_AUTO_PLOT_HEIGHT=160,Yn.MAX_AUTO_HEIGHT=450,Yn.MIN_CATEGORY_ROW_HEIGHT=22;let xs=Yn;const bt=600,Nt=8,Lc=0,Qn=bt+100,Z=300,bs=250,pt=of,j=of,Y2=500;function xe(n,t,e,i){return i>Y2?t:t+n*e}const X2={Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",ShortDashDotDot:"6,2,2,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"};function on(n){return!n||n==="Solid"?"none":X2[n]||"none"}function Zf(n,t){const e=n.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(e){const r=Math.min(255,parseInt(e[1],16)+Math.round(255*t)),o=Math.min(255,parseInt(e[2],16)+Math.round(255*t)),s=Math.min(255,parseInt(e[3],16)+Math.round(255*t));return`rgb(${r},${o},${s})`}const i=n.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(i){const r=Math.min(255,parseInt(i[1])+Math.round(255*t)),o=Math.min(255,parseInt(i[2])+Math.round(255*t)),s=Math.min(255,parseInt(i[3])+Math.round(255*t));return`rgb(${r},${o},${s})`}return n}class Xt{constructor(t){this.selectedPoints=new Set,this._cachedExtents=null,this.config=t,this.visible=t.visible!==!1,this.data=t._processedData||[]}init(t){this.context=t,this.group=t.chartGroup.append("g").attr("class",`katucharts-series katucharts-series-${this.config._internalType}`).attr("data-series-index",this.config.index),this.config.opacity!==void 0&&this.config.opacity!==1&&this.group.attr("opacity",this.config.opacity),this.config.zIndex!==void 0&&this.group.style("z-index",String(this.config.zIndex)),this.config.className&&this.group.classed(this.config.className,!0),this.config.shadow&&this.applyShadowFilter(),this.visible||this.group.style("display","none"),this.config.allowPointSelect&&this.data.forEach((e,i)=>{e.selected&&this.selectedPoints.add(i)}),this.group.on("mouseenter",()=>{var e,i;(i=(e=this.config.events)==null?void 0:e.mouseOver)==null||i.call(this,new Event("mouseOver")),this.context.events.emit("series:mouseenter",this)}).on("mouseleave",()=>{var e,i;(i=(e=this.config.events)==null?void 0:e.mouseOut)==null||i.call(this,new Event("mouseOut")),this.context.events.emit("series:mouseleave",this)})}setOnVisibilityChange(t){this._onVisibilityChange=t}processData(){this.data=this.config._processedData||[],this._cachedExtents=null}getColor(){return this.config.color||this.context.colors[this.context.colorIndex%this.context.colors.length]}autoLabelColor(t){return gn(this.context.backgroundColor,t)}labelHalo(){const t=this.labelHaloColor();return`0 0 3px ${t}, 0 0 3px ${t}`}labelHaloColor(){return gn(this.context.backgroundColor)==="#ffffff"?"rgba(0,0,0,0.85)":"#ffffff"}autoBorderColor(){const t=this.context.backgroundColor;return!t||t==="transparent"||t==="none"?"#ffffff":t}getMultiLegendItems(){return null}toggleLegendItem(t){return null}getLegendSymbolShape(){return null}getBubbleLegendInfo(){return null}animateUpdate(t){this.group.selectAll("*").remove(),this.render()}updateContext(t){Object.assign(this.context,t)}redraw(){this.group.selectAll("*").remove(),this.render()}setVisible(t,e=!0){var i,r,o,s;this.visible=t,t?(r=(i=this.config.events)==null?void 0:i.show)==null||r.call(this,new Event("show")):(s=(o=this.config.events)==null?void 0:o.hide)==null||s.call(this,new Event("hide")),e&&this._onVisibilityChange?(t?this.group.style("display","").attr("opacity",0).transition().duration(300).attr("opacity",this.config.opacity??1):this.group.transition().duration(300).attr("opacity",0).on("end",()=>{this.group.style("display","none")}),this._onVisibilityChange(500)):this.group.style("display",t?"":"none"),this.context.events.emit("series:visibilityChanged",this,t)}toggleVisible(){this.setVisible(!this.visible)}getDataExtents(){if(this._cachedExtents)return this._cachedExtents;let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data)o.x!==void 0&&o.x!==null&&(o.x<t&&(t=o.x),o.x>e&&(e=o.x)),o.y!==void 0&&o.y!==null&&(o.y<i&&(i=o.y),o.y>r&&(r=o.y));return this._cachedExtents={xMin:t,xMax:e,yMin:i,yMax:r},this._cachedExtents}getCategories(){return this.data.filter(t=>t.name!==void 0).map(t=>t.name)}destroy(){var t;(t=this.group)==null||t.remove()}setData(t,e=!0,i=!0){this.data=t,this.config._processedData=t,this._cachedExtents=null,e&&(i?this.animateUpdate(500):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoint(t,e=!0,i=!1,r=!0){if(this.data.push(t),this.config._processedData=this.data,i&&this.data.length>1)this.data.shift(),this.config._processedData=this.data,this._cachedExtents=null;else if(this._cachedExtents){const o=this._cachedExtents;t.x!==void 0&&t.x!==null&&(t.x<o.xMin&&(o.xMin=t.x),t.x>o.xMax&&(o.xMax=t.x)),t.y!==void 0&&t.y!==null&&(t.y<o.yMin&&(o.yMin=t.y),t.y>o.yMax&&(o.yMax=t.y))}e&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoints(t,e=!0,i=!1,r=!0){for(const o of t)this.data.push(o);i&&this.data.length>t.length&&this.data.splice(0,t.length),this.config._processedData=this.data,this._cachedExtents=null,e&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}removePoint(t,e=!0,i=!0){t>=0&&t<this.data.length&&(this.data.splice(t,1),this.config._processedData=this.data,this._cachedExtents=null,e&&(i?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this)))}updateSeries(t,e=!0){Object.assign(this.config,t),t.data&&(this.config._processedData=t.data,this.data=this.config._processedData,this._cachedExtents=null),e&&this.redraw()}applyBatch(t){for(const e of t.entries)switch(e.type){case"setData":this.data=e.payload,this.config._processedData=this.data;break;case"addPoint":this.data.push(e.payload.point),e.payload.shift&&this.data.length>1&&this.data.shift();break;case"addPoints":for(const i of e.payload.points)this.data.push(i);e.payload.shift&&this.data.splice(0,e.payload.points.length);break;case"removePoint":e.payload.index>=0&&e.payload.index<this.data.length&&this.data.splice(e.payload.index,1);break}this.config._processedData=this.data,this._cachedExtents=null,this.redraw(),this.context.events.emit("series:dataChanged",this)}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}getSelectedPoints(){return Array.from(this.selectedPoints).map(t=>({index:t,point:this.data[t]})).filter(t=>t.point!==void 0)}applyClipPath(){const{plotArea:t}=this.context;this.clipId=`katucharts-clip-${this.config.index}-${Date.now()}`;const e=this.group.select(function(){return this.ownerSVGElement});if(!e.empty()){let i=e.select("defs");i.empty()&&(i=e.append("defs")),i.append("clipPath").attr("id",this.clipId).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height),this.group.attr("clip-path",`url(#${this.clipId})`)}}applyShadowFilter(){const t=this.config.shadow;if(!t)return;const e=`katucharts-shadow-${this.config.index}-${Date.now()}`,i=this.group.select(function(){return this.ownerSVGElement});if(!i.empty()){let r=i.select("defs");r.empty()&&(r=i.append("defs"));const o=typeof t=="object"?t:{},s=o.offsetX??1,a=o.offsetY??1,c=o.width??3,l=o.opacity??.15;r.append("filter").attr("id",e).append("feDropShadow").attr("dx",s).attr("dy",a).attr("stdDeviation",c).attr("flood-opacity",l),this.group.style("filter",`url(#${e})`)}}applyInactiveState(){var r,o,s,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const e=((o=(r=this.config.states)==null?void 0:r.inactive)==null?void 0:o.opacity)??.2,i=((c=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??bs;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(i).ease(j).attr("opacity",e)}clearInactiveState(){var i,r,o,s,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const e=((o=(r=(i=this.config.states)==null?void 0:i.normal)==null?void 0:r.animation)==null?void 0:o.duration)??((c=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??bs;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(e).ease(j).attr("opacity",l.config.opacity??1)}emitAfterAnimate(t){var o;const e=!!((o=this.config.events)!=null&&o.afterAnimate),i=typeof this.config.animation=="object"?this.config.animation:null,r=!!(i!=null&&i.complete);(e||r)&&setTimeout(()=>{var s,a,c;(a=(s=this.config.events)==null?void 0:s.afterAnimate)==null||a.call(this,new Event("afterAnimate")),(c=i==null?void 0:i.complete)==null||c.call(i)},t)}renderDataLabels(t,e,i){const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;this.group.selectAll(".katucharts-data-labels").remove();const o=this.group.append("g").attr("class","katucharts-data-labels");this.getColor(),t.forEach((s,a)=>{var y,g;if(s.y===null||s.y===void 0)return;const c=s.dataLabels,l={...r,...c};let h;if(l.formatter?h=l.formatter.call({point:{...s,index:a},series:this,x:s.x??a,y:s.y,percentage:s._percentage}):l.format?h=oe(Kt(l.format,{point:s,series:{name:this.config.name??""},x:s.x,y:s.y,percentage:s._percentage??s.percentage})):h=String(s.y),l.filter){const m=s[l.filter.property??"y"]??0,x=l.filter.operator??">",v=l.filter.value??0;if(!(x===">"?m>v:x==="<"?m<v:x===">="?m>=v:x==="<="?m<=v:x==="=="?m===v:!0))return}const f=e(s,a)+(l.x??0),u=i(s,a)+(l.y??-10),d=o.append("text").attr("x",f).attr("y",u).attr("text-anchor",l.align==="left"?"start":l.align==="right"?"end":"middle").attr("dominant-baseline",l.verticalAlign==="top"?"text-before-edge":l.verticalAlign==="bottom"?"text-after-edge":"central").text(h),p=l.style||{};if(d.style("font-size",p.fontSize??kt).style("font-weight",p.fontWeight??"bold").style("fill",l.color||p.color||this.autoLabelColor()),p.textOutline&&d.style("text-shadow",p.textOutline),l.rotation&&d.attr("transform",`rotate(${l.rotation},${f},${u})`),l.backgroundColor||l.borderWidth){const m=(g=(y=d.node()).getBBox)==null?void 0:g.call(y);if(m){const x=l.padding??5,v=l.borderRadius??0;o.insert("rect",":last-child").attr("x",m.x-x).attr("y",m.y-x).attr("width",m.width+x*2).attr("height",m.height+x*2).attr("rx",v).attr("fill",l.backgroundColor||"none").attr("stroke",l.borderColor||"none").attr("stroke-width",l.borderWidth??0)}}this.context.animate&&l.defer!==!1&&d.attr("opacity",0).transition().delay(Qn+a*Nt).duration(400).ease(pt).attr("opacity",1)})}handlePointSelect(t,e,i,r){var s,a,c,l;if(!this.config.allowPointSelect)return;const o=this.selectedPoints.has(i);if(o){if(((a=(s=e.events)==null?void 0:s.unselect)==null?void 0:a.call(e,r))===!1)return;this.selectedPoints.delete(i),e.selected=!1,this.clearSelectStyle(t)}else{if(((l=(c=e.events)==null?void 0:c.select)==null?void 0:l.call(e,r))===!1)return;this.selectedPoints.add(i),e.selected=!0,this.applySelectStyle(t)}this.context.events.emit("point:select",{point:e,index:i,series:this,selected:!o})}applySelectStyle(t){var i;const e=(i=this.config.states)==null?void 0:i.select;e!=null&&e.color&&t.attr("fill",e.color),e!=null&&e.borderColor&&t.attr("stroke",e.borderColor),(e==null?void 0:e.borderWidth)!==void 0&&t.attr("stroke-width",e.borderWidth)}clearSelectStyle(t){t.attr("fill",null).attr("stroke",null).attr("stroke-width",null)}attachPointEvents(t,e,i){var s;if(this.config.enableMouseTracking===!1)return;const r=e.events||{},o=((s=this.config.point)==null?void 0:s.events)||{};t.on("mouseover",a=>{var c,l;this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:a,plotX:this.context.xAxis.getPixelForValue(e.x??i),plotY:this.context.yAxis.getPixelForValue(e.y??0)}),(c=r.mouseOver)==null||c.call(e,a),(l=o.mouseOver)==null||l.call(e,a)}).on("mouseout",a=>{var c,l;this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:a}),(c=r.mouseOut)==null||c.call(e,a),(l=o.mouseOut)==null||l.call(e,a)}).on("click",a=>{var c,l,h,f;this.context.events.emit("point:click",{point:e,index:i,series:this,event:a}),(c=r.click)==null||c.call(e,a),(l=o.click)==null||l.call(e,a),(f=(h=this.config.events)==null?void 0:h.click)==null||f.call(this,a),this.handlePointSelect(t,e,i,a)}),t.style("cursor",this.config.cursor||"pointer")}applyJitter(t,e,i){return i?t+(Math.random()-.5)*i*e:t}}function $c(n,t){const e=n.length;if(t>=e||t<3)return n;const i=new Array(t);i[0]=n[0],i[t-1]=n[e-1];const r=(e-2)/(t-2);let o=0;for(let s=1;s<t-1;s++){const a=Math.floor((s-1)*r)+1,c=Math.min(Math.floor(s*r)+1,e-1),l=Math.floor(s*r)+1,h=Math.min(Math.floor((s+1)*r)+1,e-1);let f=0,u=0;const d=h-l;for(let x=l;x<h;x++)f+=n[x].x??x,u+=n[x].y??0;d>0&&(f/=d,u/=d);const p=n[o].x??o,y=n[o].y??0;let g=-1,m=a;for(let x=a;x<c;x++){const v=n[x].x??x,b=n[x].y??0,k=Math.abs((p-f)*(b-y)-(p-v)*(u-y));k>g&&(g=k,m=x)}i[s]=n[m],o=m}return i}function U2(n,t){const e=n.length;if(t>=e||t<2)return n;const i=Math.ceil(t/2),r=e/i,o=[];o.push(n[0]);for(let s=0;s<i;s++){const a=Math.floor(s*r),c=Math.min(Math.floor((s+1)*r),e);let l=a,h=a,f=n[a].y??0,u=f;for(let d=a+1;d<c;d++){const p=n[d].y??0;p<f&&(f=p,l=d),p>u&&(u=p,h=d)}l<h?(o.push(n[l]),l!==h&&o.push(n[h])):(o.push(n[h]),l!==h&&o.push(n[l]))}return o[o.length-1]!==n[e-1]&&o.push(n[e-1]),o}const Kf=new WeakMap;function j2(n,t){let e=Kf.get(n);return e||(e=[],Kf.set(n,e),st(n).on("mousemove.hover-shared",i=>{const r=n.querySelector(".katucharts-plot-group");if(!r)return;const o=r.getScreenCTM();if(!o)return;const s=n.createSVGPoint();s.x=i.clientX,s.y=i.clientY;const a=s.matrixTransform(o.inverse()),c=a.x,l=a.y;if(c<0||c>t.width||l<0||l>t.height){for(const d of e)d.currentIdx>=0&&d.hideHover(i);return}let h=null,f=-1,u=1/0;for(const d of e){const p=d.findCandidate(c,l);p&&p.dist<u&&(u=p.dist,f=p.idx,h=d)}for(const d of e)d!==h&&d.currentIdx>=0&&d.hideHover(i);h&&f!==h.currentIdx&&h.showHover(f,i)}),st(n).on("mouseleave.hover-shared",i=>{for(const r of e)r.currentIdx>=0&&r.hideHover(i)}),st(n).on("click.hover-shared",i=>{for(const r of e)if(r.currentIdx>=0){r.handleClick(i);break}})),e}class q2{constructor(t){var a;this.config=t,this.currentIdx=-1;const{group:e,data:i,xAxis:r,plotArea:o}=t;this.validData=i.filter(c=>c.y!==null&&c.y!==void 0),this.xPositions=new Float64Array(this.validData.length);for(let c=0;c<this.validData.length;c++)this.xPositions[c]=r.getPixelForValue(this.validData[c].x??c);this.hoverGroup=e.append("g").attr("class","katucharts-hover-targets"),this.halo=this.hoverGroup.append("circle").attr("r",0).attr("opacity",0).attr("class","katucharts-halo"),this.hoverMarker=this.hoverGroup.append("circle").attr("r",t.markerRadius).attr("opacity",0).attr("class","katucharts-hover-marker").attr("stroke","#fff").attr("stroke-width",1);const s=(a=e.node())==null?void 0:a.ownerSVGElement;s&&j2(s,o).push(this)}findCandidate(t,e){const{yAxis:i}=this.config,r=this.xPositions;if(r.length===0)return null;let o=0,s=r.length-1;for(;o<s;){const h=o+s>>1;r[h]<t?o=h+1:s=h}let a=-1,c=1/0;const l=2;for(let h=Math.max(0,o-l);h<=Math.min(r.length-1,o+l);h++){const f=r[h],u=i.getPixelForValue(this.validData[h].y??0),d=Math.sqrt((f-t)**2+(u-e)**2);d<c&&(c=d,a=h)}return a<0||Math.abs(r[a]-t)>50?null:{idx:a,dist:c}}handleClick(t){var o,s,a,c,l,h,f;if(this.currentIdx<0)return;const{series:e,events:i}=this.config,r=this.validData[this.currentIdx];i.emit("point:click",{point:r,index:this.currentIdx,series:e,event:t}),(s=(o=r.events)==null?void 0:o.click)==null||s.call(r,t),(l=(c=(a=e.config.point)==null?void 0:a.events)==null?void 0:c.click)==null||l.call(r,t),(f=(h=e.config.events)==null?void 0:h.click)==null||f.call(e,t)}showHover(t,e){var x,v,b,k,M;if(t<0||t>=this.validData.length)return;const{series:i,events:r,yAxis:o,haloSize:s,haloOpacity:a,hoverRadius:c,hoverLineWidth:l,pathSelection:h,lineWidthPlus:f,baseLineWidth:u,getColor:d}=this.config,p=this.validData[t],y=this.xPositions[t],g=o.getPixelForValue(p.y??0),m=d(p);this.currentIdx>=0&&this.currentIdx!==t&&r.emit("point:mouseout",{point:this.validData[this.currentIdx],index:this.currentIdx,series:i,event:e}),this.currentIdx=t,this.halo.attr("cx",y).attr("cy",g).attr("fill",m).transition().duration(Z).ease(j).attr("r",s).attr("opacity",a),this.hoverMarker.attr("cx",y).attr("cy",g).attr("fill",m).transition().duration(Z).ease(j).attr("r",c).attr("opacity",1).attr("stroke-width",l),f&&h&&h.transition("hover").duration(Z).ease(j).attr("stroke-width",u+f),r.emit("point:mouseover",{point:p,index:t,series:i,event:e,plotX:y,plotY:g}),(v=(x=p.events)==null?void 0:x.mouseOver)==null||v.call(p,e),(M=(k=(b=i.config.point)==null?void 0:b.events)==null?void 0:k.mouseOver)==null||M.call(p,e)}hideHover(t){var s,a,c,l,h;const{series:e,events:i,pathSelection:r,baseLineWidth:o}=this.config;if(this.currentIdx>=0){const f=this.validData[this.currentIdx];i.emit("point:mouseout",{point:f,index:this.currentIdx,series:e,event:t}),(a=(s=f.events)==null?void 0:s.mouseOut)==null||a.call(f,t),(h=(l=(c=e.config.point)==null?void 0:c.events)==null?void 0:l.mouseOut)==null||h.call(f,t)}this.halo.transition().duration(Z).ease(j).attr("r",0).attr("opacity",0),this.hoverMarker.transition().duration(Z).ease(j).attr("r",this.config.markerRadius).attr("opacity",0),r&&r.transition("hover").duration(Z).ease(j).attr("stroke-width",o),this.currentIdx=-1}findNearest(t){const e=this.xPositions;if(e.length===0)return-1;let i=0,r=e.length-1;for(;i<r;){const o=i+r>>1;e[o]<t?i=o+1:r=o}return i>0&&Math.abs(e[i-1]-t)<Math.abs(e[i]-t)&&(i=i-1),Math.abs(e[i]-t)>30?-1:i}}const Z2={circle:bn,square:ps,diamond:ds,triangle:gs,"triangle-down":ms,cross:fs};class Jf extends Xt{constructor(t){super(t),this.pathSelection=null}render(){var r;const t=this.getColor(),e=this.getFilteredData(),i=this.context.animate;(r=this.config.zones)!=null&&r.length?this.renderZones(e,t):this.config.negativeColor&&this.config.threshold!==null?this.renderNegativeColor(e,t):this.renderMainLine(e,t,i),this.renderMarkers(e,t,!!i),this.renderHoverTargets(e,t),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0)),i&&this.emitAfterAnimate(bt+Qn)}renderMainLine(t,e,i){const r=this.buildLineGenerator();this.pathSelection=this.group.append("path").datum(t).attr("d",r).attr("fill","none").attr("stroke",e).attr("stroke-width",this.config.lineWidth??2).attr("stroke-dasharray",on(this.config.dashStyle)).attr("stroke-linecap",this.config.linecap||"round").attr("class","katucharts-line"),i&&this.animateLineEntry(this.pathSelection)}renderNegativeColor(t,e){const i=this.config.threshold??0,r=this.config.negativeColor,o=this.config.lineWidth??2,s=this.config.linecap||"round",a=on(this.config.dashStyle),c=[];let l=[],h=null;for(const f of t){if(f.y===null||f.y===void 0){l.length>0&&(c.push({points:l,negative:h}),l=[],h=null);continue}const u=f.y<i;h!==null&&u!==h&&l.length>0&&(c.push({points:[...l],negative:h}),l=[l[l.length-1]]),h=u,l.push(f)}l.length>0&&c.push({points:l,negative:h});for(const f of c){const u=this.buildLineGenerator();this.group.append("path").datum(f.points).attr("d",u).attr("fill","none").attr("stroke",f.negative?r:e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",a).attr("class","katucharts-line katucharts-negative-segment")}}renderZones(t,e){var u,d;const i=this.config.zones,r=this.config.zoneAxis||"y",o=this.config.lineWidth??2,s=this.config.linecap||"round";(u=this.pathSelection)==null||u.remove(),this.pathSelection=null;const a=[...i].sort((p,y)=>(p.value??1/0)-(y.value??1/0)),c=p=>r==="x"?p.x??0:p.y??0,l=t.filter(p=>p.y!==null&&p.y!==void 0),h=a.map(()=>[]),f=[];for(const p of l){const y=c(p);let g=!1;for(let m=0;m<a.length;m++)if(y<(a[m].value??1/0)){h[m].push(p),g=!0;break}g||f.push(p)}for(let p=0;p<a.length;p++)h[p].length!==0&&(p>0&&h[p-1].length>0&&h[p].unshift(h[p-1][h[p-1].length-1]),p<a.length-1&&((d=h[p+1])==null?void 0:d.length)>0?h[p].push(h[p+1][0]):f.length>0&&h[p].push(f[0]));for(let p=0;p<a.length;p++){const y=h[p];if(y.length<2)continue;const g=a[p],m=this.buildLineGenerator();this.group.append("path").datum(y).attr("d",m).attr("fill","none").attr("stroke",g.color||e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",on(g.dashStyle||this.config.dashStyle)).attr("class","katucharts-line katucharts-zone")}if(f.length>0){const p=h[h.length-1];if((p==null?void 0:p.length)>0&&f.unshift(p[p.length-1]),f.length>1){const y=this.buildLineGenerator();this.group.append("path").datum(f).attr("d",y).attr("fill","none").attr("stroke",e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",on(this.config.dashStyle)).attr("class","katucharts-line katucharts-zone")}}}animateUpdate(t){const e=this.getFilteredData(),i=this.buildLineGenerator(),r=this.getColor();this.pathSelection&&!this.pathSelection.empty()?this.pathSelection.datum(e).transition().duration(t).attr("d",i):(this.group.selectAll(".katucharts-line").remove(),this.renderMainLine(e,r,!1)),this.group.selectAll(".katucharts-markers").remove(),this.group.selectAll(".katucharts-hover-targets").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderMarkers(e,r,!1),this.renderHoverTargets(e,r),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0))}buildLineGenerator(){const{xAxis:t,yAxis:e}=this.context,i=this.config.connectNulls,r=!!this.context.inverted,o=(c,l)=>typeof c=="number"?l:(c==null?void 0:c.x)??l,s=c=>typeof c=="number"?c:c==null?void 0:c.y,a=Ai().x((c,l)=>r?e.getPixelForValue(s(c)??0):t.getPixelForValue(o(c,l))).y((c,l)=>r?t.getPixelForValue(o(c,l)):e.getPixelForValue(s(c)??0)).curve(this.getCurve());return i||a.defined(c=>{const l=s(c);return l!=null}),a}getFilteredData(){var e;let t;if(this.config.connectNulls?t=this.data.filter(i=>i.y!==null&&i.y!==void 0):t=this.data,(e=this.context)!=null&&e.plotArea){const r=this.context.plotArea.width*4;t.length>r&&(t=$c(t,Math.floor(r)))}return t}getCurve(){const t=this.config.step;return t==="left"?Uf:t==="center"?Yf:t==="right"?Xf:ji}animateLineEntry(t){var i,r;const e=((r=(i=t.node())==null?void 0:i.getTotalLength)==null?void 0:r.call(i))||0;if(e>0){const o=typeof this.config.animation=="object"?this.config.animation:{},s=o.duration??bt,a=o.defer??0,c=t.attr("stroke-dasharray");t.attr("stroke-dasharray",`${e} ${e}`).attr("stroke-dashoffset",e).transition().delay(a).duration(s).ease(pt).attr("stroke-dashoffset",0).on("end",()=>{t.attr("stroke-dasharray",c==="none"?null:c)})}}renderMarkers(t,e,i){const r=this.config.marker,o=(r==null?void 0:r.enabledThreshold)??2;if(!((r==null?void 0:r.enabled)===!0||(r==null?void 0:r.enabled)!==!1&&t.length<=o*this.context.plotArea.width/12))return;const{xAxis:a,yAxis:c}=this.context,l=(r==null?void 0:r.radius)??4,h=(r==null?void 0:r.symbol)||"circle",f=this.group.append("g").attr("class","katucharts-markers"),u=t.filter(d=>d.y!==null&&d.y!==void 0);if(h==="circle"){const d=f.selectAll("circle").data(u).join("circle").attr("cx",p=>a.getPixelForValue(p.x??0)).attr("cy",p=>c.getPixelForValue(p.y??0)).attr("fill",(p,y)=>this.getMarkerFill(p,y,r,e)).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");i?d.attr("r",0).transition().delay((p,y)=>xe(y,Qn,Nt,u.length)).duration(bt).ease(pt).attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??l}):d.attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??l})}else{const d=Z2[h]||bn,p=Math.PI*l*l;Ve().type(d).size(p);const y=f.selectAll("path").data(u).join("path").attr("transform",g=>`translate(${a.getPixelForValue(g.x??0)},${c.getPixelForValue(g.y??0)})`).attr("fill",(g,m)=>this.getMarkerFill(g,m,r,e)).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");if(i){const g=Ve().type(d).size(0);y.attr("d",g).transition().delay((m,x)=>xe(x,Qn,Nt,u.length)).duration(bt).ease(pt).attr("d",m=>{var v;const x=((v=m.marker)==null?void 0:v.radius)??l;return Ve().type(d).size(Math.PI*x*x)()})}else y.attr("d",g=>{var x;const m=((x=g.marker)==null?void 0:x.radius)??l;return Ve().type(d).size(Math.PI*m*m)()})}}getMarkerFill(t,e,i,r){var o;return t.color?t.color:(o=t.marker)!=null&&o.fillColor?t.marker.fillColor:i!=null&&i.fillColor?i.fillColor:this.config.negativeColor&&(t.y??0)<(this.config.threshold??0)?this.config.negativeColor:r}renderHoverTargets(t,e){var f,u,d,p,y,g,m,x;if(this.config.enableMouseTracking===!1)return;const i=((f=this.config.marker)==null?void 0:f.radius)??4,r=(d=(u=this.config.marker)==null?void 0:u.states)==null?void 0:d.hover,o=(r==null?void 0:r.radiusPlus)??2,s=(r==null?void 0:r.radius)??i+o,a=(r==null?void 0:r.lineWidthPlus)??1,c=(r==null?void 0:r.lineWidth)??(((p=this.config.marker)==null?void 0:p.lineWidth)??1)+a,l=((g=(y=this.config.states)==null?void 0:y.hover)==null?void 0:g.lineWidthPlus)??1,h=(x=(m=this.config.states)==null?void 0:m.hover)==null?void 0:x.halo;new q2({series:this,group:this.group,data:t,xAxis:this.context.xAxis,yAxis:this.context.yAxis,plotArea:this.context.plotArea,events:this.context.events,haloSize:(h==null?void 0:h.size)??10,haloOpacity:(h==null?void 0:h.opacity)??.25,markerRadius:i,hoverRadius:s,hoverLineWidth:c,cursor:this.config.cursor||"pointer",pathSelection:this.pathSelection,lineWidthPlus:l,baseLineWidth:this.config.lineWidth??2,getColor:v=>v.color||e})}}class K2 extends Jf{constructor(t){super(t)}getCurve(){return Vf.alpha(.5)}}function Ic(n){return!!n&&typeof n=="object"&&("linearGradient"in n||"radialGradient"in n)}let J2=0;function Qf(n,t,e){const i=lo(e);n.append("stop").attr("offset",String(t)).attr("stop-color",`rgb(${i.r}, ${i.g}, ${i.b})`).attr("stop-opacity",i.a)}function ti(n,t,e){if(n==null)return e;if(typeof n=="string")return n;if(!Ic(n))return e;const i=`katucharts-fill-grad-${++J2}`,r=t.append("defs");if("radialGradient"in n){const o=n.radialGradient,s=r.append("radialGradient").attr("id",i).attr("cx",String(o.cx??.5)).attr("cy",String(o.cy??.5)).attr("r",String(o.r??.5));for(const[a,c]of n.stops)Qf(s,a,c)}else{const o=n.linearGradient,s=r.append("linearGradient").attr("id",i).attr("x1",String(o.x1??0)).attr("y1",String(o.y1??0)).attr("x2",String(o.x2??0)).attr("y2",String(o.y2??1));for(const[a,c]of n.stops)Qf(s,a,c)}return`url(#${i})`}const Q2={circle:bn,square:ps,diamond:ds,triangle:gs,"triangle-down":ms,cross:fs};class td extends Xt{constructor(t){super(t),this.isSpline=!1,this.areaPath=null,this.linePath=null,this.negAreaPath=null}render(){var r;const t=this.getColor(),e=this.getFilteredData(),i=this.context.animate;(r=this.config.zones)!=null&&r.length?this.renderZones(e,t):this.config.negativeFillColor||this.config.negativeColor?this.renderWithNegativeColor(e,t,!!i):this.renderMainArea(e,t,!!i),this.renderMarkers(e,t,!!i),this.config.trackByArea?this.renderAreaHoverTargets(e,t):this.renderHoverTargets(e,t),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0)),i&&this.emitAfterAnimate(bt+Qn)}renderMainArea(t,e,i){const{areaGen:r,lineGen:o}=this.buildGenerators(),s=this.config.lineColor||e,a=Ic(this.config.fillColor),c=ti(this.config.fillColor,this.group,e),l=this.config.fillOpacity??(a?1:.75);if(this.areaPath=this.group.append("path").datum(t).attr("d",r).attr("fill",c).attr("class","katucharts-area"),this.linePath=this.group.append("path").datum(t).attr("d",o).attr("fill","none").attr("stroke",s).attr("stroke-width",this.config.lineWidth??2).attr("stroke-linecap",this.config.linecap||"round").attr("stroke-dasharray",on(this.config.dashStyle)).attr("class","katucharts-area-line"),i){const f=(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt;this.areaPath.attr("fill-opacity",0).transition().duration(f).ease(pt).attr("fill-opacity",l),this.animateLineEntry(this.linePath)}else this.areaPath.attr("fill-opacity",l)}renderWithNegativeColor(t,e,i){const{xAxis:r,yAxis:o}=this.context,s=this.config.threshold??0,a=o.getPixelForValue(s),c=this.getCurve(),l=this.config.fillOpacity??(Ic(this.config.fillColor)?1:.75),h=ti(this.config.negativeFillColor||this.config.negativeColor,this.group,e),f=ti(this.config.fillColor,this.group,e),u=this.config.lineColor||e,d=t.filter(g=>g.y!==null&&g.y!==void 0&&(g.y??0)>=s),p=t.filter(g=>g.y!==null&&g.y!==void 0&&(g.y??0)<s);if(d.length>0){const g=qi().x(m=>r.getPixelForValue(m.x??0)).y0(a).y1(m=>o.getPixelForValue(m.y??0)).curve(c);this.areaPath=this.group.append("path").datum(d).attr("d",g).attr("fill",f).attr("fill-opacity",l).attr("class","katucharts-area katucharts-area-positive")}if(p.length>0){const g=qi().x(m=>r.getPixelForValue(m.x??0)).y0(a).y1(m=>o.getPixelForValue(m.y??0)).curve(c);this.negAreaPath=this.group.append("path").datum(p).attr("d",g).attr("fill",h).attr("fill-opacity",l).attr("class","katucharts-area katucharts-area-negative")}const y=Ai().defined(g=>g.y!==null&&g.y!==void 0).x(g=>r.getPixelForValue(g.x??0)).y(g=>o.getPixelForValue(g.y??0)).curve(c);if(this.linePath=this.group.append("path").datum(t).attr("d",y).attr("fill","none").attr("stroke",u).attr("stroke-width",this.config.lineWidth??2).attr("stroke-linecap",this.config.linecap||"round").attr("stroke-dasharray",on(this.config.dashStyle)).attr("class","katucharts-area-line"),i){const m=(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt;this.areaPath&&this.areaPath.attr("fill-opacity",0).transition().duration(m).ease(pt).attr("fill-opacity",l),this.negAreaPath&&this.negAreaPath.attr("fill-opacity",0).transition().duration(m).ease(pt).attr("fill-opacity",l),this.animateLineEntry(this.linePath)}}renderZones(t,e){const{xAxis:i,yAxis:r}=this.context,o=this.config.zones,s=this.config.zoneAxis||"y",a=this.config.fillOpacity??.75,c=this.config.lineWidth??2,l=this.getCurve(),h=r.getPixelForValue(this.config.threshold??0),f=[...o].sort((g,m)=>(g.value??1/0)-(m.value??1/0)),u=g=>s==="x"?g.x??0:g.y??0,d=t.filter(g=>g.y!==null&&g.y!==void 0);let p=-1/0;const y=(g,m,x,v)=>{if(g.length<2)return;const b=qi().x(M=>i.getPixelForValue(M.x??0)).y0(h).y1(M=>r.getPixelForValue(M.y??0)).curve(l);this.group.append("path").datum(g).attr("d",b).attr("fill",ti(x,this.group,m)).attr("fill-opacity",a).attr("class","katucharts-area katucharts-zone");const k=Ai().x(M=>i.getPixelForValue(M.x??0)).y(M=>r.getPixelForValue(M.y??0)).curve(l);this.group.append("path").datum(g).attr("d",k).attr("fill","none").attr("stroke",m).attr("stroke-width",c).attr("stroke-dasharray",on(v||this.config.dashStyle)).attr("class","katucharts-area-line katucharts-zone")};for(const g of f){const m=g.value??1/0,x=g.color||e,v=g.fillColor||x,b=[];for(let k=0;k<d.length;k++){const M=u(d[k]);if(M>=p&&M<m)b.length===0&&k>0&&b.push(d[k-1]),b.push(d[k]);else if(M>=m&&b.length>0){b.push(d[k]);break}}y(b,x,v,g.dashStyle),p=m}if(p!==1/0){const g=[];for(let m=0;m<d.length;m++)u(d[m])>=p&&(g.length===0&&m>0&&g.push(d[m-1]),g.push(d[m]));y(g,e,this.config.fillColor)}}getCurve(){if(this.isSpline)return Vf.alpha(.5);const t=this.config.step;return t==="left"?Uf:t==="center"?Yf:t==="right"?Xf:ji}getFilteredData(){var e;let t;if(this.config.connectNulls?t=this.data.filter(i=>i.y!==null&&i.y!==void 0):t=this.data,(e=this.context)!=null&&e.plotArea){const r=this.context.plotArea.width*4;t.length>r&&(t=$c(t,Math.floor(r)))}return t}buildGenerators(){const{xAxis:t,yAxis:e}=this.context,i=e.getPixelForValue(this.config.threshold??0),r=this.getCurve(),o=this.context.stackOffsets,s=this.config.stacking,a=this.config.connectNulls,c=u=>!s||!o?u.y??0:(o.get(u.x??0)||0)+(u.y??0),l=u=>!s||!o?this.config.threshold??0:o.get(u.x??0)||0,h=qi().x(u=>t.getPixelForValue(u.x??0)).y0(u=>s?e.getPixelForValue(l(u)):i).y1(u=>e.getPixelForValue(c(u))).curve(r),f=Ai().x(u=>t.getPixelForValue(u.x??0)).y(u=>e.getPixelForValue(c(u))).curve(r);return a||(h.defined(u=>u.y!==null&&u.y!==void 0),f.defined(u=>u.y!==null&&u.y!==void 0)),{areaGen:h,lineGen:f}}animateUpdate(t){const e=this.getFilteredData(),{areaGen:i,lineGen:r}=this.buildGenerators(),o=this.getColor();this.areaPath&&!this.areaPath.empty()&&this.areaPath.datum(e).transition().duration(t).attr("d",i),this.linePath&&!this.linePath.empty()&&this.linePath.datum(e).transition().duration(t).attr("d",r),this.group.selectAll(".katucharts-hover-targets").remove(),this.group.selectAll(".katucharts-markers").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderMarkers(e,o,!1),this.config.trackByArea?this.renderAreaHoverTargets(e,o):this.renderHoverTargets(e,o),this.renderDataLabels(e.filter(s=>s.y!==null&&s.y!==void 0),(s,a)=>this.context.xAxis.getPixelForValue(s.x??a),s=>this.context.yAxis.getPixelForValue(s.y??0))}animateLineEntry(t){var i,r;const e=((r=(i=t.node())==null?void 0:i.getTotalLength)==null?void 0:r.call(i))||0;if(e>0){const o=typeof this.config.animation=="object"?this.config.animation:{},s=o.duration??bt,a=o.defer??0,c=t.attr("stroke-dasharray");t.attr("stroke-dasharray",`${e} ${e}`).attr("stroke-dashoffset",e).transition().delay(a).duration(s).ease(pt).attr("stroke-dashoffset",0).on("end",()=>t.attr("stroke-dasharray",c==="none"?null:c))}}renderMarkers(t,e,i){const r=this.config.marker;if((r==null?void 0:r.enabled)!==!0)return;const{xAxis:o,yAxis:s}=this.context,a=(r==null?void 0:r.radius)??4,c=(r==null?void 0:r.symbol)||"circle",l=this.group.append("g").attr("class","katucharts-markers"),h=t.filter(f=>f.y!==null&&f.y!==void 0);if(c==="circle"){const f=l.selectAll("circle").data(h).join("circle").attr("cx",u=>o.getPixelForValue(u.x??0)).attr("cy",u=>s.getPixelForValue(u.y??0)).attr("fill",u=>u.color||(r==null?void 0:r.fillColor)||e).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");i?f.attr("r",0).transition().delay((u,d)=>xe(d,Qn,Nt,h.length)).duration(bt).ease(pt).attr("r",u=>{var d;return((d=u.marker)==null?void 0:d.radius)??a}):f.attr("r",u=>{var d;return((d=u.marker)==null?void 0:d.radius)??a})}else{const f=Q2[c]||bn,u=l.selectAll("path").data(h).join("path").attr("transform",d=>`translate(${o.getPixelForValue(d.x??0)},${s.getPixelForValue(d.y??0)})`).attr("fill",d=>d.color||(r==null?void 0:r.fillColor)||e).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");if(i){const d=Ve().type(f).size(0);u.attr("d",d).transition().delay((p,y)=>xe(y,Qn,Nt,h.length)).duration(bt).ease(pt).attr("d",p=>{var g;const y=((g=p.marker)==null?void 0:g.radius)??a;return Ve().type(f).size(Math.PI*y*y)()})}else u.attr("d",d=>{var y;const p=((y=d.marker)==null?void 0:y.radius)??a;return Ve().type(f).size(Math.PI*p*p)()})}}renderAreaHoverTargets(t,e){if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=r.getPixelForValue(this.config.threshold??0),s=this.getCurve(),a=qi().x(h=>i.getPixelForValue(h.x??0)).y0(o).y1(h=>r.getPixelForValue(h.y??0)).curve(s),c=t.filter(h=>h.y!==null&&h.y!==void 0);this.group.append("path").datum(c).attr("d",a).attr("fill","transparent").attr("class","katucharts-hover-targets").style("cursor",this.config.cursor||"pointer").on("mousemove",h=>{const[f]=[h.offsetX-(this.context.plotArea.x||0)];let u=0,d=1/0;c.forEach((y,g)=>{const m=i.getPixelForValue(y.x??0),x=Math.abs(m-f);x<d&&(d=x,u=g)});const p=c[u];this.context.events.emit("point:mouseover",{point:p,index:u,series:this,event:h,plotX:i.getPixelForValue(p.x??0),plotY:r.getPixelForValue(p.y??0)})}).on("mouseout",h=>{this.context.events.emit("point:mouseout",{point:c[0],index:0,series:this,event:h})}).on("click",h=>{var y,g,m,x;const[f]=[h.offsetX-(this.context.plotArea.x||0)];let u=0,d=1/0;c.forEach((v,b)=>{const k=i.getPixelForValue(v.x??0),M=Math.abs(k-f);M<d&&(d=M,u=b)});const p=c[u];this.context.events.emit("point:click",{point:p,index:u,series:this,event:h}),(g=(y=p.events)==null?void 0:y.click)==null||g.call(p,h),(x=(m=this.config.events)==null?void 0:m.click)==null||x.call(this,h)})}renderHoverTargets(t,e){var f,u,d,p,y;if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=this.group.append("g").attr("class","katucharts-hover-targets"),s=((d=(u=(f=this.config.marker)==null?void 0:f.states)==null?void 0:u.hover)==null?void 0:d.radius)??6,a=t.filter(g=>g.y!==null&&g.y!==void 0),c=(y=(p=this.config.states)==null?void 0:p.hover)==null?void 0:y.halo,l=(c==null?void 0:c.size)??10,h=(c==null?void 0:c.opacity)??.25;a.forEach((g,m)=>{const x=i.getPixelForValue(g.x??0),v=r.getPixelForValue(g.y??0),b=o.append("circle").attr("cx",x).attr("cy",v).attr("r",0).attr("fill",g.color||e).attr("opacity",0).attr("class","katucharts-halo"),k=o.append("circle").attr("cx",x).attr("cy",v).attr("r",0).attr("fill",g.color||e).attr("stroke",this.autoBorderColor()).attr("stroke-width",1).attr("class","katucharts-hover-marker");o.append("circle").attr("cx",x).attr("cy",v).attr("r",15).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",C=>{var E,_,T,I,L;b.transition().duration(Z).ease(j).attr("r",l).attr("opacity",h),k.transition().duration(Z).ease(j).attr("r",s),this.context.events.emit("point:mouseover",{point:g,index:m,series:this,event:C,plotX:x,plotY:v}),(_=(E=g.events)==null?void 0:E.mouseOver)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.mouseOver)==null||L.call(g,C)}).on("mouseout",C=>{var E,_,T,I,L;b.transition().duration(Z).ease(j).attr("r",0).attr("opacity",0),k.transition().duration(Z).ease(j).attr("r",0),this.context.events.emit("point:mouseout",{point:g,index:m,series:this,event:C}),(_=(E=g.events)==null?void 0:E.mouseOut)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.mouseOut)==null||L.call(g,C)}).on("click",C=>{var E,_,T,I,L,P,A;this.context.events.emit("point:click",{point:g,index:m,series:this,event:C}),(_=(E=g.events)==null?void 0:E.click)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.click)==null||L.call(g,C),(A=(P=this.config.events)==null?void 0:P.click)==null||A.call(this,C),this.handlePointSelect(k,g,m,C)})})}}class tw extends td{constructor(){super(...arguments),this.isSpline=!0}}function Fc(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}function ew(n,t,e,i,r,o,s){if(e<=0||i<=0)return`M${n},${t}H${n}V${t}Z`;const a=o?Math.min(r,e/2,i/2):0,c=s?Math.min(r,e/2,i/2):0;return`M${n+a},${t}H${n+e-a}`+(a?`A${a},${a},0,0,1,${n+e},${t+a}`:`L${n+e},${t}`)+`V${t+i-c}`+(c?`A${c},${c},0,0,1,${n+e-c},${t+i}`:`L${n+e},${t+i}`)+`H${n+c}`+(c?`A${c},${c},0,0,1,${n},${t+i-c}`:`L${n},${t+i}`)+`V${t+a}`+(a?`A${a},${a},0,0,1,${n+a},${t}`:`L${n},${t}`)+"Z"}function nw(n,t,e,i,r,o,s){if(e<=0||i<=0)return`M${n},${t}H${n}V${t}Z`;const a=o?Math.min(r,e/2,i/2):0,c=s?Math.min(r,e/2,i/2):0;return`M${n+c},${t}H${n+e-a}`+(a?`A${a},${a},0,0,1,${n+e},${t+a}`:`L${n+e},${t}`)+`V${t+i-a}`+(a?`A${a},${a},0,0,1,${n+e-a},${t+i}`:`L${n+e},${t+i}`)+`H${n+c}`+(c?`A${c},${c},0,0,1,${n},${t+i-c}`:`L${n},${t+i}`)+`V${t+c}`+(c?`A${c},${c},0,0,1,${n+c},${t}`:`L${n},${t}`)+"Z"}class ed extends Xt{constructor(t){super(t),this.isHorizontal=!1}getEntryDuration(){return(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt}render(){this.group.selectAll(".katucharts-data-labels").remove();const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{barWidth:a,barOffset:c,baseline:l}=this.computeBarGeometry(),h=this.config.stacking,f=this.context.stackOffsets,u=h==="percent",d=u?this.context.stackTotals:void 0,p=b=>{const k=b.x??0,M=(f==null?void 0:f.get(k))||0,C=b.y??0;if(u&&d){const E=d.get(k)||1;return(M+C)/E*100}return M+C},y=b=>{const k=b.x??0,M=(f==null?void 0:f.get(k))||0;if(u&&d){const C=d.get(k)||1;return M/C*100}return M};if(h){const b=this.context.stackTotals;for(const k of o){const M=k.x??0;if(b&&(k.total=b.get(M)||0,k.stackTotal=b.get(M)||0),u&&b){const C=b.get(M)||1;k.percentage=(k.y??0)/C*100}}}const g=this.config.minPointLength??0,m=this.config.crisp!==!1,x=Fc(this.config.borderRadius);if(h){const b=this.group.selectAll(".katucharts-column").data(o).join("path").attr("class","katucharts-column").attr("stroke",k=>k.borderColor||this.config.borderColor||"none").attr("stroke-width",k=>k.borderWidth??this.config.borderWidth??0);this.renderStackedBars(b,o,a,c,p,y,r,g,m,!!s,x),this.attachHoverEffects(b,o),this.renderColumnDataLabels(o,a,c,l,p,y),s&&this.emitAfterAnimate(bt+o.length*Nt);return}const v=this.group.selectAll(".katucharts-column").data(o).join("rect").attr("class","katucharts-column").attr("rx",x).attr("stroke",b=>b.borderColor||this.config.borderColor||"none").attr("stroke-width",b=>b.borderWidth??this.config.borderWidth??0);this.isHorizontal?this.renderHorizontalBars(v,o,a,c,l,r,g,m,!!s):this.renderVerticalBars(v,o,a,c,l,r,g,m,!!s),this.attachHoverEffects(v,o),this.renderColumnDataLabels(o,a,c,l,h?p:void 0,h?y:void 0),s&&this.emitAfterAnimate(bt+o.length*Nt)}renderVerticalBars(t,e,i,r,o,s,a,c,l){const{xAxis:h,yAxis:f}=this.context,u=this.config.threshold??0,d=this.config.negativeColor;if(t.attr("x",p=>this.crispCoord(h.getPixelForValue(p.x??0)+r,c)).attr("width",c?Math.round(i):i).attr("fill",(p,y)=>this.getPointColor(p,y,s,d,u)).attr("display",p=>p.y==null?"none":null),l){const p=this.getEntryDuration();t.attr("y",o).attr("height",0).transition().duration(p).ease(pt).delay((y,g)=>xe(g,0,Nt,e.length)).attr("y",y=>this.getBarY(y,f,o,a)).attr("height",y=>this.getBarHeight(y,f,o,a))}else t.attr("y",p=>this.getBarY(p,f,o,a)).attr("height",p=>this.getBarHeight(p,f,o,a))}renderHorizontalBars(t,e,i,r,o,s,a,c,l){const{xAxis:h,yAxis:f}=this.context,u=this.config.threshold??0,d=this.config.negativeColor;if(t.attr("y",p=>this.crispCoord(h.getPixelForValue(p.x??0)+r,c)).attr("height",c?Math.round(i):i).attr("fill",(p,y)=>this.getPointColor(p,y,s,d,u)).attr("display",p=>p.y==null?"none":null),l){const p=this.getEntryDuration();t.attr("x",o).attr("width",0).transition().duration(p).ease(pt).delay((y,g)=>xe(g,0,Nt,e.length)).attr("x",y=>{const g=f.getPixelForValue(y.y??0);return Math.min(o,g)}).attr("width",y=>{const g=Math.abs(f.getPixelForValue(y.y??0)-o);return Math.max(g,a)})}else t.attr("x",p=>Math.min(o,f.getPixelForValue(p.y??0))).attr("width",p=>Math.max(Math.abs(f.getPixelForValue(p.y??0)-o),a))}renderStackedBars(t,e,i,r,o,s,a,c,l,h,f){const u=this.context.totalSeriesOfType||1,d=this.context.indexInType||0,p=d===u-1,y=d===0,g=f??0;if(t.attr("fill",(m,x)=>this.getPointColor(m,x,a)),h){const m=this.getEntryDuration();t.each((x,v,b)=>{const k=st(b[v]),M=this.computeStackedStartParams(x,e,i,r,s,l),C=this.computeStackedRectParams(x,e,i,r,o,s,l,c);x._rectParams=C,k.attr("d",this.rectParamsToPath(M,g,p,y)).transition().duration(m).ease(pt).delay(xe(v,0,Nt,e.length)).attrTween("d",()=>{const E=he(M.x,C.x),_=he(M.y,C.y),T=he(M.w,C.w),I=he(M.h,C.h);return L=>this.rectParamsToPath({x:E(L),y:_(L),w:T(L),h:I(L)},g,p,y)})})}else t.each((m,x,v)=>{const b=this.computeStackedRectParams(m,e,i,r,o,s,l,c);m._rectParams=b,st(v[x]).attr("d",this.rectParamsToPath(b,g,p,y))})}getBarY(t,e,i,r){const o=e.getPixelForValue(t.y??0),s=Math.min(o,i),a=Math.abs(o-i);return a<r&&(t.y??0)>=(this.config.threshold??0)?s-(r-a):s}getBarHeight(t,e,i,r){return Math.max(Math.abs(e.getPixelForValue(t.y??0)-i),r)}crispCoord(t,e){return e?Math.round(t):t}computeStackedRectParams(t,e,i,r,o,s,a,c){const{xAxis:l,yAxis:h}=this.context;if(this.isHorizontal){const f=this.crispCoord(l.getPixelForValue(t.x??e.indexOf(t))+r,a),u=a?Math.round(i):i,d=Math.min(h.getPixelForValue(o(t)),h.getPixelForValue(s(t))),p=Math.max(Math.abs(h.getPixelForValue(o(t))-h.getPixelForValue(s(t))),c);return{x:d,y:f,w:p,h:u}}else{const f=this.crispCoord(l.getPixelForValue(t.x??0)+r,a),u=a?Math.round(i):i,d=Math.min(h.getPixelForValue(o(t)),h.getPixelForValue(s(t))),p=Math.max(Math.abs(h.getPixelForValue(o(t))-h.getPixelForValue(s(t))),c);return{x:f,y:d,w:u,h:p}}}computeStackedStartParams(t,e,i,r,o,s){const{xAxis:a,yAxis:c}=this.context;if(this.isHorizontal){const l=this.crispCoord(a.getPixelForValue(t.x??e.indexOf(t))+r,s),h=s?Math.round(i):i;return{x:c.getPixelForValue(o(t)),y:l,w:.1,h}}else{const l=this.crispCoord(a.getPixelForValue(t.x??0)+r,s),h=s?Math.round(i):i,f=c.getPixelForValue(o(t));return{x:l,y:f,w:h,h:.1}}}rectParamsToPath(t,e,i,r){return this.isHorizontal?nw(t.x,t.y,t.w,t.h,e,i,r):ew(t.x,t.y,t.w,t.h,e,i,r)}animateUpdate(t){if(this.config.stacking){this.updateStackedBars(t);return}const{xAxis:i,yAxis:r,plotArea:o}=this.context,s=this.getColor(),a=this.data,{barWidth:c,barOffset:l,baseline:h}=this.computeBarGeometry(),f=this.config.minPointLength??0,u=this.config.crisp!==!1,d=this.config.threshold??0,p=this.config.negativeColor,y=this.group.selectAll(".katucharts-column").data(a),g=y.enter().append("rect").attr("class","katucharts-column").attr("rx",Fc(this.config.borderRadius)).attr("fill",(x,v)=>this.getPointColor(x,v,s,p,d)).attr("display",x=>x.y==null?"none":null).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0);this.isHorizontal||g.attr("x",x=>this.crispCoord(i.getPixelForValue(x.x??0)+l,u)).attr("width",u?Math.round(c):c).attr("y",h).attr("height",0);const m=g.merge(y);m.attr("display",x=>x.y==null?"none":null),this.isHorizontal?m.transition().duration(t).attr("y",x=>this.crispCoord(i.getPixelForValue(x.x??0)+l,u)).attr("height",u?Math.round(c):c).attr("x",x=>Math.min(h,r.getPixelForValue(x.y??0))).attr("width",x=>Math.max(Math.abs(r.getPixelForValue(x.y??0)-h),f)).attr("fill",(x,v)=>this.getPointColor(x,v,s,p,d)):m.transition().duration(t).attr("x",x=>this.crispCoord(i.getPixelForValue(x.x??0)+l,u)).attr("width",u?Math.round(c):c).attr("y",x=>this.getBarY(x,r,h,f)).attr("height",x=>this.getBarHeight(x,r,h,f)).attr("fill",(x,v)=>this.getPointColor(x,v,s,p,d)),y.exit().transition().duration(t).attr("opacity",0).remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.attachHoverEffects(this.group.selectAll(".katucharts-column"),a),this.renderColumnDataLabels(a,c,l,h)}updateStackedBars(t){const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data,{barWidth:a,barOffset:c,baseline:l}=this.computeBarGeometry(),h=this.config.stacking,f=this.context.stackOffsets,u=h==="percent",d=this.config.crisp!==!1,p=Fc(this.config.borderRadius),y=this.config.minPointLength??0,g=u?this.context.stackTotals:void 0,m=_=>{const T=_.x??0,I=(f==null?void 0:f.get(T))||0,L=_.y??0;if(u&&g){const P=g.get(T)||1;return(I+L)/P*100}return I+L},x=_=>{const T=_.x??0,I=(f==null?void 0:f.get(T))||0;if(u&&g){const L=g.get(T)||1;return I/L*100}return I};if(h){const _=this.context.stackTotals;for(const T of s){const I=T.x??0;if(_&&(T.total=_.get(I)||0,T.stackTotal=_.get(I)||0),u&&_){const L=_.get(I)||1;T.percentage=(T.y??0)/L*100}}}const v=this.context.totalSeriesOfType||1,b=this.context.indexInType||0,k=b===v-1,M=b===0,C=p,E=this.group.selectAll(".katucharts-column").data(s);E.each((_,T,I)=>{const L=st(I[T]),P=this.computeStackedRectParams(_,s,a,c,m,x,d,y),A=_._rectParams||P;_._rectParams=P,L.transition().duration(t).attrTween("d",()=>{const w=he(A.x,P.x),S=he(A.y,P.y),$=he(A.w,P.w),R=he(A.h,P.h);return F=>this.rectParamsToPath({x:w(F),y:S(F),w:$(F),h:R(F)},C,k,M)}).attr("fill",this.getPointColor(_,T,o))}),E.enter().append("path").attr("class","katucharts-column").attr("stroke",_=>_.borderColor||this.config.borderColor||"none").attr("stroke-width",_=>_.borderWidth??this.config.borderWidth??0).attr("fill",(_,T)=>this.getPointColor(_,T,o)).each((_,T,I)=>{const L=this.computeStackedRectParams(_,s,a,c,m,x,d,y);_._rectParams=L,st(I[T]).attr("d",this.rectParamsToPath(L,C,k,M))}),E.exit().transition().duration(t).attr("opacity",0).remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.attachHoverEffects(this.group.selectAll(".katucharts-column"),s),this.renderColumnDataLabels(s,a,c,l,m,x)}computeBarGeometry(){var y,g;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=!!this.config.stacking,o=r?1:this.config.grouping!==!1&&this.context.totalSeriesOfType||1,s=r?0:this.config.grouping!==!1&&this.context.indexInType||0,a=this.config.groupPadding??.2,c=this.config.pointPadding??.1;let l;if(t instanceof cf)l=t.getBandwidth();else if(this.isHorizontal)l=i.height/Math.max(this.data.length,1);else if(this.config.pointRange!==void 0&&this.config.pointRange>0)l=Math.abs(t.getPixelForValue(this.config.pointRange)-t.getPixelForValue(0));else{const m=this.data;l=m.length>1?Math.abs(t.getPixelForValue(((y=m[1])==null?void 0:y.x)??1)-t.getPixelForValue(((g=m[0])==null?void 0:g.x)??0))*(1-a*2):i.width/Math.max(m.length,1)*(1-a*2)}const h=r?0:a,f=r?0:c;let u;this.config.pointWidth!==void 0?u=this.config.pointWidth:u=l*(1-h*2)/o*(1-f*2),this.config.maxPointWidth!==void 0&&(u=Math.min(u,this.config.maxPointWidth));let d;this.config.centerInCategory?d=-u/2:d=-l*(1-h*2)/2+(u+u*f*2)*s+u*f;const p=e.getPixelForValue(this.config.threshold??0);return{barWidth:u,barOffset:d,baseline:p,groupWidth:l}}getPointColor(t,e,i,r,o){if(t.color)return t.color;if(this.config.colorByPoint){const s=this.config.colors||this.context.colors;return s[e%s.length]}return r&&(t.y??0)<(o??0)?r:i}renderColumnDataLabels(t,e,i,r,o,s){const a=this.config.dataLabels;if(!(a!=null&&a.enabled))return;const{xAxis:c,yAxis:l}=this.context,h=a.inside??!1;this.renderDataLabels(t,f=>{if(this.isHorizontal){const u=l.getPixelForValue(f.y??0);return h?(u+r)/2:u-5}return c.getPixelForValue(f.x??0)+i+e/2},f=>{if(this.isHorizontal)return c.getPixelForValue(f.x??0)+i+e/2;const u=o?l.getPixelForValue(o(f)):l.getPixelForValue(f.y??0);return h?(u+r)/2:u})}attachHoverEffects(t,e){var h,f,u,d,p,y,g,m;if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=!!this.config.stacking,s=((f=(h=this.config.states)==null?void 0:h.hover)==null?void 0:f.brightness)??(o?.2:.1),a=(d=(u=this.config.states)==null?void 0:u.hover)==null?void 0:d.color,c=(y=(p=this.config.states)==null?void 0:p.hover)==null?void 0:y.borderColor,l=(m=(g=this.config.states)==null?void 0:g.hover)==null?void 0:m.borderWidth;t.style("cursor",this.config.cursor||"pointer").on("mouseover",(x,v)=>{var L,P,A,w,S,$,R;const b=x.currentTarget,k=b.getAttribute("fill")||"";b.setAttribute("data-orig-fill",k);const C=st(b).interrupt("hover").transition("hover").duration(Z).ease(j);if(a?C.style("fill",a):C.style("fill",Zf(k,s)),c&&C.style("stroke",c),l!==void 0&&C.style("stroke-width",String(l)),b.style.filter="drop-shadow(0 1px 3px rgba(0,0,0,0.2))",o){const F=this.context.allSeries;if(F)for(const D of F)D.visible&&((L=D.config)!=null&&L.stacking)&&((P=D.group)==null||P.selectAll(".katucharts-column").filter(function(){return this!==b}).interrupt("stackDim").transition("stackDim").duration(bs).ease(j).attr("opacity",.3));b.setAttribute("data-orig-stroke",b.getAttribute("stroke")||""),b.setAttribute("data-orig-stroke-width",b.getAttribute("stroke-width")||""),C.style("stroke","#ffffff").style("stroke-width","2")}const E=e.indexOf(v),_=i.getPixelForValue(v.x??0),T=r.getPixelForValue(v.y??0),I=this.context.inverted;this.context.events.emit("point:mouseover",{point:v,index:E,series:this,event:x,plotX:I?T:_,plotY:I?_:T}),(w=(A=v.events)==null?void 0:A.mouseOver)==null||w.call(v,x),(R=($=(S=this.config.point)==null?void 0:S.events)==null?void 0:$.mouseOver)==null||R.call(v,x)}).on("mouseout",(x,v)=>{var _,T,I,L,P,A,w;const b=x.currentTarget,k=b.getAttribute("data-orig-fill")||"",C=st(b).interrupt("hover").transition("hover").duration(Z).ease(j);if(C.style("fill",k),b.style.filter="",o){const S=this.context.allSeries;if(S)for(const $ of S)$.visible&&((_=$.config)!=null&&_.stacking)&&((T=$.group)==null||T.selectAll(".katucharts-column").interrupt("stackDim").transition("stackDim").duration(bs).ease(j).attr("opacity",1));C.style("stroke",b.getAttribute("data-orig-stroke")||"").style("stroke-width",b.getAttribute("data-orig-stroke-width")||"")}else C.style("stroke","").style("stroke-width","");C.on("end",()=>{b.matches(":hover")||(b.style.fill="")});const E=e.indexOf(v);this.context.events.emit("point:mouseout",{point:v,index:E,series:this,event:x}),(L=(I=v.events)==null?void 0:I.mouseOut)==null||L.call(v,x),(w=(A=(P=this.config.point)==null?void 0:P.events)==null?void 0:A.mouseOut)==null||w.call(v,x)}).on("click",(x,v)=>{var C,E,_,T,I,L,P;const b=e.indexOf(v);this.context.events.emit("point:click",{point:v,index:b,series:this,event:x}),(E=(C=v.events)==null?void 0:C.click)==null||E.call(v,x),(I=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click)==null||I.call(v,x),(P=(L=this.config.events)==null?void 0:L.click)==null||P.call(this,x);const k=x.currentTarget,M=st(k);this.handlePointSelect(M,v,b,x)})}}class iw extends ed{constructor(){super(...arguments),this.isHorizontal=!0}}const nd={circle:bn,square:ps,diamond:ds,triangle:gs,"triangle-down":ms,cross:fs},id=["circle","diamond","square","triangle","triangle-down"];class rw extends Xt{constructor(t){t.clip=!1,super(t),this.cachedPositions=[]}resolveMarkerSymbol(){var r;if((r=this.config.marker)!=null&&r.symbol)return this.config.marker.symbol;const e=(this.context.allSeries||[]).filter(o=>o.config._internalType==="scatter");if(e.length<=1)return"circle";const i=e.indexOf(this);return id[i%id.length]}getLegendSymbolShape(){return this.resolveMarkerSymbol()}render(){var f,u,d,p;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data.filter(y=>y.y!==null&&y.y!==void 0),s=((f=this.config.marker)==null?void 0:f.radius)??4,a=((p=(d=(u=this.config.marker)==null?void 0:u.states)==null?void 0:d.hover)==null?void 0:p.radius)??s+3,c=this.context.animate,l=this.resolveMarkerSymbol(),h=this.config.jitter;this.cachedPositions=o.map(y=>({cx:this.applyJitter(t.getPixelForValue(y.x??0),i.width,h==null?void 0:h.x),cy:this.applyJitter(e.getPixelForValue(y.y??0),i.height,h==null?void 0:h.y)})),l==="circle"?this.renderCircles(o,r,s,a,!!c):this.renderSymbols(o,r,s,a,l,!!c),this.renderDataLabels(o,(y,g)=>this.cachedPositions[g].cx,(y,g)=>this.cachedPositions[g].cy),c&&this.emitAfterAnimate(bt+o.length*Nt)}animateUpdate(t){var f;const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data.filter(u=>u.y!==null&&u.y!==void 0),a=((f=this.config.marker)==null?void 0:f.radius)??4,c=this.config.jitter;this.cachedPositions=s.map(u=>({cx:this.applyJitter(e.getPixelForValue(u.x??0),r.width,c==null?void 0:c.x),cy:this.applyJitter(i.getPixelForValue(u.y??0),r.height,c==null?void 0:c.y)}));const l=this.resolveMarkerSymbol();if(l==="circle"){const u=this.group.selectAll(".katucharts-scatter-point").data(s);u.exit().transition().duration(t).attr("r",0).remove(),u.enter().append("circle").attr("class","katucharts-scatter-point").attr("r",0).attr("fill",p=>this.getPointFill(p,o)).attr("stroke",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineColor)??((g=this.config.marker)==null?void 0:g.lineColor)??o}).attr("stroke-width",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineWidth)??((g=this.config.marker)==null?void 0:g.lineWidth)??1}).attr("opacity",this.config.opacity??1).merge(u).attr("fill",p=>this.getPointFill(p,o)).attr("stroke",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineColor)??((g=this.config.marker)==null?void 0:g.lineColor)??o}).transition().duration(t).attr("cx",(p,y)=>this.cachedPositions[y].cx).attr("cy",(p,y)=>this.cachedPositions[y].cy).attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??a})}else{const u=nd[l]||bn,d=this.group.selectAll(".katucharts-scatter-point").data(s);d.exit().transition().duration(t).attr("opacity",0).remove(),d.enter().append("path").attr("class","katucharts-scatter-point").attr("fill",y=>this.getPointFill(y,o)).attr("stroke",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineColor)??((m=this.config.marker)==null?void 0:m.lineColor)??o}).attr("stroke-width",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineWidth)??((m=this.config.marker)==null?void 0:m.lineWidth)??1}).attr("opacity",this.config.opacity??1).merge(d).attr("fill",y=>this.getPointFill(y,o)).attr("stroke",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineColor)??((m=this.config.marker)==null?void 0:m.lineColor)??o}).transition().duration(t).attr("transform",(y,g)=>`translate(${this.cachedPositions[g].cx},${this.cachedPositions[g].cy})`).attr("d",y=>{var m;const g=((m=y.marker)==null?void 0:m.radius)??a;return Ve().type(u).size(Math.PI*g*g)()})}this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(s,(u,d)=>this.cachedPositions[d].cx,(u,d)=>this.cachedPositions[d].cy)}getPointFill(t,e){var i,r;return t.color?t.color:(i=t.marker)!=null&&i.fillColor?t.marker.fillColor:(r=this.config.marker)!=null&&r.fillColor?this.config.marker.fillColor:this.config.negativeColor&&(t.y??0)<(this.config.threshold??0)?this.config.negativeColor:e}getEntryDuration(){return(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt}renderCircles(t,e,i,r,o){const s=this.group.selectAll(".katucharts-scatter-point").data(t).join("circle").attr("class","katucharts-scatter-point").attr("cx",(a,c)=>this.cachedPositions[c].cx).attr("cy",(a,c)=>this.cachedPositions[c].cy).attr("fill",a=>this.getPointFill(a,e)).attr("stroke",a=>{var c,l;return((c=a.marker)==null?void 0:c.lineColor)??((l=this.config.marker)==null?void 0:l.lineColor)??e}).attr("stroke-width",a=>{var c,l;return((c=a.marker)==null?void 0:c.lineWidth)??((l=this.config.marker)==null?void 0:l.lineWidth)??1}).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer");o?s.attr("r",0).transition().duration(this.getEntryDuration()).ease(pt).delay((a,c)=>xe(c,0,Nt,t.length)).attr("r",a=>{var c;return((c=a.marker)==null?void 0:c.radius)??i}):s.attr("r",a=>{var c;return((c=a.marker)==null?void 0:c.radius)??i}),this.attachScatterEvents(s,t,i,r,e,"circle")}renderSymbols(t,e,i,r,o,s){const a=nd[o]||bn,c=this.group.selectAll(".katucharts-scatter-point").data(t).join("path").attr("class","katucharts-scatter-point").attr("transform",(h,f)=>`translate(${this.cachedPositions[f].cx},${this.cachedPositions[f].cy})`).attr("fill",h=>this.getPointFill(h,e)).attr("stroke",h=>{var f,u;return((f=h.marker)==null?void 0:f.lineColor)??((u=this.config.marker)==null?void 0:u.lineColor)??e}).attr("stroke-width",h=>{var f,u;return((f=h.marker)==null?void 0:f.lineWidth)??((u=this.config.marker)==null?void 0:u.lineWidth)??1}).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer"),l=h=>{var u;const f=((u=h.marker)==null?void 0:u.radius)??i;return Ve().type(a).size(Math.PI*f*f)()};if(s){const h=Ve().type(a).size(0);c.attr("d",h).transition().duration(this.getEntryDuration()).ease(pt).delay((f,u)=>xe(u,0,Nt,t.length)).attr("d",l)}else c.attr("d",l);this.attachScatterEvents(c,t,i,r,e,"symbol",a)}attachScatterEvents(t,e,i,r,o,s,a){var y,g,m,x,v;if(this.config.enableMouseTracking===!1)return;const c=(y=this.config.states)==null?void 0:y.hover,l=(g=c==null?void 0:c.marker)==null?void 0:g.fillColor,h=(v=(x=(m=this.config.marker)==null?void 0:m.states)==null?void 0:x.hover)==null?void 0:v.lineWidth,f=c==null?void 0:c.halo,u=(f==null?void 0:f.size)??10,d=(f==null?void 0:f.opacity)??.25,p=e.map((b,k)=>{var M;return this.group.insert("circle",".katucharts-scatter-point").attr("cx",this.cachedPositions[k].cx).attr("cy",this.cachedPositions[k].cy).attr("r",0).attr("fill",b.color||((M=this.config.marker)==null?void 0:M.fillColor)||o).attr("opacity",0).attr("class","katucharts-halo")});t.on("mouseover",(b,k)=>{var L,P,A,w,S,$,R,F,D,z,B,W,K,X;const M=b.currentTarget,C=e.indexOf(k);C>=0&&p[C]&&p[C].transition("halo").duration(Z).ease(j).attr("r",u).attr("opacity",d);const E=((L=k.marker)==null?void 0:L.radius)??i,_=((w=(A=(P=k.marker)==null?void 0:P.states)==null?void 0:A.hover)==null?void 0:w.radius)??((R=($=(S=this.config.marker)==null?void 0:S.states)==null?void 0:$.hover)==null?void 0:R.radius)??E+3,I=st(M).interrupt("hover").transition("hover").duration(Z).ease(j);if(s==="circle")I.attr("r",_);else if(a){const q=Math.PI*_*_;I.attr("d",Ve().type(a).size(q)())}M.style.filter="drop-shadow(0 1px 4px rgba(0,0,0,0.3))",l&&I.style("fill",l),h!==void 0&&I.style("stroke-width",String(h)),this.context.events.emit("point:mouseover",{point:k,index:C,series:this,event:b,plotX:((F=this.cachedPositions[C])==null?void 0:F.cx)??0,plotY:((D=this.cachedPositions[C])==null?void 0:D.cy)??0}),(B=(z=k.events)==null?void 0:z.mouseOver)==null||B.call(k,b),(X=(K=(W=this.config.point)==null?void 0:W.events)==null?void 0:K.mouseOver)==null||X.call(k,b)}).on("mouseout",(b,k)=>{var I,L,P,A,w,S;const M=b.currentTarget,C=e.indexOf(k);C>=0&&p[C]&&p[C].transition("halo").duration(Z).ease(j).attr("r",0).attr("opacity",0);const E=((I=k.marker)==null?void 0:I.radius)??i,T=st(M).interrupt("hover").transition("hover").duration(Z).ease(j);if(s==="circle")T.attr("r",E);else if(a){const $=Math.PI*E*E;T.attr("d",Ve().type(a).size($)())}M.style.filter="",T.style("fill",null).style("stroke-width",null),this.context.events.emit("point:mouseout",{point:k,index:C,series:this,event:b}),(P=(L=k.events)==null?void 0:L.mouseOut)==null||P.call(k,b),(S=(w=(A=this.config.point)==null?void 0:A.events)==null?void 0:w.mouseOut)==null||S.call(k,b)}).on("click",(b,k)=>{var C,E,_,T,I,L,P;const M=e.indexOf(k);this.context.events.emit("point:click",{point:k,index:M,series:this,event:b}),(E=(C=k.events)==null?void 0:C.click)==null||E.call(k,b),(I=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click)==null||I.call(k,b),(P=(L=this.config.events)==null?void 0:L.click)==null||P.call(this,b),this.handlePointSelect(st(b.currentTarget),k,M,b)})}}class ow extends Xt{constructor(t){t.clip=!1,super(t)}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data.filter(f=>f.y!==null&&f.y!==void 0),s=this.context.animate,a=this.config.jitter,c=this.filterByZThreshold(o);this.buildSizeScale(c);const l=c.map(f=>({cx:this.applyJitter(t.getPixelForValue(f.x??0),i.width,a==null?void 0:a.x),cy:this.applyJitter(e.getPixelForValue(f.y??0),i.height,a==null?void 0:a.y)})),h=this.group.selectAll(".katucharts-bubble").data(c).join("circle").attr("class","katucharts-bubble").attr("cx",(f,u)=>l[u].cx).attr("cy",(f,u)=>l[u].cy).attr("fill",(f,u)=>this.getBubbleFill(f,u,r)).attr("fill-opacity",this.config.fillOpacity??.5).attr("stroke",(f,u)=>this.config.lineColor||this.getBubbleFill(f,u,r)).attr("stroke-width",this.config.lineWidth??1).style("cursor",this.config.cursor||"pointer");if(s){const u=(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt;h.attr("r",0).transition().duration(u).ease(pt).delay((d,p)=>xe(p,0,Nt,c.length)).attr("r",d=>this.sizeScale(this.getZValue(d)))}else h.attr("r",f=>this.sizeScale(this.getZValue(f)));this.attachBubbleEvents(h,c,l,r),this.renderDataLabels(c,(f,u)=>l[u].cx,(f,u)=>l[u].cy),s&&this.emitAfterAnimate(bt+c.length*Nt)}animateUpdate(t){const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data.filter(u=>u.y!==null&&u.y!==void 0),a=this.filterByZThreshold(s),c=this.config.jitter;this.buildSizeScale(a);const l=a.map(u=>({cx:this.applyJitter(e.getPixelForValue(u.x??0),r.width,c==null?void 0:c.x),cy:this.applyJitter(i.getPixelForValue(u.y??0),r.height,c==null?void 0:c.y)})),h=this.group.selectAll(".katucharts-bubble").data(a);h.exit().transition().duration(t).attr("r",0).remove(),h.enter().append("circle").attr("class","katucharts-bubble").attr("r",0).attr("fill",(u,d)=>this.getBubbleFill(u,d,o)).attr("fill-opacity",this.config.fillOpacity??.5).attr("stroke",(u,d)=>this.config.lineColor||this.getBubbleFill(u,d,o)).attr("stroke-width",this.config.lineWidth??1).merge(h).transition().duration(t).attr("cx",(u,d)=>{var p;return((p=l[d])==null?void 0:p.cx)??0}).attr("cy",(u,d)=>{var p;return((p=l[d])==null?void 0:p.cy)??0}).attr("r",u=>this.sizeScale(this.getZValue(u))).attr("fill",(u,d)=>this.getBubbleFill(u,d,o)),this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(a,(u,d)=>{var p;return((p=l[d])==null?void 0:p.cx)??0},(u,d)=>{var p;return((p=l[d])==null?void 0:p.cy)??0})}filterByZThreshold(t){const e=this.config.displayNegative!==!1,i=this.config.zThreshold??0;return e?t:t.filter(r=>(r.z??0)>=i)}getZValue(t){const e=t.z??1;return this.config.sizeByAbsoluteValue?Math.abs(e):e}buildSizeScale(t){const e=t.map(c=>this.getZValue(c)),i=this.config.zMin??Math.min(...e,0),r=this.config.zMax??Math.max(...e,1),o=this.parseSize(this.config.minSize,8),s=this.parseSize(this.config.maxSize,30);(this.config.sizeBy||"area")==="width"?this.sizeScale=ke().domain([i,r]).range([o,s]).clamp(!0):this.sizeScale=Ix().domain([i,r]).range([o,s]).clamp(!0)}parseSize(t,e){if(t===void 0)return e;if(typeof t=="number")return t;if(typeof t=="string"&&t.endsWith("%")){const i=parseFloat(t)/100;return Math.min(this.context.plotArea.width,this.context.plotArea.height)*i/2}return parseFloat(t)||e}getBubbleFill(t,e,i){if(t.color)return t.color;if(this.config.negativeColor&&(t.z??0)<(this.config.zThreshold??0))return this.config.negativeColor;if(this.config.colorByPoint){const r=this.config.colors||this.context.colors;return r[e%r.length]}return i}attachBubbleEvents(t,e,i,r){var s,a;if(this.config.enableMouseTracking===!1)return;(a=(s=this.config.states)==null?void 0:s.hover)==null||a.brightness;const o=this.config.fillOpacity??.5;t.on("mouseover",(c,l)=>{var d,p,y,g,m,x,v;const h=c.currentTarget,f=this.sizeScale(this.getZValue(l));st(h).interrupt("hover").transition("hover").duration(Z).ease(j).attr("r",f+4).attr("fill-opacity",Math.min(o+.3,1)),h.style.filter="drop-shadow(0 2px 6px rgba(0,0,0,0.3))";const u=e.indexOf(l);this.context.events.emit("point:mouseover",{point:l,index:u,series:this,event:c,plotX:((d=i[u])==null?void 0:d.cx)??0,plotY:((p=i[u])==null?void 0:p.cy)??0}),(g=(y=l.events)==null?void 0:y.mouseOver)==null||g.call(l,c),(v=(x=(m=this.config.point)==null?void 0:m.events)==null?void 0:x.mouseOver)==null||v.call(l,c)}).on("mouseout",(c,l)=>{var u,d,p,y,g;const h=c.currentTarget;st(h).interrupt("hover").transition("hover").duration(Z).ease(j).attr("r",this.sizeScale(this.getZValue(l))).attr("fill-opacity",o),h.style.filter="";const f=e.indexOf(l);this.context.events.emit("point:mouseout",{point:l,index:f,series:this,event:c}),(d=(u=l.events)==null?void 0:u.mouseOut)==null||d.call(l,c),(g=(y=(p=this.config.point)==null?void 0:p.events)==null?void 0:y.mouseOut)==null||g.call(l,c)}).on("click",(c,l)=>{var f,u,d,p,y,g,m;const h=e.indexOf(l);this.context.events.emit("point:click",{point:l,index:h,series:this,event:c}),(u=(f=l.events)==null?void 0:f.click)==null||u.call(l,c),(y=(p=(d=this.config.point)==null?void 0:d.events)==null?void 0:p.click)==null||y.call(l,c),(m=(g=this.config.events)==null?void 0:g.click)==null||m.call(this,c),this.handlePointSelect(st(c.currentTarget),l,h,c)})}getBubbleLegendInfo(){const t=this.filterByZThreshold(this.data.filter(c=>c.y!==null&&c.y!==void 0));if(t.length===0)return null;this.buildSizeScale(t);const e=t.map(c=>this.getZValue(c)),i=this.config.zMin??Math.min(...e),r=this.config.zMax??Math.max(...e);if(!isFinite(i)||!isFinite(r)||r<=0)return null;const o=[r,(i+r)/2,i],s=new Set,a=o.map(c=>Math.round(c)).filter(c=>c>0&&!s.has(c)&&(s.add(c),!0)).map(c=>({value:c,radius:this.sizeScale(c)}));return a.length===0?null:{sizeBy:this.config.sizeBy||"area",color:this.getColor(),ranges:a}}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const c of this.data)c.x!==void 0&&c.x!==null&&(t=Math.min(t,c.x),e=Math.max(e,c.x)),c.y!==void 0&&c.y!==null&&(i=Math.min(i,c.y),r=Math.max(r,c.y));const o=e-t||1,s=r-i||1,a=.08;return t-=o*a,e+=o*a,i-=s*a,r+=s*a,{xMin:t,xMax:e,yMin:i,yMax:r}}}class rd extends Xt{constructor(t){super(t),this.selectedIndices=new Set,t.showInLegend=t.showInLegend??!1}legendPoints(){return this.data.filter(t=>t.y!==null&&t.y!==void 0&&(t.y??0)>0)}getMultiLegendItems(){var i;const t=this.config.colors,e=((i=this.context)==null?void 0:i.colors)??[];return this.legendPoints().map((r,o)=>({label:r.name??String(r.y??""),color:r.color??(t?t[o%t.length]:e[o%e.length]),visible:r.visible!==!1}))}toggleLegendItem(t){const e=this.legendPoints()[t];return e?(e.visible=e.visible===!1,this.redraw(),e.visible!==!1):null}dataLabelConfigs(){const t=this.config.dataLabels;return t?(Array.isArray(t)?t:[t]).filter(i=>i&&i.enabled!==!1):[]}init(t){const e=this.dataLabelConfigs().length>0;if(e&&(this.config.clip=!1),super.init(t),e){const i=this.group.select(function(){return this.ownerSVGElement});i.empty()||i.style("overflow","visible")}}render(){var Y,G,Q,O,it,et,ht,ft,ct,nt;const{plotArea:t,colors:e}=this.context,i=this.config.ignoreHiddenPoint!==!1,r=this.data.filter(U=>U.y!==null&&U.y!==void 0&&(U.y??0)>0),o=i?r.filter(U=>U.visible!==!1):r,s=this.context.animate,a=this.dataLabelConfigs().filter(U=>(U.distance??30)>=0),c=a.length>0,l=c?Math.max(...a.map(U=>(U.distance??30)+10)):0,h=this.config.center||["50%","50%"],f=this.resolvePercent(h[0],t.width),u=this.resolvePercent(h[1],t.height),d=t.width-l*2,p=t.height-l,y=Math.min(d,p),g=Math.min(t.width,t.height),m=this.config.size!==void 0&&this.config.size!==null,x=m?this.resolvePercent(this.config.size,g):y,v=this.config.minSize?this.resolvePercent(this.config.minSize,g):0,k=Math.max(c?Math.min(x,y):m?x:g,v)/2,M=this.resolvePercent(this.config.innerSize||0,k*2)/2,C=this.config.depth??0,E=(this.config.startAngle??0)*Math.PI/180,_=this.config.endAngle!==void 0?this.config.endAngle*Math.PI/180:E+2*Math.PI,T=o.reduce((U,at)=>U+(at.y??0),0),I=this.config.fillColor;if(T===0&&I){const U=this.group.append("g").attr("transform",`translate(${f},${u})`),at=Ce().innerRadius(M).outerRadius(k).startAngle(E).endAngle(_);U.append("path").attr("d",at({})).attr("fill",ti(I,U,"#cccccc"));return}const L=P2().value(U=>U.y??0).sort(null).startAngle(E).endAngle(_),P=this.resolveBorderRadius(this.config.borderRadius),A=Ce().innerRadius(M).outerRadius(k).cornerRadius(P),w=this.config.slicedOffset??10,S=Ce().innerRadius(M).outerRadius(k+w*.4).cornerRadius(P),$=L(o),R=_-E;for(const U of $)U.data.percentage=(U.endAngle-U.startAngle)/R*100,U.data.total=T;const F=this.group.append("g").attr("transform",`translate(${f},${u})`);C>0&&this.render3DEffect(F,$,M,k,C);const D=this.config.allowPointSelect===!0;(G=(Y=this.config.states)==null?void 0:Y.hover)==null||G.brightness;const z=(O=(Q=this.config.states)==null?void 0:Q.select)==null?void 0:O.color,B=(et=(it=this.config.states)==null?void 0:it.select)==null?void 0:et.borderColor,W=(ft=(ht=this.config.states)==null?void 0:ht.select)==null?void 0:ft.borderWidth,K=((nt=(ct=this.config.states)==null?void 0:ct.inactive)==null?void 0:nt.opacity)??.4,X=(U,at)=>U.data.color?U.data.color:this.config.colors?this.config.colors[at%this.config.colors.length]:e[at%e.length],q=U=>{const at=(U.startAngle+U.endAngle)/2,yt=w*Math.sin(at),St=-w*Math.cos(at);return`translate(${yt},${St})`},N=this,H=F.selectAll(".katucharts-pie-slice").data($).join("path").attr("class","katucharts-pie-slice").attr("fill",(U,at)=>X(U,at)).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer");H.each(function(U,at){const yt=st(this);(U.data.sliced||N.selectedIndices.has(at))&&yt.attr("transform",q(U))}),s?H.each(function(U,at){const yt=st(this),St={startAngle:U.startAngle,endAngle:U.startAngle},Mt=he(St,U);yt.transition().duration(bt).ease(pt).delay(Lc+at*Nt).attrTween("d",()=>Et=>A(Mt(Et)))}):H.attr("d",A),this.config.enableMouseTracking!==!1&&H.on("mouseover",function(U,at){var Ht,ne,Ct,Zt,Qt;const yt=st(this),St=$.indexOf(at);N.selectedIndices.has(St)||yt.transition("arc").duration(Z).ease(j).attr("d",S(at)),yt.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.25))"),H.interrupt("highlight"),H.attr("opacity",N.config.opacity??1),H.filter(ge=>ge!==at).transition("highlight").duration(Z).ease(j).attr("opacity",K);const Et=A.centroid(at);N.context.events.emit("point:mouseover",{point:at.data,index:St,series:N,event:U,plotX:f+Et[0],plotY:u+Et[1]}),(ne=(Ht=at.data.events)==null?void 0:Ht.mouseOver)==null||ne.call(at.data,U),(Qt=(Zt=(Ct=N.config.point)==null?void 0:Ct.events)==null?void 0:Zt.mouseOver)==null||Qt.call(at.data,U)}).on("mouseout",function(U,at){var Et,Ht,ne,Ct,Zt;const yt=st(this),St=$.indexOf(at);N.selectedIndices.has(St)||yt.transition("arc").duration(Z).ease(j).attr("d",A(at)),yt.style("filter",""),H.interrupt("highlight"),H.transition("highlight").duration(Z).ease(j).attr("opacity",N.config.opacity??1),N.context.events.emit("point:mouseout",{point:at.data,index:St,series:N,event:U}),(Ht=(Et=at.data.events)==null?void 0:Et.mouseOut)==null||Ht.call(at.data,U),(Zt=(Ct=(ne=N.config.point)==null?void 0:ne.events)==null?void 0:Ct.mouseOut)==null||Zt.call(at.data,U)}).on("click",function(U,at){var St,Mt,Et,Ht,ne,Ct,Zt,Qt,ge,Vt,Ut,Xe,se,hn;const yt=$.indexOf(at);D&&(N.selectedIndices.has(yt)?(N.selectedIndices.delete(yt),st(this).transition("slice").duration(Z).ease(j).attr("transform",""),(Mt=(St=at.data.events)==null?void 0:St.unselect)==null||Mt.call(at.data,U),(ne=(Ht=(Et=N.config.point)==null?void 0:Et.events)==null?void 0:Ht.unselect)==null||ne.call(at.data,U)):(N.selectedIndices.add(yt),st(this).transition("slice").duration(Z).ease(j).attr("transform",q(at)),(Zt=(Ct=at.data.events)==null?void 0:Ct.select)==null||Zt.call(at.data,U),(Vt=(ge=(Qt=N.config.point)==null?void 0:Qt.events)==null?void 0:ge.select)==null||Vt.call(at.data,U)),(z||B||W!==void 0)&&H.each(function(ze,Be){const un=st(this);N.selectedIndices.has(Be)?(z&&un.attr("fill",z),B&&un.attr("stroke",B),W!==void 0&&un.attr("stroke-width",W)):(un.attr("fill",X(ze,Be)),un.attr("stroke",N.config.borderColor||N.autoBorderColor()),un.attr("stroke-width",N.config.borderWidth??1))})),N.context.events.emit("point:click",{point:at.data,index:yt,series:N,event:U}),(Xe=(Ut=at.data.events)==null?void 0:Ut.click)==null||Xe.call(at.data,U),(hn=(se=N.config.events)==null?void 0:se.click)==null||hn.call(N,U)});for(const U of this.dataLabelConfigs())this.renderPieLabels(F,$,A,k,_-E,U,f);s&&this.emitAfterAnimate(bt+$.length*Nt)}renderPieLabels(t,e,i,r,o,s,a){var _,T;if(!s||s.enabled===!1)return;const c=this.context.plotArea.width,l=this.context.plotArea.height,h=c/2,f=l/2,u=s.distance??30,d=s.connectorWidth??1,p=s.connectorColor||"#999",y=s.connectorPadding??5;s.softConnector;const g=((_=s.style)==null?void 0:_.fontSize)||kt,m=s.color||((T=s.style)==null?void 0:T.color)||Le,x=s.alignTo,v=u<0,b=me(g),k=b*1.4,M=[],{colors:C}=this.context;if(e.forEach((I,L)=>{const P=I.data.percentage,A=i.centroid(I),w=(I.startAngle+I.endAngle)/2,S=I.data.color||(this.config.colors?this.config.colors[L%this.config.colors.length]:C[L%C.length]),$=r+u;let R=$*Math.sin(w),F=-$*Math.cos(w);(x==="plotEdges"||x==="connectors")&&(R=w<Math.PI?h-5:-(h-5));let D,z;const B={...I.data,color:S};s.formatter?D=s.formatter.call({point:B,series:{name:this.config.name},x:I.data.x,y:I.data.y,percentage:P}):s.format?D=Kt(s.format,{point:B,series:{name:this.config.name}}):D=I.data.name||String(I.data.y);const W=/(?:^|[\s;"'])color\s*:\s*([^;"'>]+)/i.exec(D);W&&(z=af(W[1],S)),D=oe(D),M.push({lx:R,ly:F,text:D,midAngle:w,centroid:A,percentage:P,data:I.data,visible:!0,color:S,inlineColor:z})}),!v&&!s.allowOverlap){const I=M.filter(A=>A.midAngle<Math.PI),L=M.filter(A=>A.midAngle>=Math.PI);this.distribute(I,k,f,h,g),this.distribute(L,k,f,h,g);const P=r+u;for(const A of M){if(!A.visible)continue;const w=Math.max(-P,Math.min(P,A.ly)),S=Math.sqrt(Math.max(0,P*P-w*w)),$=A.midAngle<Math.PI;A.lx=$?Math.max(S,r*.3):-Math.max(S,r*.3);const R=a+A.lx,F=(A.lx>=0?c-R:R)-6;if(F>b&&He(A.text,b)>F){let D=A.text;for(;D.length>1&&He(D+"…",b)>F;)D=D.slice(0,-1);A.text=D.trimEnd()+"…"}}}else if(v&&!s.allowOverlap){const I=[],L=M.filter(P=>P.visible).sort((P,A)=>A.percentage-P.percentage);for(const P of L){const A=He(P.text,b),w=b*1.1,S=P.centroid[0],$=P.centroid[1],R={l:S-A/2,r:S+A/2,t:$-w/2,b:$+w/2};if(I.some(D=>R.l<D.r&&R.r>D.l&&R.t<D.b&&R.b>D.t)){P.visible=!1;continue}I.push(R)}}const E=t.append("g").attr("class","katucharts-pie-labels");M.forEach(I=>{if(!I.visible)return;const{lx:L,ly:P,text:A,midAngle:w,centroid:S,color:$,inlineColor:R}=I,F=w<Math.PI,D=$||p;if(d>0&&u>=0){const W=r+y,K=W*Math.sin(w),X=-W*Math.cos(w),q=s.connectorShape||"fixedOffset";if(q==="straight")E.append("line").attr("class","katucharts-pie-connector").attr("x1",S[0]).attr("y1",S[1]).attr("x2",L).attr("y2",P).attr("stroke",D).attr("stroke-width",d);else if(q==="crookedLine"){const N=s.crookDistance??"70%",H=typeof N=="string"?parseFloat(N)/100:N/u,Y=r+u*H,G=Y*Math.sin(w),Q=-Y*Math.cos(w);E.append("path").attr("class","katucharts-pie-connector").attr("d",`M${S[0]},${S[1]}L${G},${Q}L${L},${P}`).attr("fill","none").attr("stroke",D).attr("stroke-width",d)}else if(typeof q=="function"){const N=q({connectorPosition:{from:S,to:[L,P]},labelDistance:u,labelPosition:[L,P]});E.append("path").attr("class","katucharts-pie-connector").attr("d",N).attr("fill","none").attr("stroke",D).attr("stroke-width",d)}else{const N=r+u*.5,H=N*Math.sin(w),Y=-N*Math.cos(w);E.append("path").attr("class","katucharts-pie-connector").attr("d",`M${K},${X}L${H},${Y}L${L},${P}`).attr("fill","none").attr("stroke",D).attr("stroke-width",d)}}const z=E.append("text").attr("x",(v?S[0]:L)+(s.x??0)).attr("y",(v?S[1]:P)+(s.y??0)).attr("text-anchor",v?"middle":F?"start":"end").attr("dominant-baseline","middle").attr("font-size",g).attr("fill",R||m).style("pointer-events","none").text(A),B=s.style||{};B.fontWeight&&z.attr("font-weight",B.fontWeight),B.fontFamily&&z.attr("font-family",B.fontFamily),B.textOutline&&z.style("text-shadow",B.textOutline)})}distribute(t,e,i,r,o){const s=t.filter(u=>u.visible);if(s.length<=1)return;const a=-(i-5),l=i-5-a,h=s.map(u=>({target:u.ly-a,size:e,rank:u.percentage,pos:0,removed:!1,label:u})),f=e*3;this.distributeBoxes(h,l,f);for(const u of h)u.removed?u.label.visible=!1:u.label.ly=a+u.pos+e/2}distributeBoxes(t,e,i){const r=t.filter(s=>!s.removed);if(r.length===0)return;let o=r.reduce((s,a)=>s+a.size,0);if(o>e){const s=[...r].sort((c,l)=>c.rank-l.rank);let a=0;for(;o>e&&a<s.length;)s[a].removed=!0,o-=s[a].size,a++}for(let s=0;s<=t.length;s++){const a=r.filter(l=>!l.removed);if(a.length<=1)break;a.sort((l,h)=>l.target-h.target);for(let l=0;l<a.length;l++)if(a[l].pos=a[l].target,l>0){const h=a[l-1].pos+a[l-1].size;a[l].pos<h&&(a[l].pos=h)}for(let l=a.length-1;l>=0;l--){const h=l===a.length-1?e-a[l].size:a[l+1].pos-a[l].size;a[l].pos>h&&(a[l].pos=Math.max(0,h))}for(let l=0;l<5;l++)for(let h=0;h<a.length;h++){const f=a[h].pos+(a[h].target-a[h].pos)*.3,u=h>0?a[h-1].pos+a[h-1].size:0,d=h<a.length-1?a[h+1].pos-a[h].size:e-a[h].size;a[h].pos=Math.max(u,Math.min(d,f))}let c=null;for(const l of a)Math.abs(l.pos-l.target)<=i||(!c||l.rank<c.rank)&&(c=l);if(!c)break;c.removed=!0}}render3DEffect(t,e,i,r,o){const{colors:s}=this.context,a=t.insert("g",":first-child").attr("class","katucharts-pie-3d");for(const c of e){const l=e.indexOf(c),h=c.data.color||(this.config.colors?this.config.colors[l%this.config.colors.length]:s[l%s.length]),f=c.startAngle-Math.PI/2,u=c.endAngle-Math.PI/2;if(f>0&&u>0||f<0&&u<0&&f<-Math.PI&&u<-Math.PI)continue;const d=Ce().innerRadius(i).outerRadius(r).startAngle(c.startAngle).endAngle(c.endAngle);a.append("path").attr("d",d({})).attr("fill",h).attr("opacity",.7).attr("transform",`translate(0,${o})`)}}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}resolveBorderRadius(t){return t===void 0?3:typeof t=="number"?t:t.radius??3}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class od extends Xt{constructor(t){super(t)}render(){var p,y;const{plotArea:t,colors:e}=this.context,i=this.data.filter(g=>g.y!==null&&g.y!==void 0),r=this.context.animate,o=t.height*.8,s=o/i.length,a=Math.max(...i.map(g=>g.y??0),1),c=t.width/2,l=t.width*.7,h=l*.15,f=(t.height-o)/2,u=((y=(p=this.config.states)==null?void 0:p.inactive)==null?void 0:y.opacity)??.4,d=[];i.forEach((g,m)=>{var T,I,L;const x=(g.y??0)/a,v=m<i.length-1?(i[m+1].y??0)/a:x*.5,b=h+(l-h)*x,k=h+(l-h)*v,M=f+m*s,C=[`M ${c-b/2} ${M}`,`L ${c+b/2} ${M}`,`L ${c+k/2} ${M+s}`,`L ${c-k/2} ${M+s}`,"Z"].join(" "),E=g.color||e[m%e.length],_=this.group.append("path").attr("d",C).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("class","katucharts-funnel-segment").style("cursor",this.config.cursor||"pointer");if(d.push(_),r?_.attr("fill",E).attr("opacity",0).transition().duration(bt).ease(pt).delay(xe(m,0,Nt,i.length)).attr("opacity",1):_.attr("fill",E),(T=this.config.dataLabels)!=null&&T.enabled){const P=this.config.dataLabels,A=((I=P.style)==null?void 0:I.fontSize)||kt,w=P.color||((L=P.style)==null?void 0:L.color)||Le;let S;P.formatter?S=P.formatter.call({point:g,series:{name:this.config.name},x:g.x,y:g.y}):P.format?S=oe(Kt(P.format,{point:g,series:{name:this.config.name}})):S=g.name||String(g.y),this.group.append("text").attr("class","katucharts-funnel-label").attr("x",c+(P.x??0)).attr("y",M+s/2+(P.y??0)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",A).attr("fill",w).style("pointer-events","none").text(S)}this.config.enableMouseTracking!==!1&&_.on("mouseover",P=>{var A,w;_.transition("move").duration(Z).ease(j).attr("transform","translate(0, -3)").style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.2))"),d.forEach(S=>S.interrupt("highlight")),d.forEach(S=>S.attr("opacity",1)),d.forEach((S,$)=>{$!==m&&S.transition("highlight").duration(Z).ease(j).attr("opacity",u)}),this.context.events.emit("point:mouseover",{point:g,index:m,series:this,event:P,plotX:c,plotY:M+s/2}),(w=(A=g.events)==null?void 0:A.mouseOver)==null||w.call(g,P)}).on("mouseout",P=>{var A,w;_.transition("move").duration(Z).ease(j).attr("transform","").style("filter",""),d.forEach(S=>S.interrupt("highlight")),d.forEach(S=>S.transition("highlight").duration(Z).ease(j).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:g,index:m,series:this,event:P}),(w=(A=g.events)==null?void 0:A.mouseOut)==null||w.call(g,P)}).on("click",P=>{var A,w,S,$;this.context.events.emit("point:click",{point:g,index:m,series:this,event:P}),(w=(A=g.events)==null?void 0:A.click)==null||w.call(g,P),($=(S=this.config.events)==null?void 0:S.click)==null||$.call(this,P)})})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class sw extends od{constructor(t){super(t),this.data=[...t._processedData||[]].reverse()}}function Ze(n){for(var t=n.length/6|0,e=new Array(t),i=0;i<t;)e[i]="#"+n.slice(i*6,++i*6);return e}const Hn=n=>Yy(n[n.length-1]);var aw=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Ze);const cw=Hn(aw);var lw=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Ze);const hw=Hn(lw);var uw=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Ze);const sd=Hn(uw);var fw=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Ze);const ad=Hn(fw);var dw=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Ze);const pw=Hn(dw);var gw=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Ze);const mw=Hn(gw);var yw=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Ze);const xw=Hn(yw);var bw=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Ze);const vw=Hn(bw);var ww=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Ze);const kw=Hn(ww);function vs(n){var t=n.length;return function(e){return n[Math.max(0,Math.min(t-1,Math.floor(e*t)))]}}const Mw=vs(Ze("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));vs(Ze("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));var Aw=vs(Ze("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),Sw=vs(Ze("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function _w(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Cw extends Xt{constructor(t){super(t),t.showInLegend=!1}render(){var A,w;const{plotArea:t}=this.context,e=this.context.animate,i=this.data,r=this.config.colorAxis||{},o=i.map(S=>S.value??S.z??S.y??0).filter(S=>S!=null),s=r.min??(o.length>0?Math.min(...o):0),a=r.max??(o.length>0?Math.max(...o):1),c=this.config.nullColor??"#e4e4e4",l=((w=(A=this.config.states)==null?void 0:A.inactive)==null?void 0:w.opacity)??.4,h=this.buildColorScale(r,s,a),f=this.config.interpolation===!0,u=this.config.colsize??1,d=this.config.rowsize??1,p=this.config.pointPadding??0,y=this.getUniqueValues("x"),g=this.getUniqueValues("yCategory"),m=y.length>0&&g.length>0,x=m?t.width/y.length:t.width/Math.max(1,Math.ceil((Math.max(...i.map(S=>S.x??0))+u)/u)),v=m?t.height/g.length:t.height/Math.max(1,Math.ceil((Math.max(...i.map(S=>S.y??0))+d)/d)),b=S=>{if(S.color)return S.color;const $=S.value??S.z??S.y;return $==null?c:h($)},k=S=>m?(typeof S.x=="number"?S.x:0)*x:(S.x??0)/u*x,M=S=>m?(typeof S.yCategory=="number"?S.yCategory:typeof S.y=="number"?S.y:0)*v:(S.y??0)/d*v,C=p*x,E=p*v,_=x*u-(this.config.borderWidth??1),T=v*d-(this.config.borderWidth??1),I=Math.max(1,(m?x-1:_)-C*2),L=Math.max(1,(m?v-1:T)-E*2);if(f){this.renderInterpolated(i,t,h,c,k,M,x,v,b),this.renderHeatmapLabels(i,k,M,x,v,b),this.renderColorAxis(h,s,a);return}const P=this.group.selectAll(".katucharts-heatmap-cell").data(i).join("rect").attr("class","katucharts-heatmap-cell").attr("x",S=>k(S)+C).attr("y",S=>M(S)+E).attr("width",I).attr("height",L).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("rx",_w(this.config.borderRadius)).style("cursor",this.config.cursor||"pointer");e?P.attr("fill","#fff").transition().duration(600).delay((S,$)=>$*8).attr("fill",S=>b(S)):P.attr("fill",S=>b(S)),this.config.enableMouseTracking!==!1&&P.on("mouseover",(S,$)=>{var W,K,X,q;const R=st(S.currentTarget),F=b($),D=((K=(W=ce(F))==null?void 0:W.brighter(.4))==null?void 0:K.toString())||F;R.interrupt("hover").transition("hover").duration(Z).ease(j).attr("fill",D).attr("stroke","#333").attr("stroke-width",2),R.style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.3))"),P.interrupt("highlight"),P.attr("opacity",1),P.filter(N=>N!==$).transition("highlight").duration(Z).ease(j).attr("opacity",l);const z=i.indexOf($),B=$.value??$.z??$.y;this.context.events.emit("point:mouseover",{point:{...$,value:B},index:z,series:this,event:S,plotX:k($)+x/2,plotY:M($)+v/2}),(q=(X=$.events)==null?void 0:X.mouseOver)==null||q.call($,S)}).on("mouseout",(S,$)=>{var D,z;const R=st(S.currentTarget);R.interrupt("hover").transition("hover").duration(Z).ease(j).attr("fill",b($)).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1),R.style("filter",""),P.interrupt("highlight"),P.transition("highlight").duration(Z).ease(j).attr("opacity",1);const F=i.indexOf($);this.context.events.emit("point:mouseout",{point:$,index:F,series:this,event:S}),(z=(D=$.events)==null?void 0:D.mouseOut)==null||z.call($,S)}).on("click",(S,$)=>{var F,D,z,B;const R=i.indexOf($);this.context.events.emit("point:click",{point:$,index:R,series:this,event:S}),(D=(F=$.events)==null?void 0:F.click)==null||D.call($,S),(B=(z=this.config.events)==null?void 0:z.click)==null||B.call(this,S)}),this.renderHeatmapLabels(i,k,M,x,v,b),this.renderColorAxis(h,s,a)}renderInterpolated(t,e,i,r,o,s,a,c,l){const h=new Set,f=new Set;for(const E of t)h.add(E.x??0),f.add(E.yCategory??E.y??0);const u=Array.from(h).sort((E,_)=>E-_),d=Array.from(f).sort((E,_)=>E-_),p=u.length,y=d.length;if(p===0||y===0)return;const g=new Map;for(const E of t){const _=E.value??E.z??E.y,T=u.indexOf(E.x??0),I=d.indexOf(E.yCategory??E.y??0);_!=null&&g.set(`${T},${I}`,_)}const m=Math.round(e.width),x=Math.round(e.height),v=document.createElement("canvas");v.width=m,v.height=x;const b=v.getContext("2d");if(!b)return;const k=b.createImageData(m,x),M=k.data;for(let E=0;E<x;E++)for(let _=0;_<m;_++){const T=_/m*p-.5,I=E/x*y-.5,L=Math.floor(T),P=Math.floor(I),A=T-L,w=I-P,S=(N,H)=>g.get(`${Math.max(0,Math.min(p-1,N))},${Math.max(0,Math.min(y-1,H))}`)??null,$=S(L,P),R=S(L+1,P),F=S(L,P+1),D=S(L+1,P+1),z=[$,R,F,D].filter(N=>N!==null);if(z.length===0){const N=je(r),H=(E*m+_)*4;M[H]=N.r,M[H+1]=N.g,M[H+2]=N.b,M[H+3]=255;continue}const B=N=>N??z[0],W=B($)*(1-A)*(1-w)+B(R)*A*(1-w)+B(F)*(1-A)*w+B(D)*A*w,K=i(W),X=je(K),q=(E*m+_)*4;M[q]=X.r,M[q+1]=X.g,M[q+2]=X.b,M[q+3]=255}b.putImageData(k,0,0);const C=v.toDataURL();this.group.append("image").attr("class","katucharts-heatmap-interpolated").attr("width",e.width).attr("height",e.height).attr("href",C).style("image-rendering","auto")}buildColorScale(t,e,i){const r=t.reversed===!0,o=r?i:e,s=r?e:i;if(t.dataClasses&&t.dataClasses.length>0){const u=t.dataClasses;return d=>{var p;for(const y of u){const g=y.from??-1/0,m=y.to??1/0;if(d>=g&&d<m)return y.color||"#cccccc"}return((p=u[u.length-1])==null?void 0:p.color)||"#cccccc"}}const a=t.type==="logarithmic",c=a?Math.max(o,1e-10):o,l=()=>a?Io().domain([c,s]).clamp(!0):ke().domain([o,s]).clamp(!0);if(t.stops&&t.stops.length>=2){const u=t.stops,d=l();return p=>{const y=d(a?Math.max(p,1e-10):p);let g=0;for(;g<u.length-1&&!(y<=u[g+1][0]);g++);const[m,x]=u[g],[v,b]=u[Math.min(g+1,u.length-1)],k=v!==m?(y-m)/(v-m):0;return yi(x,b)(k)}}if(t.minColor&&t.maxColor){const u=yi(t.minColor,t.maxColor),d=l();return p=>u(d(a?Math.max(p,1e-10):p))}const h=r?[i,e]:[e,i],f=Hu(sd).domain(h);return u=>f(u)}renderColorAxis(t,e,i){var k,M;const r=this.config.colorAxis||{};if(((k=r.labels)==null?void 0:k.enabled)===!1)return;const{plotArea:o}=this.context,a=(this.context.legendConfig||{}).layout==="vertical",c=C=>this.context.chartWidth!==void 0?(this.context.chartWidth-C)/2-o.x:(o.width-C)/2,l=this.context.plotGroup||this.group;l.selectAll(".katucharts-color-axis").remove();const h=l.append("g").attr("class","katucharts-color-axis"),f=((M=r.labels)==null?void 0:M.style)||{},u=f.fontSize||kt,d=f.color||this.autoLabelColor(),p=i-e,y=p/6,g=Math.pow(10,Math.floor(Math.log10(y))),m=[1,2,2.5,5,10].find(C=>C*g>=y)*g,x=Math.ceil(e/m)*m,v=[];for(let C=x;C<=i+m*.01;C+=m)v.push(Math.round(C*1e6)/1e6);(v.length===0||v[0]-e>m*.5)&&v.unshift(e),i-v[v.length-1]>m*.5&&v.push(i);const b=m>=1?0:m>=.1?1:2;if(r.dataClasses&&r.dataClasses.length>0){const C=r.dataClasses,E=Math.min(o.width*.6,300),_=12,T=c(E),I=o.height+60,L=E/C.length;for(let P=0;P<C.length;P++){const A=C[P];h.append("rect").attr("x",T+P*L).attr("y",I).attr("width",L).attr("height",_).attr("fill",A.color||"#ccc").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",P===0?2:0).attr("ry",P===0?2:0),A.name&&h.append("text").attr("x",T+P*L+L/2).attr("y",I+_+30).attr("font-size",u).attr("fill",d).attr("text-anchor","middle").text(A.name)}return}if(a){const E=Math.min(o.height*.7,200),_=o.width+20,T=(o.height-E)/2,I=h.append("defs"),L=v.length-1,P=E/L;for(let A=0;A<L;A++){const w=L-1-A,S=`katucharts-heatmap-seg-${Math.random().toString(36).slice(2,8)}`,$=I.append("linearGradient").attr("id",S).attr("x1","0%").attr("y1","0%").attr("x2","0%").attr("y2","100%");$.append("stop").attr("offset","0%").attr("stop-color",t(v[w+1])),$.append("stop").attr("offset","100%").attr("stop-color",t(v[w])),h.append("rect").attr("x",_).attr("y",T+A*P).attr("width",12).attr("height",P+.5).attr("fill",`url(#${S})`).attr("stroke","none")}h.append("rect").attr("x",_).attr("y",T).attr("width",12).attr("height",E).attr("fill","none").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);for(let A=0;A<v.length;A++){const w=T+E-(v[A]-e)/p*E;h.append("line").attr("x1",_+12).attr("y1",w).attr("x2",_+12+4).attr("y2",w).attr("stroke","#999").attr("stroke-width",.5),h.append("text").attr("x",_+12+7).attr("y",w+4).attr("font-size",u).attr("fill",d).attr("text-anchor","start").text(v[A].toFixed(b))}}else{const E=Math.min(o.width*.6,300),_=c(E),T=o.height+60,I=h.append("defs"),L=v.length-1,P=E/L;for(let A=0;A<L;A++){const w=`katucharts-heatmap-seg-${Math.random().toString(36).slice(2,8)}`,S=I.append("linearGradient").attr("id",w).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");S.append("stop").attr("offset","0%").attr("stop-color",t(v[A])),S.append("stop").attr("offset","100%").attr("stop-color",t(v[A+1])),h.append("rect").attr("x",_+A*P).attr("y",T).attr("width",P+.5).attr("height",12).attr("fill",`url(#${w})`).attr("stroke","none")}h.append("rect").attr("x",_).attr("y",T).attr("width",E).attr("height",12).attr("fill","none").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);for(let A=0;A<v.length;A++){const w=_+(v[A]-e)/p*E;h.append("line").attr("x1",w).attr("y1",T+12+8).attr("x2",w).attr("y2",T+12+16).attr("stroke","#999").attr("stroke-width",.5),h.append("text").attr("x",w).attr("y",T+12+30).attr("font-size",u).attr("fill",d).attr("text-anchor",A===0?"start":A===v.length-1?"end":"middle").text(v[A].toFixed(b))}}}renderHeatmapLabels(t,e,i,r,o,s){var f,u;const a=this.config.dataLabels;if(!(a!=null&&a.enabled))return;const c=a.minCellHeight??20;if(o<c)return;const l=((f=a.style)==null?void 0:f.fontSize)||kt,h=a.color||((u=a.style)==null?void 0:u.color)||void 0;this.group.selectAll(".katucharts-heatmap-label").data(t).join("text").attr("class","katucharts-heatmap-label").attr("x",d=>e(d)+r/2+(a.x??0)).attr("y",d=>i(d)+o/2+(a.y??0)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",l).attr("fill",d=>gn(s(d),h)).style("pointer-events","none").text(d=>{const p=d.value??d.z??d.y;return p==null?a.nullFormatter?a.nullFormatter.call({point:d,series:{name:this.config.name}}):a.nullFormat?a.nullFormat:"":a.formatter?a.formatter.call({point:{...d,value:p},series:{name:this.config.name},x:d.x,y:d.y}):a.format?oe(Kt(a.format,{point:{...d,value:p},series:{name:this.config.name},x:d.x,y:d.y,value:p})):String(p)})}getUniqueValues(t){const e=new Set;for(const i of this.data){const r=i[t];r!==void 0&&e.add(r)}return Array.from(e).sort((i,r)=>i-r)}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function Pw(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Ew extends Xt{constructor(t){super(t)}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{boxWidth:a,boxOffset:c}=this.computeBoxGeometry(),l=this.config.medianColor||null,h=this.config.medianWidth??2,f=on(this.config.medianDashStyle),u=this.config.stemWidth??1,d=on(this.config.stemDashStyle),p=this.config.whiskerWidth??2,y=on(this.config.whiskerDashStyle),g=this.parseWhiskerLength(this.config.whiskerLength,a),m=on(this.config.boxDashStyle),x=this.config.lineWidth??1,b=(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt;for(let k=0;k<o.length;k++){const M=o[k],C=t.getPixelForValue(M.x??k)+c+a/2,E=M.low??0,_=M.q1??M.low??0,T=M.median??M.y??0,I=M.q3??M.high??0,L=M.high??0,P=e.getPixelForValue((E+L)/2),A=M.color||this.getPointColor(k,r),w=ti(this.config.fillColor,this.group,"transparent"),S=this.config.stemColor||A,$=this.config.whiskerColor||A,R=this.group.append("g").attr("class","katucharts-boxplot-point").style("cursor",this.config.cursor||"pointer"),F=R.append("line").attr("x1",C).attr("x2",C).attr("stroke",S).attr("stroke-width",u).attr("stroke-dasharray",d),D=R.append("line").attr("x1",C).attr("x2",C).attr("stroke",S).attr("stroke-width",u).attr("stroke-dasharray",d),z=R.append("rect").attr("x",C-a/2).attr("width",a).attr("fill",w).attr("stroke",A).attr("stroke-width",x).attr("stroke-dasharray",m).attr("rx",Pw(this.config.borderRadius)),B=R.append("line").attr("x1",C-a/2).attr("x2",C+a/2).attr("stroke",l||this.config.lineColor||A).attr("stroke-width",h).attr("stroke-dasharray",f),W=R.append("line").attr("x1",C-g/2).attr("x2",C+g/2).attr("stroke",$).attr("stroke-width",p).attr("stroke-dasharray",y),K=R.append("line").attr("x1",C-g/2).attr("x2",C+g/2).attr("stroke",$).attr("stroke-width",p).attr("stroke-dasharray",y);if(s){const X=xe(k,0,Nt,o.length),q=b;F.attr("y1",P).attr("y2",P).transition().duration(q).ease(pt).delay(X).attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(_)),D.attr("y1",P).attr("y2",P).transition().duration(q).ease(pt).delay(X).attr("y1",e.getPixelForValue(I)).attr("y2",e.getPixelForValue(L)),z.attr("y",P).attr("height",0).transition().duration(q).ease(pt).delay(X).attr("y",e.getPixelForValue(I)).attr("height",Math.abs(e.getPixelForValue(_)-e.getPixelForValue(I))),B.attr("y1",P).attr("y2",P).transition().duration(q).ease(pt).delay(X).attr("y1",e.getPixelForValue(T)).attr("y2",e.getPixelForValue(T)),W.attr("y1",P).attr("y2",P).transition().duration(q).ease(pt).delay(X).attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(E)),K.attr("y1",P).attr("y2",P).transition().duration(q).ease(pt).delay(X).attr("y1",e.getPixelForValue(L)).attr("y2",e.getPixelForValue(L))}else F.attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(_)),D.attr("y1",e.getPixelForValue(I)).attr("y2",e.getPixelForValue(L)),z.attr("y",e.getPixelForValue(I)).attr("height",Math.abs(e.getPixelForValue(_)-e.getPixelForValue(I))),B.attr("y1",e.getPixelForValue(T)).attr("y2",e.getPixelForValue(T)),W.attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(E)),K.attr("y1",e.getPixelForValue(L)).attr("y2",e.getPixelForValue(L));this.attachBoxPointEvents(R,M,k,C,e.getPixelForValue(T),x)}this.renderDataLabels(o,(k,M)=>t.getPixelForValue(k.x??M)+c+a/2,k=>e.getPixelForValue(k.high??k.y??0)),s&&this.emitAfterAnimate(b+o.length*Nt)}animateUpdate(t){const{xAxis:e,yAxis:i}=this.context,r=this.getColor(),o=this.data,{boxWidth:s,boxOffset:a}=this.computeBoxGeometry(),l=this.group.selectAll(".katucharts-boxplot-point").nodes();if(l.length!==o.length){this.group.selectAll("*").remove(),this.render();return}for(let h=0;h<Math.min(l.length,o.length);h++){const f=o[h],u=l[h],d=e.getPixelForValue(f.x??h)+a+s/2,p=f.low??0,y=f.q1??f.low??0,g=f.median??f.y??0,m=f.q3??f.high??0,x=f.high??0,v=f.color||this.getPointColor(h,r),b=this.config.stemColor||v,k=this.config.whiskerColor||v,M=this.config.medianColor||this.config.lineColor||v,C=ti(this.config.fillColor,this.group,"transparent"),E=u.querySelectorAll("line"),_=u.querySelector("rect");if(E[0]&&this.group.select(()=>E[0]).attr("stroke",b).transition().duration(t).attr("x1",d).attr("x2",d).attr("y1",i.getPixelForValue(p)).attr("y2",i.getPixelForValue(y)),E[1]&&this.group.select(()=>E[1]).attr("stroke",b).transition().duration(t).attr("x1",d).attr("x2",d).attr("y1",i.getPixelForValue(m)).attr("y2",i.getPixelForValue(x)),_&&this.group.select(()=>_).attr("stroke",v).attr("fill",C).transition().duration(t).attr("x",d-s/2).attr("y",i.getPixelForValue(m)).attr("height",Math.abs(i.getPixelForValue(y)-i.getPixelForValue(m))),E[2]&&this.group.select(()=>E[2]).attr("stroke",M).transition().duration(t).attr("x1",d-s/2).attr("x2",d+s/2).attr("y1",i.getPixelForValue(g)).attr("y2",i.getPixelForValue(g)),E[3]){const T=this.parseWhiskerLength(this.config.whiskerLength,s);this.group.select(()=>E[3]).attr("stroke",k).transition().duration(t).attr("x1",d-T/2).attr("x2",d+T/2).attr("y1",i.getPixelForValue(p)).attr("y2",i.getPixelForValue(p))}if(E[4]){const T=this.parseWhiskerLength(this.config.whiskerLength,s);this.group.select(()=>E[4]).attr("stroke",k).transition().duration(t).attr("x1",d-T/2).attr("x2",d+T/2).attr("y1",i.getPixelForValue(x)).attr("y2",i.getPixelForValue(x))}}this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(o,(h,f)=>e.getPixelForValue(h.x??f)+a+s/2,h=>i.getPixelForValue(h.high??h.y??0))}computeBoxGeometry(){const{xAxis:t,plotArea:e}=this.context,i=this.data,r=this.config.grouping!==!1&&this.context.totalSeriesOfType||1,o=this.config.grouping!==!1&&this.context.indexInType||0,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1;let c;this.config.pointWidth!==void 0?c=this.config.pointWidth*r*1.5:c=Math.min(200*r,e.width/Math.max(i.length,1));let l;this.config.pointWidth!==void 0?l=this.config.pointWidth:(l=c*(1-s*2)/r*(1-a*2),this.config.maxPointWidth!==void 0&&(l=Math.min(l,this.config.maxPointWidth)),l=Math.min(l,90));const f=-c*(1-s*2)/2+(l+l*a*2)*o+l*a;return{boxWidth:l,boxOffset:f}}getPointColor(t,e){if(this.config.colorByPoint){const i=this.config.colors||this.context.colors;return i[t%i.length]}return e}parseWhiskerLength(t,e){return t===void 0?e*.5:typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?e*(parseFloat(t)/100):parseFloat(t)||e*.5}attachBoxPointEvents(t,e,i,r,o,s){if(this.config.enableMouseTracking===!1)return;const a=()=>this.group.selectAll(".katucharts-boxplot-point");t.on("mouseover",c=>{var h,f,u,d,p;t.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),t.select("rect").interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",s+1),a().filter(function(){return this!==t.node()}).interrupt("hover").transition("hover").duration(Z).ease(j).style("opacity",.4),this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:c,plotX:r,plotY:o}),(f=(h=e.events)==null?void 0:h.mouseOver)==null||f.call(e,c),(p=(d=(u=this.config.point)==null?void 0:u.events)==null?void 0:d.mouseOver)==null||p.call(e,c)}).on("mouseout",c=>{var l,h,f,u,d;t.style("filter",""),t.select("rect").interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",s),a().interrupt("hover").transition("hover").duration(Z).ease(j).style("opacity",null),this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:c}),(h=(l=e.events)==null?void 0:l.mouseOut)==null||h.call(e,c),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.mouseOut)==null||d.call(e,c)}).on("click",c=>{var l,h,f,u,d,p,y;this.context.events.emit("point:click",{point:e,index:i,series:this,event:c}),(h=(l=e.events)==null?void 0:l.click)==null||h.call(e,c),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.click)==null||d.call(e,c),(y=(p=this.config.events)==null?void 0:p.click)==null||y.call(this,c)})}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(let o=0;o<this.data.length;o++){const s=this.data[o],a=s.x??o;t=Math.min(t,a),e=Math.max(e,a),i=Math.min(i,s.low??s.y??0),r=Math.max(r,s.high??s.y??0)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function cd(){Tt.registerType("line",Jf),Tt.registerType("spline",K2),Tt.registerType("area",td),Tt.registerType("areaspline",tw),Tt.registerType("column",ed),Tt.registerType("bar",iw),Tt.registerType("scatter",rw),Tt.registerType("bubble",ow),Tt.registerType("pie",rd),Tt.registerType("donut",rd),Tt.registerType("heatmap",Cw),Tt.registerType("boxplot",Ew)}function ld(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Tw extends Xt{constructor(t){super(t),this.processed=[]}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{barWidth:a,barOffset:c}=this.computeBarGeometry();this.processed=this.processWaterfallData(o);const l=this.group.selectAll(".katucharts-waterfall-bar").data(this.processed).join("rect").attr("class","katucharts-waterfall-bar").attr("x",d=>t.getPixelForValue(d.x??0)+c).attr("width",a).attr("rx",ld(this.config.borderRadius)).attr("fill",(d,p)=>this.getBarColor(d,p,r)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).style("cursor",this.config.cursor||"pointer"),h=e.getPixelForValue(0),u=(typeof this.config.animation=="object"?this.config.animation:{}).duration??bt;s?l.attr("y",h).attr("height",0).transition().duration(u).ease(pt).delay((d,p)=>xe(p,0,Nt,this.processed.length)).attr("y",d=>Math.min(e.getPixelForValue(d._start),e.getPixelForValue(d._end))).attr("height",d=>Math.max(Math.abs(e.getPixelForValue(d._start)-e.getPixelForValue(d._end)),this.config.minPointLength??0)):l.attr("y",d=>Math.min(e.getPixelForValue(d._start),e.getPixelForValue(d._end))).attr("height",d=>Math.max(Math.abs(e.getPixelForValue(d._start)-e.getPixelForValue(d._end)),this.config.minPointLength??0)),this.attachBarEvents(l),this.renderConnectors(a,c,!!s),this.renderDataLabels(this.processed,d=>t.getPixelForValue(d.x??0)+c+a/2,d=>e.getPixelForValue(d._end)),s&&this.emitAfterAnimate(u+o.length*Nt)}animateUpdate(t){const{xAxis:e,yAxis:i}=this.context,r=this.getColor(),{barWidth:o,barOffset:s}=this.computeBarGeometry();this.processed=this.processWaterfallData(this.data);const a=this.group.selectAll(".katucharts-waterfall-bar").data(this.processed);a.exit().transition().duration(t).attr("opacity",0).remove(),a.enter().append("rect").attr("class","katucharts-waterfall-bar").attr("rx",ld(this.config.borderRadius)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).attr("y",i.getPixelForValue(0)).attr("height",0).merge(a).transition().duration(t).attr("x",l=>e.getPixelForValue(l.x??0)+s).attr("width",o).attr("fill",(l,h)=>this.getBarColor(l,h,r)).attr("y",l=>Math.min(i.getPixelForValue(l._start),i.getPixelForValue(l._end))).attr("height",l=>Math.max(Math.abs(i.getPixelForValue(l._start)-i.getPixelForValue(l._end)),this.config.minPointLength??0)),this.group.selectAll(".katucharts-waterfall-connector").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderConnectors(o,s,!1),this.attachBarEvents(this.group.selectAll(".katucharts-waterfall-bar")),this.renderDataLabels(this.processed,l=>e.getPixelForValue(l.x??0)+s+o/2,l=>i.getPixelForValue(l._end))}processWaterfallData(t){let e=0,i=0;return t.map((r,o)=>{const s=!!r.isSum,a=!!r.isIntermediateSum,c=s||a,l=r.y??0;let h,f;return s?(h=0,f=e):a?(h=i,f=e,i=e):(h=e,f=e+l,e+=l),{...r,_start:h,_end:f,_isTotal:c,_isIntermediate:a}})}getBarColor(t,e,i){if(t.color)return t.color;if(this.config.colorByPoint){const o=this.config.colors||this.context.colors;return o[e%o.length]}return t._isIntermediate?this.config.intermediateSumColor||this.config.sumColor||"#434348":t._isTotal?this.config.sumColor||"#434348":(t.y??0)>=0?this.config.upColor||i:this.config.negativeColor||"#f15c80"}computeBarGeometry(){const{xAxis:t,plotArea:e}=this.context,i=this.data,r=this.config.grouping!==!1&&this.context.totalSeriesOfType||1,o=this.config.grouping!==!1&&this.context.indexInType||0,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1;let c;this.config.pointWidth!==void 0?c=this.config.pointWidth*r*1.5:c=e.width/Math.max(i.length,1);let l;this.config.pointWidth!==void 0?l=this.config.pointWidth:l=c*(1-s*2)/r*(1-a*2),this.config.maxPointWidth!==void 0&&(l=Math.min(l,this.config.maxPointWidth));const f=-c*(1-s*2)/2+(l+l*a*2)*o+l*a;return{barWidth:l,barOffset:f}}renderConnectors(t,e,i){const{xAxis:r,yAxis:o}=this.context,s=this.config.lineColor||"#999",a=this.config.lineWidth??1,c=on(this.config.dashStyle||"Dot"),l=this.group.selectAll(".katucharts-waterfall-connector").data(this.processed.slice(0,-1)).join("line").attr("class","katucharts-waterfall-connector").attr("x1",h=>r.getPixelForValue(h.x??0)+e+t).attr("x2",(h,f)=>r.getPixelForValue(this.processed[f+1].x??0)+e).attr("y1",h=>o.getPixelForValue(h._end)).attr("y2",h=>o.getPixelForValue(h._end)).attr("stroke",s).attr("stroke-width",a).attr("stroke-dasharray",c);i&&l.attr("opacity",0).transition().duration(bt).ease(pt).delay((h,f)=>bt+f*Nt).attr("opacity",1)}attachBarEvents(t){if(this.config.enableMouseTracking===!1)return;const{xAxis:e,yAxis:i}=this.context,r=this.processed;t.style("cursor",this.config.cursor||"pointer").on("mouseover",(o,s)=>{var h,f,u,d,p;const a=o.currentTarget,c=a.getAttribute("fill")||"";a.setAttribute("data-orig-fill",c),a.style.filter="drop-shadow(0 2px 4px rgba(0,0,0,0.25))",st(a).interrupt("hover").transition("hover").duration(Z).ease(j).style("fill",Zf(c,.15));const l=r.indexOf(s);this.context.events.emit("point:mouseover",{point:s,index:l,series:this,event:o,plotX:e.getPixelForValue(s.x??0),plotY:i.getPixelForValue(s._end)}),(f=(h=s.events)==null?void 0:h.mouseOver)==null||f.call(s,o),(p=(d=(u=this.config.point)==null?void 0:u.events)==null?void 0:d.mouseOver)==null||p.call(s,o)}).on("mouseout",(o,s)=>{var l,h,f,u,d;const a=o.currentTarget;a.style.filter="",st(a).interrupt("hover").transition("hover").duration(Z).ease(j).style("fill",null);const c=r.indexOf(s);this.context.events.emit("point:mouseout",{point:s,index:c,series:this,event:o}),(h=(l=s.events)==null?void 0:l.mouseOut)==null||h.call(s,o),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.mouseOut)==null||d.call(s,o)}).on("click",(o,s)=>{var c,l,h,f,u,d,p;const a=r.indexOf(s);this.context.events.emit("point:click",{point:s,index:a,series:this,event:o}),(l=(c=s.events)==null?void 0:c.click)==null||l.call(s,o),(u=(f=(h=this.config.point)==null?void 0:h.events)==null?void 0:f.click)==null||u.call(s,o),(p=(d=this.config.events)==null?void 0:d.click)==null||p.call(this,o),this.handlePointSelect(st(o.currentTarget),s,a,o)})}getDataExtents(){let t=1/0,e=-1/0,i=0,r=0,o=0;for(let s=0;s<this.data.length;s++){const a=this.data[s],c=a.x??s;t=Math.min(t,c),e=Math.max(e,c);const l=a.isSum||a.isIntermediateSum,h=a.y??0;l||(o+=h),i=Math.min(i,l?0:Math.min(o-h,o),0),r=Math.max(r,o)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function Lw(n,t){return n.parent===t.parent?1:2}function $w(n){return n.reduce(Iw,0)/n.length}function Iw(n,t){return n+t.x}function Fw(n){return 1+n.reduce(Rw,0)}function Rw(n,t){return Math.max(n,t.y)}function Dw(n){for(var t;t=n.children;)n=t[0];return n}function zw(n){for(var t;t=n.children;)n=t[t.length-1];return n}function Bw(){var n=Lw,t=1,e=1,i=!1;function r(o){var s,a=0;o.eachAfter(function(u){var d=u.children;d?(u.x=$w(d),u.y=Fw(d)):(u.x=s?a+=n(u,s):0,u.y=0,s=u)});var c=Dw(o),l=zw(o),h=c.x-n(c,l)/2,f=l.x+n(l,c)/2;return o.eachAfter(i?function(u){u.x=(u.x-o.x)*t,u.y=(o.y-u.y)*e}:function(u){u.x=(u.x-h)/(f-h)*t,u.y=(1-(o.y?u.y/o.y:1))*e})}return r.separation=function(o){return arguments.length?(n=o,r):n},r.size=function(o){return arguments.length?(i=!1,t=+o[0],e=+o[1],r):i?null:[t,e]},r.nodeSize=function(o){return arguments.length?(i=!0,t=+o[0],e=+o[1],r):i?[t,e]:null},r}function Ow(n){var t=0,e=n.children,i=e&&e.length;if(!i)t=1;else for(;--i>=0;)t+=e[i].value;n.value=t}function Nw(){return this.eachAfter(Ow)}function Ww(n,t){let e=-1;for(const i of this)n.call(t,i,++e,this);return this}function Hw(n,t){for(var e=this,i=[e],r,o,s=-1;e=i.pop();)if(n.call(t,e,++s,this),r=e.children)for(o=r.length-1;o>=0;--o)i.push(r[o]);return this}function Vw(n,t){for(var e=this,i=[e],r=[],o,s,a,c=-1;e=i.pop();)if(r.push(e),o=e.children)for(s=0,a=o.length;s<a;++s)i.push(o[s]);for(;e=r.pop();)n.call(t,e,++c,this);return this}function Gw(n,t){let e=-1;for(const i of this)if(n.call(t,i,++e,this))return i}function Yw(n){return this.eachAfter(function(t){for(var e=+n(t.data)||0,i=t.children,r=i&&i.length;--r>=0;)e+=i[r].value;t.value=e})}function Xw(n){return this.eachBefore(function(t){t.children&&t.children.sort(n)})}function Uw(n){for(var t=this,e=jw(t,n),i=[t];t!==e;)t=t.parent,i.push(t);for(var r=i.length;n!==e;)i.splice(r,0,n),n=n.parent;return i}function jw(n,t){if(n===t)return n;var e=n.ancestors(),i=t.ancestors(),r=null;for(n=e.pop(),t=i.pop();n===t;)r=n,n=e.pop(),t=i.pop();return r}function qw(){for(var n=this,t=[n];n=n.parent;)t.push(n);return t}function Zw(){return Array.from(this)}function Kw(){var n=[];return this.eachBefore(function(t){t.children||n.push(t)}),n}function Jw(){var n=this,t=[];return n.each(function(e){e!==n&&t.push({source:e.parent,target:e})}),t}function*Qw(){var n=this,t,e=[n],i,r,o;do for(t=e.reverse(),e=[];n=t.pop();)if(yield n,i=n.children)for(r=0,o=i.length;r<o;++r)e.push(i[r]);while(e.length)}function Zi(n,t){n instanceof Map?(n=[void 0,n],t===void 0&&(t=nk)):t===void 0&&(t=ek);for(var e=new Ki(n),i,r=[e],o,s,a,c;i=r.pop();)if((s=t(i.data))&&(c=(s=Array.from(s)).length))for(i.children=s,a=c-1;a>=0;--a)r.push(o=s[a]=new Ki(s[a])),o.parent=i,o.depth=i.depth+1;return e.eachBefore(hd)}function tk(){return Zi(this).eachBefore(ik)}function ek(n){return n.children}function nk(n){return Array.isArray(n)?n[1]:null}function ik(n){n.data.value!==void 0&&(n.value=n.data.value),n.data=n.data.data}function hd(n){var t=0;do n.height=t;while((n=n.parent)&&n.height<++t)}function Ki(n){this.data=n,this.depth=this.height=0,this.parent=null}Ki.prototype=Zi.prototype={constructor:Ki,count:Nw,each:Ww,eachAfter:Vw,eachBefore:Hw,find:Gw,sum:Yw,sort:Xw,path:Uw,ancestors:qw,descendants:Zw,leaves:Kw,links:Jw,copy:tk,[Symbol.iterator]:Qw};function Rc(n){return n==null?null:ud(n)}function ud(n){if(typeof n!="function")throw new Error;return n}function $r(){return 0}function Ir(n){return function(){return n}}function fd(n){n.x0=Math.round(n.x0),n.y0=Math.round(n.y0),n.x1=Math.round(n.x1),n.y1=Math.round(n.y1)}function ws(n,t,e,i,r){for(var o=n.children,s,a=-1,c=o.length,l=n.value&&(i-t)/n.value;++a<c;)s=o[a],s.y0=e,s.y1=r,s.x0=t,s.x1=t+=s.value*l}function dd(){var n=1,t=1,e=0,i=!1;function r(s){var a=s.height+1;return s.x0=s.y0=e,s.x1=n,s.y1=t/a,s.eachBefore(o(t,a)),i&&s.eachBefore(fd),s}function o(s,a){return function(c){c.children&&ws(c,c.x0,s*(c.depth+1)/a,c.x1,s*(c.depth+2)/a);var l=c.x0,h=c.y0,f=c.x1-e,u=c.y1-e;f<l&&(l=f=(l+f)/2),u<h&&(h=u=(h+u)/2),c.x0=l,c.y0=h,c.x1=f,c.y1=u}}return r.round=function(s){return arguments.length?(i=!!s,r):i},r.size=function(s){return arguments.length?(n=+s[0],t=+s[1],r):[n,t]},r.padding=function(s){return arguments.length?(e=+s,r):e},r}var rk={depth:-1},pd={},Dc={};function ok(n){return n.id}function sk(n){return n.parentId}function zc(){var n=ok,t=sk,e;function i(r){var o=Array.from(r),s=n,a=t,c,l,h,f,u,d,p,y,g=new Map;if(e!=null){const m=o.map((b,k)=>ak(e(b,k,r))),x=m.map(gd),v=new Set(m).add("");for(const b of x)v.has(b)||(v.add(b),m.push(b),x.push(gd(b)),o.push(Dc));s=(b,k)=>m[k],a=(b,k)=>x[k]}for(h=0,c=o.length;h<c;++h)l=o[h],d=o[h]=new Ki(l),(p=s(l,h,r))!=null&&(p+="")&&(y=d.id=p,g.set(y,g.has(y)?pd:d)),(p=a(l,h,r))!=null&&(p+="")&&(d.parent=p);for(h=0;h<c;++h)if(d=o[h],p=d.parent){if(u=g.get(p),!u)throw new Error("missing: "+p);if(u===pd)throw new Error("ambiguous: "+p);u.children?u.children.push(d):u.children=[d],d.parent=u}else{if(f)throw new Error("multiple roots");f=d}if(!f)throw new Error("no root");if(e!=null){for(;f.data===Dc&&f.children.length===1;)f=f.children[0],--c;for(let m=o.length-1;m>=0&&(d=o[m],d.data===Dc);--m)d.data=null}if(f.parent=rk,f.eachBefore(function(m){m.depth=m.parent.depth+1,--c}).eachBefore(hd),f.parent=null,c>0)throw new Error("cycle");return f}return i.id=function(r){return arguments.length?(n=Rc(r),i):n},i.parentId=function(r){return arguments.length?(t=Rc(r),i):t},i.path=function(r){return arguments.length?(e=Rc(r),i):e},i}function ak(n){n=`${n}`;let t=n.length;return Bc(n,t-1)&&!Bc(n,t-2)&&(n=n.slice(0,-1)),n[0]==="/"?n:`/${n}`}function gd(n){let t=n.length;if(t<2)return"";for(;--t>1&&!Bc(n,t););return n.slice(0,t)}function Bc(n,t){if(n[t]==="/"){let e=0;for(;t>0&&n[--t]==="\\";)++e;if(!(e&1))return!0}return!1}function ck(n,t){return n.parent===t.parent?1:2}function Oc(n){var t=n.children;return t?t[0]:n.t}function Nc(n){var t=n.children;return t?t[t.length-1]:n.t}function lk(n,t,e){var i=e/(t.i-n.i);t.c-=i,t.s+=e,n.c+=i,t.z+=e,t.m+=e}function hk(n){for(var t=0,e=0,i=n.children,r=i.length,o;--r>=0;)o=i[r],o.z+=t,o.m+=t,t+=o.s+(e+=o.c)}function uk(n,t,e){return n.a.parent===t.parent?n.a:e}function ks(n,t){this._=n,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}ks.prototype=Object.create(Ki.prototype);function fk(n){for(var t=new ks(n,0),e,i=[t],r,o,s,a;e=i.pop();)if(o=e._.children)for(e.children=new Array(a=o.length),s=a-1;s>=0;--s)i.push(r=e.children[s]=new ks(o[s],s)),r.parent=e;return(t.parent=new ks(null,0)).children=[t],t}function dk(){var n=ck,t=1,e=1,i=null;function r(l){var h=fk(l);if(h.eachAfter(o),h.parent.m=-h.z,h.eachBefore(s),i)l.eachBefore(c);else{var f=l,u=l,d=l;l.eachBefore(function(x){x.x<f.x&&(f=x),x.x>u.x&&(u=x),x.depth>d.depth&&(d=x)});var p=f===u?1:n(f,u)/2,y=p-f.x,g=t/(u.x+p+y),m=e/(d.depth||1);l.eachBefore(function(x){x.x=(x.x+y)*g,x.y=x.depth*m})}return l}function o(l){var h=l.children,f=l.parent.children,u=l.i?f[l.i-1]:null;if(h){hk(l);var d=(h[0].z+h[h.length-1].z)/2;u?(l.z=u.z+n(l._,u._),l.m=l.z-d):l.z=d}else u&&(l.z=u.z+n(l._,u._));l.parent.A=a(l,u,l.parent.A||f[0])}function s(l){l._.x=l.z+l.parent.m,l.m+=l.parent.m}function a(l,h,f){if(h){for(var u=l,d=l,p=h,y=u.parent.children[0],g=u.m,m=d.m,x=p.m,v=y.m,b;p=Nc(p),u=Oc(u),p&&u;)y=Oc(y),d=Nc(d),d.a=l,b=p.z+x-u.z-g+n(p._,u._),b>0&&(lk(uk(p,l,f),l,b),g+=b,m+=b),x+=p.m,g+=u.m,v+=y.m,m+=d.m;p&&!Nc(d)&&(d.t=p,d.m+=x-m),u&&!Oc(y)&&(y.t=u,y.m+=g-v,f=l)}return f}function c(l){l.x*=t,l.y=l.depth*e}return r.separation=function(l){return arguments.length?(n=l,r):n},r.size=function(l){return arguments.length?(i=!1,t=+l[0],e=+l[1],r):i?null:[t,e]},r.nodeSize=function(l){return arguments.length?(i=!0,t=+l[0],e=+l[1],r):i?[t,e]:null},r}function Fr(n,t,e,i,r){for(var o=n.children,s,a=-1,c=o.length,l=n.value&&(r-e)/n.value;++a<c;)s=o[a],s.x0=t,s.x1=i,s.y0=e,s.y1=e+=s.value*l}var pk=(1+Math.sqrt(5))/2;function gk(n,t,e,i,r,o){for(var s=[],a=t.children,c,l,h=0,f=0,u=a.length,d,p,y=t.value,g,m,x,v,b,k,M;h<u;){d=r-e,p=o-i;do g=a[f++].value;while(!g&&f<u);for(m=x=g,k=Math.max(p/d,d/p)/(y*n),M=g*g*k,b=Math.max(x/M,M/m);f<u;++f){if(g+=l=a[f].value,l<m&&(m=l),l>x&&(x=l),M=g*g*k,v=Math.max(x/M,M/m),v>b){g-=l;break}b=v}s.push(c={value:g,dice:d<p,children:a.slice(h,f)}),c.dice?ws(c,e,i,r,y?i+=p*g/y:o):Fr(c,e,i,y?e+=d*g/y:r,o),y-=g,h=f}return s}const Ms=function n(t){function e(i,r,o,s,a){gk(t,i,r,o,s,a)}return e.ratio=function(i){return n((i=+i)>1?i:1)},e}(pk);function mk(){var n=Ms,t=!1,e=1,i=1,r=[0],o=$r,s=$r,a=$r,c=$r,l=$r;function h(u){return u.x0=u.y0=0,u.x1=e,u.y1=i,u.eachBefore(f),r=[0],t&&u.eachBefore(fd),u}function f(u){var d=r[u.depth],p=u.x0+d,y=u.y0+d,g=u.x1-d,m=u.y1-d;g<p&&(p=g=(p+g)/2),m<y&&(y=m=(y+m)/2),u.x0=p,u.y0=y,u.x1=g,u.y1=m,u.children&&(d=r[u.depth+1]=o(u)/2,p+=l(u)-d,y+=s(u)-d,g-=a(u)-d,m-=c(u)-d,g<p&&(p=g=(p+g)/2),m<y&&(y=m=(y+m)/2),n(u,p,y,g,m))}return h.round=function(u){return arguments.length?(t=!!u,h):t},h.size=function(u){return arguments.length?(e=+u[0],i=+u[1],h):[e,i]},h.tile=function(u){return arguments.length?(n=ud(u),h):n},h.padding=function(u){return arguments.length?h.paddingInner(u).paddingOuter(u):h.paddingInner()},h.paddingInner=function(u){return arguments.length?(o=typeof u=="function"?u:Ir(+u),h):o},h.paddingOuter=function(u){return arguments.length?h.paddingTop(u).paddingRight(u).paddingBottom(u).paddingLeft(u):h.paddingTop()},h.paddingTop=function(u){return arguments.length?(s=typeof u=="function"?u:Ir(+u),h):s},h.paddingRight=function(u){return arguments.length?(a=typeof u=="function"?u:Ir(+u),h):a},h.paddingBottom=function(u){return arguments.length?(c=typeof u=="function"?u:Ir(+u),h):c},h.paddingLeft=function(u){return arguments.length?(l=typeof u=="function"?u:Ir(+u),h):l},h}function yk(n,t,e,i,r){var o=n.children,s,a=o.length,c,l=new Array(a+1);for(l[0]=c=s=0;s<a;++s)l[s+1]=c+=o[s].value;h(0,a,n.value,t,e,i,r);function h(f,u,d,p,y,g,m){if(f>=u-1){var x=o[f];x.x0=p,x.y0=y,x.x1=g,x.y1=m;return}for(var v=l[f],b=d/2+v,k=f+1,M=u-1;k<M;){var C=k+M>>>1;l[C]<b?k=C+1:M=C}b-l[k-1]<l[k]-b&&f+1<k&&--k;var E=l[k]-v,_=d-E;if(g-p>m-y){var T=d?(p*_+g*E)/d:g;h(f,k,E,p,y,T,m),h(k,u,_,T,y,g,m)}else{var I=d?(y*_+m*E)/d:m;h(f,k,E,p,y,g,I),h(k,u,_,p,I,g,m)}}}function Rr(n,t,e,i,r){(n.depth&1?Fr:ws)(n,t,e,i,r)}function xk(n,t,e){return n?n.split(/<br\s*\/?>/i).map(r=>{const o=[],s=/<b(?:\s+style="([^"]*)")?\s*>([\s\S]*?)<\/b>/gi;let a=0,c;for(;(c=s.exec(r))!==null;){if(c.index>a){const d=oe(r.slice(a,c.index));d&&o.push({text:d,fontSize:t,fontWeight:e})}const l=c[1]||"",h=l.match(/font-size\s*:\s*([^;"]+)/i),f=l.match(/font-weight\s*:\s*([^;"]+)/i),u=oe(c[2]);u&&o.push({text:u,fontSize:h?h[1].trim():t,fontWeight:f?f[1].trim():"bold"}),a=c.index+c[0].length}if(a<r.length){const l=oe(r.slice(a));l&&o.push({text:l,fontSize:t,fontWeight:e})}return o}):[]}function bk(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class vk extends Xt{constructor(t){super(t),this.currentRoot=null}render(){var T,I,L;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=this.config.levels||[],s=this.config.colorByPoint!==!1,a=this.config.allowTraversingTree===!0||this.config.allowDrillToNode===!0,c=this.config.interactByLeaf??!a,l=this.config.alternateStartingDirection===!0,h=((I=(T=this.config.states)==null?void 0:T.inactive)==null?void 0:I.opacity)??.4,f=this.buildHierarchy(r),u=a&&this.currentRoot?this.currentRoot:f,d={squarify:Ms,squarified:Ms,binary:yk,dice:ws,slice:Fr,sliceDice:Rr,sliceAndDice:Rr,strip:Fr,stripes:Fr},p=this.config.layoutAlgorithm||"squarified",y=d[p]||Ms,g=this.config.layoutStartingDirection||"vertical",m=this.config.opacity??1,x=l||p==="sliceAndDice"||p==="sliceDice"?Rr:y,v=(P,A)=>{var $,R;const w=(($=P.data)==null?void 0:$.sortIndex)??0,S=((R=A.data)==null?void 0:R.sortIndex)??0;return w!==S?w-S:(A.value||0)-(P.value||0)};u.sort(v),mk().size([t.width,t.height]).tile(x).padding(1)(u);const b=a&&!c&&u.children||u.leaves(),k=P=>o.find(A=>A.level===P),C=(((L=this.config.colorAxis)==null?void 0:L.dataClasses)||[]).map(P=>P.color),E=(P,A)=>{var S,$,R,F,D;if(P.data.color)return P.data.color;const w=k(P.depth);if(w!=null&&w.color){const z=w.colorVariation;if((z==null?void 0:z.key)==="brightness"&&((S=P.parent)!=null&&S.children)){const B=P.parent.children,W=B.indexOf(P),K=B.length,X=K>1?-.5+W/(K-1)*(z.to??.5):0,q=ci((($=ce(w.color))==null?void 0:$.toString())||w.color);return q.l=Math.max(.1,Math.min(.95,q.l+X*.3)),q.toString()}return w.color}if(C.length>0)return C[A%C.length];if(s){const z=e[A%e.length],B=P.parent?k(P.parent.depth):void 0;if(((R=B==null?void 0:B.colorVariation)==null?void 0:R.key)==="brightness"){const W=((F=P.parent)==null?void 0:F.children)||[],K=W.indexOf(P),X=W.length,q=B.colorVariation.to??.5,N=X>1?K/(X-1)*q:q*.5,H=ci(((D=ce(z))==null?void 0:D.toString())||z);return H.l=Math.max(.1,Math.min(.95,H.l+N*.3)),H.toString()}return z}return this.getColor()},_=this.group.selectAll(".katucharts-treemap-cell").data(b).join("rect").attr("class","katucharts-treemap-cell").attr("x",P=>P.x0).attr("y",P=>P.y0).attr("width",P=>Math.max(0,P.x1-P.x0)).attr("height",P=>Math.max(0,P.y1-P.y0)).attr("fill",(P,A)=>{const w=E(P,A);return P._color=w,w}).attr("stroke",P=>{const A=k(P.depth);return(A==null?void 0:A.borderColor)||this.config.borderColor||this.autoBorderColor()}).attr("stroke-width",P=>{const A=k(P.depth);return(A==null?void 0:A.borderWidth)??this.config.borderWidth??1}).attr("rx",bk(this.config.borderRadius)).style("cursor",this.config.cursor||"pointer");i?_.attr("opacity",0).transition().duration(bt).ease(pt).delay((P,A)=>xe(A,0,Nt,b.length)).attr("opacity",m):m!==1&&_.attr("opacity",m),this.config.enableMouseTracking!==!1&&_.on("mouseover",(P,A)=>{var D,z,B,W,K,X;const w=st(P.currentTarget),S=w.attr("fill"),$=((z=(D=this.config.states)==null?void 0:D.hover)==null?void 0:z.brightness)??.3,R=((W=(B=ce(S))==null?void 0:B.brighter($))==null?void 0:W.toString())||S;w.transition("fill").duration(Z).ease(j).attr("fill",R),w.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.2))"),_.interrupt("highlight"),_.attr("opacity",1),_.filter(q=>q!==A).transition("highlight").duration(Z).ease(j).attr("opacity",h);const F=b.indexOf(A);this.context.events.emit("point:mouseover",{point:A.data,index:F,series:this,event:P,plotX:(A.x0+A.x1)/2,plotY:(A.y0+A.y1)/2}),(X=(K=A.data.events)==null?void 0:K.mouseOver)==null||X.call(A.data,P)}).on("mouseout",(P,A)=>{var R,F;const w=st(P.currentTarget),S=b.indexOf(A),$=E(A,S);w.transition("fill").duration(Z).ease(j).attr("fill",$),w.style("filter",""),_.interrupt("highlight"),_.transition("highlight").duration(Z).ease(j).attr("opacity",1),this.context.events.emit("point:mouseout",{point:A.data,index:S,series:this,event:P}),(F=(R=A.data.events)==null?void 0:R.mouseOut)==null||F.call(A.data,P)}).on("click",(P,A)=>{var S,$,R,F;const w=b.indexOf(A);if(a&&A.children){this.currentRoot=A,this.group.selectAll("*").remove(),this.render();return}this.context.events.emit("point:click",{point:A.data,index:w,series:this,event:P}),($=(S=A.data.events)==null?void 0:S.click)==null||$.call(A.data,P),(F=(R=this.config.events)==null?void 0:R.click)==null||F.call(this,P)}),a&&this.currentRoot&&this.currentRoot!==f&&this.renderBreadcrumbs(t,f),this.renderLabels(b,k)}buildHierarchy(t){if(t.some(i=>i.children&&i.children.length>0)){const i=r=>r.map(o=>{const s={...o,value:o.y??o.value??(o.children?0:1)};return s.children&&(s.children=i(s.children)),s});return Zi({children:i(t)}).sum(r=>r.children?0:r.value||0)}return Zi({children:t.map(i=>({...i,value:i.y??i.value??1}))}).sum(i=>i.value||0)}renderBreadcrumbs(t,e){const i=this.config.breadcrumbs||{},r=i.position||{},o=r.x??0,s=r.y??-20,a=i.separator??" / ",c=i.style||{},l=c.fontSize||"11px",h=c.color||Le,f=[];let u=this.currentRoot;for(;u;)f.unshift(u),u=u.parent;const d=this.group.append("g").attr("class","katucharts-treemap-breadcrumbs").attr("transform",`translate(${o},${s})`);let p=0;f.forEach((y,g)=>{var k,M,C;const m=((k=y.data)==null?void 0:k.name)||(g===0?"Root":`Level ${g}`),x=g===f.length-1,v=d.append("text").attr("x",p).attr("y",0).attr("font-size",l).attr("fill",x?"#999":"#2f7ed8").attr("dominant-baseline","middle").style("cursor",x?"default":"pointer").style("text-decoration",x?"none":"underline").text(m);x||v.on("click",()=>{this.currentRoot=y===e?null:y,this.group.selectAll("*").remove(),this.render()});const b=((C=(M=v.node())==null?void 0:M.getComputedTextLength)==null?void 0:C.call(M))||m.length*7;p+=b,x||(d.append("text").attr("x",p).attr("y",0).attr("font-size",l).attr("fill",h).attr("dominant-baseline","middle").style("pointer-events","none").text(a),p+=a.length*5)})}renderLabels(t,e){var u,d,p;const i=this.config.dataLabels||{};if(!(i.enabled!==!1))return;const o=((u=i.style)==null?void 0:u.fontSize)||kt,s=i.color||((d=i.style)==null?void 0:d.color)||void 0,a=((p=i.style)==null?void 0:p.fontWeight)||"normal",c=i.align||"left",l=i.verticalAlign||"top",h=i.x??4,f=i.y??4;this.group.selectAll(".katucharts-treemap-label").remove(),t.forEach((y,g)=>{const m=e(y.depth),x=m==null?void 0:m.dataLabels;if((x==null?void 0:x.enabled)===!1)return;const v=y.x1-y.x0,b=y.y1-y.y0;if(v<30||b<16)return;let k="";if(i.formatter)k=i.formatter.call({point:y.data,series:{name:this.config.name},x:y.data.x,y:y.data.y??y.data.value});else{const P=i.format||i.pointFormat;P?k=Kt(P,{point:y.data,series:{name:this.config.name},x:y.data.x,y:y.data.y??y.data.value}):k=y.data.name||""}const M=xk(k,o,a);let C;c==="right"?C=y.x1-h:c==="center"?C=(y.x0+y.x1)/2:C=y.x0+h;const E=c==="right"?"end":c==="center"?"middle":"start";let _;l==="bottom"?_=y.y1-f:l==="middle"?_=(y.y0+y.y1)/2:_=y.y0+f;const T=this.group.append("text").attr("class","katucharts-treemap-label").attr("x",C).attr("text-anchor",E).attr("fill",gn(y._color,s)).style("pointer-events","none");let I=_;M.forEach((P,A)=>{if(P.length===0)return;const w=P.map($=>me($.fontSize)),S=Math.max(...w)*1.15;I+=S,P.forEach(($,R)=>{const F=T.append("tspan").attr("font-size",$.fontSize).attr("font-weight",$.fontWeight).text($.text);R===0&&F.attr("x",C).attr("y",I)})}),this.context.animate&&T.attr("opacity",0).transition().duration(bt).ease(pt).delay(Qn+g*Nt).attr("opacity",1);const L=T.node();if(L)try{const P=L.getBBox();(P.height+f>b||P.width+h>v)&&P.height>b-f&&T.remove()}catch{}})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class wk extends Xt{constructor(t){super(t),this.currentRoot=null,t.showInLegend=!1}render(){var W,K,X,q,N;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config.levels||[],o=this.config.allowTraversingTree===!0||this.config.allowDrillToNode===!0,s=this.config.slicedOffset??0,a=((K=(W=this.config.states)==null?void 0:W.inactive)==null?void 0:K.opacity)??.4,c=this.config.center||["50%","50%"],l=this.resolvePercent(c[0],t.width),h=this.resolvePercent(c[1],t.height),f=this.config.size,u=Math.min(t.width,t.height),d=f?this.resolvePercent(f,u)/2-5:u/2-5,p=this.config.startAngle??0,y=this.config.endAngle??360,g=p*Math.PI/180,x=y*Math.PI/180-g,v=(X=this.group.node())==null?void 0:X.parentElement;v&&st(v).attr("clip-path",null);const b=this.buildHierarchy(g,x),k=this.config.rootId;let M=b;o&&this.currentRoot?M=this.currentRoot:k&&b.each(H=>{var Y;((Y=H.data)==null?void 0:Y.id)===k&&(M=H)});const C=this.getMaxDepth(M),E=this.config.levelIsConstant!==!1,_=this.computeRingWidths(d,C,r);this.applyCustomRadii(M,_,E),this.assignColors(M,e,r);const T=this.config.borderRadius!==void 0?this.resolveBorderRadius(this.config.borderRadius):0,I=Ce().startAngle(H=>H.x0).endAngle(H=>H.x1).innerRadius(H=>H._y0).outerRadius(H=>H._y1).padAngle(.005).cornerRadius(T),L=this.group.append("g").attr("transform",`translate(${l},${h})`),P=M.descendants(),A=P[0],w=P.filter(H=>H.depth>0),S=A._y1||A.y1,$=A.data.color||this.getColor()||"#ffffff",R=ci($),F=R&&!isNaN(R.h)?ci(R.h,R.s*.4,.88).toString():$,D=L.append("circle").attr("r",S).attr("fill",F).attr("stroke","none").style("cursor",o?"pointer":"default");if(o&&this.currentRoot&&this.currentRoot!==b&&(L.select("circle").on("click",()=>{var H;this.currentRoot=((H=this.currentRoot)==null?void 0:H.parent)||null,this.group.selectAll("*").remove(),this.render()}),this.renderBreadcrumbs(b)),this.config.enableMouseTracking!==!1){const H=this,Y="#f0f0f0";D.on("mouseover",function(G){st(this).transition("fill").duration(Z).ease(j).attr("fill",Y),st(this).style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.15))"),H.context.events.emit("point:mouseover",{point:{...A.data,value:A.value,y:A.value??A.data.value},index:-1,series:H,event:G,plotX:l,plotY:h})}).on("mouseout",function(G){st(this).transition("fill").duration(Z).ease(j).attr("fill",F),st(this).style("filter",""),H.context.events.emit("point:mouseout",{point:{...A.data,value:A.value,y:A.value??A.data.value},index:-1,series:H,event:G})})}if(S>15){const H=this.config.name||((q=A.data)==null?void 0:q.name)||"";if(H){const Y=((N=this.config.dataLabels)==null?void 0:N.style)||{},G=gn(F,Y.color),Q=Y.textOutline,O=L.append("text").attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",S>35?"13px":"10px").attr("font-weight","bold").attr("fill",G).style("pointer-events","none").text(H);if(Q){const it=Q.split(/\s+/);O.style("paint-order","stroke fill").attr("stroke",it.length>=2?it.slice(1).join(" "):"white").attr("stroke-width",parseFloat(Q)||0).attr("stroke-linejoin","round")}}}const z=L.selectAll(".katucharts-sunburst-arc").data(w).join("path").attr("class","katucharts-sunburst-arc").attr("fill",H=>H._color).attr("stroke",H=>{const Y=r.find(G=>G.level===H.depth);return(Y==null?void 0:Y.borderColor)||H._color}).attr("stroke-width",H=>{const Y=r.find(G=>G.level===H.depth);return Y!=null&&Y.borderColor?(Y==null?void 0:Y.borderWidth)??1:.5}).attr("shape-rendering","geometricPrecision").style("cursor","pointer");s>0&&z.each(function(H){if(H.data.sliced){const Y=(H.x0+H.x1)/2,G=s*Math.sin(Y),Q=-s*Math.cos(Y);st(this).attr("transform",`translate(${G},${Q})`)}}),i?z.each(function(H,Y){const G=st(this),Q={x0:H.x0,x1:H.x0,_y0:H._y0,_y1:H._y1},O={x0:H.x0,x1:H.x1,_y0:H._y0,_y1:H._y1},it=he(Q,O);G.transition().duration(bt).ease(pt).delay(Lc+Y*Nt).attrTween("d",()=>et=>I(it(et)))}):z.attr("d",I);const B=new Set;for(const H of w)H.depth>1&&B.add(H._y0);for(const H of B)L.append("circle").attr("r",H).attr("fill","none").attr("stroke",this.autoBorderColor()).attr("stroke-width",2).style("pointer-events","none");if(this.renderLabels(L,w,r),this.config.enableMouseTracking!==!1){const H=this;z.on("mouseover",function(Y,G){var ht,ft,ct,nt;const Q=st(this),O=((ft=(ht=ce(G._color))==null?void 0:ht.brighter(.3))==null?void 0:ft.toString())||G._color;Q.transition("fill").duration(Z).ease(j).attr("fill",O),Q.style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.2))"),z.interrupt("highlight"),z.attr("opacity",1),z.filter(U=>U!==G&&!H.isAncestorOf(U,G)).transition("highlight").duration(Z).ease(j).attr("opacity",a);const it=w.indexOf(G),et=I.centroid(G);H.context.events.emit("point:mouseover",{point:{...G.data,value:G.value,y:G.value??G.data.value},index:it,series:H,event:Y,plotX:l+et[0],plotY:h+et[1]}),(nt=(ct=G.data.events)==null?void 0:ct.mouseOver)==null||nt.call(G.data,Y)}).on("mouseout",function(Y,G){var it,et;const Q=st(this);Q.transition("fill").duration(Z).ease(j).attr("fill",G._color),Q.style("filter",""),z.interrupt("highlight"),z.transition("highlight").duration(Z).ease(j).attr("opacity",1);const O=w.indexOf(G);H.context.events.emit("point:mouseout",{point:{...G.data,value:G.value,y:G.value??G.data.value},index:O,series:H,event:Y}),(et=(it=G.data.events)==null?void 0:it.mouseOut)==null||et.call(G.data,Y)}).on("click",function(Y,G){var O,it,et,ht;const Q=w.indexOf(G);if(o&&G.children&&G.children.length>0){H.currentRoot=G,dd().size([x,1])(H.currentRoot),g!==0&&H.currentRoot.each(ft=>{ft.x0+=g,ft.x1+=g}),H.group.selectAll("*").remove(),H.render();return}H.context.events.emit("point:click",{point:G.data,index:Q,series:H,event:Y}),(it=(O=G.data.events)==null?void 0:O.click)==null||it.call(G.data,Y),(ht=(et=H.config.events)==null?void 0:et.click)==null||ht.call(H,Y)})}}isAncestorOf(t,e){let i=e;for(;i;){if(i===t)return!0;i=i.parent}return!1}buildHierarchy(t=0,e=2*Math.PI){const i=this.data,r=i.length>0&&(i[0].id!==void 0||i[0].parent!==void 0);let o;if(r){const s=i.map(c=>({...c,id:c.id||c.name||String(i.indexOf(c)),parentId:c.parent||null,value:c.y??c.value??void 0}));s.some(c=>!c.parentId||c.parentId==="")?s.forEach(c=>{(!c.parentId||c.parentId==="")&&(c.parentId=null)}):(s.unshift({id:"__root__",parentId:null,name:"Root",value:void 0}),s.forEach(c=>{c.id!=="__root__"&&(!c.parentId||c.parentId==="")&&(c.parentId="__root__")})),o=zc().id(c=>c.id).parentId(c=>c.parentId)(s),o.sum(c=>c.children?0:c.value??0)}else o=Zi({children:this.prepareNestedData(i)}).sum(s=>s.children?0:s.value||0);return dd().size([e,1])(o),t!==0&&o.each(s=>{s.x0+=t,s.x1+=t}),o}prepareNestedData(t){return t.map(e=>{const i={...e,value:e.y??e.value??1};return i.children&&(i.children=this.prepareNestedData(i.children)),i})}getMaxDepth(t){let e=0;return t.each(i=>{i.depth>e&&(e=i.depth)}),e}computeRingWidths(t,e,i){const r=[],o=this.config.levelSize;for(let l=0;l<=e;l++){const h=i.find(f=>f.level===l);h!=null&&h.levelSize?r.push({value:h.levelSize.value,unit:h.levelSize.unit}):o!=null&&o.unit&&(o!=null&&o.value)?r.push({value:o.value,unit:o.unit}):r.push({value:1,unit:"weight"})}let s=t;const a=new Array(e+1).fill(0);for(let l=0;l<=e;l++)r[l].unit==="pixels"&&(a[l]=r[l].value,s-=a[l]);for(let l=0;l<=e;l++)r[l].unit==="percentage"&&(a[l]=r[l].value/100*t,s-=a[l]);let c=0;for(let l=0;l<=e;l++)r[l].unit==="weight"&&(c+=r[l].value);if(c>0&&s>0)for(let l=0;l<=e;l++)r[l].unit==="weight"&&(a[l]=r[l].value/c*s);return a}applyCustomRadii(t,e,i=!0){const r=[0];for(let s=0;s<e.length;s++)r.push(r[s]+e[s]);const o=i?0:t.depth;t.each(s=>{const a=s.depth-o;s._y0=r[a]||0,s._y1=r[a+1]||r[r.length-1]})}assignColors(t,e,i){var c;let r=0;t._color=t.data.color||"transparent";const s=((c=i.find(l=>l.colorByPoint))==null?void 0:c.level)??1,a=l=>{if(l.depth===0)l._color=l.data.color||"transparent";else if(l.data.color)l._color=l.data.color;else if(l.depth===s)l._color=e[r++%e.length];else if(l.depth>s&&l.parent){const h=i.find(d=>d.level===l.depth),f=h==null?void 0:h.colorVariation,u=ce(l.parent._color);if(u&&(f==null?void 0:f.key)==="brightness"){const d=l.parent.children||[],p=d.indexOf(l),y=d.length,g=y>1?p/(y-1)*f.to:f.to*.5,m=ci(u.toString());m.l=Math.max(.1,Math.min(.95,m.l+g*.3)),l._color=m.toString()}else if(u){const d=l.parent.children||[],p=d.indexOf(l),y=d.length,g=y>1?-.3+p/(y-1)*.6:0;l._color=u.brighter(g).toString()}else l._color=l.parent._color}else l.depth<s&&l.parent&&(l._color=l.parent._color!=="transparent"?l.parent._color:e[r++%e.length]);if(l.children)for(const h of l.children)a(h)};a(t)}renderLabels(t,e,i){var g;const o=this.config.dataLabels,s=(o==null?void 0:o.rotationMode)||"auto",a=(o==null?void 0:o.style)||{},c=a.fontSize||kt,l=a.textOutline,h=o==null?void 0:o.filter,f=m=>{var v,b;const x=i.find(k=>k.level===m.depth);return((b=(v=x==null?void 0:x.dataLabels)==null?void 0:v.style)==null?void 0:b.textOutline)||l},d=((g=i.find(m=>m.colorByPoint))==null?void 0:g.level)??1,p=m=>{let x=m;for(;x.depth>d&&x.parent;)x=x.parent;return x._color},y=m=>{var b,k;const x=i.find(M=>M.level===m.depth),v=((k=(b=x==null?void 0:x.dataLabels)==null?void 0:b.style)==null?void 0:k.color)||a.color;return gn(p(m),v)};t.selectAll(".katucharts-sunburst-label").data(e).join("text").attr("class","katucharts-sunburst-label").attr("transform",m=>{var I;const x=i.find(L=>L.level===m.depth),v=((I=x==null?void 0:x.dataLabels)==null?void 0:I.rotationMode)||s,b=(m.x0+m.x1)/2,k=(m._y0+m._y1)/2,M=b*180/Math.PI-90,C=b<Math.PI/2||b>Math.PI*3/2,E=b>Math.PI;if(v==="parallel")return`rotate(${M}) translate(${k},0) rotate(${C?90:-90})`;if(v==="perpendicular")return`rotate(${M}) translate(${k},0)${E?" rotate(180)":""}`;const _=m._y1*(m.x1-m.x0),T=m._y1-m._y0;return _>T*2?`rotate(${M}) translate(${k},0) rotate(${C?90:-90})`:`rotate(${M}) translate(${k},0)${E?" rotate(180)":""}`}).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",m=>{var v,b;const x=i.find(k=>k.level===m.depth);return((b=(v=x==null?void 0:x.dataLabels)==null?void 0:v.style)==null?void 0:b.fontSize)||c}).attr("font-weight","bold").attr("fill",m=>y(m)).style("paint-order","stroke fill").attr("stroke",m=>{const x=f(m);if(!x)return"none";const v=x.split(/\s+/);return v.length>=2?v.slice(1).join(" "):"white"}).attr("stroke-width",m=>{const x=f(m);return x&&parseFloat(x)||0}).attr("stroke-linejoin","round").style("pointer-events","none").each(function(m){var B,W,K,X,q;const x=st(this);x.selectAll("tspan").remove();const v=i.find(N=>N.level===m.depth);if(((B=v==null?void 0:v.dataLabels)==null?void 0:B.enabled)===!1)return;const b=((W=v==null?void 0:v.dataLabels)==null?void 0:W.filter)||h,k=m._y1*(m.x1-m.x0),M=m._y0*(m.x1-m.x0),C=m._y1-m._y0;if(b){const N=b.property==="outerArcLength"?k:b.property==="innerArcLength"?M:0;if(b.operator===">"&&N<=b.value||b.operator==="<"&&N>=b.value)return}else if(k<16)return;const E=m.data.name||"",_=((K=v==null?void 0:v.dataLabels)==null?void 0:K.rotationMode)||s,T=_==="parallel"||_==="auto"&&k>C*2,I=T?(k+M)/2:C,L=T?C:(k+M)/2,P=parseFloat(((q=(X=v==null?void 0:v.dataLabels)==null?void 0:X.style)==null?void 0:q.fontSize)||c)||11,A=P*.6,w=Math.max(3,Math.floor(I/A)),S=Math.max(1,Math.floor(L/(P*1.2)));if(E.length<=w){x.text(E);return}const $=E.split(/[\s_-]+/),R=[];let F="";for(const N of $){const H=F?F+" "+N:N;if(H.length<=w?F=H:(F&&R.push(F),F=N.length>w?N.substring(0,w-1)+"…":N),R.length>=S)break}if(F&&R.length<S&&R.push(F),R.length===0)return;if(R.length>S&&(R.length=S),R.length===S&&F&&!R[R.length-1].endsWith("…")&&$.slice(R.join(" ").split(/[\s]+/).length).length>0){const H=R[R.length-1];H.length+2>w&&(R[R.length-1]=H.substring(0,w-1)+"…")}const z=-(R.length*P*1.2-P*1.2)/2;R.forEach((N,H)=>{x.append("tspan").attr("x",0).attr("dy",H===0?`${z}px`:`${P*1.2}px`).text(N)})})}renderBreadcrumbs(t){const e=this.config.breadcrumbs||{},r=(e.style||{}).fontSize||"11px",o=e.separator??" / ",s=[];let a=this.currentRoot;for(;a;)s.unshift(a),a=a.parent;const c=this.group.append("g").attr("class","katucharts-sunburst-breadcrumbs").attr("transform","translate(0,-15)");let l=0;s.forEach((h,f)=>{var g,m,x;const u=((g=h.data)==null?void 0:g.name)||(f===0?"Root":`Level ${f}`),d=f===s.length-1,p=c.append("text").attr("x",l).attr("y",0).attr("font-size",r).attr("fill",d?"#999":"#2f7ed8").attr("dominant-baseline","middle").style("cursor",d?"default":"pointer").style("text-decoration",d?"none":"underline").text(u);d||p.on("click",()=>{this.currentRoot=h===t?null:h,this.group.selectAll("*").remove(),this.render()});const y=((x=(m=p.node())==null?void 0:m.getComputedTextLength)==null?void 0:x.call(m))||u.length*7;l+=y,d||(c.append("text").attr("x",l).attr("y",0).attr("font-size",r).attr("fill","#666").attr("dominant-baseline","middle").style("pointer-events","none").text(o),l+=o.length*5)})}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}resolveBorderRadius(t){return t===void 0?3:typeof t=="number"?t:t.radius??3}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class kk extends Xt{constructor(t){super(t)}render(){var Y,G,Q;const{plotArea:t}=this.context,e=this.context.animate,i=t.width/2,r=this.config.pane||{},o=r.startAngle??-90,s=r.endAngle??90,a=o*Math.PI/180,c=s*Math.PI/180,l=Math.abs(s-o)<=180,h=l?t.height*.62:t.height/2,f=l?Math.min(t.width/2,h)-20:Math.min(t.width,t.height)/2-20,u=((Y=this.config._yAxis??this.config.yAxis)==null?void 0:Y.min)??this.config.min??0,d=((G=this.config._yAxis??this.config.yAxis)==null?void 0:G.max)??this.config.max??100,p=((Q=this.data[0])==null?void 0:Q.y)??0,y=this.config.wrap!==!1,g=this.config.overshoot??0;let m=p;if(y){const O=d-u;O>0&&(m=u+((p-u)%O+O)%O)}const x=g*Math.PI/180;let b=ke().domain([u,d]).range([a,c]).clamp(!y&&g<=0)(m);if(!y&&g>0){const O=a-x,it=c+x;b=Math.max(O,Math.min(it,b))}const k=this.group.append("g").attr("transform",`translate(${i},${h})`);this.renderPaneBackground(k,f,a,c,r);const M=f*.15,C=Ce().innerRadius(f-M).outerRadius(f).startAngle(a).endAngle(c).cornerRadius(M/2);k.append("path").attr("d",C({})).attr("fill","#ddd"),this.renderPlotBands(k,f,a,c,u,d,M),this.renderTickMarks(k,f,a,c,u,d,M);const E=this.config.dial||{},_=this.config.pivot||{},T=E.backgroundColor||"#333",I=E.borderColor||"none",L=E.borderWidth??0,P=E.baseWidth??8,A=E.topWidth??1,w=this.resolvePercent(E.radius??"80%",f),S=this.resolvePercent(E.rearLength??"15%",f),$=b-Math.PI/2,R=w*Math.cos($),F=w*Math.sin($),D=-S*Math.cos($),z=-S*Math.sin($),B=$+Math.PI/2,W=P/2,K=A/2,X=[`M${D+W*Math.cos(B)},${z+W*Math.sin(B)}`,`L${R+K*Math.cos(B)},${F+K*Math.sin(B)}`,`L${R-K*Math.cos(B)},${F-K*Math.sin(B)}`,`L${D-W*Math.cos(B)},${z-W*Math.sin(B)}`,"Z"].join(" "),q=k.append("path").attr("fill",T).attr("stroke",I).attr("stroke-width",L).style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.3))").style("cursor","pointer");if(e){const O=this.buildNeedlePath(a,w,S,P,A);q.attr("d",O).transition().duration(bt).ease(pt).attrTween("d",()=>{const it=he(a,b);return et=>this.buildNeedlePath(it(et),w,S,P,A)})}else q.attr("d",X);if(this.config.enableMouseTracking!==!1){const O=L;q.on("mouseover",it=>{var et,ht,ft;q.interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",O+2),q.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.4))"),this.context.events.emit("point:mouseover",{point:this.data[0],index:0,series:this,event:it,plotX:i,plotY:h}),(ft=(ht=(et=this.data[0])==null?void 0:et.events)==null?void 0:ht.mouseOver)==null||ft.call(this.data[0],it)}).on("mouseout",it=>{var et,ht,ft;q.interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",O),q.style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.3))"),this.context.events.emit("point:mouseout",{point:this.data[0],index:0,series:this,event:it}),(ft=(ht=(et=this.data[0])==null?void 0:et.events)==null?void 0:ht.mouseOut)==null||ft.call(this.data[0],it)}).on("click",it=>{var et,ht,ft,ct,nt;this.context.events.emit("point:click",{point:this.data[0],index:0,series:this,event:it}),(ft=(ht=(et=this.data[0])==null?void 0:et.events)==null?void 0:ht.click)==null||ft.call(this.data[0],it),(nt=(ct=this.config.events)==null?void 0:ct.click)==null||nt.call(this,it)})}const N=_.radius??10,H=_.borderWidth??2;k.append("circle").attr("r",N).attr("fill",_.backgroundColor||"#666").attr("stroke",_.borderColor||"#fff").attr("stroke-width",H).style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.2))"),this.renderValueLabel(k,f,p),e&&this.emitAfterAnimate(bt+100)}buildNeedlePath(t,e,i,r,o){const s=t-Math.PI/2,a=e*Math.cos(s),c=e*Math.sin(s),l=-i*Math.cos(s),h=-i*Math.sin(s),f=s+Math.PI/2,u=r/2,d=o/2;return[`M${l+u*Math.cos(f)},${h+u*Math.sin(f)}`,`L${a+d*Math.cos(f)},${c+d*Math.sin(f)}`,`L${a-d*Math.cos(f)},${c-d*Math.sin(f)}`,`L${l-u*Math.cos(f)},${h-u*Math.sin(f)}`,"Z"].join(" ")}renderPaneBackground(t,e,i,r,o){const s=o.background?Array.isArray(o.background)?o.background:[o.background]:[];for(const a of s){const c=this.resolvePercent(a.outerRadius??"100%",e),l=this.resolvePercent(a.innerRadius??"0%",e),h=Ce().innerRadius(l).outerRadius(c).startAngle(i).endAngle(r);t.append("path").attr("d",h({})).attr("fill",a.backgroundColor||"#f2f2f2").attr("stroke",a.borderColor||"#cccccc").attr("stroke-width",a.borderWidth??0)}}renderPlotBands(t,e,i,r,o,s,a){var f;const c=((f=this.config._yAxis??this.config.yAxis)==null?void 0:f.plotBands)||[];if(c.length===0)return;const l=a??e*.15,h=ke().domain([o,s]).range([i,r]);for(const u of c){if(u.from===void 0||u.to===void 0)continue;const d=Ce().innerRadius(e-l).outerRadius(e).startAngle(h(u.from)).endAngle(h(u.to)).cornerRadius(0);t.append("path").attr("d",d({})).attr("fill",u.color||"#e0e0e0").attr("stroke",u.borderColor||"none").attr("stroke-width",u.borderWidth??0)}}renderTickMarks(t,e,i,r,o,s,a){var v,b;const c=(this.config._yAxis??this.config.yAxis)||{},l=c.tickPositions||this.generateTicks(o,s,5),h=c.tickLength??15,f=c.tickWidth??2,u=((v=c.labels)==null?void 0:v.enabled)!==!1,d=((b=c.labels)==null?void 0:b.style)||{},p=d.fontSize||kt,y=d.color||this.autoLabelColor(),g=a??e*.15,m=ke().domain([o,s]).range([i,r]),x=c.minorTickInterval?Math.round((s-o)/c.minorTickInterval):0;if(x>0&&c.minorTickInterval)for(let k=0;k<=x;k++){const M=o+k*c.minorTickInterval;if(M>s)break;const C=m(M)-Math.PI/2,E=e-g+2,_=E-6;t.append("line").attr("x1",_*Math.cos(C)).attr("y1",_*Math.sin(C)).attr("x2",E*Math.cos(C)).attr("y2",E*Math.sin(C)).attr("stroke","#999").attr("stroke-width",1)}for(const k of l){const M=m(k)-Math.PI/2,C=e-g+2,E=C-h;if(t.append("line").attr("x1",E*Math.cos(M)).attr("y1",E*Math.sin(M)).attr("x2",C*Math.cos(M)).attr("y2",C*Math.sin(M)).attr("stroke","#333").attr("stroke-width",f),u){const _=E-10;t.append("text").attr("x",_*Math.cos(M)).attr("y",_*Math.sin(M)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",p).attr("font-weight","600").attr("fill",y).style("pointer-events","none").text(String(k))}}}generateTicks(t,e,i){const r=(e-t)/i,o=[];for(let s=0;s<=i;s++)o.push(Math.round((t+r*s)*100)/100);return o}renderValueLabel(t,e,i){var l,h,f,u;const r=this.config.dataLabels||{};if(!(r.enabled!==!1))return;const s=((l=r.style)==null?void 0:l.fontSize)||kt,a=r.color||((h=r.style)==null?void 0:h.color)||this.autoLabelColor();let c;r.formatter?c=r.formatter.call({point:this.data[0],series:{name:this.config.name},x:(f=this.data[0])==null?void 0:f.x,y:i}):r.format?c=oe(Kt(r.format,{point:this.data[0],series:{name:this.config.name},x:(u=this.data[0])==null?void 0:u.x,y:i})):c=i.toString(),t.append("text").attr("y",e*.25+(r.y??0)).attr("x",r.x??0).attr("text-anchor","middle").attr("font-size",s).attr("font-weight","bold").attr("fill",a).text(c)}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class Mk extends Xt{constructor(t){super(t)}render(){var k,M,C,E;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=Math.min(t.width,t.height)/2-10,o=t.width/2,s=t.height/2,a=((k=this.config._yAxis??this.config.yAxis)==null?void 0:k.min)??this.config.min??0,c=((M=this.config._yAxis??this.config.yAxis)==null?void 0:M.max)??this.config.max??100,l=this.data.length>1,h=this.config.pane||{},f=(h.startAngle??-135)*Math.PI/180,u=(h.endAngle??135)*Math.PI/180,d=this.config.overshoot??0,p=d*Math.PI/180,y=this.group.append("g").attr("transform",`translate(${o},${s})`),g=this.config.innerRadius??.6,m=this.config.radius??1,x=this.config.rounded??5,v=this.config.linecap||"round",b=((C=this.config._yAxis??this.config.yAxis)==null?void 0:C.stops)||[];if(l){const _=r/(this.data.length+.5),T=_*.1;this.renderPaneBackground(y,r,0,f,u,h),this.data.forEach((I,L)=>{const P=I.radius?this.resolveRadiusValue(I.radius,r):r-L*_,A=I.innerRadius?this.resolveRadiusValue(I.innerRadius,r):P-_+T,w=I.color||e[L%e.length],S=this.config.color;this.config.color=w,this.renderSingleArc(y,I,L,A,P,r,f,u,a,c,d,p,x,v,b,o,s,i),this.config.color=S})}else{const _=this.resolveRadiusValue(g,r),T=this.resolveRadiusValue(m,r);this.renderPaneBackground(y,T,_,f,u,h),this.renderPlotBands(y,T,_,f,u,a,c),this.renderSingleArc(y,this.data[0],0,_,T,r,f,u,a,c,d,p,x,v,b,o,s,i)}this.renderTickMarks(y,r,f,u,a,c),l||this.renderValueLabel(y,((E=this.data[0])==null?void 0:E.y)??0),i&&this.emitAfterAnimate(bt+100)}renderSingleArc(t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g,m,x){const v=(e==null?void 0:e.y)??0,b=Math.max(0,Math.min(1,(v-l)/(h-l)));let k=a+(c-a)*b;if(f>0&&v>h){const P=(v-h)/(h-l);k=c+Math.min(u,(c-a)*P)}const M=p==="round",C=Ce().innerRadius(r).outerRadius(o).startAngle(a).endAngle(c).cornerRadius(M?(o-r)/2:d);t.append("path").attr("d",C({})).attr("fill","#e0e0e0");const E=M?(o-r)/2:d,_=Ce().innerRadius(r).outerRadius(o).cornerRadius(E),T=Ce().innerRadius(r).outerRadius(o+5).cornerRadius(E),I=this.resolveArcColor(b,y,e),L=t.append("path").attr("fill",I).style("cursor","pointer");if(x){const P=he(a,k),A=this;L.transition().duration(bt).ease(pt).attrTween("d",()=>w=>{const S=P(w),$=_.startAngle(a).endAngle(S)({});if(y.length>0){const R=(S-a)/(c-a);L.attr("fill",A.getStopColor(Math.min(1,R),y))}return $})}else L.attr("d",_.startAngle(a).endAngle(k)({}));this.config.enableMouseTracking!==!1&&L.on("mouseover",P=>{var A,w;L.interrupt("hover").transition("hover").duration(Z).ease(j).attr("d",T.startAngle(a).endAngle(k)({})),L.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.25))"),this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:P,plotX:g,plotY:m}),(w=(A=e==null?void 0:e.events)==null?void 0:A.mouseOver)==null||w.call(e,P)}).on("mouseout",P=>{var A,w;L.interrupt("hover").transition("hover").duration(Z).ease(j).attr("d",_.startAngle(a).endAngle(k)({})),L.style("filter",""),this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:P}),(w=(A=e==null?void 0:e.events)==null?void 0:A.mouseOut)==null||w.call(e,P)}).on("click",P=>{var A,w,S,$;this.context.events.emit("point:click",{point:e,index:i,series:this,event:P}),(w=(A=e==null?void 0:e.events)==null?void 0:A.click)==null||w.call(e,P),($=(S=this.config.events)==null?void 0:S.click)==null||$.call(this,P)})}resolveArcColor(t,e,i){return i!=null&&i.color?i.color:e.length>=2?this.getStopColor(t,e):this.getColor()}getStopColor(t,e){if(t<=e[0][0])return e[0][1];if(t>=e[e.length-1][0])return e[e.length-1][1];for(let i=0;i<e.length-1;i++)if(t>=e[i][0]&&t<=e[i+1][0]){const r=(t-e[i][0])/(e[i+1][0]-e[i][0]),o=e[i][1],s=e[i+1][1];return he(o,s)(r)}return e[e.length-1][1]}resolveRadiusValue(t,e){return typeof t=="string"&&t.endsWith("%")?e*parseFloat(t)/100:typeof t=="number"?t<=1?e*t:t:e*.6}renderPaneBackground(t,e,i,r,o,s){const a=s.background?Array.isArray(s.background)?s.background:[s.background]:[];for(const c of a){const l=this.resolvePercent(c.outerRadius??"100%",e),h=this.resolvePercent(c.innerRadius??"0%",e),f=Ce().innerRadius(h).outerRadius(l).startAngle(r).endAngle(o);t.append("path").attr("d",f({})).attr("fill",c.backgroundColor||"#f2f2f2").attr("stroke",c.borderColor||"#cccccc").attr("stroke-width",c.borderWidth??0)}}renderPlotBands(t,e,i,r,o,s,a){var h;const c=((h=this.config._yAxis??this.config.yAxis)==null?void 0:h.plotBands)||[];if(c.length===0)return;const l=ke().domain([s,a]).range([r,o]);for(const f of c){if(f.from===void 0||f.to===void 0)continue;const u=Ce().innerRadius(i).outerRadius(e).startAngle(l(f.from)).endAngle(l(f.to));t.append("path").attr("d",u({})).attr("fill",f.color||"#e0e0e0").attr("stroke",f.borderColor||"none").attr("stroke-width",f.borderWidth??0)}}renderTickMarks(t,e,i,r,o,s){var p,y;const a=(this.config._yAxis??this.config.yAxis)||{},c=a.tickPositions||this.generateTicks(o,s,5),l=((p=a.labels)==null?void 0:p.enabled)!==!1,h=((y=a.labels)==null?void 0:y.style)||{},f=h.fontSize||kt,u=h.color||this.autoLabelColor(),d=ke().domain([o,s]).range([i,r]);for(const g of c){const m=d(g)-Math.PI/2;if(l){const x=e+14;t.append("text").attr("x",x*Math.cos(m)).attr("y",x*Math.sin(m)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",f).attr("fill",u).style("pointer-events","none").text(String(g))}}}generateTicks(t,e,i){const r=(e-t)/i,o=[];for(let s=0;s<=i;s++)o.push(Math.round((t+r*s)*100)/100);return o}renderValueLabel(t,e){var c,l,h,f;const i=this.config.dataLabels||{};if(!(i.enabled!==!1))return;const o=((c=i.style)==null?void 0:c.fontSize)||kt,s=i.color||((l=i.style)==null?void 0:l.color)||this.autoLabelColor();let a;i.formatter?a=i.formatter.call({point:this.data[0],series:{name:this.config.name},x:(h=this.data[0])==null?void 0:h.x,y:e}):i.format?a=oe(Kt(i.format,{point:this.data[0],series:{name:this.config.name},x:(f=this.data[0])==null?void 0:f.x,y:e})):a=e.toString(),t.append("text").attr("y",10+(i.y??0)).attr("x",i.x??0).attr("text-anchor","middle").attr("font-size",o).attr("font-weight","bold").attr("fill",s).text(a)}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const Ak=gr("~s");function Sk(n){return n===0?"0":n>=1e3?Ak(n).replace("G","B"):String(n)}function _k(n){return!Number.isFinite(n)||Math.abs(n)<1e3?String(n):Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function md(n){if(n<=0)return{ticks:[1],niceMax:1,gridMax:1};const t=n/2,e=Math.pow(10,Math.floor(Math.log10(t))),i=t/e;let r;i<1.5?r=1*e:i<3?r=2*e:i<7?r=5*e:r=10*e;const o=Math.max(r,Math.floor(n/r)*r),s=n*1.15;return{ticks:o>0?[Math.round(o*1e6)/1e6]:[],niceMax:o,gridMax:s}}function yd(n,t,e){const i=e==null?void 0:e.size;let r;typeof i=="string"&&i.trim().endsWith("%")?r=parseFloat(i)/100:typeof i=="number"?r=i>1?i/100:i:r=.85;const o=Math.min(n,t)*r/2;return Math.max(20,o-30)}class xd extends Xt{constructor(t){super(t)}render(){const t=this.resolvePolarSubType();t==="column"?this.renderColumnPolar():this.renderLineAreaPolar(t)}resolvePolarSubType(){const t=this.config.polarType||this.config._polarSubType||"area";return t==="column"||t==="bar"?"column":t==="line"?"line":"area"}renderLineAreaPolar(t){var L,P,A,w,S,$,R,F,D,z;const{plotArea:e}=this.context,i=this.context.animate,r=this.data,o=this.getColor(),s=this.context.pane||this.config.pane,a=yd(e.width,e.height,s),c=e.width/2,l=e.height/2,h=Math.max(...r.map(B=>B.y??0),1),{ticks:f,gridMax:u}=md(h),d=ke().domain([0,u]).range([0,a]),p=((L=this.config.marker)==null?void 0:L.radius)??4,y=((P=this.config.marker)==null?void 0:P.enabled)!==!1,g=this.config.pointPlacement,m=g==="on"?0:g==="between"?Math.PI/r.length:typeof g=="number"?g*Math.PI/180:0,x=2*Math.PI/r.length,v=this.config.connectEnds!==!1;(w=(A=this.config.states)==null?void 0:A.inactive)==null||w.opacity;const b=this.group.append("g").attr("transform",`translate(${c},${l})`);let k=0,M=1/0;for(let B=0;B<r.length;B++){const W=r[B].y??0;W<M&&(M=W,k=B)}const C=k*x-Math.PI/2;this.renderGrid(b,a,r.length,d,f,C);const E=v?N2:ji,_=E2().angle((B,W)=>W*x+m).radius(B=>d(B.y??0)).defined(B=>B.y!==null&&B.y!==void 0).curve(E),T=r.map(B=>({...B,y:0})),I=b.append("path").datum(r).attr("fill","none").attr("stroke",o).attr("stroke-width",this.config.lineWidth??2);if(t==="area"){const B=T2().angle((K,X)=>X*x+m).innerRadius(0).outerRadius(K=>d(K.y??0)).defined(K=>K.y!==null&&K.y!==void 0).curve(E),W=b.append("path").datum(r).attr("fill",ti(this.config.fillColor,b,o)).attr("fill-opacity",this.config.fillOpacity??.3);i?W.attr("d",B(T)||"").transition().duration(bt).ease(pt).attr("d",B(r)||""):W.attr("d",B)}if(i?I.attr("d",_(T)||"").transition().duration(bt).ease(pt).attr("d",_(r)||""):I.attr("d",_),y){const W=Math.max(...r.map(X=>X.y??0),1)*.02,K=b.selectAll(".katucharts-polar-point").data(r).join("circle").attr("class","katucharts-polar-point").attr("cx",(X,q)=>d(X.y??0)*Math.cos(q*x-Math.PI/2+m)).attr("cy",(X,q)=>d(X.y??0)*Math.sin(q*x-Math.PI/2+m)).attr("fill",((S=this.config.marker)==null?void 0:S.fillColor)||o).attr("stroke",(($=this.config.marker)==null?void 0:$.lineColor)||this.autoBorderColor()).attr("stroke-width",((R=this.config.marker)==null?void 0:R.lineWidth)??1).style("display",X=>(X.y??0)<W?"none":null).style("cursor",this.config.cursor||"pointer");if(i?K.attr("r",0).attr("opacity",0).transition().duration(bt).ease(pt).delay((X,q)=>q*Nt).attr("r",p).attr("opacity",1):K.attr("r",p),this.renderPolarDataLabels(b,r,d,x,m),this.config.enableMouseTracking!==!1){const X=((z=(D=(F=this.config.marker)==null?void 0:F.states)==null?void 0:D.hover)==null?void 0:z.radius)??p+3;K.on("mouseover",(q,N)=>{var O,it;const H=st(q.currentTarget);H.transition("hover").duration(Z).ease(j).attr("r",X),H.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))");const Y=r.indexOf(N),G=d(N.y??0)*Math.cos(Y*x-Math.PI/2+m),Q=d(N.y??0)*Math.sin(Y*x-Math.PI/2+m);this.context.events.emit("point:mouseover",{point:N,index:Y,series:this,event:q,plotX:c+G,plotY:l+Q}),(it=(O=N.events)==null?void 0:O.mouseOver)==null||it.call(N,q)}).on("mouseout",(q,N)=>{var G,Q;const H=st(q.currentTarget);H.transition("hover").duration(Z).ease(j).attr("r",p),H.style("filter","");const Y=r.indexOf(N);this.context.events.emit("point:mouseout",{point:N,index:Y,series:this,event:q}),(Q=(G=N.events)==null?void 0:G.mouseOut)==null||Q.call(N,q)}).on("click",(q,N)=>{var Y,G,Q,O;const H=r.indexOf(N);this.context.events.emit("point:click",{point:N,index:H,series:this,event:q}),(G=(Y=N.events)==null?void 0:Y.click)==null||G.call(N,q),(O=(Q=this.config.events)==null?void 0:Q.click)==null||O.call(this,q)})}}}renderColumnPolar(){var L,P;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=this.getColor(),s=this.context.pane||this.config.pane,a=yd(t.width,t.height,s),c=t.width/2,l=t.height/2,h=Math.max(...r.map(A=>A.y??0),1),{ticks:f,gridMax:u}=md(h),d=ke().domain([0,u]).range([0,a]),p=2*Math.PI/r.length,y=this.config.pointPlacement,g=y==="on"?0:y==="between"?Math.PI/r.length:typeof y=="number"?y*Math.PI/180:0,m=.02,x=((P=(L=this.config.states)==null?void 0:L.inactive)==null?void 0:P.opacity)??.4,v=this.config.colorByPoint===!0,b=this.config.stacking,k=this.group.append("g").attr("transform",`translate(${c},${l})`);let M=0,C=1/0;for(let A=0;A<r.length;A++){const w=r[A].y??0;w<C&&(C=w,M=A)}const E=M*p-Math.PI/2;this.renderGrid(k,a,r.length,d,f,E);const _=Ce().cornerRadius(2),T=k.selectAll(".katucharts-polar-bar").data(r).join("path").attr("class","katucharts-polar-bar").attr("fill",(A,w)=>A.color||(v?e[w%e.length]:o)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).style("cursor",this.config.cursor||"pointer"),I=this.context.stackOffsets;i?T.each(function(A,w){const S=st(this),$=w*p-Math.PI/2+g+m,R=(w+1)*p-Math.PI/2+g-m,F=b&&I?d(I.get(w)??0):0,D=F+d(A.y??0);S.attr("d",_({innerRadius:F,outerRadius:F,startAngle:$+Math.PI/2,endAngle:R+Math.PI/2})||"").transition().duration(bt).ease(pt).delay(w*Nt).attrTween("d",()=>z=>_({innerRadius:F,outerRadius:F+(D-F)*z,startAngle:$+Math.PI/2,endAngle:R+Math.PI/2})||""),b&&I&&I.set(w,(I.get(w)??0)+(A.y??0))}):T.attr("d",(A,w)=>{const S=w*p-Math.PI/2+g+m,$=(w+1)*p-Math.PI/2+g-m,R=b&&I?d(I.get(w)??0):0,F=R+d(A.y??0);return b&&I&&I.set(w,(I.get(w)??0)+(A.y??0)),_({innerRadius:R,outerRadius:F,startAngle:S+Math.PI/2,endAngle:$+Math.PI/2})||""}),this.config.enableMouseTracking!==!1&&T.on("mouseover",(A,w)=>{var D,z;st(A.currentTarget).style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),T.interrupt("highlight"),T.attr("opacity",1),T.filter(B=>B!==w).transition("highlight").duration(Z).ease(j).attr("opacity",x);const $=r.indexOf(w),R=$*p+p/2-Math.PI/2+g,F=d(w.y??0)/2;this.context.events.emit("point:mouseover",{point:w,index:$,series:this,event:A,plotX:c+F*Math.cos(R),plotY:l+F*Math.sin(R)}),(z=(D=w.events)==null?void 0:D.mouseOver)==null||z.call(w,A)}).on("mouseout",(A,w)=>{var R,F;st(A.currentTarget).style("filter",""),T.interrupt("highlight"),T.transition("highlight").duration(Z).ease(j).attr("opacity",1);const $=r.indexOf(w);this.context.events.emit("point:mouseout",{point:w,index:$,series:this,event:A}),(F=(R=w.events)==null?void 0:R.mouseOut)==null||F.call(w,A)}).on("click",(A,w)=>{var $,R,F,D;const S=r.indexOf(w);this.context.events.emit("point:click",{point:w,index:S,series:this,event:A}),(R=($=w.events)==null?void 0:$.click)==null||R.call(w,A),(D=(F=this.config.events)==null?void 0:F.click)==null||D.call(this,A)})}renderPolarDataLabels(t,e,i,r,o){var k,M,C;const s=this.config.dataLabels||{};if(s.enabled!==!0)return;const a=((k=s.style)==null?void 0:k.fontSize)||kt,c=((M=s.style)==null?void 0:M.color)||this.autoLabelColor(),l=((C=s.style)==null?void 0:C.fontWeight)||"normal",h=[],f=16,u=6,d=Math.max(...e.map(E=>E.y??0),1),p=d*.02,y=d*.5,g=e.map((E,_)=>({d:E,i:_,v:E.y??0})).filter(E=>E.d.y!=null&&E.d.y!==0&&E.v>=p),m=g.filter(E=>E.v>=y),x=g.filter(E=>E.v<y);x.sort((E,_)=>_.v-E.v);const v=x.length>0?x[0]:null,b=v?[...m,v]:m;b.sort((E,_)=>E.i-_.i);for(const{d:E,i:_}of b){const T=_*r-Math.PI/2+o,I=i(E.y??0),L=I*Math.cos(T),P=I*Math.sin(T),A=((T+Math.PI/2)*180/Math.PI+360)%360;let w;A>20&&A<160?w="start":A>200&&A<340?w="end":w="middle";let S;A<45||A>315?S="text-after-edge":A>135&&A<225?S="text-before-edge":S="middle";const $=Math.cos(T),R=Math.sin(T),F=L+$*u,D=P+R*u;let z=!1;for(const B of h)if((B.x-F)**2+(B.y-D)**2<f*f){z=!0;break}z||(h.push({x:F,y:D}),t.append("text").attr("class","katucharts-polar-datalabel").attr("x",F).attr("y",D).attr("text-anchor",w).attr("dominant-baseline",S).attr("fill",c).attr("font-size",a).attr("font-weight",l).attr("stroke",this.labelHaloColor()).attr("stroke-width",3).attr("stroke-linejoin","round").attr("paint-order","stroke fill").style("pointer-events","none").text(_k(E.y)))}}renderGrid(t,e,i,r,o,s=-Math.PI/2){var h,f,u,d;const c=(this.config.gridLineInterpolation||((h=this.config._yAxis??this.config.yAxis)==null?void 0:h.gridLineInterpolation)||"circle")==="polygon",l=2*Math.PI/i;if(c){const p=[];for(let y=0;y<i;y++){const g=y*l-Math.PI/2;p.push(`${e*Math.cos(g)},${e*Math.sin(g)}`)}t.append("polygon").attr("points",p.join(" ")).attr("fill","none").attr("stroke","#d0d0d0").attr("stroke-width",.8)}else t.append("circle").attr("r",e).attr("fill","none").attr("stroke","#d0d0d0").attr("stroke-width",.8);for(const p of o){const y=r(p);if(c){const x=[];for(let v=0;v<i;v++){const b=v*l-Math.PI/2,k=y*Math.cos(b),M=y*Math.sin(b);x.push(`${k},${M}`)}t.append("polygon").attr("points",x.join(" ")).attr("fill","none").attr("stroke","#e6e6e6").attr("stroke-width",.5)}else t.append("circle").attr("r",y).attr("fill","none").attr("stroke","#e6e6e6").attr("stroke-width",.5);const g=y*Math.cos(s)+5*Math.cos(s+Math.PI/2),m=y*Math.sin(s)+5*Math.sin(s+Math.PI/2);t.append("text").attr("x",g).attr("y",m).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",kt).attr("fill",this.autoLabelColor()).attr("stroke",this.labelHaloColor()).attr("stroke-width",3).attr("stroke-linejoin","round").attr("paint-order","stroke fill").style("pointer-events","none").text(Sk(p))}for(let p=0;p<i;p++){const y=p*l-Math.PI/2;t.append("line").attr("x1",0).attr("y1",0).attr("x2",e*Math.cos(y)).attr("y2",e*Math.sin(y)).attr("stroke","#ccc").attr("stroke-width",.5);const g=(u=(f=this.context.xAxis)==null?void 0:f.config)==null?void 0:u.categories,m=g&&g[p]||((d=this.data[p])==null?void 0:d.name)||`${p}`,x=e+28;t.append("text").attr("x",x*Math.cos(y)).attr("y",x*Math.sin(y)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",kt).attr("fill",this.autoLabelColor()).text(m)}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const bd={circle:bn,square:ps,diamond:ds,triangle:gs,"triangle-down":ms,cross:fs};class Ck extends Xt{constructor(t){super(t),this.nodes=[],this.applyDescriptionTooltipDefault()}applyDescriptionTooltipDefault(){if(!this.data.some(i=>i.description!=null&&i.description!==""))return;const e=this.config.tooltip;e!=null&&e.pointFormat||e!=null&&e.pointFormatter||e!=null&&e.formatter||(this.config.tooltip={...e,pointFormat:"{point.description}"})}render(){const t=this.data;if(!t.length)return;const e=!!this.context.inverted;this.nodes=this.layoutNodes(e),this.renderBaseline(e),this.nodes.forEach(i=>this.renderNode(i,e)),this.context.animate&&this.emitAfterAnimate(bt+t.length*Nt)}layoutNodes(t){var u;const{plotArea:e,colors:i}=this.context,r=this.config,o=this.data,s=o.length,a=r.colorByPoint!==!1,c=((u=this.config.dataLabels)==null?void 0:u.alternate)!==!1,l=this.config.marker||{},h=t?28:52,f=Math.max(1,(t?e.height:e.width)-h*2);return o.map((d,p)=>{var k,M;const y=s===1?.5:p/(s-1),g=h+y*f,m=t?e.width/2:g,x=t?g:e.height/2,v=c?p%2===0?-1:1:t?1:-1,b=d.color||(a?i[p%i.length]:this.getColor());return{point:d,index:p,cx:m,cy:x,side:v,radius:((k=d.marker)==null?void 0:k.radius)??l.radius??6,symbol:((M=d.marker)==null?void 0:M.symbol)??l.symbol??"circle",color:b,group:null,marker:null}})}renderBaseline(t){if(this.nodes.length<2)return;const e=this.config,i=this.nodes[0],r=this.nodes[this.nodes.length-1],o=e.lineWidth??4,s=e.lineColor??"rgba(140,140,140,0.5)",a=this.group.append("line").attr("class","katucharts-timeline-baseline").attr("x1",i.cx).attr("y1",i.cy).attr("stroke",s).attr("stroke-width",o).attr("stroke-linecap","round"),c=t?i.cx:r.cx,l=t?r.cy:i.cy;this.context.animate?a.attr("x2",i.cx).attr("y2",i.cy).transition().duration(bt).ease(pt).attr("x2",c).attr("y2",l):a.attr("x2",c).attr("y2",l)}renderNode(t,e){const i=this.group.append("g").attr("class","katucharts-timeline-node");t.group=i,this.renderMarker(i,t);const r=this.renderLabel(i,t,e);this.renderConnector(i,t,e,r),this.attachNodeEvents(t),this.context.animate&&i.attr("opacity",0).transition().duration(bt).ease(pt).delay(t.index*Nt).attr("opacity",1)}renderMarker(t,e){var a,c;const i=this.config.marker||{},r=((a=e.point.marker)==null?void 0:a.lineColor)??i.lineColor??this.autoBorderColor(),o=((c=e.point.marker)==null?void 0:c.lineWidth)??i.lineWidth??1,s=this.context.animate;if(e.symbol==="circle"){const l=t.append("circle").attr("class","katucharts-timeline-marker").attr("cx",e.cx).attr("cy",e.cy).attr("fill",e.color).attr("stroke",r).attr("stroke-width",o);s?l.attr("r",0).transition().duration(bt).ease(pt).delay(e.index*Nt).attr("r",e.radius):l.attr("r",e.radius),e.marker=l}else{const l=bd[e.symbol]||bn;e.marker=t.append("path").attr("class","katucharts-timeline-marker").attr("transform",`translate(${e.cx},${e.cy})`).attr("fill",e.color).attr("stroke",r).attr("stroke-width",o).attr("d",Ve().type(l).size(Math.PI*e.radius*e.radius)())}}renderConnector(t,e,i,r){const o=this.config.dataLabels||{},s=o.connectorWidth??1,a=o.connectorColor??e.color,c=e.radius+(o.distance??22),l=t.append("line").attr("class","katucharts-timeline-connector").attr("stroke",a).attr("stroke-width",s);if(i){const h=e.cx+e.side*e.radius,f=r?e.side>0?r.x:r.x+r.width:e.cx+e.side*c;if(e.side>0?f<=h:f>=h)return;l.attr("y1",e.cy).attr("y2",e.cy).attr("x1",h).attr("x2",f)}else{const h=e.cy+e.side*e.radius,f=r?e.side<0?r.y+r.height:r.y:e.cy+e.side*c;if(e.side<0?f>=h:f<=h)return;l.attr("x1",e.cx).attr("x2",e.cx).attr("y1",h).attr("y2",f)}}renderLabel(t,e,i){const r=this.config.dataLabels||{};if(r.enabled===!1)return null;const o=this.buildLabelLines(e.point,e.index);if(!o.length)return null;const s=r.style||{},a=me(s.fontSize||kt),c=a*1.28,l=r.color||s.color||this.autoLabelColor(),h=e.radius+(r.distance??22),f=i?e.cx+e.side*h:e.cx,u=i?e.cy:e.cy+e.side*h,d=i?e.side>0?"start":"end":"middle",p=t.append("text").attr("class","katucharts-timeline-label").attr("text-anchor",d).style("font-size",`${a}px`).style("fill",l),y=o.length;return o.forEach((g,m)=>{const x=this.labelLineY(u,m,y,c,e.side,i,e.cy);p.append("tspan").attr("x",f).attr("y",x).attr("dominant-baseline","middle").style("font-weight",g.bold?"bold":"normal").text(g.text)}),this.renderLabelBox(t,p,e,r)}labelLineY(t,e,i,r,o,s,a){return s?a-(i-1)/2*r+e*r:o<0?t-(i-1-e)*r:t+e*r}renderLabelBox(t,e,i,r){var f,u;const o=(u=(f=e.node()).getBBox)==null?void 0:u.call(f);if(!o||!o.width)return null;const s=r.borderWidth??1.5,a=r.backgroundColor??"none";if(!s&&a==="none")return{x:o.x,y:o.y,width:o.width,height:o.height};const c=r.padding??5,l=!r.borderColor||r.borderColor==="auto"?i.color:r.borderColor,h={x:o.x-c,y:o.y-c,width:o.width+c*2,height:o.height+c*2};return t.insert("rect",".katucharts-timeline-label").attr("x",h.x).attr("y",h.y).attr("width",h.width).attr("height",h.height).attr("rx",r.borderRadius??3).attr("fill",a).attr("stroke",l).attr("stroke-width",s),h}buildLabelLines(t,e){const i=this.config.dataLabels||{};let r=null;if(i.formatter?r=i.formatter.call({point:{...t,index:e},series:this,x:t.x??e,y:t.y}):i.format&&(r=Kt(i.format,{point:t,series:{name:this.config.name??""},x:t.x,y:t.y})),r==null){const o=[];return t.name!=null&&o.push({text:String(t.name),bold:!0}),t.label!=null&&o.push({text:String(t.label),bold:!1}),o.length||o.push({text:`Event ${e+1}`,bold:!0}),o}return String(r).split(/<br\s*\/?>/i).map(o=>oe(o)).filter(o=>o.length>0).map((o,s)=>({text:o,bold:s===0}))}attachNodeEvents(t){var r;if(this.config.enableMouseTracking===!1)return;const e=t.point.events||{},i=((r=this.config.point)==null?void 0:r.events)||{};t.group.style("cursor",this.config.cursor||"pointer").on("mouseover",o=>{var s,a;this.bumpMarker(t,t.radius+3),t.group.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),this.dimOthers(t),this.context.events.emit("point:mouseover",{point:t.point,index:t.index,series:this,event:o,plotX:t.cx,plotY:t.cy}),(s=e.mouseOver)==null||s.call(t.point,o),(a=i.mouseOver)==null||a.call(t.point,o)}).on("mouseout",o=>{var s,a;this.bumpMarker(t,t.radius),t.group.style("filter",""),this.restoreOpacity(),this.context.events.emit("point:mouseout",{point:t.point,index:t.index,series:this,event:o}),(s=e.mouseOut)==null||s.call(t.point,o),(a=i.mouseOut)==null||a.call(t.point,o)}).on("click",o=>{var s,a,c,l;this.context.events.emit("point:click",{point:t.point,index:t.index,series:this,event:o}),(s=e.click)==null||s.call(t.point,o),(a=i.click)==null||a.call(t.point,o),(l=(c=this.config.events)==null?void 0:c.click)==null||l.call(this,o)})}bumpMarker(t,e){if(!t.marker)return;const i=t.marker.interrupt("size").transition("size").duration(Z).ease(j);if(t.symbol==="circle")i.attr("r",e);else{const r=bd[t.symbol]||bn;i.attr("d",Ve().type(r).size(Math.PI*e*e)())}}dimOthers(t){this.nodes.forEach(e=>{e.group.interrupt("dim"),e===t?e.group.attr("opacity",1):e.group.transition("dim").duration(Z).ease(j).attr("opacity",.4)})}restoreOpacity(){this.nodes.forEach(t=>{t.group.interrupt("dim"),t.group.transition("dim").duration(Z).ease(j).attr("opacity",1)})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class Pk extends Xt{constructor(t){super(t)}render(){const{xAxis:t,plotArea:e,colors:i}=this.context,r=this.data,o=Math.min(25,e.height/Math.max(r.length,1)*.7),s=e.height/Math.max(r.length,1);r.forEach((a,c)=>{const l=a.start??a.x??0,h=a.end??l+1,f=t.getPixelForValue(l),u=t.getPixelForValue(h),d=c*s+(s-o)/2,p=a.color||i[c%i.length],y=this.group.append("rect").attr("class","katucharts-gantt-bar").attr("x",f).attr("y",d).attr("width",Math.max(1,u-f)).attr("height",o).attr("rx",3).attr("fill",p).attr("stroke","none");this.group.append("text").attr("x",f+4).attr("y",d+o/2).attr("dy","0.35em").attr("font-size","10px").attr("fill","#fff").text(a.name||""),y.style("cursor","pointer"),y.on("mouseover",g=>{y.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),y.interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke","#333").attr("stroke-width",1.5),this.context.events.emit("point:mouseover",{point:a,index:c,series:this,event:g,plotX:(f+u)/2,plotY:d+o/2})}).on("mouseout",g=>{y.style("filter",""),y.interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke","none").attr("stroke-width",0),this.context.events.emit("point:mouseout",{point:a,index:c,series:this,event:g})}).on("click",g=>{this.context.events.emit("point:click",{point:a,index:c,series:this,event:g})})})}getDataExtents(){let t=1/0,e=-1/0;for(const i of this.data){const r=i.start??i.x??0,o=i.end??r+1;t=Math.min(t,r),e=Math.max(e,o)}return{xMin:t,xMax:e,yMin:0,yMax:0}}}var At=1e-6,vd=1e-12,Bt=Math.PI,te=Bt/2,wd=Bt/4,Ke=Bt*2,Fe=180/Bt,ee=Bt/180,Yt=Math.abs,Ji=Math.atan,Vn=Math.atan2,Dt=Math.cos,As=Math.ceil,kd=Math.exp,Ss=Math.log,Wc=Math.pow,$t=Math.sin,sn=Math.sign||function(n){return n>0?1:n<0?-1:0},Ge=Math.sqrt,Hc=Math.tan;function Md(n){return n>1?0:n<-1?Bt:Math.acos(n)}function an(n){return n>1?te:n<-1?-te:Math.asin(n)}function cn(){}function _s(n,t){n&&Sd.hasOwnProperty(n.type)&&Sd[n.type](n,t)}var Ad={Feature:function(n,t){_s(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,i=-1,r=e.length;++i<r;)_s(e[i].geometry,t)}},Sd={Sphere:function(n,t){t.sphere()},Point:function(n,t){n=n.coordinates,t.point(n[0],n[1],n[2])},MultiPoint:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)n=e[i],t.point(n[0],n[1],n[2])},LineString:function(n,t){Vc(n.coordinates,t,0)},MultiLineString:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)Vc(e[i],t,0)},Polygon:function(n,t){_d(n.coordinates,t)},MultiPolygon:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)_d(e[i],t)},GeometryCollection:function(n,t){for(var e=n.geometries,i=-1,r=e.length;++i<r;)_s(e[i],t)}};function Vc(n,t,e){var i=-1,r=n.length-e,o;for(t.lineStart();++i<r;)o=n[i],t.point(o[0],o[1],o[2]);t.lineEnd()}function _d(n,t){var e=-1,i=n.length;for(t.polygonStart();++e<i;)Vc(n[e],t,1);t.polygonEnd()}function Qi(n,t){n&&Ad.hasOwnProperty(n.type)?Ad[n.type](n,t):_s(n,t)}function Gc(n){return[Vn(n[1],n[0]),an(n[2])]}function tr(n){var t=n[0],e=n[1],i=Dt(e);return[i*Dt(t),i*$t(t),$t(e)]}function Cs(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function Ps(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Yc(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function Es(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function Xc(n){var t=Ge(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function Uc(n,t){function e(i,r){return i=n(i,r),t(i[0],i[1])}return n.invert&&t.invert&&(e.invert=function(i,r){return i=t.invert(i,r),i&&n.invert(i[0],i[1])}),e}function jc(n,t){return Yt(n)>Bt&&(n-=Math.round(n/Ke)*Ke),[n,t]}jc.invert=jc;function Cd(n,t,e){return(n%=Ke)?t||e?Uc(Ed(n),Td(t,e)):Ed(n):t||e?Td(t,e):jc}function Pd(n){return function(t,e){return t+=n,Yt(t)>Bt&&(t-=Math.round(t/Ke)*Ke),[t,e]}}function Ed(n){var t=Pd(n);return t.invert=Pd(-n),t}function Td(n,t){var e=Dt(n),i=$t(n),r=Dt(t),o=$t(t);function s(a,c){var l=Dt(c),h=Dt(a)*l,f=$t(a)*l,u=$t(c),d=u*e+h*i;return[Vn(f*r-d*o,h*e-u*i),an(d*r+f*o)]}return s.invert=function(a,c){var l=Dt(c),h=Dt(a)*l,f=$t(a)*l,u=$t(c),d=u*r-f*o;return[Vn(f*r+u*o,h*e+d*i),an(d*e-h*i)]},s}function Ek(n){n=Cd(n[0]*ee,n[1]*ee,n.length>2?n[2]*ee:0);function t(e){return e=n(e[0]*ee,e[1]*ee),e[0]*=Fe,e[1]*=Fe,e}return t.invert=function(e){return e=n.invert(e[0]*ee,e[1]*ee),e[0]*=Fe,e[1]*=Fe,e},t}function Tk(n,t,e,i,r,o){if(e){var s=Dt(t),a=$t(t),c=i*e;r==null?(r=t+i*Ke,o=t-c/2):(r=Ld(s,r),o=Ld(s,o),(i>0?r<o:r>o)&&(r+=i*Ke));for(var l,h=r;i>0?h>o:h<o;h-=c)l=Gc([s,-a*Dt(h),-a*$t(h)]),n.point(l[0],l[1])}}function Ld(n,t){t=tr(t),t[0]-=n,Xc(t);var e=Md(-t[1]);return((-t[2]<0?-e:e)+Ke-At)%Ke}function $d(){var n=[],t;return{point:function(e,i,r){t.push([e,i,r])},lineStart:function(){n.push(t=[])},lineEnd:cn,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function Ts(n,t){return Yt(n[0]-t[0])<At&&Yt(n[1]-t[1])<At}function Ls(n,t,e,i){this.x=n,this.z=t,this.o=e,this.e=i,this.v=!1,this.n=this.p=null}function Id(n,t,e,i,r){var o=[],s=[],a,c;if(n.forEach(function(p){if(!((y=p.length-1)<=0)){var y,g=p[0],m=p[y],x;if(Ts(g,m)){if(!g[2]&&!m[2]){for(r.lineStart(),a=0;a<y;++a)r.point((g=p[a])[0],g[1]);r.lineEnd();return}m[0]+=2*At}o.push(x=new Ls(g,p,null,!0)),s.push(x.o=new Ls(g,null,x,!1)),o.push(x=new Ls(m,p,null,!1)),s.push(x.o=new Ls(m,null,x,!0))}}),!!o.length){for(s.sort(t),Fd(o),Fd(s),a=0,c=s.length;a<c;++a)s[a].e=e=!e;for(var l=o[0],h,f;;){for(var u=l,d=!0;u.v;)if((u=u.n)===l)return;h=u.z,r.lineStart();do{if(u.v=u.o.v=!0,u.e){if(d)for(a=0,c=h.length;a<c;++a)r.point((f=h[a])[0],f[1]);else i(u.x,u.n.x,1,r);u=u.n}else{if(d)for(h=u.p.z,a=h.length-1;a>=0;--a)r.point((f=h[a])[0],f[1]);else i(u.x,u.p.x,-1,r);u=u.p}u=u.o,h=u.z,d=!d}while(!u.v);r.lineEnd()}}}function Fd(n){if(t=n.length){for(var t,e=0,i=n[0],r;++e<t;)i.n=r=n[e],r.p=i,i=r;i.n=r=n[0],r.p=i}}function qc(n){return Yt(n[0])<=Bt?n[0]:sn(n[0])*((Yt(n[0])+Bt)%Ke-Bt)}function Lk(n,t){var e=qc(t),i=t[1],r=$t(i),o=[$t(e),-Dt(e),0],s=0,a=0,c=new pi;r===1?i=te+At:r===-1&&(i=-te-At);for(var l=0,h=n.length;l<h;++l)if(u=(f=n[l]).length)for(var f,u,d=f[u-1],p=qc(d),y=d[1]/2+wd,g=$t(y),m=Dt(y),x=0;x<u;++x,p=b,g=M,m=C,d=v){var v=f[x],b=qc(v),k=v[1]/2+wd,M=$t(k),C=Dt(k),E=b-p,_=E>=0?1:-1,T=_*E,I=T>Bt,L=g*M;if(c.add(Vn(L*_*$t(T),m*C+L*Dt(T))),s+=I?E+_*Ke:E,I^p>=e^b>=e){var P=Ps(tr(d),tr(v));Xc(P);var A=Ps(o,P);Xc(A);var w=(I^E>=0?-1:1)*an(A[2]);(i>w||i===w&&(P[0]||P[1]))&&(a+=I^E>=0?1:-1)}}return(s<-At||s<At&&c<-vd)^a&1}function Rd(n,t,e,i){return function(r){var o=t(r),s=$d(),a=t(s),c=!1,l,h,f,u={point:d,lineStart:y,lineEnd:g,polygonStart:function(){u.point=m,u.lineStart=x,u.lineEnd=v,h=[],l=[]},polygonEnd:function(){u.point=d,u.lineStart=y,u.lineEnd=g,h=tu(h);var b=Lk(l,i);h.length?(c||(r.polygonStart(),c=!0),Id(h,Ik,b,e,r)):b&&(c||(r.polygonStart(),c=!0),r.lineStart(),e(null,null,1,r),r.lineEnd()),c&&(r.polygonEnd(),c=!1),h=l=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}};function d(b,k){n(b,k)&&r.point(b,k)}function p(b,k){o.point(b,k)}function y(){u.point=p,o.lineStart()}function g(){u.point=d,o.lineEnd()}function m(b,k){f.push([b,k]),a.point(b,k)}function x(){a.lineStart(),f=[]}function v(){m(f[0][0],f[0][1]),a.lineEnd();var b=a.clean(),k=s.result(),M,C=k.length,E,_,T;if(f.pop(),l.push(f),f=null,!!C){if(b&1){if(_=k[0],(E=_.length-1)>0){for(c||(r.polygonStart(),c=!0),r.lineStart(),M=0;M<E;++M)r.point((T=_[M])[0],T[1]);r.lineEnd()}return}C>1&&b&2&&k.push(k.pop().concat(k.shift())),h.push(k.filter($k))}}return u}}function $k(n){return n.length>1}function Ik(n,t){return((n=n.x)[0]<0?n[1]-te-At:te-n[1])-((t=t.x)[0]<0?t[1]-te-At:te-t[1])}const Dd=Rd(function(){return!0},Fk,Dk,[-Bt,-te]);function Fk(n){var t=NaN,e=NaN,i=NaN,r;return{lineStart:function(){n.lineStart(),r=1},point:function(o,s){var a=o>0?Bt:-Bt,c=Yt(o-t);Yt(c-Bt)<At?(n.point(t,e=(e+s)/2>0?te:-te),n.point(i,e),n.lineEnd(),n.lineStart(),n.point(a,e),n.point(o,e),r=0):i!==a&&c>=Bt&&(Yt(t-i)<At&&(t-=i*At),Yt(o-a)<At&&(o-=a*At),e=Rk(t,e,o,s),n.point(i,e),n.lineEnd(),n.lineStart(),n.point(a,e),r=0),n.point(t=o,e=s),i=a},lineEnd:function(){n.lineEnd(),t=e=NaN},clean:function(){return 2-r}}}function Rk(n,t,e,i){var r,o,s=$t(n-e);return Yt(s)>At?Ji(($t(t)*(o=Dt(i))*$t(e)-$t(i)*(r=Dt(t))*$t(n))/(r*o*s)):(t+i)/2}function Dk(n,t,e,i){var r;if(n==null)r=e*te,i.point(-Bt,r),i.point(0,r),i.point(Bt,r),i.point(Bt,0),i.point(Bt,-r),i.point(0,-r),i.point(-Bt,-r),i.point(-Bt,0),i.point(-Bt,r);else if(Yt(n[0]-t[0])>At){var o=n[0]<t[0]?Bt:-Bt;r=e*o/2,i.point(-o,r),i.point(0,r),i.point(o,r)}else i.point(t[0],t[1])}function zk(n){var t=Dt(n),e=2*ee,i=t>0,r=Yt(t)>At;function o(h,f,u,d){Tk(d,n,e,u,h,f)}function s(h,f){return Dt(h)*Dt(f)>t}function a(h){var f,u,d,p,y;return{lineStart:function(){p=d=!1,y=1},point:function(g,m){var x=[g,m],v,b=s(g,m),k=i?b?0:l(g,m):b?l(g+(g<0?Bt:-Bt),m):0;if(!f&&(p=d=b)&&h.lineStart(),b!==d&&(v=c(f,x),(!v||Ts(f,v)||Ts(x,v))&&(x[2]=1)),b!==d)y=0,b?(h.lineStart(),v=c(x,f),h.point(v[0],v[1])):(v=c(f,x),h.point(v[0],v[1],2),h.lineEnd()),f=v;else if(r&&f&&i^b){var M;!(k&u)&&(M=c(x,f,!0))&&(y=0,i?(h.lineStart(),h.point(M[0][0],M[0][1]),h.point(M[1][0],M[1][1]),h.lineEnd()):(h.point(M[1][0],M[1][1]),h.lineEnd(),h.lineStart(),h.point(M[0][0],M[0][1],3)))}b&&(!f||!Ts(f,x))&&h.point(x[0],x[1]),f=x,d=b,u=k},lineEnd:function(){d&&h.lineEnd(),f=null},clean:function(){return y|(p&&d)<<1}}}function c(h,f,u){var d=tr(h),p=tr(f),y=[1,0,0],g=Ps(d,p),m=Cs(g,g),x=g[0],v=m-x*x;if(!v)return!u&&h;var b=t*m/v,k=-t*x/v,M=Ps(y,g),C=Es(y,b),E=Es(g,k);Yc(C,E);var _=M,T=Cs(C,_),I=Cs(_,_),L=T*T-I*(Cs(C,C)-1);if(!(L<0)){var P=Ge(L),A=Es(_,(-T-P)/I);if(Yc(A,C),A=Gc(A),!u)return A;var w=h[0],S=f[0],$=h[1],R=f[1],F;S<w&&(F=w,w=S,S=F);var D=S-w,z=Yt(D-Bt)<At,B=z||D<At;if(!z&&R<$&&(F=$,$=R,R=F),B?z?$+R>0^A[1]<(Yt(A[0]-w)<At?$:R):$<=A[1]&&A[1]<=R:D>Bt^(w<=A[0]&&A[0]<=S)){var W=Es(_,(-T+P)/I);return Yc(W,C),[A,Gc(W)]}}}function l(h,f){var u=i?n:Bt-n,d=0;return h<-u?d|=1:h>u&&(d|=2),f<-u?d|=4:f>u&&(d|=8),d}return Rd(s,a,o,i?[0,-n]:[-Bt,n-Bt])}function Bk(n,t,e,i,r,o){var s=n[0],a=n[1],c=t[0],l=t[1],h=0,f=1,u=c-s,d=l-a,p;if(p=e-s,!(!u&&p>0)){if(p/=u,u<0){if(p<h)return;p<f&&(f=p)}else if(u>0){if(p>f)return;p>h&&(h=p)}if(p=r-s,!(!u&&p<0)){if(p/=u,u<0){if(p>f)return;p>h&&(h=p)}else if(u>0){if(p<h)return;p<f&&(f=p)}if(p=i-a,!(!d&&p>0)){if(p/=d,d<0){if(p<h)return;p<f&&(f=p)}else if(d>0){if(p>f)return;p>h&&(h=p)}if(p=o-a,!(!d&&p<0)){if(p/=d,d<0){if(p>f)return;p>h&&(h=p)}else if(d>0){if(p<h)return;p<f&&(f=p)}return h>0&&(n[0]=s+h*u,n[1]=a+h*d),f<1&&(t[0]=s+f*u,t[1]=a+f*d),!0}}}}}var Dr=1e9,$s=-Dr;function Ok(n,t,e,i){function r(l,h){return n<=l&&l<=e&&t<=h&&h<=i}function o(l,h,f,u){var d=0,p=0;if(l==null||(d=s(l,f))!==(p=s(h,f))||c(l,h)<0^f>0)do u.point(d===0||d===3?n:e,d>1?i:t);while((d=(d+f+4)%4)!==p);else u.point(h[0],h[1])}function s(l,h){return Yt(l[0]-n)<At?h>0?0:3:Yt(l[0]-e)<At?h>0?2:1:Yt(l[1]-t)<At?h>0?1:0:h>0?3:2}function a(l,h){return c(l.x,h.x)}function c(l,h){var f=s(l,1),u=s(h,1);return f!==u?f-u:f===0?h[1]-l[1]:f===1?l[0]-h[0]:f===2?l[1]-h[1]:h[0]-l[0]}return function(l){var h=l,f=$d(),u,d,p,y,g,m,x,v,b,k,M,C={point:E,lineStart:L,lineEnd:P,polygonStart:T,polygonEnd:I};function E(w,S){r(w,S)&&h.point(w,S)}function _(){for(var w=0,S=0,$=d.length;S<$;++S)for(var R=d[S],F=1,D=R.length,z=R[0],B,W,K=z[0],X=z[1];F<D;++F)B=K,W=X,z=R[F],K=z[0],X=z[1],W<=i?X>i&&(K-B)*(i-W)>(X-W)*(n-B)&&++w:X<=i&&(K-B)*(i-W)<(X-W)*(n-B)&&--w;return w}function T(){h=f,u=[],d=[],M=!0}function I(){var w=_(),S=M&&w,$=(u=tu(u)).length;(S||$)&&(l.polygonStart(),S&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),$&&Id(u,a,w,o,l),l.polygonEnd()),h=l,u=d=p=null}function L(){C.point=A,d&&d.push(p=[]),k=!0,b=!1,x=v=NaN}function P(){u&&(A(y,g),m&&b&&f.rejoin(),u.push(f.result())),C.point=E,b&&h.lineEnd()}function A(w,S){var $=r(w,S);if(d&&p.push([w,S]),k)y=w,g=S,m=$,k=!1,$&&(h.lineStart(),h.point(w,S));else if($&&b)h.point(w,S);else{var R=[x=Math.max($s,Math.min(Dr,x)),v=Math.max($s,Math.min(Dr,v))],F=[w=Math.max($s,Math.min(Dr,w)),S=Math.max($s,Math.min(Dr,S))];Bk(R,F,n,t,e,i)?(b||(h.lineStart(),h.point(R[0],R[1])),h.point(F[0],F[1]),$||h.lineEnd(),M=!1):$&&(h.lineStart(),h.point(w,S),M=!1)}x=w,v=S,b=$}return C}}function zd(n,t,e){var i=gi(n,t-At,e).concat(t);return function(r){return i.map(function(o){return[r,o]})}}function Bd(n,t,e){var i=gi(n,t-At,e).concat(t);return function(r){return i.map(function(o){return[o,r]})}}function Nk(){var n,t,e,i,r,o,s,a,c=10,l=c,h=90,f=360,u,d,p,y,g=2.5;function m(){return{type:"MultiLineString",coordinates:x()}}function x(){return gi(As(i/h)*h,e,h).map(p).concat(gi(As(a/f)*f,s,f).map(y)).concat(gi(As(t/c)*c,n,c).filter(function(v){return Yt(v%h)>At}).map(u)).concat(gi(As(o/l)*l,r,l).filter(function(v){return Yt(v%f)>At}).map(d))}return m.lines=function(){return x().map(function(v){return{type:"LineString",coordinates:v}})},m.outline=function(){return{type:"Polygon",coordinates:[p(i).concat(y(s).slice(1),p(e).reverse().slice(1),y(a).reverse().slice(1))]}},m.extent=function(v){return arguments.length?m.extentMajor(v).extentMinor(v):m.extentMinor()},m.extentMajor=function(v){return arguments.length?(i=+v[0][0],e=+v[1][0],a=+v[0][1],s=+v[1][1],i>e&&(v=i,i=e,e=v),a>s&&(v=a,a=s,s=v),m.precision(g)):[[i,a],[e,s]]},m.extentMinor=function(v){return arguments.length?(t=+v[0][0],n=+v[1][0],o=+v[0][1],r=+v[1][1],t>n&&(v=t,t=n,n=v),o>r&&(v=o,o=r,r=v),m.precision(g)):[[t,o],[n,r]]},m.step=function(v){return arguments.length?m.stepMajor(v).stepMinor(v):m.stepMinor()},m.stepMajor=function(v){return arguments.length?(h=+v[0],f=+v[1],m):[h,f]},m.stepMinor=function(v){return arguments.length?(c=+v[0],l=+v[1],m):[c,l]},m.precision=function(v){return arguments.length?(g=+v,u=zd(o,r,90),d=Bd(t,n,g),p=zd(a,s,90),y=Bd(i,e,g),m):g},m.extentMajor([[-180,-90+At],[180,90-At]]).extentMinor([[-180,-80-At],[180,80+At]])}const Zc=n=>n;var Kc=new pi,Jc=new pi,Od,Nd,Qc,tl,Gn={point:cn,lineStart:cn,lineEnd:cn,polygonStart:function(){Gn.lineStart=Wk,Gn.lineEnd=Vk},polygonEnd:function(){Gn.lineStart=Gn.lineEnd=Gn.point=cn,Kc.add(Yt(Jc)),Jc=new pi},result:function(){var n=Kc/2;return Kc=new pi,n}};function Wk(){Gn.point=Hk}function Hk(n,t){Gn.point=Wd,Od=Qc=n,Nd=tl=t}function Wd(n,t){Jc.add(tl*n-Qc*t),Qc=n,tl=t}function Vk(){Wd(Od,Nd)}var er=1/0,Is=er,zr=-er,Fs=zr,Rs={point:Gk,lineStart:cn,lineEnd:cn,polygonStart:cn,polygonEnd:cn,result:function(){var n=[[er,Is],[zr,Fs]];return zr=Fs=-(Is=er=1/0),n}};function Gk(n,t){n<er&&(er=n),n>zr&&(zr=n),t<Is&&(Is=t),t>Fs&&(Fs=t)}var el=0,nl=0,Br=0,Ds=0,zs=0,nr=0,il=0,rl=0,Or=0,Hd,Vd,_n,Cn,ln={point:Si,lineStart:Gd,lineEnd:Yd,polygonStart:function(){ln.lineStart=Uk,ln.lineEnd=jk},polygonEnd:function(){ln.point=Si,ln.lineStart=Gd,ln.lineEnd=Yd},result:function(){var n=Or?[il/Or,rl/Or]:nr?[Ds/nr,zs/nr]:Br?[el/Br,nl/Br]:[NaN,NaN];return el=nl=Br=Ds=zs=nr=il=rl=Or=0,n}};function Si(n,t){el+=n,nl+=t,++Br}function Gd(){ln.point=Yk}function Yk(n,t){ln.point=Xk,Si(_n=n,Cn=t)}function Xk(n,t){var e=n-_n,i=t-Cn,r=Ge(e*e+i*i);Ds+=r*(_n+n)/2,zs+=r*(Cn+t)/2,nr+=r,Si(_n=n,Cn=t)}function Yd(){ln.point=Si}function Uk(){ln.point=qk}function jk(){Xd(Hd,Vd)}function qk(n,t){ln.point=Xd,Si(Hd=_n=n,Vd=Cn=t)}function Xd(n,t){var e=n-_n,i=t-Cn,r=Ge(e*e+i*i);Ds+=r*(_n+n)/2,zs+=r*(Cn+t)/2,nr+=r,r=Cn*n-_n*t,il+=r*(_n+n),rl+=r*(Cn+t),Or+=r*3,Si(_n=n,Cn=t)}function Ud(n){this._context=n}Ud.prototype={_radius:4.5,pointRadius:function(n){return this._radius=n,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(n,t){switch(this._point){case 0:{this._context.moveTo(n,t),this._point=1;break}case 1:{this._context.lineTo(n,t);break}default:{this._context.moveTo(n+this._radius,t),this._context.arc(n,t,this._radius,0,Ke);break}}},result:cn};var ol=new pi,sl,jd,qd,Nr,Wr,Hr={point:cn,lineStart:function(){Hr.point=Zk},lineEnd:function(){sl&&Zd(jd,qd),Hr.point=cn},polygonStart:function(){sl=!0},polygonEnd:function(){sl=null},result:function(){var n=+ol;return ol=new pi,n}};function Zk(n,t){Hr.point=Zd,jd=Nr=n,qd=Wr=t}function Zd(n,t){Nr-=n,Wr-=t,ol.add(Ge(Nr*Nr+Wr*Wr)),Nr=n,Wr=t}let Kd,Bs,Jd,Qd;class tp{constructor(t){this._append=t==null?ep:Kk(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:{this._append`M${t},${e}`,this._point=1;break}case 1:{this._append`L${t},${e}`;break}default:{if(this._append`M${t},${e}`,this._radius!==Jd||this._append!==Bs){const i=this._radius,r=this._;this._="",this._append`m0,${i}a${i},${i} 0 1,1 0,${-2*i}a${i},${i} 0 1,1 0,${2*i}z`,Jd=i,Bs=this._append,Qd=this._,this._=r}this._+=Qd;break}}}result(){const t=this._;return this._="",t.length?t:null}}function ep(n){let t=1;this._+=n[0];for(const e=n.length;t<e;++t)this._+=arguments[t]+n[t]}function Kk(n){const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);if(t>15)return ep;if(t!==Kd){const e=10**t;Kd=t,Bs=function(r){let o=1;this._+=r[0];for(const s=r.length;o<s;++o)this._+=Math.round(arguments[o]*e)/e+r[o]}}return Bs}function Jk(n,t){let e=3,i=4.5,r,o;function s(a){return a&&(typeof i=="function"&&o.pointRadius(+i.apply(this,arguments)),Qi(a,r(o))),o.result()}return s.area=function(a){return Qi(a,r(Gn)),Gn.result()},s.measure=function(a){return Qi(a,r(Hr)),Hr.result()},s.bounds=function(a){return Qi(a,r(Rs)),Rs.result()},s.centroid=function(a){return Qi(a,r(ln)),ln.result()},s.projection=function(a){return arguments.length?(r=a==null?(n=null,Zc):(n=a).stream,s):n},s.context=function(a){return arguments.length?(o=a==null?(t=null,new tp(e)):new Ud(t=a),typeof i!="function"&&o.pointRadius(i),s):t},s.pointRadius=function(a){return arguments.length?(i=typeof a=="function"?a:(o.pointRadius(+a),+a),s):i},s.digits=function(a){if(!arguments.length)return e;if(a==null)e=null;else{const c=Math.floor(a);if(!(c>=0))throw new RangeError(`invalid digits: ${a}`);e=c}return t===null&&(o=new tp(e)),s},s.projection(n).digits(e).context(t)}function al(n){return function(t){var e=new cl;for(var i in n)e[i]=n[i];return e.stream=t,e}}function cl(){}cl.prototype={constructor:cl,point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function ll(n,t,e){var i=n.clipExtent&&n.clipExtent();return n.scale(150).translate([0,0]),i!=null&&n.clipExtent(null),Qi(e,n.stream(Rs)),t(Rs.result()),i!=null&&n.clipExtent(i),n}function hl(n,t,e){return ll(n,function(i){var r=t[1][0]-t[0][0],o=t[1][1]-t[0][1],s=Math.min(r/(i[1][0]-i[0][0]),o/(i[1][1]-i[0][1])),a=+t[0][0]+(r-s*(i[1][0]+i[0][0]))/2,c=+t[0][1]+(o-s*(i[1][1]+i[0][1]))/2;n.scale(150*s).translate([a,c])},e)}function np(n,t,e){return hl(n,[[0,0],t],e)}function ip(n,t,e){return ll(n,function(i){var r=+t,o=r/(i[1][0]-i[0][0]),s=(r-o*(i[1][0]+i[0][0]))/2,a=-o*i[0][1];n.scale(150*o).translate([s,a])},e)}function rp(n,t,e){return ll(n,function(i){var r=+t,o=r/(i[1][1]-i[0][1]),s=-o*i[0][0],a=(r-o*(i[1][1]+i[0][1]))/2;n.scale(150*o).translate([s,a])},e)}var op=16,Qk=Dt(30*ee);function sp(n,t){return+t?eM(n,t):tM(n)}function tM(n){return al({point:function(t,e){t=n(t,e),this.stream.point(t[0],t[1])}})}function eM(n,t){function e(i,r,o,s,a,c,l,h,f,u,d,p,y,g){var m=l-i,x=h-r,v=m*m+x*x;if(v>4*t&&y--){var b=s+u,k=a+d,M=c+p,C=Ge(b*b+k*k+M*M),E=an(M/=C),_=Yt(Yt(M)-1)<At||Yt(o-f)<At?(o+f)/2:Vn(k,b),T=n(_,E),I=T[0],L=T[1],P=I-i,A=L-r,w=x*P-m*A;(w*w/v>t||Yt((m*P+x*A)/v-.5)>.3||s*u+a*d+c*p<Qk)&&(e(i,r,o,s,a,c,I,L,_,b/=C,k/=C,M,y,g),g.point(I,L),e(I,L,_,b,k,M,l,h,f,u,d,p,y,g))}}return function(i){var r,o,s,a,c,l,h,f,u,d,p,y,g={point:m,lineStart:x,lineEnd:b,polygonStart:function(){i.polygonStart(),g.lineStart=k},polygonEnd:function(){i.polygonEnd(),g.lineStart=x}};function m(E,_){E=n(E,_),i.point(E[0],E[1])}function x(){f=NaN,g.point=v,i.lineStart()}function v(E,_){var T=tr([E,_]),I=n(E,_);e(f,u,h,d,p,y,f=I[0],u=I[1],h=E,d=T[0],p=T[1],y=T[2],op,i),i.point(f,u)}function b(){g.point=m,i.lineEnd()}function k(){x(),g.point=M,g.lineEnd=C}function M(E,_){v(r=E,_),o=f,s=u,a=d,c=p,l=y,g.point=v}function C(){e(f,u,h,d,p,y,o,s,r,a,c,l,op,i),g.lineEnd=b,b()}return g}}var nM=al({point:function(n,t){this.stream.point(n*ee,t*ee)}});function iM(n){return al({point:function(t,e){var i=n(t,e);return this.stream.point(i[0],i[1])}})}function rM(n,t,e,i,r){function o(s,a){return s*=i,a*=r,[t+n*s,e-n*a]}return o.invert=function(s,a){return[(s-t)/n*i,(e-a)/n*r]},o}function ap(n,t,e,i,r,o){if(!o)return rM(n,t,e,i,r);var s=Dt(o),a=$t(o),c=s*n,l=a*n,h=s/n,f=a/n,u=(a*e-s*t)/n,d=(a*t+s*e)/n;function p(y,g){return y*=i,g*=r,[c*y-l*g+t,e-l*y-c*g]}return p.invert=function(y,g){return[i*(h*y-f*g+u),r*(d-f*y-h*g)]},p}function Pn(n){return cp(function(){return n})()}function cp(n){var t,e=150,i=480,r=250,o=0,s=0,a=0,c=0,l=0,h,f=0,u=1,d=1,p=null,y=Dd,g=null,m,x,v,b=Zc,k=.5,M,C,E,_,T;function I(w){return E(w[0]*ee,w[1]*ee)}function L(w){return w=E.invert(w[0],w[1]),w&&[w[0]*Fe,w[1]*Fe]}I.stream=function(w){return _&&T===w?_:_=nM(iM(h)(y(M(b(T=w)))))},I.preclip=function(w){return arguments.length?(y=w,p=void 0,A()):y},I.postclip=function(w){return arguments.length?(b=w,g=m=x=v=null,A()):b},I.clipAngle=function(w){return arguments.length?(y=+w?zk(p=w*ee):(p=null,Dd),A()):p*Fe},I.clipExtent=function(w){return arguments.length?(b=w==null?(g=m=x=v=null,Zc):Ok(g=+w[0][0],m=+w[0][1],x=+w[1][0],v=+w[1][1]),A()):g==null?null:[[g,m],[x,v]]},I.scale=function(w){return arguments.length?(e=+w,P()):e},I.translate=function(w){return arguments.length?(i=+w[0],r=+w[1],P()):[i,r]},I.center=function(w){return arguments.length?(o=w[0]%360*ee,s=w[1]%360*ee,P()):[o*Fe,s*Fe]},I.rotate=function(w){return arguments.length?(a=w[0]%360*ee,c=w[1]%360*ee,l=w.length>2?w[2]%360*ee:0,P()):[a*Fe,c*Fe,l*Fe]},I.angle=function(w){return arguments.length?(f=w%360*ee,P()):f*Fe},I.reflectX=function(w){return arguments.length?(u=w?-1:1,P()):u<0},I.reflectY=function(w){return arguments.length?(d=w?-1:1,P()):d<0},I.precision=function(w){return arguments.length?(M=sp(C,k=w*w),A()):Ge(k)},I.fitExtent=function(w,S){return hl(I,w,S)},I.fitSize=function(w,S){return np(I,w,S)},I.fitWidth=function(w,S){return ip(I,w,S)},I.fitHeight=function(w,S){return rp(I,w,S)};function P(){var w=ap(e,0,0,u,d,f).apply(null,t(o,s)),S=ap(e,i-w[0],r-w[1],u,d,f);return h=Cd(a,c,l),C=Uc(t,S),E=Uc(h,C),M=sp(C,k),A()}function A(){return _=T=null,I}return function(){return t=n.apply(this,arguments),I.invert=t.invert&&L,P()}}function ul(n){var t=0,e=Bt/3,i=cp(n),r=i(t,e);return r.parallels=function(o){return arguments.length?i(t=o[0]*ee,e=o[1]*ee):[t*Fe,e*Fe]},r}function oM(n){var t=Dt(n);function e(i,r){return[i*t,$t(r)/t]}return e.invert=function(i,r){return[i/t,an(r*t)]},e}function sM(n,t){var e=$t(n),i=(e+$t(t))/2;if(Yt(i)<At)return oM(n);var r=1+e*(2*i-e),o=Ge(r)/i;function s(a,c){var l=Ge(r-2*i*$t(c))/i;return[l*$t(a*=i),o-l*Dt(a)]}return s.invert=function(a,c){var l=o-c,h=Vn(a,Yt(l))*sn(l);return l*i<0&&(h-=Bt*sn(a)*sn(l)),[h/i,an((r-(a*a+l*l)*i*i)/(2*i))]},s}function Os(){return ul(sM).scale(155.424).center([0,33.6442])}function lp(){return Os().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function aM(n){var t=n.length;return{point:function(e,i){for(var r=-1;++r<t;)n[r].point(e,i)},sphere:function(){for(var e=-1;++e<t;)n[e].sphere()},lineStart:function(){for(var e=-1;++e<t;)n[e].lineStart()},lineEnd:function(){for(var e=-1;++e<t;)n[e].lineEnd()},polygonStart:function(){for(var e=-1;++e<t;)n[e].polygonStart()},polygonEnd:function(){for(var e=-1;++e<t;)n[e].polygonEnd()}}}function cM(){var n,t,e=lp(),i,r=Os().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o,s=Os().rotate([157,0]).center([-3,19.9]).parallels([8,18]),a,c,l={point:function(u,d){c=[u,d]}};function h(u){var d=u[0],p=u[1];return c=null,i.point(d,p),c||(o.point(d,p),c)||(a.point(d,p),c)}h.invert=function(u){var d=e.scale(),p=e.translate(),y=(u[0]-p[0])/d,g=(u[1]-p[1])/d;return(g>=.12&&g<.234&&y>=-.425&&y<-.214?r:g>=.166&&g<.234&&y>=-.214&&y<-.115?s:e).invert(u)},h.stream=function(u){return n&&t===u?n:n=aM([e.stream(t=u),r.stream(u),s.stream(u)])},h.precision=function(u){return arguments.length?(e.precision(u),r.precision(u),s.precision(u),f()):e.precision()},h.scale=function(u){return arguments.length?(e.scale(u),r.scale(u*.35),s.scale(u),h.translate(e.translate())):e.scale()},h.translate=function(u){if(!arguments.length)return e.translate();var d=e.scale(),p=+u[0],y=+u[1];return i=e.translate(u).clipExtent([[p-.455*d,y-.238*d],[p+.455*d,y+.238*d]]).stream(l),o=r.translate([p-.307*d,y+.201*d]).clipExtent([[p-.425*d+At,y+.12*d+At],[p-.214*d-At,y+.234*d-At]]).stream(l),a=s.translate([p-.205*d,y+.212*d]).clipExtent([[p-.214*d+At,y+.166*d+At],[p-.115*d-At,y+.234*d-At]]).stream(l),f()},h.fitExtent=function(u,d){return hl(h,u,d)},h.fitSize=function(u,d){return np(h,u,d)},h.fitWidth=function(u,d){return ip(h,u,d)},h.fitHeight=function(u,d){return rp(h,u,d)};function f(){return n=t=null,h}return h.scale(1070)}function hp(n){return function(t,e){var i=Dt(t),r=Dt(e),o=n(i*r);return o===1/0?[2,0]:[o*r*$t(t),o*$t(e)]}}function Vr(n){return function(t,e){var i=Ge(t*t+e*e),r=n(i),o=$t(r),s=Dt(r);return[Vn(t*o,i*s),an(i&&e*o/i)]}}var up=hp(function(n){return Ge(2/(1+n))});up.invert=Vr(function(n){return 2*an(n/2)});function lM(){return Pn(up).scale(124.75).clipAngle(180-.001)}var fp=hp(function(n){return(n=Md(n))&&n/$t(n)});fp.invert=Vr(function(n){return n});function hM(){return Pn(fp).scale(79.4188).clipAngle(180-.001)}function Ns(n,t){return[n,Ss(Hc((te+t)/2))]}Ns.invert=function(n,t){return[n,2*Ji(kd(t))-te]};function dp(){return pp(Ns).scale(961/Ke)}function pp(n){var t=Pn(n),e=t.center,i=t.scale,r=t.translate,o=t.clipExtent,s=null,a,c,l;t.scale=function(f){return arguments.length?(i(f),h()):i()},t.translate=function(f){return arguments.length?(r(f),h()):r()},t.center=function(f){return arguments.length?(e(f),h()):e()},t.clipExtent=function(f){return arguments.length?(f==null?s=a=c=l=null:(s=+f[0][0],a=+f[0][1],c=+f[1][0],l=+f[1][1]),h()):s==null?null:[[s,a],[c,l]]};function h(){var f=Bt*i(),u=t(Ek(t.rotate()).invert([0,0]));return o(s==null?[[u[0]-f,u[1]-f],[u[0]+f,u[1]+f]]:n===Ns?[[Math.max(u[0]-f,s),a],[Math.min(u[0]+f,c),l]]:[[s,Math.max(u[1]-f,a)],[c,Math.min(u[1]+f,l)]])}return h()}function Ws(n){return Hc((te+n)/2)}function uM(n,t){var e=Dt(n),i=n===t?$t(n):Ss(e/Dt(t))/Ss(Ws(t)/Ws(n)),r=e*Wc(Ws(n),i)/i;if(!i)return Ns;function o(s,a){r>0?a<-te+At&&(a=-te+At):a>te-At&&(a=te-At);var c=r/Wc(Ws(a),i);return[c*$t(i*s),r-c*Dt(i*s)]}return o.invert=function(s,a){var c=r-a,l=sn(i)*Ge(s*s+c*c),h=Vn(s,Yt(c))*sn(c);return c*i<0&&(h-=Bt*sn(s)*sn(c)),[h/i,2*Ji(Wc(r/l,1/i))-te]},o}function fM(){return ul(uM).scale(109.5).parallels([30,30])}function Hs(n,t){return[n,t]}Hs.invert=Hs;function dM(){return Pn(Hs).scale(152.63)}function pM(n,t){var e=Dt(n),i=n===t?$t(n):(e-Dt(t))/(t-n),r=e/i+n;if(Yt(i)<At)return Hs;function o(s,a){var c=r-a,l=i*s;return[c*$t(l),r-c*Dt(l)]}return o.invert=function(s,a){var c=r-a,l=Vn(s,Yt(c))*sn(c);return c*i<0&&(l-=Bt*sn(s)*sn(c)),[l/i,r-sn(i)*Ge(s*s+c*c)]},o}function gM(){return ul(pM).scale(131.154).center([0,13.9389])}var Gr=1.340264,Yr=-.081106,Xr=893e-6,Ur=.003796,Vs=Ge(3)/2,mM=12;function gp(n,t){var e=an(Vs*$t(t)),i=e*e,r=i*i*i;return[n*Dt(e)/(Vs*(Gr+3*Yr*i+r*(7*Xr+9*Ur*i))),e*(Gr+Yr*i+r*(Xr+Ur*i))]}gp.invert=function(n,t){for(var e=t,i=e*e,r=i*i*i,o=0,s,a,c;o<mM&&(a=e*(Gr+Yr*i+r*(Xr+Ur*i))-t,c=Gr+3*Yr*i+r*(7*Xr+9*Ur*i),e-=s=a/c,i=e*e,r=i*i*i,!(Yt(s)<vd));++o);return[Vs*n*(Gr+3*Yr*i+r*(7*Xr+9*Ur*i))/Dt(e),an($t(e)/Vs)]};function mp(){return Pn(gp).scale(177.158)}function yp(n,t){var e=Dt(t),i=Dt(n)*e;return[e*$t(n)/i,$t(t)/i]}yp.invert=Vr(Ji);function yM(){return Pn(yp).scale(144.049).clipAngle(60)}function xp(n,t){var e=t*t,i=e*e;return[n*(.8707-.131979*e+i*(-.013791+i*(.003971*e-.001529*i))),t*(1.007226+e*(.015085+i*(-.044475+.028874*e-.005916*i)))]}xp.invert=function(n,t){var e=t,i=25,r;do{var o=e*e,s=o*o;e-=r=(e*(1.007226+o*(.015085+s*(-.044475+.028874*o-.005916*s)))-t)/(1.007226+o*(.015085*3+s*(-.044475*7+.028874*9*o-.005916*11*s)))}while(Yt(r)>At&&--i>0);return[n/(.8707+(o=e*e)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),e]};function fl(){return Pn(xp).scale(175.295)}function bp(n,t){return[Dt(t)*$t(n),$t(t)]}bp.invert=Vr(an);function vp(){return Pn(bp).scale(249.5).clipAngle(90+At)}function wp(n,t){var e=Dt(t),i=1+Dt(n)*e;return[e*$t(n)/i,$t(t)/i]}wp.invert=Vr(function(n){return 2*Ji(n)});function xM(){return Pn(wp).scale(250).clipAngle(142)}function kp(n,t){return[Ss(Hc((te+t)/2)),-n]}kp.invert=function(n,t){return[-t,2*Ji(kd(n))-te]};function bM(){var n=pp(kp),t=n.center,e=n.rotate;return n.center=function(i){return arguments.length?t([-i[1],i[0]]):(i=t(),[i[1],-i[0]])},n.rotate=function(i){return arguments.length?e([i[0],i[1],i.length>2?i[2]+90:90]):(i=e(),[i[0],i[1],i[2]-90])},e([0,0,90]).scale(159.155)}function vM(n){return n}function wM(n){if(n==null)return vM;var t,e,i=n.scale[0],r=n.scale[1],o=n.translate[0],s=n.translate[1];return function(a,c){c||(t=e=0);var l=2,h=a.length,f=new Array(h);for(f[0]=(t+=a[0])*i+o,f[1]=(e+=a[1])*r+s;l<h;)f[l]=a[l],++l;return f}}function kM(n,t){for(var e,i=n.length,r=i-t;r<--i;)e=n[r],n[r++]=n[i],n[i]=e}function MM(n,t){return typeof t=="string"&&(t=n.objects[t]),t.type==="GeometryCollection"?{type:"FeatureCollection",features:t.geometries.map(function(e){return Mp(n,e)})}:Mp(n,t)}function Mp(n,t){var e=t.id,i=t.bbox,r=t.properties==null?{}:t.properties,o=AM(n,t);return e==null&&i==null?{type:"Feature",properties:r,geometry:o}:i==null?{type:"Feature",id:e,properties:r,geometry:o}:{type:"Feature",id:e,bbox:i,properties:r,geometry:o}}function AM(n,t){var e=wM(n.transform),i=n.arcs;function r(h,f){f.length&&f.pop();for(var u=i[h<0?~h:h],d=0,p=u.length;d<p;++d)f.push(e(u[d],d));h<0&&kM(f,p)}function o(h){return e(h)}function s(h){for(var f=[],u=0,d=h.length;u<d;++u)r(h[u],f);return f.length<2&&f.push(f[0]),f}function a(h){for(var f=s(h);f.length<4;)f.push(f[0]);return f}function c(h){return h.map(a)}function l(h){var f=h.type,u;switch(f){case"GeometryCollection":return{type:f,geometries:h.geometries.map(l)};case"Point":u=o(h.coordinates);break;case"MultiPoint":u=h.coordinates.map(o);break;case"LineString":u=s(h.arcs);break;case"MultiLineString":u=h.arcs.map(s);break;case"Polygon":u=c(h.arcs);break;case"MultiPolygon":u=h.arcs.map(c);break;default:return null}return{type:f,coordinates:u}}return l(t)}const Ap=(n,t)=>[n,1.25*Math.log(Math.tan(Math.PI/4+.4*t))];Ap.invert=(n,t)=>[n,2.5*Math.atan(Math.exp(.8*t))-.625*Math.PI];const SM={naturalEarth:fl,naturalEarth1:fl,mercator:dp,orthographic:vp,albers:lp,albersUsa:cM,equirectangular:dM,equalEarth:mp,conicEqualArea:Os,conicEquidistant:gM,stereographic:xM,transverseMercator:bM,azimuthalEqualArea:lM,azimuthalEquidistant:hM,gnomonic:yM,Orthographic:vp,WebMercator:dp,EqualEarth:mp,LambertConformalConic:fM,Miller:()=>Pn(Ap).scale(108.318)};function _M(n,t){if(n&&n.type==="Topology"&&n.objects){const e=t||(n.objects.countries?"countries":Object.keys(n.objects)[0]),i=MM(n,n.objects[e]);return i.features||[i]}return n.features||n}function dl(n,t){var e;return String(n).toLowerCase()==="orthographic"||!!((e=t==null?void 0:t.options3d)!=null&&e.enabled)}function pl(n,t,e,i){var f,u,d;const r=_M(n,i),o={type:"FeatureCollection",features:r},s=(t==null?void 0:t.name)||t||"naturalEarth",c=(SM[s]||fl)(),l=typeof t=="object"?t:{};l.rotation&&((f=c.rotate)==null||f.call(c,l.rotation)),l.center&&((u=c.center)==null||u.call(c,l.center)),l.scale&&((d=c.scale)==null||d.call(c,l.scale)),l.parallels&&c.parallels&&c.parallels(l.parallels),l.scale||c.fitSize([e.width,e.height],o);const h=Jk().projection(c);return{projection:c,pathGen:h,features:r,projName:String(s)}}function gl(n,t){const e=t.width/2,i=t.height/2,r=Math.min(t.width,t.height)/2-10;return n.translate([e,i]).scale(r).clipAngle(90),r}function ml(n){var t;return n?Array.isArray(n)&&n.length>=2&&typeof n[0]=="number"?[n[0],n[1]]:n.lon!=null&&n.lat!=null?[n.lon,n.lat]:(t=n.geometry)!=null&&t.coordinates&&Array.isArray(n.geometry.coordinates)?[n.geometry.coordinates[0],n.geometry.coordinates[1]]:typeof n.x=="number"&&typeof n.y=="number"?[n.x,n.y]:null:null}const CM={blues:ad,reds:vw,greens:pw,oranges:kw,purples:xw,greys:mw,ylOrRd:sd,ylGnBu:hw,rdYlGn:cw,viridis:Mw,plasma:Sw,inferno:Aw};class PM extends Xt{constructor(t){super(t),this.zoomBehavior=null,this.mapGroup=null,this.featurePaths=null,this.dataMap=new Map,this.globeProjection=null,this.globePathGen=null,this.autoRotateTimer=null}destroy(){this.autoRotateTimer&&(this.autoRotateTimer.stop(),this.autoRotateTimer=null),super.destroy()}render(){var T;const{plotArea:t}=this.context,e=this.config,i=e.mapData;if(!i){this.group.append("text").attr("x",t.width/2).attr("y",t.height/2).attr("text-anchor","middle").attr("fill","#999").text("Map data not provided");return}const{projection:r,pathGen:o,features:s,projName:a}=pl(i,e.projection,t,e.mapDataObject);this.dataMap.clear();const c=e.joinBy||["hc-key","code"],l=Array.isArray(c)?c:[c,c],h=l[0],f=l.length>1?l[1]:l[0];for(const I of this.data){const L=I[f]||I.code||I["hc-key"]||I.name;L&&this.dataMap.set(String(L),I)}const u=e.colorAxis||{},d=this.data.map(I=>I.y??I.value??0).filter(I=>I!=null),p=u.min??(d.length?Math.min(...d):0),y=u.max??(d.length?Math.max(...d):1);if(Array.isArray(u.stops)&&u.stops.length>=2){const I=y-p||1,L=u.stops.map(w=>p+w[0]*I),P=u.stops.map(w=>w[1]),A=ke().domain(L).range(P).clamp(!0);this.colorScale=w=>A(w)}else if(u.minColor&&u.maxColor){const I=yi(u.minColor,u.maxColor),L=this.makeAxisNorm(u,p,y);this.colorScale=P=>I(L(P))}else{const I=u.colorScheme||"blues",L=CM[I]||ad,P=this.makeAxisNorm(u,p,y);this.colorScale=A=>L(P(A))}const g=e.nullColor??"#f0f0f0",m=e.allAreas!==!1,x=e.borderColor??"#cccccc",v=e.borderWidth??.5,b=`katucharts-map-clip-${Math.random().toString(36).slice(2,8)}`;this.group.append("defs").append("clipPath").attr("id",b).append("rect").attr("width",t.width).attr("height",t.height);const M=this.group.append("g").attr("clip-path",`url(#${b})`).attr("class","katucharts-map-clip");this.mapGroup=M.append("g").attr("class","katucharts-map-container katucharts-mapzoom");const C=m?s:s.filter(I=>{const L=this.getFeatureKey(I,h);return this.dataMap.has(L)}),E=this.context.animate;this.featurePaths=this.mapGroup.selectAll(".katucharts-map-feature").data(C).join("path").attr("class","katucharts-map-feature").attr("d",o).attr("stroke",x).attr("stroke-width",v).attr("stroke-linejoin","round").style("cursor","pointer"),E?this.featurePaths.attr("fill",g).attr("fill-opacity",0).transition().duration(bt).ease(pt).attr("fill-opacity",1).attr("fill",I=>this.getFeatureColor(I,h,g)):this.featurePaths.attr("fill",I=>this.getFeatureColor(I,h,g)),this.attachMapHover(h,x,v,g),this.renderMapLabels(o,C,h),u.enabled!==!1&&d.length>0&&this.renderColorAxis(p,y,u),dl(a,e)?this.setupGlobeMode(r,o,s,h,g,x,v,e):((T=e.mapNavigation)==null?void 0:T.enabled)!==!1&&this.setupMapNavigation(r,o)}makeAxisNorm(t,e,i){if(t.type==="logarithmic"&&e>0&&i>0){const o=Io().domain([e,i]).clamp(!0);return s=>o(Math.max(s,e))}const r=ke().domain([e,i]).clamp(!0);return o=>r(o)}getFeatureKey(t,e){var i,r,o;return String(((i=t.properties)==null?void 0:i[e])||((r=t.properties)==null?void 0:r["hc-key"])||((o=t.properties)==null?void 0:o.name)||t.id||"")}getFeatureColor(t,e,i){const r=this.getFeatureKey(t,e),o=this.dataMap.get(r);if(o){if(o.color)return o.color;const s=o.y??o.value;if(s!=null)return this.colorScale(s)}return i}attachMapHover(t,e,i,r){var h,f,u,d,p,y,g,m;const o=this.config,s=(f=(h=o.states)==null?void 0:h.hover)==null?void 0:f.color,a=((d=(u=o.states)==null?void 0:u.hover)==null?void 0:d.borderColor)??"#333333",c=((y=(p=o.states)==null?void 0:p.hover)==null?void 0:y.borderWidth)??1.5,l=((m=(g=o.states)==null?void 0:g.hover)==null?void 0:m.brightness)??.2;this.featurePaths.on("mouseover",(x,v)=>{var I,L,P;const b=st(x.currentTarget),k=this.getFeatureKey(v,t),M=this.dataMap.get(k),C=b.attr("fill");if(s)b.transition("hover").duration(Z).ease(j).attr("fill",s);else{const A=((L=(I=ce(C))==null?void 0:I.brighter(l))==null?void 0:L.toString())||C;b.transition("hover").duration(Z).ease(j).attr("fill",A)}b.attr("stroke",a).attr("stroke-width",c),b.raise(),this.featurePaths.interrupt("highlight"),this.featurePaths.filter(A=>A!==v).transition("highlight").duration(Z).ease(j).attr("opacity",.7);const E=((P=v.properties)==null?void 0:P.name)||k,_=M?{name:M.name??E,y:M.y??M.value,...M}:{name:E},T=x.currentTarget.getBBox();this.context.events.emit("point:mouseover",{point:_,index:0,series:this,event:x,plotX:T.x+T.width/2,plotY:T.y+T.height/2})}).on("mouseout",(x,v)=>{var E;const b=st(x.currentTarget),k=this.getFeatureColor(v,t,r);b.transition("hover").duration(Z).ease(j).attr("fill",k),b.attr("stroke",e).attr("stroke-width",i),this.featurePaths.interrupt("highlight"),this.featurePaths.transition("highlight").duration(Z).ease(j).attr("opacity",1);const M=this.getFeatureKey(v,t),C=this.dataMap.get(M)||{name:((E=v.properties)==null?void 0:E.name)||M};this.context.events.emit("point:mouseout",{point:C,index:0,series:this,event:x})}).on("click",(x,v)=>{var M;const b=this.getFeatureKey(v,t),k=this.dataMap.get(b)||{name:((M=v.properties)==null?void 0:M.name)||b};this.context.events.emit("point:click",{point:k,index:0,series:this,event:x})})}renderMapLabels(t,e,i){var l,h,f;const r=this.config.dataLabels||this.config.dataLabels;if(!(r!=null&&r.enabled))return;const o=((l=r.style)==null?void 0:l.fontSize)||kt,s=this.autoLabelColor(r.color||((h=r.style)==null?void 0:h.color)),a=this.labelHalo(),c=((f=r.filter)==null?void 0:f.property)==="hasData";this.mapGroup.selectAll(".katucharts-map-label").data(e).join("text").attr("class","katucharts-map-label").attr("transform",u=>{const d=t.centroid(u);return isFinite(d[0])?`translate(${d[0]},${d[1]})`:"translate(-9999,-9999)"}).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",o).attr("fill",s).style("pointer-events","none").style("text-shadow",a).text(u=>{var y,g,m,x,v;const d=this.getFeatureKey(u,i),p=this.dataMap.get(d);return c&&!p?"":r.formatter?r.formatter.call({point:p||{name:(y=u.properties)==null?void 0:y.name},series:{name:this.config.name},x:(g=u.properties)==null?void 0:g.name,y:(p==null?void 0:p.y)??(p==null?void 0:p.value)}):r.format?oe(Kt(r.format,{point:p||{name:(m=u.properties)==null?void 0:m.name},series:{name:this.config.name},x:(x=u.properties)==null?void 0:x.name,y:(p==null?void 0:p.y)??(p==null?void 0:p.value)})):(p==null?void 0:p.name)||((v=u.properties)==null?void 0:v.name)||""})}renderColorAxis(t,e,i){const{plotArea:r}=this.context,o=i.layout==="horizontal"?"bottom":"right",s=i.labels||{},a=i.title;o==="bottom"?this.renderHorizontalColorAxis(t,e,i,s,a):this.renderVerticalColorAxis(t,e,i,s,a)}renderVerticalColorAxis(t,e,i,r,o){var k,M;const{plotArea:s}=this.context,a=i.width??12,c=i.height??s.height*.5,l=s.width+15,h=(s.height-c)/2,f=60,u=this.group.append("g").attr("class","katucharts-map-color-axis"),d=u.append("defs"),p=`katucharts-map-grad-${Math.random().toString(36).slice(2,8)}`,y=d.append("linearGradient").attr("id",p).attr("x1","0%").attr("y1","100%").attr("x2","0%").attr("y2","0%");for(let C=0;C<=f;C++){const E=C/f,_=t+E*(e-t);y.append("stop").attr("offset",`${E*100}%`).attr("stop-color",this.colorScale(_))}u.append("rect").attr("x",l).attr("y",h).attr("width",a).attr("height",c).attr("fill",`url(#${p})`).attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);const g=((k=r.style)==null?void 0:k.fontSize)||kt,m=this.autoLabelColor((M=r.style)==null?void 0:M.color),x=r.formatter,v=C=>x?x.call({value:C}):String(Math.round(C));u.append("text").attr("x",l+a+4).attr("y",h+c).attr("font-size",g).attr("fill",m).attr("dominant-baseline","auto").text(v(t)),u.append("text").attr("x",l+a+4).attr("y",h).attr("font-size",g).attr("fill",m).attr("dominant-baseline","hanging").text(v(e));const b=(t+e)/2;u.append("text").attr("x",l+a+4).attr("y",h+c/2).attr("font-size",g).attr("fill",m).attr("dominant-baseline","middle").text(v(b)),o!=null&&o.text&&u.append("text").attr("x",l+a/2).attr("y",h-8).attr("text-anchor","middle").attr("font-size","10px").attr("fill",this.autoLabelColor()).text(o.text)}renderHorizontalColorAxis(t,e,i,r,o){var b,k;const{plotArea:s}=this.context,a=i.width??s.width*.5,c=i.height??12,l=(s.width-a)/2,h=s.height+25,f=60,u=this.group.append("g").attr("class","katucharts-map-color-axis"),d=u.append("defs"),p=`katucharts-map-grad-${Math.random().toString(36).slice(2,8)}`,y=d.append("linearGradient").attr("id",p).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");for(let M=0;M<=f;M++){const C=M/f,E=t+C*(e-t);y.append("stop").attr("offset",`${C*100}%`).attr("stop-color",this.colorScale(E))}u.append("rect").attr("x",l).attr("y",h).attr("width",a).attr("height",c).attr("fill",`url(#${p})`).attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);const g=((b=r.style)==null?void 0:b.fontSize)||kt,m=this.autoLabelColor((k=r.style)==null?void 0:k.color),x=r.formatter,v=M=>x?x.call({value:M}):String(Math.round(M));u.append("text").attr("x",l).attr("y",h+c+12).attr("text-anchor","start").attr("font-size",g).attr("fill",m).text(v(t)),u.append("text").attr("x",l+a).attr("y",h+c+12).attr("text-anchor","end").attr("font-size",g).attr("fill",m).text(v(e)),o!=null&&o.text&&u.append("text").attr("x",l+a/2).attr("y",h-6).attr("text-anchor","middle").attr("font-size","10px").attr("fill",this.autoLabelColor()).text(o.text)}setupMapNavigation(t,e){const{plotArea:i}=this.context,r=this.config.mapNavigation||{},o=r.enableButtons!==!1,s=r.enableMouseWheelZoom!==!1,a=r.enableDoubleClickZoom!==!1,c=r.enableDrag!==!1,l=r.maxZoom??16,h=i.width/2,f=i.height/2;this.zoomBehavior=kf().scaleExtent([1,l]).on("zoom",p=>{this.context.chartGroup.selectAll(".katucharts-mapzoom").attr("transform",p.transform)});const u=this.group.select(".katucharts-map-clip"),d=u.empty()?this.group:u;d.insert("rect",":first-child").attr("width",i.width).attr("height",i.height).attr("fill","none").style("pointer-events","all"),(s||a||c)&&(d.call(this.zoomBehavior),s||d.on("wheel.zoom",null),a||d.on("dblclick.zoom",null),c||(d.on("mousedown.zoom",null),d.on("touchstart.zoom",null))),o&&this.renderNavButtons(d,h,f)}renderNavButtons(t,e,i){var C,E;const{plotArea:r}=this.context,o=this.config.mapNavigation||{},s=o.buttonOptions||{},a=s.theme||{},c=o.buttons||{},l=24,h=4,f=10,u=l*2+h,d=s.align||"left",p=s.verticalAlign||"top",y=(d==="right"?r.width-l-f:f)+(s.x??0),g=(p==="bottom"?r.height-u-f:f)+(s.y??0),m=a.fill||"#ffffff",x=a.stroke||"#e0e0e0",v=a.style&&a.style.color||s.symbolStroke||"#3f3f46",b=this.group.append("g").attr("class","katucharts-map-nav"),k=[e,i],M=(_,T,I)=>{const L=b.append("g").style("cursor","pointer").on("click",I);return L.append("rect").attr("x",y).attr("y",_).attr("width",l).attr("height",l).attr("fill",m).attr("stroke",x).attr("stroke-width",1).attr("rx",4),L.append("text").attr("x",y+l/2).attr("y",_+l/2+1).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","17px").attr("fill",v).style("user-select","none").text(T),L.on("mouseover",function(){st(this).select("rect").attr("fill","#f5f5f5")}).on("mouseout",function(){st(this).select("rect").attr("fill",m)}),L};M(g,((C=c.zoomIn)==null?void 0:C.text)||"+",()=>{t.transition().duration(300).call(this.zoomBehavior.scaleBy,1.5,k)}),M(g+l+h,((E=c.zoomOut)==null?void 0:E.text)||"−",()=>{t.transition().duration(300).call(this.zoomBehavior.scaleBy,1/1.5,k)})}setupGlobeMode(t,e,i,r,o,s,a,c){const{plotArea:l}=this.context,h=l.width/2,f=l.height/2;this.globeProjection=t,this.globePathGen=e;const u=gl(t,l),d=c.options3d||{},p=d.oceanColor??"#d4f1f9",y=d.atmosphereColor??"rgba(100,180,255,0.15)",g=d.graticule!==!1,m=d.graticuleColor??"#ccc",x=d.graticuleOpacity??.4,v=d.autoRotate!==!1,b=d.rotateSpeed??.3,k=d.shadow!==!1,M=this.mapGroup.append("defs"),C=`katucharts-globe-glow-${Math.random().toString(36).slice(2,8)}`,E=M.append("radialGradient").attr("id",C);if(E.append("stop").attr("offset","70%").attr("stop-color",y),E.append("stop").attr("offset","100%").attr("stop-color","rgba(100,180,255,0)"),this.mapGroup.insert("circle",":first-child").attr("cx",h).attr("cy",f).attr("r",u+15).attr("fill",`url(#${C})`).attr("class","katucharts-globe-atmosphere"),k&&this.mapGroup.insert("ellipse",":first-child").attr("cx",h+8).attr("cy",f+u+18).attr("rx",u*.6).attr("ry",8).attr("fill","rgba(0,0,0,0.12)").attr("class","katucharts-globe-shadow"),this.mapGroup.insert("circle",".katucharts-map-feature").attr("cx",h).attr("cy",f).attr("r",u).attr("fill",p).attr("stroke","#999").attr("stroke-width",.5).attr("class","katucharts-globe-ocean"),g){const w=Nk().step([15,15]);this.mapGroup.insert("path",".katucharts-map-feature").datum(w()).attr("d",e).attr("fill","none").attr("stroke",m).attr("stroke-width",.3).attr("stroke-opacity",x).attr("class","katucharts-globe-graticule")}this.featurePaths.attr("d",e);const _=`katucharts-globe-spec-${Math.random().toString(36).slice(2,8)}`,T=M.append("radialGradient").attr("id",_).attr("cx","35%").attr("cy","25%");T.append("stop").attr("offset","0%").attr("stop-color","rgba(255,255,255,0.35)"),T.append("stop").attr("offset","50%").attr("stop-color","rgba(255,255,255,0.05)"),T.append("stop").attr("offset","100%").attr("stop-color","rgba(255,255,255,0)"),this.mapGroup.append("circle").attr("cx",h).attr("cy",f).attr("r",u).attr("fill",`url(#${_})`).style("pointer-events","none").attr("class","katucharts-globe-specular");const I=this;let L=null,P=v;const A=vf().on("start",w=>{const S=t.rotate();L=[S[0],S[1],w.x],I.autoRotateTimer&&(P=!0,I.autoRotateTimer.stop(),I.autoRotateTimer=null)}).on("drag",w=>{if(!L)return;const S=.4,$=(w.x-L[2])*S,R=L[0]+$,F=Math.max(-90,Math.min(90,L[1]-(w.y-w.subject.y)*S));t.rotate([R,F]),I.redrawGlobe()}).on("end",()=>{L=null,P&&v&&I.startAutoRotate(t,b)});this.group.call(A),this.group.style("cursor","grab"),this.group.on("wheel",w=>{w.preventDefault();const S=t.scale(),$=w.deltaY>0?.95:1.05,R=Math.max(u*.5,Math.min(u*8,S*$));t.scale(R),I.redrawGlobe()}),v&&this.startAutoRotate(t,b)}startAutoRotate(t,e){const i=this;this.autoRotateTimer&&(this.autoRotateTimer.stop(),this.autoRotateTimer=null);let r=0;this.autoRotateTimer=Zo(o=>{const s=r?Math.min(o-r,64):16;r=o;const a=t.rotate();t.rotate([a[0]+e*(s/16),a[1]]),i.redrawGlobe()})}redrawGlobe(){if(!this.globePathGen||!this.featurePaths||!this.globeProjection)return;const t=this.globeProjection,[e,i]=t.translate(),r=t.scale();this.featurePaths.attr("d",this.globePathGen),this.mapGroup.selectAll(".katucharts-globe-graticule").attr("d",this.globePathGen),this.mapGroup.select(".katucharts-globe-ocean").attr("cx",e).attr("cy",i).attr("r",r),this.mapGroup.select(".katucharts-globe-atmosphere").attr("cx",e).attr("cy",i).attr("r",r+15),this.mapGroup.select(".katucharts-globe-specular").attr("cx",e).attr("cy",i).attr("r",r),this.mapGroup.select(".katucharts-globe-shadow").attr("cx",e+8).attr("cy",i+r+18).attr("rx",r*.6),this.mapGroup.selectAll(".katucharts-map-label").attr("transform",o=>{const s=this.globePathGen.centroid(o);return isFinite(s[0])?`translate(${s[0]},${s[1]})`:"translate(-9999,-9999)"}).attr("display",o=>{const s=this.globePathGen.centroid(o);return isFinite(s[0])?null:"none"})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class EM extends Xt{constructor(t){super(t)}resolveMapData(){const t=this.config;if(t.mapData)return t.mapData;for(const e of this.context.allSeries||[]){const i=e.config;if(e!==this&&(i!=null&&i.mapData))return i.mapData}return null}render(){var v,b,k;const t=this.config,{plotArea:e}=this.context,i=this.resolveMapData();if(!i)return;const{projection:r,projName:o}=pl(i,t.projection,e,t.mapDataObject);dl(o,t)&&gl(r,e);const s=this.group.append("g").attr("class","katucharts-mapzoom katucharts-mappoint-layer"),a=t.marker||{},c=a.enabled!==!1,l=a.radius??5,h=a.lineColor??"#ffffff",f=a.lineWidth??1,u=t.color||this.getColor(),d=this.context.animate,p=t.dataLabels,y=!!(p!=null&&p.enabled),g=this.autoLabelColor((p==null?void 0:p.color)||((v=p==null?void 0:p.style)==null?void 0:v.color)),m=((b=p==null?void 0:p.style)==null?void 0:b.fontSize)||kt,x=((k=p==null?void 0:p.style)==null?void 0:k.fontWeight)||"600";this.data.forEach((M,C)=>{var w;M.name==null&&M.id!=null&&(M.name=M.id);const E=ml(M);if(!E)return;const _=r(E);if(!_||!isFinite(_[0])||!isFinite(_[1]))return;const[T,I]=_,L=M.color||u,P=((w=M.marker)==null?void 0:w.radius)??l,A=s.append("g").attr("class","katucharts-mappoint");if(c){const S=A.append("circle").attr("class","katucharts-mappoint-marker").attr("cx",T).attr("cy",I).attr("fill",L).attr("stroke",h).attr("stroke-width",f).style("cursor",t.cursor||"pointer").attr("r",d?0:P);d&&S.transition().duration(bt).delay(C*12).ease(pt).attr("r",P),S.on("mouseover",$=>{var R,F;st($.currentTarget).transition("hover").duration(Z).ease(j).attr("r",P*1.4),this.context.events.emit("point:mouseover",{point:M,index:C,series:this,event:$,plotX:T,plotY:I}),(F=(R=M.events)==null?void 0:R.mouseOver)==null||F.call(M,$)}).on("mouseout",$=>{var R,F;st($.currentTarget).transition("hover").duration(Z).ease(j).attr("r",P),this.context.events.emit("point:mouseout",{point:M,index:C,series:this,event:$}),(F=(R=M.events)==null?void 0:R.mouseOut)==null||F.call(M,$)}).on("click",$=>{var R,F,D,z,B,W,K;this.context.events.emit("point:click",{point:M,index:C,series:this,event:$}),(F=(R=M.events)==null?void 0:R.click)==null||F.call(M,$),(B=(z=(D=t.point)==null?void 0:D.events)==null?void 0:z.click)==null||B.call(M,$),(K=(W=t.events)==null?void 0:W.click)==null||K.call(this,$)})}if(y){const S=this.formatLabel(M,C);S&&s.append("text").attr("class","katucharts-mappoint-label").attr("x",T).attr("y",I-P-3).attr("text-anchor","middle").attr("dominant-baseline","auto").attr("font-size",m).attr("font-weight",x).attr("fill",g).style("pointer-events","none").style("text-shadow",this.labelHalo()).text(S)}})}formatLabel(t,e){const i=this.config.dataLabels,r={point:t,series:{name:this.config.name},x:t.id??t.name,y:t.y??t.value};return i!=null&&i.formatter?i.formatter.call(r):i!=null&&i.format?oe(Kt(i.format,r)):t.id||t.name||""}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class TM extends Xt{constructor(t){super(t)}resolveMapData(){const t=this.config;if(t.mapData)return t.mapData;for(const e of this.context.allSeries||[]){const i=e.config;if(e!==this&&(i!=null&&i.mapData))return i.mapData}return null}buildIdMap(){const t=new Map;for(const e of this.context.allSeries||[])if(e!==this)for(const i of e.data){const r=ml(i),o=i.id??i.name;o!=null&&r&&t.set(String(o),r)}return t}resolveEndpoint(t,e){return t==null?null:Array.isArray(t)&&typeof t[0]=="number"?[t[0],t[1]]:typeof t=="object"?ml(t):e.get(String(t))||null}render(){var g;const t=this.config,{plotArea:e}=this.context,i=this.resolveMapData();if(!i)return;const{projection:r,projName:o}=pl(i,t.projection,e,t.mapDataObject);dl(o,t)&&gl(r,e);const s=this.buildIdMap(),a=this.group.append("g").attr("class","katucharts-mapzoom katucharts-flowmap-layer"),c=t.color||this.getColor(),l=t.fillOpacity??.5,h=t.curveFactor??.3,f=((g=t.markerEnd)==null?void 0:g.enabled)!==!1,u=this.context.animate,d=this.data.map(m=>m.weight??m.y??m.value??1),p=Math.max(...d,1),y=t.width!=null?t.width<=1?t.width*40:t.width:16;this.data.forEach((m,x)=>{const v=m,b=this.resolveEndpoint(v.from,s),k=this.resolveEndpoint(v.to,s);if(!b||!k)return;v.name==null&&typeof v.from=="string"&&typeof v.to=="string"&&(v.name=`${v.from} → ${v.to}`);const M=r(b),C=r(k);if(!M||!C||!isFinite(M[0])||!isFinite(C[0]))return;const E=v.weight??v.y??v.value??1,_=Math.max(2,y*(E/p)),T=v.color||c,{d:I,mid:L,tip:P,tipAngle:A}=this.buildFlowPath(M,C,_,h),w=a.append("path").attr("class","katucharts-flowmap-link").attr("d",I).attr("fill",T).attr("fill-opacity",u?0:l).attr("stroke","none").style("cursor",t.cursor||"pointer");if(u&&w.transition().duration(bt).delay(x*30).ease(pt).attr("fill-opacity",l),f){const S=_*1.1+3,$=a.append("path").attr("class","katucharts-flowmap-arrow").attr("d",this.arrowHead(P,A,S)).attr("fill",T).attr("fill-opacity",u?0:l).style("pointer-events","none");u&&$.transition().duration(bt).delay(x*30).ease(pt).attr("fill-opacity",l)}w.on("mouseover",S=>{var $,R;st(S.currentTarget).transition("hover").duration(Z).ease(j).attr("fill-opacity",Math.min(1,l+.3)),this.context.events.emit("point:mouseover",{point:m,index:x,series:this,event:S,plotX:L[0],plotY:L[1]}),(R=($=v.events)==null?void 0:$.mouseOver)==null||R.call(m,S)}).on("mouseout",S=>{var $,R;st(S.currentTarget).transition("hover").duration(Z).ease(j).attr("fill-opacity",l),this.context.events.emit("point:mouseout",{point:m,index:x,series:this,event:S}),(R=($=v.events)==null?void 0:$.mouseOut)==null||R.call(m,S)}).on("click",S=>{var $,R,F,D,z,B,W;this.context.events.emit("point:click",{point:m,index:x,series:this,event:S}),(R=($=v.events)==null?void 0:$.click)==null||R.call(m,S),(z=(D=(F=t.point)==null?void 0:F.events)==null?void 0:D.click)==null||z.call(m,S),(W=(B=t.events)==null?void 0:B.click)==null||W.call(this,S)})})}buildFlowPath(t,e,i,r){const o=e[0]-t[0],s=e[1]-t[1],a=Math.hypot(o,s)||1,c=-s/a,l=o/a,h=[(t[0]+e[0])/2+c*r*a,(t[1]+e[1])/2+l*r*a],f=24,u=Math.max(.6,i*.12),d=i/2,p=[],y=[];let g=t;for(let k=0;k<=f;k++){const M=k/f,C=1-M,E=C*C*t[0]+2*C*M*h[0]+M*M*e[0],_=C*C*t[1]+2*C*M*h[1]+M*M*e[1],T=E-g[0],I=_-g[1],L=Math.hypot(T,I)||1,P=-I/L,A=T/L,w=u+(d-u)*M;p.push([E+P*w,_+A*w]),y.push([E-P*w,_-A*w]),g=[E,_]}const m=.25*t[0]+.5*h[0]+.25*e[0],x=.25*t[1]+.5*h[1]+.25*e[1],v=Math.atan2(e[1]-h[1],e[0]-h[0]);return{d:"M"+p.map(k=>`${k[0].toFixed(2)},${k[1].toFixed(2)}`).join("L")+"L"+y.reverse().map(k=>`${k[0].toFixed(2)},${k[1].toFixed(2)}`).join("L")+"Z",mid:[m,x],tip:e,tipAngle:v}}arrowHead(t,e,i){const r=e,o=r+Math.PI,s=.5,a=[t[0]+Math.cos(r)*i*.6,t[1]+Math.sin(r)*i*.6],c=[t[0]+Math.cos(o+s)*i,t[1]+Math.sin(o+s)*i],l=[t[0]+Math.cos(o-s)*i,t[1]+Math.sin(o-s)*i];return`M${a[0].toFixed(2)},${a[1].toFixed(2)}L${c[0].toFixed(2)},${c[1].toFixed(2)}L${l[0].toFixed(2)},${l[1].toFixed(2)}Z`}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const Sp=["#5b9bd5","#ed7d31","#70ad47","#9e5fa0","#ffc000","#44546a"],LM=/^(.+?)\s+(\([^()]+\))\s*$/,_p=1.15;function Cp(n,t,e){for(;n.firstChild;)n.removeChild(n.firstChild);let i;if(t.includes(`
6
+ `,s=(i==null?void 0:i.decimalPoint)??".",a=["Category"];t.forEach(d=>{if(i!=null&&i.columnHeaderFormatter){const p=i.columnHeaderFormatter(d,"y",1);a.push(p===!1?d.name||"Series":p)}else a.push(d.name||"Series")});const c=new Set;for(const d of t)for(const p of d.data)c.add(p.name??p.x??"");const l=d=>{if(d==null)return"";const p=String(d);return s!=="."&&typeof d=="number"?p.replace(".",s):p},h=[];for(const d of c){const p=[String(d)];for(const y of t){const g=y.data.find(m=>(m.name??m.x)===d);p.push((g==null?void 0:g.y)!==void 0&&g.y!==null?l(g.y):"")}h.push(p)}const f=[a.map(d=>ns(d,r)).join(r),...h.map(d=>d.map(p=>ns(p,r)).join(r))].join(o),u=new Blob([f],{type:"text/csv;charset=utf-8"});Kt.downloadBlob(u,`${e}.csv`)}static getCSV(t,e){const i=(e==null?void 0:e.itemDelimiter)??",",r=(e==null?void 0:e.lineDelimiter)??`
7
+ `,o=(e==null?void 0:e.decimalPoint)??".",s=["Category"];t.forEach(h=>{if(e!=null&&e.columnHeaderFormatter){const f=e.columnHeaderFormatter(h,"y",1);s.push(f===!1?h.name||"Series":f)}else s.push(h.name||"Series")});const a=new Set;for(const h of t)for(const f of h.data)a.add(f.name??f.x??"");const c=h=>{if(h==null)return"";const f=String(h);return o!=="."&&typeof h=="number"?f.replace(".",o):f},l=[];for(const h of a){const f=[String(h)];for(const u of t){const d=u.data.find(p=>(p.name??p.x)===h);f.push((d==null?void 0:d.y)!==void 0&&d.y!==null?c(d.y):"")}l.push(f)}return[s.map(h=>ns(h,i)).join(i),...l.map(h=>h.map(f=>ns(f,i)).join(i))].join(r)}static getDataRows(t){const e=["Category"];t.forEach(o=>e.push(o.name||"Series"));const i=new Set;for(const o of t)for(const s of o.data)i.add(s.name??s.x??"");const r=[e];for(const o of i){const s=[o!=null?String(o):""];for(const a of t){const c=a.data.find(l=>(l.name??l.x)===o);s.push((c==null?void 0:c.y)??null)}r.push(s)}return r}static getTable(t,e){const i=Kt.getDataRows(t);if(i.length===0)return"<table></table>";const r=i[0],o=i.slice(1);let s='<table class="katucharts-data-table">';e&&typeof e=="string"&&(s+=`<caption>${Qn(e)}</caption>`),s+="<thead><tr>";for(const a of r)s+=`<th>${Qn(a??"")}</th>`;s+="</tr></thead><tbody>";for(const a of o){s+="<tr>";for(const c of a)s+=`<td>${Qn(c??"")}</td>`;s+="</tr>"}return s+="</tbody></table>",s}static viewDataTable(t,e,i){let r=e.querySelector(".katucharts-data-table-container");if(r)return r.remove(),null;r=document.createElement("div"),r.className="katucharts-data-table-container",Object.assign(r.style,{position:"relative",maxHeight:"300px",overflow:"auto",border:"1px solid #ccc",marginTop:"10px",fontSize:"11px"});const o=Kt.getTable(t,i);r.innerHTML=o;const s=r.querySelector("table");return s&&(Object.assign(s.style,{width:"100%",borderCollapse:"collapse"}),s.querySelectorAll("th, td").forEach(a=>{Object.assign(a.style,{padding:"4px 8px",borderBottom:"1px solid #e6e6e6",textAlign:"left"})}),s.querySelectorAll("th").forEach(a=>{Object.assign(a.style,{backgroundColor:"#f7f7f7",fontWeight:"bold"})})),e.appendChild(r),r}static downloadBlob(t,e){const i=URL.createObjectURL(t),r=document.createElement("a");r.href=i,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i)}};Kt.INLINE_PROPS=["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","text-decoration","visibility","display"],Kt.JSPDF_CDN_URL="https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js",Kt.jsPDFLoader=null;let oe=Kt;class Uv{constructor(t){this.host=t}getSVG(){return this.host.getRenderer().getSerializedSVG()}getInlinedSVG(){const t=this.host.getRenderer(),e=t.getSVGNode();return e?oe.inlineStyles(e):t.getSerializedSVG()}handleExportAction(t){const e=this.host.getOptions(),i=this.getInlinedSVG(),r=e.exporting.filename??"chart",o=e.exporting.scale??2;switch(t){case"downloadPNG":oe.exportPNG(i,r,o).catch(s=>console.warn("KatuCharts: PNG export failed.",s));break;case"downloadJPEG":oe.exportJPEG(i,r,o).catch(s=>console.warn("KatuCharts: JPEG export failed.",s));break;case"downloadSVG":oe.exportSVG(i,r);break;case"downloadPDF":oe.exportPDF(i,r,o).catch(s=>console.warn("KatuCharts: PDF export failed.",s));break;case"downloadCSV":oe.exportCSV(this.getSeriesDataForExport(),r,e.exporting.csv);break;case"downloadXLS":this.exportXLS(r);break;case"viewDataTable":oe.viewDataTable(this.getSeriesDataForExport(),this.host.getContainer(),e.exporting.tableCaption);break;case"viewFullScreen":this.toggleFullScreen();break;case"printChart":this.host.fireEvent("beforePrint"),oe.print(i,e.exporting.printMaxWidth),this.host.fireEvent("afterPrint");break}}toggleFullScreen(){var m;const t=this.host.getContainer();if(!t)return;const e=t.ownerDocument,i=e.defaultView||window;if(e.fullscreenElement===t||e.webkitFullscreenElement===t){e.exitFullscreen?e.exitFullscreen():e.webkitExitFullscreen&&e.webkitExitFullscreen();return}const o=t.style,s={width:o.width,height:o.height,maxWidth:o.maxWidth,maxHeight:o.maxHeight,background:o.background},a=this.host.getOptions().chart.backgroundColor||"#fff";o.background=a,o.width="100vw",o.height="100vh",o.maxWidth="none",o.maxHeight="none",this.host.disconnectResizeObserver();const c=this.host.getViewportSize(),l=()=>{o.width=s.width,o.height=s.height,o.maxWidth=s.maxWidth,o.maxHeight=s.maxHeight,o.background=s.background},h=()=>{this.host.fitToViewport(c.width,c.height)};let f=null;const u=()=>{const b=i.innerWidth,x=i.innerHeight;!b||!x||this.host.fitToViewport(b,x)},d=()=>{e.exitFullscreen?e.exitFullscreen():e.webkitExitFullscreen&&e.webkitExitFullscreen()},p=()=>{i.removeEventListener("resize",u),e.removeEventListener("fullscreenchange",y),e.removeEventListener("webkitfullscreenchange",y)},y=()=>{e.fullscreenElement===t||e.webkitFullscreenElement===t?(f=e.createElement("button"),f.textContent="✕",Object.assign(f.style,{position:"absolute",top:"10px",left:"50%",transform:"translateX(-50%)",zIndex:"10000",width:"32px",height:"32px",border:"none",borderRadius:"50%",background:"rgba(0,0,0,0.4)",color:"#fff",fontSize:"18px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:"1",padding:"0"}),f.addEventListener("mouseenter",()=>{f&&(f.style.background="rgba(0,0,0,0.7)")}),f.addEventListener("mouseleave",()=>{f&&(f.style.background="rgba(0,0,0,0.4)")}),f.addEventListener("click",d),t.appendChild(f),u(),requestAnimationFrame(u),i.addEventListener("resize",u)):(p(),f&&(f.remove(),f=null),l(),h(),requestAnimationFrame(()=>{this.host.observeResizeObserver(),this.host.fireEvent("exitFullScreen")}))};e.addEventListener("fullscreenchange",y),e.addEventListener("webkitfullscreenchange",y);const g=()=>{p(),l(),this.host.getRenderer().svg.style("width",null).style("height",null),h(),this.host.observeResizeObserver()};try{const b=t.requestFullscreen?t.requestFullscreen():(m=t.webkitRequestFullscreen)==null?void 0:m.call(t);b&&typeof b.catch=="function"&&b.catch(g),this.host.fireEvent("enterFullScreen")}catch{g()}}getSeriesDataForExport(){return this.host.getSeriesInstances().map(t=>({name:t.config.name||`Series ${t.config.index+1}`,data:t.data.map(e=>({x:e.x,y:e.y,name:e.name}))}))}exportXLS(t){const e=oe.getDataRows(this.getSeriesDataForExport());let i='<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:spreadsheet" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"/></head><body><table>';for(const o of e){i+="<tr>";for(const s of o)i+=`<td>${s??""}</td>`;i+="</tr>"}i+="</table></body></html>";const r=new Blob([i],{type:"application/vnd.ms-excel"});oe.downloadBlob(r,`${t}.xls`)}getCSV(){return oe.getCSV(this.getSeriesDataForExport(),this.host.getOptions().exporting.csv)}getTable(){return oe.getTable(this.getSeriesDataForExport(),this.host.getOptions().exporting.tableCaption)}getDataRows(){return oe.getDataRows(this.getSeriesDataForExport())}exportChart(t){const e={...this.host.getOptions().exporting,...t},i=this.getInlinedSVG(),r=e.filename??"chart",o=e.scale??2;switch(e.type){case"image/jpeg":oe.exportJPEG(i,r,o);break;case"image/svg+xml":oe.exportSVG(i,r);break;case"application/pdf":oe.exportPDF(i,r,o);break;case"image/png":default:oe.exportPNG(i,r,o);break}}print(){this.host.fireEvent("beforePrint");const t=this.getInlinedSVG();oe.print(t,this.host.getOptions().exporting.printMaxWidth),this.host.fireEvent("afterPrint")}optionsToExternal(){const t=this.host.getOptions();return{chart:t.chart,title:t.title,subtitle:t.subtitle,xAxis:t.xAxis,yAxis:t.yAxis,colorAxis:t.colorAxis,series:t.series,tooltip:t.tooltip,legend:t.legend,plotOptions:t.plotOptions,credits:t.credits,colors:t.colors}}}class jv{constructor(t){this.host=t}updateTooltipCategories(){const t=this.host.getTooltip();if(!t)return;const e=this.host.getXAxes()[0];e&&(e.config.type==="category"||e.config.categories)&&t.setCategories(e.config.categories||[]),t.setDatetimeAxis(!!e&&e.config.type==="datetime")}updateAxesDomains(){const t=Li,e=this.host.getOptions(),i=this.host.getLayout(),r=this.host.getSeriesInstances(),o=this.host.getXAxes(),s=this.host.getYAxes();for(let a=0;a<o.length;a++){const c=o[a];if(c.config.type==="category"||c.config.categories&&c.config.categories.length>0){const u=r.filter((p,y)=>p.visible&&e.series[y]._xAxisIndex===a&&!t.has(p.config._internalType)),d=(c.config.categories&&c.config.categories.length>0?c.config.categories:null)||(u.length>0?u[0].getCategories():void 0);d&&d.length>0&&c.updateDomain(d);continue}const l=r.filter((u,d)=>u.visible&&e.series[d]._xAxisIndex===a&&!t.has(u.config._internalType));if(l.length===0)continue;let h=1/0,f=-1/0;for(const u of l){const d=u.getDataExtents();h=Math.min(h,d.xMin),f=Math.max(f,d.xMax)}if(isFinite(h)&&isFinite(f)){const u=e.series.filter((p,y)=>{var g;return((g=r[y])==null?void 0:g.visible)&&p._xAxisIndex===a&&!t.has(p._internalType)}),d=this.computeBubbleRadiusPadding(u,i.plotArea.width);c.updateDomain({min:h,max:f,extraMinPadding:d,extraMaxPadding:d})}}for(let a=0;a<s.length;a++){const c=s[a],l=e.series.filter((b,x)=>{var v;return((v=r[x])==null?void 0:v.visible)&&b._yAxisIndex===a&&!t.has(b._internalType)}),h=r.filter((b,x)=>b.visible&&e.series[x]._yAxisIndex===a&&!t.has(b.config._internalType));if(h.length===0)continue;let f=1/0,u=-1/0;const d=new Map,p=new Map;for(let b=0;b<h.length;b++){const x=h[b],v=l[b];if(v!=null&&v.stacking){const k=as(v);d.has(k)||(d.set(k,new Map),p.set(k,new Map)),_r(x.data,d.get(k),p.get(k))}else{const k=x.getDataExtents();f=Math.min(f,k.yMin),u=Math.max(u,k.yMax)}}const y=l.some(b=>(b==null?void 0:b.stacking)==="percent"),g=[...p.values()].some(b=>[...b.values()].some(x=>x<0));if(y)f=g?-100:0,u=100,c.config.min=f,c.config.max=100;else for(const b of d.keys()){for(const x of d.get(b).values())u=Math.max(u,x,0);for(const x of p.get(b).values())f=Math.min(f,x,0)}if(l.some(b=>Ag.has(b._internalType))&&c.config.min===void 0&&(f=Math.min(f,0),u=Math.max(u,0)),isFinite(f)&&isFinite(u)){const b=this.computeBubbleRadiusPadding(l,i.plotArea.height);c.updateDomain({min:f,max:u,extraMinPadding:b,extraMaxPadding:b})}}}computeBubbleRadiusPadding(t,e){const i=t.filter(s=>s&&s._internalType==="bubble");if(i.length===0||e<=0)return 0;const r=this.host.getLayout().plotArea;let o=0;for(const s of i){const a=s.maxSize;let c;typeof a=="number"?c=a:typeof a=="string"&&a.endsWith("%")?c=Math.min(r.width,r.height)*parseFloat(a)/100/2:c=30,o=Math.max(o,c)}return o/Math.max(e-2*o,1)}renderAxes(){const t=this.host.getAxisGroup(),e=this.host.getLayout();if(t.selectAll("*").remove(),!Js(this.host.getOptions().series)){for(const i of this.host.getXAxes())i.config.showEmpty===!1&&!this.hasSeriesForAxis(i,!0)||i.render(t,e.plotArea);for(const i of this.host.getYAxes())i.config.showEmpty===!1&&!this.hasSeriesForAxis(i,!1)||i.render(t,e.plotArea);this.setupAxisLabelHover()}}setupAxisLabelHover(){const t=this.host.getXAxes()[0];if(!t)return;const i=this.host.getAxisGroup().select(".katucharts-axis-x");if(i.empty())return;const r=i.selectAll(".tick"),o=this.host.getOptions(),s=this.host.getSeriesInstances(),a=this.host.getYAxes(),c=this.host.getEvents();r.each(function(){const l=st(this),h=l.select("text");if(h.empty())return;const f=h.node().getBBox();l.insert("rect","text").attr("x",f.x-4).attr("y",f.y-2).attr("width",f.width+8).attr("height",f.height+4).attr("fill","transparent").attr("class","katucharts-tick-hitarea")}),r.style("cursor","pointer").on("mouseover",function(l){var y;const h=this.__data__,f=typeof h=="string"?((y=t.config.categories)==null?void 0:y.indexOf(h))??-1:typeof h=="number"?h:-1;if(f<0)return;const u=!!o.chart.inverted,d=t.getPixelForValue(h),p=[];for(const g of s){if(!g.visible)continue;const m=g.data.find(b=>(b.x??0)===f);if(m&&m.y!==null&&m.y!==void 0){const x=a[0].getPixelForValue(m.y??0);p.push({point:m,series:g,plotX:u?x:d,plotY:u?d:x})}}if(p.length>0){const g=p[0];c.emit("point:mouseover",{point:{...g.point,matchingPoints:p},index:f,series:g.series,event:l,plotX:g.plotX,plotY:g.plotY})}for(const g of s){if(!g.visible)continue;const m=g.group;if(!m)continue;m.selectAll(".katucharts-column, .katucharts-bar, .katucharts-marker, .katucharts-bubble, .katucharts-scatter-point").each(function(x){const v=st(this);((x==null?void 0:x.x)??-1)===f?v.attr("filter","brightness(1.15)"):v.transition().duration(100).attr("opacity",.3)})}}).on("mouseout",function(){for(const l of s){if(!l.visible)continue;const h=l.group;h&&h.selectAll(".katucharts-column, .katucharts-bar, .katucharts-marker, .katucharts-bubble, .katucharts-scatter-point").interrupt().attr("opacity",null).attr("filter",null)}c.emit("point:mouseout",{point:{},index:-1,series:null,event:null})})}hasSeriesForAxis(t,e){const i=this.host.getOptions();return this.host.getSeriesInstances().some((r,o)=>{const s=i.series[o],a=e?s._xAxisIndex:s._yAxisIndex;return r.visible&&a===t.config.index})}}class wf{constructor(t,e,i){if(this.stack=[],this.breadcrumbsEl=null,this.container=null,this.config=t,this.events=e,this.container=i||null,this.drilldownMap=new Map,t.series)for(const r of t.series)r.id&&this.drilldownMap.set(r.id,r);this.pointClickHandler=r=>{const o=r.point.drilldown;o&&this.drilldownMap.has(o)&&this.drillDown(o,r)},e.on("point:click",this.pointClickHandler)}addSeriesAsDrilldown(t,e){e.id&&this.drilldownMap.set(e.id,e);const i=t.drilldown||e.id;i&&this.drillDown(i,{point:t,series:{}})}drillDown(t,e){var r,o;const i=this.drilldownMap.get(t);i&&(this.stack.push({seriesOptions:(r=e.series)!=null&&r.config?[e.series.config]:[],title:(o=e.point)==null?void 0:o.name}),this.events.emit("drilldown:drilldown",{point:e.point,seriesOptions:i}),this.updateBreadcrumbs())}drillUp(){const t=this.stack.pop();t&&(this.events.emit("drilldown:drillup",t),this.updateBreadcrumbs())}drillUpToLevel(t){for(;this.stack.length>t;)this.drillUp()}hasLevels(){return this.stack.length>0}getCurrentLevel(){return this.stack.length}get breadcrumbsConfig(){const t=this.config.breadcrumbs;return t&&typeof t=="object"?t:{}}isBreadcrumbsEnabled(){const t=this.config.breadcrumbs;return!(t===!1||t&&typeof t=="object"&&t.enabled===!1)}updateBreadcrumbs(){var u,d,p,y,g,m,b,x;if(!this.container||!this.isBreadcrumbsEnabled())return;const t=this.breadcrumbsConfig,e=t.floating!==!1;if(!this.breadcrumbsEl){this.breadcrumbsEl=document.createElement("div"),this.breadcrumbsEl.className="katucharts-breadcrumbs";const v=t.position||{};e&&getComputedStyle(this.container).position==="static"&&(this.container.style.position="relative"),Object.assign(this.breadcrumbsEl.style,{position:e?"absolute":"relative",display:"flex",alignItems:"center",gap:"6px",padding:"3px 10px",borderRadius:"999px",fontSize:((u=t.style)==null?void 0:u.fontSize)||"12px",fontWeight:((d=t.style)==null?void 0:d.fontWeight)||"500",lineHeight:"1.4",color:((p=t.style)==null?void 0:p.color)||"#1b1a15",background:((y=t.style)==null?void 0:y.background)||"rgba(255,255,255,0.86)",boxShadow:((g=t.style)==null?void 0:g.boxShadow)||"0 1px 3px rgba(27,26,21,0.18)",zIndex:"10",top:e?`${v.y??8}px`:"",left:e?`${v.x??8}px`:"",userSelect:"none"}),this.container.appendChild(this.breadcrumbsEl)}if(this.breadcrumbsEl.innerHTML="",this.stack.length===0){this.breadcrumbsEl.style.display="none";return}this.breadcrumbsEl.style.display="flex";const i=((m=t.style)==null?void 0:m.linkColor)||"#003399",r=((b=t.separator)==null?void 0:b.text)??"/",o=((x=t.separator)==null?void 0:x.style)||{},s=t.showFullPath!==!1,a=t.showBackButton!==!1,c=t.rootText??"Main",l=v=>{const k=document.createElement("span");k.textContent="◀",k.setAttribute("role","button"),k.setAttribute("aria-label","Drill up"),Object.assign(k.style,{cursor:"pointer",color:i,fontSize:"0.8em",lineHeight:"1",transition:"opacity 120ms ease"}),k.addEventListener("mouseenter",()=>{k.style.opacity="0.55"}),k.addEventListener("mouseleave",()=>{k.style.opacity="1"}),k.addEventListener("click",v),this.breadcrumbsEl.appendChild(k)},h=(v,k,M)=>{const C=document.createElement("span");C.textContent=v,M&&(Object.assign(C.style,{cursor:"pointer",color:i,transition:"opacity 120ms ease"}),C.addEventListener("mouseenter",()=>{C.style.textDecoration="underline"}),C.addEventListener("mouseleave",()=>{C.style.textDecoration="none"}),C.addEventListener("click",()=>{var E;(E=t.events)!=null&&E.click&&t.events.click.call(this,{level:k}),this.drillUpToLevel(k)})),this.breadcrumbsEl.appendChild(C)},f=()=>{const v=document.createElement("span");v.textContent=r,v.style.opacity="0.55",o.color&&(v.style.color=o.color),this.breadcrumbsEl.appendChild(v)};if(s){a&&l(()=>this.drillUp()),h(c,0,!0);for(let v=0;v<this.stack.length;v++){f();const k=v===this.stack.length-1,M=this.getCrumbLabel(v);h(M,v+1,!k)}}else{l(()=>this.drillUp());const v=document.createElement("span");v.textContent="Back",v.style.cursor="pointer",v.style.color=i,v.addEventListener("click",()=>this.drillUp()),this.breadcrumbsEl.appendChild(v)}}getCrumbLabel(t){const e=this.stack[t],i=this.breadcrumbsConfig;return i.formatter?i.formatter.call({level:t,levelOptions:e}):e.title||`Level ${t+1}`}destroy(){this.events.off("point:click",this.pointClickHandler),this.breadcrumbsEl&&(this.breadcrumbsEl.remove(),this.breadcrumbsEl=null)}}const qv={passive:!1},Cr={capture:!0,passive:!1};function fc(n){n.stopImmediatePropagation()}function Gi(n){n.preventDefault(),n.stopImmediatePropagation()}function dc(n){var t=n.document.documentElement,e=st(n).on("dragstart.drag",Gi,Cr);"onselectstart"in t?e.on("selectstart.drag",Gi,Cr):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function pc(n,t){var e=n.document.documentElement,i=st(n).on("dragstart.drag",null);t&&(i.on("click.drag",Gi,Cr),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in e?i.on("selectstart.drag",null):(e.style.MozUserSelect=e.__noselect,delete e.__noselect)}const cs=n=>()=>n;function gc(n,{sourceEvent:t,subject:e,target:i,identifier:r,active:o,x:s,y:a,dx:c,dy:l,dispatch:h}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:h}})}gc.prototype.on=function(){var n=this._.on.apply(this._,arguments);return n===this._?this:n};function Zv(n){return!n.ctrlKey&&!n.button}function Kv(){return this.parentNode}function Jv(n,t){return t??{x:n.x,y:n.y}}function Qv(){return navigator.maxTouchPoints||"ontouchstart"in this}function kf(){var n=Zv,t=Kv,e=Jv,i=Qv,r={},o=Ni("start","drag","end"),s=0,a,c,l,h,f=0;function u(v){v.on("mousedown.drag",d).filter(i).on("touchstart.drag",g).on("touchmove.drag",m,qv).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(v,k){if(!(h||!n.call(this,v,k))){var M=x(this,t.call(this,v,k),v,k,"mouse");M&&(st(v.view).on("mousemove.drag",p,Cr).on("mouseup.drag",y,Cr),dc(v.view),fc(v),l=!1,a=v.clientX,c=v.clientY,M("start",v))}}function p(v){if(Gi(v),!l){var k=v.clientX-a,M=v.clientY-c;l=k*k+M*M>f}r.mouse("drag",v)}function y(v){st(v.view).on("mousemove.drag mouseup.drag",null),pc(v.view,l),Gi(v),r.mouse("end",v)}function g(v,k){if(n.call(this,v,k)){var M=v.changedTouches,C=t.call(this,v,k),E=M.length,_,T;for(_=0;_<E;++_)(T=x(this,C,v,k,M[_].identifier,M[_]))&&(fc(v),T("start",v,M[_]))}}function m(v){var k=v.changedTouches,M=k.length,C,E;for(C=0;C<M;++C)(E=r[k[C].identifier])&&(Gi(v),E("drag",v,k[C]))}function b(v){var k=v.changedTouches,M=k.length,C,E;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),C=0;C<M;++C)(E=r[k[C].identifier])&&(fc(v),E("end",v,k[C]))}function x(v,k,M,C,E,_){var T=o.copy(),I=mn(_||M,k),L,P,A;if((A=e.call(v,new gc("beforestart",{sourceEvent:M,target:u,identifier:E,active:s,x:I[0],y:I[1],dx:0,dy:0,dispatch:T}),C))!=null)return L=A.x-I[0]||0,P=A.y-I[1]||0,function w(S,$,R){var F=I,D;switch(S){case"start":r[E]=w,D=s++;break;case"end":delete r[E],--s;case"drag":I=mn(R||$,k),D=s;break}T.call(S,v,new gc(S,{sourceEvent:$,subject:A,target:u,identifier:E,active:D,x:I[0]+L,y:I[1]+P,dx:I[0]-F[0],dy:I[1]-F[1],dispatch:T}),C)}}return u.filter=function(v){return arguments.length?(n=typeof v=="function"?v:cs(!!v),u):n},u.container=function(v){return arguments.length?(t=typeof v=="function"?v:cs(v),u):t},u.subject=function(v){return arguments.length?(e=typeof v=="function"?v:cs(v),u):e},u.touchable=function(v){return arguments.length?(i=typeof v=="function"?v:cs(!!v),u):i},u.on=function(){var v=o.on.apply(o,arguments);return v===o?u:v},u.clickDistance=function(v){return arguments.length?(f=(v=+v)*v,u):Math.sqrt(f)},u}const ls=n=>()=>n;function t2(n,{sourceEvent:t,target:e,transform:i,dispatch:r}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:r}})}function Nn(n,t,e){this.k=n,this.x=t,this.y=e}Nn.prototype={constructor:Nn,scale:function(n){return n===1?this:new Nn(this.k*n,this.x,this.y)},translate:function(n,t){return n===0&t===0?this:new Nn(this.k,this.x+this.k*n,this.y+this.k*t)},apply:function(n){return[n[0]*this.k+this.x,n[1]*this.k+this.y]},applyX:function(n){return n*this.k+this.x},applyY:function(n){return n*this.k+this.y},invert:function(n){return[(n[0]-this.x)/this.k,(n[1]-this.y)/this.k]},invertX:function(n){return(n-this.x)/this.k},invertY:function(n){return(n-this.y)/this.k},rescaleX:function(n){return n.copy().domain(n.range().map(this.invertX,this).map(n.invert,n))},rescaleY:function(n){return n.copy().domain(n.range().map(this.invertY,this).map(n.invert,n))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Pr=new Nn(1,0,0);Nn.prototype;function mc(n){n.stopImmediatePropagation()}function Er(n){n.preventDefault(),n.stopImmediatePropagation()}function e2(n){return(!n.ctrlKey||n.type==="wheel")&&!n.button}function n2(){var n=this;return n instanceof SVGElement?(n=n.ownerSVGElement||n,n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]):[[0,0],[n.clientWidth,n.clientHeight]]}function Mf(){return this.__zoom||Pr}function i2(n){return-n.deltaY*(n.deltaMode===1?.05:n.deltaMode?1:.002)*(n.ctrlKey?10:1)}function r2(){return navigator.maxTouchPoints||"ontouchstart"in this}function o2(n,t,e){var i=n.invertX(t[0][0])-e[0][0],r=n.invertX(t[1][0])-e[1][0],o=n.invertY(t[0][1])-e[0][1],s=n.invertY(t[1][1])-e[1][1];return n.translate(r>i?(i+r)/2:Math.min(0,i)||Math.max(0,r),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function Af(){var n=e2,t=n2,e=o2,i=i2,r=r2,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=ax,l=Ni("start","zoom","end"),h,f,u,d=500,p=150,y=0,g=10;function m(A){A.property("__zoom",Mf).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",_).on("dblclick.zoom",T).filter(r).on("touchstart.zoom",I).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(A,w,S,$){var R=A.selection?A.selection():A;R.property("__zoom",Mf),A!==R?k(A,w,S,$):R.interrupt().each(function(){M(this,arguments).event($).start().zoom(null,typeof w=="function"?w.apply(this,arguments):w).end()})},m.scaleBy=function(A,w,S,$){m.scaleTo(A,function(){var R=this.__zoom.k,F=typeof w=="function"?w.apply(this,arguments):w;return R*F},S,$)},m.scaleTo=function(A,w,S,$){m.transform(A,function(){var R=t.apply(this,arguments),F=this.__zoom,D=S==null?v(R):typeof S=="function"?S.apply(this,arguments):S,z=F.invert(D),B=typeof w=="function"?w.apply(this,arguments):w;return e(x(b(F,B),D,z),R,s)},S,$)},m.translateBy=function(A,w,S,$){m.transform(A,function(){return e(this.__zoom.translate(typeof w=="function"?w.apply(this,arguments):w,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),s)},null,$)},m.translateTo=function(A,w,S,$,R){m.transform(A,function(){var F=t.apply(this,arguments),D=this.__zoom,z=$==null?v(F):typeof $=="function"?$.apply(this,arguments):$;return e(Pr.translate(z[0],z[1]).scale(D.k).translate(typeof w=="function"?-w.apply(this,arguments):-w,typeof S=="function"?-S.apply(this,arguments):-S),F,s)},$,R)};function b(A,w){return w=Math.max(o[0],Math.min(o[1],w)),w===A.k?A:new Nn(w,A.x,A.y)}function x(A,w,S){var $=w[0]-S[0]*A.k,R=w[1]-S[1]*A.k;return $===A.x&&R===A.y?A:new Nn(A.k,$,R)}function v(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function k(A,w,S,$){A.on("start.zoom",function(){M(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event($).end()}).tween("zoom",function(){var R=this,F=arguments,D=M(R,F).event($),z=t.apply(R,F),B=S==null?v(z):typeof S=="function"?S.apply(R,F):S,N=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),K=R.__zoom,V=typeof w=="function"?w.apply(R,F):w,G=c(K.invert(B).concat(N/K.k),V.invert(B).concat(N/V.k));return function(H){if(H===1)H=V;else{var j=G(H),U=N/j[2];H=new Nn(U,B[0]-j[0]*U,B[1]-j[1]*U)}D.zoom(null,H)}})}function M(A,w,S){return!S&&A.__zooming||new C(A,w)}function C(A,w){this.that=A,this.args=w,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,w),this.taps=0}C.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,w){return this.mouse&&A!=="mouse"&&(this.mouse[1]=w.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=w.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=w.invert(this.touch1[0])),this.that.__zoom=w,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var w=st(this.that).datum();l.call(A,this.that,new t2(A,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),w)}};function E(A,...w){if(!n.apply(this,arguments))return;var S=M(this,w).event(A),$=this.__zoom,R=Math.max(o[0],Math.min(o[1],$.k*Math.pow(2,i.apply(this,arguments)))),F=mn(A);if(S.wheel)(S.mouse[0][0]!==F[0]||S.mouse[0][1]!==F[1])&&(S.mouse[1]=$.invert(S.mouse[0]=F)),clearTimeout(S.wheel);else{if($.k===R)return;S.mouse=[F,$.invert(F)],Hi(this),S.start()}Er(A),S.wheel=setTimeout(D,p),S.zoom("mouse",e(x(b($,R),S.mouse[0],S.mouse[1]),S.extent,s));function D(){S.wheel=null,S.end()}}function _(A,...w){if(u||!n.apply(this,arguments))return;var S=A.currentTarget,$=M(this,w,!0).event(A),R=st(A.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",N,!0),F=mn(A,S),D=A.clientX,z=A.clientY;dc(A.view),mc(A),$.mouse=[F,this.__zoom.invert(F)],Hi(this),$.start();function B(K){if(Er(K),!$.moved){var V=K.clientX-D,G=K.clientY-z;$.moved=V*V+G*G>y}$.event(K).zoom("mouse",e(x($.that.__zoom,$.mouse[0]=mn(K,S),$.mouse[1]),$.extent,s))}function N(K){R.on("mousemove.zoom mouseup.zoom",null),pc(K.view,$.moved),Er(K),$.event(K).end()}}function T(A,...w){if(n.apply(this,arguments)){var S=this.__zoom,$=mn(A.changedTouches?A.changedTouches[0]:A,this),R=S.invert($),F=S.k*(A.shiftKey?.5:2),D=e(x(b(S,F),$,R),t.apply(this,w),s);Er(A),a>0?st(this).transition().duration(a).call(k,D,$,A):st(this).call(m.transform,D,$,A)}}function I(A,...w){if(n.apply(this,arguments)){var S=A.touches,$=S.length,R=M(this,w,A.changedTouches.length===$).event(A),F,D,z,B;for(mc(A),D=0;D<$;++D)z=S[D],B=mn(z,this),B=[B,this.__zoom.invert(B),z.identifier],R.touch0?!R.touch1&&R.touch0[2]!==B[2]&&(R.touch1=B,R.taps=0):(R.touch0=B,F=!0,R.taps=1+!!h);h&&(h=clearTimeout(h)),F&&(R.taps<2&&(f=B[0],h=setTimeout(function(){h=null},d)),Hi(this),R.start())}}function L(A,...w){if(this.__zooming){var S=M(this,w).event(A),$=A.changedTouches,R=$.length,F,D,z,B;for(Er(A),F=0;F<R;++F)D=$[F],z=mn(D,this),S.touch0&&S.touch0[2]===D.identifier?S.touch0[0]=z:S.touch1&&S.touch1[2]===D.identifier&&(S.touch1[0]=z);if(D=S.that.__zoom,S.touch1){var N=S.touch0[0],K=S.touch0[1],V=S.touch1[0],G=S.touch1[1],H=(H=V[0]-N[0])*H+(H=V[1]-N[1])*H,j=(j=G[0]-K[0])*j+(j=G[1]-K[1])*j;D=b(D,Math.sqrt(H/j)),z=[(N[0]+V[0])/2,(N[1]+V[1])/2],B=[(K[0]+G[0])/2,(K[1]+G[1])/2]}else if(S.touch0)z=S.touch0[0],B=S.touch0[1];else return;S.zoom("touch",e(x(D,z,B),S.extent,s))}}function P(A,...w){if(this.__zooming){var S=M(this,w).event(A),$=A.changedTouches,R=$.length,F,D;for(mc(A),u&&clearTimeout(u),u=setTimeout(function(){u=null},d),F=0;F<R;++F)D=$[F],S.touch0&&S.touch0[2]===D.identifier?delete S.touch0:S.touch1&&S.touch1[2]===D.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(D=mn(D,this),Math.hypot(f[0]-D[0],f[1]-D[1])<g)){var z=st(this).on("dblclick.zoom");z&&z.apply(this,arguments)}}}return m.wheelDelta=function(A){return arguments.length?(i=typeof A=="function"?A:ls(+A),m):i},m.filter=function(A){return arguments.length?(n=typeof A=="function"?A:ls(!!A),m):n},m.touchable=function(A){return arguments.length?(r=typeof A=="function"?A:ls(!!A),m):r},m.extent=function(A){return arguments.length?(t=typeof A=="function"?A:ls([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),m):t},m.scaleExtent=function(A){return arguments.length?(o[0]=+A[0],o[1]=+A[1],m):[o[0],o[1]]},m.translateExtent=function(A){return arguments.length?(s[0][0]=+A[0][0],s[1][0]=+A[1][0],s[0][1]=+A[0][1],s[1][1]=+A[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(A){return arguments.length?(e=A,m):e},m.duration=function(A){return arguments.length?(a=+A,m):a},m.interpolate=function(A){return arguments.length?(c=A,m):c},m.on=function(){var A=l.on.apply(l,arguments);return A===l?m:A},m.clickDistance=function(A){return arguments.length?(y=(A=+A)*A,m):Math.sqrt(y)},m.tapDistance=function(A){return arguments.length?(g=+A,m):g},m}class Sf{constructor(t,e,i,r,o){this.resetButton=null,this.selectionRect=null,this.selectionStart=null,this.resetClickHandler=null;const s=typeof t=="string"?{type:t}:t;this.zoomKey=s.key,this.panKey=s.panKey,this.plotGroup=e;const a=s.panning;typeof a=="object"?(this.panningEnabled=a.enabled!==!1,this.panningType=a.type||s.type):(this.panningEnabled=a===!0,this.panningType=s.type);const c=this.isMouseWheelEnabled(s.mouseWheel),l=this.getMouseWheelSensitivity(s.mouseWheel);this.zoomBehavior=Af().scaleExtent([1,20]).extent([[0,0],[i.width,i.height]]).translateExtent([[0,0],[i.width,i.height]]).on("zoom",f=>{const u=f.transform;o.emit("zoom:changed",{type:s.type,transform:u})});const h=!!s.selectionHandler;this.zoomBehavior.filter(f=>f.type==="wheel"?c:f.type==="mousedown"||f.type==="touchstart"?h?!1:this.zoomKey?this.isKeyPressed(f,this.zoomKey):!0:!0),e.call(this.zoomBehavior),l!==1&&c&&e.on("wheel.zoom",f=>{f.preventDefault();const u=e.node().__zoom||Pr,d=f.deltaY>0?1/(1+.1*l):1+.1*l,p=Math.max(1,Math.min(20,u.k*d));e.transition().duration(100).call(this.zoomBehavior.scaleTo,p)}),s.selectionHandler&&this.setupSelectionZoom(e,i,s,o),this.panningEnabled&&this.panKey&&this.setupPanning(e,i,o),this.resetButton=this.createResetButton(s.resetButton),this.resetClickHandler=()=>{e.transition().duration(300).call(this.zoomBehavior.transform,Pr),this.resetButton.style.display="none"},this.resetButton.addEventListener("click",this.resetClickHandler),r.appendChild(this.resetButton),o.on("zoom:changed",()=>{this.resetButton&&(this.resetButton.style.display="block")})}setupSelectionZoom(t,e,i,r){t.on("mousedown.selection",o=>{if(this.zoomKey&&!this.isKeyPressed(o,this.zoomKey)||this.panKey&&this.isKeyPressed(o,this.panKey))return;const s=t.node().getBoundingClientRect();this.selectionStart={x:o.clientX-s.left,y:o.clientY-s.top};const a=i.selectionMarkerFill||"rgba(51,92,173,0.25)";this.selectionRect=t.append("rect").attr("class","katucharts-selection").attr("fill",a).attr("stroke","#4572a7").attr("stroke-width",1).attr("x",this.selectionStart.x).attr("y",0).attr("width",0).attr("height",e.height)}),t.on("mousemove.selection",o=>{if(!this.selectionStart||!this.selectionRect)return;const s=t.node().getBoundingClientRect(),a=o.clientX-s.left,c=Math.min(this.selectionStart.x,a),l=Math.abs(a-this.selectionStart.x);if(this.selectionRect.attr("x",c).attr("width",l),i.type==="xy"||i.type==="y"){const h=o.clientY-s.top,f=Math.min(this.selectionStart.y,h),u=Math.abs(h-this.selectionStart.y);this.selectionRect.attr("y",f).attr("height",u)}}),t.on("mouseup.selection",o=>{if(!this.selectionStart||!this.selectionRect)return;const s=t.node().getBoundingClientRect(),a=o.clientX-s.left,c=o.clientY-s.top;if(this.selectionRect.remove(),this.selectionRect=null,Math.abs(a-this.selectionStart.x)<5){this.selectionStart=null;return}let l=!1;const h={xAxis:[{min:Math.min(this.selectionStart.x,a),max:Math.max(this.selectionStart.x,a)}],yAxis:[{min:Math.min(this.selectionStart.y,c),max:Math.max(this.selectionStart.y,c)}],originalEvent:o,preventDefault:()=>{l=!0}};i.selectionHandler&&i.selectionHandler(h),l||r.emit("chart:selection",h),this.selectionStart=null})}setupPanning(t,e,i){let r=null,o={x:0,y:0};t.on("mousedown.pan",s=>{!this.panKey||!this.isKeyPressed(s,this.panKey)||(s.preventDefault(),r={x:s.clientX-o.x,y:s.clientY-o.y},t.style("cursor","grabbing"))}),t.on("mousemove.pan",s=>{if(!r)return;let a=s.clientX-r.x,c=s.clientY-r.y;this.panningType==="x"&&(c=0),this.panningType==="y"&&(a=0),o={x:a,y:c},i.emit("zoom:panned",{dx:a,dy:c,type:this.panningType})}),t.on("mouseup.pan",()=>{r&&(r=null,t.style("cursor",""))})}isKeyPressed(t,e){switch(e){case"ctrl":return t.ctrlKey;case"alt":return t.altKey;case"shift":return t.shiftKey;case"meta":return t.metaKey;default:return!0}}isMouseWheelEnabled(t){return t===!0||typeof t=="object"&&t.enabled!==!1}getMouseWheelSensitivity(t){return typeof t=="object"&&t.sensitivity!==void 0?t.sensitivity:1}createResetButton(t){const e=document.createElement("button");e.textContent="Reset zoom";const i=(t==null?void 0:t.theme)||{},r=(t==null?void 0:t.position)||{},o=r.y??5,s=r.x!==void 0?`${r.x}px`:"5px";return Object.assign(e.style,{position:"absolute",top:`${o}px`,right:s,padding:i.padding||"3px 8px",fontSize:i.fontSize||"11px",border:i.border||"1px solid #ccc",borderRadius:i.borderRadius||"3px",backgroundColor:i.backgroundColor||"#f9f9f9",color:i.color||"#333",cursor:"pointer",display:"none",zIndex:"5"}),e}setResetHandler(t){this.resetButton&&(this.resetClickHandler&&this.resetButton.removeEventListener("click",this.resetClickHandler),this.resetClickHandler=t,this.resetButton.addEventListener("click",this.resetClickHandler))}setResetButtonVisible(t){this.resetButton&&(this.resetButton.style.display=t?"block":"none")}resetTransform(){const t=this.plotGroup.node();t&&(t.__zoom=Pr)}destroy(){this.resetButton&&(this.resetClickHandler&&this.resetButton.removeEventListener("click",this.resetClickHandler),this.resetButton.remove())}}class _f{constructor(t){this.lastSeriesCount=0,this.lastPointCounts=[],this.config=t}apply(t,e,i){var s,a;if(this.config.enabled===!1)return;const r=this.config.landmarkVerbosity||"all";t.attr("role","img"),i&&t.attr("aria-label",this.config.description||`Chart: ${i}`);const o="katucharts-desc-"+Math.random().toString(36).slice(2,8);t.append("desc").attr("id",o).text(this.config.description||this.generateDescription(e,i)),t.attr("aria-describedby",o),t.attr("tabindex","0"),t.style("outline","none"),this.renderScreenReaderSections(t,e,i),this.applyLandmarks(t,e,r),((s=this.config.keyboardNavigation)==null?void 0:s.enabled)!==!1&&this.setupKeyboardNav(t,e),(a=this.config.announceNewData)!=null&&a.enabled&&this.setupAnnounceNewData(e)}setupAnnounceNewData(t){var o;const e=((o=this.config.announceNewData)==null?void 0:o.minAnnounceInterval)??5e3;let i=0;this.lastSeriesCount=t.length,this.lastPointCounts=t.map(s=>s.data.length),setInterval(()=>{const s=Date.now();if(s-i<e)return;let a=!1,c="";if(t.length!==this.lastSeriesCount)a=!0,c=`Chart updated. Now showing ${t.length} data series.`;else for(let l=0;l<t.length;l++){const h=t[l].data.length,f=this.lastPointCounts[l]??0;if(h!==f){a=!0;const u=h-f;c=`${t[l].config.name||"Series"} updated with ${Math.abs(u)} ${u>0?"new":"fewer"} point${Math.abs(u)!==1?"s":""}. Total: ${h}.`;break}}a&&(this.announce(c),i=s,this.lastSeriesCount=t.length,this.lastPointCounts=t.map(l=>l.data.length))},Math.max(1e3,e/2))}renderScreenReaderSections(t,e,i){var s;const r=this.config.screenReaderSection,o=(s=t.node())==null?void 0:s.parentElement;if(o){if(r!=null&&r.beforeChartFormat){const a=this.createScreenReaderDiv(this.formatSectionTemplate(r.beforeChartFormat,e,i));o.insertBefore(a,t.node())}if(r!=null&&r.afterChartFormat){const a=this.createScreenReaderDiv(this.formatSectionTemplate(r.afterChartFormat,e,i));o.appendChild(a)}}}createScreenReaderDiv(t){const e=document.createElement("div");return e.className="katucharts-screen-reader-region",e.setAttribute("role","region"),e.setAttribute("aria-label","Chart information"),e.innerHTML=t,Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"}),e}formatSectionTemplate(t,e,i){return t.replace("{chartTitle}",Qn(i||"Chart")).replace("{numSeries}",String(e.length)).replace("{seriesList}",e.map(r=>Qn(r.config.name||"Series")).join(", "))}applyLandmarks(t,e,i){if(i==="disabled")return;if(i==="one"){t.attr("role","region");return}t.selectAll(".katucharts-legend").attr("role","region").attr("aria-label","Chart legend");const r=this.config.series,o=(r==null?void 0:r.describeSingleSeries)??!1;e.length===1&&!o||e.forEach((s,a)=>{const c=s.group;if(c){const l=s.config.name||`Series ${a+1}`,h=r==null?void 0:r.descriptionFormat,f=h?h.replace("{name}",l).replace("{index}",String(a)):`${l}, ${s.data.length} data points`;c.attr("role","region").attr("aria-label",f)}})}generateDescription(t,e){const i=[];e&&i.push(`${e}.`),i.push(`Chart with ${t.length} data series.`);for(const r of t){const o=r.config.name||`Series ${r.config.index+1}`,s=r.data.length;i.push(`${o}: ${s} data points.`)}return i.join(" ")}setupKeyboardNav(t,e){let i=0,r=0;t.on("keydown",o=>{const s=e[i];if(s)switch(o.key){case"ArrowRight":o.preventDefault(),r=Math.min(r+1,s.data.length-1),this.announcePoint(s,r);break;case"ArrowLeft":o.preventDefault(),r=Math.max(r-1,0),this.announcePoint(s,r);break;case"ArrowUp":o.preventDefault(),i=Math.max(i-1,0),r=0,this.announceSeries(e[i]);break;case"ArrowDown":o.preventDefault(),i=Math.min(i+1,e.length-1),r=0,this.announceSeries(e[i]);break;case"Enter":case" ":o.preventDefault(),this.announcePoint(s,r);break}})}announcePoint(t,e){var o,s;const i=t.data[e];if(!i)return;let r;(o=this.config.point)!=null&&o.descriptionFormatter?r=this.config.point.descriptionFormatter(i):(s=this.config.point)!=null&&s.valueDescriptionFormat?r=this.config.point.valueDescriptionFormat.replace("{index}",String(e+1)).replace("{value}",String(i.y??"")).replace("{xDescription}",i.name||String(i.x??"")).replace("{point.name}",i.name||"").replace("{point.y}",String(i.y??"")).replace("{point.x}",String(i.x??"")).replace("{series.name}",t.config.name||"Series"):r=`${t.config.name||"Series"}, point ${e+1}: ${i.name?i.name+", ":""}value ${i.y}`,this.announce(r)}announceSeries(t){const e=`${t.config.name||"Series"}, ${t.data.length} points`;this.announce(e)}announce(t){let e=document.getElementById("katucharts-announcer");e||(e=document.createElement("div"),e.id="katucharts-announcer",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap"}),document.body.appendChild(e)),e.textContent=t}}class s2{constructor(t){this.host=t,this.drilldown=null,this.zoom=null,this.a11yModule=null,this.origXDomains=[],this.origYDomains=[],this.isBoxZoomed=!1}setup(){this.setupSeriesDimming(),this.setupDrilldown(),this.setupZoom(),this.setupAccessibility()}destroy(){var t,e;(t=this.drilldown)==null||t.destroy(),(e=this.zoom)==null||e.destroy()}setupSeriesDimming(){var a,c,l,h;const t=this.host.getEvents(),e=((h=(l=(c=(a=this.host.getOptions().plotOptions)==null?void 0:a.series)==null?void 0:c.states)==null?void 0:l.inactive)==null?void 0:h.opacity)??.2;let i=null;const r=(f,u)=>{var p;let d=u;for(let y=0;y<f.length;y++){const g=(p=f[d])==null?void 0:p.config.linkedTo;if(g==null)break;let m=-1;if(g===":previous"?m=d-1:g===":next"?m=d+1:m=f.findIndex(b=>b.config.id===g),m<0||m===d)break;d=m}return d},o=f=>{var y,g,m,b,x,v,k,M,C,E;i&&(clearTimeout(i),i=null);const u=this.host.getSeriesInstances(),d=u.indexOf(f),p=d>=0?r(u,d):-1;for(let _=0;_<u.length;_++){const T=u[_];(g=(y=T.group)==null?void 0:y.interrupt)==null||g.call(y,"seriesDim"),!(d>=0&&r(u,_)===p)&&T.visible?(M=(k=(v=(x=(b=(m=T.group)==null?void 0:m.transition)==null?void 0:b.call(m,"seriesDim"))==null?void 0:x.duration)==null?void 0:v.call(x,200))==null?void 0:k.attr)==null||M.call(k,"opacity",e):(E=(C=T.group)==null?void 0:C.attr)==null||E.call(C,"opacity",T.config.opacity??1)}},s=()=>{i&&clearTimeout(i),i=setTimeout(()=>{var f,u,d,p,y,g,m,b;for(const x of this.host.getSeriesInstances())(u=(f=x.group)==null?void 0:f.interrupt)==null||u.call(f,"seriesDim"),(b=(m=(g=(y=(p=(d=x.group)==null?void 0:d.transition)==null?void 0:p.call(d,"seriesDim"))==null?void 0:y.duration)==null?void 0:g.call(y,200))==null?void 0:m.attr)==null||b.call(m,"opacity",x.config.opacity??1);i=null},50)};t.on("series:mouseenter",o),t.on("series:mouseleave",s),t.on("legend:itemHover",o),t.on("legend:itemLeave",s)}setupDrilldown(){var l;const e=this.host.getOptions().drilldown;if(!((l=e==null?void 0:e.series)!=null&&l.length))return;const i=this.host.getEvents(),r=this.host.getSeriesGroup();this.drilldown=new wf(e,i,this.host.getContainer());const o=[],s=new Jn,a=e.animation,c=typeof a=="object"?a.duration??400:a!==!1?400:0;i.on("drilldown:drilldown",h=>{o.push([...this.host.getOptions().series]),c>0?r.transition().duration(c/2).style("opacity","0").on("end",()=>{this.performDrillSwap(h,s),r.style("opacity","0").transition().duration(c/2).style("opacity","1")}):this.performDrillSwap(h,s),this.host.fireEvent("drilldown",h)}),i.on("drilldown:drillup",()=>{const h=o.pop();h&&this.host.setSeries(h),c>0?r.transition().duration(c/2).style("opacity","0").on("end",()=>{this.host.rebuild(),r.style("opacity","0").transition().duration(c/2).style("opacity","1")}):this.host.rebuild(),this.host.fireEvent("drillup")})}performDrillSwap(t,e){const i=this.host.getOptions(),r=t.seriesOptions,o=e.parse({chart:i.chart,xAxis:i.xAxis,yAxis:i.yAxis,series:[r]});this.host.setSeries(o.series),this.host.rebuild()}setupZoom(){const t=this.host.getOptions(),e=t.chart.zooming||t.chart.zoomType;if(!e)return;const i=typeof e=="string"?e:e.type||"x",r={type:i,key:typeof e=="object"?e.key:void 0,mouseWheel:typeof e=="object"?e.mouseWheel:void 0,resetButton:typeof e=="object"?e.resetButton:void 0,panning:typeof e=="object"?e.panning:void 0,panKey:typeof e=="object"?e.panKey:void 0,pinchType:typeof e=="object"?e.pinchType:void 0,selectionMarkerFill:t.chart.selectionMarkerFill,selectionHandler:s=>this.applyBoxZoom(s,i)},o=this.host.getEvents();t.chart.scrollablePlotArea&&(r.mouseWheel=!1),this.zoom=new Sf(r,this.host.getPlotGroup(),this.host.getLayout().plotArea,this.host.getContainer(),o),this.zoom.setResetHandler(()=>this.resetBoxZoom()),o.on("zoom:changed",s=>{var f;const a=s.transform,c=s.type,l=this.host.getLayout().plotArea,h=!this.isBoxZoomed;(c==="x"||c==="xy")&&this.host.getXAxes().forEach((u,d)=>{h&&(this.origXDomains[d]=u.scale.domain());const p=this.origXDomains[d];if(!p||typeof p[0]!="number"||typeof p[1]!="number")return;const y=p[1]-p[0],g=(0-a.x)/a.k,m=(l.width-a.x)/a.k;u.updateDomain({min:p[0]+g/l.width*y,max:p[0]+m/l.width*y})}),(c==="y"||c==="xy")&&this.host.getYAxes().forEach((u,d)=>{h&&(this.origYDomains[d]=u.scale.domain());const p=this.origYDomains[d];if(!p||typeof p[0]!="number"||typeof p[1]!="number")return;const y=p[1]-p[0],g=(0-a.y)/a.k,m=(l.height-a.y)/a.k;u.updateDomain({max:p[1]-g/l.height*y,min:p[1]-m/l.height*y})}),this.isBoxZoomed=!0,(f=this.zoom)==null||f.setResetButtonVisible(!0),this.host.renderAfterZoom()})}applyBoxZoom(t,e){var r;const i=!this.isBoxZoomed;return(e==="x"||e==="xy")&&this.host.getXAxes().forEach((s,a)=>{i&&(this.origXDomains[a]=s.scale.domain());const c=s.getValueForPixel(t.xAxis[0].min),l=s.getValueForPixel(t.xAxis[0].max);c==null||l==null||!Number.isFinite(+c)||!Number.isFinite(+l)||s.updateDomain({min:Math.min(+c,+l),max:Math.max(+c,+l)})}),(e==="y"||e==="xy")&&this.host.getYAxes().forEach((s,a)=>{i&&(this.origYDomains[a]=s.scale.domain());const c=s.getValueForPixel(t.yAxis[0].min),l=s.getValueForPixel(t.yAxis[0].max);c==null||l==null||!Number.isFinite(+c)||!Number.isFinite(+l)||s.updateDomain({min:Math.min(+c,+l),max:Math.max(+c,+l)})}),this.isBoxZoomed=!0,(r=this.zoom)==null||r.setResetButtonVisible(!0),this.host.renderAfterZoom(),this.host.getEvents().emit("chart:afterZoom"),!0}resetBoxZoom(){var t,e;this.isBoxZoomed&&(this.host.getXAxes().forEach((i,r)=>{const o=this.origXDomains[r];o&&i.updateDomain({min:o[0],max:o[1]})}),this.host.getYAxes().forEach((i,r)=>{const o=this.origYDomains[r];o&&i.updateDomain({min:o[0],max:o[1]})}),this.isBoxZoomed=!1,this.origXDomains=[],this.origYDomains=[],(t=this.zoom)==null||t.resetTransform(),(e=this.zoom)==null||e.setResetButtonVisible(!1),this.host.renderAfterZoom(),this.host.getEvents().emit("chart:afterZoom"))}setupAccessibility(){var i;const t=this.host.getOptions(),e=t.accessibility;!e||e.enabled===!1||(this.a11yModule=new _f(e),this.a11yModule.apply(this.host.getRenderer().svg,this.host.getSeriesInstances(),((i=t.title)==null?void 0:i.text)??void 0))}}const yc=n=>()=>n;function a2(n,{sourceEvent:t,target:e,selection:i,mode:r,dispatch:o}){Object.defineProperties(this,{type:{value:n,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:i,enumerable:!0,configurable:!0},mode:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function c2(n){n.stopImmediatePropagation()}function xc(n){n.preventDefault(),n.stopImmediatePropagation()}var Cf={name:"drag"},bc={name:"space"},Yi={name:"handle"},Xi={name:"center"};const{abs:Pf,max:Ae,min:Se}=Math;function Ef(n){return[+n[0],+n[1]]}function Tf(n){return[Ef(n[0]),Ef(n[1])]}var hs={name:"x",handles:["w","e"].map(wc),input:function(n,t){return n==null?null:[[+n[0],t[0][1]],[+n[1],t[1][1]]]},output:function(n){return n&&[n[0][0],n[1][0]]}},vc={},Wn={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Lf={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},$f={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},l2={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},h2={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function wc(n){return{type:n}}function u2(n){return!n.ctrlKey&&!n.button}function f2(){var n=this.ownerSVGElement||this;return n.hasAttribute("viewBox")?(n=n.viewBox.baseVal,[[n.x,n.y],[n.x+n.width,n.y+n.height]]):[[0,0],[n.width.baseVal.value,n.height.baseVal.value]]}function d2(){return navigator.maxTouchPoints||"ontouchstart"in this}function kc(n){for(;!n.__brush;)if(!(n=n.parentNode))return;return n.__brush}function p2(n){return n[0][0]===n[1][0]||n[0][1]===n[1][1]}function g2(){return m2(hs)}function m2(n){var t=f2,e=u2,i=d2,r=!0,o=Ni("start","brush","end"),s=6,a;function c(g){var m=g.property("__brush",y).selectAll(".overlay").data([wc("overlay")]);m.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",Wn.overlay).merge(m).each(function(){var x=kc(this).extent;st(this).attr("x",x[0][0]).attr("y",x[0][1]).attr("width",x[1][0]-x[0][0]).attr("height",x[1][1]-x[0][1])}),g.selectAll(".selection").data([wc("selection")]).enter().append("rect").attr("class","selection").attr("cursor",Wn.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var b=g.selectAll(".handle").data(n.handles,function(x){return x.type});b.exit().remove(),b.enter().append("rect").attr("class",function(x){return"handle handle--"+x.type}).attr("cursor",function(x){return Wn[x.type]}),g.each(l).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",u).filter(i).on("touchstart.brush",u).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}c.move=function(g,m,b){g.tween?g.on("start.brush",function(x){h(this,arguments).beforestart().start(x)}).on("interrupt.brush end.brush",function(x){h(this,arguments).end(x)}).tween("brush",function(){var x=this,v=x.__brush,k=h(x,arguments),M=v.selection,C=n.input(typeof m=="function"?m.apply(this,arguments):m,v.extent),E=ue(M,C);function _(T){v.selection=T===1&&C===null?null:E(T),l.call(x),k.brush()}return M!==null&&C!==null?_:_(1)}):g.each(function(){var x=this,v=arguments,k=x.__brush,M=n.input(typeof m=="function"?m.apply(x,v):m,k.extent),C=h(x,v).beforestart();Hi(x),k.selection=M===null?null:M,l.call(x),C.start(b).brush(b).end(b)})},c.clear=function(g,m){c.move(g,null,m)};function l(){var g=st(this),m=kc(this).selection;m?(g.selectAll(".selection").style("display",null).attr("x",m[0][0]).attr("y",m[0][1]).attr("width",m[1][0]-m[0][0]).attr("height",m[1][1]-m[0][1]),g.selectAll(".handle").style("display",null).attr("x",function(b){return b.type[b.type.length-1]==="e"?m[1][0]-s/2:m[0][0]-s/2}).attr("y",function(b){return b.type[0]==="s"?m[1][1]-s/2:m[0][1]-s/2}).attr("width",function(b){return b.type==="n"||b.type==="s"?m[1][0]-m[0][0]+s:s}).attr("height",function(b){return b.type==="e"||b.type==="w"?m[1][1]-m[0][1]+s:s})):g.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function h(g,m,b){var x=g.__brush.emitter;return x&&(!b||!x.clean)?x:new f(g,m,b)}function f(g,m,b){this.that=g,this.args=m,this.state=g.__brush,this.active=0,this.clean=b}f.prototype={beforestart:function(){return++this.active===1&&(this.state.emitter=this,this.starting=!0),this},start:function(g,m){return this.starting?(this.starting=!1,this.emit("start",g,m)):this.emit("brush",g),this},brush:function(g,m){return this.emit("brush",g,m),this},end:function(g,m){return--this.active===0&&(delete this.state.emitter,this.emit("end",g,m)),this},emit:function(g,m,b){var x=st(this.that).datum();o.call(g,this.that,new a2(g,{sourceEvent:m,target:c,selection:n.output(this.state.selection),mode:b,dispatch:o}),x)}};function u(g){if(a&&!g.touches||!e.apply(this,arguments))return;var m=this,b=g.target.__data__.type,x=(r&&g.metaKey?b="overlay":b)==="selection"?Cf:r&&g.altKey?Xi:Yi,v=n===vc?null:l2[b],k=n===hs?null:h2[b],M=kc(m),C=M.extent,E=M.selection,_=C[0][0],T,I,L=C[0][1],P,A,w=C[1][0],S,$,R=C[1][1],F,D,z=0,B=0,N,K=v&&k&&r&&g.shiftKey,V,G,H=Array.from(g.touches||[g],at=>{const W=at.identifier;return at=mn(at,m),at.point0=at.slice(),at.identifier=W,at});Hi(m);var j=h(m,arguments,!0).beforestart();if(b==="overlay"){E&&(N=!0);const at=[H[0],H[1]||H[0]];M.selection=E=[[T=n===vc?_:Se(at[0][0],at[1][0]),P=n===hs?L:Se(at[0][1],at[1][1])],[S=n===vc?w:Ae(at[0][0],at[1][0]),F=n===hs?R:Ae(at[0][1],at[1][1])]],H.length>1&&it(g)}else T=E[0][0],P=E[0][1],S=E[1][0],F=E[1][1];I=T,A=P,$=S,D=F;var U=st(m).attr("pointer-events","none"),X=U.selectAll(".overlay").attr("cursor",Wn[b]);if(g.touches)j.moved=O,j.ended=nt;else{var tt=st(g.view).on("mousemove.brush",O,!0).on("mouseup.brush",nt,!0);r&&tt.on("keydown.brush",lt,!0).on("keyup.brush",ht,!0),dc(g.view)}l.call(m),j.start(g,x.name);function O(at){for(const W of at.changedTouches||[at])for(const J of H)J.identifier===W.identifier&&(J.cur=mn(W,m));if(K&&!V&&!G&&H.length===1){const W=H[0];Pf(W.cur[0]-W[0])>Pf(W.cur[1]-W[1])?G=!0:V=!0}for(const W of H)W.cur&&(W[0]=W.cur[0],W[1]=W.cur[1]);N=!0,xc(at),it(at)}function it(at){const W=H[0],J=W.point0;var ut;switch(z=W[0]-J[0],B=W[1]-J[1],x){case bc:case Cf:{v&&(z=Ae(_-T,Se(w-S,z)),I=T+z,$=S+z),k&&(B=Ae(L-P,Se(R-F,B)),A=P+B,D=F+B);break}case Yi:{H[1]?(v&&(I=Ae(_,Se(w,H[0][0])),$=Ae(_,Se(w,H[1][0])),v=1),k&&(A=Ae(L,Se(R,H[0][1])),D=Ae(L,Se(R,H[1][1])),k=1)):(v<0?(z=Ae(_-T,Se(w-T,z)),I=T+z,$=S):v>0&&(z=Ae(_-S,Se(w-S,z)),I=T,$=S+z),k<0?(B=Ae(L-P,Se(R-P,B)),A=P+B,D=F):k>0&&(B=Ae(L-F,Se(R-F,B)),A=P,D=F+B));break}case Xi:{v&&(I=Ae(_,Se(w,T-z*v)),$=Ae(_,Se(w,S+z*v))),k&&(A=Ae(L,Se(R,P-B*k)),D=Ae(L,Se(R,F+B*k)));break}}$<I&&(v*=-1,ut=T,T=S,S=ut,ut=I,I=$,$=ut,b in Lf&&X.attr("cursor",Wn[b=Lf[b]])),D<A&&(k*=-1,ut=P,P=F,F=ut,ut=A,A=D,D=ut,b in $f&&X.attr("cursor",Wn[b=$f[b]])),M.selection&&(E=M.selection),V&&(I=E[0][0],$=E[1][0]),G&&(A=E[0][1],D=E[1][1]),(E[0][0]!==I||E[0][1]!==A||E[1][0]!==$||E[1][1]!==D)&&(M.selection=[[I,A],[$,D]],l.call(m),j.brush(at,x.name))}function nt(at){if(c2(at),at.touches){if(at.touches.length)return;a&&clearTimeout(a),a=setTimeout(function(){a=null},500)}else pc(at.view,N),tt.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);U.attr("pointer-events","all"),X.attr("cursor",Wn.overlay),M.selection&&(E=M.selection),p2(E)&&(M.selection=null,l.call(m)),j.end(at,x.name)}function lt(at){switch(at.keyCode){case 16:{K=v&&k;break}case 18:{x===Yi&&(v&&(S=$-z*v,T=I+z*v),k&&(F=D-B*k,P=A+B*k),x=Xi,it(at));break}case 32:{(x===Yi||x===Xi)&&(v<0?S=$-z:v>0&&(T=I-z),k<0?F=D-B:k>0&&(P=A-B),x=bc,X.attr("cursor",Wn.selection),it(at));break}default:return}xc(at)}function ht(at){switch(at.keyCode){case 16:{K&&(V=G=K=!1,it(at));break}case 18:{x===Xi&&(v<0?S=$:v>0&&(T=I),k<0?F=D:k>0&&(P=A),x=Yi,it(at));break}case 32:{x===bc&&(at.altKey?(v&&(S=$-z*v,T=I+z*v),k&&(F=D-B*k,P=A+B*k),x=Xi):(v<0?S=$:v>0&&(T=I),k<0?F=D:k>0&&(P=A),x=Yi),X.attr("cursor",Wn[b]),it(at));break}default:return}xc(at)}}function d(g){h(this,arguments).moved(g)}function p(g){h(this,arguments).ended(g)}function y(){var g=this.__brush||{selection:null};return g.extent=Tf(t.apply(this,arguments)),g.dim=n,g}return c.extent=function(g){return arguments.length?(t=typeof g=="function"?g:yc(Tf(g)),c):t},c.filter=function(g){return arguments.length?(e=typeof g=="function"?g:yc(!!g),c):e},c.touchable=function(g){return arguments.length?(i=typeof g=="function"?g:yc(!!g),c):i},c.handleSize=function(g){return arguments.length?(s=+g,c):s},c.keyModifiers=function(g){return arguments.length?(r=!!g,c):r},c.on=function(){var g=o.on.apply(o,arguments);return g===o?c:g},c}function Rt(n){return function(){return n}}const If=Math.abs,_e=Math.atan2,Mi=Math.cos,y2=Math.max,Mc=Math.min,An=Math.sin,De=Math.sqrt,Ce=1e-12,Ui=Math.PI,us=Ui/2,Tr=2*Ui;function x2(n){return n>1?0:n<-1?Ui:Math.acos(n)}function Ff(n){return n>=1?us:n<=-1?-us:Math.asin(n)}const Ac=Math.PI,Sc=2*Ac,Ai=1e-6,b2=Sc-Ai;function Rf(n){this._+=n[0];for(let t=1,e=n.length;t<e;++t)this._+=arguments[t]+n[t]}function v2(n){let t=Math.floor(n);if(!(t>=0))throw new Error(`invalid digits: ${n}`);if(t>15)return Rf;const e=10**t;return function(i){this._+=i[0];for(let r=1,o=i.length;r<o;++r)this._+=Math.round(arguments[r]*e)/e+i[r]}}let w2=class{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?Rf:v2(t)}moveTo(t,e){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,e){this._append`L${this._x1=+t},${this._y1=+e}`}quadraticCurveTo(t,e,i,r){this._append`Q${+t},${+e},${this._x1=+i},${this._y1=+r}`}bezierCurveTo(t,e,i,r,o,s){this._append`C${+t},${+e},${+i},${+r},${this._x1=+o},${this._y1=+s}`}arcTo(t,e,i,r,o){if(t=+t,e=+e,i=+i,r=+r,o=+o,o<0)throw new Error(`negative radius: ${o}`);let s=this._x1,a=this._y1,c=i-t,l=r-e,h=s-t,f=a-e,u=h*h+f*f;if(this._x1===null)this._append`M${this._x1=t},${this._y1=e}`;else if(u>Ai)if(!(Math.abs(f*c-l*h)>Ai)||!o)this._append`L${this._x1=t},${this._y1=e}`;else{let d=i-s,p=r-a,y=c*c+l*l,g=d*d+p*p,m=Math.sqrt(y),b=Math.sqrt(u),x=o*Math.tan((Ac-Math.acos((y+u-g)/(2*m*b)))/2),v=x/b,k=x/m;Math.abs(v-1)>Ai&&this._append`L${t+v*h},${e+v*f}`,this._append`A${o},${o},0,0,${+(f*d>h*p)},${this._x1=t+k*c},${this._y1=e+k*l}`}}arc(t,e,i,r,o,s){if(t=+t,e=+e,i=+i,s=!!s,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),c=i*Math.sin(r),l=t+a,h=e+c,f=1^s,u=s?r-o:o-r;this._x1===null?this._append`M${l},${h}`:(Math.abs(this._x1-l)>Ai||Math.abs(this._y1-h)>Ai)&&this._append`L${l},${h}`,i&&(u<0&&(u=u%Sc+Sc),u>b2?this._append`A${i},${i},0,1,${f},${t-a},${e-c}A${i},${i},0,1,${f},${this._x1=l},${this._y1=h}`:u>Ai&&this._append`A${i},${i},0,${+(u>=Ac)},${f},${this._x1=t+i*Math.cos(o)},${this._y1=e+i*Math.sin(o)}`)}rect(t,e,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+e}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}};function Lr(n){let t=3;return n.digits=function(e){if(!arguments.length)return t;if(e==null)t=null;else{const i=Math.floor(e);if(!(i>=0))throw new RangeError(`invalid digits: ${e}`);t=i}return n},()=>new w2(t)}function k2(n){return n.innerRadius}function M2(n){return n.outerRadius}function A2(n){return n.startAngle}function S2(n){return n.endAngle}function _2(n){return n&&n.padAngle}function C2(n,t,e,i,r,o,s,a){var c=e-n,l=i-t,h=s-r,f=a-o,u=f*c-h*l;if(!(u*u<Ce))return u=(h*(t-o)-f*(n-r))/u,[n+u*c,t+u*l]}function fs(n,t,e,i,r,o,s){var a=n-e,c=t-i,l=(s?o:-o)/De(a*a+c*c),h=l*c,f=-l*a,u=n+h,d=t+f,p=e+h,y=i+f,g=(u+p)/2,m=(d+y)/2,b=p-u,x=y-d,v=b*b+x*x,k=r-o,M=u*y-p*d,C=(x<0?-1:1)*De(y2(0,k*k*v-M*M)),E=(M*x-b*C)/v,_=(-M*b-x*C)/v,T=(M*x+b*C)/v,I=(-M*b+x*C)/v,L=E-g,P=_-m,A=T-g,w=I-m;return L*L+P*P>A*A+w*w&&(E=T,_=I),{cx:E,cy:_,x01:-h,y01:-f,x11:E*(r/k-1),y11:_*(r/k-1)}}function Pe(){var n=k2,t=M2,e=Rt(0),i=null,r=A2,o=S2,s=_2,a=null,c=Lr(l);function l(){var h,f,u=+n.apply(this,arguments),d=+t.apply(this,arguments),p=r.apply(this,arguments)-us,y=o.apply(this,arguments)-us,g=If(y-p),m=y>p;if(a||(a=h=c()),d<u&&(f=d,d=u,u=f),!(d>Ce))a.moveTo(0,0);else if(g>Tr-Ce)a.moveTo(d*Mi(p),d*An(p)),a.arc(0,0,d,p,y,!m),u>Ce&&(a.moveTo(u*Mi(y),u*An(y)),a.arc(0,0,u,y,p,m));else{var b=p,x=y,v=p,k=y,M=g,C=g,E=s.apply(this,arguments)/2,_=E>Ce&&(i?+i.apply(this,arguments):De(u*u+d*d)),T=Mc(If(d-u)/2,+e.apply(this,arguments)),I=T,L=T,P,A;if(_>Ce){var w=Ff(_/u*An(E)),S=Ff(_/d*An(E));(M-=w*2)>Ce?(w*=m?1:-1,v+=w,k-=w):(M=0,v=k=(p+y)/2),(C-=S*2)>Ce?(S*=m?1:-1,b+=S,x-=S):(C=0,b=x=(p+y)/2)}var $=d*Mi(b),R=d*An(b),F=u*Mi(k),D=u*An(k);if(T>Ce){var z=d*Mi(x),B=d*An(x),N=u*Mi(v),K=u*An(v),V;if(g<Ui)if(V=C2($,R,N,K,z,B,F,D)){var G=$-V[0],H=R-V[1],j=z-V[0],U=B-V[1],X=1/An(x2((G*j+H*U)/(De(G*G+H*H)*De(j*j+U*U)))/2),tt=De(V[0]*V[0]+V[1]*V[1]);I=Mc(T,(u-tt)/(X-1)),L=Mc(T,(d-tt)/(X+1))}else I=L=0}C>Ce?L>Ce?(P=fs(N,K,$,R,d,L,m),A=fs(z,B,F,D,d,L,m),a.moveTo(P.cx+P.x01,P.cy+P.y01),L<T?a.arc(P.cx,P.cy,L,_e(P.y01,P.x01),_e(A.y01,A.x01),!m):(a.arc(P.cx,P.cy,L,_e(P.y01,P.x01),_e(P.y11,P.x11),!m),a.arc(0,0,d,_e(P.cy+P.y11,P.cx+P.x11),_e(A.cy+A.y11,A.cx+A.x11),!m),a.arc(A.cx,A.cy,L,_e(A.y11,A.x11),_e(A.y01,A.x01),!m))):(a.moveTo($,R),a.arc(0,0,d,b,x,!m)):a.moveTo($,R),!(u>Ce)||!(M>Ce)?a.lineTo(F,D):I>Ce?(P=fs(F,D,z,B,u,-I,m),A=fs($,R,N,K,u,-I,m),a.lineTo(P.cx+P.x01,P.cy+P.y01),I<T?a.arc(P.cx,P.cy,I,_e(P.y01,P.x01),_e(A.y01,A.x01),!m):(a.arc(P.cx,P.cy,I,_e(P.y01,P.x01),_e(P.y11,P.x11),!m),a.arc(0,0,u,_e(P.cy+P.y11,P.cx+P.x11),_e(A.cy+A.y11,A.cx+A.x11),m),a.arc(A.cx,A.cy,I,_e(A.y11,A.x11),_e(A.y01,A.x01),!m))):a.arc(0,0,u,k,v,m)}if(a.closePath(),h)return a=null,h+""||null}return l.centroid=function(){var h=(+n.apply(this,arguments)+ +t.apply(this,arguments))/2,f=(+r.apply(this,arguments)+ +o.apply(this,arguments))/2-Ui/2;return[Mi(f)*h,An(f)*h]},l.innerRadius=function(h){return arguments.length?(n=typeof h=="function"?h:Rt(+h),l):n},l.outerRadius=function(h){return arguments.length?(t=typeof h=="function"?h:Rt(+h),l):t},l.cornerRadius=function(h){return arguments.length?(e=typeof h=="function"?h:Rt(+h),l):e},l.padRadius=function(h){return arguments.length?(i=h==null?null:typeof h=="function"?h:Rt(+h),l):i},l.startAngle=function(h){return arguments.length?(r=typeof h=="function"?h:Rt(+h),l):r},l.endAngle=function(h){return arguments.length?(o=typeof h=="function"?h:Rt(+h),l):o},l.padAngle=function(h){return arguments.length?(s=typeof h=="function"?h:Rt(+h),l):s},l.context=function(h){return arguments.length?(a=h??null,l):a},l}var P2=Array.prototype.slice;function _c(n){return typeof n=="object"&&"length"in n?n:Array.from(n)}function Df(n){this._context=n}Df.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;default:this._context.lineTo(n,t);break}}};function Si(n){return new Df(n)}function Cc(n){return n[0]}function Pc(n){return n[1]}function on(n,t){var e=Rt(!0),i=null,r=Si,o=null,s=Lr(a);n=typeof n=="function"?n:n===void 0?Cc:Rt(n),t=typeof t=="function"?t:t===void 0?Pc:Rt(t);function a(c){var l,h=(c=_c(c)).length,f,u=!1,d;for(i==null&&(o=r(d=s())),l=0;l<=h;++l)!(l<h&&e(f=c[l],l,c))===u&&((u=!u)?o.lineStart():o.lineEnd()),u&&o.point(+n(f,l,c),+t(f,l,c));if(d)return o=null,d+""||null}return a.x=function(c){return arguments.length?(n=typeof c=="function"?c:Rt(+c),a):n},a.y=function(c){return arguments.length?(t=typeof c=="function"?c:Rt(+c),a):t},a.defined=function(c){return arguments.length?(e=typeof c=="function"?c:Rt(!!c),a):e},a.curve=function(c){return arguments.length?(r=c,i!=null&&(o=r(i)),a):r},a.context=function(c){return arguments.length?(c==null?i=o=null:o=r(i=c),a):i},a}function ti(n,t,e){var i=null,r=Rt(!0),o=null,s=Si,a=null,c=Lr(l);n=typeof n=="function"?n:n===void 0?Cc:Rt(+n),t=typeof t=="function"?t:Rt(t===void 0?0:+t),e=typeof e=="function"?e:e===void 0?Pc:Rt(+e);function l(f){var u,d,p,y=(f=_c(f)).length,g,m=!1,b,x=new Array(y),v=new Array(y);for(o==null&&(a=s(b=c())),u=0;u<=y;++u){if(!(u<y&&r(g=f[u],u,f))===m)if(m=!m)d=u,a.areaStart(),a.lineStart();else{for(a.lineEnd(),a.lineStart(),p=u-1;p>=d;--p)a.point(x[p],v[p]);a.lineEnd(),a.areaEnd()}m&&(x[u]=+n(g,u,f),v[u]=+t(g,u,f),a.point(i?+i(g,u,f):x[u],e?+e(g,u,f):v[u]))}if(b)return a=null,b+""||null}function h(){return on().defined(r).curve(s).context(o)}return l.x=function(f){return arguments.length?(n=typeof f=="function"?f:Rt(+f),i=null,l):n},l.x0=function(f){return arguments.length?(n=typeof f=="function"?f:Rt(+f),l):n},l.x1=function(f){return arguments.length?(i=f==null?null:typeof f=="function"?f:Rt(+f),l):i},l.y=function(f){return arguments.length?(t=typeof f=="function"?f:Rt(+f),e=null,l):t},l.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Rt(+f),l):t},l.y1=function(f){return arguments.length?(e=f==null?null:typeof f=="function"?f:Rt(+f),l):e},l.lineX0=l.lineY0=function(){return h().x(n).y(t)},l.lineY1=function(){return h().x(n).y(e)},l.lineX1=function(){return h().x(i).y(t)},l.defined=function(f){return arguments.length?(r=typeof f=="function"?f:Rt(!!f),l):r},l.curve=function(f){return arguments.length?(s=f,o!=null&&(a=s(o)),l):s},l.context=function(f){return arguments.length?(f==null?o=a=null:a=s(o=f),l):o},l}function E2(n,t){return t<n?-1:t>n?1:t>=n?0:NaN}function T2(n){return n}function L2(){var n=T2,t=E2,e=null,i=Rt(0),r=Rt(Tr),o=Rt(0);function s(a){var c,l=(a=_c(a)).length,h,f,u=0,d=new Array(l),p=new Array(l),y=+i.apply(this,arguments),g=Math.min(Tr,Math.max(-Tr,r.apply(this,arguments)-y)),m,b=Math.min(Math.abs(g)/l,o.apply(this,arguments)),x=b*(g<0?-1:1),v;for(c=0;c<l;++c)(v=p[d[c]=c]=+n(a[c],c,a))>0&&(u+=v);for(t!=null?d.sort(function(k,M){return t(p[k],p[M])}):e!=null&&d.sort(function(k,M){return e(a[k],a[M])}),c=0,f=u?(g-l*x)/u:0;c<l;++c,y=m)h=d[c],v=p[h],m=y+(v>0?v*f:0)+x,p[h]={data:a[h],index:c,value:v,startAngle:y,endAngle:m,padAngle:b};return p}return s.value=function(a){return arguments.length?(n=typeof a=="function"?a:Rt(+a),s):n},s.sortValues=function(a){return arguments.length?(t=a,e=null,s):t},s.sort=function(a){return arguments.length?(e=a,t=null,s):e},s.startAngle=function(a){return arguments.length?(i=typeof a=="function"?a:Rt(+a),s):i},s.endAngle=function(a){return arguments.length?(r=typeof a=="function"?a:Rt(+a),s):r},s.padAngle=function(a){return arguments.length?(o=typeof a=="function"?a:Rt(+a),s):o},s}var zf=Ec(Si);function Bf(n){this._curve=n}Bf.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(n,t){this._curve.point(t*Math.sin(n),t*-Math.cos(n))}};function Ec(n){function t(e){return new Bf(n(e))}return t._curve=n,t}function $r(n){var t=n.curve;return n.angle=n.x,delete n.x,n.radius=n.y,delete n.y,n.curve=function(e){return arguments.length?t(Ec(e)):t()._curve},n}function $2(){return $r(on().curve(zf))}function I2(){var n=ti().curve(zf),t=n.curve,e=n.lineX0,i=n.lineX1,r=n.lineY0,o=n.lineY1;return n.angle=n.x,delete n.x,n.startAngle=n.x0,delete n.x0,n.endAngle=n.x1,delete n.x1,n.radius=n.y,delete n.y,n.innerRadius=n.y0,delete n.y0,n.outerRadius=n.y1,delete n.y1,n.lineStartAngle=function(){return $r(e())},delete n.lineX0,n.lineEndAngle=function(){return $r(i())},delete n.lineX1,n.lineInnerRadius=function(){return $r(r())},delete n.lineY0,n.lineOuterRadius=function(){return $r(o())},delete n.lineY1,n.curve=function(s){return arguments.length?t(Ec(s)):t()._curve},n}class Of{constructor(t,e){this._context=t,this._x=e}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,e){switch(t=+t,e=+e,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,e):this._context.moveTo(t,e);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,e,t,e):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+e)/2,t,this._y0,t,e);break}}this._x0=t,this._y0=e}}function F2(n){return new Of(n,!0)}function R2(n){return new Of(n,!1)}function D2(n){return n.source}function z2(n){return n.target}function Nf(n){let t=D2,e=z2,i=Cc,r=Pc,o=null,s=null,a=Lr(c);function c(){let l;const h=P2.call(arguments),f=t.apply(this,h),u=e.apply(this,h);if(o==null&&(s=n(l=a())),s.lineStart(),h[0]=f,s.point(+i.apply(this,h),+r.apply(this,h)),h[0]=u,s.point(+i.apply(this,h),+r.apply(this,h)),s.lineEnd(),l)return s=null,l+""||null}return c.source=function(l){return arguments.length?(t=l,c):t},c.target=function(l){return arguments.length?(e=l,c):e},c.x=function(l){return arguments.length?(i=typeof l=="function"?l:Rt(+l),c):i},c.y=function(l){return arguments.length?(r=typeof l=="function"?l:Rt(+l),c):r},c.context=function(l){return arguments.length?(l==null?o=s=null:s=n(o=l),c):o},c}function B2(){return Nf(F2)}function O2(){return Nf(R2)}const bn={draw(n,t){const e=De(t/Ui);n.moveTo(e,0),n.arc(0,0,e,0,Tr)}},ds={draw(n,t){const e=De(t/5)/2;n.moveTo(-3*e,-e),n.lineTo(-e,-e),n.lineTo(-e,-3*e),n.lineTo(e,-3*e),n.lineTo(e,-e),n.lineTo(3*e,-e),n.lineTo(3*e,e),n.lineTo(e,e),n.lineTo(e,3*e),n.lineTo(-e,3*e),n.lineTo(-e,e),n.lineTo(-3*e,e),n.closePath()}},Wf=De(1/3),N2=Wf*2,ps={draw(n,t){const e=De(t/N2),i=e*Wf;n.moveTo(0,-e),n.lineTo(i,0),n.lineTo(0,e),n.lineTo(-i,0),n.closePath()}},gs={draw(n,t){const e=De(t),i=-e/2;n.rect(i,i,e,e)}},Tc=De(3),ms={draw(n,t){const e=-De(t/(Tc*3));n.moveTo(0,e*2),n.lineTo(-Tc*e,-e),n.lineTo(Tc*e,-e),n.closePath()}},W2=De(3),ys={draw(n,t){const e=De(t)*.6824,i=e/2,r=e*W2/2;n.moveTo(0,-e),n.lineTo(r,i),n.lineTo(-r,i),n.closePath()}};function Ve(n,t){let e=null,i=Lr(r);n=typeof n=="function"?n:Rt(n||bn),t=typeof t=="function"?t:Rt(t===void 0?64:+t);function r(){let o;if(e||(e=o=i()),n.apply(this,arguments).draw(e,+t.apply(this,arguments)),o)return e=null,o+""||null}return r.type=function(o){return arguments.length?(n=typeof o=="function"?o:Rt(o),r):n},r.size=function(o){return arguments.length?(t=typeof o=="function"?o:Rt(+o),r):t},r.context=function(o){return arguments.length?(e=o??null,r):e},r}function Hf(){}function Vf(n,t,e){n._context.bezierCurveTo(n._x1+n._k*(n._x2-n._x0),n._y1+n._k*(n._y2-n._y0),n._x2+n._k*(n._x1-t),n._y2+n._k*(n._y1-e),n._x2,n._y2)}function Lc(n,t){this._context=n,this._k=(1-t)/6}Lc.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Vf(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2,this._x1=n,this._y1=t;break;case 2:this._point=3;default:Vf(this,n,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=n,this._y0=this._y1,this._y1=this._y2,this._y2=t}},function n(t){function e(i){return new Lc(i,t)}return e.tension=function(i){return n(+i)},e}(0);function H2(n,t,e){var i=n._x1,r=n._y1,o=n._x2,s=n._y2;if(n._l01_a>Ce){var a=2*n._l01_2a+3*n._l01_a*n._l12_a+n._l12_2a,c=3*n._l01_a*(n._l01_a+n._l12_a);i=(i*a-n._x0*n._l12_2a+n._x2*n._l01_2a)/c,r=(r*a-n._y0*n._l12_2a+n._y2*n._l01_2a)/c}if(n._l23_a>Ce){var l=2*n._l23_2a+3*n._l23_a*n._l12_a+n._l12_2a,h=3*n._l23_a*(n._l23_a+n._l12_a);o=(o*l+n._x1*n._l23_2a-t*n._l12_2a)/h,s=(s*l+n._y1*n._l23_2a-e*n._l12_2a)/h}n._context.bezierCurveTo(i,r,o,s,n._x2,n._y2)}function Gf(n,t){this._context=n,this._alpha=t}Gf.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(n,t){if(n=+n,t=+t,this._point){var e=this._x2-n,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;break;case 2:this._point=3;default:H2(this,n,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=n,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const $c=function n(t){function e(i){return t?new Gf(i,t):new Lc(i,0)}return e.alpha=function(i){return n(+i)},e}(.5);function Yf(n){this._context=n}Yf.prototype={areaStart:Hf,areaEnd:Hf,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(n,t){n=+n,t=+t,this._point?this._context.lineTo(n,t):(this._point=1,this._context.moveTo(n,t))}};function V2(n){return new Yf(n)}function xs(n,t){this._context=n,this._t=t}xs.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(n,t){switch(n=+n,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(n,t):this._context.moveTo(n,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(n,t);else{var e=this._x*(1-this._t)+n*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,t)}break}}this._x=n,this._y=t}};function Xf(n){return new xs(n,.5)}function Uf(n){return new xs(n,0)}function jf(n){return new xs(n,1)}class qf{constructor(t,e,i,r,o,s){var m;if(this.width=0,this.height=0,this.brush=null,this.brushGroup=null,this.programmatic=!1,this.config=t,this.events=o,!t.enabled){this.group=e.append("g").style("display","none");return}this.height=t.height||40,t.margin;const a=r-this.height-10;this.width=i.width,this.group=e.append("g").attr("class","katucharts-navigator").attr("transform",`translate(${i.x},${a})`);const c=t.maskFill??"rgba(102,133,194,0.3)",l=t.maskInside??!0,h=((m=t.series)==null?void 0:m.color)??"#6699cc",f=t.handles||{},u=f.backgroundColor??"#f2f2f2",d=f.borderColor??"#999999",p=f.enabled!==!1;this.group.append("rect").attr("width",this.width).attr("height",this.height).attr("fill","#f2f2f2").attr("stroke",t.outlineColor||"#cccccc").attr("stroke-width",t.outlineWidth||1),this.renderSeriesLine(s,h);const y=g2().extent([[0,0],[this.width,this.height]]).on("end",b=>{if(this.programmatic||!b.selection)return;const[x,v]=b.selection;o.emit("navigator:brushed",{x0:x/this.width,x1:v/this.width})});this.brush=y;const g=this.group.append("g").attr("class","katucharts-navigator-brush").call(y);this.brushGroup=g,g.selectAll(".selection").attr("fill",l?c:"none").attr("stroke","none"),p?g.selectAll(".handle").attr("fill",u).attr("stroke",d).attr("stroke-width",f.lineWidth??1):g.selectAll(".handle").style("display","none"),t.adaptToUpdatedData!==!1&&o.on("series:dataUpdated",b=>{this.updateSeriesLine(b,h)})}renderSeriesLine(t,e){if(t.length===0)return;const i=[Math.min(...t.map(c=>c.x)),Math.max(...t.map(c=>c.x))],r=[Math.min(...t.map(c=>c.y)),Math.max(...t.map(c=>c.y))],o=Me().domain(i).range([0,this.width]),s=Me().domain(r).range([this.height-2,2]),a=on().x(c=>o(c.x)).y(c=>s(c.y));this.group.selectAll(".katucharts-navigator-line").remove(),this.group.append("path").datum(t).attr("class","katucharts-navigator-line").attr("d",a).attr("fill","none").attr("stroke",e).attr("stroke-width",1)}updateSeriesLine(t,e){this.renderSeriesLine(t,e)}setSelection(t,e){if(!(!this.brush||!this.brushGroup)){if(this.programmatic=!0,t<=5e-4&&e>=.9995)this.brush.move(this.brushGroup,null);else{const i=Math.max(0,Math.min(1,t))*this.width,r=Math.max(0,Math.min(1,e))*this.width;this.brush.move(this.brushGroup,[Math.min(i,r),Math.max(i,r)])}this.programmatic=!1}}destroy(){this.group.remove()}}class Zf{constructor(t,e,i){if(this.container=null,this.config=t,this.events=i,!t.enabled)return;this.container=hc("katucharts-range-selector",e),Object.assign(this.container.style,{display:"flex",gap:`${t.buttonSpacing??4}px`,padding:"5px",alignItems:"center",flexWrap:"wrap",fontSize:"12px"}),t.floating&&(this.container.style.position="absolute",this.container.style.zIndex="10"),t.x!==void 0&&(this.container.style.left=`${t.x}px`),t.y!==void 0&&(this.container.style.top=`${t.y}px`);const r=t.buttonPosition||{};r.align==="right"?this.container.style.justifyContent="flex-end":r.align==="center"&&(this.container.style.justifyContent="center");const o=t.buttons||[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],s=t.buttonTheme||{},a=t.allButtonsEnabled??!1;if(o.forEach((c,l)=>{const h=document.createElement("button");h.textContent=c.text||c.type||"",h.title=c.title||"";const f=l===(t.selected??0),u=s["states.select.fill"]||s.fill||"#e0e0e0",d=s.fill||"#fff";Object.assign(h.style,{padding:s.padding||"3px 8px",border:`1px solid ${s.stroke||"#ccc"}`,borderRadius:`${s.r??3}px`,backgroundColor:f?u:d,cursor:"pointer",fontSize:s["style.fontSize"]||"11px",fontWeight:s["style.fontWeight"]||"normal",color:s["style.color"]||"#333"}),!a&&!f&&(h.style.opacity="0.8"),h.addEventListener("click",()=>{var p;(p=c.events)!=null&&p.click&&c.events.click.call(c,new Event("click")),this.container.querySelectorAll("button").forEach(y=>{y.style.backgroundColor=d,y.style.opacity=a?"1":"0.8"}),h.style.backgroundColor=u,h.style.opacity="1",i.emit("rangeSelector:selected",{type:c.type,count:c.count,index:l})}),this.container.appendChild(h)}),t.inputEnabled!==!1){const c=t.inputPosition||{},l=document.createElement("div");l.style.display="flex",l.style.alignItems="center",l.style.gap="4px",l.style.marginLeft=c.x!==void 0?`${c.x}px`:"10px";const h=t.inputStyle||{},f=t.inputBoxBorderColor||"#ccc",u=t.inputBoxHeight??22,d=t.inputBoxWidth??90,p=document.createElement("input");p.type="date",Object.assign(p.style,{fontSize:h.fontSize||"11px",border:`1px solid ${f}`,height:`${u}px`,width:`${d}px`,padding:"0 4px",color:h.color||"#333"});const y=document.createElement("input");y.type="date",Object.assign(y.style,{fontSize:h.fontSize||"11px",border:`1px solid ${f}`,height:`${u}px`,width:`${d}px`,padding:"0 4px",color:h.color||"#333"});const g=()=>{p.value&&y.value&&i.emit("rangeSelector:dateRange",{from:new Date(p.value).getTime(),to:new Date(y.value).getTime()})};p.addEventListener("change",g),y.addEventListener("change",g);const m=t.labelStyle||{},b=document.createElement("span");b.textContent=" to ",b.style.fontSize=m.fontSize||"11px",b.style.color=m.color||"#666",l.appendChild(p),l.appendChild(b),l.appendChild(y),this.container.appendChild(l)}}destroy(){this.container&&this.container.remove()}}const G2=[{type:"month",count:1,text:"1m"},{type:"month",count:3,text:"3m"},{type:"month",count:6,text:"6m"},{type:"ytd",text:"YTD"},{type:"year",count:1,text:"1y"},{type:"all",text:"All"}],Y2={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5,week:6048e5,month:2592e6,year:31536e6};class X2{constructor(t){this.host=t,this.navigator=null,this.rangeSelector=null,this.xMin=0,this.xMax=0}setup(){var a,c;const t=this.host.getOptions(),e=(a=t.navigator)==null?void 0:a.enabled,i=(c=t.rangeSelector)==null?void 0:c.enabled;if(!e&&!i)return;const r=this.getBaseSeriesData();r.length>0&&(this.xMin=r[0].x,this.xMax=r[r.length-1].x);const o=this.host.getEvents(),s=t.rangeSelector;if(i&&(this.rangeSelector=new Zf(s,this.host.getContainer(),o),this.placeRangeSelectorOnTop(),o.on("rangeSelector:selected",l=>this.applyButton(l)),o.on("rangeSelector:dateRange",l=>this.applyXRange(l.from,l.to))),e&&(this.navigator=new qf(t.navigator,this.host.getSvg(),this.host.getLayout().plotArea,this.host.getChartHeight(),o,r),o.on("navigator:brushed",l=>{const h=this.xMax-this.xMin;this.applyXRange(this.xMin+l.x0*h,this.xMin+l.x1*h)})),i){const l=s.selected;if(l!=null){const h=(s.buttons||G2)[l];h&&this.applyButton(h)}}o.on("chart:afterZoom",()=>{const l=this.host.getXAxes()[0];if(l){const[h,f]=l.scale.domain();this.syncNavigator(+h,+f)}})}getBaseSeriesData(){const t=this.host.getSeriesInstances();return t.length===0?[]:t[0].data.map(i=>({x:i.x??0,y:i.close??i.y??0})).filter(i=>i.y!==null&&i.y!==void 0&&Number.isFinite(i.x))}placeRangeSelectorOnTop(){const t=this.host.getContainer(),e=t.querySelector(".katucharts-range-selector");e&&t.firstChild&&e!==t.firstChild&&t.insertBefore(e,t.firstChild)}applyButton(t){const e=t.type,i=t.count??1;if(e==="all"){this.applyXRange(this.xMin,this.xMax);return}if(e==="ytd"){const o=new Date(this.xMax),s=Date.UTC(o.getUTCFullYear(),0,1);this.applyXRange(Math.max(this.xMin,s),this.xMax);return}const r=Y2[e];r&&this.applyXRange(Math.max(this.xMin,this.xMax-i*r),this.xMax)}applyXRange(t,e){if(!(!Number.isFinite(t)||!Number.isFinite(e)||e<=t)){for(const i of this.host.getXAxes())i.updateDomain({min:t,max:e});this.host.rerender(),this.syncNavigator(t,e)}}syncNavigator(t,e){if(!this.navigator)return;const i=this.xMax-this.xMin;i<=0||this.navigator.setSelection((t-this.xMin)/i,(e-this.xMin)/i)}destroy(){var t,e;(t=this.navigator)==null||t.destroy(),(e=this.rangeSelector)==null||e.destroy()}}const U2=22,Xn=class Xn{constructor(t,e){var h,f;this.xAxes=[],this.yAxes=[],this.seriesInstances=[],this.tooltip=null,this.legend=null,this.crosshair=null,this.credits=null,this.exportButton=null,this.responsiveEngine=null,this.stock=null,this.clipPathId="",this.clipMargin=0,this.autoHeight=!1,this.resizeObserver=null,this.isResponsiveUpdate=!1,this.scrollableInner=null,this.scrollableOuterWidth=0,this.scrollableOuterHeight=0,this.useVerticalScroll=!1,this.useHorizontalScroll=!1,this.fixedAxisOverlay=null,this.container=Fv(t),this.container.style.position="relative";const i=new Jn;this.options=i.parse(e),this.originalUserOptions=go(e),vv(((h=this.options.time)==null?void 0:h.useUTC)!==!1),this.events=new Kh,this.state=new Ay(this.options,this.events),this.layoutEngine=new Cy;const r=uf(this.container,this.getDefaultHeightAspectRatio()),o=this.options.chart.width||r.width||600;let s=this.resolveHeight(this.options.chart.height,r.height);const a=this.options.chart.scrollablePlotArea,c=(a==null?void 0:a.minWidth)&&a.minWidth>o;if(this.autoHeight=this.options.chart.height==null&&!r.heightMeasured,this.chartWidth=c?a.minWidth:o,this.autoHeight){const u=a!=null&&a.minHeight?Math.min(a.minHeight,Xn.MAX_AUTO_HEIGHT):0;s=Math.max(this.fitHeightToContent(s),u)}const l=(a==null?void 0:a.minHeight)&&a.minHeight>s;this.chartHeight=l?a.minHeight:s,this.scrollableOuterWidth=o,this.scrollableOuterHeight=s,this.useVerticalScroll=!!l,this.useHorizontalScroll=!!c,(l||c)&&(this.container.style.position="relative",this.container.querySelectorAll(":scope > [data-katu-scrollable-inner]").forEach(p=>{var y;return(y=p.parentElement)==null?void 0:y.removeChild(p)}),this.container.querySelectorAll(":scope > svg[data-katu-fixed-overlay]").forEach(p=>{var y;return(y=p.parentElement)==null?void 0:y.removeChild(p)}),this.scrollableInner=document.createElement("div"),this.scrollableInner.setAttribute("data-katu-scrollable-inner","1"),this.scrollableInner.style.overflowX=c?"auto":"hidden",this.scrollableInner.style.overflowY=l?"auto":"hidden",this.scrollableInner.style.width=o+"px",this.scrollableInner.style.height=s+"px",this.container.appendChild(this.scrollableInner)),this.setupResponsive(),this.applyInitialResponsiveRules(),this.autoHeight&&!this.useVerticalScroll&&(this.chartHeight=this.fitHeightToContent(this.chartHeight),this.scrollableOuterHeight=this.chartHeight),this.renderer=new _o(this.scrollableInner||this.container,this.chartWidth,this.chartHeight),this.scrollableInner&&this.renderer.svg.style("max-width","none"),this.exporter=new Uv({getRenderer:()=>this.renderer,getOptions:()=>this.options,getContainer:()=>this.container,getSeriesInstances:()=>this.seriesInstances,setSize:(u,d)=>this.setSize(u,d),fireEvent:(u,...d)=>this.fireEvent(u,...d),getDefaultHeightAspectRatio:()=>this.getDefaultHeightAspectRatio(),disconnectResizeObserver:()=>{var u;return(u=this.resizeObserver)==null?void 0:u.disconnect()},observeResizeObserver:()=>{var u;return(u=this.resizeObserver)==null?void 0:u.observe(this.container)},getViewportSize:()=>this.getViewportSize(),fitToViewport:(u,d)=>this.fitToViewport(u,d)}),this.axes=new jv({getOptions:()=>this.options,getLayout:()=>this.layout,getSeriesInstances:()=>this.seriesInstances,getXAxes:()=>this.xAxes,getYAxes:()=>this.yAxes,getAxisGroup:()=>this.axisGroup,getEvents:()=>this.events,getTooltip:()=>this.tooltip}),this.interactions=new s2({getOptions:()=>this.options,getContainer:()=>this.container,getEvents:()=>this.events,getRenderer:()=>this.renderer,getSeriesGroup:()=>this.seriesGroup,getPlotGroup:()=>this.plotGroup,getLayout:()=>this.layout,getXAxes:()=>this.xAxes,getYAxes:()=>this.yAxes,getSeriesInstances:()=>this.seriesInstances,setSeries:u=>{this.options.series=u},rebuild:()=>{var u;this.seriesInstances.forEach(d=>d.destroy()),this.seriesInstances=[],this.buildAxes(),this.buildSeries(),this.renderAll(),(u=this.credits)==null||u.refresh()},renderAfterZoom:()=>{this.renderAxes(),this.renderSeriesInstances(),this.renderLegend()},fireEvent:(u,...d)=>this.fireEvent(u,...d)}),this.applyChartStyles(),this.computeLayout(),this.createStructuralGroups(),this.buildAxes(),this.buildSeries(),this.renderAll(),(f=this.credits)==null||f.refresh(),(l||c)&&this.createFixedAxisOverlay(),this.options.chart.reflow&&this.setupReflow(),this.interactions.setup(),this.stock=new X2({getOptions:()=>this.options,getContainer:()=>this.container,getEvents:()=>this.events,getSvg:()=>this.renderer.svg,getLayout:()=>this.layout,getChartHeight:()=>this.chartHeight,getXAxes:()=>this.xAxes,getSeriesInstances:()=>this.seriesInstances,rerender:()=>{this.renderAxes(),this.renderSeriesInstances(),this.renderLegend()}}),this.stock.setup(),this.fireEvent("load")}createFixedAxisOverlay(){const t=Xv({container:this.container,renderer:this.renderer,options:this.options,plotGroup:this.plotGroup,layout:this.layout,chartWidth:this.chartWidth,chartHeight:this.chartHeight,scrollableInner:this.scrollableInner,scrollableOuterWidth:this.scrollableOuterWidth,scrollableOuterHeight:this.scrollableOuterHeight,useVerticalScroll:this.useVerticalScroll,useHorizontalScroll:this.useHorizontalScroll,exportButton:this.exportButton,previousOverlay:this.fixedAxisOverlay});t&&(this.fixedAxisOverlay=t)}getDefaultHeightAspectRatio(){var i;const t=((i=this.options)==null?void 0:i.series)||[],e=new Set(t.map(r=>{var o,s;return(r==null?void 0:r.type)||((s=(o=this.options)==null?void 0:o.chart)==null?void 0:s.type)}));return e.has("dependencywheel")||e.has("networkgraph")?1:e.has("treemap")||e.has("sankey")?.3:e.has("pie")||e.has("donut")||e.has("radar")?.6:.5}fitHeightToContent(t){const r=4e3-this.layoutEngine.compute(this.options,this.chartWidth,4e3).plotArea.height,o=Math.max(Xn.MIN_AUTO_PLOT_HEIGHT,this.verticalCategoryCount()*Xn.MIN_CATEGORY_ROW_HEIGHT),s=Math.ceil(r+o);return s<=t?t:Math.min(s,Math.max(t,Xn.MAX_AUTO_HEIGHT))}verticalCategoryCount(){var o;const i=(this.options.series||[]).some(s=>s._internalType==="heatmap")?this.options.yAxis:this.options.chart.inverted?this.options.xAxis:null;if(!i)return 0;let r=0;for(const s of i){const a=((o=s.categories)==null?void 0:o.length)??0;a>r&&(r=a)}return r}resolveHeight(t,e){if(typeof t=="number")return t;if(typeof t=="string"){if(t.endsWith("%"))return parseFloat(t)/100*e;const i=parseFloat(t);if(!isNaN(i)&&i>0)return i}return e||400}applyChartStyles(){const t=this.options.chart.backgroundColor;t&&this.renderer.svg.append("rect").attr("class","katucharts-background").attr("width",this.chartWidth).attr("height",this.chartHeight).attr("fill",t).attr("rx",this.options.chart.borderRadius??0),this.options.chart.borderWidth&&this.renderer.svg.append("rect").attr("class","katucharts-border").attr("width",this.chartWidth).attr("height",this.chartHeight).attr("fill","none").attr("stroke",this.options.chart.borderColor||"#335cad").attr("stroke-width",this.options.chart.borderWidth).attr("rx",this.options.chart.borderRadius??0)}computeLayout(){this.layout=this.layoutEngine.compute(this.options,this.chartWidth,this.chartHeight)}createStructuralGroups(){var a,c,l,h,f;this.titleGroup=this.renderer.createGroup("katucharts-title-group"),this.renderTitles(),this.plotGroup=this.renderer.createGroup("katucharts-plot-group"),this.plotGroup.attr("transform",`translate(${this.layout.plotArea.x},${this.layout.plotArea.y})`);const t=this.options.chart.plotBackgroundColor;t&&this.plotGroup.append("rect").attr("class","katucharts-plot-background").attr("width",this.layout.plotArea.width).attr("height",this.layout.plotArea.height).attr("fill",t);const e=this.options.chart.plotBorderWidth;e&&this.plotGroup.append("rect").attr("class","katucharts-plot-border").attr("width",this.layout.plotArea.width).attr("height",this.layout.plotArea.height).attr("fill","none").attr("stroke",this.options.chart.plotBorderColor||"#cccccc").attr("stroke-width",e),this.options.chart.plotShadow&&((a=this.plotGroup.node())==null||a.setAttribute("filter","drop-shadow(3px 3px 6px rgba(0,0,0,0.15))")),this.axisGroup=this.renderer.createGroup("katucharts-axis-group",this.plotGroup),this.seriesGroup=this.renderer.createGroup("katucharts-series-group",this.plotGroup),this.stackLabelsGroup=this.renderer.createGroup("katucharts-stack-labels-group",this.plotGroup);const i=this.options.series.some(u=>u.clip===!1||Mg.has(u._internalType));this.clipMargin=!Js(this.options.series)&&!i?U2:0,this.clipPathId=this.renderer.createClipPath(-this.clipMargin,-this.clipMargin,this.layout.plotArea.width+2*this.clipMargin,this.layout.plotArea.height+2*this.clipMargin),!Js(this.options.series)&&!i&&this.seriesGroup.attr("clip-path",`url(#${this.clipPathId})`),this.tooltip=new os(this.options.tooltip,this.container,this.layout.plotArea,this.events),(c=this.options.tooltip)!=null&&c.shared&&this.tooltip.setSharedPointsProvider(u=>this.collectSharedPointsAt(u)),this.legend=new ss({...this.options.legend,_backgroundColor:this.options.chart.backgroundColor},this.renderer.svg,this.events),this.credits=new Ov(this.options.credits,this.renderer.svg,this.chartWidth,this.chartHeight),this.options.exporting.enabled!==!1&&(this.exportButton=new mf(this.options.exporting,this.renderer.svg,this.container,this.chartWidth,this.chartHeight,u=>this.handleExportAction(u)));let r=(l=this.options.xAxis[0])==null?void 0:l.crosshair,o=(h=this.options.yAxis[0])==null?void 0:h.crosshair;const s=(f=this.options.tooltip)==null?void 0:f.crosshairs;if(s){const u=Array.isArray(s)?s[0]:s,d=Array.isArray(s)?s[1]:!1;u&&!r&&(r=typeof u=="object"?u:!0),d&&!o&&(o=typeof d=="object"?d:!0)}(r||o)&&(this.crosshair=new df(r,o,this.plotGroup,this.layout.plotArea,this.events))}renderTitles(){Yv({titleGroup:this.titleGroup,container:this.container,options:this.options,layout:this.layout,chartWidth:this.chartWidth})}buildAxes(){const t=this.options.series.some(e=>e._internalType==="heatmap");this.xAxes=this.options.xAxis.map(e=>lc(t?{...e,_centerTitleOnChart:!0,_chartWidth:this.chartWidth}:e,this.layout.plotArea)),this.yAxes=this.options.yAxis.map(e=>lc(e,this.layout.plotArea))}buildSeries(){const t=this.options;this.seriesInstances=t.series.map((e,i)=>{const r=e._internalType,o=St.getType(r);if(!o){console.warn(`KatuCharts: unknown series type "${r}", falling back to line`);const s=St.getType("line");if(!s)throw new Error("KatuCharts: line series type not registered");return new s(e)}return new o(e)})}collectSharedPointsAt(t){var r;const e=[],i=typeof t=="number"?t:NaN;for(let o=0;o<this.seriesInstances.length;o++){const s=this.seriesInstances[o],a=this.options.series[o];if(!s.visible||a.enableMouseTracking===!1)continue;const c=s.data;if(!c||c.length===0)continue;let l=null,h=1/0;for(const p of c){if(p.x===void 0||p.x===null)continue;const y=Math.abs(p.x-i);y<h&&(h=y,l=p)}if(!l)continue;const f=l.close??l.y??l.high;if(f==null)continue;const u=this.xAxes[a._xAxisIndex]||this.xAxes[0],d=this.yAxes[a._yAxisIndex]||this.yAxes[0];e.push({point:l,plotX:u.getPixelForValue(l.x),plotY:d.getPixelForValue(f),series:{name:a.name??"",color:((r=s.getColor)==null?void 0:r.call(s))??a.color??"#333",config:a}})}return e}renderAll(){this.updateAxesDomains(),this.updateTooltipCategories(),this.renderAxes(),this.renderSeriesInstances(),this.renderStackLabels(),this.raiseplotLineLabels(),this.renderLegend(),this.fireEvent("render")}formatStackLabel(t,e){return e.formatter?e.formatter.call({total:t}):e.format?re(Zt(e.format,{total:t})):this.options.chart.numberFormatter?this.options.chart.numberFormatter(t):es(t,0,".",",")}renderStackLabels(){if(this.stackLabelsGroup){this.stackLabelsGroup.selectAll("*").remove();for(let t=0;t<this.yAxes.length;t++){const i=this.yAxes[t].config.stackLabels;if(!(i!=null&&i.enabled))continue;const r=this.seriesInstances.map((a,c)=>({series:a,cfg:this.options.series[c]})).filter(({series:a,cfg:c})=>a.visible&&c._yAxisIndex===t&&(c._internalType==="column"||c._internalType==="bar")&&c.stacking&&c.stacking!=="percent");if(r.length===0)continue;const o=new Map;for(const{series:a,cfg:c}of r){const l=as(c);o.has(l)||o.set(l,{totals:new Map,series:[],type:c._internalType,xAxis:this.xAxes[c._xAxisIndex]||this.xAxes[0],yAxis:this.yAxes[c._yAxisIndex]||this.yAxes[0]});const h=o.get(l);h.series.push(a),Vv(a.data,h.totals)}const s=this.stackLabelsGroup.append("g").attr("class",`katucharts-stack-labels katucharts-stack-labels-axis-${t}`);for(const[a,c]of o){const l=s.append("g").attr("class","katucharts-stack-labels-stack").attr("data-stack-key",a);for(const[h,f]of c.totals.entries()){if(!isFinite(f)||f===0)continue;const u=this.formatStackLabel(f,i),d=c.type==="bar",p=f<0,y=c.xAxis.getPixelForValue(h),g=c.yAxis.getPixelForValue(f),m=d?p?"end":"start":"middle",b=d?"central":p?"hanging":"auto",x=d?g+(p?-6:6):y,v=d?y:g+(p?6:-6),k=x+(i.x??0),M=v+(i.y??0),C=l.append("text").attr("class","katucharts-stack-label").attr("x",k).attr("y",M).attr("text-anchor",i.align==="left"?"start":i.align==="right"?"end":m).text(u);i.verticalAlign==="middle"||d?C.attr("dominant-baseline",b):i.verticalAlign==="bottom"&&C.attr("dominant-baseline","hanging");const E=i.style||{};C.style("fill",E.color??"#000000").style("font-size",E.fontSize??"11px").style("font-weight",E.fontWeight??"bold"),E.textOutline&&C.style("text-shadow",E.textOutline),i.rotation&&C.attr("transform",`rotate(${i.rotation},${k},${M})`)}}}}}raiseplotLineLabels(){const t=this.plotGroup.node();t&&this.axisGroup.selectAll(".katucharts-plot-line-label").each(function(){t.appendChild(this)})}updateTooltipCategories(){this.axes.updateTooltipCategories()}updateAxesDomains(){this.axes.updateAxesDomains()}buildAbsStackTotals(t,e){const i=new Map;for(const r of t.keys()){const o=new Map,s=t.get(r),a=e.get(r)||new Map;for(const c of new Set([...s.keys(),...a.keys()]))o.set(c,Gv(c,s,a));i.set(r,o)}return i}renderAxes(){this.axes.renderAxes()}renderSeriesInstances(){var p;this.seriesGroup.selectAll("*").remove();const t=new Map,e=new Map;for(const y of this.options.series){const g=y._internalType;t.set(g,(t.get(g)||0)+1),e.set(g,0)}const i=this.options.chart.animation!==!1,r=as,o=new Map,s=new Map,a=new Map,c=new Map,l=new Map,h=new Map;for(let y=0;y<this.options.series.length;y++){const g=this.options.series[y];if(g.stacking){const m=r(g);o.set(m,(o.get(m)||0)+1),a.has(m)||(a.set(m,new Map),c.set(m,new Map));const b=this.seriesInstances[y];b.processData(),_r(b.data,a.get(m),c.get(m))}}const f=this.buildAbsStackTotals(a,c),u=new Map,d=new Map;for(let y=0;y<this.options.series.length;y++){const g=this.options.series[y];if(!g.stacking)continue;const m=r(g);u.has(m)||(u.set(m,new Map),d.set(m,new Map)),l.set(y,new Map(u.get(m))),h.set(y,new Map(d.get(m))),_r(this.seriesInstances[y].data,u.get(m),d.get(m))}for(let y=0;y<this.seriesInstances.length;y++){const g=this.seriesInstances[y],m=this.options.series[y],b=this.xAxes[m._xAxisIndex]||this.xAxes[0],x=this.yAxes[m._yAxisIndex]||this.yAxes[0],v=m._internalType,k=e.get(v)||0;e.set(v,k+1);let M,C;m.stacking&&(M=l.get(y)||new Map,C=h.get(y)||new Map);const E={plotArea:this.layout.plotArea,chartWidth:this.chartWidth,xAxis:b,yAxis:x,colorIndex:y,colors:this.options.colors,events:this.events,chartGroup:this.seriesGroup,plotGroup:this.plotGroup,totalSeriesOfType:m.stacking?o.get(r(m))||1:t.get(v)||1,indexInType:m.stacking?s.get(r(m))||0:k,animate:i&&m.animation!==!1,stackOffsets:M,stackOffsetsPos:M,stackOffsetsNeg:C,stackTotals:m.stacking?f.get(r(m)):void 0,allSeries:this.seriesInstances,inverted:!!this.options.chart.inverted,legendConfig:this.options.legend,pane:this.options.pane,backgroundColor:this.options.chart.backgroundColor};if(g.processData(),g.init(E),g.render(),m.stacking){const _=r(m);s.set(_,(s.get(_)||0)+1)}g.setOnVisibilityChange(_=>this.animatedRedraw(_)),(p=m.dataLabels)!=null&&p.enabled&&!wg.has(m._internalType)&&!kg.has(m._internalType)&&rs.render(g.group,g.data,m.dataLabels,b,x,m.name||"")}this.reorderSeriesByZIndex()}reorderSeriesByZIndex(){var o,s;const t=(s=(o=this.seriesGroup)==null?void 0:o.node)==null?void 0:s.call(o);if(!t)return;const e=Array.from(t.querySelectorAll(":scope > g.katucharts-series"));if(e.length<2)return;const i=new Map(this.seriesInstances.map(a=>[a.config.index,a.config.zIndex??0])),r=e.map((a,c)=>({g:a,i:c,z:i.get(Number(a.getAttribute("data-series-index")))??0}));r.sort((a,c)=>a.z-c.z||a.i-c.i);for(const a of r)t.appendChild(a.g)}renderLegend(){this.legend&&this.legend.render(this.seriesInstances,this.layout.legendArea)}setupReflow(){if(typeof ResizeObserver>"u")return;const t=Rv(()=>this.reflow(),100);this.resizeObserver=new ResizeObserver(t),this.resizeObserver.observe(this.container)}fireEvent(t,...e){var r;this.events.emit(`chart:${t}`,this,...e);const i=(r=this.options.chart.events)==null?void 0:r[t];typeof i=="function"&&i.call(this,...e)}get plotLeft(){return this.layout.plotArea.x}get plotTop(){return this.layout.plotArea.y}get plotWidth(){return this.layout.plotArea.width}get plotHeight(){return this.layout.plotArea.height}get plotRenderer(){const t=this.seriesGroup,e=this.xAxes,i=this.yAxes,r=this.layout.plotArea;return{rect(o,s,a,c){return t.insert("rect",":first-child").attr("x",o).attr("y",s).attr("width",a).attr("height",c)},circle(o,s,a){return t.insert("circle",":first-child").attr("cx",o).attr("cy",s).attr("r",a)},ellipse(o,s,a,c){return t.insert("ellipse",":first-child").attr("cx",o).attr("cy",s).attr("rx",a).attr("ry",c)},path(o){return t.insert("path",":first-child").attr("d",o)},line(o,s,a,c){return t.insert("line",":first-child").attr("x1",o).attr("y1",s).attr("x2",a).attr("y2",c)},text(o,s,a){return t.append("text").attr("x",s).attr("y",a).text(o)},group(o){const s=t.insert("g",":first-child");return o&&s.attr("class",o),s.style("pointer-events","none"),s},get plotArea(){return{x:0,y:0,width:r.width,height:r.height}},get localPlotArea(){return{x:0,y:0,width:r.width,height:r.height}},xAxis:{toPixels(o,s=0){var a;return((a=e[s])==null?void 0:a.getPixelForValue(o))??0}},yAxis:{toPixels(o,s=0){var a;return((a=i[s])==null?void 0:a.getPixelForValue(o))??0}}}}setupResponsive(){var t,e;(e=(t=this.options.responsive)==null?void 0:t.rules)!=null&&e.length&&(this.responsiveEngine=new yf(this.options.responsive))}applyInitialResponsiveRules(){if(!this.responsiveEngine)return;const t=this.responsiveEngine.evaluate(this.chartWidth,this.chartHeight);if(t.changed&&t.matchingIndices.length>0){const e=this.responsiveEngine.getRules();let i=go(this.originalUserOptions);for(const o of t.matchingIndices)i=ge(i,e[o].chartOptions);const r=new Jn;this.options=r.parse(i),this.state.updateConfig(this.options)}}addSeries(t,e=!0){this.originalUserOptions.series||(this.originalUserOptions.series=[]),this.originalUserOptions.series.push(t);const o={...new Jn().parse({series:[t]}).series[0],index:this.options.series.length};this.state.addSeries(o),this.options=this.state.getConfig();const s=St.getType(o._internalType)||St.getType("line");if(!s)throw new Error("KatuCharts: no series type registered");const a=new s(o);return this.seriesInstances.push(a),e&&this.redraw(),a}get(t){const e=this.seriesInstances.find(r=>r.config.id===t);if(e)return e;const i=this.xAxes.find(r=>r.config.id===t);return i||this.yAxes.find(r=>r.config.id===t)}canReuseSeriesInstances(t){return this.seriesInstances.length!==t.series.length?!1:this.seriesInstances.every((e,i)=>{var r;return e.config._internalType===((r=t.series[i])==null?void 0:r._internalType)})}syncSeriesInstances(t){for(let e=0;e<this.seriesInstances.length;e++){const i=this.seriesInstances[e],r={...t.series[e],visible:i.visible};this.options.series[e]=r,i.config=r,i.visible=r.visible!==!1,i.processData()}}update(t,e=!0){var a;this.isResponsiveUpdate||(this.originalUserOptions=ge(go(this.originalUserOptions),t));const i=new Jn,r=ge(this.optionsToExternal(),t);(a=t.chart)!=null&&a.type&&Array.isArray(r.series)&&r.series.forEach((c,l)=>{var f,u;const h=Array.isArray(t.series)?(f=t.series[l])==null?void 0:f.type:void 0;(u=this.options.series[l])!=null&&u._typeFromChart&&!h&&delete c.type});const o=i.parse(r),s=this.canReuseSeriesInstances(o);if(this.state.updateConfig(o),this.options=this.state.getConfig(),e)if(!s)this.redraw();else{this.buildAxes(),this.syncSeriesInstances(o);try{this.animatedRedraw(300)}catch{this.redraw()}}}animatedRedraw(t=500){this.updateAxesDomains(),this.updateTooltipCategories();for(const u of this.xAxes)u.animateAxis(this.axisGroup,this.layout.plotArea,t);for(const u of this.yAxes)u.animateAxis(this.axisGroup,this.layout.plotArea,t);const e=new Map,i=new Map,r=new Map,o=new Map,s=new Map,a=new Map,c=as,l=new Map,h=new Map;for(const u of this.seriesInstances){if(!u.visible)continue;const d=u.config._internalType;if(e.set(d,(e.get(d)||0)+1),u.config.stacking){const p=c(u.config);r.set(p,(r.get(p)||0)+1),s.has(p)||(s.set(p,new Map),a.set(p,new Map)),l.has(p)||(l.set(p,new Map),h.set(p,new Map)),_r(u.data,l.get(p),h.get(p))}}const f=this.buildAbsStackTotals(l,h);for(let u=0;u<this.seriesInstances.length;u++){const d=this.seriesInstances[u];if(!d.visible)continue;const p=this.options.series[u],y=p._internalType,g=i.get(y)||0;i.set(y,g+1);let m,b,x,v,k;if(p.stacking){const M=c(p);m=r.get(M)||1,b=o.get(M)||0,o.set(M,b+1),x=new Map(s.get(M)),v=new Map(a.get(M)),k=f.get(M)}else m=e.get(y)||1,b=g;d.updateContext({xAxis:this.xAxes[p._xAxisIndex]||this.xAxes[0],yAxis:this.yAxes[p._yAxisIndex]||this.yAxes[0],totalSeriesOfType:m,indexInType:b,stackOffsets:x,stackOffsetsPos:x,stackOffsetsNeg:v,stackTotals:k}),d.animateUpdate(t),p.stacking&&_r(d.data,s.get(c(p)),a.get(c(p)))}this.renderStackLabels(),this.renderTitles(),this.renderLegend(),this.fireEvent("render")}redraw(){this.computeLayout(),this.plotGroup.attr("transform",`translate(${this.layout.plotArea.x},${this.layout.plotArea.y})`),this.renderer.updateClipPath(this.clipPathId,-this.clipMargin,-this.clipMargin,this.layout.plotArea.width+2*this.clipMargin,this.layout.plotArea.height+2*this.clipMargin),this.buildAxes(),this.seriesInstances.forEach(t=>t.destroy()),this.seriesInstances=[],this.buildSeries(),this.renderAll(),this.tooltip&&this.tooltip.updatePlotArea(this.layout.plotArea),this.renderTitles(),this.fireEvent("redraw")}reflow(){if(this.options.chart.width)return;const t=uf(this.container,this.getDefaultHeightAspectRatio());let e=t.width,i=this.resolveHeight(this.options.chart.height,t.height);const r=this.options.chart.scrollablePlotArea;if(r!=null&&r.minWidth&&r.minWidth>e&&(e=r.minWidth),r!=null&&r.minHeight&&r.minHeight>i&&(i=r.minHeight),this.autoHeight&&!(r!=null&&r.minHeight)){const o=this.chartWidth;this.chartWidth=e,i=this.fitHeightToContent(i),this.chartWidth=o}if(!(e===this.chartWidth&&i===this.chartHeight)){if(this.responsiveEngine){const o=this.responsiveEngine.evaluate(e,i);if(o.changed){const s=this.responsiveEngine.getRules();let a=go(this.originalUserOptions);for(const c of o.matchingIndices)a=ge(a,s[c].chartOptions);this.isResponsiveUpdate=!0,this.update(a,!1),this.isResponsiveUpdate=!1}}this.setSize(e,i)}}setSize(t,e){var i,r;this.chartWidth=t,this.chartHeight=e,this.renderer.setSize(t,e),this.renderer.svg.select(".katucharts-background").attr("width",t).attr("height",e),this.renderer.svg.select(".katucharts-border").attr("width",t).attr("height",e),(i=this.exportButton)==null||i.updatePosition(t,e),(r=this.credits)==null||r.updatePosition(t,e),this.redraw()}getViewportSize(){return this.scrollableInner?{width:this.scrollableOuterWidth,height:this.scrollableOuterHeight}:{width:this.chartWidth,height:this.chartHeight}}fitToViewport(t,e){if(!this.scrollableInner){this.setSize(t,e);return}const i=this.options.chart.scrollablePlotArea;this.scrollableOuterWidth=t,this.scrollableOuterHeight=e,this.scrollableInner.style.width=t+"px",this.scrollableInner.style.height=e+"px";const r=Math.max((i==null?void 0:i.minWidth)||0,t),o=Math.max((i==null?void 0:i.minHeight)||0,e);this.setSize(r,o),this.createFixedAxisOverlay()}setTitle(t,e){t&&(this.options.title=ge(this.options.title,t),this.originalUserOptions.title=ge(this.originalUserOptions.title||{},t)),e&&(this.options.subtitle=ge(this.options.subtitle,e),this.originalUserOptions.subtitle=ge(this.originalUserOptions.subtitle||{},e)),this.renderTitles()}addAxis(t,e=!0,i=!0){const r=e?this.options.xAxis:this.options.yAxis,o={...t,index:r.length,isX:e};r.push(o);const s=lc(o,this.layout.plotArea);return(e?this.xAxes:this.yAxes).push(s),i&&this.redraw(),s}showLoading(t){let e=this.container.querySelector(".katucharts-loading");e||(e=document.createElement("div"),e.className="katucharts-loading",Object.assign(e.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",backgroundColor:"rgba(255,255,255,0.75)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",fontWeight:"bold",color:"#666",zIndex:"20"}),this.container.appendChild(e)),e.textContent=t||"Loading...",e.style.display="flex"}hideLoading(){const t=this.container.querySelector(".katucharts-loading");t&&(t.style.display="none")}destroy(){var i,r,o,s,a,c,l;this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.seriesInstances.forEach(h=>h.destroy()),(i=this.tooltip)==null||i.destroy(),(r=this.legend)==null||r.destroy(),(o=this.crosshair)==null||o.destroy(),(s=this.credits)==null||s.destroy(),(a=this.exportButton)==null||a.destroy(),this.interactions.destroy(),(c=this.stock)==null||c.destroy(),(l=this.responsiveEngine)==null||l.reset(),this.events.removeAllListeners(),this.renderer.destroy();const t=this.container.querySelector(".katucharts-loading");t&&t.remove();const e=this.container.querySelector(".katucharts-tooltip");e&&e.remove(),this.container.querySelectorAll(".katucharts-title-html, .katucharts-subtitle-html").forEach(h=>h.remove())}getSVG(){return this.exporter.getSVG()}getSeriesInstances(){return this.seriesInstances}get series(){return this.seriesInstances}getXAxes(){return this.xAxes}getYAxes(){return this.yAxes}handleExportAction(t){this.exporter.handleExportAction(t)}getCSV(){return this.exporter.getCSV()}getTable(){return this.exporter.getTable()}getDataRows(){return this.exporter.getDataRows()}exportChart(t,e){this.exporter.exportChart(t)}print(){this.exporter.print()}optionsToExternal(){return this.exporter.optionsToExternal()}};Xn.MIN_AUTO_PLOT_HEIGHT=160,Xn.MAX_AUTO_HEIGHT=450,Xn.MIN_CATEGORY_ROW_HEIGHT=22;let bs=Xn;const gt=600,Bt=8,Ic=0,ei=gt+100,Z=300,vs=250,dt=af,q=af,j2=500;function xe(n,t,e,i){return i>j2?t:t+n*e}const q2={Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",ShortDashDotDot:"6,2,2,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"};function sn(n){return!n||n==="Solid"?"none":q2[n]||"none"}function Kf(n,t){const e=n.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(e){const r=Math.min(255,parseInt(e[1],16)+Math.round(255*t)),o=Math.min(255,parseInt(e[2],16)+Math.round(255*t)),s=Math.min(255,parseInt(e[3],16)+Math.round(255*t));return`rgb(${r},${o},${s})`}const i=n.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(i){const r=Math.min(255,parseInt(i[1])+Math.round(255*t)),o=Math.min(255,parseInt(i[2])+Math.round(255*t)),s=Math.min(255,parseInt(i[3])+Math.round(255*t));return`rgb(${r},${o},${s})`}return n}class Ht{constructor(t){this.selectedPoints=new Set,this._cachedExtents=null,this.config=t,this.visible=t.visible!==!1,this.data=t._processedData||[]}init(t){this.context=t,this.group=t.chartGroup.append("g").attr("class",`katucharts-series katucharts-series-${this.config._internalType}`).attr("data-series-index",this.config.index),this.config.opacity!==void 0&&this.config.opacity!==1&&this.group.attr("opacity",this.config.opacity),this.config.zIndex!==void 0&&this.group.style("z-index",String(this.config.zIndex)),this.config.className&&this.group.classed(this.config.className,!0),this.config.shadow&&this.applyShadowFilter(),this.visible||this.group.style("display","none"),this.config.allowPointSelect&&this.data.forEach((e,i)=>{e.selected&&this.selectedPoints.add(i)}),this.group.on("mouseenter",()=>{var e,i;(i=(e=this.config.events)==null?void 0:e.mouseOver)==null||i.call(this,new Event("mouseOver")),this.context.events.emit("series:mouseenter",this)}).on("mouseleave",()=>{var e,i;(i=(e=this.config.events)==null?void 0:e.mouseOut)==null||i.call(this,new Event("mouseOut")),this.context.events.emit("series:mouseleave",this)})}setOnVisibilityChange(t){this._onVisibilityChange=t}processData(){this.data=this.config._processedData||[],this._cachedExtents=null}getColor(){return this.config.color||this.context.colors[this.context.colorIndex%this.context.colors.length]}autoLabelColor(t){return gn(this.context.backgroundColor,t)}labelHalo(){const t=this.labelHaloColor();return`0 0 3px ${t}, 0 0 3px ${t}`}labelHaloColor(){return gn(this.context.backgroundColor)==="#ffffff"?"rgba(0,0,0,0.85)":"#ffffff"}autoBorderColor(){const t=this.context.backgroundColor;return!t||t==="transparent"||t==="none"?"#ffffff":t}getMultiLegendItems(){return null}toggleLegendItem(t){return null}getLegendSymbolShape(){return null}getBubbleLegendInfo(){return null}animateUpdate(t){this.group.selectAll("*").remove(),this.render()}updateContext(t){Object.assign(this.context,t)}redraw(){this.group.selectAll("*").remove(),this.render()}setVisible(t,e=!0){var i,r,o,s;this.visible=t,t?(r=(i=this.config.events)==null?void 0:i.show)==null||r.call(this,new Event("show")):(s=(o=this.config.events)==null?void 0:o.hide)==null||s.call(this,new Event("hide")),e&&this._onVisibilityChange?(t?this.group.style("display","").attr("opacity",0).transition().duration(300).attr("opacity",this.config.opacity??1):this.group.transition().duration(300).attr("opacity",0).on("end",()=>{this.group.style("display","none")}),this._onVisibilityChange(500)):this.group.style("display",t?"":"none"),this.context.events.emit("series:visibilityChanged",this,t)}toggleVisible(){this.setVisible(!this.visible)}getDataExtents(){if(this._cachedExtents)return this._cachedExtents;let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data)o.x!==void 0&&o.x!==null&&(o.x<t&&(t=o.x),o.x>e&&(e=o.x)),o.y!==void 0&&o.y!==null&&(o.y<i&&(i=o.y),o.y>r&&(r=o.y));return this._cachedExtents={xMin:t,xMax:e,yMin:i,yMax:r},this._cachedExtents}getCategories(){return this.data.filter(t=>t.name!==void 0).map(t=>t.name)}destroy(){var t;(t=this.group)==null||t.remove()}setData(t,e=!0,i=!0){this.data=t,this.config._processedData=t,this._cachedExtents=null,e&&(i?this.animateUpdate(500):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoint(t,e=!0,i=!1,r=!0){if(this.data.push(t),this.config._processedData=this.data,i&&this.data.length>1)this.data.shift(),this.config._processedData=this.data,this._cachedExtents=null;else if(this._cachedExtents){const o=this._cachedExtents;t.x!==void 0&&t.x!==null&&(t.x<o.xMin&&(o.xMin=t.x),t.x>o.xMax&&(o.xMax=t.x)),t.y!==void 0&&t.y!==null&&(t.y<o.yMin&&(o.yMin=t.y),t.y>o.yMax&&(o.yMax=t.y))}e&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}addPoints(t,e=!0,i=!1,r=!0){for(const o of t)this.data.push(o);i&&this.data.length>t.length&&this.data.splice(0,t.length),this.config._processedData=this.data,this._cachedExtents=null,e&&(r?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this))}removePoint(t,e=!0,i=!0){t>=0&&t<this.data.length&&(this.data.splice(t,1),this.config._processedData=this.data,this._cachedExtents=null,e&&(i?this.animateUpdate(300):this.redraw(),this.context.events.emit("series:dataChanged",this)))}updateSeries(t,e=!0){Object.assign(this.config,t),t.data&&(this.config._processedData=t.data,this.data=this.config._processedData,this._cachedExtents=null),e&&this.redraw()}applyBatch(t){for(const e of t.entries)switch(e.type){case"setData":this.data=e.payload,this.config._processedData=this.data;break;case"addPoint":this.data.push(e.payload.point),e.payload.shift&&this.data.length>1&&this.data.shift();break;case"addPoints":for(const i of e.payload.points)this.data.push(i);e.payload.shift&&this.data.splice(0,e.payload.points.length);break;case"removePoint":e.payload.index>=0&&e.payload.index<this.data.length&&this.data.splice(e.payload.index,1);break}this.config._processedData=this.data,this._cachedExtents=null,this.redraw(),this.context.events.emit("series:dataChanged",this)}show(){this.setVisible(!0)}hide(){this.setVisible(!1)}getSelectedPoints(){return Array.from(this.selectedPoints).map(t=>({index:t,point:this.data[t]})).filter(t=>t.point!==void 0)}applyClipPath(){const{plotArea:t}=this.context;this.clipId=`katucharts-clip-${this.config.index}-${Date.now()}`;const e=this.group.select(function(){return this.ownerSVGElement});if(!e.empty()){let i=e.select("defs");i.empty()&&(i=e.append("defs")),i.append("clipPath").attr("id",this.clipId).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height),this.group.attr("clip-path",`url(#${this.clipId})`)}}applyShadowFilter(){const t=this.config.shadow;if(!t)return;const e=`katucharts-shadow-${this.config.index}-${Date.now()}`,i=this.group.select(function(){return this.ownerSVGElement});if(!i.empty()){let r=i.select("defs");r.empty()&&(r=i.append("defs"));const o=typeof t=="object"?t:{},s=o.offsetX??1,a=o.offsetY??1,c=o.width??3,l=o.opacity??.15;r.append("filter").attr("id",e).append("feDropShadow").attr("dx",s).attr("dy",a).attr("stdDeviation",c).attr("flood-opacity",l),this.group.style("filter",`url(#${e})`)}}applyInactiveState(){var r,o,s,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const e=((o=(r=this.config.states)==null?void 0:r.inactive)==null?void 0:o.opacity)??.2,i=((c=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??vs;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(i).ease(q).attr("opacity",e)}clearInactiveState(){var i,r,o,s,a,c;const t=this.context.allSeries;if(!t||t.length<=1)return;const e=((o=(r=(i=this.config.states)==null?void 0:i.normal)==null?void 0:r.animation)==null?void 0:o.duration)??((c=(a=(s=this.config.states)==null?void 0:s.inactive)==null?void 0:a.animation)==null?void 0:c.duration)??vs;for(const l of t)l!==this&&l.visible&&l.group.transition("inactive").duration(e).ease(q).attr("opacity",l.config.opacity??1)}emitAfterAnimate(t){var o;const e=!!((o=this.config.events)!=null&&o.afterAnimate),i=typeof this.config.animation=="object"?this.config.animation:null,r=!!(i!=null&&i.complete);(e||r)&&setTimeout(()=>{var s,a,c;(a=(s=this.config.events)==null?void 0:s.afterAnimate)==null||a.call(this,new Event("afterAnimate")),(c=i==null?void 0:i.complete)==null||c.call(i)},t)}renderDataLabels(t,e,i,r,o=-10){const s=this.config.dataLabels;if(!(s!=null&&s.enabled))return;this.group.selectAll(".katucharts-data-labels").remove();const a=this.group.append("g").attr("class","katucharts-data-labels");this.getColor(),t.forEach((c,l)=>{var b,x;if(c.y===null||c.y===void 0)return;const h=c.dataLabels,f={...s,...h};let u;f.formatter?u=f.formatter.call({point:{...c,index:l},series:this,x:c.x??l,y:c.y,percentage:c._percentage}):f.format?u=re(Zt(f.format,{point:c,series:{name:this.config.name??""},x:c.x,y:c.y,percentage:c._percentage??c.percentage})):u=String(c.y);let d;if(typeof u=="string"&&u.indexOf("<")!==-1){const v=u.match(/color:\s*([^;"')]+)/i);v&&(d=v[1].trim()),u=re(u)}if(f.filter){const v=c[f.filter.property??"y"]??0,k=f.filter.operator??">",M=f.filter.value??0;if(!(k===">"?v>M:k==="<"?v<M:k===">="?v>=M:k==="<="?v<=M:k==="=="?v===M:!0))return}const p=e(c,l)+(f.x??0),y=i(c,l)+(f.y??o),g=a.append("text").attr("x",p).attr("y",y).attr("text-anchor",f.align==="left"?"start":f.align==="right"?"end":"middle").attr("dominant-baseline",f.verticalAlign==="top"?"text-before-edge":f.verticalAlign==="bottom"?"text-after-edge":"central").text(u),m=f.style||{};if(g.style("font-size",m.fontSize??kt).style("font-weight",m.fontWeight??"bold").style("fill",f.color||d||m.color||this.autoLabelColor()),m.textOutline&&g.style("text-shadow",m.textOutline),r){const v=pe(u,se(m.fontSize||kt)),k=r(c,l,v);k&&g.attr("x",k.x).attr("text-anchor",k.anchor)}if(f.rotation&&g.attr("transform",`rotate(${f.rotation},${p},${y})`),f.backgroundColor||f.borderWidth){const v=(x=(b=g.node()).getBBox)==null?void 0:x.call(b);if(v){const k=f.padding??5,M=f.borderRadius??0;a.insert("rect",":last-child").attr("x",v.x-k).attr("y",v.y-k).attr("width",v.width+k*2).attr("height",v.height+k*2).attr("rx",M).attr("fill",f.backgroundColor||"none").attr("stroke",f.borderColor||"none").attr("stroke-width",f.borderWidth??0)}}this.context.animate&&f.defer!==!1&&g.attr("opacity",0).transition().delay(ei+l*Bt).duration(400).ease(dt).attr("opacity",1)})}handlePointSelect(t,e,i,r){var s,a,c,l;if(!this.config.allowPointSelect)return;const o=this.selectedPoints.has(i);if(o){if(((a=(s=e.events)==null?void 0:s.unselect)==null?void 0:a.call(e,r))===!1)return;this.selectedPoints.delete(i),e.selected=!1,this.clearSelectStyle(t)}else{if(((l=(c=e.events)==null?void 0:c.select)==null?void 0:l.call(e,r))===!1)return;this.selectedPoints.add(i),e.selected=!0,this.applySelectStyle(t)}this.context.events.emit("point:select",{point:e,index:i,series:this,selected:!o})}applySelectStyle(t){var i;const e=(i=this.config.states)==null?void 0:i.select;e!=null&&e.color&&t.attr("fill",e.color),e!=null&&e.borderColor&&t.attr("stroke",e.borderColor),(e==null?void 0:e.borderWidth)!==void 0&&t.attr("stroke-width",e.borderWidth)}clearSelectStyle(t){t.attr("fill",null).attr("stroke",null).attr("stroke-width",null)}attachPointEvents(t,e,i){var s;if(this.config.enableMouseTracking===!1)return;const r=e.events||{},o=((s=this.config.point)==null?void 0:s.events)||{};t.on("mouseover",a=>{var c,l;this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:a,plotX:this.context.xAxis.getPixelForValue(e.x??i),plotY:this.context.yAxis.getPixelForValue(e.y??0)}),(c=r.mouseOver)==null||c.call(e,a),(l=o.mouseOver)==null||l.call(e,a)}).on("mouseout",a=>{var c,l;this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:a}),(c=r.mouseOut)==null||c.call(e,a),(l=o.mouseOut)==null||l.call(e,a)}).on("click",a=>{var c,l,h,f;this.context.events.emit("point:click",{point:e,index:i,series:this,event:a}),(c=r.click)==null||c.call(e,a),(l=o.click)==null||l.call(e,a),(f=(h=this.config.events)==null?void 0:h.click)==null||f.call(this,a),this.handlePointSelect(t,e,i,a)}),t.style("cursor",this.config.cursor||"pointer")}applyJitter(t,e,i){return i?t+(Math.random()-.5)*i*e:t}}function Fc(n,t){const e=n.length;if(t>=e||t<3)return n;const i=new Array(t);i[0]=n[0],i[t-1]=n[e-1];const r=(e-2)/(t-2);let o=0;for(let s=1;s<t-1;s++){const a=Math.floor((s-1)*r)+1,c=Math.min(Math.floor(s*r)+1,e-1),l=Math.floor(s*r)+1,h=Math.min(Math.floor((s+1)*r)+1,e-1);let f=0,u=0;const d=h-l;for(let b=l;b<h;b++)f+=n[b].x??b,u+=n[b].y??0;d>0&&(f/=d,u/=d);const p=n[o].x??o,y=n[o].y??0;let g=-1,m=a;for(let b=a;b<c;b++){const x=n[b].x??b,v=n[b].y??0,k=Math.abs((p-f)*(v-y)-(p-x)*(u-y));k>g&&(g=k,m=b)}i[s]=n[m],o=m}return i}function Z2(n,t){const e=n.length;if(t>=e||t<2)return n;const i=Math.ceil(t/2),r=e/i,o=[];o.push(n[0]);for(let s=0;s<i;s++){const a=Math.floor(s*r),c=Math.min(Math.floor((s+1)*r),e);let l=a,h=a,f=n[a].y??0,u=f;for(let d=a+1;d<c;d++){const p=n[d].y??0;p<f&&(f=p,l=d),p>u&&(u=p,h=d)}l<h?(o.push(n[l]),l!==h&&o.push(n[h])):(o.push(n[h]),l!==h&&o.push(n[l]))}return o[o.length-1]!==n[e-1]&&o.push(n[e-1]),o}const Jf=new WeakMap;function K2(n,t){let e=Jf.get(n);return e||(e=[],Jf.set(n,e),st(n).on("mousemove.hover-shared",i=>{const r=n.querySelector(".katucharts-plot-group");if(!r)return;const o=r.getScreenCTM();if(!o)return;const s=n.createSVGPoint();s.x=i.clientX,s.y=i.clientY;const a=s.matrixTransform(o.inverse()),c=a.x,l=a.y;if(c<0||c>t.width||l<0||l>t.height){for(const d of e)d.currentIdx>=0&&d.hideHover(i);return}let h=null,f=-1,u=1/0;for(const d of e){const p=d.findCandidate(c,l);p&&p.dist<u&&(u=p.dist,f=p.idx,h=d)}for(const d of e)d!==h&&d.currentIdx>=0&&d.hideHover(i);h&&f!==h.currentIdx&&h.showHover(f,i)}),st(n).on("mouseleave.hover-shared",i=>{for(const r of e)r.currentIdx>=0&&r.hideHover(i)}),st(n).on("click.hover-shared",i=>{for(const r of e)if(r.currentIdx>=0){r.handleClick(i);break}})),e}class J2{constructor(t){var a;this.config=t,this.currentIdx=-1;const{group:e,data:i,xAxis:r,plotArea:o}=t;this.validData=i.filter(c=>c.y!==null&&c.y!==void 0),this.xPositions=new Float64Array(this.validData.length);for(let c=0;c<this.validData.length;c++)this.xPositions[c]=r.getPixelForValue(this.validData[c].x??c);this.hoverGroup=e.append("g").attr("class","katucharts-hover-targets"),this.halo=this.hoverGroup.append("circle").attr("r",0).attr("opacity",0).attr("class","katucharts-halo"),this.hoverMarker=this.hoverGroup.append("circle").attr("r",t.markerRadius).attr("opacity",0).attr("class","katucharts-hover-marker").attr("stroke","#fff").attr("stroke-width",1);const s=(a=e.node())==null?void 0:a.ownerSVGElement;s&&K2(s,o).push(this)}findCandidate(t,e){const{yAxis:i}=this.config,r=this.xPositions;if(r.length===0)return null;let o=0,s=r.length-1;for(;o<s;){const h=o+s>>1;r[h]<t?o=h+1:s=h}let a=-1,c=1/0;const l=2;for(let h=Math.max(0,o-l);h<=Math.min(r.length-1,o+l);h++){const f=r[h],u=i.getPixelForValue(this.validData[h].y??0),d=Math.sqrt((f-t)**2+(u-e)**2);d<c&&(c=d,a=h)}return a<0||Math.abs(r[a]-t)>50?null:{idx:a,dist:c}}handleClick(t){var o,s,a,c,l,h,f;if(this.currentIdx<0)return;const{series:e,events:i}=this.config,r=this.validData[this.currentIdx];i.emit("point:click",{point:r,index:this.currentIdx,series:e,event:t}),(s=(o=r.events)==null?void 0:o.click)==null||s.call(r,t),(l=(c=(a=e.config.point)==null?void 0:a.events)==null?void 0:c.click)==null||l.call(r,t),(f=(h=e.config.events)==null?void 0:h.click)==null||f.call(e,t)}showHover(t,e){var b,x,v,k,M;if(t<0||t>=this.validData.length)return;const{series:i,events:r,yAxis:o,haloSize:s,haloOpacity:a,hoverRadius:c,hoverLineWidth:l,pathSelection:h,lineWidthPlus:f,baseLineWidth:u,getColor:d}=this.config,p=this.validData[t],y=this.xPositions[t],g=o.getPixelForValue(p.y??0),m=d(p);this.currentIdx>=0&&this.currentIdx!==t&&r.emit("point:mouseout",{point:this.validData[this.currentIdx],index:this.currentIdx,series:i,event:e}),this.currentIdx=t,this.halo.attr("cx",y).attr("cy",g).attr("fill",m).transition().duration(Z).ease(q).attr("r",s).attr("opacity",a),this.hoverMarker.attr("cx",y).attr("cy",g).attr("fill",m).transition().duration(Z).ease(q).attr("r",c).attr("opacity",1).attr("stroke-width",l),f&&h&&h.transition("hover").duration(Z).ease(q).attr("stroke-width",u+f),r.emit("point:mouseover",{point:p,index:t,series:i,event:e,plotX:y,plotY:g}),(x=(b=p.events)==null?void 0:b.mouseOver)==null||x.call(p,e),(M=(k=(v=i.config.point)==null?void 0:v.events)==null?void 0:k.mouseOver)==null||M.call(p,e)}hideHover(t){var s,a,c,l,h;const{series:e,events:i,pathSelection:r,baseLineWidth:o}=this.config;if(this.currentIdx>=0){const f=this.validData[this.currentIdx];i.emit("point:mouseout",{point:f,index:this.currentIdx,series:e,event:t}),(a=(s=f.events)==null?void 0:s.mouseOut)==null||a.call(f,t),(h=(l=(c=e.config.point)==null?void 0:c.events)==null?void 0:l.mouseOut)==null||h.call(f,t)}this.halo.transition().duration(Z).ease(q).attr("r",0).attr("opacity",0),this.hoverMarker.transition().duration(Z).ease(q).attr("r",this.config.markerRadius).attr("opacity",0),r&&r.transition("hover").duration(Z).ease(q).attr("stroke-width",o),this.currentIdx=-1}findNearest(t){const e=this.xPositions;if(e.length===0)return-1;let i=0,r=e.length-1;for(;i<r;){const o=i+r>>1;e[o]<t?i=o+1:r=o}return i>0&&Math.abs(e[i-1]-t)<Math.abs(e[i]-t)&&(i=i-1),Math.abs(e[i]-t)>30?-1:i}}const Q2={circle:bn,square:gs,diamond:ps,triangle:ms,"triangle-down":ys,cross:ds};class Qf extends Ht{constructor(t){super(t),this.pathSelection=null}render(){var r;const t=this.getColor(),e=this.getFilteredData(),i=this.context.animate;(r=this.config.zones)!=null&&r.length?this.renderZones(e,t):this.config.negativeColor&&this.config.threshold!==null?this.renderNegativeColor(e,t):this.renderMainLine(e,t,i),this.renderMarkers(e,t,!!i),this.renderHoverTargets(e,t),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0)),i&&this.emitAfterAnimate(gt+ei)}renderMainLine(t,e,i){const r=this.buildLineGenerator();this.pathSelection=this.group.append("path").datum(t).attr("d",r).attr("fill","none").attr("stroke",e).attr("stroke-width",this.config.lineWidth??2).attr("stroke-dasharray",sn(this.config.dashStyle)).attr("stroke-linecap",this.config.linecap||"round").attr("class","katucharts-line"),i&&this.animateLineEntry(this.pathSelection)}renderNegativeColor(t,e){const i=this.config.threshold??0,r=this.config.negativeColor,o=this.config.lineWidth??2,s=this.config.linecap||"round",a=sn(this.config.dashStyle),c=[];let l=[],h=null;for(const f of t){if(f.y===null||f.y===void 0){l.length>0&&(c.push({points:l,negative:h}),l=[],h=null);continue}const u=f.y<i;h!==null&&u!==h&&l.length>0&&(c.push({points:[...l],negative:h}),l=[l[l.length-1]]),h=u,l.push(f)}l.length>0&&c.push({points:l,negative:h});for(const f of c){const u=this.buildLineGenerator();this.group.append("path").datum(f.points).attr("d",u).attr("fill","none").attr("stroke",f.negative?r:e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",a).attr("class","katucharts-line katucharts-negative-segment")}}renderZones(t,e){var u,d;const i=this.config.zones,r=this.config.zoneAxis||"y",o=this.config.lineWidth??2,s=this.config.linecap||"round";(u=this.pathSelection)==null||u.remove(),this.pathSelection=null;const a=[...i].sort((p,y)=>(p.value??1/0)-(y.value??1/0)),c=p=>r==="x"?p.x??0:p.y??0,l=t.filter(p=>p.y!==null&&p.y!==void 0),h=a.map(()=>[]),f=[];for(const p of l){const y=c(p);let g=!1;for(let m=0;m<a.length;m++)if(y<(a[m].value??1/0)){h[m].push(p),g=!0;break}g||f.push(p)}for(let p=0;p<a.length;p++)h[p].length!==0&&(p>0&&h[p-1].length>0&&h[p].unshift(h[p-1][h[p-1].length-1]),p<a.length-1&&((d=h[p+1])==null?void 0:d.length)>0?h[p].push(h[p+1][0]):f.length>0&&h[p].push(f[0]));for(let p=0;p<a.length;p++){const y=h[p];if(y.length<2)continue;const g=a[p],m=this.buildLineGenerator();this.group.append("path").datum(y).attr("d",m).attr("fill","none").attr("stroke",g.color||e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",sn(g.dashStyle||this.config.dashStyle)).attr("class","katucharts-line katucharts-zone")}if(f.length>0){const p=h[h.length-1];if((p==null?void 0:p.length)>0&&f.unshift(p[p.length-1]),f.length>1){const y=this.buildLineGenerator();this.group.append("path").datum(f).attr("d",y).attr("fill","none").attr("stroke",e).attr("stroke-width",o).attr("stroke-linecap",s).attr("stroke-dasharray",sn(this.config.dashStyle)).attr("class","katucharts-line katucharts-zone")}}}animateUpdate(t){const e=this.getFilteredData(),i=this.buildLineGenerator(),r=this.getColor();this.pathSelection&&!this.pathSelection.empty()?this.pathSelection.datum(e).transition().duration(t).attr("d",i):(this.group.selectAll(".katucharts-line").remove(),this.renderMainLine(e,r,!1)),this.group.selectAll(".katucharts-markers").remove(),this.group.selectAll(".katucharts-hover-targets").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderMarkers(e,r,!1),this.renderHoverTargets(e,r),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0))}buildLineGenerator(){const{xAxis:t,yAxis:e}=this.context,i=this.config.connectNulls,r=!!this.context.inverted,o=(c,l)=>typeof c=="number"?l:(c==null?void 0:c.x)??l,s=c=>typeof c=="number"?c:c==null?void 0:c.y,a=on().x((c,l)=>r?e.getPixelForValue(s(c)??0):t.getPixelForValue(o(c,l))).y((c,l)=>r?t.getPixelForValue(o(c,l)):e.getPixelForValue(s(c)??0)).curve(this.getCurve());return i||a.defined(c=>{const l=s(c);return l!=null}),a}getFilteredData(){var e;let t;if(this.config.connectNulls?t=this.data.filter(i=>i.y!==null&&i.y!==void 0):t=this.data,(e=this.context)!=null&&e.plotArea){const r=this.context.plotArea.width*4;t.length>r&&(t=Fc(t,Math.floor(r)))}return t}getCurve(){const t=this.config.step;return t==="left"?jf:t==="center"?Xf:t==="right"?Uf:Si}animateLineEntry(t){var i,r;const e=((r=(i=t.node())==null?void 0:i.getTotalLength)==null?void 0:r.call(i))||0;if(e>0){const o=typeof this.config.animation=="object"?this.config.animation:{},s=o.duration??gt,a=o.defer??0,c=t.attr("stroke-dasharray");t.attr("stroke-dasharray",`${e} ${e}`).attr("stroke-dashoffset",e).transition().delay(a).duration(s).ease(dt).attr("stroke-dashoffset",0).on("end",()=>{t.attr("stroke-dasharray",c==="none"?null:c)})}}renderMarkers(t,e,i){const r=this.config.marker,o=(r==null?void 0:r.enabledThreshold)??2;if(!((r==null?void 0:r.enabled)===!0||(r==null?void 0:r.enabled)!==!1&&t.length<=o*this.context.plotArea.width/12))return;const{xAxis:a,yAxis:c}=this.context,l=(r==null?void 0:r.radius)??4,h=(r==null?void 0:r.symbol)||"circle",f=this.group.append("g").attr("class","katucharts-markers"),u=t.filter(d=>d.y!==null&&d.y!==void 0);if(h==="circle"){const d=f.selectAll("circle").data(u).join("circle").attr("cx",p=>a.getPixelForValue(p.x??0)).attr("cy",p=>c.getPixelForValue(p.y??0)).attr("fill",(p,y)=>this.getMarkerFill(p,y,r,e)).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");i?d.attr("r",0).transition().delay((p,y)=>xe(y,ei,Bt,u.length)).duration(gt).ease(dt).attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??l}):d.attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??l})}else{const d=Q2[h]||bn,p=Math.PI*l*l;Ve().type(d).size(p);const y=f.selectAll("path").data(u).join("path").attr("transform",g=>`translate(${a.getPixelForValue(g.x??0)},${c.getPixelForValue(g.y??0)})`).attr("fill",(g,m)=>this.getMarkerFill(g,m,r,e)).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");if(i){const g=Ve().type(d).size(0);y.attr("d",g).transition().delay((m,b)=>xe(b,ei,Bt,u.length)).duration(gt).ease(dt).attr("d",m=>{var x;const b=((x=m.marker)==null?void 0:x.radius)??l;return Ve().type(d).size(Math.PI*b*b)()})}else y.attr("d",g=>{var b;const m=((b=g.marker)==null?void 0:b.radius)??l;return Ve().type(d).size(Math.PI*m*m)()})}}getMarkerFill(t,e,i,r){var o;return t.color?t.color:(o=t.marker)!=null&&o.fillColor?t.marker.fillColor:i!=null&&i.fillColor?i.fillColor:this.config.negativeColor&&(t.y??0)<(this.config.threshold??0)?this.config.negativeColor:r}renderHoverTargets(t,e){var f,u,d,p,y,g,m,b;if(this.config.enableMouseTracking===!1)return;const i=((f=this.config.marker)==null?void 0:f.radius)??4,r=(d=(u=this.config.marker)==null?void 0:u.states)==null?void 0:d.hover,o=(r==null?void 0:r.radiusPlus)??2,s=(r==null?void 0:r.radius)??i+o,a=(r==null?void 0:r.lineWidthPlus)??1,c=(r==null?void 0:r.lineWidth)??(((p=this.config.marker)==null?void 0:p.lineWidth)??1)+a,l=((g=(y=this.config.states)==null?void 0:y.hover)==null?void 0:g.lineWidthPlus)??1,h=(b=(m=this.config.states)==null?void 0:m.hover)==null?void 0:b.halo;new J2({series:this,group:this.group,data:t,xAxis:this.context.xAxis,yAxis:this.context.yAxis,plotArea:this.context.plotArea,events:this.context.events,haloSize:(h==null?void 0:h.size)??10,haloOpacity:(h==null?void 0:h.opacity)??.25,markerRadius:i,hoverRadius:s,hoverLineWidth:c,cursor:this.config.cursor||"pointer",pathSelection:this.pathSelection,lineWidthPlus:l,baseLineWidth:this.config.lineWidth??2,getColor:x=>x.color||e})}}class tw extends Qf{constructor(t){super(t)}getCurve(){return $c.alpha(.5)}}function ji(n){return!!n&&typeof n=="object"&&("linearGradient"in n||"radialGradient"in n)}let ew=0;function td(n,t,e){const i=cr(e);n.append("stop").attr("offset",String(t)).attr("stop-color",`rgb(${i.r}, ${i.g}, ${i.b})`).attr("stop-opacity",i.a)}function Hn(n,t,e){if(n==null)return e;if(typeof n=="string")return n;if(!ji(n))return e;const i=`katucharts-fill-grad-${++ew}`,r=t.append("defs");if("radialGradient"in n){const o=n.radialGradient,s=r.append("radialGradient").attr("id",i).attr("cx",String(o.cx??.5)).attr("cy",String(o.cy??.5)).attr("r",String(o.r??.5));for(const[a,c]of n.stops)td(s,a,c)}else{const o=n.linearGradient,s=r.append("linearGradient").attr("id",i).attr("x1",String(o.x1??0)).attr("y1",String(o.y1??0)).attr("x2",String(o.x2??0)).attr("y2",String(o.y2??1));for(const[a,c]of n.stops)td(s,a,c)}return`url(#${i})`}const nw={circle:bn,square:gs,diamond:ps,triangle:ms,"triangle-down":ys,cross:ds};class ed extends Ht{constructor(t){super(t),this.isSpline=!1,this.areaPath=null,this.linePath=null,this.negAreaPath=null}render(){var r;const t=this.getColor(),e=this.getFilteredData(),i=this.context.animate;(r=this.config.zones)!=null&&r.length?this.renderZones(e,t):this.config.negativeFillColor||this.config.negativeColor?this.renderWithNegativeColor(e,t,!!i):this.renderMainArea(e,t,!!i),this.renderMarkers(e,t,!!i),this.config.trackByArea?this.renderAreaHoverTargets(e,t):this.renderHoverTargets(e,t),this.renderDataLabels(e.filter(o=>o.y!==null&&o.y!==void 0),(o,s)=>this.context.xAxis.getPixelForValue(o.x??s),o=>this.context.yAxis.getPixelForValue(o.y??0)),i&&this.emitAfterAnimate(gt+ei)}renderMainArea(t,e,i){const{areaGen:r,lineGen:o}=this.buildGenerators(),s=this.config.lineColor||e,a=ji(this.config.fillColor),c=Hn(this.config.fillColor,this.group,e),l=this.config.fillOpacity??(a?1:.75);if(this.areaPath=this.group.append("path").datum(t).attr("d",r).attr("fill",c).attr("class","katucharts-area"),this.linePath=this.group.append("path").datum(t).attr("d",o).attr("fill","none").attr("stroke",s).attr("stroke-width",this.config.lineWidth??2).attr("stroke-linecap",this.config.linecap||"round").attr("stroke-dasharray",sn(this.config.dashStyle)).attr("class","katucharts-area-line"),i){const f=(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt;this.areaPath.attr("fill-opacity",0).transition().duration(f).ease(dt).attr("fill-opacity",l),this.animateLineEntry(this.linePath)}else this.areaPath.attr("fill-opacity",l)}renderWithNegativeColor(t,e,i){const{xAxis:r,yAxis:o}=this.context,s=this.config.threshold??0,a=o.getPixelForValue(s),c=this.getCurve(),l=this.config.fillOpacity??(ji(this.config.fillColor)?1:.75),h=Hn(this.config.negativeFillColor||this.config.negativeColor,this.group,e),f=Hn(this.config.fillColor,this.group,e),u=this.config.lineColor||e,d=t.filter(g=>g.y!==null&&g.y!==void 0&&(g.y??0)>=s),p=t.filter(g=>g.y!==null&&g.y!==void 0&&(g.y??0)<s);if(d.length>0){const g=ti().x(m=>r.getPixelForValue(m.x??0)).y0(a).y1(m=>o.getPixelForValue(m.y??0)).curve(c);this.areaPath=this.group.append("path").datum(d).attr("d",g).attr("fill",f).attr("fill-opacity",l).attr("class","katucharts-area katucharts-area-positive")}if(p.length>0){const g=ti().x(m=>r.getPixelForValue(m.x??0)).y0(a).y1(m=>o.getPixelForValue(m.y??0)).curve(c);this.negAreaPath=this.group.append("path").datum(p).attr("d",g).attr("fill",h).attr("fill-opacity",l).attr("class","katucharts-area katucharts-area-negative")}const y=on().defined(g=>g.y!==null&&g.y!==void 0).x(g=>r.getPixelForValue(g.x??0)).y(g=>o.getPixelForValue(g.y??0)).curve(c);if(this.linePath=this.group.append("path").datum(t).attr("d",y).attr("fill","none").attr("stroke",u).attr("stroke-width",this.config.lineWidth??2).attr("stroke-linecap",this.config.linecap||"round").attr("stroke-dasharray",sn(this.config.dashStyle)).attr("class","katucharts-area-line"),i){const m=(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt;this.areaPath&&this.areaPath.attr("fill-opacity",0).transition().duration(m).ease(dt).attr("fill-opacity",l),this.negAreaPath&&this.negAreaPath.attr("fill-opacity",0).transition().duration(m).ease(dt).attr("fill-opacity",l),this.animateLineEntry(this.linePath)}}renderZones(t,e){const{xAxis:i,yAxis:r}=this.context,o=this.config.zones,s=this.config.zoneAxis||"y",a=this.config.fillOpacity??.75,c=this.config.lineWidth??2,l=this.getCurve(),h=r.getPixelForValue(this.config.threshold??0),f=[...o].sort((g,m)=>(g.value??1/0)-(m.value??1/0)),u=g=>s==="x"?g.x??0:g.y??0,d=t.filter(g=>g.y!==null&&g.y!==void 0);let p=-1/0;const y=(g,m,b,x)=>{if(g.length<2)return;const v=ti().x(M=>i.getPixelForValue(M.x??0)).y0(h).y1(M=>r.getPixelForValue(M.y??0)).curve(l);this.group.append("path").datum(g).attr("d",v).attr("fill",Hn(b,this.group,m)).attr("fill-opacity",a).attr("class","katucharts-area katucharts-zone");const k=on().x(M=>i.getPixelForValue(M.x??0)).y(M=>r.getPixelForValue(M.y??0)).curve(l);this.group.append("path").datum(g).attr("d",k).attr("fill","none").attr("stroke",m).attr("stroke-width",c).attr("stroke-dasharray",sn(x||this.config.dashStyle)).attr("class","katucharts-area-line katucharts-zone")};for(const g of f){const m=g.value??1/0,b=g.color||e,x=g.fillColor||b,v=[];for(let k=0;k<d.length;k++){const M=u(d[k]);if(M>=p&&M<m)v.length===0&&k>0&&v.push(d[k-1]),v.push(d[k]);else if(M>=m&&v.length>0){v.push(d[k]);break}}y(v,b,x,g.dashStyle),p=m}if(p!==1/0){const g=[];for(let m=0;m<d.length;m++)u(d[m])>=p&&(g.length===0&&m>0&&g.push(d[m-1]),g.push(d[m]));y(g,e,this.config.fillColor)}}getCurve(){if(this.isSpline)return $c.alpha(.5);const t=this.config.step;return t==="left"?jf:t==="center"?Xf:t==="right"?Uf:Si}getFilteredData(){var e;let t;if(this.config.connectNulls?t=this.data.filter(i=>i.y!==null&&i.y!==void 0):t=this.data,(e=this.context)!=null&&e.plotArea){const r=this.context.plotArea.width*4;t.length>r&&(t=Fc(t,Math.floor(r)))}return t}buildGenerators(){const{xAxis:t,yAxis:e}=this.context,i=e.getPixelForValue(this.config.threshold??0),r=this.getCurve(),o=this.context.stackOffsets,s=this.config.stacking,a=this.config.connectNulls,c=u=>!s||!o?u.y??0:(o.get(u.x??0)||0)+(u.y??0),l=u=>!s||!o?this.config.threshold??0:o.get(u.x??0)||0,h=ti().x(u=>t.getPixelForValue(u.x??0)).y0(u=>s?e.getPixelForValue(l(u)):i).y1(u=>e.getPixelForValue(c(u))).curve(r),f=on().x(u=>t.getPixelForValue(u.x??0)).y(u=>e.getPixelForValue(c(u))).curve(r);return a||(h.defined(u=>u.y!==null&&u.y!==void 0),f.defined(u=>u.y!==null&&u.y!==void 0)),{areaGen:h,lineGen:f}}animateUpdate(t){const e=this.getFilteredData(),{areaGen:i,lineGen:r}=this.buildGenerators(),o=this.getColor();this.areaPath&&!this.areaPath.empty()&&this.areaPath.datum(e).transition().duration(t).attr("d",i),this.linePath&&!this.linePath.empty()&&this.linePath.datum(e).transition().duration(t).attr("d",r),this.group.selectAll(".katucharts-hover-targets").remove(),this.group.selectAll(".katucharts-markers").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderMarkers(e,o,!1),this.config.trackByArea?this.renderAreaHoverTargets(e,o):this.renderHoverTargets(e,o),this.renderDataLabels(e.filter(s=>s.y!==null&&s.y!==void 0),(s,a)=>this.context.xAxis.getPixelForValue(s.x??a),s=>this.context.yAxis.getPixelForValue(s.y??0))}animateLineEntry(t){var i,r;const e=((r=(i=t.node())==null?void 0:i.getTotalLength)==null?void 0:r.call(i))||0;if(e>0){const o=typeof this.config.animation=="object"?this.config.animation:{},s=o.duration??gt,a=o.defer??0,c=t.attr("stroke-dasharray");t.attr("stroke-dasharray",`${e} ${e}`).attr("stroke-dashoffset",e).transition().delay(a).duration(s).ease(dt).attr("stroke-dashoffset",0).on("end",()=>t.attr("stroke-dasharray",c==="none"?null:c))}}renderMarkers(t,e,i){const r=this.config.marker;if((r==null?void 0:r.enabled)!==!0)return;const{xAxis:o,yAxis:s}=this.context,a=(r==null?void 0:r.radius)??4,c=(r==null?void 0:r.symbol)||"circle",l=this.group.append("g").attr("class","katucharts-markers"),h=t.filter(f=>f.y!==null&&f.y!==void 0);if(c==="circle"){const f=l.selectAll("circle").data(h).join("circle").attr("cx",u=>o.getPixelForValue(u.x??0)).attr("cy",u=>s.getPixelForValue(u.y??0)).attr("fill",u=>u.color||(r==null?void 0:r.fillColor)||e).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");i?f.attr("r",0).transition().delay((u,d)=>xe(d,ei,Bt,h.length)).duration(gt).ease(dt).attr("r",u=>{var d;return((d=u.marker)==null?void 0:d.radius)??a}):f.attr("r",u=>{var d;return((d=u.marker)==null?void 0:d.radius)??a})}else{const f=nw[c]||bn,u=l.selectAll("path").data(h).join("path").attr("transform",d=>`translate(${o.getPixelForValue(d.x??0)},${s.getPixelForValue(d.y??0)})`).attr("fill",d=>d.color||(r==null?void 0:r.fillColor)||e).attr("stroke",(r==null?void 0:r.lineColor)||this.autoBorderColor()).attr("stroke-width",(r==null?void 0:r.lineWidth)??1).attr("class","katucharts-marker");if(i){const d=Ve().type(f).size(0);u.attr("d",d).transition().delay((p,y)=>xe(y,ei,Bt,h.length)).duration(gt).ease(dt).attr("d",p=>{var g;const y=((g=p.marker)==null?void 0:g.radius)??a;return Ve().type(f).size(Math.PI*y*y)()})}else u.attr("d",d=>{var y;const p=((y=d.marker)==null?void 0:y.radius)??a;return Ve().type(f).size(Math.PI*p*p)()})}}renderAreaHoverTargets(t,e){if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=r.getPixelForValue(this.config.threshold??0),s=this.getCurve(),a=ti().x(h=>i.getPixelForValue(h.x??0)).y0(o).y1(h=>r.getPixelForValue(h.y??0)).curve(s),c=t.filter(h=>h.y!==null&&h.y!==void 0);this.group.append("path").datum(c).attr("d",a).attr("fill","transparent").attr("class","katucharts-hover-targets").style("cursor",this.config.cursor||"pointer").on("mousemove",h=>{const[f]=[h.offsetX-(this.context.plotArea.x||0)];let u=0,d=1/0;c.forEach((y,g)=>{const m=i.getPixelForValue(y.x??0),b=Math.abs(m-f);b<d&&(d=b,u=g)});const p=c[u];this.context.events.emit("point:mouseover",{point:p,index:u,series:this,event:h,plotX:i.getPixelForValue(p.x??0),plotY:r.getPixelForValue(p.y??0)})}).on("mouseout",h=>{this.context.events.emit("point:mouseout",{point:c[0],index:0,series:this,event:h})}).on("click",h=>{var y,g,m,b;const[f]=[h.offsetX-(this.context.plotArea.x||0)];let u=0,d=1/0;c.forEach((x,v)=>{const k=i.getPixelForValue(x.x??0),M=Math.abs(k-f);M<d&&(d=M,u=v)});const p=c[u];this.context.events.emit("point:click",{point:p,index:u,series:this,event:h}),(g=(y=p.events)==null?void 0:y.click)==null||g.call(p,h),(b=(m=this.config.events)==null?void 0:m.click)==null||b.call(this,h)})}renderHoverTargets(t,e){var f,u,d,p,y;if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=this.group.append("g").attr("class","katucharts-hover-targets"),s=((d=(u=(f=this.config.marker)==null?void 0:f.states)==null?void 0:u.hover)==null?void 0:d.radius)??6,a=t.filter(g=>g.y!==null&&g.y!==void 0),c=(y=(p=this.config.states)==null?void 0:p.hover)==null?void 0:y.halo,l=(c==null?void 0:c.size)??10,h=(c==null?void 0:c.opacity)??.25;a.forEach((g,m)=>{const b=i.getPixelForValue(g.x??0),x=r.getPixelForValue(g.y??0),v=o.append("circle").attr("cx",b).attr("cy",x).attr("r",0).attr("fill",g.color||e).attr("opacity",0).attr("class","katucharts-halo"),k=o.append("circle").attr("cx",b).attr("cy",x).attr("r",0).attr("fill",g.color||e).attr("stroke",this.autoBorderColor()).attr("stroke-width",1).attr("class","katucharts-hover-marker");o.append("circle").attr("cx",b).attr("cy",x).attr("r",15).attr("fill","transparent").style("cursor",this.config.cursor||"pointer").on("mouseover",C=>{var E,_,T,I,L;v.transition().duration(Z).ease(q).attr("r",l).attr("opacity",h),k.transition().duration(Z).ease(q).attr("r",s),this.context.events.emit("point:mouseover",{point:g,index:m,series:this,event:C,plotX:b,plotY:x}),(_=(E=g.events)==null?void 0:E.mouseOver)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.mouseOver)==null||L.call(g,C)}).on("mouseout",C=>{var E,_,T,I,L;v.transition().duration(Z).ease(q).attr("r",0).attr("opacity",0),k.transition().duration(Z).ease(q).attr("r",0),this.context.events.emit("point:mouseout",{point:g,index:m,series:this,event:C}),(_=(E=g.events)==null?void 0:E.mouseOut)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.mouseOut)==null||L.call(g,C)}).on("click",C=>{var E,_,T,I,L,P,A;this.context.events.emit("point:click",{point:g,index:m,series:this,event:C}),(_=(E=g.events)==null?void 0:E.click)==null||_.call(g,C),(L=(I=(T=this.config.point)==null?void 0:T.events)==null?void 0:I.click)==null||L.call(g,C),(A=(P=this.config.events)==null?void 0:P.click)==null||A.call(this,C),this.handlePointSelect(k,g,m,C)})})}}class iw extends ed{constructor(){super(...arguments),this.isSpline=!0}}function Rc(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}function rw(n,t,e,i,r,o,s){if(e<=0||i<=0)return`M${n},${t}H${n}V${t}Z`;const a=o?Math.min(r,e/2,i/2):0,c=s?Math.min(r,e/2,i/2):0;return`M${n+a},${t}H${n+e-a}`+(a?`A${a},${a},0,0,1,${n+e},${t+a}`:`L${n+e},${t}`)+`V${t+i-c}`+(c?`A${c},${c},0,0,1,${n+e-c},${t+i}`:`L${n+e},${t+i}`)+`H${n+c}`+(c?`A${c},${c},0,0,1,${n},${t+i-c}`:`L${n},${t+i}`)+`V${t+a}`+(a?`A${a},${a},0,0,1,${n+a},${t}`:`L${n},${t}`)+"Z"}function ow(n,t,e,i,r,o,s){if(e<=0||i<=0)return`M${n},${t}H${n}V${t}Z`;const a=o?Math.min(r,e/2,i/2):0,c=s?Math.min(r,e/2,i/2):0;return`M${n+c},${t}H${n+e-a}`+(a?`A${a},${a},0,0,1,${n+e},${t+a}`:`L${n+e},${t}`)+`V${t+i-a}`+(a?`A${a},${a},0,0,1,${n+e-a},${t+i}`:`L${n+e},${t+i}`)+`H${n+c}`+(c?`A${c},${c},0,0,1,${n},${t+i-c}`:`L${n},${t+i}`)+`V${t+c}`+(c?`A${c},${c},0,0,1,${n+c},${t}`:`L${n},${t}`)+"Z"}class Dc extends Ht{constructor(t){super(t),this.isHorizontal=!1}getEntryDuration(){return(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt}render(){this.group.selectAll(".katucharts-data-labels").remove();const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{barWidth:a,barOffset:c,baseline:l}=this.computeBarGeometry(),h=this.config.stacking,f=this.context.stackOffsetsPos,u=this.context.stackOffsetsNeg,d=M=>((M.y??0)<0?u==null?void 0:u.get(M.x??0):f==null?void 0:f.get(M.x??0))||0,p=h==="percent",y=p?this.context.stackTotals:void 0,g=M=>{const C=M.x??0,E=d(M),_=M.y??0;if(p&&y){const T=y.get(C)||1;return(E+_)/T*100}return E+_},m=M=>{const C=M.x??0,E=d(M);if(p&&y){const _=y.get(C)||1;return E/_*100}return E};if(h){const M=this.context.stackTotals;for(const C of o){const E=C.x??0;if(M&&(C.total=M.get(E)||0,C.stackTotal=M.get(E)||0),p&&M){const _=M.get(E)||1;C.percentage=(C.y??0)/_*100}}}const b=this.config.minPointLength??0,x=this.config.crisp!==!1,v=Rc(this.config.borderRadius);if(h){const M=this.group.selectAll(".katucharts-column").data(o).join("path").attr("class","katucharts-column").attr("stroke",C=>C.borderColor||this.config.borderColor||"none").attr("stroke-width",C=>C.borderWidth??this.config.borderWidth??0);this.renderStackedBars(M,o,a,c,g,m,r,b,x,!!s,v),this.attachHoverEffects(M,o),this.renderColumnDataLabels(o,a,c,l,g,m),s&&this.emitAfterAnimate(gt+o.length*Bt);return}const k=this.group.selectAll(".katucharts-column").data(o).join("rect").attr("class","katucharts-column").attr("rx",v).attr("stroke",M=>M.borderColor||this.config.borderColor||"none").attr("stroke-width",M=>M.borderWidth??this.config.borderWidth??0);this.isHorizontal?this.renderHorizontalBars(k,o,a,c,l,r,b,x,!!s):this.renderVerticalBars(k,o,a,c,l,r,b,x,!!s),this.attachHoverEffects(k,o),this.renderColumnDataLabels(o,a,c,l,h?g:void 0,h?m:void 0),s&&this.emitAfterAnimate(gt+o.length*Bt)}renderVerticalBars(t,e,i,r,o,s,a,c,l){const{xAxis:h,yAxis:f}=this.context,u=this.config.threshold??0,d=this.config.negativeColor;if(t.attr("x",p=>this.crispCoord(h.getPixelForValue(p.x??0)+r,c)).attr("width",c?Math.round(i):i).attr("fill",(p,y)=>this.getPointColor(p,y,s,d,u)).attr("display",p=>p.y==null?"none":null),l){const p=this.getEntryDuration();t.attr("y",o).attr("height",0).transition().duration(p).ease(dt).delay((y,g)=>xe(g,0,Bt,e.length)).attr("y",y=>this.getBarY(y,f,o,a)).attr("height",y=>this.getBarHeight(y,f,o,a))}else t.attr("y",p=>this.getBarY(p,f,o,a)).attr("height",p=>this.getBarHeight(p,f,o,a))}renderHorizontalBars(t,e,i,r,o,s,a,c,l){const{xAxis:h,yAxis:f}=this.context,u=this.config.threshold??0,d=this.config.negativeColor;if(t.attr("y",p=>this.crispCoord(h.getPixelForValue(p.x??0)+r,c)).attr("height",c?Math.round(i):i).attr("fill",(p,y)=>this.getPointColor(p,y,s,d,u)).attr("display",p=>p.y==null?"none":null),l){const p=this.getEntryDuration();t.attr("x",o).attr("width",0).transition().duration(p).ease(dt).delay((y,g)=>xe(g,0,Bt,e.length)).attr("x",y=>{const g=f.getPixelForValue(y.y??0);return Math.min(o,g)}).attr("width",y=>{const g=Math.abs(f.getPixelForValue(y.y??0)-o);return Math.max(g,a)})}else t.attr("x",p=>Math.min(o,f.getPixelForValue(p.y??0))).attr("width",p=>Math.max(Math.abs(f.getPixelForValue(p.y??0)-o),a))}renderStackedBars(t,e,i,r,o,s,a,c,l,h,f){const u=this.context.totalSeriesOfType||1,d=this.context.indexInType||0,p=d===u-1,y=d===0,g=f??0;if(t.attr("fill",(m,b)=>this.getPointColor(m,b,a)),h){const m=this.getEntryDuration();t.each((b,x,v)=>{const k=st(v[x]),M=this.computeStackedStartParams(b,e,i,r,s,l),C=this.computeStackedRectParams(b,e,i,r,o,s,l,c);b._rectParams=C,k.attr("d",this.rectParamsToPath(M,g,p,y)).transition().duration(m).ease(dt).delay(xe(x,0,Bt,e.length)).attrTween("d",()=>{const E=ue(M.x,C.x),_=ue(M.y,C.y),T=ue(M.w,C.w),I=ue(M.h,C.h);return L=>this.rectParamsToPath({x:E(L),y:_(L),w:T(L),h:I(L)},g,p,y)})})}else t.each((m,b,x)=>{const v=this.computeStackedRectParams(m,e,i,r,o,s,l,c);m._rectParams=v,st(x[b]).attr("d",this.rectParamsToPath(v,g,p,y))})}getBarY(t,e,i,r){const o=e.getPixelForValue(t.y??0),s=Math.min(o,i),a=Math.abs(o-i);return a<r&&(t.y??0)>=(this.config.threshold??0)?s-(r-a):s}getBarHeight(t,e,i,r){return Math.max(Math.abs(e.getPixelForValue(t.y??0)-i),r)}crispCoord(t,e){return e?Math.round(t):t}computeStackedRectParams(t,e,i,r,o,s,a,c){const{xAxis:l,yAxis:h}=this.context;if(this.isHorizontal){const f=this.crispCoord(l.getPixelForValue(t.x??e.indexOf(t))+r,a),u=a?Math.round(i):i,d=Math.min(h.getPixelForValue(o(t)),h.getPixelForValue(s(t))),p=Math.max(Math.abs(h.getPixelForValue(o(t))-h.getPixelForValue(s(t))),c);return{x:d,y:f,w:p,h:u}}else{const f=this.crispCoord(l.getPixelForValue(t.x??0)+r,a),u=a?Math.round(i):i,d=Math.min(h.getPixelForValue(o(t)),h.getPixelForValue(s(t))),p=Math.max(Math.abs(h.getPixelForValue(o(t))-h.getPixelForValue(s(t))),c);return{x:f,y:d,w:u,h:p}}}computeStackedStartParams(t,e,i,r,o,s){const{xAxis:a,yAxis:c}=this.context;if(this.isHorizontal){const l=this.crispCoord(a.getPixelForValue(t.x??e.indexOf(t))+r,s),h=s?Math.round(i):i;return{x:c.getPixelForValue(o(t)),y:l,w:.1,h}}else{const l=this.crispCoord(a.getPixelForValue(t.x??0)+r,s),h=s?Math.round(i):i,f=c.getPixelForValue(o(t));return{x:l,y:f,w:h,h:.1}}}rectParamsToPath(t,e,i,r){return this.isHorizontal?ow(t.x,t.y,t.w,t.h,e,i,r):rw(t.x,t.y,t.w,t.h,e,i,r)}animateUpdate(t){if(this.config.stacking){this.updateStackedBars(t);return}const{xAxis:i,yAxis:r,plotArea:o}=this.context,s=this.getColor(),a=this.data,{barWidth:c,barOffset:l,baseline:h}=this.computeBarGeometry(),f=this.config.minPointLength??0,u=this.config.crisp!==!1,d=this.config.threshold??0,p=this.config.negativeColor,y=this.group.selectAll(".katucharts-column").data(a),g=y.enter().append("rect").attr("class","katucharts-column").attr("rx",Rc(this.config.borderRadius)).attr("fill",(b,x)=>this.getPointColor(b,x,s,p,d)).attr("display",b=>b.y==null?"none":null).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0);this.isHorizontal||g.attr("x",b=>this.crispCoord(i.getPixelForValue(b.x??0)+l,u)).attr("width",u?Math.round(c):c).attr("y",h).attr("height",0);const m=g.merge(y);m.attr("display",b=>b.y==null?"none":null),this.isHorizontal?m.transition().duration(t).attr("y",b=>this.crispCoord(i.getPixelForValue(b.x??0)+l,u)).attr("height",u?Math.round(c):c).attr("x",b=>Math.min(h,r.getPixelForValue(b.y??0))).attr("width",b=>Math.max(Math.abs(r.getPixelForValue(b.y??0)-h),f)).attr("fill",(b,x)=>this.getPointColor(b,x,s,p,d)):m.transition().duration(t).attr("x",b=>this.crispCoord(i.getPixelForValue(b.x??0)+l,u)).attr("width",u?Math.round(c):c).attr("y",b=>this.getBarY(b,r,h,f)).attr("height",b=>this.getBarHeight(b,r,h,f)).attr("fill",(b,x)=>this.getPointColor(b,x,s,p,d)),y.exit().transition().duration(t).attr("opacity",0).remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.attachHoverEffects(this.group.selectAll(".katucharts-column"),a),this.renderColumnDataLabels(a,c,l,h)}updateStackedBars(t){const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data,{barWidth:a,barOffset:c,baseline:l}=this.computeBarGeometry(),h=this.config.stacking,f=this.context.stackOffsetsPos,u=this.context.stackOffsetsNeg,d=I=>((I.y??0)<0?u==null?void 0:u.get(I.x??0):f==null?void 0:f.get(I.x??0))||0,p=h==="percent",y=this.config.crisp!==!1,g=Rc(this.config.borderRadius),m=this.config.minPointLength??0,b=p?this.context.stackTotals:void 0,x=I=>{const L=I.x??0,P=d(I),A=I.y??0;if(p&&b){const w=b.get(L)||1;return(P+A)/w*100}return P+A},v=I=>{const L=I.x??0,P=d(I);if(p&&b){const A=b.get(L)||1;return P/A*100}return P};if(h){const I=this.context.stackTotals;for(const L of s){const P=L.x??0;if(I&&(L.total=I.get(P)||0,L.stackTotal=I.get(P)||0),p&&I){const A=I.get(P)||1;L.percentage=(L.y??0)/A*100}}}const k=this.context.totalSeriesOfType||1,M=this.context.indexInType||0,C=M===k-1,E=M===0,_=g,T=this.group.selectAll(".katucharts-column").data(s);T.each((I,L,P)=>{const A=st(P[L]),w=this.computeStackedRectParams(I,s,a,c,x,v,y,m),S=I._rectParams||w;I._rectParams=w,A.transition().duration(t).attrTween("d",()=>{const $=ue(S.x,w.x),R=ue(S.y,w.y),F=ue(S.w,w.w),D=ue(S.h,w.h);return z=>this.rectParamsToPath({x:$(z),y:R(z),w:F(z),h:D(z)},_,C,E)}).attr("fill",this.getPointColor(I,L,o))}),T.enter().append("path").attr("class","katucharts-column").attr("stroke",I=>I.borderColor||this.config.borderColor||"none").attr("stroke-width",I=>I.borderWidth??this.config.borderWidth??0).attr("fill",(I,L)=>this.getPointColor(I,L,o)).each((I,L,P)=>{const A=this.computeStackedRectParams(I,s,a,c,x,v,y,m);I._rectParams=A,st(P[L]).attr("d",this.rectParamsToPath(A,_,C,E))}),T.exit().transition().duration(t).attr("opacity",0).remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.attachHoverEffects(this.group.selectAll(".katucharts-column"),s),this.renderColumnDataLabels(s,a,c,l,x,v)}computeBarGeometry(){var y,g;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=!!this.config.stacking,o=r?1:this.config.grouping!==!1&&this.context.totalSeriesOfType||1,s=r?0:this.config.grouping!==!1&&this.context.indexInType||0,a=this.config.groupPadding??.2,c=this.config.pointPadding??.1;let l;if(t instanceof hf)l=t.getBandwidth();else if(this.isHorizontal)l=i.height/Math.max(this.data.length,1);else if(this.config.pointRange!==void 0&&this.config.pointRange>0)l=Math.abs(t.getPixelForValue(this.config.pointRange)-t.getPixelForValue(0));else{const m=this.data;l=m.length>1?Math.abs(t.getPixelForValue(((y=m[1])==null?void 0:y.x)??1)-t.getPixelForValue(((g=m[0])==null?void 0:g.x)??0))*(1-a*2):i.width/Math.max(m.length,1)*(1-a*2)}const h=r?0:a,f=r?0:c;let u;this.config.pointWidth!==void 0?u=this.config.pointWidth:u=l*(1-h*2)/o*(1-f*2),this.config.maxPointWidth!==void 0&&(u=Math.min(u,this.config.maxPointWidth));let d;this.config.centerInCategory?d=-u/2:d=-l*(1-h*2)/2+(u+u*f*2)*s+u*f;const p=e.getPixelForValue(this.config.threshold??0);return{barWidth:u,barOffset:d,baseline:p,groupWidth:l}}getPointColor(t,e,i,r,o){if(t.color)return t.color;if(this.config.colorByPoint){const s=this.config.colors||this.context.colors;return s[e%s.length]}return r&&(t.y??0)<(o??0)?r:i}renderColumnDataLabels(t,e,i,r,o,s){const a=this.config.dataLabels;if(!(a!=null&&a.enabled))return;const{xAxis:c,yAxis:l}=this.context,h=a.inside??!1,f=this.context.plotArea.width,u=p=>o?l.getPixelForValue(o(p)):l.getPixelForValue(p.y??0),d=this.isHorizontal&&!h?(p,y,g)=>{const m=u(p),b=6,x=10;return m+b+g<=f?{x:m+b,anchor:"start"}:{x:Math.max(m-x,g+2),anchor:"end"}}:void 0;this.renderDataLabels(t,p=>{if(this.isHorizontal){const y=u(p);return h?(y+r)/2:y-5}return c.getPixelForValue(p.x??0)+i+e/2},p=>{if(this.isHorizontal)return c.getPixelForValue(p.x??0)+i+e/2;const y=o?l.getPixelForValue(o(p)):l.getPixelForValue(p.y??0);return h?(y+r)/2:y},d,this.isHorizontal?0:-10)}attachHoverEffects(t,e){var h,f,u,d,p,y,g,m;if(this.config.enableMouseTracking===!1)return;const{xAxis:i,yAxis:r}=this.context,o=!!this.config.stacking,s=((f=(h=this.config.states)==null?void 0:h.hover)==null?void 0:f.brightness)??(o?.2:.1),a=(d=(u=this.config.states)==null?void 0:u.hover)==null?void 0:d.color,c=(y=(p=this.config.states)==null?void 0:p.hover)==null?void 0:y.borderColor,l=(m=(g=this.config.states)==null?void 0:g.hover)==null?void 0:m.borderWidth;t.style("cursor",this.config.cursor||"pointer").on("mouseover",(b,x)=>{var L,P,A,w,S,$,R;const v=b.currentTarget,k=v.getAttribute("fill")||"";v.setAttribute("data-orig-fill",k);const C=st(v).interrupt("hover").transition("hover").duration(Z).ease(q);if(a?C.style("fill",a):C.style("fill",Kf(k,s)),c&&C.style("stroke",c),l!==void 0&&C.style("stroke-width",String(l)),v.style.filter="drop-shadow(0 1px 3px rgba(0,0,0,0.2))",o){const F=this.context.allSeries;if(F)for(const D of F)D.visible&&((L=D.config)!=null&&L.stacking)&&((P=D.group)==null||P.selectAll(".katucharts-column").filter(function(){return this!==v}).interrupt("stackDim").transition("stackDim").duration(vs).ease(q).attr("opacity",.3));v.setAttribute("data-orig-stroke",v.getAttribute("stroke")||""),v.setAttribute("data-orig-stroke-width",v.getAttribute("stroke-width")||""),C.style("stroke","#ffffff").style("stroke-width","2")}const E=e.indexOf(x),_=i.getPixelForValue(x.x??0),T=r.getPixelForValue(x.y??0),I=this.context.inverted;this.context.events.emit("point:mouseover",{point:x,index:E,series:this,event:b,plotX:I?T:_,plotY:I?_:T}),(w=(A=x.events)==null?void 0:A.mouseOver)==null||w.call(x,b),(R=($=(S=this.config.point)==null?void 0:S.events)==null?void 0:$.mouseOver)==null||R.call(x,b)}).on("mouseout",(b,x)=>{var _,T,I,L,P,A,w;const v=b.currentTarget,k=v.getAttribute("data-orig-fill")||"",C=st(v).interrupt("hover").transition("hover").duration(Z).ease(q);if(C.style("fill",k),v.style.filter="",o){const S=this.context.allSeries;if(S)for(const $ of S)$.visible&&((_=$.config)!=null&&_.stacking)&&((T=$.group)==null||T.selectAll(".katucharts-column").interrupt("stackDim").transition("stackDim").duration(vs).ease(q).attr("opacity",1));C.style("stroke",v.getAttribute("data-orig-stroke")||"").style("stroke-width",v.getAttribute("data-orig-stroke-width")||"")}else C.style("stroke","").style("stroke-width","");C.on("end",()=>{v.matches(":hover")||(v.style.fill="")});const E=e.indexOf(x);this.context.events.emit("point:mouseout",{point:x,index:E,series:this,event:b}),(L=(I=x.events)==null?void 0:I.mouseOut)==null||L.call(x,b),(w=(A=(P=this.config.point)==null?void 0:P.events)==null?void 0:A.mouseOut)==null||w.call(x,b)}).on("click",(b,x)=>{var C,E,_,T,I,L,P;const v=e.indexOf(x);this.context.events.emit("point:click",{point:x,index:v,series:this,event:b}),(E=(C=x.events)==null?void 0:C.click)==null||E.call(x,b),(I=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click)==null||I.call(x,b),(P=(L=this.config.events)==null?void 0:L.click)==null||P.call(this,b);const k=b.currentTarget,M=st(k);this.handlePointSelect(M,x,v,b)})}}class sw extends Dc{constructor(){super(...arguments),this.isHorizontal=!0}}const nd={circle:bn,square:gs,diamond:ps,triangle:ms,"triangle-down":ys,cross:ds},id=["circle","diamond","square","triangle","triangle-down"];class aw extends Ht{constructor(t){t.clip=!1,super(t),this.cachedPositions=[]}resolveMarkerSymbol(){var r;if((r=this.config.marker)!=null&&r.symbol)return this.config.marker.symbol;const e=(this.context.allSeries||[]).filter(o=>o.config._internalType==="scatter");if(e.length<=1)return"circle";const i=e.indexOf(this);return id[i%id.length]}getLegendSymbolShape(){return this.resolveMarkerSymbol()}render(){var f,u,d,p;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data.filter(y=>y.y!==null&&y.y!==void 0),s=((f=this.config.marker)==null?void 0:f.radius)??4,a=((p=(d=(u=this.config.marker)==null?void 0:u.states)==null?void 0:d.hover)==null?void 0:p.radius)??s+3,c=this.context.animate,l=this.resolveMarkerSymbol(),h=this.config.jitter;this.cachedPositions=o.map(y=>({cx:this.applyJitter(t.getPixelForValue(y.x??0),i.width,h==null?void 0:h.x),cy:this.applyJitter(e.getPixelForValue(y.y??0),i.height,h==null?void 0:h.y)})),l==="circle"?this.renderCircles(o,r,s,a,!!c):this.renderSymbols(o,r,s,a,l,!!c),this.renderDataLabels(o,(y,g)=>this.cachedPositions[g].cx,(y,g)=>this.cachedPositions[g].cy),c&&this.emitAfterAnimate(gt+o.length*Bt)}animateUpdate(t){var f;const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data.filter(u=>u.y!==null&&u.y!==void 0),a=((f=this.config.marker)==null?void 0:f.radius)??4,c=this.config.jitter;this.cachedPositions=s.map(u=>({cx:this.applyJitter(e.getPixelForValue(u.x??0),r.width,c==null?void 0:c.x),cy:this.applyJitter(i.getPixelForValue(u.y??0),r.height,c==null?void 0:c.y)}));const l=this.resolveMarkerSymbol();if(l==="circle"){const u=this.group.selectAll(".katucharts-scatter-point").data(s);u.exit().transition().duration(t).attr("r",0).remove(),u.enter().append("circle").attr("class","katucharts-scatter-point").attr("r",0).attr("fill",p=>this.getPointFill(p,o)).attr("stroke",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineColor)??((g=this.config.marker)==null?void 0:g.lineColor)??o}).attr("stroke-width",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineWidth)??((g=this.config.marker)==null?void 0:g.lineWidth)??1}).attr("opacity",this.config.opacity??1).merge(u).attr("fill",p=>this.getPointFill(p,o)).attr("stroke",p=>{var y,g;return((y=p.marker)==null?void 0:y.lineColor)??((g=this.config.marker)==null?void 0:g.lineColor)??o}).transition().duration(t).attr("cx",(p,y)=>this.cachedPositions[y].cx).attr("cy",(p,y)=>this.cachedPositions[y].cy).attr("r",p=>{var y;return((y=p.marker)==null?void 0:y.radius)??a})}else{const u=nd[l]||bn,d=this.group.selectAll(".katucharts-scatter-point").data(s);d.exit().transition().duration(t).attr("opacity",0).remove(),d.enter().append("path").attr("class","katucharts-scatter-point").attr("fill",y=>this.getPointFill(y,o)).attr("stroke",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineColor)??((m=this.config.marker)==null?void 0:m.lineColor)??o}).attr("stroke-width",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineWidth)??((m=this.config.marker)==null?void 0:m.lineWidth)??1}).attr("opacity",this.config.opacity??1).merge(d).attr("fill",y=>this.getPointFill(y,o)).attr("stroke",y=>{var g,m;return((g=y.marker)==null?void 0:g.lineColor)??((m=this.config.marker)==null?void 0:m.lineColor)??o}).transition().duration(t).attr("transform",(y,g)=>`translate(${this.cachedPositions[g].cx},${this.cachedPositions[g].cy})`).attr("d",y=>{var m;const g=((m=y.marker)==null?void 0:m.radius)??a;return Ve().type(u).size(Math.PI*g*g)()})}this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(s,(u,d)=>this.cachedPositions[d].cx,(u,d)=>this.cachedPositions[d].cy)}getPointFill(t,e){var i,r;return t.color?t.color:(i=t.marker)!=null&&i.fillColor?t.marker.fillColor:(r=this.config.marker)!=null&&r.fillColor?this.config.marker.fillColor:this.config.negativeColor&&(t.y??0)<(this.config.threshold??0)?this.config.negativeColor:e}getEntryDuration(){return(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt}renderCircles(t,e,i,r,o){const s=this.group.selectAll(".katucharts-scatter-point").data(t).join("circle").attr("class","katucharts-scatter-point").attr("cx",(a,c)=>this.cachedPositions[c].cx).attr("cy",(a,c)=>this.cachedPositions[c].cy).attr("fill",a=>this.getPointFill(a,e)).attr("stroke",a=>{var c,l;return((c=a.marker)==null?void 0:c.lineColor)??((l=this.config.marker)==null?void 0:l.lineColor)??e}).attr("stroke-width",a=>{var c,l;return((c=a.marker)==null?void 0:c.lineWidth)??((l=this.config.marker)==null?void 0:l.lineWidth)??1}).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer");o?s.attr("r",0).transition().duration(this.getEntryDuration()).ease(dt).delay((a,c)=>xe(c,0,Bt,t.length)).attr("r",a=>{var c;return((c=a.marker)==null?void 0:c.radius)??i}):s.attr("r",a=>{var c;return((c=a.marker)==null?void 0:c.radius)??i}),this.attachScatterEvents(s,t,i,r,e,"circle")}renderSymbols(t,e,i,r,o,s){const a=nd[o]||bn,c=this.group.selectAll(".katucharts-scatter-point").data(t).join("path").attr("class","katucharts-scatter-point").attr("transform",(h,f)=>`translate(${this.cachedPositions[f].cx},${this.cachedPositions[f].cy})`).attr("fill",h=>this.getPointFill(h,e)).attr("stroke",h=>{var f,u;return((f=h.marker)==null?void 0:f.lineColor)??((u=this.config.marker)==null?void 0:u.lineColor)??e}).attr("stroke-width",h=>{var f,u;return((f=h.marker)==null?void 0:f.lineWidth)??((u=this.config.marker)==null?void 0:u.lineWidth)??1}).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer"),l=h=>{var u;const f=((u=h.marker)==null?void 0:u.radius)??i;return Ve().type(a).size(Math.PI*f*f)()};if(s){const h=Ve().type(a).size(0);c.attr("d",h).transition().duration(this.getEntryDuration()).ease(dt).delay((f,u)=>xe(u,0,Bt,t.length)).attr("d",l)}else c.attr("d",l);this.attachScatterEvents(c,t,i,r,e,"symbol",a)}attachScatterEvents(t,e,i,r,o,s,a){var y,g,m,b,x;if(this.config.enableMouseTracking===!1)return;const c=(y=this.config.states)==null?void 0:y.hover,l=(g=c==null?void 0:c.marker)==null?void 0:g.fillColor,h=(x=(b=(m=this.config.marker)==null?void 0:m.states)==null?void 0:b.hover)==null?void 0:x.lineWidth,f=c==null?void 0:c.halo,u=(f==null?void 0:f.size)??10,d=(f==null?void 0:f.opacity)??.25,p=e.map((v,k)=>{var M;return this.group.insert("circle",".katucharts-scatter-point").attr("cx",this.cachedPositions[k].cx).attr("cy",this.cachedPositions[k].cy).attr("r",0).attr("fill",v.color||((M=this.config.marker)==null?void 0:M.fillColor)||o).attr("opacity",0).attr("class","katucharts-halo")});t.on("mouseover",(v,k)=>{var L,P,A,w,S,$,R,F,D,z,B,N,K,V;const M=v.currentTarget,C=e.indexOf(k);C>=0&&p[C]&&p[C].transition("halo").duration(Z).ease(q).attr("r",u).attr("opacity",d);const E=((L=k.marker)==null?void 0:L.radius)??i,_=((w=(A=(P=k.marker)==null?void 0:P.states)==null?void 0:A.hover)==null?void 0:w.radius)??((R=($=(S=this.config.marker)==null?void 0:S.states)==null?void 0:$.hover)==null?void 0:R.radius)??E+3,I=st(M).interrupt("hover").transition("hover").duration(Z).ease(q);if(s==="circle")I.attr("r",_);else if(a){const G=Math.PI*_*_;I.attr("d",Ve().type(a).size(G)())}M.style.filter="drop-shadow(0 1px 4px rgba(0,0,0,0.3))",l&&I.style("fill",l),h!==void 0&&I.style("stroke-width",String(h)),this.context.events.emit("point:mouseover",{point:k,index:C,series:this,event:v,plotX:((F=this.cachedPositions[C])==null?void 0:F.cx)??0,plotY:((D=this.cachedPositions[C])==null?void 0:D.cy)??0}),(B=(z=k.events)==null?void 0:z.mouseOver)==null||B.call(k,v),(V=(K=(N=this.config.point)==null?void 0:N.events)==null?void 0:K.mouseOver)==null||V.call(k,v)}).on("mouseout",(v,k)=>{var I,L,P,A,w,S;const M=v.currentTarget,C=e.indexOf(k);C>=0&&p[C]&&p[C].transition("halo").duration(Z).ease(q).attr("r",0).attr("opacity",0);const E=((I=k.marker)==null?void 0:I.radius)??i,T=st(M).interrupt("hover").transition("hover").duration(Z).ease(q);if(s==="circle")T.attr("r",E);else if(a){const $=Math.PI*E*E;T.attr("d",Ve().type(a).size($)())}M.style.filter="",T.style("fill",null).style("stroke-width",null),this.context.events.emit("point:mouseout",{point:k,index:C,series:this,event:v}),(P=(L=k.events)==null?void 0:L.mouseOut)==null||P.call(k,v),(S=(w=(A=this.config.point)==null?void 0:A.events)==null?void 0:w.mouseOut)==null||S.call(k,v)}).on("click",(v,k)=>{var C,E,_,T,I,L,P;const M=e.indexOf(k);this.context.events.emit("point:click",{point:k,index:M,series:this,event:v}),(E=(C=k.events)==null?void 0:C.click)==null||E.call(k,v),(I=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click)==null||I.call(k,v),(P=(L=this.config.events)==null?void 0:L.click)==null||P.call(this,v),this.handlePointSelect(st(v.currentTarget),k,M,v)})}}class cw extends Ht{constructor(t){t.clip=!1,super(t)}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data.filter(f=>f.y!==null&&f.y!==void 0),s=this.context.animate,a=this.config.jitter,c=this.filterByZThreshold(o);this.buildSizeScale(c);const l=c.map(f=>({cx:this.applyJitter(t.getPixelForValue(f.x??0),i.width,a==null?void 0:a.x),cy:this.applyJitter(e.getPixelForValue(f.y??0),i.height,a==null?void 0:a.y)})),h=this.group.selectAll(".katucharts-bubble").data(c).join("circle").attr("class","katucharts-bubble").attr("cx",(f,u)=>l[u].cx).attr("cy",(f,u)=>l[u].cy).attr("fill",(f,u)=>this.getBubbleFill(f,u,r)).attr("fill-opacity",this.config.fillOpacity??.5).attr("stroke",(f,u)=>this.config.lineColor||this.getBubbleFill(f,u,r)).attr("stroke-width",this.config.lineWidth??1).style("cursor",this.config.cursor||"pointer");if(s){const u=(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt;h.attr("r",0).transition().duration(u).ease(dt).delay((d,p)=>xe(p,0,Bt,c.length)).attr("r",d=>this.sizeScale(this.getZValue(d)))}else h.attr("r",f=>this.sizeScale(this.getZValue(f)));this.attachBubbleEvents(h,c,l,r),this.renderDataLabels(c,(f,u)=>l[u].cx,(f,u)=>l[u].cy),s&&this.emitAfterAnimate(gt+c.length*Bt)}animateUpdate(t){const{xAxis:e,yAxis:i,plotArea:r}=this.context,o=this.getColor(),s=this.data.filter(u=>u.y!==null&&u.y!==void 0),a=this.filterByZThreshold(s),c=this.config.jitter;this.buildSizeScale(a);const l=a.map(u=>({cx:this.applyJitter(e.getPixelForValue(u.x??0),r.width,c==null?void 0:c.x),cy:this.applyJitter(i.getPixelForValue(u.y??0),r.height,c==null?void 0:c.y)})),h=this.group.selectAll(".katucharts-bubble").data(a);h.exit().transition().duration(t).attr("r",0).remove(),h.enter().append("circle").attr("class","katucharts-bubble").attr("r",0).attr("fill",(u,d)=>this.getBubbleFill(u,d,o)).attr("fill-opacity",this.config.fillOpacity??.5).attr("stroke",(u,d)=>this.config.lineColor||this.getBubbleFill(u,d,o)).attr("stroke-width",this.config.lineWidth??1).merge(h).transition().duration(t).attr("cx",(u,d)=>{var p;return((p=l[d])==null?void 0:p.cx)??0}).attr("cy",(u,d)=>{var p;return((p=l[d])==null?void 0:p.cy)??0}).attr("r",u=>this.sizeScale(this.getZValue(u))).attr("fill",(u,d)=>this.getBubbleFill(u,d,o)),this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(a,(u,d)=>{var p;return((p=l[d])==null?void 0:p.cx)??0},(u,d)=>{var p;return((p=l[d])==null?void 0:p.cy)??0})}filterByZThreshold(t){const e=this.config.displayNegative!==!1,i=this.config.zThreshold??0;return e?t:t.filter(r=>(r.z??0)>=i)}getZValue(t){const e=t.z??1;return this.config.sizeByAbsoluteValue?Math.abs(e):e}buildSizeScale(t){const e=t.map(c=>this.getZValue(c)),i=this.config.zMin??Math.min(...e,0),r=this.config.zMax??Math.max(...e,1),o=this.parseSize(this.config.minSize,8),s=this.parseSize(this.config.maxSize,30);(this.config.sizeBy||"area")==="width"?this.sizeScale=Me().domain([i,r]).range([o,s]).clamp(!0):this.sizeScale=Fx().domain([i,r]).range([o,s]).clamp(!0)}parseSize(t,e){if(t===void 0)return e;if(typeof t=="number")return t;if(typeof t=="string"&&t.endsWith("%")){const i=parseFloat(t)/100;return Math.min(this.context.plotArea.width,this.context.plotArea.height)*i/2}return parseFloat(t)||e}getBubbleFill(t,e,i){if(t.color)return t.color;if(this.config.negativeColor&&(t.z??0)<(this.config.zThreshold??0))return this.config.negativeColor;if(this.config.colorByPoint){const r=this.config.colors||this.context.colors;return r[e%r.length]}return i}attachBubbleEvents(t,e,i,r){var s,a;if(this.config.enableMouseTracking===!1)return;(a=(s=this.config.states)==null?void 0:s.hover)==null||a.brightness;const o=this.config.fillOpacity??.5;t.on("mouseover",(c,l)=>{var d,p,y,g,m,b,x;const h=c.currentTarget,f=this.sizeScale(this.getZValue(l));st(h).interrupt("hover").transition("hover").duration(Z).ease(q).attr("r",f+4).attr("fill-opacity",Math.min(o+.3,1)),h.style.filter="drop-shadow(0 2px 6px rgba(0,0,0,0.3))";const u=e.indexOf(l);this.context.events.emit("point:mouseover",{point:l,index:u,series:this,event:c,plotX:((d=i[u])==null?void 0:d.cx)??0,plotY:((p=i[u])==null?void 0:p.cy)??0}),(g=(y=l.events)==null?void 0:y.mouseOver)==null||g.call(l,c),(x=(b=(m=this.config.point)==null?void 0:m.events)==null?void 0:b.mouseOver)==null||x.call(l,c)}).on("mouseout",(c,l)=>{var u,d,p,y,g;const h=c.currentTarget;st(h).interrupt("hover").transition("hover").duration(Z).ease(q).attr("r",this.sizeScale(this.getZValue(l))).attr("fill-opacity",o),h.style.filter="";const f=e.indexOf(l);this.context.events.emit("point:mouseout",{point:l,index:f,series:this,event:c}),(d=(u=l.events)==null?void 0:u.mouseOut)==null||d.call(l,c),(g=(y=(p=this.config.point)==null?void 0:p.events)==null?void 0:y.mouseOut)==null||g.call(l,c)}).on("click",(c,l)=>{var f,u,d,p,y,g,m;const h=e.indexOf(l);this.context.events.emit("point:click",{point:l,index:h,series:this,event:c}),(u=(f=l.events)==null?void 0:f.click)==null||u.call(l,c),(y=(p=(d=this.config.point)==null?void 0:d.events)==null?void 0:p.click)==null||y.call(l,c),(m=(g=this.config.events)==null?void 0:g.click)==null||m.call(this,c),this.handlePointSelect(st(c.currentTarget),l,h,c)})}getBubbleLegendInfo(){const t=this.filterByZThreshold(this.data.filter(c=>c.y!==null&&c.y!==void 0));if(t.length===0)return null;this.buildSizeScale(t);const e=t.map(c=>this.getZValue(c)),i=this.config.zMin??Math.min(...e),r=this.config.zMax??Math.max(...e);if(!isFinite(i)||!isFinite(r)||r<=0)return null;const o=[r,(i+r)/2,i],s=new Set,a=o.map(c=>Math.round(c)).filter(c=>c>0&&!s.has(c)&&(s.add(c),!0)).map(c=>({value:c,radius:this.sizeScale(c)}));return a.length===0?null:{sizeBy:this.config.sizeBy||"area",color:this.getColor(),ranges:a}}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const c of this.data)c.x!==void 0&&c.x!==null&&(t=Math.min(t,c.x),e=Math.max(e,c.x)),c.y!==void 0&&c.y!==null&&(i=Math.min(i,c.y),r=Math.max(r,c.y));const o=e-t||1,s=r-i||1,a=.08;return t-=o*a,e+=o*a,i-=s*a,r+=s*a,{xMin:t,xMax:e,yMin:i,yMax:r}}}class rd extends Ht{constructor(t){super(t),this.selectedIndices=new Set,t.showInLegend=t.showInLegend??!1}legendPoints(){return this.data.filter(t=>t.y!==null&&t.y!==void 0&&(t.y??0)>0)}getMultiLegendItems(){var i;const t=this.config.colors,e=((i=this.context)==null?void 0:i.colors)??[];return this.legendPoints().map((r,o)=>({label:r.name??String(r.y??""),color:r.color??(t?t[o%t.length]:e[o%e.length]),visible:r.visible!==!1}))}toggleLegendItem(t){const e=this.legendPoints()[t];return e?(e.visible=e.visible===!1,this.redraw(),e.visible!==!1):null}dataLabelConfigs(){const t=this.config.dataLabels;return t?(Array.isArray(t)?t:[t]).filter(i=>i&&i.enabled!==!1):[]}init(t){const e=this.dataLabelConfigs().length>0;if(e&&(this.config.clip=!1),super.init(t),e){const i=this.group.select(function(){return this.ownerSVGElement});i.empty()||i.style("overflow","visible")}}render(){var j,U,X,tt,O,it,nt,lt,ht,at;const{plotArea:t}=this.context,e=this.config.ignoreHiddenPoint!==!1,i=this.data.filter(W=>W.y!==null&&W.y!==void 0&&(W.y??0)>0),r=e?i.filter(W=>W.visible!==!1):i,o=this.context.animate,s=this.dataLabelConfigs().filter(W=>(W.distance??30)>=0),a=s.length>0,c=this.config.center||["50%","50%"],l=this.resolvePercent(c[0],t.width),h=this.resolvePercent(c[1],t.height),f=(this.config.startAngle??0)*Math.PI/180,u=this.config.endAngle!==void 0?this.config.endAngle*Math.PI/180:f+2*Math.PI,d=r.reduce((W,J)=>W+(J.y??0),0),y=L2().value(W=>W.y??0).sort(null).startAngle(f).endAngle(u)(r),g=u-f;for(const W of y)W.data.percentage=(W.endAngle-W.startAngle)/g*100,W.data.total=d;const m=a?this.measureLabelMargins(y,s,t.width):{horizontal:0,vertical:0},b=t.width-m.horizontal*2,x=t.height-m.vertical,v=Math.min(b,x),k=Math.min(t.width,t.height),M=this.config.size!==void 0&&this.config.size!==null,C=M?this.resolvePercent(this.config.size,k):v,E=this.config.minSize?this.resolvePercent(this.config.minSize,k):0,T=Math.max(a?Math.min(C,v):M?C:k,E)/2,I=this.resolvePercent(this.config.innerSize||0,T*2)/2,L=this.config.depth??0,P=this.config.fillColor;if(d===0&&P){const W=this.group.append("g").attr("transform",`translate(${l},${h})`),J=Pe().innerRadius(I).outerRadius(T).startAngle(f).endAngle(u);W.append("path").attr("d",J({})).attr("fill",Hn(P,W,"#cccccc"));return}const A=this.resolveBorderRadius(this.config.borderRadius),w=Pe().innerRadius(I).outerRadius(T).cornerRadius(A),S=this.config.slicedOffset??10,$=Pe().innerRadius(I).outerRadius(T+S*.4).cornerRadius(A),R=this.group.append("g").attr("transform",`translate(${l},${h})`);L>0&&this.render3DEffect(R,y,I,T,L);const F=this.config.allowPointSelect===!0;(U=(j=this.config.states)==null?void 0:j.hover)==null||U.brightness;const D=(tt=(X=this.config.states)==null?void 0:X.select)==null?void 0:tt.color,z=(it=(O=this.config.states)==null?void 0:O.select)==null?void 0:it.borderColor,B=(lt=(nt=this.config.states)==null?void 0:nt.select)==null?void 0:lt.borderWidth,N=((at=(ht=this.config.states)==null?void 0:ht.inactive)==null?void 0:at.opacity)??.4,K=(W,J)=>this.resolveSliceColor(W.data,J),V=W=>{const J=(W.startAngle+W.endAngle)/2,ut=S*Math.sin(J),vt=-S*Math.cos(J);return`translate(${ut},${vt})`},G=this,H=R.selectAll(".katucharts-pie-slice").data(y).join("path").attr("class","katucharts-pie-slice").attr("fill",(W,J)=>K(W,J)).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("opacity",this.config.opacity??1).style("cursor",this.config.cursor||"pointer");H.each(function(W,J){const ut=st(this);(W.data.sliced||G.selectedIndices.has(J))&&ut.attr("transform",V(W))}),o?H.each(function(W,J){const ut=st(this),vt={startAngle:W.startAngle,endAngle:W.startAngle},Lt=ue(vt,W);ut.transition().duration(gt).ease(dt).delay(Ic+J*Bt).attrTween("d",()=>wt=>w(Lt(wt)))}):H.attr("d",w),this.config.enableMouseTracking!==!1&&H.on("mouseover",function(W,J){var $t,Vt,ee,Ct,Jt;const ut=st(this),vt=y.indexOf(J);G.selectedIndices.has(vt)||ut.transition("arc").duration(Z).ease(q).attr("d",$(J)),ut.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.25))"),H.interrupt("highlight"),H.attr("opacity",G.config.opacity??1),H.filter(ne=>ne!==J).transition("highlight").duration(Z).ease(q).attr("opacity",N);const wt=w.centroid(J);G.context.events.emit("point:mouseover",{point:J.data,index:vt,series:G,event:W,plotX:l+wt[0],plotY:h+wt[1]}),(Vt=($t=J.data.events)==null?void 0:$t.mouseOver)==null||Vt.call(J.data,W),(Jt=(Ct=(ee=G.config.point)==null?void 0:ee.events)==null?void 0:Ct.mouseOver)==null||Jt.call(J.data,W)}).on("mouseout",function(W,J){var wt,$t,Vt,ee,Ct;const ut=st(this),vt=y.indexOf(J);G.selectedIndices.has(vt)||ut.transition("arc").duration(Z).ease(q).attr("d",w(J)),ut.style("filter",""),H.interrupt("highlight"),H.transition("highlight").duration(Z).ease(q).attr("opacity",G.config.opacity??1),G.context.events.emit("point:mouseout",{point:J.data,index:vt,series:G,event:W}),($t=(wt=J.data.events)==null?void 0:wt.mouseOut)==null||$t.call(J.data,W),(Ct=(ee=(Vt=G.config.point)==null?void 0:Vt.events)==null?void 0:ee.mouseOut)==null||Ct.call(J.data,W)}).on("click",function(W,J){var vt,Lt,wt,$t,Vt,ee,Ct,Jt,ne,Ee,Gt,Ut,Xe,ae;const ut=y.indexOf(J);F&&(G.selectedIndices.has(ut)?(G.selectedIndices.delete(ut),st(this).transition("slice").duration(Z).ease(q).attr("transform",""),(Lt=(vt=J.data.events)==null?void 0:vt.unselect)==null||Lt.call(J.data,W),(Vt=($t=(wt=G.config.point)==null?void 0:wt.events)==null?void 0:$t.unselect)==null||Vt.call(J.data,W)):(G.selectedIndices.add(ut),st(this).transition("slice").duration(Z).ease(q).attr("transform",V(J)),(Ct=(ee=J.data.events)==null?void 0:ee.select)==null||Ct.call(J.data,W),(Ee=(ne=(Jt=G.config.point)==null?void 0:Jt.events)==null?void 0:ne.select)==null||Ee.call(J.data,W)),(D||z||B!==void 0)&&H.each(function(un,Te){const de=st(this);G.selectedIndices.has(Te)?(D&&de.attr("fill",D),z&&de.attr("stroke",z),B!==void 0&&de.attr("stroke-width",B)):(de.attr("fill",K(un,Te)),de.attr("stroke",G.config.borderColor||G.autoBorderColor()),de.attr("stroke-width",G.config.borderWidth??1))})),G.context.events.emit("point:click",{point:J.data,index:ut,series:G,event:W}),(Ut=(Gt=J.data.events)==null?void 0:Gt.click)==null||Ut.call(J.data,W),(ae=(Xe=G.config.events)==null?void 0:Xe.click)==null||ae.call(G,W)});for(const W of this.dataLabelConfigs())this.renderPieLabels(R,y,w,T,u-f,W,l);o&&this.emitAfterAnimate(gt+y.length*Bt)}resolveSliceColor(t,e){if(t.color)return t.color;if(this.config.colors)return this.config.colors[e%this.config.colors.length];const i=this.context.colors;return i[e%i.length]}resolveLabelText(t,e,i){const r={...e,color:i};let o;t.formatter?o=t.formatter.call({point:r,series:{name:this.config.name},x:e.x,y:e.y,percentage:e.percentage}):t.format?o=Zt(t.format,{point:r,series:{name:this.config.name}}):o=e.name||String(e.y);let s;const a=/(?:^|[\s;"'])color\s*:\s*([^;"'>]+)/i.exec(o);return a&&(s=lf(a[1],i)),{text:re(o),inlineColor:s}}measureLabelMargins(t,e,i){var c;let r=0,o=0,s=0;for(const l of e){const h=l.distance??30,f=l.connectorPadding??5,u=se(((c=l.style)==null?void 0:c.fontSize)||kt);s=Math.max(s,h+10);for(const d of t){const p=this.resolveSliceColor(d.data,d.index),{text:y}=this.resolveLabelText(l,d.data,p),g=h+pe(y,u)+f;(d.startAngle+d.endAngle)/2<Math.PI?o=Math.max(o,g):r=Math.max(r,g)}}return{horizontal:Math.min(Math.max(r,o),i*.22),vertical:s}}renderPieLabels(t,e,i,r,o,s,a){var E,_;if(!s||s.enabled===!1)return;const c=this.context.plotArea.width,l=this.context.plotArea.height,h=c/2,f=l/2,u=s.distance??30,d=s.connectorWidth??1,p=s.connectorColor||"#999",y=s.connectorPadding??5;s.softConnector;const g=((E=s.style)==null?void 0:E.fontSize)||kt,m=s.color||((_=s.style)==null?void 0:_.color)||Fe,b=s.alignTo,x=u<0,v=se(g),k=v*1.4,M=[];if(e.forEach((T,I)=>{const L=T.data.percentage,P=i.centroid(T),A=(T.startAngle+T.endAngle)/2,w=this.resolveSliceColor(T.data,I),S=r+u;let $=S*Math.sin(A),R=-S*Math.cos(A);(b==="plotEdges"||b==="connectors")&&($=A<Math.PI?h-5:-(h-5));const{text:F,inlineColor:D}=this.resolveLabelText(s,T.data,w);M.push({lx:$,ly:R,text:F,midAngle:A,centroid:P,percentage:L,data:T.data,visible:!0,color:w,inlineColor:D})}),!x&&!s.allowOverlap){for(const P of M){const A=a+P.lx;P.availWidth=(P.lx>=0?c-A:A)-6}const T=M.filter(P=>P.midAngle<Math.PI),I=M.filter(P=>P.midAngle>=Math.PI);this.distribute(T,k,f,h,g),this.distribute(I,k,f,h,g);const L=r+u;for(const P of M){if(!P.visible)continue;const A=Math.max(-L,Math.min(L,P.ly)),w=Math.sqrt(Math.max(0,L*L-A*A)),S=P.midAngle<Math.PI;P.lx=S?Math.max(w,r*.3):-Math.max(w,r*.3);const $=a+P.lx;P.availWidth=(P.lx>=0?c-$:$)-6}}else if(x&&!s.allowOverlap){const T=[],I=M.filter(L=>L.visible).sort((L,P)=>P.percentage-L.percentage);for(const L of I){const P=pe(L.text,v),A=v*1.1,w=L.centroid[0],S=L.centroid[1],$={l:w-P/2,r:w+P/2,t:S-A/2,b:S+A/2};if(T.some(F=>$.l<F.r&&$.r>F.l&&$.t<F.b&&$.b>F.t)){L.visible=!1;continue}T.push($)}}const C=t.append("g").attr("class","katucharts-pie-labels");M.forEach(T=>{if(!T.visible)return;const{lx:I,ly:L,text:P,midAngle:A,centroid:w,color:S,inlineColor:$}=T,R=A<Math.PI,F=S||p;if(d>0&&u>=0){const N=r+y,K=N*Math.sin(A),V=-N*Math.cos(A),G=s.connectorShape||"fixedOffset";if(G==="straight")C.append("line").attr("class","katucharts-pie-connector").attr("x1",w[0]).attr("y1",w[1]).attr("x2",I).attr("y2",L).attr("stroke",F).attr("stroke-width",d);else if(G==="crookedLine"){const H=s.crookDistance??"70%",j=typeof H=="string"?parseFloat(H)/100:H/u,U=r+u*j,X=U*Math.sin(A),tt=-U*Math.cos(A);C.append("path").attr("class","katucharts-pie-connector").attr("d",`M${w[0]},${w[1]}L${X},${tt}L${I},${L}`).attr("fill","none").attr("stroke",F).attr("stroke-width",d)}else if(typeof G=="function"){const H=G({connectorPosition:{from:w,to:[I,L]},labelDistance:u,labelPosition:[I,L]});C.append("path").attr("class","katucharts-pie-connector").attr("d",H).attr("fill","none").attr("stroke",F).attr("stroke-width",d)}else{const H=r+u*.5,j=H*Math.sin(A),U=-H*Math.cos(A);C.append("path").attr("class","katucharts-pie-connector").attr("d",`M${K},${V}L${j},${U}L${I},${L}`).attr("fill","none").attr("stroke",F).attr("stroke-width",d)}}const D=(x?w[0]:I)+(s.x??0),z=C.append("text").attr("x",D).attr("y",(x?w[1]:L)+(s.y??0)).attr("text-anchor",x?"middle":R?"start":"end").attr("dominant-baseline","middle").attr("font-size",g).attr("fill",$||m).style("pointer-events","none");!x&&T.availWidth?this.wrapLabelLines(z,P,T.availWidth,v,D):z.text(P);const B=s.style||{};z.attr("font-weight",B.fontWeight||"bold"),B.fontFamily&&z.attr("font-family",B.fontFamily),B.textOutline&&z.style("text-shadow",B.textOutline)})}wrapLabelLines(t,e,i,r,o){if(!(i>r)||pe(e,r)<=i){t.text(e);return}const s=String(e).split(/\s+/).filter(Boolean),a=[];let c="";for(const u of s){const d=c?`${c} ${u}`:u;c&&pe(d,r)>i?(a.push(c),c=u):c=d}c&&a.push(c);const l=3;if(a.length>l){let u=a.slice(l-1).join(" ");for(;u.length>1&&pe(`${u}…`,r)>i;)u=u.slice(0,-1);a.length=l-1,a.push(`${u.trimEnd()}…`)}t.text(null);const h=r*1.15,f=-((a.length-1)/2)*h;a.forEach((u,d)=>{t.append("tspan").attr("x",o).attr("dy",d===0?f:h).text(u)})}distribute(t,e,i,r,o){const s=t.filter(d=>d.visible);if(s.length<=1)return;const a=-(i-5),l=i-5-a,h=se(o),f=s.map(d=>({target:d.ly-a,size:e*this.estimateLabelLines(d.text,d.availWidth??1/0,h),rank:d.percentage,pos:0,removed:!1,label:d})),u=e*3;this.distributeBoxes(f,l,u);for(const d of f)d.removed?d.label.visible=!1:d.label.ly=a+d.pos+d.size/2}estimateLabelLines(t,e,i){if(!(e>i))return 1;const r=pe(t,i);return r<=e?1:Math.min(3,Math.ceil(r/e))}distributeBoxes(t,e,i){const r=t.filter(s=>!s.removed);if(r.length===0)return;let o=r.reduce((s,a)=>s+a.size,0);if(o>e){const s=[...r].sort((c,l)=>c.rank-l.rank);let a=0;for(;o>e&&a<s.length;)s[a].removed=!0,o-=s[a].size,a++}for(let s=0;s<=t.length;s++){const a=r.filter(l=>!l.removed);if(a.length<=1)break;a.sort((l,h)=>l.target-h.target);for(let l=0;l<a.length;l++)if(a[l].pos=a[l].target,l>0){const h=a[l-1].pos+a[l-1].size;a[l].pos<h&&(a[l].pos=h)}for(let l=a.length-1;l>=0;l--){const h=l===a.length-1?e-a[l].size:a[l+1].pos-a[l].size;a[l].pos>h&&(a[l].pos=Math.max(0,h))}for(let l=0;l<5;l++)for(let h=0;h<a.length;h++){const f=a[h].pos+(a[h].target-a[h].pos)*.3,u=h>0?a[h-1].pos+a[h-1].size:0,d=h<a.length-1?a[h+1].pos-a[h].size:e-a[h].size;a[h].pos=Math.max(u,Math.min(d,f))}let c=null;for(const l of a)Math.abs(l.pos-l.target)<=i||(!c||l.rank<c.rank)&&(c=l);if(!c)break;c.removed=!0}}render3DEffect(t,e,i,r,o){const{colors:s}=this.context,a=t.insert("g",":first-child").attr("class","katucharts-pie-3d");for(const c of e){const l=e.indexOf(c),h=c.data.color||(this.config.colors?this.config.colors[l%this.config.colors.length]:s[l%s.length]),f=c.startAngle-Math.PI/2,u=c.endAngle-Math.PI/2;if(f>0&&u>0||f<0&&u<0&&f<-Math.PI&&u<-Math.PI)continue;const d=Pe().innerRadius(i).outerRadius(r).startAngle(c.startAngle).endAngle(c.endAngle);a.append("path").attr("d",d({})).attr("fill",h).attr("opacity",.7).attr("transform",`translate(0,${o})`)}}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}resolveBorderRadius(t){return t===void 0?3:typeof t=="number"?t:t.radius??3}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class od extends Ht{constructor(t){super(t)}render(){var p,y;const{plotArea:t,colors:e}=this.context,i=this.data.filter(g=>g.y!==null&&g.y!==void 0),r=this.context.animate,o=t.height*.8,s=o/i.length,a=Math.max(...i.map(g=>g.y??0),1),c=t.width/2,l=t.width*.7,h=l*.15,f=(t.height-o)/2,u=((y=(p=this.config.states)==null?void 0:p.inactive)==null?void 0:y.opacity)??.4,d=[];i.forEach((g,m)=>{var T,I,L;const b=(g.y??0)/a,x=m<i.length-1?(i[m+1].y??0)/a:b*.5,v=h+(l-h)*b,k=h+(l-h)*x,M=f+m*s,C=[`M ${c-v/2} ${M}`,`L ${c+v/2} ${M}`,`L ${c+k/2} ${M+s}`,`L ${c-k/2} ${M+s}`,"Z"].join(" "),E=g.color||e[m%e.length],_=this.group.append("path").attr("d",C).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("class","katucharts-funnel-segment").style("cursor",this.config.cursor||"pointer");if(d.push(_),r?_.attr("fill",E).attr("opacity",0).transition().duration(gt).ease(dt).delay(xe(m,0,Bt,i.length)).attr("opacity",1):_.attr("fill",E),(T=this.config.dataLabels)!=null&&T.enabled){const P=this.config.dataLabels,A=((I=P.style)==null?void 0:I.fontSize)||kt,w=P.color||((L=P.style)==null?void 0:L.color)||Fe;let S;P.formatter?S=P.formatter.call({point:g,series:{name:this.config.name},x:g.x,y:g.y}):P.format?S=re(Zt(P.format,{point:g,series:{name:this.config.name}})):S=g.name||String(g.y),this.group.append("text").attr("class","katucharts-funnel-label").attr("x",c+(P.x??0)).attr("y",M+s/2+(P.y??0)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",A).attr("fill",w).style("pointer-events","none").text(S)}this.config.enableMouseTracking!==!1&&_.on("mouseover",P=>{var A,w;_.transition("move").duration(Z).ease(q).attr("transform","translate(0, -3)").style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.2))"),d.forEach(S=>S.interrupt("highlight")),d.forEach(S=>S.attr("opacity",1)),d.forEach((S,$)=>{$!==m&&S.transition("highlight").duration(Z).ease(q).attr("opacity",u)}),this.context.events.emit("point:mouseover",{point:g,index:m,series:this,event:P,plotX:c,plotY:M+s/2}),(w=(A=g.events)==null?void 0:A.mouseOver)==null||w.call(g,P)}).on("mouseout",P=>{var A,w;_.transition("move").duration(Z).ease(q).attr("transform","").style("filter",""),d.forEach(S=>S.interrupt("highlight")),d.forEach(S=>S.transition("highlight").duration(Z).ease(q).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:g,index:m,series:this,event:P}),(w=(A=g.events)==null?void 0:A.mouseOut)==null||w.call(g,P)}).on("click",P=>{var A,w,S,$;this.context.events.emit("point:click",{point:g,index:m,series:this,event:P}),(w=(A=g.events)==null?void 0:A.click)==null||w.call(g,P),($=(S=this.config.events)==null?void 0:S.click)==null||$.call(this,P)})})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class lw extends od{constructor(t){super(t),this.data=[...t._processedData||[]].reverse()}}function Ze(n){for(var t=n.length/6|0,e=new Array(t),i=0;i<t;)e[i]="#"+n.slice(i*6,++i*6);return e}const Vn=n=>Xy(n[n.length-1]);var hw=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(Ze);const uw=Vn(hw);var fw=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(Ze);const dw=Vn(fw);var pw=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(Ze);const sd=Vn(pw);var gw=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(Ze);const ad=Vn(gw);var mw=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(Ze);const yw=Vn(mw);var xw=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(Ze);const bw=Vn(xw);var vw=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(Ze);const ww=Vn(vw);var kw=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(Ze);const Mw=Vn(kw);var Aw=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(Ze);const Sw=Vn(Aw);function ws(n){var t=n.length;return function(e){return n[Math.max(0,Math.min(t-1,Math.floor(e*t)))]}}const _w=ws(Ze("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725"));ws(Ze("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf"));var Cw=ws(Ze("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),Pw=ws(Ze("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function Ew(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Tw extends Ht{constructor(t){super(t),t.showInLegend=!1}render(){var A,w;const{plotArea:t}=this.context,e=this.context.animate,i=this.data,r=this.config.colorAxis||{},o=i.map(S=>S.value??S.z??S.y??0).filter(S=>S!=null),s=r.min??(o.length>0?Math.min(...o):0),a=r.max??(o.length>0?Math.max(...o):1),c=this.config.nullColor??"#e4e4e4",l=((w=(A=this.config.states)==null?void 0:A.inactive)==null?void 0:w.opacity)??.4,h=this.buildColorScale(r,s,a),f=this.config.interpolation===!0,u=this.config.colsize??1,d=this.config.rowsize??1,p=this.config.pointPadding??0,y=this.getUniqueValues("x"),g=this.getUniqueValues("yCategory"),m=y.length>0&&g.length>0,b=m?t.width/y.length:t.width/Math.max(1,Math.ceil((Math.max(...i.map(S=>S.x??0))+u)/u)),x=m?t.height/g.length:t.height/Math.max(1,Math.ceil((Math.max(...i.map(S=>S.y??0))+d)/d)),v=S=>{if(S.color)return S.color;const $=S.value??S.z??S.y;return $==null?c:h($)},k=S=>m?(typeof S.x=="number"?S.x:0)*b:(S.x??0)/u*b,M=S=>m?(typeof S.yCategory=="number"?S.yCategory:typeof S.y=="number"?S.y:0)*x:(S.y??0)/d*x,C=p*b,E=p*x,_=b*u-(this.config.borderWidth??1),T=x*d-(this.config.borderWidth??1),I=Math.max(1,(m?b-1:_)-C*2),L=Math.max(1,(m?x-1:T)-E*2);if(f){this.renderInterpolated(i,t,h,c,k,M,b,x,v),this.renderHeatmapLabels(i,k,M,b,x,v),this.renderColorAxis(h,s,a);return}const P=this.group.selectAll(".katucharts-heatmap-cell").data(i).join("rect").attr("class","katucharts-heatmap-cell").attr("x",S=>k(S)+C).attr("y",S=>M(S)+E).attr("width",I).attr("height",L).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1).attr("rx",Ew(this.config.borderRadius)).style("cursor",this.config.cursor||"pointer");e?P.attr("fill","#fff").transition().duration(600).delay((S,$)=>$*8).attr("fill",S=>v(S)):P.attr("fill",S=>v(S)),this.config.enableMouseTracking!==!1&&P.on("mouseover",(S,$)=>{var N,K,V,G;const R=st(S.currentTarget),F=v($),D=((K=(N=le(F))==null?void 0:N.brighter(.4))==null?void 0:K.toString())||F;R.interrupt("hover").transition("hover").duration(Z).ease(q).attr("fill",D).attr("stroke","#333").attr("stroke-width",2),R.style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.3))"),P.interrupt("highlight"),P.attr("opacity",1),P.filter(H=>H!==$).transition("highlight").duration(Z).ease(q).attr("opacity",l);const z=i.indexOf($),B=$.value??$.z??$.y;this.context.events.emit("point:mouseover",{point:{...$,value:B},index:z,series:this,event:S,plotX:k($)+b/2,plotY:M($)+x/2}),(G=(V=$.events)==null?void 0:V.mouseOver)==null||G.call($,S)}).on("mouseout",(S,$)=>{var D,z;const R=st(S.currentTarget);R.interrupt("hover").transition("hover").duration(Z).ease(q).attr("fill",v($)).attr("stroke",this.config.borderColor||this.autoBorderColor()).attr("stroke-width",this.config.borderWidth??1),R.style("filter",""),P.interrupt("highlight"),P.transition("highlight").duration(Z).ease(q).attr("opacity",1);const F=i.indexOf($);this.context.events.emit("point:mouseout",{point:$,index:F,series:this,event:S}),(z=(D=$.events)==null?void 0:D.mouseOut)==null||z.call($,S)}).on("click",(S,$)=>{var F,D,z,B;const R=i.indexOf($);this.context.events.emit("point:click",{point:$,index:R,series:this,event:S}),(D=(F=$.events)==null?void 0:F.click)==null||D.call($,S),(B=(z=this.config.events)==null?void 0:z.click)==null||B.call(this,S)}),this.renderHeatmapLabels(i,k,M,b,x,v),this.renderColorAxis(h,s,a)}renderInterpolated(t,e,i,r,o,s,a,c,l){const h=new Set,f=new Set;for(const E of t)h.add(E.x??0),f.add(E.yCategory??E.y??0);const u=Array.from(h).sort((E,_)=>E-_),d=Array.from(f).sort((E,_)=>E-_),p=u.length,y=d.length;if(p===0||y===0)return;const g=new Map;for(const E of t){const _=E.value??E.z??E.y,T=u.indexOf(E.x??0),I=d.indexOf(E.yCategory??E.y??0);_!=null&&g.set(`${T},${I}`,_)}const m=Math.round(e.width),b=Math.round(e.height),x=document.createElement("canvas");x.width=m,x.height=b;const v=x.getContext("2d");if(!v)return;const k=v.createImageData(m,b),M=k.data;for(let E=0;E<b;E++)for(let _=0;_<m;_++){const T=_/m*p-.5,I=E/b*y-.5,L=Math.floor(T),P=Math.floor(I),A=T-L,w=I-P,S=(H,j)=>g.get(`${Math.max(0,Math.min(p-1,H))},${Math.max(0,Math.min(y-1,j))}`)??null,$=S(L,P),R=S(L+1,P),F=S(L,P+1),D=S(L+1,P+1),z=[$,R,F,D].filter(H=>H!==null);if(z.length===0){const H=je(r),j=(E*m+_)*4;M[j]=H.r,M[j+1]=H.g,M[j+2]=H.b,M[j+3]=255;continue}const B=H=>H??z[0],N=B($)*(1-A)*(1-w)+B(R)*A*(1-w)+B(F)*(1-A)*w+B(D)*A*w,K=i(N),V=je(K),G=(E*m+_)*4;M[G]=V.r,M[G+1]=V.g,M[G+2]=V.b,M[G+3]=255}v.putImageData(k,0,0);const C=x.toDataURL();this.group.append("image").attr("class","katucharts-heatmap-interpolated").attr("width",e.width).attr("height",e.height).attr("href",C).style("image-rendering","auto")}buildColorScale(t,e,i){const r=t.reversed===!0,o=r?i:e,s=r?e:i;if(t.dataClasses&&t.dataClasses.length>0){const u=t.dataClasses;return d=>{var p;for(const y of u){const g=y.from??-1/0,m=y.to??1/0;if(d>=g&&d<m)return y.color||"#cccccc"}return((p=u[u.length-1])==null?void 0:p.color)||"#cccccc"}}const a=t.type==="logarithmic",c=a?Math.max(o,1e-10):o,l=()=>a?Fo().domain([c,s]).clamp(!0):Me().domain([o,s]).clamp(!0);if(t.stops&&t.stops.length>=2){const u=t.stops,d=l();return p=>{const y=d(a?Math.max(p,1e-10):p);let g=0;for(;g<u.length-1&&!(y<=u[g+1][0]);g++);const[m,b]=u[g],[x,v]=u[Math.min(g+1,u.length-1)],k=x!==m?(y-m)/(x-m):0;return xi(b,v)(k)}}if(t.minColor&&t.maxColor){const u=xi(t.minColor,t.maxColor),d=l();return p=>u(d(a?Math.max(p,1e-10):p))}const h=r?[i,e]:[e,i],f=Gu(sd).domain(h);return u=>f(u)}renderColorAxis(t,e,i){var k,M;const r=this.config.colorAxis||{};if(((k=r.labels)==null?void 0:k.enabled)===!1)return;const{plotArea:o}=this.context,a=(this.context.legendConfig||{}).layout==="vertical",c=C=>this.context.chartWidth!==void 0?(this.context.chartWidth-C)/2-o.x:(o.width-C)/2,l=this.context.plotGroup||this.group;l.selectAll(".katucharts-color-axis").remove();const h=l.append("g").attr("class","katucharts-color-axis"),f=((M=r.labels)==null?void 0:M.style)||{},u=f.fontSize||kt,d=f.color||this.autoLabelColor(),p=i-e,y=p/6,g=Math.pow(10,Math.floor(Math.log10(y))),m=[1,2,2.5,5,10].find(C=>C*g>=y)*g,b=Math.ceil(e/m)*m,x=[];for(let C=b;C<=i+m*.01;C+=m)x.push(Math.round(C*1e6)/1e6);(x.length===0||x[0]-e>m*.5)&&x.unshift(e),i-x[x.length-1]>m*.5&&x.push(i);const v=m>=1?0:m>=.1?1:2;if(r.dataClasses&&r.dataClasses.length>0){const C=r.dataClasses,E=Math.min(o.width*.6,300),_=12,T=c(E),I=o.height+60,L=E/C.length;for(let P=0;P<C.length;P++){const A=C[P];h.append("rect").attr("x",T+P*L).attr("y",I).attr("width",L).attr("height",_).attr("fill",A.color||"#ccc").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",P===0?2:0).attr("ry",P===0?2:0),A.name&&h.append("text").attr("x",T+P*L+L/2).attr("y",I+_+30).attr("font-size",u).attr("fill",d).attr("text-anchor","middle").text(A.name)}return}if(a){const E=Math.min(o.height*.7,200),_=o.width+20,T=(o.height-E)/2,I=h.append("defs"),L=x.length-1,P=E/L;for(let A=0;A<L;A++){const w=L-1-A,S=`katucharts-heatmap-seg-${Math.random().toString(36).slice(2,8)}`,$=I.append("linearGradient").attr("id",S).attr("x1","0%").attr("y1","0%").attr("x2","0%").attr("y2","100%");$.append("stop").attr("offset","0%").attr("stop-color",t(x[w+1])),$.append("stop").attr("offset","100%").attr("stop-color",t(x[w])),h.append("rect").attr("x",_).attr("y",T+A*P).attr("width",12).attr("height",P+.5).attr("fill",`url(#${S})`).attr("stroke","none")}h.append("rect").attr("x",_).attr("y",T).attr("width",12).attr("height",E).attr("fill","none").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);for(let A=0;A<x.length;A++){const w=T+E-(x[A]-e)/p*E;h.append("line").attr("x1",_+12).attr("y1",w).attr("x2",_+12+4).attr("y2",w).attr("stroke","#999").attr("stroke-width",.5),h.append("text").attr("x",_+12+7).attr("y",w+4).attr("font-size",u).attr("fill",d).attr("text-anchor","start").text(x[A].toFixed(v))}}else{const E=Math.min(o.width*.6,300),_=c(E),T=o.height+60,I=h.append("defs"),L=x.length-1,P=E/L;for(let A=0;A<L;A++){const w=`katucharts-heatmap-seg-${Math.random().toString(36).slice(2,8)}`,S=I.append("linearGradient").attr("id",w).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");S.append("stop").attr("offset","0%").attr("stop-color",t(x[A])),S.append("stop").attr("offset","100%").attr("stop-color",t(x[A+1])),h.append("rect").attr("x",_+A*P).attr("y",T).attr("width",P+.5).attr("height",12).attr("fill",`url(#${w})`).attr("stroke","none")}h.append("rect").attr("x",_).attr("y",T).attr("width",E).attr("height",12).attr("fill","none").attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);for(let A=0;A<x.length;A++){const w=_+(x[A]-e)/p*E;h.append("line").attr("x1",w).attr("y1",T+12+8).attr("x2",w).attr("y2",T+12+16).attr("stroke","#999").attr("stroke-width",.5),h.append("text").attr("x",w).attr("y",T+12+30).attr("font-size",u).attr("fill",d).attr("text-anchor",A===0?"start":A===x.length-1?"end":"middle").text(x[A].toFixed(v))}}}renderHeatmapLabels(t,e,i,r,o,s){var f,u;const a=this.config.dataLabels;if(!(a!=null&&a.enabled))return;const c=a.minCellHeight??20;if(o<c)return;const l=((f=a.style)==null?void 0:f.fontSize)||kt,h=a.color||((u=a.style)==null?void 0:u.color)||void 0;this.group.selectAll(".katucharts-heatmap-label").data(t).join("text").attr("class","katucharts-heatmap-label").attr("x",d=>e(d)+r/2+(a.x??0)).attr("y",d=>i(d)+o/2+(a.y??0)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",l).attr("fill",d=>gn(s(d),h)).style("pointer-events","none").text(d=>{const p=d.value??d.z??d.y;return p==null?a.nullFormatter?a.nullFormatter.call({point:d,series:{name:this.config.name}}):a.nullFormat?a.nullFormat:"":a.formatter?a.formatter.call({point:{...d,value:p},series:{name:this.config.name},x:d.x,y:d.y}):a.format?re(Zt(a.format,{point:{...d,value:p},series:{name:this.config.name},x:d.x,y:d.y,value:p})):String(p)})}getUniqueValues(t){const e=new Set;for(const i of this.data){const r=i[t];r!==void 0&&e.add(r)}return Array.from(e).sort((i,r)=>i-r)}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function Lw(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class $w extends Ht{constructor(t){super(t)}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{boxWidth:a,boxOffset:c}=this.computeBoxGeometry(),l=this.config.medianColor||null,h=this.config.medianWidth??2,f=sn(this.config.medianDashStyle),u=this.config.stemWidth??1,d=sn(this.config.stemDashStyle),p=this.config.whiskerWidth??2,y=sn(this.config.whiskerDashStyle),g=this.parseWhiskerLength(this.config.whiskerLength,a),m=sn(this.config.boxDashStyle),b=this.config.lineWidth??1,v=(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt;for(let k=0;k<o.length;k++){const M=o[k],C=t.getPixelForValue(M.x??k)+c+a/2,E=M.low??0,_=M.q1??M.low??0,T=M.median??M.y??0,I=M.q3??M.high??0,L=M.high??0,P=e.getPixelForValue((E+L)/2),A=M.color||this.getPointColor(k,r),w=Hn(this.config.fillColor,this.group,"transparent"),S=this.config.stemColor||A,$=this.config.whiskerColor||A,R=this.group.append("g").attr("class","katucharts-boxplot-point").style("cursor",this.config.cursor||"pointer"),F=R.append("line").attr("x1",C).attr("x2",C).attr("stroke",S).attr("stroke-width",u).attr("stroke-dasharray",d),D=R.append("line").attr("x1",C).attr("x2",C).attr("stroke",S).attr("stroke-width",u).attr("stroke-dasharray",d),z=R.append("rect").attr("x",C-a/2).attr("width",a).attr("fill",w).attr("stroke",A).attr("stroke-width",b).attr("stroke-dasharray",m).attr("rx",Lw(this.config.borderRadius)),B=R.append("line").attr("x1",C-a/2).attr("x2",C+a/2).attr("stroke",l||this.config.lineColor||A).attr("stroke-width",h).attr("stroke-dasharray",f),N=R.append("line").attr("x1",C-g/2).attr("x2",C+g/2).attr("stroke",$).attr("stroke-width",p).attr("stroke-dasharray",y),K=R.append("line").attr("x1",C-g/2).attr("x2",C+g/2).attr("stroke",$).attr("stroke-width",p).attr("stroke-dasharray",y);if(s){const V=xe(k,0,Bt,o.length),G=v;F.attr("y1",P).attr("y2",P).transition().duration(G).ease(dt).delay(V).attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(_)),D.attr("y1",P).attr("y2",P).transition().duration(G).ease(dt).delay(V).attr("y1",e.getPixelForValue(I)).attr("y2",e.getPixelForValue(L)),z.attr("y",P).attr("height",0).transition().duration(G).ease(dt).delay(V).attr("y",e.getPixelForValue(I)).attr("height",Math.abs(e.getPixelForValue(_)-e.getPixelForValue(I))),B.attr("y1",P).attr("y2",P).transition().duration(G).ease(dt).delay(V).attr("y1",e.getPixelForValue(T)).attr("y2",e.getPixelForValue(T)),N.attr("y1",P).attr("y2",P).transition().duration(G).ease(dt).delay(V).attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(E)),K.attr("y1",P).attr("y2",P).transition().duration(G).ease(dt).delay(V).attr("y1",e.getPixelForValue(L)).attr("y2",e.getPixelForValue(L))}else F.attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(_)),D.attr("y1",e.getPixelForValue(I)).attr("y2",e.getPixelForValue(L)),z.attr("y",e.getPixelForValue(I)).attr("height",Math.abs(e.getPixelForValue(_)-e.getPixelForValue(I))),B.attr("y1",e.getPixelForValue(T)).attr("y2",e.getPixelForValue(T)),N.attr("y1",e.getPixelForValue(E)).attr("y2",e.getPixelForValue(E)),K.attr("y1",e.getPixelForValue(L)).attr("y2",e.getPixelForValue(L));this.attachBoxPointEvents(R,M,k,C,e.getPixelForValue(T),b)}this.renderDataLabels(o,(k,M)=>t.getPixelForValue(k.x??M)+c+a/2,k=>e.getPixelForValue(k.high??k.y??0)),s&&this.emitAfterAnimate(v+o.length*Bt)}animateUpdate(t){const{xAxis:e,yAxis:i}=this.context,r=this.getColor(),o=this.data,{boxWidth:s,boxOffset:a}=this.computeBoxGeometry(),l=this.group.selectAll(".katucharts-boxplot-point").nodes();if(l.length!==o.length){this.group.selectAll("*").remove(),this.render();return}for(let h=0;h<Math.min(l.length,o.length);h++){const f=o[h],u=l[h],d=e.getPixelForValue(f.x??h)+a+s/2,p=f.low??0,y=f.q1??f.low??0,g=f.median??f.y??0,m=f.q3??f.high??0,b=f.high??0,x=f.color||this.getPointColor(h,r),v=this.config.stemColor||x,k=this.config.whiskerColor||x,M=this.config.medianColor||this.config.lineColor||x,C=Hn(this.config.fillColor,this.group,"transparent"),E=u.querySelectorAll("line"),_=u.querySelector("rect");if(E[0]&&this.group.select(()=>E[0]).attr("stroke",v).transition().duration(t).attr("x1",d).attr("x2",d).attr("y1",i.getPixelForValue(p)).attr("y2",i.getPixelForValue(y)),E[1]&&this.group.select(()=>E[1]).attr("stroke",v).transition().duration(t).attr("x1",d).attr("x2",d).attr("y1",i.getPixelForValue(m)).attr("y2",i.getPixelForValue(b)),_&&this.group.select(()=>_).attr("stroke",x).attr("fill",C).transition().duration(t).attr("x",d-s/2).attr("y",i.getPixelForValue(m)).attr("height",Math.abs(i.getPixelForValue(y)-i.getPixelForValue(m))),E[2]&&this.group.select(()=>E[2]).attr("stroke",M).transition().duration(t).attr("x1",d-s/2).attr("x2",d+s/2).attr("y1",i.getPixelForValue(g)).attr("y2",i.getPixelForValue(g)),E[3]){const T=this.parseWhiskerLength(this.config.whiskerLength,s);this.group.select(()=>E[3]).attr("stroke",k).transition().duration(t).attr("x1",d-T/2).attr("x2",d+T/2).attr("y1",i.getPixelForValue(p)).attr("y2",i.getPixelForValue(p))}if(E[4]){const T=this.parseWhiskerLength(this.config.whiskerLength,s);this.group.select(()=>E[4]).attr("stroke",k).transition().duration(t).attr("x1",d-T/2).attr("x2",d+T/2).attr("y1",i.getPixelForValue(b)).attr("y2",i.getPixelForValue(b))}}this.group.selectAll(".katucharts-data-labels").remove(),this.renderDataLabels(o,(h,f)=>e.getPixelForValue(h.x??f)+a+s/2,h=>i.getPixelForValue(h.high??h.y??0))}computeBoxGeometry(){const{xAxis:t,plotArea:e}=this.context,i=this.data,r=this.config.grouping!==!1&&this.context.totalSeriesOfType||1,o=this.config.grouping!==!1&&this.context.indexInType||0,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1;let c;this.config.pointWidth!==void 0?c=this.config.pointWidth*r*1.5:c=Math.min(200*r,e.width/Math.max(i.length,1));let l;this.config.pointWidth!==void 0?l=this.config.pointWidth:(l=c*(1-s*2)/r*(1-a*2),this.config.maxPointWidth!==void 0&&(l=Math.min(l,this.config.maxPointWidth)),l=Math.min(l,90));const f=-c*(1-s*2)/2+(l+l*a*2)*o+l*a;return{boxWidth:l,boxOffset:f}}getPointColor(t,e){if(this.config.colorByPoint){const i=this.config.colors||this.context.colors;return i[t%i.length]}return e}parseWhiskerLength(t,e){return t===void 0?e*.5:typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?e*(parseFloat(t)/100):parseFloat(t)||e*.5}attachBoxPointEvents(t,e,i,r,o,s){if(this.config.enableMouseTracking===!1)return;const a=()=>this.group.selectAll(".katucharts-boxplot-point");t.on("mouseover",c=>{var h,f,u,d,p;t.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),t.select("rect").interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",s+1),a().filter(function(){return this!==t.node()}).interrupt("hover").transition("hover").duration(Z).ease(q).style("opacity",.4),this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:c,plotX:r,plotY:o}),(f=(h=e.events)==null?void 0:h.mouseOver)==null||f.call(e,c),(p=(d=(u=this.config.point)==null?void 0:u.events)==null?void 0:d.mouseOver)==null||p.call(e,c)}).on("mouseout",c=>{var l,h,f,u,d;t.style("filter",""),t.select("rect").interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",s),a().interrupt("hover").transition("hover").duration(Z).ease(q).style("opacity",null),this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:c}),(h=(l=e.events)==null?void 0:l.mouseOut)==null||h.call(e,c),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.mouseOut)==null||d.call(e,c)}).on("click",c=>{var l,h,f,u,d,p,y;this.context.events.emit("point:click",{point:e,index:i,series:this,event:c}),(h=(l=e.events)==null?void 0:l.click)==null||h.call(e,c),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.click)==null||d.call(e,c),(y=(p=this.config.events)==null?void 0:p.click)==null||y.call(this,c)})}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(let o=0;o<this.data.length;o++){const s=this.data[o],a=s.x??o;t=Math.min(t,a),e=Math.max(e,a),i=Math.min(i,s.low??s.y??0),r=Math.max(r,s.high??s.y??0)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function cd(){St.registerType("line",Qf),St.registerType("spline",tw),St.registerType("area",ed),St.registerType("areaspline",iw),St.registerType("column",Dc),St.registerType("bar",sw),St.registerType("scatter",aw),St.registerType("bubble",cw),St.registerType("pie",rd),St.registerType("donut",rd),St.registerType("heatmap",Tw),St.registerType("boxplot",$w)}function ld(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Iw extends Ht{constructor(t){super(t),this.processed=[]}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.getColor(),o=this.data,s=this.context.animate,{barWidth:a,barOffset:c}=this.computeBarGeometry();this.processed=this.processWaterfallData(o);const l=this.group.selectAll(".katucharts-waterfall-bar").data(this.processed).join("rect").attr("class","katucharts-waterfall-bar").attr("x",d=>t.getPixelForValue(d.x??0)+c).attr("width",a).attr("rx",ld(this.config.borderRadius)).attr("fill",(d,p)=>this.getBarColor(d,p,r)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).style("cursor",this.config.cursor||"pointer"),h=e.getPixelForValue(0),u=(typeof this.config.animation=="object"?this.config.animation:{}).duration??gt;s?l.attr("y",h).attr("height",0).transition().duration(u).ease(dt).delay((d,p)=>xe(p,0,Bt,this.processed.length)).attr("y",d=>Math.min(e.getPixelForValue(d._start),e.getPixelForValue(d._end))).attr("height",d=>Math.max(Math.abs(e.getPixelForValue(d._start)-e.getPixelForValue(d._end)),this.config.minPointLength??0)):l.attr("y",d=>Math.min(e.getPixelForValue(d._start),e.getPixelForValue(d._end))).attr("height",d=>Math.max(Math.abs(e.getPixelForValue(d._start)-e.getPixelForValue(d._end)),this.config.minPointLength??0)),this.attachBarEvents(l),this.renderConnectors(a,c,!!s),this.renderDataLabels(this.processed,d=>t.getPixelForValue(d.x??0)+c+a/2,d=>e.getPixelForValue(d._end)),s&&this.emitAfterAnimate(u+o.length*Bt)}animateUpdate(t){const{xAxis:e,yAxis:i}=this.context,r=this.getColor(),{barWidth:o,barOffset:s}=this.computeBarGeometry();this.processed=this.processWaterfallData(this.data);const a=this.group.selectAll(".katucharts-waterfall-bar").data(this.processed);a.exit().transition().duration(t).attr("opacity",0).remove(),a.enter().append("rect").attr("class","katucharts-waterfall-bar").attr("rx",ld(this.config.borderRadius)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).attr("y",i.getPixelForValue(0)).attr("height",0).merge(a).transition().duration(t).attr("x",l=>e.getPixelForValue(l.x??0)+s).attr("width",o).attr("fill",(l,h)=>this.getBarColor(l,h,r)).attr("y",l=>Math.min(i.getPixelForValue(l._start),i.getPixelForValue(l._end))).attr("height",l=>Math.max(Math.abs(i.getPixelForValue(l._start)-i.getPixelForValue(l._end)),this.config.minPointLength??0)),this.group.selectAll(".katucharts-waterfall-connector").remove(),this.group.selectAll(".katucharts-data-labels").remove(),this.renderConnectors(o,s,!1),this.attachBarEvents(this.group.selectAll(".katucharts-waterfall-bar")),this.renderDataLabels(this.processed,l=>e.getPixelForValue(l.x??0)+s+o/2,l=>i.getPixelForValue(l._end))}processWaterfallData(t){let e=0,i=0;return t.map((r,o)=>{const s=!!r.isSum,a=!!r.isIntermediateSum,c=s||a,l=r.y??0;let h,f;return s?(h=0,f=e):a?(h=i,f=e,i=e):(h=e,f=e+l,e+=l),{...r,_start:h,_end:f,_isTotal:c,_isIntermediate:a}})}getBarColor(t,e,i){if(t.color)return t.color;if(this.config.colorByPoint){const o=this.config.colors||this.context.colors;return o[e%o.length]}return t._isIntermediate?this.config.intermediateSumColor||this.config.sumColor||"#434348":t._isTotal?this.config.sumColor||"#434348":(t.y??0)>=0?this.config.upColor||i:this.config.negativeColor||"#f15c80"}computeBarGeometry(){const{xAxis:t,plotArea:e}=this.context,i=this.data,r=this.config.grouping!==!1&&this.context.totalSeriesOfType||1,o=this.config.grouping!==!1&&this.context.indexInType||0,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1;let c;this.config.pointWidth!==void 0?c=this.config.pointWidth*r*1.5:c=e.width/Math.max(i.length,1);let l;this.config.pointWidth!==void 0?l=this.config.pointWidth:l=c*(1-s*2)/r*(1-a*2),this.config.maxPointWidth!==void 0&&(l=Math.min(l,this.config.maxPointWidth));const f=-c*(1-s*2)/2+(l+l*a*2)*o+l*a;return{barWidth:l,barOffset:f}}renderConnectors(t,e,i){const{xAxis:r,yAxis:o}=this.context,s=this.config.lineColor||"#999",a=this.config.lineWidth??1,c=sn(this.config.dashStyle||"Dot"),l=this.group.selectAll(".katucharts-waterfall-connector").data(this.processed.slice(0,-1)).join("line").attr("class","katucharts-waterfall-connector").attr("x1",h=>r.getPixelForValue(h.x??0)+e+t).attr("x2",(h,f)=>r.getPixelForValue(this.processed[f+1].x??0)+e).attr("y1",h=>o.getPixelForValue(h._end)).attr("y2",h=>o.getPixelForValue(h._end)).attr("stroke",s).attr("stroke-width",a).attr("stroke-dasharray",c);i&&l.attr("opacity",0).transition().duration(gt).ease(dt).delay((h,f)=>gt+f*Bt).attr("opacity",1)}attachBarEvents(t){if(this.config.enableMouseTracking===!1)return;const{xAxis:e,yAxis:i}=this.context,r=this.processed;t.style("cursor",this.config.cursor||"pointer").on("mouseover",(o,s)=>{var h,f,u,d,p;const a=o.currentTarget,c=a.getAttribute("fill")||"";a.setAttribute("data-orig-fill",c),a.style.filter="drop-shadow(0 2px 4px rgba(0,0,0,0.25))",st(a).interrupt("hover").transition("hover").duration(Z).ease(q).style("fill",Kf(c,.15));const l=r.indexOf(s);this.context.events.emit("point:mouseover",{point:s,index:l,series:this,event:o,plotX:e.getPixelForValue(s.x??0),plotY:i.getPixelForValue(s._end)}),(f=(h=s.events)==null?void 0:h.mouseOver)==null||f.call(s,o),(p=(d=(u=this.config.point)==null?void 0:u.events)==null?void 0:d.mouseOver)==null||p.call(s,o)}).on("mouseout",(o,s)=>{var l,h,f,u,d;const a=o.currentTarget;a.style.filter="",st(a).interrupt("hover").transition("hover").duration(Z).ease(q).style("fill",null);const c=r.indexOf(s);this.context.events.emit("point:mouseout",{point:s,index:c,series:this,event:o}),(h=(l=s.events)==null?void 0:l.mouseOut)==null||h.call(s,o),(d=(u=(f=this.config.point)==null?void 0:f.events)==null?void 0:u.mouseOut)==null||d.call(s,o)}).on("click",(o,s)=>{var c,l,h,f,u,d,p;const a=r.indexOf(s);this.context.events.emit("point:click",{point:s,index:a,series:this,event:o}),(l=(c=s.events)==null?void 0:c.click)==null||l.call(s,o),(u=(f=(h=this.config.point)==null?void 0:h.events)==null?void 0:f.click)==null||u.call(s,o),(p=(d=this.config.events)==null?void 0:d.click)==null||p.call(this,o),this.handlePointSelect(st(o.currentTarget),s,a,o)})}getDataExtents(){let t=1/0,e=-1/0,i=0,r=0,o=0;for(let s=0;s<this.data.length;s++){const a=this.data[s],c=a.x??s;t=Math.min(t,c),e=Math.max(e,c);const l=a.isSum||a.isIntermediateSum,h=a.y??0;l||(o+=h),i=Math.min(i,l?0:Math.min(o-h,o),0),r=Math.max(r,o)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function Fw(n,t){return n.parent===t.parent?1:2}function Rw(n){return n.reduce(Dw,0)/n.length}function Dw(n,t){return n+t.x}function zw(n){return 1+n.reduce(Bw,0)}function Bw(n,t){return Math.max(n,t.y)}function Ow(n){for(var t;t=n.children;)n=t[0];return n}function Nw(n){for(var t;t=n.children;)n=t[t.length-1];return n}function Ww(){var n=Fw,t=1,e=1,i=!1;function r(o){var s,a=0;o.eachAfter(function(u){var d=u.children;d?(u.x=Rw(d),u.y=zw(d)):(u.x=s?a+=n(u,s):0,u.y=0,s=u)});var c=Ow(o),l=Nw(o),h=c.x-n(c,l)/2,f=l.x+n(l,c)/2;return o.eachAfter(i?function(u){u.x=(u.x-o.x)*t,u.y=(o.y-u.y)*e}:function(u){u.x=(u.x-h)/(f-h)*t,u.y=(1-(o.y?u.y/o.y:1))*e})}return r.separation=function(o){return arguments.length?(n=o,r):n},r.size=function(o){return arguments.length?(i=!1,t=+o[0],e=+o[1],r):i?null:[t,e]},r.nodeSize=function(o){return arguments.length?(i=!0,t=+o[0],e=+o[1],r):i?[t,e]:null},r}function Hw(n){var t=0,e=n.children,i=e&&e.length;if(!i)t=1;else for(;--i>=0;)t+=e[i].value;n.value=t}function Vw(){return this.eachAfter(Hw)}function Gw(n,t){let e=-1;for(const i of this)n.call(t,i,++e,this);return this}function Yw(n,t){for(var e=this,i=[e],r,o,s=-1;e=i.pop();)if(n.call(t,e,++s,this),r=e.children)for(o=r.length-1;o>=0;--o)i.push(r[o]);return this}function Xw(n,t){for(var e=this,i=[e],r=[],o,s,a,c=-1;e=i.pop();)if(r.push(e),o=e.children)for(s=0,a=o.length;s<a;++s)i.push(o[s]);for(;e=r.pop();)n.call(t,e,++c,this);return this}function Uw(n,t){let e=-1;for(const i of this)if(n.call(t,i,++e,this))return i}function jw(n){return this.eachAfter(function(t){for(var e=+n(t.data)||0,i=t.children,r=i&&i.length;--r>=0;)e+=i[r].value;t.value=e})}function qw(n){return this.eachBefore(function(t){t.children&&t.children.sort(n)})}function Zw(n){for(var t=this,e=Kw(t,n),i=[t];t!==e;)t=t.parent,i.push(t);for(var r=i.length;n!==e;)i.splice(r,0,n),n=n.parent;return i}function Kw(n,t){if(n===t)return n;var e=n.ancestors(),i=t.ancestors(),r=null;for(n=e.pop(),t=i.pop();n===t;)r=n,n=e.pop(),t=i.pop();return r}function Jw(){for(var n=this,t=[n];n=n.parent;)t.push(n);return t}function Qw(){return Array.from(this)}function tk(){var n=[];return this.eachBefore(function(t){t.children||n.push(t)}),n}function ek(){var n=this,t=[];return n.each(function(e){e!==n&&t.push({source:e.parent,target:e})}),t}function*nk(){var n=this,t,e=[n],i,r,o;do for(t=e.reverse(),e=[];n=t.pop();)if(yield n,i=n.children)for(r=0,o=i.length;r<o;++r)e.push(i[r]);while(e.length)}function qi(n,t){n instanceof Map?(n=[void 0,n],t===void 0&&(t=ok)):t===void 0&&(t=rk);for(var e=new Zi(n),i,r=[e],o,s,a,c;i=r.pop();)if((s=t(i.data))&&(c=(s=Array.from(s)).length))for(i.children=s,a=c-1;a>=0;--a)r.push(o=s[a]=new Zi(s[a])),o.parent=i,o.depth=i.depth+1;return e.eachBefore(hd)}function ik(){return qi(this).eachBefore(sk)}function rk(n){return n.children}function ok(n){return Array.isArray(n)?n[1]:null}function sk(n){n.data.value!==void 0&&(n.value=n.data.value),n.data=n.data.data}function hd(n){var t=0;do n.height=t;while((n=n.parent)&&n.height<++t)}function Zi(n){this.data=n,this.depth=this.height=0,this.parent=null}Zi.prototype=qi.prototype={constructor:Zi,count:Vw,each:Gw,eachAfter:Xw,eachBefore:Yw,find:Uw,sum:jw,sort:qw,path:Zw,ancestors:Jw,descendants:Qw,leaves:tk,links:ek,copy:ik,[Symbol.iterator]:nk};function zc(n){return n==null?null:ud(n)}function ud(n){if(typeof n!="function")throw new Error;return n}function Ir(){return 0}function Fr(n){return function(){return n}}function fd(n){n.x0=Math.round(n.x0),n.y0=Math.round(n.y0),n.x1=Math.round(n.x1),n.y1=Math.round(n.y1)}function ks(n,t,e,i,r){for(var o=n.children,s,a=-1,c=o.length,l=n.value&&(i-t)/n.value;++a<c;)s=o[a],s.y0=e,s.y1=r,s.x0=t,s.x1=t+=s.value*l}function dd(){var n=1,t=1,e=0,i=!1;function r(s){var a=s.height+1;return s.x0=s.y0=e,s.x1=n,s.y1=t/a,s.eachBefore(o(t,a)),i&&s.eachBefore(fd),s}function o(s,a){return function(c){c.children&&ks(c,c.x0,s*(c.depth+1)/a,c.x1,s*(c.depth+2)/a);var l=c.x0,h=c.y0,f=c.x1-e,u=c.y1-e;f<l&&(l=f=(l+f)/2),u<h&&(h=u=(h+u)/2),c.x0=l,c.y0=h,c.x1=f,c.y1=u}}return r.round=function(s){return arguments.length?(i=!!s,r):i},r.size=function(s){return arguments.length?(n=+s[0],t=+s[1],r):[n,t]},r.padding=function(s){return arguments.length?(e=+s,r):e},r}var ak={depth:-1},pd={},Bc={};function ck(n){return n.id}function lk(n){return n.parentId}function Oc(){var n=ck,t=lk,e;function i(r){var o=Array.from(r),s=n,a=t,c,l,h,f,u,d,p,y,g=new Map;if(e!=null){const m=o.map((v,k)=>hk(e(v,k,r))),b=m.map(gd),x=new Set(m).add("");for(const v of b)x.has(v)||(x.add(v),m.push(v),b.push(gd(v)),o.push(Bc));s=(v,k)=>m[k],a=(v,k)=>b[k]}for(h=0,c=o.length;h<c;++h)l=o[h],d=o[h]=new Zi(l),(p=s(l,h,r))!=null&&(p+="")&&(y=d.id=p,g.set(y,g.has(y)?pd:d)),(p=a(l,h,r))!=null&&(p+="")&&(d.parent=p);for(h=0;h<c;++h)if(d=o[h],p=d.parent){if(u=g.get(p),!u)throw new Error("missing: "+p);if(u===pd)throw new Error("ambiguous: "+p);u.children?u.children.push(d):u.children=[d],d.parent=u}else{if(f)throw new Error("multiple roots");f=d}if(!f)throw new Error("no root");if(e!=null){for(;f.data===Bc&&f.children.length===1;)f=f.children[0],--c;for(let m=o.length-1;m>=0&&(d=o[m],d.data===Bc);--m)d.data=null}if(f.parent=ak,f.eachBefore(function(m){m.depth=m.parent.depth+1,--c}).eachBefore(hd),f.parent=null,c>0)throw new Error("cycle");return f}return i.id=function(r){return arguments.length?(n=zc(r),i):n},i.parentId=function(r){return arguments.length?(t=zc(r),i):t},i.path=function(r){return arguments.length?(e=zc(r),i):e},i}function hk(n){n=`${n}`;let t=n.length;return Nc(n,t-1)&&!Nc(n,t-2)&&(n=n.slice(0,-1)),n[0]==="/"?n:`/${n}`}function gd(n){let t=n.length;if(t<2)return"";for(;--t>1&&!Nc(n,t););return n.slice(0,t)}function Nc(n,t){if(n[t]==="/"){let e=0;for(;t>0&&n[--t]==="\\";)++e;if(!(e&1))return!0}return!1}function uk(n,t){return n.parent===t.parent?1:2}function Wc(n){var t=n.children;return t?t[0]:n.t}function Hc(n){var t=n.children;return t?t[t.length-1]:n.t}function fk(n,t,e){var i=e/(t.i-n.i);t.c-=i,t.s+=e,n.c+=i,t.z+=e,t.m+=e}function dk(n){for(var t=0,e=0,i=n.children,r=i.length,o;--r>=0;)o=i[r],o.z+=t,o.m+=t,t+=o.s+(e+=o.c)}function pk(n,t,e){return n.a.parent===t.parent?n.a:e}function Ms(n,t){this._=n,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}Ms.prototype=Object.create(Zi.prototype);function gk(n){for(var t=new Ms(n,0),e,i=[t],r,o,s,a;e=i.pop();)if(o=e._.children)for(e.children=new Array(a=o.length),s=a-1;s>=0;--s)i.push(r=e.children[s]=new Ms(o[s],s)),r.parent=e;return(t.parent=new Ms(null,0)).children=[t],t}function mk(){var n=uk,t=1,e=1,i=null;function r(l){var h=gk(l);if(h.eachAfter(o),h.parent.m=-h.z,h.eachBefore(s),i)l.eachBefore(c);else{var f=l,u=l,d=l;l.eachBefore(function(b){b.x<f.x&&(f=b),b.x>u.x&&(u=b),b.depth>d.depth&&(d=b)});var p=f===u?1:n(f,u)/2,y=p-f.x,g=t/(u.x+p+y),m=e/(d.depth||1);l.eachBefore(function(b){b.x=(b.x+y)*g,b.y=b.depth*m})}return l}function o(l){var h=l.children,f=l.parent.children,u=l.i?f[l.i-1]:null;if(h){dk(l);var d=(h[0].z+h[h.length-1].z)/2;u?(l.z=u.z+n(l._,u._),l.m=l.z-d):l.z=d}else u&&(l.z=u.z+n(l._,u._));l.parent.A=a(l,u,l.parent.A||f[0])}function s(l){l._.x=l.z+l.parent.m,l.m+=l.parent.m}function a(l,h,f){if(h){for(var u=l,d=l,p=h,y=u.parent.children[0],g=u.m,m=d.m,b=p.m,x=y.m,v;p=Hc(p),u=Wc(u),p&&u;)y=Wc(y),d=Hc(d),d.a=l,v=p.z+b-u.z-g+n(p._,u._),v>0&&(fk(pk(p,l,f),l,v),g+=v,m+=v),b+=p.m,g+=u.m,x+=y.m,m+=d.m;p&&!Hc(d)&&(d.t=p,d.m+=b-m),u&&!Wc(y)&&(y.t=u,y.m+=g-x,f=l)}return f}function c(l){l.x*=t,l.y=l.depth*e}return r.separation=function(l){return arguments.length?(n=l,r):n},r.size=function(l){return arguments.length?(i=!1,t=+l[0],e=+l[1],r):i?null:[t,e]},r.nodeSize=function(l){return arguments.length?(i=!0,t=+l[0],e=+l[1],r):i?[t,e]:null},r}function Rr(n,t,e,i,r){for(var o=n.children,s,a=-1,c=o.length,l=n.value&&(r-e)/n.value;++a<c;)s=o[a],s.x0=t,s.x1=i,s.y0=e,s.y1=e+=s.value*l}var yk=(1+Math.sqrt(5))/2;function xk(n,t,e,i,r,o){for(var s=[],a=t.children,c,l,h=0,f=0,u=a.length,d,p,y=t.value,g,m,b,x,v,k,M;h<u;){d=r-e,p=o-i;do g=a[f++].value;while(!g&&f<u);for(m=b=g,k=Math.max(p/d,d/p)/(y*n),M=g*g*k,v=Math.max(b/M,M/m);f<u;++f){if(g+=l=a[f].value,l<m&&(m=l),l>b&&(b=l),M=g*g*k,x=Math.max(b/M,M/m),x>v){g-=l;break}v=x}s.push(c={value:g,dice:d<p,children:a.slice(h,f)}),c.dice?ks(c,e,i,r,y?i+=p*g/y:o):Rr(c,e,i,y?e+=d*g/y:r,o),y-=g,h=f}return s}const As=function n(t){function e(i,r,o,s,a){xk(t,i,r,o,s,a)}return e.ratio=function(i){return n((i=+i)>1?i:1)},e}(yk);function bk(){var n=As,t=!1,e=1,i=1,r=[0],o=Ir,s=Ir,a=Ir,c=Ir,l=Ir;function h(u){return u.x0=u.y0=0,u.x1=e,u.y1=i,u.eachBefore(f),r=[0],t&&u.eachBefore(fd),u}function f(u){var d=r[u.depth],p=u.x0+d,y=u.y0+d,g=u.x1-d,m=u.y1-d;g<p&&(p=g=(p+g)/2),m<y&&(y=m=(y+m)/2),u.x0=p,u.y0=y,u.x1=g,u.y1=m,u.children&&(d=r[u.depth+1]=o(u)/2,p+=l(u)-d,y+=s(u)-d,g-=a(u)-d,m-=c(u)-d,g<p&&(p=g=(p+g)/2),m<y&&(y=m=(y+m)/2),n(u,p,y,g,m))}return h.round=function(u){return arguments.length?(t=!!u,h):t},h.size=function(u){return arguments.length?(e=+u[0],i=+u[1],h):[e,i]},h.tile=function(u){return arguments.length?(n=ud(u),h):n},h.padding=function(u){return arguments.length?h.paddingInner(u).paddingOuter(u):h.paddingInner()},h.paddingInner=function(u){return arguments.length?(o=typeof u=="function"?u:Fr(+u),h):o},h.paddingOuter=function(u){return arguments.length?h.paddingTop(u).paddingRight(u).paddingBottom(u).paddingLeft(u):h.paddingTop()},h.paddingTop=function(u){return arguments.length?(s=typeof u=="function"?u:Fr(+u),h):s},h.paddingRight=function(u){return arguments.length?(a=typeof u=="function"?u:Fr(+u),h):a},h.paddingBottom=function(u){return arguments.length?(c=typeof u=="function"?u:Fr(+u),h):c},h.paddingLeft=function(u){return arguments.length?(l=typeof u=="function"?u:Fr(+u),h):l},h}function vk(n,t,e,i,r){var o=n.children,s,a=o.length,c,l=new Array(a+1);for(l[0]=c=s=0;s<a;++s)l[s+1]=c+=o[s].value;h(0,a,n.value,t,e,i,r);function h(f,u,d,p,y,g,m){if(f>=u-1){var b=o[f];b.x0=p,b.y0=y,b.x1=g,b.y1=m;return}for(var x=l[f],v=d/2+x,k=f+1,M=u-1;k<M;){var C=k+M>>>1;l[C]<v?k=C+1:M=C}v-l[k-1]<l[k]-v&&f+1<k&&--k;var E=l[k]-x,_=d-E;if(g-p>m-y){var T=d?(p*_+g*E)/d:g;h(f,k,E,p,y,T,m),h(k,u,_,T,y,g,m)}else{var I=d?(y*_+m*E)/d:m;h(f,k,E,p,y,g,I),h(k,u,_,p,I,g,m)}}}function Dr(n,t,e,i,r){(n.depth&1?Rr:ks)(n,t,e,i,r)}function wk(n,t,e){return n?n.split(/<br\s*\/?>/i).map(r=>{const o=[],s=/<b(?:\s+style="([^"]*)")?\s*>([\s\S]*?)<\/b>/gi;let a=0,c;for(;(c=s.exec(r))!==null;){if(c.index>a){const d=re(r.slice(a,c.index));d&&o.push({text:d,fontSize:t,fontWeight:e})}const l=c[1]||"",h=l.match(/font-size\s*:\s*([^;"]+)/i),f=l.match(/font-weight\s*:\s*([^;"]+)/i),u=re(c[2]);u&&o.push({text:u,fontSize:h?h[1].trim():t,fontWeight:f?f[1].trim():"bold"}),a=c.index+c[0].length}if(a<r.length){const l=re(r.slice(a));l&&o.push({text:l,fontSize:t,fontWeight:e})}return o}):[]}function kk(n){return n===void 0?4:typeof n=="number"?n:n.radius??4}class Mk extends Ht{constructor(t){super(t),this.currentRoot=null}render(){var T,I,L;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=this.config.levels||[],s=this.config.colorByPoint!==!1,a=this.config.allowTraversingTree===!0||this.config.allowDrillToNode===!0,c=this.config.interactByLeaf??!a,l=this.config.alternateStartingDirection===!0,h=((I=(T=this.config.states)==null?void 0:T.inactive)==null?void 0:I.opacity)??.4,f=this.buildHierarchy(r),u=a&&this.currentRoot?this.currentRoot:f,d={squarify:As,squarified:As,binary:vk,dice:ks,slice:Rr,sliceDice:Dr,sliceAndDice:Dr,strip:Rr,stripes:Rr},p=this.config.layoutAlgorithm||"squarified",y=d[p]||As,g=this.config.layoutStartingDirection||"vertical",m=this.config.opacity??1,b=l||p==="sliceAndDice"||p==="sliceDice"?Dr:y,x=(P,A)=>{var $,R;const w=(($=P.data)==null?void 0:$.sortIndex)??0,S=((R=A.data)==null?void 0:R.sortIndex)??0;return w!==S?w-S:(A.value||0)-(P.value||0)};u.sort(x),bk().size([t.width,t.height]).tile(b).padding(1)(u);const v=a&&!c&&u.children||u.leaves(),k=P=>o.find(A=>A.level===P),C=(((L=this.config.colorAxis)==null?void 0:L.dataClasses)||[]).map(P=>P.color),E=(P,A)=>{var S,$,R,F,D;if(P.data.color)return P.data.color;const w=k(P.depth);if(w!=null&&w.color){const z=w.colorVariation;if((z==null?void 0:z.key)==="brightness"&&((S=P.parent)!=null&&S.children)){const B=P.parent.children,N=B.indexOf(P),K=B.length,V=K>1?-.5+N/(K-1)*(z.to??.5):0,G=li((($=le(w.color))==null?void 0:$.toString())||w.color);return G.l=Math.max(.1,Math.min(.95,G.l+V*.3)),G.toString()}return w.color}if(C.length>0)return C[A%C.length];if(s){const z=e[A%e.length],B=P.parent?k(P.parent.depth):void 0;if(((R=B==null?void 0:B.colorVariation)==null?void 0:R.key)==="brightness"){const N=((F=P.parent)==null?void 0:F.children)||[],K=N.indexOf(P),V=N.length,G=B.colorVariation.to??.5,H=V>1?K/(V-1)*G:G*.5,j=li(((D=le(z))==null?void 0:D.toString())||z);return j.l=Math.max(.1,Math.min(.95,j.l+H*.3)),j.toString()}return z}return this.getColor()},_=this.group.selectAll(".katucharts-treemap-cell").data(v).join("rect").attr("class","katucharts-treemap-cell").attr("x",P=>P.x0).attr("y",P=>P.y0).attr("width",P=>Math.max(0,P.x1-P.x0)).attr("height",P=>Math.max(0,P.y1-P.y0)).attr("fill",(P,A)=>{const w=E(P,A);return P._color=w,w}).attr("stroke",P=>{const A=k(P.depth);return(A==null?void 0:A.borderColor)||this.config.borderColor||this.autoBorderColor()}).attr("stroke-width",P=>{const A=k(P.depth);return(A==null?void 0:A.borderWidth)??this.config.borderWidth??1}).attr("rx",kk(this.config.borderRadius)).style("cursor",this.config.cursor||"pointer");i?_.attr("opacity",0).transition().duration(gt).ease(dt).delay((P,A)=>xe(A,0,Bt,v.length)).attr("opacity",m):m!==1&&_.attr("opacity",m),this.config.enableMouseTracking!==!1&&_.on("mouseover",(P,A)=>{var D,z,B,N,K,V;const w=st(P.currentTarget),S=w.attr("fill"),$=((z=(D=this.config.states)==null?void 0:D.hover)==null?void 0:z.brightness)??.3,R=((N=(B=le(S))==null?void 0:B.brighter($))==null?void 0:N.toString())||S;w.transition("fill").duration(Z).ease(q).attr("fill",R),w.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.2))"),_.interrupt("highlight"),_.attr("opacity",1),_.filter(G=>G!==A).transition("highlight").duration(Z).ease(q).attr("opacity",h);const F=v.indexOf(A);this.context.events.emit("point:mouseover",{point:A.data,index:F,series:this,event:P,plotX:(A.x0+A.x1)/2,plotY:(A.y0+A.y1)/2}),(V=(K=A.data.events)==null?void 0:K.mouseOver)==null||V.call(A.data,P)}).on("mouseout",(P,A)=>{var R,F;const w=st(P.currentTarget),S=v.indexOf(A),$=E(A,S);w.transition("fill").duration(Z).ease(q).attr("fill",$),w.style("filter",""),_.interrupt("highlight"),_.transition("highlight").duration(Z).ease(q).attr("opacity",1),this.context.events.emit("point:mouseout",{point:A.data,index:S,series:this,event:P}),(F=(R=A.data.events)==null?void 0:R.mouseOut)==null||F.call(A.data,P)}).on("click",(P,A)=>{var S,$,R,F;const w=v.indexOf(A);if(a&&A.children){this.currentRoot=A,this.group.selectAll("*").remove(),this.render();return}this.context.events.emit("point:click",{point:A.data,index:w,series:this,event:P}),($=(S=A.data.events)==null?void 0:S.click)==null||$.call(A.data,P),(F=(R=this.config.events)==null?void 0:R.click)==null||F.call(this,P)}),a&&this.currentRoot&&this.currentRoot!==f&&this.renderBreadcrumbs(t,f),this.renderLabels(v,k)}buildHierarchy(t){if(t.some(i=>i.children&&i.children.length>0)){const i=r=>r.map(o=>{const s={...o,value:o.y??o.value??(o.children?0:1)};return s.children&&(s.children=i(s.children)),s});return qi({children:i(t)}).sum(r=>r.children?0:r.value||0)}return qi({children:t.map(i=>({...i,value:i.y??i.value??1}))}).sum(i=>i.value||0)}renderBreadcrumbs(t,e){const i=this.config.breadcrumbs||{},r=i.position||{},o=r.x??0,s=r.y??-20,a=i.separator??" / ",c=i.style||{},l=c.fontSize||"11px",h=c.color||Fe,f=[];let u=this.currentRoot;for(;u;)f.unshift(u),u=u.parent;const d=this.group.append("g").attr("class","katucharts-treemap-breadcrumbs").attr("transform",`translate(${o},${s})`);let p=0;f.forEach((y,g)=>{var k,M,C;const m=((k=y.data)==null?void 0:k.name)||(g===0?"Root":`Level ${g}`),b=g===f.length-1,x=d.append("text").attr("x",p).attr("y",0).attr("font-size",l).attr("fill",b?"#999":"#2f7ed8").attr("dominant-baseline","middle").style("cursor",b?"default":"pointer").style("text-decoration",b?"none":"underline").text(m);b||x.on("click",()=>{this.currentRoot=y===e?null:y,this.group.selectAll("*").remove(),this.render()});const v=((C=(M=x.node())==null?void 0:M.getComputedTextLength)==null?void 0:C.call(M))||m.length*7;p+=v,b||(d.append("text").attr("x",p).attr("y",0).attr("font-size",l).attr("fill",h).attr("dominant-baseline","middle").style("pointer-events","none").text(a),p+=a.length*5)})}renderLabels(t,e){var u,d,p;const i=this.config.dataLabels||{};if(!(i.enabled!==!1))return;const o=((u=i.style)==null?void 0:u.fontSize)||kt,s=i.color||((d=i.style)==null?void 0:d.color)||void 0,a=((p=i.style)==null?void 0:p.fontWeight)||"normal",c=i.align||"left",l=i.verticalAlign||"top",h=i.x??4,f=i.y??4;this.group.selectAll(".katucharts-treemap-label").remove(),t.forEach((y,g)=>{const m=e(y.depth),b=m==null?void 0:m.dataLabels;if((b==null?void 0:b.enabled)===!1)return;const x=y.x1-y.x0,v=y.y1-y.y0;if(x<30||v<16)return;let k="";if(i.formatter)k=i.formatter.call({point:y.data,series:{name:this.config.name},x:y.data.x,y:y.data.y??y.data.value});else{const P=i.format||i.pointFormat;P?k=Zt(P,{point:y.data,series:{name:this.config.name},x:y.data.x,y:y.data.y??y.data.value}):k=y.data.name||""}const M=wk(k,o,a);let C;c==="right"?C=y.x1-h:c==="center"?C=(y.x0+y.x1)/2:C=y.x0+h;const E=c==="right"?"end":c==="center"?"middle":"start";let _;l==="bottom"?_=y.y1-f:l==="middle"?_=(y.y0+y.y1)/2:_=y.y0+f;const T=this.group.append("text").attr("class","katucharts-treemap-label").attr("x",C).attr("text-anchor",E).attr("fill",gn(y._color,s)).style("pointer-events","none");let I=_;M.forEach((P,A)=>{if(P.length===0)return;const w=P.map($=>se($.fontSize)),S=Math.max(...w)*1.15;I+=S,P.forEach(($,R)=>{const F=T.append("tspan").attr("font-size",$.fontSize).attr("font-weight",$.fontWeight).text($.text);R===0&&F.attr("x",C).attr("y",I)})}),this.context.animate&&T.attr("opacity",0).transition().duration(gt).ease(dt).delay(ei+g*Bt).attr("opacity",1);const L=T.node();if(L)try{const P=L.getBBox();(P.height+f>v||P.width+h>x)&&P.height>v-f&&T.remove()}catch{}})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class Ak extends Ht{constructor(t){super(t),this.currentRoot=null,t.showInLegend=!1}render(){var N,K,V,G,H;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config.levels||[],o=this.config.allowTraversingTree===!0||this.config.allowDrillToNode===!0,s=this.config.slicedOffset??0,a=((K=(N=this.config.states)==null?void 0:N.inactive)==null?void 0:K.opacity)??.4,c=this.config.center||["50%","50%"],l=this.resolvePercent(c[0],t.width),h=this.resolvePercent(c[1],t.height),f=this.config.size,u=Math.min(t.width,t.height),d=f?this.resolvePercent(f,u)/2-5:u/2-5,p=this.config.startAngle??0,y=this.config.endAngle??360,g=p*Math.PI/180,b=y*Math.PI/180-g,x=(V=this.group.node())==null?void 0:V.parentElement;x&&st(x).attr("clip-path",null);const v=this.buildHierarchy(g,b),k=this.config.rootId;let M=v;o&&this.currentRoot?M=this.currentRoot:k&&v.each(j=>{var U;((U=j.data)==null?void 0:U.id)===k&&(M=j)});const C=this.getMaxDepth(M),E=this.config.levelIsConstant!==!1,_=this.computeRingWidths(d,C,r);this.applyCustomRadii(M,_,E),this.assignColors(M,e,r);const T=this.config.borderRadius!==void 0?this.resolveBorderRadius(this.config.borderRadius):0,I=Pe().startAngle(j=>j.x0).endAngle(j=>j.x1).innerRadius(j=>j._y0).outerRadius(j=>j._y1).padAngle(.005).cornerRadius(T),L=this.group.append("g").attr("transform",`translate(${l},${h})`),P=M.descendants(),A=P[0],w=P.filter(j=>j.depth>0),S=A._y1||A.y1,$=A.data.color||this.getColor()||"#ffffff",R=li($),F=R&&!isNaN(R.h)?li(R.h,R.s*.4,.88).toString():$,D=L.append("circle").attr("r",S).attr("fill",F).attr("stroke","none").style("cursor",o?"pointer":"default");if(o&&this.currentRoot&&this.currentRoot!==v&&(L.select("circle").on("click",()=>{var j;this.currentRoot=((j=this.currentRoot)==null?void 0:j.parent)||null,this.group.selectAll("*").remove(),this.render()}),this.renderBreadcrumbs(v)),this.config.enableMouseTracking!==!1){const j=this,U="#f0f0f0";D.on("mouseover",function(X){st(this).transition("fill").duration(Z).ease(q).attr("fill",U),st(this).style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.15))"),j.context.events.emit("point:mouseover",{point:{...A.data,value:A.value,y:A.value??A.data.value},index:-1,series:j,event:X,plotX:l,plotY:h})}).on("mouseout",function(X){st(this).transition("fill").duration(Z).ease(q).attr("fill",F),st(this).style("filter",""),j.context.events.emit("point:mouseout",{point:{...A.data,value:A.value,y:A.value??A.data.value},index:-1,series:j,event:X})})}if(S>15){const j=this.config.name||((G=A.data)==null?void 0:G.name)||"";if(j){const U=((H=this.config.dataLabels)==null?void 0:H.style)||{},X=gn(F,U.color),tt=U.textOutline,O=L.append("text").attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",S>35?"13px":"10px").attr("font-weight","bold").attr("fill",X).style("pointer-events","none").text(j);if(tt){const it=tt.split(/\s+/);O.style("paint-order","stroke fill").attr("stroke",it.length>=2?it.slice(1).join(" "):"white").attr("stroke-width",parseFloat(tt)||0).attr("stroke-linejoin","round")}}}const z=L.selectAll(".katucharts-sunburst-arc").data(w).join("path").attr("class","katucharts-sunburst-arc").attr("fill",j=>j._color).attr("stroke",j=>{const U=r.find(X=>X.level===j.depth);return(U==null?void 0:U.borderColor)||j._color}).attr("stroke-width",j=>{const U=r.find(X=>X.level===j.depth);return U!=null&&U.borderColor?(U==null?void 0:U.borderWidth)??1:.5}).attr("shape-rendering","geometricPrecision").style("cursor","pointer");s>0&&z.each(function(j){if(j.data.sliced){const U=(j.x0+j.x1)/2,X=s*Math.sin(U),tt=-s*Math.cos(U);st(this).attr("transform",`translate(${X},${tt})`)}}),i?z.each(function(j,U){const X=st(this),tt={x0:j.x0,x1:j.x0,_y0:j._y0,_y1:j._y1},O={x0:j.x0,x1:j.x1,_y0:j._y0,_y1:j._y1},it=ue(tt,O);X.transition().duration(gt).ease(dt).delay(Ic+U*Bt).attrTween("d",()=>nt=>I(it(nt)))}):z.attr("d",I);const B=new Set;for(const j of w)j.depth>1&&B.add(j._y0);for(const j of B)L.append("circle").attr("r",j).attr("fill","none").attr("stroke",this.autoBorderColor()).attr("stroke-width",2).style("pointer-events","none");if(this.renderLabels(L,w,r),this.config.enableMouseTracking!==!1){const j=this;z.on("mouseover",function(U,X){var lt,ht,at,W;const tt=st(this),O=((ht=(lt=le(X._color))==null?void 0:lt.brighter(.3))==null?void 0:ht.toString())||X._color;tt.transition("fill").duration(Z).ease(q).attr("fill",O),tt.style("filter","drop-shadow(0 1px 3px rgba(0,0,0,0.2))"),z.interrupt("highlight"),z.attr("opacity",1),z.filter(J=>J!==X&&!j.isAncestorOf(J,X)).transition("highlight").duration(Z).ease(q).attr("opacity",a);const it=w.indexOf(X),nt=I.centroid(X);j.context.events.emit("point:mouseover",{point:{...X.data,value:X.value,y:X.value??X.data.value},index:it,series:j,event:U,plotX:l+nt[0],plotY:h+nt[1]}),(W=(at=X.data.events)==null?void 0:at.mouseOver)==null||W.call(X.data,U)}).on("mouseout",function(U,X){var it,nt;const tt=st(this);tt.transition("fill").duration(Z).ease(q).attr("fill",X._color),tt.style("filter",""),z.interrupt("highlight"),z.transition("highlight").duration(Z).ease(q).attr("opacity",1);const O=w.indexOf(X);j.context.events.emit("point:mouseout",{point:{...X.data,value:X.value,y:X.value??X.data.value},index:O,series:j,event:U}),(nt=(it=X.data.events)==null?void 0:it.mouseOut)==null||nt.call(X.data,U)}).on("click",function(U,X){var O,it,nt,lt;const tt=w.indexOf(X);if(o&&X.children&&X.children.length>0){j.currentRoot=X,dd().size([b,1])(j.currentRoot),g!==0&&j.currentRoot.each(ht=>{ht.x0+=g,ht.x1+=g}),j.group.selectAll("*").remove(),j.render();return}j.context.events.emit("point:click",{point:X.data,index:tt,series:j,event:U}),(it=(O=X.data.events)==null?void 0:O.click)==null||it.call(X.data,U),(lt=(nt=j.config.events)==null?void 0:nt.click)==null||lt.call(j,U)})}}isAncestorOf(t,e){let i=e;for(;i;){if(i===t)return!0;i=i.parent}return!1}buildHierarchy(t=0,e=2*Math.PI){const i=this.data,r=i.length>0&&(i[0].id!==void 0||i[0].parent!==void 0);let o;if(r){const s=i.map(c=>({...c,id:c.id||c.name||String(i.indexOf(c)),parentId:c.parent||null,value:c.y??c.value??void 0}));s.some(c=>!c.parentId||c.parentId==="")?s.forEach(c=>{(!c.parentId||c.parentId==="")&&(c.parentId=null)}):(s.unshift({id:"__root__",parentId:null,name:"Root",value:void 0}),s.forEach(c=>{c.id!=="__root__"&&(!c.parentId||c.parentId==="")&&(c.parentId="__root__")})),o=Oc().id(c=>c.id).parentId(c=>c.parentId)(s),o.sum(c=>c.children?0:c.value??0)}else o=qi({children:this.prepareNestedData(i)}).sum(s=>s.children?0:s.value||0);return dd().size([e,1])(o),t!==0&&o.each(s=>{s.x0+=t,s.x1+=t}),o}prepareNestedData(t){return t.map(e=>{const i={...e,value:e.y??e.value??1};return i.children&&(i.children=this.prepareNestedData(i.children)),i})}getMaxDepth(t){let e=0;return t.each(i=>{i.depth>e&&(e=i.depth)}),e}computeRingWidths(t,e,i){const r=[],o=this.config.levelSize;for(let l=0;l<=e;l++){const h=i.find(f=>f.level===l);h!=null&&h.levelSize?r.push({value:h.levelSize.value,unit:h.levelSize.unit}):o!=null&&o.unit&&(o!=null&&o.value)?r.push({value:o.value,unit:o.unit}):r.push({value:1,unit:"weight"})}let s=t;const a=new Array(e+1).fill(0);for(let l=0;l<=e;l++)r[l].unit==="pixels"&&(a[l]=r[l].value,s-=a[l]);for(let l=0;l<=e;l++)r[l].unit==="percentage"&&(a[l]=r[l].value/100*t,s-=a[l]);let c=0;for(let l=0;l<=e;l++)r[l].unit==="weight"&&(c+=r[l].value);if(c>0&&s>0)for(let l=0;l<=e;l++)r[l].unit==="weight"&&(a[l]=r[l].value/c*s);return a}applyCustomRadii(t,e,i=!0){const r=[0];for(let s=0;s<e.length;s++)r.push(r[s]+e[s]);const o=i?0:t.depth;t.each(s=>{const a=s.depth-o;s._y0=r[a]||0,s._y1=r[a+1]||r[r.length-1]})}assignColors(t,e,i){var c;let r=0;t._color=t.data.color||"transparent";const s=((c=i.find(l=>l.colorByPoint))==null?void 0:c.level)??1,a=l=>{if(l.depth===0)l._color=l.data.color||"transparent";else if(l.data.color)l._color=l.data.color;else if(l.depth===s)l._color=e[r++%e.length];else if(l.depth>s&&l.parent){const h=i.find(d=>d.level===l.depth),f=h==null?void 0:h.colorVariation,u=le(l.parent._color);if(u&&(f==null?void 0:f.key)==="brightness"){const d=l.parent.children||[],p=d.indexOf(l),y=d.length,g=y>1?p/(y-1)*f.to:f.to*.5,m=li(u.toString());m.l=Math.max(.1,Math.min(.95,m.l+g*.3)),l._color=m.toString()}else if(u){const d=l.parent.children||[],p=d.indexOf(l),y=d.length,g=y>1?-.3+p/(y-1)*.6:0;l._color=u.brighter(g).toString()}else l._color=l.parent._color}else l.depth<s&&l.parent&&(l._color=l.parent._color!=="transparent"?l.parent._color:e[r++%e.length]);if(l.children)for(const h of l.children)a(h)};a(t)}renderLabels(t,e,i){var g;const o=this.config.dataLabels,s=(o==null?void 0:o.rotationMode)||"auto",a=(o==null?void 0:o.style)||{},c=a.fontSize||kt,l=a.textOutline,h=o==null?void 0:o.filter,f=m=>{var x,v;const b=i.find(k=>k.level===m.depth);return((v=(x=b==null?void 0:b.dataLabels)==null?void 0:x.style)==null?void 0:v.textOutline)||l},d=((g=i.find(m=>m.colorByPoint))==null?void 0:g.level)??1,p=m=>{let b=m;for(;b.depth>d&&b.parent;)b=b.parent;return b._color},y=m=>{var v,k;const b=i.find(M=>M.level===m.depth),x=((k=(v=b==null?void 0:b.dataLabels)==null?void 0:v.style)==null?void 0:k.color)||a.color;return gn(p(m),x)};t.selectAll(".katucharts-sunburst-label").data(e).join("text").attr("class","katucharts-sunburst-label").attr("transform",m=>{var I;const b=i.find(L=>L.level===m.depth),x=((I=b==null?void 0:b.dataLabels)==null?void 0:I.rotationMode)||s,v=(m.x0+m.x1)/2,k=(m._y0+m._y1)/2,M=v*180/Math.PI-90,C=v<Math.PI/2||v>Math.PI*3/2,E=v>Math.PI;if(x==="parallel")return`rotate(${M}) translate(${k},0) rotate(${C?90:-90})`;if(x==="perpendicular")return`rotate(${M}) translate(${k},0)${E?" rotate(180)":""}`;const _=m._y1*(m.x1-m.x0),T=m._y1-m._y0;return _>T*2?`rotate(${M}) translate(${k},0) rotate(${C?90:-90})`:`rotate(${M}) translate(${k},0)${E?" rotate(180)":""}`}).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",m=>{var x,v;const b=i.find(k=>k.level===m.depth);return((v=(x=b==null?void 0:b.dataLabels)==null?void 0:x.style)==null?void 0:v.fontSize)||c}).attr("font-weight","bold").attr("fill",m=>y(m)).style("paint-order","stroke fill").attr("stroke",m=>{const b=f(m);if(!b)return"none";const x=b.split(/\s+/);return x.length>=2?x.slice(1).join(" "):"white"}).attr("stroke-width",m=>{const b=f(m);return b&&parseFloat(b)||0}).attr("stroke-linejoin","round").style("pointer-events","none").each(function(m){var B,N,K,V,G;const b=st(this);b.selectAll("tspan").remove();const x=i.find(H=>H.level===m.depth);if(((B=x==null?void 0:x.dataLabels)==null?void 0:B.enabled)===!1)return;const v=((N=x==null?void 0:x.dataLabels)==null?void 0:N.filter)||h,k=m._y1*(m.x1-m.x0),M=m._y0*(m.x1-m.x0),C=m._y1-m._y0;if(v){const H=v.property==="outerArcLength"?k:v.property==="innerArcLength"?M:0;if(v.operator===">"&&H<=v.value||v.operator==="<"&&H>=v.value)return}else if(k<16)return;const E=m.data.name||"",_=((K=x==null?void 0:x.dataLabels)==null?void 0:K.rotationMode)||s,T=_==="parallel"||_==="auto"&&k>C*2,I=T?(k+M)/2:C,L=T?C:(k+M)/2,P=parseFloat(((G=(V=x==null?void 0:x.dataLabels)==null?void 0:V.style)==null?void 0:G.fontSize)||c)||11,A=P*.6,w=Math.max(3,Math.floor(I/A)),S=Math.max(1,Math.floor(L/(P*1.2)));if(E.length<=w){b.text(E);return}const $=E.split(/[\s_-]+/),R=[];let F="";for(const H of $){const j=F?F+" "+H:H;if(j.length<=w?F=j:(F&&R.push(F),F=H.length>w?H.substring(0,w-1)+"…":H),R.length>=S)break}if(F&&R.length<S&&R.push(F),R.length===0)return;if(R.length>S&&(R.length=S),R.length===S&&F&&!R[R.length-1].endsWith("…")&&$.slice(R.join(" ").split(/[\s]+/).length).length>0){const j=R[R.length-1];j.length+2>w&&(R[R.length-1]=j.substring(0,w-1)+"…")}const z=-(R.length*P*1.2-P*1.2)/2;R.forEach((H,j)=>{b.append("tspan").attr("x",0).attr("dy",j===0?`${z}px`:`${P*1.2}px`).text(H)})})}renderBreadcrumbs(t){const e=this.config.breadcrumbs||{},r=(e.style||{}).fontSize||"11px",o=e.separator??" / ",s=[];let a=this.currentRoot;for(;a;)s.unshift(a),a=a.parent;const c=this.group.append("g").attr("class","katucharts-sunburst-breadcrumbs").attr("transform","translate(0,-15)");let l=0;s.forEach((h,f)=>{var g,m,b;const u=((g=h.data)==null?void 0:g.name)||(f===0?"Root":`Level ${f}`),d=f===s.length-1,p=c.append("text").attr("x",l).attr("y",0).attr("font-size",r).attr("fill",d?"#999":"#2f7ed8").attr("dominant-baseline","middle").style("cursor",d?"default":"pointer").style("text-decoration",d?"none":"underline").text(u);d||p.on("click",()=>{this.currentRoot=h===t?null:h,this.group.selectAll("*").remove(),this.render()});const y=((b=(m=p.node())==null?void 0:m.getComputedTextLength)==null?void 0:b.call(m))||u.length*7;l+=y,d||(c.append("text").attr("x",l).attr("y",0).attr("font-size",r).attr("fill","#666").attr("dominant-baseline","middle").style("pointer-events","none").text(o),l+=o.length*5)})}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}resolveBorderRadius(t){return t===void 0?3:typeof t=="number"?t:t.radius??3}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class Sk extends Ht{constructor(t){super(t)}render(){var U,X,tt;const{plotArea:t}=this.context,e=this.context.animate,i=t.width/2,r=this.config.pane||{},o=r.startAngle??-90,s=r.endAngle??90,a=o*Math.PI/180,c=s*Math.PI/180,l=Math.abs(s-o)<=180,h=l?t.height*.62:t.height/2,f=l?Math.min(t.width/2,h)-20:Math.min(t.width,t.height)/2-20,u=((U=this.config._yAxis??this.config.yAxis)==null?void 0:U.min)??this.config.min??0,d=((X=this.config._yAxis??this.config.yAxis)==null?void 0:X.max)??this.config.max??100,p=((tt=this.data[0])==null?void 0:tt.y)??0,y=this.config.wrap!==!1,g=this.config.overshoot??0;let m=p;if(y){const O=d-u;O>0&&(m=u+((p-u)%O+O)%O)}const b=g*Math.PI/180;let v=Me().domain([u,d]).range([a,c]).clamp(!y&&g<=0)(m);if(!y&&g>0){const O=a-b,it=c+b;v=Math.max(O,Math.min(it,v))}const k=this.group.append("g").attr("transform",`translate(${i},${h})`);this.renderPaneBackground(k,f,a,c,r);const M=f*.15,C=Pe().innerRadius(f-M).outerRadius(f).startAngle(a).endAngle(c).cornerRadius(M/2);k.append("path").attr("d",C({})).attr("fill","#ddd"),this.renderPlotBands(k,f,a,c,u,d,M),this.renderTickMarks(k,f,a,c,u,d,M);const E=this.config.dial||{},_=this.config.pivot||{},T=E.backgroundColor||"#333",I=E.borderColor||"none",L=E.borderWidth??0,P=E.baseWidth??8,A=E.topWidth??1,w=this.resolvePercent(E.radius??"80%",f),S=this.resolvePercent(E.rearLength??"15%",f),$=v-Math.PI/2,R=w*Math.cos($),F=w*Math.sin($),D=-S*Math.cos($),z=-S*Math.sin($),B=$+Math.PI/2,N=P/2,K=A/2,V=[`M${D+N*Math.cos(B)},${z+N*Math.sin(B)}`,`L${R+K*Math.cos(B)},${F+K*Math.sin(B)}`,`L${R-K*Math.cos(B)},${F-K*Math.sin(B)}`,`L${D-N*Math.cos(B)},${z-N*Math.sin(B)}`,"Z"].join(" "),G=k.append("path").attr("fill",T).attr("stroke",I).attr("stroke-width",L).style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.3))").style("cursor","pointer");if(e){const O=this.buildNeedlePath(a,w,S,P,A);G.attr("d",O).transition().duration(gt).ease(dt).attrTween("d",()=>{const it=ue(a,v);return nt=>this.buildNeedlePath(it(nt),w,S,P,A)})}else G.attr("d",V);if(this.config.enableMouseTracking!==!1){const O=L;G.on("mouseover",it=>{var nt,lt,ht;G.interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",O+2),G.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.4))"),this.context.events.emit("point:mouseover",{point:this.data[0],index:0,series:this,event:it,plotX:i,plotY:h}),(ht=(lt=(nt=this.data[0])==null?void 0:nt.events)==null?void 0:lt.mouseOver)==null||ht.call(this.data[0],it)}).on("mouseout",it=>{var nt,lt,ht;G.interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",O),G.style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.3))"),this.context.events.emit("point:mouseout",{point:this.data[0],index:0,series:this,event:it}),(ht=(lt=(nt=this.data[0])==null?void 0:nt.events)==null?void 0:lt.mouseOut)==null||ht.call(this.data[0],it)}).on("click",it=>{var nt,lt,ht,at,W;this.context.events.emit("point:click",{point:this.data[0],index:0,series:this,event:it}),(ht=(lt=(nt=this.data[0])==null?void 0:nt.events)==null?void 0:lt.click)==null||ht.call(this.data[0],it),(W=(at=this.config.events)==null?void 0:at.click)==null||W.call(this,it)})}const H=_.radius??10,j=_.borderWidth??2;k.append("circle").attr("r",H).attr("fill",_.backgroundColor||"#666").attr("stroke",_.borderColor||"#fff").attr("stroke-width",j).style("filter","drop-shadow(0 1px 2px rgba(0,0,0,0.2))"),this.renderValueLabel(k,f,p),e&&this.emitAfterAnimate(gt+100)}buildNeedlePath(t,e,i,r,o){const s=t-Math.PI/2,a=e*Math.cos(s),c=e*Math.sin(s),l=-i*Math.cos(s),h=-i*Math.sin(s),f=s+Math.PI/2,u=r/2,d=o/2;return[`M${l+u*Math.cos(f)},${h+u*Math.sin(f)}`,`L${a+d*Math.cos(f)},${c+d*Math.sin(f)}`,`L${a-d*Math.cos(f)},${c-d*Math.sin(f)}`,`L${l-u*Math.cos(f)},${h-u*Math.sin(f)}`,"Z"].join(" ")}renderPaneBackground(t,e,i,r,o){const s=o.background?Array.isArray(o.background)?o.background:[o.background]:[];for(const a of s){const c=this.resolvePercent(a.outerRadius??"100%",e),l=this.resolvePercent(a.innerRadius??"0%",e),h=Pe().innerRadius(l).outerRadius(c).startAngle(i).endAngle(r);t.append("path").attr("d",h({})).attr("fill",a.backgroundColor||"#f2f2f2").attr("stroke",a.borderColor||"#cccccc").attr("stroke-width",a.borderWidth??0)}}renderPlotBands(t,e,i,r,o,s,a){var f;const c=((f=this.config._yAxis??this.config.yAxis)==null?void 0:f.plotBands)||[];if(c.length===0)return;const l=a??e*.15,h=Me().domain([o,s]).range([i,r]);for(const u of c){if(u.from===void 0||u.to===void 0)continue;const d=Pe().innerRadius(e-l).outerRadius(e).startAngle(h(u.from)).endAngle(h(u.to)).cornerRadius(0);t.append("path").attr("d",d({})).attr("fill",u.color||"#e0e0e0").attr("stroke",u.borderColor||"none").attr("stroke-width",u.borderWidth??0)}}renderTickMarks(t,e,i,r,o,s,a){var x,v;const c=(this.config._yAxis??this.config.yAxis)||{},l=c.tickPositions||this.generateTicks(o,s,5),h=c.tickLength??15,f=c.tickWidth??2,u=((x=c.labels)==null?void 0:x.enabled)!==!1,d=((v=c.labels)==null?void 0:v.style)||{},p=d.fontSize||kt,y=d.color||this.autoLabelColor(),g=a??e*.15,m=Me().domain([o,s]).range([i,r]),b=c.minorTickInterval?Math.round((s-o)/c.minorTickInterval):0;if(b>0&&c.minorTickInterval)for(let k=0;k<=b;k++){const M=o+k*c.minorTickInterval;if(M>s)break;const C=m(M)-Math.PI/2,E=e-g+2,_=E-6;t.append("line").attr("x1",_*Math.cos(C)).attr("y1",_*Math.sin(C)).attr("x2",E*Math.cos(C)).attr("y2",E*Math.sin(C)).attr("stroke","#999").attr("stroke-width",1)}for(const k of l){const M=m(k)-Math.PI/2,C=e-g+2,E=C-h;if(t.append("line").attr("x1",E*Math.cos(M)).attr("y1",E*Math.sin(M)).attr("x2",C*Math.cos(M)).attr("y2",C*Math.sin(M)).attr("stroke","#333").attr("stroke-width",f),u){const _=E-10;t.append("text").attr("x",_*Math.cos(M)).attr("y",_*Math.sin(M)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",p).attr("font-weight","600").attr("fill",y).style("pointer-events","none").text(String(k))}}}generateTicks(t,e,i){const r=(e-t)/i,o=[];for(let s=0;s<=i;s++)o.push(Math.round((t+r*s)*100)/100);return o}renderValueLabel(t,e,i){var l,h,f,u;const r=this.config.dataLabels||{};if(!(r.enabled!==!1))return;const s=((l=r.style)==null?void 0:l.fontSize)||kt,a=r.color||((h=r.style)==null?void 0:h.color)||this.autoLabelColor();let c;r.formatter?c=r.formatter.call({point:this.data[0],series:{name:this.config.name},x:(f=this.data[0])==null?void 0:f.x,y:i}):r.format?c=re(Zt(r.format,{point:this.data[0],series:{name:this.config.name},x:(u=this.data[0])==null?void 0:u.x,y:i})):c=i.toString(),t.append("text").attr("y",e*.25+(r.y??0)).attr("x",r.x??0).attr("text-anchor","middle").attr("font-size",s).attr("font-weight","bold").attr("fill",a).text(c)}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class _k extends Ht{constructor(t){super(t)}render(){var k,M,C,E;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=Math.min(t.width,t.height)/2-10,o=t.width/2,s=t.height/2,a=((k=this.config._yAxis??this.config.yAxis)==null?void 0:k.min)??this.config.min??0,c=((M=this.config._yAxis??this.config.yAxis)==null?void 0:M.max)??this.config.max??100,l=this.data.length>1,h=this.config.pane||{},f=(h.startAngle??-135)*Math.PI/180,u=(h.endAngle??135)*Math.PI/180,d=this.config.overshoot??0,p=d*Math.PI/180,y=this.group.append("g").attr("transform",`translate(${o},${s})`),g=this.config.innerRadius??.6,m=this.config.radius??1,b=this.config.rounded??5,x=this.config.linecap||"round",v=((C=this.config._yAxis??this.config.yAxis)==null?void 0:C.stops)||[];if(l){const _=r/(this.data.length+.5),T=_*.1;this.renderPaneBackground(y,r,0,f,u,h),this.data.forEach((I,L)=>{const P=I.radius?this.resolveRadiusValue(I.radius,r):r-L*_,A=I.innerRadius?this.resolveRadiusValue(I.innerRadius,r):P-_+T,w=I.color||e[L%e.length],S=this.config.color;this.config.color=w,this.renderSingleArc(y,I,L,A,P,r,f,u,a,c,d,p,b,x,v,o,s,i),this.config.color=S})}else{const _=this.resolveRadiusValue(g,r),T=this.resolveRadiusValue(m,r);this.renderPaneBackground(y,T,_,f,u,h),this.renderPlotBands(y,T,_,f,u,a,c),this.renderSingleArc(y,this.data[0],0,_,T,r,f,u,a,c,d,p,b,x,v,o,s,i)}this.renderTickMarks(y,r,f,u,a,c),l||this.renderValueLabel(y,((E=this.data[0])==null?void 0:E.y)??0),i&&this.emitAfterAnimate(gt+100)}renderSingleArc(t,e,i,r,o,s,a,c,l,h,f,u,d,p,y,g,m,b){const x=(e==null?void 0:e.y)??0,v=Math.max(0,Math.min(1,(x-l)/(h-l)));let k=a+(c-a)*v;if(f>0&&x>h){const P=(x-h)/(h-l);k=c+Math.min(u,(c-a)*P)}const M=p==="round",C=Pe().innerRadius(r).outerRadius(o).startAngle(a).endAngle(c).cornerRadius(M?(o-r)/2:d);t.append("path").attr("d",C({})).attr("fill","#e0e0e0");const E=M?(o-r)/2:d,_=Pe().innerRadius(r).outerRadius(o).cornerRadius(E),T=Pe().innerRadius(r).outerRadius(o+5).cornerRadius(E),I=this.resolveArcColor(v,y,e),L=t.append("path").attr("fill",I).style("cursor","pointer");if(b){const P=ue(a,k),A=this;L.transition().duration(gt).ease(dt).attrTween("d",()=>w=>{const S=P(w),$=_.startAngle(a).endAngle(S)({});if(y.length>0){const R=(S-a)/(c-a);L.attr("fill",A.getStopColor(Math.min(1,R),y))}return $})}else L.attr("d",_.startAngle(a).endAngle(k)({}));this.config.enableMouseTracking!==!1&&L.on("mouseover",P=>{var A,w;L.interrupt("hover").transition("hover").duration(Z).ease(q).attr("d",T.startAngle(a).endAngle(k)({})),L.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.25))"),this.context.events.emit("point:mouseover",{point:e,index:i,series:this,event:P,plotX:g,plotY:m}),(w=(A=e==null?void 0:e.events)==null?void 0:A.mouseOver)==null||w.call(e,P)}).on("mouseout",P=>{var A,w;L.interrupt("hover").transition("hover").duration(Z).ease(q).attr("d",_.startAngle(a).endAngle(k)({})),L.style("filter",""),this.context.events.emit("point:mouseout",{point:e,index:i,series:this,event:P}),(w=(A=e==null?void 0:e.events)==null?void 0:A.mouseOut)==null||w.call(e,P)}).on("click",P=>{var A,w,S,$;this.context.events.emit("point:click",{point:e,index:i,series:this,event:P}),(w=(A=e==null?void 0:e.events)==null?void 0:A.click)==null||w.call(e,P),($=(S=this.config.events)==null?void 0:S.click)==null||$.call(this,P)})}resolveArcColor(t,e,i){return i!=null&&i.color?i.color:e.length>=2?this.getStopColor(t,e):this.getColor()}getStopColor(t,e){if(t<=e[0][0])return e[0][1];if(t>=e[e.length-1][0])return e[e.length-1][1];for(let i=0;i<e.length-1;i++)if(t>=e[i][0]&&t<=e[i+1][0]){const r=(t-e[i][0])/(e[i+1][0]-e[i][0]),o=e[i][1],s=e[i+1][1];return ue(o,s)(r)}return e[e.length-1][1]}resolveRadiusValue(t,e){return typeof t=="string"&&t.endsWith("%")?e*parseFloat(t)/100:typeof t=="number"?t<=1?e*t:t:e*.6}renderPaneBackground(t,e,i,r,o,s){const a=s.background?Array.isArray(s.background)?s.background:[s.background]:[];for(const c of a){const l=this.resolvePercent(c.outerRadius??"100%",e),h=this.resolvePercent(c.innerRadius??"0%",e),f=Pe().innerRadius(h).outerRadius(l).startAngle(r).endAngle(o);t.append("path").attr("d",f({})).attr("fill",c.backgroundColor||"#f2f2f2").attr("stroke",c.borderColor||"#cccccc").attr("stroke-width",c.borderWidth??0)}}renderPlotBands(t,e,i,r,o,s,a){var h;const c=((h=this.config._yAxis??this.config.yAxis)==null?void 0:h.plotBands)||[];if(c.length===0)return;const l=Me().domain([s,a]).range([r,o]);for(const f of c){if(f.from===void 0||f.to===void 0)continue;const u=Pe().innerRadius(i).outerRadius(e).startAngle(l(f.from)).endAngle(l(f.to));t.append("path").attr("d",u({})).attr("fill",f.color||"#e0e0e0").attr("stroke",f.borderColor||"none").attr("stroke-width",f.borderWidth??0)}}renderTickMarks(t,e,i,r,o,s){var p,y;const a=(this.config._yAxis??this.config.yAxis)||{},c=a.tickPositions||this.generateTicks(o,s,5),l=((p=a.labels)==null?void 0:p.enabled)!==!1,h=((y=a.labels)==null?void 0:y.style)||{},f=h.fontSize||kt,u=h.color||this.autoLabelColor(),d=Me().domain([o,s]).range([i,r]);for(const g of c){const m=d(g)-Math.PI/2;if(l){const b=e+14;t.append("text").attr("x",b*Math.cos(m)).attr("y",b*Math.sin(m)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",f).attr("fill",u).style("pointer-events","none").text(String(g))}}}generateTicks(t,e,i){const r=(e-t)/i,o=[];for(let s=0;s<=i;s++)o.push(Math.round((t+r*s)*100)/100);return o}renderValueLabel(t,e){var c,l,h,f;const i=this.config.dataLabels||{};if(!(i.enabled!==!1))return;const o=((c=i.style)==null?void 0:c.fontSize)||kt,s=i.color||((l=i.style)==null?void 0:l.color)||this.autoLabelColor();let a;i.formatter?a=i.formatter.call({point:this.data[0],series:{name:this.config.name},x:(h=this.data[0])==null?void 0:h.x,y:e}):i.format?a=re(Zt(i.format,{point:this.data[0],series:{name:this.config.name},x:(f=this.data[0])==null?void 0:f.x,y:e})):a=e.toString(),t.append("text").attr("y",10+(i.y??0)).attr("x",i.x??0).attr("text-anchor","middle").attr("font-size",o).attr("font-weight","bold").attr("fill",s).text(a)}resolvePercent(t,e){return typeof t=="number"?t:typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:parseFloat(t)||0}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const Ck=gr("~s");function Pk(n){return n===0?"0":n>=1e3?Ck(n).replace("G","B"):String(n)}function Ek(n){return!Number.isFinite(n)||Math.abs(n)<1e3?String(n):Math.round(n).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".")}function md(n){if(n<=0)return{ticks:[1],niceMax:1,gridMax:1};const t=n/2,e=Math.pow(10,Math.floor(Math.log10(t))),i=t/e;let r;i<1.5?r=1*e:i<3?r=2*e:i<7?r=5*e:r=10*e;const o=Math.max(r,Math.floor(n/r)*r),s=n*1.15;return{ticks:o>0?[Math.round(o*1e6)/1e6]:[],niceMax:o,gridMax:s}}function yd(n,t,e){const i=e==null?void 0:e.size;let r;typeof i=="string"&&i.trim().endsWith("%")?r=parseFloat(i)/100:typeof i=="number"?r=i>1?i/100:i:r=.85;const o=Math.min(n,t)*r/2;return Math.max(20,o-30)}class xd extends Ht{constructor(t){super(t)}render(){const t=this.resolvePolarSubType();t==="column"?this.renderColumnPolar():this.renderLineAreaPolar(t)}resolvePolarSubType(){const t=this.config.polarType||this.config._polarSubType||"area";return t==="column"||t==="bar"?"column":t==="line"?"line":"area"}renderLineAreaPolar(t){var L,P,A,w,S,$,R,F,D,z;const{plotArea:e}=this.context,i=this.context.animate,r=this.data,o=this.getColor(),s=this.context.pane||this.config.pane,a=yd(e.width,e.height,s),c=e.width/2,l=e.height/2,h=Math.max(...r.map(B=>B.y??0),1),{ticks:f,gridMax:u}=md(h),d=Me().domain([0,u]).range([0,a]),p=((L=this.config.marker)==null?void 0:L.radius)??4,y=((P=this.config.marker)==null?void 0:P.enabled)!==!1,g=this.config.pointPlacement,m=g==="on"?0:g==="between"?Math.PI/r.length:typeof g=="number"?g*Math.PI/180:0,b=2*Math.PI/r.length,x=this.config.connectEnds!==!1;(w=(A=this.config.states)==null?void 0:A.inactive)==null||w.opacity;const v=this.group.append("g").attr("transform",`translate(${c},${l})`);let k=0,M=1/0;for(let B=0;B<r.length;B++){const N=r[B].y??0;N<M&&(M=N,k=B)}const C=k*b-Math.PI/2;this.renderGrid(v,a,r.length,d,f,C);const E=x?V2:Si,_=$2().angle((B,N)=>N*b+m).radius(B=>d(B.y??0)).defined(B=>B.y!==null&&B.y!==void 0).curve(E),T=r.map(B=>({...B,y:0})),I=v.append("path").datum(r).attr("fill","none").attr("stroke",o).attr("stroke-width",this.config.lineWidth??2);if(t==="area"){const B=I2().angle((K,V)=>V*b+m).innerRadius(0).outerRadius(K=>d(K.y??0)).defined(K=>K.y!==null&&K.y!==void 0).curve(E),N=v.append("path").datum(r).attr("fill",Hn(this.config.fillColor,v,o)).attr("fill-opacity",this.config.fillOpacity??.3);i?N.attr("d",B(T)||"").transition().duration(gt).ease(dt).attr("d",B(r)||""):N.attr("d",B)}if(i?I.attr("d",_(T)||"").transition().duration(gt).ease(dt).attr("d",_(r)||""):I.attr("d",_),y){const N=Math.max(...r.map(V=>V.y??0),1)*.02,K=v.selectAll(".katucharts-polar-point").data(r).join("circle").attr("class","katucharts-polar-point").attr("cx",(V,G)=>d(V.y??0)*Math.cos(G*b-Math.PI/2+m)).attr("cy",(V,G)=>d(V.y??0)*Math.sin(G*b-Math.PI/2+m)).attr("fill",((S=this.config.marker)==null?void 0:S.fillColor)||o).attr("stroke",(($=this.config.marker)==null?void 0:$.lineColor)||this.autoBorderColor()).attr("stroke-width",((R=this.config.marker)==null?void 0:R.lineWidth)??1).style("display",V=>(V.y??0)<N?"none":null).style("cursor",this.config.cursor||"pointer");if(i?K.attr("r",0).attr("opacity",0).transition().duration(gt).ease(dt).delay((V,G)=>G*Bt).attr("r",p).attr("opacity",1):K.attr("r",p),this.renderPolarDataLabels(v,r,d,b,m),this.config.enableMouseTracking!==!1){const V=((z=(D=(F=this.config.marker)==null?void 0:F.states)==null?void 0:D.hover)==null?void 0:z.radius)??p+3;K.on("mouseover",(G,H)=>{var O,it;const j=st(G.currentTarget);j.transition("hover").duration(Z).ease(q).attr("r",V),j.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))");const U=r.indexOf(H),X=d(H.y??0)*Math.cos(U*b-Math.PI/2+m),tt=d(H.y??0)*Math.sin(U*b-Math.PI/2+m);this.context.events.emit("point:mouseover",{point:H,index:U,series:this,event:G,plotX:c+X,plotY:l+tt}),(it=(O=H.events)==null?void 0:O.mouseOver)==null||it.call(H,G)}).on("mouseout",(G,H)=>{var X,tt;const j=st(G.currentTarget);j.transition("hover").duration(Z).ease(q).attr("r",p),j.style("filter","");const U=r.indexOf(H);this.context.events.emit("point:mouseout",{point:H,index:U,series:this,event:G}),(tt=(X=H.events)==null?void 0:X.mouseOut)==null||tt.call(H,G)}).on("click",(G,H)=>{var U,X,tt,O;const j=r.indexOf(H);this.context.events.emit("point:click",{point:H,index:j,series:this,event:G}),(X=(U=H.events)==null?void 0:U.click)==null||X.call(H,G),(O=(tt=this.config.events)==null?void 0:tt.click)==null||O.call(this,G)})}}}renderColumnPolar(){var L,P;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=this.getColor(),s=this.context.pane||this.config.pane,a=yd(t.width,t.height,s),c=t.width/2,l=t.height/2,h=Math.max(...r.map(A=>A.y??0),1),{ticks:f,gridMax:u}=md(h),d=Me().domain([0,u]).range([0,a]),p=2*Math.PI/r.length,y=this.config.pointPlacement,g=y==="on"?0:y==="between"?Math.PI/r.length:typeof y=="number"?y*Math.PI/180:0,m=.02,b=((P=(L=this.config.states)==null?void 0:L.inactive)==null?void 0:P.opacity)??.4,x=this.config.colorByPoint===!0,v=this.config.stacking,k=this.group.append("g").attr("transform",`translate(${c},${l})`);let M=0,C=1/0;for(let A=0;A<r.length;A++){const w=r[A].y??0;w<C&&(C=w,M=A)}const E=M*p-Math.PI/2;this.renderGrid(k,a,r.length,d,f,E);const _=Pe().cornerRadius(2),T=k.selectAll(".katucharts-polar-bar").data(r).join("path").attr("class","katucharts-polar-bar").attr("fill",(A,w)=>A.color||(x?e[w%e.length]:o)).attr("stroke",this.config.borderColor||"none").attr("stroke-width",this.config.borderWidth??0).style("cursor",this.config.cursor||"pointer"),I=this.context.stackOffsets;i?T.each(function(A,w){const S=st(this),$=w*p-Math.PI/2+g+m,R=(w+1)*p-Math.PI/2+g-m,F=v&&I?d(I.get(w)??0):0,D=F+d(A.y??0);S.attr("d",_({innerRadius:F,outerRadius:F,startAngle:$+Math.PI/2,endAngle:R+Math.PI/2})||"").transition().duration(gt).ease(dt).delay(w*Bt).attrTween("d",()=>z=>_({innerRadius:F,outerRadius:F+(D-F)*z,startAngle:$+Math.PI/2,endAngle:R+Math.PI/2})||""),v&&I&&I.set(w,(I.get(w)??0)+(A.y??0))}):T.attr("d",(A,w)=>{const S=w*p-Math.PI/2+g+m,$=(w+1)*p-Math.PI/2+g-m,R=v&&I?d(I.get(w)??0):0,F=R+d(A.y??0);return v&&I&&I.set(w,(I.get(w)??0)+(A.y??0)),_({innerRadius:R,outerRadius:F,startAngle:S+Math.PI/2,endAngle:$+Math.PI/2})||""}),this.config.enableMouseTracking!==!1&&T.on("mouseover",(A,w)=>{var D,z;st(A.currentTarget).style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),T.interrupt("highlight"),T.attr("opacity",1),T.filter(B=>B!==w).transition("highlight").duration(Z).ease(q).attr("opacity",b);const $=r.indexOf(w),R=$*p+p/2-Math.PI/2+g,F=d(w.y??0)/2;this.context.events.emit("point:mouseover",{point:w,index:$,series:this,event:A,plotX:c+F*Math.cos(R),plotY:l+F*Math.sin(R)}),(z=(D=w.events)==null?void 0:D.mouseOver)==null||z.call(w,A)}).on("mouseout",(A,w)=>{var R,F;st(A.currentTarget).style("filter",""),T.interrupt("highlight"),T.transition("highlight").duration(Z).ease(q).attr("opacity",1);const $=r.indexOf(w);this.context.events.emit("point:mouseout",{point:w,index:$,series:this,event:A}),(F=(R=w.events)==null?void 0:R.mouseOut)==null||F.call(w,A)}).on("click",(A,w)=>{var $,R,F,D;const S=r.indexOf(w);this.context.events.emit("point:click",{point:w,index:S,series:this,event:A}),(R=($=w.events)==null?void 0:$.click)==null||R.call(w,A),(D=(F=this.config.events)==null?void 0:F.click)==null||D.call(this,A)})}renderPolarDataLabels(t,e,i,r,o){var k,M,C;const s=this.config.dataLabels||{};if(s.enabled!==!0)return;const a=((k=s.style)==null?void 0:k.fontSize)||kt,c=((M=s.style)==null?void 0:M.color)||this.autoLabelColor(),l=((C=s.style)==null?void 0:C.fontWeight)||"normal",h=[],f=16,u=6,d=Math.max(...e.map(E=>E.y??0),1),p=d*.02,y=d*.5,g=e.map((E,_)=>({d:E,i:_,v:E.y??0})).filter(E=>E.d.y!=null&&E.d.y!==0&&E.v>=p),m=g.filter(E=>E.v>=y),b=g.filter(E=>E.v<y);b.sort((E,_)=>_.v-E.v);const x=b.length>0?b[0]:null,v=x?[...m,x]:m;v.sort((E,_)=>E.i-_.i);for(const{d:E,i:_}of v){const T=_*r-Math.PI/2+o,I=i(E.y??0),L=I*Math.cos(T),P=I*Math.sin(T),A=((T+Math.PI/2)*180/Math.PI+360)%360;let w;A>20&&A<160?w="start":A>200&&A<340?w="end":w="middle";let S;A<45||A>315?S="text-after-edge":A>135&&A<225?S="text-before-edge":S="middle";const $=Math.cos(T),R=Math.sin(T),F=L+$*u,D=P+R*u;let z=!1;for(const B of h)if((B.x-F)**2+(B.y-D)**2<f*f){z=!0;break}z||(h.push({x:F,y:D}),t.append("text").attr("class","katucharts-polar-datalabel").attr("x",F).attr("y",D).attr("text-anchor",w).attr("dominant-baseline",S).attr("fill",c).attr("font-size",a).attr("font-weight",l).attr("stroke",this.labelHaloColor()).attr("stroke-width",3).attr("stroke-linejoin","round").attr("paint-order","stroke fill").style("pointer-events","none").text(Ek(E.y)))}}renderGrid(t,e,i,r,o,s=-Math.PI/2){var h,f,u,d;const c=(this.config.gridLineInterpolation||((h=this.config._yAxis??this.config.yAxis)==null?void 0:h.gridLineInterpolation)||"circle")==="polygon",l=2*Math.PI/i;if(c){const p=[];for(let y=0;y<i;y++){const g=y*l-Math.PI/2;p.push(`${e*Math.cos(g)},${e*Math.sin(g)}`)}t.append("polygon").attr("points",p.join(" ")).attr("fill","none").attr("stroke","#d0d0d0").attr("stroke-width",.8)}else t.append("circle").attr("r",e).attr("fill","none").attr("stroke","#d0d0d0").attr("stroke-width",.8);for(const p of o){const y=r(p);if(c){const b=[];for(let x=0;x<i;x++){const v=x*l-Math.PI/2,k=y*Math.cos(v),M=y*Math.sin(v);b.push(`${k},${M}`)}t.append("polygon").attr("points",b.join(" ")).attr("fill","none").attr("stroke","#e6e6e6").attr("stroke-width",.5)}else t.append("circle").attr("r",y).attr("fill","none").attr("stroke","#e6e6e6").attr("stroke-width",.5);const g=y*Math.cos(s)+5*Math.cos(s+Math.PI/2),m=y*Math.sin(s)+5*Math.sin(s+Math.PI/2);t.append("text").attr("x",g).attr("y",m).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",kt).attr("fill",this.autoLabelColor()).attr("stroke",this.labelHaloColor()).attr("stroke-width",3).attr("stroke-linejoin","round").attr("paint-order","stroke fill").style("pointer-events","none").text(Pk(p))}for(let p=0;p<i;p++){const y=p*l-Math.PI/2;t.append("line").attr("x1",0).attr("y1",0).attr("x2",e*Math.cos(y)).attr("y2",e*Math.sin(y)).attr("stroke","#ccc").attr("stroke-width",.5);const g=(u=(f=this.context.xAxis)==null?void 0:f.config)==null?void 0:u.categories,m=g&&g[p]||((d=this.data[p])==null?void 0:d.name)||`${p}`,b=e+28;t.append("text").attr("x",b*Math.cos(y)).attr("y",b*Math.sin(y)).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("font-size",kt).attr("fill",this.autoLabelColor()).text(m)}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const bd={circle:bn,square:gs,diamond:ps,triangle:ms,"triangle-down":ys,cross:ds};class Tk extends Ht{constructor(t){super(t),this.nodes=[],this.applyDescriptionTooltipDefault()}applyDescriptionTooltipDefault(){if(!this.data.some(i=>i.description!=null&&i.description!==""))return;const e=this.config.tooltip;e!=null&&e.pointFormat||e!=null&&e.pointFormatter||e!=null&&e.formatter||(this.config.tooltip={...e,pointFormat:"{point.description}"})}render(){const t=this.data;if(!t.length)return;const e=!!this.context.inverted;this.nodes=this.layoutNodes(e),this.renderBaseline(e),this.nodes.forEach(i=>this.renderNode(i,e)),this.context.animate&&this.emitAfterAnimate(gt+t.length*Bt)}layoutNodes(t){var u;const{plotArea:e,colors:i}=this.context,r=this.config,o=this.data,s=o.length,a=r.colorByPoint!==!1,c=((u=this.config.dataLabels)==null?void 0:u.alternate)!==!1,l=this.config.marker||{},h=t?28:52,f=Math.max(1,(t?e.height:e.width)-h*2);return o.map((d,p)=>{var k,M;const y=s===1?.5:p/(s-1),g=h+y*f,m=t?e.width/2:g,b=t?g:e.height/2,x=c?p%2===0?-1:1:t?1:-1,v=d.color||(a?i[p%i.length]:this.getColor());return{point:d,index:p,cx:m,cy:b,side:x,radius:((k=d.marker)==null?void 0:k.radius)??l.radius??6,symbol:((M=d.marker)==null?void 0:M.symbol)??l.symbol??"circle",color:v,group:null,marker:null}})}renderBaseline(t){if(this.nodes.length<2)return;const e=this.config,i=this.nodes[0],r=this.nodes[this.nodes.length-1],o=e.lineWidth??4,s=e.lineColor??"rgba(140,140,140,0.5)",a=this.group.append("line").attr("class","katucharts-timeline-baseline").attr("x1",i.cx).attr("y1",i.cy).attr("stroke",s).attr("stroke-width",o).attr("stroke-linecap","round"),c=t?i.cx:r.cx,l=t?r.cy:i.cy;this.context.animate?a.attr("x2",i.cx).attr("y2",i.cy).transition().duration(gt).ease(dt).attr("x2",c).attr("y2",l):a.attr("x2",c).attr("y2",l)}renderNode(t,e){const i=this.group.append("g").attr("class","katucharts-timeline-node");t.group=i,this.renderMarker(i,t);const r=this.renderLabel(i,t,e);this.renderConnector(i,t,e,r),this.attachNodeEvents(t),this.context.animate&&i.attr("opacity",0).transition().duration(gt).ease(dt).delay(t.index*Bt).attr("opacity",1)}renderMarker(t,e){var a,c;const i=this.config.marker||{},r=((a=e.point.marker)==null?void 0:a.lineColor)??i.lineColor??this.autoBorderColor(),o=((c=e.point.marker)==null?void 0:c.lineWidth)??i.lineWidth??1,s=this.context.animate;if(e.symbol==="circle"){const l=t.append("circle").attr("class","katucharts-timeline-marker").attr("cx",e.cx).attr("cy",e.cy).attr("fill",e.color).attr("stroke",r).attr("stroke-width",o);s?l.attr("r",0).transition().duration(gt).ease(dt).delay(e.index*Bt).attr("r",e.radius):l.attr("r",e.radius),e.marker=l}else{const l=bd[e.symbol]||bn;e.marker=t.append("path").attr("class","katucharts-timeline-marker").attr("transform",`translate(${e.cx},${e.cy})`).attr("fill",e.color).attr("stroke",r).attr("stroke-width",o).attr("d",Ve().type(l).size(Math.PI*e.radius*e.radius)())}}renderConnector(t,e,i,r){const o=this.config.dataLabels||{},s=o.connectorWidth??1,a=o.connectorColor??e.color,c=e.radius+(o.distance??22),l=t.append("line").attr("class","katucharts-timeline-connector").attr("stroke",a).attr("stroke-width",s);if(i){const h=e.cx+e.side*e.radius,f=r?e.side>0?r.x:r.x+r.width:e.cx+e.side*c;if(e.side>0?f<=h:f>=h)return;l.attr("y1",e.cy).attr("y2",e.cy).attr("x1",h).attr("x2",f)}else{const h=e.cy+e.side*e.radius,f=r?e.side<0?r.y+r.height:r.y:e.cy+e.side*c;if(e.side<0?f>=h:f<=h)return;l.attr("x1",e.cx).attr("x2",e.cx).attr("y1",h).attr("y2",f)}}renderLabel(t,e,i){const r=this.config.dataLabels||{};if(r.enabled===!1)return null;const o=this.buildLabelLines(e.point,e.index);if(!o.length)return null;const s=r.style||{},a=se(s.fontSize||kt),c=a*1.28,l=r.color||s.color||this.autoLabelColor(),h=e.radius+(r.distance??22),f=i?e.cx+e.side*h:e.cx,u=i?e.cy:e.cy+e.side*h,d=i?e.side>0?"start":"end":"middle",p=t.append("text").attr("class","katucharts-timeline-label").attr("text-anchor",d).style("font-size",`${a}px`).style("fill",l),y=o.length;return o.forEach((g,m)=>{const b=this.labelLineY(u,m,y,c,e.side,i,e.cy);p.append("tspan").attr("x",f).attr("y",b).attr("dominant-baseline","middle").style("font-weight",g.bold?"bold":"normal").text(g.text)}),this.renderLabelBox(t,p,e,r)}labelLineY(t,e,i,r,o,s,a){return s?a-(i-1)/2*r+e*r:o<0?t-(i-1-e)*r:t+e*r}renderLabelBox(t,e,i,r){var f,u;const o=(u=(f=e.node()).getBBox)==null?void 0:u.call(f);if(!o||!o.width)return null;const s=r.borderWidth??1.5,a=r.backgroundColor??"none";if(!s&&a==="none")return{x:o.x,y:o.y,width:o.width,height:o.height};const c=r.padding??5,l=!r.borderColor||r.borderColor==="auto"?i.color:r.borderColor,h={x:o.x-c,y:o.y-c,width:o.width+c*2,height:o.height+c*2};return t.insert("rect",".katucharts-timeline-label").attr("x",h.x).attr("y",h.y).attr("width",h.width).attr("height",h.height).attr("rx",r.borderRadius??3).attr("fill",a).attr("stroke",l).attr("stroke-width",s),h}buildLabelLines(t,e){const i=this.config.dataLabels||{};let r=null;if(i.formatter?r=i.formatter.call({point:{...t,index:e},series:this,x:t.x??e,y:t.y}):i.format&&(r=Zt(i.format,{point:t,series:{name:this.config.name??""},x:t.x,y:t.y})),r==null){const o=[];return t.name!=null&&o.push({text:String(t.name),bold:!0}),t.label!=null&&o.push({text:String(t.label),bold:!1}),o.length||o.push({text:`Event ${e+1}`,bold:!0}),o}return String(r).split(/<br\s*\/?>/i).map(o=>re(o)).filter(o=>o.length>0).map((o,s)=>({text:o,bold:s===0}))}attachNodeEvents(t){var r;if(this.config.enableMouseTracking===!1)return;const e=t.point.events||{},i=((r=this.config.point)==null?void 0:r.events)||{};t.group.style("cursor",this.config.cursor||"pointer").on("mouseover",o=>{var s,a;this.bumpMarker(t,t.radius+3),t.group.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),this.dimOthers(t),this.context.events.emit("point:mouseover",{point:t.point,index:t.index,series:this,event:o,plotX:t.cx,plotY:t.cy}),(s=e.mouseOver)==null||s.call(t.point,o),(a=i.mouseOver)==null||a.call(t.point,o)}).on("mouseout",o=>{var s,a;this.bumpMarker(t,t.radius),t.group.style("filter",""),this.restoreOpacity(),this.context.events.emit("point:mouseout",{point:t.point,index:t.index,series:this,event:o}),(s=e.mouseOut)==null||s.call(t.point,o),(a=i.mouseOut)==null||a.call(t.point,o)}).on("click",o=>{var s,a,c,l;this.context.events.emit("point:click",{point:t.point,index:t.index,series:this,event:o}),(s=e.click)==null||s.call(t.point,o),(a=i.click)==null||a.call(t.point,o),(l=(c=this.config.events)==null?void 0:c.click)==null||l.call(this,o)})}bumpMarker(t,e){if(!t.marker)return;const i=t.marker.interrupt("size").transition("size").duration(Z).ease(q);if(t.symbol==="circle")i.attr("r",e);else{const r=bd[t.symbol]||bn;i.attr("d",Ve().type(r).size(Math.PI*e*e)())}}dimOthers(t){this.nodes.forEach(e=>{e.group.interrupt("dim"),e===t?e.group.attr("opacity",1):e.group.transition("dim").duration(Z).ease(q).attr("opacity",.4)})}restoreOpacity(){this.nodes.forEach(t=>{t.group.interrupt("dim"),t.group.transition("dim").duration(Z).ease(q).attr("opacity",1)})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class Lk extends Ht{constructor(t){super(t)}render(){const{xAxis:t,plotArea:e,colors:i}=this.context,r=this.data,o=Math.min(25,e.height/Math.max(r.length,1)*.7),s=e.height/Math.max(r.length,1);r.forEach((a,c)=>{const l=a.start??a.x??0,h=a.end??l+1,f=t.getPixelForValue(l),u=t.getPixelForValue(h),d=c*s+(s-o)/2,p=a.color||i[c%i.length],y=this.group.append("rect").attr("class","katucharts-gantt-bar").attr("x",f).attr("y",d).attr("width",Math.max(1,u-f)).attr("height",o).attr("rx",3).attr("fill",p).attr("stroke","none");this.group.append("text").attr("x",f+4).attr("y",d+o/2).attr("dy","0.35em").attr("font-size","10px").attr("fill","#fff").text(a.name||""),y.style("cursor","pointer"),y.on("mouseover",g=>{y.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),y.interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke","#333").attr("stroke-width",1.5),this.context.events.emit("point:mouseover",{point:a,index:c,series:this,event:g,plotX:(f+u)/2,plotY:d+o/2})}).on("mouseout",g=>{y.style("filter",""),y.interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke","none").attr("stroke-width",0),this.context.events.emit("point:mouseout",{point:a,index:c,series:this,event:g})}).on("click",g=>{this.context.events.emit("point:click",{point:a,index:c,series:this,event:g})})})}getDataExtents(){let t=1/0,e=-1/0;for(const i of this.data){const r=i.start??i.x??0,o=i.end??r+1;t=Math.min(t,r),e=Math.max(e,o)}return{xMin:t,xMax:e,yMin:0,yMax:0}}}var At=1e-6,vd=1e-12,Ot=Math.PI,Qt=Ot/2,wd=Ot/4,Ke=Ot*2,ze=180/Ot,te=Ot/180,Xt=Math.abs,Ki=Math.atan,Gn=Math.atan2,Dt=Math.cos,Ss=Math.ceil,kd=Math.exp,_s=Math.log,Vc=Math.pow,Tt=Math.sin,an=Math.sign||function(n){return n>0?1:n<0?-1:0},Ge=Math.sqrt,Gc=Math.tan;function Md(n){return n>1?0:n<-1?Ot:Math.acos(n)}function cn(n){return n>1?Qt:n<-1?-Qt:Math.asin(n)}function ln(){}function Cs(n,t){n&&Sd.hasOwnProperty(n.type)&&Sd[n.type](n,t)}var Ad={Feature:function(n,t){Cs(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,i=-1,r=e.length;++i<r;)Cs(e[i].geometry,t)}},Sd={Sphere:function(n,t){t.sphere()},Point:function(n,t){n=n.coordinates,t.point(n[0],n[1],n[2])},MultiPoint:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)n=e[i],t.point(n[0],n[1],n[2])},LineString:function(n,t){Yc(n.coordinates,t,0)},MultiLineString:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)Yc(e[i],t,0)},Polygon:function(n,t){_d(n.coordinates,t)},MultiPolygon:function(n,t){for(var e=n.coordinates,i=-1,r=e.length;++i<r;)_d(e[i],t)},GeometryCollection:function(n,t){for(var e=n.geometries,i=-1,r=e.length;++i<r;)Cs(e[i],t)}};function Yc(n,t,e){var i=-1,r=n.length-e,o;for(t.lineStart();++i<r;)o=n[i],t.point(o[0],o[1],o[2]);t.lineEnd()}function _d(n,t){var e=-1,i=n.length;for(t.polygonStart();++e<i;)Yc(n[e],t,1);t.polygonEnd()}function Ji(n,t){n&&Ad.hasOwnProperty(n.type)?Ad[n.type](n,t):Cs(n,t)}function Xc(n){return[Gn(n[1],n[0]),cn(n[2])]}function Qi(n){var t=n[0],e=n[1],i=Dt(e);return[i*Dt(t),i*Tt(t),Tt(e)]}function Ps(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function Es(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Uc(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function Ts(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function jc(n){var t=Ge(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function qc(n,t){function e(i,r){return i=n(i,r),t(i[0],i[1])}return n.invert&&t.invert&&(e.invert=function(i,r){return i=t.invert(i,r),i&&n.invert(i[0],i[1])}),e}function Zc(n,t){return Xt(n)>Ot&&(n-=Math.round(n/Ke)*Ke),[n,t]}Zc.invert=Zc;function Cd(n,t,e){return(n%=Ke)?t||e?qc(Ed(n),Td(t,e)):Ed(n):t||e?Td(t,e):Zc}function Pd(n){return function(t,e){return t+=n,Xt(t)>Ot&&(t-=Math.round(t/Ke)*Ke),[t,e]}}function Ed(n){var t=Pd(n);return t.invert=Pd(-n),t}function Td(n,t){var e=Dt(n),i=Tt(n),r=Dt(t),o=Tt(t);function s(a,c){var l=Dt(c),h=Dt(a)*l,f=Tt(a)*l,u=Tt(c),d=u*e+h*i;return[Gn(f*r-d*o,h*e-u*i),cn(d*r+f*o)]}return s.invert=function(a,c){var l=Dt(c),h=Dt(a)*l,f=Tt(a)*l,u=Tt(c),d=u*r-f*o;return[Gn(f*r+u*o,h*e+d*i),cn(d*e-h*i)]},s}function $k(n){n=Cd(n[0]*te,n[1]*te,n.length>2?n[2]*te:0);function t(e){return e=n(e[0]*te,e[1]*te),e[0]*=ze,e[1]*=ze,e}return t.invert=function(e){return e=n.invert(e[0]*te,e[1]*te),e[0]*=ze,e[1]*=ze,e},t}function Ik(n,t,e,i,r,o){if(e){var s=Dt(t),a=Tt(t),c=i*e;r==null?(r=t+i*Ke,o=t-c/2):(r=Ld(s,r),o=Ld(s,o),(i>0?r<o:r>o)&&(r+=i*Ke));for(var l,h=r;i>0?h>o:h<o;h-=c)l=Xc([s,-a*Dt(h),-a*Tt(h)]),n.point(l[0],l[1])}}function Ld(n,t){t=Qi(t),t[0]-=n,jc(t);var e=Md(-t[1]);return((-t[2]<0?-e:e)+Ke-At)%Ke}function $d(){var n=[],t;return{point:function(e,i,r){t.push([e,i,r])},lineStart:function(){n.push(t=[])},lineEnd:ln,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function Ls(n,t){return Xt(n[0]-t[0])<At&&Xt(n[1]-t[1])<At}function $s(n,t,e,i){this.x=n,this.z=t,this.o=e,this.e=i,this.v=!1,this.n=this.p=null}function Id(n,t,e,i,r){var o=[],s=[],a,c;if(n.forEach(function(p){if(!((y=p.length-1)<=0)){var y,g=p[0],m=p[y],b;if(Ls(g,m)){if(!g[2]&&!m[2]){for(r.lineStart(),a=0;a<y;++a)r.point((g=p[a])[0],g[1]);r.lineEnd();return}m[0]+=2*At}o.push(b=new $s(g,p,null,!0)),s.push(b.o=new $s(g,null,b,!1)),o.push(b=new $s(m,p,null,!1)),s.push(b.o=new $s(m,null,b,!0))}}),!!o.length){for(s.sort(t),Fd(o),Fd(s),a=0,c=s.length;a<c;++a)s[a].e=e=!e;for(var l=o[0],h,f;;){for(var u=l,d=!0;u.v;)if((u=u.n)===l)return;h=u.z,r.lineStart();do{if(u.v=u.o.v=!0,u.e){if(d)for(a=0,c=h.length;a<c;++a)r.point((f=h[a])[0],f[1]);else i(u.x,u.n.x,1,r);u=u.n}else{if(d)for(h=u.p.z,a=h.length-1;a>=0;--a)r.point((f=h[a])[0],f[1]);else i(u.x,u.p.x,-1,r);u=u.p}u=u.o,h=u.z,d=!d}while(!u.v);r.lineEnd()}}}function Fd(n){if(t=n.length){for(var t,e=0,i=n[0],r;++e<t;)i.n=r=n[e],r.p=i,i=r;i.n=r=n[0],r.p=i}}function Kc(n){return Xt(n[0])<=Ot?n[0]:an(n[0])*((Xt(n[0])+Ot)%Ke-Ot)}function Fk(n,t){var e=Kc(t),i=t[1],r=Tt(i),o=[Tt(e),-Dt(e),0],s=0,a=0,c=new gi;r===1?i=Qt+At:r===-1&&(i=-Qt-At);for(var l=0,h=n.length;l<h;++l)if(u=(f=n[l]).length)for(var f,u,d=f[u-1],p=Kc(d),y=d[1]/2+wd,g=Tt(y),m=Dt(y),b=0;b<u;++b,p=v,g=M,m=C,d=x){var x=f[b],v=Kc(x),k=x[1]/2+wd,M=Tt(k),C=Dt(k),E=v-p,_=E>=0?1:-1,T=_*E,I=T>Ot,L=g*M;if(c.add(Gn(L*_*Tt(T),m*C+L*Dt(T))),s+=I?E+_*Ke:E,I^p>=e^v>=e){var P=Es(Qi(d),Qi(x));jc(P);var A=Es(o,P);jc(A);var w=(I^E>=0?-1:1)*cn(A[2]);(i>w||i===w&&(P[0]||P[1]))&&(a+=I^E>=0?1:-1)}}return(s<-At||s<At&&c<-vd)^a&1}function Rd(n,t,e,i){return function(r){var o=t(r),s=$d(),a=t(s),c=!1,l,h,f,u={point:d,lineStart:y,lineEnd:g,polygonStart:function(){u.point=m,u.lineStart=b,u.lineEnd=x,h=[],l=[]},polygonEnd:function(){u.point=d,u.lineStart=y,u.lineEnd=g,h=nu(h);var v=Fk(l,i);h.length?(c||(r.polygonStart(),c=!0),Id(h,Dk,v,e,r)):v&&(c||(r.polygonStart(),c=!0),r.lineStart(),e(null,null,1,r),r.lineEnd()),c&&(r.polygonEnd(),c=!1),h=l=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}};function d(v,k){n(v,k)&&r.point(v,k)}function p(v,k){o.point(v,k)}function y(){u.point=p,o.lineStart()}function g(){u.point=d,o.lineEnd()}function m(v,k){f.push([v,k]),a.point(v,k)}function b(){a.lineStart(),f=[]}function x(){m(f[0][0],f[0][1]),a.lineEnd();var v=a.clean(),k=s.result(),M,C=k.length,E,_,T;if(f.pop(),l.push(f),f=null,!!C){if(v&1){if(_=k[0],(E=_.length-1)>0){for(c||(r.polygonStart(),c=!0),r.lineStart(),M=0;M<E;++M)r.point((T=_[M])[0],T[1]);r.lineEnd()}return}C>1&&v&2&&k.push(k.pop().concat(k.shift())),h.push(k.filter(Rk))}}return u}}function Rk(n){return n.length>1}function Dk(n,t){return((n=n.x)[0]<0?n[1]-Qt-At:Qt-n[1])-((t=t.x)[0]<0?t[1]-Qt-At:Qt-t[1])}const Dd=Rd(function(){return!0},zk,Ok,[-Ot,-Qt]);function zk(n){var t=NaN,e=NaN,i=NaN,r;return{lineStart:function(){n.lineStart(),r=1},point:function(o,s){var a=o>0?Ot:-Ot,c=Xt(o-t);Xt(c-Ot)<At?(n.point(t,e=(e+s)/2>0?Qt:-Qt),n.point(i,e),n.lineEnd(),n.lineStart(),n.point(a,e),n.point(o,e),r=0):i!==a&&c>=Ot&&(Xt(t-i)<At&&(t-=i*At),Xt(o-a)<At&&(o-=a*At),e=Bk(t,e,o,s),n.point(i,e),n.lineEnd(),n.lineStart(),n.point(a,e),r=0),n.point(t=o,e=s),i=a},lineEnd:function(){n.lineEnd(),t=e=NaN},clean:function(){return 2-r}}}function Bk(n,t,e,i){var r,o,s=Tt(n-e);return Xt(s)>At?Ki((Tt(t)*(o=Dt(i))*Tt(e)-Tt(i)*(r=Dt(t))*Tt(n))/(r*o*s)):(t+i)/2}function Ok(n,t,e,i){var r;if(n==null)r=e*Qt,i.point(-Ot,r),i.point(0,r),i.point(Ot,r),i.point(Ot,0),i.point(Ot,-r),i.point(0,-r),i.point(-Ot,-r),i.point(-Ot,0),i.point(-Ot,r);else if(Xt(n[0]-t[0])>At){var o=n[0]<t[0]?Ot:-Ot;r=e*o/2,i.point(-o,r),i.point(0,r),i.point(o,r)}else i.point(t[0],t[1])}function Nk(n){var t=Dt(n),e=2*te,i=t>0,r=Xt(t)>At;function o(h,f,u,d){Ik(d,n,e,u,h,f)}function s(h,f){return Dt(h)*Dt(f)>t}function a(h){var f,u,d,p,y;return{lineStart:function(){p=d=!1,y=1},point:function(g,m){var b=[g,m],x,v=s(g,m),k=i?v?0:l(g,m):v?l(g+(g<0?Ot:-Ot),m):0;if(!f&&(p=d=v)&&h.lineStart(),v!==d&&(x=c(f,b),(!x||Ls(f,x)||Ls(b,x))&&(b[2]=1)),v!==d)y=0,v?(h.lineStart(),x=c(b,f),h.point(x[0],x[1])):(x=c(f,b),h.point(x[0],x[1],2),h.lineEnd()),f=x;else if(r&&f&&i^v){var M;!(k&u)&&(M=c(b,f,!0))&&(y=0,i?(h.lineStart(),h.point(M[0][0],M[0][1]),h.point(M[1][0],M[1][1]),h.lineEnd()):(h.point(M[1][0],M[1][1]),h.lineEnd(),h.lineStart(),h.point(M[0][0],M[0][1],3)))}v&&(!f||!Ls(f,b))&&h.point(b[0],b[1]),f=b,d=v,u=k},lineEnd:function(){d&&h.lineEnd(),f=null},clean:function(){return y|(p&&d)<<1}}}function c(h,f,u){var d=Qi(h),p=Qi(f),y=[1,0,0],g=Es(d,p),m=Ps(g,g),b=g[0],x=m-b*b;if(!x)return!u&&h;var v=t*m/x,k=-t*b/x,M=Es(y,g),C=Ts(y,v),E=Ts(g,k);Uc(C,E);var _=M,T=Ps(C,_),I=Ps(_,_),L=T*T-I*(Ps(C,C)-1);if(!(L<0)){var P=Ge(L),A=Ts(_,(-T-P)/I);if(Uc(A,C),A=Xc(A),!u)return A;var w=h[0],S=f[0],$=h[1],R=f[1],F;S<w&&(F=w,w=S,S=F);var D=S-w,z=Xt(D-Ot)<At,B=z||D<At;if(!z&&R<$&&(F=$,$=R,R=F),B?z?$+R>0^A[1]<(Xt(A[0]-w)<At?$:R):$<=A[1]&&A[1]<=R:D>Ot^(w<=A[0]&&A[0]<=S)){var N=Ts(_,(-T+P)/I);return Uc(N,C),[A,Xc(N)]}}}function l(h,f){var u=i?n:Ot-n,d=0;return h<-u?d|=1:h>u&&(d|=2),f<-u?d|=4:f>u&&(d|=8),d}return Rd(s,a,o,i?[0,-n]:[-Ot,n-Ot])}function Wk(n,t,e,i,r,o){var s=n[0],a=n[1],c=t[0],l=t[1],h=0,f=1,u=c-s,d=l-a,p;if(p=e-s,!(!u&&p>0)){if(p/=u,u<0){if(p<h)return;p<f&&(f=p)}else if(u>0){if(p>f)return;p>h&&(h=p)}if(p=r-s,!(!u&&p<0)){if(p/=u,u<0){if(p>f)return;p>h&&(h=p)}else if(u>0){if(p<h)return;p<f&&(f=p)}if(p=i-a,!(!d&&p>0)){if(p/=d,d<0){if(p<h)return;p<f&&(f=p)}else if(d>0){if(p>f)return;p>h&&(h=p)}if(p=o-a,!(!d&&p<0)){if(p/=d,d<0){if(p>f)return;p>h&&(h=p)}else if(d>0){if(p<h)return;p<f&&(f=p)}return h>0&&(n[0]=s+h*u,n[1]=a+h*d),f<1&&(t[0]=s+f*u,t[1]=a+f*d),!0}}}}}var zr=1e9,Is=-zr;function Hk(n,t,e,i){function r(l,h){return n<=l&&l<=e&&t<=h&&h<=i}function o(l,h,f,u){var d=0,p=0;if(l==null||(d=s(l,f))!==(p=s(h,f))||c(l,h)<0^f>0)do u.point(d===0||d===3?n:e,d>1?i:t);while((d=(d+f+4)%4)!==p);else u.point(h[0],h[1])}function s(l,h){return Xt(l[0]-n)<At?h>0?0:3:Xt(l[0]-e)<At?h>0?2:1:Xt(l[1]-t)<At?h>0?1:0:h>0?3:2}function a(l,h){return c(l.x,h.x)}function c(l,h){var f=s(l,1),u=s(h,1);return f!==u?f-u:f===0?h[1]-l[1]:f===1?l[0]-h[0]:f===2?l[1]-h[1]:h[0]-l[0]}return function(l){var h=l,f=$d(),u,d,p,y,g,m,b,x,v,k,M,C={point:E,lineStart:L,lineEnd:P,polygonStart:T,polygonEnd:I};function E(w,S){r(w,S)&&h.point(w,S)}function _(){for(var w=0,S=0,$=d.length;S<$;++S)for(var R=d[S],F=1,D=R.length,z=R[0],B,N,K=z[0],V=z[1];F<D;++F)B=K,N=V,z=R[F],K=z[0],V=z[1],N<=i?V>i&&(K-B)*(i-N)>(V-N)*(n-B)&&++w:V<=i&&(K-B)*(i-N)<(V-N)*(n-B)&&--w;return w}function T(){h=f,u=[],d=[],M=!0}function I(){var w=_(),S=M&&w,$=(u=nu(u)).length;(S||$)&&(l.polygonStart(),S&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),$&&Id(u,a,w,o,l),l.polygonEnd()),h=l,u=d=p=null}function L(){C.point=A,d&&d.push(p=[]),k=!0,v=!1,b=x=NaN}function P(){u&&(A(y,g),m&&v&&f.rejoin(),u.push(f.result())),C.point=E,v&&h.lineEnd()}function A(w,S){var $=r(w,S);if(d&&p.push([w,S]),k)y=w,g=S,m=$,k=!1,$&&(h.lineStart(),h.point(w,S));else if($&&v)h.point(w,S);else{var R=[b=Math.max(Is,Math.min(zr,b)),x=Math.max(Is,Math.min(zr,x))],F=[w=Math.max(Is,Math.min(zr,w)),S=Math.max(Is,Math.min(zr,S))];Wk(R,F,n,t,e,i)?(v||(h.lineStart(),h.point(R[0],R[1])),h.point(F[0],F[1]),$||h.lineEnd(),M=!1):$&&(h.lineStart(),h.point(w,S),M=!1)}b=w,x=S,v=$}return C}}function zd(n,t,e){var i=mi(n,t-At,e).concat(t);return function(r){return i.map(function(o){return[r,o]})}}function Bd(n,t,e){var i=mi(n,t-At,e).concat(t);return function(r){return i.map(function(o){return[o,r]})}}function Vk(){var n,t,e,i,r,o,s,a,c=10,l=c,h=90,f=360,u,d,p,y,g=2.5;function m(){return{type:"MultiLineString",coordinates:b()}}function b(){return mi(Ss(i/h)*h,e,h).map(p).concat(mi(Ss(a/f)*f,s,f).map(y)).concat(mi(Ss(t/c)*c,n,c).filter(function(x){return Xt(x%h)>At}).map(u)).concat(mi(Ss(o/l)*l,r,l).filter(function(x){return Xt(x%f)>At}).map(d))}return m.lines=function(){return b().map(function(x){return{type:"LineString",coordinates:x}})},m.outline=function(){return{type:"Polygon",coordinates:[p(i).concat(y(s).slice(1),p(e).reverse().slice(1),y(a).reverse().slice(1))]}},m.extent=function(x){return arguments.length?m.extentMajor(x).extentMinor(x):m.extentMinor()},m.extentMajor=function(x){return arguments.length?(i=+x[0][0],e=+x[1][0],a=+x[0][1],s=+x[1][1],i>e&&(x=i,i=e,e=x),a>s&&(x=a,a=s,s=x),m.precision(g)):[[i,a],[e,s]]},m.extentMinor=function(x){return arguments.length?(t=+x[0][0],n=+x[1][0],o=+x[0][1],r=+x[1][1],t>n&&(x=t,t=n,n=x),o>r&&(x=o,o=r,r=x),m.precision(g)):[[t,o],[n,r]]},m.step=function(x){return arguments.length?m.stepMajor(x).stepMinor(x):m.stepMinor()},m.stepMajor=function(x){return arguments.length?(h=+x[0],f=+x[1],m):[h,f]},m.stepMinor=function(x){return arguments.length?(c=+x[0],l=+x[1],m):[c,l]},m.precision=function(x){return arguments.length?(g=+x,u=zd(o,r,90),d=Bd(t,n,g),p=zd(a,s,90),y=Bd(i,e,g),m):g},m.extentMajor([[-180,-90+At],[180,90-At]]).extentMinor([[-180,-80-At],[180,80+At]])}const Jc=n=>n;var Qc=new gi,tl=new gi,Od,Nd,el,nl,Yn={point:ln,lineStart:ln,lineEnd:ln,polygonStart:function(){Yn.lineStart=Gk,Yn.lineEnd=Xk},polygonEnd:function(){Yn.lineStart=Yn.lineEnd=Yn.point=ln,Qc.add(Xt(tl)),tl=new gi},result:function(){var n=Qc/2;return Qc=new gi,n}};function Gk(){Yn.point=Yk}function Yk(n,t){Yn.point=Wd,Od=el=n,Nd=nl=t}function Wd(n,t){tl.add(nl*n-el*t),el=n,nl=t}function Xk(){Wd(Od,Nd)}var tr=1/0,Fs=tr,Br=-tr,Rs=Br,Ds={point:Uk,lineStart:ln,lineEnd:ln,polygonStart:ln,polygonEnd:ln,result:function(){var n=[[tr,Fs],[Br,Rs]];return Br=Rs=-(Fs=tr=1/0),n}};function Uk(n,t){n<tr&&(tr=n),n>Br&&(Br=n),t<Fs&&(Fs=t),t>Rs&&(Rs=t)}var il=0,rl=0,Or=0,zs=0,Bs=0,er=0,ol=0,sl=0,Nr=0,Hd,Vd,Sn,_n,hn={point:_i,lineStart:Gd,lineEnd:Yd,polygonStart:function(){hn.lineStart=Zk,hn.lineEnd=Kk},polygonEnd:function(){hn.point=_i,hn.lineStart=Gd,hn.lineEnd=Yd},result:function(){var n=Nr?[ol/Nr,sl/Nr]:er?[zs/er,Bs/er]:Or?[il/Or,rl/Or]:[NaN,NaN];return il=rl=Or=zs=Bs=er=ol=sl=Nr=0,n}};function _i(n,t){il+=n,rl+=t,++Or}function Gd(){hn.point=jk}function jk(n,t){hn.point=qk,_i(Sn=n,_n=t)}function qk(n,t){var e=n-Sn,i=t-_n,r=Ge(e*e+i*i);zs+=r*(Sn+n)/2,Bs+=r*(_n+t)/2,er+=r,_i(Sn=n,_n=t)}function Yd(){hn.point=_i}function Zk(){hn.point=Jk}function Kk(){Xd(Hd,Vd)}function Jk(n,t){hn.point=Xd,_i(Hd=Sn=n,Vd=_n=t)}function Xd(n,t){var e=n-Sn,i=t-_n,r=Ge(e*e+i*i);zs+=r*(Sn+n)/2,Bs+=r*(_n+t)/2,er+=r,r=_n*n-Sn*t,ol+=r*(Sn+n),sl+=r*(_n+t),Nr+=r*3,_i(Sn=n,_n=t)}function Ud(n){this._context=n}Ud.prototype={_radius:4.5,pointRadius:function(n){return this._radius=n,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(n,t){switch(this._point){case 0:{this._context.moveTo(n,t),this._point=1;break}case 1:{this._context.lineTo(n,t);break}default:{this._context.moveTo(n+this._radius,t),this._context.arc(n,t,this._radius,0,Ke);break}}},result:ln};var al=new gi,cl,jd,qd,Wr,Hr,Vr={point:ln,lineStart:function(){Vr.point=Qk},lineEnd:function(){cl&&Zd(jd,qd),Vr.point=ln},polygonStart:function(){cl=!0},polygonEnd:function(){cl=null},result:function(){var n=+al;return al=new gi,n}};function Qk(n,t){Vr.point=Zd,jd=Wr=n,qd=Hr=t}function Zd(n,t){Wr-=n,Hr-=t,al.add(Ge(Wr*Wr+Hr*Hr)),Wr=n,Hr=t}let Kd,Os,Jd,Qd;class tp{constructor(t){this._append=t==null?ep:tM(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,e){switch(this._point){case 0:{this._append`M${t},${e}`,this._point=1;break}case 1:{this._append`L${t},${e}`;break}default:{if(this._append`M${t},${e}`,this._radius!==Jd||this._append!==Os){const i=this._radius,r=this._;this._="",this._append`m0,${i}a${i},${i} 0 1,1 0,${-2*i}a${i},${i} 0 1,1 0,${2*i}z`,Jd=i,Os=this._append,Qd=this._,this._=r}this._+=Qd;break}}}result(){const t=this._;return this._="",t.length?t:null}}function ep(n){let t=1;this._+=n[0];for(const e=n.length;t<e;++t)this._+=arguments[t]+n[t]}function tM(n){const t=Math.floor(n);if(!(t>=0))throw new RangeError(`invalid digits: ${n}`);if(t>15)return ep;if(t!==Kd){const e=10**t;Kd=t,Os=function(r){let o=1;this._+=r[0];for(const s=r.length;o<s;++o)this._+=Math.round(arguments[o]*e)/e+r[o]}}return Os}function eM(n,t){let e=3,i=4.5,r,o;function s(a){return a&&(typeof i=="function"&&o.pointRadius(+i.apply(this,arguments)),Ji(a,r(o))),o.result()}return s.area=function(a){return Ji(a,r(Yn)),Yn.result()},s.measure=function(a){return Ji(a,r(Vr)),Vr.result()},s.bounds=function(a){return Ji(a,r(Ds)),Ds.result()},s.centroid=function(a){return Ji(a,r(hn)),hn.result()},s.projection=function(a){return arguments.length?(r=a==null?(n=null,Jc):(n=a).stream,s):n},s.context=function(a){return arguments.length?(o=a==null?(t=null,new tp(e)):new Ud(t=a),typeof i!="function"&&o.pointRadius(i),s):t},s.pointRadius=function(a){return arguments.length?(i=typeof a=="function"?a:(o.pointRadius(+a),+a),s):i},s.digits=function(a){if(!arguments.length)return e;if(a==null)e=null;else{const c=Math.floor(a);if(!(c>=0))throw new RangeError(`invalid digits: ${a}`);e=c}return t===null&&(o=new tp(e)),s},s.projection(n).digits(e).context(t)}function ll(n){return function(t){var e=new hl;for(var i in n)e[i]=n[i];return e.stream=t,e}}function hl(){}hl.prototype={constructor:hl,point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function ul(n,t,e){var i=n.clipExtent&&n.clipExtent();return n.scale(150).translate([0,0]),i!=null&&n.clipExtent(null),Ji(e,n.stream(Ds)),t(Ds.result()),i!=null&&n.clipExtent(i),n}function fl(n,t,e){return ul(n,function(i){var r=t[1][0]-t[0][0],o=t[1][1]-t[0][1],s=Math.min(r/(i[1][0]-i[0][0]),o/(i[1][1]-i[0][1])),a=+t[0][0]+(r-s*(i[1][0]+i[0][0]))/2,c=+t[0][1]+(o-s*(i[1][1]+i[0][1]))/2;n.scale(150*s).translate([a,c])},e)}function np(n,t,e){return fl(n,[[0,0],t],e)}function ip(n,t,e){return ul(n,function(i){var r=+t,o=r/(i[1][0]-i[0][0]),s=(r-o*(i[1][0]+i[0][0]))/2,a=-o*i[0][1];n.scale(150*o).translate([s,a])},e)}function rp(n,t,e){return ul(n,function(i){var r=+t,o=r/(i[1][1]-i[0][1]),s=-o*i[0][0],a=(r-o*(i[1][1]+i[0][1]))/2;n.scale(150*o).translate([s,a])},e)}var op=16,nM=Dt(30*te);function sp(n,t){return+t?rM(n,t):iM(n)}function iM(n){return ll({point:function(t,e){t=n(t,e),this.stream.point(t[0],t[1])}})}function rM(n,t){function e(i,r,o,s,a,c,l,h,f,u,d,p,y,g){var m=l-i,b=h-r,x=m*m+b*b;if(x>4*t&&y--){var v=s+u,k=a+d,M=c+p,C=Ge(v*v+k*k+M*M),E=cn(M/=C),_=Xt(Xt(M)-1)<At||Xt(o-f)<At?(o+f)/2:Gn(k,v),T=n(_,E),I=T[0],L=T[1],P=I-i,A=L-r,w=b*P-m*A;(w*w/x>t||Xt((m*P+b*A)/x-.5)>.3||s*u+a*d+c*p<nM)&&(e(i,r,o,s,a,c,I,L,_,v/=C,k/=C,M,y,g),g.point(I,L),e(I,L,_,v,k,M,l,h,f,u,d,p,y,g))}}return function(i){var r,o,s,a,c,l,h,f,u,d,p,y,g={point:m,lineStart:b,lineEnd:v,polygonStart:function(){i.polygonStart(),g.lineStart=k},polygonEnd:function(){i.polygonEnd(),g.lineStart=b}};function m(E,_){E=n(E,_),i.point(E[0],E[1])}function b(){f=NaN,g.point=x,i.lineStart()}function x(E,_){var T=Qi([E,_]),I=n(E,_);e(f,u,h,d,p,y,f=I[0],u=I[1],h=E,d=T[0],p=T[1],y=T[2],op,i),i.point(f,u)}function v(){g.point=m,i.lineEnd()}function k(){b(),g.point=M,g.lineEnd=C}function M(E,_){x(r=E,_),o=f,s=u,a=d,c=p,l=y,g.point=x}function C(){e(f,u,h,d,p,y,o,s,r,a,c,l,op,i),g.lineEnd=v,v()}return g}}var oM=ll({point:function(n,t){this.stream.point(n*te,t*te)}});function sM(n){return ll({point:function(t,e){var i=n(t,e);return this.stream.point(i[0],i[1])}})}function aM(n,t,e,i,r){function o(s,a){return s*=i,a*=r,[t+n*s,e-n*a]}return o.invert=function(s,a){return[(s-t)/n*i,(e-a)/n*r]},o}function ap(n,t,e,i,r,o){if(!o)return aM(n,t,e,i,r);var s=Dt(o),a=Tt(o),c=s*n,l=a*n,h=s/n,f=a/n,u=(a*e-s*t)/n,d=(a*t+s*e)/n;function p(y,g){return y*=i,g*=r,[c*y-l*g+t,e-l*y-c*g]}return p.invert=function(y,g){return[i*(h*y-f*g+u),r*(d-f*y-h*g)]},p}function Cn(n){return cp(function(){return n})()}function cp(n){var t,e=150,i=480,r=250,o=0,s=0,a=0,c=0,l=0,h,f=0,u=1,d=1,p=null,y=Dd,g=null,m,b,x,v=Jc,k=.5,M,C,E,_,T;function I(w){return E(w[0]*te,w[1]*te)}function L(w){return w=E.invert(w[0],w[1]),w&&[w[0]*ze,w[1]*ze]}I.stream=function(w){return _&&T===w?_:_=oM(sM(h)(y(M(v(T=w)))))},I.preclip=function(w){return arguments.length?(y=w,p=void 0,A()):y},I.postclip=function(w){return arguments.length?(v=w,g=m=b=x=null,A()):v},I.clipAngle=function(w){return arguments.length?(y=+w?Nk(p=w*te):(p=null,Dd),A()):p*ze},I.clipExtent=function(w){return arguments.length?(v=w==null?(g=m=b=x=null,Jc):Hk(g=+w[0][0],m=+w[0][1],b=+w[1][0],x=+w[1][1]),A()):g==null?null:[[g,m],[b,x]]},I.scale=function(w){return arguments.length?(e=+w,P()):e},I.translate=function(w){return arguments.length?(i=+w[0],r=+w[1],P()):[i,r]},I.center=function(w){return arguments.length?(o=w[0]%360*te,s=w[1]%360*te,P()):[o*ze,s*ze]},I.rotate=function(w){return arguments.length?(a=w[0]%360*te,c=w[1]%360*te,l=w.length>2?w[2]%360*te:0,P()):[a*ze,c*ze,l*ze]},I.angle=function(w){return arguments.length?(f=w%360*te,P()):f*ze},I.reflectX=function(w){return arguments.length?(u=w?-1:1,P()):u<0},I.reflectY=function(w){return arguments.length?(d=w?-1:1,P()):d<0},I.precision=function(w){return arguments.length?(M=sp(C,k=w*w),A()):Ge(k)},I.fitExtent=function(w,S){return fl(I,w,S)},I.fitSize=function(w,S){return np(I,w,S)},I.fitWidth=function(w,S){return ip(I,w,S)},I.fitHeight=function(w,S){return rp(I,w,S)};function P(){var w=ap(e,0,0,u,d,f).apply(null,t(o,s)),S=ap(e,i-w[0],r-w[1],u,d,f);return h=Cd(a,c,l),C=qc(t,S),E=qc(h,C),M=sp(C,k),A()}function A(){return _=T=null,I}return function(){return t=n.apply(this,arguments),I.invert=t.invert&&L,P()}}function dl(n){var t=0,e=Ot/3,i=cp(n),r=i(t,e);return r.parallels=function(o){return arguments.length?i(t=o[0]*te,e=o[1]*te):[t*ze,e*ze]},r}function cM(n){var t=Dt(n);function e(i,r){return[i*t,Tt(r)/t]}return e.invert=function(i,r){return[i/t,cn(r*t)]},e}function lM(n,t){var e=Tt(n),i=(e+Tt(t))/2;if(Xt(i)<At)return cM(n);var r=1+e*(2*i-e),o=Ge(r)/i;function s(a,c){var l=Ge(r-2*i*Tt(c))/i;return[l*Tt(a*=i),o-l*Dt(a)]}return s.invert=function(a,c){var l=o-c,h=Gn(a,Xt(l))*an(l);return l*i<0&&(h-=Ot*an(a)*an(l)),[h/i,cn((r-(a*a+l*l)*i*i)/(2*i))]},s}function Ns(){return dl(lM).scale(155.424).center([0,33.6442])}function lp(){return Ns().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])}function hM(n){var t=n.length;return{point:function(e,i){for(var r=-1;++r<t;)n[r].point(e,i)},sphere:function(){for(var e=-1;++e<t;)n[e].sphere()},lineStart:function(){for(var e=-1;++e<t;)n[e].lineStart()},lineEnd:function(){for(var e=-1;++e<t;)n[e].lineEnd()},polygonStart:function(){for(var e=-1;++e<t;)n[e].polygonStart()},polygonEnd:function(){for(var e=-1;++e<t;)n[e].polygonEnd()}}}function uM(){var n,t,e=lp(),i,r=Ns().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o,s=Ns().rotate([157,0]).center([-3,19.9]).parallels([8,18]),a,c,l={point:function(u,d){c=[u,d]}};function h(u){var d=u[0],p=u[1];return c=null,i.point(d,p),c||(o.point(d,p),c)||(a.point(d,p),c)}h.invert=function(u){var d=e.scale(),p=e.translate(),y=(u[0]-p[0])/d,g=(u[1]-p[1])/d;return(g>=.12&&g<.234&&y>=-.425&&y<-.214?r:g>=.166&&g<.234&&y>=-.214&&y<-.115?s:e).invert(u)},h.stream=function(u){return n&&t===u?n:n=hM([e.stream(t=u),r.stream(u),s.stream(u)])},h.precision=function(u){return arguments.length?(e.precision(u),r.precision(u),s.precision(u),f()):e.precision()},h.scale=function(u){return arguments.length?(e.scale(u),r.scale(u*.35),s.scale(u),h.translate(e.translate())):e.scale()},h.translate=function(u){if(!arguments.length)return e.translate();var d=e.scale(),p=+u[0],y=+u[1];return i=e.translate(u).clipExtent([[p-.455*d,y-.238*d],[p+.455*d,y+.238*d]]).stream(l),o=r.translate([p-.307*d,y+.201*d]).clipExtent([[p-.425*d+At,y+.12*d+At],[p-.214*d-At,y+.234*d-At]]).stream(l),a=s.translate([p-.205*d,y+.212*d]).clipExtent([[p-.214*d+At,y+.166*d+At],[p-.115*d-At,y+.234*d-At]]).stream(l),f()},h.fitExtent=function(u,d){return fl(h,u,d)},h.fitSize=function(u,d){return np(h,u,d)},h.fitWidth=function(u,d){return ip(h,u,d)},h.fitHeight=function(u,d){return rp(h,u,d)};function f(){return n=t=null,h}return h.scale(1070)}function hp(n){return function(t,e){var i=Dt(t),r=Dt(e),o=n(i*r);return o===1/0?[2,0]:[o*r*Tt(t),o*Tt(e)]}}function Gr(n){return function(t,e){var i=Ge(t*t+e*e),r=n(i),o=Tt(r),s=Dt(r);return[Gn(t*o,i*s),cn(i&&e*o/i)]}}var up=hp(function(n){return Ge(2/(1+n))});up.invert=Gr(function(n){return 2*cn(n/2)});function fM(){return Cn(up).scale(124.75).clipAngle(180-.001)}var fp=hp(function(n){return(n=Md(n))&&n/Tt(n)});fp.invert=Gr(function(n){return n});function dM(){return Cn(fp).scale(79.4188).clipAngle(180-.001)}function Ws(n,t){return[n,_s(Gc((Qt+t)/2))]}Ws.invert=function(n,t){return[n,2*Ki(kd(t))-Qt]};function dp(){return pp(Ws).scale(961/Ke)}function pp(n){var t=Cn(n),e=t.center,i=t.scale,r=t.translate,o=t.clipExtent,s=null,a,c,l;t.scale=function(f){return arguments.length?(i(f),h()):i()},t.translate=function(f){return arguments.length?(r(f),h()):r()},t.center=function(f){return arguments.length?(e(f),h()):e()},t.clipExtent=function(f){return arguments.length?(f==null?s=a=c=l=null:(s=+f[0][0],a=+f[0][1],c=+f[1][0],l=+f[1][1]),h()):s==null?null:[[s,a],[c,l]]};function h(){var f=Ot*i(),u=t($k(t.rotate()).invert([0,0]));return o(s==null?[[u[0]-f,u[1]-f],[u[0]+f,u[1]+f]]:n===Ws?[[Math.max(u[0]-f,s),a],[Math.min(u[0]+f,c),l]]:[[s,Math.max(u[1]-f,a)],[c,Math.min(u[1]+f,l)]])}return h()}function Hs(n){return Gc((Qt+n)/2)}function pM(n,t){var e=Dt(n),i=n===t?Tt(n):_s(e/Dt(t))/_s(Hs(t)/Hs(n)),r=e*Vc(Hs(n),i)/i;if(!i)return Ws;function o(s,a){r>0?a<-Qt+At&&(a=-Qt+At):a>Qt-At&&(a=Qt-At);var c=r/Vc(Hs(a),i);return[c*Tt(i*s),r-c*Dt(i*s)]}return o.invert=function(s,a){var c=r-a,l=an(i)*Ge(s*s+c*c),h=Gn(s,Xt(c))*an(c);return c*i<0&&(h-=Ot*an(s)*an(c)),[h/i,2*Ki(Vc(r/l,1/i))-Qt]},o}function gM(){return dl(pM).scale(109.5).parallels([30,30])}function Vs(n,t){return[n,t]}Vs.invert=Vs;function mM(){return Cn(Vs).scale(152.63)}function yM(n,t){var e=Dt(n),i=n===t?Tt(n):(e-Dt(t))/(t-n),r=e/i+n;if(Xt(i)<At)return Vs;function o(s,a){var c=r-a,l=i*s;return[c*Tt(l),r-c*Dt(l)]}return o.invert=function(s,a){var c=r-a,l=Gn(s,Xt(c))*an(c);return c*i<0&&(l-=Ot*an(s)*an(c)),[l/i,r-an(i)*Ge(s*s+c*c)]},o}function xM(){return dl(yM).scale(131.154).center([0,13.9389])}var Yr=1.340264,Xr=-.081106,Ur=893e-6,jr=.003796,Gs=Ge(3)/2,bM=12;function gp(n,t){var e=cn(Gs*Tt(t)),i=e*e,r=i*i*i;return[n*Dt(e)/(Gs*(Yr+3*Xr*i+r*(7*Ur+9*jr*i))),e*(Yr+Xr*i+r*(Ur+jr*i))]}gp.invert=function(n,t){for(var e=t,i=e*e,r=i*i*i,o=0,s,a,c;o<bM&&(a=e*(Yr+Xr*i+r*(Ur+jr*i))-t,c=Yr+3*Xr*i+r*(7*Ur+9*jr*i),e-=s=a/c,i=e*e,r=i*i*i,!(Xt(s)<vd));++o);return[Gs*n*(Yr+3*Xr*i+r*(7*Ur+9*jr*i))/Dt(e),cn(Tt(e)/Gs)]};function mp(){return Cn(gp).scale(177.158)}function yp(n,t){var e=Dt(t),i=Dt(n)*e;return[e*Tt(n)/i,Tt(t)/i]}yp.invert=Gr(Ki);function vM(){return Cn(yp).scale(144.049).clipAngle(60)}function xp(n,t){var e=t*t,i=e*e;return[n*(.8707-.131979*e+i*(-.013791+i*(.003971*e-.001529*i))),t*(1.007226+e*(.015085+i*(-.044475+.028874*e-.005916*i)))]}xp.invert=function(n,t){var e=t,i=25,r;do{var o=e*e,s=o*o;e-=r=(e*(1.007226+o*(.015085+s*(-.044475+.028874*o-.005916*s)))-t)/(1.007226+o*(.015085*3+s*(-.044475*7+.028874*9*o-.005916*11*s)))}while(Xt(r)>At&&--i>0);return[n/(.8707+(o=e*e)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),e]};function pl(){return Cn(xp).scale(175.295)}function bp(n,t){return[Dt(t)*Tt(n),Tt(t)]}bp.invert=Gr(cn);function vp(){return Cn(bp).scale(249.5).clipAngle(90+At)}function wp(n,t){var e=Dt(t),i=1+Dt(n)*e;return[e*Tt(n)/i,Tt(t)/i]}wp.invert=Gr(function(n){return 2*Ki(n)});function wM(){return Cn(wp).scale(250).clipAngle(142)}function kp(n,t){return[_s(Gc((Qt+t)/2)),-n]}kp.invert=function(n,t){return[-t,2*Ki(kd(n))-Qt]};function kM(){var n=pp(kp),t=n.center,e=n.rotate;return n.center=function(i){return arguments.length?t([-i[1],i[0]]):(i=t(),[i[1],-i[0]])},n.rotate=function(i){return arguments.length?e([i[0],i[1],i.length>2?i[2]+90:90]):(i=e(),[i[0],i[1],i[2]-90])},e([0,0,90]).scale(159.155)}function MM(n){return n}function AM(n){if(n==null)return MM;var t,e,i=n.scale[0],r=n.scale[1],o=n.translate[0],s=n.translate[1];return function(a,c){c||(t=e=0);var l=2,h=a.length,f=new Array(h);for(f[0]=(t+=a[0])*i+o,f[1]=(e+=a[1])*r+s;l<h;)f[l]=a[l],++l;return f}}function SM(n,t){for(var e,i=n.length,r=i-t;r<--i;)e=n[r],n[r++]=n[i],n[i]=e}function _M(n,t){return typeof t=="string"&&(t=n.objects[t]),t.type==="GeometryCollection"?{type:"FeatureCollection",features:t.geometries.map(function(e){return Mp(n,e)})}:Mp(n,t)}function Mp(n,t){var e=t.id,i=t.bbox,r=t.properties==null?{}:t.properties,o=CM(n,t);return e==null&&i==null?{type:"Feature",properties:r,geometry:o}:i==null?{type:"Feature",id:e,properties:r,geometry:o}:{type:"Feature",id:e,bbox:i,properties:r,geometry:o}}function CM(n,t){var e=AM(n.transform),i=n.arcs;function r(h,f){f.length&&f.pop();for(var u=i[h<0?~h:h],d=0,p=u.length;d<p;++d)f.push(e(u[d],d));h<0&&SM(f,p)}function o(h){return e(h)}function s(h){for(var f=[],u=0,d=h.length;u<d;++u)r(h[u],f);return f.length<2&&f.push(f[0]),f}function a(h){for(var f=s(h);f.length<4;)f.push(f[0]);return f}function c(h){return h.map(a)}function l(h){var f=h.type,u;switch(f){case"GeometryCollection":return{type:f,geometries:h.geometries.map(l)};case"Point":u=o(h.coordinates);break;case"MultiPoint":u=h.coordinates.map(o);break;case"LineString":u=s(h.arcs);break;case"MultiLineString":u=h.arcs.map(s);break;case"Polygon":u=c(h.arcs);break;case"MultiPolygon":u=h.arcs.map(c);break;default:return null}return{type:f,coordinates:u}}return l(t)}const Ap=(n,t)=>[n,1.25*Math.log(Math.tan(Math.PI/4+.4*t))];Ap.invert=(n,t)=>[n,2.5*Math.atan(Math.exp(.8*t))-.625*Math.PI];const PM={naturalEarth:pl,naturalEarth1:pl,mercator:dp,orthographic:vp,albers:lp,albersUsa:uM,equirectangular:mM,equalEarth:mp,conicEqualArea:Ns,conicEquidistant:xM,stereographic:wM,transverseMercator:kM,azimuthalEqualArea:fM,azimuthalEquidistant:dM,gnomonic:vM,Orthographic:vp,WebMercator:dp,EqualEarth:mp,LambertConformalConic:gM,Miller:()=>Cn(Ap).scale(108.318)};function EM(n,t){if(n&&n.type==="Topology"&&n.objects){const e=t||(n.objects.countries?"countries":Object.keys(n.objects)[0]),i=_M(n,n.objects[e]);return i.features||[i]}return n.features||n}function gl(n,t){var e;return String(n).toLowerCase()==="orthographic"||!!((e=t==null?void 0:t.options3d)!=null&&e.enabled)}function ml(n,t,e,i){var f,u,d;const r=EM(n,i),o={type:"FeatureCollection",features:r},s=(t==null?void 0:t.name)||t||"naturalEarth",c=(PM[s]||pl)(),l=typeof t=="object"?t:{};l.rotation&&((f=c.rotate)==null||f.call(c,l.rotation)),l.center&&((u=c.center)==null||u.call(c,l.center)),l.scale&&((d=c.scale)==null||d.call(c,l.scale)),l.parallels&&c.parallels&&c.parallels(l.parallels),l.scale||c.fitSize([e.width,e.height],o);const h=eM().projection(c);return{projection:c,pathGen:h,features:r,projName:String(s)}}function yl(n,t){const e=t.width/2,i=t.height/2,r=Math.min(t.width,t.height)/2-10;return n.translate([e,i]).scale(r).clipAngle(90),r}function xl(n){var t;return n?Array.isArray(n)&&n.length>=2&&typeof n[0]=="number"?[n[0],n[1]]:n.lon!=null&&n.lat!=null?[n.lon,n.lat]:(t=n.geometry)!=null&&t.coordinates&&Array.isArray(n.geometry.coordinates)?[n.geometry.coordinates[0],n.geometry.coordinates[1]]:typeof n.x=="number"&&typeof n.y=="number"?[n.x,n.y]:null:null}const TM={blues:ad,reds:Mw,greens:yw,oranges:Sw,purples:ww,greys:bw,ylOrRd:sd,ylGnBu:dw,rdYlGn:uw,viridis:_w,plasma:Pw,inferno:Cw};class LM extends Ht{constructor(t){super(t),this.zoomBehavior=null,this.mapGroup=null,this.featurePaths=null,this.dataMap=new Map,this.globeProjection=null,this.globePathGen=null,this.autoRotateTimer=null}destroy(){this.autoRotateTimer&&(this.autoRotateTimer.stop(),this.autoRotateTimer=null),super.destroy()}render(){var T;const{plotArea:t}=this.context,e=this.config,i=e.mapData;if(!i){this.group.append("text").attr("x",t.width/2).attr("y",t.height/2).attr("text-anchor","middle").attr("fill","#999").text("Map data not provided");return}const{projection:r,pathGen:o,features:s,projName:a}=ml(i,e.projection,t,e.mapDataObject);this.dataMap.clear();const c=e.joinBy||["hc-key","code"],l=Array.isArray(c)?c:[c,c],h=l[0],f=l.length>1?l[1]:l[0];for(const I of this.data){const L=I[f]||I.code||I["hc-key"]||I.name;L&&this.dataMap.set(String(L),I)}const u=e.colorAxis||{},d=this.data.map(I=>I.y??I.value??0).filter(I=>I!=null),p=u.min??(d.length?Math.min(...d):0),y=u.max??(d.length?Math.max(...d):1);if(Array.isArray(u.stops)&&u.stops.length>=2){const I=y-p||1,L=u.stops.map(w=>p+w[0]*I),P=u.stops.map(w=>w[1]),A=Me().domain(L).range(P).clamp(!0);this.colorScale=w=>A(w)}else if(u.minColor&&u.maxColor){const I=xi(u.minColor,u.maxColor),L=this.makeAxisNorm(u,p,y);this.colorScale=P=>I(L(P))}else{const I=u.colorScheme||"blues",L=TM[I]||ad,P=this.makeAxisNorm(u,p,y);this.colorScale=A=>L(P(A))}const g=e.nullColor??"#f0f0f0",m=e.allAreas!==!1,b=e.borderColor??"#cccccc",x=e.borderWidth??.5,v=`katucharts-map-clip-${Math.random().toString(36).slice(2,8)}`;this.group.append("defs").append("clipPath").attr("id",v).append("rect").attr("width",t.width).attr("height",t.height);const M=this.group.append("g").attr("clip-path",`url(#${v})`).attr("class","katucharts-map-clip");this.mapGroup=M.append("g").attr("class","katucharts-map-container katucharts-mapzoom");const C=m?s:s.filter(I=>{const L=this.getFeatureKey(I,h);return this.dataMap.has(L)}),E=this.context.animate;this.featurePaths=this.mapGroup.selectAll(".katucharts-map-feature").data(C).join("path").attr("class","katucharts-map-feature").attr("d",o).attr("stroke",b).attr("stroke-width",x).attr("stroke-linejoin","round").style("cursor","pointer"),E?this.featurePaths.attr("fill",g).attr("fill-opacity",0).transition().duration(gt).ease(dt).attr("fill-opacity",1).attr("fill",I=>this.getFeatureColor(I,h,g)):this.featurePaths.attr("fill",I=>this.getFeatureColor(I,h,g)),this.attachMapHover(h,b,x,g),this.renderMapLabels(o,C,h),u.enabled!==!1&&d.length>0&&this.renderColorAxis(p,y,u),gl(a,e)?this.setupGlobeMode(r,o,s,h,g,b,x,e):((T=e.mapNavigation)==null?void 0:T.enabled)!==!1&&this.setupMapNavigation(r,o)}makeAxisNorm(t,e,i){if(t.type==="logarithmic"&&e>0&&i>0){const o=Fo().domain([e,i]).clamp(!0);return s=>o(Math.max(s,e))}const r=Me().domain([e,i]).clamp(!0);return o=>r(o)}getFeatureKey(t,e){var i,r,o;return String(((i=t.properties)==null?void 0:i[e])||((r=t.properties)==null?void 0:r["hc-key"])||((o=t.properties)==null?void 0:o.name)||t.id||"")}getFeatureColor(t,e,i){const r=this.getFeatureKey(t,e),o=this.dataMap.get(r);if(o){if(o.color)return o.color;const s=o.y??o.value;if(s!=null)return this.colorScale(s)}return i}attachMapHover(t,e,i,r){var h,f,u,d,p,y,g,m;const o=this.config,s=(f=(h=o.states)==null?void 0:h.hover)==null?void 0:f.color,a=((d=(u=o.states)==null?void 0:u.hover)==null?void 0:d.borderColor)??"#333333",c=((y=(p=o.states)==null?void 0:p.hover)==null?void 0:y.borderWidth)??1.5,l=((m=(g=o.states)==null?void 0:g.hover)==null?void 0:m.brightness)??.2;this.featurePaths.on("mouseover",(b,x)=>{var I,L,P;const v=st(b.currentTarget),k=this.getFeatureKey(x,t),M=this.dataMap.get(k),C=v.attr("fill");if(s)v.transition("hover").duration(Z).ease(q).attr("fill",s);else{const A=((L=(I=le(C))==null?void 0:I.brighter(l))==null?void 0:L.toString())||C;v.transition("hover").duration(Z).ease(q).attr("fill",A)}v.attr("stroke",a).attr("stroke-width",c),v.raise(),this.featurePaths.interrupt("highlight"),this.featurePaths.filter(A=>A!==x).transition("highlight").duration(Z).ease(q).attr("opacity",.7);const E=((P=x.properties)==null?void 0:P.name)||k,_=M?{name:M.name??E,y:M.y??M.value,...M}:{name:E},T=b.currentTarget.getBBox();this.context.events.emit("point:mouseover",{point:_,index:0,series:this,event:b,plotX:T.x+T.width/2,plotY:T.y+T.height/2})}).on("mouseout",(b,x)=>{var E;const v=st(b.currentTarget),k=this.getFeatureColor(x,t,r);v.transition("hover").duration(Z).ease(q).attr("fill",k),v.attr("stroke",e).attr("stroke-width",i),this.featurePaths.interrupt("highlight"),this.featurePaths.transition("highlight").duration(Z).ease(q).attr("opacity",1);const M=this.getFeatureKey(x,t),C=this.dataMap.get(M)||{name:((E=x.properties)==null?void 0:E.name)||M};this.context.events.emit("point:mouseout",{point:C,index:0,series:this,event:b})}).on("click",(b,x)=>{var M;const v=this.getFeatureKey(x,t),k=this.dataMap.get(v)||{name:((M=x.properties)==null?void 0:M.name)||v};this.context.events.emit("point:click",{point:k,index:0,series:this,event:b})})}renderMapLabels(t,e,i){var l,h,f;const r=this.config.dataLabels||this.config.dataLabels;if(!(r!=null&&r.enabled))return;const o=((l=r.style)==null?void 0:l.fontSize)||kt,s=this.autoLabelColor(r.color||((h=r.style)==null?void 0:h.color)),a=this.labelHalo(),c=((f=r.filter)==null?void 0:f.property)==="hasData";this.mapGroup.selectAll(".katucharts-map-label").data(e).join("text").attr("class","katucharts-map-label").attr("transform",u=>{const d=t.centroid(u);return isFinite(d[0])?`translate(${d[0]},${d[1]})`:"translate(-9999,-9999)"}).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",o).attr("fill",s).style("pointer-events","none").style("text-shadow",a).text(u=>{var y,g,m,b,x;const d=this.getFeatureKey(u,i),p=this.dataMap.get(d);return c&&!p?"":r.formatter?r.formatter.call({point:p||{name:(y=u.properties)==null?void 0:y.name},series:{name:this.config.name},x:(g=u.properties)==null?void 0:g.name,y:(p==null?void 0:p.y)??(p==null?void 0:p.value)}):r.format?re(Zt(r.format,{point:p||{name:(m=u.properties)==null?void 0:m.name},series:{name:this.config.name},x:(b=u.properties)==null?void 0:b.name,y:(p==null?void 0:p.y)??(p==null?void 0:p.value)})):(p==null?void 0:p.name)||((x=u.properties)==null?void 0:x.name)||""})}renderColorAxis(t,e,i){const{plotArea:r}=this.context,o=i.layout==="horizontal"?"bottom":"right",s=i.labels||{},a=i.title;o==="bottom"?this.renderHorizontalColorAxis(t,e,i,s,a):this.renderVerticalColorAxis(t,e,i,s,a)}renderVerticalColorAxis(t,e,i,r,o){var k,M;const{plotArea:s}=this.context,a=i.width??12,c=i.height??s.height*.5,l=s.width+15,h=(s.height-c)/2,f=60,u=this.group.append("g").attr("class","katucharts-map-color-axis"),d=u.append("defs"),p=`katucharts-map-grad-${Math.random().toString(36).slice(2,8)}`,y=d.append("linearGradient").attr("id",p).attr("x1","0%").attr("y1","100%").attr("x2","0%").attr("y2","0%");for(let C=0;C<=f;C++){const E=C/f,_=t+E*(e-t);y.append("stop").attr("offset",`${E*100}%`).attr("stop-color",this.colorScale(_))}u.append("rect").attr("x",l).attr("y",h).attr("width",a).attr("height",c).attr("fill",`url(#${p})`).attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);const g=((k=r.style)==null?void 0:k.fontSize)||kt,m=this.autoLabelColor((M=r.style)==null?void 0:M.color),b=r.formatter,x=C=>b?b.call({value:C}):String(Math.round(C));u.append("text").attr("x",l+a+4).attr("y",h+c).attr("font-size",g).attr("fill",m).attr("dominant-baseline","auto").text(x(t)),u.append("text").attr("x",l+a+4).attr("y",h).attr("font-size",g).attr("fill",m).attr("dominant-baseline","hanging").text(x(e));const v=(t+e)/2;u.append("text").attr("x",l+a+4).attr("y",h+c/2).attr("font-size",g).attr("fill",m).attr("dominant-baseline","middle").text(x(v)),o!=null&&o.text&&u.append("text").attr("x",l+a/2).attr("y",h-8).attr("text-anchor","middle").attr("font-size","10px").attr("fill",this.autoLabelColor()).text(o.text)}renderHorizontalColorAxis(t,e,i,r,o){var v,k;const{plotArea:s}=this.context,a=i.width??s.width*.5,c=i.height??12,l=(s.width-a)/2,h=s.height+25,f=60,u=this.group.append("g").attr("class","katucharts-map-color-axis"),d=u.append("defs"),p=`katucharts-map-grad-${Math.random().toString(36).slice(2,8)}`,y=d.append("linearGradient").attr("id",p).attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");for(let M=0;M<=f;M++){const C=M/f,E=t+C*(e-t);y.append("stop").attr("offset",`${C*100}%`).attr("stop-color",this.colorScale(E))}u.append("rect").attr("x",l).attr("y",h).attr("width",a).attr("height",c).attr("fill",`url(#${p})`).attr("stroke","#ccc").attr("stroke-width",.5).attr("rx",2);const g=((v=r.style)==null?void 0:v.fontSize)||kt,m=this.autoLabelColor((k=r.style)==null?void 0:k.color),b=r.formatter,x=M=>b?b.call({value:M}):String(Math.round(M));u.append("text").attr("x",l).attr("y",h+c+12).attr("text-anchor","start").attr("font-size",g).attr("fill",m).text(x(t)),u.append("text").attr("x",l+a).attr("y",h+c+12).attr("text-anchor","end").attr("font-size",g).attr("fill",m).text(x(e)),o!=null&&o.text&&u.append("text").attr("x",l+a/2).attr("y",h-6).attr("text-anchor","middle").attr("font-size","10px").attr("fill",this.autoLabelColor()).text(o.text)}setupMapNavigation(t,e){const{plotArea:i}=this.context,r=this.config.mapNavigation||{},o=r.enableButtons!==!1,s=r.enableMouseWheelZoom!==!1,a=r.enableDoubleClickZoom!==!1,c=r.enableDrag!==!1,l=r.maxZoom??16,h=i.width/2,f=i.height/2;this.zoomBehavior=Af().scaleExtent([1,l]).on("zoom",p=>{this.context.chartGroup.selectAll(".katucharts-mapzoom").attr("transform",p.transform)});const u=this.group.select(".katucharts-map-clip"),d=u.empty()?this.group:u;d.insert("rect",":first-child").attr("width",i.width).attr("height",i.height).attr("fill","none").style("pointer-events","all"),(s||a||c)&&(d.call(this.zoomBehavior),s||d.on("wheel.zoom",null),a||d.on("dblclick.zoom",null),c||(d.on("mousedown.zoom",null),d.on("touchstart.zoom",null))),o&&this.renderNavButtons(d,h,f)}renderNavButtons(t,e,i){var C,E;const{plotArea:r}=this.context,o=this.config.mapNavigation||{},s=o.buttonOptions||{},a=s.theme||{},c=o.buttons||{},l=24,h=4,f=10,u=l*2+h,d=s.align||"left",p=s.verticalAlign||"top",y=(d==="right"?r.width-l-f:f)+(s.x??0),g=(p==="bottom"?r.height-u-f:f)+(s.y??0),m=a.fill||"#ffffff",b=a.stroke||"#e0e0e0",x=a.style&&a.style.color||s.symbolStroke||"#3f3f46",v=this.group.append("g").attr("class","katucharts-map-nav"),k=[e,i],M=(_,T,I)=>{const L=v.append("g").style("cursor","pointer").on("click",I);return L.append("rect").attr("x",y).attr("y",_).attr("width",l).attr("height",l).attr("fill",m).attr("stroke",b).attr("stroke-width",1).attr("rx",4),L.append("text").attr("x",y+l/2).attr("y",_+l/2+1).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size","17px").attr("fill",x).style("user-select","none").text(T),L.on("mouseover",function(){st(this).select("rect").attr("fill","#f5f5f5")}).on("mouseout",function(){st(this).select("rect").attr("fill",m)}),L};M(g,((C=c.zoomIn)==null?void 0:C.text)||"+",()=>{t.transition().duration(300).call(this.zoomBehavior.scaleBy,1.5,k)}),M(g+l+h,((E=c.zoomOut)==null?void 0:E.text)||"−",()=>{t.transition().duration(300).call(this.zoomBehavior.scaleBy,1/1.5,k)})}setupGlobeMode(t,e,i,r,o,s,a,c){const{plotArea:l}=this.context,h=l.width/2,f=l.height/2;this.globeProjection=t,this.globePathGen=e;const u=yl(t,l),d=c.options3d||{},p=d.oceanColor??"#d4f1f9",y=d.atmosphereColor??"rgba(100,180,255,0.15)",g=d.graticule!==!1,m=d.graticuleColor??"#ccc",b=d.graticuleOpacity??.4,x=d.autoRotate!==!1,v=d.rotateSpeed??.3,k=d.shadow!==!1,M=this.mapGroup.append("defs"),C=`katucharts-globe-glow-${Math.random().toString(36).slice(2,8)}`,E=M.append("radialGradient").attr("id",C);if(E.append("stop").attr("offset","70%").attr("stop-color",y),E.append("stop").attr("offset","100%").attr("stop-color","rgba(100,180,255,0)"),this.mapGroup.insert("circle",":first-child").attr("cx",h).attr("cy",f).attr("r",u+15).attr("fill",`url(#${C})`).attr("class","katucharts-globe-atmosphere"),k&&this.mapGroup.insert("ellipse",":first-child").attr("cx",h+8).attr("cy",f+u+18).attr("rx",u*.6).attr("ry",8).attr("fill","rgba(0,0,0,0.12)").attr("class","katucharts-globe-shadow"),this.mapGroup.insert("circle",".katucharts-map-feature").attr("cx",h).attr("cy",f).attr("r",u).attr("fill",p).attr("stroke","#999").attr("stroke-width",.5).attr("class","katucharts-globe-ocean"),g){const w=Vk().step([15,15]);this.mapGroup.insert("path",".katucharts-map-feature").datum(w()).attr("d",e).attr("fill","none").attr("stroke",m).attr("stroke-width",.3).attr("stroke-opacity",b).attr("class","katucharts-globe-graticule")}this.featurePaths.attr("d",e);const _=`katucharts-globe-spec-${Math.random().toString(36).slice(2,8)}`,T=M.append("radialGradient").attr("id",_).attr("cx","35%").attr("cy","25%");T.append("stop").attr("offset","0%").attr("stop-color","rgba(255,255,255,0.35)"),T.append("stop").attr("offset","50%").attr("stop-color","rgba(255,255,255,0.05)"),T.append("stop").attr("offset","100%").attr("stop-color","rgba(255,255,255,0)"),this.mapGroup.append("circle").attr("cx",h).attr("cy",f).attr("r",u).attr("fill",`url(#${_})`).style("pointer-events","none").attr("class","katucharts-globe-specular");const I=this;let L=null,P=x;const A=kf().on("start",w=>{const S=t.rotate();L=[S[0],S[1],w.x],I.autoRotateTimer&&(P=!0,I.autoRotateTimer.stop(),I.autoRotateTimer=null)}).on("drag",w=>{if(!L)return;const S=.4,$=(w.x-L[2])*S,R=L[0]+$,F=Math.max(-90,Math.min(90,L[1]-(w.y-w.subject.y)*S));t.rotate([R,F]),I.redrawGlobe()}).on("end",()=>{L=null,P&&x&&I.startAutoRotate(t,v)});this.group.call(A),this.group.style("cursor","grab"),this.group.on("wheel",w=>{w.preventDefault();const S=t.scale(),$=w.deltaY>0?.95:1.05,R=Math.max(u*.5,Math.min(u*8,S*$));t.scale(R),I.redrawGlobe()}),x&&this.startAutoRotate(t,v)}startAutoRotate(t,e){const i=this;this.autoRotateTimer&&(this.autoRotateTimer.stop(),this.autoRotateTimer=null);let r=0;this.autoRotateTimer=Ko(o=>{const s=r?Math.min(o-r,64):16;r=o;const a=t.rotate();t.rotate([a[0]+e*(s/16),a[1]]),i.redrawGlobe()})}redrawGlobe(){if(!this.globePathGen||!this.featurePaths||!this.globeProjection)return;const t=this.globeProjection,[e,i]=t.translate(),r=t.scale();this.featurePaths.attr("d",this.globePathGen),this.mapGroup.selectAll(".katucharts-globe-graticule").attr("d",this.globePathGen),this.mapGroup.select(".katucharts-globe-ocean").attr("cx",e).attr("cy",i).attr("r",r),this.mapGroup.select(".katucharts-globe-atmosphere").attr("cx",e).attr("cy",i).attr("r",r+15),this.mapGroup.select(".katucharts-globe-specular").attr("cx",e).attr("cy",i).attr("r",r),this.mapGroup.select(".katucharts-globe-shadow").attr("cx",e+8).attr("cy",i+r+18).attr("rx",r*.6),this.mapGroup.selectAll(".katucharts-map-label").attr("transform",o=>{const s=this.globePathGen.centroid(o);return isFinite(s[0])?`translate(${s[0]},${s[1]})`:"translate(-9999,-9999)"}).attr("display",o=>{const s=this.globePathGen.centroid(o);return isFinite(s[0])?null:"none"})}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class $M extends Ht{constructor(t){super(t)}resolveMapData(){const t=this.config;if(t.mapData)return t.mapData;for(const e of this.context.allSeries||[]){const i=e.config;if(e!==this&&(i!=null&&i.mapData))return i.mapData}return null}render(){var x,v,k;const t=this.config,{plotArea:e}=this.context,i=this.resolveMapData();if(!i)return;const{projection:r,projName:o}=ml(i,t.projection,e,t.mapDataObject);gl(o,t)&&yl(r,e);const s=this.group.append("g").attr("class","katucharts-mapzoom katucharts-mappoint-layer"),a=t.marker||{},c=a.enabled!==!1,l=a.radius??5,h=a.lineColor??"#ffffff",f=a.lineWidth??1,u=t.color||this.getColor(),d=this.context.animate,p=t.dataLabels,y=!!(p!=null&&p.enabled),g=this.autoLabelColor((p==null?void 0:p.color)||((x=p==null?void 0:p.style)==null?void 0:x.color)),m=((v=p==null?void 0:p.style)==null?void 0:v.fontSize)||kt,b=((k=p==null?void 0:p.style)==null?void 0:k.fontWeight)||"600";this.data.forEach((M,C)=>{var w;M.name==null&&M.id!=null&&(M.name=M.id);const E=xl(M);if(!E)return;const _=r(E);if(!_||!isFinite(_[0])||!isFinite(_[1]))return;const[T,I]=_,L=M.color||u,P=((w=M.marker)==null?void 0:w.radius)??l,A=s.append("g").attr("class","katucharts-mappoint");if(c){const S=A.append("circle").attr("class","katucharts-mappoint-marker").attr("cx",T).attr("cy",I).attr("fill",L).attr("stroke",h).attr("stroke-width",f).style("cursor",t.cursor||"pointer").attr("r",d?0:P);d&&S.transition().duration(gt).delay(C*12).ease(dt).attr("r",P),S.on("mouseover",$=>{var R,F;st($.currentTarget).transition("hover").duration(Z).ease(q).attr("r",P*1.4),this.context.events.emit("point:mouseover",{point:M,index:C,series:this,event:$,plotX:T,plotY:I}),(F=(R=M.events)==null?void 0:R.mouseOver)==null||F.call(M,$)}).on("mouseout",$=>{var R,F;st($.currentTarget).transition("hover").duration(Z).ease(q).attr("r",P),this.context.events.emit("point:mouseout",{point:M,index:C,series:this,event:$}),(F=(R=M.events)==null?void 0:R.mouseOut)==null||F.call(M,$)}).on("click",$=>{var R,F,D,z,B,N,K;this.context.events.emit("point:click",{point:M,index:C,series:this,event:$}),(F=(R=M.events)==null?void 0:R.click)==null||F.call(M,$),(B=(z=(D=t.point)==null?void 0:D.events)==null?void 0:z.click)==null||B.call(M,$),(K=(N=t.events)==null?void 0:N.click)==null||K.call(this,$)})}if(y){const S=this.formatLabel(M,C);S&&s.append("text").attr("class","katucharts-mappoint-label").attr("x",T).attr("y",I-P-3).attr("text-anchor","middle").attr("dominant-baseline","auto").attr("font-size",m).attr("font-weight",b).attr("fill",g).style("pointer-events","none").style("text-shadow",this.labelHalo()).text(S)}})}formatLabel(t,e){const i=this.config.dataLabels,r={point:t,series:{name:this.config.name},x:t.id??t.name,y:t.y??t.value};return i!=null&&i.formatter?i.formatter.call(r):i!=null&&i.format?re(Zt(i.format,r)):t.id||t.name||""}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}class IM extends Ht{constructor(t){super(t)}resolveMapData(){const t=this.config;if(t.mapData)return t.mapData;for(const e of this.context.allSeries||[]){const i=e.config;if(e!==this&&(i!=null&&i.mapData))return i.mapData}return null}buildIdMap(){const t=new Map;for(const e of this.context.allSeries||[])if(e!==this)for(const i of e.data){const r=xl(i),o=i.id??i.name;o!=null&&r&&t.set(String(o),r)}return t}resolveEndpoint(t,e){return t==null?null:Array.isArray(t)&&typeof t[0]=="number"?[t[0],t[1]]:typeof t=="object"?xl(t):e.get(String(t))||null}render(){var g;const t=this.config,{plotArea:e}=this.context,i=this.resolveMapData();if(!i)return;const{projection:r,projName:o}=ml(i,t.projection,e,t.mapDataObject);gl(o,t)&&yl(r,e);const s=this.buildIdMap(),a=this.group.append("g").attr("class","katucharts-mapzoom katucharts-flowmap-layer"),c=t.color||this.getColor(),l=t.fillOpacity??.5,h=t.curveFactor??.3,f=((g=t.markerEnd)==null?void 0:g.enabled)!==!1,u=this.context.animate,d=this.data.map(m=>m.weight??m.y??m.value??1),p=Math.max(...d,1),y=t.width!=null?t.width<=1?t.width*40:t.width:16;this.data.forEach((m,b)=>{const x=m,v=this.resolveEndpoint(x.from,s),k=this.resolveEndpoint(x.to,s);if(!v||!k)return;x.name==null&&typeof x.from=="string"&&typeof x.to=="string"&&(x.name=`${x.from} → ${x.to}`);const M=r(v),C=r(k);if(!M||!C||!isFinite(M[0])||!isFinite(C[0]))return;const E=x.weight??x.y??x.value??1,_=Math.max(2,y*(E/p)),T=x.color||c,{d:I,mid:L,tip:P,tipAngle:A}=this.buildFlowPath(M,C,_,h),w=a.append("path").attr("class","katucharts-flowmap-link").attr("d",I).attr("fill",T).attr("fill-opacity",u?0:l).attr("stroke","none").style("cursor",t.cursor||"pointer");if(u&&w.transition().duration(gt).delay(b*30).ease(dt).attr("fill-opacity",l),f){const S=_*1.1+3,$=a.append("path").attr("class","katucharts-flowmap-arrow").attr("d",this.arrowHead(P,A,S)).attr("fill",T).attr("fill-opacity",u?0:l).style("pointer-events","none");u&&$.transition().duration(gt).delay(b*30).ease(dt).attr("fill-opacity",l)}w.on("mouseover",S=>{var $,R;st(S.currentTarget).transition("hover").duration(Z).ease(q).attr("fill-opacity",Math.min(1,l+.3)),this.context.events.emit("point:mouseover",{point:m,index:b,series:this,event:S,plotX:L[0],plotY:L[1]}),(R=($=x.events)==null?void 0:$.mouseOver)==null||R.call(m,S)}).on("mouseout",S=>{var $,R;st(S.currentTarget).transition("hover").duration(Z).ease(q).attr("fill-opacity",l),this.context.events.emit("point:mouseout",{point:m,index:b,series:this,event:S}),(R=($=x.events)==null?void 0:$.mouseOut)==null||R.call(m,S)}).on("click",S=>{var $,R,F,D,z,B,N;this.context.events.emit("point:click",{point:m,index:b,series:this,event:S}),(R=($=x.events)==null?void 0:$.click)==null||R.call(m,S),(z=(D=(F=t.point)==null?void 0:F.events)==null?void 0:D.click)==null||z.call(m,S),(N=(B=t.events)==null?void 0:B.click)==null||N.call(this,S)})})}buildFlowPath(t,e,i,r){const o=e[0]-t[0],s=e[1]-t[1],a=Math.hypot(o,s)||1,c=-s/a,l=o/a,h=[(t[0]+e[0])/2+c*r*a,(t[1]+e[1])/2+l*r*a],f=24,u=Math.max(.6,i*.12),d=i/2,p=[],y=[];let g=t;for(let k=0;k<=f;k++){const M=k/f,C=1-M,E=C*C*t[0]+2*C*M*h[0]+M*M*e[0],_=C*C*t[1]+2*C*M*h[1]+M*M*e[1],T=E-g[0],I=_-g[1],L=Math.hypot(T,I)||1,P=-I/L,A=T/L,w=u+(d-u)*M;p.push([E+P*w,_+A*w]),y.push([E-P*w,_-A*w]),g=[E,_]}const m=.25*t[0]+.5*h[0]+.25*e[0],b=.25*t[1]+.5*h[1]+.25*e[1],x=Math.atan2(e[1]-h[1],e[0]-h[0]);return{d:"M"+p.map(k=>`${k[0].toFixed(2)},${k[1].toFixed(2)}`).join("L")+"L"+y.reverse().map(k=>`${k[0].toFixed(2)},${k[1].toFixed(2)}`).join("L")+"Z",mid:[m,b],tip:e,tipAngle:x}}arrowHead(t,e,i){const r=e,o=r+Math.PI,s=.5,a=[t[0]+Math.cos(r)*i*.6,t[1]+Math.sin(r)*i*.6],c=[t[0]+Math.cos(o+s)*i,t[1]+Math.sin(o+s)*i],l=[t[0]+Math.cos(o-s)*i,t[1]+Math.sin(o-s)*i];return`M${a[0].toFixed(2)},${a[1].toFixed(2)}L${c[0].toFixed(2)},${c[1].toFixed(2)}L${l[0].toFixed(2)},${l[1].toFixed(2)}Z`}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}const Sp=["#5b9bd5","#ed7d31","#70ad47","#9e5fa0","#ffc000","#44546a"],FM=/^(.+?)\s+(\([^()]+\))\s*$/,_p=1.15;function Cp(n,t,e){for(;n.firstChild;)n.removeChild(n.firstChild);let i;if(t.includes(`
8
8
  `))i=t.split(`
9
- `);else{const a=t.match(LM);i=a?[a[1],a[2]]:[t]}const r="http://www.w3.org/2000/svg",o=i.length,s=o>1?-((o-1)*_p)/2:0;i.forEach((a,c)=>{const l=document.createElementNS(r,"tspan");l.setAttribute("x",String(e)),l.setAttribute("dy",`${c===0?s:_p}em`),l.textContent=a,n.appendChild(l)})}const $M={Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"};class IM extends Xt{constructor(t){super(t),this.selectedIndices=new Set,t.showInLegend=!1,t.clip=!1}render(){var E;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=r.filter(_=>{var T;return((T=_.sets)==null?void 0:T.length)===1}),s=r.filter(_=>{var T;return((T=_.sets)==null?void 0:T.length)>=2});if(o.length===0)return;const a=t.width/2,c=t.height/2,l=t.height/2*.92,h=Math.max(...o.map(_=>_.value||_.y||1)),f=this.config.opacity??.25,u=Math.min(1,f+.25),d=.4,p=this.config.borderColor,y=this.config.borderWidth??0,g=this.resolveDashStyle(this.config.borderDashStyle),m=this.config.allowPointSelect===!0,x=new Map;this.layoutSets(o,s,x,a,c,l,h,e,t);const v=Array.from(x.values()),b=[];for(const _ of o){const T=x.get(_.sets[0]);if(!T)continue;let I=T.cx,L=T.cy;const P=v.filter(A=>A.id!==T.id);if(P.length>0){let A=0,w=0;for(const $ of P){const R=T.cx-$.cx,F=T.cy-$.cy,D=Math.sqrt(R*R+F*F)||1;A+=R/D,w+=F/D}const S=Math.sqrt(A*A+w*w)||1;I=T.cx+A/S*T.r*.7,L=T.cy+w/S*T.r*.7}b.push({sets:_.sets,value:_.value||_.y||0,name:_.name||_.sets[0],color:_.color||T.color,path:this.circlePath(T.cx,T.cy,T.r),labelX:I,labelY:L,data:_,order:1,key:_.sets.join("_")})}for(const _ of s){if(_.sets.length!==2)continue;const T=x.get(_.sets[0]),I=x.get(_.sets[1]);if(!T||!I)continue;const L=this.lensPath(T,I);if(!L)continue;const P=_.color||this.blendColors(T.color,I.color);b.push({sets:_.sets,value:_.value||_.y||0,name:_.name||`${_.sets.join(" ∩ ")} (${_.value||_.y||0})`,color:P,path:L.path,labelX:L.cx,labelY:L.cy,data:_,order:2,key:[..._.sets].sort().join("_")})}for(const _ of s){if(_.sets.length!==3)continue;const T=_.sets.map(P=>x.get(P)).filter(Boolean);if(T.length<3)continue;const I=this.triIntersectionPath(T[0],T[1],T[2]);if(!I)continue;const L=_.color||this.blendColors(T[0].color,T[1].color,T[2].color);b.push({sets:_.sets,value:_.value||_.y||0,name:_.name||`${_.sets.join(" ∩ ")} (${_.value||_.y||0})`,color:L,path:I.path,labelX:I.cx,labelY:I.cy,data:_,order:3,key:[..._.sets].sort().join("_")})}b.sort((_,T)=>_.order-T.order);const M=(((E=this.config.accessibility)==null?void 0:E.point)||{}).descriptionFormatter,C=this.group.selectAll(".katucharts-venn-area").data(b,_=>_.key).join(_=>{const T=_.append("g").attr("class",I=>`katucharts-venn-area katucharts-venn-${I.sets.length===1?"circle-area":"intersection-area"}`).attr("data-venn-sets",I=>I.sets.join("_"));return T.append("path"),T},_=>_,_=>_.remove());C.attr("class",_=>`katucharts-venn-area katucharts-venn-${_.sets.length===1?"circle-area":"intersection-area"}`),C.select("path").attr("d",_=>_.path).attr("fill",_=>_.color).attr("fill-opacity",_=>_.sets.length===1?f:0).attr("stroke",_=>_.sets.length===1?p||_.color:"none").attr("stroke-width",_=>_.sets.length===1?y:0).attr("stroke-dasharray",g).attr("role","img").attr("aria-label",_=>M?M({name:_.name,value:_.value,sets:_.sets}):`${_.name}: ${_.value}`).style("cursor",this.config.cursor||"pointer"),C.sort((_,T)=>_.order-T.order),C.each(function(_){if(_.sets.length>=2){const I=this.querySelector("path");if(I)try{const L=I.getBBox();L.width>0&&L.height>0&&(_.labelX=L.x+L.width/2,_.labelY=L.y+L.height/2)}catch{}}}),i&&C.select("path").attr("opacity",0).transition().duration(bt).ease(pt).delay((_,T)=>T*Nt).attr("opacity",1),this.config.enableMouseTracking!==!1&&this.attachEvents(C,b,f,u,d,m),this.renderLabels(b,i??!1)}resolveDashStyle(t){return t&&$M[t]||"none"}attachEvents(t,e,i,r,o,s){var c,l;(l=(c=this.config.dataLabels)==null?void 0:c.intersections)==null||l.enabled;const a=()=>this.group.selectAll(".katucharts-venn-inter-label");t.on("mouseover",(h,f)=>{var y,g,m;const u=e.indexOf(f),d=f.sets.length>=2;st(h.currentTarget).select("path").transition("hover").duration(Z).ease(j).attr("fill-opacity",d?o:r),d&&a().filter(x=>x.sets.length===f.sets.length&&x.sets.every(v=>f.sets.includes(v))).transition("label").duration(Z).ease(j).attr("opacity",1),this.context.events.emit("point:mouseover",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h,plotX:f.labelX,plotY:f.labelY}),(m=(g=(y=f.data)==null?void 0:y.events)==null?void 0:g.mouseOver)==null||m.call(f.data,h)}).on("mouseout",(h,f)=>{var y,g,m;const u=e.indexOf(f),d=f.sets.length>=2;st(h.currentTarget).select("path").transition("hover").duration(Z).ease(j).attr("fill-opacity",d?0:i),a().filter(function(){return this.__autoHidden===!0}).transition("label").duration(Z).ease(j).attr("opacity",0),this.context.events.emit("point:mouseout",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h}),(m=(g=(y=f.data)==null?void 0:y.events)==null?void 0:g.mouseOut)==null||m.call(f.data,h)}).on("click",(h,f)=>{var p,y,g,m,x,v,b,k,M,C,E,_,T;const u=e.indexOf(f);s&&(this.selectedIndices.has(u)?(this.selectedIndices.delete(u),(g=(y=(p=f.data)==null?void 0:p.events)==null?void 0:y.unselect)==null||g.call(f.data,h)):(this.selectedIndices.add(u),(v=(x=(m=f.data)==null?void 0:m.events)==null?void 0:x.select)==null||v.call(f.data,h))),this.context.events.emit("point:click",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h}),(M=(k=(b=f.data)==null?void 0:b.events)==null?void 0:k.click)==null||M.call(f.data,h),(E=(C=this.config.events)==null?void 0:C.click)==null||E.call(this,h);const d=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click;d&&d.call({...f.data,sets:f.sets,name:f.name,value:f.value},h)})}renderLabels(t,e){var u,d,p,y;const i=this.config.dataLabels||{},r=i.enabled!==!1,o=((u=i.intersections)==null?void 0:u.enabled)!==!1,s=((d=i.style)==null?void 0:d.fontSize)||kt,a=i.color||((p=i.style)==null?void 0:p.color)||Le,c=((y=i.style)==null?void 0:y.fontWeight)||"bold",l=t.filter(g=>g.sets.length===1),h=t.filter(g=>g.sets.length>=2);if(r){const g=this.group.selectAll(".katucharts-venn-set-label").data(l,m=>m.key).join("text").attr("class","katucharts-venn-set-label").attr("x",m=>m.labelX).attr("y",m=>m.labelY).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",s).attr("font-weight",c).attr("fill",a).style("pointer-events","none").style("text-shadow","0 0 4px #fff, 0 0 4px #fff");g.each((m,x,v)=>{const b=i.formatter?i.formatter.call({point:{name:m.name,y:m.value,sets:m.sets},series:{name:this.config.name},x:m.name,y:m.value}):m.name;Cp(v[x],String(b??""),m.labelX)}),e&&g.attr("opacity",0).transition().duration(bt).ease(pt).attr("opacity",1)}const f=this.group.selectAll(".katucharts-venn-inter-label").data(h,g=>g.key).join("text").attr("class","katucharts-venn-inter-label").attr("x",g=>g.labelX).attr("y",g=>g.labelY).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",kt).attr("fill",Le).style("pointer-events","none").style("text-shadow","0 0 3px #fff, 0 0 3px #fff").attr("opacity",o?1:0);if(f.each((g,m,x)=>{Cp(x[m],g.name,g.labelX)}),o){const g=this.group;f.each(function(m){const x=this,v=g.select(`[data-venn-sets="${m.sets.join("_")}"]`).node(),b=v==null?void 0:v.querySelector("path");if(b)try{const k=x.getBBox(),M=b.getBBox(),C=k.width<=M.width*.95&&k.height<=M.height*.95;x.setAttribute("opacity",C?"1":"0"),x.__autoHidden=!C}catch{}})}}layoutSets(t,e,i,r,o,s,a,c,l){var P,A;const h=t.length,f=t.map(w=>w.sets[0]),u=t.map(w=>s*Math.sqrt((w.value||w.y||1)/a)),d=new Map;for(const w of e){if(((P=w.sets)==null?void 0:P.length)!==2)continue;const[S,$]=w.sets,R=f.indexOf(S),F=f.indexOf($);if(R<0||F<0)continue;const D=w.value||w.y||0;if(D<=0)d.set(`${R}-${F}`,u[R]+u[F]+5);else{const z=Math.PI*s*s*(D/a);d.set(`${R}-${F}`,this.findDistance(u[R],u[F],z))}}const p=new Array(h),y=new Set,g=new Array(h).fill(0);for(const w of e){if(((A=w.sets)==null?void 0:A.length)!==2)continue;const S=w.value||w.y||0;for(const $ of w.sets){const R=f.indexOf($);R>=0&&(g[R]+=S)}}const m=Array.from({length:h},(w,S)=>S).sort((w,S)=>g[S]-g[w]);p[m[0]]=[0,0],y.add(m[0]);for(let w=1;w<h;w++){const S=m[w];let $=[0,0],R=1/0;const F=[];for(const D of y){const z=D<S?`${D}-${S}`:`${S}-${D}`,B=d.get(z)??(u[D]+u[S])*1.1,[W,K]=p[D];for(let X=0;X<12;X++){const q=2*Math.PI*X/12;F.push([W+B*Math.cos(q),K+B*Math.sin(q)])}}for(const[D,z]of F){let B=0;for(const W of y){const K=W<S?`${W}-${S}`:`${S}-${W}`,X=d.get(K)??(u[W]+u[S])*1.1,q=Math.sqrt((D-p[W][0])**2+(z-p[W][1])**2);B+=(q-X)**2}B<R&&(R=B,$=[D,z])}p[S]=$,y.add(S)}h>=3&&this.optimizePositions(p,u,d,h);let x=1/0,v=-1/0,b=1/0,k=-1/0;for(let w=0;w<h;w++)x=Math.min(x,p[w][0]-u[w]),v=Math.max(v,p[w][0]+u[w]),b=Math.min(b,p[w][1]-u[w]),k=Math.max(k,p[w][1]+u[w]);const M=v-x||1,C=k-b||1,E=l?l.width*.95:s*2,_=l?l.height*.95:s*2,T=Math.min(E/M,_/C),I=(x+v)/2,L=(b+k)/2;for(let w=0;w<h;w++){const S=r+(p[w][0]-I)*T,$=o+(p[w][1]-L)*T,R=u[w]*T;i.set(f[w],{id:f[w],cx:S,cy:$,r:R,color:t[w].color||Sp[w%Sp.length]})}}optimizePositions(t,e,i,r){const o=u=>{let d=0;for(let p=0;p<r;p++)for(let y=p+1;y<r;y++){const g=`${p}-${y}`,m=i.get(g)??(e[p]+e[y])*1.1,x=u[p*2]-u[y*2],v=u[p*2+1]-u[y*2+1],b=Math.sqrt(x*x+v*v);d+=(b-m)**2}return d},s=new Array(r*2);for(let u=0;u<r;u++)s[u*2]=t[u][0],s[u*2+1]=t[u][1];const a=r*2,c=[s.slice()];for(let u=0;u<a;u++){const d=s.slice();d[u]+=e[Math.floor(u/2)]*.3,c.push(d)}const l=c.map(u=>o(u));for(let u=0;u<200;u++){let d=0,p=0;for(let x=1;x<=a;x++)l[x]<l[d]&&(d=x),l[x]>l[p]&&(p=x);if(l[p]-l[d]<.01)break;const y=new Array(a).fill(0);for(let x=0;x<=a;x++)if(x!==p)for(let v=0;v<a;v++)y[v]+=c[x][v];for(let x=0;x<a;x++)y[x]/=a;const g=y.map((x,v)=>2*x-c[p][v]),m=o(g);if(m<l[d]){const x=y.map((b,k)=>3*b-2*c[p][k]),v=o(x);v<m?(c[p]=x,l[p]=v):(c[p]=g,l[p]=m)}else if(m<l[p])c[p]=g,l[p]=m;else{const x=y.map((b,k)=>.5*(b+c[p][k])),v=o(x);if(v<l[p])c[p]=x,l[p]=v;else for(let b=0;b<=a;b++)if(b!==d){for(let k=0;k<a;k++)c[b][k]=.5*(c[d][k]+c[b][k]);l[b]=o(c[b])}}}let h=0;for(let u=1;u<=a;u++)l[u]<l[h]&&(h=u);const f=c[h];for(let u=0;u<r;u++)t[u]=[f[u*2],f[u*2+1]]}circlePath(t,e,i){return`M${t-i},${e}A${i},${i},0,1,1,${t+i},${e}A${i},${i},0,1,1,${t-i},${e}Z`}lensPath(t,e){const i=e.cx-t.cx,r=e.cy-t.cy,o=Math.sqrt(i*i+r*r);if(o>=t.r+e.r)return null;if(o<=Math.abs(t.r-e.r)){const m=t.r<e.r?t:e;return{path:this.circlePath(m.cx,m.cy,m.r),cx:m.cx,cy:m.cy}}const s=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=Math.sqrt(t.r*t.r-s*s),c=t.cx+s*i/o,l=t.cy+s*r/o,h=c+a*r/o,f=l-a*i/o,u=c-a*r/o,d=l+a*i/o,p=s<0?1:0,y=o-s<0?1:0;return{path:`M${h},${f}A${t.r},${t.r},0,${p},1,${u},${d}A${e.r},${e.r},0,${y},1,${h},${f}Z`,cx:c,cy:l}}triIntersectionPath(t,e,i){const r=this.circleIntersectionPoints(t,e),o=this.circleIntersectionPoints(t,i),s=this.circleIntersectionPoints(e,i);if(!r||!o||!s)return null;const c=[...r,...o,...s].filter(u=>this.insideCircle(u,t)&&this.insideCircle(u,e)&&this.insideCircle(u,i));if(c.length<3)return null;const l=c.reduce((u,d)=>u+d[0],0)/c.length,h=c.reduce((u,d)=>u+d[1],0)/c.length;c.sort((u,d)=>Math.atan2(u[1]-h,u[0]-l)-Math.atan2(d[1]-h,d[0]-l));let f=`M${c[0][0]},${c[0][1]}`;for(let u=0;u<c.length;u++){const d=c[u],p=c[(u+1)%c.length],y=this.findArcCircle(d,p,[t,e,i]);y?f+=`A${y.r},${y.r},0,0,1,${p[0]},${p[1]}`:f+=`L${p[0]},${p[1]}`}return f+="Z",{path:f,cx:l,cy:h}}circleIntersectionPoints(t,e){const i=e.cx-t.cx,r=e.cy-t.cy,o=Math.sqrt(i*i+r*r);if(o>=t.r+e.r||o<=Math.abs(t.r-e.r))return null;const s=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=Math.sqrt(Math.max(0,t.r*t.r-s*s)),c=t.cx+s*i/o,l=t.cy+s*r/o;return[[c+a*r/o,l-a*i/o],[c-a*r/o,l+a*i/o]]}insideCircle(t,e){const i=t[0]-e.cx,r=t[1]-e.cy;return i*i+r*r<=(e.r+.5)*(e.r+.5)}findArcCircle(t,e,i){const r=(t[0]+e[0])/2,o=(t[1]+e[1])/2;for(const s of i){const a=Math.sqrt((t[0]-s.cx)**2+(t[1]-s.cy)**2),c=Math.sqrt((e[0]-s.cx)**2+(e[1]-s.cy)**2),l=Math.sqrt((r-s.cx)**2+(o-s.cy)**2);if(Math.abs(a-s.r)<1&&Math.abs(c-s.r)<1&&l<=s.r+1)return s}return null}blendColors(...t){let e=0,i=0,r=0;for(const s of t){const a=je(ce(s)||s);e+=a.r,i+=a.g,r+=a.b}const o=t.length||1;return je(Math.round(e/o*.85),Math.round(i/o*.85),Math.round(r/o*.85)).formatHex()}findDistance(t,e,i){if(i<=0)return t+e+10;const r=Math.PI*Math.min(t,e)**2;if(i>=r)return Math.abs(t-e);let o=Math.abs(t-e),s=t+e;for(let a=0;a<50;a++){const c=(o+s)/2;this.lensArea(t,e,c)>i?o=c:s=c}return(o+s)/2}lensArea(t,e,i){if(i>=t+e)return 0;if(i<=Math.abs(t-e))return Math.PI*Math.min(t,e)**2;const r=(t*t-e*e+i*i)/(2*i),o=t*t-r*r;return o<0?0:t*t*Math.acos(r/t)-r*Math.sqrt(o)+e*e*Math.acos((i-r)/e)-(i-r)*Math.sqrt(e*e-(i-r)*(i-r))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function FM(n,t=0){return n===void 0?t:typeof n=="number"?n:n.radius??t}const RM=["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1","#7798bf","#aaeeee","#ff0066","#eeaaee","#55bf3b","#df5353","#7798bf","#aaeeee"];class DM extends Xt{constructor(t){super(t),this.keyframes=[],this.currentFrameIndex=0,this.colorMap=new Map,this.timer=null,this.playing=!1,this.controlsEl=null,this.playBtn=null,this.rangeInput=null,this.rangeLabel=null}processData(){var o;const t=this.config.data;if(!Array.isArray(t))return;this.keyframes=t.filter(s=>s&&s.date&&Array.isArray(s.values));const e=new Set;for(const s of this.keyframes)for(const a of s.values)e.add(a.name);const i=this.config.colors||((o=this.context)==null?void 0:o.colors)||RM;let r=0;for(const s of e)this.colorMap.has(s)||(this.colorMap.set(s,i[r%i.length]),r++)}render(){if(this.keyframes.length===0)return;const{plotArea:t}=this.context,e=this.config,i=40,r=30;this.axisGroup=this.group.append("g").attr("class","katucharts-race-axis").attr("transform",`translate(0,${r})`),this.barsGroup=this.group.append("g").attr("class","katucharts-race-bars").attr("transform",`translate(0,${r+5})`),this.tickerText=this.group.append("text").attr("class","katucharts-race-ticker").attr("x",t.width-10).attr("y",t.height-i-10).attr("text-anchor","end").attr("font-size",e.tickerFontSize||"48px").attr("font-weight","bold").attr("fill",e.tickerColor||"#ddd").style("pointer-events","none"),this.renderControls(),this.currentFrameIndex=0,this.renderFrame(0,!1),e.autoPlay!==!1&&this.play()}renderControls(){var e,i,r;const t=(i=(e=this.group.node())==null?void 0:e.closest("svg"))==null?void 0:i.parentElement;t&&(this.controlsEl=document.createElement("div"),this.controlsEl.style.cssText="position:absolute;bottom:8px;left:12px;right:12px;display:flex;align-items:center;gap:8px;z-index:10;",this.playBtn=document.createElement("button"),this.playBtn.innerHTML=this.pauseIcon(),this.playBtn.style.cssText="width:32px;height:32px;border:none;border-radius:50%;background:#2f7ed8;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;flex-shrink:0;box-shadow:0 1px 3px rgba(0,0,0,0.2);transition:background 0.15s;",this.playBtn.onmouseenter=()=>{this.playBtn&&(this.playBtn.style.background="#1a5fa8")},this.playBtn.onmouseleave=()=>{this.playBtn&&(this.playBtn.style.background="#2f7ed8")},this.playBtn.onclick=()=>{this.playing?this.pause():this.currentFrameIndex>=this.keyframes.length-1?this.restart():this.play()},this.rangeInput=document.createElement("input"),this.rangeInput.type="range",this.rangeInput.min="0",this.rangeInput.max=String(this.keyframes.length-1),this.rangeInput.value="0",this.rangeInput.style.cssText="flex:1;height:4px;cursor:pointer;accent-color:#2f7ed8;",this.rangeInput.oninput=()=>{const o=parseInt(this.rangeInput.value,10),s=this.playing;s&&this.pause(),this.goToFrame(o),s&&this.play()},this.rangeLabel=document.createElement("span"),this.rangeLabel.style.cssText='font-size:11px;color:#666;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;min-width:30px;text-align:right;flex-shrink:0;',this.rangeLabel.textContent=((r=this.keyframes[0])==null?void 0:r.date)||"",this.controlsEl.appendChild(this.playBtn),this.controlsEl.appendChild(this.rangeInput),this.controlsEl.appendChild(this.rangeLabel),t.appendChild(this.controlsEl))}updateControls(){this.rangeInput&&(this.rangeInput.value=String(this.currentFrameIndex)),this.rangeLabel&&this.keyframes[this.currentFrameIndex]&&(this.rangeLabel.textContent=this.keyframes[this.currentFrameIndex].date),this.playBtn&&(this.playBtn.innerHTML=this.playing?this.pauseIcon():this.playIcon())}playIcon(){return'<svg width="14" height="14" viewBox="0 0 14 14"><polygon points="3,1 12,7 3,13" fill="currentColor"/></svg>'}pauseIcon(){return'<svg width="14" height="14" viewBox="0 0 14 14"><rect x="2" y="1" width="3.5" height="12" rx="0.5" fill="currentColor"/><rect x="8.5" y="1" width="3.5" height="12" rx="0.5" fill="currentColor"/></svg>'}renderFrame(t,e){if(t<0||t>=this.keyframes.length)return;const{plotArea:i}=this.context,r=this.config,o=r.barsToShow??12,s=r.barPadding??.1,a=FM(r.borderRadius,3),c=r.frameDuration??500,l=e?r.transitionDuration??c:0,u=i.height-35-40-20,d=this.keyframes[t],y=[...d.values].sort((E,_)=>_.value-E.value).slice(0,o),g=y.length>0?y[0].value:1;this.valueScale=ke().domain([0,g*1.1]).range([0,i.width-80]),this.renderAxis(l);const m=u/o*(1-s),x=u/o,v=E=>E.name,b=this.barsGroup.selectAll(".katucharts-race-bar").data(y,v),k=b.enter().append("g").attr("class","katucharts-race-bar").attr("transform",(E,_)=>`translate(0,${e?u+m:_*x})`).style("opacity",e?0:1);k.append("rect").attr("height",m).attr("rx",a).attr("width",E=>e?0:Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),k.append("text").attr("class","katucharts-race-label").attr("x",6).attr("y",m/2).attr("dy","0.35em").attr("fill","#fff").attr("font-weight","bold").attr("font-size",kt).style("pointer-events","none").text(E=>E.name),k.append("text").attr("class","katucharts-race-value").attr("y",m/2).attr("dy","0.35em").attr("fill",Le).attr("font-weight","bold").attr("font-size",kt).style("pointer-events","none").attr("data-value",E=>E.value).attr("x",E=>Math.max(0,this.valueScale(E.value))+5).text(E=>E.value.toLocaleString());const M=k.merge(b);l>0?(M.transition().duration(l).ease(Sr).attr("transform",(E,_)=>`translate(0,${_*x})`).style("opacity",1),M.select("rect").transition().duration(l).ease(Sr).attr("width",E=>Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),M.select(".katucharts-race-value").transition().duration(l).ease(Sr).attr("x",E=>Math.max(0,this.valueScale(E.value))+5).tween("text",function(E){const _=this,T=parseFloat(_.getAttribute("data-value")||"0"),I=E.value;return L=>{const P=Math.round(T+(I-T)*L);_.textContent=P.toLocaleString(),_.setAttribute("data-value",String(P))}})):(M.attr("transform",(E,_)=>`translate(0,${_*x})`).style("opacity",1),M.select("rect").attr("width",E=>Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),M.select(".katucharts-race-value").attr("x",E=>Math.max(0,this.valueScale(E.value))+5).attr("data-value",E=>E.value).text(E=>E.value.toLocaleString())),M.select(".katucharts-race-label").style("display",E=>this.valueScale(E.value)<50?"none":"");const C=b.exit();l>0?C.transition().duration(l).ease(Sr).attr("transform",`translate(0,${u+m})`).style("opacity",0).remove():C.remove(),this.tickerText.text(d.date),this.updateControls(),this.attachBarHoverEffects(M,m)}renderAxis(t){const e=Ka(this.valueScale).ticks(5).tickSize(-this.context.plotArea.height+110).tickFormat(i=>{const r=i;return r>=1e9?(r/1e9).toFixed(1)+"B":r>=1e6?(r/1e6).toFixed(1)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toString()});t>0?this.axisGroup.transition().duration(t).ease(Sr).call(e):this.axisGroup.call(e),this.axisGroup.select(".domain").remove(),this.axisGroup.selectAll(".tick line").attr("stroke","#e0e0e0").attr("stroke-dasharray","2,2"),this.axisGroup.selectAll(".tick text").attr("fill",Le).attr("font-size",kt)}attachBarHoverEffects(t,e){const i=this;t.style("cursor","pointer").on("mouseover",function(r,o){const a=st(this).select("rect"),c=a.attr("fill");a.attr("data-orig-fill",c),a.attr("fill",i.brightenColor(c,.1)),a.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),t.filter(l=>l.name!==o.name).style("opacity","0.5"),i.context.events.emit("point:mouseover",{point:{name:o.name,y:o.value},index:0,series:i,event:r,plotX:i.valueScale(o.value),plotY:0})}).on("mouseout",function(r,o){const a=st(this).select("rect"),c=a.attr("data-orig-fill")||"";a.attr("fill",c),a.style("filter",""),t.style("opacity",""),i.context.events.emit("point:mouseout",{point:{name:o.name,y:o.value},index:0,series:i,event:r})})}play(){if(this.playing)return;this.playing=!0,this.updateControls();const t=this.config,e=t.frameDuration??500;this.timer=setInterval(()=>{if(this.currentFrameIndex++,this.currentFrameIndex>=this.keyframes.length)if(t.loop)this.currentFrameIndex=0;else{this.currentFrameIndex=this.keyframes.length-1,this.pause();return}this.renderFrame(this.currentFrameIndex,!0)},e)}pause(){this.playing=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.updateControls()}restart(){this.pause(),this.currentFrameIndex=0,this.renderFrame(0,!0),this.play()}goToFrame(t){t<0||t>=this.keyframes.length||(this.currentFrameIndex=t,this.renderFrame(t,!0))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}destroy(){this.pause(),this.controlsEl&&(this.controlsEl.remove(),this.controlsEl=null),super.destroy()}brightenColor(t,e){const i=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i){const r=Math.min(255,parseInt(i[1],16)+Math.round(255*e)),o=Math.min(255,parseInt(i[2],16)+Math.round(255*e)),s=Math.min(255,parseInt(i[3],16)+Math.round(255*e));return`rgb(${r},${o},${s})`}return t}}function zM(n){return n!=null&&n!==""}function ir(n){return n===void 0?"":String(n)}function BM(n,t){if(!t.has(n))return t.add(n),n;let e=2,i=`${n}__${e}`;for(;t.has(i);)e+=1,i=`${n}__${e}`;return t.add(i),i}function OM(n){const t=n.filter(h=>zM(h.id));if(!t.length)return[];const e=new Set(t.map(h=>ir(h.id))),i=new Set;for(const h of t){const f=ir(h.parent);f&&!e.has(f)&&i.add(f)}const o=[...Array.from(i).map(h=>({id:h,parent:"",name:h})),...t],s=o.reduce((h,f)=>{const u=ir(f.id);return h.set(u,(h.get(u)||0)+1),h},new Map),a=new Set,c=new Map,l=new Map;return o.forEach((h,f)=>{const u=ir(h.id),d=ir(h.parent),y=(s.get(u)||0)>1?`${d||"root"}::${u}::${f}`:u,g=BM(y,a);c.set(h,g),l.has(u)||l.set(u,g)}),o.map(h=>{const f=ir(h.parent),u=f&&l.get(f)||"";return{...h,id:c.get(h),parent:u,name:h.name??String(h.id)}})}class NM extends Xt{constructor(t){super(t),t.clip=!1}render(){var _,T,I;const{plotArea:t,colors:e}=this.context,i=this.data||[];if(!i.length)return;const r=this.config.layout==="vertical"?"vertical":"horizontal",o=this.config.link||{},s=((_=this.config.marker)==null?void 0:_.radius)??6,a=o.color||"#cccccc",c=o.lineWidth??1,l=this.config.layoutAlgorithm==="cluster",h=this.config.levels||[],f=this.config.dataLabels||{},u=((T=f.style)==null?void 0:T.fontSize)||kt,d=f.color||((I=f.style)==null?void 0:I.color)||Le,p=this.buildRoot(i);if(!p)return;const y=r==="horizontal"?[t.height,t.width]:[t.width,t.height],g=l?Bw():dk();g.size(y),g(p);const m=L=>r==="horizontal"?L.y:L.x,x=L=>r==="horizontal"?L.x:L.y,v=r==="horizontal"?R2().x(L=>m(L)).y(L=>x(L)):D2().x(L=>m(L)).y(L=>x(L)),b=this.group.append("g").attr("class","katucharts-treegraph"),k=p.descendants(),M=p.links(),C=L=>{const P=h.find(A=>A.level===L);return P!=null&&P.color?P.color:e[L%Math.max(1,e.length)]||"#2f7ed8"};b.append("g").attr("class","katucharts-treegraph-links").selectAll("path").data(M).join("path").attr("d",L=>v(L)).attr("fill","none").attr("stroke",a).attr("stroke-width",c);const E=b.append("g").attr("class","katucharts-treegraph-nodes").selectAll("g").data(k).join("g").attr("transform",L=>`translate(${m(L)},${x(L)})`);E.append("circle").attr("r",s).attr("fill",L=>{var P;return((P=L.data)==null?void 0:P.color)||C(L.depth)}).attr("stroke",this.autoBorderColor()).attr("stroke-width",1),f.enabled!==!1&&E.append("text").attr("dy",r==="horizontal"?"0.32em":s+12).attr("x",r==="horizontal"?L=>L.children?-(s+4):s+4:0).attr("text-anchor",r==="horizontal"?L=>L.children?"end":"start":"middle").attr("font-size",u).attr("fill",d).style("pointer-events","none").text(L=>{var P,A;return((P=L.data)==null?void 0:P.name)??((A=L.data)==null?void 0:A.id)??""}),this.context.animate&&b.attr("opacity",0).transition().duration(bt).ease(pt).attr("opacity",1)}buildRoot(t){if(t.some(o=>o.children&&o.children.length>0))return Zi({name:"root",children:t},o=>o.children);const i=OM(t);if(!i.length)return null;if(!(i.filter(o=>!o.parent).length<=1)){const o="__katu_treegraph_root__",s=i.map(a=>({...a,parent:a.parent||o}));return s.push({id:o,parent:"",name:""}),zc().id(a=>String(a.id)).parentId(a=>a.parent?String(a.parent):null)(s)}return zc().id(o=>String(o.id)).parentId(o=>o.parent?String(o.parent):null)(i)}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}class WM extends Xt{constructor(t){super(t),t.clip=!1}render(){var b,k,M,C,E;const{plotArea:t,colors:e}=this.context,i=this.data||[];if(!i.length)return;const r=this.config.minFontSize??8,o=this.config.maxFontSize??50,s=this.config.rotation||{},a=Array.isArray(s.orientations)?s.orientations:s.from!==void 0&&s.to!==void 0?[s.from,s.to]:[0],c=((k=(b=this.config.dataLabels)==null?void 0:b.style)==null?void 0:k.fontFamily)||"sans-serif",l=((M=this.config.dataLabels)==null?void 0:M.color)||((E=(C=this.config.dataLabels)==null?void 0:C.style)==null?void 0:E.color)||Le,h=[...i].filter(_=>_&&_.name&&typeof _.weight=="number"&&_.weight>0).sort((_,T)=>T.weight-_.weight);if(!h.length)return;const f=h[h.length-1].weight,u=h[0].weight,d=_=>{if(u===f)return(r+o)/2;const T=(_-f)/(u-f);return r+T*(o-r)},p=t.width/2,y=t.height/2,g=[],m=this.group.append("g").attr("class","katucharts-wordcloud"),{measure:x,dispose:v}=this.createMeasurer(m.node(),c);try{h.forEach((_,T)=>{const I=d(_.weight),L=a[T%a.length]??0,P=x(_.name,I),A=P.width,w=P.height,S=this.findSpiralSpot(p,y,A,w,L,g,t.width,t.height);S&&g.push({x:S.x,y:S.y,width:A,height:w,word:_,rotation:L,fontSize:I})})}finally{v()}g.forEach((_,T)=>{const I=_.word.color||e[T%Math.max(1,e.length)]||l;m.append("text").attr("x",_.x).attr("y",_.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("transform",_.rotation?`rotate(${_.rotation},${_.x},${_.y})`:null).attr("font-size",_.fontSize).attr("font-family",c).attr("fill",I).style("pointer-events","none").text(_.word.name)}),this.context.animate&&m.attr("opacity",0).transition().duration(bt).ease(pt).attr("opacity",1)}createMeasurer(t,e){const i=t.ownerSVGElement||t,o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("visibility","hidden"),o.setAttribute("font-family",e),i.appendChild(o),{measure:(a,c)=>{o.setAttribute("font-size",String(c)),o.textContent=a;try{const l=o.getBBox();return{width:l.width,height:l.height||c}}catch{return{width:a.length*c*.55,height:c}}},dispose:()=>o.remove()}}findSpiralSpot(t,e,i,r,o,s,a,c){const l=o%180!==0,h=l?r:i,f=l?i:r,u=.2,d=4*Math.PI*6;for(let p=0;p<d;p+=u){const y=4*p,g=t+y*Math.cos(p),m=e+y*Math.sin(p);if(g-h/2<0||g+h/2>a||m-f/2<0||m+f/2>c)continue;if(!s.some(v=>{const b=v.rotation%180!==0?v.height:v.width,k=v.rotation%180!==0?v.width:v.height;return Math.abs(g-v.x)<(h+b)/2+2&&Math.abs(m-v.y)<(f+k)/2+2}))return{x:g,y:m}}return null}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}function Gs(n,t){return n==null?0:typeof n=="number"?n:typeof n=="string"&&n.trim().endsWith("%")?parseFloat(n)/100*t:parseFloat(n)||0}class Pp extends Xt{constructor(t){super(t),t.showInLegend=t.showInLegend??!0}getMultiLegendItems(){return this.isGrouped()?this.orderedGroups().map(t=>({label:t,color:this.groupColor(t),visible:this.data.some(e=>e.group===t&&e.visible!==!1)})):this.categories().map((t,e)=>({label:t.point.name||t.point.label||`Item ${e+1}`,color:t.color,visible:t.point.visible!==!1}))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}toggleLegendItem(t){if(this.isGrouped()){const i=this.orderedGroups()[t];if(i==null)return null;const r=!this.data.some(o=>o.group===i&&o.visible!==!1);return this.data.forEach(o=>{o.group===i&&(o.visible=r)}),this.redraw(),r}const e=this.categories()[t];return e?(e.point.visible=e.point.visible===!1,this.redraw(),e.point.visible!==!1):null}isGrouped(){return this.data.some(t=>t.group!=null)}orderedGroups(){const t=[];for(const e of this.data){const i=e.group;i!=null&&!t.includes(i)&&t.push(i)}return t}groupColor(t){var r;const e=(r=this.data.find(o=>o.group===t&&o.color))==null?void 0:r.color;if(e)return e;const i=this.orderedGroups().indexOf(t);return this.config.colors?this.config.colors[i%this.config.colors.length]:this.context.colors[i%this.context.colors.length]}render(){const{plotArea:t}=this.context,e=this.config.ignoreHiddenPoint!==!1,i=this.categories().filter(a=>!e||a.point.visible!==!1),r=i.reduce((a,c)=>a+c.seats,0);if(r===0)return;const s=this.config.startAngle!==void 0&&this.config.endAngle!==void 0?this.layoutHemicycle(i,r,t):this.layoutGrid(i,r,t);this.renderSeats(i,s),this.renderItemLabels(i,s),this.context.animate&&this.emitAfterAnimate(bt+Math.min(r,60)*Nt)}categories(){const t=this.isGrouped(),e=[];let i=0;return this.data.forEach((r,o)=>{if(r.y===null||r.y===void 0||(r.y??0)<=0)return;const s=r.group,a=r.color||(t&&s!=null?this.groupColor(s):this.config.colors?this.config.colors[i%this.config.colors.length]:this.context.colors[i%this.context.colors.length]);e.push({point:r,dataIndex:o,color:a,seats:Math.round(r.y??0),group:s}),i++}),e}layoutHemicycle(t,e,i){var C;const r=this.config.center||["50%","50%"],o=Gs(r[0],i.width),s=Gs(r[1],i.height),a=(this.config.startAngle??0)*Math.PI/180,c=(this.config.endAngle??360)*Math.PI/180,l=c-a,h=this.config.itemPadding??.1,f=Math.min(i.width,i.height),u=this.config.size!==void 0?Gs(this.config.size,f)/2:this.fitRadius(o,s,i.width,i.height,a,c)*.96,d=Gs(this.config.innerSize??"40%",u*2)/2;let p=this.config.rows;(!p||p<1)&&(p=this.estimateRows(e,d,u,l));const y=(u-d)/p,g=[];for(let E=0;E<p;E++)g.push(d+y*(E+.5));const m=g.map(E=>E*Math.abs(l)),x=m.reduce((E,_)=>E+_,0)||1,v=VM(m.map(E=>E/x*e),e),b=(C=this.config.marker)==null?void 0:C.radius;let k=b??y/2*(1-h);if(b==null)for(let E=0;E<p;E++){const _=v[E];if(_<=0)continue;const T=2*g[E]*Math.sin(Math.abs(l)/(2*_));k=Math.min(k,T/2*(1-h))}k=Math.max(k,.5);const M=[];for(let E=0;E<p;E++){const _=v[E],T=g[E];for(let I=0;I<_;I++){const L=_===1?.5:(I+.5)/_,P=a+L*l;M.push({x:o+T*Math.sin(P),y:s-T*Math.cos(P),angle:P,ring:E,catIndex:-1})}}return M.sort((E,_)=>E.angle-_.angle||E.ring-_.ring),this.assignSeats(M,t,k,{x:o,y:s})}layoutGrid(t,e,i){var y;const o=Math.max(i.width-16,1),s=Math.max(i.height-8*2,1),a=this.config.itemPadding??.1;let c=this.config.rows;(!c||c<1)&&(c=Math.max(1,Math.round(Math.sqrt(e*s/o))));const l=Math.ceil(e/c),h=o/l,f=s/c,u=((y=this.config.marker)==null?void 0:y.radius)??Math.max(Math.min(h,f)/2*(1-a),.5),d=this.config.layout==="horizontal",p=[];for(let g=0;g<e;g++){const m=d?Math.floor(g/l):g%c,x=d?g%l:Math.floor(g/c);p.push({x:8+h*(x+.5),y:8+f*(m+.5),angle:0,ring:m,catIndex:-1})}return this.assignSeats(p,t,u,{x:i.width/2,y:i.height/2})}assignSeats(t,e,i,r){const o=e.map(()=>({sx:0,sy:0,n:0}));let s=0;for(let c=0;c<e.length;c++)for(let l=0;l<e[c].seats&&s<t.length;l++,s++)t[s].catIndex=c,o[c].sx+=t[s].x,o[c].sy+=t[s].y,o[c].n+=1;const a=o.map(c=>c.n>0?{x:c.sx/c.n,y:c.sy/c.n}:r);return{seats:t.filter(c=>c.catIndex>=0),radius:i,centroids:a}}fitRadius(t,e,i,r,o,s){let a=1/0,c=-1/0,l=1/0,h=-1/0;const f=180;for(let d=0;d<=f;d++){const p=o+(s-o)*(d/f),y=Math.sin(p),g=Math.cos(p);y<a&&(a=y),y>c&&(c=y),g<l&&(l=g),g>h&&(h=g)}const u=[];return c>1e-6&&u.push((i-t)/c),a<-1e-6&&u.push(t/-a),h>1e-6&&u.push(e/h),l<-1e-6&&u.push((r-e)/-l),u.length?Math.max(0,Math.min(...u)):Math.min(i,r)/2}estimateRows(t,e,i,r){const o=Math.abs(r)*(e+i);if(o<=0)return 1;const s=Math.round(Math.sqrt(t*2*(i-e)/o));return Math.max(1,s)}renderSeats(t,e){var c,l;const i=this,r=this.context.animate,o=this.config.borderColor||this.autoBorderColor(),s=this.config.borderWidth??1,a=this.group.selectAll(".katucharts-item-point").data(e.seats).join("circle").attr("class","katucharts-item-point").attr("cx",h=>h.x).attr("cy",h=>h.y).attr("fill",h=>t[h.catIndex].color).attr("stroke",o).attr("stroke-width",s).style("cursor",this.config.cursor||"default");if(r?a.attr("r",0).transition().duration(bt).delay((h,f)=>Lc+xe(f,0,Nt,e.seats.length)).ease(pt).attr("r",e.radius):a.attr("r",e.radius),this.config.enableMouseTracking!==!1){const h=e.radius+2,f=((l=(c=this.config.states)==null?void 0:c.inactive)==null?void 0:l.opacity)??.25,u=this.isGrouped(),d=(p,y)=>u?t[p.catIndex].group===t[y.catIndex].group:p.catIndex===y.catIndex;a.on("mouseover",function(p,y){var m,x,v,b,k;st(this).transition("hover").duration(Z).ease(j).attr("r",h),a.interrupt("fade"),a.filter(M=>!d(M,y)).transition("fade").duration(Z).ease(j).attr("opacity",f),a.filter(M=>d(M,y)).transition("fade").duration(Z).ease(j).attr("opacity",1);const g=t[y.catIndex];i.context.events.emit("point:mouseover",{point:g.point,index:g.dataIndex,series:i,event:p,plotX:y.x,plotY:y.y}),(x=(m=g.point.events)==null?void 0:m.mouseOver)==null||x.call(g.point,p),(k=(b=(v=i.config.point)==null?void 0:v.events)==null?void 0:b.mouseOver)==null||k.call(g.point,p)}).on("mouseout",function(p,y){var m,x;st(this).transition("hover").duration(Z).ease(j).attr("r",e.radius),a.interrupt("fade"),a.transition("fade").duration(Z).ease(j).attr("opacity",1);const g=t[y.catIndex];i.context.events.emit("point:mouseout",{point:g.point,index:g.dataIndex,series:i,event:p}),(x=(m=g.point.events)==null?void 0:m.mouseOut)==null||x.call(g.point,p)}).on("click",function(p,y){var m,x,v,b,k,M,C;const g=t[y.catIndex];i.context.events.emit("point:click",{point:g.point,index:g.dataIndex,series:i,event:p}),(x=(m=g.point.events)==null?void 0:m.click)==null||x.call(g.point,p),(k=(b=(v=i.config.point)==null?void 0:v.events)==null?void 0:b.click)==null||k.call(g.point,p),(C=(M=i.config.events)==null?void 0:M.click)==null||C.call(i,p)})}}renderItemLabels(t,e){var s;const i=this.config.dataLabels;if(!i||!i.enabled)return;const r=this.group.append("g").attr("class","katucharts-item-labels"),o=((s=i.style)==null?void 0:s.fontSize)||kt;t.forEach((a,c)=>{var y,g,m;const l=e.centroids[c];if(!l)return;const h=a.point;let f;i.formatter?f=i.formatter.call({point:h,series:{name:this.config.name},x:h.x,y:h.y}):i.format?f=oe(Kt(i.format,{point:h,series:{name:this.config.name},x:h.x,y:h.y})):f=h.label||h.name||String(h.y);const u=i.color||((y=i.style)==null?void 0:y.color)||gn(a.color),d=r.append("text").attr("x",l.x+(i.x??0)).attr("y",l.y+(i.y??0)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",o).attr("font-weight",((g=i.style)==null?void 0:g.fontWeight)||"bold").attr("fill",u).style("pointer-events","none").text(f),p=this.labelOutline((m=i.style)==null?void 0:m.textOutline,u);p&&d.attr("stroke",p.color).attr("stroke-width",p.width).attr("paint-order","stroke").style("stroke-linejoin","round")})}labelOutline(t,e){if(t===!1||t==="none"||t==="0")return null;const i=gn(e);if(t==null)return{width:3,color:i};const r=/^([\d.]+)px\s+(.+)$/.exec(t.trim());return r?{width:parseFloat(r[1]),color:/contrast/i.test(r[2])?i:r[2].trim()}:{width:3,color:i}}}class HM extends Pp{constructor(t){t.startAngle===void 0&&(t.startAngle=-100),t.endAngle===void 0&&(t.endAngle=100),t.center===void 0&&(t.center=["50%","82%"]),t.innerSize===void 0&&(t.innerSize="40%"),super(t)}}function VM(n,t){const e=n.map(s=>Math.floor(s));let i=e.reduce((s,a)=>s+a,0);const r=n.map((s,a)=>({i:a,frac:s-Math.floor(s)})).sort((s,a)=>a.frac-s.frac);let o=0;for(;i<t&&r.length>0;)e[r[o%r.length].i]+=1,i+=1,o+=1;return e}function Ep(){Tt.registerType("waterfall",Tw),Tt.registerType("funnel",od),Tt.registerType("pyramid",sw),Tt.registerType("treemap",vk),Tt.registerType("sunburst",wk),Tt.registerType("gauge",kk),Tt.registerType("solidgauge",Mk),Tt.registerType("polar",xd),Tt.registerType("radar",xd),Tt.registerType("timeline",Ck),Tt.registerType("gantt",Pk),Tt.registerType("map",PM),Tt.registerType("mappoint",EM),Tt.registerType("flowmap",TM),Tt.registerType("venn",IM),Tt.registerType("barchartrace",DM),Tt.registerType("treegraph",NM),Tt.registerType("wordcloud",WM),Tt.registerType("item",Pp),Tt.registerType("classroom",HM)}class GM extends Xt{constructor(t){super(t),this.selectedIndices=new Set}getCandleStyle(t){const e=t.isUp?t.upLineColor:t.downLineColor;return{fill:t.isUp?t.upColor:t.downColor,stroke:e,wick:e}}getCandleClass(){return"katucharts-candlestick"}render(){var E,_,T,I,L,P,A,w;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.applyDataGrouping(o),a=this.config.pointRange,c=this.config.groupPadding??.2,l=this.config.pointPadding??.1,h=c+l,f=this.config.maxPointWidth??1/0,u=a?Math.max(1,Math.min(f,i.width/Math.max(1,((E=t.domain)==null?void 0:E[1])-((_=t.domain)==null?void 0:_[0])||s.length)*a*(1-h))):Math.max(1,Math.min(f,i.width/s.length*(1-h))),d=this.config.pointWidth??u,p=this.config.color||"#f45b5b",y=this.config.upColor||"#2f7ed8",g=this.config.lineColor||p,m=this.config.upLineColor||y,x=this.config.lineWidth??1,v=((I=(T=this.config.states)==null?void 0:T.inactive)==null?void 0:I.opacity)??.4,b=this.config.allowPointSelect===!0,k=(P=(L=this.config.states)==null?void 0:L.select)==null?void 0:P.color,M=(w=(A=this.config.states)==null?void 0:A.select)==null?void 0:w.borderColor,C=[];for(let S=0;S<s.length;S++){const $=s[S];if($.y===null&&$.open===void 0)continue;const R=$.open??$.y??0,F=$.high??R,D=$.low??R,z=$.close??R,B=t.getPixelForValue($.x??S),W=z>=R,K=this.getCandleStyle({open:R,high:F,low:D,close:z,isUp:W,index:S,data:s,upColor:y,downColor:p,upLineColor:m,downLineColor:g}),X=K.fill,q=K.stroke,N=this.group.append("g").attr("class",this.getCandleClass()).style("cursor",this.config.cursor||"pointer");C.push(N);const H=N.append("line").attr("x1",B).attr("x2",B).attr("stroke",K.wick).attr("stroke-width",x),Y=W?z:R,G=W?R:z,Q=e.getPixelForValue(Y),O=Math.max(1,Math.abs(e.getPixelForValue(G)-e.getPixelForValue(Y))),it=N.append("rect").attr("x",B-d/2).attr("width",d).attr("stroke",q).attr("stroke-width",x).attr("rx",2);if(r){const et=e.getPixelForValue((F+D)/2),ht=xe(S,0,Nt,s.length);H.attr("y1",et).attr("y2",et).transition().duration(bt).ease(pt).delay(ht).attr("y1",e.getPixelForValue(F)).attr("y2",e.getPixelForValue(D)),it.attr("y",et).attr("height",0).attr("fill",X).transition().duration(bt).ease(pt).delay(ht).attr("y",Q).attr("height",O)}else H.attr("y1",e.getPixelForValue(F)).attr("y2",e.getPixelForValue(D)),it.attr("y",Q).attr("height",O).attr("fill",X);this.config.enableMouseTracking!==!1&&N.on("mouseover",et=>{var ft,ct,nt,U;const ht=((ct=(ft=this.config.states)==null?void 0:ft.hover)==null?void 0:ct.lineWidthPlus)??2;N.select("rect").transition("size").duration(Z).ease(j).attr("x",B-d*.7).attr("width",d*1.4),N.select("line").transition("size").duration(Z).ease(j).attr("stroke-width",x+ht),N.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),C.forEach(at=>at.interrupt("highlight")),C.forEach(at=>at.attr("opacity",1)),C.forEach((at,yt)=>{yt!==S&&at.transition("highlight").duration(Z).ease(j).attr("opacity",v)}),this.context.events.emit("point:mouseover",{point:{...$,open:R,high:F,low:D,close:z},index:S,series:this,event:et,plotX:B,plotY:e.getPixelForValue((F+D)/2)}),(U=(nt=$.events)==null?void 0:nt.mouseOver)==null||U.call($,et)}).on("mouseout",et=>{var ht,ft;N.select("rect").transition("size").duration(Z).ease(j).attr("x",B-d/2).attr("width",d),N.select("line").transition("size").duration(Z).ease(j).attr("stroke-width",x),N.style("filter",""),C.forEach(ct=>ct.interrupt("highlight")),C.forEach(ct=>ct.transition("highlight").duration(Z).ease(j).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:$,index:S,series:this,event:et}),(ft=(ht=$.events)==null?void 0:ht.mouseOut)==null||ft.call($,et)}).on("click",et=>{var ht,ft,ct,nt,U,at,yt,St;b&&(this.selectedIndices.has(S)?(this.selectedIndices.delete(S),N.select("rect").attr("stroke-width",x),(ft=(ht=$.events)==null?void 0:ht.unselect)==null||ft.call($,et)):(this.selectedIndices.add(S),N.select("rect").attr("stroke",M||"#000").attr("stroke-width",k?2:x+1),k&&N.select("rect").attr("fill",k),(nt=(ct=$.events)==null?void 0:ct.select)==null||nt.call($,et))),this.context.events.emit("point:click",{point:$,index:S,series:this,event:et}),(at=(U=$.events)==null?void 0:U.click)==null||at.call($,et),(St=(yt=this.config.events)==null?void 0:yt.click)==null||St.call(this,et)})}this.renderCandlestickLabels(s,t,e)}renderCandlestickLabels(t,e,i){var a,c;const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;const o=((a=r.style)==null?void 0:a.fontSize)||kt,s=r.color||((c=r.style)==null?void 0:c.color)||Le;t.forEach((l,h)=>{if(l.y===null&&l.open===void 0)return;const f=l.high??l.open??l.y??0,u=e.getPixelForValue(l.x??h),d=i.getPixelForValue(f);let p;r.formatter?p=r.formatter.call({point:l,series:{name:this.config.name},x:l.x,y:l.y}):r.format?p=oe(Kt(r.format,{point:l,series:{name:this.config.name},x:l.x,y:l.y})):p=String(l.close??l.y??""),this.group.append("text").attr("class","katucharts-candlestick-label").attr("x",u+(r.x??0)).attr("y",d-6+(r.y??0)).attr("text-anchor","middle").attr("font-size",o).attr("fill",s).style("pointer-events","none").text(p)})}applyDataGrouping(t){const e=this.config.dataGrouping;if(!(e!=null&&e.enabled)||!e.units||t.length===0)return t;const i=e.groupPixelWidth??10,{plotArea:r}=this.context,o=r.width/Math.max(1,t.length);if(o>=i)return t;const s=Math.ceil(i/o),a=[];for(let c=0;c<t.length;c+=s){const l=t.slice(c,c+s);if(l.length===0)continue;const h=l[0].open??l[0].y??0,f=l[l.length-1].close??l[l.length-1].y??0;let u=-1/0,d=1/0;for(const p of l)u=Math.max(u,p.high??p.y??0),d=Math.min(d,p.low??p.y??0);a.push({...l[0],x:l[0].x,open:h,high:u,low:d,close:f,y:f})}return a}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),e=Math.max(e,s);const a=o.high??o.y??0,c=o.low??o.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}class YM extends Xt{constructor(t){super(t)}render(){var f,u;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=Math.max(2,Math.min(10,i.width/o.length*.3)),a=this.config.color||"#f45b5b",c=this.config.upColor||"#2f7ed8",l=((u=(f=this.config.states)==null?void 0:f.inactive)==null?void 0:u.opacity)??.4,h=[];for(let d=0;d<o.length;d++){const p=o[d];if(p.y===null&&p.open===void 0)continue;const y=p.open??p.y??0,g=p.high??y,m=p.low??y,x=p.close??y,v=t.getPixelForValue(p.x??d),b=x>=y?c:a,k=this.group.append("g").attr("class","katucharts-ohlc").style("cursor",this.config.cursor||"pointer");h.push(k),r&&k.attr("opacity",0).transition().duration(bt).ease(pt).delay(xe(d,0,Nt,o.length)).attr("opacity",1),k.append("line").attr("x1",v).attr("x2",v).attr("y1",e.getPixelForValue(g)).attr("y2",e.getPixelForValue(m)).attr("stroke",b).attr("stroke-width",1.5),k.append("line").attr("x1",v-s).attr("x2",v).attr("y1",e.getPixelForValue(y)).attr("y2",e.getPixelForValue(y)).attr("stroke",b).attr("stroke-width",1.5),k.append("line").attr("x1",v).attr("x2",v+s).attr("y1",e.getPixelForValue(x)).attr("y2",e.getPixelForValue(x)).attr("stroke",b).attr("stroke-width",1.5),this.config.enableMouseTracking!==!1&&k.on("mouseover",M=>{var C,E;k.selectAll("line").interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",3),k.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),h.forEach(_=>_.interrupt("highlight")),h.forEach(_=>_.attr("opacity",1)),h.forEach((_,T)=>{T!==d&&_.transition("highlight").duration(Z).ease(j).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{...p,open:y,high:g,low:m,close:x},index:d,series:this,event:M,plotX:v,plotY:e.getPixelForValue((g+m)/2)}),(E=(C=p.events)==null?void 0:C.mouseOver)==null||E.call(p,M)}).on("mouseout",M=>{var C,E;k.selectAll("line").interrupt("hover").transition("hover").duration(Z).ease(j).attr("stroke-width",1.5),k.style("filter",""),h.forEach(_=>_.interrupt("highlight")),h.forEach(_=>_.transition("highlight").duration(Z).ease(j).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:p,index:d,series:this,event:M}),(E=(C=p.events)==null?void 0:C.mouseOut)==null||E.call(p,M)}).on("click",M=>{var C,E,_,T;this.context.events.emit("point:click",{point:p,index:d,series:this,event:M}),(E=(C=p.events)==null?void 0:C.click)==null||E.call(p,M),(T=(_=this.config.events)==null?void 0:_.click)==null||T.call(this,M)})}}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),e=Math.max(e,s);const a=o.high??o.y??0,c=o.low??o.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function Tp(){Tt.registerType("candlestick",GM),Tt.registerType("ohlc",YM)}function Lp(n,t){let e;if(t===void 0)for(const i of n)i!=null&&(e<i||e===void 0&&i>=i)&&(e=i);else{let i=-1;for(let r of n)(r=t(r,++i,n))!=null&&(e<r||e===void 0&&r>=r)&&(e=r)}return e}function XM(n,t){let e;if(t===void 0)for(const i of n)i!=null&&(e>i||e===void 0&&i>=i)&&(e=i);else{let i=-1;for(let r of n)(r=t(r,++i,n))!=null&&(e>r||e===void 0&&r>=r)&&(e=r)}return e}function yl(n,t){let e=0;if(t===void 0)for(let i of n)(i=+i)&&(e+=i);else{let i=-1;for(let r of n)(r=+t(r,++i,n))&&(e+=r)}return e}function UM(n){return n.depth}function $p(n,t){return n.sourceLinks.length?n.depth:t-1}function Ys(n){return function(){return n}}function Ip(n,t){return Xs(n.source,t.source)||n.index-t.index}function Fp(n,t){return Xs(n.target,t.target)||n.index-t.index}function Xs(n,t){return n.y0-t.y0}function xl(n){return n.value}function jM(n){return n.index}function qM(n){return n.nodes}function ZM(n){return n.links}function Rp(n,t){const e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function Dp({nodes:n}){for(const t of n){let e=t.y0,i=e;for(const r of t.sourceLinks)r.y0=e+r.width/2,e+=r.width;for(const r of t.targetLinks)r.y1=i+r.width/2,i+=r.width}}function KM(){let n=0,t=0,e=1,i=1,r=24,o=8,s,a=jM,c=$p,l,h,f=qM,u=ZM,d=6;function p(){const w={nodes:f.apply(null,arguments),links:u.apply(null,arguments)};return y(w),g(w),m(w),x(w),k(w),Dp(w),w}p.update=function(w){return Dp(w),w},p.nodeId=function(w){return arguments.length?(a=typeof w=="function"?w:Ys(w),p):a},p.nodeAlign=function(w){return arguments.length?(c=typeof w=="function"?w:Ys(w),p):c},p.nodeSort=function(w){return arguments.length?(l=w,p):l},p.nodeWidth=function(w){return arguments.length?(r=+w,p):r},p.nodePadding=function(w){return arguments.length?(o=s=+w,p):o},p.nodes=function(w){return arguments.length?(f=typeof w=="function"?w:Ys(w),p):f},p.links=function(w){return arguments.length?(u=typeof w=="function"?w:Ys(w),p):u},p.linkSort=function(w){return arguments.length?(h=w,p):h},p.size=function(w){return arguments.length?(n=t=0,e=+w[0],i=+w[1],p):[e-n,i-t]},p.extent=function(w){return arguments.length?(n=+w[0][0],e=+w[1][0],t=+w[0][1],i=+w[1][1],p):[[n,t],[e,i]]},p.iterations=function(w){return arguments.length?(d=+w,p):d};function y({nodes:w,links:S}){for(const[R,F]of w.entries())F.index=R,F.sourceLinks=[],F.targetLinks=[];const $=new Map(w.map((R,F)=>[a(R,F,w),R]));for(const[R,F]of S.entries()){F.index=R;let{source:D,target:z}=F;typeof D!="object"&&(D=F.source=Rp($,D)),typeof z!="object"&&(z=F.target=Rp($,z)),D.sourceLinks.push(F),z.targetLinks.push(F)}if(h!=null)for(const{sourceLinks:R,targetLinks:F}of w)R.sort(h),F.sort(h)}function g({nodes:w}){for(const S of w)S.value=S.fixedValue===void 0?Math.max(yl(S.sourceLinks,xl),yl(S.targetLinks,xl)):S.fixedValue}function m({nodes:w}){const S=w.length;let $=new Set(w),R=new Set,F=0;for(;$.size;){for(const D of $){D.depth=F;for(const{target:z}of D.sourceLinks)R.add(z)}if(++F>S)throw new Error("circular link");$=R,R=new Set}}function x({nodes:w}){const S=w.length;let $=new Set(w),R=new Set,F=0;for(;$.size;){for(const D of $){D.height=F;for(const{source:z}of D.targetLinks)R.add(z)}if(++F>S)throw new Error("circular link");$=R,R=new Set}}function v({nodes:w}){const S=Lp(w,F=>F.depth)+1,$=(e-n-r)/(S-1),R=new Array(S);for(const F of w){const D=Math.max(0,Math.min(S-1,Math.floor(c.call(null,F,S))));F.layer=D,F.x0=n+D*$,F.x1=F.x0+r,R[D]?R[D].push(F):R[D]=[F]}if(l)for(const F of R)F.sort(l);return R}function b(w){const S=XM(w,$=>(i-t-($.length-1)*s)/yl($,xl));for(const $ of w){let R=t;for(const F of $){F.y0=R,F.y1=R+F.value*S,R=F.y1+s;for(const D of F.sourceLinks)D.width=D.value*S}R=(i-R+s)/($.length+1);for(let F=0;F<$.length;++F){const D=$[F];D.y0+=R*(F+1),D.y1+=R*(F+1)}L($)}}function k(w){const S=v(w);s=Math.min(o,(i-t)/(Lp(S,$=>$.length)-1)),b(S);for(let $=0;$<d;++$){const R=Math.pow(.99,$),F=Math.max(1-R,($+1)/d);C(S,R,F),M(S,R,F)}}function M(w,S,$){for(let R=1,F=w.length;R<F;++R){const D=w[R];for(const z of D){let B=0,W=0;for(const{source:X,value:q}of z.targetLinks){let N=q*(z.layer-X.layer);B+=P(X,z)*N,W+=N}if(!(W>0))continue;let K=(B/W-z.y0)*S;z.y0+=K,z.y1+=K,I(z)}l===void 0&&D.sort(Xs),E(D,$)}}function C(w,S,$){for(let R=w.length,F=R-2;F>=0;--F){const D=w[F];for(const z of D){let B=0,W=0;for(const{target:X,value:q}of z.sourceLinks){let N=q*(X.layer-z.layer);B+=A(z,X)*N,W+=N}if(!(W>0))continue;let K=(B/W-z.y0)*S;z.y0+=K,z.y1+=K,I(z)}l===void 0&&D.sort(Xs),E(D,$)}}function E(w,S){const $=w.length>>1,R=w[$];T(w,R.y0-s,$-1,S),_(w,R.y1+s,$+1,S),T(w,i,w.length-1,S),_(w,t,0,S)}function _(w,S,$,R){for(;$<w.length;++$){const F=w[$],D=(S-F.y0)*R;D>1e-6&&(F.y0+=D,F.y1+=D),S=F.y1+s}}function T(w,S,$,R){for(;$>=0;--$){const F=w[$],D=(F.y1-S)*R;D>1e-6&&(F.y0-=D,F.y1-=D),S=F.y0-s}}function I({sourceLinks:w,targetLinks:S}){if(h===void 0){for(const{source:{sourceLinks:$}}of S)$.sort(Fp);for(const{target:{targetLinks:$}}of w)$.sort(Ip)}}function L(w){if(h===void 0)for(const{sourceLinks:S,targetLinks:$}of w)S.sort(Fp),$.sort(Ip)}function P(w,S){let $=w.y0-(w.sourceLinks.length-1)*s/2;for(const{target:R,width:F}of w.sourceLinks){if(R===S)break;$+=F+s}for(const{source:R,width:F}of S.targetLinks){if(R===w)break;$-=F}return $}function A(w,S){let $=S.y0-(S.targetLinks.length-1)*s/2;for(const{source:R,width:F}of S.targetLinks){if(R===w)break;$+=F+s}for(const{target:R,width:F}of w.sourceLinks){if(R===S)break;$-=F}return $}return p}var bl=Math.PI,vl=2*bl,_i=1e-6,JM=vl-_i;function wl(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function zp(){return new wl}wl.prototype=zp.prototype={constructor:wl,moveTo:function(n,t){this._+="M"+(this._x0=this._x1=+n)+","+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(n,t){this._+="L"+(this._x1=+n)+","+(this._y1=+t)},quadraticCurveTo:function(n,t,e,i){this._+="Q"+ +n+","+ +t+","+(this._x1=+e)+","+(this._y1=+i)},bezierCurveTo:function(n,t,e,i,r,o){this._+="C"+ +n+","+ +t+","+ +e+","+ +i+","+(this._x1=+r)+","+(this._y1=+o)},arcTo:function(n,t,e,i,r){n=+n,t=+t,e=+e,i=+i,r=+r;var o=this._x1,s=this._y1,a=e-n,c=i-t,l=o-n,h=s-t,f=l*l+h*h;if(r<0)throw new Error("negative radius: "+r);if(this._x1===null)this._+="M"+(this._x1=n)+","+(this._y1=t);else if(f>_i)if(!(Math.abs(h*a-c*l)>_i)||!r)this._+="L"+(this._x1=n)+","+(this._y1=t);else{var u=e-o,d=i-s,p=a*a+c*c,y=u*u+d*d,g=Math.sqrt(p),m=Math.sqrt(f),x=r*Math.tan((bl-Math.acos((p+f-y)/(2*g*m)))/2),v=x/m,b=x/g;Math.abs(v-1)>_i&&(this._+="L"+(n+v*l)+","+(t+v*h)),this._+="A"+r+","+r+",0,0,"+ +(h*u>l*d)+","+(this._x1=n+b*a)+","+(this._y1=t+b*c)}},arc:function(n,t,e,i,r,o){n=+n,t=+t,e=+e,o=!!o;var s=e*Math.cos(i),a=e*Math.sin(i),c=n+s,l=t+a,h=1^o,f=o?i-r:r-i;if(e<0)throw new Error("negative radius: "+e);this._x1===null?this._+="M"+c+","+l:(Math.abs(this._x1-c)>_i||Math.abs(this._y1-l)>_i)&&(this._+="L"+c+","+l),e&&(f<0&&(f=f%vl+vl),f>JM?this._+="A"+e+","+e+",0,1,"+h+","+(n-s)+","+(t-a)+"A"+e+","+e+",0,1,"+h+","+(this._x1=c)+","+(this._y1=l):f>_i&&(this._+="A"+e+","+e+",0,"+ +(f>=bl)+","+h+","+(this._x1=n+e*Math.cos(r))+","+(this._y1=t+e*Math.sin(r))))},rect:function(n,t,e,i){this._+="M"+(this._x0=this._x1=+n)+","+(this._y0=this._y1=+t)+"h"+ +e+"v"+ +i+"h"+-e+"Z"},toString:function(){return this._}};function Bp(n){return function(){return n}}function QM(n){return n[0]}function tA(n){return n[1]}var eA=Array.prototype.slice;function nA(n){return n.source}function iA(n){return n.target}function rA(n){var t=nA,e=iA,i=QM,r=tA,o=null;function s(){var a,c=eA.call(arguments),l=t.apply(this,c),h=e.apply(this,c);if(o||(o=a=zp()),n(o,+i.apply(this,(c[0]=l,c)),+r.apply(this,c),+i.apply(this,(c[0]=h,c)),+r.apply(this,c)),a)return o=null,a+""||null}return s.source=function(a){return arguments.length?(t=a,s):t},s.target=function(a){return arguments.length?(e=a,s):e},s.x=function(a){return arguments.length?(i=typeof a=="function"?a:Bp(+a),s):i},s.y=function(a){return arguments.length?(r=typeof a=="function"?a:Bp(+a),s):r},s.context=function(a){return arguments.length?(o=a??null,s):o},s}function oA(n,t,e,i,r){n.moveTo(t,e),n.bezierCurveTo(t=(t+i)/2,e,t,r,i,r)}function sA(){return rA(oA)}function aA(n){return[n.source.x1,n.y0]}function cA(n){return[n.target.x0,n.y1]}function lA(){return sA().source(aA).target(cA)}const hA=500,uA=380,fA=280;function dA(n){if(n.endsWith("px"))return parseFloat(n)||12;if(n.endsWith("rem")||n.endsWith("em")){const e=typeof document>"u"?16:parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return(parseFloat(n)||1)*e}const t=parseFloat(n);return Number.isNaN(t)?12:t}class pA extends Xt{getBaseFlowDuration(){return bt*4}constructor(t){super(t)}render(){var Pe,dn,wn,Xn,Qr;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,o=this.getBaseFlowDuration();this.group.selectAll("rect, path, text").interrupt("enter").interrupt("highlight");const{nodes:s,links:a}=this.buildGraph();if(s.length===0)return;const c=t.width<hA,l=t.width<uA,h=t.width<fA,f=r.nodeWidth,u=f==="auto",d=s.map(V=>typeof V.column=="number"&&Number.isFinite(V.column)?Math.max(0,Math.floor(V.column)):null).filter(V=>V!==null),p=d.length>0,y=p?Math.max(...d):0,g=typeof r.nodePadding=="number"?r.nodePadding:c?Math.max(4,Math.min(10,t.height/40)):10,m=r.linkOpacity??.4,x=r.colorByPoint!==!1,v=r.minLinkWidth??1,b=r.borderWidth??0,k=r.borderColor??"none",M=r.levels||[],C=this.config.dataLabels||{},E=C.enabled!==!1,_=((Pe=C.style)==null?void 0:Pe.fontSize)||kt,T=dA(_),I=l?Math.min(T,10):c?Math.min(T,12):T,L=`${I}px`,P=C.color||((dn=C.style)==null?void 0:dn.color)||this.autoLabelColor(),A=I*.62,w=V=>C.formatter?String(C.formatter.call({point:{name:V.name||V.id,y:V.value},series:{name:this.config.name},x:V.name||V.id,y:V.value})??""):String(V.name||V.id||""),S=V=>V.length*A,$=(V,tt,lt=2)=>{if(tt<=0)return"";if(S(V)<=tt)return V;const Ft=Math.floor(tt/A)-1;return Ft<lt?"":Ft>=V.length?V:V.slice(0,Ft)+"…"},R=r.nodeAlignment==="left"?UM:$p,D=h?5:l?8:c?10:14,z=typeof f=="number"?f:20,B=(V,tt,lt,Pt)=>{const Ft=Math.max(tt+Pt+20,t.width-lt),Ne=KM().nodeId(be=>be.id).nodeAlign(R).nodeWidth(Pt).nodePadding(V).extent([[tt,0],[Ft,t.height]]),Ee=Ne({nodes:[...s],links:[...a]});for(const be of Ee.nodes)if(be.x0<tt){const En=be.x1-be.x0;be.x0=tt,be.x1=tt+En}return{gen:Ne,graph:Ee}};let W=z;const K=B(g,0,0,W),X=V=>p&&typeof V.column=="number"&&Number.isFinite(V.column)?Math.max(0,Math.floor(V.column)):V.layer??V.depth??0,q=p?y:K.graph.nodes.reduce((V,tt)=>Math.max(V,tt.depth??0),0),N=K.graph.nodes.reduce((V,tt)=>Math.min(V,tt.x0??1/0),1/0),H=p?K.graph.nodes.filter(V=>X(V)===0):K.graph.nodes.filter(V=>(V.x0??1/0)<=N+.5),Y=E?Math.max(0,...H.map(V=>S(w(V)))):0,G=E&&c?Math.min(Math.floor(t.width*.08),Math.max(0,Y*.18)):0,Q=E&&!h,O=0,it=Math.max(1,t.width-G-O),et=Math.max(q,0);if(et>0){const tt=(it-et*(h?8:l?10:c?14:18))/(et+1),lt=Math.max(D,Math.min(z,tt));(typeof f!="number"||c)&&(W=lt)}else typeof f!="number"&&(W=Math.max(D,Math.min(z,it*.5)));const ht=l?Math.max(2,Math.min(8,W*.35)):0,ft=G+ht,ct=O+ht;let{gen:nt,graph:U}=B(g,ft,ct,W);const at=new Map;for(const V of U.nodes){const tt=X(V);at.set(tt,(at.get(tt)??0)+1)}const yt=Math.max(1,...at.values());let St=g;const Mt=typeof r.nodePadding!="number";if(E&&Mt&&yt>1){const V=I*1.3;t.height*.82/(yt-1)>=V&&(St=Math.max(g,V))}if(yt*St>t.height&&(St=Math.max(1,t.height/yt)),St!==g&&({gen:nt,graph:U}=B(St,ft,ct,W)),u){const V=U.nodes.reduce((lt,Pt)=>Math.max(lt,X(Pt)),0),tt=Math.max(D,Math.min(20,it/((V+1)*3)));nt.nodeWidth(tt),U=nt({nodes:[...s],links:[...a]})}if(p){const V=Math.max(1,U.nodes[0]?U.nodes[0].x1-U.nodes[0].x0:W);St=this.applyExplicitColumnLayout(U,nt,X,y,ft,Math.max(ft+V,t.width-ct),t.height,St,V)}else this.reorderNodesByValueDesc(U,nt,X,t.height,St);const Et=new Map,Ht=new Map;for(const V of U.nodes){const tt=X(V);Et.has(tt)||Et.set(tt,[]),Et.get(tt).push(V)}for(const V of U.links){const tt=X(V.source);Ht.has(tt)||Ht.set(tt,[]),Ht.get(tt).push(V)}const ne=U.nodes.reduce((V,tt)=>Math.max(V,X(tt)),0),Ct=Math.round(o*.22),Zt=Ct,Qt=Zt,ge=ne*Qt+Ct+Zt,Vt=r.centerNodes===!0,Ut=r.spreadFactor??1;(Vt||Ut!==1)&&this.centerAndSpreadNodes(U,nt,t.height,Ut,St);const Xe=new Map;for(const V of M)V.level!==void 0&&Xe.set(V.level,V);const se=V=>{const tt=V.source?X(V.source):void 0,lt=tt!==void 0?Xe.get(tt):void 0;return(lt==null?void 0:lt.linkOpacity)??m},hn=lA(),vn=V=>{if(!l)return hn(V);const tt=V.source.x1,lt=V.target.x0,Pt=V.y0,Ft=V.y1,Ne=lt-tt;if(!Number.isFinite(Ne)||!Number.isFinite(Pt)||!Number.isFinite(Ft))return hn(V);if(Ne<=14)return`M${tt},${Pt}L${lt},${Ft}`;if(Ne<28){const Ee=Math.max(2,Ne*.35);return`M${tt},${Pt}C${tt+Ee},${Pt} ${lt-Ee},${Ft} ${lt},${Ft}`}return hn(V)},ze=l,un=ze?V=>{const tt=V.source.x1,lt=V.target.x0,Pt=V.y0,Ft=V.y1,Ne=lt-tt,Ee=Math.max(v,V.width)/2;if(!Number.isFinite(Ne)||!Number.isFinite(Pt)||!Number.isFinite(Ft))return vn(V);const be=Pt-Ee,En=Pt+Ee,to=Ft-Ee,ii=Ft+Ee,Un=Math.max(1,Ne*.42);return Ne<=2?[`M${tt},${be}`,`L${lt},${to}`,`L${lt},${ii}`,`L${tt},${En}`,"Z"].join(""):[`M${tt},${be}`,`C${tt+Un},${be} ${lt-Un},${to} ${lt},${to}`,`L${lt},${ii}`,`C${lt-Un},${ii} ${tt+Un},${En} ${tt},${En}`,"Z"].join("")}:vn,Je=ze?"fill-opacity":"stroke-opacity",Qe=r.linkColorMode??"from",Zr=V=>V.source.color||e[U.nodes.indexOf(V.source)%e.length]||"#aaa",Kr=V=>V.target.color||e[U.nodes.indexOf(V.target)%e.length]||"#aaa",Jr=this.group.append("defs"),rt=`katucharts-sankey-clip-${this.config.index}-${Math.random().toString(36).slice(2,8)}`;Jr.append("clipPath").attr("id",rt).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height);const ot=this.group.append("g").attr("class","katucharts-sankey-clipped-layer").attr("clip-path",`url(#${rt})`),ut=ot.append("g").attr("class","katucharts-sankey-links"),wt=ot.append("g").attr("class","katucharts-sankey-nodes"),xt=ot.append("g").attr("class","katucharts-sankey-link-hitareas");let mt=null;Qe==="gradient"&&(mt=Jr);let J=null;const Lt=.55,zt=.25,gt=ut.selectAll(".katucharts-sankey-link").data(U.links).join("path").attr("class","katucharts-sankey-link").attr("d",un).attr("fill",ze?"#aaa":"none").attr("stroke",ze?"none":"#aaa").attr("stroke-width",V=>ze?null:Math.max(v,V.width)).attr("stroke-linecap","butt").style("cursor","pointer");Qe==="gradient"&&mt?gt.each(function(V,tt){const lt=`katucharts-sankey-grad-${tt}-${Math.random().toString(36).slice(2,6)}`;mt.append("linearGradient").attr("id",lt).attr("gradientUnits","userSpaceOnUse").attr("x1",V.source.x1).attr("x2",V.target.x0).selectAll("stop").data([{offset:"0%",color:Zr(V)},{offset:"100%",color:Kr(V)}]).join("stop").attr("offset",Pt=>Pt.offset).attr("stop-color",Pt=>Pt.color),st(this).attr(ze?"fill":"stroke",`url(#${lt})`)}):Qe==="to"?gt.attr(ze?"fill":"stroke",V=>Kr(V)):gt.attr(ze?"fill":"stroke",V=>Zr(V)),i&&!h?c?gt.attr(Je,0).each(function(V){const tt=X(V.source),Pt=(Ht.get(tt)||[]).indexOf(V),Ft=tt*Qt+Ct-60+Math.min(Pt*12,60);st(this).transition("enter").duration(Zt).delay(Ft).ease(pt).attr(Je,se(V))}):gt.attr(Je,V=>se(V)).each(function(V){var En;const tt=this,lt=((En=tt.getTotalLength)==null?void 0:En.call(tt))||0;if(lt===0)return;const Pt=X(V.source),Ne=(Ht.get(Pt)||[]).indexOf(V),be=Pt*Qt+Ct-60+Math.min(Ne*12,60);st(this).attr("stroke-dasharray",`${lt} ${lt}`).attr("stroke-dashoffset",lt).transition("enter").duration(Zt).delay(be).ease(pt).attr("stroke-dashoffset",0).on("end",function(){st(this).attr("stroke-dasharray",null).attr("stroke-dashoffset",null)})}):gt.attr(Je,V=>se(V));const jt=(V,tt,lt)=>{const Pt={name:`${lt.source.name} → ${lt.target.name}`,from:lt.source.name,to:lt.target.name,y:lt.value,weight:lt.value,fromNode:{name:lt.source.name,id:lt.source.id},toNode:{name:lt.target.name,id:lt.target.id}};if(V==="mouseover"){this.context.events.emit("point:mouseover",{point:Pt,index:U.links.indexOf(lt),series:this,event:tt,plotX:(lt.source.x1+lt.target.x0)/2,plotY:(lt.y0+lt.y1)/2});return}if(V==="mouseout"){this.context.events.emit("point:mouseout",{point:Pt,index:U.links.indexOf(lt),series:this,event:tt});return}this.context.events.emit("point:click",{point:Pt,index:U.links.indexOf(lt),series:this,event:tt})},Ot=(V,tt)=>{const lt=se(tt);gt.interrupt("highlight"),Wt.interrupt("highlight"),J==null||J.interrupt("highlight"),gt.attr(Je,Pt=>Pt===tt?Math.min(lt+.3,1):se(Pt)),gt.filter(Pt=>Pt!==tt).transition("highlight").duration(Z).ease(j).attr(Je,lt*.375),Wt.attr("opacity",1),Wt.transition("highlight").duration(Z).ease(j).attr("opacity",Pt=>Pt===tt.source||Pt===tt.target?1:Lt),J==null||J.transition("highlight").duration(Z).ease(j).attr("opacity",Pt=>Pt===tt.source||Pt===tt.target?1:zt),jt("mouseover",V,tt)},qt=(V,tt)=>{gt.interrupt("highlight"),Wt.interrupt("highlight"),J==null||J.interrupt("highlight"),gt.transition("highlight").duration(Z).ease(j).attr(Je,lt=>se(lt)),Wt.transition("highlight").duration(Z).ease(j).attr("opacity",1),J==null||J.transition("highlight").duration(Z).ease(j).attr("opacity",1),jt("mouseout",V,tt)},ie=(V,tt)=>{jt("click",V,tt)};gt.on("mouseover",Ot).on("mouseout",qt).on("click",ie);const Wt=wt.selectAll(".katucharts-sankey-node").data(U.nodes).join("rect").attr("class","katucharts-sankey-node").attr("x",V=>V.x0).attr("y",V=>V.y0).attr("width",V=>V.x1-V.x0).attr("height",V=>Math.max(1,V.y1-V.y0)).attr("fill",(V,tt)=>{if(V.color)return V.color;const lt=Xe.get(X(V));return lt!=null&&lt.color?lt.color:x?e[tt%e.length]:r.color||e[0]}).attr("stroke",k).attr("stroke-width",b).attr("rx",4).style("cursor","pointer");i&&!h&&Wt.attr("opacity",0).attr("x",V=>V.x0-(l?4:10)).each(function(V){const tt=X(V),Pt=(Et.get(tt)||[]).indexOf(V),Ft=tt*Qt+Math.min(Pt*20,80);st(this).transition("enter").duration(Ct).delay(Ft).ease(pt).attr("opacity",1).attr("x",V.x0)});const fn=(V,tt)=>{Wt.filter(Ft=>Ft===tt).style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),Wt.interrupt("highlight"),gt.interrupt("highlight"),J==null||J.interrupt("highlight");const lt=new Set([tt]);for(const Ft of U.links)Ft.source===tt?lt.add(Ft.target):Ft.target===tt&&lt.add(Ft.source);Wt.attr("opacity",1),Wt.filter(Ft=>!lt.has(Ft)).transition("highlight").duration(Z).ease(j).attr("opacity",Lt),J==null||J.transition("highlight").duration(Z).ease(j).attr("opacity",Ft=>lt.has(Ft)?1:zt),gt.transition("highlight").duration(Z).ease(j).attr(Je,Ft=>Ft.source===tt||Ft.target===tt?Math.min(se(Ft)+.3,1):se(Ft)*.375);const Pt={name:tt.name||tt.id,y:tt.value,sum:tt.value};this.context.events.emit("point:mouseover",{point:Pt,index:U.nodes.indexOf(tt),series:this,event:V,plotX:(tt.x0+tt.x1)/2,plotY:(tt.y0+tt.y1)/2})},Oe=(V,tt)=>{Wt.filter(lt=>lt===tt).style("filter",""),Wt.interrupt("highlight"),gt.interrupt("highlight"),J==null||J.interrupt("highlight"),Wt.transition("highlight").duration(Z).ease(j).attr("opacity",1),J==null||J.transition("highlight").duration(Z).ease(j).attr("opacity",1),gt.transition("highlight").duration(Z).ease(j).attr(Je,lt=>se(lt)),this.context.events.emit("point:mouseout",{point:{name:tt.name||tt.id,y:tt.value,sum:tt.value},index:U.nodes.indexOf(tt),series:this,event:V})},Ue=(V,tt)=>{this.context.events.emit("point:click",{point:{name:tt.name||tt.id,y:tt.value},index:U.nodes.indexOf(tt),series:this,event:V})};if(Wt.on("mouseover",fn).on("mouseout",Oe).on("click",Ue),xt.selectAll(".katucharts-sankey-link-hitarea").data(U.links).join("path").attr("class","katucharts-sankey-link-hitarea").attr("d",vn).attr("fill","none").attr("stroke","transparent").attr("stroke-linecap","round").attr("stroke-width",V=>Math.max(16,Math.max(v,V.width)+10)).style("cursor","pointer").on("mouseover",Ot).on("mouseout",qt).on("click",ie),E){const V=this.group.append("g").attr("class","katucharts-sankey-labels"),tt=Math.max(6,I*.6),lt=U.nodes.reduce((dt,It)=>Math.max(dt,It.x0??0),0),Pt=U.nodes.reduce((dt,It)=>Math.min(dt,It.x0??1/0),1/0),Ft=dt=>p?X(dt)===ne:lt>0&&(dt.x0??0)>=lt-.5,Ne=dt=>p?X(dt)===0:Number.isFinite(Pt)&&(dt.x0??0)<=Pt+.5,Ee=dt=>Q&&Ft(dt)||Ne(dt),be=new Map;for(const dt of U.nodes){const It=dt.y1-dt.y0;if(!Ee(dt)&&It<tt){be.set(dt,"");continue}be.set(dt,w(dt))}const En=dt=>Ee(dt)?Ft(dt)?"end":"start":"middle",to=dt=>Ee(dt)?Ft(dt)?dt.x0-4+(C.x??0):dt.x1+4+(C.x??0):(dt.x0+dt.x1)/2+(C.x??0);J=V.selectAll(".katucharts-sankey-label").data(U.nodes).join("text").attr("class","katucharts-sankey-label").attr("x",to).attr("y",dt=>(dt.y0+dt.y1)/2+(C.y??0)).attr("dy","0.35em").attr("text-anchor",En).attr("font-size",L).attr("font-weight",((wn=C.style)==null?void 0:wn.fontWeight)??600).attr("fill",P).attr("paint-order","stroke").attr("stroke",(Xn=C.style)!=null&&Xn.textOutline?null:this.labelHaloColor()).attr("stroke-width",(Qr=C.style)!=null&&Qr.textOutline?null:2).attr("stroke-linejoin","round").style("pointer-events","auto").style("cursor","pointer").on("mouseover",fn).on("mouseout",Oe).on("click",Ue).text(dt=>be.get(dt)??"");const ii=new Map,Un=new Map;for(const dt of U.nodes){const It=X(dt);ii.set(It,Math.min(ii.get(It)??1/0,dt.x0)),Un.set(It,Math.max(Un.get(It)??-1/0,dt.x1))}J.each(function(dt){const It=this;let ae=It.textContent;if(!ae)return;const Tn=S(ae);if(Ee(dt)){const Kp=X(dt),Jp=I*.75;let no;if(Ft(dt)){const io=Un.get(Kp-1),Qp=io!==void 0?(io+dt.x0)/2:2;no=dt.x0-4-(Qp+Jp/2)}else{const io=ii.get(Kp+1);no=(io!==void 0?(dt.x1+io)/2:t.width-2)-Jp/2-(dt.x1+4)}if(no<=A){It.textContent="";return}Tn>no&&(ae=$(ae,no,1),It.textContent=ae);return}const Pi=(dt.x0+dt.x1)/2,ri=Pi-Tn/2,or=Pi+Tn/2;if(or<=t.width&&ri>=0)return;const eo=X(dt),r5=ii.get(eo+1)??t.width,o5=Un.get(eo-1)??0,Sl=r5-dt.x1-4,_l=dt.x0-o5-4;if(ri<0&&Sl>I*1.5){It.setAttribute("text-anchor","start"),It.setAttribute("x",String(dt.x1+2)),Tn>Sl&&(It.textContent=$(ae,Sl));return}if(or>t.width&&_l>I*1.5){It.setAttribute("text-anchor","end"),It.setAttribute("x",String(dt.x0-2)),Tn>_l&&(It.textContent=$(ae,_l));return}const Zp=2*Math.min(Pi,t.width-Pi)-4;if(Zp<I*2){It.textContent="";return}It.textContent=$(ae,Zp)});const jp=[],n5=[...U.nodes].sort((dt,It)=>(It.value??0)-(dt.value??0)),qp=new Map;J.each(function(dt){qp.set(dt,this)});const i5=(dt,It)=>dt.left<It.right&&dt.right>It.left&&dt.top<It.bottom&&dt.bottom>It.top;for(const dt of n5){if(C.allowOverlap===!0)break;const It=qp.get(dt);if(!It||!It.textContent)continue;let ae;try{ae=It.getBBox()}catch{const ri=S(It.textContent||""),or=Number(It.getAttribute("x")||0),eo=It.getAttribute("text-anchor");ae={x:eo==="end"?or-ri:eo==="middle"?or-ri/2:or,y:Number(It.getAttribute("y")||0)-I/2,width:ri,height:I}}if(ae.width===0&&ae.height===0)continue;const Tn={left:ae.x,right:ae.x+ae.width,top:ae.y,bottom:ae.y+ae.height};if(jp.some(ri=>i5(ri,Tn))&&C.overflow!=="allow"){It.textContent="";continue}jp.push(Tn)}i&&!h&&J.attr("opacity",0).each(function(dt){const It=X(dt),Tn=(Et.get(It)||[]).indexOf(dt),Pi=It*Qt+Ct-80+Math.min(Tn*20,80);st(this).transition("enter").duration(Ct).delay(Pi).ease(pt).attr("opacity",1)})}i&&this.emitAfterAnimate(h?0:ge+100)}applyExplicitColumnLayout(t,e,i,r,o,s,a,c,l){var m,x;const h=new Map;for(const v of t.nodes){const b=i(v);v.depth=b,v.layer=b,h.has(b)||h.set(b,[]),h.get(b).push(v)}const f=Array.from(h.entries()).sort((v,b)=>v[0]-b[0]),u=Math.max(1,...f.map(([,v])=>v.length)),d=u>1?Math.min(c,Math.max(1,a/(u-1))):c,y=f.map(([,v])=>v.reduce((b,k)=>b+Math.max(0,k.value??0),0)).filter(v=>v>0).length>0?Math.min(...f.map(([,v])=>{const b=v.reduce((k,M)=>k+Math.max(0,M.value??0),0);return b<=0?1/0:Math.max(1e-4,(a-Math.max(0,v.length-1)*d)/b)})):1,g=r>0?(s-o-l)/r:0;for(const[v,b]of f){const k=b.some(_=>typeof _.offset=="number");b.sort((_,T)=>k?(_.offset??0)-(T.offset??0)||(_.y0??0)-(T.y0??0)||String(_.name??_.id).localeCompare(String(T.name??T.id)):(T.value??0)-(_.value??0)||String(_.name??_.id).localeCompare(String(T.name??T.id)));const M=b.reduce((_,T)=>_+Math.max(1,(T.value??0)*y),0)+Math.max(0,b.length-1)*d;let C=Math.max(0,(a-M)/2);const E=o+v*g;for(const _ of b){const T=Math.max(1,(_.value??0)*y);_.x0=E,_.x1=E+l,_.y0=C,_.y1=C+T,C=_.y1+d}}for(const v of t.links)v.width=Math.max(1e-4,v.value*y);for(const v of t.nodes)(m=v.sourceLinks)==null||m.sort((b,k)=>(b.target.y0??0)-(k.target.y0??0)),(x=v.targetLinks)==null||x.sort((b,k)=>(b.source.y0??0)-(k.source.y0??0));return e.update(t),d}reorderNodesByValueDesc(t,e,i,r,o){var a,c;const s=new Map;for(const l of t.nodes){const h=i(l);s.has(h)||s.set(h,[]),s.get(h).push(l)}for(const[,l]of s){if(l.some(p=>typeof p.offset=="number"))continue;const u=l.reduce((p,y)=>p+(y.y1-y.y0),0)+Math.max(0,l.length-1)*o;l.sort((p,y)=>(y.value??0)-(p.value??0)||String(p.name??p.id).localeCompare(String(y.name??y.id)));let d=Math.max(0,(r-u)/2);for(const p of l){const y=p.y1-p.y0;p.y0=d,p.y1=d+y,d=p.y1+o}}for(const l of t.nodes)(a=l.sourceLinks)==null||a.sort((h,f)=>(h.target.y0??0)-(f.target.y0??0)),(c=l.targetLinks)==null||c.sort((h,f)=>(h.source.y0??0)-(f.source.y0??0));e.update(t)}centerAndSpreadNodes(t,e,i,r,o){const s=new Map;for(const a of t.nodes){const c=a.layer??a.depth??0;s.has(c)||s.set(c,[]),s.get(c).push(a)}for(const[,a]of s){if(a.sort((f,u)=>f.y0-u.y0),r!==1&&a.length>1){const f=a[0].y0,u=a[a.length-1].y1,d=(f+u)/2;for(const p of a){const y=(p.y0+p.y1)/2,g=p.y1-p.y0,m=d+(y-d)*r;p.y0=m-g/2,p.y1=m+g/2}for(let p=1;p<a.length;p++){const y=a[p-1].y1+o-a[p].y0;y>0&&(a[p].y0+=y,a[p].y1+=y)}}const c=a[0].y0,l=a[a.length-1].y1,h=(i-(l-c))/2-c;for(const f of a){const u=f.y1-f.y0,d=f.y0+h;f.y0=Math.max(0,Math.min(i-u,d)),f.y1=f.y0+u}}e.update(t)}buildGraph(){const t=new Map,e=[],i=this.config.nodes||[];for(const r of i)t.set(r.id,{id:r.id,name:r.name||r.id,color:r.color,column:r.column,offset:r.offset});for(const r of this.data){const o=r.from,s=r.to,a=r.y??r.weight??1;o&&s&&(t.has(o)||t.set(o,{id:o,name:o}),t.has(s)||t.set(s,{id:s,name:s}),e.push({source:o,target:s,value:a}))}return{nodes:Array.from(t.values()),links:e}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function gA(n,t){var e,i=1;n==null&&(n=0),t==null&&(t=0);function r(){var o,s=e.length,a,c=0,l=0;for(o=0;o<s;++o)a=e[o],c+=a.x,l+=a.y;for(c=(c/s-n)*i,l=(l/s-t)*i,o=0;o<s;++o)a=e[o],a.x-=c,a.y-=l}return r.initialize=function(o){e=o},r.x=function(o){return arguments.length?(n=+o,r):n},r.y=function(o){return arguments.length?(t=+o,r):t},r.strength=function(o){return arguments.length?(i=+o,r):i},r}function mA(n){const t=+this._x.call(null,n),e=+this._y.call(null,n);return Op(this.cover(t,e),t,e,n)}function Op(n,t,e,i){if(isNaN(t)||isNaN(e))return n;var r,o=n._root,s={data:i},a=n._x0,c=n._y0,l=n._x1,h=n._y1,f,u,d,p,y,g,m,x;if(!o)return n._root=s,n;for(;o.length;)if((y=t>=(f=(a+l)/2))?a=f:l=f,(g=e>=(u=(c+h)/2))?c=u:h=u,r=o,!(o=o[m=g<<1|y]))return r[m]=s,n;if(d=+n._x.call(null,o.data),p=+n._y.call(null,o.data),t===d&&e===p)return s.next=o,r?r[m]=s:n._root=s,n;do r=r?r[m]=new Array(4):n._root=new Array(4),(y=t>=(f=(a+l)/2))?a=f:l=f,(g=e>=(u=(c+h)/2))?c=u:h=u;while((m=g<<1|y)===(x=(p>=u)<<1|d>=f));return r[x]=o,r[m]=s,n}function yA(n){var t,e,i=n.length,r,o,s=new Array(i),a=new Array(i),c=1/0,l=1/0,h=-1/0,f=-1/0;for(e=0;e<i;++e)isNaN(r=+this._x.call(null,t=n[e]))||isNaN(o=+this._y.call(null,t))||(s[e]=r,a[e]=o,r<c&&(c=r),r>h&&(h=r),o<l&&(l=o),o>f&&(f=o));if(c>h||l>f)return this;for(this.cover(c,l).cover(h,f),e=0;e<i;++e)Op(this,s[e],a[e],n[e]);return this}function xA(n,t){if(isNaN(n=+n)||isNaN(t=+t))return this;var e=this._x0,i=this._y0,r=this._x1,o=this._y1;if(isNaN(e))r=(e=Math.floor(n))+1,o=(i=Math.floor(t))+1;else{for(var s=r-e||1,a=this._root,c,l;e>n||n>=r||i>t||t>=o;)switch(l=(t<i)<<1|n<e,c=new Array(4),c[l]=a,a=c,s*=2,l){case 0:r=e+s,o=i+s;break;case 1:e=r-s,o=i+s;break;case 2:r=e+s,i=o-s;break;case 3:e=r-s,i=o-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._y0=i,this._x1=r,this._y1=o,this}function bA(){var n=[];return this.visit(function(t){if(!t.length)do n.push(t.data);while(t=t.next)}),n}function vA(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Re(n,t,e,i,r){this.node=n,this.x0=t,this.y0=e,this.x1=i,this.y1=r}function wA(n,t,e){var i,r=this._x0,o=this._y0,s,a,c,l,h=this._x1,f=this._y1,u=[],d=this._root,p,y;for(d&&u.push(new Re(d,r,o,h,f)),e==null?e=1/0:(r=n-e,o=t-e,h=n+e,f=t+e,e*=e);p=u.pop();)if(!(!(d=p.node)||(s=p.x0)>h||(a=p.y0)>f||(c=p.x1)<r||(l=p.y1)<o))if(d.length){var g=(s+c)/2,m=(a+l)/2;u.push(new Re(d[3],g,m,c,l),new Re(d[2],s,m,g,l),new Re(d[1],g,a,c,m),new Re(d[0],s,a,g,m)),(y=(t>=m)<<1|n>=g)&&(p=u[u.length-1],u[u.length-1]=u[u.length-1-y],u[u.length-1-y]=p)}else{var x=n-+this._x.call(null,d.data),v=t-+this._y.call(null,d.data),b=x*x+v*v;if(b<e){var k=Math.sqrt(e=b);r=n-k,o=t-k,h=n+k,f=t+k,i=d.data}}return i}function kA(n){if(isNaN(h=+this._x.call(null,n))||isNaN(f=+this._y.call(null,n)))return this;var t,e=this._root,i,r,o,s=this._x0,a=this._y0,c=this._x1,l=this._y1,h,f,u,d,p,y,g,m;if(!e)return this;if(e.length)for(;;){if((p=h>=(u=(s+c)/2))?s=u:c=u,(y=f>=(d=(a+l)/2))?a=d:l=d,t=e,!(e=e[g=y<<1|p]))return this;if(!e.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(i=t,m=g)}for(;e.data!==n;)if(r=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,r?(o?r.next=o:delete r.next,this):t?(o?t[g]=o:delete t[g],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(i?i[m]=e:this._root=e),this):(this._root=o,this)}function MA(n){for(var t=0,e=n.length;t<e;++t)this.remove(n[t]);return this}function AA(){return this._root}function SA(){var n=0;return this.visit(function(t){if(!t.length)do++n;while(t=t.next)}),n}function _A(n){var t=[],e,i=this._root,r,o,s,a,c;for(i&&t.push(new Re(i,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!n(i=e.node,o=e.x0,s=e.y0,a=e.x1,c=e.y1)&&i.length){var l=(o+a)/2,h=(s+c)/2;(r=i[3])&&t.push(new Re(r,l,h,a,c)),(r=i[2])&&t.push(new Re(r,o,h,l,c)),(r=i[1])&&t.push(new Re(r,l,s,a,h)),(r=i[0])&&t.push(new Re(r,o,s,l,h))}return this}function CA(n){var t=[],e=[],i;for(this._root&&t.push(new Re(this._root,this._x0,this._y0,this._x1,this._y1));i=t.pop();){var r=i.node;if(r.length){var o,s=i.x0,a=i.y0,c=i.x1,l=i.y1,h=(s+c)/2,f=(a+l)/2;(o=r[0])&&t.push(new Re(o,s,a,h,f)),(o=r[1])&&t.push(new Re(o,h,a,c,f)),(o=r[2])&&t.push(new Re(o,s,f,h,l)),(o=r[3])&&t.push(new Re(o,h,f,c,l))}e.push(i)}for(;i=e.pop();)n(i.node,i.x0,i.y0,i.x1,i.y1);return this}function PA(n){return n[0]}function EA(n){return arguments.length?(this._x=n,this):this._x}function TA(n){return n[1]}function LA(n){return arguments.length?(this._y=n,this):this._y}function kl(n,t,e){var i=new Ml(t??PA,e??TA,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function Ml(n,t,e,i,r,o){this._x=n,this._y=t,this._x0=e,this._y0=i,this._x1=r,this._y1=o,this._root=void 0}function Np(n){for(var t={data:n.data},e=t;n=n.next;)e=e.next={data:n.data};return t}var De=kl.prototype=Ml.prototype;De.copy=function(){var n=new Ml(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,i;if(!t)return n;if(!t.length)return n._root=Np(t),n;for(e=[{source:t,target:n._root=new Array(4)}];t=e.pop();)for(var r=0;r<4;++r)(i=t.source[r])&&(i.length?e.push({source:i,target:t.target[r]=new Array(4)}):t.target[r]=Np(i));return n},De.add=mA,De.addAll=yA,De.cover=xA,De.data=bA,De.extent=vA,De.find=wA,De.remove=kA,De.removeAll=MA,De.root=AA,De.size=SA,De.visit=_A,De.visitAfter=CA,De.x=EA,De.y=LA;function Ci(n){return function(){return n}}function ei(n){return(n()-.5)*1e-6}function $A(n){return n.x+n.vx}function IA(n){return n.y+n.vy}function FA(n){var t,e,i,r=1,o=1;typeof n!="function"&&(n=Ci(n==null?1:+n));function s(){for(var l,h=t.length,f,u,d,p,y,g,m=0;m<o;++m)for(f=kl(t,$A,IA).visitAfter(a),l=0;l<h;++l)u=t[l],y=e[u.index],g=y*y,d=u.x+u.vx,p=u.y+u.vy,f.visit(x);function x(v,b,k,M,C){var E=v.data,_=v.r,T=y+_;if(E){if(E.index>u.index){var I=d-E.x-E.vx,L=p-E.y-E.vy,P=I*I+L*L;P<T*T&&(I===0&&(I=ei(i),P+=I*I),L===0&&(L=ei(i),P+=L*L),P=(T-(P=Math.sqrt(P)))/P*r,u.vx+=(I*=P)*(T=(_*=_)/(g+_)),u.vy+=(L*=P)*T,E.vx-=I*(T=1-T),E.vy-=L*T)}return}return b>d+T||M<d-T||k>p+T||C<p-T}}function a(l){if(l.data)return l.r=e[l.data.index];for(var h=l.r=0;h<4;++h)l[h]&&l[h].r>l.r&&(l.r=l[h].r)}function c(){if(t){var l,h=t.length,f;for(e=new Array(h),l=0;l<h;++l)f=t[l],e[f.index]=+n(f,l,t)}}return s.initialize=function(l,h){t=l,i=h,c()},s.iterations=function(l){return arguments.length?(o=+l,s):o},s.strength=function(l){return arguments.length?(r=+l,s):r},s.radius=function(l){return arguments.length?(n=typeof l=="function"?l:Ci(+l),c(),s):n},s}function RA(n){return n.index}function Wp(n,t){var e=n.get(t);if(!e)throw new Error("node not found: "+t);return e}function DA(n){var t=RA,e=f,i,r=Ci(30),o,s,a,c,l,h=1;n==null&&(n=[]);function f(g){return 1/Math.min(a[g.source.index],a[g.target.index])}function u(g){for(var m=0,x=n.length;m<h;++m)for(var v=0,b,k,M,C,E,_,T;v<x;++v)b=n[v],k=b.source,M=b.target,C=M.x+M.vx-k.x-k.vx||ei(l),E=M.y+M.vy-k.y-k.vy||ei(l),_=Math.sqrt(C*C+E*E),_=(_-o[v])/_*g*i[v],C*=_,E*=_,M.vx-=C*(T=c[v]),M.vy-=E*T,k.vx+=C*(T=1-T),k.vy+=E*T}function d(){if(s){var g,m=s.length,x=n.length,v=new Map(s.map((k,M)=>[t(k,M,s),k])),b;for(g=0,a=new Array(m);g<x;++g)b=n[g],b.index=g,typeof b.source!="object"&&(b.source=Wp(v,b.source)),typeof b.target!="object"&&(b.target=Wp(v,b.target)),a[b.source.index]=(a[b.source.index]||0)+1,a[b.target.index]=(a[b.target.index]||0)+1;for(g=0,c=new Array(x);g<x;++g)b=n[g],c[g]=a[b.source.index]/(a[b.source.index]+a[b.target.index]);i=new Array(x),p(),o=new Array(x),y()}}function p(){if(s)for(var g=0,m=n.length;g<m;++g)i[g]=+e(n[g],g,n)}function y(){if(s)for(var g=0,m=n.length;g<m;++g)o[g]=+r(n[g],g,n)}return u.initialize=function(g,m){s=g,l=m,d()},u.links=function(g){return arguments.length?(n=g,d(),u):n},u.id=function(g){return arguments.length?(t=g,u):t},u.iterations=function(g){return arguments.length?(h=+g,u):h},u.strength=function(g){return arguments.length?(e=typeof g=="function"?g:Ci(+g),p(),u):e},u.distance=function(g){return arguments.length?(r=typeof g=="function"?g:Ci(+g),y(),u):r},u}const zA=1664525,BA=1013904223,Hp=4294967296;function OA(){let n=1;return()=>(n=(zA*n+BA)%Hp)/Hp}function NA(n){return n.x}function WA(n){return n.y}var HA=10,VA=Math.PI*(3-Math.sqrt(5));function GA(n){var t,e=1,i=.001,r=1-Math.pow(i,1/300),o=0,s=.6,a=new Map,c=Zo(f),l=Oi("tick","end"),h=OA();n==null&&(n=[]);function f(){u(),l.call("tick",t),e<i&&(c.stop(),l.call("end",t))}function u(y){var g,m=n.length,x;y===void 0&&(y=1);for(var v=0;v<y;++v)for(e+=(o-e)*r,a.forEach(function(b){b(e)}),g=0;g<m;++g)x=n[g],x.fx==null?x.x+=x.vx*=s:(x.x=x.fx,x.vx=0),x.fy==null?x.y+=x.vy*=s:(x.y=x.fy,x.vy=0);return t}function d(){for(var y=0,g=n.length,m;y<g;++y){if(m=n[y],m.index=y,m.fx!=null&&(m.x=m.fx),m.fy!=null&&(m.y=m.fy),isNaN(m.x)||isNaN(m.y)){var x=HA*Math.sqrt(.5+y),v=y*VA;m.x=x*Math.cos(v),m.y=x*Math.sin(v)}(isNaN(m.vx)||isNaN(m.vy))&&(m.vx=m.vy=0)}}function p(y){return y.initialize&&y.initialize(n,h),y}return d(),t={tick:u,restart:function(){return c.restart(f),t},stop:function(){return c.stop(),t},nodes:function(y){return arguments.length?(n=y,d(),a.forEach(p),t):n},alpha:function(y){return arguments.length?(e=+y,t):e},alphaMin:function(y){return arguments.length?(i=+y,t):i},alphaDecay:function(y){return arguments.length?(r=+y,t):+r},alphaTarget:function(y){return arguments.length?(o=+y,t):o},velocityDecay:function(y){return arguments.length?(s=1-y,t):1-s},randomSource:function(y){return arguments.length?(h=y,a.forEach(p),t):h},force:function(y,g){return arguments.length>1?(g==null?a.delete(y):a.set(y,p(g)),t):a.get(y)},find:function(y,g,m){var x=0,v=n.length,b,k,M,C,E;for(m==null?m=1/0:m*=m,x=0;x<v;++x)C=n[x],b=y-C.x,k=g-C.y,M=b*b+k*k,M<m&&(E=C,m=M);return E},on:function(y,g){return arguments.length>1?(l.on(y,g),t):l.on(y)}}}function YA(){var n,t,e,i,r=Ci(-30),o,s=1,a=1/0,c=.81;function l(d){var p,y=n.length,g=kl(n,NA,WA).visitAfter(f);for(i=d,p=0;p<y;++p)t=n[p],g.visit(u)}function h(){if(n){var d,p=n.length,y;for(o=new Array(p),d=0;d<p;++d)y=n[d],o[y.index]=+r(y,d,n)}}function f(d){var p=0,y,g,m=0,x,v,b;if(d.length){for(x=v=b=0;b<4;++b)(y=d[b])&&(g=Math.abs(y.value))&&(p+=y.value,m+=g,x+=g*y.x,v+=g*y.y);d.x=x/m,d.y=v/m}else{y=d,y.x=y.data.x,y.y=y.data.y;do p+=o[y.data.index];while(y=y.next)}d.value=p}function u(d,p,y,g){if(!d.value)return!0;var m=d.x-t.x,x=d.y-t.y,v=g-p,b=m*m+x*x;if(v*v/c<b)return b<a&&(m===0&&(m=ei(e),b+=m*m),x===0&&(x=ei(e),b+=x*x),b<s&&(b=Math.sqrt(s*b)),t.vx+=m*d.value*i/b,t.vy+=x*d.value*i/b),!0;if(d.length||b>=a)return;(d.data!==t||d.next)&&(m===0&&(m=ei(e),b+=m*m),x===0&&(x=ei(e),b+=x*x),b<s&&(b=Math.sqrt(s*b)));do d.data!==t&&(v=o[d.data.index]*i/b,t.vx+=m*v,t.vy+=x*v);while(d=d.next)}return l.initialize=function(d,p){n=d,e=p,h()},l.strength=function(d){return arguments.length?(r=typeof d=="function"?d:Ci(+d),h(),l):r},l.distanceMin=function(d){return arguments.length?(s=d*d,l):Math.sqrt(s)},l.distanceMax=function(d){return arguments.length?(a=d*d,l):Math.sqrt(a)},l.theta=function(d){return arguments.length?(c=d*d,l):Math.sqrt(c)},l}class XA extends Xt{constructor(t){super(t),this.simulation=null}render(){var L,P,A;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,{nodes:o,links:s}=this.buildGraph();if(o.length===0)return;const a=r.link||{},c=r.layoutAlgorithm||{},l=r.draggable!==!1,h=c.linkLength??a.distance??80,f=a.color??"#999",u=a.width,d=a.dashStyle,p=c.maxIterations??300,y=c.gravitationalConstant??-200,g=c.friction??.9,m=c.maxSpeed??10,x=c.initialPositions,v=c.attractiveForce,b=c.repulsiveForce;if(x==="circle"){const w=t.width/2,S=t.height/2,$=Math.min(t.width,t.height)/3;o.forEach((R,F)=>{const D=2*Math.PI*F/o.length;R.x=w+$*Math.cos(D),R.y=S+$*Math.sin(D)})}else x==="random"?o.forEach(w=>{w.x=Math.random()*t.width,w.y=Math.random()*t.height}):typeof x=="function"&&x(o);const k=Math.sqrt(t.width*t.height/Math.max(o.length,1)),M=DA(s).id(w=>w.id);v?M.distance(w=>v(Math.sqrt((w.source.x-w.target.x)**2+(w.source.y-w.target.y)**2)||1,k)):M.distance(h);const C=YA();b?C.strength(w=>-b(1,k)):C.strength(y),this.simulation=GA(o).force("link",M).force("charge",C).force("center",gA(t.width/2,t.height/2)).force("collide",FA(20)).velocityDecay(1-g).alphaDecay(1-Math.pow(.001,1/p)).stop();for(let w=0;w<p;w++)this.simulation.tick(),o.forEach(S=>{const $=Math.abs(S.vx||0),R=Math.abs(S.vy||0);$>m&&(S.vx=Math.sign(S.vx)*m),R>m&&(S.vy=Math.sign(S.vy)*m)});o.forEach(w=>{var $;const S=(($=w.marker)==null?void 0:$.radius)||10;w.x=Math.max(S+30,Math.min(t.width-S-30,w.x??0)),w.y=Math.max(S+18,Math.min(t.height-S-6,w.y??0))});const E=this.getDashArray(d),_=this.group.selectAll(".katucharts-network-link").data(s).join("line").attr("class","katucharts-network-link").attr("x1",w=>w.source.x).attr("y1",w=>w.source.y).attr("x2",w=>w.target.x).attr("y2",w=>w.target.y).attr("stroke",f).attr("stroke-width",w=>u??Math.sqrt(w.value||1)).attr("stroke-dasharray",E);i?_.attr("stroke-opacity",0).transition().duration(bt).ease(pt).attr("stroke-opacity",.6):_.attr("stroke-opacity",.6);const T=this.group.selectAll(".katucharts-network-node").data(o).join("circle").attr("class","katucharts-network-node").attr("cx",w=>w.x).attr("cy",w=>w.y).attr("fill",(w,S)=>w.color||e[S%e.length]).attr("stroke",this.autoBorderColor()).attr("stroke-width",1.5).style("cursor",l?"grab":"pointer");if(i?T.attr("r",0).transition().duration(bt).ease(pt).attr("r",w=>{var S;return((S=w.marker)==null?void 0:S.radius)||10}):T.attr("r",w=>{var S;return((S=w.marker)==null?void 0:S.radius)||10}),l){const w=vf().on("start",(S,$)=>{st(S.sourceEvent.target).style("cursor","grabbing"),this.simulation&&this.simulation.alphaTarget(.3).restart(),$.fx=$.x,$.fy=$.y}).on("drag",(S,$)=>{$.fx=S.x,$.fy=S.y,$.x=S.x,$.y=S.y,this.updatePositions(T,_,I)}).on("end",(S,$)=>{st(S.sourceEvent.target).style("cursor","grab"),this.simulation&&this.simulation.alphaTarget(0),$.fx=null,$.fy=null});T.call(w)}T.on("mouseover",(w,S)=>{var D;const $=st(w.currentTarget),R=((D=S.marker)==null?void 0:D.radius)||10;$.transition("size").duration(Z).ease(j).attr("r",R+4),$.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.3))"),T.interrupt("highlight"),_.interrupt("highlight"),T.attr("opacity",1),_.transition("highlight").duration(Z).ease(j).attr("stroke-opacity",z=>z.source===S||z.target===S?.9:.1).attr("stroke-width",z=>z.source===S||z.target===S?3:u??Math.sqrt(z.value||1)),T.filter(z=>z!==S).transition("highlight").duration(Z).ease(j).attr("opacity",z=>s.some(W=>W.source===S&&W.target===z||W.target===S&&W.source===z)?1:.3);const F=o.indexOf(S);this.context.events.emit("point:mouseover",{point:{name:S.name||S.id},index:F,series:this,event:w,plotX:S.x,plotY:S.y})}).on("mouseout",(w,S)=>{var F;const $=st(w.currentTarget);$.transition("size").duration(Z).ease(j).attr("r",((F=S.marker)==null?void 0:F.radius)||10),$.style("filter",""),T.interrupt("highlight"),_.interrupt("highlight"),_.transition("highlight").duration(Z).ease(j).attr("stroke-opacity",.6).attr("stroke-width",D=>u??Math.sqrt(D.value||1)),T.transition("highlight").duration(Z).ease(j).attr("opacity",1);const R=o.indexOf(S);this.context.events.emit("point:mouseout",{point:{name:S.name||S.id},index:R,series:this,event:w})}).on("click",(w,S)=>{const $=o.indexOf(S);this.context.events.emit("point:click",{point:{name:S.name||S.id},index:$,series:this,event:w})});const I=this.group.selectAll(".katucharts-network-label").data(o).join("text").attr("class","katucharts-network-label").attr("x",w=>w.x).attr("y",w=>w.y-14).attr("text-anchor","middle").attr("font-size",kt).attr("fill",this.autoLabelColor(((L=this.config.dataLabels)==null?void 0:L.color)||((A=(P=this.config.dataLabels)==null?void 0:P.style)==null?void 0:A.color))).style("pointer-events","none").text(w=>w.name||w.id);i&&I.attr("opacity",0).transition().duration(bt).ease(pt).attr("opacity",1)}updatePositions(t,e,i){t.attr("cx",r=>r.x).attr("cy",r=>r.y),e.attr("x1",r=>r.source.x).attr("y1",r=>r.source.y).attr("x2",r=>r.target.x).attr("y2",r=>r.target.y),i.attr("x",r=>r.x).attr("y",r=>r.y-14)}getDashArray(t){return t&&{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t]||"none"}buildGraph(){const t=new Map,e=[],i=this.config.nodes||[];for(const r of i)t.set(r.id,{...r});for(const r of this.data){const o=r[0]||r.from,s=r[1]||r.to;o&&s&&(t.has(o)||t.set(o,{id:o,name:o}),t.has(s)||t.set(s,{id:s,name:s}),e.push({source:o,target:s,value:r.y??1}))}return{nodes:Array.from(t.values()),links:e}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}destroy(){this.simulation&&(this.simulation.stop(),this.simulation=null),super.destroy()}}var UA=Math.PI,Vp=UA*2,Gp=Math.max;function Yp(n,t){return Array.from({length:t-n},(e,i)=>n+i)}function jA(n){return function(t,e){return n(t.source.value+t.target.value,e.source.value+e.target.value)}}function qA(){return ZA(!1)}function ZA(n,t){var e=0,i=null,r=null,o=null;function s(a){var c=a.length,l=new Array(c),h=Yp(0,c),f=new Array(c*c),u=new Array(c),d=0,p;a=Float64Array.from({length:c*c},(y,g)=>a[g/c|0][g%c]);for(let y=0;y<c;++y){let g=0;for(let m=0;m<c;++m)g+=a[y*c+m]+n*a[m*c+y];d+=l[y]=g}d=Gp(0,Vp-e*c)/d,p=d?e:Vp/c;{let y=0;i&&h.sort((g,m)=>i(l[g],l[m]));for(const g of h){const m=y;{const x=Yp(0,c).filter(v=>a[g*c+v]||a[v*c+g]);r&&x.sort((v,b)=>r(a[g*c+v],a[g*c+b]));for(const v of x){let b;if(g<v?(b=f[g*c+v]||(f[g*c+v]={source:null,target:null}),b.source={index:g,startAngle:y,endAngle:y+=a[g*c+v]*d,value:a[g*c+v]}):(b=f[v*c+g]||(f[v*c+g]={source:null,target:null}),b.target={index:g,startAngle:y,endAngle:y+=a[g*c+v]*d,value:a[g*c+v]},g===v&&(b.source=b.target)),b.source&&b.target&&b.source.value<b.target.value){const k=b.source;b.source=b.target,b.target=k}}u[g]={index:g,startAngle:m,endAngle:y,value:l[g]}}y+=p}}return f=Object.values(f),f.groups=u,o?f.sort(o):f}return s.padAngle=function(a){return arguments.length?(e=Gp(0,a),s):e},s.sortGroups=function(a){return arguments.length?(i=a,s):i},s.sortSubgroups=function(a){return arguments.length?(r=a,s):r},s.sortChords=function(a){return arguments.length?(a==null?o=null:(o=jA(a))._=a,s):o&&o._},s}class KA extends Xt{constructor(t){super(t)}render(){var Zr,Kr,Jr;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,o=r.labelType??"max",s=bt*2,a=8,c=Math.round(s*.48),l=12,h=Math.round(c*.65),f=c+8,u=r.nodeWidth??20,d=r.linkOpacity??.5;r.minLinkWidth;const p=(r.startAngle??0)*(Math.PI/180),y=(Zr=this.group.node())==null?void 0:Zr.parentElement;y&&st(y).attr("clip-path",null);const g=this.group.select(function(){return this.ownerSVGElement});g.empty()||g.style("overflow","visible");const m=r.center||["50%","50%"],x=this.resolvePercent(m[0],t.width),v=this.resolvePercent(m[1],t.height),b=r.size,k=o==="small"?34:70,M=o==="small"?34:24,C=Math.max(80,Math.min(t.width-2*k,t.height-2*M)),E=b?this.resolvePercent(b,C):C,_=Math.max(40,E/2-2),T=_-u,{matrix:I,names:L,nodeColors:P}=this.buildMatrix();if(L.length===0)return;const w=(r.nodePadding??2)/(_>0?_:1),$=qA().padAngle(w).sortSubgroups(null)(I);this.normalizeChordWidths($),this.sortChordEndpoints($);const R=Ce().innerRadius(T).outerRadius(_).cornerRadius(3),F=Ce().innerRadius(T).outerRadius(_+4).cornerRadius(3),D=r.curveFactor??.05,z=rt=>{const ot=T,ut=rt.source.startAngle+p-Math.PI/2,wt=rt.source.endAngle+p-Math.PI/2,xt=rt.target.startAngle+p-Math.PI/2,mt=rt.target.endAngle+p-Math.PI/2,J=ot*Math.cos(ut),Lt=ot*Math.sin(ut),zt=ot*Math.cos(wt),gt=ot*Math.sin(wt),jt=ot*Math.cos(xt),Ot=ot*Math.sin(xt),qt=ot*Math.cos(mt),ie=ot*Math.sin(mt),Wt=Math.abs(wt-ut)>Math.PI?1:0,fn=Math.abs(mt-xt)>Math.PI?1:0;let Oe=Math.abs(xt-wt);Oe>Math.PI&&(Oe=2*Math.PI-Oe);const Ue=Oe/Math.PI,Pe=ot*Math.max(D,(1-Ue)*(1-Ue)*(1-Ue));let dn=Math.abs(ut-mt);dn>Math.PI&&(dn=2*Math.PI-dn);const wn=dn/Math.PI,Xn=ot*Math.max(D,(1-wn)*(1-wn)*(1-wn));return`M${J},${Lt}A${ot},${ot},0,${Wt},1,${zt},${gt}C${Pe*Math.cos(wt)},${Pe*Math.sin(wt)},${Pe*Math.cos(xt)},${Pe*Math.sin(xt)},${jt},${Ot}A${ot},${ot},0,${fn},1,${qt},${ie}C${Xn*Math.cos(mt)},${Xn*Math.sin(mt)},${Xn*Math.cos(ut)},${Xn*Math.sin(ut)},${J},${Lt}Z`},B=this.group.append("g").attr("transform",`translate(${x},${v})`),W=rt=>P[rt]||e[rt%e.length],K=r.linkColorMode??"from",X=B.append("defs");let q=null;K==="gradient"&&(q=X);const N=rt=>W(K==="to"?rt.target.index:rt.source.index),H=u*2,Y=(rt,ot,ut,wt)=>{const xt=`katucharts-dw-edge-${wt}-${ut}-${Math.random().toString(36).slice(2,6)}`,mt=T*Math.cos(rt),J=T*Math.sin(rt),Lt=(T-H)*Math.cos(rt),zt=(T-H)*Math.sin(rt);return X.append("linearGradient").attr("id",xt).attr("gradientUnits","userSpaceOnUse").attr("x1",mt).attr("y1",J).attr("x2",Lt).attr("y2",zt).selectAll("stop").data([{offset:"0%",opacity:.7},{offset:"25%",opacity:.2},{offset:"50%",opacity:.05},{offset:"100%",opacity:0}]).join("stop").attr("offset",gt=>gt.offset).attr("stop-color",ot).attr("stop-opacity",gt=>gt.opacity),xt},G=K!=="gradient";let Q,O;if(G){const rt=new Map;for(const wt of $){const xt=N(wt);rt.has(xt)||rt.set(xt,[]),rt.get(xt).push(wt)}const ot=B.append("g").attr("class","katucharts-chord-container");for(const[wt,xt]of rt)ot.append("g").attr("class","katucharts-chord-group").attr("opacity",d).selectAll(".katucharts-chord").data(xt).join("path").attr("class","katucharts-chord").attr("d",J=>z(J)).attr("fill",wt).attr("fill-opacity",1).attr("stroke","none").style("cursor","pointer");Q=ot.selectAll(".katucharts-chord"),O=ot.selectAll(".katucharts-chord-group");const ut=B.append("g").attr("class","katucharts-chord-edges").attr("opacity",d);if($.forEach((wt,xt)=>{const mt=W(wt.source.index),J=W(wt.target.index);if(mt===J)return;const Lt=z(wt),zt=(wt.target.startAngle+wt.target.endAngle)/2+p-Math.PI/2,gt=Y(zt,J,xt,"tgt");ut.append("path").attr("d",Lt).attr("fill",`url(#${gt})`).attr("stroke","none").style("pointer-events","none");const jt=(wt.source.startAngle+wt.source.endAngle)/2+p-Math.PI/2,Ot=Y(jt,mt,xt,"src");ut.append("path").attr("d",Lt).attr("fill",`url(#${Ot})`).attr("stroke","none").style("pointer-events","none")}),i){ut.attr("opacity",0);const wt=B.append("defs"),xt=Math.round(s*.62);Q.each(function(J,Lt){const zt=f+Lt*a,gt=`dw-clip-${Lt}-${Math.random().toString(36).slice(2,6)}`,jt=J.source.startAngle+p-Math.PI/2,Ot=J.source.endAngle+p-Math.PI/2,qt=J.target.startAngle+p-Math.PI/2,ie=J.target.endAngle+p-Math.PI/2,Wt=(jt+Ot)/2,fn=(qt+ie)/2,Oe=T*Math.cos(Wt),Ue=T*Math.sin(Wt),Pe=T*Math.cos(fn),dn=T*Math.sin(fn),wn=Math.atan2(dn-Ue,Pe-Oe)*180/Math.PI,Xn=Math.sqrt((Pe-Oe)**2+(dn-Ue)**2)+_*2,Qr=wt.append("clipPath").attr("id",gt).attr("clipPathUnits","userSpaceOnUse"),V=Qr.append("rect").attr("transform",`translate(${Oe},${Ue}) rotate(${wn})`).attr("x",-_).attr("y",-_).attr("width",0).attr("height",_*2),tt=st(this);tt.attr("clip-path",`url(#${gt})`),V.transition("enter").duration(xt).delay(zt).ease(pt).attr("width",Xn).on("end",function(){tt.attr("clip-path",null),Qr.remove()})});const mt=f+($.length-1)*a+xt;ut.transition("enter").duration(300).delay(mt).ease(pt).attr("opacity",d)}}else if(Q=B.selectAll(".katucharts-chord").data($).join("path").attr("class","katucharts-chord").attr("d",rt=>z(rt)).attr("stroke","none").style("cursor","pointer"),Q.each(function(rt,ot){const ut=`katucharts-dw-grad-${ot}-${Math.random().toString(36).slice(2,6)}`,wt=(rt.source.startAngle+rt.source.endAngle)/2+p-Math.PI/2,xt=(rt.target.startAngle+rt.target.endAngle)/2+p-Math.PI/2;q.append("linearGradient").attr("id",ut).attr("gradientUnits","userSpaceOnUse").attr("x1",T*Math.cos(wt)).attr("y1",T*Math.sin(wt)).attr("x2",T*Math.cos(xt)).attr("y2",T*Math.sin(xt)).selectAll("stop").data([{offset:"0%",color:W(rt.source.index)},{offset:"100%",color:W(rt.target.index)}]).join("stop").attr("offset",mt=>mt.offset).attr("stop-color",mt=>mt.color),st(this).attr("fill",`url(#${ut})`)}),i){Q.attr("fill-opacity",d);const rt=B.append("defs"),ot=Math.round(s*.62);Q.each(function(ut,wt){const xt=f+wt*a,mt=`dw-clip-${wt}-${Math.random().toString(36).slice(2,6)}`,J=ut.source.startAngle+p-Math.PI/2,Lt=ut.source.endAngle+p-Math.PI/2,zt=ut.target.startAngle+p-Math.PI/2,gt=ut.target.endAngle+p-Math.PI/2,jt=(J+Lt)/2,Ot=(zt+gt)/2,qt=T*Math.cos(jt),ie=T*Math.sin(jt),Wt=T*Math.cos(Ot),fn=T*Math.sin(Ot),Oe=Math.atan2(fn-ie,Wt-qt)*180/Math.PI,Ue=Math.sqrt((Wt-qt)**2+(fn-ie)**2)+_*2,Pe=rt.append("clipPath").attr("id",mt).attr("clipPathUnits","userSpaceOnUse"),dn=Pe.append("rect").attr("transform",`translate(${qt},${ie}) rotate(${Oe})`).attr("x",-_).attr("y",-_).attr("width",0).attr("height",_*2),wn=st(this);wn.attr("clip-path",`url(#${mt})`),dn.transition("enter").duration(ot).delay(xt).ease(pt).attr("width",Ue).on("end",function(){wn.attr("clip-path",null),Pe.remove()})})}else Q.attr("fill-opacity",d);const it=(rt,ot,ut)=>{const wt=L[ut.source.index],xt=L[ut.target.index],mt={name:`${wt} → ${xt}`,from:wt,to:xt,y:ut.source.value,weight:ut.source.value,fromNode:{name:wt},toNode:{name:xt}};if(rt==="mouseover"){this.context.events.emit("point:mouseover",{point:mt,index:$.indexOf(ut),series:this,event:ot,plotX:ot.offsetX-this.context.plotArea.x,plotY:ot.offsetY-this.context.plotArea.y});return}if(rt==="mouseout"){this.context.events.emit("point:mouseout",{point:mt,index:$.indexOf(ut),series:this,event:ot});return}this.context.events.emit("point:click",{point:mt,index:$.indexOf(ut),series:this,event:ot})},et=(rt,ot)=>{Q.interrupt("highlight"),Mt.interrupt("highlight"),O&&O.interrupt("highlight").attr("opacity",1),Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",ut=>ut===ot?Math.min(d+.35,1):.05),Mt.attr("opacity",1),Mt.transition("highlight").duration(Z).ease(j).attr("opacity",ut=>ut.index===ot.source.index||ut.index===ot.target.index?1:.3),it("mouseover",rt,ot)},ht=(rt,ot)=>{Q.interrupt("highlight"),Mt.interrupt("highlight"),O?(O.interrupt("highlight"),O.transition("highlight").duration(Z).ease(j).attr("opacity",d),Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",1)):Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",d),Mt.transition("highlight").duration(Z).ease(j).attr("opacity",1),it("mouseout",rt,ot)},ft=(rt,ot)=>{it("click",rt,ot)};Q.on("mouseover",et).on("mouseout",ht).on("click",ft);const ct=$.groups.map(rt=>({...rt,startAngle:rt.startAngle+p,endAngle:rt.endAngle+p})),nt=rt=>{const ot=Math.PI*2;let ut=rt%ot;return ut<0&&(ut+=ot),ut},U=(rt,ot)=>{const ut=rt.offsetX-this.context.plotArea.x-x,wt=rt.offsetY-this.context.plotArea.y-v,xt=nt(Math.atan2(wt,ut)+Math.PI/2),mt=$.filter(Ot=>Ot.source.index===ot.index||Ot.target.index===ot.index);if(mt.length===0)return null;const J=Ot=>Ot.source.index===ot.index?Ot.source:Ot.target,Lt=Ot=>{const qt=J(Ot),ie=nt(qt.startAngle+p),Wt=nt(qt.endAngle+p);return ie<=Wt?xt>=ie&&xt<=Wt:xt>=ie||xt<=Wt},zt=mt.find(Lt);if(zt)return zt;let gt=mt[0],jt=1/0;for(const Ot of mt){const qt=J(Ot),ie=nt((qt.startAngle+qt.endAngle)/2+p);let Wt=Math.abs(xt-ie);Wt>Math.PI&&(Wt=Math.PI*2-Wt),Wt<jt&&(jt=Wt,gt=Ot)}return gt},at=rt=>{const ot=L[rt.source.index],ut=L[rt.target.index];return{name:`${ot} → ${ut}`,from:ot,to:ut,y:rt.source.value,weight:rt.source.value,fromNode:{name:ot},toNode:{name:ut}}},yt=r.borderColor??this.autoBorderColor(),St=r.borderWidth??1,Mt=B.selectAll(".katucharts-chord-arc").data(ct).join("path").attr("class","katucharts-chord-arc").attr("fill",rt=>W(rt.index)).attr("stroke",yt).attr("stroke-width",St).style("cursor","pointer");i?Mt.each(function(rt,ot){const ut=st(this),wt={startAngle:rt.startAngle,endAngle:rt.startAngle},xt=he(wt,rt);ut.transition("enter").duration(c).delay(ot*l).ease(pt).attrTween("d",()=>mt=>R(xt(mt)))}):Mt.attr("d",R),Mt.on("mouseover",(rt,ot)=>{st(rt.currentTarget).transition("arc").duration(Z).ease(j).attr("d",F(ot)),Q.interrupt("highlight"),Mt.interrupt("highlight"),O&&O.interrupt("highlight").attr("opacity",1),Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",xt=>xt.source.index===ot.index||xt.target.index===ot.index?Math.min(d+.35,1):.05),Mt.attr("opacity",1),Mt.filter(xt=>xt!==ot).transition("highlight").duration(Z).ease(j).attr("opacity",xt=>$.some(J=>J.source.index===ot.index&&J.target.index===xt.index||J.target.index===ot.index&&J.source.index===xt.index)?1:.3),Qe.filter(xt=>xt.index===ot.index).transition("label").duration(Z).ease(j).attr("opacity",1);const wt=U(rt,ot);this.context.events.emit("point:mouseover",{point:wt?at(wt):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt,plotX:rt.offsetX-this.context.plotArea.x,plotY:rt.offsetY-this.context.plotArea.y})}).on("mouseout",(rt,ot)=>{st(rt.currentTarget).transition("arc").duration(Z).ease(j).attr("d",R(ot)),Q.interrupt("highlight"),Mt.interrupt("highlight"),O?(O.interrupt("highlight"),O.transition("highlight").duration(Z).ease(j).attr("opacity",d),Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",1)):Q.transition("highlight").duration(Z).ease(j).attr("fill-opacity",d),Mt.transition("highlight").duration(Z).ease(j).attr("opacity",1),Qe.filter(xt=>xt.index===ot.index).transition("label").duration(Z).ease(j).attr("opacity",xt=>un(xt)?1:0);const wt=U(rt,ot);this.context.events.emit("point:mouseout",{point:wt?at(wt):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt})}).on("click",(rt,ot)=>{const ut=U(rt,ot);this.context.events.emit("point:click",{point:ut?at(ut):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt})}),B.append("g").attr("class","katucharts-chord-hitareas").selectAll(".katucharts-chord-hitarea").data($).join("path").attr("class","katucharts-chord-hitarea").attr("d",rt=>z(rt)).attr("fill","#ffffff").attr("fill-opacity",0).attr("stroke","#ffffff").attr("stroke-opacity",0).attr("stroke-width",12).attr("stroke-linejoin","round").style("cursor","pointer").style("pointer-events","all").on("mouseover",et).on("mouseout",ht).on("click",ft);const Et=this.config.dataLabels||{},Ht=Et.color||((Kr=Et.style)==null?void 0:Kr.color)||Le,ne=((Jr=Et.style)==null?void 0:Jr.fontSize)||kt,Ct=me(ne),Zt=22,Qt=_+Zt,ge=Math.max(Ct*1.6,17),Vt="…",Ut=He(Vt,Ct,"bold"),Xe=(rt,ot)=>{if(!rt||ot<=Ut)return"";if(He(rt,Ct,"bold")<=ot)return rt;let ut="";for(const wt of rt){if(He(ut+wt,Ct,"bold")+Ut>ot)break;ut+=wt}return ut=ut.trimEnd(),(ut||rt[0])+Vt},se=t.width-x,hn=x,vn=v,ze=t.height-v,Be=ct.map(rt=>{const ot=(rt.startAngle+rt.endAngle)/2,ut=Math.sin(ot)>=0;return{index:rt.index,mid:ot,span:rt.endAngle-rt.startAngle,isRight:ut,ax:_*Math.sin(ot),ay:-_*Math.cos(ot),lx:Qt*Math.sin(ot),ly:-Qt*Math.cos(ot),rank:rt.value||0,color:W(rt.index),visible:!!L[rt.index]}}),un=rt=>!!rt.visible,Je=B.append("g").attr("class","katucharts-chord-labels");let Qe;if(o==="small"){const rt=Math.PI*2,ot=_+6+Ct*.5,ut=mt=>[ot*Math.sin(mt),-ot*Math.cos(mt)],wt=(mt,J)=>{if(!mt)return"";const Lt=J*ot-2;if(Lt<He(mt[0],Ct,"bold"))return"";if(He(mt,Ct,"bold")<=Lt)return mt;let zt="";for(const gt of mt){if(zt&&He(zt+gt,Ct,"bold")>Lt)break;zt+=gt}return zt},xt=B.append("defs");if(Qe=Je.selectAll(".katucharts-chord-label").data(Be.filter(mt=>mt.visible)).join("text").attr("class","katucharts-chord-label").attr("font-size",ne).attr("font-weight","bold").attr("fill",Ht).style("pointer-events","none").attr("opacity",0),Qe.each((mt,J,Lt)=>{const zt=st(Lt[J]);zt.text(null);const gt=wt(L[mt.index]||"",mt.span);if(!gt)return;const jt=(mt.mid%rt+rt)%rt,Ot=jt>Math.PI/2&&jt<Math.PI*3/2,qt=mt.span/2,[ie,Wt]=ut(Ot?mt.mid+qt:mt.mid-qt),[fn,Oe]=ut(Ot?mt.mid-qt:mt.mid+qt),Ue=Ot?0:1,Pe=`katucharts-dw-label-${J}-${Math.random().toString(36).slice(2,6)}`;xt.append("path").attr("id",Pe).attr("fill","none").attr("d",`M${ie},${Wt}A${ot},${ot},0,0,${Ue},${fn},${Oe}`),zt.append("textPath").attr("href",`#${Pe}`).attr("startOffset","50%").attr("text-anchor","middle").attr("dominant-baseline","central").text(gt)}),i){Qe.transition("enter").duration(300).delay(h).ease(pt).attr("opacity",1);const mt=Math.round(s*.62),J=$.length,Lt=f+J*a+mt;this.emitAfterAnimate(Lt+100)}else Qe.attr("opacity",1)}else{const rt=Math.max(1,vn-5+(ze-5));if(o==="medium"){const Lt=Math.max(1,Math.min(10,Math.floor(rt/(ge*1.2))))*2,zt=Be.filter(gt=>gt.visible).sort((gt,jt)=>jt.rank-gt.rank);zt.length>Lt&&zt.slice(Lt).forEach(gt=>{gt.visible=!1})}else{const J=Math.max(3,Math.floor(rt/(ge*2)));for(const Lt of[!0,!1])Be.filter(gt=>gt.visible&&gt.isRight===Lt).sort((gt,jt)=>jt.rank-gt.rank).slice(J).forEach(gt=>{gt.visible=!1})}this.distributeChordLabels(Be.filter(J=>J.visible&&J.isRight),ge,vn,ze),this.distributeChordLabels(Be.filter(J=>J.visible&&!J.isRight),ge,vn,ze);const ot=Math.max(Ct*1.4,16),ut=J=>{const Lt=J.filter(Ot=>Ot.visible).sort((Ot,qt)=>Ot.ly-qt.ly),zt=Lt.length*ge/rt;let gt=1;Lt.length>=8&&zt>.5&&(gt=2),Lt.length>=14&&zt>.75&&(gt=3);const jt=Math.max(1,gt*2-2);Lt.forEach((Ot,qt)=>{if(gt<=1){Ot.col=0;return}const ie=qt%jt;Ot.col=ie<gt?ie:jt-ie})};if(o==="medium")for(const J of Be)J.col=0;else ut(Be.filter(J=>J.isRight)),ut(Be.filter(J=>!J.isRight));for(const J of Be){if(!J.visible)continue;const Lt=(J.col||0)*ot,zt=Qt+Lt,gt=Math.max(-zt,Math.min(zt,J.ly)),jt=Math.sqrt(Math.max(0,zt*zt-gt*gt)),Ot=_*.4+Lt;J.lx=J.isRight?Math.max(jt,Ot):-Math.max(jt,Ot);const qt=(J.isRight?se:hn)-Ut-4;J.lx=J.isRight?Math.min(J.lx,qt):Math.max(J.lx,-qt)}const wt=J=>J.lx+(J.isRight?4:-4),xt=J=>Math.max(0,(J.isRight?se-wt(J):wt(J)+hn)-6),mt=Je.selectAll(".katucharts-chord-connector").data(Be.filter(J=>J.visible)).join("path").attr("class","katucharts-chord-connector").attr("fill","none").attr("stroke",J=>J.color).attr("stroke-width",1).attr("opacity",0).attr("d",J=>{const Lt=_+Zt*.55,zt=Lt*Math.sin(J.mid),gt=-Lt*Math.cos(J.mid);return`M${J.ax},${J.ay}L${zt},${gt}L${J.lx},${J.ly}`});if(Qe=Je.selectAll(".katucharts-chord-label").data(Be).join("text").attr("class","katucharts-chord-label").attr("text-anchor",J=>J.isRight?"start":"end").attr("dominant-baseline","middle").attr("font-size",ne).attr("font-weight","bold").attr("fill",Ht).style("pointer-events","none").attr("opacity",0).attr("x",J=>wt(J)).attr("y",J=>J.ly).text(J=>J.visible&&xt(J)>=Ut?Xe(L[J.index]||"",xt(J)):""),i){mt.transition("enter").duration(300).delay(h).ease(pt).attr("opacity",.8),Qe.transition("enter").duration(300).delay(h).ease(pt).attr("opacity",gt=>un(gt)?1:0);const J=Math.round(s*.62),Lt=$.length,zt=f+Lt*a+J;this.emitAfterAnimate(zt+100)}else mt.attr("opacity",.8),Qe.attr("opacity",J=>un(J)?1:0)}}distributeChordLabels(t,e,i,r){const o=t.filter(h=>h.visible);if(o.length<=1)return;const s=-(i-5),c=r-5-s,l=o.map(h=>({target:h.ly-s,size:e,rank:h.rank,pos:0,removed:!1,label:h}));this.distributeBoxes(l,c,c,c/4);for(const h of l)h.removed?h.label.visible=!1:h.label.ly=s+h.pos+e/2}distributeBoxes(t,e,i,r){const o=t.filter(l=>!l.removed);if(o.length===0)return;let s=o.reduce((l,h)=>l+h.size,0);if(s>e){const l=[...o].sort((f,u)=>f.rank-u.rank);let h=0;for(;s>e&&h<l.length;)l[h].removed=!0,s-=l[h].size,h++}const a=o.filter(l=>!l.removed);if(a.length===0)return;a.sort((l,h)=>l.target-h.target);for(let l=0;l<a.length;l++)if(a[l].pos=a[l].target,l>0){const h=a[l-1].pos+a[l-1].size;a[l].pos<h&&(a[l].pos=h)}for(let l=a.length-1;l>=0;l--){const h=l===a.length-1?e-a[l].size:a[l+1].pos-a[l].size;a[l].pos>h&&(a[l].pos=Math.max(0,h))}for(let l=0;l<5;l++)for(let h=0;h<a.length;h++){const f=a[h].pos+(a[h].target-a[h].pos)*.3,u=h>0?a[h-1].pos+a[h-1].size:0,d=h<a.length-1?a[h+1].pos-a[h].size:e-a[h].size;a[h].pos=Math.max(u,Math.min(d,f))}if(a.some(l=>Math.abs(l.pos-l.target)>r)){const l=e*.9;if(l>=i*.1){const h=[...a].sort((f,u)=>f.rank-u.rank);h[0].removed=!0,this.distributeBoxes(t,l,i,l/4)}}}resolvePercent(t,e){return typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:typeof t=="number"?t:parseFloat(t)||e/2}normalizeChordWidths(t){const e=t.groups;if(e.length===0)return;let i=0;for(const r of e){const o=r.endAngle-r.startAngle;o>0&&r.value>0&&(i=Math.max(i,r.value/o))}if(i!==0)for(const r of e){const o=[];for(const f of t)f.source.index===r.index&&o.push({ref:f.source,value:f.source.value}),f.target.index===r.index&&o.push({ref:f.target,value:f.target.value});if(o.length===0)continue;o.sort((f,u)=>f.ref.startAngle-u.ref.startAngle);const s=r.endAngle-r.startAngle,a=o.reduce((f,u)=>f+u.value/i,0),l=Math.max(0,s-a)/(o.length+1);let h=r.startAngle+l;for(const f of o){const u=f.value/i;f.ref.startAngle=h,f.ref.endAngle=h+u,h+=u+l}}}sortChordEndpoints(t){const e=t.groups,i=2*Math.PI;for(const r of e){const o=[],s=d=>d.side==="source"?d.chord.source:d.chord.target;for(const d of t){if(d.source.index===r.index){const p=e[d.target.index];o.push({chord:d,side:"source",partnerMid:(p.startAngle+p.endAngle)/2,width:d.source.endAngle-d.source.startAngle})}if(d.target.index===r.index){const p=e[d.source.index];o.push({chord:d,side:"target",partnerMid:(p.startAngle+p.endAngle)/2,width:d.target.endAngle-d.target.startAngle})}}if(o.length<=1)continue;const a=r.endAngle-r.startAngle,c=o.reduce((d,p)=>d+p.width,0),h=Math.max(0,a-c)/(o.length+1),f=r.endAngle;o.sort((d,p)=>{const y=((d.partnerMid-f)%i+i)%i;return((p.partnerMid-f)%i+i)%i-y});let u=r.startAngle+h;for(const d of o){const p=s(d);p.startAngle=u,p.endAngle=u+d.width,u+=d.width+h}}}buildMatrix(){const t=this.config.nodes||[],e=new Map;for(const c of t)c.color&&e.set(c.id,c.color);const i=new Set;for(const c of this.data)c.from&&i.add(c.from),c.to&&i.add(c.to);const r=Array.from(i),o=new Map(r.map((c,l)=>[c,l])),s=Array.from({length:r.length},()=>new Array(r.length).fill(0));for(const c of this.data){const l=o.get(c.from),h=o.get(c.to);if(l!==void 0&&h!==void 0){const f=c.y??c.weight??1;s[l][h]+=f,s[h][l]+=f}}const a=r.map(c=>e.get(c));return{matrix:s,names:r,nodeColors:a}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function Xp(){Tt.registerType("sankey",pA),Tt.registerType("networkgraph",XA),Tt.registerType("dependencywheel",KA)}class jr{static group(t,e,i="average",r,o){if(!t.length||e<=0)return t;const s=[...t].sort((f,u)=>(f.x??0)-(u.x??0)),a=!(r!=null&&r.groupAll)&&o?s.filter(f=>{const u=f.x??0;return u>=o.min&&u<=o.max}):s,c=new Map;for(const f of a){const u=f.x??0,d=Math.floor(u/e)*e;c.has(d)||c.set(d,[]),c.get(d).push(f)}const l=(r==null?void 0:r.anchor)??"start",h=[];for(const[f,u]of c){const d=jr.applyAnchor(f,e,l),p=jr.approximate(d,u,i);h.push(p)}return r!=null&&r.smoothed&&h.length>=3?jr.smooth(h):h}static applyAnchor(t,e,i){switch(i){case"middle":return t+e/2;case"end":return t+e;default:return t}}static smooth(t){const e=[t[0]];for(let i=1;i<t.length-1;i++){const r=t[i-1].y??0,o=t[i].y??0,s=t[i+1].y??0;e.push({...t[i],y:(r+o+s)/3})}return e.push(t[t.length-1]),e}static approximate(t,e,i){const r=e.map(o=>o.y??0);switch(i){case"sum":return{x:t,y:r.reduce((o,s)=>o+s,0)};case"open":return{x:t,y:r[0]};case"high":return{x:t,y:Math.max(...r)};case"low":return{x:t,y:Math.min(...r)};case"close":return{x:t,y:r[r.length-1]};case"range":return{x:t,y:Math.max(...r)-Math.min(...r)};case"ohlc":return{x:t,y:r[r.length-1],open:r[0],high:Math.max(...r),low:Math.min(...r),close:r[r.length-1]};case"average":default:return{x:t,y:r.reduce((o,s)=>o+s,0)/r.length}}}}class JA{constructor(t){this.head=0,this._size=0,this.capacity=t,this.buffer=new Array(t)}push(t){const e=this._size===this.capacity?this.buffer[this.head]:void 0,i=(this.head+this._size)%this.capacity;return this.buffer[i]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity,e}pushMany(t){const e=[];for(const i of t){const r=this.push(i);r!==void 0&&e.push(r)}return e}get size(){return this._size}get isFull(){return this._size===this.capacity}get(t){if(!(t<0||t>=this._size))return this.buffer[(this.head+t)%this.capacity]}toArray(){const t=new Array(this._size);for(let e=0;e<this._size;e++)t[e]=this.buffer[(this.head+e)%this.capacity];return t}clear(){this.head=0,this._size=0}}class Up{constructor(){this.entries=[]}add(t,e){if(t==="setData"){this.entries=[{type:t,payload:e}];return}this.entries.push({type:t,payload:e})}get isEmpty(){return this.entries.length===0}}class QA{constructor(t,e){this.pendingUpdates=new Map,this.rafId=null,this.lastFrameTime=0,this.maxFps=t.maxFps??30,this.flushCallback=e}schedule(t,e,i){let r=this.pendingUpdates.get(t);r||(r=new Up,this.pendingUpdates.set(t,r)),r.add(e,i),this.requestFrame()}requestFrame(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const t=performance.now(),e=1e3/this.maxFps;if(t-this.lastFrameTime<e){this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.lastFrameTime=performance.now(),this.flush()});return}this.lastFrameTime=t,this.flush()}))}flush(){if(this.pendingUpdates.size!==0){for(const[t,e]of this.pendingUpdates)e.isEmpty||t.applyBatch(e);this.pendingUpdates.clear(),this.flushCallback()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingUpdates.clear()}get hasPending(){return this.pendingUpdates.size>0}}class t5{static fromWebSocket(t,e,i,r){const o=(r==null?void 0:r.shift)??!1,s=a=>{let c;try{c=JSON.parse(a.data)}catch{return}const l=i(c);if(Array.isArray(l))if(e.addPoints)e.addPoints(l,!0,o);else{for(const h of l)e.addPoint(h,!1,o);e.addPoint(l[l.length-1],!0,o)}else e.addPoint(l,!0,o)};return t.addEventListener("message",s),{unsubscribe:()=>t.removeEventListener("message",s)}}static fromEventSource(t,e,i,r,o){const s=(o==null?void 0:o.shift)??!1,a=c=>{const l=r(c.data);e.addPoint(l,!0,s)};return t.addEventListener(i,a),{unsubscribe:()=>t.removeEventListener(i,a)}}static fromPolling(t,e,i,r){const o=(r==null?void 0:r.shift)??!1;let s=!0;const a=async()=>{if(s){try{const c=await t();if(!s)return;if(Array.isArray(c))if(e.addPoints)e.addPoints(c,!0,o);else for(const l of c)e.addPoint(l,!0,o);else e.addPoint(c,!0,o)}catch{}s&&setTimeout(a,i)}};return setTimeout(a,i),{unsubscribe:()=>{s=!1}}}}cd(),Ep(),Tp(),Xp();const Al={chart(n,t){return new xs(n,t)},setOptions(n){wa(n)},getOptions(){return Rh()},dateFormat:sc,numberFormat:ts,templateFormat:Kt,stripHtmlTags:oe,color(n){return lo(n)},palettes:ho,getPalette(n){return Dl(n)},themes:uo,themeNames:gg,getTheme(n){return Ol(n)},setTheme(n){const t=uo[n];t&&wa(t)},use(n){Kh.register(n),n.init(Al)},setLicenseKey(n){return tn.setKey(n)},isLicensed(){return tn.isLicensed()},configureLicensing(n){tn.configure(n)},ChartRegistry:Tt},e5=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));_t.A11yModule=Af,_t.BaseSeries=Xt,_t.Chart=xs,_t.ChartRegistry=Tt,_t.CircularBuffer=JA,_t.Crosshair=uf,_t.DataGrouping=jr,_t.DataLabels=is,_t.Drilldown=bf,_t.EventBus=qh,_t.ExportButton=pf,_t.ExportModule=re,_t.KatuCharts=Al,_t.Legend=os,_t.LicenseManager=tn,_t.ModuleRegistry=Kh,_t.Navigator=jf,_t.OptionsParser=Kn,_t.RangeSelector=qf,_t.ResponsiveEngine=gf,_t.SVGRenderer=So,_t.StreamAdapter=t5,_t.Tooltip=rs,_t.UpdateBatch=Up,_t.UpdateScheduler=QA,_t.Zoom=Mf,_t.default=Al,_t.getGlobalOptions=Rh,_t.lttbDecimate=$c,_t.minMaxDecimate=U2,_t.registerCoreSeriesTypes=cd,_t.registerFinancialSeriesTypes=Tp,_t.registerFlowSeriesTypes=Xp,_t.registerGeneralSeriesTypes=Ep,_t.setGlobalOptions=wa,Object.defineProperties(_t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
9
+ `);else{const a=t.match(FM);i=a?[a[1],a[2]]:[t]}const r="http://www.w3.org/2000/svg",o=i.length,s=o>1?-((o-1)*_p)/2:0;i.forEach((a,c)=>{const l=document.createElementNS(r,"tspan");l.setAttribute("x",String(e)),l.setAttribute("dy",`${c===0?s:_p}em`),l.textContent=a,n.appendChild(l)})}const RM={Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"};class DM extends Ht{constructor(t){super(t),this.selectedIndices=new Set,t.showInLegend=!1,t.clip=!1}render(){var E;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.data,o=r.filter(_=>{var T;return((T=_.sets)==null?void 0:T.length)===1}),s=r.filter(_=>{var T;return((T=_.sets)==null?void 0:T.length)>=2});if(o.length===0)return;const a=t.width/2,c=t.height/2,l=t.height/2*.92,h=Math.max(...o.map(_=>_.value||_.y||1)),f=this.config.opacity??.25,u=Math.min(1,f+.25),d=.4,p=this.config.borderColor,y=this.config.borderWidth??0,g=this.resolveDashStyle(this.config.borderDashStyle),m=this.config.allowPointSelect===!0,b=new Map;this.layoutSets(o,s,b,a,c,l,h,e,t);const x=Array.from(b.values()),v=[];for(const _ of o){const T=b.get(_.sets[0]);if(!T)continue;let I=T.cx,L=T.cy;const P=x.filter(A=>A.id!==T.id);if(P.length>0){let A=0,w=0;for(const $ of P){const R=T.cx-$.cx,F=T.cy-$.cy,D=Math.sqrt(R*R+F*F)||1;A+=R/D,w+=F/D}const S=Math.sqrt(A*A+w*w)||1;I=T.cx+A/S*T.r*.7,L=T.cy+w/S*T.r*.7}v.push({sets:_.sets,value:_.value||_.y||0,name:_.name||_.sets[0],color:_.color||T.color,path:this.circlePath(T.cx,T.cy,T.r),labelX:I,labelY:L,data:_,order:1,key:_.sets.join("_")})}for(const _ of s){if(_.sets.length!==2)continue;const T=b.get(_.sets[0]),I=b.get(_.sets[1]);if(!T||!I)continue;const L=this.lensPath(T,I);if(!L)continue;const P=_.color||this.blendColors(T.color,I.color);v.push({sets:_.sets,value:_.value||_.y||0,name:_.name||`${_.sets.join(" ∩ ")} (${_.value||_.y||0})`,color:P,path:L.path,labelX:L.cx,labelY:L.cy,data:_,order:2,key:[..._.sets].sort().join("_")})}for(const _ of s){if(_.sets.length!==3)continue;const T=_.sets.map(P=>b.get(P)).filter(Boolean);if(T.length<3)continue;const I=this.triIntersectionPath(T[0],T[1],T[2]);if(!I)continue;const L=_.color||this.blendColors(T[0].color,T[1].color,T[2].color);v.push({sets:_.sets,value:_.value||_.y||0,name:_.name||`${_.sets.join(" ∩ ")} (${_.value||_.y||0})`,color:L,path:I.path,labelX:I.cx,labelY:I.cy,data:_,order:3,key:[..._.sets].sort().join("_")})}v.sort((_,T)=>_.order-T.order);const M=(((E=this.config.accessibility)==null?void 0:E.point)||{}).descriptionFormatter,C=this.group.selectAll(".katucharts-venn-area").data(v,_=>_.key).join(_=>{const T=_.append("g").attr("class",I=>`katucharts-venn-area katucharts-venn-${I.sets.length===1?"circle-area":"intersection-area"}`).attr("data-venn-sets",I=>I.sets.join("_"));return T.append("path"),T},_=>_,_=>_.remove());C.attr("class",_=>`katucharts-venn-area katucharts-venn-${_.sets.length===1?"circle-area":"intersection-area"}`),C.select("path").attr("d",_=>_.path).attr("fill",_=>_.color).attr("fill-opacity",_=>_.sets.length===1?f:0).attr("stroke",_=>_.sets.length===1?p||_.color:"none").attr("stroke-width",_=>_.sets.length===1?y:0).attr("stroke-dasharray",g).attr("role","img").attr("aria-label",_=>M?M({name:_.name,value:_.value,sets:_.sets}):`${_.name}: ${_.value}`).style("cursor",this.config.cursor||"pointer"),C.sort((_,T)=>_.order-T.order),C.each(function(_){if(_.sets.length>=2){const I=this.querySelector("path");if(I)try{const L=I.getBBox();L.width>0&&L.height>0&&(_.labelX=L.x+L.width/2,_.labelY=L.y+L.height/2)}catch{}}}),i&&C.select("path").attr("opacity",0).transition().duration(gt).ease(dt).delay((_,T)=>T*Bt).attr("opacity",1),this.config.enableMouseTracking!==!1&&this.attachEvents(C,v,f,u,d,m),this.renderLabels(v,i??!1)}resolveDashStyle(t){return t&&RM[t]||"none"}attachEvents(t,e,i,r,o,s){var c,l;(l=(c=this.config.dataLabels)==null?void 0:c.intersections)==null||l.enabled;const a=()=>this.group.selectAll(".katucharts-venn-inter-label");t.on("mouseover",(h,f)=>{var y,g,m;const u=e.indexOf(f),d=f.sets.length>=2;st(h.currentTarget).select("path").transition("hover").duration(Z).ease(q).attr("fill-opacity",d?o:r),d&&a().filter(b=>b.sets.length===f.sets.length&&b.sets.every(x=>f.sets.includes(x))).transition("label").duration(Z).ease(q).attr("opacity",1),this.context.events.emit("point:mouseover",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h,plotX:f.labelX,plotY:f.labelY}),(m=(g=(y=f.data)==null?void 0:y.events)==null?void 0:g.mouseOver)==null||m.call(f.data,h)}).on("mouseout",(h,f)=>{var y,g,m;const u=e.indexOf(f),d=f.sets.length>=2;st(h.currentTarget).select("path").transition("hover").duration(Z).ease(q).attr("fill-opacity",d?0:i),a().filter(function(){return this.__autoHidden===!0}).transition("label").duration(Z).ease(q).attr("opacity",0),this.context.events.emit("point:mouseout",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h}),(m=(g=(y=f.data)==null?void 0:y.events)==null?void 0:g.mouseOut)==null||m.call(f.data,h)}).on("click",(h,f)=>{var p,y,g,m,b,x,v,k,M,C,E,_,T;const u=e.indexOf(f);s&&(this.selectedIndices.has(u)?(this.selectedIndices.delete(u),(g=(y=(p=f.data)==null?void 0:p.events)==null?void 0:y.unselect)==null||g.call(f.data,h)):(this.selectedIndices.add(u),(x=(b=(m=f.data)==null?void 0:m.events)==null?void 0:b.select)==null||x.call(f.data,h))),this.context.events.emit("point:click",{point:{name:f.name,y:f.value,value:f.value,sets:f.sets},index:u,series:this,event:h}),(M=(k=(v=f.data)==null?void 0:v.events)==null?void 0:k.click)==null||M.call(f.data,h),(E=(C=this.config.events)==null?void 0:C.click)==null||E.call(this,h);const d=(T=(_=this.config.point)==null?void 0:_.events)==null?void 0:T.click;d&&d.call({...f.data,sets:f.sets,name:f.name,value:f.value},h)})}renderLabels(t,e){var u,d,p,y;const i=this.config.dataLabels||{},r=i.enabled!==!1,o=((u=i.intersections)==null?void 0:u.enabled)!==!1,s=((d=i.style)==null?void 0:d.fontSize)||kt,a=i.color||((p=i.style)==null?void 0:p.color)||Fe,c=((y=i.style)==null?void 0:y.fontWeight)||"bold",l=t.filter(g=>g.sets.length===1),h=t.filter(g=>g.sets.length>=2);if(r){const g=this.group.selectAll(".katucharts-venn-set-label").data(l,m=>m.key).join("text").attr("class","katucharts-venn-set-label").attr("x",m=>m.labelX).attr("y",m=>m.labelY).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",s).attr("font-weight",c).attr("fill",a).style("pointer-events","none").style("text-shadow","0 0 4px #fff, 0 0 4px #fff");g.each((m,b,x)=>{const v=i.formatter?i.formatter.call({point:{name:m.name,y:m.value,sets:m.sets},series:{name:this.config.name},x:m.name,y:m.value}):m.name;Cp(x[b],String(v??""),m.labelX)}),e&&g.attr("opacity",0).transition().duration(gt).ease(dt).attr("opacity",1)}const f=this.group.selectAll(".katucharts-venn-inter-label").data(h,g=>g.key).join("text").attr("class","katucharts-venn-inter-label").attr("x",g=>g.labelX).attr("y",g=>g.labelY).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",kt).attr("fill",Fe).style("pointer-events","none").style("text-shadow","0 0 3px #fff, 0 0 3px #fff").attr("opacity",o?1:0);if(f.each((g,m,b)=>{Cp(b[m],g.name,g.labelX)}),o){const g=this.group;f.each(function(m){const b=this,x=g.select(`[data-venn-sets="${m.sets.join("_")}"]`).node(),v=x==null?void 0:x.querySelector("path");if(v)try{const k=b.getBBox(),M=v.getBBox(),C=k.width<=M.width*.95&&k.height<=M.height*.95;b.setAttribute("opacity",C?"1":"0"),b.__autoHidden=!C}catch{}})}}layoutSets(t,e,i,r,o,s,a,c,l){var P,A;const h=t.length,f=t.map(w=>w.sets[0]),u=t.map(w=>s*Math.sqrt((w.value||w.y||1)/a)),d=new Map;for(const w of e){if(((P=w.sets)==null?void 0:P.length)!==2)continue;const[S,$]=w.sets,R=f.indexOf(S),F=f.indexOf($);if(R<0||F<0)continue;const D=w.value||w.y||0;if(D<=0)d.set(`${R}-${F}`,u[R]+u[F]+5);else{const z=Math.PI*s*s*(D/a);d.set(`${R}-${F}`,this.findDistance(u[R],u[F],z))}}const p=new Array(h),y=new Set,g=new Array(h).fill(0);for(const w of e){if(((A=w.sets)==null?void 0:A.length)!==2)continue;const S=w.value||w.y||0;for(const $ of w.sets){const R=f.indexOf($);R>=0&&(g[R]+=S)}}const m=Array.from({length:h},(w,S)=>S).sort((w,S)=>g[S]-g[w]);p[m[0]]=[0,0],y.add(m[0]);for(let w=1;w<h;w++){const S=m[w];let $=[0,0],R=1/0;const F=[];for(const D of y){const z=D<S?`${D}-${S}`:`${S}-${D}`,B=d.get(z)??(u[D]+u[S])*1.1,[N,K]=p[D];for(let V=0;V<12;V++){const G=2*Math.PI*V/12;F.push([N+B*Math.cos(G),K+B*Math.sin(G)])}}for(const[D,z]of F){let B=0;for(const N of y){const K=N<S?`${N}-${S}`:`${S}-${N}`,V=d.get(K)??(u[N]+u[S])*1.1,G=Math.sqrt((D-p[N][0])**2+(z-p[N][1])**2);B+=(G-V)**2}B<R&&(R=B,$=[D,z])}p[S]=$,y.add(S)}h>=3&&this.optimizePositions(p,u,d,h);let b=1/0,x=-1/0,v=1/0,k=-1/0;for(let w=0;w<h;w++)b=Math.min(b,p[w][0]-u[w]),x=Math.max(x,p[w][0]+u[w]),v=Math.min(v,p[w][1]-u[w]),k=Math.max(k,p[w][1]+u[w]);const M=x-b||1,C=k-v||1,E=l?l.width*.95:s*2,_=l?l.height*.95:s*2,T=Math.min(E/M,_/C),I=(b+x)/2,L=(v+k)/2;for(let w=0;w<h;w++){const S=r+(p[w][0]-I)*T,$=o+(p[w][1]-L)*T,R=u[w]*T;i.set(f[w],{id:f[w],cx:S,cy:$,r:R,color:t[w].color||Sp[w%Sp.length]})}}optimizePositions(t,e,i,r){const o=u=>{let d=0;for(let p=0;p<r;p++)for(let y=p+1;y<r;y++){const g=`${p}-${y}`,m=i.get(g)??(e[p]+e[y])*1.1,b=u[p*2]-u[y*2],x=u[p*2+1]-u[y*2+1],v=Math.sqrt(b*b+x*x);d+=(v-m)**2}return d},s=new Array(r*2);for(let u=0;u<r;u++)s[u*2]=t[u][0],s[u*2+1]=t[u][1];const a=r*2,c=[s.slice()];for(let u=0;u<a;u++){const d=s.slice();d[u]+=e[Math.floor(u/2)]*.3,c.push(d)}const l=c.map(u=>o(u));for(let u=0;u<200;u++){let d=0,p=0;for(let b=1;b<=a;b++)l[b]<l[d]&&(d=b),l[b]>l[p]&&(p=b);if(l[p]-l[d]<.01)break;const y=new Array(a).fill(0);for(let b=0;b<=a;b++)if(b!==p)for(let x=0;x<a;x++)y[x]+=c[b][x];for(let b=0;b<a;b++)y[b]/=a;const g=y.map((b,x)=>2*b-c[p][x]),m=o(g);if(m<l[d]){const b=y.map((v,k)=>3*v-2*c[p][k]),x=o(b);x<m?(c[p]=b,l[p]=x):(c[p]=g,l[p]=m)}else if(m<l[p])c[p]=g,l[p]=m;else{const b=y.map((v,k)=>.5*(v+c[p][k])),x=o(b);if(x<l[p])c[p]=b,l[p]=x;else for(let v=0;v<=a;v++)if(v!==d){for(let k=0;k<a;k++)c[v][k]=.5*(c[d][k]+c[v][k]);l[v]=o(c[v])}}}let h=0;for(let u=1;u<=a;u++)l[u]<l[h]&&(h=u);const f=c[h];for(let u=0;u<r;u++)t[u]=[f[u*2],f[u*2+1]]}circlePath(t,e,i){return`M${t-i},${e}A${i},${i},0,1,1,${t+i},${e}A${i},${i},0,1,1,${t-i},${e}Z`}lensPath(t,e){const i=e.cx-t.cx,r=e.cy-t.cy,o=Math.sqrt(i*i+r*r);if(o>=t.r+e.r)return null;if(o<=Math.abs(t.r-e.r)){const m=t.r<e.r?t:e;return{path:this.circlePath(m.cx,m.cy,m.r),cx:m.cx,cy:m.cy}}const s=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=Math.sqrt(t.r*t.r-s*s),c=t.cx+s*i/o,l=t.cy+s*r/o,h=c+a*r/o,f=l-a*i/o,u=c-a*r/o,d=l+a*i/o,p=s<0?1:0,y=o-s<0?1:0;return{path:`M${h},${f}A${t.r},${t.r},0,${p},1,${u},${d}A${e.r},${e.r},0,${y},1,${h},${f}Z`,cx:c,cy:l}}triIntersectionPath(t,e,i){const r=this.circleIntersectionPoints(t,e),o=this.circleIntersectionPoints(t,i),s=this.circleIntersectionPoints(e,i);if(!r||!o||!s)return null;const c=[...r,...o,...s].filter(u=>this.insideCircle(u,t)&&this.insideCircle(u,e)&&this.insideCircle(u,i));if(c.length<3)return null;const l=c.reduce((u,d)=>u+d[0],0)/c.length,h=c.reduce((u,d)=>u+d[1],0)/c.length;c.sort((u,d)=>Math.atan2(u[1]-h,u[0]-l)-Math.atan2(d[1]-h,d[0]-l));let f=`M${c[0][0]},${c[0][1]}`;for(let u=0;u<c.length;u++){const d=c[u],p=c[(u+1)%c.length],y=this.findArcCircle(d,p,[t,e,i]);y?f+=`A${y.r},${y.r},0,0,1,${p[0]},${p[1]}`:f+=`L${p[0]},${p[1]}`}return f+="Z",{path:f,cx:l,cy:h}}circleIntersectionPoints(t,e){const i=e.cx-t.cx,r=e.cy-t.cy,o=Math.sqrt(i*i+r*r);if(o>=t.r+e.r||o<=Math.abs(t.r-e.r))return null;const s=(t.r*t.r-e.r*e.r+o*o)/(2*o),a=Math.sqrt(Math.max(0,t.r*t.r-s*s)),c=t.cx+s*i/o,l=t.cy+s*r/o;return[[c+a*r/o,l-a*i/o],[c-a*r/o,l+a*i/o]]}insideCircle(t,e){const i=t[0]-e.cx,r=t[1]-e.cy;return i*i+r*r<=(e.r+.5)*(e.r+.5)}findArcCircle(t,e,i){const r=(t[0]+e[0])/2,o=(t[1]+e[1])/2;for(const s of i){const a=Math.sqrt((t[0]-s.cx)**2+(t[1]-s.cy)**2),c=Math.sqrt((e[0]-s.cx)**2+(e[1]-s.cy)**2),l=Math.sqrt((r-s.cx)**2+(o-s.cy)**2);if(Math.abs(a-s.r)<1&&Math.abs(c-s.r)<1&&l<=s.r+1)return s}return null}blendColors(...t){let e=0,i=0,r=0;for(const s of t){const a=je(le(s)||s);e+=a.r,i+=a.g,r+=a.b}const o=t.length||1;return je(Math.round(e/o*.85),Math.round(i/o*.85),Math.round(r/o*.85)).formatHex()}findDistance(t,e,i){if(i<=0)return t+e+10;const r=Math.PI*Math.min(t,e)**2;if(i>=r)return Math.abs(t-e);let o=Math.abs(t-e),s=t+e;for(let a=0;a<50;a++){const c=(o+s)/2;this.lensArea(t,e,c)>i?o=c:s=c}return(o+s)/2}lensArea(t,e,i){if(i>=t+e)return 0;if(i<=Math.abs(t-e))return Math.PI*Math.min(t,e)**2;const r=(t*t-e*e+i*i)/(2*i),o=t*t-r*r;return o<0?0:t*t*Math.acos(r/t)-r*Math.sqrt(o)+e*e*Math.acos((i-r)/e)-(i-r)*Math.sqrt(e*e-(i-r)*(i-r))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function zM(n,t=0){return n===void 0?t:typeof n=="number"?n:n.radius??t}const BM=["#7cb5ec","#434348","#90ed7d","#f7a35c","#8085e9","#f15c80","#e4d354","#2b908f","#f45b5b","#91e8e1","#7798bf","#aaeeee","#ff0066","#eeaaee","#55bf3b","#df5353","#7798bf","#aaeeee"];class OM extends Ht{constructor(t){super(t),this.keyframes=[],this.currentFrameIndex=0,this.colorMap=new Map,this.timer=null,this.playing=!1,this.controlsEl=null,this.playBtn=null,this.rangeInput=null,this.rangeLabel=null}processData(){var o;const t=this.config.data;if(!Array.isArray(t))return;this.keyframes=t.filter(s=>s&&s.date&&Array.isArray(s.values));const e=new Set;for(const s of this.keyframes)for(const a of s.values)e.add(a.name);const i=this.config.colors||((o=this.context)==null?void 0:o.colors)||BM;let r=0;for(const s of e)this.colorMap.has(s)||(this.colorMap.set(s,i[r%i.length]),r++)}render(){if(this.keyframes.length===0)return;const{plotArea:t}=this.context,e=this.config,i=40,r=30;this.axisGroup=this.group.append("g").attr("class","katucharts-race-axis").attr("transform",`translate(0,${r})`),this.barsGroup=this.group.append("g").attr("class","katucharts-race-bars").attr("transform",`translate(0,${r+5})`),this.tickerText=this.group.append("text").attr("class","katucharts-race-ticker").attr("x",t.width-10).attr("y",t.height-i-10).attr("text-anchor","end").attr("font-size",e.tickerFontSize||"48px").attr("font-weight","bold").attr("fill",e.tickerColor||"#ddd").style("pointer-events","none"),this.renderControls(),this.currentFrameIndex=0,this.renderFrame(0,!1),e.autoPlay!==!1&&this.play()}renderControls(){var e,i,r;const t=(i=(e=this.group.node())==null?void 0:e.closest("svg"))==null?void 0:i.parentElement;t&&(this.controlsEl=document.createElement("div"),this.controlsEl.style.cssText="position:absolute;bottom:8px;left:12px;right:12px;display:flex;align-items:center;gap:8px;z-index:10;",this.playBtn=document.createElement("button"),this.playBtn.innerHTML=this.pauseIcon(),this.playBtn.style.cssText="width:32px;height:32px;border:none;border-radius:50%;background:#2f7ed8;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;flex-shrink:0;box-shadow:0 1px 3px rgba(0,0,0,0.2);transition:background 0.15s;",this.playBtn.onmouseenter=()=>{this.playBtn&&(this.playBtn.style.background="#1a5fa8")},this.playBtn.onmouseleave=()=>{this.playBtn&&(this.playBtn.style.background="#2f7ed8")},this.playBtn.onclick=()=>{this.playing?this.pause():this.currentFrameIndex>=this.keyframes.length-1?this.restart():this.play()},this.rangeInput=document.createElement("input"),this.rangeInput.type="range",this.rangeInput.min="0",this.rangeInput.max=String(this.keyframes.length-1),this.rangeInput.value="0",this.rangeInput.style.cssText="flex:1;height:4px;cursor:pointer;accent-color:#2f7ed8;",this.rangeInput.oninput=()=>{const o=parseInt(this.rangeInput.value,10),s=this.playing;s&&this.pause(),this.goToFrame(o),s&&this.play()},this.rangeLabel=document.createElement("span"),this.rangeLabel.style.cssText='font-size:11px;color:#666;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;min-width:30px;text-align:right;flex-shrink:0;',this.rangeLabel.textContent=((r=this.keyframes[0])==null?void 0:r.date)||"",this.controlsEl.appendChild(this.playBtn),this.controlsEl.appendChild(this.rangeInput),this.controlsEl.appendChild(this.rangeLabel),t.appendChild(this.controlsEl))}updateControls(){this.rangeInput&&(this.rangeInput.value=String(this.currentFrameIndex)),this.rangeLabel&&this.keyframes[this.currentFrameIndex]&&(this.rangeLabel.textContent=this.keyframes[this.currentFrameIndex].date),this.playBtn&&(this.playBtn.innerHTML=this.playing?this.pauseIcon():this.playIcon())}playIcon(){return'<svg width="14" height="14" viewBox="0 0 14 14"><polygon points="3,1 12,7 3,13" fill="currentColor"/></svg>'}pauseIcon(){return'<svg width="14" height="14" viewBox="0 0 14 14"><rect x="2" y="1" width="3.5" height="12" rx="0.5" fill="currentColor"/><rect x="8.5" y="1" width="3.5" height="12" rx="0.5" fill="currentColor"/></svg>'}renderFrame(t,e){if(t<0||t>=this.keyframes.length)return;const{plotArea:i}=this.context,r=this.config,o=r.barsToShow??12,s=r.barPadding??.1,a=zM(r.borderRadius,3),c=r.frameDuration??500,l=e?r.transitionDuration??c:0,u=i.height-35-40-20,d=this.keyframes[t],y=[...d.values].sort((E,_)=>_.value-E.value).slice(0,o),g=y.length>0?y[0].value:1;this.valueScale=Me().domain([0,g*1.1]).range([0,i.width-80]),this.renderAxis(l);const m=u/o*(1-s),b=u/o,x=E=>E.name,v=this.barsGroup.selectAll(".katucharts-race-bar").data(y,x),k=v.enter().append("g").attr("class","katucharts-race-bar").attr("transform",(E,_)=>`translate(0,${e?u+m:_*b})`).style("opacity",e?0:1);k.append("rect").attr("height",m).attr("rx",a).attr("width",E=>e?0:Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),k.append("text").attr("class","katucharts-race-label").attr("x",6).attr("y",m/2).attr("dy","0.35em").attr("fill","#fff").attr("font-weight","bold").attr("font-size",kt).style("pointer-events","none").text(E=>E.name),k.append("text").attr("class","katucharts-race-value").attr("y",m/2).attr("dy","0.35em").attr("fill",Fe).attr("font-weight","bold").attr("font-size",kt).style("pointer-events","none").attr("data-value",E=>E.value).attr("x",E=>Math.max(0,this.valueScale(E.value))+5).text(E=>E.value.toLocaleString());const M=k.merge(v);l>0?(M.transition().duration(l).ease(Sr).attr("transform",(E,_)=>`translate(0,${_*b})`).style("opacity",1),M.select("rect").transition().duration(l).ease(Sr).attr("width",E=>Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),M.select(".katucharts-race-value").transition().duration(l).ease(Sr).attr("x",E=>Math.max(0,this.valueScale(E.value))+5).tween("text",function(E){const _=this,T=parseFloat(_.getAttribute("data-value")||"0"),I=E.value;return L=>{const P=Math.round(T+(I-T)*L);_.textContent=P.toLocaleString(),_.setAttribute("data-value",String(P))}})):(M.attr("transform",(E,_)=>`translate(0,${_*b})`).style("opacity",1),M.select("rect").attr("width",E=>Math.max(0,this.valueScale(E.value))).attr("fill",E=>this.colorMap.get(E.name)||"#999"),M.select(".katucharts-race-value").attr("x",E=>Math.max(0,this.valueScale(E.value))+5).attr("data-value",E=>E.value).text(E=>E.value.toLocaleString())),M.select(".katucharts-race-label").style("display",E=>this.valueScale(E.value)<50?"none":"");const C=v.exit();l>0?C.transition().duration(l).ease(Sr).attr("transform",`translate(0,${u+m})`).style("opacity",0).remove():C.remove(),this.tickerText.text(d.date),this.updateControls(),this.attachBarHoverEffects(M,m)}renderAxis(t){const e=Ja(this.valueScale).ticks(5).tickSize(-this.context.plotArea.height+110).tickFormat(i=>{const r=i;return r>=1e9?(r/1e9).toFixed(1)+"B":r>=1e6?(r/1e6).toFixed(1)+"M":r>=1e3?(r/1e3).toFixed(1)+"K":r.toString()});t>0?this.axisGroup.transition().duration(t).ease(Sr).call(e):this.axisGroup.call(e),this.axisGroup.select(".domain").remove(),this.axisGroup.selectAll(".tick line").attr("stroke","#e0e0e0").attr("stroke-dasharray","2,2"),this.axisGroup.selectAll(".tick text").attr("fill",Fe).attr("font-size",kt)}attachBarHoverEffects(t,e){const i=this;t.style("cursor","pointer").on("mouseover",function(r,o){const a=st(this).select("rect"),c=a.attr("fill");a.attr("data-orig-fill",c),a.attr("fill",i.brightenColor(c,.1)),a.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),t.filter(l=>l.name!==o.name).style("opacity","0.5"),i.context.events.emit("point:mouseover",{point:{name:o.name,y:o.value},index:0,series:i,event:r,plotX:i.valueScale(o.value),plotY:0})}).on("mouseout",function(r,o){const a=st(this).select("rect"),c=a.attr("data-orig-fill")||"";a.attr("fill",c),a.style("filter",""),t.style("opacity",""),i.context.events.emit("point:mouseout",{point:{name:o.name,y:o.value},index:0,series:i,event:r})})}play(){if(this.playing)return;this.playing=!0,this.updateControls();const t=this.config,e=t.frameDuration??500;this.timer=setInterval(()=>{if(this.currentFrameIndex++,this.currentFrameIndex>=this.keyframes.length)if(t.loop)this.currentFrameIndex=0;else{this.currentFrameIndex=this.keyframes.length-1,this.pause();return}this.renderFrame(this.currentFrameIndex,!0)},e)}pause(){this.playing=!1,this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.updateControls()}restart(){this.pause(),this.currentFrameIndex=0,this.renderFrame(0,!0),this.play()}goToFrame(t){t<0||t>=this.keyframes.length||(this.currentFrameIndex=t,this.renderFrame(t,!0))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}destroy(){this.pause(),this.controlsEl&&(this.controlsEl.remove(),this.controlsEl=null),super.destroy()}brightenColor(t,e){const i=t.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i);if(i){const r=Math.min(255,parseInt(i[1],16)+Math.round(255*e)),o=Math.min(255,parseInt(i[2],16)+Math.round(255*e)),s=Math.min(255,parseInt(i[3],16)+Math.round(255*e));return`rgb(${r},${o},${s})`}return t}}function NM(n){if(n===!1||n==="none"||n==="0")return null;if(n==null)return{width:3,color:"#ffffff"};const t=/^([\d.]+)px\s+(.+)$/.exec(n.trim());return t?{width:parseFloat(t[1]),color:/contrast/i.test(t[2])?"#ffffff":t[2].trim()}:{width:3,color:"#ffffff"}}function WM(n){return n!=null&&n!==""}function nr(n){return n===void 0?"":String(n)}function HM(n,t){if(!t.has(n))return t.add(n),n;let e=2,i=`${n}__${e}`;for(;t.has(i);)e+=1,i=`${n}__${e}`;return t.add(i),i}function VM(n){const t=n.filter(h=>WM(h.id));if(!t.length)return[];const e=new Set(t.map(h=>nr(h.id))),i=new Set;for(const h of t){const f=nr(h.parent);f&&!e.has(f)&&i.add(f)}const o=[...Array.from(i).map(h=>({id:h,parent:"",name:h})),...t],s=o.reduce((h,f)=>{const u=nr(f.id);return h.set(u,(h.get(u)||0)+1),h},new Map),a=new Set,c=new Map,l=new Map;return o.forEach((h,f)=>{const u=nr(h.id),d=nr(h.parent),y=(s.get(u)||0)>1?`${d||"root"}::${u}::${f}`:u,g=HM(y,a);c.set(h,g),l.has(u)||l.set(u,g)}),o.map(h=>{const f=nr(h.parent),u=f&&l.get(f)||"";return{...h,id:c.get(h),parent:u,name:h.name??String(h.id)}})}class GM extends Ht{constructor(t){super(t),t.clip=!1}render(){var $,R,F,D,z,B;const{plotArea:t,colors:e}=this.context,i=this.data||[];if(!i.length)return;const r=this.config.layout==="vertical"?"vertical":"horizontal",o=this.config.link||{},s=(($=this.config.marker)==null?void 0:$.radius)??6,a=(R=this.config.marker)==null?void 0:R.fillColor,c=(F=this.config.marker)==null?void 0:F.lineWidth,l=o.color||"#cccccc",h=o.lineWidth??1,f=this.config.layoutAlgorithm==="cluster",u=this.config.levels||[],d=this.config.dataLabels||{},p=d.enabled!==!1,y=((D=d.style)==null?void 0:D.fontSize)||kt,g=d.color||((z=d.style)==null?void 0:z.color)||Fe,m=d.x,b=d.y??0,x=NM((B=d.style)==null?void 0:B.textOutline),v=this.buildRoot(i);if(!v)return;const k=Math.max(1,v.height),M=r==="horizontal"?t.height:t.width,C=r==="horizontal"?t.width:t.height,E=p?Math.min(160,C*.5/k):C/k,_=f?Ww():mk();_.size([M,E*k]),_(v),this.assignColors(v,u,e);const T=N=>r==="horizontal"?N.y:N.x,I=N=>r==="horizontal"?N.x:N.y,L=r==="horizontal"?B2().x(N=>T(N)).y(N=>I(N)):O2().x(N=>T(N)).y(N=>I(N)),P=this.group.append("g").attr("class","katucharts-treegraph"),A=v.descendants(),w=v.links();P.append("g").attr("class","katucharts-treegraph-links").selectAll("path").data(w).join("path").attr("d",N=>L(N)).attr("fill","none").attr("stroke",l).attr("stroke-width",h);const S=P.append("g").attr("class","katucharts-treegraph-nodes").selectAll("g").data(A).join("g").attr("transform",N=>`translate(${T(N)},${I(N)})`);if(S.append("circle").attr("r",s).attr("fill",N=>a??N.__color).attr("stroke",N=>a?N.__color:this.autoBorderColor()).attr("stroke-width",c??1),p){const N=m??s+4,K=S.append("text").attr("x",r==="horizontal"?V=>V.children?-N:N:0).attr("y",b).attr("dy",r==="horizontal"?"0.32em":s+12).attr("text-anchor",r==="horizontal"?V=>V.children?"end":"start":"middle").attr("font-size",y).attr("fill",g).style("pointer-events","none").text(V=>{var G,H;return((G=V.data)==null?void 0:G.name)??((H=V.data)==null?void 0:H.id)??""});x&&K.attr("stroke",x.color).attr("stroke-width",x.width).attr("paint-order","stroke").style("stroke-linejoin","round")}this.context.animate&&P.attr("opacity",0).transition().duration(gt).ease(dt).attr("opacity",1)}assignColors(t,e,i){const r=new Map,o=i.length?i:["#2f7ed8"];t.each(s=>{var c,l,h;const a=e.find(f=>f.level===s.depth+1);if((c=s.data)!=null&&c.color)s.__color=s.data.color;else if(a!=null&&a.color)s.__color=a.color;else if(a!=null&&a.colorByPoint){const f=(r.get(s.depth)??-1)+1;r.set(s.depth,f),s.__color=o[f%o.length]}else if(a!=null&&a.colorVariation&&((l=s.parent)!=null&&l.__color)){const f=a.colorVariation,u=s.parent.children||[s],d=u.length>1?u.indexOf(s)/(u.length-1):0,p=(f.key==="brightness"?f.to??0:0)*d*10;s.__color=cr(s.parent.__color).brighten(p).toString()}else(h=s.parent)!=null&&h.__color?s.__color=s.parent.__color:s.__color=o[s.depth%o.length]})}buildRoot(t){if(t.some(o=>o.children&&o.children.length>0))return qi({name:"root",children:t},o=>o.children);const i=VM(t);if(!i.length)return null;if(!(i.filter(o=>!o.parent).length<=1)){const o="__katu_treegraph_root__",s=i.map(a=>({...a,parent:a.parent||o}));return s.push({id:o,parent:"",name:""}),Oc().id(a=>String(a.id)).parentId(a=>a.parent?String(a.parent):null)(s)}return Oc().id(o=>String(o.id)).parentId(o=>o.parent?String(o.parent):null)(i)}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}class YM extends Ht{constructor(t){super(t),t.clip=!1}render(){var v,k,M,C,E;const{plotArea:t,colors:e}=this.context,i=this.data||[];if(!i.length)return;const r=this.config.minFontSize??8,o=this.config.maxFontSize??50,s=this.config.rotation||{},a=Array.isArray(s.orientations)?s.orientations:s.from!==void 0&&s.to!==void 0?[s.from,s.to]:[0],c=((k=(v=this.config.dataLabels)==null?void 0:v.style)==null?void 0:k.fontFamily)||"sans-serif",l=((M=this.config.dataLabels)==null?void 0:M.color)||((E=(C=this.config.dataLabels)==null?void 0:C.style)==null?void 0:E.color)||Fe,h=[...i].filter(_=>_&&_.name&&typeof _.weight=="number"&&_.weight>0).sort((_,T)=>T.weight-_.weight);if(!h.length)return;const f=h[h.length-1].weight,u=h[0].weight,d=_=>{if(u===f)return(r+o)/2;const T=(_-f)/(u-f);return r+T*(o-r)},p=t.width/2,y=t.height/2,g=[],m=this.group.append("g").attr("class","katucharts-wordcloud"),{measure:b,dispose:x}=this.createMeasurer(m.node(),c);try{h.forEach((_,T)=>{const I=d(_.weight),L=a[T%a.length]??0,P=b(_.name,I),A=P.width,w=P.height,S=this.findSpiralSpot(p,y,A,w,L,g,t.width,t.height);S&&g.push({x:S.x,y:S.y,width:A,height:w,word:_,rotation:L,fontSize:I})})}finally{x()}g.forEach((_,T)=>{const I=_.word.color||e[T%Math.max(1,e.length)]||l;m.append("text").attr("x",_.x).attr("y",_.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("transform",_.rotation?`rotate(${_.rotation},${_.x},${_.y})`:null).attr("font-size",_.fontSize).attr("font-family",c).attr("fill",I).style("pointer-events","none").text(_.word.name)}),this.context.animate&&m.attr("opacity",0).transition().duration(gt).ease(dt).attr("opacity",1)}createMeasurer(t,e){const i=t.ownerSVGElement||t,o=document.createElementNS("http://www.w3.org/2000/svg","text");return o.setAttribute("visibility","hidden"),o.setAttribute("font-family",e),i.appendChild(o),{measure:(a,c)=>{o.setAttribute("font-size",String(c)),o.textContent=a;try{const l=o.getBBox();return{width:l.width,height:l.height||c}}catch{return{width:a.length*c*.55,height:c}}},dispose:()=>o.remove()}}findSpiralSpot(t,e,i,r,o,s,a,c){const l=o%180!==0,h=l?r:i,f=l?i:r,u=.2,d=4*Math.PI*6;for(let p=0;p<d;p+=u){const y=4*p,g=t+y*Math.cos(p),m=e+y*Math.sin(p);if(g-h/2<0||g+h/2>a||m-f/2<0||m+f/2>c)continue;if(!s.some(x=>{const v=x.rotation%180!==0?x.height:x.width,k=x.rotation%180!==0?x.width:x.height;return Math.abs(g-x.x)<(h+v)/2+2&&Math.abs(m-x.y)<(f+k)/2+2}))return{x:g,y:m}}return null}getDataExtents(){return{xMin:1/0,xMax:-1/0,yMin:1/0,yMax:-1/0}}}function Ys(n,t){return n==null?0:typeof n=="number"?n:typeof n=="string"&&n.trim().endsWith("%")?parseFloat(n)/100*t:parseFloat(n)||0}class Pp extends Ht{constructor(t){super(t),t.showInLegend=t.showInLegend??!0}getMultiLegendItems(){return this.isGrouped()?this.orderedGroups().map(t=>({label:t,color:this.groupColor(t),visible:this.data.some(e=>e.group===t&&e.visible!==!1)})):this.categories().map((t,e)=>({label:t.point.name||t.point.label||`Item ${e+1}`,color:t.color,visible:t.point.visible!==!1}))}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}toggleLegendItem(t){if(this.isGrouped()){const i=this.orderedGroups()[t];if(i==null)return null;const r=!this.data.some(o=>o.group===i&&o.visible!==!1);return this.data.forEach(o=>{o.group===i&&(o.visible=r)}),this.redraw(),r}const e=this.categories()[t];return e?(e.point.visible=e.point.visible===!1,this.redraw(),e.point.visible!==!1):null}isGrouped(){return this.data.some(t=>t.group!=null)}orderedGroups(){const t=[];for(const e of this.data){const i=e.group;i!=null&&!t.includes(i)&&t.push(i)}return t}groupColor(t){var r;const e=(r=this.data.find(o=>o.group===t&&o.color))==null?void 0:r.color;if(e)return e;const i=this.orderedGroups().indexOf(t);return this.config.colors?this.config.colors[i%this.config.colors.length]:this.context.colors[i%this.context.colors.length]}render(){const{plotArea:t}=this.context,e=this.config.ignoreHiddenPoint!==!1,i=this.categories().filter(a=>!e||a.point.visible!==!1),r=i.reduce((a,c)=>a+c.seats,0);if(r===0)return;const s=this.config.startAngle!==void 0&&this.config.endAngle!==void 0?this.layoutHemicycle(i,r,t):this.layoutGrid(i,r,t);this.renderSeats(i,s),this.renderItemLabels(i,s),this.context.animate&&this.emitAfterAnimate(gt+Math.min(r,60)*Bt)}categories(){const t=this.isGrouped(),e=[];let i=0;return this.data.forEach((r,o)=>{if(r.y===null||r.y===void 0||(r.y??0)<=0)return;const s=r.group,a=r.color||(t&&s!=null?this.groupColor(s):this.config.colors?this.config.colors[i%this.config.colors.length]:this.context.colors[i%this.context.colors.length]);e.push({point:r,dataIndex:o,color:a,seats:Math.round(r.y??0),group:s}),i++}),e}layoutHemicycle(t,e,i){var C;const r=this.config.center||["50%","50%"],o=Ys(r[0],i.width),s=Ys(r[1],i.height),a=(this.config.startAngle??0)*Math.PI/180,c=(this.config.endAngle??360)*Math.PI/180,l=c-a,h=this.config.itemPadding??.1,f=Math.min(i.width,i.height),u=this.config.size!==void 0?Ys(this.config.size,f)/2:this.fitRadius(o,s,i.width,i.height,a,c)*.96,d=Ys(this.config.innerSize??"40%",u*2)/2;let p=this.config.rows;(!p||p<1)&&(p=this.estimateRows(e,d,u,l));const y=(u-d)/p,g=[];for(let E=0;E<p;E++)g.push(d+y*(E+.5));const m=g.map(E=>E*Math.abs(l)),b=m.reduce((E,_)=>E+_,0)||1,x=UM(m.map(E=>E/b*e),e),v=(C=this.config.marker)==null?void 0:C.radius;let k=v??y/2*(1-h);if(v==null)for(let E=0;E<p;E++){const _=x[E];if(_<=0)continue;const T=2*g[E]*Math.sin(Math.abs(l)/(2*_));k=Math.min(k,T/2*(1-h))}k=Math.max(k,.5);const M=[];for(let E=0;E<p;E++){const _=x[E],T=g[E];for(let I=0;I<_;I++){const L=_===1?.5:(I+.5)/_,P=a+L*l;M.push({x:o+T*Math.sin(P),y:s-T*Math.cos(P),angle:P,ring:E,catIndex:-1})}}return M.sort((E,_)=>E.angle-_.angle||E.ring-_.ring),this.assignSeats(M,t,k,{x:o,y:s})}layoutGrid(t,e,i){var y;const o=Math.max(i.width-16,1),s=Math.max(i.height-8*2,1),a=this.config.itemPadding??.1;let c=this.config.rows;(!c||c<1)&&(c=Math.max(1,Math.round(Math.sqrt(e*s/o))));const l=Math.ceil(e/c),h=o/l,f=s/c,u=((y=this.config.marker)==null?void 0:y.radius)??Math.max(Math.min(h,f)/2*(1-a),.5),d=this.config.layout==="horizontal",p=[];for(let g=0;g<e;g++){const m=d?Math.floor(g/l):g%c,b=d?g%l:Math.floor(g/c);p.push({x:8+h*(b+.5),y:8+f*(m+.5),angle:0,ring:m,catIndex:-1})}return this.assignSeats(p,t,u,{x:i.width/2,y:i.height/2})}assignSeats(t,e,i,r){const o=e.map(()=>({sx:0,sy:0,n:0}));let s=0;for(let c=0;c<e.length;c++)for(let l=0;l<e[c].seats&&s<t.length;l++,s++)t[s].catIndex=c,o[c].sx+=t[s].x,o[c].sy+=t[s].y,o[c].n+=1;const a=o.map(c=>c.n>0?{x:c.sx/c.n,y:c.sy/c.n}:r);return{seats:t.filter(c=>c.catIndex>=0),radius:i,centroids:a}}fitRadius(t,e,i,r,o,s){let a=1/0,c=-1/0,l=1/0,h=-1/0;const f=180;for(let d=0;d<=f;d++){const p=o+(s-o)*(d/f),y=Math.sin(p),g=Math.cos(p);y<a&&(a=y),y>c&&(c=y),g<l&&(l=g),g>h&&(h=g)}const u=[];return c>1e-6&&u.push((i-t)/c),a<-1e-6&&u.push(t/-a),h>1e-6&&u.push(e/h),l<-1e-6&&u.push((r-e)/-l),u.length?Math.max(0,Math.min(...u)):Math.min(i,r)/2}estimateRows(t,e,i,r){const o=Math.abs(r)*(e+i);if(o<=0)return 1;const s=Math.round(Math.sqrt(t*2*(i-e)/o));return Math.max(1,s)}renderSeats(t,e){var c,l;const i=this,r=this.context.animate,o=this.config.borderColor||this.autoBorderColor(),s=this.config.borderWidth??1,a=this.group.selectAll(".katucharts-item-point").data(e.seats).join("circle").attr("class","katucharts-item-point").attr("cx",h=>h.x).attr("cy",h=>h.y).attr("fill",h=>t[h.catIndex].color).attr("stroke",o).attr("stroke-width",s).style("cursor",this.config.cursor||"default");if(r?a.attr("r",0).transition().duration(gt).delay((h,f)=>Ic+xe(f,0,Bt,e.seats.length)).ease(dt).attr("r",e.radius):a.attr("r",e.radius),this.config.enableMouseTracking!==!1){const h=e.radius+2,f=((l=(c=this.config.states)==null?void 0:c.inactive)==null?void 0:l.opacity)??.25,u=this.isGrouped(),d=(p,y)=>u?t[p.catIndex].group===t[y.catIndex].group:p.catIndex===y.catIndex;a.on("mouseover",function(p,y){var m,b,x,v,k;st(this).transition("hover").duration(Z).ease(q).attr("r",h),a.interrupt("fade"),a.filter(M=>!d(M,y)).transition("fade").duration(Z).ease(q).attr("opacity",f),a.filter(M=>d(M,y)).transition("fade").duration(Z).ease(q).attr("opacity",1);const g=t[y.catIndex];i.context.events.emit("point:mouseover",{point:g.point,index:g.dataIndex,series:i,event:p,plotX:y.x,plotY:y.y}),(b=(m=g.point.events)==null?void 0:m.mouseOver)==null||b.call(g.point,p),(k=(v=(x=i.config.point)==null?void 0:x.events)==null?void 0:v.mouseOver)==null||k.call(g.point,p)}).on("mouseout",function(p,y){var m,b;st(this).transition("hover").duration(Z).ease(q).attr("r",e.radius),a.interrupt("fade"),a.transition("fade").duration(Z).ease(q).attr("opacity",1);const g=t[y.catIndex];i.context.events.emit("point:mouseout",{point:g.point,index:g.dataIndex,series:i,event:p}),(b=(m=g.point.events)==null?void 0:m.mouseOut)==null||b.call(g.point,p)}).on("click",function(p,y){var m,b,x,v,k,M,C;const g=t[y.catIndex];i.context.events.emit("point:click",{point:g.point,index:g.dataIndex,series:i,event:p}),(b=(m=g.point.events)==null?void 0:m.click)==null||b.call(g.point,p),(k=(v=(x=i.config.point)==null?void 0:x.events)==null?void 0:v.click)==null||k.call(g.point,p),(C=(M=i.config.events)==null?void 0:M.click)==null||C.call(i,p)})}}renderItemLabels(t,e){var s;const i=this.config.dataLabels;if(!i||!i.enabled)return;const r=this.group.append("g").attr("class","katucharts-item-labels"),o=((s=i.style)==null?void 0:s.fontSize)||kt;t.forEach((a,c)=>{var y,g,m;const l=e.centroids[c];if(!l)return;const h=a.point;let f;i.formatter?f=i.formatter.call({point:h,series:{name:this.config.name},x:h.x,y:h.y}):i.format?f=re(Zt(i.format,{point:h,series:{name:this.config.name},x:h.x,y:h.y})):f=h.label||h.name||String(h.y);const u=i.color||((y=i.style)==null?void 0:y.color)||gn(a.color),d=r.append("text").attr("x",l.x+(i.x??0)).attr("y",l.y+(i.y??0)).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",o).attr("font-weight",((g=i.style)==null?void 0:g.fontWeight)||"bold").attr("fill",u).style("pointer-events","none").text(f),p=this.labelOutline((m=i.style)==null?void 0:m.textOutline,u);p&&d.attr("stroke",p.color).attr("stroke-width",p.width).attr("paint-order","stroke").style("stroke-linejoin","round")})}labelOutline(t,e){if(t===!1||t==="none"||t==="0")return null;const i=gn(e);if(t==null)return{width:3,color:i};const r=/^([\d.]+)px\s+(.+)$/.exec(t.trim());return r?{width:parseFloat(r[1]),color:/contrast/i.test(r[2])?i:r[2].trim()}:{width:3,color:i}}}class XM extends Pp{constructor(t){t.startAngle===void 0&&(t.startAngle=-100),t.endAngle===void 0&&(t.endAngle=100),t.center===void 0&&(t.center=["50%","82%"]),t.innerSize===void 0&&(t.innerSize="40%"),super(t)}}function UM(n,t){const e=n.map(s=>Math.floor(s));let i=e.reduce((s,a)=>s+a,0);const r=n.map((s,a)=>({i:a,frac:s-Math.floor(s)})).sort((s,a)=>a.frac-s.frac);let o=0;for(;i<t&&r.length>0;)e[r[o%r.length].i]+=1,i+=1,o+=1;return e}class jM extends Dc{render(){var T,I;this.group.selectAll("*").remove();const t=this.getPaths();if(!t.length){super.render();return}const{xAxis:e,yAxis:i}=this.context,r=this.data,o=this.getColor(),s=this.context.animate,a=this.config.stacking,c=a==="percent",l=this.context.stackOffsetsPos,h=this.context.stackOffsetsNeg,f=L=>((L.y??0)<0?h==null?void 0:h.get(L.x??0):l==null?void 0:l.get(L.x??0))||0,u=this.context.stackTotals,d=c?u:void 0;if(a)for(const L of r){const P=L.x??0;if(u&&(L.total=u.get(P)||0,L.stackTotal=u.get(P)||0),c&&u){const A=u.get(P)||1;L.percentage=(L.y??0)/A*100}}const p=L=>{const P=L.x??0,A=f(L),w=L.y??0;if(c&&d){const S=d.get(P)||1;return(A+w)/S*100}return A+w},y=L=>{const P=L.x??0,A=f(L);if(c&&d){const w=d.get(P)||1;return A/w*100}return A},{barWidth:g,barOffset:m}=this.computeBarGeometry(),b=this.getAxisTopValue(c),x=i.getPixelForValue(0),v=Math.abs(i.getPixelForValue(b)-x),k=this.group.append("defs"),M=!!((I=(T=i.config)==null?void 0:T.stackShadow)!=null&&I.enabled),C=(this.context.indexInType??0)===0,E=this.group.selectAll(".katucharts-pictorial-segment").data(r).join("rect").attr("class","katucharts-pictorial-segment katucharts-column").attr("fill",(L,P)=>this.getPointColor(L,P,o)).attr("stroke",L=>L.borderColor||this.config.borderColor||"none").attr("stroke-width",L=>L.borderWidth??this.config.borderWidth??0).attr("display",L=>L.y==null?"none":null),_=this.getEntryDuration();E.each((L,P,A)=>{var K;const w=st(A[P]);if(L.y==null)return;const S=e.getPixelForValue(L.x??P)+m,$=(K=t[P%t.length])==null?void 0:K.definition;if(!$){w.attr("display","none");return}const R=this.computeSilhouette($,S,g,x,v,b),F=`katucharts-pictorial-${this.config.index}-${P}`;k.append("clipPath").attr("id",F).attr("clipPathUnits","userSpaceOnUse").append("path").attr("d",$).attr("transform",R.transform),M&&C&&this.group.insert("path",":first-child").attr("class","katucharts-pictorial-shadow").attr("d",$).attr("transform",R.transform).attr("fill",this.shadowFill()).attr("pointer-events","none");const D=R.pixelFor(p(L)),z=R.pixelFor(y(L)),B=Math.min(D,z),N=Math.abs(D-z);L._labelX=R.left+R.width/2,L._labelY=(D+z)/2,w.attr("x",R.left).attr("width",R.width).attr("clip-path",`url(#${F})`),s?w.attr("y",x).attr("height",0).transition().duration(_).attr("y",B).attr("height",N):w.attr("y",B).attr("height",N)}),this.attachHoverEffects(E,r),this.renderPictorialLabels(r)}renderPictorialLabels(t){var e;(e=this.config.dataLabels)!=null&&e.enabled&&this.renderDataLabels(t,i=>i._labelX??0,i=>i._labelY??0)}animateUpdate(){this.render()}getPaths(){const t=this.config.paths;return Array.isArray(t)?t.filter(e=>e&&typeof e.definition=="string"):[]}getAxisTopValue(t){var r,o;const e=(o=(r=this.context.yAxis.scale)==null?void 0:r.domain)==null?void 0:o.call(r),i=Array.isArray(e)&&e.length?Number(e[e.length-1]):NaN;return Number.isFinite(i)&&i!==0?i:t?100:1}computeSilhouette(t,e,i,r,o,s){var y;const a=this.group.append("path").attr("d",t).attr("visibility","hidden"),c=a.node(),l=(y=c==null?void 0:c.getBBox)==null?void 0:y.call(c);a.remove();const h=r-o,f=g=>r-g/s*o;if(!l||l.width===0||l.height===0)return{transform:`translate(${e},${h})`,pixelFor:f,left:e,width:i};const u=o/l.height,d=l.width*u,p=e+(i-d)/2;return{transform:`translate(${p},${h}) scale(${u}) translate(${-l.x},${-l.y})`,pixelFor:f,left:p,width:d}}shadowFill(){return this.autoBorderColor()==="#ffffff"?"rgba(0,0,0,0.06)":"rgba(255,255,255,0.10)"}}class Ep extends Ht{constructor(t){super(t)}getCurve(){return Si}render(){const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.color,a=this.context.colors[this.context.colorIndex%this.context.colors.length],c=this.gradientBaseColor(s)??(ji(s)?a:s||a),l=this.config.fillColor??s,h=Hn(l,this.group,c),f=this.config.fillOpacity??(ji(l)?1:.3),u=this.config.lineColor||c,d=this.config.lineWidth??1,p=o.filter(v=>{const k=v.low,M=v.high??v.y;return k!=null&&M!==void 0&&M!==null});if(p.length===0)return;const y=(v,k)=>t.getPixelForValue(v.x??k),g=v=>e.getPixelForValue(v.low),m=v=>e.getPixelForValue(v.high??v.y),b=ti().x((v,k)=>y(v,k)).y0(v=>g(v)).y1(v=>m(v)).curve(this.getCurve()),x=this.group.append("path").datum(p).attr("class","katucharts-arearange-fill").attr("d",b).attr("fill",h).attr("fill-opacity",f).attr("stroke","none");if(d>0){const v=on().x((M,C)=>y(M,C)).y(M=>m(M)).curve(this.getCurve()),k=on().x((M,C)=>y(M,C)).y(M=>g(M)).curve(this.getCurve());this.group.append("path").datum(p).attr("class","katucharts-arearange-line-top").attr("d",v).attr("fill","none").attr("stroke",u).attr("stroke-width",d),this.group.append("path").datum(p).attr("class","katucharts-arearange-line-bottom").attr("d",k).attr("fill","none").attr("stroke",u).attr("stroke-width",d)}if(r){const v=i.height/2,k=ti().x((M,C)=>y(M,C)).y0(()=>v).y1(()=>v).curve(this.getCurve());if(x.attr("d",k).transition().duration(gt).ease(dt).attr("d",b),d>0){const C=on().x((T,I)=>y(T,I)).y(()=>v).curve(this.getCurve())(p)||"",E=on().x((T,I)=>y(T,I)).y(T=>m(T)).curve(this.getCurve())(p)||"",_=on().x((T,I)=>y(T,I)).y(T=>g(T)).curve(this.getCurve())(p)||"";this.group.select(".katucharts-arearange-line-top").attr("d",C).transition().duration(gt).ease(dt).attr("d",E),this.group.select(".katucharts-arearange-line-bottom").attr("d",C).transition().duration(gt).ease(dt).attr("d",_)}this.emitAfterAnimate(gt)}this.setupHoverMarkers(p,y,g,m,c)}gradientBaseColor(t){var i;if(!ji(t))return null;const e=t.stops;if(!Array.isArray(e)||e.length===0)return null;for(const[,r]of e)if(typeof r=="string"&&!/rgba?\([^)]*,\s*0?\.\d+\s*\)/.test(r))return r;return((i=e[Math.floor(e.length/2)])==null?void 0:i[1])??null}setupHoverMarkers(t,e,i,r,o){var y;const s=this.context.events;if(this.hoverHandlers&&(s.off("point:mouseover",this.hoverHandlers.over),s.off("point:mouseout",this.hoverHandlers.out),s.off("series:mouseleave",this.hoverHandlers.out)),this.config.enableMouseTracking===!1)return;const a=this.group.append("g").attr("class","katucharts-arearange-hover").style("pointer-events","none"),c=((y=this.config.marker)==null?void 0:y.radius)??4,l=()=>a.append("circle").attr("r",c).attr("fill",o).attr("stroke","#ffffff").attr("stroke-width",1).attr("opacity",0),h=l(),f=l(),u=new Map;t.forEach((g,m)=>u.set(g.x??m,{x:e(g,m),hi:r(g),lo:i(g)}));const d=g=>{var b;const m=u.get((b=g==null?void 0:g.point)==null?void 0:b.x);if(!m){h.attr("opacity",0),f.attr("opacity",0);return}h.attr("cx",m.x).attr("cy",m.hi).attr("opacity",1),f.attr("cx",m.x).attr("cy",m.lo).attr("opacity",1)},p=()=>{h.attr("opacity",0),f.attr("opacity",0)};s.on("point:mouseover",d),s.on("point:mouseout",p),s.on("series:mouseleave",p),this.hoverHandlers={over:d,out:p}}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;s<t&&(t=s),s>e&&(e=s);const a=o.low,c=o.high??o.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),c!=null&&(c<i&&(i=c),c>r&&(r=c))}return{xMin:t,xMax:e,yMin:i,yMax:r}}}class qM extends Ep{getCurve(){return $c.alpha(.5)}}class ZM extends Ht{constructor(t){super(t)}render(){var g,m;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.config.groupPadding??.2,a=this.config.pointPadding??.1,c=s+a,l=this.config.maxPointWidth??1/0,h=Math.max(1,Math.min(l,i.width/Math.max(1,o.length)*(1-c))),f=this.config.pointWidth??h,u=this.getColor(),d=this.config.borderRadius??0,p=((m=(g=this.config.states)==null?void 0:g.inactive)==null?void 0:m.opacity)??.4,y=[];for(let b=0;b<o.length;b++){const x=o[b],v=x.low,k=x.high??x.y;if(v==null||k===void 0||k===null)continue;const M=t.getPixelForValue(x.x??b),C=e.getPixelForValue(k),E=e.getPixelForValue(v),_=Math.min(C,E),T=Math.max(1,Math.abs(E-C)),I=x.color||u,L=this.group.append("rect").attr("class","katucharts-columnrange-bar").attr("x",M-f/2).attr("width",f).attr("fill",I).attr("rx",d).style("cursor",this.config.cursor||"pointer");if(r){const P=_+T/2;L.attr("y",P).attr("height",0).transition().duration(gt).ease(dt).delay(xe(b,0,Bt,o.length)).attr("y",_).attr("height",T)}else L.attr("y",_).attr("height",T);y.push(L),this.config.enableMouseTracking!==!1&&L.on("mouseover",P=>{var A,w;L.transition("hover").duration(Z).ease(q).attr("opacity",.85),y.forEach((S,$)=>{$!==b&&S.interrupt("highlight"),$!==b&&S.transition("highlight").duration(Z).ease(q).attr("opacity",p)}),this.context.events.emit("point:mouseover",{point:x,index:b,series:this,event:P,plotX:M,plotY:C}),(w=(A=x.events)==null?void 0:A.mouseOver)==null||w.call(x,P)}).on("mouseout",P=>{var A,w;L.transition("hover").duration(Z).ease(q).attr("opacity",1),y.forEach(S=>{S.interrupt("highlight"),S.transition("highlight").duration(Z).ease(q).attr("opacity",1)}),this.context.events.emit("point:mouseout",{point:x,index:b,series:this,event:P}),(w=(A=x.events)==null?void 0:A.mouseOut)==null||w.call(x,P)}).on("click",P=>{var A,w,S,$;this.context.events.emit("point:click",{point:x,index:b,series:this,event:P}),(w=(A=x.events)==null?void 0:A.click)==null||w.call(x,P),($=(S=this.config.events)==null?void 0:S.click)==null||$.call(this,P)})}r&&this.emitAfterAnimate(gt+o.length*Bt)}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;s<t&&(t=s),s>e&&(e=s);const a=o.low,c=o.high??o.y;a!=null&&(a<i&&(i=a),a>r&&(r=a)),c!=null&&(c<i&&(i=c),c>r&&(r=c))}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function Tp(){St.registerType("waterfall",Iw),St.registerType("funnel",od),St.registerType("pyramid",lw),St.registerType("treemap",Mk),St.registerType("sunburst",Ak),St.registerType("gauge",Sk),St.registerType("solidgauge",_k),St.registerType("polar",xd),St.registerType("radar",xd),St.registerType("timeline",Tk),St.registerType("gantt",Lk),St.registerType("map",LM),St.registerType("mappoint",$M),St.registerType("flowmap",IM),St.registerType("venn",DM),St.registerType("barchartrace",OM),St.registerType("treegraph",GM),St.registerType("wordcloud",YM),St.registerType("item",Pp),St.registerType("classroom",XM),St.registerType("pictorial",jM),St.registerType("arearange",Ep),St.registerType("areasplinerange",qM),St.registerType("columnrange",ZM)}class KM extends Ht{constructor(t){super(t),this.selectedIndices=new Set}getCandleStyle(t){const e=t.isUp?t.upLineColor:t.downLineColor;return{fill:t.isUp?t.upColor:t.downColor,stroke:e,wick:e}}getCandleClass(){return"katucharts-candlestick"}render(){var E,_,T,I,L,P,A,w;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=this.applyDataGrouping(o),a=this.config.pointRange,c=this.config.groupPadding??.2,l=this.config.pointPadding??.1,h=c+l,f=this.config.maxPointWidth??1/0,u=a?Math.max(1,Math.min(f,i.width/Math.max(1,((E=t.domain)==null?void 0:E[1])-((_=t.domain)==null?void 0:_[0])||s.length)*a*(1-h))):Math.max(1,Math.min(f,i.width/s.length*(1-h))),d=this.config.pointWidth??u,p=this.config.color||"#f45b5b",y=this.config.upColor||"#2f7ed8",g=this.config.lineColor||p,m=this.config.upLineColor||y,b=this.config.lineWidth??1,x=((I=(T=this.config.states)==null?void 0:T.inactive)==null?void 0:I.opacity)??.4,v=this.config.allowPointSelect===!0,k=(P=(L=this.config.states)==null?void 0:L.select)==null?void 0:P.color,M=(w=(A=this.config.states)==null?void 0:A.select)==null?void 0:w.borderColor,C=[];for(let S=0;S<s.length;S++){const $=s[S];if($.y===null&&$.open===void 0)continue;const R=$.open??$.y??0,F=$.high??R,D=$.low??R,z=$.close??R,B=t.getPixelForValue($.x??S),N=z>=R,K=this.getCandleStyle({open:R,high:F,low:D,close:z,isUp:N,index:S,data:s,upColor:y,downColor:p,upLineColor:m,downLineColor:g}),V=K.fill,G=K.stroke,H=this.group.append("g").attr("class",this.getCandleClass()).style("cursor",this.config.cursor||"pointer");C.push(H);const j=H.append("line").attr("x1",B).attr("x2",B).attr("stroke",K.wick).attr("stroke-width",b),U=N?z:R,X=N?R:z,tt=e.getPixelForValue(U),O=Math.max(1,Math.abs(e.getPixelForValue(X)-e.getPixelForValue(U))),it=H.append("rect").attr("x",B-d/2).attr("width",d).attr("stroke",G).attr("stroke-width",b).attr("rx",2);if(r){const nt=e.getPixelForValue((F+D)/2),lt=xe(S,0,Bt,s.length);j.attr("y1",nt).attr("y2",nt).transition().duration(gt).ease(dt).delay(lt).attr("y1",e.getPixelForValue(F)).attr("y2",e.getPixelForValue(D)),it.attr("y",nt).attr("height",0).attr("fill",V).transition().duration(gt).ease(dt).delay(lt).attr("y",tt).attr("height",O)}else j.attr("y1",e.getPixelForValue(F)).attr("y2",e.getPixelForValue(D)),it.attr("y",tt).attr("height",O).attr("fill",V);this.config.enableMouseTracking!==!1&&H.on("mouseover",nt=>{var ht,at,W,J;const lt=((at=(ht=this.config.states)==null?void 0:ht.hover)==null?void 0:at.lineWidthPlus)??2;H.select("rect").transition("size").duration(Z).ease(q).attr("x",B-d*.7).attr("width",d*1.4),H.select("line").transition("size").duration(Z).ease(q).attr("stroke-width",b+lt),H.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),C.forEach(ut=>ut.interrupt("highlight")),C.forEach(ut=>ut.attr("opacity",1)),C.forEach((ut,vt)=>{vt!==S&&ut.transition("highlight").duration(Z).ease(q).attr("opacity",x)}),this.context.events.emit("point:mouseover",{point:{...$,open:R,high:F,low:D,close:z},index:S,series:this,event:nt,plotX:B,plotY:e.getPixelForValue((F+D)/2)}),(J=(W=$.events)==null?void 0:W.mouseOver)==null||J.call($,nt)}).on("mouseout",nt=>{var lt,ht;H.select("rect").transition("size").duration(Z).ease(q).attr("x",B-d/2).attr("width",d),H.select("line").transition("size").duration(Z).ease(q).attr("stroke-width",b),H.style("filter",""),C.forEach(at=>at.interrupt("highlight")),C.forEach(at=>at.transition("highlight").duration(Z).ease(q).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:$,index:S,series:this,event:nt}),(ht=(lt=$.events)==null?void 0:lt.mouseOut)==null||ht.call($,nt)}).on("click",nt=>{var lt,ht,at,W,J,ut,vt,Lt;v&&(this.selectedIndices.has(S)?(this.selectedIndices.delete(S),H.select("rect").attr("stroke-width",b),(ht=(lt=$.events)==null?void 0:lt.unselect)==null||ht.call($,nt)):(this.selectedIndices.add(S),H.select("rect").attr("stroke",M||"#000").attr("stroke-width",k?2:b+1),k&&H.select("rect").attr("fill",k),(W=(at=$.events)==null?void 0:at.select)==null||W.call($,nt))),this.context.events.emit("point:click",{point:$,index:S,series:this,event:nt}),(ut=(J=$.events)==null?void 0:J.click)==null||ut.call($,nt),(Lt=(vt=this.config.events)==null?void 0:vt.click)==null||Lt.call(this,nt)})}this.renderCandlestickLabels(s,t,e)}renderCandlestickLabels(t,e,i){var a,c;const r=this.config.dataLabels;if(!(r!=null&&r.enabled))return;const o=((a=r.style)==null?void 0:a.fontSize)||kt,s=r.color||((c=r.style)==null?void 0:c.color)||Fe;t.forEach((l,h)=>{if(l.y===null&&l.open===void 0)return;const f=l.high??l.open??l.y??0,u=e.getPixelForValue(l.x??h),d=i.getPixelForValue(f);let p;r.formatter?p=r.formatter.call({point:l,series:{name:this.config.name},x:l.x,y:l.y}):r.format?p=re(Zt(r.format,{point:l,series:{name:this.config.name},x:l.x,y:l.y})):p=String(l.close??l.y??""),this.group.append("text").attr("class","katucharts-candlestick-label").attr("x",u+(r.x??0)).attr("y",d-6+(r.y??0)).attr("text-anchor","middle").attr("font-size",o).attr("fill",s).style("pointer-events","none").text(p)})}applyDataGrouping(t){const e=this.config.dataGrouping;if(!(e!=null&&e.enabled)||!e.units||t.length===0)return t;const i=e.groupPixelWidth??10,{plotArea:r}=this.context,o=r.width/Math.max(1,t.length);if(o>=i)return t;const s=Math.ceil(i/o),a=[];for(let c=0;c<t.length;c+=s){const l=t.slice(c,c+s);if(l.length===0)continue;const h=l[0].open??l[0].y??0,f=l[l.length-1].close??l[l.length-1].y??0;let u=-1/0,d=1/0;for(const p of l)u=Math.max(u,p.high??p.y??0),d=Math.min(d,p.low??p.y??0);a.push({...l[0],x:l[0].x,open:h,high:u,low:d,close:f,y:f})}return a}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),e=Math.max(e,s);const a=o.high??o.y??0,c=o.low??o.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}class JM extends Ht{constructor(t){super(t)}render(){var f,u;const{xAxis:t,yAxis:e,plotArea:i}=this.context,r=this.context.animate,o=this.data,s=Math.max(2,Math.min(10,i.width/o.length*.3)),a=this.config.color||"#f45b5b",c=this.config.upColor||"#2f7ed8",l=((u=(f=this.config.states)==null?void 0:f.inactive)==null?void 0:u.opacity)??.4,h=[];for(let d=0;d<o.length;d++){const p=o[d];if(p.y===null&&p.open===void 0)continue;const y=p.open??p.y??0,g=p.high??y,m=p.low??y,b=p.close??y,x=t.getPixelForValue(p.x??d),v=b>=y?c:a,k=this.group.append("g").attr("class","katucharts-ohlc").style("cursor",this.config.cursor||"pointer");h.push(k),r&&k.attr("opacity",0).transition().duration(gt).ease(dt).delay(xe(d,0,Bt,o.length)).attr("opacity",1),k.append("line").attr("x1",x).attr("x2",x).attr("y1",e.getPixelForValue(g)).attr("y2",e.getPixelForValue(m)).attr("stroke",v).attr("stroke-width",1.5),k.append("line").attr("x1",x-s).attr("x2",x).attr("y1",e.getPixelForValue(y)).attr("y2",e.getPixelForValue(y)).attr("stroke",v).attr("stroke-width",1.5),k.append("line").attr("x1",x).attr("x2",x+s).attr("y1",e.getPixelForValue(b)).attr("y2",e.getPixelForValue(b)).attr("stroke",v).attr("stroke-width",1.5),this.config.enableMouseTracking!==!1&&k.on("mouseover",M=>{var C,E;k.selectAll("line").interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",3),k.style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.25))"),h.forEach(_=>_.interrupt("highlight")),h.forEach(_=>_.attr("opacity",1)),h.forEach((_,T)=>{T!==d&&_.transition("highlight").duration(Z).ease(q).attr("opacity",l)}),this.context.events.emit("point:mouseover",{point:{...p,open:y,high:g,low:m,close:b},index:d,series:this,event:M,plotX:x,plotY:e.getPixelForValue((g+m)/2)}),(E=(C=p.events)==null?void 0:C.mouseOver)==null||E.call(p,M)}).on("mouseout",M=>{var C,E;k.selectAll("line").interrupt("hover").transition("hover").duration(Z).ease(q).attr("stroke-width",1.5),k.style("filter",""),h.forEach(_=>_.interrupt("highlight")),h.forEach(_=>_.transition("highlight").duration(Z).ease(q).attr("opacity",1)),this.context.events.emit("point:mouseout",{point:p,index:d,series:this,event:M}),(E=(C=p.events)==null?void 0:C.mouseOut)==null||E.call(p,M)}).on("click",M=>{var C,E,_,T;this.context.events.emit("point:click",{point:p,index:d,series:this,event:M}),(E=(C=p.events)==null?void 0:C.click)==null||E.call(p,M),(T=(_=this.config.events)==null?void 0:_.click)==null||T.call(this,M)})}}getDataExtents(){let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of this.data){const s=o.x??0;t=Math.min(t,s),e=Math.max(e,s);const a=o.high??o.y??0,c=o.low??o.y??0;i=Math.min(i,c),r=Math.max(r,a)}return{xMin:t,xMax:e,yMin:i,yMax:r}}}function Lp(){St.registerType("candlestick",KM),St.registerType("ohlc",JM)}function $p(n,t){let e;if(t===void 0)for(const i of n)i!=null&&(e<i||e===void 0&&i>=i)&&(e=i);else{let i=-1;for(let r of n)(r=t(r,++i,n))!=null&&(e<r||e===void 0&&r>=r)&&(e=r)}return e}function QM(n,t){let e;if(t===void 0)for(const i of n)i!=null&&(e>i||e===void 0&&i>=i)&&(e=i);else{let i=-1;for(let r of n)(r=t(r,++i,n))!=null&&(e>r||e===void 0&&r>=r)&&(e=r)}return e}function bl(n,t){let e=0;if(t===void 0)for(let i of n)(i=+i)&&(e+=i);else{let i=-1;for(let r of n)(r=+t(r,++i,n))&&(e+=r)}return e}function tA(n){return n.depth}function Ip(n,t){return n.sourceLinks.length?n.depth:t-1}function Xs(n){return function(){return n}}function Fp(n,t){return Us(n.source,t.source)||n.index-t.index}function Rp(n,t){return Us(n.target,t.target)||n.index-t.index}function Us(n,t){return n.y0-t.y0}function vl(n){return n.value}function eA(n){return n.index}function nA(n){return n.nodes}function iA(n){return n.links}function Dp(n,t){const e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function zp({nodes:n}){for(const t of n){let e=t.y0,i=e;for(const r of t.sourceLinks)r.y0=e+r.width/2,e+=r.width;for(const r of t.targetLinks)r.y1=i+r.width/2,i+=r.width}}function rA(){let n=0,t=0,e=1,i=1,r=24,o=8,s,a=eA,c=Ip,l,h,f=nA,u=iA,d=6;function p(){const w={nodes:f.apply(null,arguments),links:u.apply(null,arguments)};return y(w),g(w),m(w),b(w),k(w),zp(w),w}p.update=function(w){return zp(w),w},p.nodeId=function(w){return arguments.length?(a=typeof w=="function"?w:Xs(w),p):a},p.nodeAlign=function(w){return arguments.length?(c=typeof w=="function"?w:Xs(w),p):c},p.nodeSort=function(w){return arguments.length?(l=w,p):l},p.nodeWidth=function(w){return arguments.length?(r=+w,p):r},p.nodePadding=function(w){return arguments.length?(o=s=+w,p):o},p.nodes=function(w){return arguments.length?(f=typeof w=="function"?w:Xs(w),p):f},p.links=function(w){return arguments.length?(u=typeof w=="function"?w:Xs(w),p):u},p.linkSort=function(w){return arguments.length?(h=w,p):h},p.size=function(w){return arguments.length?(n=t=0,e=+w[0],i=+w[1],p):[e-n,i-t]},p.extent=function(w){return arguments.length?(n=+w[0][0],e=+w[1][0],t=+w[0][1],i=+w[1][1],p):[[n,t],[e,i]]},p.iterations=function(w){return arguments.length?(d=+w,p):d};function y({nodes:w,links:S}){for(const[R,F]of w.entries())F.index=R,F.sourceLinks=[],F.targetLinks=[];const $=new Map(w.map((R,F)=>[a(R,F,w),R]));for(const[R,F]of S.entries()){F.index=R;let{source:D,target:z}=F;typeof D!="object"&&(D=F.source=Dp($,D)),typeof z!="object"&&(z=F.target=Dp($,z)),D.sourceLinks.push(F),z.targetLinks.push(F)}if(h!=null)for(const{sourceLinks:R,targetLinks:F}of w)R.sort(h),F.sort(h)}function g({nodes:w}){for(const S of w)S.value=S.fixedValue===void 0?Math.max(bl(S.sourceLinks,vl),bl(S.targetLinks,vl)):S.fixedValue}function m({nodes:w}){const S=w.length;let $=new Set(w),R=new Set,F=0;for(;$.size;){for(const D of $){D.depth=F;for(const{target:z}of D.sourceLinks)R.add(z)}if(++F>S)throw new Error("circular link");$=R,R=new Set}}function b({nodes:w}){const S=w.length;let $=new Set(w),R=new Set,F=0;for(;$.size;){for(const D of $){D.height=F;for(const{source:z}of D.targetLinks)R.add(z)}if(++F>S)throw new Error("circular link");$=R,R=new Set}}function x({nodes:w}){const S=$p(w,F=>F.depth)+1,$=(e-n-r)/(S-1),R=new Array(S);for(const F of w){const D=Math.max(0,Math.min(S-1,Math.floor(c.call(null,F,S))));F.layer=D,F.x0=n+D*$,F.x1=F.x0+r,R[D]?R[D].push(F):R[D]=[F]}if(l)for(const F of R)F.sort(l);return R}function v(w){const S=QM(w,$=>(i-t-($.length-1)*s)/bl($,vl));for(const $ of w){let R=t;for(const F of $){F.y0=R,F.y1=R+F.value*S,R=F.y1+s;for(const D of F.sourceLinks)D.width=D.value*S}R=(i-R+s)/($.length+1);for(let F=0;F<$.length;++F){const D=$[F];D.y0+=R*(F+1),D.y1+=R*(F+1)}L($)}}function k(w){const S=x(w);s=Math.min(o,(i-t)/($p(S,$=>$.length)-1)),v(S);for(let $=0;$<d;++$){const R=Math.pow(.99,$),F=Math.max(1-R,($+1)/d);C(S,R,F),M(S,R,F)}}function M(w,S,$){for(let R=1,F=w.length;R<F;++R){const D=w[R];for(const z of D){let B=0,N=0;for(const{source:V,value:G}of z.targetLinks){let H=G*(z.layer-V.layer);B+=P(V,z)*H,N+=H}if(!(N>0))continue;let K=(B/N-z.y0)*S;z.y0+=K,z.y1+=K,I(z)}l===void 0&&D.sort(Us),E(D,$)}}function C(w,S,$){for(let R=w.length,F=R-2;F>=0;--F){const D=w[F];for(const z of D){let B=0,N=0;for(const{target:V,value:G}of z.sourceLinks){let H=G*(V.layer-z.layer);B+=A(z,V)*H,N+=H}if(!(N>0))continue;let K=(B/N-z.y0)*S;z.y0+=K,z.y1+=K,I(z)}l===void 0&&D.sort(Us),E(D,$)}}function E(w,S){const $=w.length>>1,R=w[$];T(w,R.y0-s,$-1,S),_(w,R.y1+s,$+1,S),T(w,i,w.length-1,S),_(w,t,0,S)}function _(w,S,$,R){for(;$<w.length;++$){const F=w[$],D=(S-F.y0)*R;D>1e-6&&(F.y0+=D,F.y1+=D),S=F.y1+s}}function T(w,S,$,R){for(;$>=0;--$){const F=w[$],D=(F.y1-S)*R;D>1e-6&&(F.y0-=D,F.y1-=D),S=F.y0-s}}function I({sourceLinks:w,targetLinks:S}){if(h===void 0){for(const{source:{sourceLinks:$}}of S)$.sort(Rp);for(const{target:{targetLinks:$}}of w)$.sort(Fp)}}function L(w){if(h===void 0)for(const{sourceLinks:S,targetLinks:$}of w)S.sort(Rp),$.sort(Fp)}function P(w,S){let $=w.y0-(w.sourceLinks.length-1)*s/2;for(const{target:R,width:F}of w.sourceLinks){if(R===S)break;$+=F+s}for(const{source:R,width:F}of S.targetLinks){if(R===w)break;$-=F}return $}function A(w,S){let $=S.y0-(S.targetLinks.length-1)*s/2;for(const{source:R,width:F}of S.targetLinks){if(R===w)break;$+=F+s}for(const{target:R,width:F}of w.sourceLinks){if(R===S)break;$-=F}return $}return p}var wl=Math.PI,kl=2*wl,Ci=1e-6,oA=kl-Ci;function Ml(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function Bp(){return new Ml}Ml.prototype=Bp.prototype={constructor:Ml,moveTo:function(n,t){this._+="M"+(this._x0=this._x1=+n)+","+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(n,t){this._+="L"+(this._x1=+n)+","+(this._y1=+t)},quadraticCurveTo:function(n,t,e,i){this._+="Q"+ +n+","+ +t+","+(this._x1=+e)+","+(this._y1=+i)},bezierCurveTo:function(n,t,e,i,r,o){this._+="C"+ +n+","+ +t+","+ +e+","+ +i+","+(this._x1=+r)+","+(this._y1=+o)},arcTo:function(n,t,e,i,r){n=+n,t=+t,e=+e,i=+i,r=+r;var o=this._x1,s=this._y1,a=e-n,c=i-t,l=o-n,h=s-t,f=l*l+h*h;if(r<0)throw new Error("negative radius: "+r);if(this._x1===null)this._+="M"+(this._x1=n)+","+(this._y1=t);else if(f>Ci)if(!(Math.abs(h*a-c*l)>Ci)||!r)this._+="L"+(this._x1=n)+","+(this._y1=t);else{var u=e-o,d=i-s,p=a*a+c*c,y=u*u+d*d,g=Math.sqrt(p),m=Math.sqrt(f),b=r*Math.tan((wl-Math.acos((p+f-y)/(2*g*m)))/2),x=b/m,v=b/g;Math.abs(x-1)>Ci&&(this._+="L"+(n+x*l)+","+(t+x*h)),this._+="A"+r+","+r+",0,0,"+ +(h*u>l*d)+","+(this._x1=n+v*a)+","+(this._y1=t+v*c)}},arc:function(n,t,e,i,r,o){n=+n,t=+t,e=+e,o=!!o;var s=e*Math.cos(i),a=e*Math.sin(i),c=n+s,l=t+a,h=1^o,f=o?i-r:r-i;if(e<0)throw new Error("negative radius: "+e);this._x1===null?this._+="M"+c+","+l:(Math.abs(this._x1-c)>Ci||Math.abs(this._y1-l)>Ci)&&(this._+="L"+c+","+l),e&&(f<0&&(f=f%kl+kl),f>oA?this._+="A"+e+","+e+",0,1,"+h+","+(n-s)+","+(t-a)+"A"+e+","+e+",0,1,"+h+","+(this._x1=c)+","+(this._y1=l):f>Ci&&(this._+="A"+e+","+e+",0,"+ +(f>=wl)+","+h+","+(this._x1=n+e*Math.cos(r))+","+(this._y1=t+e*Math.sin(r))))},rect:function(n,t,e,i){this._+="M"+(this._x0=this._x1=+n)+","+(this._y0=this._y1=+t)+"h"+ +e+"v"+ +i+"h"+-e+"Z"},toString:function(){return this._}};function Op(n){return function(){return n}}function sA(n){return n[0]}function aA(n){return n[1]}var cA=Array.prototype.slice;function lA(n){return n.source}function hA(n){return n.target}function uA(n){var t=lA,e=hA,i=sA,r=aA,o=null;function s(){var a,c=cA.call(arguments),l=t.apply(this,c),h=e.apply(this,c);if(o||(o=a=Bp()),n(o,+i.apply(this,(c[0]=l,c)),+r.apply(this,c),+i.apply(this,(c[0]=h,c)),+r.apply(this,c)),a)return o=null,a+""||null}return s.source=function(a){return arguments.length?(t=a,s):t},s.target=function(a){return arguments.length?(e=a,s):e},s.x=function(a){return arguments.length?(i=typeof a=="function"?a:Op(+a),s):i},s.y=function(a){return arguments.length?(r=typeof a=="function"?a:Op(+a),s):r},s.context=function(a){return arguments.length?(o=a??null,s):o},s}function fA(n,t,e,i,r){n.moveTo(t,e),n.bezierCurveTo(t=(t+i)/2,e,t,r,i,r)}function dA(){return uA(fA)}function pA(n){return[n.source.x1,n.y0]}function gA(n){return[n.target.x0,n.y1]}function mA(){return dA().source(pA).target(gA)}const yA=500,xA=380,bA=280;function vA(n){if(n.endsWith("px"))return parseFloat(n)||12;if(n.endsWith("rem")||n.endsWith("em")){const e=typeof document>"u"?16:parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return(parseFloat(n)||1)*e}const t=parseFloat(n);return Number.isNaN(t)?12:t}class wA extends Ht{getBaseFlowDuration(){return gt*4}constructor(t){super(t)}render(){var Le,dn,vn,Un,eo;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,o=this.getBaseFlowDuration();this.group.selectAll("rect, path, text").interrupt("enter").interrupt("highlight");const{nodes:s,links:a}=this.buildGraph();if(s.length===0)return;const c=t.width<yA,l=t.width<xA,h=t.width<bA,f=r.nodeWidth,u=f==="auto",d=s.map(Y=>typeof Y.column=="number"&&Number.isFinite(Y.column)?Math.max(0,Math.floor(Y.column)):null).filter(Y=>Y!==null),p=d.length>0,y=p?Math.max(...d):0,g=typeof r.nodePadding=="number"?r.nodePadding:c?Math.max(4,Math.min(10,t.height/40)):10,m=r.linkOpacity??.4,b=r.colorByPoint!==!1,x=r.minLinkWidth??1,v=r.borderWidth??0,k=r.borderColor??"none",M=r.levels||[],C=this.config.dataLabels||{},E=C.enabled!==!1,_=((Le=C.style)==null?void 0:Le.fontSize)||kt,T=vA(_),I=l?Math.min(T,10):c?Math.min(T,12):T,L=`${I}px`,P=C.color||((dn=C.style)==null?void 0:dn.color)||this.autoLabelColor(),A=I*.62,w=Y=>C.formatter?String(C.formatter.call({point:{name:Y.name||Y.id,y:Y.value},series:{name:this.config.name},x:Y.name||Y.id,y:Y.value})??""):String(Y.name||Y.id||""),S=Y=>Y.length*A,$=(Y,et,ct=2)=>{if(et<=0)return"";if(S(Y)<=et)return Y;const Ft=Math.floor(et/A)-1;return Ft<ct?"":Ft>=Y.length?Y:Y.slice(0,Ft)+"…"},R=r.nodeAlignment==="left"?tA:Ip,D=h?5:l?8:c?10:14,z=typeof f=="number"?f:20,B=(Y,et,ct,Pt)=>{const Ft=Math.max(et+Pt+20,t.width-ct),We=rA().nodeId(ve=>ve.id).nodeAlign(R).nodeWidth(Pt).nodePadding(Y).extent([[et,0],[Ft,t.height]]),$e=We({nodes:[...s],links:[...a]});for(const ve of $e.nodes)if(ve.x0<et){const En=ve.x1-ve.x0;ve.x0=et,ve.x1=et+En}return{gen:We,graph:$e}};let N=z;const K=B(g,0,0,N),V=Y=>p&&typeof Y.column=="number"&&Number.isFinite(Y.column)?Math.max(0,Math.floor(Y.column)):Y.layer??Y.depth??0,G=p?y:K.graph.nodes.reduce((Y,et)=>Math.max(Y,et.depth??0),0),H=K.graph.nodes.reduce((Y,et)=>Math.min(Y,et.x0??1/0),1/0),j=p?K.graph.nodes.filter(Y=>V(Y)===0):K.graph.nodes.filter(Y=>(Y.x0??1/0)<=H+.5),U=E?Math.max(0,...j.map(Y=>S(w(Y)))):0,X=E&&c?Math.min(Math.floor(t.width*.08),Math.max(0,U*.18)):0,tt=E&&!h,O=0,it=Math.max(1,t.width-X-O),nt=Math.max(G,0);if(nt>0){const et=(it-nt*(h?8:l?10:c?14:18))/(nt+1),ct=Math.max(D,Math.min(z,et));(typeof f!="number"||c)&&(N=ct)}else typeof f!="number"&&(N=Math.max(D,Math.min(z,it*.5)));const lt=l?Math.max(2,Math.min(8,N*.35)):0,ht=X+lt,at=O+lt;let{gen:W,graph:J}=B(g,ht,at,N);const ut=new Map;for(const Y of J.nodes){const et=V(Y);ut.set(et,(ut.get(et)??0)+1)}const vt=Math.max(1,...ut.values());let Lt=g;const wt=typeof r.nodePadding!="number";if(E&&wt&&vt>1){const Y=I*1.3;t.height*.82/(vt-1)>=Y&&(Lt=Math.max(g,Y))}if(vt*Lt>t.height&&(Lt=Math.max(1,t.height/vt)),Lt!==g&&({gen:W,graph:J}=B(Lt,ht,at,N)),u){const Y=J.nodes.reduce((ct,Pt)=>Math.max(ct,V(Pt)),0),et=Math.max(D,Math.min(20,it/((Y+1)*3)));W.nodeWidth(et),J=W({nodes:[...s],links:[...a]})}if(p){const Y=Math.max(1,J.nodes[0]?J.nodes[0].x1-J.nodes[0].x0:N);Lt=this.applyExplicitColumnLayout(J,W,V,y,ht,Math.max(ht+Y,t.width-at),t.height,Lt,Y)}else this.reorderNodesByValueDesc(J,W,V,t.height,Lt);const $t=new Map,Vt=new Map;for(const Y of J.nodes){const et=V(Y);$t.has(et)||$t.set(et,[]),$t.get(et).push(Y)}for(const Y of J.links){const et=V(Y.source);Vt.has(et)||Vt.set(et,[]),Vt.get(et).push(Y)}const ee=J.nodes.reduce((Y,et)=>Math.max(Y,V(et)),0),Ct=Math.round(o*.22),Jt=Ct,ne=Jt,Ee=ee*ne+Ct+Jt,Gt=r.centerNodes===!0,Ut=r.spreadFactor??1;(Gt||Ut!==1)&&this.centerAndSpreadNodes(J,W,t.height,Ut,Lt);const Xe=new Map;for(const Y of M)Y.level!==void 0&&Xe.set(Y.level,Y);const ae=Y=>{const et=Y.source?V(Y.source):void 0,ct=et!==void 0?Xe.get(et):void 0;return(ct==null?void 0:ct.linkOpacity)??m},Pn=mA(),un=Y=>{if(!l)return Pn(Y);const et=Y.source.x1,ct=Y.target.x0,Pt=Y.y0,Ft=Y.y1,We=ct-et;if(!Number.isFinite(We)||!Number.isFinite(Pt)||!Number.isFinite(Ft))return Pn(Y);if(We<=14)return`M${et},${Pt}L${ct},${Ft}`;if(We<28){const $e=Math.max(2,We*.35);return`M${et},${Pt}C${et+$e},${Pt} ${ct-$e},${Ft} ${ct},${Ft}`}return Pn(Y)},Te=l,Kr=Te?Y=>{const et=Y.source.x1,ct=Y.target.x0,Pt=Y.y0,Ft=Y.y1,We=ct-et,$e=Math.max(x,Y.width)/2;if(!Number.isFinite(We)||!Number.isFinite(Pt)||!Number.isFinite(Ft))return un(Y);const ve=Pt-$e,En=Pt+$e,no=Ft-$e,ri=Ft+$e,jn=Math.max(1,We*.42);return We<=2?[`M${et},${ve}`,`L${ct},${no}`,`L${ct},${ri}`,`L${et},${En}`,"Z"].join(""):[`M${et},${ve}`,`C${et+jn},${ve} ${ct-jn},${no} ${ct},${no}`,`L${ct},${ri}`,`C${ct-jn},${ri} ${et+jn},${En} ${et},${En}`,"Z"].join("")}:un,Je=Te?"fill-opacity":"stroke-opacity",Qe=r.linkColorMode??"from",Jr=Y=>Y.source.color||e[J.nodes.indexOf(Y.source)%e.length]||"#aaa",Qr=Y=>Y.target.color||e[J.nodes.indexOf(Y.target)%e.length]||"#aaa",to=this.group.append("defs"),rt=`katucharts-sankey-clip-${this.config.index}-${Math.random().toString(36).slice(2,8)}`;to.append("clipPath").attr("id",rt).append("rect").attr("x",0).attr("y",0).attr("width",t.width).attr("height",t.height);const ot=this.group.append("g").attr("class","katucharts-sankey-clipped-layer").attr("clip-path",`url(#${rt})`),ft=ot.append("g").attr("class","katucharts-sankey-links"),Mt=ot.append("g").attr("class","katucharts-sankey-nodes"),xt=ot.append("g").attr("class","katucharts-sankey-link-hitareas");let yt=null;Qe==="gradient"&&(yt=to);let Q=null;const Et=.55,zt=.25,mt=ft.selectAll(".katucharts-sankey-link").data(J.links).join("path").attr("class","katucharts-sankey-link").attr("d",Kr).attr("fill",Te?"#aaa":"none").attr("stroke",Te?"none":"#aaa").attr("stroke-width",Y=>Te?null:Math.max(x,Y.width)).attr("stroke-linecap","butt").style("cursor","pointer");Qe==="gradient"&&yt?mt.each(function(Y,et){const ct=`katucharts-sankey-grad-${et}-${Math.random().toString(36).slice(2,6)}`;yt.append("linearGradient").attr("id",ct).attr("gradientUnits","userSpaceOnUse").attr("x1",Y.source.x1).attr("x2",Y.target.x0).selectAll("stop").data([{offset:"0%",color:Jr(Y)},{offset:"100%",color:Qr(Y)}]).join("stop").attr("offset",Pt=>Pt.offset).attr("stop-color",Pt=>Pt.color),st(this).attr(Te?"fill":"stroke",`url(#${ct})`)}):Qe==="to"?mt.attr(Te?"fill":"stroke",Y=>Qr(Y)):mt.attr(Te?"fill":"stroke",Y=>Jr(Y)),i&&!h?c?mt.attr(Je,0).each(function(Y){const et=V(Y.source),Pt=(Vt.get(et)||[]).indexOf(Y),Ft=et*ne+Ct-60+Math.min(Pt*12,60);st(this).transition("enter").duration(Jt).delay(Ft).ease(dt).attr(Je,ae(Y))}):mt.attr(Je,Y=>ae(Y)).each(function(Y){var En;const et=this,ct=((En=et.getTotalLength)==null?void 0:En.call(et))||0;if(ct===0)return;const Pt=V(Y.source),We=(Vt.get(Pt)||[]).indexOf(Y),ve=Pt*ne+Ct-60+Math.min(We*12,60);st(this).attr("stroke-dasharray",`${ct} ${ct}`).attr("stroke-dashoffset",ct).transition("enter").duration(Jt).delay(ve).ease(dt).attr("stroke-dashoffset",0).on("end",function(){st(this).attr("stroke-dasharray",null).attr("stroke-dashoffset",null)})}):mt.attr(Je,Y=>ae(Y));const jt=(Y,et,ct)=>{const Pt={name:`${ct.source.name} → ${ct.target.name}`,from:ct.source.name,to:ct.target.name,y:ct.value,weight:ct.value,fromNode:{name:ct.source.name,id:ct.source.id},toNode:{name:ct.target.name,id:ct.target.id}};if(Y==="mouseover"){this.context.events.emit("point:mouseover",{point:Pt,index:J.links.indexOf(ct),series:this,event:et,plotX:(ct.source.x1+ct.target.x0)/2,plotY:(ct.y0+ct.y1)/2});return}if(Y==="mouseout"){this.context.events.emit("point:mouseout",{point:Pt,index:J.links.indexOf(ct),series:this,event:et});return}this.context.events.emit("point:click",{point:Pt,index:J.links.indexOf(ct),series:this,event:et})},Nt=(Y,et)=>{const ct=ae(et);mt.interrupt("highlight"),Wt.interrupt("highlight"),Q==null||Q.interrupt("highlight"),mt.attr(Je,Pt=>Pt===et?Math.min(ct+.3,1):ae(Pt)),mt.filter(Pt=>Pt!==et).transition("highlight").duration(Z).ease(q).attr(Je,ct*.375),Wt.attr("opacity",1),Wt.transition("highlight").duration(Z).ease(q).attr("opacity",Pt=>Pt===et.source||Pt===et.target?1:Et),Q==null||Q.transition("highlight").duration(Z).ease(q).attr("opacity",Pt=>Pt===et.source||Pt===et.target?1:zt),jt("mouseover",Y,et)},qt=(Y,et)=>{mt.interrupt("highlight"),Wt.interrupt("highlight"),Q==null||Q.interrupt("highlight"),mt.transition("highlight").duration(Z).ease(q).attr(Je,ct=>ae(ct)),Wt.transition("highlight").duration(Z).ease(q).attr("opacity",1),Q==null||Q.transition("highlight").duration(Z).ease(q).attr("opacity",1),jt("mouseout",Y,et)},ie=(Y,et)=>{jt("click",Y,et)};mt.on("mouseover",Nt).on("mouseout",qt).on("click",ie);const Wt=Mt.selectAll(".katucharts-sankey-node").data(J.nodes).join("rect").attr("class","katucharts-sankey-node").attr("x",Y=>Y.x0).attr("y",Y=>Y.y0).attr("width",Y=>Y.x1-Y.x0).attr("height",Y=>Math.max(1,Y.y1-Y.y0)).attr("fill",(Y,et)=>{if(Y.color)return Y.color;const ct=Xe.get(V(Y));return ct!=null&&ct.color?ct.color:b?e[et%e.length]:r.color||e[0]}).attr("stroke",k).attr("stroke-width",v).attr("rx",4).style("cursor","pointer");i&&!h&&Wt.attr("opacity",0).attr("x",Y=>Y.x0-(l?4:10)).each(function(Y){const et=V(Y),Pt=($t.get(et)||[]).indexOf(Y),Ft=et*ne+Math.min(Pt*20,80);st(this).transition("enter").duration(Ct).delay(Ft).ease(dt).attr("opacity",1).attr("x",Y.x0)});const fn=(Y,et)=>{Wt.filter(Ft=>Ft===et).style("filter","drop-shadow(0 2px 4px rgba(0,0,0,0.3))"),Wt.interrupt("highlight"),mt.interrupt("highlight"),Q==null||Q.interrupt("highlight");const ct=new Set([et]);for(const Ft of J.links)Ft.source===et?ct.add(Ft.target):Ft.target===et&&ct.add(Ft.source);Wt.attr("opacity",1),Wt.filter(Ft=>!ct.has(Ft)).transition("highlight").duration(Z).ease(q).attr("opacity",Et),Q==null||Q.transition("highlight").duration(Z).ease(q).attr("opacity",Ft=>ct.has(Ft)?1:zt),mt.transition("highlight").duration(Z).ease(q).attr(Je,Ft=>Ft.source===et||Ft.target===et?Math.min(ae(Ft)+.3,1):ae(Ft)*.375);const Pt={name:et.name||et.id,y:et.value,sum:et.value};this.context.events.emit("point:mouseover",{point:Pt,index:J.nodes.indexOf(et),series:this,event:Y,plotX:(et.x0+et.x1)/2,plotY:(et.y0+et.y1)/2})},Ne=(Y,et)=>{Wt.filter(ct=>ct===et).style("filter",""),Wt.interrupt("highlight"),mt.interrupt("highlight"),Q==null||Q.interrupt("highlight"),Wt.transition("highlight").duration(Z).ease(q).attr("opacity",1),Q==null||Q.transition("highlight").duration(Z).ease(q).attr("opacity",1),mt.transition("highlight").duration(Z).ease(q).attr(Je,ct=>ae(ct)),this.context.events.emit("point:mouseout",{point:{name:et.name||et.id,y:et.value,sum:et.value},index:J.nodes.indexOf(et),series:this,event:Y})},Ue=(Y,et)=>{this.context.events.emit("point:click",{point:{name:et.name||et.id,y:et.value},index:J.nodes.indexOf(et),series:this,event:Y})};if(Wt.on("mouseover",fn).on("mouseout",Ne).on("click",Ue),xt.selectAll(".katucharts-sankey-link-hitarea").data(J.links).join("path").attr("class","katucharts-sankey-link-hitarea").attr("d",un).attr("fill","none").attr("stroke","transparent").attr("stroke-linecap","round").attr("stroke-width",Y=>Math.max(16,Math.max(x,Y.width)+10)).style("cursor","pointer").on("mouseover",Nt).on("mouseout",qt).on("click",ie),E){const Y=this.group.append("g").attr("class","katucharts-sankey-labels"),et=Math.max(6,I*.6),ct=J.nodes.reduce((pt,It)=>Math.max(pt,It.x0??0),0),Pt=J.nodes.reduce((pt,It)=>Math.min(pt,It.x0??1/0),1/0),Ft=pt=>p?V(pt)===ee:ct>0&&(pt.x0??0)>=ct-.5,We=pt=>p?V(pt)===0:Number.isFinite(Pt)&&(pt.x0??0)<=Pt+.5,$e=pt=>tt&&Ft(pt)||We(pt),ve=new Map;for(const pt of J.nodes){const It=pt.y1-pt.y0;if(!$e(pt)&&It<et){ve.set(pt,"");continue}ve.set(pt,w(pt))}const En=pt=>$e(pt)?Ft(pt)?"end":"start":"middle",no=pt=>$e(pt)?Ft(pt)?pt.x0-4+(C.x??0):pt.x1+4+(C.x??0):(pt.x0+pt.x1)/2+(C.x??0);Q=Y.selectAll(".katucharts-sankey-label").data(J.nodes).join("text").attr("class","katucharts-sankey-label").attr("x",no).attr("y",pt=>(pt.y0+pt.y1)/2+(C.y??0)).attr("dy","0.35em").attr("text-anchor",En).attr("font-size",L).attr("font-weight",((vn=C.style)==null?void 0:vn.fontWeight)??600).attr("fill",P).attr("paint-order","stroke").attr("stroke",(Un=C.style)!=null&&Un.textOutline?null:this.labelHaloColor()).attr("stroke-width",(eo=C.style)!=null&&eo.textOutline?null:2).attr("stroke-linejoin","round").style("pointer-events","auto").style("cursor","pointer").on("mouseover",fn).on("mouseout",Ne).on("click",Ue).text(pt=>ve.get(pt)??"");const ri=new Map,jn=new Map;for(const pt of J.nodes){const It=V(pt);ri.set(It,Math.min(ri.get(It)??1/0,pt.x0)),jn.set(It,Math.max(jn.get(It)??-1/0,pt.x1))}Q.each(function(pt){const It=this;let ce=It.textContent;if(!ce)return;const Tn=S(ce);if($e(pt)){const Jp=V(pt),Qp=I*.75;let ro;if(Ft(pt)){const oo=jn.get(Jp-1),tg=oo!==void 0?(oo+pt.x0)/2:2;ro=pt.x0-4-(tg+Qp/2)}else{const oo=ri.get(Jp+1);ro=(oo!==void 0?(pt.x1+oo)/2:t.width-2)-Qp/2-(pt.x1+4)}if(ro<=A){It.textContent="";return}Tn>ro&&(ce=$(ce,ro,1),It.textContent=ce);return}const Ei=(pt.x0+pt.x1)/2,oi=Ei-Tn/2,rr=Ei+Tn/2;if(rr<=t.width&&oi>=0)return;const io=V(pt),u5=ri.get(io+1)??t.width,f5=jn.get(io-1)??0,Cl=u5-pt.x1-4,Pl=pt.x0-f5-4;if(oi<0&&Cl>I*1.5){It.setAttribute("text-anchor","start"),It.setAttribute("x",String(pt.x1+2)),Tn>Cl&&(It.textContent=$(ce,Cl));return}if(rr>t.width&&Pl>I*1.5){It.setAttribute("text-anchor","end"),It.setAttribute("x",String(pt.x0-2)),Tn>Pl&&(It.textContent=$(ce,Pl));return}const Kp=2*Math.min(Ei,t.width-Ei)-4;if(Kp<I*2){It.textContent="";return}It.textContent=$(ce,Kp)});const qp=[],l5=[...J.nodes].sort((pt,It)=>(It.value??0)-(pt.value??0)),Zp=new Map;Q.each(function(pt){Zp.set(pt,this)});const h5=(pt,It)=>pt.left<It.right&&pt.right>It.left&&pt.top<It.bottom&&pt.bottom>It.top;for(const pt of l5){if(C.allowOverlap===!0)break;const It=Zp.get(pt);if(!It||!It.textContent)continue;let ce;try{ce=It.getBBox()}catch{const oi=S(It.textContent||""),rr=Number(It.getAttribute("x")||0),io=It.getAttribute("text-anchor");ce={x:io==="end"?rr-oi:io==="middle"?rr-oi/2:rr,y:Number(It.getAttribute("y")||0)-I/2,width:oi,height:I}}if(ce.width===0&&ce.height===0)continue;const Tn={left:ce.x,right:ce.x+ce.width,top:ce.y,bottom:ce.y+ce.height};if(qp.some(oi=>h5(oi,Tn))&&C.overflow!=="allow"){It.textContent="";continue}qp.push(Tn)}i&&!h&&Q.attr("opacity",0).each(function(pt){const It=V(pt),Tn=($t.get(It)||[]).indexOf(pt),Ei=It*ne+Ct-80+Math.min(Tn*20,80);st(this).transition("enter").duration(Ct).delay(Ei).ease(dt).attr("opacity",1)})}i&&this.emitAfterAnimate(h?0:Ee+100)}applyExplicitColumnLayout(t,e,i,r,o,s,a,c,l){var m,b;const h=new Map;for(const x of t.nodes){const v=i(x);x.depth=v,x.layer=v,h.has(v)||h.set(v,[]),h.get(v).push(x)}const f=Array.from(h.entries()).sort((x,v)=>x[0]-v[0]),u=Math.max(1,...f.map(([,x])=>x.length)),d=u>1?Math.min(c,Math.max(1,a/(u-1))):c,y=f.map(([,x])=>x.reduce((v,k)=>v+Math.max(0,k.value??0),0)).filter(x=>x>0).length>0?Math.min(...f.map(([,x])=>{const v=x.reduce((k,M)=>k+Math.max(0,M.value??0),0);return v<=0?1/0:Math.max(1e-4,(a-Math.max(0,x.length-1)*d)/v)})):1,g=r>0?(s-o-l)/r:0;for(const[x,v]of f){const k=v.some(_=>typeof _.offset=="number");v.sort((_,T)=>k?(_.offset??0)-(T.offset??0)||(_.y0??0)-(T.y0??0)||String(_.name??_.id).localeCompare(String(T.name??T.id)):(T.value??0)-(_.value??0)||String(_.name??_.id).localeCompare(String(T.name??T.id)));const M=v.reduce((_,T)=>_+Math.max(1,(T.value??0)*y),0)+Math.max(0,v.length-1)*d;let C=Math.max(0,(a-M)/2);const E=o+x*g;for(const _ of v){const T=Math.max(1,(_.value??0)*y);_.x0=E,_.x1=E+l,_.y0=C,_.y1=C+T,C=_.y1+d}}for(const x of t.links)x.width=Math.max(1e-4,x.value*y);for(const x of t.nodes)(m=x.sourceLinks)==null||m.sort((v,k)=>(v.target.y0??0)-(k.target.y0??0)),(b=x.targetLinks)==null||b.sort((v,k)=>(v.source.y0??0)-(k.source.y0??0));return e.update(t),d}reorderNodesByValueDesc(t,e,i,r,o){var a,c;const s=new Map;for(const l of t.nodes){const h=i(l);s.has(h)||s.set(h,[]),s.get(h).push(l)}for(const[,l]of s){if(l.some(p=>typeof p.offset=="number"))continue;const u=l.reduce((p,y)=>p+(y.y1-y.y0),0)+Math.max(0,l.length-1)*o;l.sort((p,y)=>(y.value??0)-(p.value??0)||String(p.name??p.id).localeCompare(String(y.name??y.id)));let d=Math.max(0,(r-u)/2);for(const p of l){const y=p.y1-p.y0;p.y0=d,p.y1=d+y,d=p.y1+o}}for(const l of t.nodes)(a=l.sourceLinks)==null||a.sort((h,f)=>(h.target.y0??0)-(f.target.y0??0)),(c=l.targetLinks)==null||c.sort((h,f)=>(h.source.y0??0)-(f.source.y0??0));e.update(t)}centerAndSpreadNodes(t,e,i,r,o){const s=new Map;for(const a of t.nodes){const c=a.layer??a.depth??0;s.has(c)||s.set(c,[]),s.get(c).push(a)}for(const[,a]of s){if(a.sort((f,u)=>f.y0-u.y0),r!==1&&a.length>1){const f=a[0].y0,u=a[a.length-1].y1,d=(f+u)/2;for(const p of a){const y=(p.y0+p.y1)/2,g=p.y1-p.y0,m=d+(y-d)*r;p.y0=m-g/2,p.y1=m+g/2}for(let p=1;p<a.length;p++){const y=a[p-1].y1+o-a[p].y0;y>0&&(a[p].y0+=y,a[p].y1+=y)}}const c=a[0].y0,l=a[a.length-1].y1,h=(i-(l-c))/2-c;for(const f of a){const u=f.y1-f.y0,d=f.y0+h;f.y0=Math.max(0,Math.min(i-u,d)),f.y1=f.y0+u}}e.update(t)}buildGraph(){const t=new Map,e=[],i=this.config.nodes||[];for(const r of i)t.set(r.id,{id:r.id,name:r.name||r.id,color:r.color,column:r.column,offset:r.offset});for(const r of this.data){const o=r.from,s=r.to,a=r.y??r.weight??1;o&&s&&(t.has(o)||t.set(o,{id:o,name:o}),t.has(s)||t.set(s,{id:s,name:s}),e.push({source:o,target:s,value:a}))}return{nodes:Array.from(t.values()),links:e}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function kA(n,t){var e,i=1;n==null&&(n=0),t==null&&(t=0);function r(){var o,s=e.length,a,c=0,l=0;for(o=0;o<s;++o)a=e[o],c+=a.x,l+=a.y;for(c=(c/s-n)*i,l=(l/s-t)*i,o=0;o<s;++o)a=e[o],a.x-=c,a.y-=l}return r.initialize=function(o){e=o},r.x=function(o){return arguments.length?(n=+o,r):n},r.y=function(o){return arguments.length?(t=+o,r):t},r.strength=function(o){return arguments.length?(i=+o,r):i},r}function MA(n){const t=+this._x.call(null,n),e=+this._y.call(null,n);return Np(this.cover(t,e),t,e,n)}function Np(n,t,e,i){if(isNaN(t)||isNaN(e))return n;var r,o=n._root,s={data:i},a=n._x0,c=n._y0,l=n._x1,h=n._y1,f,u,d,p,y,g,m,b;if(!o)return n._root=s,n;for(;o.length;)if((y=t>=(f=(a+l)/2))?a=f:l=f,(g=e>=(u=(c+h)/2))?c=u:h=u,r=o,!(o=o[m=g<<1|y]))return r[m]=s,n;if(d=+n._x.call(null,o.data),p=+n._y.call(null,o.data),t===d&&e===p)return s.next=o,r?r[m]=s:n._root=s,n;do r=r?r[m]=new Array(4):n._root=new Array(4),(y=t>=(f=(a+l)/2))?a=f:l=f,(g=e>=(u=(c+h)/2))?c=u:h=u;while((m=g<<1|y)===(b=(p>=u)<<1|d>=f));return r[b]=o,r[m]=s,n}function AA(n){var t,e,i=n.length,r,o,s=new Array(i),a=new Array(i),c=1/0,l=1/0,h=-1/0,f=-1/0;for(e=0;e<i;++e)isNaN(r=+this._x.call(null,t=n[e]))||isNaN(o=+this._y.call(null,t))||(s[e]=r,a[e]=o,r<c&&(c=r),r>h&&(h=r),o<l&&(l=o),o>f&&(f=o));if(c>h||l>f)return this;for(this.cover(c,l).cover(h,f),e=0;e<i;++e)Np(this,s[e],a[e],n[e]);return this}function SA(n,t){if(isNaN(n=+n)||isNaN(t=+t))return this;var e=this._x0,i=this._y0,r=this._x1,o=this._y1;if(isNaN(e))r=(e=Math.floor(n))+1,o=(i=Math.floor(t))+1;else{for(var s=r-e||1,a=this._root,c,l;e>n||n>=r||i>t||t>=o;)switch(l=(t<i)<<1|n<e,c=new Array(4),c[l]=a,a=c,s*=2,l){case 0:r=e+s,o=i+s;break;case 1:e=r-s,o=i+s;break;case 2:r=e+s,i=o-s;break;case 3:e=r-s,i=o-s;break}this._root&&this._root.length&&(this._root=a)}return this._x0=e,this._y0=i,this._x1=r,this._y1=o,this}function _A(){var n=[];return this.visit(function(t){if(!t.length)do n.push(t.data);while(t=t.next)}),n}function CA(n){return arguments.length?this.cover(+n[0][0],+n[0][1]).cover(+n[1][0],+n[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function Be(n,t,e,i,r){this.node=n,this.x0=t,this.y0=e,this.x1=i,this.y1=r}function PA(n,t,e){var i,r=this._x0,o=this._y0,s,a,c,l,h=this._x1,f=this._y1,u=[],d=this._root,p,y;for(d&&u.push(new Be(d,r,o,h,f)),e==null?e=1/0:(r=n-e,o=t-e,h=n+e,f=t+e,e*=e);p=u.pop();)if(!(!(d=p.node)||(s=p.x0)>h||(a=p.y0)>f||(c=p.x1)<r||(l=p.y1)<o))if(d.length){var g=(s+c)/2,m=(a+l)/2;u.push(new Be(d[3],g,m,c,l),new Be(d[2],s,m,g,l),new Be(d[1],g,a,c,m),new Be(d[0],s,a,g,m)),(y=(t>=m)<<1|n>=g)&&(p=u[u.length-1],u[u.length-1]=u[u.length-1-y],u[u.length-1-y]=p)}else{var b=n-+this._x.call(null,d.data),x=t-+this._y.call(null,d.data),v=b*b+x*x;if(v<e){var k=Math.sqrt(e=v);r=n-k,o=t-k,h=n+k,f=t+k,i=d.data}}return i}function EA(n){if(isNaN(h=+this._x.call(null,n))||isNaN(f=+this._y.call(null,n)))return this;var t,e=this._root,i,r,o,s=this._x0,a=this._y0,c=this._x1,l=this._y1,h,f,u,d,p,y,g,m;if(!e)return this;if(e.length)for(;;){if((p=h>=(u=(s+c)/2))?s=u:c=u,(y=f>=(d=(a+l)/2))?a=d:l=d,t=e,!(e=e[g=y<<1|p]))return this;if(!e.length)break;(t[g+1&3]||t[g+2&3]||t[g+3&3])&&(i=t,m=g)}for(;e.data!==n;)if(r=e,!(e=e.next))return this;return(o=e.next)&&delete e.next,r?(o?r.next=o:delete r.next,this):t?(o?t[g]=o:delete t[g],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(i?i[m]=e:this._root=e),this):(this._root=o,this)}function TA(n){for(var t=0,e=n.length;t<e;++t)this.remove(n[t]);return this}function LA(){return this._root}function $A(){var n=0;return this.visit(function(t){if(!t.length)do++n;while(t=t.next)}),n}function IA(n){var t=[],e,i=this._root,r,o,s,a,c;for(i&&t.push(new Be(i,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!n(i=e.node,o=e.x0,s=e.y0,a=e.x1,c=e.y1)&&i.length){var l=(o+a)/2,h=(s+c)/2;(r=i[3])&&t.push(new Be(r,l,h,a,c)),(r=i[2])&&t.push(new Be(r,o,h,l,c)),(r=i[1])&&t.push(new Be(r,l,s,a,h)),(r=i[0])&&t.push(new Be(r,o,s,l,h))}return this}function FA(n){var t=[],e=[],i;for(this._root&&t.push(new Be(this._root,this._x0,this._y0,this._x1,this._y1));i=t.pop();){var r=i.node;if(r.length){var o,s=i.x0,a=i.y0,c=i.x1,l=i.y1,h=(s+c)/2,f=(a+l)/2;(o=r[0])&&t.push(new Be(o,s,a,h,f)),(o=r[1])&&t.push(new Be(o,h,a,c,f)),(o=r[2])&&t.push(new Be(o,s,f,h,l)),(o=r[3])&&t.push(new Be(o,h,f,c,l))}e.push(i)}for(;i=e.pop();)n(i.node,i.x0,i.y0,i.x1,i.y1);return this}function RA(n){return n[0]}function DA(n){return arguments.length?(this._x=n,this):this._x}function zA(n){return n[1]}function BA(n){return arguments.length?(this._y=n,this):this._y}function Al(n,t,e){var i=new Sl(t??RA,e??zA,NaN,NaN,NaN,NaN);return n==null?i:i.addAll(n)}function Sl(n,t,e,i,r,o){this._x=n,this._y=t,this._x0=e,this._y0=i,this._x1=r,this._y1=o,this._root=void 0}function Wp(n){for(var t={data:n.data},e=t;n=n.next;)e=e.next={data:n.data};return t}var Oe=Al.prototype=Sl.prototype;Oe.copy=function(){var n=new Sl(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,i;if(!t)return n;if(!t.length)return n._root=Wp(t),n;for(e=[{source:t,target:n._root=new Array(4)}];t=e.pop();)for(var r=0;r<4;++r)(i=t.source[r])&&(i.length?e.push({source:i,target:t.target[r]=new Array(4)}):t.target[r]=Wp(i));return n},Oe.add=MA,Oe.addAll=AA,Oe.cover=SA,Oe.data=_A,Oe.extent=CA,Oe.find=PA,Oe.remove=EA,Oe.removeAll=TA,Oe.root=LA,Oe.size=$A,Oe.visit=IA,Oe.visitAfter=FA,Oe.x=DA,Oe.y=BA;function Pi(n){return function(){return n}}function ni(n){return(n()-.5)*1e-6}function OA(n){return n.x+n.vx}function NA(n){return n.y+n.vy}function WA(n){var t,e,i,r=1,o=1;typeof n!="function"&&(n=Pi(n==null?1:+n));function s(){for(var l,h=t.length,f,u,d,p,y,g,m=0;m<o;++m)for(f=Al(t,OA,NA).visitAfter(a),l=0;l<h;++l)u=t[l],y=e[u.index],g=y*y,d=u.x+u.vx,p=u.y+u.vy,f.visit(b);function b(x,v,k,M,C){var E=x.data,_=x.r,T=y+_;if(E){if(E.index>u.index){var I=d-E.x-E.vx,L=p-E.y-E.vy,P=I*I+L*L;P<T*T&&(I===0&&(I=ni(i),P+=I*I),L===0&&(L=ni(i),P+=L*L),P=(T-(P=Math.sqrt(P)))/P*r,u.vx+=(I*=P)*(T=(_*=_)/(g+_)),u.vy+=(L*=P)*T,E.vx-=I*(T=1-T),E.vy-=L*T)}return}return v>d+T||M<d-T||k>p+T||C<p-T}}function a(l){if(l.data)return l.r=e[l.data.index];for(var h=l.r=0;h<4;++h)l[h]&&l[h].r>l.r&&(l.r=l[h].r)}function c(){if(t){var l,h=t.length,f;for(e=new Array(h),l=0;l<h;++l)f=t[l],e[f.index]=+n(f,l,t)}}return s.initialize=function(l,h){t=l,i=h,c()},s.iterations=function(l){return arguments.length?(o=+l,s):o},s.strength=function(l){return arguments.length?(r=+l,s):r},s.radius=function(l){return arguments.length?(n=typeof l=="function"?l:Pi(+l),c(),s):n},s}function HA(n){return n.index}function Hp(n,t){var e=n.get(t);if(!e)throw new Error("node not found: "+t);return e}function VA(n){var t=HA,e=f,i,r=Pi(30),o,s,a,c,l,h=1;n==null&&(n=[]);function f(g){return 1/Math.min(a[g.source.index],a[g.target.index])}function u(g){for(var m=0,b=n.length;m<h;++m)for(var x=0,v,k,M,C,E,_,T;x<b;++x)v=n[x],k=v.source,M=v.target,C=M.x+M.vx-k.x-k.vx||ni(l),E=M.y+M.vy-k.y-k.vy||ni(l),_=Math.sqrt(C*C+E*E),_=(_-o[x])/_*g*i[x],C*=_,E*=_,M.vx-=C*(T=c[x]),M.vy-=E*T,k.vx+=C*(T=1-T),k.vy+=E*T}function d(){if(s){var g,m=s.length,b=n.length,x=new Map(s.map((k,M)=>[t(k,M,s),k])),v;for(g=0,a=new Array(m);g<b;++g)v=n[g],v.index=g,typeof v.source!="object"&&(v.source=Hp(x,v.source)),typeof v.target!="object"&&(v.target=Hp(x,v.target)),a[v.source.index]=(a[v.source.index]||0)+1,a[v.target.index]=(a[v.target.index]||0)+1;for(g=0,c=new Array(b);g<b;++g)v=n[g],c[g]=a[v.source.index]/(a[v.source.index]+a[v.target.index]);i=new Array(b),p(),o=new Array(b),y()}}function p(){if(s)for(var g=0,m=n.length;g<m;++g)i[g]=+e(n[g],g,n)}function y(){if(s)for(var g=0,m=n.length;g<m;++g)o[g]=+r(n[g],g,n)}return u.initialize=function(g,m){s=g,l=m,d()},u.links=function(g){return arguments.length?(n=g,d(),u):n},u.id=function(g){return arguments.length?(t=g,u):t},u.iterations=function(g){return arguments.length?(h=+g,u):h},u.strength=function(g){return arguments.length?(e=typeof g=="function"?g:Pi(+g),p(),u):e},u.distance=function(g){return arguments.length?(r=typeof g=="function"?g:Pi(+g),y(),u):r},u}const GA=1664525,YA=1013904223,Vp=4294967296;function XA(){let n=1;return()=>(n=(GA*n+YA)%Vp)/Vp}function UA(n){return n.x}function jA(n){return n.y}var qA=10,ZA=Math.PI*(3-Math.sqrt(5));function KA(n){var t,e=1,i=.001,r=1-Math.pow(i,1/300),o=0,s=.6,a=new Map,c=Ko(f),l=Ni("tick","end"),h=XA();n==null&&(n=[]);function f(){u(),l.call("tick",t),e<i&&(c.stop(),l.call("end",t))}function u(y){var g,m=n.length,b;y===void 0&&(y=1);for(var x=0;x<y;++x)for(e+=(o-e)*r,a.forEach(function(v){v(e)}),g=0;g<m;++g)b=n[g],b.fx==null?b.x+=b.vx*=s:(b.x=b.fx,b.vx=0),b.fy==null?b.y+=b.vy*=s:(b.y=b.fy,b.vy=0);return t}function d(){for(var y=0,g=n.length,m;y<g;++y){if(m=n[y],m.index=y,m.fx!=null&&(m.x=m.fx),m.fy!=null&&(m.y=m.fy),isNaN(m.x)||isNaN(m.y)){var b=qA*Math.sqrt(.5+y),x=y*ZA;m.x=b*Math.cos(x),m.y=b*Math.sin(x)}(isNaN(m.vx)||isNaN(m.vy))&&(m.vx=m.vy=0)}}function p(y){return y.initialize&&y.initialize(n,h),y}return d(),t={tick:u,restart:function(){return c.restart(f),t},stop:function(){return c.stop(),t},nodes:function(y){return arguments.length?(n=y,d(),a.forEach(p),t):n},alpha:function(y){return arguments.length?(e=+y,t):e},alphaMin:function(y){return arguments.length?(i=+y,t):i},alphaDecay:function(y){return arguments.length?(r=+y,t):+r},alphaTarget:function(y){return arguments.length?(o=+y,t):o},velocityDecay:function(y){return arguments.length?(s=1-y,t):1-s},randomSource:function(y){return arguments.length?(h=y,a.forEach(p),t):h},force:function(y,g){return arguments.length>1?(g==null?a.delete(y):a.set(y,p(g)),t):a.get(y)},find:function(y,g,m){var b=0,x=n.length,v,k,M,C,E;for(m==null?m=1/0:m*=m,b=0;b<x;++b)C=n[b],v=y-C.x,k=g-C.y,M=v*v+k*k,M<m&&(E=C,m=M);return E},on:function(y,g){return arguments.length>1?(l.on(y,g),t):l.on(y)}}}function JA(){var n,t,e,i,r=Pi(-30),o,s=1,a=1/0,c=.81;function l(d){var p,y=n.length,g=Al(n,UA,jA).visitAfter(f);for(i=d,p=0;p<y;++p)t=n[p],g.visit(u)}function h(){if(n){var d,p=n.length,y;for(o=new Array(p),d=0;d<p;++d)y=n[d],o[y.index]=+r(y,d,n)}}function f(d){var p=0,y,g,m=0,b,x,v;if(d.length){for(b=x=v=0;v<4;++v)(y=d[v])&&(g=Math.abs(y.value))&&(p+=y.value,m+=g,b+=g*y.x,x+=g*y.y);d.x=b/m,d.y=x/m}else{y=d,y.x=y.data.x,y.y=y.data.y;do p+=o[y.data.index];while(y=y.next)}d.value=p}function u(d,p,y,g){if(!d.value)return!0;var m=d.x-t.x,b=d.y-t.y,x=g-p,v=m*m+b*b;if(x*x/c<v)return v<a&&(m===0&&(m=ni(e),v+=m*m),b===0&&(b=ni(e),v+=b*b),v<s&&(v=Math.sqrt(s*v)),t.vx+=m*d.value*i/v,t.vy+=b*d.value*i/v),!0;if(d.length||v>=a)return;(d.data!==t||d.next)&&(m===0&&(m=ni(e),v+=m*m),b===0&&(b=ni(e),v+=b*b),v<s&&(v=Math.sqrt(s*v)));do d.data!==t&&(x=o[d.data.index]*i/v,t.vx+=m*x,t.vy+=b*x);while(d=d.next)}return l.initialize=function(d,p){n=d,e=p,h()},l.strength=function(d){return arguments.length?(r=typeof d=="function"?d:Pi(+d),h(),l):r},l.distanceMin=function(d){return arguments.length?(s=d*d,l):Math.sqrt(s)},l.distanceMax=function(d){return arguments.length?(a=d*d,l):Math.sqrt(a)},l.theta=function(d){return arguments.length?(c=d*d,l):Math.sqrt(c)},l}class QA extends Ht{constructor(t){super(t),this.simulation=null}render(){var L,P,A;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,{nodes:o,links:s}=this.buildGraph();if(o.length===0)return;const a=r.link||{},c=r.layoutAlgorithm||{},l=r.draggable!==!1,h=c.linkLength??a.distance??80,f=a.color??"#999",u=a.width,d=a.dashStyle,p=c.maxIterations??300,y=c.gravitationalConstant??-200,g=c.friction??.9,m=c.maxSpeed??10,b=c.initialPositions,x=c.attractiveForce,v=c.repulsiveForce;if(b==="circle"){const w=t.width/2,S=t.height/2,$=Math.min(t.width,t.height)/3;o.forEach((R,F)=>{const D=2*Math.PI*F/o.length;R.x=w+$*Math.cos(D),R.y=S+$*Math.sin(D)})}else b==="random"?o.forEach(w=>{w.x=Math.random()*t.width,w.y=Math.random()*t.height}):typeof b=="function"&&b(o);const k=Math.sqrt(t.width*t.height/Math.max(o.length,1)),M=VA(s).id(w=>w.id);x?M.distance(w=>x(Math.sqrt((w.source.x-w.target.x)**2+(w.source.y-w.target.y)**2)||1,k)):M.distance(h);const C=JA();v?C.strength(w=>-v(1,k)):C.strength(y),this.simulation=KA(o).force("link",M).force("charge",C).force("center",kA(t.width/2,t.height/2)).force("collide",WA(20)).velocityDecay(1-g).alphaDecay(1-Math.pow(.001,1/p)).stop();for(let w=0;w<p;w++)this.simulation.tick(),o.forEach(S=>{const $=Math.abs(S.vx||0),R=Math.abs(S.vy||0);$>m&&(S.vx=Math.sign(S.vx)*m),R>m&&(S.vy=Math.sign(S.vy)*m)});o.forEach(w=>{var $;const S=(($=w.marker)==null?void 0:$.radius)||10;w.x=Math.max(S+30,Math.min(t.width-S-30,w.x??0)),w.y=Math.max(S+18,Math.min(t.height-S-6,w.y??0))});const E=this.getDashArray(d),_=this.group.selectAll(".katucharts-network-link").data(s).join("line").attr("class","katucharts-network-link").attr("x1",w=>w.source.x).attr("y1",w=>w.source.y).attr("x2",w=>w.target.x).attr("y2",w=>w.target.y).attr("stroke",f).attr("stroke-width",w=>u??Math.sqrt(w.value||1)).attr("stroke-dasharray",E);i?_.attr("stroke-opacity",0).transition().duration(gt).ease(dt).attr("stroke-opacity",.6):_.attr("stroke-opacity",.6);const T=this.group.selectAll(".katucharts-network-node").data(o).join("circle").attr("class","katucharts-network-node").attr("cx",w=>w.x).attr("cy",w=>w.y).attr("fill",(w,S)=>w.color||e[S%e.length]).attr("stroke",this.autoBorderColor()).attr("stroke-width",1.5).style("cursor",l?"grab":"pointer");if(i?T.attr("r",0).transition().duration(gt).ease(dt).attr("r",w=>{var S;return((S=w.marker)==null?void 0:S.radius)||10}):T.attr("r",w=>{var S;return((S=w.marker)==null?void 0:S.radius)||10}),l){const w=kf().on("start",(S,$)=>{st(S.sourceEvent.target).style("cursor","grabbing"),this.simulation&&this.simulation.alphaTarget(.3).restart(),$.fx=$.x,$.fy=$.y}).on("drag",(S,$)=>{$.fx=S.x,$.fy=S.y,$.x=S.x,$.y=S.y,this.updatePositions(T,_,I)}).on("end",(S,$)=>{st(S.sourceEvent.target).style("cursor","grab"),this.simulation&&this.simulation.alphaTarget(0),$.fx=null,$.fy=null});T.call(w)}T.on("mouseover",(w,S)=>{var D;const $=st(w.currentTarget),R=((D=S.marker)==null?void 0:D.radius)||10;$.transition("size").duration(Z).ease(q).attr("r",R+4),$.style("filter","drop-shadow(0 2px 6px rgba(0,0,0,0.3))"),T.interrupt("highlight"),_.interrupt("highlight"),T.attr("opacity",1),_.transition("highlight").duration(Z).ease(q).attr("stroke-opacity",z=>z.source===S||z.target===S?.9:.1).attr("stroke-width",z=>z.source===S||z.target===S?3:u??Math.sqrt(z.value||1)),T.filter(z=>z!==S).transition("highlight").duration(Z).ease(q).attr("opacity",z=>s.some(N=>N.source===S&&N.target===z||N.target===S&&N.source===z)?1:.3);const F=o.indexOf(S);this.context.events.emit("point:mouseover",{point:{name:S.name||S.id},index:F,series:this,event:w,plotX:S.x,plotY:S.y})}).on("mouseout",(w,S)=>{var F;const $=st(w.currentTarget);$.transition("size").duration(Z).ease(q).attr("r",((F=S.marker)==null?void 0:F.radius)||10),$.style("filter",""),T.interrupt("highlight"),_.interrupt("highlight"),_.transition("highlight").duration(Z).ease(q).attr("stroke-opacity",.6).attr("stroke-width",D=>u??Math.sqrt(D.value||1)),T.transition("highlight").duration(Z).ease(q).attr("opacity",1);const R=o.indexOf(S);this.context.events.emit("point:mouseout",{point:{name:S.name||S.id},index:R,series:this,event:w})}).on("click",(w,S)=>{const $=o.indexOf(S);this.context.events.emit("point:click",{point:{name:S.name||S.id},index:$,series:this,event:w})});const I=this.group.selectAll(".katucharts-network-label").data(o).join("text").attr("class","katucharts-network-label").attr("x",w=>w.x).attr("y",w=>w.y-14).attr("text-anchor","middle").attr("font-size",kt).attr("fill",this.autoLabelColor(((L=this.config.dataLabels)==null?void 0:L.color)||((A=(P=this.config.dataLabels)==null?void 0:P.style)==null?void 0:A.color))).style("pointer-events","none").text(w=>w.name||w.id);i&&I.attr("opacity",0).transition().duration(gt).ease(dt).attr("opacity",1)}updatePositions(t,e,i){t.attr("cx",r=>r.x).attr("cy",r=>r.y),e.attr("x1",r=>r.source.x).attr("y1",r=>r.source.y).attr("x2",r=>r.target.x).attr("y2",r=>r.target.y),i.attr("x",r=>r.x).attr("y",r=>r.y-14)}getDashArray(t){return t&&{Solid:"none",ShortDash:"6,2",ShortDot:"2,2",ShortDashDot:"6,2,2,2",Dot:"2,6",Dash:"8,6",LongDash:"16,6",DashDot:"8,6,2,6",LongDashDot:"16,6,2,6",LongDashDotDot:"16,6,2,6,2,6"}[t]||"none"}buildGraph(){const t=new Map,e=[],i=this.config.nodes||[];for(const r of i)t.set(r.id,{...r});for(const r of this.data){const o=r[0]||r.from,s=r[1]||r.to;o&&s&&(t.has(o)||t.set(o,{id:o,name:o}),t.has(s)||t.set(s,{id:s,name:s}),e.push({source:o,target:s,value:r.y??1}))}return{nodes:Array.from(t.values()),links:e}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}destroy(){this.simulation&&(this.simulation.stop(),this.simulation=null),super.destroy()}}var t5=Math.PI,Gp=t5*2,Yp=Math.max;function Xp(n,t){return Array.from({length:t-n},(e,i)=>n+i)}function e5(n){return function(t,e){return n(t.source.value+t.target.value,e.source.value+e.target.value)}}function n5(){return i5(!1)}function i5(n,t){var e=0,i=null,r=null,o=null;function s(a){var c=a.length,l=new Array(c),h=Xp(0,c),f=new Array(c*c),u=new Array(c),d=0,p;a=Float64Array.from({length:c*c},(y,g)=>a[g/c|0][g%c]);for(let y=0;y<c;++y){let g=0;for(let m=0;m<c;++m)g+=a[y*c+m]+n*a[m*c+y];d+=l[y]=g}d=Yp(0,Gp-e*c)/d,p=d?e:Gp/c;{let y=0;i&&h.sort((g,m)=>i(l[g],l[m]));for(const g of h){const m=y;{const b=Xp(0,c).filter(x=>a[g*c+x]||a[x*c+g]);r&&b.sort((x,v)=>r(a[g*c+x],a[g*c+v]));for(const x of b){let v;if(g<x?(v=f[g*c+x]||(f[g*c+x]={source:null,target:null}),v.source={index:g,startAngle:y,endAngle:y+=a[g*c+x]*d,value:a[g*c+x]}):(v=f[x*c+g]||(f[x*c+g]={source:null,target:null}),v.target={index:g,startAngle:y,endAngle:y+=a[g*c+x]*d,value:a[g*c+x]},g===x&&(v.source=v.target)),v.source&&v.target&&v.source.value<v.target.value){const k=v.source;v.source=v.target,v.target=k}}u[g]={index:g,startAngle:m,endAngle:y,value:l[g]}}y+=p}}return f=Object.values(f),f.groups=u,o?f.sort(o):f}return s.padAngle=function(a){return arguments.length?(e=Yp(0,a),s):e},s.sortGroups=function(a){return arguments.length?(i=a,s):i},s.sortSubgroups=function(a){return arguments.length?(r=a,s):r},s.sortChords=function(a){return arguments.length?(a==null?o=null:(o=e5(a))._=a,s):o&&o._},s}class r5 extends Ht{constructor(t){super(t)}render(){var Jr,Qr,to;const{plotArea:t,colors:e}=this.context,i=this.context.animate,r=this.config,o=r.labelType??"max",s=gt*2,a=8,c=Math.round(s*.48),l=12,h=Math.round(c*.65),f=c+8,u=r.nodeWidth??20,d=r.linkOpacity??.5;r.minLinkWidth;const p=(r.startAngle??0)*(Math.PI/180),y=(Jr=this.group.node())==null?void 0:Jr.parentElement;y&&st(y).attr("clip-path",null);const g=this.group.select(function(){return this.ownerSVGElement});g.empty()||g.style("overflow","visible");const m=r.center||["50%","50%"],b=this.resolvePercent(m[0],t.width),x=this.resolvePercent(m[1],t.height),v=r.size,k=o==="small"?34:70,M=o==="small"?34:24,C=Math.max(80,Math.min(t.width-2*k,t.height-2*M)),E=v?this.resolvePercent(v,C):C,_=Math.max(40,E/2-2),T=_-u,{matrix:I,names:L,nodeColors:P}=this.buildMatrix();if(L.length===0)return;const w=(r.nodePadding??2)/(_>0?_:1),$=n5().padAngle(w).sortSubgroups(null)(I);this.normalizeChordWidths($),this.sortChordEndpoints($);const R=Pe().innerRadius(T).outerRadius(_).cornerRadius(3),F=Pe().innerRadius(T).outerRadius(_+4).cornerRadius(3),D=r.curveFactor??.05,z=rt=>{const ot=T,ft=rt.source.startAngle+p-Math.PI/2,Mt=rt.source.endAngle+p-Math.PI/2,xt=rt.target.startAngle+p-Math.PI/2,yt=rt.target.endAngle+p-Math.PI/2,Q=ot*Math.cos(ft),Et=ot*Math.sin(ft),zt=ot*Math.cos(Mt),mt=ot*Math.sin(Mt),jt=ot*Math.cos(xt),Nt=ot*Math.sin(xt),qt=ot*Math.cos(yt),ie=ot*Math.sin(yt),Wt=Math.abs(Mt-ft)>Math.PI?1:0,fn=Math.abs(yt-xt)>Math.PI?1:0;let Ne=Math.abs(xt-Mt);Ne>Math.PI&&(Ne=2*Math.PI-Ne);const Ue=Ne/Math.PI,Le=ot*Math.max(D,(1-Ue)*(1-Ue)*(1-Ue));let dn=Math.abs(ft-yt);dn>Math.PI&&(dn=2*Math.PI-dn);const vn=dn/Math.PI,Un=ot*Math.max(D,(1-vn)*(1-vn)*(1-vn));return`M${Q},${Et}A${ot},${ot},0,${Wt},1,${zt},${mt}C${Le*Math.cos(Mt)},${Le*Math.sin(Mt)},${Le*Math.cos(xt)},${Le*Math.sin(xt)},${jt},${Nt}A${ot},${ot},0,${fn},1,${qt},${ie}C${Un*Math.cos(yt)},${Un*Math.sin(yt)},${Un*Math.cos(ft)},${Un*Math.sin(ft)},${Q},${Et}Z`},B=this.group.append("g").attr("transform",`translate(${b},${x})`),N=rt=>P[rt]||e[rt%e.length],K=r.linkColorMode??"from",V=B.append("defs");let G=null;K==="gradient"&&(G=V);const H=rt=>N(K==="to"?rt.target.index:rt.source.index),j=u*2,U=(rt,ot,ft,Mt)=>{const xt=`katucharts-dw-edge-${Mt}-${ft}-${Math.random().toString(36).slice(2,6)}`,yt=T*Math.cos(rt),Q=T*Math.sin(rt),Et=(T-j)*Math.cos(rt),zt=(T-j)*Math.sin(rt);return V.append("linearGradient").attr("id",xt).attr("gradientUnits","userSpaceOnUse").attr("x1",yt).attr("y1",Q).attr("x2",Et).attr("y2",zt).selectAll("stop").data([{offset:"0%",opacity:.7},{offset:"25%",opacity:.2},{offset:"50%",opacity:.05},{offset:"100%",opacity:0}]).join("stop").attr("offset",mt=>mt.offset).attr("stop-color",ot).attr("stop-opacity",mt=>mt.opacity),xt},X=K!=="gradient";let tt,O;if(X){const rt=new Map;for(const Mt of $){const xt=H(Mt);rt.has(xt)||rt.set(xt,[]),rt.get(xt).push(Mt)}const ot=B.append("g").attr("class","katucharts-chord-container");for(const[Mt,xt]of rt)ot.append("g").attr("class","katucharts-chord-group").attr("opacity",d).selectAll(".katucharts-chord").data(xt).join("path").attr("class","katucharts-chord").attr("d",Q=>z(Q)).attr("fill",Mt).attr("fill-opacity",1).attr("stroke","none").style("cursor","pointer");tt=ot.selectAll(".katucharts-chord"),O=ot.selectAll(".katucharts-chord-group");const ft=B.append("g").attr("class","katucharts-chord-edges").attr("opacity",d);if($.forEach((Mt,xt)=>{const yt=N(Mt.source.index),Q=N(Mt.target.index);if(yt===Q)return;const Et=z(Mt),zt=(Mt.target.startAngle+Mt.target.endAngle)/2+p-Math.PI/2,mt=U(zt,Q,xt,"tgt");ft.append("path").attr("d",Et).attr("fill",`url(#${mt})`).attr("stroke","none").style("pointer-events","none");const jt=(Mt.source.startAngle+Mt.source.endAngle)/2+p-Math.PI/2,Nt=U(jt,yt,xt,"src");ft.append("path").attr("d",Et).attr("fill",`url(#${Nt})`).attr("stroke","none").style("pointer-events","none")}),i){ft.attr("opacity",0);const Mt=B.append("defs"),xt=Math.round(s*.62);tt.each(function(Q,Et){const zt=f+Et*a,mt=`dw-clip-${Et}-${Math.random().toString(36).slice(2,6)}`,jt=Q.source.startAngle+p-Math.PI/2,Nt=Q.source.endAngle+p-Math.PI/2,qt=Q.target.startAngle+p-Math.PI/2,ie=Q.target.endAngle+p-Math.PI/2,Wt=(jt+Nt)/2,fn=(qt+ie)/2,Ne=T*Math.cos(Wt),Ue=T*Math.sin(Wt),Le=T*Math.cos(fn),dn=T*Math.sin(fn),vn=Math.atan2(dn-Ue,Le-Ne)*180/Math.PI,Un=Math.sqrt((Le-Ne)**2+(dn-Ue)**2)+_*2,eo=Mt.append("clipPath").attr("id",mt).attr("clipPathUnits","userSpaceOnUse"),Y=eo.append("rect").attr("transform",`translate(${Ne},${Ue}) rotate(${vn})`).attr("x",-_).attr("y",-_).attr("width",0).attr("height",_*2),et=st(this);et.attr("clip-path",`url(#${mt})`),Y.transition("enter").duration(xt).delay(zt).ease(dt).attr("width",Un).on("end",function(){et.attr("clip-path",null),eo.remove()})});const yt=f+($.length-1)*a+xt;ft.transition("enter").duration(300).delay(yt).ease(dt).attr("opacity",d)}}else if(tt=B.selectAll(".katucharts-chord").data($).join("path").attr("class","katucharts-chord").attr("d",rt=>z(rt)).attr("stroke","none").style("cursor","pointer"),tt.each(function(rt,ot){const ft=`katucharts-dw-grad-${ot}-${Math.random().toString(36).slice(2,6)}`,Mt=(rt.source.startAngle+rt.source.endAngle)/2+p-Math.PI/2,xt=(rt.target.startAngle+rt.target.endAngle)/2+p-Math.PI/2;G.append("linearGradient").attr("id",ft).attr("gradientUnits","userSpaceOnUse").attr("x1",T*Math.cos(Mt)).attr("y1",T*Math.sin(Mt)).attr("x2",T*Math.cos(xt)).attr("y2",T*Math.sin(xt)).selectAll("stop").data([{offset:"0%",color:N(rt.source.index)},{offset:"100%",color:N(rt.target.index)}]).join("stop").attr("offset",yt=>yt.offset).attr("stop-color",yt=>yt.color),st(this).attr("fill",`url(#${ft})`)}),i){tt.attr("fill-opacity",d);const rt=B.append("defs"),ot=Math.round(s*.62);tt.each(function(ft,Mt){const xt=f+Mt*a,yt=`dw-clip-${Mt}-${Math.random().toString(36).slice(2,6)}`,Q=ft.source.startAngle+p-Math.PI/2,Et=ft.source.endAngle+p-Math.PI/2,zt=ft.target.startAngle+p-Math.PI/2,mt=ft.target.endAngle+p-Math.PI/2,jt=(Q+Et)/2,Nt=(zt+mt)/2,qt=T*Math.cos(jt),ie=T*Math.sin(jt),Wt=T*Math.cos(Nt),fn=T*Math.sin(Nt),Ne=Math.atan2(fn-ie,Wt-qt)*180/Math.PI,Ue=Math.sqrt((Wt-qt)**2+(fn-ie)**2)+_*2,Le=rt.append("clipPath").attr("id",yt).attr("clipPathUnits","userSpaceOnUse"),dn=Le.append("rect").attr("transform",`translate(${qt},${ie}) rotate(${Ne})`).attr("x",-_).attr("y",-_).attr("width",0).attr("height",_*2),vn=st(this);vn.attr("clip-path",`url(#${yt})`),dn.transition("enter").duration(ot).delay(xt).ease(dt).attr("width",Ue).on("end",function(){vn.attr("clip-path",null),Le.remove()})})}else tt.attr("fill-opacity",d);const it=(rt,ot,ft)=>{const Mt=L[ft.source.index],xt=L[ft.target.index],yt={name:`${Mt} → ${xt}`,from:Mt,to:xt,y:ft.source.value,weight:ft.source.value,fromNode:{name:Mt},toNode:{name:xt}};if(rt==="mouseover"){this.context.events.emit("point:mouseover",{point:yt,index:$.indexOf(ft),series:this,event:ot,plotX:ot.offsetX-this.context.plotArea.x,plotY:ot.offsetY-this.context.plotArea.y});return}if(rt==="mouseout"){this.context.events.emit("point:mouseout",{point:yt,index:$.indexOf(ft),series:this,event:ot});return}this.context.events.emit("point:click",{point:yt,index:$.indexOf(ft),series:this,event:ot})},nt=(rt,ot)=>{tt.interrupt("highlight"),wt.interrupt("highlight"),O&&O.interrupt("highlight").attr("opacity",1),tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",ft=>ft===ot?Math.min(d+.35,1):.05),wt.attr("opacity",1),wt.transition("highlight").duration(Z).ease(q).attr("opacity",ft=>ft.index===ot.source.index||ft.index===ot.target.index?1:.3),it("mouseover",rt,ot)},lt=(rt,ot)=>{tt.interrupt("highlight"),wt.interrupt("highlight"),O?(O.interrupt("highlight"),O.transition("highlight").duration(Z).ease(q).attr("opacity",d),tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",1)):tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",d),wt.transition("highlight").duration(Z).ease(q).attr("opacity",1),it("mouseout",rt,ot)},ht=(rt,ot)=>{it("click",rt,ot)};tt.on("mouseover",nt).on("mouseout",lt).on("click",ht);const at=$.groups.map(rt=>({...rt,startAngle:rt.startAngle+p,endAngle:rt.endAngle+p})),W=rt=>{const ot=Math.PI*2;let ft=rt%ot;return ft<0&&(ft+=ot),ft},J=(rt,ot)=>{const ft=rt.offsetX-this.context.plotArea.x-b,Mt=rt.offsetY-this.context.plotArea.y-x,xt=W(Math.atan2(Mt,ft)+Math.PI/2),yt=$.filter(Nt=>Nt.source.index===ot.index||Nt.target.index===ot.index);if(yt.length===0)return null;const Q=Nt=>Nt.source.index===ot.index?Nt.source:Nt.target,Et=Nt=>{const qt=Q(Nt),ie=W(qt.startAngle+p),Wt=W(qt.endAngle+p);return ie<=Wt?xt>=ie&&xt<=Wt:xt>=ie||xt<=Wt},zt=yt.find(Et);if(zt)return zt;let mt=yt[0],jt=1/0;for(const Nt of yt){const qt=Q(Nt),ie=W((qt.startAngle+qt.endAngle)/2+p);let Wt=Math.abs(xt-ie);Wt>Math.PI&&(Wt=Math.PI*2-Wt),Wt<jt&&(jt=Wt,mt=Nt)}return mt},ut=rt=>{const ot=L[rt.source.index],ft=L[rt.target.index];return{name:`${ot} → ${ft}`,from:ot,to:ft,y:rt.source.value,weight:rt.source.value,fromNode:{name:ot},toNode:{name:ft}}},vt=r.borderColor??this.autoBorderColor(),Lt=r.borderWidth??1,wt=B.selectAll(".katucharts-chord-arc").data(at).join("path").attr("class","katucharts-chord-arc").attr("fill",rt=>N(rt.index)).attr("stroke",vt).attr("stroke-width",Lt).style("cursor","pointer");i?wt.each(function(rt,ot){const ft=st(this),Mt={startAngle:rt.startAngle,endAngle:rt.startAngle},xt=ue(Mt,rt);ft.transition("enter").duration(c).delay(ot*l).ease(dt).attrTween("d",()=>yt=>R(xt(yt)))}):wt.attr("d",R),wt.on("mouseover",(rt,ot)=>{st(rt.currentTarget).transition("arc").duration(Z).ease(q).attr("d",F(ot)),tt.interrupt("highlight"),wt.interrupt("highlight"),O&&O.interrupt("highlight").attr("opacity",1),tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",xt=>xt.source.index===ot.index||xt.target.index===ot.index?Math.min(d+.35,1):.05),wt.attr("opacity",1),wt.filter(xt=>xt!==ot).transition("highlight").duration(Z).ease(q).attr("opacity",xt=>$.some(Q=>Q.source.index===ot.index&&Q.target.index===xt.index||Q.target.index===ot.index&&Q.source.index===xt.index)?1:.3),Qe.filter(xt=>xt.index===ot.index).transition("label").duration(Z).ease(q).attr("opacity",1);const Mt=J(rt,ot);this.context.events.emit("point:mouseover",{point:Mt?ut(Mt):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt,plotX:rt.offsetX-this.context.plotArea.x,plotY:rt.offsetY-this.context.plotArea.y})}).on("mouseout",(rt,ot)=>{st(rt.currentTarget).transition("arc").duration(Z).ease(q).attr("d",R(ot)),tt.interrupt("highlight"),wt.interrupt("highlight"),O?(O.interrupt("highlight"),O.transition("highlight").duration(Z).ease(q).attr("opacity",d),tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",1)):tt.transition("highlight").duration(Z).ease(q).attr("fill-opacity",d),wt.transition("highlight").duration(Z).ease(q).attr("opacity",1),Qe.filter(xt=>xt.index===ot.index).transition("label").duration(Z).ease(q).attr("opacity",xt=>Kr(xt)?1:0);const Mt=J(rt,ot);this.context.events.emit("point:mouseout",{point:Mt?ut(Mt):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt})}).on("click",(rt,ot)=>{const ft=J(rt,ot);this.context.events.emit("point:click",{point:ft?ut(ft):{name:L[ot.index],y:ot.value,sum:ot.value},index:ot.index,series:this,event:rt})}),B.append("g").attr("class","katucharts-chord-hitareas").selectAll(".katucharts-chord-hitarea").data($).join("path").attr("class","katucharts-chord-hitarea").attr("d",rt=>z(rt)).attr("fill","#ffffff").attr("fill-opacity",0).attr("stroke","#ffffff").attr("stroke-opacity",0).attr("stroke-width",12).attr("stroke-linejoin","round").style("cursor","pointer").style("pointer-events","all").on("mouseover",nt).on("mouseout",lt).on("click",ht);const $t=this.config.dataLabels||{},Vt=$t.color||((Qr=$t.style)==null?void 0:Qr.color)||Fe,ee=((to=$t.style)==null?void 0:to.fontSize)||kt,Ct=se(ee),Jt=22,ne=_+Jt,Ee=Math.max(Ct*1.6,17),Gt="…",Ut=pe(Gt,Ct,"bold"),Xe=(rt,ot)=>{if(!rt||ot<=Ut)return"";if(pe(rt,Ct,"bold")<=ot)return rt;let ft="";for(const Mt of rt){if(pe(ft+Mt,Ct,"bold")+Ut>ot)break;ft+=Mt}return ft=ft.trimEnd(),(ft||rt[0])+Gt},ae=t.width-b,Pn=b,un=x,Te=t.height-x,de=at.map(rt=>{const ot=(rt.startAngle+rt.endAngle)/2,ft=Math.sin(ot)>=0;return{index:rt.index,mid:ot,span:rt.endAngle-rt.startAngle,isRight:ft,ax:_*Math.sin(ot),ay:-_*Math.cos(ot),lx:ne*Math.sin(ot),ly:-ne*Math.cos(ot),rank:rt.value||0,color:N(rt.index),visible:!!L[rt.index]}}),Kr=rt=>!!rt.visible,Je=B.append("g").attr("class","katucharts-chord-labels");let Qe;if(o==="small"){const rt=Math.PI*2,ot=_+6+Ct*.5,ft=yt=>[ot*Math.sin(yt),-ot*Math.cos(yt)],Mt=(yt,Q)=>{if(!yt)return"";const Et=Q*ot-2;if(Et<pe(yt[0],Ct,"bold"))return"";if(pe(yt,Ct,"bold")<=Et)return yt;let zt="";for(const mt of yt){if(zt&&pe(zt+mt,Ct,"bold")>Et)break;zt+=mt}return zt},xt=B.append("defs");if(Qe=Je.selectAll(".katucharts-chord-label").data(de.filter(yt=>yt.visible)).join("text").attr("class","katucharts-chord-label").attr("font-size",ee).attr("font-weight","bold").attr("fill",Vt).style("pointer-events","none").attr("opacity",0),Qe.each((yt,Q,Et)=>{const zt=st(Et[Q]);zt.text(null);const mt=Mt(L[yt.index]||"",yt.span);if(!mt)return;const jt=(yt.mid%rt+rt)%rt,Nt=jt>Math.PI/2&&jt<Math.PI*3/2,qt=yt.span/2,[ie,Wt]=ft(Nt?yt.mid+qt:yt.mid-qt),[fn,Ne]=ft(Nt?yt.mid-qt:yt.mid+qt),Ue=Nt?0:1,Le=`katucharts-dw-label-${Q}-${Math.random().toString(36).slice(2,6)}`;xt.append("path").attr("id",Le).attr("fill","none").attr("d",`M${ie},${Wt}A${ot},${ot},0,0,${Ue},${fn},${Ne}`),zt.append("textPath").attr("href",`#${Le}`).attr("startOffset","50%").attr("text-anchor","middle").attr("dominant-baseline","central").text(mt)}),i){Qe.transition("enter").duration(300).delay(h).ease(dt).attr("opacity",1);const yt=Math.round(s*.62),Q=$.length,Et=f+Q*a+yt;this.emitAfterAnimate(Et+100)}else Qe.attr("opacity",1)}else{const rt=Math.max(1,un-5+(Te-5));if(o==="medium"){const Et=Math.max(1,Math.min(10,Math.floor(rt/(Ee*1.2))))*2,zt=de.filter(mt=>mt.visible).sort((mt,jt)=>jt.rank-mt.rank);zt.length>Et&&zt.slice(Et).forEach(mt=>{mt.visible=!1})}else{const Q=Math.max(3,Math.floor(rt/(Ee*2)));for(const Et of[!0,!1])de.filter(mt=>mt.visible&&mt.isRight===Et).sort((mt,jt)=>jt.rank-mt.rank).slice(Q).forEach(mt=>{mt.visible=!1})}this.distributeChordLabels(de.filter(Q=>Q.visible&&Q.isRight),Ee,un,Te),this.distributeChordLabels(de.filter(Q=>Q.visible&&!Q.isRight),Ee,un,Te);const ot=Math.max(Ct*1.4,16),ft=Q=>{const Et=Q.filter(Nt=>Nt.visible).sort((Nt,qt)=>Nt.ly-qt.ly),zt=Et.length*Ee/rt;let mt=1;Et.length>=8&&zt>.5&&(mt=2),Et.length>=14&&zt>.75&&(mt=3);const jt=Math.max(1,mt*2-2);Et.forEach((Nt,qt)=>{if(mt<=1){Nt.col=0;return}const ie=qt%jt;Nt.col=ie<mt?ie:jt-ie})};if(o==="medium")for(const Q of de)Q.col=0;else ft(de.filter(Q=>Q.isRight)),ft(de.filter(Q=>!Q.isRight));for(const Q of de){if(!Q.visible)continue;const Et=(Q.col||0)*ot,zt=ne+Et,mt=Math.max(-zt,Math.min(zt,Q.ly)),jt=Math.sqrt(Math.max(0,zt*zt-mt*mt)),Nt=_*.4+Et;Q.lx=Q.isRight?Math.max(jt,Nt):-Math.max(jt,Nt);const qt=(Q.isRight?ae:Pn)-Ut-4;Q.lx=Q.isRight?Math.min(Q.lx,qt):Math.max(Q.lx,-qt)}const Mt=Q=>Q.lx+(Q.isRight?4:-4),xt=Q=>Math.max(0,(Q.isRight?ae-Mt(Q):Mt(Q)+Pn)-6),yt=Je.selectAll(".katucharts-chord-connector").data(de.filter(Q=>Q.visible)).join("path").attr("class","katucharts-chord-connector").attr("fill","none").attr("stroke",Q=>Q.color).attr("stroke-width",1).attr("opacity",0).attr("d",Q=>{const Et=_+Jt*.55,zt=Et*Math.sin(Q.mid),mt=-Et*Math.cos(Q.mid);return`M${Q.ax},${Q.ay}L${zt},${mt}L${Q.lx},${Q.ly}`});if(Qe=Je.selectAll(".katucharts-chord-label").data(de).join("text").attr("class","katucharts-chord-label").attr("text-anchor",Q=>Q.isRight?"start":"end").attr("dominant-baseline","middle").attr("font-size",ee).attr("font-weight","bold").attr("fill",Vt).style("pointer-events","none").attr("opacity",0).attr("x",Q=>Mt(Q)).attr("y",Q=>Q.ly).text(Q=>Q.visible&&xt(Q)>=Ut?Xe(L[Q.index]||"",xt(Q)):""),i){yt.transition("enter").duration(300).delay(h).ease(dt).attr("opacity",.8),Qe.transition("enter").duration(300).delay(h).ease(dt).attr("opacity",mt=>Kr(mt)?1:0);const Q=Math.round(s*.62),Et=$.length,zt=f+Et*a+Q;this.emitAfterAnimate(zt+100)}else yt.attr("opacity",.8),Qe.attr("opacity",Q=>Kr(Q)?1:0)}}distributeChordLabels(t,e,i,r){const o=t.filter(h=>h.visible);if(o.length<=1)return;const s=-(i-5),c=r-5-s,l=o.map(h=>({target:h.ly-s,size:e,rank:h.rank,pos:0,removed:!1,label:h}));this.distributeBoxes(l,c,c,c/4);for(const h of l)h.removed?h.label.visible=!1:h.label.ly=s+h.pos+e/2}distributeBoxes(t,e,i,r){const o=t.filter(l=>!l.removed);if(o.length===0)return;let s=o.reduce((l,h)=>l+h.size,0);if(s>e){const l=[...o].sort((f,u)=>f.rank-u.rank);let h=0;for(;s>e&&h<l.length;)l[h].removed=!0,s-=l[h].size,h++}const a=o.filter(l=>!l.removed);if(a.length===0)return;a.sort((l,h)=>l.target-h.target);for(let l=0;l<a.length;l++)if(a[l].pos=a[l].target,l>0){const h=a[l-1].pos+a[l-1].size;a[l].pos<h&&(a[l].pos=h)}for(let l=a.length-1;l>=0;l--){const h=l===a.length-1?e-a[l].size:a[l+1].pos-a[l].size;a[l].pos>h&&(a[l].pos=Math.max(0,h))}for(let l=0;l<5;l++)for(let h=0;h<a.length;h++){const f=a[h].pos+(a[h].target-a[h].pos)*.3,u=h>0?a[h-1].pos+a[h-1].size:0,d=h<a.length-1?a[h+1].pos-a[h].size:e-a[h].size;a[h].pos=Math.max(u,Math.min(d,f))}if(a.some(l=>Math.abs(l.pos-l.target)>r)){const l=e*.9;if(l>=i*.1){const h=[...a].sort((f,u)=>f.rank-u.rank);h[0].removed=!0,this.distributeBoxes(t,l,i,l/4)}}}resolvePercent(t,e){return typeof t=="string"&&t.endsWith("%")?parseFloat(t)/100*e:typeof t=="number"?t:parseFloat(t)||e/2}normalizeChordWidths(t){const e=t.groups;if(e.length===0)return;let i=0;for(const r of e){const o=r.endAngle-r.startAngle;o>0&&r.value>0&&(i=Math.max(i,r.value/o))}if(i!==0)for(const r of e){const o=[];for(const f of t)f.source.index===r.index&&o.push({ref:f.source,value:f.source.value}),f.target.index===r.index&&o.push({ref:f.target,value:f.target.value});if(o.length===0)continue;o.sort((f,u)=>f.ref.startAngle-u.ref.startAngle);const s=r.endAngle-r.startAngle,a=o.reduce((f,u)=>f+u.value/i,0),l=Math.max(0,s-a)/(o.length+1);let h=r.startAngle+l;for(const f of o){const u=f.value/i;f.ref.startAngle=h,f.ref.endAngle=h+u,h+=u+l}}}sortChordEndpoints(t){const e=t.groups,i=2*Math.PI;for(const r of e){const o=[],s=d=>d.side==="source"?d.chord.source:d.chord.target;for(const d of t){if(d.source.index===r.index){const p=e[d.target.index];o.push({chord:d,side:"source",partnerMid:(p.startAngle+p.endAngle)/2,width:d.source.endAngle-d.source.startAngle})}if(d.target.index===r.index){const p=e[d.source.index];o.push({chord:d,side:"target",partnerMid:(p.startAngle+p.endAngle)/2,width:d.target.endAngle-d.target.startAngle})}}if(o.length<=1)continue;const a=r.endAngle-r.startAngle,c=o.reduce((d,p)=>d+p.width,0),h=Math.max(0,a-c)/(o.length+1),f=r.endAngle;o.sort((d,p)=>{const y=((d.partnerMid-f)%i+i)%i;return((p.partnerMid-f)%i+i)%i-y});let u=r.startAngle+h;for(const d of o){const p=s(d);p.startAngle=u,p.endAngle=u+d.width,u+=d.width+h}}}buildMatrix(){const t=this.config.nodes||[],e=new Map;for(const c of t)c.color&&e.set(c.id,c.color);const i=new Set;for(const c of this.data)c.from&&i.add(c.from),c.to&&i.add(c.to);const r=Array.from(i),o=new Map(r.map((c,l)=>[c,l])),s=Array.from({length:r.length},()=>new Array(r.length).fill(0));for(const c of this.data){const l=o.get(c.from),h=o.get(c.to);if(l!==void 0&&h!==void 0){const f=c.y??c.weight??1;s[l][h]+=f,s[h][l]+=f}}const a=r.map(c=>e.get(c));return{matrix:s,names:r,nodeColors:a}}getDataExtents(){return{xMin:0,xMax:0,yMin:0,yMax:0}}}function Up(){St.registerType("sankey",wA),St.registerType("networkgraph",QA),St.registerType("dependencywheel",r5)}class qr{static group(t,e,i="average",r,o){if(!t.length||e<=0)return t;const s=[...t].sort((f,u)=>(f.x??0)-(u.x??0)),a=!(r!=null&&r.groupAll)&&o?s.filter(f=>{const u=f.x??0;return u>=o.min&&u<=o.max}):s,c=new Map;for(const f of a){const u=f.x??0,d=Math.floor(u/e)*e;c.has(d)||c.set(d,[]),c.get(d).push(f)}const l=(r==null?void 0:r.anchor)??"start",h=[];for(const[f,u]of c){const d=qr.applyAnchor(f,e,l),p=qr.approximate(d,u,i);h.push(p)}return r!=null&&r.smoothed&&h.length>=3?qr.smooth(h):h}static applyAnchor(t,e,i){switch(i){case"middle":return t+e/2;case"end":return t+e;default:return t}}static smooth(t){const e=[t[0]];for(let i=1;i<t.length-1;i++){const r=t[i-1].y??0,o=t[i].y??0,s=t[i+1].y??0;e.push({...t[i],y:(r+o+s)/3})}return e.push(t[t.length-1]),e}static approximate(t,e,i){const r=e.map(o=>o.y??0);switch(i){case"sum":return{x:t,y:r.reduce((o,s)=>o+s,0)};case"open":return{x:t,y:r[0]};case"high":return{x:t,y:Math.max(...r)};case"low":return{x:t,y:Math.min(...r)};case"close":return{x:t,y:r[r.length-1]};case"range":return{x:t,y:Math.max(...r)-Math.min(...r)};case"ohlc":return{x:t,y:r[r.length-1],open:r[0],high:Math.max(...r),low:Math.min(...r),close:r[r.length-1]};case"average":default:return{x:t,y:r.reduce((o,s)=>o+s,0)/r.length}}}}class o5{constructor(t){this.head=0,this._size=0,this.capacity=t,this.buffer=new Array(t)}push(t){const e=this._size===this.capacity?this.buffer[this.head]:void 0,i=(this.head+this._size)%this.capacity;return this.buffer[i]=t,this._size<this.capacity?this._size++:this.head=(this.head+1)%this.capacity,e}pushMany(t){const e=[];for(const i of t){const r=this.push(i);r!==void 0&&e.push(r)}return e}get size(){return this._size}get isFull(){return this._size===this.capacity}get(t){if(!(t<0||t>=this._size))return this.buffer[(this.head+t)%this.capacity]}toArray(){const t=new Array(this._size);for(let e=0;e<this._size;e++)t[e]=this.buffer[(this.head+e)%this.capacity];return t}clear(){this.head=0,this._size=0}}class jp{constructor(){this.entries=[]}add(t,e){if(t==="setData"){this.entries=[{type:t,payload:e}];return}this.entries.push({type:t,payload:e})}get isEmpty(){return this.entries.length===0}}class s5{constructor(t,e){this.pendingUpdates=new Map,this.rafId=null,this.lastFrameTime=0,this.maxFps=t.maxFps??30,this.flushCallback=e}schedule(t,e,i){let r=this.pendingUpdates.get(t);r||(r=new jp,this.pendingUpdates.set(t,r)),r.add(e,i),this.requestFrame()}requestFrame(){this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;const t=performance.now(),e=1e3/this.maxFps;if(t-this.lastFrameTime<e){this.rafId=requestAnimationFrame(()=>{this.rafId=null,this.lastFrameTime=performance.now(),this.flush()});return}this.lastFrameTime=t,this.flush()}))}flush(){if(this.pendingUpdates.size!==0){for(const[t,e]of this.pendingUpdates)e.isEmpty||t.applyBatch(e);this.pendingUpdates.clear(),this.flushCallback()}}destroy(){this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingUpdates.clear()}get hasPending(){return this.pendingUpdates.size>0}}class a5{static fromWebSocket(t,e,i,r){const o=(r==null?void 0:r.shift)??!1,s=a=>{let c;try{c=JSON.parse(a.data)}catch{return}const l=i(c);if(Array.isArray(l))if(e.addPoints)e.addPoints(l,!0,o);else{for(const h of l)e.addPoint(h,!1,o);e.addPoint(l[l.length-1],!0,o)}else e.addPoint(l,!0,o)};return t.addEventListener("message",s),{unsubscribe:()=>t.removeEventListener("message",s)}}static fromEventSource(t,e,i,r,o){const s=(o==null?void 0:o.shift)??!1,a=c=>{const l=r(c.data);e.addPoint(l,!0,s)};return t.addEventListener(i,a),{unsubscribe:()=>t.removeEventListener(i,a)}}static fromPolling(t,e,i,r){const o=(r==null?void 0:r.shift)??!1;let s=!0;const a=async()=>{if(s){try{const c=await t();if(!s)return;if(Array.isArray(c))if(e.addPoints)e.addPoints(c,!0,o);else for(const l of c)e.addPoint(l,!0,o);else e.addPoint(c,!0,o)}catch{}s&&setTimeout(a,i)}};return setTimeout(a,i),{unsubscribe:()=>{s=!1}}}}cd(),Tp(),Lp(),Up();const _l={chart(n,t){return new bs(n,t)},setOptions(n){ka(n)},getOptions(){return zh()},dateFormat:ac,numberFormat:es,templateFormat:Zt,stripHtmlTags:re,color(n){return cr(n)},palettes:uo,getPalette(n){return Bl(n)},themes:fo,themeNames:mg,getTheme(n){return Wl(n)},setTheme(n){const t=fo[n];t&&ka(t)},use(n){Qh.register(n),n.init(_l)},setLicenseKey(n){return tn.setKey(n)},isLicensed(){return tn.isLicensed()},configureLicensing(n){tn.configure(n)},ChartRegistry:St},c5=Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"}));_t.A11yModule=_f,_t.BaseSeries=Ht,_t.Chart=bs,_t.ChartRegistry=St,_t.CircularBuffer=o5,_t.Crosshair=df,_t.DataGrouping=qr,_t.DataLabels=rs,_t.Drilldown=wf,_t.EventBus=Kh,_t.ExportButton=mf,_t.ExportModule=oe,_t.KatuCharts=_l,_t.Legend=ss,_t.LicenseManager=tn,_t.ModuleRegistry=Qh,_t.Navigator=qf,_t.OptionsParser=Jn,_t.RangeSelector=Zf,_t.ResponsiveEngine=yf,_t.SVGRenderer=_o,_t.StreamAdapter=a5,_t.Tooltip=os,_t.UpdateBatch=jp,_t.UpdateScheduler=s5,_t.Zoom=Sf,_t.default=_l,_t.getGlobalOptions=zh,_t.lttbDecimate=Fc,_t.minMaxDecimate=Z2,_t.registerCoreSeriesTypes=cd,_t.registerFinancialSeriesTypes=Lp,_t.registerFlowSeriesTypes=Up,_t.registerGeneralSeriesTypes=Tp,_t.setGlobalOptions=ka,Object.defineProperties(_t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});