// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Microsoft Software License Terms for the Azure Communications Services, Azure CPaaS, MICROSOFT AZURE COMMUNICATION CALLING EFFECTS
// See LICENSE file for license information.

import{EventEmitterImpl as e}from"./a3496b.js";import{ACSEffectsConfigProvider as t}from"./164f58.js";import{CapabilityChecker as i}from"./93bb86.js";import{WasmVQEProvider as r}from"./8bf39f.js";import{stringifyObject as o}from"./cd7b0b.js";import{getSdkInternalVersion as n,getSdkVersion as s}from"./8fdf2a.js";var __awaiter=function(e,t,i,r){function adopt(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r.throw(e))}catch(e){o(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))};class AudioEffectInternalBase{get name(){return this.effectName}constructor(o,n){this.effectName=o,this.logger=n,this.eventEmitter=new e(this.logger),this._acsEffectsConfigProvider=new t(this.eventEmitter,this.logger.createChild("AE:ACSEffConfigProvider"),this.effectName),this._capabilityChecker=new i(this._acsEffectsConfigProvider,this.logger.createChild("AE:CapabilityChecker")),this.wasmvqeProvider=new r(this.logger.createChild(this.name)),this.logger.info("AudioEffectsBase ctor success")}get configProvider(){return this._acsEffectsConfigProvider}get capabilityChecker(){return this._capabilityChecker}setConfig(e){return __awaiter(this,void 0,void 0,(function*(){this.configProvider.updateConfig(Object.assign(Object.assign({},this.configProvider.config),{audioEffects:Object.assign({},e)}))}))}dispose(){var e,t;return __awaiter(this,void 0,void 0,(function*(){this.eventEmitter.removeAllListeners(),yield null===(t=null===(e=this.wasmvqeProvider)||void 0===e?void 0:e.wasmVqeAudioEffectProvider)||void 0===t?void 0:t.dispose(),this.wasmvqeProvider=null}))}getVersion(e){return e?n():s()}on(e,t){if("processingStarted"!==e&&"processingStopped"!==e&&"processingError"!==e&&"configUpdated"!==e)throw new Error(`Not able to subscribe to event ${e}, unknown event name`);this.eventEmitter.on(e,t)}off(e,t){if("processingStarted"!==e&&"processingStopped"!==e&&"processingError"!==e&&"configUpdated"!==e)throw new Error(`Not able to subscribe to event ${e}, unknown event name`);this.eventEmitter.off(e,t)}handleProcessingError(e){this.logger.error(o(e)),this.eventEmitter.emit("processingError",e)}}export{AudioEffectInternalBase};
