UNPKG

highcharts

Version:
12 lines 53.3 kB
!/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/data-tools * @requires highcharts * * Highcharts * * (c) 2010-2026 Highsoft AS * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts):"function"==typeof define&&define.amd?define("highcharts/modules/data-tools",["highcharts/highcharts"],function(e){return t(e)}):"object"==typeof exports?exports["highcharts/modules/data-tools"]=t(e._Highcharts):e.Highcharts=t(e.Highcharts)}("u"<typeof window?this:window,e=>(()=>{"use strict";var t={944:t=>{t.exports=e}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var s={};n.d(s,{default:()=>e7});var i=n(944),o=n.n(i);let{doc:l,win:a}=o();function u(e,t,r,n={}){let s="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(s,"hcEvents")||(s.hcEvents={});let i=s.hcEvents;o().Point&&e instanceof o().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let l=e.addEventListener;l&&l.call(e,t,r,!!o().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==t.indexOf("touch"):n.passive,capture:!1}),i[t]||(i[t]=[]);let a={fn:r,order:"number"==typeof n.order?n.order:1/0};return i[t].push(a),i[t].sort((e,t)=>e.order-t.order),function(){!function(e,t,r){function n(t,r){let n=e.removeEventListener;n&&n.call(e,t,r,!1)}function s(r){let s,i;e.nodeName&&(t?(s={})[t]=!0:s=r,b(s,function(e,t){if(r[t])for(i=r[t].length;i--;)n(t,r[t][i].fn)}))}let i="function"==typeof e&&e.prototype||e;if(Object.hasOwnProperty.call(i,"hcEvents")){let e=i.hcEvents;if(t){let i=e[t]||[];r?(e[t]=i.filter(function(e){return r!==e.fn}),n(t,r)):(s(e),e[t]=[])}else s(e),delete i.hcEvents}}(e,t,r)}}function h(e){return null!=e}function c(e,t){let r;for(r in e||(e={}),t)e[r]=t[r];return e}function f(e,t,r,n){if(r=r||{},l?.createEvent&&(e.dispatchEvent||e.fireEvent&&e!==o())){let n=l.createEvent("Events");n.initEvent(t,!0,!0),r=c(n,r),e.dispatchEvent?e.dispatchEvent(r):e.fireEvent(t,r)}else if(e.hcEvents){r.target||c(r,{preventDefault:function(){r.defaultPrevented=!0},target:e,type:t});let n=[],s=e,i=!1;for(;s.hcEvents;)Object.hasOwnProperty.call(s,"hcEvents")&&s.hcEvents[t]&&(n.length&&(i=!0),n.unshift.apply(n,s.hcEvents[t])),s=Object.getPrototypeOf(s);i&&n.sort((e,t)=>e.order-t.order),n.forEach(t=>{!1===t.fn.call(e,r,e)&&r.preventDefault()})}n&&!r.defaultPrevented&&n.call(e,r)}function d(e){return g(e)&&"number"==typeof e.nodeType}function p(e){return"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0}function m(e){let t=Object.prototype.toString.call(e);return"[object Array]"===t||"[object Array Iterator]"===t}function g(e,t){return!!e&&"object"==typeof e&&(!t||!m(e))}function y(e,...t){let r,n=[e,...t],s={},i=function(e,t){return"object"!=typeof e&&(e={}),b(t,function(r,n){if("__proto__"!==n&&"constructor"!==n){let s;!g(r,!0)||(s=r?.constructor,g(r,!0)&&!d(r)&&s?.name&&"Object"!==s.name)||d(r)?e[n]=t[n]:e[n]=i(e[n]||{},r)}}),e};!0===e&&(s=n[1],n=Array.prototype.slice.call(n,2));let o=n.length;for(r=0;r<o;r++)s=i(s,n[r]);return s}function b(e,t,r){for(let n in e)Object.hasOwnProperty.call(e,n)&&t.call(r||e[n],e[n],n,e)}function w(){let e=arguments,t=e.length;for(let r=0;r<t;r++){let t=e[r];if(null!=t)return t}}Array.prototype.find;class C{static registerType(e,t){return!!e&&!C.types[e]&&!!(C.types[e]=t)}benchmark(e,t){let r=[],n=this,s=()=>{n.modifyTable(e),n.emit({type:"afterBenchmarkIteration"})},{iterations:i}=y({iterations:1},t);n.on("afterBenchmarkIteration",()=>{r.length===i?n.emit({type:"afterBenchmark",results:r}):s()});let o={startTime:0,endTime:0};return n.on("modify",()=>{o.startTime=window.performance.now()}),n.on("afterModify",()=>{o.endTime=window.performance.now(),r.push(o.endTime-o.startTime)}),s(),r}emit(e){f(this,e.type,e)}modify(e,t){let r=this;return new Promise((n,s)=>{e.modified||(e.modified=e.clone(!1,t));try{n(r.modifyTable(e,t))}catch(n){r.emit({type:"error",detail:t,table:e}),s(n instanceof Error?n:Error(""+n))}})}on(e,t){return u(this,e,t)}}C.types={};let R=C,N={convertToNumber:function(e,t){switch(typeof e){case"boolean":return+!!e;case"number":return isNaN(e)&&!t?null:e;default:return isNaN(e=parseFloat(`${e??""}`))&&!t?null:e}},setLength:function(e,t,r){return Array.isArray(e)?(e.length=t,e):e[r?"subarray":"slice"](0,t)},splice:function(e,t,r,n,s=[]){if(Array.isArray(e))return Array.isArray(s)||(s=Array.from(s)),{removed:e.splice(t,r,...s),array:e};let i=Object.getPrototypeOf(e).constructor,o=e[n?"subarray":"slice"](t,t+r),l=new i(e.length-r+s.length);return l.set(e.subarray(0,t),0),l.set(s,t),l.set(e.subarray(t+r),t+s.length),{removed:o,array:l}}},{setLength:v,splice:O}=N,T=class{constructor(e={}){this.autoId=!e.id,this.columns={},this.id=e.id||(0,i.uniqueKey)(),this.rowCount=0,this.versionTag=(0,i.uniqueKey)();let t=0;b(e.columns||{},(e,r)=>{this.columns[r]=e.slice(),t=Math.max(t,e.length)}),this.applyRowCount(t)}applyRowCount(e){this.rowCount=e,b(this.columns,(t,r)=>{t.length!==e&&(this.columns[r]=v(t,e))})}deleteRows(e,t=1){if(t>0&&e<this.rowCount){let r=0;b(this.columns,(n,s)=>{this.columns[s]=O(n,e,t).array,r=n.length}),this.rowCount=r}f(this,"afterDeleteRows",{rowIndex:e,rowCount:t}),this.versionTag=(0,i.uniqueKey)()}getColumn(e,t){return this.columns[e]}getColumns(e,t){return(e||Object.keys(this.columns)).reduce((e,t)=>(e[t]=this.columns[t],e),{})}getRow(e,t){return(t||Object.keys(this.columns)).map(t=>this.columns[t]?.[e])}setColumn(e,t=[],r=0,n){this.setColumns({[e]:t},r,n)}setColumns(e,t,r){let n=this.rowCount;b(e,(e,t)=>{this.columns[t]=e.slice(),n=e.length}),this.applyRowCount(n),r?.silent||(f(this,"afterSetColumns"),this.versionTag=(0,i.uniqueKey)())}setRow(e,t=this.rowCount,r,n){let{columns:s}=this,o=r?this.rowCount+1:t+1,l=Object.keys(e);if(n?.addColumns!==!1)for(let e=0,t=l.length;e<t;e++){let t=l[e];s[t]||(s[t]=[])}b(s,(i,l)=>{i||n?.addColumns===!1||(i=Array(o)),i&&(r?i=O(i,t,0,!0,[e[l]??null]).array:i[t]=e[l]??null,s[l]=i)}),o>this.rowCount&&this.applyRowCount(o),n?.silent||(f(this,"afterSetRows"),this.versionTag=(0,i.uniqueKey)())}getModified(){return this.modified||this}},{splice:A,setLength:M}=N;class x extends T{constructor(e={}){super(e),this.metadata=e.metadata}clone(e,t){let r={};this.emit({type:"cloneTable",detail:t}),e||(r.columns=this.columns),this.autoId||(r.id=this.id);let n=new x(r);return e||(n.versionTag=this.versionTag,n.originalRowIndexes=this.originalRowIndexes,n.localRowIndexes=this.localRowIndexes),n.metadata={...this.metadata},this.emit({type:"afterCloneTable",detail:t,tableClone:n}),n}deleteColumns(e,t){let r=this.columns,n={},s={},i=this.modifier,o=this.rowCount;if((e=e||Object.keys(r)).length){this.emit({type:"deleteColumns",columnIds:e,detail:t});for(let t=0,i=e.length,l,a;t<i;++t)(l=r[a=e[t]])&&(n[a]=l,s[a]=Array(o)),delete r[a];return Object.keys(r).length||(this.rowCount=0,this.deleteRowIndexReferences()),i&&i.modifyTable(this),this.emit({type:"afterDeleteColumns",columns:n,columnIds:e,detail:t}),n}}deleteRowIndexReferences(){delete this.originalRowIndexes,delete this.localRowIndexes}deleteRows(e,t=1,r){let n,s,{columns:i,modifier:o}=this,l=[];if(h(e)?Array.isArray(e)?s=(n=e.filter((e,t,r)=>e>=0&&e<this.rowCount&&r.indexOf(e)===t).sort((e,t)=>t-e)).length:(n=[e],s=t):(n=[0],s=this.rowCount),this.emit({type:"deleteRows",detail:r,rowCount:s,rowIndex:e??0}),s>0){let e=Object.keys(i);for(let t=0;t<e.length;++t){let r,o=e[t],a=i[o];if(1===n.length&&s>1){let e=A(a,n[0],s);r=e.removed,i[o]=e.array}else{for(let e of(r=[],n))r.push(a[e]),A(a,e,1);r.reverse()}t||(this.rowCount=a.length);for(let e=0,n=r.length;e<n;++e)l[e]=l[e]||[],l[e][t]=r[e]}}return o&&o.modifyTable(this),this.emit({type:"afterDeleteRows",detail:r,rowCount:s,rowIndex:e??0,rows:l}),l}emit(e){["afterDeleteColumns","afterDeleteRows","afterSetCell","afterSetColumns","afterSetRows"].includes(e.type)&&(this.versionTag=(0,i.uniqueKey)()),f(this,e.type,e)}getCell(e,t){let r=this.columns[e];if(r)return r[t]}getColumn(e,t){return this.getColumns([e],t)[e]}getColumnIds(){return Object.keys(this.columns)}getColumns(e,t,r){let n=this.columns,s={};e=e||Object.keys(n);for(let i=0,o=e.length,l,a;i<o;++i)(l=n[a=e[i]])&&(t?s[a]=l:r&&!Array.isArray(l)?s[a]=Array.from(l):s[a]=l.slice());return s}getLocalRowIndex(e){let{localRowIndexes:t}=this;return t?t[e]:e}getModifier(){return this.modifier}getOriginalRowIndex(e){let{originalRowIndexes:t}=this;return t?t[e]:e}getRow(e,t){return this.getRows(e,1,t)[0]}getRowCount(){return this.rowCount}getRowIndexBy(e,t,r){let n=this.columns[e];if(n){let e=-1;if(Array.isArray(n)?e=n.indexOf(t,r):p(t)&&(e=n.indexOf(t,r)),-1!==e)return e}}getRowObject(e,t){return this.getRowObjects(e,1,t)[0]}getRowObjects(e=0,t=this.rowCount-e,r){let n=this.columns,s=Array(t);r=r||Object.keys(n);for(let i=e,o=0,l=Math.min(this.rowCount,e+t),a,u;i<l;++i,++o)for(let e of(u=s[o]={},r))a=n[e],u[e]=a?a[i]:void 0;return s}getRows(e=0,t=this.rowCount-e,r){let n=this.columns,s=Array(t);r=r||Object.keys(n);for(let i=e,o=0,l=Math.min(this.rowCount,e+t),a,u;i<l;++i,++o)for(let e of(u=s[o]=[],r))a=n[e],u.push(a?a[i]:void 0);return s}getVersionTag(){return this.versionTag}hasColumns(e){let t=this.columns;for(let r=0,n=e.length;r<n;++r)if(!t[e[r]])return!1;return!0}hasRowWith(e,t){let r=this.columns[e];return Array.isArray(r)?-1!==r.indexOf(t):!!(h(t)&&Number.isFinite(t))&&-1!==r.indexOf(+t)}on(e,t){return u(this,e,t)}changeColumnId(e,t){let r=this.columns;return!!r[e]&&(e!==t&&(r[t]=r[e],delete r[e]),!0)}setCell(e,t,r,n){let s=this.columns,i=this.modifier,o=s[e];o&&o[t]===r||(this.emit({type:"setCell",cellValue:r,columnId:e,detail:n,rowIndex:t}),o||(o=s[e]=Array(this.rowCount)),t>=this.rowCount&&(this.rowCount=t+1),o[t]=r,i&&i.modifyTable(this),this.emit({type:"afterSetCell",cellValue:r,columnId:e,detail:n,rowIndex:t}))}setColumns(e,t,r,n){let s=this.columns,i=this.modifier,o=Object.keys(e),l=this.rowCount;if(this.emit({type:"setColumns",columns:e,columnIds:o,detail:r,rowIndex:t}),h(t)||n){for(let r=0,i=o.length,a,u,h,c;r<i;++r){a=e[h=o[r]],c=Object.getPrototypeOf((u=s[h])&&n?u:a).constructor,u?c===Array?Array.isArray(u)||(u=Array.from(u)):u.length<l&&(u=new c(l)).set(s[h]):u=new c(l),s[h]=u;for(let e=t||0,r=a.length;e<r;++e)u[e]=a[e];l=Math.max(l,a.length)}this.applyRowCount(l)}else super.setColumns(e,t,c(r,{silent:!0}));i&&i.modifyTable(this),this.emit({type:"afterSetColumns",columns:e,columnIds:o,detail:r,rowIndex:t})}setModifier(e,t){let r=this;return r.emit({type:"setModifier",detail:t,modifier:e,modified:r.getModified()}),r.modifier=e,(e?e.modify(r):Promise.resolve(r)).then(r=>(r.emit({type:"afterSetModifier",detail:t,modifier:e,modified:r.getModified()}),r)).catch(t=>{throw r.emit({type:"setModifierError",error:t,modifier:e,modified:r.getModified()}),t})}setOriginalRowIndexes(e,t=!1){if(this.originalRowIndexes=e,t)return;let r=this.localRowIndexes=[];for(let t=0,n=e.length,s;t<n;++t)h(s=e[t])&&(r[s]=t)}setRow(e,t,r,n){this.setRows([e],t,r,n)}setRows(e,t=this.rowCount,r,n){let s=this.columns,i=Object.keys(s),o=this.modifier,l=e.length;this.emit({type:"setRows",detail:n,rowCount:l,rowIndex:t,rows:e});for(let n=0,o=t,a;n<l;++n,++o)if(0===Object.keys(a=e[n]).length)for(let e=0,t=i.length;e<t;++e){let t=s[i[e]];r?s[i[e]]=A(t,o,0,!0,[null]).array:t[o]=null}else if(Array.isArray(a))for(let e=0,t=i.length;e<t;++e)s[i[e]][o]=a[e];else super.setRow(a,o,r,{silent:!0});let a=r?l+e.length:t+l;if(a>this.rowCount){this.rowCount=a;for(let e=0,t=i.length;e<t;++e){let t=i[e];s[t]=M(s[t],a)}}o&&o.modifyTable(this),this.emit({type:"afterSetRows",detail:n,rowCount:l,rowIndex:t,rows:e})}}class E{static registerType(e,t){return!!e&&!E.types[e]&&!!(E.types[e]=t)}get polling(){return!!this._polling}constructor(e){this.dataTables={},this.loaded=!1,this.metadata=e.metadata||{columns:{}},this.options=e;const t=e?.dataTables;let r=0;if(e.options&&console.error("The `DataConnectorOptions.options` property was removed in Dashboards v4.0.0. Check how to upgrade your connector to use the new options structure here: https://api.highcharts.com/dashboards/#interfaces/Data_DataTableOptions.DataTableOptions"),t&&t?.length>0)for(let e=0,n=t.length;e<n;++e){const n=t[e],s=n?.key;this.dataTables[s??r]=new x(n),!s&&r++}else this.dataTables[0]=new x({id:e.id})}getTable(e){return e?this.dataTables[e]:Object.values(this.dataTables)[0]}describeColumn(e,t){let r=this.metadata.columns;r[e]=y(r[e]||{},t)}describeColumns(e){let t,r=Object.keys(e);for(;"string"==typeof(t=r.pop());)this.describeColumn(t,e[t])}getColumnOrder(){let e=this.metadata.columns,t=Object.keys(e||{});if(t.length)return t.sort((t,r)=>w(e[t].index,0)-w(e[r].index,0))}getSortedColumns(){return this.getTable().getColumns(this.getColumnOrder())}setColumnOrder(e){for(let t=0,r=e.length;t<r;++t)this.describeColumn(e[t],{index:t})}async update(e,t=!0){this.emit({type:"beforeUpdate"}),y(!0,this.options,e);let{options:r}=this;("enablePolling"in e||"dataRefreshRate"in e)&&("enablePolling"in r&&r.enablePolling?(this.stopPolling(),this.startPolling("dataRefreshRate"in r&&"number"==typeof r.dataRefreshRate?1e3*Math.max(r.dataRefreshRate,1):1e3)):this.stopPolling()),t&&await this.load(),this.emit({type:"afterUpdate"})}load(){return this.emit({type:"afterLoad"}),Promise.resolve(this)}async applyTableModifiers(){let e=this.options?.dataTables;for(let[t,r]of Object.entries(this.dataTables)){let n=e?.find(e=>e.key===t)?.dataModifier??this.options?.dataModifier,s=n&&R.types[n.type];await r.setModifier(s?new s(n):void 0)}return this}startPolling(e=1e3){let t=this;this.pollingController=new AbortController,window.clearTimeout(t._polling),t._polling=window.setTimeout(()=>t.load().catch(e=>t.emit({type:"loadError",error:e})).then(()=>{t._polling&&t.startPolling(e)}),e)}stopPolling(){this.polling&&(this?.pollingController?.abort(),window.clearTimeout(this._polling),delete this._polling)}emit(e){f(this,e.type,e)}on(e,t){return u(this,e,t)}initConverters(e,t,r){let n=0;for(let[s,i]of Object.entries(this.dataTables)){let o=t(s),l=r(o,e);i.deleteColumns(),i.setColumns(l),0===n&&(this.converter=o),n++}}}E.types={};let I=E;function P(e,t){return"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,""),t&&/^[\d\s]+$/.test(e)&&(e=e.replace(/\s/g,""))),e}let F=function(e,t){let r;if("string"==typeof e)r=t.parseDate(e);else if("number"==typeof e)r=e;else{if(e instanceof Date)return e;r=t.parseDate(""+e)}return new Date(r)},j=function(e,t){if("number"==typeof e)return e;if("boolean"==typeof e)return+!!e;if("string"==typeof e){if(e.indexOf(" ")>-1&&(e=e.replace(/\s+/g,"")),t){if(!t.test(e))return NaN;e=e.replace(t,"$1.$2")}return parseFloat(e)}return e instanceof Date?e.getDate():e?e.getRowCount():NaN},D=function(e){return""+e},L=function(e=[],t){let r={};for(let n=0,s=Math.max(t.length,e.length);n<s;++n)r[t[n]||`${n}`]=e[n]?e[n].slice():[];return r},k=function(e,t){let r="string";if("string"==typeof e){let n=P(`${e}`),s=t.decimalRegExp,i=P(n,!0);s&&(i=s.test(i)?i.replace(s,"$1.$2"):"");let o=parseFloat(i);+i===o?e=o:r=p(t.parseDate(e))?"Date":"string"}return"number"==typeof e&&(r=e>31536e6?"Date":"number"),r};class Y{static registerType(e,t){return!!e&&!Y.types[e]&&!!(Y.types[e]=t)}constructor(e){this.dateFormats={"YYYY/mm/dd":{regex:/^(\d{4})([\-\.\/])(\d{1,2})\2(\d{1,2})$/,parser:function(e){return e?Date.UTC(+e[1],e[3]-1,+e[4]):NaN}},"dd/mm/YYYY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{4})$/,parser:function(e){return e?Date.UTC(+e[4],e[3]-1,+e[1]):NaN},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{4})$/,parser:function(e){return e?Date.UTC(+e[4],e[1]-1,+e[3]):NaN}},"dd/mm/YY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{2})$/,parser:function(e){let t=new Date;if(!e)return NaN;let r=+e[4];return r>t.getFullYear()-2e3?r+=1900:r+=2e3,Date.UTC(r,e[3]-1,+e[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{2})$/,parser:function(e){return e?Date.UTC(+e[4]+2e3,e[1]-1,+e[3]):NaN}}};const t=y(Y.defaultOptions,e);let r=t.decimalPoint;("."===r||","===r)&&(r="."===r?"\\.":",",this.decimalRegExp=RegExp("^(-?[0-9]+)"+r+"([0-9]+)$")),this.options=t}convertByType(e){let t=this;return({number:e=>j(e,t.decimalRegExp),Date:e=>F(e,t),string:D})[k(e,t)].call(t,e)}deduceDateFormat(e,t,r){let n=[],s=[],i="YYYY/mm/dd",o,l=[],a=0,u=!1,h,c;for((!t||t>e.length)&&(t=e.length);a<t;a++)if(void 0!==e[a]&&e[a]&&e[a].length)for(c=0,o=e[a].trim().replace(/[\-\.\/]/g," ").split(" "),l=["","",""];c<o.length;c++)c<l.length&&(h=parseInt(o[c],10))&&(s[c]=!s[c]||s[c]<h?h:s[c],void 0!==n[c]?n[c]!==h&&(n[c]=!1):n[c]=h,h>31?h<100?l[c]="YY":l[c]="YYYY":h>12&&h<=31?(l[c]="dd",u=!0):l[c].length||(l[c]="mm"));if(u){for(c=0;c<n.length;c++)!1!==n[c]?s[c]>12&&"YY"!==l[c]&&"YYYY"!==l[c]&&(l[c]="YY"):s[c]>12&&"mm"===l[c]&&(l[c]="dd");3===l.length&&"dd"===l[1]&&"dd"===l[2]&&(l[2]="YY"),i=l.join("/")}return r&&(this.options.dateFormat=i),i}emit(e){f(this,e.type,e)}on(e,t){return u(this,e,t)}parseDate(e,t){let r=this.options,n=t||r.dateFormat,s=NaN,i,o=null;if(r.parseDate)s=r.parseDate(e);else{let t=this.dateFormats;if(n){let r=t[n];r||(r=t["YYYY/mm/dd"]),(o=e.match(r.regex))&&(s=r.parser(o))}else for(i in t){let r=t[i];if(o=e.match(r.regex)){n=i,s=r.parser(o);break}}if(!o){let t=Date.parse(e);!isNaN(t)&&(s=t-6e4*new Date(t).getTimezoneOffset(),e.includes("2001")||2001!==new Date(s).getFullYear()||(s=NaN))}}return s}}Y.defaultOptions={dateFormat:"",firstRowAsNames:!0},Y.types={};let S=Y;function V(e,t){if("position"===e.type){for(let r,n=0,s=t.length;n<s;++n)if("position"===(r=t[n]).type&&r.state===e.state&&r.column===e.column&&r.row===e.row)return n}else{let r=JSON.stringify(e.columns);for(let n,s=0,i=t.length;s<i;++s)if("range"===(n=t[s]).type&&n.state===e.state&&n.firstRow===e.firstRow&&n.lastRow===e.lastRow&&JSON.stringify(n.columns)===r)return s}return -1}let $=class{constructor(e={}){this.emittingRegister=[],this.listenerMap={},this.stateMap=e}addListener(e,t,r){let n=this.listenerMap[e]=this.listenerMap[e]||{};return(n[t]=n[t]||[]).push(r),this}buildEmittingTag(e){return("position"===e.cursor.type?[e.table.id,e.cursor.column,e.cursor.row,e.cursor.state,e.cursor.type]:[e.table.id,e.cursor.columns,e.cursor.firstRow,e.cursor.lastRow,e.cursor.state,e.cursor.type]).join("\0")}emitCursor(e,t,r,n){let s=e.id,i=t.state,o=this.listenerMap[s]&&this.listenerMap[s][i];if(o){let i=this.stateMap[s]=this.stateMap[s]??{},l=i[t.state]||[];n&&(l.length||(i[t.state]=l),-1===V(t,l)&&l.push(t));let a={cursor:t,cursors:l,table:e};r&&(a.event=r);let u=this.emittingRegister,h=this.buildEmittingTag(a);if(u.indexOf(h)>=0)return this;try{this.emittingRegister.push(h);for(let e=0,t=o.length;e<t;++e)o[e].call(this,a)}finally{let e=this.emittingRegister.indexOf(h);e>=0&&this.emittingRegister.splice(e,1)}}return this}remitCursor(e,t){let r=this.stateMap[e]&&this.stateMap[e][t.state];if(r){let e=V(t,r);e>=0&&r.splice(e,1)}return this}removeListener(e,t,r){let n=this.listenerMap[e]&&this.listenerMap[e][t];if(n){let e=n.indexOf(r);e>=0&&n.splice(e,1)}return this}};class U{constructor(e){this.options=y(U.defaultOptions,e),this.connectors={},this.waiting={}}emit(e){f(this,e.type,e)}getConnector(e){let t=this.connectors[e];if(t?.loaded)return Promise.resolve(t);let r=this.waiting[e];if(!r){r=this.waiting[e]=[];let t=this.getConnectorOptions(e);if(!t)throw Error(`Connector '${e}' not found.`);this.loadConnector(t).then(t=>{delete this.waiting[e];for(let e=0,n=r.length;e<n;++e)r[e][0](t)}).catch(t=>{delete this.waiting[e];for(let e=0,n=r.length;e<n;++e)r[e][1](t)})}return new Promise((e,t)=>{r.push([e,t])})}getConnectorIds(){let e=this.options.connectors,t=[];for(let r=0,n=e.length;r<n;++r)t.push(e[r].id);return t}getConnectorOptions(e){let t=this.options.connectors;for(let r=0,n=t.length;r<n;++r)if(t[r].id===e)return t[r]}isNewConnector(e){return!this.connectors[e]}loadConnector(e){return new Promise((t,r)=>{this.emit({type:"load",options:e});let n=I.types[e.type];if(!n)throw Error(`Connector type not found. (${e.type})`);let s=this.connectors[e.id]=new n(e);s.load().then(({converter:r})=>{s.converter=r,s.loaded=!0,this.emit({type:"afterLoad",options:e}),t(s)}).catch(r)})}cancelPendingRequests(){let{connectors:e}=this;for(let t of Object.keys(e))e[t].stopPolling()}on(e,t){return u(this,e,t)}async setConnectorOptions(e,t){let r=this.options.connectors,n=this.connectors;this.emit({type:"setConnectorOptions",options:e});for(let t=0,n=r.length;t<n;++t)if(r[t].id===e.id){r.splice(t,1);break}let s=n[e.id];s&&(t?await s.update(e,!0):(s.stopPolling(),s=void 0,delete n[e.id])),s||r.push(e),this.emit({type:"afterSetConnectorOptions",options:e})}}U.defaultOptions={connectors:[]};let H=/^(?:FALSE|TRUE)/,_=/^[+\-]?\d+(?:\.\d+)?(?:e[+\-]\d+)?/,B=/^[+\-]?\d+(?:,\d+)?(?:e[+\-]\d+)?/,Z=/^([A-Z][A-Z\d\.]*)\(/,K=/^(?:[+\-*\/^<=>]|<=|=>)/,X=/^(\$?[A-Z]+)(\$?\d+)\:(\$?[A-Z]+)(\$?\d+)/,q=/^R(\d*|\[\d+\])C(\d*|\[\d+\])\:R(\d*|\[\d+\])C(\d*|\[\d+\])/,G=/^(\$?[A-Z]+)(\$?\d+)(?![\:C])/,J=/^R(\d*|\[\d+\])C(\d*|\[\d+\])(?!\:)/;function W(e){let t=0;for(let r=0,n=e.length,s,i=1;r<n;++r){if("("===(s=e[r])){t||(i=r+1),++t;continue}if(")"===s&&!--t)return e.substring(i,r)}if(t>0){let e=Error("Incomplete parentheses.");throw e.name="FormulaParseError",e}return""}function z(e){let t=-1;for(let r=0,n=e.length,s,i=!1;r<n;++r){if("\\"===(s=e[r])){i=!i;continue}if(i){i=!1;continue}if('"'===s)if(!(t<0))return e.substring(t+1,r);else t=r}let r=Error("Incomplete string.");throw r.name="FormulaParseError",r}function Q(e,t){let r;if(r=e.match(q)){let e=""===r[2]||"["===r[2][0],t=""===r[1]||"["===r[1][0],n=""===r[4]||"["===r[4][0],s=""===r[3]||"["===r[3][0],i={type:"range",beginColumn:e?parseInt(r[2].substring(1,-1)||"0",10):parseInt(r[2],10)-1,beginRow:t?parseInt(r[1].substring(1,-1)||"0",10):parseInt(r[1],10)-1,endColumn:n?parseInt(r[4].substring(1,-1)||"0",10):parseInt(r[4],10)-1,endRow:s?parseInt(r[3].substring(1,-1)||"0",10):parseInt(r[3],10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),n&&(i.endColumnRelative=!0),s&&(i.endRowRelative=!0),i}if(r=e.match(X)){let e="$"!==r[1][0],t="$"!==r[2][0],n="$"!==r[3][0],s="$"!==r[4][0],i={type:"range",beginColumn:er(e?r[1]:r[1].substring(1))-1,beginRow:parseInt(t?r[2]:r[2].substring(1),10)-1,endColumn:er(n?r[3]:r[3].substring(1))-1,endRow:parseInt(s?r[4]:r[4].substring(1),10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),n&&(i.endColumnRelative=!0),s&&(i.endRowRelative=!0),i}let n=et(e,t);return 1===n.length&&"string"!=typeof n[0]?n[0]:n}function ee(e){let t=e.length,r=e[t-2];return"-"===e[t-1]&&"string"==typeof r&&!!r.match(/\*|\/|\^/)}function et(e,t){let r=t?B:_,n=[],s,i=("="===e[0]?e.substring(1):e).trim();for(;i;){if(s=i.match(J)){let e=""===s[2]||"["===s[2][0],t=""===s[1]||"["===s[1][0],r={type:"reference",column:e?parseInt(s[2].substring(1,-1)||"0",10):parseInt(s[2],10)-1,row:t?parseInt(s[1].substring(1,-1)||"0",10):parseInt(s[1],10)-1};e&&(r.columnRelative=!0),t&&(r.rowRelative=!0),ee(n)&&(n.pop(),r.isNegative=!0),n.push(r),i=i.substring(s[0].length).trim();continue}if(s=i.match(G)){let e="$"!==s[1][0],t="$"!==s[2][0],r={type:"reference",column:er(e?s[1]:s[1].substring(1))-1,row:parseInt(t?s[2]:s[2].substring(1),10)-1};e&&(r.columnRelative=!0),t&&(r.rowRelative=!0),ee(n)&&(n.pop(),r.isNegative=!0),n.push(r),i=i.substring(s[0].length).trim();continue}if(s=i.match(K)){n.push(s[0]),i=i.substring(s[0].length).trim();continue}if(s=i.match(H)){n.push("TRUE"===s[0]),i=i.substring(s[0].length).trim();continue}if(s=i.match(r)){let e=parseFloat(s[0]);ee(n)&&(n.pop(),e=-e),n.push(e),i=i.substring(s[0].length).trim();continue}if('"'===i[0]){let e=z(i);n.push(e.substring(1,-1)),i=i.substring(e.length+2).trim();continue}if(s=i.match(Z)){let e=W(i=i.substring(s[1].length).trim());n.push({type:"function",name:s[1],args:function(e,t){let r=[],n=t?";":",",s=0,i="";for(let o=0,l=e.length,a;o<l;++o)if((a=e[o])===n&&!s&&i)r.push(Q(i,t)),i="";else if('"'!==a||s||i)" "!==a&&(i+=a,"("===a?++s:")"===a&&--s);else{let t=z(e.substring(o));r.push(t),o+=t.length+1}return!s&&i&&r.push(Q(i,t)),r}(e,t)}),i=i.substring(e.length+2).trim();continue}if("("===i[0]){let e=W(i);if(e){n.push(et(e,t)),i=i.substring(e.length+2).trim();continue}}let o=e.length-i.length,l=Error("Unexpected character `"+e.substring(o,o+1)+"` at position "+(o+1)+". (`..."+e.substring(o-5,o+6)+"...`)");throw l.name="FormulaParseError",l}return n}function er(e){let t=0;for(let r=0,n=e.length,s,i=e.length-1;r<n;++r)(s=e.charCodeAt(r))>=65&&s<=90&&(t+=(s-64)*Math.pow(26,i)),--i;return t}let en={parseFormula:et},es=["+","-","*","/","^","=","<","<=",">",">="],ei={isFormula:function(e){return Array.isArray(e)},isFunction:function(e){return"object"==typeof e&&!Array.isArray(e)&&"function"===e.type},isOperator:function(e){return"string"==typeof e&&es.indexOf(e)>=0},isRange:function(e){return"object"==typeof e&&!Array.isArray(e)&&"range"===e.type},isReference:function(e){return"object"==typeof e&&!Array.isArray(e)&&"reference"===e.type},isValue:function(e){return"boolean"==typeof e||"number"==typeof e||"string"==typeof e}},{isFormula:eo,isFunction:el,isOperator:ea,isRange:eu,isReference:eh,isValue:ec}=ei,ef=/ */,ed=Number.MAX_VALUE/1.000000000001,ep=Number.MAX_VALUE/1.000000000002,em=Number.MAX_VALUE,eg={"^":3,"*":2,"/":2,"+":1,"-":1,"=":0,"<":0,"<=":0,">":0,">=":0},ey={},eb=/^[A-Z][A-Z\.]*$/;function ew(e){switch(typeof e){case"boolean":return e?em:ed;case"string":return ep;case"number":return e;default:return NaN}}function eC(e){return"string"==typeof e?e.toLowerCase().replace(ef,"\0"):e}function eR(e){switch(typeof e){case"boolean":return+!!e;case"string":return parseFloat(e.replace(",","."));case"number":return e;default:return NaN}}function eN(e,t){return ec(e)?e:eu(e)?t&&ev(e,t)||[]:el(e)?eM(e,t):eA(eo(e)?e:[e],t)}function ev(e,t){let r=t.getColumnIds().slice(e.beginColumn,e.endColumn+1),n=[];for(let s=0,i=r.length,o;s<i;++s){let i=t.getColumn(r[s],!0)||[];for(let l=e.beginRow,a=e.endRow+1;l<a;++l)"string"==typeof(o=i[l])&&"="===o[0]&&t!==t.getModified()&&(o=t.getModified().getCell(r[s],l)),n.push(ec(o)?o:NaN)}return n}function eO(e,t){let r=t.getColumnIds()[e.column];if(r){let n=t.getCell(r,e.row);if("string"==typeof n&&"="===n[0]&&t!==t.getModified()){let n=t.getModified().getCell(r,e.row);return ec(n)?n:NaN}if(ec(n))return e.isNegative?-n:n}return NaN}function eT(e,t){(e.length<2||t.length<1)&&e.push(NaN);let r=e.pop(),n=e.pop(),s=t.pop();h(r)&&h(n)&&h(s)?e.push(function(e,t,r){let n;switch(e){case"=":return eC(t)===eC(r);case"<":if(typeof t==typeof r)return eC(t)<eC(r);return ew(t)<ew(r);case"<=":if(typeof t==typeof r)return eC(t)<=eC(r);return ew(t)<=ew(r);case">":if(typeof t==typeof r)return eC(t)>eC(r);return ew(t)>ew(r);case">=":if(typeof t==typeof r)return eC(t)>=eC(r);return ew(t)>=ew(r)}switch(t=eR(t),r=eR(r),e){case"+":n=t+r;break;case"-":n=t-r;break;case"*":n=t*r;break;case"/":n=t/r;break;case"^":n=Math.pow(t,r);break;default:return NaN}return n%1?Math.round(1e9*n)/1e9:n}(s,n,r)):e.push(NaN)}function eA(e,t){let r=[],n=[],s=!0;for(let i=0,o=e.length;i<o;++i){let o,l=e[i];if(ea(l)){if(s&&"-"===l)r.push(0),n.push("-"),s=!0;else{for(;n.length&&eg[n[n.length-1]]>=eg[l];)eT(r,n);n.push(l),s=!0}continue}if(ec(l))o=l;else if(eh(l))o=t?eO(l,t):NaN;else if(el(l)){let e=eM(l,t);o=ec(e)?e:NaN}else eo(l)&&(o=eA(l,t));if(void 0===o)return NaN;r.push(o),s=!1}for(;n.length;)eT(r,n);return 1!==r.length?NaN:r[0]}function eM(e,t,r){let n=ey[e.name];if(n)try{return n(e.args,t)}catch{return NaN}let s=Error(`Function "${e.name}" not found.`);throw s.name="FormulaProcessError",s}let ex={asNumber:eR,getArgumentValue:eN,getArgumentsValues:function(e,t){let r=[];for(let n=0,s=e.length;n<s;++n)r.push(eN(e[n],t));return r},getRangeValues:ev,getReferenceValue:eO,processFormula:eA,processorFunctions:ey,registerProcessorFunction:function(e,t){return eb.test(e)&&!ey[e]&&!!(ey[e]=t)},translateReferences:function e(t,r=0,n=0){for(let s=0,i=t.length,o;s<i;++s)Array.isArray(o=t[s])?e(o,r,n):el(o)?e(o.args,r,n):eu(o)?(o.beginColumnRelative&&(o.beginColumn+=r),o.beginRowRelative&&(o.beginRow+=n),o.endColumnRelative&&(o.endColumn+=r),o.endRowRelative&&(o.endRow+=n)):eh(o)&&(o.columnRelative&&(o.column+=r),o.rowRelative&&(o.row+=n));return t}},{getArgumentValue:eE}=ex;ex.registerProcessorFunction("ABS",function(e,t){let r=eE(e[0],t);switch(typeof r){case"number":return Math.abs(r);case"object":{let e=[];for(let t=0,n=r.length,s;t<n;++t){if("number"!=typeof(s=r[t]))return NaN;e.push(Math.abs(s))}return e}default:return NaN}});let{getArgumentValue:eI}=ex;ex.registerProcessorFunction("AND",function e(t,r){for(let n=0,s=t.length,i;n<s;++n)if(!(i=eI(t[n],r))||"object"==typeof i&&!e(i,r))return!1;return!0});let{getArgumentsValues:eP}=ex;ex.registerProcessorFunction("AVERAGE",function(e,t){let r=eP(e,t),n=0,s=0;for(let e=0,t=r.length,i;e<t;++e)switch(typeof(i=r[e])){case"number":isNaN(i)||(++n,s+=i);break;case"object":for(let e=0,t=i.length,r;e<t;++e)"number"!=typeof(r=i[e])||isNaN(r)||(++n,s+=r)}return n?s/n:0});let{getArgumentValue:eF}=ex;ex.registerProcessorFunction("AVERAGEA",function(e,t){let r=0,n=0;for(let s=0,i=e.length,o;s<i;++s)switch(typeof(o=eF(e[s],t))){case"boolean":++r,n+=+!!o;continue;case"number":isNaN(o)||(++r,n+=o);continue;case"string":++r;continue;default:for(let e=0,t=o.length,s;e<t;++e)switch(typeof(s=o[e])){case"boolean":++r,n+=+!!s;continue;case"number":isNaN(s)||(++r,n+=s);continue;case"string":++r;continue}continue}return r?n/r:0}),ex.registerProcessorFunction("COUNT",function e(t,r){let n=ex.getArgumentsValues(t,r),s=0;for(let t=0,i=n.length,o;t<i;++t)switch(typeof(o=n[t])){case"number":!isNaN(o)&&++s;break;case"object":s+=e(o,r)}return s}),ex.registerProcessorFunction("COUNTA",function e(t,r){let n=ex.getArgumentsValues(t,r),s=0;for(let t=0,i=n.length,o;t<i;++t){switch(typeof(o=n[t])){case"number":if(isNaN(o))continue;break;case"object":s+=e(o,r);continue;case"string":if(!o)continue}++s}return s});let{getArgumentValue:ej}=ex;ex.registerProcessorFunction("IF",function(e,t){return ej(e[0],t)?ej(e[1],t):ej(e[2],t)});let{getArgumentValue:eD}=ex;ex.registerProcessorFunction("ISNA",function(e,t){let r=eD(e[0],t);return"number"!=typeof r||isNaN(r)});let{getArgumentsValues:eL}=ex;ex.registerProcessorFunction("MAX",function e(t,r){let n=eL(t,r),s=-1/0;for(let t=0,r=n.length,i;t<r;++t)switch(typeof(i=n[t])){case"number":i>s&&(s=i);break;case"object":(i=e(i))>s&&(s=i)}return isFinite(s)?s:0}),ex.registerProcessorFunction("MEDIAN",function(e,t){let r=[],n=ex.getArgumentsValues(e,t);for(let e=0,t=n.length,s;e<t;++e)switch(typeof(s=n[e])){case"number":isNaN(s)||r.push(s);break;case"object":for(let e=0,t=s.length,n;e<t;++e)"number"!=typeof(n=s[e])||isNaN(n)||r.push(n)}let s=r.length;if(!s)return NaN;let i=Math.floor(s/2);return s%2?r[i]:(r[i-1]+r[i])/2});let{getArgumentsValues:ek}=ex;ex.registerProcessorFunction("MIN",function e(t,r){let n=ek(t,r),s=1/0;for(let t=0,r=n.length,i;t<r;++t)switch(typeof(i=n[t])){case"number":i<s&&(s=i);break;case"object":(i=e(i))<s&&(s=i)}return isFinite(s)?s:0});let{getArgumentValue:eY}=ex;function eS(e,t){let r={},n=ex.getArgumentsValues(e,t);for(let e=0,t=n.length,s;e<t;++e)switch(typeof(s=n[e])){case"number":isNaN(s)||(r[s]=(r[s]||0)+1);break;case"object":for(let e=0,t=s.length,n;e<t;++e)"number"!=typeof(n=s[e])||isNaN(n)||(r[n]=(r[n]||0)+1)}return r}function eV(e,t){let r=eS(e,t),n=Object.keys(r);if(!n.length)return NaN;let s=parseFloat(n[0]),i=r[n[0]];for(let e=1,t=n.length,o,l,a;e<t;++e)i<(a=r[o=n[e]])?(s=parseFloat(o),i=a):i===a&&s>(l=parseFloat(o))&&(s=l,i=a);return i>1?s:NaN}ex.registerProcessorFunction("MOD",function(e,t){let r=eY(e[0],t),n=eY(e[1],t);return("object"==typeof r&&(r=r[0]),"object"==typeof n&&(n=n[0]),"number"!=typeof r||"number"!=typeof n||0===n)?NaN:r%n}),ex.registerProcessorFunction("MODE",eV),ex.registerProcessorFunction("MODE.MULT",function(e,t){let r=eS(e,t),n=Object.keys(r);if(!n.length)return NaN;let s=[parseFloat(n[0])],i=r[n[0]];for(let e=1,t=n.length,o,l;e<t;++e)i<(l=r[o=n[e]])?(s=[parseFloat(o)],i=l):i===l&&s.push(parseFloat(o));return i>1?s:NaN}),ex.registerProcessorFunction("MODE.SNGL",eV);let{getArgumentValue:e$}=ex;ex.registerProcessorFunction("NOT",function(e,t){let r=e$(e[0],t);switch("object"==typeof r&&(r=r[0]),typeof r){case"boolean":case"number":return!r}return NaN});let{getArgumentValue:eU}=ex;ex.registerProcessorFunction("OR",function e(t,r){for(let n=0,s=t.length,i;n<s;++n)if("object"==typeof(i=eU(t[n],r))){if(e(i,r))return!0}else if(i)return!0;return!1});let{getArgumentsValues:eH}=ex;ex.registerProcessorFunction("PRODUCT",function e(t,r){let n=eH(t,r),s=1,i=!1;for(let t=0,o=n.length,l;t<o;++t)switch(typeof(l=n[t])){case"number":isNaN(l)||(i=!0,s*=l);break;case"object":i=!0,s*=e(l,r)}return i?s:0}),ex.registerProcessorFunction("SUM",function e(t,r){let n=ex.getArgumentsValues(t,r),s=0;for(let t=0,i=n.length,o;t<i;++t)switch(typeof(o=n[t])){case"number":isNaN(o)||(s+=o);break;case"object":s+=e(o,r)}return s});let{getArgumentValue:e_}=ex;ex.registerProcessorFunction("XOR",function(e,t){for(let r=0,n=e.length,s,i;r<n;++r)switch(typeof(i=e_(e[r],t))){case"boolean":case"number":if(void 0===s)s=!!i;else if(!!i!==s)return!0;break;case"object":for(let e=0,t=i.length,r;e<t;++e)switch(typeof(r=i[e])){case"boolean":case"number":if(void 0===s)s=!!r;else if(!!r!==s)return!0}}return!1});let eB={...en,...ex,...ei};class eZ extends S{constructor(e){const t=y(eZ.defaultOptions,e);super(t),this.headers=[],this.dataTypes=[],this.options=t}parse(e,t){let r=this.dataTypes,n=y(this.options,e),{beforeParse:s,lineDelimiter:i,firstRowAsNames:o,itemDelimiter:l}=n,a,u=0,{csv:h,startRow:c,endRow:f}=n,d,p=[];if(this.emit({type:"parse",columns:p,detail:t,headers:this.headers}),h&&s&&(h=s(h)),h){if(a=h.replace(/\r\n|\r/g,"\n").split(i||"\n"),(!c||c<0)&&(c=0),(!f||f>=a.length)&&(f=a.length-1),l||(this.guessedItemDelimiter=this.guessDelimiter(a)),o){let e=a[0].split(l||this.guessedItemDelimiter||",");for(let t=0;t<e.length;t++)e[t]=e[t].trim().replace(/^["']|["']$/g,"");this.headers=e,c++}let e=0;for(u=c;u<=f;u++)"#"===a[u][0]?e++:this.parseCSVRow(p,a[u],u-c-e);r.length&&r[0].length&&"date"===r[0][1]&&!this.options.dateFormat&&this.deduceDateFormat(p[0],null,!0);for(let e=0,t=p.length;e<t;++e){d=p[e];for(let t=0,r=d.length;t<r;++t)if(d[t]&&"string"==typeof d[t]){let r=this.convertByType(d[t]);r instanceof Date&&(r=r.getTime()),p[e][t]=r}}}return p.forEach(e=>{e.length=Math.max(...p.map(e=>e.length))}),this.emit({type:"afterParse",columns:p,detail:t,headers:this.headers}),L(p,this.headers)}parseCSVRow(e,t,r){let n=this,s=n.dataTypes,{startColumn:i,endColumn:o}=n.options,l=n.options.itemDelimiter||n.guessedItemDelimiter,{decimalPoint:a}=n.options;a&&a!==l||(a=n.guessedDecimalPoint||".");let u=0,h="",c="",f=0,d=0,p=e=>{h=t[e]},m=e=>{s.length<d+1&&s.push([e]),s[d][s[d].length-1]!==e&&s[d].push(e)},g=()=>{if(i>f||f>o){++f,c="";return}if("string"==typeof c){let e=parseFloat(c);!isNaN(e)&&isFinite(Number(c))?(c=e,m("number")):isNaN(Date.parse(c))?m("string"):(c=c.replace(/\//g,"-"),m("date"))}else m("number");if(e.length<d+1&&e.push([]),"number"!=typeof c&&"number"!==k(c,n)&&a){let e=c;"number"!==k(c=c.replace(a,"."),n)&&(c=e)}e[d][r]=c,c="",++d,++f};if(t.trim().length&&"#"!==t.trim()[0]){for(;u<t.length;u++){if(p(u),"#"===h&&!/^#[A-F\d]{3,3}|[A-F\d]{6,6}/i.test(t.substring(u)))return void g();if('"'===h)for(p(++u);u<t.length&&'"'!==h;)c+=h,p(++u);else h===l?g():c+=h}g()}}guessDelimiter(e){let t=0,r=0,n,s={",":0,";":0," ":0},i=e.length;for(let n=0;n<i;n++){let i=!1,o,l,a,u="";if(n>13)break;let h=e[n];for(let e=0;e<h.length&&(o=h[e],l=h[e+1],a=h[e-1],"#"!==o);e++){if('"'===o)if(i){if('"'!==a&&'"'!==l){for(;" "===l&&e<h.length;)l=h[++e];void 0!==s[l]&&s[l]++,i=!1}}else i=!0;else void 0!==s[o]?(isNaN(Date.parse(u=u.trim()))?(isNaN(Number(u))||!isFinite(Number(u)))&&s[o]++:s[o]++,u=""):u+=o;","===o&&r++,"."===o&&t++}}return s[";"]>s[","]?n=";":(s[","]>s[";"],n=","),t>r?this.guessedDecimalPoint=".":this.guessedDecimalPoint=",",n}}eZ.defaultOptions={...S.defaultOptions,lineDelimiter:"\n",startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},S.registerType("CSV",eZ);class eK extends I{constructor(e){const t=y(eK.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){f(this,e.type,e)}load(e){let t=this,r=t.options,{csv:n,csvURL:s,dataTables:i,decimalPoint:o}=r;return t.emit({type:"load",csv:n}),Promise.resolve(s?fetch(s,{signal:t?.pollingController?.signal}).then(e=>e.text()):n||"").then(e=>(e&&this.initConverters(e,e=>{let{firstRowAsNames:t=r.firstRowAsNames,beforeParse:n=r.beforeParse}=i?.find(t=>t.key===e)||{};return new eZ(y(r,{decimalPoint:o,firstRowAsNames:t,beforeParse:n}))},(e,t)=>e.parse({csv:t})),t.applyTableModifiers().then(()=>e))).then(r=>(t.emit({type:"afterLoad",detail:e,csv:r}),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}eK.defaultOptions={id:"csv-connector",type:"CSV",csv:"",csvURL:"",enablePolling:!1,dataRefreshRate:1,firstRowAsNames:!0},I.registerType("CSV",eK);class eX extends S{constructor(e){const t=y(eX.defaultOptions,e);super(t),this.headerColumnIds=[],this.headers=[],this.options=t}parse(e,t){let{beforeParse:r,orientation:n,firstRowAsNames:s,columnIds:i}=e=y(this.options,e),o=e.data;if(!o)return{};this.headers=[];let l=[];return this.emit({type:"parse",columns:l,detail:t,headers:this.headers}),r&&(o=r(o)),o=o.slice(),"columns"===n?this.parseColumnsOrientation(l,o,s,i):"rows"===n&&this.parseRowsOrientation(l,o,s,i),this.emit({type:"afterParse",columns:l,detail:t,headers:this.headers}),L(l,this.headers)}parseColumnsOrientation(e,t,r,n){for(let s=0,o=t.length;s<o;s++){let o=t[s];if(!Array.isArray(o))return;Array.isArray(this.headers)?(r?this.headers.push(`${o.shift()}`):n&&Array.isArray(n)&&this.headers.push(n[s]),e.push(o)):(0,i.error)("JSONConverter: Invalid `columnIds` option.",!1)}}parseRowsOrientation(e,t,r,n){r?this.headers=t.shift():n&&(this.headerColumnIds=n);for(let s=0,o=t.length;s<o;s++){let o=t[s];m(o)||(o=this.convertItemToRow(o,n));for(let t=0,n=o.length;t<n;t++)e.length<t+1&&e.push([]),e[t].push(o[t]),r||0!==s||(Array.isArray(this.headerColumnIds)?this.headers.push(this.headerColumnIds[t]||t.toString()):(0,i.error)("JSONConverter: Invalid `columnIds` option.",!1))}}convertItemToRow(e,t){let r=this;if(t&&!Array.isArray(t)){let n=[];return b(t,(t,s)=>{n.push(t.reduce((e,t)=>e[t],e)),0>r.headers.indexOf(s)&&r.headers.push(s)}),n}return r.headerColumnIds=Object.keys(e),Object.values(e)}}eX.defaultOptions={...S.defaultOptions,orientation:"rows"},S.registerType("JSON",eX);class eq extends I{constructor(e){const t=y(eq.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){f(this,e.type,e)}load(e){let t=this,r=t.options,{data:n,dataUrl:s,dataTables:i}=r;return t.emit({type:"load",detail:e,data:n}),Promise.resolve(s?fetch(s,{signal:t?.pollingController?.signal}).then(e=>e.json()).catch(r=>{t.emit({type:"loadError",detail:e,error:r}),console.warn(`Unable to fetch data from ${s}.`)}):n||[]).then(async e=>(e&&this.initConverters(e,t=>{let{columnIds:n=r.columnIds,firstRowAsNames:s=r.firstRowAsNames,orientation:o=r.orientation,beforeParse:l=r.beforeParse}=i?.find(e=>e.key===t)||{};return new eX({data:e,columnIds:n,firstRowAsNames:s,orientation:o,beforeParse:l})},(e,t)=>e.parse({data:t})),t.applyTableModifiers().then(()=>e??[]))).then(r=>(t.emit({type:"afterLoad",detail:e,data:r}),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}eq.defaultOptions={type:"JSON",id:"json-connector",data:[],enablePolling:!1,dataRefreshRate:0,firstRowAsNames:!0,orientation:"rows"},I.registerType("JSON",eq);class eG extends S{constructor(e){const t=y(eG.defaultOptions,e);super(t),this.header=[],this.options=t}parse(e,t){let r,n=y(this.options,e),s=(n.json?.values||[]).map(e=>e.slice());if(0===s.length)return{};this.header=[],this.emit({type:"parse",columns:[],detail:t,headers:this.header});let{beforeParse:o,json:l}=n;o&&l&&(s=o(l.values));for(let e=0,t=s.length;e<t;e++){r=s[e],this.header[e]=n.firstRowAsNames?`${r.shift()}`:(0,i.uniqueKey)();for(let t=0,n=r.length;t<n;++t){var a;let n=r[t];a=n,"[object Date]"===Object.prototype.toString.call(a)&&(n=n.getTime()),s[e][t]=n}}return this.emit({type:"afterParse",columns:s,detail:t,headers:this.header}),L(s,this.header)}}eG.defaultOptions={...S.defaultOptions},S.registerType("GoogleSheets",eG);class eJ extends I{constructor(e){const t=y(eJ.defaultOptions,e);super(t),this.options=t}emit(e){f(this,e.type,e)}load(e){let t=this,r=t.options,{dataRefreshRate:n,enablePolling:s,googleAPIKey:i,googleSpreadsheetKey:o,dataTables:l}=r,a=function(e,t,r={}){let n=new URL(`https://sheets.googleapis.com/v4/spreadsheets/${t}/values/`),s=r.onlyColumnIds?"A1:Z1":function(e={}){let{endColumn:t,endRow:r,googleSpreadsheetRange:n,startColumn:s,startRow:i}=e;return n||(eW[s||0]||"A")+(Math.max(i||0,0)+1)+":"+(eW[w(t,25)]||"Z")+(r?Math.max(r,0):"Z")}(r);n.pathname+=s;let i=n.searchParams;return i.set("alt","json"),r.onlyColumnIds||(i.set("dateTimeRenderOption","FORMATTED_STRING"),i.set("majorDimension","COLUMNS"),i.set("valueRenderOption","UNFORMATTED_VALUE")),i.set("prettyPrint","false"),i.set("key",e),n.href}(i,o,r);if(t.emit({type:"load",detail:e,url:a}),!URL.canParse(a))throw Error("Invalid URL: "+a);return fetch(a,{signal:t?.pollingController?.signal}).then(e=>e.json()).then(e=>{if("object"==typeof e&&e&&"object"==typeof e.error&&e.error&&"number"==typeof e.error.code&&"string"==typeof e.error.message&&"string"==typeof e.error.status)throw Error(e.error.message);return this.initConverters(e,e=>{let{firstRowAsNames:t=r.firstRowAsNames,beforeParse:n=r.beforeParse}=l?.find(t=>t.key===e)||{};return new eG({firstRowAsNames:t,beforeParse:n})},(e,t)=>e.parse({json:t})),t.applyTableModifiers()}).then(()=>(t.emit({type:"afterLoad",detail:e,url:a}),s&&setTimeout(()=>t.load(),1e3*Math.max(n||0,1)),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}eJ.defaultOptions={id:"google-sheets-connector",type:"GoogleSheets",googleAPIKey:"",googleSpreadsheetKey:"",enablePolling:!1,dataRefreshRate:2,firstRowAsNames:!0};let eW="ABCDEFGHIJKLMNOPQRSTUVWXYZ";I.registerType("GoogleSheets",eJ);class ez extends S{constructor(e){const t=y(ez.defaultOptions,e);super(t),this.headers=[],this.options=t,t.tableElement&&(this.tableElement=t.tableElement,this.tableElementID=t.tableElement.id)}export(e,t=this.options){let r=!1!==t.firstRowAsNames,n=t.useMultiLevelHeaders,s=e.getSortedColumns(),i=Object.keys(s),o=[],l=i.length,a=[],u="";if(r){let e=[];if(n){for(let t of i){let r=s[t];Array.isArray(r)||(r=Array.from(r));let n=(r.shift()||"").toString();s[t]=r,e.push(n)}u=this.getTableHeaderHTML(i,e,t)}else u=this.getTableHeaderHTML(void 0,i,t)}for(let e=0;e<l;e++){let t=s[i[e]],r=t.length;for(let n=0;n<r;n++){let r=t[n];a[n]||(a[n]=[]),"string"!=typeof r&&"number"!=typeof r&&void 0!==r&&(r=(r||"").toString()),a[n][e]=this.getCellHTMLFromValue(e?"td":"th",null,e?"":'scope="row"',r),e===l-1&&o.push("<tr>"+a[n].join("")+"</tr>")}}let h="";return t.tableCaption&&(h='<caption class="highcharts-table-caption">'+t.tableCaption+"</caption>"),"<table>"+h+u+"<tbody>"+o.join("")+"</tbody></table>"}getCellHTMLFromValue(e,t,r,n,s){let i=n,o="text"+(t?" "+t:"");return"number"==typeof i?(i=i.toString(),","===s&&(i=i.replace(".",s)),o="number"):n||(i="",o="empty"),"<"+e+(r?" "+r:"")+' class="'+o+'">'+i+"</"+e+">"}getTableHeaderHTML(e=[],t=[],r=this.options){let{useMultiLevelHeaders:n,useRowspanHeaders:s}=r,i="<thead>",o=0,l=t&&t.length,a,u=0,h;if(n&&e&&t&&!function(e,t){let r=e.length;if(t.length!==r)return!1;for(;--r;)if(e[r]!==t[r])return!1;return!0}(e,t)){for(i+="<tr>";o<l;++o)(a=e[o])===e[o+1]?++u:u?(i+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col" colspan="'+(u+1)+'"',a),u=0):(a===t[o]?s?(h=2,t.splice(o,1)):(h=1,t[o]=""):h=1,i+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col"'+(h>1?' valign="top" rowspan="'+h+'"':""),a));i+="</tr>"}if(t){for(i+="<tr>",o=0,l=t.length;o<l;++o)void 0!==t[o]&&(i+=this.getCellHTMLFromValue("th",null,'scope="col"',t[o]));i+="</tr>"}return i+"</thead>"}parse(e,t){let r=[],n=[],s=y(this.options,e),{endRow:i,startColumn:o,endColumn:l,firstRowAsNames:a}=s,u=s.tableElement||this.tableElement;if(!(u instanceof HTMLElement))return this.emit({type:"parseError",columns:r,detail:t,headers:n,error:"Not a valid HTML Table"}),{};this.tableElement=u,this.tableElementID=u.id,this.emit({type:"parse",columns:r,detail:t,headers:this.headers});let h=u.getElementsByTagName("tr"),c=h.length,f=0,d,{startRow:p}=s;if(a&&c){let e=h[0].children,t=e.length;for(let r=o;r<t&&!(r>l);r++)("TD"===(d=e[r]).tagName||"TH"===d.tagName)&&n.push(d.innerHTML);p++}for(;f<c;){if(f>=p&&f<=i){let e=h[f].children,t=e.length,n=0;for(;n<t;){let t=n-o,s=r[t];if(("TD"===(d=e[n]).tagName||"TH"===d.tagName)&&n>=o&&n<=l){r[t]||(r[t]=[]);let e=this.convertByType(d.innerHTML);e instanceof Date&&(e=e.getTime()),r[t][f-p]=e;let n=1;for(;f-p>=n&&void 0===s[f-p-n];)s[f-p-n]=null,n++}n++}}f++}return this.headers=n,this.emit({type:"afterParse",columns:r,detail:t,headers:n}),L(r,this.headers)}}ez.defaultOptions={...S.defaultOptions,useRowspanHeaders:!0,useMultiLevelHeaders:!0,startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},S.registerType("HTMLTable",ez);let{win:eQ}=o();class e0 extends I{constructor(e){const t=y(e0.defaultOptions,e);super(t),this.options=t,this.converter=new ez(t)}async load(e){let t,r=this.options,n=this.converter,s=this.getTable(),i=r.htmlTable;if(this.emit({type:"load",detail:e}),"string"==typeof i?(this.tableID=i,t=eQ.document.getElementById(i)):(t=i,this.tableID=t.id),this.tableElement=t||void 0,!this.tableElement){let t="HTML table not provided, or element with ID not found";return this.emit({type:"loadError",detail:e,error:t}),Promise.reject(Error(t))}let o=n.parse(y({tableElement:this.tableElement},r),e);return s.deleteColumns(),s.setColumns(o),await this.applyTableModifiers(),this.emit({type:"afterLoad",detail:e}),this}}e0.defaultOptions={id:"HTML-table-connector",type:"HTMLTable",htmlTable:""},I.registerType("HTMLTable",e0);class e1 extends R{constructor(e,...t){super(),this.chain=t,this.options=y(e1.defaultOptions,e);const r=this.options.chain||[];for(let e=0,n=r.length,s,i;e<n;++e)(s=r[e]).type&&(i=R.types[s.type])&&t.push(new i(s))}add(e,t){this.emit({type:"addModifier",detail:t,modifier:e}),this.chain.push(e),this.emit({type:"addModifier",detail:t,modifier:e})}clear(e){this.emit({type:"clearChain",detail:e}),this.chain.length=0,this.emit({type:"afterClearChain",detail:e})}async modify(e,t){let r=this.options.reverse?this.chain.slice().reverse():this.chain.slice();e.modified||(e.modified=e.clone(!1,t));let n=e;for(let s=0,i=r.length;s<i;++s){try{await r[s].modify(n,t)}catch(r){throw this.emit({type:"error",detail:t,table:e}),r}n=n.getModified()}return e.modified=n,e}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.reverse?this.chain.reverse():this.chain.slice(),n=e.getModified();for(let e=0,s=r.length;e<s;++e)n=r[e].modifyTable(n,t).getModified();return e.modified=n,this.emit({type:"afterModify",detail:t,table:e}),e}remove(e,t){let r=this.chain;this.emit({type:"removeModifier",detail:t,modifier:e}),r.splice(r.indexOf(e),1),this.emit({type:"afterRemoveModifier",detail:t,modifier:e})}emit(e){f(this,e.type,e)}on(e,t){return u(this,e,t)}}e1.defaultOptions={type:"Chain"},R.registerType("Chain",e1);class e2 extends R{constructor(e){super(),this.options=y(e2.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=e.getModified();if(e.hasColumns(["columnIds"])){let t=(e.deleteColumns(["columnIds"])||{}).columnIds||[],n={},s=[];for(let e=0,r=t.length;e<r;++e)s.push(""+t[e]);for(let t=0,r=e.getRowCount(),i;t<r;++t)(i=e.getRow(t))&&(n[s[t]]=i);r.deleteColumns(),r.setColumns(n)}else{let t={};for(let r=0,n=e.getRowCount(),s;r<n;++r)(s=e.getRow(r))&&(t[`${r}`]=s);t.columnIds=e.getColumnIds(),r.deleteColumns(),r.setColumns(t)}return this.emit({type:"afterModify",detail:t,table:e}),e}}e2.defaultOptions={type:"Invert"},R.registerType("Invert",e2);class e3 extends R{constructor(e){super(),this.options={...e3.defaultOptions,...e}}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.alternativeSeparators,n=this.options.formulaColumns||e.getColumnIds(),s=e.getModified();for(let t=0,r=n.length,i;t<r;++t)i=n[t],n.indexOf(i)>=0&&s.setColumn(i,this.processColumn(e,i));let i=this.options.columnFormulas||[];for(let t=0,n=i.length,o,l;t<n;++t)o=i[t],l=en.parseFormula(o.formula,r),s.setColumn(o.column,this.processColumnFormula(l,e,o.rowStart,o.rowEnd));return this.emit({type:"afterModify",detail:t,table:e}),e}processColumn(e,t,r=0){let n=this.options.alternativeSeparators,s=(e.getColumn(t,!0)||[]).slice(r>0?r:0);for(let t=0,r=s.length,i=[],o;t<r;++t)if("string"==typeof(o=s[t])&&"="===o[0])try{i=""===o?i:en.parseFormula(o.substring(1),n),s[t]=ex.processFormula(i,e)}catch{s[t]=NaN}return s}processColumnFormula(e,t,r=0,n=t.getRowCount()){r=r>=0?r:0,n=n>=0?n:t.getRowCount()+n;let s=[],i=t.getModified();for(let t=0,o=n-r;t<o;++t)try{s[t]=ex.processFormula(e,i)}catch{s[t]=NaN}finally{e=ex.translateReferences(e,0,1)}return s}}e3.defaultOptions={type:"Math",alternativeSeparators:!1},R.registerType("Math",e3);class e4 extends R{constructor(e){super(),this.options=y(e4.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{start:r,end:n}=this.options;r=Math.max(0,r||0);let s=Mat