@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/index.js
CHANGED
|
@@ -21,13 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
AMENITY_FALLBACK_LABELS: () => AMENITY_FALLBACK_LABELS,
|
|
24
|
+
DEFAULT_PHONE_COUNTRY_CODE: () => DEFAULT_PHONE_COUNTRY_CODE,
|
|
24
25
|
FORBIDDEN_SEARCH_QUERY_KEYS: () => FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
25
26
|
GaragemSdkError: () => GaragemSdkError,
|
|
26
27
|
LISTING_AMENITY_TITLES: () => LISTING_AMENITY_TITLES,
|
|
27
28
|
LISTING_DESCRIPTION_CLAMP: () => LISTING_DESCRIPTION_CLAMP,
|
|
28
29
|
LeadSubmitError: () => LeadSubmitError,
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
MAX_NATIONAL_PHONE_DIGITS: () => MAX_NATIONAL_PHONE_DIGITS,
|
|
31
|
+
PHONE_COUNTRIES: () => PHONE_COUNTRIES,
|
|
31
32
|
SEARCH_EMPTY_COPY: () => SEARCH_EMPTY_COPY,
|
|
32
33
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
33
34
|
STUDIO_DEFAULT_VISIT_SCHEDULE: () => STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
@@ -41,18 +42,22 @@ __export(src_exports, {
|
|
|
41
42
|
canonicalizeSearchHref: () => canonicalizeSearchHref,
|
|
42
43
|
clearStagedPathFilters: () => clearStagedPathFilters,
|
|
43
44
|
coerceNpmVersion: () => coerceNpmVersion,
|
|
45
|
+
collapseDuplicatedBrazilianMobileNine: () => collapseDuplicatedBrazilianMobileNine,
|
|
44
46
|
compareSemver: () => compareSemver,
|
|
45
47
|
composeSearchPublicHref: () => composeSearchPublicHref2,
|
|
46
48
|
composeSearchPublicPath: () => composeSearchPublicPath2,
|
|
47
49
|
countFacetChoices: () => countFacetChoices,
|
|
48
50
|
countOptionLabel: () => countOptionLabel,
|
|
49
51
|
createGaragemClient: () => createGaragemClient,
|
|
52
|
+
defaultPhoneCountry: () => defaultPhoneCountry,
|
|
50
53
|
displayPathLocation: () => displayPathLocation,
|
|
51
54
|
expandVisitSchedule: () => expandVisitSchedule,
|
|
52
55
|
expandVisitTimeSlots: () => expandVisitTimeSlots,
|
|
56
|
+
findPhoneCountry: () => findPhoneCountry,
|
|
53
57
|
formatAreaM2: () => formatAreaM2,
|
|
54
58
|
formatGroupedInteger: () => formatGroupedInteger,
|
|
55
59
|
formatListingPrice: () => formatListingPrice,
|
|
60
|
+
formatPhoneNational: () => formatPhoneNational,
|
|
56
61
|
getCmsCollection: () => getCmsCollection,
|
|
57
62
|
getCmsCollections: () => getCmsCollections,
|
|
58
63
|
getCmsEntries: () => getCmsEntries,
|
|
@@ -69,6 +74,7 @@ __export(src_exports, {
|
|
|
69
74
|
hrefWithExplicitPage: () => hrefWithExplicitPage,
|
|
70
75
|
isListingDetailPath: () => isListingDetailPath,
|
|
71
76
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
77
|
+
isValidPhone: () => isValidPhone,
|
|
72
78
|
isVisitSlotAllowed: () => isVisitSlotAllowed,
|
|
73
79
|
labelAmenities: () => labelAmenities,
|
|
74
80
|
listingAmenityGroups: () => listingAmenityGroups,
|
|
@@ -86,22 +92,26 @@ __export(src_exports, {
|
|
|
86
92
|
listingPublicPath: () => listingPublicPath,
|
|
87
93
|
listingValues: () => listingValues,
|
|
88
94
|
mergeAppliedSearchQueryIntoSearch: () => mergeAppliedSearchQueryIntoSearch2,
|
|
95
|
+
nationalPhoneDigits: () => nationalPhoneDigits,
|
|
89
96
|
normalizeVisitDate: () => normalizeVisitDate,
|
|
90
97
|
normalizeVisitTime: () => normalizeVisitTime,
|
|
91
98
|
paginationPages: () => paginationPages,
|
|
92
99
|
parseAppliedSearchQuery: () => parseAppliedSearchQuery2,
|
|
93
100
|
parseGroupedInteger: () => parseGroupedInteger,
|
|
101
|
+
parsePhoneInput: () => parsePhoneInput,
|
|
94
102
|
parseReactSdkNamedImports: () => parseReactSdkNamedImports,
|
|
95
103
|
parseSearchPublicPath: () => parseSearchPublicPath2,
|
|
96
104
|
pathFilterHasOption: () => pathFilterHasOption,
|
|
97
105
|
pathFilterValue: () => pathFilterValue,
|
|
98
106
|
pathFiltersToQueryFilters: () => pathFiltersToQueryFilters,
|
|
99
107
|
pathLocationToFilterInput: () => pathLocationToFilterInput,
|
|
108
|
+
phoneCountrySearchValue: () => phoneCountrySearchValue,
|
|
100
109
|
publicSearchHref: () => publicSearchHref,
|
|
101
110
|
queryListings: () => queryListings,
|
|
102
111
|
rangeDraftFromPath: () => rangeDraftFromPath,
|
|
103
112
|
readPublicSearch: () => readPublicSearch,
|
|
104
113
|
reduceAppliedSearchQuery: () => reduceAppliedSearchQuery2,
|
|
114
|
+
remaskPhoneForCountry: () => remaskPhoneForCountry,
|
|
105
115
|
resolvePublicSiteId: () => resolvePublicSiteId,
|
|
106
116
|
searchChromeModel: () => searchChromeModel,
|
|
107
117
|
searchHrefUsesLegacyFilterQuery: () => searchHrefUsesLegacyFilterQuery,
|
|
@@ -116,6 +126,7 @@ __export(src_exports, {
|
|
|
116
126
|
studioDefaultLeadUi: () => studioDefaultLeadUi,
|
|
117
127
|
studioLayoutInstruction: () => studioLayoutInstruction,
|
|
118
128
|
studioLeadInstruction: () => studioLeadInstruction,
|
|
129
|
+
studioListingCardInstruction: () => studioListingCardInstruction,
|
|
119
130
|
studioListingDetailInstruction: () => studioListingDetailInstruction,
|
|
120
131
|
studioSdkPinInstruction: () => studioSdkPinInstruction,
|
|
121
132
|
studioSearchInstruction: () => studioSearchInstruction,
|
|
@@ -123,8 +134,10 @@ __export(src_exports, {
|
|
|
123
134
|
studioSiteWidthCss: () => studioSiteWidthCss,
|
|
124
135
|
submitContactLead: () => submitContactLead,
|
|
125
136
|
submitVisitLead: () => submitVisitLead,
|
|
137
|
+
toE164: () => toE164,
|
|
126
138
|
toListingCardModel: () => toListingCardModel,
|
|
127
139
|
toolbarFilterIds: () => toolbarFilterIds,
|
|
140
|
+
truncateNationalPhoneDigits: () => truncateNationalPhoneDigits,
|
|
128
141
|
unavailableReactImports: () => unavailableReactImports,
|
|
129
142
|
visibleSearchFilters: () => visibleSearchFilters
|
|
130
143
|
});
|
|
@@ -146,6 +159,7 @@ function listingPublicPath(listing) {
|
|
|
146
159
|
|
|
147
160
|
// src/internal/url.ts
|
|
148
161
|
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
162
|
+
var DEFAULT_RESOLVE_BASE_URL = "https://cdn.fndn.ai/site";
|
|
149
163
|
function normalizeBaseUrl(baseUrl) {
|
|
150
164
|
const url = baseUrl ?? DEFAULT_BASE_URL;
|
|
151
165
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -245,7 +259,7 @@ async function getSite(options) {
|
|
|
245
259
|
"getSite: provide only one of `siteId` or `domain`, not both."
|
|
246
260
|
);
|
|
247
261
|
}
|
|
248
|
-
const base = normalizeBaseUrl(baseUrl);
|
|
262
|
+
const base = normalizeBaseUrl(baseUrl ?? DEFAULT_RESOLVE_BASE_URL);
|
|
249
263
|
const params = new URLSearchParams();
|
|
250
264
|
if (siteId) params.set("siteId", siteId);
|
|
251
265
|
if (domain) params.set("domain", domain);
|
|
@@ -610,6 +624,349 @@ function isVisitSlotAllowed(schedule, visitDate, visitTime, now = /* @__PURE__ *
|
|
|
610
624
|
return slotsForDate(schedule, visitDate, now).includes(time);
|
|
611
625
|
}
|
|
612
626
|
|
|
627
|
+
// src/phone.ts
|
|
628
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
629
|
+
|
|
630
|
+
// src/phone-countries.ts
|
|
631
|
+
var DEFAULT_PHONE_COUNTRY_CODE = "BR";
|
|
632
|
+
var PHONE_COUNTRIES = [
|
|
633
|
+
{ code: "BR", name: "Brasil", dialCode: "55", flag: "\u{1F1E7}\u{1F1F7}" },
|
|
634
|
+
{ code: "US", name: "Estados Unidos", dialCode: "1", flag: "\u{1F1FA}\u{1F1F8}" },
|
|
635
|
+
{ code: "CA", name: "Canad\xE1", dialCode: "1", flag: "\u{1F1E8}\u{1F1E6}" },
|
|
636
|
+
{ code: "MX", name: "M\xE9xico", dialCode: "52", flag: "\u{1F1F2}\u{1F1FD}" },
|
|
637
|
+
{ code: "GT", name: "Guatemala", dialCode: "502", flag: "\u{1F1EC}\u{1F1F9}" },
|
|
638
|
+
{ code: "BZ", name: "Belize", dialCode: "501", flag: "\u{1F1E7}\u{1F1FF}" },
|
|
639
|
+
{ code: "SV", name: "El Salvador", dialCode: "503", flag: "\u{1F1F8}\u{1F1FB}" },
|
|
640
|
+
{ code: "HN", name: "Honduras", dialCode: "504", flag: "\u{1F1ED}\u{1F1F3}" },
|
|
641
|
+
{ code: "NI", name: "Nicar\xE1gua", dialCode: "505", flag: "\u{1F1F3}\u{1F1EE}" },
|
|
642
|
+
{ code: "CR", name: "Costa Rica", dialCode: "506", flag: "\u{1F1E8}\u{1F1F7}" },
|
|
643
|
+
{ code: "PA", name: "Panam\xE1", dialCode: "507", flag: "\u{1F1F5}\u{1F1E6}" },
|
|
644
|
+
{ code: "CU", name: "Cuba", dialCode: "53", flag: "\u{1F1E8}\u{1F1FA}" },
|
|
645
|
+
{ code: "DO", name: "Rep\xFAblica Dominicana", dialCode: "1", flag: "\u{1F1E9}\u{1F1F4}" },
|
|
646
|
+
{ code: "HT", name: "Haiti", dialCode: "509", flag: "\u{1F1ED}\u{1F1F9}" },
|
|
647
|
+
{ code: "AR", name: "Argentina", dialCode: "54", flag: "\u{1F1E6}\u{1F1F7}" },
|
|
648
|
+
{ code: "CL", name: "Chile", dialCode: "56", flag: "\u{1F1E8}\u{1F1F1}" },
|
|
649
|
+
{ code: "CO", name: "Col\xF4mbia", dialCode: "57", flag: "\u{1F1E8}\u{1F1F4}" },
|
|
650
|
+
{ code: "PE", name: "Peru", dialCode: "51", flag: "\u{1F1F5}\u{1F1EA}" },
|
|
651
|
+
{ code: "UY", name: "Uruguai", dialCode: "598", flag: "\u{1F1FA}\u{1F1FE}" },
|
|
652
|
+
{ code: "PY", name: "Paraguai", dialCode: "595", flag: "\u{1F1F5}\u{1F1FE}" },
|
|
653
|
+
{ code: "BO", name: "Bol\xEDvia", dialCode: "591", flag: "\u{1F1E7}\u{1F1F4}" },
|
|
654
|
+
{ code: "EC", name: "Equador", dialCode: "593", flag: "\u{1F1EA}\u{1F1E8}" },
|
|
655
|
+
{ code: "VE", name: "Venezuela", dialCode: "58", flag: "\u{1F1FB}\u{1F1EA}" },
|
|
656
|
+
{ code: "GY", name: "Guiana", dialCode: "592", flag: "\u{1F1EC}\u{1F1FE}" },
|
|
657
|
+
{ code: "SR", name: "Suriname", dialCode: "597", flag: "\u{1F1F8}\u{1F1F7}" },
|
|
658
|
+
{ code: "PT", name: "Portugal", dialCode: "351", flag: "\u{1F1F5}\u{1F1F9}" },
|
|
659
|
+
{ code: "ES", name: "Espanha", dialCode: "34", flag: "\u{1F1EA}\u{1F1F8}" },
|
|
660
|
+
{ code: "FR", name: "Fran\xE7a", dialCode: "33", flag: "\u{1F1EB}\u{1F1F7}" },
|
|
661
|
+
{ code: "UK", name: "Reino Unido", dialCode: "44", flag: "\u{1F1EC}\u{1F1E7}" },
|
|
662
|
+
{ code: "DE", name: "Alemanha", dialCode: "49", flag: "\u{1F1E9}\u{1F1EA}" },
|
|
663
|
+
{ code: "IT", name: "It\xE1lia", dialCode: "39", flag: "\u{1F1EE}\u{1F1F9}" },
|
|
664
|
+
{ code: "NL", name: "Holanda", dialCode: "31", flag: "\u{1F1F3}\u{1F1F1}" },
|
|
665
|
+
{ code: "BE", name: "B\xE9lgica", dialCode: "32", flag: "\u{1F1E7}\u{1F1EA}" },
|
|
666
|
+
{ code: "CH", name: "Su\xED\xE7a", dialCode: "41", flag: "\u{1F1E8}\u{1F1ED}" },
|
|
667
|
+
{ code: "AT", name: "\xC1ustria", dialCode: "43", flag: "\u{1F1E6}\u{1F1F9}" },
|
|
668
|
+
{ code: "SE", name: "Su\xE9cia", dialCode: "46", flag: "\u{1F1F8}\u{1F1EA}" },
|
|
669
|
+
{ code: "NO", name: "Noruega", dialCode: "47", flag: "\u{1F1F3}\u{1F1F4}" },
|
|
670
|
+
{ code: "DK", name: "Dinamarca", dialCode: "45", flag: "\u{1F1E9}\u{1F1F0}" },
|
|
671
|
+
{ code: "FI", name: "Finl\xE2ndia", dialCode: "358", flag: "\u{1F1EB}\u{1F1EE}" },
|
|
672
|
+
{ code: "IE", name: "Irlanda", dialCode: "353", flag: "\u{1F1EE}\u{1F1EA}" },
|
|
673
|
+
{ code: "AU", name: "Austr\xE1lia", dialCode: "61", flag: "\u{1F1E6}\u{1F1FA}" },
|
|
674
|
+
{ code: "NZ", name: "Nova Zel\xE2ndia", dialCode: "64", flag: "\u{1F1F3}\u{1F1FF}" },
|
|
675
|
+
{ code: "JP", name: "Jap\xE3o", dialCode: "81", flag: "\u{1F1EF}\u{1F1F5}" },
|
|
676
|
+
{ code: "KR", name: "Coreia do Sul", dialCode: "82", flag: "\u{1F1F0}\u{1F1F7}" },
|
|
677
|
+
{ code: "CN", name: "China", dialCode: "86", flag: "\u{1F1E8}\u{1F1F3}" },
|
|
678
|
+
{ code: "IN", name: "\xCDndia", dialCode: "91", flag: "\u{1F1EE}\u{1F1F3}" },
|
|
679
|
+
{ code: "RU", name: "R\xFAssia", dialCode: "7", flag: "\u{1F1F7}\u{1F1FA}" },
|
|
680
|
+
{ code: "UA", name: "Ucr\xE2nia", dialCode: "380", flag: "\u{1F1FA}\u{1F1E6}" },
|
|
681
|
+
{ code: "AE", name: "Emirados \xC1rabes", dialCode: "971", flag: "\u{1F1E6}\u{1F1EA}" },
|
|
682
|
+
{ code: "SA", name: "Ar\xE1bia Saudita", dialCode: "966", flag: "\u{1F1F8}\u{1F1E6}" },
|
|
683
|
+
{ code: "QA", name: "Catar", dialCode: "974", flag: "\u{1F1F6}\u{1F1E6}" },
|
|
684
|
+
{ code: "KW", name: "Kuwait", dialCode: "965", flag: "\u{1F1F0}\u{1F1FC}" },
|
|
685
|
+
{ code: "BH", name: "Bahrein", dialCode: "973", flag: "\u{1F1E7}\u{1F1ED}" },
|
|
686
|
+
{ code: "OM", name: "Om\xE3", dialCode: "968", flag: "\u{1F1F4}\u{1F1F2}" },
|
|
687
|
+
{ code: "JO", name: "Jord\xE2nia", dialCode: "962", flag: "\u{1F1EF}\u{1F1F4}" },
|
|
688
|
+
{ code: "LB", name: "L\xEDbano", dialCode: "961", flag: "\u{1F1F1}\u{1F1E7}" },
|
|
689
|
+
{ code: "IL", name: "Israel", dialCode: "972", flag: "\u{1F1EE}\u{1F1F1}" },
|
|
690
|
+
{ code: "TR", name: "Turquia", dialCode: "90", flag: "\u{1F1F9}\u{1F1F7}" },
|
|
691
|
+
{ code: "EG", name: "Egito", dialCode: "20", flag: "\u{1F1EA}\u{1F1EC}" },
|
|
692
|
+
{ code: "ZA", name: "\xC1frica do Sul", dialCode: "27", flag: "\u{1F1FF}\u{1F1E6}" },
|
|
693
|
+
{ code: "AO", name: "Angola", dialCode: "244", flag: "\u{1F1E6}\u{1F1F4}" },
|
|
694
|
+
{ code: "MZ", name: "Mo\xE7ambique", dialCode: "258", flag: "\u{1F1F2}\u{1F1FF}" },
|
|
695
|
+
{ code: "CV", name: "Cabo Verde", dialCode: "238", flag: "\u{1F1E8}\u{1F1FB}" }
|
|
696
|
+
];
|
|
697
|
+
function phoneCountrySearchValue(country) {
|
|
698
|
+
return `${country.name} ${country.code} ${country.dialCode} +${country.dialCode}`;
|
|
699
|
+
}
|
|
700
|
+
function findPhoneCountry(code) {
|
|
701
|
+
if (!code) return void 0;
|
|
702
|
+
const normalized = code.trim().toUpperCase();
|
|
703
|
+
return PHONE_COUNTRIES.find((country) => country.code === normalized);
|
|
704
|
+
}
|
|
705
|
+
function defaultPhoneCountry() {
|
|
706
|
+
return findPhoneCountry(DEFAULT_PHONE_COUNTRY_CODE) ?? PHONE_COUNTRIES[0];
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/phone.ts
|
|
710
|
+
var MAX_NATIONAL_PHONE_DIGITS = 15;
|
|
711
|
+
var VALID_BR_DDDS = /* @__PURE__ */ new Set([
|
|
712
|
+
"11",
|
|
713
|
+
"12",
|
|
714
|
+
"13",
|
|
715
|
+
"14",
|
|
716
|
+
"15",
|
|
717
|
+
"16",
|
|
718
|
+
"17",
|
|
719
|
+
"18",
|
|
720
|
+
"19",
|
|
721
|
+
"21",
|
|
722
|
+
"22",
|
|
723
|
+
"24",
|
|
724
|
+
"27",
|
|
725
|
+
"28",
|
|
726
|
+
"31",
|
|
727
|
+
"32",
|
|
728
|
+
"33",
|
|
729
|
+
"34",
|
|
730
|
+
"35",
|
|
731
|
+
"37",
|
|
732
|
+
"38",
|
|
733
|
+
"41",
|
|
734
|
+
"42",
|
|
735
|
+
"43",
|
|
736
|
+
"44",
|
|
737
|
+
"45",
|
|
738
|
+
"46",
|
|
739
|
+
"47",
|
|
740
|
+
"48",
|
|
741
|
+
"49",
|
|
742
|
+
"51",
|
|
743
|
+
"53",
|
|
744
|
+
"54",
|
|
745
|
+
"55",
|
|
746
|
+
"61",
|
|
747
|
+
"62",
|
|
748
|
+
"63",
|
|
749
|
+
"64",
|
|
750
|
+
"65",
|
|
751
|
+
"66",
|
|
752
|
+
"67",
|
|
753
|
+
"68",
|
|
754
|
+
"69",
|
|
755
|
+
"71",
|
|
756
|
+
"73",
|
|
757
|
+
"74",
|
|
758
|
+
"75",
|
|
759
|
+
"77",
|
|
760
|
+
"79",
|
|
761
|
+
"81",
|
|
762
|
+
"82",
|
|
763
|
+
"83",
|
|
764
|
+
"84",
|
|
765
|
+
"85",
|
|
766
|
+
"86",
|
|
767
|
+
"87",
|
|
768
|
+
"88",
|
|
769
|
+
"89",
|
|
770
|
+
"91",
|
|
771
|
+
"92",
|
|
772
|
+
"93",
|
|
773
|
+
"94",
|
|
774
|
+
"95",
|
|
775
|
+
"96",
|
|
776
|
+
"97",
|
|
777
|
+
"98",
|
|
778
|
+
"99"
|
|
779
|
+
]);
|
|
780
|
+
var PHONE_INPUT_COUNTRY_CODES = new Set(
|
|
781
|
+
PHONE_COUNTRIES.map((country) => country.code)
|
|
782
|
+
);
|
|
783
|
+
var SORTED_PHONE_INPUT_DIAL_CODES = [
|
|
784
|
+
...new Set(PHONE_COUNTRIES.map((country) => country.dialCode))
|
|
785
|
+
].sort((a, b) => b.length - a.length);
|
|
786
|
+
function toLibCountryCode(code) {
|
|
787
|
+
if (code === "UK") return "GB";
|
|
788
|
+
return code;
|
|
789
|
+
}
|
|
790
|
+
function fromLibCountryCode(code) {
|
|
791
|
+
if (code === "GB") return "UK";
|
|
792
|
+
return code;
|
|
793
|
+
}
|
|
794
|
+
function nationalPhoneDigits(value) {
|
|
795
|
+
return String(value ?? "").replace(/\D/g, "");
|
|
796
|
+
}
|
|
797
|
+
function truncateNationalPhoneDigits(digits, max = MAX_NATIONAL_PHONE_DIGITS) {
|
|
798
|
+
return digits.slice(0, max);
|
|
799
|
+
}
|
|
800
|
+
function collapseDuplicatedBrazilianMobileNine(digits) {
|
|
801
|
+
if (digits.length === 14 && digits.startsWith("55")) {
|
|
802
|
+
const national = collapseDuplicatedBrazilianMobileNine(digits.slice(2));
|
|
803
|
+
return national === digits.slice(2) ? digits : `55${national}`;
|
|
804
|
+
}
|
|
805
|
+
if (digits.length !== 12) return digits;
|
|
806
|
+
const ddd = digits.slice(0, 2);
|
|
807
|
+
if (!VALID_BR_DDDS.has(ddd)) return digits;
|
|
808
|
+
if (digits.charAt(2) !== "9") return digits;
|
|
809
|
+
const rest = digits.slice(3);
|
|
810
|
+
if (rest.length !== 9 || rest.charAt(0) !== "9") return digits;
|
|
811
|
+
if (ddd === "55") {
|
|
812
|
+
const subscriberFirst = digits.charAt(4);
|
|
813
|
+
if (subscriberFirst >= "0" && subscriberFirst <= "5") {
|
|
814
|
+
return digits;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return `${ddd}${rest}`;
|
|
818
|
+
}
|
|
819
|
+
var BR_DIAL_CODE = "55";
|
|
820
|
+
function stripAccidentalDialCodePrefix(numbers, country) {
|
|
821
|
+
const dial = country.dialCode;
|
|
822
|
+
if (!numbers.startsWith(dial) || numbers.length <= dial.length) {
|
|
823
|
+
return numbers;
|
|
824
|
+
}
|
|
825
|
+
const withoutDial = numbers.slice(dial.length);
|
|
826
|
+
if (!withoutDial) return numbers;
|
|
827
|
+
try {
|
|
828
|
+
const parsed = (0, import_libphonenumber_js.parsePhoneNumber)(numbers, toLibCountryCode(country.code));
|
|
829
|
+
if (parsed.nationalNumber === numbers) {
|
|
830
|
+
return numbers;
|
|
831
|
+
}
|
|
832
|
+
if (parsed.countryCallingCode === dial && parsed.nationalNumber === withoutDial) {
|
|
833
|
+
return withoutDial;
|
|
834
|
+
}
|
|
835
|
+
} catch {
|
|
836
|
+
}
|
|
837
|
+
return numbers;
|
|
838
|
+
}
|
|
839
|
+
function prepareNationalDigits(value, country) {
|
|
840
|
+
const raw = nationalPhoneDigits(value);
|
|
841
|
+
const stripped = stripAccidentalDialCodePrefix(raw, country);
|
|
842
|
+
const digits = country.dialCode === BR_DIAL_CODE ? collapseDuplicatedBrazilianMobileNine(stripped) : stripped;
|
|
843
|
+
return truncateNationalPhoneDigits(digits);
|
|
844
|
+
}
|
|
845
|
+
function prepareInternationalDigits(value) {
|
|
846
|
+
const digits = nationalPhoneDigits(value);
|
|
847
|
+
const collapsed = collapseDuplicatedBrazilianMobileNine(digits);
|
|
848
|
+
if (collapsed === digits) return digits;
|
|
849
|
+
try {
|
|
850
|
+
const original = (0, import_libphonenumber_js.parsePhoneNumber)(`+${digits}`);
|
|
851
|
+
if (original.isValid() && original.countryCallingCode !== BR_DIAL_CODE) {
|
|
852
|
+
return digits;
|
|
853
|
+
}
|
|
854
|
+
} catch {
|
|
855
|
+
}
|
|
856
|
+
return collapsed;
|
|
857
|
+
}
|
|
858
|
+
function formatNationalDigits(digits, country) {
|
|
859
|
+
if (!digits) return "";
|
|
860
|
+
const libCode = toLibCountryCode(country.code);
|
|
861
|
+
const formatter = new import_libphonenumber_js.AsYouType(libCode);
|
|
862
|
+
formatter.input(`+${country.dialCode}${digits}`);
|
|
863
|
+
const national = formatter.getNumber()?.formatNational();
|
|
864
|
+
if (national && nationalPhoneDigits(national) === digits) return national;
|
|
865
|
+
const asTyped = new import_libphonenumber_js.AsYouType(libCode).input(digits);
|
|
866
|
+
if (nationalPhoneDigits(asTyped) === digits) return asTyped;
|
|
867
|
+
return digits;
|
|
868
|
+
}
|
|
869
|
+
function formatPhoneNational(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
870
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
871
|
+
return formatNationalDigits(prepareNationalDigits(value, country), country);
|
|
872
|
+
}
|
|
873
|
+
function parsePhoneInput(input) {
|
|
874
|
+
const cleaned = String(input ?? "").replace(/[\s\-().]/g, "");
|
|
875
|
+
if (!cleaned) {
|
|
876
|
+
return { ddi: null, national: "", countryCode: null };
|
|
877
|
+
}
|
|
878
|
+
const hasPlus = cleaned.startsWith("+");
|
|
879
|
+
if (hasPlus) {
|
|
880
|
+
try {
|
|
881
|
+
const parsed = (0, import_libphonenumber_js.parsePhoneNumber)(cleaned);
|
|
882
|
+
if (parsed.country) {
|
|
883
|
+
const ourCode = fromLibCountryCode(parsed.country);
|
|
884
|
+
if (PHONE_INPUT_COUNTRY_CODES.has(ourCode)) {
|
|
885
|
+
return {
|
|
886
|
+
ddi: parsed.countryCallingCode,
|
|
887
|
+
national: parsed.nationalNumber,
|
|
888
|
+
countryCode: ourCode
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
} catch {
|
|
893
|
+
}
|
|
894
|
+
const digits = cleaned.slice(1);
|
|
895
|
+
for (const ddi of SORTED_PHONE_INPUT_DIAL_CODES) {
|
|
896
|
+
if (digits.startsWith(ddi)) {
|
|
897
|
+
const national = digits.slice(ddi.length);
|
|
898
|
+
const match = PHONE_COUNTRIES.find((c) => c.dialCode === ddi);
|
|
899
|
+
return {
|
|
900
|
+
ddi,
|
|
901
|
+
national,
|
|
902
|
+
countryCode: match?.code ?? null
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return {
|
|
907
|
+
ddi: null,
|
|
908
|
+
national: digits,
|
|
909
|
+
countryCode: null
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
ddi: null,
|
|
914
|
+
national: cleaned.replace(/\D/g, ""),
|
|
915
|
+
countryCode: null
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function preferValidE164(candidate) {
|
|
919
|
+
try {
|
|
920
|
+
const number = (0, import_libphonenumber_js.parsePhoneNumber)(candidate);
|
|
921
|
+
if (number.isValid()) return number.number;
|
|
922
|
+
} catch {
|
|
923
|
+
}
|
|
924
|
+
return candidate;
|
|
925
|
+
}
|
|
926
|
+
function toE164(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
927
|
+
const trimmed = String(value ?? "").trim();
|
|
928
|
+
if (!trimmed) return "";
|
|
929
|
+
const parsed = parsePhoneInput(trimmed);
|
|
930
|
+
if (parsed.ddi && parsed.national) {
|
|
931
|
+
const ddiCountry = parsed.countryCode && findPhoneCountry(parsed.countryCode) || PHONE_COUNTRIES.find((c) => c.dialCode === parsed.ddi) || defaultPhoneCountry();
|
|
932
|
+
return preferValidE164(
|
|
933
|
+
`+${parsed.ddi}${prepareNationalDigits(parsed.national, ddiCountry)}`
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
937
|
+
const national = prepareNationalDigits(parsed.national || trimmed, country);
|
|
938
|
+
if (!national) return "";
|
|
939
|
+
return preferValidE164(`+${country.dialCode}${national}`);
|
|
940
|
+
}
|
|
941
|
+
function isValidPhone(value, countryCode) {
|
|
942
|
+
const cleaned = String(value ?? "").trim();
|
|
943
|
+
if (!cleaned) return false;
|
|
944
|
+
if (cleaned.startsWith("+")) {
|
|
945
|
+
const digits2 = prepareInternationalDigits(cleaned);
|
|
946
|
+
return digits2 ? (0, import_libphonenumber_js.isValidPhoneNumber)(`+${digits2}`) : false;
|
|
947
|
+
}
|
|
948
|
+
const country = countryCode ? findPhoneCountry(countryCode) : defaultPhoneCountry();
|
|
949
|
+
if (!country) return false;
|
|
950
|
+
const digits = prepareNationalDigits(cleaned, country);
|
|
951
|
+
if (!digits) return false;
|
|
952
|
+
if (countryCode) {
|
|
953
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(digits, toLibCountryCode(countryCode));
|
|
954
|
+
}
|
|
955
|
+
if ((0, import_libphonenumber_js.isValidPhoneNumber)(`+${digits}`)) return true;
|
|
956
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(digits, "BR");
|
|
957
|
+
}
|
|
958
|
+
function remaskPhoneForCountry(nationalOrDraft, countryCode) {
|
|
959
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
960
|
+
const digits = truncateNationalPhoneDigits(
|
|
961
|
+
nationalPhoneDigits(nationalOrDraft)
|
|
962
|
+
);
|
|
963
|
+
return {
|
|
964
|
+
display: formatNationalDigits(digits, country),
|
|
965
|
+
e164: digits ? `+${country.dialCode}${digits}` : "",
|
|
966
|
+
country
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
|
|
613
970
|
// src/resolve-site-id.ts
|
|
614
971
|
var PREVIEW_HOST_SUFFIXES = [".vusercontent.net"];
|
|
615
972
|
function isStudioPreviewHost(host) {
|
|
@@ -743,10 +1100,15 @@ function normalizeContact(input) {
|
|
|
743
1100
|
code: "invalid_contact"
|
|
744
1101
|
});
|
|
745
1102
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
1103
|
+
let normalizedPhone;
|
|
1104
|
+
if (phone) {
|
|
1105
|
+
const e164 = toE164(phone);
|
|
1106
|
+
if (!e164 || !isValidPhone(e164) || e164.length > 40) {
|
|
1107
|
+
throw new LeadSubmitError("Garagem SDK: phone is invalid.", {
|
|
1108
|
+
code: "invalid_contact"
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
normalizedPhone = e164;
|
|
750
1112
|
}
|
|
751
1113
|
const message = input.message?.trim() || void 0;
|
|
752
1114
|
if (message && message.length > MESSAGE_MAX) {
|
|
@@ -757,10 +1119,19 @@ function normalizeContact(input) {
|
|
|
757
1119
|
return {
|
|
758
1120
|
name,
|
|
759
1121
|
...email ? { email } : {},
|
|
760
|
-
...
|
|
1122
|
+
...normalizedPhone ? { phone: normalizedPhone } : {},
|
|
761
1123
|
...message ? { message } : {}
|
|
762
1124
|
};
|
|
763
1125
|
}
|
|
1126
|
+
function normalizeSdkBusinessType(value) {
|
|
1127
|
+
if (!value) return void 0;
|
|
1128
|
+
const normalized = value.trim().toLowerCase();
|
|
1129
|
+
if (normalized === "rent" || normalized === "rental" || normalized === "aluguel") {
|
|
1130
|
+
return "rent";
|
|
1131
|
+
}
|
|
1132
|
+
if (normalized === "sale" || normalized === "venda") return "sale";
|
|
1133
|
+
return void 0;
|
|
1134
|
+
}
|
|
764
1135
|
async function postSiteLead(input) {
|
|
765
1136
|
const siteId = await resolveLeadSiteId(input);
|
|
766
1137
|
const base = normalizeBaseUrl(input.baseUrl);
|
|
@@ -808,13 +1179,16 @@ async function postSiteLead(input) {
|
|
|
808
1179
|
}
|
|
809
1180
|
function leadPostContext(input) {
|
|
810
1181
|
assertListingId(input.listingId);
|
|
1182
|
+
const businessType = normalizeSdkBusinessType(input.businessType) ?? normalizeSdkBusinessType(input.listingType);
|
|
811
1183
|
return {
|
|
812
1184
|
listingId: input.listingId.trim(),
|
|
813
1185
|
contact: normalizeContact(input),
|
|
814
1186
|
extras: {
|
|
815
1187
|
...input.visitorId ? { visitorId: input.visitorId } : {},
|
|
816
1188
|
...input.brokerRef ? { brokerRef: input.brokerRef } : {},
|
|
817
|
-
...input.referrer ? { referrer: input.referrer } : {}
|
|
1189
|
+
...input.referrer ? { referrer: input.referrer } : {},
|
|
1190
|
+
...businessType ? { businessType } : {},
|
|
1191
|
+
...input.listingType ? { listingType: input.listingType } : {}
|
|
818
1192
|
}
|
|
819
1193
|
};
|
|
820
1194
|
}
|
|
@@ -1180,7 +1554,7 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1180
1554
|
if (unitLabels.length > 0) {
|
|
1181
1555
|
groups.push({
|
|
1182
1556
|
key: "unit",
|
|
1183
|
-
title: LISTING_AMENITY_TITLES.unit,
|
|
1557
|
+
title: dictionary?.amenitySectionTitles?.unit ?? LISTING_AMENITY_TITLES.unit,
|
|
1184
1558
|
labels: unitLabels
|
|
1185
1559
|
});
|
|
1186
1560
|
}
|
|
@@ -1191,7 +1565,7 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1191
1565
|
if (buildingLabels.length > 0) {
|
|
1192
1566
|
groups.push({
|
|
1193
1567
|
key: "building",
|
|
1194
|
-
title: LISTING_AMENITY_TITLES.building,
|
|
1568
|
+
title: dictionary?.amenitySectionTitles?.building ?? LISTING_AMENITY_TITLES.building,
|
|
1195
1569
|
labels: buildingLabels
|
|
1196
1570
|
});
|
|
1197
1571
|
}
|
|
@@ -1199,25 +1573,6 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1199
1573
|
}
|
|
1200
1574
|
|
|
1201
1575
|
// src/presentation.ts
|
|
1202
|
-
var SEARCH_CSS_VARS = {
|
|
1203
|
-
cardRadius: "--garagem-listing-card-radius",
|
|
1204
|
-
cardGap: "--garagem-listing-card-gap",
|
|
1205
|
-
priceSize: "--garagem-listing-price-size",
|
|
1206
|
-
mediaRatio: "--garagem-listing-media-ratio",
|
|
1207
|
-
controlHeight: "--garagem-search-control-height",
|
|
1208
|
-
iconSize: "--garagem-search-icon-size",
|
|
1209
|
-
skeleton: "--garagem-skeleton"
|
|
1210
|
-
};
|
|
1211
|
-
var SEARCH_CSS_RECIPE = `:root {
|
|
1212
|
-
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
1213
|
-
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
1214
|
-
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
1215
|
-
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
1216
|
-
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
1217
|
-
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
1218
|
-
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
1219
|
-
}
|
|
1220
|
-
`;
|
|
1221
1576
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
1222
1577
|
if (amount == null) return "Sob consulta";
|
|
1223
1578
|
try {
|
|
@@ -1271,7 +1626,7 @@ function toListingCardModel(listing) {
|
|
|
1271
1626
|
businessLabel: listingBusinessLabel(listing.businessType),
|
|
1272
1627
|
priceVisibility: listing.priceVisibility,
|
|
1273
1628
|
price: listing.price,
|
|
1274
|
-
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price),
|
|
1629
|
+
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price, "pt-BR", listing.currency ?? "BRL"),
|
|
1275
1630
|
pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
|
|
1276
1631
|
locationLabel: listingLocationLabel(listing.location || {}),
|
|
1277
1632
|
propertyType: listing.property?.type ?? null,
|
|
@@ -1293,6 +1648,7 @@ var DEFAULT_MAX_PRICE = 1e9;
|
|
|
1293
1648
|
var DEFAULT_MIN_AREA = 0;
|
|
1294
1649
|
var DEFAULT_MAX_AREA = 1e5;
|
|
1295
1650
|
var SORT_URL_TOKENS = [
|
|
1651
|
+
"recentes",
|
|
1296
1652
|
"preco-asc",
|
|
1297
1653
|
"preco-desc",
|
|
1298
1654
|
"area-asc",
|
|
@@ -1932,6 +2288,8 @@ function currentSearchHref(pathname, search) {
|
|
|
1932
2288
|
return qs ? `${path}?${qs}` : path;
|
|
1933
2289
|
}
|
|
1934
2290
|
function canonicalizeSearchHref(pathname, search, dictionary) {
|
|
2291
|
+
if (pathname.includes("/api/v0-preview/")) return null;
|
|
2292
|
+
if (isListingDetailPath(pathname)) return null;
|
|
1935
2293
|
const { pathFilters, applied } = readPublicSearch(
|
|
1936
2294
|
pathname,
|
|
1937
2295
|
search,
|
|
@@ -2192,7 +2550,11 @@ function listingValues(listing) {
|
|
|
2192
2550
|
{
|
|
2193
2551
|
key: "price",
|
|
2194
2552
|
label: "Pre\xE7o",
|
|
2195
|
-
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2553
|
+
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2554
|
+
listing.price,
|
|
2555
|
+
"pt-BR",
|
|
2556
|
+
listing.currency ?? "BRL"
|
|
2557
|
+
)
|
|
2196
2558
|
}
|
|
2197
2559
|
];
|
|
2198
2560
|
const condoFee = positiveCount(listing.property?.condoFee);
|
|
@@ -2207,7 +2569,7 @@ function listingValues(listing) {
|
|
|
2207
2569
|
if (propertyTax != null) {
|
|
2208
2570
|
values.push({
|
|
2209
2571
|
key: "propertyTax",
|
|
2210
|
-
label: "IPTU",
|
|
2572
|
+
label: listing.propertyTaxLabel?.trim() || "IPTU",
|
|
2211
2573
|
text: formatListingPrice(propertyTax)
|
|
2212
2574
|
});
|
|
2213
2575
|
}
|
|
@@ -2376,25 +2738,23 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2376
2738
|
* 0.4.12 (`visibleSearchFilters` / `toolbarFilterIds` are on that pin).
|
|
2377
2739
|
*/
|
|
2378
2740
|
minNpmVersion: "0.4.12",
|
|
2379
|
-
/**
|
|
2741
|
+
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
2380
2742
|
selfInjectSince: "0.4.2",
|
|
2381
|
-
chromeStrategy: "
|
|
2382
|
-
reactExports: ["usePublicSearch"
|
|
2743
|
+
chromeStrategy: "app-owned",
|
|
2744
|
+
reactExports: ["usePublicSearch"],
|
|
2383
2745
|
/**
|
|
2384
|
-
* Names that exist in git /
|
|
2746
|
+
* Names that exist in git / unpublished patches. Completeness treats an
|
|
2385
2747
|
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
2386
2748
|
* `since`. Studio prompts must not mention these names at all (even as
|
|
2387
2749
|
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
2388
2750
|
* throws FatalRendererError.
|
|
2389
2751
|
*/
|
|
2390
|
-
optionalReactExports: {
|
|
2391
|
-
SearchChromeStyles: "0.4.1",
|
|
2392
|
-
ListingDetailFields: "0.4.13"
|
|
2393
|
-
},
|
|
2752
|
+
optionalReactExports: {},
|
|
2394
2753
|
/**
|
|
2395
|
-
* Former `/react` chrome
|
|
2396
|
-
* `reactExports`). Prompts must not
|
|
2397
|
-
* identifiers even inside
|
|
2754
|
+
* Former `/react` chrome (including card/skeleton inject). Completeness
|
|
2755
|
+
* flags imports as mismatch (not in `reactExports`). Prompts must not
|
|
2756
|
+
* mention these names at all — v0 copies identifiers even inside
|
|
2757
|
+
* “never import”.
|
|
2398
2758
|
*/
|
|
2399
2759
|
retiredReactExports: [
|
|
2400
2760
|
"SearchPage",
|
|
@@ -2402,7 +2762,11 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2402
2762
|
"SearchSortSelect",
|
|
2403
2763
|
"FilterPanel",
|
|
2404
2764
|
"SearchPagination",
|
|
2405
|
-
"SearchPageFallback"
|
|
2765
|
+
"SearchPageFallback",
|
|
2766
|
+
"ListingCard",
|
|
2767
|
+
"ResultsSkeleton",
|
|
2768
|
+
"SearchChromeStyles",
|
|
2769
|
+
"ListingDetailFields"
|
|
2406
2770
|
],
|
|
2407
2771
|
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
|
|
2408
2772
|
leadStrategy: "visit-default",
|
|
@@ -2417,6 +2781,36 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2417
2781
|
"STUDIO_DEFAULT_VISIT_SCHEDULE"
|
|
2418
2782
|
],
|
|
2419
2783
|
listingDetailExports: ["listingDetailModel", "getSimilarListings"],
|
|
2784
|
+
/** Main-package card helpers — markup stays in the generated app. */
|
|
2785
|
+
listingCardExports: [
|
|
2786
|
+
"toListingCardModel",
|
|
2787
|
+
"listingPublicPath",
|
|
2788
|
+
"formatAreaM2",
|
|
2789
|
+
"listingBusinessLabel",
|
|
2790
|
+
"formatListingPrice"
|
|
2791
|
+
],
|
|
2792
|
+
/**
|
|
2793
|
+
* Prompt-safe phone helpers on `minNpmVersion`. Empty until a published
|
|
2794
|
+
* tarball exports them and this pin bumps — then move names here from
|
|
2795
|
+
* `unpublishedPhoneExports`.
|
|
2796
|
+
*/
|
|
2797
|
+
phoneExports: [],
|
|
2798
|
+
/**
|
|
2799
|
+
* Headless phone mask helpers in git / newer tarballs but not on
|
|
2800
|
+
* `minNpmVersion` (0.4.12). Prompts, completeness, and repair text must
|
|
2801
|
+
* not mention these until the pin bumps — v0 installs the pin and the
|
|
2802
|
+
* ESM loader throws on missing named exports.
|
|
2803
|
+
*/
|
|
2804
|
+
unpublishedPhoneExports: [
|
|
2805
|
+
"PHONE_COUNTRIES",
|
|
2806
|
+
"formatPhoneNational",
|
|
2807
|
+
"toE164",
|
|
2808
|
+
"isValidPhone",
|
|
2809
|
+
"parsePhoneInput",
|
|
2810
|
+
"phoneCountrySearchValue",
|
|
2811
|
+
"findPhoneCountry",
|
|
2812
|
+
"remaskPhoneForCountry"
|
|
2813
|
+
],
|
|
2420
2814
|
amenityExports: ["listingAmenityGroups"],
|
|
2421
2815
|
/**
|
|
2422
2816
|
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
@@ -2470,7 +2864,7 @@ ${studioSiteWidthCss()}
|
|
|
2470
2864
|
Every page section is two layers: (1) surface \u2014 \`section\` / header / footer \`${STUDIO_SITE_LAYOUT.surfaceClassName}\`, background to the viewport edges, no max-width class and no horizontal padding; (2) wrapper \u2014 one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Header and footer use that same inner wrapper. Components fill the wrapper (\`w-full\`). Never nest a second max-width container with extra horizontal padding. ${studioSearchLandmarkInstruction()} Do not use \`ml-auto\` on the content wrapper. To make the site narrower or wider, change ONLY \`--site-max-width\` in \`app/globals.css\` (allowed: ${scale}; default ${STUDIO_SITE_LAYOUT.maxWidthRem}). Do not edit wrapper class names or horizontal padding. Full-bleed image surfaces (home hero, listing gallery) stay flush with the header \u2014 do not add vertical padding there.`;
|
|
2471
2865
|
}
|
|
2472
2866
|
function studioSearchLandmarkInstruction() {
|
|
2473
|
-
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`.
|
|
2867
|
+
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. The server page awaits the catalog and renders it with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` (\`search\` from the page searchParams, plus \`initial\`). Do not wrap that UI in \`<Suspense>\` and do not add a route \`loading\` file. A suspended page is streamed into a hidden node and stays invisible until JavaScript runs. Do not wrap the search UI in \`<section>\` or a second max-width. The page owns the SEO heading as \`<div data-slot="search-heading">\`: count \`<span data-slot="search-heading-count">\` FIRST, then \`<h1 data-slot="search-heading-title">\` \u2014 never put the count inside the H1 and never put the h1 first. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 change those values if the design needs it. Flush search (glued to the header) is allowed only with \`${STUDIO_SITE_LAYOUT.searchFlushMarker}\` on that \`<main>\`. Never add that vertical padding to home heroes or listing galleries.`;
|
|
2474
2868
|
}
|
|
2475
2869
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2476
2870
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
@@ -2533,22 +2927,26 @@ function studioSdkPinInstruction() {
|
|
|
2533
2927
|
}
|
|
2534
2928
|
function studioLeadInstruction() {
|
|
2535
2929
|
const names = STUDIO_SDK_CONTRACT.leadExports.join(", ");
|
|
2536
|
-
return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` \u2014 never concatenate a leads webhook URL and never POST the Showcase demo leads route.`;
|
|
2930
|
+
return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` \u2014 never concatenate a leads webhook URL and never POST the Showcase demo leads route. Phone fields use a national mask with a country picker and submit E.164 \u2014 do not invent a second mask and do not import \`@garagem/ui\` PhoneInput.`;
|
|
2931
|
+
}
|
|
2932
|
+
function studioListingCardInstruction() {
|
|
2933
|
+
const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
|
|
2934
|
+
return `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` \u2014 one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` \u2014 never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` \u2014 \u201CSob consulta\u201D when private; \`model.pricePeriod\` \u201C/m\xEAs\u201D when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` only for a slot whose content is still unknown \u2014 never as a \`<Suspense>\` fallback that replaces the catalog, and never the text \u201CCarregando im\xF3veis\u2026\u201D. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
|
|
2537
2935
|
}
|
|
2538
2936
|
function studioListingDetailInstruction() {
|
|
2539
2937
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
2540
|
-
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}
|
|
2938
|
+
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). The pre\xE7o / sob consulta entry is the primary value; condom\xEDnio and IPTU are secondary and omitted when missing. \`model.description\` is the complete string \u2014 do not slice. A collapsed disclosure uses a container (max-height or overflow), not a cut of the string. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, or \`model.mediaOverlays\` as a React child. Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`); player src is \`embedSrc\`; fullscreen overlay closes with browser back; omit when that overlay is absent. Do not key the page on \`location.hash\`. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` plus the site listing-card module; hide the section when empty. Do not invent a local recommendation loop.`;
|
|
2541
2939
|
}
|
|
2542
2940
|
function studioAmenityInstruction() {
|
|
2543
|
-
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (
|
|
2941
|
+
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing, dictionary)\` (pass the dictionary from \`getSearchUi()\` so section titles follow Campos). Each group is \`{ title, labels: string[] }\` \u2014 render \`group.title\` and \`group.labels.map((label) => \u2026)\` and hide a group when \`group.labels.length === 0\`. Do not hardcode section titles. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
|
|
2544
2942
|
}
|
|
2545
2943
|
function studioSearchInstruction() {
|
|
2546
2944
|
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
2547
2945
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
2548
|
-
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}.
|
|
2946
|
+
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Prefetch \`getSearchUi\` + \`queryListings\` on the server page. \`const search = usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE, search: searchFromServer, initial })\` where \`searchFromServer\` is \`new URLSearchParams(await searchParams).toString()\` \u2014 never shorthand \`{ search }\` beside \`const search =\` (temporal dead zone). Do not wrap this UI in \`<Suspense>\` and do not add a route \`loading\` file \u2014 heading and cards are ordinary elements in the document, visible with JavaScript off. Compose the page UI in the app \u2014 do not paste a canonical search TSX. Required chrome (design is free; omit none): query (\`qDraft\` / \`setQDraft\` / form \`preventDefault\` + \`submitQuery\`), heading (count span FIRST then h1 from \`searchResultsHeading(search.pathFilters, search.schema?.dictionary, search.locationNames)\` \u2014 never \`searchResultsHeading({})\`), toolbar (\`toolbarFilterIds\` + \`applyFilter\`; range \u201CAtualizar\u201D on that toolbar item only) vs sheet (\`visibleSearchFilters\` extras, \`stageFilter\`, one footer \`applyStaged\`), sort (\`searchSortOptions\` + \`setSort\`; first option id is \`""\` / \u201CMais relevantes\u201D \u2014 map **only** that empty id to Select sentinel \`"relevancia"\` (\`opt.id || "relevancia"\`), never \`SelectItem value=""\` and never give \u201CMais recentes\u201D (\`id: "recentes"\`, \`?ordenar=recentes\`) that sentinel; on change \`setSort(id === "relevancia" ? "" : id)\` so recentes stays recentes. Closed trigger shows the option \`.label\`, never \`{search.applied.sort}\`), grid (\`listings.map\` + the site listing-card module; listing-card-skeleton only for a slot whose content is still unknown, never as a Suspense fallback; do not \`throw\` in that chrome), pagination (\`paginationPages\` + \`hrefWithExplicitPage\`). Never interpolate \`schema\`, \`pathFilters\`, or a filter object as a React child. \`queryListings\` key is \`params\`. The URL is the document. Count text is \`{search.total}\` only. Heading is one row; font size lives on the container and the span and h1 use \`font-size: inherit\`. Sort trigger shows the option label (\u201CMais relevantes\u201D when \`ordenar\` is absent), chevron at the end, same height as the toolbar controls. Toolbar ranges open a Popover form (not DropdownMenu \u2014 Menu typeahead swallows digit keys) whose submit calls \`applyFilter\`; the popup clips and the two inputs stay inside (\`min-w-0\`, no \`w-64\`). Reset min/max drafts when the popover opens and when the applied path range changes. The sheet omits toolbar ids (price, bedrooms) so Pre\xE7o is never a heading without inputs. Sheet DialogContent uses \`h-[min(640px,85dvh)]\` (not max-h alone) so the body ScrollArea can move. Tipo de im\xF3vel, caracter\xEDsticas and comodidades each use a nested ScrollArea with \`h-56 overflow-hidden\` (viewport \`h-full\`). Area is two inputs in schema order with no \u201CAplicar\u201D; the footer stages then applyStaged. Never read \`staged[filter.id]\` \u2014 path keys are \`bedrooms\` / \`listingType\` / \`bathrooms\`. Bedrooms Select reads \`pathFilters.bedrooms\` so \`/imoveis/4-quartos\` checks \`"4"\` and shows the same trigger dot as price. Bathrooms and parking pressed state uses \`pathFilterHasOption\`. Limpar keeps location plus toolbar price and bedrooms via \`clearStagedPathFilters\` and \`toolbarFilterIds\`; do not call \`clearStaged\` for that button. It enables only when staged has a path filter other than location and those kept toolbar ids. Each multi-select \`stageFilter\` value is one option id, never a concatenated slug; \`checked\` uses \`pathFilterHasOption\`. Listing type does not pass the clicked id: no path value shows every checkbox checked, unchecking one stages the other option's id, and the last box stays checked. Price inputs use formatGroupedInteger. The closed price and bedrooms triggers keep the filter label plus a dot when set \u2014 never the literal range. Empty price calls applyFilter(id, undefined); never send 0 or 1000000000. Area is a plain integer (not that mask). The results button stageFilter property_area_total with both drafts, then applyStaged. Never send 0 or 100000. Count buttons pass the option id (\`"2"\`), never the label \`"2+"\`. Property type, features, and amenities render in pt-BR label order. Do not set \`[data-slot="search-sort"] { flex-direction: column }\` in a \`<style>\` tag; that selector is row so the chevron sits beside the label. Empty copy: ${JSON.stringify(SEARCH_EMPTY_COPY)}`;
|
|
2549
2947
|
}
|
|
2550
2948
|
function studioChromeInstruction() {
|
|
2551
|
-
return `
|
|
2949
|
+
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\`.`;
|
|
2552
2950
|
}
|
|
2553
2951
|
function mentionsExportName(text, name) {
|
|
2554
2952
|
return new RegExp(`\\b${name}\\b`).test(text);
|
|
@@ -2568,6 +2966,11 @@ function studioCodegenContractViolations(text) {
|
|
|
2568
2966
|
violations.push(name);
|
|
2569
2967
|
}
|
|
2570
2968
|
}
|
|
2969
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
2970
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
2971
|
+
violations.push(name);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2571
2974
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
2572
2975
|
const available = reactExportsAvailableAt(pin);
|
|
2573
2976
|
for (const name of parseReactSdkNamedImports(text)) {
|
|
@@ -2742,13 +3145,14 @@ function createGaragemClient(options = {}) {
|
|
|
2742
3145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2743
3146
|
0 && (module.exports = {
|
|
2744
3147
|
AMENITY_FALLBACK_LABELS,
|
|
3148
|
+
DEFAULT_PHONE_COUNTRY_CODE,
|
|
2745
3149
|
FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
2746
3150
|
GaragemSdkError,
|
|
2747
3151
|
LISTING_AMENITY_TITLES,
|
|
2748
3152
|
LISTING_DESCRIPTION_CLAMP,
|
|
2749
3153
|
LeadSubmitError,
|
|
2750
|
-
|
|
2751
|
-
|
|
3154
|
+
MAX_NATIONAL_PHONE_DIGITS,
|
|
3155
|
+
PHONE_COUNTRIES,
|
|
2752
3156
|
SEARCH_EMPTY_COPY,
|
|
2753
3157
|
SEARCH_SORT_RELEVANCE,
|
|
2754
3158
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
@@ -2762,18 +3166,22 @@ function createGaragemClient(options = {}) {
|
|
|
2762
3166
|
canonicalizeSearchHref,
|
|
2763
3167
|
clearStagedPathFilters,
|
|
2764
3168
|
coerceNpmVersion,
|
|
3169
|
+
collapseDuplicatedBrazilianMobileNine,
|
|
2765
3170
|
compareSemver,
|
|
2766
3171
|
composeSearchPublicHref,
|
|
2767
3172
|
composeSearchPublicPath,
|
|
2768
3173
|
countFacetChoices,
|
|
2769
3174
|
countOptionLabel,
|
|
2770
3175
|
createGaragemClient,
|
|
3176
|
+
defaultPhoneCountry,
|
|
2771
3177
|
displayPathLocation,
|
|
2772
3178
|
expandVisitSchedule,
|
|
2773
3179
|
expandVisitTimeSlots,
|
|
3180
|
+
findPhoneCountry,
|
|
2774
3181
|
formatAreaM2,
|
|
2775
3182
|
formatGroupedInteger,
|
|
2776
3183
|
formatListingPrice,
|
|
3184
|
+
formatPhoneNational,
|
|
2777
3185
|
getCmsCollection,
|
|
2778
3186
|
getCmsCollections,
|
|
2779
3187
|
getCmsEntries,
|
|
@@ -2790,6 +3198,7 @@ function createGaragemClient(options = {}) {
|
|
|
2790
3198
|
hrefWithExplicitPage,
|
|
2791
3199
|
isListingDetailPath,
|
|
2792
3200
|
isStudioPreviewHost,
|
|
3201
|
+
isValidPhone,
|
|
2793
3202
|
isVisitSlotAllowed,
|
|
2794
3203
|
labelAmenities,
|
|
2795
3204
|
listingAmenityGroups,
|
|
@@ -2807,22 +3216,26 @@ function createGaragemClient(options = {}) {
|
|
|
2807
3216
|
listingPublicPath,
|
|
2808
3217
|
listingValues,
|
|
2809
3218
|
mergeAppliedSearchQueryIntoSearch,
|
|
3219
|
+
nationalPhoneDigits,
|
|
2810
3220
|
normalizeVisitDate,
|
|
2811
3221
|
normalizeVisitTime,
|
|
2812
3222
|
paginationPages,
|
|
2813
3223
|
parseAppliedSearchQuery,
|
|
2814
3224
|
parseGroupedInteger,
|
|
3225
|
+
parsePhoneInput,
|
|
2815
3226
|
parseReactSdkNamedImports,
|
|
2816
3227
|
parseSearchPublicPath,
|
|
2817
3228
|
pathFilterHasOption,
|
|
2818
3229
|
pathFilterValue,
|
|
2819
3230
|
pathFiltersToQueryFilters,
|
|
2820
3231
|
pathLocationToFilterInput,
|
|
3232
|
+
phoneCountrySearchValue,
|
|
2821
3233
|
publicSearchHref,
|
|
2822
3234
|
queryListings,
|
|
2823
3235
|
rangeDraftFromPath,
|
|
2824
3236
|
readPublicSearch,
|
|
2825
3237
|
reduceAppliedSearchQuery,
|
|
3238
|
+
remaskPhoneForCountry,
|
|
2826
3239
|
resolvePublicSiteId,
|
|
2827
3240
|
searchChromeModel,
|
|
2828
3241
|
searchHrefUsesLegacyFilterQuery,
|
|
@@ -2837,6 +3250,7 @@ function createGaragemClient(options = {}) {
|
|
|
2837
3250
|
studioDefaultLeadUi,
|
|
2838
3251
|
studioLayoutInstruction,
|
|
2839
3252
|
studioLeadInstruction,
|
|
3253
|
+
studioListingCardInstruction,
|
|
2840
3254
|
studioListingDetailInstruction,
|
|
2841
3255
|
studioSdkPinInstruction,
|
|
2842
3256
|
studioSearchInstruction,
|
|
@@ -2844,8 +3258,10 @@ function createGaragemClient(options = {}) {
|
|
|
2844
3258
|
studioSiteWidthCss,
|
|
2845
3259
|
submitContactLead,
|
|
2846
3260
|
submitVisitLead,
|
|
3261
|
+
toE164,
|
|
2847
3262
|
toListingCardModel,
|
|
2848
3263
|
toolbarFilterIds,
|
|
3264
|
+
truncateNationalPhoneDigits,
|
|
2849
3265
|
unavailableReactImports,
|
|
2850
3266
|
visibleSearchFilters
|
|
2851
3267
|
});
|