Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/,T.utils={},T.utils.warn=(e=this,function(t){e.console&&console.warn&&console.warn(t)}),T.utils.asString=function(e){returnnull==e?"":e.toString()},T.utils.clone=function(e){if(null==e)returne;for(vart=Object.create(null),r=Object.keys(e),i=0;i<r.length;i++){varn=r[i],s=e[n];if(Array.isArray(s))t[n]=s.slice();else{if("string"!=typeofs&&"number"!=typeofs&&"boolean"!=typeofs)thrownewTypeError("clone is not deep and does not support nested objects");t[n]=s}}returnt},T.FieldRef=function(e,t,r){this.docRef=e,this.fieldName=t,this._stringValue=r},T.FieldRef.joiner="/",T.FieldRef.fromString=function(e){vart=e.indexOf(T.FieldRef.joiner);if(-1===t)throw"malformed field ref string";varr=e.slice(0,t),i=e.slice(t+1);returnnewT.FieldRef(i,r,e)},T.FieldRef.prototype.toString=function(){returnnull==this._stringValue&&(this._stringValue=this.fieldName+T.FieldRef.joiner+this.docRef),this._stringValue}
*/,T.Pipeline=function(){this._stack=[]},T.Pipeline.registeredFunctions=Object.create(null),T.Pipeline.registerFunction=function(e,t){tinthis.registeredFunctions&&T.utils.warn("Overwriting existing registered function: "+t),e.label=t,T.Pipeline.registeredFunctions[e.label]=e},T.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.labelinthis.registeredFunctions||T.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},T.Pipeline.load=function(e){vart=newT.Pipeline;returne.forEach((function(e){varr=T.Pipeline.registeredFunctions[e];if(!r)thrownewError("Cannot load unregistered function: "+e);t.add(r)})),t},T.Pipeline.prototype.add=function(){vare=Array.prototype.slice.call(arguments);e.forEach((function(e){T.Pipeline.warnIfFunctionNotRegistered(e),this._stack.push(e)}),this)},T.Pipeline.prototype.after=function(e,t){T.Pipeline.warnIfFunctionNotRegistered(t);varr=this._stack.indexOf(e);if(-1==r)thrownewError("Cannot find existingFn");r+=1,this._stack.splice(r,0,t)},T.Pipeline.prototype.before=function(e,t){T.Pipeline.warnIfFunctionNotRegistered(t);varr=this._stack.indexOf(e);if(-1==r)thrownewError("Cannot find existingFn");this._stack.splice(r,0,t)},T.Pipeline.prototype.remove=function(e){vart=this._stack.indexOf(e);-1!=t&&this._stack.splice(t,1)},T.Pipeline.prototype.run=function(e){for(vart=this._stack.length,r=0;r<t;r++){for(vari=this._stack[r],n=[],s=0;s<e.length;s++){varo=i(e[s],s,e);if(null!=o&&""!==o)if(Array.isArray(o))for(vara=0;a<o.length;a++)n.push(o[a]);elsen.push(o)}e=n}returne},T.Pipeline.prototype.runString=function(e,t){varr=newT.Token(e,t);returnthis.run([r]).map((function(e){returne.toString()}))},T.Pipeline.prototype.reset=function(){this._stack=[]},T.Pipeline.prototype.toJSON=function(){returnthis._stack.map((function(e){returnT.Pipeline.warnIfFunctionNotRegistered(e),e.label}))}
*/,T.TokenSet=function(){this.final=!1,this.edges={},this.id=T.TokenSet._nextId,T.TokenSet._nextId+=1},T.TokenSet._nextId=1,T.TokenSet.fromArray=function(e){for(vart=newT.TokenSet.Builder,r=0,i=e.length;r<i;r++)t.insert(e[r]);returnt.finish(),t.root},T.TokenSet.fromClause=function(e){return"editDistance"ine?T.TokenSet.fromFuzzyString(e.term,e.editDistance):T.TokenSet.fromString(e.term)},T.TokenSet.fromFuzzyString=function(e,t){for(varr=newT.TokenSet,i=[{node:r,editsRemaining:t,str:e}];i.length;){varn=i.pop();if(n.str.length>0){vars,o=n.str.charAt(0);oinn.node.edges?s=n.node.edges[o]:(s=newT.TokenSet,n.node.edges[o]=s),1==n.str.length&&(s.final=!0),i.push({node:s,editsRemaining:n.editsRemaining,str:n.str.slice(1)})}if(0!=n.editsRemaining){if("*"inn.node.edges)vara=n.node.edges["*"];else{a=newT.TokenSet;n.node.edges["*"]=a}if(0==n.str.length&&(a.final=!0),i.push({node:a,editsRemaining:n.editsRemaining-1,str:n.str}),n.str.length>1&&i.push({node:n.node,editsRemaining:n.editsRemaining-1,str:n.str.slice(1)}),1==n.str.length&&(n.node.final=!0),n.str.length>=1){if("*"inn.node.edges)varu=n.node.edges["*"];else{u=newT.TokenSet;n.node.edges["*"]=u}1==n.str.length&&(u.final=!0),i.push({node:u,editsRemaining:n.editsRemaining-1,str:n.str.slice(1)})}if(n.str.length>1){varl,c=n.str.charAt(0),h=n.str.charAt(1);hinn.node.edges?l=n.node.edges[h]:(l=newT.TokenSet,n.node.edges[h]=l),1==n.str.length&&(l.final=!0),i.push({node:l,editsRemaining:n.editsRemaining-1,str:c+n.str.slice(2)})}}}returnr},T.TokenSet.fromString=function(e){for(vart=newT.TokenSet,r=t,i=0,n=e.length;i<n;i++){vars=e[i],o=i==n-1;if("*"==s)t.edges[s]=t,t.final=o;else{vara=newT.TokenSet;a.final=o,t.edges[s]=a,t=a}}returnr},T.TokenSet.prototype.toArray=function(){for(vare=[],t=[{prefix:"",node:this}];t.length;){varr=t.pop(),i=Object.keys(r.node.edges),n=i.length;r.node.final&&(r.prefix.charAt(0),e.push(r.prefix));for(vars=0;s<n;s++){varo=i[s];t.push({prefix:r.prefix.concat(o),node:r.node.edges[o]})}}returne},T.TokenSet.prototype.toString=function(){if(this._str)returnthis._str;for(vare=this.final?"1":"0",t=Object.keys(this.edges).sort(),r=t.length,i=0;i<r;i++){varn=t[i];e=e+n+this.edges[n].id}returne},T.TokenSet.prototype.intersect=function(e){for(vart=newT.TokenSet,r=void0,i=[{qNode:e,output:t,node:this}];i.length;){r=i.pop();for(varn=Object.keys(r.qNode.edges),s=n.length,o=Object.keys(r.node.edges),a=o.length,u=0;u<s;u++)for(varl=n[u],c=0;c<a;c++){varh=o[c];if(h==l||"*"==l){vard=r.node.edges[h],f=r.qNode.edges[l],p=d.final&&f.final,y=void0;hinr.output.edges?(y=r.output.edges[h]).final=y.final||p:((y=newT.TokenSet).final=p,r.output.edges[h]=y),i.push({qNode:f,output:y,node:d})}}}returnt},T.TokenSet.Builder=function(){this.previousWord="",this.root=newT.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},T.TokenSet.Builder.prototype.insert=function(e){vart,r=0;if(e<this.previousWord)thrownewError("Out of order word insertion");for(vari=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++){varn=newT.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},T.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},T.TokenSet.Builder.prototype.minimize=function(e){for(vart=this.uncheckedNodes.length-1;t>=e;t--){varr=this.uncheckedNodes[t],i=r.child.toString();iinthis.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}}
/*!
* lunr.Index
* Copyright (C) 2020 Oliver Nightingale
*/,T.Index=function(e){this.invertedIndex=e.invertedIndex,this.fieldVectors=e.fieldVectors,this.tokenSet=e.tokenSet,this.fields=e.fields,this.pipeline=e.pipeline},T.Index.prototype.search=function(e){returnthis.query((function(t){newT.QueryParser(e,t).parse()}))},T.Index.prototype.query=function(e){for(vart=newT.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]]=newT.Vector;e.call(t,t);for(a=0;a<t.clauses.length;a++){varu=t.clauses[a],l=null,c=T.Set.empty;l=u.usePipeline?this.pipeline.runString(u.term,{fields:u.fields}):[u.term];for(varh=0;h<l.length;h++){vard=l[h];u.term=d;varf=T.TokenSet.fromClause(u),p=this.tokenSet.intersect(f).toArray();if(0===p.length&&u.presence===T.Query.presence.REQUIRED){for(vary=0;y<u.fields.length;y++){s[F=u.fields[y]]=T.Set.empty}break}for(varm=0;m<p.length;m++){varg=p[m],x=this.invertedIndex[g],v=x._index;for(y=0;y<u.fields.length;y++){varw=x[F=u.fields[y]],Q=Object.keys(w),k=g+"/"+F,S=newT.Set(Q);if(u.presence==T.Query.presence.REQUIRED&&(c=c.union(S),void0===s[F]&&(s[F]=T.Set.complete)),u.presence!=T.Query.presence.PROHIBITED){if(i[F].upsert(v,u.boost,(function(e,t){returne+t})),!n[k]){for(varE=0;E<Q.length;E++){varL,b=Q[E],P=newT.FieldRef(b,F),O=w[b];void0===(L=r[P])?r[P]=newT.MatchData(g,F,O):L.add(g,F,O)}n[k]=!0}}elsevoid0===o[F]&&(o[F]=T.Set.empty),o[F]=o[F].union(S)}}}if(u.presence===T.Query.presence.REQUIRED)for(y=0;y<u.fields.length;y++){s[F=u.fields[y]]=s[F].intersect(c)}}varI=T.Set.complete,R=T.Set.empty;for(a=0;a<this.fields.length;a++){varF;s[F=this.fields[a]]&&(I=I.intersect(s[F])),o[F]&&(R=R.union(o[F]))}varC=Object.keys(r),N=[],j=Object.create(null);if(t.isNegated()){C=Object.keys(this.fieldVectors);for(a=0;a<C.length;a++){P=C[a];var_=T.FieldRef.fromString(P);r[P]=newT.MatchData}}for(a=0;a<C.length;a++){varD=(_=T.FieldRef.fromString(C[a])).docRef;if(I.contains(D)&&!R.contains(D)){varA,B=this.fieldVectors[_],V=i[_.fieldName].similarity(B);if(void0!==(A=j[D]))A.score+=V,A.matchData.combine(r[_]);else{varz={ref:D,score:V,matchData:r[_]};j[D]=z,N.push(z)}}}returnN.sort((function(e,t){returnt.score-e.score}))},T.Index.prototype.toJSON=function(){vare=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:T.version,fields:this.fields,fieldVectors:t,invertedIndex:e,pipeline:this.pipeline.toJSON()}},T.Index.load=function(e){vart={},r={},i=e.fieldVectors,n=Object.create(null),s=e.invertedIndex,o=newT.TokenSet.Builder,a=T.Pipeline.load(e.pipeline);e.version!=T.version&&T.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+T.version+"' does not match serialized index '"+e.version+"'");for(varu=0;u<i.length;u++){varl=(h=i[u])[0],c=h[1];r[l]=newT.Vector(c)}for(u=0;u<s.length;u++){varh,d=(h=s[u])[0],f=h[1];o.insert(d),n[d]=f}returno.finish(),t.fields=e.fields,t.fieldVectors=r,t.invertedIndex=n,t.tokenSet=o.root,t.pipeline=a,newT.Index(t)}
/*!
* lunr.Builder
* Copyright (C) 2020 Oliver Nightingale
*/,T.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=T.tokenizer,this.pipeline=newT.Pipeline,this.searchPipeline=newT.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},T.Builder.prototype.ref=function(e){this._ref=e},T.Builder.prototype.field=function(e,t){if(/\//.test(e))thrownewRangeError("Field '"+e+"' contains illegal character '/'");this._fields[e]=t||{}},T.Builder.prototype.b=function(e){this._b=e<0?0:e>1?1:e},T.Builder.prototype.k1=function(e){this._k1=e},T.Builder.prototype.add=function(e,t){varr=e[this._ref],i=Object.keys(this._fields);this._documents[r]=t||{},this.documentCount+=1;for(varn=0;n<i.length;n++){vars=i[n],o=this._fields[s].extractor,a=o?o(e):e[s],u=this.tokenizer(a,{fields:[s]}),l=this.pipeline.run(u),c=newT.FieldRef(r,s),h=Object.create(null);this.fieldTermFrequencies[c]=h,this.fieldLengths[c]=0,this.fieldLengths[c]+=l.length;for(vard=0;d<l.length;d++){varf=l[d];if(null==h[f]&&(h[f]=0),h[f]+=1,null==this.invertedIndex[f]){varp=Object.create(null);p._index=this.termIndex,this.termIndex+=1;for(vary=0;y<i.length;y++)p[i[y]]=Object.create(null);this.invertedIndex[f]=p}null==this.invertedIndex[f][s][r]&&(this.invertedIndex[f][s][r]=Object.create(null));for(varm=0;m<this.metadataWhitelist.length;m++){varg=this.metadataWhitelist[m],x=f.metadata[g];null==this.invertedIndex[f][s][r][g]&&(this.invertedIndex[f][s][r][g]=[]),this.invertedIndex[f][s][r][g].push(x)}}}},T.Builder.prototype.calculateAverageFieldLengths=function(){for(vare=Object.keys(this.fieldLengths),t=e.length,r={},i={},n=0;n<t;n++){vars=T.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]}vara=Object.keys(this._fields);for(n=0;n<a.length;n++){varu=a[n];r[u]=r[u]/i[u]}this.averageFieldLength=r},T.Builder.prototype.createFieldVectors=function(){for(vare={},t=Object.keys(this.fieldTermFrequencies),r=t.length,i=Object.create(null),n=0;n<r;n++){for(vars=T.FieldRef.fromString(t[n]),o=s.fieldName,a=this.fieldLengths[s],u=newT.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++){vary,m,g,x=c[p],v=l[x],w=this.invertedIndex[x]._index;void0===i[x]?(y=T.idf(this.invertedIndex[x],this.documentCount),i[x]=y):y=i[x],m=y*((this._k1+1)*v)/(this._k1*(1-this._b+this._b*(a/this.averageFieldLength[o]))+v),m*=d,m*=f,g=Math.round(1e3*m)/1e3,u.insert(w,g)}e[s]=u}this.fieldVectors=e},T.Builder.prototype.createTokenSet=function(){this.tokenSet=T.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},T.Builder.prototype.build=function(){returnthis.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),newT.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},T.Builder.prototype.use=function(e){vart=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},T.MatchData=function(e,t,r){for(vari=Object.create(null),n=Object.keys(r||{}),s=0;s<n.length;s++){varo=n[s];i[o]=r[o].slice()}this.metadata=Object.create(null),void0!==e&&(this.metadata[e]=Object.create(null),this.metadata[e][t]=i)},T.MatchData.prototype.combine=function(e){for(vart=Object.keys(e.metadata),r=0;r<t.length;r++){vari=t[r],n=Object.keys(e.metadata[i]);null==this.metadata[i]&&(this.metadata[i]=Object.create(null));for(vars=0;s<n.length;s++){varo=n[s],a=Object.keys(e.metadata[i][o]);null==this.metadata[i][o]&&(this.metadata[i][o]=Object.create(null));for(varu=0;u<a.length;u++){varl=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])}}}},T.MatchData.prototype.add=function(e,t,r){if(!(einthis.metadata))returnthis.metadata[e]=Object.create(null),void(this.metadata[e][t]=r);if(tinth