lulichat 1.0.7 → 1.0.8

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.
@@ -1,9 +1,11 @@
1
- var kt = Object.defineProperty;
2
- var Ct = (n, s, l) => s in n ? kt(n, s, { enumerable: !0, configurable: !0, writable: !0, value: l }) : n[s] = l;
3
- var F = (n, s, l) => Ct(n, typeof s != "symbol" ? s + "" : s, l);
4
- import S, { useRef as U, useCallback as $e, useImperativeHandle as Et, useState as P, useEffect as ce } from "react";
5
- import Rt, { clsx as St } from "clsx";
6
- var ue = { exports: {} }, J = {};
1
+ var St = Object.defineProperty;
2
+ var _t = (n, r, a) => r in n ? St(n, r, { enumerable: !0, configurable: !0, writable: !0, value: a }) : n[r] = a;
3
+ var q = (n, r, a) => _t(n, typeof r != "symbol" ? r + "" : r, a);
4
+ import g, { useRef as J, useCallback as Ue, useImperativeHandle as Tt, useState as W, useEffect as be } from "react";
5
+ import Nt from "socket.io-client";
6
+ import { marked as Ot } from "marked";
7
+ import Mt from "dompurify";
8
+ var je = { exports: {} }, te = {};
7
9
  /**
8
10
  * @license React
9
11
  * react-jsx-runtime.production.min.js
@@ -13,21 +15,21 @@ var ue = { exports: {} }, J = {};
13
15
  * This source code is licensed under the MIT license found in the
14
16
  * LICENSE file in the root directory of this source tree.
15
17
  */
16
- var Me;
17
- function _t() {
18
- if (Me) return J;
19
- Me = 1;
20
- var n = S, s = Symbol.for("react.element"), l = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, v = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, d = { key: !0, ref: !0, __self: !0, __source: !0 };
21
- function y(b, u, h) {
22
- var p, E = {}, R = null, T = null;
23
- h !== void 0 && (R = "" + h), u.key !== void 0 && (R = "" + u.key), u.ref !== void 0 && (T = u.ref);
24
- for (p in u) i.call(u, p) && !d.hasOwnProperty(p) && (E[p] = u[p]);
25
- if (b && b.defaultProps) for (p in u = b.defaultProps, u) E[p] === void 0 && (E[p] = u[p]);
26
- return { $$typeof: s, type: b, key: R, ref: T, props: E, _owner: v.current };
18
+ var He;
19
+ function Dt() {
20
+ if (He) return te;
21
+ He = 1;
22
+ var n = g, r = Symbol.for("react.element"), a = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, l = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
23
+ function h(f, u, b) {
24
+ var p, E = {}, m = null, _ = null;
25
+ b !== void 0 && (m = "" + b), u.key !== void 0 && (m = "" + u.key), u.ref !== void 0 && (_ = u.ref);
26
+ for (p in u) i.call(u, p) && !c.hasOwnProperty(p) && (E[p] = u[p]);
27
+ if (f && f.defaultProps) for (p in u = f.defaultProps, u) E[p] === void 0 && (E[p] = u[p]);
28
+ return { $$typeof: r, type: f, key: m, ref: _, props: E, _owner: l.current };
27
29
  }
28
- return J.Fragment = l, J.jsx = y, J.jsxs = y, J;
30
+ return te.Fragment = a, te.jsx = h, te.jsxs = h, te;
29
31
  }
30
- var K = {};
32
+ var re = {};
31
33
  /**
32
34
  * @license React
33
35
  * react-jsx-runtime.development.js
@@ -37,91 +39,91 @@ var K = {};
37
39
  * This source code is licensed under the MIT license found in the
38
40
  * LICENSE file in the root directory of this source tree.
39
41
  */
40
- var Ie;
41
- function Nt() {
42
- return Ie || (Ie = 1, process.env.NODE_ENV !== "production" && function() {
43
- var n = S, s = Symbol.for("react.element"), l = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), d = Symbol.for("react.profiler"), y = Symbol.for("react.provider"), b = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), h = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), R = Symbol.for("react.lazy"), T = Symbol.for("react.offscreen"), A = Symbol.iterator, M = "@@iterator";
44
- function j(e) {
42
+ var Ye;
43
+ function It() {
44
+ return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
45
+ var n = g, r = Symbol.for("react.element"), a = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), l = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), f = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), p = Symbol.for("react.suspense_list"), E = Symbol.for("react.memo"), m = Symbol.for("react.lazy"), _ = Symbol.for("react.offscreen"), S = Symbol.iterator, w = "@@iterator";
46
+ function R(e) {
45
47
  if (e === null || typeof e != "object")
46
48
  return null;
47
- var r = A && e[A] || e[M];
48
- return typeof r == "function" ? r : null;
49
+ var s = S && e[S] || e[w];
50
+ return typeof s == "function" ? s : null;
49
51
  }
50
- var O = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
51
- function o(e) {
52
+ var T = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
53
+ function j(e) {
52
54
  {
53
- for (var r = arguments.length, a = new Array(r > 1 ? r - 1 : 0), c = 1; c < r; c++)
54
- a[c - 1] = arguments[c];
55
- w("error", e, a);
55
+ for (var s = arguments.length, o = new Array(s > 1 ? s - 1 : 0), d = 1; d < s; d++)
56
+ o[d - 1] = arguments[d];
57
+ X("error", e, o);
56
58
  }
57
59
  }
58
- function w(e, r, a) {
60
+ function X(e, s, o) {
59
61
  {
60
- var c = O.ReactDebugCurrentFrame, g = c.getStackAddendum();
61
- g !== "" && (r += "%s", a = a.concat([g]));
62
- var x = a.map(function(m) {
63
- return String(m);
62
+ var d = T.ReactDebugCurrentFrame, k = d.getStackAddendum();
63
+ k !== "" && (s += "%s", o = o.concat([k]));
64
+ var C = o.map(function(x) {
65
+ return String(x);
64
66
  });
65
- x.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, x);
67
+ C.unshift("Warning: " + s), Function.prototype.apply.call(console[e], console, C);
66
68
  }
67
69
  }
68
- var $ = !1, Ye = !1, Ue = !1, qe = !1, He = !1, fe;
69
- fe = Symbol.for("react.module.reference");
70
- function Je(e) {
71
- return !!(typeof e == "string" || typeof e == "function" || e === i || e === d || He || e === v || e === h || e === p || qe || e === T || $ || Ye || Ue || typeof e == "object" && e !== null && (e.$$typeof === R || e.$$typeof === E || e.$$typeof === y || e.$$typeof === b || e.$$typeof === u || // This needs to include all possible module reference object
70
+ var D = !1, B = !1, Y = !1, z = !1, y = !1, I;
71
+ I = Symbol.for("react.module.reference");
72
+ function M(e) {
73
+ return !!(typeof e == "string" || typeof e == "function" || e === i || e === c || y || e === l || e === b || e === p || z || e === _ || D || B || Y || typeof e == "object" && e !== null && (e.$$typeof === m || e.$$typeof === E || e.$$typeof === h || e.$$typeof === f || e.$$typeof === u || // This needs to include all possible module reference object
72
74
  // types supported by any Flight configuration anywhere since
73
75
  // we don't know which Flight build this will end up being used
74
76
  // with.
75
- e.$$typeof === fe || e.getModuleId !== void 0));
77
+ e.$$typeof === I || e.getModuleId !== void 0));
76
78
  }
77
- function Ke(e, r, a) {
78
- var c = e.displayName;
79
- if (c)
80
- return c;
81
- var g = r.displayName || r.name || "";
82
- return g !== "" ? a + "(" + g + ")" : a;
79
+ function $(e, s, o) {
80
+ var d = e.displayName;
81
+ if (d)
82
+ return d;
83
+ var k = s.displayName || s.name || "";
84
+ return k !== "" ? o + "(" + k + ")" : o;
83
85
  }
84
- function de(e) {
86
+ function ne(e) {
85
87
  return e.displayName || "Context";
86
88
  }
87
- function I(e) {
89
+ function F(e) {
88
90
  if (e == null)
89
91
  return null;
90
- if (typeof e.tag == "number" && o("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
92
+ if (typeof e.tag == "number" && j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
91
93
  return e.displayName || e.name || null;
92
94
  if (typeof e == "string")
93
95
  return e;
94
96
  switch (e) {
95
97
  case i:
96
98
  return "Fragment";
97
- case l:
99
+ case a:
98
100
  return "Portal";
99
- case d:
101
+ case c:
100
102
  return "Profiler";
101
- case v:
103
+ case l:
102
104
  return "StrictMode";
103
- case h:
105
+ case b:
104
106
  return "Suspense";
105
107
  case p:
106
108
  return "SuspenseList";
107
109
  }
108
110
  if (typeof e == "object")
109
111
  switch (e.$$typeof) {
110
- case b:
111
- var r = e;
112
- return de(r) + ".Consumer";
113
- case y:
114
- var a = e;
115
- return de(a._context) + ".Provider";
112
+ case f:
113
+ var s = e;
114
+ return ne(s) + ".Consumer";
115
+ case h:
116
+ var o = e;
117
+ return ne(o._context) + ".Provider";
116
118
  case u:
117
- return Ke(e, e.render, "ForwardRef");
119
+ return $(e, e.render, "ForwardRef");
118
120
  case E:
119
- var c = e.displayName || null;
120
- return c !== null ? c : I(e.type) || "Memo";
121
- case R: {
122
- var g = e, x = g._payload, m = g._init;
121
+ var d = e.displayName || null;
122
+ return d !== null ? d : F(e.type) || "Memo";
123
+ case m: {
124
+ var k = e, C = k._payload, x = k._init;
123
125
  try {
124
- return I(m(x));
126
+ return F(x(C));
125
127
  } catch {
126
128
  return null;
127
129
  }
@@ -129,18 +131,18 @@ function Nt() {
129
131
  }
130
132
  return null;
131
133
  }
132
- var L = Object.assign, q = 0, he, me, ve, pe, ge, xe, ye;
133
- function be() {
134
+ var V = Object.assign, Q = 0, ke, we, Ce, Ee, Re, Se, _e;
135
+ function Te() {
134
136
  }
135
- be.__reactDisabledLog = !0;
136
- function Ge() {
137
+ Te.__reactDisabledLog = !0;
138
+ function et() {
137
139
  {
138
- if (q === 0) {
139
- he = console.log, me = console.info, ve = console.warn, pe = console.error, ge = console.group, xe = console.groupCollapsed, ye = console.groupEnd;
140
+ if (Q === 0) {
141
+ ke = console.log, we = console.info, Ce = console.warn, Ee = console.error, Re = console.group, Se = console.groupCollapsed, _e = console.groupEnd;
140
142
  var e = {
141
143
  configurable: !0,
142
144
  enumerable: !0,
143
- value: be,
145
+ value: Te,
144
146
  writable: !0
145
147
  };
146
148
  Object.defineProperties(console, {
@@ -153,332 +155,332 @@ function Nt() {
153
155
  groupEnd: e
154
156
  });
155
157
  }
156
- q++;
158
+ Q++;
157
159
  }
158
160
  }
159
- function Ze() {
161
+ function tt() {
160
162
  {
161
- if (q--, q === 0) {
163
+ if (Q--, Q === 0) {
162
164
  var e = {
163
165
  configurable: !0,
164
166
  enumerable: !0,
165
167
  writable: !0
166
168
  };
167
169
  Object.defineProperties(console, {
168
- log: L({}, e, {
169
- value: he
170
+ log: V({}, e, {
171
+ value: ke
170
172
  }),
171
- info: L({}, e, {
172
- value: me
173
+ info: V({}, e, {
174
+ value: we
173
175
  }),
174
- warn: L({}, e, {
175
- value: ve
176
+ warn: V({}, e, {
177
+ value: Ce
176
178
  }),
177
- error: L({}, e, {
178
- value: pe
179
+ error: V({}, e, {
180
+ value: Ee
179
181
  }),
180
- group: L({}, e, {
181
- value: ge
182
+ group: V({}, e, {
183
+ value: Re
182
184
  }),
183
- groupCollapsed: L({}, e, {
184
- value: xe
185
+ groupCollapsed: V({}, e, {
186
+ value: Se
185
187
  }),
186
- groupEnd: L({}, e, {
187
- value: ye
188
+ groupEnd: V({}, e, {
189
+ value: _e
188
190
  })
189
191
  });
190
192
  }
191
- q < 0 && o("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
+ Q < 0 && j("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
192
194
  }
193
195
  }
194
- var te = O.ReactCurrentDispatcher, re;
195
- function G(e, r, a) {
196
+ var de = T.ReactCurrentDispatcher, fe;
197
+ function ae(e, s, o) {
196
198
  {
197
- if (re === void 0)
199
+ if (fe === void 0)
198
200
  try {
199
201
  throw Error();
200
- } catch (g) {
201
- var c = g.stack.trim().match(/\n( *(at )?)/);
202
- re = c && c[1] || "";
202
+ } catch (k) {
203
+ var d = k.stack.trim().match(/\n( *(at )?)/);
204
+ fe = d && d[1] || "";
203
205
  }
204
206
  return `
205
- ` + re + e;
207
+ ` + fe + e;
206
208
  }
207
209
  }
208
- var ne = !1, Z;
210
+ var he = !1, oe;
209
211
  {
210
- var Xe = typeof WeakMap == "function" ? WeakMap : Map;
211
- Z = new Xe();
212
+ var rt = typeof WeakMap == "function" ? WeakMap : Map;
213
+ oe = new rt();
212
214
  }
213
- function je(e, r) {
214
- if (!e || ne)
215
+ function Ne(e, s) {
216
+ if (!e || he)
215
217
  return "";
216
218
  {
217
- var a = Z.get(e);
218
- if (a !== void 0)
219
- return a;
219
+ var o = oe.get(e);
220
+ if (o !== void 0)
221
+ return o;
220
222
  }
221
- var c;
222
- ne = !0;
223
- var g = Error.prepareStackTrace;
223
+ var d;
224
+ he = !0;
225
+ var k = Error.prepareStackTrace;
224
226
  Error.prepareStackTrace = void 0;
225
- var x;
226
- x = te.current, te.current = null, Ge();
227
+ var C;
228
+ C = de.current, de.current = null, et();
227
229
  try {
228
- if (r) {
229
- var m = function() {
230
+ if (s) {
231
+ var x = function() {
230
232
  throw Error();
231
233
  };
232
- if (Object.defineProperty(m.prototype, "props", {
234
+ if (Object.defineProperty(x.prototype, "props", {
233
235
  set: function() {
234
236
  throw Error();
235
237
  }
236
238
  }), typeof Reflect == "object" && Reflect.construct) {
237
239
  try {
238
- Reflect.construct(m, []);
239
- } catch (N) {
240
- c = N;
240
+ Reflect.construct(x, []);
241
+ } catch (P) {
242
+ d = P;
241
243
  }
242
- Reflect.construct(e, [], m);
244
+ Reflect.construct(e, [], x);
243
245
  } else {
244
246
  try {
245
- m.call();
246
- } catch (N) {
247
- c = N;
247
+ x.call();
248
+ } catch (P) {
249
+ d = P;
248
250
  }
249
- e.call(m.prototype);
251
+ e.call(x.prototype);
250
252
  }
251
253
  } else {
252
254
  try {
253
255
  throw Error();
254
- } catch (N) {
255
- c = N;
256
+ } catch (P) {
257
+ d = P;
256
258
  }
257
259
  e();
258
260
  }
259
- } catch (N) {
260
- if (N && c && typeof N.stack == "string") {
261
- for (var f = N.stack.split(`
262
- `), _ = c.stack.split(`
263
- `), k = f.length - 1, C = _.length - 1; k >= 1 && C >= 0 && f[k] !== _[C]; )
264
- C--;
265
- for (; k >= 1 && C >= 0; k--, C--)
266
- if (f[k] !== _[C]) {
267
- if (k !== 1 || C !== 1)
261
+ } catch (P) {
262
+ if (P && d && typeof P.stack == "string") {
263
+ for (var v = P.stack.split(`
264
+ `), L = d.stack.split(`
265
+ `), N = v.length - 1, O = L.length - 1; N >= 1 && O >= 0 && v[N] !== L[O]; )
266
+ O--;
267
+ for (; N >= 1 && O >= 0; N--, O--)
268
+ if (v[N] !== L[O]) {
269
+ if (N !== 1 || O !== 1)
268
270
  do
269
- if (k--, C--, C < 0 || f[k] !== _[C]) {
270
- var D = `
271
- ` + f[k].replace(" at new ", " at ");
272
- return e.displayName && D.includes("<anonymous>") && (D = D.replace("<anonymous>", e.displayName)), typeof e == "function" && Z.set(e, D), D;
271
+ if (N--, O--, O < 0 || v[N] !== L[O]) {
272
+ var A = `
273
+ ` + v[N].replace(" at new ", " at ");
274
+ return e.displayName && A.includes("<anonymous>") && (A = A.replace("<anonymous>", e.displayName)), typeof e == "function" && oe.set(e, A), A;
273
275
  }
274
- while (k >= 1 && C >= 0);
276
+ while (N >= 1 && O >= 0);
275
277
  break;
276
278
  }
277
279
  }
278
280
  } finally {
279
- ne = !1, te.current = x, Ze(), Error.prepareStackTrace = g;
281
+ he = !1, de.current = C, tt(), Error.prepareStackTrace = k;
280
282
  }
281
- var B = e ? e.displayName || e.name : "", W = B ? G(B) : "";
282
- return typeof e == "function" && Z.set(e, W), W;
283
+ var K = e ? e.displayName || e.name : "", H = K ? ae(K) : "";
284
+ return typeof e == "function" && oe.set(e, H), H;
283
285
  }
284
- function Qe(e, r, a) {
285
- return je(e, !1);
286
+ function st(e, s, o) {
287
+ return Ne(e, !1);
286
288
  }
287
- function et(e) {
288
- var r = e.prototype;
289
- return !!(r && r.isReactComponent);
289
+ function nt(e) {
290
+ var s = e.prototype;
291
+ return !!(s && s.isReactComponent);
290
292
  }
291
- function X(e, r, a) {
293
+ function ie(e, s, o) {
292
294
  if (e == null)
293
295
  return "";
294
296
  if (typeof e == "function")
295
- return je(e, et(e));
297
+ return Ne(e, nt(e));
296
298
  if (typeof e == "string")
297
- return G(e);
299
+ return ae(e);
298
300
  switch (e) {
299
- case h:
300
- return G("Suspense");
301
+ case b:
302
+ return ae("Suspense");
301
303
  case p:
302
- return G("SuspenseList");
304
+ return ae("SuspenseList");
303
305
  }
304
306
  if (typeof e == "object")
305
307
  switch (e.$$typeof) {
306
308
  case u:
307
- return Qe(e.render);
309
+ return st(e.render);
308
310
  case E:
309
- return X(e.type, r, a);
310
- case R: {
311
- var c = e, g = c._payload, x = c._init;
311
+ return ie(e.type, s, o);
312
+ case m: {
313
+ var d = e, k = d._payload, C = d._init;
312
314
  try {
313
- return X(x(g), r, a);
315
+ return ie(C(k), s, o);
314
316
  } catch {
315
317
  }
316
318
  }
317
319
  }
318
320
  return "";
319
321
  }
320
- var H = Object.prototype.hasOwnProperty, we = {}, ke = O.ReactDebugCurrentFrame;
321
- function Q(e) {
322
+ var ee = Object.prototype.hasOwnProperty, Oe = {}, Me = T.ReactDebugCurrentFrame;
323
+ function le(e) {
322
324
  if (e) {
323
- var r = e._owner, a = X(e.type, e._source, r ? r.type : null);
324
- ke.setExtraStackFrame(a);
325
+ var s = e._owner, o = ie(e.type, e._source, s ? s.type : null);
326
+ Me.setExtraStackFrame(o);
325
327
  } else
326
- ke.setExtraStackFrame(null);
328
+ Me.setExtraStackFrame(null);
327
329
  }
328
- function tt(e, r, a, c, g) {
330
+ function at(e, s, o, d, k) {
329
331
  {
330
- var x = Function.call.bind(H);
331
- for (var m in e)
332
- if (x(e, m)) {
333
- var f = void 0;
332
+ var C = Function.call.bind(ee);
333
+ for (var x in e)
334
+ if (C(e, x)) {
335
+ var v = void 0;
334
336
  try {
335
- if (typeof e[m] != "function") {
336
- var _ = Error((c || "React class") + ": " + a + " type `" + m + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[m] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
337
- throw _.name = "Invariant Violation", _;
337
+ if (typeof e[x] != "function") {
338
+ var L = Error((d || "React class") + ": " + o + " type `" + x + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[x] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
339
+ throw L.name = "Invariant Violation", L;
338
340
  }
339
- f = e[m](r, m, c, a, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
340
- } catch (k) {
341
- f = k;
341
+ v = e[x](s, x, d, o, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
342
+ } catch (N) {
343
+ v = N;
342
344
  }
343
- f && !(f instanceof Error) && (Q(g), o("%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).", c || "React class", a, m, typeof f), Q(null)), f instanceof Error && !(f.message in we) && (we[f.message] = !0, Q(g), o("Failed %s type: %s", a, f.message), Q(null));
345
+ v && !(v instanceof Error) && (le(k), j("%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).", d || "React class", o, x, typeof v), le(null)), v instanceof Error && !(v.message in Oe) && (Oe[v.message] = !0, le(k), j("Failed %s type: %s", o, v.message), le(null));
344
346
  }
345
347
  }
346
348
  }
347
- var rt = Array.isArray;
348
- function ae(e) {
349
- return rt(e);
349
+ var ot = Array.isArray;
350
+ function me(e) {
351
+ return ot(e);
350
352
  }
351
- function nt(e) {
353
+ function it(e) {
352
354
  {
353
- var r = typeof Symbol == "function" && Symbol.toStringTag, a = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
354
- return a;
355
+ var s = typeof Symbol == "function" && Symbol.toStringTag, o = s && e[Symbol.toStringTag] || e.constructor.name || "Object";
356
+ return o;
355
357
  }
356
358
  }
357
- function at(e) {
359
+ function lt(e) {
358
360
  try {
359
- return Ce(e), !1;
361
+ return De(e), !1;
360
362
  } catch {
361
363
  return !0;
362
364
  }
363
365
  }
364
- function Ce(e) {
366
+ function De(e) {
365
367
  return "" + e;
366
368
  }
367
- function Ee(e) {
368
- if (at(e))
369
- return o("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", nt(e)), Ce(e);
369
+ function Ie(e) {
370
+ if (lt(e))
371
+ return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", it(e)), De(e);
370
372
  }
371
- var Re = O.ReactCurrentOwner, st = {
373
+ var Fe = T.ReactCurrentOwner, ct = {
372
374
  key: !0,
373
375
  ref: !0,
374
376
  __self: !0,
375
377
  __source: !0
376
- }, Se, _e;
377
- function ot(e) {
378
- if (H.call(e, "ref")) {
379
- var r = Object.getOwnPropertyDescriptor(e, "ref").get;
380
- if (r && r.isReactWarning)
378
+ }, Le, Pe;
379
+ function ut(e) {
380
+ if (ee.call(e, "ref")) {
381
+ var s = Object.getOwnPropertyDescriptor(e, "ref").get;
382
+ if (s && s.isReactWarning)
381
383
  return !1;
382
384
  }
383
385
  return e.ref !== void 0;
384
386
  }
385
- function it(e) {
386
- if (H.call(e, "key")) {
387
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
388
- if (r && r.isReactWarning)
387
+ function dt(e) {
388
+ if (ee.call(e, "key")) {
389
+ var s = Object.getOwnPropertyDescriptor(e, "key").get;
390
+ if (s && s.isReactWarning)
389
391
  return !1;
390
392
  }
391
393
  return e.key !== void 0;
392
394
  }
393
- function lt(e, r) {
394
- typeof e.ref == "string" && Re.current;
395
+ function ft(e, s) {
396
+ typeof e.ref == "string" && Fe.current;
395
397
  }
396
- function ct(e, r) {
398
+ function ht(e, s) {
397
399
  {
398
- var a = function() {
399
- Se || (Se = !0, o("%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));
400
+ var o = function() {
401
+ Le || (Le = !0, j("%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)", s));
400
402
  };
401
- a.isReactWarning = !0, Object.defineProperty(e, "key", {
402
- get: a,
403
+ o.isReactWarning = !0, Object.defineProperty(e, "key", {
404
+ get: o,
403
405
  configurable: !0
404
406
  });
405
407
  }
406
408
  }
407
- function ut(e, r) {
409
+ function mt(e, s) {
408
410
  {
409
- var a = function() {
410
- _e || (_e = !0, o("%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));
411
+ var o = function() {
412
+ Pe || (Pe = !0, j("%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)", s));
411
413
  };
412
- a.isReactWarning = !0, Object.defineProperty(e, "ref", {
413
- get: a,
414
+ o.isReactWarning = !0, Object.defineProperty(e, "ref", {
415
+ get: o,
414
416
  configurable: !0
415
417
  });
416
418
  }
417
419
  }
418
- var ft = function(e, r, a, c, g, x, m) {
419
- var f = {
420
+ var gt = function(e, s, o, d, k, C, x) {
421
+ var v = {
420
422
  // This tag allows us to uniquely identify this as a React Element
421
- $$typeof: s,
423
+ $$typeof: r,
422
424
  // Built-in properties that belong on the element
423
425
  type: e,
424
- key: r,
425
- ref: a,
426
- props: m,
426
+ key: s,
427
+ ref: o,
428
+ props: x,
427
429
  // Record the component responsible for creating this element.
428
- _owner: x
430
+ _owner: C
429
431
  };
430
- return f._store = {}, Object.defineProperty(f._store, "validated", {
432
+ return v._store = {}, Object.defineProperty(v._store, "validated", {
431
433
  configurable: !1,
432
434
  enumerable: !1,
433
435
  writable: !0,
434
436
  value: !1
435
- }), Object.defineProperty(f, "_self", {
437
+ }), Object.defineProperty(v, "_self", {
436
438
  configurable: !1,
437
439
  enumerable: !1,
438
440
  writable: !1,
439
- value: c
440
- }), Object.defineProperty(f, "_source", {
441
+ value: d
442
+ }), Object.defineProperty(v, "_source", {
441
443
  configurable: !1,
442
444
  enumerable: !1,
443
445
  writable: !1,
444
- value: g
445
- }), Object.freeze && (Object.freeze(f.props), Object.freeze(f)), f;
446
+ value: k
447
+ }), Object.freeze && (Object.freeze(v.props), Object.freeze(v)), v;
446
448
  };
447
- function dt(e, r, a, c, g) {
449
+ function pt(e, s, o, d, k) {
448
450
  {
449
- var x, m = {}, f = null, _ = null;
450
- a !== void 0 && (Ee(a), f = "" + a), it(r) && (Ee(r.key), f = "" + r.key), ot(r) && (_ = r.ref, lt(r, g));
451
- for (x in r)
452
- H.call(r, x) && !st.hasOwnProperty(x) && (m[x] = r[x]);
451
+ var C, x = {}, v = null, L = null;
452
+ o !== void 0 && (Ie(o), v = "" + o), dt(s) && (Ie(s.key), v = "" + s.key), ut(s) && (L = s.ref, ft(s, k));
453
+ for (C in s)
454
+ ee.call(s, C) && !ct.hasOwnProperty(C) && (x[C] = s[C]);
453
455
  if (e && e.defaultProps) {
454
- var k = e.defaultProps;
455
- for (x in k)
456
- m[x] === void 0 && (m[x] = k[x]);
456
+ var N = e.defaultProps;
457
+ for (C in N)
458
+ x[C] === void 0 && (x[C] = N[C]);
457
459
  }
458
- if (f || _) {
459
- var C = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
460
- f && ct(m, C), _ && ut(m, C);
460
+ if (v || L) {
461
+ var O = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
462
+ v && ht(x, O), L && mt(x, O);
461
463
  }
462
- return ft(e, f, _, g, c, Re.current, m);
464
+ return gt(e, v, L, k, d, Fe.current, x);
463
465
  }
464
466
  }
465
- var se = O.ReactCurrentOwner, Ne = O.ReactDebugCurrentFrame;
466
- function V(e) {
467
+ var ge = T.ReactCurrentOwner, Ae = T.ReactDebugCurrentFrame;
468
+ function U(e) {
467
469
  if (e) {
468
- var r = e._owner, a = X(e.type, e._source, r ? r.type : null);
469
- Ne.setExtraStackFrame(a);
470
+ var s = e._owner, o = ie(e.type, e._source, s ? s.type : null);
471
+ Ae.setExtraStackFrame(o);
470
472
  } else
471
- Ne.setExtraStackFrame(null);
473
+ Ae.setExtraStackFrame(null);
472
474
  }
473
- var oe;
474
- oe = !1;
475
- function ie(e) {
476
- return typeof e == "object" && e !== null && e.$$typeof === s;
475
+ var pe;
476
+ pe = !1;
477
+ function ve(e) {
478
+ return typeof e == "object" && e !== null && e.$$typeof === r;
477
479
  }
478
- function Te() {
480
+ function qe() {
479
481
  {
480
- if (se.current) {
481
- var e = I(se.current.type);
482
+ if (ge.current) {
483
+ var e = F(ge.current.type);
482
484
  if (e)
483
485
  return `
484
486
 
@@ -487,288 +489,380 @@ Check the render method of \`` + e + "`.";
487
489
  return "";
488
490
  }
489
491
  }
490
- function ht(e) {
492
+ function vt(e) {
491
493
  return "";
492
494
  }
493
- var Oe = {};
494
- function mt(e) {
495
+ var $e = {};
496
+ function yt(e) {
495
497
  {
496
- var r = Te();
497
- if (!r) {
498
- var a = typeof e == "string" ? e : e.displayName || e.name;
499
- a && (r = `
498
+ var s = qe();
499
+ if (!s) {
500
+ var o = typeof e == "string" ? e : e.displayName || e.name;
501
+ o && (s = `
500
502
 
501
- Check the top-level render call using <` + a + ">.");
503
+ Check the top-level render call using <` + o + ">.");
502
504
  }
503
- return r;
505
+ return s;
504
506
  }
505
507
  }
506
- function De(e, r) {
508
+ function We(e, s) {
507
509
  {
508
510
  if (!e._store || e._store.validated || e.key != null)
509
511
  return;
510
512
  e._store.validated = !0;
511
- var a = mt(r);
512
- if (Oe[a])
513
+ var o = yt(s);
514
+ if ($e[o])
513
515
  return;
514
- Oe[a] = !0;
515
- var c = "";
516
- e && e._owner && e._owner !== se.current && (c = " It was passed a child from " + I(e._owner.type) + "."), V(e), o('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', a, c), V(null);
516
+ $e[o] = !0;
517
+ var d = "";
518
+ e && e._owner && e._owner !== ge.current && (d = " It was passed a child from " + F(e._owner.type) + "."), U(e), j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', o, d), U(null);
517
519
  }
518
520
  }
519
- function Pe(e, r) {
521
+ function Be(e, s) {
520
522
  {
521
523
  if (typeof e != "object")
522
524
  return;
523
- if (ae(e))
524
- for (var a = 0; a < e.length; a++) {
525
- var c = e[a];
526
- ie(c) && De(c, r);
525
+ if (me(e))
526
+ for (var o = 0; o < e.length; o++) {
527
+ var d = e[o];
528
+ ve(d) && We(d, s);
527
529
  }
528
- else if (ie(e))
530
+ else if (ve(e))
529
531
  e._store && (e._store.validated = !0);
530
532
  else if (e) {
531
- var g = j(e);
532
- if (typeof g == "function" && g !== e.entries)
533
- for (var x = g.call(e), m; !(m = x.next()).done; )
534
- ie(m.value) && De(m.value, r);
533
+ var k = R(e);
534
+ if (typeof k == "function" && k !== e.entries)
535
+ for (var C = k.call(e), x; !(x = C.next()).done; )
536
+ ve(x.value) && We(x.value, s);
535
537
  }
536
538
  }
537
539
  }
538
- function vt(e) {
540
+ function xt(e) {
539
541
  {
540
- var r = e.type;
541
- if (r == null || typeof r == "string")
542
+ var s = e.type;
543
+ if (s == null || typeof s == "string")
542
544
  return;
543
- var a;
544
- if (typeof r == "function")
545
- a = r.propTypes;
546
- else if (typeof r == "object" && (r.$$typeof === u || // Note: Memo only checks outer props here.
545
+ var o;
546
+ if (typeof s == "function")
547
+ o = s.propTypes;
548
+ else if (typeof s == "object" && (s.$$typeof === u || // Note: Memo only checks outer props here.
547
549
  // Inner props are checked in the reconciler.
548
- r.$$typeof === E))
549
- a = r.propTypes;
550
+ s.$$typeof === E))
551
+ o = s.propTypes;
550
552
  else
551
553
  return;
552
- if (a) {
553
- var c = I(r);
554
- tt(a, e.props, "prop", c, e);
555
- } else if (r.PropTypes !== void 0 && !oe) {
556
- oe = !0;
557
- var g = I(r);
558
- o("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", g || "Unknown");
554
+ if (o) {
555
+ var d = F(s);
556
+ at(o, e.props, "prop", d, e);
557
+ } else if (s.PropTypes !== void 0 && !pe) {
558
+ pe = !0;
559
+ var k = F(s);
560
+ j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", k || "Unknown");
559
561
  }
560
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && o("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
562
+ typeof s.getDefaultProps == "function" && !s.getDefaultProps.isReactClassApproved && j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
561
563
  }
562
564
  }
563
- function pt(e) {
565
+ function bt(e) {
564
566
  {
565
- for (var r = Object.keys(e.props), a = 0; a < r.length; a++) {
566
- var c = r[a];
567
- if (c !== "children" && c !== "key") {
568
- V(e), o("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", c), V(null);
567
+ for (var s = Object.keys(e.props), o = 0; o < s.length; o++) {
568
+ var d = s[o];
569
+ if (d !== "children" && d !== "key") {
570
+ U(e), j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", d), U(null);
569
571
  break;
570
572
  }
571
573
  }
572
- e.ref !== null && (V(e), o("Invalid attribute `ref` supplied to `React.Fragment`."), V(null));
574
+ e.ref !== null && (U(e), j("Invalid attribute `ref` supplied to `React.Fragment`."), U(null));
573
575
  }
574
576
  }
575
- var Fe = {};
576
- function Ae(e, r, a, c, g, x) {
577
+ var ze = {};
578
+ function Ve(e, s, o, d, k, C) {
577
579
  {
578
- var m = Je(e);
579
- if (!m) {
580
- var f = "";
581
- (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (f += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
582
- var _ = ht();
583
- _ ? f += _ : f += Te();
584
- var k;
585
- e === null ? k = "null" : ae(e) ? k = "array" : e !== void 0 && e.$$typeof === s ? (k = "<" + (I(e.type) || "Unknown") + " />", f = " Did you accidentally export a JSX literal instead of a component?") : k = typeof e, o("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", k, f);
580
+ var x = M(e);
581
+ if (!x) {
582
+ var v = "";
583
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (v += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
584
+ var L = vt();
585
+ L ? v += L : v += qe();
586
+ var N;
587
+ e === null ? N = "null" : me(e) ? N = "array" : e !== void 0 && e.$$typeof === r ? (N = "<" + (F(e.type) || "Unknown") + " />", v = " Did you accidentally export a JSX literal instead of a component?") : N = typeof e, j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", N, v);
586
588
  }
587
- var C = dt(e, r, a, g, x);
588
- if (C == null)
589
- return C;
590
- if (m) {
591
- var D = r.children;
592
- if (D !== void 0)
593
- if (c)
594
- if (ae(D)) {
595
- for (var B = 0; B < D.length; B++)
596
- Pe(D[B], e);
597
- Object.freeze && Object.freeze(D);
589
+ var O = pt(e, s, o, k, C);
590
+ if (O == null)
591
+ return O;
592
+ if (x) {
593
+ var A = s.children;
594
+ if (A !== void 0)
595
+ if (d)
596
+ if (me(A)) {
597
+ for (var K = 0; K < A.length; K++)
598
+ Be(A[K], e);
599
+ Object.freeze && Object.freeze(A);
598
600
  } else
599
- o("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
601
+ j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
600
602
  else
601
- Pe(D, e);
603
+ Be(A, e);
602
604
  }
603
- if (H.call(r, "key")) {
604
- var W = I(e), N = Object.keys(r).filter(function(wt) {
605
- return wt !== "key";
606
- }), le = N.length > 0 ? "{key: someKey, " + N.join(": ..., ") + ": ...}" : "{key: someKey}";
607
- if (!Fe[W + le]) {
608
- var jt = N.length > 0 ? "{" + N.join(": ..., ") + ": ...}" : "{}";
609
- o(`A props object containing a "key" prop is being spread into JSX:
605
+ if (ee.call(s, "key")) {
606
+ var H = F(e), P = Object.keys(s).filter(function(Rt) {
607
+ return Rt !== "key";
608
+ }), ye = P.length > 0 ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}";
609
+ if (!ze[H + ye]) {
610
+ var Et = P.length > 0 ? "{" + P.join(": ..., ") + ": ...}" : "{}";
611
+ j(`A props object containing a "key" prop is being spread into JSX:
610
612
  let props = %s;
611
613
  <%s {...props} />
612
614
  React keys must be passed directly to JSX without using spread:
613
615
  let props = %s;
614
- <%s key={someKey} {...props} />`, le, W, jt, W), Fe[W + le] = !0;
616
+ <%s key={someKey} {...props} />`, ye, H, Et, H), ze[H + ye] = !0;
615
617
  }
616
618
  }
617
- return e === i ? pt(C) : vt(C), C;
619
+ return e === i ? bt(O) : xt(O), O;
618
620
  }
619
621
  }
620
- function gt(e, r, a) {
621
- return Ae(e, r, a, !0);
622
+ function jt(e, s, o) {
623
+ return Ve(e, s, o, !0);
622
624
  }
623
- function xt(e, r, a) {
624
- return Ae(e, r, a, !1);
625
+ function kt(e, s, o) {
626
+ return Ve(e, s, o, !1);
625
627
  }
626
- var yt = xt, bt = gt;
627
- K.Fragment = i, K.jsx = yt, K.jsxs = bt;
628
- }()), K;
628
+ var wt = kt, Ct = jt;
629
+ re.Fragment = i, re.jsx = wt, re.jsxs = Ct;
630
+ }()), re;
629
631
  }
630
- process.env.NODE_ENV === "production" ? ue.exports = _t() : ue.exports = Nt();
631
- var t = ue.exports;
632
- class Tt {
633
- constructor(s) {
634
- F(this, "config");
635
- F(this, "baseUrl");
636
- this.config = s, this.baseUrl = s.baseUrl || "http://localhost:8000";
632
+ process.env.NODE_ENV === "production" ? je.exports = Dt() : je.exports = It();
633
+ var t = je.exports;
634
+ class Ft {
635
+ constructor(r) {
636
+ q(this, "config");
637
+ q(this, "baseUrl");
638
+ q(this, "abortControllers", {});
639
+ this.config = r, this.baseUrl = r.baseUrl || "https://api.lulichat.com";
637
640
  }
638
- async getCompanyInfo() {
639
- try {
640
- const s = await fetch(`${this.baseUrl}/companies/e/info`, {
641
- headers: {
642
- Authorization: `Bearer ${this.config.apiKey}`,
643
- "Content-Type": "application/json"
644
- }
645
- });
646
- if (!s.ok)
647
- throw new Error(`HTTP error! status: ${s.status}`);
648
- return await s.json();
649
- } catch (s) {
650
- throw console.error("Failed to fetch company info:", s), s;
651
- }
641
+ abort(r) {
642
+ var a;
643
+ (a = this.abortControllers[r]) == null || a.abort();
652
644
  }
653
- async submitContactInfo(s) {
645
+ useRequest() {
646
+ const [r, a] = g.useState(!1), [i, l] = g.useState("");
647
+ let c;
648
+ return { loading: r, error: i, getOptions: async (f) => {
649
+ try {
650
+ c && this.abort(c), c = (Math.random() * 9999999999).toString(16), a(!0);
651
+ const u = await this.getOptions(f, c);
652
+ return a(!1), u;
653
+ } catch (u) {
654
+ l(u.message || "Error getting options");
655
+ } finally {
656
+ }
657
+ }, setLoading: a };
658
+ }
659
+ async request(r, a = {}) {
660
+ const { body: i, headers: l, key: c } = a;
654
661
  try {
655
- const l = await fetch(`${this.baseUrl}/companies/e/chat/init`, {
656
- method: "POST",
662
+ const h = new AbortController();
663
+ c && (this.abortControllers[c] = h);
664
+ const f = await fetch(`${this.baseUrl}${r}`, {
665
+ body: i ? JSON.stringify(i) : void 0,
666
+ method: i ? "POST" : "GET",
657
667
  headers: {
658
668
  Authorization: `Bearer ${this.config.apiKey}`,
659
- "Content-Type": "application/json"
669
+ "Content-Type": "application/json",
670
+ ...l
660
671
  },
661
- body: JSON.stringify(s || {})
672
+ signal: h.signal
662
673
  });
663
- if (!l.ok)
664
- throw new Error(`HTTP error! status: ${l.status}`);
665
- return await l.json();
666
- } catch (l) {
667
- throw console.error("Failed to submit contact info:", l), l;
674
+ if (!f.ok)
675
+ throw new Error(`HTTP error! status: ${f.status}`);
676
+ return await f.json();
677
+ } catch (h) {
678
+ throw console.error("Failed to fetch company info:", h), h;
668
679
  }
669
680
  }
670
- async startAnonymousChat() {
671
- return this.submitContactInfo();
681
+ async getCompanyInfo() {
682
+ return this.request("/companies/e/info");
683
+ }
684
+ async getOptions(r, a) {
685
+ const i = Object.keys(r).reduce((l, c) => (l.push(`${c}=${r[c]}`), l), []).join("&");
686
+ return this.request("/queue-options/external?" + i, { key: a });
687
+ }
688
+ async submitContactInfo(r, a) {
689
+ return this.request("/help/create-ticket/external", {
690
+ body: r,
691
+ key: a
692
+ });
693
+ }
694
+ async getTicketMessages(r, a = 1) {
695
+ return this.request(`/messages/${r}/external?pageNumber=${a}`);
696
+ }
697
+ async getSession(r) {
698
+ return this.request(`/help/${r}/session`);
672
699
  }
673
700
  }
674
- function Le(...n) {
675
- return St(n);
701
+ function se(...n) {
702
+ return n.filter(Boolean).map((r) => r == null ? void 0 : r.toString().trim()).join(" ");
676
703
  }
677
- const ee = S.forwardRef(
678
- (n, s) => /* @__PURE__ */ t.jsx(
704
+ function Ke(n = 32) {
705
+ return Array.from(crypto.getRandomValues(new Uint8Array(n))).map((r) => r.toString(36)).join("").slice(0, n);
706
+ }
707
+ function Lt(n, r) {
708
+ const a = /* @__PURE__ */ new Set(), i = [];
709
+ for (const l of n) {
710
+ const c = r(l);
711
+ a.has(c) || (a.add(c), i.push(l));
712
+ }
713
+ return i;
714
+ }
715
+ const ce = g.forwardRef(
716
+ (n, r) => /* @__PURE__ */ t.jsx(
679
717
  "input",
680
718
  {
681
719
  ...n,
682
720
  autoComplete: n.autoComplete || n.name || "off",
683
- ref: s,
684
- className: Le("lulichat-input", n.className)
721
+ ref: r,
722
+ className: se("lulichat-input", n.className)
685
723
  }
686
724
  )
687
725
  );
688
- S.forwardRef(
689
- (n, s) => /* @__PURE__ */ t.jsx("input", { className: "", ...n, ref: s })
726
+ g.forwardRef(
727
+ (n, r) => /* @__PURE__ */ t.jsx("input", { className: "", ...n, ref: r })
690
728
  );
691
- const We = S.createContext(
729
+ const Ge = g.createContext(
692
730
  void 0
693
- ), Y = S.forwardRef(
694
- ({ children: n, onValuesChange: s, initialValues: l, ...i }, v) => {
695
- const d = U(l || {}), y = U(null), b = $e(
696
- (h, p) => {
697
- d.current[h] = p, s && s({ ...d.current });
731
+ ), G = g.forwardRef(
732
+ ({ children: n, onValuesChange: r, initialValues: a, ...i }, l) => {
733
+ const c = J(a || {}), h = J(null), f = Ue(
734
+ (b, p) => {
735
+ c.current[b] = p, r && r({ ...c.current });
698
736
  },
699
- [s]
737
+ [r]
700
738
  ), u = {
701
- getValues: () => d.current,
702
- getFieldValue: (h) => {
739
+ getValues: () => c.current,
740
+ getFieldValue: (b) => {
703
741
  var p;
704
- return (p = d.current) == null ? void 0 : p[h];
742
+ return (p = c.current) == null ? void 0 : p[b];
705
743
  },
706
- elementRef: () => y.current,
707
- setFieldValue: b
744
+ elementRef: () => h.current,
745
+ setFieldValue: f
708
746
  };
709
- return Et(v, () => u), /* @__PURE__ */ t.jsx(We.Provider, { value: u, children: /* @__PURE__ */ t.jsx("form", { ...i, ref: y, onSubmit: i.onSubmit, children: n }) });
747
+ return Tt(l, () => u), /* @__PURE__ */ t.jsx(Ge.Provider, { value: u, children: /* @__PURE__ */ t.jsx("form", { ...i, ref: h, onSubmit: i.onSubmit, children: n }) });
710
748
  }
711
- ), Ot = S.forwardRef(
712
- ({ name: n, children: s, ...l }, i) => {
713
- const v = S.useContext(We), d = function(u) {
714
- var h, p;
715
- v && n && v.setFieldValue(n, u.target.value), (p = (h = this.props).onChange) == null || p.call(h, u);
716
- }, y = S.Children.map(s, (u) => {
717
- if (S.isValidElement(u) && n && u.type === ee) {
718
- let h = u;
719
- return S.cloneElement(h, {
720
- ...h.props,
749
+ ), Pt = g.forwardRef(
750
+ ({ name: n, children: r, ...a }, i) => {
751
+ const l = g.useContext(Ge), c = function(u) {
752
+ var b, p;
753
+ l && n && l.setFieldValue(n, u.target.value), (p = (b = this.props).onChange) == null || p.call(b, u);
754
+ }, h = g.Children.map(r, (u) => {
755
+ if (g.isValidElement(u) && n && u.type === ce) {
756
+ let b = u;
757
+ return g.cloneElement(b, {
758
+ ...b.props,
721
759
  name: n,
722
- value: (v == null ? void 0 : v.getFieldValue(n)) ?? "",
723
- onChange: d.bind(h),
724
- required: l.required
760
+ value: (l == null ? void 0 : l.getFieldValue(n)) ?? "",
761
+ onChange: c.bind(b),
762
+ required: a.required
725
763
  });
726
764
  }
727
765
  return u;
728
- }), b = Object.create(l);
729
- return delete b.required, delete b.label, /* @__PURE__ */ t.jsxs("div", { className: "lulichat-form-item", ref: i, ...b, children: [
730
- l.label && /* @__PURE__ */ t.jsx(ze, { htmlFor: n, required: l.required, children: l.label }),
731
- y,
732
- l.error && /* @__PURE__ */ t.jsx("p", { className: "error", children: l.error })
766
+ }), f = Object.create(a);
767
+ return delete f.required, delete f.label, /* @__PURE__ */ t.jsxs("div", { className: "lulichat-form-item", ref: i, ...f, children: [
768
+ a.label && /* @__PURE__ */ t.jsx(Je, { htmlFor: n, required: a.required, children: a.label }),
769
+ h,
770
+ a.error && /* @__PURE__ */ t.jsx("p", { className: "error", children: a.error })
733
771
  ] });
734
772
  }
735
- ), ze = S.forwardRef(
736
- (n, s) => {
737
- const l = n.required, i = n.children;
773
+ ), Je = g.forwardRef(
774
+ (n, r) => {
775
+ const a = n.required, i = n.children;
738
776
  return /* @__PURE__ */ t.jsxs(
739
777
  "label",
740
778
  {
741
779
  ...n,
742
- className: Le("lulichat-form-label", n.className),
743
- ref: s,
780
+ className: se("lulichat-form-label", n.className),
781
+ ref: r,
744
782
  children: [
745
783
  i,
746
- l && /* @__PURE__ */ t.jsx("b", { style: { color: "red" }, children: "*" })
784
+ a && /* @__PURE__ */ t.jsx("b", { style: { color: "red" }, children: "*" })
747
785
  ]
748
786
  }
749
787
  );
750
788
  }
751
- ), Dt = (n) => {
752
- const s = U(n || {}), l = U(null), i = $e(
753
- (d, y) => {
754
- s.current[d] = y;
789
+ ), At = (n) => {
790
+ const r = J(n || {}), a = J(null), i = Ue(
791
+ (c, h) => {
792
+ r.current[c] = h;
755
793
  },
756
794
  []
757
795
  );
758
796
  return [{
759
- getValues: () => s.current,
760
- getFieldValue: (d) => {
761
- var y;
762
- return (y = s.current) == null ? void 0 : y[d];
797
+ getValues: () => r.current,
798
+ getFieldValue: (c) => {
799
+ var h;
800
+ return (h = r.current) == null ? void 0 : h[c];
763
801
  },
764
- elementRef: () => l.current,
802
+ elementRef: () => a.current,
765
803
  setFieldValue: i
766
804
  }];
767
805
  };
768
- Y.Item = Ot;
769
- Y.Label = ze;
770
- Y.useForm = Dt;
771
- const Pt = (n) => /* @__PURE__ */ t.jsx(
806
+ G.Item = Pt;
807
+ G.Label = Je;
808
+ G.useForm = At;
809
+ const qt = (n) => /* @__PURE__ */ t.jsx(
810
+ "svg",
811
+ {
812
+ xmlns: "http://www.w3.org/2000/svg",
813
+ width: "48",
814
+ height: "48",
815
+ viewBox: "0 0 24 24",
816
+ ...n,
817
+ children: /* @__PURE__ */ t.jsxs(
818
+ "g",
819
+ {
820
+ fill: "none",
821
+ stroke: "currentColor",
822
+ strokeLinecap: "round",
823
+ strokeLinejoin: "round",
824
+ strokeWidth: "2",
825
+ children: [
826
+ /* @__PURE__ */ t.jsx(
827
+ "path",
828
+ {
829
+ strokeDasharray: "14",
830
+ strokeDashoffset: "14",
831
+ d: "M15 7h-11.5M9 17h11.5",
832
+ children: /* @__PURE__ */ t.jsx(
833
+ "animate",
834
+ {
835
+ fill: "freeze",
836
+ attributeName: "stroke-dashoffset",
837
+ dur: "0.3s",
838
+ values: "14;0"
839
+ }
840
+ )
841
+ }
842
+ ),
843
+ /* @__PURE__ */ t.jsx(
844
+ "path",
845
+ {
846
+ strokeDasharray: "8",
847
+ strokeDashoffset: "8",
848
+ d: "M3 7l4 4M3 7l4 -4M21 17l-4 4M21 17l-4 -4",
849
+ children: /* @__PURE__ */ t.jsx(
850
+ "animate",
851
+ {
852
+ fill: "freeze",
853
+ attributeName: "stroke-dashoffset",
854
+ begin: "0.3s",
855
+ dur: "0.2s",
856
+ values: "8;0"
857
+ }
858
+ )
859
+ }
860
+ )
861
+ ]
862
+ }
863
+ )
864
+ }
865
+ ), $t = (n) => /* @__PURE__ */ t.jsx(
772
866
  "svg",
773
867
  {
774
868
  xmlns: "http://www.w3.org/2000/svg",
@@ -799,7 +893,7 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
799
893
  }
800
894
  )
801
895
  }
802
- ), Ft = (n) => /* @__PURE__ */ t.jsxs(
896
+ ), Wt = (n) => /* @__PURE__ */ t.jsxs(
803
897
  "svg",
804
898
  {
805
899
  xmlns: "http://www.w3.org/2000/svg",
@@ -902,39 +996,52 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
902
996
  )
903
997
  ]
904
998
  }
905
- ), At = (n) => /* @__PURE__ */ t.jsx(
999
+ ), Ze = (n) => /* @__PURE__ */ t.jsx(
906
1000
  "svg",
907
1001
  {
908
1002
  xmlns: "http://www.w3.org/2000/svg",
909
1003
  width: "48",
910
1004
  height: "48",
911
- viewBox: "0 0 22 22",
1005
+ viewBox: "0 0 24 24",
912
1006
  ...n,
913
1007
  children: /* @__PURE__ */ t.jsx(
914
1008
  "path",
915
1009
  {
916
- fill: "currentColor",
917
- d: "M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"
1010
+ fill: "none",
1011
+ stroke: "currentColor",
1012
+ strokeLinecap: "round",
1013
+ strokeLinejoin: "round",
1014
+ strokeWidth: "2",
1015
+ d: "M5 5L12 5L19 5M5 12H19M5 19L12 19L19 19",
1016
+ children: /* @__PURE__ */ t.jsx(
1017
+ "animate",
1018
+ {
1019
+ fill: "freeze",
1020
+ attributeName: "d",
1021
+ dur: "0.4s",
1022
+ values: "M5 5L12 5L19 5M5 12H19M5 19L12 19L19 19;M5 5L12 12L19 5M12 12H12M5 19L12 12L19 19"
1023
+ }
1024
+ )
918
1025
  }
919
1026
  )
920
1027
  }
921
- ), Mt = (n) => /* @__PURE__ */ t.jsx(
1028
+ ), Bt = (n) => /* @__PURE__ */ t.jsx(
922
1029
  "svg",
923
1030
  {
924
1031
  xmlns: "http://www.w3.org/2000/svg",
925
- width: "24",
926
- height: "24",
927
- viewBox: "0 0 24 24",
1032
+ width: "48",
1033
+ height: "48",
1034
+ viewBox: "0 0 22 22",
928
1035
  ...n,
929
1036
  children: /* @__PURE__ */ t.jsx(
930
1037
  "path",
931
1038
  {
932
1039
  fill: "currentColor",
933
- d: "M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"
1040
+ d: "M1.5 4v1.5c0 4.15 2.21 7.78 5.5 9.8V20h15v-2c0-2.66-5.33-4-8-4h-.25C9 14 5 10 5 5.5V4m9 0a4 4 0 0 0-4 4a4 4 0 0 0 4 4a4 4 0 0 0 4-4a4 4 0 0 0-4-4"
934
1041
  }
935
1042
  )
936
1043
  }
937
- ), It = (n) => /* @__PURE__ */ t.jsx(
1044
+ ), zt = (n) => /* @__PURE__ */ t.jsx(
938
1045
  "svg",
939
1046
  {
940
1047
  xmlns: "http://www.w3.org/2000/svg",
@@ -942,41 +1049,15 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
942
1049
  height: "24",
943
1050
  viewBox: "0 0 24 24",
944
1051
  ...n,
945
- children: /* @__PURE__ */ t.jsxs(
946
- "g",
1052
+ children: /* @__PURE__ */ t.jsx(
1053
+ "path",
947
1054
  {
948
- fill: "none",
949
- stroke: "currentColor",
950
- strokeDasharray: "28",
951
- strokeDashoffset: "28",
952
- strokeLinecap: "round",
953
- strokeLinejoin: "round",
954
- strokeWidth: "2",
955
- children: [
956
- /* @__PURE__ */ t.jsx("path", { d: "M4 21v-1c0 -3.31 2.69 -6 6 -6h4c3.31 0 6 2.69 6 6v1", children: /* @__PURE__ */ t.jsx(
957
- "animate",
958
- {
959
- fill: "freeze",
960
- attributeName: "stroke-dashoffset",
961
- dur: "0.4s",
962
- values: "28;0"
963
- }
964
- ) }),
965
- /* @__PURE__ */ t.jsx("path", { d: "M12 11c-2.21 0 -4 -1.79 -4 -4c0 -2.21 1.79 -4 4 -4c2.21 0 4 1.79 4 4c0 2.21 -1.79 4 -4 4Z", children: /* @__PURE__ */ t.jsx(
966
- "animate",
967
- {
968
- fill: "freeze",
969
- attributeName: "stroke-dashoffset",
970
- begin: "0.4s",
971
- dur: "0.4s",
972
- values: "28;0"
973
- }
974
- ) })
975
- ]
1055
+ fill: "currentColor",
1056
+ d: "M12 2.25A9.75 9.75 0 0 0 2.25 12v5q0 .04.004.08v.05c-.003 1.278.602 2.682 1.963 3.25l.071.03c.11.044.22.12.362.25c.07.064.138.132.22.213l.008.008c.08.08.175.175.277.265c.204.183.474.388.83.506c.37.122.77.131 1.208.022c.723-.18 1.266-.752 1.469-1.454c.089-.309.089-.668.088-1.084v-4.094c0-.285 0-.528-.01-.728a2.3 2.3 0 0 0-.107-.627c-.23-.683-.786-1.223-1.504-1.377a2.25 2.25 0 0 0-1.264.065c-.37.133-.652.354-.87.558c-.12.11-.269.267-.391.396l-.164.17a1.8 1.8 0 0 1-.427.338q-.136.07-.263.152V12a8.25 8.25 0 1 1 16.5 0v1.864a3 3 0 0 0-.538-.274a1.2 1.2 0 0 1-.362-.25c-.07-.064-.138-.132-.22-.213l-.008-.008a7 7 0 0 0-.277-.265a2.4 2.4 0 0 0-.83-.506q-.553-.184-1.208-.022c-.723.18-1.266.752-1.469 1.454c-.089.309-.088.668-.088 1.085v4.093c0 .285 0 .528.01.728c.012.208.037.418.107.627c.23.683.786 1.223 1.504 1.377c.463.1.883.073 1.264-.065c.37-.133.652-.354.87-.558c.12-.11.269-.267.391-.395c.065-.069.123-.13.164-.17a1.8 1.8 0 0 1 .427-.34c1.11-.573 1.755-1.724 1.758-2.936v-.143L21.75 17v-5A9.75 9.75 0 0 0 12 2.25"
976
1057
  }
977
1058
  )
978
1059
  }
979
- ), Ve = () => /* @__PURE__ */ t.jsx(
1060
+ ), Xe = () => /* @__PURE__ */ t.jsx(
980
1061
  "svg",
981
1062
  {
982
1063
  xmlns: "http://www.w3.org/2000/svg",
@@ -995,7 +1076,7 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
995
1076
  }
996
1077
  )
997
1078
  }
998
- ), Be = (n) => /* @__PURE__ */ t.jsx(
1079
+ ), ue = (n) => /* @__PURE__ */ t.jsx(
999
1080
  "svg",
1000
1081
  {
1001
1082
  xmlns: "http://www.w3.org/2000/svg",
@@ -1063,7 +1144,7 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
1063
1144
  }
1064
1145
  )
1065
1146
  }
1066
- ), $t = (n) => /* @__PURE__ */ t.jsxs(
1147
+ ), Vt = (n) => /* @__PURE__ */ t.jsxs(
1067
1148
  "svg",
1068
1149
  {
1069
1150
  xmlns: "http://www.w3.org/2000/svg",
@@ -1206,441 +1287,451 @@ const Pt = (n) => /* @__PURE__ */ t.jsx(
1206
1287
  )
1207
1288
  ]
1208
1289
  }
1209
- ), z = S.forwardRef(
1290
+ ), Z = g.forwardRef(
1210
1291
  ({
1211
1292
  className: n,
1212
- variant: s = "outline",
1213
- size: l = "md",
1293
+ variant: r = "outline",
1294
+ size: a = "md",
1214
1295
  shape: i = "rounded",
1215
- ...v
1216
- }, d) => /* @__PURE__ */ t.jsx(
1296
+ ...l
1297
+ }, c) => /* @__PURE__ */ t.jsx(
1217
1298
  "button",
1218
1299
  {
1219
- className: Rt(
1300
+ className: se(
1220
1301
  "lulichat-btn",
1221
- `lulichat-btn-${s}`,
1222
- `lulichat-btn-${l}`,
1302
+ `lulichat-btn-${r}`,
1303
+ `lulichat-btn-${a}`,
1223
1304
  `lulichat-btn-${i}`,
1224
1305
  n
1225
1306
  ),
1226
- ref: d,
1227
- ...v
1307
+ ref: c,
1308
+ ...l
1228
1309
  }
1229
1310
  )
1230
1311
  );
1231
- z.displayName = "Button";
1232
- const Lt = ({
1233
- companyName: n,
1234
- onSubmit: s,
1235
- onSkip: l,
1236
- allowAnonymous: i,
1237
- isLoading: v
1238
- }) => {
1239
- const [d, y] = S.useState(!1), [b, u] = P({
1240
- name: "",
1241
- email: "",
1242
- phone: "",
1243
- company: ""
1244
- }), [h, p] = P({}), [E, R] = S.useState({
1245
- email: "",
1246
- name: ""
1247
- }), T = () => {
1248
- const j = {};
1249
- return b.name.trim() || (j.name = "Name is required"), b.email.trim() ? /\S+@\S+\.\S+/.test(b.email) || (j.email = "Email is invalid") : j.email = "Email is required", p(j), Object.keys(j).length === 0;
1250
- }, A = (j) => {
1251
- j.preventDefault(), T() && s(b);
1252
- }, M = (j, O) => {
1253
- u((o) => ({ ...o, [j]: O })), h[j] && p((o) => ({ ...o, [j]: void 0 }));
1254
- };
1255
- return /* @__PURE__ */ t.jsxs(
1256
- Y,
1257
- {
1258
- autoComplete: "off",
1259
- onSubmit: A,
1260
- onValuesChange: R,
1261
- className: "lulichat-contact-form",
1262
- children: [
1263
- /* @__PURE__ */ t.jsxs("div", { className: "lulichat-form-header", children: [
1264
- /* @__PURE__ */ t.jsxs(
1265
- "div",
1266
- {
1267
- style: {
1268
- marginBottom: "20px",
1269
- display: "flex",
1270
- alignItems: "end",
1271
- columnGap: 8
1272
- },
1273
- children: [
1274
- /* @__PURE__ */ t.jsx(
1275
- At,
1276
- {
1277
- style: { display: "block" },
1278
- color: "#DEDEDE6A",
1279
- height: 40,
1280
- width: 50
1281
- }
1282
- ),
1283
- /* @__PURE__ */ t.jsx("h3", { style: { fontWeight: 500 }, children: "Hello," })
1284
- ]
1285
- }
1286
- ),
1287
- /* @__PURE__ */ t.jsxs("h3", { style: { marginBottom: 8 }, className: "lulichat-title", children: [
1288
- "Welcome to ",
1289
- n,
1290
- " Live Chat"
1312
+ Z.displayName = "Button";
1313
+ const Ht = g.forwardRef(
1314
+ (n, r) => {
1315
+ const { companyName: a, isLoading: i, allowAnonymous: l } = n, [c, h] = g.useState(!0), [f, u] = W({
1316
+ name: "",
1317
+ email: ""
1318
+ }), [b, p] = W({}), [E, m] = g.useState(!1), _ = () => {
1319
+ var T, j;
1320
+ const R = {};
1321
+ return !l && !((T = f.name) != null && T.trim()) && (R.name = "Name is required"), l || ((j = f.email) != null && j.trim() ? /\S+@\S+\.\S+/.test(f.email) || (R.email = "Email is invalid") : R.email = "Email is required"), p(R), Object.keys(R).length === 0;
1322
+ }, S = (R) => {
1323
+ R.preventDefault(), _() && (m(!0), h(!1));
1324
+ }, w = (R, T) => {
1325
+ u((j) => ({ ...j, [R]: T })), b[R] && p((j) => ({ ...j, [R]: void 0 }));
1326
+ };
1327
+ return g.useImperativeHandle(
1328
+ r,
1329
+ () => ({
1330
+ getValues: () => f
1331
+ }),
1332
+ [f]
1333
+ ), console.log({ formData: f, submitted: E }), /* @__PURE__ */ t.jsxs(
1334
+ G,
1335
+ {
1336
+ autoComplete: "off",
1337
+ onSubmit: S,
1338
+ onValuesChange: u,
1339
+ className: "lulichat-contact-form",
1340
+ children: [
1341
+ /* @__PURE__ */ t.jsxs("div", { className: "lulichat-form-header", children: [
1342
+ /* @__PURE__ */ t.jsxs(
1343
+ "div",
1344
+ {
1345
+ style: {
1346
+ marginBottom: "20px",
1347
+ display: "flex",
1348
+ alignItems: "end",
1349
+ columnGap: 8
1350
+ },
1351
+ children: [
1352
+ /* @__PURE__ */ t.jsx(
1353
+ Bt,
1354
+ {
1355
+ style: { display: "block" },
1356
+ color: "#DEDEDE6A",
1357
+ height: 40,
1358
+ width: 50
1359
+ }
1360
+ ),
1361
+ /* @__PURE__ */ t.jsx("h3", { style: { fontWeight: 500 }, children: "Hello," })
1362
+ ]
1363
+ }
1364
+ ),
1365
+ /* @__PURE__ */ t.jsxs("h3", { style: { marginBottom: 8 }, className: "lulichat-title", children: [
1366
+ "Welcome to ",
1367
+ a,
1368
+ " Live Chat"
1369
+ ] }),
1370
+ E ? /* @__PURE__ */ t.jsxs("div", { children: [
1371
+ /* @__PURE__ */ t.jsxs("p", { children: [
1372
+ "Name: ",
1373
+ /* @__PURE__ */ t.jsx("b", { children: f.name })
1374
+ ] }),
1375
+ /* @__PURE__ */ t.jsxs("p", { children: [
1376
+ "Email: ",
1377
+ /* @__PURE__ */ t.jsx("b", { children: f.email })
1378
+ ] })
1379
+ ] }) : /* @__PURE__ */ t.jsxs(
1380
+ "p",
1381
+ {
1382
+ role: "button",
1383
+ onClickCapture: () => h(!c),
1384
+ style: {
1385
+ textDecoration: "underline",
1386
+ lineHeight: "1rem",
1387
+ cursor: "pointer"
1388
+ },
1389
+ children: [
1390
+ "Please provide your details for a better support experience",
1391
+ " ",
1392
+ /* @__PURE__ */ t.jsx(
1393
+ $t,
1394
+ {
1395
+ style: {
1396
+ display: "inline-block",
1397
+ marginBottom: -2
1398
+ },
1399
+ height: 20,
1400
+ width: 20
1401
+ }
1402
+ )
1403
+ ]
1404
+ }
1405
+ )
1291
1406
  ] }),
1292
- /* @__PURE__ */ t.jsxs(
1293
- "p",
1294
- {
1295
- role: "button",
1296
- onClickCapture: () => y(!d),
1297
- style: {
1298
- textDecoration: "underline",
1299
- lineHeight: "1rem",
1300
- cursor: "pointer"
1301
- },
1302
- children: [
1303
- "Please provide your details for a better support experience",
1304
- " ",
1305
- /* @__PURE__ */ t.jsx(
1306
- Pt,
1307
- {
1308
- style: {
1309
- display: "inline-block",
1310
- marginBottom: -2
1311
- },
1312
- height: 20,
1313
- width: 20
1314
- }
1315
- )
1316
- ]
1317
- }
1318
- )
1319
- ] }),
1320
- /* @__PURE__ */ t.jsxs("div", { className: `lulichat-form-group${d ? " open" : ""}`, children: [
1321
- /* @__PURE__ */ t.jsx(Y.Item, { error: h.name, label: "Name (Optional)", name: "name", children: /* @__PURE__ */ t.jsx(
1322
- ee,
1323
- {
1324
- id: "name",
1325
- placeholder: "Enter your name",
1326
- type: "text",
1327
- value: b.name,
1328
- onChange: (j) => M("name", j.target.value),
1329
- className: "transparent" + (h.name ? " error" : "")
1330
- }
1331
- ) }),
1332
- /* @__PURE__ */ t.jsx(Y.Item, { name: "email", error: h.email, label: "Email", children: /* @__PURE__ */ t.jsx(
1333
- ee,
1334
- {
1335
- id: "email",
1336
- type: "email",
1337
- placeholder: "Enter your valid email",
1338
- value: b.email,
1339
- onChange: (j) => M("email", j.target.value),
1340
- className: "transparent" + (h.name ? " error" : "")
1341
- }
1342
- ) }),
1343
- /* @__PURE__ */ t.jsx(
1344
- z,
1345
- {
1346
- type: "submit",
1347
- disabled: v || !E.email,
1348
- style: { width: "100%", marginTop: 10 },
1349
- className: "lulichat-contact-form-btn",
1350
- children: v ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1351
- /* @__PURE__ */ t.jsx(Be, {}),
1352
- "Submitting..."
1353
- ] }) : "Submit"
1354
- }
1355
- )
1356
- ] })
1357
- ]
1358
- }
1359
- );
1360
- };
1361
- class Wt {
1362
- constructor(s, l, i = "wss://ws.lulichat.com") {
1363
- F(this, "socket", null);
1364
- F(this, "token");
1365
- F(this, "sessionId");
1366
- F(this, "onMessageCallback");
1367
- F(this, "onStatusCallback");
1368
- F(this, "reconnectAttempts", 0);
1369
- F(this, "maxReconnectAttempts", 5);
1370
- this.token = s, this.sessionId = l, this.connect(i);
1407
+ /* @__PURE__ */ t.jsxs("div", { className: `lulichat-form-group${c ? " open" : ""}`, children: [
1408
+ /* @__PURE__ */ t.jsx(G.Item, { error: b.name, label: "Name (Optional)", name: "name", children: /* @__PURE__ */ t.jsx(
1409
+ ce,
1410
+ {
1411
+ id: "name",
1412
+ placeholder: "Enter your name",
1413
+ type: "text",
1414
+ value: f.name,
1415
+ onChange: (R) => w("name", R.target.value),
1416
+ className: "transparent" + (b.name ? " error" : "")
1417
+ }
1418
+ ) }),
1419
+ /* @__PURE__ */ t.jsx(G.Item, { name: "email", error: b.email, label: "Email", children: /* @__PURE__ */ t.jsx(
1420
+ ce,
1421
+ {
1422
+ id: "email",
1423
+ type: "email",
1424
+ placeholder: "Enter your valid email",
1425
+ value: f.email,
1426
+ onChange: (R) => w("email", R.target.value),
1427
+ className: "transparent" + (b.name ? " error" : "")
1428
+ }
1429
+ ) }),
1430
+ /* @__PURE__ */ t.jsx(
1431
+ Z,
1432
+ {
1433
+ type: "submit",
1434
+ disabled: i || !f.email,
1435
+ style: { width: "100%", marginBlock: 10 },
1436
+ className: "lulichat-contact-form-btn",
1437
+ children: i ? /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1438
+ /* @__PURE__ */ t.jsx(ue, {}),
1439
+ "Submitting..."
1440
+ ] }) : "Submit"
1441
+ }
1442
+ )
1443
+ ] })
1444
+ ]
1445
+ }
1446
+ );
1447
+ }
1448
+ );
1449
+ class Yt {
1450
+ constructor(r, a = "wss://ws.lulichat.com", i) {
1451
+ q(this, "socket", null);
1452
+ q(this, "token");
1453
+ q(this, "ticket");
1454
+ q(this, "onMessageCallback");
1455
+ q(this, "onStatusCallback");
1456
+ q(this, "reconnectAttempts", 0);
1457
+ q(this, "maxReconnectAttempts", 5);
1458
+ this.token = r, this.ticket = i, this.connect(a);
1371
1459
  }
1372
- connect(s) {
1373
- var l;
1460
+ connect(r) {
1461
+ var a;
1374
1462
  try {
1375
- this.socket = new WebSocket(
1376
- `${s}/chat?token=${this.token}&session=${this.sessionId}`
1377
- ), this.socket.onopen = () => {
1378
- var i;
1379
- console.log("Socket connected"), this.reconnectAttempts = 0, (i = this.onStatusCallback) == null || i.call(this, "connected");
1380
- }, this.socket.onmessage = (i) => {
1381
- var v;
1382
- try {
1383
- const d = JSON.parse(i.data);
1384
- (v = this.onMessageCallback) == null || v.call(this, d);
1385
- } catch (d) {
1386
- console.error("Failed to parse message:", d);
1463
+ this.socket = Nt(`${r}`, {
1464
+ transports: ["websocket"],
1465
+ // @ts-expect-error
1466
+ pingTimeout: 18e3,
1467
+ pingInterval: 18e3,
1468
+ query: { token: this.token }
1469
+ }), this.socket.on("connect", () => {
1470
+ var i, l;
1471
+ console.log("Socket connected"), this.reconnectAttempts = 0, (i = this.socket) == null || i.emit("joinChatBox", this.ticket.id), (l = this.onStatusCallback) == null || l.call(this, "connected");
1472
+ }), this.socket.on(
1473
+ `company-${this.ticket.companyId}-appMessage`,
1474
+ (i) => {
1475
+ var l;
1476
+ (l = this.onMessageCallback) == null || l.call(this, i.message);
1387
1477
  }
1388
- }, this.socket.onclose = () => {
1389
- var i;
1390
- console.log("Socket disconnected"), (i = this.onStatusCallback) == null || i.call(this, "disconnected"), this.handleReconnect(s);
1391
- }, this.socket.onerror = (i) => {
1392
- var v;
1393
- console.error("Socket error:", i), (v = this.onStatusCallback) == null || v.call(this, "error");
1394
- };
1478
+ ), this.socket.onAny((i, ...l) => {
1479
+ console.debug({ event: i, args: l });
1480
+ }), this.socket.on("disconnect", (i, l) => {
1481
+ var c;
1482
+ console.log("Socket disconnected"), console.log({ reason: i, details: l }), (c = this.onStatusCallback) == null || c.call(this, "disconnected");
1483
+ }), this.socket.on("connect_error", (i) => {
1484
+ var l;
1485
+ console.error("Socket error:", i.message), (l = this.onStatusCallback) == null || l.call(this, "error");
1486
+ });
1395
1487
  } catch (i) {
1396
- console.error("Failed to connect socket:", i), (l = this.onStatusCallback) == null || l.call(this, "error");
1488
+ console.error("Failed to connect socket:", i), (a = this.onStatusCallback) == null || a.call(this, "error");
1397
1489
  }
1398
1490
  }
1399
- handleReconnect(s) {
1400
- this.reconnectAttempts < this.maxReconnectAttempts && (this.reconnectAttempts++, setTimeout(() => {
1401
- console.log(`Reconnecting... attempt ${this.reconnectAttempts}`), this.connect(s);
1402
- }, 2e3 * this.reconnectAttempts));
1491
+ // private handleReconnect(baseUrl: string) {
1492
+ // if (this.reconnectAttempts < this.maxReconnectAttempts) {
1493
+ // this.reconnectAttempts++;
1494
+ // setTimeout(() => {
1495
+ // console.log(`Reconnecting... attempt ${this.reconnectAttempts}`);
1496
+ // this.connect(baseUrl);
1497
+ // }, 2000 * this.reconnectAttempts);
1498
+ // }
1499
+ // }
1500
+ sendMessage(r) {
1501
+ var a;
1502
+ (a = this.socket) != null && a.connected && this.socket.emit("message", r);
1403
1503
  }
1404
- sendMessage(s) {
1405
- var l;
1406
- if (((l = this.socket) == null ? void 0 : l.readyState) === WebSocket.OPEN) {
1407
- const i = {
1408
- type: "message",
1409
- content: s,
1410
- timestamp: (/* @__PURE__ */ new Date()).toISOString()
1411
- };
1412
- this.socket.send(JSON.stringify(i));
1413
- }
1414
- }
1415
- onMessage(s) {
1416
- this.onMessageCallback = s;
1504
+ onMessage(r) {
1505
+ this.onMessageCallback = r;
1417
1506
  }
1418
- onStatus(s) {
1419
- this.onStatusCallback = s;
1507
+ onStatus(r) {
1508
+ this.onStatusCallback = r;
1420
1509
  }
1421
1510
  disconnect() {
1422
1511
  this.socket && (this.socket.close(), this.socket = null);
1423
1512
  }
1424
1513
  }
1425
- const zt = ({
1426
- session: n,
1427
- companyInfo: s,
1428
- onClose: l
1429
- }) => {
1430
- const [i, v] = P([]), [d, y] = P(""), [b, u] = P(!1), [h, p] = P("disconnected"), E = U(null), R = U(null);
1431
- ce(() => (R.current = new Wt(n.token, n.id), R.current.onMessage((w) => {
1432
- v(($) => [...$, w]), u(!1);
1433
- }), R.current.onStatus((w) => {
1434
- p(w);
1435
- }), v([{
1436
- id: "welcome",
1437
- content: "",
1438
- timestamp: /* @__PURE__ */ new Date(),
1439
- sender: "system"
1440
- }]), () => {
1441
- var w;
1442
- (w = R.current) == null || w.disconnect();
1443
- }), [n, s]), ce(() => {
1444
- T();
1445
- }, [i]);
1446
- const T = () => {
1447
- var o;
1448
- (o = E.current) == null || o.scrollIntoView({ behavior: "smooth" });
1449
- }, A = () => {
1450
- var w;
1451
- if (!d.trim() || h !== "connected") return;
1452
- const o = {
1453
- id: Date.now().toString(),
1454
- content: d,
1455
- timestamp: /* @__PURE__ */ new Date(),
1456
- sender: "user"
1514
+ function Qe(n) {
1515
+ const r = Mt(), a = Ot.parse(n || "");
1516
+ return r.sanitize(a);
1517
+ }
1518
+ const Ut = (n) => {
1519
+ var z;
1520
+ const { session: r, companyInfo: a, onClose: i, api: l } = n, [c, h] = W([]), [f, u] = W(""), [b, p] = W(!1), [E, m] = W("disconnected"), _ = J(null), S = J(null), [w, R] = g.useState(), { ticket: T } = r, j = g.useCallback(async () => {
1521
+ const y = await l.getTicketMessages(r.ticket.id);
1522
+ h(
1523
+ (I) => Lt([...I, ...y.messages], (M) => M.id).sort(
1524
+ (M, $) => +new Date(M.createdAt) - +new Date($.createdAt)
1525
+ )
1526
+ ), R(y);
1527
+ }, [r.ticket.id]);
1528
+ g.useEffect(() => {
1529
+ j();
1530
+ }, [j]), be(() => {
1531
+ const { token: y, ticket: I } = r;
1532
+ return S.current = new Yt(y, l.baseUrl, I), S.current.onMessage((M) => {
1533
+ h(($) => [...$, M]), p(!1);
1534
+ }), S.current.onStatus((M) => {
1535
+ m(M);
1536
+ }), () => {
1537
+ var M;
1538
+ (M = S.current) == null || M.disconnect();
1539
+ };
1540
+ }, [r, a]), be(() => {
1541
+ X();
1542
+ }, [c]);
1543
+ const X = () => {
1544
+ var y;
1545
+ (y = _.current) == null || y.scrollIntoView({ behavior: "smooth" });
1546
+ }, D = () => {
1547
+ var I;
1548
+ if (!f.trim() || E !== "connected") return;
1549
+ const y = {
1550
+ id: Ke(32),
1551
+ ticketId: T.id,
1552
+ body: f,
1553
+ contactId: T.contact.id,
1554
+ queueId: T.queueId,
1555
+ companyId: T.companyId
1457
1556
  };
1458
- v(($) => [...$, o]), (w = R.current) == null || w.sendMessage(d), y(""), u(!0);
1459
- }, M = (o) => {
1460
- o.key === "Enter" && !o.shiftKey && (o.preventDefault(), A());
1461
- }, j = (o) => new Intl.DateTimeFormat("en-US", {
1557
+ (I = S.current) == null || I.sendMessage(y), u(""), p(!0);
1558
+ }, B = (y) => {
1559
+ y.key === "Enter" && !y.shiftKey && (y.preventDefault(), D());
1560
+ }, Y = (y) => new Intl.DateTimeFormat("en-US", {
1462
1561
  hour: "2-digit",
1463
1562
  minute: "2-digit"
1464
- }).format(o), O = (o) => {
1465
- switch (o) {
1466
- case "agent":
1467
- return /* @__PURE__ */ t.jsx(Mt, { className: "w-4 h-4" });
1468
- case "user":
1469
- return /* @__PURE__ */ t.jsx(It, { className: "w-4 h-4" });
1470
- default:
1471
- return null;
1472
- }
1473
- };
1474
- return /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col h-full", children: [
1475
- /* @__PURE__ */ t.jsxs("div", { className: "bg-primary text-primary-foreground p-4 rounded-t-lg", children: [
1476
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between", children: [
1477
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
1478
- /* @__PURE__ */ t.jsx("div", { className: "w-2 h-2 rounded-full bg-green-400" }),
1479
- /* @__PURE__ */ t.jsx("span", { className: "font-medium", children: s.name })
1480
- ] }),
1481
- /* @__PURE__ */ t.jsx(
1482
- z,
1483
- {
1484
- variant: "ghost",
1485
- size: "sm",
1486
- onClick: l,
1487
- className: "text-primary-foreground hover:bg-primary-foreground/20",
1488
- children: "×"
1489
- }
1490
- )
1491
- ] }),
1492
- /* @__PURE__ */ t.jsx("div", { className: "text-xs opacity-80 mt-1", children: h === "connected" ? "Online" : "Connecting..." })
1493
- ] }),
1494
- /* @__PURE__ */ t.jsxs("div", { className: "flex-1 overflow-y-auto p-4 space-y-4 bg-background", children: [
1495
- i.map((o) => /* @__PURE__ */ t.jsx(
1496
- "div",
1497
- {
1498
- className: `flex ${o.sender === "user" ? "justify-end" : "justify-start"}`,
1499
- children: /* @__PURE__ */ t.jsxs(
1500
- "div",
1501
- {
1502
- className: `max-w-xs lg:max-w-md px-4 py-2 rounded-lg ${o.sender === "user" ? "bg-primary text-primary-foreground" : o.sender === "system" ? "bg-muted text-muted-foreground text-center" : "bg-muted text-foreground"}`,
1503
- children: [
1504
- o.sender !== "system" && /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-1 mb-1", children: [
1505
- O(o.sender),
1506
- /* @__PURE__ */ t.jsx("span", { className: "text-xs opacity-70", children: o.senderName || (o.sender === "user" ? "You" : "Support") })
1507
- ] }),
1508
- /* @__PURE__ */ t.jsx("p", { className: "text-sm", children: o.content }),
1509
- /* @__PURE__ */ t.jsx("p", { className: "text-xs opacity-60 mt-1", children: j(o.timestamp) })
1510
- ]
1511
- }
1512
- )
1513
- },
1514
- o.id
1515
- )),
1516
- b && /* @__PURE__ */ t.jsx("div", { className: "flex justify-start", children: /* @__PURE__ */ t.jsx("div", { className: "bg-muted text-foreground px-4 py-2 rounded-lg", children: /* @__PURE__ */ t.jsxs("div", { className: "flex space-x-1", children: [
1517
- /* @__PURE__ */ t.jsx("div", { className: "w-2 h-2 bg-current rounded-full animate-bounce" }),
1563
+ }).format(y);
1564
+ return /* @__PURE__ */ t.jsxs("div", { className: "lulichat-room", children: [
1565
+ /* @__PURE__ */ t.jsx("div", { className: "lulichat-room-header", children: /* @__PURE__ */ t.jsxs("div", { className: "lulichat-flex lulichat-space-x-2", children: [
1566
+ /* @__PURE__ */ t.jsxs("div", { className: "lulichat-flex lulichat-space-x-2", children: [
1518
1567
  /* @__PURE__ */ t.jsx(
1519
1568
  "div",
1520
1569
  {
1521
- className: "w-2 h-2 bg-current rounded-full animate-bounce",
1522
- style: { animationDelay: "0.1s" }
1570
+ style: {
1571
+ width: "0.5rem",
1572
+ height: "0.5rem",
1573
+ borderRadius: "9999px",
1574
+ background: "#22c55e"
1575
+ // green
1576
+ }
1523
1577
  }
1524
1578
  ),
1525
- /* @__PURE__ */ t.jsx(
1526
- "div",
1527
- {
1528
- className: "w-2 h-2 bg-current rounded-full animate-bounce",
1529
- style: { animationDelay: "0.2s" }
1530
- }
1531
- )
1532
- ] }) }) }),
1533
- /* @__PURE__ */ t.jsx("div", { ref: E })
1534
- ] }),
1535
- /* @__PURE__ */ t.jsxs("div", { className: "p-4 border-t bg-background", children: [
1536
- /* @__PURE__ */ t.jsxs("div", { className: "flex space-x-2", children: [
1579
+ /* @__PURE__ */ t.jsx("span", { className: "font-medium", children: ((z = T.contact) == null ? void 0 : z.name) || "Anonymous" }),
1580
+ /* @__PURE__ */ t.jsx(qt, { height: 24, width: 24 }),
1581
+ /* @__PURE__ */ t.jsx("span", { className: "font-medium", children: a.name })
1582
+ ] }),
1583
+ /* @__PURE__ */ t.jsx(Z, { variant: "ghost", size: "sm", onClick: i, className: "", children: /* @__PURE__ */ t.jsx(Ze, { height: 16, width: 16 }) })
1584
+ ] }) }),
1585
+ /* @__PURE__ */ t.jsxs(
1586
+ "div",
1587
+ {
1588
+ className: "lulichat-flex-1 lulichat-p-4 lulichat-bg-background",
1589
+ style: { overflowY: "auto", flex: 1 },
1590
+ children: [
1591
+ c.map((y, I) => {
1592
+ var $;
1593
+ const M = ($ = c[I - 1]) == null ? void 0 : $.fromMe;
1594
+ return /* @__PURE__ */ t.jsx(
1595
+ "div",
1596
+ {
1597
+ className: se(
1598
+ "lulichat-message",
1599
+ y.fromMe ? "agent" : "user"
1600
+ ),
1601
+ children: /* @__PURE__ */ t.jsxs("div", { className: "lulichat-message-content", children: [
1602
+ y.fromMe && !M && /* @__PURE__ */ t.jsxs("div", { className: "lulichat-message-header", children: [
1603
+ /* @__PURE__ */ t.jsx(zt, { width: 16, height: 16 }),
1604
+ /* @__PURE__ */ t.jsx("span", { className: "lulichat-message-sender", children: "Support" })
1605
+ ] }),
1606
+ /* @__PURE__ */ t.jsxs(
1607
+ "p",
1608
+ {
1609
+ className: se(
1610
+ "lulichat-message-body",
1611
+ y.fromMe ? "support" : "user"
1612
+ ),
1613
+ children: [
1614
+ /* @__PURE__ */ t.jsx(
1615
+ "span",
1616
+ {
1617
+ dangerouslySetInnerHTML: {
1618
+ __html: Qe(y.body)
1619
+ }
1620
+ }
1621
+ ),
1622
+ /* @__PURE__ */ t.jsx("p", { className: "lulichat-message-time", children: Y(new Date(y.createdAt)) })
1623
+ ]
1624
+ }
1625
+ )
1626
+ ] })
1627
+ },
1628
+ y.id
1629
+ );
1630
+ }),
1631
+ b && /* @__PURE__ */ t.jsx("div", { className: "lulichat-typing", children: /* @__PURE__ */ t.jsx("div", { className: "lulichat-typing-bubble", children: /* @__PURE__ */ t.jsxs("div", { className: "lulichat-typing-dots", children: [
1632
+ /* @__PURE__ */ t.jsx("div", { className: "lulichat-typing-dot" }),
1633
+ /* @__PURE__ */ t.jsx("div", { className: "lulichat-typing-dot" }),
1634
+ /* @__PURE__ */ t.jsx("div", { className: "lulichat-typing-dot" })
1635
+ ] }) }) }),
1636
+ /* @__PURE__ */ t.jsx("div", { ref: _ })
1637
+ ]
1638
+ }
1639
+ ),
1640
+ /* @__PURE__ */ t.jsxs("div", { className: "lulichat-input-wrapper", children: [
1641
+ /* @__PURE__ */ t.jsxs("div", { className: "lulichat-input-container", children: [
1537
1642
  /* @__PURE__ */ t.jsx(
1538
1643
  "input",
1539
1644
  {
1540
- value: d,
1541
- onChange: (o) => y(o.target.value),
1542
- onKeyPress: M,
1645
+ value: f,
1646
+ onChange: (y) => u(y.target.value),
1647
+ onKeyPress: B,
1543
1648
  placeholder: "Type your message...",
1544
- disabled: h !== "connected",
1545
- className: "flex-1"
1649
+ disabled: E !== "connected",
1650
+ className: "lulichat-input"
1546
1651
  }
1547
1652
  ),
1548
1653
  /* @__PURE__ */ t.jsx(
1549
- z,
1654
+ "button",
1550
1655
  {
1551
- onClick: A,
1552
- disabled: !d.trim() || h !== "connected",
1553
- size: "icon",
1554
- children: /* @__PURE__ */ t.jsx(Ve, { className: "w-4 h-4" })
1656
+ onClick: D,
1657
+ disabled: !f.trim() || E !== "connected",
1658
+ className: "lulichat-send-button",
1659
+ children: /* @__PURE__ */ t.jsx(Xe, { width: 16, height: 16 })
1555
1660
  }
1556
1661
  )
1557
1662
  ] }),
1558
- h !== "connected" && /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground mt-2", children: h === "error" ? "Connection error. Retrying..." : "Connecting..." })
1663
+ E !== "connected" && /* @__PURE__ */ t.jsx("p", { className: "lulichat-connection-status", children: E === "error" ? "Connection error. Retrying..." : "Connecting..." })
1559
1664
  ] })
1560
1665
  ] });
1561
- }, Vt = ({ config: n }) => {
1562
- const [s, l] = P("contact-form"), [i, v] = P(
1563
- null
1564
- ), [d, y] = P(null), [b, u] = P(!1), [h, p] = P(null), [E, R] = S.useState(!1), T = new Tt(n);
1565
- ce(() => {
1566
- A();
1567
- }, [n]);
1568
- const A = async () => {
1569
- try {
1570
- const o = await T.getCompanyInfo();
1571
- v(o.data);
1572
- } catch (o) {
1573
- p("Failed to load chat configuration"), console.error("Failed to load company info:", o);
1666
+ }, Kt = g.forwardRef((n, r) => {
1667
+ const [a, i] = g.useState([]), [l, c] = g.useState(n.queues), h = g.useRef(null), f = g.useRef("auto"), u = n.api.useRequest(), b = g.useCallback(async (m) => {
1668
+ if (!m.length) {
1669
+ c(n.queues);
1670
+ return;
1574
1671
  }
1575
- }, M = async (o) => {
1576
- u(!0);
1577
- try {
1578
- const w = await T.submitContactInfo(o), $ = {
1579
- id: w.sessionId,
1580
- token: w.token,
1581
- isActive: !0
1582
- };
1583
- y($), l("chat");
1584
- } catch (w) {
1585
- p("Failed to start chat. Please try again."), console.error("Failed to submit contact info:", w);
1586
- } finally {
1587
- u(!1);
1588
- }
1589
- }, j = async () => {
1590
- u(!0);
1591
- try {
1592
- const o = await T.startAnonymousChat(), w = {
1593
- id: o.sessionId,
1594
- token: o.token,
1595
- isActive: !0
1672
+ c([]);
1673
+ const _ = m[m.length - 1], S = _.type == "queue", w = await u.getOptions({
1674
+ [S ? "queueId" : "queueOptionId"]: _.id,
1675
+ parentId: S ? -1 : _.id
1676
+ });
1677
+ w != null && w.length && (E(), c(w));
1678
+ }, []);
1679
+ g.useEffect(() => {
1680
+ b(a);
1681
+ }, [a]), g.useImperativeHandle(
1682
+ r,
1683
+ () => ({
1684
+ getTags: () => a
1685
+ }),
1686
+ [a]
1687
+ );
1688
+ const p = a[a.length - 1];
1689
+ g.useEffect(() => {
1690
+ if (!h.current) return;
1691
+ const m = h.current, _ = m.offsetHeight;
1692
+ m.style.height = `${_}px`, requestAnimationFrame(() => {
1693
+ if (!h.current) return;
1694
+ const S = m.scrollHeight;
1695
+ if (_ === S) {
1696
+ m.style.height = "auto";
1697
+ return;
1698
+ }
1699
+ m.offsetHeight, m.style.height = `${S}px`;
1700
+ const w = () => {
1701
+ h.current && (h.current.style.height = "auto"), m.removeEventListener("transitionend", w);
1596
1702
  };
1597
- y(w), l("chat");
1598
- } catch (o) {
1599
- p("Failed to start chat. Please try again."), console.error("Failed to start anonymous chat:", o);
1600
- } finally {
1601
- u(!1);
1602
- }
1603
- }, O = () => {
1604
- l("closed"), y(null), p(null);
1605
- };
1606
- return console.log({ companyInfo: i }), /* @__PURE__ */ t.jsxs("div", { className: `lulichat lulichat-${n.position}`, children: [
1607
- E && /* @__PURE__ */ t.jsxs("div", { className: "lulichat-main", children: [
1608
- h && /* @__PURE__ */ t.jsxs("div", { className: "p-4 bg-destructive/10 border-b", children: [
1609
- /* @__PURE__ */ t.jsx("p", { className: "text-sm text-destructive", children: h }),
1610
- /* @__PURE__ */ t.jsx("button", { onClick: () => p(null), className: "mt-2", children: "Retry" })
1611
- ] }),
1612
- /* @__PURE__ */ t.jsx(
1613
- Lt,
1614
- {
1615
- companyName: i == null ? void 0 : i.name,
1616
- onSubmit: M,
1617
- onSkip: n.allowAnonymous ? j : void 0,
1618
- allowAnonymous: n.allowAnonymous || !1,
1619
- isLoading: b
1620
- }
1621
- ),
1622
- /* @__PURE__ */ t.jsxs("div", { style: { padding: 16 }, children: [
1623
- /* @__PURE__ */ t.jsx(
1703
+ m.addEventListener("transitionend", w);
1704
+ });
1705
+ }, [a, n.message]);
1706
+ const E = g.useCallback(() => {
1707
+ var m;
1708
+ h.current && (f.current = (m = h.current) == null ? void 0 : m.offsetHeight);
1709
+ }, []);
1710
+ return g.useEffect(E, [l, a]), console.log({ loading: u.loading }), /* @__PURE__ */ t.jsxs(
1711
+ "div",
1712
+ {
1713
+ className: "wrap",
1714
+ ref: h,
1715
+ style: {
1716
+ overflow: "hidden",
1717
+ transition: "height 200ms ease"
1718
+ },
1719
+ children: [
1720
+ (p || n.message) && /* @__PURE__ */ t.jsx(
1624
1721
  "div",
1625
1722
  {
1723
+ className: "lulichat-queue-message",
1626
1724
  style: {
1627
- display: "flex",
1628
- gap: 10,
1629
- flexWrap: "wrap"
1725
+ background: "#EBEBEBFF",
1726
+ padding: 10,
1727
+ marginBottom: 10,
1728
+ fontSize: ".79rem",
1729
+ borderRadius: "0.5rem"
1630
1730
  },
1631
- children: i == null ? void 0 : i.queues.map((o) => {
1632
- var w;
1633
- return /* @__PURE__ */ t.jsx("div", { className: "lulichat-tag", children: (w = o.name) == null ? void 0 : w.toLocaleLowerCase() }, o.id);
1634
- })
1635
- }
1636
- ),
1637
- /* @__PURE__ */ t.jsx(
1638
- "div",
1639
- {
1640
- style: {
1641
- height: 2,
1642
- backgroundColor: "hsl(var(--border))",
1643
- marginBlock: 16
1731
+ dangerouslySetInnerHTML: {
1732
+ __html: Qe(
1733
+ (p == null ? void 0 : p.message) || (p == null ? void 0 : p.greetingMessage) || n.message
1734
+ )
1644
1735
  }
1645
1736
  }
1646
1737
  ),
@@ -1650,40 +1741,148 @@ const zt = ({
1650
1741
  style: {
1651
1742
  display: "flex",
1652
1743
  alignItems: "center",
1653
- columnGap: 10
1744
+ justifyContent: "start",
1745
+ gap: 10,
1746
+ flexWrap: "wrap"
1654
1747
  },
1655
- className: "form-control",
1656
1748
  children: [
1657
- /* @__PURE__ */ t.jsx(
1658
- ee,
1659
- {
1660
- name: "message",
1661
- autoComplete: "off",
1662
- style: { border: "none", paddingInline: 0 },
1663
- placeholder: "What can we help you with ?."
1664
- }
1665
- ),
1666
- /* @__PURE__ */ t.jsxs("div", { className: "lulichat-btn-group", children: [
1667
- /* @__PURE__ */ t.jsx(z, { style: { color: "#00000080" }, size: "icon", children: /* @__PURE__ */ t.jsx(Ft, { height: 24 }) }),
1668
- /* @__PURE__ */ t.jsx(z, { style: { color: "#00000080" }, size: "icon", children: /* @__PURE__ */ t.jsx(Ve, {}) })
1669
- ] })
1749
+ a.map((m, _) => {
1750
+ m.name;
1751
+ const S = m.name || m.title, w = _ == a.length - 1, R = w && u.loading;
1752
+ return /* @__PURE__ */ t.jsxs(
1753
+ "button",
1754
+ {
1755
+ onClick: w ? () => {
1756
+ E(), i(
1757
+ (T) => [...T].filter((j) => j.id != m.id ? m.type != j.type : !1)
1758
+ );
1759
+ } : void 0,
1760
+ disabled: !w,
1761
+ className: "lulichat-tag" + (w ? " selected" : ""),
1762
+ children: [
1763
+ R && /* @__PURE__ */ t.jsx(ue, { height: 14, width: 14 }),
1764
+ S == null ? void 0 : S.toLocaleLowerCase(),
1765
+ w && /* @__PURE__ */ t.jsx(Ze, { style: { marginLeft: 4 }, height: 14, width: 14 })
1766
+ ]
1767
+ },
1768
+ m.id
1769
+ );
1770
+ }),
1771
+ l.map((m) => {
1772
+ const _ = m.name ? "queue" : "option", S = a.find((R) => R.id == m.id && R.type == _), w = m.name || m.title;
1773
+ return /* @__PURE__ */ t.jsx(
1774
+ "button",
1775
+ {
1776
+ onClick: () => i([...a, { ...m, type: _ }]),
1777
+ className: "lulichat-tag" + (S ? " selected" : ""),
1778
+ children: w == null ? void 0 : w.toLocaleLowerCase()
1779
+ },
1780
+ m.id
1781
+ );
1782
+ })
1670
1783
  ]
1671
1784
  }
1672
1785
  )
1786
+ ]
1787
+ }
1788
+ );
1789
+ }), xe = "luli-g-id", Gt = ({ config: n }) => {
1790
+ const [r, a] = W(
1791
+ null
1792
+ ), [i, l] = W(null), [c, h] = W(!1), [f, u] = W(null), [b, p] = g.useState(!1), [E, m] = g.useState(
1793
+ localStorage.getItem(xe) || Ke()
1794
+ ), _ = g.useRef(null), S = g.useRef(null), w = new Ft(n);
1795
+ be(() => {
1796
+ R(), j();
1797
+ }, [n]);
1798
+ const R = async () => {
1799
+ try {
1800
+ const D = await w.getCompanyInfo();
1801
+ a(D.data);
1802
+ } catch (D) {
1803
+ u("Failed to load chat configuration"), console.error("Failed to load company info:", D);
1804
+ }
1805
+ }, T = async (D) => {
1806
+ var B, Y;
1807
+ h(!0);
1808
+ try {
1809
+ const z = ((B = _.current) == null ? void 0 : B.getValues()) || {}, y = ((Y = S.current) == null ? void 0 : Y.getTags()) || [], I = y[0], M = (y == null ? void 0 : y.length) > 1 ? y[y.length - 1] : void 0, $ = {
1810
+ ...z,
1811
+ ...D,
1812
+ message: `${y.map((F) => `*${(F == null ? void 0 : F.name) || (F == null ? void 0 : F.title)}*`)}
1813
+ ${D.message}`,
1814
+ queueId: I == null ? void 0 : I.id,
1815
+ queueOptionId: M == null ? void 0 : M.id,
1816
+ guestId: E
1817
+ }, ne = await w.submitContactInfo($);
1818
+ localStorage.setItem(xe, E), l(ne.data);
1819
+ } catch (z) {
1820
+ u("Failed to start chat. Please try again."), console.error("Failed to submit contact info:", z);
1821
+ } finally {
1822
+ h(!1);
1823
+ }
1824
+ }, j = g.useCallback(async () => {
1825
+ var B;
1826
+ const D = await w.getSession(E);
1827
+ (B = D.data) != null && B.ticket && D.data.token && (l(D.data), p(!0));
1828
+ }, [xe]), X = () => {
1829
+ l(null), u(null);
1830
+ };
1831
+ return r ? /* @__PURE__ */ t.jsxs("div", { className: `lulichat lulichat-${n.position}`, children: [
1832
+ b && /* @__PURE__ */ t.jsxs("div", { className: "lulichat-main", children: [
1833
+ !i && /* @__PURE__ */ t.jsxs(g.Fragment, { children: [
1834
+ /* @__PURE__ */ t.jsx(
1835
+ Ht,
1836
+ {
1837
+ companyName: r == null ? void 0 : r.name,
1838
+ allowAnonymous: n.allowAnonymous || !1,
1839
+ isLoading: c,
1840
+ ref: _
1841
+ }
1842
+ ),
1843
+ /* @__PURE__ */ t.jsxs("div", { style: { padding: 16 }, children: [
1844
+ /* @__PURE__ */ t.jsx(
1845
+ Kt,
1846
+ {
1847
+ message: n.welcomeMessage,
1848
+ api: w,
1849
+ queues: r == null ? void 0 : r.queues,
1850
+ ref: S
1851
+ }
1852
+ ),
1853
+ /* @__PURE__ */ t.jsx(
1854
+ "div",
1855
+ {
1856
+ style: {
1857
+ height: 2,
1858
+ backgroundColor: "hsl(var(--border))",
1859
+ marginBlock: 16
1860
+ }
1861
+ }
1862
+ ),
1863
+ /* @__PURE__ */ t.jsx(
1864
+ Jt,
1865
+ {
1866
+ isLoading: c,
1867
+ handleSubmit: T
1868
+ }
1869
+ )
1870
+ ] })
1673
1871
  ] }),
1674
- s === "chat" && d && i && /* @__PURE__ */ t.jsx(
1675
- zt,
1872
+ i && /* @__PURE__ */ t.jsx(
1873
+ Ut,
1676
1874
  {
1677
- session: d,
1678
- companyInfo: i,
1679
- onClose: O
1875
+ session: i,
1876
+ companyInfo: r,
1877
+ onClose: X,
1878
+ api: w
1680
1879
  }
1681
1880
  )
1682
1881
  ] }),
1683
1882
  /* @__PURE__ */ t.jsx(
1684
- z,
1883
+ Z,
1685
1884
  {
1686
- onClick: () => R(!E),
1885
+ onClick: () => p(!b),
1687
1886
  className: "",
1688
1887
  shape: "circle",
1689
1888
  size: "icon",
@@ -1695,33 +1894,100 @@ const zt = ({
1695
1894
  color: "#fff",
1696
1895
  alignSelf: "end"
1697
1896
  },
1698
- disabled: !i && !h,
1699
- children: !i && !h ? /* @__PURE__ */ t.jsx(Be, {}) : /* @__PURE__ */ t.jsx($t, { height: 40, width: 40 })
1897
+ disabled: !r && !f,
1898
+ children: !r && !f ? /* @__PURE__ */ t.jsx(ue, {}) : /* @__PURE__ */ t.jsx(Vt, { height: 40, width: 40 })
1700
1899
  }
1701
1900
  )
1702
- ] });
1703
- }, qt = ({
1901
+ ] }) : /* @__PURE__ */ t.jsx(t.Fragment, {});
1902
+ }, Jt = (n) => {
1903
+ const [r, a] = g.useState({
1904
+ message: "",
1905
+ files: null
1906
+ }), i = g.useRef(null);
1907
+ return /* @__PURE__ */ t.jsxs(
1908
+ "div",
1909
+ {
1910
+ style: {
1911
+ display: "flex",
1912
+ alignItems: "center",
1913
+ columnGap: 10
1914
+ },
1915
+ className: "form-control",
1916
+ children: [
1917
+ /* @__PURE__ */ t.jsx(
1918
+ ce,
1919
+ {
1920
+ name: "message",
1921
+ autoComplete: "off",
1922
+ style: { border: "none", paddingInline: 0 },
1923
+ placeholder: "What can we help you with ?.",
1924
+ onChange: (l) => a({ ...r, message: l.target.value })
1925
+ }
1926
+ ),
1927
+ n.isLoading ? /* @__PURE__ */ t.jsx(ue, {}) : /* @__PURE__ */ t.jsxs("div", { className: "lulichat-btn-group", children: [
1928
+ /* @__PURE__ */ t.jsxs(
1929
+ Z,
1930
+ {
1931
+ onClick: () => {
1932
+ var l;
1933
+ return (l = i.current) == null ? void 0 : l.click();
1934
+ },
1935
+ style: { color: "#00000080" },
1936
+ size: "icon",
1937
+ children: [
1938
+ /* @__PURE__ */ t.jsx(Wt, { height: 24 }),
1939
+ /* @__PURE__ */ t.jsx(
1940
+ "input",
1941
+ {
1942
+ ref: i,
1943
+ hidden: !0,
1944
+ type: "file",
1945
+ multiple: !1,
1946
+ onChange: (l) => a({ ...r, files: l.target.files }),
1947
+ accept: "image/jpeg,image/png"
1948
+ }
1949
+ )
1950
+ ]
1951
+ }
1952
+ ),
1953
+ /* @__PURE__ */ t.jsx(
1954
+ Z,
1955
+ {
1956
+ onClick: r.message ? () => {
1957
+ n.handleSubmit(r);
1958
+ } : void 0,
1959
+ disabled: !r.message,
1960
+ style: { color: "#00000080" },
1961
+ size: "icon",
1962
+ children: /* @__PURE__ */ t.jsx(Xe, {})
1963
+ }
1964
+ )
1965
+ ] })
1966
+ ]
1967
+ }
1968
+ );
1969
+ }, rr = ({
1704
1970
  apiKey: n,
1705
- baseUrl: s,
1706
- position: l = "bottom-right",
1971
+ baseUrl: r,
1972
+ position: a = "bottom-right",
1707
1973
  primaryColor: i = "#007bff",
1708
- companyName: v = "Support",
1709
- welcomeMessage: d = "Hello! How can we help you today?",
1710
- requireContactInfo: y = !0,
1711
- allowAnonymous: b = !0
1974
+ companyName: l = "Support",
1975
+ welcomeMessage: c = "Hello! How can we help you today?",
1976
+ requireContactInfo: h = !0,
1977
+ allowAnonymous: f = !0
1712
1978
  }) => {
1713
1979
  const u = {
1714
1980
  apiKey: n,
1715
- baseUrl: s,
1716
- position: l,
1981
+ baseUrl: r,
1982
+ position: a,
1717
1983
  primaryColor: i,
1718
- companyName: v,
1719
- welcomeMessage: d,
1720
- requireContactInfo: y,
1721
- allowAnonymous: b
1984
+ companyName: l,
1985
+ welcomeMessage: c,
1986
+ requireContactInfo: h,
1987
+ allowAnonymous: f
1722
1988
  };
1723
- return n ? /* @__PURE__ */ t.jsx(Vt, { config: u }) : (console.error("LuliChat: API key is required"), null);
1989
+ return n ? /* @__PURE__ */ t.jsx(Gt, { config: u }) : (console.error("LuliChat: API key is required"), null);
1724
1990
  };
1725
1991
  export {
1726
- qt as default
1992
+ rr as default
1727
1993
  };