import{i as e}from"./firebase-CgQ6Zkyt.js";var t=class extends e{constructor(){super(),this.speechSynthesis=null,`speechSynthesis`in window&&(this.speechSynthesis=window.speechSynthesis,window.addEventListener(`beforeunload`,()=>{this.stop()}))}async speak(e){this.speechSynthesis||this.throwUnsupportedError(),await this.stop();let t=this.speechSynthesis,n=this.createSpeechSynthesisUtterance(e);return new Promise((e,r)=>{n.onend=()=>{e()},n.onerror=e=>{r(e)},t.speak(n)})}async stop(){this.speechSynthesis||this.throwUnsupportedError(),this.speechSynthesis.cancel()}async getSupportedLanguages(){return{languages:this.getSpeechSynthesisVoices().map(e=>e.lang).filter((e,t,n)=>n.indexOf(e)==t)}}async getSupportedVoices(){return{voices:this.getSpeechSynthesisVoices()}}async isLanguageSupported(e){return{supported:(await this.getSupportedLanguages()).languages.includes(e.lang)}}async openInstall(){this.throwUnimplementedError()}createSpeechSynthesisUtterance(e){let t=this.getSpeechSynthesisVoices(),n=new SpeechSynthesisUtterance,{text:r,lang:i,rate:a,pitch:o,volume:s,voice:c}=e;return c!==void 0&&(n.voice=t[c]),s!==void 0&&(n.volume=s>=0&&s<=1?s:1),a!==void 0&&(n.rate=a>=.1&&a<=10?a:1),o!==void 0&&(n.pitch=o>=0&&o<=2?o:2),i&&(n.lang=i),n.text=r,n}getSpeechSynthesisVoices(){return this.speechSynthesis||this.throwUnsupportedError(),(!this.supportedVoices||this.supportedVoices.length<1)&&(this.supportedVoices=this.speechSynthesis.getVoices()),this.supportedVoices}throwUnsupportedError(){throw this.unavailable(`SpeechSynthesis API not available in this browser.`)}throwUnimplementedError(){throw this.unimplemented(`Not implemented on web.`)}};export{t as TextToSpeechWeb};