/**! * FlexSearch.js v0.8.214 (Light) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH * https://github.com/nextapps-de/flexsearch */ (function(self){'use strict';var r;function v(a,c,b){const f=typeof b,d=typeof a;if(f!=="undefined"){if(d!=="undefined"){if(b){if(d==="function"&&f===d)return function(k){return a(b(k))};c=a.constructor;if(c===b.constructor){if(c===Array)return b.concat(a);if(c===Map){var h=new Map(b);for(var e of a)h.set(e[0],e[1]);return h}if(c===Set){e=new Set(b);for(h of a.values())e.add(h);return e}}}return a}return b}return d==="undefined"?c:a}function z(){return Object.create(null)};const A=/[^\p{L}\p{N}]+/u,B=/(\d{3})/g,C=/(\D)(\d{3})/g,D=/(\d{3})(\D)/g,E=/[\u0300-\u036f]/g;function F(a={}){if(!this||this.constructor!==F)return new F(...arguments);if(arguments.length)for(a=0;a1)return this.addMatcher(a,c);this.mapper||(this.mapper=new Map);this.mapper.set(a,c);this.cache&&G(this);return this};r.addMatcher=function(a,c){if(typeof a==="object")return this.addReplacer(a,c);if(a.length<2&&(this.dedupe||this.mapper))return this.addMapper(a,c);this.matcher||(this.matcher=new Map);this.matcher.set(a,c);this.g+=(this.g?"|":"")+a;this.s=null;this.cache&&G(this);return this}; r.addReplacer=function(a,c){if(typeof a==="string")return this.addMatcher(a,c);this.replacer||(this.replacer=[]);this.replacer.push(a,c);this.cache&&G(this);return this}; r.encode=function(a,c){if(this.cache&&a.length<=this.m)if(this.l){if(this.i.has(a))return this.i.get(a)}else this.l=setTimeout(G,50,this);this.normalize&&(typeof this.normalize==="function"?a=this.normalize(a):a=E?a.normalize("NFKD").replace(E,"").toLowerCase():a.toLowerCase());this.prepare&&(a=this.prepare(a));this.numeric&&a.length>3&&(a=a.replace(C,"$1 $2").replace(D,"$1 $2").replace(B,"$1 "));const b=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let f=[], d=z(),h,e,k=this.split||this.split===""?a.split(this.split):[a];for(let n=0,g,t;nthis.maxlength)){if(c){if(d[g])continue;d[g]=1}else{if(h===g)continue;h=g}if(b)f.push(g);else if(!this.filter||(typeof this.filter==="function"?this.filter(g):!this.filter.has(g))){if(this.cache&&g.length<=this.o)if(this.l){var l=this.j.get(g);if(l||l===""){l&&f.push(l);continue}}else this.l=setTimeout(G,50,this);if(this.stemmer){this.u||(this.u=new RegExp("(?!^)("+ this.h+")$"));let w;for(;w!==g&&g.length>2;)w=g,g=g.replace(this.u,q=>this.stemmer.get(q))}if(g&&(this.mapper||this.dedupe&&g.length>1)){l="";for(let w=0,q="",m,p;w1&&(this.s||(this.s=new RegExp("("+this.g+")","g")),g=g.replace(this.s,w=>this.matcher.get(w)));if(g&&this.replacer)for(l=0;g&&lthis.A&&(this.j.clear(),this.o=this.o/1.1|0));if(g){if(g!==t)if(c){if(d[g])continue;d[g]=1}else{if(e===g)continue;e=g}f.push(g)}}}this.finalize&&(f=this.finalize(f)||f);this.cache&&a.length<=this.m&&(this.i.set(a,f),this.i.size>this.A&&(this.i.clear(),this.m=this.m/1.1|0));return f};function G(a){a.l=null;a.i.clear();a.j.clear()};function H(a,c,b){if(!a.length)return a;if(a.length===1)return a=a[0],a=b||a.length>c?a.slice(b,b+c):a;let f=[];for(let d=0,h,e;d=e){b-=e;continue}h=h.slice(b,b+c);e=h.length;b=0}e>c&&(h=h.slice(0,c),e=c);if(!f.length&&e>=c)return h;f.push(h);c-=e;if(!c)break}return f=f.length>1?[].concat.apply([],f):f[0]};z();J.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let f=0,d,h;f=0&&d.splice(e,1)}}else K(this.map,a),this.depth&&K(this.ctx,a);c||this.reg.delete(a)}return this}; function K(a,c){let b=0;var f=typeof c==="undefined";if(a.constructor===Array)for(let d=0,h,e,k;d=0){if(h.length>1)return h.splice(e,1),1;delete a[d];if(b)return 1;k=1}else{if(k)return 1;b++}}}else for(let d of a.entries())f=d[0],K(d[1],c)?b++:a.delete(f);return b};const L={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"full"},score:{resolution:9,context:{depth:2,resolution:3}}};J.prototype.add=function(a,c,b,f){if(c&&(a||a===0)){if(!f&&!b&&this.reg.has(a))return this.update(a,c);f=this.depth;c=this.encoder.encode(c,!f);const n=c.length;if(n){const g=z(),t=z(),w=this.resolution;for(let q=0;q2){for(let p=1,u,y,x,I;p2){for(let p=0,u;pp;h--){e=m.substring(p,h);u=this.rtl?d-1-p:p;var k=this.score?this.score(c,m,q,e,u):M(w,n,q,d,u);N(this,t,e,k,a,b)}break}case "bidirectional":case "reverse":if(d>1){for(k=d-1;k>0;k--){e=m[this.rtl?d-1-k:k]+e;var l=this.score?this.score(c,m,q,e,k):M(w,n,q,d,k);N(this,t,e,l,a,b)}e=""}case "forward":if(d>1){for(k=0;k1&&qe;const p=this.score?this.score(c,e,q,m,k-1):M(d+(n/2>d?0:1),n,q,h-1,k-1);N(this,g,l?e:m,p,a,b,l?m:e)}}}}this.fastupdate||this.reg.add(a)}}return this}; function N(a,c,b,f,d,h,e){let k,l;if(!(k=c[b])||e&&!k[e]){e?(c=k||(c[b]=z()),c[e]=1,l=a.ctx,(k=l.get(e))?l=k:l.set(e,l=new Map)):(l=a.map,c[b]=1);(k=l.get(b))?l=k:l.set(b,l=k=[]);if(h)for(let n=0,g;n1?c+(f||0)<=a?b+(d||0):(a-1)/(c+(f||0))*(b+(d||0))+1|0:0};J.prototype.search=function(a,c,b){b||(c||typeof a!=="object"?typeof c==="object"&&(b=c,c=0):(b=a,a=""));var f=[],d=0;if(b){a=b.query||a;c=b.limit||c;d=b.offset||0;var h=b.context;var e=b.suggest;var k=!0;var l=b.resolution}typeof k==="undefined"&&(k=!0);h=this.depth&&h!==!1;a=this.encoder.encode(a,!h);b=a.length;c=c||(k?100:0);if(b===1)return e=d,(d=O(this,a[0],""))&&d.length?H.call(this,d,c,e):[];if(b===2&&h&&!e)return e=d,(d=O(this,a[1],a[0]))&&d.length?H.call(this,d,c,e):[];k=z();var n=0;if(h){var g= a[0];n=1}l||l===0||(l=g?this.v:this.resolution);for(let m,p;n1)b:{f=e;g=a.length;e=[];b=z();for(let m=0,p,u,y,x;m1)c:for(a=[],l=z(),f=e.length,k=f-1;k>=0;k--){if(b=(f=e[k])&&f.length)for(n=0;nc||d?e.slice(d,c+d):e;e=a}else{if(ac||d)e=e.slice(d,c+d)}g=e}else if(f=== 1){c=H.call(null,a[0],c,d);break a}c=g}return c};function O(a,c,b){let f;b&&(f=a.bidirectional&&c>b)&&(f=b,b=c,c=f);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};function J(a,c){if(!this||this.constructor!==J)return new J(a);if(a){var b=typeof a==="string"?a:a.preset;b&&(a=Object.assign({},L[b],a))}else a={};b=a.context;const f=b===!0?{depth:1}:b||{},d=a.encode||a.encoder||{};this.encoder=d.encode?d:typeof d==="object"?new F(d):{encode:d};this.resolution=a.resolution||9;this.tokenize=b=(b=a.tokenize)&&b!=="default"&&b!=="exact"&&b||"strict";this.depth=b==="strict"&&f.depth||0;this.bidirectional=f.bidirectional!==!1;this.fastupdate=!!a.fastupdate;this.score= a.score||null;this.map=new Map;this.ctx=new Map;this.reg=c||(this.fastupdate?new Map:new Set);this.v=f.resolution||3;this.rtl=d.rtl||a.rtl||!1}r=J.prototype;r.clear=function(){this.map.clear();this.ctx.clear();this.reg.clear();return this};r.append=function(a,c){return this.add(a,c,!0)};r.contain=function(a){return this.reg.has(a)};r.update=function(a,c){const b=this,f=this.remove(a);return f&&f.then?f.then(()=>b.add(a,c)):this.add(a,c)}; r.cleanup=function(){if(!this.fastupdate)return this;K(this.map);this.depth&&K(this.ctx);return this};z();const P={Index:J,Charset:null,Encoder:F,Document:null,Worker:null,Resolver:null,IndexedDB:null,Language:{}},Q=typeof self!=="undefined"?self:typeof global!=="undefined"?global:self;let R;(R=Q.define)&&R.amd?R([],function(){return P}):typeof Q.exports==="object"?Q.exports=P:Q.FlexSearch=P;}(this||self));