@mypixia/simplex-designer 2.1.0 → 2.1.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/index.cjs.js +8 -8
- package/dist/index.es.js +614 -608
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import _e, { useState as N, useRef as nt, useEffect as et, useMemo as re, forwardRef as Ye, useCallback as ot, useReducer as qe, useImperativeHandle as Ve } from "react";
|
|
2
|
+
import Xe from "qrcode";
|
|
3
|
+
import Je from "react-barcode";
|
|
4
4
|
import ae from "axios";
|
|
5
5
|
import './index_external.css';var Rt = { exports: {} }, Tt = {};
|
|
6
6
|
/**
|
|
@@ -13,23 +13,23 @@ import './index_external.css';var Rt = { exports: {} }, Tt = {};
|
|
|
13
13
|
* LICENSE file in the root directory of this source tree.
|
|
14
14
|
*/
|
|
15
15
|
var se;
|
|
16
|
-
function
|
|
16
|
+
function Ke() {
|
|
17
17
|
if (se) return Tt;
|
|
18
18
|
se = 1;
|
|
19
19
|
var d = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
|
|
20
|
-
function a(l, s,
|
|
21
|
-
var
|
|
22
|
-
if (
|
|
23
|
-
|
|
20
|
+
function a(l, s, h) {
|
|
21
|
+
var y = null;
|
|
22
|
+
if (h !== void 0 && (y = "" + h), s.key !== void 0 && (y = "" + s.key), "key" in s) {
|
|
23
|
+
h = {};
|
|
24
24
|
for (var c in s)
|
|
25
|
-
c !== "key" && (
|
|
26
|
-
} else
|
|
27
|
-
return s =
|
|
25
|
+
c !== "key" && (h[c] = s[c]);
|
|
26
|
+
} else h = s;
|
|
27
|
+
return s = h.ref, {
|
|
28
28
|
$$typeof: d,
|
|
29
29
|
type: l,
|
|
30
|
-
key:
|
|
30
|
+
key: y,
|
|
31
31
|
ref: s !== void 0 ? s : null,
|
|
32
|
-
props:
|
|
32
|
+
props: h
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
return Tt.Fragment = o, Tt.jsx = a, Tt.jsxs = a, Tt;
|
|
@@ -45,7 +45,7 @@ var jt = {};
|
|
|
45
45
|
* LICENSE file in the root directory of this source tree.
|
|
46
46
|
*/
|
|
47
47
|
var le;
|
|
48
|
-
function
|
|
48
|
+
function Ze() {
|
|
49
49
|
return le || (le = 1, process.env.NODE_ENV !== "production" && function() {
|
|
50
50
|
function d(m) {
|
|
51
51
|
if (m == null) return null;
|
|
@@ -125,10 +125,10 @@ function Ke() {
|
|
|
125
125
|
var m = Y.A;
|
|
126
126
|
return m === null ? null : m.getOwner();
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function h() {
|
|
129
129
|
return Error("react-stack-top-frame");
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function y(m) {
|
|
132
132
|
if (O.call(m, "key")) {
|
|
133
133
|
var A = Object.getOwnPropertyDescriptor(m, "key").get;
|
|
134
134
|
if (A && A.isReactWarning) return !1;
|
|
@@ -147,13 +147,13 @@ function Ke() {
|
|
|
147
147
|
configurable: !0
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function u() {
|
|
151
151
|
var m = d(this.type);
|
|
152
152
|
return it[m] || (it[m] = !0, console.error(
|
|
153
153
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
154
154
|
)), m = this.props.ref, m !== void 0 ? m : null;
|
|
155
155
|
}
|
|
156
|
-
function
|
|
156
|
+
function x(m, A, Q, _, Z, V, ht, H) {
|
|
157
157
|
return Q = V.ref, m = {
|
|
158
158
|
$$typeof: I,
|
|
159
159
|
type: m,
|
|
@@ -162,7 +162,7 @@ function Ke() {
|
|
|
162
162
|
_owner: Z
|
|
163
163
|
}, (Q !== void 0 ? Q : null) !== null ? Object.defineProperty(m, "ref", {
|
|
164
164
|
enumerable: !1,
|
|
165
|
-
get:
|
|
165
|
+
get: u
|
|
166
166
|
}) : Object.defineProperty(m, "ref", { enumerable: !1, value: null }), m._store = {}, Object.defineProperty(m._store, "validated", {
|
|
167
167
|
configurable: !1,
|
|
168
168
|
enumerable: !1,
|
|
@@ -200,10 +200,10 @@ function Ke() {
|
|
|
200
200
|
else C(P);
|
|
201
201
|
if (O.call(A, "key")) {
|
|
202
202
|
P = d(m);
|
|
203
|
-
var
|
|
203
|
+
var ct = Object.keys(A).filter(function(Dt) {
|
|
204
204
|
return Dt !== "key";
|
|
205
205
|
});
|
|
206
|
-
_ = 0 <
|
|
206
|
+
_ = 0 < ct.length ? "{key: someKey, " + ct.join(": ..., ") + ": ...}" : "{key: someKey}", j[P + _] || (ct = 0 < ct.length ? "{" + ct.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
207
207
|
`A props object containing a "key" prop is being spread into JSX:
|
|
208
208
|
let props = %s;
|
|
209
209
|
<%s {...props} />
|
|
@@ -212,11 +212,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
212
212
|
<%s key={someKey} {...props} />`,
|
|
213
213
|
_,
|
|
214
214
|
P,
|
|
215
|
-
|
|
215
|
+
ct,
|
|
216
216
|
P
|
|
217
217
|
), j[P + _] = !0);
|
|
218
218
|
}
|
|
219
|
-
if (P = null, Q !== void 0 && (a(Q), P = "" + Q),
|
|
219
|
+
if (P = null, Q !== void 0 && (a(Q), P = "" + Q), y(A) && (a(A.key), P = "" + A.key), "key" in A) {
|
|
220
220
|
Q = {};
|
|
221
221
|
for (var gt in A)
|
|
222
222
|
gt !== "key" && (Q[gt] = A[gt]);
|
|
@@ -224,7 +224,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
224
224
|
return P && c(
|
|
225
225
|
Q,
|
|
226
226
|
typeof m == "function" ? m.displayName || m.name || "Unknown" : m
|
|
227
|
-
),
|
|
227
|
+
), x(
|
|
228
228
|
m,
|
|
229
229
|
P,
|
|
230
230
|
V,
|
|
@@ -238,7 +238,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
238
238
|
function C(m) {
|
|
239
239
|
typeof m == "object" && m !== null && m.$$typeof === I && m._store && (m._store.validated = 1);
|
|
240
240
|
}
|
|
241
|
-
var p =
|
|
241
|
+
var p = _e, I = Symbol.for("react.transitional.element"), T = Symbol.for("react.portal"), w = Symbol.for("react.fragment"), z = Symbol.for("react.strict_mode"), E = Symbol.for("react.profiler"), S = Symbol.for("react.consumer"), $ = Symbol.for("react.context"), B = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), at = Symbol.for("react.suspense_list"), U = Symbol.for("react.memo"), ft = Symbol.for("react.lazy"), q = Symbol.for("react.activity"), rt = Symbol.for("react.client.reference"), Y = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, O = Object.prototype.hasOwnProperty, J = Array.isArray, st = console.createTask ? console.createTask : function() {
|
|
242
242
|
return null;
|
|
243
243
|
};
|
|
244
244
|
p = {
|
|
@@ -246,10 +246,10 @@ React keys must be passed directly to JSX without using spread:
|
|
|
246
246
|
return m();
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
-
var K, it = {},
|
|
249
|
+
var K, it = {}, M = p["react-stack-bottom-frame"].bind(
|
|
250
250
|
p,
|
|
251
|
-
|
|
252
|
-
)(), G = st(l(
|
|
251
|
+
h
|
|
252
|
+
)(), G = st(l(h)), j = {};
|
|
253
253
|
jt.Fragment = w, jt.jsx = function(m, A, Q, _, Z) {
|
|
254
254
|
var V = 1e4 > Y.recentlyCreatedOwnerStacks++;
|
|
255
255
|
return F(
|
|
@@ -259,7 +259,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
259
259
|
!1,
|
|
260
260
|
_,
|
|
261
261
|
Z,
|
|
262
|
-
V ? Error("react-stack-top-frame") :
|
|
262
|
+
V ? Error("react-stack-top-frame") : M,
|
|
263
263
|
V ? st(l(m)) : G
|
|
264
264
|
);
|
|
265
265
|
}, jt.jsxs = function(m, A, Q, _, Z) {
|
|
@@ -271,17 +271,17 @@ React keys must be passed directly to JSX without using spread:
|
|
|
271
271
|
!0,
|
|
272
272
|
_,
|
|
273
273
|
Z,
|
|
274
|
-
V ? Error("react-stack-top-frame") :
|
|
274
|
+
V ? Error("react-stack-top-frame") : M,
|
|
275
275
|
V ? st(l(m)) : G
|
|
276
276
|
);
|
|
277
277
|
};
|
|
278
278
|
}()), jt;
|
|
279
279
|
}
|
|
280
280
|
var ne;
|
|
281
|
-
function
|
|
282
|
-
return ne || (ne = 1, process.env.NODE_ENV === "production" ? Rt.exports =
|
|
281
|
+
function ti() {
|
|
282
|
+
return ne || (ne = 1, process.env.NODE_ENV === "production" ? Rt.exports = Ke() : Rt.exports = Ze()), Rt.exports;
|
|
283
283
|
}
|
|
284
|
-
var i =
|
|
284
|
+
var i = ti();
|
|
285
285
|
const Pt = {
|
|
286
286
|
business: {
|
|
287
287
|
name: "Business & Office",
|
|
@@ -378,27 +378,27 @@ const Pt = {
|
|
|
378
378
|
...o,
|
|
379
379
|
category: d.name
|
|
380
380
|
}))
|
|
381
|
-
),
|
|
381
|
+
), ei = (d) => de().filter(
|
|
382
382
|
(a) => a.name.toLowerCase().includes(d.toLowerCase()) || a.category.toLowerCase().includes(d.toLowerCase())
|
|
383
|
-
),
|
|
384
|
-
const [a, l] = N(!1), [s,
|
|
383
|
+
), ii = ({ onSelectIcon: d, disabled: o = !1 }) => {
|
|
384
|
+
const [a, l] = N(!1), [s, h] = N(""), [y, c] = N("all"), u = nt(null);
|
|
385
385
|
et(() => {
|
|
386
386
|
const p = (I) => {
|
|
387
|
-
|
|
387
|
+
u.current && !u.current.contains(I.target) && l(!1);
|
|
388
388
|
};
|
|
389
389
|
return document.addEventListener("mousedown", p), () => document.removeEventListener("mousedown", p);
|
|
390
390
|
}, []);
|
|
391
|
-
const
|
|
392
|
-
d(p), l(!1),
|
|
391
|
+
const x = (p) => {
|
|
392
|
+
d(p), l(!1), h("");
|
|
393
393
|
}, C = (() => {
|
|
394
394
|
let p = de();
|
|
395
|
-
if (s.trim() && (p =
|
|
396
|
-
const I = Pt[
|
|
395
|
+
if (s.trim() && (p = ei(s)), y !== "all") {
|
|
396
|
+
const I = Pt[y];
|
|
397
397
|
I && (p = p.filter((T) => T.category === I.name));
|
|
398
398
|
}
|
|
399
399
|
return p;
|
|
400
400
|
})();
|
|
401
|
-
return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref:
|
|
401
|
+
return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref: u, children: [
|
|
402
402
|
/* @__PURE__ */ i.jsxs(
|
|
403
403
|
"button",
|
|
404
404
|
{
|
|
@@ -421,14 +421,14 @@ const Pt = {
|
|
|
421
421
|
type: "text",
|
|
422
422
|
placeholder: "Search icons...",
|
|
423
423
|
value: s,
|
|
424
|
-
onChange: (p) =>
|
|
424
|
+
onChange: (p) => h(p.target.value),
|
|
425
425
|
className: "icon-search"
|
|
426
426
|
}
|
|
427
427
|
),
|
|
428
428
|
/* @__PURE__ */ i.jsxs(
|
|
429
429
|
"select",
|
|
430
430
|
{
|
|
431
|
-
value:
|
|
431
|
+
value: y,
|
|
432
432
|
onChange: (p) => c(p.target.value),
|
|
433
433
|
className: "category-select",
|
|
434
434
|
children: [
|
|
@@ -442,7 +442,7 @@ const Pt = {
|
|
|
442
442
|
"button",
|
|
443
443
|
{
|
|
444
444
|
className: "icon-item",
|
|
445
|
-
onClick: () =>
|
|
445
|
+
onClick: () => x(p),
|
|
446
446
|
title: `${p.name} (${p.category})`,
|
|
447
447
|
children: [
|
|
448
448
|
/* @__PURE__ */ i.jsx("span", { className: "icon-symbol", children: p.symbol }),
|
|
@@ -458,11 +458,11 @@ const Pt = {
|
|
|
458
458
|
] }) })
|
|
459
459
|
] })
|
|
460
460
|
] });
|
|
461
|
-
},
|
|
462
|
-
const [s,
|
|
461
|
+
}, oi = ({ isOpen: d, onClose: o, onAddQRCode: a, theme: l }) => {
|
|
462
|
+
const [s, h] = N(""), [y, c] = N(""), [u, x] = N(200), [F, C] = N("M"), p = () => {
|
|
463
463
|
if (!s.trim()) return;
|
|
464
464
|
const w = {
|
|
465
|
-
width:
|
|
465
|
+
width: u,
|
|
466
466
|
errorCorrectionLevel: F,
|
|
467
467
|
type: "image/png",
|
|
468
468
|
quality: 0.92,
|
|
@@ -472,7 +472,7 @@ const Pt = {
|
|
|
472
472
|
light: "#FFFFFF"
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
|
-
|
|
475
|
+
Xe.toDataURL(s, w, (z, E) => {
|
|
476
476
|
if (z) {
|
|
477
477
|
console.error("QR Code generation error:", z);
|
|
478
478
|
return;
|
|
@@ -480,23 +480,23 @@ const Pt = {
|
|
|
480
480
|
c(E);
|
|
481
481
|
});
|
|
482
482
|
}, I = () => {
|
|
483
|
-
if (!
|
|
483
|
+
if (!y) return;
|
|
484
484
|
const w = new Image();
|
|
485
485
|
w.onload = () => {
|
|
486
486
|
a({
|
|
487
487
|
type: "qrcode",
|
|
488
|
-
src:
|
|
488
|
+
src: y,
|
|
489
489
|
data: s,
|
|
490
|
-
width:
|
|
491
|
-
height:
|
|
490
|
+
width: u,
|
|
491
|
+
height: u,
|
|
492
492
|
x: 100,
|
|
493
493
|
y: 100,
|
|
494
494
|
imageObject: w
|
|
495
495
|
// Store the loaded image object
|
|
496
496
|
}), T();
|
|
497
|
-
}, w.src =
|
|
497
|
+
}, w.src = y;
|
|
498
498
|
}, T = () => {
|
|
499
|
-
|
|
499
|
+
h(""), c(""), o();
|
|
500
500
|
};
|
|
501
501
|
return d ? /* @__PURE__ */ i.jsx("div", { className: "qr-modal-overlay", onClick: T, children: /* @__PURE__ */ i.jsxs("div", { className: "qr-modal-content", onClick: (w) => w.stopPropagation(), children: [
|
|
502
502
|
/* @__PURE__ */ i.jsxs("div", { className: "qr-modal-header", children: [
|
|
@@ -519,7 +519,7 @@ const Pt = {
|
|
|
519
519
|
{
|
|
520
520
|
id: "qr-data",
|
|
521
521
|
value: s,
|
|
522
|
-
onChange: (w) =>
|
|
522
|
+
onChange: (w) => h(w.target.value),
|
|
523
523
|
placeholder: "https://example.com or any text...",
|
|
524
524
|
rows: 3
|
|
525
525
|
}
|
|
@@ -533,8 +533,8 @@ const Pt = {
|
|
|
533
533
|
{
|
|
534
534
|
type: "number",
|
|
535
535
|
id: "qr-size",
|
|
536
|
-
value:
|
|
537
|
-
onChange: (w) =>
|
|
536
|
+
value: u,
|
|
537
|
+
onChange: (w) => x(Math.max(50, Math.min(500, parseInt(w.target.value) || 200))),
|
|
538
538
|
min: "50",
|
|
539
539
|
max: "500"
|
|
540
540
|
}
|
|
@@ -567,9 +567,9 @@ const Pt = {
|
|
|
567
567
|
children: "Generate QR Code"
|
|
568
568
|
}
|
|
569
569
|
) }),
|
|
570
|
-
|
|
570
|
+
y && /* @__PURE__ */ i.jsxs("div", { className: "qr-preview", children: [
|
|
571
571
|
/* @__PURE__ */ i.jsx("h4", { children: "Preview" }),
|
|
572
|
-
/* @__PURE__ */ i.jsx("div", { className: "qr-preview-container", children: /* @__PURE__ */ i.jsx("img", { src:
|
|
572
|
+
/* @__PURE__ */ i.jsx("div", { className: "qr-preview-container", children: /* @__PURE__ */ i.jsx("img", { src: y, alt: "QR Code Preview" }) }),
|
|
573
573
|
/* @__PURE__ */ i.jsx(
|
|
574
574
|
"button",
|
|
575
575
|
{
|
|
@@ -585,8 +585,8 @@ const Pt = {
|
|
|
585
585
|
] })
|
|
586
586
|
] })
|
|
587
587
|
] }) }) : null;
|
|
588
|
-
},
|
|
589
|
-
const [s,
|
|
588
|
+
}, ri = ({ isOpen: d, onClose: o, onAddBarcode: a, theme: l }) => {
|
|
589
|
+
const [s, h] = N(""), [y, c] = N("CODE128"), [u, x] = N(null), [F, C] = N(2), [p, I] = N(100), [T, w] = N(20), [z, E] = N("center"), [S, $] = N("bottom"), [B, W] = N(10), at = nt(null), U = [
|
|
590
590
|
{ value: "CODE128", label: "CODE128 (Most Common)" },
|
|
591
591
|
{ value: "EAN13", label: "EAN-13 (European Article Number)" },
|
|
592
592
|
{ value: "EAN8", label: "EAN-8 (Short EAN)" },
|
|
@@ -599,11 +599,11 @@ const Pt = {
|
|
|
599
599
|
], ft = () => {
|
|
600
600
|
if (s.trim())
|
|
601
601
|
try {
|
|
602
|
-
|
|
603
|
-
|
|
602
|
+
x(/* @__PURE__ */ i.jsx(
|
|
603
|
+
Je,
|
|
604
604
|
{
|
|
605
605
|
value: s,
|
|
606
|
-
format:
|
|
606
|
+
format: y,
|
|
607
607
|
width: F,
|
|
608
608
|
height: p,
|
|
609
609
|
fontSize: T,
|
|
@@ -619,25 +619,25 @@ const Pt = {
|
|
|
619
619
|
}
|
|
620
620
|
}, q = () => {
|
|
621
621
|
var O, J, st, K;
|
|
622
|
-
if (!(!
|
|
622
|
+
if (!(!u || !at.current))
|
|
623
623
|
try {
|
|
624
624
|
const it = at.current.querySelector("svg");
|
|
625
625
|
if (!it) {
|
|
626
626
|
console.error("No SVG element found in barcode");
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
|
-
const
|
|
630
|
-
|
|
629
|
+
const M = document.createElement("canvas"), G = M.getContext("2d"), j = it.getBoundingClientRect(), m = ((J = (O = it.width) == null ? void 0 : O.baseVal) == null ? void 0 : J.value) || j.width || 200, A = ((K = (st = it.height) == null ? void 0 : st.baseVal) == null ? void 0 : K.value) || j.height || 100;
|
|
630
|
+
M.width = m, M.height = A;
|
|
631
631
|
const Q = new XMLSerializer().serializeToString(it), _ = new Blob([Q], { type: "image/svg+xml;charset=utf-8" }), Z = URL.createObjectURL(_), V = new Image();
|
|
632
632
|
V.onload = () => {
|
|
633
633
|
G.drawImage(V, 0, 0);
|
|
634
|
-
const ht =
|
|
634
|
+
const ht = M.toDataURL("image/png"), H = new Image();
|
|
635
635
|
H.onload = () => {
|
|
636
636
|
a({
|
|
637
637
|
type: "barcode",
|
|
638
638
|
src: ht,
|
|
639
639
|
data: s,
|
|
640
|
-
format:
|
|
640
|
+
format: y,
|
|
641
641
|
width: m,
|
|
642
642
|
height: A,
|
|
643
643
|
x: 100,
|
|
@@ -650,7 +650,7 @@ const Pt = {
|
|
|
650
650
|
console.error("Error adding barcode to canvas:", it), alert("Failed to add barcode to canvas. Please try again.");
|
|
651
651
|
}
|
|
652
652
|
}, rt = () => {
|
|
653
|
-
|
|
653
|
+
h(""), x(null), c("CODE128"), C(2), I(100), w(20), o();
|
|
654
654
|
}, Y = (O) => ({
|
|
655
655
|
CODE128: "Supports all ASCII characters. Most versatile format.",
|
|
656
656
|
EAN13: "Requires exactly 12 digits (13th is checksum). Used for retail products.",
|
|
@@ -684,7 +684,7 @@ const Pt = {
|
|
|
684
684
|
type: "text",
|
|
685
685
|
id: "barcode-data",
|
|
686
686
|
value: s,
|
|
687
|
-
onChange: (O) =>
|
|
687
|
+
onChange: (O) => h(O.target.value),
|
|
688
688
|
placeholder: "Enter your data..."
|
|
689
689
|
}
|
|
690
690
|
)
|
|
@@ -695,12 +695,12 @@ const Pt = {
|
|
|
695
695
|
"select",
|
|
696
696
|
{
|
|
697
697
|
id: "barcode-format",
|
|
698
|
-
value:
|
|
698
|
+
value: y,
|
|
699
699
|
onChange: (O) => c(O.target.value),
|
|
700
700
|
children: U.map((O) => /* @__PURE__ */ i.jsx("option", { value: O.value, children: O.label }, O.value))
|
|
701
701
|
}
|
|
702
702
|
),
|
|
703
|
-
/* @__PURE__ */ i.jsx("small", { className: "format-description", children: Y(
|
|
703
|
+
/* @__PURE__ */ i.jsx("small", { className: "format-description", children: Y(y) })
|
|
704
704
|
] }),
|
|
705
705
|
/* @__PURE__ */ i.jsxs("div", { className: "barcode-options", children: [
|
|
706
706
|
/* @__PURE__ */ i.jsxs("div", { className: "barcode-form-group", children: [
|
|
@@ -783,9 +783,9 @@ const Pt = {
|
|
|
783
783
|
children: "Generate Barcode"
|
|
784
784
|
}
|
|
785
785
|
) }),
|
|
786
|
-
|
|
786
|
+
u && /* @__PURE__ */ i.jsxs("div", { className: "barcode-preview", children: [
|
|
787
787
|
/* @__PURE__ */ i.jsx("h4", { children: "Preview" }),
|
|
788
|
-
/* @__PURE__ */ i.jsx("div", { className: "barcode-preview-container", ref: at, children:
|
|
788
|
+
/* @__PURE__ */ i.jsx("div", { className: "barcode-preview-container", ref: at, children: u }),
|
|
789
789
|
/* @__PURE__ */ i.jsx(
|
|
790
790
|
"button",
|
|
791
791
|
{
|
|
@@ -801,7 +801,7 @@ const Pt = {
|
|
|
801
801
|
] })
|
|
802
802
|
] })
|
|
803
803
|
] }) }) : null;
|
|
804
|
-
},
|
|
804
|
+
}, ai = ({ theme: d }) => /* @__PURE__ */ i.jsxs("div", { className: "premium-feature-container", style: {
|
|
805
805
|
padding: "20px",
|
|
806
806
|
backgroundColor: "#f8f9fa",
|
|
807
807
|
borderRadius: "8px",
|
|
@@ -864,40 +864,40 @@ const Pt = {
|
|
|
864
864
|
100% { transform: rotate(360deg); }
|
|
865
865
|
}
|
|
866
866
|
` })
|
|
867
|
-
] }),
|
|
868
|
-
const [
|
|
869
|
-
|
|
870
|
-
const [S, $] = N(!1), [B, W] = N(!1), [at, U] = N(!1), ft = `${
|
|
867
|
+
] }), si = ({ isOpen: d, onClose: o, onAddSticker: a, theme: l, apiKey: s, apiEndpoint: h }) => {
|
|
868
|
+
const [y, c] = N([]), [u, x] = N(!1), [F, C] = N(null), [p, I] = N(""), [T, w] = N(""), [z, E] = N({});
|
|
869
|
+
nt(null);
|
|
870
|
+
const [S, $] = N(!1), [B, W] = N(!1), [at, U] = N(!1), ft = `${h}/api/v1/designer`;
|
|
871
871
|
et(() => {
|
|
872
872
|
d && s && q();
|
|
873
873
|
}, [d, s]);
|
|
874
874
|
const q = async () => {
|
|
875
|
-
const
|
|
876
|
-
|
|
875
|
+
const M = sessionStorage.getItem("apc_x_sub_status");
|
|
876
|
+
M === "active" ? ($(!0), W(!0), Y()) : M === "inactive" ? ($(!1), W(!0)) : (U(!0), await rt());
|
|
877
877
|
}, rt = async () => {
|
|
878
878
|
if (!s) {
|
|
879
879
|
$(!1), W(!0), U(!1);
|
|
880
880
|
return;
|
|
881
881
|
}
|
|
882
|
-
const
|
|
882
|
+
const M = `${ft}/get-subscription-status/${s}`;
|
|
883
883
|
try {
|
|
884
|
-
(await ae.get(
|
|
884
|
+
(await ae.get(M)).data.object === "active" ? (sessionStorage.setItem("apc_x_sub_status", "active"), $(!0), Y()) : (sessionStorage.setItem("apc_x_sub_status", "inactive"), $(!1));
|
|
885
885
|
} catch (G) {
|
|
886
886
|
console.error("Subscription check failed:", G), sessionStorage.setItem("apc_x_sub_status", "inactive"), $(!1);
|
|
887
887
|
} finally {
|
|
888
888
|
U(!1), W(!0);
|
|
889
889
|
}
|
|
890
890
|
}, Y = async () => {
|
|
891
|
-
const
|
|
892
|
-
if (
|
|
891
|
+
const M = sessionStorage.getItem("apc_stickers");
|
|
892
|
+
if (M)
|
|
893
893
|
try {
|
|
894
|
-
const G = JSON.parse(
|
|
894
|
+
const G = JSON.parse(M);
|
|
895
895
|
c(G);
|
|
896
896
|
return;
|
|
897
897
|
} catch {
|
|
898
898
|
console.warn("Failed to parse cached stickers, fetching fresh data");
|
|
899
899
|
}
|
|
900
|
-
|
|
900
|
+
x(!0), C(null);
|
|
901
901
|
try {
|
|
902
902
|
const G = await ae.get(`${ft}/get-stickers`);
|
|
903
903
|
if (G.data && G.data.object && G.data.object.contents) {
|
|
@@ -908,43 +908,43 @@ const Pt = {
|
|
|
908
908
|
} catch (G) {
|
|
909
909
|
console.error("Error fetching stickers:", G), C("Failed to load stickers. Please try again.");
|
|
910
910
|
} finally {
|
|
911
|
-
|
|
911
|
+
x(!1);
|
|
912
912
|
}
|
|
913
|
-
}, O = (
|
|
913
|
+
}, O = (M, G) => {
|
|
914
914
|
a({
|
|
915
915
|
type: "sticker",
|
|
916
|
-
src:
|
|
916
|
+
src: M,
|
|
917
917
|
name: G,
|
|
918
918
|
width: 100,
|
|
919
919
|
height: 100,
|
|
920
920
|
x: 100,
|
|
921
921
|
y: 100
|
|
922
922
|
}), o();
|
|
923
|
-
}, J = (
|
|
923
|
+
}, J = (M) => {
|
|
924
924
|
E((G) => ({
|
|
925
925
|
...G,
|
|
926
|
-
[
|
|
926
|
+
[M]: !G[M]
|
|
927
927
|
}));
|
|
928
|
-
}, st = (
|
|
928
|
+
}, st = (M) => {
|
|
929
929
|
const G = {};
|
|
930
|
-
return
|
|
930
|
+
return M.forEach((j) => {
|
|
931
931
|
const m = j.name.split("/");
|
|
932
932
|
let A = G;
|
|
933
933
|
m.forEach((Q, _) => {
|
|
934
934
|
A[Q] || (A[Q] = _ === m.length - 1 ? j : {}), A = A[Q];
|
|
935
935
|
});
|
|
936
936
|
}), G;
|
|
937
|
-
}, K = (
|
|
937
|
+
}, K = (M, G = "", j = 0) => /* @__PURE__ */ i.jsx("div", { className: "sticker-tree-level", style: { paddingLeft: `${j * 15}px` }, children: Object.keys(M).map((m) => {
|
|
938
938
|
const A = `${G}/${m}`, Q = z[A];
|
|
939
|
-
return
|
|
939
|
+
return M[m].type === "image" ? !T || m.toLowerCase().includes(T.toLowerCase()) ? /* @__PURE__ */ i.jsx(
|
|
940
940
|
"div",
|
|
941
941
|
{
|
|
942
942
|
className: "sticker-item",
|
|
943
|
-
onClick: () => O(
|
|
943
|
+
onClick: () => O(M[m].url, m),
|
|
944
944
|
children: /* @__PURE__ */ i.jsx("div", { className: "sticker-preview", children: /* @__PURE__ */ i.jsx(
|
|
945
945
|
"img",
|
|
946
946
|
{
|
|
947
|
-
src:
|
|
947
|
+
src: M[m].url,
|
|
948
948
|
alt: m,
|
|
949
949
|
loading: "lazy",
|
|
950
950
|
onError: (Z) => {
|
|
@@ -966,12 +966,12 @@ const Pt = {
|
|
|
966
966
|
]
|
|
967
967
|
}
|
|
968
968
|
),
|
|
969
|
-
Q && K(
|
|
969
|
+
Q && K(M[m], A, j + 1)
|
|
970
970
|
] }, A);
|
|
971
|
-
}) }), it =
|
|
972
|
-
(
|
|
971
|
+
}) }), it = y.filter(
|
|
972
|
+
(M) => !T || M.name.toLowerCase().includes(T.toLowerCase())
|
|
973
973
|
);
|
|
974
|
-
return d ? /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-content", onClick: (
|
|
974
|
+
return d ? /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-content", onClick: (M) => M.stopPropagation(), children: [
|
|
975
975
|
/* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-header", children: [
|
|
976
976
|
/* @__PURE__ */ i.jsx("h3", { children: "Stickers" }),
|
|
977
977
|
/* @__PURE__ */ i.jsx(
|
|
@@ -986,7 +986,7 @@ const Pt = {
|
|
|
986
986
|
] }),
|
|
987
987
|
/* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-body", children: [
|
|
988
988
|
at && /* @__PURE__ */ i.jsx(ce, {}),
|
|
989
|
-
!S && !at && B && /* @__PURE__ */ i.jsx(
|
|
989
|
+
!S && !at && B && /* @__PURE__ */ i.jsx(ai, { theme: l }),
|
|
990
990
|
S && B && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
991
991
|
/* @__PURE__ */ i.jsx("div", { className: "sticker-modal-controls", children: /* @__PURE__ */ i.jsx("div", { className: "search-container", children: /* @__PURE__ */ i.jsx(
|
|
992
992
|
"input",
|
|
@@ -994,20 +994,20 @@ const Pt = {
|
|
|
994
994
|
type: "text",
|
|
995
995
|
placeholder: "Search stickers...",
|
|
996
996
|
value: T,
|
|
997
|
-
onChange: (
|
|
997
|
+
onChange: (M) => w(M.target.value),
|
|
998
998
|
className: "sticker-search"
|
|
999
999
|
}
|
|
1000
1000
|
) }) }),
|
|
1001
|
-
|
|
1001
|
+
u && /* @__PURE__ */ i.jsx(ce, {}),
|
|
1002
1002
|
F && /* @__PURE__ */ i.jsxs("div", { className: "sticker-error", children: [
|
|
1003
1003
|
/* @__PURE__ */ i.jsx("p", { children: F }),
|
|
1004
1004
|
/* @__PURE__ */ i.jsx("button", { onClick: Y, children: "Retry" })
|
|
1005
1005
|
] }),
|
|
1006
|
-
!
|
|
1006
|
+
!u && !F && y.length > 0 && /* @__PURE__ */ i.jsx("div", { className: "sticker-grid", children: K(st(it)) })
|
|
1007
1007
|
] })
|
|
1008
1008
|
] })
|
|
1009
1009
|
] }) }) : null;
|
|
1010
|
-
},
|
|
1010
|
+
}, li = [
|
|
1011
1011
|
// FLORAL DESIGNS (40 items)
|
|
1012
1012
|
{
|
|
1013
1013
|
id: 1,
|
|
@@ -2559,10 +2559,10 @@ const Pt = {
|
|
|
2559
2559
|
category: "Geometric",
|
|
2560
2560
|
description: "Complex mandala flower pattern"
|
|
2561
2561
|
}
|
|
2562
|
-
],
|
|
2563
|
-
const [
|
|
2562
|
+
], ni = ({ isOpen: d, onClose: o, onAddEmbroidery: a, theme: l, apiKey: s, apiEndpoint: h }) => {
|
|
2563
|
+
const [y, c] = N([]), [u, x] = N(!1), [F, C] = N(null), [p, I] = N(""), [T, w] = N("All"), z = nt(null), E = ["All", "Floral", "Nature", "Geometric", "Traditional", "Sports", "Hobbies", "Food", "Symbols", "Holiday", "Text"];
|
|
2564
2564
|
et(() => {
|
|
2565
|
-
d && c(
|
|
2565
|
+
d && c(li);
|
|
2566
2566
|
}, [d]);
|
|
2567
2567
|
const S = (B) => {
|
|
2568
2568
|
a({
|
|
@@ -2576,7 +2576,7 @@ const Pt = {
|
|
|
2576
2576
|
x: 100,
|
|
2577
2577
|
y: 100
|
|
2578
2578
|
}), o();
|
|
2579
|
-
}, $ =
|
|
2579
|
+
}, $ = y.filter((B) => {
|
|
2580
2580
|
const W = !p || B.name.toLowerCase().includes(p.toLowerCase()) || B.description.toLowerCase().includes(p.toLowerCase()), at = T === "All" || B.category === T;
|
|
2581
2581
|
return W && at;
|
|
2582
2582
|
});
|
|
@@ -2624,12 +2624,12 @@ const Pt = {
|
|
|
2624
2624
|
] })
|
|
2625
2625
|
] }),
|
|
2626
2626
|
/* @__PURE__ */ i.jsxs("div", { className: "embroidery-modal-body", children: [
|
|
2627
|
-
|
|
2627
|
+
u && /* @__PURE__ */ i.jsxs("div", { className: "embroidery-loading", children: [
|
|
2628
2628
|
/* @__PURE__ */ i.jsx("div", { className: "loading-spinner" }),
|
|
2629
2629
|
/* @__PURE__ */ i.jsx("p", { children: "Loading embroidery designs..." })
|
|
2630
2630
|
] }),
|
|
2631
2631
|
F && /* @__PURE__ */ i.jsx("div", { className: "embroidery-error", children: /* @__PURE__ */ i.jsx("p", { children: F }) }),
|
|
2632
|
-
!
|
|
2632
|
+
!u && !F && /* @__PURE__ */ i.jsx("div", { className: "embroidery-grid", children: $.map((B) => /* @__PURE__ */ i.jsxs(
|
|
2633
2633
|
"div",
|
|
2634
2634
|
{
|
|
2635
2635
|
className: "embroidery-item",
|
|
@@ -2655,7 +2655,7 @@ const Pt = {
|
|
|
2655
2655
|
},
|
|
2656
2656
|
B.id
|
|
2657
2657
|
)) }),
|
|
2658
|
-
!
|
|
2658
|
+
!u && !F && $.length === 0 && /* @__PURE__ */ i.jsx("div", { className: "no-embroideries", children: /* @__PURE__ */ i.jsx("p", { children: "No embroidery designs found matching your search." }) })
|
|
2659
2659
|
] }),
|
|
2660
2660
|
/* @__PURE__ */ i.jsx("div", { className: "embroidery-modal-footer", children: /* @__PURE__ */ i.jsxs("div", { className: "embroidery-disclaimer", children: [
|
|
2661
2661
|
/* @__PURE__ */ i.jsx("span", { className: "disclaimer-icon", children: "ℹ️" }),
|
|
@@ -4601,17 +4601,17 @@ const Pt = {
|
|
|
4601
4601
|
fill: "#8B0000",
|
|
4602
4602
|
textAlign: "center"
|
|
4603
4603
|
}
|
|
4604
|
-
],
|
|
4605
|
-
const [s,
|
|
4604
|
+
], ci = ({ isOpen: d, onClose: o, onAddText: a, theme: l }) => {
|
|
4605
|
+
const [s, h] = N(""), [y, c] = N("All"), u = re(() => {
|
|
4606
4606
|
const p = Nt.reduce((I, T) => (I[T.category] = (I[T.category] || 0) + 1, I), {});
|
|
4607
4607
|
return [
|
|
4608
4608
|
{ name: "All", count: Nt.length },
|
|
4609
4609
|
...Object.entries(p).map(([I, T]) => ({ name: I, count: T }))
|
|
4610
4610
|
];
|
|
4611
|
-
}, [Nt]),
|
|
4612
|
-
const I = !s || p.text.toLowerCase().includes(s.toLowerCase()) || p.category.toLowerCase().includes(s.toLowerCase()), T =
|
|
4611
|
+
}, [Nt]), x = re(() => Nt.filter((p) => {
|
|
4612
|
+
const I = !s || p.text.toLowerCase().includes(s.toLowerCase()) || p.category.toLowerCase().includes(s.toLowerCase()), T = y === "All" || p.category === y;
|
|
4613
4613
|
return I && T;
|
|
4614
|
-
}), [Nt, s,
|
|
4614
|
+
}), [Nt, s, y]), F = (p) => {
|
|
4615
4615
|
const I = {
|
|
4616
4616
|
...p,
|
|
4617
4617
|
x: 100,
|
|
@@ -4640,14 +4640,14 @@ const Pt = {
|
|
|
4640
4640
|
type: "text",
|
|
4641
4641
|
placeholder: "Search templates...",
|
|
4642
4642
|
value: s,
|
|
4643
|
-
onChange: (p) =>
|
|
4643
|
+
onChange: (p) => h(p.target.value),
|
|
4644
4644
|
className: "search-input"
|
|
4645
4645
|
}
|
|
4646
4646
|
) }),
|
|
4647
|
-
/* @__PURE__ */ i.jsx("div", { className: "category-tabs", children:
|
|
4647
|
+
/* @__PURE__ */ i.jsx("div", { className: "category-tabs", children: u.map((p) => /* @__PURE__ */ i.jsxs(
|
|
4648
4648
|
"button",
|
|
4649
4649
|
{
|
|
4650
|
-
className: `category-tab ${
|
|
4650
|
+
className: `category-tab ${y === p.name ? "active" : ""}`,
|
|
4651
4651
|
onClick: () => c(p.name),
|
|
4652
4652
|
children: [
|
|
4653
4653
|
p.name,
|
|
@@ -4666,7 +4666,7 @@ const Pt = {
|
|
|
4666
4666
|
/* @__PURE__ */ i.jsx("div", { className: "custom-icon", children: "✏️" }),
|
|
4667
4667
|
/* @__PURE__ */ i.jsx("div", { className: "custom-label", children: "Create Custom Text" })
|
|
4668
4668
|
] }) }),
|
|
4669
|
-
|
|
4669
|
+
x.map((p) => /* @__PURE__ */ i.jsxs(
|
|
4670
4670
|
"div",
|
|
4671
4671
|
{
|
|
4672
4672
|
className: "template-item",
|
|
@@ -4701,23 +4701,23 @@ const Pt = {
|
|
|
4701
4701
|
))
|
|
4702
4702
|
] }),
|
|
4703
4703
|
/* @__PURE__ */ i.jsx("div", { className: "modal-footer", children: /* @__PURE__ */ i.jsxs("div", { className: "results-count", children: [
|
|
4704
|
-
|
|
4704
|
+
x.length,
|
|
4705
4705
|
" template",
|
|
4706
|
-
|
|
4706
|
+
x.length !== 1 ? "s" : "",
|
|
4707
4707
|
" found"
|
|
4708
4708
|
] }) })
|
|
4709
4709
|
] }) }) : null;
|
|
4710
|
-
},
|
|
4710
|
+
}, di = ({
|
|
4711
4711
|
onAddElement: d,
|
|
4712
4712
|
onDeleteElement: o,
|
|
4713
4713
|
onDuplicateElement: a,
|
|
4714
4714
|
onUndo: l,
|
|
4715
4715
|
onRedo: s,
|
|
4716
|
-
onToggleGrid:
|
|
4717
|
-
onToggleRulers:
|
|
4716
|
+
onToggleGrid: h,
|
|
4717
|
+
onToggleRulers: y,
|
|
4718
4718
|
onToggleSnap: c,
|
|
4719
|
-
onImageUpload:
|
|
4720
|
-
canUndo:
|
|
4719
|
+
onImageUpload: u,
|
|
4720
|
+
canUndo: x,
|
|
4721
4721
|
canRedo: F,
|
|
4722
4722
|
showGrid: C,
|
|
4723
4723
|
showRulers: p,
|
|
@@ -4728,9 +4728,9 @@ const Pt = {
|
|
|
4728
4728
|
apiKey: E,
|
|
4729
4729
|
apiEndpoint: S
|
|
4730
4730
|
}) => {
|
|
4731
|
-
const [$, B] = N(!1), [W, at] = N(!1), [U, ft] = N(!1), [q, rt] = N(!1), [Y, O] = N(!1), [J, st] = N(!1), [K, it] = N(!1),
|
|
4732
|
-
const
|
|
4733
|
-
|
|
4731
|
+
const [$, B] = N(!1), [W, at] = N(!1), [U, ft] = N(!1), [q, rt] = N(!1), [Y, O] = N(!1), [J, st] = N(!1), [K, it] = N(!1), M = (P) => {
|
|
4732
|
+
const ct = P.target.files[0];
|
|
4733
|
+
ct && ct.type.startsWith("image/") && u(ct), P.target.value = "";
|
|
4734
4734
|
}, G = (P) => {
|
|
4735
4735
|
d("icon", {
|
|
4736
4736
|
iconData: P,
|
|
@@ -4747,8 +4747,8 @@ const Pt = {
|
|
|
4747
4747
|
d("sticker", P);
|
|
4748
4748
|
}, Q = (P) => {
|
|
4749
4749
|
d("embroidery", P);
|
|
4750
|
-
}, _ = (P,
|
|
4751
|
-
d(P,
|
|
4750
|
+
}, _ = (P, ct) => {
|
|
4751
|
+
d(P, ct);
|
|
4752
4752
|
}, Z = () => {
|
|
4753
4753
|
st(!J), it(!1);
|
|
4754
4754
|
}, V = () => {
|
|
@@ -4766,7 +4766,7 @@ const Pt = {
|
|
|
4766
4766
|
{
|
|
4767
4767
|
className: "toolbar-btn compact",
|
|
4768
4768
|
onClick: l,
|
|
4769
|
-
disabled: !
|
|
4769
|
+
disabled: !x || z,
|
|
4770
4770
|
title: "Undo (Ctrl+Z)",
|
|
4771
4771
|
children: [
|
|
4772
4772
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "↶" }),
|
|
@@ -4890,13 +4890,13 @@ const Pt = {
|
|
|
4890
4890
|
{
|
|
4891
4891
|
type: "file",
|
|
4892
4892
|
accept: "image/*",
|
|
4893
|
-
onChange:
|
|
4893
|
+
onChange: M,
|
|
4894
4894
|
disabled: z
|
|
4895
4895
|
}
|
|
4896
4896
|
)
|
|
4897
4897
|
] }),
|
|
4898
4898
|
/* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
|
|
4899
|
-
/* @__PURE__ */ i.jsx(
|
|
4899
|
+
/* @__PURE__ */ i.jsx(ii, { onSelectIcon: G, theme: w, disabled: z }),
|
|
4900
4900
|
/* @__PURE__ */ i.jsxs(
|
|
4901
4901
|
"button",
|
|
4902
4902
|
{
|
|
@@ -4989,7 +4989,7 @@ const Pt = {
|
|
|
4989
4989
|
"button",
|
|
4990
4990
|
{
|
|
4991
4991
|
className: `toolbar-btn compact ${C ? "active" : ""}`,
|
|
4992
|
-
onClick:
|
|
4992
|
+
onClick: h,
|
|
4993
4993
|
title: "Toggle Grid",
|
|
4994
4994
|
children: [
|
|
4995
4995
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "⚏" }),
|
|
@@ -5001,7 +5001,7 @@ const Pt = {
|
|
|
5001
5001
|
"button",
|
|
5002
5002
|
{
|
|
5003
5003
|
className: `toolbar-btn compact ${p ? "active" : ""}`,
|
|
5004
|
-
onClick:
|
|
5004
|
+
onClick: y,
|
|
5005
5005
|
title: "Toggle Rulers",
|
|
5006
5006
|
children: [
|
|
5007
5007
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "📐" }),
|
|
@@ -5024,7 +5024,7 @@ const Pt = {
|
|
|
5024
5024
|
] })
|
|
5025
5025
|
] }),
|
|
5026
5026
|
/* @__PURE__ */ i.jsx(
|
|
5027
|
-
|
|
5027
|
+
oi,
|
|
5028
5028
|
{
|
|
5029
5029
|
isOpen: $,
|
|
5030
5030
|
onClose: () => B(!1),
|
|
@@ -5033,7 +5033,7 @@ const Pt = {
|
|
|
5033
5033
|
}
|
|
5034
5034
|
),
|
|
5035
5035
|
/* @__PURE__ */ i.jsx(
|
|
5036
|
-
|
|
5036
|
+
ri,
|
|
5037
5037
|
{
|
|
5038
5038
|
isOpen: W,
|
|
5039
5039
|
onClose: () => at(!1),
|
|
@@ -5042,7 +5042,7 @@ const Pt = {
|
|
|
5042
5042
|
}
|
|
5043
5043
|
),
|
|
5044
5044
|
/* @__PURE__ */ i.jsx(
|
|
5045
|
-
|
|
5045
|
+
si,
|
|
5046
5046
|
{
|
|
5047
5047
|
isOpen: U,
|
|
5048
5048
|
onClose: () => ft(!1),
|
|
@@ -5053,7 +5053,7 @@ const Pt = {
|
|
|
5053
5053
|
}
|
|
5054
5054
|
),
|
|
5055
5055
|
/* @__PURE__ */ i.jsx(
|
|
5056
|
-
|
|
5056
|
+
ni,
|
|
5057
5057
|
{
|
|
5058
5058
|
isOpen: q,
|
|
5059
5059
|
onClose: () => rt(!1),
|
|
@@ -5064,7 +5064,7 @@ const Pt = {
|
|
|
5064
5064
|
}
|
|
5065
5065
|
),
|
|
5066
5066
|
/* @__PURE__ */ i.jsx(
|
|
5067
|
-
|
|
5067
|
+
ci,
|
|
5068
5068
|
{
|
|
5069
5069
|
isOpen: Y,
|
|
5070
5070
|
onClose: () => O(!1),
|
|
@@ -5073,14 +5073,14 @@ const Pt = {
|
|
|
5073
5073
|
}
|
|
5074
5074
|
)
|
|
5075
5075
|
] });
|
|
5076
|
-
},
|
|
5076
|
+
}, fi = ({
|
|
5077
5077
|
selectedElement: d,
|
|
5078
5078
|
onUpdate: o,
|
|
5079
5079
|
onMoveLayer: a,
|
|
5080
5080
|
availableFonts: l,
|
|
5081
5081
|
theme: s
|
|
5082
5082
|
}) => {
|
|
5083
|
-
const [
|
|
5083
|
+
const [h, y] = N(!1);
|
|
5084
5084
|
if (!d)
|
|
5085
5085
|
return /* @__PURE__ */ i.jsxs("div", { className: "properties-panel", children: [
|
|
5086
5086
|
/* @__PURE__ */ i.jsx("h3", { children: "Properties" }),
|
|
@@ -5088,7 +5088,7 @@ const Pt = {
|
|
|
5088
5088
|
] });
|
|
5089
5089
|
const c = (w, z) => {
|
|
5090
5090
|
o(d.id, { [w]: z });
|
|
5091
|
-
},
|
|
5091
|
+
}, u = () => {
|
|
5092
5092
|
var w, z, E;
|
|
5093
5093
|
return /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
|
|
5094
5094
|
/* @__PURE__ */ i.jsx("h4", { children: "Text Content" }),
|
|
@@ -5344,7 +5344,7 @@ const Pt = {
|
|
|
5344
5344
|
] })
|
|
5345
5345
|
] })
|
|
5346
5346
|
] }) }),
|
|
5347
|
-
|
|
5347
|
+
h && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
5348
5348
|
/* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
5349
5349
|
/* @__PURE__ */ i.jsxs("div", { className: "input-group", children: [
|
|
5350
5350
|
/* @__PURE__ */ i.jsx("label", { children: "Letter Spacing" }),
|
|
@@ -5552,7 +5552,7 @@ const Pt = {
|
|
|
5552
5552
|
] })
|
|
5553
5553
|
] })
|
|
5554
5554
|
] });
|
|
5555
|
-
},
|
|
5555
|
+
}, x = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
|
|
5556
5556
|
/* @__PURE__ */ i.jsx("h4", { children: "Shape Properties" }),
|
|
5557
5557
|
/* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
5558
5558
|
/* @__PURE__ */ i.jsx("label", { children: "Fill Color" }),
|
|
@@ -5635,7 +5635,7 @@ const Pt = {
|
|
|
5635
5635
|
"%"
|
|
5636
5636
|
] })
|
|
5637
5637
|
] }),
|
|
5638
|
-
|
|
5638
|
+
h && /* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
5639
5639
|
/* @__PURE__ */ i.jsx("label", { children: "Border Radius" }),
|
|
5640
5640
|
/* @__PURE__ */ i.jsx(
|
|
5641
5641
|
"input",
|
|
@@ -5803,8 +5803,8 @@ const Pt = {
|
|
|
5803
5803
|
/* @__PURE__ */ i.jsx("span", { className: "element-type", children: d.type })
|
|
5804
5804
|
] }),
|
|
5805
5805
|
/* @__PURE__ */ i.jsxs("div", { className: "panel-content", children: [
|
|
5806
|
-
d.type === "text" &&
|
|
5807
|
-
T.includes(d.type) &&
|
|
5806
|
+
d.type === "text" && u(),
|
|
5807
|
+
T.includes(d.type) && x(),
|
|
5808
5808
|
d.type === "image" && F(),
|
|
5809
5809
|
d.type === "horizontalLine" && p(),
|
|
5810
5810
|
C(),
|
|
@@ -5813,25 +5813,25 @@ const Pt = {
|
|
|
5813
5813
|
"button",
|
|
5814
5814
|
{
|
|
5815
5815
|
className: "toggle-advanced",
|
|
5816
|
-
onClick: () =>
|
|
5816
|
+
onClick: () => y(!h),
|
|
5817
5817
|
children: [
|
|
5818
|
-
|
|
5818
|
+
h ? "Hide" : "Show",
|
|
5819
5819
|
" Advanced Options"
|
|
5820
5820
|
]
|
|
5821
5821
|
}
|
|
5822
5822
|
) })
|
|
5823
5823
|
] })
|
|
5824
5824
|
] });
|
|
5825
|
-
},
|
|
5825
|
+
}, hi = ({
|
|
5826
5826
|
elements: d,
|
|
5827
5827
|
selectedElement: o,
|
|
5828
5828
|
onSelectElement: a,
|
|
5829
5829
|
onMoveLayer: l,
|
|
5830
5830
|
onDeleteElement: s,
|
|
5831
|
-
theme:
|
|
5831
|
+
theme: h
|
|
5832
5832
|
}) => {
|
|
5833
|
-
const
|
|
5834
|
-
switch (
|
|
5833
|
+
const y = (u, x) => {
|
|
5834
|
+
switch (u) {
|
|
5835
5835
|
case "text":
|
|
5836
5836
|
return "T";
|
|
5837
5837
|
case "rectangle":
|
|
@@ -5871,32 +5871,32 @@ const Pt = {
|
|
|
5871
5871
|
default:
|
|
5872
5872
|
return "?";
|
|
5873
5873
|
}
|
|
5874
|
-
}, c = (
|
|
5875
|
-
var
|
|
5876
|
-
if (
|
|
5877
|
-
return
|
|
5878
|
-
if (
|
|
5879
|
-
return `QR Code: ${(
|
|
5880
|
-
if (
|
|
5881
|
-
const C =
|
|
5874
|
+
}, c = (u) => {
|
|
5875
|
+
var x, F;
|
|
5876
|
+
if (u.type === "text")
|
|
5877
|
+
return u.isIcon && u.iconData ? `Icon: ${u.iconData.name}` : ((x = u.text) == null ? void 0 : x.substring(0, 20)) + (((F = u.text) == null ? void 0 : F.length) > 20 ? "..." : "") || "Text";
|
|
5878
|
+
if (u.type === "qrcode")
|
|
5879
|
+
return `QR Code: ${(u.data || "").substring(0, 15) + ((u.data || "").length > 15 ? "..." : "")}`;
|
|
5880
|
+
if (u.type === "barcode") {
|
|
5881
|
+
const C = u.format || "CODE128", p = u.data || "";
|
|
5882
5882
|
return `Barcode (${C}): ${p.substring(0, 10) + (p.length > 10 ? "..." : "")}`;
|
|
5883
5883
|
}
|
|
5884
|
-
return
|
|
5884
|
+
return u.type === "sticker" ? `Sticker: ${(u.name || "Untitled").substring(0, 15)}` : u.type === "embroidery" ? `Embroidery: ${(u.name || "Design").substring(0, 15)}` : u.type.charAt(0).toUpperCase() + u.type.slice(1);
|
|
5885
5885
|
};
|
|
5886
5886
|
return /* @__PURE__ */ i.jsxs("div", { className: "layers-panel", children: [
|
|
5887
5887
|
/* @__PURE__ */ i.jsxs("div", { className: "panel-header", children: [
|
|
5888
5888
|
/* @__PURE__ */ i.jsx("h3", { children: "Layers" }),
|
|
5889
5889
|
/* @__PURE__ */ i.jsx("span", { className: "layer-count", children: d.length })
|
|
5890
5890
|
] }),
|
|
5891
|
-
/* @__PURE__ */ i.jsx("div", { className: "layers-list", children: d.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...d].reverse().map((
|
|
5891
|
+
/* @__PURE__ */ i.jsx("div", { className: "layers-list", children: d.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...d].reverse().map((u, x) => /* @__PURE__ */ i.jsxs(
|
|
5892
5892
|
"div",
|
|
5893
5893
|
{
|
|
5894
|
-
className: `layer-item ${(o == null ? void 0 : o.id) ===
|
|
5895
|
-
onClick: () => a(
|
|
5894
|
+
className: `layer-item ${(o == null ? void 0 : o.id) === u.id ? "selected" : ""}`,
|
|
5895
|
+
onClick: () => a(u),
|
|
5896
5896
|
children: [
|
|
5897
5897
|
/* @__PURE__ */ i.jsxs("div", { className: "layer-info", children: [
|
|
5898
|
-
/* @__PURE__ */ i.jsx("span", { className: "layer-icon", children:
|
|
5899
|
-
/* @__PURE__ */ i.jsx("span", { className: "layer-name", children: c(
|
|
5898
|
+
/* @__PURE__ */ i.jsx("span", { className: "layer-icon", children: y(u.type) }),
|
|
5899
|
+
/* @__PURE__ */ i.jsx("span", { className: "layer-name", children: c(u) })
|
|
5900
5900
|
] }),
|
|
5901
5901
|
/* @__PURE__ */ i.jsxs("div", { className: "layer-controls", children: [
|
|
5902
5902
|
/* @__PURE__ */ i.jsx(
|
|
@@ -5904,9 +5904,9 @@ const Pt = {
|
|
|
5904
5904
|
{
|
|
5905
5905
|
className: "layer-btn",
|
|
5906
5906
|
onClick: (F) => {
|
|
5907
|
-
F.stopPropagation(), l(
|
|
5907
|
+
F.stopPropagation(), l(u.id, "up");
|
|
5908
5908
|
},
|
|
5909
|
-
disabled:
|
|
5909
|
+
disabled: x === 0,
|
|
5910
5910
|
title: "Move Up",
|
|
5911
5911
|
children: "↑"
|
|
5912
5912
|
}
|
|
@@ -5916,9 +5916,9 @@ const Pt = {
|
|
|
5916
5916
|
{
|
|
5917
5917
|
className: "layer-btn",
|
|
5918
5918
|
onClick: (F) => {
|
|
5919
|
-
F.stopPropagation(), l(
|
|
5919
|
+
F.stopPropagation(), l(u.id, "down");
|
|
5920
5920
|
},
|
|
5921
|
-
disabled:
|
|
5921
|
+
disabled: x === d.length - 1,
|
|
5922
5922
|
title: "Move Down",
|
|
5923
5923
|
children: "↓"
|
|
5924
5924
|
}
|
|
@@ -5928,7 +5928,7 @@ const Pt = {
|
|
|
5928
5928
|
{
|
|
5929
5929
|
className: "layer-btn delete",
|
|
5930
5930
|
onClick: (F) => {
|
|
5931
|
-
F.stopPropagation(), s(
|
|
5931
|
+
F.stopPropagation(), s(u.id);
|
|
5932
5932
|
},
|
|
5933
5933
|
title: "Delete",
|
|
5934
5934
|
children: "×"
|
|
@@ -5937,26 +5937,26 @@ const Pt = {
|
|
|
5937
5937
|
] })
|
|
5938
5938
|
]
|
|
5939
5939
|
},
|
|
5940
|
-
|
|
5940
|
+
u.id
|
|
5941
5941
|
)) })
|
|
5942
5942
|
] });
|
|
5943
5943
|
};
|
|
5944
|
-
class
|
|
5944
|
+
class gi {
|
|
5945
5945
|
constructor() {
|
|
5946
5946
|
this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d");
|
|
5947
5947
|
}
|
|
5948
5948
|
// Add this method to the ExportManager class
|
|
5949
|
-
async exportAllSections(o, a, l, s,
|
|
5950
|
-
const
|
|
5951
|
-
for (const
|
|
5952
|
-
const F =
|
|
5949
|
+
async exportAllSections(o, a, l, s, h = "png", y = !0, c = null) {
|
|
5950
|
+
const u = {};
|
|
5951
|
+
for (const x of a) {
|
|
5952
|
+
const F = x.id || x.sectionName, C = o[F];
|
|
5953
5953
|
if (!C || !C.elements || C.elements.length === 0) {
|
|
5954
5954
|
console.log(`Skipping section ${F} - no elements`);
|
|
5955
5955
|
continue;
|
|
5956
5956
|
}
|
|
5957
|
-
if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s),
|
|
5958
|
-
let I =
|
|
5959
|
-
if (c && c.sectionImage && (
|
|
5957
|
+
if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), y) {
|
|
5958
|
+
let I = x.image || x.sectionImage;
|
|
5959
|
+
if (c && c.sectionImage && (x.sectionName === "Front" || c.sections && Object.keys(c.sections).includes(x.sectionName)) && (I = c.sectionImage), I)
|
|
5960
5960
|
try {
|
|
5961
5961
|
const T = await this.loadImage(I);
|
|
5962
5962
|
await this.processImageColor(T, C.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
|
|
@@ -5967,13 +5967,13 @@ class hi {
|
|
|
5967
5967
|
this.ctx.clearRect(0, 0, l, s);
|
|
5968
5968
|
for (const I of C.elements)
|
|
5969
5969
|
await this.drawElement(I);
|
|
5970
|
-
const p = this.canvas.toDataURL(`image/${
|
|
5971
|
-
|
|
5970
|
+
const p = this.canvas.toDataURL(`image/${h}`, h === "jpeg" ? 0.9 : void 0);
|
|
5971
|
+
u[F] = {
|
|
5972
5972
|
dataUrl: p,
|
|
5973
5973
|
blob: await this.dataUrlToBlob(p)
|
|
5974
5974
|
};
|
|
5975
5975
|
}
|
|
5976
|
-
return
|
|
5976
|
+
return u;
|
|
5977
5977
|
}
|
|
5978
5978
|
// Also add a method to download all exports
|
|
5979
5979
|
async downloadExports(o, a = "design") {
|
|
@@ -5983,12 +5983,12 @@ class hi {
|
|
|
5983
5983
|
return;
|
|
5984
5984
|
}
|
|
5985
5985
|
if (l.length === 1) {
|
|
5986
|
-
const s = l[0], { blob:
|
|
5987
|
-
c.href =
|
|
5986
|
+
const s = l[0], { blob: h } = o[s], y = URL.createObjectURL(h), c = document.createElement("a");
|
|
5987
|
+
c.href = y, c.download = `${a}-${s}.png`, document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(y);
|
|
5988
5988
|
} else
|
|
5989
5989
|
for (const s of l) {
|
|
5990
|
-
const { blob:
|
|
5991
|
-
c.href =
|
|
5990
|
+
const { blob: h } = o[s], y = URL.createObjectURL(h), c = document.createElement("a");
|
|
5991
|
+
c.href = y, c.download = `${a}-${s}.png`, document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(y), await new Promise((u) => setTimeout(u, 100));
|
|
5992
5992
|
}
|
|
5993
5993
|
}
|
|
5994
5994
|
async loadImage(o) {
|
|
@@ -6005,18 +6005,18 @@ class hi {
|
|
|
6005
6005
|
async processImageColor(o, a) {
|
|
6006
6006
|
const l = document.createElement("canvas"), s = l.getContext("2d");
|
|
6007
6007
|
l.width = o.width, l.height = o.height, s.clearRect(0, 0, l.width, l.height), s.drawImage(o, 0, 0);
|
|
6008
|
-
const
|
|
6008
|
+
const h = s.getImageData(0, 0, l.width, l.height), y = h.data, c = this.hexToRgb(a);
|
|
6009
6009
|
if (!c) {
|
|
6010
6010
|
console.warn("Invalid target color:", a);
|
|
6011
6011
|
return;
|
|
6012
6012
|
}
|
|
6013
|
-
const { r:
|
|
6014
|
-
for (let C = 0; C <
|
|
6015
|
-
if (
|
|
6016
|
-
const I = this.getLuma(
|
|
6017
|
-
|
|
6013
|
+
const { r: u, g: x, b: F } = c;
|
|
6014
|
+
for (let C = 0; C < y.length; C += 4) {
|
|
6015
|
+
if (y[C + 3] === 0) continue;
|
|
6016
|
+
const I = this.getLuma(y[C], y[C + 1], y[C + 2]);
|
|
6017
|
+
y[C] = Math.round(u * I), y[C + 1] = Math.round(x * I), y[C + 2] = Math.round(F * I);
|
|
6018
6018
|
}
|
|
6019
|
-
return s.putImageData(
|
|
6019
|
+
return s.putImageData(h, 0, 0), this.processedImage = new Image(), new Promise((C) => {
|
|
6020
6020
|
this.processedImage.onload = () => {
|
|
6021
6021
|
C();
|
|
6022
6022
|
}, this.processedImage.onerror = () => {
|
|
@@ -6089,9 +6089,9 @@ class hi {
|
|
|
6089
6089
|
this.ctx.font = `${o.fontStyle || "normal"} ${o.fontWeight || "normal"} ${o.fontSize || 20}px ${o.fontFamily || "Arial"}`, this.ctx.fillStyle = o.fill || "#000000", this.ctx.textAlign = o.textAlign || "left", this.ctx.textBaseline = "top", o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth);
|
|
6090
6090
|
const a = (o.text || "Text").split(`
|
|
6091
6091
|
`), l = (o.fontSize || 20) * 1.2;
|
|
6092
|
-
a.forEach((s,
|
|
6093
|
-
const
|
|
6094
|
-
o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0,
|
|
6092
|
+
a.forEach((s, h) => {
|
|
6093
|
+
const y = h * l;
|
|
6094
|
+
o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0, y), this.ctx.fillText(s, 0, y);
|
|
6095
6095
|
});
|
|
6096
6096
|
}
|
|
6097
6097
|
drawRectangle(o) {
|
|
@@ -6106,10 +6106,10 @@ class hi {
|
|
|
6106
6106
|
this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(0, o.height), this.ctx.lineTo(o.width, o.height), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6107
6107
|
}
|
|
6108
6108
|
drawStar(o) {
|
|
6109
|
-
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2,
|
|
6109
|
+
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = s * 0.4, y = o.numPoints || 5;
|
|
6110
6110
|
this.ctx.beginPath();
|
|
6111
|
-
for (let c = 0; c <
|
|
6112
|
-
const
|
|
6111
|
+
for (let c = 0; c < y * 2; c++) {
|
|
6112
|
+
const u = c % 2 === 0 ? s : h, x = c * Math.PI / y, F = a + Math.cos(x) * u, C = l + Math.sin(x) * u;
|
|
6113
6113
|
c === 0 ? this.ctx.moveTo(F, C) : this.ctx.lineTo(F, C);
|
|
6114
6114
|
}
|
|
6115
6115
|
this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
@@ -6120,10 +6120,10 @@ class hi {
|
|
|
6120
6120
|
}
|
|
6121
6121
|
async dataUrlToBlob(o) {
|
|
6122
6122
|
return new Promise((a) => {
|
|
6123
|
-
const l = document.createElement("canvas"), s = l.getContext("2d"),
|
|
6124
|
-
|
|
6125
|
-
l.width =
|
|
6126
|
-
},
|
|
6123
|
+
const l = document.createElement("canvas"), s = l.getContext("2d"), h = new Image();
|
|
6124
|
+
h.onload = () => {
|
|
6125
|
+
l.width = h.width, l.height = h.height, s.drawImage(h, 0, 0), l.toBlob(a);
|
|
6126
|
+
}, h.src = o;
|
|
6127
6127
|
});
|
|
6128
6128
|
}
|
|
6129
6129
|
hexToRgb(o) {
|
|
@@ -6140,67 +6140,67 @@ class hi {
|
|
|
6140
6140
|
this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(o.width, l), this.ctx.lineTo(a, o.height), this.ctx.lineTo(0, l), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6141
6141
|
}
|
|
6142
6142
|
drawHexagon(o) {
|
|
6143
|
-
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2,
|
|
6143
|
+
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 6;
|
|
6144
6144
|
this.ctx.beginPath();
|
|
6145
|
-
for (let
|
|
6146
|
-
const c =
|
|
6147
|
-
|
|
6145
|
+
for (let y = 0; y < h; y++) {
|
|
6146
|
+
const c = y * 2 * Math.PI / h - Math.PI / 2, u = a + s * Math.cos(c), x = l + s * Math.sin(c);
|
|
6147
|
+
y === 0 ? this.ctx.moveTo(u, x) : this.ctx.lineTo(u, x);
|
|
6148
6148
|
}
|
|
6149
6149
|
this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6150
6150
|
}
|
|
6151
6151
|
drawPentagon(o) {
|
|
6152
|
-
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2,
|
|
6152
|
+
const a = o.width / 2, l = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 5;
|
|
6153
6153
|
this.ctx.beginPath();
|
|
6154
|
-
for (let
|
|
6155
|
-
const c =
|
|
6156
|
-
|
|
6154
|
+
for (let y = 0; y < h; y++) {
|
|
6155
|
+
const c = y * 2 * Math.PI / h - Math.PI / 2, u = a + s * Math.cos(c), x = l + s * Math.sin(c);
|
|
6156
|
+
y === 0 ? this.ctx.moveTo(u, x) : this.ctx.lineTo(u, x);
|
|
6157
6157
|
}
|
|
6158
6158
|
this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6159
6159
|
}
|
|
6160
6160
|
drawHeart(o) {
|
|
6161
|
-
const a = o.width, l = o.height, s = 0,
|
|
6161
|
+
const a = o.width, l = o.height, s = 0, h = 0;
|
|
6162
6162
|
this.ctx.beginPath();
|
|
6163
|
-
const
|
|
6164
|
-
this.ctx.moveTo(s + a / 2,
|
|
6163
|
+
const y = l * 0.3;
|
|
6164
|
+
this.ctx.moveTo(s + a / 2, h + y), this.ctx.bezierCurveTo(
|
|
6165
6165
|
s + a / 2,
|
|
6166
|
-
|
|
6166
|
+
h,
|
|
6167
6167
|
s,
|
|
6168
|
-
|
|
6168
|
+
h,
|
|
6169
6169
|
s,
|
|
6170
|
-
|
|
6170
|
+
h + y
|
|
6171
6171
|
), this.ctx.bezierCurveTo(
|
|
6172
6172
|
s,
|
|
6173
|
-
|
|
6173
|
+
h + (l + y) / 2,
|
|
6174
6174
|
s + a / 2,
|
|
6175
|
-
|
|
6175
|
+
h + (l + y) / 2,
|
|
6176
6176
|
s + a / 2,
|
|
6177
|
-
|
|
6177
|
+
h + l
|
|
6178
6178
|
), this.ctx.bezierCurveTo(
|
|
6179
6179
|
s + a / 2,
|
|
6180
|
-
|
|
6180
|
+
h + (l + y) / 2,
|
|
6181
6181
|
s + a,
|
|
6182
|
-
|
|
6182
|
+
h + (l + y) / 2,
|
|
6183
6183
|
s + a,
|
|
6184
|
-
|
|
6184
|
+
h + y
|
|
6185
6185
|
), this.ctx.bezierCurveTo(
|
|
6186
6186
|
s + a,
|
|
6187
|
-
|
|
6187
|
+
h,
|
|
6188
6188
|
s + a / 2,
|
|
6189
|
-
|
|
6189
|
+
h,
|
|
6190
6190
|
s + a / 2,
|
|
6191
|
-
|
|
6191
|
+
h + y
|
|
6192
6192
|
), this.ctx.closePath(), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6193
6193
|
}
|
|
6194
6194
|
drawOval(o) {
|
|
6195
|
-
const a = o.width / 2, l = o.height / 2, s = o.width / 2,
|
|
6196
|
-
this.ctx.beginPath(), this.ctx.ellipse(a, l, s,
|
|
6195
|
+
const a = o.width / 2, l = o.height / 2, s = o.width / 2, h = o.height / 2;
|
|
6196
|
+
this.ctx.beginPath(), this.ctx.ellipse(a, l, s, h, 0, 0, 2 * Math.PI), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6197
6197
|
}
|
|
6198
6198
|
drawRoundedRectangle(o) {
|
|
6199
6199
|
const a = Math.min(o.width, o.height) * 0.1;
|
|
6200
6200
|
this.drawRoundedRect(0, 0, o.width, o.height, a), o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fill()), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.stroke());
|
|
6201
6201
|
}
|
|
6202
|
-
drawRoundedRect(o, a, l, s,
|
|
6203
|
-
this.ctx.beginPath(), this.ctx.moveTo(o +
|
|
6202
|
+
drawRoundedRect(o, a, l, s, h) {
|
|
6203
|
+
this.ctx.beginPath(), this.ctx.moveTo(o + h, a), this.ctx.lineTo(o + l - h, a), this.ctx.quadraticCurveTo(o + l, a, o + l, a + h), this.ctx.lineTo(o + l, a + s - h), this.ctx.quadraticCurveTo(o + l, a + s, o + l - h, a + s), this.ctx.lineTo(o + h, a + s), this.ctx.quadraticCurveTo(o, a + s, o, a + s - h), this.ctx.lineTo(o, a + h), this.ctx.quadraticCurveTo(o, a, o + h, a), this.ctx.closePath();
|
|
6204
6204
|
}
|
|
6205
6205
|
async drawQRCode(o) {
|
|
6206
6206
|
if (o.imageObject)
|
|
@@ -6321,9 +6321,9 @@ class hi {
|
|
|
6321
6321
|
});
|
|
6322
6322
|
}
|
|
6323
6323
|
// Export all sections as JSON with File objects
|
|
6324
|
-
async exportAllSectionsAsJSON(o, a, l, s,
|
|
6324
|
+
async exportAllSectionsAsJSON(o, a, l, s, h = "png", y = null) {
|
|
6325
6325
|
var p, I;
|
|
6326
|
-
const c = [],
|
|
6326
|
+
const c = [], u = [], x = {};
|
|
6327
6327
|
for (const T of a) {
|
|
6328
6328
|
const w = T.sectionName, z = o[w];
|
|
6329
6329
|
if (!z || !z.elements || z.elements.length === 0) {
|
|
@@ -6331,7 +6331,7 @@ class hi {
|
|
|
6331
6331
|
continue;
|
|
6332
6332
|
}
|
|
6333
6333
|
let E = T.image || T.sectionImage;
|
|
6334
|
-
|
|
6334
|
+
y && y.sectionImage && (T.sectionName === "Front" || y.sections && Object.keys(y.sections).includes(T.sectionName)) && (E = y.sectionImage);
|
|
6335
6335
|
const S = {
|
|
6336
6336
|
...z,
|
|
6337
6337
|
// Include background information using the determined image
|
|
@@ -6344,22 +6344,22 @@ class hi {
|
|
|
6344
6344
|
canvasWidth: l,
|
|
6345
6345
|
canvasHeight: s
|
|
6346
6346
|
};
|
|
6347
|
-
|
|
6347
|
+
x[w] = S;
|
|
6348
6348
|
const $ = await this.exportSectionAsBlob(
|
|
6349
6349
|
z,
|
|
6350
6350
|
T,
|
|
6351
6351
|
l,
|
|
6352
6352
|
s,
|
|
6353
|
-
|
|
6353
|
+
h,
|
|
6354
6354
|
!0,
|
|
6355
|
-
|
|
6355
|
+
y
|
|
6356
6356
|
// Pass initData to exportSectionAsBlob
|
|
6357
6357
|
);
|
|
6358
6358
|
if ($) {
|
|
6359
6359
|
const W = await this.blobToFile(
|
|
6360
6360
|
$,
|
|
6361
|
-
`${w}-full.${
|
|
6362
|
-
`image/${
|
|
6361
|
+
`${w}-full.${h}`,
|
|
6362
|
+
`image/${h}`
|
|
6363
6363
|
);
|
|
6364
6364
|
c.push({
|
|
6365
6365
|
sectionName: w,
|
|
@@ -6371,41 +6371,41 @@ class hi {
|
|
|
6371
6371
|
T,
|
|
6372
6372
|
l,
|
|
6373
6373
|
s,
|
|
6374
|
-
|
|
6374
|
+
h,
|
|
6375
6375
|
!1,
|
|
6376
|
-
|
|
6376
|
+
y
|
|
6377
6377
|
// Pass initData to exportSectionAsBlob
|
|
6378
6378
|
);
|
|
6379
6379
|
if (B) {
|
|
6380
6380
|
const W = await this.blobToFile(
|
|
6381
6381
|
B,
|
|
6382
|
-
`${w}-print.${
|
|
6383
|
-
`image/${
|
|
6382
|
+
`${w}-print.${h}`,
|
|
6383
|
+
`image/${h}`
|
|
6384
6384
|
);
|
|
6385
|
-
|
|
6385
|
+
u.push({
|
|
6386
6386
|
sectionName: w,
|
|
6387
6387
|
sectionImage: W
|
|
6388
6388
|
});
|
|
6389
6389
|
}
|
|
6390
6390
|
}
|
|
6391
6391
|
let F = ((p = a[0]) == null ? void 0 : p.image) || ((I = a[0]) == null ? void 0 : I.sectionImage);
|
|
6392
|
-
if (
|
|
6392
|
+
if (y && y.sectionImage) {
|
|
6393
6393
|
const T = a[0];
|
|
6394
|
-
T && (T.sectionName === "Front" ||
|
|
6394
|
+
T && (T.sectionName === "Front" || y.sections && Object.keys(y.sections).includes(T.sectionName)) && (F = y.sectionImage);
|
|
6395
6395
|
}
|
|
6396
6396
|
const C = {
|
|
6397
|
-
sections:
|
|
6397
|
+
sections: x,
|
|
6398
6398
|
canvasWidth: l,
|
|
6399
6399
|
canvasHeight: s,
|
|
6400
6400
|
sectionImage: F,
|
|
6401
|
-
format:
|
|
6401
|
+
format: h,
|
|
6402
6402
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6403
6403
|
version: "1.0",
|
|
6404
6404
|
// Include initData information if present
|
|
6405
|
-
...
|
|
6405
|
+
...y && {
|
|
6406
6406
|
initData: {
|
|
6407
|
-
sectionImage:
|
|
6408
|
-
sections:
|
|
6407
|
+
sectionImage: y.sectionImage,
|
|
6408
|
+
sections: y.sections ? Object.keys(y.sections) : []
|
|
6409
6409
|
}
|
|
6410
6410
|
},
|
|
6411
6411
|
// Include product information for complete context
|
|
@@ -6419,46 +6419,46 @@ class hi {
|
|
|
6419
6419
|
};
|
|
6420
6420
|
return {
|
|
6421
6421
|
fullDesign: c,
|
|
6422
|
-
printReady:
|
|
6422
|
+
printReady: u,
|
|
6423
6423
|
designFile: JSON.stringify(C)
|
|
6424
6424
|
};
|
|
6425
6425
|
}
|
|
6426
6426
|
// Helper method to export a single section as blob
|
|
6427
|
-
async exportSectionAsBlob(o, a, l, s,
|
|
6427
|
+
async exportSectionAsBlob(o, a, l, s, h = "png", y = !0, c = null) {
|
|
6428
6428
|
try {
|
|
6429
|
-
if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s),
|
|
6430
|
-
let
|
|
6431
|
-
if (c && c.sectionImage && (a.sectionName === "Front" || c.sections && Object.keys(c.sections).includes(a.sectionName)) && (
|
|
6429
|
+
if (this.canvas.width = l, this.canvas.height = s, this.ctx.clearRect(0, 0, l, s), y) {
|
|
6430
|
+
let u = a.image || a.sectionImage;
|
|
6431
|
+
if (c && c.sectionImage && (a.sectionName === "Front" || c.sections && Object.keys(c.sections).includes(a.sectionName)) && (u = c.sectionImage), u)
|
|
6432
6432
|
try {
|
|
6433
|
-
const
|
|
6434
|
-
await this.processImageColor(
|
|
6435
|
-
} catch (
|
|
6436
|
-
console.warn("Failed to load background image:",
|
|
6433
|
+
const x = await this.loadImage(u);
|
|
6434
|
+
await this.processImageColor(x, o.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, l, s);
|
|
6435
|
+
} catch (x) {
|
|
6436
|
+
console.warn("Failed to load background image:", x);
|
|
6437
6437
|
}
|
|
6438
6438
|
} else
|
|
6439
6439
|
this.ctx.clearRect(0, 0, l, s);
|
|
6440
|
-
for (const
|
|
6441
|
-
await this.drawElement(
|
|
6442
|
-
return new Promise((
|
|
6443
|
-
this.canvas.toBlob(
|
|
6440
|
+
for (const u of o.elements)
|
|
6441
|
+
await this.drawElement(u);
|
|
6442
|
+
return new Promise((u) => {
|
|
6443
|
+
this.canvas.toBlob(u, `image/${h}`, h === "jpeg" ? 0.9 : void 0);
|
|
6444
6444
|
});
|
|
6445
|
-
} catch (
|
|
6446
|
-
return console.error("Error exporting section as blob:",
|
|
6445
|
+
} catch (u) {
|
|
6446
|
+
return console.error("Error exporting section as blob:", u), null;
|
|
6447
6447
|
}
|
|
6448
6448
|
}
|
|
6449
6449
|
async exportCurrentSectionAsJSON(o, a = "png", l = null) {
|
|
6450
6450
|
var I, T, w;
|
|
6451
6451
|
const s = ((I = o.activeSection) == null ? void 0 : I.sectionName) || "main";
|
|
6452
|
-
let
|
|
6453
|
-
l && l.sectionImage && (s === "Front" || l.sections && Object.keys(l.sections).includes(s)) && (
|
|
6454
|
-
const
|
|
6452
|
+
let h = ((T = o.activeSection) == null ? void 0 : T.sectionImage) || ((w = o.activeSection) == null ? void 0 : w.image);
|
|
6453
|
+
l && l.sectionImage && (s === "Front" || l.sections && Object.keys(l.sections).includes(s)) && (h = l.sectionImage);
|
|
6454
|
+
const y = {
|
|
6455
6455
|
elements: o.elements,
|
|
6456
6456
|
selectedColor: o.selectedColor,
|
|
6457
6457
|
canvasWidth: o.canvasWidth,
|
|
6458
6458
|
canvasHeight: o.canvasHeight,
|
|
6459
6459
|
// Include background information using the determined image
|
|
6460
|
-
backgroundImage:
|
|
6461
|
-
sectionImage:
|
|
6460
|
+
backgroundImage: h,
|
|
6461
|
+
sectionImage: h,
|
|
6462
6462
|
sectionName: s,
|
|
6463
6463
|
zoomLevel: o.zoomLevel,
|
|
6464
6464
|
showGrid: o.showGrid,
|
|
@@ -6466,10 +6466,10 @@ class hi {
|
|
|
6466
6466
|
}, c = {
|
|
6467
6467
|
id: s,
|
|
6468
6468
|
sectionName: s,
|
|
6469
|
-
image:
|
|
6470
|
-
sectionImage:
|
|
6471
|
-
},
|
|
6472
|
-
|
|
6469
|
+
image: h,
|
|
6470
|
+
sectionImage: h
|
|
6471
|
+
}, u = [], x = [], F = await this.exportSectionAsBlob(
|
|
6472
|
+
y,
|
|
6473
6473
|
c,
|
|
6474
6474
|
o.canvasWidth,
|
|
6475
6475
|
o.canvasHeight,
|
|
@@ -6484,13 +6484,13 @@ class hi {
|
|
|
6484
6484
|
`${s}-full.${a}`,
|
|
6485
6485
|
`image/${a}`
|
|
6486
6486
|
);
|
|
6487
|
-
|
|
6487
|
+
u.push({
|
|
6488
6488
|
sectionName: s,
|
|
6489
6489
|
sectionImage: z
|
|
6490
6490
|
});
|
|
6491
6491
|
}
|
|
6492
6492
|
const C = await this.exportSectionAsBlob(
|
|
6493
|
-
|
|
6493
|
+
y,
|
|
6494
6494
|
c,
|
|
6495
6495
|
o.canvasWidth,
|
|
6496
6496
|
o.canvasHeight,
|
|
@@ -6505,16 +6505,16 @@ class hi {
|
|
|
6505
6505
|
`${s}-print.${a}`,
|
|
6506
6506
|
`image/${a}`
|
|
6507
6507
|
);
|
|
6508
|
-
|
|
6508
|
+
x.push({
|
|
6509
6509
|
sectionName: s,
|
|
6510
6510
|
sectionImage: z
|
|
6511
6511
|
});
|
|
6512
6512
|
}
|
|
6513
6513
|
const p = {
|
|
6514
|
-
sections: { [s]:
|
|
6514
|
+
sections: { [s]: y },
|
|
6515
6515
|
canvasWidth: o.canvasWidth,
|
|
6516
6516
|
canvasHeight: o.canvasHeight,
|
|
6517
|
-
sectionImage:
|
|
6517
|
+
sectionImage: h,
|
|
6518
6518
|
// Use the determined image here too
|
|
6519
6519
|
format: a,
|
|
6520
6520
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -6530,20 +6530,20 @@ class hi {
|
|
|
6530
6530
|
productInfo: {
|
|
6531
6531
|
sections: [{
|
|
6532
6532
|
sectionName: s,
|
|
6533
|
-
sectionImage:
|
|
6533
|
+
sectionImage: h,
|
|
6534
6534
|
// Use the determined image here too
|
|
6535
6535
|
id: s
|
|
6536
6536
|
}]
|
|
6537
6537
|
}
|
|
6538
6538
|
};
|
|
6539
6539
|
return {
|
|
6540
|
-
fullDesign:
|
|
6541
|
-
printReady:
|
|
6540
|
+
fullDesign: u,
|
|
6541
|
+
printReady: x,
|
|
6542
6542
|
designFile: JSON.stringify(p)
|
|
6543
6543
|
};
|
|
6544
6544
|
}
|
|
6545
6545
|
}
|
|
6546
|
-
class
|
|
6546
|
+
class xi {
|
|
6547
6547
|
constructor(o = "localStorage") {
|
|
6548
6548
|
this.storage = o === "sessionStorage" ? sessionStorage : localStorage, this.STORAGE_PREFIX = "mypixia_canvas_", this.DESIGNS_LIST_KEY = "mypixia_saved_designs";
|
|
6549
6549
|
}
|
|
@@ -6551,10 +6551,10 @@ class gi {
|
|
|
6551
6551
|
saveDesign(o, a) {
|
|
6552
6552
|
var l;
|
|
6553
6553
|
try {
|
|
6554
|
-
const s = this.generateDesignId(o),
|
|
6554
|
+
const s = this.generateDesignId(o), h = (/* @__PURE__ */ new Date()).toISOString(), y = {
|
|
6555
6555
|
id: s,
|
|
6556
6556
|
name: o,
|
|
6557
|
-
timestamp:
|
|
6557
|
+
timestamp: h,
|
|
6558
6558
|
version: "1.0",
|
|
6559
6559
|
canvasData: {
|
|
6560
6560
|
elements: a.elements || [],
|
|
@@ -6570,11 +6570,11 @@ class gi {
|
|
|
6570
6570
|
},
|
|
6571
6571
|
metadata: {
|
|
6572
6572
|
elementCount: ((l = a.elements) == null ? void 0 : l.length) || 0,
|
|
6573
|
-
lastModified:
|
|
6573
|
+
lastModified: h,
|
|
6574
6574
|
thumbnail: a.thumbnail || null
|
|
6575
6575
|
}
|
|
6576
6576
|
};
|
|
6577
|
-
return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(
|
|
6577
|
+
return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(y)), this.updateDesignsList(s, o, h), { success: !0, designId: s, message: "Design saved successfully" };
|
|
6578
6578
|
} catch (s) {
|
|
6579
6579
|
return console.error("Error saving design:", s), { success: !1, error: s.message };
|
|
6580
6580
|
}
|
|
@@ -6584,10 +6584,10 @@ class gi {
|
|
|
6584
6584
|
try {
|
|
6585
6585
|
let a = o;
|
|
6586
6586
|
if (!o.startsWith("design_")) {
|
|
6587
|
-
const
|
|
6588
|
-
if (!
|
|
6587
|
+
const y = this.getAllDesigns().find((c) => c.name === o);
|
|
6588
|
+
if (!y)
|
|
6589
6589
|
return { success: !1, error: "Design not found" };
|
|
6590
|
-
a =
|
|
6590
|
+
a = y.id;
|
|
6591
6591
|
}
|
|
6592
6592
|
const l = this.storage.getItem(this.STORAGE_PREFIX + a);
|
|
6593
6593
|
return l ? { success: !0, data: JSON.parse(l) } : { success: !1, error: "Design not found" };
|
|
@@ -6620,8 +6620,8 @@ class gi {
|
|
|
6620
6620
|
const a = this.loadDesign(o);
|
|
6621
6621
|
if (!a.success)
|
|
6622
6622
|
return a;
|
|
6623
|
-
const l = a.data, s = JSON.stringify(l, null, 2),
|
|
6624
|
-
return c.href =
|
|
6623
|
+
const l = a.data, s = JSON.stringify(l, null, 2), h = new Blob([s], { type: "application/json" }), y = URL.createObjectURL(h), c = document.createElement("a");
|
|
6624
|
+
return c.href = y, c.download = `${l.name}_${l.id}.json`, document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(y), { success: !0, message: "Design exported successfully" };
|
|
6625
6625
|
} catch (a) {
|
|
6626
6626
|
return console.error("Error exporting design:", a), { success: !1, error: a.message };
|
|
6627
6627
|
}
|
|
@@ -6633,13 +6633,13 @@ class gi {
|
|
|
6633
6633
|
const l = new FileReader();
|
|
6634
6634
|
l.onload = (s) => {
|
|
6635
6635
|
try {
|
|
6636
|
-
const
|
|
6637
|
-
if (!this.validateDesignData(
|
|
6636
|
+
const h = JSON.parse(s.target.result);
|
|
6637
|
+
if (!this.validateDesignData(h)) {
|
|
6638
6638
|
a({ success: !1, error: "Invalid design file format" });
|
|
6639
6639
|
return;
|
|
6640
6640
|
}
|
|
6641
|
-
const
|
|
6642
|
-
|
|
6641
|
+
const y = this.generateDesignId(h.name + "_imported");
|
|
6642
|
+
h.id = y, h.name += "_imported", h.timestamp = (/* @__PURE__ */ new Date()).toISOString(), h.metadata.lastModified = h.timestamp, this.storage.setItem(this.STORAGE_PREFIX + y, JSON.stringify(h)), this.updateDesignsList(y, h.name, h.timestamp), a({ success: !0, data: h, message: "Design imported successfully" });
|
|
6643
6643
|
} catch {
|
|
6644
6644
|
a({ success: !1, error: "Failed to parse design file" });
|
|
6645
6645
|
}
|
|
@@ -6707,13 +6707,13 @@ class gi {
|
|
|
6707
6707
|
return `design_${a}_${l}`;
|
|
6708
6708
|
}
|
|
6709
6709
|
updateDesignsList(o, a, l) {
|
|
6710
|
-
const s = this.getAllDesigns(),
|
|
6710
|
+
const s = this.getAllDesigns(), h = s.findIndex((c) => c.id === o), y = {
|
|
6711
6711
|
id: o,
|
|
6712
6712
|
name: a,
|
|
6713
6713
|
timestamp: l,
|
|
6714
6714
|
lastModified: l
|
|
6715
6715
|
};
|
|
6716
|
-
|
|
6716
|
+
h >= 0 ? s[h] = y : s.push(y), s.sort((c, u) => new Date(u.timestamp) - new Date(c.timestamp)), this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(s));
|
|
6717
6717
|
}
|
|
6718
6718
|
validateDesignData(o) {
|
|
6719
6719
|
return o && o.id && o.name && o.canvasData && Array.isArray(o.canvasData.elements);
|
|
@@ -6733,7 +6733,7 @@ class gi {
|
|
|
6733
6733
|
return "Unknown";
|
|
6734
6734
|
}
|
|
6735
6735
|
}
|
|
6736
|
-
const
|
|
6736
|
+
const yi = Ye((d, o) => {
|
|
6737
6737
|
const {
|
|
6738
6738
|
theme: a = {
|
|
6739
6739
|
primaryColor: "#000000",
|
|
@@ -6763,16 +6763,16 @@ const xi = _e((d, o) => {
|
|
|
6763
6763
|
}
|
|
6764
6764
|
]
|
|
6765
6765
|
},
|
|
6766
|
-
initFile:
|
|
6767
|
-
initDesignContent:
|
|
6768
|
-
} = d, [c,
|
|
6766
|
+
initFile: h,
|
|
6767
|
+
initDesignContent: y
|
|
6768
|
+
} = d, [c, u] = N([]), [x, F] = N(null), [C, p] = N(!1), [I, T] = N(!1), [w, z] = N(!1), [E, S] = N({ x: 0, y: 0 }), [$, B] = N(null), [W, at] = N(800), [U, ft] = N(600), [q, rt] = N(1), [Y, O] = N(s.colorSettings[0]), [J, st] = N(!1), [K, it] = N(!0), [M, G] = N(!0), [j, m] = N(s.sections[0]), [A, Q] = N(!1), [_, Z] = N({}), [V, ht] = N([]), [H, P] = N(-1), [ct] = N(new xi("localStorage")), gt = nt(null), Dt = nt(null), kt = nt(null), wt = nt(null), Ut = nt(null), Et = nt(new gi()), Bt = nt(!1), [yt, Ot] = N(null), lt = ot(() => {
|
|
6769
6769
|
const e = {
|
|
6770
6770
|
elements: JSON.parse(JSON.stringify(c)),
|
|
6771
|
-
selectedElement:
|
|
6771
|
+
selectedElement: x ? { ...x } : null,
|
|
6772
6772
|
timestamp: Date.now()
|
|
6773
6773
|
}, t = V.slice(0, H + 1);
|
|
6774
6774
|
t.push(e), t.length > 50 ? t.shift() : P(H + 1), ht(t);
|
|
6775
|
-
}, [c,
|
|
6775
|
+
}, [c, x, V, H]), St = ot(() => ({
|
|
6776
6776
|
elements: c,
|
|
6777
6777
|
canvasWidth: W,
|
|
6778
6778
|
canvasHeight: U,
|
|
@@ -6782,16 +6782,16 @@ const xi = _e((d, o) => {
|
|
|
6782
6782
|
sectionDesigns: _,
|
|
6783
6783
|
zoomLevel: q,
|
|
6784
6784
|
showGrid: J,
|
|
6785
|
-
snapToGrid:
|
|
6786
|
-
selectedElement:
|
|
6785
|
+
snapToGrid: M,
|
|
6786
|
+
selectedElement: x ? { ...x } : null,
|
|
6787
6787
|
canvasRef: gt
|
|
6788
6788
|
// Include reference for thumbnail generation
|
|
6789
|
-
}), [c, W, U, Y, j, s, _, q, J,
|
|
6789
|
+
}), [c, W, U, Y, j, s, _, q, J, M, x]), Qt = (e) => {
|
|
6790
6790
|
if (e.sections && typeof e.sections == "object") {
|
|
6791
6791
|
const t = Object.keys(e.sections)[0], r = e.sections[t];
|
|
6792
6792
|
if (r && r.elements) {
|
|
6793
|
-
|
|
6794
|
-
const n = s.sections.find((
|
|
6793
|
+
u(r.elements || []), at(r.canvasWidth || 800), ft(r.canvasHeight || 600), O(r.selectedColor || s.colorSettings[0]), rt(r.zoomLevel || 1), st(r.showGrid || !1), G(r.snapToGrid || !0), F(null), e.sections && Z(e.sections);
|
|
6794
|
+
const n = s.sections.find((f) => f.sectionName === t);
|
|
6795
6795
|
n && m(n), ht([]), P(-1), setTimeout(() => {
|
|
6796
6796
|
lt();
|
|
6797
6797
|
}, 100);
|
|
@@ -6802,21 +6802,21 @@ const xi = _e((d, o) => {
|
|
|
6802
6802
|
et(() => {
|
|
6803
6803
|
const t = setTimeout(async () => {
|
|
6804
6804
|
if (c.length === 0 && V.length <= 1)
|
|
6805
|
-
if (
|
|
6805
|
+
if (y)
|
|
6806
6806
|
try {
|
|
6807
|
-
const r = JSON.parse(
|
|
6808
|
-
|
|
6807
|
+
const r = JSON.parse(y);
|
|
6808
|
+
Ot(r), Qt(r);
|
|
6809
6809
|
} catch (r) {
|
|
6810
6810
|
console.error("Error loading design file:", r), console.warn("Using default text instead");
|
|
6811
6811
|
}
|
|
6812
|
-
else if (
|
|
6812
|
+
else if (h)
|
|
6813
6813
|
try {
|
|
6814
|
-
const r = await fetch(
|
|
6814
|
+
const r = await fetch(h);
|
|
6815
6815
|
if (r.ok) {
|
|
6816
6816
|
const n = await r.text();
|
|
6817
6817
|
if (n.trim()) {
|
|
6818
|
-
const
|
|
6819
|
-
|
|
6818
|
+
const f = JSON.parse(n.trim());
|
|
6819
|
+
Ot(f), Qt(f);
|
|
6820
6820
|
}
|
|
6821
6821
|
} else
|
|
6822
6822
|
console.warn("Failed to load design file, using default text");
|
|
@@ -6824,10 +6824,10 @@ const xi = _e((d, o) => {
|
|
|
6824
6824
|
console.error("Error loading design file:", r), console.warn("Using default text instead");
|
|
6825
6825
|
}
|
|
6826
6826
|
else {
|
|
6827
|
-
const n = "Arial",
|
|
6827
|
+
const n = "Arial", f = "Change me", b = document.createElement("canvas").getContext("2d");
|
|
6828
6828
|
b.font = `24px ${n}`;
|
|
6829
|
-
const v = b.measureText(
|
|
6830
|
-
id:
|
|
6829
|
+
const v = b.measureText(f).width, R = {
|
|
6830
|
+
id: dt(),
|
|
6831
6831
|
type: "text",
|
|
6832
6832
|
x: W / 2 - v / 2,
|
|
6833
6833
|
// Center the actual text width
|
|
@@ -6835,7 +6835,7 @@ const xi = _e((d, o) => {
|
|
|
6835
6835
|
// Center based on font size
|
|
6836
6836
|
width: v,
|
|
6837
6837
|
height: 24,
|
|
6838
|
-
text:
|
|
6838
|
+
text: f,
|
|
6839
6839
|
fontSize: 24,
|
|
6840
6840
|
fontFamily: n,
|
|
6841
6841
|
fontWeight: "normal",
|
|
@@ -6848,13 +6848,13 @@ const xi = _e((d, o) => {
|
|
|
6848
6848
|
rotation: 0,
|
|
6849
6849
|
opacity: 1
|
|
6850
6850
|
};
|
|
6851
|
-
|
|
6851
|
+
u([R]), F(R), setTimeout(() => {
|
|
6852
6852
|
lt();
|
|
6853
6853
|
}, 100);
|
|
6854
6854
|
}
|
|
6855
6855
|
}, 300);
|
|
6856
6856
|
return () => clearTimeout(t);
|
|
6857
|
-
}, [
|
|
6857
|
+
}, [h, y, s.colorSettings, s.sections]);
|
|
6858
6858
|
const zt = ot((e = "png", t = !0) => {
|
|
6859
6859
|
const r = St();
|
|
6860
6860
|
return s.sections, Et.current.exportAllSections(
|
|
@@ -6897,8 +6897,8 @@ const xi = _e((d, o) => {
|
|
|
6897
6897
|
}, [W, U]), et(() => {
|
|
6898
6898
|
V.length === 0 && lt();
|
|
6899
6899
|
}, []);
|
|
6900
|
-
const At = (e, t, r, n,
|
|
6901
|
-
e.beginPath(), e.moveTo(t +
|
|
6900
|
+
const At = (e, t, r, n, f, g) => {
|
|
6901
|
+
e.beginPath(), e.moveTo(t + g, r), e.lineTo(t + n - g, r), e.quadraticCurveTo(t + n, r, t + n, r + g), e.lineTo(t + n, r + f - g), e.quadraticCurveTo(t + n, r + f, t + n - g, r + f), e.lineTo(t + g, r + f), e.quadraticCurveTo(t, r + f, t, r + f - g), e.lineTo(t, r + g), e.quadraticCurveTo(t, r, t + g, r), e.closePath();
|
|
6902
6902
|
}, $t = (e, t) => {
|
|
6903
6903
|
if (!t.isIcon)
|
|
6904
6904
|
return {
|
|
@@ -6910,11 +6910,11 @@ const xi = _e((d, o) => {
|
|
|
6910
6910
|
cy: t.y + t.height / 2
|
|
6911
6911
|
};
|
|
6912
6912
|
e.save(), e.font = `${t.fontStyle || ""} ${t.fontWeight || ""} ${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = "left";
|
|
6913
|
-
const r = e.measureText(t.text), n = r.actualBoundingBoxAscent ?? t.fontSize * 0.8,
|
|
6914
|
-
return e.restore(), { x:
|
|
6913
|
+
const r = e.measureText(t.text), n = r.actualBoundingBoxAscent ?? t.fontSize * 0.8, f = r.actualBoundingBoxDescent ?? t.fontSize * 0.2, g = r.actualBoundingBoxLeft ?? 0, b = r.actualBoundingBoxRight ?? r.width, k = g + b, v = n + f, R = t.x, D = t.y, L = R - k / 2 - g, tt = D - v / 2 - n;
|
|
6914
|
+
return e.restore(), { x: L, y: tt, width: k, height: v, cx: R, cy: D };
|
|
6915
6915
|
}, he = (e, t) => {
|
|
6916
6916
|
if (!t) return;
|
|
6917
|
-
const r = 8, n = 8,
|
|
6917
|
+
const r = 8, n = 8, f = 4, g = 30, b = $t(e, t), k = t.isIcon ? Math.max(r, 12) : r, v = {
|
|
6918
6918
|
x: -b.width / 2 - k,
|
|
6919
6919
|
y: -b.height / 2 - k,
|
|
6920
6920
|
w: b.width + k * 2,
|
|
@@ -6933,8 +6933,8 @@ const xi = _e((d, o) => {
|
|
|
6933
6933
|
v.y - 1,
|
|
6934
6934
|
v.w + 2,
|
|
6935
6935
|
v.h + 2,
|
|
6936
|
-
|
|
6937
|
-
), e.stroke(), e.strokeStyle = R, e.lineWidth = 2, e.setLineDash([8, 4]), At(e, v.x, v.y, v.w, v.h,
|
|
6936
|
+
f + 1
|
|
6937
|
+
), e.stroke(), e.strokeStyle = R, e.lineWidth = 2, e.setLineDash([8, 4]), At(e, v.x, v.y, v.w, v.h, f), e.stroke(), e.lineDashOffset = -(Date.now() / 50) % 12, e.strokeStyle = "#ffffff", e.lineWidth = 1, e.setLineDash([4, 8]), At(e, v.x, v.y, v.w, v.h, f), e.stroke(), e.setLineDash([]), e.lineDashOffset = 0, [
|
|
6938
6938
|
{ x: v.x, y: v.y },
|
|
6939
6939
|
{ x: v.x + v.w, y: v.y },
|
|
6940
6940
|
{ x: v.x + v.w, y: v.y + v.h },
|
|
@@ -6957,11 +6957,11 @@ const xi = _e((d, o) => {
|
|
|
6957
6957
|
n
|
|
6958
6958
|
);
|
|
6959
6959
|
});
|
|
6960
|
-
const D = 0,
|
|
6961
|
-
e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(D,
|
|
6960
|
+
const D = 0, L = v.y - g;
|
|
6961
|
+
e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(D, L + 12), e.lineTo(D, v.y), e.stroke(), e.setLineDash([]), e.beginPath(), e.arc(D, L, 12, 0, 2 * Math.PI), e.fillStyle = "#f59e0b", e.fill(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.stroke(), e.strokeStyle = "#ffffff", e.lineWidth = 2, e.beginPath(), e.arc(D, L, 6, -Math.PI / 2, Math.PI, !1), e.stroke(), e.beginPath(), e.moveTo(D - 6, L), e.lineTo(D - 3, L - 3), e.lineTo(D - 3, L + 3), e.closePath(), e.fillStyle = "#ffffff", e.fill(), e.restore();
|
|
6962
6962
|
}, ge = (e, t) => {
|
|
6963
6963
|
if (!t) return [];
|
|
6964
|
-
const r = $t(e, t), n = t.isIcon ? Math.max(8, 12) : 8,
|
|
6964
|
+
const r = $t(e, t), n = t.isIcon ? Math.max(8, 12) : 8, f = 8, g = 30, b = (t.rotation || 0) * Math.PI / 180, k = {
|
|
6965
6965
|
x: -r.width / 2 - n,
|
|
6966
6966
|
y: -r.height / 2 - n,
|
|
6967
6967
|
w: r.width + n * 2,
|
|
@@ -6971,20 +6971,20 @@ const xi = _e((d, o) => {
|
|
|
6971
6971
|
{ x: k.x + k.w, y: k.y, type: "ne-resize" },
|
|
6972
6972
|
{ x: k.x + k.w, y: k.y + k.h, type: "se-resize" },
|
|
6973
6973
|
{ x: k.x, y: k.y + k.h, type: "sw-resize" },
|
|
6974
|
-
{ x: 0, y: k.y -
|
|
6974
|
+
{ x: 0, y: k.y - g, type: "rotate" }
|
|
6975
6975
|
], R = Math.cos(b), D = Math.sin(b);
|
|
6976
|
-
return v.map((
|
|
6977
|
-
x: r.cx + (
|
|
6978
|
-
y: r.cy + (
|
|
6979
|
-
type:
|
|
6980
|
-
size:
|
|
6976
|
+
return v.map((L) => ({
|
|
6977
|
+
x: r.cx + (L.x * R - L.y * D),
|
|
6978
|
+
y: r.cy + (L.x * D + L.y * R),
|
|
6979
|
+
type: L.type,
|
|
6980
|
+
size: L.type === "rotate" ? 24 : f
|
|
6981
6981
|
}));
|
|
6982
6982
|
}, Ht = (e, t, r) => {
|
|
6983
6983
|
if (!r) return null;
|
|
6984
6984
|
const n = gt.current;
|
|
6985
6985
|
if (!n) return null;
|
|
6986
|
-
const
|
|
6987
|
-
for (const b of
|
|
6986
|
+
const f = n.getContext("2d"), g = ge(f, r);
|
|
6987
|
+
for (const b of g) {
|
|
6988
6988
|
const k = e - b.x, v = t - b.y;
|
|
6989
6989
|
if (Math.sqrt(k * k + v * v) <= b.size / 2)
|
|
6990
6990
|
return b.type;
|
|
@@ -6993,19 +6993,19 @@ const xi = _e((d, o) => {
|
|
|
6993
6993
|
}, Ft = ot(() => {
|
|
6994
6994
|
if (H > 0) {
|
|
6995
6995
|
const e = V[H - 1];
|
|
6996
|
-
|
|
6996
|
+
u(e.elements), F(e.selectedElement), P(H - 1);
|
|
6997
6997
|
}
|
|
6998
6998
|
}, [V, H]), bt = ot(() => {
|
|
6999
6999
|
if (H < V.length - 1) {
|
|
7000
7000
|
const e = V[H + 1];
|
|
7001
|
-
|
|
7001
|
+
u(e.elements), F(e.selectedElement), P(H + 1);
|
|
7002
7002
|
}
|
|
7003
|
-
}, [V, H]),
|
|
7003
|
+
}, [V, H]), mt = (e) => M ? Math.round(e / It) * It : e;
|
|
7004
7004
|
et(() => {
|
|
7005
7005
|
if (j != null && j.sectionImage) {
|
|
7006
7006
|
kt.current = null, wt.current = null;
|
|
7007
7007
|
const e = gt.current;
|
|
7008
|
-
if (e && e.getContext("2d").clearRect(0, 0, W, U),
|
|
7008
|
+
if (e && e.getContext("2d").clearRect(0, 0, W, U), h && !yt)
|
|
7009
7009
|
return;
|
|
7010
7010
|
const t = new Image();
|
|
7011
7011
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
@@ -7021,10 +7021,10 @@ const xi = _e((d, o) => {
|
|
|
7021
7021
|
const e = (t) => {
|
|
7022
7022
|
const r = document.activeElement;
|
|
7023
7023
|
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable))) {
|
|
7024
|
-
if ((t.key === "Delete" || t.key === "Backspace") &&
|
|
7024
|
+
if ((t.key === "Delete" || t.key === "Backspace") && x && !l) {
|
|
7025
7025
|
t.preventDefault();
|
|
7026
|
-
const
|
|
7027
|
-
|
|
7026
|
+
const f = x;
|
|
7027
|
+
u((g) => g.filter((b) => b.id !== f.id)), F(null), lt();
|
|
7028
7028
|
}
|
|
7029
7029
|
if (t.ctrlKey || t.metaKey)
|
|
7030
7030
|
switch (t.key) {
|
|
@@ -7040,7 +7040,7 @@ const xi = _e((d, o) => {
|
|
|
7040
7040
|
return document.addEventListener("keydown", e), () => {
|
|
7041
7041
|
document.removeEventListener("keydown", e);
|
|
7042
7042
|
};
|
|
7043
|
-
}, [
|
|
7043
|
+
}, [x, l, Ft, bt, lt]);
|
|
7044
7044
|
const xe = (e) => {
|
|
7045
7045
|
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
|
|
7046
7046
|
return t ? {
|
|
@@ -7048,14 +7048,14 @@ const xi = _e((d, o) => {
|
|
|
7048
7048
|
g: parseInt(t[2], 16),
|
|
7049
7049
|
b: parseInt(t[3], 16)
|
|
7050
7050
|
} : null;
|
|
7051
|
-
},
|
|
7051
|
+
}, dt = () => `element_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, ye = (e) => {
|
|
7052
7052
|
e.strokeStyle = "#e0e0e0", e.lineWidth = 1, e.setLineDash([1, 1]);
|
|
7053
7053
|
for (let t = 0; t <= W; t += It)
|
|
7054
7054
|
e.beginPath(), e.moveTo(t, 0), e.lineTo(t, U), e.stroke();
|
|
7055
7055
|
for (let t = 0; t <= U; t += It)
|
|
7056
7056
|
e.beginPath(), e.moveTo(0, t), e.lineTo(W, t), e.stroke();
|
|
7057
7057
|
e.setLineDash([]);
|
|
7058
|
-
},
|
|
7058
|
+
}, ue = (e, t) => {
|
|
7059
7059
|
e.save();
|
|
7060
7060
|
const r = t.x + t.width / 2, n = t.y + t.height / 2;
|
|
7061
7061
|
switch (e.translate(r, n), t.rotation && e.rotate(t.rotation * Math.PI / 180), e.translate(-t.width / 2, -t.height / 2), t.type) {
|
|
@@ -7096,41 +7096,41 @@ const xi = _e((d, o) => {
|
|
|
7096
7096
|
Ae(e, t);
|
|
7097
7097
|
break;
|
|
7098
7098
|
case "image":
|
|
7099
|
-
|
|
7099
|
+
Ee(e, t);
|
|
7100
7100
|
break;
|
|
7101
7101
|
case "qrcode":
|
|
7102
7102
|
pe(e, t);
|
|
7103
7103
|
break;
|
|
7104
7104
|
case "barcode":
|
|
7105
|
-
|
|
7105
|
+
me(e, t);
|
|
7106
7106
|
break;
|
|
7107
7107
|
case "sticker":
|
|
7108
|
-
|
|
7108
|
+
Be(e, t);
|
|
7109
7109
|
break;
|
|
7110
7110
|
case "horizontalLine":
|
|
7111
7111
|
Re(e, t);
|
|
7112
7112
|
break;
|
|
7113
7113
|
case "embroidery":
|
|
7114
|
-
|
|
7114
|
+
ze(e, t);
|
|
7115
7115
|
break;
|
|
7116
7116
|
}
|
|
7117
7117
|
e.restore();
|
|
7118
|
-
},
|
|
7118
|
+
}, me = (e, t) => {
|
|
7119
7119
|
if (t.imageObject)
|
|
7120
7120
|
e.drawImage(t.imageObject, 0, 0, t.width, t.height);
|
|
7121
7121
|
else if (t.src && !t.imageLoading) {
|
|
7122
7122
|
t.imageLoading = !0;
|
|
7123
7123
|
const r = new Image();
|
|
7124
7124
|
r.onload = () => {
|
|
7125
|
-
|
|
7125
|
+
u(
|
|
7126
7126
|
(n) => n.map(
|
|
7127
|
-
(
|
|
7127
|
+
(f) => f.id === t.id ? { ...f, imageObject: r, imageLoading: !1 } : f
|
|
7128
7128
|
)
|
|
7129
7129
|
);
|
|
7130
7130
|
}, r.onerror = () => {
|
|
7131
|
-
|
|
7131
|
+
u(
|
|
7132
7132
|
(n) => n.map(
|
|
7133
|
-
(
|
|
7133
|
+
(f) => f.id === t.id ? { ...f, imageLoading: !1 } : f
|
|
7134
7134
|
)
|
|
7135
7135
|
);
|
|
7136
7136
|
}, r.src = t.src, e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2);
|
|
@@ -7142,15 +7142,15 @@ const xi = _e((d, o) => {
|
|
|
7142
7142
|
t.imageLoading = !0;
|
|
7143
7143
|
const r = new Image();
|
|
7144
7144
|
r.onload = () => {
|
|
7145
|
-
|
|
7145
|
+
u(
|
|
7146
7146
|
(n) => n.map(
|
|
7147
|
-
(
|
|
7147
|
+
(f) => f.id === t.id ? { ...f, imageObject: r, imageLoading: !1 } : f
|
|
7148
7148
|
)
|
|
7149
7149
|
);
|
|
7150
7150
|
}, r.onerror = () => {
|
|
7151
|
-
|
|
7151
|
+
u(
|
|
7152
7152
|
(n) => n.map(
|
|
7153
|
-
(
|
|
7153
|
+
(f) => f.id === t.id ? { ...f, imageLoading: !1 } : f
|
|
7154
7154
|
)
|
|
7155
7155
|
);
|
|
7156
7156
|
}, r.src = t.src, e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading QR...", t.width / 2, t.height / 2);
|
|
@@ -7172,23 +7172,23 @@ const xi = _e((d, o) => {
|
|
|
7172
7172
|
}
|
|
7173
7173
|
e.font = `${t.fontStyle || "normal"} ${t.fontWeight || "normal"} ${t.fontSize || 20}px ${t.fontFamily || "Arial"}`, e.fillStyle = t.fill || "#000000", e.textAlign = t.textAlign || "left", e.textBaseline = "top", t.opacity !== void 0 && (e.globalAlpha = t.opacity), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth);
|
|
7174
7174
|
const n = r.split(`
|
|
7175
|
-
`),
|
|
7175
|
+
`), f = (t.fontSize || 20) * (t.lineHeight || 1.2), g = Math.max(...n.map((k) => e.measureText(k).width)), b = n.length * f;
|
|
7176
7176
|
if (t.backgroundColor && t.backgroundColor !== "transparent") {
|
|
7177
7177
|
e.fillStyle = t.backgroundColor;
|
|
7178
7178
|
const k = t.backgroundPadding || 4;
|
|
7179
7179
|
e.fillRect(
|
|
7180
7180
|
-k,
|
|
7181
7181
|
-k,
|
|
7182
|
-
|
|
7182
|
+
g + k * 2,
|
|
7183
7183
|
b + k * 2
|
|
7184
7184
|
), e.fillStyle = t.fill || "#000000";
|
|
7185
7185
|
}
|
|
7186
7186
|
n.forEach((k, v) => {
|
|
7187
|
-
const R = v *
|
|
7187
|
+
const R = v * f, D = e.measureText(k).width;
|
|
7188
7188
|
t.stroke && t.strokeWidth > 0 && e.strokeText(k, 0, R), e.fillText(k, 0, R);
|
|
7189
|
-
const
|
|
7189
|
+
const L = t.fontSize || 20, tt = t.decorationColor || t.fill || "#000000", xt = Math.max(1, L / 20);
|
|
7190
7190
|
if (e.strokeStyle = tt, e.lineWidth = xt, t.textDecoration === "underline" || t.underline) {
|
|
7191
|
-
const pt = R +
|
|
7191
|
+
const pt = R + L + 2;
|
|
7192
7192
|
e.beginPath(), e.moveTo(0, pt), e.lineTo(D, pt), e.stroke();
|
|
7193
7193
|
}
|
|
7194
7194
|
if (t.textDecoration === "overline" || t.overline) {
|
|
@@ -7196,13 +7196,13 @@ const xi = _e((d, o) => {
|
|
|
7196
7196
|
e.beginPath(), e.moveTo(0, pt), e.lineTo(D, pt), e.stroke();
|
|
7197
7197
|
}
|
|
7198
7198
|
if (t.textDecoration === "line-through" || t.strikethrough) {
|
|
7199
|
-
const pt = R +
|
|
7199
|
+
const pt = R + L / 2;
|
|
7200
7200
|
e.beginPath(), e.moveTo(0, pt), e.lineTo(D, pt), e.stroke();
|
|
7201
7201
|
}
|
|
7202
|
-
typeof t.textDecoration == "string" && t.textDecoration.includes(" ") && t.textDecoration.split(" ").forEach((
|
|
7203
|
-
switch (
|
|
7202
|
+
typeof t.textDecoration == "string" && t.textDecoration.includes(" ") && t.textDecoration.split(" ").forEach((Ge) => {
|
|
7203
|
+
switch (Ge.trim()) {
|
|
7204
7204
|
case "underline":
|
|
7205
|
-
const ee = R +
|
|
7205
|
+
const ee = R + L + 2;
|
|
7206
7206
|
e.beginPath(), e.moveTo(0, ee), e.lineTo(D, ee), e.stroke();
|
|
7207
7207
|
break;
|
|
7208
7208
|
case "overline":
|
|
@@ -7210,7 +7210,7 @@ const xi = _e((d, o) => {
|
|
|
7210
7210
|
e.beginPath(), e.moveTo(0, ie), e.lineTo(D, ie), e.stroke();
|
|
7211
7211
|
break;
|
|
7212
7212
|
case "line-through":
|
|
7213
|
-
const oe = R +
|
|
7213
|
+
const oe = R + L / 2;
|
|
7214
7214
|
e.beginPath(), e.moveTo(0, oe), e.lineTo(D, oe), e.stroke();
|
|
7215
7215
|
break;
|
|
7216
7216
|
}
|
|
@@ -7219,112 +7219,118 @@ const xi = _e((d, o) => {
|
|
|
7219
7219
|
}, be = (e, t) => {
|
|
7220
7220
|
t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fillRect(0, 0, t.width, t.height)), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.strokeRect(0, 0, t.width, t.height));
|
|
7221
7221
|
}, ve = (e, t) => {
|
|
7222
|
-
const r = Math.min(t.width, t.height) / 2, n = t.width / 2,
|
|
7223
|
-
e.beginPath(), e.arc(n,
|
|
7222
|
+
const r = Math.min(t.width, t.height) / 2, n = t.width / 2, f = t.height / 2;
|
|
7223
|
+
e.beginPath(), e.arc(n, f, r, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7224
7224
|
}, ke = (e, t) => {
|
|
7225
7225
|
const r = t.width / 2;
|
|
7226
7226
|
t.height / 2, e.beginPath(), e.moveTo(r, 0), e.lineTo(0, t.height), e.lineTo(t.width, t.height), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7227
7227
|
}, Se = (e, t) => {
|
|
7228
|
-
const r = t.width / 2, n = t.height / 2,
|
|
7228
|
+
const r = t.width / 2, n = t.height / 2, f = Math.min(t.width, t.height) / 2, g = f * 0.4, b = t.numPoints || 5;
|
|
7229
7229
|
e.beginPath();
|
|
7230
7230
|
for (let k = 0; k < b * 2; k++) {
|
|
7231
|
-
const v = k % 2 === 0 ?
|
|
7232
|
-
k === 0 ? e.moveTo(D,
|
|
7231
|
+
const v = k % 2 === 0 ? f : g, R = k * Math.PI / b, D = r + Math.cos(R) * v, L = n + Math.sin(R) * v;
|
|
7232
|
+
k === 0 ? e.moveTo(D, L) : e.lineTo(D, L);
|
|
7233
7233
|
}
|
|
7234
7234
|
e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7235
7235
|
}, Fe = (e, t) => {
|
|
7236
|
-
const r = t.width, n = t.height,
|
|
7237
|
-
e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, n * 0.6), e.lineTo(r -
|
|
7236
|
+
const r = t.width, n = t.height, f = r * 0.3;
|
|
7237
|
+
e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, n * 0.6), e.lineTo(r - f, n * 0.6), e.lineTo(r - f, n), e.lineTo(f, n), e.lineTo(f, n * 0.6), e.lineTo(0, n * 0.6), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7238
7238
|
}, Ce = (e, t) => {
|
|
7239
7239
|
const r = t.width / 2, n = t.height / 2;
|
|
7240
7240
|
e.beginPath(), e.moveTo(r, 0), e.lineTo(t.width, n), e.lineTo(r, t.height), e.lineTo(0, n), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7241
7241
|
}, Te = (e, t) => {
|
|
7242
|
-
const r = t.width / 2, n = t.height / 2,
|
|
7242
|
+
const r = t.width / 2, n = t.height / 2, f = Math.min(t.width, t.height) / 2, g = 6;
|
|
7243
7243
|
e.beginPath();
|
|
7244
|
-
for (let b = 0; b <
|
|
7245
|
-
const k = b * 2 * Math.PI /
|
|
7244
|
+
for (let b = 0; b < g; b++) {
|
|
7245
|
+
const k = b * 2 * Math.PI / g - Math.PI / 2, v = r + f * Math.cos(k), R = n + f * Math.sin(k);
|
|
7246
7246
|
b === 0 ? e.moveTo(v, R) : e.lineTo(v, R);
|
|
7247
7247
|
}
|
|
7248
7248
|
e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7249
7249
|
}, je = (e, t) => {
|
|
7250
|
-
const r = t.width / 2, n = t.height / 2,
|
|
7250
|
+
const r = t.width / 2, n = t.height / 2, f = Math.min(t.width, t.height) / 2, g = 5;
|
|
7251
7251
|
e.beginPath();
|
|
7252
|
-
for (let b = 0; b <
|
|
7253
|
-
const k = b * 2 * Math.PI /
|
|
7252
|
+
for (let b = 0; b < g; b++) {
|
|
7253
|
+
const k = b * 2 * Math.PI / g - Math.PI / 2, v = r + f * Math.cos(k), R = n + f * Math.sin(k);
|
|
7254
7254
|
b === 0 ? e.moveTo(v, R) : e.lineTo(v, R);
|
|
7255
7255
|
}
|
|
7256
7256
|
e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7257
7257
|
}, Ne = (e, t) => {
|
|
7258
|
-
const r = t.width, n = t.height,
|
|
7258
|
+
const r = t.width, n = t.height, f = 0, g = 0;
|
|
7259
7259
|
e.beginPath();
|
|
7260
7260
|
const b = n * 0.3;
|
|
7261
|
-
e.moveTo(
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7261
|
+
e.moveTo(f + r / 2, g + b), e.bezierCurveTo(
|
|
7262
|
+
f + r / 2,
|
|
7263
|
+
g,
|
|
7264
|
+
f,
|
|
7265
|
+
g,
|
|
7266
|
+
f,
|
|
7267
|
+
g + b
|
|
7268
7268
|
), e.bezierCurveTo(
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
|
|
7269
|
+
f,
|
|
7270
|
+
g + (n + b) / 2,
|
|
7271
|
+
f + r / 2,
|
|
7272
|
+
g + (n + b) / 2,
|
|
7273
|
+
f + r / 2,
|
|
7274
|
+
g + n
|
|
7275
7275
|
), e.bezierCurveTo(
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7276
|
+
f + r / 2,
|
|
7277
|
+
g + (n + b) / 2,
|
|
7278
|
+
f + r,
|
|
7279
|
+
g + (n + b) / 2,
|
|
7280
|
+
f + r,
|
|
7281
|
+
g + b
|
|
7282
7282
|
), e.bezierCurveTo(
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7283
|
+
f + r,
|
|
7284
|
+
g,
|
|
7285
|
+
f + r / 2,
|
|
7286
|
+
g,
|
|
7287
|
+
f + r / 2,
|
|
7288
|
+
g + b
|
|
7289
7289
|
), e.closePath(), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7290
7290
|
}, Ie = (e, t) => {
|
|
7291
|
-
const r = t.width / 2, n = t.height / 2,
|
|
7292
|
-
e.beginPath(), e.ellipse(r, n,
|
|
7291
|
+
const r = t.width / 2, n = t.height / 2, f = t.width / 2, g = t.height / 2;
|
|
7292
|
+
e.beginPath(), e.ellipse(r, n, f, g, 0, 0, 2 * Math.PI), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7293
7293
|
}, Ae = (e, t) => {
|
|
7294
7294
|
const r = Math.min(t.width, t.height) * 0.1;
|
|
7295
7295
|
At(e, 0, 0, t.width, t.height, r), t.fill && t.fill !== "transparent" && (e.fillStyle = t.fill, e.fill()), t.stroke && t.strokeWidth > 0 && (e.strokeStyle = t.stroke, e.lineWidth = t.strokeWidth, e.stroke());
|
|
7296
7296
|
}, Re = (e, t) => {
|
|
7297
7297
|
e.save(), t.opacity !== void 0 && (e.globalAlpha = t.opacity), e.strokeStyle = t.stroke || t.fill || "#000000", e.lineWidth = t.strokeWidth || t.height || 2, e.lineCap = "round", e.beginPath(), e.moveTo(0, t.height / 2), e.lineTo(t.width, t.height / 2), e.stroke(), e.restore();
|
|
7298
|
-
}, De = (e, t) => {
|
|
7299
|
-
const
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
if (t._imageElement || (t._imageElement = new Image(), t._imageElement.crossOrigin = "anonymous", t._imageElement.onload = () => {
|
|
7309
|
-
X();
|
|
7310
|
-
}, t._imageElement.onerror = () => {
|
|
7311
|
-
console.error("Failed to load image:", r), t._imageLoadError = !0, X();
|
|
7312
|
-
}, t._imageElement.src = r), t._imageElement.complete && t._imageElement.naturalWidth > 0 && t._imageElement.naturalHeight > 0) {
|
|
7313
|
-
e.drawImage(t._imageElement, 0, 0, t.width, t.height);
|
|
7314
|
-
return;
|
|
7315
|
-
}
|
|
7316
|
-
if (t._imageLoadError) {
|
|
7317
|
-
e.fillStyle = "#ffebee", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#f44336", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#f44336", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Error loading image", t.width / 2, t.height / 2);
|
|
7318
|
-
return;
|
|
7319
|
-
}
|
|
7320
|
-
}
|
|
7321
|
-
e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.lineWidth = 1, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2);
|
|
7322
|
-
} catch (n) {
|
|
7323
|
-
console.error("Error drawing image:", n), e.fillStyle = "#ffebee", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#f44336", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#f44336", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Error loading image", t.width / 2, t.height / 2);
|
|
7298
|
+
}, De = nt(/* @__PURE__ */ new Map()), Ee = (e, t) => {
|
|
7299
|
+
const n = (() => {
|
|
7300
|
+
if (typeof t.src == "string" && t.src.length > 0) return t.src;
|
|
7301
|
+
const f = t.imageData;
|
|
7302
|
+
return f instanceof HTMLImageElement || typeof f == "string" && f.length > 0 ? f : f && typeof f == "object" && typeof f.src == "string" && f.src.length > 0 ? f.src : null;
|
|
7303
|
+
})();
|
|
7304
|
+
if (n instanceof HTMLImageElement) {
|
|
7305
|
+
if (n.complete && n.naturalWidth > 0 && n.naturalHeight > 0) {
|
|
7306
|
+
e.drawImage(n, 0, 0, t.width, t.height);
|
|
7307
|
+
return;
|
|
7324
7308
|
}
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7309
|
+
e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2);
|
|
7310
|
+
return;
|
|
7311
|
+
}
|
|
7312
|
+
if (typeof n == "string" && n.length > 0) {
|
|
7313
|
+
const f = De.current;
|
|
7314
|
+
let g = f.get(t.id);
|
|
7315
|
+
if (g || (g = { img: null, error: null, loading: !1, src: n }, f.set(t.id, g)), g.src !== n && (g.img = null, g.error = null, g.loading = !1, g.src = n), g.img && g.img.complete && g.img.naturalWidth > 0 && g.img.naturalHeight > 0) {
|
|
7316
|
+
e.drawImage(g.img, 0, 0, t.width, t.height);
|
|
7317
|
+
return;
|
|
7318
|
+
}
|
|
7319
|
+
if (!g.loading && !g.error) {
|
|
7320
|
+
g.loading = !0;
|
|
7321
|
+
const b = new Image();
|
|
7322
|
+
n.startsWith("data:") || (b.crossOrigin = "anonymous"), b.onload = () => {
|
|
7323
|
+
g.img = b, g.loading = !1, X();
|
|
7324
|
+
}, b.onerror = () => {
|
|
7325
|
+
g.error = !0, g.loading = !1, console.error("Failed to load image:", n), X();
|
|
7326
|
+
}, b.src = n, typeof b.decode == "function" && b.decode().catch(() => {
|
|
7327
|
+
});
|
|
7328
|
+
}
|
|
7329
|
+
g.error ? (e.fillStyle = "#ffebee", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#f44336", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#f44336", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Error loading image", t.width / 2, t.height / 2)) : (e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.lineWidth = 1, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("Loading...", t.width / 2, t.height / 2));
|
|
7330
|
+
return;
|
|
7331
|
+
}
|
|
7332
|
+
e.fillStyle = "#f8f8f8", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ddd", e.lineWidth = 1, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#999", e.font = "14px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("No Image", t.width / 2, t.height / 2);
|
|
7333
|
+
}, Be = (e, t) => {
|
|
7328
7334
|
if (t.src && !t.imageLoading && !t.loadedImage) {
|
|
7329
7335
|
t.imageLoading = !0;
|
|
7330
7336
|
const r = new Image();
|
|
@@ -7334,7 +7340,7 @@ const xi = _e((d, o) => {
|
|
|
7334
7340
|
console.error("Failed to load sticker:", t.src), t.imageLoading = !1, e.fillStyle = "#f0f0f0", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ccc", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#666", e.font = "12px Arial", e.textAlign = "center", e.fillText("Failed to load", t.width / 2, t.height / 2);
|
|
7335
7341
|
}, r.src = t.src;
|
|
7336
7342
|
} else t.loadedImage ? e.drawImage(t.loadedImage, 0, 0, t.width, t.height) : t.imageLoading && (e.fillStyle = "#f8f9fa", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#dee2e6", e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#6c757d", e.font = "12px Arial", e.textAlign = "center", e.fillText("Loading...", t.width / 2, t.height / 2));
|
|
7337
|
-
},
|
|
7343
|
+
}, ze = (e, t) => {
|
|
7338
7344
|
if (t.imageObject && t.imageObject.complete && t.imageObject.naturalHeight !== 0)
|
|
7339
7345
|
try {
|
|
7340
7346
|
e.drawImage(t.imageObject, 0, 0, t.width, t.height);
|
|
@@ -7354,9 +7360,9 @@ const xi = _e((d, o) => {
|
|
|
7354
7360
|
e.fillStyle = "#f9f9f9", e.fillRect(0, 0, t.width, t.height), e.strokeStyle = "#ddd", e.lineWidth = 2, e.strokeRect(0, 0, t.width, t.height), e.fillStyle = "#999", e.font = "24px Arial", e.textAlign = "center", e.textBaseline = "middle", e.fillText("🧵", t.width / 2, t.height / 2 - 10), e.fillStyle = "#666", e.font = "12px Arial", e.fillText(r, t.width / 2, t.height / 2 + 15);
|
|
7355
7361
|
}, Gt = (e, t, r) => {
|
|
7356
7362
|
if (!r) return !1;
|
|
7357
|
-
const n = r.x + r.width / 2,
|
|
7358
|
-
return D >= -tt && D <= tt &&
|
|
7359
|
-
},
|
|
7363
|
+
const n = r.x + r.width / 2, f = r.y + r.height / 2, g = e - n, b = t - f, k = -(r.rotation || 0) * Math.PI / 180, v = Math.cos(k), R = Math.sin(k), D = g * v - b * R, L = g * R + b * v, tt = r.width / 2, xt = r.height / 2;
|
|
7364
|
+
return D >= -tt && D <= tt && L >= -xt && L <= xt;
|
|
7365
|
+
}, We = ot(() => {
|
|
7360
7366
|
(C || I || w) && lt(), p(!1), T(!1), z(!1), B(null);
|
|
7361
7367
|
const e = gt.current;
|
|
7362
7368
|
e && (e.style.cursor = "default");
|
|
@@ -7365,32 +7371,32 @@ const xi = _e((d, o) => {
|
|
|
7365
7371
|
const e = (t) => {
|
|
7366
7372
|
if (l) return;
|
|
7367
7373
|
const r = document.activeElement;
|
|
7368
|
-
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(), Ft()) : (t.key === "z" && t.shiftKey || t.key === "y") && (t.preventDefault(), bt())), (t.key === "Delete" || t.key === "Backspace") &&
|
|
7374
|
+
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(), Ft()) : (t.key === "z" && t.shiftKey || t.key === "y") && (t.preventDefault(), bt())), (t.key === "Delete" || t.key === "Backspace") && x && (Wt(x.id), t.preventDefault()), (t.ctrlKey || t.metaKey) && t.key === "d" && x && (Yt(x.id), t.preventDefault()), x && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key))) {
|
|
7369
7375
|
t.preventDefault();
|
|
7370
|
-
const
|
|
7371
|
-
let
|
|
7376
|
+
const f = t.shiftKey ? 10 : 1;
|
|
7377
|
+
let g = {};
|
|
7372
7378
|
switch (t.key) {
|
|
7373
7379
|
case "ArrowUp":
|
|
7374
|
-
|
|
7380
|
+
g.y = x.y - f;
|
|
7375
7381
|
break;
|
|
7376
7382
|
case "ArrowDown":
|
|
7377
|
-
|
|
7383
|
+
g.y = x.y + f;
|
|
7378
7384
|
break;
|
|
7379
7385
|
case "ArrowLeft":
|
|
7380
|
-
|
|
7386
|
+
g.x = x.x - f;
|
|
7381
7387
|
break;
|
|
7382
7388
|
case "ArrowRight":
|
|
7383
|
-
|
|
7389
|
+
g.x = x.x + f;
|
|
7384
7390
|
break;
|
|
7385
7391
|
}
|
|
7386
|
-
_t(
|
|
7392
|
+
_t(x.id, g), lt();
|
|
7387
7393
|
}
|
|
7388
7394
|
};
|
|
7389
7395
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
7390
|
-
}, [
|
|
7391
|
-
const
|
|
7396
|
+
}, [x, Ft, bt, l]);
|
|
7397
|
+
const Me = (e, t = {}) => {
|
|
7392
7398
|
const r = {
|
|
7393
|
-
id:
|
|
7399
|
+
id: dt(),
|
|
7394
7400
|
type: e,
|
|
7395
7401
|
x: 50,
|
|
7396
7402
|
y: 50,
|
|
@@ -7404,28 +7410,28 @@ const xi = _e((d, o) => {
|
|
|
7404
7410
|
};
|
|
7405
7411
|
switch (e) {
|
|
7406
7412
|
case "text":
|
|
7407
|
-
r.id =
|
|
7413
|
+
r.id = dt(), r.text = t.text || "New Text", r.fontSize = t.fontSize || 20, r.fontFamily = t.fontFamily || "Arial", r.fontWeight = t.fontWeight || "normal", r.fontStyle = t.fontStyle || "normal", r.textAlign = t.textAlign || "left", r.width = 150, r.height = 50;
|
|
7408
7414
|
break;
|
|
7409
7415
|
case "icon":
|
|
7410
|
-
r.id =
|
|
7416
|
+
r.id = dt(), r.text = t.text || "🎯", r.fontSize = t.fontSize || 48, r.fontFamily = t.fontFamily || "Arial", r.fontWeight = t.fontWeight || "normal", r.fontStyle = t.fontStyle || "normal", r.textAlign = "center", r.width = 80, r.height = 80, r.iconData = t.iconData || null, r.type = "text", r.isIcon = !0;
|
|
7411
7417
|
break;
|
|
7412
7418
|
case "image":
|
|
7413
|
-
r.id =
|
|
7419
|
+
r.id = dt(), r.imageData = t.imageData || null, r.width = t.width || 200, r.height = t.height || 200;
|
|
7414
7420
|
break;
|
|
7415
7421
|
case "qrcode":
|
|
7416
|
-
r.id =
|
|
7422
|
+
r.id = dt(), r.type = "qrcode", r.x = (t == null ? void 0 : t.x) || W / 2 - ((t == null ? void 0 : t.width) || 100) / 2, r.y = (t == null ? void 0 : t.y) || U / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 100, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.rotation = 0, r.opacity = 1;
|
|
7417
7423
|
break;
|
|
7418
7424
|
case "barcode":
|
|
7419
|
-
r.id =
|
|
7425
|
+
r.id = dt(), r.type = "barcode", r.x = (t == null ? void 0 : t.x) || W / 2 - ((t == null ? void 0 : t.width) || 200) / 2, r.y = (t == null ? void 0 : t.y) || U / 2 - ((t == null ? void 0 : t.height) || 100) / 2, r.width = (t == null ? void 0 : t.width) || 200, r.height = (t == null ? void 0 : t.height) || 100, r.src = (t == null ? void 0 : t.src) || "", r.data = (t == null ? void 0 : t.data) || "", r.format = (t == null ? void 0 : t.format) || "CODE128", r.rotation = 0, r.opacity = 1, r.imageObject = (t == null ? void 0 : t.imageObject) || null;
|
|
7420
7426
|
break;
|
|
7421
7427
|
case "sticker":
|
|
7422
|
-
r.id =
|
|
7428
|
+
r.id = dt(), r.type = "sticker", r.imageData = (t == null ? void 0 : t.imageData) || null, r.width = t.width || 200, r.height = t.height || 200;
|
|
7423
7429
|
break;
|
|
7424
7430
|
case "horizontalLine":
|
|
7425
|
-
r.id =
|
|
7431
|
+
r.id = dt(), r.type = "horizontalLine", r.x = W / 2 - 100, r.y = U / 2 - 1, r.width = 200, r.height = 2, r.fill = "#000000", r.stroke = "#000000", r.strokeWidth = 2, r.rotation = 0, r.opacity = 1;
|
|
7426
7432
|
break;
|
|
7427
7433
|
case "embroidery":
|
|
7428
|
-
r.id =
|
|
7434
|
+
r.id = dt(), r.type = "embroidery", r.imageData = (t == null ? void 0 : t.imageData) || null, r.width = t.width || 200, r.height = t.height || 200;
|
|
7429
7435
|
break;
|
|
7430
7436
|
case "rectangle":
|
|
7431
7437
|
case "circle":
|
|
@@ -7443,29 +7449,29 @@ const xi = _e((d, o) => {
|
|
|
7443
7449
|
console.warn(`Unknown element type: ${e}`);
|
|
7444
7450
|
return;
|
|
7445
7451
|
}
|
|
7446
|
-
|
|
7452
|
+
u((n) => [...n, r]), F(r), lt();
|
|
7447
7453
|
}, _t = (e, t) => {
|
|
7448
|
-
|
|
7454
|
+
u((r) => r.map(
|
|
7449
7455
|
(n) => n.id === e ? { ...n, ...t } : n
|
|
7450
|
-
)),
|
|
7456
|
+
)), x && x.id === e && F((r) => ({ ...r, ...t }));
|
|
7451
7457
|
}, Wt = ot(() => {
|
|
7452
|
-
|
|
7453
|
-
}, [
|
|
7458
|
+
x && (u((e) => e.filter((t) => t.id !== x.id)), F(null), lt());
|
|
7459
|
+
}, [x, lt]), Yt = (e) => {
|
|
7454
7460
|
const t = c.find((r) => r.id === e);
|
|
7455
7461
|
if (t) {
|
|
7456
7462
|
const r = {
|
|
7457
7463
|
...t,
|
|
7458
|
-
id:
|
|
7464
|
+
id: dt(),
|
|
7459
7465
|
x: t.x + 20,
|
|
7460
7466
|
y: t.y + 20
|
|
7461
7467
|
};
|
|
7462
|
-
|
|
7468
|
+
u((n) => [...n, r]), F(r), lt();
|
|
7463
7469
|
}
|
|
7464
7470
|
}, qt = (e, t) => {
|
|
7465
|
-
const r = c.findIndex((
|
|
7471
|
+
const r = c.findIndex((g) => g.id === e);
|
|
7466
7472
|
if (r === -1) return;
|
|
7467
|
-
const n = [...c],
|
|
7468
|
-
t === "up" && r < n.length - 1 ? (n[r] = n[r + 1], n[r + 1] =
|
|
7473
|
+
const n = [...c], f = n[r];
|
|
7474
|
+
t === "up" && r < n.length - 1 ? (n[r] = n[r + 1], n[r + 1] = f) : t === "down" && r > 0 ? (n[r] = n[r - 1], n[r - 1] = f) : t === "top" ? (n.splice(r, 1), n.push(f)) : t === "bottom" && (n.splice(r, 1), n.unshift(f)), u(n), lt();
|
|
7469
7475
|
};
|
|
7470
7476
|
ot(() => {
|
|
7471
7477
|
j && Z((e) => ({
|
|
@@ -7476,11 +7482,11 @@ const xi = _e((d, o) => {
|
|
|
7476
7482
|
}
|
|
7477
7483
|
}));
|
|
7478
7484
|
}, [j, c, Y]);
|
|
7479
|
-
const [, Le] =
|
|
7485
|
+
const [, Le] = qe((e) => e + 1, 0);
|
|
7480
7486
|
setTimeout(() => {
|
|
7481
7487
|
Le();
|
|
7482
7488
|
}, 20);
|
|
7483
|
-
const
|
|
7489
|
+
const Pe = ot(() => {
|
|
7484
7490
|
j && Z((e) => ({
|
|
7485
7491
|
...e,
|
|
7486
7492
|
[j.sectionName]: {
|
|
@@ -7489,9 +7495,9 @@ const xi = _e((d, o) => {
|
|
|
7489
7495
|
}
|
|
7490
7496
|
}));
|
|
7491
7497
|
}, [j, c, Y]);
|
|
7492
|
-
|
|
7498
|
+
Ve(o, () => ({
|
|
7493
7499
|
handleSectionChange: Vt,
|
|
7494
|
-
flushCurrentSectionDesign:
|
|
7500
|
+
flushCurrentSectionDesign: Pe,
|
|
7495
7501
|
// Export methods that return download-ready data
|
|
7496
7502
|
exportPrintReady: async (e = "png") => await zt(e, !1),
|
|
7497
7503
|
exportFullDesign: async (e = "png") => await zt(e, !0),
|
|
@@ -7507,18 +7513,18 @@ const xi = _e((d, o) => {
|
|
|
7507
7513
|
selectedColor: t.selectedColor,
|
|
7508
7514
|
canvasWidth: t.canvasWidth,
|
|
7509
7515
|
canvasHeight: t.canvasHeight
|
|
7510
|
-
},
|
|
7516
|
+
}, f = {
|
|
7511
7517
|
...t.sectionDesigns || {},
|
|
7512
7518
|
[r]: n
|
|
7513
|
-
},
|
|
7519
|
+
}, g = s.sections && s.sections.length > 0 ? s.sections : [{
|
|
7514
7520
|
id: r,
|
|
7515
7521
|
sectionName: r,
|
|
7516
7522
|
image: j == null ? void 0 : j.sectionImage,
|
|
7517
7523
|
sectionImage: j == null ? void 0 : j.sectionImage
|
|
7518
7524
|
}];
|
|
7519
7525
|
return await Et.current.exportAllSectionsAsJSON(
|
|
7520
|
-
|
|
7521
|
-
|
|
7526
|
+
f,
|
|
7527
|
+
g,
|
|
7522
7528
|
W,
|
|
7523
7529
|
U,
|
|
7524
7530
|
e,
|
|
@@ -7537,140 +7543,140 @@ const xi = _e((d, o) => {
|
|
|
7537
7543
|
}
|
|
7538
7544
|
}
|
|
7539
7545
|
}));
|
|
7540
|
-
const
|
|
7546
|
+
const ut = nt(null), Mt = nt(!1), X = ot(() => {
|
|
7541
7547
|
const e = gt.current;
|
|
7542
|
-
if (!e ||
|
|
7543
|
-
|
|
7548
|
+
if (!e || Mt.current) return;
|
|
7549
|
+
Mt.current = !0;
|
|
7544
7550
|
const t = e.getContext("2d");
|
|
7545
7551
|
t.clearRect(0, 0, W, U), wt.current && t.drawImage(wt.current, 0, 0, W, U), J && ye(t), c.forEach((r) => {
|
|
7546
|
-
t.save(), t.globalAlpha = r.opacity || 1,
|
|
7547
|
-
}),
|
|
7548
|
-
}, [c,
|
|
7549
|
-
|
|
7550
|
-
X(),
|
|
7552
|
+
t.save(), t.globalAlpha = r.opacity || 1, ue(t, r), t.restore();
|
|
7553
|
+
}), x && he(t, x), Mt.current = !1;
|
|
7554
|
+
}, [c, x, W, U, J]), vt = ot(() => {
|
|
7555
|
+
ut.current && cancelAnimationFrame(ut.current), ut.current = requestAnimationFrame(() => {
|
|
7556
|
+
X(), ut.current = null;
|
|
7551
7557
|
});
|
|
7552
7558
|
}, [X]);
|
|
7553
7559
|
et(() => {
|
|
7554
7560
|
vt();
|
|
7555
|
-
}, [c,
|
|
7561
|
+
}, [c, x, W, U, J, vt]), et(() => {
|
|
7556
7562
|
wt.current && vt();
|
|
7557
7563
|
}, [wt.current, vt]), et(() => () => {
|
|
7558
|
-
|
|
7564
|
+
ut.current && cancelAnimationFrame(ut.current);
|
|
7559
7565
|
}, []);
|
|
7560
|
-
const
|
|
7561
|
-
X(), (C || I || w) && (
|
|
7566
|
+
const Lt = ot(() => {
|
|
7567
|
+
X(), (C || I || w) && (ut.current = requestAnimationFrame(Lt));
|
|
7562
7568
|
}, [X, C, I, w]);
|
|
7563
7569
|
et(() => {
|
|
7564
|
-
C || I || w ?
|
|
7565
|
-
}, [C, I, w,
|
|
7566
|
-
const
|
|
7570
|
+
C || I || w ? Lt() : (ut.current && (cancelAnimationFrame(ut.current), ut.current = null), vt());
|
|
7571
|
+
}, [C, I, w, Lt, vt]);
|
|
7572
|
+
const Ue = ot((e) => {
|
|
7567
7573
|
if (l) return;
|
|
7568
|
-
const r = gt.current.getBoundingClientRect(), n = (e.clientX - r.left) / q,
|
|
7569
|
-
if (S({ x: n, y:
|
|
7570
|
-
const b = Ht(n,
|
|
7574
|
+
const r = gt.current.getBoundingClientRect(), n = (e.clientX - r.left) / q, f = (e.clientY - r.top) / q;
|
|
7575
|
+
if (S({ x: n, y: f }), x) {
|
|
7576
|
+
const b = Ht(n, f, x);
|
|
7571
7577
|
if (b) {
|
|
7572
7578
|
if (b === "rotate") {
|
|
7573
7579
|
z(!0);
|
|
7574
|
-
const k =
|
|
7580
|
+
const k = x.x + x.width / 2, v = x.y + x.height / 2, R = Math.atan2(f - v, n - k) * 180 / Math.PI;
|
|
7575
7581
|
S({
|
|
7576
7582
|
x: n,
|
|
7577
|
-
y:
|
|
7583
|
+
y: f,
|
|
7578
7584
|
initialAngle: R,
|
|
7579
|
-
initialRotation:
|
|
7585
|
+
initialRotation: x.rotation || 0
|
|
7580
7586
|
});
|
|
7581
7587
|
} else
|
|
7582
7588
|
T(!0), B(b), S({
|
|
7583
7589
|
x: n,
|
|
7584
|
-
y:
|
|
7585
|
-
initialWidth:
|
|
7586
|
-
initialHeight:
|
|
7587
|
-
initialX:
|
|
7588
|
-
initialY:
|
|
7590
|
+
y: f,
|
|
7591
|
+
initialWidth: x.width,
|
|
7592
|
+
initialHeight: x.height,
|
|
7593
|
+
initialX: x.x,
|
|
7594
|
+
initialY: x.y
|
|
7589
7595
|
});
|
|
7590
7596
|
return;
|
|
7591
7597
|
}
|
|
7592
7598
|
}
|
|
7593
|
-
let
|
|
7599
|
+
let g = null;
|
|
7594
7600
|
for (let b = c.length - 1; b >= 0; b--)
|
|
7595
|
-
if (Gt(n,
|
|
7596
|
-
|
|
7601
|
+
if (Gt(n, f, c[b])) {
|
|
7602
|
+
g = c[b];
|
|
7597
7603
|
break;
|
|
7598
7604
|
}
|
|
7599
|
-
|
|
7605
|
+
g ? (F(g), p(!0), S({
|
|
7600
7606
|
x: n,
|
|
7601
|
-
y:
|
|
7602
|
-
offsetX: n -
|
|
7603
|
-
offsetY:
|
|
7607
|
+
y: f,
|
|
7608
|
+
offsetX: n - g.x,
|
|
7609
|
+
offsetY: f - g.y
|
|
7604
7610
|
})) : F(null), X();
|
|
7605
|
-
}, [l, q,
|
|
7611
|
+
}, [l, q, x, c, X]), Oe = ot((e) => {
|
|
7606
7612
|
if (l) return;
|
|
7607
|
-
const t = gt.current, r = t.getBoundingClientRect(), n = (e.clientX - r.left) / q,
|
|
7608
|
-
if (
|
|
7609
|
-
const
|
|
7610
|
-
|
|
7613
|
+
const t = gt.current, r = t.getBoundingClientRect(), n = (e.clientX - r.left) / q, f = (e.clientY - r.top) / q;
|
|
7614
|
+
if (x && !C && !I && !w) {
|
|
7615
|
+
const g = Ht(n, f, x);
|
|
7616
|
+
g ? g === "rotate" ? t.style.cursor = "grab" : t.style.cursor = g : Gt(n, f, x) ? t.style.cursor = "move" : t.style.cursor = "default";
|
|
7611
7617
|
} else
|
|
7612
7618
|
t.style.cursor = C ? "grabbing" : "default";
|
|
7613
|
-
if (w &&
|
|
7614
|
-
const
|
|
7619
|
+
if (w && x) {
|
|
7620
|
+
const g = x.x + x.width / 2, b = x.y + x.height / 2, v = Math.atan2(f - b, n - g) * 180 / Math.PI - E.initialAngle;
|
|
7615
7621
|
let R = E.initialRotation + v;
|
|
7616
|
-
e.shiftKey && (R = Math.round(R / 15) * 15), R = (R % 360 + 360) % 360,
|
|
7622
|
+
e.shiftKey && (R = Math.round(R / 15) * 15), R = (R % 360 + 360) % 360, u(
|
|
7617
7623
|
(D) => D.map(
|
|
7618
|
-
(
|
|
7624
|
+
(L) => L.id === x.id ? { ...L, rotation: R } : L
|
|
7619
7625
|
)
|
|
7620
7626
|
), F((D) => ({ ...D, rotation: R })), X();
|
|
7621
7627
|
return;
|
|
7622
7628
|
}
|
|
7623
|
-
if (I &&
|
|
7624
|
-
const
|
|
7629
|
+
if (I && x && $) {
|
|
7630
|
+
const g = n - E.x, b = f - E.y;
|
|
7625
7631
|
let k = E.initialWidth, v = E.initialHeight, R = E.initialX, D = E.initialY;
|
|
7626
7632
|
switch ($) {
|
|
7627
7633
|
case "se-resize":
|
|
7628
|
-
k = Math.max(20, E.initialWidth +
|
|
7634
|
+
k = Math.max(20, E.initialWidth + g), v = Math.max(20, E.initialHeight + b);
|
|
7629
7635
|
break;
|
|
7630
7636
|
case "sw-resize":
|
|
7631
|
-
k = Math.max(20, E.initialWidth -
|
|
7637
|
+
k = Math.max(20, E.initialWidth - g), v = Math.max(20, E.initialHeight + b), R = E.initialX + (E.initialWidth - k);
|
|
7632
7638
|
break;
|
|
7633
7639
|
case "ne-resize":
|
|
7634
|
-
k = Math.max(20, E.initialWidth +
|
|
7640
|
+
k = Math.max(20, E.initialWidth + g), v = Math.max(20, E.initialHeight - b), D = E.initialY + (E.initialHeight - v);
|
|
7635
7641
|
break;
|
|
7636
7642
|
case "nw-resize":
|
|
7637
|
-
k = Math.max(20, E.initialWidth -
|
|
7643
|
+
k = Math.max(20, E.initialWidth - g), v = Math.max(20, E.initialHeight - b), R = E.initialX + (E.initialWidth - k), D = E.initialY + (E.initialHeight - v);
|
|
7638
7644
|
break;
|
|
7639
7645
|
}
|
|
7640
|
-
if (e.shiftKey &&
|
|
7646
|
+
if (e.shiftKey && x.type !== "text") {
|
|
7641
7647
|
const tt = E.initialWidth / E.initialHeight;
|
|
7642
7648
|
$.includes("e"), v = k / tt, $.includes("n") && (D = E.initialY + (E.initialHeight - v));
|
|
7643
7649
|
}
|
|
7644
|
-
|
|
7645
|
-
const
|
|
7646
|
-
...
|
|
7650
|
+
M && (R = mt(R), D = mt(D), k = mt(k), v = mt(v));
|
|
7651
|
+
const L = {
|
|
7652
|
+
...x,
|
|
7647
7653
|
x: R,
|
|
7648
7654
|
y: D,
|
|
7649
7655
|
width: k,
|
|
7650
7656
|
height: v
|
|
7651
7657
|
};
|
|
7652
|
-
|
|
7658
|
+
u(
|
|
7653
7659
|
(tt) => tt.map(
|
|
7654
|
-
(xt) => xt.id ===
|
|
7660
|
+
(xt) => xt.id === x.id ? L : xt
|
|
7655
7661
|
)
|
|
7656
|
-
), F(
|
|
7662
|
+
), F(L), X();
|
|
7657
7663
|
return;
|
|
7658
7664
|
}
|
|
7659
|
-
if (C &&
|
|
7660
|
-
let
|
|
7661
|
-
|
|
7665
|
+
if (C && x) {
|
|
7666
|
+
let g = n - E.offsetX, b = f - E.offsetY;
|
|
7667
|
+
M && (g = mt(g), b = mt(b)), g = Math.max(0, Math.min(W - x.width, g)), b = Math.max(0, Math.min(U - x.height, b));
|
|
7662
7668
|
const k = {
|
|
7663
|
-
...
|
|
7664
|
-
x:
|
|
7669
|
+
...x,
|
|
7670
|
+
x: g,
|
|
7665
7671
|
y: b
|
|
7666
7672
|
};
|
|
7667
|
-
|
|
7673
|
+
u(
|
|
7668
7674
|
(v) => v.map(
|
|
7669
|
-
(R) => R.id ===
|
|
7675
|
+
(R) => R.id === x.id ? k : R
|
|
7670
7676
|
)
|
|
7671
7677
|
), F(k), X();
|
|
7672
7678
|
}
|
|
7673
|
-
}, [l, q,
|
|
7679
|
+
}, [l, q, x, C, I, w, $, E, M, W, U, c, X]), Vt = ot((e) => {
|
|
7674
7680
|
j && Z((r) => ({
|
|
7675
7681
|
...r,
|
|
7676
7682
|
[j.sectionName]: {
|
|
@@ -7687,32 +7693,32 @@ const xi = _e((d, o) => {
|
|
|
7687
7693
|
if (t) {
|
|
7688
7694
|
const r = t.elements.map((n) => {
|
|
7689
7695
|
if (n.type === "image" && n.src && !n.imageData) {
|
|
7690
|
-
const
|
|
7691
|
-
return
|
|
7692
|
-
|
|
7693
|
-
(
|
|
7694
|
-
(b) => b.id === n.id ? { ...b, imageData:
|
|
7696
|
+
const f = new Image();
|
|
7697
|
+
return f.onload = () => {
|
|
7698
|
+
u(
|
|
7699
|
+
(g) => g.map(
|
|
7700
|
+
(b) => b.id === n.id ? { ...b, imageData: f } : b
|
|
7695
7701
|
)
|
|
7696
7702
|
), X();
|
|
7697
|
-
},
|
|
7703
|
+
}, f.src = n.src, { ...n, imageData: f };
|
|
7698
7704
|
}
|
|
7699
7705
|
return n;
|
|
7700
7706
|
});
|
|
7701
|
-
|
|
7707
|
+
u(r), O(t.selectedColor || Y);
|
|
7702
7708
|
} else
|
|
7703
|
-
|
|
7709
|
+
u([]);
|
|
7704
7710
|
m(e), F(null);
|
|
7705
|
-
}, [j, c, Y, _, X]),
|
|
7711
|
+
}, [j, c, Y, _, X]), Qe = ot((e) => {
|
|
7706
7712
|
if (e && e.type.startsWith("image/")) {
|
|
7707
7713
|
const t = new FileReader();
|
|
7708
7714
|
t.onload = (r) => {
|
|
7709
7715
|
const n = new Image();
|
|
7710
7716
|
n.onload = () => {
|
|
7711
|
-
const
|
|
7712
|
-
id:
|
|
7717
|
+
const f = {
|
|
7718
|
+
id: dt(),
|
|
7713
7719
|
type: "image",
|
|
7714
|
-
x:
|
|
7715
|
-
y:
|
|
7720
|
+
x: mt(W / 2 - 100),
|
|
7721
|
+
y: mt(U / 2 - 100),
|
|
7716
7722
|
width: Math.min(n.width, 200),
|
|
7717
7723
|
// Limit initial size
|
|
7718
7724
|
height: Math.min(n.height, 200),
|
|
@@ -7721,8 +7727,8 @@ const xi = _e((d, o) => {
|
|
|
7721
7727
|
src: r.target.result,
|
|
7722
7728
|
originalWidth: n.width,
|
|
7723
7729
|
originalHeight: n.height
|
|
7724
|
-
},
|
|
7725
|
-
|
|
7730
|
+
}, g = n.width / n.height;
|
|
7731
|
+
f.width / f.height !== g && (f.width / g <= 200 ? f.height = f.width / g : f.width = f.height * g), u((b) => [...b, f]), F(f), lt();
|
|
7726
7732
|
}, n.onerror = () => {
|
|
7727
7733
|
console.error("Failed to load uploaded image"), alert("Failed to load the uploaded image. Please try again.");
|
|
7728
7734
|
}, n.src = r.target.result;
|
|
@@ -7731,8 +7737,8 @@ const xi = _e((d, o) => {
|
|
|
7731
7737
|
}, t.readAsDataURL(e);
|
|
7732
7738
|
} else
|
|
7733
7739
|
alert("Please select a valid image file.");
|
|
7734
|
-
}, [W, U,
|
|
7735
|
-
|
|
7740
|
+
}, [W, U, mt, dt, lt]), Xt = ot(
|
|
7741
|
+
$e(() => {
|
|
7736
7742
|
X();
|
|
7737
7743
|
}, 16),
|
|
7738
7744
|
// 60fps limit
|
|
@@ -7740,14 +7746,14 @@ const xi = _e((d, o) => {
|
|
|
7740
7746
|
);
|
|
7741
7747
|
et(() => {
|
|
7742
7748
|
Bt.current || Xt();
|
|
7743
|
-
}, [c,
|
|
7744
|
-
function
|
|
7749
|
+
}, [c, x, J, Xt]);
|
|
7750
|
+
function $e(e, t) {
|
|
7745
7751
|
let r;
|
|
7746
|
-
return function(...
|
|
7747
|
-
const
|
|
7748
|
-
clearTimeout(r), e(...
|
|
7752
|
+
return function(...f) {
|
|
7753
|
+
const g = () => {
|
|
7754
|
+
clearTimeout(r), e(...f);
|
|
7749
7755
|
};
|
|
7750
|
-
clearTimeout(r), r = setTimeout(
|
|
7756
|
+
clearTimeout(r), r = setTimeout(g, t);
|
|
7751
7757
|
};
|
|
7752
7758
|
}
|
|
7753
7759
|
et(() => {
|
|
@@ -7755,21 +7761,21 @@ const xi = _e((d, o) => {
|
|
|
7755
7761
|
}, [Y]), et(() => {
|
|
7756
7762
|
X();
|
|
7757
7763
|
}, [X]);
|
|
7758
|
-
const
|
|
7764
|
+
const He = (e, t, r) => (0.2126 * e + 0.7152 * t + 0.0722 * r) / 255, Jt = ot((e, t) => {
|
|
7759
7765
|
const r = Ut.current, n = r.getContext("2d");
|
|
7760
7766
|
r.width = W, r.height = U, n.clearRect(0, 0, W, U), n.drawImage(e, 0, 0, W, U);
|
|
7761
|
-
const
|
|
7767
|
+
const f = n.getImageData(0, 0, W, U), g = f.data, b = xe(t);
|
|
7762
7768
|
if (!b) {
|
|
7763
7769
|
Bt.current = !1;
|
|
7764
7770
|
return;
|
|
7765
7771
|
}
|
|
7766
7772
|
const { r: k, g: v, b: R } = b;
|
|
7767
|
-
for (let
|
|
7768
|
-
if (
|
|
7769
|
-
const xt =
|
|
7770
|
-
|
|
7773
|
+
for (let L = 0; L < g.length; L += 4) {
|
|
7774
|
+
if (g[L + 3] === 0) continue;
|
|
7775
|
+
const xt = He(g[L], g[L + 1], g[L + 2]);
|
|
7776
|
+
g[L] = Math.round(k * xt), g[L + 1] = Math.round(v * xt), g[L + 2] = Math.round(R * xt);
|
|
7771
7777
|
}
|
|
7772
|
-
n.putImageData(
|
|
7778
|
+
n.putImageData(f, 0, 0);
|
|
7773
7779
|
const D = new Image();
|
|
7774
7780
|
D.onload = () => {
|
|
7775
7781
|
wt.current = s.plainColor === "Y" ? D : e, Bt.current = !1, X();
|
|
@@ -7779,9 +7785,9 @@ const xi = _e((d, o) => {
|
|
|
7779
7785
|
const t = document.querySelector(".ruler-horizontal"), r = document.querySelector(".ruler-vertical");
|
|
7780
7786
|
if (!t || !r)
|
|
7781
7787
|
return { horizontal: [], vertical: [] };
|
|
7782
|
-
const n = t.getBoundingClientRect(),
|
|
7783
|
-
for (let D = k; D <=
|
|
7784
|
-
D <=
|
|
7788
|
+
const n = t.getBoundingClientRect(), f = r.getBoundingClientRect(), g = n.width, b = f.height, k = 50, v = [], R = [];
|
|
7789
|
+
for (let D = k; D <= g; D += k)
|
|
7790
|
+
D <= g - 20 && v.push({
|
|
7785
7791
|
position: D,
|
|
7786
7792
|
value: Math.round(D / e)
|
|
7787
7793
|
});
|
|
@@ -7817,23 +7823,23 @@ const xi = _e((d, o) => {
|
|
|
7817
7823
|
}
|
|
7818
7824
|
}, [K, A, q]), /* @__PURE__ */ i.jsxs("div", { className: "pure-canvas-designer", children: [
|
|
7819
7825
|
/* @__PURE__ */ i.jsx("div", { className: "designer-header", children: /* @__PURE__ */ i.jsx(
|
|
7820
|
-
|
|
7826
|
+
di,
|
|
7821
7827
|
{
|
|
7822
|
-
onAddElement:
|
|
7823
|
-
onDeleteElement: () =>
|
|
7824
|
-
onDuplicateElement: () =>
|
|
7828
|
+
onAddElement: Me,
|
|
7829
|
+
onDeleteElement: () => x && Wt(x.id),
|
|
7830
|
+
onDuplicateElement: () => x && Yt(x.id),
|
|
7825
7831
|
onUndo: Ft,
|
|
7826
7832
|
onRedo: bt,
|
|
7827
7833
|
onToggleGrid: () => st(!J),
|
|
7828
7834
|
onToggleRulers: () => it(!K),
|
|
7829
|
-
onToggleSnap: () => G(!
|
|
7830
|
-
onImageUpload:
|
|
7835
|
+
onToggleSnap: () => G(!M),
|
|
7836
|
+
onImageUpload: Qe,
|
|
7831
7837
|
canUndo: H > 0,
|
|
7832
7838
|
canRedo: H < V.length - 1,
|
|
7833
7839
|
showGrid: J,
|
|
7834
7840
|
showRulers: K,
|
|
7835
|
-
snapToGrid:
|
|
7836
|
-
selectedElement:
|
|
7841
|
+
snapToGrid: M,
|
|
7842
|
+
selectedElement: x,
|
|
7837
7843
|
theme: a,
|
|
7838
7844
|
readOnly: l,
|
|
7839
7845
|
apiKey: d.apiKey,
|
|
@@ -7867,9 +7873,9 @@ const xi = _e((d, o) => {
|
|
|
7867
7873
|
ref: gt,
|
|
7868
7874
|
width: W,
|
|
7869
7875
|
height: U,
|
|
7870
|
-
onMouseDown:
|
|
7871
|
-
onMouseMove:
|
|
7872
|
-
onMouseUp:
|
|
7876
|
+
onMouseDown: Ue,
|
|
7877
|
+
onMouseMove: Oe,
|
|
7878
|
+
onMouseUp: We,
|
|
7873
7879
|
style: {
|
|
7874
7880
|
border: "1px solid #e2e8f0",
|
|
7875
7881
|
cursor: C ? "grabbing" : "default",
|
|
@@ -7880,9 +7886,9 @@ const xi = _e((d, o) => {
|
|
|
7880
7886
|
) }),
|
|
7881
7887
|
/* @__PURE__ */ i.jsxs("div", { className: "side-panels", children: [
|
|
7882
7888
|
/* @__PURE__ */ i.jsx(
|
|
7883
|
-
|
|
7889
|
+
fi,
|
|
7884
7890
|
{
|
|
7885
|
-
selectedElement:
|
|
7891
|
+
selectedElement: x,
|
|
7886
7892
|
onUpdate: _t,
|
|
7887
7893
|
onMoveLayer: qt,
|
|
7888
7894
|
availableFonts: fe,
|
|
@@ -7890,10 +7896,10 @@ const xi = _e((d, o) => {
|
|
|
7890
7896
|
}
|
|
7891
7897
|
),
|
|
7892
7898
|
/* @__PURE__ */ i.jsx(
|
|
7893
|
-
|
|
7899
|
+
hi,
|
|
7894
7900
|
{
|
|
7895
7901
|
elements: c,
|
|
7896
|
-
selectedElement:
|
|
7902
|
+
selectedElement: x,
|
|
7897
7903
|
onSelectElement: F,
|
|
7898
7904
|
onMoveLayer: qt,
|
|
7899
7905
|
onDeleteElement: Wt,
|
|
@@ -7916,7 +7922,7 @@ const xi = _e((d, o) => {
|
|
|
7916
7922
|
className: `section-thumbnail compact ${j.sectionName === e.sectionName ? "active" : ""}`,
|
|
7917
7923
|
onClick: (r) => {
|
|
7918
7924
|
r.stopPropagation();
|
|
7919
|
-
const n = s.sections.find((
|
|
7925
|
+
const n = s.sections.find((f) => f.sectionName === e.sectionName);
|
|
7920
7926
|
Vt(n);
|
|
7921
7927
|
},
|
|
7922
7928
|
title: e.sectionName,
|
|
@@ -8077,7 +8083,7 @@ const xi = _e((d, o) => {
|
|
|
8077
8083
|
] })
|
|
8078
8084
|
] });
|
|
8079
8085
|
});
|
|
8080
|
-
|
|
8086
|
+
yi.displayName = "Mypixia";
|
|
8081
8087
|
export {
|
|
8082
|
-
|
|
8088
|
+
yi as default
|
|
8083
8089
|
};
|