(function(){var lunr=function(config){var builder=new lunr.Builder;builder.pipeline.add(lunr.trimmer,lunr.stopWordFilter,lunr.stemmer);builder.searchPipeline.add(lunr.stemmer);config.call(builder,builder);return builder.build()};lunr.version="2.1.2";lunr.utils={};lunr.utils.warn=function(global){return function(message){if(global.console&&console.warn){console.warn(message)}}}(this);lunr.utils.asString=function(obj){if(obj===void 0||obj===null){return""}else{return obj.toString()}};lunr.FieldRef=function(docRef,fieldName){this.docRef=docRef;this.fieldName=fieldName;this._stringValue=fieldName+lunr.FieldRef.joiner+docRef};lunr.FieldRef.joiner="/";lunr.FieldRef.fromString=function(s){var n=s.indexOf(lunr.FieldRef.joiner);if(n===-1){throw"malformed field ref string"}var fieldRef=s.slice(0,n),docRef=s.slice(n+1);return new lunr.FieldRef(docRef,fieldRef)};lunr.FieldRef.prototype.toString=function(){return this._stringValue};lunr.idf=function(posting,documentCount){var documentsWithTerm=0;for(var fieldName in posting){if(fieldName=="_index")continue;documentsWithTerm+=Object.keys(posting[fieldName]).length}var x=(documentCount-documentsWithTerm+.5)/(documentsWithTerm+.5);return Math.log(1+Math.abs(x))};lunr.Token=function(str,metadata){this.str=str||"";this.metadata=metadata||{}};lunr.Token.prototype.toString=function(){return this.str};lunr.Token.prototype.update=function(fn){this.str=fn(this.str,this.metadata);return this};lunr.Token.prototype.clone=function(fn){fn=fn||function(s){return s};return new lunr.Token(fn(this.str,this.metadata),this.metadata)};lunr.tokenizer=function(obj){if(obj==null||obj==undefined){return[]}if(Array.isArray(obj)){return obj.map((function(t){return new lunr.Token(lunr.utils.asString(t).toLowerCase())}))}var str=obj.toString().trim().toLowerCase(),len=str.length,tokens=[];for(var sliceEnd=0,sliceStart=0;sliceEnd<=len;sliceEnd++){var char=str.charAt(sliceEnd),sliceLength=sliceEnd-sliceStart;if(char.match(lunr.tokenizer.separator)||sliceEnd==len){if(sliceLength>0){tokens.push(new lunr.Token(str.slice(sliceStart,sliceEnd),{position:[sliceStart,sliceLength],index:tokens.length}))}sliceStart=sliceEnd+1}}return tokens};lunr.tokenizer.separator=/[\s\-]+/;lunr.Pipeline=function(){this._stack=[]};lunr.Pipeline.registeredFunctions=Object.create(null);lunr.Pipeline.registerFunction=function(fn,label){if(label in this.registeredFunctions){lunr.utils.warn("Overwriting existing registered function: "+label)}fn.label=label;lunr.Pipeline.registeredFunctions[fn.label]=fn};lunr.Pipeline.warnIfFunctionNotRegistered=function(fn){var isRegistered=fn.label&&fn.label in this.registeredFunctions;if(!isRegistered){lunr.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",fn)}};lunr.Pipeline.load=function(serialised){var pipeline=new lunr.Pipeline;serialised.forEach((function(fnName){var fn=lunr.Pipeline.registeredFunctions[fnName];if(fn){pipeline.add(fn)}else{throw new Error("Cannot load unregistered function: "+fnName)}}));return pipeline};lunr.Pipeline.prototype.add=function(){var fns=Array.prototype.slice.call(arguments);fns.forEach((function(fn){lunr.Pipeline.warnIfFunctionNotRegistered(fn);this._stack.push(fn)}),this)};lunr.Pipeline.prototype.after=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(pos==-1){throw new Error("Cannot find existingFn")}pos=pos+1;this._stack.splice(pos,0,newFn)};lunr.Pipeline.prototype.before=function(existingFn,newFn){lunr.Pipeline.warnIfFunctionNotRegistered(newFn);var pos=this._stack.indexOf(existingFn);if(pos==-1){throw new Error("Cannot find existingFn")}this._stack.splice(pos,0,newFn)};lunr.Pipeline.prototype.remove=function(fn){var pos=this._stack.indexOf(fn);if(pos==-1){return}this._stack.splice(pos,1)};lunr.Pipeline.prototype.run=function(tokens){var stackLength=this._stack.length;for(var i=0;i1){if(pivotIndexindex){end=pivotPoint}if(pivotIndex==index){break}sliceLength=end-start;pivotPoint=start+Math.floor(sliceLength/2);pivotIndex=this.elements[pivotPoint*2]}if(pivotIndex==index){return pivotPoint*2}if(pivotIndex>index){return pivotPoint*2}if(pivotIndexbVal){j+=2}else if(aVal==bVal){dotProduct+=a[i+1]*b[j+1];i+=2;j+=2}}return dotProduct};lunr.Vector.prototype.similarity=function(otherVector){return this.dot(otherVector)/(this.magnitude()*otherVector.magnitude())};lunr.Vector.prototype.toArray=function(){var output=new Array(this.elements.length/2);for(var i=1,j=0;i0){var char=frame.str.charAt(0),noEditNode;if(char in frame.node.edges){noEditNode=frame.node.edges[char]}else{noEditNode=new lunr.TokenSet;frame.node.edges[char]=noEditNode}if(frame.str.length==1){noEditNode.final=true}else{stack.push({node:noEditNode,editsRemaining:frame.editsRemaining,str:frame.str.slice(1)})}}if(frame.editsRemaining>0&&frame.str.length>1){var char=frame.str.charAt(1),deletionNode;if(char in frame.node.edges){deletionNode=frame.node.edges[char]}else{deletionNode=new lunr.TokenSet;frame.node.edges[char]=deletionNode}if(frame.str.length<=2){deletionNode.final=true}else{stack.push({node:deletionNode,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(2)})}}if(frame.editsRemaining>0&&frame.str.length==1){frame.node.final=true}if(frame.editsRemaining>0&&frame.str.length>=1){if("*"in frame.node.edges){var substitutionNode=frame.node.edges["*"]}else{var substitutionNode=new lunr.TokenSet;frame.node.edges["*"]=substitutionNode}if(frame.str.length==1){substitutionNode.final=true}else{stack.push({node:substitutionNode,editsRemaining:frame.editsRemaining-1,str:frame.str.slice(1)})}}if(frame.editsRemaining>0){if("*"in frame.node.edges){var insertionNode=frame.node.edges["*"]}else{var insertionNode=new lunr.TokenSet;frame.node.edges["*"]=insertionNode}if(frame.str.length==0){insertionNode.final=true}else{stack.push({node:insertionNode,editsRemaining:frame.editsRemaining-1,str:frame.str})}}if(frame.editsRemaining>0&&frame.str.length>1){var charA=frame.str.charAt(0),charB=frame.str.charAt(1),transposeNode;if(charB in frame.node.edges){transposeNode=frame.node.edges[charB]}else{transposeNode=new lunr.TokenSet;frame.node.edges[charB]=transposeNode}if(frame.str.length==1){transposeNode.final=true}else{stack.push({node:transposeNode,editsRemaining:frame.editsRemaining-1,str:charA+frame.str.slice(2)})}}}return root};lunr.TokenSet.fromString=function(str){var node=new lunr.TokenSet,root=node,wildcardFound=false;for(var i=0,len=str.length;i=downTo;i--){var node=this.uncheckedNodes[i],childKey=node.child.toString();if(childKey in this.minimizedNodes){node.parent.edges[node.char]=this.minimizedNodes[childKey]}else{node.child._str=childKey;this.minimizedNodes[childKey]=node.child}this.uncheckedNodes.pop()}};lunr.Index=function(attrs){this.invertedIndex=attrs.invertedIndex;this.fieldVectors=attrs.fieldVectors;this.tokenSet=attrs.tokenSet;this.fields=attrs.fields;this.pipeline=attrs.pipeline};lunr.Index.prototype.search=function(queryString){return this.query((function(query){var parser=new lunr.QueryParser(queryString,query);parser.parse()}))};lunr.Index.prototype.query=function(fn){var query=new lunr.Query(this.fields),matchingFields=Object.create(null),queryVectors=Object.create(null);fn.call(query,query);for(var i=0;i1){this._b=1}else{this._b=number}};lunr.Builder.prototype.k1=function(number){this._k1=number};lunr.Builder.prototype.add=function(doc){var docRef=doc[this._ref];this.documentCount+=1;for(var i=0;i=this.length){return lunr.QueryLexer.EOS}var char=this.str.charAt(this.pos);this.pos+=1;return char};lunr.QueryLexer.prototype.width=function(){return this.pos-this.start};lunr.QueryLexer.prototype.ignore=function(){if(this.start==this.pos){this.pos+=1}this.start=this.pos};lunr.QueryLexer.prototype.backup=function(){this.pos-=1};lunr.QueryLexer.prototype.acceptDigitRun=function(){var char,charCode;do{char=this.next();charCode=char.charCodeAt(0)}while(charCode>47&&charCode<58);if(char!=lunr.QueryLexer.EOS){this.backup()}};lunr.QueryLexer.prototype.more=function(){return this.pos1){lexer.backup();lexer.emit(lunr.QueryLexer.TERM)}lexer.ignore();if(lexer.more()){return lunr.QueryLexer.lexText}};lunr.QueryLexer.lexEditDistance=function(lexer){lexer.ignore();lexer.acceptDigitRun();lexer.emit(lunr.QueryLexer.EDIT_DISTANCE);return lunr.QueryLexer.lexText};lunr.QueryLexer.lexBoost=function(lexer){lexer.ignore();lexer.acceptDigitRun();lexer.emit(lunr.QueryLexer.BOOST);return lunr.QueryLexer.lexText};lunr.QueryLexer.lexEOS=function(lexer){if(lexer.width()>0){lexer.emit(lunr.QueryLexer.TERM)}};lunr.QueryLexer.termSeparator=lunr.tokenizer.separator;lunr.QueryLexer.lexText=function(lexer){while(true){var char=lexer.next();if(char==lunr.QueryLexer.EOS){return lunr.QueryLexer.lexEOS}if(char.charCodeAt(0)==92){lexer.escapeCharacter();continue}if(char==":"){return lunr.QueryLexer.lexField}if(char=="~"){lexer.backup();if(lexer.width()>0){lexer.emit(lunr.QueryLexer.TERM)}return lunr.QueryLexer.lexEditDistance}if(char=="^"){lexer.backup();if(lexer.width()>0){lexer.emit(lunr.QueryLexer.TERM)}return lunr.QueryLexer.lexBoost}if(char.match(lunr.QueryLexer.termSeparator)){return lunr.QueryLexer.lexTerm}}};lunr.QueryParser=function(str,query){this.lexer=new lunr.QueryLexer(str);this.query=query;this.currentClause={};this.lexemeIdx=0};lunr.QueryParser.prototype.parse=function(){this.lexer.run();this.lexemes=this.lexer.lexemes;var state=lunr.QueryParser.parseFieldOrTerm;while(state){state=state(this)}return this.query};lunr.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]};lunr.QueryParser.prototype.consumeLexeme=function(){var lexeme=this.peekLexeme();this.lexemeIdx+=1;return lexeme};lunr.QueryParser.prototype.nextClause=function(){var completedClause=this.currentClause;this.query.clause(completedClause);this.currentClause={}};lunr.QueryParser.parseFieldOrTerm=function(parser){var lexeme=parser.peekLexeme();if(lexeme==undefined){return}switch(lexeme.type){case lunr.QueryLexer.FIELD:return lunr.QueryParser.parseField;case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:var errorMessage="expected either a field or a term, found "+lexeme.type;if(lexeme.str.length>=1){errorMessage+=" with value '"+lexeme.str+"'"}throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}};lunr.QueryParser.parseField=function(parser){var lexeme=parser.consumeLexeme();if(lexeme==undefined){return}if(parser.query.allFields.indexOf(lexeme.str)==-1){var possibleFields=parser.query.allFields.map((function(f){return"'"+f+"'"})).join(", "),errorMessage="unrecognised field '"+lexeme.str+"', possible fields: "+possibleFields;throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.fields=[lexeme.str];var nextLexeme=parser.peekLexeme();if(nextLexeme==undefined){var errorMessage="expecting term, found nothing";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}switch(nextLexeme.type){case lunr.QueryLexer.TERM:return lunr.QueryParser.parseTerm;default:var errorMessage="expecting term, found '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}};lunr.QueryParser.parseTerm=function(parser){var lexeme=parser.consumeLexeme();if(lexeme==undefined){return}parser.currentClause.term=lexeme.str.toLowerCase();if(lexeme.str.indexOf("*")!=-1){parser.currentClause.usePipeline=false}var nextLexeme=parser.peekLexeme();if(nextLexeme==undefined){parser.nextClause();return}switch(nextLexeme.type){case lunr.QueryLexer.TERM:parser.nextClause();return lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:parser.nextClause();return lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}};lunr.QueryParser.parseEditDistance=function(parser){var lexeme=parser.consumeLexeme();if(lexeme==undefined){return}var editDistance=parseInt(lexeme.str,10);if(isNaN(editDistance)){var errorMessage="edit distance must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.editDistance=editDistance;var nextLexeme=parser.peekLexeme();if(nextLexeme==undefined){parser.nextClause();return}switch(nextLexeme.type){case lunr.QueryLexer.TERM:parser.nextClause();return lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:parser.nextClause();return lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}};lunr.QueryParser.parseBoost=function(parser){var lexeme=parser.consumeLexeme();if(lexeme==undefined){return}var boost=parseInt(lexeme.str,10);if(isNaN(boost)){var errorMessage="boost must be numeric";throw new lunr.QueryParseError(errorMessage,lexeme.start,lexeme.end)}parser.currentClause.boost=boost;var nextLexeme=parser.peekLexeme();if(nextLexeme==undefined){parser.nextClause();return}switch(nextLexeme.type){case lunr.QueryLexer.TERM:parser.nextClause();return lunr.QueryParser.parseTerm;case lunr.QueryLexer.FIELD:parser.nextClause();return lunr.QueryParser.parseField;case lunr.QueryLexer.EDIT_DISTANCE:return lunr.QueryParser.parseEditDistance;case lunr.QueryLexer.BOOST:return lunr.QueryParser.parseBoost;default:var errorMessage="Unexpected lexeme type '"+nextLexeme.type+"'";throw new lunr.QueryParseError(errorMessage,nextLexeme.start,nextLexeme.end)}};(function(root,factory){if(typeof define==="function"&&define.amd){define(factory)}else if(typeof exports==="object"){module.exports=factory()}else{root.lunr=factory()}})(this,(function(){return lunr}))})();