UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 47.6 kB
/*! * ApexCharts v6.6.1 * (c) 2018-2026 ApexCharts */ "use strict";var t=Object.defineProperty,e=Object.defineProperties,i=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,o=(e,i,n)=>i in e?t(e,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[i]=n,l=(t,e)=>{for(var i in e||(e={}))s.call(e,i)&&o(t,i,e[i]);if(n)for(var i of n(e))a.call(e,i)&&o(t,i,e[i]);return t},r=(t,n)=>e(t,i(n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("apexcharts/core");function h(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const i in t)if("default"!==i){const n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:()=>t[i]})}return e.default=t,Object.freeze(e)}const d=h(c),g=d.__apex_Graphics,m=d.__apex_axes_AxesUtils,u=d.__apex_Data,p=d.__apex_Series,x=d.__apex_Utils,f=d.__apex_Environment_Environment,b=d.__apex_math_SVGNS;class w{constructor(t,e){this.w=t,this.ctx=e}svgStringToNode(t){return(new DOMParser).parseFromString(t,"image/svg+xml").documentElement}scaleSvgNode(t,e){const i=parseFloat(t.getAttributeNS(null,"width")),n=parseFloat(t.getAttributeNS(null,"height"));t.setAttributeNS(null,"width",i*e),t.setAttributeNS(null,"height",n*e),t.setAttributeNS(null,"viewBox","0 0 "+i+" "+n)}inlineCanvasLayers(t){const e=this.w.dom.elWrap.querySelectorAll(".apexcharts-series-canvas");if(!e.length)return;const i=t.querySelectorAll(".apexcharts-canvas-series");for(let t=0;t<e.length&&t<i.length;t++){let n;try{n=e[t].toDataURL()}catch(t){continue}const s=i[t],a=document.createElementNS(b,"image");a.setAttribute("x",s.getAttribute("x")||"0"),a.setAttribute("y",s.getAttribute("y")||"0"),a.setAttribute("width",s.getAttribute("width")||"0"),a.setAttribute("height",s.getAttribute("height")||"0"),a.setAttribute("href",n),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n),s.parentNode&&s.parentNode.replaceChild(a,s)}}getSvgString(t){return new Promise(e=>{const i=this.w;let n=t||i.config.chart.toolbar.export.scale||i.config.chart.toolbar.export.width/i.globals.svgWidth;n||(n=1);const s=i.globals.svgWidth*n,a=i.globals.svgHeight*n,o=i.dom.elWrap.cloneNode(!0);o.style.width=s+"px",o.style.height=a+"px",this.inlineCanvasLayers(o);const l=(new XMLSerializer).serializeToString(o);let r="\n .apexcharts-tooltip, .apexcharts-toolbar, .apexcharts-xaxistooltip, .apexcharts-yaxistooltip, .apexcharts-xcrosshairs, .apexcharts-ycrosshairs, .apexcharts-zoom-rect, .apexcharts-selection-rect {\n display: none;\n }\n ";i.config.legend.show&&i.dom.elLegendWrap&&i.dom.elLegendWrap.children.length>0&&(r+=".apexcharts-flip-y {\n transform: scaleY(-1) translateY(-100%);\n transform-origin: top;\n transform-box: fill-box;\n}\n.apexcharts-flip-x {\n transform: scaleX(-1);\n transform-origin: center;\n transform-box: fill-box;\n}\n.apexcharts-legend {\n display: flex;\n overflow: auto;\n padding: 0 10px;\n}\n.apexcharts-legend.apexcharts-legend-group-horizontal {\n flex-direction: column;\n}\n.apexcharts-legend-group {\n display: flex;\n}\n.apexcharts-legend-group-vertical {\n flex-direction: column-reverse;\n}\n.apexcharts-legend.apx-legend-position-bottom, .apexcharts-legend.apx-legend-position-top {\n flex-wrap: wrap\n}\n.apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\n flex-direction: column;\n bottom: 0;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-left, .apexcharts-legend.apx-legend-position-top.apexcharts-align-left, .apexcharts-legend.apx-legend-position-right, .apexcharts-legend.apx-legend-position-left {\n justify-content: flex-start;\n align-items: flex-start;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-center, .apexcharts-legend.apx-legend-position-top.apexcharts-align-center {\n justify-content: center;\n align-items: center;\n}\n.apexcharts-legend.apx-legend-position-bottom.apexcharts-align-right, .apexcharts-legend.apx-legend-position-top.apexcharts-align-right {\n justify-content: flex-end;\n align-items: flex-end;\n}\n.apexcharts-legend-series {\n cursor: pointer;\n line-height: normal;\n display: flex;\n align-items: center;\n}\n.apexcharts-legend-text {\n position: relative;\n font-size: 14px;\n}\n.apexcharts-legend-text *, .apexcharts-legend-marker * {\n pointer-events: none;\n}\n.apexcharts-legend-marker {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n margin-right: 1px;\n}\n\n.apexcharts-legend-series.apexcharts-no-click {\n cursor: auto;\n}\n.apexcharts-legend .apexcharts-hidden-zero-series, .apexcharts-legend .apexcharts-hidden-null-series {\n display: none !important;\n}\n.apexcharts-inactive-legend {\n opacity: 0.45;\n} ");let c=`\n <svg xmlns="http://www.w3.org/2000/svg"\n version="1.1"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n class="apexcharts-svg"\n xmlns:data="ApexChartsNS"\n transform="translate(0, 0)"\n width="${i.globals.svgWidth}px" height="${i.globals.svgHeight}px">\n <foreignObject width="100%" height="100%">\n <div xmlns="http://www.w3.org/1999/xhtml" style="width:${s}px; height:${a}px;">\n <style type="text/css">\n ${r}\n </style>\n ${l}\n </div>\n </foreignObject>\n </svg>\n `;const h=this.svgStringToNode(c);1!==n&&this.scaleSvgNode(h,n),this.convertImagesToBase64(h).then(()=>{c=(new XMLSerializer).serializeToString(h),e(c.replace(/&nbsp;/g,"&#160;"))})})}convertImagesToBase64(t){const e=t.getElementsByTagName("image"),i=Array.from(e).map(t=>{const e=t.getAttributeNS("http://www.w3.org/1999/xlink","href");return e&&!e.startsWith("data:")?this.getBase64FromUrl(e).then(e=>{t.setAttributeNS("http://www.w3.org/1999/xlink","href",e)}).catch(t=>{}):Promise.resolve()});return Promise.all(i)}getBase64FromUrl(t){return f.isSSR()?Promise.resolve(t):new Promise((e,i)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>{const t=document.createElement("canvas");t.width=n.width,t.height=n.height;const i=t.getContext("2d");i&&i.drawImage(n,0,0),e(t.toDataURL())},n.onerror=i,n.src=t})}svgUrl(){return new Promise(t=>{this.getSvgString().then(e=>{const i=new Blob([e],{type:"image/svg+xml;charset=utf-8"});t(URL.createObjectURL(i))})})}dataURI(t){return f.isSSR()?Promise.resolve({imgURI:""}):new Promise(e=>{const i=this.w,n=t?t.scale||t.width/i.globals.svgWidth:1,s=document.createElement("canvas");s.width=i.globals.svgWidth*n,s.height=parseInt(i.dom.elWrap.style.height,10)*n;const a="transparent"!==i.config.chart.background&&i.config.chart.background?i.config.chart.background:"#fff",o=s.getContext("2d");o&&(o.fillStyle=a,o.fillRect(0,0,s.width*n,s.height*n),this.getSvgString(n).then(t=>{const i="data:image/svg+xml,"+encodeURIComponent(t),n=new Image;n.crossOrigin="anonymous",n.onload=()=>{o.drawImage(n,0,0);const t=s;if(t.msToBlob){const i=t.msToBlob();e({blob:i})}else{const t=s.toDataURL("image/png");e({imgURI:t})}},n.src=i}))})}exportToSVG(){this.svgUrl().then(t=>{this.triggerDownload(t,this.w.config.chart.toolbar.export.svg.filename,".svg")})}exportToPng(){const t=this.w.config.chart.toolbar.export.scale,e=this.w.config.chart.toolbar.export.width,i=t?{scale:t}:e?{width:e}:void 0;this.dataURI(i).then(({imgURI:t,blob:e})=>{e?navigator.msSaveOrOpenBlob(e,this.w.globals.chartID+".png"):this.triggerDownload(t,this.w.config.chart.toolbar.export.png.filename,".png")})}exportToCSV({series:t,fileName:e,columnDelimiter:i=",",lineDelimiter:n="\n"}){const s=this.w;t||(t=s.config.series);let a=[];const o=[];let l="";const r=s.seriesData.series.map((t,e)=>-1===s.globals.collapsedSeriesIndices.indexOf(e)?t:[]),c=t=>"function"==typeof s.config.chart.toolbar.export.csv.categoryFormatter?s.config.chart.toolbar.export.csv.categoryFormatter(t):"datetime"===s.config.xaxis.type&&String(t).length>=10?new Date(t).toDateString():x.isNumber(t)?t:t.split(i).join(""),h=t=>"function"==typeof s.config.chart.toolbar.export.csv.valueFormatter?s.config.chart.toolbar.export.csv.valueFormatter(t):t,d=Math.max(...t.map(t=>t.data?t.data.length:0)),g=new u(this.w),f=new m(this.w,{theme:this.ctx.theme,timeScale:this.ctx.timeScale}),b=t=>{let e="";if(s.globals.axisCharts){if("category"===s.config.xaxis.type||s.config.xaxis.convertedCatToNumeric)if(s.globals.isBarHorizontal){const i=s.formatters.yLabelFormatters[0],n=new p(this.ctx.w).getActiveConfigSeriesIndex();e=i(s.labelData.labels[t],{seriesIndex:n,dataPointIndex:t,w:s})}else e=f.getLabel(s.labelData.labels,s.labelData.timescaleLabels,0,t).text;"datetime"===s.config.xaxis.type&&(s.config.xaxis.categories.length?e=s.config.xaxis.categories[t]:s.config.labels.length&&(e=s.config.labels[t]))}else e=s.config.labels[t];return null===e?"nullvalue":(Array.isArray(e)&&(e=e.join(" ")),x.isNumber(e)?e:e.split(i).join(""))},w=(e,n)=>{var l,m,u,p,x,f;if(a.length&&0===n&&o.push(a.join(i)),e.data){e.data=e.data.length&&e.data||[...Array(d)].map(()=>"");for(let d=0;d<e.data.length;d++){a=[];let w=b(d);if("nullvalue"!==w){if(w||(g.isFormatXY()?w=t[n].data[d].x:g.isFormat2DArray()&&(w=t[n].data[d]?t[n].data[d][0]:"")),0===n){a.push(c(w));for(let e=0;e<s.seriesData.series.length;e++){const i=g.isFormatXY()?null==(l=t[e].data[d])?void 0:l.y:r[e][d];a.push(h(i))}}("candlestick"===s.config.chart.type||e.type&&"candlestick"===e.type)&&(a.pop(),a.push(s.candleData.seriesCandleO[n][d]),a.push(s.candleData.seriesCandleH[n][d]),a.push(s.candleData.seriesCandleL[n][d]),a.push(s.candleData.seriesCandleC[n][d])),("boxPlot"===s.config.chart.type||e.type&&"boxPlot"===e.type)&&(a.pop(),a.push(s.candleData.seriesCandleO[n][d]),a.push(s.candleData.seriesCandleH[n][d]),a.push(s.candleData.seriesCandleM[n][d]),a.push(s.candleData.seriesCandleL[n][d]),a.push(s.candleData.seriesCandleC[n][d])),"rangeBar"===s.config.chart.type&&(a.pop(),a.push(s.rangeData.seriesRangeStart[n][d]),a.push(s.rangeData.seriesRangeEnd[n][d])),("violin"===s.config.chart.type||e.type&&"violin"===e.type)&&(a.pop(),a.push(null==(m=s.violinData.seriesViolinMin[n])?void 0:m[d]),a.push(null==(u=s.violinData.seriesViolinMax[n])?void 0:u[d]),a.push(null!=(f=null==(x=null==(p=s.violinData.seriesViolinPoints[n])?void 0:p[d])?void 0:x.length)?f:0)),a.length&&o.push(a.join(i))}}}};a.push(s.config.chart.toolbar.export.csv.headerCategory),"boxPlot"===s.config.chart.type?(a.push("minimum"),a.push("q1"),a.push("median"),a.push("q3"),a.push("maximum")):"candlestick"===s.config.chart.type?(a.push("open"),a.push("high"),a.push("low"),a.push("close")):"rangeBar"===s.config.chart.type?(a.push("minimum"),a.push("maximum")):"violin"===s.config.chart.type?(a.push("minimum"),a.push("maximum"),a.push("observations")):t.map((t,e)=>{const n=(t.name?t.name:`series-${e}`)+"";s.globals.axisCharts&&a.push(n.split(i).join("")?n.split(i).join(""):`series-${e}`)}),s.globals.axisCharts||(a.push(s.config.chart.toolbar.export.csv.headerValue),o.push(a.join(i))),s.globals.allSeriesHasEqualX||!s.globals.axisCharts||s.config.xaxis.categories.length||s.config.labels.length?t.map((t,e)=>{s.globals.axisCharts?w(t,e):(a=[],a.push(c(s.labelData.labels[e])),a.push(h(r[e])),o.push(a.join(i)))}):(()=>{const e=new Set,n={};t.forEach((i,s)=>{null==i||i.data.forEach(i=>{let a,o;if(g.isFormatXY())a=i.x,o=i.y;else{if(!g.isFormat2DArray())return;a=i[0],o=i[1]}n[a]||(n[a]=Array(t.length).fill("")),n[a][s]=h(o),e.add(a)})}),a.length&&o.push(a.join(i)),Array.from(e).sort().forEach(t=>{o.push([c(t),n[t].join(i)])})})(),l+=o.join(n),this.triggerDownload("data:text/csv; charset=utf-8,"+encodeURIComponent("\ufeff"+l),e||s.config.chart.toolbar.export.csv.filename,".csv")}triggerDownload(t,e,i){if(f.isSSR())return;const n=document.createElement("a");n.href=t,n.download=(e||this.w.globals.chartID)+i,document.body.appendChild(n),n.click(),document.body.removeChild(n)}}const y=d.__apex_BrowserAPIs_BrowserAPIs;class v{constructor(t,e){this.w=t,this.ctx=e,this.ev=this.w.config.chart.events,this.selectedClass="apexcharts-selected",this.localeValues=this.w.globals.locale.toolbar,this.minX=t.globals.minX,this.maxX=t.globals.maxX,this.elZoom=null,this.elZoomIn=null,this.elZoomOut=null,this.elPan=null,this.elSelection=null,this.elMeasure=null,this.elZoomReset=null,this.elMenuIcon=null,this.elMenu=null,this.elMenuItems=[],this.t=null}createToolbar(){var t,e;const i=this.w,n=()=>y.createElementNS("http://www.w3.org/1999/xhtml","div"),s=()=>{const t=y.createElementNS("http://www.w3.org/1999/xhtml","button");return t.setAttribute("type","button"),t},a=n();if(a.setAttribute("class","apexcharts-toolbar"),a.style.top=i.config.chart.toolbar.offsetY+"px",a.style.right=3-i.config.chart.toolbar.offsetX+"px",i.dom.elWrap.appendChild(a),this.elZoom=s(),this.elZoomIn=s(),this.elZoomOut=s(),this.elPan=s(),this.elSelection=s(),this.elMeasure=s(),this.elZoomReset=s(),this.elMenuIcon=s(),this.elMenu=n(),this.elCustomIcons=[],this.t=i.config.chart.toolbar.tools,Array.isArray(this.t.customIcons))for(let t=0;t<this.t.customIcons.length;t++)this.elCustomIcons.push(s());const o=[],l=(t,e,n)=>{const s=t.toLowerCase();this.t[s]&&i.config.chart.zoom.enabled&&o.push({el:e,icon:"string"==typeof this.t[s]?this.t[s]:n,title:this.localeValues[t],class:`apexcharts-${s}-icon`})};l("zoomIn",this.elZoomIn,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M12 5v14M5 12h14"/>\n</svg>\n'),l("zoomOut",this.elZoomOut,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M5 12h14"/>\n</svg>\n');const r=t=>{this.t[t]&&i.config.chart[t].enabled&&o.push({el:"zoom"===t?this.elZoom:this.elSelection,icon:"string"==typeof this.t[t]?this.t[t]:"zoom"===t?'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <circle cx="11" cy="11" r="7"/>\n <path d="m21 21-4.3-4.3M8 11h6M11 8v6"/>\n</svg>\n':'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M5 3a2 2 0 0 0-2 2"/>\n <path d="M19 3a2 2 0 0 1 2 2"/>\n <path d="M21 19a2 2 0 0 1-2 2"/>\n <path d="M5 21a2 2 0 0 1-2-2"/>\n <path d="M9 3h1M14 3h1M9 21h1M14 21h1M3 9v1M3 14v1M21 9v1M21 14v1"/>\n</svg>\n',title:this.localeValues["zoom"===t?"selectionZoom":"selection"],class:`apexcharts-${t}-icon`})};r("zoom"),r("selection"),this.t.pan&&i.config.chart.zoom.enabled&&o.push({el:this.elPan,icon:"string"==typeof this.t.pan?this.t.pan:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M5 9 2 12l3 3"/>\n <path d="M9 5l3-3 3 3"/>\n <path d="M15 19l-3 3-3-3"/>\n <path d="M19 9l3 3-3 3"/>\n <path d="M2 12h20"/>\n <path d="M12 2v20"/>\n</svg>\n',title:this.localeValues.pan,class:"apexcharts-pan-icon"}),this.t.measure&&i.config.chart.measure&&i.config.chart.measure.enabled&&o.push({el:this.elMeasure,icon:"string"==typeof this.t.measure?this.t.measure:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.4 2.4 0 0 1 0-3.4l2.6-2.6a2.4 2.4 0 0 1 3.4 0Z"/>\n <path d="m14.5 12.5 2-2"/>\n <path d="m11.5 9.5 2-2"/>\n <path d="m8.5 6.5 2-2"/>\n <path d="m17.5 15.5 2-2"/>\n</svg>\n',title:this.localeValues.measure||"Measure",class:"apexcharts-measure-icon"}),l("reset",this.elZoomReset,'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/>\n <path d="M3 3v5h5"/>\n</svg>\n'),this.t.download&&o.push({el:this.elMenuIcon,icon:"string"==typeof this.t.download?this.t.download:'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <path d="M4 6h16M4 12h16M4 18h16"/>\n</svg>\n',title:this.localeValues.menu,class:"apexcharts-menu-icon"});for(let t=0;t<this.elCustomIcons.length;t++)o.push({el:this.elCustomIcons[t],icon:this.t.customIcons[t].icon,title:this.t.customIcons[t].title,index:this.t.customIcons[t].index,class:"apexcharts-toolbar-custom-icon "+this.t.customIcons[t].class});o.forEach((t,e)=>{t.index&&x.moveIndexInArray(o,e,t.index)});for(let t=0;t<o.length;t++)g.setAttrs(o[t].el,{class:o[t].class,title:o[t].title,"aria-label":o[t].title}),o[t].el.innerHTML=o[t].icon,a.appendChild(o[t].el);this.elZoom.parentNode&&this.elZoom.setAttribute("aria-pressed",String(!!i.interact.zoomEnabled)),this.elSelection.parentNode&&this.elSelection.setAttribute("aria-pressed",String(!!i.interact.selectionEnabled)),this.elPan.parentNode&&this.elPan.setAttribute("aria-pressed",String(!!i.interact.panEnabled)),this.elMeasure.parentNode&&this.elMeasure.setAttribute("aria-pressed",String(!!i.interact.measureEnabled)),this.elMenuIcon.parentNode&&(this.elMenuIcon.setAttribute("aria-haspopup","true"),this.elMenuIcon.setAttribute("aria-expanded","false")),this._createHamburgerMenu(a),i.interact.zoomEnabled?this.elZoom.classList.add(this.selectedClass):i.interact.panEnabled?this.elPan.classList.add(this.selectedClass):i.interact.selectionEnabled?this.elSelection.classList.add(this.selectedClass):i.interact.measureEnabled&&this.elMeasure&&(this.elMeasure.classList.add(this.selectedClass),null==(e=null==(t=this.ctx.measure)?void 0:t.startMeasure)||e.call(t)),this.addToolbarEventListeners()}_createHamburgerMenu(t){this.elMenuItems=[],t.appendChild(this.elMenu),g.setAttrs(this.elMenu,{class:"apexcharts-menu",role:"menu"});const e=[{name:"exportSVG",title:this.localeValues.exportToSVG},{name:"exportPNG",title:this.localeValues.exportToPNG},{name:"exportCSV",title:this.localeValues.exportToCSV}];for(let t=0;t<e.length;t++)this.elMenuItems.push(y.createElementNS("http://www.w3.org/1999/xhtml","div")),this.elMenuItems[t].innerHTML=e[t].title,g.setAttrs(this.elMenuItems[t],{class:`apexcharts-menu-item ${e[t].name}`,title:e[t].title,role:"menuitem",tabindex:"-1"}),this.elMenu.appendChild(this.elMenuItems[t])}addToolbarEventListeners(){var t,e,i,n,s,a,o,l,r;null==(t=this.elZoomReset)||t.addEventListener("click",this.handleZoomReset.bind(this)),null==(e=this.elSelection)||e.addEventListener("click",this.toggleZoomSelection.bind(this,"selection")),null==(i=this.elZoom)||i.addEventListener("click",this.toggleZoomSelection.bind(this,"zoom")),null==(n=this.elZoomIn)||n.addEventListener("click",this.handleZoomIn.bind(this)),null==(s=this.elZoomOut)||s.addEventListener("click",this.handleZoomOut.bind(this)),null==(a=this.elPan)||a.addEventListener("click",this.togglePanning.bind(this)),null==(o=this.elMeasure)||o.addEventListener("click",this.toggleMeasure.bind(this)),null==(l=this.elMenuIcon)||l.addEventListener("click",this.toggleMenu.bind(this)),this.elMenuItems.forEach(t=>{t.classList.contains("exportSVG")?t.addEventListener("click",this.handleDownload.bind(this,"svg")):t.classList.contains("exportPNG")?t.addEventListener("click",this.handleDownload.bind(this,"png")):t.classList.contains("exportCSV")&&t.addEventListener("click",this.handleDownload.bind(this,"csv"))});for(let t=0;t<this.t.customIcons.length;t++)this.elCustomIcons[t].addEventListener("click",this.t.customIcons[t].click.bind(this,this.ctx,this.ctx.w));[this.elZoomReset,this.elSelection,this.elZoom,this.elZoomIn,this.elZoomOut,this.elPan,this.elMeasure,this.elMenuIcon,...this.elCustomIcons].forEach(t=>{t.addEventListener("keydown",e=>{if("Enter"===e.key||" "===e.key){e.preventDefault();const i=t.className;t.click(),requestAnimationFrame(()=>{const t=this.w.dom.baseEl;if(!t)return;const e=i.split(" ").find(t=>t.startsWith("apexcharts-"));if(!e)return;const n=t.querySelector(`.${e}`);n&&n.focus()})}})}),null==(r=this.elMenuIcon)||r.addEventListener("keydown",t=>{var e;"ArrowDown"!==t.key&&"ArrowUp"!==t.key||(t.preventDefault(),(null==(e=this.elMenu)?void 0:e.classList.contains("apexcharts-menu-open"))||this.toggleMenu(),window.setTimeout(()=>{const e="ArrowDown"===t.key?0:this.elMenuItems.length-1;this.elMenuItems[e]&&this.elMenuItems[e].focus()},20))}),this.elMenuItems.forEach((t,e)=>{t.addEventListener("keydown",i=>{var n;if("ArrowDown"===i.key){i.preventDefault();(this.elMenuItems[e+1]||this.elMenuItems[0]).focus()}else if("ArrowUp"===i.key){i.preventDefault();(this.elMenuItems[e-1]||this.elMenuItems[this.elMenuItems.length-1]).focus()}else"Escape"===i.key||"Tab"===i.key?(this._closeMenu(),null==(n=this.elMenuIcon)||n.focus(),"Tab"===i.key||i.preventDefault()):"Enter"!==i.key&&" "!==i.key||(i.preventDefault(),t.click())})})}toggleZoomSelection(t){this.ctx.getSyncedCharts().forEach(e=>{const i=e.ctx.toolbar,n="selection"===t?"selectionEnabled":"zoomEnabled",s=!!e.w.globals[n];i.toggleOtherControls();const a="selection"===t?i.elSelection:i.elZoom;s||(e.w.globals[n]=!0,a.classList.add(i.selectedClass)),a.setAttribute("aria-pressed",String(!!e.w.globals[n]))})}toggleMeasure(){var t,e,i,n;const s=this.w,a=!s.interact.measureEnabled;this.toggleOtherControls(),a&&(s.interact.measureEnabled=!0,null==(t=this.elMeasure)||t.classList.add(this.selectedClass),null==(i=null==(e=this.ctx.measure)?void 0:e.startMeasure)||i.call(e)),null==(n=this.elMeasure)||n.setAttribute("aria-pressed",String(s.interact.measureEnabled))}getToolbarIconsReference(){const t=this.w;this.elZoom||(this.elZoom=t.dom.baseEl.querySelector(".apexcharts-zoom-icon")),this.elPan||(this.elPan=t.dom.baseEl.querySelector(".apexcharts-pan-icon")),this.elSelection||(this.elSelection=t.dom.baseEl.querySelector(".apexcharts-selection-icon")),this.elMeasure||(this.elMeasure=t.dom.baseEl.querySelector(".apexcharts-measure-icon"))}enableZoomPanFromToolbar(t){this.toggleOtherControls(),"pan"===t?this.w.interact.panEnabled=!0:this.w.interact.zoomEnabled=!0;const e="pan"===t?this.elPan:this.elZoom,i="pan"===t?this.elZoom:this.elPan;e&&e.classList.add(this.selectedClass),i&&i.classList.remove(this.selectedClass)}togglePanning(){this.ctx.getSyncedCharts().forEach(t=>{const e=t.ctx.toolbar,i=!!t.w.interact.panEnabled;e.toggleOtherControls(),i||(t.w.interact.panEnabled=!0,e.elPan.classList.add(e.selectedClass)),e.elPan.setAttribute("aria-pressed",String(!!t.w.interact.panEnabled))})}toggleOtherControls(){var t,e,i;const n=this.w;n.interact.panEnabled=!1,n.interact.zoomEnabled=!1,n.interact.selectionEnabled=!1,n.interact.measureEnabled&&(n.interact.measureEnabled=!1,null==(e=null==(t=this.ctx.measure)?void 0:t.stopMeasure)||e.call(t),null==(i=this.elMeasure)||i.setAttribute("aria-pressed","false")),this.getToolbarIconsReference();[this.elPan,this.elSelection,this.elZoom,this.elMeasure].forEach(t=>{t&&t.classList.remove(this.selectedClass)})}_currentXRange(){const t=this.w;return t.axisFlags.isRangeBar?{minX:t.globals.minY,maxX:t.globals.maxY}:{minX:t.globals.minX,maxX:t.globals.maxX}}handleZoomIn(){const t=this.w,{minX:e,maxX:i}=this._currentXRange();this.minX=e,this.maxX=i;const n=(e+i)/2,s=(e+n)/2,a=(i+n)/2,o=this._getNewMinXMaxX(s,a);t.interact.disableZoomIn||this.zoomUpdateOptions(o.minX,o.maxX)}handleZoomOut(){const t=this.w,{minX:e,maxX:i}=this._currentXRange();if(this.minX=e,this.maxX=i,"datetime"===t.config.xaxis.type&&new Date(e).getUTCFullYear()<1e3)return;const n=(e+i)/2,s=e-(n-e),a=i-(n-i),o=this._getNewMinXMaxX(s,a);t.interact.disableZoomOut||this.zoomUpdateOptions(o.minX,o.maxX)}_getNewMinXMaxX(t,e){const i=this.w.config.xaxis.convertedCatToNumeric;return{minX:i?Math.floor(t):t,maxX:i?Math.floor(e):e}}zoomUpdateOptions(t,e){const i=this.w;if(void 0===t&&void 0===e)return void this.handleZoomReset();if(i.config.xaxis.convertedCatToNumeric&&(t<1&&(t=1,e=i.globals.dataPoints),e-t<2))return;let n={min:t,max:e};const s=this.getBeforeZoomRange(n,void 0);s&&(n=s.xaxis);const a={xaxis:n};if(!i.globals.initialConfig)return;const o=x.clone(i.globals.initialConfig.yaxis);i.config.chart.group||(a.yaxis=o),this.w.interact.zoomed=!0,this.ctx.updateHelpers._updateOptions(a,!1,this.w.config.chart.animations.dynamicAnimation.enabled),this.zoomCallback(n,o)}zoomCallback(t,e){"function"==typeof this.ev.zoomed&&(this.ev.zoomed(this.ctx,{xaxis:t,yaxis:e}),this.ctx.events.fireEvent("zoomed",{xaxis:t,yaxis:e}))}getBeforeZoomRange(t,e){let i=null;return"function"==typeof this.ev.beforeZoom&&(i=this.ev.beforeZoom(this,{xaxis:t,yaxis:e})),i}toggleMenu(){window.setTimeout(()=>{var t,e,i;(null==(t=this.elMenu)?void 0:t.classList.contains("apexcharts-menu-open"))?this._closeMenu():(null==(e=this.elMenu)||e.classList.add("apexcharts-menu-open"),null==(i=this.elMenuIcon)||i.setAttribute("aria-expanded","true"))},0)}_closeMenu(){var t,e;null==(t=this.elMenu)||t.classList.remove("apexcharts-menu-open"),null==(e=this.elMenuIcon)||e.setAttribute("aria-expanded","false")}handleDownload(t){const e=this.w,i=new w(this.w,this.ctx);switch(t){case"svg":i.exportToSVG();break;case"png":i.exportToPng();break;case"csv":i.exportToCSV({series:e.config.series,columnDelimiter:e.config.chart.toolbar.export.csv.columnDelimiter})}}handleZoomReset(){this.ctx.getSyncedCharts().forEach(t=>{const e=t.w;if(!e.interact.zoomed)return;if(e.globals.lastXAxis.min=e.globals.initialConfig.xaxis.min,e.globals.lastXAxis.max=e.globals.initialConfig.xaxis.max,t.updateHelpers.revertDefaultAxisMinMax(),"function"==typeof e.config.chart.events.beforeResetZoom){const i=e.config.chart.events.beforeResetZoom(t,e);i&&t.updateHelpers.revertDefaultAxisMinMax(i)}"function"==typeof e.config.chart.events.zoomed&&t.ctx.toolbar.zoomCallback({min:e.config.xaxis.min,max:e.config.xaxis.max});const i=t.ctx.series.emptyCollapsedSeries(x.clone(e.globals.initialSeries));t.updateHelpers._updateSeries(i,e.config.chart.animations.dynamicAnimation.enabled),e.interact.zoomed=!1})}destroy(){this.elZoom=null,this.elZoomIn=null,this.elZoomOut=null,this.elPan=null,this.elSelection=null,this.elMeasure=null,this.elZoomReset=null,this.elMenuIcon=null}}class M{static xRatio(t){const e=t.layout.gridWidth||1;return(t.globals.maxX-t.globals.minX)/e}static dataXToPx(t,e){return(e-t.globals.minX)/M.xRatio(t)}static pxToDataX(t,e){return t.globals.minX+e*M.xRatio(t)}}const R=d.__apex_index_Box;c.registerFeatures({toolbar:v,zoomPanSelection:class extends v{constructor(t,e){super(t,e),this.w=t,this.ctx=e,this.dragged=!1,this.graphics=new g(this.w),this.eventList=["mousedown","mouseleave","mousemove","touchstart","touchmove","mouseup","touchend","wheel"],this.clientX=0,this.clientY=0,this.startX=0,this.endX=0,this.dragX=0,this.startY=0,this.endY=0,this.dragY=0,this.moveDirection="none"}init({xyRatios:t}){const e=this.w,i=this;this.xyRatios=t,this.zoomRect=this.graphics.drawRect(0,0,0,0),this.selectionRect=this.graphics.drawRect(0,0,0,0),this.constraints=new R(0,0,e.layout.gridWidth,e.layout.gridHeight),this.zoomRect.node.classList.add("apexcharts-zoom-rect"),this.selectionRect.node.classList.add("apexcharts-selection-rect"),e.dom.Paper.add(this.zoomRect),e.dom.Paper.add(this.selectionRect),"x"===e.config.chart.selection.type?this.slDraggableRect=this.selectionRect.draggable({minX:0,minY:0,maxX:e.layout.gridWidth,maxY:e.layout.gridHeight}).on("dragmove.namespace",this.selectionDragging.bind(this,"dragging")):"y"===e.config.chart.selection.type?this.slDraggableRect=this.selectionRect.draggable({minX:0,maxX:e.layout.gridWidth}).on("dragmove.namespace",this.selectionDragging.bind(this,"dragging")):this.slDraggableRect=this.selectionRect.draggable().on("dragmove.namespace",this.selectionDragging.bind(this,"dragging")),this.preselectedSelection(),this.hoverArea=e.dom.baseEl.querySelector(`${e.globals.chartClass} .apexcharts-svg`),this.hoverArea&&(this.hoverArea.classList.add("apexcharts-zoomable"),this.eventList.forEach(e=>{var n;null==(n=this.hoverArea)||n.addEventListener(e,i.svgMouseEvents.bind(i,t),{capture:!1,passive:!0})}),e.config.chart.zoom.enabled&&e.config.chart.zoom.allowMouseWheelZoom&&this.hoverArea.addEventListener("wheel",i.mouseWheelEvent.bind(i),{capture:!1,passive:!1}),this._momentumEnabled()&&["touchstart","touchmove","touchend","touchcancel"].forEach(t=>{var e;null==(e=this.hoverArea)||e.addEventListener(t,i.momentumTouch.bind(i),{capture:!1,passive:!1})}))}destroy(){this.slDraggableRect&&(this.slDraggableRect.draggable(!1),this.slDraggableRect.off(),this.selectionRect.off()),this.selectionRect=null,this.zoomRect=null}svgMouseEvents(t,e){const i=this.w,n=this.ctx.toolbar;if(i.interact.momentum&&i.interact.momentum.busy)return;if(this._momentumEnabled()&&e.touches&&e.touches.length>1)return;const s=i.interact.zoomEnabled?i.config.chart.zoom.type:i.config.chart.selection.type,a=i.config.chart.toolbar.autoSelected;if("measure"!==a&&(e.shiftKey?(this.shiftWasPressed=!0,n.enableZoomPanFromToolbar("pan"===a?"zoom":"pan")):this.shiftWasPressed&&(n.enableZoomPanFromToolbar(a),this.shiftWasPressed=!1)),!e.target)return;const o=e.target.classList;let l;e.target.parentNode&&null!==e.target.parentNode&&(l=e.target.parentNode.classList);if(!(o.contains("apexcharts-legend-marker")||o.contains("apexcharts-legend-text")||l&&l.contains("apexcharts-toolbar"))){if(this.clientX="touchmove"===e.type||"touchstart"===e.type?e.touches[0].clientX:"touchend"===e.type?e.changedTouches[0].clientX:e.clientX,this.clientY="touchmove"===e.type||"touchstart"===e.type?e.touches[0].clientY:"touchend"===e.type?e.changedTouches[0].clientY:e.clientY,"mousedown"===e.type&&1===e.which||"touchstart"===e.type){const t=this._gridRect();if(!t)return;this.startX=this._screenXToPlotPx(this.clientX),this.startY=this.clientY-t.top,this.dragged=!1,this.w.interact.mousedown=!0}("mousemove"===e.type&&1===e.which||"touchmove"===e.type)&&(this.dragged=!0,i.interact.panEnabled?(i.interact.selection=null,this.w.interact.mousedown&&this.panDragging({context:this,zoomtype:s,xyRatios:this.xyRatios})):(this.w.interact.mousedown&&i.interact.zoomEnabled||this.w.interact.mousedown&&i.interact.selectionEnabled)&&(this.selection=this.selectionDrawing({context:this,zoomtype:s}))),"mouseup"!==e.type&&"touchend"!==e.type&&"mouseleave"!==e.type||this.handleMouseUp({zoomtype:s}),this.makeSelectionRectDraggable()}}handleMouseUp({zoomtype:t,isResized:e}){const i=this.w,n=this._gridRect();n&&(this.w.interact.mousedown||e)&&(this.endX=this._screenXToPlotPx(this.clientX),this.endY=this.clientY-n.top,this.dragX=Math.abs(this.endX-this.startX),this.dragY=Math.abs(this.endY-this.startY),(i.interact.zoomEnabled||i.interact.selectionEnabled)&&this.selectionDrawn({context:this,zoomtype:t})),i.interact.zoomEnabled&&this.hideSelectionRect(this.selectionRect),this.dragged=!1,this.w.interact.mousedown=!1}_wheel(){const t=this.w.interact;return t.wheel||(t.wheel={factor:1,clientX:0,rafId:null,endTimer:null}),t.wheel}mouseWheelEvent(t){t.preventDefault();const e=this._wheel();let i=t.deltaY;1===t.deltaMode?i*=33:2===t.deltaMode&&(i*=330),e.factor*=Math.pow(2,i/240),e.clientX=t.clientX,null==e.rafId&&(e.rafId=requestAnimationFrame(()=>this._applyWheelZoom())),e.endTimer&&clearTimeout(e.endTimer),e.endTimer=setTimeout(()=>this._endWheelZoom(),150)}_applyWheelZoom(){const t=this.w,e=this._wheel();e.rafId=null;const i=e.factor;if(e.factor=1,1===i||t.globals.isDestroyed)return;const n=this._gridRect();if(!n||!n.width)return;const{min:s,max:a}=this._currentXWindow(),o=a-s,l=Math.min(Math.max((e.clientX-n.left)/n.width,0),1);let r=o*i;const c=this._clampBounds();if(c){const e=t.globals.minXDiff>0&&isFinite(t.globals.minXDiff)?t.globals.minXDiff:0,i=Math.max(2*e,1e-6*(c.max-c.min));r<i&&(r=i),r>c.max-c.min&&(r=c.max-c.min)}let h=s+l*o-l*r,d=h+r;const g=1e-9*o;if(Math.abs(h-s)<g&&Math.abs(d-a)<g)return;if(isNaN(h)||isNaN(d))return;const m=this.getBeforeZoomRange({min:h,max:d},void 0);m&&m.xaxis&&(h=m.xaxis.min,d=m.xaxis.max),this._applyXRange(h,d,!0)}_endWheelZoom(){const t=this.w;if(this._wheel().endTimer=null,t.globals.isDestroyed||!t.interact.zoomed)return;const{min:e,max:i}=this._currentXWindow(),n=t.globals.initialConfig?x.clone(t.globals.initialConfig.yaxis):[],s=this.ctx.toolbar;s&&s.zoomCallback({min:e,max:i},n)}makeSelectionRectDraggable(){const t=this.w;if(!this.selectionRect)return;const e=this.selectionRect.node.getBoundingClientRect();e.width>0&&e.height>0&&(this.selectionRect.select(!1).resize(!1),this.selectionRect.select({createRot:()=>{},updateRot:()=>{},createHandle:(t,e,i,n,s)=>"l"===s||"r"===s?t.circle(8).css({"stroke-width":1,stroke:"#333",fill:"#fff"}):t.circle(0),updateHandle:(t,e)=>t.center(e[0],e[1])}).resize().on("resize",()=>{var e;if(t.interact.selectionEnabled)t.interact.selection={x:parseFloat(this.selectionRect.node.getAttribute("x")),y:parseFloat(this.selectionRect.node.getAttribute("y")),width:parseFloat(this.selectionRect.node.getAttribute("width")),height:parseFloat(this.selectionRect.node.getAttribute("height"))},clearTimeout(null!=(e=this.w.globals.selectionResizeTimer)?e:void 0),this.w.globals.selectionResizeTimer=window.setTimeout(()=>{this._emitSelectionFromRect()},30);else{const e=t.interact.zoomEnabled?t.config.chart.zoom.type:t.config.chart.selection.type;this.handleMouseUp({zoomtype:e,isResized:!0})}}))}preselectedSelection(){const t=this.w,e=this.xyRatios;if(!t.interact.zoomEnabled)if(void 0!==t.interact.selection&&null!==t.interact.selection)this.drawSelectionRect(r(l({},t.interact.selection),{translateX:t.layout.translateX,translateY:t.layout.translateY}));else if(void 0!==t.config.chart.selection.xaxis.min&&void 0!==t.config.chart.selection.xaxis.max){let i=M.dataXToPx(t,t.config.chart.selection.xaxis.min),n=M.dataXToPx(t,t.config.chart.selection.xaxis.max)-i;t.axisFlags.isRangeBar&&(i=(t.config.chart.selection.xaxis.min-t.globals.yAxisScale[0].niceMin)/e.invertedYRatio,n=(t.config.chart.selection.xaxis.max-t.config.chart.selection.xaxis.min)/e.invertedYRatio);const s={x:i,y:0,width:n,height:t.layout.gridHeight,translateX:t.layout.translateX,translateY:t.layout.translateY,selectionEnabled:!0};this.drawSelectionRect(s),this.makeSelectionRectDraggable(),"function"==typeof t.config.chart.events.selection&&t.config.chart.events.selection(this.ctx,{xaxis:{min:t.config.chart.selection.xaxis.min,max:t.config.chart.selection.xaxis.max},yaxis:{}})}}drawSelectionRect({x:t,y:e,width:i,height:n,translateX:s=0,translateY:a=0}){const o=this.w,l=this.zoomRect,r=this.selectionRect;if(this.dragged||null!==o.interact.selection){const c={transform:"translate("+s+", "+a+")"};o.interact.zoomEnabled&&this.dragged&&(i<0&&(i=1),l.attr({x:t,y:e,width:i,height:n,fill:o.config.chart.zoom.zoomedArea.fill.color,"fill-opacity":o.config.chart.zoom.zoomedArea.fill.opacity,stroke:o.config.chart.zoom.zoomedArea.stroke.color,"stroke-width":o.config.chart.zoom.zoomedArea.stroke.width,"stroke-opacity":o.config.chart.zoom.zoomedArea.stroke.opacity}),g.setAttrs(l.node,c)),o.interact.selectionEnabled&&(r.attr({x:t,y:e,width:i>0?i:0,height:n>0?n:0,fill:o.config.chart.selection.fill.color,"fill-opacity":o.config.chart.selection.fill.opacity,stroke:o.config.chart.selection.stroke.color,"stroke-width":o.config.chart.selection.stroke.width,"stroke-dasharray":o.config.chart.selection.stroke.dashArray,"stroke-opacity":o.config.chart.selection.stroke.opacity}),g.setAttrs(r.node,c))}}hideSelectionRect(t){t&&t.attr({x:0,y:0,width:0,height:0})}selectionDrawing({context:t,zoomtype:e}){const i=this.w,n=t,s=this._gridRect();if(!s)return;const a=n.startX-1,o=n.startY;let c=!1,h=!1;const d=this._screenXToPlotPx(n.clientX),g=n.clientY-s.top;let m=d-a,u=g-o,p={translateX:i.layout.translateX,translateY:i.layout.translateY};return Math.abs(m+a)>i.layout.gridWidth?m=i.layout.gridWidth-a:d<0&&(m=a),a>d&&(c=!0,m=Math.abs(m)),o>g&&(h=!0,u=Math.abs(u)),p="x"===e?{x:c?a-m:a,y:0,width:m,height:i.layout.gridHeight}:"y"===e?{x:0,y:h?o-u:o,width:i.layout.gridWidth,height:u}:{x:c?a-m:a,y:h?o-u:o,width:m,height:u},p=r(l({},p),{translateX:i.layout.translateX,translateY:i.layout.translateY}),n.drawSelectionRect(p),n.selectionDragging("resizing"),p}selectionDragging(t,e){var i;const n=this.w;if(!e)return;e.preventDefault();const{handler:s,box:a}=e.detail,o=this.constraints;let{x:l,y:r}=a;l<o.x&&(l=o.x),r<o.y&&(r=o.y),a.x2>o.x2&&(l=o.x2-a.w),a.y2>o.y2&&(r=o.y2-a.h),s.move(l,r);const c=this.selectionRect;let h=0;"resizing"===t&&(h=30);const d=t=>parseFloat(c.node.getAttribute(t)),g={x:d("x"),y:d("y"),width:d("width"),height:d("height")};n.interact.selection=g;const m=n.config.chart.link,u=!(!m||!m.enabled&&"function"!=typeof m.dimension);("function"==typeof n.config.chart.events.selection||u)&&n.interact.selectionEnabled&&(clearTimeout(null!=(i=this.w.globals.selectionResizeTimer)?i:void 0),this.w.globals.selectionResizeTimer=window.setTimeout(()=>{this._emitSelectionFromRect()},h))}_emitSelectionFromRect(){var t;const e=this.w;if(!e.interact.selectionEnabled)return;const i=e.config.chart.link,n=!(!i||!i.enabled&&"function"!=typeof i.dimension);if("function"!=typeof e.config.chart.events.selection&&!n)return;const s=this._gridRect();if(!s)return;const a=this.selectionRect.node.getBoundingClientRect(),o=this.xyRatios;let l,r,c,h;const d=this._screenXToPlotPx(a.left),g=this._screenXToPlotPx(a.right);if(e.axisFlags.isRangeBar)l=e.globals.yAxisScale[0].niceMin+d*o.invertedYRatio,r=e.globals.yAxisScale[0].niceMin+g*o.invertedYRatio,c=0,h=1;else{if(!e.globals.xAxisScale)return;l=M.pxToDataX(e,d),r=M.pxToDataX(e,g),c=e.globals.yAxisScale[0].niceMin+(s.bottom-a.bottom)*o.yRatio[0],h=e.globals.yAxisScale[0].niceMax-(a.top-s.top)*o.yRatio[0]}const m={xaxis:{min:l,max:r},yaxis:{min:c,max:h}};"function"==typeof e.config.chart.events.selection&&e.config.chart.events.selection(this.ctx,m),e.config.chart.brush.enabled&&void 0!==e.config.chart.events.brushScrolled&&e.config.chart.events.brushScrolled(this.ctx,m),null==(t=this.ctx.linkedViews)||t.onSourceSelection(m.xaxis)}selectionDrawn({context:t,zoomtype:e}){var i;const n=this.w,s=t,a=this.xyRatios,o=this.ctx.toolbar,l=n.interact.zoomEnabled?s.zoomRect.node.getBoundingClientRect():s.selectionRect.node.getBoundingClientRect(),r=s._gridRect();if(!r)return;const c=this._screenXToPlotPx(l.left),h=this._screenXToPlotPx(l.right),d=l.top-r.top,g=l.bottom-r.top;let m,u;n.axisFlags.isRangeBar?(m=n.globals.yAxisScale[0].niceMin+c*a.invertedYRatio,u=n.globals.yAxisScale[0].niceMin+h*a.invertedYRatio):(m=M.pxToDataX(n,c),u=M.pxToDataX(n,h));const p=[],f=[];if(n.config.yaxis.forEach((t,e)=>{const i=n.globals.seriesYAxisMap[e][0],s=n.globals.yAxisScale[e].niceMax-a.yRatio[i]*d,o=n.globals.yAxisScale[e].niceMax-a.yRatio[i]*g;p.push(s),f.push(o)}),s.dragged&&(s.dragX>10||s.dragY>10)&&m!==u)if(n.interact.zoomEnabled){if(!n.globals.initialConfig)return;let t=x.clone(n.globals.initialConfig.yaxis),i=x.clone(n.globals.initialConfig.xaxis);if(n.interact.zoomed=!0,n.config.xaxis.convertedCatToNumeric&&(m=Math.floor(m),u=Math.floor(u),m<1&&(m=1,u=n.globals.dataPoints),u-m<2&&(u=m+1)),"xy"!==e&&"x"!==e||(i={min:m,max:u}),"xy"!==e&&"y"!==e||t.forEach((e,i)=>{t[i].min=f[i],t[i].max=p[i]}),o){const e=o.getBeforeZoomRange(i,t);e&&(i=e.xaxis?e.xaxis:i,t=e.yaxis?e.yaxis:t)}const a={xaxis:i};n.config.chart.group||(a.yaxis=t),s.ctx.updateHelpers._updateOptions(a,!1,s.w.config.chart.animations.dynamicAnimation.enabled),"function"==typeof n.config.chart.events.zoomed&&o.zoomCallback(i,t)}else if(n.interact.selectionEnabled){let t=null,a=null;if(a={min:m,max:u},"xy"===e||"y"===e){const e=x.clone(n.config.yaxis);t=e,e.forEach((t,i)=>{e[i].min=f[i],e[i].max=p[i]})}n.interact.selection=s.selection,"function"==typeof n.config.chart.events.selection&&n.config.chart.events.selection(s.ctx,{xaxis:a,yaxis:t}),null==(i=s.ctx.linkedViews)||i.onSourceSelection(a)}}panDragging({context:t}){var e;const i=this.w,n=t;if(void 0!==i.interact.lastClientPosition.x){const t=i.interact.lastClientPosition.x-n.clientX,s=(null!=(e=i.interact.lastClientPosition.y)?e:0)-n.clientY;Math.abs(t)>Math.abs(s)&&t>0?this.moveDirection="left":Math.abs(t)>Math.abs(s)&&t<0?this.moveDirection="right":Math.abs(s)>Math.abs(t)&&s>0?this.moveDirection="up":Math.abs(s)>Math.abs(t)&&s<0&&(this.moveDirection="down")}i.interact.lastClientPosition={x:n.clientX,y:n.clientY};const s=i.axisFlags.isRangeBar?i.globals.minY:i.globals.minX,a=i.axisFlags.isRangeBar?i.globals.maxY:i.globals.maxX;n.panScrolled(s,a)}panScrolled(t,e){var i,n;const s=this.w,a=this.xyRatios;if(!s.globals.initialConfig)return;const o=x.clone(s.globals.initialConfig.yaxis);let l=a.xRatio,r=s.globals.minX,c=s.globals.maxX;if(s.axisFlags.isRangeBar&&(l=a.invertedYRatio,r=s.globals.minY,c=s.globals.maxY),"left"===this.moveDirection?(t=r+s.layout.gridWidth/15*l,e=c+s.layout.gridWidth/15*l):"right"===this.moveDirection&&(t=r-s.layout.gridWidth/15*l,e=c-s.layout.gridWidth/15*l),!s.axisFlags.isRangeBar){const a=null!=(i=s.globals.dataReducerRawMinX)?i:s.globals.initialMinX,o=null!=(n=s.globals.dataReducerRawMaxX)?n:s.globals.initialMaxX;(t<a||e>o)&&(t=r,e=c)}const h={xaxis:{min:t,max:e}};s.config.chart.group||(h.yaxis=o),this.updateScrolledChart(h,t,e)}updateScrolledChart(t,e,i){const n=this.w;if(this.ctx.updateHelpers._updateOptions(t,!1,!1),"function"==typeof n.config.chart.events.scrolled){const t={xaxis:{min:e,max:i}};n.config.chart.events.scrolled(this.ctx,t),this.ctx.events.fireEvent("scrolled",t)}}_momentumEnabled(){return this._pinchEnabled()||this._panInertiaEnabled()}_pinchEnabled(){const t=this.w.config.chart;return!!(t.zoom&&t.zoom.enabled&&t.zoom.pinch)}_panInertiaEnabled(){const t=this.w.config.chart;return!(!t.pan||!t.pan.inertia)}_m(){const t=this.w.interact;return t.momentum||(t.momentum={busy:!1,pinch:null,panState:null,samples:[],inertiaRAF:null}),t.momentum}_currentXWindow(){const t=this.w;return t.axisFlags.isRangeBar?{min:t.globals.minY,max:t.globals.maxY}:{min:t.globals.minX,max:t.globals.maxX}}_gridRect(){const t=this.w.dom.baseEl,e=t&&t.querySelector(".apexcharts-grid");return e?e.getBoundingClientRect():null}_screenXToPlotPx(t){const e=this.w.dom.baseEl,i=e&&e.querySelector(".apexcharts-svg");return t-(i?i.getBoundingClientRect().left:0)-this.w.layout.translateX}_clampBounds(){var t,e;const i=this.w;return i.axisFlags.isRangeBar?null:{min:null!=(t=i.globals.dataReducerRawMinX)?t:i.globals.initialMinX,max:null!=(e=i.globals.dataReducerRawMaxX)?e:i.globals.initialMaxX}}_applyXRange(t,e,i){const n=this.w;if(!n.globals.initialConfig)return!1;const s=this._currentXWindow(),a=i&&e-t>s.max-s.min,o=this._clampBounds();if(o){const i=e-t;t<o.min&&(e=(t=o.min)+i),e>o.max&&(t=(e=o.max)-i),t<o.min&&(t=o.min)}if(n.config.xaxis.convertedCatToNumeric&&(t=Math.floor(t),e=a?Math.ceil(e):Math.floor(e),t<1&&(t=1),o&&e>o.max&&(e=Math.floor(o.max)),e-t<2))return!1;if(!(e>t))return!1;const l={xaxis:{min:t,max:e}};return n.config.chart.group||(l.yaxis=x.clone(n.globals.initialConfig.yaxis)),i&&(n.interact.zoomed=!0),this.ctx.updateHelpers._updateOptions(l,!1,!1),{minX:t,maxX:e}}_cancelInertia(){const t=this._m();null!=t.inertiaRAF&&(cancelAnimationFrame(t.inertiaRAF),t.inertiaRAF=null)}_fireScrolled(){const t=this.w;if("function"!=typeof t.config.chart.events.scrolled)return;const{min:e,max:i}=this._currentXWindow(),n={xaxis:{min:e,max:i}};t.config.chart.events.scrolled(this.ctx,n),this.ctx.events.fireEvent("scrolled",n)}_pushSample(t,e){const i=this._m().samples;for(i.push({x:t,t:e});i.length>6;)i.shift()}momentumTouch(t){const e=this.w,i=this._m(),n=t.type;if("touchstart"===n){this._cancelInertia();const n=this._gridRect();if(!n)return;if(t.touches.length>=2&&this._pinchEnabled())t.preventDefault(),i.busy=!0,i.panState=null,this._beginPinch(t,n);else if(1===t.touches.length&&this._panInertiaEnabled()&&e.interact.panEnabled){i.busy=!0,i.pinch=null;const n=t.touches[0],s=this._currentXWindow(),a=e.layout.gridWidth||1;i.panState={startX:n.clientX,startY:n.clientY,axis:null,minX0:s.min,maxX0:s.max,ratio0:(s.max-s.min)/a},i.samples=[{x:n.clientX,t:t.timeStamp}]}return}"touchmove"!==n?(i.pinch?t.touches.length<2&&this._endPinch():i.panState&&0===t.touches.length&&this._endPan(),0===t.touches.length&&(e.interact.mousedown=!1,this.dragged=!1,null!=i.inertiaRAF||i.pinch||i.panState||(i.busy=!1))):i.pinch&&t.touches.length>=2?(t.preventDefault(),this._movePinch(t)):i.panState&&1===t.touches.length&&this._movePan(t)}_beginPinch(t,e){const i=this.w,n=t.touches[0],s=t.touches[1],a=Math.hypot(s.clientX-n.clientX,s.clientY-n.clientY)||1,o=(n.clientX+s.clientX)/2-e.left-i.globals.barPadForNumericAxis,{min:l,max:r}=this._currentXWindow();this._m().pinch={d0:a,cx0:o,minX0:l,maxX0:r,gridWidth:i.layout.gridWidth||1}}_movePinch(t){const e=this.w,i=this._m().pinch;if(!i)return;const n=this._gridRect();if(!n)return;const s=t.touches[0],a=t.touches[1],o=Math.hypot(a.clientX-s.clientX,a.clientY-s.clientY)||1,l=(s.clientX+a.clientX)/2-n.left-e.globals.barPadForNumericAxis,r=i.maxX0-i.minX0,c=r*(i.d0/o);let h=i.minX0+i.cx0/i.gridWidth*r-l/i.gridWidth*c,d=h+c;const g=this._clampBounds();if(g){const t=e.globals.minXDiff>0&&isFinite(e.globals.minXDiff)?e.globals.minXDiff:0,i=Math.max(2*t,1e-6*(g.max-g.min));if(d-h<i){const t=(h+d)/2;h=t-i/2,d=t+i/2}}this._applyXRange(h,d,!0)}_endPinch(){const t=this.w;this._m().pinch=null;const{min:e,max:i}=this._currentXWindow(),n={min:e,max:i},s=t.globals.initialConfig?x.clone(t.globals.initialConfig.yaxis):[],a=this.ctx.toolbar;a&&a.zoomCallback(n,s)}_movePan(t){const e=this._m(),i=e.panState,n=t.touches[0];if(!i.axis){const s=Math.abs(n.clientX-i.startX),a=Math.abs(n.clientY-i.startY);if(s<6&&a<6)return void this._pushSample(n.clientX,t.timeStamp);if(a>s)return e.busy=!1,void(e.panState=null);i.axis="x"}if("x"!==i.axis)return;t.preventDefault();const s=(n.clientX-i.startX)*i.ratio0;this._pushSample(n.clientX,t.timeStamp),this._applyXRange(i.minX0-s,i.maxX0-s,!1)}_endPan(){const t=this._m(),e=t.panState;t.panState=null;let i=0;const n=t.samples;if(n.length>=2){const t=n[0],e=n[n.length-1],s=e.t-t.t;s>0&&(i=(e.x-t.x)/s)}t.samples=[],e&&"x"===e.axis&&this._panInertiaEnabled()&&Math.abs(i)>.05?this._startInertia(i):(t.busy=!1,this._fireScrolled())}_startInertia(t){const e=this.w,i=this._m(),n=e.config.chart.pan&&e.config.chart.pan.friction,s="number"==typeof n?Math.min(Math.max(n,.5),.999):.92;let a=t,o=null;i.busy=!0;const l=t=>{if(e.globals.isDestroyed)return i.inertiaRAF=null,void(i.busy=!1);if(null==o)return o=t,void(i.inertiaRAF=requestAnimationFrame(l));const n=t-o;if(o=t,a*=Math.pow(s,n/16.6667),Math.abs(a)<.02)return i.inertiaRAF=null,i.busy=!1,void this._fireScrolled();const r=this._currentXWindow(),c=e.layout.gridWidth||1,h=(r.max-r.min)/c,d=a*n*h,g=this._applyXRange(r.min-d,r.max-d,!1),m=this._clampBounds();if(!g||m&&(d>0&&g.minX<=m.min+1e-6*(m.max-m.min)||d<0&&g.maxX>=m.max-1e-6*(m.max-m.min)))return i.inertiaRAF=null,i.busy=!1,void this._fireScrolled();i.inertiaRAF=requestAnimationFrame(l)};i.inertiaRAF=requestAnimationFrame(l)}}}),exports.default=c;