'use client';

/**
 * Lazy-loaded Map Components
 *
 * Heavy MapLibre GL (~800KB) is loaded only when components are rendered.
 * Use these for automatic code-splitting with Suspense fallback.
 *
 * For direct imports without lazy loading, use:
 * import { MapContainer } from '@djangocfg/ui-tools/map'
 */

import * as React from 'react';
import { createLazyComponent, MapLoadingFallback } from '../../components';

// ============================================================================
// Lazy Components
// ============================================================================

/**
 * LazyMapContainer - Lazy-loaded map container
 *
 * Automatically shows loading state while MapLibre GL loads (~800KB)
 */
export const LazyMapContainer = createLazyComponent(
  () => import('./components/MapContainer').then((mod) => ({ default: mod.MapContainer })),
  {
    displayName: 'LazyMapContainer',
    fallback: <MapLoadingFallback minHeight={400} />,
  }
);

/**
 * LazyMapView - Lazy-loaded map view (alias for MapContainer)
 */
export const LazyMapView = createLazyComponent(
  () => import('./components/MapContainer').then((mod) => ({ default: mod.MapView })),
  {
    displayName: 'LazyMapView',
    fallback: <MapLoadingFallback minHeight={400} />,
  }
);

// ============================================================================
// Re-export types for convenience
// ============================================================================

export type {
  MapContainerProps,
} from './components';

export type {
  MapViewport,
  MapStyleKey,
  MarkerData,
} from './types';
