@snowcone-app/canvas 0.41.3 → 0.41.5
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/dist/{CanvasRenderer-JcBrIZ6I.js → CanvasRenderer-3M-52sAd.js} +4 -4
- package/dist/{CanvasRenderer-JcBrIZ6I.js.map → CanvasRenderer-3M-52sAd.js.map} +1 -1
- package/dist/{CanvasStateV1-BJ5-75NN.js → CanvasStateV1-C9tFMK5q.js} +3 -3
- package/dist/{CanvasStateV1-BJ5-75NN.js.map → CanvasStateV1-C9tFMK5q.js.map} +1 -1
- package/dist/{ContextualToolbars-wmbHxn5a.js → ContextualToolbars-B2LTNu7r.js} +358 -358
- package/dist/{ContextualToolbars-wmbHxn5a.js.map → ContextualToolbars-B2LTNu7r.js.map} +1 -1
- package/dist/{EditorCanvasImpl-CSDnCIpN.js → EditorCanvasImpl-CKqnla_y.js} +26 -26
- package/dist/EditorCanvasImpl-CKqnla_y.js.map +1 -0
- package/dist/{ExportManager-CHlByUYV.js → ExportManager-9_RjQEv0.js} +2 -2
- package/dist/{ExportManager-CHlByUYV.js.map → ExportManager-9_RjQEv0.js.map} +1 -1
- package/dist/{FontAnalyzer-Bj2KrX80.js → FontAnalyzer-Ch1jgTq7.js} +88 -68
- package/dist/FontAnalyzer-Ch1jgTq7.js.map +1 -0
- package/dist/ImagePanel-DY9Ve3X7.js +1016 -0
- package/dist/{ImagePanel-0ZwDDaCy.js.map → ImagePanel-DY9Ve3X7.js.map} +1 -1
- package/dist/SnowconeCanvas-BSFMazgl.js +1098 -0
- package/dist/SnowconeCanvas-BSFMazgl.js.map +1 -0
- package/dist/advanced.mjs +44 -44
- package/dist/api/stable.d.ts +1 -1
- package/dist/components/embed/SnowconeCanvas.d.ts +15 -0
- package/dist/components/embed/kernel.d.ts +3 -1
- package/dist/core/ArtboardElement.d.ts +2 -0
- package/dist/core/ArtboardManager.d.ts +11 -0
- package/dist/{custom-icons-up58ZbC9.js → custom-icons-D_XezOul.js} +2 -2
- package/dist/{custom-icons-up58ZbC9.js.map → custom-icons-D_XezOul.js.map} +1 -1
- package/dist/design-builder-BFM94eA9.js +1859 -0
- package/dist/design-builder-BFM94eA9.js.map +1 -0
- package/dist/{embed-GXevsHX5.js → embed-KG_YnRHA.js} +10 -10
- package/dist/{embed-GXevsHX5.js.map → embed-KG_YnRHA.js.map} +1 -1
- package/dist/embed.mjs +12 -12
- package/dist/{guards-CQeF53PN.js → guards-D_mw4DgS.js} +2 -2
- package/dist/{guards-CQeF53PN.js.map → guards-D_mw4DgS.js.map} +1 -1
- package/dist/index.mjs +9 -9
- package/dist/internals.mjs +6 -6
- package/dist/{placement-D31o3YYC.js → placement-tSiIVhrL.js} +3 -3
- package/dist/{placement-D31o3YYC.js.map → placement-tSiIVhrL.js.map} +1 -1
- package/dist/placement.mjs +2 -2
- package/dist/{template-fields-tobyHoMe.js → template-fields-C0qoE_ZH.js} +32 -32
- package/dist/{template-fields-tobyHoMe.js.map → template-fields-C0qoE_ZH.js.map} +1 -1
- package/dist/testing.mjs +3 -3
- package/dist/{useCommands-Cm3mDB-l.js → useCommands-DSapP-w1.js} +7 -7
- package/dist/{useCommands-Cm3mDB-l.js.map → useCommands-DSapP-w1.js.map} +1 -1
- package/dist/{usePieceGuideBundle-BTnUn33k.js → usePieceGuideBundle-oBykb3X8.js} +2 -2
- package/dist/{usePieceGuideBundle-BTnUn33k.js.map → usePieceGuideBundle-oBykb3X8.js.map} +1 -1
- package/dist/utils/newImagePlacement.d.ts +56 -0
- package/dist/{validation-D4zxugNJ.js → validation-D6zVSeTh.js} +307 -307
- package/dist/{validation-D4zxugNJ.js.map → validation-D6zVSeTh.js.map} +1 -1
- package/dist/vendor/ui/primitives/badge.d.ts +1 -1
- package/dist/vendor/ui/primitives/link.d.ts +1 -1
- package/dist/vendor/ui/primitives/spinner.d.ts +1 -1
- package/example/package.json +1 -1
- package/package.json +4 -4
- package/dist/EditorCanvasImpl-CSDnCIpN.js.map +0 -1
- package/dist/FontAnalyzer-Bj2KrX80.js.map +0 -1
- package/dist/ImagePanel-0ZwDDaCy.js +0 -984
- package/dist/SnowconeCanvas-BZk7PRpk.js +0 -1215
- package/dist/SnowconeCanvas-BZk7PRpk.js.map +0 -1
- package/dist/design-builder-DUEwCUmA.js +0 -1676
- package/dist/design-builder-DUEwCUmA.js.map +0 -1
|
@@ -0,0 +1,1016 @@
|
|
|
1
|
+
import { jsx as e, jsxs as c, Fragment as ae } from "react/jsx-runtime";
|
|
2
|
+
import * as cs from "react";
|
|
3
|
+
import He, { useMemo as Ge, useState as n, useRef as U, useEffect as re, useCallback as fe } from "react";
|
|
4
|
+
import { b as rs, c as as, p as Te } from "./design-builder-BFM94eA9.js";
|
|
5
|
+
import { u as ns, c as os, a as _e, D as is, I as y, i as me, B as J, b as ls, d as ds, C as us } from "./useCommands-DSapP-w1.js";
|
|
6
|
+
import { c as Fe, I as ms } from "./FontAnalyzer-Ch1jgTq7.js";
|
|
7
|
+
import { T as M, S as Pe, a as ye, I as Ee, L as Ie } from "./custom-icons-D_XezOul.js";
|
|
8
|
+
import { i as Ve } from "./guards-D_mw4DgS.js";
|
|
9
|
+
const Ye = cs.forwardRef(
|
|
10
|
+
({ className: d, isInvalid: t, disabled: p, readOnly: R, required: m, variant: z, ...r }, h) => {
|
|
11
|
+
const a = ns(), u = z ?? (a.variant === "default" ? "filled" : "default");
|
|
12
|
+
return /* @__PURE__ */ e(
|
|
13
|
+
"textarea",
|
|
14
|
+
{
|
|
15
|
+
className: os(
|
|
16
|
+
"sc:flex sc:min-h-[80px] sc:w-full sc:rounded-input sc:px-2.5 sc:py-2 sc:text-sm sc:transition-colors",
|
|
17
|
+
"sc:text-foreground sc:border-none",
|
|
18
|
+
"sc:placeholder:text-foreground/50",
|
|
19
|
+
"sc:focus-visible:outline-none sc:focus-visible:ring-2 sc:focus-visible:ring-focus",
|
|
20
|
+
"sc:disabled:cursor-not-allowed sc:disabled:opacity-50",
|
|
21
|
+
// Variant styles - semantic: field on page vs field on surface
|
|
22
|
+
u === "default" && "sc:bg-field sc:shadow-soft sc:dark:shadow-none",
|
|
23
|
+
u === "filled" && "sc:bg-[var(--color-field-on-surface)]",
|
|
24
|
+
t && "sc:ring-2 sc:ring-danger sc:focus-visible:ring-danger",
|
|
25
|
+
d
|
|
26
|
+
),
|
|
27
|
+
ref: h,
|
|
28
|
+
disabled: p,
|
|
29
|
+
readOnly: R,
|
|
30
|
+
required: m,
|
|
31
|
+
"aria-invalid": t,
|
|
32
|
+
...r
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
Ye.displayName = "Textarea";
|
|
38
|
+
const Xe = Ye;
|
|
39
|
+
Xe.displayName = "TextArea";
|
|
40
|
+
const ve = Fe("ImageBrowser"), fs = "Image search is temporarily unavailable.", Ue = "Image generation is temporarily unavailable.", hs = "Vector search is temporarily unavailable.", Be = "Background removal is temporarily unavailable.";
|
|
41
|
+
function gs(d, t) {
|
|
42
|
+
const p = d instanceof Error ? d.message : "";
|
|
43
|
+
return !p || /VITE_|NEXT_PUBLIC_|\.env/i.test(p) ? t : p;
|
|
44
|
+
}
|
|
45
|
+
const ps = "1px", Le = "1px", ke = { contentVisibility: "auto", contain: "paint" }, $e = He.memo(function({ image: t, onImageSelect: p, fixedHeight: R = !1 }) {
|
|
46
|
+
const [m, z] = n(!1), [r, h] = n(!1), [a, u] = n("top"), o = U(null), g = U(null), S = U(null), v = U(!0), [T, w] = n(!1), N = U(null), A = () => {
|
|
47
|
+
r || p(t);
|
|
48
|
+
}, K = (D) => {
|
|
49
|
+
if (!S.current) return "top";
|
|
50
|
+
const x = S.current.getBoundingClientRect(), ce = D.clientX - x.left, B = D.clientY - x.top, O = x.width, f = x.height, V = {
|
|
51
|
+
top: B,
|
|
52
|
+
bottom: f - B,
|
|
53
|
+
left: ce,
|
|
54
|
+
right: O - ce
|
|
55
|
+
}, Q = Math.min(V.top, V.bottom, V.left, V.right);
|
|
56
|
+
return Q === V.top ? "top" : Q === V.bottom ? "bottom" : Q === V.left ? "left" : "right";
|
|
57
|
+
}, se = (D) => {
|
|
58
|
+
const x = K(D);
|
|
59
|
+
N.current && (cancelAnimationFrame(N.current), N.current = null), x !== a ? (w(!0), u(x), N.current = requestAnimationFrame(() => {
|
|
60
|
+
N.current = requestAnimationFrame(() => {
|
|
61
|
+
w(!1), z(!0), N.current = null;
|
|
62
|
+
});
|
|
63
|
+
})) : (u(x), z(!0)), v.current = !1;
|
|
64
|
+
}, H = (D) => {
|
|
65
|
+
N.current && (cancelAnimationFrame(N.current), N.current = null);
|
|
66
|
+
const x = K(D);
|
|
67
|
+
u(x), w(!1), z(!1);
|
|
68
|
+
}, C = () => {
|
|
69
|
+
g.current && (clearTimeout(g.current), g.current = null), o.current = setTimeout(() => {
|
|
70
|
+
h(!0);
|
|
71
|
+
}, 400);
|
|
72
|
+
}, te = () => {
|
|
73
|
+
o.current && (clearTimeout(o.current), o.current = null), h(!1);
|
|
74
|
+
}, ne = () => {
|
|
75
|
+
o.current && (clearTimeout(o.current), o.current = null), g.current && (clearTimeout(g.current), g.current = null);
|
|
76
|
+
}, $ = () => {
|
|
77
|
+
h(!1);
|
|
78
|
+
}, P = t.source === "unsplash" ? "Unsplash" : "Pixabay", oe = m || r, W = () => {
|
|
79
|
+
if (!m) return "none";
|
|
80
|
+
switch (a) {
|
|
81
|
+
case "top":
|
|
82
|
+
return `scale(${1.12}) translateY(5%)`;
|
|
83
|
+
case "bottom":
|
|
84
|
+
return `scale(${1.12}) translateY(-5%)`;
|
|
85
|
+
case "left":
|
|
86
|
+
return `scale(${1.12}) translateX(5%)`;
|
|
87
|
+
case "right":
|
|
88
|
+
return `scale(${1.12}) translateX(-5%)`;
|
|
89
|
+
default:
|
|
90
|
+
return `scale(${1.12})`;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ c(
|
|
94
|
+
"div",
|
|
95
|
+
{
|
|
96
|
+
ref: S,
|
|
97
|
+
onClick: A,
|
|
98
|
+
onMouseEnter: se,
|
|
99
|
+
onMouseLeave: H,
|
|
100
|
+
className: `sc:group sc:relative sc:cursor-pointer sc:overflow-hidden ${R ? "sc:h-full sc:rounded-xs" : "sc:break-inside-avoid sc:rounded-lg"}`,
|
|
101
|
+
children: [
|
|
102
|
+
/* @__PURE__ */ e(
|
|
103
|
+
"img",
|
|
104
|
+
{
|
|
105
|
+
src: t.urls.small,
|
|
106
|
+
alt: t.alt || "Image",
|
|
107
|
+
className: `sc:duration-500 sc:ease-out ${T ? "sc:transition-none" : "sc:transition-transform"} ${R ? "sc:h-full sc:w-full sc:object-cover" : "sc:w-full sc:object-cover"}`,
|
|
108
|
+
style: {
|
|
109
|
+
transform: W(),
|
|
110
|
+
filter: m ? "brightness(1.04)" : void 0
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ e("div", { className: "sc:absolute sc:top-2 sc:right-2 sc:z-10", children: /* @__PURE__ */ e(
|
|
115
|
+
"button",
|
|
116
|
+
{
|
|
117
|
+
className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${oe ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
|
|
118
|
+
"aria-label": "Image info",
|
|
119
|
+
onMouseEnter: C,
|
|
120
|
+
onMouseLeave: te,
|
|
121
|
+
children: /* @__PURE__ */ e(y, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
/* @__PURE__ */ e(
|
|
125
|
+
"div",
|
|
126
|
+
{
|
|
127
|
+
className: `sc:absolute sc:inset-x-0 sc:bottom-0 sc:z-0 sc:bg-linear-to-t sc:from-black/80 sc:via-black/60 sc:to-transparent sc:px-3 sc:py-3 sc:pt-8 sc:transition-transform sc:duration-300 sc:ease-out ${r ? "sc:translate-y-0" : "sc:translate-y-full"}`,
|
|
128
|
+
onMouseEnter: ne,
|
|
129
|
+
onMouseLeave: $,
|
|
130
|
+
children: /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-1", children: [
|
|
131
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:items-center sc:gap-2", children: [
|
|
132
|
+
/* @__PURE__ */ e(
|
|
133
|
+
y,
|
|
134
|
+
{
|
|
135
|
+
icon: t.source === "unsplash" ? "simple-icons:unsplash" : "simple-icons:pixabay",
|
|
136
|
+
className: "sc:size-3 sc:text-white/80"
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ e("span", { className: "sc:text-xs sc:font-medium sc:text-white/80", children: P })
|
|
140
|
+
] }),
|
|
141
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-0.5", children: [
|
|
142
|
+
/* @__PURE__ */ e("span", { className: "sc:text-xs sc:text-white/60", children: "Photo by" }),
|
|
143
|
+
/* @__PURE__ */ c("span", { className: "sc:text-sm sc:font-medium sc:text-white", children: [
|
|
144
|
+
t.attribution.profileUrl ? /* @__PURE__ */ e(
|
|
145
|
+
"a",
|
|
146
|
+
{
|
|
147
|
+
href: t.attribution.profileUrl,
|
|
148
|
+
target: "_blank",
|
|
149
|
+
rel: "noopener noreferrer",
|
|
150
|
+
onClick: (D) => D.stopPropagation(),
|
|
151
|
+
className: "sc:underline sc:decoration-white/40 sc:underline-offset-2 sc:hover:decoration-white",
|
|
152
|
+
children: t.attribution.name
|
|
153
|
+
}
|
|
154
|
+
) : t.attribution.name,
|
|
155
|
+
t.attribution.sourceUrl && /* @__PURE__ */ c(ae, { children: [
|
|
156
|
+
" ",
|
|
157
|
+
/* @__PURE__ */ e("span", { className: "sc:font-normal sc:text-white/60", children: "on" }),
|
|
158
|
+
" ",
|
|
159
|
+
/* @__PURE__ */ e(
|
|
160
|
+
"a",
|
|
161
|
+
{
|
|
162
|
+
href: t.attribution.sourceUrl,
|
|
163
|
+
target: "_blank",
|
|
164
|
+
rel: "noopener noreferrer",
|
|
165
|
+
onClick: (D) => D.stopPropagation(),
|
|
166
|
+
className: "sc:underline sc:decoration-white/40 sc:underline-offset-2 sc:hover:decoration-white",
|
|
167
|
+
children: P
|
|
168
|
+
}
|
|
169
|
+
)
|
|
170
|
+
] })
|
|
171
|
+
] })
|
|
172
|
+
] })
|
|
173
|
+
] })
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}), je = He.memo(function({ vector: t, onVectorSelect: p, fixedHeight: R = !1 }) {
|
|
180
|
+
const [m, z] = n(!1), [r, h] = n(!1), a = U(null), u = U(null), o = () => {
|
|
181
|
+
r || p(t);
|
|
182
|
+
}, g = () => {
|
|
183
|
+
u.current && (clearTimeout(u.current), u.current = null), a.current = setTimeout(() => {
|
|
184
|
+
h(!0);
|
|
185
|
+
}, 400);
|
|
186
|
+
}, S = () => {
|
|
187
|
+
a.current && (clearTimeout(a.current), a.current = null), h(!1);
|
|
188
|
+
}, v = () => {
|
|
189
|
+
a.current && (clearTimeout(a.current), a.current = null), u.current && (clearTimeout(u.current), u.current = null);
|
|
190
|
+
}, T = () => {
|
|
191
|
+
h(!1);
|
|
192
|
+
}, w = m || r;
|
|
193
|
+
return /* @__PURE__ */ c(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
onClick: o,
|
|
197
|
+
onMouseEnter: () => z(!0),
|
|
198
|
+
onMouseLeave: () => z(!1),
|
|
199
|
+
className: `sc:group sc:relative sc:cursor-pointer sc:overflow-hidden sc:bg-white/10 sc:transition-all sc:duration-300 ${R ? "sc:h-full sc:rounded-xs" : "sc:break-inside-avoid sc:rounded-lg"} ${m ? "sc:scale-105 sc:bg-white/20" : ""}`,
|
|
200
|
+
children: [
|
|
201
|
+
/* @__PURE__ */ e(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
className: `sc:flex sc:items-center sc:justify-center sc:p-6 sc:transition-all sc:duration-300 ${R ? "sc:h-full sc:w-full" : "sc:aspect-square sc:w-full"}`,
|
|
205
|
+
children: /* @__PURE__ */ e(
|
|
206
|
+
"img",
|
|
207
|
+
{
|
|
208
|
+
src: t.urls.preview,
|
|
209
|
+
alt: t.term,
|
|
210
|
+
className: `sc:max-h-full sc:max-w-full sc:object-contain sc:transition-all sc:duration-300 ${m ? "sc:scale-110" : "sc:scale-100"}`,
|
|
211
|
+
style: {
|
|
212
|
+
filter: m ? "brightness(1.1)" : void 0
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
}
|
|
217
|
+
),
|
|
218
|
+
/* @__PURE__ */ c("div", { className: "sc:absolute sc:top-2 sc:right-2 sc:z-10 sc:flex sc:items-center sc:gap-2", children: [
|
|
219
|
+
!t.urls.svg && /* @__PURE__ */ e(
|
|
220
|
+
"span",
|
|
221
|
+
{
|
|
222
|
+
className: `sc:rounded-xs sc:bg-amber-500/90 sc:px-1.5 sc:py-0.5 sc:text-[10px] sc:font-semibold sc:uppercase sc:tracking-wide sc:text-white sc:shadow-sm sc:transition-all sc:duration-300 sc:ease-in-out ${w ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
|
|
223
|
+
children: "PNG"
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ e(
|
|
227
|
+
"button",
|
|
228
|
+
{
|
|
229
|
+
className: `sc:relative sc:flex sc:h-6 sc:w-6 sc:items-center sc:justify-center sc:rounded-full sc:bg-black/50 sc:transition-all sc:duration-300 sc:ease-in-out sc:hover:scale-110 ${w ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
|
|
230
|
+
"aria-label": "Vector info",
|
|
231
|
+
onMouseEnter: g,
|
|
232
|
+
onMouseLeave: S,
|
|
233
|
+
children: /* @__PURE__ */ e(y, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
] }),
|
|
237
|
+
/* @__PURE__ */ c(
|
|
238
|
+
"div",
|
|
239
|
+
{
|
|
240
|
+
className: `sc:absolute sc:inset-x-0 sc:bottom-0 sc:z-0 sc:bg-linear-to-t sc:from-black/80 sc:via-black/60 sc:to-transparent sc:px-3 sc:py-3 sc:pt-8 sc:transition-transform sc:duration-300 sc:ease-out ${r ? "sc:translate-y-0" : "sc:translate-y-full"}`,
|
|
241
|
+
onMouseEnter: v,
|
|
242
|
+
onMouseLeave: T,
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ c("div", { className: "sc:mb-1", children: [
|
|
245
|
+
/* @__PURE__ */ e(y, { icon: "mdi:cube-outline", className: "sc:mr-2 sc:inline-block sc:size-3 sc:text-white/80" }),
|
|
246
|
+
/* @__PURE__ */ e("span", { className: "sc:text-xs sc:font-medium sc:text-white/80", children: "Noun Project" })
|
|
247
|
+
] }),
|
|
248
|
+
/* @__PURE__ */ e("div", { className: "sc:text-xs sc:text-white/60", children: "Icon by" }),
|
|
249
|
+
/* @__PURE__ */ e("div", { className: "sc:text-sm sc:font-medium sc:text-white", children: t.uploader.name })
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
}), xs = ({
|
|
257
|
+
isOpen: d,
|
|
258
|
+
onToggle: t,
|
|
259
|
+
onImageSelect: p,
|
|
260
|
+
currentImageUrl: R,
|
|
261
|
+
placement: m = "bottom",
|
|
262
|
+
busy: z = !1
|
|
263
|
+
}) => {
|
|
264
|
+
const { imageSearch: r, generate: h, vectors: a, removeBackground: u } = _e(), o = Ge(
|
|
265
|
+
() => [
|
|
266
|
+
...r ? ["search"] : [],
|
|
267
|
+
"url",
|
|
268
|
+
...a ? ["vector"] : [],
|
|
269
|
+
...h ? ["ai"] : []
|
|
270
|
+
],
|
|
271
|
+
[r, a, h]
|
|
272
|
+
), [g, S] = n(""), [v, T] = n(""), [w, N] = n([]), [A, K] = n(!1), [se, H] = n(null), [C, te] = n(o[0]), [ne, $] = n(1), [P, oe] = n(!0), [W, D] = n("masonry"), [x, ce] = n(""), [B, O] = n([]), [f, V] = n(!1), [Q, he] = n(null), [ee, ge] = n(null), [G, _] = n(!0), [ie, Re] = n("grid"), [q, F] = n(""), [le, pe] = n(!1), [xe, I] = n(null), [k, E] = n(null), [j, i] = n(!1), [Y, X] = n(null), de = U(null), be = U(null), Se = U(null);
|
|
273
|
+
re(() => {
|
|
274
|
+
o.includes(C) || te(o[0]);
|
|
275
|
+
}, [o, C]), re(() => {
|
|
276
|
+
d && R && (T(R), te("url"));
|
|
277
|
+
}, [d, R]), re(() => {
|
|
278
|
+
d || (S(""), T(""), N([]), H(null), $(1), oe(!0), ce(""), O([]), he(null), ge(null), _(!0));
|
|
279
|
+
}, [d]);
|
|
280
|
+
const we = fe(
|
|
281
|
+
async (s, l, b) => {
|
|
282
|
+
if (r) {
|
|
283
|
+
K(!0), H(null);
|
|
284
|
+
try {
|
|
285
|
+
const L = await r.search({ query: s, page: l, perPage: 30 });
|
|
286
|
+
N((Z) => b ? [...Z, ...L.results] : L.results), $(L.page), oe(L.hasMore);
|
|
287
|
+
} catch (L) {
|
|
288
|
+
H(fs), ve.error("Error searching images:", L);
|
|
289
|
+
} finally {
|
|
290
|
+
K(!1);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
[r]
|
|
295
|
+
);
|
|
296
|
+
re(() => {
|
|
297
|
+
d && !g && C === "search" && w.length === 0 && r && we("", 1, !1);
|
|
298
|
+
}, [d, C, r]);
|
|
299
|
+
const We = (s) => {
|
|
300
|
+
s.preventDefault(), we(g, 1, !1);
|
|
301
|
+
}, Ae = fe(() => {
|
|
302
|
+
A || !P || we(g, ne + 1, !0);
|
|
303
|
+
}, [A, P, g, ne, we]);
|
|
304
|
+
re(() => {
|
|
305
|
+
const s = de.current;
|
|
306
|
+
if (!s || !d || C !== "search") return;
|
|
307
|
+
const l = new IntersectionObserver(
|
|
308
|
+
(b) => {
|
|
309
|
+
b[0].isIntersecting && P && !A && Ae();
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
root: null,
|
|
313
|
+
// viewport
|
|
314
|
+
rootMargin: "200px",
|
|
315
|
+
// Trigger 200px before sentinel is visible
|
|
316
|
+
threshold: 0
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
return l.observe(s), () => {
|
|
320
|
+
l.disconnect();
|
|
321
|
+
};
|
|
322
|
+
}, [d, C, P, A, Ae]);
|
|
323
|
+
const Ne = fe(
|
|
324
|
+
async (s, l) => {
|
|
325
|
+
if (a) {
|
|
326
|
+
V(!0), he(null);
|
|
327
|
+
try {
|
|
328
|
+
const { results: b, nextPage: L } = await a.search({ query: s, nextPage: l ?? null });
|
|
329
|
+
O(l ? (Z) => {
|
|
330
|
+
const Ce = new Set(Z.map((ue) => ue.id));
|
|
331
|
+
return [...Z, ...b.filter((ue) => !Ce.has(ue.id))];
|
|
332
|
+
} : b), ge(L), _(L !== null);
|
|
333
|
+
} catch (b) {
|
|
334
|
+
he(hs), ve.error("Error searching vectors:", b);
|
|
335
|
+
} finally {
|
|
336
|
+
V(!1);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
[a]
|
|
341
|
+
);
|
|
342
|
+
re(() => {
|
|
343
|
+
d && !x && C === "vector" && B.length === 0 && a && Ne("");
|
|
344
|
+
}, [d, C, a]);
|
|
345
|
+
const Qe = (s) => {
|
|
346
|
+
s.preventDefault(), Ne(x);
|
|
347
|
+
}, De = fe(() => {
|
|
348
|
+
f || !G || !ee || Ne(x, ee);
|
|
349
|
+
}, [f, G, ee, x, Ne]);
|
|
350
|
+
re(() => {
|
|
351
|
+
const s = be.current;
|
|
352
|
+
if (!s || !d || C !== "vector") return;
|
|
353
|
+
const l = new IntersectionObserver(
|
|
354
|
+
(b) => {
|
|
355
|
+
b[0].isIntersecting && G && !f && De();
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
root: null,
|
|
359
|
+
rootMargin: "200px",
|
|
360
|
+
threshold: 0
|
|
361
|
+
}
|
|
362
|
+
);
|
|
363
|
+
return l.observe(s), () => {
|
|
364
|
+
l.disconnect();
|
|
365
|
+
};
|
|
366
|
+
}, [d, C, G, f, De]);
|
|
367
|
+
const Me = (s) => {
|
|
368
|
+
const l = s.selectUrl || s.urls.svg || s.urls.png;
|
|
369
|
+
l && (p(l), t(!1));
|
|
370
|
+
}, ze = (s) => {
|
|
371
|
+
var l;
|
|
372
|
+
try {
|
|
373
|
+
Promise.resolve((l = r == null ? void 0 : r.trackSelect) == null ? void 0 : l.call(r, s)).catch(() => {
|
|
374
|
+
});
|
|
375
|
+
} catch {
|
|
376
|
+
}
|
|
377
|
+
p(s.urls.regular), t(!1);
|
|
378
|
+
}, qe = (s) => {
|
|
379
|
+
s.preventDefault(), v.trim() && (p(v.trim()), t(!1));
|
|
380
|
+
}, Ze = (s) => {
|
|
381
|
+
var b;
|
|
382
|
+
const l = (b = s.target.files) == null ? void 0 : b[0];
|
|
383
|
+
if (l && l.type.startsWith("image/")) {
|
|
384
|
+
const L = new FileReader();
|
|
385
|
+
L.onload = (Z) => {
|
|
386
|
+
var ue;
|
|
387
|
+
const Ce = (ue = Z.target) == null ? void 0 : ue.result;
|
|
388
|
+
T(Ce);
|
|
389
|
+
}, L.readAsDataURL(l);
|
|
390
|
+
}
|
|
391
|
+
}, Je = () => {
|
|
392
|
+
var s;
|
|
393
|
+
(s = Se.current) == null || s.click();
|
|
394
|
+
}, Ke = async () => {
|
|
395
|
+
if (!(!u || !v.trim())) {
|
|
396
|
+
i(!0), X(null);
|
|
397
|
+
try {
|
|
398
|
+
const s = await u(v);
|
|
399
|
+
T(s);
|
|
400
|
+
} catch (s) {
|
|
401
|
+
X(Be), ve.error("Error removing background:", s);
|
|
402
|
+
} finally {
|
|
403
|
+
i(!1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}, Oe = async (s) => {
|
|
407
|
+
var l, b;
|
|
408
|
+
if (s.preventDefault(), !!h) {
|
|
409
|
+
if (!q.trim()) {
|
|
410
|
+
I("Please enter a prompt");
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
pe(!0), I(null), E(null);
|
|
414
|
+
try {
|
|
415
|
+
const Z = (b = (l = (await h.generate({
|
|
416
|
+
prompt: q,
|
|
417
|
+
width: 1024,
|
|
418
|
+
height: 1024,
|
|
419
|
+
numberResults: 1
|
|
420
|
+
})).images) == null ? void 0 : l[0]) == null ? void 0 : b.imageUrl;
|
|
421
|
+
if (!Z)
|
|
422
|
+
throw new Error(Ue);
|
|
423
|
+
E(Z);
|
|
424
|
+
} catch (L) {
|
|
425
|
+
I(gs(L, Ue)), ve.error("Error generating AI image:", L);
|
|
426
|
+
} finally {
|
|
427
|
+
pe(!1);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}, es = () => {
|
|
431
|
+
k && (p(k), t(!1));
|
|
432
|
+
}, ss = async () => {
|
|
433
|
+
if (!(!u || !k)) {
|
|
434
|
+
i(!0), X(null);
|
|
435
|
+
try {
|
|
436
|
+
const s = await u(k);
|
|
437
|
+
E(s);
|
|
438
|
+
} catch (s) {
|
|
439
|
+
X(Be), ve.error("Error removing background:", s);
|
|
440
|
+
} finally {
|
|
441
|
+
i(!1);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}, ts = (s, l) => {
|
|
445
|
+
const b = s.width / s.height;
|
|
446
|
+
return l % 12 === 0 && b > 0.8 && b < 1.2 ? "sc:col-span-2 sc:row-span-2" : b < 0.75 ? "sc:row-span-2" : b > 1.5 ? "sc:col-span-2" : "";
|
|
447
|
+
};
|
|
448
|
+
return /* @__PURE__ */ c(
|
|
449
|
+
is,
|
|
450
|
+
{
|
|
451
|
+
isOpen: d,
|
|
452
|
+
onClose: () => t(!1),
|
|
453
|
+
title: "Image Browser",
|
|
454
|
+
description: "Browse images or enter a custom image URL",
|
|
455
|
+
placement: m,
|
|
456
|
+
height: m === "bottom" ? "90vh" : void 0,
|
|
457
|
+
width: m !== "bottom" ? "500px" : void 0,
|
|
458
|
+
hideHandle: !0,
|
|
459
|
+
hideVisibleTitle: !0,
|
|
460
|
+
showCloseButton: !1,
|
|
461
|
+
"data-testid": "image-browser-drawer",
|
|
462
|
+
children: [
|
|
463
|
+
z && /* @__PURE__ */ c(
|
|
464
|
+
"div",
|
|
465
|
+
{
|
|
466
|
+
className: "sc:absolute sc:inset-0 sc:z-50 sc:flex sc:flex-col sc:items-center sc:justify-center sc:gap-3 sc:bg-background/70 sc:backdrop-blur-sm",
|
|
467
|
+
"data-testid": "image-browser-busy",
|
|
468
|
+
"aria-live": "polite",
|
|
469
|
+
children: [
|
|
470
|
+
/* @__PURE__ */ e("div", { className: "sc:size-8 sc:animate-spin sc:rounded-full sc:border-2 sc:border-divider sc:border-t-foreground" }),
|
|
471
|
+
/* @__PURE__ */ e("span", { className: "sc:text-foreground sc:text-sm", children: "Adding image…" })
|
|
472
|
+
]
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
/* @__PURE__ */ c(
|
|
476
|
+
M,
|
|
477
|
+
{
|
|
478
|
+
value: C,
|
|
479
|
+
onValueChange: (s) => te(s),
|
|
480
|
+
className: "sc:flex sc:flex-col",
|
|
481
|
+
"data-testid": "image-browser-container",
|
|
482
|
+
children: [
|
|
483
|
+
/* @__PURE__ */ e(M.ListContainer, { className: "sc:flex sc:justify-center sc:pt-4 sc:pb-2", children: /* @__PURE__ */ c(
|
|
484
|
+
M.List,
|
|
485
|
+
{
|
|
486
|
+
className: "sc:h-14 sc:gap-1 sc:px-1.5 sc:md:h-12",
|
|
487
|
+
"aria-label": "Image source",
|
|
488
|
+
children: [
|
|
489
|
+
r && /* @__PURE__ */ c(
|
|
490
|
+
M.Tab,
|
|
491
|
+
{
|
|
492
|
+
id: "search",
|
|
493
|
+
className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
|
|
494
|
+
"data-testid": "image-tab-search",
|
|
495
|
+
children: [
|
|
496
|
+
/* @__PURE__ */ e(y, { icon: me.image, className: "sc:size-6" }),
|
|
497
|
+
/* @__PURE__ */ e(M.Indicator, {})
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
),
|
|
501
|
+
/* @__PURE__ */ c(
|
|
502
|
+
M.Tab,
|
|
503
|
+
{
|
|
504
|
+
id: "url",
|
|
505
|
+
className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
|
|
506
|
+
"data-testid": "image-tab-url",
|
|
507
|
+
children: [
|
|
508
|
+
/* @__PURE__ */ e(y, { icon: me.link, className: "sc:size-6" }),
|
|
509
|
+
/* @__PURE__ */ e(M.Indicator, {})
|
|
510
|
+
]
|
|
511
|
+
}
|
|
512
|
+
),
|
|
513
|
+
a && /* @__PURE__ */ c(
|
|
514
|
+
M.Tab,
|
|
515
|
+
{
|
|
516
|
+
id: "vector",
|
|
517
|
+
className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
|
|
518
|
+
"data-testid": "image-tab-vector",
|
|
519
|
+
children: [
|
|
520
|
+
/* @__PURE__ */ e(y, { icon: "fa6-solid:icons", className: "sc:size-5" }),
|
|
521
|
+
/* @__PURE__ */ e(M.Indicator, {})
|
|
522
|
+
]
|
|
523
|
+
}
|
|
524
|
+
),
|
|
525
|
+
h && /* @__PURE__ */ c(
|
|
526
|
+
M.Tab,
|
|
527
|
+
{
|
|
528
|
+
id: "ai",
|
|
529
|
+
className: "sc:h-11 sc:w-14 sc:px-0 sc:md:h-9 sc:md:w-11",
|
|
530
|
+
"data-testid": "image-tab-ai",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ e(Pe, { size: 24 }),
|
|
533
|
+
/* @__PURE__ */ e(M.Indicator, {})
|
|
534
|
+
]
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
) }),
|
|
540
|
+
r && /* @__PURE__ */ c(M.Panel, { id: "search", className: "sc:flex sc:flex-col", children: [
|
|
541
|
+
/* @__PURE__ */ c("form", { onSubmit: We, className: "sc:sticky sc:top-0 sc:z-9 sc:flex sc:gap-2 sc:bg-surface sc:px-6 sc:pt-4 sc:pb-3", children: [
|
|
542
|
+
/* @__PURE__ */ e(ye, { className: "sc:flex-1", "aria-label": "Search for images", children: /* @__PURE__ */ e(
|
|
543
|
+
Ee,
|
|
544
|
+
{
|
|
545
|
+
type: "text",
|
|
546
|
+
placeholder: "Search for images...",
|
|
547
|
+
value: g,
|
|
548
|
+
onChange: (s) => S(s.target.value),
|
|
549
|
+
variant: "subtle",
|
|
550
|
+
"data-testid": "image-search-input"
|
|
551
|
+
}
|
|
552
|
+
) }),
|
|
553
|
+
/* @__PURE__ */ e(J, { type: "submit", size: "icon", variant: "secondary", disabled: A, "aria-label": "Search", children: /* @__PURE__ */ e(y, { icon: me.search, className: "sc:size-5" }) }),
|
|
554
|
+
/* @__PURE__ */ e(
|
|
555
|
+
J,
|
|
556
|
+
{
|
|
557
|
+
size: "icon",
|
|
558
|
+
variant: "secondary",
|
|
559
|
+
onClick: () => D(W === "grid" ? "masonry" : "grid"),
|
|
560
|
+
"aria-label": W === "grid" ? "Switch to masonry view" : "Switch to grid view",
|
|
561
|
+
children: W === "grid" ? /* @__PURE__ */ e(y, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(y, { icon: me.grip, className: "sc:size-5" })
|
|
562
|
+
}
|
|
563
|
+
)
|
|
564
|
+
] }),
|
|
565
|
+
se && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:mx-6 sc:mb-3 sc:rounded-2xl sc:border-2 sc:px-4 sc:py-3 sc:text-sm", children: se }),
|
|
566
|
+
A && w.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading images..." }),
|
|
567
|
+
w.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
|
|
568
|
+
W === "masonry" ? (
|
|
569
|
+
/* CSS Grid Masonry (Dense) */
|
|
570
|
+
/* @__PURE__ */ e(
|
|
571
|
+
"div",
|
|
572
|
+
{
|
|
573
|
+
className: "sc:grid sc:grid-flow-dense sc:pb-4",
|
|
574
|
+
style: {
|
|
575
|
+
display: "grid",
|
|
576
|
+
gridTemplateColumns: m === "bottom" ? "repeat(auto-fill, minmax(200px, 1fr))" : "repeat(3, 1fr)",
|
|
577
|
+
gridAutoRows: m === "bottom" ? "200px" : "120px",
|
|
578
|
+
gap: ps
|
|
579
|
+
},
|
|
580
|
+
children: w.map((s, l) => /* @__PURE__ */ e("div", { className: ts(s, l), style: ke, children: /* @__PURE__ */ e($e, { image: s, onImageSelect: ze, fixedHeight: !0 }) }, s.id))
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
) : (
|
|
584
|
+
/* Fixed Height Grid - Square Tiles */
|
|
585
|
+
/* @__PURE__ */ e(
|
|
586
|
+
"div",
|
|
587
|
+
{
|
|
588
|
+
className: "sc:pb-4",
|
|
589
|
+
style: {
|
|
590
|
+
display: "grid",
|
|
591
|
+
gridTemplateColumns: m === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
|
|
592
|
+
gap: Le
|
|
593
|
+
},
|
|
594
|
+
children: w.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...ke }, children: /* @__PURE__ */ e($e, { image: s, onImageSelect: ze, fixedHeight: !0 }) }, s.id))
|
|
595
|
+
}
|
|
596
|
+
)
|
|
597
|
+
),
|
|
598
|
+
P && /* @__PURE__ */ e("div", { ref: de, className: "sc:h-px" }),
|
|
599
|
+
A && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-4 sc:text-center sc:text-sm", children: "Loading more..." }),
|
|
600
|
+
!P && !A && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more images" })
|
|
601
|
+
] }),
|
|
602
|
+
!A && w.length === 0 && g && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
|
|
603
|
+
'No images found for "',
|
|
604
|
+
g,
|
|
605
|
+
'"'
|
|
606
|
+
] })
|
|
607
|
+
] }),
|
|
608
|
+
/* @__PURE__ */ c(M.Panel, { id: "url", className: "sc:flex sc:flex-col sc:gap-5 sc:p-6", children: [
|
|
609
|
+
/* @__PURE__ */ e(
|
|
610
|
+
"input",
|
|
611
|
+
{
|
|
612
|
+
ref: Se,
|
|
613
|
+
type: "file",
|
|
614
|
+
accept: "image/*",
|
|
615
|
+
onChange: Ze,
|
|
616
|
+
className: "sc:hidden"
|
|
617
|
+
}
|
|
618
|
+
),
|
|
619
|
+
/* @__PURE__ */ c(
|
|
620
|
+
"button",
|
|
621
|
+
{
|
|
622
|
+
type: "button",
|
|
623
|
+
onClick: Je,
|
|
624
|
+
className: "sc:flex sc:flex-col sc:items-center sc:justify-center sc:gap-3 sc:rounded-2xl sc:border-2 sc:border-dashed sc:border-divider sc:bg-muted/30 sc:px-6 sc:py-10 sc:transition-colors sc:hover:bg-muted/50 sc:active:bg-muted/60",
|
|
625
|
+
"data-testid": "image-upload-btn",
|
|
626
|
+
children: [
|
|
627
|
+
/* @__PURE__ */ e(
|
|
628
|
+
y,
|
|
629
|
+
{
|
|
630
|
+
icon: "lucide:upload-cloud",
|
|
631
|
+
className: "sc:size-10 sc:text-foreground/60"
|
|
632
|
+
}
|
|
633
|
+
),
|
|
634
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:items-center sc:gap-1", children: [
|
|
635
|
+
/* @__PURE__ */ e("span", { className: "sc:text-base sc:font-medium sc:text-foreground", children: "Upload from device" }),
|
|
636
|
+
/* @__PURE__ */ e("span", { className: "sc:text-xs sc:text-muted-foreground", children: "PNG · JPG · SVG · GIF" })
|
|
637
|
+
] })
|
|
638
|
+
]
|
|
639
|
+
}
|
|
640
|
+
),
|
|
641
|
+
/* @__PURE__ */ c("div", { className: "sc:relative sc:flex sc:items-center sc:gap-3", children: [
|
|
642
|
+
/* @__PURE__ */ e("div", { className: "sc:h-px sc:flex-1 sc:bg-divider" }),
|
|
643
|
+
/* @__PURE__ */ e("span", { className: "sc:text-muted-foreground sc:text-xs sc:uppercase sc:tracking-wider", children: "or paste a link" }),
|
|
644
|
+
/* @__PURE__ */ e("div", { className: "sc:h-px sc:flex-1 sc:bg-divider" })
|
|
645
|
+
] }),
|
|
646
|
+
/* @__PURE__ */ c(
|
|
647
|
+
"form",
|
|
648
|
+
{
|
|
649
|
+
onSubmit: qe,
|
|
650
|
+
className: "sc:flex sc:flex-col sc:gap-3",
|
|
651
|
+
children: [
|
|
652
|
+
/* @__PURE__ */ c(ye, { children: [
|
|
653
|
+
/* @__PURE__ */ e(Ie, { className: "sc:sr-only", children: "Image URL" }),
|
|
654
|
+
/* @__PURE__ */ e(
|
|
655
|
+
Ee,
|
|
656
|
+
{
|
|
657
|
+
type: "url",
|
|
658
|
+
placeholder: "https://example.com/image.jpg",
|
|
659
|
+
value: v,
|
|
660
|
+
onChange: (s) => T(s.target.value),
|
|
661
|
+
variant: "subtle",
|
|
662
|
+
"data-testid": "image-url-input"
|
|
663
|
+
}
|
|
664
|
+
)
|
|
665
|
+
] }),
|
|
666
|
+
/* @__PURE__ */ e(
|
|
667
|
+
J,
|
|
668
|
+
{
|
|
669
|
+
type: "submit",
|
|
670
|
+
variant: "default",
|
|
671
|
+
disabled: !v.trim(),
|
|
672
|
+
className: "sc:w-full",
|
|
673
|
+
"data-testid": "image-url-submit-btn",
|
|
674
|
+
children: "Use This Image"
|
|
675
|
+
}
|
|
676
|
+
)
|
|
677
|
+
]
|
|
678
|
+
}
|
|
679
|
+
),
|
|
680
|
+
v.trim() && /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-3 sc:rounded-2xl sc:border sc:border-divider sc:bg-muted/30 sc:p-4", children: [
|
|
681
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:items-center sc:justify-between sc:gap-3", children: [
|
|
682
|
+
/* @__PURE__ */ e("span", { className: "sc:text-xs sc:font-medium sc:uppercase sc:tracking-wider sc:text-muted-foreground", children: "Preview" }),
|
|
683
|
+
u && /* @__PURE__ */ e(
|
|
684
|
+
J,
|
|
685
|
+
{
|
|
686
|
+
onClick: Ke,
|
|
687
|
+
disabled: j || !v.trim(),
|
|
688
|
+
variant: "secondary",
|
|
689
|
+
size: "sm",
|
|
690
|
+
className: "sc:gap-2",
|
|
691
|
+
"data-testid": "remove-background-btn",
|
|
692
|
+
children: j ? /* @__PURE__ */ c(ae, { children: [
|
|
693
|
+
/* @__PURE__ */ e(
|
|
694
|
+
y,
|
|
695
|
+
{
|
|
696
|
+
icon: "eos-icons:loading",
|
|
697
|
+
className: "sc:size-4 sc:animate-spin"
|
|
698
|
+
}
|
|
699
|
+
),
|
|
700
|
+
"Removing…"
|
|
701
|
+
] }) : /* @__PURE__ */ c(ae, { children: [
|
|
702
|
+
/* @__PURE__ */ e(y, { icon: "mdi:image-remove", className: "sc:size-4" }),
|
|
703
|
+
"Remove BG"
|
|
704
|
+
] })
|
|
705
|
+
}
|
|
706
|
+
)
|
|
707
|
+
] }),
|
|
708
|
+
Y && /* @__PURE__ */ e("div", { className: "sc:rounded-lg sc:border sc:border-danger sc:bg-danger/10 sc:px-3 sc:py-2 sc:text-xs sc:text-danger", children: Y }),
|
|
709
|
+
/* @__PURE__ */ e(
|
|
710
|
+
"img",
|
|
711
|
+
{
|
|
712
|
+
src: v,
|
|
713
|
+
alt: "Preview",
|
|
714
|
+
className: "sc:max-h-[280px] sc:w-full sc:rounded-lg sc:object-contain",
|
|
715
|
+
onError: (s) => {
|
|
716
|
+
s.target.style.display = "none";
|
|
717
|
+
},
|
|
718
|
+
onLoad: (s) => {
|
|
719
|
+
s.target.style.display = "block";
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
)
|
|
723
|
+
] })
|
|
724
|
+
] }),
|
|
725
|
+
a && /* @__PURE__ */ c(M.Panel, { id: "vector", className: "sc:flex sc:flex-col", children: [
|
|
726
|
+
/* @__PURE__ */ c("form", { onSubmit: Qe, className: "sc:sticky sc:top-0 sc:z-9 sc:flex sc:gap-2 sc:bg-surface sc:px-6 sc:pt-4 sc:pb-3", children: [
|
|
727
|
+
/* @__PURE__ */ e(ye, { className: "sc:flex-1", "aria-label": "Search for vector graphics", children: /* @__PURE__ */ e(
|
|
728
|
+
Ee,
|
|
729
|
+
{
|
|
730
|
+
type: "text",
|
|
731
|
+
placeholder: "Search for icons...",
|
|
732
|
+
value: x,
|
|
733
|
+
onChange: (s) => ce(s.target.value),
|
|
734
|
+
variant: "subtle",
|
|
735
|
+
"data-testid": "vector-search-input"
|
|
736
|
+
}
|
|
737
|
+
) }),
|
|
738
|
+
/* @__PURE__ */ e(J, { type: "submit", size: "icon", variant: "secondary", disabled: f, "aria-label": "Search", children: /* @__PURE__ */ e(y, { icon: me.search, className: "sc:size-5" }) }),
|
|
739
|
+
/* @__PURE__ */ e(
|
|
740
|
+
J,
|
|
741
|
+
{
|
|
742
|
+
size: "icon",
|
|
743
|
+
variant: "secondary",
|
|
744
|
+
onClick: () => Re(ie === "grid" ? "masonry" : "grid"),
|
|
745
|
+
"aria-label": ie === "grid" ? "Switch to masonry view" : "Switch to grid view",
|
|
746
|
+
children: ie === "grid" ? /* @__PURE__ */ e(y, { icon: "lucide:layout-grid", className: "sc:size-5" }) : /* @__PURE__ */ e(y, { icon: me.grip, className: "sc:size-5" })
|
|
747
|
+
}
|
|
748
|
+
)
|
|
749
|
+
] }),
|
|
750
|
+
Q && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:mx-6 sc:mb-3 sc:rounded-2xl sc:border-2 sc:px-4 sc:py-3 sc:text-sm", children: Q }),
|
|
751
|
+
f && B.length === 0 && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:px-6 sc:py-8 sc:text-center sc:text-sm", children: "Loading vectors..." }),
|
|
752
|
+
B.length > 0 && /* @__PURE__ */ c("div", { className: "sc:mx-6 sc:overflow-hidden sc:rounded-t-2xl", children: [
|
|
753
|
+
ie === "masonry" ? (
|
|
754
|
+
/* CSS Grid Masonry */
|
|
755
|
+
/* @__PURE__ */ e(
|
|
756
|
+
"div",
|
|
757
|
+
{
|
|
758
|
+
className: "sc:grid sc:grid-flow-dense sc:pb-4",
|
|
759
|
+
style: {
|
|
760
|
+
display: "grid",
|
|
761
|
+
gridTemplateColumns: m === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(3, 1fr)",
|
|
762
|
+
gridAutoRows: m === "bottom" ? "150px" : "120px",
|
|
763
|
+
gap: Le
|
|
764
|
+
},
|
|
765
|
+
children: B.map((s) => /* @__PURE__ */ e("div", { style: ke, children: /* @__PURE__ */ e(je, { vector: s, onVectorSelect: Me, fixedHeight: !0 }) }, s.id))
|
|
766
|
+
}
|
|
767
|
+
)
|
|
768
|
+
) : (
|
|
769
|
+
/* Fixed Height Grid - Square Tiles */
|
|
770
|
+
/* @__PURE__ */ e(
|
|
771
|
+
"div",
|
|
772
|
+
{
|
|
773
|
+
className: "sc:pb-4",
|
|
774
|
+
style: {
|
|
775
|
+
display: "grid",
|
|
776
|
+
gridTemplateColumns: m === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
|
|
777
|
+
gap: Le
|
|
778
|
+
},
|
|
779
|
+
children: B.map((s) => /* @__PURE__ */ e("div", { style: { aspectRatio: "1 / 1", ...ke }, children: /* @__PURE__ */ e(je, { vector: s, onVectorSelect: Me, fixedHeight: !0 }) }, s.id))
|
|
780
|
+
}
|
|
781
|
+
)
|
|
782
|
+
),
|
|
783
|
+
G && /* @__PURE__ */ e("div", { ref: be, className: "sc:h-px" }),
|
|
784
|
+
f && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-4 sc:text-center sc:text-sm", children: "Loading more..." }),
|
|
785
|
+
!G && !f && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more vectors" })
|
|
786
|
+
] }),
|
|
787
|
+
!f && B.length === 0 && x && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
|
|
788
|
+
'No vectors found for "',
|
|
789
|
+
x,
|
|
790
|
+
'"'
|
|
791
|
+
] })
|
|
792
|
+
] }),
|
|
793
|
+
h && /* @__PURE__ */ c(M.Panel, { id: "ai", className: "sc:flex sc:flex-col sc:gap-6 sc:p-6", children: [
|
|
794
|
+
/* @__PURE__ */ c("form", { onSubmit: Oe, className: "sc:flex sc:flex-col sc:gap-6", children: [
|
|
795
|
+
/* @__PURE__ */ c(ye, { children: [
|
|
796
|
+
/* @__PURE__ */ e(Ie, { children: "Prompt" }),
|
|
797
|
+
/* @__PURE__ */ e(
|
|
798
|
+
Xe,
|
|
799
|
+
{
|
|
800
|
+
placeholder: "Describe the image you want to generate... (e.g., 'avocado, transparent background')",
|
|
801
|
+
value: q,
|
|
802
|
+
onChange: (s) => F(s.target.value),
|
|
803
|
+
className: "sc:min-h-[100px] sc:resize-y",
|
|
804
|
+
rows: 4,
|
|
805
|
+
"data-testid": "ai-prompt-input",
|
|
806
|
+
disabled: le
|
|
807
|
+
}
|
|
808
|
+
)
|
|
809
|
+
] }),
|
|
810
|
+
/* @__PURE__ */ e(
|
|
811
|
+
J,
|
|
812
|
+
{
|
|
813
|
+
type: "submit",
|
|
814
|
+
variant: "default",
|
|
815
|
+
disabled: !q.trim() || le,
|
|
816
|
+
className: "sc:w-full",
|
|
817
|
+
"data-testid": "ai-generate-btn",
|
|
818
|
+
children: le ? /* @__PURE__ */ c(ae, { children: [
|
|
819
|
+
/* @__PURE__ */ e(y, { icon: "eos-icons:loading", className: "sc:size-5 sc:animate-spin" }),
|
|
820
|
+
"Generating..."
|
|
821
|
+
] }) : /* @__PURE__ */ c(ae, { children: [
|
|
822
|
+
/* @__PURE__ */ e(Pe, { size: 24 }),
|
|
823
|
+
"Generate Image"
|
|
824
|
+
] })
|
|
825
|
+
}
|
|
826
|
+
)
|
|
827
|
+
] }),
|
|
828
|
+
xe && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:rounded-2xl sc:border-2 sc:px-4 sc:py-3 sc:text-sm", children: xe }),
|
|
829
|
+
k && /* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-4 sc:rounded-2xl sc:border sc:border-divider sc:bg-muted/40 sc:p-6", children: [
|
|
830
|
+
/* @__PURE__ */ e("div", { className: "sc:flex sc:items-center sc:justify-between", children: /* @__PURE__ */ e(Ie, { className: "sc:text-muted sc:text-xs sc:uppercase sc:tracking-wide", children: "Generated Image" }) }),
|
|
831
|
+
/* @__PURE__ */ e("div", { className: "sc:flex sc:w-fit sc:items-center sc:justify-center sc:overflow-hidden sc:rounded-lg sc:bg-white/50 sc:dark:bg-black/50", style: { maxHeight: "500px", maxWidth: "100%" }, children: /* @__PURE__ */ e(
|
|
832
|
+
"img",
|
|
833
|
+
{
|
|
834
|
+
src: k,
|
|
835
|
+
alt: q,
|
|
836
|
+
className: "sc:max-h-full sc:max-w-full sc:object-contain"
|
|
837
|
+
}
|
|
838
|
+
) }),
|
|
839
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-1", children: [
|
|
840
|
+
/* @__PURE__ */ e(Ie, { className: "sc:text-muted sc:text-xs", children: "Prompt" }),
|
|
841
|
+
/* @__PURE__ */ e("p", { className: "sc:text-sm", children: q })
|
|
842
|
+
] }),
|
|
843
|
+
/* @__PURE__ */ c("div", { className: "sc:flex sc:flex-col sc:gap-3", children: [
|
|
844
|
+
u && /* @__PURE__ */ e(
|
|
845
|
+
J,
|
|
846
|
+
{
|
|
847
|
+
onClick: ss,
|
|
848
|
+
disabled: j || !k,
|
|
849
|
+
variant: "secondary",
|
|
850
|
+
size: "sm",
|
|
851
|
+
className: "sc:w-full sc:gap-2",
|
|
852
|
+
"data-testid": "ai-remove-background-btn",
|
|
853
|
+
children: j ? /* @__PURE__ */ c(ae, { children: [
|
|
854
|
+
/* @__PURE__ */ e(y, { icon: "eos-icons:loading", className: "sc:size-4 sc:animate-spin" }),
|
|
855
|
+
"Removing..."
|
|
856
|
+
] }) : /* @__PURE__ */ c(ae, { children: [
|
|
857
|
+
/* @__PURE__ */ e(y, { icon: "mdi:image-remove", className: "sc:size-4" }),
|
|
858
|
+
"Remove Background"
|
|
859
|
+
] })
|
|
860
|
+
}
|
|
861
|
+
),
|
|
862
|
+
Y && /* @__PURE__ */ e("div", { className: "sc:border-danger sc:bg-danger/10 sc:text-danger sc:rounded-xl sc:border-2 sc:px-3 sc:py-2 sc:text-xs", children: Y }),
|
|
863
|
+
/* @__PURE__ */ e(
|
|
864
|
+
J,
|
|
865
|
+
{
|
|
866
|
+
onClick: es,
|
|
867
|
+
variant: "default",
|
|
868
|
+
className: "sc:w-full",
|
|
869
|
+
"data-testid": "ai-use-image-btn",
|
|
870
|
+
children: "Use This Image"
|
|
871
|
+
}
|
|
872
|
+
)
|
|
873
|
+
] })
|
|
874
|
+
] })
|
|
875
|
+
] })
|
|
876
|
+
]
|
|
877
|
+
}
|
|
878
|
+
)
|
|
879
|
+
]
|
|
880
|
+
}
|
|
881
|
+
);
|
|
882
|
+
}, bs = Fe("ImagePanel");
|
|
883
|
+
function vs(d, t, p, R) {
|
|
884
|
+
const { zoom: m, setElements: z, executeElementUpdate: r } = R, h = d.transformData.width || 300 / m, a = d.transformData.height || 300 / m;
|
|
885
|
+
t.imageUrl = p, t.transformData.cropX = 0, t.transformData.cropY = 0, t.transformData.cropWidth = 1, t.transformData.cropHeight = 1, t.transformData.flipHorizontal = !1, t.transformData.flipVertical = !1, t.transformData.borderRadius = 0, t.imageLoaded = !1, t.imageElement = null, t.isCropping = !1, t.preserveDimensions = !1, t.transformData.width = h, t.transformData.height = a, t.onLoadCallback = (u) => {
|
|
886
|
+
const o = u, g = o.transformData.width, S = o.transformData.height, v = Math.min(h / g, a / S, 1);
|
|
887
|
+
v < 1 && (o.transformData.width = g * v, o.transformData.height = S * v), z((T) => T.map((w) => w.id === o.id ? o : w));
|
|
888
|
+
}, t.loadImage(p), r(d, t);
|
|
889
|
+
}
|
|
890
|
+
const Es = ({
|
|
891
|
+
isOpen: d,
|
|
892
|
+
onOpenChange: t,
|
|
893
|
+
onImageAdded: p,
|
|
894
|
+
onImageChanged: R,
|
|
895
|
+
changingElementId: m,
|
|
896
|
+
onChangingElementIdChange: z,
|
|
897
|
+
services: r
|
|
898
|
+
}) => {
|
|
899
|
+
var O;
|
|
900
|
+
const {
|
|
901
|
+
elements: h,
|
|
902
|
+
setElements: a,
|
|
903
|
+
canvasEditorRef: u,
|
|
904
|
+
artboardManager: o,
|
|
905
|
+
executeAddElement: g,
|
|
906
|
+
executeElementUpdate: S,
|
|
907
|
+
executeRemoveElement: v
|
|
908
|
+
} = rs(), { selectedId: T, setSelectedId: w } = as(), { activeArtboardId: N } = ls(), A = _e(), K = Ge(() => {
|
|
909
|
+
if (A.ingestImage) return A.ingestImage;
|
|
910
|
+
if (r != null && r.ingestImage) return r.ingestImage;
|
|
911
|
+
if (r != null && r.ingestImageUrl) return ds(r.ingestImageUrl);
|
|
912
|
+
}, [A.ingestImage, r == null ? void 0 : r.ingestImage, r == null ? void 0 : r.ingestImageUrl]), se = U(K);
|
|
913
|
+
se.current = K;
|
|
914
|
+
const H = U(h);
|
|
915
|
+
H.current = h;
|
|
916
|
+
const C = U(T);
|
|
917
|
+
C.current = T;
|
|
918
|
+
const [te, ne] = n(null), $ = m ?? te, P = z ?? ne, [oe, W] = n(!1), D = fe(
|
|
919
|
+
async (f) => {
|
|
920
|
+
var pe, xe;
|
|
921
|
+
const V = se.current;
|
|
922
|
+
if (V) {
|
|
923
|
+
W(!0);
|
|
924
|
+
try {
|
|
925
|
+
f = await V(f);
|
|
926
|
+
} catch (I) {
|
|
927
|
+
bs.warn("Image ingest failed; placing the original URL", I);
|
|
928
|
+
} finally {
|
|
929
|
+
W(!1);
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
const Q = H.current, he = C.current;
|
|
933
|
+
let ee = $, ge = [];
|
|
934
|
+
if (!ee && N) {
|
|
935
|
+
const I = o.placeholderOnlyElementIds(N), k = I ? Q.find((E) => I.includes(E.id) && Ve(E)) : void 0;
|
|
936
|
+
I && k && (ee = k.id, ge = I.filter((E) => E !== k.id));
|
|
937
|
+
}
|
|
938
|
+
if (ee) {
|
|
939
|
+
const I = Q.find((k) => k.id === ee);
|
|
940
|
+
if (I && Ve(I)) {
|
|
941
|
+
const k = o.getArtboardForElement(I.id) ?? o.getActiveArtboard(), E = await Te(k, f), j = H.current.find((Y) => Y.id === I.id) ?? I, i = j.clone();
|
|
942
|
+
E ? (i.imageUrl = f, i.transformData.cropX = 0, i.transformData.cropY = 0, i.transformData.cropWidth = 1, i.transformData.cropHeight = 1, i.transformData.flipHorizontal = !1, i.transformData.flipVertical = !1, i.transformData.borderRadius = 0, i.imageLoaded = !1, i.imageElement = null, i.isCropping = !1, i.preserveDimensions = !0, i.rotation = 0, i.x = E.x, i.y = E.y, i.transformData.width = E.width, i.transformData.height = E.height, i.onLoadCallback = (Y) => {
|
|
943
|
+
const X = Y;
|
|
944
|
+
a((de) => de.map((be) => be.id === X.id ? X : be));
|
|
945
|
+
}, S(j, i), i.loadImage(f)) : vs(j, i, f, {
|
|
946
|
+
zoom: ((pe = u.current) == null ? void 0 : pe.getZoom()) || 1,
|
|
947
|
+
setElements: a,
|
|
948
|
+
executeElementUpdate: S
|
|
949
|
+
}), o.unmarkPlaceholder(i.id);
|
|
950
|
+
for (const Y of ge) {
|
|
951
|
+
const X = H.current.find((de) => de.id === Y);
|
|
952
|
+
X && v(X);
|
|
953
|
+
}
|
|
954
|
+
$ || w(i.id), R && R(i);
|
|
955
|
+
}
|
|
956
|
+
$ && P(null);
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
if (!N) {
|
|
960
|
+
alert("Please create or select an artboard first");
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
const G = `element-${Date.now()}`, _ = o.getActiveArtboard(), ie = _ ? _.x + _.width / 2 : window.innerWidth / 2, Re = _ ? _.y + _.height / 2 : window.innerHeight / 2, q = ((xe = u.current) == null ? void 0 : xe.getZoom()) || 1, F = await Te(_, f), le = new ms({
|
|
964
|
+
id: G,
|
|
965
|
+
x: F ? F.x : ie,
|
|
966
|
+
y: F ? F.y : Re,
|
|
967
|
+
imageUrl: f,
|
|
968
|
+
...F ? { preserveDimensions: !0 } : {},
|
|
969
|
+
transformData: F ? { width: F.width, height: F.height } : {
|
|
970
|
+
width: 300 / q,
|
|
971
|
+
height: 300 / q
|
|
972
|
+
},
|
|
973
|
+
onLoadCallback: (I) => {
|
|
974
|
+
const k = I;
|
|
975
|
+
a((E) => E.map((j) => j.id === k.id ? k : j));
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
o.addElementToArtboard(G, N), g(le, N, he || void 0), w(G), p && p(le);
|
|
979
|
+
},
|
|
980
|
+
[
|
|
981
|
+
$,
|
|
982
|
+
// Note: elements and selectedId are accessed via refs (elementsRef, selectedIdRef)
|
|
983
|
+
// to prevent callback recreation on every context update
|
|
984
|
+
o,
|
|
985
|
+
g,
|
|
986
|
+
S,
|
|
987
|
+
v,
|
|
988
|
+
N,
|
|
989
|
+
u,
|
|
990
|
+
a,
|
|
991
|
+
w,
|
|
992
|
+
P,
|
|
993
|
+
p,
|
|
994
|
+
R
|
|
995
|
+
]
|
|
996
|
+
), x = fe(
|
|
997
|
+
(f) => {
|
|
998
|
+
t(f), f || P(null);
|
|
999
|
+
},
|
|
1000
|
+
[t, P]
|
|
1001
|
+
), ce = $ ? (O = h.find((f) => f.id === $)) == null ? void 0 : O.imageUrl : void 0, B = /* @__PURE__ */ e(
|
|
1002
|
+
xs,
|
|
1003
|
+
{
|
|
1004
|
+
isOpen: d,
|
|
1005
|
+
onToggle: x,
|
|
1006
|
+
onImageSelect: D,
|
|
1007
|
+
currentImageUrl: ce,
|
|
1008
|
+
busy: oe
|
|
1009
|
+
}
|
|
1010
|
+
);
|
|
1011
|
+
return r ? /* @__PURE__ */ e(us, { services: r, children: B }) : B;
|
|
1012
|
+
};
|
|
1013
|
+
export {
|
|
1014
|
+
Es as ImagePanel
|
|
1015
|
+
};
|
|
1016
|
+
//# sourceMappingURL=ImagePanel-DY9Ve3X7.js.map
|