1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-02 18:33:17 +02:00

v0.5.1 Resolution

This commit is contained in:
Thomas Wilkerling
2019-02-12 02:24:18 +01:00
parent 1bfab0e2be
commit f22b23105d
17 changed files with 2210 additions and 755 deletions

201
README.md
View File

@@ -3,23 +3,21 @@
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/doc/flexsearch.svg" alt="Search Library" width="50%">
<br><br>
<a target="_blank" href="https://www.npmjs.com/package/flexsearch"><img src="https://img.shields.io/npm/v/flexsearch.svg"></a>
<!--<img src="https://img.shields.io/badge/status-BETA-orange.svg">-->
<a target="_blank" href="https://travis-ci.org/nextapps-de/flexsearch"><img src="https://travis-ci.org/nextapps-de/flexsearch.svg?branch=master"></a>
<a target="_blank" href="https://coveralls.io/github/nextapps-de/flexsearch?branch=master"><img src="https://coveralls.io/repos/github/nextapps-de/flexsearch/badge.svg?branch=master"></a>
<a target="_blank" href="https://www.codacy.com/app/ts-thomas/FlexSearch?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=nextapps-de/flexsearch&amp;utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a896e010f6b4429aa7bc9a89550320a7"/></a>
<a target="_blank" href="https://github.com/nextapps-de/flexsearch/issues"><img src="https://img.shields.io/github/issues/nextapps-de/flexsearch.svg"></a>
<!--<img src="https://badges.greenkeeper.io/nextapps-de/flexsearch.svg">-->
<a target="_blank" href="https://github.com/nextapps-de/flexsearch/blob/master/LICENSE.md"><img src="https://img.shields.io/npm/l/flexsearch.svg"></a>
</p>
<h1></h1>
<h3>Web's fastest and most memory-flexible full-text search library with zero dependencies.</h3>
When it comes to raw search speed <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-word matching, phonetic transformations or partial matching.
Depending on the used options it also provides the <a href="#memory">most memory-efficient index</a>. Keep in mind that updating and/or removing existing items from the index has a significant cost. When your index needs to be updated very often then <a href="https://github.com/nextapps-de/bulksearch" target="_blank">BulkSearch</a> may be a better choice.
When it comes to raw search speed <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-field search, phonetic transformations or partial matching.
Depending on the used <a href="#options">options</a> it also provides the <a href="#memory">most memory-efficient index</a>. Keep in mind that updating __existing__ items or removing items from the index has a significant cost. When existing items of your index needs to be updated/removed continuously then <a href="https://github.com/nextapps-de/bulksearch" target="_blank">BulkSearch</a> may be a better choice.
FlexSearch also provides you a non-blocking asynchronous processing model as well as web workers to perform any updates or queries on the index in parallel through dedicated balanced threads.
FlexSearch Server is also available here: <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">https://github.com/nextapps-de/flexsearch-server</a>.
FlexSearch Server is available here: <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">https://github.com/nextapps-de/flexsearch-server</a>.
<a href="#installation">Installation Guide</a> &ensp;&bull;&ensp; <a href="#api">API Reference</a> &ensp;&bull;&ensp; <a href="#builds">Custom Builds</a> &ensp;&bull;&ensp; <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">Flexsearch Server</a> &ensp;&bull;&ensp; <a href="CHANGELOG.md">Changelog</a>
@@ -390,7 +388,7 @@ Comparison: <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/
<a name="notes" id="notes"></a>
_* Index Size: The size of memory the index requires_<br>
_** Memory Allocation: The amount of memory which was additionally allocated during a row of 10 queries_<br>
_*** The preset "fastest" was used for this test_ <br>
_*** The preset "fast" was used for this test_ <br>
_**** The preset "memory" was used for this test_
Library Comparison: <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">Benchmark "Gulliver's Travels"</a>
@@ -398,27 +396,56 @@ Library Comparison: <a href="https://raw.githack.com/nextapps-de/flexsearch/mast
<a name="contextual"></a>
## Contextual Search
> __Note:__ This feature is actually not enabled by default. Read <a href="#contextual_enable">here</a> how to enable.
FlexSearch introduce a new scoring mechanism called __Contextual Search__ which was invented by Thomas Wilkerling, the author of this library. A Contextual Search <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">incredibly boost up queries to a complete new level</a> but also requires some additionally memory (depending on ___depth___).
The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole (unlimited) distance.<!--Imagine you add a text block of some sentences to an index ID. Assuming the query includes a combination of first and last word from this text block, are they really relevant to each other?-->
In this way contextual search also <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">improves the results of relevance-based queries</a> on a large amount of text data.
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018
FlexSearch introduce a new scoring mechanism called __Contextual Search__ which was invented by Thomas Wilkerling, the author of this library. A Contextual Search <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark.html" target="_blank">incredibly boost up queries to a complete new level</a> but also requires some additionally memory.
The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole (unlimited) distance.
Imagine you add a text block of some sentences to an index ID. Assuming the query includes a combination of first and last word from this text block, are they really relevant to each other?
In this way contextual search <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">also improves the results of relevance-based queries</a> on large amount of text data.
#### Model of context-based scoring
<p align="center">
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/doc/contextual-index.svg">
</p>
__Note:__ This feature is actually not enabled by default. Read <a href="#contextual_enable">here</a> how to enable.
#### Compare BulkSearch vs. FlexSearch
<a name="dictionary"></a>
#### Lexical Pre-Scored Dictionary / Context-based Map
The index consists of an in-memory pre-scored dictionary as its base. The biggest complexity of these algorithm occurs during the calculation of intersections. As a consequence each additional term in the query has a significant potential to increase complexity. A contextual map comes into play __when the query contains more than 1 term__ and increase effect for each additional term by cutting down the complexity for the intersection calculations. Instead of an increase, the complexity is lowered for each additional term. The contextual index itself is also based on a pre-scored dictionary and follows a memory-friendly strategy.
<table>
<tr></tr>
<tr>
<td align="left"></th>
<td align="left"><b>BulkSearch</b></th>
<td align="left"><b>FlexSearch</b></th>
<td align="left">Type</td>
<td align="left">Complexity</td>
</tr>
<tr>
<td align="left">Each single term query:</td>
<td align="left"><i>1</i></td>
</tr>
<tr></tr>
<tr>
<td align="left">Lexical Pre-Scored Dictionary (Solo):</td>
<td align="left"><i>TERM_COUNT * TERM_MATCHES</i></td>
</tr>
<tr></tr>
<tr>
<td align="left">Lexical Pre-Scored Dictionary + Context-based Map:</td>
<td align="left"><i>TERM_MATCHES / TERM_COUNT</i></td>
</tr>
</table>
The complexity for one single term is always 1.
## Compare BulkSearch vs. FlexSearch
<table>
<tr></tr>
<tr>
<td align="left"></td>
<td align="left"><b>BulkSearch</b></td>
<td align="left"><b>FlexSearch</b></td>
</tr>
<tr>
<td>Access</td>
@@ -435,7 +462,7 @@ __Note:__ This feature is actually not enabled by default. Read <a href="#contex
<tr>
<td>Index Type</td>
<td>Bulk of encoded string data divided into chunks</td>
<td><ol><li>Lexical pre-scored dictionary</li><li>Contextual-based map</li></ol></td>
<td><ol><li>Lexical pre-scored dictionary</li><li>Context-based map</li></ol></td>
</tr>
<tr></tr>
<tr>
@@ -447,7 +474,7 @@ __Note:__ This feature is actually not enabled by default. Read <a href="#contex
<tr>
<td>Weaks</td>
<td><ul><li>less powerful contextual search</li><li>less memory efficient (has to be defragmented from time to time)</li></ul></td>
<td><ul><li>updating / deleting existing items from index is slow</li><li>adding items to the index optimized for super partial matching (tokenize: "full") is slow</li></ul></td>
<td><ul><li>updating existing / deleting items from index is slow</li><li>adding items to the index optimized for partial matching (tokenize: "forward" / "reverse" / "full") is slow</li></ul></td>
</tr>
<tr></tr>
<tr>
@@ -455,14 +482,14 @@ __Note:__ This feature is actually not enabled by default. Read <a href="#contex
<td>Yes</td>
<td>No</td>
</tr>
<!--
<tr></tr>
<tr>
<td>Query Wildcards</td>
<td>Wildcards</td>
<td>Yes</td>
<td>No</td>
</tr>
<tr></tr>
<!--
<tr>
<td>Ranked Searching</td>
<td>Yes</td>
@@ -564,6 +591,8 @@ Index methods:
- <a href="#index.destroy">Index.__destroy__()</a>
- <a href="#index.init">Index.__init__(\<options\>)</a>
- <a href="#index.info">Index.__info__()</a>
- <a href="#where">Index.__find__()</a>
- <a href="#where">Index.__where__()</a>
- <a href="#index.addmatcher">Index.__addMatcher__({_KEY: VALUE_})</a>
- <a href="#index.encode">Index.__encode__(string)</a>
- <a href="#index.export">Index.__export__()</a>
@@ -1297,7 +1326,7 @@ index.where(function(item){
});
```
#### Combine fuzzy search with a where-clause:
#### Combine fuzzy search with a where-clause
Add some content, e.g.:
```js
@@ -1331,7 +1360,9 @@ index.search("foo", {
<a name="tags"></a>
## Tags
Tagging is pretty much the same like adding an index to a database column. Whenever you use ___where___ on an indexed/tagged attribute will improve performance drastically but also at a cost of additional memory.
> __IMPORTANT NOTICE:__ This feature will be removed due to the lack of scaling and redundancy.
Tagging is pretty much the same like adding an additional index to a database column. Whenever you use ___where___ on an indexed/tagged attribute will improve performance drastically but also at a cost of additional memory.
> The colon notation also has to be applied for tags respectively.
@@ -1541,7 +1572,7 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
"match"<br>
"score"<br>
"balance"<br>
"fastest"
"fast"
</td>
<td vertical-align="top">
The <a href="#presets">configuration profile</a>. Choose your preferation.<br>
@@ -1629,7 +1660,7 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
<td align="top">depth<br><br></td>
<td>
false<br>
{number:0-9}
{number}
</td>
<td>Enable/Disable <a href="#contextual">contextual indexing</a> and also sets contextual distance of relevance.</td>
</tr>
@@ -1638,11 +1669,19 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
<td align="top">threshold<br><br></td>
<td>
false<br>
{number:0-9}
{number}
</td>
<td>Enable/Disable the threshold of minimum relevance all results should have.<br><br>Note: It is also possible to set a lower threshold for indexing and pass a higher value when calling <i>index.search(options)</i>.</td>
</tr>
<tr></tr>
<tr>
<td align="top">resolution</td>
<td>
{number}
</td>
<td>Sets the scoring resolution (default: 9).</td>
</tr>
<tr></tr>
<tr>
<td align="top">stemmer<br><br><br></td>
<td>
@@ -1664,7 +1703,7 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
</tr>
<tr></tr>
<tr>
<td align="top">rtl<br><br><br></td>
<td align="top">rtl<br><br></td>
<td>
true<br>
false
@@ -1966,6 +2005,8 @@ The required memory for the index depends on several options:
</tr>
</table>
Adding, removing or updating existing items has a similar complexity.
<a name="consumption"></a>
#### Compare Memory Consumption
@@ -1983,7 +2024,8 @@ __"default"__: Standard profile
```js
{
encode: "icase",
tokenize: "forward"
tokenize: "forward",
resolution: 9
}
```
@@ -1992,7 +2034,8 @@ __"memory"__: Memory-optimized profile
{
encode: "extra",
tokenize: "strict",
threshold: 7
threshold: 0,
resolution: 1
}
```
@@ -2002,7 +2045,8 @@ __"speed"__: Speed-optimized profile
{
encode: "icase",
tokenize: "strict",
threshold: 7,
threshold: 1,
resolution: 3,
depth: 2
}
```
@@ -2012,7 +2056,9 @@ __"match"__: Matching-tolerant profile
```js
{
encode: "extra",
tokenize: "full"
tokenize: "full",
threshold: 1,
resolution: 3
}
```
@@ -2022,8 +2068,9 @@ __"score"__: Relevance-optimized profile
{
encode: "extra",
tokenize: "strict",
threshold: 5,
depth: 5
threshold: 1,
resolution: 9,
depth: 4
}
```
@@ -2033,17 +2080,19 @@ __"balance"__: Most-balanced profile
{
encode: "balance",
tokenize: "strict",
threshold: 6,
threshold: 0,
resolution: 3,
depth: 3
}
```
__"fastest"__: Absolute fastest profile
__"fast"__: Absolute fastest profile
```js
{
encode: "icase",
threshold: 9,
threshold: 8,
resolution: 9,
depth: 1
}
```
@@ -2052,6 +2101,41 @@ Compare these presets:
- <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/matching-presets.html" target="_blank">Relevance Scoring</a><br>
- <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/benchmark-presets.html" target="_blank">Benchmarks</a>
## Performance Guide
Methods to retrieve results sorted from fastest to slowest:
1. `index.find(id) -> doc`
2. `index.where({field: string}) -> Arrary<doc>` with a tag on the same field
3. `index.search(query) -> Arrary<id>` when just adding _id_ and _content_ to the index (no documents)
4. `index.search(query) -> Arrary<doc>` when using documents
5. `index.search(query, { where }) -> Arrary<doc>` when using documents and a where clause
6. `index.where({field: [string, string]}) -> Arrary<doc>` when a tag was set to one of two fields
7. `index.where({field: string}) -> Arrary<doc>` when no tag was set to this field
Methods to change index from fastest to slowest:
1. `index.add(id, string)`
2. `index.add(docs)`
3. `index.delete(id, string)`
4. `index.delete(docs)`
5. `index.update(id, string)`
6. `index.update(docs)`
Performance Checklist:
- Using just id-content-pairs for the index performs almost faster than using docs
- An additional where-clause in `index.search()` has a significant cost
- When adding multiple fields of documents to the index try to set the lowest possible preset for each field
- Make sure the auto-balanced ___cache___ is enabled and has a meaningful value
- Using `index.where()` to find documents is very slow when not using a tagged field
- Getting a document by ID via `index.find(id)` is extremely fast
- Do not enable ___async___ as well as ___worker___ when the index does not claim it
- Use numeric IDs (the datatype length of IDs influences the memory consumption significantly)
- Verify if you can activate _contextual index_ by setting the ___depth___ to a minimum meaningful value and tokenizer to ___"strict"___
- Pass a ___limit___ when searching (lower values performs better)
- Pass a minimum ___threshold___ when searching (higher values performs better)
## Best Practices
##### Split Complexity
@@ -2064,7 +2148,39 @@ var adventure = new FlexSearch();
var comedy = new FlexSearch();
```
This way you can also provide different settings for each category.
This way you can also provide different settings for each category. This is actually the fastest way to perform a fuzzy search.
To make this workaround more extendable you can use a short helper:
```js
var index = {};
function add(id, cat, content){
(index[cat] || (
index[cat] = new FlexSearch
)).add(id, content);
}
function search(cat, query){
return index[cat] ?
index[cat].search(query) : [];
}
```
Add content to the index:
```js
add(1, "action", "Movie Title");
add(2, "adventure", "Movie Title");
add(3, "comedy", "Movie Title");
```
Perform queries:
```js
var results = search("action", "movie title"); // --> [1]
```
<!--
##### Split Complexity by Tags (Document Indexes)
You can also gets the same effect when using documents in combination with tags and a ___where___ clause, e.g.:
@@ -2075,7 +2191,7 @@ var movies = new FlexSearch({
title: "title"
},
tag:{
cat: "cat",
cat: "cat"
}
});
```
@@ -2097,13 +2213,16 @@ var results = search("movie title", {
}
});
```
-->
Split indexes by categories improves performance significantly.
Filter queries by categories will hugely improve performance.
##### Use numeric IDs
It is recommended to use numeric id values as reference when adding content to the index. The byte length of passed ids influences the memory consumption significantly. If this is not possible you should consider to use a index table and map the ids with indexes, this becomes important especially when using contextual indexes on a large amount of content.
<!--
e.g. instead of this:
```js
index.add("fdf12cad-8779-47ab-b614-4dbbd649178b", "content");
@@ -2122,6 +2241,7 @@ index.add(index_table["fdf12cad-8779-47ab-b614-4dbbd649178b"], "content");
```
It is planned to provide a built-in feature which should replace this workaround.
-->
<a name="export"></a>
## Export/Import Index
@@ -2286,6 +2406,11 @@ node compile SUPPORT_WORKER=true
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_WHERE</td>
<td>true, false</td>
</tr>
<tr></tr>
<tr>
<td>SUPPORT_WORKER</td>
<td>true, false</td>

View File

@@ -1,27 +1,28 @@
/*
FlexSearch v0.5.0
FlexSearch v0.5.1
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(g,t,A){let d;(d=A.define)&&d.amd?d([],function(){return t}):(d=A.modules)?d[g.toLowerCase()]=t:"object"===typeof exports?module.exports=t:A[g]=t})("FlexSearch",function(){function g(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:P++;this.init(a,b);A(this,"index",function(){return this.c});A(this,"length",function(){return Object.keys(this.c).length})}function t(a,b){a=a.concat.apply([],a);b&&(D(b)||(w=b.split(":"),1<w.length?b=Q:(w=w[0],b=R)),a.sort(b));return a}function A(a,
b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function y(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function E(a,b,c,e,h,k,f){if(b[c])return b[c];h=h?(9-(f||6))*k+(f||6)*h:k;b[c]=h;h>=f&&(a=a[9-(h+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=e);return h}function H(a,b){if(a){const c=Object.keys(a);for(let e=0,h=c.length;e<h;e++){const h=c[e],f=a[h];if(f)for(let c=0,e=f.length;c<e;c++)if(f[c]===b){1===e?delete a[h]:f.splice(c,1);break}else z(f[c])&&
H(f[c],b)}}}function I(a){let b="",c="";var e="";for(let h=0;h<a.length;h++){const k=a[h];if(k!==c)if(h&&"h"===k){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=k}else b+=k;e=h===a.length-1?"":a[h+1];c=k}return b}function S(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function T(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function R(a,b){a=a[w];b=b[w];return a<b?-1:a>b?1:0}function Q(a,b){const c=w.length;for(let e=
0;e<c;e++)a=a[w[e]],b=b[w[e]];return a<b?-1:a>b?1:0}function U(a,b,c,e){let h=[],k;const f=a.length;if(1<f){a.sort(T);const m=v();let l=a[0],n=l.length,p=0;for(;p<n;)m["@"+l[p++]]=1;let r,q=0,g=0;for(;++g<f;){let u=!1;const V=g===f-1;k=[];l=a[g];n=l.length;for(p=0;p<n;){r=l[p++];var d="@"+r;if(m[d]){const a=m[d];if(a===g){if(V){if(h[q++]=c?c[d]:r,b&&q===b)return h}else m[d]=g+1;u=!0}else e&&(d=k[a]||(k[a]=[]),d[d.length]=r)}}if(!u&&!e)break}if(e&&(q=h.length,(g=k.length)&&(!b||q<b)))for(;g--;)if(r=
k[g])for(p=0,n=r.length;p<n;p++)if(h[q++]=c?c["@"+r[p]]:r[p],b&&q===b)return h}else if(f)if(c)for(a=a[0],e=a.length,b&&b<e&&(e=b),h=Array(e),b=0;b<e;b++)h[b]=c["@"+a[b]];else h=a[0],b&&h.length>b&&(h=h.slice(0,b));return h}function F(a){return"string"===typeof a}function D(a){return"function"===typeof a}function z(a){return"object"===typeof a}function G(a){return"undefined"===typeof a}function K(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}const x=
{encode:"icase",b:"forward",o:!1,cache:!1,async:!1,s:!1,l:!1,threshold:0,depth:0,a:!1},L={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",threshold:9,depth:1}},J=[];let P=0;const M=d("\\W+"),N={},O={};g.create=function(a){return new g(a)};g.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&
J.push(d(b),a[b]);return this};g.registerEncoder=function(a,b){C[a]=b.bind(C);return this};g.registerLanguage=function(a,b){N[a]=b.filter;O[a]=b.stemmer;return this};g.encode=function(a,b){return C[a](b)};g.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=x),c=a.preset;b={};F(a)?(b=L[a],a={}):c&&(b=L[c]);this.b=a.tokenize||b.b||this.b||x.b;this.l=a.rtl||this.l||x.l;this.async="undefined"===typeof Promise||G(c=a.async)?this.async||x.async:c;this.threshold=G(c=a.threshold)?
b.threshold||this.threshold||x.threshold:c;this.depth=G(c=a.depth)?b.depth||this.depth||x.depth:c;this.h=(c=G(c=a.encode)?b.encode||x.encode:c)&&C[c]&&C[c].bind(C)||(D(c)?c:this.h||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=N[c]||c;b=this.h;var e=v();if(c)for(var h=0;h<c.length;h++){var k=b?b(c[h]):c[h];e[k]=String.fromCharCode(65E3-c.length+h)}this.filter=c=e}if(c=a.stemmer){var f;b=O[c]||c;e=this.h;h=[];if(b)for(f in b)b.hasOwnProperty(f)&&(k=e?e(f):f,h.push(d("(?=.{"+(k.length+3)+",})"+
k+"$"),e?e(b[f]):b[f]));this.stemmer=f=h}this.a=f=(c=a.doc)?c:this.a||x.a;this.j=K(10-(this.threshold||0));this.g=v();this.c=v();if(f&&(this.f=v(),a.doc=null,c=f.index=[],b=f.ref={},e=f.field,f.id=f.id.split(":"),e))for(e.constructor===Array||(f.field=e=[e]),f=0;f<e.length;f++)b[e[f]]=f,e[f]=e[f].split(":"),c[f]=new g(a),c[f].f=this.f;return this};g.prototype.encode=function(a){a&&J.length&&(a=y(a,J));a&&this.m.length&&(a=y(a,this.m));a&&this.h&&(a=this.h(a));a&&this.stemmer&&(a=y(a,this.stemmer));
return a};g.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(d(c),a[c]);return this};g.prototype.add=function(a,b,c,e,h){if(this.a&&z(a))return this.i("add",a,b);if(b&&F(b)&&(a||0===a)){var d="@"+a;if(this.c[d]&&!e)return this.update(a,b);if(!h){if(this.async&&"function"!==typeof importScripts){let f=this;d=new Promise(function(c){setTimeout(function(){f.add(a,b,null,e,!0);f=null;c()})});if(c)d.then(c);else return d;return this}if(c)return this.add(a,b,
null,e,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.b;h=D(c)?c(b):b.split(M);const k=v();k._ctx=v();const r=this.threshold,q=this.depth,u=this.j,B=h.length,t=this.l;for(let b=0;b<B;b++){var f=h[b];if(f){var n=f.length,m=(t?b+1:B-b)/B,l="";switch(c){case "reverse":case "both":for(var g=n;--g;)l=f[g]+l,E(u,k,l,a,t?1:(n-g)/n,m,r);l="";case "forward":for(g=0;g<n;g++)l+=f[g],E(u,k,l,a,t?(g+1)/n:1,m,r);break;case "full":for(g=0;g<n;g++){const b=(t?g+1:n-g)/n;for(let c=n;c>g;c--)l=f.substring(g,
c),E(u,k,l,a,b,m,r)}break;default:if(n=E(u,k,f,a,1,m,r),q&&1<B&&n>=r)for(n=k._ctx[f]||(k._ctx[f]=v()),f=this.g[f]||(this.g[f]=K(10-(r||0))),m=b-q,l=b+q+1,0>m&&(m=0),l>B&&(l=B);m<l;m++)m!==b&&E(f,n,h[m],a,0,10-(m<b?b-m:m-b),r)}}}this.c[d]=1}return this};g.prototype.i=function(a,b,c){if(b.constructor===Array)for(let e=0,d=b.length;e<d;e++){if(e===d-1)return this.i(a,b[e],c);this.i(a,b[e])}else{const f=this.a.index;var e=this.a.tag,h=this.a.id;let k;for(var d=0;d<h.length;d++)k=(k||b)[h[d]];if(e)for(h=
0;h<e.length;h++);if("remove"===a){delete this.f["@"+k];for(let a=0,b=f.length;a<b;a++){if(a===b-1)return f[a].remove(k,c);f[a].remove(k)}}h=this.a.field;for(let g=0,l=h.length;g<l;g++){e=h[g];let n;for(d=0;d<e.length;d++)n=(n||b)[e[d]];this.f["@"+k]=b;e=f[g];d="add"===a?e.add:e.update;if(g===l-1)return d.call(e,k,n,c);d.call(e,k,n)}}};g.prototype.update=function(a,b,c){if(this.a&&z(a))return this.i("update",a,b);this.c["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=
function(a,b,c){if(this.a&&z(a))return this.i("remove",a,b);var e="@"+a;if(this.c[e]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;e=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)e.then(b);else return e;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)H(this.j[b],a);this.depth&&H(this.g,a);delete this.c[e]}return this};let w;g.prototype.search=function(a,b,c,e){if(z(b)){if(b.constructor===Array)for(var d=
0;d<b.length;d++)b[d].query=a;else b.query=a;a=b;b=0}let k=a;let f,g=[];if(z(a)&&a.constructor!==Array){(c=a.callback||b)&&(k.callback=null);var m=a.boost;f=a.sort;b=a.limit;var l=a.threshold;a=a.query}if(this.a){l=this.a.ref;var u=this.a.index,p=k.field;if(p)k.field=null;else if(k.constructor===Array){var r=k;p=[];for(var q=0;q<k.length;q++)p[q]=k[q].field}else p=Object.keys(l);if(z(p)){p.constructor===Array||(p=[p]);q=p.length;for(a=0;a<q;a++)r&&(k=r[a]),g[a]=u[l[p[a]]].search(k);return c?c(t(g,
f)):this.async?new Promise(function(a){Promise.all(g).then(function(b){a(t(b,f))})}):t(g,f)}return u[l[p]].search(k,c)}l||(l=this.threshold||0);D(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!e){if(this.async&&"function"!==typeof importScripts){let a=this;l=new Promise(function(c){setTimeout(function(){c(a.search(k,b,null,!0));a=null})});if(c)l.then(c);else return l;return this}if(c)return c(this.search(k,b,null,!0)),this}if(!a||!F(a))return g;k=a;k=this.encode(k);if(!k.length)return g;c=this.b;c=D(c)?c(k):
k.split(M);r=c.length;a=!0;e=[];d=v();1<r&&(this.depth?(u=!0,q=c[0],d[q]=1):c.sort(S));if(!u||(p=this.g)[q]){let b=0;m&&(l=(l||1)/m,0>m&&(b=l));for(m=u?1:0;m<r;m++){const f=c[m];if(f){if(!d[f]){const c=[];let g=!1,h=0;if(q=u?p[q]:this.j){let a;for(let d=b;d<10-l;d++)if(a=q[d][f])c[h++]=a,g=!0}if(g)e[e.length]=1<h?c.concat.apply([],c):c[0];else{a=!1;break}d[f]=1}q=f}}}else a=!1;a&&(g=U(e,b,this.f,!1));f&&(g=t([g],f));return g};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=
function(){this.j=this.g=this.c=null;if(this.a){const a=this.f.index;for(let b=0;b<a.length;b++)a.destroy();this.f=null}return this};const C={icase:function(a){return a.toLowerCase()},simple:function(){const a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & "),
" and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=y(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=y(b,a));c||1<b.length&&(b=I(b));return b}}(),extra:function(){const a=[d("p"),
"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+y(d.substring(1),a))}b=b.join(" ");b=I(b)}return b}}(),balance:function(){const a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return I(y(b.toLowerCase(),a))}}()};return g}(!1),this);
'use strict';(function(n,u,A){let f;(f=A.define)&&f.amd?f([],function(){return u}):(f=A.modules)?f[n.toLowerCase()]=u:"object"===typeof exports?module.exports=u:A[n]=u})("FlexSearch",function(){function n(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:Q++;this.init(a,b);A(this,"index",function(){return this.f});A(this,"length",function(){return Object.keys(this.f).length})}function u(a,b){a=a.concat.apply([],a);b&&(F(b)||(x=b.split(":"),1<x.length?b=R:(x=x[0],b=S)),a.sort(b));return a}function A(a,
b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function z(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function G(a,b,c,d,g,h,e,k){if(b[c])return b[c];g=g?(k-(e||k/1.5))*h+(e||k/1.5)*g:h;b[c]=g;g>=e&&(a=a[k-(g+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return g}function I(a,b){if(a){const c=Object.keys(a);for(let d=0,g=c.length;d<g;d++){const g=c[d],e=a[g];if(e)for(let c=0,d=e.length;c<d;c++)if(e[c]===b){1===d?delete a[g]:e.splice(c,1);break}else y(e[c])&&
I(e[c],b)}}}function J(a){let b="",c="";var d="";for(let g=0;g<a.length;g++){const h=a[g];if(h!==c)if(g&&"h"===h){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=h}else b+=h;d=g===a.length-1?"":a[g+1];c=h}return b}function T(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function U(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function S(a,b){a=a[x];b=b[x];return a<b?-1:a>b?1:0}function R(a,b){const c=x.length;for(let d=
0;d<c;d++)a=a[x[d]],b=b[x[d]];return a<b?-1:a>b?1:0}function V(a,b,c,d,g){c=[];let h;const e=a.length;if(1<e){a.sort(U);const k=v();let m=a[0],l=m.length,w=0;for(;w<l;)k["@"+m[w++]]=1;let p,B=0,r=0;for(;++r<e;){let q=!1;const n=r===e-1;h=[];m=a[r];l=m.length;for(w=0;w<l;){p=m[w++];var f="@"+p;if(k[f]){const a=k[f];if(a===r){if(n){if(c[B++]=d?d[p]:p,b&&B===b)return c}else k[f]=r+1;q=!0}else g&&(f=h[a]||(h[a]=[]),f[f.length]=p)}}if(!q&&!g)break}if(g&&(B=c.length,(r=h.length)&&(!b||B<b)))for(;r--;)if(p=
h[r])for(w=0,l=p.length;w<l;w++)if(c[B++]=d?d[p[w]]:p[w],b&&B===b)return c}else if(e)if(d)for(a=a[0],g=a.length,b&&b<g&&(g=b),c=Array(g),b=0;b<g;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function H(a){return"string"===typeof a}function F(a){return"function"===typeof a}function y(a){return"object"===typeof a}function D(a){return"undefined"===typeof a}function L(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}const t={encode:"icase",
c:"forward",v:!1,cache:!1,async:!1,w:!1,m:!1,b:!1,s:!1,a:9,threshold:0,depth:0},M={memory:{encode:"extra",c:"strict",threshold:0,a:1},speed:{encode:"icase",c:"strict",threshold:1,a:3,depth:2},match:{encode:"extra",c:"full",threshold:1,a:3},score:{encode:"extra",c:"strict",threshold:1,a:9,depth:4},balance:{encode:"balance",c:"strict",threshold:0,a:3,depth:3},fast:{encode:"icase",c:"strict",threshold:8,a:9,depth:1}},K=[];let Q=0;const N=f("\\W+"),O={},P={};n.create=function(a){return new n(a)};n.registerMatcher=
function(a){for(const b in a)a.hasOwnProperty(b)&&K.push(f(b),a[b]);return this};n.registerEncoder=function(a,b){E[a]=b.bind(E);return this};n.registerLanguage=function(a,b){O[a]=b.filter;P[a]=b.stemmer;return this};n.encode=function(a,b){return E[a](b)};n.prototype.init=function(a,b){this.o=[];if(b){var c=b.preset;a=b}else a||(a=t),c=a.preset;b={};H(a)?(b=M[a],a={}):c&&(b=M[c]);this.c=a.tokenize||b.c||this.c||t.c;this.m=a.rtl||this.m||t.m;this.async="undefined"===typeof Promise||D(c=a.async)?this.async||
t.async:c;this.threshold=D(c=a.threshold)?b.threshold||this.threshold||t.threshold:c;this.a=D(c=a.resolution)?c=b.a||this.a||t.a:c;c<=this.threshold&&(this.a=this.threshold+1);this.depth=D(c=a.depth)?b.depth||this.depth||t.depth:c;this.s=D(c=a.paging)?this.s||t.s:c;this.i=(c=D(c=a.encode)?b.encode||t.encode:c)&&E[c]&&E[c].bind(E)||(F(c)?c:this.i||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=O[c]||c;b=this.i;var d=v();if(c)for(var g=0;g<c.length;g++){var h=b?b(c[g]):c[g];d[h]=String.fromCharCode(65E3-
c.length+g)}this.filter=c=d}if(c=a.stemmer){var e;b=P[c]||c;d=this.i;g=[];if(b)for(e in b)b.hasOwnProperty(e)&&(h=d?d(e):e,g.push(f("(?=.{"+(h.length+3)+",})"+h+"$"),d?d(b[e]):b[e]));this.stemmer=e=g}this.b=e=(c=a.doc)?c:this.b||t.b;this.l=L(this.a-(this.threshold||0));this.h=v();this.f=v();if(e&&(this.g=v(),a.doc=null,c=e.index=[],b=e.ref={},d=e.field,e.id.constructor===Array||(e.id=e.id.split(":")),d)){let g;d.constructor!==Array&&(y(d)?(g=d,e.field=d=Object.keys(d)):e.field=d=[d]);for(e=0;e<d.length;e++)d[e].constructor!==
Array&&(g&&(a=g[d[e]]),b[d[e]]=e,d[e]=d[e].split(":")),c[e]=new n(a),c[e].g=this.g}return this};n.prototype.encode=function(a){a&&K.length&&(a=z(a,K));a&&this.o.length&&(a=z(a,this.o));a&&this.i&&(a=this.i(a));a&&this.stemmer&&(a=z(a,this.stemmer));return a};n.prototype.addMatcher=function(a){const b=this.o;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};n.prototype.add=function(a,b,c,d,g){if(this.b&&y(a))return this.j("add",a,b);if(b&&H(b)&&(a||0===a)){var f="@"+a;if(this.f[f]&&
!d)return this.update(a,b);if(!g){if(this.async&&"function"!==typeof importScripts){let e=this;f=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)f.then(c);else return f;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;g=F(c)?c(b):b.split(N);const h=v();h._ctx=v();const p=this.threshold,n=this.depth,r=this.a,t=this.l,C=g.length,u=this.m;for(let b=0;b<C;b++){var e=g[b];if(e){var k=e.length,q=(u?b+1:C-b)/
C,m="";switch(c){case "reverse":case "both":for(var l=k;--l;)m=e[l]+m,G(t,h,m,a,u?1:(k-l)/k,q,p,r-1);m="";case "forward":for(l=0;l<k;l++)m+=e[l],G(t,h,m,a,u?(l+1)/k:1,q,p,r-1);break;case "full":for(l=0;l<k;l++){const b=(u?l+1:k-l)/k;for(let c=k;c>l;c--)m=e.substring(l,c),G(t,h,m,a,b,q,p,r-1)}break;default:if(k=G(t,h,e,a,1,q,p,r-1),n&&1<C&&k>=p)for(k=h._ctx[e]||(h._ctx[e]=v()),e=this.h[e]||(this.h[e]=L(r-(p||0))),q=b-n,m=b+n+1,0>q&&(q=0),m>C&&(m=C);q<m;q++)q!==b&&G(e,k,g[q],a,0,r-(q<b?b-q:q-b),p,r-
1)}}}this.f[f]=1}return this};n.prototype.j=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.j(a,b[d],c);this.j(a,b[d])}else{const h=this.b.index;var d=this.b.tag,g=this.b.id;let m;let l;for(var f=0;f<g.length;f++)m=(m||b)[g[f]];if(d){for(g=0;g<d.length;g++){var e=d[g];var k=e.split(":");for(f=0;f<k.length;f++)l=(l||b)[k[f]];l="@"+l}k=this.u[e];k=k[l]||(k[l]=[])}if("remove"===a){delete this.g[m];for(let a=0,b=h.length;a<b;a++){if(a===b-1)return h[a].remove(m,
c);h[a].remove(m)}}g=this.b.field;k&&(k[k.length]=b);for(let f=0,k=g.length;f<k;f++){d=g[f];let l;for(e=0;e<d.length;e++)l=(l||b)[d[e]];this.g[m]=b;d=h[f];e="add"===a?d.add:d.update;if(f===k-1)return e.call(d,m,l,c);e.call(d,m,l)}}};n.prototype.update=function(a,b,c){if(this.b&&y(a))return this.j("update",a,b);this.f["@"+a]&&H(b)&&(this.remove(a),this.add(a,b,c,!0));return this};n.prototype.remove=function(a,b,c){if(this.b&&y(a))return this.j("remove",a,b);var d="@"+a;if(this.f[d]){if(!c){if(this.async&&
"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.a-(this.threshold||0);b++)I(this.l[b],a);this.depth&&I(this.h,a);delete this.f[d]}return this};let x;n.prototype.search=function(a,b,c,d){if(y(b)){if(b.constructor===Array)for(var f=0;f<b.length;f++)b[f].query=a;else b.query=a;a=b;b=0}let h=a;let e,k=[];if(y(a)&&a.constructor!==
Array){(c=a.callback||b)&&(h.callback=null);e=a.sort;b=a.limit;var q=a.threshold;a=a.query}if(this.b){q=this.b.ref;var m=this.b.index,l=h.field;if(l)h.field=null;else if(h.constructor===Array){var n=h;l=[];for(var p=0;p<h.length;p++)l[p]=h[p].field}else l=Object.keys(q);if(y(l)){e&&(h.sort=null);l.constructor===Array||(l=[l]);p=l.length;for(a=0;a<p;a++)n&&(h=n[a]),k[a]=m[q[l[a]]].search(h);return c?c(u(k,e)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(u(b,e))})}):u(k,e)}return m[q[l]].search(h,
c)}q||(q=this.threshold||0);F(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;q=new Promise(function(c){setTimeout(function(){c(a.search(h,b,null,!0));a=null})});if(c)q.then(c);else return q;return this}if(c)return c(this.search(h,b,null,!0)),this}if(!a||!H(a))return k;h=a;h=this.encode(h);if(!h.length)return k;c=this.c;c=F(c)?c(h):h.split(N);n=c.length;a=!0;d=[];f=v();1<n&&(this.depth?(m=!0,p=c[0],f[p]=1):c.sort(T));if(!m||(l=this.h)[p]){let b=
this.a;for(let e=m?1:0;e<n;e++){const g=c[e];if(g){if(!f[g]){const c=[];let e=!1,h=0;if(p=m?l[p]:this.l){let a;for(let d=0;d<b-q;d++)if(a=p[d][g])c[h++]=a,e=!0}if(e)d[d.length]=1<h?c.concat.apply([],c):c[0];else{a=!1;break}f[g]=1}p=g}}}else a=!1;a&&(k=V(d,b,void 0,this.g,!1));e&&(k=u([k],e));return k};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.l=this.h=this.f=null;if(this.b){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};
const E={icase:function(a){return a.toLowerCase()},simple:function(){const a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=z(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=
[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=z(b,a));c||1<b.length&&(b=J(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=
b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+z(d.substring(1),a))}b=b.join(" ");b=J(b)}return b}}(),balance:function(){const a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return J(z(b.toLowerCase(),a))}}()};return n}(!1),this);

View File

@@ -1,44 +1,45 @@
/*
FlexSearch v0.5.0
FlexSearch v0.5.1
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';function Q(f){var k=0;return function(){return k<f.length?{done:!1,value:f[k++]}:{done:!0}}}function R(f){var k="undefined"!=typeof Symbol&&Symbol.iterator&&f[Symbol.iterator];return k?k.call(f):{next:Q(f)}}var X="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,Y="function"==typeof Object.defineProperties?Object.defineProperty:function(f,k,e){f!=Array.prototype&&f!=Object.prototype&&(f[k]=e.value)};
function Z(f,k){if(k){var e=X;f=f.split(".");for(var g=0;g<f.length-1;g++){var l=f[g];l in e||(e[l]={});e=e[l]}f=f[f.length-1];g=e[f];k=k(g);k!=g&&null!=k&&Y(e,f,{configurable:!0,writable:!0,value:k})}}
Z("Promise",function(f){function k(c){this.f=0;this.o=void 0;this.a=[];var e=this.j();try{c(e.resolve,e.reject)}catch(A){e.reject(A)}}function e(){this.a=null}function g(c){return c instanceof k?c:new k(function(e){e(c)})}if(f)return f;e.prototype.f=function(c){if(null==this.a){this.a=[];var e=this;this.j(function(){e.o()})}this.a.push(c)};var l=X.setTimeout;e.prototype.j=function(c){l(c,0)};e.prototype.o=function(){for(;this.a&&this.a.length;){var c=this.a;this.a=[];for(var e=0;e<c.length;++e){var k=
c[e];c[e]=null;try{k()}catch(G){this.l(G)}}}this.a=null};e.prototype.l=function(c){this.j(function(){throw c;})};k.prototype.j=function(){function c(c){return function(f){k||(k=!0,c.call(e,f))}}var e=this,k=!1;return{resolve:c(this.M),reject:c(this.l)}};k.prototype.M=function(c){if(c===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(c instanceof k)this.N(c);else{a:switch(typeof c){case "object":var e=null!=c;break a;case "function":e=!0;break a;default:e=!1}e?this.L(c):this.v(c)}};
k.prototype.L=function(c){var e=void 0;try{e=c.then}catch(A){this.l(A);return}"function"==typeof e?this.O(e,c):this.v(c)};k.prototype.l=function(c){this.J(2,c)};k.prototype.v=function(c){this.J(1,c)};k.prototype.J=function(c,e){if(0!=this.f)throw Error("Cannot settle("+c+", "+e+"): Promise already settled in state"+this.f);this.f=c;this.o=e;this.K()};k.prototype.K=function(){if(null!=this.a){for(var c=0;c<this.a.length;++c)I.f(this.a[c]);this.a=null}};var I=new e;k.prototype.N=function(c){var e=this.j();
c.D(e.resolve,e.reject)};k.prototype.O=function(c,e){var k=this.j();try{c.call(e,k.resolve,k.reject)}catch(G){k.reject(G)}};k.prototype.then=function(c,e){function f(c,e){return"function"==typeof c?function(e){try{g(c(e))}catch(P){r(P)}}:e}var g,r,l=new k(function(c,e){g=c;r=e});this.D(f(c,g),f(e,r));return l};k.prototype.catch=function(c){return this.then(void 0,c)};k.prototype.D=function(c,e){function k(){switch(f.f){case 1:c(f.o);break;case 2:e(f.o);break;default:throw Error("Unexpected state: "+
f.f);}}var f=this;null==this.a?I.f(k):this.a.push(k)};k.resolve=g;k.reject=function(c){return new k(function(e,k){k(c)})};k.race=function(c){return new k(function(e,k){for(var f=R(c),l=f.next();!l.done;l=f.next())g(l.value).D(e,k)})};k.all=function(c){var e=R(c),f=e.next();return f.done?g([]):new k(function(c,k){function l(e){return function(k){r[e]=k;A--;0==A&&c(r)}}var r=[],A=0;do r.push(void 0),A++,g(f.value).D(l(r.length-1),k),f=e.next();while(!f.done)})};return k});
(function(f,k,e){var g;(g=e.define)&&g.amd?g([],function(){return k}):(g=e.modules)?g[f.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[f]=k})("FlexSearch",function ea(f){function e(a,b){var d=b?b.id:a&&a.id;this.id=d||0===d?d:fa++;this.init(a,b);I(this,"index",function(){return this.c});I(this,"length",function(){return Object.keys(this.c).length})}function g(a,b,d,m){this.B!==this.h&&(this.u=this.u.concat(d),this.B++,m&&this.u.length>=m&&(this.B=this.h),this.G&&this.B===this.h&&(this.cache&&
this.w.set(b,this.u),this.G(this.u),this.u=[]));return this}function l(a,b){a=a.concat.apply([],a);b&&(K(b)||(E=b.split(":"),1<E.length?b=ca:(E=E[0],b=ba)),a.sort(b));return a}function I(a,b,d){Object.defineProperty(a,b,{get:d})}function c(a){return new RegExp(a,"g")}function r(a,b){for(var d=0;d<b.length;d+=2)a=a.replace(b[d],b[d+1]);return a}function A(a,b,d,m,c,h,e){if(b[d])return b[d];c=c?(9-(e||6))*h+(e||6)*c:h;b[d]=c;c>=e&&(a=a[9-(c+.5>>0)],a=a[d]||(a[d]=[]),a[a.length]=m);return c}function G(a,
b){if(a)for(var d=Object.keys(a),c=0,e=d.length;c<e;c++){var h=d[c],D=a[h];if(D)for(var B=0,f=D.length;B<f;B++)if(D[B]===b){1===f?delete a[h]:D.splice(B,1);break}else J(D[B])&&G(D[B],b)}}function O(a){for(var b="",d="",c="",e=0;e<a.length;e++){var h=a[e];if(h!==d)if(e&&"h"===h){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d)&&c||" "===d)b+=h}else b+=h;c=e===a.length-1?"":a[e+1];d=h}return b}function da(a,b){a=a.length-b.length;return 0>
a?1:a?-1:0}function aa(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function ba(a,b){a=a[E];b=b[E];return a<b?-1:a>b?1:0}function ca(a,b){for(var d=E.length,c=0;c<d;c++)a=a[E[c]],b=b[E[c]];return a<b?-1:a>b?1:0}function P(a,b,d,c){var e=[],h=a.length;if(1<h){a.sort(aa);for(var m=C(),B=a[0],f=B.length,w=0;w<f;)m["@"+B[w++]]=1;for(var n,F=0,u=0;++u<h;){var t=!1,g=u===h-1;var v=[];B=a[u];f=B.length;for(w=0;w<f;){n=B[w++];var p="@"+n;if(m[p]){var y=m[p];if(y===u){if(g){if(e[F++]=d?d[p]:n,b&&F===b)return e}else m[p]=
u+1;t=!0}else c&&(p=v[y]||(v[y]=[]),p[p.length]=n)}}if(!t&&!c)break}if(c&&(F=e.length,(u=v.length)&&(!b||F<b)))for(;u--;)if(n=v[u])for(w=0,f=n.length;w<f;w++)if(e[F++]=d?d["@"+n[w]]:n[w],b&&F===b)return e}else if(h)if(d)for(a=a[0],c=a.length,b&&b<c&&(c=b),e=Array(c),b=0;b<c;b++)e[b]=d["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function M(a){return"string"===typeof a}function K(a){return"function"===typeof a}function J(a){return"object"===typeof a}function H(a){return"undefined"===
typeof a}function S(a){for(var b=Array(a),d=0;d<a;d++)b[d]=C();return b}function C(){return Object.create(null)}function ha(){var a,b;self.onmessage=function(d){if(d=d.data)if(d.search){var c=b.search(d.content,d.threshold?{limit:d.limit,threshold:d.threshold}:d.limit);self.postMessage({id:a,content:d.content,limit:d.limit,result:c})}else d.add?b.add(d.id,d.content):d.update?b.update(d.id,d.content):d.remove?b.remove(d.id):d.clear?b.clear():d.info?(d=b.info(),d.worker=a,console.log(d)):d.register&&
(a=d.id,d.options.cache=!1,d.options.async=!1,d.options.worker=!1,b=(new Function(d.register.substring(d.register.indexOf("{")+1,d.register.lastIndexOf("}"))))(),b=new b(d.options))}}function ia(a,b,d,c){a=f("flexsearch","id"+a,ha,function(a){(a=a.data)&&a.result&&c(a.id,a.content,a.result,a.limit)},b);var e=ea.toString();d.id=b;a.postMessage({register:e,options:d,id:b});return a}var z={encode:"icase",g:"forward",C:!1,cache:!1,async:!1,h:!1,F:!1,threshold:0,depth:0,b:!1},T={memory:{encode:"extra",
g:"strict",threshold:7},speed:{encode:"icase",g:"strict",threshold:7,depth:2},match:{encode:"extra",g:"full"},score:{encode:"extra",g:"strict",threshold:5,depth:4},balance:{encode:"balance",g:"strict",threshold:6,depth:3},fastest:{encode:"icase",g:"strict",threshold:9,depth:1}},N=[],fa=0,U=c("\\W+"),V={},W={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&N.push(c(b),a[b]);return this};e.registerEncoder=function(a,b){L[a]=b.bind(L);return this};
e.registerLanguage=function(a,b){V[a]=b.filter;W[a]=b.stemmer;return this};e.encode=function(a,b){return L[a](b)};e.prototype.init=function(a,b){this.f=[];if(b){var d=b.preset;a=b}else a||(a=z),d=a.preset;b={};M(a)?((b=T[a])||console.warn("Preset not found: "+a),a={}):d&&((b=T[d])||console.warn("Preset not found: "+d));if(d=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.a=null;else{var m=parseInt(d,10)||4;this.v=-1;this.B=0;this.u=[];this.G=null;this.a=Array(m);for(var q=0;q<m;q++)this.a[q]=
ia(this.id,q,a,g.bind(this))}this.g=a.tokenize||b.g||this.g||z.g;this.F=a.rtl||this.F||z.F;this.async="undefined"===typeof Promise||H(d=a.async)?this.async||z.async:d;this.h=H(d=a.worker)?this.h||z.h:d;this.threshold=H(d=a.threshold)?b.threshold||this.threshold||z.threshold:d;this.depth=H(d=a.depth)?b.depth||this.depth||z.depth:d;this.C=H(d=a.suggest)?this.C||z.C:d;this.j=(d=H(d=a.encode)?b.encode||z.encode:d)&&L[d]&&L[d].bind(L)||(K(d)?d:this.j||!1);(d=a.matcher)&&this.addMatcher(d);if(d=a.filter){d=
V[d]||d;b=this.j;m=C();if(d)for(q=0;q<d.length;q++){var h=b?b(d[q]):d[q];m[h]=String.fromCharCode(65E3-d.length+q)}this.filter=m}if(d=a.stemmer){b=W[d]||d;m=this.j;q=[];if(b)for(var D in b)b.hasOwnProperty(D)&&(h=m?m(D):D,q.push(c("(?=.{"+(h.length+3)+",})"+h+"$"),m?m(b[D]):b[D]));this.stemmer=q}this.b=h=(d=a.doc)?d:this.b||z.b;this.m=S(10-(this.threshold||0));this.s=C();this.c=C();if(h){this.i=C();a.doc=null;D=h.index=[];b=h.ref={};m=h.field;q=h.tag;h.id=h.id.split(":");if(q){this.H=C();q.constructor===
Array||(h.tag=q=[q]);for(var f=0;f<q.length;f++)this.H[q[f]]=C(),q[f]=q[f].split(":")}if(m)for(m.constructor===Array||(h.field=m=[m]),h=0;h<m.length;h++)b[m[h]]=h,m[h]=m[h].split(":"),D[h]=new e(a),D[h].i=this.i,q&&(D[h].H=this.H)}this.o=!0;this.w=(this.cache=d=H(d=a.cache)?this.cache||z.cache:d)?new ja(d):!1;return this};e.prototype.encode=function(a){a&&N.length&&(a=r(a,N));a&&this.f.length&&(a=r(a,this.f));a&&this.j&&(a=this.j(a));a&&this.stemmer&&(a=r(a,this.stemmer));return a};e.prototype.addMatcher=
function(a){var b=this.f,d;for(d in a)a.hasOwnProperty(d)&&b.push(c(d),a[d]);return this};e.prototype.add=function(a,b,d,c,e){if(this.b&&J(a))return this.l("add",a,b);if(b&&M(b)&&(a||0===a)){var h="@"+a;if(this.c[h]&&!c)return this.update(a,b);if(this.h)return++this.v>=this.a.length&&(this.v=0),this.a[this.v].postMessage({add:!0,id:a,content:b}),this.c[h]=""+this.v,d&&d(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var m=this;h=new Promise(function(d){setTimeout(function(){m.add(a,
b,null,c,!0);m=null;d()})});if(d)h.then(d);else return h;return this}if(d)return this.add(a,b,null,c,!0),d(),this}b=this.encode(b);if(!b.length)return this;d=this.g;e=K(d)?d(b):b.split(U);var q=C();q._ctx=C();for(var f=this.threshold,w=this.depth,n=this.m,g=e.length,u=this.F,t=0;t<g;t++){var l=e[t];if(l){var v=l.length,p=(u?t+1:g-t)/g,y="";switch(d){case "reverse":case "both":for(var x=v;--x;)y=l[x]+y,A(n,q,y,a,u?1:(v-x)/v,p,f);y="";case "forward":for(x=0;x<v;x++)y+=l[x],A(n,q,y,a,u?(x+1)/v:1,p,f);
break;case "full":for(x=0;x<v;x++)for(var r=(u?x+1:v-x)/v,z=v;z>x;z--)y=l.substring(x,z),A(n,q,y,a,r,p,f);break;default:if(v=A(n,q,l,a,1,p,f),w&&1<g&&v>=f)for(v=q._ctx[l]||(q._ctx[l]=C()),l=this.s[l]||(this.s[l]=S(10-(f||0))),p=t-w,y=t+w+1,0>p&&(p=0),y>g&&(y=g);p<y;p++)p!==t&&A(l,v,e[p],a,0,10-(p<t?t-p:p-t),f)}}}this.c[h]=1;this.o=!1}return this};e.prototype.l=function(a,b,d){if(b.constructor===Array)for(var c=0,e=b.length;c<e;c++){if(c===e-1)return this.l(a,b[c],d);this.l(a,b[c])}else{c=this.b.index;
for(var h=this.b.tag,f=this.b.id,B=0;B<f.length;B++)e=(e||b)[f[B]];if(h)for(f=0;f<h.length;f++);if("remove"===a)for(delete this.i["@"+e],f=0,h=c.length;f<h;f++){if(f===h-1)return c[f].remove(e,d);c[f].remove(e)}f=this.b.field;h=0;for(B=f.length;h<B;h++){for(var l=f[h],g=void 0,n=0;n<l.length;n++)g=(g||b)[l[n]];this.i["@"+e]=b;l=c[h];n="add"===a?l.add:l.update;if(h===B-1)return n.call(l,e,g,d);n.call(l,e,g)}}};e.prototype.update=function(a,b,d){if(this.b&&J(a))return this.l("update",a,b);this.c["@"+
a]&&M(b)&&(this.remove(a),this.add(a,b,d,!0));return this};e.prototype.remove=function(a,b,d){if(this.b&&J(a))return this.l("remove",a,b);var c="@"+a;if(this.c[c]){if(this.h)return this.a[this.c[c]].postMessage({remove:!0,id:a}),delete this.c[c],b&&b(),this;if(!d){if(this.async&&"function"!==typeof importScripts){var e=this;c=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<
10-(this.threshold||0);b++)G(this.m[b],a);this.depth&&G(this.s,a);delete this.c[c];this.o=!1}return this};var E;e.prototype.search=function(a,b,d,c){if(J(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var h=a,f=[];if(J(a)&&a.constructor!==Array){(d=a.callback||b)&&(h.callback=null);var m=a.boost;var g=a.where;var w=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.b){a=this.b.ref;n=this.b.index;if(g=h.field)h.field=null;else if(h.constructor===Array){var F=
h;g=[];for(var u=0;u<h.length;u++)g[u]=h[u].field}else g=Object.keys(a);if(J(g)){g.constructor===Array||(g=[g]);u=g.length;for(var t=0;t<u;t++)F&&(h=F[t]),f[t]=n[a[g[t]]].search(h);return d?d(l(f,w)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(l(b,w))})}):l(f,w)}return n[a[g]].search(h,d)}n||(n=this.threshold||0);K(b)?(d=b,b=1E3):b||0===b||(b=1E3);if(this.h)for(this.G=d,this.B=0,this.u=[],g=0;g<this.h;g++)this.a[g].postMessage({search:!0,limit:b,threshold:n,content:a});else{if(!c){if(this.async&&
"function"!==typeof importScripts){var r=this;a=new Promise(function(a){setTimeout(function(){a(r.search(h,b,null,!0));r=null})});if(d)a.then(d);else return a;return this}if(d)return d(this.search(h,b,null,!0)),this}if(!a||!M(a))return f;h=a;if(this.cache)if(this.o){if(d=this.w.get(a))return d}else this.w.clear(),this.o=!0;h=this.encode(h);if(!h.length)return f;d=this.g;d=K(d)?d(h):h.split(U);F=d.length;c=!0;e=[];var v=C();if(1<F)if(this.depth){u=!0;var p=d[0];v[p]=1}else d.sort(da);if(!u||(t=this.s)[p]){var y=
0;m&&(n=(n||1)/m,0>m&&(y=n));for(m=u?1:0;m<F;m++){var x=d[m];if(x){if(!v[x]){var z=[],A=!1,E=0;if(p=u?t[p]:this.m)for(var H=void 0,G=y;G<10-n;G++)if(H=p[G][x])z[E++]=H,A=!0;if(A)e[e.length]=1<E?z.concat.apply([],z):z[0];else if(!this.C){c=!1;break}v[x]=1}p=x}}}else c=!1;c&&(f=P(e,b,this.i,this.C));g&&(f=this.where(g,null,b,f));w&&(f=l([f],w));this.cache&&this.w.set(a,f);return f}};e.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};e.prototype.where=function(a,b,d,c){var e=c||this.i,
f=[],m=0,g;if(M(a)){if("id"===a)return[e["@"+b]];var l=1;var w=[a.split(":")];var n=!0}else{if(K(a)){b=c||Object.keys(e);d=b.length;for(g=0;g<d;g++)l=c?c[g]:e[b[g]],a(l)&&(f[m++]=l);return f}d||(d=b);g=Object.keys(a);l=g.length;n=!1;if(1===l&&"id"===g[0])return[e["@"+a.id]];w=Array(l);for(var r=0;r<l;r++)w[r]=g[r].split(":")}r=c||Object.keys(e);for(var u=r.length,t=0;t<u;t++){for(var z=c?c[t]:e[r[t]],v=!0,p=0;p<l;p++){n||(b=a[g[p]]);var y=w[p],x=y.length,A=z;if(1<x)for(var C=0;C<x;C++)A=A[y[C]];else A=
A[y[0]];if(A!==b){v=!1;break}}if(v&&(f[m++]=z,d&&m===d))break}return f};e.prototype.info=function(){if(this.h)for(var a=0;a<this.h;a++)this.a[a].postMessage({info:!0,id:this.id});else{for(var b,d=0,c=0,e=0,f=0;f<10-(this.threshold||0);f++){a=Object.keys(this.m[f]);for(var g=0;g<a.length;g++)b=this.m[f][a[g]].length,d+=1*b+2*a[g].length+4,c+=b,e+=2*a[g].length}a=Object.keys(this.c);b=a.length;for(f=0;f<b;f++)d+=2*a[f].length+2;return{id:this.id,memory:d,items:b,sequences:c,chars:e,cache:this.cache&&
this.cache.A?this.cache.A.length:!1,matcher:N.length+(this.f?this.f.length:0),worker:this.h,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.g}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.w.clear(),this.w=null);this.m=this.s=this.c=null;if(this.b){for(var a=this.i.index,b=0;b<a.length;b++)a.destroy();this.i=null}return this};e.prototype.export=function(){if(this.b){for(var a=this.b.index,b=Array(a.length+
1),d=0;d<a.length;d++)b[d]=[a[d].m,a[d].s,a[d].c];b[d]=this.i;return JSON.stringify(b)}return JSON.stringify([this.m,this.s,this.c])};e.prototype.import=function(a){a=JSON.parse(a);if(this.b){for(var b=this.b.index,d=b.length,c=0;c<d;c++){var e=b[c];e.m=a[c][0];e.s=a[c][1];e.c=a[c][2];e.i=a[d]}this.i=a[d]}else this.m=a[0],this.s=a[1],this.c=a[2],this.i=a[3]};var L={icase:function(a){return a.toLowerCase()},simple:function(){var a=[c("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",c("[\u00e8\u00e9\u00ea\u00eb]"),
"e",c("[\u00ec\u00ed\u00ee\u00ef]"),"i",c("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",c("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",c("[\u00fd\u0177\u00ff]"),"y",c("\u00f1"),"n",c("\u00e7"),"c",c("\u00df"),"s",c(" & ")," and ",c("[-/]")," ",c("[^a-z0-9 ]"),"",c("\\s+")," "];return function(b){b=r(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[c("ae"),"a",c("ai"),"ei",c("ay"),"ei",c("ey"),"ei",c("oe"),"o",c("ue"),"u",c("ie"),"i",c("sz"),"s",c("zs"),"s",c("sh"),"s",c("ck"),"k",c("cc"),
"k",c("dt"),"t",c("ph"),"f",c("pf"),"f",c("ou"),"o",c("uo"),"u"];return function(b,d){if(!b)return b;b=this.simple(b);2<b.length&&(b=r(b,a));d||1<b.length&&(b=O(b));return b}}(),extra:function(){var a=[c("p"),"b",c("z"),"s",c("[cgq]"),"k",c("n"),"m",c("d"),"t",c("[vw]"),"f",c("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var d=0;d<b.length;d++){var c=b[d];1<c.length&&(b[d]=c[0]+r(c.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){var a=
[c("[-/]")," ",c("[^a-z0-9 ]"),"",c("\\s+")," "];return function(b){return O(r(b.toLowerCase(),a))}}()},ja=function(){function a(a){this.clear();this.I=!0!==a&&a}a.prototype.clear=function(){this.cache=C();this.count=C();this.index=C();this.A=[]};a.prototype.set=function(a,c){if(this.I&&H(this.cache[a])){var b=this.A.length;if(b===this.I){b--;var d=this.A[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.A[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=
c};a.prototype.get=function(a){var b=this.cache[a];if(this.I&&b){var c=++this.count[a],e=this.index,f=e[a];if(0<f){for(var g=this.A,l=f;this.count[g[--f]]<=c&&-1!==f;);f++;if(f!==l){for(c=l;c>f;c--)l=g[c-1],g[c]=l,e[l]=c;g[f]=a;e[a]=f}}}return b};return a}();return e}(function(){var f={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,g,l,I,c){l=k?URL.createObjectURL(new Blob(["("+l.toString()+")()"],{type:"text/javascript"})):e+".es5.js";e+="-"+g;f[e]||
(f[e]=[]);f[e][c]=new Worker(l);f[e][c].onmessage=I;console.log("Register Worker: "+e+"@"+c);return f[e][c]}}()),this);
'use strict';function S(f){var k=0;return function(){return k<f.length?{done:!1,value:f[k++]}:{done:!0}}}function T(f){var k="undefined"!=typeof Symbol&&Symbol.iterator&&f[Symbol.iterator];return k?k.call(f):{next:S(f)}}var Z="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,aa="function"==typeof Object.defineProperties?Object.defineProperty:function(f,k,e){f!=Array.prototype&&f!=Object.prototype&&(f[k]=e.value)};
function ba(f,k){if(k){var e=Z;f=f.split(".");for(var n=0;n<f.length-1;n++){var l=f[n];l in e||(e[l]={});e=e[l]}f=f[f.length-1];n=e[f];k=k(n);k!=n&&null!=k&&aa(e,f,{configurable:!0,writable:!0,value:k})}}
ba("Promise",function(f){function k(d){this.g=0;this.s=void 0;this.a=[];var e=this.l();try{d(e.resolve,e.reject)}catch(B){e.reject(B)}}function e(){this.a=null}function n(d){return d instanceof k?d:new k(function(e){e(d)})}if(f)return f;e.prototype.g=function(d){if(null==this.a){this.a=[];var e=this;this.l(function(){e.s()})}this.a.push(d)};var l=Z.setTimeout;e.prototype.l=function(d){l(d,0)};e.prototype.s=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var e=0;e<d.length;++e){var k=
d[e];d[e]=null;try{k()}catch(H){this.m(H)}}}this.a=null};e.prototype.m=function(d){this.l(function(){throw d;})};k.prototype.l=function(){function d(d){return function(f){k||(k=!0,d.call(e,f))}}var e=this,k=!1;return{resolve:d(this.N),reject:d(this.m)}};k.prototype.N=function(d){if(d===this)this.m(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof k)this.O(d);else{a:switch(typeof d){case "object":var e=null!=d;break a;case "function":e=!0;break a;default:e=!1}e?this.M(d):this.w(d)}};
k.prototype.M=function(d){var e=void 0;try{e=d.then}catch(B){this.m(B);return}"function"==typeof e?this.P(e,d):this.w(d)};k.prototype.m=function(d){this.B(2,d)};k.prototype.w=function(d){this.B(1,d)};k.prototype.B=function(d,e){if(0!=this.g)throw Error("Cannot settle("+d+", "+e+"): Promise already settled in state"+this.g);this.g=d;this.s=e;this.J()};k.prototype.J=function(){if(null!=this.a){for(var d=0;d<this.a.length;++d)K.g(this.a[d]);this.a=null}};var K=new e;k.prototype.O=function(d){var e=this.l();
d.G(e.resolve,e.reject)};k.prototype.P=function(d,e){var k=this.l();try{d.call(e,k.resolve,k.reject)}catch(H){k.reject(H)}};k.prototype.then=function(d,e){function f(d,e){return"function"==typeof d?function(e){try{n(d(e))}catch(Q){t(Q)}}:e}var n,t,l=new k(function(d,e){n=d;t=e});this.G(f(d,n),f(e,t));return l};k.prototype.catch=function(d){return this.then(void 0,d)};k.prototype.G=function(d,e){function k(){switch(f.g){case 1:d(f.s);break;case 2:e(f.s);break;default:throw Error("Unexpected state: "+
f.g);}}var f=this;null==this.a?K.g(k):this.a.push(k)};k.resolve=n;k.reject=function(d){return new k(function(e,k){k(d)})};k.race=function(d){return new k(function(e,k){for(var f=T(d),l=f.next();!l.done;l=f.next())n(l.value).G(e,k)})};k.all=function(d){var e=T(d),f=e.next();return f.done?n([]):new k(function(d,k){function l(e){return function(k){t[e]=k;B--;0==B&&d(t)}}var t=[],B=0;do t.push(void 0),B++,n(f.value).G(l(t.length-1),k),f=e.next();while(!f.done)})};return k});
(function(f,k,e){var n;(n=e.define)&&n.amd?n([],function(){return k}):(n=e.modules)?n[f.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[f]=k})("FlexSearch",function ha(f){function e(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:ia++;this.init(a,b);K(this,"index",function(){return this.c});K(this,"length",function(){return Object.keys(this.c).length})}function n(a,b,c,g){this.D!==this.i&&(this.v=this.v.concat(c),this.D++,g&&this.v.length>=g&&(this.D=this.i),this.I&&this.D===this.i&&(this.cache&&
this.A.set(b,this.v),this.I(this.v),this.v=[]));return this}function l(a,b){a=a.concat.apply([],a);b&&(L(b)||(F=b.split(":"),1<F.length?b=ea:(F=F[0],b=da)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function t(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function B(a,b,c,g,m,d,e,h){if(b[c])return b[c];m=m?(h-(e||h/1.5))*d+(e||h/1.5)*m:d;b[c]=m;m>=e&&(a=a[h-(m+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=g);return m}
function H(a,b){if(a)for(var c=Object.keys(a),g=0,m=c.length;g<m;g++){var d=c[g],e=a[d];if(e)for(var h=0,f=e.length;h<f;h++)if(e[h]===b){1===f?delete a[d]:e.splice(h,1);break}else J(e[h])&&H(e[h],b)}}function P(a){for(var b="",c="",g="",d=0;d<a.length;d++){var e=a[d];if(e!==c)if(d&&"h"===e){if(g="a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&g||" "===c)b+=e}else b+=e;g=d===a.length-1?"":a[d+1];c=e}return b}function fa(a,b){a=a.length-b.length;
return 0>a?1:a?-1:0}function ca(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function da(a,b){a=a[F];b=b[F];return a<b?-1:a>b?1:0}function ea(a,b){for(var c=F.length,g=0;g<c;g++)a=a[F[g]],b=b[F[g]];return a<b?-1:a>b?1:0}function Q(a,b,c,g,d){c=[];var e=a.length;if(1<e){a.sort(ca);for(var m=C(),h=a[0],f=h.length,p=0;p<f;)m["@"+h[p++]]=1;for(var q,z=0,r=0;++r<e;){var n=!1,l=r===e-1;var u=[];h=a[r];f=h.length;for(p=0;p<f;){q=h[p++];var v="@"+q;if(m[v]){var w=m[v];if(w===r){if(l){if(c[z++]=g?g[q]:q,b&&
z===b)return c}else m[v]=r+1;n=!0}else d&&(v=u[w]||(u[w]=[]),v[v.length]=q)}}if(!n&&!d)break}if(d&&(z=c.length,(r=u.length)&&(!b||z<b)))for(;r--;)if(q=u[r])for(p=0,f=q.length;p<f;p++)if(c[z++]=g?g[q[p]]:q[p],b&&z===b)return c}else if(e)if(g)for(a=a[0],d=a.length,b&&b<d&&(d=b),c=Array(d),b=0;b<d;b++)c[b]=g[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function M(a){return"string"===typeof a}function I(a){return a.constructor===Array}function L(a){return"function"===typeof a}function J(a){return"object"===
typeof a}function E(a){return"undefined"===typeof a}function U(a){for(var b=Array(a),c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ja(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),
c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ka(a,b,c,d){a=f("flexsearch","id"+a,ja,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);var g=ha.toString();c.id=b;a.postMessage({register:g,options:c,id:b});return a}var y={encode:"icase",h:"forward",F:!1,cache:!1,async:!1,i:!1,H:!1,b:!1,L:!1,f:9,
threshold:0,depth:0},V={memory:{encode:"extra",h:"strict",threshold:0,f:1},speed:{encode:"icase",h:"strict",threshold:1,f:3,depth:2},match:{encode:"extra",h:"full",threshold:1,f:3},score:{encode:"extra",h:"strict",threshold:1,f:9,depth:4},balance:{encode:"balance",h:"strict",threshold:0,f:3,depth:3},fast:{encode:"icase",h:"strict",threshold:8,f:9,depth:1}},O=[],ia=0,W=d("\\W+"),X={},Y={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&O.push(d(b),
a[b]);return this};e.registerEncoder=function(a,b){N[a]=b.bind(N);return this};e.registerLanguage=function(a,b){X[a]=b.filter;Y[a]=b.stemmer;return this};e.encode=function(a,b){return N[a](b)};e.prototype.init=function(a,b){this.g=[];if(b){var c=b.preset;a=b}else a||(a=y),c=a.preset;b={};M(a)?((b=V[a])||console.warn("Preset not found: "+a),a={}):c&&((b=V[c])||console.warn("Preset not found: "+c));if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.a=null;else{var g=parseInt(c,10)||4;this.w=
-1;this.D=0;this.v=[];this.I=null;this.a=Array(g);for(var m=0;m<g;m++)this.a[m]=ka(this.id,m,a,n.bind(this))}this.h=a.tokenize||b.h||this.h||y.h;this.H=a.rtl||this.H||y.H;this.async="undefined"===typeof Promise||E(c=a.async)?this.async||y.async:c;this.i=E(c=a.worker)?this.i||y.i:c;this.threshold=E(c=a.threshold)?b.threshold||this.threshold||y.threshold:c;this.f=E(c=a.resolution)?c=b.f||this.f||y.f:c;c<=this.threshold&&(this.f=this.threshold+1);this.depth=E(c=a.depth)?b.depth||this.depth||y.depth:
c;this.L=E(c=a.paging)?this.L||y.L:c;this.F=E(c=a.suggest)?this.F||y.F:c;this.l=(c=E(c=a.encode)?b.encode||y.encode:c)&&N[c]&&N[c].bind(N)||(L(c)?c:this.l||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=X[c]||c;b=this.l;g=C();if(c)for(m=0;m<c.length;m++){var G=b?b(c[m]):c[m];g[G]=String.fromCharCode(65E3-c.length+m)}this.filter=g}if(c=a.stemmer){b=Y[c]||c;g=this.l;m=[];if(b)for(var f in b)b.hasOwnProperty(f)&&(G=g?g(f):f,m.push(d("(?=.{"+(G.length+3)+",})"+G+"$"),g?g(b[f]):b[f]));this.stemmer=
m}this.b=g=(c=a.doc)?c:this.b||y.b;this.o=U(this.f-(this.threshold||0));this.u=C();this.c=C();if(g){this.j=C();a.doc=null;f=g.index=[];b=g.ref={};m=g.field;G=g.tag;I(g.id)||(g.id=g.id.split(":"));if(G){this.B=C();var h=C();if(m)if(M(m))h[m]=a;else if(I(m))for(var R=0;R<m.length;R++)h[m[R]]=a;else J(m)&&(h=m);I(G)||(g.tag=G=[G]);for(m=0;m<G.length;m++)this.B[G[m]]=C();this.J=G;m=h}if(m){if(!I(m))if(J(m)){var p=m;g.field=m=Object.keys(m)}else g.field=m=[m];for(g=0;g<m.length;g++)I(m[g])||(p&&(a=p[m[g]]),
b[m[g]]=g,m[g]=m[g].split(":")),f[g]=new e(a),f[g].j=this.j}}this.s=!0;this.A=(this.cache=c=E(c=a.cache)?this.cache||y.cache:c)?new la(c):!1;return this};e.prototype.encode=function(a){a&&O.length&&(a=t(a,O));a&&this.g.length&&(a=t(a,this.g));a&&this.l&&(a=this.l(a));a&&this.stemmer&&(a=t(a,this.stemmer));return a};e.prototype.addMatcher=function(a){var b=this.g,c;for(c in a)a.hasOwnProperty(c)&&b.push(d(c),a[c]);return this};e.prototype.add=function(a,b,c,d,e){if(this.b&&J(a))return this.m("add",
a,b);if(b&&M(b)&&(a||0===a)){var g="@"+a;if(this.c[g]&&!d)return this.update(a,b);if(this.i)return++this.w>=this.a.length&&(this.w=0),this.a[this.w].postMessage({add:!0,id:a,content:b}),this.c[g]=""+this.w,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var m=this;g=new Promise(function(c){setTimeout(function(){m.add(a,b,null,d,!0);m=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.h;
e=L(c)?c(b):b.split(W);var h=C();h._ctx=C();for(var f=this.threshold,p=this.depth,q=this.f,z=this.o,r=e.length,n=this.H,l=0;l<r;l++){var u=e[l];if(u){var v=u.length,w=(n?l+1:r-l)/r,A="";switch(c){case "reverse":case "both":for(var x=v;--x;)A=u[x]+A,B(z,h,A,a,n?1:(v-x)/v,w,f,q-1);A="";case "forward":for(x=0;x<v;x++)A+=u[x],B(z,h,A,a,n?(x+1)/v:1,w,f,q-1);break;case "full":for(x=0;x<v;x++)for(var t=(n?x+1:v-x)/v,y=v;y>x;y--)A=u.substring(x,y),B(z,h,A,a,t,w,f,q-1);break;default:if(v=B(z,h,u,a,1,w,f,q-
1),p&&1<r&&v>=f)for(v=h._ctx[u]||(h._ctx[u]=C()),u=this.u[u]||(this.u[u]=U(q-(f||0))),w=l-p,A=l+p+1,0>w&&(w=0),A>r&&(A=r);w<A;w++)w!==l&&B(u,v,e[w],a,0,q-(w<l?l-w:w-l),f,q-1)}}}this.c[g]=1;this.s=!1}return this};e.prototype.m=function(a,b,c){if(I(b))for(var d=0,e=b.length;d<e;d++){if(d===e-1)return this.m(a,b[d],c);this.m(a,b[d])}else{d=this.b.index;for(var f=this.b.tag,D=this.b.id,h,l,p,q=0;q<D.length;q++)e=(e||b)[D[q]];if(f){for(D=0;D<f.length;D++){l=f[D];h=l.split(":");for(q=0;q<h.length;q++)p=
(p||b)[h[q]];p="@"+p}h=this.B[l];h=h[p]||(h[p]=[])}if("remove"===a)for(delete this.j[e],D=0,f=d.length;D<f;D++){if(D===f-1)return d[D].remove(e,c);d[D].remove(e)}D=this.b.field;h&&(h[h.length]=b);f=0;for(l=D.length;f<l;f++){h=D[f];p=void 0;for(q=0;q<h.length;q++)p=(p||b)[h[q]];this.j[e]=b;h=d[f];q="add"===a?h.add:h.update;if(f===l-1)return q.call(h,e,p,c);q.call(h,e,p)}}};e.prototype.update=function(a,b,c){if(this.b&&J(a))return this.m("update",a,b);this.c["@"+a]&&M(b)&&(this.remove(a),this.add(a,
b,c,!0));return this};e.prototype.remove=function(a,b,c){if(this.b&&J(a))return this.m("remove",a,b);var d="@"+a;if(this.c[d]){if(this.i)return this.a[this.c[d]].postMessage({remove:!0,id:a}),delete this.c[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;d=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.f-(this.threshold||0);b++)H(this.o[b],
a);this.depth&&H(this.u,a);delete this.c[d];this.s=!1}return this};var F;e.prototype.search=function(a,b,c,d){if(J(b)){if(I(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var g=a,f=[];if(J(a)&&!I(a)){(c=a.callback||b)&&(g.callback=null);var h=a.where;var n=a.sort;b=a.limit;var p=a.threshold;a=a.query}if(this.b){a=this.b.ref;p=this.b.index;if(h=g.field)g.field=null;else if(I(g)){var q=g;h=[];for(var z=0;z<g.length;z++)h[z]=g[z].field}else h=Object.keys(a);if(J(h)){n&&(g.sort=null);
I(h)||(h=[h]);z=h.length;for(var r=0;r<z;r++)q&&(g=q[r]),f[r]=p[a[h[r]]].search(g);return c?c(l(f,n)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(l(b,n))})}):l(f,n)}return p[a[h]].search(g,c)}p||(p=this.threshold||0);L(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.i)for(this.I=c,this.D=0,this.v=[],h=0;h<this.i;h++)this.a[h].postMessage({search:!0,limit:b,threshold:p,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var t=this;a=new Promise(function(a){setTimeout(function(){a(t.search(g,
b,null,!0));t=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!M(a))return f;g=a;if(this.cache)if(this.s){if(c=this.A.get(a))return c}else this.A.clear(),this.s=!0;g=this.encode(g);if(!g.length)return f;c=this.h;c=L(c)?c(g):g.split(W);q=c.length;d=!0;e=[];var y=C();if(1<q)if(this.depth){z=!0;var u=c[0];y[u]=1}else c.sort(fa);if(!z||(r=this.u)[u])for(var v=this.f,w=z?1:0;w<q;w++){var A=c[w];if(A){if(!y[A]){var x=[],B=!1,E=0;if(u=z?r[u]:this.o)for(var F=
void 0,H=0;H<v-p;H++)if(F=u[H][A])x[E++]=F,B=!0;if(B)e[e.length]=1<E?x.concat.apply([],x):x[0];else if(!this.F){d=!1;break}y[A]=1}u=A}}else d=!1;d&&(f=Q(e,b,void 0,this.j,this.F));h&&(f=this.where(h,null,b,f));n&&(f=l([f],n));this.cache&&this.A.set(a,f);return f}};e.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};e.prototype.where=function(a,b,c,d){var e=d||this.j,g=[],f=0,h;if("number"===typeof a)return[e[a]];if(M(a)){if(E(b))return[e[a]];if("id"===a)return[e[b]];var l=1;var p=[a.split(":")];
var q=!0}else{if(L(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)l=d?d[h]:e[b[h]],a(l)&&(g[f++]=l);return g}c||(c=b);h=Object.keys(a);l=h.length;q=!1;if(1===l&&"id"===h[0])return[e[a.id]];if((p=this.J)&&!d)for(var n=0;n<p.length;n++){var r=p[n],t=a[r];if(!E(t)){d=this.B[r]["@"+t];if(0===--l)return d;h.splice(h.indexOf(r),1);delete a[r];break}}p=Array(l);for(n=0;n<l;n++)p[n]=h[n].split(":")}n=d||Object.keys(e);r=n.length;for(t=0;t<r;t++){for(var y=d?d[t]:e[n[t]],u=!0,v=0;v<l;v++){q||(b=a[h[v]]);
var w=p[v],A=w.length,x=y;if(1<A)for(var B=0;B<A;B++)x=x[w[B]];else x=x[w[0]];if(x!==b){u=!1;break}}if(u&&(g[f++]=y,c&&f===c))break}return g};e.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.a[a].postMessage({info:!0,id:this.id});else{for(var b,c=0,d=0,e=0,f=0;f<this.f-(this.threshold||0);f++){a=Object.keys(this.o[f]);for(var l=0;l<a.length;l++)b=this.o[f][a[l]].length,c+=1*b+2*a[l].length+4,d+=b,e+=2*a[l].length}a=Object.keys(this.c);b=a.length;for(f=0;f<b;f++)c+=2*a[f].length+
2;return{id:this.id,memory:c,items:b,sequences:d,chars:e,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:O.length+(this.g?this.g.length:0),worker:this.i,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.h}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.A.clear(),this.A=null);this.o=this.u=this.c=null;if(this.b){for(var a=this.j.index,b=0;b<a.length;b++)a.destroy();this.j=null}return this};e.prototype.export=
function(){if(this.b){for(var a=this.b.index,b=Array(a.length+1),c=0;c<a.length;c++)b[c]=[a[c].o,a[c].u,a[c].c];b[c]=this.j;return JSON.stringify(b)}return JSON.stringify([this.o,this.u,this.c])};e.prototype.import=function(a){a=JSON.parse(a);if(this.b){for(var b=this.b.index,c=b.length,d=0;d<c;d++){var e=b[d];e.o=a[d][0];e.u=a[d][1];e.c=a[d][2];e.j=a[c]}this.j=a[c]}else this.o=a[0],this.u=a[1],this.c=a[2],this.j=a[3]};var N={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),
"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=t(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),
"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=t(b,a));c||1<b.length&&(b=P(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+t(d.substring(1),a))}b=b.join(" ");
b=P(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return P(t(b.toLowerCase(),a))}}()},la=function(){function a(a){this.clear();this.K=!0!==a&&a}a.prototype.clear=function(){this.cache=C();this.count=C();this.index=C();this.C=[]};a.prototype.set=function(a,c){if(this.K&&E(this.cache[a])){var b=this.C.length;if(b===this.K){b--;var d=this.C[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.C[b]=a;this.count[a]=
-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.K&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var l=this.C,h=f;this.count[l[--f]]<=d&&-1!==f;);f++;if(f!==h){for(d=h;d>f;d--)h=l[d-1],l[d]=h,e[h]=d;l[f]=a;e[a]=f}}}return b};return a}();return e}(function(){var f={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,n,l,K,d){l=k?URL.createObjectURL(new Blob(["("+l.toString()+")()"],{type:"text/javascript"})):
e+".es5.js";e+="-"+n;f[e]||(f[e]=[]);f[e][d]=new Worker(l);f[e][d].onmessage=K;console.log("Register Worker: "+e+"@"+d);return f[e][d]}}()),this);

View File

@@ -1,18 +1,18 @@
/*
FlexSearch v0.5.0
FlexSearch v0.5.1
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(e,l,u){let n;(n=u.define)&&n.amd?n([],function(){return l}):(n=u.modules)?n[e.toLowerCase()]=l:"object"===typeof exports?module.exports=l:u[e]=l})("FlexSearch",function(){function e(a,c){const b=c?c.id:a&&a.id;this.id=b||0===b?b:G++;this.init(a,c);l(this,"index",function(){return this.a});l(this,"length",function(){return Object.keys(this.a).length})}function l(a,c,b){Object.defineProperty(a,c,{get:b})}function u(a,c){for(let b=0;b<c.length;b+=2)a=a.replace(c[b],c[b+1]);return a}
function n(a,c,b,f,d,p,g){if(c[b])return c[b];d=d?(9-(g||6))*p+(g||6)*d:p;c[b]=d;d>=g&&(a=a[9-(d+.5>>0)],a=a[b]||(a[b]=[]),a[a.length]=f);return d}function y(a,c){if(a){const b=Object.keys(a);for(let f=0,d=b.length;f<d;f++){const d=b[f],g=a[d];if(g)for(let b=0,f=g.length;b<f;b++)if(g[b]===c){1===f?delete a[d]:g.splice(b,1);break}else"object"===typeof g[b]&&y(g[b],c)}}}function H(a,c){a=a.length-c.length;return 0>a?1:a?-1:0}function I(a,c){a=a.length-c.length;return 0>a?-1:a?1:0}function x(a){return"function"===
typeof a}function z(a){return"undefined"===typeof a}function C(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=t();return c}function t(){return Object.create(null)}const v={encode:"icase",b:"forward",l:!1,cache:!1,async:!1,m:!1,h:!1,threshold:0,depth:0,j:!1},A=[];let G=0;const D=/\W+/g,E={},F={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(const c in a)a.hasOwnProperty(c)&&A.push(new RegExp(c,"g"),a[c]);return this};e.registerEncoder=function(a,c){w[a]=c.bind(w);return this};
e.registerLanguage=function(a,c){E[a]=c.filter;F[a]=c.stemmer;return this};e.encode=function(a,c){return w[a](c)};e.prototype.init=function(a,c){this.i=[];if(c){var b=c.preset;a=c}else a||(a=v),b=a.preset;c={};this.b=a.tokenize||c.b||this.b||v.b;this.h=a.rtl||this.h||v.h;this.threshold=z(b=a.threshold)?c.threshold||this.threshold||v.threshold:b;this.depth=z(b=a.depth)?c.depth||this.depth||v.depth:b;this.f=(b=z(b=a.encode)?c.encode||v.encode:b)&&w[b]&&w[b].bind(w)||(x(b)?b:this.f||!1);(b=a.matcher)&&
this.addMatcher(b);if(b=a.filter){b=E[b]||b;c=this.f;var f=t();if(b)for(let a=0;a<b.length;a++){const d=c?c(b[a]):b[a];f[d]=String.fromCharCode(65E3-b.length+a)}this.filter=b=f}if(b=a.stemmer){var d;a=F[b]||b;b=this.f;c=[];if(a)for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp("(?=.{"+(f.length+3)+",})"+f+"$","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.g=C(10-(this.threshold||0));this.c=t();this.a=t();return this};e.prototype.encode=function(a){a&&A.length&&(a=u(a,A));a&&this.i.length&&
(a=u(a,this.i));a&&this.f&&(a=this.f(a));a&&this.stemmer&&(a=u(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const c=this.i;for(const b in a)a.hasOwnProperty(b)&&c.push(new RegExp(b,"g"),a[b]);return this};e.prototype.add=function(a,c,b,f,d){if(c&&"string"===typeof c&&(a||0===a)){const e="@"+a;if(this.a[e]&&!f)return this.update(a,c);if(!d&&b)return this.add(a,c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.b;c=x(b)?b(c):c.split(D);f=t();f._ctx=t();d=this.threshold;
const B=this.depth,r=this.g,q=c.length,l=this.h;for(let e=0;e<q;e++){var p=c[e];if(p){var g=p.length,k=(l?e+1:q-e)/q,m="";switch(b){case "reverse":case "both":for(var h=g;--h;)m=p[h]+m,n(r,f,m,a,l?1:(g-h)/g,k,d);m="";case "forward":for(h=0;h<g;h++)m+=p[h],n(r,f,m,a,l?(h+1)/g:1,k,d);break;case "full":for(h=0;h<g;h++){const c=(l?h+1:g-h)/g;for(let b=g;b>h;b--)m=p.substring(h,b),n(r,f,m,a,c,k,d)}break;default:if(g=n(r,f,p,a,1,k,d),B&&1<q&&g>=d)for(g=f._ctx[p]||(f._ctx[p]=t()),p=this.c[p]||(this.c[p]=
C(10-(d||0))),k=e-B,m=e+B+1,0>k&&(k=0),m>q&&(m=q);k<m;k++)k!==e&&n(p,g,c[k],a,0,10-(k<e?e-k:k-e),d)}}}this.a[e]=1}return this};e.prototype.update=function(a,c,b){this.a["@"+a]&&"string"===typeof c&&(this.remove(a),this.add(a,c,b,!0));return this};e.prototype.remove=function(a,c,b){const f="@"+a;if(this.a[f]){if(!b&&c)return this.remove(a,null,!0),c(),this;for(c=0;c<10-(this.threshold||0);c++)y(this.g[c],a);this.depth&&y(this.c,a);delete this.a[f]}return this};e.prototype.search=function(a,c,b,f){var d=
a,e=[];if("object"===typeof a){c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);x(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(d,c,null,!0)),this;if(!a||"string"!==typeof a)return e;d=this.encode(a);if(!d.length)return e;a=this.b;a=x(a)?a(d):d.split(D);b=a.length;f=!0;d=[];var k=t();if(1<b)if(this.depth){var m=!0;var h=a[0];k[h]=1}else a.sort(H);var l;if(!m||(l=this.c)[h])for(var n=m?1:0;n<b;n++){var r=a[n];if(r){if(!k[r]){var q=[];let a=!1,b=0;if(h=m?l[h]:this.g){let c;
for(let d=0;d<10-g;d++)if(c=h[d][r])q[b++]=c,a=!0}if(a)d[d.length]=1<b?q.concat.apply([],q):q[0];else{f=!1;break}k[r]=1}h=r}}else f=!1;if(f)a:{g=[];e=d.length;if(1<e){d.sort(I);m=t();l=d[0];h=l.length;for(a=0;a<h;)m["@"+l[a++]]=1;for(k=f=0;++k<e;){n=!1;r=k===e-1;l=d[k];h=l.length;for(a=0;a<h;)if(b=l[a++],q="@"+b,m[q]&&m[q]===k){if(r){if(g[f++]=b,c&&f===c){e=g;break a}}else m[q]=k+1;n=!0}if(!n)break}}else e&&(g=d[0],c&&g.length>c&&(g=g.slice(0,c)));e=g}return e};e.prototype.clear=function(){return this.destroy().init()};
e.prototype.destroy=function(){this.g=this.c=this.a=null;return this};const w={icase:function(a){return a.toLowerCase()}};return e}(!1),this);
'use strict';(function(d,l,v){let t;(t=v.define)&&t.amd?t([],function(){return l}):(t=v.modules)?t[d.toLowerCase()]=l:"object"===typeof exports?module.exports=l:v[d]=l})("FlexSearch",function(){function d(a,c){const b=c?c.id:a&&a.id;this.id=b||0===b?b:G++;this.init(a,c);l(this,"index",function(){return this.b});l(this,"length",function(){return Object.keys(this.b).length})}function l(a,c,b){Object.defineProperty(a,c,{get:b})}function v(a,c){for(let b=0;b<c.length;b+=2)a=a.replace(c[b],c[b+1]);return a}
function t(a,c,b,f,e,p,g,h){if(c[b])return c[b];e=e?(h-(g||h/1.5))*p+(g||h/1.5)*e:p;c[b]=e;e>=g&&(a=a[h-(e+.5>>0)],a=a[b]||(a[b]=[]),a[a.length]=f);return e}function A(a,c){if(a){const b=Object.keys(a);for(let f=0,e=b.length;f<e;f++){const e=b[f],g=a[e];if(g)for(let b=0,f=g.length;b<f;b++)if(g[b]===c){1===f?delete a[e]:g.splice(b,1);break}else"object"===typeof g[b]&&A(g[b],c)}}}function H(a,c){a=a.length-c.length;return 0>a?1:a?-1:0}function I(a,c){a=a.length-c.length;return 0>a?-1:a?1:0}function z(a){return"function"===
typeof a}function y(a){return"undefined"===typeof a}function C(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=u();return c}function u(){return Object.create(null)}const n={encode:"icase",c:"forward",o:!1,cache:!1,async:!1,s:!1,i:!1,m:!1,l:!1,a:9,threshold:0,depth:0},B=[];let G=0;const D=/\W+/g,E={},F={};d.create=function(a){return new d(a)};d.registerMatcher=function(a){for(const c in a)a.hasOwnProperty(c)&&B.push(new RegExp(c,"g"),a[c]);return this};d.registerEncoder=function(a,c){w[a]=c.bind(w);return this};
d.registerLanguage=function(a,c){E[a]=c.filter;F[a]=c.stemmer;return this};d.encode=function(a,c){return w[a](c)};d.prototype.init=function(a,c){this.j=[];if(c){var b=c.preset;a=c}else a||(a=n),b=a.preset;c={};this.c=a.tokenize||c.c||this.c||n.c;this.i=a.rtl||this.i||n.i;this.threshold=y(b=a.threshold)?c.threshold||this.threshold||n.threshold:b;this.a=y(b=a.resolution)?b=c.a||this.a||n.a:b;b<=this.threshold&&(this.a=this.threshold+1);this.depth=y(b=a.depth)?c.depth||this.depth||n.depth:b;this.l=y(b=
a.paging)?this.l||n.l:b;this.g=(b=y(b=a.encode)?c.encode||n.encode:b)&&w[b]&&w[b].bind(w)||(z(b)?b:this.g||!1);(b=a.matcher)&&this.addMatcher(b);if(b=a.filter){b=E[b]||b;c=this.g;var f=u();if(b)for(let a=0;a<b.length;a++){const e=c?c(b[a]):b[a];f[e]=String.fromCharCode(65E3-b.length+a)}this.filter=b=f}if(b=a.stemmer){var e;a=F[b]||b;b=this.g;c=[];if(a)for(e in a)a.hasOwnProperty(e)&&(f=b?b(e):e,c.push(new RegExp("(?=.{"+(f.length+3)+",})"+f+"$","g"),b?b(a[e]):a[e]));this.stemmer=e=c}this.h=C(this.a-
(this.threshold||0));this.f=u();this.b=u();return this};d.prototype.encode=function(a){a&&B.length&&(a=v(a,B));a&&this.j.length&&(a=v(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=v(a,this.stemmer));return a};d.prototype.addMatcher=function(a){const c=this.j;for(const b in a)a.hasOwnProperty(b)&&c.push(new RegExp(b,"g"),a[b]);return this};d.prototype.add=function(a,c,b,f,e){if(c&&"string"===typeof c&&(a||0===a)){const d="@"+a;if(this.b[d]&&!f)return this.update(a,c);if(!e&&b)return this.add(a,
c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.c;c=z(b)?b(c):c.split(D);f=u();f._ctx=u();e=this.threshold;const n=this.depth,r=this.a,q=this.h,x=c.length,l=this.i;for(let d=0;d<x;d++){var p=c[d];if(p){var g=p.length,h=(l?d+1:x-d)/x,m="";switch(b){case "reverse":case "both":for(var k=g;--k;)m=p[k]+m,t(q,f,m,a,l?1:(g-k)/g,h,e,r-1);m="";case "forward":for(k=0;k<g;k++)m+=p[k],t(q,f,m,a,l?(k+1)/g:1,h,e,r-1);break;case "full":for(k=0;k<g;k++){const b=(l?k+1:g-k)/g;for(let c=g;c>
k;c--)m=p.substring(k,c),t(q,f,m,a,b,h,e,r-1)}break;default:if(g=t(q,f,p,a,1,h,e,r-1),n&&1<x&&g>=e)for(g=f._ctx[p]||(f._ctx[p]=u()),p=this.f[p]||(this.f[p]=C(r-(e||0))),h=d-n,m=d+n+1,0>h&&(h=0),m>x&&(m=x);h<m;h++)h!==d&&t(p,g,c[h],a,0,r-(h<d?d-h:h-d),e,r-1)}}}this.b[d]=1}return this};d.prototype.update=function(a,c,b){this.b["@"+a]&&"string"===typeof c&&(this.remove(a),this.add(a,c,b,!0));return this};d.prototype.remove=function(a,c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,
!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)A(this.h[c],a);this.depth&&A(this.f,a);delete this.b[f]}return this};d.prototype.search=function(a,c,b,f){var e=a,d=[];if("object"===typeof a){c=a.limit;var g=a.threshold;a=a.query}g||(g=this.threshold||0);z(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(e,c,null,!0)),this;if(!a||"string"!==typeof a)return d;e=this.encode(a);if(!e.length)return d;a=this.c;a=z(a)?a(e):e.split(D);b=a.length;f=!0;e=[];var h=u();if(1<b)if(this.depth){var m=
!0;var k=a[0];h[k]=1}else a.sort(H);var l;if(!m||(l=this.f)[k]){var n=this.a;for(var r=m?1:0;r<b;r++){var q=a[r];if(q){if(!h[q]){const a=[];let b=!1,c=0;if(k=m?l[k]:this.h){let e;for(let d=0;d<n-g;d++)if(e=k[d][q])a[c++]=e,b=!0}if(b)e[e.length]=1<c?a.concat.apply([],a):a[0];else{f=!1;break}h[q]=1}k=q}}}else f=!1;if(f)a:{g=[];d=e.length;if(1<d){e.sort(I);m=u();l=e[0];k=l.length;for(a=0;a<k;)m["@"+l[a++]]=1;for(h=f=0;++h<d;){n=!1;r=h===d-1;l=e[h];k=l.length;for(a=0;a<k;)if(b=l[a++],q="@"+b,m[q]&&m[q]===
h){if(r){if(g[f++]=b,c&&f===c){d=g;break a}}else m[q]=h+1;n=!0}if(!n)break}}else d&&(g=e[0],c&&g.length>c&&(g=g.slice(0,c)));d=g}return d};d.prototype.clear=function(){return this.destroy().init()};d.prototype.destroy=function(){this.h=this.f=this.b=null;return this};const w={icase:function(a){return a.toLowerCase()}};return d}(!1),this);

View File

@@ -1,37 +1,38 @@
/*
FlexSearch v0.5.0
FlexSearch v0.5.1
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(x,F,f){let y;(y=f.define)&&y.amd?y([],function(){return F}):(y=f.modules)?y[x.toLowerCase()]=F:"object"===typeof exports?module.exports=F:f[x]=F})("FlexSearch",function U(x){function f(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:V++;this.init(a,b);K(this,"index",function(){return this.b});K(this,"length",function(){return Object.keys(this.b).length})}function y(a,b,c,d){this.s!==this.f&&(this.j=this.j.concat(c),this.s++,d&&this.j.length>=d&&(this.s=this.f),this.F&&this.s===
this.f&&(this.cache&&this.m.set(b,this.j),this.F(this.j),this.j=[]));return this}function A(a,b){a=a.concat.apply([],a);b&&(G(b)||(z=b.split(":"),1<z.length?b=W:(z=z[0],b=X)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function h(a){return new RegExp(a,"g")}function C(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function I(a,b,c,d,e,g,k){if(b[c])return b[c];e=e?(9-(k||6))*g+(k||6)*e:g;b[c]=e;e>=k&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);
return e}function N(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else D(k[c])&&N(k[c],b)}}}function O(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}
function Y(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function Z(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function X(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function W(a,b){const c=z.length;for(let d=0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function aa(a,b,c,d){let e=[],g;const k=a.length;if(1<k){a.sort(Z);const h=q();let l=a[0],m=l.length,f=0;for(;f<m;)h["@"+l[f++]]=1;let n,u=0,t=0;for(;++t<k;){let r=!1;const E=t===k-1;g=[];l=a[t];m=l.length;for(f=0;f<m;){n=l[f++];var p="@"+n;if(h[p]){const a=
h[p];if(a===t){if(E){if(e[u++]=c?c[p]:n,b&&u===b)return e}else h[p]=t+1;r=!0}else d&&(p=g[a]||(g[a]=[]),p[p.length]=n)}}if(!r&&!d)break}if(d&&(u=e.length,(t=g.length)&&(!b||u<b)))for(;t--;)if(n=g[t])for(f=0,m=n.length;f<m;f++)if(e[u++]=c?c["@"+n[f]]:n[f],b&&u===b)return e}else if(k)if(c)for(a=a[0],d=a.length,b&&b<d&&(d=b),e=Array(d),b=0;b<d;b++)e[b]=c["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function J(a){return"string"===typeof a}function G(a){return"function"===typeof a}function D(a){return"object"===
typeof a}function B(a){return"undefined"===typeof a}function P(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=q();return b}function q(){return Object.create(null)}function ba(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?
(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ca(a,b,c,d){a=x("flexsearch","id"+a,ba,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const e=U.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}const w={encode:"icase",c:"forward",A:!1,cache:!1,async:!1,f:!1,D:!1,
threshold:0,depth:0,a:!1},Q={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",c:"strict",threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},M=[];let V=0;const R=h("\\W+"),S={},T={};f.create=function(a){return new f(a)};f.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&M.push(h(b),a[b]);return this};
f.registerEncoder=function(a,b){H[a]=b.bind(H);return this};f.registerLanguage=function(a,b){S[a]=b.filter;T[a]=b.stemmer;return this};f.encode=function(a,b){return H[a](b)};f.prototype.init=function(a,b){this.u=[];if(b){var c=b.preset;a=b}else a||(a=w),c=a.preset;b={};J(a)?(b=Q[a],a={}):c&&(b=Q[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.l=null;else{var d=parseInt(c,10)||4;this.C=-1;this.s=0;this.j=[];this.F=null;this.l=Array(d);for(var e=0;e<d;e++)this.l[e]=ca(this.id,e,a,
y.bind(this))}this.c=a.tokenize||b.c||this.c||w.c;this.D=a.rtl||this.D||w.D;this.async="undefined"===typeof Promise||B(c=a.async)?this.async||w.async:c;this.f=B(c=a.worker)?this.f||w.f:c;this.threshold=B(c=a.threshold)?b.threshold||this.threshold||w.threshold:c;this.depth=B(c=a.depth)?b.depth||this.depth||w.depth:c;this.A=B(c=a.suggest)?this.A||w.A:c;this.v=(c=B(c=a.encode)?b.encode||w.encode:c)&&H[c]&&H[c].bind(H)||(G(c)?c:this.v||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=S[c]||c;b=
this.v;d=q();if(c)for(e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var k;b=T[c]||c;d=this.v;e=[];if(b)for(k in b)b.hasOwnProperty(k)&&(g=d?d(k):k,e.push(h("(?=.{"+(g.length+3)+",})"+g+"$"),d?d(b[k]):b[k]));this.stemmer=k=e}this.a=g=(c=a.doc)?c:this.a||w.a;this.h=P(10-(this.threshold||0));this.i=q();this.b=q();if(g){this.g=q();a.doc=null;k=g.index=[];b=g.ref={};d=g.field;e=g.tag;g.id=g.id.split(":");if(e){this.G=q();e.constructor===
Array||(g.tag=e=[e]);for(let a=0;a<e.length;a++)this.G[e[a]]=q(),e[a]=e[a].split(":")}if(d)for(d.constructor===Array||(g.field=d=[d]),g=0;g<d.length;g++)b[d[g]]=g,d[g]=d[g].split(":"),k[g]=new f(a),k[g].g=this.g,e&&(k[g].G=this.G)}this.B=!0;this.m=(this.cache=c=B(c=a.cache)?this.cache||w.cache:c)?new da(c):!1;return this};f.prototype.encode=function(a){a&&M.length&&(a=C(a,M));a&&this.u.length&&(a=C(a,this.u));a&&this.v&&(a=this.v(a));a&&this.stemmer&&(a=C(a,this.stemmer));return a};f.prototype.addMatcher=
function(a){const b=this.u;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};f.prototype.add=function(a,b,c,d,e){if(this.a&&D(a))return this.w("add",a,b);if(b&&J(b)&&(a||0===a)){var g="@"+a;if(this.b[g]&&!d)return this.update(a,b);if(this.f)return++this.C>=this.l.length&&(this.C=0),this.l[this.C].postMessage({add:!0,id:a,content:b}),this.b[g]=""+this.C,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,
b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=G(c)?c(b):b.split(R);const m=q();m._ctx=q();const n=this.threshold,r=this.depth,t=this.h,v=e.length,L=this.D;for(let b=0;b<v;b++){var k=e[b];if(k){var p=k.length,h=(L?b+1:v-b)/v,l="";switch(c){case "reverse":case "both":for(var f=p;--f;)l=k[f]+l,I(t,m,l,a,L?1:(p-f)/p,h,n);l="";case "forward":for(f=0;f<p;f++)l+=k[f],I(t,m,l,a,L?(f+1)/
p:1,h,n);break;case "full":for(f=0;f<p;f++){const b=(L?f+1:p-f)/p;for(let c=p;c>f;c--)l=k.substring(f,c),I(t,m,l,a,b,h,n)}break;default:if(p=I(t,m,k,a,1,h,n),r&&1<v&&p>=n)for(p=m._ctx[k]||(m._ctx[k]=q()),k=this.i[k]||(this.i[k]=P(10-(n||0))),h=b-r,l=b+r+1,0>h&&(h=0),l>v&&(l=v);h<l;h++)h!==b&&I(k,p,e[h],a,0,10-(h<b?b-h:h-b),n)}}}this.b[g]=1;this.B=!1}return this};f.prototype.w=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.w(a,b[d],c);this.w(a,b[d])}else{const k=
this.a.index;var d=this.a.tag,e=this.a.id;let h;for(var g=0;g<e.length;g++)h=(h||b)[e[g]];if(d)for(e=0;e<d.length;e++);if("remove"===a){delete this.g["@"+h];for(let a=0,b=k.length;a<b;a++){if(a===b-1)return k[a].remove(h,c);k[a].remove(h)}}e=this.a.field;for(let f=0,p=e.length;f<p;f++){d=e[f];let l;for(g=0;g<d.length;g++)l=(l||b)[d[g]];this.g["@"+h]=b;d=k[f];g="add"===a?d.add:d.update;if(f===p-1)return g.call(d,h,l,c);g.call(d,h,l)}}};f.prototype.update=function(a,b,c){if(this.a&&D(a))return this.w("update",
a,b);this.b["@"+a]&&J(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&D(a))return this.w("remove",a,b);var d="@"+a;if(this.b[d]){if(this.f)return this.l[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),
b(),this}for(b=0;b<10-(this.threshold||0);b++)N(this.h[b],a);this.depth&&N(this.i,a);delete this.b[d];this.B=!1}return this};let z;f.prototype.search=function(a,b,c,d){if(D(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let g=a;let h,f=[];if(D(a)&&a.constructor!==Array){(c=a.callback||b)&&(g.callback=null);var r=a.boost;var l=a.where;h=a.sort;b=a.limit;var m=a.threshold;a=a.query}if(this.a){a=this.a.ref;m=this.a.index;if(l=g.field)g.field=null;else if(g.constructor===
Array){var E=g;l=[];for(var n=0;n<g.length;n++)l[n]=g[n].field}else l=Object.keys(a);if(D(l)){l.constructor===Array||(l=[l]);n=l.length;for(var u=0;u<n;u++)E&&(g=E[u]),f[u]=m[a[l[u]]].search(g);return c?c(A(f,h)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(A(b,h))})}):A(f,h)}return m[a[l]].search(g,c)}m||(m=this.threshold||0);G(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.f)for(this.F=c,this.s=0,this.j=[],l=0;l<this.f;l++)this.l[l].postMessage({search:!0,limit:b,threshold:m,content:a});
else{if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(g,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!J(a))return f;g=a;if(this.cache)if(this.B){if(c=this.m.get(a))return c}else this.m.clear(),this.B=!0;g=this.encode(g);if(!g.length)return f;c=this.c;c=G(c)?c(g):g.split(R);E=c.length;d=!0;e=[];var t=q();if(1<E)if(this.depth){n=!0;var v=c[0];t[v]=1}else c.sort(Y);
if(!n||(u=this.i)[v]){let a=0;r&&(m=(m||1)/r,0>r&&(a=m));for(r=n?1:0;r<E;r++){const b=c[r];if(b){if(!t[b]){const c=[];let g=!1,h=0;if(v=n?u[v]:this.h){let d;for(let e=a;e<10-m;e++)if(d=v[e][b])c[h++]=d,g=!0}if(g)e[e.length]=1<h?c.concat.apply([],c):c[0];else if(!this.A){d=!1;break}t[b]=1}v=b}}}else d=!1;d&&(f=aa(e,b,this.g,this.A));l&&(f=this.where(l,null,b,f));h&&(f=A([f],h));this.cache&&this.m.set(a,f);return f}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};f.prototype.where=
function(a,b,c,d){const e=d||this.g,g=[];let h=0;var f;let r,l;if(J(a)){if("id"===a)return[e["@"+b]];var m=1;l=[a.split(":")];r=!0}else{if(G(a)){b=d||Object.keys(e);c=b.length;for(f=0;f<c;f++)m=d?d[f]:e[b[f]],a(m)&&(g[h++]=m);return g}c||(c=b);f=Object.keys(a);m=f.length;r=!1;if(1===m&&"id"===f[0])return[e["@"+a.id]];l=Array(m);for(var q=0;q<m;q++)l[q]=f[q].split(":")}q=d||Object.keys(e);const n=q.length;for(let k=0;k<n;k++){const p=d?d[k]:e[q[k]];let n=!0;for(let c=0;c<m;c++){r||(b=a[f[c]]);const d=
l[c],e=d.length;let g=p;if(1<e)for(let a=0;a<e;a++)g=g[d[a]];else g=g[d[0]];if(g!==b){n=!1;break}}if(n&&(g[h++]=p,c&&h===c))break}return g};f.prototype.info=function(){if(this.f)for(var a=0;a<this.f;a++)this.l[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){a=Object.keys(this.h[e]);for(let f=0;f<a.length;f++){var g=this.h[e][a[f]].length;b+=1*g+2*a[f].length+4;c+=g;d+=2*a[f].length}}a=Object.keys(this.b);g=a.length;for(e=0;e<g;e++)b+=2*a[e].length+
2;return{id:this.id,memory:b,items:g,sequences:c,chars:d,cache:this.cache&&this.cache.o?this.cache.o.length:!1,matcher:M.length+(this.u?this.u.length:0),worker:this.f,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&(this.m.clear(),this.m=null);this.h=this.i=this.b=null;if(this.a){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};
f.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].h,a[c].i,a[c].b];b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.b])};f.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.h=a[d][0];e.i=a[d][1];e.b=a[d][2];e.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.b=a[2],this.g=a[3]};const H={icase:function(a){return a.toLowerCase()},
simple:function(){const a=[h("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",h("[\u00e8\u00e9\u00ea\u00eb]"),"e",h("[\u00ec\u00ed\u00ee\u00ef]"),"i",h("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",h("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",h("[\u00fd\u0177\u00ff]"),"y",h("\u00f1"),"n",h("\u00e7"),"c",h("\u00df"),"s",h(" & ")," and ",h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){b=C(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[h("ae"),"a",h("ai"),"ei",h("ay"),
"ei",h("ey"),"ei",h("oe"),"o",h("ue"),"u",h("ie"),"i",h("sz"),"s",h("zs"),"s",h("sh"),"s",h("ck"),"k",h("cc"),"k",h("dt"),"t",h("ph"),"f",h("pf"),"f",h("ou"),"o",h("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=C(b,a));c||1<b.length&&(b=O(b));return b}}(),extra:function(){const a=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=
0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+C(d.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){const a=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){return O(C(b.toLowerCase(),a))}}()},da=function(){function a(a){this.clear();this.H=!0!==a&&a}a.prototype.clear=function(){this.cache=q();this.count=q();this.index=q();this.o=[]};a.prototype.set=function(a,c){if(this.H&&B(this.cache[a])){let b=this.o.length;if(b===this.H){b--;const a=this.o[b];delete this.cache[a];
delete this.count[a];delete this.index[a]}this.index[a]=b;this.o[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.H&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.o;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return f}(function(){const x={},F="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;
return function(f,y,A,K,h){A=F?URL.createObjectURL(new Blob(["("+A.toString()+")()"],{type:"text/javascript"})):f+".min.js";f+="-"+y;x[f]||(x[f]=[]);x[f][h]=new Worker(A);x[f][h].onmessage=K;return x[f][h]}}()),this);
'use strict';(function(w,F,g){let y;(y=g.define)&&y.amd?y([],function(){return F}):(y=g.modules)?y[w.toLowerCase()]=F:"object"===typeof exports?module.exports=F:g[w]=F})("FlexSearch",function U(w){function g(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:V++;this.init(a,b);K(this,"index",function(){return this.b});K(this,"length",function(){return Object.keys(this.b).length})}function y(a,b,c,d){this.u!==this.g&&(this.l=this.l.concat(c),this.u++,d&&this.l.length>=d&&(this.u=this.g),this.G&&this.u===
this.g&&(this.cache&&this.o.set(b,this.l),this.G(this.l),this.l=[]));return this}function B(a,b){a=a.concat.apply([],a);b&&(G(b)||(z=b.split(":"),1<z.length?b=W:(z=z[0],b=X)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function E(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function J(a,b,c,d,e,l,k,h){if(b[c])return b[c];e=e?(h-(k||h/1.5))*l+(k||h/1.5)*e:l;b[c]=e;e>=k&&(a=a[h-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=
d);return e}function N(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else A(k[c])&&N(k[c],b)}}}function O(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const l=a[e];if(l!==c)if(e&&"h"===l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=e===a.length-1?"":a[e+1];c=l}return b}
function Y(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function Z(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function X(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function W(a,b){const c=z.length;for(let d=0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function aa(a,b,c,d,e){c=[];let l;const k=a.length;if(1<k){a.sort(Z);const C=r();let f=a[0],q=f.length,m=0;for(;m<q;)C["@"+f[m++]]=1;let p,g=0,t=0;for(;++t<k;){let n=!1;const D=t===k-1;l=[];f=a[t];q=f.length;for(m=0;m<q;){p=f[m++];var h="@"+p;
if(C[h]){const a=C[h];if(a===t){if(D){if(c[g++]=d?d[p]:p,b&&g===b)return c}else C[h]=t+1;n=!0}else e&&(h=l[a]||(l[a]=[]),h[h.length]=p)}}if(!n&&!e)break}if(e&&(g=c.length,(t=l.length)&&(!b||g<b)))for(;t--;)if(p=l[t])for(m=0,q=p.length;m<q;m++)if(c[g++]=d?d[p[m]]:p[m],b&&g===b)return c}else if(k)if(d)for(a=a[0],e=a.length,b&&b<e&&(e=b),c=Array(e),b=0;b<e;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function H(a){return"string"===typeof a}function x(a){return a.constructor===
Array}function G(a){return"function"===typeof a}function A(a){return"object"===typeof a}function v(a){return"undefined"===typeof a}function P(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=r();return b}function r(){return Object.create(null)}function ba(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?
b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ca(a,b,c,d){a=w("flexsearch","id"+a,ba,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const e=U.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}
const u={encode:"icase",f:"forward",B:!1,cache:!1,async:!1,g:!1,F:!1,a:!1,J:!1,c:9,threshold:0,depth:0},Q={memory:{encode:"extra",f:"strict",threshold:0,c:1},speed:{encode:"icase",f:"strict",threshold:1,c:3,depth:2},match:{encode:"extra",f:"full",threshold:1,c:3},score:{encode:"extra",f:"strict",threshold:1,c:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,c:3,depth:3},fast:{encode:"icase",f:"strict",threshold:8,c:9,depth:1}},M=[];let V=0;const R=f("\\W+"),S={},T={};g.create=function(a){return new g(a)};
g.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&M.push(f(b),a[b]);return this};g.registerEncoder=function(a,b){I[a]=b.bind(I);return this};g.registerLanguage=function(a,b){S[a]=b.filter;T[a]=b.stemmer;return this};g.encode=function(a,b){return I[a](b)};g.prototype.init=function(a,b){this.v=[];if(b){var c=b.preset;a=b}else a||(a=u),c=a.preset;b={};H(a)?(b=Q[a],a={}):c&&(b=Q[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.m=null;else{var d=parseInt(c,10)||4;this.D=
-1;this.u=0;this.l=[];this.G=null;this.m=Array(d);for(var e=0;e<d;e++)this.m[e]=ca(this.id,e,a,y.bind(this))}this.f=a.tokenize||b.f||this.f||u.f;this.F=a.rtl||this.F||u.F;this.async="undefined"===typeof Promise||v(c=a.async)?this.async||u.async:c;this.g=v(c=a.worker)?this.g||u.g:c;this.threshold=v(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.c=v(c=a.resolution)?c=b.c||this.c||u.c:c;c<=this.threshold&&(this.c=this.threshold+1);this.depth=v(c=a.depth)?b.depth||this.depth||u.depth:
c;this.J=v(c=a.paging)?this.J||u.J:c;this.B=v(c=a.suggest)?this.B||u.B:c;this.w=(c=v(c=a.encode)?b.encode||u.encode:c)&&I[c]&&I[c].bind(I)||(G(c)?c:this.w||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=S[c]||c;b=this.w;d=r();if(c)for(e=0;e<c.length;e++){var l=b?b(c[e]):c[e];d[l]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var k;b=T[c]||c;d=this.w;e=[];if(b)for(k in b)b.hasOwnProperty(k)&&(l=d?d(k):k,e.push(f("(?=.{"+(l.length+3)+",})"+l+"$"),d?d(b[k]):b[k]));this.stemmer=
k=e}this.a=d=(c=a.doc)?c:this.a||u.a;this.i=P(this.c-(this.threshold||0));this.j=r();this.b=r();if(d){this.h=r();a.doc=null;k=d.index=[];b=d.ref={};e=d.field;l=d.tag;x(d.id)||(d.id=d.id.split(":"));if(l){this.H=r();let b=r();if(e)if(H(e))b[e]=a;else if(x(e))for(let c=0;c<e.length;c++)b[e[c]]=a;else A(e)&&(b=e);x(l)||(d.tag=l=[l]);for(e=0;e<l.length;e++)this.H[l[e]]=r();this.K=l;e=b}if(e){let c;x(e)||(A(e)?(c=e,d.field=e=Object.keys(e)):d.field=e=[e]);for(d=0;d<e.length;d++)x(e[d])||(c&&(a=c[e[d]]),
b[e[d]]=d,e[d]=e[d].split(":")),k[d]=new g(a),k[d].h=this.h}}this.C=!0;this.o=(this.cache=c=v(c=a.cache)?this.cache||u.cache:c)?new da(c):!1;return this};g.prototype.encode=function(a){a&&M.length&&(a=E(a,M));a&&this.v.length&&(a=E(a,this.v));a&&this.w&&(a=this.w(a));a&&this.stemmer&&(a=E(a,this.stemmer));return a};g.prototype.addMatcher=function(a){const b=this.v;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};g.prototype.add=function(a,b,c,d,e){if(this.a&&A(a))return this.A("add",
a,b);if(b&&H(b)&&(a||0===a)){var l="@"+a;if(this.b[l]&&!d)return this.update(a,b);if(this.g)return++this.D>=this.m.length&&(this.D=0),this.m[this.D].postMessage({add:!0,id:a,content:b}),this.b[l]=""+this.D,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;l=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)l.then(c);else return l;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;
e=G(c)?c(b):b.split(R);const m=r();m._ctx=r();const p=this.threshold,C=this.depth,t=this.c,q=this.i,D=e.length,L=this.F;for(let b=0;b<D;b++){var k=e[b];if(k){var h=k.length,f=(L?b+1:D-b)/D,n="";switch(c){case "reverse":case "both":for(var g=h;--g;)n=k[g]+n,J(q,m,n,a,L?1:(h-g)/h,f,p,t-1);n="";case "forward":for(g=0;g<h;g++)n+=k[g],J(q,m,n,a,L?(g+1)/h:1,f,p,t-1);break;case "full":for(g=0;g<h;g++){const b=(L?g+1:h-g)/h;for(let c=h;c>g;c--)n=k.substring(g,c),J(q,m,n,a,b,f,p,t-1)}break;default:if(h=J(q,
m,k,a,1,f,p,t-1),C&&1<D&&h>=p)for(h=m._ctx[k]||(m._ctx[k]=r()),k=this.j[k]||(this.j[k]=P(t-(p||0))),f=b-C,n=b+C+1,0>f&&(f=0),n>D&&(n=D);f<n;f++)f!==b&&J(k,h,e[f],a,0,t-(f<b?b-f:f-b),p,t-1)}}}this.b[l]=1;this.C=!1}return this};g.prototype.A=function(a,b,c){if(x(b))for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.A(a,b[d],c);this.A(a,b[d])}else{const g=this.a.index;var d=this.a.tag,e=this.a.id;let h;let q;for(var l=0;l<e.length;l++)h=(h||b)[e[l]];if(d){for(e=0;e<d.length;e++){var k=d[e];var f=
k.split(":");for(l=0;l<f.length;l++)q=(q||b)[f[l]];q="@"+q}f=this.H[k];f=f[q]||(f[q]=[])}if("remove"===a){delete this.h[h];for(let a=0,b=g.length;a<b;a++){if(a===b-1)return g[a].remove(h,c);g[a].remove(h)}}e=this.a.field;f&&(f[f.length]=b);for(let f=0,l=e.length;f<l;f++){d=e[f];let m;for(k=0;k<d.length;k++)m=(m||b)[d[k]];this.h[h]=b;d=g[f];k="add"===a?d.add:d.update;if(f===l-1)return k.call(d,h,m,c);k.call(d,h,m)}}};g.prototype.update=function(a,b,c){if(this.a&&A(a))return this.A("update",a,b);this.b["@"+
a]&&H(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.A("remove",a,b);var d="@"+a;if(this.b[d]){if(this.g)return this.m[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<
this.c-(this.threshold||0);b++)N(this.i[b],a);this.depth&&N(this.j,a);delete this.b[d];this.C=!1}return this};let z;g.prototype.search=function(a,b,c,d){if(A(b)){if(x(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let f=a;let k,h=[];if(A(a)&&!x(a)){(c=a.callback||b)&&(f.callback=null);var g=a.where;k=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.a){a=this.a.ref;n=this.a.index;if(g=f.field)f.field=null;else if(x(f)){var q=f;g=[];for(var m=0;m<f.length;m++)g[m]=f[m].field}else g=
Object.keys(a);if(A(g)){k&&(f.sort=null);x(g)||(g=[g]);m=g.length;for(var p=0;p<m;p++)q&&(f=q[p]),h[p]=n[a[g[p]]].search(f);return c?c(B(h,k)):this.async?new Promise(function(a){Promise.all(h).then(function(b){a(B(b,k))})}):B(h,k)}return n[a[g]].search(f,c)}n||(n=this.threshold||0);G(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.G=c,this.u=0,this.l=[],g=0;g<this.g;g++)this.m[g].postMessage({search:!0,limit:b,threshold:n,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let d=
this;a=new Promise(function(a){setTimeout(function(){a(d.search(f,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!H(a))return h;f=a;if(this.cache)if(this.C){if(c=this.o.get(a))return c}else this.o.clear(),this.C=!0;f=this.encode(f);if(!f.length)return h;c=this.f;c=G(c)?c(f):f.split(R);q=c.length;d=!0;e=[];var u=r();if(1<q)if(this.depth){m=!0;var t=c[0];u[t]=1}else c.sort(Y);if(!m||(p=this.j)[t]){let a=this.c;for(let b=m?1:0;b<q;b++){const f=
c[b];if(f){if(!u[f]){const b=[];let c=!1,g=0;if(t=m?p[t]:this.i){let d;for(let e=0;e<a-n;e++)if(d=t[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!this.B){d=!1;break}u[f]=1}t=f}}}else d=!1;d&&(h=aa(e,b,void 0,this.h,this.B));g&&(h=this.where(g,null,b,h));k&&(h=B([h],k));this.cache&&this.o.set(a,h);return h}};g.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};g.prototype.where=function(a,b,c,d){const e=d||this.h,f=[];let g=0;var h;let u;if("number"===typeof a)return[e[a]];
if(H(a)){if(v(b))return[e[a]];if("id"===a)return[e[b]];var n=1;var q=[a.split(":")];u=!0}else{if(G(a)){b=d||Object.keys(e);c=b.length;for(h=0;h<c;h++)n=d?d[h]:e[b[h]],a(n)&&(f[g++]=n);return f}c||(c=b);h=Object.keys(a);n=h.length;u=!1;if(1===n&&"id"===h[0])return[e[a.id]];if((q=this.K)&&!d)for(var m=0;m<q.length;m++){var p=q[m],r=a[p];if(!v(r)){d=this.H[p]["@"+r];if(0===--n)return d;h.splice(h.indexOf(p),1);delete a[p];break}}q=Array(n);for(m=0;m<n;m++)q[m]=h[m].split(":")}m=d||Object.keys(e);p=m.length;
for(r=0;r<p;r++){const k=d?d[r]:e[m[r]];let l=!0;for(let c=0;c<n;c++){u||(b=a[h[c]]);const d=q[c],e=d.length;let f=k;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){l=!1;break}}if(l&&(f[g++]=k,c&&g===c))break}return f};g.prototype.info=function(){if(this.g)for(var a=0;a<this.g;a++)this.m[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var e=0;e<this.c-(this.threshold||0);e++){a=Object.keys(this.i[e]);for(let g=0;g<a.length;g++){var f=this.i[e][a[g]].length;b+=1*f+2*a[g].length+
4;c+=f;d+=2*a[g].length}}a=Object.keys(this.b);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.s?this.cache.s.length:!1,matcher:M.length+(this.v?this.v.length:0),worker:this.g,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.f}}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&(this.o.clear(),this.o=null);this.i=this.j=this.b=null;
if(this.a){const a=this.h.index;for(let b=0;b<a.length;b++)a.destroy();this.h=null}return this};g.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].i,a[c].j,a[c].b];b[c]=this.h;return JSON.stringify(b)}return JSON.stringify([this.i,this.j,this.b])};g.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.i=a[d][0];e.j=a[d][1];e.b=a[d][2];e.h=a[c]}this.h=a[c]}else this.i=
a[0],this.j=a[1],this.b=a[2],this.h=a[3]};const I={icase:function(a){return a.toLowerCase()},simple:function(){const a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=E(b.toLowerCase(),
a);return" "===b?"":b}}(),advanced:function(){const a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=E(b,a));c||1<b.length&&(b=O(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;
b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+E(d.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){const a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return O(E(b.toLowerCase(),a))}}()},da=function(){function a(a){this.clear();this.I=!0!==a&&a}a.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.s=[]};a.prototype.set=function(a,c){if(this.I&&v(this.cache[a])){let b=
this.s.length;if(b===this.I){b--;const a=this.s[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.s[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.I&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.s;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return g}(function(){const w=
{},F="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,y,B,K,f){B=F?URL.createObjectURL(new Blob(["("+B.toString()+")()"],{type:"text/javascript"})):g+".min.js";g+="-"+y;w[g]||(w[g]=[]);w[g][f]=new Worker(B);w[g][f].onmessage=K;return w[g][f]}}()),this);

View File

@@ -1,33 +1,34 @@
/*
FlexSearch v0.5.0
FlexSearch v0.5.1
Copyright 2019 Nextapps GmbH
Author: Thomas Wilkerling
Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch
*/
'use strict';(function(h,w,C){let f;(f=C.define)&&f.amd?f([],function(){return w}):(f=C.modules)?f[h.toLowerCase()]=w:"object"===typeof exports?module.exports=w:C[h]=w})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:R++;this.init(a,b);C(this,"index",function(){return this.b});C(this,"length",function(){return Object.keys(this.b).length})}function w(a,b){a=a.concat.apply([],a);b&&(D(b)||(x=b.split(":"),1<x.length?b=S:(x=x[0],b=T)),a.sort(b));return a}function C(a,
b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function y(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,d,e,g,l){if(b[c])return b[c];e=e?(9-(l||6))*g+(l||6)*e:g;b[c]=e;e>=l&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function K(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],l=a[e];if(l)for(let c=0,d=l.length;c<d;c++)if(l[c]===b){1===d?delete a[e]:l.splice(c,1);break}else z(l[c])&&
K(l[c],b)}}}function L(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}function U(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function V(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function T(a,b){a=a[x];b=b[x];return a<b?-1:a>b?1:0}function S(a,b){const c=x.length;for(let d=
0;d<c;d++)a=a[x[d]],b=b[x[d]];return a<b?-1:a>b?1:0}function W(a,b,c,d){let e=[],g;const l=a.length;if(1<l){a.sort(V);const f=u();let n=a[0],m=n.length,q=0;for(;q<m;)f["@"+n[q++]]=1;let p,h=0,r=0;for(;++r<l;){let E=!1;const F=r===l-1;g=[];n=a[r];m=n.length;for(q=0;q<m;){p=n[q++];var k="@"+p;if(f[k]){const a=f[k];if(a===r){if(F){if(e[h++]=c?c[k]:p,b&&h===b)return e}else f[k]=r+1;E=!0}else d&&(k=g[a]||(g[a]=[]),k[k.length]=p)}}if(!E&&!d)break}if(d&&(h=e.length,(r=g.length)&&(!b||h<b)))for(;r--;)if(p=
g[r])for(q=0,m=p.length;q<m;q++)if(e[h++]=c?c["@"+p[q]]:p[q],b&&h===b)return e}else if(l)if(c)for(a=a[0],d=a.length,b&&b<d&&(d=b),e=Array(d),b=0;b<d;b++)e[b]=c["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function I(a){return"string"===typeof a}function D(a){return"function"===typeof a}function z(a){return"object"===typeof a}function B(a){return"undefined"===typeof a}function M(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}const v=
{encode:"icase",c:"forward",s:!1,cache:!1,async:!1,B:!1,v:!1,threshold:0,depth:0,a:!1},N={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",c:"strict",threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},J=[];let R=0;const O=f("\\W+"),P={},Q={};h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&
J.push(f(b),a[b]);return this};h.registerEncoder=function(a,b){G[a]=b.bind(G);return this};h.registerLanguage=function(a,b){P[a]=b.filter;Q[a]=b.stemmer;return this};h.encode=function(a,b){return G[a](b)};h.prototype.init=function(a,b){this.l=[];if(b){var c=b.preset;a=b}else a||(a=v),c=a.preset;b={};I(a)?(b=N[a],a={}):c&&(b=N[c]);this.c=a.tokenize||b.c||this.c||v.c;this.v=a.rtl||this.v||v.v;this.async="undefined"===typeof Promise||B(c=a.async)?this.async||v.async:c;this.threshold=B(c=a.threshold)?
b.threshold||this.threshold||v.threshold:c;this.depth=B(c=a.depth)?b.depth||this.depth||v.depth:c;this.s=B(c=a.suggest)?this.s||v.s:c;this.m=(c=B(c=a.encode)?b.encode||v.encode:c)&&G[c]&&G[c].bind(G)||(D(c)?c:this.m||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=P[c]||c;b=this.m;var d=u();if(c)for(var e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var l;b=Q[c]||c;d=this.m;e=[];if(b)for(l in b)b.hasOwnProperty(l)&&(g=d?d(l):
l,e.push(f("(?=.{"+(g.length+3)+",})"+g+"$"),d?d(b[l]):b[l]));this.stemmer=l=e}this.a=g=(c=a.doc)?c:this.a||v.a;this.g=M(10-(this.threshold||0));this.h=u();this.b=u();if(g){this.f=u();a.doc=null;l=g.index=[];b=g.ref={};d=g.field;e=g.tag;g.id=g.id.split(":");if(e){this.w=u();e.constructor===Array||(g.tag=e=[e]);for(let a=0;a<e.length;a++)this.w[e[a]]=u(),e[a]=e[a].split(":")}if(d)for(d.constructor===Array||(g.field=d=[d]),g=0;g<d.length;g++)b[d[g]]=g,d[g]=d[g].split(":"),l[g]=new h(a),l[g].f=this.f,
e&&(l[g].w=this.w)}this.u=!0;this.j=(this.cache=c=B(c=a.cache)?this.cache||v.cache:c)?new X(c):!1;return this};h.prototype.encode=function(a){a&&J.length&&(a=y(a,J));a&&this.l.length&&(a=y(a,this.l));a&&this.m&&(a=this.m(a));a&&this.stemmer&&(a=y(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.l;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};h.prototype.add=function(a,b,c,d,e){if(this.a&&z(a))return this.o("add",a,b);if(b&&I(b)&&(a||0===a)){var g="@"+
a;if(this.b[g]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=D(c)?c(b):b.split(O);const h=u();h._ctx=u();const p=this.threshold,E=this.depth,r=this.g,t=e.length,F=this.v;for(let b=0;b<t;b++){var l=e[b];if(l){var k=l.length,f=(F?
b+1:t-b)/t,n="";switch(c){case "reverse":case "both":for(var m=k;--m;)n=l[m]+n,H(r,h,n,a,F?1:(k-m)/k,f,p);n="";case "forward":for(m=0;m<k;m++)n+=l[m],H(r,h,n,a,F?(m+1)/k:1,f,p);break;case "full":for(m=0;m<k;m++){const b=(F?m+1:k-m)/k;for(let c=k;c>m;c--)n=l.substring(m,c),H(r,h,n,a,b,f,p)}break;default:if(k=H(r,h,l,a,1,f,p),E&&1<t&&k>=p)for(k=h._ctx[l]||(h._ctx[l]=u()),l=this.h[l]||(this.h[l]=M(10-(p||0))),f=b-E,n=b+E+1,0>f&&(f=0),n>t&&(n=t);f<n;f++)f!==b&&H(l,k,e[f],a,0,10-(f<b?b-f:f-b),p)}}}this.b[g]=
1;this.u=!1}return this};h.prototype.o=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.o(a,b[d],c);this.o(a,b[d])}else{const l=this.a.index;var d=this.a.tag,e=this.a.id;let f;for(var g=0;g<e.length;g++)f=(f||b)[e[g]];if(d)for(e=0;e<d.length;e++);if("remove"===a){delete this.f["@"+f];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return l[a].remove(f,c);l[a].remove(f)}}e=this.a.field;for(let k=0,h=e.length;k<h;k++){d=e[k];let m;for(g=0;g<d.length;g++)m=(m||
b)[d[g]];this.f["@"+f]=b;d=l[k];g="add"===a?d.add:d.update;if(k===h-1)return g.call(d,f,m,c);g.call(d,f,m)}}};h.prototype.update=function(a,b,c){if(this.a&&z(a))return this.o("update",a,b);this.b["@"+a]&&I(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&z(a))return this.o("remove",a,b);var d="@"+a;if(this.b[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=
null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)K(this.g[b],a);this.depth&&K(this.h,a);delete this.b[d];this.u=!1}return this};let x;h.prototype.search=function(a,b,c,d){if(z(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let g=a;let f,k=[];if(z(a)&&a.constructor!==Array){(c=a.callback||b)&&(g.callback=null);var h=a.boost;var n=a.where;f=a.sort;b=a.limit;var m=a.threshold;
a=a.query}if(this.a){a=this.a.ref;m=this.a.index;if(n=g.field)g.field=null;else if(g.constructor===Array){var q=g;n=[];for(var p=0;p<g.length;p++)n[p]=g[p].field}else n=Object.keys(a);if(z(n)){n.constructor===Array||(n=[n]);p=n.length;for(var A=0;A<p;A++)q&&(g=q[A]),k[A]=m[a[n[A]]].search(g);return c?c(w(k,f)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(w(b,f))})}):w(k,f)}return m[a[n]].search(g,c)}m||(m=this.threshold||0);D(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&
"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(g,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!I(a))return k;g=a;if(this.cache)if(this.u){if(c=this.j.get(a))return c}else this.j.clear(),this.u=!0;g=this.encode(g);if(!g.length)return k;c=this.c;c=D(c)?c(g):g.split(O);q=c.length;d=!0;e=[];const r=u();if(1<q)if(this.depth){p=!0;var t=c[0];r[t]=1}else c.sort(U);if(!p||(A=this.h)[t]){let a=
0;h&&(m=(m||1)/h,0>h&&(a=m));for(h=p?1:0;h<q;h++){const b=c[h];if(b){if(!r[b]){const c=[];let g=!1,f=0;if(t=p?A[t]:this.g){let d;for(let e=a;e<10-m;e++)if(d=t[e][b])c[f++]=d,g=!0}if(g)e[e.length]=1<f?c.concat.apply([],c):c[0];else if(!this.s){d=!1;break}r[b]=1}t=b}}}else d=!1;d&&(k=W(e,b,this.f,this.s));n&&(k=this.where(n,null,b,k));f&&(k=w([k],f));this.cache&&this.j.set(a,k);return k};h.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};h.prototype.where=function(a,b,c,d){const e=d||
this.f,g=[];let f=0;var k;let h,n;if(I(a)){if("id"===a)return[e["@"+b]];var m=1;n=[a.split(":")];h=!0}else{if(D(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=d?d[k]:e[b[k]],a(m)&&(g[f++]=m);return g}c||(c=b);k=Object.keys(a);m=k.length;h=!1;if(1===m&&"id"===k[0])return[e["@"+a.id]];n=Array(m);for(var q=0;q<m;q++)n[q]=k[q].split(":")}q=d||Object.keys(e);const p=q.length;for(let l=0;l<p;l++){const p=d?d[l]:e[q[l]];let t=!0;for(let c=0;c<m;c++){h||(b=a[k[c]]);const d=n[c],e=d.length;let f=p;if(1<
e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){t=!1;break}}if(t&&(g[f++]=p,c&&f===c))break}return g};h.prototype.info=function(){let a;let b=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){a=Object.keys(this.g[e]);for(let g=0;g<a.length;g++){var f=this.g[e][a[g]].length;b+=1*f+2*a[g].length+4;c+=f;d+=2*a[g].length}}a=Object.keys(this.b);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.i?this.cache.i.length:
!1,matcher:J.length+(this.l?this.l.length:0),worker:this.B,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.g=this.h=this.b=null;if(this.a){const a=this.f.index;for(let b=0;b<a.length;b++)a.destroy();this.f=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=
[a[c].g,a[c].h,a[c].b];b[c]=this.f;return JSON.stringify(b)}return JSON.stringify([this.g,this.h,this.b])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.g=a[d][0];e.h=a[d][1];e.b=a[d][2];e.f=a[c]}this.f=a[c]}else this.g=a[0],this.h=a[1],this.b=a[2],this.f=a[3]};const G={icase:function(a){return a.toLowerCase()},simple:function(){const a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",
f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=y(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),
"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=y(b,a));c||1<b.length&&(b=L(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+y(d.substring(1),a))}b=b.join(" ");b=L(b)}return b}}(),balance:function(){const a=
[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return L(y(b.toLowerCase(),a))}}()},X=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.i=[]};a.prototype.set=function(a,c){if(this.A&&B(this.cache[a])){let b=this.i.length;if(b===this.A){b--;const a=this.i[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.i[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=
c};a.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.i;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return h}(!1),this);
'use strict';(function(h,y,D){let e;(e=D.define)&&e.amd?e([],function(){return y}):(e=D.modules)?e[h.toLowerCase()]=y:"object"===typeof exports?module.exports=y:D[h]=y})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:S++;this.init(a,b);D(this,"index",function(){return this.c});D(this,"length",function(){return Object.keys(this.c).length})}function y(a,b){a=a.concat.apply([],a);b&&(E(b)||(z=b.split(":"),1<z.length?b=T:(z=z[0],b=U)),a.sort(b));return a}function D(a,
b,c){Object.defineProperty(a,b,{get:c})}function e(a){return new RegExp(a,"g")}function C(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,d,f,l,g,k){if(b[c])return b[c];f=f?(k-(g||k/1.5))*l+(g||k/1.5)*f:l;b[c]=f;f>=g&&(a=a[k-(f+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return f}function L(a,b){if(a){const c=Object.keys(a);for(let d=0,f=c.length;d<f;d++){const f=c[d],g=a[f];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===b){1===d?delete a[f]:g.splice(c,1);break}else A(g[c])&&
L(g[c],b)}}}function M(a){let b="",c="";var d="";for(let f=0;f<a.length;f++){const l=a[f];if(l!==c)if(f&&"h"===l){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=l}else b+=l;d=f===a.length-1?"":a[f+1];c=l}return b}function V(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function W(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function U(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function T(a,b){const c=z.length;for(let d=
0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function X(a,b,c,d,f){c=[];let l;const g=a.length;if(1<g){a.sort(W);const u=t();let e=a[0],m=e.length,p=0;for(;p<m;)u["@"+e[p++]]=1;let q,w=0,h=0;for(;++h<g;){let n=!1;const B=h===g-1;l=[];e=a[h];m=e.length;for(p=0;p<m;){q=e[p++];var k="@"+q;if(u[k]){const a=u[k];if(a===h){if(B){if(c[w++]=d?d[q]:q,b&&w===b)return c}else u[k]=h+1;n=!0}else f&&(k=l[a]||(l[a]=[]),k[k.length]=q)}}if(!n&&!f)break}if(f&&(w=c.length,(h=l.length)&&(!b||w<b)))for(;h--;)if(q=
l[h])for(p=0,m=q.length;p<m;p++)if(c[w++]=d?d[q[p]]:q[p],b&&w===b)return c}else if(g)if(d)for(a=a[0],f=a.length,b&&b<f&&(f=b),c=Array(f),b=0;b<f;b++)c[b]=d[a[b]];else c=a[0],b&&c.length>b&&(c=c.slice(0,b));return c}function F(a){return"string"===typeof a}function x(a){return a.constructor===Array}function E(a){return"function"===typeof a}function A(a){return"object"===typeof a}function v(a){return"undefined"===typeof a}function N(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=t();return b}function t(){return Object.create(null)}
const r={encode:"icase",f:"forward",u:!1,cache:!1,async:!1,F:!1,w:!1,a:!1,C:!1,b:9,threshold:0,depth:0},O={memory:{encode:"extra",f:"strict",threshold:0,b:1},speed:{encode:"icase",f:"strict",threshold:1,b:3,depth:2},match:{encode:"extra",f:"full",threshold:1,b:3},score:{encode:"extra",f:"strict",threshold:1,b:9,depth:4},balance:{encode:"balance",f:"strict",threshold:0,b:3,depth:3},fast:{encode:"icase",f:"strict",threshold:8,b:9,depth:1}},K=[];let S=0;const P=e("\\W+"),Q={},R={};h.create=function(a){return new h(a)};
h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&K.push(e(b),a[b]);return this};h.registerEncoder=function(a,b){G[a]=b.bind(G);return this};h.registerLanguage=function(a,b){Q[a]=b.filter;R[a]=b.stemmer;return this};h.encode=function(a,b){return G[a](b)};h.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=r),c=a.preset;b={};F(a)?(b=O[a],a={}):c&&(b=O[c]);this.f=a.tokenize||b.f||this.f||r.f;this.w=a.rtl||this.w||r.w;this.async="undefined"===typeof Promise||
v(c=a.async)?this.async||r.async:c;this.threshold=v(c=a.threshold)?b.threshold||this.threshold||r.threshold:c;this.b=v(c=a.resolution)?c=b.b||this.b||r.b:c;c<=this.threshold&&(this.b=this.threshold+1);this.depth=v(c=a.depth)?b.depth||this.depth||r.depth:c;this.C=v(c=a.paging)?this.C||r.C:c;this.u=v(c=a.suggest)?this.u||r.u:c;this.o=(c=v(c=a.encode)?b.encode||r.encode:c)&&G[c]&&G[c].bind(G)||(E(c)?c:this.o||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=Q[c]||c;b=this.o;var d=t();if(c)for(var f=
0;f<c.length;f++){var l=b?b(c[f]):c[f];d[l]=String.fromCharCode(65E3-c.length+f)}this.filter=c=d}if(c=a.stemmer){var g;b=R[c]||c;d=this.o;f=[];if(b)for(g in b)b.hasOwnProperty(g)&&(l=d?d(g):g,f.push(e("(?=.{"+(l.length+3)+",})"+l+"$"),d?d(b[g]):b[g]));this.stemmer=g=f}this.a=d=(c=a.doc)?c:this.a||r.a;this.h=N(this.b-(this.threshold||0));this.i=t();this.c=t();if(d){this.g=t();a.doc=null;g=d.index=[];b=d.ref={};f=d.field;l=d.tag;x(d.id)||(d.id=d.id.split(":"));if(l){this.A=t();let b=t();if(f)if(F(f))b[f]=
a;else if(x(f))for(let c=0;c<f.length;c++)b[f[c]]=a;else A(f)&&(b=f);x(l)||(d.tag=l=[l]);for(f=0;f<l.length;f++)this.A[l[f]]=t();this.D=l;f=b}if(f){let c;x(f)||(A(f)?(c=f,d.field=f=Object.keys(f)):d.field=f=[f]);for(d=0;d<f.length;d++)x(f[d])||(c&&(a=c[f[d]]),b[f[d]]=d,f[d]=f[d].split(":")),g[d]=new h(a),g[d].g=this.g}}this.v=!0;this.l=(this.cache=c=v(c=a.cache)?this.cache||r.cache:c)?new Y(c):!1;return this};h.prototype.encode=function(a){a&&K.length&&(a=C(a,K));a&&this.m.length&&(a=C(a,this.m));
a&&this.o&&(a=this.o(a));a&&this.stemmer&&(a=C(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(e(c),a[c]);return this};h.prototype.add=function(a,b,c,d,f){if(this.a&&A(a))return this.s("add",a,b);if(b&&F(b)&&(a||0===a)){var l="@"+a;if(this.c[l]&&!d)return this.update(a,b);if(!f){if(this.async&&"function"!==typeof importScripts){let f=this;l=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)l.then(c);
else return l;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.f;f=E(c)?c(b):b.split(P);const p=t();p._ctx=t();const q=this.threshold,h=this.depth,u=this.b,I=this.h,B=f.length,J=this.w;for(let b=0;b<B;b++){var g=f[b];if(g){var k=g.length,e=(J?b+1:B-b)/B,n="";switch(c){case "reverse":case "both":for(var m=k;--m;)n=g[m]+n,H(I,p,n,a,J?1:(k-m)/k,e,q,u-1);n="";case "forward":for(m=0;m<k;m++)n+=g[m],H(I,p,n,a,J?(m+1)/k:1,e,q,u-1);break;case "full":for(m=
0;m<k;m++){const b=(J?m+1:k-m)/k;for(let c=k;c>m;c--)n=g.substring(m,c),H(I,p,n,a,b,e,q,u-1)}break;default:if(k=H(I,p,g,a,1,e,q,u-1),h&&1<B&&k>=q)for(k=p._ctx[g]||(p._ctx[g]=t()),g=this.i[g]||(this.i[g]=N(u-(q||0))),e=b-h,n=b+h+1,0>e&&(e=0),n>B&&(n=B);e<n;e++)e!==b&&H(g,k,f[e],a,0,u-(e<b?b-e:e-b),q,u-1)}}}this.c[l]=1;this.v=!1}return this};h.prototype.s=function(a,b,c){if(x(b))for(let d=0,f=b.length;d<f;d++){if(d===f-1)return this.s(a,b[d],c);this.s(a,b[d])}else{const k=this.a.index;var d=this.a.tag,
f=this.a.id;let n;let m;for(var l=0;l<f.length;l++)n=(n||b)[f[l]];if(d){for(f=0;f<d.length;f++){var g=d[f];var e=g.split(":");for(l=0;l<e.length;l++)m=(m||b)[e[l]];m="@"+m}e=this.A[g];e=e[m]||(e[m]=[])}if("remove"===a){delete this.g[n];for(let a=0,b=k.length;a<b;a++){if(a===b-1)return k[a].remove(n,c);k[a].remove(n)}}f=this.a.field;e&&(e[e.length]=b);for(let e=0,l=f.length;e<l;e++){d=f[e];let m;for(g=0;g<d.length;g++)m=(m||b)[d[g]];this.g[n]=b;d=k[e];g="add"===a?d.add:d.update;if(e===l-1)return g.call(d,
n,m,c);g.call(d,n,m)}}};h.prototype.update=function(a,b,c){if(this.a&&A(a))return this.s("update",a,b);this.c["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&A(a))return this.s("remove",a,b);var d="@"+a;if(this.c[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,
!0),b(),this}for(b=0;b<this.b-(this.threshold||0);b++)L(this.h[b],a);this.depth&&L(this.i,a);delete this.c[d];this.v=!1}return this};let z;h.prototype.search=function(a,b,c,d){if(A(b)){if(x(b))for(var f=0;f<b.length;f++)b[f].query=a;else b.query=a;a=b;b=0}let e=a;let g,k=[];if(A(a)&&!x(a)){(c=a.callback||b)&&(e.callback=null);var h=a.where;g=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.a){a=this.a.ref;n=this.a.index;if(h=e.field)e.field=null;else if(x(e)){var m=e;h=[];for(var p=0;p<e.length;p++)h[p]=
e[p].field}else h=Object.keys(a);if(A(h)){g&&(e.sort=null);x(h)||(h=[h]);p=h.length;for(var q=0;q<p;q++)m&&(e=m[q]),k[q]=n[a[h[q]]].search(e);return c?c(y(k,g)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(y(b,g))})}):y(k,g)}return n[a[h]].search(e,c)}n||(n=this.threshold||0);E(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(e,b,null,!0));d=null})});if(c)a.then(c);
else return a;return this}if(c)return c(this.search(e,b,null,!0)),this}if(!a||!F(a))return k;e=a;if(this.cache)if(this.v){if(c=this.l.get(a))return c}else this.l.clear(),this.v=!0;e=this.encode(e);if(!e.length)return k;c=this.f;c=E(c)?c(e):e.split(P);m=c.length;d=!0;f=[];const w=t();if(1<m)if(this.depth){p=!0;var r=c[0];w[r]=1}else c.sort(V);if(!p||(q=this.i)[r]){let a=this.b;for(let b=p?1:0;b<m;b++){const e=c[b];if(e){if(!w[e]){const b=[];let c=!1,g=0;if(r=p?q[r]:this.h){let d;for(let f=0;f<a-n;f++)if(d=
r[f][e])b[g++]=d,c=!0}if(c)f[f.length]=1<g?b.concat.apply([],b):b[0];else if(!this.u){d=!1;break}w[e]=1}r=e}}}else d=!1;d&&(k=X(f,b,void 0,this.g,this.u));h&&(k=this.where(h,null,b,k));g&&(k=y([k],g));this.cache&&this.l.set(a,k);return k};h.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};h.prototype.where=function(a,b,c,d){const f=d||this.g,e=[];let g=0;var k;let h;if("number"===typeof a)return[f[a]];if(F(a)){if(v(b))return[f[a]];if("id"===a)return[f[b]];var n=1;var m=[a.split(":")];
h=!0}else{if(E(a)){b=d||Object.keys(f);c=b.length;for(k=0;k<c;k++)n=d?d[k]:f[b[k]],a(n)&&(e[g++]=n);return e}c||(c=b);k=Object.keys(a);n=k.length;h=!1;if(1===n&&"id"===k[0])return[f[a.id]];if((m=this.D)&&!d)for(var p=0;p<m.length;p++){var q=m[p],r=a[q];if(!v(r)){d=this.A[q]["@"+r];if(0===--n)return d;k.splice(k.indexOf(q),1);delete a[q];break}}m=Array(n);for(p=0;p<n;p++)m[p]=k[p].split(":")}p=d||Object.keys(f);q=p.length;for(r=0;r<q;r++){const l=d?d[r]:f[p[r]];let q=!0;for(let c=0;c<n;c++){h||(b=
a[k[c]]);const d=m[c],f=d.length;let e=l;if(1<f)for(let a=0;a<f;a++)e=e[d[a]];else e=e[d[0]];if(e!==b){q=!1;break}}if(q&&(e[g++]=l,c&&g===c))break}return e};h.prototype.info=function(){let a;let b=0,c=0,d=0;for(var f=0;f<this.b-(this.threshold||0);f++){a=Object.keys(this.h[f]);for(let g=0;g<a.length;g++){var e=this.h[f][a[g]].length;b+=1*e+2*a[g].length+4;c+=e;d+=2*a[g].length}}a=Object.keys(this.c);e=a.length;for(f=0;f<e;f++)b+=2*a[f].length+2;return{id:this.id,memory:b,items:e,sequences:c,chars:d,
cache:this.cache&&this.cache.j?this.cache.j.length:!1,matcher:K.length+(this.m?this.m.length:0),worker:this.F,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.f}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.l.clear(),this.l=null);this.h=this.i=this.c=null;if(this.a){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.index,
b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].h,a[c].i,a[c].c];b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.c])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const f=b[d];f.h=a[d][0];f.i=a[d][1];f.c=a[d][2];f.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.c=a[2],this.g=a[3]};const G={icase:function(a){return a.toLowerCase()},simple:function(){const a=[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),
"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=C(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",
e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=C(b,a));c||1<b.length&&(b=M(b));return b}}(),extra:function(){const a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+C(d.substring(1),
a))}b=b.join(" ");b=M(b)}return b}}(),balance:function(){const a=[e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){return M(C(b.toLowerCase(),a))}}()},Y=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=t();this.count=t();this.index=t();this.j=[]};a.prototype.set=function(a,c){if(this.B&&v(this.cache[a])){let b=this.j.length;if(b===this.B){b--;const a=this.j[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=
b;this.j[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.B&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const e=this.j;for(var f=c;this.count[e[--c]]<=d&&-1!==c;);c++;if(c!==f){for(d=f;d>c;d--)f=e[d-1],e[d]=f,b[f]=d;e[c]=a;b[a]=c}}}return b};return a}();return h}(!1),this);

View File

@@ -1,5 +1,5 @@
/**!
* @preserve FlexSearch v0.5.0
* @preserve FlexSearch v0.5.1
* Copyright 2019 Nextapps GmbH
* Author: Thomas Wilkerling
* Released under the Apache 2.0 Licence
@@ -41,15 +41,17 @@
async: false,
worker: false,
rtl: false,
doc: false,
paging: false,
// minimum scoring (0 - 9)
// maximum scoring
resolution: 9,
// minimum scoring
threshold: 0,
// contextual depth
depth: 0,
// multi-field documents
doc: false
depth: 0
};
/**
@@ -62,39 +64,46 @@
"memory": {
encode: SUPPORT_ENCODER ? "extra" : "icase",
tokenize: "strict",
threshold: 7
threshold: 0,
resolution: 1
},
"speed": {
encode: "icase",
tokenize: "strict",
threshold: 7,
threshold: 1,
resolution: 3,
depth: 2
},
"match": {
encode: SUPPORT_ENCODER ? "extra" : "icase",
tokenize: "full"
tokenize: "full",
threshold: 1,
resolution: 3
},
"score": {
encode: SUPPORT_ENCODER ? "extra" : "icase",
tokenize: "strict",
threshold: 5,
threshold: 1,
resolution: 9,
depth: 4
},
"balance": {
encode: SUPPORT_ENCODER ? "balance" : "icase",
tokenize: "strict",
threshold: 6,
threshold: 0,
resolution: 3,
depth: 3
},
"fastest": {
"fast": {
encode: "icase",
tokenize: "strict",
threshold: 9,
threshold: 8,
resolution: 9,
depth: 1
}
};
@@ -114,19 +123,6 @@
let id_counter = 0;
/**
* @enum {number}
*/
/*
const enum_task = {
add: 0,
update: 1,
remove: 2
};
*/
/**
* NOTE: This could make issues on some languages (chinese, korean, thai)
* TODO: extract all language-specific stuff from the core
@@ -295,6 +291,14 @@
return this;
}
const tag_options = {
"encode": false,
"tokenize": function(doc){
return [doc];
}
};
/**
* @param {Object<string, number|string|boolean|Object|function(string):string>|string=} options
* @param {Object<string, number|string|boolean>=} settings
@@ -432,6 +436,23 @@
custom
);
/** @private */
this.resolution = (
is_undefined(custom = options["resolution"]) ?
custom = preset.resolution ||
this.resolution ||
defaults.resolution
:
custom
);
if(custom <= this.threshold){
this.resolution = this.threshold + 1;
}
/** @private */
this.depth = (
@@ -444,6 +465,27 @@
custom
);
/** @private */
this.paging = (
is_undefined(custom = options["paging"]) ?
this.paging ||
defaults.paging
:
custom
);
// TODO: provide boost
/** @private */
/*
this.boost = (
(custom = options["boost"]) ? custom : 0
);
*/
if(SUPPORT_SUGGESTIONS){
/** @private */
@@ -511,7 +553,7 @@
// initialize primary index
/** @private */
this._map = create_object_array(10 - (this.threshold || 0));
this._map = create_object_array(this.resolution - (this.threshold || 0));
/** @private */
this._ctx = create_object();
/** @private */
@@ -529,12 +571,36 @@
let field = doc["field"];
let tag = doc["tag"];
doc["id"] = doc["id"].split(":");
if(!is_array(doc["id"])){
doc["id"] = doc["id"].split(":");
}
if(SUPPORT_WHERE && tag){
this._tag = create_object();
let field_custom = create_object();
if(field){
if(is_string(field)){
field_custom[field] = options;
}
else if(is_array(field)){
for(let i = 0; i < field.length; i++){
field_custom[field[i]] = options;
}
}
else if(is_object(field)){
field_custom = field;
}
}
if(!is_array(tag)){
doc["tag"] = tag = [tag];
@@ -542,30 +608,57 @@
for(let i = 0; i < tag.length; i++){
this._tag[tag[i]] = create_object();
//TODO: delegate tag indexes to intersection
//field_custom[tag[i]] = tag_options;
tag[i] = tag[i].split(":");
this._tag[tag[i]] = create_object();
}
this._tags = tag;
field = field_custom;
}
if(field){
let has_custom;
if(!is_array(field)){
doc["field"] = field = [field];
if(is_object(field)){
has_custom = field;
doc["field"] = field = get_keys(field);
}
else{
doc["field"] = field = [field];
}
}
for(let i = 0; i < field.length; i++){
ref[field[i]] = i;
field[i] = field[i].split(":");
if(!is_array(field[i])){
if(has_custom){
options = has_custom[field[i]];
}
ref[field[i]] = i;
field[i] = field[i].split(":");
}
// TODO: move fields to main index to provide pagination
index[i] = new FlexSearch(options);
index[i]._doc = this._doc;
if(SUPPORT_WHERE && tag){
index[i]._tag = this._tag;
}
// if(SUPPORT_WHERE && tag){
//
// index[i]._tag = this._tag;
// index[i]._tags = tag;
// }
}
}
}
@@ -826,6 +919,7 @@
const threshold = this.threshold;
const depth = this.depth;
const resolution = this.resolution;
const map = this._map;
const word_length = words.length;
const rtl = this.rtl;
@@ -863,7 +957,8 @@
id,
rtl ? 1 : (length - a) / length,
context_score,
threshold
threshold,
resolution - 1
);
}
@@ -885,7 +980,8 @@
id,
rtl ? (a + 1) / length : 1,
context_score,
threshold
threshold,
resolution - 1
);
}
@@ -909,7 +1005,8 @@
id,
partial_score,
context_score,
threshold
threshold,
resolution - 1
);
}
}
@@ -930,13 +1027,14 @@
// TODO compute and pass distance of ngram sequences as the initial score for each word
1,
context_score,
threshold
threshold,
resolution - 1
);
if(depth && (word_length > 1) && (score >= threshold)){
const ctxDupes = dupes["_ctx"][value] || (dupes["_ctx"][value] = create_object());
const ctxTmp = this._ctx[value] || (this._ctx[value] = create_object_array(10 - (threshold || 0)));
const ctxTmp = this._ctx[value] || (this._ctx[value] = create_object_array(resolution - (threshold || 0)));
let x = i - depth;
let y = i + depth + 1;
@@ -953,8 +1051,9 @@
words[x],
id,
0,
10 - (x < i ? i - x : x - i),
threshold
resolution - (x < i ? i - x : x - i),
threshold,
resolution - 1
);
}
}
@@ -986,24 +1085,24 @@
/**
* @param {!string} job
* @param docs
* @param doc
* @param {Function=} callback
* @returns {*}
*/
FlexSearch.prototype.handle_docs = function(job, docs, callback){
FlexSearch.prototype.handle_docs = function(job, doc, callback){
if(is_array(docs)){
if(is_array(doc)){
for(let i = 0, len = docs.length; i < len; i++){
for(let i = 0, len = doc.length; i < len; i++){
if(i === len - 1){
return this.handle_docs(job, docs[i], callback);
return this.handle_docs(job, doc[i], callback);
}
else{
this.handle_docs(job, docs[i]);
this.handle_docs(job, doc[i]);
}
}
}
@@ -1014,23 +1113,37 @@
let tree = this.doc["id"];
let id;
let tag;
let tag_key;
let tag_value;
for(let i = 0; i < tree.length; i++){
id = (id || docs)[tree[i]];
id = (id || doc)[tree[i]];
}
if(tags){
for(let i = 0; i < tags.length; i++){
tag = (tag || docs)[tags[i]];
tag_key = tags[i];
const tag_split = tag_key.split(":");
for(let i = 0; i < tag_split.length; i++){
tag_value = (tag_value || doc)[tag_split[i]];
}
tag_value = "@" + tag_value;
}
tag = this._tag[tag_key];
tag = tag[tag_value] || (tag[tag_value] = []);
}
if(job === "remove"){
delete this._doc["@" + id];
delete this._doc[id];
for(let z = 0, length = index.length; z < length; z++){
@@ -1047,6 +1160,11 @@
tree = this.doc["field"];
if(tag){
tag[tag.length] = doc; // tag[tag.length] = id;
}
for(let i = 0, len = tree.length; i < len; i++){
const branch = tree[i];
@@ -1054,20 +1172,23 @@
for(let x = 0; x < branch.length; x++){
content = (content || docs)[branch[x]];
content = (content || doc)[branch[x]];
}
this._doc["@" + id] = docs;
this._doc[id] = doc;
const self = index[i];
const fn = (
job === "add" ?
let fn;
self.add
:
self.update
);
if(job === "add"){
fn = self.add;
}
else{
fn = self.update;
}
if(i === len - 1){
@@ -1199,7 +1320,7 @@
profile_start("remove");
}
for(let z = 0; z < (10 - (this.threshold || 0)); z++){
for(let z = 0; z < (this.resolution - (this.threshold || 0)); z++){
remove_index(this._map[z], id);
}
@@ -1257,6 +1378,8 @@
}
/**
* TODO: move fields to main index to provide pagination
*
* @param {!string|Object|Array<Object>} query
* @param {number|Function=} limit
* @param {Function=} callback
@@ -1287,9 +1410,10 @@
let _query = query;
let threshold;
let boost;
//let boost;
let where;
let sort;
let cursor;
let result = [];
if(is_object(query) && (!SUPPORT_DOCUMENTS || !is_array(query))){
@@ -1308,11 +1432,12 @@
if(SUPPORT_DOCUMENTS){
boost = query["boost"];
//boost = query["boost"];
where = query["where"];
sort = query["sort"];
}
//cursor = this.paging && query["cursor"];
limit = query["limit"];
threshold = query["threshold"];
query = query["query"];
@@ -1347,6 +1472,11 @@
if(is_object(field)){
if(sort){
_query["sort"] = null;
}
if(!is_array(field)){
field = [field];
@@ -1364,7 +1494,6 @@
const ref = doc_ref[field[i]];
// TODO: Support Field-Merging (return array before intersection and apply here)
result[i] = doc_idx[ref].search(_query);
}
@@ -1419,6 +1548,7 @@
"search": true,
"limit": limit,
//"cursor": cursor,
"threshold": threshold,
"content": query
});
@@ -1551,21 +1681,45 @@
}
}
/*
if(SUPPORT_WHERE && where){
const tags = this._tags;
if(tags){
for(let i = 0; i < tags.length; i++){
const current_tag = tags[i];
const current_where = where[current_tag];
if(!is_undefined(current_where)){
check[check.length] = this._tag[current_tag]["@" + current_where];
delete where[current_tag];
}
}
if(get_keys(where).length === 0){
where = false;
}
}
}
*/
let ctx_map;
if(!use_contextual || (ctx_map = this._ctx)[ctx_root]){
let initial_z = 0;
let resolution = this.resolution;
if(SUPPORT_DOCUMENTS && boost){
threshold = (threshold || 1) / boost;
if(boost < 0){
initial_z = threshold;
}
}
// TODO: boost on custom search is actually not possible, move to adding index instead
// if(SUPPORT_DOCUMENTS && boost){
//
// threshold = (threshold || 1) / boost;
// }
for(let a = (use_contextual ? 1 : 0); a < length; a++){
@@ -1589,7 +1743,7 @@
let map_value;
for(let z = initial_z; z < (10 - threshold); z++){
for(let z = 0; z < (resolution - threshold); z++){
if((map_value = map[z][value])){
@@ -1639,7 +1793,7 @@
// Not handled by intersection:
result = intersect(check, limit, SUPPORT_DOCUMENTS && this._doc, SUPPORT_SUGGESTIONS && this.suggest);
result = intersect(check, limit, cursor, SUPPORT_DOCUMENTS && this._doc, SUPPORT_SUGGESTIONS && this.suggest);
// Handled by intersection:
@@ -1651,7 +1805,7 @@
result = this.where(where, null, limit, result);
}
if(sort){
if(SUPPORT_DOCUMENTS && sort){
result = merge_and_sort([result], sort);
}
@@ -1702,11 +1856,20 @@
let has_value;
let tree;
if(is_string(key)){
if(typeof key === "number"){
return [doc[key]];
}
else if(is_string(key)){
if(is_undefined(value)){
return [doc[key]];
}
if(key === "id"){
return [doc["@" + value]];
return [doc[value]];
}
//keys = [key];
@@ -1740,7 +1903,40 @@
if((keys_len === 1) && (keys[0] === "id")){
return [doc["@" + key["id"]]];
return [doc[key["id"]]];
}
const tags = this._tags;
if(tags && !result){
for(let i = 0; i < tags.length; i++){
const current_tag = tags[i];
const current_where = key[current_tag];
if(!is_undefined(current_where)){
result = this._tag[current_tag]["@" + current_where];
//result = result.slice(0, limit && (limit < result.length) ? limit : result.length);
if(--keys_len === 0){
return result;
}
keys.splice(keys.indexOf(current_tag), 1);
// TODO: delete from original reference?
delete key[current_tag];
break;
}
}
// for(let i = 0; i < result.length; i++){
//
// result[i] = this._doc[result[i]];
// }
}
tree = new Array(keys_len);
@@ -1799,7 +1995,7 @@
}
return results;
}
};
}
if(SUPPORT_INFO){
@@ -1828,7 +2024,7 @@
words = 0,
chars = 0;
for(let z = 0; z < (10 - (this.threshold || 0)); z++){
for(let z = 0; z < (this.resolution - (this.threshold || 0)); z++){
keys = get_keys(this._map[z]);
@@ -2225,36 +2421,8 @@
} : {
"icase": global_encoder_icase
//"balance": global_encoder_balance
};
// Async Handler
/*
const queue = SUPPORT_ASYNC ? (function(){
const stack = create_object();
return function(fn, delay, key){
const timer = stack[key];
if(timer){
clearTimeout(timer);
}
return (
stack[key] = setTimeout(fn, delay)
);
};
}()) : null;
*/
// Flexi-Cache
const Cache = SUPPORT_CACHE ? (function(){
function CacheClass(limit){
@@ -2452,9 +2620,10 @@
* @param {number} partial_score
* @param {number} context_score
* @param {number} threshold
* @param {number} resolution
*/
function add_index(map, dupes, value, id, partial_score, context_score, threshold){
function add_index(map, dupes, value, id, partial_score, context_score, threshold, resolution){
/*
if(index_blacklist[value]){
@@ -2472,7 +2641,7 @@
partial_score ?
(9 - (threshold || 6)) * context_score + (threshold || 6) * partial_score
(resolution - (threshold || (resolution / 1.5))) * context_score + (threshold || (resolution / 1.5)) * partial_score
//(9 - (threshold || 4.5)) * context_score + (threshold || 4.5) * partial_score
//4.5 * (context_score + partial_score)
:
@@ -2483,7 +2652,7 @@
if(score >= threshold){
let arr = map[9 - ((score + 0.5) >> 0)];
let arr = map[resolution - ((score + 0.5) >> 0)];
arr = arr[value] || (arr[value] = []);
arr[arr.length] = id;
@@ -2849,12 +3018,13 @@
/**
* @param {!Array<Array<number|string>>} arrays
* @param {number=} limit
* @param {number=} cursor
* @param {Object=} docs
* @param {boolean=} suggest
* @returns {Array}
*/
function intersect(arrays, limit, docs, suggest) {
function intersect(arrays, limit, cursor, docs, suggest) {
let result = [];
let suggestions;
@@ -2885,8 +3055,6 @@
while(++z < length_z){
// get each array one by one
let found = false;
const is_final_loop = (z === (length_z - 1));
@@ -2911,10 +3079,21 @@
if(is_final_loop){
result[count++] = docs ? docs[index] : tmp;
result[count++] = docs ? docs[tmp] : tmp;
if(limit && (count === limit)){
// if(cursor){
//
// return {
//
// "current": cursor,
// "prev": null,
// "next": z + ":" + i,
// "result": result
// };
// }
return result;
}
}
@@ -2963,7 +3142,7 @@
for(i = 0, length = tmp.length; i < length; i++){
result[count++] = docs ? docs["@" + tmp[i]] : tmp[i];
result[count++] = docs ? docs[tmp[i]] : tmp[i];
if(limit && (count === limit)){
@@ -2991,7 +3170,7 @@
for(let i = 0; i < length; i++){
result[i] = docs["@" + arr[i]];
result[i] = docs[arr[i]];
}
}
else{

View File

@@ -1,6 +1,6 @@
{
"name": "flexsearch",
"version": "0.5.0",
"version": "0.5.1",
"description": "Next-Generation full text search library with zero dependencies.",
"homepage": "https://github.com/nextapps-de/flexsearch/",
"author": "Thomas Wilkerling",
@@ -33,7 +33,7 @@
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
"build-lang": "node compile RELEASE=lang",
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node && npm run build-lang",
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node",
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit",
"test-light": "nyc --reporter=html --reporter=text mocha --timeout=3000 test/ --exit",
"test-develop": "nyc --reporter=html --reporter=text mocha --timeout=3000 --exit",
@@ -58,7 +58,7 @@
"chai": "^4.2.0",
"codacy-coverage": "^3.4.0",
"coveralls": "^3.0.2",
"google-closure-compiler": "^20190124.0.0-nightly",
"google-closure-compiler": "^20190204.0.0-nightly",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mocha-phantomjs": "^4.1.0",

555
test/benchmark-docs.html Normal file
View File

@@ -0,0 +1,555 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark Presets</title>
<style>
body{
font-family: sans-serif;
}
table td{
padding: 1em 2em;
}
button{
padding: 5px 10px;
}
</style>
</head>
<body>
<h2>Document Index Benchmark Comparison</h2>
<h4>Indexed Text: Movie Documents</h4>
<hr>
<div id="container"></div>
<hr>
<script src="../dist/flexsearch.min.js"></script>
<script src="../data/movies.js"></script>
<script>
(function(){
var index = {};
var index_doc = {};
var flexsearch_doc;
var flexsearch_doc_field;
var flexsearch_where;
var flexsearch_where_custom;
var flexsearch_tag;
var flexsearch_static;
var flexsearch_static_tag;
var flexsearch_static_tag_query;
var flexsearch_static_query;
var flexsearch_index_tag;
var flexsearch_index_ref;
var flexsearch_find;
function add(id, cat, content){
(index[cat] || (
index[cat] = new FlexSearch("fast")
)).add(id, content);
}
function search(cat, query){
return index[cat].search(query);
}
function add_doc(cat, content){
(index_doc[cat] || (
index_doc[cat] = new FlexSearch({
preset: "fast",
doc: {
id: "id",
field: "title"
}
})
)).add(content);
}
function search_doc(cat, query){
return index_doc[cat].search(query, {
field: "title"
});
}
var tests = {
"helper-no-doc": {
init: function(){},
add: function(content){
add(content.id, content.genre, content.title);
},
query: function(query){
return search("Adventure", query);
},
loops: 400000
},
"helper-doc": {
init: function(){},
add: function(content){
add_doc(content.genre, content);
},
query: function(query){
return search_doc("Adventure", query);
},
loops: 300000
},
"doc-no-cat-no-field": {
init: function(){
flexsearch_doc = new FlexSearch({
preset: "fast",
doc: {
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_doc.add(content);
},
query: function(query){
return flexsearch_doc.search(query);
},
loops: 250000
},
"doc-no-cat-field": {
init: function(){
flexsearch_doc_field = new FlexSearch({
preset: "fast",
doc: {
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_doc_field.add(content);
},
query: function(query){
return flexsearch_doc_field.search(query, {
field: "title"
});
},
loops: 250000
},
"where-cat": {
init: function(){
flexsearch_where = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_where.add(content);
},
query: function(query){
return flexsearch_where.search(query, {
field: "title",
where: {
genre: "Adventure"
}
});
},
loops: 250000
},
"where-custom": {
init: function(){
flexsearch_where_custom = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_where_custom.add(content);
},
query: function(query){
return flexsearch_where_custom.search(query, {
field: "title",
where: function(val){
return val.genre === "Adventure";
}
});
},
loops: 250000
},
"where-tag": {
init: function(){
flexsearch_tag = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: ["title"],
tag: ["genre"]
}
});
},
add: function(content){
flexsearch_tag.add(content);
},
query: function(query){
return flexsearch_tag.search(query, {
field: "title",
where: {
genre: "Adventure"
}
});
},
loops: 250000
},
"where-indexed-manual": {
init: function(){
flexsearch_index_ref = new FlexSearch({
encode: false,
tokenize: function(doc){
return [doc];
},
doc:{
id: "id",
field: ["genre"]
}
});
},
add: function(content){
flexsearch_index_ref.add(content);
},
query: function(query){
return flexsearch_index_ref.search("Adventure", {
field: "genre"
});
},
loops: 300000
},
/*
"where-indexed-tag": {
init: function(){
flexsearch_index_tag = new FlexSearch({
preset: "fastest",
doc:{
id: "id",
field: ["title"],
tag: ["genre"]
}
});
},
add: function(content){
flexsearch_index_tag.add(content);
},
query: function(query){
return flexsearch_index_tag.search("Adventure", {
field: "genre"
});
},
loops: 250000
},
*/
"static-where": {
init: function(){
flexsearch_static = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_static.add(content);
},
query: function(query){
return flexsearch_static.where({
genre: "Adventure"
});
},
loops: 400
},
"static-where-tag": {
init: function(){
flexsearch_static_tag = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title",
tag: "genre"
}
});
},
add: function(content){
flexsearch_static_tag.add(content);
},
query: function(query){
return flexsearch_static_tag.where({
genre: "Adventure"
});
},
loops: 5000000
},
"static-where-query": {
init: function(){
flexsearch_static_query = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_static_query.add(content);
},
query: function(query){
return flexsearch_static_query.where({
title: query,
genre: "Adventure"
});
},
loops: 400
},
"static-where-tag-query": {
init: function(){
flexsearch_static_tag_query = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title",
tag: "genre"
}
});
},
add: function(content){
flexsearch_static_tag_query.add(content);
},
query: function(query){
return flexsearch_static_tag_query.where({
title: query,
genre: "Adventure"
});
},
loops: 5000
},
"static-find-id": {
init: function(){
flexsearch_find = new FlexSearch({
preset: "fast",
doc:{
id: "id",
field: "title"
}
});
},
add: function(content){
flexsearch_find.add(content);
},
query: function(query){
return flexsearch_find.find(10000);
},
loops: 20000000
}
};
function init_container(target){
var html = "<table>" +
"<tr>" +
"<th>Preset&emsp;</th>" +
"<th>Single Phrase&emsp;</th>" +
"<th>Multi Phrase&emsp;</th>" +
"<th>Not Found&emsp;</th>" +
"</tr>";
for(var test in tests){
if(tests.hasOwnProperty(test)){
html += "<tr>" +
"<td>" + test + "</td>" +
"<td id=\"test-" + test + "\">indexing ...</td>" +
"<td id=\"test-multi-" + test + "\"></td>" +
"<td id=\"test-notfound-" + test + "\"></td>" +
"</tr>"
}
}
html += "</table>";
target.innerHTML = html;
}
var is_mobile = navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/);
var genres = ["Comedy", "Adventure", "Comic", "Horror"];
function init_tests(index, keys){
var key = keys[index];
var test = tests[key];
test.init();
if(is_mobile && (test.loops > 1)){
test.loops = (test.loops / 5) >> 0;
}
for(var i = 0; i < data.length; i++){
test.add({
id: i,
genre: genres[i % 4],
title: data[i]
});
}
document.getElementById("test-" + key).textContent = "ready ...";
if(++index < keys.length){
setTimeout(function(){
init_tests(index, keys);
}, 100);
}
else{
setTimeout(function(){
start_tests(0, 0, keys);
}, 1000);
}
}
function start_tests(suite, index, keys){
var phrase = suite === 0 ? "mermaid" : (suite === 1 ? "little mermaid" : "undefined");
var key = keys[index];
var test = tests[key];
var loops = test.loops;
var query = test.query;
var start = Date.now();
for(var x = 0; x < loops; x++){
query(phrase);
}
var duration = Date.now() - start;
console.log("[Suite " + suite + "] " + key + ":", duration);
document.getElementById("test-" + (suite === 1 ? "multi-" : (suite === 2 ? "notfound-" : "")) + key).textContent = format_number(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
if(++index >= keys.length){
if(++suite < 3){
index = 0;
}
}
if(index < keys.length){
setTimeout(function(){
start_tests(suite, index, keys);
}, 1000);
}
}
init_container(document.getElementById("container"));
setTimeout(function(){
init_tests(0, Object.keys(tests));
}, 100);
function format_number(num){
return ("" + num).replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
}
// ---------------------------------------
//window.tests = tests;
})();
</script>
</body>
</html>

View File

@@ -17,7 +17,6 @@
</head>
<body>
<h2>Presets Benchmark Comparison</h2>
<!--<button id="btn_start" onclick="start();" disabled>Start</button>-->
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<hr>
<div id="container"></div>
@@ -26,30 +25,28 @@
<script src="../data/gulliver.js"></script>
<script>
//var data = [];
(function(){
var flexsearch_default = new FlexSearch();
var flexsearch_memory = new FlexSearch("memory");
var flexsearch_speed = new FlexSearch("speed");
var flexsearch_fastest = new FlexSearch("fastest");
var flexsearch_fast = new FlexSearch("fast");
var flexsearch_match = new FlexSearch("match");
var flexsearch_score = new FlexSearch("score");
var flexsearch_balance = new FlexSearch("balance");
var tests = {
"fastest": {
"fast": {
init: function(){},
add: function(index, content){
flexsearch_fastest.add(index, content);
flexsearch_fast.add(index, content);
},
query: function(query){
return flexsearch_fastest.search(query);
return flexsearch_fast.search(query);
},
loops: 250000
},
@@ -146,7 +143,7 @@
"<th>Preset&emsp;</th>" +
"<th>Benchmark (Single Phrase)&emsp;</th>" +
"<th>Benchmark (Multi Phrase)&emsp;</th>" +
"<th>Benchmark (Mixed Not Found)&emsp;</th>" +
"<th>Benchmark (Not Found)&emsp;</th>" +
"</tr>";
for(var test in tests){
@@ -198,15 +195,6 @@
}
else{
/*
window.start = function(){
start_tests(0, Object.keys(tests));
};
document.getElementById("btn_start").disabled = false;
*/
setTimeout(function(){
start_tests(0, 0, keys);
@@ -280,7 +268,7 @@
// ---------------------------------------
window.tests = tests;
//window.tests = tests;
})();
</script>
</body>

463
test/benchmark-short.html Normal file
View File

@@ -0,0 +1,463 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Benchmark</title>
<style>
body{
font-family: sans-serif;
}
table td{
padding: 1em 2em;
}
button{
padding: 5px 10px;
}
</style>
</head>
<body>
<h2>Benchmark Comparison</h2>
<h4>Indexed Text: Movie Titles</h4>
<hr>
<div id="container"></div>
<hr>
Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least 8 matches for the query "The Spirit", 4. result should be ordered by relevance
<script src="../dist/flexsearch.light.js"></script>
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.light.js"></script>
<script src="https://cdn.jsdelivr.net/gh/weixsong/elasticlunr.js@0.9.6/example/elasticlunr.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lunr@2.3.5/lunr.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/kbrsh/wade@0.3.3/dist/wade.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@3.3.0/dist/fuse.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/js-search@1.4.2/dist/umd/js-search.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
<script src="https://gist.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
<script src="../data/movies.js"></script>
<script>
(function(){
var bulksearch;
var flexsearch;
// var flexsearch_cache;
// var flexsearch_worker;
// var flexsearch_cache_scale;
var elasticsearch;
var lunrsearch;
var wade;
var fuse;
var jssearch;
var jsii;
var bm25;
var tests = {
flexsearch: {
init: function(){
flexsearch = new FlexSearch({
encode: "icase",
tokenize: "strict",
threshold: 8,
resolution: 9,
depth: 1,
async: false,
cache: false,
worker: false
});
},
add: function(index, content){
flexsearch.add(index, content);
},
query: function(query){
return flexsearch.search(query);
},
loops: 350000
},
/*
flexsearch_cache_unbound: {
init: function(){
flexsearch_cache = new FlexSearch({
encode: "icase",
tokenize: "strict",
threshold: 9,
depth: 1,
async: false,
cache: true,
worker: false
});
},
add: function(index, content){
flexsearch_cache.add(index, content);
},
query: function(query){
return flexsearch_cache.search(query);
},
loops: 1000000
},
*/
/*
flexsearch_cache_balanced: {
init: function(){
flexsearch_cache_scale = new FlexSearch({
encode: "icase",
tokenize: "strict",
threshold: 9,
depth: 1,
async: false,
cache: 100,
worker: false
});
},
add: function(index, content){
flexsearch_cache_scale.add(index, content);
},
query: function(query){
return flexsearch_cache_scale.search(query);
},
loops: 1000000
},
*/
/*
flexsearch_worker: {
init: function(){
flexsearch_worker = new FlexSearch({
encode: "icase",
tokenize: "strict",
threshold: 9,
depth: 1,
async: true,
cache: false,
worker: 4
});
},
add: function(index, content){
flexsearch_worker.add(index, content);
},
query: async function(query){
return await new Promise(function(resolve){
flexsearch_worker.search(query, resolve);
});
},
loops: 5000
},
*/
bulksearch: {
init: function(){
bulksearch = new BulkSearch({
type: "short",
encode: "icase",
multi: false,
async: false,
cache: false,
worker: false
});
},
add: function(index, content){
bulksearch.add(index, content);
},
query: function(query){
return bulksearch.search(query);
},
loops: 2800
},
elasticlunr: {
init: function(){
elasticsearch = elasticlunr(function(){
this.setRef("id");
this.addField("content");
});
},
add: function(index, content){
elasticsearch.addDoc({id: index, content: content});
},
query: function(query){
return elasticsearch.search(query);
},
loops: 700
},
lunr: {
init: function(){
lunrsearch = lunr(function(){
this.ref("id");
this.field("content");
for(var i = 0; i < data.length; i++){
this.add({id: i, content: data[i]});
}
});
},
add: function(index, content){},
query: function(query){
return lunrsearch.search(query);
},
loops: 2400
},
wade: {
init: function(){
wade = Wade(data.slice(0));
},
sort: function(a, b){
var sum = a.score - b.score;
return sum < 0 ? 1 : sum ? -1 : 0;
},
add: function(index, content){},
query: function(query){
return wade(query).sort(this.sort);
},
loops: 10000
},
fuse: {
init: function(){
var payload = [];
for(var i = 0; i < data.length; i++){
payload[i] = {id: i, content: data[i]};
}
fuse = new Fuse(payload, {
keys: ["content"],
id: "id",
shouldSort: true,
tokenize: true,
matchAllTokens: true,
threshold: 0.2
});
},
add: function(index, content){},
query: function(query){
return fuse.search(query);
},
loops: 1
},
jssearch: {
init: function(){
var payload = [];
for(var i = 0; i < data.length; i++){
payload[i] = {id: i, content: data[i]};
}
jssearch = new JsSearch.Search("id");
jssearch.addIndex("content");
jssearch.addDocuments(payload);
},
add: function(index, content){},
query: function(query){
return jssearch.search(query);
},
loops: 8000
},
jsii: {
init: function(){
var payload = [];
for(var i = 0; i < data.length; i++){
payload[i] = {id: i, text: data[i]};
}
jsii = new JSii();
jsii.feedDocs(payload);
},
add: function(index, content){},
query: function(query){
return jsii.search(query);
},
loops: 100000
},
bm25: {
init: function(){
bm25 = new BM25();
for(var i = 0; i < data.length; i++){
bm25.addDocument({id: i, body: data[i]});
}
bm25.updateIdf();
},
add: function(index, content){},
query: function(query){
return bm25.search(query);
},
loops: 50
}
};
function init_container(target){
var html = "<table>" +
"<tr>" +
"<th>Library&emsp;</th>" +
"<th>Benchmark (Single Phrase)&emsp;</th>" +
"<th>Benchmark (Multi Phrase)&emsp;</th>" +
"<th>Benchmark (Not Found)&emsp;</th>" +
"</tr>";
for(var test in tests){
if(tests.hasOwnProperty(test)){
html += "<tr>" +
"<td>" + test + "</td>" +
"<td id=\"test-" + test + "\">indexing ...</td>" +
"<td id=\"test-multi-" + test + "\"></td>" +
"<td id=\"test-notfound-" + test + "\"></td>" +
"</tr>"
}
}
html += "</table>";
target.innerHTML = html;
}
var is_mobile = navigator.userAgent.match(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/);
function init_tests(index, keys){
var key = keys[index];
var test = tests[key];
test.init();
if(is_mobile && (test.loops > 1)){
test.loops = (test.loops / 5) >> 0;
}
for(var i = 0; i < data.length; i++){
test.add(i, data[i]);
}
document.getElementById("test-" + key).textContent = "ready ...";
if(++index < keys.length){
setTimeout(function(){
init_tests(index, keys);
}, 100);
}
else{
setTimeout(function(){
start_tests(0, 0, keys);
}, 1000);
}
}
function start_tests(suite, index, keys){
var phrase = suite === 0 ? "mermaid" : (suite === 1 ? "little mermaid" : "undefined");
var key = keys[index];
var test = tests[key];
var loops = test.loops;
var query = test.query;
var start = Date.now();
for(var x = 0; x < loops; x++){
query(phrase);
}
var duration = Date.now() - start;
console.log("[Suite " + suite + "] " + key + ":", duration);
document.getElementById("test-" + (suite === 1 ? "multi-" : (suite === 2 ? "notfound-" : "")) + key).textContent = format_number(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
if(++index >= keys.length){
if(++suite < 3){
index = 0;
}
}
if(index < keys.length){
setTimeout(function(){
start_tests(suite, index, keys);
}, 1000);
}
}
init_container(document.getElementById("container"));
setTimeout(function(){
init_tests(0, Object.keys(tests));
}, 100);
function format_number(num){
return ("" + num).replace(/(\d)(?=(\d{3})+\b)/g, '$1,');
}
// ---------------------------------------
//window.tests = tests;
})();
</script>
</body>
</html>

View File

@@ -17,7 +17,6 @@
</head>
<body>
<h2>Benchmark Comparison</h2>
<!--<button id="btn_start" onclick="start();" disabled>Start</button>-->
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
<hr>
<div id="container"></div>
@@ -36,19 +35,16 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
<script src="../data/gulliver.js"></script>
<script>
//var data = [];
(function(){
var bulksearch;
var flexsearch;
// var flexsearch_cache;
// var flexsearch_worker;
// var flexsearch_cache_scale;
var flexsearch_cache;
var flexsearch_worker;
var flexsearch_cache_scale;
var elasticsearch;
var lunrsearch;
var wade;
//var wadesearch;
var fuse;
var jssearch;
var jsii;
@@ -63,7 +59,8 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
flexsearch = new FlexSearch({
encode: "icase",
tokenize: "strict",
threshold: 9,
threshold: 8,
resolution: 9,
depth: 1,
async: false,
cache: false,
@@ -106,9 +103,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
},
loops: 1000000
},
*/
/*
flexsearch_cache_balanced: {
init: function(){
@@ -133,9 +128,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
},
loops: 1000000
},
*/
/*
flexsearch_worker: {
init: function(){
@@ -170,7 +163,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
init: function(){
bulksearch = new BulkSearch({
type: "short", // this type specifies the maximum bitlength of assigned IDs!
type: "short",
encode: "icase",
multi: false,
async: false,
@@ -204,7 +197,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
},
query: function(query){
return elasticsearch.search(query)/*.map(function(val){return val.ref})*/;
return elasticsearch.search(query);
},
loops: 100
},
@@ -224,7 +217,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
add: function(index, content){},
query: function(query){
return lunrsearch.search(query)/*.map(function(val){return val.ref})*/;
return lunrsearch.search(query);
},
loops: 350
},
@@ -243,7 +236,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
add: function(index, content){},
query: function(query){
return wade(query).sort(this.sort)/*.map(function(val){return val.index})*/;
return wade(query).sort(this.sort);
},
loops: 1500
},
@@ -292,7 +285,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
add: function(index, content){},
query: function(query){
return jssearch.search(query)/*.map(function(val){return val.id})*/;
return jssearch.search(query);
},
loops: 800
},
@@ -313,7 +306,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
add: function(index, content){},
query: function(query){
return jsii.search(query)/*.docs.map(function(val){return val.id})*/;
return jsii.search(query);
},
loops: 600
},
@@ -333,7 +326,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
add: function(index, content){},
query: function(query){
return bm25.search(query)/*.map(function(val){return val.id})*/;
return bm25.search(query);
},
loops: 95
}
@@ -398,15 +391,6 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
}
else{
/*
window.start = function(){
start_tests(0, Object.keys(tests));
};
document.getElementById("btn_start").disabled = false;
*/
setTimeout(function(){
start_tests(0, 0, keys);
@@ -480,7 +464,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
// ---------------------------------------
window.tests = tests;
//window.tests = tests;
})();
</script>
</body>

View File

@@ -22,6 +22,7 @@
var env = "min";
</script>
<script src="test.js"></script>
<!--<script src="test.es6.js"></script>-->
<script>
if(window.mochaPhantomJS) {

View File

@@ -28,7 +28,7 @@
<th>matching</th>
<th>scoring</th>
<th>balanced</th>
<th>fastest</th>
<th>fast</th>
</tr>
<tr id="test-1">
<td style="width: 200px">"without breach of modesty"</td>
@@ -175,7 +175,7 @@
var flexsearch_default = new FlexSearch();
var flexsearch_memory = new FlexSearch("memory");
var flexsearch_speed = new FlexSearch("speed");
var flexsearch_fastest = new FlexSearch("fastest");
var flexsearch_fast = new FlexSearch("fast");
var flexsearch_match = new FlexSearch("match");
var flexsearch_score = new FlexSearch("score");
var flexsearch_balance = new FlexSearch("balance");
@@ -242,13 +242,13 @@
// ---------------------------------------
console.time('flexsearch_fastest');
console.time('flexsearch_fast');
for(var i = 0; i < data.length; i++){
flexsearch_fastest.add(i, data[i]);
flexsearch_fast.add(i, data[i]);
}
console.timeEnd('flexsearch_fastest');
console.timeEnd('flexsearch_fast');
// ---------------------------------------
@@ -301,7 +301,7 @@
break;
case 7:
results = flexsearch_fastest.search(query);
results = flexsearch_fast.search(query);
break;
}

View File

@@ -277,7 +277,8 @@
flexsearch = new FlexSearch({
encode: 'extra',
tokenize: 'strict',
threshold: 5,
threshold: 0,
resolution: 9,
depth: 3,
suggest: true
});

View File

@@ -1,416 +1,147 @@
var env = "";
if(typeof module !== "undefined"){
var expect = require("chai").expect;
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
}
module.exports = function(FlexSearch, env){
// ------------------------------------------------------------------------
// Multi-Field Documents
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Multi-Field Documents
// ------------------------------------------------------------------------
describe("Index Multi-Field Documents (ES6)", function(){
if(env === "") describe("Index Multi-Field Documents", function(){
var data = [{
var data = [{
id: 2,
data:{
title: "Title 3",
body: "Body 3"
}
},{
id: 1,
data:{
title: "Title 2",
body: "Body 2"
}
},{
id: 0,
data:{
title: "Title 1",
body: "Body 1"
}
}];
id: 2,
data:{
title: "Title 3",
body: "Body 3"
var update = [{
id: 0,
data:{
title: "Foo 1",
body: "Bar 1"
}
},{
id: 1,
data:{
title: "Foo 2",
body: "Bar 2"
}
},{
id: 2,
data:{
title: "Foo 3",
body: "Bar 3"
}
}];
it("Should have been indexed properly (Async)", async function(){
var index = new FlexSearch({
async: true,
doc: {
id: "id",
field: [
"data:title",
"data:body"
]
}
},{
id: 1,
data:{
title: "Title 2",
body: "Body 2"
}
},{
id: 0,
data:{
title: "Title 1",
body: "Body 1"
}
}];
var update = [{
id: 0,
data:{
title: "Foo 1",
body: "Bar 1"
}
},{
id: 1,
data:{
title: "Foo 2",
body: "Bar 2"
}
},{
id: 2,
data:{
title: "Foo 3",
body: "Bar 3"
}
}];
it("Should have been indexed properly", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: [
"data:title",
"data:body"
]
}
});
index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("title")).to.have.members(data);
expect(index.search({
field: "data:title",
query: "title",
boost: 2
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body",
boost: 2
},{
field: "data:body",
query: "body",
boost: 2
}])).to.have.members(data);
expect(index.search("title", {
field: "data:title",
boost: 2
})).to.have.members(data);
expect(index.search("title", {
field: "data:body",
boost: 2
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title",
boost: 2
},{
field: "data:body",
boost: 2
}])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
index.remove(update);
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
});
it("Should have been boosted properly", function(){
await index.add(data);
var index = new FlexSearch({
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
tokenize: "strict",
depth: 3,
doc: {
id: "id",
field: ["title", "body"]
}
});
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
index.add([{
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
id: 0,
title: "1 2 3 4 5",
body: "1 2 3 4 5"
},{
id: 1,
title: "1 2 3 4 5",
body: "1 2 5 4 3" // <-- body
},{
id: 2,
title: "1 2 5 4 3", // <-- title
body: "1 2 3 4 5"
}]);
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search([{
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
field: "title",
query: "5",
boost: 0.1
},{
field: "body",
query: "5",
boost: 9
await index.update(update);
}])[0].id).to.equal(1);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
expect(index.search([{
await index.remove(update);
field: "title",
query: "5",
boost: 9
},{
field: "body",
query: "5",
boost: 0.1
}])[0].id).to.equal(2);
});
it("Should have been indexed properly (Async)", async function(){
var index = new FlexSearch({
async: true,
doc: {
id: "id",
field: [
"data:title",
"data:body"
]
}
});
await index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
await index.update(update);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
await index.remove(update);
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
});
it("Should have been indexed properly (Worker)", async function(){
var index = new FlexSearch({
worker: 4,
async: true,
doc: {
id: "id",
field: [
"data:title",
"data:body"
]
}
});
await index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
await index.update(update);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
await index.remove(update);
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
});
it("Should have been sorted properly", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: [
"data:title"
]
}
});
index.add(data);
var results = index.search({
field: "data:title",
query: "title"
});
expect(results[0]).to.equal(data[0]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[2]);
results = index.search({
query: "title",
field: "data:title",
sort: function(a, b){
const diff = a.id - b.id;
return (diff < 0 ? -1 : (diff ? 1 : 0));
}
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
results = index.search({
query: "title",
field: "data:title",
sort: "id"
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
results = index.search({
query: "title",
field: "data:title",
sort: "data:title"
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
});
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
});
// ------------------------------------------------------------------------
// Export / Import
// ------------------------------------------------------------------------
it("Should have been indexed properly (Worker)", async function(){
if(env !== "light") describe("Export / Import", function(){
var index = new FlexSearch({
var data;
worker: 4,
async: true,
doc: {
it("Should have been exported properly", function(){
var index = new FlexSearch({
tokenize: "reverse",
doc: {
id: "id",
field: "title"
}
});
index.add({id: 0, title: "foo"});
index.add({id: 1, title: "bar"});
index.add({id: 2, title: "foobar"});
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
data = index.export();
expect(data).to.equal(JSON.stringify([
[
index.doc.index[0]._map,
index.doc.index[0]._ctx,
index.doc.index[0]._ids
],
index._doc
]));
}
else{
data = index.export();
id: "id",
field: [
"data:title",
"data:body"
]
}
});
it("Should have been imported properly", function(){
await index.add(data);
var index = new FlexSearch("score", {
doc: {
id: "id",
field: "title"
}
});
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
index.import(data);
expect(await index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(await index.search({field: "data:title", query: "title"})).to.have.members(data);
if(env === ""){
expect(await index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(await index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.doc.index[0].length).to.equal(3);
}
expect(await index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(await index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search("foo")).to.have.lengthOf(2);
expect(index.search("bar")).to.have.lengthOf(2);
expect(index.search("foobar")).to.have.lengthOf(1);
expect(index.search("foobar")[0].id).to.equal(2);
});
expect(await index.search({query: "body"})).to.have.members(data);
expect(await index.search("title")).to.have.members(data);
await index.update(update);
expect(await index.search("foo")).not.to.have.members(data);
expect(await index.search("bar")).not.to.have.members(data);
expect(await index.search("foo")).to.have.members(update);
expect(await index.search("bar")).to.have.members(update);
await index.remove(update);
expect(await index.doc.index[0].length).to.equal(0);
expect(await index.doc.index[1].length).to.equal(0);
});
};
});

View File

@@ -1,11 +1,5 @@
if(typeof module !== "undefined"){
// Node.js Stub
URL = function(string){};
URL.createObjectURL = function(val){};
Blob = function(string){};
var env = process.argv[3] === "test" ? "min" : process.argv[3] === "test/" ? "light" : "";
var expect = require("chai").expect;
var FlexSearch = require("../" + (env ? "dist/": "") + "flexsearch" + (env ? "." + env : "") + ".js");
@@ -110,6 +104,7 @@ describe("Initialize", function(){
encode: "icase",
tokenize: "reverse",
resolution: 10,
async: false,
worker: false
});
@@ -140,6 +135,17 @@ describe("Initialize", function(){
expect(flexsearch_default).to.be.an.instanceOf(FlexSearch);
expect(flexsearch_sync).to.be.an.instanceOf(FlexSearch);
expect(flexsearch_async).to.be.an.instanceOf(FlexSearch);
it("Should have correct uuids", function(){
expect(flexsearch_default.id).to.equal(0);
expect(flexsearch_sync.id).to.equal(1);
expect(flexsearch_async.id).to.equal(2);
expect(flexsearch_icase.id).to.equal(3);
expect(flexsearch_simple.id).to.equal(4);
expect(flexsearch_advanced.id).to.equal(5);
expect(flexsearch_extra.id).to.equal(6);
});
});
it("Should have all provided methods", function(){
@@ -157,17 +163,6 @@ describe("Initialize", function(){
}
});
it("Should have correct uuids", function(){
expect(flexsearch_default.id).to.equal(0);
expect(flexsearch_sync.id).to.equal(1);
expect(flexsearch_async.id).to.equal(2);
expect(flexsearch_icase.id).to.equal(3);
expect(flexsearch_simple.id).to.equal(4);
expect(flexsearch_advanced.id).to.equal(5);
expect(flexsearch_extra.id).to.equal(6);
});
it("Should have the correct options", function(){
if(env !== "light"){
@@ -1104,7 +1099,7 @@ if(env !== "light") describe("Suggestions", function(){
// Where Clause
// ------------------------------------------------------------------------
if(env === "") describe("Where/Find", function(){
if(env === "" || env === "min") describe("Where/Find", function(){
var data = [{
id: 0,
@@ -1128,8 +1123,7 @@ if(env === "") describe("Where/Find", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: "title",
tag: "cat"
field: ["title"]
}
});
@@ -1175,10 +1169,445 @@ if(env === "") describe("Where/Find", function(){
// Multi-Field Documents
// ------------------------------------------------------------------------
if((typeof require !== "undefined") && !this._phantom){
if(env !== "light") describe("Index Multi-Field Documents", function(){
require("./test.es6.js")(FlexSearch, env);
}
var data = [{
id: 2,
data:{
title: "Title 3",
body: "Body 3"
}
},{
id: 1,
data:{
title: "Title 2",
body: "Body 2"
}
},{
id: 0,
data:{
title: "Title 1",
body: "Body 1"
}
}];
var update = [{
id: 0,
data:{
title: "Foo 1",
body: "Bar 1"
}
},{
id: 1,
data:{
title: "Foo 2",
body: "Bar 2"
}
},{
id: 2,
data:{
title: "Foo 3",
body: "Bar 3"
}
}];
it("Should have been indexed properly", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: [
"data:title",
"data:body"
]
}
});
index.add(data);
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
}
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(index.search({field: "data:title", query: "title"})).to.have.members(data);
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("title")).to.have.members(data);
expect(index.search({
field: "data:title",
query: "title",
boost: 2
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body",
boost: 2
},{
field: "data:body",
query: "body",
boost: 2
}])).to.have.members(data);
expect(index.search("title", {
field: "data:title",
boost: 2
})).to.have.members(data);
expect(index.search("title", {
field: "data:body",
boost: 2
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title",
boost: 2
},{
field: "data:body",
boost: 2
}])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
index.remove(update);
if(env === ""){
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
}
});
it("Should have been indexed properly (custom fields)", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: {
"data:title": {
encode: "advanced",
tokenize: "reverse"
},
"data:body": {
encode: "icase",
tokenize: "strict"
}
}
}
});
index.add(data);
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
}
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(index.search({field: "data:title", query: "tle"})).to.have.members(data);
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "tle"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("tle")).to.have.members(data);
expect(index.search({
field: "data:title",
query: "tle"
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body"
},{
field: "data:body",
query: "body"
}])).to.have.members(data);
expect(index.search("tle", {
field: "data:title"
})).to.have.members(data);
expect(index.search("tle", {
field: "data:body"
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title"
},{
field: "data:body"
}])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
index.remove(update);
if(env === ""){
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
}
});
/*
it("Should have been indexed properly (tag)", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: "data:body",
tag: "data:title"
}
});
index.add(data);
expect(index.doc.index[0].length).to.equal(3);
expect(index.doc.index[1].length).to.equal(3);
expect(index.search({field: "data:body", query: "body"})).to.have.members(data);
expect(index.search({field: "data:title", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "Title 1"})).to.have.members(data[0]);
expect(index.search({field: "data:body", query: "title"})).to.have.lengthOf(0);
expect(index.search({field: "data:title", query: "body"})).to.have.lengthOf(0);
expect(index.search({field: ["data:title", "data:body"], query: "body"})).to.have.members(data);
expect(index.search({field: ["data:body", "data:title"], query: "title"})).to.have.members(data);
expect(index.search({query: "body"})).to.have.members(data);
expect(index.search("title")).to.have.members(data);
expect(index.search({
field: "data:title",
query: "title",
boost: 2
})).to.have.members(data);
expect(index.search([{
field: "data:title",
query: "body",
boost: 2
},{
field: "data:body",
query: "body",
boost: 2
}])).to.have.members(data);
expect(index.search("title", {
field: "data:title",
boost: 2
})).to.have.members(data);
expect(index.search("title", {
field: "data:body",
boost: 2
})).to.have.lengthOf(0);
expect(index.search("body", [{
field: "data:title",
boost: 2
},{
field: "data:body",
boost: 2
}])).to.have.members(data);
index.update(update);
expect(index.search("foo")).not.to.have.members(data);
expect(index.search("bar")).not.to.have.members(data);
expect(index.search("foo")).to.have.members(update);
expect(index.search("bar")).to.have.members(update);
index.remove(update);
expect(index.doc.index[0].length).to.equal(0);
expect(index.doc.index[1].length).to.equal(0);
});
*/
/*
it("Should have been boosted properly", function(){
var index = new FlexSearch({
tokenize: "strict",
depth: 3,
doc: {
id: "id",
field: ["title", "body"]
}
});
index.add([{
id: 0,
title: "1 2 3 4 5",
body: "1 2 3 4 5"
},{
id: 1,
title: "1 2 3 4 5",
body: "1 2 5 4 3" // <-- body
},{
id: 2,
title: "1 2 5 4 3", // <-- title
body: "1 2 3 4 5"
}]);
expect(index.search([{
field: "title",
query: "5",
boost: 0.1
},{
field: "body",
query: "5",
boost: 9
}])[0].id).to.equal(1);
expect(index.search([{
field: "title",
query: "5",
boost: 9
},{
field: "body",
query: "5",
boost: 0.1
}])[0].id).to.equal(2);
});
*/
it("Should have been sorted properly", function(){
var index = new FlexSearch({
doc: {
id: "id",
field: "data:title"
}
});
index.add(data);
var results = index.search({
field: "data:title",
query: "title"
});
expect(results[0]).to.equal(data[0]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[2]);
results = index.search({
query: "title",
field: "data:title",
sort: function(a, b){
const diff = a.id - b.id;
return (diff < 0 ? -1 : (diff ? 1 : 0));
}
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
results = index.search({
query: "title",
field: "data:title",
sort: "id"
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
results = index.search({
query: "title",
field: "data:title",
sort: "data:title"
});
expect(results[0]).to.equal(data[2]);
expect(results[1]).to.equal(data[1]);
expect(results[2]).to.equal(data[0]);
});
if(env === "" && (typeof require !== "undefined") && !this._phantom){
require("./test.es6.js");
}
});
// ------------------------------------------------------------------------
// Export / Import
@@ -1202,12 +1631,11 @@ if(env !== "light") describe("Export / Import", function(){
index.add({id: 1, title: "bar"});
index.add({id: 2, title: "foobar"});
data = index.export();
if(env === ""){
expect(index.doc.index[0].length).to.equal(3);
data = index.export();
expect(data).to.equal(JSON.stringify([
[
index.doc.index[0]._map,
@@ -1217,10 +1645,6 @@ if(env !== "light") describe("Export / Import", function(){
index._doc
]));
}
else{
data = index.export();
}
});
it("Should have been imported properly", function(){