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