import { aggregateAcrossTeams, formatAggregationResult, loopGet, } from "../lib/loop-api.js";
export async function propertiesList(params) {
    const { accountId, type, teamName, limit } = params;
    const result = await aggregateAcrossTeams(accountId, "properties", "loop-properties-list", async (apiKey, team) => {
        const path = type && type !== "both"
            ? `/properties?type=${encodeURIComponent(type)}`
            : "/properties";
        const data = await loopGet(apiKey, path, "loop-properties-list", team);
        return Array.isArray(data) ? data : [];
    }, { teamName, limitPerTeam: limit ?? 50, limitTotal: limit ?? 200 });
    return formatAggregationResult(result, (p) => {
        const price = p.price ? ` — £${p.price.toLocaleString("en-GB")}` : "";
        const beds = p.bedrooms ? ` ${p.bedrooms}bed` : "";
        const status = p.status ? ` [${p.status}]` : "";
        const propType = p.type ? ` (${p.type})` : "";
        return `- ${p.address ?? "Unknown address"}${price}${beds}${propType}${status}`;
    }, "properties");
}
//# sourceMappingURL=properties-list.js.map