import React, { useMemo } from "react";
import { PopupContent } from "../PopupContent";
import { Address } from "./Address";
import { Link } from "./Link";
import { SchoolAttributes } from "./SchoolAttributes";
import * as styles from "./styles";
import { TransitRoutes } from "~/components/TransitRoutes";
export function POIPopupContent({ marker, poiCategory, onLocationLinkClick, onSchoolLinkClick, onClose, children, showSchoolRatings = false, }) {
    if (!marker) {
        return null;
    }
    const categories = useMemo(() => {
        const isSchool = (item) => {
            return "school_attributes" in item;
        };
        if (!isSchool(marker)) {
            return undefined;
        }
        return [
            marker.is_advanced_placement && "advancedPlacement",
            marker.is_charter && "charter",
            marker.is_magnet && "magnet",
        ].filter(Boolean);
    }, [marker, poiCategory]);
    const rating = useMemo(() => {
        if (showSchoolRatings && "rating" in marker && marker.rating) {
            return marker.rating;
        }
        return undefined;
    }, [marker, showSchoolRatings]);
    return (React.createElement(PopupContent, { title: marker.name, onClose: onClose },
        React.createElement("div", { className: styles.container },
            React.createElement("div", { className: styles.content },
                React.createElement(Address, { address: marker.address }),
                React.createElement(Link, { url: marker.url, onClick: onLocationLinkClick }),
                React.createElement(TransitRoutes, { keyPrefix: "map-popup-transit-routes", routes: marker.routes, useLongName: poiCategory === "train_stations" })),
            React.createElement(SchoolAttributes, { attributes: marker.school_attributes, boardAttributes: marker.school_board_attributes, categories: categories, onLinkClick: onSchoolLinkClick, rating: rating }),
            children)));
}
//# sourceMappingURL=index.js.map