You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

1 lines
28 KiB

!function(){var t,l,c,h,d,f,p,y,m,g,x,v,w,Q,k,S,E,L,b,P,T,O,I,e,r,D=function(e){var t=new D.Builder;return t.pipeline.add(D.trimmer,D.stopWordFilter,D.stemmer),t.searchPipeline.add(D.stemmer),e.call(t,t),t.build()};function i(e){var t,r,i,n,s,o,a,u;return e.length<3||("y"==(r=e.substr(0,1))&&(e=r.toUpperCase()+e.substr(1)),a=m,(s=y).test(e)?e=e.replace(s,"$1$2"):a.test(e)&&(e=e.replace(a,"$1$2")),a=x,(s=g).test(e)?(u=s.exec(e),(s=h).test(u[1])&&(s=v,e=e.replace(s,""))):a.test(e)&&(o=(u=a.exec(e))[1],(a=p).test(o)&&(i=Q,n=k,(a=w).test(e=o)?e+="e":i.test(e)?(s=v,e=e.replace(s,"")):n.test(e)&&(e+="e"))),(s=S).test(e)&&(e=(o=(u=s.exec(e))[1])+"i"),(s=E).test(e)&&(o=(u=s.exec(e))[1],t=u[2],(s=h).test(o)&&(e=o+l[t])),(s=L).test(e)&&(o=(u=s.exec(e))[1],t=u[2],(s=h).test(o)&&(e=o+c[t])),a=P,(s=b).test(e)?(o=(u=s.exec(e))[1],(s=d).test(o)&&(e=o)):a.test(e)&&(o=(u=a.exec(e))[1]+u[2],(a=d).test(o)&&(e=o)),(s=T).test(e)&&(o=(u=s.exec(e))[1],a=f,i=I,((s=d).test(o)||a.test(o)&&!i.test(o))&&(e=o)),a=d,(s=O).test(e)&&a.test(e)&&(s=v,e=e.replace(s,"")),"y"==r&&(e=r.toLowerCase()+e.substr(1))),e}D.version="2.3.8",D.utils={},D.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),D.utils.asString=function(e){return null==e?"":e.toString()},D.utils.clone=function(e){if(null==e)return e;for(var t=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){var n=r[i],s=e[n];if(Array.isArray(s))t[n]=s.slice();else{if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s)throw new TypeError("clone is not deep and does not support nested objects");t[n]=s}}return t},D.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},D.FieldRef.joiner="/",D.FieldRef.fromString=function(e){var t=e.indexOf(D.FieldRef.joiner);if(-1===t)throw"malformed field ref string";var r=e.slice(0,t),t=e.slice(t+1);return new D.FieldRef(t,r,e)},D.FieldRef.prototype.toString=function(){return null==this._stringValue&&(this._stringValue=this.fieldName+D.FieldRef.joiner+this.docRef),this._stringValue},D.Set=function(e){if(this.elements=Object.create(null),e){this.length=e.length;for(var t=0;t<this.length;t++)this.elements[e[t]]=!0}else this.length=0},D.Set.complete={intersect:function(e){return e},union:function(e){return e},contains:function(){return!0}},D.Set.empty={intersect:function(){return this},union:function(e){return e},contains:function(){return!1}},D.Set.prototype.contains=function(e){return!!this.elements[e]},D.Set.prototype.intersect=function(e){var t,r,i,n=[];if(e===D.Set.complete)return this;if(e===D.Set.empty)return e;r=this.length<e.length?(t=this,e):(t=e,this),i=Object.keys(t.elements);for(var s=0;s<i.length;s++){var o=i[s];o in r.elements&&n.push(o)}return new D.Set(n)},D.Set.prototype.union=function(e){return e===D.Set.complete?D.Set.complete:e===D.Set.empty?this:new D.Set(Object.keys(this.elements).concat(Object.keys(e.elements)))},D.idf=function(e,t){var r,i=0;for(r in e)"_index"!=r&&(i+=Object.keys(e[r]).length);t=(t-i+.5)/(i+.5);return Math.log(1+Math.abs(t))},D.Token=function(e,t){this.str=e||"",this.metadata=t||{}},D.Token.prototype.toString=function(){return this.str},D.Token.prototype.update=function(e){return this.str=e(this.str,this.metadata),this},D.Token.prototype.clone=function(e){return e=e||function(e){return e},new D.Token(e(this.str,this.metadata),this.metadata)},D.tokenizer=function(e,t){if(null==e||null==e)return[];if(Array.isArray(e))return e.map(function(e){return new D.Token(D.utils.asString(e).toLowerCase(),D.utils.clone(t))});for(var r=e.toString().toLowerCase(),i=r.length,n=[],s=0,o=0;s<=i;s++){var a,u=s-o;!r.charAt(s).match(D.tokenizer.separator)&&s!=i||(0<u&&((a=D.utils.clone(t)||{}).position=[o,u],a.index=n.length,n.push(new D.Token(r.slice(o,s),a))),o=s+1)}return n},D.tokenizer.separator=/[\s\-]+/,D.Pipeline=function(){this._stack=[]},D.Pipeline.registeredFunctions=Object.create(null),D.Pipeline.registerFunction=function(e,t){t in this.registeredFunctions&&D.utils.warn("Overwriting existing registered function: "+t),e.label=t,D.Pipeline.registeredFunctions[e.label]=e},D.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||D.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},D.Pipeline.load=function(e){var r=new D.Pipeline;return e.forEach(function(e){var t=D.Pipeline.registeredFunctions[e];if(!t)throw new Error("Cannot load unregistered function: "+e);r.add(t)}),r},D.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){D.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)},this)},D.Pipeline.prototype.after=function(e,t){D.Pipeline.warnIfFunctionNotRegistered(t);e=this._stack.indexOf(e);if(-1==e)throw new Error("Cannot find existingFn");e+=1,this._stack.splice(e,0,t)},D.Pipeline.prototype.before=function(e,t){D.Pipeline.warnIfFunctionNotRegistered(t);e=this._stack.indexOf(e);if(-1==e)throw new Error("Cannot find existingFn");this._stack.splice(e,0,t)},D.Pipeline.prototype.remove=function(e){e=this._stack.indexOf(e);-1!=e&&this._stack.splice(e,1)},D.Pipeline.prototype.run=function(e){for(var t=this._stack.length,r=0;r<t;r++){for(var i=this._stack[r],n=[],s=0;s<e.length;s++){var o=i(e[s],s,e);if(null!=o&&""!==o)if(Array.isArray(o))for(var a=0;a<o.length;a++)n.push(o[a]);else n.push(o)}e=n}return e},D.Pipeline.prototype.runString=function(e,t){t=new D.Token(e,t);return this.run([t]).map(function(e){return e.toString()})},D.Pipeline.prototype.reset=function(){this._stack=[]},D.Pipeline.prototype.toJSON=function(){return this._stack.map(function(e){return D.Pipeline.warnIfFunctionNotRegistered(e),e.label})},D.Vector=function(e){this._magnitude=0,this.elements=e||[]},D.Vector.prototype.positionForIndex=function(e){if(0==this.elements.length)return 0;for(var t=0,r=this.elements.length/2,i=r-t,n=Math.floor(i/2),s=this.elements[2*n];1<i&&(s<e&&(t=n),e<s&&(r=n),s!=e);)i=r-t,n=t+Math.floor(i/2),s=this.elements[2*n];return s==e||e<s?2*n:s<e?2*(n+1):void 0},D.Vector.prototype.insert=function(e,t){this.upsert(e,t,function(){throw"duplicate index"})},D.Vector.prototype.upsert=function(e,t,r){this._magnitude=0;var i=this.positionForIndex(e);this.elements[i]==e?this.elements[i+1]=r(this.elements[i+1],t):this.elements.splice(i,0,e,t)},D.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var e=0,t=this.elements.length,r=1;r<t;r+=2){var i=this.elements[r];e+=i*i}return this._magnitude=Math.sqrt(e)},D.Vector.prototype.dot=function(e){for(var t,r,i=0,n=this.elements,s=e.elements,o=n.length,a=s.length,u=0,l=0;u<o&&l<a;)(t=n[u])<(r=s[l])?u+=2:r<t?l+=2:t==r&&(i+=n[u+1]*s[l+1],u+=2,l+=2);return i},D.Vector.prototype.similarity=function(e){return this.dot(e)/this.magnitude()||0},D.Vector.prototype.toArray=function(){for(var e=new Array(this.elements.length/2),t=1,r=0;t<this.elements.length;t+=2,r++)e[r]=this.elements[t];return e},D.Vector.prototype.toJSON=function(){return this.elements},D.stemmer=(l={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"},c={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},r="[aeiouy]",e="[^aeiou][^aeiouy]*",h=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),d=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*[aeiouy][aeiou]*[^aeiou][^aeiouy]*"),f=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy][aeiou]*[^aeiou][^aeiouy]*([aeiouy][aeiou]*)?$"),p=new RegExp("^([^aeiou][^aeiouy]*)?[aeiouy]"),y=/^(.+?)(ss|i)es$/,m=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,x=/^(.+?)(ed|ing)$/,v=/.$/,w=/(at|bl|iz)$/,Q=new RegExp("([^aeiouylsz])\\1$"),k=new RegExp("^"+e+r+"[^aeiouwxy]$"),S=/^(.+?[^aeiou])y$/,E=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,L=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,b=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,P=/^(.+?)(s|t)(ion)$/,T=/^(.+?)e$/,O=/ll$/,I=new RegExp("^"+e+r+"[^aeiouwxy]$"),function(e){return e.update(i)}),D.Pipeline.registerFunction(D.stemmer,"stemmer"),D.generateStopWordFilter=function(e){var t=e.reduce(function(e,t){return e[t]=t,e},{});return function(e){if(e&&t[e.toString()]!==e.toString())return e}},D.stopWordFilter=D.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),D.Pipeline.registerFunction(D.stopWordFilter,"stopWordFilter"),D.trimmer=function(e){return e.update(function(e){return e.replace(/^\W+/,"").replace(/\W+$/,"")})},D.Pipeline.registerFunction(D.trimmer,"trimmer"),D.TokenSet=function(){this.final=!1,this.edges={},this.id=D.TokenSet._nextId,D.TokenSet._nextId+=1},D.TokenSet._nextId=1,D.TokenSet.fromArray=function(e){for(var t=new D.TokenSet.Builder,r=0,i=e.length;r<i;r++)t.insert(e[r]);return t.finish(),t.root},D.TokenSet.fromClause=function(e){return"editDistance"in e?D.TokenSet.fromFuzzyString(e.term,e.editDistance):D.TokenSet.fromString(e.term)},D.TokenSet.fromFuzzyString=function(e,t){for(var r=new D.TokenSet,i=[{node:r,editsRemaining:t,str:e}];i.length;){var n,s,o,a,u,l,c=i.pop();0<c.str.length&&((u=c.str.charAt(0))in c.node.edges?n=c.node.edges[u]:(n=new D.TokenSet,c.node.edges[u]=n),1==c.str.length&&(n.final=!0),i.push({node:n,editsRemaining:c.editsRemaining,str:c.str.slice(1)})),0!=c.editsRemaining&&("*"in c.node.edges?s=c.node.edges["*"]:(s=new D.TokenSet,c.node.edges["*"]=s),0==c.str.length&&(s.final=!0),i.push({node:s,editsRemaining:c.editsRemaining-1,str:c.str}),1<c.str.length&&i.push({node:c.node,editsRemaining:c.editsRemaining-1,str:c.str.slice(1)}),1==c.str.length&&(c.node.final=!0),1<=c.str.length&&("*"in c.node.edges?o=c.node.edges["*"]:(o=new D.TokenSet,c.node.edges["*"]=o),1==c.str.length&&(o.final=!0),i.push({node:o,editsRemaining:c.editsRemaining-1,str:c.str.slice(1)})),1<c.str.length&&(a=c.str.charAt(0),(u=c.str.charAt(1))in c.node.edges?l=c.node.edges[u]:(l=new D.TokenSet,c.node.edges[u]=l),1==c.str.length&&(l.final=!0),i.push({node:l,editsRemaining:c.editsRemaining-1,str:a+c.str.slice(2)})))}return r},D.TokenSet.fromString=function(e){for(var t=new D.TokenSet,r=t,i=0,n=e.length;i<n;i++){var s,o=e[i],a=i==n-1;"*"==o?(t.edges[o]=t).final=a:((s=new D.TokenSet).final=a,t.edges[o]=s,t=s)}return r},D.TokenSet.prototype.toArray=function(){for(var e=[],t=[{prefix:"",node:this}];t.length;){var r=t.pop(),i=Object.keys(r.node.edges),n=i.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(var s=0;s<n;s++){var o=i[s];t.push({prefix:r.prefix.concat(o),node:r.node.edges[o]})}}return e},D.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var e=this.final?"1":"0",t=Object.keys(this.edges).sort(),r=t.length,i=0;i<r;i++)var n=t[i],e=e+n+this.edges[n].id;return e},D.TokenSet.prototype.intersect=function(e){for(var t=new D.TokenSet,r=void 0,i=[{qNode:e,output:t,node:this}];i.length;){r=i.pop();for(var n=Object.keys(r.qNode.edges),s=n.length,o=Object.keys(r.node.edges),a=o.length,u=0;u<s;u++)for(var l=n[u],c=0;c<a;c++){var h,d,f,p,y=o[c];y!=l&&"*"!=l||(h=r.node.edges[y],d=r.qNode.edges[l],f=h.final&&d.final,p=void 0,y in r.output.edges?(p=r.output.edges[y]).final=p.final||f:((p=new D.TokenSet).final=f,r.output.edges[y]=p),i.push({qNode:d,output:p,node:h}))}}return t},D.TokenSet.Builder=function(){this.previousWord="",this.root=new D.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},D.TokenSet.Builder.prototype.insert=function(e){var t,r=0;if(e<this.previousWord)throw new Error("Out of order word insertion");for(var i=0;i<e.length&&i<this.previousWord.length&&e[i]==this.previousWord[i];i++)r++;this.minimize(r),t=0==this.uncheckedNodes.length?this.root:this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(i=r;i<e.length;i++){var n=new D.TokenSet,s=e[i];t.edges[s]=n,this.uncheckedNodes.push({parent:t,char:s,child:n}),t=n}t.final=!0,this.previousWord=e},D.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},D.TokenSet.Builder.prototype.minimize=function(e){for(var t=this.uncheckedNodes.length-1;e<=t;t--){var r=this.uncheckedNodes[t],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}},D.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},D.Index.prototype.search=function(t){return this.query(function(e){new D.QueryParser(t,e).parse()})},D.Index.prototype.query=function(e){for(var t=new D.Query(this.fields),r=Object.create(null),i=Object.create(null),n=Object.create(null),s=Object.create(null),o=Object.create(null),a=0;a<this.fields.length;a++)i[this.fields[a]]=new D.Vector;e.call(t,t);for(a=0;a<t.clauses.length;a++){for(var u=t.clauses[a],l=null,c=D.Set.complete,l=u.usePipeline?this.pipeline.runString(u.term,{fields:u.fields}):[u.term],h=0;h<l.length;h++){var d=l[h];u.term=d;var d=D.TokenSet.fromClause(u),f=this.tokenSet.intersect(d).toArray();if(0===f.length&&u.presence===D.Query.presence.REQUIRED){for(var p=0;p<u.fields.length;p++)s[P=u.fields[p]]=D.Set.empty;break}for(var y=0;y<f.length;y++)for(var m=f[y],g=this.invertedIndex[m],x=g._index,p=0;p<u.fields.length;p++){var v=g[P=u.fields[p]],w=Object.keys(v),Q=m+"/"+P,k=new D.Set(w);if(u.presence==D.Query.presence.REQUIRED&&(c=c.union(k),void 0===s[P]&&(s[P]=D.Set.complete)),u.presence!=D.Query.presence.PROHIBITED){if(i[P].upsert(x,u.boost,function(e,t){return e+t}),!n[Q]){for(var S=0;S<w.length;S++){var E=w[S],L=new D.FieldRef(E,P),b=v[E];void 0===(E=r[L])?r[L]=new D.MatchData(m,P,b):E.add(m,P,b)}n[Q]=!0}}else void 0===o[P]&&(o[P]=D.Set.empty),o[P]=o[P].union(k)}}if(u.presence===D.Query.presence.REQUIRED)for(p=0;p<u.fields.length;p++)s[P=u.fields[p]]=s[P].intersect(c)}for(var P,T=D.Set.complete,O=D.Set.empty,a=0;a<this.fields.length;a++)s[P=this.fields[a]]&&(T=T.intersect(s[P])),o[P]&&(O=O.union(o[P]));var I=Object.keys(r),R=[],F=Object.create(null);if(t.isNegated()){I=Object.keys(this.fieldVectors);for(a=0;a<I.length;a++){var L=I[a],C=D.FieldRef.fromString(L);r[L]=new D.MatchData}}for(a=0;a<I.length;a++){var N,j,_=(C=D.FieldRef.fromString(I[a])).docRef;T.contains(_)&&(O.contains(_)||(N=this.fieldVectors[C],j=i[C.fieldName].similarity(N),void 0!==(N=F[_])?(N.score+=j,N.matchData.combine(r[C])):(j={ref:_,score:j,matchData:r[C]},F[_]=j,R.push(j))))}return R.sort(function(e,t){return t.score-e.score})},D.Index.prototype.toJSON=function(){var e=Object.keys(this.invertedIndex).sort().map(function(e){return[e,this.invertedIndex[e]]},this),t=Object.keys(this.fieldVectors).map(function(e){return[e,this.fieldVectors[e].toJSON()]},this);return{version:D.version,fields:this.fields,fieldVectors:t,invertedIndex:e,pipeline:this.pipeline.toJSON()}},D.Index.load=function(e){var t={},r={},i=e.fieldVectors,n=Object.create(null),s=e.invertedIndex,o=new D.TokenSet.Builder,a=D.Pipeline.load(e.pipeline);e.version!=D.version&&D.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+D.version+"' does not match serialized index '"+e.version+"'");for(var u=0;u<i.length;u++){var l=(h=i[u])[0],c=h[1];r[l]=new D.Vector(c)}for(u=0;u<s.length;u++){var h,d=(h=s[u])[0],f=h[1];o.insert(d),n[d]=f}return o.finish(),t.fields=e.fields,t.fieldVectors=r,t.invertedIndex=n,t.tokenSet=o.root,t.pipeline=a,new D.Index(t)},D.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=D.tokenizer,this.pipeline=new D.Pipeline,this.searchPipeline=new D.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},D.Builder.prototype.ref=function(e){this._ref=e},D.Builder.prototype.field=function(e,t){if(/\//.test(e))throw new RangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=t||{}},D.Builder.prototype.b=function(e){this._b=e<0?0:1<e?1:e},D.Builder.prototype.k1=function(e){this._k1=e},D.Builder.prototype.add=function(e,t){var r=e[this._ref],i=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(var n=0;n<i.length;n++){var s=i[n],o=this._fields[s].extractor,o=o?o(e):e[s],o=this.tokenizer(o,{fields:[s]}),a=this.pipeline.run(o),o=new D.FieldRef(r,s),u=Object.create(null);this.fieldTermFrequencies[o]=u,this.fieldLengths[o]=0,this.fieldLengths[o]+=a.length;for(var l=0;l<a.length;l++){var c=a[l];if(null==u[c]&&(u[c]=0),u[c]+=1,null==this.invertedIndex[c]){var h=Object.create(null);h._index=this.termIndex,this.termIndex+=1;for(var d=0;d<i.length;d++)h[i[d]]=Object.create(null);this.invertedIndex[c]=h}null==this.invertedIndex[c][s][r]&&(this.invertedIndex[c][s][r]=Object.create(null));for(var f=0;f<this.metadataWhitelist.length;f++){var p=this.metadataWhitelist[f],y=c.metadata[p];null==this.invertedIndex[c][s][r][p]&&(this.invertedIndex[c][s][r][p]=[]),this.invertedIndex[c][s][r][p].push(y)}}}},D.Builder.prototype.calculateAverageFieldLengths=function(){for(var e=Object.keys(this.fieldLengths),t=e.length,r={},i={},n=0;n<t;n++){var s=D.FieldRef.fromString(e[n]),o=s.fieldName;i[o]||(i[o]=0),i[o]+=1,r[o]||(r[o]=0),r[o]+=this.fieldLengths[s]}for(var a=Object.keys(this._fields),n=0;n<a.length;n++){var u=a[n];r[u]=r[u]/i[u]}this.averageFieldLength=r},D.Builder.prototype.createFieldVectors=function(){for(var e={},t=Object.keys(this.fieldTermFrequencies),r=t.length,i=Object.create(null),n=0;n<r;n++){for(var s=D.FieldRef.fromString(t[n]),o=s.fieldName,a=this.fieldLengths[s],u=new D.Vector,l=this.fieldTermFrequencies[s],c=Object.keys(l),h=c.length,d=this._fields[o].boost||1,f=this._documents[s.docRef].boost||1,p=0;p<h;p++){var y,m=c[p],g=l[m],x=this.invertedIndex[m]._index;void 0===i[m]?(y=D.idf(this.invertedIndex[m],this.documentCount),i[m]=y):y=i[m],g=y*((this._k1+1)*g)/(this._k1*(1-this._b+this._b*(a/this.averageFieldLength[o]))+g),g*=d,g*=f,g=Math.round(1e3*g)/1e3,u.insert(x,g)}e[s]=u}this.fieldVectors=e},D.Builder.prototype.createTokenSet=function(){this.tokenSet=D.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},D.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new D.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},D.Builder.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},D.MatchData=function(e,t,r){for(var i=Object.create(null),n=Object.keys(r||{}),s=0;s<n.length;s++){var o=n[s];i[o]=r[o].slice()}this.metadata=Object.create(null),void 0!==e&&(this.metadata[e]=Object.create(null),this.metadata[e][t]=i)},D.MatchData.prototype.combine=function(e){for(var t=Object.keys(e.metadata),r=0;r<t.length;r++){var i=t[r],n=Object.keys(e.metadata[i]);null==this.metadata[i]&&(this.metadata[i]=Object.create(null));for(var s=0;s<n.length;s++){var o=n[s],a=Object.keys(e.metadata[i][o]);null==this.metadata[i][o]&&(this.metadata[i][o]=Object.create(null));for(var u=0;u<a.length;u++){var l=a[u];null==this.metadata[i][o][l]?this.metadata[i][o][l]=e.metadata[i][o][l]:this.metadata[i][o][l]=this.metadata[i][o][l].concat(e.metadata[i][o][l])}}}},D.MatchData.prototype.add=function(e,t,r){if(!(e in this.metadata))return this.metadata[e]=Object.create(null),void(this.metadata[e][t]=r);if(t in this.metadata[e])for(var i=Object.keys(r),n=0;n<i.length;n++){var s=i[n];s in this.metadata[e][t]?this.metadata[e][t][s]=this.metadata[e][t][s].concat(r[s]):this.metadata[e][t][s]=r[s]}else this.metadata[e][t]=r},D.Query=function(e){this.clauses=[],this.allFields=e},D.Query.wildcard=new String("*"),D.Query.wildcard.NONE=0,D.Query.wildcard.LEADING=1,D.Query.wildcard.TRAILING=2,D.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},D.Query.prototype.clause=function(e){return"fields"in e||(e.fields=this.allFields),"boost"in e||(e.boost=1),"usePipeline"in e||(e.usePipeline=!0),"wildcard"in e||(e.wildcard=D.Query.wildcard.NONE),e.wildcard&D.Query.wildcard.LEADING&&e.term.charAt(0)!=D.Query.wildcard&&(e.term="*"+e.term),e.wildcard&D.Query.wildcard.TRAILING&&e.term.slice(-1)!=D.Query.wildcard&&(e.term=e.term+"*"),"presence"in e||(e.presence=D.Query.presence.OPTIONAL),this.clauses.push(e),this},D.Query.prototype.isNegated=function(){for(var e=0;e<this.clauses.length;e++)if(this.clauses[e].presence!=D.Query.presence.PROHIBITED)return!1;return!0},D.Query.prototype.term=function(e,t){if(Array.isArray(e))return e.forEach(function(e){this.term(e,D.utils.clone(t))},this),this;var r=t||{};return r.term=e.toString(),this.clause(r),this},D.QueryParseError=function(e,t,r){this.name="QueryParseError",this.message=e,this.start=t,this.end=r},D.QueryParseError.prototype=new Error,D.QueryLexer=function(e){this.lexemes=[],this.str=e,this.length=e.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},D.QueryLexer.prototype.run=function(){for(var e=D.QueryLexer.lexText;e;)e=e(this)},D.QueryLexer.prototype.sliceString=function(){for(var e=[],t=this.start,r=this.pos,i=0;i<this.escapeCharPositions.length;i++)r=this.escapeCharPositions[i],e.push(this.str.slice(t,r)),t=r+1;return e.push(this.str.slice(t,this.pos)),this.escapeCharPositions.length=0,e.join("")},D.QueryLexer.prototype.emit=function(e){this.lexemes.push({type:e,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},D.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},D.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return D.QueryLexer.EOS;var e=this.str.charAt(this.pos);return this.pos+=1,e},D.QueryLexer.prototype.width=function(){return this.pos-this.start},D.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},D.QueryLexer.prototype.backup=function(){--this.pos},D.QueryLexer.prototype.acceptDigitRun=function(){for(var e,t;t=(e=this.next()).charCodeAt(0),47<t&&t<58;);e!=D.QueryLexer.EOS&&this.backup()},D.QueryLexer.prototype.more=function(){return this.pos<this.length},D.QueryLexer.EOS="EOS",D.QueryLexer.FIELD="FIELD",D.QueryLexer.TERM="TERM",D.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",D.QueryLexer.BOOST="BOOST",D.QueryLexer.PRESENCE="PRESENCE",D.QueryLexer.lexField=function(e){return e.backup(),e.emit(D.QueryLexer.FIELD),e.ignore(),D.QueryLexer.lexText},D.QueryLexer.lexTerm=function(e){if(1<e.width()&&(e.backup(),e.emit(D.QueryLexer.TERM)),e.ignore(),e.more())return D.QueryLexer.lexText},D.QueryLexer.lexEditDistance=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(D.QueryLexer.EDIT_DISTANCE),D.QueryLexer.lexText},D.QueryLexer.lexBoost=function(e){return e.ignore(),e.acceptDigitRun(),e.emit(D.QueryLexer.BOOST),D.QueryLexer.lexText},D.QueryLexer.lexEOS=function(e){0<e.width()&&e.emit(D.QueryLexer.TERM)},D.QueryLexer.termSeparator=D.tokenizer.separator,D.QueryLexer.lexText=function(e){for(;;){var t=e.next();if(t==D.QueryLexer.EOS)return D.QueryLexer.lexEOS;if(92!=t.charCodeAt(0)){if(":"==t)return D.QueryLexer.lexField;if("~"==t)return e.backup(),0<e.width()&&e.emit(D.QueryLexer.TERM),D.QueryLexer.lexEditDistance;if("^"==t)return e.backup(),0<e.width()&&e.emit(D.QueryLexer.TERM),D.QueryLexer.lexBoost;if("+"==t&&1===e.width())return e.emit(D.QueryLexer.PRESENCE),D.QueryLexer.lexText;if("-"==t&&1===e.width())return e.emit(D.QueryLexer.PRESENCE),D.QueryLexer.lexText;if(t.match(D.QueryLexer.termSeparator))return D.QueryLexer.lexTerm}else e.escapeCharacter()}},D.QueryParser=function(e,t){this.lexer=new D.QueryLexer(e),this.query=t,this.currentClause={},this.lexemeIdx=0},D.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var e=D.QueryParser.parseClause;e;)e=e(this);return this.query},D.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},D.QueryParser.prototype.consumeLexeme=function(){var e=this.peekLexeme();return this.lexemeIdx+=1,e},D.QueryParser.prototype.nextClause=function(){var e=this.currentClause;this.query.clause(e),this.currentClause={}},D.QueryParser.parseClause=function(e){var t=e.peekLexeme();if(null!=t)switch(t.type){case D.QueryLexer.PRESENCE:return D.QueryParser.parsePresence;case D.QueryLexer.FIELD:return D.QueryParser.parseField;case D.QueryLexer.TERM:return D.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+t.type;throw 1<=t.str.length&&(r+=" with value '"+t.str+"'"),new D.QueryParseError(r,t.start,t.end)}},D.QueryParser.parsePresence=function(e){var t=e.consumeLexeme();if(null!=t){switch(t.str){case"-":e.currentClause.presence=D.Query.presence.PROHIBITED;break;case"+":e.currentClause.presence=D.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+t.str+"'";throw new D.QueryParseError(r,t.start,t.end)}var i=e.peekLexeme();if(null==i){r="expecting term or field, found nothing";throw new D.QueryParseError(r,t.start,t.end)}switch(i.type){case D.QueryLexer.FIELD:return D.QueryParser.parseField;case D.QueryLexer.TERM:return D.QueryParser.parseTerm;default:r="expecting term or field, found '"+i.type+"'";throw new D.QueryParseError(r,i.start,i.end)}}},D.QueryParser.parseField=function(e){var t=e.consumeLexeme();if(null!=t){if(-1==e.query.allFields.indexOf(t.str)){var r=e.query.allFields.map(function(e){return"'"+e+"'"}).join(", "),r="unrecognised field '"+t.str+"', possible fields: "+r;throw new D.QueryParseError(r,t.start,t.end)}e.currentClause.fields=[t.str];e=e.peekLexeme();if(null==e){r="expecting term, found nothing";throw new D.QueryParseError(r,t.start,t.end)}if(e.type===D.QueryLexer.TERM)return D.QueryParser.parseTerm;r="expecting term, found '"+e.type+"'";throw new D.QueryParseError(r,e.start,e.end)}},D.QueryParser.parseTerm=function(e){var t=e.consumeLexeme();if(null!=t){e.currentClause.term=t.str.toLowerCase(),-1!=t.str.indexOf("*")&&(e.currentClause.usePipeline=!1);var r=e.peekLexeme();if(null!=r)switch(r.type){case D.QueryLexer.TERM:return e.nextClause(),D.QueryParser.parseTerm;case D.QueryLexer.FIELD:return e.nextClause(),D.QueryParser.parseField;case D.QueryLexer.EDIT_DISTANCE:return D.QueryParser.parseEditDistance;case D.QueryLexer.BOOST:return D.QueryParser.parseBoost;case D.QueryLexer.PRESENCE:return e.nextClause(),D.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new D.QueryParseError(i,r.start,r.end)}else e.nextClause()}},D.QueryParser.parseEditDistance=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new D.QueryParseError(i,t.start,t.end)}e.currentClause.editDistance=r;var n=e.peekLexeme();if(null!=n)switch(n.type){case D.QueryLexer.TERM:return e.nextClause(),D.QueryParser.parseTerm;case D.QueryLexer.FIELD:return e.nextClause(),D.QueryParser.parseField;case D.QueryLexer.EDIT_DISTANCE:return D.QueryParser.parseEditDistance;case D.QueryLexer.BOOST:return D.QueryParser.parseBoost;case D.QueryLexer.PRESENCE:return e.nextClause(),D.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+n.type+"'";throw new D.QueryParseError(i,n.start,n.end)}else e.nextClause()}},D.QueryParser.parseBoost=function(e){var t=e.consumeLexeme();if(null!=t){var r=parseInt(t.str,10);if(isNaN(r)){var i="boost must be numeric";throw new D.QueryParseError(i,t.start,t.end)}e.currentClause.boost=r;var n=e.peekLexeme();if(null!=n)switch(n.type){case D.QueryLexer.TERM:return e.nextClause(),D.QueryParser.parseTerm;case D.QueryLexer.FIELD:return e.nextClause(),D.QueryParser.parseField;case D.QueryLexer.EDIT_DISTANCE:return D.QueryParser.parseEditDistance;case D.QueryLexer.BOOST:return D.QueryParser.parseBoost;case D.QueryLexer.PRESENCE:return e.nextClause(),D.QueryParser.parsePresence;default:i="Unexpected lexeme type '"+n.type+"'";throw new D.QueryParseError(i,n.start,n.end)}else e.nextClause()}},e=this,r=function(){return D},"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=D:e.lunr=D}();