/**
 * Copyright 2019 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as e,html as i,css as r}from"../../lit/index.js";import{record as t}from"./lib/vmsg-fork.js";import"../simple-icon/lib/simple-icon-button-lite.js";import"../simple-icon/lib/simple-icons.js";class VoiceRecorder extends e{static get styles(){return[r`
        :host {
          display: inline-flex;
        }
      `]}render(){return i`
      ${this.recording?i``:i`
            <simple-icon-button-lite
              icon="av:mic"
              @click="${this.toggleRecording}"
              >${this.label}</simple-icon-button-lite
            >
          `}
      <slot></slot>
    `}static get properties(){return{recording:{type:Boolean},label:{type:String}}}static get tag(){return"voice-recorder"}constructor(){super(),this.recording=!1,this.label="Activate Recorder"}toggleRecording(e){this.recording=!this.recording}updated(e){e.has("recording")&&this.recording&&this.recorder()}recorder(){t({wasmURL:new URL("./lib/vmsg.wasm",import.meta.url).href},this).then((e=>{this.dispatchEvent(new CustomEvent("voice-recorder-recording-blob",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:e}})),this.recording=!1,this.innerHTML=""}))}}customElements.define(VoiceRecorder.tag,VoiceRecorder);export{VoiceRecorder};