import{r as s}from"./index-CxGMQRP8.js";let u=null,d=!1;const l=()=>{if(typeof window>"u")return null;if(!u){const t=window.AudioContext||window.webkitAudioContext;if(!t)return null;try{u=new t}catch{return null}w()}return u},w=()=>{if(d||typeof window>"u")return;d=!0;const t=()=>{const e=u;if(e){e.state==="suspended"&&e.resume().catch(()=>{});try{const r=e.createOscillator(),c=e.createGain();c.gain.value=0,r.connect(c).connect(e.destination),r.start(0),r.stop(e.currentTime+.01)}catch{}window.removeEventListener("pointerdown",t),window.removeEventListener("touchstart",t),window.removeEventListener("click",t)}};window.addEventListener("pointerdown",t,{once:!0,passive:!0}),window.addEventListener("touchstart",t,{once:!0,passive:!0}),window.addEventListener("click",t,{once:!0,passive:!0})},p=()=>{const t=s.useRef(null),e=s.useCallback(()=>{const n=l();return t.current=n,n},[]),r=s.useCallback(()=>{const n=e();return n&&n.state==="suspended"&&n.resume().catch(()=>{}),n},[e]),c=s.useCallback((n,i=["pointerdown","touchstart"])=>{if(!n)return()=>{};const a=()=>{const o=e();o&&o.state==="suspended"&&o.resume().catch(()=>{})};return i.forEach(o=>n.addEventListener(o,a,{once:!0,passive:!0})),()=>{i.forEach(o=>n.removeEventListener(o,a))}},[e]);return s.useEffect(()=>{l()},[]),{getContext:r,unlockOn:c}};export{p as u};
//# sourceMappingURL=useIOSAudioContext-DSBnluc9.js.map