@linktr.ee/messaging-react 4.4.0-rc-1787552892 → 4.4.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.
Files changed (45) hide show
  1. package/dist/AttachmentCard-BqwWgqvi.js +369 -0
  2. package/dist/AttachmentCard-BqwWgqvi.js.map +1 -0
  3. package/dist/AttachmentCard-DUrgGRsq.cjs +2 -0
  4. package/dist/AttachmentCard-DUrgGRsq.cjs.map +1 -0
  5. package/dist/Card-BIbqWagz.cjs +2 -0
  6. package/dist/Card-BIbqWagz.cjs.map +1 -0
  7. package/dist/Card-C7uLQbYz.js +105 -0
  8. package/dist/Card-C7uLQbYz.js.map +1 -0
  9. package/dist/Card-Ds1FMcUj.cjs +2 -0
  10. package/dist/Card-Ds1FMcUj.cjs.map +1 -0
  11. package/dist/Card-f51K6V7Y.js +498 -0
  12. package/dist/Card-f51K6V7Y.js.map +1 -0
  13. package/dist/LoadingDots-BSk_UeS0.cjs +2 -0
  14. package/dist/LoadingDots-BSk_UeS0.cjs.map +1 -0
  15. package/dist/LoadingDots-B_WiXBeQ.js +73 -0
  16. package/dist/LoadingDots-B_WiXBeQ.js.map +1 -0
  17. package/dist/assets/index.css +2 -1
  18. package/dist/index.cjs +3 -2
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.js +3925 -38
  21. package/dist/index.js.map +1 -1
  22. package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
  23. package/dist/testing.cjs +2 -2
  24. package/dist/testing.cjs.map +1 -1
  25. package/dist/testing.js +106 -118
  26. package/dist/testing.js.map +1 -1
  27. package/package.json +5 -5
  28. package/src/components/MessageAttachment/_shared/MediaStackGrid.test.tsx +28 -0
  29. package/src/components/MessageAttachment/_shared/MediaStackGrid.tsx +22 -14
  30. package/dist/Card-Be81K6su.cjs +0 -2
  31. package/dist/Card-Be81K6su.cjs.map +0 -1
  32. package/dist/Card-BzvDr-pU.js +0 -112
  33. package/dist/Card-BzvDr-pU.js.map +0 -1
  34. package/dist/Card-ChcosZir.js +0 -1034
  35. package/dist/Card-ChcosZir.js.map +0 -1
  36. package/dist/Card-KU88ECCR.cjs +0 -2
  37. package/dist/Card-KU88ECCR.cjs.map +0 -1
  38. package/dist/PurchaseStatusBadge-BmqAQEV9.cjs +0 -2
  39. package/dist/PurchaseStatusBadge-BmqAQEV9.cjs.map +0 -1
  40. package/dist/PurchaseStatusBadge-D1RRsubZ.js +0 -59
  41. package/dist/PurchaseStatusBadge-D1RRsubZ.js.map +0 -1
  42. package/dist/index-Dg235rZT.js +0 -5364
  43. package/dist/index-Dg235rZT.js.map +0 -1
  44. package/dist/index-WEbnLVHC.cjs +0 -3
  45. package/dist/index-WEbnLVHC.cjs.map +0 -1
@@ -1,1034 +0,0 @@
1
- import { jsxs as g, jsx as e } from "react/jsx-runtime";
2
- import { CircleNotchIcon as be, PlayIcon as H, PauseIcon as ge, LockOpenIcon as ve, LockSimpleIcon as re, CaretLeftIcon as we, CaretRightIcon as pe, ImagesIcon as xe, DownloadSimpleIcon as ie, XIcon as ye, PencilSimpleIcon as Ne } from "@phosphor-icons/react";
3
- import T, { useRef as I, useState as y, useCallback as L, useEffect as C } from "react";
4
- import z from "classnames";
5
- import { g as S, r as E, n as ke, o as X } from "./index-Dg235rZT.js";
6
- import { L as Pe, P as se } from "./PurchaseStatusBadge-D1RRsubZ.js";
7
- const ze = (t) => {
8
- var a, n;
9
- return "touches" in t ? ((a = t.touches[0]) == null ? void 0 : a.clientX) ?? ((n = t.changedTouches[0]) == null ? void 0 : n.clientX) ?? 0 : t.clientX;
10
- }, Ie = ({
11
- source: t,
12
- mimeType: a,
13
- poster: n,
14
- autoPlay: s = !1,
15
- playing: i,
16
- loop: o = !1,
17
- controls: c = !0,
18
- showProgress: h = !1,
19
- muted: f = !1,
20
- onContainerClick: l
21
- }) => {
22
- const d = S(a), u = I(null), b = I(null), p = I(null), P = I(i), [v, w] = y(s), [N, k] = y(0), [x, A] = y(!1), [U, B] = y(!1), [V, F] = y(!1), [ue, M] = y(!1), [Z, ee] = y(!0), [J, fe] = y(null), te = L(() => {
23
- F(!1), w(!0);
24
- }, []), K = L((r) => {
25
- const m = b.current;
26
- if (!m) return 0;
27
- const D = m.getBoundingClientRect();
28
- return Math.max(
29
- 0,
30
- Math.min(1, (ze(r) - D.left) / D.width)
31
- );
32
- }, []), j = L((r) => {
33
- const m = u.current;
34
- m && m.duration && (m.currentTime = r * m.duration);
35
- }, []), G = (r) => {
36
- r.stopPropagation(), A(!0);
37
- const m = K(r);
38
- k(m), j(m);
39
- }, ae = L(
40
- (r) => {
41
- r.key === "ArrowRight" && j(Math.min(1, N + 0.05)), r.key === "ArrowLeft" && j(Math.max(0, N - 0.05));
42
- },
43
- [j, N]
44
- );
45
- C(() => {
46
- i !== void 0 && i !== P.current && (P.current = i, w(i));
47
- }, [i]), C(() => {
48
- if (!v) {
49
- p.current !== null && (cancelAnimationFrame(p.current), p.current = null);
50
- return;
51
- }
52
- const r = () => {
53
- const m = u.current;
54
- m && m.duration && !x && k(m.currentTime / m.duration), p.current = requestAnimationFrame(r);
55
- };
56
- return p.current = requestAnimationFrame(r), () => {
57
- p.current !== null && cancelAnimationFrame(p.current);
58
- };
59
- }, [v, x]), C(() => {
60
- const r = u.current;
61
- r && (v ? r.play().catch((m) => {
62
- w(!1), F(!0);
63
- }) : r.pause());
64
- }, [v]), C(() => {
65
- if (!x) return;
66
- const r = (D) => k(K(D)), m = (D) => {
67
- A(!1), j(K(D));
68
- };
69
- return window.addEventListener("mousemove", r), window.addEventListener("mouseup", m), window.addEventListener("touchmove", r, { passive: !0 }), window.addEventListener("touchend", m), () => {
70
- window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", m), window.removeEventListener("touchmove", r), window.removeEventListener("touchend", m);
71
- };
72
- }, [x, K, j]);
73
- const he = J ? { aspectRatio: String(J) } : void 0, me = J ? "" : " aspect-video", R = Math.round(N * 100);
74
- return /* @__PURE__ */ g(
75
- "div",
76
- {
77
- role: "button",
78
- tabIndex: 0,
79
- className: `relative cursor-pointer overflow-hidden bg-black ${me}`,
80
- style: he,
81
- onClick: (r) => {
82
- if (l) {
83
- l(r);
84
- return;
85
- }
86
- V || c && w((m) => !m);
87
- },
88
- onKeyDown: (r) => {
89
- if (!(r.key !== "Enter" && r.key !== " ")) {
90
- if (r.preventDefault(), l) {
91
- l(r);
92
- return;
93
- }
94
- V || c && w((m) => !m);
95
- }
96
- },
97
- children: [
98
- n && (d === "audio" || Z) && /* @__PURE__ */ e(
99
- "img",
100
- {
101
- src: n,
102
- alt: "",
103
- className: "absolute inset-0 h-full w-full object-cover"
104
- }
105
- ),
106
- !n && (d === "audio" || Z) && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: E(a, {
107
- className: "size-12 text-black/20",
108
- weight: "regular"
109
- }) }),
110
- /* @__PURE__ */ e("div", { className: "absolute inset-0", children: d === "audio" ? /* @__PURE__ */ e(
111
- "audio",
112
- {
113
- ...ke,
114
- ref: u,
115
- src: t,
116
- loop: o,
117
- muted: f,
118
- style: { width: "100%", height: "100%" },
119
- onLoadStart: () => M(!0),
120
- onCanPlay: () => {
121
- M(!1), ee(!1);
122
- },
123
- onWaiting: () => M(!0),
124
- onPlay: () => F(!1),
125
- onEnded: () => {
126
- o || (w(!1), k(0));
127
- },
128
- children: /* @__PURE__ */ e("track", { kind: "captions" })
129
- }
130
- ) : /* @__PURE__ */ e(
131
- "video",
132
- {
133
- ref: u,
134
- src: t,
135
- loop: o,
136
- muted: f,
137
- playsInline: !0,
138
- style: { width: "100%", height: "100%" },
139
- onLoadStart: () => M(!0),
140
- onCanPlay: () => {
141
- M(!1), ee(!1);
142
- },
143
- onWaiting: () => M(!0),
144
- onPlay: () => F(!1),
145
- onLoadedMetadata: () => {
146
- const r = u.current;
147
- r instanceof HTMLVideoElement && r.videoWidth && r.videoHeight && fe(r.videoWidth / r.videoHeight);
148
- },
149
- onEnded: () => {
150
- o || (w(!1), k(0));
151
- },
152
- children: /* @__PURE__ */ e("track", { kind: "captions" })
153
- }
154
- ) }),
155
- ue && !V && /* @__PURE__ */ e("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ e(
156
- be,
157
- {
158
- className: "size-8 animate-spin text-white/80",
159
- weight: "bold"
160
- }
161
- ) }),
162
- V && !c && /* @__PURE__ */ e(
163
- "div",
164
- {
165
- className: "absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",
166
- role: "button",
167
- tabIndex: 0,
168
- "aria-label": "Play preview",
169
- onClick: (r) => {
170
- r.stopPropagation(), te();
171
- },
172
- onKeyDown: (r) => {
173
- r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.stopPropagation(), te());
174
- },
175
- children: /* @__PURE__ */ e("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ e(H, { className: "size-9 translate-x-0.5", weight: "fill" }) })
176
- }
177
- ),
178
- h && !c && /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent", children: /* @__PURE__ */ e(
179
- "div",
180
- {
181
- role: "slider",
182
- "aria-label": "Playback position",
183
- "aria-valuenow": R,
184
- "aria-valuemin": 0,
185
- "aria-valuemax": 100,
186
- tabIndex: 0,
187
- ref: b,
188
- className: "relative flex h-4 w-full cursor-pointer items-center",
189
- onMouseDown: G,
190
- onTouchStart: G,
191
- onClick: (r) => r.stopPropagation(),
192
- onKeyDown: ae,
193
- children: /* @__PURE__ */ e("div", { className: "w-full overflow-hidden rounded-full bg-white/30 h-1", children: /* @__PURE__ */ e(
194
- "div",
195
- {
196
- className: "h-full rounded-full bg-white",
197
- style: { width: `${R}%` }
198
- }
199
- ) })
200
- }
201
- ) }),
202
- c && /* @__PURE__ */ g("div", { className: "absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/60 to-transparent px-3 pb-2.5 pt-6 transition-all duration-200", children: [
203
- /* @__PURE__ */ e(
204
- "button",
205
- {
206
- type: "button",
207
- onClick: (r) => {
208
- r.stopPropagation(), w((m) => !m);
209
- },
210
- className: "shrink-0 text-white",
211
- "aria-label": v ? "Pause" : "Play",
212
- children: v ? /* @__PURE__ */ e(ge, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ e(H, { className: "size-5 translate-x-px", weight: "fill" })
213
- }
214
- ),
215
- /* @__PURE__ */ g(
216
- "div",
217
- {
218
- role: "slider",
219
- "aria-label": "Playback position",
220
- "aria-valuenow": R,
221
- "aria-valuemin": 0,
222
- "aria-valuemax": 100,
223
- tabIndex: 0,
224
- ref: b,
225
- className: "relative flex h-4 w-full cursor-pointer items-center",
226
- onMouseDown: G,
227
- onTouchStart: G,
228
- onClick: (r) => r.stopPropagation(),
229
- onMouseEnter: () => B(!0),
230
- onMouseLeave: () => B(!1),
231
- onKeyDown: ae,
232
- children: [
233
- /* @__PURE__ */ e(
234
- "div",
235
- {
236
- className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${U || x ? "h-1.5" : "h-1"}`,
237
- children: /* @__PURE__ */ e(
238
- "div",
239
- {
240
- className: "h-full rounded-full bg-white",
241
- style: { width: `${R}%` }
242
- }
243
- )
244
- }
245
- ),
246
- /* @__PURE__ */ e(
247
- "div",
248
- {
249
- className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${U || x ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
250
- style: { left: `${R}%` }
251
- }
252
- )
253
- ]
254
- }
255
- )
256
- ] })
257
- ]
258
- }
259
- );
260
- }, ne = (t) => t === "dark" ? "size-12 text-white/20" : "size-12 text-black/20", Q = (t) => t === "dark" ? "aspect-video overflow-hidden bg-white/10" : "aspect-video overflow-hidden bg-black/5", le = ({
261
- mimeType: t,
262
- sourceUrl: a,
263
- thumbnailUrl: n,
264
- title: s,
265
- variant: i,
266
- mediaPlayerProps: o,
267
- containedImage: c = !1
268
- }) => {
269
- const h = S(t), [f, l] = y(!1), d = X(a), u = X(n);
270
- return a && (h === "video" || h === "audio") ? /* @__PURE__ */ e(
271
- Ie,
272
- {
273
- source: a,
274
- mimeType: t,
275
- poster: u,
276
- controls: !0,
277
- ...o
278
- }
279
- ) : a && h === "image" ? c ? /* @__PURE__ */ e("div", { className: `relative ${Q(i)}`, children: /* @__PURE__ */ e(
280
- "img",
281
- {
282
- src: d ?? a,
283
- alt: s ?? "",
284
- className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${f ? "opacity-100" : "opacity-0"}`,
285
- draggable: !1,
286
- onLoad: () => l(!0)
287
- }
288
- ) }) : /* @__PURE__ */ e(
289
- "img",
290
- {
291
- src: d ?? a,
292
- alt: s ?? "",
293
- className: "block w-full",
294
- draggable: !1
295
- }
296
- ) : a && h === "document" ? n ? c ? /* @__PURE__ */ e("div", { className: `relative ${Q(i)}`, children: /* @__PURE__ */ e(
297
- "img",
298
- {
299
- src: u ?? n,
300
- alt: s ?? "",
301
- className: `absolute inset-0 h-full w-full object-contain transition-opacity duration-300 ${f ? "opacity-100" : "opacity-0"}`,
302
- draggable: !1,
303
- onLoad: () => l(!0)
304
- }
305
- ) }) : /* @__PURE__ */ e(
306
- "img",
307
- {
308
- src: u ?? n,
309
- alt: "",
310
- className: "block w-full",
311
- draggable: !1
312
- }
313
- ) : /* @__PURE__ */ e(
314
- "div",
315
- {
316
- className: `flex aspect-video w-full items-center justify-center ${i === "dark" ? "bg-white/10" : "bg-black/5"}`,
317
- children: E(t, {
318
- className: ne(i),
319
- weight: "regular"
320
- })
321
- }
322
- ) : n ? /* @__PURE__ */ e("div", { className: `relative ${Q(i)}`, children: /* @__PURE__ */ e(
323
- "img",
324
- {
325
- src: u ?? n,
326
- alt: s ?? "",
327
- draggable: !1,
328
- className: "absolute inset-0 h-full w-full object-cover"
329
- }
330
- ) }) : /* @__PURE__ */ e(
331
- "div",
332
- {
333
- className: `flex aspect-video w-full items-center justify-center ${i === "dark" ? "bg-white/10" : "bg-black/5"}`,
334
- children: E(t, {
335
- className: ne(i),
336
- weight: "regular"
337
- })
338
- }
339
- );
340
- }, q = ({
341
- variant: t,
342
- title: a,
343
- placeholderTitle: n = "Attachment title",
344
- mimeType: s,
345
- detail: i,
346
- statusBadge: o,
347
- action: c,
348
- icon: h,
349
- trailingAction: f
350
- }) => {
351
- const l = t === "dark", d = a || n, u = !a, b = h ?? E(s, {
352
- className: z(
353
- "size-5 shrink-0",
354
- l ? "text-white/55" : "text-black/55"
355
- ),
356
- weight: "regular"
357
- });
358
- return /* @__PURE__ */ g("div", { className: "px-4 py-3", children: [
359
- /* @__PURE__ */ g("div", { className: "flex items-end gap-3", children: [
360
- /* @__PURE__ */ g("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [
361
- d.trim() !== "" && /* @__PURE__ */ e(
362
- "p",
363
- {
364
- className: z(
365
- "truncate text-base font-medium leading-6",
366
- {
367
- "text-black/90": !l && !u,
368
- "text-black/30": !l && u,
369
- "text-white/30": l && u,
370
- "text-white": l && !u
371
- }
372
- ),
373
- children: d
374
- }
375
- ),
376
- /* @__PURE__ */ g("div", { className: "flex flex-wrap items-center gap-1", children: [
377
- b,
378
- i != null && i !== "" && /* @__PURE__ */ e(
379
- "span",
380
- {
381
- className: z(
382
- "text-xs font-medium",
383
- l ? "text-white/55" : "text-black/55"
384
- ),
385
- children: i
386
- }
387
- ),
388
- o
389
- ] })
390
- ] }),
391
- f && /* @__PURE__ */ e("div", { className: "shrink-0", children: f })
392
- ] }),
393
- c
394
- ] });
395
- }, oe = ({
396
- paymentStatus: t,
397
- mimeType: a,
398
- isPlayable: n,
399
- isLocked: s
400
- }) => {
401
- const i = a ? S(a) : void 0, c = (n ?? (i === "video" || i === "audio")) && !s ? H : t === "paid" ? ve : re;
402
- return /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(
403
- "div",
404
- {
405
- className: z(
406
- "flex size-12 items-center justify-center rounded-full bg-black/30 text-white",
407
- c === H && "group-hover:bg-black/40"
408
- ),
409
- children: /* @__PURE__ */ e(c, { className: "size-6", weight: "fill" })
410
- }
411
- ) });
412
- };
413
- function Le(t) {
414
- const a = S(t.mimeType);
415
- return a === "video" || a === "audio";
416
- }
417
- const Me = ({
418
- variant: t,
419
- gallery: a,
420
- title: n,
421
- showLocked: s,
422
- paymentStatus: i,
423
- topRight: o
424
- }) => {
425
- const [c, h] = y(0), f = a.length, l = Math.min(c, f - 1), d = a[l], u = Le(d), b = X(
426
- d.thumbnailUrl
427
- ), p = (k) => {
428
- k.stopPropagation(), h((x) => Math.max(0, x - 1));
429
- }, P = (k) => {
430
- k.stopPropagation(), h((x) => Math.min(f - 1, x + 1));
431
- }, v = l === 0, w = l === f - 1, N = t === "dark";
432
- return /* @__PURE__ */ g(
433
- "div",
434
- {
435
- className: z(
436
- "group relative overflow-hidden rounded-t-md",
437
- s ? "aspect-[337/386]" : void 0
438
- ),
439
- children: [
440
- s ? /* @__PURE__ */ e(
441
- "div",
442
- {
443
- className: z(
444
- "absolute inset-0",
445
- N ? "bg-white/10" : "bg-black/5"
446
- ),
447
- children: d.thumbnailUrl && /* @__PURE__ */ e(
448
- "img",
449
- {
450
- src: b ?? d.thumbnailUrl,
451
- alt: "",
452
- "aria-hidden": !0,
453
- draggable: !1,
454
- className: "absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
455
- }
456
- )
457
- }
458
- ) : /* @__PURE__ */ e(
459
- le,
460
- {
461
- mimeType: d.mimeType,
462
- sourceUrl: d.sourceUrl,
463
- thumbnailUrl: d.thumbnailUrl,
464
- title: n,
465
- variant: t,
466
- mediaPlayerProps: { autoPlay: !0 }
467
- },
468
- l
469
- ),
470
- s && /* @__PURE__ */ e(
471
- oe,
472
- {
473
- paymentStatus: i,
474
- isPlayable: u,
475
- isLocked: s
476
- }
477
- ),
478
- f > 1 && /* @__PURE__ */ g(T.Fragment, { children: [
479
- /* @__PURE__ */ e(
480
- "button",
481
- {
482
- type: "button",
483
- onClick: p,
484
- disabled: v,
485
- "aria-label": "Previous item",
486
- className: z(
487
- "absolute left-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity",
488
- v ? "opacity-40" : "hover:bg-black/40"
489
- ),
490
- children: /* @__PURE__ */ e(we, { className: "size-5", weight: "bold" })
491
- }
492
- ),
493
- /* @__PURE__ */ e(
494
- "button",
495
- {
496
- type: "button",
497
- onClick: P,
498
- disabled: w,
499
- "aria-label": "Next item",
500
- className: z(
501
- "absolute right-3 top-1/2 -translate-y-1/2 flex size-7 items-center justify-center rounded-full bg-black/30 text-white transition-opacity",
502
- w ? "opacity-40" : "hover:bg-black/40"
503
- ),
504
- children: /* @__PURE__ */ e(pe, { className: "size-5", weight: "bold" })
505
- }
506
- ),
507
- /* @__PURE__ */ e("div", { className: "pointer-events-none absolute bottom-10 left-1/2 flex size-8 -translate-x-1/2 items-center justify-center rounded-full bg-black/30", children: /* @__PURE__ */ g("span", { className: "text-xs font-medium leading-none text-white", children: [
508
- l + 1,
509
- "/",
510
- f
511
- ] }) })
512
- ] }),
513
- o && /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: o })
514
- ]
515
- }
516
- );
517
- }, je = ({
518
- variant: t,
519
- mimeType: a,
520
- thumbnailUrl: n,
521
- title: s,
522
- source: i,
523
- showLocked: o,
524
- paymentStatus: c,
525
- topRight: h,
526
- containedImage: f = !1
527
- }) => {
528
- const l = o || i == null ? void 0 : i.sourceUrl, d = o ? n : (i == null ? void 0 : i.thumbnailUrl) ?? n, u = X(
529
- d
530
- ), b = t === "dark";
531
- return /* @__PURE__ */ g("div", { className: "relative overflow-hidden rounded-t-md", children: [
532
- o ? /* @__PURE__ */ g(
533
- "div",
534
- {
535
- className: z(
536
- "relative aspect-video overflow-hidden",
537
- b ? "bg-white/10" : "bg-black/5"
538
- ),
539
- children: [
540
- d ? /* @__PURE__ */ e(
541
- "img",
542
- {
543
- src: u ?? d,
544
- alt: "",
545
- "aria-hidden": !0,
546
- draggable: !1,
547
- className: "absolute inset-0 h-full w-full scale-110 object-cover blur-[40px]"
548
- }
549
- ) : /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: E(a, {
550
- className: b ? "size-12 text-white/20" : "size-12 text-black/20",
551
- weight: "regular"
552
- }) }),
553
- /* @__PURE__ */ e(
554
- oe,
555
- {
556
- paymentStatus: c,
557
- mimeType: a,
558
- isLocked: o
559
- }
560
- )
561
- ]
562
- }
563
- ) : /* @__PURE__ */ e(
564
- le,
565
- {
566
- mimeType: a,
567
- sourceUrl: l,
568
- thumbnailUrl: d,
569
- title: s,
570
- variant: t,
571
- containedImage: f,
572
- mediaPlayerProps: l ? { autoPlay: !0, loop: !0, controls: !0, muted: !1 } : void 0
573
- }
574
- ),
575
- h && /* @__PURE__ */ e("div", { className: "pointer-events-auto absolute right-3 top-3 z-10", children: h })
576
- ] });
577
- }, $ = (t) => t.length >= 2, O = (t) => /* @__PURE__ */ e(
578
- xe,
579
- {
580
- className: t === "dark" ? "size-5 shrink-0 text-white/55" : "size-5 shrink-0 text-black/55"
581
- }
582
- ), W = ({
583
- variant: t,
584
- gallery: a,
585
- title: n,
586
- showLocked: s,
587
- paymentStatus: i,
588
- mimeType: o,
589
- thumbnailUrl: c,
590
- source: h,
591
- containedImage: f,
592
- topRight: l
593
- }) => $(a) ? /* @__PURE__ */ e(
594
- Me,
595
- {
596
- variant: t,
597
- gallery: a,
598
- title: n,
599
- showLocked: s,
600
- paymentStatus: i,
601
- topRight: l
602
- }
603
- ) : /* @__PURE__ */ e(
604
- je,
605
- {
606
- variant: t,
607
- mimeType: o,
608
- thumbnailUrl: c,
609
- title: n,
610
- source: h,
611
- showLocked: s,
612
- paymentStatus: i,
613
- topRight: l,
614
- containedImage: f
615
- }
616
- ), _ = ({
617
- variant: t,
618
- children: a,
619
- rootRef: n,
620
- "data-testid": s
621
- }) => /* @__PURE__ */ e(
622
- "div",
623
- {
624
- ref: n,
625
- "data-testid": s,
626
- className: z(
627
- "relative w-[280px] select-none overflow-hidden rounded-md",
628
- t === "dark" ? "bg-[#1e2330]" : "bg-white",
629
- "shadow-[0_1px_2px_rgba(0,0,0,0.08)]"
630
- ),
631
- children: a
632
- }
633
- ), ce = ({
634
- onToggle: t,
635
- isBusy: a,
636
- isPreviewVisible: n,
637
- children: s
638
- }) => t ? /* @__PURE__ */ e(
639
- "div",
640
- {
641
- role: "button",
642
- tabIndex: a ? -1 : 0,
643
- "aria-label": "Toggle preview",
644
- "aria-busy": a,
645
- "aria-pressed": n,
646
- "aria-disabled": a || void 0,
647
- onClick: a ? void 0 : t,
648
- onKeyDown: (i) => {
649
- a || i.target === i.currentTarget && (i.key === "Enter" || i.key === " ") && (i.preventDefault(), t());
650
- },
651
- className: a ? "block w-full text-left" : "block w-full cursor-pointer text-left",
652
- children: s
653
- }
654
- ) : /* @__PURE__ */ e(T.Fragment, { children: s });
655
- function de({
656
- isGallery: t,
657
- onFetchSource: a,
658
- onPreviewClick: n
659
- }) {
660
- const [s, i] = y(), [o, c] = y(!1), [h, f] = y(!1), l = I(!1), d = L(async () => {
661
- if (n == null || n(), o) {
662
- c(!1);
663
- return;
664
- }
665
- if (t) {
666
- c(!0);
667
- return;
668
- }
669
- if (s) {
670
- c(!0);
671
- return;
672
- }
673
- if (a && !l.current) {
674
- l.current = !0, f(!0);
675
- try {
676
- const b = await a();
677
- b && (i(b), c(!0));
678
- } finally {
679
- l.current = !1, f(!1);
680
- }
681
- }
682
- }, [o, t, s, n, a]), u = t || a != null || n != null ? d : void 0;
683
- return {
684
- source: s,
685
- isPreviewVisible: o,
686
- isLoadingPreview: h,
687
- handleToggle: d,
688
- togglePreview: u
689
- };
690
- }
691
- function De({
692
- paymentStatus: t,
693
- onFetchSource: a,
694
- onUnlockClick: n
695
- }) {
696
- const [s, i] = y(), o = I(null), c = I(!1), h = I(a);
697
- h.current = a;
698
- const f = L(async () => {
699
- var d;
700
- if (!c.current) {
701
- c.current = !0;
702
- try {
703
- const u = await ((d = h.current) == null ? void 0 : d.call(h));
704
- u && i(u);
705
- } finally {
706
- c.current = !1;
707
- }
708
- }
709
- }, []), l = L(() => {
710
- t === "paid" ? f() : n == null || n();
711
- }, [t, f, n]);
712
- return C(() => {
713
- if (!o.current || t !== "paid" || s !== void 0) return;
714
- const d = new IntersectionObserver(
715
- ([u]) => {
716
- u.isIntersecting && (f(), d.disconnect());
717
- },
718
- { threshold: 1 }
719
- );
720
- return d.observe(o.current), () => d.disconnect();
721
- }, [t, s, f]), { source: s, cardRef: o, handleUnlockClick: l };
722
- }
723
- const Y = "mt-3 inline-flex h-10 w-full items-center justify-center gap-2 rounded-full bg-[#121110] px-4 text-sm font-medium leading-none text-white hover:bg-[#2a2928]", Re = ({
724
- isLocked: t,
725
- sourceUrl: a,
726
- redeemUrl: n,
727
- onUnlockClicked: s,
728
- onDownloadClicked: i,
729
- isUnlocking: o = !1
730
- }) => {
731
- if (t && s != null)
732
- return /* @__PURE__ */ e(
733
- "button",
734
- {
735
- type: "button",
736
- onClick: s,
737
- disabled: o,
738
- "aria-label": o ? "Unlocking" : "Unlock",
739
- "aria-busy": o,
740
- title: o ? "Unlocking" : "Unlock",
741
- className: Y,
742
- children: o ? /* @__PURE__ */ e(Pe, {}) : /* @__PURE__ */ g(T.Fragment, { children: [
743
- /* @__PURE__ */ e(re, { className: "size-4", weight: "fill" }),
744
- "Unlock"
745
- ] })
746
- }
747
- );
748
- if (!t && i != null) {
749
- const c = n ?? a;
750
- return c != null ? /* @__PURE__ */ g(
751
- "a",
752
- {
753
- href: c,
754
- "aria-label": "Download",
755
- target: "_blank",
756
- rel: "noopener noreferrer",
757
- onClick: i,
758
- className: `${Y} !text-white`,
759
- children: [
760
- /* @__PURE__ */ e(ie, { className: "size-4", weight: "bold" }),
761
- "Download"
762
- ]
763
- }
764
- ) : /* @__PURE__ */ g(
765
- "button",
766
- {
767
- type: "button",
768
- onClick: i,
769
- "aria-label": "Download",
770
- className: Y,
771
- children: [
772
- /* @__PURE__ */ e(ie, { className: "size-4", weight: "bold" }),
773
- "Download"
774
- ]
775
- }
776
- );
777
- }
778
- return null;
779
- }, Ce = ({
780
- title: t,
781
- mimeType: a = "application/octet-stream",
782
- thumbnailUrl: n,
783
- detail: s,
784
- amountText: i,
785
- placeholderTitle: o,
786
- placeholderAmountText: c,
787
- gallery: h = [],
788
- onDismiss: f,
789
- onPreviewClick: l,
790
- onFetchSource: d,
791
- onEditClick: u
792
- }) => {
793
- const b = $(h), { source: p, isPreviewVisible: P, isLoadingPreview: v, togglePreview: w } = de({ isGallery: b, onFetchSource: d, onPreviewClick: l }), N = !P, k = v, x = /* @__PURE__ */ g(T.Fragment, { children: [
794
- /* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
795
- /* @__PURE__ */ e(
796
- "span",
797
- {
798
- className: i ? "text-xs font-medium text-white/55" : "text-xs font-medium text-white/30",
799
- children: i || c
800
- }
801
- )
802
- ] }), A = f ? /* @__PURE__ */ e(
803
- "button",
804
- {
805
- type: "button",
806
- onClick: (B) => {
807
- B.stopPropagation(), f();
808
- },
809
- className: "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",
810
- "aria-label": "Dismiss attachment",
811
- children: /* @__PURE__ */ e(ye, { className: "size-3", weight: "bold" })
812
- }
813
- ) : void 0, U = u ? /* @__PURE__ */ e(
814
- "button",
815
- {
816
- type: "button",
817
- onClick: u,
818
- "aria-label": "Edit attachment",
819
- className: "flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
820
- children: /* @__PURE__ */ e(Ne, { className: "size-5", weight: "regular" })
821
- }
822
- ) : void 0;
823
- return /* @__PURE__ */ g(_, { variant: "dark", children: [
824
- /* @__PURE__ */ e(
825
- ce,
826
- {
827
- onToggle: w,
828
- isBusy: k,
829
- isPreviewVisible: !N,
830
- children: /* @__PURE__ */ e(
831
- W,
832
- {
833
- variant: "dark",
834
- gallery: h,
835
- title: t,
836
- showLocked: N,
837
- mimeType: a,
838
- thumbnailUrl: n,
839
- source: p,
840
- topRight: A
841
- }
842
- )
843
- }
844
- ),
845
- /* @__PURE__ */ e(
846
- q,
847
- {
848
- variant: "dark",
849
- title: t,
850
- placeholderTitle: o,
851
- mimeType: a,
852
- detail: s,
853
- statusBadge: x,
854
- icon: b ? O("dark") : void 0,
855
- trailingAction: U
856
- }
857
- )
858
- ] });
859
- }, Ee = ({
860
- title: t,
861
- mimeType: a = "application/octet-stream",
862
- thumbnailUrl: n,
863
- detail: s,
864
- amountText: i,
865
- placeholderTitle: o,
866
- placeholderAmountText: c,
867
- gallery: h = []
868
- }) => {
869
- const f = $(h), l = /* @__PURE__ */ g(T.Fragment, { children: [
870
- /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: "•" }),
871
- /* @__PURE__ */ e(
872
- "span",
873
- {
874
- className: i ? "text-xs font-medium text-black/55" : "text-xs font-medium text-black/30",
875
- children: i || c
876
- }
877
- )
878
- ] });
879
- return /* @__PURE__ */ g(_, { variant: "light", children: [
880
- /* @__PURE__ */ e(
881
- W,
882
- {
883
- variant: "light",
884
- gallery: h,
885
- title: t,
886
- showLocked: !0,
887
- mimeType: a,
888
- thumbnailUrl: n
889
- }
890
- ),
891
- /* @__PURE__ */ e(
892
- q,
893
- {
894
- variant: "light",
895
- title: t,
896
- placeholderTitle: o,
897
- mimeType: a,
898
- detail: s,
899
- statusBadge: l,
900
- icon: f ? O("light") : void 0
901
- }
902
- )
903
- ] });
904
- }, Te = ({
905
- title: t,
906
- mimeType: a = "application/octet-stream",
907
- thumbnailUrl: n,
908
- detail: s,
909
- amountText: i,
910
- placeholderTitle: o,
911
- paymentStatus: c = "pending",
912
- gallery: h = [],
913
- onPreviewClick: f,
914
- onFetchSource: l
915
- }) => {
916
- const d = $(h), { source: u, isPreviewVisible: b, isLoadingPreview: p, togglePreview: P } = de({ isGallery: d, onFetchSource: l, onPreviewClick: f }), v = !b;
917
- return /* @__PURE__ */ g(_, { variant: "dark", children: [
918
- /* @__PURE__ */ e(
919
- ce,
920
- {
921
- onToggle: P,
922
- isBusy: p,
923
- isPreviewVisible: !v,
924
- children: /* @__PURE__ */ e(
925
- W,
926
- {
927
- variant: "dark",
928
- gallery: h,
929
- title: t,
930
- showLocked: v,
931
- paymentStatus: c,
932
- mimeType: a,
933
- thumbnailUrl: n,
934
- source: u
935
- }
936
- )
937
- }
938
- ),
939
- /* @__PURE__ */ e(
940
- q,
941
- {
942
- variant: "dark",
943
- title: t,
944
- placeholderTitle: o,
945
- mimeType: a,
946
- detail: s,
947
- statusBadge: /* @__PURE__ */ e(
948
- se,
949
- {
950
- isMine: !0,
951
- paymentStatus: c,
952
- amountText: i
953
- }
954
- ),
955
- icon: d ? O("dark") : void 0
956
- }
957
- )
958
- ] });
959
- }, Se = ({
960
- title: t,
961
- amountText: a,
962
- thumbnailUrl: n,
963
- mimeType: s = "application/octet-stream",
964
- detail: i,
965
- gallery: o = [],
966
- onUnlockClick: c,
967
- onFetchSource: h,
968
- onDownloadClick: f,
969
- paymentStatus: l,
970
- isUnlocking: d = !1
971
- }) => {
972
- const u = $(o), { source: b, cardRef: p, handleUnlockClick: P } = De({
973
- paymentStatus: l,
974
- onFetchSource: h,
975
- onUnlockClick: c
976
- }), v = b == null ? void 0 : b.sourceUrl, w = b == null ? void 0 : b.redeemUrl, N = u ? l !== "paid" : v === void 0, k = S(s), x = u ? void 0 : v;
977
- return /* @__PURE__ */ g(
978
- _,
979
- {
980
- variant: "light",
981
- rootRef: p,
982
- "data-testid": "locked-attachment",
983
- children: [
984
- /* @__PURE__ */ e(
985
- W,
986
- {
987
- variant: "light",
988
- gallery: o,
989
- title: t,
990
- showLocked: N,
991
- paymentStatus: l,
992
- mimeType: s,
993
- thumbnailUrl: n,
994
- source: b,
995
- containedImage: !N && k === "document"
996
- }
997
- ),
998
- /* @__PURE__ */ e(
999
- q,
1000
- {
1001
- variant: "light",
1002
- title: t,
1003
- mimeType: s,
1004
- detail: i,
1005
- statusBadge: /* @__PURE__ */ e(
1006
- se,
1007
- {
1008
- isMine: !1,
1009
- paymentStatus: l,
1010
- amountText: a
1011
- }
1012
- ),
1013
- icon: u ? O("light") : void 0,
1014
- action: /* @__PURE__ */ e(
1015
- Re,
1016
- {
1017
- isLocked: N,
1018
- isUnlocking: d,
1019
- sourceUrl: x,
1020
- redeemUrl: w,
1021
- onUnlockClicked: P,
1022
- onDownloadClicked: f
1023
- }
1024
- )
1025
- }
1026
- )
1027
- ]
1028
- }
1029
- );
1030
- }, Ke = (t) => t.isDraft ? /* @__PURE__ */ e(Ce, { ...t }) : t.isPreview ? /* @__PURE__ */ e(Ee, { ...t }) : t.isMine ? /* @__PURE__ */ e(Te, { ...t }) : /* @__PURE__ */ e(Se, { ...t });
1031
- export {
1032
- Ke as default
1033
- };
1034
- //# sourceMappingURL=Card-ChcosZir.js.map