@burdenoff/website-sdk 2026.924.10 → 2026.924.12

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.
@@ -715,6 +715,42 @@ function buildFallbackCatalog(examplePrompts, welcome) {
715
715
  conceptHighlights: []
716
716
  };
717
717
  }
718
+ var BAKED_CATALOG_ELEMENT_ID = "boff-explore-catalog";
719
+ function bakedCatalogLocale() {
720
+ if (typeof navigator === "undefined") return "";
721
+ return (navigator.language || "").toLowerCase().split("-")[0] ?? "";
722
+ }
723
+ function snapshotBakedElement() {
724
+ if (typeof document === "undefined") return null;
725
+ const el = document.getElementById(BAKED_CATALOG_ELEMENT_ID);
726
+ if (!el || el.tagName !== "SCRIPT" || el.getAttribute("type") !== "application/json")
727
+ return null;
728
+ return {
729
+ product: el.getAttribute("data-product") ?? "",
730
+ locale: el.getAttribute("data-locale") ?? "",
731
+ text: el.textContent ?? ""
732
+ };
733
+ }
734
+ var BAKED_AT_LOAD = snapshotBakedElement();
735
+ function isCatalogShape(value) {
736
+ if (!value || typeof value !== "object") return false;
737
+ const c = value;
738
+ const listOrAbsent = (v) => v === void 0 || v === null || Array.isArray(v);
739
+ const textOrAbsent = (v) => v === void 0 || v === null || typeof v === "string";
740
+ return (c["enabled"] === void 0 || typeof c["enabled"] === "boolean") && listOrAbsent(c["products"]) && listOrAbsent(c["examplePrompts"]) && listOrAbsent(c["conceptHighlights"]) && textOrAbsent(c["welcomeTitle"]) && textOrAbsent(c["welcomeBody"]);
741
+ }
742
+ function readBakedCatalog(productSlug) {
743
+ const baked = snapshotBakedElement() ?? BAKED_AT_LOAD;
744
+ if (!baked) return null;
745
+ if (baked.product !== (productSlug ?? "")) return null;
746
+ if (baked.locale && baked.locale !== bakedCatalogLocale()) return null;
747
+ try {
748
+ const parsed = JSON.parse(baked.text);
749
+ return isCatalogShape(parsed) ? parsed : null;
750
+ } catch {
751
+ return null;
752
+ }
753
+ }
718
754
  function normalizeCatalog(raw, fallback) {
719
755
  return {
720
756
  enabled: raw.enabled !== false,
@@ -964,9 +1000,17 @@ function useExploreChat(options = {}) {
964
1000
  ),
965
1001
  [promptKey, welcomeKey]
966
1002
  );
967
- const [catalog, setCatalog] = useState(fallbackCatalog);
1003
+ const [bakedRaw] = useState(
1004
+ () => readBakedCatalog(productSlug)
1005
+ );
1006
+ const [catalog, setCatalog] = useState(
1007
+ () => bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
1008
+ );
1009
+ const [serverCatalogRaw, setServerCatalogRaw] = useState(bakedRaw);
968
1010
  const [messages, setMessages] = useState([]);
969
- const [phase, setPhase] = useState("loading");
1011
+ const [phase, setPhase] = useState(
1012
+ () => bakedRaw ? bakedRaw.enabled === false ? "disabled" : "ready" : "loading"
1013
+ );
970
1014
  const [error, setError] = useState(null);
971
1015
  const [remainingToday, setRemainingToday] = useState(null);
972
1016
  const [focusProduct, setFocusProductState] = useState(null);
@@ -984,7 +1028,7 @@ function useExploreChat(options = {}) {
984
1028
  shareTokenRef.current = readShareToken();
985
1029
  }
986
1030
  const isSharedView = shareTokenRef.current !== null;
987
- const catalogRef = useRef(fallbackCatalog);
1031
+ const catalogRef = useRef(catalog);
988
1032
  const turnCountRef = useRef(0);
989
1033
  const focusProductRef = useRef(null);
990
1034
  const lastSentTextRef = useRef(null);
@@ -1130,25 +1174,29 @@ function useExploreChat(options = {}) {
1130
1174
  const raw = res.data?.exploreCatalog;
1131
1175
  if (res.errors?.length || !raw) {
1132
1176
  console.warn(
1133
- "[WebSDK] exploreCatalog unavailable \u2014 using the built-in fallback catalog",
1177
+ "[WebSDK] exploreCatalog unavailable \u2014 keeping the catalog the page started with",
1134
1178
  res.errors?.[0]?.message
1135
1179
  );
1136
1180
  setPhase((prev) => prev === "loading" ? "ready" : prev);
1137
1181
  return;
1138
1182
  }
1139
- const next = normalizeCatalog(raw, fallbackCatalog);
1183
+ const next = normalizeCatalog(
1184
+ raw,
1185
+ bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
1186
+ );
1140
1187
  setCatalog(next);
1188
+ setServerCatalogRaw(raw);
1141
1189
  catalogRef.current = next;
1142
1190
  setPhase((prev) => {
1143
1191
  if (!next.enabled) return "disabled";
1144
- return prev === "loading" ? "ready" : prev;
1192
+ return prev === "loading" || prev === "disabled" ? "ready" : prev;
1145
1193
  });
1146
1194
  };
1147
1195
  void load();
1148
1196
  return () => {
1149
1197
  cancelled = true;
1150
1198
  };
1151
- }, [client, productSlug, fallbackCatalog]);
1199
+ }, [client, productSlug, fallbackCatalog, bakedRaw]);
1152
1200
  const startPolling = useCallback(
1153
1201
  (conversationToken, messageId) => {
1154
1202
  pollGenerationRef.current += 1;
@@ -1616,6 +1664,7 @@ function useExploreChat(options = {}) {
1616
1664
  return {
1617
1665
  phase,
1618
1666
  catalog,
1667
+ serverCatalogRaw,
1619
1668
  messages,
1620
1669
  activity,
1621
1670
  remainingToday,