@linktr.ee/messaging-react 4.2.1-rc-1787343260 → 4.3.0-rc-1787409421

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