import DividerPage from '../create/components/base/divider/Divider.vue';
import DividerSetting from '../create/components/base/divider/DividerSetting.vue';
import SpacingPage from '../create/components/base/spacing/Spacing.vue';
import SpacingSetting from '../create/components/base/spacing/SpacingSetting.vue';
import AudioPage from '../create/components/base/audio/Audio.vue';
import AudioSetting from '../create/components/base/audio/AudioSetting.vue';
import PicturePage from '../create/components/base/picture/Picture.vue';
import PictureSetting from '../create/components/base/picture/PictureSetting.vue';
import SelectPage from '../create/components/question/select/Select.vue';
import SelectSetting from '../create/components/question/select/SelectSetting.vue';
import VideoPage from '../create/components/base/video/Video.vue';
import VideoSetting from '../create/components/base/video/VideoSetting.vue';
import StemPage from '../create/components/base/stem/Stem.vue';
import StemSetting from '../create/components/base/stem/StemSetting.vue';
import DescribePage from '../create/components/base/describe/Describe.vue';
import DescribeSetting from '../create/components/base/describe/DescribeSetting.vue';
import LabelPage from '../create/components/base/label/Label.vue';
import LabelSetting from '../create/components/base/label/LabelSetting.vue';
import MatchingPage from '../create/components/question/matching/Matching.vue';
import MatchingSetting from '../create/components/question/matching/MatchingSetting.vue';
import SortPage from '../create/components/question/sort/Sort.vue';
import SortSetting from '../create/components/question/sort/SortSetting.vue';
import VoiceMatrix from '../create/components/question/voice_matrix/VoiceMatrix.vue';
import VoiceMatrixSetting from '../create/components/question/voice_matrix/VoiceMatrixSetting.vue';
import FillPage from '../create/components/question/fill/Fill.vue';
import FillSetting from '../create/components/question/fill/FillSetting.vue';
import RecordInput from '../create/components/question/record_input/RecordInput.vue';
import RecordInputSetting from '../create/components/question/record_input/RecordInputSetting.vue';
import UploadControl from '../create/components/base/upload_control/UploadControl.vue';
import UploadControlSetting from '../create/components/base/upload_control/UploadControlSetting.vue';
import UploadPreview from '../create/components/base/upload_preview/UploadPreview.vue';
import UploadRreviewSetting from '../create/components/base/upload_preview/UploadRreviewSetting.vue';


import AudioPreview from '@/views/book/courseware/preview/components/audio/AudioPreview.vue';
import DividerPreview from '@/views/book/courseware/preview/components/divider/DividerPreview.vue';
import SpacingPreview from '@/views/book/courseware/preview/components/spacing/SpacingPreview.vue';
import PicturePreview from '@/views/book/courseware/preview/components/picture/PicturePreview.vue';
import VideoPreview from '@/views/book/courseware/preview/components/video/VideoPreview.vue';
import StemPreview from '@/views/book/courseware/preview/components/stem/StemPreview.vue';
import DescribePreview from '@/views/book/courseware/preview/components/describe/DescribePreview.vue';
import LabelPreview from '@/views/book/courseware/preview/components/label/LabelPreview.vue';
import SelectPreview from '@/views/book/courseware/preview/components/select/SelectPreview.vue';
import MatchingPreview from '@/views/book/courseware/preview/components/matching/MatchingPreview.vue';
import SortPreview from '@/views/book/courseware/preview/components/sort/SortPreview.vue';
import VoiceMatrixPreview from '@/views/book/courseware/preview/components/voice_matrix/VoiceMatrixPreview.vue';
import FillPreview from '@/views/book/courseware/preview/components/fill/FillPreview.vue';
import RecordInputPreview from '../preview/components/record_input/RecordInputPreview.vue';
import UploadControlPreview from '../preview/components/upload_control/UploadControlPreview.vue';
import UploadPreviewPreview from '../preview/components/upload_preview/UploadPreviewPreview.vue';

export const bookTypeOption = [
  {
    value: 'base',
    label: '基础组件',
    children: [
      {
        value: 'stem',
        label: '题干',
        icon: 'stem',
        component: StemPage,
        // 设置页面
        set: StemSetting,
        preview: StemPreview, // 预览页面
      },
      {
        value: 'describe',
        label: '描述',
        icon: 'describe',
        component: DescribePage,
        set: DescribeSetting,
        preview: DescribePreview,
      },
      {
        value: 'label',
        label: '标签',
        icon: 'label',
        component: LabelPage,
        set: LabelSetting,
        preview: LabelPreview,
      },
      {
        value: 'audio',
        label: '音频',
        icon: 'audio',
        component: AudioPage,
        set: AudioSetting,
        preview: AudioPreview,
      },
      {
        value: 'video',
        label: '视频',
        icon: 'video',
        component: VideoPage,
        set: VideoSetting,
        preview: VideoPreview,
      },
      {
        value: 'picture',
        label: '图片',
        icon: 'picture',
        component: PicturePage,
        set: PictureSetting,
        preview: PicturePreview,
      },
      {
        value: 'upload_control',
        label: '上传',
        icon: 'upload',
        component: UploadControl,
        set: UploadControlSetting,
        preview: UploadControlPreview,
      },
      {
        value: 'upload_preview',
        label: '上传预览',
        icon: 'uploadPreview',
        component: UploadPreview,
        set: UploadRreviewSetting,
        preview: UploadPreviewPreview,
      },
      {
        value: 'divider',
        label: '分割线',
        icon: 'divider',
        component: DividerPage,
        set: DividerSetting,
        preview: DividerPreview,
      },
      {
        value: 'spacing',
        label: '间距',
        icon: 'spacing',
        component: SpacingPage,
        set: SpacingSetting,
        preview: SpacingPreview,
      },
    ],
  },
  {
    value: 'question',
    label: '题型组件',
    children: [
      {
        value: 'select',
        label: '选择组件',
        icon: '',
        component: SelectPage,
        set: SelectSetting,
        preview: SelectPreview,
      },
      {
        value: 'matching',
        label: '连线组件',
        icon: '',
        component: MatchingPage,
        set: MatchingSetting,
        preview: MatchingPreview,
      },
      {
        value: 'sort',
        label: '排序组件',
        icon: '',
        component: SortPage,
        set: SortSetting,
        preview: SortPreview,
      },
      {
        value: 'voice_matrix',
        label: '语音矩阵',
        icon: '',
        component: VoiceMatrix,
        set: VoiceMatrixSetting,
        preview: VoiceMatrixPreview,
      },
      {
        value: 'fill',
        label: '填空组件',
        icon: '',
        component: FillPage,
        set: FillSetting,
        preview: FillPreview,
      },
      {
        value: 'record_input',
        label: '录音组件',
        icon: '',
        component: RecordInput,
        set: RecordInputSetting,
        preview: RecordInputPreview,
      },
    ],
  },
];

// 组件列表
export const componentList = bookTypeOption
  .flatMap((item) => item.children)
  .reduce((prev, { value, component }) => ({ ...prev, [value]: component }), {});

// 组件设置列表
export const componentSettingList = bookTypeOption
  .flatMap((item) => item.children)
  .reduce((prev, { value, set }) => ({ ...prev, [value]: set }), {});

// 组件名称列表
export const componentNameList = bookTypeOption
  .flatMap((item) => item.children)
  .reduce((prev, { value, label }) => ({ ...prev, [value]: label }), {});

// 预览组件列表
export const previewComponentList = bookTypeOption
  .flatMap((item) => item.children)
  .reduce((prev, { value, preview }) => ({ ...prev, [value]: preview }), {});
