@snowcone-app/canvas 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/ERROR_CONTRACT.md +45 -0
  2. package/dist/{CanvasRenderer-3M-52sAd.js → CanvasRenderer-DnYgiWjt.js} +4 -4
  3. package/dist/{CanvasRenderer-3M-52sAd.js.map → CanvasRenderer-DnYgiWjt.js.map} +1 -1
  4. package/dist/{CanvasStateV1-BQ3cbxt2.js → CanvasStateV1-B51bXTyy.js} +3 -3
  5. package/dist/{CanvasStateV1-BQ3cbxt2.js.map → CanvasStateV1-B51bXTyy.js.map} +1 -1
  6. package/dist/{ContextualToolbars-B2LTNu7r.js → ContextualToolbars-DtlxDatY.js} +6 -6
  7. package/dist/{ContextualToolbars-B2LTNu7r.js.map → ContextualToolbars-DtlxDatY.js.map} +1 -1
  8. package/dist/{EditorCanvasImpl-VJ7kBhXB.js → EditorCanvasImpl-BpudFLkw.js} +8 -8
  9. package/dist/{EditorCanvasImpl-VJ7kBhXB.js.map → EditorCanvasImpl-BpudFLkw.js.map} +1 -1
  10. package/dist/{ExportManager-9_RjQEv0.js → ExportManager-vAuaoF5Q.js} +1212 -1224
  11. package/dist/{ExportManager-9_RjQEv0.js.map → ExportManager-vAuaoF5Q.js.map} +1 -1
  12. package/dist/{FontAnalyzer-Ch1jgTq7.js → FontAnalyzer-D9R2PYsy.js} +5 -1
  13. package/dist/FontAnalyzer-D9R2PYsy.js.map +1 -0
  14. package/dist/{ImagePanel-DY9Ve3X7.js → ImagePanel-kybrF6yT.js} +372 -366
  15. package/dist/{ImagePanel-DY9Ve3X7.js.map → ImagePanel-kybrF6yT.js.map} +1 -1
  16. package/dist/SnowconeCanvas-p9XmnSCK.js +1157 -0
  17. package/dist/SnowconeCanvas-p9XmnSCK.js.map +1 -0
  18. package/dist/advanced.mjs +15 -15
  19. package/dist/api/embed.d.ts +1 -0
  20. package/dist/api/stable.d.ts +1 -0
  21. package/dist/components/embed/SnowconeCanvas.d.ts +18 -2
  22. package/dist/core/ArtboardManager.d.ts +2 -0
  23. package/dist/{custom-icons-D_XezOul.js → custom-icons-Dlfrg3A_.js} +2 -2
  24. package/dist/{custom-icons-D_XezOul.js.map → custom-icons-Dlfrg3A_.js.map} +1 -1
  25. package/dist/{design-builder-BFM94eA9.js → design-builder-C8s1r4MF.js} +20 -19
  26. package/dist/{design-builder-BFM94eA9.js.map → design-builder-C8s1r4MF.js.map} +1 -1
  27. package/dist/{embed-5W-gg9dt.js → embed-DuIOU8mL.js} +10 -10
  28. package/dist/{embed-5W-gg9dt.js.map → embed-DuIOU8mL.js.map} +1 -1
  29. package/dist/embed.mjs +15 -15
  30. package/dist/errors/editorError.d.ts +4 -1
  31. package/dist/{guards-D_mw4DgS.js → guards-B0PNEbK6.js} +2 -2
  32. package/dist/{guards-D_mw4DgS.js.map → guards-B0PNEbK6.js.map} +1 -1
  33. package/dist/index.mjs +9 -9
  34. package/dist/internals.mjs +6 -6
  35. package/dist/{template-fields-CQURvcab.js → template-fields-DCZ9TqxY.js} +19 -19
  36. package/dist/{template-fields-CQURvcab.js.map → template-fields-DCZ9TqxY.js.map} +1 -1
  37. package/dist/testing.mjs +3 -3
  38. package/dist/{useCommands-DSapP-w1.js → useCommands-d5UM6Cnc.js} +7 -7
  39. package/dist/{useCommands-DSapP-w1.js.map → useCommands-d5UM6Cnc.js.map} +1 -1
  40. package/dist/{usePieceGuideBundle-oBykb3X8.js → usePieceGuideBundle-BPVWvChD.js} +2 -2
  41. package/dist/{usePieceGuideBundle-oBykb3X8.js.map → usePieceGuideBundle-BPVWvChD.js.map} +1 -1
  42. package/dist/utils/ExportManager.d.ts +37 -1
  43. package/dist/utils/printFiles.d.ts +23 -0
  44. package/dist/{validation-D6zVSeTh.js → validation-C8qNtk6j.js} +11 -11
  45. package/dist/{validation-D6zVSeTh.js.map → validation-C8qNtk6j.js.map} +1 -1
  46. package/example/package.json +1 -1
  47. package/package.json +2 -2
  48. package/dist/FontAnalyzer-Ch1jgTq7.js.map +0 -1
  49. package/dist/SnowconeCanvas-BzOy46Yw.js +0 -1098
  50. package/dist/SnowconeCanvas-BzOy46Yw.js.map +0 -1
@@ -1,83 +1,83 @@
1
- import { jsx as e, jsxs as c, Fragment as ae } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as c, Fragment as oe } from "react/jsx-runtime";
2
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");
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-d5UM6Cnc.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-Dlfrg3A_.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: os(
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
- u === "default" && "sc:bg-field sc:shadow-soft sc:dark:shadow-none",
23
- u === "filled" && "sc:bg-[var(--color-field-on-surface)]",
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: p,
28
+ disabled: x,
29
29
  readOnly: R,
30
- required: m,
30
+ required: u,
31
31
  "aria-invalid": t,
32
32
  ...r
33
33
  }
34
34
  );
35
35
  }
36
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;
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 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;
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
- })) : (u(x), z(!0)), v.current = !1;
63
+ })) : (m(v), z(!0)), b.current = !1;
64
64
  }, H = (D) => {
65
- N.current && (cancelAnimationFrame(N.current), N.current = null);
66
- const x = K(D);
67
- u(x), w(!1), z(!1);
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
- g.current && (clearTimeout(g.current), g.current = null), o.current = setTimeout(() => {
69
+ p.current && (clearTimeout(p.current), p.current = null), a.current = setTimeout(() => {
70
70
  h(!0);
71
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);
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", oe = m || r, W = () => {
79
- if (!m) return "none";
80
- switch (a) {
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: S,
97
- onClick: A,
98
- onMouseEnter: se,
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: W(),
110
- filter: m ? "brightness(1.04)" : void 0
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 ${oe ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
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: te,
121
- children: /* @__PURE__ */ e(y, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
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: ne,
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
- y,
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(ae, { children: [
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
- }), 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(() => {
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
- }, 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);
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
- }, w = m || r;
192
+ }, N = u || r;
193
193
  return /* @__PURE__ */ c(
194
194
  "div",
195
195
  {
196
- onClick: o,
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"} ${m ? "sc:scale-105 sc:bg-white/20" : ""}`,
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 ${m ? "sc:scale-110" : "sc:scale-100"}`,
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: m ? "brightness(1.1)" : void 0
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 ${w ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
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 ${w ? "sc:opacity-100" : "sc:pointer-events-none sc:opacity-0"}`,
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: g,
232
- onMouseLeave: S,
233
- children: /* @__PURE__ */ e(y, { icon: "lucide:aperture", className: "sc:size-4 sc:text-white/80" })
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: v,
241
+ onMouseEnter: b,
242
242
  onMouseLeave: T,
243
243
  children: [
244
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" }),
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
- }), xs = ({
256
+ }), bs = ({
257
257
  isOpen: d,
258
258
  onToggle: t,
259
- onImageSelect: p,
259
+ onImageSelect: x,
260
260
  currentImageUrl: R,
261
- placement: m = "bottom",
261
+ placement: u = "bottom",
262
262
  busy: z = !1
263
263
  }) => {
264
- const { imageSearch: r, generate: h, vectors: a, removeBackground: u } = _e(), o = Ge(
264
+ const { imageSearch: r, generate: h, vectors: n, removeBackground: m } = Fe(), a = _e(
265
265
  () => [
266
266
  ...r ? ["search"] : [],
267
267
  "url",
268
- ...a ? ["vector"] : [],
268
+ ...n ? ["vector"] : [],
269
269
  ...h ? ["ai"] : []
270
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));
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 we = fe(
281
- async (s, l, b) => {
280
+ const se = he(
281
+ async (s, l, w) => {
282
282
  if (r) {
283
- K(!0), H(null);
283
+ Z(!0), H(null);
284
284
  try {
285
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);
286
+ y((Q) => w ? [...Q, ...L.results] : L.results), $(L.page), le(L.hasMore);
287
287
  } catch (L) {
288
- H(fs), ve.error("Error searching images:", L);
288
+ H(hs), we.error("Error searching images:", L);
289
289
  } finally {
290
- K(!1);
290
+ Z(!1);
291
291
  }
292
292
  }
293
293
  },
294
294
  [r]
295
295
  );
296
- re(() => {
297
- d && !g && C === "search" && w.length === 0 && r && we("", 1, !1);
296
+ ne(() => {
297
+ d && !p && C === "search" && N.length === 0 && r && se("", 1, !1);
298
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;
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
- (b) => {
309
- b[0].isIntersecting && P && !A && Ae();
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, A, Ae]);
323
- const Ne = fe(
322
+ }, [d, C, P, S, De]);
323
+ const Ie = he(
324
324
  async (s, l) => {
325
- if (a) {
326
- V(!0), he(null);
325
+ if (n) {
326
+ U(!0), ge(null);
327
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);
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
- V(!1);
336
+ U(!1);
337
337
  }
338
338
  }
339
339
  },
340
- [a]
340
+ [n]
341
341
  );
342
- re(() => {
343
- d && !x && C === "vector" && B.length === 0 && a && Ne("");
344
- }, [d, C, a]);
342
+ ne(() => {
343
+ d && !v && C === "vector" && j.length === 0 && n && Ie("");
344
+ }, [d, C, n]);
345
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;
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
- (b) => {
355
- b[0].isIntersecting && G && !f && De();
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, G, f, De]);
367
- const Me = (s) => {
366
+ }, [d, C, W, f, Me]);
367
+ const ze = (s) => {
368
368
  const l = s.selectUrl || s.urls.svg || s.urls.png;
369
- l && (p(l), t(!1));
370
- }, ze = (s) => {
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
- p(s.urls.regular), t(!1);
377
+ x(s.urls.regular), t(!1);
378
378
  }, qe = (s) => {
379
- s.preventDefault(), v.trim() && (p(v.trim()), t(!1));
379
+ s.preventDefault(), b.trim() && (x(b.trim()), t(!1));
380
380
  }, Ze = (s) => {
381
- var b;
382
- const l = (b = s.target.files) == null ? void 0 : b[0];
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 = (Z) => {
385
+ L.onload = (Q) => {
386
386
  var ue;
387
- const Ce = (ue = Z.target) == null ? void 0 : ue.result;
388
- T(Ce);
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 = Se.current) == null || s.click();
393
+ (s = ee.current) == null || s.click();
394
394
  }, Ke = async () => {
395
- if (!(!u || !v.trim())) {
396
- i(!0), X(null);
395
+ if (!(!m || !b.trim())) {
396
+ E(!0), _(null);
397
397
  try {
398
- const s = await u(v);
398
+ const s = await m(b);
399
399
  T(s);
400
400
  } catch (s) {
401
- X(Be), ve.error("Error removing background:", s);
401
+ _($e), we.error("Error removing background:", s);
402
402
  } finally {
403
- i(!1);
403
+ E(!1);
404
404
  }
405
405
  }
406
406
  }, Oe = async (s) => {
407
- var l, b;
407
+ var l, w;
408
408
  if (s.preventDefault(), !!h) {
409
- if (!q.trim()) {
410
- I("Please enter a prompt");
409
+ if (!V.trim()) {
410
+ de("Please enter a prompt");
411
411
  return;
412
412
  }
413
- pe(!0), I(null), E(null);
413
+ ve(!0), de(null), me(null);
414
414
  try {
415
- const Z = (b = (l = (await h.generate({
416
- prompt: q,
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 : b.imageUrl;
421
- if (!Z)
422
- throw new Error(Ue);
423
- E(Z);
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
- I(gs(L, Ue)), ve.error("Error generating AI image:", L);
425
+ de(ps(L, Be)), we.error("Error generating AI image:", L);
426
426
  } finally {
427
- pe(!1);
427
+ ve(!1);
428
428
  }
429
429
  }
430
430
  }, es = () => {
431
- k && (p(k), t(!1));
431
+ F && (x(F), t(!1));
432
432
  }, ss = async () => {
433
- if (!(!u || !k)) {
434
- i(!0), X(null);
433
+ if (!(!m || !F)) {
434
+ E(!0), _(null);
435
435
  try {
436
- const s = await u(k);
437
- E(s);
436
+ const s = await m(F);
437
+ me(s);
438
438
  } catch (s) {
439
- X(Be), ve.error("Error removing background:", s);
439
+ _($e), we.error("Error removing background:", s);
440
440
  } finally {
441
- i(!1);
441
+ E(!1);
442
442
  }
443
443
  }
444
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" : "";
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
- is,
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: m,
456
- height: m === "bottom" ? "90vh" : void 0,
457
- width: m !== "bottom" ? "500px" : void 0,
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) => te(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(y, { icon: me.image, className: "sc:size-6" }),
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(y, { icon: me.link, className: "sc:size-6" }),
508
+ /* @__PURE__ */ e(k, { icon: fe.link, className: "sc:size-6" }),
509
509
  /* @__PURE__ */ e(M.Indicator, {})
510
510
  ]
511
511
  }
512
512
  ),
513
- a && /* @__PURE__ */ c(
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(y, { icon: "fa6-solid:icons", className: "sc:size-5" }),
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(Pe, { size: 24 }),
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: 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,
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: g,
548
- onChange: (s) => S(s.target.value),
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(J, { type: "submit", size: "icon", variant: "secondary", disabled: A, "aria-label": "Search", children: /* @__PURE__ */ e(y, { icon: me.search, className: "sc:size-5" }) }),
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
- J,
555
+ q,
556
556
  {
557
557
  size: "icon",
558
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" })
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
- 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" ? (
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: m === "bottom" ? "repeat(auto-fill, minmax(200px, 1fr))" : "repeat(3, 1fr)",
577
- gridAutoRows: m === "bottom" ? "200px" : "120px",
578
- gap: ps
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: 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))
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: m === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
592
- gap: Le
591
+ gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(auto-fill, minmax(120px, 1fr))",
592
+ gap: Se
593
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))
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: 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" })
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
- !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: [
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
- g,
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: Se,
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
- y,
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(ye, { children: [
653
- /* @__PURE__ */ e(Ie, { className: "sc:sr-only", children: "Image URL" }),
652
+ /* @__PURE__ */ c(ke, { children: [
653
+ /* @__PURE__ */ e(Ee, { className: "sc:sr-only", children: "Image URL" }),
654
654
  /* @__PURE__ */ e(
655
- Ee,
655
+ Ae,
656
656
  {
657
657
  type: "url",
658
658
  placeholder: "https://example.com/image.jpg",
659
- value: v,
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
- J,
667
+ q,
668
668
  {
669
669
  type: "submit",
670
670
  variant: "default",
671
- disabled: !v.trim(),
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
- 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: [
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
- u && /* @__PURE__ */ e(
684
- J,
683
+ m && /* @__PURE__ */ e(
684
+ q,
685
685
  {
686
686
  onClick: Ke,
687
- disabled: j || !v.trim(),
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: j ? /* @__PURE__ */ c(ae, { children: [
692
+ children: g ? /* @__PURE__ */ c(oe, { children: [
693
693
  /* @__PURE__ */ e(
694
- y,
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(ae, { children: [
702
- /* @__PURE__ */ e(y, { icon: "mdi:image-remove", className: "sc:size-4" }),
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
- 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 }),
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: v,
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
- a && /* @__PURE__ */ c(M.Panel, { id: "vector", className: "sc:flex sc:flex-col", children: [
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(ye, { className: "sc:flex-1", "aria-label": "Search for vector graphics", children: /* @__PURE__ */ e(
728
- Ee,
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: x,
733
- onChange: (s) => ce(s.target.value),
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(J, { type: "submit", size: "icon", variant: "secondary", disabled: f, "aria-label": "Search", children: /* @__PURE__ */ e(y, { icon: me.search, className: "sc:size-5" }) }),
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
- J,
740
+ q,
741
741
  {
742
742
  size: "icon",
743
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" })
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
- 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" ? (
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: m === "bottom" ? "repeat(auto-fill, minmax(150px, 1fr))" : "repeat(3, 1fr)",
762
- gridAutoRows: m === "bottom" ? "150px" : "120px",
763
- gap: Le
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: B.map((s) => /* @__PURE__ */ e("div", { style: ke, children: /* @__PURE__ */ e(je, { vector: s, onVectorSelect: Me, fixedHeight: !0 }) }, s.id))
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: m === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
777
- gap: Le
776
+ gridTemplateColumns: u === "bottom" ? "repeat(auto-fill, minmax(120px, 1fr))" : "repeat(auto-fill, minmax(100px, 1fr))",
777
+ gap: Se
778
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))
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
- G && /* @__PURE__ */ e("div", { ref: be, className: "sc:h-px" }),
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
- !G && !f && /* @__PURE__ */ e("div", { className: "sc:text-muted sc:py-6 sc:text-center sc:text-sm", children: "No more vectors" })
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 && B.length === 0 && x && /* @__PURE__ */ c("div", { className: "sc:text-muted sc:px-6 sc:py-12 sc:text-center sc:text-sm", children: [
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
- x,
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(ye, { children: [
796
- /* @__PURE__ */ e(Ie, { children: "Prompt" }),
795
+ /* @__PURE__ */ c(ke, { children: [
796
+ /* @__PURE__ */ e(Ee, { children: "Prompt" }),
797
797
  /* @__PURE__ */ e(
798
- Xe,
798
+ We,
799
799
  {
800
800
  placeholder: "Describe the image you want to generate... (e.g., 'avocado, transparent background')",
801
- value: q,
802
- onChange: (s) => F(s.target.value),
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: le
806
+ disabled: be
807
807
  }
808
808
  )
809
809
  ] }),
810
810
  /* @__PURE__ */ e(
811
- J,
811
+ q,
812
812
  {
813
813
  type: "submit",
814
814
  variant: "default",
815
- disabled: !q.trim() || le,
815
+ disabled: !V.trim() || be,
816
816
  className: "sc:w-full",
817
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" }),
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(ae, { children: [
822
- /* @__PURE__ */ e(Pe, { size: 24 }),
821
+ ] }) : /* @__PURE__ */ c(oe, { children: [
822
+ /* @__PURE__ */ e(Ve, { size: 24 }),
823
823
  "Generate Image"
824
824
  ] })
825
825
  }
826
826
  )
827
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" }) }),
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: k,
835
- alt: q,
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(Ie, { className: "sc:text-muted sc:text-xs", children: "Prompt" }),
841
- /* @__PURE__ */ e("p", { className: "sc:text-sm", children: q })
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
- u && /* @__PURE__ */ e(
845
- J,
844
+ m && /* @__PURE__ */ e(
845
+ q,
846
846
  {
847
847
  onClick: ss,
848
- disabled: j || !k,
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: j ? /* @__PURE__ */ c(ae, { children: [
854
- /* @__PURE__ */ e(y, { icon: "eos-icons:loading", className: "sc:size-4 sc:animate-spin" }),
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(ae, { children: [
857
- /* @__PURE__ */ e(y, { icon: "mdi:image-remove", className: "sc:size-4" }),
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
- 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 }),
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
- J,
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
- }, 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);
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 Es = ({
890
+ const Ls = ({
891
891
  isOpen: d,
892
892
  onOpenChange: t,
893
- onImageAdded: p,
893
+ onImageAdded: x,
894
894
  onImageChanged: R,
895
- changingElementId: m,
895
+ changingElementId: u,
896
896
  onChangingElementIdChange: z,
897
897
  services: r
898
898
  }) => {
899
- var O;
899
+ var J;
900
900
  const {
901
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;
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 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);
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 = U(T);
916
+ const C = B(T);
917
917
  C.current = T;
918
- const [te, ne] = n(null), $ = m ?? te, P = z ?? ne, [oe, W] = n(!1), D = fe(
918
+ const [ce, ie] = o(null), $ = u ?? ce, P = z ?? ie, [le, Y] = o(!1), D = he(
919
919
  async (f) => {
920
- var pe, xe;
921
- const V = se.current;
922
- if (V) {
923
- W(!0);
920
+ var F, me;
921
+ const U = te.current;
922
+ if (U) {
923
+ Y(!0);
924
924
  try {
925
- f = await V(f);
926
- } catch (I) {
927
- bs.warn("Image ingest failed; placing the original URL", I);
925
+ f = await U(f);
926
+ } catch (g) {
927
+ vs.warn("Image ingest failed; placing the original URL", g);
928
928
  } finally {
929
- W(!1);
929
+ Y(!1);
930
930
  }
931
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));
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 (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);
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
- $ || w(i.id), R && R(i);
960
+ ae(), $ || N(i.id), R && R(i);
955
961
  }
956
962
  $ && P(null);
957
963
  return;
958
964
  }
959
- if (!N) {
965
+ if (!y) {
960
966
  alert("Please create or select an artboard first");
961
967
  return;
962
968
  }
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,
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
- ...F ? { preserveDimensions: !0 } : {},
969
- transformData: F ? { width: F.width, height: F.height } : {
970
- width: 300 / q,
971
- height: 300 / q
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: (I) => {
974
- const k = I;
975
- a((E) => E.map((j) => j.id === k.id ? k : j));
979
+ onLoadCallback: (g) => {
980
+ const E = g;
981
+ n((I) => I.map((_) => _.id === E.id ? E : _));
976
982
  }
977
983
  });
978
- o.addElementToArtboard(G, N), g(le, N, he || void 0), w(G), p && p(le);
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
- ), x = fe(
1002
+ ), v = he(
997
1003
  (f) => {
998
1004
  t(f), f || P(null);
999
1005
  },
1000
1006
  [t, P]
1001
- ), ce = $ ? (O = h.find((f) => f.id === $)) == null ? void 0 : O.imageUrl : void 0, B = /* @__PURE__ */ e(
1002
- xs,
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: x,
1011
+ onToggle: v,
1006
1012
  onImageSelect: D,
1007
- currentImageUrl: ce,
1008
- busy: oe
1013
+ currentImageUrl: re,
1014
+ busy: le
1009
1015
  }
1010
1016
  );
1011
- return r ? /* @__PURE__ */ e(us, { services: r, children: B }) : B;
1017
+ return r ? /* @__PURE__ */ e(us, { services: r, children: j }) : j;
1012
1018
  };
1013
1019
  export {
1014
- Es as ImagePanel
1020
+ Ls as ImagePanel
1015
1021
  };
1016
- //# sourceMappingURL=ImagePanel-DY9Ve3X7.js.map
1022
+ //# sourceMappingURL=ImagePanel-kybrF6yT.js.map