/**
 * Type declarations for Google Maps API
 * These define the global google.maps namespace when the API is loaded dynamically
 */

declare global {
  namespace google {
    namespace maps {
      /**
       * Google Maps Map instance
       */
      class Map {
        constructor(
          container: HTMLElement | null,
          options?: google.maps.MapOptions
        );
        setCenter(latlng: google.maps.LatLng | google.maps.LatLngLiteral): void;
        setZoom(zoom: number): void;
        fitBounds(
          bounds: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral,
          padding?: number | { top: number; right: number; bottom: number; left: number }
        ): void;
        getCenter(): google.maps.LatLng | undefined;
        getZoom(): number | undefined;
      }

      /**
       * Google Maps Marker
       */
      class Marker {
        constructor(options?: google.maps.MarkerOptions);
        setMap(map: google.maps.Map | null): void;
        setPosition(latlng: google.maps.LatLng | google.maps.LatLngLiteral): void;
        getPosition(): google.maps.LatLng | undefined;
        setTitle(title: string): void;
        addListener(
          eventName: string,
          callback: (...args: any[]) => void
        ): google.maps.MapsEventListener;
      }

      /**
       * Google Maps InfoWindow
       */
      class InfoWindow {
        constructor(options?: google.maps.InfoWindowOptions);
        open(target?: google.maps.Map | { anchor?: any; map?: google.maps.Map | null; shouldFocus?: boolean } | null, anchor?: google.maps.Marker): void;
        close(): void;
        setContent(content: string | HTMLElement): void;
      }

      /**
       * Google Maps LatLng
       */
      class LatLng {
        constructor(lat: number, lng: number);
        lat(): number;
        lng(): number;
      }

      /**
       * Google Maps LatLngBounds
       */
      class LatLngBounds {
        constructor(sw?: google.maps.LatLng, ne?: google.maps.LatLng);
        extend(point: google.maps.LatLng): google.maps.LatLngBounds;
      }

      /**
       * Google Maps Symbol Path enum
       */
      enum SymbolPath {
        CIRCLE = 'CIRCLE',
        FORWARD_CLOSED_ARROW = 'FORWARD_CLOSED_ARROW',
        FORWARD_OPEN_ARROW = 'FORWARD_OPEN_ARROW',
        BACKWARD_CLOSED_ARROW = 'BACKWARD_CLOSED_ARROW',
        BACKWARD_OPEN_ARROW = 'BACKWARD_OPEN_ARROW'
      }

      namespace marker {
        interface AdvancedMarkerElementOptions {
          position?: google.maps.LatLng | google.maps.LatLngLiteral;
          map?: google.maps.Map | null;
          title?: string;
          content?: HTMLElement;
        }

        class AdvancedMarkerElement {
          constructor(options?: AdvancedMarkerElementOptions);
          map: google.maps.Map | null;
          position?: google.maps.LatLng | google.maps.LatLngLiteral;
          content?: HTMLElement;
          title?: string;
          addListener(
            eventName: string,
            callback: (...args: any[]) => void
          ): google.maps.MapsEventListener;
        }
      }

      /**
       * Google Maps Event Listener
       */
      interface MapsEventListener {
        remove(): void;
      }

      /**
       * Map Options
       */
      interface MapOptions {
        zoom?: number;
        center?: google.maps.LatLng | google.maps.LatLngLiteral;
        mapTypeId?: string;
        mapId?: string;
        [key: string]: any;
      }

      /**
       * Marker Options
       */
      interface MarkerOptions {
        position?: google.maps.LatLng | google.maps.LatLngLiteral;
        map?: google.maps.Map;
        title?: string;
        icon?: string | google.maps.Icon;
        [key: string]: any;
      }

      /**
       * Info Window Options
       */
      interface InfoWindowOptions {
        content?: string | HTMLElement;
        position?: google.maps.LatLng | google.maps.LatLngLiteral;
        maxWidth?: number;
        [key: string]: any;
      }

      /**
       * Icon options
       */
      interface Icon {
        url?: string;
        size?: { width: number; height: number };
        [key: string]: any;
      }

      /**
       * LatLng Literal
       */
      interface LatLngLiteral {
        lat: number;
        lng: number;
      }

      /**
       * LatLngBounds Literal
       */
      interface LatLngBoundsLiteral {
        east: number;
        north: number;
        south: number;
        west: number;
      }
    }
  }
}

export {};
