@wexio/messenger-widget-react 1.2.4 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +61 -1
  2. package/README.md +15 -1
  3. package/dist/{widget-react-DubCiNev.js → widget-react--IUy5lNt.js} +21 -20
  4. package/dist/{widget-react-CIy9jXND.js → widget-react-B7es3n1-.js} +1 -1
  5. package/dist/{widget-react-2tTH7-bO.js → widget-react-BAUpSGhZ.js} +1 -1
  6. package/dist/widget-react-BS9kUSRS.js +255 -0
  7. package/dist/{widget-react-CtvdaJvy.js → widget-react-BXf2Ty8d.js} +4 -4
  8. package/dist/{widget-react-DDEFbIbU.js → widget-react-BfO-uP4o.js} +89 -139
  9. package/dist/{widget-react-faSyVXFQ.js → widget-react-BgALABDe.js} +1 -1
  10. package/dist/{widget-react-DXP6EOCM.js → widget-react-BkXA6ytR.js} +1 -1
  11. package/dist/{widget-react-yTVzOzaU.js → widget-react-Bop75Z1t.js} +87 -87
  12. package/dist/widget-react-BxEjM2it.js +118 -0
  13. package/dist/{widget-react-CK8xTxwO.js → widget-react-C6lzldez.js} +4936 -4455
  14. package/dist/widget-react-CN_FIvMD.js +834 -0
  15. package/dist/{widget-react-CAsPo1rw.js → widget-react-DRER1XF_.js} +112 -112
  16. package/dist/widget-react-DSAyUf2U.js +229 -0
  17. package/dist/{widget-react-B9XrHKqv.js → widget-react-DbOJZl9F.js} +1238 -2052
  18. package/dist/{widget-react-BlTmXnei.js → widget-react-DgIxSjv7.js} +1 -1
  19. package/dist/widget-react-Ds5J9FbQ.js +27 -0
  20. package/dist/{widget-react-DV3UnggB.js → widget-react-MXOCL3Mg.js} +148 -237
  21. package/dist/{widget-react-B8rXZyxg.js → widget-react-SI7deQTE.js} +1 -1
  22. package/dist/{widget-react-AwEaD0v2.js → widget-react-bPokx9L5.js} +169 -273
  23. package/dist/widget-react-wSc9gIfG.js +198 -0
  24. package/dist/widget-react.d.ts +2 -2
  25. package/dist/widget-react.js +9387 -4696
  26. package/package.json +1 -1
  27. package/dist/widget-react-B9X7Tn7t.js +0 -125
  28. package/dist/widget-react-DNFROpaS.js +0 -262
@@ -11,23 +11,23 @@ import "react";
11
11
  import "react-dom";
12
12
  import "react/jsx-runtime";
13
13
  import "react-dom/client";
14
- import { i as e } from "./widget-react-B9XrHKqv.js";
15
- import { I as t, N as n, c as r, k as i, l as a, v as o, y as s } from "./widget-react-CK8xTxwO.js";
16
- import { i as c, n as l } from "./widget-react-krPPnv02.js";
17
- import { f as u, l as d, n as f, r as p, u as m } from "./widget-react-AwEaD0v2.js";
18
- import { t as h } from "./widget-react-B8rXZyxg.js";
19
- import { a as g, c as ee, i as te, l as ne, n as _, o as v, r as y, s as b, t as x } from "./widget-react-DDEFbIbU.js";
20
- import { useEffect as S, useMemo as C, useRef as w, useState as re } from "react";
21
- import { jsx as T, jsxs as E } from "react/jsx-runtime";
14
+ import { F as e, I as t, M as n, N as r, b as i, c as a, ct as ee, k as te, l as o, st as s, u as c, y as l, yt as u, z as d } from "./widget-react-C6lzldez.js";
15
+ import { i as f, n as p } from "./widget-react-krPPnv02.js";
16
+ import { i as ne } from "./widget-react-CN_FIvMD.js";
17
+ import { o as re, p as ie, s as m, t as h } from "./widget-react-bPokx9L5.js";
18
+ import { t as ae } from "./widget-react-SI7deQTE.js";
19
+ import { a as g, i as _, n as oe, o as v, r as y, s as b, t as x } from "./widget-react-BfO-uP4o.js";
20
+ import { useEffect as S, useMemo as C, useRef as se, useState as ce } from "react";
21
+ import { jsx as w, jsxs as T } from "react/jsx-runtime";
22
22
  //#region components/widget/help-article-view/helpers.ts
23
- function D(e) {
23
+ function le(e) {
24
24
  let t = (e) => Array.isArray(e) ? e : [];
25
25
  return {
26
26
  id: String(e._id ?? ""),
27
27
  title: typeof e.title == "string" ? e.title : "",
28
28
  excerpt: typeof e.excerpt == "string" ? e.excerpt : "",
29
29
  content: typeof e.content == "string" ? e.content : "",
30
- contentFormat: e.contentFormat === b.HTML ? b.HTML : b.MARKDOWN,
30
+ contentFormat: e.contentFormat === g.HTML ? g.HTML : g.MARKDOWN,
31
31
  authors: t(e.authors).filter((e) => !!e && typeof e == "object").map((e) => ({
32
32
  _id: String(e._id ?? ""),
33
33
  name: typeof e.name == "string" ? e.name : null,
@@ -42,63 +42,63 @@ function D(e) {
42
42
  }
43
43
  //#endregion
44
44
  //#region components/widget/help-article-view/index.tsx
45
- function O({ slug: l, locale: O, isDummy: k, onHandoff: ae, onOpenArticle: A, onOpenTranslation: j, onTitleResolved: M }) {
46
- let N = c("help"), P = c("demo"), F = n(), { config: I } = i(), L = I.messenger?.showRelatedHelpArticles ?? !0, R = I.messenger?.showReactionCounts ?? !0, z = h(), [B, V] = re(O), H = g(B, P), U = C(() => {
47
- if (k) return null;
45
+ function E({ slug: p, locale: E, isDummy: O, onHandoff: k, onOpenArticle: A, onOpenTranslation: j, onTitleResolved: M }) {
46
+ let N = f("help"), P = e(), F = n(), { config: I } = te(), L = I.messenger?.showRelatedHelpArticles ?? !0, R = I.messenger?.showReactionCounts ?? !0, z = ae(), [B, ue] = ce(E), V = t(B, P), H = C(() => {
47
+ if (O) return null;
48
48
  let e = F.previewData?.helpArticles;
49
- return Array.isArray(e) ? e.find((e) => e && typeof e == "object" && e.slug === l) ?? null : null;
49
+ return Array.isArray(e) ? e.find((e) => e && typeof e == "object" && e.slug === p) ?? null : null;
50
50
  }, [
51
51
  F.previewData,
52
- k,
53
- l
54
- ]), W = !!U, { data: G, loading: K } = p({
52
+ O,
53
+ p
54
+ ]), U = !!H, { data: W, loading: de } = m({
55
55
  variables: { args: {
56
- slug: l,
57
- locale: O
56
+ slug: p,
57
+ locale: E
58
58
  } },
59
- skip: k || W
60
- }), [q] = f(), { trackLinkClick: J } = r(), Y = w(null), X = C(() => k ? u(H).find((e) => e.slug === l) : null, [
61
- k,
62
- l,
63
- H
64
- ]), Z = k ? X ? {
59
+ skip: O || U
60
+ }), G = s(), K = o(G && !O && !U ? d.article(G, p, E) : null, W), [q] = re(), { trackLinkClick: J } = a(), Y = se(null), X = C(() => O ? u(V).find((e) => e.slug === p) : null, [
61
+ O,
62
+ p,
63
+ V
64
+ ]), Z = O ? X ? {
65
65
  id: X.id,
66
66
  title: X.title,
67
67
  excerpt: X.excerpt,
68
68
  content: X.contentMarkdown,
69
- contentFormat: b.MARKDOWN,
69
+ contentFormat: g.MARKDOWN,
70
70
  authors: X.authors,
71
71
  tags: X.tags,
72
72
  reactionCounts: null,
73
73
  locale: B,
74
74
  translations: []
75
- } : null : W && U ? {
76
- ...D(U),
77
- reactionCounts: U.reactionCounts ?? null,
78
- locale: O,
75
+ } : null : U && H ? {
76
+ ...le(H),
77
+ reactionCounts: H.reactionCounts ?? null,
78
+ locale: E,
79
79
  translations: []
80
- } : G?.visitorHelpArticle ? {
81
- id: G.visitorHelpArticle._id,
82
- title: G.visitorHelpArticle.title,
83
- excerpt: G.visitorHelpArticle.excerpt ?? "",
84
- content: G.visitorHelpArticle.content,
85
- contentFormat: G.visitorHelpArticle.contentFormat,
86
- authors: G.visitorHelpArticle.authors,
87
- tags: G.visitorHelpArticle.tags,
88
- reactionCounts: G.visitorHelpArticle.reactionCounts ?? null,
89
- locale: G.visitorHelpArticle.locale,
90
- translations: G.visitorHelpArticle.translations
91
- } : null, { data: oe } = d({
80
+ } : K?.visitorHelpArticle ? {
81
+ id: K.visitorHelpArticle._id,
82
+ title: K.visitorHelpArticle.title,
83
+ excerpt: K.visitorHelpArticle.excerpt ?? "",
84
+ content: K.visitorHelpArticle.content,
85
+ contentFormat: K.visitorHelpArticle.contentFormat,
86
+ authors: K.visitorHelpArticle.authors,
87
+ tags: K.visitorHelpArticle.tags,
88
+ reactionCounts: K.visitorHelpArticle.reactionCounts ?? null,
89
+ locale: K.visitorHelpArticle.locale,
90
+ translations: K.visitorHelpArticle.translations
91
+ } : null, { data: fe } = ie({
92
92
  variables: {
93
93
  articleId: Z?.id ?? "",
94
94
  limit: 5,
95
- locale: O
95
+ locale: E
96
96
  },
97
- skip: k || W || !Z?.id || !L
98
- }), se = C(() => {
99
- if (!W || !Z?.id) return [];
97
+ skip: O || U || !Z?.id || !L
98
+ }), pe = C(() => {
99
+ if (!U || !Z?.id) return [];
100
100
  let e = (F.previewData?.helpArticles ?? []).filter((e) => !!e && typeof e == "object"), t = new Set((Z.tags ?? []).map((e) => typeof e == "object" && e && "slug" in e ? String(e.slug) : null).filter((e) => !!e)), n = (() => {
101
- let e = U;
101
+ let e = H;
102
102
  if (!e) return null;
103
103
  let t = e.folderId;
104
104
  if (typeof t == "string") return t;
@@ -122,141 +122,141 @@ function O({ slug: l, locale: O, isDummy: k, onHandoff: ae, onOpenArticle: A, on
122
122
  excerpt: typeof e.excerpt == "string" ? e.excerpt : null
123
123
  }));
124
124
  }, [
125
- W,
126
- Z,
127
125
  U,
126
+ Z,
127
+ H,
128
128
  F.previewData
129
- ]), Q = W ? se : oe?.visitorHelpRelated ?? [], ce = k || W ? null : G?.visitorHelpArticle?.viewerReaction ?? null, le = !k && !W && G?.visitorHelpArticle ? [G.visitorHelpArticle._id, ...(G.visitorHelpArticle.translations ?? []).map((e) => e._id)] : Z?.id ? [Z.id] : [];
129
+ ]), Q = U ? pe : fe?.visitorHelpRelated ?? [], me = O || U ? null : W?.visitorHelpArticle?.viewerReaction ?? null, he = !O && !U && W?.visitorHelpArticle ? [W.visitorHelpArticle._id, ...(W.visitorHelpArticle.translations ?? []).map((e) => e._id)] : Z?.id ? [Z.id] : [];
130
130
  S(() => {
131
- k || !Z?.id || !t() || q({ variables: { articleId: Z.id } }).catch(() => {});
131
+ O || !Z?.id || !ee() || q({ variables: { articleId: Z.id } }).catch(() => {});
132
132
  }, [
133
133
  Z?.id,
134
- k,
134
+ O,
135
135
  q
136
136
  ]), S(() => {
137
- k || W || !Z?.id || Y.current !== Z.id && (Y.current = Z.id, J({
138
- url: `/help/${l}`,
137
+ O || U || !Z?.id || Y.current !== Z.id && (Y.current = Z.id, J({
138
+ url: `/help/${p}`,
139
139
  targetType: "HELP_ARTICLE",
140
140
  targetRefId: Z.id
141
141
  }));
142
142
  }, [
143
143
  Z?.id,
144
- k,
145
- W,
146
- l,
144
+ O,
145
+ U,
146
+ p,
147
147
  J
148
- ]), v(Z?.title, M);
149
- let ue = () => ae();
150
- if (!K && !Z) return /* @__PURE__ */ T("div", {
148
+ ]), _(Z?.title, M);
149
+ let ge = () => k();
150
+ if (!de && !Z) return /* @__PURE__ */ w("div", {
151
151
  className: "flex flex-1 flex-col items-center justify-center px-6 py-12",
152
- children: /* @__PURE__ */ T(o, { children: /* @__PURE__ */ T(s, {
152
+ children: /* @__PURE__ */ w(l, { children: /* @__PURE__ */ w(i, {
153
153
  className: "py-8 text-center",
154
- children: /* @__PURE__ */ T("p", {
154
+ children: /* @__PURE__ */ w("p", {
155
155
  className: "text-sm font-semibold text-wx-fg",
156
156
  children: N("articleNotFound")
157
157
  })
158
158
  }) })
159
159
  });
160
- let de = O.split("-")[0].toLowerCase(), $ = Z ? Z.locale.split("-")[0].toLowerCase() : null;
161
- return !k && !W && !I.contentLocaleFallback && $ !== null && $ !== de ? /* @__PURE__ */ T("div", {
160
+ let _e = E.split("-")[0].toLowerCase(), $ = Z ? Z.locale.split("-")[0].toLowerCase() : null;
161
+ return !O && !U && !I.contentLocaleFallback && $ !== null && $ !== _e ? /* @__PURE__ */ w("div", {
162
162
  className: "flex flex-1 flex-col items-center justify-center px-6 py-12",
163
- children: /* @__PURE__ */ T(o, { children: /* @__PURE__ */ T(s, {
163
+ children: /* @__PURE__ */ w(l, { children: /* @__PURE__ */ w(i, {
164
164
  className: "py-8 text-center",
165
- children: /* @__PURE__ */ T("p", {
165
+ children: /* @__PURE__ */ w("p", {
166
166
  className: "text-sm font-semibold text-wx-fg",
167
167
  children: N("articleNotTranslated")
168
168
  })
169
169
  }) })
170
- }) : Z ? /* @__PURE__ */ T(a, {
170
+ }) : Z ? /* @__PURE__ */ w(c, {
171
171
  className: "flex-1",
172
- children: /* @__PURE__ */ E("div", {
172
+ children: /* @__PURE__ */ T("div", {
173
173
  className: "flex flex-col px-5 pt-5 pb-12",
174
174
  children: [
175
- /* @__PURE__ */ T("h2", {
175
+ /* @__PURE__ */ w("h2", {
176
176
  className: "text-xl leading-tight font-bold text-wx-fg",
177
177
  children: Z.title
178
178
  }),
179
- Z.authors.length > 0 && /* @__PURE__ */ E("p", {
179
+ Z.authors.length > 0 && /* @__PURE__ */ T("p", {
180
180
  className: "mt-2 flex items-center gap-2 text-xs text-wx-fg-muted",
181
- children: [/* @__PURE__ */ T("span", {
181
+ children: [/* @__PURE__ */ w("span", {
182
182
  className: "flex -space-x-1.5",
183
- children: Z.authors.slice(0, 3).map((e) => /* @__PURE__ */ T("span", {
183
+ children: Z.authors.slice(0, 3).map((e) => /* @__PURE__ */ w("span", {
184
184
  className: "h-5 w-5 overflow-hidden rounded-full bg-wx-bg-elevated ring-1 ring-wx-bg",
185
185
  "aria-hidden": "true",
186
- children: e.photo?.url ? /* @__PURE__ */ T("img", {
186
+ children: e.photo?.url ? /* @__PURE__ */ w("img", {
187
187
  src: e.photo.url,
188
188
  alt: "",
189
189
  className: "h-full w-full object-cover"
190
- }) : /* @__PURE__ */ T("span", {
190
+ }) : /* @__PURE__ */ w("span", {
191
191
  className: "flex h-full w-full items-center justify-center text-[10px] font-semibold uppercase text-wx-fg-muted",
192
192
  children: (e.name ?? "?").charAt(0)
193
193
  })
194
194
  }, e._id))
195
- }), /* @__PURE__ */ T("span", { children: N("writtenBy", { names: Z.authors.map((e) => e.name ?? "").filter(Boolean).join(", ") }) })]
195
+ }), /* @__PURE__ */ w("span", { children: N("writtenBy", { names: Z.authors.map((e) => e.name ?? "").filter(Boolean).join(", ") }) })]
196
196
  }),
197
- Z.tags.length > 0 && /* @__PURE__ */ T("div", {
197
+ Z.tags.length > 0 && /* @__PURE__ */ w("div", {
198
198
  className: "mt-2 flex flex-wrap gap-1",
199
- children: Z.tags.map((e) => /* @__PURE__ */ T("span", {
199
+ children: Z.tags.map((e) => /* @__PURE__ */ w("span", {
200
200
  className: "rounded-full bg-wx-bg-elevated px-2 py-0.5 text-[11px] font-medium text-wx-fg-muted",
201
201
  children: e.label
202
202
  }, e._id))
203
203
  }),
204
- Z.excerpt && /* @__PURE__ */ T("p", {
204
+ Z.excerpt && /* @__PURE__ */ w("p", {
205
205
  className: "mt-2 mb-5 text-sm text-wx-fg-muted",
206
206
  children: Z.excerpt
207
207
  }),
208
- /* @__PURE__ */ T(y, {
208
+ /* @__PURE__ */ w(y, {
209
209
  content: Z.content,
210
- isHtml: Z.contentFormat === b.HTML || ne(Z.content),
210
+ isHtml: Z.contentFormat === g.HTML || b(Z.content),
211
211
  markdownMarginClass: "mt-3"
212
212
  }),
213
- /* @__PURE__ */ E(m, {
213
+ /* @__PURE__ */ T(h, {
214
214
  type: "button",
215
215
  variant: "solid",
216
216
  size: "lg",
217
217
  className: "mt-6 w-full shrink-0 min-h-12",
218
- onClick: ue,
218
+ onClick: ge,
219
219
  ...z.parentHandlers,
220
- children: [/* @__PURE__ */ T(e, {
220
+ children: [/* @__PURE__ */ w(ne, {
221
221
  ref: z.iconRef,
222
222
  size: 16
223
- }), /* @__PURE__ */ T("span", { children: N("unresolvedCta") })]
223
+ }), /* @__PURE__ */ w("span", { children: N("unresolvedCta") })]
224
224
  }),
225
- Z.id && /* @__PURE__ */ T(x, {
226
- surface: ee.HELP,
225
+ Z.id && /* @__PURE__ */ w(x, {
226
+ surface: v.HELP,
227
227
  itemId: Z.id,
228
228
  reactionCounts: Z.reactionCounts,
229
- viewerReaction: ce,
230
- groupItemIds: le,
231
- isDummy: k,
229
+ viewerReaction: me,
230
+ groupItemIds: he,
231
+ isDummy: O,
232
232
  showCounts: R,
233
233
  className: "mt-4"
234
234
  }),
235
- /* @__PURE__ */ T(_, {
236
- currentLocale: k ? B : Z.locale,
237
- locales: k ? [...te] : Z.translations.map((e) => e.locale),
238
- allowedLocales: k ? void 0 : I.supportedLocales,
239
- onSelect: k ? (e) => V(e) : (e) => {
235
+ /* @__PURE__ */ w(oe, {
236
+ currentLocale: O ? B : Z.locale,
237
+ locales: O ? [...r] : Z.translations.map((e) => e.locale),
238
+ allowedLocales: O ? void 0 : I.supportedLocales,
239
+ onSelect: O ? (e) => ue(e) : (e) => {
240
240
  let t = Z.translations.find((t) => t.locale === e);
241
241
  t && j?.(t.slug, t.locale);
242
242
  },
243
243
  className: "mt-6"
244
244
  }),
245
- L && Q.length > 0 && /* @__PURE__ */ E("section", {
245
+ L && Q.length > 0 && /* @__PURE__ */ T("section", {
246
246
  className: "mt-6",
247
- children: [/* @__PURE__ */ T("p", {
247
+ children: [/* @__PURE__ */ w("p", {
248
248
  className: "mb-2 text-xs font-semibold tracking-wide text-wx-fg-muted uppercase",
249
249
  children: N("relatedTitle")
250
- }), /* @__PURE__ */ T("ul", {
250
+ }), /* @__PURE__ */ w("ul", {
251
251
  className: "flex flex-col gap-1.5",
252
- children: Q.map((e) => /* @__PURE__ */ T("li", { children: /* @__PURE__ */ E("button", {
252
+ children: Q.map((e) => /* @__PURE__ */ w("li", { children: /* @__PURE__ */ T("button", {
253
253
  type: "button",
254
254
  onClick: () => A?.(e.slug),
255
255
  className: "flex w-full flex-col items-start gap-0.5 rounded-wx-lg bg-wx-bg-elevated px-3 py-2 text-left transition-colors hover:bg-wx-bg-elevated/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary",
256
- children: [/* @__PURE__ */ T("span", {
256
+ children: [/* @__PURE__ */ w("span", {
257
257
  className: "block truncate text-sm font-medium text-wx-fg",
258
258
  children: e.title
259
- }), e.excerpt && /* @__PURE__ */ T("span", {
259
+ }), e.excerpt && /* @__PURE__ */ w("span", {
260
260
  className: "line-clamp-1 block text-xs text-wx-fg-muted",
261
261
  children: e.excerpt
262
262
  })]
@@ -265,25 +265,25 @@ function O({ slug: l, locale: O, isDummy: k, onHandoff: ae, onOpenArticle: A, on
265
265
  })
266
266
  ]
267
267
  })
268
- }) : /* @__PURE__ */ T(ie, {});
268
+ }) : /* @__PURE__ */ w(D, {});
269
269
  }
270
- function ie() {
271
- return /* @__PURE__ */ T(a, {
270
+ function D() {
271
+ return /* @__PURE__ */ w(c, {
272
272
  className: "flex-1",
273
- children: /* @__PURE__ */ E("div", {
273
+ children: /* @__PURE__ */ T("div", {
274
274
  className: "flex flex-col px-5 pt-5 pb-12",
275
275
  "aria-busy": "true",
276
276
  "aria-live": "polite",
277
277
  children: [
278
- /* @__PURE__ */ E("div", {
278
+ /* @__PURE__ */ T("div", {
279
279
  className: "animate-pulse space-y-2.5",
280
- children: [/* @__PURE__ */ T("div", { className: "h-5 w-3/4 rounded-md bg-wx-bg-elevated" }), /* @__PURE__ */ T("div", { className: "h-5 w-1/2 rounded-md bg-wx-bg-elevated" })]
280
+ children: [/* @__PURE__ */ w("div", { className: "h-5 w-3/4 rounded-md bg-wx-bg-elevated" }), /* @__PURE__ */ w("div", { className: "h-5 w-1/2 rounded-md bg-wx-bg-elevated" })]
281
281
  }),
282
- /* @__PURE__ */ E("div", {
282
+ /* @__PURE__ */ T("div", {
283
283
  className: "mt-4 flex items-center gap-2 animate-pulse",
284
- children: [/* @__PURE__ */ T("div", { className: "h-5 w-5 rounded-full bg-wx-bg-elevated" }), /* @__PURE__ */ T("div", { className: "h-3 w-32 rounded-md bg-wx-bg-elevated" })]
284
+ children: [/* @__PURE__ */ w("div", { className: "h-5 w-5 rounded-full bg-wx-bg-elevated" }), /* @__PURE__ */ w("div", { className: "h-3 w-32 rounded-md bg-wx-bg-elevated" })]
285
285
  }),
286
- /* @__PURE__ */ T("div", {
286
+ /* @__PURE__ */ w("div", {
287
287
  className: "mt-6 space-y-2.5 animate-pulse",
288
288
  children: [
289
289
  "w-full",
@@ -294,13 +294,13 @@ function ie() {
294
294
  "w-full",
295
295
  "w-11/12",
296
296
  "w-7/12"
297
- ].map((e, t) => /* @__PURE__ */ T("div", { className: l("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
297
+ ].map((e, t) => /* @__PURE__ */ w("div", { className: p("h-3 rounded-md bg-wx-bg-elevated", e) }, t))
298
298
  })
299
299
  ]
300
300
  })
301
301
  });
302
302
  }
303
303
  //#endregion
304
- export { O as HelpArticleView };
304
+ export { E as HelpArticleView };
305
305
 
306
- //# sourceMappingURL=widget-react-CAsPo1rw.js.map
306
+ //# sourceMappingURL=widget-react-DRER1XF_.js.map
@@ -0,0 +1,229 @@
1
+ globalThis.process === void 0 && (globalThis.process = {
2
+ env: {},
3
+ nextTick: function(e) {
4
+ setTimeout(e, 0);
5
+ },
6
+ emit: function() {
7
+ return !1;
8
+ }
9
+ });
10
+ import "react";
11
+ import "react-dom";
12
+ import "react/jsx-runtime";
13
+ import "react-dom/client";
14
+ import { t as e } from "./widget-react-DbOJZl9F.js";
15
+ import { i as t, n } from "./widget-react-krPPnv02.js";
16
+ import { n as r, t as i } from "./widget-react-wSc9gIfG.js";
17
+ import { t as a } from "./widget-react-Ds5J9FbQ.js";
18
+ import { useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
19
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
20
+ //#region components/widget/tabs/messages-tab/composer/giphy-picker.tsx
21
+ var f = 300;
22
+ function p({ open: p, onClose: m, fetchPage: h, onPick: g, anchorRef: _ }) {
23
+ let v = t("messages.giphy"), y = c(null), b = c(null), x = c(null), [S, C] = l("GIF"), [w, T] = l(""), [E, D] = l(""), [O, k] = l([]), [A, j] = l("loading"), M = c(0), N = c(!1), P = c(0);
24
+ s(() => {
25
+ let e = setTimeout(() => D(w.trim()), f);
26
+ return () => clearTimeout(e);
27
+ }, [w]);
28
+ let F = o(async (e) => {
29
+ let t = e ? ++P.current : P.current, n = e ? 0 : M.current;
30
+ j(e ? "loading" : "loadingMore");
31
+ try {
32
+ let r = await h({
33
+ type: S,
34
+ query: E,
35
+ offset: n
36
+ });
37
+ if (t !== P.current) return;
38
+ M.current = r.nextOffset ?? n + r.items.length, N.current = r.hasNext, k((t) => {
39
+ let n = e ? r.items : [...t, ...r.items], i = /* @__PURE__ */ new Set();
40
+ return n.filter((e) => i.has(e.id) ? !1 : (i.add(e.id), !0));
41
+ }), j("ready");
42
+ } catch {
43
+ if (t !== P.current) return;
44
+ j("error");
45
+ }
46
+ }, [
47
+ h,
48
+ S,
49
+ E
50
+ ]);
51
+ s(() => {
52
+ p && (b.current?.scrollTo({ top: 0 }), F(!0));
53
+ }, [p, F]), s(() => {
54
+ if (!p) return;
55
+ let e = x.current, t = b.current;
56
+ if (!e || !t) return;
57
+ let n = new IntersectionObserver((e) => {
58
+ e[0]?.isIntersecting && N.current && A === "ready" && F(!1);
59
+ }, {
60
+ root: t,
61
+ rootMargin: "200px"
62
+ });
63
+ return n.observe(e), () => n.disconnect();
64
+ }, [
65
+ p,
66
+ A,
67
+ F
68
+ ]), s(() => {
69
+ if (!p) return;
70
+ let e = (e) => {
71
+ let t = e.composedPath();
72
+ y.current && t.includes(y.current) || _?.current && t.includes(_.current) || m();
73
+ }, t = (e) => {
74
+ e.key === "Escape" && m();
75
+ };
76
+ return document.addEventListener("mousedown", e), document.addEventListener("keydown", t), () => {
77
+ document.removeEventListener("mousedown", e), document.removeEventListener("keydown", t);
78
+ };
79
+ }, [
80
+ p,
81
+ m,
82
+ _
83
+ ]);
84
+ let I = (e) => {
85
+ e !== S && (k([]), C(e));
86
+ };
87
+ return /* @__PURE__ */ u(r, { children: p && /* @__PURE__ */ d(e.div, {
88
+ ref: y,
89
+ initial: {
90
+ opacity: 0,
91
+ y: 6,
92
+ scale: .96
93
+ },
94
+ animate: {
95
+ opacity: 1,
96
+ y: 0,
97
+ scale: 1
98
+ },
99
+ exit: {
100
+ opacity: 0,
101
+ y: 6,
102
+ scale: .96
103
+ },
104
+ transition: {
105
+ duration: .14,
106
+ ease: "easeOut"
107
+ },
108
+ className: n("absolute bottom-full left-3 z-20 mb-2 flex origin-bottom-left flex-col", "h-105 w-95 max-w-[calc(100vw-24px)] overflow-hidden", "rounded-wx-lg border border-wx-border bg-wx-bg shadow-lg"),
109
+ role: "dialog",
110
+ "aria-label": v("title"),
111
+ children: [
112
+ /* @__PURE__ */ d("div", {
113
+ className: "flex items-center gap-2 border-wx-border border-b px-3 py-2",
114
+ children: [
115
+ /* @__PURE__ */ u(a, {
116
+ "aria-hidden": "true",
117
+ className: "size-4 shrink-0 text-wx-fg-subtle"
118
+ }),
119
+ /* @__PURE__ */ u("input", {
120
+ type: "text",
121
+ value: w,
122
+ onChange: (e) => T(e.target.value),
123
+ placeholder: v("searchPlaceholder"),
124
+ "aria-label": v("searchPlaceholder"),
125
+ autoFocus: !0,
126
+ className: "min-w-0 flex-1 bg-transparent text-sm text-wx-fg placeholder:text-wx-fg-subtle focus:outline-none"
127
+ }),
128
+ w && /* @__PURE__ */ u("button", {
129
+ type: "button",
130
+ onClick: () => T(""),
131
+ "aria-label": v("clear"),
132
+ className: "shrink-0 rounded-full p-0.5 text-wx-fg-subtle transition-colors hover:bg-wx-bg-elevated-2 hover:text-wx-fg",
133
+ children: /* @__PURE__ */ u(i, {
134
+ "aria-hidden": "true",
135
+ className: "size-3.5"
136
+ })
137
+ })
138
+ ]
139
+ }),
140
+ /* @__PURE__ */ u("div", {
141
+ className: "px-3 py-2",
142
+ children: /* @__PURE__ */ u("div", {
143
+ className: "flex rounded-full bg-wx-bg-elevated-2 p-0.5",
144
+ children: ["GIF", "STICKER"].map((t) => {
145
+ let r = S === t;
146
+ return /* @__PURE__ */ d("button", {
147
+ type: "button",
148
+ onClick: () => I(t),
149
+ "aria-pressed": r,
150
+ className: "relative flex-1 rounded-full px-3.5 py-1 text-center font-medium text-[13px] transition-colors",
151
+ children: [r && /* @__PURE__ */ u(e.span, {
152
+ layoutId: "giphyTabPill",
153
+ transition: {
154
+ type: "spring",
155
+ stiffness: 400,
156
+ damping: 32
157
+ },
158
+ className: "absolute inset-0 rounded-full bg-wx-bg shadow-sm"
159
+ }), /* @__PURE__ */ u("span", {
160
+ className: n("relative z-10", r ? "text-wx-fg" : "text-wx-fg-muted"),
161
+ children: v(t === "GIF" ? "tabGifs" : "tabStickers")
162
+ })]
163
+ }, t);
164
+ })
165
+ })
166
+ }),
167
+ /* @__PURE__ */ u("div", {
168
+ ref: b,
169
+ className: "relative flex-1 overflow-y-auto px-3",
170
+ children: A === "loading" ? /* @__PURE__ */ u("div", {
171
+ className: "flex h-full items-center justify-center",
172
+ children: /* @__PURE__ */ u("div", { className: "size-5 animate-spin rounded-full border-2 border-wx-border border-t-wx-primary" })
173
+ }) : A === "error" ? /* @__PURE__ */ d("div", {
174
+ className: "flex h-full flex-col items-center justify-center gap-2 text-center",
175
+ children: [/* @__PURE__ */ u("p", {
176
+ className: "text-sm text-wx-fg-muted",
177
+ children: v("error")
178
+ }), /* @__PURE__ */ u("button", {
179
+ type: "button",
180
+ onClick: () => F(!0),
181
+ className: "font-medium text-[13px] text-wx-primary hover:underline",
182
+ children: v("retry")
183
+ })]
184
+ }) : O.length === 0 ? /* @__PURE__ */ u("div", {
185
+ className: "flex h-full items-center justify-center",
186
+ children: /* @__PURE__ */ u("p", {
187
+ className: "text-sm text-wx-fg-muted",
188
+ children: v("empty")
189
+ })
190
+ }) : /* @__PURE__ */ d("div", {
191
+ className: n("columns-2 gap-2 py-1", S === "STICKER" && "[&_img]:bg-wx-bg-elevated-2"),
192
+ children: [
193
+ O.map((e) => /* @__PURE__ */ u("button", {
194
+ type: "button",
195
+ onClick: () => {
196
+ g(e, S), m();
197
+ },
198
+ className: "mb-2 block w-full overflow-hidden rounded-wx-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-wx-primary",
199
+ children: /* @__PURE__ */ u("img", {
200
+ src: e.previewUrl,
201
+ alt: e.title,
202
+ width: e.previewWidth,
203
+ height: e.previewHeight,
204
+ loading: "lazy",
205
+ className: "block h-auto w-full"
206
+ })
207
+ }, e.id)),
208
+ /* @__PURE__ */ u("div", {
209
+ ref: x,
210
+ className: "h-1 w-full"
211
+ }),
212
+ A === "loadingMore" && /* @__PURE__ */ u("div", {
213
+ className: "flex justify-center py-2",
214
+ children: /* @__PURE__ */ u("div", { className: "size-4 animate-spin rounded-full border-2 border-wx-border border-t-wx-primary" })
215
+ })
216
+ ]
217
+ })
218
+ }),
219
+ /* @__PURE__ */ u("div", {
220
+ className: "border-wx-border border-t px-3 py-1.5 text-center text-[10px] text-wx-fg-subtle",
221
+ children: v("poweredBy")
222
+ })
223
+ ]
224
+ }) });
225
+ }
226
+ //#endregion
227
+ export { p as GiphyPicker };
228
+
229
+ //# sourceMappingURL=widget-react-DSAyUf2U.js.map