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