import { Domain, ScalarAny } from '@things-factory/shell'
import { User } from '@things-factory/auth-base'
import { ObjectType, Field, InputType, Int, Float, ID, registerEnumType } from 'type-graphql'
import { RobotArm, Matrix, HandEyeConfig, ROI, Pose } from '../robotarm/robotarm-type'

// type TrackingCamera {
//   id: String
//   name: String
//   domain: Domain
//   description: String
//   type: String
//   endpoint: String
//   active: Boolean
//   config: Object
//   baseRobotArm: RobotArm
//   cameraMatrix: Matrix
//   distortionCoefficient: [Float]
//   handEyeConfig: HandEyeConfig
//   handEyeMatrix: Matrix
//   rois: [ROI]
//   camObjOffset: Pose
//   width: String
//   height: String
//   updater: User
//   creator: User
//   updatedAt: String
//   createdAt: String
// }
@ObjectType()
export class TrackingCamera {
  @Field(type => ID, { nullable: true })
  id?: string

  @Field()
  name: string

  @Field(type => Domain)
  domain: Domain

  @Field({ nullable: true })
  description?: string

  @Field({ nullable: true })
  type?: string

  @Field({ nullable: true })
  endpoint?: string

  @Field({ nullable: true })
  active: boolean

  // TODO: check object
  @Field(type => ScalarAny, { nullable: true })
  params?: any

  @Field(type => RobotArm, { nullable: true })
  baseRobotArm?: RobotArm

  @Field(type => Matrix, { nullable: true })
  cameraMatrix?: Matrix

  @Field(type => [Float], { nullable: true })
  distortionCoefficient?: number[]

  @Field(type => HandEyeConfig, { nullable: true })
  handEyeConfig?: HandEyeConfig

  @Field(type => Matrix, { nullable: true })
  handEyeMatrix?: Matrix

  @Field(type => [ROI], { nullable: true })
  rois?: ROI[]

  @Field(type => Pose, { nullable: true })
  camObjOffset?: Pose

  @Field({ nullable: true })
  width: string

  @Field({ nullable: true })
  height?: string

  @Field(type => User, { nullable: true })
  updater: User

  @Field(type => User, { nullable: true })
  creator: User

  @Field({ nullable: true })
  updatedAt: string

  @Field({ nullable: true })
  createdAt: string
}

// type TrackingCameraList {
//   items: [TrackingCamera]
//   total: Int
// }
@ObjectType()
export class TrackingCameraList {
  @Field(type => [TrackingCamera])
  items: TrackingCamera[]

  @Field(type => Int)
  total: number
}
