export interface Address {
  lat: number;
  lng: number;
  calle: string;
  numero: string;
  ciudad: string;
  zona: string;
  pais: string;
  codigoPostal: string;
}
export interface Place {
  address_components: AddressComponent[];
  formatted_address: string;
  geometry: Geometry;
  place_id: string;
  types: string[];
}

export interface Seduvi {
  _id?: string;
  alcaldia?: string;
  calle?: string;
  no_externo?: number;
  colonia?: string;
  codigo_pos?: number;
  superficie?: number;
  uso_descri?: string;
  densidad_d?: string;
  niveles?: number;
  altura?: number | null;
  area_libre?: number;
  minimo_viv?: number | null;
  liga_ciuda?: string;
  longitud?: number;
  latitud?: number;
  location?: {
    coordinates?: [number, number];
  };
  tipo: 'plurifamiliar' | 'unifamiliar' | 'pyme';
  viviendas?: number | null;
  _naturgy?: {
    es_comercio?: boolean;
    es_cesado?: boolean;
    tiene_servicio?: boolean;
  };
}

export interface AddressComponent {
  long_name: string;
  short_name: string;
  types: string[];
}

export interface Geometry {
  bounds: Bounds;
  location: LatLng;
  location_type: string;
  viewport: Bounds;
}

export interface Bounds {
  northeast: LatLng;
  southwest: LatLng;
}

export interface LatLng {
  lat: number;
  lng: number;
}

export type AddressField = keyof Omit<
  AppLocation,
  'geolocation' | 'fullAddress' | 'registry' | 'confirmed' | 'street_between_1' | 'street_between_2' | 'colony' | 'town' | 'floor_number' | 'door_number' | 'interior_number'
>;

export interface AppLocation {
  id?: number;
  geolocation: Geolocation;
  streetNumber: string;
  street: string;
  city: string;
  zone: string;
  town: string;
  country: string;
  postalCode: string;
  fullAddress?: string;
  registry?: string; // numero de catastro
  fecha_validacion?: string;
  colony?: string;
  confirmed?: boolean;
  street_between_1?: string;
  street_between_2?: string;
  door_number?: string;
  floor_number?: string;
  interior_number?: string;
}

export interface AppLocationLocale {
  id?: number;
  calle: string | null;
  numero: string | number;
  zona: string | null;
  pais: string | null;
  ciudad: string | null;
  codigoPostal: string | null;
  lat: number | null;
  lng: number | null;
  catastro: string | null;
  confirmada: boolean | null;
  provincia?: string;
  cod_postal?: string;
  municipio?: string;
  colonia?: string;
  entre_calle?: string;
  entre_calle2?: string;
  latitude?: number;
  longitude?: number;
  edificio?: number;
  departamento?: number;
  numero_interior?: number;
}

export type Geolocation = { lng: number; lat: number };

export const defaultLocation: AppLocation = {
  geolocation: { lat: 0, lng: 0 },
  streetNumber: '',
  street: '',
  city: '',
  zone: '',
  country: '',
  postalCode: '',
  door_number: '',
  floor_number: '',
  interior_number: '',
  town: '',
  colony: '',
  street_between_1: '',
  street_between_2: '',
  registry: '',
  confirmed: false,
};
Object.freeze(defaultLocation);

export interface Place {
  address_components: AddressComponent[];
  formatted_address: string;
  geometry: Geometry;
  place_id: string;
  types: string[];
}

export interface AddressComponent {
  long_name: string;
  short_name: string;
  types: string[];
}
export interface RawLocation {
  route: string;
  street_number: string;
  locality: string;
  administrative_area_level_1: string;
  country: string;
  postal_code: string;
}

export interface UbicacionRaw {
  ID_UBICACION: number;
  ID_CONTACTO: null;
  ID_PRODUCTO: number;
  ID_ENTIDAD_BANCARIA: null;
  CODIGO: null;
  DESCRIPCION: null;
  NOMBRE: null;
  ID_PAIS: null;
  PROVINCIA: string;
  PAIS: string;
  ID_ZONA: null;
  CIUDAD: string;
  MUNICIPIO: null;
  LOCALIDAD: null;
  COLONIA: null;
  COD_POSTAL: string;
  POBLACION: null;
  CALLE: string;
  NUMERO: number;
  NUMERO_INTERIOR: null;
  ENTRE_CALLE: null;
  ENTRE_CALLE2: null;
  MANZANA: null;
  LOTE: null;
  EDIFICIO: null;
  DEPARTAMENTO: null;
  LONGITUDE: number;
  LATITUDE: number;
  CATASTRO: string;
  FECHA_VALIDACION: Date;
  ESTADO: number;
  FECHA_UPD: Date;
}

export interface ZonaPais {
  ID_ZONA: number;
  NOMBRE: string;
  ID_PAIS: number;
  ID_DELEGACION_EXCLUSIVA: null;
  ESTADO: number;
  FECHA_UPD: Date;
  FECHA_CREATED: Date;
}
