@chartshq/datamodel
Version:
An environment with `node`, `rustup` and `wasm-pack` set up.
1 lines • 70.6 kB
JavaScript
exports.ids=[2],exports.modules=[,,,function(t,e,r){"use strict";var n;r.r(e),function(t){t.SUM="sum",t.AVG="avg",t.MIN="min",t.MAX="max",t.FIRST="first",t.LAST="last",t.COUNT="count",t.STD="std"}(n||(n={}));var o,i,a=function(t){return{sum:0,avg:1,count:3,min:4,max:5,std:6}[t]};!function(t){t.EQUAL="eq",t.NOT_EQUAL="neq",t.GREATER_THAN="gt",t.LESS_THAN="lt",t.GREATER_THAN_EQUAL="gte",t.LESS_THAN_EQUAL="lte",t.IN="in",t.NIN="nin",t.EQUAL_TO="eq",t.NOT_EQUAL_TO="neq"}(o||(o={})),function(t){t.AND="and",t.OR="or"}(i||(i={}));var u,s=function(t){var e={eq:1,neq:2,gt:3,lt:4,gte:5,lte:6,in:9,nin:10,and:7,or:8}[t];return void 0!==e?e:-1};!function(t){t.NORMAL="normal",t.INVERSE="inverse",t.ALL="all"}(u||(u={}));var c,f=function(t){return{normal:1,inverse:2,all:3}[t]};!function(t){t.ASC="asc",t.DESC="desc",t.NO_ORDER=""}(c||(c={}));var l=function(t){return t===c.DESC?1:t===c.NO_ORDER?3:0},p=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},d=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(p(arguments[e]));return t};function h(t){return t instanceof Date?t:new Date(t)}function _(t){return t<10?"0"+t:t}function v(t){this.format=t,this.dtParams=void 0,this.nativeDate=void 0}RegExp.escape=function(t){return t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},v.TOKEN_PREFIX="%",v.DATETIME_PARAM_SEQUENCE={YEAR:0,MONTH:1,DAY:2,HOUR:3,MINUTE:4,SECOND:5,MILLISECOND:6},v.defaultNumberParser=function(t){return function(e){var r;return isFinite(r=parseInt(e,10))?r:t}},v.defaultRangeParser=function(t,e){return function(r){var n,o;if(!r)return e;var i=r.toLowerCase();for(n=0,o=t.length;n<o;n++)if(t[n].toLowerCase()===i)return n;return void 0===n?e:null}},v.getTokenDefinitions=function(){var t={short:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],long:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},e={short:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],long:["January","February","March","April","May","June","July","August","September","October","November","December"]};return{H:{name:"H",index:3,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){return h(t).getHours().toString()}},l:{name:"l",index:3,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){var e=h(t).getHours()%12;return(0===e?12:e).toString()}},p:{name:"p",index:3,extract:function(){return"(AM|PM)"},parser:function(t){return t?t.toLowerCase():null},formatter:function(t){return h(t).getHours()<12?"AM":"PM"}},P:{name:"P",index:3,extract:function(){return"(am|pm)"},parser:function(t){return t?t.toLowerCase():null},formatter:function(t){return h(t).getHours()<12?"am":"pm"}},M:{name:"M",index:4,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){return _(h(t).getMinutes())}},S:{name:"S",index:5,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){return _(h(t).getSeconds())}},K:{name:"K",index:6,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){return h(t).getMilliseconds().toString()}},a:{name:"a",index:2,extract:function(){return"("+t.short.join("|")+")"},parser:v.defaultRangeParser(t.short),formatter:function(e){var r=h(e).getDay();return t.short[r].toString()}},A:{name:"A",index:2,extract:function(){return"("+t.long.join("|")+")"},parser:v.defaultRangeParser(t.long),formatter:function(e){var r=h(e).getDay();return t.long[r].toString()}},e:{name:"e",index:2,extract:function(){return"(\\d+) of ("+e.long.join("|")+")"},parser:v.defaultNumberParser(),formatter:function(t){return h(t).getDate().toString()}},d:{name:"d",index:2,extract:function(){return"(\\d+)"},parser:v.defaultNumberParser(),formatter:function(t){return _(h(t).getDate())}},b:{name:"b",index:1,extract:function(){return"("+e.short.join("|")+")"},parser:v.defaultRangeParser(e.short),formatter:function(t){var r=h(t).getMonth();return e.short[r].toString()}},B:{name:"B",index:1,extract:function(){return"("+e.long.join("|")+")"},parser:v.defaultRangeParser(e.long),formatter:function(t){var r=h(t).getMonth();return e.long[r].toString()}},m:{name:"m",index:1,extract:function(){return"(\\d+)"},parser:function(t){return v.defaultNumberParser()(t)-1},formatter:function(t){return _(h(t).getMonth()+1)}},y:{name:"y",index:0,extract:function(){return"(\\d{2})"},parser:function(t){var e;if(t){var r=t.length;t=t.substring(r-2,r)}var n=v.defaultNumberParser()(t),o=new Date,i=Math.trunc(o.getFullYear()/100);return h(e=""+i+n).getFullYear()>o.getFullYear()&&(e=""+(i-1)+n),h(e).getFullYear()},formatter:function(t){var e,r=h(t).getFullYear().toString();return r&&(e=r.length,r=r.substring(e-2,e)),r}},Y:{name:"Y",index:0,extract:function(){return"(\\d{4})"},parser:v.defaultNumberParser(),formatter:function(t){return h(t).getFullYear().toString()}}}},v.getTokenFormalNames=function(){var t=v.getTokenDefinitions();return{HOUR:t.H,HOUR_12:t.l,AMPM_UPPERCASE:t.p,AMPM_LOWERCASE:t.P,MINUTE:t.M,SECOND:t.S,SHORT_DAY:t.a,LONG_DAY:t.A,DAY_OF_MONTH:t.e,DAY_OF_MONTH_CONSTANT_WIDTH:t.d,SHORT_MONTH:t.b,LONG_MONTH:t.B,MONTH_OF_YEAR:t.m,SHORT_YEAR:t.y,LONG_YEAR:t.Y}},v.tokenResolver=function(){var t=v.getTokenDefinitions(),e=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r,n,o=0,i=t.length;o<i;o++)r=t[o],t[o]&&(n=r);return n?n[0].parser(n[1]):null};return{YEAR:[t.y,t.Y,e],MONTH:[t.b,t.B,t.m,e],DAY:[t.a,t.A,t.d,e],HOUR:[t.H,t.l,t.p,t.P,function(t,e,r,n){var o,i,a,u;return e&&(i=r||n)?("pm"===i[0].parser(i[1])&&(a=!0),o=e):o=e||t,o?(u=o[0].parser(o[1]),a&&(u+=12),u):null}],MINUTE:[t.M,e],SECOND:[t.S,e],MILLISECOND:[t.K,e]}},v.findTokens=function(t){for(var e,r,n=v.TOKEN_PREFIX,o=v.getTokenDefinitions(),i=Object.keys(o),a=[];(e=t.indexOf(n,e+1))>=0;)r=t[e+1],-1!==i.indexOf(r)&&a.push({index:e,token:r});return a},v.formatAs=function(t,e){var r,n,o,i,a=h(t),u=v.findTokens(e),s=v.getTokenDefinitions(),c=String(e),f=v.TOKEN_PREFIX;for(o=0,i=u.length;o<i;o++)n=s[r=u[o].token].formatter(a),c=c.replace(new RegExp(f+r,"g"),n);return c},v.prototype.parse=function(t,e){var r,n,o,i,a,u,s,c,f=v.tokenResolver(),l=this.extractTokenValue(t),p=v.DATETIME_PARAM_SEQUENCE,h=e&&e.noBreak,_=[],g=[],y=[];for(r in f)if({}.hasOwnProperty.call(f,r)){for(g.length=0,o=(n=f[r]).splice(n.length-1,1)[0],a=0,c=n.length;a<c;a++)void 0===(i=l[(u=n[a]).name])?g.push(null):g.push([u,i]);if(null==(s=o.apply(this,g))&&!h)break;_[p[r]]=s}return _.length&&this.checkIfOnlyYear(_.length)?y.unshift(_[0],0,1):y.unshift.apply(y,d(_)),y},v.prototype.extractTokenValue=function(t){var e,r,n,o,i,a,u,s=this.format,c=v.getTokenDefinitions(),f=v.TOKEN_PREFIX,l=v.findTokens(s),p={};i=String(s);var d=l.map((function(t){return t.token})),h=l.length;for(u=h-1;u>=0;u--)(n=l[u].index)+1!==i.length-1?(void 0===e&&(e=i.length),o=i.substring(n+2,e),i=i.substring(0,n+2)+RegExp.escape(o)+i.substring(e,i.length),e=n):e=n;for(u=0;u<h;u++)r=l[u],i=i.replace(f+r.token,c[r.token].extract());var _=(null==t?void 0:t.match(new RegExp(i)))||[];for(_.shift(),u=0,a=d.length;u<a;u++)p[d[u]]=_[u];return p},v.prototype.getNativeDate=function(t){var e=null,r=!this.format||"string"!=typeof this.format;if(Number.isFinite(t)&&r)e=new Date(t);else if(r)e=new Date(t);else{var n=this.dtParams=this.parse(t);n.length&&(this.nativeDate=new(Date.bind.apply(Date,d([void 0],n))),e=this.nativeDate)}return e},v.prototype.checkIfOnlyYear=function(t){return 1===t&&this.format.match(/y|Y/g).length};var g,y=function(t){var e=0;return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];r.forEach((function(r,n){t[n]instanceof Array||(t[n]=Array.from({length:e})),t[n].push(r)})),e++}};function m(t){return Array.isArray(t)}!function(t){t.FLAT_JSON="FlatJSON",t.DSV_STR="DSVStr",t.DSV_ARR="DSVArr",t.AUTO="Auto"}(g||(g={}));var b,w,O=function(t){return"string"==typeof t?g.DSV_STR:m(t)&&m(t[0])?g.DSV_ARR:m(t)&&(0===t.length||function(t){return t===Object(t)}(t[0]))?g.FLAT_JSON:null},A=r(12),x=r(15),S=function(t){return t.isFree},E=function(t){var e=function(){return t.find(S)};return function(t){var r,n=Object(x.a)(),o=A.a(n);return(r=e(),new Promise((function(t){if(null==r)var n=setInterval((function(){var r=e();null!=r&&(r.isFree=!1,clearInterval(n),t(r))}),64);else r.isFree=!1,t(r)}))).then((function(e){var r=e.worker;r.addEventListener("message",(function(t){var r=t.data,n=r.reqId,o=r.data;e.isFree=!0,o.error?A.b(n,new Error(o.error)):A.c(n,o.data)})),r.postMessage({data:t,reqId:n,type:"transform-data"})})),o}},D=r(14);!function(t){t.MEASURE="measure",t.DIMENSION="dimension"}(b||(b={})),function(t){t.CATEGORICAL="categorical",t.TEMPORAL="temporal",t.BINNED="binned",t.CONTINUOUS="continuous",t.ROWID="__id"}(w||(w={}));var N,M={categorical:0,continuous:1,temporal:2,__id:3},T=function(){function t(){this._type=w.CATEGORICAL}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.parse=function(t){return"number"==typeof t?String(t):t},t}(),F=function(){function t(){this._type=w.CONTINUOUS}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.parse=function(t){return t||0===t?Number(t):NaN},t}();!function(t){t.SELECT="select",t.GROUPBY="groupBy",t.PROJECT="project",t.SPLIT="split",t.SORT="sort",t.CALCULATE="calculate_variable"}(N||(N={}));var R=function(){function t(){this._type=w.TEMPORAL}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.parse=function(t,e){var r="default";if(this._dtf={},t){var n=t;e&&"string"==typeof e?(n=String(t),r=e,this._dtf&&this._dtf[r]||(this._dtf[r]=new v(r))):(n=Number(t),this._dtf&&this._dtf.default||(this._dtf.default=new v));var o=this._dtf[r].getNativeDate(n);return o?o.getTime():NaN}return NaN},t}(),C=function(){function t(){this.store=new Map,this.parsers(this._getDefaultParsers())}return t.prototype._getDefaultParsers=function(){return[new T,new F,new R]},t.prototype.parsers=function(t){var e=this;return t.forEach((function(t){return e.register(t)})),this.store},t.prototype.register=function(t){return this.store.set(t._type,t),this},t.prototype.unregister=function(t){return this.store.delete(t._type),this},t.prototype.get=function(t){return t&&this.store.has(t)?this.store.get(t):null},t}(),I=null||new C,P=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},L=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(P(arguments[e]));return t};var U=function(t,e,r){if(!Array.isArray(e))throw new Error("Schema missing or is in an unsupported format");var n=e.map((function(t){return t.name}));r=Object.assign({},{firstRowHeader:!0},r);var o=[[]],i=y(o),a=n;r.firstRowHeader&&(a=t.splice(0,1)[0]);var u=a.reduce((function(t,e,r){var n;return Object.assign(t,((n={})[e]=r,n)),t}),{});return t.forEach((function(t){var r=[];return e.forEach((function(e){var n=e.name,o=e.type,i=e.format,a=void 0===i?function(t){return t}:i,s=e.subtype,c=void 0===s?w.CATEGORICAL:s;o===b.MEASURE&&(c=w.CONTINUOUS);var f=I.get(c),l=u[n],p=f?f.parse(t[l],a):t[l];r.push(p)})),i.apply(void 0,L(r))})),{data:o,schema:e}};var j=function(t,e,r){if((r=Object.assign({},{firstRowHeader:!0,fieldSeparator:","},r)).fieldSeparator){var n=Object(D.a)(r.fieldSeparator);return U(n.parseRows(t),e,r)}return{schema:[],data:[]}},k=function(){function t(){this._type=g.DSV_STR}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.convert=function(t,e,r){return j(t,e,r)},t}(),H=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},Y=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(H(arguments[e]));return t};var V=function(t,e){if(!Array.isArray(e))throw new Error("Schema missing or is in an unsupported format");var r,n={},o=0,i=[[]],a=y(i);return t.forEach((function(t){var i=[];e.forEach((function(e){var a=e.name,u=e.type,s=e.format,c=void 0===s?function(t){return t}:s,f=e.subtype,l=void 0===f?w.CATEGORICAL:f;u===b.MEASURE&&(l=w.CONTINUOUS);var p=I.get(l);a in n?r=n[a]:(n[a]=o++,r=o-1);var d=p?p.parse(t[a],c):t[a];i[r]=d})),a.apply(void 0,Y(i))})),{data:i,schema:e}},B=function(){function t(){this._type=g.FLAT_JSON}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.convert=function(t,e){return V(t,e)},t}(),G=function(){function t(){this._type=g.DSV_ARR}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.convert=function(t,e,r){return U(t,e,r)},t}();var J=function(t,e,r){var n={FlatJSON:V,DSVStr:j,DSVArr:U},o=O(t);if(!o)throw new Error("Could not detect the data format");return n[o](t,e,r)},q=function(){function t(){this._type=g.AUTO}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!1,configurable:!0}),t.prototype.convert=function(t,e,r){return J(t,e,r)},t}(),W=function(){function t(){this.store=new Map,this.converters(this._getDefaultConverters())}return t.prototype._getDefaultConverters=function(){return[new k,new G,new B,new q]},t.prototype.converters=function(t){var e=this;return t.forEach((function(t){return e.store.set(t._type,t)})),this.store},t.prototype.register=function(t){return this.store.set(t._type,t),this},t.prototype.unregister=function(t){return this.store.delete(t._type),this},t.prototype.get=function(t){return t&&this.store.has(t)?this.store.get(t):null},t}(),K=function(){var t=null;return t||(t=new W)}(),X=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},z=function(t,e){var r=t.options;return e&&!1!==r.useWorker?function(t,e){return E(e)(t)}(t,e):new Promise((function(e,r){setTimeout((function(){try{e(function(t){var e=t.data,r=t.schema,n=t.options,o=K.get(n.dataFormat);return o?o.convert(e,r,n):{data:[],schema:r}}(t))}catch(t){r(t)}}),0)}))},Z=function(t,e,r,n){return X(void 0,void 0,void 0,(function(){var o;return Q(this,(function(i){switch(i.label){case 0:return o={dataFormat:g.AUTO},r=Object.assign(Object.assign({},o),r),[4,z({data:t,schema:e,options:r},n)];case 1:return[2,i.sent()]}}))}))},$=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{s(n.next(t))}catch(t){i(t)}}function u(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,u)}s((n=n.apply(t,e||[])).next())}))},tt=function(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}};var et,rt=r(8),nt=r.n(rt),ot=function(){function t(t){this._value=t}return t.prototype.value=function(){return this._value},t.prototype.toString=function(){return String(this._value)},t}(),it=r(4);!function(t){t.WASM="wasm"}(et||(et={}));var at,ut,st=r(5);!function(t){t.UNDEFINED=""}(at||(at={})),function(t){t.NULL="null",t.UNDEFINED="undefined",t.NAN="NaN",t.NIL="nil",t.NA="na",t.EMPTY_STRING=""}(ut||(ut={}));var ct,ft,lt,pt,dt=((ct={})[w.TEMPORAL]=function(t,e){var r=t;if("number"!=typeof t){var n=I.get(w.TEMPORAL);r=n?n.parse(t,e):t}return r},ct[w.CATEGORICAL]=function(t,e){var r=I.get(w.CATEGORICAL),n=r?r.parse(t,e):t;return wt(n)?n:"_#-"},ct[w.CONTINUOUS]=function(t,e){var r=I.get(w.CONTINUOUS);return null==r?void 0:r.parse(t,e)},ct),ht=function(t,e,r){var n=dt[t];return n?n(e,r):e},_t=function(t,e,r){void 0===r&&(r={});var n=t.conditions,o=t.operator;if(n&&o&&n.length>0){r.conditions=[];for(var i=0;i<n.length;i++){var a=r.conditions[i]={},u=_t(n[i],e,a);u.operator?a=u:r.conditions.pop()}if(r.operator=s(o),-1===r.operator)r={};else if(1===r.conditions.length)r=r.conditions[0]?r.conditions[0]:{};else{var c=[];for(var i in r.conditions)r.conditions[i]&&c.push(r.conditions[i]);r.conditions=c,1===r.conditions.length&&(r=r.conditions[0])}}else if(t.field){var f=t.field,l=t.value,p=e.get(f||{});if(p&&null!=p.index){var d=p.index,h=p.field;r.field=d;var _=h.schema(),v=_.subtype,g=void 0===v?w.CATEGORICAL:v,y=_.format,m=ht(g,l,void 0===y?function(t){return t}:y);r.value=m,r.operator=s(o),-1==r.operator&&(r={})}}return r},vt=function(t,e){new Int32Array(st.ib.buffer,t,e.length).set(e)},gt=function(t,e){new Float64Array(st.ib.buffer,t,e.length).set(e)},yt=function(t){void 0===t&&(t=[]);var e=[],r=[];return t.forEach((function(t){"number"==typeof t&&Number.isFinite(t)?(e.push(t),r.push(1)):(e.push(NaN),r.push(-1))})),{indices:r,values:e}},mt=function(t,e){for(var r=new Int32Array(st.ib.buffer,t,e),n=new Array(e),o=0;o<r.length;o++)n[o]=r[o];return n},bt=function(t,e){for(var r=new Float64Array(st.ib.buffer,t,e),n=new Array(e),o=0;o<r.length;o++)n[o]=r[o];return n},wt=function(t){var e="",r=re.defaults.getInvalidStore();if(null==t)return!1;if("number"==typeof t){if(isNaN(t))return!1;e=String(t)}else e=t;return!r.isInvalid(e)},Ot=function(t){return{name:t.name,type:(r=t.type,r===b.MEASURE?1:0),subtype:(e=t.subtype,M[e]),aggregation_function:a(t.defAggFn)};var e,r},At={stackBy:function(t,e,r,n,o){var i={y0:[],y1:[],id:[]},a=t.context();switch(re._contextType){case et.WASM:var u=a.context(),s=a.getSchema().findIndex((function(t){return e===t.name})),c=a.getSchema().findIndex((function(t){return r===t.name})),f=a.getSchema().findIndex((function(t){return n===t.name})),p=Object(it.f)(u,s,c,f,l(o));i.y0=bt(p.get_y_0(),a.getDataMeta().rows),i.y1=bt(p.get_y_1(),a.getDataMeta().rows),i.id=mt(p.get_id(),a.getDataMeta().rows),p.free_data(),p.free()}return i}},xt=function(){return(xt=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},St=function(){function t(){}return t.loadData=function(t,e,r){var n,o,i=[],a=e.map((function(t){i.push(xt({},t));var e=xt({},t),r=e.format;return r&&"function"==typeof r&&delete e.format,e}));return(n={data:t,schema:a,options:r},o=this._taskerPool,$(void 0,void 0,void 0,(function(){var t,e,r;return tt(this,(function(i){switch(i.label){case 0:return t=n.data,e=n.schema,r=n.options,[4,Z(t,e,r,o)];case 1:return[2,i.sent()]}}))}))).then((function(t){return t.schema=i,t}))},t.AggregationFunctions=n,t.ComparisonOperators=o,t.FilteringModes=u,t.LogicalOperators=i,t.DateTimeFormatter=v,t.FieldType=b,t.FieldSubtype=w,t.DerivationOperations=N,t.SortOrder=c,t.Invalid=ot,t.DataWranglers=At,t._taskerPool=function(t){var e,r;if("undefined"!=typeof window){var n=Math.min(null!==(r=null===(e=window.navigator)||void 0===e?void 0:e.hardwareConcurrency)&&void 0!==r?r:1,4);if(null!=window.Worker)return Array.from({length:n}).map((function(){return{isFree:!0,worker:new t}}))}}(nt.a),t}(),Et=function(){function t(t){this._schema=t}return t.prototype.name=function(){return this._schema.name},t.prototype.type=function(){return this._schema.type},t.prototype.schema=function(){return this._schema},t.prototype.displayName=function(){return this._schema.displayName||this._schema.name},t.prototype.subtype=function(){return this._schema.subtype},t}(),Dt=(ft=function(t,e){return(ft=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}ft(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),Nt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},Mt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Nt(arguments[e]));return t},Tt=function(t){function e(e,r){var n=t.call(this,e)||this;return n._cachedData=[],n._cachedFormattedData=[],n._cachedDomain=[],n._wasmField=r,n._uniqueStrings=[],n}return Dt(e,t),e.prototype._setMeta=function(t){this._uniqueStrings=t},e.prototype._getMeta=function(){return this._uniqueStrings},e.prototype.domain=function(){var t=this;if(!this._cachedDomain.length&&this._wasmField){var e=[],r=this._wasmField.get_domain(),n=mt(r.data_ptr,r.data_len);r.free(),n.forEach((function(r){-1===r?e.push(re.defaultInvalidValue()):e.push(t._uniqueStrings[r])})),this._cachedDomain=Mt(e)}return this._cachedDomain},e.prototype.data=function(){var t=this;if(0===this._cachedData.length&&this._wasmField){var e=mt(this._wasmField.get_data_info(),this._wasmField.get_rows_count()).map((function(e){var r=t._uniqueStrings[t._wasmField.get_value_at_index(e)];return void 0===r?new ot(re.defaultInvalidValue()):r}));this._cachedData=e}return this._cachedData},e.prototype.formattedData=function(t){if(0===this._cachedFormattedData.length||t){var e=this.data(),r=t||this._schema.format,n=[];this._cachedFormattedData=e,r instanceof Function&&(e.forEach((function(t){var e;e=t instanceof ot?t:r(t),n.push(e)})),this._cachedFormattedData=n)}return this._cachedFormattedData},e.prototype.getRowsCount=function(){return this._wasmField?this._wasmField.get_rows_count():0},e.prototype.dispose=function(){this._cachedDomain=[],this._cachedData=[],this._cachedFormattedData=[],this._wasmField&&this._wasmField.free()},e}(Et),Ft=Tt,Rt=function(t,e,r){var n=function(t){void 0===t&&(t=[]);for(var e=new Map,r=[],n=[],o=0,i=0;i<t.length;i++){var a=wt(t[i]);a&&!e.has(t[i])?(e.set(t[i],o),r.push(o),o++,n.push(String(t[i]))):r.push(a?e.get(t[i]):-1)}return{uniqueStrings:n,indices:r}}(t),o=n.uniqueStrings,i=n.indices,a=void 0,u=Number.MAX_VALUE;if(r){var s=r.add_field(Ot(e),o),c=(a=r.get_categorical_field(s)).get_data_indices();vt(c,i)}var f=new Tt(e,a);return f._setMeta(o),{field:f,index:u}},Ct=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),It=function(t){function e(e,r){var n=t.call(this,e)||this;return n._cachedData=[],n._cachedDomain=[],n._wasmField=r,n._cachedFormattedData=[],n}return Ct(e,t),e.prototype.domain=function(){if(this._wasmField){var t=this._wasmField.get_domain();t.length&&(this._cachedDomain=[t[0],t[1]])}return this._cachedDomain},e.prototype.data=function(){var t=this;if(0===this._cachedData.length&&this._wasmField){var e=mt(this._wasmField.get_data_info(),this._wasmField.get_rows_count()).map((function(e){var r=t._wasmField.get_value_at_index(e);return Number.isFinite(r)?r:new ot(NaN)}));this._cachedData=e}return this._cachedData},e.prototype.formattedData=function(t){if(0===this._cachedFormattedData.length||t){var e=this.data(),r=t||this._schema.format,n=[];this._cachedFormattedData=e,r instanceof Function&&(e.forEach((function(t){var e;e=t instanceof ot?t:r(t),n.push(e)})),this._cachedFormattedData=n)}return this._cachedFormattedData},e.prototype.getRowsCount=function(){return this._wasmField?this._wasmField.get_rows_count():0},e.prototype.dispose=function(){this._cachedDomain=[],this._cachedData=[],this._cachedFormattedData=[],this._wasmField&&this._wasmField.free()},e}(Et),Pt=It,Lt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ut=function(t){function e(e,r){var n=t.call(this,e)||this;return n._cachedDomain=[],n._cachedData=[],n._wasmField=r,n._cachedFormattedData=[],n}return Lt(e,t),e.prototype.domain=function(){if(this._wasmField){var t=this._wasmField.get_domain();t.length&&(this._cachedDomain=[t[0],t[1]])}return this._cachedDomain},e.prototype.data=function(){var t=this;if(0===this._cachedData.length&&this._wasmField){var e=mt(this._wasmField.get_data_info(),this._wasmField.get_rows_count()).map((function(e){var r=t._wasmField.get_value_at_index(e);return Number.isFinite(r)?r:new ot(NaN)}));this._cachedData=e}return this._cachedData},e.prototype.formattedData=function(t){if(0===this._cachedFormattedData.length||t){var e=this.data(),r=t||this._schema.format;if(this._cachedFormattedData=e,r instanceof Function){var n=[];e.forEach((function(t){var e;e=t instanceof ot?t:r(t),n.push(e)})),this._cachedFormattedData=n}else if("string"==typeof r||r instanceof String){var o=[];e.forEach((function(t){var e;e=t instanceof ot?t:v.formatAs(new Date(t),r),o.push(e)})),this._cachedFormattedData=o}}return this._cachedFormattedData},e.prototype.getRowsCount=function(){return this._wasmField?this._wasmField.get_rows_count():0},e.prototype.dispose=function(){this._cachedDomain=[],this._cachedData=[],this._cachedFormattedData=[],this._wasmField&&this._wasmField.free()},e.prototype.minimumConsecutiveDifference=function(){var t=this._wasmField?this._wasmField.min_consecutive_diff():1/0;return isFinite(t)?t:NaN},e}(Et),jt=Ut,kt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),Ht=function(t){function e(e,r){var n=t.call(this,e)||this;return n._cachedDomain=[],n._cachedData=[],n._wasmField=r,n}return kt(e,t),e.prototype.displayName=function(){return this._schema.name},e.prototype.domain=function(){return[]},e.prototype.formattedData=function(){return[]},e.prototype.data=function(){var t=this;if(0===this._cachedData.length&&this._wasmField){var e=mt(this._wasmField.get_data_info(),this._wasmField.get_rows_count()).map((function(e){return t._wasmField.get_value_at_index(e)}));this._cachedData=e}return this._cachedData},e.prototype.getRowsCount=function(){return this._wasmField?this._wasmField.get_rows_count():0},e.prototype.getValueAtIndex=function(t){return this.data()[t]},e.prototype.dispose=function(){this._cachedDomain=[],this._cachedData=[],this._wasmField&&this._wasmField.free()},e}(Et),Yt=Ht,Vt=function(){return{name:"__id__",format:function(t){return t},displayName:"__id__",type:b.MEASURE,subtype:w.ROWID,defAggFn:"sum"}},Bt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},Gt=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Bt(arguments[e]));return t},Jt=function(){function t(e,r){if(this._contextName=et.WASM,this._fieldOrder=[],this._fieldMap=new Map,this._dataMeta={rows:0,columns:0},e instanceof t)this._context=e._context,this._fieldOrder=e._fieldOrder,this._fieldMap=e._fieldMap;else{var n=e.data,o=e.schema,i=r,a=i.rows,u=i.columns;this._dataMeta=r,a&&(this._context=new it.a(new it.b(a,u))),this.createFields(n,o)}}return t.prototype.updateFieldMap=function(t){var e=t.field,r=t.index,n=e.name(),o=r===Number.MAX_VALUE?this._fieldMap.size:r;this._fieldMap.set(n,{field:e,index:o})},t.prototype.createFields=function(t,e){var r=this;e.forEach((function(e,n){r.createField(t[n],e)})),this.createField(new Array(t[0].length).fill(0).map((function(t,e){return e})),Vt())},t.prototype.createField=function(t,e){switch(e.subtype){case w.CATEGORICAL:this.updateFieldMap(Rt(t,e,this._context));break;case w.CONTINUOUS:this.updateFieldMap(function(t,e,r){var n=yt(t),o=n.indices,i=n.values,a=void 0,u=Number.MAX_VALUE;return r&&(u=r.add_field(Ot(e),[]),a=r.get_continuous_field(u),vt(a.get_data_indices(),o),gt(a.get_data_ptr(),i)),{field:new It(e,a),index:u}}(t,e,this._context));break;case w.TEMPORAL:this.updateFieldMap(function(t,e,r){var n=yt(t),o=n.indices,i=n.values,a=Number.MAX_VALUE,u=void 0;return r&&(a=r.add_field(Ot(e),[]),u=r.get_temporal_field(a),vt(u.get_data_indices(),o),gt(u.get_data_ptr(),i)),{field:new Ut(e,u),index:a}}(t,e,this._context));break;case w.ROWID:this.updateFieldMap(function(t,e,r){var n=void 0,o=Number.MAX_VALUE;return r&&(o=r.add_field(Ot(e),[]),n=r.get_id_field(o),vt(n.get_data_ptr(),t)),{field:new Ht(e,n),index:o}}(t,e,this._context))}this._fieldOrder.push(e.name)},t.prototype.updateFields=function(t){var e=this;this._fieldOrder.forEach((function(r){var n=t.get(r),o=n.field,i=n.index,a=o.schema();switch(a.subtype){case w.CATEGORICAL:var u=new Ft(a,e._context.get_categorical_field(i));u._setMeta(o._getMeta()),e.updateFieldMap({field:u,index:i});break;case w.CONTINUOUS:e.updateFieldMap({index:i,field:new Pt(a,e._context.get_continuous_field(i))});break;case w.TEMPORAL:e.updateFieldMap({field:new jt(a,e._context.get_temporal_field(i)),index:i});break;case w.ROWID:e.updateFieldMap({field:new Yt(a,e._context.get_id_field(i)),index:i})}}))},t.prototype.setContextInfo=function(t,e,r){void 0===t&&(t=this._context),void 0===e&&(e=Gt(this._fieldOrder)),void 0===r&&(r=this._fieldMap),this._context?(this._context=t,this._dataMeta={rows:t.row_count(),columns:t.column_count()},this._fieldOrder=e,this._fieldMap=new Map,this.updateFields(r)):(this._fieldOrder=e,this._fieldMap=r)},t.prototype.getClonedFieldMap=function(t,e){var r=new Map;return e.forEach((function(e,n){var o=t._fieldMap.get(e).field;r.set(e,{field:o,index:n})})),r},t.prototype.getField=function(t){var e=(this._fieldMap.get(t)||{}).field;return void 0===e?void 0:e},t.prototype.getData=function(t,e){var r=this;void 0===t&&(t=0);var n=[],o=[],i=this._fieldMap.get(this._fieldOrder[0]);if(i){for(var a=i.field.getRowsCount(),u=e||a,s=function(t){o.push([]),c._fieldOrder.forEach((function(e,n){var i=r._fieldMap.get(e).field,a=o.length-1,u=i.data()||[];o[a][n]=u[t]}))},c=this,f=t;f<u;f++)s(f);return{schema:n=this.getSchema(),data:o}}return{schema:n,data:[]}},t.prototype.getSchema=function(){var t=this;return this._fieldOrder.map((function(e){return t._fieldMap.get(e).field.schema()}))},t.prototype.getDataMeta=function(){return this._dataMeta},t.prototype.sort=function(t){var e=this,r=this.clone();if(this._context){var n=[];t.forEach((function(t){var r=e._fieldMap.get(t[0]);r&&n.push([r.index,l(t[1])])}));var o=this._context.sort(n);r.setContextInfo(o)}return r},t.prototype.groupBy=function(t,e,r){var n=this;void 0===e&&(e=[]),void 0===r&&(r={createId:!0});var o=this.clone(),i=Bt(t.reduce((function(t,e){var r=n._fieldMap.get(e);return r&&(r.field instanceof Ft||r.field instanceof jt)&&(t[0].push(e),t[1].push(r.index)),t}),[[],[]]),2),u=i[0],s=i[1],c=[];e.map((function(t){var e=n._fieldMap.get(t.field);e&&c.push([e.index,a(t.aggn)])}));var f=this._context?this._context.group_by(s,c):void 0,l=this._fieldOrder.filter((function(t){var e;return(null===(e=n._fieldMap.get(t))||void 0===e?void 0:e.field)instanceof Pt}));l=Gt(u,l);var p=this.getClonedFieldMap(o,l);if(o.setContextInfo(f,l,p),!1!==r.createId){var d=o._fieldMap.get(o._fieldOrder[0]).field.getRowsCount();o.createField(new Array(d).fill(0).map((function(t,e){return e})),Vt())}return o},t.prototype.select=function(t,e){var r=this.clone(),n=r;if(this._context){var o=_t(t,this._fieldMap);if(o.operator){var i=(e||{}).mode,a=void 0===i?u.NORMAL:i,s=f(a),c=this._context.select(o,s);switch(a){case u.ALL:r.setContextInfo(c.get_filtered_dm());var l=this.clone();l.setContextInfo(c.get_unfiltered_dm()),n=[r,l];break;case u.INVERSE:r.setContextInfo(c.get_unfiltered_dm()),n=r;break;default:r.setContextInfo(c.get_filtered_dm()),n=r}c.free()}else n.setContextInfo(n._context&&n._context.clone())}return n},t.prototype.project=function(t,e){var r=this,n=this.clone(),o=n,i=(e||{}).mode,a=void 0===i?u.NORMAL:i,s=[],c=[];t.map((function(t){var e=r._fieldMap.get(t);e&&(s.push(t),c.push(e.index))})),s.push("__id__");var l,p=this._fieldOrder.filter((function(t,e){return!c.includes(e)})),d=f(a),h=this._context?this._context.project({columns:c,mode:d}):void 0;switch(a){case u.ALL:l=this.getClonedFieldMap(n,s),n.setContextInfo(h?h.get_filtered_dm():void 0,s,l);var _=this.clone();l=this.getClonedFieldMap(_,p),_.setContextInfo(h?h.get_unfiltered_dm():void 0,p,l),o=[n,_];break;case u.INVERSE:l=this.getClonedFieldMap(n,p),n.setContextInfo(h?h.get_unfiltered_dm():void 0,p,l),o=n;break;default:l=this.getClonedFieldMap(n,s),n.setContextInfo(h?h.get_filtered_dm():void 0,s,l),o=n}return h&&h.free(),o},t.prototype.splitByRow=function(t){var e=this,r=[];if(this._context){var n=[];t.forEach((function(t){var r=e._fieldMap.get(t);r&&n.push(r.index)}));var o=this._context.split_by_row(n),i=o.get_count();r=[];for(var a=0;a<i;a++){var u=this.clone();u.setContextInfo(o.get_dm()),r.push(u)}o.free()}return r},t.prototype.clone=function(){return new t(this)},t.prototype.dispose=function(t){var e=this,r=t.disposePartialFields,n=t.disposeFields,o=r.dispose,i=r.values,a=void 0===i?[]:i;if(o&&this._context){var u=a.map((function(t){return e._fieldMap.get(t).index}));this._context.dispose(u)}n&&this._fieldOrder.forEach((function(t){e._fieldMap.get(t).field.dispose()})),this._context&&this._context.free()},t.prototype.addIdField=function(t){return this.createField(Array.from(t),Vt()),this},t.prototype.calculateVariable=function(t,e,r){var n=this,o=this.clone();if(this._context){var i=e.map((function(t){return n._fieldMap.get(t).field.data()})),a=t.subtype,u=void 0===a?w.CATEGORICAL:a,s=t.format,c=new Array(this._context.get_partial_row_count());c.fill(-1);for(var f=this._context.get_eligible_rows(),l=function(t){var e=r.apply(void 0,Gt(i.map((function(e){return e[t]}))));u===w.TEMPORAL?c[f[t]]=ht(u,e,s||function(t){return t}):c[f[t]]=e},p=0;p<this._dataMeta.rows;p++)l(p);var d=this._context.clone();o.setContextInfo(d),o.createField(c,t)}return o},t.prototype.getMatchingIds=function(t){return Array.from(this._context&&t._context?this._context.get_matching_ids(t._context):[])},t.prototype.context=function(){return this._context},t}(),qt=((lt={})[N.SELECT]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!1,values:[]}}},lt[N.PROJECT]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!1,values:[]}}},lt[N.GROUPBY]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!0,values:[]}}},lt[N.SORT]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!1,values:[]}}},lt[N.SPLIT]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!1,values:[]}}},lt[N.CALCULATE]=function(t){return{disposeFields:!0,disposePartialFields:{dispose:!0,values:[t.fieldInfo.name]}}},lt),Wt=function(t,e){for(;t;)t._refCount=Math.max(t._refCount+(e?1:-1),0),t=null==t?void 0:t.getParent()},Kt=function(t,e,r,n){var o=e.info,i=e.query,a=e.targetMap,u=e.nonPropagationDms,s=o.targetDms,c=void 0===s?new Set:s,f=o.payload,l=o.exclude,p=void 0===l||l;if(!1!==a.get(t.id())){var d=n;if(i){var h=t.id();!r.get(h)&&d||(d=t.select(i),t.removeChild(d),d.detachParent())}var _=c.has(t.id());(function(t,e,r,n){var o=n._propagationInfo.listeners;return r&&o.forEach((function(r){r(t,e)})),!r||!o.length})(d,f,p?!_:_,t)&&u.push(d),t.getChildren().filter((function(t){return!1!==a.get(t.id())})).forEach((function(t){var n;d&&(n=function(t,e){var r,n=e.getDerivations()[0],o=n.operation,i=n.params,a=void 0===i?[]:i;switch(o){case N.SELECT:r=t.select(a.query);break;case N.GROUPBY:var u=(r=t.groupBy(a.fields,a.reducers,{createId:!1}))._context.getMatchingIds(e._context);r._context.addIdField(u);break;case N.PROJECT:r=t.project(a.fields);break;case N.SORT:r=t.sort(a);break;case N.CALCULATE:r=t.calculateVariable(a.fieldInfo,a.fields,a.fn)}return r}(d,t)),Kt(t,e,r,n)}))}},Xt=function(t,e,r,n){void 0===e&&(e=new Set),void 0===r&&(r=!0),void 0===n&&(n=new Map);var o=t.getChildren(),i=!1;o.forEach((function(t){var o=Xt(t,e,r,n);i=i||o}));var a=e.has(t.id());return i=i||(r?!a:a),n.set(t.id(),i),i},Qt=function(t,e){return{operator:o.EQUAL,value:t===re.defaultInvalidValue()?void 0:t,field:e}},zt=function(){function t(){this._defaultInvalids=new Set;var t=Object.values(ut);for(var e in t){var r=t[e];this._defaultInvalids.add(r)}}return t.prototype.setInvalids=function(t){var e=this;t.forEach((function(t){return e._defaultInvalids.add(t)}))},t.prototype.getInvalids=function(){return this._defaultInvalids},t.prototype.unsetInvalids=function(t){for(var e in t)this._defaultInvalids.delete(t[e])},t.prototype.isInvalid=function(t){return this._defaultInvalids.has(t)},t}(),Zt=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),$t=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a},te=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat($t(arguments[e]));return t},ee=(pt=0,function(){return pt++}),re=function(t){function e(r){var n=t.call(this)||this;if(n._children=[],n._derivations=[],r instanceof e)n._context=r._context,n._derivations=te(r._derivations),n._commonDerivation=null;else{var o=r.data,i=r.schema,a=n.sanitizeSchema(i);switch(e._contextType){case et.WASM:n._context=n.setWasmContext({data:o,schema:a},{rows:o[0].length,columns:a.length});break;default:n._context=n.setWasmContext({data:o,schema:a},{rows:o[0].length,columns:a.length})}n._commonDerivation=null}return n._id=ee(),n._propagationInfo={listeners:[],propagationCriterias:new Map},n._refCount=1,n}return Zt(e,t),e.setContext=function(t){void 0===t&&(t=et.WASM),e._contextType=t},e.prototype.setWasmContext=function(t,e){return new Jt(t,e)},e.prototype.setContextInfo=function(t){this._context=t},e.prototype.sanitizeSchema=function(t){var r=e.defaultAggregation();return t.map((function(t){var e,n=t.format,o=void 0===n?function(t){return t}:n;return{name:t.name,type:t.type,subtype:t.subtype||(e=t.type,e===b.MEASURE?w.CONTINUOUS:w.CATEGORICAL),defAggFn:t.defAggFn||r,format:o,displayName:t.displayName||t.name}}))},e.prototype.cloneFromContext=function(t){var e=this;if(Array.isArray(t)){var r=[];return t.forEach((function(t){var n=e.clone();n.setContextInfo(t),n._derivations=[],r.push(n)})),r}var n=this.clone();return n._derivations=[],n.setContextInfo(t),n},e.setInvalids=function(t){t&&e.defaults.setInvalids(t)},e.unsetInvalids=function(t){t&&e.defaults.unsetInvalids(t)},e.defaultInvalidValue=function(t){return t&&e.defaults.setDefaultInvalidValue(t),e.defaults.getDefaultInvalidValue()},e.defaultAggregation=function(t){return t&&e.defaults.setDefaultAggregation(t),e.defaults.getDefaultAggregation()},Object.defineProperty(e,"defaults",{get:function(){var t,r,o;return e._defaults||(e._defaults=(t=n.SUM,r=new zt,o="_invalid",{setDefaultAggregation:function(e){t=e},getDefaultAggregation:function(){return t},setInvalids:function(t){r.setInvalids(t)},unsetInvalids:function(t){r.unsetInvalids(t)},getInvalidStore:function(){return r},setDefaultInvalidValue:function(t){o=t},getDefaultInvalidValue:function(){return o}})),e._defaults},enumerable:!1,configurable:!0}),e.prototype.id=function(){return this._id},e.prototype.getField=function(t){return this._context.getField(t)},e.prototype.getParent=function(){return this._parent},e.prototype.getChildren=function(){return te(this._children)},e.prototype.getDerivations=function(){return te(this._derivations)},e.prototype.removeChild=function(t){var e=this._children.findIndex((function(e){return e===t}));e>-1&&this._children.splice(e,1)},e.prototype.detachParent=function(){return this._parent=void 0,this},e.prototype.getData=function(){return this._context.getData()},e.prototype.getDataMeta=function(){return this._context.getDataMeta()},e.prototype.getSchema=function(){return this._context.getSchema()},e.prototype.clone=function(t){void 0===t&&(t=!0);var r=new e(this);return t&&(Wt(this,!0),this._children.push(r),r._parent=this),r},e.prototype.sort=function(t){var e=this._context.sort(t),r=this.cloneFromContext(e);return r._derivations.push({operation:N.SORT,params:t}),r},e.prototype.select=function(t,e){var r=(e||{}).mode,n=void 0===r?u.NORMAL:r,o=this._context.select(t,{mode:n}),i=this.cloneFromContext(o);return i instanceof Array?(i[0]._derivations.push({operation:N.SELECT,params:{query:t,options:{mode:u.NORMAL}}}),i[1]._derivations.push({operation:N.SELECT,params:{query:t,options:{mode:u.INVERSE}}})):i._derivations.push({operation:N.SELECT,params:{query:t,options:{mode:n}}}),i},e.prototype.splitByRow=function(t){var e=this._context.splitByRow(t),r=this.cloneFromContext(e);return r.map((function(e){var r=function(t,e){var r={},n=e.length;if(1===n){var o=t.getField(e[0]);r=o?Qt(o.domain()[0],e[0]):{}}else n>1&&(r.conditions=[],e.forEach((function(e,n){var o=t.getField(e);o&&(r.operator=i.AND,r.conditions[n]=Qt(o.domain()[0],e))})));return r}(e,t);return e._commonDerivation={operation:N.SPLIT,params:{fields:t}},e._derivations.push({operation:N.SELECT,params:{query:r,options:{mode:u.NORMAL}}})})),r},e.prototype.project=function(t,e){var r=(e||{}).mode,n=void 0===r?u.NORMAL:r,o=this._context.project(t,{mode:n}),i=this.cloneFromContext(o);return i instanceof Array?(i[0]._derivations.push({operation:N.PROJECT,params:{fields:t,options:{mode:u.NORMAL}}}),i[1]._derivations.push({operation:N.PROJECT,params:{fields:t,options:{mode:u.INVERSE}}})):i._derivations.push({operation:N.PROJECT,params:{fields:t,options:e}}),i},e.prototype.groupBy=function(t,e,r){void 0===e&&(e=[]),void 0===r&&(r={});var n=this._context.groupBy(t,e,r),o=this.cloneFromContext(n);return o._derivations.push({operation:N.GROUPBY,params:{fields:t,reducers:e}}),o},e.prototype.disposeRecursive=function(t){(void 0===t&&(t=!0),this._refCount=Math.max(this._refCount-1,0),0===this._refCount||t)&&(this.disposeResources(),this.getChildren().forEach((function(e){e.disposeRecursive(t)})))},e.prototype.getPropagationCriterias=function(){return this._propagationInfo.propagationCriterias},e.prototype.dispose=function(t){if(void 0===t&&(t=!0),!this._disposed){var e=this.getParent();this.disposeRecursive(t),Wt(e,!1),function(t){for(;t;){var e=null==t?void 0:t.getParent();!t._refCount&&t.disposeResources(),t=e}}(e)}return this},e.prototype.disposeResources=function(){var t;if(this._disposed)return this;var e=this._derivations[this._derivations.length-1];if(e){var r=e.operation;this._context.dispose(qt[r](e.params))}else this._context.dispose({disposeFields:!0,disposePartialFields:{dispose:!1,values:[]}});return null===(t=this._parent)||void 0===t||t.removeChild(this),this.detachParent(),this._disposed=!0,this},e.prototype.propagate=function(t,e){var r=function(t){for(;t;){var e=null==t?void 0:t.getParent();if(!e)break;t=e}return t}(this),n=t.map((function(t){return t.criteria})).filter((function(t){return null!==t})),o=n.length?{operator:e.queryOperator||"and",conditions:n}:null,i=function(t,e){var r=new Map;return t.forEach((function(t){for(var n=t.dm,o=void 0===n?e:n,i=t.criteria,a=t.fields,u=o,s=a.slice(),c=a.some((function(t){var e;return(null===(e=o.getField(t))||void 0===e?void 0:e.type())===b.MEASURE})),f=function(){var t=null==u?void 0:u.getParent(),e=u.getDerivations();if(e.length){var n=e[0].operation===N.GROUPBY&&c,o=s.filter((function(e){return t.getField(e)}));if(n)return r.set(null==u?void 0:u.id(),i),"break";o.length<s.length&&(s=o,r.set(null==u?void 0:u.id(),i))}u=t};u;){if("break"===f())break}})),r}(t,this),a=new Map;Xt(r,e.targetDms,e.exclude,a);var u=[];return Kt(r,{query:o,info:e,targetMap:a,nonPropagationDms:u},i),u.forEach((function(t){t&&t.dispose(!1)})),this},e.prototype.onPropagation=function(t){return this._propagationInfo.listeners.push(t),this},e.prototype.unsubscribePropagationListeners=function(){return this._propagationInfo.listeners=[],this},e.prototype.calculateVariable=function(t,e,r){var n=this._context.calculateVariable(this.sanitizeSchema([t])[0],e,r),o=this.cloneFromContext(n);return o._derivations.push({operation:N.CALCULATE,params:{fieldInfo:t,fields:e,fn:r}}),o},e.prototype.context=function(){return this._context},e._contextType=et.WASM,e}(St);e.default=re},function(t,e,r){"use strict";(function(t,n){r.d(e,"f",(function(){return E})),r.d(e,"a",(function(){return T})),r.d(e,"b",(function(){return F})),r.d(e,"c",(function(){return U})),r.d(e,"d",(function(){return j})),r.d(e,"e",(function(){return k}));var o=r(5);const i=new Array(32).fill(void 0);function a(t){return i[t]}i.push(void 0,null,!0,!1);let u=0,s=null;function c(){return null!==s&&s.buffer===o.ib.buffer||(s=new Uint8Array(o.ib.buffer)),s}let f=new(void 0===t?r(1).TextEncoder:t)("utf-8");const l="function"==typeof f.encodeInto?function(t,e){return f.encodeInto(t,e)}:function(t,e){const r=f.encode(t);return e.set(r),{read:t.length,written:r.length}};let p=null;function d(){return null!==p&&p.buffer===o.ib.buffer||(p=new Int32Array(o.ib.buffer)),p}let h=i.length;function _(t){const e=a(t);return function(t){t<36||(i[t]=h,h=t)}(t),e}let v=new(void 0===n?r(1).TextDecoder:n)("utf-8",{ignoreBOM:!0,fatal:!0});function g(t,e){return v.decode(c().subarray(t,t+e))}function y(t,e){if(!(t instanceof e))throw new Error("expected instance of "+e.name);return t.ptr}function m(t){h===i.length&&i.push(i.length+1);const e=h;return h=i[e],i[e]=t,e}v.decode();let b=32;function w(t){if(1==b)throw new Error("out of js stack");return i[--b]=t,b}let O=null;function A(t,e){return(null!==O&&O.buffer===o.ib.buffer||(O=new Uint32Array(o.ib.buffer)),O).subarray(t/4,t/4+e)}let x=null;function S(t,e){return(null!==x&&x.buffer===o.ib.buffer||(x=new Float64Array(o.ib.buffer)),x).subarray(t/8,t/8+e)}function E(t,e,r,n,i){y(t,T);var a=o.mb(t.ptr,e,r,n,i);return P.__wrap(a)}class D{static __wrap(t){const e=Object.create(D.prototype);return e.ptr=t,e}free(){const t=this.ptr;this.ptr=0,o.a(t)}get data_ptr(){return o.g(this.ptr)}set data_ptr(t){o.m(this.ptr,t)}get data_len(){return o.f(this.ptr)>>>0}set data_len(t){o.l(this.ptr,t)}}class N{static __wrap(t){const e=Object.create(N.prototype);return e.ptr=t,e}free(){const t=this.ptr;this.ptr=0,o.b(t)}get_name(){try{o.z(8,this.ptr);var t=d()[2],e=d()[3];return g(t,e)}finally{o.s(t,e)}}get_data_indices(){return o.w(this.ptr)}get_data_info(){return o.x(this.ptr)}get_rows_count(){return o.A(this.ptr)>>>0}get_value_at_index(t){return o.B(this.ptr,t)}get_domain(){var t=o.y(this.ptr);return D.__wrap(t)}}class M{static __wrap(t){const e=Object.create(M.prototype);return e.ptr=t,e}free(){const t=this.ptr;this.ptr=0,o.c(t)}get_name(){try{o.z(8,this.ptr);var t=d()[2],e=d()[3];return g(t,e)}finally{o.s(t,e)}}get_data_ptr(){return o.E(this.ptr)}get_data_indices(){return o.C(this.ptr)}get_data_info(){return o.D(this.ptr)}get_rows_count(){return o.G(this.ptr)>>>0}get_value_at_index(t){return o.H