9 lines
19 KiB
JavaScript
Raw Permalink Normal View History

2026-05-31 13:21:13 +02:00
/**
* Fuse.js v7.4.0 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2026 Kiro Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
"use strict";function e(e){return Array.isArray?Array.isArray(e):"[object Array]"===u(e)}function t(e){return null==e?"":function(e){if("string"==typeof e)return e;if("bigint"==typeof e)return e.toString();const t=e+"";return"0"==t&&1/e==-1/0?"-0":t}(e)}function s(e){return"string"==typeof e}function n(e){return"number"==typeof e}function i(e){return!0===e||!1===e||function(e){return function(e){return"object"==typeof e}(e)&&null!==e}(e)&&"[object Boolean]"==u(e)}function r(e){return null!=e}function o(e){return!e.trim().length}function u(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const c="Invalid doc index: must be a non-negative integer within the bounds of the docs array",h=Object.prototype.hasOwnProperty;class a{constructor(e){this._keys=[],this._keyMap={};let t=0;e.forEach(e=>{const s=l(e);this._keys.push(s),this._keyMap[s.id]=s,t+=s.weight}),this._keys.forEach(e=>{e.weight/=t})}get(e){return this._keyMap[e]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function l(t){let n=null,i=null,r=null,o=1,u=null;if(s(t)||e(t))r=t,n=d(t),i=f(t);else{if(!h.call(t,"name"))throw new Error((e=>`Missing ${e} property in key`)("name"));const e=t.name;if(r=e,h.call(t,"weight")&&void 0!==t.weight&&(o=t.weight,o<=0))throw new Error((e=>`Property 'weight' in key '${e}' must be a positive integer`)(f(e)));n=d(e),i=f(e),u=t.getFn??null}return{path:n,id:i,weight:o,src:r,getFn:u}}function d(t){return e(t)?t:t.split(".")}function f(t){return e(t)?t.join("."):t}const g={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:function(o,u){const c=[];let h=!1;const a=(o,u,l,d)=>{if(r(o))if(u[l]){const f=o[u[l]];if(!r(f))return;if(l===u.length-1&&(s(f)||n(f)||i(f)||"bigint"==typeof f))c.push(void 0!==d?{v:t(f),i:d}:t(f));else if(e(f)){h=!0;for(let e=0,t=f.length;e<t;e+=1)a(f[e],u,l+1,e)}else u.length&&a(f,u,l+1,d)}else c.push(void 0!==d?{v:o,i:d}:o)};return a(o,s(u)?u.split("."):u,0),h?c:c[0]},ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},A=Object.freeze({isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(e,t)=>e.score===t.score?e.idx<t.idx?-1:1:e.score<t.score?-1:1,includeMatches:!1,findAllMatches:!1,minMatchCharLength:1,location:0,threshold:.6,distance:100,...g});class m{constructor({getFn:e=A.getFn,fieldNormWeight:t=A.fieldNormWeight}={}){this.norm=function(e=1,t=3){const s=new Map,n=Math.pow(10,t);return{get(t){let i=1,r=!1;for(let e=0;e<t.length;e++)32===t.charCodeAt(e)?r||(i++,r=!0):r=!1;if(s.has(i))return s.get(i);const o=Math.round(n/Math.pow(i,.5*e))/n;return s.set(i,o),o},clear(){s.clear()}}}(t,3),this.getFn=e,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(e=[]){this.docs=e}setIndexRecords(e=[]){this.records=e}setKeys(e=[]){this.keys=e,this._keysMap={},e.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;const e=this.docs.length;this.records=new Array(e);let t=0;if(s(this.docs[0]))for(let s=0;s<e;s++){const e=this._createStringRecord(this.docs[s],s);e&&(this.records[t++]=e)}else for(let s=0;s<e;s++)this.records[t++]=this._createObjectRecord(this.docs[s],s);this.records.length=t,this.norm.clear()}add(e,t){if(!Number.isInteger(t)||t<0)throw new Error(c);if(s(e)){const s=this._createStringRecord(e,t);return s&&this.records.push(s),s}const n=this._createObjectRecord(e,t);return this.records.push(n),n}removeAt(e){if(!Number.isInteger(e)||e<0)throw new Error(c);for(let t=0,s=this.records.length;t<s;t+=1)if(this.records[t].i===e){this.records.splice(t,1);break}for(let t=0,s=this.records.length;t<s;t+=1)this.records[t].i>e&&(this.records[t].i-=1)}removeAll(e){const t=new Set;for(const s of e)Number.isInteger(s)&&s>=0&&t.add(s);if(0===t.size)return;this.records=this.records.filter(e=>!t.has(e.i));const s=Array.from(t).sort((e,t)=>e-t);for(const e of this.records){let t=0,n=s.length;for(;t<n;){const i=t+n>>>1;s[i]<e.i?t=i+1:n=i}e.i-=t}}getValueForItemAtKeyId(e,t){return e[this._keysMap[t]]}size