From 61efad8851e8f90644d8d5b2ee36ed0bb8b52a83 Mon Sep 17 00:00:00 2001 From: Mateusz Date: Sun, 15 May 2022 16:33:05 +0200 Subject: [PATCH] Custom Aggregations sorting #101 with tests (#109) * Update aggregations sort this update add the ability to sort aggregations using custom array, it remove the sorting limitiation by the predefined 'selected', 'key', 'doc_count' ... no you can Use something like ''sort['key', 'doc_count']" in aggresgations. * added tests and info in readme Co-authored-by: Houcine Cherif <31718137+lhoucinecherif@users.noreply.github.com> --- README.md | 4 +- dist/itemsjs.js | 4 +- dist/itemsjs.min.js | 2 +- package.json | 2 +- src/helpers.js | 4 +- tests/facetSortingSpec.js | 94 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 tests/facetSortingSpec.js diff --git a/README.md b/README.md index 3609033..758c60c 100644 --- a/README.md +++ b/README.md @@ -182,8 +182,8 @@ Responsible for defining global configuration. Look for full example here - [con - **`title`** Human readable filter name - **`size`** Number of values provided for this filter (Default: `10`) - - **`sort`** Values sorted by `count` (Default) or `term` for the value name - - **`order`** `asc` | `desc` + - **`sort`** Values sorted by `count` (Default) or `term` for the value name. This can be also an array of keys which define the sorting priority + - **`order`** `asc` | `desc`. This can be also an array of orders (if `sort` is also array) - **`show_facet_stats`** `true` | `false` (Default) to retrieve the min, max, avg, sum rating values from the whole filtered dataset - **`conjunction`** `true` (Default) stands for an _AND_ query (results have to fit all selected facet-values), `false` for an _OR_ query (results have to fit one of the selected facet-values) diff --git a/dist/itemsjs.js b/dist/itemsjs.js index b8a91c0..a805fa8 100644 --- a/dist/itemsjs.js +++ b/dist/itemsjs.js @@ -20280,7 +20280,9 @@ var getBuckets = function getBuckets(data, input, aggregations) { }; }).value(); - if (sort === 'term') { + if (_.isArray(sort)) { + buckets = _.orderBy(buckets, sort || ['key'], order || ['asc']); + } else if (sort === 'term') { buckets = _.orderBy(buckets, ['selected', 'key'], ['desc', order || 'asc']); } else { buckets = _.orderBy(buckets, ['selected', 'doc_count', 'key'], ['desc', order || 'desc', 'asc']); diff --git a/dist/itemsjs.min.js b/dist/itemsjs.min.js index c7eeb88..e385ff5 100644 --- a/dist/itemsjs.min.js +++ b/dist/itemsjs.min.js @@ -1 +1 @@ -(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.itemsjs=e()}})(function(){var e=Math.floor,t=Math.max,n=Math.min,r;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o>>5]|=1<>>5]^=1<>>5]&=~(1<>>5]&1<>>5],n=t|1<>>5]=n,(n^t)>>>e},o.prototype.trim=function(){let e=this.words.length;for(;0>>5;t++)this.words[t]=0},o.prototype.hammingWeight=function(e){return e-=1431655765&e>>>1,e=(858993459&e)+(858993459&e>>>2),16843009*(252645135&e+(e>>>4))>>>24},o.prototype.hammingWeight4=function(e,t,n,r){return e-=1431655765&e>>>1,t-=1431655765&t>>>1,n-=1431655765&n>>>1,r-=1431655765&r>>>1,e=(858993459&e)+(858993459&e>>>2),t=(858993459&t)+(858993459&t>>>2),n=(858993459&n)+(858993459&n>>>2),r=(858993459&r)+(858993459&r>>>2),e=252645135&e+(e>>>4),t=252645135&t+(t>>>4),n=252645135&n+(n>>>4),r=252645135&r+(r>>>4),16843009*(e+t+n+r)>>>24},o.prototype.size=function(){let e=0;const t=this.words.length,n=this.words;for(let r=0;r=t;--r)e.words[r]=this.words[r];return e.words=e.words.slice(0,this.words.length),e},o.prototype.new_difference=function(e){return this.clone().difference(e)},o.prototype.difference_size=function(e){const t=n(this.words.length,e.words.length);let r=0,o=0;for(;o=t;--r)this.words[r]=e.words[r];return this},o.prototype.new_change=function(e){const r=Object.create(o.prototype),i=t(this.words.length,e.words.length);r.words=Array(i);const d=n(this.words.length,e.words.length);let s=0;for(;s+7e.words.length?this:e,d=i.words.length;for(;o"']/g,pt=RegExp(at.source),ut=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,ct=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ft=/^\w*$/,yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mt=/[\\^$.*+?()[\]{}|]/g,wt=RegExp(mt.source),kt=/^\s+/,xt=/\s/,bt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,vt=/\{\n\/\* \[wrapped with (.+)\] \*/,St=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,It=/[()=,{}\[\]\/\s]/,jt=/\\(\\)?/g,zt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,At=/\w*$/,Et=/^[-+]0x[0-9a-f]+$/i,Ot=/^0b[01]+$/i,Ft=/^\[object .+?Constructor\]$/,Nt=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Pt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ct=/($^)/,Rt=/['\n\r\u2028\u2029\\]/g,Vt="\\ud800-\\udfff",Lt="\\u2700-\\u27bf",Bt="a-z\\xdf-\\xf6\\xf8-\\xff",Ut="A-Z\\xc0-\\xd6\\xd8-\\xde",Dt="\\xac\\xb1\\xd7\\xf7"+"\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf"+"\\u2000-\\u206f"+" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",qt="['\u2019]",Mt="["+Dt+"]",$t="["+("\\u0300-\\u036f"+"\\ufe20-\\ufe2f"+"\\u20d0-\\u20ff")+"]",Jt="\\d+",Kt="["+Bt+"]",Ht="[^"+Vt+Dt+Jt+Lt+Bt+Ut+"]",Gt="\\ud83c[\\udffb-\\udfff]",Zt="[^"+Vt+"]",Yt="(?:\\ud83c[\\udde6-\\uddff]){2}",Qt="[\\ud800-\\udbff][\\udc00-\\udfff]",Xt="["+Ut+"]",en="(?:"+Kt+"|"+Ht+")",tn="(?:"+qt+"(?:d|ll|m|re|s|t|ve))?",nn="(?:"+qt+"(?:D|LL|M|RE|S|T|VE))?",rn="(?:"+$t+"|"+Gt+")"+"?",on="["+"\\ufe0e\\ufe0f"+"]?",dn="(?:"+"\\u200d"+"(?:"+[Zt,Yt,Qt].join("|")+")"+on+rn+")*",sn=on+rn+dn,an="(?:"+["["+Lt+"]",Yt,Qt].join("|")+")"+sn,ln="(?:"+[Zt+$t+"?",$t,Yt,Qt,"["+Vt+"]"].join("|")+")",pn=/['’]/g,un=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g,hn=RegExp(Gt+"(?="+Gt+")|"+ln+sn,"g"),cn=RegExp([Xt+"?"+Kt+"+"+tn+"(?="+[Mt,Xt,"$"].join("|")+")","(?:"+Xt+"|"+Ht+")"+"+"+nn+"(?="+[Mt,Xt+en,"$"].join("|")+")",Xt+"?"+en+"+"+tn,Xt+"+"+nn,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Jt,an].join("|"),"g"),gn=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/,_n=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fn=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],yn=-1,mn={};mn[Ze]=mn[Ye]=mn[Qe]=mn[Xe]=mn[et]=mn[tt]=mn[nt]=mn[rt]=mn[ot]=!0,mn[Fe]=mn[Ne]=mn[He]=mn[We]=mn[Ge]=mn[Pe]=mn[Ce]=mn[Re]=mn[Le]=mn[Be]=mn[Ue]=mn[qe]=mn[Me]=mn[$e]=mn[Ke]=!1;var wn={};wn[Fe]=wn[Ne]=wn[He]=wn[Ge]=wn[We]=wn[Pe]=wn[Ze]=wn[Ye]=wn[Qe]=wn[Xe]=wn[et]=wn[Le]=wn[Be]=wn[Ue]=wn[qe]=wn[Me]=wn[$e]=wn[Je]=wn[tt]=wn[nt]=wn[rt]=wn[ot]=!0,wn[Ce]=wn[Re]=wn[Ke]=!1;var kn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xn=parseFloat,bn=parseInt,vn="object"==typeof o&&o&&o.Object===Object&&o,Sn="object"==typeof self&&self&&self.Object===Object&&self,Tn=vn||Sn||Function("return this")(),In="object"==typeof d&&d&&!d.nodeType&&d,jn=In&&"object"==typeof i&&i&&!i.nodeType&&i,zn=jn&&jn.exports===In,An=zn&&vn.process,En=function(){try{var e=jn&&jn.require&&jn.require("util").types;return e?e:An&&An.binding&&An.binding("util")}catch(t){}}(),On=En&&En.isArrayBuffer,Fn=En&&En.isDate,Nn=En&&En.isMap,Wn=En&&En.isRegExp,Pn=En&&En.isSet,Cn=En&&En.isTypedArray,Rn=A("length"),Vn=E({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Ln=E({"&":"&","<":"<",">":">",'"':""","'":"'"}),Bn=E({"&":"&","<":"<",">":">",""":"\"","'":"'"}),Un=function r(o){function i(e){if(Li(e)&&!za(e)&&!(e instanceof x)){if(e instanceof _)return e;if(Ad.call(e,"__wrapped__"))return li(e)}return new _(e)}function d(){}function _(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function x(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ee,this.__views__=[]}function E(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Zt(e,t,n,r,o,i){var d=t&ue,s=t&he,a;if(n&&(a=o?n(e,r,o,i):n(e)),void 0!==a)return a;if(!Vi(e))return e;var p=za(e);if(!p){var u=Vs(e),h=u==Re||u==Ve;if(Ea(e))return Nr(e,d);if(u!=Ue&&u!=Fe&&(!h||o)){if(!wn[u])return o?e:{};a=Vo(e,u,d)}else if(a=s||h?{}:Ro(e),!d)return s?Jr(e,Jt(a,e)):$r(e,$t(a,e))}else if(a=Co(e),!d)return qr(e,a);i||(i=new xt);var c=i.get(e);if(c)return c;i.set(e,a),Wa(e)?e.forEach(function(r){a.add(Zt(r,t,n,r,e,i))}):Fa(e)&&e.forEach(function(r,o){a.set(o,Zt(r,t,n,o,e,i))});var g=t&ce?s?To:So:s?ed:Xi,_=p?void 0:g(e);return l(_||e,function(r,o){_&&(o=r,r=e[o]),Dt(a,o,Zt(r,t,n,o,e,i))}),a}function Yt(e){var t=Xi(e);return function(n){return Qt(n,e,t)}}function Qt(e,t,n){var r=n.length;if(null==e)return!r;for(e=kd(e);r--;){var o=n[r],i=t[o],d=e[o];if(void 0===d&&!(o in e)||!i(d))return!1}return!0}function Xt(e,t,n){if("function"!=typeof e)throw new vd(ae);return Us(function(){e.apply(void 0,n)},t)}function en(e,t,n,r){var o=-1,i=c,d=!0,s=e.length,a=[],l=t.length;if(!s)return a;n&&(t=f(t,R(n))),r?(i=g,d=!1):t.length>=se&&(i=L,d=!1,t=new ie(t));outer:for(;++on&&(n=-n>o?0:o+n),r=void 0===r||r>o?o:Ji(r),0>r&&(r+=o),r=n>r?0:Ki(r);nt}function kn(e,t){return null!=e&&Ad.call(e,t)}function vn(e,t){return null!=e&&t in kd(e)}function Sn(e,t,n){return e>=is(t,n)&&et?n:0,Uo(t,n)?e[t]:void 0}function tr(e,t,n){t=t.length?f(t,function(e){return za(e)?function(t){return hn(t,1===e.length?e[0]:e)}:e}):[ad];var r=-1;t=f(t,R(zo()));var o=Gn(e,function(e){var n=f(t,function(t){return t(e)});return{criteria:n,index:++r,value:e}});return F(o,function(e,t){return Br(e,t,n)})}function nr(e,t){return rr(e,t,function(t,n){return Qi(e,n)})}function rr(e,t,n){for(var r=-1,o=t.length,i={};++rt||t>ze)return n;do t%2&&(n+=e),t=Qd(t/2),t&&(e+=e);while(t);return n}function pr(e,t){return Ds(Xo(e,t,ad),e+"")}function ur(e){return Vt(rd(e))}function hr(e,t){var n=rd(e);return ii(n,Gt(t,0,n.length))}function cr(e,t,n,r){if(!Vi(e))return e;t=Or(t,e);for(var o=-1,i=t.length,d=e;null!=d&&++ot&&(t=-t>o?0:o+t),n=n>o?o:n,0>n&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=_d(o);++r>>1){for(;r>>1,d=e[i];null!==d&&!qi(d)&&(n?d<=t:d=se){var l=t?null:Ws(e);if(l)return Y(l);d=!1,o=L,a=new ie}else a=t?[]:s;outer:for(;++rr)return r?br(e[0]):[];for(var o=-1,i=_d(r);++o=r?e:_r(e,t,n)}function Nr(e,t){if(t)return e.slice();var n=e.length,r=Ld?Ld(n):new e.constructor(n);return e.copy(r),r}function Wr(e){var t=new e.constructor(e.byteLength);return new Vd(t).set(new Vd(e)),t}function Pr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Cr(e){var t=new e.constructor(e.source,At.exec(e));return t.lastIndex=e.lastIndex,t}function Rr(e){return Ss?kd(Ss.call(e)):{}}function Vr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Lr(e,t){if(e!==t){var n=void 0!==e,r=null===e,o=e===e,i=qi(e),d=void 0!==t,s=null===t,a=t===t,l=qi(t);if(!s&&!l&&!i&&e>t||i&&d&&a&&!s&&!l||r&&d&&a||!n&&a||!o)return 1;if(!r&&!i&&!l&&e=s)return a;var l=n[r];return a*("desc"==l?-1:1)}return e.index-t.index}function Ur(e,t,n,r){for(var o=-1,i=e.length,d=n.length,s=-1,a=t.length,l=os(i-d,0),p=_d(a+l),u=!r;++so?void 0:i,o=1),t=kd(t);++ri&&d[0]!==l&&d[i-1]!==l?[]:Z(d,l);if(i-=p.length,in)return n?lr(t,e):t;var r=lr(t,Yd(e/te(t)));return $(t)?Fr(ne(r),0,e).join(""):r.slice(0,e)}function po(e,t,n,r){function o(){for(var t=-1,a=arguments.length,l=-1,p=r.length,u=_d(p+a),h=this&&this!==Tn&&this instanceof o?d:e;++ls))return!1;var l=i.get(e),p=i.get(t);if(l&&p)return l==t&&p==e;var u=-1,h=!0,c=n&_e?new ie:void 0;for(i.set(e,t),i.set(t,e);++ut.length?e:hn(e,_r(t,0,-1))}function ti(e,t){for(var n=e.length,r=is(t.length,n),o=qr(e),i;r--;)i=t[r],e[r]=Uo(i,n)?o[i]:void 0;return e}function ni(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"==t?void 0:e[t]}function ri(e,t,n){var r=t+"";return Ds(e,Lo(r,ai(Wo(r),n)))}function oi(e){var t=0,n=0;return function(){var r=ds(),o=16-(r-n);if(n=r,!(0=800)return arguments[0];return e.apply(void 0,arguments)}}function ii(e,t){var n=-1,r=e.length;for(t=void 0===t?r:t;++no&&(o=os(r+o,0)),S(e,zo(t,3),o)}function ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r-1;return void 0!==n&&(o=Ji(n),o=0>n?os(r+o,0):is(o,r-1)),S(e,zo(t,3),o,!0)}function hi(e){var t=null==e?0:e.length;return t?dn(e,1):[]}function ci(e){return e&&e.length?e[0]:void 0}function gi(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function _i(e,t){return e&&e.length&&t&&t.length?ir(e,t):e}function fi(e){return null==e?e:ls.call(e)}function yi(e){if(!(e&&e.length))return[];var t=0;return e=h(e,function(e){if(Ni(e))return t=os(e.length,t),!0}),W(t,function(t){return f(e,A(t))})}function mi(e,t){if(!(e&&e.length))return[];var n=yi(e);return null==t?n:f(n,function(e){return s(t,void 0,e)})}function wi(e){var t=i(e);return t.__chain__=!0,t}function ki(e,t){return t(e)}function xi(e,t){var n=za(e)?l:js;return n(e,zo(t,3))}function bi(e,t){var n=za(e)?p:zs;return n(e,zo(t,3))}function vi(e,t){var n=za(e)?f:Gn;return n(e,zo(t,3))}function Si(e,t,n){return t=n?void 0:t,t=e&&null==t?e.length:t,fo(e,ve,void 0,void 0,void 0,void 0,t)}function Ti(e,t){var n;if("function"!=typeof t)throw new vd(ae);return e=Ji(e),function(){return 0<--e&&(n=t.apply(this,arguments)),1>=e&&(t=void 0),n}}function Ii(e,t,n){t=n?void 0:t;var r=fo(e,we,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=Ii.placeholder,r}function ji(e,t,n){t=n?void 0:t;var r=fo(e,ke,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=ji.placeholder,r}function zi(e,t,n){function r(t){var n=g,r=_;return g=_=void 0,p=t,y=e.apply(r,n),y}function o(e){return p=e,m=Us(s,t),u?r(e):y}function i(e){var n=e-w,r=e-p,o=t-n;return h?is(o,f-r):o}function d(e){var n=e-w,r=e-p;return void 0==w||n>=t||0>n||h&&r>=f}function s(){var e=fa();return d(e)?a(e):void(m=Us(s,i(e)))}function a(e){return(m=void 0,c&&g)?r(e):(g=_=void 0,y)}function l(){var e=fa(),n=d(e);if(g=arguments,_=this,w=e,n){if(void 0===m)return o(w);if(h)return Ns(m),m=Us(s,t),r(w)}return void 0===m&&(m=Us(s,t)),y}var p=0,u=!1,h=!1,c=!0,g,_,f,y,m,w;if("function"!=typeof e)throw new vd(ae);return t=Hi(t)||0,Vi(n)&&(u=!!n.leading,h="maxWait"in n,f=h?os(Hi(n.maxWait)||0,t):f,c="trailing"in n?!!n.trailing:c),l.cancel=function(){void 0!==m&&Ns(m),p=0,g=w=_=m=void 0},l.flush=function(){return void 0===m?y:a(fa())},l}function Ai(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new vd(ae);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var d=e.apply(this,r);return n.cache=i.set(o,d)||i,d};return n.cache=new(Ai.Cache||oe),n}function Ei(e){if("function"!=typeof e)throw new vd(ae);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2]);}return!e.apply(this,t)}}function Oi(e,t){return e===t||e!==e&&t!==t}function Fi(e){return null!=e&&Ri(e.length)&&!Pi(e)}function Ni(e){return Li(e)&&Fi(e)}function Wi(e){if(!Li(e))return!1;var t=gn(e);return t==Ce||t=="[object DOMException]"||"string"==typeof e.message&&"string"==typeof e.name&&!Ui(e)}function Pi(e){if(!Vi(e))return!1;var t=gn(e);return t==Re||t==Ve||t=="[object AsyncFunction]"||t=="[object Proxy]"}function Ci(e){return"number"==typeof e&&e==Ji(e)}function Ri(e){return"number"==typeof e&&-1e?-1:1;return t*1.7976931348623157e308}return e===e?e:0}function Ji(e){var t=$i(e),n=t%1;return t===t?n?t-n:t:0}function Ki(e){return e?Gt(Ji(e),0,Ee):0}function Hi(e){if("number"==typeof e)return e;if(qi(e))return Ae;if(Vi(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Vi(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=C(e);var n=Ot.test(e);return n||Nt.test(e)?bn(e.slice(2),n?2:8):Et.test(e)?Ae:+e}function Gi(e){return Mr(e,ed(e))}function Zi(e){return null==e?"":xr(e)}function Yi(e,t,n){var r=null==e?void 0:hn(e,t);return void 0===r?n:r}function Qi(e,t){return null!=e&&Po(e,t,vn)}function Xi(e){return Fi(e)?Tt(e):Jn(e)}function ed(e){return Fi(e)?Tt(e,!0):Kn(e)}function td(e,t){if(null==e)return{};var n=f(To(e),function(e){return[e]});return t=zo(t),rr(e,n,function(e,n){return t(e,n[0])})}function nd(e,t,n){t=Or(t,e);var r=-1,o=t.length;for(o||(o=1,e=void 0);++rn)return!1;var r=t.length-1;return n==r?t.pop():qd.call(t,n,1),--this.size,!0},X.prototype.get=function(e){var t=this.__data__,n=qt(t,e);return 0>n?void 0:t[n][1]},X.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},oe.prototype.clear=function(){this.size=0,this.__data__={hash:new E,map:new(us||X),string:new E}},oe.prototype["delete"]=function(e){var t=Ao(this,e)["delete"](e);return this.size-=t?1:0,t},oe.prototype.get=function(e){return Ao(this,e).get(e)},oe.prototype.has=function(e){return Ao(this,e).has(e)},oe.prototype.set=function(e,t){var n=Ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ie.prototype.add=ie.prototype.push=function(e){return this.__data__.set(e,le),this},ie.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.clear=function(){this.__data__=new X,this.size=0},xt.prototype["delete"]=function(e){var t=this.__data__,n=t["delete"](e);return this.size=t.size,n},xt.prototype.get=function(e){return this.__data__.get(e)},xt.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof X){var r=n.__data__;if(!us||r.length=t}),ja=En(function(){return arguments}())?En:function(e){return Li(e)&&Ad.call(e,"callee")&&!Dd.call(e,"callee")},za=_d.isArray,Aa=On?R(On):function(e){return Li(e)&&gn(e)==He},Ea=es||gd,Oa=Fn?R(Fn):function(e){return Li(e)&&gn(e)==Pe},Fa=Nn?R(Nn):function(e){return Li(e)&&Vs(e)==Le},Na=Wn?R(Wn):function(e){return Li(e)&&gn(e)==qe},Wa=Pn?R(Pn):function(e){return Li(e)&&Vs(e)==Me},Pa=Cn?R(Cn):function(e){return Li(e)&&Ri(e.length)&&!!mn[gn(e)]},Ca=ho(Hn),Ra=ho(function(e,t){return e<=t}),Va=Hr(function(e,t){if(Ko(t)||Fi(t))return void Mr(t,Xi(t),e);for(var n in t)Ad.call(t,n)&&Dt(e,n,t[n])}),La=Hr(function(e,t){Mr(t,ed(t),e)}),Ba=Hr(function(e,t,n,r){Mr(t,ed(t),e,r)}),Ua=Hr(function(e,t,n,r){Mr(t,Xi(t),e,r)}),Da=vo(Ht),qa=pr(function(e,t){e=kd(e);var n=-1,r=t.length,o=2--e)return t.apply(this,arguments)}},i.ary=Si,i.assign=Va,i.assignIn=La,i.assignInWith=Ba,i.assignWith=Ua,i.at=Da,i.before=Ti,i.bind=ya,i.bindAll=ll,i.bindKey=ma,i.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return za(e)?e:[e]},i.chain=wi,i.chunk=function(e,t,n){t=(n?Do(e,t,n):void 0===t)?1:os(Ji(t),0);var r=null==e?0:e.length;if(!r||1>t)return[];for(var o=0,i=0,d=_d(Yd(r/t));ot?0:t,r)):[]},i.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0,0>t?0:t)):[]},i.dropRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0,!0):[]},i.dropWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0):[]},i.fill=function(e,t,n,r){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&Do(e,t,n)&&(n=0,r=o),rn(e,t,n,r)):[]},i.filter=function(e,t){var n=za(e)?h:on;return n(e,zo(t,3))},i.flatMap=function(e,t){return dn(vi(e,t),1)},i.flatMapDeep=function(e,t){return dn(vi(e,t),je)},i.flatMapDepth=function(e,t,n){return n=void 0===n?1:Ji(n),dn(vi(e,t),n)},i.flatten=hi,i.flattenDeep=function(e){var t=null==e?0:e.length;return t?dn(e,je):[]},i.flattenDepth=function(e,t){var n=null==e?0:e.length;return n?(t=void 0===t?1:Ji(t),dn(e,t)):[]},i.flip=function(e){return fo(e,Te)},i.flow=pl,i.flowRight=ul,i.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={},o;++t>>0,!n)?[]:(e=Zi(e),e&&("string"==typeof t||null!=t&&!Na(t))&&(t=xr(t),!t&&$(e))?Fr(ne(e),0,n):e.split(t,n))},i.spread=function(e,t){if("function"!=typeof e)throw new vd(ae);return t=null==t?0:os(Ji(t),0),pr(function(n){var r=n[t],o=Fr(n,0,t);return r&&y(o,r),s(e,this,o)})},i.tail=function(e){var t=null==e?0:e.length;return t?_r(e,1,t):[]},i.take=function(e,t,n){return e&&e.length?(t=n||void 0===t?1:Ji(t),_r(e,0,0>t?0:t)):[]},i.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0>t?0:t,r)):[]},i.takeRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!1,!0):[]},i.takeWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3)):[]},i.tap=function(e,t){return t(e),e},i.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new vd(ae);return Vi(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),zi(e,t,{leading:r,maxWait:t,trailing:o})},i.thru=ki,i.toArray=Mi,i.toPairs=Qa,i.toPairsIn=Xa,i.toPath=function(e){return za(e)?f(e,di):qi(e)?[e]:qr(qs(Zi(e)))},i.toPlainObject=Gi,i.transform=function(e,t,n){var r=za(e),o=r||Ea(e)||Pa(e);if(t=zo(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Vi(e)?Pi(i)?Is(Bd(e)):{}:{}}return(o?l:sn)(e,function(e,r,o){return t(n,e,r,o)}),n},i.unary=function(e){return Si(e,1)},i.union=Qs,i.unionBy=Xs,i.unionWith=ea,i.uniq=function(e){return e&&e.length?br(e):[]},i.uniqBy=function(e,t){return e&&e.length?br(e,zo(t,2)):[]},i.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?br(e,void 0,t):[]},i.unset=function(e,t){return null==e||vr(e,t)},i.unzip=yi,i.unzipWith=mi,i.update=function(e,t,n){return null==e?e:Sr(e,t,Er(n))},i.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:Sr(e,t,Er(n),r)},i.values=rd,i.valuesIn=function(e){return null==e?[]:V(e,ed(e))},i.without=ta,i.words=dd,i.wrap=function(e,t){return ba(Er(t),e)},i.xor=na,i.xorBy=ra,i.xorWith=oa,i.zip=ia,i.zipObject=function(e,t){return zr(e||[],t||[],Dt)},i.zipObjectDeep=function(e,t){return zr(e||[],t||[],cr)},i.zipWith=da,i.entries=Qa,i.entriesIn=Xa,i.extend=La,i.extendWith=Ba,pd(i,i),i.add=wl,i.attempt=al,i.camelCase=el,i.capitalize=od,i.ceil=kl,i.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=Hi(n),n=n===n?n:0),void 0!==t&&(t=Hi(t),t=t===t?t:0),Gt(Hi(e),t,n)},i.clone=function(e){return Zt(e,ce)},i.cloneDeep=function(e){return Zt(e,ue|ce)},i.cloneDeepWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ue|ce,t)},i.cloneWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ce,t)},i.conformsTo=function(e,t){return null==t||Qt(e,t,Xi(t))},i.deburr=id,i.defaultTo=function(e,t){return null==e||e!==e?t:e},i.divide=xl,i.endsWith=function(e,t,n){e=Zi(e),t=xr(t);var r=e.length;n=void 0===n?r:Gt(Ji(n),0,r);var o=n;return n-=t.length,0<=n&&e.slice(n,o)==t},i.eq=Oi,i.escape=function(e){return e=Zi(e),e&&ut.test(e)?e.replace(lt,Ln):e},i.escapeRegExp=function(e){return e=Zi(e),e&&wt.test(e)?e.replace(mt,"\\$&"):e},i.every=function(e,t,n){var r=za(e)?u:tn;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.find=la,i.findIndex=pi,i.findKey=function(e,t){return v(e,zo(t,3),sn)},i.findLast=pa,i.findLastIndex=ui,i.findLastKey=function(e,t){return v(e,zo(t,3),an)},i.floor=bl,i.forEach=xi,i.forEachRight=bi,i.forIn=function(e,t){return null==e?e:As(e,zo(t,3),ed)},i.forInRight=function(e,t){return null==e?e:Es(e,zo(t,3),ed)},i.forOwn=function(e,t){return e&&sn(e,zo(t,3))},i.forOwnRight=function(e,t){return e&&an(e,zo(t,3))},i.get=Yi,i.gt=Ta,i.gte=Ia,i.has=function(e,t){return null!=e&&Po(e,t,kn)},i.hasIn=Qi,i.head=ci,i.identity=ad,i.includes=function(e,t,n,r){e=Fi(e)?e:rd(e),n=n&&!r?Ji(n):0;var o=e.length;return 0>n&&(n=os(o+n,0)),Di(e)?n<=o&&-1o&&(o=os(r+o,0)),T(e,t,o)},i.inRange=function(e,t,n){return t=$i(t),void 0===n?(n=t,t=0):n=$i(n),e=Hi(e),Sn(e,t,n)},i.invoke=Ka,i.isArguments=ja,i.isArray=za,i.isArrayBuffer=Aa,i.isArrayLike=Fi,i.isArrayLikeObject=Ni,i.isBoolean=function(e){return!0===e||!1===e||Li(e)&&gn(e)==We},i.isBuffer=Ea,i.isDate=Oa,i.isElement=function(e){return Li(e)&&1===e.nodeType&&!Ui(e)},i.isEmpty=function(e){if(null==e)return!0;if(Fi(e)&&(za(e)||"string"==typeof e||"function"==typeof e.splice||Ea(e)||Pa(e)||ja(e)))return!e.length;var t=Vs(e);if(t==Le||t==Me)return!e.size;if(Ko(e))return!Jn(e).length;for(var n in e)if(Ad.call(e,n))return!1;return!0},i.isEqual=function(e,t){return Rn(e,t)},i.isEqualWith=function(e,t,n){n="function"==typeof n?n:void 0;var r=n?n(e,t):void 0;return void 0===r?Rn(e,t,void 0,n):!!r},i.isError=Wi,i.isFinite=function(e){return"number"==typeof e&&ts(e)},i.isFunction=Pi,i.isInteger=Ci,i.isLength=Ri,i.isMap=Fa,i.isMatch=function(e,t){return e===t||qn(e,t,Eo(t))},i.isMatchWith=function(e,t,n){return n="function"==typeof n?n:void 0,qn(e,t,Eo(t),n)},i.isNaN=function(e){return Bi(e)&&e!=+e},i.isNative=function(e){if(Ls(e))throw new yd("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mn(e)},i.isNil=function(e){return null==e},i.isNull=function(e){return null===e},i.isNumber=Bi,i.isObject=Vi,i.isObjectLike=Li,i.isPlainObject=Ui,i.isRegExp=Na,i.isSafeInteger=function(e){return Ci(e)&&e>=-ze&&e<=ze},i.isSet=Wa,i.isString=Di,i.isSymbol=qi,i.isTypedArray=Pa,i.isUndefined=function(e){return void 0===e},i.isWeakMap=function(e){return Li(e)&&Vs(e)==Ke},i.isWeakSet=function(e){return Li(e)&&gn(e)=="[object WeakSet]"},i.join=function(e,t){return null==e?"":ns.call(e,t)},i.kebabCase=tl,i.last=gi,i.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return void 0!==n&&(o=Ji(n),o=0>o?os(r+o,0):is(o,r-1)),t===t?ee(e,t,o):S(e,j,o,!0)},i.lowerCase=nl,i.lowerFirst=rl,i.lt=Ca,i.lte=Ra,i.max=function(e){return e&&e.length?nn(e,ad,_n):void 0},i.maxBy=function(e,t){return e&&e.length?nn(e,zo(t,2),_n):void 0},i.mean=function(e){return z(e,ad)},i.meanBy=function(e,t){return z(e,zo(t,2))},i.min=function(e){return e&&e.length?nn(e,ad,Hn):void 0},i.minBy=function(e,t){return e&&e.length?nn(e,zo(t,2),Hn):void 0},i.stubArray=cd,i.stubFalse=gd,i.stubObject=function(){return{}},i.stubString=function(){return""},i.stubTrue=function(){return!0},i.multiply=vl,i.nth=function(e,t){return e&&e.length?er(e,Ji(t)):void 0},i.noConflict=function(){return Tn._===this&&(Tn._=Wd),this},i.noop=ud,i.now=fa,i.pad=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return lo(Qd(o),n)+e+lo(Yd(o),n)},i.padEnd=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=as();return is(e+o*(t-e+xn("1e-"+((o+"").length-1))),t)}return sr(e,t)},i.reduce=function(e,t,n){var r=za(e)?m:O,o=3>arguments.length;return r(e,zo(t,4),n,o,js)},i.reduceRight=function(e,t,n){var r=za(e)?w:O,o=3>arguments.length;return r(e,zo(t,4),n,o,zs)},i.repeat=function(e,t,n){return t=(n?Do(e,t,n):void 0===t)?1:Ji(t),lr(Zi(e),t)},i.replace=function(){var e=arguments,t=Zi(e[0]);return 3>e.length?t:t.replace(e[1],e[2])},i.result=nd,i.round=Sl,i.runInContext=r,i.sample=function(e){var t=za(e)?Vt:ur;return t(e)},i.size=function(e){if(null==e)return 0;if(Fi(e))return Di(e)?te(e):e.length;var t=Vs(e);return t==Le||t==Me?e.size:Jn(e).length},i.snakeCase=ol,i.some=function(e,t,n){var r=za(e)?k:fr;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.sortedIndex=function(e,t){return yr(e,t)},i.sortedIndexBy=function(e,t,n){return mr(e,t,zo(n,2))},i.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=yr(e,t);if(re||e>ze)return[];var n=Ee,r=is(e,Ee);t=zo(t),e-=Ee;for(var o=W(r,t);++n=i)return e;var s=n-te(r);if(1>s)return r;var a=d?Fr(d,0,s).join(""):e.slice(0,s);if(void 0===o)return a+r;if(d&&(s+=a.length-s),Na(o)){if(e.slice(s).search(o)){var l=a,p;for(o.global||(o=xd(o.source,Zi(At.exec(o))+"g")),o.lastIndex=0;p=o.exec(l);)var u=p.index;a=a.slice(0,void 0===u?s:u)}}else if(e.indexOf(xr(o),s)!=s){var h=a.lastIndexOf(o);-1n.__dir__?"Right":"")}),n},x.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),l(["filter","map","takeWhile"],function(e,t){var n=t+1;x.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:zo(e,3),type:n}),t.__filtered__=t.__filtered__||n==Ie||n==3,t}}),l(["head","last"],function(e,t){var n="take"+(t?"Right":"");x.prototype[e]=function(){return this[n](1).value()[0]}}),l(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");x.prototype[e]=function(){return this.__filtered__?new x(this):this[n](1)}}),x.prototype.compact=function(){return this.filter(ad)},x.prototype.find=function(e){return this.filter(e).head()},x.prototype.findLast=function(e){return this.reverse().find(e)},x.prototype.invokeMap=pr(function(e,t){return"function"==typeof e?new x(this):this.map(function(n){return An(n,e,t)})}),x.prototype.reject=function(e){return this.filter(Ei(zo(e)))},x.prototype.slice=function(e,t){e=Ji(e);var n=this;return n.__filtered__&&(0t)?new x(n):(0>e?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(t=Ji(t),n=0>t?n.dropRight(-t):n.take(t-e)),n)},x.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},x.prototype.toArray=function(){return this.take(Ee)},sn(x.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=i[r?"take"+("last"==t?"Right":""):t],d=r||/^find/.test(t);o&&(i.prototype[t]=function(){var t=this.__wrapped__,s=r?[1]:arguments,a=t instanceof x,l=s[0],p=a||za(t),u=function(e){var t=o.apply(i,y([e],s));return r&&h?t[0]:t};p&&n&&"function"==typeof l&&1!=l.length&&(a=p=!1);var h=this.__chain__,c=!!this.__actions__.length,g=d&&!h,f=a&&!c;if(!d&&p){t=f?t:new x(this);var m=e.apply(t,s);return m.__actions__.push({func:ki,args:[u],thisArg:void 0}),new _(m,h)}return g&&f?e.apply(this,s):(m=this.thru(u),g?r?m.value()[0]:m.value():m)})}),l(["pop","push","shift","sort","splice","unshift"],function(e){var t=Sd[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);i.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(za(o)?o:[],e)}return this[n](function(n){return t.apply(za(n)?n:[],e)})}}),sn(x.prototype,function(e,t){var n=i[t];if(n){var r=n.name+"";Ad.call(ys,r)||(ys[r]=[]),ys[r].push({name:t,func:n})}}),ys[oo(void 0,ye).name]=[{name:"wrapper",func:void 0}],x.prototype.clone=function(){var e=new x(this.__wrapped__);return e.__actions__=qr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qr(this.__views__),e},x.prototype.reverse=function(){if(this.__filtered__){var e=new x(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},x.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=za(e),r=0>t,o=n?e.length:0,i=No(0,o,this.__views__),d=i.start,s=i.end,a=s-d,l=r?s:d-1,p=this.__iteratees__,u=p.length,h=0,c=is(a,this.__takeCount__);if(!n||!r&&o==a&&c==a)return Ir(e,this.__actions__);var g=[];outer:for(;a--&&h=this.__values__.length,t=e?void 0:this.__values__[this.__index__++];return{done:e,value:t}},i.prototype.plant=function(e){for(var t=this,n,r;t instanceof d;){r=li(t),r.__index__=0,r.__values__=void 0,n?o.__wrapped__=r:n=r;var o=r;t=t.__wrapped__}return o.__wrapped__=e,n},i.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof x){var t=e;return this.__actions__.length&&(t=new x(this)),t=t.reverse(),t.__actions__.push({func:ki,args:[fi],thisArg:void 0}),new _(t,this.__chain__)}return this.thru(fi)},i.prototype.toJSON=i.prototype.valueOf=i.prototype.value=function(){return Ir(this.__wrapped__,this.__actions__)},i.prototype.first=i.prototype.head,$d&&(i.prototype[$d]=function(){return this}),i}();"function"==typeof r&&"object"==typeof r.amd&&r.amd?(Tn._=Un,r(function(){return Un})):jn?((jn.exports=Un)._=Un,In._=Un):Tn._=Un}).call(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],4:[function(n,o,i){(function(){var n=Math.log,d=function(e){var t=new d.Index;return t.pipeline.add(d.trimmer,d.stopWordFilter,d.stemmer),e&&e.call(t,t),t};d.version="1.0.0",d.utils={},d.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),d.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},d.EventEmitter=function(){this.events={}},d.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},d.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},d.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)})}},d.EventEmitter.prototype.hasHandler=function(e){return e in this.events},d.tokenizer=function(e){return arguments.length&&null!=e&&void 0!=e?Array.isArray(e)?e.map(function(e){return d.utils.asString(e).toLowerCase()}):e.toString().trim().toLowerCase().split(d.tokenizer.separator):[]},d.tokenizer.separator=/[\s\-]+/,d.tokenizer.load=function(e){var t=this.registeredFunctions[e];if(!t)throw new Error("Cannot load un-registered function: "+e);return t},d.tokenizer.label="default",d.tokenizer.registeredFunctions={default:d.tokenizer},d.tokenizer.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing tokenizer: "+t),e.label=t,this.registeredFunctions[t]=e},d.Pipeline=function(){this._stack=[]},d.Pipeline.registeredFunctions={},d.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing registered function: "+t),e.label=t,d.Pipeline.registeredFunctions[e.label]=e},d.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||d.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},d.Pipeline.load=function(e){var t=new d.Pipeline;return e.forEach(function(e){var n=d.Pipeline.registeredFunctions[e];if(n)t.add(n);else throw new Error("Cannot load un-registered function: "+e)}),t},d.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){d.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},d.Pipeline.prototype.after=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");++n,this._stack.splice(n,0,t)},d.Pipeline.prototype.before=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},d.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1==t||this._stack.splice(t,1)},d.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,o=0,i;on.idx?n=n.next:(r+=t.val*n.val,t=t.next,n=n.next);return r},d.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},d.SortedSet=function(){this.length=0,this.elements=[]},d.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},d.SortedSet.prototype.add=function(){var e,t;for(e=0;et&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i]}return d===t?i:-1},d.SortedSet.prototype.locationFor=function(t){for(var n=0,r=this.elements.length,o=r-n,i=n+e(o/2),d=this.elements[i];1t&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i];return d>t?i:do-1||r>i-1);){if(s[n]===a[r]){t.add(s[n]),n++,r++;continue}if(s[n]a[r]){r++;continue}}return t},d.SortedSet.prototype.clone=function(){var e=new d.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},d.SortedSet.prototype.union=function(e){var t,n,r;this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone();for(var o=0,i=n.toArray();on.length)return n;if(w=n.substr(0,1),"y"==w&&(n=w.toUpperCase()+n.substr(1)),I=l,j=p,I.test(n)?n=n.replace(I,"$1$2"):j.test(n)&&(n=n.replace(j,"$1$2")),I=u,j=h,I.test(n)){var E=I.exec(n);I=i,I.test(E[1])&&(I=c,n=n.replace(I,""))}else if(j.test(n)){var E=j.exec(n);r=E[1],j=a,j.test(r)&&(n=r,j=g,z=_,A=f,j.test(n)?n+="e":z.test(n)?(I=c,n=n.replace(I,"")):A.test(n)&&(n+="e"))}if(I=y,I.test(n)){var E=I.exec(n);r=E[1],n=r+"i"}if(I=m,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+e[o])}if(I=k,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+t[o])}if(I=x,j=b,I.test(n)){var E=I.exec(n);r=E[1],I=d,I.test(r)&&(n=r)}else if(j.test(n)){var E=j.exec(n);r=E[1]+E[2],j=d,j.test(r)&&(n=r)}if(I=v,I.test(n)){var E=I.exec(n);r=E[1],I=d,j=s,z=T,(I.test(r)||j.test(r)&&!z.test(r))&&(n=r)}return I=S,j=d,I.test(n)&&j.test(n)&&(I=c,n=n.replace(I,"")),"y"==w&&(n=w.toLowerCase()+n.substr(1)),n}}(),d.Pipeline.registerFunction(d.stemmer,"stemmer"),d.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e]!==e)return e}},d.stopWordFilter=d.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),d.Pipeline.registerFunction(d.stopWordFilter,"stopWordFilter"),d.trimmer=function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")},d.Pipeline.registerFunction(d.trimmer,"trimmer"),d.TokenStore=function(){this.root={docs:{}},this.length=0},d.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},d.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e.charAt(0),o=e.slice(1);return r in n||(n[r]={docs:{}}),0===o.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(o,t,n[r])},d.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;n=d&&(p.push(e[u]),p[p.length-1].intersection_length=h.length)}return p=n.orderBy(p,["intersection_length"],["desc"]),{pagination:{per_page:o,page:s,total:p.length},data:{items:p.slice((s-1)*o,s*o)}}},t.exports.aggregation=function(e,n,o,i,d){var s=n.per_page||10,a=n.page||1;if(n.name&&(!o.aggregations||!o.aggregations[n.name]))throw new Error("Please define aggregation \"".concat(n.name,"\" in config"));var l=r.clone(n);if(l.page=1,l.per_page=0,!n.name)throw new Error("field name is required");o.aggregations[n.name].size=1e4;var p=t.exports.search(e,l,o,i,d),u=p.data.aggregations[n.name].buckets;return{pagination:{per_page:s,page:a,total:u.length},data:{buckets:u.slice((a-1)*s,a*s)}}}},{"./helpers":7,fastbitset:2,lodash:3}]},{},[1])(1)}); \ No newline at end of file +(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.itemsjs=e()}})(function(){var e=Math.floor,t=Math.max,n=Math.min,r;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o>>5]|=1<>>5]^=1<>>5]&=~(1<>>5]&1<>>5],n=t|1<>>5]=n,(n^t)>>>e},o.prototype.trim=function(){let e=this.words.length;for(;0>>5;t++)this.words[t]=0},o.prototype.hammingWeight=function(e){return e-=1431655765&e>>>1,e=(858993459&e)+(858993459&e>>>2),16843009*(252645135&e+(e>>>4))>>>24},o.prototype.hammingWeight4=function(e,t,n,r){return e-=1431655765&e>>>1,t-=1431655765&t>>>1,n-=1431655765&n>>>1,r-=1431655765&r>>>1,e=(858993459&e)+(858993459&e>>>2),t=(858993459&t)+(858993459&t>>>2),n=(858993459&n)+(858993459&n>>>2),r=(858993459&r)+(858993459&r>>>2),e=252645135&e+(e>>>4),t=252645135&t+(t>>>4),n=252645135&n+(n>>>4),r=252645135&r+(r>>>4),16843009*(e+t+n+r)>>>24},o.prototype.size=function(){let e=0;const t=this.words.length,n=this.words;for(let r=0;r=t;--r)e.words[r]=this.words[r];return e.words=e.words.slice(0,this.words.length),e},o.prototype.new_difference=function(e){return this.clone().difference(e)},o.prototype.difference_size=function(e){const t=n(this.words.length,e.words.length);let r=0,o=0;for(;o=t;--r)this.words[r]=e.words[r];return this},o.prototype.new_change=function(e){const r=Object.create(o.prototype),i=t(this.words.length,e.words.length);r.words=Array(i);const d=n(this.words.length,e.words.length);let s=0;for(;s+7e.words.length?this:e,d=i.words.length;for(;o"']/g,pt=RegExp(at.source),ut=RegExp(lt.source),ht=/<%-([\s\S]+?)%>/g,ct=/<%([\s\S]+?)%>/g,_t=/<%=([\s\S]+?)%>/g,gt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ft=/^\w*$/,yt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,mt=/[\\^$.*+?()[\]{}|]/g,wt=RegExp(mt.source),kt=/^\s+/,xt=/\s/,bt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,vt=/\{\n\/\* \[wrapped with (.+)\] \*/,St=/,? & /,Tt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,It=/[()=,{}\[\]\/\s]/,jt=/\\(\\)?/g,zt=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,At=/\w*$/,Et=/^[-+]0x[0-9a-f]+$/i,Ot=/^0b[01]+$/i,Ft=/^\[object .+?Constructor\]$/,Nt=/^0o[0-7]+$/i,Wt=/^(?:0|[1-9]\d*)$/,Pt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ct=/($^)/,Rt=/['\n\r\u2028\u2029\\]/g,Vt="\\ud800-\\udfff",Lt="\\u2700-\\u27bf",Bt="a-z\\xdf-\\xf6\\xf8-\\xff",Ut="A-Z\\xc0-\\xd6\\xd8-\\xde",Dt="\\xac\\xb1\\xd7\\xf7"+"\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf"+"\\u2000-\\u206f"+" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",qt="['\u2019]",Mt="["+Dt+"]",$t="["+("\\u0300-\\u036f"+"\\ufe20-\\ufe2f"+"\\u20d0-\\u20ff")+"]",Jt="\\d+",Kt="["+Bt+"]",Ht="[^"+Vt+Dt+Jt+Lt+Bt+Ut+"]",Gt="\\ud83c[\\udffb-\\udfff]",Zt="[^"+Vt+"]",Yt="(?:\\ud83c[\\udde6-\\uddff]){2}",Qt="[\\ud800-\\udbff][\\udc00-\\udfff]",Xt="["+Ut+"]",en="(?:"+Kt+"|"+Ht+")",tn="(?:"+qt+"(?:d|ll|m|re|s|t|ve))?",nn="(?:"+qt+"(?:D|LL|M|RE|S|T|VE))?",rn="(?:"+$t+"|"+Gt+")"+"?",on="["+"\\ufe0e\\ufe0f"+"]?",dn="(?:"+"\\u200d"+"(?:"+[Zt,Yt,Qt].join("|")+")"+on+rn+")*",sn=on+rn+dn,an="(?:"+["["+Lt+"]",Yt,Qt].join("|")+")"+sn,ln="(?:"+[Zt+$t+"?",$t,Yt,Qt,"["+Vt+"]"].join("|")+")",pn=/['’]/g,un=/[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]/g,hn=RegExp(Gt+"(?="+Gt+")|"+ln+sn,"g"),cn=RegExp([Xt+"?"+Kt+"+"+tn+"(?="+[Mt,Xt,"$"].join("|")+")","(?:"+Xt+"|"+Ht+")"+"+"+nn+"(?="+[Mt,Xt+en,"$"].join("|")+")",Xt+"?"+en+"+"+tn,Xt+"+"+nn,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Jt,an].join("|"),"g"),gn=/[\u200d\ud800-\udfff\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff\ufe0e\ufe0f]/,_n=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fn=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],yn=-1,mn={};mn[Ze]=mn[Ye]=mn[Qe]=mn[Xe]=mn[et]=mn[tt]=mn[nt]=mn[rt]=mn[ot]=!0,mn[Fe]=mn[Ne]=mn[He]=mn[We]=mn[Ge]=mn[Pe]=mn[Ce]=mn[Re]=mn[Le]=mn[Be]=mn[Ue]=mn[qe]=mn[Me]=mn[$e]=mn[Ke]=!1;var wn={};wn[Fe]=wn[Ne]=wn[He]=wn[Ge]=wn[We]=wn[Pe]=wn[Ze]=wn[Ye]=wn[Qe]=wn[Xe]=wn[et]=wn[Le]=wn[Be]=wn[Ue]=wn[qe]=wn[Me]=wn[$e]=wn[Je]=wn[tt]=wn[nt]=wn[rt]=wn[ot]=!0,wn[Ce]=wn[Re]=wn[Ke]=!1;var kn={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xn=parseFloat,bn=parseInt,vn="object"==typeof o&&o&&o.Object===Object&&o,Sn="object"==typeof self&&self&&self.Object===Object&&self,Tn=vn||Sn||Function("return this")(),In="object"==typeof d&&d&&!d.nodeType&&d,jn=In&&"object"==typeof i&&i&&!i.nodeType&&i,zn=jn&&jn.exports===In,An=zn&&vn.process,En=function(){try{var e=jn&&jn.require&&jn.require("util").types;return e?e:An&&An.binding&&An.binding("util")}catch(t){}}(),On=En&&En.isArrayBuffer,Fn=En&&En.isDate,Nn=En&&En.isMap,Wn=En&&En.isRegExp,Pn=En&&En.isSet,Cn=En&&En.isTypedArray,Rn=A("length"),Vn=E({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"}),Ln=E({"&":"&","<":"<",">":">",'"':""","'":"'"}),Bn=E({"&":"&","<":"<",">":">",""":"\"","'":"'"}),Un=function r(o){function i(e){if(Li(e)&&!za(e)&&!(e instanceof x)){if(e instanceof _)return e;if(Ad.call(e,"__wrapped__"))return li(e)}return new _(e)}function d(){}function _(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function x(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ee,this.__views__=[]}function E(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Zt(e,t,n,r,o,i){var d=t&ue,s=t&he,a;if(n&&(a=o?n(e,r,o,i):n(e)),void 0!==a)return a;if(!Vi(e))return e;var p=za(e);if(!p){var u=Vs(e),h=u==Re||u==Ve;if(Ea(e))return Nr(e,d);if(u!=Ue&&u!=Fe&&(!h||o)){if(!wn[u])return o?e:{};a=Vo(e,u,d)}else if(a=s||h?{}:Ro(e),!d)return s?Jr(e,Jt(a,e)):$r(e,$t(a,e))}else if(a=Co(e),!d)return qr(e,a);i||(i=new xt);var c=i.get(e);if(c)return c;i.set(e,a),Wa(e)?e.forEach(function(r){a.add(Zt(r,t,n,r,e,i))}):Fa(e)&&e.forEach(function(r,o){a.set(o,Zt(r,t,n,o,e,i))});var g=t&ce?s?To:So:s?ed:Xi,_=p?void 0:g(e);return l(_||e,function(r,o){_&&(o=r,r=e[o]),Dt(a,o,Zt(r,t,n,o,e,i))}),a}function Yt(e){var t=Xi(e);return function(n){return Qt(n,e,t)}}function Qt(e,t,n){var r=n.length;if(null==e)return!r;for(e=kd(e);r--;){var o=n[r],i=t[o],d=e[o];if(void 0===d&&!(o in e)||!i(d))return!1}return!0}function Xt(e,t,n){if("function"!=typeof e)throw new vd(ae);return Us(function(){e.apply(void 0,n)},t)}function en(e,t,n,r){var o=-1,i=c,d=!0,s=e.length,a=[],l=t.length;if(!s)return a;n&&(t=f(t,R(n))),r?(i=g,d=!1):t.length>=se&&(i=L,d=!1,t=new ie(t));outer:for(;++on&&(n=-n>o?0:o+n),r=void 0===r||r>o?o:Ji(r),0>r&&(r+=o),r=n>r?0:Ki(r);nt}function kn(e,t){return null!=e&&Ad.call(e,t)}function vn(e,t){return null!=e&&t in kd(e)}function Sn(e,t,n){return e>=is(t,n)&&et?n:0,Uo(t,n)?e[t]:void 0}function tr(e,t,n){t=t.length?f(t,function(e){return za(e)?function(t){return hn(t,1===e.length?e[0]:e)}:e}):[ad];var r=-1;t=f(t,R(zo()));var o=Gn(e,function(e){var n=f(t,function(t){return t(e)});return{criteria:n,index:++r,value:e}});return F(o,function(e,t){return Br(e,t,n)})}function nr(e,t){return rr(e,t,function(t,n){return Qi(e,n)})}function rr(e,t,n){for(var r=-1,o=t.length,i={};++rt||t>ze)return n;do t%2&&(n+=e),t=Qd(t/2),t&&(e+=e);while(t);return n}function pr(e,t){return Ds(Xo(e,t,ad),e+"")}function ur(e){return Vt(rd(e))}function hr(e,t){var n=rd(e);return ii(n,Gt(t,0,n.length))}function cr(e,t,n,r){if(!Vi(e))return e;t=Or(t,e);for(var o=-1,i=t.length,d=e;null!=d&&++ot&&(t=-t>o?0:o+t),n=n>o?o:n,0>n&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var i=_d(o);++r>>1){for(;r>>1,d=e[i];null!==d&&!qi(d)&&(n?d<=t:d=se){var l=t?null:Ws(e);if(l)return Y(l);d=!1,o=L,a=new ie}else a=t?[]:s;outer:for(;++rr)return r?br(e[0]):[];for(var o=-1,i=_d(r);++o=r?e:_r(e,t,n)}function Nr(e,t){if(t)return e.slice();var n=e.length,r=Ld?Ld(n):new e.constructor(n);return e.copy(r),r}function Wr(e){var t=new e.constructor(e.byteLength);return new Vd(t).set(new Vd(e)),t}function Pr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Cr(e){var t=new e.constructor(e.source,At.exec(e));return t.lastIndex=e.lastIndex,t}function Rr(e){return Ss?kd(Ss.call(e)):{}}function Vr(e,t){var n=t?Wr(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Lr(e,t){if(e!==t){var n=void 0!==e,r=null===e,o=e===e,i=qi(e),d=void 0!==t,s=null===t,a=t===t,l=qi(t);if(!s&&!l&&!i&&e>t||i&&d&&a&&!s&&!l||r&&d&&a||!n&&a||!o)return 1;if(!r&&!i&&!l&&e=s)return a;var l=n[r];return a*("desc"==l?-1:1)}return e.index-t.index}function Ur(e,t,n,r){for(var o=-1,i=e.length,d=n.length,s=-1,a=t.length,l=os(i-d,0),p=_d(a+l),u=!r;++so?void 0:i,o=1),t=kd(t);++ri&&d[0]!==l&&d[i-1]!==l?[]:Z(d,l);if(i-=p.length,in)return n?lr(t,e):t;var r=lr(t,Yd(e/te(t)));return $(t)?Fr(ne(r),0,e).join(""):r.slice(0,e)}function po(e,t,n,r){function o(){for(var t=-1,a=arguments.length,l=-1,p=r.length,u=_d(p+a),h=this&&this!==Tn&&this instanceof o?d:e;++ls))return!1;var l=i.get(e),p=i.get(t);if(l&&p)return l==t&&p==e;var u=-1,h=!0,c=n&_e?new ie:void 0;for(i.set(e,t),i.set(t,e);++ut.length?e:hn(e,_r(t,0,-1))}function ti(e,t){for(var n=e.length,r=is(t.length,n),o=qr(e),i;r--;)i=t[r],e[r]=Uo(i,n)?o[i]:void 0;return e}function ni(e,t){return"constructor"===t&&"function"==typeof e[t]||"__proto__"==t?void 0:e[t]}function ri(e,t,n){var r=t+"";return Ds(e,Lo(r,ai(Wo(r),n)))}function oi(e){var t=0,n=0;return function(){var r=ds(),o=16-(r-n);if(n=r,!(0=800)return arguments[0];return e.apply(void 0,arguments)}}function ii(e,t){var n=-1,r=e.length;for(t=void 0===t?r:t;++no&&(o=os(r+o,0)),S(e,zo(t,3),o)}function ui(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r-1;return void 0!==n&&(o=Ji(n),o=0>n?os(r+o,0):is(o,r-1)),S(e,zo(t,3),o,!0)}function hi(e){var t=null==e?0:e.length;return t?dn(e,1):[]}function ci(e){return e&&e.length?e[0]:void 0}function gi(e){var t=null==e?0:e.length;return t?e[t-1]:void 0}function _i(e,t){return e&&e.length&&t&&t.length?ir(e,t):e}function fi(e){return null==e?e:ls.call(e)}function yi(e){if(!(e&&e.length))return[];var t=0;return e=h(e,function(e){if(Ni(e))return t=os(e.length,t),!0}),W(t,function(t){return f(e,A(t))})}function mi(e,t){if(!(e&&e.length))return[];var n=yi(e);return null==t?n:f(n,function(e){return s(t,void 0,e)})}function wi(e){var t=i(e);return t.__chain__=!0,t}function ki(e,t){return t(e)}function xi(e,t){var n=za(e)?l:js;return n(e,zo(t,3))}function bi(e,t){var n=za(e)?p:zs;return n(e,zo(t,3))}function vi(e,t){var n=za(e)?f:Gn;return n(e,zo(t,3))}function Si(e,t,n){return t=n?void 0:t,t=e&&null==t?e.length:t,fo(e,ve,void 0,void 0,void 0,void 0,t)}function Ti(e,t){var n;if("function"!=typeof t)throw new vd(ae);return e=Ji(e),function(){return 0<--e&&(n=t.apply(this,arguments)),1>=e&&(t=void 0),n}}function Ii(e,t,n){t=n?void 0:t;var r=fo(e,we,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=Ii.placeholder,r}function ji(e,t,n){t=n?void 0:t;var r=fo(e,ke,void 0,void 0,void 0,void 0,void 0,t);return r.placeholder=ji.placeholder,r}function zi(e,t,n){function r(t){var n=g,r=_;return g=_=void 0,p=t,y=e.apply(r,n),y}function o(e){return p=e,m=Us(s,t),u?r(e):y}function i(e){var n=e-w,r=e-p,o=t-n;return h?is(o,f-r):o}function d(e){var n=e-w,r=e-p;return void 0==w||n>=t||0>n||h&&r>=f}function s(){var e=fa();return d(e)?a(e):void(m=Us(s,i(e)))}function a(e){return(m=void 0,c&&g)?r(e):(g=_=void 0,y)}function l(){var e=fa(),n=d(e);if(g=arguments,_=this,w=e,n){if(void 0===m)return o(w);if(h)return Ns(m),m=Us(s,t),r(w)}return void 0===m&&(m=Us(s,t)),y}var p=0,u=!1,h=!1,c=!0,g,_,f,y,m,w;if("function"!=typeof e)throw new vd(ae);return t=Hi(t)||0,Vi(n)&&(u=!!n.leading,h="maxWait"in n,f=h?os(Hi(n.maxWait)||0,t):f,c="trailing"in n?!!n.trailing:c),l.cancel=function(){void 0!==m&&Ns(m),p=0,g=w=_=m=void 0},l.flush=function(){return void 0===m?y:a(fa())},l}function Ai(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new vd(ae);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var d=e.apply(this,r);return n.cache=i.set(o,d)||i,d};return n.cache=new(Ai.Cache||oe),n}function Ei(e){if("function"!=typeof e)throw new vd(ae);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2]);}return!e.apply(this,t)}}function Oi(e,t){return e===t||e!==e&&t!==t}function Fi(e){return null!=e&&Ri(e.length)&&!Pi(e)}function Ni(e){return Li(e)&&Fi(e)}function Wi(e){if(!Li(e))return!1;var t=gn(e);return t==Ce||t=="[object DOMException]"||"string"==typeof e.message&&"string"==typeof e.name&&!Ui(e)}function Pi(e){if(!Vi(e))return!1;var t=gn(e);return t==Re||t==Ve||t=="[object AsyncFunction]"||t=="[object Proxy]"}function Ci(e){return"number"==typeof e&&e==Ji(e)}function Ri(e){return"number"==typeof e&&-1e?-1:1;return t*1.7976931348623157e308}return e===e?e:0}function Ji(e){var t=$i(e),n=t%1;return t===t?n?t-n:t:0}function Ki(e){return e?Gt(Ji(e),0,Ee):0}function Hi(e){if("number"==typeof e)return e;if(qi(e))return Ae;if(Vi(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Vi(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=C(e);var n=Ot.test(e);return n||Nt.test(e)?bn(e.slice(2),n?2:8):Et.test(e)?Ae:+e}function Gi(e){return Mr(e,ed(e))}function Zi(e){return null==e?"":xr(e)}function Yi(e,t,n){var r=null==e?void 0:hn(e,t);return void 0===r?n:r}function Qi(e,t){return null!=e&&Po(e,t,vn)}function Xi(e){return Fi(e)?Tt(e):Jn(e)}function ed(e){return Fi(e)?Tt(e,!0):Kn(e)}function td(e,t){if(null==e)return{};var n=f(To(e),function(e){return[e]});return t=zo(t),rr(e,n,function(e,n){return t(e,n[0])})}function nd(e,t,n){t=Or(t,e);var r=-1,o=t.length;for(o||(o=1,e=void 0);++rn)return!1;var r=t.length-1;return n==r?t.pop():qd.call(t,n,1),--this.size,!0},X.prototype.get=function(e){var t=this.__data__,n=qt(t,e);return 0>n?void 0:t[n][1]},X.prototype.has=function(e){return-1r?(++this.size,n.push([e,t])):n[r][1]=t,this},oe.prototype.clear=function(){this.size=0,this.__data__={hash:new E,map:new(us||X),string:new E}},oe.prototype["delete"]=function(e){var t=Ao(this,e)["delete"](e);return this.size-=t?1:0,t},oe.prototype.get=function(e){return Ao(this,e).get(e)},oe.prototype.has=function(e){return Ao(this,e).has(e)},oe.prototype.set=function(e,t){var n=Ao(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ie.prototype.add=ie.prototype.push=function(e){return this.__data__.set(e,le),this},ie.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.clear=function(){this.__data__=new X,this.size=0},xt.prototype["delete"]=function(e){var t=this.__data__,n=t["delete"](e);return this.size=t.size,n},xt.prototype.get=function(e){return this.__data__.get(e)},xt.prototype.has=function(e){return this.__data__.has(e)},xt.prototype.set=function(e,t){var n=this.__data__;if(n instanceof X){var r=n.__data__;if(!us||r.length=t}),ja=En(function(){return arguments}())?En:function(e){return Li(e)&&Ad.call(e,"callee")&&!Dd.call(e,"callee")},za=_d.isArray,Aa=On?R(On):function(e){return Li(e)&&gn(e)==He},Ea=es||gd,Oa=Fn?R(Fn):function(e){return Li(e)&&gn(e)==Pe},Fa=Nn?R(Nn):function(e){return Li(e)&&Vs(e)==Le},Na=Wn?R(Wn):function(e){return Li(e)&&gn(e)==qe},Wa=Pn?R(Pn):function(e){return Li(e)&&Vs(e)==Me},Pa=Cn?R(Cn):function(e){return Li(e)&&Ri(e.length)&&!!mn[gn(e)]},Ca=ho(Hn),Ra=ho(function(e,t){return e<=t}),Va=Hr(function(e,t){if(Ko(t)||Fi(t))return void Mr(t,Xi(t),e);for(var n in t)Ad.call(t,n)&&Dt(e,n,t[n])}),La=Hr(function(e,t){Mr(t,ed(t),e)}),Ba=Hr(function(e,t,n,r){Mr(t,ed(t),e,r)}),Ua=Hr(function(e,t,n,r){Mr(t,Xi(t),e,r)}),Da=vo(Ht),qa=pr(function(e,t){e=kd(e);var n=-1,r=t.length,o=2--e)return t.apply(this,arguments)}},i.ary=Si,i.assign=Va,i.assignIn=La,i.assignInWith=Ba,i.assignWith=Ua,i.at=Da,i.before=Ti,i.bind=ya,i.bindAll=ll,i.bindKey=ma,i.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return za(e)?e:[e]},i.chain=wi,i.chunk=function(e,t,n){t=(n?Do(e,t,n):void 0===t)?1:os(Ji(t),0);var r=null==e?0:e.length;if(!r||1>t)return[];for(var o=0,i=0,d=_d(Yd(r/t));ot?0:t,r)):[]},i.dropRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0,0>t?0:t)):[]},i.dropRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0,!0):[]},i.dropWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!0):[]},i.fill=function(e,t,n,r){var o=null==e?0:e.length;return o?(n&&"number"!=typeof n&&Do(e,t,n)&&(n=0,r=o),rn(e,t,n,r)):[]},i.filter=function(e,t){var n=za(e)?h:on;return n(e,zo(t,3))},i.flatMap=function(e,t){return dn(vi(e,t),1)},i.flatMapDeep=function(e,t){return dn(vi(e,t),je)},i.flatMapDepth=function(e,t,n){return n=void 0===n?1:Ji(n),dn(vi(e,t),n)},i.flatten=hi,i.flattenDeep=function(e){var t=null==e?0:e.length;return t?dn(e,je):[]},i.flattenDepth=function(e,t){var n=null==e?0:e.length;return n?(t=void 0===t?1:Ji(t),dn(e,t)):[]},i.flip=function(e){return fo(e,Te)},i.flow=pl,i.flowRight=ul,i.fromPairs=function(e){for(var t=-1,n=null==e?0:e.length,r={},o;++t>>0,!n)?[]:(e=Zi(e),e&&("string"==typeof t||null!=t&&!Na(t))&&(t=xr(t),!t&&$(e))?Fr(ne(e),0,n):e.split(t,n))},i.spread=function(e,t){if("function"!=typeof e)throw new vd(ae);return t=null==t?0:os(Ji(t),0),pr(function(n){var r=n[t],o=Fr(n,0,t);return r&&y(o,r),s(e,this,o)})},i.tail=function(e){var t=null==e?0:e.length;return t?_r(e,1,t):[]},i.take=function(e,t,n){return e&&e.length?(t=n||void 0===t?1:Ji(t),_r(e,0,0>t?0:t)):[]},i.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?(t=n||void 0===t?1:Ji(t),t=r-t,_r(e,0>t?0:t,r)):[]},i.takeRightWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3),!1,!0):[]},i.takeWhile=function(e,t){return e&&e.length?Tr(e,zo(t,3)):[]},i.tap=function(e,t){return t(e),e},i.throttle=function(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new vd(ae);return Vi(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),zi(e,t,{leading:r,maxWait:t,trailing:o})},i.thru=ki,i.toArray=Mi,i.toPairs=Qa,i.toPairsIn=Xa,i.toPath=function(e){return za(e)?f(e,di):qi(e)?[e]:qr(qs(Zi(e)))},i.toPlainObject=Gi,i.transform=function(e,t,n){var r=za(e),o=r||Ea(e)||Pa(e);if(t=zo(t,4),null==n){var i=e&&e.constructor;n=o?r?new i:[]:Vi(e)?Pi(i)?Is(Bd(e)):{}:{}}return(o?l:sn)(e,function(e,r,o){return t(n,e,r,o)}),n},i.unary=function(e){return Si(e,1)},i.union=Qs,i.unionBy=Xs,i.unionWith=ea,i.uniq=function(e){return e&&e.length?br(e):[]},i.uniqBy=function(e,t){return e&&e.length?br(e,zo(t,2)):[]},i.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?br(e,void 0,t):[]},i.unset=function(e,t){return null==e||vr(e,t)},i.unzip=yi,i.unzipWith=mi,i.update=function(e,t,n){return null==e?e:Sr(e,t,Er(n))},i.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:Sr(e,t,Er(n),r)},i.values=rd,i.valuesIn=function(e){return null==e?[]:V(e,ed(e))},i.without=ta,i.words=dd,i.wrap=function(e,t){return ba(Er(t),e)},i.xor=na,i.xorBy=ra,i.xorWith=oa,i.zip=ia,i.zipObject=function(e,t){return zr(e||[],t||[],Dt)},i.zipObjectDeep=function(e,t){return zr(e||[],t||[],cr)},i.zipWith=da,i.entries=Qa,i.entriesIn=Xa,i.extend=La,i.extendWith=Ba,pd(i,i),i.add=wl,i.attempt=al,i.camelCase=el,i.capitalize=od,i.ceil=kl,i.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=Hi(n),n=n===n?n:0),void 0!==t&&(t=Hi(t),t=t===t?t:0),Gt(Hi(e),t,n)},i.clone=function(e){return Zt(e,ce)},i.cloneDeep=function(e){return Zt(e,ue|ce)},i.cloneDeepWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ue|ce,t)},i.cloneWith=function(e,t){return t="function"==typeof t?t:void 0,Zt(e,ce,t)},i.conformsTo=function(e,t){return null==t||Qt(e,t,Xi(t))},i.deburr=id,i.defaultTo=function(e,t){return null==e||e!==e?t:e},i.divide=xl,i.endsWith=function(e,t,n){e=Zi(e),t=xr(t);var r=e.length;n=void 0===n?r:Gt(Ji(n),0,r);var o=n;return n-=t.length,0<=n&&e.slice(n,o)==t},i.eq=Oi,i.escape=function(e){return e=Zi(e),e&&ut.test(e)?e.replace(lt,Ln):e},i.escapeRegExp=function(e){return e=Zi(e),e&&wt.test(e)?e.replace(mt,"\\$&"):e},i.every=function(e,t,n){var r=za(e)?u:tn;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.find=la,i.findIndex=pi,i.findKey=function(e,t){return v(e,zo(t,3),sn)},i.findLast=pa,i.findLastIndex=ui,i.findLastKey=function(e,t){return v(e,zo(t,3),an)},i.floor=bl,i.forEach=xi,i.forEachRight=bi,i.forIn=function(e,t){return null==e?e:As(e,zo(t,3),ed)},i.forInRight=function(e,t){return null==e?e:Es(e,zo(t,3),ed)},i.forOwn=function(e,t){return e&&sn(e,zo(t,3))},i.forOwnRight=function(e,t){return e&&an(e,zo(t,3))},i.get=Yi,i.gt=Ta,i.gte=Ia,i.has=function(e,t){return null!=e&&Po(e,t,kn)},i.hasIn=Qi,i.head=ci,i.identity=ad,i.includes=function(e,t,n,r){e=Fi(e)?e:rd(e),n=n&&!r?Ji(n):0;var o=e.length;return 0>n&&(n=os(o+n,0)),Di(e)?n<=o&&-1o&&(o=os(r+o,0)),T(e,t,o)},i.inRange=function(e,t,n){return t=$i(t),void 0===n?(n=t,t=0):n=$i(n),e=Hi(e),Sn(e,t,n)},i.invoke=Ka,i.isArguments=ja,i.isArray=za,i.isArrayBuffer=Aa,i.isArrayLike=Fi,i.isArrayLikeObject=Ni,i.isBoolean=function(e){return!0===e||!1===e||Li(e)&&gn(e)==We},i.isBuffer=Ea,i.isDate=Oa,i.isElement=function(e){return Li(e)&&1===e.nodeType&&!Ui(e)},i.isEmpty=function(e){if(null==e)return!0;if(Fi(e)&&(za(e)||"string"==typeof e||"function"==typeof e.splice||Ea(e)||Pa(e)||ja(e)))return!e.length;var t=Vs(e);if(t==Le||t==Me)return!e.size;if(Ko(e))return!Jn(e).length;for(var n in e)if(Ad.call(e,n))return!1;return!0},i.isEqual=function(e,t){return Rn(e,t)},i.isEqualWith=function(e,t,n){n="function"==typeof n?n:void 0;var r=n?n(e,t):void 0;return void 0===r?Rn(e,t,void 0,n):!!r},i.isError=Wi,i.isFinite=function(e){return"number"==typeof e&&ts(e)},i.isFunction=Pi,i.isInteger=Ci,i.isLength=Ri,i.isMap=Fa,i.isMatch=function(e,t){return e===t||qn(e,t,Eo(t))},i.isMatchWith=function(e,t,n){return n="function"==typeof n?n:void 0,qn(e,t,Eo(t),n)},i.isNaN=function(e){return Bi(e)&&e!=+e},i.isNative=function(e){if(Ls(e))throw new yd("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Mn(e)},i.isNil=function(e){return null==e},i.isNull=function(e){return null===e},i.isNumber=Bi,i.isObject=Vi,i.isObjectLike=Li,i.isPlainObject=Ui,i.isRegExp=Na,i.isSafeInteger=function(e){return Ci(e)&&e>=-ze&&e<=ze},i.isSet=Wa,i.isString=Di,i.isSymbol=qi,i.isTypedArray=Pa,i.isUndefined=function(e){return void 0===e},i.isWeakMap=function(e){return Li(e)&&Vs(e)==Ke},i.isWeakSet=function(e){return Li(e)&&gn(e)=="[object WeakSet]"},i.join=function(e,t){return null==e?"":ns.call(e,t)},i.kebabCase=tl,i.last=gi,i.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var o=r;return void 0!==n&&(o=Ji(n),o=0>o?os(r+o,0):is(o,r-1)),t===t?ee(e,t,o):S(e,j,o,!0)},i.lowerCase=nl,i.lowerFirst=rl,i.lt=Ca,i.lte=Ra,i.max=function(e){return e&&e.length?nn(e,ad,_n):void 0},i.maxBy=function(e,t){return e&&e.length?nn(e,zo(t,2),_n):void 0},i.mean=function(e){return z(e,ad)},i.meanBy=function(e,t){return z(e,zo(t,2))},i.min=function(e){return e&&e.length?nn(e,ad,Hn):void 0},i.minBy=function(e,t){return e&&e.length?nn(e,zo(t,2),Hn):void 0},i.stubArray=cd,i.stubFalse=gd,i.stubObject=function(){return{}},i.stubString=function(){return""},i.stubTrue=function(){return!0},i.multiply=vl,i.nth=function(e,t){return e&&e.length?er(e,Ji(t)):void 0},i.noConflict=function(){return Tn._===this&&(Tn._=Wd),this},i.noop=ud,i.now=fa,i.pad=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;if(!t||r>=t)return e;var o=(t-r)/2;return lo(Qd(o),n)+e+lo(Yd(o),n)},i.padEnd=function(e,t,n){e=Zi(e),t=Ji(t);var r=t?te(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var o=as();return is(e+o*(t-e+xn("1e-"+((o+"").length-1))),t)}return sr(e,t)},i.reduce=function(e,t,n){var r=za(e)?m:O,o=3>arguments.length;return r(e,zo(t,4),n,o,js)},i.reduceRight=function(e,t,n){var r=za(e)?w:O,o=3>arguments.length;return r(e,zo(t,4),n,o,zs)},i.repeat=function(e,t,n){return t=(n?Do(e,t,n):void 0===t)?1:Ji(t),lr(Zi(e),t)},i.replace=function(){var e=arguments,t=Zi(e[0]);return 3>e.length?t:t.replace(e[1],e[2])},i.result=nd,i.round=Sl,i.runInContext=r,i.sample=function(e){var t=za(e)?Vt:ur;return t(e)},i.size=function(e){if(null==e)return 0;if(Fi(e))return Di(e)?te(e):e.length;var t=Vs(e);return t==Le||t==Me?e.size:Jn(e).length},i.snakeCase=ol,i.some=function(e,t,n){var r=za(e)?k:fr;return n&&Do(e,t,n)&&(t=void 0),r(e,zo(t,3))},i.sortedIndex=function(e,t){return yr(e,t)},i.sortedIndexBy=function(e,t,n){return mr(e,t,zo(n,2))},i.sortedIndexOf=function(e,t){var n=null==e?0:e.length;if(n){var r=yr(e,t);if(re||e>ze)return[];var n=Ee,r=is(e,Ee);t=zo(t),e-=Ee;for(var o=W(r,t);++n=i)return e;var s=n-te(r);if(1>s)return r;var a=d?Fr(d,0,s).join(""):e.slice(0,s);if(void 0===o)return a+r;if(d&&(s+=a.length-s),Na(o)){if(e.slice(s).search(o)){var l=a,p;for(o.global||(o=xd(o.source,Zi(At.exec(o))+"g")),o.lastIndex=0;p=o.exec(l);)var u=p.index;a=a.slice(0,void 0===u?s:u)}}else if(e.indexOf(xr(o),s)!=s){var h=a.lastIndexOf(o);-1n.__dir__?"Right":"")}),n},x.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}}),l(["filter","map","takeWhile"],function(e,t){var n=t+1;x.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:zo(e,3),type:n}),t.__filtered__=t.__filtered__||n==Ie||n==3,t}}),l(["head","last"],function(e,t){var n="take"+(t?"Right":"");x.prototype[e]=function(){return this[n](1).value()[0]}}),l(["initial","tail"],function(e,t){var n="drop"+(t?"":"Right");x.prototype[e]=function(){return this.__filtered__?new x(this):this[n](1)}}),x.prototype.compact=function(){return this.filter(ad)},x.prototype.find=function(e){return this.filter(e).head()},x.prototype.findLast=function(e){return this.reverse().find(e)},x.prototype.invokeMap=pr(function(e,t){return"function"==typeof e?new x(this):this.map(function(n){return An(n,e,t)})}),x.prototype.reject=function(e){return this.filter(Ei(zo(e)))},x.prototype.slice=function(e,t){e=Ji(e);var n=this;return n.__filtered__&&(0t)?new x(n):(0>e?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(t=Ji(t),n=0>t?n.dropRight(-t):n.take(t-e)),n)},x.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},x.prototype.toArray=function(){return this.take(Ee)},sn(x.prototype,function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),o=i[r?"take"+("last"==t?"Right":""):t],d=r||/^find/.test(t);o&&(i.prototype[t]=function(){var t=this.__wrapped__,s=r?[1]:arguments,a=t instanceof x,l=s[0],p=a||za(t),u=function(e){var t=o.apply(i,y([e],s));return r&&h?t[0]:t};p&&n&&"function"==typeof l&&1!=l.length&&(a=p=!1);var h=this.__chain__,c=!!this.__actions__.length,g=d&&!h,f=a&&!c;if(!d&&p){t=f?t:new x(this);var m=e.apply(t,s);return m.__actions__.push({func:ki,args:[u],thisArg:void 0}),new _(m,h)}return g&&f?e.apply(this,s):(m=this.thru(u),g?r?m.value()[0]:m.value():m)})}),l(["pop","push","shift","sort","splice","unshift"],function(e){var t=Sd[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);i.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(za(o)?o:[],e)}return this[n](function(n){return t.apply(za(n)?n:[],e)})}}),sn(x.prototype,function(e,t){var n=i[t];if(n){var r=n.name+"";Ad.call(ys,r)||(ys[r]=[]),ys[r].push({name:t,func:n})}}),ys[oo(void 0,ye).name]=[{name:"wrapper",func:void 0}],x.prototype.clone=function(){var e=new x(this.__wrapped__);return e.__actions__=qr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qr(this.__views__),e},x.prototype.reverse=function(){if(this.__filtered__){var e=new x(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e},x.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=za(e),r=0>t,o=n?e.length:0,i=No(0,o,this.__views__),d=i.start,s=i.end,a=s-d,l=r?s:d-1,p=this.__iteratees__,u=p.length,h=0,c=is(a,this.__takeCount__);if(!n||!r&&o==a&&c==a)return Ir(e,this.__actions__);var g=[];outer:for(;a--&&h=this.__values__.length,t=e?void 0:this.__values__[this.__index__++];return{done:e,value:t}},i.prototype.plant=function(e){for(var t=this,n,r;t instanceof d;){r=li(t),r.__index__=0,r.__values__=void 0,n?o.__wrapped__=r:n=r;var o=r;t=t.__wrapped__}return o.__wrapped__=e,n},i.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof x){var t=e;return this.__actions__.length&&(t=new x(this)),t=t.reverse(),t.__actions__.push({func:ki,args:[fi],thisArg:void 0}),new _(t,this.__chain__)}return this.thru(fi)},i.prototype.toJSON=i.prototype.valueOf=i.prototype.value=function(){return Ir(this.__wrapped__,this.__actions__)},i.prototype.first=i.prototype.head,$d&&(i.prototype[$d]=function(){return this}),i}();"function"==typeof r&&"object"==typeof r.amd&&r.amd?(Tn._=Un,r(function(){return Un})):jn?((jn.exports=Un)._=Un,In._=Un):Tn._=Un}).call(this)}).call(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],4:[function(n,o,i){(function(){var n=Math.log,d=function(e){var t=new d.Index;return t.pipeline.add(d.trimmer,d.stopWordFilter,d.stemmer),e&&e.call(t,t),t};d.version="1.0.0",d.utils={},d.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),d.utils.asString=function(e){return void 0===e||null===e?"":e.toString()},d.EventEmitter=function(){this.events={}},d.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop();if("function"!=typeof t)throw new TypeError("last argument must be a function");e.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},d.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);this.events[e].splice(n,1),this.events[e].length||delete this.events[e]}},d.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)})}},d.EventEmitter.prototype.hasHandler=function(e){return e in this.events},d.tokenizer=function(e){return arguments.length&&null!=e&&void 0!=e?Array.isArray(e)?e.map(function(e){return d.utils.asString(e).toLowerCase()}):e.toString().trim().toLowerCase().split(d.tokenizer.separator):[]},d.tokenizer.separator=/[\s\-]+/,d.tokenizer.load=function(e){var t=this.registeredFunctions[e];if(!t)throw new Error("Cannot load un-registered function: "+e);return t},d.tokenizer.label="default",d.tokenizer.registeredFunctions={default:d.tokenizer},d.tokenizer.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing tokenizer: "+t),e.label=t,this.registeredFunctions[t]=e},d.Pipeline=function(){this._stack=[]},d.Pipeline.registeredFunctions={},d.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&d.utils.warn("Overwriting existing registered function: "+t),e.label=t,d.Pipeline.registeredFunctions[e.label]=e},d.Pipeline.warnIfFunctionNotRegistered=function(e){var t=e.label&&e.label in this.registeredFunctions;t||d.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},d.Pipeline.load=function(e){var t=new d.Pipeline;return e.forEach(function(e){var n=d.Pipeline.registeredFunctions[e];if(n)t.add(n);else throw new Error("Cannot load un-registered function: "+e)}),t},d.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){d.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},d.Pipeline.prototype.after=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");++n,this._stack.splice(n,0,t)},d.Pipeline.prototype.before=function(e,t){d.Pipeline.warnIfFunctionNotRegistered(t);var n=this._stack.indexOf(e);if(-1==n)throw new Error("Cannot find existingFn");this._stack.splice(n,0,t)},d.Pipeline.prototype.remove=function(e){var t=this._stack.indexOf(e);-1==t||this._stack.splice(t,1)},d.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,r=this._stack.length,o=0,i;on.idx?n=n.next:(r+=t.val*n.val,t=t.next,n=n.next);return r},d.Vector.prototype.similarity=function(e){return this.dot(e)/(this.magnitude()*e.magnitude())},d.SortedSet=function(){this.length=0,this.elements=[]},d.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},d.SortedSet.prototype.add=function(){var e,t;for(e=0;et&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i]}return d===t?i:-1},d.SortedSet.prototype.locationFor=function(t){for(var n=0,r=this.elements.length,o=r-n,i=n+e(o/2),d=this.elements[i];1t&&(r=i),o=r-n,i=n+e(o/2),d=this.elements[i];return d>t?i:do-1||r>i-1);){if(s[n]===a[r]){t.add(s[n]),n++,r++;continue}if(s[n]a[r]){r++;continue}}return t},d.SortedSet.prototype.clone=function(){var e=new d.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},d.SortedSet.prototype.union=function(e){var t,n,r;this.length>=e.length?(t=this,n=e):(t=e,n=this),r=t.clone();for(var o=0,i=n.toArray();on.length)return n;if(w=n.substr(0,1),"y"==w&&(n=w.toUpperCase()+n.substr(1)),I=l,j=p,I.test(n)?n=n.replace(I,"$1$2"):j.test(n)&&(n=n.replace(j,"$1$2")),I=u,j=h,I.test(n)){var E=I.exec(n);I=i,I.test(E[1])&&(I=c,n=n.replace(I,""))}else if(j.test(n)){var E=j.exec(n);r=E[1],j=a,j.test(r)&&(n=r,j=g,z=_,A=f,j.test(n)?n+="e":z.test(n)?(I=c,n=n.replace(I,"")):A.test(n)&&(n+="e"))}if(I=y,I.test(n)){var E=I.exec(n);r=E[1],n=r+"i"}if(I=m,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+e[o])}if(I=k,I.test(n)){var E=I.exec(n);r=E[1],o=E[2],I=i,I.test(r)&&(n=r+t[o])}if(I=x,j=b,I.test(n)){var E=I.exec(n);r=E[1],I=d,I.test(r)&&(n=r)}else if(j.test(n)){var E=j.exec(n);r=E[1]+E[2],j=d,j.test(r)&&(n=r)}if(I=v,I.test(n)){var E=I.exec(n);r=E[1],I=d,j=s,z=T,(I.test(r)||j.test(r)&&!z.test(r))&&(n=r)}return I=S,j=d,I.test(n)&&j.test(n)&&(I=c,n=n.replace(I,"")),"y"==w&&(n=w.toLowerCase()+n.substr(1)),n}}(),d.Pipeline.registerFunction(d.stemmer,"stemmer"),d.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e]!==e)return e}},d.stopWordFilter=d.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),d.Pipeline.registerFunction(d.stopWordFilter,"stopWordFilter"),d.trimmer=function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")},d.Pipeline.registerFunction(d.trimmer,"trimmer"),d.TokenStore=function(){this.root={docs:{}},this.length=0},d.TokenStore.load=function(e){var t=new this;return t.root=e.root,t.length=e.length,t},d.TokenStore.prototype.add=function(e,t,n){var n=n||this.root,r=e.charAt(0),o=e.slice(1);return r in n||(n[r]={docs:{}}),0===o.length?(n[r].docs[t.ref]=t,void(this.length+=1)):this.add(o,t,n[r])},d.TokenStore.prototype.has=function(e){if(!e)return!1;for(var t=this.root,n=0;n=d&&(p.push(e[u]),p[p.length-1].intersection_length=h.length)}return p=n.orderBy(p,["intersection_length"],["desc"]),{pagination:{per_page:o,page:s,total:p.length},data:{items:p.slice((s-1)*o,s*o)}}},t.exports.aggregation=function(e,n,o,i,d){var s=n.per_page||10,a=n.page||1;if(n.name&&(!o.aggregations||!o.aggregations[n.name]))throw new Error("Please define aggregation \"".concat(n.name,"\" in config"));var l=r.clone(n);if(l.page=1,l.per_page=0,!n.name)throw new Error("field name is required");o.aggregations[n.name].size=1e4;var p=t.exports.search(e,l,o,i,d),u=p.data.aggregations[n.name].buckets;return{pagination:{per_page:s,page:a,total:u.length},data:{buckets:u.slice((a-1)*s,a*s)}}}},{"./helpers":7,fastbitset:2,lodash:3}]},{},[1])(1)}); \ No newline at end of file diff --git a/package.json b/package.json index e26869c..a51ce71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "itemsjs", - "version": "2.1.14", + "version": "2.1.15", "description": "Created to perform fast search on small json dataset (up to 1000 elements).", "main": "lib/index.js", "scripts": { diff --git a/src/helpers.js b/src/helpers.js index c408b28..24412bd 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -291,7 +291,9 @@ const getBuckets = function(data, input, aggregations) { }) .value(); - if (sort === 'term') { + if (_.isArray(sort)) { + buckets = _.orderBy(buckets, sort || ['key'], order || ['asc']); + } else if (sort === 'term') { buckets = _.orderBy(buckets, ['selected', 'key'], ['desc', order || 'asc']); } else { buckets = _.orderBy(buckets, ['selected', 'doc_count', 'key'], ['desc', order || 'desc', 'asc']); diff --git a/tests/facetSortingSpec.js b/tests/facetSortingSpec.js new file mode 100644 index 0000000..a2ac633 --- /dev/null +++ b/tests/facetSortingSpec.js @@ -0,0 +1,94 @@ +'use strict'; + +const assert = require('assert'); +const items = [{ + genres: 'Western' +}, { + genres: 'Western' +}, { + genres: 'Comedy' +}, { + genres: 'Drama' +}, { + genres: 'Horror' +}, { + genres: 'Romance' +}, { + genres: 'Western' +}]; + +describe('facet sorting', function() { + + it('sort by key', function test(done) { + + const result = require('./../index')(items, { + aggregations: { + genres: { + sort: ['key'], + } + } + }).aggregation({ + name: 'genres', + }); + + assert.deepEqual(result.data.buckets.map(v => v.key), ['Comedy', 'Drama', 'Horror', 'Romance', 'Western']); + + done(); + }); + + it('sort by key descending', function test(done) { + + const result = require('./../index')(items, { + aggregations: { + genres: { + sort: ['key'], + order: ['desc'] + } + } + }).aggregation({ + name: 'genres', + }); + + assert.deepEqual(result.data.buckets.map(v => v.key), ['Western', 'Romance', 'Horror', 'Drama', 'Comedy']); + + done(); + }); + + it('sort by doc_count', function test(done) { + + const result = require('./../index')(items, { + aggregations: { + genres: { + sort: ['doc_count'], + order: ['desc'], + } + } + }).aggregation({ + name: 'genres', + }); + + assert.deepEqual(result.data.buckets.map(v => v.key), ['Western', 'Comedy', 'Drama', 'Horror', 'Romance']); + + done(); + }); + + it('sort by doc_count and key and order key desc', function test(done) { + + const result = require('./../index')(items, { + aggregations: { + genres: { + sort: ['doc_count', 'key'], + order: ['desc', 'desc'], + } + } + }).aggregation({ + name: 'genres', + }); + + assert.deepEqual(result.data.buckets.map(v => v.key), ['Western', 'Romance', 'Horror', 'Drama', 'Comedy']); + + done(); + }); + +}); +