"use client";
import { useState, useEffect } from "react";
import dynamic from "next/dynamic";
import type {
City,
CityStats,
CategoryId,
TravelMode,
ProfileId,
} from "@transportationer/shared";
import { PROFILES } from "@transportationer/shared";
import { ControlPanel } from "@/components/control-panel";
import { StatsBar } from "@/components/stats-bar";
import { CitySelector } from "@/components/city-selector";
import {
LocationScorePanel,
type LocationScoreData,
type OverlayMode,
} from "@/components/location-score-panel";
import { MapLegend } from "@/components/map-legend";
import { isochroneContours } from "@/lib/isochrone";
const MapView = dynamic(
() => import("@/components/map-view").then((m) => m.MapView),
{ ssr: false, loading: () =>
},
);
export default function HomePage() {
const [cities, setCities] = useState([]);
const [selectedCity, setSelectedCity] = useState(null);
const [profile, setProfile] = useState("universal");
const [mode, setMode] = useState("cyclist");
const [threshold, setThreshold] = useState(15);
const [weights, setWeights] = useState({ ...PROFILES["universal"].categoryWeights });
const [activeCategory, setActiveCategory] = useState("composite");
const [stats, setStats] = useState(null);
// Pin / location rating
const [pinLocation, setPinLocation] = useState<{ lat: number; lng: number } | null>(null);
const [pinData, setPinData] = useState(null);
const [pinScoreError, setPinScoreError] = useState(false);
const [pinAddress, setPinAddress] = useState(undefined);
const [pinEstateValue, setPinEstateValue] = useState(null);
const [pinEstatePercentile, setPinEstatePercentile] = useState(null);
const [pinEstateScorePercentile, setPinEstateScorePercentile] = useState(null);
// Reachable POI pins
type ReachablePoi = { category: string; subcategory: string; name: string | null; lat: number; lng: number; scored: boolean };
const [reachablePois, setReachablePois] = useState([]);
const [showPois, setShowPois] = useState(true);
// Overlay mode: isochrone (new default) or relative heatmap
const [overlayMode, setOverlayMode] = useState("isochrone");
const [isochroneData, setIsochroneData] = useState