"use strict";exports.id=439,exports.ids=[439],exports.modules={41127:(e,t,n)=>{t.OnBeforeTrigger=void 0;var r=n(49893),o=n(8637),i=n(96286);t.OnBeforeTrigger=class{constructor(e){this.context=e.context,this.indexManager=e.indexManager}async run(e){const t=(0,i.listCreateElasticsearchIndexTaskPlugin)(this.context.plugins),n=this.context.tenancy.getCurrentTenant();if(!n?.id)throw new Error("Something went wrong, tenant not found when triggering a task.");const s=this.context.i18n.getContentLocale();if(!s)throw new Error("Something went wrong, locale not found when triggering a task.");try{const i=(await(0,r.listIndexes)({context:this.context,plugins:t,tenants:[n],locales:[s]})).filter((t=>{if(!e?.length)return!0;for(const n of e)if(t.index.includes(n))return!0;return!1}));if(0===i.length)return void console.warn("There are no indexes to create before triggering the Create indexes task.",{targets:e});const a=(0,o.createIndexFactory)(this.indexManager);for(const{index:e,settings:t}of i)try{console.log("Creating index",e),await a.createIfNotExists(e,t)}catch(t){console.error(`Failed to create index "${e}".`,t)}}catch(e){console.error(e)}}}}};
//# sourceMappingURL=OnBeforeTrigger.74fb627c.chunk.js.map