UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 20.7 kB
/*! * ApexCharts v6.6.1 * (c) 2018-2026 ApexCharts */ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("apexcharts/core");function e(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const n in t)if("default"!==n){const i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:()=>t[n]})}return e.default=t,Object.freeze(e)}const n=e(t),i=n.__apex_Utils,a=n.__apex_Options,s=["point","xaxis","yaxis"],o=[10,11,12,14,17,20],r=["circle","square","diamond","triangle"],l={circle:"\u25cf",square:"\u25a0",diamond:"\u25c6",triangle:"\u25b2"},c=["#ffffff","#334155","#2563eb","#16a34a","#d97706","#dc2626"];class d{constructor(t,e){this.w=t,this.ctx=e,this._wired=!1,this._drag=null,this._editor=null,this._creating=!1,this._createSeq=0,this._attach=this._attach.bind(this),this._onRerender=this._onRerender.bind(this),this._onMove=this._onMove.bind(this),this._onUp=this._onUp.bind(this),this._onCreateClick=this._onCreateClick.bind(this),this._onDocDownEditor=this._onDocDownEditor.bind(this),(this._enabledGlobally()||this._hasDraggable()||this._paletteEnabled())&&this._wire()}_enabledGlobally(){const t=this.w.config.chart.ink;return!(!t||!t.enabled)}_paletteEnabled(){const t=this.w.config.chart.ink;return!(!t||!t.palette)}_snapEnabled(){const t=this.w.config.chart.ink;return!(!t||!t.snap)}_nearest(t,e){let n=t,i=1/0;for(let a=0;a<e.length;a++){const s=Math.abs(e[a]-t);s<i&&(i=s,n=e[a])}return n}_snapX(t){if(!this._snapEnabled()||"number"!=typeof t)return t;const e=this.w.globals.xAxisScale;return e&&Array.isArray(e.result)&&e.result.length?this._nearest(t,e.result):t}_snapY(t,e){if(!this._snapEnabled()||"number"!=typeof t)return t;const n=this.w.globals.yAxisScale,i=n&&n[e];return i&&Array.isArray(i.result)&&i.result.length?this._nearest(t,i.result):t}_annoList(t){const e=this.w.config.annotations;if(!e)return[];const n="point"===t?"points":t;return Array.isArray(e[n])?e[n]:[]}_isDraggable(t){return!!t&&(!0===t.draggable||!1!==t.draggable&&this._enabledGlobally())}_hasDraggable(){return s.some(t=>this._annoList(t).some(t=>this._isDraggable(t)))}_wire(){this._wired||(this._wired=!0,this.ctx.addEventListener("mounted",this._onRerender),this.ctx.addEventListener("updated",this._onRerender))}_onRerender(){this._closeEditor(!1),this._attach()}_attach(){const t=this.w,e=t.dom.baseEl;e&&(s.forEach(n=>{this._annoList(n).forEach((i,a)=>{this._isDraggable(i)&&(i.id||(i.id="apexcharts-ink-"+n+"-"+a+"-"+t.globals.chartID),e.querySelectorAll("."+i.id).forEach(t=>{t.__inkBound||(t.__inkBound=!0,t.style.cursor="move",t.classList.add("apexcharts-ink-draggable"),t.addEventListener("mousedown",t=>this._onDown(t,n,a)),t.addEventListener("touchstart",t=>this._onDown(t,n,a)),t.addEventListener("dblclick",t=>{t.preventDefault(),t.stopPropagation(),this._startEdit(n,a,{select:!0})}))}))})}),this._paletteEnabled()&&this._renderPalette())}_onDown(t,e,n){if(t.button&&0!==t.button)return;const i=this.w,a=i.dom.baseEl&&i.dom.baseEl.ownerDocument;if(!a)return;t.stopPropagation(),t.cancelable&&t.preventDefault();const s="touchstart"===t.type?t.touches[0]:t,o=i.dom.Paper&&i.dom.Paper.node,r=o&&o.getScreenCTM?o.getScreenCTM():null,l=this._annoList(e)[n];let c="move",d=null,h=0,p=0;if("xaxis"===e&&null!=l.x2&&(d=i.dom.baseEl.querySelector(".apexcharts-annotation-rect."+l.id),d)){const t=d.getBoundingClientRect();Math.abs(s.clientX-t.left)<=8?c="resize-x1":Math.abs(s.clientX-t.right)<=8&&(c="resize-x2"),h=parseFloat(d.getAttribute("x"))||0,p=parseFloat(d.getAttribute("width"))||0}this._drag={type:e,index:n,anno:l,els:Array.from(i.dom.baseEl.querySelectorAll("."+l.id)),mode:c,rect:d,origX:h,origW:p,startX:s.clientX,startY:s.clientY,scaleX:r&&r.a?r.a:1,scaleY:r&&r.d?r.d:1,dxPixel:0,dyPixel:0,moved:!1},a.addEventListener("mousemove",this._onMove),a.addEventListener("touchmove",this._onMove,{passive:!1}),a.addEventListener("mouseup",this._onUp),a.addEventListener("touchend",this._onUp)}_onMove(t){const e=this._drag;if(!e)return;t.cancelable&&t.preventDefault();const n="touchmove"===t.type?t.touches[0]:t;if(e.dxPixel=(n.clientX-e.startX)/e.scaleX,e.dyPixel=(n.clientY-e.startY)/e.scaleY,(Math.abs(e.dxPixel)>2||Math.abs(e.dyPixel)>2)&&(e.moved=!0),"move"===e.mode){const t=`translate(${e.dxPixel} ${e.dyPixel})`;e.els.forEach(e=>e.setAttribute("transform",t))}else e.rect&&("resize-x1"===e.mode?(e.rect.setAttribute("x",e.origX+e.dxPixel),e.rect.setAttribute("width",Math.max(1,e.origW-e.dxPixel))):"resize-x2"===e.mode&&e.rect.setAttribute("width",Math.max(1,e.origW+e.dxPixel)))}_onUp(){const t=this._drag;if(this._drag=null,this._teardownDocListeners(),!t||!t.moved)return void(t&&(t.els.forEach(t=>t.removeAttribute("transform")),this._startEdit(t.type,t.index)));const e=this._annoList(t.type)[t.index];e&&(this._applyDelta(t,e),t.els.forEach(t=>t.removeAttribute("transform")),this._redrawAnno(t.type,e,t.index),this._checkpoint("ink:drag"),this._fireDragged(t.type,e,t.index))}_checkpoint(t){var e,n;null==(n=null==(e=this.ctx.history)?void 0:e.snapshot)||n.call(e,t)}_applyDelta(t,e){const n=this.w,i=n.layout.gridWidth?t.dxPixel*(n.globals.xRange/n.layout.gridWidth):0;if("point"===t.type){const{newX:i,newY:a}=this._invertPoint(e,t.dxPixel,t.dyPixel);if(e.x=this._snapX(i),null!=a){const t=e.yAxisIndex||0,i=n.globals.seriesYAxisMap;e.y=this._snapY(a,i&&i[t]?i[t][0]:0)}return}if("xaxis"!==t.type){if("yaxis"===t.type){const i=e.yAxisIndex||0,a=n.globals.seriesYAxisMap,s=a&&a[i]?a[i][0]:0,o=n.globals.yRange?n.globals.yRange[s]:null;if(null==o||!n.layout.gridHeight)return;const r=-t.dyPixel*(o/n.layout.gridHeight);"number"==typeof e.y2?("number"==typeof e.y&&(e.y+=r),e.y2+=r):"number"==typeof e.y&&(e.y=this._snapY(e.y+r,s))}}else{if("number"!=typeof e.x)return;if("move"===t.mode)"number"==typeof e.x2?(e.x+=i,e.x2+=i):e.x=this._snapX(e.x+i);else if("resize-x1"===t.mode||"resize-x2"===t.mode){const n=null==e.x2||e.x<=e.x2;("resize-x2"===t.mode?!n:n)?e.x=this._snapX(e.x+i):"number"==typeof e.x2&&(e.x2=this._snapX(e.x2+i))}}}_invertPoint(t,e,n){const i=this.w,a=("category"===i.config.xaxis.type||i.config.xaxis.convertedCatToNumeric)&&!i.axisFlags.dataFormatXNumeric;let s=t.x;!a&&"number"==typeof t.x&&i.layout.gridWidth&&(s=t.x+e*(i.globals.xRange/i.layout.gridWidth));let o=t.y;const r=t.yAxisIndex||0,l=i.globals.seriesYAxisMap,c=l&&l[r]?l[r][0]:0,d=i.globals.yRange?i.globals.yRange[c]:null,h=i.config.yaxis[r]&&i.config.yaxis[r].logarithmic;return"number"==typeof t.y&&null!=d&&!h&&i.layout.gridHeight&&(o=t.y-n*(d/i.layout.gridHeight)),{newX:s,newY:o}}_redrawAnno(t,e,n){const i=this.w.dom.baseEl,a=this.ctx.annotations;if(!i||!a)return;i.querySelectorAll("."+e.id).forEach(t=>t.remove());const s=i.querySelector(".apexcharts-"+t+"-annotations");if(!s)return;"point"===t&&a.pointsAnnotations?a.pointsAnnotations.addPointAnnotation(e,s,n):"xaxis"===t&&a.xAxisAnnotations?a.xAxisAnnotations.addXaxisAnnotation(e,s,n):"yaxis"===t&&a.yAxisAnnotations&&a.yAxisAnnotations.addYaxisAnnotation(e,s,n);const o=i.querySelector(".apexcharts-"+t+"-annotation-label."+e.id);if(o&&a.helpers&&e.label&&e.label.text){const t=a.helpers.addBackgroundToAnno(o,e);t&&o.parentNode&&o.parentNode.insertBefore(t.node,o)}this._attach()}_fireDragged(t,e,n){var i;const a={type:t,id:e.id,index:n,x:e.x,y:e.y};null!=e.x2&&(a.x2=e.x2),null!=e.y2&&(a.y2=e.y2);const s=this.w.config.chart.events;"function"==typeof s.annotationDragged&&s.annotationDragged(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("annotationDragged",[this.ctx,a])}startCreate(){if(this._creating)return;const t=this.w.dom.Paper&&this.w.dom.Paper.node;t&&(this._creating=!0,t.style.cursor="crosshair",t.addEventListener("click",this._onCreateClick,!0),this._syncPalette())}stopCreate(){if(!this._creating)return;this._creating=!1;const t=this.w.dom.Paper&&this.w.dom.Paper.node;t&&(t.style.cursor="",t.removeEventListener("click",this._onCreateClick,!0)),this._syncPalette()}_onCreateClick(t){if(!this._creating)return;t.preventDefault(),t.stopPropagation();const e=this._pixelToData(t.clientX,t.clientY);this.stopCreate(),e&&this.createAt(e.x,e.y)}createAt(t,e,n={}){const s=this.w;this._wire(),this._createSeq+=1;const o="apexcharts-ink-new-"+this._createSeq+"-"+s.globals.chartID,r=i.extend((new a).pointAnnotation,{x:t,y:e,id:o,draggable:!0,label:{text:n.text||"Note"}});s.config.annotations||(s.config.annotations={}),Array.isArray(s.config.annotations.points)||(s.config.annotations.points=[]),s.config.annotations.points.push(r);const l=s.config.annotations.points.length-1;return this._redrawAnno("point",r,l),this._checkpoint("ink:create"),this._fireCreated("point",r,l),this._startEdit("point",l,{select:!0}),r}createLineAt(t,e,n={}){const s=this.w;this._wire(),this._createSeq+=1;const o="apexcharts-ink-new-"+this._createSeq+"-"+s.globals.chartID,r="y"===t?"yaxis":"xaxis",l="yaxis"===r?(new a).yAxisAnnotation:(new a).xAxisAnnotation,c={id:o,draggable:!0,strokeDashArray:null!=n.strokeDashArray?n.strokeDashArray:4,label:{text:n.text||""}};n.color&&(c.borderColor=n.color,c.label.borderColor=n.color),"yaxis"===r?c.y=e:c.x=e;const d=i.extend(l,c);s.config.annotations||(s.config.annotations={}),Array.isArray(s.config.annotations[r])||(s.config.annotations[r]=[]),s.config.annotations[r].push(d);const h=s.config.annotations[r].length-1;return this._redrawAnno(r,d,h),this._checkpoint("ink:create"),this._fireCreated(r,d,h),!1!==n.select&&this._startEdit(r,h,{select:!0}),d}_pixelToData(t,e){const n=this.w,i=n.dom.baseEl&&n.dom.baseEl.querySelector(".apexcharts-grid");if(!i)return null;const a=i.getBoundingClientRect();if(!a.width||!a.height)return null;const s=(t-a.left)/a.width,o=(e-a.top)/a.height;let r=n.globals.minX+s*n.globals.xRange;const l=(n.globals.minYArr&&null!=n.globals.minYArr[0]?n.globals.minYArr[0]:n.globals.minY)+(1-o)*(n.globals.yRange&&null!=n.globals.yRange[0]?n.globals.yRange[0]:n.globals.maxY-n.globals.minY);return("category"===n.config.xaxis.type||n.config.xaxis.convertedCatToNumeric)&&!n.axisFlags.dataFormatXNumeric&&(r=Math.round(r)),{x:r,y:l}}_fireCreated(t,e,n){var i;const a={type:t,id:e.id,index:n};void 0!==e.x&&(a.x=e.x),void 0!==e.y&&(a.y=e.y);const s=this.w.config.chart.events;"function"==typeof s.annotationCreated&&s.annotationCreated(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("annotationCreated",[this.ctx,a])}_renderPalette(){const t=this.w.dom.elWrap;if(!t||t.querySelector(".apexcharts-ink-palette"))return;const e=t.ownerDocument,n=e.createElement("div");n.className="apexcharts-ink-palette";const i=n.style;i.position="absolute",i.top="6px",i.left="6px",i.zIndex="15";const a=e.createElement("button");a.type="button",a.className="apexcharts-ink-add",a.textContent="+ Note";const s=a.style;s.cursor="pointer",s.font="12px sans-serif",s.padding="4px 9px",s.borderRadius="5px",s.border="1px solid #6366f1",s.color="#4338ca",s.background="#fff",a.addEventListener("click",t=>{t.stopPropagation(),this._creating?this.stopCreate():this.startCreate()}),n.appendChild(a),t.appendChild(n),this._syncPalette()}_syncPalette(){const t=this.w.dom.elWrap,e=t&&t.querySelector(".apexcharts-ink-add");e&&(this._creating?(e.style.background="#6366f1",e.style.color="#fff",e.textContent="Click chart..."):(e.style.background="#fff",e.style.color="#4338ca",e.textContent="+ Note"))}_noteColors(){const t=this.w.config.chart.ink;return t&&Array.isArray(t.noteColors)&&t.noteColors.length?t.noteColors:c}static _isLight(t){const e=String(t||"").replace("#",""),n=3===e.length?e.split("").map(t=>t+t).join(""):e,i=parseInt(n,16);if(isNaN(i)||6!==n.length)return!1;return(.299*(i>>16&255)+.587*(i>>8&255)+.114*(255&i))/255>.72}static _isBold(t){const e=t&&t.fontWeight;return"bold"===e||parseInt(String(e),10)>=600}_cardBtn(t,e,n,i,a,s){const o=t.createElement("button");return o.type="button",o.className="apexcharts-ink-btn"+(a?" "+a:""),o.title=n,o.setAttribute("aria-label",n),s?o.innerHTML=e:o.textContent=e,o.addEventListener("mousedown",t=>t.preventDefault()),o.addEventListener("click",t=>{t.stopPropagation(),i()}),o}_cardLabel(t,e){const n=t.createElement("span");return n.className="apexcharts-ink-cardlabel",n.textContent=e,n}_mkSwatch(t,e,n,i){const a=t.createElement("button");return a.type="button",a.className="apexcharts-ink-swatch"+(i?" "+i:""),a.title=e,a.setAttribute("aria-label","Color "+e),a.dataset.color=e,a.style.background=e,a.addEventListener("mousedown",t=>t.preventDefault()),a.addEventListener("click",t=>{t.stopPropagation(),n(e)}),a}_startEdit(t,e,n={}){const i=this.w,a=this._annoList(t)[e],s=i.dom.baseEl,o=i.dom.elWrap;if(!(a&&a.id&&s&&o))return;this._closeEditor(!1);const r=s.ownerDocument,c=r.createElement("div");c.className="apexcharts-ink-card",c.setAttribute("role","dialog"),c.setAttribute("aria-label","Edit note"),c.style.visibility="hidden";const d=r.createElement("div");d.className="apexcharts-ink-card-row";const h=r.createElement("input");h.type="text",h.className="apexcharts-ink-editor",h.placeholder="Note text",h.value=a.label&&a.label.text||"",d.appendChild(h),d.appendChild(this._cardBtn(r,'<svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 6h18M8 6V4a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/></svg>',"Delete note",()=>this._deleteAnno(),"apexcharts-ink-btn--delete",!0)),c.appendChild(d);const p=r.createElement("div");p.className="apexcharts-ink-card-row","point"!==t&&p.appendChild(this._cardLabel(r,"Label")),this._noteColors().forEach(t=>{p.appendChild(this._mkSwatch(r,t,t=>this._applyColor(t)))});const x=r.createElement("span");if(x.className="apexcharts-ink-sep",p.appendChild(x),p.appendChild(this._cardBtn(r,"B","Bold",()=>this._toggleBold(),"apexcharts-ink-btn--bold")),p.appendChild(this._cardBtn(r,"A-","Smaller text",()=>this._stepFont(-1))),p.appendChild(this._cardBtn(r,"A+","Larger text",()=>this._stepFont(1))),c.appendChild(p),"point"!==t){const t=r.createElement("div");t.className="apexcharts-ink-card-row",t.appendChild(this._cardLabel(r,"Line")),this._noteColors().forEach(e=>{t.appendChild(this._mkSwatch(r,e,t=>this._applyLineColor(t),"apexcharts-ink-swatch--line"))}),c.appendChild(t)}if("point"===t){const t=r.createElement("div");t.className="apexcharts-ink-card-row",t.appendChild(this._cardLabel(r,"Marker")),t.appendChild(this._cardBtn(r,"-","Smaller marker",()=>this._stepMarker(-1)));const e=r.createElement("span");e.className="apexcharts-ink-marker-size",t.appendChild(e),t.appendChild(this._cardBtn(r,"+","Larger marker",()=>this._stepMarker(1))),t.appendChild(this._cardBtn(r,l.circle,"Marker shape",()=>this._cycleShape(),"apexcharts-ink-btn--shape")),c.appendChild(t)}o.appendChild(c),this._editor={card:c,input:h,type:t,index:e},this._positionCard(),this._syncCard(),c.style.visibility="",h.focus(),n.select&&h.select(),c.addEventListener("keydown",t=>{"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),this._closeEditor(!1)):"Enter"===t.key&&t.target===h&&(t.preventDefault(),this._closeEditor(!0))}),r.addEventListener("mousedown",this._onDocDownEditor,!0),r.addEventListener("touchstart",this._onDocDownEditor,!0)}_onDocDownEditor(t){const e=this._editor;e&&!e.card.contains(t.target)&&this._closeEditor(!0)}_positionCard(){const t=this._editor;if(!t)return;const e=this.w,n=e.dom.baseEl,i=e.dom.elWrap,a=this._annoList(t.type)[t.index];if(!n||!i||!a)return;const s=n.querySelector(".apexcharts-"+t.type+"-annotation-label."+a.id)||n.querySelector("."+a.id);if(!s)return;const o=i.getBoundingClientRect(),r=s.getBoundingClientRect(),l=t.card.offsetWidth,c=t.card.offsetHeight;let d=Math.round(r.left-o.left),h=Math.round(r.bottom-o.top)+8;h+c>i.clientHeight-4&&(h=Math.round(r.top-o.top)-c-8),d+l>i.clientWidth-4&&(d=i.clientWidth-l-4),t.card.style.left=Math.max(4,d)+"px",t.card.style.top=Math.max(4,h)+"px"}_syncCard(){const t=this._editor;if(!t)return;const e=this._annoList(t.type)[t.index];if(!e)return;const n=e.label&&e.label.style||{},i=String(n.background||"").toLowerCase();t.card.querySelectorAll(".apexcharts-ink-swatch:not(.apexcharts-ink-swatch--line)").forEach(t=>{t.classList.toggle("apexcharts-ink-swatch--active",(t.dataset.color||"").toLowerCase()===i)});const a=String(e.borderColor||"").toLowerCase();t.card.querySelectorAll(".apexcharts-ink-swatch--line").forEach(t=>{t.classList.toggle("apexcharts-ink-swatch--active",(t.dataset.color||"").toLowerCase()===a)});const s=t.card.querySelector(".apexcharts-ink-btn--bold");s&&s.classList.toggle("apexcharts-ink-btn--active",d._isBold(n));const o=e.marker||{},r=t.card.querySelector(".apexcharts-ink-marker-size");r&&(r.textContent=String("number"==typeof o.size?o.size:4));const c=t.card.querySelector(".apexcharts-ink-btn--shape");c&&(c.textContent=l[o.shape]||l.circle)}_commitTextOf(t){const e=this._annoList(t.type)[t.index];if(!e)return;const n=t.input.value;e.label||(e.label={}),e.label.text!==n&&(e.label.text=n,this._redrawAnno(t.type,e,t.index),this._checkpoint("ink:edit"),this._fireEdited(t.type,e,t.index))}_closeEditor(t){const e=this._editor;if(!e)return;this._editor=null;const n=this.w.dom.baseEl&&this.w.dom.baseEl.ownerDocument;n&&(n.removeEventListener("mousedown",this._onDocDownEditor,!0),n.removeEventListener("touchstart",this._onDocDownEditor,!0)),e.card.parentNode&&e.card.parentNode.removeChild(e.card),t&&this._commitTextOf(e)}_applyStyle(t,e){const n=this._editor;if(!n)return;const i=this._annoList(n.type)[n.index];i&&(this._commitTextOf(n),i.label||(i.label={}),i.label.style||(i.label.style={}),e(i),this._redrawAnno(n.type,i,n.index),this._checkpoint(t),this._fireStyled(n.type,i,n.index),this._syncCard(),this._positionCard())}_applyColor(t){const e=this._editor;if(!e)return;const n=d._isLight(t);this._applyStyle("ink:style",i=>{i.label.style.background=t,i.label.style.color=n?"#334155":"#ffffff",i.label.borderColor=n?"#cbd5e1":t,"point"===e.type&&(i.marker||(i.marker={}),i.marker.strokeColor=n?"#334155":t,i.marker.fillColor=n?"#ffffff":t)})}_applyLineColor(t){const e=this._editor;e&&"point"!==e.type&&this._applyStyle("ink:style",e=>{e.borderColor=t,null==e.x2&&null==e.y2||(e.fillColor=t)})}_stepFont(t){this._applyStyle("ink:style",e=>{const n=parseFloat(e.label.style.fontSize)||11;let i=0;for(let t=1;t<o.length;t++)Math.abs(o[t]-n)<Math.abs(o[i]-n)&&(i=t);i=Math.min(o.length-1,Math.max(0,i+t)),e.label.style.fontSize=o[i]+"px"})}_toggleBold(){this._applyStyle("ink:style",t=>{t.label.style.fontWeight=d._isBold(t.label.style)?400:700})}_stepMarker(t){this._applyStyle("ink:style",e=>{e.marker||(e.marker={});const n="number"==typeof e.marker.size?e.marker.size:4;e.marker.size=Math.min(14,Math.max(2,n+t))})}_cycleShape(){this._applyStyle("ink:style",t=>{t.marker||(t.marker={});const e=r.indexOf(t.marker.shape);t.marker.shape=r[(e+1)%r.length]})}_deleteAnno(){const t=this._editor;if(!t)return;const e=this._annoList(t.type),n=e[t.index];if(this._closeEditor(!1),!n)return;const i=this.w.dom.baseEl;i&&n.id&&i.querySelectorAll("."+n.id).forEach(t=>t.remove()),e.splice(t.index,1);for(let n=t.index;n<e.length;n++)this._redrawAnno(t.type,e[n],n);this._checkpoint("ink:delete"),this._fireDeleted(t.type,n,t.index)}_fireEdited(t,e,n){var i;const a={type:t,id:e.id,index:n,text:e.label?e.label.text:""},s=this.w.config.chart.events;"function"==typeof s.annotationEdited&&s.annotationEdited(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("annotationEdited",[this.ctx,a])}_fireStyled(t,e,n){var i;const a={type:t,id:e.id,index:n,label:e.label,marker:e.marker},s=this.w.config.chart.events;"function"==typeof s.annotationStyled&&s.annotationStyled(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("annotationStyled",[this.ctx,a])}_fireDeleted(t,e,n){var i;const a={type:t,id:e.id,index:n},s=this.w.config.chart.events;"function"==typeof s.annotationDeleted&&s.annotationDeleted(this.ctx,a),null==(i=this.ctx.events)||i.fireEvent("annotationDeleted",[this.ctx,a])}_teardownDocListeners(){const t=this.w.dom.baseEl&&this.w.dom.baseEl.ownerDocument;t&&(t.removeEventListener("mousemove",this._onMove),t.removeEventListener("touchmove",this._onMove),t.removeEventListener("mouseup",this._onUp),t.removeEventListener("touchend",this._onUp))}teardown(){var t,e,n,i;this._teardownDocListeners(),this._closeEditor(!1),this.stopCreate(),this._drag=null,this._wired&&(null==(e=(t=this.ctx).removeEventListener)||e.call(t,"mounted",this._onRerender),null==(i=(n=this.ctx).removeEventListener)||i.call(n,"updated",this._onRerender),this._wired=!1)}}t.registerFeatures({ink:d}),exports.default=t;