import*as SDK from"../sdk/sdk.js";export class WebAudioModel extends SDK.SDKModel.SDKModel{constructor(e){super(e),this._enabled=!1,this._agent=e.webAudioAgent(),e.registerWebAudioDispatcher(this),SDK.SDKModel.TargetManager.instance().addModelListener(SDK.ResourceTreeModel.ResourceTreeModel,SDK.ResourceTreeModel.Events.FrameNavigated,this._flushContexts,this)}_flushContexts(){this.dispatchEventToListeners("ModelReset")}async suspendModel(){this.dispatchEventToListeners("ModelSuspend"),await this._agent.invoke_disable()}async resumeModel(){if(!this._enabled)return Promise.resolve();await this._agent.invoke_enable()}ensureEnabled(){this._enabled||(this._agent.invoke_enable(),this._enabled=!0)}contextCreated({context:e}){this.dispatchEventToListeners("ContextCreated",e)}contextWillBeDestroyed({contextId:e}){this.dispatchEventToListeners("ContextDestroyed",e)}contextChanged({context:e}){this.dispatchEventToListeners("ContextChanged",e)}audioListenerCreated({listener:e}){this.dispatchEventToListeners("AudioListenerCreated",e)}audioListenerWillBeDestroyed({listenerId:e,contextId:t}){this.dispatchEventToListeners("AudioListenerWillBeDestroyed",{listenerId:e,contextId:t})}audioNodeCreated({node:e}){this.dispatchEventToListeners("AudioNodeCreated",e)}audioNodeWillBeDestroyed({contextId:e,nodeId:t}){this.dispatchEventToListeners("AudioNodeWillBeDestroyed",{contextId:e,nodeId:t})}audioParamCreated({param:e}){this.dispatchEventToListeners("AudioParamCreated",e)}audioParamWillBeDestroyed({contextId:e,nodeId:t,paramId:d}){this.dispatchEventToListeners("AudioParamWillBeDestroyed",{contextId:e,nodeId:t,paramId:d})}nodesConnected({contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n,destinationInputIndex:s}){this.dispatchEventToListeners("NodesConnected",{contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n,destinationInputIndex:s})}nodesDisconnected({contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n,destinationInputIndex:s}){this.dispatchEventToListeners("NodesDisconnected",{contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n,destinationInputIndex:s})}nodeParamConnected({contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n}){this.dispatchEventToListeners("NodeParamConnected",{contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n})}nodeParamDisconnected({contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n}){this.dispatchEventToListeners("NodeParamDisconnected",{contextId:e,sourceId:t,destinationId:d,sourceOutputIndex:n})}async requestRealtimeData(e){return(await this._agent.invoke_getRealtimeData({contextId:e})).realtimeData}}SDK.SDKModel.SDKModel.register(WebAudioModel,SDK.SDKModel.Capability.DOM,!1);