/**
 * 适配老的大屏组件数据格式传入
 */
import React from 'react';
import { AlgorithmVersionStr, HumanProperty, ObjectType, Rect, IScreenshotButtonProp } from '@zhst/types'
import { VideoViewProps, ImgViewProps, VideoViewRef, ImgViewRef } from '@zhst/meta'

export type TAB_TYPE = 'COMPATER' | 'NORMAL' | 'TRACK';
export type MODEL_TYPE = 'VIDEO' | 'IMAGE';

export interface CarouselProps {
  hasPre?: boolean;
  hasNext?: boolean;
  selectIndex: number;
  setSelectIndex: React.Dispatch<React.SetStateAction<number>>;
  dataSource: Array<{
    key: string;
    url: string;
  }>;
}

export type ISelectItem = Partial<Omit<ImgViewProps, 'screenshotButtonRender'>> &
  Partial<Omit<VideoViewProps, 'screenshotButtonRender'>>;

export interface HeaderProps {
  value: TAB_TYPE;
  onChange: (type: TAB_TYPE) => void;
  tabsFilter: TAB_TYPE[];
}

export interface ParamProps {
  tab: string;
  selectItem: ISelectItem;
  imgViewRef: React.MutableRefObject<ImgViewRef>;
  VideoViewRef: React.MutableRefObject<VideoViewRef>;
  model: MODEL_TYPE;
  setModel: React.Dispatch<React.SetStateAction<MODEL_TYPE>>;
  /* 可观测值 */
  scale$: number;
  showCrop$: boolean;
}


export interface BigImageData {
  //imageKey 小图
  extendRectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
  rectList: (Rect & { algorithmVersion: AlgorithmVersionStr; imageKey: string })[];
  attachImg: { url: string; label: '形体' | '人脸' }[];
  odRect: Rect;
  imageKey: string; //大图
  imgSummary: string; //摘要图

  objectExtImageKey: string; //比对到的目标图扩展图 === imgSummary
  attributeList: { label: string; list: any[] }[];
  archiveImages?: any;
  spaceName: string;

  objectType: ObjectType;
  objectId: string; //这张摘要本身的Id
  bodyObjectId?: string;
  faceObjectId?: string; //这张摘要下的人脸Id(如果有)
  sourceObjectId?: string; //这张摘要上游的形体Id(如果有)
  cameraId: string;
  cameraName: string;
  selectIndex: number;
  humanProperty: HumanProperty;
  qualityScore?: number; //人脸质量分
  score: number; //相似度
  timestamp: string;
  bodyImageUrl: string;
  faceImageUrl: string;
  algorithmVersion: AlgorithmVersionStr;

  bodySpaceName: string;
  faceSpaceName: string;

  solutionId?: string;
  [index: string]: any;
}

interface IOldImageData {
  visible?: boolean;
  defaultModel?: MODEL_TYPE;
  onClose?: () => void;
  isLoading?: boolean;
  hasPre?: boolean;
  hasNext?: boolean;
  selectIndex?: number;
  onSelectIndexChange?: (i: number) => void;
  dataSource: BigImageData[];
  dataSources: BigImageData[];
  relatedData?: BigImageData[];
  transformPropFunc: (item: any) => ISelectItem;
  transformVideoPropFunc: (
    item: ISelectItem
  ) => Promise<Omit<VideoViewProps, 'screenshotButtonRender'>>;
  screenshotButtonRender?: (screenshotButtonProp: IScreenshotButtonProp) => React.ReactElement;
  showTool?: boolean;
  showCarousel?: boolean;
  imgViewProp?: Partial<ImgViewProps>;
  videoViewProp?: Partial<VideoViewProps>;
  ToolProps?: Partial<ToolProps>;
  nullDialogProp?: {
    emptyText?: string;
  };
  showHeader?: boolean;
  tabsFilter?: TAB_TYPE[];
  useVirtual?: boolean;
  loadNext?: (i: number) => Promise<void>;
  loadPre?: (i: number) => Promise<void>;
  children: React.ReactNode;
  title?: string;
  specialTitle?: string;
  isRelated?: boolean;
  carouselProp?: Partial<CarouselProps>;
}

export interface ToolProps {
  renderRight?: (props: ParamProps) => React.ReactNode;
  renderLeft?: (props: ParamProps) => React.ReactNode;
  renderVideoBtn?: boolean;
  param: ParamProps;
  disableVideo: boolean;
}

export interface ImageModalDataProps {
  targetData: []
  compactData: []
}

const adapter = (data: IOldImageData): ImageModalDataProps => {

  return {
    targetData: [],
    compactData: [],
  }
}


export default adapter
