react-aichatbot-widget 1.5.5 → 2.0.0

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.
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { jsxs as F, jsx as y, Fragment as Z } from "react/jsx-runtime";
2
- import { useState as I, useRef as Et, useEffect as Ke } from "react";
3
- import { Minus as Ct, MessageCircle as Xe, Send as Ge, Bot as Ne, Minimize2 as Rt, Maximize2 as Tt, X as Ot } from "lucide-react";
4
- const At = ({ onMinimise: e, isOpen: t, theme: n, chatBotData: r }) => {
5
- const o = r.position === "left", i = o ? "32px" : "auto", s = o ? "auto" : "32px", l = localStorage.getItem("clone67ChatSessionId"), p = {
1
+ import { jsxs as u, jsx as o, Fragment as M } from "react/jsx-runtime";
2
+ import { useState as S, useRef as L, useEffect as T } from "react";
3
+ import { Minus as $, MessageCircle as D, Send as U, Minimize2 as j, Maximize2 as B, X as O } from "lucide-react";
4
+ const F = ({ onMinimise: t, isOpen: e, theme: s, chatBotData: i }) => {
5
+ const f = i.position === "left", d = f ? "32px" : "auto", p = f ? "auto" : "32px", x = localStorage.getItem("clone67ChatSessionId"), g = {
6
6
  position: "fixed",
7
7
  bottom: "32px",
8
- left: i,
9
- right: s,
10
- background: `linear-gradient(135deg, ${n.primaryColor}, ${n.secondaryColor})`,
11
- color: n.fontColor,
8
+ left: d,
9
+ right: p,
10
+ background: `linear-gradient(135deg, ${s.primaryColor}, ${s.secondaryColor})`,
11
+ color: s.fontColor,
12
12
  width: "64px",
13
13
  height: "64px",
14
14
  borderRadius: "50%",
@@ -22,14 +22,14 @@ const At = ({ onMinimise: e, isOpen: t, theme: n, chatBotData: r }) => {
22
22
  transition: "all 300ms ease",
23
23
  outline: "none"
24
24
  };
25
- return /* @__PURE__ */ F(
25
+ return /* @__PURE__ */ u(
26
26
  "button",
27
27
  {
28
- onClick: e,
29
- style: p,
28
+ onClick: t,
29
+ style: g,
30
30
  children: [
31
- t ? /* @__PURE__ */ y(Ct, { size: 20, strokeWidth: 2.5 }) : /* @__PURE__ */ y(Xe, { size: 20, strokeWidth: 2.5 }),
32
- !t && l && /* @__PURE__ */ y("span", { style: {
31
+ e ? /* @__PURE__ */ o($, { size: 20, strokeWidth: 2.5 }) : /* @__PURE__ */ o(D, { size: 20, strokeWidth: 2.5 }),
32
+ !e && x && /* @__PURE__ */ o("span", { style: {
33
33
  position: "absolute",
34
34
  top: "-4px",
35
35
  right: "-4px",
@@ -43,2229 +43,231 @@ const At = ({ onMinimise: e, isOpen: t, theme: n, chatBotData: r }) => {
43
43
  ]
44
44
  }
45
45
  );
46
- }, kt = ({ onSendMessage: e, isLoading: t, theme: n }) => {
47
- const [r, o] = I(""), i = () => {
48
- !r.trim() || t || (e(r.trim()), o(""));
49
- }, s = (d) => {
50
- d.key === "Enter" && !d.shiftKey && (d.preventDefault(), i());
51
- }, l = {
52
- padding: "16px",
53
- borderTop: "1px solid rgba(255, 255, 255, 0.2)",
54
- borderColor: n.fontColor,
55
- background: n.backgroundColor,
56
- flexShrink: 0
57
- }, p = {
58
- display: "flex",
59
- gap: "12px",
60
- alignItems: "center"
61
- }, u = {
62
- flex: 1,
63
- padding: "12px 16px",
64
- background: n.inputBackgroundColor || n.backgroundColor,
65
- color: n.fontColor,
66
- border: `1px solid ${n.fontColor}`,
67
- borderRadius: "12px",
68
- fontSize: "14px",
69
- outline: "none",
70
- transition: "all 0.2s ease",
71
- opacity: t ? 0.5 : 1,
72
- cursor: t ? "not-allowed" : "text",
73
- boxShadow: "none"
74
- }, c = {
75
- padding: "12px 20px",
76
- borderRadius: "12px",
77
- background: `linear-gradient(135deg, ${n.primaryColor}, ${n.secondaryColor})`,
78
- color: n.fontColor,
79
- border: "none",
80
- cursor: t || !r.trim() ? "not-allowed" : "pointer",
81
- opacity: t || !r.trim() ? 0.5 : 1,
82
- display: "flex",
83
- alignItems: "center",
84
- justifyContent: "center",
85
- gap: "8px",
86
- fontWeight: "600",
87
- fontSize: "14px",
88
- transition: "all 0.2s ease",
89
- minWidth: "48px"
90
- };
91
- return /* @__PURE__ */ y("div", { style: l, children: /* @__PURE__ */ F("div", { style: p, children: [
92
- /* @__PURE__ */ y(
93
- "input",
94
- {
95
- type: "text",
96
- placeholder: "Type a message...",
97
- value: r,
98
- onChange: (d) => o(d.target.value),
99
- onKeyDown: s,
100
- disabled: t,
101
- style: u,
102
- onFocus: (d) => {
103
- d.target.style.boxShadow = "0 0 0 3px rgba(100, 150, 255, 0.3)", d.target.style.borderColor = "#60a5fa";
104
- },
105
- onBlur: (d) => {
106
- d.target.style.boxShadow = "none", d.target.style.borderColor = n.fontColor;
107
- }
108
- }
109
- ),
110
- /* @__PURE__ */ y(
111
- "button",
112
- {
113
- onClick: i,
114
- disabled: t || !r.trim(),
115
- style: c,
116
- "aria-label": "Send message",
117
- onMouseEnter: (d) => {
118
- !t && r.trim() && (d.currentTarget.style.transform = "translateY(-2px)", d.currentTarget.style.boxShadow = "0 8px 16px rgba(0,0,0,0.15)");
119
- },
120
- onMouseLeave: (d) => {
121
- d.currentTarget.style.transform = "translateY(0)", d.currentTarget.style.boxShadow = "none";
122
- },
123
- children: /* @__PURE__ */ y(Ge, { size: 18 })
124
- }
125
- )
126
- ] }) });
127
- }, Ft = ({ messages: e, isLoading: t, theme: n }) => {
128
- console.log("messages", e);
129
- const r = Et(null), o = () => {
130
- r.current?.scrollIntoView({ behavior: "smooth" });
131
- };
132
- function i(d) {
133
- return new Date(d).toLocaleString("en-AU", {
134
- day: "numeric",
135
- month: "short",
136
- year: "numeric",
137
- hour: "2-digit",
138
- minute: "2-digit"
139
- });
140
- }
141
- Ke(() => {
142
- o();
143
- }, [e, t]);
144
- const s = {
145
- flex: 1,
46
+ }, a = [];
47
+ for (let t = 0; t < 256; ++t)
48
+ a.push((t + 256).toString(16).slice(1));
49
+ function N(t, e = 0) {
50
+ return (a[t[e + 0]] + a[t[e + 1]] + a[t[e + 2]] + a[t[e + 3]] + "-" + a[t[e + 4]] + a[t[e + 5]] + "-" + a[t[e + 6]] + a[t[e + 7]] + "-" + a[t[e + 8]] + a[t[e + 9]] + "-" + a[t[e + 10]] + a[t[e + 11]] + a[t[e + 12]] + a[t[e + 13]] + a[t[e + 14]] + a[t[e + 15]]).toLowerCase();
51
+ }
52
+ let R;
53
+ const _ = new Uint8Array(16);
54
+ function H() {
55
+ if (!R) {
56
+ if (typeof crypto > "u" || !crypto.getRandomValues)
57
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
58
+ R = crypto.getRandomValues.bind(crypto);
59
+ }
60
+ return R(_);
61
+ }
62
+ const V = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), E = { randomUUID: V };
63
+ function A(t, e, s) {
64
+ t = t || {};
65
+ const i = t.random ?? t.rng?.() ?? H();
66
+ if (i.length < 16)
67
+ throw new Error("Random bytes length must be >= 16");
68
+ return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, N(i);
69
+ }
70
+ function J(t, e, s) {
71
+ return E.randomUUID && !t ? E.randomUUID() : A(t);
72
+ }
73
+ const P = ({ messages: t, chatBotData: e, theme: s, isLoading: i }) => {
74
+ const [f, d] = S([]), p = L(null), x = (r) => {
75
+ if (r === "") return null;
76
+ try {
77
+ return JSON.parse(r);
78
+ } catch (y) {
79
+ return console.error("Error parsing message string to JSON:", y), null;
80
+ }
81
+ }, g = (r) => new Date(r).toLocaleString(void 0, {
82
+ hour: "2-digit",
83
+ minute: "2-digit",
84
+ hour12: !0
85
+ });
86
+ T(() => {
87
+ const r = x(t);
88
+ r && d((y) => [...y, r]);
89
+ }, [t]), T(() => {
90
+ p.current?.scrollIntoView({ behavior: "smooth" });
91
+ }, [f]);
92
+ const m = f.flat(), h = {
93
+ height: "290px",
146
94
  overflowY: "auto",
147
95
  padding: "20px",
148
- background: n.backgroundColor,
149
- color: n.fontColor,
96
+ background: s.backgroundColor,
97
+ color: s.fontColor,
150
98
  borderTop: "1px solid rgba(255, 255, 255, 0.2)",
151
99
  display: "flex",
152
100
  flexDirection: "column",
153
101
  gap: "16px"
154
- }, l = (d) => ({
102
+ }, c = (r) => ({
155
103
  display: "flex",
156
- justifyContent: d === "user" ? "flex-end" : "flex-start",
104
+ justifyContent: r === "user" ? "flex-end" : "flex-start",
157
105
  width: "100%"
158
- }), p = {
106
+ }), C = {
159
107
  display: "flex",
160
108
  flexDirection: "column",
161
109
  maxWidth: "80%"
162
- }, u = (d) => ({
110
+ }, b = (r) => ({
163
111
  padding: "12px 16px",
164
- borderRadius: "16px",
112
+ borderRadius: r === "user" ? "16px 0 16px 16px" : "0 16px 16px 16px",
165
113
  boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
166
- border: "1px solid #e4e4e7",
167
114
  fontSize: "14px",
168
115
  lineHeight: "1.5",
169
- background: d === "user" ? n.primaryColor : n.backgroundColor,
170
- color: n.fontColor,
116
+ background: r === "user" ? s.primaryColor : "#f5f5f5",
117
+ color: s.fontColor,
171
118
  wordWrap: "break-word"
172
- }), c = {
173
- ...u("bot"),
119
+ }), v = {
120
+ ...b("bot"),
174
121
  animation: "fadeIn 0.3s ease-in-out, pulse 1.5s ease-in-out infinite",
175
122
  animationDelay: "0s, 0.3s"
176
123
  };
177
- return /* @__PURE__ */ F("div", { style: s, children: [
178
- e.map((d, b) => /* @__PURE__ */ y("div", { style: l(d.sender_type), children: /* @__PURE__ */ F("div", { style: p, children: [
179
- d.sender_type === "bot" && d.created_at && /* @__PURE__ */ F("div", { style: { display: "flex", alignItems: "center", gap: "4px", justifyContent: "flex-start", marginLeft: "4px", marginBottom: "2px" }, children: [
180
- /* @__PURE__ */ y(Ne, { size: 14, color: n.fontColor }),
181
- /* @__PURE__ */ y(
182
- "span",
183
- {
184
- style: {
185
- fontSize: "10px",
186
- opacity: 0.55,
187
- color: n.fontColor
188
- },
189
- children: i(d.created_at)
190
- }
191
- )
192
- ] }),
193
- d.sender_type === "user" && /* @__PURE__ */ y("div", { style: { display: "flex", alignItems: "center", gap: "4px", justifyContent: "flex-end", marginRight: "4px", marginBottom: "2px" }, children: /* @__PURE__ */ y(
194
- "span",
195
- {
196
- style: {
197
- fontSize: "10px",
198
- opacity: 0.55,
199
- color: n.fontColor
200
- },
201
- children: "You"
202
- }
203
- ) }),
204
- /* @__PURE__ */ y("div", { style: u(d.sender_type), children: d.message })
205
- ] }) }, b)),
206
- t && /* @__PURE__ */ y("div", { style: l("bot"), children: /* @__PURE__ */ F("div", { style: {
207
- ...c,
208
- display: "flex",
209
- alignItems: "center",
210
- gap: "8px"
211
- }, children: [
212
- /* @__PURE__ */ y(Ne, { size: 24 }),
213
- /* @__PURE__ */ y("span", { children: "Typing..." })
214
- ] }) }),
215
- /* @__PURE__ */ y("div", { ref: r })
124
+ return /* @__PURE__ */ u("div", { style: h, children: [
125
+ m.map((r, y) => /* @__PURE__ */ o("div", { style: c(r.sender_type), children: /* @__PURE__ */ u("div", { style: C, children: [
126
+ /* @__PURE__ */ o("div", { style: {
127
+ display: "flex",
128
+ alignItems: "center",
129
+ gap: "4px",
130
+ justifyContent: r.sender_type === "user" ? "flex-end" : "flex-start",
131
+ marginRight: "4px",
132
+ marginBottom: "2px"
133
+ }, children: /* @__PURE__ */ o("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor }, children: r.sender_type === "user" ? "You" : `${e.name}` }) }),
134
+ /* @__PURE__ */ o("div", { style: r.sender_type === "user" ? b("user") : b("ai"), children: r.message }),
135
+ /* @__PURE__ */ o("span", { style: { fontSize: "10px", opacity: 0.55, color: s.fontColor, alignSelf: r.sender_type === "user" ? "flex-end" : "flex-start", marginTop: "4px" }, children: `${g(r.created_at)}` })
136
+ ] }) }, y)),
137
+ i && /* @__PURE__ */ o("div", { style: v, children: "Typing..." }),
138
+ /* @__PURE__ */ o("div", { ref: p })
216
139
  ] });
217
- };
218
- function Ye(e, t) {
219
- return function() {
220
- return e.apply(t, arguments);
221
- };
222
- }
223
- const { toString: Pt } = Object.prototype, { getPrototypeOf: Te } = Object, { iterator: fe, toStringTag: Qe } = Symbol, pe = /* @__PURE__ */ ((e) => (t) => {
224
- const n = Pt.call(t);
225
- return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
226
- })(/* @__PURE__ */ Object.create(null)), L = (e) => (e = e.toLowerCase(), (t) => pe(t) === e), he = (e) => (t) => typeof t === e, { isArray: X } = Array, K = he("undefined");
227
- function ee(e) {
228
- return e !== null && !K(e) && e.constructor !== null && !K(e.constructor) && _(e.constructor.isBuffer) && e.constructor.isBuffer(e);
229
- }
230
- const Ze = L("ArrayBuffer");
231
- function Nt(e) {
232
- let t;
233
- return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && Ze(e.buffer), t;
234
- }
235
- const _t = he("string"), _ = he("function"), et = he("number"), te = (e) => e !== null && typeof e == "object", Ut = (e) => e === !0 || e === !1, le = (e) => {
236
- if (pe(e) !== "object")
237
- return !1;
238
- const t = Te(e);
239
- return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Qe in e) && !(fe in e);
240
- }, It = (e) => {
241
- if (!te(e) || ee(e))
242
- return !1;
243
- try {
244
- return Object.keys(e).length === 0 && Object.getPrototypeOf(e) === Object.prototype;
245
- } catch {
246
- return !1;
247
- }
248
- }, Lt = L("Date"), Dt = L("File"), Bt = L("Blob"), jt = L("FileList"), vt = (e) => te(e) && _(e.pipe), zt = (e) => {
249
- let t;
250
- return e && (typeof FormData == "function" && e instanceof FormData || _(e.append) && ((t = pe(e)) === "formdata" || // detect form-data instance
251
- t === "object" && _(e.toString) && e.toString() === "[object FormData]"));
252
- }, Ht = L("URLSearchParams"), [Mt, qt, $t, Wt] = ["ReadableStream", "Request", "Response", "Headers"].map(L), Jt = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
253
- function ne(e, t, { allOwnKeys: n = !1 } = {}) {
254
- if (e === null || typeof e > "u")
255
- return;
256
- let r, o;
257
- if (typeof e != "object" && (e = [e]), X(e))
258
- for (r = 0, o = e.length; r < o; r++)
259
- t.call(null, e[r], r, e);
260
- else {
261
- if (ee(e))
262
- return;
263
- const i = n ? Object.getOwnPropertyNames(e) : Object.keys(e), s = i.length;
264
- let l;
265
- for (r = 0; r < s; r++)
266
- l = i[r], t.call(null, e[l], l, e);
267
- }
268
- }
269
- function tt(e, t) {
270
- if (ee(e))
271
- return null;
272
- t = t.toLowerCase();
273
- const n = Object.keys(e);
274
- let r = n.length, o;
275
- for (; r-- > 0; )
276
- if (o = n[r], t === o.toLowerCase())
277
- return o;
278
- return null;
279
- }
280
- const M = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, nt = (e) => !K(e) && e !== M;
281
- function Se() {
282
- const { caseless: e, skipUndefined: t } = nt(this) && this || {}, n = {}, r = (o, i) => {
283
- const s = e && tt(n, i) || i;
284
- le(n[s]) && le(o) ? n[s] = Se(n[s], o) : le(o) ? n[s] = Se({}, o) : X(o) ? n[s] = o.slice() : (!t || !K(o)) && (n[s] = o);
285
- };
286
- for (let o = 0, i = arguments.length; o < i; o++)
287
- arguments[o] && ne(arguments[o], r);
288
- return n;
289
- }
290
- const Vt = (e, t, n, { allOwnKeys: r } = {}) => (ne(t, (o, i) => {
291
- n && _(o) ? e[i] = Ye(o, n) : e[i] = o;
292
- }, { allOwnKeys: r }), e), Kt = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), Xt = (e, t, n, r) => {
293
- e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", {
294
- value: t.prototype
295
- }), n && Object.assign(e.prototype, n);
296
- }, Gt = (e, t, n, r) => {
297
- let o, i, s;
298
- const l = {};
299
- if (t = t || {}, e == null) return t;
300
- do {
301
- for (o = Object.getOwnPropertyNames(e), i = o.length; i-- > 0; )
302
- s = o[i], (!r || r(s, e, t)) && !l[s] && (t[s] = e[s], l[s] = !0);
303
- e = n !== !1 && Te(e);
304
- } while (e && (!n || n(e, t)) && e !== Object.prototype);
305
- return t;
306
- }, Yt = (e, t, n) => {
307
- e = String(e), (n === void 0 || n > e.length) && (n = e.length), n -= t.length;
308
- const r = e.indexOf(t, n);
309
- return r !== -1 && r === n;
310
- }, Qt = (e) => {
311
- if (!e) return null;
312
- if (X(e)) return e;
313
- let t = e.length;
314
- if (!et(t)) return null;
315
- const n = new Array(t);
316
- for (; t-- > 0; )
317
- n[t] = e[t];
318
- return n;
319
- }, Zt = /* @__PURE__ */ ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && Te(Uint8Array)), en = (e, t) => {
320
- const r = (e && e[fe]).call(e);
321
- let o;
322
- for (; (o = r.next()) && !o.done; ) {
323
- const i = o.value;
324
- t.call(e, i[0], i[1]);
325
- }
326
- }, tn = (e, t) => {
327
- let n;
328
- const r = [];
329
- for (; (n = e.exec(t)) !== null; )
330
- r.push(n);
331
- return r;
332
- }, nn = L("HTMLFormElement"), rn = (e) => e.toLowerCase().replace(
333
- /[-_\s]([a-z\d])(\w*)/g,
334
- function(n, r, o) {
335
- return r.toUpperCase() + o;
336
- }
337
- ), _e = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), on = L("RegExp"), rt = (e, t) => {
338
- const n = Object.getOwnPropertyDescriptors(e), r = {};
339
- ne(n, (o, i) => {
340
- let s;
341
- (s = t(o, i, e)) !== !1 && (r[i] = s || o);
342
- }), Object.defineProperties(e, r);
343
- }, sn = (e) => {
344
- rt(e, (t, n) => {
345
- if (_(e) && ["arguments", "caller", "callee"].indexOf(n) !== -1)
346
- return !1;
347
- const r = e[n];
348
- if (_(r)) {
349
- if (t.enumerable = !1, "writable" in t) {
350
- t.writable = !1;
351
- return;
352
- }
353
- t.set || (t.set = () => {
354
- throw Error("Can not rewrite read-only method '" + n + "'");
355
- });
356
- }
357
- });
358
- }, an = (e, t) => {
359
- const n = {}, r = (o) => {
360
- o.forEach((i) => {
361
- n[i] = !0;
362
- });
363
- };
364
- return X(e) ? r(e) : r(String(e).split(t)), n;
365
- }, ln = () => {
366
- }, cn = (e, t) => e != null && Number.isFinite(e = +e) ? e : t;
367
- function un(e) {
368
- return !!(e && _(e.append) && e[Qe] === "FormData" && e[fe]);
369
- }
370
- const dn = (e) => {
371
- const t = new Array(10), n = (r, o) => {
372
- if (te(r)) {
373
- if (t.indexOf(r) >= 0)
374
- return;
375
- if (ee(r))
376
- return r;
377
- if (!("toJSON" in r)) {
378
- t[o] = r;
379
- const i = X(r) ? [] : {};
380
- return ne(r, (s, l) => {
381
- const p = n(s, o + 1);
382
- !K(p) && (i[l] = p);
383
- }), t[o] = void 0, i;
384
- }
385
- }
386
- return r;
387
- };
388
- return n(e, 0);
389
- }, fn = L("AsyncFunction"), pn = (e) => e && (te(e) || _(e)) && _(e.then) && _(e.catch), ot = ((e, t) => e ? setImmediate : t ? ((n, r) => (M.addEventListener("message", ({ source: o, data: i }) => {
390
- o === M && i === n && r.length && r.shift()();
391
- }, !1), (o) => {
392
- r.push(o), M.postMessage(n, "*");
393
- }))(`axios@${Math.random()}`, []) : (n) => setTimeout(n))(
394
- typeof setImmediate == "function",
395
- _(M.postMessage)
396
- ), hn = typeof queueMicrotask < "u" ? queueMicrotask.bind(M) : typeof process < "u" && process.nextTick || ot, mn = (e) => e != null && _(e[fe]), a = {
397
- isArray: X,
398
- isArrayBuffer: Ze,
399
- isBuffer: ee,
400
- isFormData: zt,
401
- isArrayBufferView: Nt,
402
- isString: _t,
403
- isNumber: et,
404
- isBoolean: Ut,
405
- isObject: te,
406
- isPlainObject: le,
407
- isEmptyObject: It,
408
- isReadableStream: Mt,
409
- isRequest: qt,
410
- isResponse: $t,
411
- isHeaders: Wt,
412
- isUndefined: K,
413
- isDate: Lt,
414
- isFile: Dt,
415
- isBlob: Bt,
416
- isRegExp: on,
417
- isFunction: _,
418
- isStream: vt,
419
- isURLSearchParams: Ht,
420
- isTypedArray: Zt,
421
- isFileList: jt,
422
- forEach: ne,
423
- merge: Se,
424
- extend: Vt,
425
- trim: Jt,
426
- stripBOM: Kt,
427
- inherits: Xt,
428
- toFlatObject: Gt,
429
- kindOf: pe,
430
- kindOfTest: L,
431
- endsWith: Yt,
432
- toArray: Qt,
433
- forEachEntry: en,
434
- matchAll: tn,
435
- isHTMLForm: nn,
436
- hasOwnProperty: _e,
437
- hasOwnProp: _e,
438
- // an alias to avoid ESLint no-prototype-builtins detection
439
- reduceDescriptors: rt,
440
- freezeMethods: sn,
441
- toObjectSet: an,
442
- toCamelCase: rn,
443
- noop: ln,
444
- toFiniteNumber: cn,
445
- findKey: tt,
446
- global: M,
447
- isContextDefined: nt,
448
- isSpecCompliantForm: un,
449
- toJSONObject: dn,
450
- isAsyncFn: fn,
451
- isThenable: pn,
452
- setImmediate: ot,
453
- asap: hn,
454
- isIterable: mn
455
- };
456
- function g(e, t, n, r, o) {
457
- Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = new Error().stack, this.message = e, this.name = "AxiosError", t && (this.code = t), n && (this.config = n), r && (this.request = r), o && (this.response = o, this.status = o.status ? o.status : null);
458
- }
459
- a.inherits(g, Error, {
460
- toJSON: function() {
461
- return {
462
- // Standard
463
- message: this.message,
464
- name: this.name,
465
- // Microsoft
466
- description: this.description,
467
- number: this.number,
468
- // Mozilla
469
- fileName: this.fileName,
470
- lineNumber: this.lineNumber,
471
- columnNumber: this.columnNumber,
472
- stack: this.stack,
473
- // Axios
474
- config: a.toJSONObject(this.config),
475
- code: this.code,
476
- status: this.status
477
- };
478
- }
479
- });
480
- const st = g.prototype, it = {};
481
- [
482
- "ERR_BAD_OPTION_VALUE",
483
- "ERR_BAD_OPTION",
484
- "ECONNABORTED",
485
- "ETIMEDOUT",
486
- "ERR_NETWORK",
487
- "ERR_FR_TOO_MANY_REDIRECTS",
488
- "ERR_DEPRECATED",
489
- "ERR_BAD_RESPONSE",
490
- "ERR_BAD_REQUEST",
491
- "ERR_CANCELED",
492
- "ERR_NOT_SUPPORT",
493
- "ERR_INVALID_URL"
494
- // eslint-disable-next-line func-names
495
- ].forEach((e) => {
496
- it[e] = { value: e };
497
- });
498
- Object.defineProperties(g, it);
499
- Object.defineProperty(st, "isAxiosError", { value: !0 });
500
- g.from = (e, t, n, r, o, i) => {
501
- const s = Object.create(st);
502
- a.toFlatObject(e, s, function(c) {
503
- return c !== Error.prototype;
504
- }, (u) => u !== "isAxiosError");
505
- const l = e && e.message ? e.message : "Error", p = t == null && e ? e.code : t;
506
- return g.call(s, l, p, n, r, o), e && s.cause == null && Object.defineProperty(s, "cause", { value: e, configurable: !0 }), s.name = e && e.name || "Error", i && Object.assign(s, i), s;
507
- };
508
- const yn = null;
509
- function Ee(e) {
510
- return a.isPlainObject(e) || a.isArray(e);
511
- }
512
- function at(e) {
513
- return a.endsWith(e, "[]") ? e.slice(0, -2) : e;
514
- }
515
- function Ue(e, t, n) {
516
- return e ? e.concat(t).map(function(o, i) {
517
- return o = at(o), !n && i ? "[" + o + "]" : o;
518
- }).join(n ? "." : "") : t;
519
- }
520
- function gn(e) {
521
- return a.isArray(e) && !e.some(Ee);
522
- }
523
- const bn = a.toFlatObject(a, {}, null, function(t) {
524
- return /^is[A-Z]/.test(t);
525
- });
526
- function me(e, t, n) {
527
- if (!a.isObject(e))
528
- throw new TypeError("target must be an object");
529
- t = t || new FormData(), n = a.toFlatObject(n, {
530
- metaTokens: !0,
531
- dots: !1,
532
- indexes: !1
533
- }, !1, function(m, h) {
534
- return !a.isUndefined(h[m]);
535
- });
536
- const r = n.metaTokens, o = n.visitor || c, i = n.dots, s = n.indexes, p = (n.Blob || typeof Blob < "u" && Blob) && a.isSpecCompliantForm(t);
537
- if (!a.isFunction(o))
538
- throw new TypeError("visitor must be a function");
539
- function u(f) {
540
- if (f === null) return "";
541
- if (a.isDate(f))
542
- return f.toISOString();
543
- if (a.isBoolean(f))
544
- return f.toString();
545
- if (!p && a.isBlob(f))
546
- throw new g("Blob is not supported. Use a Buffer instead.");
547
- return a.isArrayBuffer(f) || a.isTypedArray(f) ? p && typeof Blob == "function" ? new Blob([f]) : Buffer.from(f) : f;
548
- }
549
- function c(f, m, h) {
550
- let w = f;
551
- if (f && !h && typeof f == "object") {
552
- if (a.endsWith(m, "{}"))
553
- m = r ? m : m.slice(0, -2), f = JSON.stringify(f);
554
- else if (a.isArray(f) && gn(f) || (a.isFileList(f) || a.endsWith(m, "[]")) && (w = a.toArray(f)))
555
- return m = at(m), w.forEach(function(x, k) {
556
- !(a.isUndefined(x) || x === null) && t.append(
557
- // eslint-disable-next-line no-nested-ternary
558
- s === !0 ? Ue([m], k, i) : s === null ? m : m + "[]",
559
- u(x)
560
- );
561
- }), !1;
562
- }
563
- return Ee(f) ? !0 : (t.append(Ue(h, m, i), u(f)), !1);
564
- }
565
- const d = [], b = Object.assign(bn, {
566
- defaultVisitor: c,
567
- convertValue: u,
568
- isVisitable: Ee
569
- });
570
- function C(f, m) {
571
- if (!a.isUndefined(f)) {
572
- if (d.indexOf(f) !== -1)
573
- throw Error("Circular reference detected in " + m.join("."));
574
- d.push(f), a.forEach(f, function(w, A) {
575
- (!(a.isUndefined(w) || w === null) && o.call(
576
- t,
577
- w,
578
- a.isString(A) ? A.trim() : A,
579
- m,
580
- b
581
- )) === !0 && C(w, m ? m.concat(A) : [A]);
582
- }), d.pop();
583
- }
584
- }
585
- if (!a.isObject(e))
586
- throw new TypeError("data must be an object");
587
- return C(e), t;
588
- }
589
- function Ie(e) {
590
- const t = {
591
- "!": "%21",
592
- "'": "%27",
593
- "(": "%28",
594
- ")": "%29",
595
- "~": "%7E",
596
- "%20": "+",
597
- "%00": "\0"
598
- };
599
- return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, function(r) {
600
- return t[r];
601
- });
602
- }
603
- function Oe(e, t) {
604
- this._pairs = [], e && me(e, this, t);
605
- }
606
- const lt = Oe.prototype;
607
- lt.append = function(t, n) {
608
- this._pairs.push([t, n]);
609
- };
610
- lt.toString = function(t) {
611
- const n = t ? function(r) {
612
- return t.call(this, r, Ie);
613
- } : Ie;
614
- return this._pairs.map(function(o) {
615
- return n(o[0]) + "=" + n(o[1]);
616
- }, "").join("&");
617
- };
618
- function xn(e) {
619
- return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
620
- }
621
- function ct(e, t, n) {
622
- if (!t)
623
- return e;
624
- const r = n && n.encode || xn;
625
- a.isFunction(n) && (n = {
626
- serialize: n
627
- });
628
- const o = n && n.serialize;
629
- let i;
630
- if (o ? i = o(t, n) : i = a.isURLSearchParams(t) ? t.toString() : new Oe(t, n).toString(r), i) {
631
- const s = e.indexOf("#");
632
- s !== -1 && (e = e.slice(0, s)), e += (e.indexOf("?") === -1 ? "?" : "&") + i;
633
- }
634
- return e;
635
- }
636
- class Le {
637
- constructor() {
638
- this.handlers = [];
639
- }
640
- /**
641
- * Add a new interceptor to the stack
642
- *
643
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
644
- * @param {Function} rejected The function to handle `reject` for a `Promise`
645
- *
646
- * @return {Number} An ID used to remove interceptor later
647
- */
648
- use(t, n, r) {
649
- return this.handlers.push({
650
- fulfilled: t,
651
- rejected: n,
652
- synchronous: r ? r.synchronous : !1,
653
- runWhen: r ? r.runWhen : null
654
- }), this.handlers.length - 1;
655
- }
656
- /**
657
- * Remove an interceptor from the stack
658
- *
659
- * @param {Number} id The ID that was returned by `use`
660
- *
661
- * @returns {void}
662
- */
663
- eject(t) {
664
- this.handlers[t] && (this.handlers[t] = null);
665
- }
666
- /**
667
- * Clear all interceptors from the stack
668
- *
669
- * @returns {void}
670
- */
671
- clear() {
672
- this.handlers && (this.handlers = []);
673
- }
674
- /**
675
- * Iterate over all the registered interceptors
676
- *
677
- * This method is particularly useful for skipping over any
678
- * interceptors that may have become `null` calling `eject`.
679
- *
680
- * @param {Function} fn The function to call for each interceptor
681
- *
682
- * @returns {void}
683
- */
684
- forEach(t) {
685
- a.forEach(this.handlers, function(r) {
686
- r !== null && t(r);
687
- });
688
- }
689
- }
690
- const ut = {
691
- silentJSONParsing: !0,
692
- forcedJSONParsing: !0,
693
- clarifyTimeoutError: !1
694
- }, wn = typeof URLSearchParams < "u" ? URLSearchParams : Oe, Sn = typeof FormData < "u" ? FormData : null, En = typeof Blob < "u" ? Blob : null, Cn = {
695
- isBrowser: !0,
696
- classes: {
697
- URLSearchParams: wn,
698
- FormData: Sn,
699
- Blob: En
700
- },
701
- protocols: ["http", "https", "file", "blob", "url", "data"]
702
- }, Ae = typeof window < "u" && typeof document < "u", Ce = typeof navigator == "object" && navigator || void 0, Rn = Ae && (!Ce || ["ReactNative", "NativeScript", "NS"].indexOf(Ce.product) < 0), Tn = typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
703
- self instanceof WorkerGlobalScope && typeof self.importScripts == "function", On = Ae && window.location.href || "http://localhost", An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
704
- __proto__: null,
705
- hasBrowserEnv: Ae,
706
- hasStandardBrowserEnv: Rn,
707
- hasStandardBrowserWebWorkerEnv: Tn,
708
- navigator: Ce,
709
- origin: On
710
- }, Symbol.toStringTag, { value: "Module" })), N = {
711
- ...An,
712
- ...Cn
713
- };
714
- function kn(e, t) {
715
- return me(e, new N.classes.URLSearchParams(), {
716
- visitor: function(n, r, o, i) {
717
- return N.isNode && a.isBuffer(n) ? (this.append(r, n.toString("base64")), !1) : i.defaultVisitor.apply(this, arguments);
718
- },
719
- ...t
720
- });
721
- }
722
- function Fn(e) {
723
- return a.matchAll(/\w+|\[(\w*)]/g, e).map((t) => t[0] === "[]" ? "" : t[1] || t[0]);
724
- }
725
- function Pn(e) {
726
- const t = {}, n = Object.keys(e);
727
- let r;
728
- const o = n.length;
729
- let i;
730
- for (r = 0; r < o; r++)
731
- i = n[r], t[i] = e[i];
732
- return t;
733
- }
734
- function dt(e) {
735
- function t(n, r, o, i) {
736
- let s = n[i++];
737
- if (s === "__proto__") return !0;
738
- const l = Number.isFinite(+s), p = i >= n.length;
739
- return s = !s && a.isArray(o) ? o.length : s, p ? (a.hasOwnProp(o, s) ? o[s] = [o[s], r] : o[s] = r, !l) : ((!o[s] || !a.isObject(o[s])) && (o[s] = []), t(n, r, o[s], i) && a.isArray(o[s]) && (o[s] = Pn(o[s])), !l);
740
- }
741
- if (a.isFormData(e) && a.isFunction(e.entries)) {
742
- const n = {};
743
- return a.forEachEntry(e, (r, o) => {
744
- t(Fn(r), o, n, 0);
745
- }), n;
746
- }
747
- return null;
748
- }
749
- function Nn(e, t, n) {
750
- if (a.isString(e))
751
- try {
752
- return (t || JSON.parse)(e), a.trim(e);
753
- } catch (r) {
754
- if (r.name !== "SyntaxError")
755
- throw r;
756
- }
757
- return (n || JSON.stringify)(e);
758
- }
759
- const re = {
760
- transitional: ut,
761
- adapter: ["xhr", "http", "fetch"],
762
- transformRequest: [function(t, n) {
763
- const r = n.getContentType() || "", o = r.indexOf("application/json") > -1, i = a.isObject(t);
764
- if (i && a.isHTMLForm(t) && (t = new FormData(t)), a.isFormData(t))
765
- return o ? JSON.stringify(dt(t)) : t;
766
- if (a.isArrayBuffer(t) || a.isBuffer(t) || a.isStream(t) || a.isFile(t) || a.isBlob(t) || a.isReadableStream(t))
767
- return t;
768
- if (a.isArrayBufferView(t))
769
- return t.buffer;
770
- if (a.isURLSearchParams(t))
771
- return n.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), t.toString();
772
- let l;
773
- if (i) {
774
- if (r.indexOf("application/x-www-form-urlencoded") > -1)
775
- return kn(t, this.formSerializer).toString();
776
- if ((l = a.isFileList(t)) || r.indexOf("multipart/form-data") > -1) {
777
- const p = this.env && this.env.FormData;
778
- return me(
779
- l ? { "files[]": t } : t,
780
- p && new p(),
781
- this.formSerializer
782
- );
783
- }
784
- }
785
- return i || o ? (n.setContentType("application/json", !1), Nn(t)) : t;
786
- }],
787
- transformResponse: [function(t) {
788
- const n = this.transitional || re.transitional, r = n && n.forcedJSONParsing, o = this.responseType === "json";
789
- if (a.isResponse(t) || a.isReadableStream(t))
790
- return t;
791
- if (t && a.isString(t) && (r && !this.responseType || o)) {
792
- const s = !(n && n.silentJSONParsing) && o;
140
+ }, Y = (t, e) => ({ socket: new WebSocket(`wss://handle-chat-session.clone67.com?chatbotNamespace=${e}&sessionId=${t}`) }), K = ({ chatBotData: t, theme: e, onlineStatus: s }) => {
141
+ const [i, f] = S(null), [d, p] = S(""), [x, g] = S("Connecting to server..."), [m, h] = S(""), [c, C] = S(!1);
142
+ T(() => {
143
+ var n = localStorage.getItem("clone67ChatSessionId");
144
+ n === null && (n = J(), localStorage.setItem("clone67ChatSessionId", n));
145
+ const { socket: l } = Y(n, t.pineconeNamespace);
146
+ f(l), l.onopen = () => {
147
+ g("Server connected"), setTimeout(() => {
148
+ g("");
149
+ }, 2e3), s("online");
150
+ }, l.onmessage = async (I) => {
151
+ C(!0);
793
152
  try {
794
- return JSON.parse(t, this.parseReviver);
795
- } catch (l) {
796
- if (s)
797
- throw l.name === "SyntaxError" ? g.from(l, g.ERR_BAD_RESPONSE, this, null, this.response) : l;
798
- }
799
- }
800
- return t;
801
- }],
802
- /**
803
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
804
- * timeout is not created.
805
- */
806
- timeout: 0,
807
- xsrfCookieName: "XSRF-TOKEN",
808
- xsrfHeaderName: "X-XSRF-TOKEN",
809
- maxContentLength: -1,
810
- maxBodyLength: -1,
811
- env: {
812
- FormData: N.classes.FormData,
813
- Blob: N.classes.Blob
814
- },
815
- validateStatus: function(t) {
816
- return t >= 200 && t < 300;
817
- },
818
- headers: {
819
- common: {
820
- Accept: "application/json, text/plain, */*",
821
- "Content-Type": void 0
822
- }
823
- }
824
- };
825
- a.forEach(["delete", "get", "head", "post", "put", "patch"], (e) => {
826
- re.headers[e] = {};
827
- });
828
- const _n = a.toObjectSet([
829
- "age",
830
- "authorization",
831
- "content-length",
832
- "content-type",
833
- "etag",
834
- "expires",
835
- "from",
836
- "host",
837
- "if-modified-since",
838
- "if-unmodified-since",
839
- "last-modified",
840
- "location",
841
- "max-forwards",
842
- "proxy-authorization",
843
- "referer",
844
- "retry-after",
845
- "user-agent"
846
- ]), Un = (e) => {
847
- const t = {};
848
- let n, r, o;
849
- return e && e.split(`
850
- `).forEach(function(s) {
851
- o = s.indexOf(":"), n = s.substring(0, o).trim().toLowerCase(), r = s.substring(o + 1).trim(), !(!n || t[n] && _n[n]) && (n === "set-cookie" ? t[n] ? t[n].push(r) : t[n] = [r] : t[n] = t[n] ? t[n] + ", " + r : r);
852
- }), t;
853
- }, De = /* @__PURE__ */ Symbol("internals");
854
- function Q(e) {
855
- return e && String(e).trim().toLowerCase();
856
- }
857
- function ce(e) {
858
- return e === !1 || e == null ? e : a.isArray(e) ? e.map(ce) : String(e);
859
- }
860
- function In(e) {
861
- const t = /* @__PURE__ */ Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
862
- let r;
863
- for (; r = n.exec(e); )
864
- t[r[1]] = r[2];
865
- return t;
866
- }
867
- const Ln = (e) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());
868
- function be(e, t, n, r, o) {
869
- if (a.isFunction(r))
870
- return r.call(this, t, n);
871
- if (o && (t = n), !!a.isString(t)) {
872
- if (a.isString(r))
873
- return t.indexOf(r) !== -1;
874
- if (a.isRegExp(r))
875
- return r.test(t);
876
- }
877
- }
878
- function Dn(e) {
879
- return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (t, n, r) => n.toUpperCase() + r);
880
- }
881
- function Bn(e, t) {
882
- const n = a.toCamelCase(" " + t);
883
- ["get", "set", "has"].forEach((r) => {
884
- Object.defineProperty(e, r + n, {
885
- value: function(o, i, s) {
886
- return this[r].call(this, t, o, i, s);
887
- },
888
- configurable: !0
889
- });
890
- });
891
- }
892
- let U = class {
893
- constructor(t) {
894
- t && this.set(t);
895
- }
896
- set(t, n, r) {
897
- const o = this;
898
- function i(l, p, u) {
899
- const c = Q(p);
900
- if (!c)
901
- throw new Error("header name must be a non-empty string");
902
- const d = a.findKey(o, c);
903
- (!d || o[d] === void 0 || u === !0 || u === void 0 && o[d] !== !1) && (o[d || p] = ce(l));
904
- }
905
- const s = (l, p) => a.forEach(l, (u, c) => i(u, c, p));
906
- if (a.isPlainObject(t) || t instanceof this.constructor)
907
- s(t, n);
908
- else if (a.isString(t) && (t = t.trim()) && !Ln(t))
909
- s(Un(t), n);
910
- else if (a.isObject(t) && a.isIterable(t)) {
911
- let l = {}, p, u;
912
- for (const c of t) {
913
- if (!a.isArray(c))
914
- throw TypeError("Object iterator must return a key-value pair");
915
- l[u = c[0]] = (p = l[u]) ? a.isArray(p) ? [...p, c[1]] : [p, c[1]] : c[1];
916
- }
917
- s(l, n);
918
- } else
919
- t != null && i(n, t, r);
920
- return this;
921
- }
922
- get(t, n) {
923
- if (t = Q(t), t) {
924
- const r = a.findKey(this, t);
925
- if (r) {
926
- const o = this[r];
927
- if (!n)
928
- return o;
929
- if (n === !0)
930
- return In(o);
931
- if (a.isFunction(n))
932
- return n.call(this, o, r);
933
- if (a.isRegExp(n))
934
- return n.exec(o);
935
- throw new TypeError("parser must be boolean|regexp|function");
936
- }
937
- }
938
- }
939
- has(t, n) {
940
- if (t = Q(t), t) {
941
- const r = a.findKey(this, t);
942
- return !!(r && this[r] !== void 0 && (!n || be(this, this[r], r, n)));
943
- }
944
- return !1;
945
- }
946
- delete(t, n) {
947
- const r = this;
948
- let o = !1;
949
- function i(s) {
950
- if (s = Q(s), s) {
951
- const l = a.findKey(r, s);
952
- l && (!n || be(r, r[l], l, n)) && (delete r[l], o = !0);
953
- }
954
- }
955
- return a.isArray(t) ? t.forEach(i) : i(t), o;
956
- }
957
- clear(t) {
958
- const n = Object.keys(this);
959
- let r = n.length, o = !1;
960
- for (; r--; ) {
961
- const i = n[r];
962
- (!t || be(this, this[i], i, t, !0)) && (delete this[i], o = !0);
963
- }
964
- return o;
965
- }
966
- normalize(t) {
967
- const n = this, r = {};
968
- return a.forEach(this, (o, i) => {
969
- const s = a.findKey(r, i);
970
- if (s) {
971
- n[s] = ce(o), delete n[i];
972
- return;
973
- }
974
- const l = t ? Dn(i) : String(i).trim();
975
- l !== i && delete n[i], n[l] = ce(o), r[l] = !0;
976
- }), this;
977
- }
978
- concat(...t) {
979
- return this.constructor.concat(this, ...t);
980
- }
981
- toJSON(t) {
982
- const n = /* @__PURE__ */ Object.create(null);
983
- return a.forEach(this, (r, o) => {
984
- r != null && r !== !1 && (n[o] = t && a.isArray(r) ? r.join(", ") : r);
985
- }), n;
986
- }
987
- [Symbol.iterator]() {
988
- return Object.entries(this.toJSON())[Symbol.iterator]();
989
- }
990
- toString() {
991
- return Object.entries(this.toJSON()).map(([t, n]) => t + ": " + n).join(`
992
- `);
993
- }
994
- getSetCookie() {
995
- return this.get("set-cookie") || [];
996
- }
997
- get [Symbol.toStringTag]() {
998
- return "AxiosHeaders";
999
- }
1000
- static from(t) {
1001
- return t instanceof this ? t : new this(t);
1002
- }
1003
- static concat(t, ...n) {
1004
- const r = new this(t);
1005
- return n.forEach((o) => r.set(o)), r;
1006
- }
1007
- static accessor(t) {
1008
- const r = (this[De] = this[De] = {
1009
- accessors: {}
1010
- }).accessors, o = this.prototype;
1011
- function i(s) {
1012
- const l = Q(s);
1013
- r[l] || (Bn(o, s), r[l] = !0);
1014
- }
1015
- return a.isArray(t) ? t.forEach(i) : i(t), this;
1016
- }
1017
- };
1018
- U.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1019
- a.reduceDescriptors(U.prototype, ({ value: e }, t) => {
1020
- let n = t[0].toUpperCase() + t.slice(1);
1021
- return {
1022
- get: () => e,
1023
- set(r) {
1024
- this[n] = r;
1025
- }
1026
- };
1027
- });
1028
- a.freezeMethods(U);
1029
- function xe(e, t) {
1030
- const n = this || re, r = t || n, o = U.from(r.headers);
1031
- let i = r.data;
1032
- return a.forEach(e, function(l) {
1033
- i = l.call(n, i, o.normalize(), t ? t.status : void 0);
1034
- }), o.normalize(), i;
1035
- }
1036
- function ft(e) {
1037
- return !!(e && e.__CANCEL__);
1038
- }
1039
- function G(e, t, n) {
1040
- g.call(this, e ?? "canceled", g.ERR_CANCELED, t, n), this.name = "CanceledError";
1041
- }
1042
- a.inherits(G, g, {
1043
- __CANCEL__: !0
1044
- });
1045
- function pt(e, t, n) {
1046
- const r = n.config.validateStatus;
1047
- !n.status || !r || r(n.status) ? e(n) : t(new g(
1048
- "Request failed with status code " + n.status,
1049
- [g.ERR_BAD_REQUEST, g.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4],
1050
- n.config,
1051
- n.request,
1052
- n
1053
- ));
1054
- }
1055
- function jn(e) {
1056
- const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e);
1057
- return t && t[1] || "";
1058
- }
1059
- function vn(e, t) {
1060
- e = e || 10;
1061
- const n = new Array(e), r = new Array(e);
1062
- let o = 0, i = 0, s;
1063
- return t = t !== void 0 ? t : 1e3, function(p) {
1064
- const u = Date.now(), c = r[i];
1065
- s || (s = u), n[o] = p, r[o] = u;
1066
- let d = i, b = 0;
1067
- for (; d !== o; )
1068
- b += n[d++], d = d % e;
1069
- if (o = (o + 1) % e, o === i && (i = (i + 1) % e), u - s < t)
1070
- return;
1071
- const C = c && u - c;
1072
- return C ? Math.round(b * 1e3 / C) : void 0;
1073
- };
1074
- }
1075
- function zn(e, t) {
1076
- let n = 0, r = 1e3 / t, o, i;
1077
- const s = (u, c = Date.now()) => {
1078
- n = c, o = null, i && (clearTimeout(i), i = null), e(...u);
1079
- };
1080
- return [(...u) => {
1081
- const c = Date.now(), d = c - n;
1082
- d >= r ? s(u, c) : (o = u, i || (i = setTimeout(() => {
1083
- i = null, s(o);
1084
- }, r - d)));
1085
- }, () => o && s(o)];
1086
- }
1087
- const de = (e, t, n = 3) => {
1088
- let r = 0;
1089
- const o = vn(50, 250);
1090
- return zn((i) => {
1091
- const s = i.loaded, l = i.lengthComputable ? i.total : void 0, p = s - r, u = o(p), c = s <= l;
1092
- r = s;
1093
- const d = {
1094
- loaded: s,
1095
- total: l,
1096
- progress: l ? s / l : void 0,
1097
- bytes: p,
1098
- rate: u || void 0,
1099
- estimated: u && l && c ? (l - s) / u : void 0,
1100
- event: i,
1101
- lengthComputable: l != null,
1102
- [t ? "download" : "upload"]: !0
1103
- };
1104
- e(d);
1105
- }, n);
1106
- }, Be = (e, t) => {
1107
- const n = e != null;
1108
- return [(r) => t[0]({
1109
- lengthComputable: n,
1110
- total: e,
1111
- loaded: r
1112
- }), t[1]];
1113
- }, je = (e) => (...t) => a.asap(() => e(...t)), Hn = N.hasStandardBrowserEnv ? /* @__PURE__ */ ((e, t) => (n) => (n = new URL(n, N.origin), e.protocol === n.protocol && e.host === n.host && (t || e.port === n.port)))(
1114
- new URL(N.origin),
1115
- N.navigator && /(msie|trident)/i.test(N.navigator.userAgent)
1116
- ) : () => !0, Mn = N.hasStandardBrowserEnv ? (
1117
- // Standard browser envs support document.cookie
1118
- {
1119
- write(e, t, n, r, o, i, s) {
1120
- if (typeof document > "u") return;
1121
- const l = [`${e}=${encodeURIComponent(t)}`];
1122
- a.isNumber(n) && l.push(`expires=${new Date(n).toUTCString()}`), a.isString(r) && l.push(`path=${r}`), a.isString(o) && l.push(`domain=${o}`), i === !0 && l.push("secure"), a.isString(s) && l.push(`SameSite=${s}`), document.cookie = l.join("; ");
1123
- },
1124
- read(e) {
1125
- if (typeof document > "u") return null;
1126
- const t = document.cookie.match(new RegExp("(?:^|; )" + e + "=([^;]*)"));
1127
- return t ? decodeURIComponent(t[1]) : null;
1128
- },
1129
- remove(e) {
1130
- this.write(e, "", Date.now() - 864e5, "/");
1131
- }
1132
- }
1133
- ) : (
1134
- // Non-standard browser env (web workers, react-native) lack needed support.
1135
- {
1136
- write() {
1137
- },
1138
- read() {
1139
- return null;
1140
- },
1141
- remove() {
1142
- }
1143
- }
1144
- );
1145
- function qn(e) {
1146
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(e);
1147
- }
1148
- function $n(e, t) {
1149
- return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e;
1150
- }
1151
- function ht(e, t, n) {
1152
- let r = !qn(t);
1153
- return e && (r || n == !1) ? $n(e, t) : t;
1154
- }
1155
- const ve = (e) => e instanceof U ? { ...e } : e;
1156
- function $(e, t) {
1157
- t = t || {};
1158
- const n = {};
1159
- function r(u, c, d, b) {
1160
- return a.isPlainObject(u) && a.isPlainObject(c) ? a.merge.call({ caseless: b }, u, c) : a.isPlainObject(c) ? a.merge({}, c) : a.isArray(c) ? c.slice() : c;
1161
- }
1162
- function o(u, c, d, b) {
1163
- if (a.isUndefined(c)) {
1164
- if (!a.isUndefined(u))
1165
- return r(void 0, u, d, b);
1166
- } else return r(u, c, d, b);
1167
- }
1168
- function i(u, c) {
1169
- if (!a.isUndefined(c))
1170
- return r(void 0, c);
1171
- }
1172
- function s(u, c) {
1173
- if (a.isUndefined(c)) {
1174
- if (!a.isUndefined(u))
1175
- return r(void 0, u);
1176
- } else return r(void 0, c);
1177
- }
1178
- function l(u, c, d) {
1179
- if (d in t)
1180
- return r(u, c);
1181
- if (d in e)
1182
- return r(void 0, u);
1183
- }
1184
- const p = {
1185
- url: i,
1186
- method: i,
1187
- data: i,
1188
- baseURL: s,
1189
- transformRequest: s,
1190
- transformResponse: s,
1191
- paramsSerializer: s,
1192
- timeout: s,
1193
- timeoutMessage: s,
1194
- withCredentials: s,
1195
- withXSRFToken: s,
1196
- adapter: s,
1197
- responseType: s,
1198
- xsrfCookieName: s,
1199
- xsrfHeaderName: s,
1200
- onUploadProgress: s,
1201
- onDownloadProgress: s,
1202
- decompress: s,
1203
- maxContentLength: s,
1204
- maxBodyLength: s,
1205
- beforeRedirect: s,
1206
- transport: s,
1207
- httpAgent: s,
1208
- httpsAgent: s,
1209
- cancelToken: s,
1210
- socketPath: s,
1211
- responseEncoding: s,
1212
- validateStatus: l,
1213
- headers: (u, c, d) => o(ve(u), ve(c), d, !0)
1214
- };
1215
- return a.forEach(Object.keys({ ...e, ...t }), function(c) {
1216
- const d = p[c] || o, b = d(e[c], t[c], c);
1217
- a.isUndefined(b) && d !== l || (n[c] = b);
1218
- }), n;
1219
- }
1220
- const mt = (e) => {
1221
- const t = $({}, e);
1222
- let { data: n, withXSRFToken: r, xsrfHeaderName: o, xsrfCookieName: i, headers: s, auth: l } = t;
1223
- if (t.headers = s = U.from(s), t.url = ct(ht(t.baseURL, t.url, t.allowAbsoluteUrls), e.params, e.paramsSerializer), l && s.set(
1224
- "Authorization",
1225
- "Basic " + btoa((l.username || "") + ":" + (l.password ? unescape(encodeURIComponent(l.password)) : ""))
1226
- ), a.isFormData(n)) {
1227
- if (N.hasStandardBrowserEnv || N.hasStandardBrowserWebWorkerEnv)
1228
- s.setContentType(void 0);
1229
- else if (a.isFunction(n.getHeaders)) {
1230
- const p = n.getHeaders(), u = ["content-type", "content-length"];
1231
- Object.entries(p).forEach(([c, d]) => {
1232
- u.includes(c.toLowerCase()) && s.set(c, d);
1233
- });
1234
- }
1235
- }
1236
- if (N.hasStandardBrowserEnv && (r && a.isFunction(r) && (r = r(t)), r || r !== !1 && Hn(t.url))) {
1237
- const p = o && i && Mn.read(i);
1238
- p && s.set(o, p);
1239
- }
1240
- return t;
1241
- }, Wn = typeof XMLHttpRequest < "u", Jn = Wn && function(e) {
1242
- return new Promise(function(n, r) {
1243
- const o = mt(e);
1244
- let i = o.data;
1245
- const s = U.from(o.headers).normalize();
1246
- let { responseType: l, onUploadProgress: p, onDownloadProgress: u } = o, c, d, b, C, f;
1247
- function m() {
1248
- C && C(), f && f(), o.cancelToken && o.cancelToken.unsubscribe(c), o.signal && o.signal.removeEventListener("abort", c);
1249
- }
1250
- let h = new XMLHttpRequest();
1251
- h.open(o.method.toUpperCase(), o.url, !0), h.timeout = o.timeout;
1252
- function w() {
1253
- if (!h)
1254
- return;
1255
- const x = U.from(
1256
- "getAllResponseHeaders" in h && h.getAllResponseHeaders()
1257
- ), P = {
1258
- data: !l || l === "text" || l === "json" ? h.responseText : h.response,
1259
- status: h.status,
1260
- statusText: h.statusText,
1261
- headers: x,
1262
- config: e,
1263
- request: h
1264
- };
1265
- pt(function(T) {
1266
- n(T), m();
1267
- }, function(T) {
1268
- r(T), m();
1269
- }, P), h = null;
1270
- }
1271
- "onloadend" in h ? h.onloadend = w : h.onreadystatechange = function() {
1272
- !h || h.readyState !== 4 || h.status === 0 && !(h.responseURL && h.responseURL.indexOf("file:") === 0) || setTimeout(w);
1273
- }, h.onabort = function() {
1274
- h && (r(new g("Request aborted", g.ECONNABORTED, e, h)), h = null);
1275
- }, h.onerror = function(k) {
1276
- const P = k && k.message ? k.message : "Network Error", E = new g(P, g.ERR_NETWORK, e, h);
1277
- E.event = k || null, r(E), h = null;
1278
- }, h.ontimeout = function() {
1279
- let k = o.timeout ? "timeout of " + o.timeout + "ms exceeded" : "timeout exceeded";
1280
- const P = o.transitional || ut;
1281
- o.timeoutErrorMessage && (k = o.timeoutErrorMessage), r(new g(
1282
- k,
1283
- P.clarifyTimeoutError ? g.ETIMEDOUT : g.ECONNABORTED,
1284
- e,
1285
- h
1286
- )), h = null;
1287
- }, i === void 0 && s.setContentType(null), "setRequestHeader" in h && a.forEach(s.toJSON(), function(k, P) {
1288
- h.setRequestHeader(P, k);
1289
- }), a.isUndefined(o.withCredentials) || (h.withCredentials = !!o.withCredentials), l && l !== "json" && (h.responseType = o.responseType), u && ([b, f] = de(u, !0), h.addEventListener("progress", b)), p && h.upload && ([d, C] = de(p), h.upload.addEventListener("progress", d), h.upload.addEventListener("loadend", C)), (o.cancelToken || o.signal) && (c = (x) => {
1290
- h && (r(!x || x.type ? new G(null, e, h) : x), h.abort(), h = null);
1291
- }, o.cancelToken && o.cancelToken.subscribe(c), o.signal && (o.signal.aborted ? c() : o.signal.addEventListener("abort", c)));
1292
- const A = jn(o.url);
1293
- if (A && N.protocols.indexOf(A) === -1) {
1294
- r(new g("Unsupported protocol " + A + ":", g.ERR_BAD_REQUEST, e));
1295
- return;
1296
- }
1297
- h.send(i || null);
1298
- });
1299
- }, Vn = (e, t) => {
1300
- const { length: n } = e = e ? e.filter(Boolean) : [];
1301
- if (t || n) {
1302
- let r = new AbortController(), o;
1303
- const i = function(u) {
1304
- if (!o) {
1305
- o = !0, l();
1306
- const c = u instanceof Error ? u : this.reason;
1307
- r.abort(c instanceof g ? c : new G(c instanceof Error ? c.message : c));
1308
- }
1309
- };
1310
- let s = t && setTimeout(() => {
1311
- s = null, i(new g(`timeout ${t} of ms exceeded`, g.ETIMEDOUT));
1312
- }, t);
1313
- const l = () => {
1314
- e && (s && clearTimeout(s), s = null, e.forEach((u) => {
1315
- u.unsubscribe ? u.unsubscribe(i) : u.removeEventListener("abort", i);
1316
- }), e = null);
1317
- };
1318
- e.forEach((u) => u.addEventListener("abort", i));
1319
- const { signal: p } = r;
1320
- return p.unsubscribe = () => a.asap(l), p;
1321
- }
1322
- }, Kn = function* (e, t) {
1323
- let n = e.byteLength;
1324
- if (n < t) {
1325
- yield e;
1326
- return;
1327
- }
1328
- let r = 0, o;
1329
- for (; r < n; )
1330
- o = r + t, yield e.slice(r, o), r = o;
1331
- }, Xn = async function* (e, t) {
1332
- for await (const n of Gn(e))
1333
- yield* Kn(n, t);
1334
- }, Gn = async function* (e) {
1335
- if (e[Symbol.asyncIterator]) {
1336
- yield* e;
1337
- return;
1338
- }
1339
- const t = e.getReader();
1340
- try {
1341
- for (; ; ) {
1342
- const { done: n, value: r } = await t.read();
1343
- if (n)
1344
- break;
1345
- yield r;
1346
- }
1347
- } finally {
1348
- await t.cancel();
1349
- }
1350
- }, ze = (e, t, n, r) => {
1351
- const o = Xn(e, t);
1352
- let i = 0, s, l = (p) => {
1353
- s || (s = !0, r && r(p));
1354
- };
1355
- return new ReadableStream({
1356
- async pull(p) {
1357
- try {
1358
- const { done: u, value: c } = await o.next();
1359
- if (u) {
1360
- l(), p.close();
1361
- return;
1362
- }
1363
- let d = c.byteLength;
1364
- if (n) {
1365
- let b = i += d;
1366
- n(b);
1367
- }
1368
- p.enqueue(new Uint8Array(c));
1369
- } catch (u) {
1370
- throw l(u), u;
1371
- }
1372
- },
1373
- cancel(p) {
1374
- return l(p), o.return();
1375
- }
1376
- }, {
1377
- highWaterMark: 2
1378
- });
1379
- }, He = 64 * 1024, { isFunction: ae } = a, Yn = (({ Request: e, Response: t }) => ({
1380
- Request: e,
1381
- Response: t
1382
- }))(a.global), {
1383
- ReadableStream: Me,
1384
- TextEncoder: qe
1385
- } = a.global, $e = (e, ...t) => {
1386
- try {
1387
- return !!e(...t);
1388
- } catch {
1389
- return !1;
1390
- }
1391
- }, Qn = (e) => {
1392
- e = a.merge.call({
1393
- skipUndefined: !0
1394
- }, Yn, e);
1395
- const { fetch: t, Request: n, Response: r } = e, o = t ? ae(t) : typeof fetch == "function", i = ae(n), s = ae(r);
1396
- if (!o)
1397
- return !1;
1398
- const l = o && ae(Me), p = o && (typeof qe == "function" ? /* @__PURE__ */ ((f) => (m) => f.encode(m))(new qe()) : async (f) => new Uint8Array(await new n(f).arrayBuffer())), u = i && l && $e(() => {
1399
- let f = !1;
1400
- const m = new n(N.origin, {
1401
- body: new Me(),
1402
- method: "POST",
1403
- get duplex() {
1404
- return f = !0, "half";
1405
- }
1406
- }).headers.has("Content-Type");
1407
- return f && !m;
1408
- }), c = s && l && $e(() => a.isReadableStream(new r("").body)), d = {
1409
- stream: c && ((f) => f.body)
1410
- };
1411
- o && ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((f) => {
1412
- !d[f] && (d[f] = (m, h) => {
1413
- let w = m && m[f];
1414
- if (w)
1415
- return w.call(m);
1416
- throw new g(`Response type '${f}' is not supported`, g.ERR_NOT_SUPPORT, h);
1417
- });
1418
- });
1419
- const b = async (f) => {
1420
- if (f == null)
1421
- return 0;
1422
- if (a.isBlob(f))
1423
- return f.size;
1424
- if (a.isSpecCompliantForm(f))
1425
- return (await new n(N.origin, {
1426
- method: "POST",
1427
- body: f
1428
- }).arrayBuffer()).byteLength;
1429
- if (a.isArrayBufferView(f) || a.isArrayBuffer(f))
1430
- return f.byteLength;
1431
- if (a.isURLSearchParams(f) && (f = f + ""), a.isString(f))
1432
- return (await p(f)).byteLength;
1433
- }, C = async (f, m) => {
1434
- const h = a.toFiniteNumber(f.getContentLength());
1435
- return h ?? b(m);
1436
- };
1437
- return async (f) => {
1438
- let {
1439
- url: m,
1440
- method: h,
1441
- data: w,
1442
- signal: A,
1443
- cancelToken: x,
1444
- timeout: k,
1445
- onDownloadProgress: P,
1446
- onUploadProgress: E,
1447
- responseType: T,
1448
- headers: Y,
1449
- withCredentials: H = "same-origin",
1450
- fetchOptions: oe
1451
- } = mt(f), se = t || fetch;
1452
- T = T ? (T + "").toLowerCase() : "text";
1453
- let W = Vn([A, x && x.toAbortSignal()], k), D = null;
1454
- const B = W && W.unsubscribe && (() => {
1455
- W.unsubscribe();
1456
- });
1457
- let S;
1458
- try {
1459
- if (E && u && h !== "get" && h !== "head" && (S = await C(Y, w)) !== 0) {
1460
- let z = new n(m, {
1461
- method: "POST",
1462
- body: w,
1463
- duplex: "half"
1464
- }), V;
1465
- if (a.isFormData(w) && (V = z.headers.get("content-type")) && Y.setContentType(V), z.body) {
1466
- const [ge, ie] = Be(
1467
- S,
1468
- de(je(E))
1469
- );
1470
- w = ze(z.body, He, ge, ie);
1471
- }
1472
- }
1473
- a.isString(H) || (H = H ? "include" : "omit");
1474
- const O = i && "credentials" in n.prototype, J = {
1475
- ...oe,
1476
- signal: W,
1477
- method: h.toUpperCase(),
1478
- headers: Y.normalize().toJSON(),
1479
- body: w,
1480
- duplex: "half",
1481
- credentials: O ? H : void 0
1482
- };
1483
- D = i && new n(m, J);
1484
- let v = await (i ? se(D, oe) : se(m, J));
1485
- const Fe = c && (T === "stream" || T === "response");
1486
- if (c && (P || Fe && B)) {
1487
- const z = {};
1488
- ["status", "statusText", "headers"].forEach((Pe) => {
1489
- z[Pe] = v[Pe];
1490
- });
1491
- const V = a.toFiniteNumber(v.headers.get("content-length")), [ge, ie] = P && Be(
1492
- V,
1493
- de(je(P), !0)
1494
- ) || [];
1495
- v = new r(
1496
- ze(v.body, He, ge, () => {
1497
- ie && ie(), B && B();
1498
- }),
1499
- z
1500
- );
1501
- }
1502
- T = T || "text";
1503
- let St = await d[a.findKey(d, T) || "text"](v, f);
1504
- return !Fe && B && B(), await new Promise((z, V) => {
1505
- pt(z, V, {
1506
- data: St,
1507
- headers: U.from(v.headers),
1508
- status: v.status,
1509
- statusText: v.statusText,
1510
- config: f,
1511
- request: D
1512
- });
1513
- });
1514
- } catch (O) {
1515
- throw B && B(), O && O.name === "TypeError" && /Load failed|fetch/i.test(O.message) ? Object.assign(
1516
- new g("Network Error", g.ERR_NETWORK, f, D),
1517
- {
1518
- cause: O.cause || O
1519
- }
1520
- ) : g.from(O, O && O.code, f, D);
1521
- }
1522
- };
1523
- }, Zn = /* @__PURE__ */ new Map(), yt = (e) => {
1524
- let t = e && e.env || {};
1525
- const { fetch: n, Request: r, Response: o } = t, i = [
1526
- r,
1527
- o,
1528
- n
1529
- ];
1530
- let s = i.length, l = s, p, u, c = Zn;
1531
- for (; l--; )
1532
- p = i[l], u = c.get(p), u === void 0 && c.set(p, u = l ? /* @__PURE__ */ new Map() : Qn(t)), c = u;
1533
- return u;
1534
- };
1535
- yt();
1536
- const ke = {
1537
- http: yn,
1538
- xhr: Jn,
1539
- fetch: {
1540
- get: yt
1541
- }
1542
- };
1543
- a.forEach(ke, (e, t) => {
1544
- if (e) {
1545
- try {
1546
- Object.defineProperty(e, "name", { value: t });
1547
- } catch {
1548
- }
1549
- Object.defineProperty(e, "adapterName", { value: t });
1550
- }
1551
- });
1552
- const We = (e) => `- ${e}`, er = (e) => a.isFunction(e) || e === null || e === !1;
1553
- function tr(e, t) {
1554
- e = a.isArray(e) ? e : [e];
1555
- const { length: n } = e;
1556
- let r, o;
1557
- const i = {};
1558
- for (let s = 0; s < n; s++) {
1559
- r = e[s];
1560
- let l;
1561
- if (o = r, !er(r) && (o = ke[(l = String(r)).toLowerCase()], o === void 0))
1562
- throw new g(`Unknown adapter '${l}'`);
1563
- if (o && (a.isFunction(o) || (o = o.get(t))))
1564
- break;
1565
- i[l || "#" + s] = o;
1566
- }
1567
- if (!o) {
1568
- const s = Object.entries(i).map(
1569
- ([p, u]) => `adapter ${p} ` + (u === !1 ? "is not supported by the environment" : "is not available in the build")
1570
- );
1571
- let l = n ? s.length > 1 ? `since :
1572
- ` + s.map(We).join(`
1573
- `) : " " + We(s[0]) : "as no adapter specified";
1574
- throw new g(
1575
- "There is no suitable adapter to dispatch the request " + l,
1576
- "ERR_NOT_SUPPORT"
1577
- );
1578
- }
1579
- return o;
1580
- }
1581
- const gt = {
1582
- /**
1583
- * Resolve an adapter from a list of adapter names or functions.
1584
- * @type {Function}
1585
- */
1586
- getAdapter: tr,
1587
- /**
1588
- * Exposes all known adapters
1589
- * @type {Object<string, Function|Object>}
1590
- */
1591
- adapters: ke
1592
- };
1593
- function we(e) {
1594
- if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
1595
- throw new G(null, e);
1596
- }
1597
- function Je(e) {
1598
- return we(e), e.headers = U.from(e.headers), e.data = xe.call(
1599
- e,
1600
- e.transformRequest
1601
- ), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), gt.getAdapter(e.adapter || re.adapter, e)(e).then(function(r) {
1602
- return we(e), r.data = xe.call(
1603
- e,
1604
- e.transformResponse,
1605
- r
1606
- ), r.headers = U.from(r.headers), r;
1607
- }, function(r) {
1608
- return ft(r) || (we(e), r && r.response && (r.response.data = xe.call(
1609
- e,
1610
- e.transformResponse,
1611
- r.response
1612
- ), r.response.headers = U.from(r.response.headers))), Promise.reject(r);
1613
- });
1614
- }
1615
- const bt = "1.13.2", ye = {};
1616
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((e, t) => {
1617
- ye[e] = function(r) {
1618
- return typeof r === e || "a" + (t < 1 ? "n " : " ") + e;
1619
- };
1620
- });
1621
- const Ve = {};
1622
- ye.transitional = function(t, n, r) {
1623
- function o(i, s) {
1624
- return "[Axios v" + bt + "] Transitional option '" + i + "'" + s + (r ? ". " + r : "");
1625
- }
1626
- return (i, s, l) => {
1627
- if (t === !1)
1628
- throw new g(
1629
- o(s, " has been removed" + (n ? " in " + n : "")),
1630
- g.ERR_DEPRECATED
1631
- );
1632
- return n && !Ve[s] && (Ve[s] = !0, console.warn(
1633
- o(
1634
- s,
1635
- " has been deprecated since v" + n + " and will be removed in the near future"
1636
- )
1637
- )), t ? t(i, s, l) : !0;
1638
- };
1639
- };
1640
- ye.spelling = function(t) {
1641
- return (n, r) => (console.warn(`${r} is likely a misspelling of ${t}`), !0);
1642
- };
1643
- function nr(e, t, n) {
1644
- if (typeof e != "object")
1645
- throw new g("options must be an object", g.ERR_BAD_OPTION_VALUE);
1646
- const r = Object.keys(e);
1647
- let o = r.length;
1648
- for (; o-- > 0; ) {
1649
- const i = r[o], s = t[i];
1650
- if (s) {
1651
- const l = e[i], p = l === void 0 || s(l, i, e);
1652
- if (p !== !0)
1653
- throw new g("option " + i + " must be " + p, g.ERR_BAD_OPTION_VALUE);
1654
- continue;
1655
- }
1656
- if (n !== !0)
1657
- throw new g("Unknown option " + i, g.ERR_BAD_OPTION);
1658
- }
1659
- }
1660
- const ue = {
1661
- assertOptions: nr,
1662
- validators: ye
1663
- }, j = ue.validators;
1664
- let q = class {
1665
- constructor(t) {
1666
- this.defaults = t || {}, this.interceptors = {
1667
- request: new Le(),
1668
- response: new Le()
1669
- };
1670
- }
1671
- /**
1672
- * Dispatch a request
1673
- *
1674
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
1675
- * @param {?Object} config
1676
- *
1677
- * @returns {Promise} The Promise to be fulfilled
1678
- */
1679
- async request(t, n) {
1680
- try {
1681
- return await this._request(t, n);
1682
- } catch (r) {
1683
- if (r instanceof Error) {
1684
- let o = {};
1685
- Error.captureStackTrace ? Error.captureStackTrace(o) : o = new Error();
1686
- const i = o.stack ? o.stack.replace(/^.+\n/, "") : "";
1687
- try {
1688
- r.stack ? i && !String(r.stack).endsWith(i.replace(/^.+\n.+\n/, "")) && (r.stack += `
1689
- ` + i) : r.stack = i;
1690
- } catch {
1691
- }
1692
- }
1693
- throw r;
1694
- }
1695
- }
1696
- _request(t, n) {
1697
- typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = $(this.defaults, n);
1698
- const { transitional: r, paramsSerializer: o, headers: i } = n;
1699
- r !== void 0 && ue.assertOptions(r, {
1700
- silentJSONParsing: j.transitional(j.boolean),
1701
- forcedJSONParsing: j.transitional(j.boolean),
1702
- clarifyTimeoutError: j.transitional(j.boolean)
1703
- }, !1), o != null && (a.isFunction(o) ? n.paramsSerializer = {
1704
- serialize: o
1705
- } : ue.assertOptions(o, {
1706
- encode: j.function,
1707
- serialize: j.function
1708
- }, !0)), n.allowAbsoluteUrls !== void 0 || (this.defaults.allowAbsoluteUrls !== void 0 ? n.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls : n.allowAbsoluteUrls = !0), ue.assertOptions(n, {
1709
- baseUrl: j.spelling("baseURL"),
1710
- withXsrfToken: j.spelling("withXSRFToken")
1711
- }, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
1712
- let s = i && a.merge(
1713
- i.common,
1714
- i[n.method]
1715
- );
1716
- i && a.forEach(
1717
- ["delete", "get", "head", "post", "put", "patch", "common"],
1718
- (f) => {
1719
- delete i[f];
1720
- }
1721
- ), n.headers = U.concat(s, i);
1722
- const l = [];
1723
- let p = !0;
1724
- this.interceptors.request.forEach(function(m) {
1725
- typeof m.runWhen == "function" && m.runWhen(n) === !1 || (p = p && m.synchronous, l.unshift(m.fulfilled, m.rejected));
1726
- });
1727
- const u = [];
1728
- this.interceptors.response.forEach(function(m) {
1729
- u.push(m.fulfilled, m.rejected);
1730
- });
1731
- let c, d = 0, b;
1732
- if (!p) {
1733
- const f = [Je.bind(this), void 0];
1734
- for (f.unshift(...l), f.push(...u), b = f.length, c = Promise.resolve(n); d < b; )
1735
- c = c.then(f[d++], f[d++]);
1736
- return c;
1737
- }
1738
- b = l.length;
1739
- let C = n;
1740
- for (; d < b; ) {
1741
- const f = l[d++], m = l[d++];
1742
- try {
1743
- C = f(C);
1744
- } catch (h) {
1745
- m.call(this, h);
1746
- break;
153
+ const W = await I.data;
154
+ h(W);
155
+ } catch (W) {
156
+ console.error("Error handling server message:", W);
157
+ } finally {
158
+ C(!1);
1747
159
  }
1748
- }
1749
- try {
1750
- c = Je.call(this, C);
1751
- } catch (f) {
1752
- return Promise.reject(f);
1753
- }
1754
- for (d = 0, b = u.length; d < b; )
1755
- c = c.then(u[d++], u[d++]);
1756
- return c;
1757
- }
1758
- getUri(t) {
1759
- t = $(this.defaults, t);
1760
- const n = ht(t.baseURL, t.url, t.allowAbsoluteUrls);
1761
- return ct(n, t.params, t.paramsSerializer);
1762
- }
1763
- };
1764
- a.forEach(["delete", "get", "head", "options"], function(t) {
1765
- q.prototype[t] = function(n, r) {
1766
- return this.request($(r || {}, {
1767
- method: t,
1768
- url: n,
1769
- data: (r || {}).data
1770
- }));
1771
- };
1772
- });
1773
- a.forEach(["post", "put", "patch"], function(t) {
1774
- function n(r) {
1775
- return function(i, s, l) {
1776
- return this.request($(l || {}, {
1777
- method: t,
1778
- headers: r ? {
1779
- "Content-Type": "multipart/form-data"
1780
- } : {},
1781
- url: i,
1782
- data: s
1783
- }));
1784
- };
1785
- }
1786
- q.prototype[t] = n(), q.prototype[t + "Form"] = n(!0);
1787
- });
1788
- let rr = class xt {
1789
- constructor(t) {
1790
- if (typeof t != "function")
1791
- throw new TypeError("executor must be a function.");
1792
- let n;
1793
- this.promise = new Promise(function(i) {
1794
- n = i;
1795
- });
1796
- const r = this;
1797
- this.promise.then((o) => {
1798
- if (!r._listeners) return;
1799
- let i = r._listeners.length;
1800
- for (; i-- > 0; )
1801
- r._listeners[i](o);
1802
- r._listeners = null;
1803
- }), this.promise.then = (o) => {
1804
- let i;
1805
- const s = new Promise((l) => {
1806
- r.subscribe(l), i = l;
1807
- }).then(o);
1808
- return s.cancel = function() {
1809
- r.unsubscribe(i);
1810
- }, s;
1811
- }, t(function(i, s, l) {
1812
- r.reason || (r.reason = new G(i, s, l), n(r.reason));
1813
- });
1814
- }
1815
- /**
1816
- * Throws a `CanceledError` if cancellation has been requested.
1817
- */
1818
- throwIfRequested() {
1819
- if (this.reason)
1820
- throw this.reason;
1821
- }
1822
- /**
1823
- * Subscribe to the cancel signal
1824
- */
1825
- subscribe(t) {
1826
- if (this.reason) {
1827
- t(this.reason);
1828
- return;
1829
- }
1830
- this._listeners ? this._listeners.push(t) : this._listeners = [t];
1831
- }
1832
- /**
1833
- * Unsubscribe from the cancel signal
1834
- */
1835
- unsubscribe(t) {
1836
- if (!this._listeners)
1837
- return;
1838
- const n = this._listeners.indexOf(t);
1839
- n !== -1 && this._listeners.splice(n, 1);
1840
- }
1841
- toAbortSignal() {
1842
- const t = new AbortController(), n = (r) => {
1843
- t.abort(r);
160
+ }, l.onerror = (I) => {
161
+ g("Server error occurred"), console.error("WebSocket error:", I), s("offline");
162
+ }, l.onclose = () => {
163
+ g("Server disconnected"), s("offline");
1844
164
  };
1845
- return this.subscribe(n), t.signal.unsubscribe = () => this.unsubscribe(n), t.signal;
1846
- }
1847
- /**
1848
- * Returns an object that contains a new `CancelToken` and a function that, when called,
1849
- * cancels the `CancelToken`.
1850
- */
1851
- static source() {
1852
- let t;
1853
- return {
1854
- token: new xt(function(o) {
1855
- t = o;
1856
- }),
1857
- cancel: t
165
+ }, []);
166
+ const b = async () => {
167
+ i && i.readyState === WebSocket.OPEN && i.send(JSON.stringify(d));
168
+ const n = {
169
+ created_at: Date.now(),
170
+ sender_type: "user",
171
+ message: d
1858
172
  };
1859
- }
1860
- };
1861
- function or(e) {
1862
- return function(n) {
1863
- return e.apply(null, n);
1864
- };
1865
- }
1866
- function sr(e) {
1867
- return a.isObject(e) && e.isAxiosError === !0;
1868
- }
1869
- const Re = {
1870
- Continue: 100,
1871
- SwitchingProtocols: 101,
1872
- Processing: 102,
1873
- EarlyHints: 103,
1874
- Ok: 200,
1875
- Created: 201,
1876
- Accepted: 202,
1877
- NonAuthoritativeInformation: 203,
1878
- NoContent: 204,
1879
- ResetContent: 205,
1880
- PartialContent: 206,
1881
- MultiStatus: 207,
1882
- AlreadyReported: 208,
1883
- ImUsed: 226,
1884
- MultipleChoices: 300,
1885
- MovedPermanently: 301,
1886
- Found: 302,
1887
- SeeOther: 303,
1888
- NotModified: 304,
1889
- UseProxy: 305,
1890
- Unused: 306,
1891
- TemporaryRedirect: 307,
1892
- PermanentRedirect: 308,
1893
- BadRequest: 400,
1894
- Unauthorized: 401,
1895
- PaymentRequired: 402,
1896
- Forbidden: 403,
1897
- NotFound: 404,
1898
- MethodNotAllowed: 405,
1899
- NotAcceptable: 406,
1900
- ProxyAuthenticationRequired: 407,
1901
- RequestTimeout: 408,
1902
- Conflict: 409,
1903
- Gone: 410,
1904
- LengthRequired: 411,
1905
- PreconditionFailed: 412,
1906
- PayloadTooLarge: 413,
1907
- UriTooLong: 414,
1908
- UnsupportedMediaType: 415,
1909
- RangeNotSatisfiable: 416,
1910
- ExpectationFailed: 417,
1911
- ImATeapot: 418,
1912
- MisdirectedRequest: 421,
1913
- UnprocessableEntity: 422,
1914
- Locked: 423,
1915
- FailedDependency: 424,
1916
- TooEarly: 425,
1917
- UpgradeRequired: 426,
1918
- PreconditionRequired: 428,
1919
- TooManyRequests: 429,
1920
- RequestHeaderFieldsTooLarge: 431,
1921
- UnavailableForLegalReasons: 451,
1922
- InternalServerError: 500,
1923
- NotImplemented: 501,
1924
- BadGateway: 502,
1925
- ServiceUnavailable: 503,
1926
- GatewayTimeout: 504,
1927
- HttpVersionNotSupported: 505,
1928
- VariantAlsoNegotiates: 506,
1929
- InsufficientStorage: 507,
1930
- LoopDetected: 508,
1931
- NotExtended: 510,
1932
- NetworkAuthenticationRequired: 511,
1933
- WebServerIsDown: 521,
1934
- ConnectionTimedOut: 522,
1935
- OriginIsUnreachable: 523,
1936
- TimeoutOccurred: 524,
1937
- SslHandshakeFailed: 525,
1938
- InvalidSslCertificate: 526
1939
- };
1940
- Object.entries(Re).forEach(([e, t]) => {
1941
- Re[t] = e;
1942
- });
1943
- function wt(e) {
1944
- const t = new q(e), n = Ye(q.prototype.request, t);
1945
- return a.extend(n, q.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(o) {
1946
- return wt($(e, o));
1947
- }, n;
1948
- }
1949
- const R = wt(re);
1950
- R.Axios = q;
1951
- R.CanceledError = G;
1952
- R.CancelToken = rr;
1953
- R.isCancel = ft;
1954
- R.VERSION = bt;
1955
- R.toFormData = me;
1956
- R.AxiosError = g;
1957
- R.Cancel = R.CanceledError;
1958
- R.all = function(t) {
1959
- return Promise.all(t);
1960
- };
1961
- R.spread = or;
1962
- R.isAxiosError = sr;
1963
- R.mergeConfig = $;
1964
- R.AxiosHeaders = U;
1965
- R.formToJSON = (e) => dt(a.isHTMLForm(e) ? new FormData(e) : e);
1966
- R.getAdapter = gt.getAdapter;
1967
- R.HttpStatusCode = Re;
1968
- R.default = R;
1969
- const {
1970
- Axios: yr,
1971
- AxiosError: gr,
1972
- CanceledError: br,
1973
- isCancel: xr,
1974
- CancelToken: wr,
1975
- VERSION: Sr,
1976
- all: Er,
1977
- Cancel: Cr,
1978
- isAxiosError: Rr,
1979
- spread: Tr,
1980
- toFormData: Or,
1981
- AxiosHeaders: Ar,
1982
- HttpStatusCode: kr,
1983
- formToJSON: Fr,
1984
- getAdapter: Pr,
1985
- mergeConfig: Nr
1986
- } = R, ir = async (e, t, n, r, o) => {
1987
- const i = {
1988
- chatInput: e,
1989
- metadata: {
1990
- pinecone_namespace: t,
1991
- name: r,
1992
- email: o
1993
- }
1994
- };
1995
- try {
1996
- return (await R.post(
1997
- n,
1998
- i,
1999
- {
2000
- headers: {
2001
- "Content-Type": "application/json"
2002
- }
2003
- }
2004
- )).data;
2005
- } catch (s) {
2006
- throw console.error("Error communicating with chat API:", s), s;
2007
- }
2008
- }, ar = async (e, t, n, r) => {
2009
- const o = {
2010
- chatInput: e,
2011
- metadata: {
2012
- pinecone_namespace: t
2013
- },
2014
- sessionId: r
2015
- };
2016
- try {
2017
- return (await R.post(
2018
- n,
2019
- o,
2020
- {
2021
- headers: {
2022
- "Content-Type": "application/json"
2023
- }
2024
- }
2025
- )).data;
2026
- } catch (i) {
2027
- throw console.error("Error communicating with chat API:", i), i;
2028
- }
2029
- }, lr = async (e, t) => {
2030
- const n = {
2031
- sessionId: e
2032
- };
2033
- try {
2034
- const r = await R.post(
2035
- t,
2036
- n,
2037
- {
2038
- headers: {
2039
- "Content-Type": "application/json"
2040
- }
2041
- }
2042
- );
2043
- return console.log("Fetch chat history response:", r), r.data.n8n;
2044
- } catch (r) {
2045
- throw console.error("Error fetching with chat API:", r), r;
2046
- }
2047
- }, cr = ({ theme: e, chatBotData: t, trackFormSubmission: n }) => {
2048
- const [r, o] = I(""), [i, s] = I(""), [l, p] = I(""), [u, c] = I(""), [d, b] = I(!1), C = async (E) => {
2049
- if (E.preventDefault(), b(!0), c(""), !r.trim() || !i.trim()) {
2050
- c("Name and email are required"), b(!1);
2051
- return;
2052
- }
2053
- try {
2054
- const T = await ir(
2055
- l,
2056
- t.pineconeNamespace,
2057
- t.initiateChatUrl,
2058
- r,
2059
- i
2060
- );
2061
- localStorage.setItem("clone67ChatSessionId", T.n8n.session_id), n(!0);
2062
- } catch (T) {
2063
- console.log("error sending user details", T), c("Failed to submit. Please try again.");
2064
- } finally {
2065
- b(!1);
2066
- }
2067
- o(""), s(""), p("");
2068
- }, f = {
2069
- padding: "20px",
2070
- flexShrink: 0,
2071
- background: e.backgroundColor,
2072
- fontFamily: "system-ui, -apple-system, sans-serif"
2073
- }, m = {
2074
- display: "flex",
2075
- flexDirection: "column",
2076
- gap: "24px"
2077
- }, h = {
2078
- fontSize: "14px",
2079
- fontWeight: "500",
2080
- color: e.fontColor,
2081
- margin: 0,
2082
- lineHeight: "1.4"
2083
- }, w = {
2084
- display: "flex",
2085
- flexDirection: "column",
2086
- gap: "20px"
2087
- }, A = {
2088
- fontSize: "14px",
2089
- color: e.fontColor,
2090
- fontWeight: "500"
2091
- }, x = {
2092
- width: "100%",
173
+ h(JSON.stringify(n)), p("");
174
+ }, v = (n) => {
175
+ n.key === "Enter" && !n.shiftKey && (n.preventDefault(), b());
176
+ }, r = {
177
+ flex: 1,
2093
178
  padding: "12px 16px",
2094
179
  background: e.backgroundColor,
2095
180
  color: e.fontColor,
2096
- border: "1px solid #a1a1aa",
181
+ border: `1px solid ${e.fontColor}`,
2097
182
  borderRadius: "12px",
2098
- fontSize: "15px",
183
+ fontSize: "14px",
2099
184
  outline: "none",
2100
- boxSizing: "border-box"
2101
- }, k = {
185
+ transition: "all 0.2s ease",
186
+ opacity: c ? 0.5 : 1,
187
+ cursor: c ? "not-allowed" : "text",
188
+ boxShadow: "none"
189
+ }, y = {
2102
190
  padding: "12px 20px",
2103
191
  borderRadius: "12px",
2104
- fontWeight: "600",
2105
- fontSize: "15px",
2106
- border: "none",
2107
- cursor: r.trim() && i.trim() && !d ? "pointer" : "not-allowed",
2108
- opacity: r.trim() && i.trim() && !d ? 1 : 0.5,
2109
192
  background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
2110
193
  color: e.fontColor,
194
+ border: "none",
195
+ cursor: c || !d.trim() ? "not-allowed" : "pointer",
196
+ opacity: c || !d.trim() ? 0.5 : 1,
2111
197
  display: "flex",
2112
198
  alignItems: "center",
2113
199
  justifyContent: "center",
2114
200
  gap: "8px",
2115
- transition: "all 0.2s ease"
201
+ fontWeight: "600",
202
+ fontSize: "14px",
203
+ transition: "all 0.2s ease",
204
+ minWidth: "48px"
205
+ }, k = {
206
+ padding: "16px",
207
+ borderTop: "1px solid rgba(255, 255, 255, 0.2)",
208
+ borderColor: e.fontColor,
209
+ background: e.backgroundColor,
210
+ flexShrink: 0
2116
211
  };
2117
- return /* @__PURE__ */ y("div", { style: f, children: /* @__PURE__ */ F("form", { onSubmit: C, style: m, children: [
2118
- u && /* @__PURE__ */ y("div", { style: {
2119
- backgroundColor: "#fee2e2",
2120
- color: "#713f12",
2121
- padding: "8px 12px",
2122
- borderRadius: "8px",
2123
- fontSize: "13px",
212
+ return /* @__PURE__ */ u("div", { children: [
213
+ x && /* @__PURE__ */ o("p", { style: {
2124
214
  textAlign: "center",
2125
- fontWeight: "500"
2126
- }, role: "alert", children: u }),
2127
- /* @__PURE__ */ y("p", { style: h, children: t.welcomeText }),
2128
- /* @__PURE__ */ F("div", { style: w, children: [
2129
- /* @__PURE__ */ F("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2130
- /* @__PURE__ */ y("label", { style: A, children: "Full Name" }),
2131
- /* @__PURE__ */ y(
2132
- "input",
2133
- {
2134
- type: "text",
2135
- placeholder: "Enter your full name",
2136
- value: r,
2137
- onChange: (E) => {
2138
- o(E.target.value), c("");
2139
- },
2140
- style: x,
2141
- required: !0
2142
- }
2143
- )
2144
- ] }),
2145
- /* @__PURE__ */ F("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2146
- /* @__PURE__ */ y("label", { style: A, children: "Email Address" }),
2147
- /* @__PURE__ */ y(
2148
- "input",
2149
- {
2150
- type: "email",
2151
- placeholder: "Enter your email",
2152
- value: i,
2153
- onChange: (E) => {
2154
- s(E.target.value), c("");
2155
- },
2156
- style: x,
2157
- required: !0
2158
- }
2159
- )
2160
- ] }),
2161
- /* @__PURE__ */ F("div", { style: { display: "flex", flexDirection: "column", gap: "4px" }, children: [
2162
- /* @__PURE__ */ y("label", { style: A, children: "Message" }),
2163
- /* @__PURE__ */ y(
2164
- "textarea",
2165
- {
2166
- placeholder: "Enter your message",
2167
- value: l,
2168
- onChange: (E) => {
2169
- p(E.target.value), c("");
2170
- },
2171
- style: {
2172
- ...x,
2173
- minHeight: "60px",
2174
- maxHeight: "80px",
2175
- resize: "vertical"
2176
- },
2177
- required: !0
2178
- }
2179
- )
2180
- ] })
2181
- ] }),
2182
- /* @__PURE__ */ y(
2183
- "button",
2184
- {
2185
- type: "submit",
2186
- disabled: !r.trim() || !i.trim() || d,
2187
- style: k,
2188
- onMouseEnter: (E) => {
2189
- r.trim() && i.trim() && !d && (E.currentTarget.style.transform = "translateY(-2px)", E.currentTarget.style.boxShadow = "0 10px 20px rgba(0,0,0,0.15)");
2190
- },
2191
- onMouseLeave: (E) => {
2192
- E.currentTarget.style.transform = "translateY(0)", E.currentTarget.style.boxShadow = "none";
2193
- },
2194
- children: d ? "Submitting..." : /* @__PURE__ */ F(Z, { children: [
2195
- /* @__PURE__ */ y(Ge, { size: 18 }),
2196
- "Submit"
2197
- ] })
2198
- }
2199
- )
2200
- ] }) });
2201
- }, ur = ({ onClose: e, theme: t, chatBotData: n }) => {
2202
- const [r, o] = I([]), [i, s] = I(!1), [l, p] = I(!1), [u, c] = I(!1), [d, b] = I(null), C = n.position === "left", f = localStorage.getItem("clone67ChatSessionId"), m = (S) => {
2203
- c(S);
2204
- }, h = async () => {
2205
- if (f) {
2206
- s(!0);
2207
- try {
2208
- const S = await lr(
2209
- f,
2210
- n.fetchChatHistoryUrl
2211
- ), O = S.chats;
2212
- if (S.status === "error") {
2213
- b(S.message);
2214
- return;
2215
- }
2216
- S.status === "success" && (o(O), b(null));
2217
- } catch (S) {
2218
- console.log("Error fetching chat history", S);
2219
- } finally {
2220
- s(!1);
2221
- }
2222
- }
2223
- };
2224
- Ke(() => {
2225
- h();
2226
- }, [u, f]);
2227
- const w = async (S) => {
2228
- s(!0), o((O) => [
2229
- ...O,
2230
- { sender_type: "user", message: S }
2231
- ]);
2232
- try {
2233
- const O = await ar(
2234
- S,
2235
- n.pineconeNamespace,
2236
- n.onGoingChatUrl,
2237
- f
2238
- );
2239
- o((J) => [
2240
- ...J,
215
+ padding: "2px",
216
+ backgroundColor: x === "Server connected" || x === "online" ? "#09BA00" : x === "Connecting to server..." ? "#DED000" : "#FF3408",
217
+ color: "#ffffff",
218
+ fontSize: "10px"
219
+ }, children: x }),
220
+ /* @__PURE__ */ o(P, { messages: m, chatBotData: t, theme: e, isLoading: c }),
221
+ /* @__PURE__ */ o("div", { style: k, children: /* @__PURE__ */ u("form", { onSubmit: b, style: {
222
+ display: "flex",
223
+ gap: "12px",
224
+ alignItems: "center"
225
+ }, children: [
226
+ /* @__PURE__ */ o(
227
+ "input",
2241
228
  {
2242
- sender_type: "bot",
2243
- message: O.n8n.message,
2244
- created_at: O.n8n.created_at,
2245
- suggested_prompts: O.n8n.suggested_prompts
229
+ type: "text",
230
+ placeholder: "Type a message...",
231
+ value: d,
232
+ onChange: (n) => p(n.target.value),
233
+ onKeyDown: v,
234
+ disabled: c,
235
+ style: r,
236
+ onFocus: (n) => {
237
+ n.target.style.boxShadow = "0 0 0 3px rgba(100, 150, 255, 0.3)", n.target.style.borderColor = "#60a5fa";
238
+ },
239
+ onBlur: (n) => {
240
+ n.target.style.boxShadow = "none", n.target.style.borderColor = e.fontColor;
241
+ }
2246
242
  }
2247
- ]);
2248
- } catch (O) {
2249
- console.error("Chat error:", O), o((J) => [
2250
- ...J,
243
+ ),
244
+ /* @__PURE__ */ o(
245
+ "button",
2251
246
  {
2252
- sender_type: "bot",
2253
- message: "Sorry, there was an error processing your request. Please try again.",
2254
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
2255
- suggested_prompts: []
247
+ onClick: b,
248
+ disabled: c || !d.trim(),
249
+ style: y,
250
+ "aria-label": "Send message",
251
+ onMouseEnter: (n) => {
252
+ !c && d.trim() && (n.currentTarget.style.transform = "translateY(-2px)", n.currentTarget.style.boxShadow = "0 8px 16px rgba(0,0,0,0.15)");
253
+ },
254
+ onMouseLeave: (n) => {
255
+ n.currentTarget.style.transform = "translateY(0)", n.currentTarget.style.boxShadow = "none";
256
+ },
257
+ children: /* @__PURE__ */ o(U, { size: 18 })
2256
258
  }
2257
- ]);
2258
- } finally {
2259
- s(!1);
2260
- }
2261
- }, A = {
259
+ )
260
+ ] }) })
261
+ ] });
262
+ }, X = ({ onClose: t, theme: e, chatBotData: s }) => {
263
+ const [i, f] = S(!1), [d, p] = S(!1), g = {
2262
264
  position: "fixed",
2263
265
  bottom: "112px",
2264
- [C ? "left" : "right"]: "32px",
266
+ [s.position === "left" ? "left" : "right"]: "32px",
2265
267
  zIndex: 50,
2266
- width: l ? "684px" : "384px",
2267
- height: l ? "620px" : "520px",
2268
- background: `${t.backgroundColor}cc`,
268
+ width: i ? "684px" : "384px",
269
+ height: i ? "620px" : "520px",
270
+ background: `${e.backgroundColor}cc`,
2269
271
  backdropFilter: "blur(16px)",
2270
272
  WebkitBackdropFilter: "blur(16px)",
2271
273
  borderRadius: "16px",
@@ -2275,18 +277,18 @@ const {
2275
277
  overflow: "hidden",
2276
278
  fontFamily: "system-ui, -apple-system, sans-serif",
2277
279
  boxShadow: "0 10px 25px -3px rgba(0,0,0,0.1)"
2278
- }, x = {
280
+ }, m = {
2279
281
  padding: "16px 20px",
2280
- background: `linear-gradient(135deg, ${t.primaryColor}, ${t.secondaryColor})`,
2281
- color: t.fontColor,
282
+ background: `linear-gradient(135deg, ${e.primaryColor}, ${e.secondaryColor})`,
283
+ color: e.fontColor,
2282
284
  borderRadius: "16px 16px 0 0",
2283
285
  display: "flex",
2284
286
  alignItems: "center",
2285
287
  justifyContent: "space-between",
2286
288
  boxShadow: "0 4px 6px -1px rgba(0,0,0,0.1)"
2287
- }, k = {
289
+ }, h = {
2288
290
  position: "relative"
2289
- }, P = {
291
+ }, c = {
2290
292
  width: "44px",
2291
293
  height: "44px",
2292
294
  borderRadius: "50%",
@@ -2294,174 +296,151 @@ const {
2294
296
  display: "flex",
2295
297
  alignItems: "center",
2296
298
  justifyContent: "center"
2297
- }, E = {
299
+ }, C = {
2298
300
  position: "absolute",
2299
301
  bottom: 0,
2300
302
  right: 0,
2301
303
  width: "14px",
2302
304
  height: "14px",
2303
- backgroundColor: "#34d399",
305
+ backgroundColor: d ? "#00BF49" : "#F54927",
2304
306
  borderRadius: "50%",
2305
307
  border: "3px solid white"
2306
- }, T = {
308
+ }, b = {
2307
309
  fontSize: "18px",
2308
310
  fontWeight: "600",
2309
311
  margin: 0,
2310
312
  lineHeight: "1.2"
2311
- }, Y = {
313
+ }, v = {
2312
314
  fontSize: "12px",
2313
315
  opacity: 0.9,
2314
316
  margin: 0,
2315
317
  lineHeight: "1.3"
2316
- }, H = {
318
+ }, r = {
2317
319
  padding: "8px",
2318
320
  borderRadius: "50%",
2319
321
  background: "transparent",
2320
322
  border: "none",
2321
323
  cursor: "pointer",
2322
324
  transition: "background 0.2s"
2323
- }, oe = {
325
+ }, y = {
2324
326
  padding: "12px 20px",
2325
327
  borderTop: "1px solid rgba(255,255,255,0.2)",
2326
- background: t.backgroundColor,
328
+ background: e.backgroundColor,
2327
329
  textAlign: "center"
2328
- }, se = {
330
+ }, k = {
2329
331
  fontSize: "11px",
2330
- color: t.fontColor,
332
+ color: e.fontColor,
2331
333
  letterSpacing: "0.5px"
2332
- }, W = {
334
+ }, z = {
2333
335
  fontWeight: "600"
2334
- }, D = (S, O) => {
2335
- S.currentTarget.style.background = O ? "rgba(255,255,255,0.2)" : "transparent";
2336
- }, B = {
2337
- flex: 1,
2338
- display: "flex",
2339
- alignItems: "center",
2340
- justifyContent: "center",
2341
- gap: "8px",
2342
- color: t.fontColor,
2343
- opacity: 0.9,
2344
- fontSize: "14px"
336
+ }, w = (l, I) => {
337
+ l.currentTarget.style.background = I ? "rgba(255,255,255,0.2)" : "transparent";
338
+ }, n = (l) => {
339
+ p(l === "online");
2345
340
  };
2346
- return /* @__PURE__ */ F("div", { style: A, children: [
2347
- /* @__PURE__ */ F("div", { style: x, children: [
2348
- /* @__PURE__ */ F("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
2349
- /* @__PURE__ */ F("div", { style: k, children: [
2350
- /* @__PURE__ */ y("div", { style: P, children: /* @__PURE__ */ y(Xe, { size: 22 }) }),
2351
- /* @__PURE__ */ y("span", { style: E })
341
+ return /* @__PURE__ */ u("div", { style: g, children: [
342
+ /* @__PURE__ */ u("div", { style: m, children: [
343
+ /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
344
+ /* @__PURE__ */ u("div", { style: h, children: [
345
+ /* @__PURE__ */ o("div", { style: c, children: /* @__PURE__ */ o(D, { size: 22 }) }),
346
+ /* @__PURE__ */ o("span", { style: C })
2352
347
  ] }),
2353
- /* @__PURE__ */ F("div", { children: [
2354
- /* @__PURE__ */ y("h3", { style: T, children: n.name }),
2355
- /* @__PURE__ */ y("p", { style: Y, children: n.subTitle })
348
+ /* @__PURE__ */ u("div", { children: [
349
+ /* @__PURE__ */ o("h3", { style: b, children: s.name }),
350
+ /* @__PURE__ */ o("p", { style: v, children: s.subTitle })
2356
351
  ] })
2357
352
  ] }),
2358
- /* @__PURE__ */ F("div", { style: { display: "flex", alignItems: "left" }, children: [
2359
- /* @__PURE__ */ y(
353
+ /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "left" }, children: [
354
+ /* @__PURE__ */ o(
2360
355
  "button",
2361
356
  {
2362
- onClick: () => p((S) => !S),
357
+ onClick: () => f((l) => !l),
2363
358
  "aria-label": "expand chat",
2364
- style: H,
2365
- onMouseEnter: (S) => D(S, !0),
2366
- onMouseLeave: (S) => D(S, !1),
2367
- children: l ? /* @__PURE__ */ y(Rt, { size: 20 }) : /* @__PURE__ */ y(Tt, { size: 20 })
359
+ style: r,
360
+ onMouseEnter: (l) => w(l, !0),
361
+ onMouseLeave: (l) => w(l, !1),
362
+ children: i ? /* @__PURE__ */ o(j, { size: 20 }) : /* @__PURE__ */ o(B, { size: 20 })
2368
363
  }
2369
364
  ),
2370
- /* @__PURE__ */ y(
365
+ /* @__PURE__ */ o(
2371
366
  "button",
2372
367
  {
2373
- onClick: e,
368
+ onClick: t,
2374
369
  "aria-label": "close chat",
2375
- style: H,
2376
- onMouseEnter: (S) => D(S, !0),
2377
- onMouseLeave: (S) => D(S, !1),
2378
- children: /* @__PURE__ */ y(Ot, { size: 20 })
370
+ style: r,
371
+ onMouseEnter: (l) => w(l, !0),
372
+ onMouseLeave: (l) => w(l, !1),
373
+ children: /* @__PURE__ */ o(O, { size: 20 })
2379
374
  }
2380
375
  )
2381
376
  ] })
2382
377
  ] }),
2383
- f ? /* @__PURE__ */ y(Z, { children: i && r.length === 0 ? /* @__PURE__ */ y("div", { style: B, children: /* @__PURE__ */ y("span", { children: "connecting server...." }) }) : /* @__PURE__ */ y(Z, { children: d ? /* @__PURE__ */ y("div", { style: B, children: /* @__PURE__ */ y("span", { children: d }) }) : /* @__PURE__ */ F(Z, { children: [
2384
- /* @__PURE__ */ y(Ft, { messages: r, isLoading: i, theme: t }),
2385
- /* @__PURE__ */ y(kt, { onSendMessage: w, isLoading: i, theme: t })
2386
- ] }) }) }) : /* @__PURE__ */ y(
2387
- cr,
2388
- {
2389
- theme: t,
2390
- chatBotData: n,
2391
- trackFormSubmission: m
2392
- }
2393
- ),
2394
- /* @__PURE__ */ y("div", { style: oe, children: /* @__PURE__ */ F("p", { style: se, children: [
378
+ /* @__PURE__ */ o(K, { chatBotData: s, theme: e, onlineStatus: n }),
379
+ /* @__PURE__ */ o("div", { style: y, children: /* @__PURE__ */ u("p", { style: k, children: [
2395
380
  "powered by ",
2396
- /* @__PURE__ */ y("span", { style: W, children: "clone67.com" })
381
+ /* @__PURE__ */ o("span", { style: z, children: "clone67.com" })
2397
382
  ] }) })
2398
383
  ] });
2399
- }, _r = ({
2400
- pineconeNamespace: e,
2401
- onGoingChatUrl: t,
2402
- initiateChatUrl: n,
2403
- fetchChatHistoryUrl: r,
2404
- primaryColor: o = "#3b82f6",
2405
- secondaryColor: i = "#8b5cf6",
2406
- backgroundColor: s = "#ffffff",
2407
- fontColor: l = "#1f2937",
2408
- placeholderColor: p = "#9ca3af",
2409
- position: u = "right",
2410
- name: c = "Assistant",
2411
- subTitle: d = "Typically replies instantly",
2412
- welcomeText: b = "Hi! How can I help you today?"
384
+ }, Z = ({
385
+ pineconeNamespace: t,
386
+ primaryColor: e = "#3b82f6",
387
+ secondaryColor: s = "#8b5cf6",
388
+ backgroundColor: i = "#ffffff",
389
+ fontColor: f = "#1f2937",
390
+ placeholderColor: d = "#9ca3af",
391
+ position: p = "right",
392
+ name: x = "Assistant",
393
+ subTitle: g = "Typically replies instantly",
394
+ welcomeText: m = "Hi! How can I help you today?"
2413
395
  }) => {
2414
- const [C, f] = I(!1), m = () => {
2415
- f((T) => !T), localStorage.removeItem("clone67ChatSessionId");
2416
- }, h = () => f((T) => !T), w = {
2417
- primaryColor: o,
2418
- secondaryColor: i,
2419
- backgroundColor: s,
2420
- fontColor: l,
2421
- placeholderColor: p,
2422
- inputBackgroundColor: s
2423
- }, A = {
2424
- name: c,
2425
- subTitle: d,
2426
- welcomeText: b,
2427
- onGoingChatUrl: t,
2428
- fetchChatHistoryUrl: r,
2429
- initiateChatUrl: n,
2430
- pineconeNamespace: e,
2431
- position: u
2432
- }, x = u === "left", k = "32px", P = {
396
+ const [h, c] = S(!1), C = () => {
397
+ c((n) => !n), localStorage.removeItem("clone67ChatSessionId");
398
+ }, b = () => c((n) => !n), v = {
399
+ primaryColor: e,
400
+ secondaryColor: s,
401
+ backgroundColor: i,
402
+ fontColor: f,
403
+ placeholderColor: d,
404
+ inputBackgroundColor: i
405
+ }, r = {
406
+ name: x,
407
+ subTitle: g,
408
+ welcomeText: m,
409
+ pineconeNamespace: t,
410
+ position: p
411
+ }, y = p === "left", k = "32px", z = {
2433
412
  position: "fixed",
2434
413
  bottom: "104px",
2435
- [x ? "left" : "right"]: k,
414
+ [y ? "left" : "right"]: k,
2436
415
  zIndex: 9999,
2437
416
  pointerEvents: "auto"
2438
- }, E = {
417
+ }, w = {
2439
418
  position: "fixed",
2440
419
  bottom: "32px",
2441
- [x ? "left" : "right"]: k,
420
+ [y ? "left" : "right"]: k,
2442
421
  zIndex: 1e4,
2443
422
  pointerEvents: "auto"
2444
423
  };
2445
- return /* @__PURE__ */ F(Z, { children: [
2446
- C && /* @__PURE__ */ y("div", { style: P, children: /* @__PURE__ */ y(
2447
- ur,
424
+ return /* @__PURE__ */ u(M, { children: [
425
+ h && /* @__PURE__ */ o("div", { style: z, children: /* @__PURE__ */ o(
426
+ X,
2448
427
  {
2449
- onClose: m,
2450
- theme: w,
2451
- chatBotData: A
428
+ onClose: C,
429
+ theme: v,
430
+ chatBotData: r
2452
431
  }
2453
432
  ) }),
2454
- /* @__PURE__ */ y("div", { style: E, children: /* @__PURE__ */ y(
2455
- At,
433
+ /* @__PURE__ */ o("div", { style: w, children: /* @__PURE__ */ o(
434
+ F,
2456
435
  {
2457
- onMinimise: h,
2458
- isOpen: C,
2459
- theme: w,
2460
- chatBotData: A
436
+ onMinimise: b,
437
+ isOpen: h,
438
+ theme: v,
439
+ chatBotData: r
2461
440
  }
2462
441
  ) })
2463
442
  ] });
2464
443
  };
2465
444
  export {
2466
- _r as default
445
+ Z as default
2467
446
  };