@emailmaker/filemanager 1.1.75 → 1.1.84

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.
@@ -1,4 +1,4 @@
1
- import { B as e, C as t, G as n, I as r, M as i, N as a, Q as o, T as s, X as c, _ as l, f as u, nt as ee, ut as d, w as f } from "./file-manager-hooks-vqT-4jeg.js";
1
+ import { D as e, E as t, F as n, H as r, P as i, Q as a, R as o, T as s, et as c, f as l, ft as u, it as ee, q as d, y as f } from "./file-manager-hooks-DQggJnuP.js";
2
2
  import { i as p, t as te } from "./file-manager-urls-DN9gaYil.js";
3
3
  import m from "react";
4
4
  import { Button as h, Modal as ne } from "antd";
@@ -74,10 +74,10 @@ function oe(e, t) {
74
74
  if (e === "svg") return new Blob([t], { type: "image/svg+xml" });
75
75
  let n = `image/${e}`;
76
76
  if (t.startsWith("data:")) {
77
- let e = c(t);
78
- return e && e.startsWith("image/") && (n = e), C(t.replace(/data:image\/[^;]+;base64,/, ""), o(n));
77
+ let e = a(t);
78
+ return e && e.startsWith("image/") && (n = e), C(t.replace(/data:image\/[^;]+;base64,/, ""), c(n));
79
79
  }
80
- return C(t, o(n));
80
+ return C(t, c(n));
81
81
  }
82
82
  function w(e) {
83
83
  return new Promise((t, n) => {
@@ -85,8 +85,8 @@ function w(e) {
85
85
  r.onload = () => t(r.result), r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("Failed to convert blob to data URL")), r.readAsDataURL(e);
86
86
  });
87
87
  }
88
- var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
89
- let { t: x } = n(), C = m.useRef(null), T = r(), se = u(), { options: E, actions: ce } = e(), { i18n: D } = n(), { config: O } = E, { setCurrentMenuFile: k } = ce, { getFileData: A, resolveFileForEditByUrl: j } = se, [M, N] = m.useState(!1), [P, F] = m.useState(null), [I, L] = m.useState(""), [R, z] = m.useState(!1), [B, V] = m.useState(!1), [H, U] = m.useState(null), W = m.useRef(!1), G = m.useRef(void 0), K = m.useRef(void 0), q = m.useRef("saveCopy"), J = m.useRef(void 0);
88
+ var T = ({ visible: a, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
89
+ let { t: x } = d(), C = m.useRef(null), T = o(), se = l(), { options: E, actions: ce } = r(), { i18n: D } = d(), { config: O } = E, { setCurrentMenuFile: k } = ce, { getFileData: A, resolveFileForEditByUrl: j } = se, [M, N] = m.useState(!1), [P, F] = m.useState(null), [I, L] = m.useState(""), [R, z] = m.useState(!1), [B, V] = m.useState(!1), [H, U] = m.useState(null), W = m.useRef(!1), G = m.useRef(void 0), K = m.useRef(void 0), q = m.useRef("saveCopy"), J = m.useRef(void 0);
90
90
  G.current = y, K.current = b, m.useEffect(() => {
91
91
  v && !W.current && (async () => {
92
92
  if (J.current !== v) {
@@ -130,23 +130,23 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
130
130
  }
131
131
  }, [A, x]);
132
132
  m.useEffect(() => {
133
- if (!P && c && H) {
133
+ if (!P && a && H) {
134
134
  let e = !1;
135
135
  return (async () => {
136
136
  N(!0);
137
137
  try {
138
- let t = await Y(H);
139
- if (!t || typeof t != "string" || t.trim() === "") throw Error("Invalid image data: empty or null");
140
- if (!t.startsWith("data:")) throw Error("Invalid image data: not a valid data URL");
141
- let n = t.match(/^data:([^;]+);base64,(.+)$/);
142
- if (!n) throw Error("Invalid image data: malformed data URL format");
143
- let [, r, i] = n;
144
- if (!r.startsWith("image/")) throw Error(`Invalid image data: unsupported MIME type ${r}`);
145
- if (i.length < 10) throw Error("Invalid image data: base64 content too short");
146
- if (!/^[A-Za-z0-9+/]+=*$/.test(i)) throw Error("Invalid image data: corrupted base64 content");
138
+ let n = await Y(H);
139
+ if (!n || typeof n != "string" || n.trim() === "") throw Error("Invalid image data: empty or null");
140
+ if (!n.startsWith("data:")) throw Error("Invalid image data: not a valid data URL");
141
+ let r = n.match(/^data:([^;]+);base64,(.+)$/);
142
+ if (!r) throw Error("Invalid image data: malformed data URL format");
143
+ let [, i, a] = r;
144
+ if (!i.startsWith("image/")) throw Error(`Invalid image data: unsupported MIME type ${i}`);
145
+ if (a.length < 10) throw Error("Invalid image data: base64 content too short");
146
+ if (!/^[A-Za-z0-9+/]+=*$/.test(a)) throw Error("Invalid image data: corrupted base64 content");
147
147
  if (!e) {
148
- F(t);
149
- let e = f(H, "image/png");
148
+ F(n);
149
+ let e = t(H, "image/png");
150
150
  L(e.mimeType);
151
151
  }
152
152
  } catch (t) {
@@ -175,67 +175,67 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
175
175
  P,
176
176
  _,
177
177
  x,
178
- c
178
+ a
179
179
  ]);
180
- let X = m.useCallback(async (e, t, n) => {
181
- let r = await oe(n, e), i = o(r.type || `image/${n}`), a = O?.compessorUrl ?? O?.compressorUrl;
182
- if (i.startsWith("image/")) try {
183
- let e = await l(new File([r], t, { type: i }), {
180
+ let X = m.useCallback(async (t, n, r) => {
181
+ let i = await oe(r, t), a = c(i.type || `image/${r}`), o = O?.compessorUrl ?? O?.compressorUrl;
182
+ if (a.startsWith("image/")) try {
183
+ let t = await f(new File([i], n, { type: a }), {
184
184
  maxSizeMB: O?.compressMaxSize,
185
185
  maxWidthOrHeight: O?.compressMaxWidthOrHeight,
186
- mimeType: i,
187
- fileName: t,
188
- libURL: a,
189
- enableCompression: s(O, i)
186
+ mimeType: a,
187
+ fileName: n,
188
+ libURL: o,
189
+ enableCompression: e(O, a)
190
190
  });
191
- r = e, i = e.type;
191
+ i = t, a = t.type;
192
192
  } catch (e) {
193
193
  console.warn("Image preparation failed, using original:", e);
194
194
  }
195
195
  return {
196
- blob: r,
197
- mimeType: i,
198
- thumbnailDataUrl: await w(r)
196
+ blob: i,
197
+ mimeType: a,
198
+ thumbnailDataUrl: await w(i)
199
199
  };
200
- }, [O]), Z = m.useCallback(async (e, t, n, r) => {
201
- let o = r === "save" ? G.current : K.current;
200
+ }, [O]), Z = m.useCallback(async (e, t, r, a) => {
201
+ let o = a === "save" ? G.current : K.current;
202
202
  if (!H || !o) return;
203
203
  let s = typeof H == "object" && H ? H : null, c = null;
204
204
  try {
205
205
  N(!0);
206
- let { blob: i, mimeType: a, thumbnailDataUrl: s } = await X(e, t, n), l = {
206
+ let { blob: n, mimeType: i, thumbnailDataUrl: s } = await X(e, t, r), l = {
207
207
  ...H,
208
208
  thumbnail: s,
209
- size: i.size,
209
+ size: n.size,
210
210
  date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
211
- type: a,
211
+ type: i,
212
212
  folderId: H.folderId || "",
213
213
  name: H.name || t,
214
214
  extension: H.extension || (H.name || t).split(".").pop()?.toLowerCase() || ""
215
215
  };
216
216
  c = l;
217
217
  let u = await o(l, {
218
- blob: i,
219
- mimeType: a,
218
+ blob: n,
219
+ mimeType: i,
220
220
  thumbnail: s,
221
- mode: r
221
+ mode: a
222
222
  });
223
223
  if (u) return N(!1), u;
224
- throw Error(x(r === "saveCopy" ? "Failed to save image copy" : "Failed to save changes"));
224
+ throw Error(x(a === "saveCopy" ? "Failed to save image copy" : "Failed to save changes"));
225
225
  } catch (e) {
226
226
  console.error("Error saving:", e);
227
- let n = c ?? s;
227
+ let r = c ?? s;
228
228
  if (!e?.notificationShown) {
229
- let o = i(e), s = a(o?.code, x) ?? o?.message ?? x(r === "saveCopy" ? "Failed to save image copy" : "Error saving image");
229
+ let o = i(e), s = n(o?.code, x) ?? o?.message ?? x(a === "saveCopy" ? "Failed to save image copy" : "Error saving image");
230
230
  T.error({
231
- id: r === "saveCopy" ? "IMAGE_SAVE_COPY_FAILED" : "IMAGE_SAVE_FAILED",
231
+ id: a === "saveCopy" ? "IMAGE_SAVE_COPY_FAILED" : "IMAGE_SAVE_FAILED",
232
232
  message: s,
233
233
  placement: "bottomRight",
234
234
  data: {
235
- itemId: n?.id ?? void 0,
236
- itemName: n?.name ?? t,
237
- folderId: n?.folderId ?? null,
238
- thumbnail: n?.thumbnail
235
+ itemId: r?.id ?? void 0,
236
+ itemName: r?.name ?? t,
237
+ folderId: r?.folderId ?? null,
238
+ thumbnail: r?.thumbnail
239
239
  },
240
240
  innerException: e
241
241
  });
@@ -253,9 +253,9 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
253
253
  return;
254
254
  }
255
255
  q.current = e;
256
- let n = H.name || "edited-image", r = f(H, I);
256
+ let n = H.name || "edited-image", r = t(H, I);
257
257
  try {
258
- await S.tools?.export.save(n.replace(/\.[^/.]+$/, ""), r.pixieFormat, t.QUALITY);
258
+ await S.tools?.export.save(n.replace(/\.[^/.]+$/, ""), r.pixieFormat, s.QUALITY);
259
259
  } catch (t) {
260
260
  console.error("🎨 Error saving through the button:", t);
261
261
  try {
@@ -270,21 +270,21 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
270
270
  I,
271
271
  Z
272
272
  ]), $ = m.useCallback(async () => {
273
- if (!(!P || !c || !R || W.current)) try {
273
+ if (!(!P || !a || !R || W.current)) try {
274
274
  W.current = !0;
275
275
  let e = C.current, n = 0;
276
276
  for (; n < 20 && (e.clientWidth === 0 || e.clientHeight === 0);) await new Promise((e) => setTimeout(e, 50)), n++;
277
- let r = O?.locale ? O?.locale.replace("_", "-") : "en", i = matchMedia("(prefers-color-scheme: dark)").matches ? ee : d, a = O?.theme === "system" ? i : O?.theme, o = (O?.locale || D.language || "en").split("-")[0].split("_")[0], s = (D.getResourceBundle(o, "translation") || {}).pixie || {}, c = (e) => e.split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" "), l = {};
278
- Object.entries(s).forEach(([e, t]) => {
279
- let n = c(e);
280
- l[n] = t, l[e] = t;
277
+ let r = O?.locale ? O?.locale.replace("_", "-") : "en", i = matchMedia("(prefers-color-scheme: dark)").matches ? ee : u, a = O?.theme === "system" ? i : O?.theme, o = (O?.locale || D.language || "en").split("-")[0].split("_")[0], c = (D.getResourceBundle(o, "translation") || {}).pixie || {}, l = (e) => e.split(" ").map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" "), d = {};
278
+ Object.entries(c).forEach(([e, t]) => {
279
+ let n = l(e);
280
+ d[n] = t, d[e] = t;
281
281
  });
282
- let u = { [r]: l }, p = f(H, I), m = {
282
+ let f = { [r]: d }, p = t(H, I), m = {
283
283
  selector: "#pixie-editor",
284
284
  baseUrl: te(O?.baseUrl || "", O?.assetsUrl || "assets/image-editor"),
285
285
  image: P,
286
286
  activeLanguage: r,
287
- languages: u,
287
+ languages: f,
288
288
  ui: {
289
289
  activeTheme: a,
290
290
  mode: "inline",
@@ -326,7 +326,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
326
326
  tools: {
327
327
  export: {
328
328
  defaultFormat: p.pixieFormat,
329
- defaultQuality: t.QUALITY,
329
+ defaultQuality: s.QUALITY,
330
330
  defaultName: H?.name?.replace(/\.[^/.]+$/, "") || "image"
331
331
  },
332
332
  text: {
@@ -475,7 +475,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
475
475
  H,
476
476
  I,
477
477
  P,
478
- c,
478
+ a,
479
479
  R,
480
480
  O?.locale,
481
481
  O?.theme,
@@ -488,14 +488,14 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
488
488
  x
489
489
  ]);
490
490
  m.useEffect(() => {
491
- c && P && R && $();
491
+ a && P && R && $();
492
492
  }, [
493
- c,
493
+ a,
494
494
  P,
495
495
  R,
496
496
  $
497
497
  ]), m.useEffect(() => {
498
- if (!c) {
498
+ if (!a) {
499
499
  try {
500
500
  S.close();
501
501
  } catch (e) {
@@ -510,11 +510,11 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
510
510
  console.warn("Error closing Pixie when unmounting:", e);
511
511
  }
512
512
  };
513
- }, [c]);
513
+ }, [a]);
514
514
  let le = !!H?.id && O?.features?.enableUpdateFile !== !1;
515
515
  return /* @__PURE__ */ g(ne, {
516
516
  title: H?.name ? x("Editing: {{name}}", { name: H.name }) : x("Editing image"),
517
- open: c,
517
+ open: a,
518
518
  closeIcon: null,
519
519
  onCancel: _,
520
520
  afterOpenChange: (e) => z(e),
@@ -562,7 +562,7 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
562
562
  width: "100%",
563
563
  height: "100%"
564
564
  },
565
- children: [c && !B ? /* @__PURE__ */ g("div", {
565
+ children: [a && !B ? /* @__PURE__ */ g("div", {
566
566
  style: {
567
567
  position: "absolute",
568
568
  inset: 0,
@@ -594,4 +594,4 @@ var T = ({ visible: c, onClose: _, file: v, onSave: y, onSaveCopy: b }) => {
594
594
  //#endregion
595
595
  export { T as PixieEditor };
596
596
 
597
- //# sourceMappingURL=file-manager-PixieEditor-Doy__jUq.js.map
597
+ //# sourceMappingURL=file-manager-PixieEditor-D-Cv1Ieh.js.map