<template>
  <CollapseItem name="内容设置" :expanded="true">
    <SettingItemBox name="时间线设置">
      <SettingItem name="背景颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.background"
        />
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.background = optionData.dataStyleClone.background"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="边界颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.borderColor"
        />
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.borderColor = optionData.dataStyleClone.borderColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="线颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.lineColor"
        />
      </SettingItem>
      <SettingItem>
        <n-button
          size="small"
          @click="optionData.dataStyle.lineColor = optionData.dataStyleClone.lineColor"
        >
          恢复默认
        </n-button>
      </SettingItem>
      <SettingItem name="时间线大小">
        <n-select
          v-model:value="optionData.dataStyle.size"
          size="small"
          :options="[
            { label: '中', value: 'medium' },
            { label: '大', value: 'large' },
          ]"
        />
      </SettingItem>
      <SettingItem name="图标大小">
        <n-input-number
          v-model:value="optionData.dataStyle.iconSize"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="上方边距">
        <n-input-number
          v-model:value="optionData.dataStyle.marginTop"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="左侧边距">
        <n-input-number
          v-model:value="optionData.dataStyle.marginLeft"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="最新内容设置">
      <SettingItem name="标题字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleColorFirst"
        />
      </SettingItem>
      <SettingItem name="标题字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.titleFontSizeFirst"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="时间字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.timeColorFirst"
        />
      </SettingItem>
      <SettingItem name="时间字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.timeFontSizeFirst"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="文本字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.contentColorFirst"
        />
      </SettingItem>
      <SettingItem name="文本字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.contentFontSizeFirst"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="文本内容设置">
      <SettingItem name="标题字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.titleColor"
        />
      </SettingItem>
      <SettingItem name="标题字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.titleFontSize"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="时间字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.timeColor"
        />
      </SettingItem>
      <SettingItem name="时间字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.timeFontSize"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="文本字体颜色">
        <n-color-picker
          size="small"
          :modes="['hex']"
          v-model:value="optionData.dataStyle.contentColor"
        />
      </SettingItem>
      <SettingItem name="文本字体大小">
        <n-input-number
          v-model:value="optionData.dataStyle.contentFontSize"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="图片设置">
      <SettingItem name="图片类型">
        <n-select v-model:value="optionData.dataStyle.imageFit" size="small" :options="fitList" />
      </SettingItem>
      <SettingItem name="图片圆角">
        <n-input-number
          v-model:value="optionData.dataStyle.imageBorderRadius"
          size="small"
          :min="0"
        />
      </SettingItem>
      <SettingItem name="图片宽度">
        <n-input-number
          v-model:value="optionData.dataStyle.imageWidth"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="图片高度">
        <n-input-number
          v-model:value="optionData.dataStyle.imageHeight"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="上边距离">
        <n-input-number
          v-model:value="optionData.dataStyle.imageMarginTop"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="水平对齐">
        <n-select
          v-model:value="optionData.dataStyle.imageAlign"
          size="small"
          :options="textAlignOptions"
        />
      </SettingItem>
    </SettingItemBox>
    <SettingItemBox name="视频设置">
      <SettingItem>
        <n-checkbox v-model:checked="optionData.dataStyle.videoLoop" size="small">
          循环播放
        </n-checkbox>
      </SettingItem>
      <SettingItem>
        <n-checkbox v-model:checked="optionData.dataStyle.videoMuted" size="small">
          静音
        </n-checkbox>
      </SettingItem>
      <SettingItem name="视频类型">
        <n-select v-model:value="optionData.dataStyle.videoFit" size="small" :options="fitList" />
      </SettingItem>
      <SettingItem name="视频宽度">
        <n-input-number
          v-model:value="optionData.dataStyle.videoWidth"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="视频高度">
        <n-input-number
          v-model:value="optionData.dataStyle.videoHeight"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="上边距离">
        <n-input-number
          v-model:value="optionData.dataStyle.videoMarginTop"
          min="0"
          type="text"
          size="small"
        />
      </SettingItem>
      <SettingItem name="水平对齐">
        <n-select
          v-model:value="optionData.dataStyle.videoAlign"
          size="small"
          :options="textAlignOptions"
        />
      </SettingItem>
    </SettingItemBox>
  </CollapseItem>
</template>

<script setup lang="ts">
  import { PropType, watch, ref } from 'vue';
  import { option } from './config';
  import { cloneDeep } from 'lodash-es';
  import { CollapseItem, SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting';

  const props = defineProps({
    optionData: {
      type: Object as PropType<typeof option>,
      required: true,
    },
  });

  // 适应类型
  const fitList = [
    {
      value: 'fill',
      label: 'fill',
    },
    {
      value: 'contain',
      label: 'contain',
    },
    {
      value: 'cover',
      label: 'cover',
    },
    {
      value: 'scale-down',
      label: 'scale-down',
    },
    {
      value: 'none',
      label: 'none',
    },
  ];

  const textAlignOptions = [
    { label: '左对齐', value: 'left' },
    { label: '居中', value: 'center' },
    { label: '右对齐', value: 'right' },
  ];
</script>
