@jrapps/my_tickets_chat_ui 0.1.2 → 0.2.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 (78) hide show
  1. package/dist/cjs/components/SiteChatComponentNew/index.js +1283 -0
  2. package/dist/cjs/components/SiteChatComponentNew/index.js.map +7 -0
  3. package/dist/cjs/index.js +1249 -1
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/chunks/chunk-BDKQK6NT.js +1251 -0
  6. package/dist/esm/chunks/chunk-BDKQK6NT.js.map +7 -0
  7. package/dist/esm/components/SiteChatComponentNew/index.js +9 -0
  8. package/dist/esm/components/SiteChatComponentNew/index.js.map +7 -0
  9. package/dist/esm/index.js +7 -1
  10. package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts +6 -0
  11. package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts.map +1 -0
  12. package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts +2 -0
  13. package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts.map +1 -0
  14. package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts +6 -0
  15. package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts.map +1 -0
  16. package/dist/types/components/SiteChatComponentNew/Header/index.d.ts +2 -0
  17. package/dist/types/components/SiteChatComponentNew/Header/index.d.ts.map +1 -0
  18. package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts +9 -0
  19. package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts.map +1 -0
  20. package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts +9 -0
  21. package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts.map +1 -0
  22. package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts +9 -0
  23. package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts.map +1 -0
  24. package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts +8 -0
  25. package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts.map +1 -0
  26. package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts +9 -0
  27. package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts.map +1 -0
  28. package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts +5 -0
  29. package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts.map +1 -0
  30. package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts +9 -0
  31. package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts.map +1 -0
  32. package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts +8 -0
  33. package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts.map +1 -0
  34. package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts +10 -0
  35. package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts.map +1 -0
  36. package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts +2 -0
  37. package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts.map +1 -0
  38. package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts +10 -0
  39. package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts.map +1 -0
  40. package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts +14 -0
  41. package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts.map +1 -0
  42. package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts +3 -0
  43. package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts.map +1 -0
  44. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts +5 -0
  45. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts.map +1 -0
  46. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts +118 -0
  47. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts.map +1 -0
  48. package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts +5 -0
  49. package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts.map +1 -0
  50. package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts +5 -0
  51. package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts.map +1 -0
  52. package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts +10 -0
  53. package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts.map +1 -0
  54. package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts +11 -0
  55. package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts.map +1 -0
  56. package/dist/types/components/SiteChatComponentNew/States/index.d.ts +5 -0
  57. package/dist/types/components/SiteChatComponentNew/States/index.d.ts.map +1 -0
  58. package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts +3 -0
  59. package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts.map +1 -0
  60. package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts +15 -0
  61. package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts.map +1 -0
  62. package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts +12 -0
  63. package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts.map +1 -0
  64. package/dist/types/components/SiteChatComponentNew/index.d.ts +4 -0
  65. package/dist/types/components/SiteChatComponentNew/index.d.ts.map +1 -0
  66. package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts +3 -0
  67. package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts.map +1 -0
  68. package/dist/types/components/SiteChatComponentNew/utils/format.d.ts +9 -0
  69. package/dist/types/components/SiteChatComponentNew/utils/format.d.ts.map +1 -0
  70. package/dist/types/components/SiteChatComponentNew/utils/index.d.ts +4 -0
  71. package/dist/types/components/SiteChatComponentNew/utils/index.d.ts.map +1 -0
  72. package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts +4 -0
  73. package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts.map +1 -0
  74. package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts +8 -0
  75. package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts.map +1 -0
  76. package/dist/types/components/index.d.ts +1 -0
  77. package/dist/types/components/index.d.ts.map +1 -1
  78. package/package.json +1 -1
@@ -0,0 +1,1283 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/components/SiteChatComponentNew/index.ts
31
+ var SiteChatComponentNew_exports = {};
32
+ __export(SiteChatComponentNew_exports, {
33
+ SiteChatComponentNew: () => SiteChatComponentNew,
34
+ useSiteChatComponentNew: () => useSiteChatComponentNew
35
+ });
36
+ module.exports = __toCommonJS(SiteChatComponentNew_exports);
37
+
38
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
39
+ var import_react5 = __toESM(require("react"));
40
+
41
+ // src/components/SiteChatComponentNew/useSiteChatComponentNew.ts
42
+ var import_react = require("react");
43
+ function useSiteChatComponentNew(defaultOpen = false) {
44
+ const [open, setOpen] = (0, import_react.useState)(defaultOpen);
45
+ const openWidget = (0, import_react.useCallback)(() => setOpen(true), []);
46
+ const closeWidget = (0, import_react.useCallback)(() => setOpen(false), []);
47
+ return { open, openWidget, closeWidget };
48
+ }
49
+
50
+ // src/components/SiteChatComponentNew/utils/theme.ts
51
+ var FONT_FAMILY = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif";
52
+ var FONT_SIZE = "14px";
53
+ var SHADOW = "0 4px 24px rgba(0,0,0,0.12)";
54
+ var WIDTH = "400px";
55
+ var HEIGHT = "600px";
56
+ var HEADER_HEIGHT = "64px";
57
+ var defaultTheme = {
58
+ primary: "#4f46e5",
59
+ background: "#ffffff",
60
+ surface: "#f9fafb",
61
+ border: "#e5e7eb",
62
+ userBubble: "#4f46e5",
63
+ userText: "#ffffff",
64
+ agentBubble: "#f3f4f6",
65
+ agentText: "#111827",
66
+ systemText: "#6b7280",
67
+ inputBackground: "#ffffff",
68
+ inputBorder: "#d1d5db",
69
+ buttonRadius: 8,
70
+ borderRadius: 12
71
+ };
72
+ function buildThemeVars(partial) {
73
+ const theme = { ...defaultTheme, ...partial };
74
+ return {
75
+ // Colours
76
+ "--cw-primary": theme.primary,
77
+ "--cw-background": theme.background,
78
+ "--cw-surface": theme.surface,
79
+ "--cw-border": theme.border,
80
+ "--cw-user-bubble": theme.userBubble,
81
+ "--cw-user-text": theme.userText,
82
+ "--cw-agent-bubble": theme.agentBubble,
83
+ "--cw-agent-text": theme.agentText,
84
+ "--cw-system-text": theme.systemText,
85
+ "--cw-input-background": theme.inputBackground,
86
+ "--cw-input-border": theme.inputBorder,
87
+ // Border radii
88
+ "--cw-button-radius": `${theme.buttonRadius}px`,
89
+ "--cw-border-radius": `${theme.borderRadius}px`,
90
+ // Fixed constants — not exposed as theme props
91
+ "--cw-font-family": FONT_FAMILY,
92
+ "--cw-font-size": FONT_SIZE,
93
+ "--cw-shadow": SHADOW,
94
+ "--cw-width": WIDTH,
95
+ "--cw-height": HEIGHT,
96
+ "--cw-header-height": HEADER_HEIGHT
97
+ };
98
+ }
99
+
100
+ // src/components/SiteChatComponentNew/utils/systemMessages.ts
101
+ var systemEventLabels = {
102
+ AGENT_JOINED: "Agent joined",
103
+ AGENT_LEFT: "Agent left",
104
+ USER_JOINED: "You joined",
105
+ USER_LEFT: "You left",
106
+ CHAT_ENDED: "Chat ended",
107
+ CHAT_REOPENED: "Chat reopened",
108
+ CHAT_TRANSFERRED: "Chat transferred",
109
+ WAITING_FOR_AGENT: "Waiting for an agent"
110
+ };
111
+ function getSystemLabel(event) {
112
+ var _a;
113
+ return (_a = systemEventLabels[event]) != null ? _a : event;
114
+ }
115
+
116
+ // src/components/SiteChatComponentNew/utils/format.ts
117
+ function formatTime(timestamp) {
118
+ return new Date(timestamp).toLocaleTimeString([], {
119
+ hour: "2-digit",
120
+ minute: "2-digit"
121
+ });
122
+ }
123
+
124
+ // src/components/SiteChatComponentNew/Header/Header.css
125
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-45eba566")) {
126
+ const s = document.createElement("style");
127
+ s.id = "jrapps-style-45eba566";
128
+ s.textContent = ".cw-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n height: var(--cw-header-height);\n background-color: var(--cw-primary);\n color: #ffffff;\n flex-shrink: 0;\n border-radius: var(--cw-border-radius) var(--cw-border-radius) 0 0;\n}\n\n.cw-header__identity {\n display: flex;\n align-items: center;\n gap: 12px;\n min-width: 0;\n}\n\n.cw-header__avatar {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n border: 2px solid rgba(255, 255, 255, 0.4);\n}\n\n.cw-header__text {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n\n.cw-header__title {\n font-size: 15px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__subtitle {\n font-size: 12px;\n opacity: 0.85;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__close {\n background: none;\n border: none;\n cursor: pointer;\n color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n}\n\n.cw-header__close:hover {\n background-color: rgba(255, 255, 255, 0.15);\n}\n\n.cw-header__close:focus-visible {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n";
129
+ document.head.appendChild(s);
130
+ }
131
+
132
+ // src/components/SiteChatComponentNew/Header/Header.tsx
133
+ var import_jsx_runtime = require("react/jsx-runtime");
134
+ var Header = ({ image, title, subtitle, onClose }) => {
135
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "cw-header", role: "banner", children: [
136
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cw-header__identity", children: [
137
+ image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
138
+ "img",
139
+ {
140
+ src: image,
141
+ alt: `${title} avatar`,
142
+ className: "cw-header__avatar"
143
+ }
144
+ ),
145
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "cw-header__text", children: [
146
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cw-header__title", children: title }),
147
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cw-header__subtitle", children: subtitle })
148
+ ] })
149
+ ] }),
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
+ "button",
152
+ {
153
+ className: "cw-header__close",
154
+ onClick: onClose,
155
+ "aria-label": "Close chat",
156
+ type: "button",
157
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
158
+ "svg",
159
+ {
160
+ xmlns: "http://www.w3.org/2000/svg",
161
+ width: "20",
162
+ height: "20",
163
+ viewBox: "0 0 24 24",
164
+ fill: "none",
165
+ stroke: "currentColor",
166
+ strokeWidth: "2",
167
+ strokeLinecap: "round",
168
+ strokeLinejoin: "round",
169
+ "aria-hidden": "true",
170
+ children: [
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
173
+ ]
174
+ }
175
+ )
176
+ }
177
+ )
178
+ ] });
179
+ };
180
+ var Header_default = Header;
181
+
182
+ // src/components/SiteChatComponentNew/Footer/Footer.tsx
183
+ var import_react2 = require("react");
184
+
185
+ // src/components/SiteChatComponentNew/Footer/Footer.css
186
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ebcf221d")) {
187
+ const s = document.createElement("style");
188
+ s.id = "jrapps-style-ebcf221d";
189
+ s.textContent = ".cw-footer {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n padding: 10px 12px;\n background-color: var(--cw-background);\n border-top: 1px solid var(--cw-border);\n flex-shrink: 0;\n}\n\n.cw-footer__input {\n flex: 1;\n resize: none;\n border: 1px solid var(--cw-input-border);\n border-radius: var(--cw-button-radius);\n background-color: var(--cw-input-background);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n color: inherit;\n padding: 8px 12px;\n line-height: 1.5;\n min-height: 38px;\n max-height: 120px;\n overflow-y: auto;\n transition: border-color 0.15s ease;\n}\n\n.cw-footer__input:focus {\n outline: none;\n border-color: var(--cw-primary);\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);\n}\n\n.cw-footer__input:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.cw-footer__attach-btn,\n.cw-footer__send-btn {\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease, color 0.15s ease;\n color: var(--cw-primary);\n margin-bottom: 1px;\n}\n\n.cw-footer__attach-btn:hover,\n.cw-footer__send-btn:not(.cw-footer__send-btn--disabled):hover {\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n}\n\n.cw-footer__attach-btn:focus-visible,\n.cw-footer__send-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-footer__attach-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.cw-footer__send-btn--disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.cw-footer__file-input {\n display: none;\n}\n";
190
+ document.head.appendChild(s);
191
+ }
192
+
193
+ // src/components/SiteChatComponentNew/Footer/Footer.tsx
194
+ var import_jsx_runtime2 = require("react/jsx-runtime");
195
+ var Footer = ({ onSend, onAttachment, disabled }) => {
196
+ const [text, setText] = (0, import_react2.useState)("");
197
+ const fileInputRef = (0, import_react2.useRef)(null);
198
+ const textareaRef = (0, import_react2.useRef)(null);
199
+ const isEmpty = text.trim().length === 0;
200
+ const handleKeyDown = (0, import_react2.useCallback)(
201
+ (e) => {
202
+ if (e.key === "Enter" && !e.shiftKey) {
203
+ e.preventDefault();
204
+ if (!isEmpty && !disabled) {
205
+ onSend(text.trim());
206
+ setText("");
207
+ if (textareaRef.current) {
208
+ textareaRef.current.style.height = "auto";
209
+ }
210
+ }
211
+ }
212
+ },
213
+ [isEmpty, disabled, onSend, text]
214
+ );
215
+ const handleSend = (0, import_react2.useCallback)(() => {
216
+ if (!isEmpty && !disabled) {
217
+ onSend(text.trim());
218
+ setText("");
219
+ if (textareaRef.current) {
220
+ textareaRef.current.style.height = "auto";
221
+ textareaRef.current.focus();
222
+ }
223
+ }
224
+ }, [isEmpty, disabled, onSend, text]);
225
+ const handleChange = (0, import_react2.useCallback)(
226
+ (e) => {
227
+ setText(e.target.value);
228
+ const el = e.target;
229
+ el.style.height = "auto";
230
+ el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
231
+ },
232
+ []
233
+ );
234
+ const handleAttachmentClick = (0, import_react2.useCallback)(() => {
235
+ var _a;
236
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
237
+ }, []);
238
+ const handleFileChange = (0, import_react2.useCallback)(
239
+ (e) => {
240
+ var _a;
241
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
242
+ if (file) {
243
+ onAttachment(file);
244
+ }
245
+ if (fileInputRef.current) {
246
+ fileInputRef.current.value = "";
247
+ }
248
+ },
249
+ [onAttachment]
250
+ );
251
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: "cw-footer", role: "contentinfo", children: [
252
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
253
+ "button",
254
+ {
255
+ className: "cw-footer__attach-btn",
256
+ onClick: handleAttachmentClick,
257
+ "aria-label": "Attach file",
258
+ type: "button",
259
+ disabled,
260
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
261
+ "svg",
262
+ {
263
+ xmlns: "http://www.w3.org/2000/svg",
264
+ width: "20",
265
+ height: "20",
266
+ viewBox: "0 0 24 24",
267
+ fill: "none",
268
+ stroke: "currentColor",
269
+ strokeWidth: "2",
270
+ strokeLinecap: "round",
271
+ strokeLinejoin: "round",
272
+ "aria-hidden": "true",
273
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
274
+ }
275
+ )
276
+ }
277
+ ),
278
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
279
+ "textarea",
280
+ {
281
+ ref: textareaRef,
282
+ className: "cw-footer__input",
283
+ value: text,
284
+ onChange: handleChange,
285
+ onKeyDown: handleKeyDown,
286
+ placeholder: "Type a message\u2026",
287
+ "aria-label": "Message input",
288
+ rows: 1,
289
+ disabled
290
+ }
291
+ ),
292
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
293
+ "button",
294
+ {
295
+ className: `cw-footer__send-btn${isEmpty || disabled ? " cw-footer__send-btn--disabled" : ""}`,
296
+ onClick: handleSend,
297
+ "aria-label": "Send message",
298
+ type: "button",
299
+ disabled: isEmpty || disabled,
300
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
301
+ "svg",
302
+ {
303
+ xmlns: "http://www.w3.org/2000/svg",
304
+ width: "20",
305
+ height: "20",
306
+ viewBox: "0 0 24 24",
307
+ fill: "currentColor",
308
+ "aria-hidden": "true",
309
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" })
310
+ }
311
+ )
312
+ }
313
+ ),
314
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
315
+ "input",
316
+ {
317
+ ref: fileInputRef,
318
+ type: "file",
319
+ className: "cw-footer__file-input",
320
+ onChange: handleFileChange,
321
+ "aria-hidden": "true",
322
+ tabIndex: -1
323
+ }
324
+ )
325
+ ] });
326
+ };
327
+ var Footer_default = Footer;
328
+
329
+ // src/components/SiteChatComponentNew/hooks/useAutoScroll.ts
330
+ var import_react3 = require("react");
331
+ function useAutoScroll(dependency) {
332
+ const ref = (0, import_react3.useRef)(null);
333
+ const userScrolledUp = (0, import_react3.useRef)(false);
334
+ (0, import_react3.useEffect)(() => {
335
+ const el = ref.current;
336
+ if (!el) return;
337
+ const handleScroll = () => {
338
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 64;
339
+ userScrolledUp.current = !atBottom;
340
+ };
341
+ el.addEventListener("scroll", handleScroll, { passive: true });
342
+ return () => el.removeEventListener("scroll", handleScroll);
343
+ }, []);
344
+ (0, import_react3.useEffect)(() => {
345
+ const el = ref.current;
346
+ if (!el || userScrolledUp.current) return;
347
+ el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
348
+ }, [dependency]);
349
+ return ref;
350
+ }
351
+
352
+ // src/components/SiteChatComponentNew/hooks/useOfflineForm.ts
353
+ var import_react4 = require("react");
354
+ function validateField(field, value) {
355
+ if (field.required) {
356
+ if (field.type === "checkbox" && !value) {
357
+ return `${field.label} is required.`;
358
+ }
359
+ if (field.type !== "checkbox" && (value === void 0 || value === null || String(value).trim() === "")) {
360
+ return `${field.label} is required.`;
361
+ }
362
+ }
363
+ if (field.type === "email") {
364
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
365
+ if (value && !emailRegex.test(String(value))) {
366
+ return "Please enter a valid email address.";
367
+ }
368
+ }
369
+ if (field.type === "phone") {
370
+ const phoneRegex = /^\+?[\d\s\-().]{7,20}$/;
371
+ if (value && !phoneRegex.test(String(value))) {
372
+ return "Please enter a valid phone number.";
373
+ }
374
+ }
375
+ return "";
376
+ }
377
+ function useOfflineForm(schema) {
378
+ const initialValues = {};
379
+ for (const field of schema.fields) {
380
+ initialValues[field.id] = field.type === "checkbox" ? false : "";
381
+ }
382
+ const [values, setValues] = (0, import_react4.useState)(initialValues);
383
+ const [errors, setErrors] = (0, import_react4.useState)({});
384
+ const [submitted, setSubmitted] = (0, import_react4.useState)(false);
385
+ const setValue = (0, import_react4.useCallback)(
386
+ (id, value) => {
387
+ setValues((prev) => ({ ...prev, [id]: value }));
388
+ if (submitted) {
389
+ const field = schema.fields.find((f) => f.id === id);
390
+ if (field) {
391
+ const error = validateField(field, value);
392
+ setErrors((prev) => ({ ...prev, [id]: error }));
393
+ }
394
+ }
395
+ },
396
+ [schema.fields, submitted]
397
+ );
398
+ const validate = (0, import_react4.useCallback)(() => {
399
+ const newErrors = {};
400
+ let valid = true;
401
+ for (const field of schema.fields) {
402
+ const error = validateField(field, values[field.id]);
403
+ newErrors[field.id] = error;
404
+ if (error) valid = false;
405
+ }
406
+ setErrors(newErrors);
407
+ return valid;
408
+ }, [schema.fields, values]);
409
+ const handleSubmit = (0, import_react4.useCallback)(
410
+ (onSubmit) => {
411
+ setSubmitted(true);
412
+ if (validate()) {
413
+ onSubmit(values);
414
+ }
415
+ },
416
+ [validate, values]
417
+ );
418
+ const reset = (0, import_react4.useCallback)(() => {
419
+ setValues(initialValues);
420
+ setErrors({});
421
+ setSubmitted(false);
422
+ }, []);
423
+ return { values, errors, setValue, handleSubmit, reset };
424
+ }
425
+
426
+ // src/components/SiteChatComponentNew/Messages/UserMessage.css
427
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-aed321e0")) {
428
+ const s = document.createElement("style");
429
+ s.id = "jrapps-style-aed321e0";
430
+ s.textContent = ".cw-user-message {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n max-width: 75%;\n align-self: flex-end;\n gap: 3px;\n}\n\n.cw-user-message__bubble {\n background-color: var(--cw-user-bubble);\n color: var(--cw-user-text);\n padding: 10px 14px;\n border-radius: 18px 18px 4px 18px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-user-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-right: 2px;\n}\n";
431
+ document.head.appendChild(s);
432
+ }
433
+
434
+ // src/components/SiteChatComponentNew/Messages/UserMessage.tsx
435
+ var import_jsx_runtime3 = require("react/jsx-runtime");
436
+ var UserMessage = ({ message }) => {
437
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "cw-user-message", role: "listitem", "aria-label": "Your message", children: [
438
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "cw-user-message__bubble", children: message.message }),
439
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "cw-user-message__time", children: formatTime(message.timestamp) })
440
+ ] });
441
+ };
442
+ var UserMessage_default = UserMessage;
443
+
444
+ // src/components/SiteChatComponentNew/Shared/Avatar.css
445
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ce14fbec")) {
446
+ const s = document.createElement("style");
447
+ s.id = "jrapps-style-ce14fbec";
448
+ s.textContent = ".cw-avatar {\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-avatar--image {\n object-fit: cover;\n}\n\n.cw-avatar--initials {\n background-color: var(--cw-primary);\n color: #ffffff;\n font-weight: 600;\n user-select: none;\n}\n";
449
+ document.head.appendChild(s);
450
+ }
451
+
452
+ // src/components/SiteChatComponentNew/Shared/Avatar.tsx
453
+ var import_jsx_runtime4 = require("react/jsx-runtime");
454
+ function getInitials(name) {
455
+ return name.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase();
456
+ }
457
+ var Avatar = ({ src, name, size = 32 }) => {
458
+ const style = {
459
+ width: `${size}px`,
460
+ height: `${size}px`,
461
+ fontSize: `${Math.round(size * 0.38)}px`
462
+ };
463
+ if (src) {
464
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
465
+ "img",
466
+ {
467
+ src,
468
+ alt: name ? `${name} avatar` : "Agent avatar",
469
+ className: "cw-avatar cw-avatar--image",
470
+ style
471
+ }
472
+ );
473
+ }
474
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
475
+ "span",
476
+ {
477
+ className: "cw-avatar cw-avatar--initials",
478
+ "aria-label": name ? `${name} avatar` : "Agent avatar",
479
+ style,
480
+ children: name ? getInitials(name) : "A"
481
+ }
482
+ );
483
+ };
484
+ var Avatar_default = Avatar;
485
+
486
+ // src/components/SiteChatComponentNew/Shared/Button.css
487
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-2aa106ea")) {
488
+ const s = document.createElement("style");
489
+ s.id = "jrapps-style-2aa106ea";
490
+ s.textContent = ".cw-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: var(--cw-button-radius);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.15s ease, transform 0.1s ease;\n white-space: nowrap;\n}\n\n.cw-button:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-button:active:not(:disabled) {\n transform: scale(0.98);\n}\n\n.cw-button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.cw-button--primary {\n background-color: var(--cw-primary);\n color: #ffffff;\n}\n\n.cw-button--primary:hover:not(:disabled) {\n opacity: 0.88;\n}\n\n.cw-button--secondary {\n background-color: var(--cw-surface);\n color: var(--cw-primary);\n border: 1px solid var(--cw-border);\n}\n\n.cw-button--secondary:hover:not(:disabled) {\n background-color: var(--cw-border);\n}\n\n.cw-button--full {\n width: 100%;\n}\n";
491
+ document.head.appendChild(s);
492
+ }
493
+
494
+ // src/components/SiteChatComponentNew/Shared/Button.tsx
495
+ var import_jsx_runtime5 = require("react/jsx-runtime");
496
+ var Button = ({
497
+ children,
498
+ onClick,
499
+ variant = "primary",
500
+ disabled = false,
501
+ type = "button",
502
+ fullWidth = false,
503
+ ariaLabel
504
+ }) => {
505
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
506
+ "button",
507
+ {
508
+ className: `cw-button cw-button--${variant}${fullWidth ? " cw-button--full" : ""}`,
509
+ onClick,
510
+ disabled,
511
+ type,
512
+ "aria-label": ariaLabel,
513
+ children
514
+ }
515
+ );
516
+ };
517
+ var Button_default = Button;
518
+
519
+ // src/components/SiteChatComponentNew/Messages/AgentMessage.css
520
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-5df522b1")) {
521
+ const s = document.createElement("style");
522
+ s.id = "jrapps-style-5df522b1";
523
+ s.textContent = ".cw-agent-message {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n max-width: 75%;\n align-self: flex-start;\n}\n\n.cw-agent-message__content {\n display: flex;\n flex-direction: column;\n gap: 3px;\n}\n\n.cw-agent-message__name {\n font-size: 11px;\n font-weight: 600;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-agent-message__bubble {\n background-color: var(--cw-agent-bubble);\n color: var(--cw-agent-text);\n padding: 10px 14px;\n border-radius: 18px 18px 18px 4px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-agent-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n";
524
+ document.head.appendChild(s);
525
+ }
526
+
527
+ // src/components/SiteChatComponentNew/Messages/AgentMessage.tsx
528
+ var import_jsx_runtime6 = require("react/jsx-runtime");
529
+ var AgentMessage = ({ message }) => {
530
+ var _a;
531
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
532
+ "div",
533
+ {
534
+ className: "cw-agent-message",
535
+ role: "listitem",
536
+ "aria-label": `Message from ${(_a = message.senderName) != null ? _a : "Agent"}`,
537
+ children: [
538
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Avatar_default, { name: message.senderName, size: 32 }),
539
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "cw-agent-message__content", children: [
540
+ message.senderName && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cw-agent-message__name", children: message.senderName }),
541
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "cw-agent-message__bubble", children: message.message }),
542
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cw-agent-message__time", children: formatTime(message.timestamp) })
543
+ ] })
544
+ ]
545
+ }
546
+ );
547
+ };
548
+ var AgentMessage_default = AgentMessage;
549
+
550
+ // src/components/SiteChatComponentNew/Messages/SystemMessage.css
551
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-464a3601")) {
552
+ const s = document.createElement("style");
553
+ s.id = "jrapps-style-464a3601";
554
+ s.textContent = ".cw-system-message {\n display: flex;\n align-items: center;\n gap: 10px;\n align-self: stretch;\n padding: 4px 8px;\n}\n\n.cw-system-message__line {\n flex: 1;\n border-top: 1px dashed var(--cw-border);\n}\n\n.cw-system-message__text {\n font-size: 11px;\n color: var(--cw-system-text);\n white-space: nowrap;\n flex-shrink: 0;\n font-style: italic;\n}\n";
555
+ document.head.appendChild(s);
556
+ }
557
+
558
+ // src/components/SiteChatComponentNew/Messages/SystemMessage.tsx
559
+ var import_jsx_runtime7 = require("react/jsx-runtime");
560
+ var SystemMessage = ({ message }) => {
561
+ var _a;
562
+ const label = message.message ? getSystemLabel(message.message) : (_a = message.message) != null ? _a : "";
563
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
564
+ "div",
565
+ {
566
+ className: "cw-system-message",
567
+ role: "listitem",
568
+ "aria-label": `System notification: ${label}`,
569
+ children: [
570
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" }),
571
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__text", children: label }),
572
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" })
573
+ ]
574
+ }
575
+ );
576
+ };
577
+ var SystemMessage_default = SystemMessage;
578
+
579
+ // src/components/SiteChatComponentNew/Messages/AttachmentMessage.css
580
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-dd846dee")) {
581
+ const s = document.createElement("style");
582
+ s.id = "jrapps-style-dd846dee";
583
+ s.textContent = ".cw-attachment-message {\n display: flex;\n flex-direction: column;\n gap: 3px;\n align-self: flex-start;\n max-width: 80%;\n}\n\n.cw-attachment-message--user {\n align-self: flex-end;\n align-items: flex-end;\n}\n\n.cw-attachment-message__card {\n display: flex;\n align-items: center;\n gap: 10px;\n background-color: var(--cw-agent-bubble);\n border: 1px solid var(--cw-border);\n border-radius: 12px;\n padding: 10px 14px;\n}\n\n.cw-attachment-message--user .cw-attachment-message__card {\n background-color: var(--cw-user-bubble);\n border-color: transparent;\n color: var(--cw-user-text);\n}\n\n.cw-attachment-message__icon {\n flex-shrink: 0;\n opacity: 0.75;\n display: flex;\n align-items: center;\n}\n\n.cw-attachment-message__info {\n display: flex;\n flex-direction: column;\n min-width: 0;\n flex: 1;\n}\n\n.cw-attachment-message__name {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.cw-attachment-message__label {\n font-size: 11px;\n opacity: 0.65;\n}\n\n.cw-attachment-message__open-btn {\n background-color: var(--cw-primary);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n padding: 5px 12px;\n font-family: var(--cw-font-family);\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n flex-shrink: 0;\n transition: opacity 0.15s ease;\n}\n\n.cw-attachment-message--user .cw-attachment-message__open-btn {\n background-color: rgba(255, 255, 255, 0.25);\n color: #ffffff;\n}\n\n.cw-attachment-message__open-btn:hover {\n opacity: 0.85;\n}\n\n.cw-attachment-message__open-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-attachment-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-attachment-message__time--right {\n padding-left: 0;\n padding-right: 2px;\n align-self: flex-end;\n}\n";
584
+ document.head.appendChild(s);
585
+ }
586
+
587
+ // src/components/SiteChatComponentNew/Messages/AttachmentMessage.tsx
588
+ var import_jsx_runtime8 = require("react/jsx-runtime");
589
+ var AttachmentMessage = ({ message }) => {
590
+ var _a;
591
+ const attachment = (_a = message.item) != null ? _a : message.attachment;
592
+ if (!attachment) return null;
593
+ const handleOpen = () => {
594
+ window.open(attachment.url, "_blank", "noopener,noreferrer");
595
+ };
596
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
597
+ "div",
598
+ {
599
+ className: `cw-attachment-message${message.senderType === "user" ? " cw-attachment-message--user" : ""}`,
600
+ role: "listitem",
601
+ "aria-label": `Attachment: ${attachment.name}`,
602
+ children: [
603
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "cw-attachment-message__card", children: [
604
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "cw-attachment-message__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
605
+ "svg",
606
+ {
607
+ xmlns: "http://www.w3.org/2000/svg",
608
+ width: "24",
609
+ height: "24",
610
+ viewBox: "0 0 24 24",
611
+ fill: "none",
612
+ stroke: "currentColor",
613
+ strokeWidth: "2",
614
+ strokeLinecap: "round",
615
+ strokeLinejoin: "round",
616
+ children: [
617
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
618
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("polyline", { points: "14 2 14 8 20 8" })
619
+ ]
620
+ }
621
+ ) }),
622
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "cw-attachment-message__info", children: [
623
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cw-attachment-message__name", children: attachment.name }),
624
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cw-attachment-message__label", children: "Attachment" })
625
+ ] }),
626
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
627
+ "button",
628
+ {
629
+ className: "cw-attachment-message__open-btn",
630
+ onClick: handleOpen,
631
+ "aria-label": `Open attachment ${attachment.name}`,
632
+ type: "button",
633
+ children: "Open"
634
+ }
635
+ )
636
+ ] }),
637
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
638
+ "span",
639
+ {
640
+ className: `cw-attachment-message__time${message.senderType === "user" ? " cw-attachment-message__time--right" : ""}`,
641
+ children: formatTime(message.timestamp)
642
+ }
643
+ )
644
+ ]
645
+ }
646
+ );
647
+ };
648
+ var AttachmentMessage_default = AttachmentMessage;
649
+
650
+ // src/components/SiteChatComponentNew/Messages/MessageRenderer.tsx
651
+ var import_jsx_runtime9 = require("react/jsx-runtime");
652
+ var MessageRenderer = ({ message }) => {
653
+ if (message.messageType === "ATTACHMENT") {
654
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AttachmentMessage_default, { message });
655
+ }
656
+ switch (message.senderType) {
657
+ case "user":
658
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(UserMessage_default, { message });
659
+ case "agent":
660
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AgentMessage_default, { message });
661
+ case "system":
662
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SystemMessage_default, { message });
663
+ default:
664
+ return null;
665
+ }
666
+ };
667
+ var MessageRenderer_default = MessageRenderer;
668
+
669
+ // src/components/SiteChatComponentNew/Messages/MessageList.css
670
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-15ae1a6b")) {
671
+ const s = document.createElement("style");
672
+ s.id = "jrapps-style-15ae1a6b";
673
+ s.textContent = ".cw-message-list {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 10px;\n overflow-y: auto;\n padding: 16px;\n background-color: var(--cw-background);\n scroll-behavior: smooth;\n}\n\n/* Scrollbar styling */\n.cw-message-list::-webkit-scrollbar {\n width: 5px;\n}\n\n.cw-message-list::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.cw-message-list::-webkit-scrollbar-thumb {\n background-color: var(--cw-border);\n border-radius: 10px;\n}\n";
674
+ document.head.appendChild(s);
675
+ }
676
+
677
+ // src/components/SiteChatComponentNew/Messages/MessageList.tsx
678
+ var import_jsx_runtime10 = require("react/jsx-runtime");
679
+ var MessageList = ({ messages }) => {
680
+ const scrollRef = useAutoScroll(messages);
681
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
682
+ "div",
683
+ {
684
+ ref: scrollRef,
685
+ className: "cw-message-list",
686
+ role: "list",
687
+ "aria-label": "Chat messages",
688
+ "aria-live": "polite",
689
+ "aria-relevant": "additions",
690
+ children: messages.map((msg, index) => {
691
+ var _a, _b;
692
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
693
+ MessageRenderer_default,
694
+ {
695
+ message: msg
696
+ },
697
+ (_b = msg._id) != null ? _b : `${(_a = msg.timestamp) != null ? _a : index}-${index}`
698
+ );
699
+ })
700
+ }
701
+ );
702
+ };
703
+ var MessageList_default = MessageList;
704
+
705
+ // src/components/SiteChatComponentNew/Messages/TypingIndicator.css
706
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-4b0ca05b")) {
707
+ const s = document.createElement("style");
708
+ s.id = "jrapps-style-4b0ca05b";
709
+ s.textContent = "@keyframes cw-bounce {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-6px);\n }\n}\n\n.cw-typing-indicator {\n align-self: flex-start;\n}\n\n.cw-typing-indicator__bubble {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background-color: var(--cw-agent-bubble);\n border-radius: 18px 18px 18px 4px;\n padding: 10px 14px;\n}\n\n.cw-typing-indicator__dot {\n display: block;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background-color: var(--cw-system-text);\n animation: cw-bounce 1.2s infinite ease-in-out;\n}\n\n.cw-typing-indicator__dot:nth-child(2) {\n animation-delay: 0.2s;\n}\n\n.cw-typing-indicator__dot:nth-child(3) {\n animation-delay: 0.4s;\n}\n";
710
+ document.head.appendChild(s);
711
+ }
712
+
713
+ // src/components/SiteChatComponentNew/Messages/TypingIndicator.tsx
714
+ var import_jsx_runtime11 = require("react/jsx-runtime");
715
+
716
+ // src/components/SiteChatComponentNew/States/LoadingState.css
717
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-7a5a4f05")) {
718
+ const s = document.createElement("style");
719
+ s.id = "jrapps-style-7a5a4f05";
720
+ s.textContent = "@keyframes cw-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.cw-loading-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-loading-state__spinner {\n width: 48px;\n height: 48px;\n}\n\n.cw-loading-state__spinner-ring {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n border: 3px solid var(--cw-border);\n border-top-color: var(--cw-primary);\n animation: cw-spin 0.8s linear infinite;\n}\n\n.cw-loading-state__title {\n font-size: 16px;\n font-weight: 600;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-loading-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.5;\n}\n";
721
+ document.head.appendChild(s);
722
+ }
723
+
724
+ // src/components/SiteChatComponentNew/States/LoadingState.tsx
725
+ var import_jsx_runtime12 = require("react/jsx-runtime");
726
+ var LoadingState = () => {
727
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
728
+ "div",
729
+ {
730
+ className: "cw-loading-state",
731
+ role: "status",
732
+ "aria-label": "Connecting to chat",
733
+ children: [
734
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "cw-loading-state__spinner", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "cw-loading-state__spinner-ring" }) }),
735
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "cw-loading-state__title", children: "Connecting\u2026" }),
736
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "cw-loading-state__subtitle", children: "Please wait while we connect you to an available agent." })
737
+ ]
738
+ }
739
+ );
740
+ };
741
+ var LoadingState_default = LoadingState;
742
+
743
+ // src/components/SiteChatComponentNew/States/StartChatState.css
744
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3e05ef30")) {
745
+ const s = document.createElement("style");
746
+ s.id = "jrapps-style-3e05ef30";
747
+ s.textContent = ".cw-start-chat-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 14px;\n}\n\n.cw-start-chat-state__image {\n width: 80px;\n height: 80px;\n object-fit: contain;\n border-radius: 50%;\n margin-bottom: 4px;\n}\n\n.cw-start-chat-state__title {\n font-size: 20px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-start-chat-state__description {\n font-size: 14px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 260px;\n line-height: 1.6;\n}\n";
748
+ document.head.appendChild(s);
749
+ }
750
+
751
+ // src/components/SiteChatComponentNew/States/StartChatState.tsx
752
+ var import_jsx_runtime13 = require("react/jsx-runtime");
753
+ var StartChatState = ({
754
+ image,
755
+ title,
756
+ description,
757
+ onStart
758
+ }) => {
759
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
760
+ "div",
761
+ {
762
+ className: "cw-start-chat-state",
763
+ role: "main",
764
+ "aria-label": "Start a chat",
765
+ children: [
766
+ image && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
767
+ "img",
768
+ {
769
+ src: image,
770
+ alt: "Support illustration",
771
+ className: "cw-start-chat-state__image"
772
+ }
773
+ ),
774
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { className: "cw-start-chat-state__title", children: title }),
775
+ description && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "cw-start-chat-state__description", children: description }),
776
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button_default, { onClick: onStart, ariaLabel: "Start chat", children: "Start Chat" })
777
+ ]
778
+ }
779
+ );
780
+ };
781
+ var StartChatState_default = StartChatState;
782
+
783
+ // src/components/SiteChatComponentNew/OfflineForm/OfflineForm.css
784
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-d9ff3956")) {
785
+ const s = document.createElement("style");
786
+ s.id = "jrapps-style-d9ff3956";
787
+ s.textContent = `.cw-offline-form {
788
+ display: flex;
789
+ flex-direction: column;
790
+ gap: 14px;
791
+ }
792
+
793
+ .cw-offline-form__title {
794
+ font-size: 15px;
795
+ font-weight: 600;
796
+ color: var(--cw-agent-text);
797
+ margin: 0 0 4px;
798
+ }
799
+
800
+ /* Field wrapper */
801
+ .cw-offline-form__field {
802
+ display: flex;
803
+ flex-direction: column;
804
+ gap: 5px;
805
+ }
806
+
807
+ .cw-offline-form__field--checkbox {
808
+ gap: 4px;
809
+ }
810
+
811
+ /* Label */
812
+ .cw-offline-form__label {
813
+ font-size: 13px;
814
+ font-weight: 500;
815
+ color: var(--cw-agent-text);
816
+ }
817
+
818
+ .cw-offline-form__required {
819
+ color: #ef4444;
820
+ }
821
+
822
+ /* Text input */
823
+ .cw-offline-form__input {
824
+ width: 100%;
825
+ padding: 8px 12px;
826
+ border: 1px solid var(--cw-input-border);
827
+ border-radius: var(--cw-button-radius);
828
+ background-color: var(--cw-input-background);
829
+ font-family: var(--cw-font-family);
830
+ font-size: var(--cw-font-size);
831
+ color: inherit;
832
+ box-sizing: border-box;
833
+ transition: border-color 0.15s ease;
834
+ }
835
+
836
+ .cw-offline-form__input:focus {
837
+ outline: none;
838
+ border-color: var(--cw-primary);
839
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
840
+ }
841
+
842
+ .cw-offline-form__input--error {
843
+ border-color: #ef4444;
844
+ }
845
+
846
+ /* Textarea */
847
+ .cw-offline-form__textarea {
848
+ width: 100%;
849
+ padding: 8px 12px;
850
+ border: 1px solid var(--cw-input-border);
851
+ border-radius: var(--cw-button-radius);
852
+ background-color: var(--cw-input-background);
853
+ font-family: var(--cw-font-family);
854
+ font-size: var(--cw-font-size);
855
+ color: inherit;
856
+ resize: vertical;
857
+ box-sizing: border-box;
858
+ transition: border-color 0.15s ease;
859
+ }
860
+
861
+ .cw-offline-form__textarea:focus {
862
+ outline: none;
863
+ border-color: var(--cw-primary);
864
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
865
+ }
866
+
867
+ .cw-offline-form__textarea--error {
868
+ border-color: #ef4444;
869
+ }
870
+
871
+ /* Select */
872
+ .cw-offline-form__select {
873
+ width: 100%;
874
+ padding: 8px 12px;
875
+ border: 1px solid var(--cw-input-border);
876
+ border-radius: var(--cw-button-radius);
877
+ background-color: var(--cw-input-background);
878
+ font-family: var(--cw-font-family);
879
+ font-size: var(--cw-font-size);
880
+ color: inherit;
881
+ box-sizing: border-box;
882
+ appearance: none;
883
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
884
+ background-repeat: no-repeat;
885
+ background-position: right 12px center;
886
+ padding-right: 32px;
887
+ cursor: pointer;
888
+ transition: border-color 0.15s ease;
889
+ }
890
+
891
+ .cw-offline-form__select:focus {
892
+ outline: none;
893
+ border-color: var(--cw-primary);
894
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
895
+ }
896
+
897
+ .cw-offline-form__select--error {
898
+ border-color: #ef4444;
899
+ }
900
+
901
+ /* Checkbox */
902
+ .cw-offline-form__checkbox-label {
903
+ display: flex;
904
+ align-items: flex-start;
905
+ gap: 8px;
906
+ cursor: pointer;
907
+ font-size: 13px;
908
+ color: var(--cw-agent-text);
909
+ }
910
+
911
+ .cw-offline-form__checkbox {
912
+ width: 16px;
913
+ height: 16px;
914
+ accent-color: var(--cw-primary);
915
+ flex-shrink: 0;
916
+ margin-top: 1px;
917
+ cursor: pointer;
918
+ }
919
+
920
+ .cw-offline-form__checkbox:focus-visible {
921
+ outline: 2px solid var(--cw-primary);
922
+ outline-offset: 2px;
923
+ }
924
+
925
+ .cw-offline-form__checkbox-text {
926
+ line-height: 1.4;
927
+ }
928
+
929
+ /* Error message */
930
+ .cw-offline-form__error {
931
+ font-size: 12px;
932
+ color: #ef4444;
933
+ font-weight: 500;
934
+ }
935
+
936
+ /* Actions */
937
+ .cw-offline-form__actions {
938
+ margin-top: 4px;
939
+ }
940
+ `;
941
+ document.head.appendChild(s);
942
+ }
943
+
944
+ // src/components/SiteChatComponentNew/OfflineForm/OfflineForm.tsx
945
+ var import_jsx_runtime14 = require("react/jsx-runtime");
946
+ var FieldRenderer = ({
947
+ field,
948
+ value,
949
+ error,
950
+ onChange
951
+ }) => {
952
+ var _a, _b;
953
+ const hasError = error.length > 0;
954
+ const fieldId = `cw-offline-field-${field.id}`;
955
+ const errorId = `${fieldId}-error`;
956
+ const commonProps = {
957
+ id: fieldId,
958
+ className: `cw-offline-form__input${hasError ? " cw-offline-form__input--error" : ""}`,
959
+ "aria-invalid": hasError,
960
+ "aria-describedby": hasError ? errorId : void 0,
961
+ required: field.required
962
+ };
963
+ if (field.type === "textarea") {
964
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field", children: [
965
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
966
+ field.label,
967
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
968
+ " ",
969
+ "*"
970
+ ] })
971
+ ] }),
972
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
973
+ "textarea",
974
+ {
975
+ ...commonProps,
976
+ value: String(value != null ? value : ""),
977
+ placeholder: field.placeholder,
978
+ rows: 3,
979
+ onChange: (e) => onChange(field.id, e.target.value),
980
+ className: `cw-offline-form__textarea${hasError ? " cw-offline-form__textarea--error" : ""}`
981
+ }
982
+ ),
983
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
984
+ ] });
985
+ }
986
+ if (field.type === "select") {
987
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field", children: [
988
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
989
+ field.label,
990
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
991
+ " ",
992
+ "*"
993
+ ] })
994
+ ] }),
995
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
996
+ "select",
997
+ {
998
+ ...commonProps,
999
+ value: String(value != null ? value : ""),
1000
+ onChange: (e) => onChange(field.id, e.target.value),
1001
+ className: `cw-offline-form__select${hasError ? " cw-offline-form__select--error" : ""}`,
1002
+ children: [
1003
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: (_a = field.placeholder) != null ? _a : `Select ${field.label}` }),
1004
+ (_b = field.options) == null ? void 0 : _b.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
1005
+ ]
1006
+ }
1007
+ ),
1008
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1009
+ ] });
1010
+ }
1011
+ if (field.type === "checkbox") {
1012
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field cw-offline-form__field--checkbox", children: [
1013
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "cw-offline-form__checkbox-label", htmlFor: fieldId, children: [
1014
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1015
+ "input",
1016
+ {
1017
+ type: "checkbox",
1018
+ id: fieldId,
1019
+ checked: Boolean(value),
1020
+ onChange: (e) => onChange(field.id, e.target.checked),
1021
+ className: "cw-offline-form__checkbox",
1022
+ "aria-invalid": hasError,
1023
+ "aria-describedby": hasError ? errorId : void 0,
1024
+ required: field.required
1025
+ }
1026
+ ),
1027
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__checkbox-text", children: [
1028
+ field.label,
1029
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1030
+ " ",
1031
+ "*"
1032
+ ] })
1033
+ ] })
1034
+ ] }),
1035
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1036
+ ] });
1037
+ }
1038
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field", children: [
1039
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
1040
+ field.label,
1041
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1042
+ " ",
1043
+ "*"
1044
+ ] })
1045
+ ] }),
1046
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1047
+ "input",
1048
+ {
1049
+ ...commonProps,
1050
+ type: field.type,
1051
+ value: String(value != null ? value : ""),
1052
+ placeholder: field.placeholder,
1053
+ onChange: (e) => onChange(field.id, e.target.value)
1054
+ }
1055
+ ),
1056
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1057
+ ] });
1058
+ };
1059
+ var OfflineForm = ({ schema, onSubmit }) => {
1060
+ const { values, errors, setValue, handleSubmit } = useOfflineForm(schema);
1061
+ const onFormSubmit = (e) => {
1062
+ e.preventDefault();
1063
+ handleSubmit(onSubmit);
1064
+ };
1065
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1066
+ "form",
1067
+ {
1068
+ className: "cw-offline-form",
1069
+ onSubmit: onFormSubmit,
1070
+ "aria-label": schema.title,
1071
+ noValidate: true,
1072
+ children: [
1073
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "cw-offline-form__title", children: schema.title }),
1074
+ schema.fields.map((field) => {
1075
+ var _a;
1076
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1077
+ FieldRenderer,
1078
+ {
1079
+ field,
1080
+ value: values[field.id],
1081
+ error: (_a = errors[field.id]) != null ? _a : "",
1082
+ onChange: setValue
1083
+ },
1084
+ field.id
1085
+ );
1086
+ }),
1087
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", { className: "cw-offline-form__actions", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Button_default, { type: "submit", fullWidth: true, children: schema.submitButtonText }) })
1088
+ ]
1089
+ }
1090
+ );
1091
+ };
1092
+ var OfflineForm_default = OfflineForm;
1093
+
1094
+ // src/components/SiteChatComponentNew/States/OfflineState.css
1095
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-8b15ae78")) {
1096
+ const s = document.createElement("style");
1097
+ s.id = "jrapps-style-8b15ae78";
1098
+ s.textContent = ".cw-offline-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n background-color: var(--cw-background);\n overflow-y: auto;\n}\n\n.cw-offline-state__header {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n padding: 28px 24px 16px;\n gap: 8px;\n}\n\n.cw-offline-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 4px;\n}\n\n.cw-offline-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-offline-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n line-height: 1.6;\n max-width: 280px;\n}\n\n.cw-offline-state__form-wrapper {\n padding: 0 16px 16px;\n}\n";
1099
+ document.head.appendChild(s);
1100
+ }
1101
+
1102
+ // src/components/SiteChatComponentNew/States/OfflineState.tsx
1103
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1104
+ var OfflineState = ({ form, onSubmit }) => {
1105
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1106
+ "div",
1107
+ {
1108
+ className: "cw-offline-state",
1109
+ role: "main",
1110
+ "aria-label": "Business is offline",
1111
+ children: [
1112
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "cw-offline-state__header", children: [
1113
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "cw-offline-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1114
+ "svg",
1115
+ {
1116
+ xmlns: "http://www.w3.org/2000/svg",
1117
+ width: "32",
1118
+ height: "32",
1119
+ viewBox: "0 0 24 24",
1120
+ fill: "none",
1121
+ stroke: "currentColor",
1122
+ strokeWidth: "2",
1123
+ strokeLinecap: "round",
1124
+ strokeLinejoin: "round",
1125
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("path", { d: "M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" })
1126
+ }
1127
+ ) }),
1128
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h2", { className: "cw-offline-state__title", children: "We're currently offline" }),
1129
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "cw-offline-state__subtitle", children: "Please leave us a message and we'll get back to you as soon as possible." })
1130
+ ] }),
1131
+ form && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "cw-offline-state__form-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(OfflineForm_default, { schema: form, onSubmit }) })
1132
+ ]
1133
+ }
1134
+ );
1135
+ };
1136
+ var OfflineState_default = OfflineState;
1137
+
1138
+ // src/components/SiteChatComponentNew/States/ChatEndedState.css
1139
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-59a49fdf")) {
1140
+ const s = document.createElement("style");
1141
+ s.id = "jrapps-style-59a49fdf";
1142
+ s.textContent = ".cw-chat-ended-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-chat-ended-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-chat-ended-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-chat-ended-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.6;\n}\n";
1143
+ document.head.appendChild(s);
1144
+ }
1145
+
1146
+ // src/components/SiteChatComponentNew/States/ChatEndedState.tsx
1147
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1148
+ var ChatEndedState = () => {
1149
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1150
+ "div",
1151
+ {
1152
+ className: "cw-chat-ended-state",
1153
+ role: "status",
1154
+ "aria-label": "Chat has ended",
1155
+ children: [
1156
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "cw-chat-ended-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1157
+ "svg",
1158
+ {
1159
+ xmlns: "http://www.w3.org/2000/svg",
1160
+ width: "32",
1161
+ height: "32",
1162
+ viewBox: "0 0 24 24",
1163
+ fill: "none",
1164
+ stroke: "currentColor",
1165
+ strokeWidth: "2",
1166
+ strokeLinecap: "round",
1167
+ strokeLinejoin: "round",
1168
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("polyline", { points: "20 6 9 17 4 12" })
1169
+ }
1170
+ ) }),
1171
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "cw-chat-ended-state__title", children: "Chat Ended" }),
1172
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "cw-chat-ended-state__subtitle", children: "Your chat session has ended. Thank you for reaching out!" })
1173
+ ]
1174
+ }
1175
+ );
1176
+ };
1177
+ var ChatEndedState_default = ChatEndedState;
1178
+
1179
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.css
1180
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-871af89c")) {
1181
+ const s = document.createElement("style");
1182
+ s.id = "jrapps-style-871af89c";
1183
+ s.textContent = "/* \u2500\u2500\u2500 Root container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * Fixed to bottom-right by default so it works out-of-the-box.\n * Override with your own positioning class if embedding differently.\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.cw-root {\n position: fixed;\n bottom: max(24px, env(safe-area-inset-bottom));\n right: max(24px, env(safe-area-inset-right));\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 12px;\n z-index: 9999;\n /* Scope CSS vars and stacking context */\n isolation: isolate;\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n}\n\n/* \u2500\u2500\u2500 Widget Panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-widget {\n display: flex;\n flex-direction: column;\n width: var(--cw-width);\n height: var(--cw-height);\n /* Clamp so it never overflows the viewport on small screens */\n max-width: calc(100vw - 48px);\n max-height: calc(100dvh - 96px);\n background-color: var(--cw-background);\n border-radius: var(--cw-border-radius);\n box-shadow: var(--cw-shadow);\n overflow: hidden;\n /* Entry animation */\n animation: cw-panel-in 0.22s ease;\n transform-origin: bottom right;\n}\n\n@keyframes cw-panel-in {\n from {\n opacity: 0;\n transform: scale(0.92) translateY(10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n.cw-widget__body {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n}\n\n/* \u2500\u2500\u2500 Launcher Button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-launcher {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background-color: var(--cw-primary);\n color: #ffffff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);\n flex-shrink: 0;\n transition: transform 0.15s ease, box-shadow 0.15s ease;\n}\n\n.cw-launcher:hover {\n transform: scale(1.07);\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.26);\n}\n\n.cw-launcher:focus-visible {\n outline: 3px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-launcher:active {\n transform: scale(0.96);\n}\n\n/* \u2500\u2500\u2500 Tablet (481px \u2013 768px): panel floats, slightly narrower margin \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (min-width: 481px) and (max-width: 768px) {\n .cw-root {\n bottom: max(16px, env(safe-area-inset-bottom));\n right: max(16px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n max-width: calc(100vw - 32px);\n max-height: calc(100dvh - 80px);\n }\n}\n\n/* \u2500\u2500\u2500 Mobile (\u2264 480px): full-screen panel, launcher stays fixed \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (max-width: 480px) {\n .cw-root {\n bottom: 0;\n right: 0;\n gap: 0;\n }\n\n .cw-root > .cw-launcher {\n position: fixed;\n bottom: max(20px, env(safe-area-inset-bottom));\n right: max(20px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n width: 100vw;\n max-width: 100vw;\n height: 100dvh;\n max-height: 100dvh;\n border-radius: 0;\n transform-origin: bottom center;\n }\n}\n";
1184
+ document.head.appendChild(s);
1185
+ }
1186
+
1187
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
1188
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1189
+ var SiteChatComponentNew = import_react5.default.forwardRef(({
1190
+ title,
1191
+ subtitle,
1192
+ image,
1193
+ theme,
1194
+ messages,
1195
+ offlineForm,
1196
+ defaultOpen = false,
1197
+ loading = false,
1198
+ chatEnded = false,
1199
+ width,
1200
+ height,
1201
+ onSend,
1202
+ onAttachment,
1203
+ onOfflineSubmit,
1204
+ onClose
1205
+ }, ref) => {
1206
+ const { open, openWidget, closeWidget } = useSiteChatComponentNew(defaultOpen);
1207
+ const themeVars = buildThemeVars(theme);
1208
+ const handleClose = () => {
1209
+ closeWidget();
1210
+ onClose == null ? void 0 : onClose();
1211
+ };
1212
+ const renderBody = () => {
1213
+ if (loading) {
1214
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LoadingState_default, {});
1215
+ }
1216
+ if (offlineForm) {
1217
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(OfflineState_default, { form: offlineForm, onSubmit: onOfflineSubmit });
1218
+ }
1219
+ if (messages.length === 0) {
1220
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1221
+ StartChatState_default,
1222
+ {
1223
+ image,
1224
+ title,
1225
+ description: subtitle,
1226
+ onStart: () => onSend("__start_chat__")
1227
+ }
1228
+ );
1229
+ }
1230
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1231
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageList_default, { messages }),
1232
+ chatEnded ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatEndedState_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Footer_default, { onSend, onAttachment })
1233
+ ] });
1234
+ };
1235
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref, className: "cw-root", style: themeVars, children: [
1236
+ open && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1237
+ "div",
1238
+ {
1239
+ className: "cw-widget",
1240
+ role: "dialog",
1241
+ "aria-modal": "true",
1242
+ "aria-label": `${title} chat widget`,
1243
+ style: { ...width !== void 0 && { width }, ...height !== void 0 && { height } },
1244
+ children: [
1245
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1246
+ Header_default,
1247
+ {
1248
+ image,
1249
+ title,
1250
+ subtitle,
1251
+ onClose: handleClose
1252
+ }
1253
+ ),
1254
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "cw-widget__body", children: renderBody() })
1255
+ ]
1256
+ }
1257
+ ),
1258
+ !open && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1259
+ "button",
1260
+ {
1261
+ className: "cw-launcher",
1262
+ onClick: openWidget,
1263
+ "aria-label": "Open chat",
1264
+ "aria-haspopup": "dialog",
1265
+ type: "button",
1266
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1267
+ "svg",
1268
+ {
1269
+ xmlns: "http://www.w3.org/2000/svg",
1270
+ width: "26",
1271
+ height: "26",
1272
+ viewBox: "0 0 24 24",
1273
+ fill: "currentColor",
1274
+ "aria-hidden": "true",
1275
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z" })
1276
+ }
1277
+ )
1278
+ }
1279
+ )
1280
+ ] });
1281
+ });
1282
+ SiteChatComponentNew.displayName = "SiteChatComponentNew";
1283
+ //# sourceMappingURL=index.js.map