@garagem-ai/site-sdk 0.5.2 → 0.6.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/README.md +16 -25
- package/dist/index.d.mts +296 -28
- package/dist/index.d.ts +296 -28
- package/dist/index.js +469 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +458 -51
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +18 -60
- package/dist/react.d.ts +18 -60
- package/dist/react.js +265 -874
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +246 -841
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-4ocM0UPk.d.mts → search-engine-CtnLzmwW.d.mts} +13 -181
- package/dist/{search-engine-4ocM0UPk.d.ts → search-engine-CtnLzmwW.d.ts} +13 -181
- package/package.json +11 -13
- package/src/amenity-labels.ts +9 -2
- package/src/fetchers.ts +2 -1
- package/src/index.ts +20 -2
- package/src/internal/url.ts +1 -0
- package/src/leads.ts +45 -6
- package/src/listing-card-model.ts +4 -1
- package/src/listing-detail.ts +8 -2
- package/src/phone-countries.ts +97 -0
- package/src/phone.ts +431 -0
- package/src/presentation.ts +1 -24
- package/src/react/index.ts +1 -11
- package/src/react/public-search-snapshot.ts +165 -0
- package/src/react/staged-filters-mirror.ts +38 -0
- package/src/react/types.ts +17 -30
- package/src/react/use-public-search.ts +121 -42
- package/src/search-engine.ts +3 -0
- package/src/studio-contract.ts +63 -21
- package/src/types.ts +12 -0
- package/src/react/cn.ts +0 -3
- package/src/react/listing-card.tsx +0 -98
- package/src/react/listing-detail-fields.tsx +0 -119
- package/src/react/search-chrome.tsx +0 -29
- package/src/react/search.css +0 -214
- package/src/react/styles/index.ts +0 -1
- package/src/react/styles/search-chrome-css.generated.ts +0 -5
- package/src/react/styles/search-chrome-styles.tsx +0 -31
package/dist/react.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
|
-
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
7
|
var __export = (target, all) => {
|
|
10
8
|
for (var name in all)
|
|
@@ -18,564 +16,87 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
|
|
31
21
|
// src/react/index.ts
|
|
32
22
|
var react_exports = {};
|
|
33
23
|
__export(react_exports, {
|
|
34
|
-
ListingCard: () => ListingCard,
|
|
35
|
-
ListingDetailFields: () => ListingDetailFields,
|
|
36
|
-
ResultsSkeleton: () => ResultsSkeleton,
|
|
37
|
-
SearchChromeStyles: () => SearchChromeStyles,
|
|
38
24
|
usePublicSearch: () => usePublicSearch
|
|
39
25
|
});
|
|
40
26
|
module.exports = __toCommonJS(react_exports);
|
|
41
27
|
|
|
42
|
-
// src/react/
|
|
43
|
-
var
|
|
28
|
+
// src/react/use-public-search.ts
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_navigation = require("next/navigation");
|
|
44
31
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
mediaRatio: "--garagem-listing-media-ratio",
|
|
51
|
-
controlHeight: "--garagem-search-control-height",
|
|
52
|
-
iconSize: "--garagem-search-icon-size",
|
|
53
|
-
skeleton: "--garagem-skeleton"
|
|
54
|
-
};
|
|
55
|
-
var SEARCH_CSS_RECIPE = `:root {
|
|
56
|
-
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
57
|
-
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
58
|
-
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
59
|
-
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
60
|
-
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
61
|
-
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
62
|
-
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
66
|
-
if (amount == null) return "Sob consulta";
|
|
67
|
-
try {
|
|
68
|
-
return new Intl.NumberFormat(locale, {
|
|
69
|
-
style: "currency",
|
|
70
|
-
currency,
|
|
71
|
-
minimumFractionDigits: 0,
|
|
72
|
-
maximumFractionDigits: 0
|
|
73
|
-
}).format(amount);
|
|
74
|
-
} catch {
|
|
75
|
-
return `${currency} ${amount}`;
|
|
76
|
-
}
|
|
32
|
+
// src/internal/url.ts
|
|
33
|
+
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
34
|
+
function normalizeBaseUrl(baseUrl) {
|
|
35
|
+
const url = baseUrl ?? DEFAULT_BASE_URL;
|
|
36
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
77
37
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
38
|
+
async function coerceSiteId(siteId) {
|
|
39
|
+
const raw = typeof siteId === "function" ? siteId() : siteId;
|
|
40
|
+
const value = await Promise.resolve(raw);
|
|
41
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
42
|
+
throw new TypeError(
|
|
43
|
+
"Garagem SDK: siteId must be a string. Await resolveSiteId(...) before getListings / getSearchUi / queryListings."
|
|
44
|
+
);
|
|
81
45
|
}
|
|
82
|
-
|
|
83
|
-
if (!digits) return void 0;
|
|
84
|
-
const amount = Number.parseInt(digits, 10);
|
|
85
|
-
return Number.isFinite(amount) ? amount : void 0;
|
|
86
|
-
}
|
|
87
|
-
function formatAreaM2(area) {
|
|
88
|
-
if (area == null || !Number.isFinite(area)) return null;
|
|
89
|
-
return `${area} m\xB2`;
|
|
90
|
-
}
|
|
91
|
-
function listingBusinessLabel(businessType) {
|
|
92
|
-
return businessType === "rental" ? "Aluguel" : "Venda";
|
|
46
|
+
return value;
|
|
93
47
|
}
|
|
94
48
|
|
|
95
|
-
// src/
|
|
96
|
-
function
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
49
|
+
// src/fetchers.ts
|
|
50
|
+
async function callJson(url, init, fetchImpl) {
|
|
51
|
+
const response = await fetchImpl(url, init);
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const text = await response.text().catch(() => "");
|
|
54
|
+
throw new GaragemSdkError(
|
|
55
|
+
`Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`,
|
|
56
|
+
{ status: response.status, url }
|
|
57
|
+
);
|
|
102
58
|
}
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// src/listing-card-model.ts
|
|
107
|
-
function listingLocationLabel(location) {
|
|
108
|
-
return [location.neighborhood, location.city, location.state].map((part) => part ? String(part).trim() : "").filter(Boolean).join(", ");
|
|
109
|
-
}
|
|
110
|
-
function toListingCardModel(listing) {
|
|
111
|
-
const isPrivate = listing.priceVisibility === "private";
|
|
112
|
-
const area = listing.property?.usableArea ?? listing.property?.totalArea;
|
|
113
|
-
return {
|
|
114
|
-
href: listingPublicPath(listing),
|
|
115
|
-
title: listing.title,
|
|
116
|
-
businessType: listing.businessType,
|
|
117
|
-
businessLabel: listingBusinessLabel(listing.businessType),
|
|
118
|
-
priceVisibility: listing.priceVisibility,
|
|
119
|
-
price: listing.price,
|
|
120
|
-
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price),
|
|
121
|
-
pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
|
|
122
|
-
locationLabel: listingLocationLabel(listing.location || {}),
|
|
123
|
-
propertyType: listing.property?.type ?? null,
|
|
124
|
-
coverSrc: listing.coverImage?.src ?? null,
|
|
125
|
-
coverAlt: listing.coverImage?.alt ?? listing.title,
|
|
126
|
-
bedrooms: listing.property?.bedrooms ?? null,
|
|
127
|
-
bathrooms: listing.property?.bathrooms ?? null,
|
|
128
|
-
parkingSpaces: listing.property?.parkingSpaces ?? null,
|
|
129
|
-
areaM2: area ?? null
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/react/cn.ts
|
|
134
|
-
function cn(...parts) {
|
|
135
|
-
return parts.filter(Boolean).join(" ");
|
|
59
|
+
return await response.json();
|
|
136
60
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
// src/react/styles/search-chrome-styles.tsx
|
|
146
|
-
var STYLE_ID = `garagem-search-chrome-${SEARCH_CHROME_CSS_VERSION}`;
|
|
147
|
-
function injectSearchChromeOnce() {
|
|
148
|
-
if (typeof document === "undefined") return;
|
|
149
|
-
if (document.getElementById(STYLE_ID)) return;
|
|
150
|
-
const el = document.createElement("style");
|
|
151
|
-
el.id = STYLE_ID;
|
|
152
|
-
el.textContent = SEARCH_CHROME_CSS;
|
|
153
|
-
document.head.appendChild(el);
|
|
154
|
-
}
|
|
155
|
-
function SearchChromeStyles() {
|
|
156
|
-
if (typeof document !== "undefined") {
|
|
157
|
-
injectSearchChromeOnce();
|
|
61
|
+
var GaragemSdkError = class extends Error {
|
|
62
|
+
status;
|
|
63
|
+
url;
|
|
64
|
+
constructor(message, info) {
|
|
65
|
+
super(message);
|
|
66
|
+
this.name = "GaragemSdkError";
|
|
67
|
+
this.status = info.status;
|
|
68
|
+
this.url = info.url;
|
|
158
69
|
}
|
|
159
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
160
|
-
injectSearchChromeOnce();
|
|
161
|
-
}, []);
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/react/listing-card.tsx
|
|
166
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
167
|
-
function isListing(value) {
|
|
168
|
-
return "priceVisibility" in value && "businessType" in value && "title" in value;
|
|
169
|
-
}
|
|
170
|
-
function ListingCard({
|
|
171
|
-
listing,
|
|
172
|
-
href,
|
|
173
|
-
className,
|
|
174
|
-
classNames,
|
|
175
|
-
slots,
|
|
176
|
-
style
|
|
177
|
-
}) {
|
|
178
|
-
const model = isListing(listing) ? toListingCardModel(listing) : listing;
|
|
179
|
-
const target = href ?? model.href;
|
|
180
|
-
const areaLabel = formatAreaM2(model.areaM2);
|
|
181
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
182
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SearchChromeStyles, {}),
|
|
183
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
|
-
"article",
|
|
185
|
-
{
|
|
186
|
-
"data-slot": "listing-card",
|
|
187
|
-
className: cn(className, classNames?.root),
|
|
188
|
-
style,
|
|
189
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_link.default, { href: target, "data-slot": "listing-card-link", children: [
|
|
190
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-media", className: classNames?.media, children: [
|
|
191
|
-
slots?.media ?? (model.coverSrc ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { src: model.coverSrc, alt: model.coverAlt }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "listing-card-empty", children: "Sem foto" })),
|
|
192
|
-
slots?.badge ?? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
193
|
-
"span",
|
|
194
|
-
{
|
|
195
|
-
"data-slot": "listing-card-badge",
|
|
196
|
-
className: classNames?.badge,
|
|
197
|
-
children: model.businessLabel
|
|
198
|
-
}
|
|
199
|
-
)
|
|
200
|
-
] }),
|
|
201
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-body", className: classNames?.body, children: [
|
|
202
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { "data-slot": "listing-card-price-row", children: [
|
|
203
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { "data-slot": "listing-card-price", className: classNames?.price, children: model.priceLabel }),
|
|
204
|
-
model.pricePeriod ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "data-slot": "listing-card-period", children: model.pricePeriod }) : null
|
|
205
|
-
] }),
|
|
206
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { "data-slot": "listing-card-title", className: classNames?.title, children: model.title }),
|
|
207
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
208
|
-
"p",
|
|
209
|
-
{
|
|
210
|
-
"data-slot": "listing-card-location",
|
|
211
|
-
className: classNames?.location,
|
|
212
|
-
children: model.locationLabel || model.propertyType || ""
|
|
213
|
-
}
|
|
214
|
-
),
|
|
215
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
216
|
-
"ul",
|
|
217
|
-
{
|
|
218
|
-
"data-slot": "listing-card-features",
|
|
219
|
-
className: classNames?.features,
|
|
220
|
-
children: [
|
|
221
|
-
model.bedrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
222
|
-
model.bedrooms,
|
|
223
|
-
" quartos"
|
|
224
|
-
] }) : null,
|
|
225
|
-
model.bathrooms != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
226
|
-
model.bathrooms,
|
|
227
|
-
" banheiros"
|
|
228
|
-
] }) : null,
|
|
229
|
-
model.parkingSpaces != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
230
|
-
model.parkingSpaces,
|
|
231
|
-
" vagas"
|
|
232
|
-
] }) : null,
|
|
233
|
-
areaLabel ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: areaLabel }) : null
|
|
234
|
-
]
|
|
235
|
-
}
|
|
236
|
-
),
|
|
237
|
-
slots?.cta ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "listing-card-cta", className: classNames?.cta, children: slots.cta }) : null
|
|
238
|
-
] })
|
|
239
|
-
] })
|
|
240
|
-
}
|
|
241
|
-
)
|
|
242
|
-
] });
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// src/amenity-labels.ts
|
|
246
|
-
var LISTING_AMENITY_TITLES = {
|
|
247
|
-
unit: "Comodidades",
|
|
248
|
-
building: "Comodidades do condom\xEDnio"
|
|
249
70
|
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
energiaSolar: "Energia solar",
|
|
260
|
-
fechaduraDigital: "Fechadura digital",
|
|
261
|
-
fechaduraEletronica: "Fechadura eletr\xF4nica",
|
|
262
|
-
geradorEletrico: "Gerador el\xE9trico",
|
|
263
|
-
gesso: "Gesso",
|
|
264
|
-
hidromassagem: "Hidromassagem",
|
|
265
|
-
lareira: "Lareira",
|
|
266
|
-
ofuro: "Ofur\xF4",
|
|
267
|
-
spa: "Spa",
|
|
268
|
-
painelSolar: "Painel solar",
|
|
269
|
-
portaoEletronico: "Port\xE3o eletr\xF4nico",
|
|
270
|
-
sistemaAlarme: "Sistema de alarme",
|
|
271
|
-
homeTheater: "Home theater",
|
|
272
|
-
adega: "Adega",
|
|
273
|
-
split: "Split",
|
|
274
|
-
arCentral: "Ar central",
|
|
275
|
-
esperaSplit: "Espera para split",
|
|
276
|
-
vistaMar: "Vista para o mar",
|
|
277
|
-
vistaPanoramica: "Vista panor\xE2mica",
|
|
278
|
-
aguaQuente: "\xC1gua quente",
|
|
279
|
-
reformado: "Reformado",
|
|
280
|
-
tvCabo: "TV a cabo",
|
|
281
|
-
gradeado: "Gradeado",
|
|
282
|
-
antenaParabolica: "Antena parab\xF3lica",
|
|
283
|
-
aquecimento: "Aquecimento",
|
|
284
|
-
aquecimentoEletrico: "Aquecimento el\xE9trico",
|
|
285
|
-
aquecimentoCentral: "Aquecimento central",
|
|
286
|
-
cercaEletrica: "Cerca el\xE9trica",
|
|
287
|
-
monitoramento: "Monitoramento",
|
|
288
|
-
vigiaInterno: "Vigia interno",
|
|
289
|
-
vigiaExterno: "Vigia externo",
|
|
290
|
-
alarme: "Alarme",
|
|
291
|
-
agua: "\xC1gua",
|
|
292
|
-
redeEsgoto: "Rede de esgoto",
|
|
293
|
-
pavimentacao: "Pavimenta\xE7\xE3o",
|
|
294
|
-
energiaEletrica: "Energia el\xE9trica",
|
|
295
|
-
// Furniture
|
|
296
|
-
mobiliado: "Mobiliado",
|
|
297
|
-
armarioEmbutido: "Arm\xE1rio embutido",
|
|
298
|
-
armarioEmbutidoQuarto: "Arm\xE1rio embutido quarto",
|
|
299
|
-
armarioCozinha: "Arm\xE1rio cozinha",
|
|
300
|
-
armarioBanheiro: "Arm\xE1rio banheiro",
|
|
301
|
-
cozinhaPlanejada: "Cozinha planejada",
|
|
302
|
-
fogao: "Fog\xE3o",
|
|
303
|
-
fornoPizza: "Forno de pizza",
|
|
304
|
-
freezer: "Freezer",
|
|
305
|
-
dormitorioComArmario: "Dormit\xF3rio com arm\xE1rio",
|
|
306
|
-
semiMobiliado: "Semi mobiliado",
|
|
307
|
-
salaArmarios: "Sala com arm\xE1rios",
|
|
308
|
-
// Structure
|
|
309
|
-
piscina: "Piscina",
|
|
310
|
-
piscinaAquecida: "Piscina aquecida",
|
|
311
|
-
piscinaCoberta: "Piscina coberta",
|
|
312
|
-
poco: "Po\xE7o",
|
|
313
|
-
pocoArtesiano: "Po\xE7o artesiano",
|
|
314
|
-
bar: "Bar",
|
|
315
|
-
jardim: "Jardim",
|
|
316
|
-
lago: "Lago",
|
|
317
|
-
lavabo: "Lavabo",
|
|
318
|
-
quintal: "Quintal",
|
|
319
|
-
solarium: "Solarium",
|
|
320
|
-
quartoServico: "Quarto de servi\xE7o",
|
|
321
|
-
varanda: "Varanda",
|
|
322
|
-
varandaFechadaVidro: "Varanda fechada com vidro",
|
|
323
|
-
varandaGourmet: "Varanda gourmet",
|
|
324
|
-
banheiroServico: "Banheiro de servi\xE7o",
|
|
325
|
-
areaServico: "\xC1rea de servi\xE7o",
|
|
326
|
-
cinema: "Cinema",
|
|
327
|
-
closet: "Closet",
|
|
328
|
-
cozinhaAmericana: "Cozinha americana",
|
|
329
|
-
cozinhaGourmet: "Cozinha gourmet",
|
|
330
|
-
despensa: "Despensa",
|
|
331
|
-
escritorio: "Escrit\xF3rio",
|
|
332
|
-
edicula: "Ed\xEDcula",
|
|
333
|
-
horta: "Horta",
|
|
334
|
-
sacada: "Sacada",
|
|
335
|
-
salaJantar: "Sala de jantar",
|
|
336
|
-
cozinha: "Cozinha",
|
|
337
|
-
banheiroSocial: "Banheiro social",
|
|
338
|
-
terraco: "Terra\xE7o",
|
|
339
|
-
copa: "Copa",
|
|
340
|
-
suiteMaster: "Su\xEDte master",
|
|
341
|
-
wcEmpregada: "WC empregada",
|
|
342
|
-
dependenciaEmpregada: "Depend\xEAncia de empregada",
|
|
343
|
-
dependenciadeEmpregada: "Depend\xEAncia empregada",
|
|
344
|
-
salaTv: "Sala de TV",
|
|
345
|
-
copaCozinha: "Copa cozinha",
|
|
346
|
-
sacadaComChurrasqueira: "Sacada com churrasqueira",
|
|
347
|
-
hallPrivativo: "Hall privativo",
|
|
348
|
-
estarIntimo: "Estar \xEDntimo",
|
|
349
|
-
livingHall: "Living hall",
|
|
350
|
-
piscinaInterna: "Piscina interna",
|
|
351
|
-
deck: "Deck",
|
|
352
|
-
jardimInverno: "Jardim de inverno",
|
|
353
|
-
rouparia: "Rouparia",
|
|
354
|
-
living: "Living",
|
|
355
|
-
familyRoom: "Family room",
|
|
356
|
-
salafitness: "Sala fitness",
|
|
357
|
-
salaEstar: "Sala de estar",
|
|
358
|
-
mezanino: "Mezanino",
|
|
359
|
-
pisoElevado: "Piso elevado",
|
|
360
|
-
entradaServicoIndependente: "Entrada de servi\xE7o independente",
|
|
361
|
-
forro: "Forro",
|
|
362
|
-
vitrine: "Vitrine",
|
|
363
|
-
banheiroAuxiliar: "Banheiro auxiliar",
|
|
364
|
-
gabinete: "Gabinete",
|
|
365
|
-
quadraTenisPrivativa: "Quadra de t\xEAnis privativa",
|
|
366
|
-
porao: "Por\xE3o",
|
|
367
|
-
sotao: "S\xF3t\xE3o",
|
|
368
|
-
patio: "P\xE1tio",
|
|
369
|
-
canaletasNoRodape: "Canaletas no rodap\xE9",
|
|
370
|
-
// Accessibility
|
|
371
|
-
barraApoioVaso: "Barra de apoio vaso",
|
|
372
|
-
barraApoioChuveiro: "Barra de apoio chuveiro",
|
|
373
|
-
entradaSemDegrau: "Entrada sem degrau",
|
|
374
|
-
rampasAcesso: "Rampas de acesso",
|
|
375
|
-
vagaDeficientes: "Vaga para deficientes",
|
|
376
|
-
// Flooring
|
|
377
|
-
cimentoQueimado: "Cimento queimado",
|
|
378
|
-
madeira: "Madeira",
|
|
379
|
-
pisoFrio: "Piso frio",
|
|
380
|
-
laminado: "Laminado",
|
|
381
|
-
vinilico: "Vin\xEDlico",
|
|
382
|
-
porcelanato: "Porcelanato",
|
|
383
|
-
// ==================== BUILDING FEATURES ====================
|
|
384
|
-
// Amenities
|
|
385
|
-
elevador: "Elevador",
|
|
386
|
-
bicicletario: "Biciclet\xE1rio",
|
|
387
|
-
carregadorEletronico: "Carregador eletr\xF4nico",
|
|
388
|
-
concierge: "Concierge",
|
|
389
|
-
coworking: "Coworking",
|
|
390
|
-
deposito: "Dep\xF3sito",
|
|
391
|
-
lavanderia: "Lavanderia",
|
|
392
|
-
petPlace: "Pet place",
|
|
393
|
-
recebimentoEncomendas: "Recebimento de encomendas",
|
|
394
|
-
salaReuniao: "Sala de reuni\xE3o",
|
|
395
|
-
salaoFestas: "Sal\xE3o de festas",
|
|
396
|
-
valet: "Valet",
|
|
397
|
-
garagemCoberta: "Garagem coberta",
|
|
398
|
-
elevadorServico: "Elevador de servi\xE7o",
|
|
399
|
-
// Leisure
|
|
400
|
-
academia: "Academia",
|
|
401
|
-
campoFutebol: "Campo de futebol",
|
|
402
|
-
espacoGourmet: "Espa\xE7o gourmet",
|
|
403
|
-
piscinaInfantil: "Piscina infantil",
|
|
404
|
-
pistaCaminhada: "Pista de caminhada",
|
|
405
|
-
playground: "Playground",
|
|
406
|
-
quadraPoliesportiva: "Quadra poliesportiva",
|
|
407
|
-
quadraTenis: "Quadra de t\xEAnis",
|
|
408
|
-
salaJogos: "Sala de jogos",
|
|
409
|
-
salaVapor: "Sala de vapor",
|
|
410
|
-
sauna: "Sauna",
|
|
411
|
-
// Security
|
|
412
|
-
circuitoTv: "Circuito fechado de TV",
|
|
413
|
-
controleAcessoEletronico: "Controle de acesso eletr\xF4nico",
|
|
414
|
-
interfone: "Interfone",
|
|
415
|
-
portaria24h: "Portaria 24h",
|
|
416
|
-
porteiroFisico: "Porteiro f\xEDsico",
|
|
417
|
-
seguranca24h: "Seguran\xE7a 24h",
|
|
418
|
-
segurancaPatrimonial: "Seguran\xE7a patrimonial",
|
|
419
|
-
condominioFechado: "Condom\xEDnio fechado",
|
|
420
|
-
// Accessibility
|
|
421
|
-
banheiroAcessivel: "Banheiro acess\xEDvel",
|
|
422
|
-
elevadorAcessivel: "Elevador acess\xEDvel",
|
|
423
|
-
pisoTatil: "Piso t\xE1til",
|
|
424
|
-
// ==================== CANONICAL HAS*/IS* KEYS ====================
|
|
425
|
-
has24hConcierge: "Portaria 24h",
|
|
426
|
-
has24hSecurity: "Seguran\xE7a 24h",
|
|
427
|
-
hasAccessRamps: "Rampas de acesso",
|
|
428
|
-
hasAccessibleBathroom: "Banheiro acess\xEDvel",
|
|
429
|
-
hasAccessibleElevator: "Elevador acess\xEDvel",
|
|
430
|
-
hasAirConditioning: "Ar condicionado",
|
|
431
|
-
hasAlarmSystem: "Sistema de alarme",
|
|
432
|
-
hasBalcony: "Varanda",
|
|
433
|
-
hasBikeStorage: "Biciclet\xE1rio",
|
|
434
|
-
hasBuiltInWardrobe: "Arm\xE1rio embutido",
|
|
435
|
-
hasCCTV: "CFTV",
|
|
436
|
-
hasCloset: "Closet",
|
|
437
|
-
hasConcierge: "Portaria",
|
|
438
|
-
hasControlledAccess: "Condom\xEDnio fechado",
|
|
439
|
-
hasCoworking: "Coworking",
|
|
440
|
-
hasDisabledParking: "Vaga para deficientes",
|
|
441
|
-
hasElectricCharger: "Carregador eletr\xF4nico",
|
|
442
|
-
hasElectronicGate: "Port\xE3o eletr\xF4nico",
|
|
443
|
-
hasElevator: "Elevador",
|
|
444
|
-
hasFireplace: "Lareira",
|
|
445
|
-
hasGarden: "Jardim",
|
|
446
|
-
hasGasShower: "Chuveiro a g\xE1s",
|
|
447
|
-
hasGenerator: "Gerador",
|
|
448
|
-
hasGourmetBalcony: "Varanda gourmet",
|
|
449
|
-
hasGourmetKitchen: "Cozinha gourmet",
|
|
450
|
-
hasGrill: "Churrasqueira",
|
|
451
|
-
hasGuestParking: "Estacionamento para visitantes",
|
|
452
|
-
hasGym: "Academia",
|
|
453
|
-
hasHeating: "Aquecimento",
|
|
454
|
-
hasHomeOffice: "Home office",
|
|
455
|
-
hasIntercom: "Interfone",
|
|
456
|
-
hasJacuzzi: "Hidromassagem",
|
|
457
|
-
hasKidsPool: "Piscina infantil",
|
|
458
|
-
hasLaundry: "Lavanderia",
|
|
459
|
-
hasMeetingRoom: "Sala de reuni\xE3o",
|
|
460
|
-
hasOffice: "Escrit\xF3rio",
|
|
461
|
-
hasOpenKitchen: "Cozinha americana",
|
|
462
|
-
hasPackageReceival: "Recebimento de encomendas",
|
|
463
|
-
hasPantry: "Despensa",
|
|
464
|
-
hasParkingGarage: "Garagem coberta",
|
|
465
|
-
hasPartySaloon: "Sal\xE3o de festas",
|
|
466
|
-
hasPetArea: "Pet place",
|
|
467
|
-
hasPipedGas: "G\xE1s encanado",
|
|
468
|
-
hasPlayground: "Playground",
|
|
469
|
-
hasPowderRoom: "Lavabo",
|
|
470
|
-
hasPrivatePool: "Piscina privativa",
|
|
471
|
-
hasSauna: "Sauna",
|
|
472
|
-
hasSecurity: "Seguran\xE7a",
|
|
473
|
-
hasServiceArea: "\xC1rea de servi\xE7o",
|
|
474
|
-
hasSolarPanel: "Painel solar",
|
|
475
|
-
hasSpa: "Spa",
|
|
476
|
-
hasSportsCourt: "Quadra de esportes",
|
|
477
|
-
hasStepFreeEntrance: "Entrada sem degrau",
|
|
478
|
-
hasStorage: "Dep\xF3sito",
|
|
479
|
-
hasSwimmingPool: "Piscina",
|
|
480
|
-
hasTennisCourt: "Quadra de t\xEAnis",
|
|
481
|
-
hasValetParking: "Valet",
|
|
482
|
-
homeOffice: "Home office",
|
|
483
|
-
isPetFriendly: "Pet friendly",
|
|
484
|
-
isFurnished: "Mobiliado",
|
|
485
|
-
isPartiallyFurnished: "Semi-mobiliado",
|
|
486
|
-
petFriendly: "Pet friendly",
|
|
487
|
-
piscinaPrivativa: "Piscina privativa",
|
|
488
|
-
pisoLaminado: "Piso laminado",
|
|
489
|
-
pisoMadeira: "Piso de madeira",
|
|
490
|
-
pisoPorcelanato: "Piso porcelanato",
|
|
491
|
-
quadraEsportes: "Quadra de esportes",
|
|
492
|
-
rooftop: "Rooftop",
|
|
493
|
-
suite: "Su\xEDte",
|
|
494
|
-
triplex: "Triplex",
|
|
495
|
-
duplex: "Duplex",
|
|
496
|
-
cobertura: "Cobertura",
|
|
497
|
-
forroGesso: "Forro de gesso",
|
|
498
|
-
gerador: "Gerador",
|
|
499
|
-
armariosCozinha: "Arm\xE1rios na cozinha",
|
|
500
|
-
armariosQuarto: "Arm\xE1rios nos quartos",
|
|
501
|
-
cftv: "CFTV"
|
|
502
|
-
};
|
|
503
|
-
function lookupLabel(id, options) {
|
|
504
|
-
const fromDictionary = options?.find((option) => option.id === id)?.label;
|
|
505
|
-
if (fromDictionary?.trim()) return fromDictionary.trim();
|
|
506
|
-
return AMENITY_FALLBACK_LABELS[id];
|
|
507
|
-
}
|
|
508
|
-
function labelAmenities(ids, dictionary) {
|
|
509
|
-
if (!ids?.length) return [];
|
|
510
|
-
const labels = [];
|
|
511
|
-
const seen = /* @__PURE__ */ new Set();
|
|
512
|
-
for (const id of ids) {
|
|
513
|
-
if (!id) continue;
|
|
514
|
-
const label = lookupLabel(id, dictionary);
|
|
515
|
-
if (!label || seen.has(label)) continue;
|
|
516
|
-
seen.add(label);
|
|
517
|
-
labels.push(label);
|
|
518
|
-
}
|
|
519
|
-
return labels.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
520
|
-
}
|
|
521
|
-
function presentIds(ids) {
|
|
522
|
-
return (ids ?? []).filter((id) => Boolean(id));
|
|
523
|
-
}
|
|
524
|
-
function buildingIdsFromMergedAmenities(listing, unitIds) {
|
|
525
|
-
if (!listing.amenities || listing.propertyFeatures == null) return [];
|
|
526
|
-
const unitCounts = /* @__PURE__ */ new Map();
|
|
527
|
-
for (const id of unitIds) {
|
|
528
|
-
unitCounts.set(id, (unitCounts.get(id) ?? 0) + 1);
|
|
529
|
-
}
|
|
530
|
-
return listing.amenities.filter((id) => {
|
|
531
|
-
if (!id) return false;
|
|
532
|
-
const count = unitCounts.get(id);
|
|
533
|
-
if (count === void 0 || count === 0) return true;
|
|
534
|
-
unitCounts.set(id, count - 1);
|
|
535
|
-
return false;
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
function unitAmenityIds(listing) {
|
|
539
|
-
if (listing.propertyFeatures != null) {
|
|
540
|
-
return presentIds(listing.propertyFeatures);
|
|
541
|
-
}
|
|
542
|
-
const building = new Set(
|
|
543
|
-
listing.building?.amenities ?? listing.buildingAmenities ?? []
|
|
71
|
+
async function getSearchUi(options) {
|
|
72
|
+
const { baseUrl, fetch: fetchImpl, next } = options;
|
|
73
|
+
const siteId = await coerceSiteId(options.siteId);
|
|
74
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
75
|
+
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search-ui`;
|
|
76
|
+
return callJson(
|
|
77
|
+
url,
|
|
78
|
+
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
79
|
+
fetchImpl ?? fetch
|
|
544
80
|
);
|
|
545
|
-
return (listing.amenities ?? []).filter((id) => id && !building.has(id));
|
|
546
81
|
}
|
|
547
|
-
function
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
labels: unitLabels
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
const buildingLabels = labelAmenities(
|
|
568
|
-
buildingAmenityIds(listing),
|
|
569
|
-
dictionary?.buildingAmenities
|
|
82
|
+
async function queryListings(options) {
|
|
83
|
+
const { params, baseUrl, fetch: fetchImpl, next } = options;
|
|
84
|
+
const siteId = await coerceSiteId(options.siteId);
|
|
85
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
86
|
+
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search/listings`;
|
|
87
|
+
return callJson(
|
|
88
|
+
url,
|
|
89
|
+
{
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: {
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
"Content-Type": "application/json"
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify(params ?? {}),
|
|
96
|
+
next
|
|
97
|
+
},
|
|
98
|
+
fetchImpl ?? fetch
|
|
570
99
|
);
|
|
571
|
-
if (buildingLabels.length > 0) {
|
|
572
|
-
groups.push({
|
|
573
|
-
key: "building",
|
|
574
|
-
title: LISTING_AMENITY_TITLES.building,
|
|
575
|
-
labels: buildingLabels
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
return groups;
|
|
579
100
|
}
|
|
580
101
|
|
|
581
102
|
// ../search-url/types.ts
|
|
@@ -587,6 +108,7 @@ var DEFAULT_MAX_PRICE = 1e9;
|
|
|
587
108
|
var DEFAULT_MIN_AREA = 0;
|
|
588
109
|
var DEFAULT_MAX_AREA = 1e5;
|
|
589
110
|
var SORT_URL_TOKENS = [
|
|
111
|
+
"recentes",
|
|
590
112
|
"preco-asc",
|
|
591
113
|
"preco-desc",
|
|
592
114
|
"area-asc",
|
|
@@ -1023,6 +545,17 @@ function pathFiltersToQueryFilters(pathFilters) {
|
|
|
1023
545
|
return result;
|
|
1024
546
|
}
|
|
1025
547
|
|
|
548
|
+
// src/presentation.ts
|
|
549
|
+
function parseGroupedInteger(value) {
|
|
550
|
+
if (typeof value === "number") {
|
|
551
|
+
return Number.isFinite(value) ? Math.trunc(value) : void 0;
|
|
552
|
+
}
|
|
553
|
+
const digits = String(value ?? "").replace(/\D/g, "");
|
|
554
|
+
if (!digits) return void 0;
|
|
555
|
+
const amount = Number.parseInt(digits, 10);
|
|
556
|
+
return Number.isFinite(amount) ? amount : void 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
1026
559
|
// src/search-engine.ts
|
|
1027
560
|
var PATH_FILTER_IDS = {
|
|
1028
561
|
listing_type: "listingType",
|
|
@@ -1044,6 +577,11 @@ function toFiniteNumber(value) {
|
|
|
1044
577
|
function pathnameOnly(pathname) {
|
|
1045
578
|
return String(pathname || "").split(/[?#]/)[0] || "/";
|
|
1046
579
|
}
|
|
580
|
+
function isListingDetailPath(pathname) {
|
|
581
|
+
const parts = pathnameOnly(pathname).split("/").filter(Boolean);
|
|
582
|
+
const last = parts[parts.length - 1] || "";
|
|
583
|
+
return last.toLowerCase().startsWith("id-");
|
|
584
|
+
}
|
|
1047
585
|
function readPublicSearch(pathname, search, dictionary) {
|
|
1048
586
|
const pathFilters = parseSearchPublicPath2(pathnameOnly(pathname), dictionary) || {};
|
|
1049
587
|
const applied = parseAppliedSearchQuery2(search || "");
|
|
@@ -1176,6 +714,8 @@ function currentSearchHref(pathname, search) {
|
|
|
1176
714
|
return qs ? `${path}?${qs}` : path;
|
|
1177
715
|
}
|
|
1178
716
|
function canonicalizeSearchHref(pathname, search, dictionary) {
|
|
717
|
+
if (pathname.includes("/api/v0-preview/")) return null;
|
|
718
|
+
if (isListingDetailPath(pathname)) return null;
|
|
1179
719
|
const { pathFilters, applied } = readPublicSearch(
|
|
1180
720
|
pathname,
|
|
1181
721
|
search,
|
|
@@ -1196,294 +736,93 @@ function clearStagedPathFilters(current, keepFilterIds = []) {
|
|
|
1196
736
|
return next;
|
|
1197
737
|
}
|
|
1198
738
|
|
|
1199
|
-
// src/
|
|
1200
|
-
function
|
|
1201
|
-
|
|
1202
|
-
if (
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
739
|
+
// src/react/public-search-snapshot.ts
|
|
740
|
+
function hrefParts(href) {
|
|
741
|
+
const q = href.indexOf("?");
|
|
742
|
+
if (q < 0) return { pathname: href, search: "" };
|
|
743
|
+
return { pathname: href.slice(0, q), search: href.slice(q + 1) };
|
|
744
|
+
}
|
|
745
|
+
function searchHrefKey(pathname, search) {
|
|
746
|
+
const qs = search.replace(/^\?/, "");
|
|
747
|
+
return qs ? `${pathname}?${qs}` : pathname;
|
|
1207
748
|
}
|
|
1208
|
-
function
|
|
1209
|
-
|
|
1210
|
-
|
|
749
|
+
function searchKeysRepresentSameQuery(a, b, dictionary) {
|
|
750
|
+
if (a == null) return false;
|
|
751
|
+
if (a === b) return true;
|
|
752
|
+
const left = hrefParts(a);
|
|
753
|
+
const right = hrefParts(b);
|
|
754
|
+
const leftCanon = canonicalizeSearchHref(left.pathname, left.search, dictionary) ?? searchHrefKey(left.pathname, left.search);
|
|
755
|
+
const rightCanon = canonicalizeSearchHref(right.pathname, right.search, dictionary) ?? searchHrefKey(right.pathname, right.search);
|
|
756
|
+
return leftCanon === rightCanon;
|
|
1211
757
|
}
|
|
1212
|
-
function
|
|
1213
|
-
|
|
1214
|
-
return value === 0 ? "T\xE9rreo" : String(value);
|
|
1215
|
-
}
|
|
1216
|
-
if (typeof value !== "string") return null;
|
|
1217
|
-
const trimmed = value.trim();
|
|
1218
|
-
if (!trimmed) return null;
|
|
1219
|
-
const parsed = Number(trimmed);
|
|
1220
|
-
if (Number.isFinite(parsed) && trimmed === String(parsed)) {
|
|
1221
|
-
return parsed === 0 ? "T\xE9rreo" : trimmed;
|
|
1222
|
-
}
|
|
1223
|
-
return trimmed;
|
|
758
|
+
function hasTrustedSearchSnapshot(initial) {
|
|
759
|
+
return Boolean(initial?.schema || initial?.listings?.length);
|
|
1224
760
|
}
|
|
1225
|
-
function
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
key: "price",
|
|
1229
|
-
label: "Pre\xE7o",
|
|
1230
|
-
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(listing.price)
|
|
1231
|
-
}
|
|
1232
|
-
];
|
|
1233
|
-
const condoFee = positiveCount(listing.property?.condoFee);
|
|
1234
|
-
if (condoFee != null) {
|
|
1235
|
-
values.push({
|
|
1236
|
-
key: "condoFee",
|
|
1237
|
-
label: "Condom\xEDnio",
|
|
1238
|
-
text: formatListingPrice(condoFee)
|
|
1239
|
-
});
|
|
1240
|
-
}
|
|
1241
|
-
const propertyTax = positiveCount(listing.property?.propertyTax);
|
|
1242
|
-
if (propertyTax != null) {
|
|
1243
|
-
values.push({
|
|
1244
|
-
key: "propertyTax",
|
|
1245
|
-
label: "IPTU",
|
|
1246
|
-
text: formatListingPrice(propertyTax)
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
return values;
|
|
761
|
+
function resolveSeedTotal(initial) {
|
|
762
|
+
if (typeof initial?.total === "number") return initial.total;
|
|
763
|
+
return initial?.listings?.length ?? 0;
|
|
1250
764
|
}
|
|
1251
|
-
function
|
|
1252
|
-
|
|
1253
|
-
const facts = [];
|
|
1254
|
-
const area = formatAreaM2(
|
|
1255
|
-
positiveCount(property.usableArea) ?? positiveCount(property.totalArea)
|
|
1256
|
-
);
|
|
1257
|
-
if (area) facts.push({ key: "area", label: "\xC1rea", text: area });
|
|
1258
|
-
const bedrooms = positiveCount(property.bedrooms);
|
|
1259
|
-
if (bedrooms != null) {
|
|
1260
|
-
facts.push({
|
|
1261
|
-
key: "bedrooms",
|
|
1262
|
-
label: "Dormit\xF3rios",
|
|
1263
|
-
text: String(bedrooms)
|
|
1264
|
-
});
|
|
1265
|
-
}
|
|
1266
|
-
const suites = positiveCount(property.suites);
|
|
1267
|
-
if (suites != null) {
|
|
1268
|
-
facts.push({ key: "suites", label: "Su\xEDtes", text: String(suites) });
|
|
1269
|
-
}
|
|
1270
|
-
const parking = positiveCount(property.parkingSpaces);
|
|
1271
|
-
if (parking != null) {
|
|
1272
|
-
facts.push({ key: "parkingSpaces", label: "Vagas", text: String(parking) });
|
|
1273
|
-
}
|
|
1274
|
-
const rooms = positiveCount(property.rooms);
|
|
1275
|
-
if (rooms != null) {
|
|
1276
|
-
facts.push({ key: "rooms", label: "Salas", text: String(rooms) });
|
|
1277
|
-
}
|
|
1278
|
-
const floorText = formatFloorFact(property.floor);
|
|
1279
|
-
if (floorText) {
|
|
1280
|
-
facts.push({ key: "floor", label: "Andar", text: floorText });
|
|
1281
|
-
}
|
|
1282
|
-
return facts;
|
|
765
|
+
function preferFetchedLocationNames(previous, fetched) {
|
|
766
|
+
return fetched ?? previous;
|
|
1283
767
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
function visibleText(value) {
|
|
1287
|
-
if (typeof value !== "string") return null;
|
|
1288
|
-
const trimmed = value.trim();
|
|
1289
|
-
if (!trimmed || trimmed === "undefined" || trimmed === "null") return null;
|
|
1290
|
-
return trimmed;
|
|
1291
|
-
}
|
|
1292
|
-
function visibleRows(rows) {
|
|
1293
|
-
return rows.filter((row) => {
|
|
1294
|
-
const label = visibleText(row.label);
|
|
1295
|
-
const text = visibleText(row.text);
|
|
1296
|
-
return label != null && text != null;
|
|
1297
|
-
});
|
|
768
|
+
function shouldClearPaintedSearchOnSchemaFailure(keepSnapshot) {
|
|
769
|
+
return !keepSnapshot;
|
|
1298
770
|
}
|
|
1299
|
-
function
|
|
1300
|
-
return
|
|
1301
|
-
facts: visibleRows(listingFacts(listing)),
|
|
1302
|
-
values: visibleRows(listingValues(listing)),
|
|
1303
|
-
amenityGroups: listingAmenityGroups(listing, dictionary).map((group) => ({
|
|
1304
|
-
...group,
|
|
1305
|
-
labels: group.labels.map((label) => visibleText(label)).filter((label) => label != null)
|
|
1306
|
-
})).filter((group) => group.labels.length > 0)
|
|
1307
|
-
};
|
|
771
|
+
function shouldAdvancePaintedSearchKeyOnCanonicalize() {
|
|
772
|
+
return false;
|
|
1308
773
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
dictionary,
|
|
1315
|
-
className,
|
|
1316
|
-
classNames,
|
|
1317
|
-
style
|
|
1318
|
-
}) {
|
|
1319
|
-
const model = listingDetailFieldsModel(listing, dictionary ?? void 0);
|
|
1320
|
-
if (model.facts.length === 0 && model.values.length === 0 && model.amenityGroups.length === 0) {
|
|
1321
|
-
return null;
|
|
1322
|
-
}
|
|
1323
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1324
|
-
"div",
|
|
1325
|
-
{
|
|
1326
|
-
"data-slot": "listing-detail-fields",
|
|
1327
|
-
className: cn(className, classNames?.root),
|
|
1328
|
-
style,
|
|
1329
|
-
children: [
|
|
1330
|
-
model.facts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { "data-slot": "listing-facts", className: classNames?.facts, children: model.facts.map((fact) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1331
|
-
"li",
|
|
1332
|
-
{
|
|
1333
|
-
"data-slot": "listing-fact",
|
|
1334
|
-
"data-key": fact.key,
|
|
1335
|
-
className: classNames?.fact,
|
|
1336
|
-
children: [
|
|
1337
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-slot": "listing-fact-label", children: fact.label }),
|
|
1338
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "data-slot": "listing-fact-text", children: fact.text })
|
|
1339
|
-
]
|
|
1340
|
-
},
|
|
1341
|
-
fact.key
|
|
1342
|
-
)) }) : null,
|
|
1343
|
-
model.values.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dl", { "data-slot": "listing-values", className: classNames?.values, children: model.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1344
|
-
"div",
|
|
1345
|
-
{
|
|
1346
|
-
"data-slot": "listing-value",
|
|
1347
|
-
"data-key": value.key,
|
|
1348
|
-
className: classNames?.value,
|
|
1349
|
-
children: [
|
|
1350
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dt", { "data-slot": "listing-value-label", children: value.label }),
|
|
1351
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("dd", { "data-slot": "listing-value-text", children: value.text })
|
|
1352
|
-
]
|
|
1353
|
-
},
|
|
1354
|
-
value.key
|
|
1355
|
-
)) }) : null,
|
|
1356
|
-
model.amenityGroups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
1357
|
-
"section",
|
|
1358
|
-
{
|
|
1359
|
-
"data-slot": "listing-amenities",
|
|
1360
|
-
"data-key": group.key,
|
|
1361
|
-
className: classNames?.amenityGroup,
|
|
1362
|
-
children: [
|
|
1363
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1364
|
-
"h2",
|
|
1365
|
-
{
|
|
1366
|
-
"data-slot": "listing-amenities-title",
|
|
1367
|
-
className: classNames?.amenityTitle,
|
|
1368
|
-
children: group.title
|
|
1369
|
-
}
|
|
1370
|
-
),
|
|
1371
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1372
|
-
"ul",
|
|
1373
|
-
{
|
|
1374
|
-
"data-slot": "listing-amenities-list",
|
|
1375
|
-
className: classNames?.amenityList,
|
|
1376
|
-
children: group.labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1377
|
-
"li",
|
|
1378
|
-
{
|
|
1379
|
-
"data-slot": "listing-amenity-label",
|
|
1380
|
-
className: classNames?.amenityLabel,
|
|
1381
|
-
children: label
|
|
1382
|
-
},
|
|
1383
|
-
label
|
|
1384
|
-
))
|
|
1385
|
-
}
|
|
1386
|
-
)
|
|
1387
|
-
]
|
|
1388
|
-
},
|
|
1389
|
-
group.key
|
|
1390
|
-
))
|
|
1391
|
-
]
|
|
1392
|
-
}
|
|
774
|
+
function shouldSetLoadingOnSearchKeyChange(options) {
|
|
775
|
+
return !searchKeysRepresentSameQuery(
|
|
776
|
+
options.paintedSearchKey,
|
|
777
|
+
options.searchKey,
|
|
778
|
+
options.dictionary
|
|
1393
779
|
);
|
|
1394
780
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
1402
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SearchChromeStyles, {}),
|
|
1403
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton", className, children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-skeleton-card", children: [
|
|
1404
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
|
|
1405
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-slot": "search-skeleton-body", children: [
|
|
1406
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
|
|
1407
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
|
|
1408
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
|
|
1409
|
-
] })
|
|
1410
|
-
] }, i)) })
|
|
1411
|
-
] });
|
|
781
|
+
function shouldPreservePaintedListingsOnRefetchFailure(options) {
|
|
782
|
+
return searchKeysRepresentSameQuery(
|
|
783
|
+
options.paintedSearchKey,
|
|
784
|
+
options.searchKey,
|
|
785
|
+
options.dictionary
|
|
786
|
+
);
|
|
1412
787
|
}
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
var import_react2 = require("react");
|
|
1416
|
-
var import_navigation = require("next/navigation");
|
|
1417
|
-
|
|
1418
|
-
// src/internal/url.ts
|
|
1419
|
-
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
1420
|
-
function normalizeBaseUrl(baseUrl) {
|
|
1421
|
-
const url = baseUrl ?? DEFAULT_BASE_URL;
|
|
1422
|
-
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
788
|
+
function initialQueryDraft(pathname, search, dictionary) {
|
|
789
|
+
return readPublicSearch(pathname, search, dictionary).applied.query || "";
|
|
1423
790
|
}
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
791
|
+
function seedPublicSearchState(initial) {
|
|
792
|
+
return {
|
|
793
|
+
schema: initial?.schema ?? null,
|
|
794
|
+
listings: initial?.listings ?? [],
|
|
795
|
+
page: initial?.page ?? 1,
|
|
796
|
+
total: resolveSeedTotal(initial),
|
|
797
|
+
totalPages: initial?.totalPages ?? 1,
|
|
798
|
+
locationNames: initial?.locationNames ?? null,
|
|
799
|
+
catalogId: initial?.catalogId ?? null,
|
|
800
|
+
loading: !hasTrustedSearchSnapshot(initial)
|
|
801
|
+
};
|
|
1433
802
|
}
|
|
1434
803
|
|
|
1435
|
-
// src/
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
throw new GaragemSdkError(
|
|
1441
|
-
`Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`,
|
|
1442
|
-
{ status: response.status, url }
|
|
1443
|
-
);
|
|
804
|
+
// src/react/staged-filters-mirror.ts
|
|
805
|
+
var StagedFiltersMirror = class {
|
|
806
|
+
current;
|
|
807
|
+
constructor(initial = {}) {
|
|
808
|
+
this.current = initial;
|
|
1444
809
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
this.
|
|
1454
|
-
this.
|
|
810
|
+
get value() {
|
|
811
|
+
return this.current;
|
|
812
|
+
}
|
|
813
|
+
replace(next) {
|
|
814
|
+
this.current = next;
|
|
815
|
+
return this.current;
|
|
816
|
+
}
|
|
817
|
+
stage(filterId, value) {
|
|
818
|
+
this.current = applyPathFilter(this.current, filterId, value);
|
|
819
|
+
return this.current;
|
|
820
|
+
}
|
|
821
|
+
clear(keepFilterIds = []) {
|
|
822
|
+
this.current = clearStagedPathFilters(this.current, keepFilterIds);
|
|
823
|
+
return this.current;
|
|
1455
824
|
}
|
|
1456
825
|
};
|
|
1457
|
-
async function getSearchUi(options) {
|
|
1458
|
-
const { baseUrl, fetch: fetchImpl, next } = options;
|
|
1459
|
-
const siteId = await coerceSiteId(options.siteId);
|
|
1460
|
-
const base = normalizeBaseUrl(baseUrl);
|
|
1461
|
-
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search-ui`;
|
|
1462
|
-
return callJson(
|
|
1463
|
-
url,
|
|
1464
|
-
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
1465
|
-
fetchImpl ?? fetch
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
|
-
async function queryListings(options) {
|
|
1469
|
-
const { params, baseUrl, fetch: fetchImpl, next } = options;
|
|
1470
|
-
const siteId = await coerceSiteId(options.siteId);
|
|
1471
|
-
const base = normalizeBaseUrl(baseUrl);
|
|
1472
|
-
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search/listings`;
|
|
1473
|
-
return callJson(
|
|
1474
|
-
url,
|
|
1475
|
-
{
|
|
1476
|
-
method: "POST",
|
|
1477
|
-
headers: {
|
|
1478
|
-
Accept: "application/json",
|
|
1479
|
-
"Content-Type": "application/json"
|
|
1480
|
-
},
|
|
1481
|
-
body: JSON.stringify(params ?? {}),
|
|
1482
|
-
next
|
|
1483
|
-
},
|
|
1484
|
-
fetchImpl ?? fetch
|
|
1485
|
-
);
|
|
1486
|
-
}
|
|
1487
826
|
|
|
1488
827
|
// src/react/use-public-search.ts
|
|
1489
828
|
async function resolveSiteIdInput(siteId) {
|
|
@@ -1494,55 +833,73 @@ function currentHref(pathname, search) {
|
|
|
1494
833
|
return search ? `${pathname}?${search}` : pathname;
|
|
1495
834
|
}
|
|
1496
835
|
function usePublicSearch(options) {
|
|
1497
|
-
const { siteId, baseUrl } = options;
|
|
836
|
+
const { siteId, baseUrl, initial, search: searchFromServer = "" } = options;
|
|
1498
837
|
const router = (0, import_navigation.useRouter)();
|
|
1499
838
|
const pathname = (0, import_navigation.usePathname)() || "/imoveis";
|
|
1500
|
-
const
|
|
1501
|
-
const
|
|
1502
|
-
const
|
|
839
|
+
const search = searchFromServer;
|
|
840
|
+
const searchKey = search ? `${pathname}?${search}` : pathname;
|
|
841
|
+
const [seed] = (0, import_react.useState)(() => seedPublicSearchState(initial));
|
|
842
|
+
const keepSnapshotRef = (0, import_react.useRef)(hasTrustedSearchSnapshot(initial));
|
|
843
|
+
const lastSearchKeyRef = (0, import_react.useRef)(keepSnapshotRef.current ? searchKey : null);
|
|
844
|
+
const siteIdRef = (0, import_react.useRef)(siteId);
|
|
1503
845
|
siteIdRef.current = siteId;
|
|
1504
846
|
const siteIdToken = typeof siteId === "string" ? siteId : null;
|
|
1505
|
-
const [catalogId, setCatalogId] = (0,
|
|
1506
|
-
const [schema, setSchema] = (0,
|
|
1507
|
-
const [listings, setListings] = (0,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
const [
|
|
1511
|
-
const [
|
|
1512
|
-
const [
|
|
1513
|
-
const [
|
|
1514
|
-
const [
|
|
1515
|
-
|
|
847
|
+
const [catalogId, setCatalogId] = (0, import_react.useState)(seed.catalogId);
|
|
848
|
+
const [schema, setSchema] = (0, import_react.useState)(seed.schema);
|
|
849
|
+
const [listings, setListings] = (0, import_react.useState)(
|
|
850
|
+
seed.listings
|
|
851
|
+
);
|
|
852
|
+
const [page, setPage] = (0, import_react.useState)(seed.page);
|
|
853
|
+
const [total, setTotal] = (0, import_react.useState)(seed.total);
|
|
854
|
+
const [totalPages, setTotalPages] = (0, import_react.useState)(seed.totalPages);
|
|
855
|
+
const [loading, setLoading] = (0, import_react.useState)(seed.loading);
|
|
856
|
+
const [qDraft, setQDraft] = (0, import_react.useState)(
|
|
857
|
+
() => initialQueryDraft(pathname, search, initial?.schema?.dictionary)
|
|
1516
858
|
);
|
|
1517
|
-
const
|
|
859
|
+
const stagedMirrorRef = (0, import_react.useRef)(new StagedFiltersMirror());
|
|
860
|
+
const [staged, setStagedState] = (0, import_react.useState)({});
|
|
861
|
+
const [locationNames, setLocationNames] = (0, import_react.useState)(
|
|
862
|
+
seed.locationNames
|
|
863
|
+
);
|
|
864
|
+
const replaceStaged = (0, import_react.useCallback)((next) => {
|
|
865
|
+
stagedMirrorRef.current.replace(next);
|
|
866
|
+
setStagedState(next);
|
|
867
|
+
}, []);
|
|
868
|
+
const parsed = (0, import_react.useMemo)(
|
|
1518
869
|
() => readPublicSearch(pathname, search, schema?.dictionary),
|
|
1519
870
|
[pathname, search, schema?.dictionary]
|
|
1520
871
|
);
|
|
1521
|
-
(0,
|
|
872
|
+
(0, import_react.useEffect)(() => {
|
|
1522
873
|
setQDraft(parsed.applied.query || "");
|
|
1523
874
|
}, [parsed.applied.query]);
|
|
1524
|
-
const resetStagedFromUrl = (0,
|
|
1525
|
-
|
|
1526
|
-
}, [parsed.pathFilters]);
|
|
1527
|
-
(0,
|
|
1528
|
-
|
|
1529
|
-
}, [parsed.pathFilters]);
|
|
1530
|
-
const locationsRef = (0,
|
|
1531
|
-
(0,
|
|
875
|
+
const resetStagedFromUrl = (0, import_react.useCallback)(() => {
|
|
876
|
+
replaceStaged({ ...parsed.pathFilters });
|
|
877
|
+
}, [parsed.pathFilters, replaceStaged]);
|
|
878
|
+
(0, import_react.useEffect)(() => {
|
|
879
|
+
replaceStaged({ ...parsed.pathFilters });
|
|
880
|
+
}, [parsed.pathFilters, replaceStaged]);
|
|
881
|
+
const locationsRef = (0, import_react.useRef)(seed.locationNames);
|
|
882
|
+
(0, import_react.useEffect)(() => {
|
|
1532
883
|
if (!schema) return;
|
|
1533
884
|
const canonical = canonicalizeSearchHref(
|
|
1534
885
|
pathname,
|
|
1535
886
|
search,
|
|
1536
887
|
schema.dictionary
|
|
1537
888
|
);
|
|
1538
|
-
if (canonical)
|
|
889
|
+
if (!canonical) return;
|
|
890
|
+
if (shouldAdvancePaintedSearchKeyOnCanonicalize()) {
|
|
891
|
+
lastSearchKeyRef.current = canonical;
|
|
892
|
+
}
|
|
893
|
+
router.replace(canonical);
|
|
1539
894
|
}, [pathname, search, schema, router]);
|
|
1540
|
-
(0,
|
|
895
|
+
(0, import_react.useEffect)(() => {
|
|
1541
896
|
let active = true;
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
897
|
+
if (!keepSnapshotRef.current) {
|
|
898
|
+
setCatalogId(null);
|
|
899
|
+
setSchema(null);
|
|
900
|
+
setListings([]);
|
|
901
|
+
setLoading(true);
|
|
902
|
+
}
|
|
1546
903
|
resolveSiteIdInput(siteIdRef.current).then((id) => {
|
|
1547
904
|
if (active) setCatalogId(id);
|
|
1548
905
|
}).catch(() => {
|
|
@@ -1552,15 +909,17 @@ function usePublicSearch(options) {
|
|
|
1552
909
|
active = false;
|
|
1553
910
|
};
|
|
1554
911
|
}, [baseUrl, siteIdToken]);
|
|
1555
|
-
(0,
|
|
912
|
+
(0, import_react.useEffect)(() => {
|
|
1556
913
|
if (!catalogId) return;
|
|
1557
914
|
const id = catalogId;
|
|
1558
915
|
let active = true;
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
916
|
+
if (!keepSnapshotRef.current) {
|
|
917
|
+
locationsRef.current = null;
|
|
918
|
+
setLocationNames(null);
|
|
919
|
+
setSchema(null);
|
|
920
|
+
setListings([]);
|
|
921
|
+
setLoading(true);
|
|
922
|
+
}
|
|
1564
923
|
async function loadSchema() {
|
|
1565
924
|
try {
|
|
1566
925
|
const nextSchema = await getSearchUi({ siteId: id, baseUrl });
|
|
@@ -1579,14 +938,22 @@ function usePublicSearch(options) {
|
|
|
1579
938
|
}
|
|
1580
939
|
}
|
|
1581
940
|
if (!active) return;
|
|
1582
|
-
|
|
1583
|
-
|
|
941
|
+
const nextLocations = preferFetchedLocationNames(
|
|
942
|
+
locationsRef.current,
|
|
943
|
+
locations
|
|
944
|
+
);
|
|
945
|
+
locationsRef.current = nextLocations;
|
|
946
|
+
setLocationNames(nextLocations);
|
|
1584
947
|
setSchema(nextSchema);
|
|
948
|
+
keepSnapshotRef.current = false;
|
|
1585
949
|
} catch {
|
|
1586
950
|
if (active) {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
951
|
+
if (shouldClearPaintedSearchOnSchemaFailure(keepSnapshotRef.current)) {
|
|
952
|
+
keepSnapshotRef.current = false;
|
|
953
|
+
locationsRef.current = null;
|
|
954
|
+
setLocationNames(null);
|
|
955
|
+
setSchema(null);
|
|
956
|
+
}
|
|
1590
957
|
setLoading(false);
|
|
1591
958
|
}
|
|
1592
959
|
}
|
|
@@ -1596,13 +963,19 @@ function usePublicSearch(options) {
|
|
|
1596
963
|
active = false;
|
|
1597
964
|
};
|
|
1598
965
|
}, [baseUrl, catalogId]);
|
|
1599
|
-
(0,
|
|
966
|
+
(0, import_react.useEffect)(() => {
|
|
1600
967
|
if (!schema || !catalogId) return;
|
|
1601
968
|
const currentSchema = schema;
|
|
1602
969
|
const id = catalogId;
|
|
1603
970
|
let active = true;
|
|
1604
971
|
async function loadListings() {
|
|
1605
|
-
|
|
972
|
+
if (shouldSetLoadingOnSearchKeyChange({
|
|
973
|
+
paintedSearchKey: lastSearchKeyRef.current,
|
|
974
|
+
searchKey,
|
|
975
|
+
dictionary: currentSchema.dictionary
|
|
976
|
+
})) {
|
|
977
|
+
setLoading(true);
|
|
978
|
+
}
|
|
1606
979
|
try {
|
|
1607
980
|
const { pathFilters, applied } = readPublicSearch(
|
|
1608
981
|
pathname,
|
|
@@ -1624,15 +997,24 @@ function usePublicSearch(options) {
|
|
|
1624
997
|
setPage(response.page || 1);
|
|
1625
998
|
setTotal(response.total || 0);
|
|
1626
999
|
setTotalPages(response.totalPages || 1);
|
|
1000
|
+
lastSearchKeyRef.current = searchKey;
|
|
1001
|
+
keepSnapshotRef.current = false;
|
|
1627
1002
|
} catch {
|
|
1628
|
-
if (active
|
|
1003
|
+
if (active && !shouldPreservePaintedListingsOnRefetchFailure({
|
|
1004
|
+
paintedSearchKey: lastSearchKeyRef.current,
|
|
1005
|
+
searchKey,
|
|
1006
|
+
dictionary: currentSchema.dictionary
|
|
1007
|
+
})) {
|
|
1629
1008
|
setListings([]);
|
|
1630
1009
|
setPage(1);
|
|
1631
1010
|
setTotal(0);
|
|
1632
1011
|
setTotalPages(1);
|
|
1012
|
+
keepSnapshotRef.current = false;
|
|
1633
1013
|
}
|
|
1634
1014
|
} finally {
|
|
1635
|
-
if (active)
|
|
1015
|
+
if (active) {
|
|
1016
|
+
setLoading(false);
|
|
1017
|
+
}
|
|
1636
1018
|
}
|
|
1637
1019
|
}
|
|
1638
1020
|
loadListings();
|
|
@@ -1640,13 +1022,13 @@ function usePublicSearch(options) {
|
|
|
1640
1022
|
active = false;
|
|
1641
1023
|
};
|
|
1642
1024
|
}, [pathname, search, baseUrl, schema, catalogId]);
|
|
1643
|
-
const go = (0,
|
|
1025
|
+
const go = (0, import_react.useCallback)(
|
|
1644
1026
|
(href) => {
|
|
1645
1027
|
if (href && href !== currentHref(pathname, search)) router.push(href);
|
|
1646
1028
|
},
|
|
1647
1029
|
[pathname, search, router]
|
|
1648
1030
|
);
|
|
1649
|
-
const applyFilter = (0,
|
|
1031
|
+
const applyFilter = (0, import_react.useCallback)(
|
|
1650
1032
|
(filterId, value) => {
|
|
1651
1033
|
if (!schema) return;
|
|
1652
1034
|
go(
|
|
@@ -1660,17 +1042,30 @@ function usePublicSearch(options) {
|
|
|
1660
1042
|
},
|
|
1661
1043
|
[go, pathname, search, schema, parsed.pathFilters]
|
|
1662
1044
|
);
|
|
1663
|
-
const
|
|
1664
|
-
|
|
1045
|
+
const setStaged = (0, import_react.useCallback)(
|
|
1046
|
+
(next) => {
|
|
1047
|
+
replaceStaged(next);
|
|
1048
|
+
},
|
|
1049
|
+
[replaceStaged]
|
|
1050
|
+
);
|
|
1051
|
+
const stageFilter = (0, import_react.useCallback)((filterId, value) => {
|
|
1052
|
+
setStagedState(stagedMirrorRef.current.stage(filterId, value));
|
|
1665
1053
|
}, []);
|
|
1666
|
-
const applyStaged = (0,
|
|
1054
|
+
const applyStaged = (0, import_react.useCallback)(() => {
|
|
1667
1055
|
if (!schema) return;
|
|
1668
|
-
go(
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1056
|
+
go(
|
|
1057
|
+
hrefForPathFilters(
|
|
1058
|
+
pathname,
|
|
1059
|
+
search,
|
|
1060
|
+
schema.dictionary,
|
|
1061
|
+
stagedMirrorRef.current.value
|
|
1062
|
+
)
|
|
1063
|
+
);
|
|
1064
|
+
}, [go, pathname, search, schema]);
|
|
1065
|
+
const clearStaged = (0, import_react.useCallback)(() => {
|
|
1066
|
+
setStagedState(stagedMirrorRef.current.clear());
|
|
1672
1067
|
}, []);
|
|
1673
|
-
const submitQuery = (0,
|
|
1068
|
+
const submitQuery = (0, import_react.useCallback)(() => {
|
|
1674
1069
|
if (!schema) return;
|
|
1675
1070
|
go(
|
|
1676
1071
|
hrefForAppliedChange(pathname, search, schema.dictionary, {
|
|
@@ -1679,7 +1074,7 @@ function usePublicSearch(options) {
|
|
|
1679
1074
|
})
|
|
1680
1075
|
);
|
|
1681
1076
|
}, [go, pathname, search, schema, qDraft]);
|
|
1682
|
-
const clearQuery = (0,
|
|
1077
|
+
const clearQuery = (0, import_react.useCallback)(() => {
|
|
1683
1078
|
setQDraft("");
|
|
1684
1079
|
if (!schema) return;
|
|
1685
1080
|
go(
|
|
@@ -1689,7 +1084,7 @@ function usePublicSearch(options) {
|
|
|
1689
1084
|
})
|
|
1690
1085
|
);
|
|
1691
1086
|
}, [go, pathname, search, schema]);
|
|
1692
|
-
const setSort = (0,
|
|
1087
|
+
const setSort = (0, import_react.useCallback)(
|
|
1693
1088
|
(sort) => {
|
|
1694
1089
|
if (!schema) return;
|
|
1695
1090
|
go(
|
|
@@ -1701,7 +1096,7 @@ function usePublicSearch(options) {
|
|
|
1701
1096
|
},
|
|
1702
1097
|
[go, pathname, search, schema]
|
|
1703
1098
|
);
|
|
1704
|
-
const hrefForPage = (0,
|
|
1099
|
+
const hrefForPage = (0, import_react.useCallback)(
|
|
1705
1100
|
(nextPage) => {
|
|
1706
1101
|
if (!schema) return pathname;
|
|
1707
1102
|
return hrefForAppliedChange(pathname, search, schema.dictionary, {
|
|
@@ -1741,10 +1136,6 @@ function usePublicSearch(options) {
|
|
|
1741
1136
|
}
|
|
1742
1137
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1743
1138
|
0 && (module.exports = {
|
|
1744
|
-
ListingCard,
|
|
1745
|
-
ListingDetailFields,
|
|
1746
|
-
ResultsSkeleton,
|
|
1747
|
-
SearchChromeStyles,
|
|
1748
1139
|
usePublicSearch
|
|
1749
1140
|
});
|
|
1750
1141
|
//# sourceMappingURL=react.js.map
|