import{r as e}from"./rolldown-runtime-DCMCV6zW.js";import{r as t,t as n}from"./vendor-other-CrvBxfcV.js";import{Ot as r,r as i}from"./api-3C7_IVZO.js";var a=!1;const useAudioService=()=>{let handleError=(e,t,n)=>{console.error(`Audio Service Error (${e}):`,t,n)},stopAllTracks=e=>{e&&=(e.getTracks().forEach(e=>{e.stop()}),null)},registerWavEncoder=async()=>{if(!a)try{await t(await n()),a=!0}catch(e){e instanceof Error&&e.message.includes(`already an encoder stored`)?a=!0:handleError(`encoder`,`Failed to register WAV encoder`,e)}},convertBlobToFileAndSubmit=async e=>{let t=`recording-${Date.now()}.wav`,n=new File([e],t,{type:e.type||`audio/wav`}),a=new FormData;a.append(`image`,n),a.append(`subfolder`,`audio`),a.append(`type`,`temp`);let o=await i.fetchApi(`/upload/image`,{method:`POST`,body:a});if(o.status!==200){let e=`Error uploading temp file: ${o.status} - ${o.statusText}`;throw r().addAlert(e),Error(e)}return`audio/${(await o.json()).name} [temp]`};return{convertBlobToFileAndSubmit,registerWavEncoder,stopAllTracks}};export{useAudioService as t};
//# sourceMappingURL=audioService-s0ixe3VV.js.map