import { ImageSourcePropType } from 'react-native';
import {
  COORDINATE_TYPE,
  DISTANCE_UNIT_TYPE,
  MAP_LOCALE_TYPE,
} from './CommandTypes';

// {"id":425049,"status":true,"name":"Machine Shop","description":"","tags":[],"keywords":[],"extensors":{},"locations":[{"mapId":7216,"waypointIds":[43102987]}],"uris":{"items":[]},"displayMode":1,"_mappedPoints":{"7216":true}}
export type JIBESTREAM_DESTINATION_TYPE = {
  id: number;
  name: string;
  description: string;
  tags: string[];
  keywords: string[];
  extensors: Object;
  locations: JIBESTREAM_LOCATION_TYPE[];
  uris: Object;
  displayMode: number;
  waypoints?: JIBESTREAM_WAYPOINT_TYPE[];
};

export type JIBESTREAM_PATH_API_TYPE = {
  id: number;
  name: string;
  description: string;
  accessibility: number;
  verticalWeight: number;
  maxFloors: number;
  weight: number;
  direction: number;
  locations: JIBESTREAM_LOCATION_TYPE[];
  uris: Object;
};

export type JIBESTREAM_AMENITY_TYPE = {
  id: number;
  name: string;
  description: string;
  status: boolean;
  keywords: any[];
  extensors: any[];
  locations: JIBESTREAM_LOCATION_TYPE[];
  uris: Object;
  svg: string;
};

export type JIBESTREAM_WAYPOINT_TYPE = {
  id: number;
  mapId: number;
  coordinates: number[];
  associations: {
    destinations: number[];
    amenities: number[];
  };
  xyz: {
    x: number;
    y: number;
    z: number;
  };
};

export type JIBESTREAM_PATH_TYPE = {
  mapId: number;
  mover: {
    moverId: number;
    speed: number;
    accessiblity: number;
    typeName: string;
    svg: null;
  };
  points: {
    id: number;
    mapId: number;

    // Manually added field
    associations?: {
      destinations: number[];
      amenities: number[];
    };
    xyz: {
      x: number;
      y: number;
      z: number;
    };
    x: number;
    y: number;
    z: number;

    // Manually added fields
    latitude: number;
    longitude: number;
  }[];
  cost: number;
  pixelDistance: number;
  mmDistance: number;
};

export type GEOJSON_PATH_TYPE = {
  distance: number;
  duration: number;
  startTime: number;
  endTime: number;
  legGeometry: {
    properties: Object;
    type: 'Feature';
    geometry: {
      type: 'LineString';
      coordinates: number[][];
    };
  };
  steps: {
    distance: number;
    directions: string;
    lat: number;
    lon: number;
    prepend: string;
    direction: string;
  }[];
};

export type JIBESTREAM_LOCATION_TYPE = {
  mapId: number;
  waypointIds: number[];
};

export type JIBESTREAM_STYLE_TYPE = {
  color?: string;
  alpha?: number;
  stroke?: string;
  strokeWidth?: number;
  strokeAlpha?: number;
};

export type JIBESTREAM_FONT_TYPE = {
  align?: string;
  fill?: string;
  fontFamily?: string;
  fontSize?: number & string;
  wordWrap?: boolean;
  wordWrapWidth?: number;
};

export type INSTRUCTION_TYPE = {
  fullText: string;
  prepend: string;
  direction: string;
  destinationName?: string;
  distance: number;
  remainingDistance: number;
  wp: number;
  dest: number;
  startPoint?: number[];
  endPoint?: number[];
  startPointLngLat?: number[];
  endPointLngLat?: number[];
};

export type MAP_CREDENTIALS_TYPE = {
  clientId: string;
  clientSecret: string;
  customerId: number;
  venueId: number;
  host: string;
  locale?: MAP_LOCALE_TYPE;
};

export type MAP_IMAGE_TYPE = {
  iconSource?: ImageSourcePropType;
  iconImage?: any;
  iconUrl?: string;
  iconWidth?: number;
  iconHeight?: number;
  iconOffsetX?: number;
  iconOffsetY?: number;
};

export type MAP_OPTIONS_TYPE = {
  snap?: {
    grid?: boolean;
    waypoint?: boolean;
    path?: boolean;
    pathThreshold?: number;
  };
  user?: MAP_IMAGE_TYPE & {
    maxSpeed?: number;
  };
  userCircle?: {
    delayBetweenPulses?: number;
    pulseAnimationDuration?: number;
    confidenceColor?: string;
    confidenceOpacity?: number;
    confidenceRadius?: number;
  };
  navigation?: {
    autoReroute?: boolean;
    autoRerouteThreshold?: number;
    directionsUnit?: DISTANCE_UNIT_TYPE;
  };
};

export type MAP_CENTER_OPTIONS_TYPE = {
  point: number[];
  zoom?: number;
  rotation?: number;
  animationDuration?: number;
  format: COORDINATE_TYPE;
};

export type MAP_ZOOM_BOUNDS_OPTIONS_TYPE = {
  topLeft: number[];
  bottomRight: number[];
  rotation?: number;
  animationDuration?: number;
  format?: COORDINATE_TYPE;
};

export type MAP_ZOOM_TO_PATH_OPTIONS_TYPE = {
  margin: number;
  rotation?: number;
  animationDuration?: number;
};

export type MAP_CENTER_USER_OPTIONS_TYPE = {
  zoom?: number;
  rotation?: number;
  animationDuration: number;
};

export type SIMULATION_OPTIONS_TYPE = {
  movementSpeed: number;
  updateRate: number;
  variance_m: number;
};

export type SIMULATION_STATUS_VALUES_TYPE = 'ACTIVE' | 'PAUSED';

export type SIMULATION_STATUS_TYPE = {
  status?: SIMULATION_STATUS_VALUES_TYPE;
  details?: {
    timeRemaining: number;
    currLoc: number[];
    currRndmLoc: number[];
    pathLeg: number;
  };
};

export type FOLLOW_BLUE_DOT_PROPERTIES_TYPE = {
  enabled: boolean;
  rotate: boolean;
  interval: number;
};

export type MAP_TAP_EVENT_TYPE = {
  x: number;
  y: number;
  destination?: JIBESTREAM_DESTINATION_TYPE;
};

export type JIBESTREAM_GEOFENCE_TYPE = {
  id: number;
  name: string;
  coordinates: number[][];
};

export interface JIBESTREAM_LR_COORDINATES_TYPE {
  topLeft: number[];
  bottomRight: number[];
}

export interface JIBESTREAM_BUILDING_TYPE {
  id: number;
  name: string;
  description: string;
  address: string;
  coordinates: number[][];
}

export type JIBESTREAM_MAP_LABEL_TYPE = {
  id: number;
  name: string;
  status: boolean;
  mapLabelInstances: {
    items: any[];
  };
  uris: Object;
};

export type JIBESTREAM_MAP_LABEL_INSTANCE_TYPE = {
  id: number;
  name: string;
  mapId: number;
  position: number[];
  rotation: number;
  allLevels: boolean;
};

export type SCREEN_ROTATED_EVENT_TYPE = {
  degrees: number;
};
