PageSourceSearch

https://recordranks.com/assets/orama-static-D_Z_b5fv.js

js recordranks.com collected 2026-10-04 11:53:59 UTC 72,123 bytes, 11 lines download raw bytes

1import{g as Nt,B as Tt}from"./index-D-laPAJv.js";import{c as Xe}from"./index-eoKCeKTu.js";import{r as Ze}from"./remove-undefined-CzMSKybq-D-34gD0A.js";import"./search-default-Bi_Y6Tpp.js";import"./index-C79FYMij.js";const Ae="fulltext",At="hybrid",Ot="vector",re="__vector",Qe={arabic:"ar",armenian:"hy",bulgarian:"bg",czech:"cs",danish:"da",dutch:"nl",english:"en",finnish:"fi",french:"fr",german:"de",greek:"el",hungarian:"hu",indian:"hi",indonesian:"id",irish:"ga",italian:"it",lithuanian:"lt",nepali:"ne",norwegian:"no",portuguese:"pt",romanian:"ro",russian:"ru",serbian:"sr",slovenian:"sl",spanish:"es",swedish:"sv",tamil:"ta",turkish:"tr",ukrainian:"uk",vietnamese:"vi",sanskrit:"sa"},le="multilingual",Dt={dutch:/[^A-Za-zàèéìòóù0-9_'-]+/gim,english:/[^A-Za-zàèéìòóù0-9_'-]+/gim,french:/[^a-z0-9äâàéèëêïîöôùüûœç-]+/gim,italian:/[^A-Za-zàèéìòóù0-9_'-]+/gim,norwegian:/[^a-z0-9_æøåÆØÅäÄöÖüÜ]+/gim,portuguese:/[^a-z0-9à-úÀ-Ú]/gim,russian:/[^a-z0-9а-яА-ЯёЁ]+/gim,spanish:/[^a-z0-9A-Zá-úÁ-ÚñÑüÜ]+/gim,swedish:/[^a-z0-9_åÅäÄöÖüÜ-]+/gim,german:/[^a-z0-9A-ZäöüÄÖÜß]+/gim,finnish:/[^a-z0-9äöÄÖ]+/gim,danish:/[^a-z0-9æøåÆØÅ]+/gim,hungarian:/[^a-z0-9áéíóöőúüűÁÉÍÓÖŐÚÜŰ]+/gim,romanian:/[^a-z0-9ăâîșțĂÂÎȘȚ]+/gim,serbian:/[^a-z0-9čćžšđČĆŽŠĐ]+/gim,turkish:/[^a-z0-9çÇğĞıİöÖşŞüÜ]+/gim,lithuanian:/[^a-z0-9ąčęėįšųūžĄČĘĖĮŠŲŪŽ]+/gim,arabic:/[^a-z0-9ء-ي]+/gim,nepali:/[^a-z0-9अ-ह]+/gim,irish:/[^a-z0-9áéíóúÁÉÍÓÚ]+/gim,indian:/[^a-z0-9अ-ह]+/gim,armenian:/[^a-z0-9ա-ֆ]+/gim,greek:/[^a-z0-9α-ωά-ώ]+/gim,indonesian:/[^a-z0-9]+/gim,ukrainian:/[^a-z0-9а-яА-ЯіїєІЇЄ]+/gim,slovenian:/[^a-z0-9螚ȎŠ]+/gim,bulgarian:/[^a-z0-9а-яА-Я]+/gim,tamil:/[^a-z0-9அ-ஹ]+/gim,sanskrit:/[^a-z0-9A-Zāīūṛḷṃṁḥśṣṭḍṇṅñḻḹṝ]+/gim,vietnamese:/[^a-z0-9A-ZáàảãạăắằẳẵặâấầẩẫậéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵđÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴĐ_]+/gim,czech:/[^A-Z0-9a-zěščřžýáíéúůóťďĚŠČŘŽÝÁÍÉÓÚŮŤĎ-]+/gim},ue=Object.keys(Qe);function Pt(t){return t!==void 0&&ue.includes(t)?Qe[t]:void 0}const Et=new Set(["vietnamese"]),Rt=Date.now().toString().slice(5);let _t=0;const Oe=BigInt(1e3),De=BigInt(1e6),Pe=BigInt(1e9);function se(){return globalThis.process}const ee=65535;function et(t,e){if(e.length<ee)Array.prototype.push.apply(t,e);else{const n=e.length;for(let o=0;o<n;o+=ee)Array.prototype.push.apply(t,e.slice(o,o+ee))}}function vt(t,...e){return t.replace(/%(?:(?<position>\d+)\$)?(?<width>-?\d*\.?\d*)(?<type>[dfs])/g,function(...n){const o=n[n.length-1],{width:r,type:s,position:c}=o,i=c?e[Number.parseInt(c)-1]:e.shift(),a=r===""?0:Number.parseInt(r);switch(s){case"d":return i.toString().padStart(a,"0");case"f":{let l=i;const[u,d]=r.split(".").map(f=>Number.parseFloat(f));return typeof d=="number"&&d>=0&&(l=l.toFixed(d)),typeof u=="number"&&u>=0?l.toString().padStart(a,"0"):l.toString()}case"s":return a<0?i.toString().padEnd(-a," "):i.toString().padStart(a," ");default:return i}})}function Lt(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function kt(){return se()?.release?.name==="node"}function Ee(){return BigInt(Math.floor(performance.now()*1e6))}function fe(t){return typeof t=="number"&&(t=BigInt(t)),t<Oe?`${t}ns`:t<De?`${t/Oe}μs`:t<Pe?`${t/De}ms`:`${t/Pe}s`}function x(){if(Lt())return Ee();if(kt()){const e=se();if(e?.hrtime?.bigint)return e.hrtime.bigint()}const t=se();return typeof t?.hrtime?.bigint=="function"?t.hrtime.bigint():typeof performance<"u"?Ee():BigInt(0)}function tt(){return`${Rt}-${_t++}`}function de(t,e){return e[1]===t[1]?t[0]-e[0]:e[1]-t[1]}function Mt(t){if(t.length===0)return[];if(t.length===1)return t[0];for(let n=1;n<t.length;n++)if(t[n].length<t[0].length){const o=t[0];t[0]=t[n],t[n]=o}const e=new Map;for(const n of t[0])e.set(n,1);for(let n=1;n<t.length;n++){let o=0;for(const r of t[n]){const s=e.get(r);s===n&&(e.set(r,s+1),o++)}if(o===0)return[]}return t[0].filter(n=>{const o=e.get(n);return o!==void 0&&e.set(n,0),o===t.length})}function nt(t,e){const n={},o=e.length;for(let r=0;r<o;
1r++){const s=e[r],c=s.split(".");let i=t;const a=c.length;for(let l=0;l<a;l++)if(i=i[c[l]],typeof i=="object"){if(i!==null&&"lat"in i&&"lon"in i&&typeof i.lat=="number"&&typeof i.lon=="number"){i=n[s]=i;break}else if(!Array.isArray(i)&&i!==null&&l===a-1){i=void 0;break}}else if((i===null||typeof i!="object")&&l<a-1){i=void 0;break}typeof i<"u"&&(n[s]=i)}return n}function ot(t,e){return nt(t,[e])[e]}const xt={cm:.01,m:1,km:1e3,ft:.3048,yd:.9144,mi:1609.344};function rt(t,e){const n=xt[e];if(n===void 0)throw new Error(N("INVALID_DISTANCE_SUFFIX",t).message);return t*n}function he(t,e){for(const n of t.hits){const o=n.document;for(const r of e){const s=r.split("."),c=s.pop();let i=o;for(const a of s){if(i==null)break;i[a]=i[a]??{},i=i[a]}i!=null&&(i[c]=null)}}}function J(t){return Array.isArray(t)?t.some(e=>J(e)):t?.constructor?.name==="AsyncFunction"}const Re="intersection"in new Set;function ie(...t){if(t.length===0)return new Set;if(t.length===1)return t[0];if(t.length===2){const o=t[0],r=t[1];if(Re)return o.intersection(r);const s=new Set,c=o.size<r.size?o:r,i=c===o?r:o;for(const a of c)i.has(a)&&s.add(a);return s}const e={index:0,size:t[0].size};for(let o=1;o<t.length;o++)t[o].size<e.size&&(e.index=o,e.size=t[o].size);if(Re){let o=t[e.index];for(let r=0;r<t.length;r++)r!==e.index&&(o=o.intersection(t[r]));return o}const n=t[e.index];for(let o=0;o<t.length;o++){if(o===e.index)continue;const r=t[o];for(const s of n)r.has(s)||n.delete(s)}return n}const Ct="union"in new Set;function W(t,e){return Ct?t?t.union(e):e:t?new Set([...t,...e]):new Set(e)}function Ut(t,e){const n=new Set;for(const o of t)e.has(o)||n.add(o);return n}const Ft=[...ue,le].join(`
2 - `),Vt={NO_LANGUAGE_WITH_CUSTOM_TOKENIZER:"Do not pass the language option to create when using a custom tokenizer.",LANGUAGE_NOT_SUPPORTED:`Language "%s" is not supported.
3Supported languages are:
4 - ${Ft}`,INVALID_STEMMER_FUNCTION_TYPE:"config.stemmer property must be a function.",MISSING_STEMMER:'As of version 1.0.0 zbsearch does not ship non English stemmers by default. To solve this, please explicitly import and specify the "%s" stemmer from the package @zbsearch/stemmers. See https://docs.zbsearch.com/docs/zbsearch-js/text-analysis/stemming for more information.',CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY:"Custom stop words array must only contain strings.",UNSUPPORTED_COMPONENT:'Unsupported component "%s".',COMPONENT_MUST_BE_FUNCTION:'The component "%s" must be a function.',COMPONENT_MUST_BE_FUNCTION_OR_ARRAY_FUNCTIONS:'The component "%s" must be a function or an array of functions.',INVALID_SCHEMA_TYPE:'Unsupported schema type "%s" at "%s". Expected "string", "boolean" or "number" or array of them.',DOCUMENT_ID_MUST_BE_STRING:'Document id must be of type "string". Got "%s" instead.',DOCUMENT_ALREADY_EXISTS:'A document with id "%s" already exists.',DOCUMENT_DOES_NOT_EXIST:'A document with id "%s" does not exists.',MISSING_DOCUMENT_PROPERTY:'Missing searchable property "%s".',INVALID_DOCUMENT_PROPERTY:'Invalid document property "%s": expected "%s", got "%s"',UNKNOWN_INDEX:'Invalid property name "%s". Expected a wildcard string ("*") or array containing one of the following properties: %s',INVALID_BOOST_VALUE:"Boost value must be a number greater than, or less than 0.",INVALID_FILTER_OPERATION:"You can only use one operation per filter, you requested %d.",SCHEMA_VALIDATION_FAILURE:'Cannot insert document due schema validation failure on "%s" property.',INVALID_SORT_SCHEMA_TYPE:'Unsupported sort schema type "%s" at "%s". Expected "string" or "number".',CANNOT_SORT_BY_ARRAY:'Cannot configure sort for "%s" because it is an array (%s).',UNABLE_TO_SORT_ON_UNKNOWN_FIELD:'Unable to sort on unknown field "%s". Allowed fields: %s',SORT_DISABLED:"Sort is disabled. Please read the documentation at https://docs.zbsearch.com/docs/zbsearch-js for more information.",UNKNOWN_GROUP_BY_PROPERTY:'Unknown groupBy property "%s".',INVALID_GROUP_BY_PROPERTY:'Invalid groupBy property "%s". Allowed types: "%s", but given "%s".',UNKNOWN_FILTER_PROPERTY:'Unknown filter property "%s".',UNKNOWN_VECTOR_PROPERTY:'Unknown vector property "%s". Make sure the property exists in the schema and is configured as a vector.',INVALID_VECTOR_SIZE:'Vector size must be a number greater than 0. Got "%s" instead.',INVA
4LID_VECTOR_VALUE:'Vector value must be a number greater than 0. Got "%s" instead.',INVALID_INPUT_VECTOR:`Property "%s" was declared as a %s-dimensional vector, but got a %s-dimensional vector instead.
5Input vectors must be of the size declared in the schema, as calculating similarity between vectors of different sizes can lead to unexpected results.`,WRONG_SEARCH_PROPERTY_TYPE:'Property "%s" is not searchable. Only "string" properties are searchable.',FACET_NOT_SUPPORTED:`Facet doens't support the type "%s".`,INVALID_DISTANCE_SUFFIX:'Invalid distance suffix "%s". Valid suffixes are: cm, m, km, mi, yd, ft.',INVALID_SEARCH_MODE:'Invalid search mode "%s". Valid modes are: "fulltext", "vector", "hybrid".',MISSING_VECTOR_AND_SECURE_PROXY:"No vector was provided and no secure proxy was configured. Please provide a vector or configure an ZBSearch Secure Proxy to perform hybrid search.",MISSING_TERM:'"term" is a required parameter when performing hybrid search. Please provide a search term.',INVALID_VECTOR_INPUT:'Invalid "vector" property. Expected an object with "value" and "property" properties, but got "%s" instead.',PLUGIN_CRASHED:"A plugin crashed during initialization. Please check the error message for more information:",PLUGIN_SECURE_PROXY_NOT_FOUND:`Could not find '@zbsearch/secure-proxy-plugin' installed in your ZBSearch instance.
6Please install it before proceeding with creating an answer session.
7Read more at https://docs.zbsearch.com/docs/zbsearch-js/plugins/plugin-secure-proxy#plugin-secure-proxy
8`,PLUGIN_SECURE_PROXY_MISSING_CHAT_MODEL:`Could not find a chat model defined in the secure proxy plugin configuration.
9Please provide a chat model before proceeding with creating an answer session.
10Read more at https://docs.zbsearch.com/docs/zbsearch-js/plugins/plugin-secure-proxy#plugin-secure-proxy
11`,ANSWER_SESSION_LAST_MESSAGE_IS_NOT_ASSISTANT:"The last message in the session is not an assistant message. Cannot regenerate non-assistant messages.",PLUGIN_COMPONENT_CONFLICT:'The component "%s" is already defined. The plugin "%s" is trying to redefine it.',IVF_INDEX_REQUIRES_FACTORY:'Vector index "%s" was serialized as IVF. Import ivf from "zbsearch/trees/vector-ivf" and pass indexes.%s at create().',RESERVED_SCHEMA_PROPERTY:'"%s" is a reserved property name and cannot be used in the schema.'};function N(t,...e){const n=new Error(vt(Vt[t]??`Unsupported ZBSearch Error code: ${t}`,...e));n.code=t;const o=Error;return typeof o.captureStackTrace=="function"&&o.captureStackTrace(n),n}function Bt(t){return{raw:Number(t),formatted:fe(t)}}function Wt(t){if(t.id){if(typeof t.id!="string")throw N("DOCUMENT_ID_MUST_BE_STRING",typeof t.id);return t.id}return tt()}function st(t,e=""){for(const[n,o]of Object.entries(t)){if(n===re)throw N("RESERVED_SCHEMA_PROPERTY",`${e}${n}`);typeof o=="object"&&o!==null&&!Array.isArray(o)&&st(o,`${e}${n}.`)}}function it(t,e){for(const[n,o]of Object.entries(e)){const r=t[n];if(!(typeof r>"u")&&!(o==="geopoint"&&typeof r=="object"&&typeof r.lon=="number"&&typeof r.lat=="number")&&!(o==="enum"&&(typeof r=="string"||typeof r=="number"))){if(o==="enum[]"&&Array.isArray(r)){const s=r.length;for(let c=0;c<s;c++)if(typeof r[c]!="string"&&typeof r[c]!="number")return n+"."+c;continue}if(F(o)){const s=at(o);if(!Array.isArray(r)||r.length!==s)throw N("INVALID_INPUT_VECTOR",n,s,r.length);continue}if(pe(o)){if(!Array.isArray(r))return n;const s=ct(o),c=r.length;for(let i=0;i<c;i++)if(typeof r[i]!==s)return n+"."+i;continue}if(typeof o=="object"){if(!r||typeof r!="object")return n;const s=it(r,o);if(s)return n+"."+s;continue}if(typeof r!==o)return n}}}const $t={string:!1,number:!1,boolean:!1,enum:!1,geopoint:!1,"string[]":!0,"number[]":!0,"boolean[]":!0,"enum[]":!0},Gt={"string[]":"string","number[]":"number","boolean[]":"boolean","enum[]":"enum"};function F(t){return typeof t=="string"&&/^vector\[\d+\]$/.test(t)}function pe(t){return typeof t=="string"&&$t[t]}function ct(t){return Gt[t]}function at(t){const e=Number(t.slice(7,-1));switch(!0){case isNaN(e):throw N("INVALID_VECTOR_VALUE",t);case e<=0:throw N("INVALID_VECTOR_SIZE",t);default:return e}}function jt(){return{idToInternalId:new Map,internalIdToId:[],save:Yt,load:Ht}}function Yt(t){return{internalIdToId:t.internalIdToId}}function Ht(t,e){const{internalIdToId:n}=e;t.internalDocumentIDStore.idToInternalId.clear(),t.internalDocumentIDStore.internalIdToId=[];const o=n.length;for(let r=0;r<o;r++){const s=n[r];t.internalDocumentIDStore.idToInternalId.set(s,r+1),t.internalDocumentIDStore.internalIdToId.push(s)}}function E(t,e){if(typeof e=="string"){const n=t.idToInternalId.get(e);if(n)return n;const o=t.idToInternalId.size+1;return t.idToInternalId.set(e,o),t.internalIdToId.push(e),o}return e>t.internalIdToId.length?E(t,e.toString()):e}function ge(t,e){if(t.internalIdToId.length<e)throw new Error(`Invalid internalId ${e}`);return t.internalIdToId[e-1]}function Jt(t,e){return{sharedInternalDocumentStore:e,docs:{},count:0}}function zt(t,e){const n=E(t.sharedInternalDocumentStore,e);return t.docs[n]}function Kt(t,e){const n=e.length,o=Array.from({length:n});for(let r=0;r<n;r++){const s=E(t.sharedInternalDocumentStore,e[r]);o[r]=t.docs[s]}return o}function qt(t){return t.docs}function Xt(t,e,n,o){return typeof t.docs[n]<"u"?!1:(t.docs[n]=o,t.count++,!0)}function Zt(t,e){const n=E(t.sharedInternalDocumentStore,e);return typeof t.docs[n]>"u"?!1:(delete t.docs[n],t.count--,!0)}function Qt(t){return t.count}function en(t,e){const n=e;return{docs:n.docs,count:n.count,sharedInternalDocumentStore:t}}function tn(t){return{docs:t.docs,count:t.count}}function nn(){return{create:Jt,get:zt,getMultiple:Kt,getAll:qt,store:Xt,remove:Zt,count:Qt,load:en,save:tn}}const on=["beforeInsert","afterInsert","beforeRemove","afterRemove","beforeUpdate","afterUpdate","beforeUpsert","afterUpsert","beforeSearch","afterSearch","beforeInsertMultiple","afterInsertMultiple","beforeRemoveMultiple","afterRemoveMultiple","beforeUpdateMultiple","afterUpdateMultiple","beforeUpsertMultiple","afterUpsertMultiple","beforeLoad","afterLoad","afterCreate"];function rn(t,e){const n=[],o=t.plugins?.length;if(!o)return n;for(let r=0;r<o;r++)try{const s=t.plugins[r];typeof s[e]=="function"&&n.push(s[e])}catch(s){throw console.error("Caught error in getAllPluginsByHook:",s),N("PLUGIN_CRASHED")}return n}const sn=["tokenizer","index","documentsStore","sorter","pinning"],_e=["validateSchema","getDocumentIndexId","getDocumentProperties","formatElapsedTime"];function me(t,e,n,o,r){if(t.some(J))return(async()=>{for(const c of t)await c(e,n,o,r)})();for(const c of t)c(e,n,o,r)}function ye(t,e,n,o){if(t.some(J))return(async()=>{for(const s of t)await s(e,n,o)})();for(const s of t)s(e,n,o)}function cn(t,e){if(t.some(J))return(async()=>{for(const o of t)await o(e)})();for(const o of t)o(e)}function an(t,e,n){if(n<0)return-1;if(t===e)return 0;const o=t.length,r=e.length;if(o===0)return r<=n?r:-1;if(r===0)return o<=n?o:-1;const s=Math.abs(o-r);if(t.startsWith(e))return s<=n?s:-1;if(e.startsWith(t))return 0;if(s>n)return-1;const c=[];for(let i=0;i<=o;i++){c[i]=[i];for(let a=1;a<=r;a++)c[i][a]=i===0?a:0}for(let i=1;i<=o;i++){let a=1/0;for(let l=1;l<=r;l++)t[i-1]===e[l-1]?c[i][l]=c[i-1][l-1]:c[i][l]=Math.min(c[i-1][l]+1,c[i][l-1]+1,c[i-1][l-1]+1),a=Math.min(a,c[i][l]);if(a>n)return-1}return c[o][r]<=n?c[o][r]:-1}function ln(t,e,n){const o=an(t,e,n);return{distance:o,isBounded:o>=0}}function lt(){return new Map}function un(t,e){t.delete(e)}function fn(t,e){return t.get(e)?.length??0}function dn(t){if(t.length===0)return[];const e=[...t].sort((o,r)=>o-r),n=[e[0]];for(let o=1;o<e.length;o++)n.push(e[o]-e[o-1]);return n}function hn(t){if(t.length===0)return[];const e=[t[0]];for(let n=1;n<t.length;n++)e.push(e[n-1]+t[n]);return e}function pn(t){const e={};for(const[n,o]of t)o.length>0&&(e[n]=dn(o));return e}function gn(t){const e=lt();if(!t)return e;for(const n of Object.keys(t)){const o=hn(t[n]);o.length>0&&e.set(n,o)}return e}function ut(t,e){if(t.e&&t.w!==void 0){const o=t.d??[];o.length>0&&e.set(t.w,[...o])}const n=t.c??[];for(let o=0;o<n.length;o++)ut(n[o][1],e)}const mn=[];class v{k;s;c=new Map;e;w="";d;constructor(e,n,o){this.k=e,this.s=n,this.e=o}updateParent(e){this.w=e.w+this.s}
11addDocumentToPostings(e,n){let o=this.d;if(o){o.push(n);return}if(o=e.get(this.w),!o){o=[n],e.set(this.w,o),this.d=o;return}o.push(n),this.d=o}removeDocumentFromPostings(e,n){const o=this.d??e.get(this.w);if(!o)return!1;const r=o.indexOf(n);return r===-1?!1:(o.splice(r,1),o.length===0?(e.delete(this.w),this.d=void 0):this.d=o,!0)}getDocumentsFromPostings(e){if(this.d)return this.d;const n=e.get(this.w);return n?(this.d=n,n):mn}hasDocumentsInPostings(e){if(this.d)return this.d.length>0;const n=e.get(this.w);return n!==void 0&&n.length>0}findAllWords(e,n,o,r,s){const c=[this];for(;c.length>0;){const i=c.pop();if(i.e){const{w:l}=i;if(r&&l!==n||s&&(Math.abs(n.length-l.length)>s||!ln(n,l,s).isBounded))continue;const u=i.getDocumentsFromPostings(o);u.length>0?e[l]=[...u]:e[l]=[]}const a=i.c;if(a.size>0)for(const l of a.values())c.push(l)}return e}insertWithPostings(e,n,o){let r=this,s=0;const c=e.length;for(;s<c;){const i=e[s],a=r.c.get(i);if(a){const l=a.s,u=l.length;let d=0;for(;d<u&&s+d<c&&l.charCodeAt(d)===e.charCodeAt(s+d);)d++;if(d===u){if(r=a,s+=d,s===c){a.e||(a.e=!0),a.addDocumentToPostings(o,n);return}continue}const f=l.slice(0,d),h=l.slice(d),p=e.slice(s+d),m=new v(f[0],f,!1);if(m.w=r.w+f,r.c.set(f[0],m),a.s=h,a.k=h[0],m.c.set(h[0],a),a.w=m.w+h,p){const S=new v(p[0],p,!0);S.w=m.w+p,m.c.set(p[0],S),S.addDocumentToPostings(o,n)}else m.e=!0,m.addDocumentToPostings(o,n);return}else{const l=e.slice(s),u=new v(i,l,!0);u.w=r.w+l,r.c.set(i,u),u.addDocumentToPostings(o,n);return}}r.e||(r.e=!0),r.addDocumentToPostings(o,n)}_findLevenshtein(e,n,o,r){const s=e.length;if(!s){this.findAllWords(o,e,r,!1,0);return}const c=new Array(s+1);for(let a=0;a<=s;a++)c[a]=a;const i=[{node:this,row:c}];for(;i.length>0;){const{node:a,row:l}=i.pop();if(a.e&&l[s]<=n){const u=a.getDocumentsFromPostings(r);o[a.w]=u.length>0?[...u]:[]}for(const u of a.c.values()){const d=u.s;let f=l,h=!1,p=!1;for(let m=0;m<d.length;m++){const S=d.charCodeAt(m),g=new Array(s+1);g[0]=f[0]+1;let y=g[0];for(let I=1;I<=s;I++){const b=e.charCodeAt(I-1)===S?f[I-1]:Math.min(f[I]+1,g[I-1]+1,f[I-1]+1);g[I]=b,b<y&&(y=b)}if(f=g,!g[s]){p=!0;break}if(y>n){h=!0;break}}p?u.findAllWords(o,e,r,!1,0):h||i.push({node:u,row:f})}}}findWithPostings(e,n){const{term:o,exact:r,tolerance:s}=e;if(s&&!r){const u={};return this._findLevenshtein(o,s,u,n),u}let c=this,i=0;const a=o.length;for(;i<a;){const u=o[i],d=c.c.get(u);if(d){const f=d.s,h=f.length;let p=0;for(;p<h&&i+p<a&&f.charCodeAt(p)===o.charCodeAt(i+p);)p++;if(p===h)c=d,i+=p;else if(i+p===a){if(p===a-i){if(r)return{};const m={};return d.findAllWords(m,o,n,r,s),m}return{}}else return{}}else return{}}const l={};return c.findAllWords(l,o,n,r,s),l}contains(e){let n=this,o=0;const r=e.length;for(;o<r;){const s=e[o],c=n.c.get(s);if(c){const i=c.s,a=i.length;let l=0;for(;l<a&&o+l<r&&i.charCodeAt(l)===e.charCodeAt(o+l);)l++;if(l<a)return!1;o+=a,n=c}else return!1}return!0}removeWordWithPostings(e,n){if(!e)return!1;let o=this;const r=e.length,s=[];for(let c=0;c<r;c++){const i=e[c];if(o.c.has(i)){const a=o.c.get(i);s.push({parent:o,character:i}),c+=a.s.length-1,o=a}else return!1}for(un(n,o.w),o.d=void 0,o.e=!1;s.length>0&&o.c.size===0&&!o.e&&!o.hasDocumentsInPostings(n);){const{parent:c,character:i}=s.pop();c.c.delete(i),o=c}return!0}removeDocumentByWordWithPostings(e,n,o,r=!0){if(!e)return!0;let s=this;const c=e.length;for(let i=0;i<c;i++){const a=e[i];if(s.c.has(a)){const l=s.c.get(a);i+=l.s.length-1,s=l,r&&s.w!==e||s.removeDocumentFromPostings(o,n)}else return!1}return!0}toNodeJSON(){return{w:this.w,s:this.s,e:this.e,k:this.k,c:Array.from(this.c.entries()).map(([e,n])=>[e,n.toNodeJSON()])}}static fromNodeJSON(e){const n=new v(e.k,e.s,e.e);return n.w=e.w,n.c=new Map(e.c?.map(([o,r])=>[o,v.fromNodeJSON(r)])||[]),n}}class z extends v{postings=lt();constructor(){super("","",!1)}insert(e,n){this.insertWithPostings(e,n,this.postings)}find(e){return this.findWithPostings(e,this.postings)}removeWord(e){return this.removeWordWithPostings(e,this.postings)}removeDocumentByWord(e,n,o=!0){return this.removeDocumentByWordWithPostings(e,n,this.postings,o)}getDocumentFrequency(e){return fn(this.postings,e)}toJSON(){return{...this.toNodeJSON(),postings:pn(this.postings)}}static fromJSON(e){const n=new z;return n.w=e.w,n.s=e.s,n.e=e.e,n.k=e.k,n.c=new Map(e.c?.map(([o,r])=>[o,v.fromNodeJSON(r)])||[]),e.postings?n.postings=gn(e.postings):ut(e,n.postings),ft(n,n.postings),n}}function ft(t,e){if(t.e){const n=e.get(t.w);n&&(t.d=n)}for(const n of t.c.values())ft(n,e)}class _{k;v;l=null;r=null;h=1;constructor(e,n){this.k=e,this.v=new Set(n)}updateHeight(){const e=this.l?this.l.h:0,n=this.r?this.r.h:0;this.h=e>=n?e+1:n+1}static getHeight(e){return e?e.h:0}getBalanceFactor(){return(this.l?this.l.h:0)-(this.r?this.r.h:0)}rotateLeft(){const e=this.r;return this.r=e.l,e.l=this,this.updateHeight(),e.updateHeight(),e}rotateRight(){const e=this.l;return this.l=e.r,e.r=this,this.updateHeight(),e.updateHeight(),e}toJSON(){return{k:this.k,v:Array.from(this.v),l:this.l?this.l.toJSON():null,r:this.r?this.r.toJSON():null,h:this.h}}static fromJSON(e){const n=new _(e.k,e.v);return n.l=e.l?_.fromJSON(e.l):null,n.r=e.r?_.fromJSON(e.r):null,n.h=e.h,n}}class K{root=null;insertCount=0;constructor(e,n){e!==void 0&&n!==void 0&&(this.root=new _(e,n))}insert(e,n,o=1e3){this.root=this.insertNode(this.root,e,n,o)}insertMultiple(e,n,o=1e3){for(let r=0;r<n.length;r++)this.insert(e,n[r],o)}rebalance(){this.root&&(this.root=this.rebalanceNode(this.root))}toJSON(){return{root:this.root?this.root.toJSON():null,insertCount:this.insertCount}}static fromJSON(e){const n=new K;return n.root=e.root?_.fromJSON(e.root):null,n.insertCount=e.insertCount||0,n}insertNode(e,n,o,r){if(e===null)return new _(n,[o]);const s=r===1||(this.insertCount+1)%r===0,c=[],i=s?[]:[];let a=e,l=null;for(;a!==null;){c.push(a),s&&i.push(l);const u=a.k;if(n<u){const d=a.l;if(d===null){const f=new _(n,[o]);a.l=f,c.push(f),s&&i.push(a);break}l=a,a=d}else if(n>u){const d=a.r;if(d===null){const f=new _(n,[o]);a.r=f,c.push(f),s&&i.push(a);break}l=a,a=d}else return a.v.add(o),e}if(this.insertCount++,s)for(let u=c.length-1;u>=0;u--){const d=c[u],f=i[u];d.updateHeight();const h=d.getBalanceFactor();if(h>1||h<-1){const p=this.rebalanceNode(d);f?f.l===d?f.l=p:f.r=p:e=p}}else for(let u=c.length-1;u>=0;u--)c[u].updateHeight();return e}rebalanceNode(e){const n=e.getBalanceFactor();if(n>1){const o=e.l;if(o&&o.getBalanceFactor()>=0)return e.rotateRight();if(o)return e.l=o.rotateLeft(),e.rotateRight()}if(n<-1){const o=e.r;if(o&&o.getBalanceFactor()<=0)return e.rotateLeft();if(o)return e.r=o.rotateRight(),e.rotateLeft()}return e}find(e){const n=this.findNodeByKey(e);return n?n.v:null}contains(e){let n=this.root;for(;n!==null;){const o=n.k;if(e<o)n=n.l;else if(e>o)n=n.r;else return!0}return!1}getSize(){let e=0;const n=[];let o=this.root;for(;o||n.length>0;){for(;o;)n.push(o),o=o.l;o=n.pop(),e++,o=o.r}return e}isBalanced(){if(!this.root)return!0;const e=[this.root];for(;e.length>0;){const n=e.pop(),o=n.getBalanceFactor();if(o>1||o<-1)return!1;n.l&&e.push(n.l),n.r&&e.push(n.r)}return!0}remove(e){this.root=this.removeNode(this.root,e)}removeDocument(e,n){const o=this.findNodeByKey(e);o&&(o.v.size===1?this.root=this.removeNode(this.root,e):o.v.delete(n))}findNodeByKey(e){let n=this.root;for(;n!==null;){const o=n.k;if(e<o)n=n.l;else if(e>o)n=n.r;else return n}return null}removeNode(e,n){if(e===null)return null;const o=[];let r=e;for(;r!==null&&r.k!==n;)o.push(r),n<r.k?r=r.l:r=r.r;if(r===null)return e;if(r.l===null||r.r===null){const s=r.l??r.r;if(o.length===0)e=s;else{const c=o[o.length-1];c.l===r?c.l=s:c.r=s}}else{let s=r,c=r.r;for(;c.l!==null;)s=c,c=c.l;r.k=c.k,r.v=c.v,s.l===c?s.l=c.r:s.r=c.r,r=s}o.push(r);for(let s=o.length-1;s>=0;s--){const c=o[s];c.updateHeight();const i=c.getBalanceFactor();if(i>1||i<-1){const a=this.rebalanceNode(c);if(s>0){const l=o[s-1];l.l===c?l.l=a:l.r=a}else e=a}}return e}rangeSearch(e,n){const o=new Set,r=[];let s=this.root;for(;s||r.length>0;){for(;s;)s.k<e?s=s.r:(r.push(s),s=s.l);if(s=r.pop(),s.k>n)break;for(const c of s.v)o.add(c);s=s.r}return o}greaterThan(e,n=!1){const o=new Set,r=[];let s=this.root;for(;s||r.length>0;){for(;s;)(n?s.k<e:s.k<=e)||r.push(s),s=s.r;if(r.length===0)break;if(s=r.pop(),n&&s.k>=e||!n&&s.k>e){for(const c of s.v)o.add(c);s=s.l}else break}return o}lessThan(e,n=!1){const o=new Set,r=[];let s=this.root;for(;s||r.length>0;){for(;s;)(n?s.k>e:s.k>=e)||r.push(s),s=s.l;if(r.length===0)break;if(s=r.pop(),n&&s.k<=e||!n&&s.k<e){for(const c of s.v)o.add(c);s=s.r}else break}return o}}class q{numberToDocumentId;constructor(){this.numberToDocumentId=new Map}insert(e,n){this.numberToDocumentId.has(e)?this.numberToDocumentId.get(e).add(n):this.numberToDocumentId.set(e,new Set([n])
11)}find(e){const n=this.numberToDocumentId.get(e);return n?Array.from(n):null}remove(e){this.numberToDocumentId.delete(e)}removeDocument(e,n){const o=this.numberToDocumentId.get(n);o&&(o.delete(e),o.size===0&&this.numberToDocumentId.delete(n))}contains(e){return this.numberToDocumentId.has(e)}getSize(){let e=0;for(const n of this.numberToDocumentId.values())e+=n.size;return e}filter(e){const n=Object.keys(e);if(n.length!==1)throw new Error("Invalid operation");const o=n[0];switch(o){case"eq":{const r=e[o],s=this.numberToDocumentId.get(r);return s?Array.from(s):[]}case"in":{const r=e[o],s=new Set;for(const c of r){const i=this.numberToDocumentId.get(c);if(i)for(const a of i)s.add(a)}return Array.from(s)}case"nin":{const r=new Set(e[o]),s=new Set;for(const[c,i]of this.numberToDocumentId.entries())if(!r.has(c))for(const a of i)s.add(a);return Array.from(s)}default:throw new Error("Invalid operation")}}filterArr(e){const n=Object.keys(e);if(n.length!==1)throw new Error("Invalid operation");const o=n[0];switch(o){case"containsAll":{const s=e[o].map(i=>this.numberToDocumentId.get(i)??new Set);if(s.length===0)return[];const c=s.reduce((i,a)=>new Set([...i].filter(l=>a.has(l))));return Array.from(c)}case"containsAny":{const s=e[o].map(i=>this.numberToDocumentId.get(i)??new Set);if(s.length===0)return[];const c=s.reduce((i,a)=>new Set([...i,...a]));return Array.from(c)}default:throw new Error("Invalid operation")}}static fromJSON(e){if(!e.numberToDocumentId)throw new Error("Invalid Flat Tree JSON");const n=new q;for(const[o,r]of e.numberToDocumentId)n.numberToDocumentId.set(o,new Set(r));return n}toJSON(){return{numberToDocumentId:Array.from(this.numberToDocumentId.entries()).map(([e,n])=>[e,Array.from(n)])}}}const yn=6371e3;class M{point;docIDs;left;right;parent;constructor(e,n){this.point=e,this.docIDs=new Set(n),this.left=null,this.right=null,this.parent=null}toJSON(){return{point:this.point,docIDs:Array.from(this.docIDs),left:this.left?this.left.toJSON():null,right:this.right?this.right.toJSON():null}}static fromJSON(e,n=null){const o=new M(e.point,e.docIDs);return o.parent=n,e.left&&(o.left=M.fromJSON(e.left,o)),e.right&&(o.right=M.fromJSON(e.right,o)),o}}class D{root;nodeMap;constructor(){this.root=null,this.nodeMap=new Map}getPointKey(e){return e.lon+","+e.lat}insert(e,n){const o=e.lon,r=e.lat,s=o+","+r,c=this.nodeMap.get(s);if(c){for(let d=0;d<n.length;d++)c.docIDs.add(n[d]);return}const i=new M(e,n);this.nodeMap.set(s,i);const a=this.root;if(a==null){this.root=i;return}let l=a,u=0;for(;;){const d=u&1,f=l.point;if((d?r:o)<(d?f.lat:f.lon)){const p=l.left;if(p==null){l.left=i,i.parent=l;return}l=p}else{const p=l.right;if(p==null){l.right=i,i.parent=l;return}l=p}u++}}contains(e){return this.nodeMap.has(e.lon+","+e.lat)}getDocIDsByCoordinates(e){const n=this.getPointKey(e),o=this.nodeMap.get(n);return o?Array.from(o.docIDs):null}removeDocByID(e,n){const o=this.getPointKey(e),r=this.nodeMap.get(o);r&&(r.docIDs.delete(n),r.docIDs.size===0&&(this.nodeMap.delete(o),this.deleteNode(r)))}deleteNode(e){const n=e.parent,o=e.left?e.left:e.right;o&&(o.parent=n),n?n.left===e?n.left=o:n.right===e&&(n.right=o):(this.root=o,this.root&&(this.root.parent=null))}searchByRadius(e,n,o=!0,r="asc",s=!1){const c=this.root;if(c==null)return[];const i=s?D.vincentyDistance:D.haversineDistance,a=s?D.vincentyAxisDistance:D.haversineAxisDistance,l=[],u=[],d=r==null||r.toLowerCase()==="asc";if(o){const f=[c],h=[0];for(;f.length>0;){const p=f.pop(),m=h.pop(),S=i(e,p.point);if(S<=n){const A={point:p.point,docIDs:Array.from(p.docIDs)};r?u.push([S,A]):l.push(A)}const g=m&1,y=g===0?e.lon:e.lat,I=g===0?p.point.lon:p.point.lat,b=y<I,w=b?p.left:p.right,T=b?p.right:p.left;w!=null&&(f.push(w),h.push(m+1)),T!=null&&a(e,p.point,g)<=n&&(f.push(T),h.push(m+1))}}else{const f=[c];for(;f.length>0;){const h=f.pop(),p=i(e,h.point);if(p>n){const m={point:h.point,docIDs:Array.from(h.docIDs)};r?u.push([p,m]):l.push(m)}h.left!=null&&f.push(h.left),h.right!=null&&f.push(h.right)}}return r&&u.length>0?(u.sort((f,h)=>d?f[0]-h[0]:h[0]-f[0]),u.map(([,f])=>f)):l}searchByPolygon(e,n=!0,o=null,r=!1){const s=this.root;if(s==null)return[];const c=D.getPolygonBounds(e),i=[],a=[],l=o==null||o.toLowerCase()==="asc",u=o?D.calculatePolygonCentroid(e):null,d=o!=null?r?D.vincentyDistance:D.haversineDistance:null;if(n){const f=[s],h=[0];for(;f.length>0;){const p=f.pop(),m=h.pop(),S=m&1;if(S===0?c.minLon<p.point.lon:c.minLat<p.point.lat){const y=p.left;y!=null&&(f.push(y),h.push(m+1))}if(S===0?c.maxLon>=p.point.lon:c.maxLat>=p.point.lat){const y=p.right;y!=null&&(f.push(y),h.push(m+1))}const g=p.point;if(g.lon>=c.minLon&&g.lon<=c.maxLon&&g.lat>=c.minLat&&g.lat<=c.maxLat&&D.isPointInPolygon(e,g)){const y={point:g,docIDs:Array.from(p.docIDs)};o&&d&&u?a.push([d(u,g),y]):i.push(y)}}}else{const f=[{node:s,depth:0}];for(;f.length>0;){const{node:h,depth:p}=f.pop();if(h==null)continue;
11h.left!=null&&f.push({node:h.left,depth:p+1}),h.right!=null&&f.push({node:h.right,depth:p+1});const m=h.point;if(!(m.lon>=c.minLon&&m.lon<=c.maxLon&&m.lat>=c.minLat&&m.lat<=c.maxLat&&D.isPointInPolygon(e,m))){const y={point:m,docIDs:Array.from(h.docIDs)};o&&d&&u?a.push([d(u,m),y]):i.push(y)}}}return o&&a.length>0?(a.sort((f,h)=>l?f[0]-h[0]:h[0]-f[0]),a.map(([,f])=>f)):i}toJSON(){return{root:this.root?this.root.toJSON():null}}static fromJSON(e){const n=new D;return e.root&&(n.root=M.fromJSON(e.root),n.buildNodeMap(n.root)),n}buildNodeMap(e){if(e==null)return;const n=this.getPointKey(e.point);this.nodeMap.set(n,e),e.left&&this.buildNodeMap(e.left),e.right&&this.buildNodeMap(e.right)}static getPolygonBounds(e){let n=e[0].lon,o=e[0].lon,r=e[0].lat,s=e[0].lat;for(let c=1;c<e.length;c++){const i=e[c];i.lon<n&&(n=i.lon),i.lon>o&&(o=i.lon),i.lat<r&&(r=i.lat),i.lat>s&&(s=i.lat)}return{minLon:n,maxLon:o,minLat:r,maxLat:s}}static calculatePolygonCentroid(e){let n=0,o=0,r=0;const s=e.length;for(let i=0,a=s-1;i<s;a=i++){const l=e[i].lon,u=e[i].lat,d=e[a].lon,f=e[a].lat,h=l*f-d*u;n+=h,o+=(l+d)*h,r+=(u+f)*h}n/=2;const c=6*n;return o/=c,r/=c,{lon:o,lat:r}}static isPointInPolygon(e,n){let o=!1;const r=n.lon,s=n.lat,c=e.length;for(let i=0,a=c-1;i<c;a=i++){const l=e[i].lon,u=e[i].lat,d=e[a].lon,f=e[a].lat;u>s!=f>s&&r<(d-l)*(s-u)/(f-u)+l&&(o=!o)}return o}static haversineAxisDistance(e,n,o){return o===0?D.haversineDistance(e,{lon:n.lon,lat:e.lat}):D.haversineDistance(e,{lon:e.lon,lat:n.lat})}static vincentyAxisDistance(e,n,o){return o===0?D.vincentyDistance(e,{lon:n.lon,lat:e.lat}):D.vincentyDistance(e,{lon:e.lon,lat:n.lat})}static haversineDistance(e,n){const o=Math.PI/180,r=e.lat*o,s=n.lat*o,c=(n.lat-e.lat)*o,i=(n.lon-e.lon)*o,a=Math.sin(c/2)*Math.sin(c/2)+Math.cos(r)*Math.cos(s)*Math.sin(i/2)*Math.sin(i/2),l=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));return yn*l}static vincentyDistance(e,n){const r=.0033528106647474805,s=(1-r)*6378137,c=Math.PI/180,i=e.lat*c,a=n.lat*c,l=(n.lon-e.lon)*c,u=Math.atan((1-r)*Math.tan(i)),d=Math.atan((1-r)*Math.tan(a)),f=Math.sin(u),h=Math.cos(u),p=Math.sin(d),m=Math.cos(d);let S=l,g,y=1e3,I,b,w,T,A,O;do{const k=Math.sin(S),C=Math.cos(S);if(I=Math.sqrt(m*k*(m*k)+(h*p-f*m*C)*(h*p-f*m*C)),I===0)return 0;b=f*p+h*m*C,w=Math.atan2(I,b),T=h*m*k/I,A=1-T*T,O=b-2*f*p/A,isNaN(O)&&(O=0);const Q=r/16*A*(4+r*(4-3*A));g=S,S=l+(1-Q)*r*T*(w+Q*I*(O+Q*b*(-1+2*O*O)))}while(Math.abs(S-g)>1e-12&&--y>0);if(y===0)return NaN;const P=A*(6378137*6378137-s*s)/(s*s),V=1+P/16384*(4096+P*(-768+P*(320-175*P))),L=P/1024*(256+P*(-128+P*(74-47*P))),Z=L*I*(O+L/4*(b*(-1+2*O*O)-L/6*O*(-3+4*I*I)*(-3+4*O*O)));return s*V*(w-Z)}}class X{true;false;constructor(){this.true=new Set,this.false=new Set}insert(e,n){n?this.true.add(e):this.false.add(e)}delete(e,n){n?this.true.delete(e):this.false.delete(e)}getSize(){return this.true.size+this.false.size}toJSON(){return{true:Array.from(this.true),false:Array.from(this.false)}}static fromJSON(e){const n=new X;return n.true=new Set(e.true),n.false=new Set(e.false),n}}function Sn(t,e,n,o,r,{k:s,b:c,d:i}){return Math.log(1+(n-e+.5)/(e+.5))*(i+t*(s+1))/(t+s*(1-c+c*o/r))}function te(t,e){let n=0;for(let s=0;s<e;s++)n+=t[s]*t[s];const o=Math.sqrt(n);if(o===0)return 0;const r=1/o;for(let s=0;s<e;s++)t[s]*=r;return o}function ve(t,e,n){let o=0,r=0;const s=n-3;for(;r<s;r+=4)o+=t[r]*e[r]+t[r+1]*e[r+1]+t[r+2]*e[r+2]+t[r+3]*e[r+3];for(;r<n;r++)o+=t[r]*e[r];return o>1?1:o<-1?-1:o}const In=.8;class Y{size;vectors=new Map;constructor(e){this.size=e}add(e,n){const o=new Float32Array(n);te(o,this.size),this.vectors.set(e,[1,o])}remove(e){this.vectors.delete(e)}find(e,n,o){const r=new Float32Array(e);return te(r,this.size)===0?[]:bn(r,o,this.vectors,this.size,n)}toJSON(){const e=[];for(const[n,[o,r]]of this.vectors)e.push([n,[o,Array.from(r)]]);return{kind:"flat",size:this.size,vectors:e}}static fromJSON(e){const n=e,o=new Y(n.size);for(const[r,[,s]]of n.vectors){const c=new Float32Array(s);te(c,n.size),o.vectors.set(r,[1,c])}return o}}function bn(t,e,n,o,r){const s=[];if(e){for(const c of e){const i=n.get(c);if(!i)continue;const a=ve(t,i[1],o);a>=r&&s.push([c,a])}return s}for(const[c,[,i]]of n){const a=ve(t,i,o);a>=r&&s.push([c,a])}return s}function wn(t,e,n){return Object.assign(e,{kind:t,fromJSON:n}
11)}function Nn(){return wn("flat",t=>new Y(t.dim),t=>Y.fromJSON(t))}const ce=Nn();function dt(t,e){if(!e)return ce;const n=t===re?void 0:e[t];if(n!==void 0)return Le(n);const o=e[re];return o!==void 0?Le(o):ce}function Le(t){return t==="flat"?ce:t}function Tn(t,e,n){const r=e.kind??"flat",s=dt(t,n);if(r==="ivf"&&s.kind!=="ivf")throw N("IVF_INDEX_REQUIRES_FACTORY",t,t);return s.fromJSON(e)}function ht(t,e,n,o,r,s){const c=s??E(t.sharedInternalDocumentStore,n);return t.avgFieldLength[e]=((t.avgFieldLength[e]??0)*(r-1)+o.length)/r,t.fieldLengths[e][c]=o.length,t.frequencies[e][c]={},c}function An(t,e,n,o,r,s){let c=0;const i=o.length;for(let u=0;u<i;u++)o[u]===r&&c++;const a=s??E(t.sharedInternalDocumentStore,n),l=i>0?c/i:0;t.frequencies[e][a][r]=l}function On(t,e,n,o,r,s,c){ht(t,e,o,s,c,r);const i=t.frequencies[e][r],a=s.length,l=a>0?1/a:0;for(let u=0;u<a;u++){const d=s[u];Object.hasOwn(i,d)?i[d]+=l:(i[d]=l,n.insert(d,r))}}function Dn(t,e,n,o){const r=E(t.sharedInternalDocumentStore,n);o>1?t.avgFieldLength[e]=(t.avgFieldLength[e]*o-t.fieldLengths[e][r])/(o-1):t.avgFieldLength[e]=void 0,t.fieldLengths[e][r]=void 0,t.frequencies[e][r]=void 0}function Pn(t,e,n){}function pt(t,e,n,o,r=""){o||(o={sharedInternalDocumentStore:e,indexes:{},vectorIndexes:{},searchableProperties:[],searchablePropertiesWithTypes:{},frequencies:{},tokenOccurrences:{},avgFieldLength:{},fieldLengths:{}});for(const[s,c]of Object.entries(n)){const i=`${r}${r?".":""}${s}`;if(typeof c=="object"&&!Array.isArray(c)){pt(t,e,c,o,i);continue}if(F(c)){const a=dt(i,t.indexes);o.searchableProperties.push(i),o.searchablePropertiesWithTypes[i]=c,o.vectorIndexes[i]={type:"Vector",node:a({dim:at(c),property:i}),isArray:!1}}else{const a=/\[/.test(c);switch(c){case"boolean":case"boolean[]":o.indexes[i]={type:"Bool",node:new X,isArray:a};break;case"number":case"number[]":o.indexes[i]={type:"AVL",node:new K(0,[]),isArray:a};break;case"string":case"string[]":o.indexes[i]={type:"Radix",node:new z,isArray:a},o.avgFieldLength[i]=0,o.frequencies[i]={},o.tokenOccurrences[i]={},o.fieldLengths[i]={};break;case"enum":case"enum[]":o.indexes[i]={type:"Flat",node:new q,isArray:a};break;case"geopoint":o.indexes[i]={type:"BKD",node:new D,isArray:a};break;default:throw N("INVALID_SCHEMA_TYPE",Array.isArray(c)?"array":c,i)}o.searchableProperties.push(i),o.searchablePropertiesWithTypes[i]=c}}return o}function ke(t,e,n,o,r,s,c,i,a,l){const{type:u,node:d}=e.indexes[n];switch(u){case"Bool":{d[s?"true":"false"].add(r);break}case"AVL":{const f=l?.avlRebalanceThreshold??1;d.insert(s,r,f);break}case"Radix":{const f=i.tokenize(s,c,n,!1);On(e,n,d,o,r,f,a);break}case"Flat":{d.insert(s,r);break}case"BKD":{d.insert(s,[r]);break}}}function En(t,e,n,o,r,s,c,i,a,l,u){if(F(c))return Rn(e,n,s,o,r);if(!pe(c))return ke(t,e,n,o,r,s,i,a,l,u);const d=s,f=d.length;for(let h=0;h<f;h++)ke(t,e,n,o,r,d[h],i,a,l,u)}function Rn(t,e,n,o,r){t.vectorIndexes[e].node.add(r,n)}function Me(t,e,n,o,r,s,c,i,a,l){if(F(c))return e.vectorIndexes[n].node.remove(r),!0;const{type:u,node:d}=e.indexes[n];switch(u){case"AVL":return d.removeDocument(s,r),!0;case"Bool":return d[s?"true":"false"].delete(r),!0;case"Radix":{const f=a.tokenize(s,i,n);t.removeDocumentScoreParameters(e,n,o,l);for(const h of f)t.removeTokenScoreParameters(e,n,h),d.removeDocumentByWord(h,r);return!0}case"Flat":return d.removeDocument(r,s),!0;case"BKD":return d.removeDocByID(s,r),!1}}function _n(t,e,n,o,r,s,c,i,a,l){if(!pe(c))return Me(t,e,n,o,r,s,c,i,a,l);const u=ct(c),d=s,f=d.length;for(let h=0;h<f;h++)Me(t,e,n,o,r,d[h],u,i,a,l);return!0}function Se(t,e,n,o,r,s,c,i,a,l){const u=t.avgFieldLength[e],d=t.fieldLengths[e],f=t.frequencies[e],h=Vn(t,e,n),p=o.length;for(let m=0;m<p;m++){const S=o[m];if(a&&!a.has(S))continue;if(l){l.has(S)||l.set(S,new Map);const I=l.get(S);I.set(e,(I.get(e)||0)+1)}const g=f?.[S]?.[n]??0,y=Sn(g,h,r,d[S],u,s);c.has(S)?c.set(S,c.get(S)+y*i):c.set(S,y*i)}}function vn(t){const e=new Set;for(const n in t){const o=t[n];for(let r=0;r<o.length;r++)e.add(o[r])}return e}function Ln(t,e){const n=[];for(let o=0;o<t.length;o++){const r=t[o];e.has(r)&&n.push(r)}return n}function kn(t,e,n,o,r,s,c,i,a){const l=new Map,u=new Set,d=[];for(const h of n){if(!(h in t.indexes))continue;
11const p=t.indexes[h];if(p.type!=="Radix")throw N("WRONG_SEARCH_PROPERTY_TYPE",h);const m=s[h]??1;if(m<=0)throw N("INVALID_BOOST_VALUE",m);let S;const g=e.length;for(let y=0;y<g;y++){const I=e[y],b=`${h}\0${I}`;let w=l.get(b);if(w||(w=p.node.find({term:I,exact:o,tolerance:r}),l.set(b,w)),!Object.keys(w).length){S=void 0;break}const T=vn(w);if(S=S===void 0?T:ie(S,T),!S.size)break}if(!(!S||!S.size)){d.push(h);for(const y of S)(!a||a.has(y))&&u.add(y)}}if(!u.size)return[];const f=new Map;for(const h of d){if(t.indexes[h].type!=="Radix")continue;const m=s[h]??1,S=e.length;for(let g=0;g<S;g++){const y=e[g],I=`${h}\0${y}`,b=l.get(I),w=Object.keys(b);for(let T=0;T<w.length;T++){const A=w[T],O=Ln(b[A],u);O.length>0&&Se(t,h,A,O,i,c,f,m,a)}}}return Array.from(f.entries()).map(([h,p])=>[h,p]).sort((h,p)=>p[1]-h[1])}function Mn(t,e,n,o,r,s,c,i,a,l,u,d=0){const f=n.tokenize(e,o),h=f.length||1;if(!f.length&&!e&&f.push(""),!d&&f.length>1)return kn(t,f,r,s,c,i,a,l,u);const p=new Map,m=new Map,S=new Map;for(const I of r){if(!(I in t.indexes))continue;const b=t.indexes[I],{type:w}=b;if(w!=="Radix")throw N("WRONG_SEARCH_PROPERTY_TYPE",I);const T=i[I]??1;if(T<=0)throw N("INVALID_BOOST_VALUE",T);const A=f.length;for(let O=0;O<A;O++){const P=f[O],V=b.node.find({term:P,exact:s,tolerance:c}),L=Object.keys(V);L.length>0&&m.set(P,!0);const Z=L.length;for(let B=0;B<Z;B++){const k=L[B],C=V[k];Se(t,I,k,C,l,a,S,T,u,p)}}}const g=Array.from(S.entries()).map(([I,b])=>[I,b]).sort((I,b)=>b[1]-I[1]);if(g.length===0)return[];if(d===1)return g;if(d===0){if(h===1)return g;for(const b of f)if(!m.get(b))return[];return g.filter(([b])=>{const w=p.get(b);return w?Array.from(w.values()).some(T=>T===h):!1})}const y=g.filter(([I])=>{const b=p.get(I);return b?Array.from(b.values()).some(w=>w===h):!1});if(y.length>0){const I=g.filter(([w])=>!y.some(([T])=>T===w)),b=Math.ceil(I.length*d);return[...y,...I.slice(0,b)]}return g}function j(t,e,n,o){if("and"in n&&n.and&&Array.isArray(n.and)){const c=n.and;if(c.length===0)return new Set;const i=c.map(a=>j(t,e,a,o));return ie(...i)}if("or"in n&&n.or&&Array.isArray(n.or)){const c=n.or;return c.length===0?new Set:c.map(a=>j(t,e,a,o)).reduce((a,l)=>W(a,l),new Set)}if("not"in n&&n.not){const c=n.not,i=new Set,a=t.sharedInternalDocumentStore;for(let u=1;u<=a.internalIdToId.length;u++)i.add(u);const l=j(t,e,c,o);return Ut(i,l)}const r=Object.keys(n),s=r.reduce((c,i)=>({[i]:new Set,...c}),{});for(const c of r){const i=n[c];if(typeof t.indexes[c]>"u")throw N("UNKNOWN_FILTER_PROPERTY",c);const{node:a,type:l,isArray:u}=t.indexes[c];if(l==="Bool"){const f=a,h=i?f.true:f.false;s[c]=W(s[c],h);continue}if(l==="BKD"){let f;if("radius"in i)f="radius";else if("polygon"in i)f="polygon";else throw new Error(`Invalid operation ${i}`);if(f==="radius"){const{value:h,coordinates:p,unit:m="m",inside:S=!0,highPrecision:g=!1}=i[f],y=rt(h,m),I=a.searchByRadius(p,y,S,void 0,g);s[c]=xe(s[c],I)}else{const{coordinates:h,inside:p=!0,highPrecision:m=!1}=i[f],S=a.searchByPolygon(h,p,void 0,m);s[c]=xe(s[c],S)}continue}if(l==="Radix"&&(typeof i=="string"||Array.isArray(i))){for(const f of[i].flat()){const h=e.tokenize(f,o,c);for(const p of h){const m=a.find({term:p,exact:!0});s[c]=Gn(s[c],m)}}continue}const d=Object.keys(i);if(d.length>1)throw N("INVALID_FILTER_OPERATION",d.length);if(l==="Flat"){const f=new Set(u?a.filterArr(i):a.filter(i));s[c]=W(s[c],f);continue}if(l==="AVL"){const f=d[0],h=i[f];let p;switch(f){case"gt":{p=a.greaterThan(h,!1);break}case"gte":{p=a.greaterThan(h,!0);break}case"lt":{p=a.lessThan(h,!1);break}case"lte":{p=a.lessThan(h,!0);break}case"eq":{p=a.find(h)??new Set;break}case"between":{const[m,S]=h;p=a.rangeSearch(m,S);break}default:throw N("INVALID_FILTER_OPERATION",f)}s[c]=W(s[c],p)}}return ie(...Object.values(s))}function xn(t){return t.searchableProperties}function Cn(t){return t.searchablePropertiesWithTypes}function Un(t,e,n){const{indexes:o,vectorIndexes:r,searchableProperties:s,searchablePropertiesWithTypes:c,frequencies:i,tokenOccurrences:a,avgFieldLength:l,fieldLengths:u}=e,d={},f={};for(const h of Object.keys(o)){const{node:p,type:m,isArray:S}=o[h];switch(m){case"Radix":d[h]={type:"Radix",node:z.fromJSON(p),isArray:S};break;case"Flat":d[h]={type:"Flat",node:q.fromJSON(p),isArray:S};break;case"AVL":d[h]={type:"AVL",node:K.fromJSON(p),isArray:S};break;case"BKD":d[h]={type:"BKD",node:D.fromJSON(p),isArray:S};break;
11case"Bool":d[h]={type:"Bool",node:X.fromJSON(p),isArray:S};break;default:d[h]=o[h]}}for(const h of Object.keys(r))f[h]={type:"Vector",isArray:!1,node:Tn(h,r[h],n)};return{sharedInternalDocumentStore:t,indexes:d,vectorIndexes:f,searchableProperties:s,searchablePropertiesWithTypes:c,frequencies:i,tokenOccurrences:a,avgFieldLength:l,fieldLengths:u}}function Fn(t){const{indexes:e,vectorIndexes:n,searchableProperties:o,searchablePropertiesWithTypes:r,frequencies:s,tokenOccurrences:c,avgFieldLength:i,fieldLengths:a}=t,l={};for(const d of Object.keys(n))l[d]=n[d].node.toJSON();const u={};for(const d of Object.keys(e)){const{type:f,node:h,isArray:p}=e[d];f==="Flat"||f==="Radix"||f==="AVL"||f==="BKD"||f==="Bool"?u[d]={type:f,node:h.toJSON(),isArray:p}:(u[d]=e[d],u[d].node=u[d].node.toJSON())}return{indexes:u,vectorIndexes:l,searchableProperties:o,searchablePropertiesWithTypes:r,frequencies:s,tokenOccurrences:{},avgFieldLength:i,fieldLengths:a}}function Vn(t,e,n){const o=t.indexes[e];if(o?.type==="Radix")return o.node.getDocumentFrequency(n);const r=t.tokenOccurrences[e]?.[n];return typeof r=="number"?r:0}function Bn(){return{create:pt,insert:En,remove:_n,insertDocumentScoreParameters:ht,insertTokenScoreParameters:An,removeDocumentScoreParameters:Dn,removeTokenScoreParameters:Pn,calculateResultScores:Se,search:Mn,searchByWhereClause:j,getSearchableProperties:xn,getSearchablePropertiesWithTypes:Cn,load:Un,save:Fn}}function xe(t,e){t||(t=new Set);const n=e.length;for(let o=0;o<n;o++){const r=e[o].docIDs,s=r.length;for(let c=0;c<s;c++)t.add(r[c])}return t}function Ce(t,e,n=!1){const o=n?D.vincentyDistance:D.haversineDistance,r=[],s=[];for(const{point:a}of t)s.push(o(e,a));const c=Math.max(...s);let i=0;for(const{docIDs:a}of t){const l=s[i],u=c-l+1;for(const d of a)r.push([d,u]);i++}return r.sort((a,l)=>l[1]-a[1]),r}function Wn(t,e){const n=Object.keys(t);if(n.length!==1)return{isGeoOnly:!1};const o=n[0],r=t[o];if(typeof e.indexes[o]>"u")return{isGeoOnly:!1};const{type:s}=e.indexes[o];return s==="BKD"&&r&&("radius"in r||"polygon"in r)?{isGeoOnly:!0,geoProperty:o,geoOperation:r}:{isGeoOnly:!1}}function $n(t,e){const n=t,o=Wn(e,n);if(!o.isGeoOnly||!o.geoProperty||!o.geoOperation)return null;const{node:r}=n.indexes[o.geoProperty],s=o.geoOperation,c=r;let i;if("radius"in s){const{value:a,coordinates:l,unit:u="m",inside:d=!0,highPrecision:f=!1}=s.radius,h=l,p=rt(a,u);return i=c.searchByRadius(h,p,d,"asc",f),Ce(i,h,f)}else if("polygon"in s){const{coordinates:a,inside:l=!0,highPrecision:u=!1}=s.polygon;i=c.searchByPolygon(a,l,"asc",u);const d=D.calculatePolygonCentroid(a);return Ce(i,d,u)}return null}function Gn(t,e){t||(t=new Set);const n=Object.keys(e),o=n.length;for(let r=0;r<o;r++){const s=e[n[r]],c=s.length;for(let i=0;i<c;i++)t.add(s[i])}return t}function gt(t,e,n,o,r){const s={language:t.tokenizer.language,sharedInternalDocumentStore:e,enabled:!0,isSorted:!0,sortableProperties:[],sortablePropertiesWithTypes:{},sorts:{}};for(const[c,i]of Object.entries(n)){const a=`${r}${r?".":""}${c}`;if(!o.includes(a)){if(typeof i=="object"&&!Array.isArray(i)){const l=gt(t,e,i,o,a);et(s.sortableProperties,l.sortableProperties),s.sorts={...s.sorts,...l.sorts},s.sortablePropertiesWithTypes={...s.sortablePropertiesWithTypes,...l.sortablePropertiesWithTypes};continue}if(!F(i))switch(i){case"boolean":case"number":case"string":s.sortableProperties.push(a),s.sortablePropertiesWithTypes[a]=i,s.sorts[a]={docs:new Map,orderedDocsToRemove:new Map,orderedDocs:[],type:i};break;case"geopoint":case"enum":continue;case"enum[]":case"boolean[]":case"number[]":case"string[]":continue;default:throw N("INVALID_SORT_SCHEMA_TYPE",Array.isArray(i)?"array":i,a)}}}return s}function jn(t,e,n,o){return o?.enabled!==!1?gt(t,e,n,(o||{}).unsortableProperties||[],""):{disabled:!0}}function Yn(t,e,n,o){if(!t.enabled)return;t.isSorted=!1;
11const r=E(t.sharedInternalDocumentStore,n),s=t.sorts[e];s.orderedDocsToRemove.has(r)&&Ie(t,e),s.docs.set(r,s.orderedDocs.length),s.orderedDocs.push([r,o])}function mt(t){if(t.isSorted||!t.enabled)return;const e=Object.keys(t.sorts);for(const n of e)Kn(t,n);t.isSorted=!0}function Hn(t,e,n){return e[1].localeCompare(n[1],Pt(t))}function Jn(t,e){return t[1]-e[1]}function zn(t,e){return e[1]?-1:1}function Kn(t,e){const n=t.sorts[e];let o;switch(n.type){case"string":o=Hn.bind(null,t.language);break;case"number":o=Jn.bind(null);break;case"boolean":o=zn.bind(null);break}n.orderedDocs.sort(o);const r=n.orderedDocs.length;for(let s=0;s<r;s++){const c=n.orderedDocs[s][0];n.docs.set(c,s)}}function qn(t){const e=Object.keys(t.sorts);for(const n of e)Ie(t,n)}function Ie(t,e){const n=t.sorts[e];n.orderedDocsToRemove.size&&(n.orderedDocs=n.orderedDocs.filter(o=>!n.orderedDocsToRemove.has(o[0])),n.orderedDocsToRemove.clear())}function Xn(t,e,n){if(!t.enabled)return;const o=t.sorts[e],r=E(t.sharedInternalDocumentStore,n);o.docs.get(r)&&(o.docs.delete(r),o.orderedDocsToRemove.set(r,!0))}function Zn(t,e,n){if(!t.enabled)throw N("SORT_DISABLED");const o=n.property,r=n.order==="DESC",s=t.sorts[o];if(!s)throw N("UNABLE_TO_SORT_ON_UNKNOWN_FIELD",o,t.sortableProperties.join(", "));return Ie(t,o),mt(t),e.sort((c,i)=>{const a=s.docs.get(E(t.sharedInternalDocumentStore,c[0])),l=s.docs.get(E(t.sharedInternalDocumentStore,i[0])),u=typeof a<"u",d=typeof l<"u";return!u&&!d?0:u?d?r?l-a:a-l:-1:1}),e}function Qn(t){return t.enabled?t.sortableProperties:[]}function eo(t){return t.enabled?t.sortablePropertiesWithTypes:{}}function to(t,e){const n=e;if(!n.enabled)return{enabled:!1};const o=Object.keys(n.sorts).reduce((r,s)=>{const{docs:c,orderedDocs:i,type:a}=n.sorts[s];return r[s]={docs:new Map(Object.entries(c).map(([l,u])=>[+l,u])),orderedDocsToRemove:new Map,orderedDocs:i,type:a},r},{});return{sharedInternalDocumentStore:t,language:n.language,sortableProperties:n.sortableProperties,sortablePropertiesWithTypes:n.sortablePropertiesWithTypes,sorts:o,enabled:!0,isSorted:n.isSorted}}function no(t){if(!t.enabled)return{enabled:!1};qn(t),mt(t);const e=Object.keys(t.sorts).reduce((n,o)=>{const{docs:r,orderedDocs:s,type:c}=t.sorts[o];return n[o]={docs:Object.fromEntries(r.entries()),orderedDocs:s,type:c},n},{});return{language:t.language,sortableProperties:t.sortableProperties,sortablePropertiesWithTypes:t.sortablePropertiesWithTypes,sorts:e,enabled:t.enabled,isSorted:t.isSorted}}function oo(){return{create:jn,insert:Yn,remove:Xn,save:no,load:to,sortBy:Zn,getSortableProperties:Qn,getSortablePropertiesWithTypes:eo}}const ae=192,ro=383,so=[65,65,65,65,65,65,65,67,69,69,69,69,73,73,73,73,69,78,79,79,79,79,79,null,79,85,85,85,85,89,80,115,97,97,97,97,97,97,97,99,101,101,101,101,105,105,105,105,101,110,111,111,111,111,111,null,111,117,117,117,117,121,112,121,65,97,65,97,65,97,67,99,67,99,67,99,67,99,68,100,68,100,69,101,69,101,69,101,69,101,69,101,71,103,71,103,71,103,71,103,72,104,72,104,73,105,73,105,73,105,73,105,73,105,73,105,74,106,75,107,107,76,108,76,108,76,108,76,108,76,108,78,110,78,110,78,110,110,78,110,79,111,79,111,79,111,79,111,82,114,82,114,82,114,83,115,83,115,83,115,83,115,84,116,84,116,84,116,85,117,85,117,85,117,85,117,85,117,85,117,87,119,89,121,89,90,122,90,122,90,122,115],io={1025:1045,1105:1077,1570:1575,1571:1575,1573:1575,1649:1575,1609:1610};function Ue(t){return t<ae?t:t<=ro?so[t-ae]||t:io[t]??t}function co(t){const e=t.length;for(let n=0;n<e;n++){const o=t.charCodeAt(n);if(o<ae)continue;const r=Ue(o);if(r===o)continue;const s=new Array(e);for(let c=0;c<n;c++)s[c]=t.charCodeAt(c);s[n]=r;for(let c=n+1;c<e;c++)s[c]=Ue(t.charCodeAt(c));return String.fromCharCode(...s)}return t}const ao={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},lo={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},uo="[^aeiou]",H="[aeiouy]",R=uo+"[^aeiouy]*",U=H+"[aeiou]*",ne="^("+R+")?"+U+R,fo="^("+R+")?"+U+R+"("+U+")?$",$="^("+R+")?"+U+R+U+R,Fe="^("+R+")?"+H;function ho(t){let e,n,o,r,s,c;if(t.length<3)return t;const i=t.substring(0,1);if(i=="y"&&(t=i.toUpperCase()+t.substring(1)),o=/^(.+?)(ss|i)es$/,r=/^(.+?)([^s])s$/,o.test(t)?t=t.replace(o,"$1$2"):r.test(t)&&(t=t.replace(r,"$1$2")),o=/^(.+?)eed$/,r=/^(.+?)(ed|ing)$/,o.test(t)){const a=o.exec(t);o=new RegExp(ne),o.test(a[1])&&(o=/.$/,t=t.replace(o,""))}else r.test(t)&&(e=r.exec(t)[1],r=new RegExp(Fe),r.test(e)&&(t=e,r=/(at|bl|iz)$/,s=new RegExp("([^aeiouylsz])\\1$"),c=new RegExp("^"+R+H+"[^aeiouwxy]$"),r.test(t)?t=t+"e":s.test(t)?(o=/.$/,t=t.replace(o,"")):c.test(t)&&(t=t+"e")));if(o=/^(.+?)y$/,o.test(t)&&(e=o.exec(t)?.[1],o=new RegExp(Fe),e&&o.test(e)&&(t=e+"i")),o=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,o.test(t)){const a=o.exec(t);e=a?.[1],n=a?.[2],o=new RegExp(ne),e&&o.test(e)&&(t=e+ao[n])}if(o=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,o.test(t)){const a=o.exec(t);e=a?.[1],n=a?.[2],o=new RegExp(ne),e&&o.test(e)&&(t=e+lo[n])}if(o=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,r=/^(.+?)(s|t)(ion)$/,o.test(t))e=o.exec(t)?.[1],o=new RegExp($),e&&o.test(e)&&(t=e);else if(r.test(t)){const a=r.exec(t);e=a?.[1]??""+a?.[2]??"",r=new RegExp($),r.test(e)&&(t=e)}return o=/^(.+?)e$/,o.test(t)&&(e=o.exec(t)?.[1],o=new RegExp($),r=new RegExp(fo),s=new RegExp("^"+R+H+"[^aeiouwxy]$"),e&&(o.test(e)||r.test(e)&&!s.test(e))&&(t=e)),o=/ll$/,r=new RegExp($),o.test(t)&&r.test(t)&&(o=/.$/,t=t.replace(o,"")),i=="y"&&(t=i.toLowerCase()+t.substring(1)),t}function Ve(t,e,n=!0){const o=`${this.language}:${t}:${e}`;return n&&this.normalizationCache.has(o)?this.normalizationCache.get(o):this.stopWordsSet?.has(e)?(n&&this.normalizationCache.set(o,""),""):(Et.has(this.language)||(e=co(e)),this.stemmer&&!this.stemmerSkipProperties.has(t)&&(e=this.stemmer(e)),n&&this.normalizationCache.set(o,e),e)}function po(t){for(;t[t.length-1]==="";)t.pop();for(;t[0]==="";)t.shift();return t}const go=/[\p{L}\p{N}]+/gu;let G;function mo(t){if(G===void 0&&typeof Intl<"u"&&typeof Intl.Segmenter=="function"&&(G=new Intl.Segmenter(void 0,{granularity:"word"})),G){const e=[];for(const{segment:n,isWordLike:o}of G.segment(t))o&&e.push(n.toLowerCase());return e}return t.toLowerCase().match(go)??[]}function Be(t,e,n,o=!0){if(e&&e!==this.language)throw N("LANGUAGE_NOT_SUPPORTED",e);if(typeof t!="string")return[t];const r=n??"";if(n&&this.tokenizeSkipProperties.has(n)){const l=this.normalizeToken(r,t,o);return l?[l]:[]}const s=this.language===le?mo(t):t.toLowerCase().split(Dt[this.language]),c=[],i=s.length;for(let l=0;l<i;l++){const u=s[l];if(!u)continue;const d=this.normalizeToken(r,u,o);d&&c.push(d)}const a=po(c);
11return this.allowDuplicates?a:Array.from(new Set(a))}function We(t={}){if(!t.language)t.language="english";else if(t.language!==le&&!ue.includes(t.language))throw N("LANGUAGE_NOT_SUPPORTED",t.language);let e;if(t.stemming||t.stemmer&&!("stemming"in t))if(t.stemmer){if(typeof t.stemmer!="function")throw N("INVALID_STEMMER_FUNCTION_TYPE");e=t.stemmer}else if(t.language==="english")e=ho;else throw N("MISSING_STEMMER",t.language);let n;if(t.stopWords!==!1){if(n=[],Array.isArray(t.stopWords))n=t.stopWords;else if(typeof t.stopWords=="function")n=t.stopWords(n);else if(t.stopWords)throw N("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");if(!Array.isArray(n))throw N("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY");for(const r of n)if(typeof r!="string")throw N("CUSTOM_STOP_WORDS_MUST_BE_FUNCTION_OR_ARRAY")}const o={tokenize:Be,language:t.language,stemmer:e,stemmerSkipProperties:new Set(t.stemmerSkipProperties?[t.stemmerSkipProperties].flat():[]),tokenizeSkipProperties:new Set(t.tokenizeSkipProperties?[t.tokenizeSkipProperties].flat():[]),stopWords:n,stopWordsSet:n?new Set(n):void 0,allowDuplicates:!!t.allowDuplicates,normalizeToken:Ve,normalizationCache:new Map};return o.tokenize=Be.bind(o),o.normalizeToken=Ve,o}function yo(t){return{sharedInternalDocumentStore:t,rules:new Map}}function So(t,e){if(t.rules.has(e.id))throw new Error(`PINNING_RULE_ALREADY_EXISTS: A pinning rule with id "${e.id}" already exists. Use updateRule to modify it.`);t.rules.set(e.id,e)}function Io(t,e){if(!t.rules.has(e.id))throw new Error(`PINNING_RULE_NOT_FOUND: Cannot update pinning rule with id "${e.id}" because it does not exist. Use addRule to create it.`);t.rules.set(e.id,e)}function bo(t,e){return t.rules.delete(e)}function wo(t,e){return t.rules.get(e)}function No(t){return Array.from(t.rules.values())}function To(t,e){const n=t.toLowerCase().trim(),o=e.pattern.toLowerCase().trim();switch(e.anchoring){case"is":return n===o;case"starts_with":return n.startsWith(o);case"contains":return n.includes(o);default:return!1}}function Ao(t,e){return t?e.conditions.every(n=>To(t,n)):!1}function yt(t,e){if(!e)return[];const n=[];for(const o of t.rules.values())Ao(e,o)&&n.push(o);return n}function Oo(t,e){const n=e;return{sharedInternalDocumentStore:t,rules:new Map(n?.rules??[])}}function Do(t){return{rules:Array.from(t.rules.entries())}}function Po(){return{create:yo,addRule:So,updateRule:Io,removeRule:bo,getRule:wo,getAllRules:No,getMatchingRules:yt,load:Oo,save:Do}}function Eo(t){const e={formatElapsedTime:Bt,getDocumentIndexId:Wt,getDocumentProperties:nt,validateSchema:it};for(const n of _e){const o=n;if(t[o]){if(typeof t[o]!="function")throw N("COMPONENT_MUST_BE_FUNCTION",o)}else t[o]=e[o]}for(const n of Object.keys(t))if(!sn.includes(n)&&!_e.includes(n))throw N("UNSUPPORTED_COMPONENT",n)}function Ro({schema:t,indexes:e,sort:n,language:o,components:r,id:s,plugins:c}){r||(r={});for(const I of c??[]){if(!("getComponents"in I)||typeof I.getComponents!="function")continue;const b=I.getComponents(t),w=Object.keys(b);for(const T of w)if(r[T])throw N("PLUGIN_COMPONENT_CONFLICT",T,I.name);r={...r,...b}}s||(s=tt()),st(t);let i=r.tokenizer,a=r.index,l=r.documentsStore,u=r.sorter,d=r.pinning;if(i?i.tokenize?i=i:i=We(i):i=We({language:o??"english"}),r.tokenizer&&o)throw N("NO_LANGUAGE_WITH_CUSTOM_TOKENIZER");const f=jt();a||=Bn(),u||=oo(),l||=nn(),d||=Po(),Eo(r);const{getDocumentProperties:h,getDocumentIndexId:p,validateSchema:m,formatElapsedTime:S}=r,g={data:{},caches:{},schema:t,tokenizer:i,index:a,sorter:u,documentsStore:l,pinning:d,internalDocumentIDStore:f,getDocumentProperties:h,getDocumentIndexId:p,validateSchema:m,beforeInsert:[],afterInsert:[],beforeRemove:[],afterRemove:[],beforeUpdate:[],afterUpdate:[],beforeUpsert:[],afterUpsert:[],beforeSearch:[],afterSearch:[],beforeInsertMultiple:[],afterInsertMultiple:[],beforeRemoveMultiple:[],afterRemoveMultiple:[],beforeUpdateMultiple:[],afterUpdateMultiple:[],beforeUpsertMultiple:[],afterUpsertMultiple:[],afterCreate:[],formatElapsedTime:S,id:s,indexes:e,plugins:c,version:_o()};g.data={index:g.index.create(g,f,t),docs:g.documentsStore.create(g,f),sorting:g.sorter.create(g,f,t,n
11),pinning:g.pinning.create(f)};for(const I of on)g[I]=(g[I]??[]).concat(rn(g,I));const y=g.afterCreate;return y&&cn(y,g),g}function _o(){return"{{VERSION}}"}function vo(t,e){return t.documentsStore.get(t.data.docs,e)}function Lo(t){return t.documentsStore.count(t.data.docs)}function ko(t,e){return t[1]-e[1]}function Mo(t,e){return e[1]-t[1]}function xo(t="desc"){return t.toLowerCase()==="asc"?ko:Mo}function Co(t,e){let n=t;for(let o=0;o<e.length;o++){if(n==null||typeof n!="object")return;n=n[e[o]]}return n}function $e(t,e,n,o){for(let r=0;r<t.length;r++){const s=t[r];if(!o?.has(s.key)&&n>=s.from&&n<=s.to){const c=e[s.key];c===void 0?e[s.key]=1:(e[s.key]=c+1,o?.add(s.key))}}}function Ge(t,e,n,o){const r=e==="boolean"?"false":"",s=n?.toString()??r;if(o?.has(s))return;const c=t[s];t[s]=c===void 0?1:c+1,o?.add(s)}function je(t){const e={};for(let n=0;n<t.length;n++){const o=t[n];e[`${o.from}-${o.to}`]=0}return e}function Ye(t){const e=Array.from({length:t.length});for(let n=0;n<t.length;n++){const o=t[n];e[n]={from:o.from,to:o.to,key:`${o.from}-${o.to}`}}return e}function Uo(t,e,n,o){const r=o?a=>Co(a,o):a=>a[t];let s={},c,i=()=>s;switch(n){case"number":{const{ranges:a}=e[t],l=Ye(a);s=je(a),c=u=>{const d=r(u);typeof d=="number"&&$e(l,s,d)};break}case"number[]":{const{ranges:a}=e[t],l=Ye(a);s=je(a),c=u=>{const d=r(u);if(!Array.isArray(d))return;const f=new Set;for(let h=0;h<d.length;h++)$e(l,s,d[h],f)};break}case"boolean":case"enum":case"string":{const a=n;if(c=l=>{const u=r(l);Ge(s,a,u)},n==="string"){const l=e[t],u=xo(l.sort),d=l.offset??0,f=l.limit??10;i=()=>Object.fromEntries(Object.entries(s).sort(u).slice(d,d+f))}break}case"boolean[]":case"enum[]":case"string[]":{const a=n==="boolean[]"?"boolean":"string";c=l=>{const u=r(l);if(!Array.isArray(u))return;const d=new Set;for(let f=0;f<u.length;f++)Ge(s,a,u[f],d)};break}default:throw N("FACET_NOT_SUPPORTED",n)}return{values:s,process:c,finalize:i}}function be(t,e,n){const o={},r=Object.keys(n),s=t.index.getSearchablePropertiesWithTypes(t.data.index),c=t.data.docs.docs,i=Array.from({length:r.length});for(let l=0;l<r.length;l++){const u=r[l],d=u.includes(".")?u.split("."):null;i[l]=Uo(u,n,s[u],d),o[u]={count:0,values:i[l].values}}const a=e.length;for(let l=0;l<a;l++){const u=c[e[l][0]];if(u)for(let d=0;d<r.length;d++)i[d].process(u)}for(let l=0;l<r.length;l++){const u=r[l],d=i[l];o[u].count=Object.keys(d.values).length,o[u].values=d.finalize()}return o}const Fo={reducer:(t,e,n,o)=>(e[o]=n,e),getInitialValue:t=>Array.from({length:t})},He=["string","number","boolean"];function we(t,e,n){const o=n.properties,r=o.length,s=t.index.getSearchablePropertiesWithTypes(t.data.index);for(let g=0;g<r;g++){const y=o[g];if(typeof s[y]>"u")throw N("UNKNOWN_GROUP_BY_PROPERTY",y);if(!He.includes(s[y]))throw N("INVALID_GROUP_BY_PROPERTY",y,He.join(", "),s[y])}const c=e.map(([g])=>ge(t.internalDocumentIDStore,g)),i=t.documentsStore.getMultiple(t.data.docs,c),a=i.length,l=n.maxResult||Number.MAX_SAFE_INTEGER,u=[],d={};for(let g=0;g<r;g++){const y=o[g],I={property:y,perValue:{}},b=new Set;for(let w=0;w<a;w++){const T=i[w],A=ot(T,y);if(typeof A>"u")continue;const O=typeof A!="boolean"?A:""+A,P=I.perValue[O]??{indexes:[],count:0};P.count>=l||(P.indexes.push(w),P.count++,I.perValue[O]=P,b.add(A))}u.push(Array.from(b)),d[y]=I}const f=St(u),h=f.length,p=[];for(let g=0;g<h;g++){const y=f[g],I=y.length,b={values:[],indexes:[]},w=[];for(let T=0;T<I;T++){const A=y[T],O=o[T];w.push(d[O].perValue[typeof A!="boolean"?A:""+A].indexes),b.values.push(A)}b.indexes=Mt(w).sort((T,A)=>T-A),b.indexes.length!==0&&p.push(b)}const m=p.length,S=Array.from({length:m});for(let g=0;g<m;g++){const y=p[g],I=n.reduce||Fo,b=y.indexes.map(O=>({id:c[O],score:e[O][1],document:i[O]})),w=I.reducer.bind(null,y.values),T=I.getInitialValue(y.indexes.length),A=b.reduce(w,T);S[g]={values:y.values,result:A}}return S}function St(t,e=0){if(e+1===t.length)return t[e].map(s=>[s]);const n=t[e],o=St(t,e+1),r=[];for(const s of n)for(const c of o){const i=[s];et(i,c),r.push(i)}return r}function Ne(t,e,n,o){const r=yt(e,o);if(r.length===0)return n;const s=r.flatMap(g=>g.consequence.promote);s.sort((g,y)=>g.position-y.position);const c=new Set,i=new Map,a=new Set;for(const g of s){const y=E(t.internalDocumentIDStore,g.doc_id);if(y!==void 0){if(i.has(y)){const I=i.get(y);g.position<I&&i.set(y,g.position);continue}a.has(g.position)||(c.add(y),i.set(y,g.position),a.add(g.position))}}if(i.size===0)return n;const l=new Map;for(const[g,y]of n)l.set(g,y);const u=[];for(const g of n)c.has(g[0])||u.push(g);const d=1e6,f=[];for(const[g,y]of i)l.get(g)!==void 0?f.push([g,d-y]):t.documentsStore.get(t.data.docs,g)&&f.push([g,0]);f.sort((g,y)=>{const I=i.get(g[0])??1/0,b=i.get(y[0])??1/0;return I-b});const h=[],p=new Map;for(const g of f){const y=i.get(g[0]);p.set(y,g)}let m=0,S=0;for(;S<u.length+f.length;)if(p.has(S))h.push(p.get(S)),S++;else if(m<u.length)h.push(u[m]),m++,S++;else break;for(const[g,y]of p.entries())g>=h.length&&h.push(y);return h}function Vo(t,e,n,o,r){const s=t.data.docs,c=new Map,i=[],a=new Set,l=e.length;let u=0;for(let d=0;d<l;d++){const f=e[d];if(typeof f>"u")continue;const[h,p]=f;if(a.has(h))continue;const m=t.documentsStore.get(s,h),S=ot(m,r);if(!(typeof S>"u"||c.has(S))&&(c.set(S,!0),u++,!(u<=n)&&(i.push({id:ge(t.internalDocumentIDStore,h),score:p,document:m}),a.add(h),u>=n+o)))break}return i}function Te(t,e,n,o){const r=t.data.docs,s=[],c=Math.min(n+o,e.length);for(let i=n;i<c;
11i++){const a=e[i];if(typeof a>"u")break;const[l,u]=a,d=t.documentsStore.get(r,l);s.push({id:ge(t.internalDocumentIDStore,l),score:u,document:d})}return s}function It(t,e,n,o){const{term:r,properties:s}=e,c=t.data.index;let i=t.caches.propertiesToSearch;if(!i){const f=t.index.getSearchablePropertiesWithTypes(c);i=t.index.getSearchableProperties(c),i=i.filter(h=>f[h].startsWith("string")),t.caches.propertiesToSearch=i}if(s&&s!=="*"){for(const f of s)if(!i.includes(f))throw N("UNKNOWN_INDEX",f,i.join(", "));i=i.filter(f=>s.includes(f))}const a=Object.keys(e.where??{}).length>0;let l=o;a&&l===void 0&&(l=t.index.searchByWhereClause(c,t.tokenizer,e.where,n));let u;const d=e.threshold!==void 0&&e.threshold!==null?e.threshold:1;if(r||s){const f=Lo(t);if(u=t.index.search(c,r||"",t.tokenizer,n,i,e.exact||!1,e.tolerance||0,e.boost||{},Go(e.relevance),f,l,d),e.exact&&r){const p=r.trim().split(/\s+/).map(m=>new RegExp(`\\b${Bo(m)}\\b`));u=u.filter(([m])=>{const S=t.documentsStore.get(t.data.docs,m);if(!S)return!1;for(const g of i){const y=Wo(S,g);if(typeof y=="string"&&p.every(b=>b.test(y)))return!0}return!1})}}else if(a){const f=$n(c,e.where);f?u=f:u=(l?Array.from(l):[]).map(p=>[+p,0])}else u=Object.keys(t.documentsStore.getAll(t.data.docs)).map(h=>[+h,0]);return u}function Bo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Wo(t,e){const n=e.split(".");let o=t;for(const r of n)if(o&&typeof o=="object"&&r in o)o=o[r];else return;return o}function $o(t,e,n){const o=x();function r(){const i=Object.keys(t.data.index.vectorIndexes),a=e.facets&&Object.keys(e.facets).length>0,{limit:l=10,offset:u=0,distinctOn:d,includeVectors:f=!1}=e,h=e.preflight===!0;let p=It(t,e,n);if(e.sortBy)if(typeof e.sortBy=="function"){const g=p.map(([b])=>b),I=t.documentsStore.getMultiple(t.data.docs,g).map((b,w)=>[p[w][0],p[w][1],b]);I.sort(e.sortBy),p=I.map(([b,w])=>[b,w])}else p=t.sorter.sortBy(t.data.sorting,p,e.sortBy).map(([g,y])=>[E(t.internalDocumentIDStore,g),y]);else p=p.sort(de);p=Ne(t,t.data.pinning,p,e.term);let m;h||(m=d?Vo(t,p,u,l,d):Te(t,p,u,l));const S={elapsed:{formatted:"",raw:0},hits:[],count:p.length};if(typeof m<"u"&&(S.hits=m.filter(Boolean),f||he(S,i)),a){const g=be(t,p,e.facets);S.facets=g}return e.groupBy&&(S.groups=we(t,p,e.groupBy)),S.elapsed=t.formatElapsedTime(x()-o),S}async function s(){t.beforeSearch&&await ye(t.beforeSearch,t,e,n);const i=r();return t.afterSearch&&await me(t.afterSearch,t,e,n,i),i}return t.beforeSearch?.length||t.afterSearch?.length?s():r()}const oe={k:1.2,b:.75,d:.5};function Go(t){const e=t??{};return e.k=e.k??oe.k,e.b=e.b??oe.b,e.d=e.d??oe.d,e}function bt(t,e,n,o){const r=e.vector;if(r&&(!("value"in r)||!("property"in r)))throw N("INVALID_VECTOR_INPUT",Object.keys(r).join(", "));const s=t.data.index.vectorIndexes[r.property];if(!s)throw N("UNKNOWN_VECTOR_PROPERTY",r.property);const c=s.node.size;if(r?.value.length!==c)throw r?.property===void 0||r?.value.length===void 0?N("INVALID_INPUT_VECTOR","undefined",c,"undefined"):N("INVALID_INPUT_VECTOR",r.property,c,r.value.length);const i=t.data.index;let a=o;return Object.keys(e.where??{}).length>0&&a===void 0&&(a=t.index.searchByWhereClause(i,t.tokenizer,e.where,n)),s.node.find(r.value,e.similarity??In,a)}function jo(t,e,n="english"){const o=x();function r(){let i=bt(t,e,n).sort(de);i=Ne(t,t.data.pinning,i,void 0);let a=[];e.facets&&Object.keys(e.facets).length>0&&(a=be(t,i,e.facets));const u=e.vector.property,d=e.includeVectors??!1,f=e.limit??10,h=e.offset??0,p=Te(t,i,h,f).filter(
11Boolean);let m=[];e.groupBy&&(m=we(t,i,e.groupBy));const g=x()-o,y={count:i.length,hits:p,elapsed:{raw:Number(g),formatted:fe(g)},...a?{facets:a}:{},...m?{groups:m}:{}};return d||he(y,[u]),y}async function s(){t.beforeSearch&&await ye(t.beforeSearch,t,e,n);const i=r();return t.afterSearch&&await me(t.afterSearch,t,e,n,i),i}return t.beforeSearch?.length||t.afterSearch?.length?s():r()}function Yo(t,e,n){const o=Object.keys(e.where??{}).length>0;let r;o&&(r=t.index.searchByWhereClause(t.data.index,t.tokenizer,e.where,n));const c=!!e.term||!!e.properties?It(t,e,n,r):[],i=bt(t,e,n,r),a=e.hybridWeights;return zo(c,i,e.term??"",a)}function Ho(t,e,n){const o=x();function r(){let i=Yo(t,e,n);i=Ne(t,t.data.pinning,i,e.term);let a;e.facets&&Object.keys(e.facets).length>0&&(a=be(t,i,e.facets));let u;e.groupBy&&(u=we(t,i,e.groupBy));const d=e.offset??0,f=e.limit??10,h=Te(t,i,d,f).filter(Boolean),p=x(),m={count:i.length,elapsed:{raw:Number(p-o),formatted:fe(p-o)},hits:h,...a?{facets:a}:{},...u?{groups:u}:{}};if(!(e.includeVectors??!1)){const g=Object.keys(t.data.index.vectorIndexes);he(m,g)}return m}async function s(){t.beforeSearch&&await ye(t.beforeSearch,t,e,n);const i=r();return t.afterSearch&&await me(t.afterSearch,t,e,n,i),i}return t.beforeSearch?.length||t.afterSearch?.length?s():r()}function Je(t){let e=0;const n=t.length;for(let o=0;o<n;o++){const r=t[o][1];r>e&&(e=r)}return e}function ze(t,e){return e>0?t/e:0}function Jo(t,e){return(n,o)=>n*t+o*e}function zo(t,e,n,o){const r=Je(t),s=Je(e),c=o&&typeof o.text=="number"&&typeof o.vector=="number",{text:i,vector:a}=c?o:Ko(),l=new Map,u=t.length,d=Jo(i,a);for(let h=0;h<u;h++){const[p,m]=t[h],S=ze(m,r),g=d(S,0);l.set(p,g)}const f=e.length;for(let h=0;h<f;h++){const[p,m]=e[h],S=ze(m,s),g=l.get(p)??0;l.set(p,g+d(0,S))}return[...l].sort(de)}function Ko(t){return{text:.5,vector:.5}}function wt(t,e,n){const o=e.mode??Ae;if(o===Ae)return $o(t,e,n);if(o===Ot)return jo(t,e);if(o===At)return Ho(t,e);throw N("INVALID_SEARCH_MODE",o)}function Ke(t,e){t.internalDocumentIDStore.load(t,e.internalDocumentIDStore),t.data.index=t.index.load(t.internalDocumentIDStore,e.index,t.indexes),t.data.docs=t.documentsStore.load(t.internalDocumentIDStore,e.docs),t.data.sorting=t.sorter.load(t.internalDocumentIDStore,e.sorting),t.data.pinning=t.pinning.load(t.internalDocumentIDStore,e.pinning),t.tokenizer.language=e.language}async function qo(t,e,n={},o){const r=Xe(e);return(await wt(t,{term:e,tolerance:1,...n,boost:{title:2,..."boost"in n?n.boost:void 0},where:Ze({locale:o?{eq:o}:void 0,...n.where})})).hits.map(s=>({type:"page",content:r.highlightMarkdown(s.document.title),breadcrumbs:s.document.breadcrumbs,id:s.document.url,url:s.document.url}))}async function Xo(t,e,n=[],{mode:o="fulltext",...r}={},s){typeof n=="string"&&(n=[n]);const c={limit:60,mode:o,...r,where:Ze({tags:n.length>0?{containsAll:n}:void 0,locale:s?{eq:s}:void 0,...r.where}),groupBy:{properties:["page_id"],maxResult:8,...r.groupBy},properties:o==="fulltext"?["content"]:["content","embeddings"]};e.length>0&&(c.term=e);const i=Xe(e),a=await wt(t,c),l=[];for(const u of a.groups??[]){const d=u.values[0],f=vo(t,d);if(f){l.push({id:d,type:"page",content:i.highlightMarkdown(f.content),breadcrumbs:f.breadcrumbs,url:f.url});for(const h of u.result)h.document.type!=="page"&&l.push({id:h.document.id.toString(),content:i.highlightMarkdown(h.document.content),breadcrumbs:h.document.breadcrumbs,type:h.document.type,url:h.document.url})}}return typeof c.limit=="number"&&l.length>c.limit?l.slice(0,c.limit):l}const qe=new Map;async function Zo(t,e=()=>Ro({schema:{_:"string"}})){const n=await fetch(t);if(!n.ok)throw new Error(`failed to fetch exported search indexes from ${t}, make sure the search database is exported and available for client.`);const o=await n.json(),r=new Map;if(o.type==="i18n")return await Promise.all(Object.entries(o.data).map(async([c,i])=>{const a=await e(c);Ke(a,i),r.set(c,{type:i.type,db:a})})),{map:r,unified:!1,i18n:!0};const s=await e();return Ke(s,o),r.set("",{type:o.type,db:s}),{map:r,unified:!0,i18n:o.i18n===!0}}function Qo({from:t=Nt(Tt,"/api/search"),initDB:e,initOrama:n}){const o=t,r=qe.get(o);if(r)return r;const s=Zo(t,e??n);return qe.set(o,s),s}function er(t={}){const{tag:e,locale:n,search:o}=t;return{deps:[e,n],async search(r){const{map:s,unified:c,i18n:i}=await Qo(t);let a,l;return c?(a=s.get(""),i&&(l=n)):(a=s.get(n??""),a||(console.warn(`failed to find search data for "${n}", available: ${Array.from(s.keys())}.`),a=s.values().next().value)),a?a.type==="simple"?qo(a.db,r,o,l):Xo(a.db,r,e,o,l):[]}}}const ir=er;export{ir as oramaStaticClient,er as staticClient};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.