@convokit/widget 0.0.1 → 0.0.4

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 (43) hide show
  1. package/README.md +226 -42
  2. package/dist/DemoErrorBoundary.d.ts +17 -0
  3. package/dist/DemoErrorBoundary.d.ts.map +1 -0
  4. package/dist/FullScreenBackendWidget.d.ts +36 -0
  5. package/dist/FullScreenBackendWidget.d.ts.map +1 -0
  6. package/dist/FullScreenWidget.d.ts +34 -0
  7. package/dist/FullScreenWidget.d.ts.map +1 -0
  8. package/dist/PopupBackendWidget.d.ts +35 -0
  9. package/dist/PopupBackendWidget.d.ts.map +1 -0
  10. package/dist/PopupWidget-CGZOe6ZA.js +5815 -0
  11. package/dist/PopupWidget.d.ts +33 -0
  12. package/dist/PopupWidget.d.ts.map +1 -0
  13. package/dist/components/ChatPopup.d.ts +10 -0
  14. package/dist/components/ChatPopup.d.ts.map +1 -0
  15. package/dist/components/ChatPopupConnect.d.ts +10 -0
  16. package/dist/components/ChatPopupConnect.d.ts.map +1 -0
  17. package/dist/components/ChatPopupEmbed.d.ts +10 -0
  18. package/dist/components/ChatPopupEmbed.d.ts.map +1 -0
  19. package/dist/components/ChatWidget.d.ts +1 -5
  20. package/dist/components/ChatWidget.d.ts.map +1 -1
  21. package/dist/components/FullScreenChat.d.ts +12 -0
  22. package/dist/components/FullScreenChat.d.ts.map +1 -0
  23. package/dist/components/FullScreenChatConnect.d.ts +12 -0
  24. package/dist/components/FullScreenChatConnect.d.ts.map +1 -0
  25. package/dist/components/FullScreenChatEmbed.d.ts +12 -0
  26. package/dist/components/FullScreenChatEmbed.d.ts.map +1 -0
  27. package/dist/demo.d.ts +1 -1
  28. package/dist/demo.d.ts.map +1 -1
  29. package/dist/index.d.ts +12 -2
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.esm.js +588 -695
  32. package/dist/next.d.ts +24 -0
  33. package/dist/next.d.ts.map +1 -0
  34. package/dist/next.esm.js +17 -0
  35. package/dist/types/index.d.ts +125 -7
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/dist/utils/api.d.ts +29 -0
  38. package/dist/utils/api.d.ts.map +1 -0
  39. package/dist/utils/markdown.d.ts +3 -0
  40. package/dist/utils/markdown.d.ts.map +1 -0
  41. package/package.json +34 -7
  42. package/dist/index.umd.js +0 -30
  43. package/dist/style.css +0 -1
package/dist/index.esm.js CHANGED
@@ -1,721 +1,614 @@
1
- import Oe, { useState as B } from "react";
2
- var ee = { exports: {} }, W = {};
3
- /**
4
- * @license React
5
- * react-jsx-runtime.production.min.js
6
- *
7
- * Copyright (c) Facebook, Inc. and its affiliates.
8
- *
9
- * This source code is licensed under the MIT license found in the
10
- * LICENSE file in the root directory of this source tree.
11
- */
12
- var Te;
13
- function fr() {
14
- if (Te) return W;
15
- Te = 1;
16
- var m = Oe, _ = Symbol.for("react.element"), I = Symbol.for("react.fragment"), R = Object.prototype.hasOwnProperty, T = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, j = { key: !0, ref: !0, __self: !0, __source: !0 };
17
- function x(y, f, C) {
18
- var v, d = {}, b = null, w = null;
19
- C !== void 0 && (b = "" + C), f.key !== void 0 && (b = "" + f.key), f.ref !== void 0 && (w = f.ref);
20
- for (v in f) R.call(f, v) && !j.hasOwnProperty(v) && (d[v] = f[v]);
21
- if (y && y.defaultProps) for (v in f = y.defaultProps, f) d[v] === void 0 && (d[v] = f[v]);
22
- return { $$typeof: _, type: y, key: b, ref: w, props: d, _owner: T.current };
23
- }
24
- return W.Fragment = I, W.jsx = x, W.jsxs = x, W;
25
- }
26
- var Y = {};
27
- /**
28
- * @license React
29
- * react-jsx-runtime.development.js
30
- *
31
- * Copyright (c) Facebook, Inc. and its affiliates.
32
- *
33
- * This source code is licensed under the MIT license found in the
34
- * LICENSE file in the root directory of this source tree.
35
- */
36
- var xe;
37
- function dr() {
38
- return xe || (xe = 1, process.env.NODE_ENV !== "production" && function() {
39
- var m = Oe, _ = Symbol.for("react.element"), I = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), T = Symbol.for("react.strict_mode"), j = Symbol.for("react.profiler"), x = Symbol.for("react.provider"), y = Symbol.for("react.context"), f = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), w = Symbol.for("react.offscreen"), P = Symbol.iterator, J = "@@iterator";
40
- function ke(e) {
41
- if (e === null || typeof e != "object")
42
- return null;
43
- var r = P && e[P] || e[J];
44
- return typeof r == "function" ? r : null;
45
- }
46
- var D = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
47
- function p(e) {
48
- {
49
- for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
50
- t[n - 1] = arguments[n];
51
- Se("error", e, t);
52
- }
53
- }
54
- function Se(e, r, t) {
55
- {
56
- var n = D.ReactDebugCurrentFrame, i = n.getStackAddendum();
57
- i !== "" && (r += "%s", t = t.concat([i]));
58
- var s = t.map(function(o) {
59
- return String(o);
60
- });
61
- s.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, s);
62
- }
63
- }
64
- var Pe = !1, De = !1, Fe = !1, Ae = !1, Ie = !1, re;
65
- re = Symbol.for("react.module.reference");
66
- function $e(e) {
67
- return !!(typeof e == "string" || typeof e == "function" || e === R || e === j || Ie || e === T || e === C || e === v || Ae || e === w || Pe || De || Fe || typeof e == "object" && e !== null && (e.$$typeof === b || e.$$typeof === d || e.$$typeof === x || e.$$typeof === y || e.$$typeof === f || // This needs to include all possible module reference object
68
- // types supported by any Flight configuration anywhere since
69
- // we don't know which Flight build this will end up being used
70
- // with.
71
- e.$$typeof === re || e.getModuleId !== void 0));
72
- }
73
- function Ne(e, r, t) {
74
- var n = e.displayName;
75
- if (n)
76
- return n;
77
- var i = r.displayName || r.name || "";
78
- return i !== "" ? t + "(" + i + ")" : t;
79
- }
80
- function te(e) {
81
- return e.displayName || "Context";
82
- }
83
- function O(e) {
84
- if (e == null)
85
- return null;
86
- if (typeof e.tag == "number" && p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
87
- return e.displayName || e.name || null;
88
- if (typeof e == "string")
89
- return e;
90
- switch (e) {
91
- case R:
92
- return "Fragment";
93
- case I:
94
- return "Portal";
95
- case j:
96
- return "Profiler";
97
- case T:
98
- return "StrictMode";
99
- case C:
100
- return "Suspense";
101
- case v:
102
- return "SuspenseList";
103
- }
104
- if (typeof e == "object")
105
- switch (e.$$typeof) {
106
- case y:
107
- var r = e;
108
- return te(r) + ".Consumer";
109
- case x:
110
- var t = e;
111
- return te(t._context) + ".Provider";
112
- case f:
113
- return Ne(e, e.render, "ForwardRef");
114
- case d:
115
- var n = e.displayName || null;
116
- return n !== null ? n : O(e.type) || "Memo";
117
- case b: {
118
- var i = e, s = i._payload, o = i._init;
119
- try {
120
- return O(o(s));
121
- } catch {
122
- return null;
123
- }
124
- }
125
- }
126
- return null;
127
- }
128
- var k = Object.assign, $ = 0, ne, ae, oe, ie, se, ue, le;
129
- function ce() {
130
- }
131
- ce.__reactDisabledLog = !0;
132
- function We() {
133
- {
134
- if ($ === 0) {
135
- ne = console.log, ae = console.info, oe = console.warn, ie = console.error, se = console.group, ue = console.groupCollapsed, le = console.groupEnd;
136
- var e = {
137
- configurable: !0,
138
- enumerable: !0,
139
- value: ce,
140
- writable: !0
141
- };
142
- Object.defineProperties(console, {
143
- info: e,
144
- log: e,
145
- warn: e,
146
- error: e,
147
- group: e,
148
- groupCollapsed: e,
149
- groupEnd: e
150
- });
151
- }
152
- $++;
153
- }
154
- }
155
- function Ye() {
156
- {
157
- if ($--, $ === 0) {
158
- var e = {
159
- configurable: !0,
160
- enumerable: !0,
161
- writable: !0
162
- };
163
- Object.defineProperties(console, {
164
- log: k({}, e, {
165
- value: ne
166
- }),
167
- info: k({}, e, {
168
- value: ae
169
- }),
170
- warn: k({}, e, {
171
- value: oe
172
- }),
173
- error: k({}, e, {
174
- value: ie
175
- }),
176
- group: k({}, e, {
177
- value: se
178
- }),
179
- groupCollapsed: k({}, e, {
180
- value: ue
181
- }),
182
- groupEnd: k({}, e, {
183
- value: le
184
- })
185
- });
186
- }
187
- $ < 0 && p("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
188
- }
189
- }
190
- var q = D.ReactCurrentDispatcher, K;
191
- function L(e, r, t) {
192
- {
193
- if (K === void 0)
194
- try {
195
- throw Error();
196
- } catch (i) {
197
- var n = i.stack.trim().match(/\n( *(at )?)/);
198
- K = n && n[1] || "";
199
- }
200
- return `
201
- ` + K + e;
202
- }
203
- }
204
- var z = !1, M;
205
- {
206
- var Le = typeof WeakMap == "function" ? WeakMap : Map;
207
- M = new Le();
208
- }
209
- function fe(e, r) {
210
- if (!e || z)
211
- return "";
212
- {
213
- var t = M.get(e);
214
- if (t !== void 0)
215
- return t;
216
- }
217
- var n;
218
- z = !0;
219
- var i = Error.prepareStackTrace;
220
- Error.prepareStackTrace = void 0;
221
- var s;
222
- s = q.current, q.current = null, We();
1
+ (function(){"use strict";try{if(typeof document!="undefined"){var o=document.createElement("style");o.appendChild(document.createTextNode(":root{--convokit-primary: #000;--convokit-header-bg: #000;--convokit-font-family: Inter, system-ui, sans-serif;--convokit-font-size: 14px;--convokit-border-radius: 18px;--convokit-chat-bg: #ffffff;--convokit-user-msg-bg: #000;--convokit-assistant-msg-bg: #f3f4f6;--convokit-input-bg: #ffffff;--convokit-input-border: #d1d5db}.convokit-widget{position:fixed;top:0;left:0;right:0;bottom:0;pointer-events:none;font-family:var(--convokit-font-family);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.convokit-button{width:56px;height:56px;border-radius:50%;border:2px solid var(--convokit-primary);color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 8px #0000001a;z-index:10000;transition:all .2s ease;background:var(--convokit-primary)}.convokit-button:hover{transform:translateY(-2px);box-shadow:0 4px 12px #00000026}.convokit-button:active{transform:translateY(0)}.convokit-button-hidden{opacity:0;transform:scale(0);pointer-events:none;transition:all .2s ease-in-out}.convokit-chat-window{width:380px;height:600px;background:#fff;border-radius:12px;box-shadow:0 4px 16px #0000001a;display:flex;flex-direction:column;overflow:hidden;position:absolute;bottom:0;right:0;z-index:9999;transform-origin:bottom right;border:2px solid #000;overscroll-behavior:contain}.convokit-chat-window-body{width:100%;height:100%;background:#fff;display:flex;flex-direction:column;overflow:hidden}.convokit-chat-wrapper{display:flex;flex-direction:column;flex:1;background:var(--convokit-chat-bg);overflow:hidden}.convokit-header{padding:16px 20px;color:#fff;display:flex;justify-content:space-between;align-items:center;min-height:60px;background:var(--convokit-header-bg);position:relative;border-bottom:2px solid var(--convokit-header-bg)}.convokit-header-subtitle{margin:0;font-size:12px;opacity:.85;line-height:1.3}.convokit-header-left{display:flex;align-items:center;gap:12px;flex:1}.convokit-avatar{display:none}.convokit-header-text{display:flex;flex-direction:column;gap:4px}.convokit-header-text h3{margin:0;font-size:16px;font-weight:600;line-height:1.3}.convokit-header-actions{display:flex;align-items:center;gap:4px}.convokit-header-icon{background:none;border:none;color:#fff;cursor:pointer;padding:4px;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:opacity .2s ease}.convokit-header-icon:hover{opacity:.7}.convokit-header-icon:active{opacity:.5}.convokit-chat-window-content{display:flex;flex-direction:column;flex:1;overflow:hidden;min-height:0}.convokit-chat-container{display:flex;flex-direction:column;flex:1;padding:16px;border:none;overflow:hidden;background:transparent;overscroll-behavior:contain}.convokit-messages{flex:1;overflow-y:auto;padding:8px 0;display:flex;flex-direction:column;gap:16px;background:transparent;scrollbar-width:none;-ms-overflow-style:none;overscroll-behavior:contain}.convokit-messages::-webkit-scrollbar{display:none}.convokit-welcome{text-align:center;color:#666;padding:20px;font-size:14px}.convokit-message{display:flex;align-items:flex-end;gap:0;max-width:75%}.convokit-message-user{align-self:flex-end}.convokit-message-assistant{align-self:flex-start}.convokit-bot-icon{display:none}.convokit-message-content{padding:10px 14px;border-radius:var(--convokit-border-radius);word-wrap:break-word;font-size:var(--convokit-font-size);line-height:1.5;position:relative}.convokit-message-user .convokit-message-content{background:var(--convokit-user-msg-bg);color:#fff;border-bottom-right-radius:4px}.convokit-message-assistant .convokit-message-content{background:var(--convokit-assistant-msg-bg);color:#000;border-bottom-left-radius:4px}.convokit-message-content strong{font-weight:600}.convokit-message-content em{font-style:italic}.convokit-message-content a{text-decoration:underline}.convokit-typing{display:flex;gap:6px;padding:4px 0;align-items:center}.convokit-typing span{width:8px;height:8px;border-radius:50%;background:#6b7280;animation:typing-bounce 1.4s ease-in-out infinite}.convokit-typing span:nth-child(1){animation-delay:0s}.convokit-typing span:nth-child(2){animation-delay:.2s}.convokit-typing span:nth-child(3){animation-delay:.4s}@keyframes typing-bounce{0%,60%,to{transform:translateY(0)}30%{transform:translateY(-8px)}}.convokit-input-form{display:flex;align-items:center;padding:12px 0 0;gap:8px;flex-shrink:0;background:transparent;border-bottom:none}.convokit-input{flex:1;padding:11px 14px;border:1px solid color-mix(in srgb,var(--convokit-primary) 35%,transparent);background:var(--convokit-input-bg);border-radius:20px;font-size:var(--convokit-font-size);outline:none;color:#000;font-family:var(--convokit-font-family);transition:border-color .2s ease,box-shadow .2s ease}.convokit-input:focus{border-color:var(--convokit-primary);box-shadow:none}.convokit-input::placeholder{color:#9ca3af}.convokit-input:disabled{background:#f9fafb;color:#9ca3af;border-color:#e5e7eb}.convokit-send-button{width:40px;height:40px;border-radius:50%;border:none;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;background:var(--convokit-primary);transition:opacity .2s ease}.convokit-send-button:hover:not(:disabled){opacity:.8}.convokit-send-button:active:not(:disabled){opacity:.6}.convokit-send-button:disabled{opacity:.3;cursor:not-allowed;background:var(--convokit-primary)}.convokit-footer{padding:10px 16px;text-align:center;background:var(--convokit-chat-bg);font-size:11px;color:#6b7280}.convokit-footer a{color:var(--convokit-primary);text-decoration:none;font-weight:500;transition:opacity .2s ease}.convokit-footer a:hover{opacity:.7}.convokit-rating-prompt{padding:16px;border-top:1px solid #e5e7eb;background-color:#f9fafb;border-bottom-left-radius:12px;border-bottom-right-radius:12px}.convokit-rating-question{margin:0 0 12px;font-size:14px;font-weight:500;color:#374151;text-align:center}.convokit-rating-buttons{display:flex;gap:12px;justify-content:center;margin-bottom:12px}.convokit-rating-button{width:48px;height:48px;border-radius:50%;border:2px solid #d1d5db;background-color:#fff;color:#6b7280;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center;padding:0}.convokit-rating-button:hover:not(:disabled){border-color:#9ca3af;transform:scale(1.05)}.convokit-rating-button:disabled{opacity:.5;cursor:not-allowed}.convokit-rating-button.convokit-rating-selected{color:#fff;border-width:2px}.convokit-rating-feedback{margin-top:12px;animation:slideDown .3s ease}@keyframes slideDown{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.convokit-rating-textarea{width:100%;padding:10px 12px;border:1px solid #d1d5db;border-radius:8px;font-size:14px;font-family:inherit;resize:vertical;min-height:60px;margin-bottom:8px;box-sizing:border-box}.convokit-rating-textarea:focus{outline:none;border-color:#3b82f6;box-shadow:0 0 0 3px #3b82f61a}.convokit-rating-textarea:disabled{background-color:#f3f4f6;cursor:not-allowed}.convokit-rating-submit{width:100%;padding:10px 16px;border:none;border-radius:8px;font-size:14px;font-weight:500;color:#fff;cursor:pointer;transition:opacity .2s ease}.convokit-rating-submit:hover:not(:disabled){opacity:.9}.convokit-rating-submit:disabled{opacity:.6;cursor:not-allowed}.convokit-rating-thankyou{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px 16px;animation:fadeIn .3s ease}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}.convokit-rating-icon{width:48px;height:48px;border-radius:50%;background-color:#10b981;color:#fff;display:flex;align-items:center;justify-content:center;font-size:24px;font-weight:700;margin-bottom:12px}.convokit-rating-message{margin:0;font-size:14px;font-weight:500;color:#374151}@media (max-width: 480px){.convokit-widget{bottom:10px;right:10px}.convokit-chat-window{width:calc(100vw - 20px);height:calc(100vh - 20px);max-width:calc(100vw - 20px);max-height:calc(100vh - 20px);bottom:0;right:0;border-radius:16px}.convokit-message{max-width:85%}.convokit-header{padding:16px 16px 12px;min-height:64px}.convokit-chat-container{padding:12px}}")),document.head.appendChild(o)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { M as L, r as _, f as R, i as $, s as G, c as Y, a as q, g as A, b as U, d as V, e as J } from "./PopupWidget-CGZOe6ZA.js";
3
+ import { P as he } from "./PopupWidget-CGZOe6ZA.js";
4
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
5
+ import { useState as u, useRef as F, useEffect as N } from "react";
6
+ const Q = "convokit-widget", X = ({ config: e, onBack: c, backLabel: r = "Back to editor" }) => {
7
+ const k = e.widgetId ?? Q, [I, C] = u(!0), [m, x] = u([]), [g, B] = u(""), [v, D] = u(!1), [S, P] = u(null), [o, l] = u(null), T = F(null), a = `convokit_messages_${k}`;
8
+ N(() => {
9
+ if (e.persistMessages)
223
10
  try {
224
- if (r) {
225
- var o = function() {
226
- throw Error();
227
- };
228
- if (Object.defineProperty(o.prototype, "props", {
229
- set: function() {
230
- throw Error();
231
- }
232
- }), typeof Reflect == "object" && Reflect.construct) {
233
- try {
234
- Reflect.construct(o, []);
235
- } catch (g) {
236
- n = g;
237
- }
238
- Reflect.construct(e, [], o);
239
- } else {
240
- try {
241
- o.call();
242
- } catch (g) {
243
- n = g;
244
- }
245
- e.call(o.prototype);
246
- }
247
- } else {
248
- try {
249
- throw Error();
250
- } catch (g) {
251
- n = g;
252
- }
253
- e();
254
- }
255
- } catch (g) {
256
- if (g && n && typeof g.stack == "string") {
257
- for (var a = g.stack.split(`
258
- `), h = n.stack.split(`
259
- `), u = a.length - 1, c = h.length - 1; u >= 1 && c >= 0 && a[u] !== h[c]; )
260
- c--;
261
- for (; u >= 1 && c >= 0; u--, c--)
262
- if (a[u] !== h[c]) {
263
- if (u !== 1 || c !== 1)
264
- do
265
- if (u--, c--, c < 0 || a[u] !== h[c]) {
266
- var E = `
267
- ` + a[u].replace(" at new ", " at ");
268
- return e.displayName && E.includes("<anonymous>") && (E = E.replace("<anonymous>", e.displayName)), typeof e == "function" && M.set(e, E), E;
269
- }
270
- while (u >= 1 && c >= 0);
271
- break;
272
- }
273
- }
274
- } finally {
275
- z = !1, q.current = s, Ye(), Error.prepareStackTrace = i;
276
- }
277
- var A = e ? e.displayName || e.name : "", S = A ? L(A) : "";
278
- return typeof e == "function" && M.set(e, S), S;
279
- }
280
- function Me(e, r, t) {
281
- return fe(e, !1);
282
- }
283
- function Ve(e) {
284
- var r = e.prototype;
285
- return !!(r && r.isReactComponent);
286
- }
287
- function V(e, r, t) {
288
- if (e == null)
289
- return "";
290
- if (typeof e == "function")
291
- return fe(e, Ve(e));
292
- if (typeof e == "string")
293
- return L(e);
294
- switch (e) {
295
- case C:
296
- return L("Suspense");
297
- case v:
298
- return L("SuspenseList");
11
+ const i = localStorage.getItem(a);
12
+ i && x(JSON.parse(i));
13
+ } catch (i) {
14
+ console.error("Failed to load messages from localStorage:", i);
299
15
  }
300
- if (typeof e == "object")
301
- switch (e.$$typeof) {
302
- case f:
303
- return Me(e.render);
304
- case d:
305
- return V(e.type, r, t);
306
- case b: {
307
- var n = e, i = n._payload, s = n._init;
308
- try {
309
- return V(s(i), r, t);
310
- } catch {
311
- }
312
- }
313
- }
314
- return "";
315
- }
316
- var N = Object.prototype.hasOwnProperty, de = {}, ve = D.ReactDebugCurrentFrame;
317
- function U(e) {
318
- if (e) {
319
- var r = e._owner, t = V(e.type, e._source, r ? r.type : null);
320
- ve.setExtraStackFrame(t);
321
- } else
322
- ve.setExtraStackFrame(null);
323
- }
324
- function Ue(e, r, t, n, i) {
325
- {
326
- var s = Function.call.bind(N);
327
- for (var o in e)
328
- if (s(e, o)) {
329
- var a = void 0;
330
- try {
331
- if (typeof e[o] != "function") {
332
- var h = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
333
- throw h.name = "Invariant Violation", h;
334
- }
335
- a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
336
- } catch (u) {
337
- a = u;
338
- }
339
- a && !(a instanceof Error) && (U(i), p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), U(null)), a instanceof Error && !(a.message in de) && (de[a.message] = !0, U(i), p("Failed %s type: %s", t, a.message), U(null));
340
- }
341
- }
342
- }
343
- var Be = Array.isArray;
344
- function G(e) {
345
- return Be(e);
346
- }
347
- function Je(e) {
348
- {
349
- var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
350
- return t;
351
- }
352
- }
353
- function qe(e) {
16
+ }, [e.persistMessages, a]), N(() => {
17
+ if (e.persistMessages && m.length > 0)
354
18
  try {
355
- return pe(e), !1;
356
- } catch {
357
- return !0;
358
- }
359
- }
360
- function pe(e) {
361
- return "" + e;
362
- }
363
- function he(e) {
364
- if (qe(e))
365
- return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Je(e)), pe(e);
366
- }
367
- var ge = D.ReactCurrentOwner, Ke = {
368
- key: !0,
369
- ref: !0,
370
- __self: !0,
371
- __source: !0
372
- }, me, ye;
373
- function ze(e) {
374
- if (N.call(e, "ref")) {
375
- var r = Object.getOwnPropertyDescriptor(e, "ref").get;
376
- if (r && r.isReactWarning)
377
- return !1;
378
- }
379
- return e.ref !== void 0;
380
- }
381
- function Ge(e) {
382
- if (N.call(e, "key")) {
383
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
384
- if (r && r.isReactWarning)
385
- return !1;
386
- }
387
- return e.key !== void 0;
388
- }
389
- function He(e, r) {
390
- typeof e.ref == "string" && ge.current;
391
- }
392
- function Xe(e, r) {
393
- {
394
- var t = function() {
395
- me || (me = !0, p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
396
- };
397
- t.isReactWarning = !0, Object.defineProperty(e, "key", {
398
- get: t,
399
- configurable: !0
400
- });
401
- }
402
- }
403
- function Ze(e, r) {
404
- {
405
- var t = function() {
406
- ye || (ye = !0, p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
407
- };
408
- t.isReactWarning = !0, Object.defineProperty(e, "ref", {
409
- get: t,
410
- configurable: !0
411
- });
412
- }
413
- }
414
- var Qe = function(e, r, t, n, i, s, o) {
415
- var a = {
416
- // This tag allows us to uniquely identify this as a React Element
417
- $$typeof: _,
418
- // Built-in properties that belong on the element
419
- type: e,
420
- key: r,
421
- ref: t,
422
- props: o,
423
- // Record the component responsible for creating this element.
424
- _owner: s
425
- };
426
- return a._store = {}, Object.defineProperty(a._store, "validated", {
427
- configurable: !1,
428
- enumerable: !1,
429
- writable: !0,
430
- value: !1
431
- }), Object.defineProperty(a, "_self", {
432
- configurable: !1,
433
- enumerable: !1,
434
- writable: !1,
435
- value: n
436
- }), Object.defineProperty(a, "_source", {
437
- configurable: !1,
438
- enumerable: !1,
439
- writable: !1,
440
- value: i
441
- }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
442
- };
443
- function er(e, r, t, n, i) {
444
- {
445
- var s, o = {}, a = null, h = null;
446
- t !== void 0 && (he(t), a = "" + t), Ge(r) && (he(r.key), a = "" + r.key), ze(r) && (h = r.ref, He(r, i));
447
- for (s in r)
448
- N.call(r, s) && !Ke.hasOwnProperty(s) && (o[s] = r[s]);
449
- if (e && e.defaultProps) {
450
- var u = e.defaultProps;
451
- for (s in u)
452
- o[s] === void 0 && (o[s] = u[s]);
453
- }
454
- if (a || h) {
455
- var c = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
456
- a && Xe(o, c), h && Ze(o, c);
457
- }
458
- return Qe(e, a, h, i, n, ge.current, o);
459
- }
460
- }
461
- var H = D.ReactCurrentOwner, be = D.ReactDebugCurrentFrame;
462
- function F(e) {
463
- if (e) {
464
- var r = e._owner, t = V(e.type, e._source, r ? r.type : null);
465
- be.setExtraStackFrame(t);
466
- } else
467
- be.setExtraStackFrame(null);
468
- }
469
- var X;
470
- X = !1;
471
- function Z(e) {
472
- return typeof e == "object" && e !== null && e.$$typeof === _;
473
- }
474
- function Ee() {
475
- {
476
- if (H.current) {
477
- var e = O(H.current.type);
478
- if (e)
479
- return `
480
-
481
- Check the render method of \`` + e + "`.";
482
- }
483
- return "";
484
- }
485
- }
486
- function rr(e) {
487
- return "";
488
- }
489
- var _e = {};
490
- function tr(e) {
491
- {
492
- var r = Ee();
493
- if (!r) {
494
- var t = typeof e == "string" ? e : e.displayName || e.name;
495
- t && (r = `
496
-
497
- Check the top-level render call using <` + t + ">.");
498
- }
499
- return r;
500
- }
501
- }
502
- function Re(e, r) {
503
- {
504
- if (!e._store || e._store.validated || e.key != null)
505
- return;
506
- e._store.validated = !0;
507
- var t = tr(r);
508
- if (_e[t])
509
- return;
510
- _e[t] = !0;
511
- var n = "";
512
- e && e._owner && e._owner !== H.current && (n = " It was passed a child from " + O(e._owner.type) + "."), F(e), p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), F(null);
19
+ localStorage.setItem(a, JSON.stringify(m));
20
+ } catch (i) {
21
+ console.error("Failed to save messages to localStorage:", i);
513
22
  }
514
- }
515
- function je(e, r) {
516
- {
517
- if (typeof e != "object")
518
- return;
519
- if (G(e))
520
- for (var t = 0; t < e.length; t++) {
521
- var n = e[t];
522
- Z(n) && Re(n, r);
523
- }
524
- else if (Z(e))
525
- e._store && (e._store.validated = !0);
526
- else if (e) {
527
- var i = ke(e);
528
- if (typeof i == "function" && i !== e.entries)
529
- for (var s = i.call(e), o; !(o = s.next()).done; )
530
- Z(o.value) && Re(o.value, r);
531
- }
532
- }
533
- }
534
- function nr(e) {
535
- {
536
- var r = e.type;
537
- if (r == null || typeof r == "string")
538
- return;
539
- var t;
540
- if (typeof r == "function")
541
- t = r.propTypes;
542
- else if (typeof r == "object" && (r.$$typeof === f || // Note: Memo only checks outer props here.
543
- // Inner props are checked in the reconciler.
544
- r.$$typeof === d))
545
- t = r.propTypes;
546
- else
23
+ }, [e.persistMessages, m, a]), N(() => {
24
+ (async () => {
25
+ if (!e.key) return;
26
+ const s = `convokit_theme_${k}`;
27
+ try {
28
+ const f = sessionStorage.getItem(s);
29
+ if (f) {
30
+ l(JSON.parse(f));
547
31
  return;
548
- if (t) {
549
- var n = O(r);
550
- Ue(t, e.props, "prop", n, e);
551
- } else if (r.PropTypes !== void 0 && !X) {
552
- X = !0;
553
- var i = O(r);
554
- p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
555
32
  }
556
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
557
- }
558
- }
559
- function ar(e) {
560
- {
561
- for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
562
- var n = r[t];
563
- if (n !== "children" && n !== "key") {
564
- F(e), p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), F(null);
565
- break;
566
- }
567
- }
568
- e.ref !== null && (F(e), p("Invalid attribute `ref` supplied to `React.Fragment`."), F(null));
33
+ } catch {
569
34
  }
570
- }
571
- var Ce = {};
572
- function we(e, r, t, n, i, s) {
573
- {
574
- var o = $e(e);
575
- if (!o) {
576
- var a = "";
577
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
578
- var h = rr();
579
- h ? a += h : a += Ee();
580
- var u;
581
- e === null ? u = "null" : G(e) ? u = "array" : e !== void 0 && e.$$typeof === _ ? (u = "<" + (O(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : u = typeof e, p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", u, a);
582
- }
583
- var c = er(e, r, t, i, s);
584
- if (c == null)
585
- return c;
586
- if (o) {
587
- var E = r.children;
588
- if (E !== void 0)
589
- if (n)
590
- if (G(E)) {
591
- for (var A = 0; A < E.length; A++)
592
- je(E[A], e);
593
- Object.freeze && Object.freeze(E);
594
- } else
595
- p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
596
- else
597
- je(E, e);
598
- }
599
- if (N.call(r, "key")) {
600
- var S = O(e), g = Object.keys(r).filter(function(cr) {
601
- return cr !== "key";
602
- }), Q = g.length > 0 ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}";
603
- if (!Ce[S + Q]) {
604
- var lr = g.length > 0 ? "{" + g.join(": ..., ") + ": ...}" : "{}";
605
- p(`A props object containing a "key" prop is being spread into JSX:
606
- let props = %s;
607
- <%s {...props} />
608
- React keys must be passed directly to JSX without using spread:
609
- let props = %s;
610
- <%s key={someKey} {...props} />`, Q, S, lr, S), Ce[S + Q] = !0;
611
- }
35
+ const h = await R(e.key);
36
+ if (h) {
37
+ l(h);
38
+ try {
39
+ sessionStorage.setItem(s, JSON.stringify(h));
40
+ } catch {
612
41
  }
613
- return e === R ? ar(c) : nr(c), c;
614
42
  }
615
- }
616
- function or(e, r, t) {
617
- return we(e, r, t, !0);
618
- }
619
- function ir(e, r, t) {
620
- return we(e, r, t, !1);
621
- }
622
- var sr = ir, ur = or;
623
- Y.Fragment = R, Y.jsx = sr, Y.jsxs = ur;
624
- }()), Y;
625
- }
626
- process.env.NODE_ENV === "production" ? ee.exports = fr() : ee.exports = dr();
627
- var l = ee.exports;
628
- const pr = ({ config: m }) => {
629
- const [_, I] = B(!1), [R, T] = B([]), [j, x] = B(""), [y, f] = B(!1), C = () => I(!_), v = async (d) => {
630
- if (d.preventDefault(), !j.trim() || y) return;
631
- const b = j.trim();
632
- x(""), T((w) => [...w, { role: "user", content: b }]), f(!0);
43
+ })();
44
+ }, [k, e.key]);
45
+ const p = {
46
+ ...e,
47
+ primaryColor: e.primaryColor || (o == null ? void 0 : o.primaryColor) || "#000",
48
+ title: e.title || (o == null ? void 0 : o.headerTitle) || "Chat",
49
+ subtitle: e.subtitle || (o == null ? void 0 : o.headerSubtitle),
50
+ welcomeMessage: e.welcomeMessage || (o == null ? void 0 : o.welcomeMessage) || "How can I help you today?",
51
+ placeholder: e.placeholder || (o == null ? void 0 : o.placeholder) || "Type a message..."
52
+ };
53
+ N(() => {
54
+ if (typeof document > "u") return;
55
+ const i = document.documentElement;
56
+ i.style.setProperty("--convokit-primary", p.primaryColor), i.style.setProperty("--convokit-header-bg", e.headerBg ?? (o == null ? void 0 : o.headerBg) ?? p.primaryColor ?? "#000"), i.style.setProperty("--convokit-font-family", (o == null ? void 0 : o.fontFamily) || "Inter, system-ui, sans-serif"), i.style.setProperty("--convokit-font-size", (o == null ? void 0 : o.fontSize) || "14px"), i.style.setProperty("--convokit-border-radius", (o == null ? void 0 : o.borderRadius) || "18px"), i.style.setProperty("--convokit-chat-bg", e.chatBg ?? (o == null ? void 0 : o.chatBg) ?? "#ffffff"), i.style.setProperty("--convokit-user-msg-bg", e.userMsgBg ?? (o == null ? void 0 : o.userMsgBg) ?? p.primaryColor ?? "#000"), i.style.setProperty("--convokit-assistant-msg-bg", e.assistantMsgBg ?? (o == null ? void 0 : o.assistantMsgBg) ?? "#f3f4f6"), i.style.setProperty("--convokit-input-bg", e.inputBg ?? (o == null ? void 0 : o.inputBg) ?? "#ffffff");
57
+ }, [o, p.primaryColor, e.headerBg, e.chatBg, e.userMsgBg, e.assistantMsgBg, e.inputBg]), N(() => {
58
+ var i;
59
+ (i = T.current) == null || i.scrollIntoView({ behavior: "smooth" });
60
+ }, [m, v]);
61
+ const E = async (i) => {
62
+ if (i.preventDefault(), !g.trim() || v) return;
63
+ const s = g.trim();
64
+ B(""), P(null);
65
+ const h = { role: "user", content: s, timestamp: /* @__PURE__ */ new Date() }, f = [...m, h];
66
+ x(f), D(!0);
633
67
  try {
634
- const P = await (await fetch(`${m.apiUrl}/api/widget/${m.widgetId}/chat`, {
635
- method: "POST",
636
- headers: { "Content-Type": "application/json" },
637
- body: JSON.stringify({ message: b })
638
- })).json();
639
- T((J) => [...J, { role: "assistant", content: P.message || "Coming soon..." }]);
640
- } catch (w) {
641
- console.error("Chat error:", w), T((P) => [...P, { role: "assistant", content: "Sorry, something went wrong." }]);
68
+ const d = m.map((H) => ({ role: H.role, content: H.content })), b = typeof window < "u" ? localStorage.getItem("widget_jwt") : null, M = typeof window < "u" ? localStorage.getItem("conversation_id") : null;
69
+ let y;
70
+ b && M && !$() ? y = await G(s, d) : (b && M && $() && Y(), y = await q(e.key, s, void 0, k));
71
+ const j = { role: "assistant", content: typeof (y == null ? void 0 : y.reply) == "string" ? y.reply : (y == null ? void 0 : y.reply) != null ? String(y.reply) : "", timestamp: /* @__PURE__ */ new Date() };
72
+ x([...f, j]);
73
+ } catch (d) {
74
+ console.error("Chat error:", d);
75
+ const b = d instanceof Error ? d.message : "Sorry, something went wrong.";
76
+ P(b), x([...f, { role: "assistant", content: `Error: ${b}`, timestamp: /* @__PURE__ */ new Date() }]);
642
77
  } finally {
643
- f(!1);
78
+ D(!1);
644
79
  }
645
80
  };
646
- return /* @__PURE__ */ l.jsxs("div", { className: "convokit-widget", children: [
647
- !_ && /* @__PURE__ */ l.jsx(
648
- "button",
649
- {
650
- onClick: C,
651
- className: "convokit-button",
652
- style: { backgroundColor: m.primaryColor || "#000" },
653
- children: /* @__PURE__ */ l.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ l.jsx(
654
- "path",
655
- {
656
- d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",
657
- stroke: "currentColor",
658
- strokeWidth: "2",
659
- strokeLinecap: "round",
660
- strokeLinejoin: "round"
661
- }
662
- ) })
663
- }
664
- ),
665
- _ && /* @__PURE__ */ l.jsxs("div", { className: "convokit-chat-window", children: [
666
- /* @__PURE__ */ l.jsxs(
667
- "div",
81
+ return I ? /* @__PURE__ */ n(
82
+ L,
83
+ {
84
+ className: "convokit-widget",
85
+ initial: { opacity: 0 },
86
+ animate: { opacity: 1 },
87
+ exit: { opacity: 0 },
88
+ transition: { duration: 0.2 },
89
+ style: {
90
+ position: "fixed",
91
+ inset: 0,
92
+ zIndex: 1e4,
93
+ display: "flex",
94
+ flexDirection: "column",
95
+ background: "var(--convokit-chat-bg)",
96
+ fontFamily: "var(--convokit-font-family)",
97
+ pointerEvents: "auto"
98
+ },
99
+ children: [
100
+ /* @__PURE__ */ n("div", { className: "convokit-header", style: { flexShrink: 0 }, children: [
101
+ /* @__PURE__ */ t("div", { className: "convokit-header-left", children: /* @__PURE__ */ n("div", { className: "convokit-header-text", children: [
102
+ /* @__PURE__ */ t("h3", { children: p.title }),
103
+ p.subtitle && /* @__PURE__ */ t("p", { className: "convokit-header-subtitle", children: p.subtitle })
104
+ ] }) }),
105
+ /* @__PURE__ */ t("div", { className: "convokit-header-actions", children: c ? /* @__PURE__ */ n("button", { type: "button", onClick: c, className: "convokit-header-icon", "aria-label": r, style: { fontSize: 14, gap: 6, display: "flex", alignItems: "center" }, children: [
106
+ /* @__PURE__ */ t("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { d: "M19 12H5M12 19l-7-7 7-7" }) }),
107
+ r
108
+ ] }) : /* @__PURE__ */ t("button", { type: "button", onClick: () => C(!1), className: "convokit-header-icon", "aria-label": "Close chat", children: /* @__PURE__ */ n("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
109
+ /* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
110
+ /* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
111
+ ] }) }) })
112
+ ] }),
113
+ /* @__PURE__ */ t("div", { className: "convokit-chat-wrapper", style: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t("div", { className: "convokit-chat-window-content", style: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ n("div", { className: "convokit-chat-container", style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column", padding: 16 }, children: [
114
+ /* @__PURE__ */ n("div", { className: "convokit-messages", style: { flex: 1, overflowY: "auto", padding: "8px 0" }, children: [
115
+ S && /* @__PURE__ */ n("div", { style: { padding: 12, margin: 8, background: "#fee", color: "#c33", borderRadius: 8, fontSize: 14 }, children: [
116
+ "⚠️ ",
117
+ S
118
+ ] }),
119
+ m.length === 0 && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(p.welcomeMessage) } }) }),
120
+ m.map((i, s) => /* @__PURE__ */ t("div", { className: `convokit-message convokit-message-${i.role}`, children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(i.content) } }) }, s)),
121
+ v && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", children: /* @__PURE__ */ n("div", { className: "convokit-typing", children: [
122
+ /* @__PURE__ */ t("span", {}),
123
+ /* @__PURE__ */ t("span", {}),
124
+ /* @__PURE__ */ t("span", {})
125
+ ] }) }) }),
126
+ /* @__PURE__ */ t("div", { ref: T })
127
+ ] }),
128
+ /* @__PURE__ */ n("form", { onSubmit: E, className: "convokit-input-form", children: [
129
+ /* @__PURE__ */ t(
130
+ "input",
131
+ {
132
+ type: "text",
133
+ value: g,
134
+ onChange: (i) => B(i.target.value),
135
+ placeholder: p.placeholder,
136
+ disabled: v,
137
+ className: "convokit-input"
138
+ }
139
+ ),
140
+ /* @__PURE__ */ t("button", { type: "submit", disabled: v || !g.trim(), className: "convokit-send-button", "aria-label": "Send message", children: /* @__PURE__ */ n("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
141
+ /* @__PURE__ */ t("path", { d: "M22 2L11 13" }),
142
+ /* @__PURE__ */ t("path", { d: "M22 2l-7 20-4-9-9-4z" })
143
+ ] }) })
144
+ ] }),
145
+ /* @__PURE__ */ n("div", { className: "convokit-footer", children: [
146
+ "Powered by ",
147
+ /* @__PURE__ */ t("a", { href: "https://convokit.com", target: "_blank", rel: "noopener noreferrer", children: "ConvoKit" })
148
+ ] })
149
+ ] }) }) })
150
+ ]
151
+ }
152
+ ) : /* @__PURE__ */ t(
153
+ L,
154
+ {
155
+ initial: { opacity: 0 },
156
+ animate: { opacity: 1 },
157
+ style: {
158
+ position: "fixed",
159
+ inset: 0,
160
+ zIndex: 1e4,
161
+ display: "flex",
162
+ alignItems: "center",
163
+ justifyContent: "center",
164
+ background: "var(--convokit-chat-bg)",
165
+ pointerEvents: "auto"
166
+ },
167
+ children: /* @__PURE__ */ n(
168
+ "button",
668
169
  {
669
- className: "convokit-header",
670
- style: { backgroundColor: m.primaryColor || "#000" },
170
+ type: "button",
171
+ onClick: () => C(!0),
172
+ "aria-label": "Open chat",
173
+ style: {
174
+ padding: "14px 28px",
175
+ borderRadius: 12,
176
+ border: "none",
177
+ background: p.primaryColor,
178
+ color: "white",
179
+ fontSize: 16,
180
+ fontWeight: 500,
181
+ cursor: "pointer",
182
+ display: "flex",
183
+ alignItems: "center",
184
+ gap: 10,
185
+ boxShadow: "0 4px 14px rgba(0,0,0,0.15)"
186
+ },
671
187
  children: [
672
- /* @__PURE__ */ l.jsx("h3", { children: m.title || "Chat" }),
673
- /* @__PURE__ */ l.jsx("button", { onClick: C, className: "convokit-close", children: "×" })
188
+ /* @__PURE__ */ t("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ t("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) }),
189
+ "Open chat"
674
190
  ]
675
191
  }
676
- ),
677
- /* @__PURE__ */ l.jsxs("div", { className: "convokit-messages", children: [
678
- R.length === 0 && /* @__PURE__ */ l.jsx("div", { className: "convokit-welcome", children: m.welcomeMessage || "Hello! How can I help you?" }),
679
- R.map((d, b) => /* @__PURE__ */ l.jsx(
680
- "div",
681
- {
682
- className: `convokit-message convokit-message-${d.role}`,
683
- children: d.content
684
- },
685
- b
686
- )),
687
- y && /* @__PURE__ */ l.jsx("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ l.jsxs("div", { className: "convokit-typing", children: [
688
- /* @__PURE__ */ l.jsx("span", {}),
689
- /* @__PURE__ */ l.jsx("span", {}),
690
- /* @__PURE__ */ l.jsx("span", {})
691
- ] }) })
692
- ] }),
693
- /* @__PURE__ */ l.jsxs("form", { onSubmit: v, className: "convokit-input-form", children: [
694
- /* @__PURE__ */ l.jsx(
695
- "input",
192
+ )
193
+ }
194
+ );
195
+ }, W = {
196
+ title: "Support",
197
+ welcomeMessage: "Hi! How can we help?"
198
+ }, re = (e) => {
199
+ const c = e.apiKey;
200
+ if (!c || typeof c != "string" || c.trim() === "")
201
+ return null;
202
+ const r = {
203
+ ...W,
204
+ key: c.trim(),
205
+ widgetId: e.widgetId,
206
+ title: e.title ?? W.title,
207
+ welcomeMessage: e.welcomeMessage ?? W.welcomeMessage,
208
+ persistMessages: e.persistMessages,
209
+ primaryColor: e.primaryColor
210
+ };
211
+ return /* @__PURE__ */ t(
212
+ X,
213
+ {
214
+ config: r,
215
+ onBack: e.onBack,
216
+ backLabel: e.backLabel ?? "Back"
217
+ }
218
+ );
219
+ }, Z = "convokit-widget", ee = ({ config: e }) => {
220
+ const c = e.widgetId ?? Z, [r, k] = u(!1), [I, C] = u([]), [m, x] = u(""), [g, B] = u(!1), [v, D] = u(!1), [S, P] = u(null), o = F(null), l = {
221
+ ...e,
222
+ primaryColor: e.primaryColor || "#000",
223
+ title: e.title || "Chat",
224
+ subtitle: e.subtitle,
225
+ welcomeMessage: e.welcomeMessage || "How can I help you today?",
226
+ placeholder: e.placeholder || "Type a message...",
227
+ position: e.position || "bottom-right"
228
+ };
229
+ N(() => {
230
+ if (typeof document > "u") return;
231
+ const s = document.documentElement;
232
+ s.style.setProperty("--convokit-primary", l.primaryColor), s.style.setProperty("--convokit-header-bg", e.headerBg ?? l.primaryColor ?? "#000"), s.style.setProperty("--convokit-font-family", "Inter, system-ui, sans-serif"), s.style.setProperty("--convokit-font-size", "14px"), s.style.setProperty("--convokit-border-radius", "18px"), s.style.setProperty("--convokit-chat-bg", e.chatBg ?? "#ffffff"), s.style.setProperty("--convokit-user-msg-bg", e.userMsgBg ?? l.primaryColor ?? "#000"), s.style.setProperty("--convokit-assistant-msg-bg", e.assistantMsgBg ?? "#f3f4f6"), s.style.setProperty("--convokit-input-bg", e.inputBg ?? "#ffffff");
233
+ }, [l.primaryColor, e.headerBg, e.chatBg, e.userMsgBg, e.assistantMsgBg, e.inputBg]), N(() => {
234
+ const s = setTimeout(() => D(!0), 100);
235
+ return () => clearTimeout(s);
236
+ }, []), N(() => {
237
+ var s;
238
+ (s = o.current) == null || s.scrollIntoView({ behavior: "smooth" });
239
+ }, [I, g]);
240
+ const T = () => k(!r), a = l.position, p = () => {
241
+ const s = { position: "absolute", zIndex: 9999 }, h = {
242
+ "bottom-right": { ...s, bottom: 20, right: 20 },
243
+ "bottom-left": { ...s, bottom: 20, left: 20 },
244
+ "bottom-middle": { ...s, bottom: 20, left: "50%" },
245
+ "top-right": { ...s, top: 20, right: 20 },
246
+ "top-left": { ...s, top: 20, left: 20 },
247
+ "top-middle": { ...s, top: 20, left: "50%" }
248
+ };
249
+ return h[a] || h["bottom-right"];
250
+ }, E = () => ({
251
+ "bottom-right": "bottom right",
252
+ "bottom-left": "bottom left",
253
+ "bottom-middle": "bottom center",
254
+ "top-right": "top right",
255
+ "top-left": "top left",
256
+ "top-middle": "top center"
257
+ })[a] || "bottom right", i = async (s) => {
258
+ if (s.preventDefault(), !m.trim() || g) return;
259
+ const h = m.trim();
260
+ x(""), P(null);
261
+ const f = { role: "user", content: h, timestamp: /* @__PURE__ */ new Date() }, d = [...I, f];
262
+ C(d), B(!0);
263
+ try {
264
+ const b = I.map((K) => ({ role: K.role, content: K.content })), M = typeof e.getAuthToken == "function" ? await Promise.resolve(e.getAuthToken()) : e.authToken, y = A(c);
265
+ let w;
266
+ y ? w = await U(
267
+ e.apiUrl,
268
+ h,
269
+ b,
270
+ y,
271
+ M,
272
+ e.apiKey
273
+ ) : w = await V(
274
+ e.apiUrl,
275
+ h,
276
+ c,
277
+ b,
278
+ M,
279
+ e.apiKey
280
+ ), w.conversation_id && typeof window < "u" && J(c, w.conversation_id);
281
+ const H = { role: "assistant", content: typeof (w == null ? void 0 : w.reply) == "string" ? w.reply : (w == null ? void 0 : w.reply) != null ? String(w.reply) : "", timestamp: /* @__PURE__ */ new Date() };
282
+ C([...d, H]);
283
+ } catch (b) {
284
+ console.error("[ConvoKit Connect] Chat error:", b);
285
+ const M = b instanceof Error ? b.message : "Sorry, something went wrong.";
286
+ P(M), C([...d, { role: "assistant", content: `Error: ${M}`, timestamp: /* @__PURE__ */ new Date() }]);
287
+ } finally {
288
+ B(!1);
289
+ }
290
+ };
291
+ return /* @__PURE__ */ t("div", { className: "convokit-widget", children: /* @__PURE__ */ n(
292
+ L,
293
+ {
294
+ className: "convokit-morph-container",
295
+ initial: { opacity: 0, scale: 0, width: 60, height: 60, borderRadius: 50, x: a === "bottom-middle" || a === "top-middle" ? "-50%" : 0 },
296
+ animate: {
297
+ opacity: 1,
298
+ scale: 1,
299
+ width: r ? 380 : 60,
300
+ height: r ? 600 : 60,
301
+ borderRadius: r ? 16 : 50,
302
+ x: a === "bottom-middle" || a === "top-middle" ? "-50%" : 0
303
+ },
304
+ transition: {
305
+ duration: 0.4,
306
+ scale: { type: "spring", visualDuration: 0.4, bounce: 0.5 },
307
+ width: v ? { type: "spring", stiffness: 300, damping: 30 } : { duration: 0 },
308
+ height: v ? { type: "spring", stiffness: 300, damping: 30 } : { duration: 0 },
309
+ borderRadius: v ? { type: "spring", stiffness: 300, damping: 30 } : { duration: 0 },
310
+ x: { duration: 0 }
311
+ },
312
+ style: {
313
+ backgroundColor: l.primaryColor,
314
+ ...p(),
315
+ transformOrigin: E(),
316
+ cursor: r ? "default" : "pointer",
317
+ overflow: "hidden",
318
+ boxShadow: r ? "0 12px 40px rgba(0, 0, 0, 0.2)" : "0 4px 20px rgba(0, 0, 0, 0.2)",
319
+ pointerEvents: "auto"
320
+ },
321
+ onClick: r ? void 0 : T,
322
+ children: [
323
+ /* @__PURE__ */ t(
324
+ L,
696
325
  {
697
- type: "text",
698
- value: j,
699
- onChange: (d) => x(d.target.value),
700
- placeholder: m.placeholder || "Type a message...",
701
- disabled: y,
702
- className: "convokit-input"
326
+ style: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, display: "flex", alignItems: "center", justifyContent: "center", pointerEvents: "none" },
327
+ animate: { opacity: r ? 0 : 1, scale: r ? 0 : 1 },
328
+ transition: { duration: 0.2 },
329
+ children: e.bubbleIconUrl ? /* @__PURE__ */ t("img", { src: e.bubbleIconUrl, alt: "", width: 24, height: 24, style: { objectFit: "contain" } }) : /* @__PURE__ */ t("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ t("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) })
703
330
  }
704
331
  ),
705
- /* @__PURE__ */ l.jsx(
706
- "button",
332
+ /* @__PURE__ */ t(
333
+ L,
707
334
  {
708
- type: "submit",
709
- disabled: y || !j.trim(),
710
- className: "convokit-send",
711
- style: { color: m.primaryColor || "#000" },
712
- children: /* @__PURE__ */ l.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ l.jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) })
335
+ style: { width: "100%", height: "100%", opacity: r ? 1 : 0, pointerEvents: r ? "all" : "none" },
336
+ animate: { opacity: r ? 1 : 0 },
337
+ transition: { duration: 0.2, delay: r ? 0.2 : 0 },
338
+ children: /* @__PURE__ */ t("div", { className: "convokit-chat-window-body", style: { background: "#ffffff", width: "100%", height: "100%", display: "flex", flexDirection: "column", overflow: "hidden" }, children: /* @__PURE__ */ n("div", { className: "convokit-chat-wrapper", children: [
339
+ /* @__PURE__ */ n("div", { className: "convokit-header", children: [
340
+ /* @__PURE__ */ n("div", { className: "convokit-header-left", children: [
341
+ /* @__PURE__ */ t("div", { className: "convokit-avatar", children: /* @__PURE__ */ n("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", children: [
342
+ /* @__PURE__ */ t("circle", { cx: "12", cy: "8", r: "4", fill: "white", opacity: "0.9" }),
343
+ /* @__PURE__ */ t("path", { d: "M6 20c0-4 2.5-6 6-6s6 2 6 6", stroke: "white", strokeWidth: "2", strokeLinecap: "round" })
344
+ ] }) }),
345
+ /* @__PURE__ */ n("div", { className: "convokit-header-text", children: [
346
+ /* @__PURE__ */ t("h3", { children: l.title }),
347
+ l.subtitle && /* @__PURE__ */ t("p", { className: "convokit-header-subtitle", children: l.subtitle })
348
+ ] })
349
+ ] }),
350
+ /* @__PURE__ */ t("div", { className: "convokit-header-actions", children: /* @__PURE__ */ t("button", { onClick: T, className: "convokit-header-icon", "aria-label": "Close chat", children: /* @__PURE__ */ n("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
351
+ /* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
352
+ /* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
353
+ ] }) }) })
354
+ ] }),
355
+ /* @__PURE__ */ t("div", { className: "convokit-chat-window-content", children: /* @__PURE__ */ n("div", { className: "convokit-chat-container", children: [
356
+ /* @__PURE__ */ n("div", { className: "convokit-messages", children: [
357
+ S && /* @__PURE__ */ n("div", { style: { padding: 12, margin: 8, background: "#fee", color: "#c33", borderRadius: 8, fontSize: 14 }, children: [
358
+ "⚠️ ",
359
+ S
360
+ ] }),
361
+ I.length === 0 && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(l.welcomeMessage) } }) }),
362
+ I.map((s, h) => /* @__PURE__ */ t("div", { className: `convokit-message convokit-message-${s.role}`, children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(s.content) } }) }, h)),
363
+ g && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", children: /* @__PURE__ */ n("div", { className: "convokit-typing", children: [
364
+ /* @__PURE__ */ t("span", {}),
365
+ /* @__PURE__ */ t("span", {}),
366
+ /* @__PURE__ */ t("span", {})
367
+ ] }) }) }),
368
+ /* @__PURE__ */ t("div", { ref: o })
369
+ ] }),
370
+ /* @__PURE__ */ n("form", { onSubmit: i, className: "convokit-input-form", children: [
371
+ /* @__PURE__ */ t(
372
+ "input",
373
+ {
374
+ type: "text",
375
+ value: m,
376
+ onChange: (s) => x(s.target.value),
377
+ placeholder: l.placeholder,
378
+ disabled: g,
379
+ className: "convokit-input"
380
+ }
381
+ ),
382
+ /* @__PURE__ */ t("button", { type: "submit", disabled: g || !m.trim(), className: "convokit-send-button", "aria-label": "Send message", children: /* @__PURE__ */ n("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
383
+ /* @__PURE__ */ t("path", { d: "M22 2L11 13" }),
384
+ /* @__PURE__ */ t("path", { d: "M22 2l-7 20-4-9-9-4z" })
385
+ ] }) })
386
+ ] }),
387
+ /* @__PURE__ */ n("div", { className: "convokit-footer", children: [
388
+ "Powered by ",
389
+ /* @__PURE__ */ t("a", { href: "https://convokit.com", target: "_blank", rel: "noopener noreferrer", children: "ConvoKit" })
390
+ ] })
391
+ ] }) })
392
+ ] }) })
713
393
  }
714
394
  )
715
- ] })
716
- ] })
717
- ] });
395
+ ]
396
+ }
397
+ ) });
398
+ }, z = {
399
+ title: "Chat",
400
+ welcomeMessage: "How can I help you today?",
401
+ position: "bottom-right"
402
+ }, ae = (e) => {
403
+ const { apiUrl: c, apiKey: r } = e;
404
+ if (!(c != null && c.trim()) || !(r != null && r.trim()))
405
+ return null;
406
+ const k = {
407
+ ...z,
408
+ apiUrl: c.trim(),
409
+ apiKey: r.trim(),
410
+ authToken: e.authToken,
411
+ widgetId: e.widgetId,
412
+ title: e.title ?? z.title,
413
+ welcomeMessage: e.welcomeMessage ?? z.welcomeMessage,
414
+ position: e.position ?? z.position,
415
+ primaryColor: e.primaryColor
416
+ };
417
+ return /* @__PURE__ */ t(ee, { config: k });
418
+ }, te = "convokit-widget", oe = ({ config: e, onBack: c, backLabel: r = "Back to editor" }) => {
419
+ const k = e.widgetId ?? te, [I, C] = u(!0), [m, x] = u([]), [g, B] = u(""), [v, D] = u(!1), [S, P] = u(null), o = F(null), l = {
420
+ ...e,
421
+ primaryColor: e.primaryColor || "#000",
422
+ title: e.title || "Chat",
423
+ subtitle: e.subtitle,
424
+ welcomeMessage: e.welcomeMessage || "How can I help you today?",
425
+ placeholder: e.placeholder || "Type a message..."
426
+ };
427
+ N(() => {
428
+ if (typeof document > "u") return;
429
+ const a = document.documentElement;
430
+ a.style.setProperty("--convokit-primary", l.primaryColor), a.style.setProperty("--convokit-header-bg", e.headerBg ?? l.primaryColor ?? "#000"), a.style.setProperty("--convokit-font-family", "Inter, system-ui, sans-serif"), a.style.setProperty("--convokit-font-size", "14px"), a.style.setProperty("--convokit-border-radius", "18px"), a.style.setProperty("--convokit-chat-bg", e.chatBg ?? "#ffffff"), a.style.setProperty("--convokit-user-msg-bg", e.userMsgBg ?? l.primaryColor ?? "#000"), a.style.setProperty("--convokit-assistant-msg-bg", e.assistantMsgBg ?? "#f3f4f6"), a.style.setProperty("--convokit-input-bg", e.inputBg ?? "#ffffff");
431
+ }, [l.primaryColor, e.headerBg, e.chatBg, e.userMsgBg, e.assistantMsgBg, e.inputBg]), N(() => {
432
+ var a;
433
+ (a = o.current) == null || a.scrollIntoView({ behavior: "smooth" });
434
+ }, [m, v]);
435
+ const T = async (a) => {
436
+ if (a.preventDefault(), !g.trim() || v) return;
437
+ const p = g.trim();
438
+ B(""), P(null);
439
+ const E = { role: "user", content: p, timestamp: /* @__PURE__ */ new Date() }, i = [...m, E];
440
+ x(i), D(!0);
441
+ try {
442
+ const s = m.map((y) => ({ role: y.role, content: y.content })), h = typeof e.getAuthToken == "function" ? await Promise.resolve(e.getAuthToken()) : e.authToken, f = A(k);
443
+ let d;
444
+ f ? d = await U(
445
+ e.apiUrl,
446
+ p,
447
+ s,
448
+ f,
449
+ h,
450
+ e.apiKey
451
+ ) : d = await V(
452
+ e.apiUrl,
453
+ p,
454
+ k,
455
+ s,
456
+ h,
457
+ e.apiKey
458
+ ), d.conversation_id && typeof window < "u" && J(k, d.conversation_id);
459
+ const M = { role: "assistant", content: typeof (d == null ? void 0 : d.reply) == "string" ? d.reply : (d == null ? void 0 : d.reply) != null ? String(d.reply) : "", timestamp: /* @__PURE__ */ new Date() };
460
+ x([...i, M]);
461
+ } catch (s) {
462
+ console.error("[ConvoKit Connect] Chat error:", s);
463
+ const h = s instanceof Error ? s.message : "Sorry, something went wrong.";
464
+ P(h), x([...i, { role: "assistant", content: `Error: ${h}`, timestamp: /* @__PURE__ */ new Date() }]);
465
+ } finally {
466
+ D(!1);
467
+ }
468
+ };
469
+ return I ? /* @__PURE__ */ n(
470
+ L,
471
+ {
472
+ className: "convokit-widget",
473
+ initial: { opacity: 0 },
474
+ animate: { opacity: 1 },
475
+ exit: { opacity: 0 },
476
+ transition: { duration: 0.2 },
477
+ style: {
478
+ position: "fixed",
479
+ inset: 0,
480
+ zIndex: 1e4,
481
+ display: "flex",
482
+ flexDirection: "column",
483
+ background: "var(--convokit-chat-bg)",
484
+ fontFamily: "var(--convokit-font-family)",
485
+ pointerEvents: "auto"
486
+ },
487
+ children: [
488
+ /* @__PURE__ */ n("div", { className: "convokit-header", style: { flexShrink: 0 }, children: [
489
+ /* @__PURE__ */ t("div", { className: "convokit-header-left", children: /* @__PURE__ */ n("div", { className: "convokit-header-text", children: [
490
+ /* @__PURE__ */ t("h3", { children: l.title }),
491
+ l.subtitle && /* @__PURE__ */ t("p", { className: "convokit-header-subtitle", children: l.subtitle })
492
+ ] }) }),
493
+ /* @__PURE__ */ t("div", { className: "convokit-header-actions", children: c ? /* @__PURE__ */ n("button", { type: "button", onClick: c, className: "convokit-header-icon", "aria-label": r, style: { fontSize: 14, gap: 6, display: "flex", alignItems: "center" }, children: [
494
+ /* @__PURE__ */ t("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ t("path", { d: "M19 12H5M12 19l-7-7 7-7" }) }),
495
+ r
496
+ ] }) : /* @__PURE__ */ t("button", { type: "button", onClick: () => C(!1), className: "convokit-header-icon", "aria-label": "Close chat", children: /* @__PURE__ */ n("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
497
+ /* @__PURE__ */ t("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
498
+ /* @__PURE__ */ t("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
499
+ ] }) }) })
500
+ ] }),
501
+ /* @__PURE__ */ t("div", { className: "convokit-chat-wrapper", style: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ t("div", { className: "convokit-chat-window-content", style: { flex: 1, minHeight: 0, overflow: "hidden", display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ n("div", { className: "convokit-chat-container", style: { flex: 1, minHeight: 0, display: "flex", flexDirection: "column", padding: 16 }, children: [
502
+ /* @__PURE__ */ n("div", { className: "convokit-messages", style: { flex: 1, overflowY: "auto", padding: "8px 0" }, children: [
503
+ S && /* @__PURE__ */ n("div", { style: { padding: 12, margin: 8, background: "#fee", color: "#c33", borderRadius: 8, fontSize: 14 }, children: [
504
+ "⚠️ ",
505
+ S
506
+ ] }),
507
+ m.length === 0 && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(l.welcomeMessage) } }) }),
508
+ m.map((a, p) => /* @__PURE__ */ t("div", { className: `convokit-message convokit-message-${a.role}`, children: /* @__PURE__ */ t("div", { className: "convokit-message-content", dangerouslySetInnerHTML: { __html: _(a.content) } }) }, p)),
509
+ v && /* @__PURE__ */ t("div", { className: "convokit-message convokit-message-assistant", children: /* @__PURE__ */ t("div", { className: "convokit-message-content", children: /* @__PURE__ */ n("div", { className: "convokit-typing", children: [
510
+ /* @__PURE__ */ t("span", {}),
511
+ /* @__PURE__ */ t("span", {}),
512
+ /* @__PURE__ */ t("span", {})
513
+ ] }) }) }),
514
+ /* @__PURE__ */ t("div", { ref: o })
515
+ ] }),
516
+ /* @__PURE__ */ n("form", { onSubmit: T, className: "convokit-input-form", children: [
517
+ /* @__PURE__ */ t(
518
+ "input",
519
+ {
520
+ type: "text",
521
+ value: g,
522
+ onChange: (a) => B(a.target.value),
523
+ placeholder: l.placeholder,
524
+ disabled: v,
525
+ className: "convokit-input"
526
+ }
527
+ ),
528
+ /* @__PURE__ */ t("button", { type: "submit", disabled: v || !g.trim(), className: "convokit-send-button", "aria-label": "Send message", children: /* @__PURE__ */ n("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
529
+ /* @__PURE__ */ t("path", { d: "M22 2L11 13" }),
530
+ /* @__PURE__ */ t("path", { d: "M22 2l-7 20-4-9-9-4z" })
531
+ ] }) })
532
+ ] }),
533
+ /* @__PURE__ */ n("div", { className: "convokit-footer", children: [
534
+ "Powered by ",
535
+ /* @__PURE__ */ t("a", { href: "https://convokit.com", target: "_blank", rel: "noopener noreferrer", children: "ConvoKit" })
536
+ ] })
537
+ ] }) }) })
538
+ ]
539
+ }
540
+ ) : /* @__PURE__ */ t(
541
+ L,
542
+ {
543
+ initial: { opacity: 0 },
544
+ animate: { opacity: 1 },
545
+ style: {
546
+ position: "fixed",
547
+ inset: 0,
548
+ zIndex: 1e4,
549
+ display: "flex",
550
+ alignItems: "center",
551
+ justifyContent: "center",
552
+ background: "var(--convokit-chat-bg)",
553
+ pointerEvents: "auto"
554
+ },
555
+ children: /* @__PURE__ */ n(
556
+ "button",
557
+ {
558
+ type: "button",
559
+ onClick: () => C(!0),
560
+ "aria-label": "Open chat",
561
+ style: {
562
+ padding: "14px 28px",
563
+ borderRadius: 12,
564
+ border: "none",
565
+ background: l.primaryColor,
566
+ color: "white",
567
+ fontSize: 16,
568
+ fontWeight: 500,
569
+ cursor: "pointer",
570
+ display: "flex",
571
+ alignItems: "center",
572
+ gap: 10,
573
+ boxShadow: "0 4px 14px rgba(0,0,0,0.15)"
574
+ },
575
+ children: [
576
+ /* @__PURE__ */ t("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ t("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) }),
577
+ "Open chat"
578
+ ]
579
+ }
580
+ )
581
+ }
582
+ );
583
+ }, O = {
584
+ title: "Chat",
585
+ welcomeMessage: "How can I help you today?"
586
+ }, le = (e) => {
587
+ const { apiUrl: c, apiKey: r } = e;
588
+ if (!(c != null && c.trim()) || !(r != null && r.trim()))
589
+ return null;
590
+ const k = {
591
+ ...O,
592
+ apiUrl: c.trim(),
593
+ apiKey: r.trim(),
594
+ authToken: e.authToken,
595
+ widgetId: e.widgetId,
596
+ title: e.title ?? O.title,
597
+ welcomeMessage: e.welcomeMessage ?? O.welcomeMessage,
598
+ primaryColor: e.primaryColor
599
+ };
600
+ return /* @__PURE__ */ t(
601
+ oe,
602
+ {
603
+ config: k,
604
+ onBack: e.onBack,
605
+ backLabel: e.backLabel ?? "Back"
606
+ }
607
+ );
718
608
  };
719
609
  export {
720
- pr as ChatWidget
610
+ le as FullScreenBackendWidget,
611
+ re as FullScreenWidget,
612
+ ae as PopupBackendWidget,
613
+ he as PopupWidget
721
614
  };