@paramms/chat-widget 1.0.15 → 1.0.16

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.
@@ -80,6 +80,9 @@ export interface Conversation {
80
80
  sentimentScore?: number;
81
81
  /** Set once an SLA-breach escalation macro has fired, so it only fires once. */
82
82
  slaEscalatedAt?: number;
83
+ /** If set, the conversation is snoozed until this Unix ms timestamp.
84
+ * Hidden from the inbox until the timestamp passes, then resurfaces. */
85
+ snoozedUntil?: number;
83
86
  /** Page URL where the widget was open when the conversation started. */
84
87
  pageUrl?: string;
85
88
  /** Browser tab title at conversation start — gives agents context. */
@@ -110,3 +113,8 @@ export interface Subject {
110
113
  createdAt: number;
111
114
  updatedAt: number;
112
115
  }
116
+ /** States in which a conversation is no longer "open": it's done with, so inbox
117
+ * / proactive sweeps skip it and load balancing frees the assigned agent. The
118
+ * single source of truth for "is this conversation finished?". */
119
+ export declare const TERMINAL_STATES: ReadonlySet<string>;
120
+ export declare function isTerminalState(state: string): boolean;
@@ -155,6 +155,7 @@ export type ServerFrame = {
155
155
  conversationId: ConversationId;
156
156
  userId: UserId;
157
157
  isTyping: boolean;
158
+ preview?: string;
158
159
  } | {
159
160
  type: 'reaction';
160
161
  conversationId: ConversationId;
package/dist/react.js CHANGED
@@ -1,63 +1,63 @@
1
- import { jsxs as C, jsx as s, Fragment as D } from "react/jsx-runtime";
1
+ import { jsxs as C, jsx as h, Fragment as D } from "react/jsx-runtime";
2
2
  import { useState as M, useRef as v, useEffect as S } from "react";
3
3
  import { mount as L } from "./index.js";
4
4
  function Y({
5
- url: x,
6
- profileId: b,
5
+ url: a,
6
+ profileId: x,
7
7
  userId: e,
8
- userName: i,
9
- userEmail: r,
8
+ userName: r,
9
+ userEmail: l,
10
10
  userAvatar: o,
11
- contextTitle: g,
12
- contextSubtitle: y,
11
+ contextTitle: w,
12
+ contextSubtitle: b,
13
13
  contextStatus: t,
14
- subjectId: f,
15
- accent: h,
14
+ subjectId: p,
15
+ accent: d,
16
16
  launcher: n,
17
- position: l,
18
- quickReplies: c,
19
- height: d = "100%",
20
- i18n: p,
21
- translateLang: u
17
+ position: c,
18
+ quickReplies: s,
19
+ height: f = "100%",
20
+ i18n: y,
21
+ translateLang: i
22
22
  }) {
23
- const w = v(null), a = v(null);
23
+ const g = v(null), u = v(null);
24
24
  return S(() => {
25
25
  var m;
26
- if (w.current)
27
- return (m = a.current) == null || m.close(), a.current = L({
28
- el: w.current,
29
- url: x,
30
- profileId: b,
31
- ...f ? { subjectId: f } : {},
26
+ if (g.current)
27
+ return (m = u.current) == null || m.close(), u.current = L({
28
+ el: g.current,
29
+ url: a,
30
+ profileId: x,
31
+ ...p ? { subjectId: p } : {},
32
32
  ...e ? { token: e } : {},
33
- ...e || i || r || o ? {
33
+ ...e || r || l || o ? {
34
34
  user: {
35
- ...i ? { name: i } : {},
36
- ...r ? { email: r } : {},
35
+ ...r ? { name: r } : {},
36
+ ...l ? { email: l } : {},
37
37
  ...o ? { avatar: o } : {}
38
38
  }
39
39
  } : {},
40
- ...g ? {
40
+ ...w ? {
41
41
  subject: {
42
- title: g,
43
- ...y ? { subtitle: y } : {},
42
+ title: w,
43
+ ...b ? { subtitle: b } : {},
44
44
  ...t ? { status: t } : {}
45
45
  }
46
46
  } : {},
47
- ...c ? { quickReplies: c } : {},
48
- ...h ? { accent: h } : {},
49
- ...u ? { translateLang: u } : {},
50
- ...p ? { i18n: p } : {},
51
- ...n ? { launcher: n, position: l ?? "bottom-right" } : {}
47
+ ...s ? { quickReplies: s } : {},
48
+ ...d ? { accent: d } : {},
49
+ ...i ? { translateLang: i } : {},
50
+ ...y ? { i18n: y } : {},
51
+ ...n ? { launcher: n, position: c ?? "bottom-right" } : {}
52
52
  }), () => {
53
53
  var R;
54
- (R = a.current) == null || R.close(), a.current = null;
54
+ (R = u.current) == null || R.close(), u.current = null;
55
55
  };
56
- }, [x, b, f, e, i, r, h, n, l, u]), /* @__PURE__ */ s(
56
+ }, [a, x, p, e, r, l, d, n, c, i]), /* @__PURE__ */ h(
57
57
  "div",
58
58
  {
59
- ref: w,
60
- style: n ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: d, minHeight: d === "100%" ? "480px" : void 0 }
59
+ ref: g,
60
+ style: n ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: f, minHeight: f === "100%" ? "480px" : void 0 }
61
61
  }
62
62
  );
63
63
  }
@@ -67,108 +67,109 @@ const B = [
67
67
  "What is your best price?"
68
68
  ];
69
69
  function A({
70
- url: x,
71
- profileId: b,
70
+ url: a,
71
+ profileId: x,
72
72
  listingId: e,
73
- listingTitle: i,
74
- listingMeta: r,
73
+ listingTitle: r,
74
+ listingMeta: l,
75
75
  listingPrice: o,
76
- listingStatus: g,
77
- userId: y,
76
+ listingStatus: w,
77
+ userId: b,
78
78
  userName: t,
79
- userEmail: f,
80
- userAvatar: h,
79
+ userEmail: p,
80
+ userAvatar: d,
81
81
  accent: n,
82
- launcher: l,
83
- position: c,
84
- quickReplies: d,
85
- height: p = "100%",
86
- i18n: u,
87
- translateLang: w
82
+ launcher: c,
83
+ position: s,
84
+ quickReplies: f,
85
+ height: y = "100%",
86
+ i18n: i,
87
+ translateLang: g
88
88
  }) {
89
- const a = v(null), m = v(null);
89
+ const u = v(null), m = v(null);
90
90
  return S(() => {
91
91
  var R;
92
- if (a.current)
92
+ if (u.current)
93
93
  return (R = m.current) == null || R.close(), m.current = L({
94
- el: a.current,
95
- url: x,
96
- profileId: b,
94
+ el: u.current,
95
+ url: a,
96
+ profileId: x,
97
97
  ...e ? { subjectId: `listing_${e}` } : {},
98
- ...y ? { token: y } : {},
99
- ...y || t || f || h ? {
98
+ ...b ? { token: b } : {},
99
+ ...b || t || p || d ? {
100
100
  user: {
101
101
  ...t ? { name: t } : {},
102
- ...f ? { email: f } : {},
103
- ...h ? { avatar: h } : {},
102
+ ...p ? { email: p } : {},
103
+ ...d ? { avatar: d } : {},
104
104
  ...e ? { meta: { listingId: e } } : {}
105
105
  }
106
106
  } : {},
107
- ...i ? {
107
+ ...r ? {
108
108
  subject: {
109
- title: i,
110
- ...r ? { subtitle: r } : {},
109
+ title: r,
110
+ ...l ? { subtitle: l } : {},
111
111
  ...o ? { tags: [`$${o.toLocaleString()}`] } : {},
112
- ...g ? { status: g } : {}
112
+ ...w ? { status: w } : {}
113
113
  }
114
114
  } : {},
115
- quickReplies: d ?? B,
115
+ quickReplies: f ?? B,
116
116
  ...n ? { accent: n } : {},
117
- ...w ? { translateLang: w } : {},
118
- ...u ? { i18n: u } : {},
119
- ...l ? { launcher: l, position: c ?? "bottom-right" } : {}
117
+ ...g ? { translateLang: g } : {},
118
+ ...i ? { i18n: i } : {},
119
+ ...c ? { launcher: c, position: s ?? "bottom-right" } : {}
120
120
  }), () => {
121
121
  var W;
122
122
  (W = m.current) == null || W.close(), m.current = null;
123
123
  };
124
- }, [x, b, e, y, t, f, n, l, c, w]), /* @__PURE__ */ s(
124
+ }, [a, x, e, b, t, p, n, c, s, g]), /* @__PURE__ */ h(
125
125
  "div",
126
126
  {
127
- ref: a,
128
- style: l ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: p, minHeight: p === "100%" ? "480px" : void 0 }
127
+ ref: u,
128
+ style: c ? { width: 0, height: 0, overflow: "hidden" } : { width: "100%", height: y, minHeight: y === "100%" ? "480px" : void 0 }
129
129
  }
130
130
  );
131
131
  }
132
132
  function $({
133
- url: x,
134
- profileId: b,
133
+ url: a,
134
+ profileId: x,
135
135
  userId: e,
136
- userName: i,
137
- userEmail: r,
136
+ userName: r,
137
+ userEmail: l,
138
138
  accent: o,
139
- height: g = "100%",
140
- i18n: y
139
+ height: w = "100%",
140
+ i18n: b
141
141
  }) {
142
- const [t, f] = M(null), h = v(null), n = v(null), l = v(null), c = v(null);
142
+ const [t, p] = M(null), d = v(null), n = v(null), c = v(null), s = v(null);
143
143
  S(() => {
144
- if (h.current)
145
- return import("./chatlist.js").then(({ mountChatList: p }) => {
146
- l.current = p({
147
- el: h.current,
148
- url: x,
149
- profileId: b,
150
- onSelect: (u) => f(u),
151
- ...e ? { userId: e } : {},
152
- ...o ? { accent: o } : {},
153
- ...y ? { i18n: y } : {}
154
- });
155
- }), () => {
156
- var p;
157
- (p = l.current) == null || p.close(), l.current = null;
158
- };
159
- }, [x, b, e]), S(() => {
160
- var p;
144
+ if (!d.current) return;
145
+ let y = !1;
146
+ return import("./chatlist.js").then(({ mountChatList: i }) => {
147
+ y || !d.current || (c.current = i({
148
+ el: d.current,
149
+ url: a,
150
+ profileId: x,
151
+ onSelect: (g) => p(g),
152
+ ...e ? { userId: e } : {},
153
+ ...o ? { accent: o } : {},
154
+ ...b ? { i18n: b } : {}
155
+ }));
156
+ }), () => {
157
+ var i;
158
+ y = !0, (i = c.current) == null || i.close(), c.current = null;
159
+ };
160
+ }, [a, x, e]), S(() => {
161
+ var y;
161
162
  if (!(!n.current || !t))
162
- return (p = c.current) == null || p.close(), c.current = L({
163
+ return (y = s.current) == null || y.close(), s.current = L({
163
164
  el: n.current,
164
- url: x,
165
- profileId: b,
165
+ url: a,
166
+ profileId: x,
166
167
  ...t.subjectId ? { subjectId: t.subjectId } : {},
167
168
  ...e ? { token: e } : {},
168
- ...e || i || r ? {
169
+ ...e || r || l ? {
169
170
  user: {
170
- ...i ? { name: i } : {},
171
- ...r ? { email: r } : {}
171
+ ...r ? { name: r } : {},
172
+ ...l ? { email: l } : {}
172
173
  }
173
174
  } : {},
174
175
  ...t.subjectTitle ? {
@@ -179,65 +180,65 @@ function $({
179
180
  } : {},
180
181
  ...o ? { accent: o } : {}
181
182
  }), () => {
182
- var u;
183
- (u = c.current) == null || u.close(), c.current = null;
183
+ var i;
184
+ (i = s.current) == null || i.close(), s.current = null;
184
185
  };
185
186
  }, [t == null ? void 0 : t.id]);
186
- const d = typeof window < "u" && window.innerWidth < 768;
187
- return /* @__PURE__ */ C("div", { style: { display: "flex", width: "100%", height: g, minHeight: "400px", overflow: "hidden" }, children: [
188
- /* @__PURE__ */ s("div", { style: {
189
- width: d ? "100%" : "360px",
190
- flex: d && t ? "none" : void 0,
191
- display: d && t ? "none" : "flex",
187
+ const f = typeof window < "u" && window.innerWidth < 768;
188
+ return /* @__PURE__ */ C("div", { style: { display: "flex", width: "100%", height: w, minHeight: "400px", overflow: "hidden" }, children: [
189
+ /* @__PURE__ */ h("div", { style: {
190
+ width: f ? "100%" : "360px",
191
+ flex: f && t ? "none" : void 0,
192
+ display: f && t ? "none" : "flex",
192
193
  flexDirection: "column",
193
- borderRight: d ? "none" : "1px solid #e8eaed",
194
+ borderRight: f ? "none" : "1px solid #e8eaed",
194
195
  minWidth: 0
195
- }, children: /* @__PURE__ */ s("div", { ref: h, style: { width: "100%", height: "100%" } }) }),
196
+ }, children: /* @__PURE__ */ h("div", { ref: d, style: { width: "100%", height: "100%" } }) }),
196
197
  t ? /* @__PURE__ */ C("div", { style: { flex: 1, display: "flex", flexDirection: "column", minWidth: 0, position: "relative" }, children: [
197
- d && /* @__PURE__ */ s(
198
+ f && /* @__PURE__ */ h(
198
199
  "button",
199
200
  {
200
- onClick: () => f(null),
201
+ onClick: () => p(null),
201
202
  style: { position: "absolute", top: 12, left: 12, zIndex: 10, background: "none", border: "none", fontSize: 22, cursor: "pointer", color: "#1c1b1a" },
202
203
  children: "←"
203
204
  }
204
205
  ),
205
- /* @__PURE__ */ s("div", { ref: n, style: { width: "100%", height: "100%" } })
206
- ] }) : /* @__PURE__ */ s("div", { style: { flex: 1, display: d ? "none" : "flex", alignItems: "center", justifyContent: "center", color: "#9b9690", fontSize: 14 }, children: "Select a conversation" })
206
+ /* @__PURE__ */ h("div", { ref: n, style: { width: "100%", height: "100%" } })
207
+ ] }) : /* @__PURE__ */ h("div", { style: { flex: 1, display: f ? "none" : "flex", alignItems: "center", justifyContent: "center", color: "#9b9690", fontSize: 14 }, children: "Select a conversation" })
207
208
  ] });
208
209
  }
209
210
  function K({
210
- url: x,
211
- profileId: b,
211
+ url: a,
212
+ profileId: x,
212
213
  userId: e,
213
- userName: i,
214
- userEmail: r,
214
+ userName: r,
215
+ userEmail: l,
215
216
  accent: o = "#4F63F5",
216
- floating: g = !0,
217
- position: y = "bottom-right",
217
+ floating: w = !0,
218
+ position: b = "bottom-right",
218
219
  label: t,
219
- panelWidth: f,
220
- panelHeight: h = "600px"
220
+ panelWidth: p,
221
+ panelHeight: d = "600px"
221
222
  }) {
222
- const [n, l] = M(!1), c = v(null), d = y === "bottom-right", u = t ?? (g ? "💬" : "Messages");
223
+ const [n, c] = M(!1), s = v(null), f = b === "bottom-right", i = t ?? (w ? "💬" : "Messages");
223
224
  if (S(() => {
224
225
  const k = (z) => {
225
- z.key === "Escape" && l(!1);
226
+ z.key === "Escape" && c(!1);
226
227
  };
227
228
  return document.addEventListener("keydown", k), () => document.removeEventListener("keydown", k);
228
- }, []), g) {
229
- const k = typeof window < "u" && window.innerWidth < 480, z = k ? "100vw" : f ?? "420px", H = k ? "100dvh" : h;
229
+ }, []), w) {
230
+ const k = typeof window < "u" && window.innerWidth < 480, z = k ? "100vw" : p ?? "420px", H = k ? "100dvh" : d;
230
231
  return /* @__PURE__ */ C("div", { style: {
231
232
  position: "fixed",
232
- [d ? "right" : "left"]: "20px",
233
+ [f ? "right" : "left"]: "20px",
233
234
  bottom: "20px",
234
235
  zIndex: 9999,
235
236
  display: "flex",
236
237
  flexDirection: "column",
237
- alignItems: d ? "flex-end" : "flex-start",
238
+ alignItems: f ? "flex-end" : "flex-start",
238
239
  gap: "12px"
239
240
  }, children: [
240
- /* @__PURE__ */ s("div", { style: {
241
+ /* @__PURE__ */ h("div", { style: {
241
242
  width: z,
242
243
  height: H,
243
244
  borderRadius: k ? "0" : "16px",
@@ -246,25 +247,25 @@ function K({
246
247
  background: "#fff",
247
248
  display: n ? "flex" : "none",
248
249
  flexDirection: "column",
249
- transformOrigin: `bottom ${d ? "right" : "left"}`,
250
+ transformOrigin: `bottom ${f ? "right" : "left"}`,
250
251
  animation: n ? "ocl-pop-in .18s ease" : "none"
251
- }, children: /* @__PURE__ */ s(
252
+ }, children: /* @__PURE__ */ h(
252
253
  $,
253
254
  {
254
- url: x,
255
- profileId: b,
255
+ url: a,
256
+ profileId: x,
256
257
  ...e ? { userId: e } : {},
257
- ...i ? { userName: i } : {},
258
- ...r ? { userEmail: r } : {},
258
+ ...r ? { userName: r } : {},
259
+ ...l ? { userEmail: l } : {},
259
260
  accent: o,
260
261
  height: "100%"
261
262
  }
262
263
  ) }),
263
- /* @__PURE__ */ s(
264
+ /* @__PURE__ */ h(
264
265
  "button",
265
266
  {
266
- ref: c,
267
- onClick: () => l((j) => !j),
267
+ ref: s,
268
+ onClick: () => c((j) => !j),
268
269
  style: {
269
270
  width: "56px",
270
271
  height: "56px",
@@ -284,20 +285,20 @@ function K({
284
285
  onMouseLeave: (j) => {
285
286
  j.target.style.transform = "scale(1)";
286
287
  },
287
- children: n ? "✕" : u
288
+ children: n ? "✕" : i
288
289
  }
289
290
  ),
290
- /* @__PURE__ */ s("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
291
+ /* @__PURE__ */ h("style", { children: "@keyframes ocl-pop-in { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }" })
291
292
  ] });
292
293
  }
293
- const w = f ?? "420px", [a, m] = M(null), R = () => {
294
- !n && c.current && m(c.current.getBoundingClientRect()), l((k) => !k);
295
- }, W = a ? a.bottom + 8 : 0, F = a ? window.innerWidth - a.right : 0;
294
+ const g = p ?? "420px", [u, m] = M(null), R = () => {
295
+ !n && s.current && m(s.current.getBoundingClientRect()), c((k) => !k);
296
+ }, W = u ? u.bottom + 8 : 0, F = u ? window.innerWidth - u.right : 0;
296
297
  return /* @__PURE__ */ C(D, { children: [
297
298
  /* @__PURE__ */ C(
298
299
  "button",
299
300
  {
300
- ref: c,
301
+ ref: s,
301
302
  onClick: R,
302
303
  style: {
303
304
  display: "inline-flex",
@@ -315,43 +316,43 @@ function K({
315
316
  },
316
317
  children: [
317
318
  "💬 ",
318
- u
319
+ i
319
320
  ]
320
321
  }
321
322
  ),
322
- n && a && /* @__PURE__ */ C(D, { children: [
323
- /* @__PURE__ */ s(
323
+ n && u && /* @__PURE__ */ C(D, { children: [
324
+ /* @__PURE__ */ h(
324
325
  "div",
325
326
  {
326
- onClick: () => l(!1),
327
+ onClick: () => c(!1),
327
328
  style: { position: "fixed", inset: 0, zIndex: 9998 }
328
329
  }
329
330
  ),
330
- /* @__PURE__ */ s("div", { style: {
331
+ /* @__PURE__ */ h("div", { style: {
331
332
  position: "fixed",
332
333
  top: W,
333
334
  right: F,
334
- width: w,
335
- height: h,
335
+ width: g,
336
+ height: d,
336
337
  borderRadius: "16px",
337
338
  overflow: "hidden",
338
339
  boxShadow: "0 8px 40px rgba(0,0,0,.2)",
339
340
  background: "#fff",
340
341
  zIndex: 9999,
341
342
  animation: "ocl-slide-in .18s ease"
342
- }, children: /* @__PURE__ */ s(
343
+ }, children: /* @__PURE__ */ h(
343
344
  $,
344
345
  {
345
- url: x,
346
- profileId: b,
346
+ url: a,
347
+ profileId: x,
347
348
  ...e ? { userId: e } : {},
348
- ...i ? { userName: i } : {},
349
- ...r ? { userEmail: r } : {},
349
+ ...r ? { userName: r } : {},
350
+ ...l ? { userEmail: l } : {},
350
351
  accent: o,
351
352
  height: "100%"
352
353
  }
353
354
  ) }),
354
- /* @__PURE__ */ s("style", { children: "@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }" })
355
+ /* @__PURE__ */ h("style", { children: "@keyframes ocl-slide-in { from { opacity:0; transform:translateY(-8px) } to { opacity:1; transform:translateY(0) } }" })
355
356
  ] })
356
357
  ] });
357
358
  }