import{a as u}from"./chunk-IRFDE6LX.js";var f=new Map,s=null,r=null;function l(){return s||(s=new(window.AudioContext||window.webkitAudioContext)({latencyHint:"interactive"})),r||(r=s.createGain(),r.gain.value=.9,r.connect(s.destination)),s}var b=async()=>{if(typeof window>"u")return!1;let e=l();if(e.state==="suspended"||e.state==="interrupted")try{await e.resume()}catch{}return e.state==="running"},m=async e=>{if(f.get(e))return;let i=await(await fetch(e)).arrayBuffer(),o=await l().decodeAudioData(i);f.set(e,o)},w=(e,c,i)=>{let o=l(),a=Math.min(Math.max(c,0),1),d=f.get(e);if(!d)return;let t=o.createBufferSource();t.buffer=d,t.playbackRate.value=1+(Math.random()-.5)*.04;let n=o.createGain();n.gain.value=a,t.connect(n),n.connect(r);let g=()=>{i.delete(e),t.removeEventListener("ended",g),t.disconnect(),n.disconnect()};t.addEventListener("ended",g),i.add(e),t.start(Math.max(o.currentTime,0))};import{useGLTF as x,useTexture as p}from"@react-three/drei";var C=(e,c,i)=>{Object.values(c).forEach(o=>{Object.entries(o?.resources||{}).forEach(([a,d])=>{Object.values(d).forEach(t=>{if(typeof t=="object"||!t)return;let n=i?i[t]:`${e}/dice/bundles/${o.slug}/${t}`;a==="models"?x.preload(n):a==="textures"?p.preload(n):a==="sounds"?m(n):fetch(n),u&&console.log(`Preloaded resource: ${n}`)})})}),u&&console.log(`Preloading common noise map texture: ${e}/dice/bundles/basic/images/noise-map.png`),p.preload(`${e}/dice/bundles/basic/images/noise-map.png`),u&&console.log(`Preloading common environment texture: ${e}/dice/images/common/environment.jpg`),p.preload(`${e}/dice/images/common/environment.jpg`),Array.from({length:3}).forEach((o,a)=>{m(`${e}/dice/sounds/collision-${a+1}.wav`)})};export{b as a,w as b,C as c};
//# sourceMappingURL=chunk-OULDMZYN.js.map
