import{n as e}from"./chunk-DR8-3Aex.js";import{Cc as t,Ka as n,dc as r,lo as i,oo as a,yc as o}from"./paths-Ci1iwL5Y.js";import{n as s,r as c}from"./analytics-DqMQntaB.js";import{AT as l,BA as u,WA as d,jT as f}from"./loadAgentsDir-C_wFhytF.js";import{n as p,r as m}from"./voiceModeEnabled-CjBjjeNR.js";import{n as h,t as g}from"./useVoice-CaBv3G13.js";var _,v;e((()=>{g(),f(),s(),o(),u(),a(),p(),_=2,v=async e=>{if(!m())return{type:`text`,value:`Voice mode is not available.`};let a=n(),o=a.voiceEnabled===!0,s=e?.trim().toLowerCase();if(o&&s===`doubao`)return i(`userSettings`,{voiceProvider:`doubao`}).error?{type:`text`,value:`Failed to update settings. Check your settings file for syntax errors.`}:(d.notifyChange(`userSettings`),{type:`text`,value:`Voice mode switched to Doubao ASR. Hold ${l(`voice:pushToTalk`,`Chat`,`Space`)} to record.`});if(o&&s===`anthropic`)return i(`userSettings`,{voiceProvider:`anthropic`}).error?{type:`text`,value:`Failed to update settings. Check your settings file for syntax errors.`}:(d.notifyChange(`userSettings`),{type:`text`,value:`Voice mode switched to Anthropic STT. Hold ${l(`voice:pushToTalk`,`Chat`,`Space`)} to record.`});if(o)return i(`userSettings`,{voiceEnabled:!1}).error?{type:`text`,value:`Failed to update settings. Check your settings file for syntax errors.`}:(d.notifyChange(`userSettings`),c(`tengu_voice_toggled`,{enabled:!1}),{type:`text`,value:`Voice mode disabled.`});let u=s===`doubao`?`doubao`:`anthropic`,{isVoiceStreamAvailable:f}=await import(`./voiceStreamSTT-CCkOfmdI.js`),{checkRecordingAvailability:p}=await import(`./voice-YtzCcIoM.js`),g=await p();if(!g.available)return{type:`text`,value:g.reason??`Voice mode is not available in this environment.`};if(u!==`doubao`&&!f())return{type:`text`,value:`Voice mode requires a Claude.ai account. Please run /login to sign in.`};let{checkVoiceDependencies:v,requestMicrophonePermission:y}=await import(`./voice-YtzCcIoM.js`),b=await v();if(!b.available)return{type:`text`,value:`No audio recording tool found.${b.installCommand?`\nInstall audio recording tools? Run: ${b.installCommand}`:`
Install SoX manually for audio recording.`}`};if(!await y()){let e;return e=process.platform===`win32`?`Settings → Privacy → Microphone`:process.platform===`linux`?`your system's audio settings`:`System Settings → Privacy & Security → Microphone`,{type:`text`,value:`Microphone access is denied. To enable it, go to ${e}, then run /voice again.`}}if(i(`userSettings`,{voiceEnabled:!0,...u===`doubao`?{voiceProvider:`doubao`}:{}}).error)return{type:`text`,value:`Failed to update settings. Check your settings file for syntax errors.`};d.notifyChange(`userSettings`),c(`tengu_voice_toggled`,{enabled:!0});let x=l(`voice:pushToTalk`,`Chat`,`Space`),S=``,C=u===`doubao`?`Doubao ASR`:`Anthropic`;if(u!==`doubao`){let e=h(a.language),n=r(),i=n.voiceLangHintLastLanguage!==e.code,o=i?0:n.voiceLangHintShownCount??0,s=!e.fellBackFrom&&o<_;e.fellBackFrom?S=` Note: "${e.fellBackFrom}" is not a supported dictation language; using English. Change it via /config.`:s&&(S=` Dictation language: ${e.code} (/config to change).`),(i||s)&&t(t=>({...t,voiceLangHintShownCount:o+ +!!s,voiceLangHintLastLanguage:e.code}))}return{type:`text`,value:`Voice mode enabled (${C}). Hold ${x} to record.${S}`}}}))();export{v as call};