@gengage/assistant-fe 0.5.7 → 0.6.1

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.
Files changed (191) hide show
  1. package/README.md +6 -22
  2. package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
  3. package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
  4. package/dist/agentic/adaptor/mount.d.ts +38 -0
  5. package/dist/agentic/context/chat-context.d.ts +15 -0
  6. package/dist/agentic/context/context-store.d.ts +20 -0
  7. package/dist/agentic/context/persistence.d.ts +12 -0
  8. package/dist/agentic/events/builders.d.ts +10 -0
  9. package/dist/agentic/events/error-taxonomy.d.ts +27 -0
  10. package/dist/agentic/events/product-normalize.d.ts +47 -0
  11. package/dist/agentic/events/ui-specs.d.ts +37 -0
  12. package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
  13. package/dist/agentic/flow/create-flow.d.ts +2 -0
  14. package/dist/agentic/flow/dispatch.d.ts +3 -0
  15. package/dist/agentic/index.d.ts +18 -0
  16. package/dist/agentic/index.js +624 -0
  17. package/dist/agentic/types.d.ts +212 -0
  18. package/dist/agentic/util/assistant-host.d.ts +11 -0
  19. package/dist/agentic/util/be-url.d.ts +4 -0
  20. package/dist/agentic/util/browser-memory.d.ts +13 -0
  21. package/dist/agentic/util/browser-tools.d.ts +31 -0
  22. package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
  23. package/dist/agentic/util/request-text.d.ts +3 -0
  24. package/dist/agentic/util/time.d.ts +2 -0
  25. package/dist/agentic/worker/be-client.d.ts +15 -0
  26. package/dist/agentic/worker/entry.d.ts +2 -0
  27. package/dist/agentic/worker/flow-runner.d.ts +24 -0
  28. package/dist/agentic/worker/jwt-mint.d.ts +21 -0
  29. package/dist/agentic/worker/rpc.d.ts +24 -0
  30. package/dist/agentic/worker/tool-bridge.d.ts +2 -0
  31. package/dist/agentic/worker.d.ts +16 -0
  32. package/dist/agentic/worker.js +119 -0
  33. package/dist/agentic.iife.js +5 -0
  34. package/dist/{api-paths-CwzwbgQZ.js → api-paths-C4WzXzyY.js} +1 -1
  35. package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
  36. package/dist/chat/api.d.ts +17 -0
  37. package/dist/chat/assistant-mode.d.ts +20 -0
  38. package/dist/chat/attachment-utils.d.ts +9 -0
  39. package/dist/chat/catalog.d.ts +455 -0
  40. package/dist/chat/chat-presentation-state.d.ts +53 -0
  41. package/dist/chat/components/AIGroupingCards.d.ts +15 -0
  42. package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
  43. package/dist/chat/components/AITopPicks.d.ts +9 -0
  44. package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
  45. package/dist/chat/components/CategoriesContainer.d.ts +11 -0
  46. package/dist/chat/components/ChatDrawer.d.ts +362 -0
  47. package/dist/chat/components/ChoicePrompter.d.ts +21 -0
  48. package/dist/chat/components/ComparisonTable.d.ts +66 -0
  49. package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
  50. package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
  51. package/dist/chat/components/FloatingLauncher.d.ts +79 -0
  52. package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
  53. package/dist/chat/components/HandoffNotice.d.ts +9 -0
  54. package/dist/chat/components/KvkkBanner.d.ts +6 -0
  55. package/dist/chat/components/Launcher.d.ts +28 -0
  56. package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
  57. package/dist/chat/components/PanelTopBar.d.ts +32 -0
  58. package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
  59. package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
  60. package/dist/chat/components/ProsAndCons.d.ts +8 -0
  61. package/dist/chat/components/ReviewHighlights.d.ts +16 -0
  62. package/dist/chat/components/actionClassifier.d.ts +12 -0
  63. package/dist/chat/components/product-price-layout.d.ts +17 -0
  64. package/dist/chat/components/productMentionLinker.d.ts +26 -0
  65. package/dist/chat/components/renderUISpec.d.ts +15 -0
  66. package/dist/chat/components/typewriter.d.ts +24 -0
  67. package/dist/chat/extendedModeManager.d.ts +32 -0
  68. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
  69. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
  70. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
  71. package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
  72. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
  73. package/dist/chat/history-storage.d.ts +85 -0
  74. package/dist/chat/index.d.ts +6 -0
  75. package/dist/chat/kvkk.d.ts +20 -0
  76. package/dist/chat/locales/en.d.ts +2 -0
  77. package/dist/chat/locales/index.d.ts +5 -0
  78. package/dist/chat/locales/tr.d.ts +2 -0
  79. package/dist/chat/panel-manager.d.ts +142 -0
  80. package/dist/chat/runtime.d.ts +417 -0
  81. package/dist/chat/session-persistence.d.ts +73 -0
  82. package/dist/chat/stream-error-display.d.ts +6 -0
  83. package/dist/chat/types.d.ts +547 -0
  84. package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
  85. package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
  86. package/dist/chat/utils/ui.d.ts +10 -0
  87. package/dist/chat-runtime.js +1 -1
  88. package/dist/chat.iife.js +12 -12
  89. package/dist/chat.js +1 -1
  90. package/dist/common/action-router.d.ts +26 -0
  91. package/dist/common/api-paths.d.ts +23 -0
  92. package/dist/common/client.d.ts +27 -0
  93. package/dist/common/communication-bridge.d.ts +51 -0
  94. package/dist/common/config-constants.d.ts +1 -0
  95. package/dist/common/config-schema.d.ts +54 -0
  96. package/dist/common/connection-warning.d.ts +8 -0
  97. package/dist/common/consulting-sources.d.ts +8 -0
  98. package/dist/common/context.d.ts +64 -0
  99. package/dist/common/css-escape.d.ts +1 -0
  100. package/dist/common/customization-factories.d.ts +59 -0
  101. package/dist/common/debug.d.ts +13 -0
  102. package/dist/common/events.d.ts +55 -0
  103. package/dist/common/fastIntent.d.ts +1 -0
  104. package/dist/common/find-similar-payload.d.ts +3 -0
  105. package/dist/common/ga-datalayer.d.ts +80 -0
  106. package/dist/common/global-error-toast.d.ts +6 -0
  107. package/dist/common/index.d.ts +47 -0
  108. package/dist/common/indexed-db.d.ts +89 -0
  109. package/dist/common/locale.d.ts +1 -0
  110. package/dist/common/native-webview.d.ts +60 -0
  111. package/dist/common/navigation.d.ts +1 -0
  112. package/dist/common/overlay.d.ts +172 -0
  113. package/dist/common/page-detect.d.ts +36 -0
  114. package/dist/common/pill-launcher.d.ts +51 -0
  115. package/dist/common/preflight.d.ts +13 -0
  116. package/dist/common/price-formatter.d.ts +35 -0
  117. package/dist/common/product-utils.d.ts +35 -0
  118. package/dist/common/protocol-adapter.d.ts +108 -0
  119. package/dist/common/renderer/dom.d.ts +3 -0
  120. package/dist/common/renderer/index.d.ts +4 -0
  121. package/dist/common/renderer/overrides.d.ts +23 -0
  122. package/dist/common/renderer/registry.d.ts +2 -0
  123. package/dist/common/renderer/types.d.ts +19 -0
  124. package/dist/common/safe-html.d.ts +22 -0
  125. package/dist/common/sdk-version.d.ts +3 -0
  126. package/dist/common/streaming.d.ts +52 -0
  127. package/dist/common/suggested-search-keywords.d.ts +18 -0
  128. package/dist/common/theme-utils.d.ts +15 -0
  129. package/dist/common/transport.d.ts +75 -0
  130. package/dist/common/tts-player.d.ts +13 -0
  131. package/dist/common/types.d.ts +379 -0
  132. package/dist/common/ui-theme.d.ts +9 -0
  133. package/dist/common/uuidv7.d.ts +7 -0
  134. package/dist/common/voice-input.d.ts +74 -0
  135. package/dist/common/widget-base.d.ts +82 -0
  136. package/dist/{common-KpJP1YwP.js → common-DstAcheX.js} +90 -139
  137. package/dist/common.js +41 -41
  138. package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Ddr91Y9x.js} +1 -1
  139. package/dist/{fastIntent--Ukm2nOh.js → fastIntent-XtUvISni.js} +199 -137
  140. package/dist/index.d.ts +25 -0
  141. package/dist/index.js +50 -50
  142. package/dist/native/index.d.ts +2 -0
  143. package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
  144. package/dist/native.iife.js +14 -14
  145. package/dist/native.js +1 -1
  146. package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
  147. package/dist/overlay.d.ts +4 -0
  148. package/dist/overlay.js +1 -1
  149. package/dist/qna/api.d.ts +23 -0
  150. package/dist/qna/catalog.d.ts +60 -0
  151. package/dist/qna/components/ButtonRow.d.ts +15 -0
  152. package/dist/qna/components/TextInput.d.ts +11 -0
  153. package/dist/qna/components/renderUISpec.d.ts +7 -0
  154. package/dist/qna/index.d.ts +3 -0
  155. package/dist/qna/locales/en.d.ts +2 -0
  156. package/dist/qna/locales/index.d.ts +4 -0
  157. package/dist/qna/locales/tr.d.ts +2 -0
  158. package/dist/qna/normalize-ui-specs.d.ts +15 -0
  159. package/dist/qna/runtime.d.ts +73 -0
  160. package/dist/qna/types.d.ts +98 -0
  161. package/dist/qna-runtime.js +1 -1
  162. package/dist/qna.iife.js +1 -1
  163. package/dist/qna.js +1 -1
  164. package/dist/{runtime-G3idwfkM.js → runtime-C66Wp6OR.js} +967 -923
  165. package/dist/{runtime-C3yOvNFK.js → runtime-CcA_r8pw.js} +3 -3
  166. package/dist/{runtime-BPyXOyyp.js → runtime-DJMUL882.js} +3 -3
  167. package/dist/simbut/index.d.ts +31 -0
  168. package/dist/simbut/locales.d.ts +3 -0
  169. package/dist/simbut/types.d.ts +43 -0
  170. package/dist/{simbut-CiknJI6-.js → simbut-B6L3fwI7.js} +1 -1
  171. package/dist/simbut.iife.js +1 -1
  172. package/dist/simbut.js +1 -1
  173. package/dist/simrel/api.d.ts +25 -0
  174. package/dist/simrel/catalog.d.ts +77 -0
  175. package/dist/simrel/components/GroupTabs.d.ts +24 -0
  176. package/dist/simrel/components/ProductCard.d.ts +19 -0
  177. package/dist/simrel/components/ProductGrid.d.ts +17 -0
  178. package/dist/simrel/components/renderUISpec.d.ts +7 -0
  179. package/dist/simrel/index.d.ts +5 -0
  180. package/dist/simrel/locales/en.d.ts +2 -0
  181. package/dist/simrel/locales/index.d.ts +4 -0
  182. package/dist/simrel/locales/tr.d.ts +2 -0
  183. package/dist/simrel/renderers/default.d.ts +41 -0
  184. package/dist/simrel/runtime.d.ts +68 -0
  185. package/dist/simrel/types.d.ts +145 -0
  186. package/dist/{simrel-C1YN71aW.js → simrel-BB4Jrr32.js} +1 -1
  187. package/dist/simrel-runtime.js +1 -1
  188. package/dist/simrel.iife.js +1 -1
  189. package/dist/simrel.js +2 -2
  190. package/dist/{widget-base-UmvgIqDk.js → widget-base-B3Oq8pjs.js} +1 -1
  191. package/package.json +21 -39
@@ -1,131 +1,187 @@
1
1
  import { j as S } from "./context-BBuSsXZ9.js";
2
- import { i as I } from "./widget-base-UmvgIqDk.js";
3
- function E(t, n) {
2
+ import { i as E } from "./widget-base-B3Oq8pjs.js";
3
+ function $(t, r) {
4
4
  if (typeof window > "u" || !S(t)) return !1;
5
- const r = new CustomEvent("gengage:navigate", {
6
- detail: n === void 0 ? { url: t } : {
5
+ const e = new CustomEvent("gengage:navigate", {
6
+ detail: r === void 0 ? { url: t } : {
7
7
  url: t,
8
- newTab: n
8
+ newTab: r
9
9
  },
10
10
  cancelable: !0
11
11
  });
12
- return window.dispatchEvent(r) ? (n ? window.open(t, "_blank", "noopener,noreferrer") : window.location.href = t, !0) : !1;
12
+ return window.dispatchEvent(e) ? (r ? window.open(t, "_blank", "noopener,noreferrer") : window.location.href = t, !0) : !1;
13
13
  }
14
- var $ = console;
15
- function W(t, n, r = {}) {
16
- const e = t.action, a = r.logger ?? $;
17
- switch (I("action", `routing action: ${e.kind}`, e), e.kind) {
14
+ var U = console;
15
+ function Z(t, r, e = {}) {
16
+ const n = t.action, i = e.logger ?? U;
17
+ switch (E("action", `routing action: ${n.kind}`, n), n.kind) {
18
18
  case "open_chat":
19
- n.openChat?.(e.payload);
19
+ r.openChat?.(n.payload);
20
20
  return;
21
21
  case "navigate": {
22
- if (typeof e.url != "string") {
23
- h(e, n, r, a);
22
+ if (typeof n.url != "string") {
23
+ g(n, r, e, i);
24
24
  return;
25
25
  }
26
- if (!S(e.url)) {
27
- a.warn("[gengage] Blocked navigation to unsafe URL:", e.url);
26
+ if (!S(n.url)) {
27
+ i.warn("[gengage] Blocked navigation to unsafe URL:", n.url);
28
28
  return;
29
29
  }
30
- const i = typeof e.newTab == "boolean" ? e.newTab : void 0;
31
- if (n.navigate) {
32
- n.navigate({
33
- url: e.url,
34
- ...i !== void 0 && { newTab: i }
30
+ const a = typeof n.newTab == "boolean" ? n.newTab : void 0;
31
+ if (r.navigate) {
32
+ r.navigate({
33
+ url: n.url,
34
+ ...a !== void 0 && { newTab: a }
35
35
  });
36
36
  return;
37
37
  }
38
- (r.defaultNavigate ?? L)(e.url, i);
38
+ (e.defaultNavigate ?? L)(n.url, a);
39
39
  return;
40
40
  }
41
41
  case "save_session":
42
- if (typeof e.sessionId != "string" || typeof e.sku != "string") {
43
- h(e, n, r, a);
42
+ if (typeof n.sessionId != "string" || typeof n.sku != "string") {
43
+ g(n, r, e, i);
44
44
  return;
45
45
  }
46
- n.saveSession?.({
47
- sessionId: e.sessionId,
48
- sku: e.sku
46
+ r.saveSession?.({
47
+ sessionId: n.sessionId,
48
+ sku: n.sku
49
49
  });
50
50
  return;
51
51
  case "add_to_cart":
52
- if (typeof e.sku != "string" || typeof e.quantity != "number" || typeof e.cartCode != "string") {
53
- h(e, n, r, a);
52
+ if (typeof n.sku != "string" || typeof n.quantity != "number" || typeof n.cartCode != "string") {
53
+ g(n, r, e, i);
54
54
  return;
55
55
  }
56
- n.addToCart?.({
57
- sku: e.sku,
58
- quantity: e.quantity,
59
- cartCode: e.cartCode
56
+ r.addToCart?.({
57
+ sku: n.sku,
58
+ quantity: n.quantity,
59
+ cartCode: n.cartCode
60
60
  });
61
61
  return;
62
62
  case "script_call": {
63
- if (r.allowScriptCall === !1) {
64
- h(e, n, r, a);
63
+ if (e.allowScriptCall === !1) {
64
+ g(n, r, e, i);
65
65
  return;
66
66
  }
67
- if (typeof e.name != "string") {
68
- h(e, n, r, a);
67
+ if (typeof n.name != "string") {
68
+ g(n, r, e, i);
69
69
  return;
70
70
  }
71
- const i = U(e.payload) ? e.payload : void 0;
72
- n.scriptCall?.({
73
- name: e.name,
74
- ...i !== void 0 && { payload: i }
71
+ const a = j(n.payload) ? n.payload : void 0;
72
+ r.scriptCall?.({
73
+ name: n.name,
74
+ ...a !== void 0 && { payload: a }
75
75
  });
76
76
  return;
77
77
  }
78
78
  default:
79
- h(e, n, r, a);
79
+ g(n, r, e, i);
80
80
  }
81
81
  }
82
- function h(t, n, r, e) {
83
- const a = r.unknownActionPolicy ?? "log-and-ignore";
84
- if (a === "delegate") {
85
- n.unknown?.(t), n.unknown || e.warn("[gengage] Unknown action received without delegate handler", t);
82
+ function g(t, r, e, n) {
83
+ const i = e.unknownActionPolicy ?? "log-and-ignore";
84
+ if (i === "delegate") {
85
+ r.unknown?.(t), r.unknown || n.warn("[gengage] Unknown action received without delegate handler", t);
86
86
  return;
87
87
  }
88
- if (a === "throw") throw new Error(`[gengage] Unknown action kind: ${t.kind}`);
89
- e.warn("[gengage] Unknown action ignored", t);
88
+ if (i === "throw") throw new Error(`[gengage] Unknown action kind: ${t.kind}`);
89
+ n.warn("[gengage] Unknown action ignored", t);
90
90
  }
91
- function L(t, n) {
91
+ function L(t, r) {
92
92
  if (!(typeof window > "u")) {
93
93
  if (!S(t)) {
94
94
  console.warn("[gengage] Blocked navigation to unsafe URL:", t);
95
95
  return;
96
96
  }
97
- E(t, n);
97
+ $(t, r);
98
98
  }
99
99
  }
100
- function U(t) {
100
+ function j(t) {
101
101
  return typeof t == "object" && t !== null && !Array.isArray(t);
102
102
  }
103
- function q(t) {
104
- const n = globalThis.CSS?.escape;
105
- if (typeof n == "function") return n(t);
106
- const r = Array.from(t);
107
- return r.map((e, a) => {
108
- const i = e.codePointAt(0);
109
- return i === void 0 ? "" : i === 0 ? "�" : i >= 1 && i <= 31 || i === 127 || a === 0 && i >= 48 && i <= 57 || a === 1 && r[0] === "-" && i >= 48 && i <= 57 ? `\\${i.toString(16)} ` : a === 0 && e === "-" && r.length === 1 ? "\\-" : i >= 128 || /[A-Za-z0-9_-]/.test(e) ? e : `\\${e}`;
103
+ function D(t) {
104
+ const r = globalThis.CSS?.escape;
105
+ if (typeof r == "function") return r(t);
106
+ const e = Array.from(t);
107
+ return e.map((n, i) => {
108
+ const a = n.codePointAt(0);
109
+ return a === void 0 ? "" : a === 0 ? "�" : a >= 1 && a <= 31 || a === 127 || i === 0 && a >= 48 && a <= 57 || i === 1 && e[0] === "-" && a >= 48 && a <= 57 ? `\\${a.toString(16)} ` : i === 0 && n === "-" && e.length === 1 ? "\\-" : a >= 128 || /[A-Za-z0-9_-]/.test(n) ? n : `\\${n}`;
110
110
  }).join("");
111
111
  }
112
- function Y() {
113
- return C() !== null;
112
+ var Q = "tr";
113
+ function P(t) {
114
+ if (!(typeof window > "u" || !t))
115
+ try {
116
+ const r = window.GengageAssistantInjector?.[t]?.streamTransport;
117
+ return typeof r == "function" ? r : void 0;
118
+ } catch {
119
+ return;
120
+ }
121
+ }
122
+ function k(t) {
123
+ return t.injectorAdapter ?? P(t.accountId);
124
+ }
125
+ function X(t) {
126
+ return {
127
+ ACCOUNT_ID: t.accountId,
128
+ MIDDLEWARE_URL: t.middlewareUrl,
129
+ LOCALE: t.locale ?? "tr"
130
+ };
114
131
  }
115
- function C() {
132
+ function J(t, r = {}) {
133
+ const e = {
134
+ accountId: t.accountId,
135
+ middlewareUrl: t.middlewareUrl,
136
+ session: { sessionId: t.sessionId },
137
+ variant: "floating",
138
+ locale: t.locale ?? "tr",
139
+ ...r
140
+ }, n = k(t);
141
+ return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
142
+ }
143
+ function tt(t, r = {}) {
144
+ const e = {
145
+ accountId: t.accountId,
146
+ middlewareUrl: t.middlewareUrl,
147
+ session: { sessionId: t.sessionId },
148
+ pageContext: {
149
+ pageType: "pdp",
150
+ sku: t.sku
151
+ },
152
+ mountTarget: t.mountTarget,
153
+ ...r
154
+ }, n = k(t);
155
+ return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
156
+ }
157
+ function et(t, r = {}) {
158
+ const e = {
159
+ accountId: t.accountId,
160
+ middlewareUrl: t.middlewareUrl,
161
+ session: { sessionId: t.sessionId },
162
+ sku: t.sku,
163
+ mountTarget: t.mountTarget,
164
+ ...r
165
+ }, n = k(t);
166
+ return n !== void 0 && (e.injectorAdapter = n), t.theme !== void 0 && (e.theme = t.theme), e;
167
+ }
168
+ function nt() {
169
+ return x() !== null;
170
+ }
171
+ function x() {
116
172
  const t = globalThis;
117
173
  return t.SpeechRecognition ?? t.webkitSpeechRecognition ?? null;
118
174
  }
119
- var X = class {
120
- constructor(t, n) {
121
- this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this._lastRestartAt = 0, this.callbacks = t, this.lang = n?.lang ?? "tr-TR", this.silenceTimeoutMs = n?.silenceTimeoutMs ?? 1500, this.autoSubmit = n?.autoSubmit ?? !0;
175
+ var rt = class {
176
+ constructor(t, r) {
177
+ this.recognition = null, this._state = "idle", this.silenceTimer = null, this.accumulatedTranscript = "", this.intentionalStop = !1, this._lastRestartAt = 0, this.callbacks = t, this.lang = r?.lang ?? "tr-TR", this.silenceTimeoutMs = r?.silenceTimeoutMs ?? 1500, this.autoSubmit = r?.autoSubmit ?? !0;
122
178
  }
123
179
  get state() {
124
180
  return this._state;
125
181
  }
126
182
  start() {
127
183
  if (this._state === "listening") return;
128
- const t = C();
184
+ const t = x();
129
185
  if (!t) {
130
186
  this.setState("error"), this.callbacks.onError?.("not-supported", "Web Speech API is not supported in this browser.");
131
187
  return;
@@ -135,41 +191,41 @@ var X = class {
135
191
  return;
136
192
  }
137
193
  this.accumulatedTranscript = "", this.intentionalStop = !1;
138
- const n = new t();
139
- n.continuous = !0, n.interimResults = !0, n.lang = this.lang, n.maxAlternatives = 1, n.onstart = () => {
194
+ const r = new t();
195
+ r.continuous = !0, r.interimResults = !0, r.lang = this.lang, r.maxAlternatives = 1, r.onstart = () => {
140
196
  this.setState("listening");
141
- }, n.onresult = (r) => {
197
+ }, r.onresult = (e) => {
142
198
  this.clearSilenceTimer();
143
- let e = "", a = "";
144
- for (let i = r.resultIndex; i < r.results.length; i++) {
145
- const u = r.results[i];
199
+ let n = "", i = "";
200
+ for (let a = e.resultIndex; a < e.results.length; a++) {
201
+ const u = e.results[a];
146
202
  if (!u) continue;
147
- const g = u[0];
148
- g && (u.isFinal ? a += g.transcript : e += g.transcript);
203
+ const p = u[0];
204
+ p && (u.isFinal ? i += p.transcript : n += p.transcript);
149
205
  }
150
- a && (this.accumulatedTranscript += a, this.callbacks.onFinal?.(this.accumulatedTranscript)), e && this.callbacks.onInterim?.(this.accumulatedTranscript + e), this.autoSubmit && this.accumulatedTranscript && this.startSilenceTimer();
151
- }, n.onerror = (r) => {
152
- const e = P(r.error);
153
- this.intentionalStop && (r.error === "no-speech" || r.error === "aborted") || (this.setState("error"), this.callbacks.onError?.(e, r.message || r.error));
154
- }, n.onend = () => {
206
+ i && (this.accumulatedTranscript += i, this.callbacks.onFinal?.(this.accumulatedTranscript)), n && this.callbacks.onInterim?.(this.accumulatedTranscript + n), this.autoSubmit && this.accumulatedTranscript && this.startSilenceTimer();
207
+ }, r.onerror = (e) => {
208
+ const n = q(e.error);
209
+ this.intentionalStop && (e.error === "no-speech" || e.error === "aborted") || (this.setState("error"), this.callbacks.onError?.(n, e.message || e.error));
210
+ }, r.onend = () => {
155
211
  if (this.clearSilenceTimer(), this._state === "listening" && !this.intentionalStop) {
156
- const r = Date.now();
157
- if (r - this._lastRestartAt < 500) {
212
+ const e = Date.now();
213
+ if (e - this._lastRestartAt < 500) {
158
214
  this.setState("idle");
159
215
  return;
160
216
  }
161
- this._lastRestartAt = r;
217
+ this._lastRestartAt = e;
162
218
  try {
163
- n.start();
219
+ r.start();
164
220
  } catch {
165
221
  this.setState("idle");
166
222
  }
167
223
  return;
168
224
  }
169
225
  this.setState("idle");
170
- }, this.recognition = n;
226
+ }, this.recognition = r;
171
227
  try {
172
- n.start();
228
+ r.start();
173
229
  } catch {
174
230
  this.setState("error"), this.callbacks.onError?.("unknown", "Failed to start speech recognition.");
175
231
  }
@@ -210,7 +266,7 @@ var X = class {
210
266
  this.silenceTimer !== null && (clearTimeout(this.silenceTimer), this.silenceTimer = null);
211
267
  }
212
268
  };
213
- function P(t) {
269
+ function q(t) {
214
270
  switch (t) {
215
271
  case "not-allowed":
216
272
  return "not-allowed";
@@ -226,19 +282,19 @@ function P(t) {
226
282
  return "unknown";
227
283
  }
228
284
  }
229
- function Z(t) {
230
- const { label: n, avatarUrl: r, primaryColor: e, secondaryColor: a = "#111827", fontFamily: i = "inherit", labelClassName: u = "gengage-pill-launcher-label", styleId: g = "gengage-pill-launcher-style", mobileBreakpoint: _ = 768, desktopWidth: d = "188px", desktopHeight: w = "60px", iconSize: m = "46px" } = t, T = `${parseInt(d, 10) - 14}px`, k = `${parseInt(w, 10) - 4}px`, y = `${parseInt(m, 10) - 4}px`, R = `
285
+ function at(t) {
286
+ const { label: r, avatarUrl: e, primaryColor: n, secondaryColor: i = "#111827", fontFamily: a = "inherit", labelClassName: u = "gengage-pill-launcher-label", styleId: p = "gengage-pill-launcher-style", mobileBreakpoint: A = 768, desktopWidth: m = "188px", desktopHeight: w = "60px", iconSize: h = "46px" } = t, T = `${parseInt(m, 10) - 14}px`, v = `${parseInt(w, 10) - 4}px`, y = `${parseInt(h, 10) - 4}px`, _ = `
231
287
  :host {
232
- --pill-primary: ${e};
233
- --pill-secondary: ${a};
234
- --pill-font: ${i};
288
+ --pill-primary: ${n};
289
+ --pill-secondary: ${i};
290
+ --pill-font: ${a};
235
291
  }
236
292
 
237
293
  button[data-gengage-part="chat-launcher-button"] {
238
294
  box-sizing: border-box;
239
- width: ${d} !important;
240
- min-width: ${d} !important;
241
- max-width: ${d} !important;
295
+ width: ${m} !important;
296
+ min-width: ${m} !important;
297
+ max-width: ${m} !important;
242
298
  height: ${w} !important;
243
299
  min-height: ${w} !important;
244
300
  padding: 6px 7px 6px 22px !important;
@@ -274,9 +330,9 @@ button[data-gengage-part="chat-launcher-button"]:hover {
274
330
  }
275
331
 
276
332
  button[data-gengage-part="chat-launcher-button"] img {
277
- width: ${m} !important;
278
- height: ${m} !important;
279
- flex: 0 0 ${m} !important;
333
+ width: ${h} !important;
334
+ height: ${h} !important;
335
+ flex: 0 0 ${h} !important;
280
336
  border-radius: 999px;
281
337
  object-fit: cover;
282
338
  object-position: center;
@@ -285,13 +341,13 @@ button[data-gengage-part="chat-launcher-button"] img {
285
341
  box-shadow: none !important;
286
342
  }
287
343
 
288
- @media (max-width: ${_}px) {
344
+ @media (max-width: ${A}px) {
289
345
  button[data-gengage-part="chat-launcher-button"] {
290
346
  width: ${T} !important;
291
347
  min-width: ${T} !important;
292
348
  max-width: ${T} !important;
293
- height: ${k} !important;
294
- min-height: ${k} !important;
349
+ height: ${v} !important;
350
+ min-height: ${v} !important;
295
351
  padding-left: 20px !important;
296
352
  padding-right: 7px !important;
297
353
  }
@@ -306,7 +362,7 @@ button[data-gengage-part="chat-launcher-button"] img {
306
362
  flex-basis: ${y} !important;
307
363
  }
308
364
  }
309
- `.trim(), x = () => {
365
+ `.trim(), I = () => {
310
366
  for (const o of document.querySelectorAll("[data-gengage-widget]")) {
311
367
  if (!(o instanceof HTMLElement)) continue;
312
368
  const s = o.shadowRoot;
@@ -315,46 +371,46 @@ button[data-gengage-part="chat-launcher-button"] img {
315
371
  }
316
372
  return null;
317
373
  }, f = (o) => {
318
- if (o.getElementById(g)) return;
374
+ if (o.getElementById(p)) return;
319
375
  const s = document.createElement("style");
320
- s.id = g, s.textContent = R, o.appendChild(s);
321
- }, A = q(u), v = (o) => {
376
+ s.id = p, s.textContent = _, o.appendChild(s);
377
+ }, R = D(u), C = (o) => {
322
378
  f(o);
323
379
  const s = o.querySelector('[data-gengage-part="chat-launcher-button"]');
324
380
  if (!(s instanceof HTMLButtonElement)) return !1;
325
- const l = o.querySelector('[data-gengage-part="chat-header-avatar"]');
326
- if (l instanceof HTMLImageElement) {
381
+ const c = o.querySelector('[data-gengage-part="chat-header-avatar"]');
382
+ if (c instanceof HTMLImageElement) {
327
383
  const b = o.querySelector('[data-gengage-part="chat-launcher-button"] img');
328
- (!b || l.src === b.src) && l.classList.remove("gengage-chat-header-avatar--logo");
384
+ (!b || c.src === b.src) && c.classList.remove("gengage-chat-header-avatar--logo");
329
385
  }
330
- if (s.querySelector(`.${A}`)) return !0;
331
- s.setAttribute("aria-label", n);
332
- const c = document.createElement("span");
333
- return c.className = u, c.textContent = n, s.appendChild(c), !0;
386
+ if (s.querySelector(`.${R}`)) return !0;
387
+ s.setAttribute("aria-label", r);
388
+ const l = document.createElement("span");
389
+ return l.className = u, l.textContent = r, s.appendChild(l), !0;
334
390
  };
335
391
  return {
336
- launcherImageUrl: r,
392
+ launcherImageUrl: e,
337
393
  apply: async (o) => {
338
394
  if (o) {
339
395
  f(o), await Promise.resolve();
340
- for (let l = 0; l < 90; l++) {
341
- if (v(o)) return;
342
- await new Promise((c) => requestAnimationFrame(() => c()));
396
+ for (let c = 0; c < 90; c++) {
397
+ if (C(o)) return;
398
+ await new Promise((l) => requestAnimationFrame(() => l()));
343
399
  }
344
400
  return;
345
401
  }
346
- const s = x();
402
+ const s = I();
347
403
  s?.shadowRoot && f(s.shadowRoot), await Promise.resolve();
348
- for (let l = 0; l < 90; l++) {
349
- const c = x()?.shadowRoot ?? null;
350
- if (c && (f(c), v(c)))
404
+ for (let c = 0; c < 90; c++) {
405
+ const l = I()?.shadowRoot ?? null;
406
+ if (l && (f(l), C(l)))
351
407
  return;
352
408
  await new Promise((b) => requestAnimationFrame(() => b()));
353
409
  }
354
410
  }
355
411
  };
356
412
  }
357
- var D = 96, p = {
413
+ var N = 96, d = {
358
414
  leadingTokens: [
359
415
  "bana",
360
416
  "beni",
@@ -396,28 +452,34 @@ var D = 96, p = {
396
452
  "alsana"
397
453
  ],
398
454
  compactBuyVerbs: ["satinal", "satinalsana"]
399
- }, B = new Set(p.leadingTokens), N = new Set(p.trailingTokens), V = new Set(p.cartTargets), F = new Set(p.cartVerbs), H = new Set(p.buyVerbs), z = new Set(p.compactBuyVerbs);
400
- function M(t) {
455
+ }, F = new Set(d.leadingTokens), B = new Set(d.trailingTokens), V = new Set(d.cartTargets), H = new Set(d.cartVerbs), M = new Set(d.buyVerbs), O = new Set(d.compactBuyVerbs);
456
+ function z(t) {
401
457
  return t.toLocaleLowerCase("tr-TR").replace(/ç/g, "c").replace(/ğ/g, "g").replace(/ı/g, "i").replace(/ö/g, "o").replace(/ş/g, "s").replace(/ü/g, "u").replace(/[^a-z0-9]+/g, " ").trim().replace(/\s+/g, " ");
402
458
  }
403
- function j(t) {
404
- if (!t.trim() || t.length > D || /[??]/.test(t)) return !1;
405
- const n = M(t);
406
- if (!n || p.negativePattern.test(n)) return !1;
407
- const r = n.split(" ");
408
- for (; r.length > 0 && B.has(r[0]); ) r.shift();
409
- for (; r.length > 0 && N.has(r[r.length - 1]); ) r.pop();
410
- return r.length === 1 ? z.has(r[0]) : r.length !== 2 ? !1 : V.has(r[0]) && F.has(r[1]) ? !0 : r[0] === "satin" && H.has(r[1]);
459
+ function G(t) {
460
+ if (!t.trim() || t.length > N || /[??]/.test(t)) return !1;
461
+ const r = z(t);
462
+ if (!r || d.negativePattern.test(r)) return !1;
463
+ const e = r.split(" ");
464
+ for (; e.length > 0 && F.has(e[0]); ) e.shift();
465
+ for (; e.length > 0 && B.has(e[e.length - 1]); ) e.pop();
466
+ return e.length === 1 ? O.has(e[0]) : e.length !== 2 ? !1 : V.has(e[0]) && H.has(e[1]) ? !0 : e[0] === "satin" && M.has(e[1]);
411
467
  }
412
- function J(t) {
413
- return j(t) ? "directAddToCart" : null;
468
+ function it(t) {
469
+ return G(t) ? "directAddToCart" : null;
414
470
  }
415
471
  export {
416
- q as a,
417
- Y as i,
418
- Z as n,
419
- W as o,
420
- X as r,
421
- E as s,
422
- J as t
472
+ Q as a,
473
+ tt as c,
474
+ D as d,
475
+ Z as f,
476
+ nt as i,
477
+ et as l,
478
+ at as n,
479
+ X as o,
480
+ $ as p,
481
+ rt as r,
482
+ J as s,
483
+ it as t,
484
+ P as u
423
485
  };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * gengage-assistant-fe — top-level barrel export.
3
+ *
4
+ * Import the whole library:
5
+ * import { GengageChat, GengageQNA, GengageSimRel, bootstrapSession } from '@gengage/assistant-fe';
6
+ *
7
+ * Or import individual widgets for smaller bundles:
8
+ * import { GengageChat } from '@gengage/assistant-fe/chat';
9
+ * import { GengageQNA } from '@gengage/assistant-fe/qna';
10
+ * import { GengageSimRel } from '@gengage/assistant-fe/simrel';
11
+ */
12
+ export { GengageChat, createChatWidget } from './chat/index.js';
13
+ export { GengageQNA, createQNAWidget } from './qna/index.js';
14
+ export { GengageSimRel, createSimRelWidget, createSimRelRenderer } from './simrel/index.js';
15
+ export { GengageSimBut, createSimButWidget } from './simbut/index.js';
16
+ export { renderUISpec as renderChatUISpec, createDefaultChatUISpecRegistry, defaultChatUnknownUISpecRenderer, } from './chat/index.js';
17
+ export { renderQnaUISpec, createDefaultQnaUISpecRegistry, defaultQnaUnknownUISpecRenderer } from './qna/index.js';
18
+ export { renderSimRelUISpec, createDefaultSimRelUISpecRegistry, defaultSimRelUnknownUISpecRenderer, } from './simrel/index.js';
19
+ export { GENGAGE_VERSION, GENGAGE_BUILD_FLAVOR, bootstrapSession, updatePageContext, initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey, detectNativeEnvironment, applyNativeSession, createNativeWebViewBridge, initNativeOverlayWidgets, wireQNAToChat, wireSimilarToChat, dispatch, listen, consumeStream, streamPost, buildChatEndpointUrl, normalizeMiddlewareUrl, routeStreamAction, renderUISpecWithRegistry, defaultUnknownUISpecRenderer, BASE_WIDGET_THEME, withBaseTheme, DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme, DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, AccountRuntimeConfigSchema, UnknownActionPolicySchema, initGengageClient, preflightDiagnostics, wireGADataLayer, isVoiceInputSupported, VoiceInput, detectPageType, extractSkuFromUrl, autoDetectPageContext, configureConnectionWarning, makePillLauncher, } from './common/index.js';
20
+ export type { PageContext, SessionContext, BaseWidgetConfig, GengageWidget, StreamEvent, UISpec, UIElement, ActionPayload, GengageEventName, ChatPublicAPI, ChatTransportConfig, ChatEndpointName, ActionEnrichmentContext, BackendRequestMeta, InjectorAdapter, ProcessActionRequest, StreamCallbacks, AccountRuntimeConfig, UnknownActionPolicy, HostActionHandlers, ActionRouterOptions, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, OverlaySimButOptions, NativeBridgeEnvironment, NativeSessionPayload, NativeBridgeMessage, NativeWebViewBridgeOptions, NativeWebViewBridge, NativeOverlayInitOptions, NativeOverlayInitResult, AccountIdentityConfig, AccountIdentity, GengageClientOptions, HostActions, PreflightResult, PreflightWarning, WireQNAToChatOptions, VoiceInputState, VoiceInputErrorCode, VoiceInputCallbacks, VoiceInputOptions, DetectablePageType, PageDetectionRule, PillLauncherOptions, PillLauncherKit, } from './common/index.js';
21
+ export type { ChatWidgetConfig, ChatMessage, ChatSession, ChatI18n, ChatRendererConfig, FloatingLauncherOptions, } from './chat/index.js';
22
+ export type { ChatUISpecRegistry, UISpecRenderContext as ChatUISpecRenderContext } from './chat/index.js';
23
+ export type { QNAWidgetConfig, QNAI18n, QNAChromeLayout, QNAChromeConfig, QNAUISpecRenderContext, QNAUISpecRegistry, QNARendererConfig, } from './qna/index.js';
24
+ export type { SimRelWidgetConfig, SimilarProduct, SimRelI18n, SimRelUISpecRenderContext, SimRelUISpecRegistry, SimRelRendererConfig, SimRelFieldPath, SimRelRendererFields, SimRelRendererLabels, SimRelRendererMedia, SimRelRendererOptions, } from './simrel/index.js';
25
+ export type { SimButWidgetConfig, SimButI18n, SimButInlineCardConfig, SimButLayout } from './simbut/index.js';