@linktr.ee/messaging-react 3.8.1 → 3.9.0-rc-1783407048

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 (87) hide show
  1. package/dist/Card-D8yiJ8Uw.cjs +2 -0
  2. package/dist/Card-D8yiJ8Uw.cjs.map +1 -0
  3. package/dist/Card-DSG-wR8t.js +96 -0
  4. package/dist/Card-DSG-wR8t.js.map +1 -0
  5. package/dist/Card-DVfSiq9b.cjs +2 -0
  6. package/dist/Card-DVfSiq9b.cjs.map +1 -0
  7. package/dist/Card-DX9nBx1S.js +221 -0
  8. package/dist/Card-DX9nBx1S.js.map +1 -0
  9. package/dist/Card-iKTcn1wg.cjs +2 -0
  10. package/dist/Card-iKTcn1wg.cjs.map +1 -0
  11. package/dist/Card-qDLtjK6u.js +108 -0
  12. package/dist/Card-qDLtjK6u.js.map +1 -0
  13. package/dist/PurchaseStatusBadge-CJH4S-8Z.js +36 -0
  14. package/dist/PurchaseStatusBadge-CJH4S-8Z.js.map +1 -0
  15. package/dist/PurchaseStatusBadge-UjDzZhLj.cjs +2 -0
  16. package/dist/PurchaseStatusBadge-UjDzZhLj.cjs.map +1 -0
  17. package/dist/TextShell-BiqF2UB0.js +32 -0
  18. package/dist/TextShell-BiqF2UB0.js.map +1 -0
  19. package/dist/TextShell-Bnzh0T75.cjs +2 -0
  20. package/dist/TextShell-Bnzh0T75.cjs.map +1 -0
  21. package/dist/assets/index.css +1 -1
  22. package/dist/{index-BCgRoF_u.js → index-CZTUyiPe.js} +1154 -1113
  23. package/dist/index-CZTUyiPe.js.map +1 -0
  24. package/dist/index-DwUOvMxg.cjs +2 -0
  25. package/dist/index-DwUOvMxg.cjs.map +1 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +98 -55
  28. package/dist/index.js +1 -1
  29. package/dist/testing.d.ts +1 -0
  30. package/dist/usePreviewToggle-BG-pfsgP.js +323 -0
  31. package/dist/usePreviewToggle-BG-pfsgP.js.map +1 -0
  32. package/dist/usePreviewToggle-DXQT07ws.cjs +2 -0
  33. package/dist/usePreviewToggle-DXQT07ws.cjs.map +1 -0
  34. package/package.json +2 -2
  35. package/src/components/CustomMessage/CustomMessage.stories.tsx +54 -1
  36. package/src/components/CustomMessage/MessageTag.tsx +8 -0
  37. package/src/components/CustomMessage/index.tsx +61 -22
  38. package/src/components/LockedAttachment/LockedAttachment.stories.tsx +410 -333
  39. package/src/components/LockedAttachment/LockedAttachment.test.tsx +104 -0
  40. package/src/components/LockedAttachment/components/Composer/Card.tsx +97 -120
  41. package/src/components/LockedAttachment/components/Media/Card.tsx +237 -0
  42. package/src/components/LockedAttachment/components/Text/Card.tsx +177 -0
  43. package/src/components/LockedAttachment/components/_shared/CardBody.tsx +3 -3
  44. package/src/components/LockedAttachment/components/_shared/CardThumbnail.tsx +92 -0
  45. package/src/components/LockedAttachment/components/_shared/GalleryThumbnail.tsx +11 -33
  46. package/src/components/LockedAttachment/components/_shared/LoadingDots.tsx +36 -0
  47. package/src/components/LockedAttachment/components/_shared/LockBadge.tsx +21 -11
  48. package/src/components/LockedAttachment/components/_shared/{LockedCardShell.tsx → MediaShell.tsx} +5 -5
  49. package/src/components/LockedAttachment/components/_shared/PreviewToggle.tsx +58 -0
  50. package/src/components/LockedAttachment/components/_shared/PriceLockRow.tsx +21 -0
  51. package/src/components/LockedAttachment/components/_shared/PurchaseStatusBadge.tsx +87 -0
  52. package/src/components/LockedAttachment/components/_shared/{LockedThumbnail.tsx → SingleThumbnail.tsx} +5 -5
  53. package/src/components/LockedAttachment/components/_shared/SkeletonTextLines.tsx +39 -0
  54. package/src/components/LockedAttachment/components/_shared/TextShell.tsx +19 -0
  55. package/src/components/LockedAttachment/components/_shared/usePreviewToggle.test.ts +67 -0
  56. package/src/components/LockedAttachment/components/_shared/usePreviewToggle.ts +89 -0
  57. package/src/components/LockedAttachment/components/_shared/useReceivedSource.ts +83 -0
  58. package/src/components/LockedAttachment/index.tsx +17 -28
  59. package/src/components/LockedAttachment/types.ts +28 -4
  60. package/src/index.ts +2 -5
  61. package/src/stream-custom-data.ts +1 -0
  62. package/src/styles.css +5 -0
  63. package/dist/Card-BRvcFjsq.js +0 -132
  64. package/dist/Card-BRvcFjsq.js.map +0 -1
  65. package/dist/Card-BuXkok0A.cjs +0 -2
  66. package/dist/Card-BuXkok0A.cjs.map +0 -1
  67. package/dist/Card-CvNHv3me.js +0 -107
  68. package/dist/Card-CvNHv3me.js.map +0 -1
  69. package/dist/Card-DOSuQdnk.cjs +0 -2
  70. package/dist/Card-DOSuQdnk.cjs.map +0 -1
  71. package/dist/Card-NnQw99XE.cjs +0 -2
  72. package/dist/Card-NnQw99XE.cjs.map +0 -1
  73. package/dist/Card-jGOcSN1O.js +0 -163
  74. package/dist/Card-jGOcSN1O.js.map +0 -1
  75. package/dist/LockedThumbnail-EsjaAqLR.js +0 -220
  76. package/dist/LockedThumbnail-EsjaAqLR.js.map +0 -1
  77. package/dist/LockedThumbnail-uAauUd5c.cjs +0 -2
  78. package/dist/LockedThumbnail-uAauUd5c.cjs.map +0 -1
  79. package/dist/index-BCgRoF_u.js.map +0 -1
  80. package/dist/index-DRurVQ0-.cjs +0 -2
  81. package/dist/index-DRurVQ0-.cjs.map +0 -1
  82. package/src/components/LockedAttachment/components/Composer/index.ts +0 -2
  83. package/src/components/LockedAttachment/components/Received/Card.tsx +0 -191
  84. package/src/components/LockedAttachment/components/Received/index.ts +0 -2
  85. package/src/components/LockedAttachment/components/Sent/Card.tsx +0 -177
  86. package/src/components/LockedAttachment/components/Sent/index.ts +0 -2
  87. /package/src/components/LockedAttachment/components/{Received → Media}/CardActions.tsx +0 -0
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("@phosphor-icons/react"),T=require("react"),s=require("./usePreviewToggle-DXQT07ws.cjs"),u=require("./TextShell-Bnzh0T75.cjs"),z=({text:t,amountText:i,placeholderAmountText:n,onDismiss:r})=>e.jsxs(u.TextShell,{children:[e.jsx("div",{className:"pr-8",children:t}),e.jsx(u.PriceLockRow,{children:e.jsx("span",{className:i?"text-white/55":"text-white/30",children:i||n})}),r&&e.jsx("button",{type:"button",onClick:r,className:"absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15","aria-label":"Dismiss attachment",children:e.jsx(a.XIcon,{className:"size-3",weight:"bold"})})]}),B=({title:t,mimeType:i="application/octet-stream",thumbnailUrl:n,detail:r,amountText:o,placeholderTitle:m="Attachment title",placeholderAmountText:g,gallery:l=[],onDismiss:c,onPreviewClick:j,onFetchSource:w,onEditClick:d})=>{const h=s.isGalleryCard(l),{source:b,isPreviewVisible:v,isLoadingPreview:f,togglePreview:p}=s.usePreviewToggle({isGallery:h,onFetchSource:w,onPreviewClick:j}),x=!v,y=f,C=e.jsxs(T.Fragment,{children:[e.jsx("span",{className:"text-xs font-medium text-white/55",children:"•"}),e.jsx("span",{className:o?"text-xs font-medium text-white/55":"text-xs font-medium text-white/30",children:o||g})]}),P=c?e.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),c()},className:"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white","aria-label":"Dismiss attachment",children:e.jsx(a.XIcon,{className:"size-3",weight:"bold"})}):void 0,N=d?e.jsx("button",{type:"button",onClick:d,"aria-label":"Edit attachment",className:"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",children:e.jsx(a.PencilSimpleIcon,{className:"size-5",weight:"regular"})}):void 0;return e.jsxs(s.MediaShell,{variant:"dark",children:[e.jsx(s.PreviewToggle,{onToggle:p,isBusy:y,isPreviewVisible:!x,children:e.jsx(s.CardThumbnail,{variant:"dark",gallery:l,title:t,showLocked:x,mimeType:i,thumbnailUrl:n,source:b,topRight:P})}),e.jsx(s.CardBody,{variant:"dark",title:t,placeholderTitle:m,mimeType:i,detail:r,statusBadge:C,icon:h?s.galleryBodyIcon("dark"):void 0,trailingAction:N})]})},S=t=>t.contentType==="text"?e.jsx(z,{...t}):e.jsx(B,{...t});exports.default=S;
2
+ //# sourceMappingURL=Card-D8yiJ8Uw.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-D8yiJ8Uw.cjs","sources":["../src/components/LockedAttachment/components/Composer/Card.tsx"],"sourcesContent":["import { PencilSimpleIcon, XIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nimport type { FetchSourceHandler, LockedAttachmentBaseProps } from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport TextShell from '../_shared/TextShell'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\n\nexport interface ComposerCardProps extends LockedAttachmentBaseProps {\n /**\n * The message's own text, shown as-is (not redacted yet — the message\n * hasn't been sent). Only used when `contentType` is `\"text\"`.\n */\n text?: string\n /** Placeholder shown in the amount slot before one is configured. */\n placeholderAmountText?: string\n /**\n * Renders a persistent dismiss X on the thumbnail (media) or next to the\n * text (text mode); called to remove the draft attachment. Unrelated to\n * `TextCardProps.onDismiss`, which only appears for `isMine` after a\n * failed payment.\n */\n onDismiss?: () => void\n /** Fired the first time the composer taps the thumbnail to preview. */\n onPreviewClick?: () => void\n /**\n * Lazily loads the underlying source so the composer can preview the\n * attachment they're about to send. Called the first time the thumbnail is\n * tapped; the returned source is cached and reused on subsequent toggles.\n * Ignored when `contentType` is `\"text\"`.\n */\n onFetchSource?: FetchSourceHandler\n /**\n * When provided, renders a pencil button in the body bottom-right that the\n * composer can use to edit the attachment metadata (e.g. open the price /\n * gallery editor). Matches the Composer \"Button\" instance in Figma.\n */\n onEditClick?: () => void\n}\n\n/**\n * Composer card in text mode: a normal outgoing chat bubble showing the real\n * draft text (it hasn't been sent/redacted yet) plus a dismiss X and a price\n * row. Media-only props are ignored here.\n */\nconst ComposerTextCard: React.FC<ComposerCardProps> = ({\n text,\n amountText,\n placeholderAmountText,\n onDismiss,\n}) => (\n <TextShell>\n <div className=\"pr-8\">{text}</div>\n <PriceLockRow>\n <span className={amountText ? 'text-white/55' : 'text-white/30'}>\n {amountText || placeholderAmountText}\n </span>\n </PriceLockRow>\n {onDismiss && (\n <button\n type=\"button\"\n onClick={onDismiss}\n className=\"absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n )}\n </TextShell>\n)\n\n/**\n * Composer card in media mode: the locked thumbnail (single or gallery) the\n * composer taps to preview the attachment they're about to send, plus the\n * title/price body with optional dismiss X and edit pencil.\n */\nconst ComposerMediaCard: React.FC<ComposerCardProps> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n placeholderAmountText,\n gallery = [],\n onDismiss,\n onPreviewClick,\n onFetchSource,\n onEditClick,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable in the composer because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n const statusBadge = (\n <React.Fragment>\n <span className=\"text-xs font-medium text-white/55\">&bull;</span>\n <span\n className={\n amountText\n ? 'text-xs font-medium text-white/55'\n : 'text-xs font-medium text-white/30'\n }\n >\n {amountText || placeholderAmountText}\n </span>\n </React.Fragment>\n )\n\n const dismissButton = onDismiss ? (\n <button\n type=\"button\"\n onClick={(e) => {\n // Stop the click from bubbling up into the outer preview-toggle\n // wrapper when both are wired up at the same time.\n e.stopPropagation()\n onDismiss()\n }}\n className=\"flex size-6 items-center justify-center rounded-full bg-[#121110] text-white\"\n aria-label=\"Dismiss attachment\"\n >\n <XIcon className=\"size-3\" weight=\"bold\" />\n </button>\n ) : undefined\n\n const editButton = onEditClick ? (\n <button\n type=\"button\"\n onClick={onEditClick}\n aria-label=\"Edit attachment\"\n className=\"flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15\"\n >\n <PencilSimpleIcon className=\"size-5\" weight=\"regular\" />\n </button>\n ) : undefined\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n topRight={dismissButton}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={statusBadge}\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n trailingAction={editButton}\n />\n </MediaShell>\n )\n}\n\n/**\n * The card the composer sees while drafting a paid attachment.\n * Matches the Composer column of the messaging design system in Figma.\n *\n * When `contentType === \"text\"`, renders as a normal outgoing chat bubble\n * showing the real draft text (it hasn't been sent/redacted yet) plus a\n * dismiss X and a price row, instead of a media thumbnail card.\n */\nconst ComposerCard: React.FC<ComposerCardProps> = (props) =>\n props.contentType === 'text' ? (\n <ComposerTextCard {...props} />\n ) : (\n <ComposerMediaCard {...props} />\n )\n\nexport default ComposerCard\n"],"names":["ComposerTextCard","text","amountText","placeholderAmountText","onDismiss","TextShell","jsx","PriceLockRow","XIcon","ComposerMediaCard","title","mimeType","thumbnailUrl","detail","placeholderTitle","gallery","onPreviewClick","onFetchSource","onEditClick","isGallery","isGalleryCard","source","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","isBusy","statusBadge","jsxs","React","dismissButton","e","editButton","PencilSimple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AAU0B,GAAM,CAGdA,EAAE,gBAAA,EACF5B,EAAA,CACF,EACA,UAAU,+EACV,aAAW,qBAEX,SAAAE,EAAAA,IAACE,QAAA,CAAM,UAAU,SAAS,OAAO,MAAA,CAAO,CAAA,CAAA,EAExC,OAEEyB,EAAaf,EACjBZ,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASY,EACT,aAAW,kBACX,UAAU,iGAEV,SAAAZ,EAAAA,IAAC4B,mBAAA,CAAiB,UAAU,SAAS,OAAO,SAAA,CAAU,CAAA,CAAA,EAEtD,OAEJ,OACEL,EAAAA,KAACM,EAAAA,WAAA,CAAW,QAAQ,OAClB,SAAA,CAAA7B,EAAAA,IAAC8B,EAAAA,cAAA,CACC,SAAUZ,EACV,OAAAG,EACA,iBAAkB,CAACD,EAEnB,SAAApB,EAAAA,IAAC+B,EAAAA,cAAA,CACC,QAAQ,OACR,QAAAtB,EACA,MAAAL,EACA,WAAAgB,EACA,SAAAf,EACA,aAAAC,EACA,OAAAS,EACA,SAAUU,CAAA,CAAA,CACZ,CAAA,EAGFzB,EAAAA,IAACgC,EAAAA,SAAA,CACC,QAAQ,OACR,MAAA5B,EACA,iBAAAI,EACA,SAAAH,EACA,OAAAE,EACA,YAAAe,EACA,KAAMT,EAAYoB,kBAAgB,MAAM,EAAI,OAC5C,eAAgBN,CAAA,CAAA,CAClB,EACF,CAEJ,EAUMO,EAA6CC,GACjDA,EAAM,cAAgB,OACpBnC,EAAAA,IAACN,EAAA,CAAkB,GAAGyC,CAAA,CAAO,EAE7BnC,EAAAA,IAACG,EAAA,CAAmB,GAAGgC,CAAA,CAAO"}
@@ -0,0 +1,96 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import { LockSimpleIcon as u } from "@phosphor-icons/react";
3
+ import { T as s, P as t } from "./TextShell-BiqF2UB0.js";
4
+ import { P as o } from "./PurchaseStatusBadge-CJH4S-8Z.js";
5
+ import h from "classnames";
6
+ const c = ({ cx: i, index: a }) => /* @__PURE__ */ e("circle", { cx: i, cy: "6.15", r: "2.4", fill: "currentColor", children: /* @__PURE__ */ e(
7
+ "animateTransform",
8
+ {
9
+ attributeName: "transform",
10
+ type: "translate",
11
+ values: "0 0; 0 -2.25; 0 0;",
12
+ dur: "900ms",
13
+ begin: `${120 * a}ms`,
14
+ repeatCount: "indefinite"
15
+ }
16
+ ) }), p = ({ className: i }) => /* @__PURE__ */ r(
17
+ "svg",
18
+ {
19
+ "aria-hidden": "true",
20
+ className: i,
21
+ viewBox: "0 0 20 12.3",
22
+ width: "20",
23
+ height: "13",
24
+ overflow: "visible",
25
+ children: [
26
+ /* @__PURE__ */ e(c, { cx: "3", index: 0 }),
27
+ /* @__PURE__ */ e(c, { cx: "10", index: 1 }),
28
+ /* @__PURE__ */ e(c, { cx: "17", index: 2 })
29
+ ]
30
+ }
31
+ ), m = ({
32
+ variant: i = "dark",
33
+ animate: a = !0
34
+ }) => {
35
+ const n = a ? "animate-pulse motion-reduce:animate-none" : "", l = i === "dark" ? "bg-white/25" : "bg-black/15";
36
+ return /* @__PURE__ */ r("div", { className: "flex flex-col gap-2 str-chat__message-text my-1", "aria-hidden": !0, children: [
37
+ /* @__PURE__ */ e("div", { className: h("h-3 w-40 rounded-full", n, l) }),
38
+ /* @__PURE__ */ e("div", { className: h("h-3 w-24 rounded-full", n, l) })
39
+ ] });
40
+ }, x = ({
41
+ amountText: i,
42
+ paymentStatus: a = "pending",
43
+ children: n
44
+ }) => {
45
+ const l = a === "failed";
46
+ return a === "paid" && n ? /* @__PURE__ */ r(s, { children: [
47
+ n,
48
+ /* @__PURE__ */ e("span", { className: "sr-only", "aria-live": "polite", children: "Sold." }),
49
+ /* @__PURE__ */ r(t, { children: [
50
+ i != null && /* @__PURE__ */ e("span", { className: "text-white/55", children: i }),
51
+ /* @__PURE__ */ e(o, { isMine: !0, paymentStatus: a })
52
+ ] })
53
+ ] }) : /* @__PURE__ */ r(s, { children: [
54
+ /* @__PURE__ */ e(m, { variant: "dark", animate: a === "pending" }),
55
+ /* @__PURE__ */ e("span", { className: "sr-only", "aria-live": "polite", children: l ? "Payment failed." : a === "refunded" ? "Refunded." : "Payment pending." }),
56
+ /* @__PURE__ */ r(t, { children: [
57
+ i != null && /* @__PURE__ */ e("span", { className: "text-white/55", children: i }),
58
+ /* @__PURE__ */ e(o, { isMine: !0, paymentStatus: a })
59
+ ] })
60
+ ] });
61
+ }, v = ({
62
+ amountText: i,
63
+ paymentStatus: a,
64
+ onUnlockClick: n,
65
+ isUnlocking: l = !1,
66
+ children: d
67
+ }) => a === "paid" && d ? /* @__PURE__ */ r(s, { children: [
68
+ d,
69
+ /* @__PURE__ */ r(t, { children: [
70
+ i != null && /* @__PURE__ */ e("span", { className: "opacity-55", children: i }),
71
+ /* @__PURE__ */ e(o, { isMine: !1, paymentStatus: "paid" })
72
+ ] })
73
+ ] }) : /* @__PURE__ */ e(s, { children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
74
+ /* @__PURE__ */ r("div", { className: "flex flex-1 flex-col gap-2", children: [
75
+ /* @__PURE__ */ e(m, { variant: "light", animate: l }),
76
+ /* @__PURE__ */ e("span", { className: "sr-only", "aria-live": "polite", children: l ? "Unlocking." : "Locked message available to unlock." }),
77
+ /* @__PURE__ */ e(t, { children: i != null && /* @__PURE__ */ e("span", { className: "opacity-55", children: i }) })
78
+ ] }),
79
+ /* @__PURE__ */ e(
80
+ "button",
81
+ {
82
+ type: "button",
83
+ onClick: n,
84
+ disabled: l,
85
+ "aria-label": l ? "Unlocking" : "Unlock",
86
+ "aria-busy": l,
87
+ title: l ? "Unlocking" : "Unlock",
88
+ className: "flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]",
89
+ children: l ? /* @__PURE__ */ e(p, {}) : /* @__PURE__ */ e(u, { className: "size-4", weight: "fill", "aria-hidden": !0 })
90
+ }
91
+ )
92
+ ] }) }), y = (i) => i.isMine ? /* @__PURE__ */ e(x, { ...i }) : /* @__PURE__ */ e(v, { ...i });
93
+ export {
94
+ y as default
95
+ };
96
+ //# sourceMappingURL=Card-DSG-wR8t.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DSG-wR8t.js","sources":["../src/components/LockedAttachment/components/_shared/LoadingDots.tsx","../src/components/LockedAttachment/components/_shared/SkeletonTextLines.tsx","../src/components/LockedAttachment/components/Text/Card.tsx"],"sourcesContent":["import React from 'react'\n\nconst Dot = ({ cx, index }: { cx: string; index: number }) => (\n <circle cx={cx} cy=\"6.15\" r=\"2.4\" fill=\"currentColor\">\n <animateTransform\n attributeName=\"transform\"\n type=\"translate\"\n values=\"0 0; 0 -2.25; 0 0;\"\n dur=\"900ms\"\n begin={`${120 * index}ms`}\n repeatCount=\"indefinite\"\n />\n </circle>\n)\n\n/**\n * Three bouncing dots, inline-sized for use inside buttons/labels (e.g. the\n * Unlock CTA while a purchase is in flight). Mirrors the typing indicator's\n * animation but uses `currentColor` so it adopts the surrounding text color.\n */\nconst LoadingDots: React.FC<{ className?: string }> = ({ className }) => (\n <svg\n aria-hidden=\"true\"\n className={className}\n viewBox=\"0 0 20 12.3\"\n width=\"20\"\n height=\"13\"\n overflow=\"visible\"\n >\n <Dot cx=\"3\" index={0} />\n <Dot cx=\"10\" index={1} />\n <Dot cx=\"17\" index={2} />\n </svg>\n)\n\nexport default LoadingDots\n","import classNames from 'classnames'\nimport React from 'react'\n\nexport interface SkeletonTextLinesProps {\n /** Matches the bubble it sits in — \"dark\" for the sender's own bubble. */\n variant: 'light' | 'dark'\n /**\n * Whether the bars pulse. Pass `false` once the outcome is settled (paid,\n * failed, refunded) — a static skeleton reads as \"nothing more will\n * change\", while a pulsing one implies something is still in flight.\n */\n animate: boolean\n}\n\n/**\n * Two skeleton bars standing in for the redacted text of a paid text-only\n * message — the real content is never sent to the client until purchase, so\n * there's nothing to render yet.\n *\n * Uses explicit black/white (not `bg-current`) because Tailwind doesn't\n * support opacity modifiers on the `current` color — `bg-current/30` silently\n * produces no CSS rule at all.\n */\nconst SkeletonTextLines: React.FC<SkeletonTextLinesProps> = ({\n variant = 'dark',\n animate = true,\n}) => {\n const pulse = animate ? 'animate-pulse motion-reduce:animate-none' : ''\n const colour = variant === 'dark' ? 'bg-white/25' : 'bg-black/15'\n\n return (\n <div className=\"flex flex-col gap-2 str-chat__message-text my-1\" aria-hidden>\n <div className={classNames('h-3 w-40 rounded-full', pulse, colour)} />\n <div className={classNames('h-3 w-24 rounded-full', pulse, colour)} />\n </div>\n )\n}\n\nexport default SkeletonTextLines\n","import { LockSimpleIcon } from '@phosphor-icons/react'\nimport type React from 'react'\n\nimport type { PaymentStatus } from '../../types'\nimport LoadingDots from '../_shared/LoadingDots'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport SkeletonTextLines from '../_shared/SkeletonTextLines'\nimport TextShell from '../_shared/TextShell'\n\ninterface TextCardSharedProps {\n amountText?: string\n paymentStatus?: PaymentStatus\n /**\n * The message's real, revealed content — shown instead of the skeleton\n * loader once `paymentStatus` is `'paid'`. Ignored otherwise. Lets the\n * caller supply its own text renderer (e.g. Stream's `MessageText`)\n * without `LockedAttachment` depending on it.\n */\n children?: React.ReactNode\n}\n\nexport type TextCardProps =\n | (TextCardSharedProps & {\n isMine: true\n })\n | (TextCardSharedProps & {\n isMine: false\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n })\n\n/**\n * The sender's ('mine') view of a paid text-only message: an outgoing chat\n * bubble showing a skeleton text loader in place of the redacted content (or\n * `children`, once paid), plus a lock/price/status row.\n */\nconst OwnTextCard: React.FC<TextCardSharedProps & { isMine: true }> = ({\n amountText,\n paymentStatus = 'pending',\n children,\n}) => {\n const isFailed = paymentStatus === 'failed'\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell>\n {children}\n <span className=\"sr-only\" aria-live=\"polite\">\n Sold.\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const liveMessage = isFailed\n ? 'Payment failed.'\n : paymentStatus === 'refunded'\n ? 'Refunded.'\n : 'Payment pending.'\n\n return (\n <TextShell>\n <SkeletonTextLines variant=\"dark\" animate={paymentStatus === 'pending'} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveMessage}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid text-only message: a plain chat\n * bubble whose content is a skeleton text loader (or `children`, once paid)\n * plus a lock/price/status row. Two pre-purchase states exist — idle and\n * unlocking (checkout in flight) — plus the revealed state once\n * `paymentStatus` is `'paid'`.\n */\nconst OtherTextCard: React.FC<\n TextCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n amountText,\n paymentStatus,\n onUnlockClick,\n isUnlocking = false,\n children,\n}) => {\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell>\n {children}\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={false} paymentStatus=\"paid\" />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const ariaLabel = isUnlocking\n ? 'Unlocking.'\n : 'Locked message available to unlock.'\n\n return (\n <TextShell>\n <div className=\"flex items-center gap-3\">\n <div className=\"flex flex-1 flex-col gap-2\">\n <SkeletonTextLines variant=\"light\" animate={isUnlocking} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {ariaLabel}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n </PriceLockRow>\n </div>\n <button\n type=\"button\"\n onClick={onUnlockClick}\n disabled={isUnlocking}\n aria-label={isUnlocking ? 'Unlocking' : 'Unlock'}\n aria-busy={isUnlocking}\n title={isUnlocking ? 'Unlocking' : 'Unlock'}\n className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]\"\n >\n {isUnlocking ? (\n <LoadingDots />\n ) : (\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" aria-hidden />\n )}\n </button>\n </div>\n </TextShell>\n )\n}\n\n/**\n * The card either party sees for a paid text-only message — a chat bubble\n * showing a skeleton text loader (or `children`, once revealed) plus a\n * lock/price/status row. `isMine` selects the sender's payment-lifecycle view\n * (pending/failed/refunded/paid + Dismiss) vs. the recipient's unlock-flow\n * view (idle/unlocking + Unlock CTA).\n */\nconst TextCard: React.FC<TextCardProps> = (props) =>\n props.isMine ? <OwnTextCard {...props} /> : <OtherTextCard {...props} />\n\nexport default TextCard\n"],"names":["Dot","cx","index","jsx","LoadingDots","className","jsxs","SkeletonTextLines","variant","animate","pulse","colour","classNames","OwnTextCard","amountText","paymentStatus","children","isFailed","TextShell","PriceLockRow","PurchaseStatusBadge","OtherTextCard","onUnlockClick","isUnlocking","LockSimpleIcon","TextCard","props"],"mappings":";;;;;AAEA,MAAMA,IAAM,CAAC,EAAE,IAAAC,GAAI,OAAAC,QACjB,gBAAAC,EAAC,UAAA,EAAO,IAAAF,GAAQ,IAAG,QAAO,GAAE,OAAM,MAAK,gBACrC,UAAA,gBAAAE;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,eAAc;AAAA,IACd,MAAK;AAAA,IACL,QAAO;AAAA,IACP,KAAI;AAAA,IACJ,OAAO,GAAG,MAAMD,CAAK;AAAA,IACrB,aAAY;AAAA,EAAA;AACd,GACF,GAQIE,IAAgD,CA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AAA,CAAW,EAAA,CAE7C;AAAA,EAAA,GACF;AAAA,EACA,gBAAAX;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,SAASmB;AAAA,MACT,UAAUC;AAAA,MACV,cAAYA,IAAc,cAAc;AAAA,MACxC,aAAWA;AAAA,MACX,OAAOA,IAAc,cAAc;AAAA,MACnC,WAAU;AAAA,MAET,UAAAA,IACC,gBAAApB,EAACC,GAAA,CAAA,CAAY,IAEb,gBAAAD,EAACqB,GAAA,EAAe,WAAU,UAAS,QAAO,QAAO,eAAW,GAAA,CAAC;AAAA,IAAA;AAAA,EAAA;AAEjE,EAAA,CACF,EAAA,CACF,GAWEC,IAAoC,CAACC,MACzCA,EAAM,SAAS,gBAAAvB,EAACU,GAAA,EAAa,GAAGa,EAAA,CAAO,IAAK,gBAAAvB,EAACkB,GAAA,EAAe,GAAGK,EAAA,CAAO;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime");require("classnames");const C=require("@phosphor-icons/react"),v=require("react"),M=require("./index-DwUOvMxg.cjs"),s=require("./usePreviewToggle-DXQT07ws.cjs"),y=require("./PurchaseStatusBadge-UjDzZhLj.cjs");function p({paymentStatus:r,onFetchSource:l,onUnlockClick:o}){const[t,d]=v.useState(),i=v.useRef(null),n=v.useRef(!1),u=v.useRef(l);u.current=l;const h=v.useCallback(async()=>{var a;if(!n.current){n.current=!0;try{const c=await((a=u.current)==null?void 0:a.call(u));c&&d(c)}finally{n.current=!1}}},[]),g=v.useCallback(()=>{r==="paid"?h():o==null||o()},[r,h,o]);return v.useEffect(()=>{if(!i.current||r!=="paid"||t!==void 0)return;const a=new IntersectionObserver(([c])=>{c.isIntersecting&&(h(),a.disconnect())},{threshold:1});return a.observe(i.current),()=>a.disconnect()},[r,t,h]),{source:t,cardRef:i,handleUnlockClick:g}}const P="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] disabled:opacity-70",I=({isLocked:r,sourceUrl:l,redeemUrl:o,onUnlockClicked:t,onDownloadClicked:d,isUnlocking:i=!1})=>{if(r&&t!=null)return e.jsx("button",{type:"button",onClick:t,disabled:i,className:P,children:i?e.jsx("span",{className:"size-4 animate-spin rounded-full border-2 border-white/30 border-t-white"}):e.jsxs(v.Fragment,{children:[e.jsx(C.LockSimpleIcon,{className:"size-4",weight:"fill"}),"Unlock"]})});if(!r&&d!=null){const n=o??l;return n!=null?e.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",onClick:d,className:`${P} !text-white`,children:[e.jsx(C.DownloadSimpleIcon,{className:"size-4",weight:"bold"}),"Download"]}):e.jsxs("button",{type:"button",onClick:d,className:P,children:[e.jsx(C.DownloadSimpleIcon,{className:"size-4",weight:"bold"}),"Download"]})}return null},S=({title:r,mimeType:l="application/octet-stream",thumbnailUrl:o,detail:t,amountText:d,placeholderTitle:i="Attachment title",paymentStatus:n="pending",gallery:u=[],onPreviewClick:h,onFetchSource:g})=>{const a=s.isGalleryCard(u),{source:c,isPreviewVisible:f,isLoadingPreview:b,togglePreview:j}=s.usePreviewToggle({isGallery:a,onFetchSource:g,onPreviewClick:h}),x=!f,w=b;return e.jsxs(s.MediaShell,{variant:"dark",children:[e.jsx(s.PreviewToggle,{onToggle:j,isBusy:w,isPreviewVisible:!x,children:e.jsx(s.CardThumbnail,{variant:"dark",gallery:u,title:r,showLocked:x,paymentStatus:n,mimeType:l,thumbnailUrl:o,source:c})}),e.jsx(s.CardBody,{variant:"dark",title:r,placeholderTitle:i,mimeType:l,detail:t,statusBadge:e.jsx(y.PurchaseStatusBadge,{isMine:!0,paymentStatus:n,amountText:d}),icon:a?s.galleryBodyIcon("dark"):void 0})]})},k=({title:r,amountText:l,thumbnailUrl:o,mimeType:t="application/octet-stream",detail:d,gallery:i=[],onUnlockClick:n,onFetchSource:u,onDownloadClick:h,paymentStatus:g,isUnlocking:a=!1})=>{const c=s.isGalleryCard(i),{source:f,cardRef:b,handleUnlockClick:j}=p({paymentStatus:g,onFetchSource:u,onUnlockClick:n}),x=f==null?void 0:f.sourceUrl,w=f==null?void 0:f.redeemUrl,m=c?g!=="paid":x===void 0,R=M.getSourceType(t),B=c?void 0:x;return e.jsxs(s.MediaShell,{variant:"light",rootRef:b,"data-testid":"locked-attachment",children:[e.jsx(s.CardThumbnail,{variant:"light",gallery:i,title:r,showLocked:m,paymentStatus:g,mimeType:t,thumbnailUrl:o,source:f,containedImage:!m&&(R==="image"||R==="document")}),e.jsx(s.CardBody,{variant:"light",title:r,mimeType:t,detail:d,statusBadge:e.jsx(y.PurchaseStatusBadge,{isMine:!1,paymentStatus:g,amountText:l}),icon:c?s.galleryBodyIcon("light"):void 0,action:e.jsx(I,{isLocked:m,isUnlocking:a,sourceUrl:B,redeemUrl:w,onUnlockClicked:j,onDownloadClicked:h})})]})},q=r=>r.isMine?e.jsx(S,{...r}):e.jsx(k,{...r});exports.default=q;
2
+ //# sourceMappingURL=Card-DVfSiq9b.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DVfSiq9b.cjs","sources":["../src/components/LockedAttachment/components/_shared/useReceivedSource.ts","../src/components/LockedAttachment/components/Media/CardActions.tsx","../src/components/LockedAttachment/components/Media/Card.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type {\n FetchSourceHandler,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nexport interface UseReceivedSourceOptions {\n paymentStatus?: PaymentStatus\n onFetchSource?: FetchSourceHandler\n /** Called on Unlock click while the card is still unpaid (opens checkout). */\n onUnlockClick?: () => void\n}\n\nexport interface UseReceivedSourceResult {\n source: LockedAttachmentSource | undefined\n /** Attach to the card root so the paid-source auto-fetch can observe it. */\n cardRef: React.RefObject<HTMLDivElement>\n /** Fetches the source when already paid, else defers to `onUnlockClick`. */\n handleUnlockClick: () => void\n}\n\n/**\n * Media !isMine's source-reveal logic: unlike Composer/Media isMine's\n * tap-to-toggle (`usePreviewToggle`), the recipient's card reveals its source\n * by fetching once — on click when already paid, or automatically the first\n * time a paid card scrolls fully into view. The fetch is guarded so it runs\n * at most once in flight.\n */\nexport function useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n}: UseReceivedSourceOptions): UseReceivedSourceResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n\n const cardRef = useRef<HTMLDivElement>(null)\n const fetchingRef = useRef(false)\n\n const onFetchSourceRef = useRef(onFetchSource)\n onFetchSourceRef.current = onFetchSource\n\n const fetchSource = useCallback(async (): Promise<void> => {\n if (fetchingRef.current) return\n fetchingRef.current = true\n try {\n const result = await onFetchSourceRef.current?.()\n if (result) setSource(result)\n } finally {\n fetchingRef.current = false\n }\n }, [])\n\n const handleUnlockClick = useCallback(() => {\n if (paymentStatus === 'paid') {\n void fetchSource()\n } else {\n onUnlockClick?.()\n }\n }, [paymentStatus, fetchSource, onUnlockClick])\n\n // Auto-fetch the source once the paid card scrolls into view.\n useEffect(() => {\n if (!cardRef.current) return\n if (paymentStatus !== 'paid' || source !== undefined) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n void fetchSource()\n observer.disconnect()\n }\n },\n { threshold: 1.0 }\n )\n\n observer.observe(cardRef.current)\n return () => observer.disconnect()\n }, [paymentStatus, source, fetchSource])\n\n return { source, cardRef, handleUnlockClick }\n}\n","import { DownloadSimpleIcon, LockSimpleIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nexport interface ReceivedCardActionsProps {\n /** Whether the card is currently locked. Drives which CTA we render. */\n isLocked: boolean\n /**\n * When unlocked, the URL used as the Download link's `href` (opens in a new\n * tab). When omitted, the Download CTA falls back to a plain `<button>`\n * that just calls `onDownloadClicked` — useful for galleries where the\n * single-source URL doesn't exist.\n */\n sourceUrl?: string\n /** Optional alternate href that takes precedence over `sourceUrl`. */\n redeemUrl?: string\n onUnlockClicked?: () => void\n onDownloadClicked?: () => void\n isUnlocking?: boolean\n}\n\nconst buttonClass =\n '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] disabled:opacity-70'\n\n/**\n * Renders the primary CTA below the body of a Received card.\n * - Locked + onUnlockClicked → \"Unlock\" button\n * - Unlocked + onDownloadClicked + (redeemUrl || sourceUrl) → \"Download\" link\n * - Unlocked + onDownloadClicked + no URL → \"Download\" button (e.g. gallery)\n * Otherwise renders nothing.\n */\nconst ReceivedCardActions: React.FC<ReceivedCardActionsProps> = ({\n isLocked,\n sourceUrl,\n redeemUrl,\n onUnlockClicked,\n onDownloadClicked,\n isUnlocking = false,\n}) => {\n if (isLocked && onUnlockClicked != null) {\n return (\n <button\n type=\"button\"\n onClick={onUnlockClicked}\n disabled={isUnlocking}\n className={buttonClass}\n >\n {isUnlocking ? (\n <span className=\"size-4 animate-spin rounded-full border-2 border-white/30 border-t-white\" />\n ) : (\n <React.Fragment>\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" />\n Unlock\n </React.Fragment>\n )}\n </button>\n )\n }\n\n if (!isLocked && onDownloadClicked != null) {\n const href = redeemUrl ?? sourceUrl\n if (href != null) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={onDownloadClicked}\n className={`${buttonClass} !text-white`}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={onDownloadClicked}\n className={buttonClass}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </button>\n )\n }\n\n return null\n}\n\nexport default ReceivedCardActions\n","import type React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type {\n FetchSourceHandler,\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\nimport { useReceivedSource } from '../_shared/useReceivedSource'\n\nimport ReceivedCardActions from './CardActions'\n\ninterface MediaCardSharedProps {\n title?: string\n mimeType?: string\n thumbnailUrl?: string\n detail?: string\n amountText?: string\n paymentStatus?: PaymentStatus\n gallery?: LockedAttachmentGalleryItem[]\n onFetchSource?: FetchSourceHandler\n}\n\nexport type MediaCardProps =\n | (MediaCardSharedProps & {\n isMine: true\n /** Dimmed fallback shown in the title slot when `title` is unset. */\n placeholderTitle?: string\n /** Fired the first time the sender taps the thumbnail to preview their own attachment. */\n onPreviewClick?: () => void\n })\n | (MediaCardSharedProps & {\n isMine: false\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * Called when the recipient clicks Download on an unlocked card.\n * Omit to hide the Download button.\n */\n onDownloadClick?: () => void\n })\n\n/**\n * The sender's ('mine') view of a paid media attachment: the locked\n * thumbnail (single or gallery) they can tap to preview their own\n * attachment, plus the title/purchase-status body.\n */\nconst OwnMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: true\n placeholderTitle?: string\n onPreviewClick?: () => void\n }\n> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n paymentStatus = 'pending',\n gallery = [],\n onPreviewClick,\n onFetchSource,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable for the sender because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={true}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n />\n </MediaShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid media attachment: the locked\n * thumbnail (single or gallery) with an Unlock/Download CTA. The source is\n * revealed by fetching once — on click when already paid, or automatically\n * the first time a paid card scrolls into view.\n */\nconst OtherMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n onDownloadClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n title,\n amountText,\n thumbnailUrl,\n mimeType = 'application/octet-stream',\n detail,\n gallery = [],\n onUnlockClick,\n onFetchSource,\n onDownloadClick,\n paymentStatus,\n isUnlocking = false,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n const { source, cardRef, handleUnlockClick } = useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n })\n\n const effectiveSourceUrl = source?.sourceUrl\n const effectiveRedeemUrl = source?.redeemUrl\n\n // For gallery, the per-item sources are carried by `gallery` itself, so\n // the lock state is driven by paymentStatus rather than the single\n // `effectiveSourceUrl`. Everything else still respects the source fetch.\n const isLocked = isGallery\n ? paymentStatus !== 'paid'\n : effectiveSourceUrl === undefined\n const sourceType = getSourceType(mimeType)\n\n // For gallery, ReceivedCardActions falls back to a plain <button>\n // (no anchor) because the gallery has no single sourceUrl to link to —\n // the per-item sources live on `gallery` itself.\n const actionSourceUrl = isGallery ? undefined : effectiveSourceUrl\n\n return (\n <MediaShell\n variant=\"light\"\n rootRef={cardRef}\n data-testid=\"locked-attachment\"\n >\n <CardThumbnail\n variant=\"light\"\n gallery={gallery}\n title={title}\n showLocked={isLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n containedImage={\n !isLocked && (sourceType === 'image' || sourceType === 'document')\n }\n />\n\n <CardBody\n variant=\"light\"\n title={title}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={false}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('light') : undefined}\n action={\n <ReceivedCardActions\n isLocked={isLocked}\n isUnlocking={isUnlocking}\n sourceUrl={actionSourceUrl}\n redeemUrl={effectiveRedeemUrl}\n onUnlockClicked={handleUnlockClick}\n onDownloadClicked={onDownloadClick}\n />\n }\n />\n </MediaShell>\n )\n}\n\n/**\n * The card either party sees for a paid media attachment. `isMine` selects\n * the sender's preview view (tap-to-preview own draft) vs. the recipient's\n * unlock/download view.\n */\nconst MediaCard: React.FC<MediaCardProps> = (props) =>\n props.isMine ? <OwnMediaCard {...props} /> : <OtherMediaCard {...props} />\n\nexport default MediaCard\n"],"names":["useReceivedSource","paymentStatus","onFetchSource","onUnlockClick","source","setSource","useState","cardRef","useRef","fetchingRef","onFetchSourceRef","fetchSource","useCallback","result","_a","handleUnlockClick","useEffect","observer","entry","buttonClass","ReceivedCardActions","isLocked","sourceUrl","redeemUrl","onUnlockClicked","onDownloadClicked","isUnlocking","jsx","jsxs","React","LockSimpleIcon","href","DownloadSimpleIcon","OwnMediaCard","title","mimeType","thumbnailUrl","detail","amountText","placeholderTitle","gallery","onPreviewClick","isGallery","isGalleryCard","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","isBusy","MediaShell","PreviewToggle","CardThumbnail","CardBody","PurchaseStatusBadge","galleryBodyIcon","OtherMediaCard","onDownloadClick","effectiveSourceUrl","effectiveRedeemUrl","sourceType","getSourceType","actionSourceUrl","MediaCard","props"],"mappings":"sUA8BO,SAASA,EAAkB,CAChC,cAAAC,EACA,cAAAC,EACA,cAAAC,CACF,EAAsD,CACpD,KAAM,CAACC,EAAQC,CAAS,EAAIC,WAAA,EAEtBC,EAAUC,EAAAA,OAAuB,IAAI,EACrCC,EAAcD,EAAAA,OAAO,EAAK,EAE1BE,EAAmBF,EAAAA,OAAON,CAAa,EAC7CQ,EAAiB,QAAUR,EAE3B,MAAMS,EAAcC,EAAAA,YAAY,SAA2B,OACzD,GAAI,CAAAH,EAAY,QAChB,CAAAA,EAAY,QAAU,GACtB,GAAI,CACF,MAAMI,EAAS,OAAMC,EAAAJ,EAAiB,UAAjB,YAAAI,EAAA,KAAAJ,IACjBG,KAAkBA,CAAM,CAC9B,QAAA,CACEJ,EAAY,QAAU,EACxB,EACF,EAAG,CAAA,CAAE,EAECM,EAAoBH,EAAAA,YAAY,IAAM,CACtCX,IAAkB,OACfU,EAAA,EAELR,GAAA,MAAAA,GAEJ,EAAG,CAACF,EAAeU,EAAaR,CAAa,CAAC,EAG9Ca,OAAAA,EAAAA,UAAU,IAAM,CAEd,GADI,CAACT,EAAQ,SACTN,IAAkB,QAAUG,IAAW,OAAW,OAEtD,MAAMa,EAAW,IAAI,qBACnB,CAAC,CAACC,CAAK,IAAM,CACPA,EAAM,iBACHP,EAAA,EACLM,EAAS,WAAA,EAEb,EACA,CAAE,UAAW,CAAA,CAAI,EAGnB,OAAAA,EAAS,QAAQV,EAAQ,OAAO,EACzB,IAAMU,EAAS,WAAA,CACxB,EAAG,CAAChB,EAAeG,EAAQO,CAAW,CAAC,EAEhC,CAAE,OAAAP,EAAQ,QAAAG,EAAS,kBAAAQ,CAAA,CAC5B,CC9DA,MA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AAA,KAACsB,EAAAA,WAAA,CACC,QAAQ,QACR,QAAS3C,EACT,cAAY,oBAEZ,SAAA,CAAAoB,EAAAA,IAACyB,EAAAA,cAAA,CACC,QAAQ,QACR,QAAAZ,EACA,MAAAN,EACA,WAAYb,EACZ,cAAApB,EACA,SAAAkC,EACA,aAAAC,EACA,OAAAhC,EACA,eACE,CAACiB,IAAauC,IAAe,SAAWA,IAAe,WAAA,CAAA,EAI3DjC,EAAAA,IAAC0B,EAAAA,SAAA,CACC,QAAQ,QACR,MAAAnB,EACA,SAAAC,EACA,OAAAE,EACA,YACEV,EAAAA,IAAC2B,EAAAA,oBAAA,CACC,OAAQ,GACR,cAAArD,EACA,WAAAqC,CAAA,CAAA,EAGJ,KAAMI,EAAYa,kBAAgB,OAAO,EAAI,OAC7C,OACE5B,EAAAA,IAACP,EAAA,CACC,SAAAC,EACA,YAAAK,EACA,UAAWoC,EACX,UAAWH,EACX,gBAAiB5C,EACjB,kBAAmB0C,CAAA,CAAA,CACrB,CAAA,CAEJ,CAAA,CAAA,CAGN,EAOMM,EAAuCC,GAC3CA,EAAM,OAASrC,EAAAA,IAACM,EAAA,CAAc,GAAG+B,CAAA,CAAO,EAAKrC,EAAAA,IAAC6B,EAAA,CAAgB,GAAGQ,CAAA,CAAO"}
@@ -0,0 +1,221 @@
1
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
+ import "classnames";
3
+ import { LockSimpleIcon as U, DownloadSimpleIcon as M } from "@phosphor-icons/react";
4
+ import j, { useState as G, useRef as p, useCallback as R, useEffect as O } from "react";
5
+ import { g as T } from "./index-CZTUyiPe.js";
6
+ import { i as B, u as A, M as N, P as D, C as k, a as I, g as y } from "./usePreviewToggle-BG-pfsgP.js";
7
+ import { P as z } from "./PurchaseStatusBadge-CJH4S-8Z.js";
8
+ function S({
9
+ paymentStatus: e,
10
+ onFetchSource: c,
11
+ onUnlockClick: a
12
+ }) {
13
+ const [t, l] = G(), i = p(null), n = p(!1), d = p(c);
14
+ d.current = c;
15
+ const f = R(async () => {
16
+ var s;
17
+ if (!n.current) {
18
+ n.current = !0;
19
+ try {
20
+ const o = await ((s = d.current) == null ? void 0 : s.call(d));
21
+ o && l(o);
22
+ } finally {
23
+ n.current = !1;
24
+ }
25
+ }
26
+ }, []), h = R(() => {
27
+ e === "paid" ? f() : a == null || a();
28
+ }, [e, f, a]);
29
+ return O(() => {
30
+ if (!i.current || e !== "paid" || t !== void 0) return;
31
+ const s = new IntersectionObserver(
32
+ ([o]) => {
33
+ o.isIntersecting && (f(), s.disconnect());
34
+ },
35
+ { threshold: 1 }
36
+ );
37
+ return s.observe(i.current), () => s.disconnect();
38
+ }, [e, t, f]), { source: t, cardRef: i, handleUnlockClick: h };
39
+ }
40
+ const C = "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] disabled:opacity-70", V = ({
41
+ isLocked: e,
42
+ sourceUrl: c,
43
+ redeemUrl: a,
44
+ onUnlockClicked: t,
45
+ onDownloadClicked: l,
46
+ isUnlocking: i = !1
47
+ }) => {
48
+ if (e && t != null)
49
+ return /* @__PURE__ */ r(
50
+ "button",
51
+ {
52
+ type: "button",
53
+ onClick: t,
54
+ disabled: i,
55
+ className: C,
56
+ children: i ? /* @__PURE__ */ r("span", { className: "size-4 animate-spin rounded-full border-2 border-white/30 border-t-white" }) : /* @__PURE__ */ m(j.Fragment, { children: [
57
+ /* @__PURE__ */ r(U, { className: "size-4", weight: "fill" }),
58
+ "Unlock"
59
+ ] })
60
+ }
61
+ );
62
+ if (!e && l != null) {
63
+ const n = a ?? c;
64
+ return n != null ? /* @__PURE__ */ m(
65
+ "a",
66
+ {
67
+ href: n,
68
+ target: "_blank",
69
+ rel: "noopener noreferrer",
70
+ onClick: l,
71
+ className: `${C} !text-white`,
72
+ children: [
73
+ /* @__PURE__ */ r(M, { className: "size-4", weight: "bold" }),
74
+ "Download"
75
+ ]
76
+ }
77
+ ) : /* @__PURE__ */ m(
78
+ "button",
79
+ {
80
+ type: "button",
81
+ onClick: l,
82
+ className: C,
83
+ children: [
84
+ /* @__PURE__ */ r(M, { className: "size-4", weight: "bold" }),
85
+ "Download"
86
+ ]
87
+ }
88
+ );
89
+ }
90
+ return null;
91
+ }, E = ({
92
+ title: e,
93
+ mimeType: c = "application/octet-stream",
94
+ thumbnailUrl: a,
95
+ detail: t,
96
+ amountText: l,
97
+ placeholderTitle: i = "Attachment title",
98
+ paymentStatus: n = "pending",
99
+ gallery: d = [],
100
+ onPreviewClick: f,
101
+ onFetchSource: h
102
+ }) => {
103
+ const s = B(d), { source: o, isPreviewVisible: u, isLoadingPreview: v, togglePreview: b } = A({ isGallery: s, onFetchSource: h, onPreviewClick: f }), g = !u;
104
+ return /* @__PURE__ */ m(N, { variant: "dark", children: [
105
+ /* @__PURE__ */ r(
106
+ D,
107
+ {
108
+ onToggle: b,
109
+ isBusy: v,
110
+ isPreviewVisible: !g,
111
+ children: /* @__PURE__ */ r(
112
+ k,
113
+ {
114
+ variant: "dark",
115
+ gallery: d,
116
+ title: e,
117
+ showLocked: g,
118
+ paymentStatus: n,
119
+ mimeType: c,
120
+ thumbnailUrl: a,
121
+ source: o
122
+ }
123
+ )
124
+ }
125
+ ),
126
+ /* @__PURE__ */ r(
127
+ I,
128
+ {
129
+ variant: "dark",
130
+ title: e,
131
+ placeholderTitle: i,
132
+ mimeType: c,
133
+ detail: t,
134
+ statusBadge: /* @__PURE__ */ r(
135
+ z,
136
+ {
137
+ isMine: !0,
138
+ paymentStatus: n,
139
+ amountText: l
140
+ }
141
+ ),
142
+ icon: s ? y("dark") : void 0
143
+ }
144
+ )
145
+ ] });
146
+ }, _ = ({
147
+ title: e,
148
+ amountText: c,
149
+ thumbnailUrl: a,
150
+ mimeType: t = "application/octet-stream",
151
+ detail: l,
152
+ gallery: i = [],
153
+ onUnlockClick: n,
154
+ onFetchSource: d,
155
+ onDownloadClick: f,
156
+ paymentStatus: h,
157
+ isUnlocking: s = !1
158
+ }) => {
159
+ const o = B(i), { source: u, cardRef: v, handleUnlockClick: b } = S({
160
+ paymentStatus: h,
161
+ onFetchSource: d,
162
+ onUnlockClick: n
163
+ }), g = u == null ? void 0 : u.sourceUrl, P = u == null ? void 0 : u.redeemUrl, w = o ? h !== "paid" : g === void 0, x = T(t), L = o ? void 0 : g;
164
+ return /* @__PURE__ */ m(
165
+ N,
166
+ {
167
+ variant: "light",
168
+ rootRef: v,
169
+ "data-testid": "locked-attachment",
170
+ children: [
171
+ /* @__PURE__ */ r(
172
+ k,
173
+ {
174
+ variant: "light",
175
+ gallery: i,
176
+ title: e,
177
+ showLocked: w,
178
+ paymentStatus: h,
179
+ mimeType: t,
180
+ thumbnailUrl: a,
181
+ source: u,
182
+ containedImage: !w && (x === "image" || x === "document")
183
+ }
184
+ ),
185
+ /* @__PURE__ */ r(
186
+ I,
187
+ {
188
+ variant: "light",
189
+ title: e,
190
+ mimeType: t,
191
+ detail: l,
192
+ statusBadge: /* @__PURE__ */ r(
193
+ z,
194
+ {
195
+ isMine: !1,
196
+ paymentStatus: h,
197
+ amountText: c
198
+ }
199
+ ),
200
+ icon: o ? y("light") : void 0,
201
+ action: /* @__PURE__ */ r(
202
+ V,
203
+ {
204
+ isLocked: w,
205
+ isUnlocking: s,
206
+ sourceUrl: L,
207
+ redeemUrl: P,
208
+ onUnlockClicked: b,
209
+ onDownloadClicked: f
210
+ }
211
+ )
212
+ }
213
+ )
214
+ ]
215
+ }
216
+ );
217
+ }, X = (e) => e.isMine ? /* @__PURE__ */ r(E, { ...e }) : /* @__PURE__ */ r(_, { ...e });
218
+ export {
219
+ X as default
220
+ };
221
+ //# sourceMappingURL=Card-DX9nBx1S.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-DX9nBx1S.js","sources":["../src/components/LockedAttachment/components/_shared/useReceivedSource.ts","../src/components/LockedAttachment/components/Media/CardActions.tsx","../src/components/LockedAttachment/components/Media/Card.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type {\n FetchSourceHandler,\n LockedAttachmentSource,\n PaymentStatus,\n} from '../../types'\n\nexport interface UseReceivedSourceOptions {\n paymentStatus?: PaymentStatus\n onFetchSource?: FetchSourceHandler\n /** Called on Unlock click while the card is still unpaid (opens checkout). */\n onUnlockClick?: () => void\n}\n\nexport interface UseReceivedSourceResult {\n source: LockedAttachmentSource | undefined\n /** Attach to the card root so the paid-source auto-fetch can observe it. */\n cardRef: React.RefObject<HTMLDivElement>\n /** Fetches the source when already paid, else defers to `onUnlockClick`. */\n handleUnlockClick: () => void\n}\n\n/**\n * Media !isMine's source-reveal logic: unlike Composer/Media isMine's\n * tap-to-toggle (`usePreviewToggle`), the recipient's card reveals its source\n * by fetching once — on click when already paid, or automatically the first\n * time a paid card scrolls fully into view. The fetch is guarded so it runs\n * at most once in flight.\n */\nexport function useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n}: UseReceivedSourceOptions): UseReceivedSourceResult {\n const [source, setSource] = useState<LockedAttachmentSource | undefined>()\n\n const cardRef = useRef<HTMLDivElement>(null)\n const fetchingRef = useRef(false)\n\n const onFetchSourceRef = useRef(onFetchSource)\n onFetchSourceRef.current = onFetchSource\n\n const fetchSource = useCallback(async (): Promise<void> => {\n if (fetchingRef.current) return\n fetchingRef.current = true\n try {\n const result = await onFetchSourceRef.current?.()\n if (result) setSource(result)\n } finally {\n fetchingRef.current = false\n }\n }, [])\n\n const handleUnlockClick = useCallback(() => {\n if (paymentStatus === 'paid') {\n void fetchSource()\n } else {\n onUnlockClick?.()\n }\n }, [paymentStatus, fetchSource, onUnlockClick])\n\n // Auto-fetch the source once the paid card scrolls into view.\n useEffect(() => {\n if (!cardRef.current) return\n if (paymentStatus !== 'paid' || source !== undefined) return\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (entry.isIntersecting) {\n void fetchSource()\n observer.disconnect()\n }\n },\n { threshold: 1.0 }\n )\n\n observer.observe(cardRef.current)\n return () => observer.disconnect()\n }, [paymentStatus, source, fetchSource])\n\n return { source, cardRef, handleUnlockClick }\n}\n","import { DownloadSimpleIcon, LockSimpleIcon } from '@phosphor-icons/react'\nimport React from 'react'\n\nexport interface ReceivedCardActionsProps {\n /** Whether the card is currently locked. Drives which CTA we render. */\n isLocked: boolean\n /**\n * When unlocked, the URL used as the Download link's `href` (opens in a new\n * tab). When omitted, the Download CTA falls back to a plain `<button>`\n * that just calls `onDownloadClicked` — useful for galleries where the\n * single-source URL doesn't exist.\n */\n sourceUrl?: string\n /** Optional alternate href that takes precedence over `sourceUrl`. */\n redeemUrl?: string\n onUnlockClicked?: () => void\n onDownloadClicked?: () => void\n isUnlocking?: boolean\n}\n\nconst buttonClass =\n '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] disabled:opacity-70'\n\n/**\n * Renders the primary CTA below the body of a Received card.\n * - Locked + onUnlockClicked → \"Unlock\" button\n * - Unlocked + onDownloadClicked + (redeemUrl || sourceUrl) → \"Download\" link\n * - Unlocked + onDownloadClicked + no URL → \"Download\" button (e.g. gallery)\n * Otherwise renders nothing.\n */\nconst ReceivedCardActions: React.FC<ReceivedCardActionsProps> = ({\n isLocked,\n sourceUrl,\n redeemUrl,\n onUnlockClicked,\n onDownloadClicked,\n isUnlocking = false,\n}) => {\n if (isLocked && onUnlockClicked != null) {\n return (\n <button\n type=\"button\"\n onClick={onUnlockClicked}\n disabled={isUnlocking}\n className={buttonClass}\n >\n {isUnlocking ? (\n <span className=\"size-4 animate-spin rounded-full border-2 border-white/30 border-t-white\" />\n ) : (\n <React.Fragment>\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" />\n Unlock\n </React.Fragment>\n )}\n </button>\n )\n }\n\n if (!isLocked && onDownloadClicked != null) {\n const href = redeemUrl ?? sourceUrl\n if (href != null) {\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={onDownloadClicked}\n className={`${buttonClass} !text-white`}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </a>\n )\n }\n\n return (\n <button\n type=\"button\"\n onClick={onDownloadClicked}\n className={buttonClass}\n >\n <DownloadSimpleIcon className=\"size-4\" weight=\"bold\" />\n Download\n </button>\n )\n }\n\n return null\n}\n\nexport default ReceivedCardActions\n","import type React from 'react'\n\nimport { getSourceType } from '../../../AttachmentCard'\nimport type {\n FetchSourceHandler,\n LockedAttachmentGalleryItem,\n PaymentStatus,\n} from '../../types'\nimport CardBody from '../_shared/CardBody'\nimport CardThumbnail, {\n galleryBodyIcon,\n isGalleryCard,\n} from '../_shared/CardThumbnail'\nimport MediaShell from '../_shared/MediaShell'\nimport PreviewToggle from '../_shared/PreviewToggle'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport { usePreviewToggle } from '../_shared/usePreviewToggle'\nimport { useReceivedSource } from '../_shared/useReceivedSource'\n\nimport ReceivedCardActions from './CardActions'\n\ninterface MediaCardSharedProps {\n title?: string\n mimeType?: string\n thumbnailUrl?: string\n detail?: string\n amountText?: string\n paymentStatus?: PaymentStatus\n gallery?: LockedAttachmentGalleryItem[]\n onFetchSource?: FetchSourceHandler\n}\n\nexport type MediaCardProps =\n | (MediaCardSharedProps & {\n isMine: true\n /** Dimmed fallback shown in the title slot when `title` is unset. */\n placeholderTitle?: string\n /** Fired the first time the sender taps the thumbnail to preview their own attachment. */\n onPreviewClick?: () => void\n })\n | (MediaCardSharedProps & {\n isMine: false\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * Called when the recipient clicks Download on an unlocked card.\n * Omit to hide the Download button.\n */\n onDownloadClick?: () => void\n })\n\n/**\n * The sender's ('mine') view of a paid media attachment: the locked\n * thumbnail (single or gallery) they can tap to preview their own\n * attachment, plus the title/purchase-status body.\n */\nconst OwnMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: true\n placeholderTitle?: string\n onPreviewClick?: () => void\n }\n> = ({\n title,\n mimeType = 'application/octet-stream',\n thumbnailUrl,\n detail,\n amountText,\n placeholderTitle = 'Attachment title',\n paymentStatus = 'pending',\n gallery = [],\n onPreviewClick,\n onFetchSource,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n // Gallery is always previewable for the sender because each item's source\n // is already provided up-front via `gallery[*].sourceUrl`.\n const { source, isPreviewVisible, isLoadingPreview, togglePreview } =\n usePreviewToggle({ isGallery, onFetchSource, onPreviewClick })\n\n const showLocked = !isPreviewVisible\n const isBusy = isLoadingPreview\n\n return (\n <MediaShell variant=\"dark\">\n <PreviewToggle\n onToggle={togglePreview}\n isBusy={isBusy}\n isPreviewVisible={!showLocked}\n >\n <CardThumbnail\n variant=\"dark\"\n gallery={gallery}\n title={title}\n showLocked={showLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n />\n </PreviewToggle>\n\n <CardBody\n variant=\"dark\"\n title={title}\n placeholderTitle={placeholderTitle}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={true}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('dark') : undefined}\n />\n </MediaShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid media attachment: the locked\n * thumbnail (single or gallery) with an Unlock/Download CTA. The source is\n * revealed by fetching once — on click when already paid, or automatically\n * the first time a paid card scrolls into view.\n */\nconst OtherMediaCard: React.FC<\n MediaCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n onDownloadClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n title,\n amountText,\n thumbnailUrl,\n mimeType = 'application/octet-stream',\n detail,\n gallery = [],\n onUnlockClick,\n onFetchSource,\n onDownloadClick,\n paymentStatus,\n isUnlocking = false,\n}) => {\n const isGallery = isGalleryCard(gallery)\n\n const { source, cardRef, handleUnlockClick } = useReceivedSource({\n paymentStatus,\n onFetchSource,\n onUnlockClick,\n })\n\n const effectiveSourceUrl = source?.sourceUrl\n const effectiveRedeemUrl = source?.redeemUrl\n\n // For gallery, the per-item sources are carried by `gallery` itself, so\n // the lock state is driven by paymentStatus rather than the single\n // `effectiveSourceUrl`. Everything else still respects the source fetch.\n const isLocked = isGallery\n ? paymentStatus !== 'paid'\n : effectiveSourceUrl === undefined\n const sourceType = getSourceType(mimeType)\n\n // For gallery, ReceivedCardActions falls back to a plain <button>\n // (no anchor) because the gallery has no single sourceUrl to link to —\n // the per-item sources live on `gallery` itself.\n const actionSourceUrl = isGallery ? undefined : effectiveSourceUrl\n\n return (\n <MediaShell\n variant=\"light\"\n rootRef={cardRef}\n data-testid=\"locked-attachment\"\n >\n <CardThumbnail\n variant=\"light\"\n gallery={gallery}\n title={title}\n showLocked={isLocked}\n paymentStatus={paymentStatus}\n mimeType={mimeType}\n thumbnailUrl={thumbnailUrl}\n source={source}\n containedImage={\n !isLocked && (sourceType === 'image' || sourceType === 'document')\n }\n />\n\n <CardBody\n variant=\"light\"\n title={title}\n mimeType={mimeType}\n detail={detail}\n statusBadge={\n <PurchaseStatusBadge\n isMine={false}\n paymentStatus={paymentStatus}\n amountText={amountText}\n />\n }\n icon={isGallery ? galleryBodyIcon('light') : undefined}\n action={\n <ReceivedCardActions\n isLocked={isLocked}\n isUnlocking={isUnlocking}\n sourceUrl={actionSourceUrl}\n redeemUrl={effectiveRedeemUrl}\n onUnlockClicked={handleUnlockClick}\n onDownloadClicked={onDownloadClick}\n />\n }\n />\n </MediaShell>\n )\n}\n\n/**\n * The card either party sees for a paid media attachment. `isMine` selects\n * the sender's preview view (tap-to-preview own draft) vs. the recipient's\n * unlock/download view.\n */\nconst MediaCard: React.FC<MediaCardProps> = (props) =>\n props.isMine ? <OwnMediaCard {...props} /> : <OtherMediaCard {...props} />\n\nexport default MediaCard\n"],"names":["useReceivedSource","paymentStatus","onFetchSource","onUnlockClick","source","setSource","useState","cardRef","useRef","fetchingRef","onFetchSourceRef","fetchSource","useCallback","result","_a","handleUnlockClick","useEffect","observer","entry","buttonClass","ReceivedCardActions","isLocked","sourceUrl","redeemUrl","onUnlockClicked","onDownloadClicked","isUnlocking","jsx","jsxs","React","LockSimpleIcon","href","DownloadSimpleIcon","OwnMediaCard","title","mimeType","thumbnailUrl","detail","amountText","placeholderTitle","gallery","onPreviewClick","isGallery","isGalleryCard","isPreviewVisible","isLoadingPreview","togglePreview","usePreviewToggle","showLocked","MediaShell","PreviewToggle","CardThumbnail","CardBody","PurchaseStatusBadge","galleryBodyIcon","OtherMediaCard","onDownloadClick","effectiveSourceUrl","effectiveRedeemUrl","sourceType","getSourceType","actionSourceUrl","MediaCard","props"],"mappings":";;;;;;;AA8BO,SAASA,EAAkB;AAAA,EAChC,eAAAC;AAAA,EACA,eAAAC;AAAA,EACA,eAAAC;AACF,GAAsD;AACpD,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAA,GAEtBC,IAAUC,EAAuB,IAAI,GACrCC,IAAcD,EAAO,EAAK,GAE1BE,IAAmBF,EAAON,CAAa;AAC7C,EAAAQ,EAAiB,UAAUR;AAE3B,QAAMS,IAAcC,EAAY,YAA2B;;AACzD,QAAI,CAAAH,EAAY,SAChB;AAAA,MAAAA,EAAY,UAAU;AACtB,UAAI;AACF,cAAMI,IAAS,QAAMC,IAAAJ,EAAiB,YAAjB,gBAAAI,EAAA,KAAAJ;AACrB,QAAIG,OAAkBA,CAAM;AAAA,MAC9B,UAAA;AACE,QAAAJ,EAAY,UAAU;AAAA,MACxB;AAAA;AAAA,EACF,GAAG,CAAA,CAAE,GAECM,IAAoBH,EAAY,MAAM;AAC1C,IAAIX,MAAkB,SACfU,EAAA,IAELR,KAAA,QAAAA;AAAA,EAEJ,GAAG,CAACF,GAAeU,GA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,YACZ,eAAApB;AAAA,YACA,UAAAkC;AAAA,YACA,cAAAC;AAAA,YACA,QAAAhC;AAAA,YACA,gBACE,CAACiB,MAAasC,MAAe,WAAWA,MAAe;AAAA,UAAA;AAAA,QAAA;AAAA,QAI3D,gBAAAhC;AAAA,UAACyB;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,OAAAlB;AAAA,YACA,UAAAC;AAAA,YACA,QAAAE;AAAA,YACA,aACE,gBAAAV;AAAA,cAAC0B;AAAA,cAAA;AAAA,gBACC,QAAQ;AAAA,gBACR,eAAApD;AAAA,gBACA,YAAAqC;AAAA,cAAA;AAAA,YAAA;AAAA,YAGJ,MAAMI,IAAYY,EAAgB,OAAO,IAAI;AAAA,YAC7C,QACE,gBAAA3B;AAAA,cAACP;AAAA,cAAA;AAAA,gBACC,UAAAC;AAAA,gBACA,aAAAK;AAAA,gBACA,WAAWmC;AAAA,gBACX,WAAWH;AAAA,gBACX,iBAAiB3C;AAAA,gBACjB,mBAAmByC;AAAA,cAAA;AAAA,YAAA;AAAA,UACrB;AAAA,QAAA;AAAA,MAEJ;AAAA,IAAA;AAAA,EAAA;AAGN,GAOMM,IAAsC,CAACC,MAC3CA,EAAM,SAAS,gBAAApC,EAACM,GAAA,EAAc,GAAG8B,EAAA,CAAO,IAAK,gBAAApC,EAAC4B,GAAA,EAAgB,GAAGQ,EAAA,CAAO;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),u=require("@phosphor-icons/react"),l=require("./TextShell-Bnzh0T75.cjs"),c=require("./PurchaseStatusBadge-UjDzZhLj.cjs"),o=require("classnames"),t=({cx:s,index:i})=>e.jsx("circle",{cx:s,cy:"6.15",r:"2.4",fill:"currentColor",children:e.jsx("animateTransform",{attributeName:"transform",type:"translate",values:"0 0; 0 -2.25; 0 0;",dur:"900ms",begin:`${120*i}ms`,repeatCount:"indefinite"})}),j=({className:s})=>e.jsxs("svg",{"aria-hidden":"true",className:s,viewBox:"0 0 20 12.3",width:"20",height:"13",overflow:"visible",children:[e.jsx(t,{cx:"3",index:0}),e.jsx(t,{cx:"10",index:1}),e.jsx(t,{cx:"17",index:2})]}),x=({variant:s="dark",animate:i=!0})=>{const r=i?"animate-pulse motion-reduce:animate-none":"",a=s==="dark"?"bg-white/25":"bg-black/15";return e.jsxs("div",{className:"flex flex-col gap-2 str-chat__message-text my-1","aria-hidden":!0,children:[e.jsx("div",{className:o("h-3 w-40 rounded-full",r,a)}),e.jsx("div",{className:o("h-3 w-24 rounded-full",r,a)})]})},f=({amountText:s,paymentStatus:i="pending",children:r})=>{const a=i==="failed";if(i==="paid"&&r)return e.jsxs(l.TextShell,{children:[r,e.jsx("span",{className:"sr-only","aria-live":"polite",children:"Sold."}),e.jsxs(l.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"text-white/55",children:s}),e.jsx(c.PurchaseStatusBadge,{isMine:!0,paymentStatus:i})]})]});const d=a?"Payment failed.":i==="refunded"?"Refunded.":"Payment pending.";return e.jsxs(l.TextShell,{children:[e.jsx(x,{variant:"dark",animate:i==="pending"}),e.jsx("span",{className:"sr-only","aria-live":"polite",children:d}),e.jsxs(l.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"text-white/55",children:s}),e.jsx(c.PurchaseStatusBadge,{isMine:!0,paymentStatus:i})]})]})},m=({amountText:s,paymentStatus:i,onUnlockClick:r,isUnlocking:a=!1,children:n})=>{if(i==="paid"&&n)return e.jsxs(l.TextShell,{children:[n,e.jsxs(l.PriceLockRow,{children:[s!=null&&e.jsx("span",{className:"opacity-55",children:s}),e.jsx(c.PurchaseStatusBadge,{isMine:!1,paymentStatus:"paid"})]})]});const h=a?"Unlocking.":"Locked message available to unlock.";return e.jsx(l.TextShell,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"flex flex-1 flex-col gap-2",children:[e.jsx(x,{variant:"light",animate:a}),e.jsx("span",{className:"sr-only","aria-live":"polite",children:h}),e.jsx(l.PriceLockRow,{children:s!=null&&e.jsx("span",{className:"opacity-55",children:s})})]}),e.jsx("button",{type:"button",onClick:r,disabled:a,"aria-label":a?"Unlocking":"Unlock","aria-busy":a,title:a?"Unlocking":"Unlock",className:"flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]",children:a?e.jsx(j,{}):e.jsx(u.LockSimpleIcon,{className:"size-4",weight:"fill","aria-hidden":!0})})]})})},g=s=>s.isMine?e.jsx(f,{...s}):e.jsx(m,{...s});exports.default=g;
2
+ //# sourceMappingURL=Card-iKTcn1wg.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Card-iKTcn1wg.cjs","sources":["../src/components/LockedAttachment/components/_shared/LoadingDots.tsx","../src/components/LockedAttachment/components/_shared/SkeletonTextLines.tsx","../src/components/LockedAttachment/components/Text/Card.tsx"],"sourcesContent":["import React from 'react'\n\nconst Dot = ({ cx, index }: { cx: string; index: number }) => (\n <circle cx={cx} cy=\"6.15\" r=\"2.4\" fill=\"currentColor\">\n <animateTransform\n attributeName=\"transform\"\n type=\"translate\"\n values=\"0 0; 0 -2.25; 0 0;\"\n dur=\"900ms\"\n begin={`${120 * index}ms`}\n repeatCount=\"indefinite\"\n />\n </circle>\n)\n\n/**\n * Three bouncing dots, inline-sized for use inside buttons/labels (e.g. the\n * Unlock CTA while a purchase is in flight). Mirrors the typing indicator's\n * animation but uses `currentColor` so it adopts the surrounding text color.\n */\nconst LoadingDots: React.FC<{ className?: string }> = ({ className }) => (\n <svg\n aria-hidden=\"true\"\n className={className}\n viewBox=\"0 0 20 12.3\"\n width=\"20\"\n height=\"13\"\n overflow=\"visible\"\n >\n <Dot cx=\"3\" index={0} />\n <Dot cx=\"10\" index={1} />\n <Dot cx=\"17\" index={2} />\n </svg>\n)\n\nexport default LoadingDots\n","import classNames from 'classnames'\nimport React from 'react'\n\nexport interface SkeletonTextLinesProps {\n /** Matches the bubble it sits in — \"dark\" for the sender's own bubble. */\n variant: 'light' | 'dark'\n /**\n * Whether the bars pulse. Pass `false` once the outcome is settled (paid,\n * failed, refunded) — a static skeleton reads as \"nothing more will\n * change\", while a pulsing one implies something is still in flight.\n */\n animate: boolean\n}\n\n/**\n * Two skeleton bars standing in for the redacted text of a paid text-only\n * message — the real content is never sent to the client until purchase, so\n * there's nothing to render yet.\n *\n * Uses explicit black/white (not `bg-current`) because Tailwind doesn't\n * support opacity modifiers on the `current` color — `bg-current/30` silently\n * produces no CSS rule at all.\n */\nconst SkeletonTextLines: React.FC<SkeletonTextLinesProps> = ({\n variant = 'dark',\n animate = true,\n}) => {\n const pulse = animate ? 'animate-pulse motion-reduce:animate-none' : ''\n const colour = variant === 'dark' ? 'bg-white/25' : 'bg-black/15'\n\n return (\n <div className=\"flex flex-col gap-2 str-chat__message-text my-1\" aria-hidden>\n <div className={classNames('h-3 w-40 rounded-full', pulse, colour)} />\n <div className={classNames('h-3 w-24 rounded-full', pulse, colour)} />\n </div>\n )\n}\n\nexport default SkeletonTextLines\n","import { LockSimpleIcon } from '@phosphor-icons/react'\nimport type React from 'react'\n\nimport type { PaymentStatus } from '../../types'\nimport LoadingDots from '../_shared/LoadingDots'\nimport PriceLockRow from '../_shared/PriceLockRow'\nimport PurchaseStatusBadge from '../_shared/PurchaseStatusBadge'\nimport SkeletonTextLines from '../_shared/SkeletonTextLines'\nimport TextShell from '../_shared/TextShell'\n\ninterface TextCardSharedProps {\n amountText?: string\n paymentStatus?: PaymentStatus\n /**\n * The message's real, revealed content — shown instead of the skeleton\n * loader once `paymentStatus` is `'paid'`. Ignored otherwise. Lets the\n * caller supply its own text renderer (e.g. Stream's `MessageText`)\n * without `LockedAttachment` depending on it.\n */\n children?: React.ReactNode\n}\n\nexport type TextCardProps =\n | (TextCardSharedProps & {\n isMine: true\n })\n | (TextCardSharedProps & {\n isMine: false\n /**\n * Called when the recipient clicks Unlock on an unpaid attachment.\n * Use this to open a checkout flow. Omit to hide the Unlock button.\n */\n onUnlockClick?: () => void\n /**\n * When true, shows a loading spinner on the Unlock button. Driven by\n * the LockedAttachmentContext (e.g. checkout in progress).\n */\n isUnlocking?: boolean\n })\n\n/**\n * The sender's ('mine') view of a paid text-only message: an outgoing chat\n * bubble showing a skeleton text loader in place of the redacted content (or\n * `children`, once paid), plus a lock/price/status row.\n */\nconst OwnTextCard: React.FC<TextCardSharedProps & { isMine: true }> = ({\n amountText,\n paymentStatus = 'pending',\n children,\n}) => {\n const isFailed = paymentStatus === 'failed'\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell>\n {children}\n <span className=\"sr-only\" aria-live=\"polite\">\n Sold.\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const liveMessage = isFailed\n ? 'Payment failed.'\n : paymentStatus === 'refunded'\n ? 'Refunded.'\n : 'Payment pending.'\n\n return (\n <TextShell>\n <SkeletonTextLines variant=\"dark\" animate={paymentStatus === 'pending'} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {liveMessage}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"text-white/55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={true} paymentStatus={paymentStatus} />\n </PriceLockRow>\n </TextShell>\n )\n}\n\n/**\n * The recipient's ('other') view of a paid text-only message: a plain chat\n * bubble whose content is a skeleton text loader (or `children`, once paid)\n * plus a lock/price/status row. Two pre-purchase states exist — idle and\n * unlocking (checkout in flight) — plus the revealed state once\n * `paymentStatus` is `'paid'`.\n */\nconst OtherTextCard: React.FC<\n TextCardSharedProps & {\n isMine: false\n onUnlockClick?: () => void\n isUnlocking?: boolean\n }\n> = ({\n amountText,\n paymentStatus,\n onUnlockClick,\n isUnlocking = false,\n children,\n}) => {\n const isPaid = paymentStatus === 'paid'\n\n if (isPaid && children) {\n return (\n <TextShell>\n {children}\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n <PurchaseStatusBadge isMine={false} paymentStatus=\"paid\" />\n </PriceLockRow>\n </TextShell>\n )\n }\n\n const ariaLabel = isUnlocking\n ? 'Unlocking.'\n : 'Locked message available to unlock.'\n\n return (\n <TextShell>\n <div className=\"flex items-center gap-3\">\n <div className=\"flex flex-1 flex-col gap-2\">\n <SkeletonTextLines variant=\"light\" animate={isUnlocking} />\n <span className=\"sr-only\" aria-live=\"polite\">\n {ariaLabel}\n </span>\n <PriceLockRow>\n {amountText != null && (\n <span className=\"opacity-55\">{amountText}</span>\n )}\n </PriceLockRow>\n </div>\n <button\n type=\"button\"\n onClick={onUnlockClick}\n disabled={isUnlocking}\n aria-label={isUnlocking ? 'Unlocking' : 'Unlock'}\n aria-busy={isUnlocking}\n title={isUnlocking ? 'Unlocking' : 'Unlock'}\n className=\"flex size-10 shrink-0 items-center justify-center rounded-full bg-[#121110] text-white hover:bg-[#2a2928]\"\n >\n {isUnlocking ? (\n <LoadingDots />\n ) : (\n <LockSimpleIcon className=\"size-4\" weight=\"fill\" aria-hidden />\n )}\n </button>\n </div>\n </TextShell>\n )\n}\n\n/**\n * The card either party sees for a paid text-only message — a chat bubble\n * showing a skeleton text loader (or `children`, once revealed) plus a\n * lock/price/status row. `isMine` selects the sender's payment-lifecycle view\n * (pending/failed/refunded/paid + Dismiss) vs. the recipient's unlock-flow\n * view (idle/unlocking + Unlock CTA).\n */\nconst TextCard: React.FC<TextCardProps> = (props) =>\n props.isMine ? <OwnTextCard {...props} /> : <OtherTextCard {...props} />\n\nexport default TextCard\n"],"names":["Dot","cx","index","jsx","LoadingDots","className","jsxs","SkeletonTextLines","variant","animate","pulse","colour","classNames","OwnTextCard","amountText","paymentStatus","children","isFailed","TextShell","PriceLockRow","PurchaseStatusBadge","liveMessage","OtherTextCard","onUnlockClick","isUnlocking","ariaLabel","LockSimpleIcon","TextCard","props"],"mappings":"sQAEMA,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AtB,EAAAA,IAACgB,EAAAA,cACE,SAAAL,GAAc,YACZ,OAAA,CAAK,UAAU,aAAc,SAAAA,CAAA,CAAW,CAAA,CAE7C,CAAA,EACF,EACAX,EAAAA,IAAC,SAAA,CACC,KAAK,SACL,QAASoB,EACT,SAAUC,EACV,aAAYA,EAAc,YAAc,SACxC,YAAWA,EACX,MAAOA,EAAc,YAAc,SACnC,UAAU,4GAET,SAAAA,EACCrB,EAAAA,IAACC,EAAA,CAAA,CAAY,EAEbD,EAAAA,IAACuB,EAAAA,eAAA,CAAe,UAAU,SAAS,OAAO,OAAO,cAAW,EAAA,CAAC,CAAA,CAAA,CAEjE,CAAA,CACF,CAAA,CACF,CAEJ,EASMC,EAAqCC,GACzCA,EAAM,OAASzB,EAAAA,IAACU,EAAA,CAAa,GAAGe,CAAA,CAAO,EAAKzB,EAAAA,IAACmB,EAAA,CAAe,GAAGM,CAAA,CAAO"}
@@ -0,0 +1,108 @@
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import { XIcon as m, PencilSimpleIcon as z } from "@phosphor-icons/react";
3
+ import B from "react";
4
+ import { i as j, u as T, M as I, P as L, C as M, a as R, g as S } from "./usePreviewToggle-BG-pfsgP.js";
5
+ import { T as A, P as G } from "./TextShell-BiqF2UB0.js";
6
+ const V = ({
7
+ text: t,
8
+ amountText: i,
9
+ placeholderAmountText: s,
10
+ onDismiss: a
11
+ }) => /* @__PURE__ */ r(A, { children: [
12
+ /* @__PURE__ */ e("div", { className: "pr-8", children: t }),
13
+ /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("span", { className: i ? "text-white/55" : "text-white/30", children: i || s }) }),
14
+ a && /* @__PURE__ */ e(
15
+ "button",
16
+ {
17
+ type: "button",
18
+ onClick: a,
19
+ className: "absolute right-3 top-3 flex size-6 shrink-0 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
20
+ "aria-label": "Dismiss attachment",
21
+ children: /* @__PURE__ */ e(m, { className: "size-3", weight: "bold" })
22
+ }
23
+ )
24
+ ] }), F = ({
25
+ title: t,
26
+ mimeType: i = "application/octet-stream",
27
+ thumbnailUrl: s,
28
+ detail: a,
29
+ amountText: o,
30
+ placeholderTitle: u = "Attachment title",
31
+ placeholderAmountText: g,
32
+ gallery: n = [],
33
+ onDismiss: l,
34
+ onPreviewClick: w,
35
+ onFetchSource: x,
36
+ onEditClick: c
37
+ }) => {
38
+ const d = j(n), { source: b, isPreviewVisible: p, isLoadingPreview: f, togglePreview: v } = T({ isGallery: d, onFetchSource: x, onPreviewClick: w }), h = !p, C = f, y = /* @__PURE__ */ r(B.Fragment, { children: [
39
+ /* @__PURE__ */ e("span", { className: "text-xs font-medium text-white/55", children: "•" }),
40
+ /* @__PURE__ */ e(
41
+ "span",
42
+ {
43
+ className: o ? "text-xs font-medium text-white/55" : "text-xs font-medium text-white/30",
44
+ children: o || g
45
+ }
46
+ )
47
+ ] }), P = l ? /* @__PURE__ */ e(
48
+ "button",
49
+ {
50
+ type: "button",
51
+ onClick: (k) => {
52
+ k.stopPropagation(), l();
53
+ },
54
+ className: "flex size-6 items-center justify-center rounded-full bg-[#121110] text-white",
55
+ "aria-label": "Dismiss attachment",
56
+ children: /* @__PURE__ */ e(m, { className: "size-3", weight: "bold" })
57
+ }
58
+ ) : void 0, N = c ? /* @__PURE__ */ e(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ onClick: c,
63
+ "aria-label": "Edit attachment",
64
+ className: "flex size-10 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/15",
65
+ children: /* @__PURE__ */ e(z, { className: "size-5", weight: "regular" })
66
+ }
67
+ ) : void 0;
68
+ return /* @__PURE__ */ r(I, { variant: "dark", children: [
69
+ /* @__PURE__ */ e(
70
+ L,
71
+ {
72
+ onToggle: v,
73
+ isBusy: C,
74
+ isPreviewVisible: !h,
75
+ children: /* @__PURE__ */ e(
76
+ M,
77
+ {
78
+ variant: "dark",
79
+ gallery: n,
80
+ title: t,
81
+ showLocked: h,
82
+ mimeType: i,
83
+ thumbnailUrl: s,
84
+ source: b,
85
+ topRight: P
86
+ }
87
+ )
88
+ }
89
+ ),
90
+ /* @__PURE__ */ e(
91
+ R,
92
+ {
93
+ variant: "dark",
94
+ title: t,
95
+ placeholderTitle: u,
96
+ mimeType: i,
97
+ detail: a,
98
+ statusBadge: y,
99
+ icon: d ? S("dark") : void 0,
100
+ trailingAction: N
101
+ }
102
+ )
103
+ ] });
104
+ }, J = (t) => t.contentType === "text" ? /* @__PURE__ */ e(V, { ...t }) : /* @__PURE__ */ e(F, { ...t });
105
+ export {
106
+ J as default
107
+ };
108
+ //# sourceMappingURL=Card-qDLtjK6u.js.map