@eka-care/medassist-widget 0.1.98-0 → 0.1.98-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,179 @@
1
+ import { c as d, A as v, d as w, y as C, u as e, s as L, p as P, F as _, S as j, B as D } from "./medassist-widget.js";
2
+ const R = [
3
+ [
4
+ "path",
5
+ {
6
+ d: "M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",
7
+ key: "18u6gg"
8
+ }
9
+ ],
10
+ ["circle", { cx: "12", cy: "13", r: "3", key: "1vg3eu" }]
11
+ ], F = d("camera", R);
12
+ const $ = [
13
+ ["path", { d: "M12 15V3", key: "m9g1x1" }],
14
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
15
+ ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
16
+ ], M = d("download", $);
17
+ const U = [
18
+ ["line", { x1: "2", x2: "22", y1: "2", y2: "22", key: "a6p6uj" }],
19
+ ["path", { d: "M10.41 10.41a2 2 0 1 1-2.83-2.83", key: "1bzlo9" }],
20
+ ["line", { x1: "13.5", x2: "6", y1: "13.5", y2: "21", key: "1q0aeu" }],
21
+ ["line", { x1: "18", x2: "21", y1: "12", y2: "15", key: "5mozeu" }],
22
+ [
23
+ "path",
24
+ {
25
+ d: "M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59",
26
+ key: "mmje98"
27
+ }
28
+ ],
29
+ ["path", { d: "M21 15V5a2 2 0 0 0-2-2H9", key: "43el77" }]
30
+ ], T = d("image-off", U);
31
+ const z = [
32
+ ["rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2", key: "1w4ew1" }],
33
+ ["path", { d: "M7 11V7a5 5 0 0 1 10 0v4", key: "fwvmzm" }]
34
+ ], A = d("lock", z);
35
+ function x(a) {
36
+ try {
37
+ return new URL(a, window.location.href).pathname.toLowerCase().endsWith(".pdf");
38
+ } catch {
39
+ return a.toLowerCase().split("?")[0].endsWith(".pdf");
40
+ }
41
+ }
42
+ function E(a, n = "download.pdf") {
43
+ try {
44
+ const t = new URL(a, window.location.href).pathname.split("/").pop();
45
+ return t ? decodeURIComponent(t) : n;
46
+ } catch {
47
+ return a.split("?")[0].split("/").pop() || n;
48
+ }
49
+ }
50
+ async function H(a) {
51
+ try {
52
+ const n = await fetch(a, { headers: { Range: "bytes=-4096" } });
53
+ if (!n.ok && n.status !== 206) return "error";
54
+ const t = await n.arrayBuffer();
55
+ return new TextDecoder("latin1").decode(t.slice(-4096)).includes("/Encrypt") ? "protected" : "ok";
56
+ } catch {
57
+ return "unknown";
58
+ }
59
+ }
60
+ function y(a, n) {
61
+ const t = document.createElement("a");
62
+ t.href = a, t.download = n, document.body.appendChild(t), t.click(), t.remove();
63
+ }
64
+ async function I(a) {
65
+ const n = E(a);
66
+ try {
67
+ const t = await fetch(a);
68
+ if (!t.ok) throw new Error(`HTTP ${t.status}`);
69
+ const o = URL.createObjectURL(await t.blob());
70
+ y(o, n), URL.revokeObjectURL(o);
71
+ } catch {
72
+ const t = document.createElement("a");
73
+ t.href = a, t.download = n, t.target = "_blank", t.rel = "noopener", document.body.appendChild(t), t.click(), t.remove();
74
+ }
75
+ }
76
+ async function g(a, n) {
77
+ if (a.current)
78
+ try {
79
+ const t = (await import("./medassist-widget-html2canvas.esm-CphxV6YW.js")).default, o = await t(a.current, { useCORS: !0 });
80
+ y(o.toDataURL("image/png"), n);
81
+ } catch {
82
+ }
83
+ }
84
+ function S({ card: a }) {
85
+ const { title: n, description: t, tags_text: o, banner_text: m, action: s, link: r } = a, i = v(null), [b, f] = w(!1), [c, h] = w(
86
+ "loading"
87
+ ), u = !!r && x(r), l = !!r && !u;
88
+ C(() => {
89
+ if (f(!1), !r || !x(r)) return;
90
+ let p = !1;
91
+ return h("loading"), H(r).then((k) => {
92
+ p || h(k);
93
+ }), () => {
94
+ p = !0;
95
+ };
96
+ }, [r]);
97
+ const N = () => {
98
+ s === "screenshot" ? g(i, `screenshot-${Date.now()}.png`) : s === "download" && (u && r ? I(r) : g(i, "card.png"));
99
+ };
100
+ return /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: [
101
+ /* @__PURE__ */ e(
102
+ L,
103
+ {
104
+ ref: i,
105
+ className: "overflow-hidden rounded-xl border border-border bg-elicitationBg text-card-foreground shadow-sm",
106
+ children: /* @__PURE__ */ e(P, { className: "p-3 space-y-2", children: [
107
+ /* @__PURE__ */ e("div", { className: `flex items-start gap-3 ${l ? "justify-between" : "justify-center"}`, children: [
108
+ /* @__PURE__ */ e("div", { className: `space-y-2 ${l ? "min-w-0 flex-1" : "flex flex-col items-center"}`, children: [
109
+ n && /* @__PURE__ */ e("span", { className: "inline-block rounded-full px-3 py-1 text-sm font-semibold bg-primary text-primary-foreground", children: n }),
110
+ t && /* @__PURE__ */ e("p", { className: `text-sm text-foreground leading-snug ${l ? "" : "text-center"}`, children: t }),
111
+ m && /* @__PURE__ */ e("span", { className: "inline-block rounded-full px-3 py-1 text-xs font-semibold bg-green-600 text-white", children: m })
112
+ ] }),
113
+ l && /* @__PURE__ */ e("div", { className: "shrink-0 h-24 w-24 rounded-lg overflow-hidden border border-border", children: b ? /* @__PURE__ */ e("div", { className: "flex h-full w-full items-center justify-center bg-muted text-muted-foreground", children: /* @__PURE__ */ e(T, { className: "h-6 w-6" }) }) : /* @__PURE__ */ e(
114
+ "img",
115
+ {
116
+ src: r,
117
+ alt: n ?? "media",
118
+ className: "h-full w-full object-cover",
119
+ onError: () => f(!0)
120
+ }
121
+ ) })
122
+ ] }),
123
+ u && /* @__PURE__ */ e(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ onClick: () => window.open(r, "_blank", "noopener,noreferrer"),
128
+ className: "relative w-full h-48 sm:h-72 md:h-80 max-h-[70vh] rounded-lg border border-border overflow-hidden cursor-pointer p-0 bg-transparent",
129
+ "aria-label": `Open ${n ?? "PDF"}`,
130
+ children: [
131
+ c === "loading" && /* @__PURE__ */ e("div", { className: "h-full w-full animate-pulse bg-muted" }),
132
+ (c === "ok" || c === "unknown") && /* @__PURE__ */ e(
133
+ "iframe",
134
+ {
135
+ src: r,
136
+ title: n ?? "PDF preview",
137
+ className: "w-full h-full pointer-events-none"
138
+ }
139
+ ),
140
+ c === "protected" && /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 bg-muted/50 text-muted-foreground", children: [
141
+ /* @__PURE__ */ e(A, { className: "h-8 w-8" }),
142
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-foreground", children: "Password-protected PDF" }),
143
+ /* @__PURE__ */ e("span", { className: "text-xs", children: "Tap to open and unlock" })
144
+ ] }),
145
+ c === "error" && /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 bg-muted/50 text-muted-foreground", children: [
146
+ /* @__PURE__ */ e(_, { className: "h-8 w-8" }),
147
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium text-foreground", children: "PDF" }),
148
+ /* @__PURE__ */ e("span", { className: "text-xs", children: "Tap to open" })
149
+ ] }),
150
+ /* @__PURE__ */ e("span", { className: "absolute inset-0", "aria-hidden": "true" })
151
+ ]
152
+ }
153
+ ),
154
+ o && /* @__PURE__ */ e(j, { children: [
155
+ /* @__PURE__ */ e("div", { className: "border-t border-border" }),
156
+ /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: o })
157
+ ] })
158
+ ] })
159
+ }
160
+ ),
161
+ s && /* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(
162
+ D,
163
+ {
164
+ type: "button",
165
+ variant: "outline",
166
+ size: "sm",
167
+ className: "rounded-md px-5 gap-1.5",
168
+ onClick: N,
169
+ children: [
170
+ s === "screenshot" ? /* @__PURE__ */ e(F, { className: "h-4 w-4" }) : /* @__PURE__ */ e(M, { className: "h-4 w-4" }),
171
+ s === "screenshot" ? "Screenshot" : "Download"
172
+ ]
173
+ }
174
+ ) })
175
+ ] });
176
+ }
177
+ export {
178
+ S as MediaCard
179
+ };