@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.
@@ -1,4 +1,4 @@
1
- export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, c as ExploreEscalateOutcome, d as ExploreEscalateResult, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, e as UseExploreChatResult, f as UseSpeechOutputOptions, g as UseSpeechOutputResult, h as classifyExploreError, s as stopSpeaking, u as useExploreChat, i as useProgressiveReveal, j as useSpeechOutput } from '../use-progressive-reveal-Cmy8bA7L.mjs';
1
+ export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, c as ExploreEscalateOutcome, d as ExploreEscalateResult, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, e as UseExploreChatResult, f as UseSpeechOutputOptions, g as UseSpeechOutputResult, h as classifyExploreError, s as stopSpeaking, u as useExploreChat, i as useProgressiveReveal, j as useSpeechOutput } from '../use-progressive-reveal-BBLRAnbU.mjs';
2
2
  import '../explore-types-B5sdOC5M.mjs';
3
3
 
4
4
  interface UseSpeechInputOptions {
@@ -1,4 +1,4 @@
1
- export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, c as ExploreEscalateOutcome, d as ExploreEscalateResult, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, e as UseExploreChatResult, f as UseSpeechOutputOptions, g as UseSpeechOutputResult, h as classifyExploreError, s as stopSpeaking, u as useExploreChat, i as useProgressiveReveal, j as useSpeechOutput } from '../use-progressive-reveal-DHPGGxZu.js';
1
+ export { D as DEFAULT_EXPLORE_EXAMPLE_PROMPTS, E as ExploreChatError, a as ExploreChatErrorKind, b as ExploreChatPhase, c as ExploreEscalateOutcome, d as ExploreEscalateResult, F as FALLBACK_EXPLORE_LIMITS, U as UseExploreChatOptions, e as UseExploreChatResult, f as UseSpeechOutputOptions, g as UseSpeechOutputResult, h as classifyExploreError, s as stopSpeaking, u as useExploreChat, i as useProgressiveReveal, j as useSpeechOutput } from '../use-progressive-reveal-myNKWb6S.js';
2
2
  import '../explore-types-B5sdOC5M.js';
3
3
 
4
4
  interface UseSpeechInputOptions {
@@ -717,6 +717,42 @@ function buildFallbackCatalog(examplePrompts, welcome) {
717
717
  conceptHighlights: []
718
718
  };
719
719
  }
720
+ var BAKED_CATALOG_ELEMENT_ID = "boff-explore-catalog";
721
+ function bakedCatalogLocale() {
722
+ if (typeof navigator === "undefined") return "";
723
+ return (navigator.language || "").toLowerCase().split("-")[0] ?? "";
724
+ }
725
+ function snapshotBakedElement() {
726
+ if (typeof document === "undefined") return null;
727
+ const el = document.getElementById(BAKED_CATALOG_ELEMENT_ID);
728
+ if (!el || el.tagName !== "SCRIPT" || el.getAttribute("type") !== "application/json")
729
+ return null;
730
+ return {
731
+ product: el.getAttribute("data-product") ?? "",
732
+ locale: el.getAttribute("data-locale") ?? "",
733
+ text: el.textContent ?? ""
734
+ };
735
+ }
736
+ var BAKED_AT_LOAD = snapshotBakedElement();
737
+ function isCatalogShape(value) {
738
+ if (!value || typeof value !== "object") return false;
739
+ const c = value;
740
+ const listOrAbsent = (v) => v === void 0 || v === null || Array.isArray(v);
741
+ const textOrAbsent = (v) => v === void 0 || v === null || typeof v === "string";
742
+ return (c["enabled"] === void 0 || typeof c["enabled"] === "boolean") && listOrAbsent(c["products"]) && listOrAbsent(c["examplePrompts"]) && listOrAbsent(c["conceptHighlights"]) && textOrAbsent(c["welcomeTitle"]) && textOrAbsent(c["welcomeBody"]);
743
+ }
744
+ function readBakedCatalog(productSlug) {
745
+ const baked = snapshotBakedElement() ?? BAKED_AT_LOAD;
746
+ if (!baked) return null;
747
+ if (baked.product !== (productSlug ?? "")) return null;
748
+ if (baked.locale && baked.locale !== bakedCatalogLocale()) return null;
749
+ try {
750
+ const parsed = JSON.parse(baked.text);
751
+ return isCatalogShape(parsed) ? parsed : null;
752
+ } catch {
753
+ return null;
754
+ }
755
+ }
720
756
  function normalizeCatalog(raw, fallback) {
721
757
  return {
722
758
  enabled: raw.enabled !== false,
@@ -966,9 +1002,17 @@ function useExploreChat(options = {}) {
966
1002
  ),
967
1003
  [promptKey, welcomeKey]
968
1004
  );
969
- const [catalog, setCatalog] = react.useState(fallbackCatalog);
1005
+ const [bakedRaw] = react.useState(
1006
+ () => readBakedCatalog(productSlug)
1007
+ );
1008
+ const [catalog, setCatalog] = react.useState(
1009
+ () => bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
1010
+ );
1011
+ const [serverCatalogRaw, setServerCatalogRaw] = react.useState(bakedRaw);
970
1012
  const [messages, setMessages] = react.useState([]);
971
- const [phase, setPhase] = react.useState("loading");
1013
+ const [phase, setPhase] = react.useState(
1014
+ () => bakedRaw ? bakedRaw.enabled === false ? "disabled" : "ready" : "loading"
1015
+ );
972
1016
  const [error, setError] = react.useState(null);
973
1017
  const [remainingToday, setRemainingToday] = react.useState(null);
974
1018
  const [focusProduct, setFocusProductState] = react.useState(null);
@@ -986,7 +1030,7 @@ function useExploreChat(options = {}) {
986
1030
  shareTokenRef.current = readShareToken();
987
1031
  }
988
1032
  const isSharedView = shareTokenRef.current !== null;
989
- const catalogRef = react.useRef(fallbackCatalog);
1033
+ const catalogRef = react.useRef(catalog);
990
1034
  const turnCountRef = react.useRef(0);
991
1035
  const focusProductRef = react.useRef(null);
992
1036
  const lastSentTextRef = react.useRef(null);
@@ -1132,25 +1176,29 @@ function useExploreChat(options = {}) {
1132
1176
  const raw = res.data?.exploreCatalog;
1133
1177
  if (res.errors?.length || !raw) {
1134
1178
  console.warn(
1135
- "[WebSDK] exploreCatalog unavailable \u2014 using the built-in fallback catalog",
1179
+ "[WebSDK] exploreCatalog unavailable \u2014 keeping the catalog the page started with",
1136
1180
  res.errors?.[0]?.message
1137
1181
  );
1138
1182
  setPhase((prev) => prev === "loading" ? "ready" : prev);
1139
1183
  return;
1140
1184
  }
1141
- const next = normalizeCatalog(raw, fallbackCatalog);
1185
+ const next = normalizeCatalog(
1186
+ raw,
1187
+ bakedRaw ? normalizeCatalog(bakedRaw, fallbackCatalog) : fallbackCatalog
1188
+ );
1142
1189
  setCatalog(next);
1190
+ setServerCatalogRaw(raw);
1143
1191
  catalogRef.current = next;
1144
1192
  setPhase((prev) => {
1145
1193
  if (!next.enabled) return "disabled";
1146
- return prev === "loading" ? "ready" : prev;
1194
+ return prev === "loading" || prev === "disabled" ? "ready" : prev;
1147
1195
  });
1148
1196
  };
1149
1197
  void load();
1150
1198
  return () => {
1151
1199
  cancelled = true;
1152
1200
  };
1153
- }, [client, productSlug, fallbackCatalog]);
1201
+ }, [client, productSlug, fallbackCatalog, bakedRaw]);
1154
1202
  const startPolling = react.useCallback(
1155
1203
  (conversationToken, messageId) => {
1156
1204
  pollGenerationRef.current += 1;
@@ -1618,6 +1666,7 @@ function useExploreChat(options = {}) {
1618
1666
  return {
1619
1667
  phase,
1620
1668
  catalog,
1669
+ serverCatalogRaw,
1621
1670
  messages,
1622
1671
  activity,
1623
1672
  remainingToday,