/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/espells@0.4.1/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{iterate}from"iterare";import{Aff}from"./aff/index";import{decoder}from"./constants";import{Dic,Word}from"./dic/index";import{Lookup}from"./lookup";import{Reader}from"./reader";import{Suggest}from"./suggest";import{concat}from"./util";export class Espells{constructor({aff:t,dic:e,override:r}){Array.isArray(e)||(e=[e]),e=e.reduce(((t,e)=>t+("string"==typeof e?e:decoder.decode(e))),""),this.aff=new Aff(new Reader(t),r),this.dic=new Dic(new Reader(e),this.aff),this.lookuper=new Lookup(this.aff,this.dic),this.suggester=new Suggest(this.aff,this.dic,this.lookuper)}static async fromURL(t){const e=await(await fetch(t.aff)).text(),r="string"==typeof t.dic?[t.dic]:t.dic,o=[];for(const t of r){const e=await(await fetch(t)).text();o.push(e)}return new Espells({...t,aff:e,dic:o})}addDictionary(t){Array.isArray(t)||(t=[t]);for(const e of t)this.dic.addDictionary(new Reader(e))}add(t){const e=new Word(t,this.aff);this.dic.add(e)}remove(t){this.dic.remove(t)}lookup(t,e=!0){return this.lookuper.check(t,e)}suggest(t,e=8){return iterate(this.suggester.suggestions(t)).take(e).map((t=>t.text)).toArray()}stems(t,e=!0){return this.lookup(t).correct?iterate(this.lookuper.stems(t,{caps:e})).toArray():[]}data(t,e=!0){return this.lookup(t).correct?iterate(this.lookuper.stems(t,{caps:e})).map((t=>this.lookuper.data(t,e))).reduce(((t,e)=>(iterate(e).flatten().forEach((([e,r])=>{t.set(e,concat(t.get(e)??new Set,r))})),t)),new Map):new Map}}
//# sourceMappingURL=/sm/70d6ffa70c5021c1c64ee501111c23415dc24105b13c58bc98d46928284d5c81.map