import{G as s,H as y,J as a,K as f,Na as u,Wb as v,d as p,e as i}from"./chunk-RISKGE32.js";import{p as d}from"./chunk-6O6MLDWR.js";import"./chunk-F4AZU7R4.js";import"./chunk-GQY3J744.js";import{g as l,n as m}from"./chunk-CLPINNGF.js";m();l();async function w(){let S=p("SettingsSync","orange"),h=u.registerHook("BEFORE_PLAY",async()=>{i("/user-settings/sync")}),r=async()=>{if(document.visibilityState==="visible"){let o=a.getCacheSync(),e=await i("/user-settings/get").then(async({voice:t,...g})=>({voice:await y(t),...g}));d(o,e)||(a.invalidateCache(),await s.emit("update",await f())),v()}},n=null,c=null,b=s.on("update",async o=>{let{voice:e,playbackSpeed:t}=o;if(n!==e||c!==t)try{await i("/sidepanel/settings-update",{voice:e??n,playbackSpeed:t}),e&&(n=e),t&&(c=t)}catch(C){S.warn("❌ Failed to notify sidepanel (may not be open):",C)}});return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r),h(),b()}}export{w as default};
//# sourceMappingURL=init-PTAPA5BN.js.map
