/**
 * Office location data + map tile configuration for the Contact section map.
 *
 * Kept dependency-free (no Leaflet runtime import) so it can be safely consumed
 * by both server and client modules. Types model `[lat, lng]` tuples that are
 * directly compatible with Leaflet's `LatLngExpression`.
 *
 * Coordinates are the real Doormile operational sites, verified against
 * satellite view — not generic city-centre points.
 */

/** A `[latitude, longitude]` coordinate pair. */
export type LatLng = [number, number];

export interface OfficeLocation {
  /** Stable, unique key (used for React keys + analytics). */
  readonly id: string;
  /** Short city label, shown on the navigation button. */
  readonly city: string;
  /** Human-readable label shown in the a11y fallback + marker title. */
  readonly name: string;
  /** Compact heading shown in the marker tooltip/popup (e.g. "Hyderabad HQ"). */
  readonly shortLabel: string;
  /** `[latitude, longitude]`. */
  readonly position: LatLng;
  /** Headquarters gets the largest, glowing, default-active marker. */
  readonly isHeadquarters?: boolean;
  /** Full office address lines. */
  readonly address: readonly string[];
}

/**
 * The three permanent office markers, ordered for the navigation row by
 * operational hierarchy: Hyderabad (HQ) → Bengaluru → Coimbatore. The
 * headquarters is conveyed purely through styling (active state + border +
 * glow), not through icons or label text.
 */
export const OFFICE_LOCATIONS: readonly OfficeLocation[] = [
  {
    id: "hyderabad",
    city: "Hyderabad",
    name: "Doormile Headquarters",
    shortLabel: "Hyderabad HQ",
    // Vision Ultima, Jayabheri Enclave, Gachibowli — verified on satellite.
    position: [17.4484, 78.3573],
    isHeadquarters: true,
    address: [
      "5th Floor, Vision Ultima,",
      "Street No.3, Jayabheri Enclave,",
      "Gachibowli, Hyderabad,",
      "Telangana 500032"
    ],
  },
  {
    id: "bengaluru",
    city: "Bengaluru",
    name: "Bengaluru Hub",
    shortLabel: "Bengaluru Hub",
    // Resolved from the supplied Google Maps share link — verified on satellite.
    position: [12.9929351, 77.6988599],
    address: [
      "C612, 6th Floor,",
      "Trifecta Starlight, ITPL Road,",
      "Garudacharapalya, Mahadevapura,",
      "Bangalore 560048,",
      "Karnataka, India"
    ],
  },
  {
    id: "coimbatore",
    city: "Coimbatore",
    name: "Coimbatore Hub",
    shortLabel: "Coimbatore Hub",
    // Mayflower Valencia, Coimbatore — verified against satellite view.
    position: [11.0191, 76.9883],
    address: [
      "Mayflower Valencia,",
      "Near Nava India Bus Stop,",
      "Avinashi Road, Udayampalayam,",
      "Tamil Nadu 641003"
    ],
  },
];

/** The headquarters office — focused by default on load. Falls back to the first office. */
export const HQ_OFFICE: OfficeLocation =
  OFFICE_LOCATIONS.find((office) => office.isHeadquarters) ?? OFFICE_LOCATIONS[0];

export interface TileLayerConfig {
  readonly url: string;
  readonly attribution: string;
  readonly maxZoom: number;
}

/**
 * Esri "World Imagery" satellite basemap.
 * Attribution is mandatory per Esri's terms of use.
 * @see https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9
 */
export const ESRI_WORLD_IMAGERY: TileLayerConfig = {
  url: "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
  attribution:
    'Imagery &copy; <a href="https://www.esri.com/" target="_blank" rel="noopener noreferrer">Esri</a>, Maxar, Earthstar Geographics &amp; the GIS User Community',
  maxZoom: 19,
};

/** City-level zoom used when an office is selected (and for the initial HQ view). */
export const MAP_FOCUS_ZOOM = 13;

/**
 * Initial center/zoom: the experience opens focused on the Hyderabad HQ so the
 * command-centre reads as the heart of the network the instant the map paints.
 */
export const MAP_INITIAL_CENTER: LatLng = HQ_OFFICE.position;
export const MAP_INITIAL_ZOOM = MAP_FOCUS_ZOOM;
