import { reactive } from 'vue'
import { __sdk } from '../../sdk'

interface ToolbarItem {
  text: string
  type: string
  icon: string
  data?: Array<any>
  checked?: boolean
  highLight?: boolean
}

interface Toolbar {
  list: Array<ToolbarItem>
}

interface WidgetItem {
  icon: string
  name: string
  text: string
  type?: string
}

interface Widget {
  type: string
  name: string
  hide?: boolean
  list: Array<WidgetItem>
}
interface CadInfo {
  cad: any
  prop: any
  toolbar: any
  execute: Function
  selected: Function
  showProps: Function
  hideProps: Function
  widgets: Array<Widget>
  furnitures: Array<Widget>
  toolbars: Array<Toolbar>
}
export default reactive<CadInfo>({
  get cad() {
    return __sdk.Plugins.EditCAD
  },
  execute: function (name: string, value?: string) {
    this.cad.uiControl.execute(name, value)
  },
  selected: function (name: string) {
    this.cad.uiControl.selectUI = name
  },
  showProps: (name: string) => {},
  hideProps: () => {},
  prop: null,
  toolbar: {},
  toolbars: [
    {
      list: [
        { icon: 'repeal', text: '撤销', type: 'recall', highLight: false },
        { icon: 'recover', text: '恢复', type: 'recover', highLight: false },
      ],
    },
    {
      list: [
        { icon: 'clear', text: '清空', type: 'clear', highLight: false },
        { icon: 'rotate', text: '旋转', type: 'rotate', highLight: true },
        { icon: 'reset', text: '恢复默认', type: 'default', highLight: true },
      ],
    },
    {
      list: [
        { icon: 'adapt', text: '适应视图', type: 'flex', highLight: true },
        {
          icon: 'eye-s',
          checked: false,
          text: '显示设置',
          type: 'viewSetting',
          highLight: true,
          data: [
            {
              icon: 'nor',
              checked: false,
              text: '漫游点',
              type: 'panos',
              highLight: true,
            },
            {
              icon: 'nor',
              checked: true,
              text: '底图',
              type: 'texture',
              highLight: true,
            },
          ],
        },
      ],
    },
    {
      list: [
        { icon: 'download', text: '下载', type: 'download', highLight: true },
        { icon: 'none', text: '测量单位：', type: 'settings', highLight: true },
      ],
    },
  ],
  widgets: [
    {
      type: 'wall',
      name: '墙',
      list: [
        { icon: 'cad-neiqiang', name: 'Wall', text: '内墙' },
        { icon: 'cad-waiqiang', name: 'OutWall', text: '外墙' },
      ],
    },
    {
      type: 'door',
      name: '门',
      list: [
        { icon: 'cad-men', name: 'SingleDoor', text: '单开门' },
        { icon: 'cad-shuangkaimen', name: 'DoubleDoor', text: '双开门' },
        { icon: 'cad-yimen', name: 'SlideDoor', text: '移门' },
        { icon: 'cad-yakou', name: 'Pass', text: '垭口' },
      ],
    },
    {
      type: 'window',
      name: '窗',
      list: [
        { icon: 'cad-chuang', name: 'SingleWindow', text: '一字窗' },
        { icon: 'cad-piaochuang', name: 'BayWindow', text: '一字飘窗' },
        { icon: 'cad-luodichuang', name: 'FrenchWindow', text: '落地窗' },
      ],
    },
    {
      type: 'structure',
      name: '构建',
      list: [
        { icon: 'cad-zhuzi', name: 'Beam', text: '柱子' },
        { icon: 'cad-yandao', name: 'Flue', text: '烟道' },
        { icon: 'cad-loudao', name: 'Corridor', text: '楼道' },
      ],
    },
    {
      type: 'namespace',
      name: '标注',
      list: [{ icon: 'cad-dange', name: 'Tag', text: '标注' }],
    },
    {
      type: 'Compass',
      name: '指南针',
      hide: true,
      list: [{ icon: 'compass', name: 'compass', text: '指南针' }],
    },
    {
      type: 'WallCorner',
      name: '点',
      hide: true,
      list: [{ icon: 'WallCorner', name: 'WallCorner', text: '点' }],
    },
  ],
  furnitures: [
    {
      type: 'saloon',
      name: '客餐厅',
      list: [
        { icon: 'TV', name: 'TV', text: '电视' },
        { icon: 'CombinationSofa', name: 'CombinationSofa', text: '组合沙发' },
        { icon: 'SingleSofa', name: 'SingleSofa', text: '单人沙发' },
        { icon: 'TeaTable', name: 'TeaTable', text: '茶几' },
        { icon: 'Carpet', name: 'Carpet', text: '地毯' },
        { icon: 'Plant', name: 'Plant', text: '植物' },
        { icon: 'DiningTable', name: 'DiningTable', text: '餐桌' },
      ],
    },
    {
      type: 'bedRoom',
      name: '卧室',
      list: [
        { icon: 'DoubleBed', name: 'DoubleBed', text: '双人床' },
        { icon: 'SingleBed', name: 'SingleBed', text: '单人床' },
        { icon: 'Wardrobe', name: 'Wardrobe', text: '衣柜' },
        { icon: 'Dresser', name: 'Dresser', text: '梳妆台' },
        { icon: 'BedsideCupboard', name: 'BedsideCupboard', text: '床头柜' },
        { icon: 'Pillow', name: 'Pillow', text: '抱枕' },
      ],
    },
    {
      type: 'kitchenToilet',
      name: '厨卫',
      list: [
        { icon: 'GasStove', name: 'GasStove', text: '燃气灶' },
        { icon: 'Cupboard', name: 'Cupboard', text: '橱柜' },
        { icon: 'Bathtub', name: 'Bathtub', text: '浴缸' },
        { icon: 'Closestool', name: 'Closestool', text: '马桶' },
        { icon: 'Washstand', name: 'Washstand', text: '洗漱台' },
      ],
    },
    {
      type: 'other',
      name: '其他',
      list: [
        { icon: 'Desk', name: 'Desk', text: '书桌' },
        { icon: 'BalconyChair', name: 'BalconyChair', text: '阳台椅' },
        { icon: 'Elevator', name: 'Elevator', text: '电梯' },
      ],
    },
  ],
})
