artifactuse 0.1.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.
- package/LICENSE +21 -0
- package/README.md +771 -0
- package/dist/core/bridge.d.ts +37 -0
- package/dist/core/detector.d.ts +134 -0
- package/dist/core/highlight.d.ts +53 -0
- package/dist/core/index.d.ts +124 -0
- package/dist/core/processors/audio.d.ts +36 -0
- package/dist/core/processors/audioPlayer.d.ts +39 -0
- package/dist/core/processors/codeEmbed.d.ts +58 -0
- package/dist/core/processors/dataViz.d.ts +28 -0
- package/dist/core/processors/design.d.ts +50 -0
- package/dist/core/processors/document.d.ts +38 -0
- package/dist/core/processors/image.d.ts +23 -0
- package/dist/core/processors/index.d.ts +62 -0
- package/dist/core/processors/interactive.d.ts +57 -0
- package/dist/core/processors/map.d.ts +29 -0
- package/dist/core/processors/math.d.ts +75 -0
- package/dist/core/processors/mermaid.d.ts +72 -0
- package/dist/core/processors/social.d.ts +63 -0
- package/dist/core/processors/table.d.ts +43 -0
- package/dist/core/processors/video.d.ts +69 -0
- package/dist/core/state.d.ts +37 -0
- package/dist/core/theme.d.ts +109 -0
- package/dist/index-_nD5FZzs.js +4300 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +115 -0
- package/dist/jszip.min-CdmYyw5L.js +2324 -0
- package/dist/react/ArtifactuseAgentMessage.d.ts +31 -0
- package/dist/react/ArtifactuseCard.d.ts +13 -0
- package/dist/react/ArtifactuseInlineForm.d.ts +16 -0
- package/dist/react/ArtifactusePanel.d.ts +12 -0
- package/dist/react/ArtifactusePanelToggle.d.ts +8 -0
- package/dist/react/ArtifactuseSocialPreview.d.ts +6 -0
- package/dist/react/ArtifactuseViewer.d.ts +14 -0
- package/dist/react/index.d.ts +108 -0
- package/dist/react/index.js +1387 -0
- package/dist/svelte/index.d.ts +439 -0
- package/dist/svelte/index.js +2556 -0
- package/dist/vue/index.d.ts +296 -0
- package/dist/vue/index.js +2745 -0
- package/dist/vue2/composables.d.ts +291 -0
- package/dist/vue2/index.d.ts +10 -0
- package/dist/vue2/index.js +27979 -0
- package/package.json +127 -0
|
@@ -0,0 +1,1387 @@
|
|
|
1
|
+
import e, { useState as C, useMemo as $, useCallback as d, useRef as W, useEffect as z, createContext as Ze, useContext as Ke } from "react";
|
|
2
|
+
import { g as we, f as je, a as qe, b as Re, n as Ye, i as Ge, D as Oe, c as Qe } from "../index-_nD5FZzs.js";
|
|
3
|
+
import { J as et } from "../jszip.min-CdmYyw5L.js";
|
|
4
|
+
import { createPortal as tt } from "react-dom";
|
|
5
|
+
function at({
|
|
6
|
+
artifact: t,
|
|
7
|
+
isActive: a = !1,
|
|
8
|
+
onOpen: n,
|
|
9
|
+
onCopy: l,
|
|
10
|
+
onDownload: s,
|
|
11
|
+
className: r = ""
|
|
12
|
+
}) {
|
|
13
|
+
const [p, u] = C(!1), g = $(() => we(t.language), [t.language]), c = $(() => {
|
|
14
|
+
var k;
|
|
15
|
+
return je(t.size || ((k = t.code) == null ? void 0 : k.length) || 0);
|
|
16
|
+
}, [t.size, t.code]), b = $(() => qe(t.language), [t.language]), P = d((k) => {
|
|
17
|
+
k.stopPropagation(), n && n(t);
|
|
18
|
+
}, [t, n]), x = d(async (k) => {
|
|
19
|
+
k.stopPropagation();
|
|
20
|
+
try {
|
|
21
|
+
await navigator.clipboard.writeText(t.code), u(!0), l && l(t), setTimeout(() => {
|
|
22
|
+
u(!1);
|
|
23
|
+
}, 2e3);
|
|
24
|
+
} catch {
|
|
25
|
+
const v = document.createElement("textarea");
|
|
26
|
+
v.value = t.code, v.style.position = "fixed", v.style.opacity = "0", document.body.appendChild(v), v.select();
|
|
27
|
+
try {
|
|
28
|
+
document.execCommand("copy"), u(!0), l && l(t), setTimeout(() => {
|
|
29
|
+
u(!1);
|
|
30
|
+
}, 2e3);
|
|
31
|
+
} catch (F) {
|
|
32
|
+
console.error("Failed to copy:", F);
|
|
33
|
+
}
|
|
34
|
+
document.body.removeChild(v);
|
|
35
|
+
}
|
|
36
|
+
}, [t, l]), _ = d((k) => {
|
|
37
|
+
var L;
|
|
38
|
+
k.stopPropagation();
|
|
39
|
+
const f = new Blob([t.code], { type: "text/plain" }), v = URL.createObjectURL(f), F = document.createElement("a"), D = Re(t.language), q = ((L = t.title) == null ? void 0 : L.replace(/[^a-z0-9]/gi, "_").toLowerCase()) || "code";
|
|
40
|
+
F.href = v, F.download = `${q}.${D}`, document.body.appendChild(F), F.click(), document.body.removeChild(F), URL.revokeObjectURL(v), s && s(t);
|
|
41
|
+
}, [t, s]), E = [
|
|
42
|
+
"artifactuse-card",
|
|
43
|
+
a && "artifactuse-card--active",
|
|
44
|
+
r
|
|
45
|
+
].filter(Boolean).join(" ");
|
|
46
|
+
return /* @__PURE__ */ e.createElement("div", { className: E, onClick: P }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__icon" }, /* @__PURE__ */ e.createElement(
|
|
47
|
+
"svg",
|
|
48
|
+
{
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
strokeWidth: "1.5",
|
|
53
|
+
dangerouslySetInnerHTML: { __html: b }
|
|
54
|
+
}
|
|
55
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__content" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__title" }, t.title), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__meta" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-card__type" }, g), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-card__separator" }, "•"), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-card__size" }, c))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__actions" }, /* @__PURE__ */ e.createElement(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
className: "artifactuse-card__action",
|
|
59
|
+
title: p ? "Copied!" : "Copy code",
|
|
60
|
+
onClick: x
|
|
61
|
+
},
|
|
62
|
+
p ? /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "20 6 9 17 4 12" })) : /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), /* @__PURE__ */ e.createElement("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }))
|
|
63
|
+
), /* @__PURE__ */ e.createElement(
|
|
64
|
+
"button",
|
|
65
|
+
{
|
|
66
|
+
className: "artifactuse-card__action",
|
|
67
|
+
title: "Download file",
|
|
68
|
+
onClick: _
|
|
69
|
+
},
|
|
70
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), /* @__PURE__ */ e.createElement("polyline", { points: "7 10 12 15 17 10" }), /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "15", x2: "12", y2: "3" }))
|
|
71
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-card__arrow" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "9 18 15 12 9 6" }))));
|
|
72
|
+
}
|
|
73
|
+
function rt(t) {
|
|
74
|
+
if (!t) return null;
|
|
75
|
+
const a = t.trim();
|
|
76
|
+
if (a.startsWith("#")) {
|
|
77
|
+
let s = a.slice(1);
|
|
78
|
+
if (s.length === 3 && (s = s.split("").map((r) => r + r).join("")), s.length === 6) {
|
|
79
|
+
const r = parseInt(s.slice(0, 2), 16), p = parseInt(s.slice(2, 4), 16), u = parseInt(s.slice(4, 6), 16);
|
|
80
|
+
if (!isNaN(r) && !isNaN(p) && !isNaN(u)) return `${r}, ${p}, ${u}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const n = a.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);
|
|
84
|
+
if (n) return `${n[1]}, ${n[2]}, ${n[3]}`;
|
|
85
|
+
const l = a.split(/[\s,]+/).map(Number).filter((s) => !isNaN(s));
|
|
86
|
+
return l.length >= 3 ? `${l[0]}, ${l[1]}, ${l[2]}` : null;
|
|
87
|
+
}
|
|
88
|
+
function Ue(t) {
|
|
89
|
+
return t ? t.map((a) => typeof a == "string" ? { label: a, value: a } : a) : [];
|
|
90
|
+
}
|
|
91
|
+
function st(t) {
|
|
92
|
+
return ["text", "email", "password", "tel", "url", "number", "date", "time", "datetime-local"].includes(t);
|
|
93
|
+
}
|
|
94
|
+
function nt({
|
|
95
|
+
artifact: t,
|
|
96
|
+
onSubmit: a,
|
|
97
|
+
onCancel: n,
|
|
98
|
+
onReset: l,
|
|
99
|
+
onButtonClick: s,
|
|
100
|
+
className: r = "",
|
|
101
|
+
theme: p = "dark",
|
|
102
|
+
accent: u = null,
|
|
103
|
+
initialState: g = "active"
|
|
104
|
+
// 'active' | 'submitted' | 'cancelled' | 'inactive'
|
|
105
|
+
}) {
|
|
106
|
+
var ie, ee, oe;
|
|
107
|
+
const c = W(null), [b, P] = C(g), x = b !== "active", _ = b === "active" ? "" : `artifactuse-form--${b}`, E = $(() => {
|
|
108
|
+
try {
|
|
109
|
+
return JSON.parse(t.code);
|
|
110
|
+
} catch {
|
|
111
|
+
return { title: "Invalid Form", variant: "fields", data: { fields: [] } };
|
|
112
|
+
}
|
|
113
|
+
}, [t.code]), k = t.id || E.id || `form-${Date.now()}`, f = ((ie = E.data) == null ? void 0 : ie.fields) || [], v = E.title || "Form", F = $(() => f.some((i) => i.type === "buttons"), [f]), D = $(() => E.variant === "buttons" ? f : [], [E.variant, f]), [q, L] = C(() => {
|
|
114
|
+
var w;
|
|
115
|
+
const i = {};
|
|
116
|
+
return f.forEach((y) => {
|
|
117
|
+
["buttons", "divider", "heading"].includes(y.type) || (y.defaultValue !== void 0 ? i[y.name] = y.defaultValue : y.type === "checkbox" ? i[y.name] = !1 : i[y.name] = "");
|
|
118
|
+
}), (w = E.data) != null && w.defaults && Object.assign(i, E.data.defaults), i;
|
|
119
|
+
}), [J, K] = C({}), [U, ne] = C(!1);
|
|
120
|
+
z(() => {
|
|
121
|
+
P(g);
|
|
122
|
+
}, [g]), z(() => {
|
|
123
|
+
var w;
|
|
124
|
+
const i = {};
|
|
125
|
+
f.forEach((y) => {
|
|
126
|
+
["buttons", "divider", "heading"].includes(y.type) || (y.defaultValue !== void 0 ? i[y.name] = y.defaultValue : y.type === "checkbox" ? i[y.name] = !1 : i[y.name] = "");
|
|
127
|
+
}), (w = E.data) != null && w.defaults && Object.assign(i, E.data.defaults), L(i), K({});
|
|
128
|
+
}, [t.code]), z(() => {
|
|
129
|
+
if (c.current && (c.current.setAttribute("data-artifactuse-theme", p), u)) {
|
|
130
|
+
const i = rt(u);
|
|
131
|
+
i && c.current.style.setProperty("--artifactuse-primary", i);
|
|
132
|
+
}
|
|
133
|
+
}, [p, u]);
|
|
134
|
+
const le = d((i) => {
|
|
135
|
+
P(i);
|
|
136
|
+
}, []), fe = d((i, w) => {
|
|
137
|
+
L((y) => ({ ...y, [i]: w })), K((y) => {
|
|
138
|
+
const N = { ...y };
|
|
139
|
+
return delete N[i], N;
|
|
140
|
+
});
|
|
141
|
+
}, []), te = d(() => {
|
|
142
|
+
var y;
|
|
143
|
+
const i = {};
|
|
144
|
+
f.forEach((N) => {
|
|
145
|
+
if (["buttons", "divider", "heading"].includes(N.type)) return;
|
|
146
|
+
const T = q[N.name];
|
|
147
|
+
if (N.required && !T && T !== 0 && T !== !1) {
|
|
148
|
+
i[N.name] = `${N.label || "This field"} is required`;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (N.pattern && T && !new RegExp(N.pattern).test(T)) {
|
|
152
|
+
i[N.name] = N.patternMessage || `${N.label || "This field"} is invalid`;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (N.type === "email" && T && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T)) {
|
|
156
|
+
i[N.name] = "Please enter a valid email address";
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (N.minLength && T && T.length < N.minLength) {
|
|
160
|
+
i[N.name] = `Minimum ${N.minLength} characters required`;
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (N.maxLength && T && T.length > N.maxLength) {
|
|
164
|
+
i[N.name] = `Maximum ${N.maxLength} characters allowed`;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const w = (y = E.data) == null ? void 0 : y.validation;
|
|
169
|
+
return w && Object.entries(w).forEach(([N, T]) => {
|
|
170
|
+
if (i[N]) return;
|
|
171
|
+
const Y = q[N];
|
|
172
|
+
T.pattern && Y && (new RegExp(T.pattern).test(Y) || (i[N] = T.message || `${N} is invalid`));
|
|
173
|
+
}), K(i), Object.keys(i).length === 0;
|
|
174
|
+
}, [f, q, (ee = E.data) == null ? void 0 : ee.validation]), X = d(() => {
|
|
175
|
+
var w;
|
|
176
|
+
const i = {};
|
|
177
|
+
f.forEach((y) => {
|
|
178
|
+
["buttons", "divider", "heading"].includes(y.type) || (y.defaultValue !== void 0 ? i[y.name] = y.defaultValue : y.type === "checkbox" ? i[y.name] = !1 : i[y.name] = "");
|
|
179
|
+
}), (w = E.data) != null && w.defaults && Object.assign(i, E.data.defaults), L(i), K({});
|
|
180
|
+
}, [f, (oe = E.data) == null ? void 0 : oe.defaults]), ae = d((i) => {
|
|
181
|
+
i == null || i.preventDefault(), te() && (ne(!0), a == null || a({
|
|
182
|
+
formId: k,
|
|
183
|
+
action: "submit",
|
|
184
|
+
values: { ...q },
|
|
185
|
+
timestamp: Date.now()
|
|
186
|
+
}), setTimeout(() => {
|
|
187
|
+
ne(!1), le("submitted");
|
|
188
|
+
}, 300));
|
|
189
|
+
}, [k, q, a, te, le]), V = d((i) => {
|
|
190
|
+
const w = i.action || "custom";
|
|
191
|
+
switch (w) {
|
|
192
|
+
case "submit":
|
|
193
|
+
ae();
|
|
194
|
+
break;
|
|
195
|
+
case "cancel":
|
|
196
|
+
n == null || n({
|
|
197
|
+
formId: k,
|
|
198
|
+
action: "cancel",
|
|
199
|
+
buttonName: i.name || "cancel",
|
|
200
|
+
timestamp: Date.now()
|
|
201
|
+
}), setTimeout(() => {
|
|
202
|
+
le("cancelled");
|
|
203
|
+
}, 150);
|
|
204
|
+
break;
|
|
205
|
+
case "reset":
|
|
206
|
+
X(), l == null || l({
|
|
207
|
+
formId: k,
|
|
208
|
+
action: "reset",
|
|
209
|
+
buttonName: i.name || "reset",
|
|
210
|
+
timestamp: Date.now()
|
|
211
|
+
});
|
|
212
|
+
break;
|
|
213
|
+
case "custom":
|
|
214
|
+
default:
|
|
215
|
+
s == null || s({
|
|
216
|
+
formId: k,
|
|
217
|
+
action: w,
|
|
218
|
+
buttonName: i.name || i.label,
|
|
219
|
+
buttonLabel: i.label,
|
|
220
|
+
values: { ...q },
|
|
221
|
+
timestamp: Date.now()
|
|
222
|
+
}), setTimeout(() => {
|
|
223
|
+
le("submitted");
|
|
224
|
+
}, 150);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}, [k, q, ae, n, l, s, X, le]);
|
|
228
|
+
return x ? /* @__PURE__ */ e.createElement(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
ref: c,
|
|
232
|
+
className: `artifactuse-inline-form artifactuse-form-${E.variant || "fields"} ${_} ${r}`,
|
|
233
|
+
"data-artifactuse-theme": p
|
|
234
|
+
},
|
|
235
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-collapsed" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-collapsed-icon" }, b === "submitted" && /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "20 6 9 17 4 12" })), b === "cancelled" && /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" })), b === "inactive" && /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("line", { x1: "5", y1: "12", x2: "19", y2: "12" }))), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-form-collapsed-title" }, v))
|
|
236
|
+
) : E.variant === "buttons" ? /* @__PURE__ */ e.createElement(
|
|
237
|
+
"div",
|
|
238
|
+
{
|
|
239
|
+
ref: c,
|
|
240
|
+
className: `artifactuse-inline-form artifactuse-form-buttons ${r}`,
|
|
241
|
+
"data-artifactuse-theme": p
|
|
242
|
+
},
|
|
243
|
+
(E.title || E.description) && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-header" }, E.title && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-title" }, E.title), E.description && /* @__PURE__ */ e.createElement("p", { className: "artifactuse-form-description" }, E.description)),
|
|
244
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-buttons" }, D.map((i, w) => /* @__PURE__ */ e.createElement(
|
|
245
|
+
"button",
|
|
246
|
+
{
|
|
247
|
+
key: i.name || i.label || w,
|
|
248
|
+
type: "button",
|
|
249
|
+
className: `artifactuse-form-btn artifactuse-form-btn-${i.variant || "secondary"}`,
|
|
250
|
+
onClick: () => V(i),
|
|
251
|
+
disabled: i.disabled || U
|
|
252
|
+
},
|
|
253
|
+
i.icon && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-form-btn-icon", dangerouslySetInnerHTML: { __html: i.icon } }),
|
|
254
|
+
i.label
|
|
255
|
+
)))
|
|
256
|
+
) : /* @__PURE__ */ e.createElement(
|
|
257
|
+
"div",
|
|
258
|
+
{
|
|
259
|
+
ref: c,
|
|
260
|
+
className: `artifactuse-inline-form artifactuse-form-fields ${r}`,
|
|
261
|
+
"data-artifactuse-theme": p
|
|
262
|
+
},
|
|
263
|
+
(E.title || E.description) && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-header" }, E.title && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-title" }, E.title), E.description && /* @__PURE__ */ e.createElement("p", { className: "artifactuse-form-description" }, E.description)),
|
|
264
|
+
/* @__PURE__ */ e.createElement("form", { onSubmit: ae, className: "artifactuse-form" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-fields" }, f.map((i, w) => /* @__PURE__ */ e.createElement(
|
|
265
|
+
lt,
|
|
266
|
+
{
|
|
267
|
+
key: i.name || w,
|
|
268
|
+
field: i,
|
|
269
|
+
formId: k,
|
|
270
|
+
value: q[i.name],
|
|
271
|
+
error: J[i.name],
|
|
272
|
+
isSubmitting: U,
|
|
273
|
+
onChange: (y) => fe(i.name, y),
|
|
274
|
+
onButtonAction: V
|
|
275
|
+
}
|
|
276
|
+
))), !F && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-buttons artifactuse-form-buttons-default" }, /* @__PURE__ */ e.createElement(
|
|
277
|
+
"button",
|
|
278
|
+
{
|
|
279
|
+
type: "button",
|
|
280
|
+
className: "artifactuse-form-btn artifactuse-form-btn-ghost",
|
|
281
|
+
onClick: () => V({ action: "cancel", label: "Cancel" })
|
|
282
|
+
},
|
|
283
|
+
"Cancel"
|
|
284
|
+
), /* @__PURE__ */ e.createElement(
|
|
285
|
+
"button",
|
|
286
|
+
{
|
|
287
|
+
type: "submit",
|
|
288
|
+
className: "artifactuse-form-btn artifactuse-form-btn-primary",
|
|
289
|
+
disabled: U
|
|
290
|
+
},
|
|
291
|
+
U && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-form-btn-spinner" }),
|
|
292
|
+
U ? "Submitting..." : "Submit"
|
|
293
|
+
)))
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
function lt({ field: t, formId: a, value: n, error: l, isSubmitting: s, onChange: r, onButtonAction: p }) {
|
|
297
|
+
const u = `${a}-${t.name}`;
|
|
298
|
+
if (t.type === "buttons")
|
|
299
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-buttons" }, (t.fields || []).map((c, b) => /* @__PURE__ */ e.createElement(
|
|
300
|
+
"button",
|
|
301
|
+
{
|
|
302
|
+
key: c.name || c.label || b,
|
|
303
|
+
type: c.action === "submit" ? "submit" : "button",
|
|
304
|
+
className: `artifactuse-form-btn artifactuse-form-btn-${c.variant || "secondary"}`,
|
|
305
|
+
onClick: c.action !== "submit" ? () => p(c) : void 0,
|
|
306
|
+
disabled: c.disabled || c.action === "submit" && s
|
|
307
|
+
},
|
|
308
|
+
s && c.action === "submit" ? /* @__PURE__ */ e.createElement("span", { className: "artifactuse-form-btn-spinner" }) : c.icon ? /* @__PURE__ */ e.createElement("span", { className: "artifactuse-form-btn-icon", dangerouslySetInnerHTML: { __html: c.icon } }) : null,
|
|
309
|
+
s && c.action === "submit" ? "Submitting..." : c.label
|
|
310
|
+
)));
|
|
311
|
+
if (t.type === "divider")
|
|
312
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-divider" });
|
|
313
|
+
if (t.type === "heading")
|
|
314
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-heading" }, t.label);
|
|
315
|
+
if (t.type === "checkbox")
|
|
316
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-field" }, /* @__PURE__ */ e.createElement("label", { className: "artifactuse-checkbox-label" }, /* @__PURE__ */ e.createElement(
|
|
317
|
+
"input",
|
|
318
|
+
{
|
|
319
|
+
type: "checkbox",
|
|
320
|
+
id: u,
|
|
321
|
+
name: t.name,
|
|
322
|
+
checked: n || !1,
|
|
323
|
+
disabled: t.disabled,
|
|
324
|
+
className: "artifactuse-checkbox",
|
|
325
|
+
onChange: (c) => r(c.target.checked)
|
|
326
|
+
}
|
|
327
|
+
), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-checkbox-text" }, t.label, t.required && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-required" }, "*"))), t.helpText && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-help-text" }, t.helpText), l && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-error-text" }, l));
|
|
328
|
+
if (t.type === "radio")
|
|
329
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-field" }, t.label && /* @__PURE__ */ e.createElement("label", { className: "artifactuse-label" }, t.label, t.required && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-required" }, "*")), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-radio-group" }, Ue(t.options).map((c) => /* @__PURE__ */ e.createElement("label", { key: c.value, className: "artifactuse-radio-label" }, /* @__PURE__ */ e.createElement(
|
|
330
|
+
"input",
|
|
331
|
+
{
|
|
332
|
+
type: "radio",
|
|
333
|
+
name: t.name,
|
|
334
|
+
value: c.value,
|
|
335
|
+
checked: n === c.value,
|
|
336
|
+
disabled: c.disabled || t.disabled,
|
|
337
|
+
className: "artifactuse-radio",
|
|
338
|
+
onChange: () => r(c.value)
|
|
339
|
+
}
|
|
340
|
+
), /* @__PURE__ */ e.createElement("span", null, c.label)))), t.helpText && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-help-text" }, t.helpText), l && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-error-text" }, l));
|
|
341
|
+
const g = () => st(t.type) ? /* @__PURE__ */ e.createElement(
|
|
342
|
+
"input",
|
|
343
|
+
{
|
|
344
|
+
type: t.type,
|
|
345
|
+
id: u,
|
|
346
|
+
name: t.name,
|
|
347
|
+
value: n || "",
|
|
348
|
+
placeholder: t.placeholder,
|
|
349
|
+
disabled: t.disabled,
|
|
350
|
+
required: t.required,
|
|
351
|
+
className: "artifactuse-input",
|
|
352
|
+
onChange: (c) => r(t.type === "number" ? Number(c.target.value) : c.target.value)
|
|
353
|
+
}
|
|
354
|
+
) : t.type === "textarea" ? /* @__PURE__ */ e.createElement(
|
|
355
|
+
"textarea",
|
|
356
|
+
{
|
|
357
|
+
id: u,
|
|
358
|
+
name: t.name,
|
|
359
|
+
value: n || "",
|
|
360
|
+
placeholder: t.placeholder,
|
|
361
|
+
disabled: t.disabled,
|
|
362
|
+
required: t.required,
|
|
363
|
+
rows: t.rows || 3,
|
|
364
|
+
className: "artifactuse-textarea",
|
|
365
|
+
onChange: (c) => r(c.target.value)
|
|
366
|
+
}
|
|
367
|
+
) : t.type === "select" ? /* @__PURE__ */ e.createElement(
|
|
368
|
+
"select",
|
|
369
|
+
{
|
|
370
|
+
id: u,
|
|
371
|
+
name: t.name,
|
|
372
|
+
value: n || "",
|
|
373
|
+
disabled: t.disabled,
|
|
374
|
+
required: t.required,
|
|
375
|
+
className: "artifactuse-select",
|
|
376
|
+
onChange: (c) => r(c.target.value)
|
|
377
|
+
},
|
|
378
|
+
/* @__PURE__ */ e.createElement("option", { value: "" }, t.placeholder || "Select..."),
|
|
379
|
+
Ue(t.options).map((c) => /* @__PURE__ */ e.createElement("option", { key: c.value, value: c.value, disabled: c.disabled }, c.label))
|
|
380
|
+
) : /* @__PURE__ */ e.createElement(
|
|
381
|
+
"input",
|
|
382
|
+
{
|
|
383
|
+
type: "text",
|
|
384
|
+
id: u,
|
|
385
|
+
name: t.name,
|
|
386
|
+
value: n || "",
|
|
387
|
+
disabled: t.disabled,
|
|
388
|
+
className: "artifactuse-input",
|
|
389
|
+
onChange: (c) => r(c.target.value)
|
|
390
|
+
}
|
|
391
|
+
);
|
|
392
|
+
return /* @__PURE__ */ e.createElement("div", { className: "artifactuse-form-field" }, /* @__PURE__ */ e.createElement("label", { htmlFor: u, className: "artifactuse-label" }, t.label, t.required && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-required" }, "*")), g(), t.helpText && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-help-text" }, t.helpText), l && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-error-text" }, l));
|
|
393
|
+
}
|
|
394
|
+
const R = 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23888"><circle cx="12" cy="8" r="4"/><path d="M12 14c-6 0-8 3-8 6v2h16v-2c0-3-2-6-8-6z"/></svg>', ct = {
|
|
395
|
+
twitter: 280,
|
|
396
|
+
linkedin: 3e3,
|
|
397
|
+
instagram: 2200,
|
|
398
|
+
facebook: 63206,
|
|
399
|
+
threads: 500,
|
|
400
|
+
tiktok: 2200,
|
|
401
|
+
youtube: 100
|
|
402
|
+
}, it = {
|
|
403
|
+
twitter: "X",
|
|
404
|
+
linkedin: "LinkedIn",
|
|
405
|
+
instagram: "Instagram",
|
|
406
|
+
facebook: "Facebook",
|
|
407
|
+
threads: "Threads",
|
|
408
|
+
tiktok: "TikTok",
|
|
409
|
+
youtube: "YouTube"
|
|
410
|
+
}, xe = ({ type: t = "blue" }) => /* @__PURE__ */ e.createElement("svg", { className: `artifactuse-social-verified artifactuse-social-verified-${t}`, viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M22.25 12c0-1.43-.88-2.67-2.19-3.34.46-1.39.2-2.9-.81-3.91s-2.52-1.27-3.91-.81c-.66-1.31-1.91-2.19-3.34-2.19s-2.67.88-3.34 2.19c-1.39-.46-2.9-.2-3.91.81s-1.27 2.52-.81 3.91C2.63 9.33 1.75 10.57 1.75 12s.88 2.67 2.19 3.34c-.46 1.39-.2 2.9.81 3.91s2.52 1.27 3.91.81c.66 1.31 1.91 2.19 3.34 2.19s2.67-.88 3.34-2.19c1.39.46 2.9.2 3.91-.81s1.27-2.52.81-3.91c1.31-.67 2.19-1.91 2.19-3.34zm-11.71 4.2L6.8 12.46l1.41-1.42 2.26 2.26 4.8-5.23 1.47 1.36-6.2 6.77z" })), H = (t) => t ? t >= 1e6 ? `${(t / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(t / 1e3).toFixed(1)}K` : t.toString() : "0", De = (t) => {
|
|
411
|
+
try {
|
|
412
|
+
return new URL(t).hostname.replace("www.", "");
|
|
413
|
+
} catch {
|
|
414
|
+
return t;
|
|
415
|
+
}
|
|
416
|
+
}, ue = (t) => {
|
|
417
|
+
if (!t) return "";
|
|
418
|
+
let a = t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
419
|
+
return a = a.replace(/\n/g, "<br>"), a = a.replace(/#(\w+)/g, '<span class="artifactuse-social-hashtag">#$1</span>'), a = a.replace(/@(\w+)/g, '<span class="artifactuse-social-mention">@$1</span>'), a;
|
|
420
|
+
}, Ve = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
421
|
+
var p, u, g;
|
|
422
|
+
const s = a.media || [], r = n.likes || n.retweets || n.replies || n.views;
|
|
423
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (c) => c.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-name" }, /* @__PURE__ */ e.createElement("span", null, t.name), t.verified && /* @__PURE__ */ e.createElement(xe, { type: t.verifiedType || "blue" })), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-meta" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-author-handle" }, t.handle), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-timestamp" }, "· ", l.timestamp || "Just now")))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-content" }, /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-text", dangerouslySetInnerHTML: { __html: ue(a.text) } }), s.length > 0 && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-media" }, /* @__PURE__ */ e.createElement("div", { className: `artifactuse-social-media-grid ${s.length === 1 ? "artifactuse-social-media-single" : ""}`, "data-count": s.length }, s.slice(0, 4).map((c, b) => /* @__PURE__ */ e.createElement("img", { key: b, src: c.url, alt: c.alt || "", onError: (P) => P.target.style.display = "none" })))), a.link && !s.length && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-card" }, a.link.image && /* @__PURE__ */ e.createElement("img", { src: a.link.image, alt: a.link.title, className: "artifactuse-social-link-image", onError: (c) => c.target.style.display = "none" }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-info" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-domain" }, a.link.domain || De(a.link.url)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-title" }, a.link.title), a.link.description && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-description" }, a.link.description))), a.poll && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-poll" }, a.poll.options.map((c, b) => {
|
|
424
|
+
var P, x;
|
|
425
|
+
return /* @__PURE__ */ e.createElement("div", { key: b, className: "artifactuse-social-poll-option" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-poll-bar", style: { width: `${((P = a.poll.votes) == null ? void 0 : P[b]) || 0}%` } }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-poll-label" }, /* @__PURE__ */ e.createElement("span", null, c), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-poll-percent" }, ((x = a.poll.votes) == null ? void 0 : x[b]) || 0, "%")));
|
|
426
|
+
}), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-poll-meta" }, H(a.poll.totalVotes || 0), " votes · ", a.poll.duration || "Poll ended")), a.quote && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-quote" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-quote-header" }, /* @__PURE__ */ e.createElement("img", { src: ((p = a.quote.author) == null ? void 0 : p.avatar) || R, className: "artifactuse-social-quote-avatar", alt: "" }), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-quote-author" }, (u = a.quote.author) == null ? void 0 : u.name), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-quote-handle" }, (g = a.quote.author) == null ? void 0 : g.handle)), /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-quote-text" }, a.quote.text))), r && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-engagement" }, /* @__PURE__ */ e.createElement("span", null, H(n.replies || 0), " replies"), /* @__PURE__ */ e.createElement("span", null, H(n.retweets || 0), " reposts"), /* @__PURE__ */ e.createElement("span", null, H(n.likes || 0), " likes"), /* @__PURE__ */ e.createElement("span", null, H(n.views || 0), " views")));
|
|
427
|
+
}, ot = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
428
|
+
const s = n.likes || n.comments || n.shares || n.reposts;
|
|
429
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (r) => r.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-info" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-name" }, t.name, t.connection && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-author-connection" }, "· ", t.connection)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-headline" }, t.headline), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-timestamp" }, l.timestamp || "Just now", " · 🌐"))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-content" }, /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-text", dangerouslySetInnerHTML: { __html: ue(a.text) } }), a.link && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-card" }, a.link.image && /* @__PURE__ */ e.createElement("img", { src: a.link.image, alt: a.link.title, className: "artifactuse-social-link-image", onError: (r) => r.target.style.display = "none" }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-info" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-title" }, a.link.title), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-domain" }, a.link.domain || De(a.link.url))))), s && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-engagement" }, /* @__PURE__ */ e.createElement("span", null, H(n.likes || 0), " reactions"), /* @__PURE__ */ e.createElement("span", null, H(n.comments || 0), " comments"), /* @__PURE__ */ e.createElement("span", null, H(n.shares || n.reposts || 0), " reposts")));
|
|
430
|
+
}, mt = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
431
|
+
const s = a.media || [];
|
|
432
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (r) => r.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-name" }, t.name, t.verified && /* @__PURE__ */ e.createElement(xe, { type: "blue" })), l.location && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-location" }, l.location))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-media" }, s[0] ? /* @__PURE__ */ e.createElement("img", { src: s[0].url, alt: s[0].alt || "", onError: (r) => r.target.style.display = "none" }) : /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-media-placeholder" })), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-likes" }, H(n.likes || 0), " likes"), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-caption" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-caption-author" }, t.name), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-caption-text", dangerouslySetInnerHTML: { __html: ue(a.text) } })), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-timestamp" }, l.timestamp || "JUST NOW"));
|
|
433
|
+
}, ut = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
434
|
+
const s = a.media || [], r = $(() => {
|
|
435
|
+
const u = n.reactions || {};
|
|
436
|
+
return Object.values(u).reduce((g, c) => g + (c || 0), 0) || n.likes || 0;
|
|
437
|
+
}, [n]), p = n.likes || n.comments || n.shares || r;
|
|
438
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (u) => u.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-name" }, t.name), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-timestamp" }, l.timestamp || "Just now", " · 🌐"))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-content" }, /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-text", dangerouslySetInnerHTML: { __html: ue(a.text) } }), s.length > 0 && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-media" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-media-grid", "data-count": s.length }, s.slice(0, 4).map((u, g) => /* @__PURE__ */ e.createElement("img", { key: g, src: u.url, alt: u.alt || "", onError: (c) => c.target.style.display = "none" })))), a.link && !s.length && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-card" }, a.link.image && /* @__PURE__ */ e.createElement("img", { src: a.link.image, alt: a.link.title, className: "artifactuse-social-link-image", onError: (u) => u.target.style.display = "none" }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-info" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-domain" }, a.link.domain || De(a.link.url)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-link-title" }, a.link.title)))), p && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-engagement" }, /* @__PURE__ */ e.createElement("span", null, "👍❤️ ", H(r)), /* @__PURE__ */ e.createElement("span", null, H(n.comments || 0), " comments · ", H(n.shares || 0), " shares")));
|
|
439
|
+
}, dt = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
440
|
+
const s = n.likes || n.replies || n.reposts;
|
|
441
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (r) => r.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-author-name" }, t.name, t.verified && /* @__PURE__ */ e.createElement(xe, { type: "blue" }))), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-timestamp" }, l.timestamp || "Just now")), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-content" }, /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-text", dangerouslySetInnerHTML: { __html: ue(a.text) } })), s && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-engagement" }, /* @__PURE__ */ e.createElement("span", null, H(n.likes || 0), " likes"), /* @__PURE__ */ e.createElement("span", null, H(n.replies || 0), " replies"), /* @__PURE__ */ e.createElement("span", null, H(n.reposts || 0), " reposts")));
|
|
442
|
+
}, ft = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
443
|
+
const s = a.media || [], r = n.likes || n.comments || n.shares;
|
|
444
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-thumbnail" }, s[0] ? /* @__PURE__ */ e.createElement("img", { src: s[0].url, alt: "Video thumbnail", onError: (p) => p.target.style.display = "none" }) : /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-thumbnail-placeholder" }), a.duration && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-duration" }, a.duration)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-info" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-header" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (p) => p.target.src = R }), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-social-author-name" }, "@", t.name), t.verified && /* @__PURE__ */ e.createElement(xe, { type: "blue" })), /* @__PURE__ */ e.createElement("p", { className: "artifactuse-social-text", dangerouslySetInnerHTML: { __html: ue(a.text) } }), a.sound && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-sound" }, "🎵 ", a.sound)), r && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-engagement" }, /* @__PURE__ */ e.createElement("span", null, H(n.likes || 0), " likes"), /* @__PURE__ */ e.createElement("span", null, H(n.comments || 0), " comments"), /* @__PURE__ */ e.createElement("span", null, H(n.shares || 0), " shares")));
|
|
445
|
+
}, pt = ({ author: t, content: a, engagement: n, meta: l }) => {
|
|
446
|
+
const s = a.media || [];
|
|
447
|
+
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-thumbnail" }, s[0] ? /* @__PURE__ */ e.createElement("img", { src: s[0].url, alt: "Video thumbnail", onError: (r) => r.target.style.display = "none" }) : /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-thumbnail-placeholder" }), a.duration && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-duration" }, a.duration)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-info" }, /* @__PURE__ */ e.createElement("img", { src: t.avatar || R, alt: t.name, className: "artifactuse-social-avatar", onError: (r) => r.target.src = R }), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-details" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-title" }, a.title), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-channel" }, t.name), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-meta" }, H(n.views || 0), " views · ", l.timestamp || "Just now"))));
|
|
448
|
+
};
|
|
449
|
+
function Et({ artifact: t, theme: a = "dark", onCopy: n }) {
|
|
450
|
+
const [l, s] = C("Copy"), r = $(() => {
|
|
451
|
+
try {
|
|
452
|
+
return JSON.parse(t.code);
|
|
453
|
+
} catch {
|
|
454
|
+
return { platform: "twitter", data: {} };
|
|
455
|
+
}
|
|
456
|
+
}, [t.code]), p = (r == null ? void 0 : r.platform) || "twitter", u = (r == null ? void 0 : r.data) || {}, { author: g = {}, content: c = {}, engagement: b = {}, meta: P = {} } = u, x = ct[p] || 280, _ = (c.text || "").length, E = _ > x ? "error" : _ > x * 0.9 ? "warning" : "", k = d(() => {
|
|
457
|
+
const v = c.text || "";
|
|
458
|
+
navigator.clipboard.writeText(v).then(() => {
|
|
459
|
+
s("Copied!"), setTimeout(() => s("Copy"), 2e3), n == null || n({ platform: p, text: v });
|
|
460
|
+
});
|
|
461
|
+
}, [c.text, p, n]), f = () => {
|
|
462
|
+
const v = { author: g, content: c, engagement: b, meta: P };
|
|
463
|
+
switch (p) {
|
|
464
|
+
case "twitter":
|
|
465
|
+
return /* @__PURE__ */ e.createElement(Ve, { ...v });
|
|
466
|
+
case "linkedin":
|
|
467
|
+
return /* @__PURE__ */ e.createElement(ot, { ...v });
|
|
468
|
+
case "instagram":
|
|
469
|
+
return /* @__PURE__ */ e.createElement(mt, { ...v });
|
|
470
|
+
case "facebook":
|
|
471
|
+
return /* @__PURE__ */ e.createElement(ut, { ...v });
|
|
472
|
+
case "threads":
|
|
473
|
+
return /* @__PURE__ */ e.createElement(dt, { ...v });
|
|
474
|
+
case "tiktok":
|
|
475
|
+
return /* @__PURE__ */ e.createElement(ft, { ...v });
|
|
476
|
+
case "youtube":
|
|
477
|
+
return /* @__PURE__ */ e.createElement(pt, { ...v });
|
|
478
|
+
default:
|
|
479
|
+
return /* @__PURE__ */ e.createElement(Ve, { ...v });
|
|
480
|
+
}
|
|
481
|
+
};
|
|
482
|
+
return /* @__PURE__ */ e.createElement("div", { className: `artifactuse-social artifactuse-social-${p}`, "data-artifactuse-theme": a }, f(), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-actions-bar" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-platform-badge" }, /* @__PURE__ */ e.createElement("span", null, it[p] || p)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-social-actions-right" }, /* @__PURE__ */ e.createElement("span", { className: `artifactuse-social-char-counter ${E}` }, _, "/", x), /* @__PURE__ */ e.createElement("button", { className: "artifactuse-social-copy-btn", onClick: k }, l))));
|
|
483
|
+
}
|
|
484
|
+
function vt({
|
|
485
|
+
isOpen: t = !1,
|
|
486
|
+
type: a = "image",
|
|
487
|
+
src: n = "",
|
|
488
|
+
alt: l = "",
|
|
489
|
+
caption: s = "",
|
|
490
|
+
onClose: r,
|
|
491
|
+
className: p = ""
|
|
492
|
+
}) {
|
|
493
|
+
const u = W(null), [g, c] = C(!1), [b, P] = C(!1);
|
|
494
|
+
z(() => (P(!0), () => P(!1)), []), z(() => {
|
|
495
|
+
var f;
|
|
496
|
+
return t ? (document.body.style.overflow = "hidden", (f = u.current) == null || f.focus()) : (document.body.style.overflow = "", c(!1)), () => {
|
|
497
|
+
document.body.style.overflow = "";
|
|
498
|
+
};
|
|
499
|
+
}, [t]), z(() => {
|
|
500
|
+
function f(v) {
|
|
501
|
+
v.key === "Escape" && t && r && r();
|
|
502
|
+
}
|
|
503
|
+
return document.addEventListener("keydown", f), () => document.removeEventListener("keydown", f);
|
|
504
|
+
}, [t, r]);
|
|
505
|
+
const x = d(() => {
|
|
506
|
+
c(!1), r && r();
|
|
507
|
+
}, [r]), _ = d(() => {
|
|
508
|
+
a === "image" && c((f) => !f);
|
|
509
|
+
}, [a]), E = d(() => {
|
|
510
|
+
const f = document.createElement("a");
|
|
511
|
+
f.href = n, f.download = l || "download", document.body.appendChild(f), f.click(), document.body.removeChild(f);
|
|
512
|
+
}, [n, l]);
|
|
513
|
+
if (!t || !b)
|
|
514
|
+
return null;
|
|
515
|
+
const k = /* @__PURE__ */ e.createElement(
|
|
516
|
+
"div",
|
|
517
|
+
{
|
|
518
|
+
ref: u,
|
|
519
|
+
className: `artifactuse-viewer-overlay ${p}`,
|
|
520
|
+
onClick: x,
|
|
521
|
+
tabIndex: -1,
|
|
522
|
+
role: "dialog",
|
|
523
|
+
"aria-modal": "true"
|
|
524
|
+
},
|
|
525
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-viewer-content", onClick: (f) => f.stopPropagation() }, a === "image" && /* @__PURE__ */ e.createElement(
|
|
526
|
+
"img",
|
|
527
|
+
{
|
|
528
|
+
src: n,
|
|
529
|
+
alt: l,
|
|
530
|
+
className: `artifactuse-viewer-image ${g ? "artifactuse-viewer-image--zoomed" : ""}`,
|
|
531
|
+
onClick: _
|
|
532
|
+
}
|
|
533
|
+
), a === "pdf" && /* @__PURE__ */ e.createElement(
|
|
534
|
+
"iframe",
|
|
535
|
+
{
|
|
536
|
+
src: n,
|
|
537
|
+
className: "artifactuse-viewer-pdf",
|
|
538
|
+
title: l || "PDF Viewer"
|
|
539
|
+
}
|
|
540
|
+
), /* @__PURE__ */ e.createElement(
|
|
541
|
+
"button",
|
|
542
|
+
{
|
|
543
|
+
className: "artifactuse-viewer-close",
|
|
544
|
+
onClick: x,
|
|
545
|
+
title: "Close (Esc)"
|
|
546
|
+
},
|
|
547
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))
|
|
548
|
+
), a === "image" && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-viewer-controls" }, /* @__PURE__ */ e.createElement(
|
|
549
|
+
"button",
|
|
550
|
+
{
|
|
551
|
+
className: "artifactuse-viewer-control",
|
|
552
|
+
onClick: _,
|
|
553
|
+
title: g ? "Zoom out" : "Zoom in"
|
|
554
|
+
},
|
|
555
|
+
g ? /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("circle", { cx: "11", cy: "11", r: "8" }), /* @__PURE__ */ e.createElement("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "11", x2: "14", y2: "11" })) : /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("circle", { cx: "11", cy: "11", r: "8" }), /* @__PURE__ */ e.createElement("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" }), /* @__PURE__ */ e.createElement("line", { x1: "11", y1: "8", x2: "11", y2: "14" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "11", x2: "14", y2: "11" }))
|
|
556
|
+
), /* @__PURE__ */ e.createElement(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
className: "artifactuse-viewer-control",
|
|
560
|
+
onClick: E,
|
|
561
|
+
title: "Download"
|
|
562
|
+
},
|
|
563
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), /* @__PURE__ */ e.createElement("polyline", { points: "7 10 12 15 17 10" }), /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "15", x2: "12", y2: "3" }))
|
|
564
|
+
)), s && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-viewer-caption" }, s))
|
|
565
|
+
);
|
|
566
|
+
return tt(k, document.body);
|
|
567
|
+
}
|
|
568
|
+
function ht(t) {
|
|
569
|
+
if (!t) return null;
|
|
570
|
+
try {
|
|
571
|
+
const a = decodeURIComponent(escape(atob(t)));
|
|
572
|
+
return JSON.parse(a);
|
|
573
|
+
} catch {
|
|
574
|
+
try {
|
|
575
|
+
const n = t.replace(/ /g, `
|
|
576
|
+
`).replace(/ /g, "\r").replace(/	/g, " ").replace(/"/g, '"').replace(/'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&");
|
|
577
|
+
return JSON.parse(n);
|
|
578
|
+
} catch (n) {
|
|
579
|
+
return console.error("Failed to parse artifact data:", n), null;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
function gt(t) {
|
|
584
|
+
const a = [];
|
|
585
|
+
if (!t) return a;
|
|
586
|
+
const n = /<div\s+class="artifactuse-placeholder[^"]*"[^>]*data-artifact-id="([^"]+)"[^>]*data-artifact-type="([^"]+)"[^>]*data-artifact=["']([^"']*)["'][^>]*><\/div>/gi;
|
|
587
|
+
let l = 0, s;
|
|
588
|
+
for (; (s = n.exec(t)) !== null; ) {
|
|
589
|
+
if (s.index > l) {
|
|
590
|
+
const u = t.slice(l, s.index);
|
|
591
|
+
u.trim() && a.push({ type: "html", content: u });
|
|
592
|
+
}
|
|
593
|
+
const r = ht(s[3]), p = s[2];
|
|
594
|
+
r && (p === "form" && r.isInline ? a.push({ type: "form", artifact: r }) : p === "social" ? a.push({ type: "social", artifact: r }) : a.push({ type: "panel", artifact: r })), l = s.index + s[0].length;
|
|
595
|
+
}
|
|
596
|
+
if (l < t.length) {
|
|
597
|
+
const r = t.slice(l);
|
|
598
|
+
r.trim() && a.push({ type: "html", content: r });
|
|
599
|
+
}
|
|
600
|
+
return a.length === 0 && t.trim() && a.push({ type: "html", content: t }), a;
|
|
601
|
+
}
|
|
602
|
+
function yt() {
|
|
603
|
+
return `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
604
|
+
}
|
|
605
|
+
function _t({
|
|
606
|
+
content: t,
|
|
607
|
+
messageId: a = yt(),
|
|
608
|
+
inlineCards: n = !0,
|
|
609
|
+
typing: l = !1,
|
|
610
|
+
isLastMessage: s = !1,
|
|
611
|
+
// Whether this is the last/most recent message
|
|
612
|
+
onArtifactDetected: r,
|
|
613
|
+
onArtifactOpen: p,
|
|
614
|
+
onArtifactCopy: u,
|
|
615
|
+
onArtifactDownload: g,
|
|
616
|
+
onFormSubmit: c,
|
|
617
|
+
onFormCancel: b,
|
|
618
|
+
onFormButtonClick: P,
|
|
619
|
+
onSocialCopy: x,
|
|
620
|
+
onMediaOpen: _,
|
|
621
|
+
className: E = ""
|
|
622
|
+
}) {
|
|
623
|
+
const {
|
|
624
|
+
processMessage: k,
|
|
625
|
+
openArtifact: f,
|
|
626
|
+
state: v,
|
|
627
|
+
getTheme: F,
|
|
628
|
+
instance: D
|
|
629
|
+
} = de(), q = W(null), L = W(null), J = W(null), K = W(l), [U, ne] = C(""), [le, fe] = C([]), [te, X] = C(!1), [ae, V] = C(!1), [ie, ee] = C("image"), [oe, i] = C(""), [w, y] = C(""), [N, T] = C(""), Y = $(() => typeof F == "function" ? F() : "dark", [F]), ge = (v == null ? void 0 : v.activeArtifactId) || null, pe = $(() => gt(U), [U]), Ce = $(() => te || s ? "active" : "inactive", [te, s]);
|
|
630
|
+
z(() => {
|
|
631
|
+
l && X(!0);
|
|
632
|
+
}, [l]);
|
|
633
|
+
const M = d((h) => {
|
|
634
|
+
ee(h.type || "image"), i(h.src || ""), y(h.alt || ""), T(h.caption || ""), V(!0), _ && _(h);
|
|
635
|
+
}, [_]), Z = d(() => {
|
|
636
|
+
V(!1), i(""), y(""), T("");
|
|
637
|
+
}, []), me = d(() => {
|
|
638
|
+
if (!L.current) return;
|
|
639
|
+
L.current.querySelectorAll('img[data-lightbox="true"]').forEach((o) => {
|
|
640
|
+
o._lightboxHandler && o.removeEventListener("click", o._lightboxHandler), o._lightboxHandler = (I) => {
|
|
641
|
+
I.preventDefault(), I.stopPropagation(), M({
|
|
642
|
+
type: "image",
|
|
643
|
+
src: o.src,
|
|
644
|
+
alt: o.alt || "",
|
|
645
|
+
caption: o.dataset.caption || o.alt || ""
|
|
646
|
+
});
|
|
647
|
+
}, o.addEventListener("click", o._lightboxHandler), o.style.cursor = "zoom-in";
|
|
648
|
+
}), L.current.querySelectorAll(".artifactuse-image-container img").forEach((o) => {
|
|
649
|
+
o._lightboxHandler || (o._lightboxHandler = (I) => {
|
|
650
|
+
I.preventDefault(), I.stopPropagation();
|
|
651
|
+
const B = o.closest(".artifactuse-image-container"), j = B == null ? void 0 : B.querySelector(".artifactuse-image-caption"), ce = (j == null ? void 0 : j.textContent) || o.dataset.caption || o.alt || "";
|
|
652
|
+
M({
|
|
653
|
+
type: "image",
|
|
654
|
+
src: o.src,
|
|
655
|
+
alt: o.alt || "",
|
|
656
|
+
caption: ce
|
|
657
|
+
});
|
|
658
|
+
}, o.addEventListener("click", o._lightboxHandler), o.style.cursor = "zoom-in");
|
|
659
|
+
}), L.current.querySelectorAll(".artifactuse-gallery-item img, .artifactuse-image-gallery img").forEach((o) => {
|
|
660
|
+
o._lightboxHandler || (o._lightboxHandler = (I) => {
|
|
661
|
+
I.preventDefault(), I.stopPropagation();
|
|
662
|
+
const B = o.closest(".artifactuse-gallery-item"), j = B == null ? void 0 : B.querySelector(".artifactuse-gallery-caption"), ce = (j == null ? void 0 : j.textContent) || o.dataset.caption || o.alt || "";
|
|
663
|
+
M({
|
|
664
|
+
type: "image",
|
|
665
|
+
src: o.src,
|
|
666
|
+
alt: o.alt || "",
|
|
667
|
+
caption: ce
|
|
668
|
+
});
|
|
669
|
+
}, o.addEventListener("click", o._lightboxHandler), o.style.cursor = "zoom-in");
|
|
670
|
+
}), L.current.querySelectorAll('a[href$=".pdf"], a[data-type="pdf"]').forEach((o) => {
|
|
671
|
+
o._pdfHandler && o.removeEventListener("click", o._pdfHandler), o._pdfHandler = (I) => {
|
|
672
|
+
I.preventDefault(), I.stopPropagation(), M({
|
|
673
|
+
type: "pdf",
|
|
674
|
+
src: o.href,
|
|
675
|
+
alt: o.textContent || "PDF Document",
|
|
676
|
+
caption: o.title || o.textContent || ""
|
|
677
|
+
});
|
|
678
|
+
}, o.addEventListener("click", o._pdfHandler);
|
|
679
|
+
}), L.current.querySelectorAll(".artifactuse-pdf-container, [data-pdf-viewer]").forEach((o) => {
|
|
680
|
+
var B;
|
|
681
|
+
o._pdfHandler && o.removeEventListener("click", o._pdfHandler);
|
|
682
|
+
const I = o.dataset.pdfSrc || ((B = o.querySelector("iframe")) == null ? void 0 : B.src) || "";
|
|
683
|
+
I && (o._pdfHandler = (j) => {
|
|
684
|
+
j.preventDefault(), j.stopPropagation(), M({
|
|
685
|
+
type: "pdf",
|
|
686
|
+
src: I,
|
|
687
|
+
alt: "PDF Document",
|
|
688
|
+
caption: o.dataset.caption || ""
|
|
689
|
+
});
|
|
690
|
+
}, o.addEventListener("click", o._pdfHandler), o.style.cursor = "pointer");
|
|
691
|
+
}), L.current.querySelectorAll(".artifactuse-video-preview-wrapper, .video-preview-wrapper").forEach((o) => {
|
|
692
|
+
o._clickHandler && o.removeEventListener("click", o._clickHandler), o._clickHandler = (I) => {
|
|
693
|
+
if (I.target.closest(".artifactuse-video-play-button")) return;
|
|
694
|
+
const B = o.dataset.videoUrl || o.dataset.url;
|
|
695
|
+
B && window.open(B, "_blank", "noopener,noreferrer");
|
|
696
|
+
}, o.addEventListener("click", o._clickHandler);
|
|
697
|
+
});
|
|
698
|
+
}, [M]), ye = d(() => {
|
|
699
|
+
if (!L.current) return;
|
|
700
|
+
L.current.querySelectorAll("img").forEach((A) => {
|
|
701
|
+
A._lightboxHandler && (A.removeEventListener("click", A._lightboxHandler), delete A._lightboxHandler);
|
|
702
|
+
}), L.current.querySelectorAll('a[href$=".pdf"], a[data-type="pdf"]').forEach((A) => {
|
|
703
|
+
A._pdfHandler && (A.removeEventListener("click", A._pdfHandler), delete A._pdfHandler);
|
|
704
|
+
}), L.current.querySelectorAll(".artifactuse-pdf-container, [data-pdf-viewer]").forEach((A) => {
|
|
705
|
+
A._pdfHandler && (A.removeEventListener("click", A._pdfHandler), delete A._pdfHandler);
|
|
706
|
+
}), L.current.querySelectorAll(".artifactuse-video-preview-wrapper, .video-preview-wrapper").forEach((A) => {
|
|
707
|
+
A._clickHandler && (A.removeEventListener("click", A._clickHandler), delete A._clickHandler);
|
|
708
|
+
});
|
|
709
|
+
}, []), re = d(() => {
|
|
710
|
+
J.current && clearTimeout(J.current), J.current = setTimeout(async () => {
|
|
711
|
+
if (D != null && D.initializeContent && L.current)
|
|
712
|
+
try {
|
|
713
|
+
await D.initializeContent(L.current);
|
|
714
|
+
} catch (h) {
|
|
715
|
+
console.error("Failed to initialize content:", h);
|
|
716
|
+
}
|
|
717
|
+
me();
|
|
718
|
+
}, 100);
|
|
719
|
+
}, [D, me]);
|
|
720
|
+
z(() => {
|
|
721
|
+
if (t) {
|
|
722
|
+
const h = k(t, a);
|
|
723
|
+
ne(h.html), fe(h.artifacts), h.artifacts.length > 0 && r && r(h.artifacts), l || re();
|
|
724
|
+
}
|
|
725
|
+
}, [t, a, k, l, re, r]), z(() => {
|
|
726
|
+
K.current === !0 && l === !1 && re(), K.current = l;
|
|
727
|
+
}, [l, re]), z(() => (l && X(!0), l || re(), () => {
|
|
728
|
+
J.current && clearTimeout(J.current), ye();
|
|
729
|
+
}), []);
|
|
730
|
+
const Le = d((h) => {
|
|
731
|
+
f(h), p && p(h);
|
|
732
|
+
}, [f, p]), _e = d((h) => {
|
|
733
|
+
u && u(h);
|
|
734
|
+
}, [u]), Ne = d((h) => {
|
|
735
|
+
g && g(h);
|
|
736
|
+
}, [g]), Pe = d((h) => {
|
|
737
|
+
c && c(h);
|
|
738
|
+
}, [c]), Ee = d((h) => {
|
|
739
|
+
b && b(h);
|
|
740
|
+
}, [b]), Te = d((h) => {
|
|
741
|
+
P && P(h);
|
|
742
|
+
}, [P]), Me = d((h) => {
|
|
743
|
+
x && x(h);
|
|
744
|
+
}, [x]), $e = (h, ve) => {
|
|
745
|
+
switch (h.type) {
|
|
746
|
+
case "html":
|
|
747
|
+
return /* @__PURE__ */ e.createElement(
|
|
748
|
+
"div",
|
|
749
|
+
{
|
|
750
|
+
key: `html-${ve}`,
|
|
751
|
+
dangerouslySetInnerHTML: { __html: h.content }
|
|
752
|
+
}
|
|
753
|
+
);
|
|
754
|
+
case "form":
|
|
755
|
+
return h.artifact.isInline ? /* @__PURE__ */ e.createElement(
|
|
756
|
+
nt,
|
|
757
|
+
{
|
|
758
|
+
key: `form-${h.artifact.id}`,
|
|
759
|
+
artifact: h.artifact,
|
|
760
|
+
theme: Y,
|
|
761
|
+
initialState: Ce,
|
|
762
|
+
onSubmit: Pe,
|
|
763
|
+
onCancel: Ee,
|
|
764
|
+
onButtonClick: Te
|
|
765
|
+
}
|
|
766
|
+
) : null;
|
|
767
|
+
case "social":
|
|
768
|
+
return /* @__PURE__ */ e.createElement(
|
|
769
|
+
Et,
|
|
770
|
+
{
|
|
771
|
+
key: `social-${h.artifact.id}`,
|
|
772
|
+
artifact: h.artifact,
|
|
773
|
+
theme: Y,
|
|
774
|
+
onCopy: Me
|
|
775
|
+
}
|
|
776
|
+
);
|
|
777
|
+
case "panel":
|
|
778
|
+
return n ? /* @__PURE__ */ e.createElement(
|
|
779
|
+
at,
|
|
780
|
+
{
|
|
781
|
+
key: `panel-${h.artifact.id}`,
|
|
782
|
+
artifact: h.artifact,
|
|
783
|
+
isActive: ge === h.artifact.id,
|
|
784
|
+
onOpen: Le,
|
|
785
|
+
onCopy: _e,
|
|
786
|
+
onDownload: Ne
|
|
787
|
+
}
|
|
788
|
+
) : null;
|
|
789
|
+
default:
|
|
790
|
+
return null;
|
|
791
|
+
}
|
|
792
|
+
};
|
|
793
|
+
return /* @__PURE__ */ e.createElement(
|
|
794
|
+
"div",
|
|
795
|
+
{
|
|
796
|
+
ref: q,
|
|
797
|
+
className: `artifactuse-agent-message ${E}`.trim()
|
|
798
|
+
},
|
|
799
|
+
/* @__PURE__ */ e.createElement("div", { ref: L, className: "artifactuse-message-content" }, pe.map($e)),
|
|
800
|
+
/* @__PURE__ */ e.createElement(
|
|
801
|
+
vt,
|
|
802
|
+
{
|
|
803
|
+
isOpen: ae,
|
|
804
|
+
type: ie,
|
|
805
|
+
src: oe,
|
|
806
|
+
alt: w,
|
|
807
|
+
caption: N,
|
|
808
|
+
onClose: Z
|
|
809
|
+
}
|
|
810
|
+
)
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
_t.propTypes = {
|
|
814
|
+
/** The raw message content (markdown/HTML from AI) */
|
|
815
|
+
content: (t, a) => {
|
|
816
|
+
if (typeof t[a] != "string")
|
|
817
|
+
return new Error(`${a} must be a string`);
|
|
818
|
+
},
|
|
819
|
+
/** Unique message ID */
|
|
820
|
+
messageId: (t, a) => {
|
|
821
|
+
if (t[a] !== void 0 && typeof t[a] != "string")
|
|
822
|
+
return new Error(`${a} must be a string`);
|
|
823
|
+
},
|
|
824
|
+
/** Whether to show artifact cards inline */
|
|
825
|
+
inlineCards: (t, a) => {
|
|
826
|
+
if (t[a] !== void 0 && typeof t[a] != "boolean")
|
|
827
|
+
return new Error(`${a} must be a boolean`);
|
|
828
|
+
},
|
|
829
|
+
/** Whether the message is still being typed/streamed */
|
|
830
|
+
typing: (t, a) => {
|
|
831
|
+
if (t[a] !== void 0 && typeof t[a] != "boolean")
|
|
832
|
+
return new Error(`${a} must be a boolean`);
|
|
833
|
+
},
|
|
834
|
+
/** Whether this is the last/most recent message in the conversation */
|
|
835
|
+
isLastMessage: (t, a) => {
|
|
836
|
+
if (t[a] !== void 0 && typeof t[a] != "boolean")
|
|
837
|
+
return new Error(`${a} must be a boolean`);
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
function Pt({
|
|
841
|
+
onAIRequest: t,
|
|
842
|
+
onSave: a,
|
|
843
|
+
onExport: n,
|
|
844
|
+
className: l = ""
|
|
845
|
+
}) {
|
|
846
|
+
const {
|
|
847
|
+
state: s,
|
|
848
|
+
activeArtifact: r,
|
|
849
|
+
artifactCount: p,
|
|
850
|
+
hasArtifacts: u,
|
|
851
|
+
closePanel: g,
|
|
852
|
+
toggleFullscreen: c,
|
|
853
|
+
setViewMode: b,
|
|
854
|
+
getPanelUrl: P,
|
|
855
|
+
openArtifact: x,
|
|
856
|
+
instance: _
|
|
857
|
+
} = de(), E = W(null), k = W(null), f = W(null), v = W(null), F = W(null), [D, q] = C(!1), [L, J] = C(!1), [K, U] = C(!0), [ne, le] = C(!1), [fe, te] = C(!1), [X, ae] = C(!1), [V, ie] = C(50), [ee, oe] = C(50), i = W(null), w = W(null), y = W(null), N = W(null), T = W(null), Y = $(() => r ? we(r.language) : "", [r]), ge = $(() => r ? qe(r.language) : "", [r]), pe = $(() => r ? P(r) : null, [r, P]), Ce = $(() => r ? Ye(r.language) : "plaintext", [r]), M = $(() => s.artifacts.filter((m) => !m.isInline), [s.artifacts]), Z = $(() => r ? M.findIndex((m) => m.id === r.id) : -1, [r, M]), me = $(() => {
|
|
858
|
+
var m;
|
|
859
|
+
return ((m = _ == null ? void 0 : _.config) == null ? void 0 : m.branding) !== !1;
|
|
860
|
+
}, [_]), ye = $(() => r ? V : Math.min(V, 30), [r, V]), re = d((m) => `<svg viewBox="0 0 24 24" fill="currentColor">${qe(m)}</svg>`, []), Le = d(() => {
|
|
861
|
+
te(!1), _.state.clearActiveArtifact();
|
|
862
|
+
}, [_]), _e = d(() => {
|
|
863
|
+
if (!v.current || !(r != null && r.code)) return;
|
|
864
|
+
const m = r.code.split(`
|
|
865
|
+
`).length, S = Array.from({ length: m }, (G, O) => `<div>${O + 1}</div>`).join("");
|
|
866
|
+
v.current.innerHTML = S;
|
|
867
|
+
}, [r]), Ne = d(() => {
|
|
868
|
+
k.current && Ge() && (window.Prism.highlightElement(k.current), setTimeout(() => {
|
|
869
|
+
Pe();
|
|
870
|
+
}, 0));
|
|
871
|
+
}, []), Pe = d(() => {
|
|
872
|
+
var S;
|
|
873
|
+
const m = (S = k.current) == null ? void 0 : S.closest("pre");
|
|
874
|
+
if (m && F.current && v.current) {
|
|
875
|
+
const O = window.getComputedStyle(m).backgroundColor;
|
|
876
|
+
O && O !== "rgba(0, 0, 0, 0)" && O !== "transparent" && (F.current.style.backgroundColor = O, v.current.style.backgroundColor = O);
|
|
877
|
+
}
|
|
878
|
+
}, []), Ee = d(() => {
|
|
879
|
+
_e(), ne || Ne();
|
|
880
|
+
}, [_e, Ne, ne]), Te = d(() => {
|
|
881
|
+
clearTimeout(T.current), U(!1), E.current && r && (_.bridge.setIframe(E.current), _.bridge.loadArtifact(r));
|
|
882
|
+
}, [r, _]), Me = d(() => {
|
|
883
|
+
clearTimeout(T.current), U(!1);
|
|
884
|
+
}, []), $e = d(() => {
|
|
885
|
+
clearTimeout(T.current), T.current = setTimeout(() => {
|
|
886
|
+
U(!1);
|
|
887
|
+
}, 1e4);
|
|
888
|
+
}, []), h = d(async () => {
|
|
889
|
+
if (r)
|
|
890
|
+
try {
|
|
891
|
+
await navigator.clipboard.writeText(r.code), q(!0), setTimeout(() => q(!1), 2e3);
|
|
892
|
+
} catch (m) {
|
|
893
|
+
console.error("Failed to copy:", m);
|
|
894
|
+
}
|
|
895
|
+
}, [r]), ve = d(() => {
|
|
896
|
+
if (!r) return;
|
|
897
|
+
const { code: m, language: S, title: G } = r, O = Re(S), he = `${G.toLowerCase().replace(/\s+/g, "-")}.${O}`, ke = new Blob([m], { type: "text/plain" }), se = URL.createObjectURL(ke), Q = document.createElement("a");
|
|
898
|
+
Q.href = se, Q.download = he, document.body.appendChild(Q), Q.click(), document.body.removeChild(Q), URL.revokeObjectURL(se);
|
|
899
|
+
}, [r]), Ae = d(async () => {
|
|
900
|
+
if (!(X || M.length === 0)) {
|
|
901
|
+
ae(!0);
|
|
902
|
+
try {
|
|
903
|
+
const m = new et(), S = /* @__PURE__ */ new Map();
|
|
904
|
+
for (const Q of M) {
|
|
905
|
+
if (!Q.code) continue;
|
|
906
|
+
const Be = Re(Q.language);
|
|
907
|
+
let Fe = (Q.title || "untitled").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-_]/g, ""), We = `${Fe}.${Be}`;
|
|
908
|
+
const ze = S.get(We) || 0;
|
|
909
|
+
ze > 0 && (We = `${Fe}-${ze}.${Be}`), S.set(`${Fe}.${Be}`, ze + 1), m.file(We, Q.code);
|
|
910
|
+
}
|
|
911
|
+
const G = await m.generateAsync({ type: "blob" }), he = `artifacts-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.zip`, ke = URL.createObjectURL(G), se = document.createElement("a");
|
|
912
|
+
se.href = ke, se.download = he, document.body.appendChild(se), se.click(), document.body.removeChild(se), URL.revokeObjectURL(ke);
|
|
913
|
+
} catch (m) {
|
|
914
|
+
console.error("Failed to create ZIP:", m);
|
|
915
|
+
} finally {
|
|
916
|
+
ae(!1);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
}, [X, M]), Se = d(() => {
|
|
920
|
+
Z > 0 && x(M[Z - 1]);
|
|
921
|
+
}, [Z, x, M]), A = d(() => {
|
|
922
|
+
Z < M.length - 1 && x(M[Z + 1]);
|
|
923
|
+
}, [Z, x, M]), Ie = d((m) => {
|
|
924
|
+
te(!0), x(m), J(!1);
|
|
925
|
+
}, [x]), o = d((m) => {
|
|
926
|
+
i.current = {
|
|
927
|
+
startX: m.clientX,
|
|
928
|
+
startWidth: V
|
|
929
|
+
}, document.addEventListener("mousemove", I), document.addEventListener("mouseup", B), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none", document.querySelectorAll("iframe").forEach((S) => {
|
|
930
|
+
S.style.pointerEvents = "none";
|
|
931
|
+
});
|
|
932
|
+
}, [V]), I = d((m) => {
|
|
933
|
+
if (!i.current) return;
|
|
934
|
+
const S = window.innerWidth, O = (i.current.startX - m.clientX) / S * 100, he = i.current.startWidth + O;
|
|
935
|
+
ie(Math.min(Math.max(he, 25), 75));
|
|
936
|
+
}, []), B = d(() => {
|
|
937
|
+
i.current = null, document.removeEventListener("mousemove", I), document.removeEventListener("mouseup", B), document.body.style.cursor = "", document.body.style.userSelect = "", document.querySelectorAll("iframe").forEach((m) => {
|
|
938
|
+
m.style.pointerEvents = "";
|
|
939
|
+
});
|
|
940
|
+
}, [I]), j = d((m) => {
|
|
941
|
+
if (!f.current) return;
|
|
942
|
+
const S = f.current.getBoundingClientRect();
|
|
943
|
+
w.current = {
|
|
944
|
+
startX: m.clientX,
|
|
945
|
+
startPosition: ee,
|
|
946
|
+
contentLeft: S.left,
|
|
947
|
+
contentWidth: S.width
|
|
948
|
+
}, document.addEventListener("mousemove", ce), document.addEventListener("mouseup", be), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.querySelectorAll("iframe").forEach((G) => {
|
|
949
|
+
G.style.pointerEvents = "none";
|
|
950
|
+
});
|
|
951
|
+
}, [ee]), ce = d((m) => {
|
|
952
|
+
if (!w.current) return;
|
|
953
|
+
const G = (m.clientX - w.current.contentLeft) / w.current.contentWidth * 100;
|
|
954
|
+
oe(Math.min(Math.max(G, 20), 80));
|
|
955
|
+
}, []), be = d(() => {
|
|
956
|
+
w.current = null, document.removeEventListener("mousemove", ce), document.removeEventListener("mouseup", be), document.body.style.cursor = "", document.body.style.userSelect = "", document.querySelectorAll("iframe").forEach((m) => {
|
|
957
|
+
m.style.pointerEvents = "";
|
|
958
|
+
});
|
|
959
|
+
}, [ce]);
|
|
960
|
+
if (z(() => {
|
|
961
|
+
r && (U(!0), $e(), Ee());
|
|
962
|
+
}, [r == null ? void 0 : r.id]), z(() => {
|
|
963
|
+
(s.viewMode === "code" || s.viewMode === "split") && Ee();
|
|
964
|
+
}, [s.viewMode, Ee]), z(() => (t && _.on("ai:request", t), a && _.on("save:request", a), n && _.on("export:complete", n), () => {
|
|
965
|
+
t && _.off("ai:request", t), a && _.off("save:request", a), n && _.off("export:complete", n);
|
|
966
|
+
}), [_, t, a, n]), z(() => () => {
|
|
967
|
+
B(), be(), clearTimeout(y.current), clearTimeout(N.current), clearTimeout(T.current);
|
|
968
|
+
}, [B, be]), !s.isPanelOpen) return null;
|
|
969
|
+
const He = [
|
|
970
|
+
"artifactuse-panel",
|
|
971
|
+
s.isFullscreen && "artifactuse-panel--fullscreen",
|
|
972
|
+
!r && u && "artifactuse-panel--list",
|
|
973
|
+
!u && "artifactuse-panel--empty",
|
|
974
|
+
l
|
|
975
|
+
].filter(Boolean).join(" "), Xe = [
|
|
976
|
+
"artifactuse-panel__content",
|
|
977
|
+
`artifactuse-panel__content--${s.viewMode}`
|
|
978
|
+
].join(" ");
|
|
979
|
+
return u ? r ? /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
980
|
+
"div",
|
|
981
|
+
{
|
|
982
|
+
className: He,
|
|
983
|
+
style: s.isFullscreen ? void 0 : { width: `${V}%` }
|
|
984
|
+
},
|
|
985
|
+
!s.isFullscreen && /* @__PURE__ */ e.createElement(
|
|
986
|
+
"div",
|
|
987
|
+
{
|
|
988
|
+
className: "artifactuse-panel__resize-handle",
|
|
989
|
+
onMouseDown: o
|
|
990
|
+
},
|
|
991
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__resize-handle-line" })
|
|
992
|
+
),
|
|
993
|
+
/* @__PURE__ */ e.createElement("header", { className: "artifactuse-panel__header" }, fe && /* @__PURE__ */ e.createElement(
|
|
994
|
+
"button",
|
|
995
|
+
{
|
|
996
|
+
className: "artifactuse-panel__back",
|
|
997
|
+
title: "Back to list",
|
|
998
|
+
onClick: Le
|
|
999
|
+
},
|
|
1000
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "15 18 9 12 15 6" }))
|
|
1001
|
+
), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title" }, /* @__PURE__ */ e.createElement(
|
|
1002
|
+
"span",
|
|
1003
|
+
{
|
|
1004
|
+
className: "artifactuse-panel__icon",
|
|
1005
|
+
dangerouslySetInnerHTML: { __html: `<svg viewBox="0 0 24 24" fill="currentColor">${ge}</svg>` }
|
|
1006
|
+
}
|
|
1007
|
+
), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title-content" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__name" }, r.title || "Untitled"), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__meta" }, Y, r.lineCount && ` • ${r.lineCount} lines`))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__tabs" }, /* @__PURE__ */ e.createElement(
|
|
1008
|
+
"button",
|
|
1009
|
+
{
|
|
1010
|
+
className: `artifactuse-panel__tab ${s.viewMode === "preview" ? "artifactuse-panel__tab--active" : ""}`,
|
|
1011
|
+
disabled: !r.isPreviewable,
|
|
1012
|
+
title: "Preview",
|
|
1013
|
+
onClick: () => b("preview")
|
|
1014
|
+
},
|
|
1015
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }), /* @__PURE__ */ e.createElement("circle", { cx: "12", cy: "12", r: "3" }))
|
|
1016
|
+
), /* @__PURE__ */ e.createElement(
|
|
1017
|
+
"button",
|
|
1018
|
+
{
|
|
1019
|
+
className: `artifactuse-panel__tab ${s.viewMode === "code" ? "artifactuse-panel__tab--active" : ""}`,
|
|
1020
|
+
title: "Code",
|
|
1021
|
+
onClick: () => b("code")
|
|
1022
|
+
},
|
|
1023
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "16 18 22 12 16 6" }), /* @__PURE__ */ e.createElement("polyline", { points: "8 6 2 12 8 18" }))
|
|
1024
|
+
), /* @__PURE__ */ e.createElement(
|
|
1025
|
+
"button",
|
|
1026
|
+
{
|
|
1027
|
+
className: `artifactuse-panel__tab ${s.viewMode === "split" ? "artifactuse-panel__tab--active" : ""}`,
|
|
1028
|
+
disabled: !r.isPreviewable,
|
|
1029
|
+
title: "Split view",
|
|
1030
|
+
onClick: () => b("split")
|
|
1031
|
+
},
|
|
1032
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2" }), /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "3", x2: "12", y2: "21" }))
|
|
1033
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__actions" }, /* @__PURE__ */ e.createElement(
|
|
1034
|
+
"button",
|
|
1035
|
+
{
|
|
1036
|
+
className: "artifactuse-panel__action",
|
|
1037
|
+
title: s.isFullscreen ? "Exit fullscreen" : "Fullscreen",
|
|
1038
|
+
onClick: c
|
|
1039
|
+
},
|
|
1040
|
+
s.isFullscreen ? /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "4 14 10 14 10 20" }), /* @__PURE__ */ e.createElement("polyline", { points: "20 10 14 10 14 4" }), /* @__PURE__ */ e.createElement("line", { x1: "14", y1: "10", x2: "21", y2: "3" }), /* @__PURE__ */ e.createElement("line", { x1: "3", y1: "21", x2: "10", y2: "14" })) : /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "15 3 21 3 21 9" }), /* @__PURE__ */ e.createElement("polyline", { points: "9 21 3 21 3 15" }), /* @__PURE__ */ e.createElement("line", { x1: "21", y1: "3", x2: "14", y2: "10" }), /* @__PURE__ */ e.createElement("line", { x1: "3", y1: "21", x2: "10", y2: "14" }))
|
|
1041
|
+
), /* @__PURE__ */ e.createElement(
|
|
1042
|
+
"button",
|
|
1043
|
+
{
|
|
1044
|
+
className: "artifactuse-panel__action artifactuse-panel__action--close",
|
|
1045
|
+
title: "Close",
|
|
1046
|
+
onClick: g
|
|
1047
|
+
},
|
|
1048
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))
|
|
1049
|
+
))),
|
|
1050
|
+
/* @__PURE__ */ e.createElement("div", { className: Xe, ref: f }, (s.viewMode === "preview" || s.viewMode === "split") && /* @__PURE__ */ e.createElement(
|
|
1051
|
+
"div",
|
|
1052
|
+
{
|
|
1053
|
+
className: "artifactuse-panel__preview",
|
|
1054
|
+
style: s.viewMode === "split" ? { width: `${ee}%` } : void 0
|
|
1055
|
+
},
|
|
1056
|
+
K && pe && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__loading" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__spinner" })),
|
|
1057
|
+
pe ? /* @__PURE__ */ e.createElement(
|
|
1058
|
+
"iframe",
|
|
1059
|
+
{
|
|
1060
|
+
ref: E,
|
|
1061
|
+
src: pe,
|
|
1062
|
+
className: `artifactuse-panel__iframe ${K ? "artifactuse-panel__iframe--loading" : ""}`,
|
|
1063
|
+
sandbox: "allow-scripts allow-same-origin allow-forms allow-popups allow-modals",
|
|
1064
|
+
onLoad: Te,
|
|
1065
|
+
onError: Me
|
|
1066
|
+
}
|
|
1067
|
+
) : /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__no-preview" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }, /* @__PURE__ */ e.createElement("path", { d: "M9 17H7A5 5 0 0 1 7 7h2" }), /* @__PURE__ */ e.createElement("path", { d: "M15 7h2a5 5 0 1 1 0 10h-2" }), /* @__PURE__ */ e.createElement("line", { x1: "8", y1: "12", x2: "16", y2: "12" })), /* @__PURE__ */ e.createElement("p", null, "Preview not available for ", Y))
|
|
1068
|
+
), (s.viewMode === "code" || s.viewMode === "split") && /* @__PURE__ */ e.createElement(
|
|
1069
|
+
"div",
|
|
1070
|
+
{
|
|
1071
|
+
className: "artifactuse-panel__code",
|
|
1072
|
+
style: s.viewMode === "split" ? { width: `${100 - ee}%` } : void 0
|
|
1073
|
+
},
|
|
1074
|
+
s.viewMode === "split" && /* @__PURE__ */ e.createElement(
|
|
1075
|
+
"div",
|
|
1076
|
+
{
|
|
1077
|
+
className: "artifactuse-panel__split-handle",
|
|
1078
|
+
onMouseDown: j
|
|
1079
|
+
},
|
|
1080
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__split-handle-line" })
|
|
1081
|
+
),
|
|
1082
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__code-scroll", ref: F }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__line-numbers", ref: v }), /* @__PURE__ */ e.createElement("pre", { className: "artifactuse-panel__code-block" }, /* @__PURE__ */ e.createElement(
|
|
1083
|
+
"code",
|
|
1084
|
+
{
|
|
1085
|
+
ref: k,
|
|
1086
|
+
className: `language-${Ce}`
|
|
1087
|
+
},
|
|
1088
|
+
r.code
|
|
1089
|
+
)))
|
|
1090
|
+
)),
|
|
1091
|
+
/* @__PURE__ */ e.createElement("footer", { className: "artifactuse-panel__footer" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__footer-left" }, me && /* @__PURE__ */ e.createElement(
|
|
1092
|
+
"a",
|
|
1093
|
+
{
|
|
1094
|
+
href: "https://artifactuse.com",
|
|
1095
|
+
target: "_blank",
|
|
1096
|
+
rel: "noopener noreferrer",
|
|
1097
|
+
className: "artifactuse-panel__branding",
|
|
1098
|
+
title: "Powered by Artifactuse"
|
|
1099
|
+
},
|
|
1100
|
+
/* @__PURE__ */ e.createElement("svg", { width: "16", height: "16", viewBox: "0 0 32 32", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M16 2L2 9l14 7 14-7-14-7zM2 23l14 7 14-7M2 16l14 7 14-7" })),
|
|
1101
|
+
/* @__PURE__ */ e.createElement("span", null, "Artifactuse")
|
|
1102
|
+
), r.code && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__badge artifactuse-panel__badge--secondary" }, je(new Blob([r.code]).size))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__footer-right" }, /* @__PURE__ */ e.createElement(
|
|
1103
|
+
"button",
|
|
1104
|
+
{
|
|
1105
|
+
className: `artifactuse-panel__footer-action ${D ? "artifactuse-panel__footer-action--success" : ""}`,
|
|
1106
|
+
title: D ? "Copied!" : "Copy code",
|
|
1107
|
+
onClick: h
|
|
1108
|
+
},
|
|
1109
|
+
D ? /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "20 6 9 17 4 12" })) : /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), /* @__PURE__ */ e.createElement("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" }))
|
|
1110
|
+
), /* @__PURE__ */ e.createElement(
|
|
1111
|
+
"button",
|
|
1112
|
+
{
|
|
1113
|
+
className: "artifactuse-panel__footer-action",
|
|
1114
|
+
title: "Download",
|
|
1115
|
+
onClick: ve
|
|
1116
|
+
},
|
|
1117
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), /* @__PURE__ */ e.createElement("polyline", { points: "7 10 12 15 17 10" }), /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "15", x2: "12", y2: "3" }))
|
|
1118
|
+
), M.length > 1 && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__nav" }, /* @__PURE__ */ e.createElement(
|
|
1119
|
+
"button",
|
|
1120
|
+
{
|
|
1121
|
+
className: "artifactuse-panel__nav-btn",
|
|
1122
|
+
disabled: Z <= 0,
|
|
1123
|
+
title: "Previous artifact",
|
|
1124
|
+
onClick: Se
|
|
1125
|
+
},
|
|
1126
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "15 18 9 12 15 6" }))
|
|
1127
|
+
), /* @__PURE__ */ e.createElement(
|
|
1128
|
+
"button",
|
|
1129
|
+
{
|
|
1130
|
+
className: "artifactuse-panel__nav-trigger",
|
|
1131
|
+
onClick: () => J(!L)
|
|
1132
|
+
},
|
|
1133
|
+
/* @__PURE__ */ e.createElement("span", null, Z + 1, " / ", M.length),
|
|
1134
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "6 9 12 15 18 9" }))
|
|
1135
|
+
), /* @__PURE__ */ e.createElement(
|
|
1136
|
+
"button",
|
|
1137
|
+
{
|
|
1138
|
+
className: "artifactuse-panel__nav-btn",
|
|
1139
|
+
disabled: Z >= M.length - 1,
|
|
1140
|
+
title: "Next artifact",
|
|
1141
|
+
onClick: A
|
|
1142
|
+
},
|
|
1143
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "9 18 15 12 9 6" }))
|
|
1144
|
+
), L && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__artifact-list" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__artifact-list-header" }, /* @__PURE__ */ e.createElement("span", null, "All Artifacts (", M.length, ")"), /* @__PURE__ */ e.createElement(
|
|
1145
|
+
"button",
|
|
1146
|
+
{
|
|
1147
|
+
className: "artifactuse-panel__artifact-list-close",
|
|
1148
|
+
onClick: () => J(!1)
|
|
1149
|
+
},
|
|
1150
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))
|
|
1151
|
+
)), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__artifact-list-items" }, M.map((m, S) => /* @__PURE__ */ e.createElement(
|
|
1152
|
+
"button",
|
|
1153
|
+
{
|
|
1154
|
+
key: m.id,
|
|
1155
|
+
className: `artifactuse-panel__artifact-item ${m.id === r.id ? "artifactuse-panel__artifact-item--active" : ""}`,
|
|
1156
|
+
onClick: () => Ie(m)
|
|
1157
|
+
},
|
|
1158
|
+
/* @__PURE__ */ e.createElement(
|
|
1159
|
+
"span",
|
|
1160
|
+
{
|
|
1161
|
+
className: "artifactuse-panel__artifact-item-icon",
|
|
1162
|
+
dangerouslySetInnerHTML: { __html: re(m.language) }
|
|
1163
|
+
}
|
|
1164
|
+
),
|
|
1165
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__artifact-item-content" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__artifact-item-title" }, m.title || "Untitled"), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__artifact-item-meta" }, we(m.language), m.lineCount && ` • ${m.lineCount} lines`)),
|
|
1166
|
+
/* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__artifact-item-index" }, S + 1)
|
|
1167
|
+
)))))))
|
|
1168
|
+
), s.isFullscreen && /* @__PURE__ */ e.createElement(
|
|
1169
|
+
"div",
|
|
1170
|
+
{
|
|
1171
|
+
className: "artifactuse-panel__backdrop",
|
|
1172
|
+
onClick: g
|
|
1173
|
+
}
|
|
1174
|
+
)) : /* @__PURE__ */ e.createElement("div", { className: He, style: s.isFullscreen ? void 0 : { width: `${ye}%` } }, !s.isFullscreen && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__resize-handle", onMouseDown: o }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__resize-handle-line" })), /* @__PURE__ */ e.createElement("header", { className: "artifactuse-panel__header artifactuse-panel__header--simple" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__icon" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "16 18 22 12 16 6" }), /* @__PURE__ */ e.createElement("polyline", { points: "8 6 2 12 8 18" }))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title-content" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__name" }, "Artifacts"), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__meta" }, M.length, " available"))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__actions" }, /* @__PURE__ */ e.createElement(
|
|
1175
|
+
"button",
|
|
1176
|
+
{
|
|
1177
|
+
className: `artifactuse-panel__action ${X ? "artifactuse-panel__action--loading" : ""}`,
|
|
1178
|
+
disabled: X,
|
|
1179
|
+
title: "Download all as ZIP",
|
|
1180
|
+
onClick: Ae
|
|
1181
|
+
},
|
|
1182
|
+
X ? /* @__PURE__ */ e.createElement("svg", { className: "artifactuse-panel__spinner-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("circle", { cx: "12", cy: "12", r: "10", strokeDasharray: "32", strokeDashoffset: "32" })) : /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), /* @__PURE__ */ e.createElement("polyline", { points: "7 10 12 15 17 10" }), /* @__PURE__ */ e.createElement("line", { x1: "12", y1: "15", x2: "12", y2: "3" }))
|
|
1183
|
+
), /* @__PURE__ */ e.createElement(
|
|
1184
|
+
"button",
|
|
1185
|
+
{
|
|
1186
|
+
className: "artifactuse-panel__action artifactuse-panel__action--close",
|
|
1187
|
+
title: "Close panel",
|
|
1188
|
+
onClick: g
|
|
1189
|
+
},
|
|
1190
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))
|
|
1191
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__list" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__list-items" }, M.map((m, S) => /* @__PURE__ */ e.createElement(
|
|
1192
|
+
"button",
|
|
1193
|
+
{
|
|
1194
|
+
key: m.id,
|
|
1195
|
+
className: "artifactuse-panel__list-item",
|
|
1196
|
+
onClick: () => Ie(m)
|
|
1197
|
+
},
|
|
1198
|
+
/* @__PURE__ */ e.createElement(
|
|
1199
|
+
"span",
|
|
1200
|
+
{
|
|
1201
|
+
className: "artifactuse-panel__list-item-icon",
|
|
1202
|
+
dangerouslySetInnerHTML: { __html: re(m.language) }
|
|
1203
|
+
}
|
|
1204
|
+
),
|
|
1205
|
+
/* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__list-item-content" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__list-item-title" }, m.title || "Untitled"), /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__list-item-meta" }, we(m.language), m.lineCount && ` • ${m.lineCount} lines`)),
|
|
1206
|
+
/* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__list-item-arrow" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "9 18 15 12 9 6" })))
|
|
1207
|
+
)))), /* @__PURE__ */ e.createElement("footer", { className: "artifactuse-panel__footer artifactuse-panel__footer--simple" }, me && /* @__PURE__ */ e.createElement(
|
|
1208
|
+
"a",
|
|
1209
|
+
{
|
|
1210
|
+
href: "https://artifactuse.com",
|
|
1211
|
+
target: "_blank",
|
|
1212
|
+
rel: "noopener noreferrer",
|
|
1213
|
+
className: "artifactuse-panel__branding"
|
|
1214
|
+
},
|
|
1215
|
+
/* @__PURE__ */ e.createElement("svg", { width: "16", height: "16", viewBox: "0 0 32 32", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M16 2L2 9l14 7 14-7-14-7zM2 23l14 7 14-7M2 16l14 7 14-7" })),
|
|
1216
|
+
/* @__PURE__ */ e.createElement("span", null, "Artifactuse")
|
|
1217
|
+
))) : /* @__PURE__ */ e.createElement("div", { className: He, style: s.isFullscreen ? void 0 : { width: `${ye}%` } }, !s.isFullscreen && /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__resize-handle", onMouseDown: o }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__resize-handle-line" })), /* @__PURE__ */ e.createElement("header", { className: "artifactuse-panel__header artifactuse-panel__header--simple" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__icon" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("polyline", { points: "16 18 22 12 16 6" }), /* @__PURE__ */ e.createElement("polyline", { points: "8 6 2 12 8 18" }))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__title-content" }, /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel__name" }, "Artifacts"))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__actions" }, /* @__PURE__ */ e.createElement(
|
|
1218
|
+
"button",
|
|
1219
|
+
{
|
|
1220
|
+
className: "artifactuse-panel__action artifactuse-panel__action--close",
|
|
1221
|
+
title: "Close panel",
|
|
1222
|
+
onClick: g
|
|
1223
|
+
},
|
|
1224
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" }, /* @__PURE__ */ e.createElement("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), /* @__PURE__ */ e.createElement("line", { x1: "6", y1: "6", x2: "18", y2: "18" }))
|
|
1225
|
+
))), /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__empty" }, /* @__PURE__ */ e.createElement("div", { className: "artifactuse-panel__empty-icon" }, /* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }, /* @__PURE__ */ e.createElement("path", { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" }), /* @__PURE__ */ e.createElement("polyline", { points: "14 2 14 8 20 8" }))), /* @__PURE__ */ e.createElement("h3", { className: "artifactuse-panel__empty-title" }, "No artifacts yet"), /* @__PURE__ */ e.createElement("p", { className: "artifactuse-panel__empty-text" }, "Code blocks, forms, and other interactive content will appear here as the AI generates them.")), /* @__PURE__ */ e.createElement("footer", { className: "artifactuse-panel__footer artifactuse-panel__footer--simple" }, me && /* @__PURE__ */ e.createElement(
|
|
1226
|
+
"a",
|
|
1227
|
+
{
|
|
1228
|
+
href: "https://artifactuse.com",
|
|
1229
|
+
target: "_blank",
|
|
1230
|
+
rel: "noopener noreferrer",
|
|
1231
|
+
className: "artifactuse-panel__branding"
|
|
1232
|
+
},
|
|
1233
|
+
/* @__PURE__ */ e.createElement("svg", { width: "16", height: "16", viewBox: "0 0 32 32", fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M16 2L2 9l14 7 14-7-14-7zM2 23l14 7 14-7M2 16l14 7 14-7" })),
|
|
1234
|
+
/* @__PURE__ */ e.createElement("span", null, "Artifactuse")
|
|
1235
|
+
)));
|
|
1236
|
+
}
|
|
1237
|
+
function Tt({ className: t = "" }) {
|
|
1238
|
+
const { state: a, artifactCount: n, hasArtifacts: l, togglePanel: s } = de(), r = $(() => n > 99 ? "99+" : String(n), [n]), p = [
|
|
1239
|
+
"artifactuse-panel-toggle",
|
|
1240
|
+
a.isPanelOpen && "artifactuse-panel-toggle--active",
|
|
1241
|
+
l && "artifactuse-panel-toggle--has-artifacts",
|
|
1242
|
+
t
|
|
1243
|
+
].filter(Boolean).join(" ");
|
|
1244
|
+
return /* @__PURE__ */ e.createElement(
|
|
1245
|
+
"button",
|
|
1246
|
+
{
|
|
1247
|
+
className: p,
|
|
1248
|
+
onClick: s,
|
|
1249
|
+
title: a.isPanelOpen ? "Close artifacts panel" : "Open artifacts panel"
|
|
1250
|
+
},
|
|
1251
|
+
/* @__PURE__ */ e.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ e.createElement("polyline", { points: "16 18 22 12 16 6" }), /* @__PURE__ */ e.createElement("polyline", { points: "8 6 2 12 8 18" })),
|
|
1252
|
+
n > 0 && /* @__PURE__ */ e.createElement("span", { className: "artifactuse-panel-toggle-badge" }, r)
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
const Je = Ze(null);
|
|
1256
|
+
function Nt({ children: t, config: a = {} }) {
|
|
1257
|
+
const n = W(null);
|
|
1258
|
+
n.current || (n.current = Qe(a));
|
|
1259
|
+
const l = n.current, [s, r] = C({
|
|
1260
|
+
artifacts: [],
|
|
1261
|
+
activeArtifactId: null,
|
|
1262
|
+
isPanelOpen: !1,
|
|
1263
|
+
viewMode: "preview",
|
|
1264
|
+
isFullscreen: !1
|
|
1265
|
+
}), [p, u] = C(() => l.getPanelTypes());
|
|
1266
|
+
z(() => {
|
|
1267
|
+
const f = l.state.subscribe((v) => {
|
|
1268
|
+
r({
|
|
1269
|
+
artifacts: v.artifacts,
|
|
1270
|
+
activeArtifactId: v.activeArtifactId,
|
|
1271
|
+
isPanelOpen: v.isPanelOpen,
|
|
1272
|
+
viewMode: v.viewMode,
|
|
1273
|
+
isFullscreen: v.isFullscreen
|
|
1274
|
+
});
|
|
1275
|
+
});
|
|
1276
|
+
return l.applyTheme(), () => {
|
|
1277
|
+
f(), l.destroy();
|
|
1278
|
+
};
|
|
1279
|
+
}, [l]);
|
|
1280
|
+
const g = $(() => s.activeArtifactId && s.artifacts.find((f) => f.id === s.activeArtifactId) || null, [s.artifacts, s.activeArtifactId]), c = s.artifacts.length, b = c > 0, P = $(() => g ? l.getPanelUrl(g) : null, [g, l]), x = d((f) => {
|
|
1281
|
+
l.setTheme(f), l.applyTheme();
|
|
1282
|
+
}, [l]), _ = d((f, v) => {
|
|
1283
|
+
l.registerPanel(f, v), u(l.getPanelTypes());
|
|
1284
|
+
}, [l]), E = d((f) => {
|
|
1285
|
+
l.unregisterPanel(f), u(l.getPanelTypes());
|
|
1286
|
+
}, [l]), k = $(() => ({
|
|
1287
|
+
instance: l,
|
|
1288
|
+
state: s,
|
|
1289
|
+
activeArtifact: g,
|
|
1290
|
+
artifactCount: c,
|
|
1291
|
+
hasArtifacts: b,
|
|
1292
|
+
// Panel computed
|
|
1293
|
+
panelTypes: p,
|
|
1294
|
+
activePanelUrl: P,
|
|
1295
|
+
// Methods
|
|
1296
|
+
processMessage: l.processMessage,
|
|
1297
|
+
initializeContent: l.initializeContent,
|
|
1298
|
+
openArtifact: l.openArtifact,
|
|
1299
|
+
closePanel: l.closePanel,
|
|
1300
|
+
togglePanel: l.togglePanel,
|
|
1301
|
+
toggleFullscreen: l.toggleFullscreen,
|
|
1302
|
+
setViewMode: l.setViewMode,
|
|
1303
|
+
getPanelUrl: l.getPanelUrl,
|
|
1304
|
+
sendToPanel: l.sendToPanel,
|
|
1305
|
+
// Panel management
|
|
1306
|
+
hasPanel: l.hasPanel,
|
|
1307
|
+
registerPanel: _,
|
|
1308
|
+
unregisterPanel: E,
|
|
1309
|
+
getPanelTypes: l.getPanelTypes,
|
|
1310
|
+
// Events
|
|
1311
|
+
on: l.on,
|
|
1312
|
+
off: l.off,
|
|
1313
|
+
// Theme
|
|
1314
|
+
applyTheme: l.applyTheme,
|
|
1315
|
+
setTheme: x,
|
|
1316
|
+
getTheme: l.getTheme
|
|
1317
|
+
}), [
|
|
1318
|
+
l,
|
|
1319
|
+
s,
|
|
1320
|
+
g,
|
|
1321
|
+
c,
|
|
1322
|
+
b,
|
|
1323
|
+
p,
|
|
1324
|
+
P,
|
|
1325
|
+
x,
|
|
1326
|
+
_,
|
|
1327
|
+
E
|
|
1328
|
+
]);
|
|
1329
|
+
return /* @__PURE__ */ e.createElement(Je.Provider, { value: k }, t);
|
|
1330
|
+
}
|
|
1331
|
+
function de() {
|
|
1332
|
+
const t = Ke(Je);
|
|
1333
|
+
if (!t)
|
|
1334
|
+
throw new Error("useArtifactuse must be used within an ArtifactuseProvider");
|
|
1335
|
+
return t;
|
|
1336
|
+
}
|
|
1337
|
+
function bt(t, a) {
|
|
1338
|
+
const { on: n, off: l } = de();
|
|
1339
|
+
z(() => {
|
|
1340
|
+
const s = n(t, a);
|
|
1341
|
+
return () => {
|
|
1342
|
+
typeof s == "function" ? s() : l(t, a);
|
|
1343
|
+
};
|
|
1344
|
+
}, [t, a, n, l]);
|
|
1345
|
+
}
|
|
1346
|
+
function kt() {
|
|
1347
|
+
const {
|
|
1348
|
+
registerPanel: t,
|
|
1349
|
+
unregisterPanel: a,
|
|
1350
|
+
hasPanel: n,
|
|
1351
|
+
panelTypes: l,
|
|
1352
|
+
instance: s
|
|
1353
|
+
} = de(), r = d((u) => n({ type: u }), [n]), p = d((u, g = {}) => {
|
|
1354
|
+
var c;
|
|
1355
|
+
return ((c = s.panelResolver) == null ? void 0 : c.resolve(u, g)) || null;
|
|
1356
|
+
}, [s]);
|
|
1357
|
+
return {
|
|
1358
|
+
register: t,
|
|
1359
|
+
unregister: a,
|
|
1360
|
+
isRegistered: r,
|
|
1361
|
+
getPanelUrl: p,
|
|
1362
|
+
types: l,
|
|
1363
|
+
defaults: Oe
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
const Mt = {
|
|
1367
|
+
ArtifactuseProvider: Nt,
|
|
1368
|
+
useArtifactuse: de,
|
|
1369
|
+
useArtifactuseEvent: bt,
|
|
1370
|
+
usePanelRegistry: kt,
|
|
1371
|
+
DEFAULT_PANELS: Oe
|
|
1372
|
+
};
|
|
1373
|
+
export {
|
|
1374
|
+
_t as ArtifactuseAgentMessage,
|
|
1375
|
+
at as ArtifactuseCard,
|
|
1376
|
+
nt as ArtifactuseInlineForm,
|
|
1377
|
+
Pt as ArtifactusePanel,
|
|
1378
|
+
Tt as ArtifactusePanelToggle,
|
|
1379
|
+
Nt as ArtifactuseProvider,
|
|
1380
|
+
Et as ArtifactuseSocialPreview,
|
|
1381
|
+
vt as ArtifactuseViewer,
|
|
1382
|
+
Oe as DEFAULT_PANELS,
|
|
1383
|
+
Mt as default,
|
|
1384
|
+
de as useArtifactuse,
|
|
1385
|
+
bt as useArtifactuseEvent,
|
|
1386
|
+
kt as usePanelRegistry
|
|
1387
|
+
};
|