@jrapps/my_tickets_chat_ui 0.2.3 → 0.3.2

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 (129) hide show
  1. package/dist/cjs/components/SiteChatComponentNewErc/index.js +1334 -0
  2. package/dist/cjs/components/SiteChatComponentNewErc/index.js.map +7 -0
  3. package/dist/cjs/index.js +1505 -1169
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/chunks/chunk-364KVRPG.mjs +1302 -0
  6. package/dist/esm/chunks/chunk-364KVRPG.mjs.map +7 -0
  7. package/dist/esm/chunks/{chunk-QGWQSJDB.js → chunk-54X5DYPJ.mjs} +1 -1
  8. package/dist/esm/components/SiteChatComponentNew/{index.js → index.mjs} +2 -2
  9. package/dist/esm/components/SiteChatComponentNewErc/index.mjs +9 -0
  10. package/dist/esm/index.mjs +15 -0
  11. package/dist/types/components/SiteChatComponentNewErc/Footer/Footer.d.ts +6 -0
  12. package/dist/types/components/SiteChatComponentNewErc/Footer/Footer.d.ts.map +1 -0
  13. package/dist/types/components/SiteChatComponentNewErc/Footer/index.d.ts +2 -0
  14. package/dist/types/components/SiteChatComponentNewErc/Footer/index.d.ts.map +1 -0
  15. package/dist/types/components/SiteChatComponentNewErc/Header/Header.d.ts +6 -0
  16. package/dist/types/components/SiteChatComponentNewErc/Header/Header.d.ts.map +1 -0
  17. package/dist/types/components/SiteChatComponentNewErc/Header/index.d.ts +2 -0
  18. package/dist/types/components/SiteChatComponentNewErc/Header/index.d.ts.map +1 -0
  19. package/dist/types/components/SiteChatComponentNewErc/Messages/AgentMessage.d.ts +10 -0
  20. package/dist/types/components/SiteChatComponentNewErc/Messages/AgentMessage.d.ts.map +1 -0
  21. package/dist/types/components/SiteChatComponentNewErc/Messages/AttachmentMessage.d.ts +9 -0
  22. package/dist/types/components/SiteChatComponentNewErc/Messages/AttachmentMessage.d.ts.map +1 -0
  23. package/dist/types/components/SiteChatComponentNewErc/Messages/MessageList.d.ts +10 -0
  24. package/dist/types/components/SiteChatComponentNewErc/Messages/MessageList.d.ts.map +1 -0
  25. package/dist/types/components/SiteChatComponentNewErc/Messages/MessageRenderer.d.ts +9 -0
  26. package/dist/types/components/SiteChatComponentNewErc/Messages/MessageRenderer.d.ts.map +1 -0
  27. package/dist/types/components/SiteChatComponentNewErc/Messages/SystemMessage.d.ts +10 -0
  28. package/dist/types/components/SiteChatComponentNewErc/Messages/SystemMessage.d.ts.map +1 -0
  29. package/dist/types/components/SiteChatComponentNewErc/Messages/TypingIndicator.d.ts +5 -0
  30. package/dist/types/components/SiteChatComponentNewErc/Messages/TypingIndicator.d.ts.map +1 -0
  31. package/dist/types/components/SiteChatComponentNewErc/Messages/UserMessage.d.ts +10 -0
  32. package/dist/types/components/SiteChatComponentNewErc/Messages/UserMessage.d.ts.map +1 -0
  33. package/dist/types/components/SiteChatComponentNewErc/Messages/index.d.ts +8 -0
  34. package/dist/types/components/SiteChatComponentNewErc/Messages/index.d.ts.map +1 -0
  35. package/dist/types/components/SiteChatComponentNewErc/OfflineForm/OfflineForm.d.ts +10 -0
  36. package/dist/types/components/SiteChatComponentNewErc/OfflineForm/OfflineForm.d.ts.map +1 -0
  37. package/dist/types/components/SiteChatComponentNewErc/OfflineForm/index.d.ts +2 -0
  38. package/dist/types/components/SiteChatComponentNewErc/OfflineForm/index.d.ts.map +1 -0
  39. package/dist/types/components/SiteChatComponentNewErc/Shared/Avatar.d.ts +10 -0
  40. package/dist/types/components/SiteChatComponentNewErc/Shared/Avatar.d.ts.map +1 -0
  41. package/dist/types/components/SiteChatComponentNewErc/Shared/Button.d.ts +14 -0
  42. package/dist/types/components/SiteChatComponentNewErc/Shared/Button.d.ts.map +1 -0
  43. package/dist/types/components/SiteChatComponentNewErc/Shared/index.d.ts +3 -0
  44. package/dist/types/components/SiteChatComponentNewErc/Shared/index.d.ts.map +1 -0
  45. package/dist/types/components/SiteChatComponentNewErc/SiteChatComponentNewErc.d.ts +5 -0
  46. package/dist/types/components/SiteChatComponentNewErc/SiteChatComponentNewErc.d.ts.map +1 -0
  47. package/dist/types/components/SiteChatComponentNewErc/SiteChatComponentNewErc.types.d.ts +146 -0
  48. package/dist/types/components/SiteChatComponentNewErc/SiteChatComponentNewErc.types.d.ts.map +1 -0
  49. package/dist/types/components/SiteChatComponentNewErc/States/ChatEndedState.d.ts +5 -0
  50. package/dist/types/components/SiteChatComponentNewErc/States/ChatEndedState.d.ts.map +1 -0
  51. package/dist/types/components/SiteChatComponentNewErc/States/LoadingState.d.ts +5 -0
  52. package/dist/types/components/SiteChatComponentNewErc/States/LoadingState.d.ts.map +1 -0
  53. package/dist/types/components/SiteChatComponentNewErc/States/OfflineState.d.ts +10 -0
  54. package/dist/types/components/SiteChatComponentNewErc/States/OfflineState.d.ts.map +1 -0
  55. package/dist/types/components/SiteChatComponentNewErc/States/StartChatState.d.ts +11 -0
  56. package/dist/types/components/SiteChatComponentNewErc/States/StartChatState.d.ts.map +1 -0
  57. package/dist/types/components/SiteChatComponentNewErc/States/index.d.ts +5 -0
  58. package/dist/types/components/SiteChatComponentNewErc/States/index.d.ts.map +1 -0
  59. package/dist/types/components/SiteChatComponentNewErc/hooks/index.d.ts +3 -0
  60. package/dist/types/components/SiteChatComponentNewErc/hooks/index.d.ts.map +1 -0
  61. package/dist/types/components/SiteChatComponentNewErc/hooks/useAutoScroll.d.ts +15 -0
  62. package/dist/types/components/SiteChatComponentNewErc/hooks/useAutoScroll.d.ts.map +1 -0
  63. package/dist/types/components/SiteChatComponentNewErc/hooks/useOfflineForm.d.ts +12 -0
  64. package/dist/types/components/SiteChatComponentNewErc/hooks/useOfflineForm.d.ts.map +1 -0
  65. package/dist/types/components/SiteChatComponentNewErc/index.d.ts +4 -0
  66. package/dist/types/components/SiteChatComponentNewErc/index.d.ts.map +1 -0
  67. package/dist/types/components/SiteChatComponentNewErc/useSiteChatComponentNewErc.d.ts +3 -0
  68. package/dist/types/components/SiteChatComponentNewErc/useSiteChatComponentNewErc.d.ts.map +1 -0
  69. package/dist/types/components/SiteChatComponentNewErc/utils/classNames.d.ts +28 -0
  70. package/dist/types/components/SiteChatComponentNewErc/utils/classNames.d.ts.map +1 -0
  71. package/dist/types/components/SiteChatComponentNewErc/utils/format.d.ts +9 -0
  72. package/dist/types/components/SiteChatComponentNewErc/utils/format.d.ts.map +1 -0
  73. package/dist/types/components/SiteChatComponentNewErc/utils/index.d.ts +4 -0
  74. package/dist/types/components/SiteChatComponentNewErc/utils/index.d.ts.map +1 -0
  75. package/dist/types/components/SiteChatComponentNewErc/utils/systemMessages.d.ts +4 -0
  76. package/dist/types/components/SiteChatComponentNewErc/utils/systemMessages.d.ts.map +1 -0
  77. package/dist/types/components/SiteChatComponentNewErc/utils/theme.d.ts +8 -0
  78. package/dist/types/components/SiteChatComponentNewErc/utils/theme.d.ts.map +1 -0
  79. package/dist/types/components/index.d.ts +1 -1
  80. package/dist/types/components/index.d.ts.map +1 -1
  81. package/package.json +4 -7
  82. package/dist/cjs/components/SiteChatComponent/index.js +0 -998
  83. package/dist/cjs/components/SiteChatComponent/index.js.map +0 -7
  84. package/dist/esm/chunks/chunk-QPJPV2T3.js +0 -971
  85. package/dist/esm/chunks/chunk-QPJPV2T3.js.map +0 -7
  86. package/dist/esm/components/SiteChatComponent/index.js +0 -7
  87. package/dist/esm/index.js +0 -13
  88. package/dist/types/components/SiteChatComponent/FabButton/FabButton.d.ts +0 -4
  89. package/dist/types/components/SiteChatComponent/FabButton/FabButton.d.ts.map +0 -1
  90. package/dist/types/components/SiteChatComponent/FabButton/FabButton.types.d.ts +0 -8
  91. package/dist/types/components/SiteChatComponent/FabButton/FabButton.types.d.ts.map +0 -1
  92. package/dist/types/components/SiteChatComponent/Footer/Footer.d.ts +0 -4
  93. package/dist/types/components/SiteChatComponent/Footer/Footer.d.ts.map +0 -1
  94. package/dist/types/components/SiteChatComponent/Footer/Footer.types.d.ts +0 -45
  95. package/dist/types/components/SiteChatComponent/Footer/Footer.types.d.ts.map +0 -1
  96. package/dist/types/components/SiteChatComponent/Footer/attachment-list/attachment-list.d.ts +0 -5
  97. package/dist/types/components/SiteChatComponent/Footer/attachment-list/attachment-list.d.ts.map +0 -1
  98. package/dist/types/components/SiteChatComponent/Footer/message-input/message-input.d.ts +0 -18
  99. package/dist/types/components/SiteChatComponent/Footer/message-input/message-input.d.ts.map +0 -1
  100. package/dist/types/components/SiteChatComponent/Footer/message-input/open-file-picker.d.ts +0 -10
  101. package/dist/types/components/SiteChatComponent/Footer/message-input/open-file-picker.d.ts.map +0 -1
  102. package/dist/types/components/SiteChatComponent/Footer/send-button/send-button.d.ts +0 -10
  103. package/dist/types/components/SiteChatComponent/Footer/send-button/send-button.d.ts.map +0 -1
  104. package/dist/types/components/SiteChatComponent/Header/Header.d.ts +0 -4
  105. package/dist/types/components/SiteChatComponent/Header/Header.d.ts.map +0 -1
  106. package/dist/types/components/SiteChatComponent/Header/Header.types.d.ts +0 -8
  107. package/dist/types/components/SiteChatComponent/Header/Header.types.d.ts.map +0 -1
  108. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.d.ts +0 -4
  109. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.d.ts.map +0 -1
  110. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts +0 -7
  111. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts.map +0 -1
  112. package/dist/types/components/SiteChatComponent/MessageContainer/messages/attachment.d.ts +0 -5
  113. package/dist/types/components/SiteChatComponent/MessageContainer/messages/attachment.d.ts.map +0 -1
  114. package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts +0 -5
  115. package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts.map +0 -1
  116. package/dist/types/components/SiteChatComponent/SiteChatComponent.d.ts +0 -11
  117. package/dist/types/components/SiteChatComponent/SiteChatComponent.d.ts.map +0 -1
  118. package/dist/types/components/SiteChatComponent/SiteChatComponent.types.d.ts +0 -10
  119. package/dist/types/components/SiteChatComponent/SiteChatComponent.types.d.ts.map +0 -1
  120. package/dist/types/components/SiteChatComponent/index.d.ts +0 -6
  121. package/dist/types/components/SiteChatComponent/index.d.ts.map +0 -1
  122. package/dist/types/components/SiteChatComponent/useSiteChatComponent.d.ts +0 -8
  123. package/dist/types/components/SiteChatComponent/useSiteChatComponent.d.ts.map +0 -1
  124. package/dist/types/test/test.d.ts +0 -8
  125. package/dist/types/test/test.d.ts.map +0 -1
  126. /package/dist/esm/chunks/{chunk-QGWQSJDB.js.map → chunk-54X5DYPJ.mjs.map} +0 -0
  127. /package/dist/esm/components/{SiteChatComponent/index.js.map → SiteChatComponentNew/index.mjs.map} +0 -0
  128. /package/dist/esm/components/{SiteChatComponentNew/index.js.map → SiteChatComponentNewErc/index.mjs.map} +0 -0
  129. /package/dist/esm/{index.js.map → index.mjs.map} +0 -0
@@ -0,0 +1,1334 @@
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/SiteChatComponentNewErc/index.ts
31
+ var SiteChatComponentNewErc_exports = {};
32
+ __export(SiteChatComponentNewErc_exports, {
33
+ SiteChatComponentNewErc: () => SiteChatComponentNewErc,
34
+ useSiteChatComponentNewErc: () => useSiteChatComponentNewErc
35
+ });
36
+ module.exports = __toCommonJS(SiteChatComponentNewErc_exports);
37
+
38
+ // src/components/SiteChatComponentNewErc/SiteChatComponentNewErc.tsx
39
+ var import_react5 = __toESM(require("react"));
40
+
41
+ // src/components/SiteChatComponentNewErc/useSiteChatComponentNewErc.ts
42
+ var import_react = require("react");
43
+ function useSiteChatComponentNewErc(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/SiteChatComponentNewErc/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, width, height) {
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 !== void 0 ? typeof width === "number" ? `${width}px` : width : WIDTH,
95
+ "--cw-height": height !== void 0 ? typeof height === "number" ? `${height}px` : height : HEIGHT,
96
+ "--cw-header-height": HEADER_HEIGHT
97
+ };
98
+ }
99
+
100
+ // src/components/SiteChatComponentNewErc/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/SiteChatComponentNewErc/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/SiteChatComponentNewErc/Header/Header.css
125
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-759620f0")) {
126
+ const s = document.createElement("style");
127
+ s.id = "jrapps-style-759620f0";
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/SiteChatComponentNewErc/Header/Header.tsx
133
+ var import_jsx_runtime = require("react/jsx-runtime");
134
+ var Header = ({ image, title, subtitle, onClose, ercClasses }) => {
135
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: ["cw-header", ercClasses == null ? void 0 : ercClasses.headerClassName].filter(Boolean).join(" "), 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", ercClasses == null ? void 0 : ercClasses.imageClassName].filter(Boolean).join(" ")
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", ercClasses == null ? void 0 : ercClasses.titleClassName].filter(Boolean).join(" "), children: title }),
147
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: ["cw-header__subtitle", ercClasses == null ? void 0 : ercClasses.subtitleClassName].filter(Boolean).join(" "), children: subtitle })
148
+ ] })
149
+ ] }),
150
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
+ "button",
152
+ {
153
+ className: ["cw-header__close", ercClasses == null ? void 0 : ercClasses.closeButtonClassName].filter(Boolean).join(" "),
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/SiteChatComponentNewErc/Footer/Footer.tsx
183
+ var import_react2 = require("react");
184
+
185
+ // src/components/SiteChatComponentNewErc/Footer/Footer.css
186
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-c86a5c82")) {
187
+ const s = document.createElement("style");
188
+ s.id = "jrapps-style-c86a5c82";
189
+ s.textContent = ".cw-footer {\n display: flex;\n flex-direction: column;\n gap: 6px;\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__controls {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n}\n\n/* \u2500\u2500\u2500 Staged file chips \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-footer__file-list {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-wrap: wrap;\n gap: 6px;\n}\n\n.cw-footer__file-chip {\n display: flex;\n align-items: center;\n gap: 4px;\n background-color: color-mix(in srgb, var(--cw-primary) 12%, transparent);\n border: 1px solid color-mix(in srgb, var(--cw-primary) 30%, transparent);\n border-radius: 999px;\n padding: 3px 8px 3px 10px;\n font-size: 12px;\n color: var(--cw-primary);\n max-width: 200px;\n}\n\n.cw-footer__file-chip-name {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.cw-footer__file-chip-remove {\n background: none;\n border: none;\n cursor: pointer;\n padding: 2px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: inherit;\n border-radius: 50%;\n flex-shrink: 0;\n opacity: 0.7;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n}\n\n.cw-footer__file-chip-remove:hover {\n opacity: 1;\n background-color: color-mix(in srgb, var(--cw-primary) 15%, transparent);\n}\n\n.cw-footer__file-chip-remove:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 1px;\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/SiteChatComponentNewErc/Footer/Footer.tsx
194
+ var import_jsx_runtime2 = require("react/jsx-runtime");
195
+ var Footer = ({ onSend, onAttachment, disabled, ercClasses }) => {
196
+ const [text, setText] = (0, import_react2.useState)("");
197
+ const [stagedFiles, setStagedFiles] = (0, import_react2.useState)([]);
198
+ const fileInputRef = (0, import_react2.useRef)(null);
199
+ const textareaRef = (0, import_react2.useRef)(null);
200
+ const isEmpty = text.trim().length === 0 && stagedFiles.length === 0;
201
+ const handleSend = (0, import_react2.useCallback)(() => {
202
+ if (!isEmpty && !disabled) {
203
+ if (text.trim().length > 0) {
204
+ onSend(text.trim());
205
+ setText("");
206
+ }
207
+ stagedFiles.forEach((file) => onAttachment(file));
208
+ setStagedFiles([]);
209
+ if (textareaRef.current) {
210
+ textareaRef.current.style.height = "auto";
211
+ textareaRef.current.focus();
212
+ }
213
+ }
214
+ }, [isEmpty, disabled, onSend, text, stagedFiles, onAttachment]);
215
+ const handleKeyDown = (0, import_react2.useCallback)(
216
+ (e) => {
217
+ if (e.key === "Enter" && !e.shiftKey) {
218
+ e.preventDefault();
219
+ handleSend();
220
+ }
221
+ },
222
+ [handleSend]
223
+ );
224
+ const handleChange = (0, import_react2.useCallback)(
225
+ (e) => {
226
+ setText(e.target.value);
227
+ const el = e.target;
228
+ el.style.height = "auto";
229
+ el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
230
+ },
231
+ []
232
+ );
233
+ const handleAttachmentClick = (0, import_react2.useCallback)(() => {
234
+ var _a;
235
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
236
+ }, []);
237
+ const handleFileChange = (0, import_react2.useCallback)(
238
+ (e) => {
239
+ var _a;
240
+ const files = Array.from((_a = e.target.files) != null ? _a : []);
241
+ if (files.length > 0) {
242
+ setStagedFiles((prev) => [...prev, ...files]);
243
+ }
244
+ if (fileInputRef.current) {
245
+ fileInputRef.current.value = "";
246
+ }
247
+ },
248
+ []
249
+ );
250
+ const handleRemoveStagedFile = (0, import_react2.useCallback)((index) => {
251
+ setStagedFiles((prev) => prev.filter((_, i) => i !== index));
252
+ }, []);
253
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("footer", { className: ["cw-footer", ercClasses == null ? void 0 : ercClasses.footerClassName].filter(Boolean).join(" "), role: "contentinfo", children: [
254
+ stagedFiles.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("ul", { className: "cw-footer__file-list", "aria-label": "Files to send", children: stagedFiles.map((file, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("li", { className: "cw-footer__file-chip", children: [
255
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "cw-footer__file-chip-name", title: file.name, children: file.name }),
256
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
257
+ "button",
258
+ {
259
+ className: "cw-footer__file-chip-remove",
260
+ onClick: () => handleRemoveStagedFile(i),
261
+ "aria-label": `Remove ${file.name}`,
262
+ type: "button",
263
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
264
+ }
265
+ )
266
+ ] }, `${file.name}-${i}`)) }),
267
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "cw-footer__controls", children: [
268
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
269
+ "button",
270
+ {
271
+ className: ["cw-footer__attach-btn", ercClasses == null ? void 0 : ercClasses.attachmentButtonClassName].filter(Boolean).join(" "),
272
+ onClick: handleAttachmentClick,
273
+ "aria-label": "Attach file",
274
+ type: "button",
275
+ disabled,
276
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
277
+ "svg",
278
+ {
279
+ xmlns: "http://www.w3.org/2000/svg",
280
+ width: "20",
281
+ height: "20",
282
+ viewBox: "0 0 24 24",
283
+ fill: "none",
284
+ stroke: "currentColor",
285
+ strokeWidth: "2",
286
+ strokeLinecap: "round",
287
+ strokeLinejoin: "round",
288
+ "aria-hidden": "true",
289
+ 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" })
290
+ }
291
+ )
292
+ }
293
+ ),
294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
295
+ "textarea",
296
+ {
297
+ ref: textareaRef,
298
+ className: ["cw-footer__input", ercClasses == null ? void 0 : ercClasses.inputClassName].filter(Boolean).join(" "),
299
+ value: text,
300
+ onChange: handleChange,
301
+ onKeyDown: handleKeyDown,
302
+ placeholder: "Type a message\u2026",
303
+ "aria-label": "Message input",
304
+ rows: 1,
305
+ disabled
306
+ }
307
+ ),
308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
309
+ "button",
310
+ {
311
+ className: [
312
+ "cw-footer__send-btn",
313
+ isEmpty || disabled ? "cw-footer__send-btn--disabled" : "",
314
+ ercClasses == null ? void 0 : ercClasses.sendButtonClassName
315
+ ].filter(Boolean).join(" "),
316
+ onClick: handleSend,
317
+ "aria-label": "Send message",
318
+ type: "button",
319
+ disabled: isEmpty || disabled,
320
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
321
+ "svg",
322
+ {
323
+ xmlns: "http://www.w3.org/2000/svg",
324
+ width: "20",
325
+ height: "20",
326
+ viewBox: "0 0 24 24",
327
+ fill: "currentColor",
328
+ "aria-hidden": "true",
329
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" })
330
+ }
331
+ )
332
+ }
333
+ ),
334
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
335
+ "input",
336
+ {
337
+ ref: fileInputRef,
338
+ type: "file",
339
+ className: "cw-footer__file-input",
340
+ onChange: handleFileChange,
341
+ "aria-hidden": "true",
342
+ tabIndex: -1,
343
+ multiple: true
344
+ }
345
+ )
346
+ ] })
347
+ ] });
348
+ };
349
+ var Footer_default = Footer;
350
+
351
+ // src/components/SiteChatComponentNewErc/hooks/useAutoScroll.ts
352
+ var import_react3 = require("react");
353
+ function useAutoScroll(dependency) {
354
+ const ref = (0, import_react3.useRef)(null);
355
+ const userScrolledUp = (0, import_react3.useRef)(false);
356
+ (0, import_react3.useEffect)(() => {
357
+ const el = ref.current;
358
+ if (!el) return;
359
+ const handleScroll = () => {
360
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 64;
361
+ userScrolledUp.current = !atBottom;
362
+ };
363
+ el.addEventListener("scroll", handleScroll, { passive: true });
364
+ return () => el.removeEventListener("scroll", handleScroll);
365
+ }, []);
366
+ (0, import_react3.useEffect)(() => {
367
+ const el = ref.current;
368
+ if (!el || userScrolledUp.current) return;
369
+ el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
370
+ }, [dependency]);
371
+ return ref;
372
+ }
373
+
374
+ // src/components/SiteChatComponentNewErc/hooks/useOfflineForm.ts
375
+ var import_react4 = require("react");
376
+ function validateField(field, value) {
377
+ if (field.required) {
378
+ if (field.type === "checkbox" && !value) {
379
+ return `${field.label} is required.`;
380
+ }
381
+ if (field.type !== "checkbox" && (value === void 0 || value === null || String(value).trim() === "")) {
382
+ return `${field.label} is required.`;
383
+ }
384
+ }
385
+ if (field.type === "email") {
386
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
387
+ if (value && !emailRegex.test(String(value))) {
388
+ return "Please enter a valid email address.";
389
+ }
390
+ }
391
+ if (field.type === "phone") {
392
+ const phoneRegex = /^\+?[\d\s\-().]{7,20}$/;
393
+ if (value && !phoneRegex.test(String(value))) {
394
+ return "Please enter a valid phone number.";
395
+ }
396
+ }
397
+ return "";
398
+ }
399
+ function useOfflineForm(schema) {
400
+ const initialValues = {};
401
+ for (const field of schema.fields) {
402
+ initialValues[field.id] = field.type === "checkbox" ? false : "";
403
+ }
404
+ const [values, setValues] = (0, import_react4.useState)(initialValues);
405
+ const [errors, setErrors] = (0, import_react4.useState)({});
406
+ const [submitted, setSubmitted] = (0, import_react4.useState)(false);
407
+ const setValue = (0, import_react4.useCallback)(
408
+ (id, value) => {
409
+ setValues((prev) => ({ ...prev, [id]: value }));
410
+ if (submitted) {
411
+ const field = schema.fields.find((f) => f.id === id);
412
+ if (field) {
413
+ const error = validateField(field, value);
414
+ setErrors((prev) => ({ ...prev, [id]: error }));
415
+ }
416
+ }
417
+ },
418
+ [schema.fields, submitted]
419
+ );
420
+ const validate = (0, import_react4.useCallback)(() => {
421
+ const newErrors = {};
422
+ let valid = true;
423
+ for (const field of schema.fields) {
424
+ const error = validateField(field, values[field.id]);
425
+ newErrors[field.id] = error;
426
+ if (error) valid = false;
427
+ }
428
+ setErrors(newErrors);
429
+ return valid;
430
+ }, [schema.fields, values]);
431
+ const handleSubmit = (0, import_react4.useCallback)(
432
+ (onSubmit) => {
433
+ setSubmitted(true);
434
+ if (validate()) {
435
+ onSubmit(values);
436
+ }
437
+ },
438
+ [validate, values]
439
+ );
440
+ const reset = (0, import_react4.useCallback)(() => {
441
+ setValues(initialValues);
442
+ setErrors({});
443
+ setSubmitted(false);
444
+ }, []);
445
+ return { values, errors, setValue, handleSubmit, reset };
446
+ }
447
+
448
+ // src/components/SiteChatComponentNewErc/Messages/UserMessage.css
449
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-488069e4")) {
450
+ const s = document.createElement("style");
451
+ s.id = "jrapps-style-488069e4";
452
+ 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";
453
+ document.head.appendChild(s);
454
+ }
455
+
456
+ // src/components/SiteChatComponentNewErc/Messages/UserMessage.tsx
457
+ var import_jsx_runtime3 = require("react/jsx-runtime");
458
+ var UserMessage = ({ message, ercClassName }) => {
459
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: ["cw-user-message", ercClassName].filter(Boolean).join(" "), role: "listitem", "aria-label": "Your message", children: [
460
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "cw-user-message__bubble", children: message.message }),
461
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "cw-user-message__time", children: formatTime(message.timestamp) })
462
+ ] });
463
+ };
464
+ var UserMessage_default = UserMessage;
465
+
466
+ // src/components/SiteChatComponentNewErc/Shared/Avatar.css
467
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ad01373e")) {
468
+ const s = document.createElement("style");
469
+ s.id = "jrapps-style-ad01373e";
470
+ 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";
471
+ document.head.appendChild(s);
472
+ }
473
+
474
+ // src/components/SiteChatComponentNewErc/Shared/Avatar.tsx
475
+ var import_jsx_runtime4 = require("react/jsx-runtime");
476
+ function getInitials(name) {
477
+ return name.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase();
478
+ }
479
+ var Avatar = ({ src, name, size = 32 }) => {
480
+ const style = {
481
+ width: `${size}px`,
482
+ height: `${size}px`,
483
+ fontSize: `${Math.round(size * 0.38)}px`
484
+ };
485
+ if (src) {
486
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
487
+ "img",
488
+ {
489
+ src,
490
+ alt: name ? `${name} avatar` : "Agent avatar",
491
+ className: "cw-avatar cw-avatar--image",
492
+ style
493
+ }
494
+ );
495
+ }
496
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
497
+ "span",
498
+ {
499
+ className: "cw-avatar cw-avatar--initials",
500
+ "aria-label": name ? `${name} avatar` : "Agent avatar",
501
+ style,
502
+ children: name ? getInitials(name) : "A"
503
+ }
504
+ );
505
+ };
506
+ var Avatar_default = Avatar;
507
+
508
+ // src/components/SiteChatComponentNewErc/Shared/Button.css
509
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-0aa71f6d")) {
510
+ const s = document.createElement("style");
511
+ s.id = "jrapps-style-0aa71f6d";
512
+ 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";
513
+ document.head.appendChild(s);
514
+ }
515
+
516
+ // src/components/SiteChatComponentNewErc/Shared/Button.tsx
517
+ var import_jsx_runtime5 = require("react/jsx-runtime");
518
+ var Button = ({
519
+ children,
520
+ onClick,
521
+ variant = "primary",
522
+ disabled = false,
523
+ type = "button",
524
+ fullWidth = false,
525
+ ariaLabel
526
+ }) => {
527
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
528
+ "button",
529
+ {
530
+ className: `cw-button cw-button--${variant}${fullWidth ? " cw-button--full" : ""}`,
531
+ onClick,
532
+ disabled,
533
+ type,
534
+ "aria-label": ariaLabel,
535
+ children
536
+ }
537
+ );
538
+ };
539
+ var Button_default = Button;
540
+
541
+ // src/components/SiteChatComponentNewErc/Messages/AgentMessage.css
542
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-f5aad44b")) {
543
+ const s = document.createElement("style");
544
+ s.id = "jrapps-style-f5aad44b";
545
+ 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";
546
+ document.head.appendChild(s);
547
+ }
548
+
549
+ // src/components/SiteChatComponentNewErc/Messages/AgentMessage.tsx
550
+ var import_jsx_runtime6 = require("react/jsx-runtime");
551
+ var AgentMessage = ({ message, ercClassName }) => {
552
+ var _a;
553
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
554
+ "div",
555
+ {
556
+ className: ["cw-agent-message", ercClassName].filter(Boolean).join(" "),
557
+ role: "listitem",
558
+ "aria-label": `Message from ${(_a = message.senderName) != null ? _a : "Agent"}`,
559
+ children: [
560
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Avatar_default, { name: message.senderName, size: 32 }),
561
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "cw-agent-message__content", children: [
562
+ message.senderName && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cw-agent-message__name", children: message.senderName }),
563
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "cw-agent-message__bubble", children: message.message }),
564
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cw-agent-message__time", children: formatTime(message.timestamp) })
565
+ ] })
566
+ ]
567
+ }
568
+ );
569
+ };
570
+ var AgentMessage_default = AgentMessage;
571
+
572
+ // src/components/SiteChatComponentNewErc/Messages/SystemMessage.css
573
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-631d733c")) {
574
+ const s = document.createElement("style");
575
+ s.id = "jrapps-style-631d733c";
576
+ 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";
577
+ document.head.appendChild(s);
578
+ }
579
+
580
+ // src/components/SiteChatComponentNewErc/Messages/SystemMessage.tsx
581
+ var import_jsx_runtime7 = require("react/jsx-runtime");
582
+ var SystemMessage = ({ message, ercClassName }) => {
583
+ var _a;
584
+ const label = message.message ? getSystemLabel(message.message) : (_a = message.message) != null ? _a : "";
585
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
586
+ "div",
587
+ {
588
+ className: ["cw-system-message", ercClassName].filter(Boolean).join(" "),
589
+ role: "listitem",
590
+ "aria-label": `System notification: ${label}`,
591
+ children: [
592
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" }),
593
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__text", children: label }),
594
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" })
595
+ ]
596
+ }
597
+ );
598
+ };
599
+ var SystemMessage_default = SystemMessage;
600
+
601
+ // src/components/SiteChatComponentNewErc/Messages/AttachmentMessage.css
602
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-daabdc64")) {
603
+ const s = document.createElement("style");
604
+ s.id = "jrapps-style-daabdc64";
605
+ 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";
606
+ document.head.appendChild(s);
607
+ }
608
+
609
+ // src/components/SiteChatComponentNewErc/Messages/AttachmentMessage.tsx
610
+ var import_jsx_runtime8 = require("react/jsx-runtime");
611
+ var AttachmentMessage = ({ message }) => {
612
+ var _a;
613
+ const attachment = (_a = message.item) != null ? _a : message.attachment;
614
+ if (!attachment) return null;
615
+ const handleOpen = () => {
616
+ window.open(attachment.url, "_blank", "noopener,noreferrer");
617
+ };
618
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
619
+ "div",
620
+ {
621
+ className: `cw-attachment-message${message.senderType === "user" ? " cw-attachment-message--user" : ""}`,
622
+ role: "listitem",
623
+ "aria-label": `Attachment: ${attachment.name}`,
624
+ children: [
625
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "cw-attachment-message__card", children: [
626
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "cw-attachment-message__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
627
+ "svg",
628
+ {
629
+ xmlns: "http://www.w3.org/2000/svg",
630
+ width: "24",
631
+ height: "24",
632
+ viewBox: "0 0 24 24",
633
+ fill: "none",
634
+ stroke: "currentColor",
635
+ strokeWidth: "2",
636
+ strokeLinecap: "round",
637
+ strokeLinejoin: "round",
638
+ children: [
639
+ /* @__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" }),
640
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("polyline", { points: "14 2 14 8 20 8" })
641
+ ]
642
+ }
643
+ ) }),
644
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "cw-attachment-message__info", children: [
645
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cw-attachment-message__name", children: attachment.name }),
646
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "cw-attachment-message__label", children: "Attachment" })
647
+ ] }),
648
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
649
+ "button",
650
+ {
651
+ className: "cw-attachment-message__open-btn",
652
+ onClick: handleOpen,
653
+ "aria-label": `Open attachment ${attachment.name}`,
654
+ type: "button",
655
+ children: "Open"
656
+ }
657
+ )
658
+ ] }),
659
+ message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
660
+ "span",
661
+ {
662
+ className: `cw-attachment-message__time${message.senderType === "user" ? " cw-attachment-message__time--right" : ""}`,
663
+ children: formatTime(message.timestamp)
664
+ }
665
+ )
666
+ ]
667
+ }
668
+ );
669
+ };
670
+ var AttachmentMessage_default = AttachmentMessage;
671
+
672
+ // src/components/SiteChatComponentNewErc/Messages/MessageRenderer.tsx
673
+ var import_jsx_runtime9 = require("react/jsx-runtime");
674
+ var MessageRenderer = ({ message, ercClasses }) => {
675
+ if (message.messageType === "ATTACHMENT") {
676
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AttachmentMessage_default, { message });
677
+ }
678
+ switch (message.senderType) {
679
+ case "user":
680
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(UserMessage_default, { message, ercClassName: ercClasses == null ? void 0 : ercClasses.userMessageClassName });
681
+ case "agent":
682
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AgentMessage_default, { message, ercClassName: ercClasses == null ? void 0 : ercClasses.agentMessageClassName });
683
+ case "system":
684
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SystemMessage_default, { message, ercClassName: ercClasses == null ? void 0 : ercClasses.systemMessageClassName });
685
+ default:
686
+ return null;
687
+ }
688
+ };
689
+ var MessageRenderer_default = MessageRenderer;
690
+
691
+ // src/components/SiteChatComponentNewErc/Messages/MessageList.css
692
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-0408335f")) {
693
+ const s = document.createElement("style");
694
+ s.id = "jrapps-style-0408335f";
695
+ 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";
696
+ document.head.appendChild(s);
697
+ }
698
+
699
+ // src/components/SiteChatComponentNewErc/Messages/MessageList.tsx
700
+ var import_jsx_runtime10 = require("react/jsx-runtime");
701
+ var MessageList = ({ messages, ercClasses }) => {
702
+ const scrollRef = useAutoScroll(messages);
703
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
704
+ "div",
705
+ {
706
+ ref: scrollRef,
707
+ className: ["cw-message-list", ercClasses == null ? void 0 : ercClasses.messageListClassName].filter(Boolean).join(" "),
708
+ role: "list",
709
+ "aria-label": "Chat messages",
710
+ "aria-live": "polite",
711
+ "aria-relevant": "additions",
712
+ children: messages.map((msg, index) => {
713
+ var _a, _b;
714
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
715
+ MessageRenderer_default,
716
+ {
717
+ message: msg,
718
+ ercClasses
719
+ },
720
+ (_b = msg._id) != null ? _b : `${(_a = msg.timestamp) != null ? _a : index}-${index}`
721
+ );
722
+ })
723
+ }
724
+ );
725
+ };
726
+ var MessageList_default = MessageList;
727
+
728
+ // src/components/SiteChatComponentNewErc/Messages/TypingIndicator.css
729
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-0a740655")) {
730
+ const s = document.createElement("style");
731
+ s.id = "jrapps-style-0a740655";
732
+ 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";
733
+ document.head.appendChild(s);
734
+ }
735
+
736
+ // src/components/SiteChatComponentNewErc/Messages/TypingIndicator.tsx
737
+ var import_jsx_runtime11 = require("react/jsx-runtime");
738
+
739
+ // src/components/SiteChatComponentNewErc/States/LoadingState.css
740
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-7bd88a9a")) {
741
+ const s = document.createElement("style");
742
+ s.id = "jrapps-style-7bd88a9a";
743
+ 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";
744
+ document.head.appendChild(s);
745
+ }
746
+
747
+ // src/components/SiteChatComponentNewErc/States/LoadingState.tsx
748
+ var import_jsx_runtime12 = require("react/jsx-runtime");
749
+ var LoadingState = () => {
750
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
751
+ "div",
752
+ {
753
+ className: "cw-loading-state",
754
+ role: "status",
755
+ "aria-label": "Connecting to chat",
756
+ children: [
757
+ /* @__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" }) }),
758
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "cw-loading-state__title", children: "Connecting\u2026" }),
759
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "cw-loading-state__subtitle", children: "Please wait while we connect you to an available agent." })
760
+ ]
761
+ }
762
+ );
763
+ };
764
+ var LoadingState_default = LoadingState;
765
+
766
+ // src/components/SiteChatComponentNewErc/States/StartChatState.css
767
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-f1f33df7")) {
768
+ const s = document.createElement("style");
769
+ s.id = "jrapps-style-f1f33df7";
770
+ 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";
771
+ document.head.appendChild(s);
772
+ }
773
+
774
+ // src/components/SiteChatComponentNewErc/States/StartChatState.tsx
775
+ var import_jsx_runtime13 = require("react/jsx-runtime");
776
+ var StartChatState = ({
777
+ image,
778
+ title,
779
+ description,
780
+ onStart
781
+ }) => {
782
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
783
+ "div",
784
+ {
785
+ className: "cw-start-chat-state",
786
+ role: "main",
787
+ "aria-label": "Start a chat",
788
+ children: [
789
+ image && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
790
+ "img",
791
+ {
792
+ src: image,
793
+ alt: "Support illustration",
794
+ className: "cw-start-chat-state__image"
795
+ }
796
+ ),
797
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { className: "cw-start-chat-state__title", children: title }),
798
+ description && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "cw-start-chat-state__description", children: description }),
799
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button_default, { onClick: onStart, ariaLabel: "Start chat", children: "Start Chat" })
800
+ ]
801
+ }
802
+ );
803
+ };
804
+ var StartChatState_default = StartChatState;
805
+
806
+ // src/components/SiteChatComponentNewErc/OfflineForm/OfflineForm.css
807
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-a7711cdc")) {
808
+ const s = document.createElement("style");
809
+ s.id = "jrapps-style-a7711cdc";
810
+ s.textContent = `.cw-offline-form {
811
+ display: flex;
812
+ flex-direction: column;
813
+ gap: 14px;
814
+ }
815
+
816
+ .cw-offline-form__title {
817
+ font-size: 15px;
818
+ font-weight: 600;
819
+ color: var(--cw-agent-text);
820
+ margin: 0 0 4px;
821
+ }
822
+
823
+ /* Field wrapper */
824
+ .cw-offline-form__field {
825
+ display: flex;
826
+ flex-direction: column;
827
+ gap: 5px;
828
+ }
829
+
830
+ .cw-offline-form__field--checkbox {
831
+ gap: 4px;
832
+ }
833
+
834
+ /* Label */
835
+ .cw-offline-form__label {
836
+ font-size: 13px;
837
+ font-weight: 500;
838
+ color: var(--cw-agent-text);
839
+ }
840
+
841
+ .cw-offline-form__required {
842
+ color: #ef4444;
843
+ }
844
+
845
+ /* Text input */
846
+ .cw-offline-form__input {
847
+ width: 100%;
848
+ padding: 8px 12px;
849
+ border: 1px solid var(--cw-input-border);
850
+ border-radius: var(--cw-button-radius);
851
+ background-color: var(--cw-input-background);
852
+ font-family: var(--cw-font-family);
853
+ font-size: var(--cw-font-size);
854
+ color: inherit;
855
+ box-sizing: border-box;
856
+ transition: border-color 0.15s ease;
857
+ }
858
+
859
+ .cw-offline-form__input:focus {
860
+ outline: none;
861
+ border-color: var(--cw-primary);
862
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
863
+ }
864
+
865
+ .cw-offline-form__input--error {
866
+ border-color: #ef4444;
867
+ }
868
+
869
+ /* Textarea */
870
+ .cw-offline-form__textarea {
871
+ width: 100%;
872
+ padding: 8px 12px;
873
+ border: 1px solid var(--cw-input-border);
874
+ border-radius: var(--cw-button-radius);
875
+ background-color: var(--cw-input-background);
876
+ font-family: var(--cw-font-family);
877
+ font-size: var(--cw-font-size);
878
+ color: inherit;
879
+ resize: vertical;
880
+ box-sizing: border-box;
881
+ transition: border-color 0.15s ease;
882
+ }
883
+
884
+ .cw-offline-form__textarea:focus {
885
+ outline: none;
886
+ border-color: var(--cw-primary);
887
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
888
+ }
889
+
890
+ .cw-offline-form__textarea--error {
891
+ border-color: #ef4444;
892
+ }
893
+
894
+ /* Select */
895
+ .cw-offline-form__select {
896
+ width: 100%;
897
+ padding: 8px 12px;
898
+ border: 1px solid var(--cw-input-border);
899
+ border-radius: var(--cw-button-radius);
900
+ background-color: var(--cw-input-background);
901
+ font-family: var(--cw-font-family);
902
+ font-size: var(--cw-font-size);
903
+ color: inherit;
904
+ box-sizing: border-box;
905
+ appearance: none;
906
+ 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");
907
+ background-repeat: no-repeat;
908
+ background-position: right 12px center;
909
+ padding-right: 32px;
910
+ cursor: pointer;
911
+ transition: border-color 0.15s ease;
912
+ }
913
+
914
+ .cw-offline-form__select:focus {
915
+ outline: none;
916
+ border-color: var(--cw-primary);
917
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
918
+ }
919
+
920
+ .cw-offline-form__select--error {
921
+ border-color: #ef4444;
922
+ }
923
+
924
+ /* Checkbox */
925
+ .cw-offline-form__checkbox-label {
926
+ display: flex;
927
+ align-items: flex-start;
928
+ gap: 8px;
929
+ cursor: pointer;
930
+ font-size: 13px;
931
+ color: var(--cw-agent-text);
932
+ }
933
+
934
+ .cw-offline-form__checkbox {
935
+ width: 16px;
936
+ height: 16px;
937
+ accent-color: var(--cw-primary);
938
+ flex-shrink: 0;
939
+ margin-top: 1px;
940
+ cursor: pointer;
941
+ }
942
+
943
+ .cw-offline-form__checkbox:focus-visible {
944
+ outline: 2px solid var(--cw-primary);
945
+ outline-offset: 2px;
946
+ }
947
+
948
+ .cw-offline-form__checkbox-text {
949
+ line-height: 1.4;
950
+ }
951
+
952
+ /* Error message */
953
+ .cw-offline-form__error {
954
+ font-size: 12px;
955
+ color: #ef4444;
956
+ font-weight: 500;
957
+ }
958
+
959
+ /* Actions */
960
+ .cw-offline-form__actions {
961
+ margin-top: 4px;
962
+ }
963
+ `;
964
+ document.head.appendChild(s);
965
+ }
966
+
967
+ // src/components/SiteChatComponentNewErc/OfflineForm/OfflineForm.tsx
968
+ var import_jsx_runtime14 = require("react/jsx-runtime");
969
+ var FieldRenderer = ({
970
+ field,
971
+ value,
972
+ error,
973
+ onChange
974
+ }) => {
975
+ var _a, _b;
976
+ const hasError = error.length > 0;
977
+ const fieldId = `cw-offline-field-${field.id}`;
978
+ const errorId = `${fieldId}-error`;
979
+ const commonProps = {
980
+ id: fieldId,
981
+ className: `cw-offline-form__input${hasError ? " cw-offline-form__input--error" : ""}`,
982
+ "aria-invalid": hasError,
983
+ "aria-describedby": hasError ? errorId : void 0,
984
+ required: field.required
985
+ };
986
+ if (field.type === "textarea") {
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.jsx)(
996
+ "textarea",
997
+ {
998
+ ...commonProps,
999
+ value: String(value != null ? value : ""),
1000
+ placeholder: field.placeholder,
1001
+ rows: 3,
1002
+ onChange: (e) => onChange(field.id, e.target.value),
1003
+ className: `cw-offline-form__textarea${hasError ? " cw-offline-form__textarea--error" : ""}`
1004
+ }
1005
+ ),
1006
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1007
+ ] });
1008
+ }
1009
+ if (field.type === "select") {
1010
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field", children: [
1011
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
1012
+ field.label,
1013
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1014
+ " ",
1015
+ "*"
1016
+ ] })
1017
+ ] }),
1018
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1019
+ "select",
1020
+ {
1021
+ ...commonProps,
1022
+ value: String(value != null ? value : ""),
1023
+ onChange: (e) => onChange(field.id, e.target.value),
1024
+ className: `cw-offline-form__select${hasError ? " cw-offline-form__select--error" : ""}`,
1025
+ children: [
1026
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: "", children: (_a = field.placeholder) != null ? _a : `Select ${field.label}` }),
1027
+ (_b = field.options) == null ? void 0 : _b.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
1028
+ ]
1029
+ }
1030
+ ),
1031
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1032
+ ] });
1033
+ }
1034
+ if (field.type === "checkbox") {
1035
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field cw-offline-form__field--checkbox", children: [
1036
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { className: "cw-offline-form__checkbox-label", htmlFor: fieldId, children: [
1037
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1038
+ "input",
1039
+ {
1040
+ type: "checkbox",
1041
+ id: fieldId,
1042
+ checked: Boolean(value),
1043
+ onChange: (e) => onChange(field.id, e.target.checked),
1044
+ className: "cw-offline-form__checkbox",
1045
+ "aria-invalid": hasError,
1046
+ "aria-describedby": hasError ? errorId : void 0,
1047
+ required: field.required
1048
+ }
1049
+ ),
1050
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__checkbox-text", children: [
1051
+ field.label,
1052
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1053
+ " ",
1054
+ "*"
1055
+ ] })
1056
+ ] })
1057
+ ] }),
1058
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1059
+ ] });
1060
+ }
1061
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "cw-offline-form__field", children: [
1062
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
1063
+ field.label,
1064
+ field.required && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1065
+ " ",
1066
+ "*"
1067
+ ] })
1068
+ ] }),
1069
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1070
+ "input",
1071
+ {
1072
+ ...commonProps,
1073
+ type: field.type,
1074
+ value: String(value != null ? value : ""),
1075
+ placeholder: field.placeholder,
1076
+ onChange: (e) => onChange(field.id, e.target.value)
1077
+ }
1078
+ ),
1079
+ hasError && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1080
+ ] });
1081
+ };
1082
+ var OfflineForm = ({ schema, onSubmit }) => {
1083
+ const { values, errors, setValue, handleSubmit } = useOfflineForm(schema);
1084
+ const onFormSubmit = (e) => {
1085
+ e.preventDefault();
1086
+ handleSubmit(onSubmit);
1087
+ };
1088
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1089
+ "form",
1090
+ {
1091
+ className: "cw-offline-form",
1092
+ onSubmit: onFormSubmit,
1093
+ "aria-label": schema.title,
1094
+ noValidate: true,
1095
+ children: [
1096
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("h3", { className: "cw-offline-form__title", children: schema.title }),
1097
+ schema.fields.map((field) => {
1098
+ var _a;
1099
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
1100
+ FieldRenderer,
1101
+ {
1102
+ field,
1103
+ value: values[field.id],
1104
+ error: (_a = errors[field.id]) != null ? _a : "",
1105
+ onChange: setValue
1106
+ },
1107
+ field.id
1108
+ );
1109
+ }),
1110
+ /* @__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 }) })
1111
+ ]
1112
+ }
1113
+ );
1114
+ };
1115
+ var OfflineForm_default = OfflineForm;
1116
+
1117
+ // src/components/SiteChatComponentNewErc/States/OfflineState.css
1118
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-03b10f90")) {
1119
+ const s = document.createElement("style");
1120
+ s.id = "jrapps-style-03b10f90";
1121
+ 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";
1122
+ document.head.appendChild(s);
1123
+ }
1124
+
1125
+ // src/components/SiteChatComponentNewErc/States/OfflineState.tsx
1126
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1127
+ var OfflineState = ({ form, onSubmit }) => {
1128
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1129
+ "div",
1130
+ {
1131
+ className: "cw-offline-state",
1132
+ role: "main",
1133
+ "aria-label": "Business is offline",
1134
+ children: [
1135
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "cw-offline-state__header", children: [
1136
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "cw-offline-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1137
+ "svg",
1138
+ {
1139
+ xmlns: "http://www.w3.org/2000/svg",
1140
+ width: "32",
1141
+ height: "32",
1142
+ viewBox: "0 0 24 24",
1143
+ fill: "none",
1144
+ stroke: "currentColor",
1145
+ strokeWidth: "2",
1146
+ strokeLinecap: "round",
1147
+ strokeLinejoin: "round",
1148
+ 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" })
1149
+ }
1150
+ ) }),
1151
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("h2", { className: "cw-offline-state__title", children: "We're currently offline" }),
1152
+ /* @__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." })
1153
+ ] }),
1154
+ 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 }) })
1155
+ ]
1156
+ }
1157
+ );
1158
+ };
1159
+ var OfflineState_default = OfflineState;
1160
+
1161
+ // src/components/SiteChatComponentNewErc/States/ChatEndedState.css
1162
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-dba39629")) {
1163
+ const s = document.createElement("style");
1164
+ s.id = "jrapps-style-dba39629";
1165
+ 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";
1166
+ document.head.appendChild(s);
1167
+ }
1168
+
1169
+ // src/components/SiteChatComponentNewErc/States/ChatEndedState.tsx
1170
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1171
+ var ChatEndedState = () => {
1172
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
1173
+ "div",
1174
+ {
1175
+ className: "cw-chat-ended-state",
1176
+ role: "status",
1177
+ "aria-label": "Chat has ended",
1178
+ children: [
1179
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "cw-chat-ended-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1180
+ "svg",
1181
+ {
1182
+ xmlns: "http://www.w3.org/2000/svg",
1183
+ width: "32",
1184
+ height: "32",
1185
+ viewBox: "0 0 24 24",
1186
+ fill: "none",
1187
+ stroke: "currentColor",
1188
+ strokeWidth: "2",
1189
+ strokeLinecap: "round",
1190
+ strokeLinejoin: "round",
1191
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("polyline", { points: "20 6 9 17 4 12" })
1192
+ }
1193
+ ) }),
1194
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "cw-chat-ended-state__title", children: "Chat Ended" }),
1195
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "cw-chat-ended-state__subtitle", children: "Your chat session has ended. Thank you for reaching out!" })
1196
+ ]
1197
+ }
1198
+ );
1199
+ };
1200
+ var ChatEndedState_default = ChatEndedState;
1201
+
1202
+ // src/components/SiteChatComponentNewErc/SiteChatComponentNewErc.css
1203
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-6b6fcb3b")) {
1204
+ const s = document.createElement("style");
1205
+ s.id = "jrapps-style-6b6fcb3b";
1206
+ 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 Editor React Component root \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 * Fills the container provided by the Wix editor. No fixed positioning,\n * no launcher button. Width & height are managed by the editor itself.\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-erc-root {\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background-color: var(--cw-background, #ffffff);\n font-family: var(--cw-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif);\n font-size: var(--cw-font-size, 14px);\n overflow: hidden;\n}\n\n/* Widget body fills remaining space between header and footer */\n.cw-erc-root .cw-widget__body {\n flex: 1;\n display: flex;\n flex-direction: column;\n overflow: hidden;\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";
1207
+ document.head.appendChild(s);
1208
+ }
1209
+
1210
+ // src/components/SiteChatComponentNewErc/SiteChatComponentNewErc.tsx
1211
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1212
+ var SiteChatComponentNewErc = import_react5.default.forwardRef(({
1213
+ title,
1214
+ subtitle,
1215
+ image,
1216
+ theme,
1217
+ messages,
1218
+ offlineForm,
1219
+ defaultOpen = false,
1220
+ loading = false,
1221
+ chatEnded = false,
1222
+ width,
1223
+ height,
1224
+ onSend,
1225
+ onAttachment,
1226
+ onOfflineSubmit,
1227
+ onClose,
1228
+ isEditorReactComponent = false,
1229
+ editorReactComponentThemeProps
1230
+ }, ref) => {
1231
+ const { open, openWidget, closeWidget } = useSiteChatComponentNewErc(defaultOpen);
1232
+ const themeVars = buildThemeVars(theme, width, height);
1233
+ const handleClose = () => {
1234
+ closeWidget();
1235
+ onClose == null ? void 0 : onClose();
1236
+ };
1237
+ const renderBody = (convClasses, footerClasses) => {
1238
+ if (loading) {
1239
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LoadingState_default, {});
1240
+ }
1241
+ if (offlineForm) {
1242
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(OfflineState_default, { form: offlineForm, onSubmit: onOfflineSubmit });
1243
+ }
1244
+ if (messages.length === 0) {
1245
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1246
+ StartChatState_default,
1247
+ {
1248
+ image,
1249
+ title,
1250
+ description: subtitle,
1251
+ onStart: () => onSend("__start_chat__")
1252
+ }
1253
+ );
1254
+ }
1255
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
1256
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MessageList_default, { messages, ercClasses: convClasses }),
1257
+ chatEnded ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ChatEndedState_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Footer_default, { onSend, onAttachment, ercClasses: footerClasses })
1258
+ ] });
1259
+ };
1260
+ if (isEditorReactComponent) {
1261
+ const ercTheme = editorReactComponentThemeProps;
1262
+ const ercStyle = ercTheme ? void 0 : buildThemeVars(theme);
1263
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref, className: "cw-erc-root", style: ercStyle, children: [
1264
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1265
+ Header_default,
1266
+ {
1267
+ image,
1268
+ title,
1269
+ subtitle,
1270
+ onClose: onClose != null ? onClose : (() => {
1271
+ }),
1272
+ ercClasses: ercTheme == null ? void 0 : ercTheme.header
1273
+ }
1274
+ ),
1275
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1276
+ "div",
1277
+ {
1278
+ className: [
1279
+ "cw-widget__body",
1280
+ ercTheme == null ? void 0 : ercTheme.conversation.conversationClassName
1281
+ ].filter(Boolean).join(" "),
1282
+ children: renderBody(ercTheme == null ? void 0 : ercTheme.conversation, ercTheme == null ? void 0 : ercTheme.footer)
1283
+ }
1284
+ )
1285
+ ] });
1286
+ }
1287
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { ref, className: "cw-root", style: themeVars, children: [
1288
+ open && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1289
+ "div",
1290
+ {
1291
+ className: "cw-widget",
1292
+ role: "dialog",
1293
+ "aria-modal": "true",
1294
+ "aria-label": `${title} chat widget`,
1295
+ children: [
1296
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1297
+ Header_default,
1298
+ {
1299
+ image,
1300
+ title,
1301
+ subtitle,
1302
+ onClose: handleClose
1303
+ }
1304
+ ),
1305
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "cw-widget__body", children: renderBody() })
1306
+ ]
1307
+ }
1308
+ ),
1309
+ !open && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1310
+ "button",
1311
+ {
1312
+ className: "cw-launcher",
1313
+ onClick: openWidget,
1314
+ "aria-label": "Open chat",
1315
+ "aria-haspopup": "dialog",
1316
+ type: "button",
1317
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1318
+ "svg",
1319
+ {
1320
+ xmlns: "http://www.w3.org/2000/svg",
1321
+ width: "26",
1322
+ height: "26",
1323
+ viewBox: "0 0 24 24",
1324
+ fill: "currentColor",
1325
+ "aria-hidden": "true",
1326
+ 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" })
1327
+ }
1328
+ )
1329
+ }
1330
+ )
1331
+ ] });
1332
+ });
1333
+ SiteChatComponentNewErc.displayName = "SiteChatComponentNewErc";
1334
+ //# sourceMappingURL=index.js.map