import{A as o}from"./abstractAudioBus--TUgnn12.js";import{_ as r,a as u,b as a,c as n}from"./spatialWebAudio-DZSznhH0.js";import"./webAudioBaseSubGraph-ymNBfs1g.js";import"./audioEngine-CbOwYhF1.js";import"./index-6jOCfdig.js";import"./index-Ds2meNS5.js";import"./svelte/svelte_svelte.js";import"./svelte/svelte_animate.js";import"./svelte/svelte_attachments.js";import"./svelte/svelte_easing.js";import"./svelte/svelte_internal_client.js";import"./svelte/svelte_internal_flags_async.js";import"./svelte/svelte_internal_flags_legacy.js";import"./svelte/svelte_internal_flags_tracing.js";import"./svelte/svelte_internal_server.js";import"./svelte/svelte_legacy.js";import"./svelte/svelte_motion.js";import"./svelte/svelte_reactivity.js";import"./svelte/svelte_reactivity_window.js";import"./svelte/svelte_server.js";import"./svelte/svelte_store.js";import"./svelte/svelte_transition.js";import"./svelte/svelte_events.js";class p extends o{constructor(t,s){super(t,s),this._outBus=null,this._onOutBusDisposed=()=>{this.outBus=this.engine.defaultMainBus}}get outBus(){return this._outBus}set outBus(t){if(this._outBus!==t){if(this._outBus&&(this._outBus.onDisposeObservable.removeCallback(this._onOutBusDisposed),!this._disconnect(this._outBus)))throw new Error("Disconnect failed");if(this._outBus=t,this._outBus&&(this._outBus.onDisposeObservable.add(this._onOutBusDisposed),!this._connect(this._outBus)))throw new Error("Connect failed")}}dispose(){super.dispose(),this._outBus=null}}class e extends p{constructor(t,s,i){super(t,s),this._spatial=null,this._spatialAutoUpdate=!0,this._spatialMinUpdateTime=0,this._stereo=null,typeof i.spatialAutoUpdate=="boolean"&&(this._spatialAutoUpdate=i.spatialAutoUpdate),typeof i.spatialMinUpdateTime=="number"&&(this._spatialMinUpdateTime=i.spatialMinUpdateTime),this._subGraph=new e._SubGraph(this)}async _initAsync(t){t.outBus?this.outBus=t.outBus:(await this.engine.isReadyPromise,this.outBus=this.engine.defaultMainBus),await this._subGraph.initAsync(t),r(t)&&this._initSpatialProperty(),this.engine._addNode(this)}dispose(){super.dispose(),this._spatial=null,this._stereo=null,this.engine._removeNode(this)}get _inNode(){return this._subGraph._inNode}get _outNode(){return this._subGraph._outNode}get spatial(){return this._spatial?this._spatial:this._initSpatialProperty()}get stereo(){return this._stereo??(this._stereo=new u(this._subGraph))}getClassName(){return"_WebAudioBus"}_connect(t){return super._connect(t)?(t._inNode&&this._outNode?.connect(t._inNode),!0):!1}_disconnect(t){return super._disconnect(t)?(t._inNode&&this._outNode?.disconnect(t._inNode),!0):!1}_initSpatialProperty(){return this._spatial||(this._spatial=new a(this._subGraph,this._spatialAutoUpdate,this._spatialMinUpdateTime)),this._spatial}}e._SubGraph=class extends n{get _downstreamNodes(){return this._owner._downstreamNodes??null}get _upstreamNodes(){return this._owner._upstreamNodes??null}};export{e as _WebAudioBus};
