@garagem-ai/site-sdk 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +135 -13
- package/dist/index.d.ts +135 -13
- package/dist/index.js +436 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +423 -69
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +4 -4
- package/dist/react.mjs.map +1 -1
- package/dist/{types-photo-search-D88oevZv.d.mts → types-photo-search-DIoV75SN.d.mts} +1 -1
- package/dist/{types-photo-search-D88oevZv.d.ts → types-photo-search-DIoV75SN.d.ts} +1 -1
- package/package.json +2 -2
- package/src/index.ts +24 -0
- package/src/leads.ts +47 -3
- package/src/map-search.ts +9 -5
- package/src/seller-lead.ts +428 -0
- package/src/studio-contract.ts +71 -11
package/dist/index.mjs
CHANGED
|
@@ -58,13 +58,13 @@ function finiteNonNegative(value) {
|
|
|
58
58
|
}
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
|
-
function parseSdkErrorBody(
|
|
62
|
-
const raw =
|
|
63
|
-
if (!
|
|
61
|
+
function parseSdkErrorBody(text2) {
|
|
62
|
+
const raw = text2 ? text2.slice(0, 200) : "";
|
|
63
|
+
if (!text2) {
|
|
64
64
|
return { reason: null, retryAfterSeconds: null, summary: "" };
|
|
65
65
|
}
|
|
66
66
|
try {
|
|
67
|
-
const body = JSON.parse(
|
|
67
|
+
const body = JSON.parse(text2);
|
|
68
68
|
if (!body || typeof body !== "object") {
|
|
69
69
|
return { reason: null, retryAfterSeconds: null, summary: raw };
|
|
70
70
|
}
|
|
@@ -160,8 +160,8 @@ var GaragemSdkError = class extends Error {
|
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
async function readGaragemSdkError(response, url) {
|
|
163
|
-
const
|
|
164
|
-
const parsed = parseSdkErrorBody(
|
|
163
|
+
const text2 = await response.text().catch(() => "");
|
|
164
|
+
const parsed = parseSdkErrorBody(text2);
|
|
165
165
|
const retryAfter = response.status === 429 ? retryAfterFromResponse(response, parsed.retryAfterSeconds) : parsed.retryAfterSeconds;
|
|
166
166
|
const detail = parsed.summary;
|
|
167
167
|
return new GaragemSdkError(
|
|
@@ -1018,7 +1018,15 @@ var LeadSubmitError = class extends Error {
|
|
|
1018
1018
|
};
|
|
1019
1019
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1020
1020
|
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1021
|
+
var NAME_RE = /^[^\d\s]{2,}.*$/;
|
|
1021
1022
|
var MESSAGE_MAX = 2e3;
|
|
1023
|
+
function isValidEmail(value) {
|
|
1024
|
+
return EMAIL_RE.test(value.trim());
|
|
1025
|
+
}
|
|
1026
|
+
function isValidName(value) {
|
|
1027
|
+
const name = value.trim();
|
|
1028
|
+
return name.length <= 200 && NAME_RE.test(name);
|
|
1029
|
+
}
|
|
1022
1030
|
var CONTACT_FIELDS = [
|
|
1023
1031
|
{ id: "name", required: true },
|
|
1024
1032
|
{ id: "email", required: false },
|
|
@@ -1118,6 +1126,27 @@ function normalizeSdkBusinessType(value) {
|
|
|
1118
1126
|
if (normalized === "sale" || normalized === "venda") return "sale";
|
|
1119
1127
|
return void 0;
|
|
1120
1128
|
}
|
|
1129
|
+
var ADDRESS_REJECTIONS = /* @__PURE__ */ new Set([
|
|
1130
|
+
"missing_postal_code",
|
|
1131
|
+
"ungeocoded_address"
|
|
1132
|
+
]);
|
|
1133
|
+
async function rejectedLeadError(response) {
|
|
1134
|
+
if (response.status !== 400 && response.status !== 409) return null;
|
|
1135
|
+
const parsed = parseSdkErrorBody(await response.text().catch(() => ""));
|
|
1136
|
+
if (response.status === 409 || parsed.reason === "duplicate_property") {
|
|
1137
|
+
return new LeadSubmitError(
|
|
1138
|
+
parsed.summary || "Garagem SDK: property already registered.",
|
|
1139
|
+
{ code: "duplicate_property", status: response.status }
|
|
1140
|
+
);
|
|
1141
|
+
}
|
|
1142
|
+
if (parsed.reason && ADDRESS_REJECTIONS.has(parsed.reason)) {
|
|
1143
|
+
return new LeadSubmitError(`Garagem SDK: ${parsed.reason}.`, {
|
|
1144
|
+
code: "invalid_address",
|
|
1145
|
+
status: 400
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
return null;
|
|
1149
|
+
}
|
|
1121
1150
|
async function postSiteLead(input) {
|
|
1122
1151
|
const siteId = await resolveLeadSiteId(input);
|
|
1123
1152
|
const base = normalizeBaseUrl(input.baseUrl);
|
|
@@ -1152,8 +1181,8 @@ async function postSiteLead(input) {
|
|
|
1152
1181
|
});
|
|
1153
1182
|
}
|
|
1154
1183
|
if (response.status === 429) {
|
|
1155
|
-
const
|
|
1156
|
-
const parsed = parseSdkErrorBody(
|
|
1184
|
+
const text2 = await response.text().catch(() => "");
|
|
1185
|
+
const parsed = parseSdkErrorBody(text2);
|
|
1157
1186
|
const retryAfter = retryAfterFromResponse(
|
|
1158
1187
|
response,
|
|
1159
1188
|
parsed.retryAfterSeconds
|
|
@@ -1170,6 +1199,8 @@ async function postSiteLead(input) {
|
|
|
1170
1199
|
status: 404
|
|
1171
1200
|
});
|
|
1172
1201
|
}
|
|
1202
|
+
const rejected = await rejectedLeadError(response);
|
|
1203
|
+
if (rejected) throw rejected;
|
|
1173
1204
|
throw new LeadSubmitError(
|
|
1174
1205
|
`Garagem SDK: lead submit failed (${response.status}).`,
|
|
1175
1206
|
{ code: "http", status: response.status }
|
|
@@ -1236,6 +1267,278 @@ async function submitContactLead(input) {
|
|
|
1236
1267
|
});
|
|
1237
1268
|
}
|
|
1238
1269
|
|
|
1270
|
+
// src/seller-lead.ts
|
|
1271
|
+
function text(value) {
|
|
1272
|
+
return typeof value === "string" ? value.trim() : "";
|
|
1273
|
+
}
|
|
1274
|
+
function inRange(value, min, max) {
|
|
1275
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max;
|
|
1276
|
+
}
|
|
1277
|
+
function sellerAddressErrors(address) {
|
|
1278
|
+
const errors = {};
|
|
1279
|
+
if (!address || !text(address.fullAddress)) {
|
|
1280
|
+
errors.fullAddress = "Informe o endere\xE7o do im\xF3vel.";
|
|
1281
|
+
} else if (!inRange(address.latitude, -90, 90) || !inRange(address.longitude, -180, 180) || !text(address.street) || !text(address.city) || !text(address.neighborhood) || !/^[A-Za-z]{2}$/.test(text(address.state))) {
|
|
1282
|
+
errors.fullAddress = "Selecione o endere\xE7o em uma das sugest\xF5es.";
|
|
1283
|
+
}
|
|
1284
|
+
if (!address?.noNumber && !text(address?.number)) {
|
|
1285
|
+
errors.number = "Informe o n\xFAmero ou marque sem n\xFAmero.";
|
|
1286
|
+
}
|
|
1287
|
+
if (!address?.noBlocoTorre && !text(address?.blocoTorre)) {
|
|
1288
|
+
errors.blocoTorre = "Informe o bloco/torre ou marque que n\xE3o tem.";
|
|
1289
|
+
}
|
|
1290
|
+
if (!address?.noUnidade && !text(address?.unidade)) {
|
|
1291
|
+
errors.unidade = "Informe a unidade ou marque que n\xE3o tem.";
|
|
1292
|
+
}
|
|
1293
|
+
if (text(address?.postalCode).replace(/\D/g, "").length !== 8) {
|
|
1294
|
+
errors.postalCode = "Informe um CEP com 8 d\xEDgitos.";
|
|
1295
|
+
}
|
|
1296
|
+
return errors;
|
|
1297
|
+
}
|
|
1298
|
+
var SELLER_LEAD_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
|
|
1299
|
+
var SELLER_LEAD_PHOTO_MAX_COUNT = 30;
|
|
1300
|
+
var SELLER_LEAD_PHOTO_TYPES = [
|
|
1301
|
+
"image/jpeg",
|
|
1302
|
+
"image/png",
|
|
1303
|
+
"image/webp"
|
|
1304
|
+
];
|
|
1305
|
+
async function uploadSellerLeadPhoto(input) {
|
|
1306
|
+
const { file } = input;
|
|
1307
|
+
if (!SELLER_LEAD_PHOTO_TYPES.includes(file.type)) {
|
|
1308
|
+
throw new LeadSubmitError("Garagem SDK: photo must be JPG, PNG or WEBP.", {
|
|
1309
|
+
code: "invalid_photo"
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
if (file.size <= 0) {
|
|
1313
|
+
throw new LeadSubmitError("Garagem SDK: photo is empty.", {
|
|
1314
|
+
code: "invalid_photo"
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
if (file.size > SELLER_LEAD_PHOTO_MAX_BYTES) {
|
|
1318
|
+
throw new LeadSubmitError("Garagem SDK: photo is larger than 10MB.", {
|
|
1319
|
+
code: "invalid_photo"
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
const siteId = await resolveLeadSiteId(input);
|
|
1323
|
+
const url = `${normalizeBaseUrl(input.baseUrl)}/api/webhooks/sites/${encodeURIComponent(siteId)}/photos`;
|
|
1324
|
+
const form = new FormData();
|
|
1325
|
+
form.append("file", file);
|
|
1326
|
+
if (file.name) form.append("fileName", file.name);
|
|
1327
|
+
let response;
|
|
1328
|
+
try {
|
|
1329
|
+
response = await (input.fetch ?? fetch)(url, {
|
|
1330
|
+
method: "POST",
|
|
1331
|
+
body: form
|
|
1332
|
+
});
|
|
1333
|
+
} catch (error) {
|
|
1334
|
+
throw new LeadSubmitError(
|
|
1335
|
+
error instanceof Error ? error.message : "Garagem SDK: network error.",
|
|
1336
|
+
{ code: "network" }
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
if (response.status === 404) {
|
|
1340
|
+
throw new LeadSubmitError("Garagem SDK: site not found.", {
|
|
1341
|
+
code: "not_found",
|
|
1342
|
+
status: 404
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
const data = await response.json().catch(() => ({}));
|
|
1346
|
+
if (!response.ok || typeof data.url !== "string" || !data.url) {
|
|
1347
|
+
throw new LeadSubmitError(
|
|
1348
|
+
`Garagem SDK: photo upload failed (${response.status}).`,
|
|
1349
|
+
{
|
|
1350
|
+
code: response.status === 400 ? "invalid_photo" : "http",
|
|
1351
|
+
status: response.status
|
|
1352
|
+
}
|
|
1353
|
+
);
|
|
1354
|
+
}
|
|
1355
|
+
return data.url;
|
|
1356
|
+
}
|
|
1357
|
+
var STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG = {
|
|
1358
|
+
disabledDays: [0, 6],
|
|
1359
|
+
weekdayTimeSlots: [
|
|
1360
|
+
"09:00",
|
|
1361
|
+
"10:00",
|
|
1362
|
+
"11:00",
|
|
1363
|
+
"14:00",
|
|
1364
|
+
"15:00",
|
|
1365
|
+
"16:00",
|
|
1366
|
+
"17:00"
|
|
1367
|
+
],
|
|
1368
|
+
weekendTimeSlots: ["10:00", "11:00", "14:00", "15:00", "16:00"]
|
|
1369
|
+
};
|
|
1370
|
+
function sellerPhotoSchedule(config = STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG) {
|
|
1371
|
+
const weekdayTimeSlots = [...config.weekdayTimeSlots].sort();
|
|
1372
|
+
const weekendTimeSlots = [...config.weekendTimeSlots].sort();
|
|
1373
|
+
const hours = (slots) => slots.length > 0 ? { start: slots[0], end: slots[slots.length - 1] } : null;
|
|
1374
|
+
return {
|
|
1375
|
+
timeZone: VISIT_TIME_ZONE,
|
|
1376
|
+
saturday: !config.disabledDays.includes(6),
|
|
1377
|
+
sunday: !config.disabledDays.includes(0),
|
|
1378
|
+
weekday: hours(weekdayTimeSlots) ?? { start: "09:00", end: "09:00" },
|
|
1379
|
+
weekend: hours(weekendTimeSlots),
|
|
1380
|
+
minHoursAhead: 2,
|
|
1381
|
+
disabledDays: [...config.disabledDays],
|
|
1382
|
+
weekdayTimeSlots,
|
|
1383
|
+
weekendTimeSlots,
|
|
1384
|
+
timeSlots: Array.from(
|
|
1385
|
+
/* @__PURE__ */ new Set([...weekdayTimeSlots, ...weekendTimeSlots])
|
|
1386
|
+
).sort()
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
function contactError(message) {
|
|
1390
|
+
return new LeadSubmitError(`Garagem SDK: ${message}`, {
|
|
1391
|
+
code: "invalid_contact"
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
function normalizeOwner(owner) {
|
|
1395
|
+
const name = text(owner?.name);
|
|
1396
|
+
const email = text(owner?.email);
|
|
1397
|
+
if (!isValidName(name)) throw contactError("owner name is invalid.");
|
|
1398
|
+
if (!isValidEmail(email)) throw contactError("owner email is invalid.");
|
|
1399
|
+
const phone = toE164(text(owner?.phone));
|
|
1400
|
+
if (!phone || !isValidPhone(phone) || phone.length > 40) {
|
|
1401
|
+
throw contactError("owner phone is invalid.");
|
|
1402
|
+
}
|
|
1403
|
+
return { name, email, phone };
|
|
1404
|
+
}
|
|
1405
|
+
function normalizeAddress(address) {
|
|
1406
|
+
const errors = sellerAddressErrors(address);
|
|
1407
|
+
const first = Object.values(errors)[0];
|
|
1408
|
+
if (first) {
|
|
1409
|
+
throw new LeadSubmitError(`Garagem SDK: ${first}`, {
|
|
1410
|
+
code: "invalid_address"
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
const optional = (value) => text(value) ? { value: text(value) } : null;
|
|
1414
|
+
const number = address.noNumber ? null : optional(address.number);
|
|
1415
|
+
const bloco = address.noBlocoTorre ? null : optional(address.blocoTorre);
|
|
1416
|
+
const unidade = address.noUnidade ? null : optional(address.unidade);
|
|
1417
|
+
return {
|
|
1418
|
+
fullAddress: text(address.fullAddress),
|
|
1419
|
+
street: text(address.street),
|
|
1420
|
+
...number ? { number: number.value } : {},
|
|
1421
|
+
neighborhood: text(address.neighborhood),
|
|
1422
|
+
city: text(address.city),
|
|
1423
|
+
state: text(address.state),
|
|
1424
|
+
postalCode: text(address.postalCode).replace(/\D/g, ""),
|
|
1425
|
+
country: text(address.country) || "BR",
|
|
1426
|
+
latitude: address.latitude,
|
|
1427
|
+
longitude: address.longitude,
|
|
1428
|
+
...bloco ? { blocoTorre: bloco.value } : {},
|
|
1429
|
+
...unidade ? { unidade: unidade.value } : {},
|
|
1430
|
+
noNumber: address.noNumber === true,
|
|
1431
|
+
noBlocoTorre: address.noBlocoTorre === true,
|
|
1432
|
+
noUnidade: address.noUnidade === true
|
|
1433
|
+
};
|
|
1434
|
+
}
|
|
1435
|
+
var COUNT_FIELDS = [
|
|
1436
|
+
"bedrooms",
|
|
1437
|
+
"bathrooms",
|
|
1438
|
+
"suites",
|
|
1439
|
+
"parkingSpaces"
|
|
1440
|
+
];
|
|
1441
|
+
var AMOUNT_FIELDS = [
|
|
1442
|
+
"saleValue",
|
|
1443
|
+
"rentValue",
|
|
1444
|
+
"condoFee",
|
|
1445
|
+
"totalArea"
|
|
1446
|
+
];
|
|
1447
|
+
function propertyError(message) {
|
|
1448
|
+
return new LeadSubmitError(`Garagem SDK: ${message}`, {
|
|
1449
|
+
code: "invalid_property"
|
|
1450
|
+
});
|
|
1451
|
+
}
|
|
1452
|
+
function normalizeProperty(property) {
|
|
1453
|
+
if (!["sale", "rent", "both"].includes(property?.businessType)) {
|
|
1454
|
+
throw propertyError("businessType must be sale, rent or both.");
|
|
1455
|
+
}
|
|
1456
|
+
for (const field of COUNT_FIELDS) {
|
|
1457
|
+
const value = property[field];
|
|
1458
|
+
if (value != null && (!Number.isInteger(value) || value < 0 || value > 999)) {
|
|
1459
|
+
throw propertyError(`${field} must be a whole number.`);
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
for (const field of AMOUNT_FIELDS) {
|
|
1463
|
+
const value = property[field];
|
|
1464
|
+
if (value != null && (!Number.isFinite(value) || value < 0 || value > 1e12)) {
|
|
1465
|
+
throw propertyError(`${field} must be a non-negative number.`);
|
|
1466
|
+
}
|
|
1467
|
+
}
|
|
1468
|
+
const sale = property.businessType === "rent" ? void 0 : property.saleValue;
|
|
1469
|
+
const rent = property.businessType === "sale" ? void 0 : property.rentValue;
|
|
1470
|
+
const price = property.businessType === "rent" ? rent : sale;
|
|
1471
|
+
const counts = Object.fromEntries(
|
|
1472
|
+
COUNT_FIELDS.filter((field) => property[field] != null).map((field) => [
|
|
1473
|
+
field,
|
|
1474
|
+
property[field]
|
|
1475
|
+
])
|
|
1476
|
+
);
|
|
1477
|
+
return {
|
|
1478
|
+
businessType: property.businessType,
|
|
1479
|
+
...price != null ? { price } : {},
|
|
1480
|
+
...property.businessType === "both" && rent != null ? { rentPrice: rent } : {},
|
|
1481
|
+
...property.condoFee != null ? { condominiumFee: property.condoFee } : {},
|
|
1482
|
+
...property.totalArea != null ? { totalArea: property.totalArea } : {},
|
|
1483
|
+
...counts
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
function normalizePhotos(photos) {
|
|
1487
|
+
if (!photos?.length) return void 0;
|
|
1488
|
+
if (photos.length > SELLER_LEAD_PHOTO_MAX_COUNT) {
|
|
1489
|
+
throw new LeadSubmitError("Garagem SDK: too many photos (max 30).", {
|
|
1490
|
+
code: "invalid_photo"
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
return photos.map((url) => {
|
|
1494
|
+
const trimmed = url.trim();
|
|
1495
|
+
if (!trimmed.startsWith("https://")) {
|
|
1496
|
+
throw new LeadSubmitError("Garagem SDK: photo URL must be https.", {
|
|
1497
|
+
code: "invalid_photo"
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
return trimmed;
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
function normalizePhotoSession(input) {
|
|
1504
|
+
if (!input.photoSession) return void 0;
|
|
1505
|
+
const schedule = input.photoSchedule ?? sellerPhotoSchedule();
|
|
1506
|
+
const date = normalizeVisitDate(input.photoSession.date, schedule.timeZone);
|
|
1507
|
+
const time = normalizeVisitTime(input.photoSession.time);
|
|
1508
|
+
if (!date || !time || !isVisitSlotAllowed(schedule, date, time)) {
|
|
1509
|
+
throw new LeadSubmitError(
|
|
1510
|
+
"Garagem SDK: photo session slot is outside the schedule.",
|
|
1511
|
+
{ code: "invalid_slot" }
|
|
1512
|
+
);
|
|
1513
|
+
}
|
|
1514
|
+
return { date, time };
|
|
1515
|
+
}
|
|
1516
|
+
async function submitSellerLead(input) {
|
|
1517
|
+
const owner = normalizeOwner(input.owner);
|
|
1518
|
+
const address = normalizeAddress(input.address);
|
|
1519
|
+
const property = normalizeProperty(input.property);
|
|
1520
|
+
const photos = normalizePhotos(input.photos);
|
|
1521
|
+
const photoScheduling = normalizePhotoSession(input);
|
|
1522
|
+
return postSiteLead({
|
|
1523
|
+
siteId: input.siteId,
|
|
1524
|
+
baseUrl: input.baseUrl,
|
|
1525
|
+
fetch: input.fetch,
|
|
1526
|
+
publishableKey: input.publishableKey,
|
|
1527
|
+
body: {
|
|
1528
|
+
source: "site-sdk",
|
|
1529
|
+
leadType: "seller_lead",
|
|
1530
|
+
...owner,
|
|
1531
|
+
address,
|
|
1532
|
+
...property,
|
|
1533
|
+
...photos ? { photos } : {},
|
|
1534
|
+
...photoScheduling ? { photoScheduling } : {},
|
|
1535
|
+
...input.visitorId ? { visitorId: input.visitorId } : {},
|
|
1536
|
+
...input.brokerRef ? { brokerRef: input.brokerRef } : {},
|
|
1537
|
+
...input.referrer ? { referrer: input.referrer } : {}
|
|
1538
|
+
}
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1239
1542
|
// src/amenity-labels.ts
|
|
1240
1543
|
var LISTING_AMENITY_TITLES = {
|
|
1241
1544
|
unit: "Comodidades",
|
|
@@ -1656,9 +1959,9 @@ var SORT_URL_TOKENS = [
|
|
|
1656
1959
|
];
|
|
1657
1960
|
|
|
1658
1961
|
// ../search-url/slugify.ts
|
|
1659
|
-
function slugifyForUrl(
|
|
1660
|
-
if (!
|
|
1661
|
-
const withDashes =
|
|
1962
|
+
function slugifyForUrl(text2) {
|
|
1963
|
+
if (!text2) return "";
|
|
1964
|
+
const withDashes = text2.replace(/([a-z])([A-Z])/g, "$1-$2");
|
|
1662
1965
|
return withDashes.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
|
|
1663
1966
|
}
|
|
1664
1967
|
|
|
@@ -1935,8 +2238,8 @@ function serializeAppliedSearchQuery(query) {
|
|
|
1935
2238
|
if (normalized.sort && isSortToken(normalized.sort)) {
|
|
1936
2239
|
params.set("ordenar", normalized.sort);
|
|
1937
2240
|
}
|
|
1938
|
-
const
|
|
1939
|
-
if (
|
|
2241
|
+
const text2 = normalized.query?.trim();
|
|
2242
|
+
if (text2) params.set("q", text2);
|
|
1940
2243
|
for (const value of (normalized.loc ?? []).slice(0, MAX_LOC_GROUPS)) {
|
|
1941
2244
|
const trimmed = value.trim();
|
|
1942
2245
|
if (trimmed) params.append("loc", trimmed);
|
|
@@ -2353,11 +2656,11 @@ function countFacetChoices(options) {
|
|
|
2353
2656
|
}
|
|
2354
2657
|
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
2355
2658
|
function pluralizePt(label) {
|
|
2356
|
-
const
|
|
2357
|
-
if (!
|
|
2358
|
-
if (/il$/i.test(
|
|
2359
|
-
if (/m$/i.test(
|
|
2360
|
-
return `${
|
|
2659
|
+
const text2 = label.trim();
|
|
2660
|
+
if (!text2 || /s$/i.test(text2)) return text2;
|
|
2661
|
+
if (/il$/i.test(text2)) return `${text2.slice(0, -1)}is`;
|
|
2662
|
+
if (/m$/i.test(text2)) return `${text2.slice(0, -1)}ns`;
|
|
2663
|
+
return `${text2}s`;
|
|
2361
2664
|
}
|
|
2362
2665
|
function headingLocationSuffix(location) {
|
|
2363
2666
|
if (!location) return "";
|
|
@@ -2650,16 +2953,16 @@ function listingBreadcrumb(listing) {
|
|
|
2650
2953
|
return crumbs;
|
|
2651
2954
|
}
|
|
2652
2955
|
function listingDescriptionPreview(description, expanded = false) {
|
|
2653
|
-
const
|
|
2654
|
-
if (!
|
|
2655
|
-
if (
|
|
2656
|
-
return { text, truncated: false, toggleLabel: null };
|
|
2956
|
+
const text2 = description?.trim() ?? "";
|
|
2957
|
+
if (!text2) return null;
|
|
2958
|
+
if (text2.length <= LISTING_DESCRIPTION_CLAMP) {
|
|
2959
|
+
return { text: text2, truncated: false, toggleLabel: null };
|
|
2657
2960
|
}
|
|
2658
2961
|
if (expanded) {
|
|
2659
|
-
return { text, truncated: true, toggleLabel: "Ler menos" };
|
|
2962
|
+
return { text: text2, truncated: true, toggleLabel: "Ler menos" };
|
|
2660
2963
|
}
|
|
2661
2964
|
return {
|
|
2662
|
-
text: `${
|
|
2965
|
+
text: `${text2.slice(0, LISTING_DESCRIPTION_CLAMP).trimEnd()}\u2026`,
|
|
2663
2966
|
truncated: true,
|
|
2664
2967
|
toggleLabel: "Ler mais"
|
|
2665
2968
|
};
|
|
@@ -2684,8 +2987,8 @@ function listingMediaOverlays(listing) {
|
|
|
2684
2987
|
return overlays;
|
|
2685
2988
|
}
|
|
2686
2989
|
function listingDetailModel(listing, options) {
|
|
2687
|
-
const
|
|
2688
|
-
const description =
|
|
2990
|
+
const text2 = listing.description?.trim() ?? "";
|
|
2991
|
+
const description = text2 || null;
|
|
2689
2992
|
const truncated = description != null && description.length > LISTING_DESCRIPTION_CLAMP;
|
|
2690
2993
|
const expanded = options?.descriptionExpanded === true;
|
|
2691
2994
|
return {
|
|
@@ -2710,8 +3013,8 @@ function visibleText(value) {
|
|
|
2710
3013
|
function visibleRows(rows) {
|
|
2711
3014
|
return rows.filter((row) => {
|
|
2712
3015
|
const label = visibleText(row.label);
|
|
2713
|
-
const
|
|
2714
|
-
return label != null &&
|
|
3016
|
+
const text2 = visibleText(row.text);
|
|
3017
|
+
return label != null && text2 != null;
|
|
2715
3018
|
});
|
|
2716
3019
|
}
|
|
2717
3020
|
function listingDetailFieldsModel(listing, dictionary) {
|
|
@@ -2735,11 +3038,13 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2735
3038
|
* this and move that release's names from `optionalReactExports` /
|
|
2736
3039
|
* `unpublishedSearchExports` / `unpublishedPhoneExports` into the
|
|
2737
3040
|
* prompt-safe lists. Do not bump here until that tarball is on npm.
|
|
2738
|
-
* Phone mask helpers shipped in 0.6.0.
|
|
3041
|
+
* Phone mask helpers shipped in 0.6.0. Map search
|
|
3042
|
+
* (`useMapSearch`, `searchListingsInBounds`) shipped in 0.9.0 — 0.7.0
|
|
3043
|
+
* does not export them. Search filter helpers
|
|
2739
3044
|
* (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
|
|
2740
3045
|
* remain on this pin.
|
|
2741
3046
|
*/
|
|
2742
|
-
minNpmVersion: "0.
|
|
3047
|
+
minNpmVersion: "0.9.0",
|
|
2743
3048
|
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
2744
3049
|
selfInjectSince: "0.4.2",
|
|
2745
3050
|
chromeStrategy: "app-owned",
|
|
@@ -2752,7 +3057,8 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2752
3057
|
* throws FatalRendererError.
|
|
2753
3058
|
*/
|
|
2754
3059
|
optionalReactExports: {
|
|
2755
|
-
usePublicPhotoSearch: "0.7.0"
|
|
3060
|
+
usePublicPhotoSearch: "0.7.0",
|
|
3061
|
+
useMapSearch: "0.9.0"
|
|
2756
3062
|
},
|
|
2757
3063
|
/**
|
|
2758
3064
|
* Former `/react` chrome (including card/skeleton inject). Completeness
|
|
@@ -2863,14 +3169,15 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2863
3169
|
],
|
|
2864
3170
|
/**
|
|
2865
3171
|
* maps.fndn.ai helpers (static map, street view, boundaries, travel
|
|
2866
|
-
* time) plus friendly map search. They ship in `mapsSince
|
|
2867
|
-
* `studioMapsInstruction()`
|
|
2868
|
-
*
|
|
2869
|
-
*
|
|
2870
|
-
*
|
|
2871
|
-
*
|
|
3172
|
+
* time) plus friendly map search. They ship in npm 0.9.0 (`mapsSince`).
|
|
3173
|
+
* Listing-detail map guidance stays empty: `studioMapsInstruction()`
|
|
3174
|
+
* keeps the listing contract for a later task and Studio does not
|
|
3175
|
+
* inject it. Map search is `studioMapSearchInstruction()`, and only
|
|
3176
|
+
* the site that opted into list-and-map may include that text.
|
|
3177
|
+
* `useMapSearch` is a `/react` hook in `optionalReactExports`; the
|
|
3178
|
+
* pin sentence does not name it.
|
|
2872
3179
|
*/
|
|
2873
|
-
mapsSince: "0.
|
|
3180
|
+
mapsSince: "0.9.0",
|
|
2874
3181
|
mapsExports: [
|
|
2875
3182
|
"listingStaticMapUrl",
|
|
2876
3183
|
"listingStreetViewUrl",
|
|
@@ -2913,8 +3220,31 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2913
3220
|
"searchListingPhotos",
|
|
2914
3221
|
"applyMatchedPhotoCover"
|
|
2915
3222
|
],
|
|
2916
|
-
photoSearchSince: "0.7.0"
|
|
3223
|
+
photoSearchSince: "0.7.0",
|
|
3224
|
+
/**
|
|
3225
|
+
* Seller lead (property registration on `/anunciar-imovel`). Prompt-safe
|
|
3226
|
+
* only once `minNpmVersion` reaches `sellerLeadSince`; below it
|
|
3227
|
+
* `studioSellerLeadSdkInstruction` prints nothing and
|
|
3228
|
+
* `studioCodegenContractViolations` flags the names.
|
|
3229
|
+
*/
|
|
3230
|
+
sellerLeadExports: [
|
|
3231
|
+
"submitSellerLead",
|
|
3232
|
+
"uploadSellerLeadPhoto",
|
|
3233
|
+
"sellerAddressErrors",
|
|
3234
|
+
"sellerPhotoSchedule",
|
|
3235
|
+
"isValidEmail",
|
|
3236
|
+
"isValidName"
|
|
3237
|
+
],
|
|
3238
|
+
sellerLeadSince: "0.10.0"
|
|
2917
3239
|
};
|
|
3240
|
+
function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3241
|
+
return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
|
|
3242
|
+
}
|
|
3243
|
+
function studioSellerLeadSdkInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3244
|
+
if (!isSellerLeadOnPin(pin)) return "";
|
|
3245
|
+
const names = STUDIO_SDK_CONTRACT.sellerLeadExports.join(", ");
|
|
3246
|
+
return `Property registration (\`/anunciar-imovel\`, client component): import ${names}, isValidPhone, toE164 from \`${STUDIO_SDK_PACKAGE}\`. Address: load Maps JS only through \`<script src="https://maps.fndn.ai/sdk.js?callback=initPlaces" async defer />\` (Places is included; never a Google key, never \`maps.googleapis.com\`), then \`google.maps.places.Autocomplete\` with \`componentRestrictions: { country: "br" }\` and pt-BR. Picking a suggestion fills fullAddress, street, number, neighborhood, city, state (the 2-letter code), postalCode, latitude and longitude from the place; a typed address without a suggestion is not enough. The visitor confirms number or "Sem n\xFAmero", bloco/torre or "N\xE3o tem", unidade or "N\xE3o tem" (noNumber, noBlocoTorre, noUnidade). Block the next group while \`sellerAddressErrors(address)\` has keys and show each message on its field. Owner: name, email and phone are all required \u2014 \`isValidName\`, \`isValidEmail\`, the phone mask with \`isValidPhone(toE164(phone))\`. Photos: \`await uploadSellerLeadPhoto({ siteId, baseUrl: GARAGEM_API_BASE, file, publishableKey })\` per file (JPG/PNG/WEBP, 10MB, up to 30), keep the returned URLs. Photo session: \`const schedule = sellerPhotoSchedule(config)\` and \`slotsForDate(schedule, day)\` for the hours. Submit once with \`await submitSellerLead({ siteId, baseUrl: GARAGEM_API_BASE, publishableKey, owner: { name, email, phone }, address, property: { businessType, saleValue, rentValue, condoFee, totalArea, bedrooms, bathrooms, suites, parkingSpaces }, photos, photoSession: { date, time }, photoSchedule: schedule })\` (omit what the visitor did not fill). Errors are \`LeadSubmitError\`: \`duplicate_property\` \u2192 "Este im\xF3vel j\xE1 est\xE1 cadastrado. Nossa equipe entrar\xE1 em contato."; \`invalid_address\` \u2192 ask to pick the address again; anything else \u2192 a retry message. Disable the submit while pending and show a success state after it resolves. Never POST the leads webhook by hand.`;
|
|
3247
|
+
}
|
|
2918
3248
|
function isPhotoSearchOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
2919
3249
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.photoSearchSince) >= 0;
|
|
2920
3250
|
}
|
|
@@ -2949,8 +3279,8 @@ function studioSearchLandmarkInstruction() {
|
|
|
2949
3279
|
}
|
|
2950
3280
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2951
3281
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
2952
|
-
function hasShowcaseLeadsPostUrl(
|
|
2953
|
-
return SHOWCASE_LEADS_POST_URL_RE.test(
|
|
3282
|
+
function hasShowcaseLeadsPostUrl(text2) {
|
|
3283
|
+
return SHOWCASE_LEADS_POST_URL_RE.test(text2);
|
|
2954
3284
|
}
|
|
2955
3285
|
function coerceNpmVersion(raw) {
|
|
2956
3286
|
if (typeof raw !== "string") return null;
|
|
@@ -3006,7 +3336,7 @@ function studioPublishableKeyInstruction() {
|
|
|
3006
3336
|
}
|
|
3007
3337
|
function studioSdkPinInstruction() {
|
|
3008
3338
|
const version = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
3009
|
-
const names =
|
|
3339
|
+
const names = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
3010
3340
|
return `In \`package.json\` set \`"@garagem-ai/site-sdk": "${version}"\` (exact). Import only these \`${STUDIO_SDK_PACKAGE}/react\` names: ${names}.`;
|
|
3011
3341
|
}
|
|
3012
3342
|
function studioLeadInstruction() {
|
|
@@ -3061,7 +3391,11 @@ function mapsExportsPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3061
3391
|
function studioMapsInstruction(options = {}) {
|
|
3062
3392
|
if (!mapsExportsPublished(options.pin)) return "";
|
|
3063
3393
|
const names = STUDIO_SDK_CONTRACT.mapsExports.join(", ");
|
|
3064
|
-
return `Maps on listing detail: from \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`listing.location.coordinates\` is already masked by the site's privacy settings (\u2248100 m by default) \u2014 pass the listing object as-is; never un-mask, never re-geocode the street address to get a sharper point, never add decimals (\`maxDecimals\` can only coarsen). Always pass \`siteId\` (the resolved site id / publishable key) so maps.fndn.ai meters the site. Static map: \`const mapSrc = listingStaticMapUrl(listing, { width: 640, height: 320, zoom: 15, style: "roadmap", siteId })\` then \`{mapSrc ? <img src={mapSrc} alt={model.location.label} /> : null}\` \u2014 \`null\` means no coordinates, so omit the block (never a placeholder image). Zoom is capped by the coordinate precision (16 on the default mask); do not work around it. Street View: on the server page \`const sv = await listingStreetViewAvailable(listing, { siteId })\` (metadata is free), and only when \`sv.available\` render \`<img src={listingStreetViewUrl(listing, { width: 640, height: 400, siteId })} alt="Street View" />\` \u2014 the image is billed per load. Neighbourhood outline on an interactive map: load Maps JS ONLY through \`<script src="https://maps.fndn.ai/sdk.js?callback=initMap" async defer />\` (never a Google key in the app, never \`NEXT_PUBLIC_GOOGLE_MAPS_API_KEY\`); in \`initMap\` do \`const outline = await neighborhoodBoundaryLayer(listing.location.city, listing.location.neighborhood, { siteId })\` and \`if (outline.feature) map.data.addGeoJson(outline.feature)\`; with MapLibre the vector source url is \`boundaryLayerUrl(listing.location.city)\`. Travel time (\u201Cquanto tempo at\xE9\u2026\u201D): \`const trip = await travelTimeFromListing(listing, destination, { mode: "driving", siteId })\` gives \`{ minutes, distanceKm }\` or \`null\` (hide the row). Every uncached call is a billed Google Directions request: call it on demand \u2014 a destination the visitor typed, or at most one fixed landmark per listing page \u2014 never per listing card, never inside a search loop, keep the SDK cache on (default 15 min LRU, \`cache: null\` only in tests), and do not re-run it on every render
|
|
3394
|
+
return `Maps on listing detail: from \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`listing.location.coordinates\` is already masked by the site's privacy settings (\u2248100 m by default) \u2014 pass the listing object as-is; never un-mask, never re-geocode the street address to get a sharper point, never add decimals (\`maxDecimals\` can only coarsen). Always pass \`siteId\` (the resolved site id / publishable key) so maps.fndn.ai meters the site. Static map: \`const mapSrc = listingStaticMapUrl(listing, { width: 640, height: 320, zoom: 15, style: "roadmap", siteId })\` then \`{mapSrc ? <img src={mapSrc} alt={model.location.label} /> : null}\` \u2014 \`null\` means no coordinates, so omit the block (never a placeholder image). Zoom is capped by the coordinate precision (16 on the default mask); do not work around it. Street View: on the server page \`const sv = await listingStreetViewAvailable(listing, { siteId })\` (metadata is free), and only when \`sv.available\` render \`<img src={listingStreetViewUrl(listing, { width: 640, height: 400, siteId })} alt="Street View" />\` \u2014 the image is billed per load. Neighbourhood outline on an interactive map: load Maps JS ONLY through \`<script src="https://maps.fndn.ai/sdk.js?callback=initMap" async defer />\` (never a Google key in the app, never \`NEXT_PUBLIC_GOOGLE_MAPS_API_KEY\`); in \`initMap\` do \`const outline = await neighborhoodBoundaryLayer(listing.location.city, listing.location.neighborhood, { siteId })\` and \`if (outline.feature) map.data.addGeoJson(outline.feature)\`; with MapLibre the vector source url is \`boundaryLayerUrl(listing.location.city)\`. Travel time (\u201Cquanto tempo at\xE9\u2026\u201D): \`const trip = await travelTimeFromListing(listing, destination, { mode: "driving", siteId })\` gives \`{ minutes, distanceKm }\` or \`null\` (hide the row). Every uncached call is a billed Google Directions request: call it on demand \u2014 a destination the visitor typed, or at most one fixed landmark per listing page \u2014 never per listing card, never inside a search loop, keep the SDK cache on (default 15 min LRU, \`cache: null\` only in tests), and do not re-run it on every render.`;
|
|
3395
|
+
}
|
|
3396
|
+
function studioMapSearchInstruction(options = {}) {
|
|
3397
|
+
if (!mapsExportsPublished(options.pin)) return "";
|
|
3398
|
+
return `Map search on \`/imoveis\` (list and map of the same query). The list stays: keep \`usePublicSearch\` for the list, including its sort and pagination. The visitor switches on the same page. \`?modo=mapa\` is the map \u2014 read it on first paint. The list is the URL without \`modo\`; do not write \`modo=lista\` or \`modo=grade\`. Choosing the map sets \`modo=mapa\` and drops \`page\`. Choosing the list removes \`modo\`. On the map, hide sort and pagination. Do not add a map pager. The heading stays. Filters apply to both. Load Maps JS ONLY through \`<script src="https://maps.fndn.ai/sdk.js?callback=initMap" async defer />\` \u2014 never a Google key in the app, never \`NEXT_PUBLIC_GOOGLE_MAPS_API_KEY\`, never \`maps.googleapis.com\`, never \`@vis.gl/react-google-maps\`. From \`${STUDIO_SDK_PACKAGE}/react\` import useMapSearch; it fetches, debounces, and clusters. \`const map = useMapSearch({ siteId, baseUrl: GARAGEM_API_BASE, bounds, zoom, q, sort, location, filters, publishableKey })\` with the same q, sort, location, filters, and publishableKey as the list. Pass the map's current zoom on every zoom change, including after a cluster click. Changing zoom recomputes \`map.clusters\` and does not refetch; a bounds change refetches. Do not send filter_by, vector_query, or nl_query from the browser. Request page 1 and pageSize at most 100. Do not walk totalPages. Pins are the masked coordinates the API returned \u2014 plot them as returned, never geocode the street. Render \`map.clusters\` with \`google.maps.Marker\` (no map id needed), in two styles that never look alike. A cluster (\`count > 1\`) is a filled circle in the brand color with a white border and the white count as its label. A listing (\`count === 1\` with \`cluster.pin\`) is a white rounded-rectangle chip with a brand-color border, labelled with the short price in the brand color ("R$ 850 mil", "R$ 1,2 mi"; "Consulte" when the price is null or 0): \`icon: { path: "M-34,-12 h68 a6,6 0 0 1 6,6 v12 a6,6 0 0 1 -6,6 h-68 a6,6 0 0 1 -6,-6 v-12 a6,6 0 0 1 6,-6 z", fillColor: "#ffffff", fillOpacity: 1, strokeColor: brand, strokeWeight: 1.5, scale: 1, labelOrigin: new google.maps.Point(0, 0) }\`. Never draw a listing as a dot or a circle, and never without its price. Clicking a listing selects it and shows its card. Clicking a cluster opens its members: \`const members = map.pins.filter((pin) => cluster.pinIds.includes(pin.id))\`, then \`fitBounds\` a LatLngBounds of their coordinates with about 64px padding, so the listings land inside the new view and split into chips. Do not step the zoom around \`cluster.lat\`/\`cluster.lng\`: that point is approximate and the area around it can come back empty. When every member has the same coordinates, or the map is already at zoom 18, do not zoom: open a small list of those listings, each with its price and a link. Layout, top to bottom: query, heading, toolbar, then the view. On desktop the toolbar is one row: featured filters on the left, and the list/map toggle immediately beside the sort select on the right. On a narrow screen the filters stay in one horizontal scroll that does not wrap, and the toggle plus the sort sit together on the row below that scroll. On the map the sort is hidden, so the toggle keeps that place beside where the sort was. In map mode the map fills the remaining viewport height, with a minimum of about 240px. Keep the hook's 400ms viewport debounce. A drawn polygon is not required. Do not add a separate /mapa route, a regions page, or a map on the listing page. Do not call Street View or travel time inside the map search.`;
|
|
3065
3399
|
}
|
|
3066
3400
|
function marketExportsAvailableAt(pin) {
|
|
3067
3401
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.marketExportsSince) >= 0;
|
|
@@ -3087,47 +3421,54 @@ function studioPhotoSearchInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3087
3421
|
function studioChromeInstruction() {
|
|
3088
3422
|
return `Card, skeleton, and search chrome markup are app-owned. Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` \u2014 v0 preview cannot load npm CSS. Do not mount an SDK stylesheet. Theme with site tokens and \`--radius\` in \`app/globals.css\`.`;
|
|
3089
3423
|
}
|
|
3090
|
-
function mentionsExportName(
|
|
3091
|
-
return new RegExp(`\\b${name}\\b`).test(
|
|
3424
|
+
function mentionsExportName(text2, name) {
|
|
3425
|
+
return new RegExp(`\\b${name}\\b`).test(text2);
|
|
3092
3426
|
}
|
|
3093
|
-
function studioCodegenContractViolations(
|
|
3427
|
+
function studioCodegenContractViolations(text2) {
|
|
3094
3428
|
const violations = [];
|
|
3095
3429
|
for (const [name, since] of Object.entries(
|
|
3096
3430
|
STUDIO_SDK_CONTRACT.optionalReactExports
|
|
3097
3431
|
)) {
|
|
3098
3432
|
if (compareSemver(STUDIO_SDK_CONTRACT.minNpmVersion, since) >= 0) continue;
|
|
3099
|
-
if (mentionsExportName(
|
|
3433
|
+
if (mentionsExportName(text2, name)) violations.push(name);
|
|
3100
3434
|
}
|
|
3101
3435
|
for (const name of STUDIO_SDK_CONTRACT.retiredReactExports) {
|
|
3102
|
-
if (mentionsExportName(
|
|
3436
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3103
3437
|
violations.push(name);
|
|
3104
3438
|
}
|
|
3105
3439
|
}
|
|
3106
3440
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedSearchExports) {
|
|
3107
|
-
if (mentionsExportName(
|
|
3441
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3108
3442
|
violations.push(name);
|
|
3109
3443
|
}
|
|
3110
3444
|
}
|
|
3111
3445
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
3112
|
-
if (mentionsExportName(
|
|
3446
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3113
3447
|
violations.push(name);
|
|
3114
3448
|
}
|
|
3115
3449
|
}
|
|
3116
3450
|
if (!mapsExportsPublished()) {
|
|
3117
3451
|
for (const name of STUDIO_SDK_CONTRACT.mapsExports) {
|
|
3118
|
-
if (mentionsExportName(
|
|
3452
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3119
3453
|
violations.push(name);
|
|
3120
3454
|
}
|
|
3121
3455
|
}
|
|
3122
3456
|
}
|
|
3123
3457
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhotoExports) {
|
|
3124
|
-
if (mentionsExportName(
|
|
3458
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3125
3459
|
violations.push(name);
|
|
3126
3460
|
}
|
|
3127
3461
|
}
|
|
3128
3462
|
if (!isPhotoSearchOnPin()) {
|
|
3129
3463
|
for (const name of STUDIO_SDK_CONTRACT.photoSearchExports) {
|
|
3130
|
-
if (mentionsExportName(
|
|
3464
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3465
|
+
violations.push(name);
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
if (!isSellerLeadOnPin()) {
|
|
3470
|
+
for (const name of STUDIO_SDK_CONTRACT.sellerLeadExports) {
|
|
3471
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3131
3472
|
violations.push(name);
|
|
3132
3473
|
}
|
|
3133
3474
|
}
|
|
@@ -3135,21 +3476,21 @@ function studioCodegenContractViolations(text) {
|
|
|
3135
3476
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
3136
3477
|
if (!marketExportsAvailableAt(pin)) {
|
|
3137
3478
|
for (const name of STUDIO_SDK_CONTRACT.marketExports) {
|
|
3138
|
-
if (mentionsExportName(
|
|
3479
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3139
3480
|
violations.push(name);
|
|
3140
3481
|
}
|
|
3141
3482
|
}
|
|
3142
3483
|
}
|
|
3143
3484
|
const available = reactExportsAvailableAt(pin);
|
|
3144
|
-
for (const name of parseReactSdkNamedImports(
|
|
3485
|
+
for (const name of parseReactSdkNamedImports(text2)) {
|
|
3145
3486
|
if (!available.has(name) && !violations.includes(name)) {
|
|
3146
3487
|
violations.push(name);
|
|
3147
3488
|
}
|
|
3148
3489
|
}
|
|
3149
|
-
if (hasShowcaseLeadsPostUrl(
|
|
3490
|
+
if (hasShowcaseLeadsPostUrl(text2)) {
|
|
3150
3491
|
violations.push("showcase-leads-url");
|
|
3151
3492
|
}
|
|
3152
|
-
if (/\btype\s*=\s*["']date["']/.test(
|
|
3493
|
+
if (/\btype\s*=\s*["']date["']/.test(text2)) {
|
|
3153
3494
|
violations.push("native-date-input");
|
|
3154
3495
|
}
|
|
3155
3496
|
return violations;
|
|
@@ -3342,14 +3683,14 @@ function listingCoordinates(listing) {
|
|
|
3342
3683
|
}
|
|
3343
3684
|
function coordinateDecimals(value) {
|
|
3344
3685
|
if (!Number.isFinite(value)) return 0;
|
|
3345
|
-
const
|
|
3346
|
-
if (
|
|
3686
|
+
const text2 = Math.abs(value).toString();
|
|
3687
|
+
if (text2.includes("e")) {
|
|
3347
3688
|
const fixed = Math.abs(value).toFixed(12).replace(/0+$/, "");
|
|
3348
3689
|
const dot2 = fixed.indexOf(".");
|
|
3349
3690
|
return dot2 === -1 ? 0 : fixed.length - dot2 - 1;
|
|
3350
3691
|
}
|
|
3351
|
-
const dot =
|
|
3352
|
-
return dot === -1 ? 0 :
|
|
3692
|
+
const dot = text2.indexOf(".");
|
|
3693
|
+
return dot === -1 ? 0 : text2.length - dot - 1;
|
|
3353
3694
|
}
|
|
3354
3695
|
function roundTo(value, decimals) {
|
|
3355
3696
|
const factor = 10 ** decimals;
|
|
@@ -3890,15 +4231,15 @@ function usablePin(pin) {
|
|
|
3890
4231
|
return finitePair(pin.lat, pin.lng) !== null && !(pin.lat === 0 && pin.lng === 0);
|
|
3891
4232
|
}
|
|
3892
4233
|
function groupPrecision(group) {
|
|
3893
|
-
let
|
|
4234
|
+
let max = 0;
|
|
3894
4235
|
for (const pin of group) {
|
|
3895
|
-
|
|
3896
|
-
|
|
4236
|
+
max = Math.max(
|
|
4237
|
+
max,
|
|
3897
4238
|
coordinateDecimals(pin.lat),
|
|
3898
4239
|
coordinateDecimals(pin.lng)
|
|
3899
4240
|
);
|
|
3900
4241
|
}
|
|
3901
|
-
return
|
|
4242
|
+
return max;
|
|
3902
4243
|
}
|
|
3903
4244
|
function multiCluster(key, group) {
|
|
3904
4245
|
const lat = group.reduce((sum, pin) => sum + pin.lat, 0) / group.length;
|
|
@@ -4213,15 +4554,15 @@ function listingVisualHighlights(listing, options) {
|
|
|
4213
4554
|
if (!isPhoto(item) || !Array.isArray(item.features)) continue;
|
|
4214
4555
|
for (const feature of item.features) {
|
|
4215
4556
|
if (typeof feature !== "string") continue;
|
|
4216
|
-
const
|
|
4217
|
-
if (!
|
|
4218
|
-
const key = normalizeRoomLabel(
|
|
4557
|
+
const text2 = feature.trim();
|
|
4558
|
+
if (!text2) continue;
|
|
4559
|
+
const key = normalizeRoomLabel(text2);
|
|
4219
4560
|
if (!key) continue;
|
|
4220
4561
|
const entry = counts.get(key);
|
|
4221
4562
|
if (entry) {
|
|
4222
4563
|
entry.count += 1;
|
|
4223
4564
|
} else {
|
|
4224
|
-
counts.set(key, { text, count: 1, seen: seen++ });
|
|
4565
|
+
counts.set(key, { text: text2, count: 1, seen: seen++ });
|
|
4225
4566
|
}
|
|
4226
4567
|
}
|
|
4227
4568
|
}
|
|
@@ -4485,6 +4826,10 @@ export {
|
|
|
4485
4826
|
PHOTO_SEARCH_MIN_QUERY_LENGTH,
|
|
4486
4827
|
SEARCH_EMPTY_COPY,
|
|
4487
4828
|
SEARCH_SORT_RELEVANCE,
|
|
4829
|
+
SELLER_LEAD_PHOTO_MAX_BYTES,
|
|
4830
|
+
SELLER_LEAD_PHOTO_MAX_COUNT,
|
|
4831
|
+
SELLER_LEAD_PHOTO_TYPES,
|
|
4832
|
+
STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG,
|
|
4488
4833
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
4489
4834
|
STUDIO_SDK_CONTRACT,
|
|
4490
4835
|
STUDIO_SDK_PACKAGE,
|
|
@@ -4546,7 +4891,10 @@ export {
|
|
|
4546
4891
|
isMapBounds,
|
|
4547
4892
|
isMapPolygon,
|
|
4548
4893
|
isPhotoSearchOnPin,
|
|
4894
|
+
isSellerLeadOnPin,
|
|
4549
4895
|
isStudioPreviewHost,
|
|
4896
|
+
isValidEmail,
|
|
4897
|
+
isValidName,
|
|
4550
4898
|
isValidPhone,
|
|
4551
4899
|
isVisitSlotAllowed,
|
|
4552
4900
|
labelAmenities,
|
|
@@ -4616,6 +4964,8 @@ export {
|
|
|
4616
4964
|
searchListingsInPolygon,
|
|
4617
4965
|
searchResultsHeading,
|
|
4618
4966
|
searchSortOptions,
|
|
4967
|
+
sellerAddressErrors,
|
|
4968
|
+
sellerPhotoSchedule,
|
|
4619
4969
|
serializeAppliedSearchQuery2 as serializeAppliedSearchQuery,
|
|
4620
4970
|
slotsForDate,
|
|
4621
4971
|
studioAmenityInstruction,
|
|
@@ -4626,6 +4976,7 @@ export {
|
|
|
4626
4976
|
studioLeadInstruction,
|
|
4627
4977
|
studioListingCardInstruction,
|
|
4628
4978
|
studioListingDetailInstruction,
|
|
4979
|
+
studioMapSearchInstruction,
|
|
4629
4980
|
studioMapsInstruction,
|
|
4630
4981
|
studioMarketInstruction,
|
|
4631
4982
|
studioPhotoInstruction,
|
|
@@ -4635,8 +4986,10 @@ export {
|
|
|
4635
4986
|
studioSdkPinInstruction,
|
|
4636
4987
|
studioSearchInstruction,
|
|
4637
4988
|
studioSearchLandmarkInstruction,
|
|
4989
|
+
studioSellerLeadSdkInstruction,
|
|
4638
4990
|
studioSiteWidthCss,
|
|
4639
4991
|
submitContactLead,
|
|
4992
|
+
submitSellerLead,
|
|
4640
4993
|
submitVisitLead,
|
|
4641
4994
|
toE164,
|
|
4642
4995
|
toListingCardModel,
|
|
@@ -4646,6 +4999,7 @@ export {
|
|
|
4646
4999
|
travelTimesFromListing,
|
|
4647
5000
|
truncateNationalPhoneDigits,
|
|
4648
5001
|
unavailableReactImports,
|
|
5002
|
+
uploadSellerLeadPhoto,
|
|
4649
5003
|
visibleSearchFilters
|
|
4650
5004
|
};
|
|
4651
5005
|
//# sourceMappingURL=index.mjs.map
|