@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.mjs
CHANGED
|
@@ -14,6 +14,7 @@ function listingPublicPath(listing) {
|
|
|
14
14
|
|
|
15
15
|
// src/internal/url.ts
|
|
16
16
|
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
17
|
+
var DEFAULT_RESOLVE_BASE_URL = "https://cdn.fndn.ai/site";
|
|
17
18
|
function normalizeBaseUrl(baseUrl) {
|
|
18
19
|
const url = baseUrl ?? DEFAULT_BASE_URL;
|
|
19
20
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
@@ -113,7 +114,7 @@ async function getSite(options) {
|
|
|
113
114
|
"getSite: provide only one of `siteId` or `domain`, not both."
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
|
-
const base = normalizeBaseUrl(baseUrl);
|
|
117
|
+
const base = normalizeBaseUrl(baseUrl ?? DEFAULT_RESOLVE_BASE_URL);
|
|
117
118
|
const params = new URLSearchParams();
|
|
118
119
|
if (siteId) params.set("siteId", siteId);
|
|
119
120
|
if (domain) params.set("domain", domain);
|
|
@@ -478,6 +479,353 @@ function isVisitSlotAllowed(schedule, visitDate, visitTime, now = /* @__PURE__ *
|
|
|
478
479
|
return slotsForDate(schedule, visitDate, now).includes(time);
|
|
479
480
|
}
|
|
480
481
|
|
|
482
|
+
// src/phone.ts
|
|
483
|
+
import {
|
|
484
|
+
AsYouType,
|
|
485
|
+
isValidPhoneNumber,
|
|
486
|
+
parsePhoneNumber
|
|
487
|
+
} from "libphonenumber-js";
|
|
488
|
+
|
|
489
|
+
// src/phone-countries.ts
|
|
490
|
+
var DEFAULT_PHONE_COUNTRY_CODE = "BR";
|
|
491
|
+
var PHONE_COUNTRIES = [
|
|
492
|
+
{ code: "BR", name: "Brasil", dialCode: "55", flag: "\u{1F1E7}\u{1F1F7}" },
|
|
493
|
+
{ code: "US", name: "Estados Unidos", dialCode: "1", flag: "\u{1F1FA}\u{1F1F8}" },
|
|
494
|
+
{ code: "CA", name: "Canad\xE1", dialCode: "1", flag: "\u{1F1E8}\u{1F1E6}" },
|
|
495
|
+
{ code: "MX", name: "M\xE9xico", dialCode: "52", flag: "\u{1F1F2}\u{1F1FD}" },
|
|
496
|
+
{ code: "GT", name: "Guatemala", dialCode: "502", flag: "\u{1F1EC}\u{1F1F9}" },
|
|
497
|
+
{ code: "BZ", name: "Belize", dialCode: "501", flag: "\u{1F1E7}\u{1F1FF}" },
|
|
498
|
+
{ code: "SV", name: "El Salvador", dialCode: "503", flag: "\u{1F1F8}\u{1F1FB}" },
|
|
499
|
+
{ code: "HN", name: "Honduras", dialCode: "504", flag: "\u{1F1ED}\u{1F1F3}" },
|
|
500
|
+
{ code: "NI", name: "Nicar\xE1gua", dialCode: "505", flag: "\u{1F1F3}\u{1F1EE}" },
|
|
501
|
+
{ code: "CR", name: "Costa Rica", dialCode: "506", flag: "\u{1F1E8}\u{1F1F7}" },
|
|
502
|
+
{ code: "PA", name: "Panam\xE1", dialCode: "507", flag: "\u{1F1F5}\u{1F1E6}" },
|
|
503
|
+
{ code: "CU", name: "Cuba", dialCode: "53", flag: "\u{1F1E8}\u{1F1FA}" },
|
|
504
|
+
{ code: "DO", name: "Rep\xFAblica Dominicana", dialCode: "1", flag: "\u{1F1E9}\u{1F1F4}" },
|
|
505
|
+
{ code: "HT", name: "Haiti", dialCode: "509", flag: "\u{1F1ED}\u{1F1F9}" },
|
|
506
|
+
{ code: "AR", name: "Argentina", dialCode: "54", flag: "\u{1F1E6}\u{1F1F7}" },
|
|
507
|
+
{ code: "CL", name: "Chile", dialCode: "56", flag: "\u{1F1E8}\u{1F1F1}" },
|
|
508
|
+
{ code: "CO", name: "Col\xF4mbia", dialCode: "57", flag: "\u{1F1E8}\u{1F1F4}" },
|
|
509
|
+
{ code: "PE", name: "Peru", dialCode: "51", flag: "\u{1F1F5}\u{1F1EA}" },
|
|
510
|
+
{ code: "UY", name: "Uruguai", dialCode: "598", flag: "\u{1F1FA}\u{1F1FE}" },
|
|
511
|
+
{ code: "PY", name: "Paraguai", dialCode: "595", flag: "\u{1F1F5}\u{1F1FE}" },
|
|
512
|
+
{ code: "BO", name: "Bol\xEDvia", dialCode: "591", flag: "\u{1F1E7}\u{1F1F4}" },
|
|
513
|
+
{ code: "EC", name: "Equador", dialCode: "593", flag: "\u{1F1EA}\u{1F1E8}" },
|
|
514
|
+
{ code: "VE", name: "Venezuela", dialCode: "58", flag: "\u{1F1FB}\u{1F1EA}" },
|
|
515
|
+
{ code: "GY", name: "Guiana", dialCode: "592", flag: "\u{1F1EC}\u{1F1FE}" },
|
|
516
|
+
{ code: "SR", name: "Suriname", dialCode: "597", flag: "\u{1F1F8}\u{1F1F7}" },
|
|
517
|
+
{ code: "PT", name: "Portugal", dialCode: "351", flag: "\u{1F1F5}\u{1F1F9}" },
|
|
518
|
+
{ code: "ES", name: "Espanha", dialCode: "34", flag: "\u{1F1EA}\u{1F1F8}" },
|
|
519
|
+
{ code: "FR", name: "Fran\xE7a", dialCode: "33", flag: "\u{1F1EB}\u{1F1F7}" },
|
|
520
|
+
{ code: "UK", name: "Reino Unido", dialCode: "44", flag: "\u{1F1EC}\u{1F1E7}" },
|
|
521
|
+
{ code: "DE", name: "Alemanha", dialCode: "49", flag: "\u{1F1E9}\u{1F1EA}" },
|
|
522
|
+
{ code: "IT", name: "It\xE1lia", dialCode: "39", flag: "\u{1F1EE}\u{1F1F9}" },
|
|
523
|
+
{ code: "NL", name: "Holanda", dialCode: "31", flag: "\u{1F1F3}\u{1F1F1}" },
|
|
524
|
+
{ code: "BE", name: "B\xE9lgica", dialCode: "32", flag: "\u{1F1E7}\u{1F1EA}" },
|
|
525
|
+
{ code: "CH", name: "Su\xED\xE7a", dialCode: "41", flag: "\u{1F1E8}\u{1F1ED}" },
|
|
526
|
+
{ code: "AT", name: "\xC1ustria", dialCode: "43", flag: "\u{1F1E6}\u{1F1F9}" },
|
|
527
|
+
{ code: "SE", name: "Su\xE9cia", dialCode: "46", flag: "\u{1F1F8}\u{1F1EA}" },
|
|
528
|
+
{ code: "NO", name: "Noruega", dialCode: "47", flag: "\u{1F1F3}\u{1F1F4}" },
|
|
529
|
+
{ code: "DK", name: "Dinamarca", dialCode: "45", flag: "\u{1F1E9}\u{1F1F0}" },
|
|
530
|
+
{ code: "FI", name: "Finl\xE2ndia", dialCode: "358", flag: "\u{1F1EB}\u{1F1EE}" },
|
|
531
|
+
{ code: "IE", name: "Irlanda", dialCode: "353", flag: "\u{1F1EE}\u{1F1EA}" },
|
|
532
|
+
{ code: "AU", name: "Austr\xE1lia", dialCode: "61", flag: "\u{1F1E6}\u{1F1FA}" },
|
|
533
|
+
{ code: "NZ", name: "Nova Zel\xE2ndia", dialCode: "64", flag: "\u{1F1F3}\u{1F1FF}" },
|
|
534
|
+
{ code: "JP", name: "Jap\xE3o", dialCode: "81", flag: "\u{1F1EF}\u{1F1F5}" },
|
|
535
|
+
{ code: "KR", name: "Coreia do Sul", dialCode: "82", flag: "\u{1F1F0}\u{1F1F7}" },
|
|
536
|
+
{ code: "CN", name: "China", dialCode: "86", flag: "\u{1F1E8}\u{1F1F3}" },
|
|
537
|
+
{ code: "IN", name: "\xCDndia", dialCode: "91", flag: "\u{1F1EE}\u{1F1F3}" },
|
|
538
|
+
{ code: "RU", name: "R\xFAssia", dialCode: "7", flag: "\u{1F1F7}\u{1F1FA}" },
|
|
539
|
+
{ code: "UA", name: "Ucr\xE2nia", dialCode: "380", flag: "\u{1F1FA}\u{1F1E6}" },
|
|
540
|
+
{ code: "AE", name: "Emirados \xC1rabes", dialCode: "971", flag: "\u{1F1E6}\u{1F1EA}" },
|
|
541
|
+
{ code: "SA", name: "Ar\xE1bia Saudita", dialCode: "966", flag: "\u{1F1F8}\u{1F1E6}" },
|
|
542
|
+
{ code: "QA", name: "Catar", dialCode: "974", flag: "\u{1F1F6}\u{1F1E6}" },
|
|
543
|
+
{ code: "KW", name: "Kuwait", dialCode: "965", flag: "\u{1F1F0}\u{1F1FC}" },
|
|
544
|
+
{ code: "BH", name: "Bahrein", dialCode: "973", flag: "\u{1F1E7}\u{1F1ED}" },
|
|
545
|
+
{ code: "OM", name: "Om\xE3", dialCode: "968", flag: "\u{1F1F4}\u{1F1F2}" },
|
|
546
|
+
{ code: "JO", name: "Jord\xE2nia", dialCode: "962", flag: "\u{1F1EF}\u{1F1F4}" },
|
|
547
|
+
{ code: "LB", name: "L\xEDbano", dialCode: "961", flag: "\u{1F1F1}\u{1F1E7}" },
|
|
548
|
+
{ code: "IL", name: "Israel", dialCode: "972", flag: "\u{1F1EE}\u{1F1F1}" },
|
|
549
|
+
{ code: "TR", name: "Turquia", dialCode: "90", flag: "\u{1F1F9}\u{1F1F7}" },
|
|
550
|
+
{ code: "EG", name: "Egito", dialCode: "20", flag: "\u{1F1EA}\u{1F1EC}" },
|
|
551
|
+
{ code: "ZA", name: "\xC1frica do Sul", dialCode: "27", flag: "\u{1F1FF}\u{1F1E6}" },
|
|
552
|
+
{ code: "AO", name: "Angola", dialCode: "244", flag: "\u{1F1E6}\u{1F1F4}" },
|
|
553
|
+
{ code: "MZ", name: "Mo\xE7ambique", dialCode: "258", flag: "\u{1F1F2}\u{1F1FF}" },
|
|
554
|
+
{ code: "CV", name: "Cabo Verde", dialCode: "238", flag: "\u{1F1E8}\u{1F1FB}" }
|
|
555
|
+
];
|
|
556
|
+
function phoneCountrySearchValue(country) {
|
|
557
|
+
return `${country.name} ${country.code} ${country.dialCode} +${country.dialCode}`;
|
|
558
|
+
}
|
|
559
|
+
function findPhoneCountry(code) {
|
|
560
|
+
if (!code) return void 0;
|
|
561
|
+
const normalized = code.trim().toUpperCase();
|
|
562
|
+
return PHONE_COUNTRIES.find((country) => country.code === normalized);
|
|
563
|
+
}
|
|
564
|
+
function defaultPhoneCountry() {
|
|
565
|
+
return findPhoneCountry(DEFAULT_PHONE_COUNTRY_CODE) ?? PHONE_COUNTRIES[0];
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/phone.ts
|
|
569
|
+
var MAX_NATIONAL_PHONE_DIGITS = 15;
|
|
570
|
+
var VALID_BR_DDDS = /* @__PURE__ */ new Set([
|
|
571
|
+
"11",
|
|
572
|
+
"12",
|
|
573
|
+
"13",
|
|
574
|
+
"14",
|
|
575
|
+
"15",
|
|
576
|
+
"16",
|
|
577
|
+
"17",
|
|
578
|
+
"18",
|
|
579
|
+
"19",
|
|
580
|
+
"21",
|
|
581
|
+
"22",
|
|
582
|
+
"24",
|
|
583
|
+
"27",
|
|
584
|
+
"28",
|
|
585
|
+
"31",
|
|
586
|
+
"32",
|
|
587
|
+
"33",
|
|
588
|
+
"34",
|
|
589
|
+
"35",
|
|
590
|
+
"37",
|
|
591
|
+
"38",
|
|
592
|
+
"41",
|
|
593
|
+
"42",
|
|
594
|
+
"43",
|
|
595
|
+
"44",
|
|
596
|
+
"45",
|
|
597
|
+
"46",
|
|
598
|
+
"47",
|
|
599
|
+
"48",
|
|
600
|
+
"49",
|
|
601
|
+
"51",
|
|
602
|
+
"53",
|
|
603
|
+
"54",
|
|
604
|
+
"55",
|
|
605
|
+
"61",
|
|
606
|
+
"62",
|
|
607
|
+
"63",
|
|
608
|
+
"64",
|
|
609
|
+
"65",
|
|
610
|
+
"66",
|
|
611
|
+
"67",
|
|
612
|
+
"68",
|
|
613
|
+
"69",
|
|
614
|
+
"71",
|
|
615
|
+
"73",
|
|
616
|
+
"74",
|
|
617
|
+
"75",
|
|
618
|
+
"77",
|
|
619
|
+
"79",
|
|
620
|
+
"81",
|
|
621
|
+
"82",
|
|
622
|
+
"83",
|
|
623
|
+
"84",
|
|
624
|
+
"85",
|
|
625
|
+
"86",
|
|
626
|
+
"87",
|
|
627
|
+
"88",
|
|
628
|
+
"89",
|
|
629
|
+
"91",
|
|
630
|
+
"92",
|
|
631
|
+
"93",
|
|
632
|
+
"94",
|
|
633
|
+
"95",
|
|
634
|
+
"96",
|
|
635
|
+
"97",
|
|
636
|
+
"98",
|
|
637
|
+
"99"
|
|
638
|
+
]);
|
|
639
|
+
var PHONE_INPUT_COUNTRY_CODES = new Set(
|
|
640
|
+
PHONE_COUNTRIES.map((country) => country.code)
|
|
641
|
+
);
|
|
642
|
+
var SORTED_PHONE_INPUT_DIAL_CODES = [
|
|
643
|
+
...new Set(PHONE_COUNTRIES.map((country) => country.dialCode))
|
|
644
|
+
].sort((a, b) => b.length - a.length);
|
|
645
|
+
function toLibCountryCode(code) {
|
|
646
|
+
if (code === "UK") return "GB";
|
|
647
|
+
return code;
|
|
648
|
+
}
|
|
649
|
+
function fromLibCountryCode(code) {
|
|
650
|
+
if (code === "GB") return "UK";
|
|
651
|
+
return code;
|
|
652
|
+
}
|
|
653
|
+
function nationalPhoneDigits(value) {
|
|
654
|
+
return String(value ?? "").replace(/\D/g, "");
|
|
655
|
+
}
|
|
656
|
+
function truncateNationalPhoneDigits(digits, max = MAX_NATIONAL_PHONE_DIGITS) {
|
|
657
|
+
return digits.slice(0, max);
|
|
658
|
+
}
|
|
659
|
+
function collapseDuplicatedBrazilianMobileNine(digits) {
|
|
660
|
+
if (digits.length === 14 && digits.startsWith("55")) {
|
|
661
|
+
const national = collapseDuplicatedBrazilianMobileNine(digits.slice(2));
|
|
662
|
+
return national === digits.slice(2) ? digits : `55${national}`;
|
|
663
|
+
}
|
|
664
|
+
if (digits.length !== 12) return digits;
|
|
665
|
+
const ddd = digits.slice(0, 2);
|
|
666
|
+
if (!VALID_BR_DDDS.has(ddd)) return digits;
|
|
667
|
+
if (digits.charAt(2) !== "9") return digits;
|
|
668
|
+
const rest = digits.slice(3);
|
|
669
|
+
if (rest.length !== 9 || rest.charAt(0) !== "9") return digits;
|
|
670
|
+
if (ddd === "55") {
|
|
671
|
+
const subscriberFirst = digits.charAt(4);
|
|
672
|
+
if (subscriberFirst >= "0" && subscriberFirst <= "5") {
|
|
673
|
+
return digits;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
return `${ddd}${rest}`;
|
|
677
|
+
}
|
|
678
|
+
var BR_DIAL_CODE = "55";
|
|
679
|
+
function stripAccidentalDialCodePrefix(numbers, country) {
|
|
680
|
+
const dial = country.dialCode;
|
|
681
|
+
if (!numbers.startsWith(dial) || numbers.length <= dial.length) {
|
|
682
|
+
return numbers;
|
|
683
|
+
}
|
|
684
|
+
const withoutDial = numbers.slice(dial.length);
|
|
685
|
+
if (!withoutDial) return numbers;
|
|
686
|
+
try {
|
|
687
|
+
const parsed = parsePhoneNumber(numbers, toLibCountryCode(country.code));
|
|
688
|
+
if (parsed.nationalNumber === numbers) {
|
|
689
|
+
return numbers;
|
|
690
|
+
}
|
|
691
|
+
if (parsed.countryCallingCode === dial && parsed.nationalNumber === withoutDial) {
|
|
692
|
+
return withoutDial;
|
|
693
|
+
}
|
|
694
|
+
} catch {
|
|
695
|
+
}
|
|
696
|
+
return numbers;
|
|
697
|
+
}
|
|
698
|
+
function prepareNationalDigits(value, country) {
|
|
699
|
+
const raw = nationalPhoneDigits(value);
|
|
700
|
+
const stripped = stripAccidentalDialCodePrefix(raw, country);
|
|
701
|
+
const digits = country.dialCode === BR_DIAL_CODE ? collapseDuplicatedBrazilianMobileNine(stripped) : stripped;
|
|
702
|
+
return truncateNationalPhoneDigits(digits);
|
|
703
|
+
}
|
|
704
|
+
function prepareInternationalDigits(value) {
|
|
705
|
+
const digits = nationalPhoneDigits(value);
|
|
706
|
+
const collapsed = collapseDuplicatedBrazilianMobileNine(digits);
|
|
707
|
+
if (collapsed === digits) return digits;
|
|
708
|
+
try {
|
|
709
|
+
const original = parsePhoneNumber(`+${digits}`);
|
|
710
|
+
if (original.isValid() && original.countryCallingCode !== BR_DIAL_CODE) {
|
|
711
|
+
return digits;
|
|
712
|
+
}
|
|
713
|
+
} catch {
|
|
714
|
+
}
|
|
715
|
+
return collapsed;
|
|
716
|
+
}
|
|
717
|
+
function formatNationalDigits(digits, country) {
|
|
718
|
+
if (!digits) return "";
|
|
719
|
+
const libCode = toLibCountryCode(country.code);
|
|
720
|
+
const formatter = new AsYouType(libCode);
|
|
721
|
+
formatter.input(`+${country.dialCode}${digits}`);
|
|
722
|
+
const national = formatter.getNumber()?.formatNational();
|
|
723
|
+
if (national && nationalPhoneDigits(national) === digits) return national;
|
|
724
|
+
const asTyped = new AsYouType(libCode).input(digits);
|
|
725
|
+
if (nationalPhoneDigits(asTyped) === digits) return asTyped;
|
|
726
|
+
return digits;
|
|
727
|
+
}
|
|
728
|
+
function formatPhoneNational(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
729
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
730
|
+
return formatNationalDigits(prepareNationalDigits(value, country), country);
|
|
731
|
+
}
|
|
732
|
+
function parsePhoneInput(input) {
|
|
733
|
+
const cleaned = String(input ?? "").replace(/[\s\-().]/g, "");
|
|
734
|
+
if (!cleaned) {
|
|
735
|
+
return { ddi: null, national: "", countryCode: null };
|
|
736
|
+
}
|
|
737
|
+
const hasPlus = cleaned.startsWith("+");
|
|
738
|
+
if (hasPlus) {
|
|
739
|
+
try {
|
|
740
|
+
const parsed = parsePhoneNumber(cleaned);
|
|
741
|
+
if (parsed.country) {
|
|
742
|
+
const ourCode = fromLibCountryCode(parsed.country);
|
|
743
|
+
if (PHONE_INPUT_COUNTRY_CODES.has(ourCode)) {
|
|
744
|
+
return {
|
|
745
|
+
ddi: parsed.countryCallingCode,
|
|
746
|
+
national: parsed.nationalNumber,
|
|
747
|
+
countryCode: ourCode
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
} catch {
|
|
752
|
+
}
|
|
753
|
+
const digits = cleaned.slice(1);
|
|
754
|
+
for (const ddi of SORTED_PHONE_INPUT_DIAL_CODES) {
|
|
755
|
+
if (digits.startsWith(ddi)) {
|
|
756
|
+
const national = digits.slice(ddi.length);
|
|
757
|
+
const match = PHONE_COUNTRIES.find((c) => c.dialCode === ddi);
|
|
758
|
+
return {
|
|
759
|
+
ddi,
|
|
760
|
+
national,
|
|
761
|
+
countryCode: match?.code ?? null
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
ddi: null,
|
|
767
|
+
national: digits,
|
|
768
|
+
countryCode: null
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
ddi: null,
|
|
773
|
+
national: cleaned.replace(/\D/g, ""),
|
|
774
|
+
countryCode: null
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function preferValidE164(candidate) {
|
|
778
|
+
try {
|
|
779
|
+
const number = parsePhoneNumber(candidate);
|
|
780
|
+
if (number.isValid()) return number.number;
|
|
781
|
+
} catch {
|
|
782
|
+
}
|
|
783
|
+
return candidate;
|
|
784
|
+
}
|
|
785
|
+
function toE164(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
786
|
+
const trimmed = String(value ?? "").trim();
|
|
787
|
+
if (!trimmed) return "";
|
|
788
|
+
const parsed = parsePhoneInput(trimmed);
|
|
789
|
+
if (parsed.ddi && parsed.national) {
|
|
790
|
+
const ddiCountry = parsed.countryCode && findPhoneCountry(parsed.countryCode) || PHONE_COUNTRIES.find((c) => c.dialCode === parsed.ddi) || defaultPhoneCountry();
|
|
791
|
+
return preferValidE164(
|
|
792
|
+
`+${parsed.ddi}${prepareNationalDigits(parsed.national, ddiCountry)}`
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
796
|
+
const national = prepareNationalDigits(parsed.national || trimmed, country);
|
|
797
|
+
if (!national) return "";
|
|
798
|
+
return preferValidE164(`+${country.dialCode}${national}`);
|
|
799
|
+
}
|
|
800
|
+
function isValidPhone(value, countryCode) {
|
|
801
|
+
const cleaned = String(value ?? "").trim();
|
|
802
|
+
if (!cleaned) return false;
|
|
803
|
+
if (cleaned.startsWith("+")) {
|
|
804
|
+
const digits2 = prepareInternationalDigits(cleaned);
|
|
805
|
+
return digits2 ? isValidPhoneNumber(`+${digits2}`) : false;
|
|
806
|
+
}
|
|
807
|
+
const country = countryCode ? findPhoneCountry(countryCode) : defaultPhoneCountry();
|
|
808
|
+
if (!country) return false;
|
|
809
|
+
const digits = prepareNationalDigits(cleaned, country);
|
|
810
|
+
if (!digits) return false;
|
|
811
|
+
if (countryCode) {
|
|
812
|
+
return isValidPhoneNumber(digits, toLibCountryCode(countryCode));
|
|
813
|
+
}
|
|
814
|
+
if (isValidPhoneNumber(`+${digits}`)) return true;
|
|
815
|
+
return isValidPhoneNumber(digits, "BR");
|
|
816
|
+
}
|
|
817
|
+
function remaskPhoneForCountry(nationalOrDraft, countryCode) {
|
|
818
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
819
|
+
const digits = truncateNationalPhoneDigits(
|
|
820
|
+
nationalPhoneDigits(nationalOrDraft)
|
|
821
|
+
);
|
|
822
|
+
return {
|
|
823
|
+
display: formatNationalDigits(digits, country),
|
|
824
|
+
e164: digits ? `+${country.dialCode}${digits}` : "",
|
|
825
|
+
country
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
481
829
|
// src/resolve-site-id.ts
|
|
482
830
|
var PREVIEW_HOST_SUFFIXES = [".vusercontent.net"];
|
|
483
831
|
function isStudioPreviewHost(host) {
|
|
@@ -611,10 +959,15 @@ function normalizeContact(input) {
|
|
|
611
959
|
code: "invalid_contact"
|
|
612
960
|
});
|
|
613
961
|
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
962
|
+
let normalizedPhone;
|
|
963
|
+
if (phone) {
|
|
964
|
+
const e164 = toE164(phone);
|
|
965
|
+
if (!e164 || !isValidPhone(e164) || e164.length > 40) {
|
|
966
|
+
throw new LeadSubmitError("Garagem SDK: phone is invalid.", {
|
|
967
|
+
code: "invalid_contact"
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
normalizedPhone = e164;
|
|
618
971
|
}
|
|
619
972
|
const message = input.message?.trim() || void 0;
|
|
620
973
|
if (message && message.length > MESSAGE_MAX) {
|
|
@@ -625,10 +978,19 @@ function normalizeContact(input) {
|
|
|
625
978
|
return {
|
|
626
979
|
name,
|
|
627
980
|
...email ? { email } : {},
|
|
628
|
-
...
|
|
981
|
+
...normalizedPhone ? { phone: normalizedPhone } : {},
|
|
629
982
|
...message ? { message } : {}
|
|
630
983
|
};
|
|
631
984
|
}
|
|
985
|
+
function normalizeSdkBusinessType(value) {
|
|
986
|
+
if (!value) return void 0;
|
|
987
|
+
const normalized = value.trim().toLowerCase();
|
|
988
|
+
if (normalized === "rent" || normalized === "rental" || normalized === "aluguel") {
|
|
989
|
+
return "rent";
|
|
990
|
+
}
|
|
991
|
+
if (normalized === "sale" || normalized === "venda") return "sale";
|
|
992
|
+
return void 0;
|
|
993
|
+
}
|
|
632
994
|
async function postSiteLead(input) {
|
|
633
995
|
const siteId = await resolveLeadSiteId(input);
|
|
634
996
|
const base = normalizeBaseUrl(input.baseUrl);
|
|
@@ -676,13 +1038,16 @@ async function postSiteLead(input) {
|
|
|
676
1038
|
}
|
|
677
1039
|
function leadPostContext(input) {
|
|
678
1040
|
assertListingId(input.listingId);
|
|
1041
|
+
const businessType = normalizeSdkBusinessType(input.businessType) ?? normalizeSdkBusinessType(input.listingType);
|
|
679
1042
|
return {
|
|
680
1043
|
listingId: input.listingId.trim(),
|
|
681
1044
|
contact: normalizeContact(input),
|
|
682
1045
|
extras: {
|
|
683
1046
|
...input.visitorId ? { visitorId: input.visitorId } : {},
|
|
684
1047
|
...input.brokerRef ? { brokerRef: input.brokerRef } : {},
|
|
685
|
-
...input.referrer ? { referrer: input.referrer } : {}
|
|
1048
|
+
...input.referrer ? { referrer: input.referrer } : {},
|
|
1049
|
+
...businessType ? { businessType } : {},
|
|
1050
|
+
...input.listingType ? { listingType: input.listingType } : {}
|
|
686
1051
|
}
|
|
687
1052
|
};
|
|
688
1053
|
}
|
|
@@ -1048,7 +1413,7 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1048
1413
|
if (unitLabels.length > 0) {
|
|
1049
1414
|
groups.push({
|
|
1050
1415
|
key: "unit",
|
|
1051
|
-
title: LISTING_AMENITY_TITLES.unit,
|
|
1416
|
+
title: dictionary?.amenitySectionTitles?.unit ?? LISTING_AMENITY_TITLES.unit,
|
|
1052
1417
|
labels: unitLabels
|
|
1053
1418
|
});
|
|
1054
1419
|
}
|
|
@@ -1059,7 +1424,7 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1059
1424
|
if (buildingLabels.length > 0) {
|
|
1060
1425
|
groups.push({
|
|
1061
1426
|
key: "building",
|
|
1062
|
-
title: LISTING_AMENITY_TITLES.building,
|
|
1427
|
+
title: dictionary?.amenitySectionTitles?.building ?? LISTING_AMENITY_TITLES.building,
|
|
1063
1428
|
labels: buildingLabels
|
|
1064
1429
|
});
|
|
1065
1430
|
}
|
|
@@ -1067,25 +1432,6 @@ function listingAmenityGroups(listing, dictionary) {
|
|
|
1067
1432
|
}
|
|
1068
1433
|
|
|
1069
1434
|
// src/presentation.ts
|
|
1070
|
-
var SEARCH_CSS_VARS = {
|
|
1071
|
-
cardRadius: "--garagem-listing-card-radius",
|
|
1072
|
-
cardGap: "--garagem-listing-card-gap",
|
|
1073
|
-
priceSize: "--garagem-listing-price-size",
|
|
1074
|
-
mediaRatio: "--garagem-listing-media-ratio",
|
|
1075
|
-
controlHeight: "--garagem-search-control-height",
|
|
1076
|
-
iconSize: "--garagem-search-icon-size",
|
|
1077
|
-
skeleton: "--garagem-skeleton"
|
|
1078
|
-
};
|
|
1079
|
-
var SEARCH_CSS_RECIPE = `:root {
|
|
1080
|
-
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
1081
|
-
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
1082
|
-
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
1083
|
-
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
1084
|
-
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
1085
|
-
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
1086
|
-
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
1087
|
-
}
|
|
1088
|
-
`;
|
|
1089
1435
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
1090
1436
|
if (amount == null) return "Sob consulta";
|
|
1091
1437
|
try {
|
|
@@ -1139,7 +1485,7 @@ function toListingCardModel(listing) {
|
|
|
1139
1485
|
businessLabel: listingBusinessLabel(listing.businessType),
|
|
1140
1486
|
priceVisibility: listing.priceVisibility,
|
|
1141
1487
|
price: listing.price,
|
|
1142
|
-
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price),
|
|
1488
|
+
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price, "pt-BR", listing.currency ?? "BRL"),
|
|
1143
1489
|
pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
|
|
1144
1490
|
locationLabel: listingLocationLabel(listing.location || {}),
|
|
1145
1491
|
propertyType: listing.property?.type ?? null,
|
|
@@ -1161,6 +1507,7 @@ var DEFAULT_MAX_PRICE = 1e9;
|
|
|
1161
1507
|
var DEFAULT_MIN_AREA = 0;
|
|
1162
1508
|
var DEFAULT_MAX_AREA = 1e5;
|
|
1163
1509
|
var SORT_URL_TOKENS = [
|
|
1510
|
+
"recentes",
|
|
1164
1511
|
"preco-asc",
|
|
1165
1512
|
"preco-desc",
|
|
1166
1513
|
"area-asc",
|
|
@@ -1800,6 +2147,8 @@ function currentSearchHref(pathname, search) {
|
|
|
1800
2147
|
return qs ? `${path}?${qs}` : path;
|
|
1801
2148
|
}
|
|
1802
2149
|
function canonicalizeSearchHref(pathname, search, dictionary) {
|
|
2150
|
+
if (pathname.includes("/api/v0-preview/")) return null;
|
|
2151
|
+
if (isListingDetailPath(pathname)) return null;
|
|
1803
2152
|
const { pathFilters, applied } = readPublicSearch(
|
|
1804
2153
|
pathname,
|
|
1805
2154
|
search,
|
|
@@ -2060,7 +2409,11 @@ function listingValues(listing) {
|
|
|
2060
2409
|
{
|
|
2061
2410
|
key: "price",
|
|
2062
2411
|
label: "Pre\xE7o",
|
|
2063
|
-
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2412
|
+
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2413
|
+
listing.price,
|
|
2414
|
+
"pt-BR",
|
|
2415
|
+
listing.currency ?? "BRL"
|
|
2416
|
+
)
|
|
2064
2417
|
}
|
|
2065
2418
|
];
|
|
2066
2419
|
const condoFee = positiveCount(listing.property?.condoFee);
|
|
@@ -2075,7 +2428,7 @@ function listingValues(listing) {
|
|
|
2075
2428
|
if (propertyTax != null) {
|
|
2076
2429
|
values.push({
|
|
2077
2430
|
key: "propertyTax",
|
|
2078
|
-
label: "IPTU",
|
|
2431
|
+
label: listing.propertyTaxLabel?.trim() || "IPTU",
|
|
2079
2432
|
text: formatListingPrice(propertyTax)
|
|
2080
2433
|
});
|
|
2081
2434
|
}
|
|
@@ -2244,25 +2597,23 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2244
2597
|
* 0.4.12 (`visibleSearchFilters` / `toolbarFilterIds` are on that pin).
|
|
2245
2598
|
*/
|
|
2246
2599
|
minNpmVersion: "0.4.12",
|
|
2247
|
-
/**
|
|
2600
|
+
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
2248
2601
|
selfInjectSince: "0.4.2",
|
|
2249
|
-
chromeStrategy: "
|
|
2250
|
-
reactExports: ["usePublicSearch"
|
|
2602
|
+
chromeStrategy: "app-owned",
|
|
2603
|
+
reactExports: ["usePublicSearch"],
|
|
2251
2604
|
/**
|
|
2252
|
-
* Names that exist in git /
|
|
2605
|
+
* Names that exist in git / unpublished patches. Completeness treats an
|
|
2253
2606
|
* import as `sdk-export-mismatch` when the generated pin is older than
|
|
2254
2607
|
* `since`. Studio prompts must not mention these names at all (even as
|
|
2255
2608
|
* “never import”) — v0 copies the identifier and the preview ESM loader
|
|
2256
2609
|
* throws FatalRendererError.
|
|
2257
2610
|
*/
|
|
2258
|
-
optionalReactExports: {
|
|
2259
|
-
SearchChromeStyles: "0.4.1",
|
|
2260
|
-
ListingDetailFields: "0.4.13"
|
|
2261
|
-
},
|
|
2611
|
+
optionalReactExports: {},
|
|
2262
2612
|
/**
|
|
2263
|
-
* Former `/react` chrome
|
|
2264
|
-
* `reactExports`). Prompts must not
|
|
2265
|
-
* identifiers even inside
|
|
2613
|
+
* Former `/react` chrome (including card/skeleton inject). Completeness
|
|
2614
|
+
* flags imports as mismatch (not in `reactExports`). Prompts must not
|
|
2615
|
+
* mention these names at all — v0 copies identifiers even inside
|
|
2616
|
+
* “never import”.
|
|
2266
2617
|
*/
|
|
2267
2618
|
retiredReactExports: [
|
|
2268
2619
|
"SearchPage",
|
|
@@ -2270,7 +2621,11 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2270
2621
|
"SearchSortSelect",
|
|
2271
2622
|
"FilterPanel",
|
|
2272
2623
|
"SearchPagination",
|
|
2273
|
-
"SearchPageFallback"
|
|
2624
|
+
"SearchPageFallback",
|
|
2625
|
+
"ListingCard",
|
|
2626
|
+
"ResultsSkeleton",
|
|
2627
|
+
"SearchChromeStyles",
|
|
2628
|
+
"ListingDetailFields"
|
|
2274
2629
|
],
|
|
2275
2630
|
forbiddenImports: ["@garagem-ai/site-sdk/react/search.css"],
|
|
2276
2631
|
leadStrategy: "visit-default",
|
|
@@ -2285,6 +2640,36 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2285
2640
|
"STUDIO_DEFAULT_VISIT_SCHEDULE"
|
|
2286
2641
|
],
|
|
2287
2642
|
listingDetailExports: ["listingDetailModel", "getSimilarListings"],
|
|
2643
|
+
/** Main-package card helpers — markup stays in the generated app. */
|
|
2644
|
+
listingCardExports: [
|
|
2645
|
+
"toListingCardModel",
|
|
2646
|
+
"listingPublicPath",
|
|
2647
|
+
"formatAreaM2",
|
|
2648
|
+
"listingBusinessLabel",
|
|
2649
|
+
"formatListingPrice"
|
|
2650
|
+
],
|
|
2651
|
+
/**
|
|
2652
|
+
* Prompt-safe phone helpers on `minNpmVersion`. Empty until a published
|
|
2653
|
+
* tarball exports them and this pin bumps — then move names here from
|
|
2654
|
+
* `unpublishedPhoneExports`.
|
|
2655
|
+
*/
|
|
2656
|
+
phoneExports: [],
|
|
2657
|
+
/**
|
|
2658
|
+
* Headless phone mask helpers in git / newer tarballs but not on
|
|
2659
|
+
* `minNpmVersion` (0.4.12). Prompts, completeness, and repair text must
|
|
2660
|
+
* not mention these until the pin bumps — v0 installs the pin and the
|
|
2661
|
+
* ESM loader throws on missing named exports.
|
|
2662
|
+
*/
|
|
2663
|
+
unpublishedPhoneExports: [
|
|
2664
|
+
"PHONE_COUNTRIES",
|
|
2665
|
+
"formatPhoneNational",
|
|
2666
|
+
"toE164",
|
|
2667
|
+
"isValidPhone",
|
|
2668
|
+
"parsePhoneInput",
|
|
2669
|
+
"phoneCountrySearchValue",
|
|
2670
|
+
"findPhoneCountry",
|
|
2671
|
+
"remaskPhoneForCountry"
|
|
2672
|
+
],
|
|
2288
2673
|
amenityExports: ["listingAmenityGroups"],
|
|
2289
2674
|
/**
|
|
2290
2675
|
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
@@ -2338,7 +2723,7 @@ ${studioSiteWidthCss()}
|
|
|
2338
2723
|
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.`;
|
|
2339
2724
|
}
|
|
2340
2725
|
function studioSearchLandmarkInstruction() {
|
|
2341
|
-
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`.
|
|
2726
|
+
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.`;
|
|
2342
2727
|
}
|
|
2343
2728
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2344
2729
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
@@ -2401,22 +2786,26 @@ function studioSdkPinInstruction() {
|
|
|
2401
2786
|
}
|
|
2402
2787
|
function studioLeadInstruction() {
|
|
2403
2788
|
const names = STUDIO_SDK_CONTRACT.leadExports.join(", ");
|
|
2404
|
-
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.`;
|
|
2789
|
+
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.`;
|
|
2790
|
+
}
|
|
2791
|
+
function studioListingCardInstruction() {
|
|
2792
|
+
const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
|
|
2793
|
+
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.`;
|
|
2405
2794
|
}
|
|
2406
2795
|
function studioListingDetailInstruction() {
|
|
2407
2796
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
2408
|
-
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}
|
|
2797
|
+
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.`;
|
|
2409
2798
|
}
|
|
2410
2799
|
function studioAmenityInstruction() {
|
|
2411
|
-
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing)\` (
|
|
2800
|
+
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".`;
|
|
2412
2801
|
}
|
|
2413
2802
|
function studioSearchInstruction() {
|
|
2414
2803
|
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
2415
2804
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
2416
|
-
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}.
|
|
2805
|
+
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)}`;
|
|
2417
2806
|
}
|
|
2418
2807
|
function studioChromeInstruction() {
|
|
2419
|
-
return `
|
|
2808
|
+
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\`.`;
|
|
2420
2809
|
}
|
|
2421
2810
|
function mentionsExportName(text, name) {
|
|
2422
2811
|
return new RegExp(`\\b${name}\\b`).test(text);
|
|
@@ -2436,6 +2825,11 @@ function studioCodegenContractViolations(text) {
|
|
|
2436
2825
|
violations.push(name);
|
|
2437
2826
|
}
|
|
2438
2827
|
}
|
|
2828
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
2829
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
2830
|
+
violations.push(name);
|
|
2831
|
+
}
|
|
2832
|
+
}
|
|
2439
2833
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
2440
2834
|
const available = reactExportsAvailableAt(pin);
|
|
2441
2835
|
for (const name of parseReactSdkNamedImports(text)) {
|
|
@@ -2609,13 +3003,14 @@ function createGaragemClient(options = {}) {
|
|
|
2609
3003
|
}
|
|
2610
3004
|
export {
|
|
2611
3005
|
AMENITY_FALLBACK_LABELS,
|
|
3006
|
+
DEFAULT_PHONE_COUNTRY_CODE,
|
|
2612
3007
|
FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
2613
3008
|
GaragemSdkError,
|
|
2614
3009
|
LISTING_AMENITY_TITLES,
|
|
2615
3010
|
LISTING_DESCRIPTION_CLAMP,
|
|
2616
3011
|
LeadSubmitError,
|
|
2617
|
-
|
|
2618
|
-
|
|
3012
|
+
MAX_NATIONAL_PHONE_DIGITS,
|
|
3013
|
+
PHONE_COUNTRIES,
|
|
2619
3014
|
SEARCH_EMPTY_COPY,
|
|
2620
3015
|
SEARCH_SORT_RELEVANCE,
|
|
2621
3016
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
@@ -2629,18 +3024,22 @@ export {
|
|
|
2629
3024
|
canonicalizeSearchHref,
|
|
2630
3025
|
clearStagedPathFilters,
|
|
2631
3026
|
coerceNpmVersion,
|
|
3027
|
+
collapseDuplicatedBrazilianMobileNine,
|
|
2632
3028
|
compareSemver,
|
|
2633
3029
|
composeSearchPublicHref2 as composeSearchPublicHref,
|
|
2634
3030
|
composeSearchPublicPath2 as composeSearchPublicPath,
|
|
2635
3031
|
countFacetChoices,
|
|
2636
3032
|
countOptionLabel,
|
|
2637
3033
|
createGaragemClient,
|
|
3034
|
+
defaultPhoneCountry,
|
|
2638
3035
|
displayPathLocation,
|
|
2639
3036
|
expandVisitSchedule,
|
|
2640
3037
|
expandVisitTimeSlots,
|
|
3038
|
+
findPhoneCountry,
|
|
2641
3039
|
formatAreaM2,
|
|
2642
3040
|
formatGroupedInteger,
|
|
2643
3041
|
formatListingPrice,
|
|
3042
|
+
formatPhoneNational,
|
|
2644
3043
|
getCmsCollection,
|
|
2645
3044
|
getCmsCollections,
|
|
2646
3045
|
getCmsEntries,
|
|
@@ -2657,6 +3056,7 @@ export {
|
|
|
2657
3056
|
hrefWithExplicitPage,
|
|
2658
3057
|
isListingDetailPath,
|
|
2659
3058
|
isStudioPreviewHost,
|
|
3059
|
+
isValidPhone,
|
|
2660
3060
|
isVisitSlotAllowed,
|
|
2661
3061
|
labelAmenities,
|
|
2662
3062
|
listingAmenityGroups,
|
|
@@ -2674,22 +3074,26 @@ export {
|
|
|
2674
3074
|
listingPublicPath,
|
|
2675
3075
|
listingValues,
|
|
2676
3076
|
mergeAppliedSearchQueryIntoSearch2 as mergeAppliedSearchQueryIntoSearch,
|
|
3077
|
+
nationalPhoneDigits,
|
|
2677
3078
|
normalizeVisitDate,
|
|
2678
3079
|
normalizeVisitTime,
|
|
2679
3080
|
paginationPages,
|
|
2680
3081
|
parseAppliedSearchQuery2 as parseAppliedSearchQuery,
|
|
2681
3082
|
parseGroupedInteger,
|
|
3083
|
+
parsePhoneInput,
|
|
2682
3084
|
parseReactSdkNamedImports,
|
|
2683
3085
|
parseSearchPublicPath2 as parseSearchPublicPath,
|
|
2684
3086
|
pathFilterHasOption,
|
|
2685
3087
|
pathFilterValue,
|
|
2686
3088
|
pathFiltersToQueryFilters,
|
|
2687
3089
|
pathLocationToFilterInput,
|
|
3090
|
+
phoneCountrySearchValue,
|
|
2688
3091
|
publicSearchHref,
|
|
2689
3092
|
queryListings,
|
|
2690
3093
|
rangeDraftFromPath,
|
|
2691
3094
|
readPublicSearch,
|
|
2692
3095
|
reduceAppliedSearchQuery2 as reduceAppliedSearchQuery,
|
|
3096
|
+
remaskPhoneForCountry,
|
|
2693
3097
|
resolvePublicSiteId,
|
|
2694
3098
|
searchChromeModel,
|
|
2695
3099
|
searchHrefUsesLegacyFilterQuery,
|
|
@@ -2704,6 +3108,7 @@ export {
|
|
|
2704
3108
|
studioDefaultLeadUi,
|
|
2705
3109
|
studioLayoutInstruction,
|
|
2706
3110
|
studioLeadInstruction,
|
|
3111
|
+
studioListingCardInstruction,
|
|
2707
3112
|
studioListingDetailInstruction,
|
|
2708
3113
|
studioSdkPinInstruction,
|
|
2709
3114
|
studioSearchInstruction,
|
|
@@ -2711,8 +3116,10 @@ export {
|
|
|
2711
3116
|
studioSiteWidthCss,
|
|
2712
3117
|
submitContactLead,
|
|
2713
3118
|
submitVisitLead,
|
|
3119
|
+
toE164,
|
|
2714
3120
|
toListingCardModel,
|
|
2715
3121
|
toolbarFilterIds,
|
|
3122
|
+
truncateNationalPhoneDigits,
|
|
2716
3123
|
unavailableReactImports,
|
|
2717
3124
|
visibleSearchFilters
|
|
2718
3125
|
};
|