@aigentyc/chat-sdk 0.1.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.
Files changed (162) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/dist/JsonRenderResult-Ftw4AKwb.d.cts +18 -0
  4. package/dist/JsonRenderResult-Ftw4AKwb.d.ts +18 -0
  5. package/dist/JsonRenderResult-GQOYPLVH.cjs +15 -0
  6. package/dist/JsonRenderResult-GQOYPLVH.cjs.map +1 -0
  7. package/dist/JsonRenderResult-ZFJ6VWMS.js +6 -0
  8. package/dist/JsonRenderResult-ZFJ6VWMS.js.map +1 -0
  9. package/dist/SlotsContext-CBtt36al.d.ts +148 -0
  10. package/dist/SlotsContext-CHvISDJT.d.cts +148 -0
  11. package/dist/VisualizationRenderer-FNFYNN66.js +5 -0
  12. package/dist/VisualizationRenderer-FNFYNN66.js.map +1 -0
  13. package/dist/VisualizationRenderer-VKMZXRUX.cjs +20 -0
  14. package/dist/VisualizationRenderer-VKMZXRUX.cjs.map +1 -0
  15. package/dist/ai-elements.cjs +4608 -0
  16. package/dist/ai-elements.cjs.map +1 -0
  17. package/dist/ai-elements.d.cts +897 -0
  18. package/dist/ai-elements.d.ts +897 -0
  19. package/dist/ai-elements.js +4363 -0
  20. package/dist/ai-elements.js.map +1 -0
  21. package/dist/chunk-3MP2EGEJ.cjs +270 -0
  22. package/dist/chunk-3MP2EGEJ.cjs.map +1 -0
  23. package/dist/chunk-3RW7O444.js +26 -0
  24. package/dist/chunk-3RW7O444.js.map +1 -0
  25. package/dist/chunk-42ARGQXE.js +51 -0
  26. package/dist/chunk-42ARGQXE.js.map +1 -0
  27. package/dist/chunk-4FBVV64J.js +257 -0
  28. package/dist/chunk-4FBVV64J.js.map +1 -0
  29. package/dist/chunk-4QT25AXI.js +21 -0
  30. package/dist/chunk-4QT25AXI.js.map +1 -0
  31. package/dist/chunk-525KS5HM.cjs +30 -0
  32. package/dist/chunk-525KS5HM.cjs.map +1 -0
  33. package/dist/chunk-5F3O3ZJH.js +299 -0
  34. package/dist/chunk-5F3O3ZJH.js.map +1 -0
  35. package/dist/chunk-5QSXB6UL.cjs +259 -0
  36. package/dist/chunk-5QSXB6UL.cjs.map +1 -0
  37. package/dist/chunk-5T4FJ2SR.js +664 -0
  38. package/dist/chunk-5T4FJ2SR.js.map +1 -0
  39. package/dist/chunk-7BNYTOTE.cjs +67 -0
  40. package/dist/chunk-7BNYTOTE.cjs.map +1 -0
  41. package/dist/chunk-AWAJOSFP.cjs +96 -0
  42. package/dist/chunk-AWAJOSFP.cjs.map +1 -0
  43. package/dist/chunk-BKDV2H6Z.js +224 -0
  44. package/dist/chunk-BKDV2H6Z.js.map +1 -0
  45. package/dist/chunk-FQN6OBGN.cjs +171 -0
  46. package/dist/chunk-FQN6OBGN.cjs.map +1 -0
  47. package/dist/chunk-FYPJSHCL.js +190 -0
  48. package/dist/chunk-FYPJSHCL.js.map +1 -0
  49. package/dist/chunk-J2H6MLQF.cjs +680 -0
  50. package/dist/chunk-J2H6MLQF.cjs.map +1 -0
  51. package/dist/chunk-J2K7EJYP.cjs +198 -0
  52. package/dist/chunk-J2K7EJYP.cjs.map +1 -0
  53. package/dist/chunk-JI5KCSOI.cjs +23 -0
  54. package/dist/chunk-JI5KCSOI.cjs.map +1 -0
  55. package/dist/chunk-JOO6C3XT.cjs +44 -0
  56. package/dist/chunk-JOO6C3XT.cjs.map +1 -0
  57. package/dist/chunk-KBGPBUTI.cjs +78 -0
  58. package/dist/chunk-KBGPBUTI.cjs.map +1 -0
  59. package/dist/chunk-MT2AMINB.js +75 -0
  60. package/dist/chunk-MT2AMINB.js.map +1 -0
  61. package/dist/chunk-MZQKGNWF.js +4 -0
  62. package/dist/chunk-MZQKGNWF.js.map +1 -0
  63. package/dist/chunk-NG7OTWXQ.cjs +226 -0
  64. package/dist/chunk-NG7OTWXQ.cjs.map +1 -0
  65. package/dist/chunk-NPJKLYLV.js +68 -0
  66. package/dist/chunk-NPJKLYLV.js.map +1 -0
  67. package/dist/chunk-NW2ESHRV.js +685 -0
  68. package/dist/chunk-NW2ESHRV.js.map +1 -0
  69. package/dist/chunk-NWF735F5.js +1631 -0
  70. package/dist/chunk-NWF735F5.js.map +1 -0
  71. package/dist/chunk-NYQSM3EB.cjs +305 -0
  72. package/dist/chunk-NYQSM3EB.cjs.map +1 -0
  73. package/dist/chunk-OU7OROOE.cjs +1643 -0
  74. package/dist/chunk-OU7OROOE.cjs.map +1 -0
  75. package/dist/chunk-PS3U7T37.js +42 -0
  76. package/dist/chunk-PS3U7T37.js.map +1 -0
  77. package/dist/chunk-Q7T3VAJV.cjs +687 -0
  78. package/dist/chunk-Q7T3VAJV.cjs.map +1 -0
  79. package/dist/chunk-QYCEHFAB.js +265 -0
  80. package/dist/chunk-QYCEHFAB.js.map +1 -0
  81. package/dist/chunk-RPDJXB3U.js +676 -0
  82. package/dist/chunk-RPDJXB3U.js.map +1 -0
  83. package/dist/chunk-UKEL7FWS.js +64 -0
  84. package/dist/chunk-UKEL7FWS.js.map +1 -0
  85. package/dist/chunk-VS3NZ7FX.js +164 -0
  86. package/dist/chunk-VS3NZ7FX.js.map +1 -0
  87. package/dist/chunk-WZLWAVSS.cjs +73 -0
  88. package/dist/chunk-WZLWAVSS.cjs.map +1 -0
  89. package/dist/chunk-X5YEOOPK.cjs +758 -0
  90. package/dist/chunk-X5YEOOPK.cjs.map +1 -0
  91. package/dist/chunk-X7R334SB.cjs +5 -0
  92. package/dist/chunk-X7R334SB.cjs.map +1 -0
  93. package/dist/chunk-XXNDL5SJ.cjs +432 -0
  94. package/dist/chunk-XXNDL5SJ.cjs.map +1 -0
  95. package/dist/chunk-YQELMJW5.js +429 -0
  96. package/dist/chunk-YQELMJW5.js.map +1 -0
  97. package/dist/components.cjs +551 -0
  98. package/dist/components.cjs.map +1 -0
  99. package/dist/components.d.cts +181 -0
  100. package/dist/components.d.ts +181 -0
  101. package/dist/components.js +483 -0
  102. package/dist/components.js.map +1 -0
  103. package/dist/core.cjs +283 -0
  104. package/dist/core.cjs.map +1 -0
  105. package/dist/core.d.cts +455 -0
  106. package/dist/core.d.ts +455 -0
  107. package/dist/core.js +241 -0
  108. package/dist/core.js.map +1 -0
  109. package/dist/hooks.cjs +324 -0
  110. package/dist/hooks.cjs.map +1 -0
  111. package/dist/hooks.d.cts +163 -0
  112. package/dist/hooks.d.ts +163 -0
  113. package/dist/hooks.js +277 -0
  114. package/dist/hooks.js.map +1 -0
  115. package/dist/i18n.cjs +26 -0
  116. package/dist/i18n.cjs.map +1 -0
  117. package/dist/i18n.d.cts +50 -0
  118. package/dist/i18n.d.ts +50 -0
  119. package/dist/i18n.js +5 -0
  120. package/dist/i18n.js.map +1 -0
  121. package/dist/index.cjs +466 -0
  122. package/dist/index.cjs.map +1 -0
  123. package/dist/index.d.cts +80 -0
  124. package/dist/index.d.ts +80 -0
  125. package/dist/index.js +438 -0
  126. package/dist/index.js.map +1 -0
  127. package/dist/interaction-tracker-D9P1Oq4j.d.cts +83 -0
  128. package/dist/interaction-tracker-D9P1Oq4j.d.ts +83 -0
  129. package/dist/json-render.cjs +23 -0
  130. package/dist/json-render.cjs.map +1 -0
  131. package/dist/json-render.d.cts +857 -0
  132. package/dist/json-render.d.ts +857 -0
  133. package/dist/json-render.js +6 -0
  134. package/dist/json-render.js.map +1 -0
  135. package/dist/live-chat-transport-4XLOIPOE.js +4 -0
  136. package/dist/live-chat-transport-4XLOIPOE.js.map +1 -0
  137. package/dist/live-chat-transport-ALVRGWX7.cjs +13 -0
  138. package/dist/live-chat-transport-ALVRGWX7.cjs.map +1 -0
  139. package/dist/select-B4l9yoyn.d.cts +99 -0
  140. package/dist/select-B4l9yoyn.d.ts +99 -0
  141. package/dist/styles.css +2 -0
  142. package/dist/theme.cjs +18 -0
  143. package/dist/theme.cjs.map +1 -0
  144. package/dist/theme.d.cts +55 -0
  145. package/dist/theme.d.ts +55 -0
  146. package/dist/theme.js +5 -0
  147. package/dist/theme.js.map +1 -0
  148. package/dist/tools.cjs +32 -0
  149. package/dist/tools.cjs.map +1 -0
  150. package/dist/tools.d.cts +117 -0
  151. package/dist/tools.d.ts +117 -0
  152. package/dist/tools.js +11 -0
  153. package/dist/tools.js.map +1 -0
  154. package/dist/types-DKJ_-nbG.d.cts +349 -0
  155. package/dist/types-DKJ_-nbG.d.ts +349 -0
  156. package/dist/ui.cjs +667 -0
  157. package/dist/ui.cjs.map +1 -0
  158. package/dist/ui.d.cts +95 -0
  159. package/dist/ui.d.ts +95 -0
  160. package/dist/ui.js +414 -0
  161. package/dist/ui.js.map +1 -0
  162. package/package.json +255 -0
@@ -0,0 +1,1643 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var chunkNYQSM3EB_cjs = require('./chunk-NYQSM3EB.cjs');
5
+ var chunk7BNYTOTE_cjs = require('./chunk-7BNYTOTE.cjs');
6
+ var chunkFQN6OBGN_cjs = require('./chunk-FQN6OBGN.cjs');
7
+ var chunk3MP2EGEJ_cjs = require('./chunk-3MP2EGEJ.cjs');
8
+ var chunkXXNDL5SJ_cjs = require('./chunk-XXNDL5SJ.cjs');
9
+ var chunkJ2K7EJYP_cjs = require('./chunk-J2K7EJYP.cjs');
10
+ var chunk525KS5HM_cjs = require('./chunk-525KS5HM.cjs');
11
+ var react = require('react');
12
+ var lucideReact = require('lucide-react');
13
+ var jsxRuntime = require('react/jsx-runtime');
14
+
15
+ function BotIcon({ className }) {
16
+ return /* @__PURE__ */ jsxRuntime.jsxs("svg", { className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
17
+ /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "8", width: "18", height: "12", rx: "2" }),
18
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "8.5", cy: "14", r: "1" }),
19
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "15.5", cy: "14", r: "1" }),
20
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 4v4" }),
21
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M8 2h8" })
22
+ ] });
23
+ }
24
+ var ChatHeader = react.memo(function ChatHeader2({
25
+ isWelcome = false,
26
+ onNewConversation,
27
+ onClose,
28
+ clientName,
29
+ logoUrl,
30
+ cartCount,
31
+ onCartClick
32
+ }) {
33
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
34
+ const ctx = chunkJ2K7EJYP_cjs.useChatContext();
35
+ const displayName = clientName || ctx.config.clientName || "AI Assistant";
36
+ const LogoOrIcon = () => {
37
+ if (logoUrl) {
38
+ return /* @__PURE__ */ jsxRuntime.jsx(
39
+ "img",
40
+ {
41
+ src: logoUrl,
42
+ alt: displayName,
43
+ className: "max-h-[40px] w-auto max-w-[120px] object-contain"
44
+ }
45
+ );
46
+ }
47
+ return /* @__PURE__ */ jsxRuntime.jsx(BotIcon, { className: "w-6 h-6" });
48
+ };
49
+ const SmallLogoOrIcon = () => {
50
+ if (logoUrl) {
51
+ return /* @__PURE__ */ jsxRuntime.jsx(
52
+ "img",
53
+ {
54
+ src: logoUrl,
55
+ alt: displayName,
56
+ className: "h-5 w-auto max-w-[100px] object-contain"
57
+ }
58
+ );
59
+ }
60
+ return /* @__PURE__ */ jsxRuntime.jsx(BotIcon, { className: "w-5 h-5" });
61
+ };
62
+ const handleCloseAction = () => {
63
+ onClose?.();
64
+ if (typeof document !== "undefined") {
65
+ const event = new CustomEvent("aigentyc:close-chat", {
66
+ bubbles: true,
67
+ composed: true
68
+ });
69
+ document.dispatchEvent(event);
70
+ }
71
+ };
72
+ if (isWelcome) {
73
+ return /* @__PURE__ */ jsxRuntime.jsxs(
74
+ "header",
75
+ {
76
+ className: "flex items-center justify-between px-6 py-4 border-b",
77
+ style: { background: "var(--ac-background)", borderColor: "var(--ac-border)" },
78
+ children: [
79
+ /* @__PURE__ */ jsxRuntime.jsx(
80
+ "button",
81
+ {
82
+ type: "button",
83
+ onClick: handleCloseAction,
84
+ className: "p-1 hover:bg-secondary rounded transition-colors",
85
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-6 h-6" })
86
+ }
87
+ ),
88
+ logoUrl ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
89
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg font-medium", children: displayName }),
90
+ /* @__PURE__ */ jsxRuntime.jsx(LogoOrIcon, {})
91
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg font-medium", children: displayName }),
92
+ !logoUrl && /* @__PURE__ */ jsxRuntime.jsx(BotIcon, { className: "w-6 h-6" })
93
+ ]
94
+ }
95
+ );
96
+ }
97
+ return /* @__PURE__ */ jsxRuntime.jsxs(
98
+ "header",
99
+ {
100
+ className: "flex items-center justify-between px-6 py-4 border-b",
101
+ style: { background: "var(--ac-background)", borderColor: "var(--ac-border)" },
102
+ children: [
103
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
104
+ /* @__PURE__ */ jsxRuntime.jsx(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ onClick: onNewConversation,
109
+ className: "p-2 hover:bg-secondary rounded-lg transition-colors",
110
+ title: t("backToStart"),
111
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: chunk525KS5HM_cjs.cn("w-5 h-5", direction === "rtl" && "rotate-180") })
112
+ }
113
+ ),
114
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
115
+ /* @__PURE__ */ jsxRuntime.jsx(SmallLogoOrIcon, {}),
116
+ !logoUrl && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-sm", children: displayName })
117
+ ] })
118
+ ] }),
119
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
120
+ cartCount !== void 0 && cartCount >= 0 && onCartClick && /* @__PURE__ */ jsxRuntime.jsxs(
121
+ "button",
122
+ {
123
+ type: "button",
124
+ onClick: onCartClick,
125
+ className: "relative p-2 hover:bg-secondary rounded-lg transition-colors",
126
+ title: t("cart"),
127
+ children: [
128
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ShoppingCart, { className: "w-5 h-5" }),
129
+ cartCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-0.5 -end-0.5 min-w-[18px] h-[18px] flex items-center justify-center bg-red-500 text-white text-[10px] font-bold rounded-full px-1", children: cartCount })
130
+ ]
131
+ }
132
+ ),
133
+ /* @__PURE__ */ jsxRuntime.jsx(
134
+ "button",
135
+ {
136
+ type: "button",
137
+ onClick: onNewConversation,
138
+ className: "p-2 hover:bg-secondary rounded-lg transition-colors",
139
+ title: t("newConversation"),
140
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-5 h-5" })
141
+ }
142
+ ),
143
+ /* @__PURE__ */ jsxRuntime.jsx(
144
+ "button",
145
+ {
146
+ type: "button",
147
+ onClick: handleCloseAction,
148
+ className: "p-2 hover:bg-secondary rounded-lg transition-colors",
149
+ title: t("closeChat"),
150
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-5 h-5" })
151
+ }
152
+ )
153
+ ] })
154
+ ]
155
+ }
156
+ );
157
+ });
158
+ var ChatInput = react.memo(function ChatInput2({
159
+ value,
160
+ onChange,
161
+ onSubmit,
162
+ isProcessing = false,
163
+ placeholder
164
+ }) {
165
+ const [isFocused, setIsFocused] = react.useState(false);
166
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
167
+ const handleKeyDown = (e) => {
168
+ if (e.key === "Enter" && value.trim() && !isProcessing) {
169
+ e.preventDefault();
170
+ onSubmit(value);
171
+ }
172
+ };
173
+ const hasValue = value.trim().length > 0;
174
+ return /* @__PURE__ */ jsxRuntime.jsxs(
175
+ "div",
176
+ {
177
+ className: `
178
+ relative flex items-center gap-3
179
+ rounded-2xl
180
+ border-2 transition-all duration-300
181
+ ${isFocused ? "shadow-lg" : "shadow-md hover:shadow-lg"}
182
+ ps-4 md:ps-5 pe-1.5 md:pe-2
183
+ `,
184
+ style: {
185
+ backgroundColor: "var(--ac-background)",
186
+ borderColor: isFocused ? "var(--ac-primary)" : "var(--ac-border, #e8e8e8)"
187
+ },
188
+ children: [
189
+ /* @__PURE__ */ jsxRuntime.jsx(
190
+ "div",
191
+ {
192
+ className: "shrink-0 transition-colors duration-300",
193
+ style: { color: isFocused ? "var(--ac-primary)" : "#a0a0a0" },
194
+ children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
195
+ /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "8" }),
196
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m21 21-4.3-4.3" })
197
+ ] })
198
+ }
199
+ ),
200
+ /* @__PURE__ */ jsxRuntime.jsx(
201
+ "input",
202
+ {
203
+ dir: direction,
204
+ type: "text",
205
+ value,
206
+ onChange: (e) => onChange(e.target.value),
207
+ onKeyDown: handleKeyDown,
208
+ onFocus: () => setIsFocused(true),
209
+ onBlur: () => setIsFocused(false),
210
+ disabled: isProcessing,
211
+ placeholder: placeholder || t("typeMessage"),
212
+ className: "\n flex-1 bg-transparent text-start\n outline-none text-base\n min-h-[52px] md:min-h-[60px]\n disabled:opacity-50\n ",
213
+ style: { color: "var(--ac-text)" }
214
+ }
215
+ ),
216
+ /* @__PURE__ */ jsxRuntime.jsx(
217
+ "button",
218
+ {
219
+ type: "button",
220
+ onClick: () => onSubmit(value),
221
+ disabled: !hasValue || isProcessing,
222
+ className: `
223
+ group relative flex items-center justify-center
224
+ w-10 h-10 md:w-12 md:h-12
225
+ rounded-xl shrink-0
226
+ transition-all duration-300 overflow-hidden
227
+ ${hasValue && !isProcessing ? "shadow-md hover:shadow-lg hover:scale-105" : "cursor-not-allowed"}
228
+ disabled:hover:scale-100
229
+ `,
230
+ style: {
231
+ backgroundColor: hasValue && !isProcessing ? "var(--ac-primary)" : "#f0f0f0",
232
+ color: hasValue && !isProcessing ? "var(--ac-primary-foreground, #fff)" : "#a0a0a0"
233
+ },
234
+ title: t("send"),
235
+ children: isProcessing ? /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }) }) : /* @__PURE__ */ jsxRuntime.jsxs(
236
+ "svg",
237
+ {
238
+ className: `w-5 h-5 md:w-6 md:h-6 relative z-10 transition-transform duration-300 group-hover:translate-x-0.5 ${direction === "rtl" ? "rotate-180" : ""}`,
239
+ viewBox: "0 0 24 24",
240
+ fill: "none",
241
+ stroke: "currentColor",
242
+ strokeWidth: "2.5",
243
+ strokeLinecap: "round",
244
+ strokeLinejoin: "round",
245
+ children: [
246
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }),
247
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 5 7 7-7 7" })
248
+ ]
249
+ }
250
+ )
251
+ }
252
+ )
253
+ ]
254
+ }
255
+ );
256
+ });
257
+ function ChatFooter({ footerText }) {
258
+ const { t } = chunk3MP2EGEJ_cjs.useI18n();
259
+ return /* @__PURE__ */ jsxRuntime.jsxs(
260
+ "div",
261
+ {
262
+ className: "flex flex-wrap items-center justify-center gap-1.5 sm:gap-2 py-2 sm:py-3 text-xs sm:text-sm px-4",
263
+ style: { color: "var(--ac-chat-footer-text, #c4c4c4)" },
264
+ children: [
265
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-center", children: footerText || t("alwaysVerify") }),
266
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: "|" }),
267
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: t("poweredBy") }),
268
+ /* @__PURE__ */ jsxRuntime.jsx(
269
+ "a",
270
+ {
271
+ href: "https://aigentyc.ai/",
272
+ target: "_blank",
273
+ rel: "noopener noreferrer",
274
+ className: "font-semibold tracking-tight hover:underline",
275
+ style: { color: "var(--ac-text, inherit)" },
276
+ children: "aiGentyc"
277
+ }
278
+ )
279
+ ]
280
+ }
281
+ );
282
+ }
283
+ var ICON_MAP = {
284
+ Shield: lucideReact.Shield,
285
+ MessageSquare: lucideReact.MessageSquare,
286
+ Zap: lucideReact.Zap,
287
+ Search: lucideReact.Search,
288
+ HelpCircle: lucideReact.HelpCircle,
289
+ FileText: lucideReact.FileText,
290
+ Users: lucideReact.Users,
291
+ Settings: lucideReact.Settings,
292
+ Utensils: lucideReact.Utensils,
293
+ Coffee: lucideReact.Coffee,
294
+ Hotel: lucideReact.Hotel,
295
+ MapPin: lucideReact.MapPin,
296
+ Calendar: lucideReact.Calendar,
297
+ Star: lucideReact.Star,
298
+ Heart: lucideReact.Heart,
299
+ Building: lucideReact.Building,
300
+ Flag: lucideReact.Flag,
301
+ FerrisWheel: lucideReact.FerrisWheel,
302
+ Ticket: lucideReact.Ticket
303
+ };
304
+ var DEFAULT_ACTIONS = [
305
+ { id: "about", label: "aboutUs", description: "aboutUsDesc", icon: lucideReact.Shield, query: "aboutUsQuery" },
306
+ { id: "support", label: "support", description: "supportDesc", icon: lucideReact.MessageSquare, query: "supportQuery" },
307
+ { id: "features", label: "features", description: "featuresDesc", icon: lucideReact.Zap, query: "featuresQuery" },
308
+ { id: "search", label: "search", description: "searchDesc", icon: lucideReact.Search, query: "searchQuery" }
309
+ ];
310
+ function WelcomePage({
311
+ onSelectCategory,
312
+ isProcessing = false,
313
+ isOpen = true,
314
+ clientName,
315
+ questions,
316
+ welcomeTitle,
317
+ welcomeSubtitle,
318
+ hideWelcomeHeader = false,
319
+ loading = false,
320
+ questionsLayout = "vertical",
321
+ questionsLayoutMobile
322
+ }) {
323
+ const isMobile = chunkNYQSM3EB_cjs.useIsMobile();
324
+ const { t } = chunk3MP2EGEJ_cjs.useI18n();
325
+ const layout = isMobile && questionsLayoutMobile ? questionsLayoutMobile : questionsLayout;
326
+ const isHorizontal = layout === "horizontal";
327
+ const [shouldAnimate, setShouldAnimate] = react.useState(false);
328
+ const wasOpenRef = react.useRef(false);
329
+ const hasCustomQuestions = questions && questions.length > 0;
330
+ react.useEffect(() => {
331
+ if (isMobile && isOpen && !wasOpenRef.current) {
332
+ const timer = setTimeout(() => setShouldAnimate(true), 350);
333
+ wasOpenRef.current = true;
334
+ return () => clearTimeout(timer);
335
+ }
336
+ if (!isOpen) {
337
+ setShouldAnimate(false);
338
+ wasOpenRef.current = false;
339
+ }
340
+ }, [isMobile, isOpen]);
341
+ const handleActionClick = (action) => {
342
+ if (isProcessing) return;
343
+ onSelectCategory(t(action.query, { clientName }), true);
344
+ };
345
+ const handleCustomQuestionClick = (question) => {
346
+ if (isProcessing) return;
347
+ onSelectCategory(question.query, true);
348
+ };
349
+ return /* @__PURE__ */ jsxRuntime.jsx(
350
+ "div",
351
+ {
352
+ className: "flex flex-col items-center flex-1 min-h-0 overflow-y-auto px-5 sm:px-[40px] py-6 sm:py-12",
353
+ style: { backgroundColor: "var(--ac-background)" },
354
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-4 sm:gap-8 w-full my-auto", children: [
355
+ !hideWelcomeHeader && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center max-w-md", children: loading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
356
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 sm:h-9 bg-muted rounded-lg w-3/4 mx-auto mb-3 animate-pulse" }),
357
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-5 bg-muted rounded w-full mx-auto animate-pulse" })
358
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
359
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-[26px] sm:text-[32px] font-semibold mb-2 sm:mb-3", style: { color: "var(--ac-text)" }, children: welcomeTitle || t("welcomeTitle", { clientName }) }),
360
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[15px] sm:text-lg text-muted-foreground", children: welcomeSubtitle || t("welcomeSubtitle", { clientName }) })
361
+ ] }) }),
362
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-3 w-full max-w-2xl", children: loading ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: [1, 2, 3, 4].map((i) => /* @__PURE__ */ jsxRuntime.jsxs(
363
+ "div",
364
+ {
365
+ className: chunk525KS5HM_cjs.cn(
366
+ "flex gap-3 p-4 border rounded-2xl animate-pulse",
367
+ isHorizontal ? "flex-row items-center" : "flex-col items-center"
368
+ ),
369
+ style: { backgroundColor: "var(--ac-background)", borderColor: "var(--ac-border)" },
370
+ children: [
371
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-10 rounded-lg bg-muted shrink-0" }),
372
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunk525KS5HM_cjs.cn("flex flex-col gap-1.5 w-full", !isHorizontal && "items-center"), children: [
373
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 bg-muted rounded w-3/4" }),
374
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-3 bg-muted rounded w-1/2" })
375
+ ] })
376
+ ]
377
+ },
378
+ i
379
+ )) }) : hasCustomQuestions ? questions.map((question, index) => {
380
+ const Icon = question.icon ? ICON_MAP[question.icon] || lucideReact.HelpCircle : null;
381
+ return /* @__PURE__ */ jsxRuntime.jsxs(
382
+ "button",
383
+ {
384
+ type: "button",
385
+ onClick: () => handleCustomQuestionClick(question),
386
+ disabled: isProcessing,
387
+ className: chunk525KS5HM_cjs.cn(
388
+ "group relative w-full active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200",
389
+ "flex gap-3 p-4",
390
+ "border rounded-2xl shadow-sm hover:bg-accent",
391
+ isHorizontal ? "flex-row items-center text-start" : "flex-col items-center text-center"
392
+ ),
393
+ style: {
394
+ backgroundColor: question.bgColor || "var(--ac-background)",
395
+ borderColor: "var(--ac-border)",
396
+ ...isMobile ? {
397
+ opacity: shouldAnimate ? 1 : 0,
398
+ transform: shouldAnimate ? "translateY(0)" : "translateY(8px)",
399
+ transition: "opacity 300ms ease-out, transform 300ms ease-out, background-color 150ms",
400
+ transitionDelay: shouldAnimate ? `${index * 60}ms` : "0ms"
401
+ } : {}
402
+ },
403
+ children: [
404
+ Icon && /* @__PURE__ */ jsxRuntime.jsx(
405
+ "div",
406
+ {
407
+ className: "flex items-center justify-center shrink-0 w-10 h-10 rounded-lg transition-all duration-200",
408
+ style: {
409
+ backgroundColor: question.iconBgColor || "color-mix(in srgb, var(--ac-primary) 10%, transparent)"
410
+ },
411
+ children: /* @__PURE__ */ jsxRuntime.jsx(
412
+ Icon,
413
+ {
414
+ className: "w-5 h-5",
415
+ style: { color: question.iconColor || "var(--ac-primary)" },
416
+ strokeWidth: 2
417
+ }
418
+ )
419
+ }
420
+ ),
421
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunk525KS5HM_cjs.cn("flex flex-col gap-0.5 min-w-0 w-full", !isHorizontal && "items-center"), children: [
422
+ /* @__PURE__ */ jsxRuntime.jsx(
423
+ "span",
424
+ {
425
+ className: "font-semibold text-[13px] sm:text-[14px] leading-snug",
426
+ style: { color: question.textColor || "var(--ac-text)" },
427
+ children: question.label
428
+ }
429
+ ),
430
+ question.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] sm:text-[12px] leading-snug text-muted-foreground", children: question.description })
431
+ ] })
432
+ ]
433
+ },
434
+ question.id
435
+ );
436
+ }) : DEFAULT_ACTIONS.map((action, index) => {
437
+ const Icon = action.icon;
438
+ return /* @__PURE__ */ jsxRuntime.jsxs(
439
+ "button",
440
+ {
441
+ type: "button",
442
+ onClick: () => handleActionClick(action),
443
+ disabled: isProcessing,
444
+ className: chunk525KS5HM_cjs.cn(
445
+ "group relative w-full active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200",
446
+ "flex gap-3 p-4",
447
+ "border rounded-2xl shadow-sm hover:bg-accent hover:shadow-md",
448
+ isHorizontal ? "flex-row items-center text-start" : "flex-col items-center text-center"
449
+ ),
450
+ style: {
451
+ backgroundColor: "var(--ac-background)",
452
+ borderColor: "var(--ac-border)",
453
+ ...isMobile ? {
454
+ opacity: shouldAnimate ? 1 : 0,
455
+ transform: shouldAnimate ? "translateY(0)" : "translateY(8px)",
456
+ transition: "opacity 300ms ease-out, transform 300ms ease-out, background-color 150ms",
457
+ transitionDelay: shouldAnimate ? `${index * 60}ms` : "0ms"
458
+ } : {}
459
+ },
460
+ children: [
461
+ /* @__PURE__ */ jsxRuntime.jsx(
462
+ "div",
463
+ {
464
+ className: "flex items-center justify-center shrink-0 w-10 h-10 rounded-lg transition-all duration-200",
465
+ style: {
466
+ backgroundColor: "color-mix(in srgb, var(--ac-primary) 10%, transparent)"
467
+ },
468
+ children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "w-5 h-5", style: { color: "var(--ac-primary)" }, strokeWidth: 2 })
469
+ }
470
+ ),
471
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: chunk525KS5HM_cjs.cn("flex flex-col gap-0.5 min-w-0 w-full", !isHorizontal && "items-center"), children: [
472
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-[13px] sm:text-[14px] leading-snug", style: { color: "var(--ac-text)" }, children: t(action.label, { clientName }) }),
473
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] sm:text-[12px] text-muted-foreground leading-snug", children: t(action.description, { clientName }) })
474
+ ] })
475
+ ]
476
+ },
477
+ action.id
478
+ );
479
+ }) })
480
+ ] })
481
+ }
482
+ );
483
+ }
484
+ function QuickQuestions({ questions, onSelect, isProcessing = false, pageKey }) {
485
+ const [dismissed, setDismissed] = react.useState(false);
486
+ const prevPageKeyRef = react.useRef(pageKey);
487
+ const scrollRef = react.useRef(null);
488
+ const { direction } = chunk3MP2EGEJ_cjs.useI18n();
489
+ react.useEffect(() => {
490
+ if (prevPageKeyRef.current !== pageKey) {
491
+ setDismissed(false);
492
+ prevPageKeyRef.current = pageKey;
493
+ }
494
+ }, [pageKey]);
495
+ if (dismissed || questions.length === 0) return null;
496
+ const isRtl = direction === "rtl";
497
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pb-2.5 pt-1", children: [
498
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
499
+ "div",
500
+ {
501
+ ref: scrollRef,
502
+ className: chunk525KS5HM_cjs.cn("flex gap-2 overflow-x-auto pb-1 scrollbar-none", isRtl && "flex-row-reverse"),
503
+ style: { scrollbarWidth: "none", msOverflowStyle: "none" },
504
+ children: [
505
+ questions.map((q, index) => /* @__PURE__ */ jsxRuntime.jsxs(
506
+ "button",
507
+ {
508
+ type: "button",
509
+ onClick: () => onSelect(q.query),
510
+ disabled: isProcessing,
511
+ className: chunk525KS5HM_cjs.cn(
512
+ "group relative shrink-0",
513
+ "flex items-center gap-2 px-4 py-2.5",
514
+ "text-[13px] leading-tight",
515
+ "border rounded-2xl",
516
+ "hover:shadow-sm",
517
+ "active:scale-[0.98] transition-all duration-150",
518
+ "disabled:opacity-50 disabled:cursor-not-allowed"
519
+ ),
520
+ style: {
521
+ backgroundColor: "var(--ac-background)",
522
+ borderColor: "var(--ac-border)",
523
+ color: "var(--ac-text)",
524
+ animationDelay: `${index * 40}ms`,
525
+ animation: "quickq-in 0.25s ease-out both"
526
+ },
527
+ children: [
528
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "whitespace-nowrap", children: q.label }),
529
+ /* @__PURE__ */ jsxRuntime.jsxs(
530
+ "svg",
531
+ {
532
+ className: chunk525KS5HM_cjs.cn(
533
+ "w-3.5 h-3.5 shrink-0 opacity-50 group-hover:opacity-100 transition-all duration-150",
534
+ "group-hover:translate-x-0.5",
535
+ isRtl && "rotate-180 group-hover:-translate-x-0.5"
536
+ ),
537
+ style: { color: "var(--ac-primary)" },
538
+ viewBox: "0 0 24 24",
539
+ fill: "none",
540
+ stroke: "currentColor",
541
+ strokeWidth: "2.5",
542
+ strokeLinecap: "round",
543
+ strokeLinejoin: "round",
544
+ children: [
545
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12h14" }),
546
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "m12 5 7 7-7 7" })
547
+ ]
548
+ }
549
+ )
550
+ ]
551
+ },
552
+ q.id
553
+ )),
554
+ /* @__PURE__ */ jsxRuntime.jsx(
555
+ "button",
556
+ {
557
+ type: "button",
558
+ onClick: () => setDismissed(true),
559
+ className: "shrink-0 flex items-center justify-center w-8 h-8 my-auto rounded-full hover:bg-accent transition-colors duration-150",
560
+ title: isRtl ? "\u05E1\u05D2\u05D5\u05E8" : "Dismiss",
561
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-3.5 h-3.5" })
562
+ }
563
+ )
564
+ ]
565
+ }
566
+ ) }),
567
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
568
+ @keyframes quickq-in {
569
+ from { opacity: 0; transform: translateY(6px); }
570
+ to { opacity: 1; transform: translateY(0); }
571
+ }
572
+ .scrollbar-none::-webkit-scrollbar { display: none; }
573
+ ` })
574
+ ] });
575
+ }
576
+ function formatPrice(minorUnits, currencyMinorUnit, currencySymbol) {
577
+ const value = parseInt(minorUnits, 10) / Math.pow(10, currencyMinorUnit);
578
+ const formatted = value % 1 === 0 ? value.toFixed(0) : value.toFixed(2);
579
+ return `${currencySymbol}${formatted}`;
580
+ }
581
+ function decodeHtmlEntities(text) {
582
+ return text.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))).replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&ndash;/g, "\u2013").replace(/&mdash;/g, "\u2014").replace(/&laquo;/g, "\xAB").replace(/&raquo;/g, "\xBB");
583
+ }
584
+ function CartDrawer({ storeOrigin, isOpen, onClose, onCartUpdate }) {
585
+ const { t } = chunk3MP2EGEJ_cjs.useI18n();
586
+ const [cart, setCart] = react.useState(null);
587
+ const [loading, setLoading] = react.useState(false);
588
+ const [updatingKeys, setUpdatingKeys] = react.useState(/* @__PURE__ */ new Set());
589
+ const nonceRef = react.useRef("");
590
+ const fetchCart = react.useCallback(async () => {
591
+ setLoading(true);
592
+ try {
593
+ const res = await fetch(`${storeOrigin}/wp-json/wc/store/v1/cart`, { credentials: "include" });
594
+ const nonce = res.headers.get("Nonce") || res.headers.get("X-WC-Store-API-Nonce") || "";
595
+ if (nonce) nonceRef.current = nonce;
596
+ if (res.ok) {
597
+ const data = await res.json();
598
+ setCart(data);
599
+ onCartUpdate?.(data.items_count);
600
+ }
601
+ } catch (err) {
602
+ console.error("[CartDrawer] Failed to fetch cart:", err);
603
+ } finally {
604
+ setLoading(false);
605
+ }
606
+ }, [storeOrigin, onCartUpdate]);
607
+ react.useEffect(() => {
608
+ if (isOpen) fetchCart();
609
+ }, [isOpen, fetchCart]);
610
+ const updateItem = react.useCallback(
611
+ async (key, quantity) => {
612
+ setUpdatingKeys((prev) => new Set(prev).add(key));
613
+ try {
614
+ const res = await fetch(`${storeOrigin}/wp-json/wc/store/v1/cart/update-item`, {
615
+ method: "POST",
616
+ headers: {
617
+ "Content-Type": "application/json",
618
+ Nonce: nonceRef.current,
619
+ "X-WC-Store-API-Nonce": nonceRef.current
620
+ },
621
+ credentials: "include",
622
+ body: JSON.stringify({ key, quantity })
623
+ });
624
+ const nonce = res.headers.get("Nonce") || res.headers.get("X-WC-Store-API-Nonce") || "";
625
+ if (nonce) nonceRef.current = nonce;
626
+ if (res.ok) {
627
+ const data = await res.json();
628
+ setCart(data);
629
+ onCartUpdate?.(data.items_count);
630
+ }
631
+ } catch (err) {
632
+ console.error("[CartDrawer] Failed to update item:", err);
633
+ } finally {
634
+ setUpdatingKeys((prev) => {
635
+ const next = new Set(prev);
636
+ next.delete(key);
637
+ return next;
638
+ });
639
+ }
640
+ },
641
+ [storeOrigin, onCartUpdate]
642
+ );
643
+ const removeItem = react.useCallback(
644
+ async (key) => {
645
+ setUpdatingKeys((prev) => new Set(prev).add(key));
646
+ try {
647
+ const res = await fetch(`${storeOrigin}/wp-json/wc/store/v1/cart/remove-item`, {
648
+ method: "POST",
649
+ headers: {
650
+ "Content-Type": "application/json",
651
+ Nonce: nonceRef.current,
652
+ "X-WC-Store-API-Nonce": nonceRef.current
653
+ },
654
+ credentials: "include",
655
+ body: JSON.stringify({ key })
656
+ });
657
+ const nonce = res.headers.get("Nonce") || res.headers.get("X-WC-Store-API-Nonce") || "";
658
+ if (nonce) nonceRef.current = nonce;
659
+ if (res.ok) {
660
+ const data = await res.json();
661
+ setCart(data);
662
+ onCartUpdate?.(data.items_count);
663
+ }
664
+ } catch (err) {
665
+ console.error("[CartDrawer] Failed to remove item:", err);
666
+ } finally {
667
+ setUpdatingKeys((prev) => {
668
+ const next = new Set(prev);
669
+ next.delete(key);
670
+ return next;
671
+ });
672
+ }
673
+ },
674
+ [storeOrigin, onCartUpdate]
675
+ );
676
+ if (!isOpen) return null;
677
+ const items = cart?.items ?? [];
678
+ const totalPrice = cart ? formatPrice(cart.totals.total_price, cart.totals.currency_minor_unit, cart.totals.currency_symbol) : "";
679
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-x-0 top-[57px] z-50 px-3 pt-1", dir: "rtl", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border shadow-lg overflow-hidden", style: { backgroundColor: "var(--ac-background)", borderColor: "var(--ac-border)" }, children: [
680
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b bg-muted/30", style: { borderColor: "var(--ac-border)" }, children: [
681
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
682
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ShoppingCart, { className: "w-4 h-4", style: { color: "var(--ac-primary)" } }),
683
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold", style: { color: "var(--ac-text)" }, children: t("yourCart") }),
684
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
685
+ "(",
686
+ t("cartItems", { count: String(cart?.items_count ?? 0) }),
687
+ ")"
688
+ ] })
689
+ ] }),
690
+ /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onClose, className: "p-1 hover:bg-secondary rounded transition-colors", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-4 h-4 text-muted-foreground" }) })
691
+ ] }),
692
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-[60vh] overflow-y-auto", children: loading && !cart ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-8", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-5 h-5 border-2 border-t-transparent rounded-full animate-spin", style: { borderColor: "var(--ac-primary)", borderTopColor: "transparent" } }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2 py-8 text-muted-foreground", children: [
693
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ShoppingCart, { className: "w-8 h-8 opacity-40" }),
694
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: t("cartEmpty") })
695
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y", style: { borderColor: "var(--ac-border)" }, children: items.map((item) => {
696
+ const isUpdating = updatingKeys.has(item.key);
697
+ const imgSrc = item.images?.[0]?.thumbnail || item.images?.[0]?.src || "";
698
+ const lineTotal = formatPrice(
699
+ item.totals.line_total,
700
+ item.totals.currency_minor_unit,
701
+ cart.totals.currency_symbol
702
+ );
703
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-3 px-4 py-3 ${isUpdating ? "opacity-50" : ""}`, children: [
704
+ imgSrc ? /* @__PURE__ */ jsxRuntime.jsx("img", { src: imgSrc, alt: item.name, className: "w-10 h-10 rounded-lg object-cover shrink-0", loading: "lazy" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-10 h-10 rounded-lg bg-muted flex items-center justify-center shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ShoppingCart, { className: "w-4 h-4 text-muted-foreground/40" }) }),
705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
706
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13px] font-medium line-clamp-1", style: { color: "var(--ac-text)" }, children: decodeHtmlEntities(item.name) }),
707
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold mt-0.5", style: { color: "var(--ac-primary)" }, children: lineTotal })
708
+ ] }),
709
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
710
+ /* @__PURE__ */ jsxRuntime.jsx(
711
+ "button",
712
+ {
713
+ type: "button",
714
+ onClick: () => updateItem(item.key, item.quantity - 1),
715
+ disabled: isUpdating || item.quantity <= 1,
716
+ className: "w-6 h-6 flex items-center justify-center rounded bg-secondary hover:bg-secondary/80 disabled:opacity-40 transition-colors",
717
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minus, { className: "w-3 h-3" })
718
+ }
719
+ ),
720
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium w-5 text-center", children: item.quantity }),
721
+ /* @__PURE__ */ jsxRuntime.jsx(
722
+ "button",
723
+ {
724
+ type: "button",
725
+ onClick: () => updateItem(item.key, item.quantity + 1),
726
+ disabled: isUpdating,
727
+ className: "w-6 h-6 flex items-center justify-center rounded bg-secondary hover:bg-secondary/80 disabled:opacity-40 transition-colors",
728
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "w-3 h-3" })
729
+ }
730
+ )
731
+ ] }),
732
+ /* @__PURE__ */ jsxRuntime.jsx(
733
+ "button",
734
+ {
735
+ type: "button",
736
+ onClick: () => removeItem(item.key),
737
+ disabled: isUpdating,
738
+ className: "p-1 hover:bg-red-50 rounded transition-colors text-muted-foreground hover:text-red-500",
739
+ title: t("removeItem"),
740
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "w-3.5 h-3.5" })
741
+ }
742
+ )
743
+ ] }, item.key);
744
+ }) }) }),
745
+ items.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "border-t px-4 py-3 space-y-2.5 bg-muted/20", style: { borderColor: "var(--ac-border)" }, children: [
746
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
747
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[13px] font-medium text-muted-foreground", children: t("cartTotal") }),
748
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-bold", style: { color: "var(--ac-text)" }, children: totalPrice })
749
+ ] }),
750
+ /* @__PURE__ */ jsxRuntime.jsx(
751
+ "a",
752
+ {
753
+ href: `${storeOrigin}/checkout`,
754
+ target: "_blank",
755
+ rel: "noopener noreferrer",
756
+ className: "flex items-center justify-center gap-2 w-full py-2.5 rounded-lg text-sm font-semibold hover:opacity-90 transition-opacity no-underline",
757
+ style: { backgroundColor: "var(--ac-primary)", color: "var(--ac-primary-foreground, #fff)" },
758
+ children: t("checkout")
759
+ }
760
+ )
761
+ ] })
762
+ ] }) });
763
+ }
764
+ function ChatInterface(props) {
765
+ const { messages, status, sendMessage, sessionId, config, clearMessages } = chunkJ2K7EJYP_cjs.useChatContext();
766
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
767
+ chunk7BNYTOTE_cjs.useTheme();
768
+ const slots = chunkJ2K7EJYP_cjs.useSlots();
769
+ let liveChat = null;
770
+ try {
771
+ liveChat = chunkNYQSM3EB_cjs.useLiveChat();
772
+ } catch {
773
+ liveChat = null;
774
+ }
775
+ const [showWelcome, setShowWelcome] = react.useState(true);
776
+ const [input, setInput] = react.useState("");
777
+ const [hideFirstUserMessage, setHideFirstUserMessage] = react.useState(false);
778
+ const [cartCount, setCartCount] = react.useState(void 0);
779
+ const [cartOpen, setCartOpen] = react.useState(false);
780
+ const [storeOrigin, _setStoreOrigin] = react.useState(null);
781
+ const isProcessing = status === "streaming";
782
+ react.useEffect(() => {
783
+ if (messages.length > 0 && showWelcome) setShowWelcome(false);
784
+ }, [messages.length, showWelcome]);
785
+ const handleSubmit = react.useCallback(
786
+ (text) => {
787
+ if (!text.trim() || isProcessing) return;
788
+ if (liveChat?.state === "live") return;
789
+ setShowWelcome(false);
790
+ setInput("");
791
+ sendMessage(text);
792
+ },
793
+ [isProcessing, sendMessage, liveChat]
794
+ );
795
+ const handleSelectCategory = react.useCallback(
796
+ (category, hideMessage = false) => {
797
+ if (hideMessage && !props.showFirstMessage) setHideFirstUserMessage(true);
798
+ handleSubmit(category);
799
+ },
800
+ [handleSubmit, props.showFirstMessage]
801
+ );
802
+ const handleNewConversation = react.useCallback(() => {
803
+ clearMessages();
804
+ setShowWelcome(true);
805
+ setInput("");
806
+ setHideFirstUserMessage(false);
807
+ props.onNewConversation?.();
808
+ }, [clearMessages, props]);
809
+ react.useEffect(() => {
810
+ if (props.pendingMessage && props.isOpen) {
811
+ const timer = setTimeout(() => {
812
+ handleSubmit(props.pendingMessage);
813
+ props.onPendingMessageConsumed?.();
814
+ }, 300);
815
+ return () => clearTimeout(timer);
816
+ }
817
+ }, [props.pendingMessage, props.isOpen, handleSubmit, props]);
818
+ react.useEffect(() => {
819
+ if (!liveChat) return;
820
+ liveChat.registerAiHistoryGetter(
821
+ () => messages.map((m) => ({
822
+ role: m.role,
823
+ content: typeof m.content === "string" ? m.content : (m.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("") || ""
824
+ }))
825
+ );
826
+ }, [messages, liveChat]);
827
+ const headerProps = react.useMemo(
828
+ () => ({
829
+ isWelcome: showWelcome && messages.length === 0,
830
+ onNewConversation: handleNewConversation,
831
+ onClose: props.onClose,
832
+ clientName: config.clientName,
833
+ logoUrl: props.logoUrl,
834
+ cartCount,
835
+ onCartClick: () => setCartOpen(!cartOpen)
836
+ }),
837
+ [showWelcome, messages.length, handleNewConversation, props.onClose, props.logoUrl, config.clientName, cartCount, cartOpen]
838
+ );
839
+ if (showWelcome && messages.length === 0) {
840
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
841
+ !props.hideHeader && chunkJ2K7EJYP_cjs.renderSlot("header", headerProps, ChatHeader, slots),
842
+ chunkJ2K7EJYP_cjs.renderSlot(
843
+ "welcomePage",
844
+ {
845
+ onSelectCategory: handleSelectCategory,
846
+ isProcessing,
847
+ clientName: config.clientName,
848
+ isOpen: props.isOpen,
849
+ questions: props.questions,
850
+ welcomeTitle: props.pageWelcomeTitle || props.welcomeTitle,
851
+ welcomeSubtitle: props.pageWelcomeSubtitle || props.welcomeSubtitle,
852
+ hideWelcomeHeader: props.hideWelcomeHeader,
853
+ loading: props.pageContextLoading,
854
+ questionsLayout: props.questionsLayout,
855
+ questionsLayoutMobile: props.questionsLayoutMobile
856
+ },
857
+ WelcomePage,
858
+ slots
859
+ ),
860
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px]", style: { backgroundColor: "var(--ac-background)" }, children: [
861
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto z-40 w-full", children: chunkJ2K7EJYP_cjs.renderSlot(
862
+ "input",
863
+ { value: input, onChange: setInput, onSubmit: handleSubmit, isProcessing },
864
+ ChatInput,
865
+ slots
866
+ ) }),
867
+ chunkJ2K7EJYP_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
868
+ ] })
869
+ ] });
870
+ }
871
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
872
+ !props.hideHeader && chunkJ2K7EJYP_cjs.renderSlot("header", headerProps, ChatHeader, slots),
873
+ storeOrigin && /* @__PURE__ */ jsxRuntime.jsx(
874
+ CartDrawer,
875
+ {
876
+ storeOrigin,
877
+ isOpen: cartOpen,
878
+ onClose: () => setCartOpen(false),
879
+ onCartUpdate: (count) => setCartCount(count)
880
+ }
881
+ ),
882
+ /* @__PURE__ */ jsxRuntime.jsx(chunkFQN6OBGN_cjs.Conversation, { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsxs(chunkFQN6OBGN_cjs.ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
883
+ messages.map((message, messageIndex) => {
884
+ if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
885
+ return /* @__PURE__ */ jsxRuntime.jsx(
886
+ "div",
887
+ {
888
+ className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
889
+ children: [...message.parts || []].sort((a, b) => {
890
+ if (a.type === "text" && b.type !== "text") return -1;
891
+ if (a.type !== "text" && b.type === "text") return 1;
892
+ return 0;
893
+ }).map((part, i) => {
894
+ if (part.type === "text") {
895
+ if (message.role === "assistant") {
896
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsxs(
897
+ "div",
898
+ {
899
+ className: "flex gap-[10px] items-start rounded-2xl",
900
+ style: {
901
+ backgroundColor: "var(--ac-assistant-bubble-bg, transparent)",
902
+ padding: "var(--ac-assistant-bubble-padding, 0)",
903
+ color: "var(--ac-assistant-bubble-text, var(--ac-text))"
904
+ },
905
+ children: [
906
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.SparklesIcon, { className: "mt-[2px] w-4 h-4 shrink-0", style: { color: "var(--ac-primary)" } }),
907
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0 whitespace-pre-wrap", children: part.text })
908
+ ]
909
+ }
910
+ ) }, `${message.id}-${i}`);
911
+ }
912
+ return /* @__PURE__ */ jsxRuntime.jsx(
913
+ "div",
914
+ {
915
+ className: "inline-block rounded-2xl px-3 py-2 max-w-[85%]",
916
+ style: {
917
+ backgroundColor: "var(--ac-user-bubble-bg, var(--ac-primary))",
918
+ color: "var(--ac-primary-foreground, #fff)"
919
+ },
920
+ children: part.text
921
+ },
922
+ `${message.id}-${i}`
923
+ );
924
+ }
925
+ if (part.type.startsWith("tool-")) {
926
+ const toolName = part.type.replace("tool-", "");
927
+ if (toolName === "requestHumanChat") return null;
928
+ let output = part.output;
929
+ if (typeof output === "string") {
930
+ try {
931
+ output = JSON.parse(output);
932
+ } catch {
933
+ }
934
+ }
935
+ const result = output && typeof output === "object" && !Array.isArray(output) && ("data" in output || "uiRenderMode" in output) ? output : { data: output };
936
+ return /* @__PURE__ */ jsxRuntime.jsx(
937
+ chunkXXNDL5SJ_cjs.ToolRenderer,
938
+ {
939
+ toolName,
940
+ state: part.state ?? "output-available",
941
+ args: part.input ?? {},
942
+ result,
943
+ onSendMessage: handleSubmit,
944
+ isProcessing
945
+ },
946
+ `${message.id}-tool-${i}`
947
+ );
948
+ }
949
+ return null;
950
+ })
951
+ },
952
+ message.id
953
+ );
954
+ }),
955
+ status === "streaming" && (() => {
956
+ const lastMessage = messages[messages.length - 1];
957
+ if (!lastMessage || lastMessage.role !== "assistant") return true;
958
+ const hasText = (lastMessage.parts || []).some(
959
+ (p) => p.type === "text" && (p.text || "").trim()
960
+ );
961
+ const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
962
+ return allToolsComplete && !hasText;
963
+ })() && /* @__PURE__ */ jsxRuntime.jsx(chunkFQN6OBGN_cjs.Loader, { text: t("thinking") })
964
+ ] }) }),
965
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px] pb-2", style: { backgroundColor: "var(--ac-background)" }, children: [
966
+ props.pageQuestions && props.pageQuestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
967
+ QuickQuestions,
968
+ {
969
+ questions: props.pageQuestions,
970
+ onSelect: (query) => handleSelectCategory(query, true),
971
+ isProcessing,
972
+ pageKey: props.pageUrl
973
+ }
974
+ ),
975
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto z-40 w-full flex items-end gap-2", children: [
976
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: chunkJ2K7EJYP_cjs.renderSlot(
977
+ "input",
978
+ { value: input, onChange: setInput, onSubmit: () => handleSubmit(input), isProcessing },
979
+ ChatInput,
980
+ slots
981
+ ) }),
982
+ liveChat && liveChat.state === "ai" && !showWelcome && /* @__PURE__ */ jsxRuntime.jsx(
983
+ "button",
984
+ {
985
+ type: "button",
986
+ onClick: () => liveChat.requestManualHandoff(),
987
+ title: t("liveChatTalkToHuman"),
988
+ className: "shrink-0 mb-[7px] h-[36px] w-[36px] rounded-lg hover:bg-muted flex items-center justify-center transition-colors opacity-50 hover:opacity-100",
989
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-4 w-4 text-muted-foreground" })
990
+ }
991
+ )
992
+ ] }),
993
+ chunkJ2K7EJYP_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
994
+ ] }),
995
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "data-session-id": sessionId, className: "hidden" })
996
+ ] });
997
+ }
998
+ function FloatingButton({
999
+ onClick,
1000
+ position,
1001
+ positionMobile,
1002
+ greeting,
1003
+ isOpen = false,
1004
+ greetingOffsetX = "-20px",
1005
+ greetingOffsetY = "-20px",
1006
+ buttonOffsetXMobile = "16px",
1007
+ buttonOffsetYMobile = "16px",
1008
+ buttonOffsetXDesktop = "24px",
1009
+ buttonOffsetYDesktop = "24px",
1010
+ buttonIconUrl,
1011
+ buttonImageUrl,
1012
+ buttonImageUrlMobile,
1013
+ buttonWidth,
1014
+ buttonHeight,
1015
+ buttonIconSize,
1016
+ buttonWidthMobile,
1017
+ buttonHeightMobile,
1018
+ buttonIconSizeMobile,
1019
+ buttonBgColor,
1020
+ buttonBorderRadius,
1021
+ greetingMaxWidth,
1022
+ zIndex = 999999,
1023
+ hideGreeting = false
1024
+ }) {
1025
+ const [showGreeting, setShowGreeting] = react.useState(false);
1026
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
1027
+ const isRtl = direction === "rtl";
1028
+ const effectiveGreeting = greeting || t("greeting");
1029
+ const [greetingDismissed, setGreetingDismissed] = react.useState(false);
1030
+ const isMobile = chunkNYQSM3EB_cjs.useIsMobile();
1031
+ const effectivePosition = isMobile && positionMobile ? positionMobile : position;
1032
+ const isRightSide = effectivePosition === "bottom-right" || effectivePosition === "top-right";
1033
+ const isBottom = effectivePosition === "bottom-right" || effectivePosition === "bottom-left";
1034
+ const buttonOffsetX = isMobile ? buttonOffsetXMobile : buttonOffsetXDesktop;
1035
+ const buttonOffsetY = isMobile ? buttonOffsetYMobile : buttonOffsetYDesktop;
1036
+ react.useEffect(() => {
1037
+ if (greetingDismissed || isOpen) return;
1038
+ const timer = setTimeout(() => setShowGreeting(true), 2e3);
1039
+ return () => clearTimeout(timer);
1040
+ }, [greetingDismissed, isOpen]);
1041
+ const getPositionStyles = () => {
1042
+ const styles = {};
1043
+ if (isBottom) styles.bottom = buttonOffsetY;
1044
+ else styles.top = buttonOffsetY;
1045
+ if (isRightSide) styles.right = buttonOffsetX;
1046
+ else styles.left = buttonOffsetX;
1047
+ return styles;
1048
+ };
1049
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1050
+ "div",
1051
+ {
1052
+ className: `fixed flex items-end gap-3 ${isRightSide ? "flex-row" : "flex-row-reverse"}`,
1053
+ dir: "ltr",
1054
+ style: { ...getPositionStyles(), zIndex },
1055
+ children: [
1056
+ showGreeting && !isOpen && !hideGreeting && /* @__PURE__ */ jsxRuntime.jsxs(
1057
+ "div",
1058
+ {
1059
+ dir: isRtl ? "rtl" : "ltr",
1060
+ className: `relative bg-white rounded-sm animate-fadeIn ${isBottom ? "mb-1" : "mt-1"}`,
1061
+ style: {
1062
+ animation: "fadeIn 0.3s ease-out",
1063
+ boxShadow: "0 4px 16px rgba(0, 0, 0, 0.12)",
1064
+ padding: "12px",
1065
+ maxWidth: greetingMaxWidth || "240px",
1066
+ color: "#000",
1067
+ textAlign: "center",
1068
+ fontSize: "16px",
1069
+ fontWeight: 400,
1070
+ lineHeight: "16px",
1071
+ right: greetingOffsetX,
1072
+ top: greetingOffsetY
1073
+ },
1074
+ children: [
1075
+ effectiveGreeting,
1076
+ /* @__PURE__ */ jsxRuntime.jsx(
1077
+ "div",
1078
+ {
1079
+ className: "absolute top-1/2 -translate-y-1/2",
1080
+ style: {
1081
+ width: "14px",
1082
+ height: "14px",
1083
+ background: "white",
1084
+ transform: "translateY(-50%) rotate(45deg)",
1085
+ boxShadow: "2px -2px 4px rgba(0, 0, 0, 0.06)",
1086
+ ...isRightSide ? { right: "-7px" } : { left: "-7px" }
1087
+ }
1088
+ }
1089
+ )
1090
+ ]
1091
+ }
1092
+ ),
1093
+ (buttonImageUrl || buttonImageUrlMobile) && !isOpen ? /* @__PURE__ */ jsxRuntime.jsx(
1094
+ "button",
1095
+ {
1096
+ type: "button",
1097
+ onClick,
1098
+ className: "bg-transparent border-none p-0 cursor-pointer hover:scale-105 transition-all duration-200 flex-shrink-0 z-[2]",
1099
+ style: {
1100
+ ...(buttonWidth || buttonWidthMobile) && { width: isMobile ? buttonWidthMobile || buttonWidth : buttonWidth },
1101
+ ...(buttonHeight || buttonHeightMobile) && { height: isMobile ? buttonHeightMobile || buttonHeight : buttonHeight }
1102
+ },
1103
+ "aria-label": "Open chat",
1104
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1105
+ "img",
1106
+ {
1107
+ src: isMobile && buttonImageUrlMobile ? buttonImageUrlMobile : buttonImageUrl || buttonImageUrlMobile,
1108
+ alt: "Chat",
1109
+ className: "w-full h-full object-contain",
1110
+ style: {
1111
+ ...!buttonWidth && !buttonWidthMobile && { width: isMobile ? "48px" : "56px" },
1112
+ ...!buttonHeight && !buttonHeightMobile && { height: isMobile ? "48px" : "56px" },
1113
+ ...buttonBorderRadius != null && { borderRadius: buttonBorderRadius }
1114
+ }
1115
+ }
1116
+ )
1117
+ }
1118
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
1119
+ "button",
1120
+ {
1121
+ type: "button",
1122
+ onClick,
1123
+ className: chunk525KS5HM_cjs.cn(
1124
+ "shadow-lg hover:shadow-xl hover:scale-105 transition-all duration-200 flex items-center justify-center flex-shrink-0 z-[2]",
1125
+ !buttonBorderRadius && "rounded-full",
1126
+ !buttonWidth && !buttonWidthMobile && !buttonHeight && !buttonHeightMobile && "w-12 h-12 md:w-14 md:h-14"
1127
+ ),
1128
+ style: {
1129
+ backgroundColor: buttonBgColor || "var(--ac-primary)",
1130
+ color: "var(--ac-primary-foreground, #fff)",
1131
+ ...(buttonWidth || buttonWidthMobile) && { width: isMobile ? buttonWidthMobile || buttonWidth : buttonWidth },
1132
+ ...(buttonHeight || buttonHeightMobile) && { height: isMobile ? buttonHeightMobile || buttonHeight : buttonHeight },
1133
+ ...buttonBorderRadius != null && { borderRadius: buttonBorderRadius }
1134
+ },
1135
+ "aria-label": isOpen ? "Close chat" : "Open chat",
1136
+ children: (() => {
1137
+ const effectiveIconSize = isMobile ? buttonIconSizeMobile || buttonIconSize : buttonIconSize;
1138
+ const iconStyle = effectiveIconSize ? { width: effectiveIconSize, height: effectiveIconSize } : void 0;
1139
+ const iconClass = !effectiveIconSize ? "w-6 h-6 md:w-7 md:h-7" : void 0;
1140
+ if (isOpen) return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: iconClass, style: iconStyle, strokeWidth: 2.5 });
1141
+ if (buttonIconUrl) return /* @__PURE__ */ jsxRuntime.jsx("img", { src: buttonIconUrl, alt: "Chat", className: chunk525KS5HM_cjs.cn("object-contain", iconClass), style: iconStyle });
1142
+ return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: iconClass, style: iconStyle, strokeWidth: 2.5 });
1143
+ })()
1144
+ }
1145
+ ),
1146
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: `
1147
+ @keyframes fadeIn {
1148
+ from { opacity: 0; transform: scale(0.95); }
1149
+ to { opacity: 1; transform: scale(1); }
1150
+ }
1151
+ ` })
1152
+ ]
1153
+ }
1154
+ );
1155
+ }
1156
+ function useLiveChatOrThrow() {
1157
+ const ctx = chunkNYQSM3EB_cjs.useLiveChat();
1158
+ if (!ctx) throw new Error("LiveChat sub-view rendered outside LiveChatProvider \u2014 this should never happen");
1159
+ return ctx;
1160
+ }
1161
+ function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
1162
+ const lc = chunkNYQSM3EB_cjs.useLiveChat();
1163
+ if (!lc) return null;
1164
+ const isActive = lc.state !== "ai" || lc.showIdentityForm;
1165
+ const showPanel = isWidgetOpen && isActive;
1166
+ const [isWide, setIsWide] = react.useState(
1167
+ () => typeof window !== "undefined" ? window.innerWidth >= 1200 : true
1168
+ );
1169
+ react.useEffect(() => {
1170
+ if (typeof window === "undefined") return;
1171
+ const mq = window.matchMedia("(min-width: 1200px)");
1172
+ const handler = (e) => setIsWide(e.matches);
1173
+ mq.addEventListener("change", handler);
1174
+ return () => mq.removeEventListener("change", handler);
1175
+ }, []);
1176
+ if (!isWide) return null;
1177
+ return /* @__PURE__ */ jsxRuntime.jsx(
1178
+ "div",
1179
+ {
1180
+ className: "fixed top-1/2 flex flex-col rounded-2xl border shadow-lg overflow-hidden",
1181
+ style: {
1182
+ backgroundColor: "var(--ac-background)",
1183
+ borderColor: "var(--ac-border)",
1184
+ zIndex,
1185
+ width: "min(420px, calc(100vw - 800px))",
1186
+ height: "75vh",
1187
+ ...isRightSide ? { right: "790px" } : { left: "790px" },
1188
+ transform: showPanel ? "translateY(-50%) translateX(0)" : `translateY(-50%) ${isRightSide ? "translateX(20px)" : "translateX(-20px)"}`,
1189
+ opacity: showPanel ? 1 : 0,
1190
+ pointerEvents: showPanel ? "auto" : "none",
1191
+ transition: "transform 300ms ease-in-out, opacity 300ms ease-in-out"
1192
+ },
1193
+ children: lc.showIdentityForm ? /* @__PURE__ */ jsxRuntime.jsx(IdentityView, {}) : lc.state === "requesting" || lc.state === "queued" ? /* @__PURE__ */ jsxRuntime.jsx(QueueView, {}) : lc.state === "live" ? /* @__PURE__ */ jsxRuntime.jsx(ChatView, {}) : lc.state === "ended" ? /* @__PURE__ */ jsxRuntime.jsx(EndedView, {}) : null
1194
+ }
1195
+ );
1196
+ }
1197
+ function MobileLiveChatDrawer() {
1198
+ const lc = chunkNYQSM3EB_cjs.useLiveChat();
1199
+ const { t } = chunk3MP2EGEJ_cjs.useI18n();
1200
+ if (!lc) return null;
1201
+ const isActive = lc.state !== "ai" || lc.showIdentityForm;
1202
+ const [minimized, setMinimized] = react.useState(false);
1203
+ const [isNarrow, setIsNarrow] = react.useState(
1204
+ () => typeof window !== "undefined" ? window.innerWidth < 1200 : false
1205
+ );
1206
+ react.useEffect(() => {
1207
+ if (typeof window === "undefined") return;
1208
+ const mq = window.matchMedia("(max-width: 1199px)");
1209
+ const handler = (e) => setIsNarrow(e.matches);
1210
+ mq.addEventListener("change", handler);
1211
+ return () => mq.removeEventListener("change", handler);
1212
+ }, []);
1213
+ react.useEffect(() => {
1214
+ if (!isActive) setMinimized(false);
1215
+ }, [isActive]);
1216
+ if (!isNarrow) return null;
1217
+ if (isActive && minimized) {
1218
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-[100px] inset-x-0 z-50 flex justify-center px-4", children: /* @__PURE__ */ jsxRuntime.jsxs(
1219
+ "button",
1220
+ {
1221
+ type: "button",
1222
+ onClick: () => setMinimized(false),
1223
+ className: "flex items-center gap-2 px-4 py-2 rounded-full border shadow-md bg-green-50 hover:bg-green-100 transition-colors",
1224
+ children: [
1225
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-green-500 animate-pulse" }),
1226
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs font-medium text-green-800", children: t("liveChatChattingWith", { name: lc.operatorName || "..." }) })
1227
+ ]
1228
+ }
1229
+ ) });
1230
+ }
1231
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1232
+ /* @__PURE__ */ jsxRuntime.jsx(
1233
+ "div",
1234
+ {
1235
+ className: "absolute inset-0 z-40 bg-black/50",
1236
+ style: {
1237
+ opacity: isActive ? 1 : 0,
1238
+ pointerEvents: isActive ? "auto" : "none",
1239
+ transition: "opacity 200ms ease-out"
1240
+ },
1241
+ onClick: () => lc.state === "live" ? setMinimized(true) : void 0
1242
+ }
1243
+ ),
1244
+ /* @__PURE__ */ jsxRuntime.jsxs(
1245
+ "div",
1246
+ {
1247
+ className: "absolute inset-x-0 bottom-0 z-50 rounded-t-2xl border-t shadow-2xl flex flex-col",
1248
+ style: {
1249
+ backgroundColor: "var(--ac-background)",
1250
+ borderColor: "var(--ac-border)",
1251
+ height: "calc(100dvh - 150px)",
1252
+ transform: isActive ? "translateY(0)" : "translateY(100%)",
1253
+ transition: "transform 300ms cubic-bezier(0.32, 0.72, 0, 1)"
1254
+ },
1255
+ children: [
1256
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 pt-2 pb-1 shrink-0", children: [
1257
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1" }),
1258
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-[80px] h-1.5 rounded-full bg-muted" }),
1259
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex justify-end", children: lc.state === "live" && /* @__PURE__ */ jsxRuntime.jsx(
1260
+ "button",
1261
+ {
1262
+ type: "button",
1263
+ onClick: () => setMinimized(true),
1264
+ className: "text-[11px] text-muted-foreground hover:text-foreground px-2 py-1 rounded-lg hover:bg-muted transition-colors whitespace-nowrap",
1265
+ children: t("liveChatBackToAI")
1266
+ }
1267
+ ) })
1268
+ ] }),
1269
+ lc.showIdentityForm ? /* @__PURE__ */ jsxRuntime.jsx(IdentityView, {}) : lc.state === "requesting" || lc.state === "queued" ? /* @__PURE__ */ jsxRuntime.jsx(QueueView, {}) : lc.state === "live" ? /* @__PURE__ */ jsxRuntime.jsx(ChatView, {}) : lc.state === "ended" ? /* @__PURE__ */ jsxRuntime.jsx(EndedView, {}) : null
1270
+ ]
1271
+ }
1272
+ )
1273
+ ] });
1274
+ }
1275
+ function isValidEmail(email) {
1276
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
1277
+ }
1278
+ function IdentityView() {
1279
+ const lc = useLiveChatOrThrow();
1280
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
1281
+ const userInfo = lc.userInfo;
1282
+ const [name, setName] = react.useState(userInfo?.name || "");
1283
+ const [email, setEmail] = react.useState(userInfo?.email || "");
1284
+ const [emailError, setEmailError] = react.useState(false);
1285
+ const isRTL = direction === "rtl";
1286
+ react.useEffect(() => {
1287
+ if (userInfo?.name && userInfo?.email && isValidEmail(userInfo.email)) {
1288
+ lc.setShowIdentityForm(false);
1289
+ lc.initiate(userInfo.name, userInfo.email);
1290
+ }
1291
+ }, []);
1292
+ const handleConnect = () => {
1293
+ if (!isValidEmail(email)) {
1294
+ setEmailError(true);
1295
+ return;
1296
+ }
1297
+ lc.setShowIdentityForm(false);
1298
+ lc.initiate(name, email);
1299
+ };
1300
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8", dir: isRTL ? "rtl" : "ltr", children: [
1301
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-14 w-14 rounded-2xl bg-blue-50 flex items-center justify-center mb-5", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-7 w-7 text-blue-500" }) }),
1302
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium mb-5", style: { color: "var(--ac-text)" }, children: t("liveChatIdentityTitle") }),
1303
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-xs space-y-3", children: [
1304
+ /* @__PURE__ */ jsxRuntime.jsx(
1305
+ "input",
1306
+ {
1307
+ type: "text",
1308
+ value: name,
1309
+ onChange: (e) => setName(e.target.value),
1310
+ placeholder: t("liveChatIdentityName"),
1311
+ className: "w-full text-sm p-3 border rounded-xl bg-background focus:outline-none focus:ring-2",
1312
+ autoFocus: true
1313
+ }
1314
+ ),
1315
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1316
+ /* @__PURE__ */ jsxRuntime.jsx(
1317
+ "input",
1318
+ {
1319
+ type: "email",
1320
+ value: email,
1321
+ onChange: (e) => {
1322
+ setEmail(e.target.value);
1323
+ setEmailError(false);
1324
+ },
1325
+ placeholder: t("liveChatIdentityEmail"),
1326
+ className: `w-full text-sm p-3 border rounded-xl bg-background focus:outline-none focus:ring-2 ${emailError ? "border-red-400 focus:ring-red-300" : ""}`
1327
+ }
1328
+ ),
1329
+ emailError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500 mt-1 px-1", children: isRTL ? "\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC \u05DC\u05D0 \u05EA\u05E7\u05D9\u05E0\u05D4" : "Invalid email address" })
1330
+ ] }),
1331
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-2 justify-end pt-1", children: [
1332
+ /* @__PURE__ */ jsxRuntime.jsx(
1333
+ "button",
1334
+ {
1335
+ type: "button",
1336
+ onClick: () => lc.setShowIdentityForm(false),
1337
+ className: "text-sm text-muted-foreground hover:text-foreground px-4 py-2 rounded-xl",
1338
+ children: t("liveChatCancel")
1339
+ }
1340
+ ),
1341
+ /* @__PURE__ */ jsxRuntime.jsx(
1342
+ "button",
1343
+ {
1344
+ type: "button",
1345
+ onClick: handleConnect,
1346
+ disabled: !name.trim() || !email.trim(),
1347
+ className: "text-sm text-white px-5 py-2.5 rounded-xl disabled:opacity-40 transition-opacity",
1348
+ style: { backgroundColor: "var(--ac-primary, #2f80ed)" },
1349
+ children: t("liveChatIdentityConnect")
1350
+ }
1351
+ )
1352
+ ] })
1353
+ ] })
1354
+ ] });
1355
+ }
1356
+ function QueueView() {
1357
+ const lc = useLiveChatOrThrow();
1358
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
1359
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8 text-center", dir: direction, children: [
1360
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16 w-16 rounded-2xl bg-blue-50 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-8 w-8 text-blue-500" }) }),
1361
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-blue-500 animate-pulse mb-4" }),
1362
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium mb-1", style: { color: "var(--ac-text)" }, children: t("liveChatConnecting") }),
1363
+ lc.queuePosition > 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mb-4", children: t("liveChatPosition", { position: String(lc.queuePosition) }) }),
1364
+ /* @__PURE__ */ jsxRuntime.jsx(
1365
+ "button",
1366
+ {
1367
+ type: "button",
1368
+ onClick: lc.cancel,
1369
+ className: "text-xs text-muted-foreground hover:text-foreground underline mt-2",
1370
+ children: t("liveChatCancel")
1371
+ }
1372
+ )
1373
+ ] });
1374
+ }
1375
+ function ChatView() {
1376
+ const lc = useLiveChatOrThrow();
1377
+ const { t, language, direction } = chunk3MP2EGEJ_cjs.useI18n();
1378
+ const [input, setInput] = react.useState("");
1379
+ const messagesEndRef = react.useRef(null);
1380
+ const isRTL = direction === "rtl";
1381
+ react.useEffect(() => {
1382
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1383
+ }, [lc.messages]);
1384
+ const handleSend = () => {
1385
+ if (!input.trim()) return;
1386
+ lc.send(input.trim());
1387
+ setInput("");
1388
+ };
1389
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col min-h-0", dir: isRTL ? "rtl" : "ltr", children: [
1390
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 bg-green-50 border-b border-green-200 px-4 py-3 flex items-center justify-between", children: [
1391
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2.5", children: [
1392
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-8 rounded-full bg-green-500 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-white font-bold", children: lc.operatorName.charAt(0).toUpperCase() || "O" }) }),
1393
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1394
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-green-900", children: t("liveChatChattingWith", { name: lc.operatorName }) }),
1395
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1", children: [
1396
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 w-1.5 rounded-full bg-green-500" }),
1397
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-green-600", children: "Online" })
1398
+ ] })
1399
+ ] })
1400
+ ] }),
1401
+ /* @__PURE__ */ jsxRuntime.jsx(
1402
+ "button",
1403
+ {
1404
+ type: "button",
1405
+ onClick: lc.end,
1406
+ className: "text-xs text-red-600 hover:text-red-800 bg-red-50 hover:bg-red-100 px-3 py-1.5 rounded-lg transition-colors",
1407
+ children: t("liveChatEndChat")
1408
+ }
1409
+ )
1410
+ ] }),
1411
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-y-auto px-4 py-3 space-y-1", children: [
1412
+ lc.messages.map((msg, idx) => {
1413
+ if (msg.senderType === "system") {
1414
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center my-3", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground bg-muted/70 px-3 py-1 rounded-full", children: msg.content }) }, msg.id);
1415
+ }
1416
+ const isOperator = msg.senderType === "operator";
1417
+ const prevMsg = idx > 0 ? lc.messages[idx - 1] : null;
1418
+ const isFirstInGroup = !prevMsg || prevMsg.senderType !== msg.senderType || prevMsg.senderType === "system";
1419
+ const locale = language === "he" ? "he-IL" : "en-US";
1420
+ const timeStr = new Date(msg.timestamp).toLocaleTimeString(locale, {
1421
+ hour: "2-digit",
1422
+ minute: "2-digit",
1423
+ hour12: false
1424
+ });
1425
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1426
+ "div",
1427
+ {
1428
+ className: `flex items-end gap-2 ${isOperator ? "justify-start" : "flex-row-reverse"} ${isFirstInGroup ? "mt-3" : "mt-0.5"}`,
1429
+ children: [
1430
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-7 shrink-0", children: isOperator && isFirstInGroup && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-7 w-7 rounded-full bg-green-500 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-white font-bold", children: lc.operatorName.charAt(0).toUpperCase() || "O" }) }) }),
1431
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-[75%]", children: [
1432
+ isOperator && isFirstInGroup && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[11px] text-muted-foreground mb-0.5 font-medium", children: lc.operatorName }),
1433
+ /* @__PURE__ */ jsxRuntime.jsx(
1434
+ "div",
1435
+ {
1436
+ className: `rounded-2xl px-3.5 py-2.5 text-[14px] leading-relaxed ${isOperator ? "bg-white border border-gray-200 text-gray-900 rounded-bl-md" : "text-white rounded-br-md"}`,
1437
+ style: !isOperator ? { backgroundColor: "var(--ac-primary, #2f80ed)" } : void 0,
1438
+ children: msg.content
1439
+ }
1440
+ ),
1441
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: `text-[10px] text-gray-400 mt-0.5 px-1 ${isOperator ? "" : "text-end"}`, children: timeStr })
1442
+ ] })
1443
+ ]
1444
+ },
1445
+ msg.id
1446
+ );
1447
+ }),
1448
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
1449
+ ] }),
1450
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0 border-t bg-white p-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1451
+ /* @__PURE__ */ jsxRuntime.jsx(
1452
+ "input",
1453
+ {
1454
+ type: "text",
1455
+ value: input,
1456
+ onChange: (e) => setInput(e.target.value),
1457
+ onKeyDown: (e) => {
1458
+ if (e.key === "Enter" && !e.shiftKey) {
1459
+ e.preventDefault();
1460
+ handleSend();
1461
+ }
1462
+ },
1463
+ placeholder: t("typeMessage"),
1464
+ className: "flex-1 text-sm px-3.5 py-2.5 border rounded-xl bg-background focus:outline-none focus:ring-2",
1465
+ autoFocus: true
1466
+ }
1467
+ ),
1468
+ /* @__PURE__ */ jsxRuntime.jsx(
1469
+ "button",
1470
+ {
1471
+ type: "button",
1472
+ onClick: handleSend,
1473
+ disabled: !input.trim(),
1474
+ className: "shrink-0 h-10 w-10 rounded-xl flex items-center justify-center text-white disabled:opacity-40 transition-opacity",
1475
+ style: { backgroundColor: "var(--ac-primary, #2f80ed)" },
1476
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "h-4 w-4" })
1477
+ }
1478
+ )
1479
+ ] }) })
1480
+ ] });
1481
+ }
1482
+ function EndedView() {
1483
+ const lc = useLiveChatOrThrow();
1484
+ const { t, direction } = chunk3MP2EGEJ_cjs.useI18n();
1485
+ const [selected, setSelected] = react.useState(null);
1486
+ const [comment, setComment] = react.useState("");
1487
+ const [submitted, setSubmitted] = react.useState(false);
1488
+ const isRTL = direction === "rtl";
1489
+ if (submitted) {
1490
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8 text-center", dir: isRTL ? "rtl" : "ltr", children: [
1491
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-14 w-14 rounded-2xl bg-green-50 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsUp, { className: "h-7 w-7 text-green-500" }) }),
1492
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium mb-1", style: { color: "var(--ac-text)" }, children: t("liveChatRateThank") }),
1493
+ /* @__PURE__ */ jsxRuntime.jsx(
1494
+ "button",
1495
+ {
1496
+ type: "button",
1497
+ onClick: lc.returnToAI,
1498
+ className: "text-sm font-medium mt-4 px-5 py-2 rounded-xl transition-colors",
1499
+ style: { backgroundColor: "var(--ac-primary, #2f80ed)", color: "white" },
1500
+ children: t("liveChatBackToAI")
1501
+ }
1502
+ )
1503
+ ] });
1504
+ }
1505
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8", dir: isRTL ? "rtl" : "ltr", children: [
1506
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-14 w-14 rounded-2xl bg-muted/50 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-7 w-7 text-muted-foreground/50" }) }),
1507
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium mb-1", style: { color: "var(--ac-text)" }, children: t("liveChatEnded") }),
1508
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-5", children: t("liveChatRateTitle") }),
1509
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-4 mb-4", children: [
1510
+ /* @__PURE__ */ jsxRuntime.jsx(
1511
+ "button",
1512
+ {
1513
+ type: "button",
1514
+ onClick: () => setSelected("positive"),
1515
+ className: `p-3 rounded-full transition-colors ${selected === "positive" ? "bg-green-100 text-green-600" : "hover:bg-gray-100 text-gray-400"}`,
1516
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsUp, { className: "h-6 w-6" })
1517
+ }
1518
+ ),
1519
+ /* @__PURE__ */ jsxRuntime.jsx(
1520
+ "button",
1521
+ {
1522
+ type: "button",
1523
+ onClick: () => setSelected("negative"),
1524
+ className: `p-3 rounded-full transition-colors ${selected === "negative" ? "bg-red-100 text-red-600" : "hover:bg-gray-100 text-gray-400"}`,
1525
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ThumbsDown, { className: "h-6 w-6" })
1526
+ }
1527
+ )
1528
+ ] }),
1529
+ selected && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full max-w-xs space-y-3", children: [
1530
+ /* @__PURE__ */ jsxRuntime.jsx(
1531
+ "textarea",
1532
+ {
1533
+ value: comment,
1534
+ onChange: (e) => setComment(e.target.value),
1535
+ placeholder: t("liveChatFeedbackPlaceholder"),
1536
+ className: "w-full text-sm p-3 border rounded-xl resize-none h-20 focus:outline-none focus:ring-2"
1537
+ }
1538
+ ),
1539
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center gap-2", children: [
1540
+ /* @__PURE__ */ jsxRuntime.jsx(
1541
+ "button",
1542
+ {
1543
+ type: "button",
1544
+ onClick: () => {
1545
+ lc.submitRating(selected, comment || void 0);
1546
+ setSubmitted(true);
1547
+ },
1548
+ className: "text-sm text-white px-4 py-2 rounded-xl",
1549
+ style: { backgroundColor: "var(--ac-primary, #2f80ed)" },
1550
+ children: t("liveChatSubmit")
1551
+ }
1552
+ ),
1553
+ /* @__PURE__ */ jsxRuntime.jsx(
1554
+ "button",
1555
+ {
1556
+ type: "button",
1557
+ onClick: lc.returnToAI,
1558
+ className: "text-sm text-muted-foreground hover:text-foreground px-4 py-2",
1559
+ children: t("liveChatSkip")
1560
+ }
1561
+ )
1562
+ ] })
1563
+ ] }),
1564
+ !selected && /* @__PURE__ */ jsxRuntime.jsx(
1565
+ "button",
1566
+ {
1567
+ type: "button",
1568
+ onClick: lc.returnToAI,
1569
+ className: "text-xs text-muted-foreground hover:text-foreground underline mt-2",
1570
+ children: t("liveChatSkip")
1571
+ }
1572
+ )
1573
+ ] });
1574
+ }
1575
+ function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
1576
+ const previewEmbed = chunkNYQSM3EB_cjs.usePreviewEmbed();
1577
+ if (!previewEmbed) return null;
1578
+ const { preview, closePreview } = previewEmbed;
1579
+ const showPanel = isOpen && !!preview;
1580
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1581
+ "div",
1582
+ {
1583
+ className: "fixed top-1/2 flex flex-col rounded-2xl border shadow-sm overflow-hidden",
1584
+ style: {
1585
+ backgroundColor: "var(--ac-background)",
1586
+ borderColor: "var(--ac-border)",
1587
+ zIndex,
1588
+ width: "min(560px, calc(100vw - 800px))",
1589
+ height: "70vh",
1590
+ ...isRightSide ? { right: "790px" } : { left: "790px" },
1591
+ transform: showPanel ? "translateY(-50%) translateX(0)" : `translateY(-50%) ${isRightSide ? "translateX(20px)" : "translateX(-20px)"}`,
1592
+ opacity: showPanel ? 1 : 0,
1593
+ pointerEvents: showPanel ? "auto" : "none",
1594
+ transition: "transform 300ms ease-in-out, opacity 300ms ease-in-out"
1595
+ },
1596
+ children: [
1597
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted/30 px-5 py-4 border-b flex items-center justify-between shrink-0", style: { borderColor: "var(--ac-border)" }, children: [
1598
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
1599
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "shrink-0 w-10 h-10 rounded-xl bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "w-5 h-5 text-muted-foreground" }) }),
1600
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
1601
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-medium text-sm truncate", style: { color: "var(--ac-text)" }, children: preview?.title || "Preview" }),
1602
+ preview?.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-0.5 truncate", children: preview.description })
1603
+ ] })
1604
+ ] }),
1605
+ /* @__PURE__ */ jsxRuntime.jsx(
1606
+ "button",
1607
+ {
1608
+ type: "button",
1609
+ onClick: closePreview,
1610
+ className: "shrink-0 w-8 h-8 rounded-full border flex items-center justify-center hover:bg-muted transition-colors ml-3",
1611
+ style: { backgroundColor: "var(--ac-background)", borderColor: "var(--ac-border)" },
1612
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "w-4 h-4" })
1613
+ }
1614
+ )
1615
+ ] }),
1616
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0", children: preview && /* @__PURE__ */ jsxRuntime.jsx(
1617
+ "iframe",
1618
+ {
1619
+ src: preview.url,
1620
+ className: "w-full h-full border-none",
1621
+ sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-presentation",
1622
+ title: preview.title || "Preview"
1623
+ },
1624
+ preview.url
1625
+ ) })
1626
+ ]
1627
+ }
1628
+ );
1629
+ }
1630
+
1631
+ exports.CartDrawer = CartDrawer;
1632
+ exports.ChatFooter = ChatFooter;
1633
+ exports.ChatHeader = ChatHeader;
1634
+ exports.ChatInput = ChatInput;
1635
+ exports.ChatInterface = ChatInterface;
1636
+ exports.FloatingButton = FloatingButton;
1637
+ exports.LiveChatPanel = LiveChatPanel;
1638
+ exports.MobileLiveChatDrawer = MobileLiveChatDrawer;
1639
+ exports.PreviewEmbedPanel = PreviewEmbedPanel;
1640
+ exports.QuickQuestions = QuickQuestions;
1641
+ exports.WelcomePage = WelcomePage;
1642
+ //# sourceMappingURL=chunk-OU7OROOE.cjs.map
1643
+ //# sourceMappingURL=chunk-OU7OROOE.cjs.map