/**
 * 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
 */import*as e from"../highcharts.js";var t={};t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r=e.default;var n=t.n(r);let{doc:s,win:i}=n();function o(e,t,r,s={}){let i="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let l=i.hcEvents;n().Point&&e instanceof n().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let a=e.addEventListener;a&&a.call(e,t,r,!!n().supportsPassiveEvents&&{passive:void 0===s.passive?-1!==t.indexOf("touch"):s.passive,capture:!1}),l[t]||(l[t]=[]);let u={fn:r,order:"number"==typeof s.order?s.order:1/0};return l[t].push(u),l[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,m(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 l(e){return null!=e}function a(e,t){let r;for(r in e||(e={}),t)e[r]=t[r];return e}function u(e,t,r,i){if(r=r||{},s?.createEvent&&(e.dispatchEvent||e.fireEvent&&e!==n())){let n=s.createEvent("Events");n.initEvent(t,!0,!0),r=a(n,r),e.dispatchEvent?e.dispatchEvent(r):e.fireEvent(t,r)}else if(e.hcEvents){r.target||a(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()})}i&&!r.defaultPrevented&&i.call(e,r)}function h(e){return d(e)&&"number"==typeof e.nodeType}function c(e){return"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0}function f(e){let t=Object.prototype.toString.call(e);return"[object Array]"===t||"[object Array Iterator]"===t}function d(e,t){return!!e&&"object"==typeof e&&(!t||!f(e))}function p(e,...t){let r,n=[e,...t],s={},i=function(e,t){return"object"!=typeof e&&(e={}),m(t,function(r,n){if("__proto__"!==n&&"constructor"!==n){let s;!d(r,!0)||(s=r?.constructor,d(r,!0)&&!h(r)&&s?.name&&"Object"!==s.name)||h(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 m(e,t,r){for(let n in e)Object.hasOwnProperty.call(e,n)&&t.call(r||e[n],e[n],n,e)}function g(){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 y{static registerType(e,t){return!!e&&!y.types[e]&&!!(y.types[e]=t)}benchmark(e,t){let r=[],n=this,s=()=>{n.modifyTable(e),n.emit({type:"afterBenchmarkIteration"})},{iterations:i}=p({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){u(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 o(this,e,t)}}y.types={};let b=y,w={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:C,splice:R}=w,N=class{constructor(e={}){this.autoId=!e.id,this.columns={},this.id=e.id||(0,r.uniqueKey)(),this.rowCount=0,this.versionTag=(0,r.uniqueKey)();let t=0;m(e.columns||{},(e,r)=>{this.columns[r]=e.slice(),t=Math.max(t,e.length)}),this.applyRowCount(t)}applyRowCount(e){this.rowCount=e,m(this.columns,(t,r)=>{t.length!==e&&(this.columns[r]=C(t,e))})}deleteRows(e,t=1){if(t>0&&e<this.rowCount){let r=0;m(this.columns,(n,s)=>{this.columns[s]=R(n,e,t).array,r=n.length}),this.rowCount=r}u(this,"afterDeleteRows",{rowIndex:e,rowCount:t}),this.versionTag=(0,r.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,n){let s=this.rowCount;m(e,(e,t)=>{this.columns[t]=e.slice(),s=e.length}),this.applyRowCount(s),n?.silent||(u(this,"afterSetColumns"),this.versionTag=(0,r.uniqueKey)())}setRow(e,t=this.rowCount,n,s){let{columns:i}=this,o=n?this.rowCount+1:t+1,l=Object.keys(e);if(s?.addColumns!==!1)for(let e=0,t=l.length;e<t;e++){let t=l[e];i[t]||(i[t]=[])}m(i,(r,l)=>{r||s?.addColumns===!1||(r=Array(o)),r&&(n?r=R(r,t,0,!0,[e[l]??null]).array:r[t]=e[l]??null,i[l]=r)}),o>this.rowCount&&this.applyRowCount(o),s?.silent||(u(this,"afterSetRows"),this.versionTag=(0,r.uniqueKey)())}getModified(){return this.modified||this}},{splice:v,setLength:O}=w;class T extends N{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 T(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,a=[];if(l(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],l=i[o];if(1===n.length&&s>1){let e=v(l,n[0],s);r=e.removed,i[o]=e.array}else{for(let e of(r=[],n))r.push(l[e]),v(l,e,1);r.reverse()}t||(this.rowCount=l.length);for(let e=0,n=r.length;e<n;++e)a[e]=a[e]||[],a[e][t]=r[e]}}return o&&o.modifyTable(this),this.emit({type:"afterDeleteRows",detail:r,rowCount:s,rowIndex:e??0,rows:a}),a}emit(e){["afterDeleteColumns","afterDeleteRows","afterSetCell","afterSetColumns","afterSetRows"].includes(e.type)&&(this.versionTag=(0,r.uniqueKey)()),u(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):c(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):!!(l(t)&&Number.isFinite(t))&&-1!==r.indexOf(+t)}on(e,t){return o(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),u=this.rowCount;if(this.emit({type:"setColumns",columns:e,columnIds:o,detail:r,rowIndex:t}),l(t)||n){for(let r=0,i=o.length,l,a,h,c;r<i;++r){l=e[h=o[r]],c=Object.getPrototypeOf((a=s[h])&&n?a:l).constructor,a?c===Array?Array.isArray(a)||(a=Array.from(a)):a.length<u&&(a=new c(u)).set(s[h]):a=new c(u),s[h]=a;for(let e=t||0,r=l.length;e<r;++e)a[e]=l[e];u=Math.max(u,l.length)}this.applyRowCount(u)}else super.setColumns(e,t,a(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)l(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]]=v(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]=O(s[t],a)}}o&&o.modifyTable(this),this.emit({type:"afterSetRows",detail:n,rowCount:l,rowIndex:t,rows:e})}}class A{static registerType(e,t){return!!e&&!A.types[e]&&!!(A.types[e]=t)}get polling(){return!!this._polling}constructor(e){this.dataTables={},this.loaded=!1,this.metadata=e.metadata||{columns:{}},this.options=e;let t=e?.dataTables,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){let n=t[e],s=n?.key;this.dataTables[s??r]=new T(n),!s&&r++}else this.dataTables[0]=new T({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]=p(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)=>g(e[t].index,0)-g(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"}),p(!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&&b.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){u(this,e.type,e)}on(e,t){return o(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++}}}A.types={};let M=A;function E(e,t){return"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,""),t&&/^[\d\s]+$/.test(e)&&(e=e.replace(/\s/g,""))),e}let I=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)},x=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},P=function(e){return""+e},F=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},D=function(e,t){let r="string";if("string"==typeof e){let n=E(`${e}`),s=t.decimalRegExp,i=E(n,!0);s&&(i=s.test(i)?i.replace(s,"$1.$2"):"");let o=parseFloat(i);+i===o?e=o:r=c(t.parseDate(e))?"Date":"string"}return"number"==typeof e&&(r=e>31536e6?"Date":"number"),r};class j{static registerType(e,t){return!!e&&!j.types[e]&&!!(j.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}}};let t=p(j.defaultOptions,e),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=>x(e,t.decimalRegExp),Date:e=>I(e,t),string:P})[D(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){u(this,e.type,e)}on(e,t){return o(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}}j.defaultOptions={dateFormat:"",firstRowAsNames:!0},j.types={};let L=j;function k(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 Y=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===k(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=k(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 S{constructor(e){this.options=p(S.defaultOptions,e),this.connectors={},this.waiting={}}emit(e){u(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=M.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 o(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})}}S.defaultOptions={connectors:[]};let V=/^(?:FALSE|TRUE)/,$=/^[+\-]?\d+(?:\.\d+)?(?:e[+\-]\d+)?/,U=/^[+\-]?\d+(?:,\d+)?(?:e[+\-]\d+)?/,H=/^([A-Z][A-Z\d\.]*)\(/,_=/^(?:[+\-*\/^<=>]|<=|=>)/,B=/^(\$?[A-Z]+)(\$?\d+)\:(\$?[A-Z]+)(\$?\d+)/,Z=/^R(\d*|\[\d+\])C(\d*|\[\d+\])\:R(\d*|\[\d+\])C(\d*|\[\d+\])/,K=/^(\$?[A-Z]+)(\$?\d+)(?![\:C])/,X=/^R(\d*|\[\d+\])C(\d*|\[\d+\])(?!\:)/;function q(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 G(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 J(e,t){let r;if(r=e.match(Z)){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(B)){let e="$"!==r[1][0],t="$"!==r[2][0],n="$"!==r[3][0],s="$"!==r[4][0],i={type:"range",beginColumn:Q(e?r[1]:r[1].substring(1))-1,beginRow:parseInt(t?r[2]:r[2].substring(1),10)-1,endColumn:Q(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=z(e,t);return 1===n.length&&"string"!=typeof n[0]?n[0]:n}function W(e){let t=e.length,r=e[t-2];return"-"===e[t-1]&&"string"==typeof r&&!!r.match(/\*|\/|\^/)}function z(e,t){let r=t?U:$,n=[],s,i=("="===e[0]?e.substring(1):e).trim();for(;i;){if(s=i.match(X)){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),W(n)&&(n.pop(),r.isNegative=!0),n.push(r),i=i.substring(s[0].length).trim();continue}if(s=i.match(K)){let e="$"!==s[1][0],t="$"!==s[2][0],r={type:"reference",column:Q(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),W(n)&&(n.pop(),r.isNegative=!0),n.push(r),i=i.substring(s[0].length).trim();continue}if(s=i.match(_)){n.push(s[0]),i=i.substring(s[0].length).trim();continue}if(s=i.match(V)){n.push("TRUE"===s[0]),i=i.substring(s[0].length).trim();continue}if(s=i.match(r)){let e=parseFloat(s[0]);W(n)&&(n.pop(),e=-e),n.push(e),i=i.substring(s[0].length).trim();continue}if('"'===i[0]){let e=G(i);n.push(e.substring(1,-1)),i=i.substring(e.length+2).trim();continue}if(s=i.match(H)){let e=q(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(J(i,t)),i="";else if('"'!==a||s||i)" "!==a&&(i+=a,"("===a?++s:")"===a&&--s);else{let t=G(e.substring(o));r.push(t),o+=t.length+1}return!s&&i&&r.push(J(i,t)),r}(e,t)}),i=i.substring(e.length+2).trim();continue}if("("===i[0]){let e=q(i);if(e){n.push(z(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 Q(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 ee={parseFormula:z},et=["+","-","*","/","^","=","<","<=",">",">="],er={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&&et.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:en,isFunction:es,isOperator:ei,isRange:eo,isReference:el,isValue:ea}=er,eu=/ */,eh=Number.MAX_VALUE/1.000000000001,ec=Number.MAX_VALUE/1.000000000002,ef=Number.MAX_VALUE,ed={"^":3,"*":2,"/":2,"+":1,"-":1,"=":0,"<":0,"<=":0,">":0,">=":0},ep={},em=/^[A-Z][A-Z\.]*$/;function eg(e){switch(typeof e){case"boolean":return e?ef:eh;case"string":return ec;case"number":return e;default:return NaN}}function ey(e){return"string"==typeof e?e.toLowerCase().replace(eu,"\0"):e}function eb(e){switch(typeof e){case"boolean":return+!!e;case"string":return parseFloat(e.replace(",","."));case"number":return e;default:return NaN}}function ew(e,t){return ea(e)?e:eo(e)?t&&eC(e,t)||[]:es(e)?eO(e,t):ev(en(e)?e:[e],t)}function eC(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(ea(o)?o:NaN)}return n}function eR(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 ea(n)?n:NaN}if(ea(n))return e.isNegative?-n:n}return NaN}function eN(e,t){(e.length<2||t.length<1)&&e.push(NaN);let r=e.pop(),n=e.pop(),s=t.pop();l(r)&&l(n)&&l(s)?e.push(function(e,t,r){let n;switch(e){case"=":return ey(t)===ey(r);case"<":if(typeof t==typeof r)return ey(t)<ey(r);return eg(t)<eg(r);case"<=":if(typeof t==typeof r)return ey(t)<=ey(r);return eg(t)<=eg(r);case">":if(typeof t==typeof r)return ey(t)>ey(r);return eg(t)>eg(r);case">=":if(typeof t==typeof r)return ey(t)>=ey(r);return eg(t)>=eg(r)}switch(t=eb(t),r=eb(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 ev(e,t){let r=[],n=[],s=!0;for(let i=0,o=e.length;i<o;++i){let o,l=e[i];if(ei(l)){if(s&&"-"===l)r.push(0),n.push("-"),s=!0;else{for(;n.length&&ed[n[n.length-1]]>=ed[l];)eN(r,n);n.push(l),s=!0}continue}if(ea(l))o=l;else if(el(l))o=t?eR(l,t):NaN;else if(es(l)){let e=eO(l,t);o=ea(e)?e:NaN}else en(l)&&(o=ev(l,t));if(void 0===o)return NaN;r.push(o),s=!1}for(;n.length;)eN(r,n);return 1!==r.length?NaN:r[0]}function eO(e,t,r){let n=ep[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 eT={asNumber:eb,getArgumentValue:ew,getArgumentsValues:function(e,t){let r=[];for(let n=0,s=e.length;n<s;++n)r.push(ew(e[n],t));return r},getRangeValues:eC,getReferenceValue:eR,processFormula:ev,processorFunctions:ep,registerProcessorFunction:function(e,t){return em.test(e)&&!ep[e]&&!!(ep[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):es(o)?e(o.args,r,n):eo(o)?(o.beginColumnRelative&&(o.beginColumn+=r),o.beginRowRelative&&(o.beginRow+=n),o.endColumnRelative&&(o.endColumn+=r),o.endRowRelative&&(o.endRow+=n)):el(o)&&(o.columnRelative&&(o.column+=r),o.rowRelative&&(o.row+=n));return t}},{getArgumentValue:eA}=eT;eT.registerProcessorFunction("ABS",function(e,t){let r=eA(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:eM}=eT;eT.registerProcessorFunction("AND",function e(t,r){for(let n=0,s=t.length,i;n<s;++n)if(!(i=eM(t[n],r))||"object"==typeof i&&!e(i,r))return!1;return!0});let{getArgumentsValues:eE}=eT;eT.registerProcessorFunction("AVERAGE",function(e,t){let r=eE(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:eI}=eT;eT.registerProcessorFunction("AVERAGEA",function(e,t){let r=0,n=0;for(let s=0,i=e.length,o;s<i;++s)switch(typeof(o=eI(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}),eT.registerProcessorFunction("COUNT",function e(t,r){let n=eT.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}),eT.registerProcessorFunction("COUNTA",function e(t,r){let n=eT.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:ex}=eT;eT.registerProcessorFunction("IF",function(e,t){return ex(e[0],t)?ex(e[1],t):ex(e[2],t)});let{getArgumentValue:eP}=eT;eT.registerProcessorFunction("ISNA",function(e,t){let r=eP(e[0],t);return"number"!=typeof r||isNaN(r)});let{getArgumentsValues:eF}=eT;eT.registerProcessorFunction("MAX",function e(t,r){let n=eF(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}),eT.registerProcessorFunction("MEDIAN",function(e,t){let r=[],n=eT.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:eD}=eT;eT.registerProcessorFunction("MIN",function e(t,r){let n=eD(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:ej}=eT;function eL(e,t){let r={},n=eT.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 ek(e,t){let r=eL(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}eT.registerProcessorFunction("MOD",function(e,t){let r=ej(e[0],t),n=ej(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}),eT.registerProcessorFunction("MODE",ek),eT.registerProcessorFunction("MODE.MULT",function(e,t){let r=eL(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}),eT.registerProcessorFunction("MODE.SNGL",ek);let{getArgumentValue:eY}=eT;eT.registerProcessorFunction("NOT",function(e,t){let r=eY(e[0],t);switch("object"==typeof r&&(r=r[0]),typeof r){case"boolean":case"number":return!r}return NaN});let{getArgumentValue:eS}=eT;eT.registerProcessorFunction("OR",function e(t,r){for(let n=0,s=t.length,i;n<s;++n)if("object"==typeof(i=eS(t[n],r))){if(e(i,r))return!0}else if(i)return!0;return!1});let{getArgumentsValues:eV}=eT;eT.registerProcessorFunction("PRODUCT",function e(t,r){let n=eV(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}),eT.registerProcessorFunction("SUM",function e(t,r){let n=eT.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$}=eT;eT.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 eU={...ee,...eT,...er};class eH extends L{constructor(e){let t=p(eH.defaultOptions,e);super(t),this.headers=[],this.dataTypes=[],this.options=t}parse(e,t){let r=this.dataTypes,n=p(this.options,e),{beforeParse:s,lineDelimiter:i,firstRowAsNames:o,itemDelimiter:l}=n,a,u=0,{csv:h,startRow:c,endRow:f}=n,d,m=[];if(this.emit({type:"parse",columns:m,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(m,a[u],u-c-e);r.length&&r[0].length&&"date"===r[0][1]&&!this.options.dateFormat&&this.deduceDateFormat(m[0],null,!0);for(let e=0,t=m.length;e<t;++e){d=m[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()),m[e][t]=r}}}return m.forEach(e=>{e.length=Math.max(...m.map(e=>e.length))}),this.emit({type:"afterParse",columns:m,detail:t,headers:this.headers}),F(m,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"!==D(c,n)&&a){let e=c;"number"!==D(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}}eH.defaultOptions={...L.defaultOptions,lineDelimiter:"\n",startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},L.registerType("CSV",eH);class e_ extends M{constructor(e){let t=p(e_.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){u(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 eH(p(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})}}e_.defaultOptions={id:"csv-connector",type:"CSV",csv:"",csvURL:"",enablePolling:!1,dataRefreshRate:1,firstRowAsNames:!0},M.registerType("CSV",e_);class eB extends L{constructor(e){let t=p(eB.defaultOptions,e);super(t),this.headerColumnIds=[],this.headers=[],this.options=t}parse(e,t){let{beforeParse:r,orientation:n,firstRowAsNames:s,columnIds:i}=e=p(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}),F(l,this.headers)}parseColumnsOrientation(e,t,n,s){for(let i=0,o=t.length;i<o;i++){let o=t[i];if(!Array.isArray(o))return;Array.isArray(this.headers)?(n?this.headers.push(`${o.shift()}`):s&&Array.isArray(s)&&this.headers.push(s[i]),e.push(o)):(0,r.error)("JSONConverter: Invalid `columnIds` option.",!1)}}parseRowsOrientation(e,t,n,s){n?this.headers=t.shift():s&&(this.headerColumnIds=s);for(let i=0,o=t.length;i<o;i++){let o=t[i];f(o)||(o=this.convertItemToRow(o,s));for(let t=0,s=o.length;t<s;t++)e.length<t+1&&e.push([]),e[t].push(o[t]),n||0!==i||(Array.isArray(this.headerColumnIds)?this.headers.push(this.headerColumnIds[t]||t.toString()):(0,r.error)("JSONConverter: Invalid `columnIds` option.",!1))}}convertItemToRow(e,t){let r=this;if(t&&!Array.isArray(t)){let n=[];return m(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)}}eB.defaultOptions={...L.defaultOptions,orientation:"rows"},L.registerType("JSON",eB);class eZ extends M{constructor(e){let t=p(eZ.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){u(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 eB({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})}}eZ.defaultOptions={type:"JSON",id:"json-connector",data:[],enablePolling:!1,dataRefreshRate:0,firstRowAsNames:!0,orientation:"rows"},M.registerType("JSON",eZ);class eK extends L{constructor(e){let t=p(eK.defaultOptions,e);super(t),this.header=[],this.options=t}parse(e,t){let n,s=p(this.options,e),i=(s.json?.values||[]).map(e=>e.slice());if(0===i.length)return{};this.header=[],this.emit({type:"parse",columns:[],detail:t,headers:this.header});let{beforeParse:o,json:l}=s;o&&l&&(i=o(l.values));for(let e=0,t=i.length;e<t;e++){n=i[e],this.header[e]=s.firstRowAsNames?`${n.shift()}`:(0,r.uniqueKey)();for(let t=0,r=n.length;t<r;++t){var a;let r=n[t];a=r,"[object Date]"===Object.prototype.toString.call(a)&&(r=r.getTime()),i[e][t]=r}}return this.emit({type:"afterParse",columns:i,detail:t,headers:this.header}),F(i,this.header)}}eK.defaultOptions={...L.defaultOptions},L.registerType("GoogleSheets",eK);class eX extends M{constructor(e){let t=p(eX.defaultOptions,e);super(t),this.options=t}emit(e){u(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||(eq[s||0]||"A")+(Math.max(i||0,0)+1)+":"+(eq[g(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 eK({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})}}eX.defaultOptions={id:"google-sheets-connector",type:"GoogleSheets",googleAPIKey:"",googleSpreadsheetKey:"",enablePolling:!1,dataRefreshRate:2,firstRowAsNames:!0};let eq="ABCDEFGHIJKLMNOPQRSTUVWXYZ";M.registerType("GoogleSheets",eX);class eG extends L{constructor(e){let t=p(eG.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=p(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:m}=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);m++}for(;f<c;){if(f>=m&&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-m]=e;let n=1;for(;f-m>=n&&void 0===s[f-m-n];)s[f-m-n]=null,n++}n++}}f++}return this.headers=n,this.emit({type:"afterParse",columns:r,detail:t,headers:n}),F(r,this.headers)}}eG.defaultOptions={...L.defaultOptions,useRowspanHeaders:!0,useMultiLevelHeaders:!0,startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},L.registerType("HTMLTable",eG);let{win:eJ}=n();class eW extends M{constructor(e){let t=p(eW.defaultOptions,e);super(t),this.options=t,this.converter=new eG(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=eJ.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(p({tableElement:this.tableElement},r),e);return s.deleteColumns(),s.setColumns(o),await this.applyTableModifiers(),this.emit({type:"afterLoad",detail:e}),this}}eW.defaultOptions={id:"HTML-table-connector",type:"HTMLTable",htmlTable:""},M.registerType("HTMLTable",eW);class ez extends b{constructor(e,...t){super(),this.chain=t,this.options=p(ez.defaultOptions,e);let r=this.options.chain||[];for(let e=0,n=r.length,s,i;e<n;++e)(s=r[e]).type&&(i=b.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){u(this,e.type,e)}on(e,t){return o(this,e,t)}}ez.defaultOptions={type:"Chain"},b.registerType("Chain",ez);class eQ extends b{constructor(e){super(),this.options=p(eQ.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}}eQ.defaultOptions={type:"Invert"},b.registerType("Invert",eQ);class e0 extends b{constructor(e){super(),this.options={...e0.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=ee.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:ee.parseFormula(o.substring(1),n),s[t]=eT.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]=eT.processFormula(e,i)}catch{s[t]=NaN}finally{e=eT.translateReferences(e,0,1)}return s}}e0.defaultOptions={type:"Math",alternativeSeparators:!1},b.registerType("Math",e0);class e1 extends b{constructor(e){super(),this.options=p(e1.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=Math.max((n=Math.min(n||1/0,e.getRowCount()))-r,0),i=e.getModified();return i.deleteRows(),i.setRows(e.getRows(r,s)),i.setOriginalRowIndexes(Array.from({length:s},(t,n)=>e.getOriginalRowIndex(r+n))),this.emit({type:"afterModify",detail:t,table:e}),e}}e1.defaultOptions={type:"Range",start:0,end:1/0},b.registerType("Range",e1);class e2 extends b{static ascending(e,t){return(e||0)<(t||0)?-1:+((e||0)>(t||0))}static descending(e,t){return(t||0)<(e||0)?-1:+((t||0)>(e||0))}static compareFactory(e,t){return t?"desc"===e?(e,r)=>-t(e,r):t:"asc"===e?e2.ascending:e2.descending}constructor(e){super(),this.options=p(e2.defaultOptions,e)}getRowReferences(e){let t=e.getRows(),r=[];for(let e=0,n=t.length;e<n;++e)r.push({index:e,row:t[e]});return r}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=e.getColumnIds(),n=e.getRowCount(),s=this.getRowReferences(e),{direction:i,orderInColumn:o,compare:l}=this.options,a=e.getModified(),u="columns"in this.options?this.options.columns:[this.options.orderByColumn],h=[];for(let e=0,t=u.length;e<t;++e){let t=u[e],n="string"==typeof t,s=n?t:t.column,o=r.indexOf(s);-1!==o&&h.push({columnIndex:o,compare:e2.compareFactory(n?i:t.direction||i,n?l:t.compare||l)})}if(h.length&&s.sort((e,t)=>{for(let r=0,n=h.length;r<n;++r){let{columnIndex:n,compare:s}=h[r],i=s(e.row[n],t.row[n]);if(i)return i}return e.index-t.index}),o){let e=[];for(let t=0;t<n;++t)e[s[t].index]=t;a.setColumns({[o]:e})}else{let t,r=[],i=[];for(let o=0;o<n;++o)t=s[o],r.push(e.getOriginalRowIndex(t.index)),i.push(t.row);a.setRows(i,0),a.setOriginalRowIndexes(r)}return this.emit({type:"afterModify",detail:t,table:e}),e}}e2.defaultOptions={type:"Sort",direction:"desc",orderByColumn:"y"},b.registerType("Sort",e2);class e3 extends b{static compile(e){if("function"==typeof e)return e;let t=e.operator;switch(t){case"and":{let t=e.conditions.map(e=>this.compile(e));return(e,r,n)=>t.every(t=>t(e,r,n))}case"or":{let t=e.conditions.map(e=>this.compile(e));return(e,r,n)=>t.some(t=>t(e,r,n))}case"not":{let t=this.compile(e.condition);return(e,r,n)=>!t(e,r,n)}}let{columnId:r,value:n}=e;switch(t){case"==":return e=>e[r]==n;case"===":return e=>e[r]===n;case"!=":return e=>e[r]!=n;case"!==":return e=>e[r]!==n;case">":return e=>(e[r]||0)>(n||0);case">=":return e=>(e[r]||0)>=(n||0);case"<":return e=>(e[r]||0)<(n||0);case"<=":return e=>(e[r]||0)<=(n||0);case"empty":return e=>null===e[r]||""===e[r]}let{ignoreCase:s}=e,i=e=>{let t=""+e;return s??!0?t.toLowerCase():t};return"contains"===t?e=>i(e[r]).includes(i(n)):e=>i(e[r])[t](i(n))}constructor(e){super(),this.options=p(e3.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{condition:r}=this.options;if(!r)return e;let n=e3.compile(r),s=e.getModified(),i=[],o=[];for(let t=0,r=e.getRowCount();t<r;++t){let r=e.getRowObject(t);r&&n(r,e,t)&&(i.push(r),o.push(e.getOriginalRowIndex(t)))}return s.deleteRows(),s.setRows(i),s.setOriginalRowIndexes(o),this.emit({type:"afterModify",detail:t,table:e}),e}}e3.defaultOptions={type:"Filter"},b.registerType("Filter",e3);let e4=n();e4.DataConnector=e4.DataConnector||M,e4.DataConverter=e4.DataConverter||L,e4.DataCursor=e4.DataCursor||Y,e4.DataModifier=e4.DataModifier||b,e4.DataPool=e4.DataPool||S,e4.DataTable=e4.DataTable||T,e4.Formula=e4.Formula||eU;let e6=n();export{e6 as default};