UNPKG

itemsjs

Version:

Created to perform fast search on small json dataset (up to 1000 elements).

1 lines 61.1 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t||self).itemsjs=e()}(this,function(){function t(){return t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},t.apply(this,arguments)}var e="object"==typeof global&&global&&global.Object===Object&&global,r="object"==typeof self&&self&&self.Object===Object&&self,n=e||r||Function("return this")(),o=n.Symbol,i=Object.prototype,s=i.hasOwnProperty,a=i.toString,u=o?o.toStringTag:void 0,c=Object.prototype.toString,f="[object Null]",l="[object Undefined]",h=o?o.toStringTag:void 0;function d(t){return null==t?void 0===t?l:f:h&&h in Object(t)?function(t){var e=s.call(t,u),r=t[u];try{t[u]=void 0;var n=!0}catch(t){}var o=a.call(t);return n&&(e?t[u]=r:delete t[u]),o}(t):function(t){return c.call(t)}(t)}function p(t){return null!=t&&"object"==typeof t}var g="[object Symbol]";function w(t){return"symbol"==typeof t||p(t)&&d(t)==g}function v(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o}var y=Array.isArray,_=1/0,b=o?o.prototype:void 0,m=b?b.toString:void 0;function j(t){if("string"==typeof t)return t;if(y(t))return v(t,j)+"";if(w(t))return m?m.call(t):"";var e=t+"";return"0"==e&&1/t==-_?"-0":e}function S(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function O(t){return t}var x="[object AsyncFunction]",A="[object Function]",k="[object GeneratorFunction]",E="[object Proxy]";function z(t){if(!S(t))return!1;var e=d(t);return e==A||e==k||e==x||e==E}var F,P=n["__core-js_shared__"],T=(F=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+F:"",N=Function.prototype.toString;function M(t){if(null!=t){try{return N.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var I=/^\[object .+?Constructor\]$/,D=RegExp("^"+Function.prototype.toString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function $(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!S(t)||(e=t,T&&T in e))&&(z(t)?D:I).test(M(t));var e}(r)?r:void 0}var W,R,C,V=$(n,"WeakMap"),U=Object.create,q=function(){function t(){}return function(e){if(!S(e))return{};if(U)return U(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),B=Date.now,J=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),L=J,H=L?function(t,e){return L(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:O,G=(W=H,R=0,C=0,function(){var t=B(),e=16-(t-C);if(C=t,e>0){if(++R>=800)return arguments[0]}else R=0;return W.apply(void 0,arguments)}),Z=G;function Y(t){return t!=t}function K(t,e){return!(null==t||!t.length)&&function(t,e,r){return e==e?function(t,e,r){for(var n=-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1}(t,e):function(t,e,r,n){for(var o=t.length,i=-1;++i<o;)if(e(t[i],i,t))return i;return-1}(t,Y)}(t,e)>-1}var Q=9007199254740991,X=/^(?:0|[1-9]\d*)$/;function tt(t,e){var r=typeof t;return!!(e=null==e?Q:e)&&("number"==r||"symbol"!=r&&X.test(t))&&t>-1&&t%1==0&&t<e}function et(t,e,r){"__proto__"==e&&L?L(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function rt(t,e){return t===e||t!=t&&e!=e}var nt=Object.prototype.hasOwnProperty;function ot(t,e,r){var n=t[e];nt.call(t,e)&&rt(n,r)&&(void 0!==r||e in t)||et(t,e,r)}function it(t,e,r,n){var o=!r;r||(r={});for(var i=-1,s=e.length;++i<s;){var a=e[i],u=n?n(r[a],t[a],a,r,t):void 0;void 0===u&&(u=t[a]),o?et(r,a,u):ot(r,a,u)}return r}var st=Math.max,at=9007199254740991;function ut(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=at}function ct(t){return null!=t&&ut(t.length)&&!z(t)}var ft=Object.prototype;function lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ft)}function ht(t){return p(t)&&"[object Arguments]"==d(t)}var dt=Object.prototype,pt=dt.hasOwnProperty,gt=dt.propertyIsEnumerable,wt=ht(function(){return arguments}())?ht:function(t){return p(t)&&pt.call(t,"callee")&&!gt.call(t,"callee")},vt=wt,yt="object"==typeof exports&&exports&&!exports.nodeType&&exports,_t=yt&&"object"==typeof module&&module&&!module.nodeType&&module,bt=_t&&_t.exports===yt?n.Buffer:void 0,mt=(bt?bt.isBuffer:void 0)||function(){return!1},jt={};function St(t){return function(e){return t(e)}}jt["[object Float32Array]"]=jt["[object Float64Array]"]=jt["[object Int8Array]"]=jt["[object Int16Array]"]=jt["[object Int32Array]"]=jt["[object Uint8Array]"]=jt["[object Uint8ClampedArray]"]=jt["[object Uint16Array]"]=jt["[object Uint32Array]"]=!0,jt["[object Arguments]"]=jt["[object Array]"]=jt["[object ArrayBuffer]"]=jt["[object Boolean]"]=jt["[object DataView]"]=jt["[object Date]"]=jt["[object Error]"]=jt["[object Function]"]=jt["[object Map]"]=jt["[object Number]"]=jt["[object Object]"]=jt["[object RegExp]"]=jt["[object Set]"]=jt["[object String]"]=jt["[object WeakMap]"]=!1;var Ot="object"==typeof exports&&exports&&!exports.nodeType&&exports,xt=Ot&&"object"==typeof module&&module&&!module.nodeType&&module,At=xt&&xt.exports===Ot&&e.process,kt=function(){try{return xt&&xt.require&&xt.require("util").types||At&&At.binding&&At.binding("util")}catch(t){}}(),Et=kt&&kt.isTypedArray,zt=Et?St(Et):function(t){return p(t)&&ut(t.length)&&!!jt[d(t)]},Ft=Object.prototype.hasOwnProperty;function Pt(t,e){var r=y(t),n=!r&&vt(t),o=!r&&!n&&mt(t),i=!r&&!n&&!o&&zt(t),s=r||n||o||i,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],u=a.length;for(var c in t)!e&&!Ft.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||tt(c,u))||a.push(c);return a}function Tt(t,e){return function(r){return t(e(r))}}var Nt=Tt(Object.keys,Object),Mt=Object.prototype.hasOwnProperty;function It(t){return ct(t)?Pt(t):function(t){if(!lt(t))return Nt(t);var e=[];for(var r in Object(t))Mt.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var Dt=Object.prototype.hasOwnProperty;function $t(t){return ct(t)?Pt(t,!0):function(t){if(!S(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=lt(t),r=[];for(var n in t)("constructor"!=n||!e&&Dt.call(t,n))&&r.push(n);return r}(t)}var Wt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Rt=/^\w*$/;function Ct(t,e){if(y(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!w(t))||Rt.test(t)||!Wt.test(t)||null!=e&&t in Object(e)}var Vt=$(Object,"create"),Ut=Object.prototype.hasOwnProperty,qt=Object.prototype.hasOwnProperty;function Bt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Jt(t,e){for(var r=t.length;r--;)if(rt(t[r][0],e))return r;return-1}Bt.prototype.clear=function(){this.__data__=Vt?Vt(null):{},this.size=0},Bt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Bt.prototype.get=function(t){var e=this.__data__;if(Vt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Ut.call(e,t)?e[t]:void 0},Bt.prototype.has=function(t){var e=this.__data__;return Vt?void 0!==e[t]:qt.call(e,t)},Bt.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Vt&&void 0===e?"__lodash_hash_undefined__":e,this};var Lt=Array.prototype.splice;function Ht(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Ht.prototype.clear=function(){this.__data__=[],this.size=0},Ht.prototype.delete=function(t){var e=this.__data__,r=Jt(e,t);return!(r<0||(r==e.length-1?e.pop():Lt.call(e,r,1),--this.size,0))},Ht.prototype.get=function(t){var e=this.__data__,r=Jt(e,t);return r<0?void 0:e[r][1]},Ht.prototype.has=function(t){return Jt(this.__data__,t)>-1},Ht.prototype.set=function(t,e){var r=this.__data__,n=Jt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Gt=$(n,"Map");function Zt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Yt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Kt(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,o=e?e.apply(this,n):n[0],i=r.cache;if(i.has(o))return i.get(o);var s=t.apply(this,n);return r.cache=i.set(o,s)||i,s};return r.cache=new(Kt.Cache||Yt),r}Yt.prototype.clear=function(){this.size=0,this.__data__={hash:new Bt,map:new(Gt||Ht),string:new Bt}},Yt.prototype.delete=function(t){var e=Zt(this,t).delete(t);return this.size-=e?1:0,e},Yt.prototype.get=function(t){return Zt(this,t).get(t)},Yt.prototype.has=function(t){return Zt(this,t).has(t)},Yt.prototype.set=function(t,e){var r=Zt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Kt.Cache=Yt;var Qt,Xt,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ee=/\\(\\)?/g,re=(Qt=Kt(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(te,function(t,r,n,o){e.push(n?o.replace(ee,"$1"):r||t)}),e},function(t){return 500===Xt.size&&Xt.clear(),t}),Xt=Qt.cache,Qt);function ne(t,e){return y(t)?t:Ct(t,e)?[t]:re(function(t){return null==t?"":j(t)}(t))}var oe=1/0;function ie(t){if("string"==typeof t||w(t))return t;var e=t+"";return"0"==e&&1/t==-oe?"-0":e}function se(t,e){for(var r=0,n=(e=ne(e,t)).length;null!=t&&r<n;)t=t[ie(e[r++])];return r&&r==n?t:void 0}function ae(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var ue=Tt(Object.getPrototypeOf,Object);function ce(t){var e=this.__data__=new Ht(t);this.size=e.size}ce.prototype.clear=function(){this.__data__=new Ht,this.size=0},ce.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},ce.prototype.get=function(t){return this.__data__.get(t)},ce.prototype.has=function(t){return this.__data__.has(t)},ce.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Ht){var n=r.__data__;if(!Gt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Yt(n)}return r.set(t,e),this.size=r.size,this};var fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,le=fe&&"object"==typeof module&&module&&!module.nodeType&&module,he=le&&le.exports===fe?n.Buffer:void 0,de=he?he.allocUnsafe:void 0;function pe(){return[]}var ge=Object.prototype.propertyIsEnumerable,we=Object.getOwnPropertySymbols,ve=we?function(t){return null==t?[]:(t=Object(t),function(e,r){for(var n=-1,o=null==e?0:e.length,i=0,s=[];++n<o;){var a=e[n];ge.call(t,a)&&(s[i++]=a)}return s}(we(t)))}:pe,ye=ve,_e=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ae(e,ye(t)),t=ue(t);return e}:pe;function be(t,e,r){var n=e(t);return y(t)?n:ae(n,r(t))}function me(t){return be(t,It,ye)}function je(t){return be(t,$t,_e)}var Se=$(n,"DataView"),Oe=$(n,"Promise"),xe=$(n,"Set"),Ae="[object Map]",ke="[object Promise]",Ee="[object Set]",ze="[object WeakMap]",Fe="[object DataView]",Pe=M(Se),Te=M(Gt),Ne=M(Oe),Me=M(xe),Ie=M(V),De=d;(Se&&De(new Se(new ArrayBuffer(1)))!=Fe||Gt&&De(new Gt)!=Ae||Oe&&De(Oe.resolve())!=ke||xe&&De(new xe)!=Ee||V&&De(new V)!=ze)&&(De=function(t){var e=d(t),r="[object Object]"==e?t.constructor:void 0,n=r?M(r):"";if(n)switch(n){case Pe:return Fe;case Te:return Ae;case Ne:return ke;case Me:return Ee;case Ie:return ze}return e});var $e=De,We=Object.prototype.hasOwnProperty,Re=n.Uint8Array;function Ce(t){var e=new t.constructor(t.byteLength);return new Re(e).set(new Re(t)),e}var Ve=/\w*$/,Ue=o?o.prototype:void 0,qe=Ue?Ue.valueOf:void 0,Be="[object Boolean]",Je="[object Date]",Le="[object Map]",He="[object Number]",Ge="[object RegExp]",Ze="[object Set]",Ye="[object String]",Ke="[object Symbol]",Qe="[object ArrayBuffer]",Xe="[object DataView]",tr="[object Float32Array]",er="[object Float64Array]",rr="[object Int8Array]",nr="[object Int16Array]",or="[object Int32Array]",ir="[object Uint8Array]",sr="[object Uint8ClampedArray]",ar="[object Uint16Array]",ur="[object Uint32Array]",cr=kt&&kt.isMap,fr=cr?St(cr):function(t){return p(t)&&"[object Map]"==$e(t)},lr=kt&&kt.isSet,hr=lr?St(lr):function(t){return p(t)&&"[object Set]"==$e(t)},dr=1,pr=2,gr=4,wr="[object Arguments]",vr="[object Function]",yr="[object GeneratorFunction]",_r="[object Object]",br={};function mr(t,e,r,n,o,i){var s,a=e&dr,u=e&pr,c=e&gr;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!S(t))return t;var f=y(t);if(f){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&We.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return function(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}(t,s)}else{var l=$e(t),h=l==vr||l==yr;if(mt(t))return function(t,e){if(e)return t.slice();var r=t.length,n=de?de(r):new t.constructor(r);return t.copy(n),n}(t,a);if(l==_r||l==wr||h&&!o){if(s=u||h?{}:function(t){return"function"!=typeof t.constructor||lt(t)?{}:q(ue(t))}(t),!a)return u?function(t,e){return it(t,_e(t),e)}(t,function(t,e){return t&&it(e,$t(e),t)}(s,t)):function(t,e){return it(t,ye(t),e)}(t,function(t,e){return t&&it(e,It(e),t)}(s,t))}else{if(!br[l])return o?t:{};s=function(t,e,r){var n,o,i=t.constructor;switch(e){case Qe:return Ce(t);case Be:case Je:return new i(+t);case Xe:return function(t,e){var r=e?Ce(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case tr:case er:case rr:case nr:case or:case ir:case sr:case ar:case ur:return function(t,e){var r=e?Ce(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case Le:return new i;case He:case Ye:return new i(t);case Ge:return(o=new(n=t).constructor(n.source,Ve.exec(n))).lastIndex=n.lastIndex,o;case Ze:return new i;case Ke:return qe?Object(qe.call(t)):{}}}(t,l,a)}}i||(i=new ce);var d=i.get(t);if(d)return d;i.set(t,s),hr(t)?t.forEach(function(n){s.add(mr(n,e,r,n,t,i))}):fr(t)&&t.forEach(function(n,o){s.set(o,mr(n,e,r,o,t,i))});var p=f?void 0:(c?u?je:me:u?$t:It)(t);return function(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r););}(p||t,function(n,o){p&&(n=t[o=n]),ot(s,o,mr(n,e,r,o,t,i))}),s}function jr(t){return mr(t,4)}function Sr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Yt;++e<r;)this.add(t[e])}function Or(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function xr(t,e){return t.has(e)}br[wr]=br["[object Array]"]=br["[object ArrayBuffer]"]=br["[object DataView]"]=br["[object Boolean]"]=br["[object Date]"]=br["[object Float32Array]"]=br["[object Float64Array]"]=br["[object Int8Array]"]=br["[object Int16Array]"]=br["[object Int32Array]"]=br["[object Map]"]=br["[object Number]"]=br[_r]=br["[object RegExp]"]=br["[object Set]"]=br["[object String]"]=br["[object Symbol]"]=br["[object Uint8Array]"]=br["[object Uint8ClampedArray]"]=br["[object Uint16Array]"]=br["[object Uint32Array]"]=!0,br["[object Error]"]=br[vr]=br["[object WeakMap]"]=!1,Sr.prototype.add=Sr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Sr.prototype.has=function(t){return this.__data__.has(t)};var Ar=1,kr=2;function Er(t,e,r,n,o,i){var s=r&Ar,a=t.length,u=e.length;if(a!=u&&!(s&&u>a))return!1;var c=i.get(t),f=i.get(e);if(c&&f)return c==e&&f==t;var l=-1,h=!0,d=r&kr?new Sr:void 0;for(i.set(t,e),i.set(e,t);++l<a;){var p=t[l],g=e[l];if(n)var w=s?n(g,p,l,e,t,i):n(p,g,l,t,e,i);if(void 0!==w){if(w)continue;h=!1;break}if(d){if(!Or(e,function(t,e){if(!xr(d,e)&&(p===t||o(p,t,r,n,i)))return d.push(e)})){h=!1;break}}else if(p!==g&&!o(p,g,r,n,i)){h=!1;break}}return i.delete(t),i.delete(e),h}function zr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Fr(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Pr=1,Tr=2,Nr="[object Boolean]",Mr="[object Date]",Ir="[object Error]",Dr="[object Map]",$r="[object Number]",Wr="[object RegExp]",Rr="[object Set]",Cr="[object String]",Vr="[object Symbol]",Ur="[object ArrayBuffer]",qr="[object DataView]",Br=o?o.prototype:void 0,Jr=Br?Br.valueOf:void 0,Lr=1,Hr=Object.prototype.hasOwnProperty,Gr=1,Zr="[object Arguments]",Yr="[object Array]",Kr="[object Object]",Qr=Object.prototype.hasOwnProperty;function Xr(t,e,r,n,o){return t===e||(null==t||null==e||!p(t)&&!p(e)?t!=t&&e!=e:function(t,e,r,n,o,i){var s=y(t),a=y(e),u=s?Yr:$e(t),c=a?Yr:$e(e),f=(u=u==Zr?Kr:u)==Kr,l=(c=c==Zr?Kr:c)==Kr,h=u==c;if(h&&mt(t)){if(!mt(e))return!1;s=!0,f=!1}if(h&&!f)return i||(i=new ce),s||zt(t)?Er(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case qr:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Ur:return!(t.byteLength!=e.byteLength||!i(new Re(t),new Re(e)));case Nr:case Mr:case $r:return rt(+t,+e);case Ir:return t.name==e.name&&t.message==e.message;case Wr:case Cr:return t==e+"";case Dr:var a=zr;case Rr:if(a||(a=Fr),t.size!=e.size&&!(n&Pr))return!1;var u=s.get(t);if(u)return u==e;n|=Tr,s.set(t,e);var c=Er(a(t),a(e),n,o,i,s);return s.delete(t),c;case Vr:if(Jr)return Jr.call(t)==Jr.call(e)}return!1}(t,e,u,r,n,o,i);if(!(r&Gr)){var d=f&&Qr.call(t,"__wrapped__"),p=l&&Qr.call(e,"__wrapped__");if(d||p){var g=d?t.value():t,w=p?e.value():e;return i||(i=new ce),o(g,w,r,n,i)}}return!!h&&(i||(i=new ce),function(t,e,r,n,o,i){var s=r&Lr,a=me(t),u=a.length;if(u!=me(e).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in e:Hr.call(e,f)))return!1}var l=i.get(t),h=i.get(e);if(l&&h)return l==e&&h==t;var d=!0;i.set(t,e),i.set(e,t);for(var p=s;++c<u;){var g=t[f=a[c]],w=e[f];if(n)var v=s?n(w,g,f,e,t,i):n(g,w,f,t,e,i);if(!(void 0===v?g===w||o(g,w,r,n,i):v)){d=!1;break}p||(p="constructor"==f)}if(d&&!p){var y=t.constructor,_=e.constructor;y==_||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof _&&_ instanceof _||(d=!1)}return i.delete(t),i.delete(e),d}(t,e,r,n,o,i))}(t,e,r,n,Xr,o))}var tn=1,en=2;function rn(t){return t==t&&!S(t)}function nn(t,e){return function(r){return null!=r&&r[t]===e&&(void 0!==e||t in Object(r))}}function on(t,e){return null!=t&&e in Object(t)}var sn=1,an=2;function un(t){return"function"==typeof t?t:null==t?O:"object"==typeof t?y(t)?function(t,e){return Ct(t)&&rn(e)?nn(ie(t),e):function(r){var n=function(t,e,r){var n=null==t?void 0:se(t,e);return void 0===n?void 0:n}(r,t);return void 0===n&&n===e?function(t,e){return null!=t&&function(t,e,r){for(var n=-1,o=(e=ne(e,t)).length,i=!1;++n<o;){var s=ie(e[n]);if(!(i=null!=t&&r(t,s)))break;t=t[s]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&ut(o)&&tt(s,o)&&(y(t)||vt(t))}(t,e,on)}(r,t):Xr(e,n,sn|an)}}(t[0],t[1]):(o=function(t){for(var e=It(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,rn(o)]}return e}(n=t),1==o.length&&o[0][2]?nn(o[0][0],o[0][1]):function(t){return t===n||function(t,e,r,n){var o=r.length,i=o;if(null==t)return!i;for(t=Object(t);o--;){var s=r[o];if(s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++o<i;){var a=(s=r[o])[0],u=t[a],c=s[1];if(s[2]){if(void 0===u&&!(a in t))return!1}else{var f=new ce;if(!Xr(c,u,tn|en,void 0,f))return!1}}return!0}(t,0,o)}):Ct(e=t)?(r=ie(e),function(t){return null==t?void 0:t[r]}):function(t){return function(e){return se(e,t)}}(e);var e,r,n,o}function cn(t,e){return t&&function(t,e,r){for(var n=-1,o=Object(t),i=r(t),s=i.length;s--;){var a=i[++n];if(!1===e(o[a],a,o))break}return t}(t,e,It)}var fn,ln=(fn=cn,function(t,e){if(null==t)return t;if(!ct(t))return fn(t,e);for(var r=t.length,n=-1,o=Object(t);++n<r&&!1!==e(o[n],n,o););return t});function hn(t,e){var r=-1,n=ct(t)?Array(t.length):[];return ln(t,function(t,o,i){n[++r]=e(t,o,i)}),n}function dn(t,e){return t>e}var pn=Math.min;function gn(t){return function(t){return p(t)&&ct(t)}(t)?t:[]}var wn=function(t,e){return Z(function(t,e,r){return e=st(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=st(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,a)}}(t,void 0,O),t+"")}(function(t){var e=v(t,gn);return e.length&&e[0]===t[0]?function(t,e,r){for(var n=K,o=t[0].length,i=t.length,s=i,a=Array(i),u=Infinity,c=[];s--;){var f=t[s];u=pn(f.length,u),a[s]=o>=120&&f.length>=120?new Sr(s&&f):void 0}f=t[0];var l=-1,h=a[0];t:for(;++l<o&&c.length<u;){var d=f[l],p=d;if(d=0!==d?d:0,!(h?xr(h,p):n(c,p,r))){for(s=i;--s;){var g=a[s];if(!(g?xr(g,p):n(t[s],p,r)))continue t}h&&h.push(p),c.push(d)}}return c}(e):[]}),vn=wn;function yn(t,e){return t<e}function _n(t,e,r){for(var n=-1,o=t.length;++n<o;){var i=t[n],s=e(i);if(null!=s&&(void 0===a?s==s&&!w(s):r(s,a)))var a=s,u=i}return u}function bn(t,e){return t&&t.length?_n(t,un(e),dn):void 0}function mn(t,e){for(var r,n=-1,o=t.length;++n<o;){var i=e(t[n]);void 0!==i&&(r=void 0===r?i:r+i)}return r}function jn(t,e){return function(t,e){var r=null==t?0:t.length;return r?mn(t,e)/r:NaN}(t,un(e))}function Sn(t,e){if(t!==e){var r=void 0!==t,n=null===t,o=t==t,i=w(t),s=void 0!==e,a=null===e,u=e==e,c=w(e);if(!a&&!c&&!i&&t>e||i&&s&&u&&!a&&!c||n&&s&&u||!r&&u||!o)return 1;if(!n&&!i&&!c&&t<e||c&&r&&o&&!n&&!i||a&&r&&o||!s&&o||!u)return-1}return 0}function On(t,e,r,n){return null==t?[]:(y(e)||(e=null==e?[]:[e]),y(r=n?void 0:r)||(r=null==r?[]:[r]),function(t,e,r){e=e.length?v(e,function(t){return y(t)?function(e){return se(e,1===t.length?t[0]:t)}:t}):[O];var n=-1;return e=v(e,St(un)),function(t,e){var n=t.length;for(t.sort(function(t,e){return function(t,e,r){for(var n=-1,o=t.criteria,i=e.criteria,s=o.length,a=r.length;++n<s;){var u=Sn(o[n],i[n]);if(u)return n>=a?u:u*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)});n--;)t[n]=t[n].value;return t}(hn(t,function(t,r,o){return{criteria:v(e,function(e){return e(t)}),index:++n,value:t}}))}(t,e,r))}function xn(t,e){return t&&t.length?mn(t,un(e)):0}function An(t){if(this.words=[],t)if(Symbol&&Symbol.iterator&&void 0!==t[Symbol.iterator]){const e=t[Symbol.iterator]();let r=e.next();for(;!r.done;)this.add(r.value),r=e.next()}else for(let e=0;e<t.length;e++)this.add(t[e])}An.fromWords=function(t){const e=Object.create(An.prototype);return e.words=t,e},An.prototype.add=function(t){this.resize(t),this.words[t>>>5]|=1<<t},An.prototype.flip=function(t){this.resize(t),this.words[t>>>5]^=1<<t},An.prototype.clear=function(){this.words.length=0},An.prototype.remove=function(t){this.resize(t),this.words[t>>>5]&=~(1<<t)},An.prototype.isEmpty=function(t){const e=this.words.length;for(let t=0;t<e;t++)if(0!==this.words[t])return!1;return!0},An.prototype.has=function(t){return 0!=(this.words[t>>>5]&1<<t)},An.prototype.checkedAdd=function(t){this.resize(t);const e=this.words[t>>>5],r=e|1<<t;return this.words[t>>>5]=r,(r^e)>>>t},An.prototype.trim=function(t){let e=this.words.length;for(;e>0&&0===this.words[e-1];)e--;this.words.length=e},An.prototype.resize=function(t){const e=t+32>>>5;for(let t=this.words.length;t<e;t++)this.words[t]=0},An.prototype.hammingWeight=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},An.prototype.hammingWeight4=function(t,e,r,n){return 16843009*((t=(t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)+(e=(e=(858993459&(e-=e>>>1&1431655765))+(e>>>2&858993459))+(e>>>4)&252645135)+(r=(r=(858993459&(r-=r>>>1&1431655765))+(r>>>2&858993459))+(r>>>4)&252645135)+(n=(n=(858993459&(n-=n>>>1&1431655765))+(n>>>2&858993459))+(n>>>4)&252645135))>>>24},An.prototype.size=function(){let t=0;const e=this.words.length,r=this.words;for(let n=0;n<e;n++)t+=this.hammingWeight(r[n]);return t},An.prototype.array=function(){const t=new Array(this.size());let e=0;const r=this.words.length;for(let n=0;n<r;++n){let r=this.words[n];for(;0!=r;){const o=r&-r;t[e++]=(n<<5)+this.hammingWeight(o-1|0),r^=o}}return t},An.prototype.forEach=function(t){const e=this.words.length;for(let r=0;r<e;++r){let e=this.words[r];for(;0!=e;){const n=e&-e;t((r<<5)+this.hammingWeight(n-1|0)),e^=n}}},An.prototype[Symbol.iterator]=function(){const t=this.words.length;let e=0,r=this.words[e],n=this.hammingWeight,o=this.words;return{[Symbol.iterator](){return this},next(){for(;e<t;){if(0!==r){const t=r&-r,o=(e<<5)+n(t-1|0);return r^=t,{done:!1,value:o}}e++,e<t&&(r=o[e])}return{done:!0,value:void 0}}}},An.prototype.clone=function(){const t=Object.create(An.prototype);return t.words=this.words.slice(),t},An.prototype.intersects=function(t){const e=Math.min(this.words.length,t.words.length);for(let r=0;r<e;++r)if(0!=(this.words[r]&t.words[r]))return!0;return!1},An.prototype.intersection=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]&=t.words[r],this.words[r+1]&=t.words[r+1],this.words[r+2]&=t.words[r+2],this.words[r+3]&=t.words[r+3],this.words[r+4]&=t.words[r+4],this.words[r+5]&=t.words[r+5],this.words[r+6]&=t.words[r+6],this.words[r+7]&=t.words[r+7];for(;r<e;++r)this.words[r]&=t.words[r];const n=this.words.length;for(r=e;r<n;++r)this.words[r]=0;return this},An.prototype.intersection_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(let n=0;n<e;++n)r+=this.hammingWeight(this.words[n]&t.words[n]);return r},An.prototype.new_intersection=function(t){const e=Object.create(An.prototype),r=Math.min(this.words.length,t.words.length);e.words=new Array(r);let n=0;for(;n+7<r;n+=8)e.words[n]=this.words[n]&t.words[n],e.words[n+1]=this.words[n+1]&t.words[n+1],e.words[n+2]=this.words[n+2]&t.words[n+2],e.words[n+3]=this.words[n+3]&t.words[n+3],e.words[n+4]=this.words[n+4]&t.words[n+4],e.words[n+5]=this.words[n+5]&t.words[n+5],e.words[n+6]=this.words[n+6]&t.words[n+6],e.words[n+7]=this.words[n+7]&t.words[n+7];for(;n<r;++n)e.words[n]=this.words[n]&t.words[n];return e},An.prototype.equals=function(t){const e=Math.min(this.words.length,t.words.length);for(let r=0;r<e;++r)if(this.words[r]!=t.words[r])return!1;if(this.words.length<t.words.length){const e=t.words.length;for(let r=this.words.length;r<e;++r)if(0!=t.words[r])return!1}else if(t.words.length<this.words.length){const e=this.words.length;for(let r=t.words.length;r<e;++r)if(0!=this.words[r])return!1}return!0},An.prototype.difference=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]&=~t.words[r],this.words[r+1]&=~t.words[r+1],this.words[r+2]&=~t.words[r+2],this.words[r+3]&=~t.words[r+3],this.words[r+4]&=~t.words[r+4],this.words[r+5]&=~t.words[r+5],this.words[r+6]&=~t.words[r+6],this.words[r+7]&=~t.words[r+7];for(;r<e;++r)this.words[r]&=~t.words[r];return this},An.prototype.new_difference=function(t){return this.clone().difference(t)},An.prototype.difference2=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)t.words[r]=this.words[r]&~t.words[r],t.words[r+1]=this.words[r+1]&~t.words[r+1],t.words[r+2]=this.words[r+2]&~t.words[r+2],t.words[r+3]=this.words[r+3]&~t.words[r+3],t.words[r+4]=this.words[r+4]&~t.words[r+4],t.words[r+5]=this.words[r+5]&~t.words[r+5],t.words[r+6]=this.words[r+6]&~t.words[r+6],t.words[r+7]=this.words[r+7]&~t.words[r+7];for(;r<e;++r)t.words[r]=this.words[r]&~t.words[r];for(r=this.words.length-1;r>=e;--r)t.words[r]=this.words[r];return t.words.length=this.words.length,t},An.prototype.difference_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0,n=0;for(;n<e;++n)r+=this.hammingWeight(this.words[n]&~t.words[n]);const o=this.words.length;for(;n<o;++n)r+=this.hammingWeight(this.words[n]);return r},An.prototype.change=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]^=t.words[r],this.words[r+1]^=t.words[r+1],this.words[r+2]^=t.words[r+2],this.words[r+3]^=t.words[r+3],this.words[r+4]^=t.words[r+4],this.words[r+5]^=t.words[r+5],this.words[r+6]^=t.words[r+6],this.words[r+7]^=t.words[r+7];for(;r<e;++r)this.words[r]^=t.words[r];for(r=t.words.length-1;r>=e;--r)this.words[r]=t.words[r];return this},An.prototype.new_change=function(t){const e=Object.create(An.prototype),r=Math.max(this.words.length,t.words.length);e.words=new Array(r);const n=Math.min(this.words.length,t.words.length);let o=0;for(;o+7<n;o+=8)e.words[o]=this.words[o]^t.words[o],e.words[o+1]=this.words[o+1]^t.words[o+1],e.words[o+2]=this.words[o+2]^t.words[o+2],e.words[o+3]=this.words[o+3]^t.words[o+3],e.words[o+4]=this.words[o+4]^t.words[o+4],e.words[o+5]=this.words[o+5]^t.words[o+5],e.words[o+6]=this.words[o+6]^t.words[o+6],e.words[o+7]=this.words[o+7]^t.words[o+7];for(;o<n;++o)e.words[o]=this.words[o]^t.words[o];const i=this.words.length;for(o=n;o<i;++o)e.words[o]=this.words[o];const s=t.words.length;for(o=n;o<s;++o)e.words[o]=t.words[o];return e},An.prototype.change_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0,n=0;for(;n<e;++n)r+=this.hammingWeight(this.words[n]^t.words[n]);const o=this.words.length>t.words.length?this:t,i=o.words.length;for(;n<i;++n)r+=this.hammingWeight(o.words[n]);return r},An.prototype.toString=function(){return"{"+this.array().join(",")+"}"},An.prototype.union=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(;r+7<e;r+=8)this.words[r]|=t.words[r],this.words[r+1]|=t.words[r+1],this.words[r+2]|=t.words[r+2],this.words[r+3]|=t.words[r+3],this.words[r+4]|=t.words[r+4],this.words[r+5]|=t.words[r+5],this.words[r+6]|=t.words[r+6],this.words[r+7]|=t.words[r+7];for(;r<e;++r)this.words[r]|=t.words[r];if(this.words.length<t.words.length){this.resize((t.words.length<<5)-1);const r=t.words.length;for(let n=e;n<r;++n)this.words[n]=t.words[n]}return this},An.prototype.new_union=function(t){const e=Object.create(An.prototype),r=Math.max(this.words.length,t.words.length);e.words=new Array(r);const n=Math.min(this.words.length,t.words.length);let o=0;for(;o+7<n;o+=8)e.words[o]=this.words[o]|t.words[o],e.words[o+1]=this.words[o+1]|t.words[o+1],e.words[o+2]=this.words[o+2]|t.words[o+2],e.words[o+3]=this.words[o+3]|t.words[o+3],e.words[o+4]=this.words[o+4]|t.words[o+4],e.words[o+5]=this.words[o+5]|t.words[o+5],e.words[o+6]=this.words[o+6]|t.words[o+6],e.words[o+7]=this.words[o+7]|t.words[o+7];for(;o<n;++o)e.words[o]=this.words[o]|t.words[o];const i=this.words.length;for(o=n;o<i;++o)e.words[o]=this.words[o];const s=t.words.length;for(o=n;o<s;++o)e.words[o]=t.words[o];return e},An.prototype.union_size=function(t){const e=Math.min(this.words.length,t.words.length);let r=0;for(let n=0;n<e;++n)r+=this.hammingWeight(this.words[n]|t.words[n]);if(this.words.length<t.words.length){const e=t.words.length;for(let n=this.words.length;n<e;++n)r+=this.hammingWeight(0|t.words[n])}else{const e=this.words.length;for(let n=t.words.length;n<e;++n)r+=this.hammingWeight(0|this.words[n])}return r};var kn=An,En=function(t,e){if(!t||"object"!=typeof t)throw new Error("Invalid facets_data provided.");if(!e||"object"!=typeof e)return null;var r=Object.entries(e).flatMap(function(t){var e=t[0],r=t[1];return Array.isArray(r)?r.map(function(t){return{field:e,filter:t}}):[]});return 0===r.length?null:r.reduce(function(e,r){var n,o=(null==(n=t[r.field])?void 0:n[r.filter])||new kn([]);return e.new_union(o)},new kn([]))},zn=function(e,r,n){var o,i,s,a=1;return o=e.bits_data_temp,i=function(e,o){var i,s,u,c,f,l,h;n[o]&&(i=n[o].order,s=n[o].sort,u=n[o].size,c=n[o].title,f=n[o].show_facet_stats||!1,l=!1!==n[o].chosen_filters_on_top,h=n[o].hide_zero_doc_count||!1);var d,p,g,w,v,_=Object.entries(e).map(function(t){var e=[];r&&r.filters&&r.filters[o]&&(e=r.filters[o]);var n=t[1].array().length,i=e.some(function(e){return String(e)===String(t[0])});if(!h||0!==n||i)return{key:t[0],doc_count:n,selected:i}}).filter(Boolean);if(y(s)?(d=s||["key"],p=i||["asc"]):("term"===s||"key"===s?(d=["key"],p=[i||"asc"]):(d=["doc_count","key"],p=[i||"desc","asc"]),l&&(d.unshift("selected"),p.unshift("desc"))),_=(_=On(_,d,p)).slice(0,u||10),f){var b=[];Object.entries(e).forEach(function(t){if(isNaN(t[0]))throw new Error("You cant use chars to calculate the facet_stats.");t[1].array().length>0&&t[1].forEach(function(){b.push(parseInt(t[0]))})}),g={min:(w=b,w&&w.length?_n(w,un(void 0),yn):void 0),max:bn(b),avg:jn(b),sum:xn(b)}}return t({name:o,title:c||(v=o,v.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(t){return t.toUpperCase()})),position:a++,buckets:_},f&&{facet_stats:g})},s={},i=un(i),cn(o,function(t,e,r){et(s,e,i(t,e,r))}),s};function Fn(t,e){var r=[];return t.forEach(function(t){e.forEach(function(e){r.push(t.concat(e))})}),r}function Pn(t){return!!~t.search(/\(|\)/)}function Tn(t,e){for(var r=e.split(" "+t+" "),n=[],o=[],i=0;i<r.length;i++)if(Pn(r[i])||o.length>0){o.push(r[i]);var s=""+o;(s.match(/\(/g)||[]).length===(s.match(/\)/g)||[]).length&&(n.push(o.join(" "+t+" ")),o=[])}else n.push(r[i]);return n}var Nn=function t(e){return function(t){for(var e=t[0],r=1;r<t.length;r++)e=e.concat(t[r]);return e}(Tn("OR",(r=e=function(t){if("("===t.charAt(0))for(var e=0,r=0;r<t.length;r++)if("("===t.charAt(r)?e++:")"===t.charAt(r)&&e--,0===e)return r!==t.length-1?t:t.substring(1,t.length-1);return t}(e),e=r.replace(/[\s]+/g," "))).map(function(e){for(var r=Tn("AND",e),n=[],o=[],i=0;i<r.length;i++)Pn(r[i])?n.push(t(r[i])):o.push(r[i]);return n.push([o]),function(t){for(var e=[[]],r=0;r<t.length;r++)e=Fn(e,t[r]);return e}(n)}));var r},Mn=function(t){return"boolean"==typeof t?t?"AND":"OR":"string"==typeof t&&"OR"===t.toUpperCase()?"OR":"AND"},In=function(e,r){var n=r&&r.aggregations||{},o=Object.create(null),i=!1,s=t({},n);return Object.keys(e||{}).forEach(function(r){var a,u,c=n[r];if(c){var f=null==(a=e[r])?void 0:a.selected;Array.isArray(f)&&f.length&&(o[r]=f,i=!0);var l=null==(u=e[r])?void 0:u.options;if(l){var h={};if(void 0!==l.conjunction){var d=Mn(l.conjunction);h.conjunction="AND"===d}"number"==typeof l.size&&(h.size=l.size),"key"===l.sortBy?(h.sort="key",h.order=l.sortDir||c.order):"count"===l.sortBy?(h.sort=void 0,h.order=l.sortDir||c.order):l.sortDir&&(h.order=l.sortDir),"boolean"==typeof l.hideZero&&(h.hide_zero_doc_count=l.hideZero),"boolean"==typeof l.chosenOnTop&&(h.chosen_filters_on_top=l.chosenOnTop),"boolean"==typeof l.showStats&&(h.show_facet_stats=l.showStats),Object.keys(h).length&&(s[r]=t({},n[r],h))}}}),{hasFilters:i,filters:i?o:void 0,aggregations:s}};function Dn(t,e,r,n,o){var i=function(t){return"number"==typeof t?t:parseInt(t,10)},s=i((e=e||Object.create(null)).per_page);(!Number.isFinite(s)||s<0)&&(s=12);var a=i(e.page);(!Number.isFinite(a)||a<1)&&(a=1),0===s&&(a=1);var u=e.is_all_filtered_items||!1;if(!1===r.native_search_enabled&&e.query)throw new Error('The "query" option is not working once native search is disabled');var c,f,l,h=0,d=(new Date).getTime(),p=o.bits_ids();if(e._ids)c=new kn(e._ids),f=e._ids;else if(e.ids)f=o.internal_ids_from_ids_map(e.ids),e.filter&&(f=t.filter(function(t){return f.includes(t._id)}).filter(e.filter).map(function(t){return t._id})),c=new kn(f);else if(n&&(e.query||e.filter)){var g=(new Date).getTime();f=n.search(e.query,e.filter),h=(new Date).getTime()-g,c=new kn(f)}var w=(new Date).getTime(),v=o.search(e,{query_ids:c});if(w=(new Date).getTime()-w,c&&(p=c),v.ids&&(p=p.new_intersection(v.ids)),v.not_ids&&(p=p.new_difference(v.not_ids)),0===s&&!u&&!e.sort&&!f){var y=p.array(),_=(new Date).getTime()-d;return{pagination:{per_page:s,page:a,total:y.length},timings:{total:_,facets:w,search:h,sorting:0},data:{items:[],allFilteredItems:null,aggregations:zn(v,e,r.aggregations)}}}var b,m,j=!1,S=(new Date).getTime(),O=p.array();e.sort?m=function(t,e,r){if(r&&r[e]&&(e=r[e]),e.field){var n=Array.isArray(e.field)?e.field:[e.field],o=Array.isArray(e.order)?e.order:[e.order||"asc"],i=[],s=[];return n.forEach(function(t,e){i.push(function(e){return null==e[t]?1:0}),s.push("asc"),i.push(t),s.push(o[e]||"asc")}),On(t,i,s)}return t}(m=O.map(function(t){return o.get_item(t)}),e.sort,r.sortings):f?(m=(O=f.filter(function(t){return p.has(t)})).slice((a-1)*s,a*s).map(function(t){return o.get_item(t)}),j=!0):m=O.map(function(t){return o.get_item(t)}),j||(l=u?m:null,m=m.slice((a-1)*s,a*s)),b=(new Date).getTime()-S;var x=(new Date).getTime()-d;return{pagination:{per_page:s,page:a,total:O.length},timings:{total:x,facets:w,search:h,sorting:b},data:{items:m,allFilteredItems:l,aggregations:zn(v,e,r.aggregations)}}}var $n=function(t){var e={exports:{}};return function(t,e){!function(){var e,r,n,o,i,s,a,u,c,f,l,h,d,p,g,w,v,y,_,b,m,j,S,O,x,A,k,E,z=function(t){var e=new z.Index;return e.pipeline.add(z.trimmer,z.stopWordFilter,z.stemmer),t&&t.call(e,e),e};z.version="1.0.0",z.utils={},z.utils.warn=function(t){return function(e){t.console&&console.warn&&console.warn(e)}}(this),z.utils.asString=function(t){return null==t?"":t.toString()},z.EventEmitter=function(){this.events={}},z.EventEmitter.prototype.addListener=function(){var t=Array.prototype.slice.call(arguments),e=t.pop(),r=t;if("function"!=typeof e)throw new TypeError("last argument must be a function");r.forEach(function(t){this.hasHandler(t)||(this.events[t]=[]),this.events[t].push(e)},this)},z.EventEmitter.prototype.removeListener=function(t,e){if(this.hasHandler(t)){var r=this.events[t].indexOf(e);this.events[t].splice(r,1),this.events[t].length||delete this.events[t]}},z.EventEmitter.prototype.emit=function(t){if(this.hasHandler(t)){var e=Array.prototype.slice.call(arguments,1);this.events[t].forEach(function(t){t.apply(void 0,e)})}},z.EventEmitter.prototype.hasHandler=function(t){return t in this.events},z.tokenizer=function(t){return arguments.length&&null!=t&&null!=t?Array.isArray(t)?t.map(function(t){return z.utils.asString(t).toLowerCase()}):t.toString().trim().toLowerCase().split(z.tokenizer.separator):[]},z.tokenizer.separator=/[\s\-]+/,z.tokenizer.load=function(t){var e=this.registeredFunctions[t];if(!e)throw new Error("Cannot load un-registered function: "+t);return e},z.tokenizer.label="default",z.tokenizer.registeredFunctions={default:z.tokenizer},z.tokenizer.registerFunction=function(t,e){e in this.registeredFunctions&&z.utils.warn("Overwriting existing tokenizer: "+e),t.label=e,this.registeredFunctions[e]=t},z.Pipeline=function(){this._stack=[]},z.Pipeline.registeredFunctions={},z.Pipeline.registerFunction=function(t,e){e in this.registeredFunctions&&z.utils.warn("Overwriting existing registered function: "+e),t.label=e,z.Pipeline.registeredFunctions[t.label]=t},z.Pipeline.warnIfFunctionNotRegistered=function(t){t.label&&t.label in this.registeredFunctions||z.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",t)},z.Pipeline.load=function(t){var e=new z.Pipeline;return t.forEach(function(t){var r=z.Pipeline.registeredFunctions[t];if(!r)throw new Error("Cannot load un-registered function: "+t);e.add(r)}),e},z.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(t){z.Pipeline.warnIfFunctionNotRegistered(t),this._stack.push(t)},this)},z.Pipeline.prototype.after=function(t,e){z.Pipeline.warnIfFunctionNotRegistered(e);var r=this._stack.indexOf(t);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r+=1,0,e)},z.Pipeline.prototype.before=function(t,e){z.Pipeline.warnIfFunctionNotRegistered(e);var r=this._stack.indexOf(t);if(-1==r)throw new Error("Cannot find existingFn");this._stack.splice(r,0,e)},z.Pipeline.prototype.remove=function(t){var e=this._stack.indexOf(t);-1!=e&&this._stack.splice(e,1)},z.Pipeline.prototype.run=function(t){for(var e=[],r=t.length,n=this._stack.length,o=0;o<r;o++){for(var i=t[o],s=0;s<n&&void 0!==(i=this._stack[s](i,o,t))&&""!==i;s++);void 0!==i&&""!==i&&e.push(i)}return e},z.Pipeline.prototype.reset=function(){this._stack=[]},z.Pipeline.prototype.toJSON=function(){return this._stack.map(function(t){return z.Pipeline.warnIfFunctionNotRegistered(t),t.label})},z.Vector=function(){this._magnitude=null,this.list=void 0,this.length=0},z.Vector.Node=function(t,e,r){this.idx=t,this.val=e,this.next=r},z.Vector.prototype.insert=function(t,e){this._magnitude=void 0;var r=this.list;if(!r)return this.list=new z.Vector.Node(t,e,r),this.length++;if(t<r.idx)return this.list=new z.Vector.Node(t,e,r),this.length++;for(var n=r,o=r.next;null!=o;){if(t<o.idx)return n.next=new z.Vector.Node(t,e,o),this.length++;n=o,o=o.next}return n.next=new z.Vector.Node(t,e,o),this.length++},z.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var t,e=this.list,r=0;e;)r+=(t=e.val)*t,e=e.next;return this._magnitude=Math.sqrt(r)},z.Vector.prototype.dot=function(t){for(var e=this.list,r=t.list,n=0;e&&r;)e.idx<r.idx?e=e.next:(e.idx>r.idx||(n+=e.val*r.val,e=e.next),r=r.next);return n},z.Vector.prototype.similarity=function(t){return this.dot(t)/(this.magnitude()*t.magnitude())},z.SortedSet=function(){this.length=0,this.elements=[]},z.SortedSet.load=function(t){var e=new this;return e.elements=t,e.length=t.length,e},z.SortedSet.prototype.add=function(){var t,e;for(t=0;t<arguments.length;t++)~this.indexOf(e=arguments[t])||this.elements.splice(this.locationFor(e),0,e);this.length=this.elements.length},z.SortedSet.prototype.toArray=function(){return this.elements.slice()},z.SortedSet.prototype.map=function(t,e){return this.elements.map(t,e)},z.SortedSet.prototype.forEach=function(t,e){return this.elements.forEach(t,e)},z.SortedSet.prototype.indexOf=function(t){for(var e=0,r=this.elements.length,n=r-e,o=e+Math.floor(n/2),i=this.elements[o];n>1;){if(i===t)return o;i<t&&(e=o),i>t&&(r=o),n=r-e,o=e+Math.floor(n/2),i=this.elements[o]}return i===t?o:-1},z.SortedSet.prototype.locationFor=function(t){for(var e=0,r=this.elements.length,n=r-e,o=e+Math.floor(n/2),i=this.elements[o];n>1;)i<t&&(e=o),i>t&&(r=o),n=r-e,o=e+Math.floor(n/2),i=this.elements[o];return i>t?o:i<t?o+1:void 0},z.SortedSet.prototype.intersect=function(t){for(var e=new z.SortedSet,r=0,n=0,o=this.length,i=t.length,s=this.elements,a=t.elements;!(r>o-1||n>i-1);)s[r]!==a[n]?s[r]<a[n]?r++:s[r]>a[n]&&n++:(e.add(s[r]),r++,n++);return e},z.SortedSet.prototype.clone=function(){var t=new z.SortedSet;return t.elements=this.toArray(),t.length=t.elements.length,t},z.SortedSet.prototype.union=function(t){var e,r,n;this.length>=t.length?(e=this,r=t):(e=t,r=this),n=e.clone();for(var o=0,i=r.toArray();o<i.length;o++)n.add(i[o]);return n},z.SortedSet.prototype.toJSON=function(){return this.toArray()},z.Index=function(){this._fields=[],this._ref="id",this.pipeline=new z.Pipeline,this.documentStore=new z.Store,this.tokenStore=new z.TokenStore,this.corpusTokens=new z.SortedSet,this.eventEmitter=new z.EventEmitter,this.tokenizerFn=z.tokenizer,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},z.Index.prototype.on=function(){var t=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,t)},z.Index.prototype.off=function(t,e){return this.eventEmitter.removeListener(t,e)},z.Index.load=function(t){t.version!==z.version&&z.utils.warn("version mismatch: current "+z.version+" importing "+t.version);var e=new this;return e._fields=t.fields,e._ref=t.ref,e.tokenizer(z.tokenizer.load(t.tokenizer)),e.documentStore=z.Store.load(t.documentStore),e.tokenStore=z.TokenStore.load(t.tokenStore),e.corpusTokens=z.SortedSet.load(t.corpusTokens),e.pipeline=z.Pipeline.load(t.pipeline),e},z.Index.prototype.field=function(t,e){return this._fields.push({name:t,boost:(e=e||{}).boost||1}),this},z.Index.prototype.ref=function(t){return this._ref=t,this},z.Index.prototype.tokenizer=function(t){return t.label&&t.label in z.tokenizer.registeredFunctions||z.utils.warn("Function is not a registered tokenizer. This may cause problems when serialising the index"),this.tokenizerFn=t,this},z.Index.prototype.add=function(t,e){var r={},n=new z.SortedSet,o=t[this._ref];e=void 0===e||e,this._fields.forEach(function(e){var o=this.pipeline.run(this.tokenizerFn(t[e.name]));r[e.name]=o;for(var i=0;i<o.length;i++){var s=o[i];n.add(s),this.corpusTokens.add(s)}},this),this.documentStore.set(o,n);for(var i=0;i<n.length;i++){for(var s=n.elements[i],a=0,u=0;u<this._fields.length;u++){var c=this._fields[u],f=r[c.name],l=f.length;if(l){for(var h=0,d=0;d<l;d++)f[d]===s&&h++;a+=h/l*c.boost}}this.tokenStore.add(s,{ref:o,tf:a})}e&&this.eventEmitter.emit("add",t,this)},z.Index.prototype.remove=function(t,e){var r=t[this._ref];if(e=void 0===e||e,this.documentStore.has(r)){var n=this.documentStore.get(r);this.documentStore.remove(r),n.forEach(function(t){this.tokenStore.remove(t,r)},this),e&&this.eventEmitter.emit("remove",t,this)}},z.Index.prototype.update=function(t,e){e=void 0===e||e,this.remove(t,!1),this.add(t,!1),e&&this.eventEmitter.emit("update",t,this)},z.Index.prototype.idf=function(t){var e="@"+t;if(Object.prototype.hasOwnProperty.call(this._idfCache,e))return this._idfCache[e];var r=this.tokenStore.count(t),n=1;return r>0&&(n=1+Math.log(this.documentStore.length/r)),this._idfCache[e]=n},z.Index.prototype.search=function(t){var e=this.pipeline.run(this.tokenizerFn(t)),r=new z.Vector,n=[],o=this._fields.reduce(function(t,e){return t+e.boost},0);return e.some(function(t){return this.tokenStore.has(t)},this)?(e.forEach(function(t,e,i){var s=1/i.length*this._fields.length*o,a=this,u=this.tokenStore.expand(t).reduce(function(e,n){var o=a.corpusTokens.indexOf(n),i=a.idf(n),u=1,c=new z.SortedSet;if(n!==t){var f=Math.max(3,n.length-t.length);u=1/Math.log(f)}o>-1&&r.insert(o,s*i*u);for(var l=a.tokenStore.get(n),h=Object.keys(l),d=h.length,p=0;p<d;p++)c.add(l[h[p]].ref);return e.union(c)},new z.SortedSet);n.push(u)},this),n.reduce(function(t,e){return t.intersect(e)}).map(function(t){return{ref:t,score:r.similarity(this.documentVector(t))}},this).sort(function(t,e){return e.score-t.score})):[]},z.Index.prototype.documentVector=function(t){for(var e=this.documentStore.get(t),r=e.length,n=new z.Vector,o=0;o<r;o++){var i=e.elements[o],s=this.tokenStore.get(i)[t].tf,a=this.idf(i);n.insert(this.corpusTokens.indexOf(i),s*a)}return n},z.Index.prototype.toJSON=function(){return{version:z.version,fields:this._fields,ref:this._ref,tokenizer:this.tokenizerFn.label,documentStore:this.documentStore.toJSON(),tokenStore:this.tokenStore.toJSON(),corpusTokens:this.corpusTokens.toJSON(),pipeline:this.pipeline.toJSON()}},z.Index.prototype.use=function(t){var e=Array.prototype.slice.call(arguments,1);e.unshift(this),t.apply(this,e)},z.Store=function(){this.store={},this.length=0},z.Store.load=function(t){var e=new this;return e.length=t.length,e.store=Object.keys(t.store).reduce(function(e,r){return e[r]=z.SortedSet.load(t.store[r]),e},{}),e},z.Store.prototype.set=function(t,e){this.has(t)||this.length++,this.store[t]=e},z.Store.prototype.get=function(t){return this.store[t]},z.Store.prototype.has=function(t){return t in this.store},z.Store.prototype.remove=function(t){this.has(t)&&(delete this.store[t],this.length--)},z.Store.prototype.toJSON=function(){return{store:this.store,length:this.length}},z.stemmer=(e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},r={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},s="^("+(o="[^aeiou][^aeiouy]*")+")?"+(i=(n="[aeiouy]")+"[aeiou]*")+o+"("+i+")?$",a="^("+o+")?"+i+o+i+o,u="^("+o+")?"+n,c=new RegExp("^("+o+")?"+i+o),f=new RegExp(a),l=new RegExp(s),h=new RegExp(u),d=/^(.+?)(ss|i)es$/,p=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,w=/^(.+?)(ed|ing)$/,v=/.$/,y=/(at|bl|iz)$/,_=new RegExp("([^aeiouylsz])\\1$"),b=new RegExp("^"+o+n+"[^aeiouwxy]$"),m=/^(.+?[^aeiou])y$/,j=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,S=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,O=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,x=/^(.+?)(s|t)(ion)$/,A=/^(.+?)e$/,k=/ll$/,E=new RegExp("^"+o+n+"[^aeiouwxy]$"),function(t){var n,o,i,s,a,u,z;if(t.length<3)return t;if("y"==(i=t.substr(0,1))&&(t=i.toUpperCase()+t.substr(1)),a=p,(s=d).test(t)?t=t.replace(s,"$1$2"):a.test(t)&&(t=t.replace(a,"$1$2")),a=w,(s=g).test(t)){var F=s.exec(t);(s=c).test(F[1])&&(t=t.replace(s=v,""))}else a.test(t)&&(F=a.exec(t),(a=h).test(n=F[1])&&(u=_,z=b,(a=y).test(t=n)?t+="e":u.test(t)?t=t.replace(s=v,""):z.test(t)&&(t+="e")));return(s=m).test(t)&&(t=(n=(F=s.exec(t))[1])+"i"),(s=j).test(t)&&(o=(F=s.exec(t))[2],(s=c).test(n=F[1])&&(t=n+e[o])),(s=S).test(t)&&(o=(F=s.exec(t))[2],(s=c).test(n=F[1])&&(t=n+r[o])),a=x,(s=O).test(t)?(F=s.exec(t),(s=f).test(n=F[1])&&(t=n)):a.test(t)&&(F=a.exec(t),(a=f).test(n=F[1]+F[2])&&(t=n)),(s=A).test(t)&&(F=s.exec(t),a=l,u=E,((s=f).test(n=F[1])||a.test(n)&&!u.test(n))&&(t=n)),a=f,(s=k).test(t)&&a.test(t)&&(t=t.replace(s=v,"")),"y"==i&&(t=i.toLowerCase()+t.substr(1)),t}),z.Pipeline.registerFunction(z.stemmer,"stemmer"),z.generateStopWordFilter=function(t){var e=t.reduce(function(t,e){return t[e]=e,t},{});return function(t){if(t&&e[t]!==t)return t}},z.stopWordFilter=z.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