import { AssetType } from '@/constant'
import { WidgetType } from '../constant'
import {
  positionConfig,
  toggleTypeConfig,
  animationConfig,
  intervalConfig
} from './base'

export default {
  type: WidgetType.IMAGE,
  label: '图片',
  icon: 'w-image',
  defaults (scale) {
    return {
      top: 0,
      left: 0,
      width: 300 * scale.width | 0,
      height: 200 * scale.height | 0,
      radius: 0,
      sources: [],
      ...toggleTypeConfig.props,
      ...animationConfig.props,
      ...intervalConfig.props
    }
  },
  transform: {
    color: ['backgroundColor']
  },
  copy ({ sources, ...widget }) {
    widget.sources = sources.map(source => {
      return { ...source }
    })
    return widget
  },
  options: [
    {
      label: '配置',
      list: [
        ...toggleTypeConfig.options,
        ...animationConfig.options,
        ...intervalConfig.options,
        {
          key: 'sources',
          type: 'data',
          label: '图片',
          options: {
            type: [AssetType.IMAGE]
          }
        }
      ]
    },
    positionConfig
  ]
}
