import { RadioRecord } from '../../../views/visual/board/detail/config/util';
// import { DeviceTypeEnum } from '../../device/model/deviceModel';
import { DataType } from '../../device/model/modelOfMatterModel';
import { DataTypeEnum } from '/@/components/Form/src/externalCompns/components/StructForm/config';

export interface AddDataBoardParams {
  name: string;
  viewType: string;
  remark?: string;
}

export interface UpdateDataBoardParams extends AddDataBoardParams {
  id: string;
}

export interface GetDataBoardParams {
  page?: number;
  pageSize?: number;
  orderFiled?: string;
  orderType?: string;
}

export interface Layout {
  h: number;
  id: string;
  w: number;
  x: number;
  y: number;
}

export interface DataBoardRecord {
  name: string;
  roleIds: string[];
  updater: string;
  description: string;
  remark: string;
  viewType: string;
  enabled: boolean;
  updateTime: string;
  createTime: string;
  tenantProfileId: string;
  id: string;
  tenantExpireTime: string;
  icon: string;
  openUrl: string;
  tenantId: string;
  creator: string;
  layout: Layout[];
  defaultConfig: string;
  tenantStatus: string;
}

export interface DataBoardList {
  items: DataBoardRecord[];
  total: number;
}

export interface GradientInfo {
  value: number;
  key: string;
  color: string;
}

export interface ComponentInfo {
  fontColor: string;
  unit: string;
  gradientInfo: GradientInfo[];
  iconColor: string;
  icon: string;
  value?: string | number;
  updateTime?: number;
  showDeviceName: boolean;
}

export interface DataSource {
  attribute: string;
  deviceId: string;
  organizationId: string;
  attributeRename: string;
  deviceRename: string;
  slaveDeviceId: string;
  gatewayDevice: boolean;
  componentInfo: ComponentInfo;
  deviceName: string;
  deviceProfileId: string;
  tbDeviceId: string;

  // front usage
  uuid?: string;
  width?: number;
  height?: number;
  radio?: RadioRecord;
  deviceType?: DeviceTypeEnum;
}

export interface DataComponentRecord {
  dataBoardId: string;
  dataSource: DataSource[];
  frontId: string;
  name: string;
  tenantId: string;
  tenantStatus: string;
  description: string;
  roleIds: string[];
  updater: string;
  enabled: boolean;
  id: string;
  defaultConfig: string;
  tenantProfileId: string;
  remark: string;
  icon: string;
  tenantExpireTime: string;
  updateTime: string;
  creator: string;
  createTime: string;
}

export interface AddDataComponentParams {
  boardId: string;
  record: Partial<DataComponentRecord> & { layout?: Partial<Layout> };
}

export interface Layout {
  id: string;
  w: number;
  h: number;
  x: number;
  y: number;
}

export interface UpdateDataBoardLayoutParams {
  boardId: string;
  layout: Layout[];
}

export interface UpdateDataComponentParams {
  boardId: string;
  record: Partial<DataComponentRecord>;
}

export interface MasterDeviceList {
  deviceType: 'DIRECT_CONNECTION' | 'GATEWAY';
  deviceProfileId: string;
  tbDeviceId: string;
  id: string;
  name: string;
  label?: string;
  value?: string;
}

export interface ComponentInfoDetail {
  data: { componentData: DataComponentRecord[]; componentLayout: Layout[] };
}

export interface DeviceAttributeParams {
  deviceProfileId: string;
  dataType?: DataTypeEnum;
}

export interface DeviceAttributeRecord {
  name: string;
  identifier: string;
  detail: { dataType: DataType };
}

export interface SendCommandParams {
  deviceId: string;
  value: any;
}

export interface GetMeetTheConditionsDeviceParams {
  deviceLabel?: string;
  deviceType?: string;
  organizationId?: string;
  deviceProfileId?: string;
}
