@linktr.ee/messaging-react 1.28.0-rc-1776233688 → 1.28.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.
@@ -1,7 +1,7 @@
1
- import { jsxs as L, jsx as n } from "react/jsx-runtime";
2
- import { FileIcon as $, ImageIcon as V, SpeakerHighIcon as G, VideoCameraIcon as Y, FileMdIcon as Z, FileTextIcon as J, FileZipIcon as Q, FilePptIcon as ee, FileCsvIcon as te, FileXlsIcon as ne, FileDocIcon as ae, FilePdfIcon as re, CircleNotchIcon as ie, PlayIcon as W, PauseIcon as oe } from "@phosphor-icons/react";
3
- import se, { useState as c, useRef as M, useEffect as x, useCallback as z } from "react";
4
- const le = [
1
+ import { jsxs as z, jsx as n } from "react/jsx-runtime";
2
+ import { FileIcon as H, ImageIcon as Y, SpeakerHighIcon as Z, VideoCameraIcon as J, FileMdIcon as Q, FileTextIcon as ee, FileZipIcon as te, FilePptIcon as ne, FileCsvIcon as ae, FileXlsIcon as ie, FileDocIcon as re, FilePdfIcon as oe, CircleNotchIcon as se, PlayIcon as $, PauseIcon as le } from "@phosphor-icons/react";
3
+ import ce, { useState as s, useRef as M, useEffect as x, useCallback as C } from "react";
4
+ const ue = [
5
5
  [/pdf/, "pdf"],
6
6
  [/wordprocessingml|msword|\.doc/, "doc"],
7
7
  [/spreadsheetml|ms-excel|\.xls/, "xls"],
@@ -11,73 +11,73 @@ const le = [
11
11
  [/plain|rtf/, "text"],
12
12
  [/markdown/, "markdown"]
13
13
  ];
14
- function H(a) {
14
+ function _(a) {
15
15
  return a.startsWith("video/") ? "video" : a.startsWith("audio/") ? "audio" : a.startsWith("image/") ? "image" : "document";
16
16
  }
17
- function ce(a) {
18
- const r = le.find(
19
- ([i]) => i.test(a)
17
+ function de(a) {
18
+ const i = ue.find(
19
+ ([r]) => r.test(a)
20
20
  );
21
- return r ? r[1] : "generic";
21
+ return i ? i[1] : "generic";
22
22
  }
23
- const ue = {
24
- video: Y,
25
- audio: G,
26
- image: V,
27
- document: $
28
- }, de = {
29
- pdf: re,
30
- doc: ae,
31
- xls: ne,
32
- csv: te,
33
- ppt: ee,
34
- zip: Q,
35
- text: J,
36
- markdown: Z,
37
- generic: $
23
+ const fe = {
24
+ video: J,
25
+ audio: Z,
26
+ image: Y,
27
+ document: H
28
+ }, me = {
29
+ pdf: oe,
30
+ doc: re,
31
+ xls: ie,
32
+ csv: ae,
33
+ ppt: ne,
34
+ zip: te,
35
+ text: ee,
36
+ markdown: Q,
37
+ generic: H
38
38
  };
39
- function fe(a) {
40
- const r = H(a);
41
- return r !== "document" ? ue[r] : de[ce(a)];
39
+ function he(a) {
40
+ const i = _(a);
41
+ return i !== "document" ? fe[i] : me[de(a)];
42
42
  }
43
- function me(a, r) {
44
- return se.createElement(fe(a), r);
43
+ function ve(a, i) {
44
+ return ce.createElement(he(a), i);
45
45
  }
46
- const he = (a, r) => a === "audio" && !r ? "bg-black/5" : "bg-black";
47
- function pe(a) {
48
- var r, i;
49
- return "touches" in a ? ((r = a.touches[0]) == null ? void 0 : r.clientX) ?? ((i = a.changedTouches[0]) == null ? void 0 : i.clientX) ?? 0 : a.clientX;
46
+ const pe = (a, i) => a === "audio" && !i ? "bg-black/5" : "bg-black";
47
+ function we(a) {
48
+ var i, r;
49
+ return "touches" in a ? ((i = a.touches[0]) == null ? void 0 : i.clientX) ?? ((r = a.changedTouches[0]) == null ? void 0 : r.clientX) ?? 0 : a.clientX;
50
50
  }
51
- const be = ({
51
+ const xe = ({
52
52
  source: a,
53
- mimeType: r,
54
- poster: i,
55
- autoPlay: _ = !1,
53
+ mimeType: i,
54
+ poster: r,
55
+ autoPlay: X = !1,
56
56
  playing: u,
57
57
  loop: k = !1,
58
- controls: v = !0,
59
- showProgress: X = !1,
58
+ controls: p = !0,
59
+ showProgress: q = !1,
60
60
  onContainerClick: N,
61
- muted: C = !1
61
+ muted: D = !1
62
62
  }) => {
63
- const D = H(r), [d, o] = c(_), R = M(u);
63
+ const R = _(i), [d, o] = s(X), A = M(u);
64
64
  x(() => {
65
- u !== void 0 && u !== R.current && (R.current = u, o(u));
65
+ u !== void 0 && u !== A.current && (A.current = u, o(u));
66
66
  }, [u]);
67
- const [w, g] = c(0), [f, A] = c(!1), [S, j] = c(!1), [T, q] = c(null), [K, m] = c(!1), [I, b] = c(!1), h = M(null), F = M(null), s = M(null);
67
+ const [w, g] = s(0), [f, S] = s(!1), [j, O] = s(!1), [L, K] = s(null), [B, m] = s(!1), [U, T] = s(!0), [I, b] = s(!1), h = M(null), F = M(null), l = M(null);
68
68
  x(() => {
69
- b(!1);
69
+ b(!1), T(!0);
70
70
  }, [a]), x(() => {
71
71
  if (!d) {
72
- s.current !== null && (cancelAnimationFrame(s.current), s.current = null);
72
+ l.current !== null && (cancelAnimationFrame(l.current), l.current = null);
73
73
  return;
74
74
  }
75
75
  const e = () => {
76
76
  const t = h.current;
77
- t && t.duration && !f && g(t.currentTime / t.duration), s.current = requestAnimationFrame(e);
77
+ t && t.duration && !f && g(t.currentTime / t.duration), l.current = requestAnimationFrame(e);
78
78
  };
79
- return s.current = requestAnimationFrame(e), () => {
80
- s.current !== null && cancelAnimationFrame(s.current);
79
+ return l.current = requestAnimationFrame(e), () => {
80
+ l.current !== null && cancelAnimationFrame(l.current);
81
81
  };
82
82
  }, [d, f]), x(() => {
83
83
  const e = h.current;
@@ -85,51 +85,51 @@ const be = ({
85
85
  o(!1), b(!0);
86
86
  }) : e.pause());
87
87
  }, [d]);
88
- const O = z(() => {
88
+ const W = C(() => {
89
89
  b(!1), o(!0);
90
- }, []), P = z(
90
+ }, []), P = C(
91
91
  (e) => {
92
92
  const t = F.current;
93
93
  if (!t) return 0;
94
- const p = t.getBoundingClientRect();
94
+ const v = t.getBoundingClientRect();
95
95
  return Math.max(
96
96
  0,
97
- Math.min(1, (pe(e) - p.left) / p.width)
97
+ Math.min(1, (we(e) - v.left) / v.width)
98
98
  );
99
99
  },
100
100
  []
101
- ), l = z((e) => {
101
+ ), c = C((e) => {
102
102
  const t = h.current;
103
103
  t && t.duration && (t.currentTime = e * t.duration);
104
104
  }, []), E = (e) => {
105
- e.stopPropagation(), A(!0);
105
+ e.stopPropagation(), S(!0);
106
106
  const t = P(e);
107
- g(t), l(t);
107
+ g(t), c(t);
108
108
  };
109
109
  x(() => {
110
110
  if (!f) return;
111
- const e = (p) => g(P(p)), t = (p) => {
112
- A(!1), l(P(p));
111
+ const e = (v) => g(P(v)), t = (v) => {
112
+ S(!1), c(P(v));
113
113
  };
114
114
  return window.addEventListener("mousemove", e), window.addEventListener("mouseup", t), window.addEventListener("touchmove", e, { passive: !0 }), window.addEventListener("touchend", t), () => {
115
115
  window.removeEventListener("mousemove", e), window.removeEventListener("mouseup", t), window.removeEventListener("touchmove", e), window.removeEventListener("touchend", t);
116
116
  };
117
- }, [f, P, l]);
118
- const B = T ? { aspectRatio: String(T) } : void 0, U = T ? "" : " aspect-video", y = Math.round(w * 100);
119
- return /* @__PURE__ */ L(
117
+ }, [f, P, c]);
118
+ const V = L ? { aspectRatio: String(L) } : void 0, G = L ? "" : " aspect-video", y = Math.round(w * 100);
119
+ return /* @__PURE__ */ z(
120
120
  "div",
121
121
  {
122
122
  role: "button",
123
123
  tabIndex: 0,
124
- className: `relative cursor-pointer overflow-hidden ${he(D, i)}${U}`,
125
- style: B,
124
+ className: `relative cursor-pointer overflow-hidden ${pe(R, r)}${G}`,
125
+ style: V,
126
126
  onClick: () => {
127
127
  if (!I) {
128
128
  if (N) {
129
129
  N();
130
130
  return;
131
131
  }
132
- v && o((e) => !e);
132
+ p && o((e) => !e);
133
133
  }
134
134
  },
135
135
  onKeyDown: (e) => {
@@ -138,32 +138,35 @@ const be = ({
138
138
  N();
139
139
  return;
140
140
  }
141
- v && o((t) => !t);
141
+ p && o((t) => !t);
142
142
  }
143
143
  },
144
144
  children: [
145
- i && /* @__PURE__ */ n(
145
+ r && /* @__PURE__ */ n(
146
146
  "img",
147
147
  {
148
- src: i,
148
+ src: r,
149
149
  alt: "",
150
150
  className: "absolute inset-0 h-full w-full object-cover"
151
151
  }
152
152
  ),
153
- !i && /* @__PURE__ */ n("div", { className: "absolute inset-0 flex items-center justify-center", children: me(r, {
153
+ !r && /* @__PURE__ */ n("div", { className: "absolute inset-0 flex items-center justify-center", children: ve(i, {
154
154
  className: "size-12 text-black/20",
155
155
  weight: "regular"
156
156
  }) }),
157
- /* @__PURE__ */ n("div", { className: "absolute inset-0", children: D === "audio" ? /* @__PURE__ */ n(
157
+ U && r && /* @__PURE__ */ n("div", { className: "absolute inset-0 z-20", children: /* @__PURE__ */ n("img", { src: r, alt: "", className: "h-full w-full object-cover" }) }),
158
+ /* @__PURE__ */ n("div", { className: "absolute inset-0", children: R === "audio" ? /* @__PURE__ */ n(
158
159
  "audio",
159
160
  {
160
161
  ref: h,
161
162
  src: a,
162
163
  loop: k,
163
- muted: C,
164
+ muted: D,
164
165
  style: { width: "100%", height: "100%" },
165
166
  onLoadStart: () => m(!0),
166
- onCanPlay: () => m(!1),
167
+ onCanPlay: () => {
168
+ m(!1), T(!1);
169
+ },
167
170
  onWaiting: () => m(!0),
168
171
  onPlay: () => b(!1),
169
172
  onEnded: () => {
@@ -176,18 +179,20 @@ const be = ({
176
179
  {
177
180
  ref: h,
178
181
  src: a,
179
- poster: i,
182
+ poster: r,
180
183
  loop: k,
181
- muted: C,
184
+ muted: D,
182
185
  playsInline: !0,
183
186
  style: { width: "100%", height: "100%" },
184
187
  onLoadStart: () => m(!0),
185
- onCanPlay: () => m(!1),
188
+ onCanPlay: () => {
189
+ m(!1), T(!1);
190
+ },
186
191
  onWaiting: () => m(!0),
187
192
  onPlay: () => b(!1),
188
193
  onLoadedMetadata: () => {
189
194
  const e = h.current;
190
- e instanceof HTMLVideoElement && e.videoWidth && e.videoHeight && q(e.videoWidth / e.videoHeight);
195
+ e instanceof HTMLVideoElement && e.videoWidth && e.videoHeight && K(e.videoWidth / e.videoHeight);
191
196
  },
192
197
  onEnded: () => {
193
198
  k || (o(!1), g(0));
@@ -195,14 +200,14 @@ const be = ({
195
200
  children: /* @__PURE__ */ n("track", { kind: "captions" })
196
201
  }
197
202
  ) }),
198
- K && !I && /* @__PURE__ */ n("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ n(
199
- ie,
203
+ B && !I && /* @__PURE__ */ n("div", { className: "absolute inset-0 z-10 flex items-center justify-center", children: /* @__PURE__ */ n(
204
+ se,
200
205
  {
201
206
  className: "size-8 animate-spin text-white/80",
202
207
  weight: "bold"
203
208
  }
204
209
  ) }),
205
- I && !v && /* @__PURE__ */ n(
210
+ I && !p && /* @__PURE__ */ n(
206
211
  "div",
207
212
  {
208
213
  className: "absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35",
@@ -210,15 +215,15 @@ const be = ({
210
215
  tabIndex: 0,
211
216
  "aria-label": "Play preview",
212
217
  onClick: (e) => {
213
- e.stopPropagation(), O();
218
+ e.stopPropagation(), W();
214
219
  },
215
220
  onKeyDown: (e) => {
216
- e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), O());
221
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), W());
217
222
  },
218
- children: /* @__PURE__ */ n("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ n(W, { className: "size-9 translate-x-0.5", weight: "fill" }) })
223
+ children: /* @__PURE__ */ n("span", { className: "flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm", children: /* @__PURE__ */ n($, { className: "size-9 translate-x-0.5", weight: "fill" }) })
219
224
  }
220
225
  ),
221
- X && !v && /* @__PURE__ */ n("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__ */ n(
226
+ q && !p && /* @__PURE__ */ n("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__ */ n(
222
227
  "div",
223
228
  {
224
229
  role: "slider",
@@ -233,7 +238,7 @@ const be = ({
233
238
  onTouchStart: E,
234
239
  onClick: (e) => e.stopPropagation(),
235
240
  onKeyDown: (e) => {
236
- e.key === "ArrowRight" && l(Math.min(1, w + 0.05)), e.key === "ArrowLeft" && l(Math.max(0, w - 0.05));
241
+ e.key === "ArrowRight" && c(Math.min(1, w + 0.05)), e.key === "ArrowLeft" && c(Math.max(0, w - 0.05));
237
242
  },
238
243
  children: /* @__PURE__ */ n("div", { className: "w-full overflow-hidden rounded-full bg-white/30 h-1", children: /* @__PURE__ */ n(
239
244
  "div",
@@ -244,7 +249,7 @@ const be = ({
244
249
  ) })
245
250
  }
246
251
  ) }),
247
- v && /* @__PURE__ */ L("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: [
252
+ p && /* @__PURE__ */ z("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: [
248
253
  /* @__PURE__ */ n(
249
254
  "button",
250
255
  {
@@ -254,10 +259,10 @@ const be = ({
254
259
  },
255
260
  className: "shrink-0 text-white",
256
261
  "aria-label": d ? "Pause" : "Play",
257
- children: d ? /* @__PURE__ */ n(oe, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ n(W, { className: "size-5 translate-x-px", weight: "fill" })
262
+ children: d ? /* @__PURE__ */ n(le, { className: "size-5", weight: "fill" }) : /* @__PURE__ */ n($, { className: "size-5 translate-x-px", weight: "fill" })
258
263
  }
259
264
  ),
260
- /* @__PURE__ */ L(
265
+ /* @__PURE__ */ z(
261
266
  "div",
262
267
  {
263
268
  role: "slider",
@@ -271,16 +276,16 @@ const be = ({
271
276
  onMouseDown: E,
272
277
  onTouchStart: E,
273
278
  onClick: (e) => e.stopPropagation(),
274
- onMouseEnter: () => j(!0),
275
- onMouseLeave: () => j(!1),
279
+ onMouseEnter: () => O(!0),
280
+ onMouseLeave: () => O(!1),
276
281
  onKeyDown: (e) => {
277
- e.key === "ArrowRight" && l(Math.min(1, w + 0.05)), e.key === "ArrowLeft" && l(Math.max(0, w - 0.05));
282
+ e.key === "ArrowRight" && c(Math.min(1, w + 0.05)), e.key === "ArrowLeft" && c(Math.max(0, w - 0.05));
278
283
  },
279
284
  children: [
280
285
  /* @__PURE__ */ n(
281
286
  "div",
282
287
  {
283
- className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${S || f ? "h-1.5" : "h-1"}`,
288
+ className: `w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${j || f ? "h-1.5" : "h-1"}`,
284
289
  children: /* @__PURE__ */ n(
285
290
  "div",
286
291
  {
@@ -293,7 +298,7 @@ const be = ({
293
298
  /* @__PURE__ */ n(
294
299
  "div",
295
300
  {
296
- className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${S || f ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
301
+ className: `absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${j || f ? "scale-100 opacity-100" : "scale-0 opacity-0"}`,
297
302
  style: { left: `${y}%` }
298
303
  }
299
304
  )
@@ -306,8 +311,8 @@ const be = ({
306
311
  );
307
312
  };
308
313
  export {
309
- be as M,
310
- H as g,
311
- me as r
314
+ xe as M,
315
+ _ as g,
316
+ ve as r
312
317
  };
313
- //# sourceMappingURL=MediaPlayer-DXz4IBLx.js.map
318
+ //# sourceMappingURL=MediaPlayer-Bf-xPB8Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MediaPlayer-Bf-xPB8Z.js","sources":["../src/components/LockedAttachment/utils/mimeType.ts","../src/components/LockedAttachment/utils/icons.ts","../src/components/LockedAttachment/components/MediaPlayer.tsx"],"sourcesContent":["export type AttachmentSourceType = 'image' | 'audio' | 'video' | 'document'\n\nexport type DocumentIconType =\n | 'pdf'\n | 'doc'\n | 'xls'\n | 'csv'\n | 'ppt'\n | 'zip'\n | 'text'\n | 'markdown'\n | 'generic'\n\nconst DOCUMENT_ICON_PATTERNS: Array<[RegExp, DocumentIconType]> = [\n [/pdf/, 'pdf'],\n [/wordprocessingml|msword|\\.doc/, 'doc'],\n [/spreadsheetml|ms-excel|\\.xls/, 'xls'],\n [/csv/, 'csv'],\n [/presentationml|ms-powerpoint|\\.ppt/, 'ppt'],\n [/zip|x-rar|x-7z|x-tar|x-gzip/, 'zip'],\n [/plain|rtf/, 'text'],\n [/markdown/, 'markdown'],\n]\n\nexport function getSourceType(mimeType: string): AttachmentSourceType {\n if (mimeType.startsWith('video/')) return 'video'\n if (mimeType.startsWith('audio/')) return 'audio'\n if (mimeType.startsWith('image/')) return 'image'\n return 'document'\n}\n\nexport function getDocumentIconType(mimeType: string): DocumentIconType {\n const match = DOCUMENT_ICON_PATTERNS.find(([pattern]) =>\n pattern.test(mimeType)\n )\n return match ? match[1] : 'generic'\n}\n","import {\n FileIcon,\n FileCsvIcon,\n FileDocIcon,\n FileMdIcon,\n FilePdfIcon,\n FilePptIcon,\n FileTextIcon,\n FileXlsIcon,\n FileZipIcon,\n ImageIcon,\n SpeakerHighIcon,\n VideoCameraIcon,\n IconProps,\n} from '@phosphor-icons/react'\nimport React from 'react'\n\nimport { getDocumentIconType, getSourceType } from './mimeType'\nimport type { AttachmentSourceType } from './mimeType'\n\nexport const MEDIA_TYPE_ICON: Record<AttachmentSourceType, React.ElementType> =\n {\n video: VideoCameraIcon,\n audio: SpeakerHighIcon,\n image: ImageIcon,\n document: FileIcon,\n }\n\nconst DOCUMENT_ICON_COMPONENT = {\n pdf: FilePdfIcon,\n doc: FileDocIcon,\n xls: FileXlsIcon,\n csv: FileCsvIcon,\n ppt: FilePptIcon,\n zip: FileZipIcon,\n text: FileTextIcon,\n markdown: FileMdIcon,\n generic: FileIcon,\n} as const\n\nexport function getTypeIcon(mimeType: string): React.ElementType {\n const sourceType = getSourceType(mimeType)\n if (sourceType !== 'document') return MEDIA_TYPE_ICON[sourceType]\n return DOCUMENT_ICON_COMPONENT[getDocumentIconType(mimeType)]\n}\n\n/** Use instead of `<TypeIcon />` where TypeIcon = getTypeIcon(mime) to satisfy react-hooks/static-components. */\nexport function renderTypeIcon(\n mimeType: string,\n props: IconProps\n): React.ReactElement {\n return React.createElement(getTypeIcon(mimeType), props)\n}\n","import { CircleNotchIcon, PauseIcon, PlayIcon } from '@phosphor-icons/react'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport { isDevBuild } from '../../../utils/isDevBuild'\nimport { renderTypeIcon } from '../utils/icons'\nimport { getSourceType, type AttachmentSourceType } from '../utils/mimeType'\n\nconst getPlayerBg = (sourceType: AttachmentSourceType, poster?: string) =>\n sourceType === 'audio' && !poster ? 'bg-black/5' : 'bg-black'\n\nfunction getClientXFromEvent(\n e: MouseEvent | TouchEvent | React.MouseEvent | React.TouchEvent\n): number {\n if ('touches' in e) {\n return e.touches[0]?.clientX ?? e.changedTouches[0]?.clientX ?? 0\n }\n return e.clientX\n}\n\nexport interface MediaPlayerProps {\n source: string\n mimeType: string\n poster?: string\n autoPlay?: boolean\n /** Controlled playing state. When provided, syncs to internal play/pause. */\n playing?: boolean\n loop?: boolean\n controls?: boolean\n showProgress?: boolean\n onContainerClick?: () => void\n /** When true, requests muted playback (helps autoplay policies on video). */\n muted?: boolean\n}\n\nconst MediaPlayer: React.FC<MediaPlayerProps> = ({\n source,\n mimeType,\n poster,\n autoPlay = false,\n playing: playingProp,\n loop = false,\n controls = true,\n showProgress = false,\n onContainerClick,\n muted = false,\n}) => {\n const sourceType = getSourceType(mimeType)\n const [playing, setPlaying] = useState(autoPlay)\n\n // Sync controlled playing prop to internal state\n const prevPlayingPropRef = useRef(playingProp)\n useEffect(() => {\n if (\n playingProp !== undefined &&\n playingProp !== prevPlayingPropRef.current\n ) {\n prevPlayingPropRef.current = playingProp\n setPlaying(playingProp)\n }\n }, [playingProp])\n const [played, setPlayed] = useState(0)\n const [seeking, setSeeking] = useState(false)\n const [scrubberHovered, setScrubberHovered] = useState(false)\n const [videoAspect, setVideoAspect] = useState<number | null>(null)\n const [buffering, setBuffering] = useState(false)\n /** True until the first canPlay fires for the current source — hides controls/spinner behind poster. */\n const [initialLoad, setInitialLoad] = useState(true)\n /** Set when autoplay/play() was rejected so user can start via gesture (no controls UI). */\n const [manualPlayRequired, setManualPlayRequired] = useState(false)\n const playerRef = useRef<HTMLMediaElement>(null)\n const trackRef = useRef<HTMLDivElement>(null)\n const rafRef = useRef<number | null>(null)\n\n useEffect(() => {\n setManualPlayRequired(false)\n setInitialLoad(true)\n }, [source])\n\n useEffect(() => {\n if (!playing) {\n if (rafRef.current !== null) {\n cancelAnimationFrame(rafRef.current)\n rafRef.current = null\n }\n return\n }\n const tick = () => {\n const el = playerRef.current\n if (el && el.duration && !seeking) setPlayed(el.currentTime / el.duration)\n rafRef.current = requestAnimationFrame(tick)\n }\n rafRef.current = requestAnimationFrame(tick)\n return () => {\n if (rafRef.current !== null) cancelAnimationFrame(rafRef.current)\n }\n }, [playing, seeking])\n\n // ReactPlayer v3 uses native HTML media elements and does not support a\n // declarative `playing` prop — playback must be driven imperatively.\n useEffect(() => {\n const el = playerRef.current\n if (!el) return\n if (playing) {\n void el.play().catch((err) => {\n setPlaying(false)\n setManualPlayRequired(true)\n if (isDevBuild()) {\n console.debug('[MediaPlayer] play() failed', err)\n }\n })\n } else {\n el.pause()\n }\n }, [playing])\n\n const startPlaybackFromGesture = useCallback(() => {\n setManualPlayRequired(false)\n setPlaying(true)\n }, [])\n\n const getFraction = useCallback(\n (e: MouseEvent | TouchEvent | React.MouseEvent | React.TouchEvent) => {\n const track = trackRef.current\n if (!track) return 0\n const rect = track.getBoundingClientRect()\n return Math.max(\n 0,\n Math.min(1, (getClientXFromEvent(e) - rect.left) / rect.width)\n )\n },\n []\n )\n\n const seekTo = useCallback((fraction: number) => {\n const el = playerRef.current\n if (el && el.duration) el.currentTime = fraction * el.duration\n }, [])\n\n const handleTrackPointerDown = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n e.stopPropagation()\n setSeeking(true)\n const fraction = getFraction(e)\n setPlayed(fraction)\n seekTo(fraction)\n }\n\n useEffect(() => {\n if (!seeking) return\n const onMove = (e: MouseEvent | TouchEvent) => setPlayed(getFraction(e))\n const onUp = (e: MouseEvent | TouchEvent) => {\n setSeeking(false)\n seekTo(getFraction(e))\n }\n window.addEventListener('mousemove', onMove)\n window.addEventListener('mouseup', onUp)\n window.addEventListener('touchmove', onMove, { passive: true })\n window.addEventListener('touchend', onUp)\n return () => {\n window.removeEventListener('mousemove', onMove)\n window.removeEventListener('mouseup', onUp)\n window.removeEventListener('touchmove', onMove)\n window.removeEventListener('touchend', onUp)\n }\n }, [seeking, getFraction, seekTo])\n\n // Use natural aspect ratio once metadata loads, fall back to 16:9 before then.\n const aspectStyle = videoAspect\n ? { aspectRatio: String(videoAspect) }\n : undefined\n const aspectClass = !videoAspect ? ' aspect-video' : ''\n const scrubberPercent = Math.round(played * 100)\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n className={`relative cursor-pointer overflow-hidden ${getPlayerBg(sourceType, poster)}${aspectClass}`}\n style={aspectStyle}\n onClick={() => {\n if (manualPlayRequired) return\n if (onContainerClick) {\n onContainerClick()\n return\n }\n if (controls) setPlaying((p) => !p)\n }}\n onKeyDown={(e) => {\n if (e.key !== 'Enter' && e.key !== ' ') return\n e.preventDefault()\n if (manualPlayRequired) return\n if (onContainerClick) {\n onContainerClick()\n return\n }\n if (controls) setPlaying((p) => !p)\n }}\n >\n {poster && (\n <img\n src={poster}\n alt=\"\"\n className=\"absolute inset-0 h-full w-full object-cover\"\n />\n )}\n {!poster && (\n <div className=\"absolute inset-0 flex items-center justify-center\">\n {renderTypeIcon(mimeType, {\n className: 'size-12 text-black/20',\n weight: 'regular',\n })}\n </div>\n )}\n {initialLoad && poster && (\n <div className=\"absolute inset-0 z-20\">\n <img src={poster} alt=\"\" className=\"h-full w-full object-cover\" />\n </div>\n )}\n <div className=\"absolute inset-0\">\n {sourceType === 'audio' ? (\n <audio\n ref={playerRef as React.RefObject<HTMLAudioElement>}\n src={source}\n loop={loop}\n muted={muted}\n style={{ width: '100%', height: '100%' }}\n onLoadStart={() => setBuffering(true)}\n onCanPlay={() => { setBuffering(false); setInitialLoad(false) }}\n onWaiting={() => setBuffering(true)}\n onPlay={() => setManualPlayRequired(false)}\n onEnded={() => {\n if (!loop) {\n setPlaying(false)\n setPlayed(0)\n }\n }}\n >\n <track kind=\"captions\" />\n </audio>\n ) : (\n <video\n ref={playerRef as React.RefObject<HTMLVideoElement>}\n src={source}\n poster={poster}\n loop={loop}\n muted={muted}\n playsInline\n style={{ width: '100%', height: '100%' }}\n onLoadStart={() => setBuffering(true)}\n onCanPlay={() => { setBuffering(false); setInitialLoad(false) }}\n onWaiting={() => setBuffering(true)}\n onPlay={() => setManualPlayRequired(false)}\n onLoadedMetadata={() => {\n const el = playerRef.current\n if (el instanceof HTMLVideoElement && el.videoWidth && el.videoHeight) {\n setVideoAspect(el.videoWidth / el.videoHeight)\n }\n }}\n onEnded={() => {\n if (!loop) {\n setPlaying(false)\n setPlayed(0)\n }\n }}\n >\n <track kind=\"captions\" />\n </video>\n )}\n </div>\n\n {buffering && !manualPlayRequired && (\n <div className=\"absolute inset-0 z-10 flex items-center justify-center\">\n <CircleNotchIcon\n className=\"size-8 animate-spin text-white/80\"\n weight=\"bold\"\n />\n </div>\n )}\n\n {manualPlayRequired && !controls && (\n <div\n className=\"absolute inset-0 z-30 flex cursor-pointer items-center justify-center bg-black/35\"\n role=\"button\"\n tabIndex={0}\n aria-label=\"Play preview\"\n onClick={(e) => {\n e.stopPropagation()\n startPlaybackFromGesture()\n }}\n onKeyDown={(e) => {\n if (e.key !== 'Enter' && e.key !== ' ') return\n e.preventDefault()\n e.stopPropagation()\n startPlaybackFromGesture()\n }}\n >\n <span className=\"flex size-16 items-center justify-center rounded-full bg-white/20 text-white backdrop-blur-sm\">\n <PlayIcon className=\"size-9 translate-x-0.5\" weight=\"fill\" />\n </span>\n </div>\n )}\n\n {showProgress && !controls && (\n <div className=\"absolute inset-x-0 bottom-0 px-3 pb-2.5 pt-6 bg-gradient-to-t from-black/40 to-transparent\">\n <div\n role=\"slider\"\n aria-label=\"Playback position\"\n aria-valuenow={scrubberPercent}\n aria-valuemin={0}\n aria-valuemax={100}\n tabIndex={0}\n ref={trackRef}\n className=\"relative flex h-4 w-full cursor-pointer items-center\"\n onMouseDown={handleTrackPointerDown}\n onTouchStart={handleTrackPointerDown}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => {\n if (e.key === 'ArrowRight') seekTo(Math.min(1, played + 0.05))\n if (e.key === 'ArrowLeft') seekTo(Math.max(0, played - 0.05))\n }}\n >\n <div className=\"w-full overflow-hidden rounded-full bg-white/30 h-1\">\n <div\n className=\"h-full rounded-full bg-white\"\n style={{ width: `${scrubberPercent}%` }}\n />\n </div>\n </div>\n </div>\n )}\n\n {controls && (\n <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\">\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n setPlaying((p) => !p)\n }}\n className=\"shrink-0 text-white\"\n aria-label={playing ? 'Pause' : 'Play'}\n >\n {playing ? (\n <PauseIcon className=\"size-5\" weight=\"fill\" />\n ) : (\n <PlayIcon className=\"size-5 translate-x-px\" weight=\"fill\" />\n )}\n </button>\n\n <div\n role=\"slider\"\n aria-label=\"Playback position\"\n aria-valuenow={scrubberPercent}\n aria-valuemin={0}\n aria-valuemax={100}\n tabIndex={0}\n ref={trackRef}\n className=\"relative flex h-4 w-full cursor-pointer items-center\"\n onMouseDown={handleTrackPointerDown}\n onTouchStart={handleTrackPointerDown}\n onClick={(e) => e.stopPropagation()}\n onMouseEnter={() => setScrubberHovered(true)}\n onMouseLeave={() => setScrubberHovered(false)}\n onKeyDown={(e) => {\n if (e.key === 'ArrowRight') seekTo(Math.min(1, played + 0.05))\n if (e.key === 'ArrowLeft') seekTo(Math.max(0, played - 0.05))\n }}\n >\n <div\n className={`w-full overflow-hidden rounded-full bg-white/30 transition-all duration-200 ${scrubberHovered || seeking ? 'h-1.5' : 'h-1'}`}\n >\n <div\n className=\"h-full rounded-full bg-white\"\n style={{ width: `${scrubberPercent}%` }}\n />\n </div>\n <div\n className={`absolute size-3 -translate-x-1/2 rounded-full bg-white shadow transition-[opacity,transform] duration-200 ${scrubberHovered || seeking ? 'scale-100 opacity-100' : 'scale-0 opacity-0'}`}\n style={{ left: `${scrubberPercent}%` }}\n />\n </div>\n </div>\n )}\n </div>\n )\n}\n\nexport default MediaPlayer\n"],"names":["DOCUMENT_ICON_PATTERNS","getSourceType","mimeType","getDocumentIconType","match","pattern","MEDIA_TYPE_ICON","VideoCameraIcon","SpeakerHighIcon","ImageIcon","FileIcon","DOCUMENT_ICON_COMPONENT","FilePdfIcon","FileDocIcon","FileXlsIcon","FileCsvIcon","FilePptIcon","FileZipIcon","FileTextIcon","FileMdIcon","getTypeIcon","sourceType","renderTypeIcon","props","React","getPlayerBg","poster","getClientXFromEvent","e","_a","_b","MediaPlayer","source","autoPlay","playingProp","loop","controls","showProgress","onContainerClick","muted","playing","setPlaying","useState","prevPlayingPropRef","useRef","useEffect","played","setPlayed","seeking","setSeeking","scrubberHovered","setScrubberHovered","videoAspect","setVideoAspect","buffering","setBuffering","initialLoad","setInitialLoad","manualPlayRequired","setManualPlayRequired","playerRef","trackRef","rafRef","tick","el","err","startPlaybackFromGesture","useCallback","getFraction","track","rect","seekTo","fraction","handleTrackPointerDown","onMove","onUp","aspectStyle","aspectClass","scrubberPercent","jsxs","p","jsx","CircleNotchIcon","PlayIcon","PauseIcon"],"mappings":";;;AAaA,MAAMA,KAA4D;AAAA,EAChE,CAAC,OAAO,KAAK;AAAA,EAC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+ import { jsxs as o, jsx as e, Fragment as g } from "react/jsx-runtime";
2
+ import { CheckCircleIcon as U, LockOpenIcon as I, DownloadSimpleIcon as M, LockSimpleIcon as O } from "@phosphor-icons/react";
3
+ import { useState as b, useEffect as S } from "react";
4
+ import { g as R, r as k, M as A } from "./MediaPlayer-Bf-xPB8Z.js";
5
+ const w = (s) => s === "paid" ? I : O, j = (s) => {
6
+ const { icon: t, loading: a } = s;
7
+ return /* @__PURE__ */ e("div", { className: "absolute inset-0 bg-black/30", children: /* @__PURE__ */ e("div", { className: "absolute left-3 top-3 flex size-8 items-center justify-center rounded-full bg-black/60", children: a ? /* @__PURE__ */ o("span", { className: "flex items-center gap-[2px]", children: [
8
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce [animation-delay:-0.3s]" }),
9
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce [animation-delay:-0.15s]" }),
10
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce" })
11
+ ] }) : /* @__PURE__ */ e(t, { className: "size-4 text-white", weight: "fill" }) }) });
12
+ }, D = (s) => {
13
+ const { thumbnail: t, mimeType: a, LockIcon: i, loading: n } = s;
14
+ return /* @__PURE__ */ o("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: [
15
+ t ? /* @__PURE__ */ e(
16
+ "img",
17
+ {
18
+ src: t,
19
+ alt: "",
20
+ className: "absolute inset-0 h-full w-full object-cover"
21
+ }
22
+ ) : /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: k(a, {
23
+ className: "size-12 text-black/20",
24
+ weight: "regular"
25
+ }) }),
26
+ /* @__PURE__ */ e(j, { icon: i, loading: n })
27
+ ] });
28
+ }, E = (s) => {
29
+ const { source: t, thumbnail: a, mimeType: i, title: n, paymentStatus: l, isLocked: c, loading: d } = s, [m, r] = b(!1);
30
+ return S(() => {
31
+ r(!1);
32
+ }, [t]), c ? /* @__PURE__ */ e(
33
+ D,
34
+ {
35
+ thumbnail: a,
36
+ mimeType: i,
37
+ LockIcon: w(l),
38
+ loading: d
39
+ }
40
+ ) : /* @__PURE__ */ e("div", { className: "relative overflow-hidden bg-black/5", children: /* @__PURE__ */ e(
41
+ "img",
42
+ {
43
+ src: t,
44
+ alt: n,
45
+ className: `block w-full transition-opacity duration-300 ${m ? "opacity-100" : "opacity-0"}`,
46
+ onLoad: () => r(!0)
47
+ }
48
+ ) });
49
+ }, F = (s) => {
50
+ const { thumbnail: t, mimeType: a, paymentStatus: i, isLocked: n, loading: l } = s;
51
+ return /* @__PURE__ */ o("div", { className: "relative aspect-video overflow-hidden bg-black/5", children: [
52
+ t ? /* @__PURE__ */ e(
53
+ "img",
54
+ {
55
+ src: t,
56
+ alt: "",
57
+ className: "absolute inset-0 h-full w-full object-cover"
58
+ }
59
+ ) : /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: k(a, {
60
+ className: "size-12 text-black/20",
61
+ weight: "regular"
62
+ }) }),
63
+ n && /* @__PURE__ */ e(j, { icon: w(i), loading: l })
64
+ ] });
65
+ }, V = (s) => {
66
+ const { source: t, thumbnail: a, mimeType: i, paymentStatus: n, isLocked: l, loading: c } = s;
67
+ return l ? /* @__PURE__ */ e(
68
+ D,
69
+ {
70
+ thumbnail: a,
71
+ mimeType: i,
72
+ LockIcon: w(n),
73
+ loading: c
74
+ }
75
+ ) : /* @__PURE__ */ e(A, { source: t, mimeType: i, poster: a });
76
+ }, z = () => /* @__PURE__ */ o("span", { className: "flex items-center gap-1", children: [
77
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce [animation-delay:-0.3s]" }),
78
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce [animation-delay:-0.15s]" }),
79
+ /* @__PURE__ */ e("span", { className: "size-1 rounded-full bg-white animate-bounce" })
80
+ ] }), $ = (s) => {
81
+ const { isLocked: t, unlockLoading: a, downloadLoading: i, paymentStatus: n, source: l, onUnlock: c, onDownload: d } = s, m = w(n);
82
+ return t && c ? /* @__PURE__ */ e(
83
+ "button",
84
+ {
85
+ type: "button",
86
+ onClick: c,
87
+ disabled: a,
88
+ className: "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 disabled:opacity-70",
89
+ children: a ? /* @__PURE__ */ e(z, {}) : /* @__PURE__ */ o(g, { children: [
90
+ n === "paid" ? /* @__PURE__ */ e(I, { className: "size-4", weight: "fill" }) : /* @__PURE__ */ e(m, { className: "size-4", weight: "fill" }),
91
+ n === "paid" ? "Open" : "Unlock"
92
+ ] })
93
+ }
94
+ ) : !t && d && l ? /* @__PURE__ */ e(
95
+ "button",
96
+ {
97
+ type: "button",
98
+ onClick: d,
99
+ disabled: i,
100
+ className: "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 disabled:opacity-70",
101
+ children: i ? /* @__PURE__ */ e(z, {}) : /* @__PURE__ */ o(g, { children: [
102
+ /* @__PURE__ */ e(M, { className: "size-4", weight: "bold" }),
103
+ "Download"
104
+ ] })
105
+ }
106
+ ) : null;
107
+ }, J = (s) => {
108
+ const {
109
+ title: t,
110
+ amountText: a,
111
+ thumbnail: i,
112
+ source: n,
113
+ mimeType: l = "application/octet-stream",
114
+ detail: c,
115
+ onUnlock: d,
116
+ onDownload: m,
117
+ paymentStatus: r
118
+ } = s, [u, y] = b(n), [f, N] = b(!1), [T, v] = b(!1);
119
+ S(() => {
120
+ n !== void 0 && y(n);
121
+ }, [n]);
122
+ const p = u === void 0, L = R(l), P = async () => {
123
+ if (d) {
124
+ N(!0);
125
+ try {
126
+ const x = await d();
127
+ y(x.source);
128
+ } catch {
129
+ } finally {
130
+ N(!1);
131
+ }
132
+ }
133
+ }, C = async () => {
134
+ if (m) {
135
+ v(!0);
136
+ try {
137
+ await m();
138
+ } catch {
139
+ } finally {
140
+ v(!1);
141
+ }
142
+ }
143
+ };
144
+ let h;
145
+ return L === "image" ? h = /* @__PURE__ */ e(
146
+ E,
147
+ {
148
+ source: u,
149
+ thumbnail: i,
150
+ mimeType: l,
151
+ title: t,
152
+ paymentStatus: r,
153
+ isLocked: p,
154
+ loading: f
155
+ }
156
+ ) : L === "document" ? h = /* @__PURE__ */ e(
157
+ F,
158
+ {
159
+ thumbnail: i,
160
+ mimeType: l,
161
+ paymentStatus: r,
162
+ isLocked: p,
163
+ loading: f
164
+ }
165
+ ) : h = /* @__PURE__ */ e(
166
+ V,
167
+ {
168
+ source: u,
169
+ thumbnail: i,
170
+ mimeType: l,
171
+ paymentStatus: r,
172
+ isLocked: p,
173
+ loading: f
174
+ }
175
+ ), /* @__PURE__ */ o("div", { className: "w-[280px] select-none overflow-hidden rounded-3xl bg-white shadow-card", children: [
176
+ h,
177
+ /* @__PURE__ */ o("div", { className: "px-4 pb-3 pt-3", children: [
178
+ /* @__PURE__ */ e("p", { className: "mb-1.5 truncate text-base font-medium text-black", children: t }),
179
+ /* @__PURE__ */ o("div", { className: "flex items-center gap-1", children: [
180
+ k(l, {
181
+ className: "size-5 shrink-0 text-black/55",
182
+ weight: "regular"
183
+ }),
184
+ c && /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: c }),
185
+ r === "paid" ? /* @__PURE__ */ o(g, { children: [
186
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: "•" }),
187
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-[#008236]", children: "Purchased" }),
188
+ /* @__PURE__ */ e(
189
+ U,
190
+ {
191
+ className: "size-4 text-[#008236]",
192
+ weight: "bold"
193
+ }
194
+ )
195
+ ] }) : a && /* @__PURE__ */ o(g, { children: [
196
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: "•" }),
197
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-black/55", children: a })
198
+ ] })
199
+ ] }),
200
+ /* @__PURE__ */ e(
201
+ $,
202
+ {
203
+ isLocked: p,
204
+ unlockLoading: f,
205
+ downloadLoading: T,
206
+ paymentStatus: r,
207
+ source: u,
208
+ onUnlock: d ? P : void 0,
209
+ onDownload: m ? C : void 0
210
+ }
211
+ )
212
+ ] })
213
+ ] });
214
+ };
215
+ export {
216
+ J as default
217
+ };
218
+ //# sourceMappingURL=Visitor-C4WqnN8H.js.map