Comparing version 0.10.5 to 0.10.6
/*! jsexpr 2022-11-22 */ | ||
"use strict";var _typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function i(o,a,s){function c(n,t){if(!a[n]){if(!o[n]){var r="function"==typeof require&&require;if(!t&&r)return r(n,!0);if(f)return f(n,!0);var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}var u=a[n]={exports:{}};o[n][0].call(u.exports,function(t){return c(o[n][1][t]||t)},u,u.exports,i,o,a,s)}return a[n].exports}for(var f="function"==typeof require&&require,t=0;t<s.length;t++)c(s[t]);return c}({1:[function(n,r,e){(function(){this.jsexpr;var t=n("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=t),e.jsexpr=t),"undefined"!=typeof window&&(window.jsexpr=t)}).call(this)},{"./index.js":2}],2:[function(t,n,r){var e=t("./lib");n.exports=e},{"./lib":5}],3:[function(require,module,exports){var CACHE={};function fneval(obj,key){try{return eval("this."+key)}catch(t){return}}function cacheeval(obj,key){if(!CACHE[key]){var rkey=key.replace(/'/g,"\\'"),rx=/^[a-zA-Z$_@]/,fn=eval("(function(){\n let rx = /^[a-zA-Z$_]/;\n return '"+rkey+"'.startsWith('this.') || '"+rkey+"'=='this' || !rx.test('"+rkey+"')?\n function() {\n let r = undefined;\n try {r="+key+";}\n catch(err){}\n return r;\n } :\n function() {\n let r = undefined;\n try {r=this."+(rx.test(key)?key:"$___$")+";}\n catch(err){try{r="+key+";}catch(err){}}\n return r;\n }\n })()");CACHE[key]=fn}return CACHE[key].call(obj)}var EVALS={eval:function(t,n){var r=fneval.call(t,t,n);return void 0===r?"":r},iteval:function(n,t){t.split(".").forEach(function(t){null!=n&&null!=n&&(n=n[t])});var r=n||void 0;return void 0===r?"":r},ceval:function(t,n){var r=cacheeval(t,n);return void 0===r?"":r},valwalk:function(t,n,r){if(!t)return t;for(var e in t){var u=r+(r?".":"")+e,i=n[u];void 0!==i?t[e]=i:"object"==_typeof2(t[e])&&EVALS.valwalk(t[e],n,u)}return t}};module.exports=EVALS},{}],4:[function(require,module,exports){var EVALS=require("./evals.js"),extend=require("extend"),dayjs=require("dayjs"),Mingo=require("mingo");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}","g"),RX_FILTER=new RegExp("^[A-Z_]+\\:"),FILTERS={JSON:function(n){function t(t){return n.apply(this,arguments)}return t.toString=function(){return n.toString()},t}(function(t){var n=t[1],r=t[2];2==t.length?r=isNaN(n)?2:(n="this",t[1]):1==t.length&&(n="this",r=2),r=parseInt(r);var e=tokens("${"+n+"}");return function(t){return JSON.stringify(e(t),null,r)}}),DATE:function(t){t.shift();var e=tokens("${"+t.shift()+"}"),u=t.join(":").split("|");return function(t){var n=e(t),r=dayjs(n,u[0]);return u[1]?r.format(u[1]):r.toDate()}},SUBSTR:function(t){t.shift();var r=tokens("${"+t.shift()+"}"),n=t.join(":").split("|"),e=parseInt(n[0]),u=parseInt(n[1]);return isNaN(e)&&(e=0),isNaN(u)&&(u=void 0),function(t){var n=r(t);return _typeof2("string"==n)?n.substring(e,u):n}}};function fnassign(path){var npath=path.split(".").map(function(t,n){return"['"+t+"']"}).join(""),fn="(function(path){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\t// Ensure path\n\t\t\t\t\tlet root = obj;\n\t\t\t\t\tlet kpath = path.split('.');\n\t\t\t\t\tfor(let i=0; i<kpath.length;i++) {\n\t\t\t\t\t\tlet k = kpath[i];\n\t\t\t\t\t\tif(!root[k]) root[k] = {};\n\t\t\t\t\t\troot = root[k];\n\t\t\t\t\t}\n\t\n\t\t\t\t\treturn obj"+npath+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})('"+path+"')";return console.log(fn),eval(fn)}function parse(r,n){n=n||"ceval";var t=r.match(RX);t&&t.forEach(function(t){var n=t.replace(RX_RPL_PARSE,"$1").trim().replace(/'/g,"\\'");r=r.replace(t,"__val(entry,'"+n+"')")});var e=new Function("entry","__val","return ("+r+")");return function(t){return e(t,EVALS[n])}}function tokens(o,a){a=EVALS[a||"ceval"];var u,s=[];return(o.match(RX)||[]).forEach(function(t){var n=o.indexOf(t),r=o.substring(0,n),e=t.replace(RX_RPL_TOKEN,"");if(o=o.substring(n+t.length),s.push(r),RX_FILTER.test(e)){var u=e.split(":"),i=FILTERS[u[0]](u);s.push(i)}else s.push(function(t){return a(t,e)})}),s.push(o),s=s.filter(function(t){return""!=t}),1<(u=s.length)?function(t){for(var n="",r=0;r<u;r++){var e=s[r];n+="string"==typeof e?e:e(t)}return n}:function(t){var n=s[0];if(void 0!==n)return"string"==typeof n?n:n(t)}}function jsontokens(u){var i,o=[];return function e(u,i){u&&Object.keys(u).forEach(function(t){var n=i+(i?".":"")+t,r=u[t];"string"==typeof r?o.push({path:n,fn:tokens(r)}):e(r,n)})}(u,""),i=o.length,function(t){for(var n={},r=0;r<i;r++){var e=o[r];n[e.path]=e.fn(t)}return EVALS.valwalk(extend(!0,{},u),n,"")}}function mingotokens(t){var n=Array.isArray(t.$)?t.$:[t.$],e=new Mingo.Aggregator(n);return function(t){var n=Array.isArray(t),r=e.run(n?t:[t]);return!n&&r.length<=1?r[0]:r}}function exprfn(n,t){if("number"==typeof n)return function(t){return n};if("object"!=(void 0===n?"undefined":_typeof2(n)))return tokens(n);var r=extend({},n);delete r.$;var e=n.$?mingotokens(n,t):function(t){return t},u=Object.keys(r).length?jsontokens(r,t):function(t){return t};return function(t){var n=e(t),r=u(n);return void 0!==r._&&1==Object.keys(r).length?r._:r}}function traverse(t,n){for(var r in t)t[r]=n(t,r,t[r]);for(var e in t)"object"==_typeof2(t[e])&&traverse(t[e],n)}function filter(t,n){FILTERS[t]=n}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn,traverse:traverse,filter:filter}}module.exports=instance},{"./evals.js":3,dayjs:7,extend:8,mingo:9}],5:[function(t,n,r){var e=t("./expression"),u=(t("./mingo_ex"),e("$"));u.newInstance=function(t){return e(t)},u.filter=function(t,n){u.FILTERS[t]=n},n.exports=u},{"./expression":4,"./mingo_ex":6}],6:[function(t,n,r){var e=t("mingo"),u=t("./expression")("$"),o={},a={};try{e.addOperators(e.OP_QUERY,function(t){return{$starts:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").startsWith(r[0])},$startsWith:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").startsWith(r[0])},$ends:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").endsWith(r[0])},$endsWith:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").endsWith(r[0])},$contains:function(t,n,r){return r=Array.isArray(r)?r:[r],0<=(n||"").indexOf(r[0])}}}),e.addOperators(e.OP_EXPRESSION,function(i){return{$eval:function(t,n,r){return o[n]||(o[n]=u.eval(n)),o[n](t)},$expr:function(t,n,r){return a[n]||(a[n]=u.expr(n)),a[n](t)},$keyval:function(t,n,r){return i.computeValue(t,n).reduce(function(t,n){return t[n[0]]=n[1]||"_",t},{})},$trim:function(t,n,r){for(var e=new Set((n.chars||"").split("")),u=i.computeValue(t,n.input).split("");e.has(u[0]);)u.shift();for(;e.has(u[u.length-1]);)u.pop();return u.join("")},$starts:function(t,n,r){return(i.computeValue(t,n[0])||"").startsWith(n[1])},$startsWidth:function(t,n,r){return(i.computeValue(t,n[0])||"").startsWith(n[1])},$ends:function(t,n,r){return(i.computeValue(t,n[0])||"").endsWith(n[1])},$endsWith:function(t,n,r){return(i.computeValue(t,n[0])||"").endsWith(n[1])},$contains:function(t,n,r){return 0<=(i.computeValue(t,n[0])||"").indexOf(n[1])}}})}catch(t){}n.exports=e},{"./expression":4,mingo:9}],7:[function(t,n,r){var e,u;e=this,u=function(){var s="millisecond",v="second",p="minute",d="hour",y="day",$="week",g="month",c="quarter",m="year",_="date",b="Invalid Date",o=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,x=/\[([^\]]+)]|Y{1,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,t={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("_")},i=function(t,n,r){var e=String(t);return!e||e.length>=n?t:""+Array(n+1-e.length).join(r)+t},n={s:i,z:function(t){var n=-t.utcOffset(),r=Math.abs(n),e=Math.floor(r/60),u=r%60;return(n<=0?"+":"-")+i(e,2,"0")+":"+i(u,2,"0")},m:function t(n,r){if(n.date()<r.date())return-t(r,n);var e=12*(r.year()-n.year())+(r.month()-n.month()),u=n.clone().add(e,g),i=r-u<0,o=n.clone().add(e+(i?-1:1),g);return+(-(e+(r-u)/(i?u-o:o-u))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:g,y:m,w:$,d:y,D:_,h:d,m:p,s:v,ms:s,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},a="en",f={};f[a]=t;var e=function(t){return t instanceof h},u=function(t,n,r){var e;if(!t)return a;if("string"==typeof t)f[t]&&(e=t),n&&(f[t]=n,e=t);else{var u=t.name;f[u]=t,e=u}return!r&&e&&(a=e),e||!r&&a},l=function(t,n){if(e(t))return t.clone();var r="object"==(void 0===n?"undefined":_typeof2(n))?n:{};return r.date=t,r.args=arguments,new h(r)},k=n;k.l=u,k.i=e,k.w=function(t,n){return l(t,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var h=function(){function t(t){this.$L=u(t.locale,null,!0),this.parse(t)}var n=t.prototype;return n.parse=function(t){this.$d=function(t){var n=t.date,r=t.utc;if(null===n)return new Date(NaN);if(k.u(n))return new Date;if(n instanceof Date)return new Date(n);if("string"==typeof n&&!/Z$/i.test(n)){var e=n.match(o);if(e){var u=e[2]-1||0,i=(e[7]||"0").substring(0,3);return r?new Date(Date.UTC(e[1],u,e[3]||1,e[4]||0,e[5]||0,e[6]||0,i)):new Date(e[1],u,e[3]||1,e[4]||0,e[5]||0,e[6]||0,i)}}return new Date(n)}(t),this.$x=t.x||{},this.init()},n.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()},n.$utils=function(){return k},n.isValid=function(){return!(this.$d.toString()===b)},n.isSame=function(t,n){var r=l(t);return this.startOf(n)<=r&&r<=this.endOf(n)},n.isAfter=function(t,n){return l(t)<this.startOf(n)},n.isBefore=function(t,n){return this.endOf(n)<l(t)},n.$g=function(t,n,r){return k.u(t)?this[n]:this.set(r,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,n){var e=this,u=!!k.u(n)||n,r=k.p(t),i=function(t,n){var r=k.w(e.$u?Date.UTC(e.$y,n,t):new Date(e.$y,n,t),e);return u?r:r.endOf(y)},o=function(t,n){return k.w(e.toDate()[t].apply(e.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(n)),e)},a=this.$W,s=this.$M,c=this.$D,f="set"+(this.$u?"UTC":"");switch(r){case m:return u?i(1,0):i(31,11);case g:return u?i(1,s):i(0,s+1);case $:var l=this.$locale().weekStart||0,h=(a<l?a+7:a)-l;return i(u?c-h:c+(6-h),s);case y:case _:return o(f+"Hours",0);case d:return o(f+"Minutes",1);case p:return o(f+"Seconds",2);case v:return o(f+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,n){var r,e=k.p(t),u="set"+(this.$u?"UTC":""),i=(r={},r[y]=u+"Date",r[_]=u+"Date",r[g]=u+"Month",r[m]=u+"FullYear",r[d]=u+"Hours",r[p]=u+"Minutes",r[v]=u+"Seconds",r[s]=u+"Milliseconds",r)[e],o=e===y?this.$D+(n-this.$W):n;if(e===g||e===m){var a=this.clone().set(_,1);a.$d[i](o),a.init(),this.$d=a.set(_,Math.min(this.$D,a.daysInMonth())).$d}else i&&this.$d[i](o);return this.init(),this},n.set=function(t,n){return this.clone().$set(t,n)},n.get=function(t){return this[k.p(t)]()},n.add=function(r,t){var n,e=this;r=Number(r);var u=k.p(t),i=function(t){var n=l(e);return k.w(n.date(n.date()+Math.round(t*r)),e)};if(u===g)return this.set(g,this.$M+r);if(u===m)return this.set(m,this.$y+r);if(u===y)return i(1);if(u===$)return i(7);var o=(n={},n[p]=6e4,n[d]=36e5,n[v]=1e3,n)[u]||1,a=this.$d.getTime()+r*o;return k.w(a,this)},n.subtract=function(t,n){return this.add(-1*t,n)},n.format=function(t){var u=this;if(!this.isValid())return b;var i=t||"YYYY-MM-DDTHH:mm:ssZ",r=k.z(this),n=this.$locale(),e=this.$H,o=this.$m,a=this.$M,s=n.weekdays,c=n.months,f=function(t,n,r,e){return t&&(t[n]||t(u,i))||r[n].substr(0,e)},l=function(t){return k.s(e%12||12,t,"0")},h=n.meridiem||function(t,n,r){var e=t<12?"AM":"PM";return r?e.toLowerCase():e},v={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:k.s(a+1,2,"0"),MMM:f(n.monthsShort,a,c,3),MMMM:f(c,a),D:this.$D,DD:k.s(this.$D,2,"0"),d:String(this.$W),dd:f(n.weekdaysMin,this.$W,s,2),ddd:f(n.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(e),HH:k.s(e,2,"0"),h:l(1),hh:l(2),a:h(e,o,!0),A:h(e,o,!1),m:String(o),mm:k.s(o,2,"0"),s:String(this.$s),ss:k.s(this.$s,2,"0"),SSS:k.s(this.$ms,3,"0"),Z:r};return i.replace(x,function(t,n){return n||v[t]||r.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,n,r){var e,u=k.p(n),i=l(t),o=6e4*(i.utcOffset()-this.utcOffset()),a=this-i,s=k.m(this,i);return s=(e={},e[m]=s/12,e[g]=s,e[c]=s/3,e[$]=(a-o)/6048e5,e[y]=(a-o)/864e5,e[d]=a/36e5,e[p]=a/6e4,e[v]=a/1e3,e)[u]||a,r?s:k.a(s)},n.daysInMonth=function(){return this.endOf(g).$D},n.$locale=function(){return f[this.$L]},n.locale=function(t,n){if(!t)return this.$L;var r=this.clone(),e=u(t,n,!0);return e&&(r.$L=e),r},n.clone=function(){return k.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},t}(),r=h.prototype;return l.prototype=r,[["$ms",s],["$s",v],["$m",p],["$H",d],["$W",y],["$M",g],["$y",m],["$D",_]].forEach(function(n){r[n[1]]=function(t){return this.$g(t,n[0],n[1])}}),l.extend=function(t,n){return t.$i||(t(n,h,l),t.$i=!0),l},l.locale=u,l.isDayjs=e,l.unix=function(t){return l(1e3*t)},l.en=f[a],l.Ls=f,l.p={},l},"object"==(void 0===r?"undefined":_typeof2(r))&&void 0!==n?n.exports=u():"function"==typeof define&&define.amd?define(u):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs=u()},{}],8:[function(t,n,r){var u=Object.prototype.hasOwnProperty,i=Object.prototype.toString,e=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},h=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var n,r=u.call(t,"constructor"),e=t.constructor&&t.constructor.prototype&&u.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!e)return!1;for(n in t);return void 0===n||u.call(t,n)},v=function(t,n){e&&"__proto__"===n.name?e(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},p=function(t,n){if("__proto__"===n){if(!u.call(t,n))return;if(o)return o(t,n).value}return t[n]};n.exports=function t(){var n,r,e,u,i,o,a=arguments[0],s=1,c=arguments.length,f=!1;for("boolean"==typeof a&&(f=a,a=arguments[1]||{},s=2),(null==a||"object"!==(void 0===a?"undefined":_typeof2(a))&&"function"!=typeof a)&&(a={});s<c;++s)if(null!=(n=arguments[s]))for(r in n)e=p(a,r),a!==(u=p(n,r))&&(f&&u&&(h(u)||(i=l(u)))?(o=i?(i=!1,e&&l(e)?e:[]):e&&h(e)?e:{},v(a,{name:r,newValue:t(f,o,u)})):void 0!==u&&v(a,{name:r,newValue:u}));return a}},{}],9:[function(t,n,r){var e,u;e=this,u=function(){function e(t){return(e="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(t){return void 0===t?"undefined":_typeof2(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":_typeof2(t)})(t)}function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function u(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function t(t,n,r){return n&&u(t.prototype,n),r&&u(t,r),t}function i(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,u=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(e=(o=a.next()).done)&&(r.push(o.value),!n||r.length!==n);e=!0);}catch(t){u=!0,i=t}finally{try{e||null==a.return||a.return()}finally{if(u)throw i}}return r}(t,n)||function(t,n){if(!t)return;if("string"==typeof t)return a(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(t,n)}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}var s="null",c="undefined",f="boolean",l="number",h="string",v="date",p="regexp",d="array",y="object",$="function",g=[s,c,f,l,h,v,p],m="expression",_="group",b="pipeline",x="projection",k="query",O=function(){};Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,n){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),e=r.length>>>0;if(0===e)return!1;var u,i,o=0|n,a=Math.max(0<=o?o:e-Math.abs(o),0);for(;a<e;){if((u=r[a])===(i=t)||"number"==typeof u&&"number"==typeof i&&isNaN(u)&&isNaN(i))return!0;a++}return!1}});var w=Array.prototype.push;function M(t,n){t||B(n)}function j(t){switch(E(t)){case d:return t.map(j);case y:return Z(t,j);default:return t}}function S(t){switch(E(t)){case d:return st([],t);case y:return Object.assign({},t);default:return t}}function A(t){return null===t?"Null":void 0===t?"Undefined":t.constructor.name}function E(t){return A(t).toLowerCase()}function N(t){return E(t)===f}function D(t){return E(t)===h}function I(t){return E(t)===l}var R=Array.isArray||function(t){return!!t&&t.constructor===Array};function T(t){return!!t&&t.constructor===Object}function L(t){return t===Object(t)}function P(t){return E(t)===v}function C(t){return E(t)===p}function r(t){return E(t)===$}function F(t){return null==t}function V(t){return null===t}function n(t){return void 0===t}function q(t,n){return t.includes(n)}function U(t,n){return!q(t,n)}function W(t){return!!t}function Y(t){return F(t)||R(t)&&0===t.length||T(t)&&0===J(t).length||!t}function H(t){return R(t)?t:[t]}function z(t,n){return t.hasOwnProperty(n)}function B(t){throw new Error(t)}var J=Object.keys;function X(t,n,r){if(n=n.bind(r),R(t))for(var e=0,u=t.length;e<u&&!1!==n(t[e],e,t);e++);else for(var i in t)if(t.hasOwnProperty(i)&&!1===n(t[i],i,t))break}function Z(t,n,r){n=n.bind(r);for(var e={},u=J(t),i=0;i<u.length;i++){var o=u[i];e[o]=n(t[o],o)}return e}function Q(n,r){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(n===O)return r;if(r===O)return n;var t=[n,r];if(!t.every(T)&&!t.every(R))throw Error("mismatched types. must both be array or object");if(e.flatten=e.flatten||!1,R(n))if(e.flatten){for(var u=0,i=0;u<n.length&&i<r.length;)n[u]=Q(n[u++],r[i++],e);for(;i<r.length;)n.push(r[i++])}else w.apply(n,r);else Object.keys(r).forEach(function(t){n.hasOwnProperty(t)?n[t]=Q(n[t],r[t],e):n[t]=r[t]});return n}function K(r,e,u){return R(r)?r.reduce(e,u):(X(r,function(t,n){return u=e(u,t,n,r)}),u)}function G(t,n){var r=n.map(ut);return t.filter(function(t){return q(r,ut(t))})}function tt(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1,i=[];return function t(n,r){for(var e=0,u=n.length;e<u;e++)R(n[e])&&(0<r||r<0)?t(n[e],Math.max(-1,r-1)):i.push(n[e])}(t,n),i}function nt(t,n){for(var r=[t],e=[n];0<r.length;)if((t=r.pop())!==(n=e.pop())){var u=E(t);if(u!==E(n)||u===$)return!1;switch(u){case d:if(t.length!==n.length)return!1;st(r,t),st(e,n);break;case y:var i=J(t),o=J(n);if(i.length!==o.length)return!1;i.sort(),o.sort();for(var a=0,s=i.length;a<s;a++){var c=i[a];if(c!==o[a])return!1;r.push(t[c]),e.push(n[c])}break;default:if(et(t)!==et(n))return!1}}return 0===r.length}function rt(t){var r={},e=[];return X(t,function(t){var n=ut(t);z(r,n)||(e.push(t),r[n]=0)}),e}function et(n){var t=E(n);switch(t){case f:case l:case p:return n.toString();case h:return JSON.stringify(n);case v:return n.toISOString();case s:case c:return t;case d:return"["+n.map(et)+"]";default:var r=t===y?"":"".concat(A(n)),e=J(n);return e.sort(),"".concat(r,"{")+e.map(function(t){return"".concat(et(t),":").concat(et(n[t]))})+"}"}}function ut(t){if(F(t))return null;for(var n=0,r=et(t),e=r.length;e;)n=(n<<5)-n^r.charCodeAt(--e);return n>>>0}function it(t,n){return t<n?-1:n<t?1:0}function ot(t,n,r){var e=[],u=[],i={};if(r=r||it,Y(t))return t;for(var o=0;o<t.length;o++){var a=t[o],s=n(a,o);F(s)?u.push(a):(i[s]?i[s].push(a):i[s]=[a],e.push(s))}e.sort(r);for(var c=0;c<e.length;c++)st(u,i[e[c]]);return u}function at(t,u){var i={keys:[],groups:[]},o={};return X(t,function(t){var n=u(t),r=ut(n),e=-1;void 0===o[r]&&(e=i.keys.length,o[r]=e,i.keys.push(n),i.groups.push([])),e=o[r],i.groups[e].push(t)}),i}function st(t,n){return w.apply(t,n),t}function ct(t,n){return L(t)?t[n]:void 0}function ft(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=0;return r.meta=r.meta||!1,t=q(g,E(t))?t:function e(t,u){for(var n=t,r=0;r<u.length;r++){var i=u[r];if(null===i.match(/^\d+$/)&&R(n)){if(0===r&&0<o)break;o+=1,u=u.slice(r),n=K(n,function(t,n){var r=e(n,u);return void 0!==r&&t.push(r),t},[]);break}if(void 0===(n=ct(n,i)))break}return n}(t,n.split(".")),r.meta?{result:t,depth:o}:t}function lt(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.preserveMissingValues=r.preserveMissingValues||!1;var e,u,i=n.split("."),o=i[0],a=1===i.length||i.slice(1).join("."),s=null!==o.match(/^\d+$/),c=1<i.length;try{R(t)?s?(e=ct(t,Number(o)),c&&(e=lt(e,a,r)),e=[e]):(e=[],X(t,function(t){u=lt(t,n,r),r.preserveMissingValues?(void 0===u&&(u=O),e.push(u)):void 0!==u&&e.push(u)})):(u=ct(t,o),c&&(u=lt(u,a,r)),M(void 0!==u),(e={})[o]=u)}catch(t){e=void 0}return e}function ht(t){if(R(t))for(var n=t.length-1;0<=n;n--)t[n]===O?t.splice(n,1):ht(t[n]);else if(T(t))for(var r in t)t.hasOwnProperty(r)&&ht(t[r]);return t}function vt(t,n,r){var e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],u=n.split("."),i=u[0],o=1===u.length||u.slice(1).join(".");1===u.length?r(t,i):(!0===e&&F(t[i])&&(t[i]={}),vt(t[i],o,r,e))}function pt(t,n,r){vt(t,n,function(t,n){t[n]=r},!0)}function dt(t,n){vt(t,n,function(t,n){R(t)&&/^\d+$/.test(n)?t.splice(parseInt(n),1):T(t)&&delete t[n]})}function yt(t){return!!t&&"$"===t[0]}function $t(t){if(q(g,E(t)))return C(t)?{$regex:t}:{$eq:t};if(L(t)){var n=J(t);if(!n.some(yt))return{$eq:t};if(q(n,"$regex")){var r=t.$regex,e=t.$options||"",u="";D(r)&&(u+=r.ignoreCase||0<=e.indexOf("i")?"i":"",u+=r.multiline||0<=e.indexOf("m")?"m":"",u+=r.global||0<=e.indexOf("g")?"g":"",r=new RegExp(r,u)),t.$regex=r,delete t.$options}}return t}function gt(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return F(r)?n<0?(n=Math.max(0,t.length+n),r=t.length-n+1):(r=n,n=0):(n<0&&(n=Math.max(0,t.length+n)),M(0<r,"Invalid argument value for $slice operator. Limit must be a positive number"),r+=n),t.slice(n,r)}function mt(t,n){var r=K(t,function(t,n){return t+n},0),e=t.length||1,u=n?1:0,i=r/e;return Math.sqrt(K(t,function(t,n){return t+Math.pow(n-i,2)},0)/(e-u))}var _t=function(){return Object.assign({computeValue:At,ops:jt},{assert:M,clone:S,cloneDeep:j,each:X,err:B,hashCode:ut,getType:A,has:z,includes:q.bind(null),isArray:R,isBoolean:N,isDate:P,isEmpty:Y,isEqual:nt,isFunction:r,isNil:F,isNull:V,isNumber:I,isObject:T,isRegExp:C,isString:D,isUndefined:n,keys:J,reduce:K,resolve:ft,resolveObj:lt})},bt={key:"_id"};var xt={$$ROOT:function(t,n,r){return r.root},$$CURRENT:function(t,n,r){return t},$$REMOVE:function(t,n,r){}},kt={$$KEEP:function(t){return t},$$PRUNE:function(){},$$DESCEND:function(r,e,u){return z(e,"$cond")&&X(r,function(t,n){L(t)&&(R(t)?(i=[],X(t,function(t){T(t)&&(t=Et(t,e,u)),F(t)||i.push(t)})):i=Et(t,e,u),F(i)?delete r[n]:r[n]=i)}),r;var i}},Ot=J(xt),wt=J(kt);function Mt(){return bt.key}function jt(){return K(Array.prototype.slice.call(arguments),function(t,n){return st(t,J(Gn[n]))},[])}function St(r,t,e){if(z(Gn[_],t))return Gn[_][t](r,e);if(T(e)){var u={};return X(e,function(t,n){if(u[n]=St(r,n,e[n]),z(Gn[_],n))return u=u[n],M(1===J(e).length,"Invalid $group expression '"+JSON.stringify(e)+"'"),!1}),u}}function At(r,e){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,u=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(u.root=u.root||r,z(Gn[m],t))return Gn[m][t](r,e,u);if(z(Gn[_],t))return r=At(r,e,null,u),M(R(r),t+" expression must resolve to an array"),Gn[_][t](r,null,u);if(D(e)&&0<e.length&&"$"===e[0]){if(q(Ot,e))return xt[e](r,null,u);if(q(wt,e))return e;var n=Ot.filter(function(t){return 0===e.indexOf(t+".")});return 1===n.length&&("$$ROOT"===(n=n[0])&&(r=u.root),e=e.substr(n.length)),ft(r,e.slice(1))}switch(E(e)){case d:return e.map(function(t){return At(r,t)});case y:var i={};return X(e,function(t,n){if(i[n]=At(r,t,n,u),[m,_].some(function(t){return z(Gn[t],n)}))return M(1===J(e).length,"Invalid aggregation expression '"+JSON.stringify(e)+"'"),i=i[n],!1}),i;default:return e}}function Et(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.root=r.root||t;var e=At(t,n,null,r);return q(wt,e)?kt[e](t,n,r):e}function Nt(t,n,r){n=n||0;var e=Math.abs(t)===t?1:-1;t=Math.abs(t);var u=Math.trunc(t),i=t-u;if(0===n){var o=Math.trunc(10*i);r&&1==(1&u)&&5<=o&&u++}else if(0<n){var a=Math.pow(10,n),s=Math.trunc(i*a),c=Math.trunc(i*a*10)%10;r&&5<c&&(s+=1),u+=s/a}else if(n<0){var f=Math.pow(10,-1*n),l=u%f;if(u=Math.max(0,u-l),r&&-1===e){for(;10<l;)l-=l%10;0<u&&5<=l&&(u+=f)}}return u*e}function Dt(t){return t instanceof Vt?t:new Vt(t)}function It(t){return!!t&&"object"===e(t)&&Rt(t.next)}function Rt(t){return!!t&&"function"==typeof t}Dt.isIterator=It;var Tt=new Error,Lt=1,Pt=2,Ct=3,Ft=4;var Vt=function(){function i(t){if(o(this,i),this.__iteratees=[],this.__first=!1,this.__done=!1,this.__buf=[],Rt(t)&&(t={next:t}),It(t)){var n=t;t=function(){var t=n.next();if(t.done)throw Tt;return t.value}}else if(Array.isArray(t)){var r=t,e=r.length,u=0;t=function(){if(u<e)return r[u++];throw Tt}}else if(!Rt(t))throw new Error("Source is not iterable. Must be Array, Function or Object{next:Function}");var f,l,h,v,p,d;this.next=(f=t,l=this.__iteratees,h=this.__buf,v=!1,p=-1,d=0,function(t){t=t===h;try{t:for(;!v;){var n=f();p++;for(var r=-1,e=l.length,u=!1;++r<e;){var i=l[r],o=i.func;switch(i.type){case Lt:n=o(n,p);break;case Pt:if(!o(n,p))continue t;break;case Ct:--i.func,i.func||(u=!0);break;case Ft:--i.func,i.func||(s=r,c=(a=l).slice(s+1),a.splice(s),Array.prototype.push.apply(a,c));continue t;default:break t}}if(v=u,!t)return{value:n,done:!1};h[d++]=n}}catch(t){if(t!==Tt)throw t}var a,s,c;return{done:v=!0}})}return t(i,[{key:"_validate",value:function(){if(this.__first)throw new Error("Cannot add iteratee/transform after `first()`")}},{key:"_push",value:function(t){return this._validate(),this.__iteratees.push(t),this}},{key:"map",value:function(t){return this._push({type:Lt,func:t})}},{key:"filter",value:function(t){return this._push({type:Pt,func:t})}},{key:"take",value:function(t){return 0<t?this._push({type:Ct,func:t}):this}},{key:"drop",value:function(t){return 0<t?this._push({type:Ft,func:t}):this}},{key:"transform",value:function(t){this._validate();var n,r=this;return Dt(function(){return n||(n=Dt(t(r.value()))),n.next()})}},{key:"first",value:function(){return this.take(1),this.__first=!0,this}},{key:"value",value:function(){return this.__done||(this.__done=this.next(this.__buf).done),this.__first?this.__buf[0]:this.__buf}},{key:"each",value:function(t){for(;;){var n=this.next();if(n.done)break;if(!1===t(n.value))return!1}return!0}},{key:"reduce",value:function(t,n){var r=this.next(),e=0;for(void 0!==n||r.done||(n=r.value,r=this.next(),e++);!r.done;)n=t(n,r.value,e++),r=this.next();return n}},{key:"size",value:function(){return this.reduce(function(t,n){return++t},0)}}]),i}();"function"==typeof Symbol&&(Vt.prototype[Symbol.iterator]=function(){return this});var qt=function(){function r(t,n){o(this,r),this.__operators=t,this.__options=n}return t(r,[{key:"stream",value:function(r,e){var u=this;r=Dt(r);var i=Gn[b];return Y(this.__operators)||X(this.__operators,function(t){var n=J(t);M(1===n.length&&q(jt(b),n[0]),"invalid aggregation operator ".concat(n)),n=n[0],r=e&&e instanceof Yt?i[n].call(e,r,t[n],u.__options):i[n](r,t[n],u.__options)}),r}},{key:"run",value:function(t,n){return this.stream(t,n).value()}}]),r}();function Ut(t,n,r){return M(R(n),"Aggregation pipeline must be an array"),new qt(n,r).run(t)}var Wt=function(){function e(t,n,r){o(this,e),this.__filterFn=n.test.bind(n),this.__query=n,this.__source=t,this.__projection=r||n.__projection,this.__operators=[],this.__result=null,this.__stack=[],this.__options={}}return t(e,[{key:"_fetch",value:function(){return this.__result||(T(this.__projection)&&this.__operators.push({$project:this.__projection}),this.__result=Dt(this.__source).filter(this.__filterFn),0<this.__operators.length&&(this.__result=new qt(this.__operators,this.__options).stream(this.__result,this.__query))),this.__result}},{key:"all",value:function(){return this._fetch().value()}},{key:"count",value:function(){return this.all().length}},{key:"skip",value:function(t){return this.__operators.push({$skip:t}),this}},{key:"limit",value:function(t){return this.__operators.push({$limit:t}),this}},{key:"sort",value:function(t){return this.__operators.push({$sort:t}),this}},{key:"collation",value:function(t){return this.__options.collation=t,this}},{key:"next",value:function(){if(this.__stack){if(0<this.__stack.length)return this.__stack.pop();var t=this._fetch().next();if(!t.done)return t.value;this.__stack=null}}},{key:"hasNext",value:function(){if(!this.__stack)return!1;if(0<this.__stack.length)return!0;var t=this._fetch().next();return t.done?this.__stack=null:this.__stack.push(t.value),!!this.__stack}},{key:"map",value:function(t){return this._fetch().map(t).value()}},{key:"forEach",value:function(t){this._fetch().each(t)}}]),e}();"function"==typeof Symbol&&(Wt.prototype[Symbol.iterator]=function(){return this._fetch()});var Yt=function(){function r(t,n){o(this,r),this.__criteria=t,this.__projection=n||{},this.__compiled=[],this._compile()}return t(r,[{key:"_compile",value:function(){var n,e=this;M(T(this.__criteria),"query criteria must be an object"),X(this.__criteria,function(t,r){"$where"===r?n={field:r,expr:t}:"$expr"===r?e._processOperator(r,r,t):q(["$and","$or","$nor"],r)?e._processOperator(r,r,t):(M(!yt(r),"unknown top level operator: ".concat(r)),X(t=$t(t),function(t,n){e._processOperator(r,n,t)})),T(n)&&e._processOperator(n.field,n.field,n.expr)})}},{key:"_processOperator",value:function(t,n,r){M(z(Gn[k],n),"invalid query operator ".concat(n," detected")),this.__compiled.push(Gn[k][n](t,r))}},{key:"test",value:function(t){for(var n=0,r=this.__compiled.length;n<r;n++)if(!this.__compiled[n](t))return!1;return!0}},{key:"find",value:function(t,n){return new Wt(t,this,n)}},{key:"remove",value:function(t){var r=this;return K(t,function(t,n){return r.test(n)||t.push(n),t},[])}}]),r}();function Ht(t,n){if(nt(t,n))return!0;if(F(t)&&F(n))return!0;if(R(t)){var r=nt.bind(null,n);return t.some(r)||tt(t,1).some(r)}return!1}function zt(t,n){return!Ht(t,n)}function Bt(t,n){return F(t)?n.some(V):0<G(H(t),n).length}function Jt(t,n){return!Bt(t,n)}function Xt(t,n){return tn(t,n,function(t,n){return t<n})}function Zt(t,n){return tn(t,n,function(t,n){return t<=n})}function Qt(t,n){return tn(t,n,function(t,n){return n<t})}function Kt(t,n){return tn(t,n,function(t,n){return n<=t})}function Gt(t,n){if(R(t)&&!Y(t)){var r=function(t){return t},e=n;J(n).every(yt)&&(e={temp:n},r=function(t){return{temp:t}});for(var u=new Yt(e),i=0,o=t.length;i<o;i++)if(u.test(r(t[i])))return!0}return!1}function tn(t,n,r){return H(t).some(function(t){return A(t)===A(n)&&r(t,n)})}function nn(e){return function(t,n){var r=At(t,n);return e(r[0],r[1])}}var rn=nn(Ht),en=nn(zt),un=nn(Qt),on=nn(Xt),an=nn(Kt),sn=nn(Zt),cn=nn(Jt);function fn(t,n){var r=At(t,n),e=new Date(r.getFullYear(),0,0),u=r-e;return Math.round(u/864e5)}function ln(t,n){return At(t,n).getDate()}function hn(t,n){return At(t,n).getDay()+1}function vn(t,n){return At(t,n).getFullYear()}function pn(t,n){return At(t,n).getMonth()+1}function dn(t,n){var r=At(t,n);(r=new Date(+r)).setHours(0,0,0),r.setDate(r.getDate()+4-(r.getDay()||7));var e=new Date(r.getFullYear(),0,1);return Math.floor(((r-e)/864e5+1)/7)}function yn(t,n){return At(t,n).getUTCHours()}function $n(t,n){return At(t,n).getMinutes()}function gn(t,n){return At(t,n).getSeconds()}function mn(t,n){return At(t,n).getMilliseconds()}var _n={"%Y":[vn,4],"%m":[pn,2],"%d":[ln,2],"%H":[yn,2],"%M":[$n,2],"%S":[gn,2],"%L":[mn,3],"%j":[fn,3],"%w":[hn,1],"%U":[dn,2],"%%":"%"};function bn(t,n){var r=At(t,n),e=r[0],u=r[1],i=r[2];return D(e)?u<0?"":i<0?e.substr(u):e.substr(u,i):""}var xn=[192,224,240];function kn(t){if(t<128)return[t];for(var n=(t<2048?1:t<65536&&2)||3,r=[(t>>6*n)+xn[n-1]];0<n;)r.push(128|t>>6*--n&63);return r}var On=Object.freeze({__proto__:null,$abs:function(t,n){var r=At(t,n);return null==r?null:Math.abs(r)},$add:function(t,n){var r=At(t,n),e=!1,u=K(r,function(t,n){return P(n)&&(M(!e,"'$add' can only have one date value"),e=!0,n=n.getTime()),t+=n},0);return e?new Date(u):u},$ceil:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$ceil expression must resolve to a number."),Math.ceil(r))},$divide:function(t,n){var r=At(t,n);return r[0]/r[1]},$exp:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$exp expression must resolve to a number."),Math.exp(r))},$floor:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$floor expression must resolve to a number."),Math.floor(r))},$ln:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$ln expression must resolve to a number."),Math.log(r))},$log:function(t,n){var r=At(t,n),e="$log expression must resolve to array(2) of numbers";return M(R(r)&&2===r.length,e),r.some(F)?null:(M(r.some(isNaN)||r.every(I),e),Math.log10(r[0])/Math.log10(r[1]))},$log10:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$log10 expression must resolve to a number."),Math.log10(r))},$mod:function(t,n){var r=At(t,n);return r[0]%r[1]},$multiply:function(t,n){return K(At(t,n),function(t,n){return t*n},1)},$pow:function(t,n){var r=At(t,n);return M(R(r)&&2===r.length&&r.every(I),"$pow expression must resolve to array(2) of numbers"),M(!(0===r[0]&&r[1]<0),"$pow cannot raise 0 to a negative exponent"),Math.pow(r[0],r[1])},$round:function(t,n){var r=At(t,n),e=r[0],u=r[1];return F(e)||isNaN(e)||Math.abs(e)===1/0?e:(M(I(e),"$round expression must resolve to a number."),Nt(e,u,!0))},$sqrt:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)&&0<r||isNaN(r),"$sqrt expression must resolve to non-negative number."),Math.sqrt(r))},$subtract:function(t,n){var r=At(t,n);return r[0]-r[1]},$trunc:function(t,n){var r=At(t,n),e=r[0],u=r[1];return F(e)||isNaN(e)||Math.abs(e)===1/0?e:(M(I(e),"$trunc expression must resolve to a number."),M(F(u)||I(u)&&-20<u&&u<100,"$trunc expression has invalid place"),Nt(e,u,!1))},$arrayElemAt:function(t,n){var r=At(t,n);M(R(r)&&2===r.length,"$arrayElemAt expression must resolve to array(2)"),M(R(r[0]),"First operand to $arrayElemAt must resolve to an array"),M(I(r[1]),"Second operand to $arrayElemAt must resolve to an integer");var e=r[1];return r=r[0],e<0&&Math.abs(e)<=r.length?r[e+r.length]:0<=e&&e<r.length?r[e]:void 0},$arrayToObject:function(t,n){var r=At(t,n);return M(R(r),"$arrayToObject expression must resolve to an array"),K(r,function(t,n){return R(n)&&2==n.length?t[n[0]]=n[1]:(M(T(n)&&z(n,"k")&&z(n,"v"),"$arrayToObject expression is invalid."),t[n.k]=n.v),t},{})},$concatArrays:function(t,n){var r=At(t,n,null);return M(R(r),"$concatArrays must resolve to an array"),r.some(F)?null:r.reduce(function(t,n){return st(t,n)},[])},$filter:function(t,n){var r=At(t,n.input),e=n.as,u=n.cond;return M(R(r),"$filter 'input' expression must resolve to an array"),r.filter(function(t){var n={};return n["$"+e]=t,!0===At(n,u)})},$in:function(t,n){var r=At(t,n[0]),e=At(t,n[1]);return M(R(e),"$in second argument must be an array"),e.some(nt.bind(null,r))},$indexOfArray:function(t,n){var r=At(t,n);if(F(r))return null;var e=r[0],u=r[1];if(F(e))return null;M(R(e),"$indexOfArray expression must resolve to an array.");var i=r[2]||0,o=r[3];return F(o)&&(o=e.length),o<i?-1:(M(0<=i&&0<=o,"$indexOfArray expression is invalid"),(0<i||o<e.length)&&(e=e.slice(i,o)),e.findIndex(nt.bind(null,u))+i)},$isArray:function(t,n){return R(At(t,n[0]))},$map:function(n,t){var r=At(n,t.input);M(R(r),"$map 'input' expression must resolve to an array");var e=t.as,u=t.in,i="$"+e;return r.map(function(t){return n[i]=t,At(n,u)})},$objectToArray:function(t,n){var r=At(t,n);M(T(r),"$objectToArray expression must resolve to an object");var e=[];return X(r,function(t,n){return e.push({k:n,v:t})}),e},$range:function(t,n){for(var r=At(t,n),e=r[0],u=r[1],i=r[2]||1,o=[];e<u&&0<i||u<e&&i<0;)o.push(e),e+=i;return o},$reduce:function(t,n){var r=At(t,n.input),e=At(t,n.initialValue),u=n.in;return F(r)?null:(M(R(r),"$reduce 'input' expression must resolve to an array"),K(r,function(t,n){return At({$value:t,$this:n},u)},e))},$reverseArray:function(t,n){var r=At(t,n);if(F(r))return null;M(R(r),"$reverseArray expression must resolve to an array");var e=[];return st(e,r),e.reverse(),e},$size:function(t,n){var r=At(t,n);return R(r)?r.length:void 0},$slice:function(t,n){var r=At(t,n);return gt(r[0],r[1],r[2])},$zip:function(t,n){var e=At(t,n.inputs),r=n.useLongestLength||!1;M(R(e),"'inputs' expression must resolve to an array"),M(N(r),"'useLongestLength' must be a boolean"),R(n.defaults)&&M(W(r),"'useLongestLength' must be set to true to use 'defaults'");for(var u=0,i=0,o=e.length;i<o;i++){var a=e[i];if(F(a))return null;M(R(a),"'inputs' expression values must resolve to an array or null"),u=r?Math.max(u,a.length):Math.min(u||a.length,a.length)}for(var s=[],c=n.defaults||[],f=function(r){var t=e.map(function(t,n){return F(t[r])?c[n]||null:t[r]});s.push(t)},l=0;l<u;l++)f(l);return s},$mergeObjects:function(t,n){var r=At(t,n);return R(r)?K(r,function(t,n){return Object.assign(t,n)},{}):{}},$and:function(t,n){var r=At(t,n);return W(r)&&r.every(W)},$or:function(t,n){var r=At(t,n);return W(r)&&r.some(W)},$not:function(t,n){return!At(t,n[0])},$eq:rn,$ne:en,$gt:un,$lt:on,$gte:an,$lte:sn,$nin:cn,$cmp:function(t,n){var r=At(t,n);return r[0]>r[1]?1:r[0]<r[1]?-1:0},$cond:function(t,n){var r,e,u,i="$cond: invalid arguments";return u=R(n)?(M(3===n.length,i),r=n[0],e=n[1],n[2]):(M(T(n),i),r=n.if,e=n.then,n.else),At(t,At(t,r)?e:u)},$switch:function(n,t){var r="Invalid arguments for $switch operator";M(t.branches,r);var e=t.branches.find(function(t){return M(t.case&&t.then,r),At(n,t.case)});return e?At(n,e.then):(M(t.default,r),At(n,t.default))},$ifNull:function(t,n){M(R(n)&&2===n.length,"$ifNull expression must resolve to array(2)");var r=At(t,n);return F(r[0])?r[1]:r[0]},$dayOfYear:fn,$dayOfMonth:ln,$dayOfWeek:hn,$year:vn,$month:pn,$week:dn,$hour:yn,$minute:$n,$second:gn,$millisecond:mn,$dateToString:function(t,n){for(var r,e,u=n.format,i=At(t,n.date),o=u.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g),a=0,s=o.length;a<s;a++){var c=_n[o[a]],f=c;if(R(c)){var l=c[0],h=c[1];r=l(t,i),e=h,f=new Array(Math.max(e-String(r).length+1,0)).join("0")+r}u=u.replace(o[a],f)}return u},$literal:function(t,n){return n},$setEquals:function(t,n){var r=At(t,n),e=rt(r[0]),u=rt(r[1]);return e.length===u.length&&e.length===G(e,u).length},$setIntersection:function(t,n){var r=At(t,n);return G(r[0],r[1])},$setDifference:function(t,n){var r=At(t,n);return r[0].filter(U.bind(null,r[1]))},$setUnion:function(t,n){var r,e,u=At(t,n);return r=u[0],e=u[1],st(st([],r),e.filter(U.bind(null,r)))},$setIsSubset:function(t,n){var r=At(t,n);return G(r[0],r[1]).length===r[0].length},$anyElementTrue:function(t,n){return At(t,n)[0].some(W)},$allElementsTrue:function(t,n){return At(t,n)[0].every(W)},$concat:function(t,n){var r=At(t,n);return[null,void 0].some(q.bind(null,r))?null:r.join("")},$indexOfBytes:function(t,n){var r=At(t,n),e="$indexOfBytes expression resolves to invalid an argument";if(F(r[0]))return null;M(D(r[0])&&D(r[1]),e);var u=r[0],i=r[1],o=r[2],a=r[3],s=F(o)||I(o)&&0<=o&&Math.round(o)===o;if(M(s=s&&(F(a)||I(a)&&0<=a&&Math.round(a)===a),e),o=o||0,(a=a||u.length)<o)return-1;var c=u.substring(o,a).indexOf(i);return-1<c?c+o:c},$split:function(t,n){var r=At(t,n);return F(r[0])?null:(M(r.every(D),"$split expression must result to array(2) of strings"),r[0].split(r[1]))},$strLenBytes:function(t,n){return~-encodeURI(At(t,n)).split(/%..|./).length},$strLenCP:function(t,n){return At(t,n).length},$strcasecmp:function(t,n){var r=At(t,n),e=r[0],u=r[1];return nt(e,u)||r.every(F)?0:(M(r.every(D),"$strcasecmp must resolve to array(2) of strings"),e=e.toUpperCase(),((u=u.toUpperCase())<e?1:e<u&&-1)||0)},$substrBytes:function(t,n){var r=At(t,n),e=r[0],u=r[1],i=r[2];M(D(e)&&I(u)&&0<=u&&I(i)&&0<=i,"$substrBytes: invalid arguments");for(var o=function(t){for(var n=[],r=0,e=t.length;r<e;r++)n.push(kn(t.codePointAt(r)));return n}(e),a=[],s=0,c=0;c<o.length;c++)a.push(s),s+=o[c].length;var f=a.indexOf(u),l=a.indexOf(u+i);return M(-1<f&&-1<l,"$substrBytes: invalid range, start or end index is a UTF-8 continuation byte."),e.substring(f,l)},$substr:bn,$substrCP:function(t,n){return bn(t,n)},$toLower:function(t,n){var r=At(t,n);return Y(r)?"":r.toLowerCase()},$toUpper:function(t,n){var r=At(t,n);return Y(r)?"":r.toUpperCase()},$let:function(r,t){var e=t.vars,n=t.in;return X(J(e),function(t){var n=At(r,e[t]);r["$"+t]=n}),At(r,n)}});function wn(t,n){return F(n)?t:t.map(function(t){return At(t,n)})}var Mn=Object.freeze({__proto__:null,$addToSet:function(t,n){return rt(wn(t,n))},$avg:function(t,n){var r=wn(t,n).filter(I);return K(r,function(t,n){return t+n},0)/(r.length||1)},$first:function(t,n){return 0<t.length?At(t[0],n):void 0},$last:function(t,n){return 0<t.length?At(t[t.length-1],n):void 0},$max:function(t,n){return K(wn(t,n),function(t,n){return F(t)||t<n?n:t},void 0)},$mergeObjects:function(t,r){return K(t,function(t,n){return Object.assign(t,At(n,r))},{})},$min:function(t,n){return K(wn(t,n),function(t,n){return F(t)||n<t?n:t},void 0)},$push:wn,$stdDevPop:function(t,n){return mt(wn(t,n).filter(I),!1)},$stdDevSamp:function(t,n){return mt(wn(t,n).filter(I),!0)},$sum:function(t,n){return R(t)?I(n)?t.length*n:K(wn(t,n).filter(I),function(t,n){return t+n},0):0}});function jn(t,u,n){var i=J(u);return 0===i.length?t:t.map(function(r){var e=j(r);return X(i,function(t){var n=At(r,u[t]);pt(e,t,n)}),e})}var Sn=jn;function An(t,i,n){var o=Mt(),r=i[o];return t.transform(function(t){var e=at(t,function(t){return At(t,r,r)});delete(i=S(i))[o];var u=-1,n=e.keys.length;return function(){if(++u===n)return{done:!0};var t=e.keys[u],r={};return void 0!==t&&(r[o]=t),X(i,function(t,n){r[n]=St(e.groups[u],n,t)}),{value:r,done:!1}}})}function En(t){var r=Mt(),e=[!1,!1];X(t,function(t,n){n!==r&&(0===t||!1===t?e[0]=!0:1!==t&&!0!==t||(e[1]=!0),M(!(e[0]&&e[1]),"Projection cannot have a mix of inclusion and exclusion."))})}function Nn(t,i,n){if(Y(i)||!T(i))return t;var o=it,r=(n=n||{}).collation;return T(r)&&D(r.locale)&&(o=function(t){var n={sensitivity:Dn[t.strength||3],caseFirst:"off"===t.caseFirst?"false":t.caseFirst||"false",numeric:t.numericOrdering||!1,ignorePunctuation:"shifted"===t.alternate};!0===(t.caseLevel||!1)&&("base"===n.sensitivity&&(n.sensitivity="case"),"accent"===n.sensitivity&&(n.sensitivity="variant"));var e=new Intl.Collator(t.locale,n);return function(t,n){if(!D(t)||!D(n))return it(t,n);var r=e.compare(t,n);return r<0?-1:0<r?1:0}}(r)),t.transform(function(u){return X(J(i).reverse(),function(n){var r=at(u,function(t){return ft(t,n)}),e={},t=ot(r.keys,function(t,n){return e[t]=n,t},o);-1===i[n]&&t.reverse(),u=[],X(t,function(t){return st(u,r.groups[e[t]])})}),u})}var Dn={1:"base",2:"accent",3:"variant"};var In=Object.freeze({__proto__:null,$addFields:jn,$set:Sn,$bucket:function(t,u,n){var i=u.boundaries,o=u.default,a=i[0],s=i[i.length-1],r=u.output||{count:{$sum:1}};M(2<i.length,"$bucket 'boundaries' expression must have at least 3 elements");for(var e=A(a),c=0,f=i.length-1;c<f;c++)M(e===A(i[c+1]),"$bucket 'boundaries' must all be of the same type"),M(i[c]<i[c+1],"$bucket 'boundaries' must be sorted in ascending order");!F(o)&&A(u.default)===A(a)&&M(a>u.default||s<u.default,"$bucket 'default' expression must be out of boundaries range");var l={};X(i,function(t){return l[t]=[]}),F(o)||(l[o]=[]);var h=!1;return Dt(function(){return h||(t.each(function(t){var n=At(t,u.groupBy);if(F(n)||n<a||s<=n)M(!F(o),"$bucket require a default for out of range values"),l[o].push(t);else{M(a<=n&&n<s,"$bucket 'groupBy' expression must resolve to a value in range of boundaries");var r=function(t,n){for(var r=0,e=t.length-1;r<=e;){var u=Math.round(r+(e-r)/2);if(n<t[u])e=u-1;else{if(!(n>t[u]))return u;r=u+1}}return r}(i,n),e=i[Math.max(0,r-1)];l[e].push(t)}}),i.pop(),F(o)||i.push(o),h=Dt(i).map(function(t){var n=St(l[t],null,r);return Object.assign(n,{_id:t})})),h.next()})},$bucketAuto:function(t,n,r){var d=n.output||{count:{$sum:1}},y=n.groupBy,$=n.buckets;return M(0<$,"The $bucketAuto 'buckets' field must be greater than 0, but found: "+$),t.transform(function(t){for(var n=Math.max(1,Math.round(t.length/$)),r=function(u){var i,o=this;return i={},function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ut(n);return z(i,e)||(i[e]=u.apply(o,n)),i[e]}}(At),e={},u=[],i=ot(t,function(t){var n=r(t,y);return F(n)?u.push(t):(e[n]||(e[n]=[]),e[n].push(t)),n}),o=Mt(),a=[],s=0,c=0,f=i.length;c<$&&s<f;c++){for(var l={},h=[],v=0;v<n&&s<f;v++){var p=r(i[s],y);F(p)&&(p=null),st(h,F(p)?u:e[p]),s+=F(p)?u.length:e[p].length,z(l,"min")||(l.min=p),0<a.length&&(a[a.length-1][o].max=l.min)}c==$-1&&st(h,i.slice(s)),a.push(Object.assign(St(h,null,d),{_id:l}))}return 0<a.length&&(a[a.length-1][o].max=r(i[i.length-1],y)),a})},$count:function(n,r,t){return M(D(r)&&""!==r.trim()&&-1===r.indexOf(".")&&"$"!==r.trim()[0],"Invalid expression value for $count"),Dt(function(){var t={};return t[r]=n.size(),{value:t,done:!1}}).first()},$facet:function(t,r,n){return t.transform(function(n){return[Z(r,function(t){return Ut(n,t)})]})},$group:An,$limit:function(t,n,r){return t.take(n)},$lookup:function(t,n,r){var e=n.from,u=n.localField,i=n.foreignField,o=n.as;M(R(e)&&D(i)&&D(u)&&D(o),"$lookup: invalid argument");var a={};return X(e,function(t){var n=ut(ft(t,i));a[n]=a[n]||[],a[n].push(t)}),t.map(function(t){var n=ut(ft(t,u)),r=S(t);return r[o]=a[n]||[],r})},$match:function(t,n,r){var e=new Yt(n);return t.filter(function(t){return e.test(t)})},$out:function(t,n,r){return M(R(n),"$out expression must be an array"),t.map(function(t){return n.push(t),t})},$project:function(t,n,r){if(Y(n))return t;var e=J(n),u=!1,i=Mt();if(En(n),q(e,i)){var o=n[i];0!==o&&!1!==o||(M(U(e=e.filter(U.bind(null,[i])),i),"Must not contain collections id key"),u=Y(e))}else e.push(i);return t.map(function(t){return function s(c,f,t,n){var l=Mt(),h={},v=!1,p=!1,d=[];return n&&d.push(l),t.forEach(function(t){var n,r=f[t];if(t!==l&&q([0,!1],r)&&(p=!0),t===l&&Y(r))n=c[t];else if(D(r))n=At(c,r,t);else if(q([1,!0],r));else if(R(r))n=r.map(function(t){var n=At(c,t);return F(n)?null:n});else{if(!T(r))return void d.push(t);var e=J(r),u=!(1<e.length)&&e[0];if(q(jt(x),u)){var i=Gn[x];"$slice"===u?H(r[u]).every(I)?(n=i[u](c,r[u],t),v=!0):n=At(c,r,t):n=i[u](c,r[u],t)}else if(z(c,t)){En(r);var o=c[t];n=R(o)?o.map(function(t){return s(t,r,e,!1)}):s(o,r,e,!1)}else n=At(c,r,t)}var a=lt(c,t,{preserveMissingValues:!0});void 0!==a&&Q(h,a,{flatten:!0}),U([0,1,!1,!0],r)&&(void 0===n?dt(h,t):pt(h,t,n))}),ht(h),(v||p||n)&&(h=Object.assign({},c,h),0<d.length&&(h=j(h),X(d,function(t){return dt(h,t)}))),h}(t,n,e,u)})},$redact:function(t,n,r){return t.map(function(t){return Et(j(t),n)})},$replaceRoot:function(t,n,r){return t.map(function(t){return M(T(t=At(t,n.newRoot)),"$replaceRoot expression must return an object"),t})},$sample:function(t,n,r){var u=n.size;return M(I(u),"$sample size must be a positive integer"),t.transform(function(n){var r=n.length,e=-1;return function(){if(++e===u)return{done:!0};var t=Math.floor(Math.random()*r);return{value:n[t],done:!1}}})},$skip:function(t,n,r){return t.drop(n)},$sort:Nn,$sortByCount:function(t,n,r){var e={count:{$sum:1}};return e[Mt()]=n,Nn(An(t,e),{count:-1},r)},$unwind:function(u,t,n){D(t)&&(t={path:t});var i,o=t.path.substr(1),r=t.includeArrayIndex||!1,a=t.preserveNullAndEmptyArrays||!1,s=function(t,n){return!1!==r&&(t[r]=n),t};return Dt(function(){for(var t=function(){if(Dt.isIterator(i)){var t=i.next();if(!t.done)return{v:t}}var e=u.next();if(e.done)return{v:e};if(e=e.value,i=ft(e,o),R(i)){if(0===i.length&&!0===a){i=null;var n=j(e);return dt(n,o),{v:{value:s(n,null),done:!1}}}i=Dt(i).map(function(t,n){var r=j(e);return pt(r,o,t),s(r,n)})}else if(!Y(i)||!0===a){var r=j(e);return{v:{value:s(r,null),done:!1}}}};;){var n=t();if("object"===e(n))return n.v}})}});var Rn=Object.freeze({__proto__:null,$:function(t,n,r){B("$ not implemented")},$elemMatch:function(t,n,r){var e=ft(t,r),u=new Yt(n);M(R(e),"$elemMatch: invalid argument");for(var i=0;i<e.length;i++)if(u.test(e[i]))return[e[i]]},$slice:function(t,n,r){var e=ft(t,r);return R(e)?R(n)?gt(e,n[0],n[1]):(M(I(n),"$slice: invalid arguments for projection"),gt(e,n)):e}});function Tn(u){return function(r,e){return function(t){var n=ft(t,r,{meta:!0});return n=function(t,n){if(n<1)return t;for(;n--&&R(t)&&1===t.length;)t=t[0];return t}(n.result,n.depth),u(n,e)}}}var Ln=Tn(function(t,n){var r=!1;if(R(t)&&R(n))for(var e=0,u=n.length;e<u;e++){if(!T(n[e])||!q(J(n[e]),"$elemMatch"))return G(n,t).length===u;r=r||Gt(t,n[e].$elemMatch)}return r}),Pn=Tn(Gt),Cn=Tn(Ht),Fn=Tn(function(t,n){return(!1===n||0===n)&&void 0===t||(!0===n||1===n)&&void 0!==t}),Vn=Tn(Qt),qn=Tn(Kt),Un=Tn(Bt),Wn=Tn(Xt),Yn=Tn(Zt),Hn=Tn(function(t,n){return H(t).some(function(t){return I(t)&&R(n)&&2===n.length&&t%n[0]===n[1]})}),zn=Tn(zt),Bn=Tn(Jt),Jn=Tn(function(t,n){var r=function(t){return D(t)&&!!t.match(n)};return(t=H(t)).some(r)||tt(t,1).some(r)}),Xn=Tn(function(t,n){return R(t)&&I(n)&&t.length===n}),Zn=Tn(function(t,n){switch(n){case 1:case"double":return I(t)&&-1!==(t+"").indexOf(".");case 2:case h:return D(t);case 3:case y:return T(t);case 4:case d:return R(t);case 6:case c:return F(t);case 8:case"bool":return N(t);case 9:case v:return P(t);case 10:case s:return V(t);case 11:case"regex":return C(t);case 16:case"int":return I(t)&&t<=2147483647&&-1===(t+"").indexOf(".");case 18:case"long":return I(t)&&2147483647<t&&t<=0x8000000000000000&&-1===(t+"").indexOf(".");case 19:case"decimal":return I(t);default:return!1}});function Qn(t,n){M(R(n),"Invalid expression. $or expects value to be an Array");var r=[];return X(n,function(t){return r.push(new Yt(t))}),function(t){for(var n=0;n<r.length;n++)if(r[n].test(t))return!0;return!1}}var Kn=Object.freeze({__proto__:null,$all:Ln,$elemMatch:Pn,$eq:Cn,$exists:Fn,$gt:Vn,$gte:qn,$in:Un,$lt:Wn,$lte:Yn,$mod:Hn,$ne:zn,$nin:Bn,$regex:Jn,$size:Xn,$type:Zn,$and:function(t,n){M(R(n),"Invalid expression: $and expects value to be an Array");var r=[];return X(n,function(t){return r.push(new Yt(t))}),function(t){for(var n=0;n<r.length;n++)if(!r[n].test(t))return!1;return!0}},$or:Qn,$nor:function(t,n){M(R(n),"Invalid expression. $nor expects value to be an Array");var r=Qn(0,n);return function(t){return!r(t)}},$not:function(t,n){var r={};r[t]=$t(n);var e=new Yt(r);return function(t){return!e.test(t)}},$where:function(t,n){return r(n)||(n=new Function("return "+n+";")),function(t){return!0===n.call(t)}},$expr:function(t,n){return function(t){return At(t,n)}}}),Gn={};Gn[m]={},Gn[_]={},Gn[b]={},Gn[x]={},Gn[k]={};var tr={query:function(t,n){return new Yt(t).find(this.toJSON(),n)},aggregate:function(t){return new qt(t).run(this.toJSON())}};X([[m,On],[_,Mn],[b,In],[x,Rn],[k,Kn]],function(t){var n=i(t,2),r=n[0],e=n[1];Object.assign(Gn[r],e)});return{_internal:_t,Aggregator:qt,CollectionMixin:tr,Cursor:Wt,Lazy:Dt,OP_EXPRESSION:m,OP_GROUP:_,OP_PIPELINE:b,OP_PROJECTION:x,OP_QUERY:k,Query:Yt,VERSION:"2.5.3",addOperators:function(r,t){var a=t(_t());M(z(Gn,r),"Invalid operator class ".concat(r));var e=Gn[r];X(a,function(t,n){M(/^\$[a-zA-Z0-9_]*$/.test(n),"Invalid operator name ".concat(n)),M(!z(e,n),"".concat(n," already exists for '").concat(r,"' operators"))});var n={};switch(r){case k:X(a,function(i,o){i=i.bind(a),n[o]=function(e,u){return function(t){var n=ft(t,e),r=i(e,n,u);return M(N(r),"".concat(o," must return a boolean")),r}}});break;case x:X(a,function(u,t){u=u.bind(a),n[t]=function(t,n,r){var e=ft(t,r);return u(r,e,n)}});break;default:X(a,function(e,t){n[t]=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(a,n)}})}Object.assign(Gn[r],n)},aggregate:Ut,find:function(t,n,r){return new Yt(n).find(t,r)},remove:function(t,n){return new Yt(n).remove(t)},setup:function(t){Object.assign(bt,t||{})}}},"object"===(void 0===r?"undefined":_typeof2(r))&&void 0!==n?n.exports=u():"function"==typeof define&&define.amd?define(u):(e=e||self).mingo=u()},{}]},{},[1]); | ||
"use strict";var _typeof2="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function i(o,a,s){function c(n,t){if(!a[n]){if(!o[n]){var r="function"==typeof require&&require;if(!t&&r)return r(n,!0);if(f)return f(n,!0);var e=new Error("Cannot find module '"+n+"'");throw e.code="MODULE_NOT_FOUND",e}var u=a[n]={exports:{}};o[n][0].call(u.exports,function(t){return c(o[n][1][t]||t)},u,u.exports,i,o,a,s)}return a[n].exports}for(var f="function"==typeof require&&require,t=0;t<s.length;t++)c(s[t]);return c}({1:[function(n,r,e){(function(){this.jsexpr;var t=n("./index.js");void 0!==e&&(void 0!==r&&r.exports&&(e=r.exports=t),e.jsexpr=t),"undefined"!=typeof window&&(window.jsexpr=t)}).call(this)},{"./index.js":2}],2:[function(t,n,r){var e=t("./lib");n.exports=e},{"./lib":5}],3:[function(require,module,exports){var CACHE={};function fneval(obj,key){try{return eval("this."+key)}catch(t){return}}function cacheeval(obj,key){if(!CACHE[key]){var rkey=key.replace(/'/g,"\\'"),rx=/^[a-zA-Z$_@]/,fn=eval("(function(){\n let rx = /^[a-zA-Z$_]/;\n return '"+rkey+"'.startsWith('this.') || '"+rkey+"'=='this' || !rx.test('"+rkey+"')?\n function() {\n let r = undefined;\n try {r="+key+";}\n catch(err){}\n return r;\n } :\n function() {\n let r = undefined;\n try {r=this."+(rx.test(key)?key:"$___$")+";}\n catch(err){try{r="+key+";}catch(err){}}\n return r;\n }\n })()");CACHE[key]=fn}return CACHE[key].call(obj)}var EVALS={eval:function(t,n){var r=fneval.call(t,t,n);return void 0===r?"":r},iteval:function(n,t){t.split(".").forEach(function(t){null!=n&&null!=n&&(n=n[t])});var r=n||void 0;return void 0===r?"":r},ceval:function(t,n){var r=cacheeval(t,n);return void 0===r?"":r},valwalk:function(t,n,r){if(!t)return t;for(var e in t){var u=r+(r?".":"")+e,i=n[u];void 0!==i?t[e]=i:"object"==_typeof2(t[e])&&EVALS.valwalk(t[e],n,u)}return t}};module.exports=EVALS},{}],4:[function(require,module,exports){var EVALS=require("./evals.js"),extend=require("extend"),dayjs=require("dayjs"),Mingo=require("mingo");function instance(token){var RX=new RegExp("\\"+token+"\\{[^\\}]+\\}","g"),RX_RPL_PARSE=new RegExp("\\"+token+"\\{([^\\}]+)\\}"),RX_RPL_TOKEN=new RegExp("\\"+token+"\\{|\\}","g"),RX_FILTER=new RegExp("^[A-Z_]+\\:"),FILTERS={JSON:function(n){function t(t){return n.apply(this,arguments)}return t.toString=function(){return n.toString()},t}(function(t){var n=t[1],r=t[2];2==t.length?r=isNaN(n)?2:(n="this",t[1]):1==t.length&&(n="this",r=2),r=parseInt(r);var e=tokens("${"+n+"}");return function(t){return JSON.stringify(e(t),null,r)}}),DATE:function(t){t.shift();var e=tokens("${"+t.shift()+"}"),u=t.join(":").split("|");return function(t){var n=e(t),r=dayjs(n,u[0]);return u[1]?r.format(u[1]):r.toDate()}},SUBSTR:function(t){t.shift();var r=tokens("${"+t.shift()+"}"),n=t.join(":").split("|"),e=parseInt(n[0]),u=parseInt(n[1]);return isNaN(e)&&(e=0),isNaN(u)&&(u=void 0),function(t){var n=r(t);return _typeof2("string"==n)?n.substring(e,u):n}}};function fnassign(path){var npath=path.split(".").map(function(t,n){return"['"+t+"']"}).join(""),fn="(function(path){\n\t\t\treturn function(obj,val) {\n\t\t\t\ttry {\n\t\t\t\t\t// Ensure path\n\t\t\t\t\tlet root = obj;\n\t\t\t\t\tlet kpath = path.split('.');\n\t\t\t\t\tfor(let i=0; i<kpath.length;i++) {\n\t\t\t\t\t\tlet k = kpath[i];\n\t\t\t\t\t\tif(!root[k]) root[k] = {};\n\t\t\t\t\t\troot = root[k];\n\t\t\t\t\t}\n\t\n\t\t\t\t\treturn obj"+npath+" = val;\n\t\t\t\t}catch(err) {}\n\t\t\t}\n\t\t})('"+path+"')";return eval(fn)}function parse(r,n){n=n||"ceval";var t=r.match(RX);t&&t.forEach(function(t){var n=t.replace(RX_RPL_PARSE,"$1").trim().replace(/'/g,"\\'");r=r.replace(t,"__val(entry,'"+n+"')")});var e=new Function("entry","__val","return ("+r+")");return function(t){return e(t,EVALS[n])}}function tokens(o,a){a=EVALS[a||"ceval"];var u,s=[];return(o.match(RX)||[]).forEach(function(t){var n=o.indexOf(t),r=o.substring(0,n),e=t.replace(RX_RPL_TOKEN,"");if(o=o.substring(n+t.length),s.push(r),RX_FILTER.test(e)){var u=e.split(":"),i=FILTERS[u[0]](u);s.push(i)}else s.push(function(t){return a(t,e)})}),s.push(o),s=s.filter(function(t){return""!=t}),1<(u=s.length)?function(t){for(var n="",r=0;r<u;r++){var e=s[r];n+="string"==typeof e?e:e(t)}return n}:function(t){var n=s[0];if(void 0!==n)return"string"==typeof n?n:n(t)}}function jsontokens(u){var i,o=[];return function e(u,i){u&&Object.keys(u).forEach(function(t){var n=i+(i?".":"")+t,r=u[t];"string"==typeof r?o.push({path:n,fn:tokens(r)}):e(r,n)})}(u,""),i=o.length,function(t){for(var n={},r=0;r<i;r++){var e=o[r];n[e.path]=e.fn(t)}return EVALS.valwalk(extend(!0,{},u),n,"")}}function mingotokens(t){var n=Array.isArray(t.$)?t.$:[t.$],e=new Mingo.Aggregator(n);return function(t){var n=Array.isArray(t),r=e.run(n?t:[t]);return!n&&r.length<=1?r[0]:r}}function exprfn(n,t){if("number"==typeof n)return function(t){return n};if("object"!=(void 0===n?"undefined":_typeof2(n)))return tokens(n);var r=extend({},n);delete r.$;var e=n.$?mingotokens(n,t):function(t){return t},u=Object.keys(r).length?jsontokens(r,t):function(t){return t};return function(t){var n=e(t),r=u(n);return void 0!==r._&&1==Object.keys(r).length?r._:r}}function traverse(t,n){for(var r in t)t[r]=n(t,r,t[r]);for(var e in t)"object"==_typeof2(t[e])&&traverse(t[e],n)}function filter(t,n){FILTERS[t]=n}return{fn:parse,eval:parse,assign:fnassign,expr:exprfn,expression:exprfn,traverse:traverse,filter:filter}}module.exports=instance},{"./evals.js":3,dayjs:7,extend:8,mingo:9}],5:[function(t,n,r){var e=t("./expression"),u=(t("./mingo_ex"),e("$"));u.newInstance=function(t){return e(t)},u.filter=function(t,n){u.FILTERS[t]=n},n.exports=u},{"./expression":4,"./mingo_ex":6}],6:[function(t,n,r){var e=t("mingo"),u=t("./expression")("$"),o={},a={};try{e.addOperators(e.OP_QUERY,function(t){return{$starts:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").startsWith(r[0])},$startsWith:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").startsWith(r[0])},$ends:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").endsWith(r[0])},$endsWith:function(t,n,r){return r=Array.isArray(r)?r:[r],(n||"").endsWith(r[0])},$contains:function(t,n,r){return r=Array.isArray(r)?r:[r],0<=(n||"").indexOf(r[0])}}}),e.addOperators(e.OP_EXPRESSION,function(i){return{$eval:function(t,n,r){return o[n]||(o[n]=u.eval(n)),o[n](t)},$expr:function(t,n,r){return a[n]||(a[n]=u.expr(n)),a[n](t)},$keyval:function(t,n,r){return i.computeValue(t,n).reduce(function(t,n){return t[n[0]]=n[1]||"_",t},{})},$trim:function(t,n,r){for(var e=new Set((n.chars||"").split("")),u=i.computeValue(t,n.input).split("");e.has(u[0]);)u.shift();for(;e.has(u[u.length-1]);)u.pop();return u.join("")},$starts:function(t,n,r){return(i.computeValue(t,n[0])||"").startsWith(n[1])},$startsWidth:function(t,n,r){return(i.computeValue(t,n[0])||"").startsWith(n[1])},$ends:function(t,n,r){return(i.computeValue(t,n[0])||"").endsWith(n[1])},$endsWith:function(t,n,r){return(i.computeValue(t,n[0])||"").endsWith(n[1])},$contains:function(t,n,r){return 0<=(i.computeValue(t,n[0])||"").indexOf(n[1])}}})}catch(t){}n.exports=e},{"./expression":4,mingo:9}],7:[function(t,n,r){var e,u;e=this,u=function(){var s="millisecond",v="second",p="minute",d="hour",y="day",$="week",g="month",c="quarter",m="year",_="date",b="Invalid Date",o=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,x=/\[([^\]]+)]|Y{1,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,t={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("_")},i=function(t,n,r){var e=String(t);return!e||e.length>=n?t:""+Array(n+1-e.length).join(r)+t},n={s:i,z:function(t){var n=-t.utcOffset(),r=Math.abs(n),e=Math.floor(r/60),u=r%60;return(n<=0?"+":"-")+i(e,2,"0")+":"+i(u,2,"0")},m:function t(n,r){if(n.date()<r.date())return-t(r,n);var e=12*(r.year()-n.year())+(r.month()-n.month()),u=n.clone().add(e,g),i=r-u<0,o=n.clone().add(e+(i?-1:1),g);return+(-(e+(r-u)/(i?u-o:o-u))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:g,y:m,w:$,d:y,D:_,h:d,m:p,s:v,ms:s,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},a="en",f={};f[a]=t;var e=function(t){return t instanceof h},u=function(t,n,r){var e;if(!t)return a;if("string"==typeof t)f[t]&&(e=t),n&&(f[t]=n,e=t);else{var u=t.name;f[u]=t,e=u}return!r&&e&&(a=e),e||!r&&a},l=function(t,n){if(e(t))return t.clone();var r="object"==(void 0===n?"undefined":_typeof2(n))?n:{};return r.date=t,r.args=arguments,new h(r)},k=n;k.l=u,k.i=e,k.w=function(t,n){return l(t,{locale:n.$L,utc:n.$u,x:n.$x,$offset:n.$offset})};var h=function(){function t(t){this.$L=u(t.locale,null,!0),this.parse(t)}var n=t.prototype;return n.parse=function(t){this.$d=function(t){var n=t.date,r=t.utc;if(null===n)return new Date(NaN);if(k.u(n))return new Date;if(n instanceof Date)return new Date(n);if("string"==typeof n&&!/Z$/i.test(n)){var e=n.match(o);if(e){var u=e[2]-1||0,i=(e[7]||"0").substring(0,3);return r?new Date(Date.UTC(e[1],u,e[3]||1,e[4]||0,e[5]||0,e[6]||0,i)):new Date(e[1],u,e[3]||1,e[4]||0,e[5]||0,e[6]||0,i)}}return new Date(n)}(t),this.$x=t.x||{},this.init()},n.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()},n.$utils=function(){return k},n.isValid=function(){return!(this.$d.toString()===b)},n.isSame=function(t,n){var r=l(t);return this.startOf(n)<=r&&r<=this.endOf(n)},n.isAfter=function(t,n){return l(t)<this.startOf(n)},n.isBefore=function(t,n){return this.endOf(n)<l(t)},n.$g=function(t,n,r){return k.u(t)?this[n]:this.set(r,t)},n.unix=function(){return Math.floor(this.valueOf()/1e3)},n.valueOf=function(){return this.$d.getTime()},n.startOf=function(t,n){var e=this,u=!!k.u(n)||n,r=k.p(t),i=function(t,n){var r=k.w(e.$u?Date.UTC(e.$y,n,t):new Date(e.$y,n,t),e);return u?r:r.endOf(y)},o=function(t,n){return k.w(e.toDate()[t].apply(e.toDate("s"),(u?[0,0,0,0]:[23,59,59,999]).slice(n)),e)},a=this.$W,s=this.$M,c=this.$D,f="set"+(this.$u?"UTC":"");switch(r){case m:return u?i(1,0):i(31,11);case g:return u?i(1,s):i(0,s+1);case $:var l=this.$locale().weekStart||0,h=(a<l?a+7:a)-l;return i(u?c-h:c+(6-h),s);case y:case _:return o(f+"Hours",0);case d:return o(f+"Minutes",1);case p:return o(f+"Seconds",2);case v:return o(f+"Milliseconds",3);default:return this.clone()}},n.endOf=function(t){return this.startOf(t,!1)},n.$set=function(t,n){var r,e=k.p(t),u="set"+(this.$u?"UTC":""),i=(r={},r[y]=u+"Date",r[_]=u+"Date",r[g]=u+"Month",r[m]=u+"FullYear",r[d]=u+"Hours",r[p]=u+"Minutes",r[v]=u+"Seconds",r[s]=u+"Milliseconds",r)[e],o=e===y?this.$D+(n-this.$W):n;if(e===g||e===m){var a=this.clone().set(_,1);a.$d[i](o),a.init(),this.$d=a.set(_,Math.min(this.$D,a.daysInMonth())).$d}else i&&this.$d[i](o);return this.init(),this},n.set=function(t,n){return this.clone().$set(t,n)},n.get=function(t){return this[k.p(t)]()},n.add=function(r,t){var n,e=this;r=Number(r);var u=k.p(t),i=function(t){var n=l(e);return k.w(n.date(n.date()+Math.round(t*r)),e)};if(u===g)return this.set(g,this.$M+r);if(u===m)return this.set(m,this.$y+r);if(u===y)return i(1);if(u===$)return i(7);var o=(n={},n[p]=6e4,n[d]=36e5,n[v]=1e3,n)[u]||1,a=this.$d.getTime()+r*o;return k.w(a,this)},n.subtract=function(t,n){return this.add(-1*t,n)},n.format=function(t){var u=this;if(!this.isValid())return b;var i=t||"YYYY-MM-DDTHH:mm:ssZ",r=k.z(this),n=this.$locale(),e=this.$H,o=this.$m,a=this.$M,s=n.weekdays,c=n.months,f=function(t,n,r,e){return t&&(t[n]||t(u,i))||r[n].substr(0,e)},l=function(t){return k.s(e%12||12,t,"0")},h=n.meridiem||function(t,n,r){var e=t<12?"AM":"PM";return r?e.toLowerCase():e},v={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:k.s(a+1,2,"0"),MMM:f(n.monthsShort,a,c,3),MMMM:f(c,a),D:this.$D,DD:k.s(this.$D,2,"0"),d:String(this.$W),dd:f(n.weekdaysMin,this.$W,s,2),ddd:f(n.weekdaysShort,this.$W,s,3),dddd:s[this.$W],H:String(e),HH:k.s(e,2,"0"),h:l(1),hh:l(2),a:h(e,o,!0),A:h(e,o,!1),m:String(o),mm:k.s(o,2,"0"),s:String(this.$s),ss:k.s(this.$s,2,"0"),SSS:k.s(this.$ms,3,"0"),Z:r};return i.replace(x,function(t,n){return n||v[t]||r.replace(":","")})},n.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},n.diff=function(t,n,r){var e,u=k.p(n),i=l(t),o=6e4*(i.utcOffset()-this.utcOffset()),a=this-i,s=k.m(this,i);return s=(e={},e[m]=s/12,e[g]=s,e[c]=s/3,e[$]=(a-o)/6048e5,e[y]=(a-o)/864e5,e[d]=a/36e5,e[p]=a/6e4,e[v]=a/1e3,e)[u]||a,r?s:k.a(s)},n.daysInMonth=function(){return this.endOf(g).$D},n.$locale=function(){return f[this.$L]},n.locale=function(t,n){if(!t)return this.$L;var r=this.clone(),e=u(t,n,!0);return e&&(r.$L=e),r},n.clone=function(){return k.w(this.$d,this)},n.toDate=function(){return new Date(this.valueOf())},n.toJSON=function(){return this.isValid()?this.toISOString():null},n.toISOString=function(){return this.$d.toISOString()},n.toString=function(){return this.$d.toUTCString()},t}(),r=h.prototype;return l.prototype=r,[["$ms",s],["$s",v],["$m",p],["$H",d],["$W",y],["$M",g],["$y",m],["$D",_]].forEach(function(n){r[n[1]]=function(t){return this.$g(t,n[0],n[1])}}),l.extend=function(t,n){return t.$i||(t(n,h,l),t.$i=!0),l},l.locale=u,l.isDayjs=e,l.unix=function(t){return l(1e3*t)},l.en=f[a],l.Ls=f,l.p={},l},"object"==(void 0===r?"undefined":_typeof2(r))&&void 0!==n?n.exports=u():"function"==typeof define&&define.amd?define(u):(e="undefined"!=typeof globalThis?globalThis:e||self).dayjs=u()},{}],8:[function(t,n,r){var u=Object.prototype.hasOwnProperty,i=Object.prototype.toString,e=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===i.call(t)},h=function(t){if(!t||"[object Object]"!==i.call(t))return!1;var n,r=u.call(t,"constructor"),e=t.constructor&&t.constructor.prototype&&u.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!r&&!e)return!1;for(n in t);return void 0===n||u.call(t,n)},v=function(t,n){e&&"__proto__"===n.name?e(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},p=function(t,n){if("__proto__"===n){if(!u.call(t,n))return;if(o)return o(t,n).value}return t[n]};n.exports=function t(){var n,r,e,u,i,o,a=arguments[0],s=1,c=arguments.length,f=!1;for("boolean"==typeof a&&(f=a,a=arguments[1]||{},s=2),(null==a||"object"!==(void 0===a?"undefined":_typeof2(a))&&"function"!=typeof a)&&(a={});s<c;++s)if(null!=(n=arguments[s]))for(r in n)e=p(a,r),a!==(u=p(n,r))&&(f&&u&&(h(u)||(i=l(u)))?(o=i?(i=!1,e&&l(e)?e:[]):e&&h(e)?e:{},v(a,{name:r,newValue:t(f,o,u)})):void 0!==u&&v(a,{name:r,newValue:u}));return a}},{}],9:[function(t,n,r){var e,u;e=this,u=function(){function e(t){return(e="function"==typeof Symbol&&"symbol"===_typeof2(Symbol.iterator)?function(t){return void 0===t?"undefined":_typeof2(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":void 0===t?"undefined":_typeof2(t)})(t)}function o(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function u(t,n){for(var r=0;r<n.length;r++){var e=n[r];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function t(t,n,r){return n&&u(t.prototype,n),r&&u(t,r),t}function i(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var r=[],e=!0,u=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(e=(o=a.next()).done)&&(r.push(o.value),!n||r.length!==n);e=!0);}catch(t){u=!0,i=t}finally{try{e||null==a.return||a.return()}finally{if(u)throw i}}return r}(t,n)||function(t,n){if(!t)return;if("string"==typeof t)return a(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(t,n)}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,e=new Array(n);r<n;r++)e[r]=t[r];return e}var s="null",c="undefined",f="boolean",l="number",h="string",v="date",p="regexp",d="array",y="object",$="function",g=[s,c,f,l,h,v,p],m="expression",_="group",b="pipeline",x="projection",k="query",O=function(){};Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(t,n){if(null==this)throw new TypeError('"this" is null or not defined');var r=Object(this),e=r.length>>>0;if(0===e)return!1;var u,i,o=0|n,a=Math.max(0<=o?o:e-Math.abs(o),0);for(;a<e;){if((u=r[a])===(i=t)||"number"==typeof u&&"number"==typeof i&&isNaN(u)&&isNaN(i))return!0;a++}return!1}});var w=Array.prototype.push;function M(t,n){t||B(n)}function j(t){switch(E(t)){case d:return t.map(j);case y:return Z(t,j);default:return t}}function S(t){switch(E(t)){case d:return st([],t);case y:return Object.assign({},t);default:return t}}function A(t){return null===t?"Null":void 0===t?"Undefined":t.constructor.name}function E(t){return A(t).toLowerCase()}function N(t){return E(t)===f}function D(t){return E(t)===h}function I(t){return E(t)===l}var R=Array.isArray||function(t){return!!t&&t.constructor===Array};function T(t){return!!t&&t.constructor===Object}function L(t){return t===Object(t)}function P(t){return E(t)===v}function C(t){return E(t)===p}function r(t){return E(t)===$}function F(t){return null==t}function V(t){return null===t}function n(t){return void 0===t}function q(t,n){return t.includes(n)}function U(t,n){return!q(t,n)}function W(t){return!!t}function Y(t){return F(t)||R(t)&&0===t.length||T(t)&&0===J(t).length||!t}function H(t){return R(t)?t:[t]}function z(t,n){return t.hasOwnProperty(n)}function B(t){throw new Error(t)}var J=Object.keys;function X(t,n,r){if(n=n.bind(r),R(t))for(var e=0,u=t.length;e<u&&!1!==n(t[e],e,t);e++);else for(var i in t)if(t.hasOwnProperty(i)&&!1===n(t[i],i,t))break}function Z(t,n,r){n=n.bind(r);for(var e={},u=J(t),i=0;i<u.length;i++){var o=u[i];e[o]=n(t[o],o)}return e}function Q(n,r){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};if(n===O)return r;if(r===O)return n;var t=[n,r];if(!t.every(T)&&!t.every(R))throw Error("mismatched types. must both be array or object");if(e.flatten=e.flatten||!1,R(n))if(e.flatten){for(var u=0,i=0;u<n.length&&i<r.length;)n[u]=Q(n[u++],r[i++],e);for(;i<r.length;)n.push(r[i++])}else w.apply(n,r);else Object.keys(r).forEach(function(t){n.hasOwnProperty(t)?n[t]=Q(n[t],r[t],e):n[t]=r[t]});return n}function K(r,e,u){return R(r)?r.reduce(e,u):(X(r,function(t,n){return u=e(u,t,n,r)}),u)}function G(t,n){var r=n.map(ut);return t.filter(function(t){return q(r,ut(t))})}function tt(t){var n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1,i=[];return function t(n,r){for(var e=0,u=n.length;e<u;e++)R(n[e])&&(0<r||r<0)?t(n[e],Math.max(-1,r-1)):i.push(n[e])}(t,n),i}function nt(t,n){for(var r=[t],e=[n];0<r.length;)if((t=r.pop())!==(n=e.pop())){var u=E(t);if(u!==E(n)||u===$)return!1;switch(u){case d:if(t.length!==n.length)return!1;st(r,t),st(e,n);break;case y:var i=J(t),o=J(n);if(i.length!==o.length)return!1;i.sort(),o.sort();for(var a=0,s=i.length;a<s;a++){var c=i[a];if(c!==o[a])return!1;r.push(t[c]),e.push(n[c])}break;default:if(et(t)!==et(n))return!1}}return 0===r.length}function rt(t){var r={},e=[];return X(t,function(t){var n=ut(t);z(r,n)||(e.push(t),r[n]=0)}),e}function et(n){var t=E(n);switch(t){case f:case l:case p:return n.toString();case h:return JSON.stringify(n);case v:return n.toISOString();case s:case c:return t;case d:return"["+n.map(et)+"]";default:var r=t===y?"":"".concat(A(n)),e=J(n);return e.sort(),"".concat(r,"{")+e.map(function(t){return"".concat(et(t),":").concat(et(n[t]))})+"}"}}function ut(t){if(F(t))return null;for(var n=0,r=et(t),e=r.length;e;)n=(n<<5)-n^r.charCodeAt(--e);return n>>>0}function it(t,n){return t<n?-1:n<t?1:0}function ot(t,n,r){var e=[],u=[],i={};if(r=r||it,Y(t))return t;for(var o=0;o<t.length;o++){var a=t[o],s=n(a,o);F(s)?u.push(a):(i[s]?i[s].push(a):i[s]=[a],e.push(s))}e.sort(r);for(var c=0;c<e.length;c++)st(u,i[e[c]]);return u}function at(t,u){var i={keys:[],groups:[]},o={};return X(t,function(t){var n=u(t),r=ut(n),e=-1;void 0===o[r]&&(e=i.keys.length,o[r]=e,i.keys.push(n),i.groups.push([])),e=o[r],i.groups[e].push(t)}),i}function st(t,n){return w.apply(t,n),t}function ct(t,n){return L(t)?t[n]:void 0}function ft(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o=0;return r.meta=r.meta||!1,t=q(g,E(t))?t:function e(t,u){for(var n=t,r=0;r<u.length;r++){var i=u[r];if(null===i.match(/^\d+$/)&&R(n)){if(0===r&&0<o)break;o+=1,u=u.slice(r),n=K(n,function(t,n){var r=e(n,u);return void 0!==r&&t.push(r),t},[]);break}if(void 0===(n=ct(n,i)))break}return n}(t,n.split(".")),r.meta?{result:t,depth:o}:t}function lt(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.preserveMissingValues=r.preserveMissingValues||!1;var e,u,i=n.split("."),o=i[0],a=1===i.length||i.slice(1).join("."),s=null!==o.match(/^\d+$/),c=1<i.length;try{R(t)?s?(e=ct(t,Number(o)),c&&(e=lt(e,a,r)),e=[e]):(e=[],X(t,function(t){u=lt(t,n,r),r.preserveMissingValues?(void 0===u&&(u=O),e.push(u)):void 0!==u&&e.push(u)})):(u=ct(t,o),c&&(u=lt(u,a,r)),M(void 0!==u),(e={})[o]=u)}catch(t){e=void 0}return e}function ht(t){if(R(t))for(var n=t.length-1;0<=n;n--)t[n]===O?t.splice(n,1):ht(t[n]);else if(T(t))for(var r in t)t.hasOwnProperty(r)&&ht(t[r]);return t}function vt(t,n,r){var e=3<arguments.length&&void 0!==arguments[3]&&arguments[3],u=n.split("."),i=u[0],o=1===u.length||u.slice(1).join(".");1===u.length?r(t,i):(!0===e&&F(t[i])&&(t[i]={}),vt(t[i],o,r,e))}function pt(t,n,r){vt(t,n,function(t,n){t[n]=r},!0)}function dt(t,n){vt(t,n,function(t,n){R(t)&&/^\d+$/.test(n)?t.splice(parseInt(n),1):T(t)&&delete t[n]})}function yt(t){return!!t&&"$"===t[0]}function $t(t){if(q(g,E(t)))return C(t)?{$regex:t}:{$eq:t};if(L(t)){var n=J(t);if(!n.some(yt))return{$eq:t};if(q(n,"$regex")){var r=t.$regex,e=t.$options||"",u="";D(r)&&(u+=r.ignoreCase||0<=e.indexOf("i")?"i":"",u+=r.multiline||0<=e.indexOf("m")?"m":"",u+=r.global||0<=e.indexOf("g")?"g":"",r=new RegExp(r,u)),t.$regex=r,delete t.$options}}return t}function gt(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;return F(r)?n<0?(n=Math.max(0,t.length+n),r=t.length-n+1):(r=n,n=0):(n<0&&(n=Math.max(0,t.length+n)),M(0<r,"Invalid argument value for $slice operator. Limit must be a positive number"),r+=n),t.slice(n,r)}function mt(t,n){var r=K(t,function(t,n){return t+n},0),e=t.length||1,u=n?1:0,i=r/e;return Math.sqrt(K(t,function(t,n){return t+Math.pow(n-i,2)},0)/(e-u))}var _t=function(){return Object.assign({computeValue:At,ops:jt},{assert:M,clone:S,cloneDeep:j,each:X,err:B,hashCode:ut,getType:A,has:z,includes:q.bind(null),isArray:R,isBoolean:N,isDate:P,isEmpty:Y,isEqual:nt,isFunction:r,isNil:F,isNull:V,isNumber:I,isObject:T,isRegExp:C,isString:D,isUndefined:n,keys:J,reduce:K,resolve:ft,resolveObj:lt})},bt={key:"_id"};var xt={$$ROOT:function(t,n,r){return r.root},$$CURRENT:function(t,n,r){return t},$$REMOVE:function(t,n,r){}},kt={$$KEEP:function(t){return t},$$PRUNE:function(){},$$DESCEND:function(r,e,u){return z(e,"$cond")&&X(r,function(t,n){L(t)&&(R(t)?(i=[],X(t,function(t){T(t)&&(t=Et(t,e,u)),F(t)||i.push(t)})):i=Et(t,e,u),F(i)?delete r[n]:r[n]=i)}),r;var i}},Ot=J(xt),wt=J(kt);function Mt(){return bt.key}function jt(){return K(Array.prototype.slice.call(arguments),function(t,n){return st(t,J(Gn[n]))},[])}function St(r,t,e){if(z(Gn[_],t))return Gn[_][t](r,e);if(T(e)){var u={};return X(e,function(t,n){if(u[n]=St(r,n,e[n]),z(Gn[_],n))return u=u[n],M(1===J(e).length,"Invalid $group expression '"+JSON.stringify(e)+"'"),!1}),u}}function At(r,e){var t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null,u=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};if(u.root=u.root||r,z(Gn[m],t))return Gn[m][t](r,e,u);if(z(Gn[_],t))return r=At(r,e,null,u),M(R(r),t+" expression must resolve to an array"),Gn[_][t](r,null,u);if(D(e)&&0<e.length&&"$"===e[0]){if(q(Ot,e))return xt[e](r,null,u);if(q(wt,e))return e;var n=Ot.filter(function(t){return 0===e.indexOf(t+".")});return 1===n.length&&("$$ROOT"===(n=n[0])&&(r=u.root),e=e.substr(n.length)),ft(r,e.slice(1))}switch(E(e)){case d:return e.map(function(t){return At(r,t)});case y:var i={};return X(e,function(t,n){if(i[n]=At(r,t,n,u),[m,_].some(function(t){return z(Gn[t],n)}))return M(1===J(e).length,"Invalid aggregation expression '"+JSON.stringify(e)+"'"),i=i[n],!1}),i;default:return e}}function Et(t,n){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};r.root=r.root||t;var e=At(t,n,null,r);return q(wt,e)?kt[e](t,n,r):e}function Nt(t,n,r){n=n||0;var e=Math.abs(t)===t?1:-1;t=Math.abs(t);var u=Math.trunc(t),i=t-u;if(0===n){var o=Math.trunc(10*i);r&&1==(1&u)&&5<=o&&u++}else if(0<n){var a=Math.pow(10,n),s=Math.trunc(i*a),c=Math.trunc(i*a*10)%10;r&&5<c&&(s+=1),u+=s/a}else if(n<0){var f=Math.pow(10,-1*n),l=u%f;if(u=Math.max(0,u-l),r&&-1===e){for(;10<l;)l-=l%10;0<u&&5<=l&&(u+=f)}}return u*e}function Dt(t){return t instanceof Vt?t:new Vt(t)}function It(t){return!!t&&"object"===e(t)&&Rt(t.next)}function Rt(t){return!!t&&"function"==typeof t}Dt.isIterator=It;var Tt=new Error,Lt=1,Pt=2,Ct=3,Ft=4;var Vt=function(){function i(t){if(o(this,i),this.__iteratees=[],this.__first=!1,this.__done=!1,this.__buf=[],Rt(t)&&(t={next:t}),It(t)){var n=t;t=function(){var t=n.next();if(t.done)throw Tt;return t.value}}else if(Array.isArray(t)){var r=t,e=r.length,u=0;t=function(){if(u<e)return r[u++];throw Tt}}else if(!Rt(t))throw new Error("Source is not iterable. Must be Array, Function or Object{next:Function}");var f,l,h,v,p,d;this.next=(f=t,l=this.__iteratees,h=this.__buf,v=!1,p=-1,d=0,function(t){t=t===h;try{t:for(;!v;){var n=f();p++;for(var r=-1,e=l.length,u=!1;++r<e;){var i=l[r],o=i.func;switch(i.type){case Lt:n=o(n,p);break;case Pt:if(!o(n,p))continue t;break;case Ct:--i.func,i.func||(u=!0);break;case Ft:--i.func,i.func||(s=r,c=(a=l).slice(s+1),a.splice(s),Array.prototype.push.apply(a,c));continue t;default:break t}}if(v=u,!t)return{value:n,done:!1};h[d++]=n}}catch(t){if(t!==Tt)throw t}var a,s,c;return{done:v=!0}})}return t(i,[{key:"_validate",value:function(){if(this.__first)throw new Error("Cannot add iteratee/transform after `first()`")}},{key:"_push",value:function(t){return this._validate(),this.__iteratees.push(t),this}},{key:"map",value:function(t){return this._push({type:Lt,func:t})}},{key:"filter",value:function(t){return this._push({type:Pt,func:t})}},{key:"take",value:function(t){return 0<t?this._push({type:Ct,func:t}):this}},{key:"drop",value:function(t){return 0<t?this._push({type:Ft,func:t}):this}},{key:"transform",value:function(t){this._validate();var n,r=this;return Dt(function(){return n||(n=Dt(t(r.value()))),n.next()})}},{key:"first",value:function(){return this.take(1),this.__first=!0,this}},{key:"value",value:function(){return this.__done||(this.__done=this.next(this.__buf).done),this.__first?this.__buf[0]:this.__buf}},{key:"each",value:function(t){for(;;){var n=this.next();if(n.done)break;if(!1===t(n.value))return!1}return!0}},{key:"reduce",value:function(t,n){var r=this.next(),e=0;for(void 0!==n||r.done||(n=r.value,r=this.next(),e++);!r.done;)n=t(n,r.value,e++),r=this.next();return n}},{key:"size",value:function(){return this.reduce(function(t,n){return++t},0)}}]),i}();"function"==typeof Symbol&&(Vt.prototype[Symbol.iterator]=function(){return this});var qt=function(){function r(t,n){o(this,r),this.__operators=t,this.__options=n}return t(r,[{key:"stream",value:function(r,e){var u=this;r=Dt(r);var i=Gn[b];return Y(this.__operators)||X(this.__operators,function(t){var n=J(t);M(1===n.length&&q(jt(b),n[0]),"invalid aggregation operator ".concat(n)),n=n[0],r=e&&e instanceof Yt?i[n].call(e,r,t[n],u.__options):i[n](r,t[n],u.__options)}),r}},{key:"run",value:function(t,n){return this.stream(t,n).value()}}]),r}();function Ut(t,n,r){return M(R(n),"Aggregation pipeline must be an array"),new qt(n,r).run(t)}var Wt=function(){function e(t,n,r){o(this,e),this.__filterFn=n.test.bind(n),this.__query=n,this.__source=t,this.__projection=r||n.__projection,this.__operators=[],this.__result=null,this.__stack=[],this.__options={}}return t(e,[{key:"_fetch",value:function(){return this.__result||(T(this.__projection)&&this.__operators.push({$project:this.__projection}),this.__result=Dt(this.__source).filter(this.__filterFn),0<this.__operators.length&&(this.__result=new qt(this.__operators,this.__options).stream(this.__result,this.__query))),this.__result}},{key:"all",value:function(){return this._fetch().value()}},{key:"count",value:function(){return this.all().length}},{key:"skip",value:function(t){return this.__operators.push({$skip:t}),this}},{key:"limit",value:function(t){return this.__operators.push({$limit:t}),this}},{key:"sort",value:function(t){return this.__operators.push({$sort:t}),this}},{key:"collation",value:function(t){return this.__options.collation=t,this}},{key:"next",value:function(){if(this.__stack){if(0<this.__stack.length)return this.__stack.pop();var t=this._fetch().next();if(!t.done)return t.value;this.__stack=null}}},{key:"hasNext",value:function(){if(!this.__stack)return!1;if(0<this.__stack.length)return!0;var t=this._fetch().next();return t.done?this.__stack=null:this.__stack.push(t.value),!!this.__stack}},{key:"map",value:function(t){return this._fetch().map(t).value()}},{key:"forEach",value:function(t){this._fetch().each(t)}}]),e}();"function"==typeof Symbol&&(Wt.prototype[Symbol.iterator]=function(){return this._fetch()});var Yt=function(){function r(t,n){o(this,r),this.__criteria=t,this.__projection=n||{},this.__compiled=[],this._compile()}return t(r,[{key:"_compile",value:function(){var n,e=this;M(T(this.__criteria),"query criteria must be an object"),X(this.__criteria,function(t,r){"$where"===r?n={field:r,expr:t}:"$expr"===r?e._processOperator(r,r,t):q(["$and","$or","$nor"],r)?e._processOperator(r,r,t):(M(!yt(r),"unknown top level operator: ".concat(r)),X(t=$t(t),function(t,n){e._processOperator(r,n,t)})),T(n)&&e._processOperator(n.field,n.field,n.expr)})}},{key:"_processOperator",value:function(t,n,r){M(z(Gn[k],n),"invalid query operator ".concat(n," detected")),this.__compiled.push(Gn[k][n](t,r))}},{key:"test",value:function(t){for(var n=0,r=this.__compiled.length;n<r;n++)if(!this.__compiled[n](t))return!1;return!0}},{key:"find",value:function(t,n){return new Wt(t,this,n)}},{key:"remove",value:function(t){var r=this;return K(t,function(t,n){return r.test(n)||t.push(n),t},[])}}]),r}();function Ht(t,n){if(nt(t,n))return!0;if(F(t)&&F(n))return!0;if(R(t)){var r=nt.bind(null,n);return t.some(r)||tt(t,1).some(r)}return!1}function zt(t,n){return!Ht(t,n)}function Bt(t,n){return F(t)?n.some(V):0<G(H(t),n).length}function Jt(t,n){return!Bt(t,n)}function Xt(t,n){return tn(t,n,function(t,n){return t<n})}function Zt(t,n){return tn(t,n,function(t,n){return t<=n})}function Qt(t,n){return tn(t,n,function(t,n){return n<t})}function Kt(t,n){return tn(t,n,function(t,n){return n<=t})}function Gt(t,n){if(R(t)&&!Y(t)){var r=function(t){return t},e=n;J(n).every(yt)&&(e={temp:n},r=function(t){return{temp:t}});for(var u=new Yt(e),i=0,o=t.length;i<o;i++)if(u.test(r(t[i])))return!0}return!1}function tn(t,n,r){return H(t).some(function(t){return A(t)===A(n)&&r(t,n)})}function nn(e){return function(t,n){var r=At(t,n);return e(r[0],r[1])}}var rn=nn(Ht),en=nn(zt),un=nn(Qt),on=nn(Xt),an=nn(Kt),sn=nn(Zt),cn=nn(Jt);function fn(t,n){var r=At(t,n),e=new Date(r.getFullYear(),0,0),u=r-e;return Math.round(u/864e5)}function ln(t,n){return At(t,n).getDate()}function hn(t,n){return At(t,n).getDay()+1}function vn(t,n){return At(t,n).getFullYear()}function pn(t,n){return At(t,n).getMonth()+1}function dn(t,n){var r=At(t,n);(r=new Date(+r)).setHours(0,0,0),r.setDate(r.getDate()+4-(r.getDay()||7));var e=new Date(r.getFullYear(),0,1);return Math.floor(((r-e)/864e5+1)/7)}function yn(t,n){return At(t,n).getUTCHours()}function $n(t,n){return At(t,n).getMinutes()}function gn(t,n){return At(t,n).getSeconds()}function mn(t,n){return At(t,n).getMilliseconds()}var _n={"%Y":[vn,4],"%m":[pn,2],"%d":[ln,2],"%H":[yn,2],"%M":[$n,2],"%S":[gn,2],"%L":[mn,3],"%j":[fn,3],"%w":[hn,1],"%U":[dn,2],"%%":"%"};function bn(t,n){var r=At(t,n),e=r[0],u=r[1],i=r[2];return D(e)?u<0?"":i<0?e.substr(u):e.substr(u,i):""}var xn=[192,224,240];function kn(t){if(t<128)return[t];for(var n=(t<2048?1:t<65536&&2)||3,r=[(t>>6*n)+xn[n-1]];0<n;)r.push(128|t>>6*--n&63);return r}var On=Object.freeze({__proto__:null,$abs:function(t,n){var r=At(t,n);return null==r?null:Math.abs(r)},$add:function(t,n){var r=At(t,n),e=!1,u=K(r,function(t,n){return P(n)&&(M(!e,"'$add' can only have one date value"),e=!0,n=n.getTime()),t+=n},0);return e?new Date(u):u},$ceil:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$ceil expression must resolve to a number."),Math.ceil(r))},$divide:function(t,n){var r=At(t,n);return r[0]/r[1]},$exp:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$exp expression must resolve to a number."),Math.exp(r))},$floor:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$floor expression must resolve to a number."),Math.floor(r))},$ln:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$ln expression must resolve to a number."),Math.log(r))},$log:function(t,n){var r=At(t,n),e="$log expression must resolve to array(2) of numbers";return M(R(r)&&2===r.length,e),r.some(F)?null:(M(r.some(isNaN)||r.every(I),e),Math.log10(r[0])/Math.log10(r[1]))},$log10:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)||isNaN(r),"$log10 expression must resolve to a number."),Math.log10(r))},$mod:function(t,n){var r=At(t,n);return r[0]%r[1]},$multiply:function(t,n){return K(At(t,n),function(t,n){return t*n},1)},$pow:function(t,n){var r=At(t,n);return M(R(r)&&2===r.length&&r.every(I),"$pow expression must resolve to array(2) of numbers"),M(!(0===r[0]&&r[1]<0),"$pow cannot raise 0 to a negative exponent"),Math.pow(r[0],r[1])},$round:function(t,n){var r=At(t,n),e=r[0],u=r[1];return F(e)||isNaN(e)||Math.abs(e)===1/0?e:(M(I(e),"$round expression must resolve to a number."),Nt(e,u,!0))},$sqrt:function(t,n){var r=At(t,n);return F(r)?null:(M(I(r)&&0<r||isNaN(r),"$sqrt expression must resolve to non-negative number."),Math.sqrt(r))},$subtract:function(t,n){var r=At(t,n);return r[0]-r[1]},$trunc:function(t,n){var r=At(t,n),e=r[0],u=r[1];return F(e)||isNaN(e)||Math.abs(e)===1/0?e:(M(I(e),"$trunc expression must resolve to a number."),M(F(u)||I(u)&&-20<u&&u<100,"$trunc expression has invalid place"),Nt(e,u,!1))},$arrayElemAt:function(t,n){var r=At(t,n);M(R(r)&&2===r.length,"$arrayElemAt expression must resolve to array(2)"),M(R(r[0]),"First operand to $arrayElemAt must resolve to an array"),M(I(r[1]),"Second operand to $arrayElemAt must resolve to an integer");var e=r[1];return r=r[0],e<0&&Math.abs(e)<=r.length?r[e+r.length]:0<=e&&e<r.length?r[e]:void 0},$arrayToObject:function(t,n){var r=At(t,n);return M(R(r),"$arrayToObject expression must resolve to an array"),K(r,function(t,n){return R(n)&&2==n.length?t[n[0]]=n[1]:(M(T(n)&&z(n,"k")&&z(n,"v"),"$arrayToObject expression is invalid."),t[n.k]=n.v),t},{})},$concatArrays:function(t,n){var r=At(t,n,null);return M(R(r),"$concatArrays must resolve to an array"),r.some(F)?null:r.reduce(function(t,n){return st(t,n)},[])},$filter:function(t,n){var r=At(t,n.input),e=n.as,u=n.cond;return M(R(r),"$filter 'input' expression must resolve to an array"),r.filter(function(t){var n={};return n["$"+e]=t,!0===At(n,u)})},$in:function(t,n){var r=At(t,n[0]),e=At(t,n[1]);return M(R(e),"$in second argument must be an array"),e.some(nt.bind(null,r))},$indexOfArray:function(t,n){var r=At(t,n);if(F(r))return null;var e=r[0],u=r[1];if(F(e))return null;M(R(e),"$indexOfArray expression must resolve to an array.");var i=r[2]||0,o=r[3];return F(o)&&(o=e.length),o<i?-1:(M(0<=i&&0<=o,"$indexOfArray expression is invalid"),(0<i||o<e.length)&&(e=e.slice(i,o)),e.findIndex(nt.bind(null,u))+i)},$isArray:function(t,n){return R(At(t,n[0]))},$map:function(n,t){var r=At(n,t.input);M(R(r),"$map 'input' expression must resolve to an array");var e=t.as,u=t.in,i="$"+e;return r.map(function(t){return n[i]=t,At(n,u)})},$objectToArray:function(t,n){var r=At(t,n);M(T(r),"$objectToArray expression must resolve to an object");var e=[];return X(r,function(t,n){return e.push({k:n,v:t})}),e},$range:function(t,n){for(var r=At(t,n),e=r[0],u=r[1],i=r[2]||1,o=[];e<u&&0<i||u<e&&i<0;)o.push(e),e+=i;return o},$reduce:function(t,n){var r=At(t,n.input),e=At(t,n.initialValue),u=n.in;return F(r)?null:(M(R(r),"$reduce 'input' expression must resolve to an array"),K(r,function(t,n){return At({$value:t,$this:n},u)},e))},$reverseArray:function(t,n){var r=At(t,n);if(F(r))return null;M(R(r),"$reverseArray expression must resolve to an array");var e=[];return st(e,r),e.reverse(),e},$size:function(t,n){var r=At(t,n);return R(r)?r.length:void 0},$slice:function(t,n){var r=At(t,n);return gt(r[0],r[1],r[2])},$zip:function(t,n){var e=At(t,n.inputs),r=n.useLongestLength||!1;M(R(e),"'inputs' expression must resolve to an array"),M(N(r),"'useLongestLength' must be a boolean"),R(n.defaults)&&M(W(r),"'useLongestLength' must be set to true to use 'defaults'");for(var u=0,i=0,o=e.length;i<o;i++){var a=e[i];if(F(a))return null;M(R(a),"'inputs' expression values must resolve to an array or null"),u=r?Math.max(u,a.length):Math.min(u||a.length,a.length)}for(var s=[],c=n.defaults||[],f=function(r){var t=e.map(function(t,n){return F(t[r])?c[n]||null:t[r]});s.push(t)},l=0;l<u;l++)f(l);return s},$mergeObjects:function(t,n){var r=At(t,n);return R(r)?K(r,function(t,n){return Object.assign(t,n)},{}):{}},$and:function(t,n){var r=At(t,n);return W(r)&&r.every(W)},$or:function(t,n){var r=At(t,n);return W(r)&&r.some(W)},$not:function(t,n){return!At(t,n[0])},$eq:rn,$ne:en,$gt:un,$lt:on,$gte:an,$lte:sn,$nin:cn,$cmp:function(t,n){var r=At(t,n);return r[0]>r[1]?1:r[0]<r[1]?-1:0},$cond:function(t,n){var r,e,u,i="$cond: invalid arguments";return u=R(n)?(M(3===n.length,i),r=n[0],e=n[1],n[2]):(M(T(n),i),r=n.if,e=n.then,n.else),At(t,At(t,r)?e:u)},$switch:function(n,t){var r="Invalid arguments for $switch operator";M(t.branches,r);var e=t.branches.find(function(t){return M(t.case&&t.then,r),At(n,t.case)});return e?At(n,e.then):(M(t.default,r),At(n,t.default))},$ifNull:function(t,n){M(R(n)&&2===n.length,"$ifNull expression must resolve to array(2)");var r=At(t,n);return F(r[0])?r[1]:r[0]},$dayOfYear:fn,$dayOfMonth:ln,$dayOfWeek:hn,$year:vn,$month:pn,$week:dn,$hour:yn,$minute:$n,$second:gn,$millisecond:mn,$dateToString:function(t,n){for(var r,e,u=n.format,i=At(t,n.date),o=u.match(/(%%|%Y|%m|%d|%H|%M|%S|%L|%j|%w|%U)/g),a=0,s=o.length;a<s;a++){var c=_n[o[a]],f=c;if(R(c)){var l=c[0],h=c[1];r=l(t,i),e=h,f=new Array(Math.max(e-String(r).length+1,0)).join("0")+r}u=u.replace(o[a],f)}return u},$literal:function(t,n){return n},$setEquals:function(t,n){var r=At(t,n),e=rt(r[0]),u=rt(r[1]);return e.length===u.length&&e.length===G(e,u).length},$setIntersection:function(t,n){var r=At(t,n);return G(r[0],r[1])},$setDifference:function(t,n){var r=At(t,n);return r[0].filter(U.bind(null,r[1]))},$setUnion:function(t,n){var r,e,u=At(t,n);return r=u[0],e=u[1],st(st([],r),e.filter(U.bind(null,r)))},$setIsSubset:function(t,n){var r=At(t,n);return G(r[0],r[1]).length===r[0].length},$anyElementTrue:function(t,n){return At(t,n)[0].some(W)},$allElementsTrue:function(t,n){return At(t,n)[0].every(W)},$concat:function(t,n){var r=At(t,n);return[null,void 0].some(q.bind(null,r))?null:r.join("")},$indexOfBytes:function(t,n){var r=At(t,n),e="$indexOfBytes expression resolves to invalid an argument";if(F(r[0]))return null;M(D(r[0])&&D(r[1]),e);var u=r[0],i=r[1],o=r[2],a=r[3],s=F(o)||I(o)&&0<=o&&Math.round(o)===o;if(M(s=s&&(F(a)||I(a)&&0<=a&&Math.round(a)===a),e),o=o||0,(a=a||u.length)<o)return-1;var c=u.substring(o,a).indexOf(i);return-1<c?c+o:c},$split:function(t,n){var r=At(t,n);return F(r[0])?null:(M(r.every(D),"$split expression must result to array(2) of strings"),r[0].split(r[1]))},$strLenBytes:function(t,n){return~-encodeURI(At(t,n)).split(/%..|./).length},$strLenCP:function(t,n){return At(t,n).length},$strcasecmp:function(t,n){var r=At(t,n),e=r[0],u=r[1];return nt(e,u)||r.every(F)?0:(M(r.every(D),"$strcasecmp must resolve to array(2) of strings"),e=e.toUpperCase(),((u=u.toUpperCase())<e?1:e<u&&-1)||0)},$substrBytes:function(t,n){var r=At(t,n),e=r[0],u=r[1],i=r[2];M(D(e)&&I(u)&&0<=u&&I(i)&&0<=i,"$substrBytes: invalid arguments");for(var o=function(t){for(var n=[],r=0,e=t.length;r<e;r++)n.push(kn(t.codePointAt(r)));return n}(e),a=[],s=0,c=0;c<o.length;c++)a.push(s),s+=o[c].length;var f=a.indexOf(u),l=a.indexOf(u+i);return M(-1<f&&-1<l,"$substrBytes: invalid range, start or end index is a UTF-8 continuation byte."),e.substring(f,l)},$substr:bn,$substrCP:function(t,n){return bn(t,n)},$toLower:function(t,n){var r=At(t,n);return Y(r)?"":r.toLowerCase()},$toUpper:function(t,n){var r=At(t,n);return Y(r)?"":r.toUpperCase()},$let:function(r,t){var e=t.vars,n=t.in;return X(J(e),function(t){var n=At(r,e[t]);r["$"+t]=n}),At(r,n)}});function wn(t,n){return F(n)?t:t.map(function(t){return At(t,n)})}var Mn=Object.freeze({__proto__:null,$addToSet:function(t,n){return rt(wn(t,n))},$avg:function(t,n){var r=wn(t,n).filter(I);return K(r,function(t,n){return t+n},0)/(r.length||1)},$first:function(t,n){return 0<t.length?At(t[0],n):void 0},$last:function(t,n){return 0<t.length?At(t[t.length-1],n):void 0},$max:function(t,n){return K(wn(t,n),function(t,n){return F(t)||t<n?n:t},void 0)},$mergeObjects:function(t,r){return K(t,function(t,n){return Object.assign(t,At(n,r))},{})},$min:function(t,n){return K(wn(t,n),function(t,n){return F(t)||n<t?n:t},void 0)},$push:wn,$stdDevPop:function(t,n){return mt(wn(t,n).filter(I),!1)},$stdDevSamp:function(t,n){return mt(wn(t,n).filter(I),!0)},$sum:function(t,n){return R(t)?I(n)?t.length*n:K(wn(t,n).filter(I),function(t,n){return t+n},0):0}});function jn(t,u,n){var i=J(u);return 0===i.length?t:t.map(function(r){var e=j(r);return X(i,function(t){var n=At(r,u[t]);pt(e,t,n)}),e})}var Sn=jn;function An(t,i,n){var o=Mt(),r=i[o];return t.transform(function(t){var e=at(t,function(t){return At(t,r,r)});delete(i=S(i))[o];var u=-1,n=e.keys.length;return function(){if(++u===n)return{done:!0};var t=e.keys[u],r={};return void 0!==t&&(r[o]=t),X(i,function(t,n){r[n]=St(e.groups[u],n,t)}),{value:r,done:!1}}})}function En(t){var r=Mt(),e=[!1,!1];X(t,function(t,n){n!==r&&(0===t||!1===t?e[0]=!0:1!==t&&!0!==t||(e[1]=!0),M(!(e[0]&&e[1]),"Projection cannot have a mix of inclusion and exclusion."))})}function Nn(t,i,n){if(Y(i)||!T(i))return t;var o=it,r=(n=n||{}).collation;return T(r)&&D(r.locale)&&(o=function(t){var n={sensitivity:Dn[t.strength||3],caseFirst:"off"===t.caseFirst?"false":t.caseFirst||"false",numeric:t.numericOrdering||!1,ignorePunctuation:"shifted"===t.alternate};!0===(t.caseLevel||!1)&&("base"===n.sensitivity&&(n.sensitivity="case"),"accent"===n.sensitivity&&(n.sensitivity="variant"));var e=new Intl.Collator(t.locale,n);return function(t,n){if(!D(t)||!D(n))return it(t,n);var r=e.compare(t,n);return r<0?-1:0<r?1:0}}(r)),t.transform(function(u){return X(J(i).reverse(),function(n){var r=at(u,function(t){return ft(t,n)}),e={},t=ot(r.keys,function(t,n){return e[t]=n,t},o);-1===i[n]&&t.reverse(),u=[],X(t,function(t){return st(u,r.groups[e[t]])})}),u})}var Dn={1:"base",2:"accent",3:"variant"};var In=Object.freeze({__proto__:null,$addFields:jn,$set:Sn,$bucket:function(t,u,n){var i=u.boundaries,o=u.default,a=i[0],s=i[i.length-1],r=u.output||{count:{$sum:1}};M(2<i.length,"$bucket 'boundaries' expression must have at least 3 elements");for(var e=A(a),c=0,f=i.length-1;c<f;c++)M(e===A(i[c+1]),"$bucket 'boundaries' must all be of the same type"),M(i[c]<i[c+1],"$bucket 'boundaries' must be sorted in ascending order");!F(o)&&A(u.default)===A(a)&&M(a>u.default||s<u.default,"$bucket 'default' expression must be out of boundaries range");var l={};X(i,function(t){return l[t]=[]}),F(o)||(l[o]=[]);var h=!1;return Dt(function(){return h||(t.each(function(t){var n=At(t,u.groupBy);if(F(n)||n<a||s<=n)M(!F(o),"$bucket require a default for out of range values"),l[o].push(t);else{M(a<=n&&n<s,"$bucket 'groupBy' expression must resolve to a value in range of boundaries");var r=function(t,n){for(var r=0,e=t.length-1;r<=e;){var u=Math.round(r+(e-r)/2);if(n<t[u])e=u-1;else{if(!(n>t[u]))return u;r=u+1}}return r}(i,n),e=i[Math.max(0,r-1)];l[e].push(t)}}),i.pop(),F(o)||i.push(o),h=Dt(i).map(function(t){var n=St(l[t],null,r);return Object.assign(n,{_id:t})})),h.next()})},$bucketAuto:function(t,n,r){var d=n.output||{count:{$sum:1}},y=n.groupBy,$=n.buckets;return M(0<$,"The $bucketAuto 'buckets' field must be greater than 0, but found: "+$),t.transform(function(t){for(var n=Math.max(1,Math.round(t.length/$)),r=function(u){var i,o=this;return i={},function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ut(n);return z(i,e)||(i[e]=u.apply(o,n)),i[e]}}(At),e={},u=[],i=ot(t,function(t){var n=r(t,y);return F(n)?u.push(t):(e[n]||(e[n]=[]),e[n].push(t)),n}),o=Mt(),a=[],s=0,c=0,f=i.length;c<$&&s<f;c++){for(var l={},h=[],v=0;v<n&&s<f;v++){var p=r(i[s],y);F(p)&&(p=null),st(h,F(p)?u:e[p]),s+=F(p)?u.length:e[p].length,z(l,"min")||(l.min=p),0<a.length&&(a[a.length-1][o].max=l.min)}c==$-1&&st(h,i.slice(s)),a.push(Object.assign(St(h,null,d),{_id:l}))}return 0<a.length&&(a[a.length-1][o].max=r(i[i.length-1],y)),a})},$count:function(n,r,t){return M(D(r)&&""!==r.trim()&&-1===r.indexOf(".")&&"$"!==r.trim()[0],"Invalid expression value for $count"),Dt(function(){var t={};return t[r]=n.size(),{value:t,done:!1}}).first()},$facet:function(t,r,n){return t.transform(function(n){return[Z(r,function(t){return Ut(n,t)})]})},$group:An,$limit:function(t,n,r){return t.take(n)},$lookup:function(t,n,r){var e=n.from,u=n.localField,i=n.foreignField,o=n.as;M(R(e)&&D(i)&&D(u)&&D(o),"$lookup: invalid argument");var a={};return X(e,function(t){var n=ut(ft(t,i));a[n]=a[n]||[],a[n].push(t)}),t.map(function(t){var n=ut(ft(t,u)),r=S(t);return r[o]=a[n]||[],r})},$match:function(t,n,r){var e=new Yt(n);return t.filter(function(t){return e.test(t)})},$out:function(t,n,r){return M(R(n),"$out expression must be an array"),t.map(function(t){return n.push(t),t})},$project:function(t,n,r){if(Y(n))return t;var e=J(n),u=!1,i=Mt();if(En(n),q(e,i)){var o=n[i];0!==o&&!1!==o||(M(U(e=e.filter(U.bind(null,[i])),i),"Must not contain collections id key"),u=Y(e))}else e.push(i);return t.map(function(t){return function s(c,f,t,n){var l=Mt(),h={},v=!1,p=!1,d=[];return n&&d.push(l),t.forEach(function(t){var n,r=f[t];if(t!==l&&q([0,!1],r)&&(p=!0),t===l&&Y(r))n=c[t];else if(D(r))n=At(c,r,t);else if(q([1,!0],r));else if(R(r))n=r.map(function(t){var n=At(c,t);return F(n)?null:n});else{if(!T(r))return void d.push(t);var e=J(r),u=!(1<e.length)&&e[0];if(q(jt(x),u)){var i=Gn[x];"$slice"===u?H(r[u]).every(I)?(n=i[u](c,r[u],t),v=!0):n=At(c,r,t):n=i[u](c,r[u],t)}else if(z(c,t)){En(r);var o=c[t];n=R(o)?o.map(function(t){return s(t,r,e,!1)}):s(o,r,e,!1)}else n=At(c,r,t)}var a=lt(c,t,{preserveMissingValues:!0});void 0!==a&&Q(h,a,{flatten:!0}),U([0,1,!1,!0],r)&&(void 0===n?dt(h,t):pt(h,t,n))}),ht(h),(v||p||n)&&(h=Object.assign({},c,h),0<d.length&&(h=j(h),X(d,function(t){return dt(h,t)}))),h}(t,n,e,u)})},$redact:function(t,n,r){return t.map(function(t){return Et(j(t),n)})},$replaceRoot:function(t,n,r){return t.map(function(t){return M(T(t=At(t,n.newRoot)),"$replaceRoot expression must return an object"),t})},$sample:function(t,n,r){var u=n.size;return M(I(u),"$sample size must be a positive integer"),t.transform(function(n){var r=n.length,e=-1;return function(){if(++e===u)return{done:!0};var t=Math.floor(Math.random()*r);return{value:n[t],done:!1}}})},$skip:function(t,n,r){return t.drop(n)},$sort:Nn,$sortByCount:function(t,n,r){var e={count:{$sum:1}};return e[Mt()]=n,Nn(An(t,e),{count:-1},r)},$unwind:function(u,t,n){D(t)&&(t={path:t});var i,o=t.path.substr(1),r=t.includeArrayIndex||!1,a=t.preserveNullAndEmptyArrays||!1,s=function(t,n){return!1!==r&&(t[r]=n),t};return Dt(function(){for(var t=function(){if(Dt.isIterator(i)){var t=i.next();if(!t.done)return{v:t}}var e=u.next();if(e.done)return{v:e};if(e=e.value,i=ft(e,o),R(i)){if(0===i.length&&!0===a){i=null;var n=j(e);return dt(n,o),{v:{value:s(n,null),done:!1}}}i=Dt(i).map(function(t,n){var r=j(e);return pt(r,o,t),s(r,n)})}else if(!Y(i)||!0===a){var r=j(e);return{v:{value:s(r,null),done:!1}}}};;){var n=t();if("object"===e(n))return n.v}})}});var Rn=Object.freeze({__proto__:null,$:function(t,n,r){B("$ not implemented")},$elemMatch:function(t,n,r){var e=ft(t,r),u=new Yt(n);M(R(e),"$elemMatch: invalid argument");for(var i=0;i<e.length;i++)if(u.test(e[i]))return[e[i]]},$slice:function(t,n,r){var e=ft(t,r);return R(e)?R(n)?gt(e,n[0],n[1]):(M(I(n),"$slice: invalid arguments for projection"),gt(e,n)):e}});function Tn(u){return function(r,e){return function(t){var n=ft(t,r,{meta:!0});return n=function(t,n){if(n<1)return t;for(;n--&&R(t)&&1===t.length;)t=t[0];return t}(n.result,n.depth),u(n,e)}}}var Ln=Tn(function(t,n){var r=!1;if(R(t)&&R(n))for(var e=0,u=n.length;e<u;e++){if(!T(n[e])||!q(J(n[e]),"$elemMatch"))return G(n,t).length===u;r=r||Gt(t,n[e].$elemMatch)}return r}),Pn=Tn(Gt),Cn=Tn(Ht),Fn=Tn(function(t,n){return(!1===n||0===n)&&void 0===t||(!0===n||1===n)&&void 0!==t}),Vn=Tn(Qt),qn=Tn(Kt),Un=Tn(Bt),Wn=Tn(Xt),Yn=Tn(Zt),Hn=Tn(function(t,n){return H(t).some(function(t){return I(t)&&R(n)&&2===n.length&&t%n[0]===n[1]})}),zn=Tn(zt),Bn=Tn(Jt),Jn=Tn(function(t,n){var r=function(t){return D(t)&&!!t.match(n)};return(t=H(t)).some(r)||tt(t,1).some(r)}),Xn=Tn(function(t,n){return R(t)&&I(n)&&t.length===n}),Zn=Tn(function(t,n){switch(n){case 1:case"double":return I(t)&&-1!==(t+"").indexOf(".");case 2:case h:return D(t);case 3:case y:return T(t);case 4:case d:return R(t);case 6:case c:return F(t);case 8:case"bool":return N(t);case 9:case v:return P(t);case 10:case s:return V(t);case 11:case"regex":return C(t);case 16:case"int":return I(t)&&t<=2147483647&&-1===(t+"").indexOf(".");case 18:case"long":return I(t)&&2147483647<t&&t<=0x8000000000000000&&-1===(t+"").indexOf(".");case 19:case"decimal":return I(t);default:return!1}});function Qn(t,n){M(R(n),"Invalid expression. $or expects value to be an Array");var r=[];return X(n,function(t){return r.push(new Yt(t))}),function(t){for(var n=0;n<r.length;n++)if(r[n].test(t))return!0;return!1}}var Kn=Object.freeze({__proto__:null,$all:Ln,$elemMatch:Pn,$eq:Cn,$exists:Fn,$gt:Vn,$gte:qn,$in:Un,$lt:Wn,$lte:Yn,$mod:Hn,$ne:zn,$nin:Bn,$regex:Jn,$size:Xn,$type:Zn,$and:function(t,n){M(R(n),"Invalid expression: $and expects value to be an Array");var r=[];return X(n,function(t){return r.push(new Yt(t))}),function(t){for(var n=0;n<r.length;n++)if(!r[n].test(t))return!1;return!0}},$or:Qn,$nor:function(t,n){M(R(n),"Invalid expression. $nor expects value to be an Array");var r=Qn(0,n);return function(t){return!r(t)}},$not:function(t,n){var r={};r[t]=$t(n);var e=new Yt(r);return function(t){return!e.test(t)}},$where:function(t,n){return r(n)||(n=new Function("return "+n+";")),function(t){return!0===n.call(t)}},$expr:function(t,n){return function(t){return At(t,n)}}}),Gn={};Gn[m]={},Gn[_]={},Gn[b]={},Gn[x]={},Gn[k]={};var tr={query:function(t,n){return new Yt(t).find(this.toJSON(),n)},aggregate:function(t){return new qt(t).run(this.toJSON())}};X([[m,On],[_,Mn],[b,In],[x,Rn],[k,Kn]],function(t){var n=i(t,2),r=n[0],e=n[1];Object.assign(Gn[r],e)});return{_internal:_t,Aggregator:qt,CollectionMixin:tr,Cursor:Wt,Lazy:Dt,OP_EXPRESSION:m,OP_GROUP:_,OP_PIPELINE:b,OP_PROJECTION:x,OP_QUERY:k,Query:Yt,VERSION:"2.5.3",addOperators:function(r,t){var a=t(_t());M(z(Gn,r),"Invalid operator class ".concat(r));var e=Gn[r];X(a,function(t,n){M(/^\$[a-zA-Z0-9_]*$/.test(n),"Invalid operator name ".concat(n)),M(!z(e,n),"".concat(n," already exists for '").concat(r,"' operators"))});var n={};switch(r){case k:X(a,function(i,o){i=i.bind(a),n[o]=function(e,u){return function(t){var n=ft(t,e),r=i(e,n,u);return M(N(r),"".concat(o," must return a boolean")),r}}});break;case x:X(a,function(u,t){u=u.bind(a),n[t]=function(t,n,r){var e=ft(t,r);return u(r,e,n)}});break;default:X(a,function(e,t){n[t]=function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return e.apply(a,n)}})}Object.assign(Gn[r],n)},aggregate:Ut,find:function(t,n,r){return new Yt(n).find(t,r)},remove:function(t,n){return new Yt(n).remove(t)},setup:function(t){Object.assign(bt,t||{})}}},"object"===(void 0===r?"undefined":_typeof2(r))&&void 0!==n?n.exports=u():"function"==typeof define&&define.amd?define(u):(e=e||self).mingo=u()},{}]},{},[1]); |
@@ -82,3 +82,2 @@ 'use strict'; | ||
console.log(fn); | ||
return eval(fn); | ||
@@ -85,0 +84,0 @@ } |
@@ -81,3 +81,2 @@ const | ||
console.log(fn); | ||
return eval(fn); | ||
@@ -84,0 +83,0 @@ } |
{ | ||
"name": "jsexpr", | ||
"version": "0.10.5", | ||
"version": "0.10.6", | ||
"description": "String and JSON expression interpolator and evaluator. Interpolates or evaluates a string against a json object, or transforms an object into another based on a json template", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
609889
6139