import type { ProviderData } from '../../../components/pages/ProvidersStep';
import type { PackagesStepProvider, ProviderTier } from '../../../components/pages/PackagesStep';
import { assetUrl } from '../assets';

export interface DemoProvider extends ProviderData {
  id: string;
  tier: ProviderTier;
}

export const providers: DemoProvider[] = [
  {
    id: 'parsons',
    name: 'H.Parsons Funeral Directors',
    location: 'Wentworth, NSW',
    verified: true,
    tier: 'verified',
    imageUrl: assetUrl('/images/venues/hparsons-funeral-home-wollongong/01.jpg'),
    logoUrl: assetUrl('/images/providers/hparsons-funeral-directors/logo.png'),
    rating: 4.6,
    reviewCount: 7,
    startingPrice: 1800,
    distanceKm: 2.3,
    coords: { lat: -34.1074, lng: 141.9166 },
    description:
      'H.Parsons delivers premium funeral services with exceptional care and support, guiding families through every step with empathy and expertise.',
  },
  {
    id: 'rankins',
    name: 'Rankins Funeral Services',
    location: 'Wollongong, NSW',
    verified: true,
    tier: 'verified',
    imageUrl: assetUrl('/images/venues/rankins-funeral-home-warrawong/01.jpg'),
    logoUrl: assetUrl('/images/providers/rankins-funerals/logo.png'),
    rating: 4.8,
    reviewCount: 23,
    startingPrice: 2450,
    distanceKm: 5.1,
    coords: { lat: -34.487, lng: 150.897 },
  },
  {
    id: 'wollongong-city',
    name: 'Wollongong City Funerals',
    location: 'Wollongong, NSW',
    verified: false,
    tier: 'tier3',
    rating: 4.2,
    reviewCount: 15,
    startingPrice: 3400,
    distanceKm: 6.8,
    coords: { lat: -34.4278, lng: 150.8931 },
  },
  {
    id: 'killick',
    name: 'Killick Family Funerals',
    location: 'Kingaroy, QLD',
    verified: true,
    tier: 'verified',
    imageUrl: assetUrl('/images/venues/killick-family-funerals-chapel-kingaroy/01.jpg'),
    logoUrl: assetUrl('/images/providers/killick-family-funerals/logo.png'),
    rating: 4.9,
    reviewCount: 15,
    startingPrice: 3100,
    distanceKm: 8.4,
    coords: { lat: -26.5408, lng: 151.8388 },
  },
  {
    id: 'mackay',
    name: 'Mackay Family Funeral Directors',
    location: 'Ourimbah, NSW',
    verified: true,
    tier: 'verified',
    imageUrl: assetUrl('/images/venues/mackay-family-garden-estate/01.jpg'),
    logoUrl: assetUrl('/images/providers/mackay-family-funerals/logo.webp'),
    rating: 4.6,
    reviewCount: 87,
    startingPrice: 2800,
    distanceKm: 18.2,
    coords: { lat: -33.3644, lng: 151.3728 },
  },
  {
    id: 'mannings',
    name: 'Mannings Funerals',
    location: 'Bega, NSW',
    verified: true,
    tier: 'verified',
    imageUrl: assetUrl('/images/venues/mannings-chapel/01.jpg'),
    logoUrl: assetUrl('/images/providers/mannings-funerals/logo.png'),
    rating: 4.7,
    reviewCount: 31,
    startingPrice: 2600,
    distanceKm: 22.0,
    coords: { lat: -36.6742, lng: 149.8417 },
  },
  {
    id: 'botanical',
    name: 'Botanical Funerals',
    location: 'Newtown, NSW',
    verified: false,
    tier: 'tier2',
    rating: 4.9,
    reviewCount: 8,
    startingPrice: 5200,
    distanceKm: 15.0,
    coords: { lat: -33.8988, lng: 151.1794 },
  },
];

export const providersById: Record<string, DemoProvider> = providers.reduce(
  (acc, p) => {
    acc[p.id] = p;
    return acc;
  },
  {} as Record<string, DemoProvider>,
);

/**
 * Strip demo-only fields so the value matches PackagesStepProvider exactly.
 * (PackagesStepProvider is a structural subset of ProviderData — no `id`, no `tier`.)
 */
export function toPackagesStepProvider(p: DemoProvider): PackagesStepProvider {
  return {
    name: p.name,
    location: p.location,
    imageUrl: p.imageUrl,
    rating: p.rating,
    reviewCount: p.reviewCount,
  };
}
