!/**
 * Highcharts JS v13.0.0 (2026-06-11)
 * @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 s(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};s.d(i,{default:()=>eG});var n=s(944),o=s.n(n);class l{static registerType(e,t){return!!e&&!l.types[e]&&!!(l.types[e]=t)}benchmark(e,t){let r=[],s=this,i=()=>{s.modifyTable(e),s.emit({type:"afterBenchmarkIteration"})},{iterations:o}=(0,n.merge)({iterations:1},t);s.on("afterBenchmarkIteration",()=>{r.length===o?s.emit({type:"afterBenchmark",results:r}):i()});let l={startTime:0,endTime:0};return s.on("modify",()=>{l.startTime=window.performance.now()}),s.on("afterModify",()=>{l.endTime=window.performance.now(),r.push(l.endTime-l.startTime)}),i(),r}emit(e){(0,n.fireEvent)(this,e.type,e)}modify(e,t){let r=this;return new Promise((s,i)=>{e.modified||(e.modified=e.clone(!1,t));try{s(r.modifyTable(e,t))}catch(s){r.emit({type:"error",detail:t,table:e}),i(s instanceof Error?s:Error(""+s))}})}on(e,t){return(0,n.addEvent)(this,e,t)}}l.types={};let a=l,u={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,s,i=[]){if(Array.isArray(e))return Array.isArray(i)||(i=Array.from(i)),{removed:e.splice(t,r,...i),array:e};let n=Object.getPrototypeOf(e).constructor,o=e[s?"subarray":"slice"](t,t+r),l=new n(e.length-r+i.length);return l.set(e.subarray(0,t),0),l.set(i,t),l.set(e.subarray(t+r),t+i.length),{removed:o,array:l}}},{setLength:h,splice:c}=u,d=class{constructor(e={}){this.isDataTable=!0,this.autoId=!e.id,this.columns={},this.id=e.id||(0,n.uniqueKey)(),this.rowCount=0,this.versionTag=(0,n.uniqueKey)();let t=0;(0,n.objectEach)(e.columns||{},(e,r)=>{this.columns[r]=e.slice(),t=Math.max(t,e.length)}),this.applyRowCount(t)}applyRowCount(e){this.rowCount=e,(0,n.objectEach)(this.columns,(t,r)=>{t.length!==e&&(this.columns[r]=h(t,e))})}deleteRows(e,t=1){if(t>0&&e<this.rowCount){let r=0;(0,n.objectEach)(this.columns,(s,i)=>{this.columns[i]=c(s,e,t).array,r=s.length}),this.rowCount=r}(0,n.fireEvent)(this,"afterDeleteRows",{rowIndex:e,rowCount:t}),this.versionTag=(0,n.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),{})}getRowObject(e,t){let r={},s=this.columns;for(let i of(t??(t=Object.keys(this.columns)),t))r[i]=s[i]?.[e];return r}setColumn(e,t=[],r=0,s){this.setColumns({[e]:t},r,s)}setColumns(e,t,r){let s=this.rowCount;(0,n.objectEach)(e,(e,t)=>{this.columns[t]=e.slice(),s=e.length}),this.applyRowCount(s),r?.silent||((0,n.fireEvent)(this,"afterSetColumns"),this.versionTag=(0,n.uniqueKey)())}setRow(e,t=this.rowCount,r,s){var i;let{columns:o}=this,l=r?this.rowCount+1:t+1,a=Object.keys(e);if(s?.addColumns!==!1)for(let e=0,t=a.length;e<t;e++)o[i=a[e]]||(o[i]=Array(this.rowCount));(0,n.objectEach)(o,(s,i)=>{s&&(r?s=c(s,t,0,!0,[e[i]]).array:s[t]=i in e?e[i]:s[t],o[i]=s)}),this.applyRowCount(Math.max(l,this.rowCount)),s?.silent||((0,n.fireEvent)(this,"afterSetRows",{rowIndex:t}),this.versionTag=(0,n.uniqueKey)())}getModified(){return this.modified||this}},{splice:f,setLength:p}=u;class m extends d{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 s=new m(r);return e||(s.versionTag=this.versionTag,s.originalRowIndexes=this.originalRowIndexes,s.localRowIndexes=this.localRowIndexes),s.metadata={...this.metadata},this.emit({type:"afterCloneTable",detail:t,tableClone:s}),s}deleteColumns(e,t){let r=this.columns,s={},i={},n=this.modifier,o=this.rowCount;if((e=e||Object.keys(r)).length){this.emit({type:"deleteColumns",columnIds:e,detail:t});for(let t=0,n=e.length,l,a;t<n;++t)(l=r[a=e[t]])&&(s[a]=l,i[a]=Array(o)),delete r[a];return Object.keys(r).length||(this.rowCount=0,this.deleteRowIndexReferences()),n&&n.modifyTable(this),this.emit({type:"afterDeleteColumns",columns:s,columnIds:e,detail:t}),s}}deleteRowIndexReferences(){delete this.originalRowIndexes,delete this.localRowIndexes}deleteRows(e,t=1,r){let s,i,{columns:o,modifier:l}=this,a=[];if((0,n.defined)(e)?Array.isArray(e)?i=(s=e.filter((e,t,r)=>e>=0&&e<this.rowCount&&r.indexOf(e)===t).sort((e,t)=>t-e)).length:(s=[e],i=t):(s=[0],i=this.rowCount),this.emit({type:"deleteRows",detail:r,rowCount:i,rowIndex:e??0}),i>0){let e=Object.keys(o);for(let t=0;t<e.length;++t){let r,n=e[t],l=o[n];if(1===s.length&&i>1){let e=f(l,s[0],i);r=e.removed,o[n]=e.array}else{for(let e of(r=[],s))r.push(l[e]),f(l,e,1);r.reverse()}t||(this.rowCount=l.length);for(let e=0,s=r.length;e<s;++e)a[e]=a[e]||[],a[e][t]=r[e]}}return l&&l.modifyTable(this),this.emit({type:"afterDeleteRows",detail:r,rowCount:i,rowIndex:e??0,rows:a}),a}emit(e){["afterDeleteColumns","afterDeleteRows","afterSetCell","afterSetColumns","afterSetRows"].includes(e.type)&&(this.versionTag=(0,n.uniqueKey)()),(0,n.fireEvent)(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 s=this.columns,i={};e=e||Object.keys(s);for(let n=0,o=e.length,l,a;n<o;++n)(l=s[a=e[n]])&&(t?i[a]=l:r&&!Array.isArray(l)?i[a]=Array.from(l):i[a]=l.slice());return i}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 s=this.columns[e];if(s){let e=-1;if(Array.isArray(s)?e=s.indexOf(t,r):(0,n.isNumber)(t)&&(e=s.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 s=this.columns,i=Array(t);r=r||Object.keys(s);for(let n=e,o=0,l=Math.min(this.rowCount,e+t),a,u;n<l;++n,++o)for(let e of(u=i[o]={},r))a=s[e],u[e]=a?a[n]:void 0;return i}getRows(e=0,t=this.rowCount-e,r){let s=this.columns,i=Array(t);r=r||Object.keys(s);for(let n=e,o=0,l=Math.min(this.rowCount,e+t),a,u;n<l;++n,++o)for(let e of(u=i[o]=[],r))a=s[e],u.push(a?a[n]:void 0);return i}getVersionTag(){return this.versionTag}hasColumns(e){let t=this.columns;for(let r=0,s=e.length;r<s;++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):!!((0,n.defined)(t)&&Number.isFinite(t))&&-1!==r.indexOf(+t)}on(e,t){return(0,n.addEvent)(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,s){let i=this.columns,n=this.modifier,o=i[e];o&&o[t]===r||(this.emit({type:"setCell",cellValue:r,columnId:e,detail:s,rowIndex:t}),o||(o=i[e]=Array(this.rowCount)),t>=this.rowCount&&(this.rowCount=t+1),o[t]=r,n&&n.modifyTable(this),this.emit({type:"afterSetCell",cellValue:r,columnId:e,detail:s,rowIndex:t}))}setColumns(e,t,r,s){let i=this.columns,o=this.modifier,l=Object.keys(e),a=this.rowCount;if(this.emit({type:"setColumns",columns:e,columnIds:l,detail:r,rowIndex:t}),(0,n.defined)(t)||s){for(let r=0,n=l.length,o,u,h,c;r<n;++r){o=e[h=l[r]],c=Object.getPrototypeOf((u=i[h])&&s?u:o).constructor,u?c===Array?Array.isArray(u)||(u=Array.from(u)):u.length<a&&(u=new c(a)).set(i[h]):u=new c(a),i[h]=u;for(let e=t||0,r=o.length;e<r;++e)u[e]=o[e];a=Math.max(a,o.length)}this.applyRowCount(a)}else super.setColumns(e,t,(0,n.extend)(r,{silent:!0}));o&&o.modifyTable(this),this.emit({type:"afterSetColumns",columns:e,columnIds:l,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,s=e.length,i;t<s;++t)i=e[t],(0,n.defined)(i)&&(r[i]=t)}setRow(e,t,r,s){this.setRows([e],t,r,s)}setRows(e,t=this.rowCount,r,s){let i=this.columns,n=Object.keys(i),o=this.modifier,l=e.length;this.emit({type:"setRows",detail:s,rowCount:l,rowIndex:t,rows:e});for(let s=0,o=t,a;s<l;++s,++o)if(0===Object.keys(a=e[s]).length)for(let e=0,t=n.length;e<t;++e){let t=i[n[e]];r?i[n[e]]=f(t,o,0,!0,[null]).array:t[o]=null}else if(Array.isArray(a))for(let e=0,t=n.length;e<t;++e)i[n[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=n.length;e<t;++e){let t=n[e];i[t]=p(i[t],a)}}o&&o.modifyTable(this),this.emit({type:"afterSetRows",detail:s,rowCount:l,rowIndex:t,rows:e})}}class g{static registerType(e,t){return!!e&&!g.types[e]&&!!(g.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,s=t.length;e<s;++e){const s=t[e],i=s?.key;this.dataTables[i??r]=new m(s),!i&&r++}else this.dataTables[0]=new m({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]=(0,n.merge)(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)=>(0,n.pick)(e[t].index,0)-(0,n.pick)(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"}),(0,n.merge)(!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 s=e?.find(e=>e.key===t)?.dataModifier??this.options?.dataModifier;if(!s)continue;let i=s&&a.types[s.type];await r.setModifier(i?new i(s):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){(0,n.fireEvent)(this,e.type,e)}on(e,t){return(0,n.addEvent)(this,e,t)}initConverters(e,t,r){let s=0;for(let[i,n]of Object.entries(this.dataTables)){let o=t(i),l=r(o,e);n.deleteColumns(),n.setColumns(l),0===s&&(this.converter=o),s++}}}g.types={};let y=g;function b(e,t){return"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,""),t&&/^[\d\s]+$/.test(e)&&(e=e.replace(/\s/g,""))),e}let w=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)},C=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},R=function(e){return""+e},N=function(e=[],t){let r={};for(let s=0,i=Math.max(t.length,e.length);s<i;++s)r[t[s]||`${s}`]=e[s]?e[s].slice():[];return r},T=function(e,t){let r="string";if("string"==typeof e){let s=b(`${e}`),i=t.decimalRegExp,o=b(s,!0);i&&(o=i.test(o)?o.replace(i,"$1.$2"):"");let l=parseFloat(o);if(+o===l)e=l;else{let s=t.parseDate(e);r=(0,n.isNumber)(s)?"Date":"string"}}return"number"==typeof e&&(r=e>31536e6?"Date":"number"),r};class v{static registerType(e,t){return!!e&&!v.types[e]&&!!(v.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=(0,n.merge)(v.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=>C(e,t.decimalRegExp),Date:e=>w(e,t),string:R})[T(e,t)].call(t,e)}deduceDateFormat(e,t,r){let s=[],i=[],n="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))&&(i[c]=!i[c]||i[c]<h?h:i[c],void 0!==s[c]?s[c]!==h&&(s[c]=!1):s[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<s.length;c++)!1!==s[c]?i[c]>12&&"YY"!==l[c]&&"YYYY"!==l[c]&&(l[c]="YY"):i[c]>12&&"mm"===l[c]&&(l[c]="dd");3===l.length&&"dd"===l[1]&&"dd"===l[2]&&(l[2]="YY"),n=l.join("/")}return r&&(this.options.dateFormat=n),n}emit(e){(0,n.fireEvent)(this,e.type,e)}on(e,t){return(0,n.addEvent)(this,e,t)}parseDate(e,t){let r=this.options,s=t||r.dateFormat,i=NaN,n,o=null;if(r.parseDate)i=r.parseDate(e);else{let t=this.dateFormats;if(s){let r=t[s];r||(r=t["YYYY/mm/dd"]),(o=e.match(r.regex))&&(i=r.parser(o))}else for(n in t){let r=t[n];if(o=e.match(r.regex)){s=n,i=r.parser(o);break}}if(!o){let t=Date.parse(e);!isNaN(t)&&(i=t-6e4*new Date(t).getTimezoneOffset(),e.includes("2001")||2001!==new Date(i).getFullYear()||(i=NaN))}}return i}}v.defaultOptions={dateFormat:"",firstRowAsNames:!0},v.types={};let O=v;function A(e,t){if("position"===e.type){for(let r,s=0,i=t.length;s<i;++s)if("position"===(r=t[s]).type&&r.state===e.state&&r.column===e.column&&r.row===e.row)return s}else{let r=JSON.stringify(e.columns);for(let s,i=0,n=t.length;i<n;++i)if("range"===(s=t[i]).type&&s.state===e.state&&s.firstRow===e.firstRow&&s.lastRow===e.lastRow&&JSON.stringify(s.columns)===r)return i}return -1}let M=class{constructor(e={}){this.emittingRegister=[],this.listenerMap={},this.stateMap=e}addListener(e,t,r){let s=this.listenerMap[e]=this.listenerMap[e]||{};return(s[t]=s[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,s){let i=e.id,n=t.state,o=this.listenerMap[i]&&this.listenerMap[i][n];if(o){let n=this.stateMap[i]=this.stateMap[i]??{},l=n[t.state]||[];s&&(l.length||(n[t.state]=l),-1===A(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=A(t,r);e>=0&&r.splice(e,1)}return this}removeListener(e,t,r){let s=this.listenerMap[e]&&this.listenerMap[e][t];if(s){let e=s.indexOf(r);e>=0&&s.splice(e,1)}return this}};class x{constructor(e){this.options=(0,n.merge)(x.defaultOptions,e),this.connectors={},this.waiting={}}emit(e){(0,n.fireEvent)(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,s=r.length;e<s;++e)r[e][0](t)}).catch(t=>{delete this.waiting[e];for(let e=0,s=r.length;e<s;++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,s=e.length;r<s;++r)t.push(e[r].id);return t}getConnectorOptions(e){let t=this.options.connectors;for(let r=0,s=t.length;r<s;++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 s=y.types[e.type];if(!s)throw Error(`Connector type not found. (${e.type})`);let i=this.connectors[e.id]=new s(e);i.load().then(({converter:r})=>{i.converter=r,i.loaded=!0,this.emit({type:"afterLoad",options:e}),t(i)}).catch(r)})}cancelPendingRequests(){let{connectors:e}=this;for(let t of Object.keys(e))e[t].stopPolling()}on(e,t){return(0,n.addEvent)(this,e,t)}async setConnectorOptions(e,t){let r=this.options.connectors,s=this.connectors;this.emit({type:"setConnectorOptions",options:e});for(let t=0,s=r.length;t<s;++t)if(r[t].id===e.id){r.splice(t,1);break}let i=s[e.id];i&&(t?await i.update(e,!0):(i.stopPolling(),i=void 0,delete s[e.id])),i||r.push(e),this.emit({type:"afterSetConnectorOptions",options:e})}}x.defaultOptions={connectors:[]};let E=/^(?:FALSE|TRUE)/,I=/^[+\-]?\d+(?:\.\d+)?(?:e[+\-]\d+)?/,F=/^[+\-]?\d+(?:,\d+)?(?:e[+\-]\d+)?/,D=/^([A-Z][A-Z\d\.]*)\(/,j=/^(?:[+\-*\/^<=>]|<=|=>)/,P=/^(\$?[A-Z]+)(\$?\d+)\:(\$?[A-Z]+)(\$?\d+)/,k=/^R(\d*|\[\d+\])C(\d*|\[\d+\])\:R(\d*|\[\d+\])C(\d*|\[\d+\])/,L=/^(\$?[A-Z]+)(\$?\d+)(?![\:C])/,Y=/^R(\d*|\[\d+\])C(\d*|\[\d+\])(?!\:)/;function S(e){let t=0;for(let r=0,s=e.length,i,n=1;r<s;++r){if("("===(i=e[r])){t||(n=r+1),++t;continue}if(")"===i&&!--t)return e.substring(n,r)}if(t>0){let e=Error("Incomplete parentheses.");throw e.name="FormulaParseError",e}return""}function V(e){let t=-1;for(let r=0,s=e.length,i,n=!1;r<s;++r){if("\\"===(i=e[r])){n=!n;continue}if(n){n=!1;continue}if('"'===i)if(!(t<0))return e.substring(t+1,r);else t=r}let r=Error("Incomplete string.");throw r.name="FormulaParseError",r}function $(e,t){let r;if(r=e.match(k)){let e=""===r[2]||"["===r[2][0],t=""===r[1]||"["===r[1][0],s=""===r[4]||"["===r[4][0],i=""===r[3]||"["===r[3][0],n={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:s?parseInt(r[4].substring(1,-1)||"0",10):parseInt(r[4],10)-1,endRow:i?parseInt(r[3].substring(1,-1)||"0",10):parseInt(r[3],10)-1};return e&&(n.beginColumnRelative=!0),t&&(n.beginRowRelative=!0),s&&(n.endColumnRelative=!0),i&&(n.endRowRelative=!0),n}if(r=e.match(P)){let e="$"!==r[1][0],t="$"!==r[2][0],s="$"!==r[3][0],i="$"!==r[4][0],n={type:"range",beginColumn:_(e?r[1]:r[1].substring(1))-1,beginRow:parseInt(t?r[2]:r[2].substring(1),10)-1,endColumn:_(s?r[3]:r[3].substring(1))-1,endRow:parseInt(i?r[4]:r[4].substring(1),10)-1};return e&&(n.beginColumnRelative=!0),t&&(n.beginRowRelative=!0),s&&(n.endColumnRelative=!0),i&&(n.endRowRelative=!0),n}let s=H(e,t);return 1===s.length&&"string"!=typeof s[0]?s[0]:s}function U(e){let t=e.length,r=e[t-2];return"-"===e[t-1]&&(0,n.isString)(r)&&!!r.match(/\*|\/|\^/)}function H(e,t){let r=t?F:I,s=[],i,n=("="===e[0]?e.substring(1):e).trim();for(;n;){if(i=n.match(Y)){let e=""===i[2]||"["===i[2][0],t=""===i[1]||"["===i[1][0],r={type:"reference",column:e?parseInt(i[2].substring(1,-1)||"0",10):parseInt(i[2],10)-1,row:t?parseInt(i[1].substring(1,-1)||"0",10):parseInt(i[1],10)-1};e&&(r.columnRelative=!0),t&&(r.rowRelative=!0),U(s)&&(s.pop(),r.isNegative=!0),s.push(r),n=n.substring(i[0].length).trim();continue}if(i=n.match(L)){let e="$"!==i[1][0],t="$"!==i[2][0],r={type:"reference",column:_(e?i[1]:i[1].substring(1))-1,row:parseInt(t?i[2]:i[2].substring(1),10)-1};e&&(r.columnRelative=!0),t&&(r.rowRelative=!0),U(s)&&(s.pop(),r.isNegative=!0),s.push(r),n=n.substring(i[0].length).trim();continue}if(i=n.match(j)){s.push(i[0]),n=n.substring(i[0].length).trim();continue}if(i=n.match(E)){s.push("TRUE"===i[0]),n=n.substring(i[0].length).trim();continue}if(i=n.match(r)){let e=parseFloat(i[0]);U(s)&&(s.pop(),e=-e),s.push(e),n=n.substring(i[0].length).trim();continue}if('"'===n[0]){let e=V(n);s.push(e.substring(1,-1)),n=n.substring(e.length+2).trim();continue}if(i=n.match(D)){let e=S(n=n.substring(i[1].length).trim());s.push({type:"function",name:i[1],args:function(e,t){let r=[],s=t?";":",",i=0,n="";for(let o=0,l=e.length,a;o<l;++o)if((a=e[o])===s&&!i&&n)r.push($(n,t)),n="";else if('"'!==a||i||n)" "!==a&&(n+=a,"("===a?++i:")"===a&&--i);else{let t=V(e.substring(o));r.push(t),o+=t.length+1}return!i&&n&&r.push($(n,t)),r}(e,t)}),n=n.substring(e.length+2).trim();continue}if("("===n[0]){let e=S(n);if(e){s.push(H(e,t)),n=n.substring(e.length+2).trim();continue}}let o=e.length-n.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 s}function _(e){let t=0;for(let r=0,s=e.length,i,n=e.length-1;r<s;++r)(i=e.charCodeAt(r))>=65&&i<=90&&(t+=(i-64)*Math.pow(26,n)),--n;return t}let B={parseFormula:H},Z=["+","-","*","/","^","=","<","<=",">",">="],K={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&&Z.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:X,isFunction:q,isOperator:G,isRange:J,isReference:W,isValue:z}=K,Q=/ */,ee=Number.MAX_VALUE/1.000000000001,et=Number.MAX_VALUE/1.000000000002,er=Number.MAX_VALUE,es={"^":3,"*":2,"/":2,"+":1,"-":1,"=":0,"<":0,"<=":0,">":0,">=":0},ei={},en=/^[A-Z][A-Z\.]*$/;function eo(e){switch(typeof e){case"boolean":return e?er:ee;case"string":return et;case"number":return e;default:return NaN}}function el(e){return"string"==typeof e?e.toLowerCase().replace(Q,"\0"):e}function ea(e){switch(typeof e){case"boolean":return+!!e;case"string":return parseFloat(e.replace(",","."));case"number":return e;default:return NaN}}function eu(e,t){return z(e)?e:J(e)?t&&eh(e,t)||[]:q(e)?ep(e,t):ef(X(e)?e:[e],t)}function eh(e,t){let r=t.getColumnIds().slice(e.beginColumn,e.endColumn+1),s=[];for(let i=0,n=r.length,o;i<n;++i){let n=t.getColumn(r[i],!0)||[];for(let l=e.beginRow,a=e.endRow+1;l<a;++l)"string"==typeof(o=n[l])&&"="===o[0]&&t!==t.getModified()&&(o=t.getModified().getCell(r[i],l)),s.push(z(o)?o:NaN)}return s}function ec(e,t){let r=t.getColumnIds()[e.column];if(r){let s=t.getCell(r,e.row);if("string"==typeof s&&"="===s[0]&&t!==t.getModified()){let s=t.getModified().getCell(r,e.row);return z(s)?s:NaN}if(z(s))return e.isNegative?-s:s}return NaN}function ed(e,t){(e.length<2||t.length<1)&&e.push(NaN);let r=e.pop(),s=e.pop(),i=t.pop();(0,n.defined)(r)&&(0,n.defined)(s)&&(0,n.defined)(i)?e.push(function(e,t,r){let s;switch(e){case"=":return el(t)===el(r);case"<":if(typeof t==typeof r)return el(t)<el(r);return eo(t)<eo(r);case"<=":if(typeof t==typeof r)return el(t)<=el(r);return eo(t)<=eo(r);case">":if(typeof t==typeof r)return el(t)>el(r);return eo(t)>eo(r);case">=":if(typeof t==typeof r)return el(t)>=el(r);return eo(t)>=eo(r)}switch(t=ea(t),r=ea(r),e){case"+":s=t+r;break;case"-":s=t-r;break;case"*":s=t*r;break;case"/":s=t/r;break;case"^":s=Math.pow(t,r);break;default:return NaN}return s%1?Math.round(1e9*s)/1e9:s}(i,s,r)):e.push(NaN)}function ef(e,t){let r=[],s=[],i=!0;for(let n=0,o=e.length;n<o;++n){let o,l=e[n];if(G(l)){if(i&&"-"===l)r.push(0),s.push("-"),i=!0;else{for(;s.length&&es[s[s.length-1]]>=es[l];)ed(r,s);s.push(l),i=!0}continue}if(z(l))o=l;else if(W(l))o=t?ec(l,t):NaN;else if(q(l)){let e=ep(l,t);o=z(e)?e:NaN}else X(l)&&(o=ef(l,t));if(void 0===o)return NaN;r.push(o),i=!1}for(;s.length;)ed(r,s);return 1!==r.length?NaN:r[0]}function ep(e,t,r){let s=ei[e.name];if(s)try{return s(e.args,t)}catch{return NaN}let i=Error(`Function "${e.name}" not found.`);throw i.name="FormulaProcessError",i}let em={asNumber:ea,getArgumentValue:eu,getArgumentsValues:function(e,t){let r=[];for(let s=0,i=e.length;s<i;++s)r.push(eu(e[s],t));return r},getRangeValues:eh,getReferenceValue:ec,processFormula:ef,processorFunctions:ei,registerProcessorFunction:function(e,t){return en.test(e)&&!ei[e]&&!!(ei[e]=t)},translateReferences:function e(t,r=0,s=0){for(let i=0,n=t.length,o;i<n;++i)Array.isArray(o=t[i])?e(o,r,s):q(o)?e(o.args,r,s):J(o)?(o.beginColumnRelative&&(o.beginColumn+=r),o.beginRowRelative&&(o.beginRow+=s),o.endColumnRelative&&(o.endColumn+=r),o.endRowRelative&&(o.endRow+=s)):W(o)&&(o.columnRelative&&(o.column+=r),o.rowRelative&&(o.row+=s));return t}},{getArgumentValue:eg}=em;em.registerProcessorFunction("ABS",function(e,t){let r=eg(e[0],t);switch(typeof r){case"number":return Math.abs(r);case"object":{let e=[];for(let t=0,s=r.length,i;t<s;++t){if("number"!=typeof(i=r[t]))return NaN;e.push(Math.abs(i))}return e}default:return NaN}});let{getArgumentValue:ey}=em;em.registerProcessorFunction("AND",function e(t,r){for(let s=0,i=t.length,n;s<i;++s)if(!(n=ey(t[s],r))||"object"==typeof n&&!e(n,r))return!1;return!0});let{getArgumentsValues:eb}=em;em.registerProcessorFunction("AVERAGE",function(e,t){let r=eb(e,t),s=0,i=0;for(let e=0,t=r.length,n;e<t;++e)switch(typeof(n=r[e])){case"number":isNaN(n)||(++s,i+=n);break;case"object":for(let e=0,t=n.length,r;e<t;++e)"number"!=typeof(r=n[e])||isNaN(r)||(++s,i+=r)}return s?i/s:0});let{getArgumentValue:ew}=em;em.registerProcessorFunction("AVERAGEA",function(e,t){let r=0,s=0;for(let i=0,n=e.length,o;i<n;++i)switch(typeof(o=ew(e[i],t))){case"boolean":++r,s+=+!!o;continue;case"number":isNaN(o)||(++r,s+=o);continue;case"string":++r;continue;default:for(let e=0,t=o.length,i;e<t;++e)switch(typeof(i=o[e])){case"boolean":++r,s+=+!!i;continue;case"number":isNaN(i)||(++r,s+=i);continue;case"string":++r;continue}continue}return r?s/r:0}),em.registerProcessorFunction("COUNT",function e(t,r){let s=em.getArgumentsValues(t,r),i=0;for(let t=0,n=s.length,o;t<n;++t)switch(typeof(o=s[t])){case"number":!isNaN(o)&&++i;break;case"object":i+=e(o,r)}return i}),em.registerProcessorFunction("COUNTA",function e(t,r){let s=em.getArgumentsValues(t,r),i=0;for(let t=0,n=s.length,o;t<n;++t){switch(typeof(o=s[t])){case"number":if(isNaN(o))continue;break;case"object":i+=e(o,r);continue;case"string":if(!o)continue}++i}return i});let{getArgumentValue:eC}=em;em.registerProcessorFunction("IF",function(e,t){return eC(e[0],t)?eC(e[1],t):eC(e[2],t)});let{getArgumentValue:eR}=em;em.registerProcessorFunction("ISNA",function(e,t){let r=eR(e[0],t);return"number"!=typeof r||isNaN(r)});let{getArgumentsValues:eN}=em;em.registerProcessorFunction("MAX",function e(t,r){let s=eN(t,r),i=-1/0;for(let t=0,r=s.length,n;t<r;++t)switch(typeof(n=s[t])){case"number":n>i&&(i=n);break;case"object":(n=e(n))>i&&(i=n)}return isFinite(i)?i:0}),em.registerProcessorFunction("MEDIAN",function(e,t){let r=[],s=em.getArgumentsValues(e,t);for(let e=0,t=s.length,i;e<t;++e)switch(typeof(i=s[e])){case"number":isNaN(i)||r.push(i);break;case"object":for(let e=0,t=i.length,s;e<t;++e)"number"!=typeof(s=i[e])||isNaN(s)||r.push(s)}let i=r.length;if(!i)return NaN;let n=Math.floor(i/2);return i%2?r[n]:(r[n-1]+r[n])/2});let{getArgumentsValues:eT}=em;em.registerProcessorFunction("MIN",function e(t,r){let s=eT(t,r),i=1/0;for(let t=0,r=s.length,n;t<r;++t)switch(typeof(n=s[t])){case"number":n<i&&(i=n);break;case"object":(n=e(n))<i&&(i=n)}return isFinite(i)?i:0});let{getArgumentValue:ev}=em;function eO(e,t){let r={},s=em.getArgumentsValues(e,t);for(let e=0,t=s.length,i;e<t;++e)switch(typeof(i=s[e])){case"number":isNaN(i)||(r[i]=(r[i]||0)+1);break;case"object":for(let e=0,t=i.length,s;e<t;++e)"number"!=typeof(s=i[e])||isNaN(s)||(r[s]=(r[s]||0)+1)}return r}function eA(e,t){let r=eO(e,t),s=Object.keys(r);if(!s.length)return NaN;let i=parseFloat(s[0]),n=r[s[0]];for(let e=1,t=s.length,o,l,a;e<t;++e)n<(a=r[o=s[e]])?(i=parseFloat(o),n=a):n===a&&i>(l=parseFloat(o))&&(i=l,n=a);return n>1?i:NaN}em.registerProcessorFunction("MOD",function(e,t){let r=ev(e[0],t),s=ev(e[1],t);return("object"==typeof r&&(r=r[0]),"object"==typeof s&&(s=s[0]),"number"!=typeof r||"number"!=typeof s||0===s)?NaN:r%s}),em.registerProcessorFunction("MODE",eA),em.registerProcessorFunction("MODE.MULT",function(e,t){let r=eO(e,t),s=Object.keys(r);if(!s.length)return NaN;let i=[parseFloat(s[0])],n=r[s[0]];for(let e=1,t=s.length,o,l;e<t;++e)n<(l=r[o=s[e]])?(i=[parseFloat(o)],n=l):n===l&&i.push(parseFloat(o));return n>1?i:NaN}),em.registerProcessorFunction("MODE.SNGL",eA);let{getArgumentValue:eM}=em;em.registerProcessorFunction("NOT",function(e,t){let r=eM(e[0],t);switch("object"==typeof r&&(r=r[0]),typeof r){case"boolean":case"number":return!r}return NaN});let{getArgumentValue:ex}=em;em.registerProcessorFunction("OR",function e(t,r){for(let s=0,i=t.length,n;s<i;++s)if("object"==typeof(n=ex(t[s],r))){if(e(n,r))return!0}else if(n)return!0;return!1});let{getArgumentsValues:eE}=em;em.registerProcessorFunction("PRODUCT",function e(t,r){let s=eE(t,r),i=1,n=!1;for(let t=0,o=s.length,l;t<o;++t)switch(typeof(l=s[t])){case"number":isNaN(l)||(n=!0,i*=l);break;case"object":n=!0,i*=e(l,r)}return n?i:0}),em.registerProcessorFunction("SUM",function e(t,r){let s=em.getArgumentsValues(t,r),i=0;for(let t=0,n=s.length,o;t<n;++t)switch(typeof(o=s[t])){case"number":isNaN(o)||(i+=o);break;case"object":i+=e(o,r)}return i});let{getArgumentValue:eI}=em;em.registerProcessorFunction("XOR",function(e,t){for(let r=0,s=e.length,i,n;r<s;++r)switch(typeof(n=eI(e[r],t))){case"boolean":case"number":if(void 0===i)i=!!n;else if(!!n!==i)return!0;break;case"object":for(let e=0,t=n.length,r;e<t;++e)switch(typeof(r=n[e])){case"boolean":case"number":if(void 0===i)i=!!r;else if(!!r!==i)return!0}}return!1});let eF={...B,...em,...K};class eD extends O{constructor(e){const t=(0,n.merge)(eD.defaultOptions,e);super(t),this.headers=[],this.dataTypes=[],this.options=t}parse(e,t){let r=this.dataTypes,s=(0,n.merge)(this.options,e),{beforeParse:i,lineDelimiter:o,firstRowAsNames:l,itemDelimiter:a}=s,u,h=0,{csv:c,startRow:d,endRow:f}=s,p,m=[];if(this.emit({type:"parse",columns:m,detail:t,headers:this.headers}),c&&i&&(c=i(c)),c){if(u=c.replace(/\r\n|\r/g,"\n").split(o||"\n"),(!d||d<0)&&(d=0),(!f||f>=u.length)&&(f=u.length-1),a||(this.guessedItemDelimiter=this.guessDelimiter(u)),l){let e=u[0].split(a||this.guessedItemDelimiter||",");for(let t=0;t<e.length;t++)e[t]=e[t].trim().replace(/^["']|["']$/g,"");this.headers=e,d++}let e=0;for(h=d;h<=f;h++)"#"===u[h][0]?e++:this.parseCSVRow(m,u[h],h-d-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){p=m[e];for(let t=0,r=p.length;t<r;++t)if(p[t]&&"string"==typeof p[t]){let r=this.convertByType(p[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}),N(m,this.headers)}parseCSVRow(e,t,r){let s=this,i=s.dataTypes,{startColumn:n,endColumn:o}=s.options,l=s.options.itemDelimiter||s.guessedItemDelimiter,{decimalPoint:a}=s.options;a&&a!==l||(a=s.guessedDecimalPoint||".");let u=0,h="",c="",d=0,f=0,p=e=>{h=t[e]},m=e=>{i.length<f+1&&i.push([e]),i[f][i[f].length-1]!==e&&i[f].push(e)},g=()=>{if(n>d||d>o){++d,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<f+1&&e.push([]),"number"!=typeof c&&"number"!==T(c,s)&&a){let e=c;"number"!==T(c=c.replace(a,"."),s)&&(c=e)}e[f][r]=c,c="",++f,++d};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,s,i={",":0,";":0,"	":0},n=e.length;for(let s=0;s<n;s++){let n=!1,o,l,a,u="";if(s>13)break;let h=e[s];for(let e=0;e<h.length&&(o=h[e],l=h[e+1],a=h[e-1],"#"!==o);e++){if('"'===o)if(n){if('"'!==a&&'"'!==l){for(;" "===l&&e<h.length;)l=h[++e];void 0!==i[l]&&i[l]++,n=!1}}else n=!0;else void 0!==i[o]?(isNaN(Date.parse(u=u.trim()))?(isNaN(Number(u))||!isFinite(Number(u)))&&i[o]++:i[o]++,u=""):u+=o;","===o&&r++,"."===o&&t++}}return i[";"]>i[","]?s=";":(i[","]>i[";"],s=","),t>r?this.guessedDecimalPoint=".":this.guessedDecimalPoint=",",s}}eD.defaultOptions={...O.defaultOptions,lineDelimiter:"\n",startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},O.registerType("CSV",eD);class ej extends y{constructor(e){const t=(0,n.merge)(ej.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){(0,n.fireEvent)(this,e.type,e)}load(e){let t=this,r=t.options,{csv:s,csvURL:i,dataTables:o,decimalPoint:l}=r;return t.emit({type:"load",csv:s}),Promise.resolve(i?fetch(i,{signal:t?.pollingController?.signal}).then(e=>e.text()):s||"").then(e=>(e&&this.initConverters(e,e=>{let{firstRowAsNames:t=r.firstRowAsNames,beforeParse:s=r.beforeParse}=o?.find(t=>t.key===e)||{};return new eD((0,n.merge)(r,{decimalPoint:l,firstRowAsNames:t,beforeParse:s}))},(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})}}ej.defaultOptions={id:"csv-connector",type:"CSV",csv:"",csvURL:"",enablePolling:!1,dataRefreshRate:1,firstRowAsNames:!0},y.registerType("CSV",ej);class eP extends O{constructor(e){const t=(0,n.merge)(eP.defaultOptions,e);super(t),this.headerColumnIds=[],this.headers=[],this.options=t}parse(e,t){let{beforeParse:r,orientation:s,firstRowAsNames:i,columnIds:o}=e=(0,n.merge)(this.options,e),l=e.data;if(!l)return{};this.headers=[];let a=[];return this.emit({type:"parse",columns:a,detail:t,headers:this.headers}),r&&(l=r(l)),l=l.slice(),"columns"===s?this.parseColumnsOrientation(a,l,i,o):"rows"===s&&this.parseRowsOrientation(a,l,i,o),this.emit({type:"afterParse",columns:a,detail:t,headers:this.headers}),N(a,this.headers)}parseColumnsOrientation(e,t,r,s){for(let i=0,o=t.length;i<o;i++){let o=t[i];if(!Array.isArray(o))return;Array.isArray(this.headers)?(r?this.headers.push(`${o.shift()}`):s&&Array.isArray(s)&&this.headers.push(s[i]),e.push(o)):(0,n.error)("JSONConverter: Invalid `columnIds` option.",!1)}}parseRowsOrientation(e,t,r,s){r?this.headers=t.shift():s&&(this.headerColumnIds=s);for(let i=0,o=t.length;i<o;i++){let o=t[i];(0,n.isArray)(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]),r||0!==i||(Array.isArray(this.headerColumnIds)?this.headers.push(this.headerColumnIds[t]||t.toString()):(0,n.error)("JSONConverter: Invalid `columnIds` option.",!1))}}convertItemToRow(e,t){let r=this;if(t&&!Array.isArray(t)){let s=[];return(0,n.objectEach)(t,(t,i)=>{s.push(t.reduce((e,t)=>e[t],e)),0>r.headers.indexOf(i)&&r.headers.push(i)}),s}return r.headerColumnIds=Object.keys(e),Object.values(e)}}eP.defaultOptions={...O.defaultOptions,orientation:"rows"},O.registerType("JSON",eP);class ek extends y{constructor(e){const t=(0,n.merge)(ek.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){(0,n.fireEvent)(this,e.type,e)}load(e){let t=this,r=t.options,{data:s,dataUrl:i,dataTables:n}=r;return t.emit({type:"load",detail:e,data:s}),Promise.resolve(i?fetch(i,{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 ${i}.`)}):s||[]).then(async e=>(e&&this.initConverters(e,t=>{let{columnIds:s=r.columnIds,firstRowAsNames:i=r.firstRowAsNames,orientation:o=r.orientation,beforeParse:l=r.beforeParse}=n?.find(e=>e.key===t)||{};return new eP({data:e,columnIds:s,firstRowAsNames:i,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})}}ek.defaultOptions={type:"JSON",id:"json-connector",data:[],enablePolling:!1,dataRefreshRate:0,firstRowAsNames:!0,orientation:"rows"},y.registerType("JSON",ek);class eL extends O{constructor(e){const t=(0,n.merge)(eL.defaultOptions,e);super(t),this.header=[],this.options=t}parse(e,t){let r,s=(0,n.merge)(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++){r=i[e],this.header[e]=s.firstRowAsNames?`${r.shift()}`:(0,n.uniqueKey)();for(let t=0,s=r.length;t<s;++t){var a;let s=r[t];a=s,"[object Date]"===Object.prototype.toString.call(a)&&(s=s.getTime()),i[e][t]=s}}return this.emit({type:"afterParse",columns:i,detail:t,headers:this.header}),N(i,this.header)}}eL.defaultOptions={...O.defaultOptions},O.registerType("GoogleSheets",eL);class eY extends y{constructor(e){const t=(0,n.merge)(eY.defaultOptions,e);super(t),this.options=t}emit(e){(0,n.fireEvent)(this,e.type,e)}load(e){let t=this,r=t.options,{dataRefreshRate:s,enablePolling:i,googleAPIKey:o,googleSpreadsheetKey:l,dataTables:a}=r,u=function(e,t,r={}){let s=new URL(`https://sheets.googleapis.com/v4/spreadsheets/${t}/values/`),i=r.onlyColumnIds?"A1:Z1":function(e={}){let{endColumn:t,endRow:r,googleSpreadsheetRange:s,startColumn:i,startRow:o}=e;return s||(eS[i||0]||"A")+(Math.max(o||0,0)+1)+":"+(eS[(0,n.pick)(t,25)]||"Z")+(r?Math.max(r,0):"Z")}(r);s.pathname+=i;let o=s.searchParams;return o.set("alt","json"),r.onlyColumnIds||(o.set("dateTimeRenderOption","FORMATTED_STRING"),o.set("majorDimension","COLUMNS"),o.set("valueRenderOption","UNFORMATTED_VALUE")),o.set("prettyPrint","false"),o.set("key",e),s.href}(o,l,r);if(t.emit({type:"load",detail:e,url:u}),!URL.canParse(u))throw Error("Invalid URL: "+u);return fetch(u,{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:s=r.beforeParse}=a?.find(t=>t.key===e)||{};return new eL({firstRowAsNames:t,beforeParse:s})},(e,t)=>e.parse({json:t})),t.applyTableModifiers()}).then(()=>(t.emit({type:"afterLoad",detail:e,url:u}),i&&setTimeout(()=>t.load(),1e3*Math.max(s||0,1)),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}eY.defaultOptions={id:"google-sheets-connector",type:"GoogleSheets",googleAPIKey:"",googleSpreadsheetKey:"",enablePolling:!1,dataRefreshRate:2,firstRowAsNames:!0};let eS="ABCDEFGHIJKLMNOPQRSTUVWXYZ";y.registerType("GoogleSheets",eY);class eV extends O{constructor(e){const t=(0,n.merge)(eV.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,s=t.useMultiLevelHeaders,i=e.getSortedColumns(),n=Object.keys(i),o=[],l=n.length,a=[],u="";if(r){let e=[];if(s){for(let t of n){let r=i[t];Array.isArray(r)||(r=Array.from(r));let s=(r.shift()||"").toString();i[t]=r,e.push(s)}u=this.getTableHeaderHTML(n,e,t)}else u=this.getTableHeaderHTML(void 0,n,t)}for(let e=0;e<l;e++){let t=i[n[e]],r=t.length;for(let s=0;s<r;s++){let r=t[s];a[s]||(a[s]=[]),"string"!=typeof r&&"number"!=typeof r&&void 0!==r&&(r=(r||"").toString()),a[s][e]=this.getCellHTMLFromValue(e?"td":"th",null,e?"":'scope="row"',r),e===l-1&&o.push("<tr>"+a[s].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,s,i){let n=s,o="text"+(t?" "+t:"");return"number"==typeof n?(n=n.toString(),","===i&&(n=n.replace(".",i)),o="number"):s||(n="",o="empty"),"<"+e+(r?" "+r:"")+' class="'+o+'">'+n+"</"+e+">"}getTableHeaderHTML(e=[],t=[],r=this.options){let{useMultiLevelHeaders:s,useRowspanHeaders:i}=r,n="<thead>",o=0,l=t&&t.length,a,u=0,h;if(s&&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(n+="<tr>";o<l;++o)(a=e[o])===e[o+1]?++u:u?(n+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col" colspan="'+(u+1)+'"',a),u=0):(a===t[o]?i?(h=2,t.splice(o,1)):(h=1,t[o]=""):h=1,n+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col"'+(h>1?' valign="top" rowspan="'+h+'"':""),a));n+="</tr>"}if(t){for(n+="<tr>",o=0,l=t.length;o<l;++o)void 0!==t[o]&&(n+=this.getCellHTMLFromValue("th",null,'scope="col"',t[o]));n+="</tr>"}return n+"</thead>"}parse(e,t){let r=[],s=[],i=(0,n.merge)(this.options,e),{endRow:o,startColumn:l,endColumn:a,firstRowAsNames:u}=i,h=i.tableElement||this.tableElement;if(!(h instanceof HTMLElement))return this.emit({type:"parseError",columns:r,detail:t,headers:s,error:"Not a valid HTML Table"}),{};this.tableElement=h,this.tableElementID=h.id,this.emit({type:"parse",columns:r,detail:t,headers:this.headers});let c=h.getElementsByTagName("tr"),d=c.length,f=0,p,{startRow:m}=i;if(u&&d){let e=c[0].children,t=e.length;for(let r=l;r<t&&!(r>a);r++)("TD"===(p=e[r]).tagName||"TH"===p.tagName)&&s.push(p.innerHTML);m++}for(;f<d;){if(f>=m&&f<=o){let e=c[f].children,t=e.length,s=0;for(;s<t;){let t=s-l,i=r[t];if(("TD"===(p=e[s]).tagName||"TH"===p.tagName)&&s>=l&&s<=a){r[t]||(r[t]=[]);let e=this.convertByType(p.innerHTML);e instanceof Date&&(e=e.getTime()),r[t][f-m]=e;let s=1;for(;f-m>=s&&void 0===i[f-m-s];)i[f-m-s]=null,s++}s++}}f++}return this.headers=s,this.emit({type:"afterParse",columns:r,detail:t,headers:s}),N(r,this.headers)}}eV.defaultOptions={...O.defaultOptions,useRowspanHeaders:!0,useMultiLevelHeaders:!0,startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},O.registerType("HTMLTable",eV);let{win:e$}=o();class eU extends y{constructor(e){const t=(0,n.merge)(eU.defaultOptions,e);super(t),this.options=t,this.converter=new eV(t)}async load(e){let t,r=this.options,s=this.converter,i=this.getTable(),o=r.htmlTable;if(this.emit({type:"load",detail:e}),"string"==typeof o?(this.tableID=o,t=e$.document.getElementById(o)):(t=o,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 l=s.parse((0,n.merge)({tableElement:this.tableElement},r),e);return i.deleteColumns(),i.setColumns(l),await this.applyTableModifiers(),this.emit({type:"afterLoad",detail:e}),this}}eU.defaultOptions={id:"HTML-table-connector",type:"HTMLTable",htmlTable:""},y.registerType("HTMLTable",eU);class eH extends a{constructor(e,...t){super(),this.chain=t,this.options=(0,n.merge)(eH.defaultOptions,e);const r=this.options.chain||[];for(let e=0,s=r.length,i,n;e<s;++e)(i=r[e]).type&&(n=a.types[i.type])&&t.push(new n(i))}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 s=e;for(let i=0,n=r.length;i<n;++i){try{await r[i].modify(s,t)}catch(r){throw this.emit({type:"error",detail:t,table:e}),r}s=s.getModified()}return e.modified=s,e}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.reverse?this.chain.reverse():this.chain.slice(),s=e.getModified();for(let e=0,i=r.length;e<i;++e)s=r[e].modifyTable(s,t).getModified();return e.modified=s,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){(0,n.fireEvent)(this,e.type,e)}on(e,t){return(0,n.addEvent)(this,e,t)}}eH.defaultOptions={type:"Chain"},a.registerType("Chain",eH);class e_ extends a{constructor(e){super(),this.options=(0,n.merge)(e_.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||[],s={},i=[];for(let e=0,r=t.length;e<r;++e)i.push(""+t[e]);for(let t=0,r=e.getRowCount(),n;t<r;++t)(n=e.getRow(t))&&(s[i[t]]=n);r.deleteColumns(),r.setColumns(s)}else{let t={};for(let r=0,s=e.getRowCount(),i;r<s;++r)(i=e.getRow(r))&&(t[`${r}`]=i);t.columnIds=e.getColumnIds(),r.deleteColumns(),r.setColumns(t)}return this.emit({type:"afterModify",detail:t,table:e}),e}}e_.defaultOptions={type:"Invert"},a.registerType("Invert",e_);class eB extends a{constructor(e){super(),this.options={...eB.defaultOptions,...e}}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.alternativeSeparators,s=this.options.formulaColumns||e.getColumnIds(),i=e.getModified();for(let t=0,r=s.length,n;t<r;++t)n=s[t],s.indexOf(n)>=0&&i.setColumn(n,this.processColumn(e,n));let n=this.options.columnFormulas||[];for(let t=0,s=n.length,o,l;t<s;++t)o=n[t],l=B.parseFormula(o.formula,r),i.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 s=this.options.alternativeSeparators,i=(e.getColumn(t,!0)||[]).slice(r>0?r:0);for(let t=0,r=i.length,n=[],o;t<r;++t)if("string"==typeof(o=i[t])&&"="===o[0])try{n=""===o?n:B.parseFormula(o.substring(1),s),i[t]=em.processFormula(n,e)}catch{i[t]=NaN}return i}processColumnFormula(e,t,r=0,s=t.getRowCount()){r=r>=0?r:0,s=s>=0?s:t.getRowCount()+s;let i=[],n=t.getModified();for(let t=0,o=s-r;t<o;++t)try{i[t]=em.processFormula(e,n)}catch{i[t]=NaN}finally{e=em.translateReferences(e,0,1)}return i}}eB.defaultOptions={type:"Math",alternativeSeparators:!1},a.registerType("Math",eB);class eZ extends a{constructor(e){super(),this.options=(0,n.merge)(eZ.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{start:r,end:s}=this.options;r=Math.max(0,r||0);let i=Math.max((s=Math.min(s||1/0,e.getRowCount()))-r,0),n=e.getModified();return n.deleteRows(),n.setRows(e.getRows(r,i)),n.setOriginalRowIndexes(Array.from({length:i},(t,s)=>e.getOriginalRowIndex(r+s))),this.emit({type:"afterModify",detail:t,table:e}),e}}eZ.defaultOptions={type:"Range",start:0,end:1/0},a.registerType("Range",eZ);class eK extends a{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?eK.ascending:eK.descending}constructor(e){super(),this.options=(0,n.merge)(eK.defaultOptions,e)}getRowReferences(e){let t=e.getRows(),r=[];for(let e=0,s=t.length;e<s;++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(),s=e.getRowCount(),i=this.getRowReferences(e),{direction:n,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],s="string"==typeof t,i=s?t:t.column,o=r.indexOf(i);-1!==o&&h.push({columnIndex:o,compare:eK.compareFactory(s?n:t.direction||n,s?l:t.compare||l)})}if(h.length&&i.sort((e,t)=>{for(let r=0,s=h.length;r<s;++r){let{columnIndex:s,compare:i}=h[r],n=i(e.row[s],t.row[s]);if(n)return n}return e.index-t.index}),o){let e=[];for(let t=0;t<s;++t)e[i[t].index]=t;a.setColumns({[o]:e})}else{let t,r=[],n=[];for(let o=0;o<s;++o)t=i[o],r.push(e.getOriginalRowIndex(t.index)),n.push(t.row);a.setRows(n,0),a.setOriginalRowIndexes(r)}return this.emit({type:"afterModify",detail:t,table:e}),e}}eK.defaultOptions={type:"Sort",direction:"desc",orderByColumn:"y"},a.registerType("Sort",eK);class eX extends a{static compile(e){if((0,n.isFunction)(e))return e;let t=e.operator;switch(t){case"and":{let t=e.conditions.map(e=>this.compile(e));return(e,r,s)=>t.every(t=>t(e,r,s))}case"or":{let t=e.conditions.map(e=>this.compile(e));return(e,r,s)=>t.some(t=>t(e,r,s))}case"not":{let t=this.compile(e.condition);return(e,r,s)=>!t(e,r,s)}}let{columnId:r,value:s}=e;switch(t){case"==":return e=>e[r]==s;case"===":return e=>e[r]===s;case"!=":return e=>e[r]!=s;case"!==":return e=>e[r]!==s;case">":return e=>(e[r]||0)>(s||0);case">=":return e=>(e[r]||0)>=(s||0);case"<":return e=>(e[r]||0)<(s||0);case"<=":return e=>(e[r]||0)<=(s||0);case"empty":return e=>null===e[r]||""===e[r]}let{ignoreCase:i}=e,o=e=>{let t=""+e;return i??!0?t.toLowerCase():t};return"contains"===t?e=>o(e[r]).includes(o(s)):e=>o(e[r])[t](o(s))}constructor(e){super(),this.options=(0,n.merge)(eX.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{condition:r}=this.options;if(!r)return e;let s=eX.compile(r),i=e.getModified(),n=[],o=[];for(let t=0,r=e.getRowCount();t<r;++t){let r=e.getRowObject(t);r&&s(r,e,t)&&(n.push(r),o.push(e.getOriginalRowIndex(t)))}return i.deleteRows(),i.setRows(n),i.setOriginalRowIndexes(o),this.emit({type:"afterModify",detail:t,table:e}),e}}eX.defaultOptions={type:"Filter"},a.registerType("Filter",eX);let eq=o();eq.DataConnector=eq.DataConnector||y,eq.DataConverter=eq.DataConverter||O,eq.DataCursor=eq.DataCursor||M,eq.DataModifier=eq.DataModifier||a,eq.DataPool=eq.DataPool||x,eq.DataTable=eq.DataTable||m,eq.Formula=eq.Formula||eF;let eG=o();return i.default})());