import"./rolldown-runtime-DIIn1E2Q.js";import{i as e,n as t}from"./vendor-other-D7fTIduy.js";import{qt as n,r}from"./api-BebQfoGK.js";var i=!1,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(!i)try{await e(await t()),i=!0}catch(e){e instanceof Error&&e.message.includes(`already an encoder stored`)?i=!0:handleError(`encoder`,`Failed to register WAV encoder`,e)}},convertBlobToFileAndSubmit=async e=>{let t=`recording-${Date.now()}.wav`,i=new File([e],t,{type:e.type||`audio/wav`}),a=new FormData;a.append(`image`,i),a.append(`subfolder`,`audio`),a.append(`type`,`temp`);let o=await r.fetchApi(`/upload/image`,{method:`POST`,body:a});if(o.status!==200){let e=`Error uploading temp file: ${o.status} - ${o.statusText}`;throw n().addAlert(e),Error(e)}return`audio/${(await o.json()).name} [temp]`};return{convertBlobToFileAndSubmit,registerWavEncoder,stopAllTracks}};export{useAudioService as t};
//# sourceMappingURL=audioService-Dv30xNvq.js.map