@paramms/chat-widget 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsxs as H, jsx as n, Fragment as J } from "react/jsx-runtime";
2
- import { useState as D, useRef as k, useEffect as W } from "react";
3
- import { mount as F } from "./index.js";
4
- function K({ size: r = 26 }) {
5
- return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: r, height: r, fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ n(
1
+ import { jsxs as W, jsx as n, Fragment as K } from "react/jsx-runtime";
2
+ import { useState as _, useRef as D, useEffect as O } from "react";
3
+ import { mount as J } from "./index.js";
4
+ function Q({ size: l = 26 }) {
5
+ return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: l, height: l, fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ n(
6
6
  "path",
7
7
  {
8
8
  d: "M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z",
@@ -14,297 +14,329 @@ function K({ size: r = 26 }) {
14
14
  }
15
15
  ) });
16
16
  }
17
- function Q({ size: r = 22 }) {
18
- return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: r, height: r, fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M18 6 6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) });
17
+ function V({ size: l = 22 }) {
18
+ return /* @__PURE__ */ n("svg", { viewBox: "0 0 24 24", width: l, height: l, fill: "none", xmlns: "http://www.w3.org/2000/svg", "aria-hidden": "true", children: /* @__PURE__ */ n("path", { d: "M18 6 6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round" }) });
19
19
  }
20
- function T({
21
- url: r,
22
- apiUrl: i,
23
- profileId: d,
24
- token: o,
25
- refreshToken: l,
26
- userId: s,
20
+ function E({
21
+ url: l,
22
+ apiUrl: o,
23
+ profileId: s,
24
+ token: e,
25
+ refreshToken: r,
26
+ userId: d,
27
27
  userName: c,
28
- userEmail: p,
29
- userAvatar: y,
30
- contextTitle: v,
31
- contextSubtitle: a,
32
- contextStatus: j,
33
- subjectId: S,
28
+ userEmail: u,
29
+ userAvatar: m,
30
+ contextTitle: C,
31
+ contextSubtitle: h,
32
+ contextStatus: R,
33
+ subjectId: j,
34
34
  accent: f,
35
- accent2: w,
36
- theme: m,
37
- webfont: h,
35
+ accent2: x,
36
+ theme: $,
37
+ webfont: p,
38
38
  launcher: t,
39
- position: x,
40
- launcherMessage: M,
41
- quickReplies: z,
39
+ position: b,
40
+ launcherMessage: L,
41
+ quickReplies: S,
42
42
  height: g = "100%",
43
43
  i18n: B,
44
- features: b,
45
- translateLang: $,
46
- inbox: C,
47
- inboxScope: u
44
+ features: w,
45
+ translateLang: M,
46
+ inbox: y,
47
+ inboxScope: a
48
48
  }) {
49
- const R = k(null), e = k(null), [L, _] = D(!1);
50
- return W(() => {
51
- var O;
52
- if (!L && R.current)
53
- return (O = e.current) == null || O.close(), e.current = F({
54
- el: R.current,
55
- url: r,
56
- ...i ? { apiUrl: i } : {},
57
- profileId: d,
58
- ...S ? { subjectId: S } : {},
59
- ...o ? { token: o } : {},
60
- ...l ? { refreshToken: l } : {},
61
- ...s ? { userId: s } : {},
62
- ...s || c || p || y ? {
49
+ const v = D(null), i = D(null), [z, H] = _(!1);
50
+ return O(() => {
51
+ var G;
52
+ if (!z && v.current)
53
+ return (G = i.current) == null || G.close(), i.current = J({
54
+ el: v.current,
55
+ url: l,
56
+ ...o ? { apiUrl: o } : {},
57
+ profileId: s,
58
+ ...j ? { subjectId: j } : {},
59
+ ...e ? { token: e } : {},
60
+ ...r ? { refreshToken: r } : {},
61
+ ...d ? { userId: d } : {},
62
+ ...d || c || u || m ? {
63
63
  user: {
64
64
  ...c ? { name: c } : {},
65
- ...p ? { email: p } : {},
66
- ...y ? { avatar: y } : {}
65
+ ...u ? { email: u } : {},
66
+ ...m ? { avatar: m } : {}
67
67
  }
68
68
  } : {},
69
- ...v ? {
69
+ ...C ? {
70
70
  subject: {
71
- title: v,
72
- ...a ? { subtitle: a } : {},
73
- ...j ? { status: j } : {}
71
+ title: C,
72
+ ...h ? { subtitle: h } : {},
73
+ ...R ? { status: R } : {}
74
74
  }
75
75
  } : {},
76
- ...z ? { quickReplies: z } : {},
76
+ ...S ? { quickReplies: S } : {},
77
77
  ...f ? { accent: f } : {},
78
- ...w ? { accent2: w } : {},
79
- ...m ? { theme: m } : {},
80
- ...h === !1 ? { webfont: !1 } : {},
81
- ...$ ? { translateLang: $ } : {},
78
+ ...x ? { accent2: x } : {},
79
+ ...$ ? { theme: $ } : {},
80
+ ...p === !1 ? { webfont: !1 } : {},
81
+ ...M ? { translateLang: M } : {},
82
82
  ...B ? { i18n: B } : {},
83
- ...b ? { features: b } : {},
84
- ...C && !t ? { onBack: () => _(!0) } : {},
85
- ...t ? { launcher: t, position: x ?? "bottom-right", ...M ? { launcherMessage: M } : {} } : {}
83
+ ...w ? { features: w } : {},
84
+ ...y && !t ? { onBack: () => H(!0) } : {},
85
+ ...t ? { launcher: t, position: b ?? "bottom-right", ...L ? { launcherMessage: L } : {} } : {}
86
86
  }), () => {
87
- var G;
88
- (G = e.current) == null || G.close(), e.current = null;
87
+ var Y;
88
+ (Y = i.current) == null || Y.close(), i.current = null;
89
89
  };
90
- }, [r, i, d, S, o, s, c, p, f, t, x, M, $, C, L]), C && !t && L ? /* @__PURE__ */ n(
91
- A,
90
+ }, [l, o, s, j, e, d, c, u, f, t, b, L, M, y, z]), t && y ? /* @__PURE__ */ n(
91
+ X,
92
92
  {
93
- url: r,
94
- ...i ? { apiUrl: i } : {},
95
- profileId: d,
96
- ...o ? { token: o } : {},
97
- ...l ? { refreshToken: l } : {},
98
- ...s ? { userId: s } : {},
93
+ url: l,
94
+ ...o ? { apiUrl: o } : {},
95
+ profileId: s,
96
+ ...e ? { token: e } : {},
97
+ ...r ? { refreshToken: r } : {},
98
+ ...d ? { userId: d } : {},
99
99
  ...c ? { userName: c } : {},
100
- ...p ? { userEmail: p } : {},
100
+ ...u ? { userEmail: u } : {},
101
+ scope: a ?? "tenant",
101
102
  ...f ? { accent: f } : {},
102
- ...w ? { accent2: w } : {},
103
- ...m ? { theme: m } : {},
104
- ...h === !1 ? { webfont: !1 } : {},
105
- scope: u ?? "tenant",
103
+ floating: !0,
104
+ position: b ?? "bottom-right"
105
+ }
106
+ ) : y && !t && z ? /* @__PURE__ */ n(
107
+ F,
108
+ {
109
+ url: l,
110
+ ...o ? { apiUrl: o } : {},
111
+ profileId: s,
112
+ ...e ? { token: e } : {},
113
+ ...r ? { refreshToken: r } : {},
114
+ ...d ? { userId: d } : {},
115
+ ...c ? { userName: c } : {},
116
+ ...u ? { userEmail: u } : {},
117
+ ...f ? { accent: f } : {},
118
+ ...x ? { accent2: x } : {},
119
+ ...$ ? { theme: $ } : {},
120
+ ...p === !1 ? { webfont: !1 } : {},
121
+ scope: a ?? "tenant",
106
122
  height: g,
107
- onClose: () => _(!1)
123
+ onClose: () => H(!1)
108
124
  }
109
125
  ) : /* @__PURE__ */ n(
110
126
  "div",
111
127
  {
112
- ref: R,
128
+ ref: v,
113
129
  style: t ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: g, minHeight: g === "100%" ? "480px" : void 0 }
114
130
  }
115
131
  );
116
132
  }
117
- function E({
118
- url: r,
119
- apiUrl: i,
120
- profileId: d,
121
- token: o,
122
- refreshToken: l,
123
- listingId: s,
133
+ function I({
134
+ url: l,
135
+ apiUrl: o,
136
+ profileId: s,
137
+ token: e,
138
+ refreshToken: r,
139
+ listingId: d,
124
140
  listingTitle: c,
125
- listingMeta: p,
126
- listingPrice: y,
127
- listingStatus: v,
128
- userId: a,
129
- userName: j,
130
- userEmail: S,
141
+ listingMeta: u,
142
+ listingPrice: m,
143
+ listingStatus: C,
144
+ userId: h,
145
+ userName: R,
146
+ userEmail: j,
131
147
  userAvatar: f,
132
- accent: w,
133
- accent2: m,
134
- theme: h,
148
+ accent: x,
149
+ accent2: $,
150
+ theme: p,
135
151
  webfont: t,
136
- launcher: x,
137
- position: M,
138
- launcherMessage: z,
152
+ launcher: b,
153
+ position: L,
154
+ launcherMessage: S,
139
155
  quickReplies: g,
140
156
  height: B = "100%",
141
- i18n: b,
142
- features: $,
143
- translateLang: C,
144
- inbox: u,
145
- inboxScope: R
157
+ i18n: w,
158
+ features: M,
159
+ translateLang: y,
160
+ inbox: a,
161
+ inboxScope: v
146
162
  }) {
147
- const e = k(null), L = k(null), [_, O] = D(!1);
148
- return W(() => {
149
- if (_ || !e.current) return;
150
- let G = !1;
151
- const V = setTimeout(() => {
152
- var Y;
153
- G || !e.current || ((Y = L.current) == null || Y.close(), L.current = F({
154
- el: e.current,
155
- url: r,
156
- ...i ? { apiUrl: i } : {},
157
- profileId: d,
158
- ...s ? { subjectId: `listing_${s}` } : {},
159
- ...o ? { token: o } : {},
160
- ...l ? { refreshToken: l } : {},
161
- ...a ? { userId: a } : {},
162
- ...a || j || S || f ? {
163
+ const i = D(null), z = D(null), [H, G] = _(!1);
164
+ return O(() => {
165
+ if (H || !i.current) return;
166
+ let Y = !1;
167
+ const Z = setTimeout(() => {
168
+ var A;
169
+ Y || !i.current || ((A = z.current) == null || A.close(), z.current = J({
170
+ el: i.current,
171
+ url: l,
172
+ ...o ? { apiUrl: o } : {},
173
+ profileId: s,
174
+ ...d ? { subjectId: `listing_${d}` } : {},
175
+ ...e ? { token: e } : {},
176
+ ...r ? { refreshToken: r } : {},
177
+ ...h ? { userId: h } : {},
178
+ ...h || R || j || f ? {
163
179
  user: {
164
- ...j ? { name: j } : {},
165
- ...S ? { email: S } : {},
180
+ ...R ? { name: R } : {},
181
+ ...j ? { email: j } : {},
166
182
  ...f ? { avatar: f } : {},
167
- ...s ? { meta: { listingId: s } } : {}
183
+ ...d ? { meta: { listingId: d } } : {}
168
184
  }
169
185
  } : {},
170
186
  ...c ? {
171
187
  subject: {
172
188
  title: c,
173
- ...p ? { subtitle: p } : {},
174
- ...y ? { tags: [`$${y.toLocaleString()}`] } : {},
175
- ...v ? { status: v } : {}
189
+ ...u ? { subtitle: u } : {},
190
+ ...m ? { tags: [`$${m.toLocaleString()}`] } : {},
191
+ ...C ? { status: C } : {}
176
192
  }
177
193
  } : {},
178
194
  ...g ? { quickReplies: g } : {},
179
- ...w ? { accent: w } : {},
180
- ...m ? { accent2: m } : {},
181
- ...h ? { theme: h } : {},
195
+ ...x ? { accent: x } : {},
196
+ ...$ ? { accent2: $ } : {},
197
+ ...p ? { theme: p } : {},
182
198
  ...t === !1 ? { webfont: !1 } : {},
183
- ...C ? { translateLang: C } : {},
184
- ...b ? { i18n: b } : {},
185
- ...$ ? { features: $ } : {},
186
- ...u && !x ? { onBack: () => O(!0) } : {},
187
- ...x ? { launcher: x, position: M ?? "bottom-right", ...z ? { launcherMessage: z } : {} } : {}
199
+ ...y ? { translateLang: y } : {},
200
+ ...w ? { i18n: w } : {},
201
+ ...M ? { features: M } : {},
202
+ ...a && !b ? { onBack: () => G(!0) } : {},
203
+ ...b ? { launcher: b, position: L ?? "bottom-right", ...S ? { launcherMessage: S } : {} } : {}
188
204
  }));
189
205
  }, 0);
190
206
  return () => {
191
- var Y;
192
- G = !0, clearTimeout(V), (Y = L.current) == null || Y.close(), L.current = null;
207
+ var A;
208
+ Y = !0, clearTimeout(Z), (A = z.current) == null || A.close(), z.current = null;
193
209
  };
194
- }, [r, i, d, s, o, a, w, x, M, z, C, u, _]), u && !x && _ ? /* @__PURE__ */ n(
195
- A,
210
+ }, [l, o, s, d, e, h, x, b, L, S, y, a, H]), b && a ? /* @__PURE__ */ n(
211
+ X,
212
+ {
213
+ url: l,
214
+ ...o ? { apiUrl: o } : {},
215
+ profileId: s,
216
+ ...e ? { token: e } : {},
217
+ ...r ? { refreshToken: r } : {},
218
+ ...h ? { userId: h } : {},
219
+ ...R ? { userName: R } : {},
220
+ ...j ? { userEmail: j } : {},
221
+ scope: v ?? "tenant",
222
+ ...x ? { accent: x } : {},
223
+ floating: !0,
224
+ position: L ?? "bottom-right"
225
+ }
226
+ ) : a && !b && H ? /* @__PURE__ */ n(
227
+ F,
196
228
  {
197
- url: r,
198
- ...i ? { apiUrl: i } : {},
199
- profileId: d,
200
- ...o ? { token: o } : {},
201
- ...l ? { refreshToken: l } : {},
202
- ...a ? { userId: a } : {},
203
- ...j ? { userName: j } : {},
204
- ...S ? { userEmail: S } : {},
205
- ...w ? { accent: w } : {},
206
- ...m ? { accent2: m } : {},
207
- ...h ? { theme: h } : {},
229
+ url: l,
230
+ ...o ? { apiUrl: o } : {},
231
+ profileId: s,
232
+ ...e ? { token: e } : {},
233
+ ...r ? { refreshToken: r } : {},
234
+ ...h ? { userId: h } : {},
235
+ ...R ? { userName: R } : {},
236
+ ...j ? { userEmail: j } : {},
237
+ ...x ? { accent: x } : {},
238
+ ...$ ? { accent2: $ } : {},
239
+ ...p ? { theme: p } : {},
208
240
  ...t === !1 ? { webfont: !1 } : {},
209
- scope: R ?? "tenant",
241
+ scope: v ?? "tenant",
210
242
  height: B,
211
- onClose: () => O(!1)
243
+ onClose: () => G(!1)
212
244
  }
213
245
  ) : /* @__PURE__ */ n(
214
246
  "div",
215
247
  {
216
- ref: e,
217
- style: x ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: B, minHeight: B === "100%" ? "480px" : void 0 }
248
+ ref: i,
249
+ style: b ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: B, minHeight: B === "100%" ? "480px" : void 0 }
218
250
  }
219
251
  );
220
252
  }
221
- function X(r) {
222
- const [i, d] = D(
223
- typeof window < "u" && window.innerWidth <= r
253
+ function q(l) {
254
+ const [o, s] = _(
255
+ typeof window < "u" && window.innerWidth <= l
224
256
  );
225
- return W(() => {
257
+ return O(() => {
226
258
  if (typeof window > "u" || !window.matchMedia) return;
227
- const o = window.matchMedia(`(max-width: ${r}px)`), l = (s) => d(s.matches);
228
- return d(o.matches), o.addEventListener("change", l), () => o.removeEventListener("change", l);
229
- }, [r]), i;
259
+ const e = window.matchMedia(`(max-width: ${l}px)`), r = (d) => s(d.matches);
260
+ return s(e.matches), e.addEventListener("change", r), () => e.removeEventListener("change", r);
261
+ }, [l]), o;
230
262
  }
231
- function A({
232
- url: r,
233
- apiUrl: i,
234
- profileId: d,
235
- tenantId: o,
236
- token: l,
237
- refreshToken: s,
263
+ function F({
264
+ url: l,
265
+ apiUrl: o,
266
+ profileId: s,
267
+ tenantId: e,
268
+ token: r,
269
+ refreshToken: d,
238
270
  userId: c,
239
- userName: p,
240
- userEmail: y,
241
- accent: v,
242
- theme: a,
243
- webfont: j,
244
- height: S = "100%",
271
+ userName: u,
272
+ userEmail: m,
273
+ accent: C,
274
+ theme: h,
275
+ webfont: R,
276
+ height: j = "100%",
245
277
  i18n: f,
246
- onClose: w,
247
- scope: m = "tenant"
278
+ onClose: x,
279
+ scope: $ = "tenant"
248
280
  }) {
249
- const h = !d && !o, [t, x] = D(null), [M, z] = D(!1), g = k(null), B = k(null), b = k(null), $ = k(null);
250
- return W(() => {
281
+ const p = !s && !e, [t, b] = _(null), [L, S] = _(!1), g = D(null), B = D(null), w = D(null), M = D(null);
282
+ return O(() => {
251
283
  if (!g.current) return;
252
- let C = !1;
253
- return import("./chatlist.js").catch((u) => (console.error("[relay] could not load the conversation list module.", u), C || z(!0), null)).then((u) => {
254
- if (!u) return;
255
- const { mountChatList: R } = u;
256
- C || !g.current || (b.current = R({
284
+ let y = !1;
285
+ return import("./chatlist.js").catch((a) => (console.error("[relay] could not load the conversation list module.", a), y || S(!0), null)).then((a) => {
286
+ if (!a) return;
287
+ const { mountChatList: v } = a;
288
+ y || !g.current || (w.current = v({
257
289
  el: g.current,
258
- url: r,
259
- ...i ? { apiUrl: i } : {},
260
- ...d ? { profileId: d } : {},
261
- ...o ? { tenantId: o } : {},
262
- ...a ? { theme: a } : {},
263
- ...j === !1 ? { webfont: !1 } : {},
264
- scope: m,
290
+ url: l,
291
+ ...o ? { apiUrl: o } : {},
292
+ ...s ? { profileId: s } : {},
293
+ ...e ? { tenantId: e } : {},
294
+ ...h ? { theme: h } : {},
295
+ ...R === !1 ? { webfont: !1 } : {},
296
+ scope: $,
265
297
  // We overlay a ✕ at top-right when `onClose` is given — tell the list to
266
298
  // keep its header clear so the ✕ doesn't land on the ✎ compose button.
267
- ...w ? { reserveCloseSpace: !0 } : {},
268
- onSelect: (e) => x(e),
299
+ ...x ? { reserveCloseSpace: !0 } : {},
300
+ onSelect: (i) => b(i),
269
301
  // Compose (✎) opens the chatroom's general support thread — without
270
302
  // this a user with no conversations yet had an empty list and no way
271
303
  // to ever start one, which is what made ChatApp feel broken.
272
304
  // Compose target: the configured chatroom, else the tenant's default
273
305
  // (oldest chatroom, reported by the server on the first list fetch).
274
306
  onNewChat: () => {
275
- var L;
276
- const e = (L = b.current) == null ? void 0 : L.defaultProfileId();
277
- e && x({ id: "__new__", profileId: e, state: "open", updatedAt: Date.now() });
307
+ var z;
308
+ const i = (z = w.current) == null ? void 0 : z.defaultProfileId();
309
+ i && b({ id: "__new__", profileId: i, state: "open", updatedAt: Date.now() });
278
310
  },
279
- ...l ? { token: l } : {},
311
+ ...r ? { token: r } : {},
280
312
  ...c ? { userId: c } : {},
281
- ...v ? { accent: v } : {},
313
+ ...C ? { accent: C } : {},
282
314
  ...f ? { i18n: f } : {}
283
315
  }));
284
316
  }), () => {
285
- var u;
286
- C = !0, (u = b.current) == null || u.close(), b.current = null;
317
+ var a;
318
+ y = !0, (a = w.current) == null || a.close(), w.current = null;
287
319
  };
288
- }, [r, i, d, o, l, c, m]), W(() => {
289
- var u;
320
+ }, [l, o, s, e, r, c, $]), O(() => {
321
+ var a;
290
322
  if (!B.current || !t) return;
291
- (u = $.current) == null || u.close(), $.current = F({
323
+ (a = M.current) == null || a.close(), M.current = J({
292
324
  el: B.current,
293
- url: r,
294
- ...i ? { apiUrl: i } : {},
295
- profileId: t.profileId ?? d,
325
+ url: l,
326
+ ...o ? { apiUrl: o } : {},
327
+ profileId: t.profileId ?? s,
296
328
  // rows always carry theirs; compose sets one explicitly
297
329
  // DM rows open as direct conversations (kind + peer). Opening them via
298
330
  // their dm:… subjectId only works for the participant that OWNS the
299
331
  // thread key — the other side would silently fork a duplicate.
300
332
  ...t.kind === "direct" && t.peerId ? { kind: "direct", peerId: t.peerId } : t.subjectId ? { subjectId: t.subjectId } : {},
301
- ...l ? { token: l } : {},
302
- ...s ? { refreshToken: s } : {},
333
+ ...r ? { token: r } : {},
334
+ ...d ? { refreshToken: d } : {},
303
335
  ...c ? { userId: c } : {},
304
- ...c || p || y ? {
336
+ ...c || u || m ? {
305
337
  user: {
306
- ...p ? { name: p } : {},
307
- ...y ? { email: y } : {}
338
+ ...u ? { name: u } : {},
339
+ ...m ? { email: m } : {}
308
340
  }
309
341
  } : {},
310
342
  ...t.subjectTitle ? {
@@ -313,29 +345,29 @@ function A({
313
345
  ...t.subjectMeta ? { subtitle: t.subjectMeta } : {}
314
346
  }
315
347
  } : {},
316
- ...v ? { accent: v } : {},
348
+ ...C ? { accent: C } : {},
317
349
  // Stack navigation: the chatroom's back chevron returns to the list.
318
- onBack: () => x(null)
350
+ onBack: () => b(null)
319
351
  });
320
- const C = setInterval(() => {
321
- var R;
322
- return (R = b.current) == null ? void 0 : R.refresh();
352
+ const y = setInterval(() => {
353
+ var v;
354
+ return (v = w.current) == null ? void 0 : v.refresh();
323
355
  }, 2e4);
324
356
  return () => {
325
- var R, e;
326
- clearInterval(C), (R = $.current) == null || R.close(), $.current = null, (e = b.current) == null || e.refresh();
357
+ var v, i;
358
+ clearInterval(y), (v = M.current) == null || v.close(), M.current = null, (i = w.current) == null || i.refresh();
327
359
  };
328
- }, [t == null ? void 0 : t.id]), h ? /* @__PURE__ */ H("div", { style: { padding: 16, font: "13px system-ui", color: "#b91c1c", background: "#fef2f2", borderRadius: 8 }, children: [
360
+ }, [t == null ? void 0 : t.id]), p ? /* @__PURE__ */ W("div", { style: { padding: 16, font: "13px system-ui", color: "#b91c1c", background: "#fef2f2", borderRadius: 8 }, children: [
329
361
  "[relay] <ChatApp/> needs a ",
330
362
  /* @__PURE__ */ n("code", { children: "profileId" }),
331
363
  " or a ",
332
364
  /* @__PURE__ */ n("code", { children: "tenantId" }),
333
365
  "."
334
- ] }) : /* @__PURE__ */ H("div", { style: { position: "relative", width: "100%", height: S, minHeight: "400px", overflow: "hidden", background: "#fff" }, children: [
335
- w && !t && /* @__PURE__ */ n(
366
+ ] }) : /* @__PURE__ */ W("div", { style: { position: "relative", width: "100%", height: j, minHeight: "400px", overflow: "hidden", background: "#fff" }, children: [
367
+ x && !t && /* @__PURE__ */ n(
336
368
  "button",
337
369
  {
338
- onClick: w,
370
+ onClick: x,
339
371
  "aria-label": (f == null ? void 0 : f.close) ?? "Close",
340
372
  style: {
341
373
  position: "absolute",
@@ -355,7 +387,7 @@ function A({
355
387
  lineHeight: 1,
356
388
  cursor: "pointer"
357
389
  },
358
- children: /* @__PURE__ */ n(Q, { size: 18 })
390
+ children: /* @__PURE__ */ n(V, { size: 18 })
359
391
  }
360
392
  ),
361
393
  /* @__PURE__ */ n("div", { style: {
@@ -363,43 +395,43 @@ function A({
363
395
  inset: 0,
364
396
  display: t ? "none" : "flex",
365
397
  flexDirection: "column"
366
- }, children: M ? /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%", padding: 16, font: "13px system-ui", color: "#b91c1c", textAlign: "center" }, children: (f == null ? void 0 : f.error) ?? "Could not load conversations." }) : /* @__PURE__ */ n("div", { ref: g, style: { width: "100%", height: "100%" } }) }),
398
+ }, children: L ? /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "center", width: "100%", height: "100%", padding: 16, font: "13px system-ui", color: "#b91c1c", textAlign: "center" }, children: (f == null ? void 0 : f.error) ?? "Could not load conversations." }) : /* @__PURE__ */ n("div", { ref: g, style: { width: "100%", height: "100%" } }) }),
367
399
  t && /* @__PURE__ */ n("div", { style: { position: "absolute", inset: 0, display: "flex", flexDirection: "column" }, children: /* @__PURE__ */ n("div", { ref: B, style: { width: "100%", height: "100%" } }) })
368
400
  ] });
369
401
  }
370
- function I({
371
- url: r,
372
- apiUrl: i,
373
- profileId: d,
374
- tenantId: o,
375
- token: l,
376
- refreshToken: s,
402
+ function X({
403
+ url: l,
404
+ apiUrl: o,
405
+ profileId: s,
406
+ tenantId: e,
407
+ token: r,
408
+ refreshToken: d,
377
409
  userId: c,
378
- userName: p,
379
- userEmail: y,
380
- scope: v,
381
- accent: a = "#6c5ce7",
382
- floating: j = !0,
383
- position: S = "bottom-right",
410
+ userName: u,
411
+ userEmail: m,
412
+ scope: C,
413
+ accent: h = "#6c5ce7",
414
+ floating: R = !0,
415
+ position: j = "bottom-right",
384
416
  label: f,
385
- panelWidth: w,
386
- panelHeight: m = "600px"
417
+ panelWidth: x,
418
+ panelHeight: $ = "600px"
387
419
  }) {
388
- const [h, t] = D(!1), x = k(null), M = S === "bottom-right", z = f ?? (j ? void 0 : "Messages"), g = X(479);
389
- if (W(() => {
390
- const e = (L) => {
391
- L.key === "Escape" && t(!1);
420
+ const [p, t] = _(!1), b = D(null), L = j === "bottom-right", S = f ?? (R ? void 0 : "Messages"), g = q(479);
421
+ if (O(() => {
422
+ const i = (z) => {
423
+ z.key === "Escape" && t(!1);
392
424
  };
393
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
394
- }, []), j)
395
- return /* @__PURE__ */ H("div", { style: {
425
+ return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
426
+ }, []), R)
427
+ return /* @__PURE__ */ W("div", { style: {
396
428
  position: "fixed",
397
- [M ? "right" : "left"]: "20px",
429
+ [L ? "right" : "left"]: "20px",
398
430
  bottom: "20px",
399
431
  zIndex: 9999,
400
432
  display: "flex",
401
433
  flexDirection: "column",
402
- alignItems: M ? "flex-end" : "flex-start",
434
+ alignItems: L ? "flex-end" : "flex-start",
403
435
  gap: "12px"
404
436
  }, children: [
405
437
  /* @__PURE__ */ n("div", { style: {
@@ -411,31 +443,31 @@ function I({
411
443
  borderRadius: "0",
412
444
  zIndex: 9998
413
445
  } : {
414
- width: `min(${w ?? "420px"}, calc(100vw - 40px))`,
415
- height: `min(${m}, calc(100dvh - 108px))`,
446
+ width: `min(${x ?? "420px"}, calc(100vw - 40px))`,
447
+ height: `min(${$}, calc(100dvh - 108px))`,
416
448
  borderRadius: "28px"
417
449
  },
418
450
  overflow: "hidden",
419
451
  boxShadow: g ? "none" : "0 12px 32px rgba(108,92,231,.14)",
420
452
  background: "#fff",
421
- display: h ? "flex" : "none",
453
+ display: p ? "flex" : "none",
422
454
  flexDirection: "column",
423
- transformOrigin: `bottom ${M ? "right" : "left"}`,
424
- animation: h ? "ocl-pop-in .18s ease" : "none"
455
+ transformOrigin: `bottom ${L ? "right" : "left"}`,
456
+ animation: p ? "ocl-pop-in .18s ease" : "none"
425
457
  }, children: /* @__PURE__ */ n(
426
- A,
458
+ F,
427
459
  {
428
- url: r,
429
- ...i ? { apiUrl: i } : {},
430
- ...d ? { profileId: d } : {},
431
- ...o ? { tenantId: o } : {},
432
- ...l ? { token: l } : {},
433
- ...s ? { refreshToken: s } : {},
460
+ url: l,
461
+ ...o ? { apiUrl: o } : {},
462
+ ...s ? { profileId: s } : {},
463
+ ...e ? { tenantId: e } : {},
464
+ ...r ? { token: r } : {},
465
+ ...d ? { refreshToken: d } : {},
434
466
  ...c ? { userId: c } : {},
435
- ...p ? { userName: p } : {},
436
- ...y ? { userEmail: y } : {},
437
- ...v ? { scope: v } : {},
438
- accent: a,
467
+ ...u ? { userName: u } : {},
468
+ ...m ? { userEmail: m } : {},
469
+ ...C ? { scope: C } : {},
470
+ accent: h,
439
471
  height: "100%",
440
472
  onClose: () => t(!1)
441
473
  }
@@ -443,15 +475,15 @@ function I({
443
475
  /* @__PURE__ */ n(
444
476
  "button",
445
477
  {
446
- ref: x,
447
- onClick: () => t((e) => !e),
448
- "aria-label": h ? "Close chat" : typeof z == "string" ? z : "Open chat",
449
- "aria-expanded": h,
478
+ ref: b,
479
+ onClick: () => t((i) => !i),
480
+ "aria-label": p ? "Close chat" : typeof S == "string" ? S : "Open chat",
481
+ "aria-expanded": p,
450
482
  style: {
451
483
  width: "56px",
452
484
  height: "56px",
453
485
  borderRadius: "50%",
454
- background: a,
486
+ background: h,
455
487
  color: "#fff",
456
488
  border: "none",
457
489
  fontSize: "20px",
@@ -461,50 +493,50 @@ function I({
461
493
  transition: "transform .15s",
462
494
  alignItems: "center",
463
495
  justifyContent: "center",
464
- display: h && g ? "none" : "flex"
496
+ display: p && g ? "none" : "flex"
465
497
  },
466
- onMouseEnter: (e) => {
467
- e.currentTarget.style.transform = "scale(1.08)";
498
+ onMouseEnter: (i) => {
499
+ i.currentTarget.style.transform = "scale(1.08)";
468
500
  },
469
- onMouseLeave: (e) => {
470
- e.currentTarget.style.transform = "scale(1)";
501
+ onMouseLeave: (i) => {
502
+ i.currentTarget.style.transform = "scale(1)";
471
503
  },
472
- children: h ? /* @__PURE__ */ n(Q, {}) : f ?? /* @__PURE__ */ n(K, {})
504
+ children: p ? /* @__PURE__ */ n(V, {}) : f ?? /* @__PURE__ */ n(Q, {})
473
505
  }
474
506
  ),
475
507
  /* @__PURE__ */ n("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
476
508
  ] });
477
- const B = `min(${w ?? "420px"}, calc(100vw - 16px))`, [b, $] = D(null), C = () => {
478
- !h && x.current && $(x.current.getBoundingClientRect()), t((e) => !e);
479
- }, u = b ? b.bottom + 8 : 0, R = b ? Math.max(8, window.innerWidth - b.right) : 0;
480
- return /* @__PURE__ */ H(J, { children: [
481
- /* @__PURE__ */ H(
509
+ const B = `min(${x ?? "420px"}, calc(100vw - 16px))`, [w, M] = _(null), y = () => {
510
+ !p && b.current && M(b.current.getBoundingClientRect()), t((i) => !i);
511
+ }, a = w ? w.bottom + 8 : 0, v = w ? Math.max(8, window.innerWidth - w.right) : 0;
512
+ return /* @__PURE__ */ W(K, { children: [
513
+ /* @__PURE__ */ W(
482
514
  "button",
483
515
  {
484
- ref: x,
485
- onClick: C,
516
+ ref: b,
517
+ onClick: y,
486
518
  style: {
487
519
  display: "inline-flex",
488
520
  alignItems: "center",
489
521
  gap: "6px",
490
522
  padding: "8px 16px",
491
523
  borderRadius: "8px",
492
- background: h ? a : "transparent",
493
- color: h ? "#fff" : a,
494
- border: `2px solid ${a}`,
524
+ background: p ? h : "transparent",
525
+ color: p ? "#fff" : h,
526
+ border: `2px solid ${h}`,
495
527
  fontSize: "14px",
496
528
  fontWeight: 600,
497
529
  cursor: "pointer",
498
530
  transition: "background .15s, color .15s"
499
531
  },
500
532
  children: [
501
- /* @__PURE__ */ n(K, { size: 16 }),
533
+ /* @__PURE__ */ n(Q, { size: 16 }),
502
534
  " ",
503
- z
535
+ S
504
536
  ]
505
537
  }
506
538
  ),
507
- h && b && /* @__PURE__ */ H(J, { children: [
539
+ p && w && /* @__PURE__ */ W(K, { children: [
508
540
  /* @__PURE__ */ n(
509
541
  "div",
510
542
  {
@@ -520,10 +552,10 @@ function I({
520
552
  height: "100dvh",
521
553
  borderRadius: "0"
522
554
  } : {
523
- top: u,
524
- right: R,
555
+ top: a,
556
+ right: v,
525
557
  width: B,
526
- height: `min(${m}, calc(100dvh - ${u}px - 12px))`,
558
+ height: `min(${$}, calc(100dvh - ${a}px - 12px))`,
527
559
  borderRadius: "28px"
528
560
  },
529
561
  overflow: "hidden",
@@ -532,19 +564,19 @@ function I({
532
564
  zIndex: 9999,
533
565
  animation: "ocl-slide-in .18s ease"
534
566
  }, children: /* @__PURE__ */ n(
535
- A,
567
+ F,
536
568
  {
537
- url: r,
538
- ...i ? { apiUrl: i } : {},
539
- ...d ? { profileId: d } : {},
540
- ...o ? { tenantId: o } : {},
541
- ...l ? { token: l } : {},
542
- ...s ? { refreshToken: s } : {},
569
+ url: l,
570
+ ...o ? { apiUrl: o } : {},
571
+ ...s ? { profileId: s } : {},
572
+ ...e ? { tenantId: e } : {},
573
+ ...r ? { token: r } : {},
574
+ ...d ? { refreshToken: d } : {},
543
575
  ...c ? { userId: c } : {},
544
- ...p ? { userName: p } : {},
545
- ...y ? { userEmail: y } : {},
546
- ...v ? { scope: v } : {},
547
- accent: a,
576
+ ...u ? { userName: u } : {},
577
+ ...m ? { userEmail: m } : {},
578
+ ...C ? { scope: C } : {},
579
+ accent: h,
548
580
  height: "100%",
549
581
  onClose: () => t(!1)
550
582
  }
@@ -554,9 +586,9 @@ function I({
554
586
  ] });
555
587
  }
556
588
  export {
557
- A as ChatApp,
558
- I as ChatAppLauncher,
559
- T as ChatWidget,
560
- E as MarketplaceChat
589
+ F as ChatApp,
590
+ X as ChatAppLauncher,
591
+ E as ChatWidget,
592
+ I as MarketplaceChat
561
593
  };
562
594
  //# sourceMappingURL=react.js.map