/**
 * Enhanced POIs response type has a very different structure compared to v3/pois and v3/schools.
 * Since we're still using v3/schools along v3/enhanced-pois, we need to normalize the enhanced POIs response
 * to match the structure of the POIs response in order to easily merge them together when we want to display them
 * on a map or a list.
 */
export function normalizeEnhancedPoisToPois(categories, enhancedPoisResponse) {
    var _a;
    if (typeof categories === "undefined" ||
        categories.length === 0 ||
        // Even though the API should always return an array for results, we add this safeguard just in case
        typeof ((_a = enhancedPoisResponse === null || enhancedPoisResponse === void 0 ? void 0 : enhancedPoisResponse.data) === null || _a === void 0 ? void 0 : _a.results) === "undefined") {
        return undefined;
    }
    const data = enhancedPoisResponse.data.results;
    const result = {};
    categories.forEach((category) => {
        result[category] = data
            .filter((poi) => poi.categories.includes(category))
            .map((poi) => ({
            name: poi.name,
            address: poi.address,
            city: poi.city,
            province: poi.province,
            postalcode: poi.postal_code,
            country: poi.country,
            lat: poi.lat,
            lng: poi.lng,
            url: poi.url,
            proximity: {
                linear_distance: poi.proximity.linear_distance_m,
                walking: poi.proximity.walking,
            },
            routes: poi.routes,
        }));
    });
    return result;
}
//# sourceMappingURL=index.js.map