import{DEFAULT_LOCALE_PLACEHOLDER as n}from"../../../../constants/index.js";import{FlexSearch as c}from"./flexsearch/index.js";import{Typesense as a}from"./typesense/index.js";class h{type;l10n;engines={flexsearch:c,typesense:a};instance;constructor(e,t){this.type=e,this.l10n=t,this.instance=new this.engines[e]}async initIndexSchema(e){await this.instance.initIndexSchema?.(e)}async addDocuments(e,t,s){return this.instance.addDocuments(e,t,s)}async search(e,t){return this.instance.search({...e,locale:this.getLocale(e)},t)}async countFacets(e,t){return this.instance.countFacets({...e,locale:this.getLocale(e)},t)}async export(e){return this.instance.export(e)}async import(e){return this.instance.import(e)}getLocale(e){const t=e.locale||this.l10n?.defaultLocale||n;return t===this.l10n?.defaultLocale?n:t.toLowerCase()}cleanupFacetValues(e){return this.instance.cleanupFacetValues(e)}}export{h as SearchEngine};
