Socket
Socket
Sign inDemoInstall

@varunaiot/varunalib

Package Overview
Dependencies
4
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

README.md

2

build/index.js

@@ -1,1 +0,1 @@

module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var i in r=arguments[e])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}).apply(this,arguments)},i=this&&this.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),i=0;for(r=0;r<e;r++)for(var a=arguments[r],o=0,u=a.length;o<u;o++,i++)n[i]=a[o];return n};Object.defineProperty(r,"__esModule",{value:!0}),r.Flowrate=r.PumpRuntime=r.GetAverageORP=r.GetAveragePH=r.Greeter=void 0;var a=e(1),o=e(2),u=e(3),s=e(4);u.extend(s),r.Greeter=function(t){return"Hello "+t},r.GetAveragePH=function(t,r,e){if(u(t).isAfter(u(r)))return!1;var n=[];e.map((function(e){var i=e.ph_scaled,a=new Date(e.custom_timestamps);u(a).isAfter(u(t))&&(u(r).isAfter(u(a))||u(a).isSame(u(r)))&&n.push(i)}));var i=n.length,o=n.reduce((function(t,r){return t+r}),0)/i,s=n.filter((function(t){return t-a.mean(n)<=3*a.standardDeviation(n)}));return{phAverage:o,phData:n,phInfo:s}},r.GetAverageORP=function(t,r,e){if(u(t).isAfter(u(r)))return!1;var n=[];e.map((function(e){var i=e.orp_scaled,a=new Date(e.custom_timestamps);u(a).isAfter(u(t))&&(u(r).isAfter(u(a))||u(a).isSame(u(r)))&&n.push(i)}));var i=n.length,o=n.reduce((function(t,r){return t+r}),0)/i,s=n.filter((function(t){return t-a.mean(n)<=3*a.standardDeviation(n)}));return{orpAverage:o,orpData:n,orpInfo:s}},r.PumpRuntime=function(t,r,e,n){if(u(t).isAfter(u(r)))return!1;var i=e.filter((function(t){return 1===Number.parseInt(t[n+"_start_stop"])})),a=[];return i.map((function(e){var n=new Date(e.custom_timestamps);u(n).isAfter(u(t))&&(u(r).isAfter(u(n))||u(n).isSame(u(r)))&&a.push(u(e.custom_timestamps))})),o.dateFormat(u.max(a).diff(u.min(a),"s"))},r.Flowrate=function(t,r,e,a,o){if(u(t).isAfter(u(r)))return!1;var s=e.filter((function(t){return t.type===o})).map((function(t){return t.symbol})),f=a.map((function(t){var r=i(Object.keys(t)).filter((function(t){return"flow_gpm"===t.slice(3,t.length)})),e={};return r.map((function(r){var i;e=n(((i={})[r]=t[r],i.custom_timestamps=t.custom_timestamps,i),e)})),e})).filter((function(e){var n=new Date(e.custom_timestamps);if(u(n).isAfter(u(t))&&(u(r).isAfter(u(n))||u(n).isSame(u(r))))return new Date(e.custom_timestamps)})),h=s.map((function(t){return t+"_flow_gpm"})),l=[];return f.map((function(t){var r={};h.map((function(e){var i;r=n(((i={})[e]=t[e],i),r)})),l.push(r),r={}})),l}},function(t,r,e){!function(t){"use strict";function r(t){if(0===t.length)return 0;for(var r,e=t[0],n=0,i=1;i<t.length;i++)r=e+t[i],Math.abs(e)>=Math.abs(t[i])?n+=e-r+t[i]:n+=t[i]-r+e,e=r;return e+n}function e(t){if(0===t.length)throw new Error("mean requires at least one data point");return r(t)/t.length}function n(t,r){var n,i,a=e(t),o=0;if(2===r)for(i=0;i<t.length;i++)o+=(n=t[i]-a)*n;else for(i=0;i<t.length;i++)o+=Math.pow(t[i]-a,r);return o}function i(t){if(0===t.length)throw new Error("variance requires at least one data point");return n(t,2)/t.length}function a(t){if(1===t.length)return 0;var r=i(t);return Math.sqrt(r)}function o(t){if(0===t.length)throw new Error("mode requires at least one data point");if(1===t.length)return t[0];for(var r=t[0],e=NaN,n=0,i=1,a=1;a<t.length+1;a++)t[a]!==r?(i>n&&(n=i,e=r),i=1,r=t[a]):i++;return e}function u(t){return t.slice().sort((function(t,r){return t-r}))}function s(t){if(0===t.length)throw new Error("min requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]<r&&(r=t[e]);return r}function f(t){if(0===t.length)throw new Error("max requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]>r&&(r=t[e]);return r}function h(t){for(var r=0,e=0;e<t.length;e++)r+=t[e];return r}function l(t,r){var e=t.length*r;if(0===t.length)throw new Error("quantile requires at least one data point.");if(r<0||r>1)throw new Error("quantiles must be between 0 and 1");return 1===r?t[t.length-1]:0===r?t[0]:e%1!=0?t[Math.ceil(e)-1]:t.length%2==0?(t[e-1]+t[e])/2:t[e]}function c(t,r,e,n){for(e=e||0,n=n||t.length-1;n>e;){if(n-e>600){var i=n-e+1,a=r-e+1,o=Math.log(i),u=.5*Math.exp(2*o/3),s=.5*Math.sqrt(o*u*(i-u)/i);a-i/2<0&&(s*=-1),c(t,r,Math.max(e,Math.floor(r-a*u/i+s)),Math.min(n,Math.floor(r+(i-a)*u/i+s)))}var f=t[r],h=e,l=n;for(v(t,e,r),t[n]>f&&v(t,e,n);h<l;){for(v(t,h,l),h++,l--;t[h]<f;)h++;for(;t[l]>f;)l--}t[e]===f?v(t,e,l):v(t,++l,n),l<=r&&(e=l+1),r<=l&&(n=l-1)}}function v(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function d(t,r){var e=t.slice();if(Array.isArray(r)){!function(t,r){for(var e=[0],n=0;n<r.length;n++)e.push(m(t.length,r[n]));e.push(t.length-1),e.sort(p);for(var i=[0,e.length-1];i.length;){var a=Math.ceil(i.pop()),o=Math.floor(i.pop());if(!(a-o<=1)){var u=Math.floor((o+a)/2);g(t,e[u],Math.floor(e[o]),Math.ceil(e[a])),i.push(o,u,u,a)}}}(e,r);for(var n=[],i=0;i<r.length;i++)n[i]=l(e,r[i]);return n}return g(e,m(e.length,r),0,e.length-1),l(e,r)}function g(t,r,e,n){r%1==0?c(t,r,e,n):(c(t,r=Math.floor(r),e,n),c(t,r+1,r+1,n))}function p(t,r){return t-r}function m(t,r){var e=t*r;return 1===r?t-1:0===r?0:e%1!=0?Math.ceil(e)-1:t%2==0?e-.5:e}function M(t,r){if(r<t[0])return 0;if(r>t[t.length-1])return 1;var e=function(t,r){for(var e=0,n=0,i=t.length;n<i;)r<=t[e=n+i>>>1]?i=e:n=-~e;return n}(t,r);if(t[e]!==r)return e/t.length;e++;var n=function(t,r){for(var e=0,n=0,i=t.length;n<i;)r>=t[e=n+i>>>1]?n=-~e:i=e;return n}(t,r);if(n===e)return e/t.length;var i=n-e+1;return i*(n+e)/2/i/t.length}function w(t){var r=d(t,.75),e=d(t,.25);if("number"==typeof r&&"number"==typeof e)return r-e}function y(t){return+d(t,.5)}function b(t){for(var r=y(t),e=[],n=0;n<t.length;n++)e.push(Math.abs(t[n]-r));return y(e)}function $(t,r){r=r||Math.random;for(var e,n,i=t.length;i>0;)n=Math.floor(r()*i--),e=t[i],t[i]=t[n],t[n]=e;return t}function S(t,r){return $(t.slice().slice(),r)}function D(t){for(var r,e=0,n=0;n<t.length;n++)0!==n&&t[n]===r||(r=t[n],e++);return e}function _(t,r){for(var e=[],n=0;n<t;n++){for(var i=[],a=0;a<r;a++)i.push(0);e.push(i)}return e}function q(t,r,e,n){var i;if(t>0){var a=(e[r]-e[t-1])/(r-t+1);i=n[r]-n[t-1]-(r-t+1)*a*a}else i=n[r]-e[r]*e[r]/(r+1);return i<0?0:i}function O(t,r,e,n,i,a,o){if(!(t>r)){var u=Math.floor((t+r)/2);n[e][u]=n[e-1][u-1],i[e][u]=u;var s=e;t>e&&(s=Math.max(s,i[e][t-1]||0)),s=Math.max(s,i[e-1][u]||0);var f,h,l,c=u-1;r<n.length-1&&(c=Math.min(c,i[e][r+1]||0));for(var v=c;v>=s&&!((f=q(v,u,a,o))+n[e-1][s-1]>=n[e][u]);--v)(h=q(s,u,a,o)+n[e-1][s-1])<n[e][u]&&(n[e][u]=h,i[e][u]=s),s++,(l=f+n[e-1][v-1])<n[e][u]&&(n[e][u]=l,i[e][u]=v);O(t,u-1,e,n,i,a,o),O(u+1,r,e,n,i,a,o)}}function E(t,r){if(t.length!==r.length)throw new Error("sampleCovariance requires samples with equal lengths");if(t.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var n=e(t),i=e(r),a=0,o=0;o<t.length;o++)a+=(t[o]-n)*(r[o]-i);return a/(t.length-1)}function A(t){if(t.length<2)throw new Error("sampleVariance requires at least two data points");return n(t,2)/(t.length-1)}function x(t){var r=A(t);return Math.sqrt(r)}function P(t,r,e,n){return(t*r+e*n)/(r+n)}function I(t){if(0===t.length)throw new Error("meanSimple requires at least one data point");return h(t)/t.length}function k(t){if(0===t.length)throw new Error("rootMeanSquare requires at least one data point");for(var r=0,e=0;e<t.length;e++)r+=Math.pow(t[e],2);return Math.sqrt(r/t.length)}var T=function(){this.totalCount=0,this.data={}};T.prototype.train=function(t,r){for(var e in this.data[r]||(this.data[r]={}),t){var n=t[e];void 0===this.data[r][e]&&(this.data[r][e]={}),void 0===this.data[r][e][n]&&(this.data[r][e][n]=0),this.data[r][e][n]++}this.totalCount++},T.prototype.score=function(t){var r,e={};for(var n in t){var i=t[n];for(r in this.data)e[r]={},this.data[r][n]?e[r][n+"_"+i]=(this.data[r][n][i]||0)/this.totalCount:e[r][n+"_"+i]=0}var a={};for(r in e)for(var o in a[r]=0,e[r])a[r]+=e[r][o];return a};var H=function(){this.weights=[],this.bias=0};function j(t){if(t<0)throw new Error("factorial requires a non-negative value");if(Math.floor(t)!==t)throw new Error("factorial requires an integer input");for(var r=1,e=2;e<=t;e++)r*=e;return r}H.prototype.predict=function(t){if(t.length!==this.weights.length)return null;for(var r=0,e=0;e<this.weights.length;e++)r+=this.weights[e]*t[e];return(r+=this.bias)>0?1:0},H.prototype.train=function(t,r){if(0!==r&&1!==r)return null;t.length!==this.weights.length&&(this.weights=t,this.bias=1);var e=this.predict(t);if("number"==typeof e&&e!==r){for(var n=r-e,i=0;i<this.weights.length;i++)this.weights[i]+=n*t[i];this.bias+=n}return this};var C=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],F=Math.log(Math.sqrt(2*Math.PI)),N={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}},Y=Math.sqrt(2*Math.PI),R={gaussian:function(t){return Math.exp(-.5*t*t)/Y}},L={nrd:function(t){var r=x(t),e=w(t);return"number"==typeof e&&(r=Math.min(r,e/1.34)),1.06*r*Math.pow(t.length,-.2)}};function W(t,r,e){var n,i;if(void 0===r)n=R.gaussian;else if("string"==typeof r){if(!R[r])throw new Error('Unknown kernel "'+r+'"');n=R[r]}else n=r;if(void 0===e)i=L.nrd(t);else if("string"==typeof e){if(!L[e])throw new Error('Unknown bandwidth method "'+e+'"');i=L[e](t)}else i=e;return function(r){var e=0,a=0;for(e=0;e<t.length;e++)a+=n((r-t[e])/i);return a/i/t.length}}var G=Math.sqrt(2*Math.PI);function U(t){for(var r=t,e=t,n=1;n<15;n++)r+=e*=t*t/(2*n+1);return Math.round(1e4*(.5+r/G*Math.exp(-t*t/2)))/1e4}for(var V=[],z=0;z<=3.09;z+=.01)V.push(U(z));function B(t){var r=1/(1+.5*Math.abs(t)),e=r*Math.exp(-t*t+((((((((.17087277*r-.82215223)*r+1.48851587)*r-1.13520398)*r+.27886807)*r-.18628806)*r+.09678418)*r+.37409196)*r+1.00002368)*r-1.26551223);return t>=0?1-e:e-1}function J(t){var r=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),e=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*r)+Math.log(1-t*t)/2,2)-Math.log(1-t*t)/r)-(2/(Math.PI*r)+Math.log(1-t*t)/2));return t>=0?e:-e}function Z(t){if("number"==typeof t)return t<0?-1:0===t?0:1;throw new TypeError("not a number")}t.BayesianClassifier=T,t.PerceptronModel=H,t.addToMean=function(t,r,e){return t+(e-t)/(r+1)},t.average=e,t.averageSimple=I,t.bayesian=T,t.bernoulliDistribution=function(t){if(t<0||t>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-t,t]},t.binomialDistribution=function(t,r){if(!(r<0||r>1||t<=0||t%1!=0)){var e=0,n=0,i=[],a=1;do{i[e]=a*Math.pow(r,e)*Math.pow(1-r,t-e),n+=i[e],a=a*(t-++e+1)/e}while(n<.9999);return i}},t.bisect=function(t,r,e,n,i){if("function"!=typeof t)throw new TypeError("func must be a function");for(var a=0;a<n;a++){var o=(r+e)/2;if(0===t(o)||Math.abs((e-r)/2)<i)return o;Z(t(o))===Z(t(r))?r=o:e=o}throw new Error("maximum number of iterations exceeded")},t.chiSquaredDistributionTable=N,t.chiSquaredGoodnessOfFit=function(t,r,n){for(var i=0,a=r(e(t)),o=[],u=[],s=0;s<t.length;s++)void 0===o[t[s]]&&(o[t[s]]=0),o[t[s]]++;for(var f=0;f<o.length;f++)void 0===o[f]&&(o[f]=0);for(var h in a)h in o&&(u[+h]=a[h]*t.length);for(var l=u.length-1;l>=0;l--)u[l]<3&&(u[l-1]+=u[l],u.pop(),o[l-1]+=o[l],o.pop());for(var c=0;c<o.length;c++)i+=Math.pow(o[c]-u[c],2)/u[c];var v=o.length-1-1;return N[v][n]<i},t.chunk=function(t,r){var e=[];if(r<1)throw new Error("chunk size must be a positive number");if(Math.floor(r)!==r)throw new Error("chunk size must be an integer");for(var n=0;n<t.length;n+=r)e.push(t.slice(n,n+r));return e},t.ckmeans=function(t,r){if(r>t.length)throw new Error("cannot generate more classes than there are data values");var e=u(t);if(1===D(e))return[e];var n=_(r,e.length),i=_(r,e.length);!function(t,r,e){for(var n=r[0].length,i=t[Math.floor(n/2)],a=[],o=[],u=0,s=void 0;u<n;++u)s=t[u]-i,0===u?(a.push(s),o.push(s*s)):(a.push(a[u-1]+s),o.push(o[u-1]+s*s)),r[0][u]=q(0,u,a,o),e[0][u]=0;for(var f=1;f<r.length;++f)O(f<r.length-1?f:n-1,n-1,f,r,e,a,o)}(e,n,i);for(var a=[],o=i[0].length-1,s=i.length-1;s>=0;s--){var f=i[s][o];a[s]=e.slice(f,o+1),s>0&&(o=f-1)}return a},t.combinations=function t(r,e){var n,i,a,o,u=[];for(n=0;n<r.length;n++)if(1===e)u.push([r[n]]);else for(a=t(r.slice(n+1,r.length),e-1),i=0;i<a.length;i++)(o=a[i]).unshift(r[n]),u.push(o);return u},t.combinationsReplacement=function t(r,e){for(var n=[],i=0;i<r.length;i++)if(1===e)n.push([r[i]]);else for(var a=t(r.slice(i,r.length),e-1),o=0;o<a.length;o++)n.push([r[i]].concat(a[o]));return n},t.combineMeans=P,t.combineVariances=function(t,r,e,n,i,a){var o=P(r,e,i,a);return(e*(t+Math.pow(r-o,2))+a*(n+Math.pow(i-o,2)))/(e+a)},t.cumulativeStdNormalProbability=function(t){var r=Math.abs(t),e=Math.min(Math.round(100*r),V.length-1);return t>=0?V[e]:+(1-V[e]).toFixed(4)},t.epsilon=1e-4,t.equalIntervalBreaks=function(t,r){if(t.length<2)return t;for(var e=s(t),n=f(t),i=[e],a=(n-e)/r,o=1;o<r;o++)i.push(i[0]+a*o);return i.push(n),i},t.erf=B,t.errorFunction=B,t.extent=function(t){if(0===t.length)throw new Error("extent requires at least one data point");for(var r=t[0],e=t[0],n=1;n<t.length;n++)t[n]>e&&(e=t[n]),t[n]<r&&(r=t[n]);return[r,e]},t.extentSorted=function(t){return[t[0],t[t.length-1]]},t.factorial=j,t.gamma=function t(r){if(Number.isInteger(r))return r<=0?NaN:j(r-1);if(--r<0)return Math.PI/(Math.sin(Math.PI*-r)*t(-r));var e=r+1/4;return Math.pow(r/Math.E,r)*Math.sqrt(2*Math.PI*(r+1/6))*(1+1/144/Math.pow(e,2)-1/12960/Math.pow(e,3)-257/207360/Math.pow(e,4)-52/2612736/Math.pow(e,5)+5741173/9405849600/Math.pow(e,6)+37529/18811699200/Math.pow(e,7))},t.gammaln=function(t){if(t<=0)return 1/0;t--;for(var r=C[0],e=1;e<15;e++)r+=C[e]/(t+e);var n=5.2421875+t;return F+Math.log(r)-n+(t+.5)*Math.log(n)},t.geometricMean=function(t){if(0===t.length)throw new Error("geometricMean requires at least one data point");for(var r=1,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("geometricMean requires only positive numbers as input");r*=t[e]}return Math.pow(r,1/t.length)},t.harmonicMean=function(t){if(0===t.length)throw new Error("harmonicMean requires at least one data point");for(var r=0,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("harmonicMean requires only positive numbers as input");r+=1/t[e]}return t.length/r},t.interquartileRange=w,t.inverseErrorFunction=J,t.iqr=w,t.kde=W,t.kernelDensityEstimation=W,t.linearRegression=function(t){var r,e,n=t.length;if(1===n)r=0,e=t[0][1];else{for(var i,a,o,u=0,s=0,f=0,h=0,l=0;l<n;l++)u+=a=(i=t[l])[0],s+=o=i[1],f+=a*a,h+=a*o;e=s/n-(r=(n*h-u*s)/(n*f-u*u))*u/n}return{m:r,b:e}},t.linearRegressionLine=function(t){return function(r){return t.b+t.m*r}},t.mad=b,t.max=f,t.maxSorted=function(t){return t[t.length-1]},t.mean=e,t.meanSimple=I,t.median=y,t.medianAbsoluteDeviation=b,t.medianSorted=function(t){return l(t,.5)},t.min=s,t.minSorted=function(t){return t[0]},t.mode=function(t){return o(u(t))},t.modeFast=function(t){for(var r,e=new Map,n=0,i=0;i<t.length;i++){var a=e.get(t[i]);void 0===a?a=1:a++,a>n&&(r=t[i],n=a),e.set(t[i],a)}if(0===n)throw new Error("mode requires at last one data point");return r},t.modeSorted=o,t.numericSort=u,t.perceptron=H,t.permutationTest=function(t,r,n,i){if(void 0===i&&(i=1e4),void 0===n&&(n="two_side"),"two_side"!==n&&"greater"!==n&&"less"!==n)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var a=e(t)-e(r),o=new Array(i),u=t.concat(r),s=Math.floor(u.length/2),f=0;f<i;f++){$(u);var h=u.slice(0,s),l=u.slice(s,u.length),c=e(h)-e(l);o[f]=c}var v=0;if("two_side"===n)for(var d=0;d<=i;d++)Math.abs(o[d])>=Math.abs(a)&&(v+=1);else if("greater"===n)for(var g=0;g<=i;g++)o[g]>=a&&(v+=1);else for(var p=0;p<=i;p++)o[p]<=a&&(v+=1);return v/i},t.permutationsHeap=function(t){for(var r=new Array(t.length),e=[t.slice()],n=0;n<t.length;n++)r[n]=0;for(var i=0;i<t.length;)if(r[i]<i){var a=0;i%2!=0&&(a=r[i]);var o=t[a];t[a]=t[i],t[i]=o,e.push(t.slice()),r[i]++,i=0}else r[i]=0,i++;return e},t.poissonDistribution=function(t){if(!(t<=0)){var r=0,e=0,n=[],i=1;do{n[r]=Math.exp(-t)*Math.pow(t,r)/i,e+=n[r],i*=++r}while(e<.9999);return n}},t.probit=function(t){return 0===t?t=1e-4:t>=1&&(t=.9999),Math.sqrt(2)*J(2*t-1)},t.product=function(t){for(var r=1,e=0;e<t.length;e++)r*=t[e];return r},t.quantile=d,t.quantileRank=function(t,r){return M(u(t),r)},t.quantileRankSorted=M,t.quantileSorted=l,t.quickselect=c,t.rSquared=function(t,r){if(t.length<2)return 1;for(var e=0,n=0;n<t.length;n++)e+=t[n][1];for(var i=e/t.length,a=0,o=0;o<t.length;o++)a+=Math.pow(i-t[o][1],2);for(var u=0,s=0;s<t.length;s++)u+=Math.pow(t[s][1]-r(t[s][0]),2);return 1-u/a},t.rms=k,t.rootMeanSquare=k,t.sample=function(t,r,e){return S(t,e).slice(0,r)},t.sampleCorrelation=function(t,r){return E(t,r)/x(t)/x(r)},t.sampleCovariance=E,t.sampleKurtosis=function(t){var r=t.length;if(r<4)throw new Error("sampleKurtosis requires at least four data points");for(var n,i=e(t),a=0,o=0,u=0;u<r;u++)a+=(n=t[u]-i)*n,o+=n*n*n*n;return(r-1)/((r-2)*(r-3))*(r*(r+1)*o/(a*a)-3*(r-1))},t.sampleSkewness=function(t){if(t.length<3)throw new Error("sampleSkewness requires at least three data points");for(var r,n=e(t),i=0,a=0,o=0;o<t.length;o++)i+=(r=t[o]-n)*r,a+=r*r*r;var u=t.length-1,s=Math.sqrt(i/u),f=t.length;return f*a/((f-1)*(f-2)*Math.pow(s,3))},t.sampleStandardDeviation=x,t.sampleVariance=A,t.sampleWithReplacement=function(t,r,e){if(0===t.length)return[];e=e||Math.random;for(var n=t.length,i=[],a=0;a<r;a++){var o=Math.floor(e()*n);i.push(t[o])}return i},t.shuffle=S,t.shuffleInPlace=$,t.sign=Z,t.standardDeviation=a,t.standardNormalTable=V,t.subtractFromMean=function(t,r,e){return(t*r-e)/(r-1)},t.sum=r,t.sumNthPowerDeviations=n,t.sumSimple=h,t.tTest=function(t,r){return(e(t)-r)/(a(t)/Math.sqrt(t.length))},t.tTestTwoSample=function(t,r,n){var i=t.length,a=r.length;if(!i||!a)return null;n||(n=0);var o=e(t),u=e(r),s=A(t),f=A(r);if("number"==typeof o&&"number"==typeof u&&"number"==typeof s&&"number"==typeof f){var h=((i-1)*s+(a-1)*f)/(i+a-2);return(o-u-n)/Math.sqrt(h*(1/i+1/a))}},t.uniqueCountSorted=D,t.variance=i,t.zScore=function(t,r,e){return(t-r)/e},Object.defineProperty(t,"__esModule",{value:!0})}(r)},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.dateFormat=void 0,r.dateFormat=function(t){var r=parseInt(t,10),e=Math.floor(r/86400);r-=3600*e*24;var n=Math.floor(r/3600);r-=3600*n;var i=Math.floor(r/60);return e+" d, "+n+" Hr, "+i+" M, "+(r-=60*i)+" S"}},function(t,r,e){t.exports=function(){"use strict";var t="millisecond",r="second",e="minute",n="hour",i="day",a="week",o="month",u="quarter",s="year",f=/^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/,h=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,l=function(t,r,e){var n=String(t);return!n||n.length>=r?t:""+Array(r+1-n.length).join(e)+t},c={s:l,z:function(t){var r=-t.utcOffset(),e=Math.abs(r),n=Math.floor(e/60),i=e%60;return(r<=0?"+":"-")+l(n,2,"0")+":"+l(i,2,"0")},m:function(t,r){var e=12*(r.year()-t.year())+(r.month()-t.month()),n=t.clone().add(e,o),i=r-n<0,a=t.clone().add(e+(i?-1:1),o);return Number(-(e+(r-n)/(i?n-a:a-n))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(f){return{M:o,y:s,w:a,d:i,D:"date",h:n,m:e,s:r,ms:t,Q:u}[f]||String(f||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},d="en",g={};g[d]=v;var p=function(t){return t instanceof y},m=function(t,r,e){var n;if(!t)return d;if("string"==typeof t)g[t]&&(n=t),r&&(g[t]=r,n=t);else{var i=t.name;g[i]=t,n=i}return!e&&n&&(d=n),n||!e&&d},M=function(t,r){if(p(t))return t.clone();var e="object"==typeof r?r:{};return e.date=t,e.args=arguments,new y(e)},w=c;w.l=m,w.i=p,w.w=function(t,r){return M(t,{locale:r.$L,utc:r.$u,$offset:r.$offset})};var y=function(){function l(t){this.$L=this.$L||m(t.locale,null,!0),this.parse(t)}var c=l.prototype;return c.parse=function(t){this.$d=function(t){var r=t.date,e=t.utc;if(null===r)return new Date(NaN);if(w.u(r))return new Date;if(r instanceof Date)return new Date(r);if("string"==typeof r&&!/Z$/i.test(r)){var n=r.match(f);if(n)return e?new Date(Date.UTC(n[1],n[2]-1,n[3]||1,n[4]||0,n[5]||0,n[6]||0,n[7]||0)):new Date(n[1],n[2]-1,n[3]||1,n[4]||0,n[5]||0,n[6]||0,n[7]||0)}return new Date(r)}(t),this.init()},c.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},c.$utils=function(){return w},c.isValid=function(){return!("Invalid Date"===this.$d.toString())},c.isSame=function(t,r){var e=M(t);return this.startOf(r)<=e&&e<=this.endOf(r)},c.isAfter=function(t,r){return M(t)<this.startOf(r)},c.isBefore=function(t,r){return this.endOf(r)<M(t)},c.$g=function(t,r,e){return w.u(t)?this[r]:this.set(e,t)},c.year=function(t){return this.$g(t,"$y",s)},c.month=function(t){return this.$g(t,"$M",o)},c.day=function(t){return this.$g(t,"$W",i)},c.date=function(t){return this.$g(t,"$D","date")},c.hour=function(t){return this.$g(t,"$H",n)},c.minute=function(t){return this.$g(t,"$m",e)},c.second=function(t){return this.$g(t,"$s",r)},c.millisecond=function(r){return this.$g(r,"$ms",t)},c.unix=function(){return Math.floor(this.valueOf()/1e3)},c.valueOf=function(){return this.$d.getTime()},c.startOf=function(t,u){var f=this,h=!!w.u(u)||u,l=w.p(t),c=function(t,r){var e=w.w(f.$u?Date.UTC(f.$y,r,t):new Date(f.$y,r,t),f);return h?e:e.endOf(i)},v=function(t,r){return w.w(f.toDate()[t].apply(f.toDate("s"),(h?[0,0,0,0]:[23,59,59,999]).slice(r)),f)},d=this.$W,g=this.$M,p=this.$D,m="set"+(this.$u?"UTC":"");switch(l){case s:return h?c(1,0):c(31,11);case o:return h?c(1,g):c(0,g+1);case a:var M=this.$locale().weekStart||0,y=(d<M?d+7:d)-M;return c(h?p-y:p+(6-y),g);case i:case"date":return v(m+"Hours",0);case n:return v(m+"Minutes",1);case e:return v(m+"Seconds",2);case r:return v(m+"Milliseconds",3);default:return this.clone()}},c.endOf=function(t){return this.startOf(t,!1)},c.$set=function(a,u){var f,h=w.p(a),l="set"+(this.$u?"UTC":""),c=(f={},f.day=l+"Date",f.date=l+"Date",f[o]=l+"Month",f[s]=l+"FullYear",f[n]=l+"Hours",f[e]=l+"Minutes",f[r]=l+"Seconds",f[t]=l+"Milliseconds",f)[h],v=h===i?this.$D+(u-this.$W):u;if(h===o||h===s){var d=this.clone().set("date",1);d.$d[c](v),d.init(),this.$d=d.set("date",Math.min(this.$D,d.daysInMonth())).toDate()}else c&&this.$d[c](v);return this.init(),this},c.set=function(t,r){return this.clone().$set(t,r)},c.get=function(t){return this[w.p(t)]()},c.add=function(t,u){var f,h=this;t=Number(t);var l=w.p(u),c=function(r){var e=M(h);return w.w(e.date(e.date()+Math.round(r*t)),h)};if(l===o)return this.set(o,this.$M+t);if(l===s)return this.set(s,this.$y+t);if(l===i)return c(1);if(l===a)return c(7);var v=(f={},f[e]=6e4,f[n]=36e5,f[r]=1e3,f)[l]||1,d=this.$d.getTime()+t*v;return w.w(d,this)},c.subtract=function(t,r){return this.add(-1*t,r)},c.format=function(t){var r=this;if(!this.isValid())return"Invalid Date";var e=t||"YYYY-MM-DDTHH:mm:ssZ",n=w.z(this),i=this.$locale(),a=this.$H,o=this.$m,u=this.$M,s=i.weekdays,f=i.months,l=function(t,n,i,a){return t&&(t[n]||t(r,e))||i[n].substr(0,a)},c=function(t){return w.s(a%12||12,t,"0")},v=i.meridiem||function(t,r,e){var n=t<12?"AM":"PM";return e?n.toLowerCase():n},d={YY:String(this.$y).slice(-2),YYYY:this.$y,M:u+1,MM:w.s(u+1,2,"0"),MMM:l(i.monthsShort,u,f,3),MMMM:l(f,u),D:this.$D,DD:w.s(this.$D,2,"0"),d:String(this.$W),dd:l(i.weekdaysMin,this.$W,s,2),ddd:l(i.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(a),HH:w.s(a,2,"0"),h:c(1),hh:c(2),a:v(a,o,!0),A:v(a,o,!1),m:String(o),mm:w.s(o,2,"0"),s:String(this.$s),ss:w.s(this.$s,2,"0"),SSS:w.s(this.$ms,3,"0"),Z:n};return e.replace(h,(function(t,r){return r||d[t]||n.replace(":","")}))},c.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},c.diff=function(t,i,f){var h,l=w.p(i),c=M(t),v=6e4*(c.utcOffset()-this.utcOffset()),d=this-c,g=w.m(this,c);return g=(h={},h[s]=g/12,h[o]=g,h[u]=g/3,h[a]=(d-v)/6048e5,h.day=(d-v)/864e5,h[n]=d/36e5,h[e]=d/6e4,h[r]=d/1e3,h)[l]||d,f?g:w.a(g)},c.daysInMonth=function(){return this.endOf(o).$D},c.$locale=function(){return g[this.$L]},c.locale=function(t,r){if(!t)return this.$L;var e=this.clone(),n=m(t,r,!0);return n&&(e.$L=n),e},c.clone=function(){return w.w(this.$d,this)},c.toDate=function(){return new Date(this.valueOf())},c.toJSON=function(){return this.isValid()?this.toISOString():null},c.toISOString=function(){return this.$d.toISOString()},c.toString=function(){return this.$d.toUTCString()},l}();return M.prototype=y.prototype,M.extend=function(t,r){return t(r,y,M),M},M.locale=m,M.isDayjs=p,M.unix=function(t){return M(1e3*t)},M.en=g[d],M.Ls=g,M}()},function(t,r,e){t.exports=function(){"use strict";return function(t,r,e){var n=function(t,r){if(!r.length)return e();var n;1===r.length&&r[0].length>0&&(r=r[0]),n=r[0];for(var i=1;i<r.length;i+=1)r[i].isValid()&&!r[i][t](n)||(n=r[i]);return n};e.max=function(){var t=[].slice.call(arguments,0);return n("isAfter",t)},e.min=function(){var t=[].slice.call(arguments,0);return n("isBefore",t)}}}()}]);
module.exports=function(t){var r={};function e(n){if(r[n])return r[n].exports;var i=r[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,e),i.l=!0,i.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var i in t)e.d(n,i,function(r){return t[r]}.bind(null,i));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=0)}([function(t,r,e){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(t){for(var r,e=1,n=arguments.length;e<n;e++)for(var i in r=arguments[e])Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}).apply(this,arguments)},i=this&&this.__spreadArrays||function(){for(var t=0,r=0,e=arguments.length;r<e;r++)t+=arguments[r].length;var n=Array(t),i=0;for(r=0;r<e;r++)for(var a=arguments[r],o=0,u=a.length;o<u;o++,i++)n[i]=a[o];return n};Object.defineProperty(r,"__esModule",{value:!0}),r.Flowrate=r.PumpRuntime=r.GetAverageORP=r.GetAveragePH=r.Greeter=void 0;var a=e(1),o=e(2),u=e(3),s=e(4);u.extend(s),r.Greeter=function(t){return"Hello "+t},r.GetAveragePH=function(t,r,e){if(u(t).isAfter(u(r)))return!1;var n=[];e.map((function(e){var i=e.ph_scaled,a=new Date(e.custom_timestamps);u(a).isAfter(u(t))&&(u(r).isAfter(u(a))||u(a).isSame(u(r)))&&n.push(i)}));var i=n.length,o=n.reduce((function(t,r){return t+r}),0)/i,s=n.filter((function(t){return t-a.mean(n)<=3*a.standardDeviation(n)}));return{phAverage:o,phData:n,phInfo:s}},r.GetAverageORP=function(t,r,e){if(u(t).isAfter(u(r)))return!1;var n=[];e.map((function(e){var i=e.orp_scaled,a=new Date(e.custom_timestamps);u(a).isAfter(u(t))&&(u(r).isAfter(u(a))||u(a).isSame(u(r)))&&n.push(i)}));var i=n.length,o=n.reduce((function(t,r){return t+r}),0)/i,s=n.filter((function(t){return t-a.mean(n)<=3*a.standardDeviation(n)}));return{orpAverage:o,orpData:n,orpInfo:s}},r.PumpRuntime=function(t,r,e,n){if(u(t).isAfter(u(r)))return!1;var i=e.filter((function(t){return 1===Number.parseInt(t[n+"_start_stop"])})),a=[];return i.map((function(e){var n=new Date(e.custom_timestamps);u(n).isAfter(u(t))&&(u(r).isAfter(u(n))||u(n).isSame(u(r)))&&a.push(u(e.custom_timestamps))})),a.length<1?"0 d, 0 Hr, 0 M, 0 S":o.dateFormat(u.max(a).diff(u.min(a),"s"))},r.Flowrate=function(t,r,e,a,o){if(u(t).isAfter(u(r)))return!1;var s=e.filter((function(t){return t.type===o})).map((function(t){return t.symbol})),f=a.map((function(t){var r=i(Object.keys(t)).filter((function(t){return"flow_gpm"===t.slice(3,t.length)})),e={};return r.map((function(r){var i;e=n(((i={})[r]=t[r],i.custom_timestamps=t.custom_timestamps,i),e)})),e})).filter((function(e){var n=new Date(e.custom_timestamps);if(u(n).isAfter(u(t))&&(u(r).isAfter(u(n))||u(n).isSame(u(r))))return new Date(e.custom_timestamps)})),h=s.map((function(t){return t+"_flow_gpm"})),l=[];return f.map((function(t){var r={};h.map((function(e){var i;r=n(((i={})[e]=t[e],i),r)})),l.push(r),r={}})),l}},function(t,r,e){!function(t){"use strict";function r(t){if(0===t.length)return 0;for(var r,e=t[0],n=0,i=1;i<t.length;i++)r=e+t[i],Math.abs(e)>=Math.abs(t[i])?n+=e-r+t[i]:n+=t[i]-r+e,e=r;return e+n}function e(t){if(0===t.length)throw new Error("mean requires at least one data point");return r(t)/t.length}function n(t,r){var n,i,a=e(t),o=0;if(2===r)for(i=0;i<t.length;i++)o+=(n=t[i]-a)*n;else for(i=0;i<t.length;i++)o+=Math.pow(t[i]-a,r);return o}function i(t){if(0===t.length)throw new Error("variance requires at least one data point");return n(t,2)/t.length}function a(t){if(1===t.length)return 0;var r=i(t);return Math.sqrt(r)}function o(t){if(0===t.length)throw new Error("mode requires at least one data point");if(1===t.length)return t[0];for(var r=t[0],e=NaN,n=0,i=1,a=1;a<t.length+1;a++)t[a]!==r?(i>n&&(n=i,e=r),i=1,r=t[a]):i++;return e}function u(t){return t.slice().sort((function(t,r){return t-r}))}function s(t){if(0===t.length)throw new Error("min requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]<r&&(r=t[e]);return r}function f(t){if(0===t.length)throw new Error("max requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]>r&&(r=t[e]);return r}function h(t){for(var r=0,e=0;e<t.length;e++)r+=t[e];return r}function l(t,r){var e=t.length*r;if(0===t.length)throw new Error("quantile requires at least one data point.");if(r<0||r>1)throw new Error("quantiles must be between 0 and 1");return 1===r?t[t.length-1]:0===r?t[0]:e%1!=0?t[Math.ceil(e)-1]:t.length%2==0?(t[e-1]+t[e])/2:t[e]}function c(t,r,e,n){for(e=e||0,n=n||t.length-1;n>e;){if(n-e>600){var i=n-e+1,a=r-e+1,o=Math.log(i),u=.5*Math.exp(2*o/3),s=.5*Math.sqrt(o*u*(i-u)/i);a-i/2<0&&(s*=-1),c(t,r,Math.max(e,Math.floor(r-a*u/i+s)),Math.min(n,Math.floor(r+(i-a)*u/i+s)))}var f=t[r],h=e,l=n;for(v(t,e,r),t[n]>f&&v(t,e,n);h<l;){for(v(t,h,l),h++,l--;t[h]<f;)h++;for(;t[l]>f;)l--}t[e]===f?v(t,e,l):v(t,++l,n),l<=r&&(e=l+1),r<=l&&(n=l-1)}}function v(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function d(t,r){var e=t.slice();if(Array.isArray(r)){!function(t,r){for(var e=[0],n=0;n<r.length;n++)e.push(m(t.length,r[n]));e.push(t.length-1),e.sort(p);for(var i=[0,e.length-1];i.length;){var a=Math.ceil(i.pop()),o=Math.floor(i.pop());if(!(a-o<=1)){var u=Math.floor((o+a)/2);g(t,e[u],Math.floor(e[o]),Math.ceil(e[a])),i.push(o,u,u,a)}}}(e,r);for(var n=[],i=0;i<r.length;i++)n[i]=l(e,r[i]);return n}return g(e,m(e.length,r),0,e.length-1),l(e,r)}function g(t,r,e,n){r%1==0?c(t,r,e,n):(c(t,r=Math.floor(r),e,n),c(t,r+1,r+1,n))}function p(t,r){return t-r}function m(t,r){var e=t*r;return 1===r?t-1:0===r?0:e%1!=0?Math.ceil(e)-1:t%2==0?e-.5:e}function M(t,r){if(r<t[0])return 0;if(r>t[t.length-1])return 1;var e=function(t,r){for(var e=0,n=0,i=t.length;n<i;)r<=t[e=n+i>>>1]?i=e:n=-~e;return n}(t,r);if(t[e]!==r)return e/t.length;e++;var n=function(t,r){for(var e=0,n=0,i=t.length;n<i;)r>=t[e=n+i>>>1]?n=-~e:i=e;return n}(t,r);if(n===e)return e/t.length;var i=n-e+1;return i*(n+e)/2/i/t.length}function w(t){var r=d(t,.75),e=d(t,.25);if("number"==typeof r&&"number"==typeof e)return r-e}function y(t){return+d(t,.5)}function b(t){for(var r=y(t),e=[],n=0;n<t.length;n++)e.push(Math.abs(t[n]-r));return y(e)}function $(t,r){r=r||Math.random;for(var e,n,i=t.length;i>0;)n=Math.floor(r()*i--),e=t[i],t[i]=t[n],t[n]=e;return t}function S(t,r){return $(t.slice().slice(),r)}function D(t){for(var r,e=0,n=0;n<t.length;n++)0!==n&&t[n]===r||(r=t[n],e++);return e}function _(t,r){for(var e=[],n=0;n<t;n++){for(var i=[],a=0;a<r;a++)i.push(0);e.push(i)}return e}function q(t,r,e,n){var i;if(t>0){var a=(e[r]-e[t-1])/(r-t+1);i=n[r]-n[t-1]-(r-t+1)*a*a}else i=n[r]-e[r]*e[r]/(r+1);return i<0?0:i}function O(t,r,e,n,i,a,o){if(!(t>r)){var u=Math.floor((t+r)/2);n[e][u]=n[e-1][u-1],i[e][u]=u;var s=e;t>e&&(s=Math.max(s,i[e][t-1]||0)),s=Math.max(s,i[e-1][u]||0);var f,h,l,c=u-1;r<n.length-1&&(c=Math.min(c,i[e][r+1]||0));for(var v=c;v>=s&&!((f=q(v,u,a,o))+n[e-1][s-1]>=n[e][u]);--v)(h=q(s,u,a,o)+n[e-1][s-1])<n[e][u]&&(n[e][u]=h,i[e][u]=s),s++,(l=f+n[e-1][v-1])<n[e][u]&&(n[e][u]=l,i[e][u]=v);O(t,u-1,e,n,i,a,o),O(u+1,r,e,n,i,a,o)}}function E(t,r){if(t.length!==r.length)throw new Error("sampleCovariance requires samples with equal lengths");if(t.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var n=e(t),i=e(r),a=0,o=0;o<t.length;o++)a+=(t[o]-n)*(r[o]-i);return a/(t.length-1)}function A(t){if(t.length<2)throw new Error("sampleVariance requires at least two data points");return n(t,2)/(t.length-1)}function x(t){var r=A(t);return Math.sqrt(r)}function P(t,r,e,n){return(t*r+e*n)/(r+n)}function I(t){if(0===t.length)throw new Error("meanSimple requires at least one data point");return h(t)/t.length}function k(t){if(0===t.length)throw new Error("rootMeanSquare requires at least one data point");for(var r=0,e=0;e<t.length;e++)r+=Math.pow(t[e],2);return Math.sqrt(r/t.length)}var T=function(){this.totalCount=0,this.data={}};T.prototype.train=function(t,r){for(var e in this.data[r]||(this.data[r]={}),t){var n=t[e];void 0===this.data[r][e]&&(this.data[r][e]={}),void 0===this.data[r][e][n]&&(this.data[r][e][n]=0),this.data[r][e][n]++}this.totalCount++},T.prototype.score=function(t){var r,e={};for(var n in t){var i=t[n];for(r in this.data)e[r]={},this.data[r][n]?e[r][n+"_"+i]=(this.data[r][n][i]||0)/this.totalCount:e[r][n+"_"+i]=0}var a={};for(r in e)for(var o in a[r]=0,e[r])a[r]+=e[r][o];return a};var H=function(){this.weights=[],this.bias=0};function j(t){if(t<0)throw new Error("factorial requires a non-negative value");if(Math.floor(t)!==t)throw new Error("factorial requires an integer input");for(var r=1,e=2;e<=t;e++)r*=e;return r}H.prototype.predict=function(t){if(t.length!==this.weights.length)return null;for(var r=0,e=0;e<this.weights.length;e++)r+=this.weights[e]*t[e];return(r+=this.bias)>0?1:0},H.prototype.train=function(t,r){if(0!==r&&1!==r)return null;t.length!==this.weights.length&&(this.weights=t,this.bias=1);var e=this.predict(t);if("number"==typeof e&&e!==r){for(var n=r-e,i=0;i<this.weights.length;i++)this.weights[i]+=n*t[i];this.bias+=n}return this};var C=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],F=Math.log(Math.sqrt(2*Math.PI)),N={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}},Y=Math.sqrt(2*Math.PI),R={gaussian:function(t){return Math.exp(-.5*t*t)/Y}},L={nrd:function(t){var r=x(t),e=w(t);return"number"==typeof e&&(r=Math.min(r,e/1.34)),1.06*r*Math.pow(t.length,-.2)}};function W(t,r,e){var n,i;if(void 0===r)n=R.gaussian;else if("string"==typeof r){if(!R[r])throw new Error('Unknown kernel "'+r+'"');n=R[r]}else n=r;if(void 0===e)i=L.nrd(t);else if("string"==typeof e){if(!L[e])throw new Error('Unknown bandwidth method "'+e+'"');i=L[e](t)}else i=e;return function(r){var e=0,a=0;for(e=0;e<t.length;e++)a+=n((r-t[e])/i);return a/i/t.length}}var G=Math.sqrt(2*Math.PI);function U(t){for(var r=t,e=t,n=1;n<15;n++)r+=e*=t*t/(2*n+1);return Math.round(1e4*(.5+r/G*Math.exp(-t*t/2)))/1e4}for(var V=[],z=0;z<=3.09;z+=.01)V.push(U(z));function B(t){var r=1/(1+.5*Math.abs(t)),e=r*Math.exp(-t*t+((((((((.17087277*r-.82215223)*r+1.48851587)*r-1.13520398)*r+.27886807)*r-.18628806)*r+.09678418)*r+.37409196)*r+1.00002368)*r-1.26551223);return t>=0?1-e:e-1}function J(t){var r=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),e=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*r)+Math.log(1-t*t)/2,2)-Math.log(1-t*t)/r)-(2/(Math.PI*r)+Math.log(1-t*t)/2));return t>=0?e:-e}function Z(t){if("number"==typeof t)return t<0?-1:0===t?0:1;throw new TypeError("not a number")}t.BayesianClassifier=T,t.PerceptronModel=H,t.addToMean=function(t,r,e){return t+(e-t)/(r+1)},t.average=e,t.averageSimple=I,t.bayesian=T,t.bernoulliDistribution=function(t){if(t<0||t>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-t,t]},t.binomialDistribution=function(t,r){if(!(r<0||r>1||t<=0||t%1!=0)){var e=0,n=0,i=[],a=1;do{i[e]=a*Math.pow(r,e)*Math.pow(1-r,t-e),n+=i[e],a=a*(t-++e+1)/e}while(n<.9999);return i}},t.bisect=function(t,r,e,n,i){if("function"!=typeof t)throw new TypeError("func must be a function");for(var a=0;a<n;a++){var o=(r+e)/2;if(0===t(o)||Math.abs((e-r)/2)<i)return o;Z(t(o))===Z(t(r))?r=o:e=o}throw new Error("maximum number of iterations exceeded")},t.chiSquaredDistributionTable=N,t.chiSquaredGoodnessOfFit=function(t,r,n){for(var i=0,a=r(e(t)),o=[],u=[],s=0;s<t.length;s++)void 0===o[t[s]]&&(o[t[s]]=0),o[t[s]]++;for(var f=0;f<o.length;f++)void 0===o[f]&&(o[f]=0);for(var h in a)h in o&&(u[+h]=a[h]*t.length);for(var l=u.length-1;l>=0;l--)u[l]<3&&(u[l-1]+=u[l],u.pop(),o[l-1]+=o[l],o.pop());for(var c=0;c<o.length;c++)i+=Math.pow(o[c]-u[c],2)/u[c];var v=o.length-1-1;return N[v][n]<i},t.chunk=function(t,r){var e=[];if(r<1)throw new Error("chunk size must be a positive number");if(Math.floor(r)!==r)throw new Error("chunk size must be an integer");for(var n=0;n<t.length;n+=r)e.push(t.slice(n,n+r));return e},t.ckmeans=function(t,r){if(r>t.length)throw new Error("cannot generate more classes than there are data values");var e=u(t);if(1===D(e))return[e];var n=_(r,e.length),i=_(r,e.length);!function(t,r,e){for(var n=r[0].length,i=t[Math.floor(n/2)],a=[],o=[],u=0,s=void 0;u<n;++u)s=t[u]-i,0===u?(a.push(s),o.push(s*s)):(a.push(a[u-1]+s),o.push(o[u-1]+s*s)),r[0][u]=q(0,u,a,o),e[0][u]=0;for(var f=1;f<r.length;++f)O(f<r.length-1?f:n-1,n-1,f,r,e,a,o)}(e,n,i);for(var a=[],o=i[0].length-1,s=i.length-1;s>=0;s--){var f=i[s][o];a[s]=e.slice(f,o+1),s>0&&(o=f-1)}return a},t.combinations=function t(r,e){var n,i,a,o,u=[];for(n=0;n<r.length;n++)if(1===e)u.push([r[n]]);else for(a=t(r.slice(n+1,r.length),e-1),i=0;i<a.length;i++)(o=a[i]).unshift(r[n]),u.push(o);return u},t.combinationsReplacement=function t(r,e){for(var n=[],i=0;i<r.length;i++)if(1===e)n.push([r[i]]);else for(var a=t(r.slice(i,r.length),e-1),o=0;o<a.length;o++)n.push([r[i]].concat(a[o]));return n},t.combineMeans=P,t.combineVariances=function(t,r,e,n,i,a){var o=P(r,e,i,a);return(e*(t+Math.pow(r-o,2))+a*(n+Math.pow(i-o,2)))/(e+a)},t.cumulativeStdNormalProbability=function(t){var r=Math.abs(t),e=Math.min(Math.round(100*r),V.length-1);return t>=0?V[e]:+(1-V[e]).toFixed(4)},t.epsilon=1e-4,t.equalIntervalBreaks=function(t,r){if(t.length<2)return t;for(var e=s(t),n=f(t),i=[e],a=(n-e)/r,o=1;o<r;o++)i.push(i[0]+a*o);return i.push(n),i},t.erf=B,t.errorFunction=B,t.extent=function(t){if(0===t.length)throw new Error("extent requires at least one data point");for(var r=t[0],e=t[0],n=1;n<t.length;n++)t[n]>e&&(e=t[n]),t[n]<r&&(r=t[n]);return[r,e]},t.extentSorted=function(t){return[t[0],t[t.length-1]]},t.factorial=j,t.gamma=function t(r){if(Number.isInteger(r))return r<=0?NaN:j(r-1);if(--r<0)return Math.PI/(Math.sin(Math.PI*-r)*t(-r));var e=r+1/4;return Math.pow(r/Math.E,r)*Math.sqrt(2*Math.PI*(r+1/6))*(1+1/144/Math.pow(e,2)-1/12960/Math.pow(e,3)-257/207360/Math.pow(e,4)-52/2612736/Math.pow(e,5)+5741173/9405849600/Math.pow(e,6)+37529/18811699200/Math.pow(e,7))},t.gammaln=function(t){if(t<=0)return 1/0;t--;for(var r=C[0],e=1;e<15;e++)r+=C[e]/(t+e);var n=5.2421875+t;return F+Math.log(r)-n+(t+.5)*Math.log(n)},t.geometricMean=function(t){if(0===t.length)throw new Error("geometricMean requires at least one data point");for(var r=1,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("geometricMean requires only positive numbers as input");r*=t[e]}return Math.pow(r,1/t.length)},t.harmonicMean=function(t){if(0===t.length)throw new Error("harmonicMean requires at least one data point");for(var r=0,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("harmonicMean requires only positive numbers as input");r+=1/t[e]}return t.length/r},t.interquartileRange=w,t.inverseErrorFunction=J,t.iqr=w,t.kde=W,t.kernelDensityEstimation=W,t.linearRegression=function(t){var r,e,n=t.length;if(1===n)r=0,e=t[0][1];else{for(var i,a,o,u=0,s=0,f=0,h=0,l=0;l<n;l++)u+=a=(i=t[l])[0],s+=o=i[1],f+=a*a,h+=a*o;e=s/n-(r=(n*h-u*s)/(n*f-u*u))*u/n}return{m:r,b:e}},t.linearRegressionLine=function(t){return function(r){return t.b+t.m*r}},t.mad=b,t.max=f,t.maxSorted=function(t){return t[t.length-1]},t.mean=e,t.meanSimple=I,t.median=y,t.medianAbsoluteDeviation=b,t.medianSorted=function(t){return l(t,.5)},t.min=s,t.minSorted=function(t){return t[0]},t.mode=function(t){return o(u(t))},t.modeFast=function(t){for(var r,e=new Map,n=0,i=0;i<t.length;i++){var a=e.get(t[i]);void 0===a?a=1:a++,a>n&&(r=t[i],n=a),e.set(t[i],a)}if(0===n)throw new Error("mode requires at last one data point");return r},t.modeSorted=o,t.numericSort=u,t.perceptron=H,t.permutationTest=function(t,r,n,i){if(void 0===i&&(i=1e4),void 0===n&&(n="two_side"),"two_side"!==n&&"greater"!==n&&"less"!==n)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var a=e(t)-e(r),o=new Array(i),u=t.concat(r),s=Math.floor(u.length/2),f=0;f<i;f++){$(u);var h=u.slice(0,s),l=u.slice(s,u.length),c=e(h)-e(l);o[f]=c}var v=0;if("two_side"===n)for(var d=0;d<=i;d++)Math.abs(o[d])>=Math.abs(a)&&(v+=1);else if("greater"===n)for(var g=0;g<=i;g++)o[g]>=a&&(v+=1);else for(var p=0;p<=i;p++)o[p]<=a&&(v+=1);return v/i},t.permutationsHeap=function(t){for(var r=new Array(t.length),e=[t.slice()],n=0;n<t.length;n++)r[n]=0;for(var i=0;i<t.length;)if(r[i]<i){var a=0;i%2!=0&&(a=r[i]);var o=t[a];t[a]=t[i],t[i]=o,e.push(t.slice()),r[i]++,i=0}else r[i]=0,i++;return e},t.poissonDistribution=function(t){if(!(t<=0)){var r=0,e=0,n=[],i=1;do{n[r]=Math.exp(-t)*Math.pow(t,r)/i,e+=n[r],i*=++r}while(e<.9999);return n}},t.probit=function(t){return 0===t?t=1e-4:t>=1&&(t=.9999),Math.sqrt(2)*J(2*t-1)},t.product=function(t){for(var r=1,e=0;e<t.length;e++)r*=t[e];return r},t.quantile=d,t.quantileRank=function(t,r){return M(u(t),r)},t.quantileRankSorted=M,t.quantileSorted=l,t.quickselect=c,t.rSquared=function(t,r){if(t.length<2)return 1;for(var e=0,n=0;n<t.length;n++)e+=t[n][1];for(var i=e/t.length,a=0,o=0;o<t.length;o++)a+=Math.pow(i-t[o][1],2);for(var u=0,s=0;s<t.length;s++)u+=Math.pow(t[s][1]-r(t[s][0]),2);return 1-u/a},t.rms=k,t.rootMeanSquare=k,t.sample=function(t,r,e){return S(t,e).slice(0,r)},t.sampleCorrelation=function(t,r){return E(t,r)/x(t)/x(r)},t.sampleCovariance=E,t.sampleKurtosis=function(t){var r=t.length;if(r<4)throw new Error("sampleKurtosis requires at least four data points");for(var n,i=e(t),a=0,o=0,u=0;u<r;u++)a+=(n=t[u]-i)*n,o+=n*n*n*n;return(r-1)/((r-2)*(r-3))*(r*(r+1)*o/(a*a)-3*(r-1))},t.sampleSkewness=function(t){if(t.length<3)throw new Error("sampleSkewness requires at least three data points");for(var r,n=e(t),i=0,a=0,o=0;o<t.length;o++)i+=(r=t[o]-n)*r,a+=r*r*r;var u=t.length-1,s=Math.sqrt(i/u),f=t.length;return f*a/((f-1)*(f-2)*Math.pow(s,3))},t.sampleStandardDeviation=x,t.sampleVariance=A,t.sampleWithReplacement=function(t,r,e){if(0===t.length)return[];e=e||Math.random;for(var n=t.length,i=[],a=0;a<r;a++){var o=Math.floor(e()*n);i.push(t[o])}return i},t.shuffle=S,t.shuffleInPlace=$,t.sign=Z,t.standardDeviation=a,t.standardNormalTable=V,t.subtractFromMean=function(t,r,e){return(t*r-e)/(r-1)},t.sum=r,t.sumNthPowerDeviations=n,t.sumSimple=h,t.tTest=function(t,r){return(e(t)-r)/(a(t)/Math.sqrt(t.length))},t.tTestTwoSample=function(t,r,n){var i=t.length,a=r.length;if(!i||!a)return null;n||(n=0);var o=e(t),u=e(r),s=A(t),f=A(r);if("number"==typeof o&&"number"==typeof u&&"number"==typeof s&&"number"==typeof f){var h=((i-1)*s+(a-1)*f)/(i+a-2);return(o-u-n)/Math.sqrt(h*(1/i+1/a))}},t.uniqueCountSorted=D,t.variance=i,t.zScore=function(t,r,e){return(t-r)/e},Object.defineProperty(t,"__esModule",{value:!0})}(r)},function(t,r,e){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.dateFormat=void 0,r.dateFormat=function(t){var r=parseInt(t,10),e=Math.floor(r/86400);r-=3600*e*24;var n=Math.floor(r/3600);r-=3600*n;var i=Math.floor(r/60);return e+" d, "+n+" Hr, "+i+" M, "+(r-=60*i)+" S"}},function(t,r,e){t.exports=function(){"use strict";var t="millisecond",r="second",e="minute",n="hour",i="day",a="week",o="month",u="quarter",s="year",f=/^(\d{4})-?(\d{1,2})-?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?.?(\d{1,3})?$/,h=/\[([^\]]+)]|Y{2,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,l=function(t,r,e){var n=String(t);return!n||n.length>=r?t:""+Array(r+1-n.length).join(e)+t},c={s:l,z:function(t){var r=-t.utcOffset(),e=Math.abs(r),n=Math.floor(e/60),i=e%60;return(r<=0?"+":"-")+l(n,2,"0")+":"+l(i,2,"0")},m:function(t,r){var e=12*(r.year()-t.year())+(r.month()-t.month()),n=t.clone().add(e,o),i=r-n<0,a=t.clone().add(e+(i?-1:1),o);return Number(-(e+(r-n)/(i?n-a:a-n))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(f){return{M:o,y:s,w:a,d:i,D:"date",h:n,m:e,s:r,ms:t,Q:u}[f]||String(f||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},d="en",g={};g[d]=v;var p=function(t){return t instanceof y},m=function(t,r,e){var n;if(!t)return d;if("string"==typeof t)g[t]&&(n=t),r&&(g[t]=r,n=t);else{var i=t.name;g[i]=t,n=i}return!e&&n&&(d=n),n||!e&&d},M=function(t,r){if(p(t))return t.clone();var e="object"==typeof r?r:{};return e.date=t,e.args=arguments,new y(e)},w=c;w.l=m,w.i=p,w.w=function(t,r){return M(t,{locale:r.$L,utc:r.$u,$offset:r.$offset})};var y=function(){function l(t){this.$L=this.$L||m(t.locale,null,!0),this.parse(t)}var c=l.prototype;return c.parse=function(t){this.$d=function(t){var r=t.date,e=t.utc;if(null===r)return new Date(NaN);if(w.u(r))return new Date;if(r instanceof Date)return new Date(r);if("string"==typeof r&&!/Z$/i.test(r)){var n=r.match(f);if(n)return e?new Date(Date.UTC(n[1],n[2]-1,n[3]||1,n[4]||0,n[5]||0,n[6]||0,n[7]||0)):new Date(n[1],n[2]-1,n[3]||1,n[4]||0,n[5]||0,n[6]||0,n[7]||0)}return new Date(r)}(t),this.init()},c.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},c.$utils=function(){return w},c.isValid=function(){return!("Invalid Date"===this.$d.toString())},c.isSame=function(t,r){var e=M(t);return this.startOf(r)<=e&&e<=this.endOf(r)},c.isAfter=function(t,r){return M(t)<this.startOf(r)},c.isBefore=function(t,r){return this.endOf(r)<M(t)},c.$g=function(t,r,e){return w.u(t)?this[r]:this.set(e,t)},c.year=function(t){return this.$g(t,"$y",s)},c.month=function(t){return this.$g(t,"$M",o)},c.day=function(t){return this.$g(t,"$W",i)},c.date=function(t){return this.$g(t,"$D","date")},c.hour=function(t){return this.$g(t,"$H",n)},c.minute=function(t){return this.$g(t,"$m",e)},c.second=function(t){return this.$g(t,"$s",r)},c.millisecond=function(r){return this.$g(r,"$ms",t)},c.unix=function(){return Math.floor(this.valueOf()/1e3)},c.valueOf=function(){return this.$d.getTime()},c.startOf=function(t,u){var f=this,h=!!w.u(u)||u,l=w.p(t),c=function(t,r){var e=w.w(f.$u?Date.UTC(f.$y,r,t):new Date(f.$y,r,t),f);return h?e:e.endOf(i)},v=function(t,r){return w.w(f.toDate()[t].apply(f.toDate("s"),(h?[0,0,0,0]:[23,59,59,999]).slice(r)),f)},d=this.$W,g=this.$M,p=this.$D,m="set"+(this.$u?"UTC":"");switch(l){case s:return h?c(1,0):c(31,11);case o:return h?c(1,g):c(0,g+1);case a:var M=this.$locale().weekStart||0,y=(d<M?d+7:d)-M;return c(h?p-y:p+(6-y),g);case i:case"date":return v(m+"Hours",0);case n:return v(m+"Minutes",1);case e:return v(m+"Seconds",2);case r:return v(m+"Milliseconds",3);default:return this.clone()}},c.endOf=function(t){return this.startOf(t,!1)},c.$set=function(a,u){var f,h=w.p(a),l="set"+(this.$u?"UTC":""),c=(f={},f.day=l+"Date",f.date=l+"Date",f[o]=l+"Month",f[s]=l+"FullYear",f[n]=l+"Hours",f[e]=l+"Minutes",f[r]=l+"Seconds",f[t]=l+"Milliseconds",f)[h],v=h===i?this.$D+(u-this.$W):u;if(h===o||h===s){var d=this.clone().set("date",1);d.$d[c](v),d.init(),this.$d=d.set("date",Math.min(this.$D,d.daysInMonth())).toDate()}else c&&this.$d[c](v);return this.init(),this},c.set=function(t,r){return this.clone().$set(t,r)},c.get=function(t){return this[w.p(t)]()},c.add=function(t,u){var f,h=this;t=Number(t);var l=w.p(u),c=function(r){var e=M(h);return w.w(e.date(e.date()+Math.round(r*t)),h)};if(l===o)return this.set(o,this.$M+t);if(l===s)return this.set(s,this.$y+t);if(l===i)return c(1);if(l===a)return c(7);var v=(f={},f[e]=6e4,f[n]=36e5,f[r]=1e3,f)[l]||1,d=this.$d.getTime()+t*v;return w.w(d,this)},c.subtract=function(t,r){return this.add(-1*t,r)},c.format=function(t){var r=this;if(!this.isValid())return"Invalid Date";var e=t||"YYYY-MM-DDTHH:mm:ssZ",n=w.z(this),i=this.$locale(),a=this.$H,o=this.$m,u=this.$M,s=i.weekdays,f=i.months,l=function(t,n,i,a){return t&&(t[n]||t(r,e))||i[n].substr(0,a)},c=function(t){return w.s(a%12||12,t,"0")},v=i.meridiem||function(t,r,e){var n=t<12?"AM":"PM";return e?n.toLowerCase():n},d={YY:String(this.$y).slice(-2),YYYY:this.$y,M:u+1,MM:w.s(u+1,2,"0"),MMM:l(i.monthsShort,u,f,3),MMMM:l(f,u),D:this.$D,DD:w.s(this.$D,2,"0"),d:String(this.$W),dd:l(i.weekdaysMin,this.$W,s,2),ddd:l(i.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(a),HH:w.s(a,2,"0"),h:c(1),hh:c(2),a:v(a,o,!0),A:v(a,o,!1),m:String(o),mm:w.s(o,2,"0"),s:String(this.$s),ss:w.s(this.$s,2,"0"),SSS:w.s(this.$ms,3,"0"),Z:n};return e.replace(h,(function(t,r){return r||d[t]||n.replace(":","")}))},c.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},c.diff=function(t,i,f){var h,l=w.p(i),c=M(t),v=6e4*(c.utcOffset()-this.utcOffset()),d=this-c,g=w.m(this,c);return g=(h={},h[s]=g/12,h[o]=g,h[u]=g/3,h[a]=(d-v)/6048e5,h.day=(d-v)/864e5,h[n]=d/36e5,h[e]=d/6e4,h[r]=d/1e3,h)[l]||d,f?g:w.a(g)},c.daysInMonth=function(){return this.endOf(o).$D},c.$locale=function(){return g[this.$L]},c.locale=function(t,r){if(!t)return this.$L;var e=this.clone(),n=m(t,r,!0);return n&&(e.$L=n),e},c.clone=function(){return w.w(this.$d,this)},c.toDate=function(){return new Date(this.valueOf())},c.toJSON=function(){return this.isValid()?this.toISOString():null},c.toISOString=function(){return this.$d.toISOString()},c.toString=function(){return this.$d.toUTCString()},l}();return M.prototype=y.prototype,M.extend=function(t,r){return t(r,y,M),M},M.locale=m,M.isDayjs=p,M.unix=function(t){return M(1e3*t)},M.en=g[d],M.Ls=g,M}()},function(t,r,e){t.exports=function(){"use strict";return function(t,r,e){var n=function(t,r){if(!r.length)return e();var n;1===r.length&&r[0].length>0&&(r=r[0]),n=r[0];for(var i=1;i<r.length;i+=1)r[i].isValid()&&!r[i][t](n)||(n=r[i]);return n};e.max=function(){var t=[].slice.call(arguments,0);return n("isAfter",t)},e.min=function(){var t=[].slice.call(arguments,0);return n("isBefore",t)}}}()}]);
{
"name": "@varunaiot/varunalib",
"version": "1.0.0",
"version": "1.0.1",
"main": "build/index.js",

@@ -5,0 +5,0 @@ "types": "lib/index.d.ts",

@@ -6,4 +6,9 @@ import { PumpRuntime } from '../../lib';

expect(
PumpRuntime(new Date('2020-05-16 10:50:24.957721'), new Date('2020-05-28 11:14:06.689533'), runtimeData, 'p3'),
).toBe('0 d, 0 Hr, 43 M, 1 S');
PumpRuntime(new Date("2020-06-21 00:00:00.979879"), new Date("2020-06-26 00:00:00.979879"), runtimeData, 'p3'),
).toBe('0 d, 4 Hr, 55 M, 0 S');
expect(
PumpRuntime(new Date("2020-06-21 00:00:00.979879"), new Date("2020-06-26 00:00:00.979879"), runtimeData, 'p1'),
).toBe('0 d, 0 Hr, 0 M, 0 S');
});
// const startDate: Date = new Date("2020-06-21 00:00:00.979879");
// const endDate: Date = new Date("2020-06-26 00:00:00.979879");

@@ -82,2 +82,5 @@ import { standardDeviation, mean } from 'simple-statistics';

});
if (runtimeData.length<1){
return `0 d, 0 Hr, 0 M, 0 S`
}

@@ -84,0 +87,0 @@ let runtime = dateFormat(dayjs.max(runtimeData).diff(dayjs.min(runtimeData), 's'));

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc