UNPKG

itemsjs

Version:

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

1 lines 56.9 kB
var t="object"==typeof global&&global&&global.Object===Object&&global,e="object"==typeof self&&self&&self.Object===Object&&self,r=t||e||Function("return this")(),n=r.Symbol,o=Object.prototype,i=o.hasOwnProperty,s=o.toString,a=n?n.toStringTag:void 0,u=Object.prototype.toString,c="[object Null]",f="[object Undefined]",h=n?n.toStringTag:void 0;function l(t){return null==t?void 0===t?f:c:h&&h in Object(t)?function(t){var e=i.call(t,a),r=t[a];try{t[a]=void 0;var n=!0}catch(t){}var o=s.call(t);return n&&(e?t[a]=r:delete t[a]),o}(t):function(t){return u.call(t)}(t)}function d(t){return null!=t&&"object"==typeof t}var p="[object Symbol]";function w(t){return"symbol"==typeof t||d(t)&&l(t)==p}function g(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 v=Array.isArray,y=1/0,_=n?n.prototype:void 0,b=_?_.toString:void 0;function m(t){if("string"==typeof t)return t;if(v(t))return g(t,m)+"";if(w(t))return b?b.call(t):"";var e=t+"";return"0"==e&&1/t==-y?"-0":e}function j(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function S(t){return t}var O="[object AsyncFunction]",x="[object Function]",k="[object GeneratorFunction]",A="[object Proxy]";function E(t){if(!j(t))return!1;var e=l(t);return e==x||e==k||e==O||e==A}var z,F=r["__core-js_shared__"],P=(z=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+z:"",T=Function.prototype.toString;function I(t){if(null!=t){try{return T.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var M=/^\[object .+?Constructor\]$/,N=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!(!j(t)||(e=t,P&&P in e))&&(E(t)?N:M).test(I(t));var e}(r)?r:void 0}var W,C,D,V=$(r,"WeakMap"),R=Object.create,U=function(){function t(){}return function(e){if(!j(e))return{};if(R)return R(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),q=Date.now,L=function(){try{var t=$(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),B=L,J=B?function(t,e){return B(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:S,H=(W=J,C=0,D=0,function(){var t=q(),e=16-(t-D);if(D=t,e>0){if(++C>=800)return arguments[0]}else C=0;return W.apply(void 0,arguments)});function G(t){return t!=t}function Y(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,G)}(t,e)>-1}var K=9007199254740991,Q=/^(?:0|[1-9]\d*)$/;function X(t,e){var r=typeof t;return!!(e=null==e?K:e)&&("number"==r||"symbol"!=r&&Q.test(t))&&t>-1&&t%1==0&&t<e}function Z(t,e,r){"__proto__"==e&&B?B(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}function tt(t,e){return t===e||t!=t&&e!=e}var et=Object.prototype.hasOwnProperty;function rt(t,e,r){var n=t[e];et.call(t,e)&&tt(n,r)&&(void 0!==r||e in t)||Z(t,e,r)}function nt(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?Z(r,a,u):rt(r,a,u)}return r}var ot=Math.max;function it(t,e){return H(function(t,e,r){return e=ot(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=ot(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,e,S),t+"")}var st=9007199254740991;function at(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=st}function ut(t){return null!=t&&at(t.length)&&!E(t)}function ct(t,e,r){if(!j(r))return!1;var n=typeof e;return!!("number"==n?ut(r)&&X(e,r.length):"string"==n&&e in r)&&tt(r[e],t)}var ft=Object.prototype;function ht(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ft)}function lt(t){return d(t)&&"[object Arguments]"==l(t)}var dt=Object.prototype,pt=dt.hasOwnProperty,wt=dt.propertyIsEnumerable,gt=lt(function(){return arguments}())?lt:function(t){return d(t)&&pt.call(t,"callee")&&!wt.call(t,"callee")},vt="object"==typeof exports&&exports&&!exports.nodeType&&exports,yt=vt&&"object"==typeof module&&module&&!module.nodeType&&module,_t=yt&&yt.exports===vt?r.Buffer:void 0,bt=(_t?_t.isBuffer:void 0)||function(){return!1},mt={};function jt(t){return function(e){return t(e)}}mt["[object Float32Array]"]=mt["[object Float64Array]"]=mt["[object Int8Array]"]=mt["[object Int16Array]"]=mt["[object Int32Array]"]=mt["[object Uint8Array]"]=mt["[object Uint8ClampedArray]"]=mt["[object Uint16Array]"]=mt["[object Uint32Array]"]=!0,mt["[object Arguments]"]=mt["[object Array]"]=mt["[object ArrayBuffer]"]=mt["[object Boolean]"]=mt["[object DataView]"]=mt["[object Date]"]=mt["[object Error]"]=mt["[object Function]"]=mt["[object Map]"]=mt["[object Number]"]=mt["[object Object]"]=mt["[object RegExp]"]=mt["[object Set]"]=mt["[object String]"]=mt["[object WeakMap]"]=!1;var St="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ot=St&&"object"==typeof module&&module&&!module.nodeType&&module,xt=Ot&&Ot.exports===St&&t.process,kt=function(){try{return Ot&&Ot.require&&Ot.require("util").types||xt&&xt.binding&&xt.binding("util")}catch(t){}}(),At=kt&&kt.isTypedArray,Et=At?jt(At):function(t){return d(t)&&at(t.length)&&!!mt[l(t)]},zt=Object.prototype.hasOwnProperty;function Ft(t,e){var r=v(t),n=!r&&gt(t),o=!r&&!n&&bt(t),i=!r&&!n&&!o&&Et(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&&!zt.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||X(c,u))||a.push(c);return a}function Pt(t,e){return function(r){return t(e(r))}}var Tt=Pt(Object.keys,Object),It=Object.prototype.hasOwnProperty;function Mt(t){return ut(t)?Ft(t):function(t){if(!ht(t))return Tt(t);var e=[];for(var r in Object(t))It.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}var Nt=Object.prototype.hasOwnProperty;function $t(t){return ut(t)?Ft(t,!0):function(t){if(!j(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=ht(t),r=[];for(var n in t)("constructor"!=n||!e&&Nt.call(t,n))&&r.push(n);return r}(t)}var Wt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ct=/^\w*$/;function Dt(t,e){if(v(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!w(t))||Ct.test(t)||!Wt.test(t)||null!=e&&t in Object(e)}var Vt=$(Object,"create"),Rt=Object.prototype.hasOwnProperty,Ut=Object.prototype.hasOwnProperty;function qt(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 Lt(t,e){for(var r=t.length;r--;)if(tt(t[r][0],e))return r;return-1}qt.prototype.clear=function(){this.__data__=Vt?Vt(null):{},this.size=0},qt.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},qt.prototype.get=function(t){var e=this.__data__;if(Vt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Rt.call(e,t)?e[t]:void 0},qt.prototype.has=function(t){var e=this.__data__;return Vt?void 0!==e[t]:Ut.call(e,t)},qt.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 Bt=Array.prototype.splice;function Jt(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])}}Jt.prototype.clear=function(){this.__data__=[],this.size=0},Jt.prototype.delete=function(t){var e=this.__data__,r=Lt(e,t);return!(r<0||(r==e.length-1?e.pop():Bt.call(e,r,1),--this.size,0))},Jt.prototype.get=function(t){var e=this.__data__,r=Lt(e,t);return r<0?void 0:e[r][1]},Jt.prototype.has=function(t){return Lt(this.__data__,t)>-1},Jt.prototype.set=function(t,e){var r=this.__data__,n=Lt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var Ht=$(r,"Map");function Gt(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 qt,map:new(Ht||Jt),string:new qt}},Yt.prototype.delete=function(t){var e=Gt(this,t).delete(t);return this.size-=e?1:0,e},Yt.prototype.get=function(t){return Gt(this,t).get(t)},Yt.prototype.has=function(t){return Gt(this,t).has(t)},Yt.prototype.set=function(t,e){var r=Gt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Kt.Cache=Yt;var Qt,Xt,Zt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,te=/\\(\\)?/g,ee=(Qt=Kt(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(Zt,function(t,r,n,o){e.push(n?o.replace(te,"$1"):r||t)}),e},function(t){return 500===Xt.size&&Xt.clear(),t}),Xt=Qt.cache,Qt);function re(t,e){return v(t)?t:Dt(t,e)?[t]:ee(function(t){return null==t?"":m(t)}(t))}var ne=1/0;function oe(t){if("string"==typeof t||w(t))return t;var e=t+"";return"0"==e&&1/t==-ne?"-0":e}function ie(t,e){for(var r=0,n=(e=re(e,t)).length;null!=t&&r<n;)t=t[oe(e[r++])];return r&&r==n?t:void 0}function se(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}var ae=n?n.isConcatSpreadable:void 0;function ue(t){return v(t)||gt(t)||!!(ae&&t&&t[ae])}function ce(t,e,r,n,o){var i=-1,s=t.length;for(r||(r=ue),o||(o=[]);++i<s;){var a=t[i];e>0&&r(a)?e>1?ce(a,e-1,r,n,o):se(o,a):n||(o[o.length]=a)}return o}var fe=Pt(Object.getPrototypeOf,Object);function he(t){var e=this.__data__=new Jt(t);this.size=e.size}he.prototype.clear=function(){this.__data__=new Jt,this.size=0},he.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},he.prototype.get=function(t){return this.__data__.get(t)},he.prototype.has=function(t){return this.__data__.has(t)},he.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Jt){var n=r.__data__;if(!Ht||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 le="object"==typeof exports&&exports&&!exports.nodeType&&exports,de=le&&"object"==typeof module&&module&&!module.nodeType&&module,pe=de&&de.exports===le?r.Buffer:void 0,we=pe?pe.allocUnsafe:void 0;function ge(){return[]}var ve=Object.prototype.propertyIsEnumerable,ye=Object.getOwnPropertySymbols,_e=ye?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];ve.call(t,a)&&(s[i++]=a)}return s}(ye(t)))}:ge,be=_e,me=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)se(e,be(t)),t=fe(t);return e}:ge;function je(t,e,r){var n=e(t);return v(t)?n:se(n,r(t))}function Se(t){return je(t,Mt,be)}function Oe(t){return je(t,$t,me)}var xe=$(r,"DataView"),ke=$(r,"Promise"),Ae=$(r,"Set"),Ee="[object Map]",ze="[object Promise]",Fe="[object Set]",Pe="[object WeakMap]",Te="[object DataView]",Ie=I(xe),Me=I(Ht),Ne=I(ke),$e=I(Ae),We=I(V),Ce=l;(xe&&Ce(new xe(new ArrayBuffer(1)))!=Te||Ht&&Ce(new Ht)!=Ee||ke&&Ce(ke.resolve())!=ze||Ae&&Ce(new Ae)!=Fe||V&&Ce(new V)!=Pe)&&(Ce=function(t){var e=l(t),r="[object Object]"==e?t.constructor:void 0,n=r?I(r):"";if(n)switch(n){case Ie:return Te;case Me:return Ee;case Ne:return ze;case $e:return Fe;case We:return Pe}return e});var De=Ce,Ve=Object.prototype.hasOwnProperty,Re=r.Uint8Array;function Ue(t){var e=new t.constructor(t.byteLength);return new Re(e).set(new Re(t)),e}var qe=/\w*$/,Le=n?n.prototype:void 0,Be=Le?Le.valueOf:void 0,Je="[object Boolean]",He="[object Date]",Ge="[object Map]",Ye="[object Number]",Ke="[object RegExp]",Qe="[object Set]",Xe="[object String]",Ze="[object Symbol]",tr="[object ArrayBuffer]",er="[object DataView]",rr="[object Float32Array]",nr="[object Float64Array]",or="[object Int8Array]",ir="[object Int16Array]",sr="[object Int32Array]",ar="[object Uint8Array]",ur="[object Uint8ClampedArray]",cr="[object Uint16Array]",fr="[object Uint32Array]",hr=kt&&kt.isMap,lr=hr?jt(hr):function(t){return d(t)&&"[object Map]"==De(t)},dr=kt&&kt.isSet,pr=dr?jt(dr):function(t){return d(t)&&"[object Set]"==De(t)},wr=1,gr=2,vr=4,yr="[object Arguments]",_r="[object Function]",br="[object GeneratorFunction]",mr="[object Object]",jr={};function Sr(t,e,r,n,o,i){var s,a=e&wr,u=e&gr,c=e&vr;if(r&&(s=o?r(t,n,o,i):r(t)),void 0!==s)return s;if(!j(t))return t;var f=v(t);if(f){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Ve.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 h=De(t),l=h==_r||h==br;if(bt(t))return function(t,e){if(e)return t.slice();var r=t.length,n=we?we(r):new t.constructor(r);return t.copy(n),n}(t,a);if(h==mr||h==yr||l&&!o){if(s=u||l?{}:function(t){return"function"!=typeof t.constructor||ht(t)?{}:U(fe(t))}(t),!a)return u?function(t,e){return nt(t,me(t),e)}(t,function(t,e){return t&&nt(e,$t(e),t)}(s,t)):function(t,e){return nt(t,be(t),e)}(t,function(t,e){return t&&nt(e,Mt(e),t)}(s,t))}else{if(!jr[h])return o?t:{};s=function(t,e,r){var n,o,i=t.constructor;switch(e){case tr:return Ue(t);case Je:case He:return new i(+t);case er:return function(t,e){var r=e?Ue(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case rr:case nr:case or:case ir:case sr:case ar:case ur:case cr:case fr:return function(t,e){var r=e?Ue(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case Ge:return new i;case Ye:case Xe:return new i(t);case Ke:return(o=new(n=t).constructor(n.source,qe.exec(n))).lastIndex=n.lastIndex,o;case Qe:return new i;case Ze:return Be?Object(Be.call(t)):{}}}(t,h,a)}}i||(i=new he);var d=i.get(t);if(d)return d;i.set(t,s),pr(t)?t.forEach(function(n){s.add(Sr(n,e,r,n,t,i))}):lr(t)&&t.forEach(function(n,o){s.set(o,Sr(n,e,r,o,t,i))});var p=f?void 0:(c?u?Oe:Se:u?$t:Mt)(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]),rt(s,o,Sr(n,e,r,o,t,i))}),s}function Or(t){return Sr(t,4)}function xr(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Yt;++e<r;)this.add(t[e])}function kr(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 Ar(t,e){return t.has(e)}jr[yr]=jr["[object Array]"]=jr["[object ArrayBuffer]"]=jr["[object DataView]"]=jr["[object Boolean]"]=jr["[object Date]"]=jr["[object Float32Array]"]=jr["[object Float64Array]"]=jr["[object Int8Array]"]=jr["[object Int16Array]"]=jr["[object Int32Array]"]=jr["[object Map]"]=jr["[object Number]"]=jr[mr]=jr["[object RegExp]"]=jr["[object Set]"]=jr["[object String]"]=jr["[object Symbol]"]=jr["[object Uint8Array]"]=jr["[object Uint8ClampedArray]"]=jr["[object Uint16Array]"]=jr["[object Uint32Array]"]=!0,jr["[object Error]"]=jr[_r]=jr["[object WeakMap]"]=!1,xr.prototype.add=xr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},xr.prototype.has=function(t){return this.__data__.has(t)};var Er=1,zr=2;function Fr(t,e,r,n,o,i){var s=r&Er,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 h=-1,l=!0,d=r&zr?new xr:void 0;for(i.set(t,e),i.set(e,t);++h<a;){var p=t[h],w=e[h];if(n)var g=s?n(w,p,h,e,t,i):n(p,w,h,t,e,i);if(void 0!==g){if(g)continue;l=!1;break}if(d){if(!kr(e,function(t,e){if(!Ar(d,e)&&(p===t||o(p,t,r,n,i)))return d.push(e)})){l=!1;break}}else if(p!==w&&!o(p,w,r,n,i)){l=!1;break}}return i.delete(t),i.delete(e),l}function Pr(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function Tr(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Ir=1,Mr=2,Nr="[object Boolean]",$r="[object Date]",Wr="[object Error]",Cr="[object Map]",Dr="[object Number]",Vr="[object RegExp]",Rr="[object Set]",Ur="[object String]",qr="[object Symbol]",Lr="[object ArrayBuffer]",Br="[object DataView]",Jr=n?n.prototype:void 0,Hr=Jr?Jr.valueOf:void 0,Gr=1,Yr=Object.prototype.hasOwnProperty,Kr=1,Qr="[object Arguments]",Xr="[object Array]",Zr="[object Object]",tn=Object.prototype.hasOwnProperty;function en(t,e,r,n,o){return t===e||(null==t||null==e||!d(t)&&!d(e)?t!=t&&e!=e:function(t,e,r,n,o,i){var s=v(t),a=v(e),u=s?Xr:De(t),c=a?Xr:De(e),f=(u=u==Qr?Zr:u)==Zr,h=(c=c==Qr?Zr:c)==Zr,l=u==c;if(l&&bt(t)){if(!bt(e))return!1;s=!0,f=!1}if(l&&!f)return i||(i=new he),s||Et(t)?Fr(t,e,r,n,o,i):function(t,e,r,n,o,i,s){switch(r){case Br:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Lr:return!(t.byteLength!=e.byteLength||!i(new Re(t),new Re(e)));case Nr:case $r:case Dr:return tt(+t,+e);case Wr:return t.name==e.name&&t.message==e.message;case Vr:case Ur:return t==e+"";case Cr:var a=Pr;case Rr:if(a||(a=Tr),t.size!=e.size&&!(n&Ir))return!1;var u=s.get(t);if(u)return u==e;n|=Mr,s.set(t,e);var c=Fr(a(t),a(e),n,o,i,s);return s.delete(t),c;case qr:if(Hr)return Hr.call(t)==Hr.call(e)}return!1}(t,e,u,r,n,o,i);if(!(r&Kr)){var d=f&&tn.call(t,"__wrapped__"),p=h&&tn.call(e,"__wrapped__");if(d||p){var w=d?t.value():t,g=p?e.value():e;return i||(i=new he),o(w,g,r,n,i)}}return!!l&&(i||(i=new he),function(t,e,r,n,o,i){var s=r&Gr,a=Se(t),u=a.length;if(u!=Se(e).length&&!s)return!1;for(var c=u;c--;){var f=a[c];if(!(s?f in e:Yr.call(e,f)))return!1}var h=i.get(t),l=i.get(e);if(h&&l)return h==e&&l==t;var d=!0;i.set(t,e),i.set(e,t);for(var p=s;++c<u;){var w=t[f=a[c]],g=e[f];if(n)var v=s?n(g,w,f,e,t,i):n(w,g,f,t,e,i);if(!(void 0===v?w===g||o(w,g,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,en,o))}var rn=1,nn=2;function on(t){return t==t&&!j(t)}function sn(t,e){return function(r){return null!=r&&r[t]===e&&(void 0!==e||t in Object(r))}}function an(t,e){return null!=t&&e in Object(t)}var un=1,cn=2;function fn(t){return"function"==typeof t?t:null==t?S:"object"==typeof t?v(t)?function(t,e){return Dt(t)&&on(e)?sn(oe(t),e):function(r){var n=function(t,e,r){var n=null==t?void 0:ie(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=re(e,t)).length,i=!1;++n<o;){var s=oe(e[n]);if(!(i=null!=t&&r(t,s)))break;t=t[s]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&at(o)&&X(s,o)&&(v(t)||gt(t))}(t,e,an)}(r,t):en(e,n,un|cn)}}(t[0],t[1]):(o=function(t){for(var e=Mt(t),r=e.length;r--;){var n=e[r],o=t[n];e[r]=[n,o,on(o)]}return e}(n=t),1==o.length&&o[0][2]?sn(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 he;if(!en(c,u,rn|nn,void 0,f))return!1}}return!0}(t,0,o)}):Dt(e=t)?(r=oe(e),function(t){return null==t?void 0:t[r]}):function(t){return function(e){return ie(e,t)}}(e);var e,r,n,o}var hn=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};function ln(t,e){return t&&hn(t,e,Mt)}var dn,pn=(dn=ln,function(t,e){if(null==t)return t;if(!ut(t))return dn(t,e);for(var r=t.length,n=-1,o=Object(t);++n<r&&!1!==e(o[n],n,o););return t});function wn(t,e){var r=-1,n=ut(t)?Array(t.length):[];return pn(t,function(t,o,i){n[++r]=e(t,o,i)}),n}function gn(t,e){return t>e}var vn=Math.min;function yn(t){return function(t){return d(t)&&ut(t)}(t)?t:[]}var _n=it(function(t){var e=g(t,yn);return e.length&&e[0]===t[0]?function(t,e,r){for(var n=Y,o=t[0].length,i=t.length,s=i,a=Array(i),u=Infinity,c=[];s--;){var f=t[s];u=vn(f.length,u),a[s]=o>=120&&f.length>=120?new xr(s&&f):void 0}f=t[0];var h=-1,l=a[0];t:for(;++h<o&&c.length<u;){var d=f[h],p=d;if(d=0!==d?d:0,!(l?Ar(l,p):n(c,p,r))){for(s=i;--s;){var w=a[s];if(!(w?Ar(w,p):n(t[s],p,r)))continue t}l&&l.push(p),c.push(d)}}return c}(e):[]}),bn=_n;function mn(t,e){return t<e}function jn(t,e){var r={};return e=fn(e),ln(t,function(t,n,o){Z(r,n,e(t,n,o))}),r}function Sn(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 On(t,e){return t&&t.length?Sn(t,fn(e),gn):void 0}function xn(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 kn(t,e){return function(t,e){var r=null==t?0:t.length;return r?xn(t,e)/r:NaN}(t,fn(e))}function An(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 En(t,e,r){e=e.length?g(e,function(t){return v(t)?function(e){return ie(e,1===t.length?t[0]:t)}:t}):[S];var n=-1;return e=g(e,jt(fn)),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=An(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}(wn(t,function(t,r,o){return{criteria:g(e,function(e){return e(t)}),index:++n,value:t}}))}function zn(t,e,r,n){return null==t?[]:(v(e)||(e=null==e?[]:[e]),v(r=n?void 0:r)||(r=null==r?[]:[r]),En(t,e,r))}var Fn=it(function(t,e){if(null==t)return[];var r=e.length;return r>1&&ct(t,e[0],e[1])?e=[]:r>2&&ct(e[0],e[1],e[2])&&(e=[e[0]]),En(t,ce(e,1),[])});function Pn(t,e){return t&&t.length?xn(t,fn(e)):0}function Tn(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])}Tn.fromWords=function(t){const e=Object.create(Tn.prototype);return e.words=t,e},Tn.prototype.add=function(t){this.resize(t),this.words[t>>>5]|=1<<t},Tn.prototype.flip=function(t){this.resize(t),this.words[t>>>5]^=1<<t},Tn.prototype.clear=function(){this.words.length=0},Tn.prototype.remove=function(t){this.resize(t),this.words[t>>>5]&=~(1<<t)},Tn.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},Tn.prototype.has=function(t){return 0!=(this.words[t>>>5]&1<<t)},Tn.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},Tn.prototype.trim=function(t){let e=this.words.length;for(;e>0&&0===this.words[e-1];)e--;this.words.length=e},Tn.prototype.resize=function(t){const e=t+32>>>5;for(let t=this.words.length;t<e;t++)this.words[t]=0},Tn.prototype.hammingWeight=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},Tn.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},Tn.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},Tn.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},Tn.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}}},Tn.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}}}},Tn.prototype.clone=function(){const t=Object.create(Tn.prototype);return t.words=this.words.slice(),t},Tn.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},Tn.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},Tn.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},Tn.prototype.new_intersection=function(t){const e=Object.create(Tn.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},Tn.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},Tn.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},Tn.prototype.new_difference=function(t){return this.clone().difference(t)},Tn.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},Tn.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},Tn.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},Tn.prototype.new_change=function(t){const e=Object.create(Tn.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},Tn.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},Tn.prototype.toString=function(){return"{"+this.array().join(",")+"}"},Tn.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},Tn.prototype.new_union=function(t){const e=Object.create(Tn.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},Tn.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 In=Tn;function Mn(){return Mn=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},Mn.apply(this,arguments)}function Nn(t,e){var r=[];return t.forEach(function(t){e.forEach(function(e){r.push(t.concat(e))})}),r}function $n(t){return!!~t.search(/\(|\)/)}function Wn(t,e){for(var r=e.split(" "+t+" "),n=[],o=[],i=0;i<r.length;i++)if($n(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 Cn=function t(e){return function(t){for(var e=t[0],r=1;r<t.length;r++)e=e.concat(t[r]);return e}(Wn("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=Wn("AND",e),n=[],o=[],i=0;i<r.length;i++)$n(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=Nn(e,t[r]);return e}(n)}));var r},Dn=function(t){try{return structuredClone(t)}catch(e){try{return JSON.parse(JSON.stringify(t))}catch(e){return t}}},Vn=function(t,e){var r=new In([]),n=0;return jn(e,function(e,o){e.forEach(function(e){++n,r=r.new_union(t[o][e]||new In([]))})}),0===n?null:r},Rn=function(t,e,r){var n=1;return jn(t.bits_data_temp,function(t,o){var i,s,a,u,c,f,h;r[o]&&(i=r[o].order,s=r[o].sort,a=r[o].size,u=r[o].title,c=r[o].show_facet_stats||!1,f=!1!==r[o].chosen_filters_on_top,h=r[o].hide_zero_doc_count||!1);var l,d,p,w,g,y,_=Object.entries(t).map(function(t){var r=[];e&&e.filters&&e.filters[o]&&(r=e.filters[o]);var n=t[1].array().length;if(!h||0!==n||-1!==r.indexOf(t[0]))return{key:t[0],doc_count:n,selected:-1!==r.indexOf(t[0])}}).filter(Boolean);return v(s)?(l=s||["key"],d=i||["asc"]):("term"===s||"key"===s?(l=["key"],d=[i||"asc"]):(l=["doc_count","key"],d=[i||"desc","asc"]),f&&(l.unshift("selected"),d.unshift("desc"))),_=(_=zn(_,l,d)).slice(0,a||10),c&&(p=[],Object.entries(t).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(){p.push(parseInt(t[0]))})}),w={min:(g=p,g&&g.length?Sn(g,fn(void 0),mn):void 0),max:On(p),avg:kn(p),sum:Pn(p)}),Mn({name:o,title:u||(y=o,y.replace(/^[\s_]+|[\s_]+$/g,"").replace(/[_\s]+/g," ").replace(/^[a-z]/,function(t){return t.toUpperCase()})),position:n++,buckets:_},c&&{facet_stats:w})})};function Un(t,e,r,n,o){e=e||Object.create(null);var i=parseInt(e.per_page||12),s=parseInt(e.page||1),a=e.is_all_filtered_items||!1;if(!1===r.native_search_enabled&&(e.query||e.filter))throw new Error('"query" and "filter" options are not working once native search is disabled');var u,c,f,h=0,l=(new Date).getTime(),d=o.bits_ids();if(e._ids)u=new In(e._ids),c=e._ids;else if(e.ids)c=o.internal_ids_from_ids_map(e.ids),u=new In(c);else if(n&&(e.query||e.filter)){var p=(new Date).getTime();c=n.search(e.query,e.filter),h=(new Date).getTime()-p,u=new In(c)}var w=(new Date).getTime(),g=o.search(e,{query_ids:u});w=(new Date).getTime()-w,u&&(d=u),g.ids&&(d=d.new_intersection(g.ids)),g.not_ids&&(d=d.new_difference(g.not_ids));var v,y=d.array(),_=y.map(function(t){return o.get_item(t)}),b=!1,m=(new Date).getTime();e.sort?_=function(t,e,r){return r&&r[e]&&(e=r[e]),e.field?zn(t,e.field,e.order||"asc"):t}(_,e.sort,r.sortings):c&&(_=(y=c.filter(function(t){return d.has(t)})).slice((s-1)*i,s*i).map(function(t){return o.get_item(t)}),b=!0),b||(f=a?_:null,_=_.slice((s-1)*i,s*i)),v=(new Date).getTime()-m;var j=(new Date).getTime()-l;return{pagination:{per_page:i,page:s,total:y.length},timings:{total:j,facets:w,search:h,sorting:v},data:{items:_,allFilteredItems:f,aggregations:Rn(g,e,r.aggregations)}}}var qn=function(t){var e={exports:{}};return function(t,e){!function(){var e,r,n,o,i,s,a,u,c,f,h,l,d,p,w,g,v,y,_,b,m,j,S,O,x,k,A,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],h=f.length;if(h){for(var l=0,d=0;d<h;d++)f[d]===s&&l++;a+=l/h*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 h=a.tokenStore.get(n),l=Object.keys(h),d=l.length,p=0;p<d;p++)c.add(h[l[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),h=new RegExp(s),l=new RegExp(u),d=/^(.+?)(ss|i)es$/,p=/^(.+?)([^s])s$/,w=/^(.+?)eed$/,g=/^(.+?)(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)$/,k=/^(.+?)e$/,A=/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=g,(s=w).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=l).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=k).test(t)&&(F=s.exec(t),a=h,u=E,((s=f).test(n=F[1])||a.test(n)&&!u.test(n))&&(t=n)),a=f,(s=A).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","your"]),z.Pipeline.registerFunction(z.stopWordFilter,"stopWordFilter"),z.trimmer=function(t){return t.replace(/^\W+/,"").replace(/\W+$/,"")},z.Pipeline.registerFunction(z.trimmer,"trimmer"),z.TokenStore=function(){this.root={docs:{}},this.length=0},z.TokenStore.load=function(t){var e=new this;return e.root=t.root,e.length=t.length,e},z.TokenStore.prototype.add=function(t,e,r){r=r||this.root;var n=t.charAt(0),o=t.slice(1);return n in r||(r[n]={docs:{}}),0===o.length?(r[n].docs[e.ref]=e,void(this.length+=1)):this.add(o,e,r[n])},z.TokenStore.prototype.has=function(t){if(!t)return!1;for(var e=this.root,r=0;r<t.length;r++){if(!e[t.charAt(r)])return!1;e=e[t.charAt(r)]}return!0},z.TokenStore.prototype.getNode=function(t){if(!t)return{};for(var e=this.root,r=0;r<t.length;r++){if(!e[t.charAt(r)])return{};e=e[t.charAt(r)]}return e},z.TokenStore.prototype.get=function(t,e){return this.getNode(t,e).docs||{}},z.TokenStore.prototype.count=function(t,e){return Object.keys(this.get(t,e)).length},z.TokenStore.prototype.remove=function(t,e){if(t){for(var r=this.root,n=0;n<t.length;n++){if(!(t.charAt(n)in r))return;r=r[t.charAt(n)]}delete r.docs[e]}},z.TokenStore.prototype.expand=function(t,e){var r=this.getNode(t);return e=e||[],Object.keys(r.docs||{}).length&&e.push(t),Object.keys(r).forEach(function(r){"docs"!==r&&e.concat(this.expand(t+r,e))},this),e},z.TokenStore.prototype.toJSON=function(){return{root:this.root,length:this.length}},t.exports=z}()}(e),e.expor