import{k as O,j as y,t as U,m as z,n as A,p as i,f as W,v as L,s as B,A as G,i as X,x as Y,F as Z}from"./web.Os7kOAdY.js";import{g as F,t as ee}from"./i18n-runtime._BAkvU05.js";var te=G('<div class=panel style=display:flex;flex-direction:column;gap:18px><section class=panel style=padding:14px;text-align:center><button class="tool-btn is-primary"style="font-size:18px;padding:12px 32px"></button><p style="margin:8px 0 0;font-size:12px;color:var(--muted)"></p></section><!$><!/><section class=panel style=padding:14px><h3 style="margin:0 0 8px;font-size:14px;color:var(--muted)"></h3><div class=tool-actions><button class=tool-btn></button><button class=tool-btn></button><button class=tool-btn></button><button class=tool-btn>'),ne=G("<section class=panel style=padding:14px><div style=display:flex;align-items:center;justify-content:space-between;margin-bottom:6px><span style=font-size:14px;font-weight:500></span><span style=font-size:12px;color:var(--muted);font-family:ui-monospace,monospace><!$><!/>%</span></div><input type=range min=0 max=100 style=width:100%;cursor:pointer>");const d=[{name:"rain",label:"🌧️ 雨声",filterType:"lowpass",frequency:1e3,Q:1,gain:.5},{name:"cafe",label:"☕ 咖啡馆",filterType:"bandpass",frequency:2e3,Q:.5,gain:.3},{name:"forest",label:"🌲 森林",filterType:"lowpass",frequency:500,Q:.8,gain:.4},{name:"waves",label:"🌊 海浪",filterType:"lowpass",frequency:300,Q:2,gain:.6}];function se(){const[M,v]=y(F(),{equals:!1}),r=t=>ee(t,M());U(()=>{const t=a=>{const e=a.detail?.locale;e&&v(e)};window.addEventListener("taitan:locale-change",t),v(F()),B(()=>window.removeEventListener("taitan:locale-change",t))});const[m,R]=y({rain:0,cafe:0,forest:0,waves:0}),[_,w]=y(!1);let s=null,c=[],f=null;const j=(t,a)=>{const e=t.sampleRate,l=e*a,o=t.createBuffer(1,l,e),u=o.getChannelData(0);for(let p=0;p<l;p++)u[p]=Math.random()*2-1;return o},H=()=>{if(s)return;s=new AudioContext,f=s.createGain(),f.gain.value=.7,f.connect(s.destination);const t=j(s,4);d.forEach(a=>{const e=s.createBufferSource();e.buffer=t,e.loop=!0;const l=s.createBiquadFilter();l.type=a.filterType,l.frequency.value=a.frequency,l.Q.value=a.Q;const o=s.createGain();o.gain.value=(m()[a.name]||0)/100*a.gain,e.connect(l),l.connect(o),o.connect(f),e.start(),c.push({source:e,gain:o,filter:l})}),w(!0)},h=()=>{c.forEach(t=>{try{t.source.stop()}catch{}}),c=[],s&&(s.close(),s=null),f=null,w(!1)},n=(t,a)=>{R(l=>({...l,[t]:a}));const e=d.findIndex(l=>l.name===t);e>=0&&c[e]&&(c[e].gain.gain.value=a/100*d[e].gain)},I=()=>{_()?h():H()};return B(()=>h()),(()=>{var t=z(te),a=t.firstChild,e=a.firstChild,l=e.nextSibling,o=a.nextSibling,[u,p]=A(o.nextSibling),P=u.nextSibling,S=P.firstChild,V=S.nextSibling,x=V.firstChild,$=x.nextSibling,b=$.nextSibling,C=b.nextSibling;return e.$$click=I,i(e,()=>_()?"⏹ 停止":"▶ 播放"),i(l,()=>r("调节下方滑块混合不同环境音")),i(t,W(Z,{each:d,children:g=>(()=>{var E=z(ne),k=E.firstChild,q=k.firstChild,T=q.nextSibling,D=T.firstChild,[N,J]=A(D.nextSibling);N.nextSibling;var Q=k.nextSibling;return i(q,()=>g.label),i(T,()=>m()[g.name],N,J),Q.$$input=K=>n(g.name,parseInt(K.currentTarget.value)),X(()=>Y(Q,"value",m()[g.name])),L(),E})()}),u,p),i(S,()=>r("预设场景")),x.$$click=()=>{n("rain",80),n("cafe",0),n("forest",30),n("waves",0)},i(x,()=>r("森林雨声")),$.$$click=()=>{n("rain",20),n("cafe",70),n("forest",0),n("waves",0)},i($,()=>r("咖啡馆")),b.$$click=()=>{n("rain",0),n("cafe",0),n("forest",20),n("waves",90)},i(b,()=>r("海边")),C.$$click=()=>{n("rain",40),n("cafe",30),n("forest",40),n("waves",40)},i(C,()=>r("全部混合")),L(),t})()}O(["click","input"]);export{se as default};
