import type {
  WidgetActionListItem,
  widgetActionType,
  WidgetMeta,
  WidgetProto,
  WidgetToolkit,
} from '../../../types/widgetTypes';
import {
  initBackgroundTpl,
  initBorderTpl,
  initPaddingTpl,
  initTitleTpl,
  initWidgetName, PaddingI18N, TitleI18N,
  widgetTpl,
} from '../../WidgetManager/utils/init';
import { WHITE } from '../../../../../../styles/StyleConstants';
import { ORIGINAL_TYPE_MAP } from '../../../constants';
export const widgetMeta: WidgetMeta = {
  icon: 'export-widget',
  originalType: ORIGINAL_TYPE_MAP.exportBtn,
  canWrapped: true,
  controllable: false,
  linkable: false,
  canFullScreen: false,
  singleton: true,

  i18ns: [
    {
      lang: 'zh-CN',
      translation: {
        desc: '导出',
        widgetName: '导出',
        action: {},
        title: TitleI18N.zh,
        background: { backgroundGroup: '背景' },
        padding: PaddingI18N.zh,

        border: { borderGroup: '边框' },
      },
    },
    {
      lang: 'en-US',
      translation: {
        desc: 'exportBtn',
        widgetName: 'export',
        action: {},
        title: TitleI18N.en,
        background: { backgroundGroup: 'Background' },
        padding: PaddingI18N.en,

        border: { borderGroup: 'Border' },
      },
    },
  ],
};
const NameI18N = {
  zh: '导出',
  en: 'ExportBtn',
};
export const widgetToolkit: WidgetToolkit = {
  create: opt => {
    const widget = widgetTpl();
    widget.id = widgetMeta.originalType + widget.id;
    widget.parentId = opt.parentId || '';
    widget.datachartId = opt.datachartId || '';
    widget.viewIds = opt.viewIds || [];
    widget.relations = opt.relations || [];
    widget.config.originalType = widgetMeta.originalType;
    widget.config.type = 'button';
    widget.config.name = opt.name || initWidgetName(NameI18N);

    widget.config.rect.width = 100;
    widget.config.rect.height = 60;
    widget.config.pRect.width = 2;
    widget.config.pRect.height = 1;

    widget.config.customConfig.props = [
      { ...initTitleTpl() },
      { ...initPaddingTpl() },
      { ...initBorderTpl() },
      { ...initBackgroundTpl(WHITE) },
    ];

    return widget;
  },
  getName(key) {
    return initWidgetName(NameI18N, key);
  },
  getDropDownList(...arg) {
    const list: WidgetActionListItem<widgetActionType>[] = [
      {
        key: 'edit',
        renderMode: ['edit'],
      },
      {
        key: 'delete',
        renderMode: ['edit'],
      },
      {
        key: 'lock',
        renderMode: ['edit'],
      },
      {
        key: 'group',
        renderMode: ['edit'],
      },
    ];
    return list;
  },
  edit() {},
  save() {},
  // lock() {},
  // unlock() {},
  // copy() {},
  // paste() {},
  // delete() {},
  // changeTitle() {},
  // getMeta() {},
  // getWidgetName() {},
  // //
};
const exportBtnProto: WidgetProto = {
  originalType: widgetMeta.originalType,
  meta: widgetMeta,
  toolkit: widgetToolkit,
};
export default exportBtnProto;
