<!-- eslint-disable vue/no-v-html -->
<template>
  <div class="readaloud-preview">
    <div class="stem">
      <span class="question-number">{{ data.property.question_number }}.</span>
      <span v-html="sanitizeHTML(data.stem)"></span>
    </div>

    <div v-if="isEnable(data.property.is_enable_description)" class="description">{{ data.description }}</div>

    <AudioPlay
      v-if="isEnable(data.property.is_enable_listening) && data.file_id_list.length > 0"
      :file-id="data.file_id_list[0]"
    />

    <SoundRecordPreview :wav-blob.sync="answer.answer_list[0].voice_file_id" />
  </div>
</template>

<script>
import PreviewMixin from './components/PreviewMixin';
import SoundRecordPreview from './components/common/SoundRecordPreview.vue';

export default {
  name: 'ReadAloudPreview',
  components: {
    SoundRecordPreview,
  },
  mixins: [PreviewMixin],
  created() {
    this.$set(this.answer.answer_list, 0, { voice_file_id: '' });
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
@use '@/styles/mixin.scss' as *;

.readaloud-preview {
  @include preview;

  .reference-answer {
    padding: 12px 24px;
    background-color: $content-color;
    border-radius: 8px;
  }
}
</style>
