minotor 9.0.2 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1828,7 +1828,6 @@ class InvalidZone extends Zone {
1828
1828
  * @private
1829
1829
  */
1830
1830
 
1831
-
1832
1831
  function normalizeZone(input, defaultZone) {
1833
1832
  if (isUndefined(input) || input === null) {
1834
1833
  return defaultZone;
@@ -2333,7 +2332,6 @@ function hasInvalidTimeData(obj) {
2333
2332
  it up into, say, parsingUtil.js and basicUtil.js and so on. But they are divided up by feature area.
2334
2333
  */
2335
2334
 
2336
-
2337
2335
  /**
2338
2336
  * @private
2339
2337
  */
@@ -10121,7 +10119,8 @@ function makeInt64Support() {
10121
10119
  typeof dv.getBigUint64 === "function" &&
10122
10120
  typeof dv.setBigInt64 === "function" &&
10123
10121
  typeof dv.setBigUint64 === "function" &&
10124
- (typeof process != "object" ||
10122
+ (!!globalThis.Deno ||
10123
+ typeof process != "object" ||
10125
10124
  typeof process.env != "object" ||
10126
10125
  process.env.BUF_BIGINT_DISABLE !== "1");
10127
10126
  if (ok) {
@@ -11333,7 +11332,7 @@ function sqDist(ax, ay, bx, by) {
11333
11332
  return dx * dx + dy * dy;
11334
11333
  }
11335
11334
 
11336
- const xt="ENTRIES",B="KEYS",G="VALUES",g="";class V{set;_type;_path;constructor(e,n){const o=e._tree,s=Array.from(o.keys());this.set=e,this._type=n,this._path=s.length>0?[{node:o,keys:s}]:[];}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return {done:true,value:void 0};const{node:e,keys:n}=z(this._path);if(z(n)===g)return {done:false,value:this.result()};const o=e.get(z(n));return this._path.push({node:o,keys:Array.from(o.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=z(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack());}key(){return this.set._prefix+this._path.map(({keys:e})=>z(e)).filter(e=>e!==g).join("")}value(){return z(this._path).node.get(g)}result(){switch(this._type){case G:return this.value();case B:return this.key();default:return [this.key(),this.value()]}}[Symbol.iterator](){return this}}const z=t=>t[t.length-1],zt=(t,e,n)=>{const o=new Map;if(typeof e!="string")return o;const s=e.length+1,r=s+n,i=new Uint8Array(r*s).fill(n+1);for(let c=0;c<s;++c)i[c]=c;for(let c=1;c<r;++c)i[c*s]=c;return K(t,e,n,o,i,1,s,""),o},K=(t,e,n,o,s,r,i,c)=>{const u=r*i;t:for(const d of t.keys())if(d===g){const a=s[u-1];a<=n&&o.set(c,[t.get(d),a]);}else {let a=r;for(let h=0;h<d.length;++h,++a){const f=d[h],_=i*a,p=_-i;let l=s[_];const m=Math.max(0,a-n-1),y=Math.min(i-1,a+n);for(let w=m;w<y;++w){const C=f!==e[w],O=s[p+w]+ +C,b=s[p+w+1]+1,x=s[_+w]+1,S=s[_+w+1]=Math.min(O,b,x);S<l&&(l=S);}if(l>n)continue t}K(t.get(d),e,n,o,s,a,i,c+d);}};class I{_tree;_prefix;_size=void 0;constructor(e=new Map,n=""){this._tree=e,this._prefix=n;}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[n,o]=v(this._tree,e.slice(this._prefix.length));if(n===void 0){const[s,r]=L(o);for(const i of s.keys())if(i!==g&&i.startsWith(r)){const c=new Map;return c.set(i.slice(r.length),s.get(i)),new I(c,e)}}return new I(n,e)}clear(){this._size=void 0,this._tree.clear();}delete(e){return this._size=void 0,St(this._tree,e)}entries(){return new V(this,xt)}forEach(e){for(const[n,o]of this)e(n,o,this);}fuzzyGet(e,n){return zt(this._tree,e,n)}get(e){const n=T(this._tree,e);return n!==void 0?n.get(g):void 0}has(e){return T(this._tree,e)?.has(g)??false}keys(){return new V(this,B)}set(e,n){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,M(this._tree,e).set(g,n),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const o=M(this._tree,e);return o.set(g,n(o.get(g))),this}fetch(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const o=M(this._tree,e);let s=o.get(g);return s===void 0&&o.set(g,s=n()),s}values(){return new V(this,G)}[Symbol.iterator](){return this.entries()}static from(e){const n=new I;for(const[o,s]of e)n.set(o,s);return n}static fromObject(e){return I.from(Object.entries(e))}}const v=(t,e,n=[])=>{if(e.length===0||t==null)return [t,n];for(const o of t.keys())if(o!==g&&e.startsWith(o))return n.push([t,o]),v(t.get(o),e.slice(o.length),n);return n.push([t,e]),v(void 0,"",n)},T=(t,e)=>{if(e.length===0||!t)return t;for(const n of t.keys())if(n!==g&&e.startsWith(n))return T(t.get(n),e.slice(n.length))},M=(t,e)=>{const n=e.length;t:for(let o=0;t&&o<n;){for(const r of t.keys())if(r!==g&&e[o]===r[0]){const i=Math.min(n-o,r.length);let c=1;for(;c<i&&e[o+c]===r[c];)++c;const u=t.get(r);if(c===r.length)t=u;else {const d=new Map;d.set(r.slice(c),u),t.set(e.slice(o,o+c),d),t.delete(r),t=d;}o+=c;continue t}const s=new Map;return t.set(e.slice(o),s),s}return t},St=(t,e)=>{const[n,o]=v(t,e);if(n!==void 0){if(n.delete(g),n.size===0)Q(o);else if(n.size===1){const[s,r]=n.entries().next().value;Y(o,s,r);}}},Q=t=>{if(t.length===0)return;const[e,n]=L(t);if(e.delete(n),e.size===0)Q(t.slice(0,-1));else if(e.size===1){const[o,s]=e.entries().next().value;o!==g&&Y(t.slice(0,-1),o,s);}},Y=(t,e,n)=>{if(t.length===0)return;const[o,s]=L(t);o.set(s+e,n),o.delete(s);},L=t=>t[t.length-1],Z=(t,e)=>t._idToShortId.has(e),vt=/[\n\r\p{Z}\p{P}]+/u,D="or",H="and",Ft="and_not",kt=(t,e)=>{t.includes(e)||t.push(e);},tt=(t,e)=>{for(const n of e)t.includes(n)||t.push(n);},et=({score:t},{score:e})=>e-t,nt=()=>new Map,E=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0,ot={[D]:(t,e)=>{for(const n of e.keys()){const o=t.get(n);if(o==null)t.set(n,e.get(n));else {const{score:s,terms:r,match:i}=e.get(n);o.score=o.score+s,o.match=Object.assign(o.match,i),tt(o.terms,r);}}return t},[H]:(t,e)=>{const n=new Map;for(const o of e.keys()){const s=t.get(o);if(s==null)continue;const{score:r,terms:i,match:c}=e.get(o);tt(s.terms,i),n.set(o,{score:s.score+r,terms:s.terms,match:Object.assign(s.match,c)});}return n},[Ft]:(t,e)=>{for(const n of e.keys())t.delete(n);return t}},Ct=(t,e,n,o,s,r)=>{const{k:i,b:c,d:u}=r;return Math.log(1+(n-e+.5)/(e+.5))*(u+t*(i+1)/(t+i*(1-c+c*o/s)))},Ot=t=>(e,n,o)=>({term:e,fuzzy:typeof t.fuzzy=="function"?t.fuzzy(e,n,o):t.fuzzy??false,prefix:typeof t.prefix=="function"?t.prefix(e,n,o):t.prefix===true,termBoost:typeof t.boostTerm=="function"?t.boostTerm(e,n,o):1}),st=(t,e,n,o)=>{for(const s of Object.keys(t._fieldIds))if(t._fieldIds[s]===n){t._options.logger("warn",`SlimSearch: document with ID ${t._documentIds.get(e)} has changed before removal: term "${o}" was not present in field "${s}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}},it=(t,e,n,o)=>{const s=t._index.fetch(o,nt);let r=s.get(e);if(r==null)r=new Map,r.set(n,1),s.set(e,r);else {const i=r.get(n);r.set(n,(i??0)+1);}},A=(t,e,n,o)=>{if(!t._index.has(o)){st(t,n,e,o);return}const s=t._index.fetch(o,nt),r=s.get(e),i=r?.get(n);!r||typeof i>"u"?st(t,n,e,o):i<=1?r.size<=1?s.delete(e):r.delete(n):r.set(n,i-1),t._index.get(o).size===0&&t._index.delete(o);},Vt=(t,e,n,o,s)=>{let r=t._fieldLength.get(e);r==null&&t._fieldLength.set(e,r=[]),r[n]=s;const i=(t._avgFieldLength[n]||0)*o+s;t._avgFieldLength[n]=i/(o+1);},Tt=(t,e)=>{const n=t._nextId;return t._idToShortId.set(e,n),t._documentIds.set(n,e),t._documentCount+=1,t._nextId+=1,n},Mt=(t,e,n)=>{const{storeFields:o,extractField:s}=t._options;if(o?.length===0)return;let r=t._storedFields.get(e);r===void 0&&t._storedFields.set(e,r={});for(const i of o){const c=s(n,i);c!=null&&(r[i]=c);}},j=(t,e)=>{const{extractField:n,tokenize:o,processTerm:s,fields:r,idField:i}=t._options,c=n(e,i);if(c==null)throw new Error(`SlimSearch: document does not have ID field "${i}"`);if(Z(t,c))throw new Error(`SlimSearch: duplicate ID ${c}`);const u=Tt(t,c);Mt(t,u,e);for(const d of r){const a=n(e,d);if(a==null)continue;const h=o(a.toString(),d),f=t._fieldIds[d],_=new Set(h).size;Vt(t,u,f,t._documentCount-1,_);for(const p of h){const l=s(p,d);if(Array.isArray(l))for(const m of l)it(t,f,u,m);else l&&it(t,f,u,l);}}},q=(t,e)=>{for(const n of e)j(t,n);},Dt={k:1.2,b:.7,d:.5},$={idField:"id",extractField:(t,e)=>t[e],tokenize:t=>t.split(vt),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{console?.[t]?.(e);},autoVacuum:true},rt={combineWith:D,prefix:false,fuzzy:false,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Dt},Et={combineWith:H,prefix:(t,e,n)=>e===n.length-1},N={batchSize:1e3,batchWait:10},W={minDirtFactor:.1,minDirtCount:20},P={...N,...W},R=Symbol("*"),jt=(t,e)=>{const n=new Map,o={...t._options.searchOptions,...e};for(const[s,r]of t._documentIds){const i=o.boostDocument?o.boostDocument(r,"",t._storedFields.get(s)):1;n.set(s,{score:i,terms:[],match:{}});}return n},ct=(t,e=D)=>{if(t.length===0)return new Map;const n=e.toLowerCase();if(!(n in ot))throw new Error(`Invalid combination operator: ${e}`);return t.reduce(ot[n])},J=(t,e,n,o,s,r,i,c,u,d=new Map)=>{if(r==null)return d;for(const a of Object.keys(i)){const h=i[a],f=t._fieldIds[a],_=r.get(f);if(_==null)continue;let p=_.size;const l=t._avgFieldLength[f];for(const m of _.keys()){if(!t._documentIds.has(m)){A(t,f,m,n),p-=1;continue}const y=c?c(t._documentIds.get(m),n,t._storedFields.get(m)):1;if(!y)continue;const w=_.get(m),C=t._fieldLength.get(m)[f],O=Ct(w,p,t._documentCount,C,l,u),b=o*s*h*y*O,x=d.get(m);if(x){x.score+=b,kt(x.terms,e);const S=E(x.match,n);S?S.push(a):x.match[n]=[a];}else d.set(m,{score:b,terms:[e],match:{[n]:[a]}});}}return d},qt=(t,e,n)=>{const o={...t._options.searchOptions,...n},s=(o.fields??t._options.fields).reduce((l,m)=>({...l,[m]:E(o.boost,m)||1}),{}),{boostDocument:r,weights:i,maxFuzzy:c,bm25:u}=o,{fuzzy:d,prefix:a}={...rt.weights,...i},h=t._index.get(e.term),f=J(t,e.term,e.term,1,e.termBoost,h,s,r,u);let _,p;if(e.prefix&&(_=t._index.atPrefix(e.term)),e.fuzzy){const l=e.fuzzy===true?.2:e.fuzzy,m=l<1?Math.min(c,Math.round(e.term.length*l)):l;m&&(p=t._index.fuzzyGet(e.term,m));}if(_)for(const[l,m]of _){const y=l.length-e.term.length;if(!y)continue;p?.delete(l);const w=a*l.length/(l.length+.3*y);J(t,e.term,l,w,e.termBoost,m,s,r,u,f);}if(p)for(const l of p.keys()){const[m,y]=p.get(l);if(!y)continue;const w=d*l.length/(l.length+y);J(t,e.term,l,w,e.termBoost,m,s,r,u,f);}return f},ut=(t,e,n={})=>{if(e===R)return jt(t,n);if(typeof e!="string"){const a={...n,...e,queries:void 0},h=e.queries.map(f=>ut(t,f,a));return ct(h,a.combineWith)}const{tokenize:o,processTerm:s,searchOptions:r}=t._options,i={tokenize:o,processTerm:s,...r,...n},{tokenize:c,processTerm:u}=i,d=c(e).flatMap(a=>u(a)).filter(a=>!!a).map(Ot(i)).map(a=>qt(t,a,i));return ct(d,i.combineWith)},dt=(t,e,n={})=>{const{searchOptions:o}=t._options,s={...o,...n},r=ut(t,e,n),i=[];for(const[c,{score:u,terms:d,match:a}]of r){const h=d.length||1,f={id:t._documentIds.get(c),score:u*h,terms:Object.keys(a),queryTerms:d,match:a};Object.assign(f,t._storedFields.get(c)),(s.filter==null||s.filter(f))&&i.push(f);}return e===R&&s.boostDocument==null||i.sort(et),i};class Nt{_options;_index;_documentCount;_documentIds;_idToShortId;_fieldIds;_fieldLength;_avgFieldLength;_nextId;_storedFields;_dirtCount;_currentVacuum;_enqueuedVacuum;_enqueuedVacuumConditions;constructor(e){if(!e?.fields)throw new Error('SlimSearch: option "fields" must be provided');const n=e.autoVacuum==null||e.autoVacuum===true?P:e.autoVacuum;this._options={...$,...e,autoVacuum:n,searchOptions:{...rt,...e.searchOptions},autoSuggestOptions:{...Et,...e.autoSuggestOptions}},this._index=new I,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=W,this.addFields(this._options.fields);}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}get documentCount(){return this._documentCount}get termCount(){return this._index.size}toJSON(){const e=[];for(const[n,o]of this._index){const s={};for(const[r,i]of o)s[r]=Object.fromEntries(i);e.push([n,s]);}return {documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,version:2}}addFields(e){for(let n=0;n<e.length;n++)this._fieldIds[e[n]]=n;}}const lt=t=>new Nt(t);
11335
+ const It="ENTRIES",U="KEYS",B="VALUES";class L{set;_type;_path;constructor(e,n){const o=e._tree,s=Array.from(o.keys());this.set=e,this._type=n,this._path=s.length>0?[{node:o,keys:s}]:[];}next(){const e=this.dive();return this.backtrack(),e}dive(){if(this._path.length===0)return {done:true,value:void 0};const{node:e,keys:n}=x(this._path);if(x(n)==="")return {done:false,value:this.result()};const o=e.get(x(n));return this._path.push({node:o,keys:Array.from(o.keys())}),this.dive()}backtrack(){if(this._path.length===0)return;const e=x(this._path).keys;e.pop(),!(e.length>0)&&(this._path.pop(),this.backtrack());}key(){return this.set._prefix+this._path.map(({keys:e})=>x(e)).filter(e=>e!=="").join("")}value(){return x(this._path).node.get("")}result(){switch(this._type){case B:return this.value();case U:return this.key();default:return [this.key(),this.value()]}}[Symbol.iterator](){return this}}const x=t=>t[t.length-1],xt=(t,e,n)=>{const o=new Map;if(typeof e!="string")return o;const s=e.length+1,r=s+n,i=new Uint8Array(r*s).fill(n+1);for(let c=0;c<s;++c)i[c]=c;for(let c=1;c<r;++c)i[c*s]=c;return G(t,e,n,o,i,1,s,""),o},G=(t,e,n,o,s,r,i,c)=>{const a=r*i;t:for(const d of t.keys())if(d===""){const u=s[a-1];u<=n&&o.set(c,[t.get(d),u]);}else {let u=r;for(let f=0;f<d.length;++f,++u){const m=d[f],_=i*u,g=_-i;let h=s[_];const l=Math.max(0,u-n-1),p=Math.min(i-1,u+n);for(let w=l;w<p;++w){const k=m!==e[w],C=s[g+w]+ +k,z=s[g+w+1]+1,I=s[_+w]+1,F=s[_+w+1]=Math.min(C,z,I);F<h&&(h=F);}if(h>n)continue t}G(t.get(d),e,n,o,s,u,i,c+d);}};class y{_tree;_prefix;_size=void 0;constructor(e=new Map,n=""){this._tree=e,this._prefix=n;}atPrefix(e){if(!e.startsWith(this._prefix))throw new Error("Mismatched prefix");const[n,o]=S(this._tree,e.slice(this._prefix.length));if(n===void 0){const[s,r]=A(o);for(const i of s.keys())if(i!==""&&i.startsWith(r)){const c=new Map;return c.set(i.slice(r.length),s.get(i)),new y(c,e)}}return new y(n,e)}clear(){this._size=void 0,this._tree.clear();}delete(e){return this._size=void 0,Ft(this._tree,e)}entries(){return new L(this,It)}forEach(e){for(const[n,o]of this)e(n,o,this);}fuzzyGet(e,n){return xt(this._tree,e,n)}get(e){const n=O(this._tree,e);return n!==void 0?n.get(""):void 0}has(e){return O(this._tree,e)?.has("")??false}keys(){return new L(this,U)}set(e,n){if(typeof e!="string")throw new Error("key must be a string");return this._size=void 0,E(this._tree,e).set("",n),this}get size(){if(this._size)return this._size;this._size=0;const e=this.entries();for(;!e.next().done;)this._size+=1;return this._size}update(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const o=E(this._tree,e);return o.set("",n(o.get(""))),this}fetch(e,n){if(typeof e!="string")throw new Error("key must be a string");this._size=void 0;const o=E(this._tree,e);let s=o.get("");return s===void 0&&o.set("",s=n()),s}values(){return new L(this,B)}[Symbol.iterator](){return this.entries()}static from(e){const n=new y;for(const[o,s]of e)n.set(o,s);return n}static fromObject(e){return y.from(Object.entries(e))}}const S=(t,e,n=[])=>{if(e.length===0||t==null)return [t,n];for(const o of t.keys())if(o!==""&&e.startsWith(o))return n.push([t,o]),S(t.get(o),e.slice(o.length),n);return n.push([t,e]),S(void 0,"",n)},O=(t,e)=>{if(e.length===0||!t)return t;for(const n of t.keys())if(n!==""&&e.startsWith(n))return O(t.get(n),e.slice(n.length))},E=(t,e)=>{const n=e.length;t:for(let o=0;t&&o<n;){for(const r of t.keys())if(r!==""&&e[o]===r[0]){const i=Math.min(n-o,r.length);let c=1;for(;c<i&&e[o+c]===r[c];)++c;const a=t.get(r);if(c===r.length)t=a;else {const d=new Map;d.set(r.slice(c),a),t.set(e.slice(o,o+c),d),t.delete(r),t=d;}o+=c;continue t}const s=new Map;return t.set(e.slice(o),s),s}return t},Ft=(t,e)=>{const[n,o]=S(t,e);if(n!==void 0){if(n.delete(""),n.size===0)K(o);else if(n.size===1){const[s,r]=n.entries().next().value;Q(o,s,r);}}},K=t=>{if(t.length===0)return;const[e,n]=A(t);if(e.delete(n),e.size===0)K(t.slice(0,-1));else if(e.size===1){const[o,s]=e.entries().next().value;o!==""&&Q(t.slice(0,-1),o,s);}},Q=(t,e,n)=>{if(t.length===0)return;const[o,s]=A(t);o.set(s+e,n),o.delete(s);},A=t=>t[t.length-1],Y=(t,e)=>t._idToShortId.has(e),St=/[\n\r\p{Z}\p{P}]+/u,V="or",Z="and",bt="and_not",vt=(t,e)=>{t.includes(e)||t.push(e);},X=(t,e)=>{for(const n of e)t.includes(n)||t.push(n);},tt=({score:t},{score:e})=>e-t,et=()=>new Map,T=(t,e)=>Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0,nt={[V]:(t,e)=>{for(const n of e.keys()){const o=t.get(n);if(o==null)t.set(n,e.get(n));else {const{score:s,terms:r,match:i}=e.get(n);o.score=o.score+s,o.match=Object.assign(o.match,i),X(o.terms,r);}}return t},[Z]:(t,e)=>{const n=new Map;for(const o of e.keys()){const s=t.get(o);if(s==null)continue;const{score:r,terms:i,match:c}=e.get(o);X(s.terms,i),n.set(o,{score:s.score+r,terms:s.terms,match:Object.assign(s.match,c)});}return n},[bt]:(t,e)=>{for(const n of e.keys())t.delete(n);return t}},kt=(t,e,n,o,s,r)=>{const{k:i,b:c,d:a}=r;return Math.log(1+(n-e+.5)/(e+.5))*(a+t*(i+1)/(t+i*(1-c+c*o/s)))},Ct=t=>(e,n,o)=>({term:e,fuzzy:typeof t.fuzzy=="function"?t.fuzzy(e,n,o):t.fuzzy??false,prefix:typeof t.prefix=="function"?t.prefix(e,n,o):t.prefix===true,termBoost:typeof t.boostTerm=="function"?t.boostTerm(e,n,o):1}),ot=(t,e,n,o)=>{for(const s of Object.keys(t._fieldIds))if(t._fieldIds[s]===n){t._options.logger("warn",`SlimSearch: document with ID ${t._documentIds.get(e)} has changed before removal: term "${o}" was not present in field "${s}". Removing a document after it has changed can corrupt the index!`,"version_conflict");return}},st=(t,e,n,o)=>{const s=t._index.fetch(o,et);let r=s.get(e);if(r==null)r=new Map,r.set(n,1),s.set(e,r);else {const i=r.get(n);r.set(n,(i??0)+1);}},M=(t,e,n,o)=>{if(!t._index.has(o)){ot(t,n,e,o);return}const s=t._index.fetch(o,et),r=s.get(e),i=r?.get(n);!r||typeof i>"u"?ot(t,n,e,o):i<=1?r.size<=1?s.delete(e):r.delete(n):r.set(n,i-1),t._index.get(o).size===0&&t._index.delete(o);},Lt=(t,e,n,o,s)=>{let r=t._fieldLength.get(e);r==null&&t._fieldLength.set(e,r=[]),r[n]=s;const i=(t._avgFieldLength[n]||0)*o+s;t._avgFieldLength[n]=i/(o+1);},Ot=(t,e)=>{const n=t._nextId;return t._idToShortId.set(e,n),t._documentIds.set(n,e),t._documentCount+=1,t._nextId+=1,n},Et=(t,e,n)=>{const{storeFields:o,extractField:s}=t._options;if(o?.length===0)return;let r=t._storedFields.get(e);r===void 0&&t._storedFields.set(e,r={});for(const i of o){const c=s(n,i);c!=null&&(r[i]=c);}},D=(t,e)=>{const{extractField:n,stringifyField:o,tokenize:s,processTerm:r,fields:i,idField:c}=t._options,a=n(e,c);if(a==null)throw new Error(`SlimSearch: document does not have ID field "${c}"`);if(Y(t,a))throw new Error(`SlimSearch: duplicate ID ${a}`);const d=Ot(t,a);Et(t,d,e);for(const u of i){const f=n(e,u);if(f==null)continue;const m=s(o(f,u),u),_=t._fieldIds[u],g=new Set(m).size;Lt(t,d,_,t._documentCount-1,g);for(const h of m){const l=r(h,u);if(Array.isArray(l))for(const p of l)st(t,_,d,p);else l&&st(t,_,d,l);}}},j=(t,e)=>{for(const n of e)D(t,n);},Vt={k:1.2,b:.7,d:.5},q={idField:"id",extractField:(t,e)=>t[e],stringifyField:t=>t.toString(),tokenize:t=>t.split(St),processTerm:t=>t.toLowerCase(),fields:void 0,searchOptions:void 0,storeFields:[],logger:(t,e)=>{console?.[t]?.(e);},autoVacuum:true},it={combineWith:V,prefix:false,fuzzy:false,maxFuzzy:6,boost:{},weights:{fuzzy:.45,prefix:.375},bm25:Vt},Tt={combineWith:Z,prefix:(t,e,n)=>e===n.length-1},$={batchSize:1e3,batchWait:10},N={minDirtFactor:.1,minDirtCount:20},W={...$,...N},P=Symbol("*"),Dt=(t,e)=>{const n=new Map,o={...t._options.searchOptions,...e};for(const[s,r]of t._documentIds){const i=o.boostDocument?o.boostDocument(r,"",t._storedFields.get(s)):1;n.set(s,{score:i,terms:[],match:{}});}return n},rt=(t,e=V)=>{if(t.length===0)return new Map;const n=e.toLowerCase();if(!(n in nt))throw new Error(`Invalid combination operator: ${e}`);return t.reduce(nt[n])},R=(t,e,n,o,s,r,i,c,a,d=new Map)=>{if(r==null)return d;for(const u of Object.keys(i)){const f=i[u],m=t._fieldIds[u],_=r.get(m);if(_==null)continue;let g=_.size;const h=t._avgFieldLength[m];for(const l of _.keys()){if(!t._documentIds.has(l)){M(t,m,l,n),g-=1;continue}const p=c?c(t._documentIds.get(l),n,t._storedFields.get(l)):1;if(!p)continue;const w=_.get(l),k=t._fieldLength.get(l)[m],C=kt(w,g,t._documentCount,k,h,a),z=o*s*f*p*C,I=d.get(l);if(I){I.score+=z,vt(I.terms,e);const F=T(I.match,n);F?F.push(u):I.match[n]=[u];}else d.set(l,{score:z,terms:[e],match:{[n]:[u]}});}}return d},jt=(t,e,n)=>{const o={...t._options.searchOptions,...n},s=(o.fields??t._options.fields).reduce((h,l)=>({...h,[l]:T(o.boost,l)||1}),{}),{boostDocument:r,weights:i,maxFuzzy:c,bm25:a}=o,{fuzzy:d,prefix:u}={...it.weights,...i},f=t._index.get(e.term),m=R(t,e.term,e.term,1,e.termBoost,f,s,r,a);let _,g;if(e.prefix&&(_=t._index.atPrefix(e.term)),e.fuzzy){const h=e.fuzzy===true?.2:e.fuzzy,l=h<1?Math.min(c,Math.round(e.term.length*h)):h;l&&(g=t._index.fuzzyGet(e.term,l));}if(_)for(const[h,l]of _){const p=h.length-e.term.length;if(!p)continue;g?.delete(h);const w=u*h.length/(h.length+.3*p);R(t,e.term,h,w,e.termBoost,l,s,r,a,m);}if(g)for(const h of g.keys()){const[l,p]=g.get(h);if(!p)continue;const w=d*h.length/(h.length+p);R(t,e.term,h,w,e.termBoost,l,s,r,a,m);}return m},ct=(t,e,n={})=>{if(e===P)return Dt(t,n);if(typeof e!="string"){const u={...n,...e,queries:void 0},f=e.queries.map(m=>ct(t,m,u));return rt(f,u.combineWith)}const{tokenize:o,processTerm:s,searchOptions:r}=t._options,i={tokenize:o,processTerm:s,...r,...n},{tokenize:c,processTerm:a}=i,d=c(e).flatMap(u=>a(u)).filter(u=>!!u).map(Ct(i)).map(u=>jt(t,u,i));return rt(d,i.combineWith)},ut=(t,e,n={})=>{const{searchOptions:o}=t._options,s={...o,...n},r=ct(t,e,n),i=[];for(const[c,{score:a,terms:d,match:u}]of r){const f=d.length||1,m={id:t._documentIds.get(c),score:a*f,terms:Object.keys(u),queryTerms:d,match:u};Object.assign(m,t._storedFields.get(c)),(s.filter==null||s.filter(m))&&i.push(m);}return e===P&&s.boostDocument==null||i.sort(tt),i};class $t{_options;_index;_documentCount;_documentIds;_idToShortId;_fieldIds;_fieldLength;_avgFieldLength;_nextId;_storedFields;_dirtCount;_currentVacuum;_enqueuedVacuum;_enqueuedVacuumConditions;constructor(e){if(!e?.fields)throw new Error('SlimSearch: option "fields" must be provided');const n=e.autoVacuum==null||e.autoVacuum===true?W:e.autoVacuum;this._options={...q,...e,autoVacuum:n,searchOptions:{...it,...e.searchOptions},autoSuggestOptions:{...Tt,...e.autoSuggestOptions}},this._index=new y,this._documentCount=0,this._documentIds=new Map,this._idToShortId=new Map,this._fieldIds={},this._fieldLength=new Map,this._avgFieldLength=[],this._nextId=0,this._storedFields=new Map,this._dirtCount=0,this._currentVacuum=null,this._enqueuedVacuum=null,this._enqueuedVacuumConditions=N,this.addFields(this._options.fields);}get isVacuuming(){return this._currentVacuum!=null}get dirtCount(){return this._dirtCount}get dirtFactor(){return this._dirtCount/(1+this._documentCount+this._dirtCount)}get documentCount(){return this._documentCount}get termCount(){return this._index.size}toJSON(){const e=[];for(const[n,o]of this._index){const s={};for(const[r,i]of o)s[r]=Object.fromEntries(i);e.push([n,s]);}return {documentCount:this._documentCount,nextId:this._nextId,documentIds:Object.fromEntries(this._documentIds),fieldIds:this._fieldIds,fieldLength:Object.fromEntries(this._fieldLength),averageFieldLength:this._avgFieldLength,storedFields:Object.fromEntries(this._storedFields),dirtCount:this._dirtCount,index:e,version:2}}addFields(e){for(let n=0;n<e.length;n++)this._fieldIds[e[n]]=n;}}const at=t=>new $t(t);
11337
11336
 
11338
11337
  /**
11339
11338
  * Generates a list of accent variants for a given term.
@@ -11375,7 +11374,7 @@ const generateAccentVariants = (term) => {
11375
11374
 
11376
11375
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
11377
11376
  // versions:
11378
- // protoc-gen-ts_proto v2.7.7
11377
+ // protoc-gen-ts_proto v2.10.1
11379
11378
  // protoc v4.23.4
11380
11379
  // source: src/stops/proto/stops.proto
11381
11380
  /* eslint-disable */
@@ -11751,7 +11750,7 @@ const serializeLocationType = (locationType) => {
11751
11750
  };
11752
11751
 
11753
11752
  /**
11754
- * The StopMap class provides functionality to search for public transport stops
11753
+ * The StopsIndex class provides functionality to search for public transport stops
11755
11754
  * by name or geographic location. It leverages text search and geospatial indexing
11756
11755
  * to efficiently find stops based on user queries.
11757
11756
  */
@@ -11782,14 +11781,14 @@ class StopsIndex {
11782
11781
  });
11783
11782
  }
11784
11783
  }
11785
- this.textIndex = lt({
11784
+ this.textIndex = at({
11786
11785
  fields: ['name'],
11787
11786
  storeFields: ['id'],
11788
11787
  searchOptions: { prefix: true, fuzzy: 0.2 },
11789
11788
  processTerm: generateAccentVariants,
11790
11789
  });
11791
11790
  const stopsArray = Array.from(stopsSet.values());
11792
- q(this.textIndex, stopsArray);
11791
+ j(this.textIndex, stopsArray);
11793
11792
  this.geoIndex = new KDBush(this.stopPoints.length);
11794
11793
  for (let i = 0; i < this.stopPoints.length; i++) {
11795
11794
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -11836,7 +11835,7 @@ class StopsIndex {
11836
11835
  * @returns An array of Stop objects that match the search query.
11837
11836
  */
11838
11837
  findStopsByName(query, maxResults = 5) {
11839
- const results = dt(this.textIndex, query).map((result) => this.stops[result.id]);
11838
+ const results = ut(this.textIndex, query).map((result) => this.stops[result.id]);
11840
11839
  return results.slice(0, maxResults);
11841
11840
  }
11842
11841
  /**
@@ -11895,6 +11894,16 @@ class StopsIndex {
11895
11894
  : stop.children;
11896
11895
  return Array.from(new Set([id, ...equivalentStops])).map((stopId) => this.stops[stopId]);
11897
11896
  }
11897
+ /**
11898
+ * Makes the StopsIndex iterable, allowing iteration over all stops.
11899
+ *
11900
+ * @returns An iterator for the stops.
11901
+ */
11902
+ *[Symbol.iterator]() {
11903
+ for (const stop of this.stops) {
11904
+ yield stop;
11905
+ }
11906
+ }
11898
11907
  }
11899
11908
 
11900
11909
  class Duration {
@@ -11980,7 +11989,7 @@ class Duration {
11980
11989
 
11981
11990
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
11982
11991
  // versions:
11983
- // protoc-gen-ts_proto v2.7.7
11992
+ // protoc-gen-ts_proto v2.10.1
11984
11993
  // protoc v4.23.4
11985
11994
  // source: src/timetable/proto/timetable.proto
11986
11995
  /* eslint-disable */