@mypixia/simplex-designer 2.0.0 → 2.0.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 +1060 -1020
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import './index_external.css';var
|
|
1
|
+
import We, { useState as N, useRef as xt, useEffect as it, useMemo as Xt, forwardRef as Me, useCallback as at, useReducer as Le, useImperativeHandle as Pe } from "react";
|
|
2
|
+
import Ue from "qrcode";
|
|
3
|
+
import Oe from "react-barcode";
|
|
4
|
+
import Jt from "axios";
|
|
5
|
+
import './index_external.css';var At = { exports: {} }, St = {};
|
|
6
6
|
/**
|
|
7
7
|
* @license React
|
|
8
8
|
* react-jsx-runtime.production.js
|
|
@@ -12,29 +12,29 @@ import './index_external.css';var Dt = { exports: {} }, Ft = {};
|
|
|
12
12
|
* This source code is licensed under the MIT license found in the
|
|
13
13
|
* LICENSE file in the root directory of this source tree.
|
|
14
14
|
*/
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
|
|
15
|
+
var Kt;
|
|
16
|
+
function Qe() {
|
|
17
|
+
if (Kt) return St;
|
|
18
|
+
Kt = 1;
|
|
19
19
|
var f = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
|
|
20
|
-
function a(
|
|
21
|
-
var
|
|
22
|
-
if (h !== void 0 && (
|
|
20
|
+
function a(n, s, h) {
|
|
21
|
+
var x = null;
|
|
22
|
+
if (h !== void 0 && (x = "" + h), s.key !== void 0 && (x = "" + s.key), "key" in s) {
|
|
23
23
|
h = {};
|
|
24
24
|
for (var l in s)
|
|
25
25
|
l !== "key" && (h[l] = s[l]);
|
|
26
26
|
} else h = s;
|
|
27
27
|
return s = h.ref, {
|
|
28
28
|
$$typeof: f,
|
|
29
|
-
type:
|
|
30
|
-
key:
|
|
29
|
+
type: n,
|
|
30
|
+
key: x,
|
|
31
31
|
ref: s !== void 0 ? s : null,
|
|
32
32
|
props: h
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
return
|
|
35
|
+
return St.Fragment = o, St.jsx = a, St.jsxs = a, St;
|
|
36
36
|
}
|
|
37
|
-
var
|
|
37
|
+
var Ft = {};
|
|
38
38
|
/**
|
|
39
39
|
* @license React
|
|
40
40
|
* react-jsx-runtime.development.js
|
|
@@ -44,24 +44,24 @@ var Ct = {};
|
|
|
44
44
|
* This source code is licensed under the MIT license found in the
|
|
45
45
|
* LICENSE file in the root directory of this source tree.
|
|
46
46
|
*/
|
|
47
|
-
var
|
|
48
|
-
function
|
|
49
|
-
return
|
|
47
|
+
var Zt;
|
|
48
|
+
function $e() {
|
|
49
|
+
return Zt || (Zt = 1, process.env.NODE_ENV !== "production" && function() {
|
|
50
50
|
function f(y) {
|
|
51
51
|
if (y == null) return null;
|
|
52
52
|
if (typeof y == "function")
|
|
53
|
-
return y.$$typeof ===
|
|
53
|
+
return y.$$typeof === $ ? null : y.displayName || y.name || null;
|
|
54
54
|
if (typeof y == "string") return y;
|
|
55
55
|
switch (y) {
|
|
56
56
|
case S:
|
|
57
57
|
return "Fragment";
|
|
58
|
-
case
|
|
58
|
+
case K:
|
|
59
59
|
return "Profiler";
|
|
60
|
-
case
|
|
60
|
+
case j:
|
|
61
61
|
return "StrictMode";
|
|
62
62
|
case st:
|
|
63
63
|
return "Suspense";
|
|
64
|
-
case
|
|
64
|
+
case W:
|
|
65
65
|
return "SuspenseList";
|
|
66
66
|
case ct:
|
|
67
67
|
return "Activity";
|
|
@@ -70,9 +70,9 @@ function Ve() {
|
|
|
70
70
|
switch (typeof y.tag == "number" && console.error(
|
|
71
71
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
72
72
|
), y.$$typeof) {
|
|
73
|
-
case
|
|
73
|
+
case z:
|
|
74
74
|
return "Portal";
|
|
75
|
-
case
|
|
75
|
+
case Q:
|
|
76
76
|
return (y.displayName || "Context") + ".Provider";
|
|
77
77
|
case C:
|
|
78
78
|
return (y._context.displayName || "Context") + ".Consumer";
|
|
@@ -102,15 +102,15 @@ function Ve() {
|
|
|
102
102
|
}
|
|
103
103
|
if (I) {
|
|
104
104
|
I = console;
|
|
105
|
-
var
|
|
106
|
-
return
|
|
105
|
+
var M = I.error, H = typeof Symbol == "function" && Symbol.toStringTag && y[Symbol.toStringTag] || y.constructor.name || "Object";
|
|
106
|
+
return M.call(
|
|
107
107
|
I,
|
|
108
108
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
109
109
|
H
|
|
110
110
|
), o(y);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function n(y) {
|
|
114
114
|
if (y === S) return "<>";
|
|
115
115
|
if (typeof y == "object" && y !== null && y.$$typeof === O)
|
|
116
116
|
return "<...>";
|
|
@@ -122,47 +122,47 @@ function Ve() {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
function s() {
|
|
125
|
-
var y =
|
|
125
|
+
var y = ot.A;
|
|
126
126
|
return y === null ? null : y.getOwner();
|
|
127
127
|
}
|
|
128
128
|
function h() {
|
|
129
129
|
return Error("react-stack-top-frame");
|
|
130
130
|
}
|
|
131
|
-
function
|
|
132
|
-
if (
|
|
131
|
+
function x(y) {
|
|
132
|
+
if (L.call(y, "key")) {
|
|
133
133
|
var I = Object.getOwnPropertyDescriptor(y, "key").get;
|
|
134
134
|
if (I && I.isReactWarning) return !1;
|
|
135
135
|
}
|
|
136
136
|
return y.key !== void 0;
|
|
137
137
|
}
|
|
138
138
|
function l(y, I) {
|
|
139
|
-
function
|
|
139
|
+
function M() {
|
|
140
140
|
nt || (nt = !0, console.error(
|
|
141
141
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
142
142
|
I
|
|
143
143
|
));
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
get:
|
|
145
|
+
M.isReactWarning = !0, Object.defineProperty(y, "key", {
|
|
146
|
+
get: M,
|
|
147
147
|
configurable: !0
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
|
-
function
|
|
150
|
+
function d() {
|
|
151
151
|
var y = f(this.type);
|
|
152
152
|
return _[y] || (_[y] = !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
|
)), y = this.props.ref, y !== void 0 ? y : null;
|
|
155
155
|
}
|
|
156
|
-
function F(y, I,
|
|
157
|
-
return
|
|
156
|
+
function F(y, I, M, H, G, tt, q, Y) {
|
|
157
|
+
return M = tt.ref, y = {
|
|
158
158
|
$$typeof: E,
|
|
159
159
|
type: y,
|
|
160
160
|
key: I,
|
|
161
|
-
props:
|
|
161
|
+
props: tt,
|
|
162
162
|
_owner: G
|
|
163
|
-
}, (
|
|
163
|
+
}, (M !== void 0 ? M : null) !== null ? Object.defineProperty(y, "ref", {
|
|
164
164
|
enumerable: !1,
|
|
165
|
-
get:
|
|
165
|
+
get: d
|
|
166
166
|
}) : Object.defineProperty(y, "ref", { enumerable: !1, value: null }), y._store = {}, Object.defineProperty(y._store, "validated", {
|
|
167
167
|
configurable: !1,
|
|
168
168
|
enumerable: !1,
|
|
@@ -185,25 +185,25 @@ function Ve() {
|
|
|
185
185
|
value: Y
|
|
186
186
|
}), Object.freeze && (Object.freeze(y.props), Object.freeze(y)), y;
|
|
187
187
|
}
|
|
188
|
-
function
|
|
189
|
-
var
|
|
190
|
-
if (
|
|
188
|
+
function T(y, I, M, H, G, tt, q, Y) {
|
|
189
|
+
var U = I.children;
|
|
190
|
+
if (U !== void 0)
|
|
191
191
|
if (H)
|
|
192
|
-
if (lt(
|
|
193
|
-
for (H = 0; H <
|
|
194
|
-
R(
|
|
195
|
-
Object.freeze && Object.freeze(
|
|
192
|
+
if (lt(U)) {
|
|
193
|
+
for (H = 0; H < U.length; H++)
|
|
194
|
+
R(U[H]);
|
|
195
|
+
Object.freeze && Object.freeze(U);
|
|
196
196
|
} else
|
|
197
197
|
console.error(
|
|
198
198
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
199
199
|
);
|
|
200
|
-
else R(
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
var
|
|
204
|
-
return
|
|
200
|
+
else R(U);
|
|
201
|
+
if (L.call(I, "key")) {
|
|
202
|
+
U = f(y);
|
|
203
|
+
var X = Object.keys(I).filter(function(ft) {
|
|
204
|
+
return ft !== "key";
|
|
205
205
|
});
|
|
206
|
-
H = 0 <
|
|
206
|
+
H = 0 < X.length ? "{key: someKey, " + X.join(": ..., ") + ": ...}" : "{key: someKey}", Z[U + H] || (X = 0 < X.length ? "{" + X.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} />
|
|
@@ -211,26 +211,26 @@ React keys must be passed directly to JSX without using spread:
|
|
|
211
211
|
let props = %s;
|
|
212
212
|
<%s key={someKey} {...props} />`,
|
|
213
213
|
H,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
),
|
|
214
|
+
U,
|
|
215
|
+
X,
|
|
216
|
+
U
|
|
217
|
+
), Z[U + H] = !0);
|
|
218
218
|
}
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
for (var
|
|
222
|
-
|
|
223
|
-
} else
|
|
224
|
-
return
|
|
225
|
-
|
|
219
|
+
if (U = null, M !== void 0 && (a(M), U = "" + M), x(I) && (a(I.key), U = "" + I.key), "key" in I) {
|
|
220
|
+
M = {};
|
|
221
|
+
for (var bt in I)
|
|
222
|
+
bt !== "key" && (M[bt] = I[bt]);
|
|
223
|
+
} else M = I;
|
|
224
|
+
return U && l(
|
|
225
|
+
M,
|
|
226
226
|
typeof y == "function" ? y.displayName || y.name || "Unknown" : y
|
|
227
227
|
), F(
|
|
228
228
|
y,
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
U,
|
|
230
|
+
tt,
|
|
231
231
|
G,
|
|
232
232
|
s(),
|
|
233
|
-
|
|
233
|
+
M,
|
|
234
234
|
q,
|
|
235
235
|
Y
|
|
236
236
|
);
|
|
@@ -238,51 +238,51 @@ React keys must be passed directly to JSX without using spread:
|
|
|
238
238
|
function R(y) {
|
|
239
239
|
typeof y == "object" && y !== null && y.$$typeof === E && y._store && (y._store.validated = 1);
|
|
240
240
|
}
|
|
241
|
-
var
|
|
241
|
+
var u = We, E = Symbol.for("react.transitional.element"), z = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), j = Symbol.for("react.strict_mode"), K = Symbol.for("react.profiler"), C = Symbol.for("react.consumer"), Q = Symbol.for("react.context"), k = Symbol.for("react.forward_ref"), st = Symbol.for("react.suspense"), W = Symbol.for("react.suspense_list"), ht = Symbol.for("react.memo"), O = Symbol.for("react.lazy"), ct = Symbol.for("react.activity"), $ = Symbol.for("react.client.reference"), ot = u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, lt = Array.isArray, J = console.createTask ? console.createTask : function() {
|
|
242
242
|
return null;
|
|
243
243
|
};
|
|
244
|
-
|
|
244
|
+
u = {
|
|
245
245
|
"react-stack-bottom-frame": function(y) {
|
|
246
246
|
return y();
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
|
-
var nt, _ = {},
|
|
250
|
-
|
|
249
|
+
var nt, _ = {}, P = u["react-stack-bottom-frame"].bind(
|
|
250
|
+
u,
|
|
251
251
|
h
|
|
252
|
-
)(),
|
|
253
|
-
|
|
254
|
-
var
|
|
255
|
-
return
|
|
252
|
+
)(), p = J(n(h)), Z = {};
|
|
253
|
+
Ft.Fragment = S, Ft.jsx = function(y, I, M, H, G) {
|
|
254
|
+
var tt = 1e4 > ot.recentlyCreatedOwnerStacks++;
|
|
255
|
+
return T(
|
|
256
256
|
y,
|
|
257
257
|
I,
|
|
258
|
-
|
|
258
|
+
M,
|
|
259
259
|
!1,
|
|
260
260
|
H,
|
|
261
261
|
G,
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
tt ? Error("react-stack-top-frame") : P,
|
|
263
|
+
tt ? J(n(y)) : p
|
|
264
264
|
);
|
|
265
|
-
},
|
|
266
|
-
var
|
|
267
|
-
return
|
|
265
|
+
}, Ft.jsxs = function(y, I, M, H, G) {
|
|
266
|
+
var tt = 1e4 > ot.recentlyCreatedOwnerStacks++;
|
|
267
|
+
return T(
|
|
268
268
|
y,
|
|
269
269
|
I,
|
|
270
|
-
|
|
270
|
+
M,
|
|
271
271
|
!0,
|
|
272
272
|
H,
|
|
273
273
|
G,
|
|
274
|
-
|
|
275
|
-
|
|
274
|
+
tt ? Error("react-stack-top-frame") : P,
|
|
275
|
+
tt ? J(n(y)) : p
|
|
276
276
|
);
|
|
277
277
|
};
|
|
278
|
-
}()),
|
|
278
|
+
}()), Ft;
|
|
279
279
|
}
|
|
280
|
-
var
|
|
281
|
-
function
|
|
282
|
-
return
|
|
280
|
+
var te;
|
|
281
|
+
function He() {
|
|
282
|
+
return te || (te = 1, process.env.NODE_ENV === "production" ? At.exports = Qe() : At.exports = $e()), At.exports;
|
|
283
283
|
}
|
|
284
|
-
var i =
|
|
285
|
-
const
|
|
284
|
+
var i = He();
|
|
285
|
+
const zt = {
|
|
286
286
|
business: {
|
|
287
287
|
name: "Business & Office",
|
|
288
288
|
icons: [
|
|
@@ -373,38 +373,38 @@ const Mt = {
|
|
|
373
373
|
{ name: "shield", symbol: "🛡️", unicode: "🛡️" }
|
|
374
374
|
]
|
|
375
375
|
}
|
|
376
|
-
},
|
|
376
|
+
}, ie = () => Object.values(zt).flatMap(
|
|
377
377
|
(f) => f.icons.map((o) => ({
|
|
378
378
|
...o,
|
|
379
379
|
category: f.name
|
|
380
380
|
}))
|
|
381
|
-
),
|
|
381
|
+
), Ge = (f) => ie().filter(
|
|
382
382
|
(a) => a.name.toLowerCase().includes(f.toLowerCase()) || a.category.toLowerCase().includes(f.toLowerCase())
|
|
383
|
-
),
|
|
384
|
-
const [a,
|
|
383
|
+
), _e = ({ onSelectIcon: f, disabled: o = !1 }) => {
|
|
384
|
+
const [a, n] = N(!1), [s, h] = N(""), [x, l] = N("all"), d = xt(null);
|
|
385
385
|
it(() => {
|
|
386
|
-
const
|
|
387
|
-
|
|
386
|
+
const u = (E) => {
|
|
387
|
+
d.current && !d.current.contains(E.target) && n(!1);
|
|
388
388
|
};
|
|
389
|
-
return document.addEventListener("mousedown",
|
|
389
|
+
return document.addEventListener("mousedown", u), () => document.removeEventListener("mousedown", u);
|
|
390
390
|
}, []);
|
|
391
|
-
const F = (
|
|
392
|
-
f(
|
|
391
|
+
const F = (u) => {
|
|
392
|
+
f(u), n(!1), h("");
|
|
393
393
|
}, R = (() => {
|
|
394
|
-
let
|
|
395
|
-
if (s.trim() && (
|
|
396
|
-
const E =
|
|
397
|
-
E && (
|
|
394
|
+
let u = ie();
|
|
395
|
+
if (s.trim() && (u = Ge(s)), x !== "all") {
|
|
396
|
+
const E = zt[x];
|
|
397
|
+
E && (u = u.filter((z) => z.category === E.name));
|
|
398
398
|
}
|
|
399
|
-
return
|
|
399
|
+
return u;
|
|
400
400
|
})();
|
|
401
|
-
return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref:
|
|
401
|
+
return /* @__PURE__ */ i.jsxs("div", { className: "icon-selector", ref: d, children: [
|
|
402
402
|
/* @__PURE__ */ i.jsxs(
|
|
403
403
|
"button",
|
|
404
404
|
{
|
|
405
405
|
className: "toolbar-btn dropdown-trigger",
|
|
406
406
|
disabled: o,
|
|
407
|
-
onClick: () =>
|
|
407
|
+
onClick: () => n(!a),
|
|
408
408
|
title: "Add Icon",
|
|
409
409
|
children: [
|
|
410
410
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "🎯" }),
|
|
@@ -421,35 +421,35 @@ const Mt = {
|
|
|
421
421
|
type: "text",
|
|
422
422
|
placeholder: "Search icons...",
|
|
423
423
|
value: s,
|
|
424
|
-
onChange: (
|
|
424
|
+
onChange: (u) => h(u.target.value),
|
|
425
425
|
className: "icon-search"
|
|
426
426
|
}
|
|
427
427
|
),
|
|
428
428
|
/* @__PURE__ */ i.jsxs(
|
|
429
429
|
"select",
|
|
430
430
|
{
|
|
431
|
-
value:
|
|
432
|
-
onChange: (
|
|
431
|
+
value: x,
|
|
432
|
+
onChange: (u) => l(u.target.value),
|
|
433
433
|
className: "category-select",
|
|
434
434
|
children: [
|
|
435
435
|
/* @__PURE__ */ i.jsx("option", { value: "all", children: "All Categories" }),
|
|
436
|
-
Object.entries(
|
|
436
|
+
Object.entries(zt).map(([u, E]) => /* @__PURE__ */ i.jsx("option", { value: u, children: E.name }, u))
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
)
|
|
440
440
|
] }),
|
|
441
|
-
/* @__PURE__ */ i.jsx("div", { className: "icon-grid", children: R.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-icons", children: s ? "No icons found" : "No icons in this category" }) : R.map((
|
|
441
|
+
/* @__PURE__ */ i.jsx("div", { className: "icon-grid", children: R.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-icons", children: s ? "No icons found" : "No icons in this category" }) : R.map((u, E) => /* @__PURE__ */ i.jsxs(
|
|
442
442
|
"button",
|
|
443
443
|
{
|
|
444
444
|
className: "icon-item",
|
|
445
|
-
onClick: () => F(
|
|
446
|
-
title: `${
|
|
445
|
+
onClick: () => F(u),
|
|
446
|
+
title: `${u.name} (${u.category})`,
|
|
447
447
|
children: [
|
|
448
|
-
/* @__PURE__ */ i.jsx("span", { className: "icon-symbol", children:
|
|
449
|
-
/* @__PURE__ */ i.jsx("span", { className: "icon-name", children:
|
|
448
|
+
/* @__PURE__ */ i.jsx("span", { className: "icon-symbol", children: u.symbol }),
|
|
449
|
+
/* @__PURE__ */ i.jsx("span", { className: "icon-name", children: u.name })
|
|
450
450
|
]
|
|
451
451
|
},
|
|
452
|
-
`${
|
|
452
|
+
`${u.name}-${E}`
|
|
453
453
|
)) }),
|
|
454
454
|
/* @__PURE__ */ i.jsx("div", { className: "icon-dropdown-footer", children: /* @__PURE__ */ i.jsxs("span", { className: "icon-count", children: [
|
|
455
455
|
R.length,
|
|
@@ -458,12 +458,12 @@ const Mt = {
|
|
|
458
458
|
] }) })
|
|
459
459
|
] })
|
|
460
460
|
] });
|
|
461
|
-
},
|
|
462
|
-
const [s, h] =
|
|
461
|
+
}, Ye = ({ isOpen: f, onClose: o, onAddQRCode: a, theme: n }) => {
|
|
462
|
+
const [s, h] = N(""), [x, l] = N(""), [d, F] = N(200), [T, R] = N("M"), u = () => {
|
|
463
463
|
if (!s.trim()) return;
|
|
464
464
|
const S = {
|
|
465
|
-
width:
|
|
466
|
-
errorCorrectionLevel:
|
|
465
|
+
width: d,
|
|
466
|
+
errorCorrectionLevel: T,
|
|
467
467
|
type: "image/png",
|
|
468
468
|
quality: 0.92,
|
|
469
469
|
margin: 1,
|
|
@@ -472,40 +472,40 @@ const Mt = {
|
|
|
472
472
|
light: "#FFFFFF"
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
|
-
|
|
476
|
-
if (
|
|
477
|
-
console.error("QR Code generation error:",
|
|
475
|
+
Ue.toDataURL(s, S, (j, K) => {
|
|
476
|
+
if (j) {
|
|
477
|
+
console.error("QR Code generation error:", j);
|
|
478
478
|
return;
|
|
479
479
|
}
|
|
480
|
-
l(
|
|
480
|
+
l(K);
|
|
481
481
|
});
|
|
482
482
|
}, E = () => {
|
|
483
|
-
if (!
|
|
483
|
+
if (!x) return;
|
|
484
484
|
const S = new Image();
|
|
485
485
|
S.onload = () => {
|
|
486
486
|
a({
|
|
487
487
|
type: "qrcode",
|
|
488
|
-
src:
|
|
488
|
+
src: x,
|
|
489
489
|
data: s,
|
|
490
|
-
width:
|
|
491
|
-
height:
|
|
490
|
+
width: d,
|
|
491
|
+
height: d,
|
|
492
492
|
x: 100,
|
|
493
493
|
y: 100,
|
|
494
494
|
imageObject: S
|
|
495
495
|
// Store the loaded image object
|
|
496
|
-
}),
|
|
497
|
-
}, S.src =
|
|
498
|
-
},
|
|
496
|
+
}), z();
|
|
497
|
+
}, S.src = x;
|
|
498
|
+
}, z = () => {
|
|
499
499
|
h(""), l(""), o();
|
|
500
500
|
};
|
|
501
|
-
return f ? /* @__PURE__ */ i.jsx("div", { className: "qr-modal-overlay", onClick:
|
|
501
|
+
return f ? /* @__PURE__ */ i.jsx("div", { className: "qr-modal-overlay", onClick: z, children: /* @__PURE__ */ i.jsxs("div", { className: "qr-modal-content", onClick: (S) => S.stopPropagation(), children: [
|
|
502
502
|
/* @__PURE__ */ i.jsxs("div", { className: "qr-modal-header", children: [
|
|
503
503
|
/* @__PURE__ */ i.jsx("h3", { children: "Generate QR Code" }),
|
|
504
504
|
/* @__PURE__ */ i.jsx(
|
|
505
505
|
"button",
|
|
506
506
|
{
|
|
507
507
|
className: "qr-modal-close",
|
|
508
|
-
onClick:
|
|
508
|
+
onClick: z,
|
|
509
509
|
"aria-label": "Close",
|
|
510
510
|
children: "×"
|
|
511
511
|
}
|
|
@@ -533,7 +533,7 @@ const Mt = {
|
|
|
533
533
|
{
|
|
534
534
|
type: "number",
|
|
535
535
|
id: "qr-size",
|
|
536
|
-
value:
|
|
536
|
+
value: d,
|
|
537
537
|
onChange: (S) => F(Math.max(50, Math.min(500, parseInt(S.target.value) || 200))),
|
|
538
538
|
min: "50",
|
|
539
539
|
max: "500"
|
|
@@ -546,7 +546,7 @@ const Mt = {
|
|
|
546
546
|
"select",
|
|
547
547
|
{
|
|
548
548
|
id: "qr-error-level",
|
|
549
|
-
value:
|
|
549
|
+
value: T,
|
|
550
550
|
onChange: (S) => R(S.target.value),
|
|
551
551
|
children: [
|
|
552
552
|
/* @__PURE__ */ i.jsx("option", { value: "L", children: "Low (7%)" }),
|
|
@@ -562,22 +562,22 @@ const Mt = {
|
|
|
562
562
|
"button",
|
|
563
563
|
{
|
|
564
564
|
className: "qr-btn qr-btn-generate",
|
|
565
|
-
onClick:
|
|
565
|
+
onClick: u,
|
|
566
566
|
disabled: !s.trim(),
|
|
567
567
|
children: "Generate QR Code"
|
|
568
568
|
}
|
|
569
569
|
) }),
|
|
570
|
-
|
|
570
|
+
x && /* @__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: x, alt: "QR Code Preview" }) }),
|
|
573
573
|
/* @__PURE__ */ i.jsx(
|
|
574
574
|
"button",
|
|
575
575
|
{
|
|
576
576
|
className: "qr-btn qr-btn-add",
|
|
577
577
|
onClick: E,
|
|
578
578
|
style: {
|
|
579
|
-
backgroundColor: (
|
|
580
|
-
borderColor: (
|
|
579
|
+
backgroundColor: (n == null ? void 0 : n.primaryColor) || "#3b82f6",
|
|
580
|
+
borderColor: (n == null ? void 0 : n.primaryColor) || "#3b82f6"
|
|
581
581
|
},
|
|
582
582
|
children: "Add to Canvas"
|
|
583
583
|
}
|
|
@@ -585,8 +585,8 @@ const Mt = {
|
|
|
585
585
|
] })
|
|
586
586
|
] })
|
|
587
587
|
] }) }) : null;
|
|
588
|
-
},
|
|
589
|
-
const [s, h] =
|
|
588
|
+
}, qe = ({ isOpen: f, onClose: o, onAddBarcode: a, theme: n }) => {
|
|
589
|
+
const [s, h] = N(""), [x, l] = N("CODE128"), [d, F] = N(null), [T, R] = N(2), [u, E] = N(100), [z, S] = N(20), [j, K] = N("center"), [C, Q] = N("bottom"), [k, st] = N(10), W = xt(null), ht = [
|
|
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)" },
|
|
@@ -600,58 +600,58 @@ const Mt = {
|
|
|
600
600
|
if (s.trim())
|
|
601
601
|
try {
|
|
602
602
|
F(/* @__PURE__ */ i.jsx(
|
|
603
|
-
|
|
603
|
+
Oe,
|
|
604
604
|
{
|
|
605
605
|
value: s,
|
|
606
|
-
format:
|
|
607
|
-
width:
|
|
608
|
-
height:
|
|
609
|
-
fontSize:
|
|
610
|
-
textAlign:
|
|
606
|
+
format: x,
|
|
607
|
+
width: T,
|
|
608
|
+
height: u,
|
|
609
|
+
fontSize: z,
|
|
610
|
+
textAlign: j,
|
|
611
611
|
textPosition: C,
|
|
612
612
|
margin: k,
|
|
613
613
|
background: "#ffffff",
|
|
614
614
|
lineColor: "#000000"
|
|
615
615
|
}
|
|
616
616
|
));
|
|
617
|
-
} catch (
|
|
618
|
-
console.error("Barcode generation error:",
|
|
617
|
+
} catch (L) {
|
|
618
|
+
console.error("Barcode generation error:", L), alert("Invalid data for selected barcode format. Please check your input.");
|
|
619
619
|
}
|
|
620
620
|
}, ct = () => {
|
|
621
|
-
var
|
|
622
|
-
if (!(!
|
|
621
|
+
var L, lt, J, nt;
|
|
622
|
+
if (!(!d || !W.current))
|
|
623
623
|
try {
|
|
624
|
-
const _ =
|
|
624
|
+
const _ = W.current.querySelector("svg");
|
|
625
625
|
if (!_) {
|
|
626
626
|
console.error("No SVG element found in barcode");
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
|
-
const
|
|
630
|
-
|
|
631
|
-
const
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
const q =
|
|
629
|
+
const P = document.createElement("canvas"), p = P.getContext("2d"), Z = _.getBoundingClientRect(), y = ((lt = (L = _.width) == null ? void 0 : L.baseVal) == null ? void 0 : lt.value) || Z.width || 200, I = ((nt = (J = _.height) == null ? void 0 : J.baseVal) == null ? void 0 : nt.value) || Z.height || 100;
|
|
630
|
+
P.width = y, P.height = I;
|
|
631
|
+
const M = new XMLSerializer().serializeToString(_), H = new Blob([M], { type: "image/svg+xml;charset=utf-8" }), G = URL.createObjectURL(H), tt = new Image();
|
|
632
|
+
tt.onload = () => {
|
|
633
|
+
p.drawImage(tt, 0, 0);
|
|
634
|
+
const q = P.toDataURL("image/png"), Y = new Image();
|
|
635
635
|
Y.onload = () => {
|
|
636
636
|
a({
|
|
637
637
|
type: "barcode",
|
|
638
638
|
src: q,
|
|
639
639
|
data: s,
|
|
640
|
-
format:
|
|
640
|
+
format: x,
|
|
641
641
|
width: y,
|
|
642
642
|
height: I,
|
|
643
643
|
x: 100,
|
|
644
644
|
y: 100,
|
|
645
645
|
imageObject: Y
|
|
646
|
-
}),
|
|
646
|
+
}), $();
|
|
647
647
|
}, Y.src = q, URL.revokeObjectURL(G);
|
|
648
|
-
},
|
|
648
|
+
}, tt.src = G;
|
|
649
649
|
} catch (_) {
|
|
650
650
|
console.error("Error adding barcode to canvas:", _), alert("Failed to add barcode to canvas. Please try again.");
|
|
651
651
|
}
|
|
652
|
-
},
|
|
652
|
+
}, $ = () => {
|
|
653
653
|
h(""), F(null), l("CODE128"), R(2), E(100), S(20), o();
|
|
654
|
-
},
|
|
654
|
+
}, ot = (L) => ({
|
|
655
655
|
CODE128: "Supports all ASCII characters. Most versatile format.",
|
|
656
656
|
EAN13: "Requires exactly 12 digits (13th is checksum). Used for retail products.",
|
|
657
657
|
EAN8: "Requires exactly 7 digits (8th is checksum). Compact version of EAN-13.",
|
|
@@ -661,15 +661,15 @@ const Mt = {
|
|
|
661
661
|
MSI: "Numeric only. Used in retail inventory.",
|
|
662
662
|
pharmacode: "Numbers 3-131070. Used in pharmaceutical industry.",
|
|
663
663
|
codabar: "Supports 0-9, A-D, and symbols. Used in libraries."
|
|
664
|
-
})[
|
|
665
|
-
return f ? /* @__PURE__ */ i.jsx("div", { className: "barcode-modal-overlay", onClick:
|
|
664
|
+
})[L] || "";
|
|
665
|
+
return f ? /* @__PURE__ */ i.jsx("div", { className: "barcode-modal-overlay", onClick: $, children: /* @__PURE__ */ i.jsxs("div", { className: "barcode-modal-content", onClick: (L) => L.stopPropagation(), children: [
|
|
666
666
|
/* @__PURE__ */ i.jsxs("div", { className: "barcode-modal-header", children: [
|
|
667
667
|
/* @__PURE__ */ i.jsx("h3", { children: "Generate Barcode" }),
|
|
668
668
|
/* @__PURE__ */ i.jsx(
|
|
669
669
|
"button",
|
|
670
670
|
{
|
|
671
671
|
className: "barcode-modal-close",
|
|
672
|
-
onClick:
|
|
672
|
+
onClick: $,
|
|
673
673
|
"aria-label": "Close",
|
|
674
674
|
children: "×"
|
|
675
675
|
}
|
|
@@ -684,7 +684,7 @@ const Mt = {
|
|
|
684
684
|
type: "text",
|
|
685
685
|
id: "barcode-data",
|
|
686
686
|
value: s,
|
|
687
|
-
onChange: (
|
|
687
|
+
onChange: (L) => h(L.target.value),
|
|
688
688
|
placeholder: "Enter your data..."
|
|
689
689
|
}
|
|
690
690
|
)
|
|
@@ -695,12 +695,12 @@ const Mt = {
|
|
|
695
695
|
"select",
|
|
696
696
|
{
|
|
697
697
|
id: "barcode-format",
|
|
698
|
-
value:
|
|
699
|
-
onChange: (
|
|
700
|
-
children: ht.map((
|
|
698
|
+
value: x,
|
|
699
|
+
onChange: (L) => l(L.target.value),
|
|
700
|
+
children: ht.map((L) => /* @__PURE__ */ i.jsx("option", { value: L.value, children: L.label }, L.value))
|
|
701
701
|
}
|
|
702
702
|
),
|
|
703
|
-
/* @__PURE__ */ i.jsx("small", { className: "format-description", children:
|
|
703
|
+
/* @__PURE__ */ i.jsx("small", { className: "format-description", children: ot(x) })
|
|
704
704
|
] }),
|
|
705
705
|
/* @__PURE__ */ i.jsxs("div", { className: "barcode-options", children: [
|
|
706
706
|
/* @__PURE__ */ i.jsxs("div", { className: "barcode-form-group", children: [
|
|
@@ -713,12 +713,12 @@ const Mt = {
|
|
|
713
713
|
min: "1",
|
|
714
714
|
max: "4",
|
|
715
715
|
step: "0.5",
|
|
716
|
-
value:
|
|
717
|
-
onChange: (
|
|
716
|
+
value: T,
|
|
717
|
+
onChange: (L) => R(parseFloat(L.target.value))
|
|
718
718
|
}
|
|
719
719
|
),
|
|
720
720
|
/* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
|
|
721
|
-
|
|
721
|
+
T,
|
|
722
722
|
"px"
|
|
723
723
|
] })
|
|
724
724
|
] }),
|
|
@@ -731,12 +731,12 @@ const Mt = {
|
|
|
731
731
|
id: "barcode-height",
|
|
732
732
|
min: "50",
|
|
733
733
|
max: "200",
|
|
734
|
-
value:
|
|
735
|
-
onChange: (
|
|
734
|
+
value: u,
|
|
735
|
+
onChange: (L) => E(parseInt(L.target.value))
|
|
736
736
|
}
|
|
737
737
|
),
|
|
738
738
|
/* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
|
|
739
|
-
|
|
739
|
+
u,
|
|
740
740
|
"px"
|
|
741
741
|
] })
|
|
742
742
|
] }),
|
|
@@ -749,12 +749,12 @@ const Mt = {
|
|
|
749
749
|
id: "barcode-fontsize",
|
|
750
750
|
min: "10",
|
|
751
751
|
max: "30",
|
|
752
|
-
value:
|
|
753
|
-
onChange: (
|
|
752
|
+
value: z,
|
|
753
|
+
onChange: (L) => S(parseInt(L.target.value))
|
|
754
754
|
}
|
|
755
755
|
),
|
|
756
756
|
/* @__PURE__ */ i.jsxs("span", { className: "range-value", children: [
|
|
757
|
-
|
|
757
|
+
z,
|
|
758
758
|
"px"
|
|
759
759
|
] })
|
|
760
760
|
] }),
|
|
@@ -765,7 +765,7 @@ const Mt = {
|
|
|
765
765
|
{
|
|
766
766
|
id: "text-position",
|
|
767
767
|
value: C,
|
|
768
|
-
onChange: (
|
|
768
|
+
onChange: (L) => Q(L.target.value),
|
|
769
769
|
children: [
|
|
770
770
|
/* @__PURE__ */ i.jsx("option", { value: "bottom", children: "Bottom" }),
|
|
771
771
|
/* @__PURE__ */ i.jsx("option", { value: "top", children: "Top" })
|
|
@@ -783,17 +783,17 @@ const Mt = {
|
|
|
783
783
|
children: "Generate Barcode"
|
|
784
784
|
}
|
|
785
785
|
) }),
|
|
786
|
-
|
|
786
|
+
d && /* @__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:
|
|
788
|
+
/* @__PURE__ */ i.jsx("div", { className: "barcode-preview-container", ref: W, children: d }),
|
|
789
789
|
/* @__PURE__ */ i.jsx(
|
|
790
790
|
"button",
|
|
791
791
|
{
|
|
792
792
|
className: "barcode-btn barcode-btn-add",
|
|
793
793
|
onClick: ct,
|
|
794
794
|
style: {
|
|
795
|
-
backgroundColor: (
|
|
796
|
-
borderColor: (
|
|
795
|
+
backgroundColor: (n == null ? void 0 : n.primaryColor) || "#3b82f6",
|
|
796
|
+
borderColor: (n == null ? void 0 : n.primaryColor) || "#3b82f6"
|
|
797
797
|
},
|
|
798
798
|
children: "Add to Canvas"
|
|
799
799
|
}
|
|
@@ -801,7 +801,7 @@ const Mt = {
|
|
|
801
801
|
] })
|
|
802
802
|
] })
|
|
803
803
|
] }) }) : null;
|
|
804
|
-
},
|
|
804
|
+
}, Ve = ({ theme: f }) => /* @__PURE__ */ i.jsxs("div", { className: "premium-feature-container", style: {
|
|
805
805
|
padding: "20px",
|
|
806
806
|
backgroundColor: "#f8f9fa",
|
|
807
807
|
borderRadius: "8px",
|
|
@@ -847,7 +847,7 @@ const Mt = {
|
|
|
847
847
|
children: "Get API Key"
|
|
848
848
|
}
|
|
849
849
|
)
|
|
850
|
-
] }),
|
|
850
|
+
] }), ee = () => /* @__PURE__ */ i.jsxs("div", { style: { textAlign: "center", padding: "40px" }, children: [
|
|
851
851
|
/* @__PURE__ */ i.jsx("div", { style: {
|
|
852
852
|
border: "4px solid #f3f3f3",
|
|
853
853
|
borderTop: "4px solid #3498db",
|
|
@@ -864,87 +864,87 @@ const Mt = {
|
|
|
864
864
|
100% { transform: rotate(360deg); }
|
|
865
865
|
}
|
|
866
866
|
` })
|
|
867
|
-
] }),
|
|
868
|
-
const [
|
|
869
|
-
|
|
870
|
-
const [C,
|
|
867
|
+
] }), Xe = ({ isOpen: f, onClose: o, onAddSticker: a, theme: n, apiKey: s, apiEndpoint: h }) => {
|
|
868
|
+
const [x, l] = N([]), [d, F] = N(!1), [T, R] = N(null), [u, E] = N(""), [z, S] = N(""), [j, K] = N({});
|
|
869
|
+
xt(null);
|
|
870
|
+
const [C, Q] = N(!1), [k, st] = N(!1), [W, ht] = N(!1), O = `${h}/api/v1/designer`;
|
|
871
871
|
it(() => {
|
|
872
872
|
f && s && ct();
|
|
873
873
|
}, [f, s]);
|
|
874
874
|
const ct = async () => {
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
},
|
|
875
|
+
const P = sessionStorage.getItem("apc_x_sub_status");
|
|
876
|
+
P === "active" ? (Q(!0), st(!0), ot()) : P === "inactive" ? (Q(!1), st(!0)) : (ht(!0), await $());
|
|
877
|
+
}, $ = async () => {
|
|
878
878
|
if (!s) {
|
|
879
|
-
|
|
879
|
+
Q(!1), st(!0), ht(!1);
|
|
880
880
|
return;
|
|
881
881
|
}
|
|
882
|
-
const
|
|
882
|
+
const P = `${O}/get-subscription-status/${s}`;
|
|
883
883
|
try {
|
|
884
|
-
(await
|
|
885
|
-
} catch (
|
|
886
|
-
console.error("Subscription check failed:",
|
|
884
|
+
(await Jt.get(P)).data.object === "active" ? (sessionStorage.setItem("apc_x_sub_status", "active"), Q(!0), ot()) : (sessionStorage.setItem("apc_x_sub_status", "inactive"), Q(!1));
|
|
885
|
+
} catch (p) {
|
|
886
|
+
console.error("Subscription check failed:", p), sessionStorage.setItem("apc_x_sub_status", "inactive"), Q(!1);
|
|
887
887
|
} finally {
|
|
888
888
|
ht(!1), st(!0);
|
|
889
889
|
}
|
|
890
|
-
},
|
|
891
|
-
const
|
|
892
|
-
if (
|
|
890
|
+
}, ot = async () => {
|
|
891
|
+
const P = sessionStorage.getItem("apc_stickers");
|
|
892
|
+
if (P)
|
|
893
893
|
try {
|
|
894
|
-
const
|
|
895
|
-
l(
|
|
894
|
+
const p = JSON.parse(P);
|
|
895
|
+
l(p);
|
|
896
896
|
return;
|
|
897
897
|
} catch {
|
|
898
898
|
console.warn("Failed to parse cached stickers, fetching fresh data");
|
|
899
899
|
}
|
|
900
900
|
F(!0), R(null);
|
|
901
901
|
try {
|
|
902
|
-
const
|
|
903
|
-
if (
|
|
904
|
-
const
|
|
905
|
-
l(
|
|
902
|
+
const p = await Jt.get(`${O}/get-stickers`);
|
|
903
|
+
if (p.data && p.data.object && p.data.object.contents) {
|
|
904
|
+
const Z = p.data.object.contents;
|
|
905
|
+
l(Z), sessionStorage.setItem("apc_stickers", JSON.stringify(Z));
|
|
906
906
|
} else
|
|
907
907
|
throw new Error("Invalid response format");
|
|
908
|
-
} catch (
|
|
909
|
-
console.error("Error fetching stickers:",
|
|
908
|
+
} catch (p) {
|
|
909
|
+
console.error("Error fetching stickers:", p), R("Failed to load stickers. Please try again.");
|
|
910
910
|
} finally {
|
|
911
911
|
F(!1);
|
|
912
912
|
}
|
|
913
|
-
},
|
|
913
|
+
}, L = (P, p) => {
|
|
914
914
|
a({
|
|
915
915
|
type: "sticker",
|
|
916
|
-
src:
|
|
917
|
-
name:
|
|
916
|
+
src: P,
|
|
917
|
+
name: p,
|
|
918
918
|
width: 100,
|
|
919
919
|
height: 100,
|
|
920
920
|
x: 100,
|
|
921
921
|
y: 100
|
|
922
922
|
}), o();
|
|
923
|
-
}, lt = (
|
|
924
|
-
|
|
925
|
-
...
|
|
926
|
-
[
|
|
923
|
+
}, lt = (P) => {
|
|
924
|
+
K((p) => ({
|
|
925
|
+
...p,
|
|
926
|
+
[P]: !p[P]
|
|
927
927
|
}));
|
|
928
|
-
},
|
|
929
|
-
const
|
|
930
|
-
return
|
|
931
|
-
const y =
|
|
932
|
-
let I =
|
|
933
|
-
y.forEach((
|
|
934
|
-
I[
|
|
928
|
+
}, J = (P) => {
|
|
929
|
+
const p = {};
|
|
930
|
+
return P.forEach((Z) => {
|
|
931
|
+
const y = Z.name.split("/");
|
|
932
|
+
let I = p;
|
|
933
|
+
y.forEach((M, H) => {
|
|
934
|
+
I[M] || (I[M] = H === y.length - 1 ? Z : {}), I = I[M];
|
|
935
935
|
});
|
|
936
|
-
}),
|
|
937
|
-
}, nt = (
|
|
938
|
-
const I = `${
|
|
939
|
-
return
|
|
936
|
+
}), p;
|
|
937
|
+
}, nt = (P, p = "", Z = 0) => /* @__PURE__ */ i.jsx("div", { className: "sticker-tree-level", style: { paddingLeft: `${Z * 15}px` }, children: Object.keys(P).map((y) => {
|
|
938
|
+
const I = `${p}/${y}`, M = j[I];
|
|
939
|
+
return P[y].type === "image" ? !z || y.toLowerCase().includes(z.toLowerCase()) ? /* @__PURE__ */ i.jsx(
|
|
940
940
|
"div",
|
|
941
941
|
{
|
|
942
942
|
className: "sticker-item",
|
|
943
|
-
onClick: () => P
|
|
943
|
+
onClick: () => L(P[y].url, y),
|
|
944
944
|
children: /* @__PURE__ */ i.jsx("div", { className: "sticker-preview", children: /* @__PURE__ */ i.jsx(
|
|
945
945
|
"img",
|
|
946
946
|
{
|
|
947
|
-
src:
|
|
947
|
+
src: P[y].url,
|
|
948
948
|
alt: y,
|
|
949
949
|
loading: "lazy",
|
|
950
950
|
onError: (G) => {
|
|
@@ -961,17 +961,17 @@ const Mt = {
|
|
|
961
961
|
className: "category-header",
|
|
962
962
|
onClick: () => lt(I),
|
|
963
963
|
children: [
|
|
964
|
-
/* @__PURE__ */ i.jsx("span", { className: `expand-icon ${
|
|
964
|
+
/* @__PURE__ */ i.jsx("span", { className: `expand-icon ${M ? "expanded" : ""}`, children: "▶" }),
|
|
965
965
|
/* @__PURE__ */ i.jsx("span", { className: "category-name", children: y })
|
|
966
966
|
]
|
|
967
967
|
}
|
|
968
968
|
),
|
|
969
|
-
|
|
969
|
+
M && nt(P[y], I, Z + 1)
|
|
970
970
|
] }, I);
|
|
971
|
-
}) }), _ =
|
|
972
|
-
(
|
|
971
|
+
}) }), _ = x.filter(
|
|
972
|
+
(P) => !z || P.name.toLowerCase().includes(z.toLowerCase())
|
|
973
973
|
);
|
|
974
|
-
return f ? /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-content", onClick: (
|
|
974
|
+
return f ? /* @__PURE__ */ i.jsx("div", { className: "sticker-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-content", onClick: (P) => P.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(
|
|
@@ -985,29 +985,29 @@ const Mt = {
|
|
|
985
985
|
)
|
|
986
986
|
] }),
|
|
987
987
|
/* @__PURE__ */ i.jsxs("div", { className: "sticker-modal-body", children: [
|
|
988
|
-
|
|
989
|
-
!C && !
|
|
988
|
+
W && /* @__PURE__ */ i.jsx(ee, {}),
|
|
989
|
+
!C && !W && k && /* @__PURE__ */ i.jsx(Ve, { theme: n }),
|
|
990
990
|
C && k && /* @__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",
|
|
993
993
|
{
|
|
994
994
|
type: "text",
|
|
995
995
|
placeholder: "Search stickers...",
|
|
996
|
-
value:
|
|
997
|
-
onChange: (
|
|
996
|
+
value: z,
|
|
997
|
+
onChange: (P) => S(P.target.value),
|
|
998
998
|
className: "sticker-search"
|
|
999
999
|
}
|
|
1000
1000
|
) }) }),
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
/* @__PURE__ */ i.jsx("p", { children:
|
|
1004
|
-
/* @__PURE__ */ i.jsx("button", { onClick:
|
|
1001
|
+
d && /* @__PURE__ */ i.jsx(ee, {}),
|
|
1002
|
+
T && /* @__PURE__ */ i.jsxs("div", { className: "sticker-error", children: [
|
|
1003
|
+
/* @__PURE__ */ i.jsx("p", { children: T }),
|
|
1004
|
+
/* @__PURE__ */ i.jsx("button", { onClick: ot, children: "Retry" })
|
|
1005
1005
|
] }),
|
|
1006
|
-
!
|
|
1006
|
+
!d && !T && x.length > 0 && /* @__PURE__ */ i.jsx("div", { className: "sticker-grid", children: nt(J(_)) })
|
|
1007
1007
|
] })
|
|
1008
1008
|
] })
|
|
1009
1009
|
] }) }) : null;
|
|
1010
|
-
},
|
|
1010
|
+
}, Je = [
|
|
1011
1011
|
// FLORAL DESIGNS (40 items)
|
|
1012
1012
|
{
|
|
1013
1013
|
id: 1,
|
|
@@ -2559,10 +2559,10 @@ const Mt = {
|
|
|
2559
2559
|
category: "Geometric",
|
|
2560
2560
|
description: "Complex mandala flower pattern"
|
|
2561
2561
|
}
|
|
2562
|
-
],
|
|
2563
|
-
const [
|
|
2562
|
+
], Ke = ({ isOpen: f, onClose: o, onAddEmbroidery: a, theme: n, apiKey: s, apiEndpoint: h }) => {
|
|
2563
|
+
const [x, l] = N([]), [d, F] = N(!1), [T, R] = N(null), [u, E] = N(""), [z, S] = N("All"), j = xt(null), K = ["All", "Floral", "Nature", "Geometric", "Traditional", "Sports", "Hobbies", "Food", "Symbols", "Holiday", "Text"];
|
|
2564
2564
|
it(() => {
|
|
2565
|
-
f && l(
|
|
2565
|
+
f && l(Je);
|
|
2566
2566
|
}, [f]);
|
|
2567
2567
|
const C = (k) => {
|
|
2568
2568
|
a({
|
|
@@ -2576,16 +2576,16 @@ const Mt = {
|
|
|
2576
2576
|
x: 100,
|
|
2577
2577
|
y: 100
|
|
2578
2578
|
}), o();
|
|
2579
|
-
},
|
|
2580
|
-
const st = !
|
|
2581
|
-
return st &&
|
|
2579
|
+
}, Q = x.filter((k) => {
|
|
2580
|
+
const st = !u || k.name.toLowerCase().includes(u.toLowerCase()) || k.description.toLowerCase().includes(u.toLowerCase()), W = z === "All" || k.category === z;
|
|
2581
|
+
return st && W;
|
|
2582
2582
|
});
|
|
2583
2583
|
return f ? /* @__PURE__ */ i.jsx("div", { className: "embroidery-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs(
|
|
2584
2584
|
"div",
|
|
2585
2585
|
{
|
|
2586
2586
|
className: "embroidery-modal-content",
|
|
2587
2587
|
onClick: (k) => k.stopPropagation(),
|
|
2588
|
-
ref:
|
|
2588
|
+
ref: j,
|
|
2589
2589
|
children: [
|
|
2590
2590
|
/* @__PURE__ */ i.jsxs("div", { className: "embroidery-modal-header", children: [
|
|
2591
2591
|
/* @__PURE__ */ i.jsx("h3", { children: "Choose an Embroidery Design" }),
|
|
@@ -2605,7 +2605,7 @@ const Mt = {
|
|
|
2605
2605
|
{
|
|
2606
2606
|
type: "text",
|
|
2607
2607
|
placeholder: "Search embroidery designs...",
|
|
2608
|
-
value:
|
|
2608
|
+
value: u,
|
|
2609
2609
|
onChange: (k) => E(k.target.value),
|
|
2610
2610
|
className: "embroidery-search"
|
|
2611
2611
|
}
|
|
@@ -2615,21 +2615,21 @@ const Mt = {
|
|
|
2615
2615
|
/* @__PURE__ */ i.jsx(
|
|
2616
2616
|
"select",
|
|
2617
2617
|
{
|
|
2618
|
-
value:
|
|
2618
|
+
value: z,
|
|
2619
2619
|
onChange: (k) => S(k.target.value),
|
|
2620
2620
|
className: "category-select",
|
|
2621
|
-
children:
|
|
2621
|
+
children: K.map((k) => /* @__PURE__ */ i.jsx("option", { value: k, children: k }, k))
|
|
2622
2622
|
}
|
|
2623
2623
|
)
|
|
2624
2624
|
] })
|
|
2625
2625
|
] }),
|
|
2626
2626
|
/* @__PURE__ */ i.jsxs("div", { className: "embroidery-modal-body", children: [
|
|
2627
|
-
|
|
2627
|
+
d && /* @__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
|
-
|
|
2632
|
-
!
|
|
2631
|
+
T && /* @__PURE__ */ i.jsx("div", { className: "embroidery-error", children: /* @__PURE__ */ i.jsx("p", { children: T }) }),
|
|
2632
|
+
!d && !T && /* @__PURE__ */ i.jsx("div", { className: "embroidery-grid", children: Q.map((k) => /* @__PURE__ */ i.jsxs(
|
|
2633
2633
|
"div",
|
|
2634
2634
|
{
|
|
2635
2635
|
className: "embroidery-item",
|
|
@@ -2655,7 +2655,7 @@ const Mt = {
|
|
|
2655
2655
|
},
|
|
2656
2656
|
k.id
|
|
2657
2657
|
)) }),
|
|
2658
|
-
!
|
|
2658
|
+
!d && !T && Q.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: "ℹ️" }),
|
|
@@ -2664,7 +2664,7 @@ const Mt = {
|
|
|
2664
2664
|
]
|
|
2665
2665
|
}
|
|
2666
2666
|
) }) : null;
|
|
2667
|
-
},
|
|
2667
|
+
}, Ct = [
|
|
2668
2668
|
// MOTIVATIONAL & INSPIRATIONAL (25 items)
|
|
2669
2669
|
{
|
|
2670
2670
|
id: 1,
|
|
@@ -4601,19 +4601,19 @@ const Mt = {
|
|
|
4601
4601
|
fill: "#8B0000",
|
|
4602
4602
|
textAlign: "center"
|
|
4603
4603
|
}
|
|
4604
|
-
],
|
|
4605
|
-
const [s, h] =
|
|
4606
|
-
const
|
|
4604
|
+
], Ze = ({ isOpen: f, onClose: o, onAddText: a, theme: n }) => {
|
|
4605
|
+
const [s, h] = N(""), [x, l] = N("All"), d = Xt(() => {
|
|
4606
|
+
const u = Ct.reduce((E, z) => (E[z.category] = (E[z.category] || 0) + 1, E), {});
|
|
4607
4607
|
return [
|
|
4608
|
-
{ name: "All", count:
|
|
4609
|
-
...Object.entries(
|
|
4608
|
+
{ name: "All", count: Ct.length },
|
|
4609
|
+
...Object.entries(u).map(([E, z]) => ({ name: E, count: z }))
|
|
4610
4610
|
];
|
|
4611
|
-
}, [
|
|
4612
|
-
const E = !s ||
|
|
4613
|
-
return E &&
|
|
4614
|
-
}), [
|
|
4611
|
+
}, [Ct]), F = Xt(() => Ct.filter((u) => {
|
|
4612
|
+
const E = !s || u.text.toLowerCase().includes(s.toLowerCase()) || u.category.toLowerCase().includes(s.toLowerCase()), z = x === "All" || u.category === x;
|
|
4613
|
+
return E && z;
|
|
4614
|
+
}), [Ct, s, x]), T = (u) => {
|
|
4615
4615
|
const E = {
|
|
4616
|
-
...
|
|
4616
|
+
...u,
|
|
4617
4617
|
x: 100,
|
|
4618
4618
|
y: 100
|
|
4619
4619
|
};
|
|
@@ -4628,7 +4628,7 @@ const Mt = {
|
|
|
4628
4628
|
y: 100
|
|
4629
4629
|
}), o();
|
|
4630
4630
|
};
|
|
4631
|
-
return f ? /* @__PURE__ */ i.jsx("div", { className: "text-templates-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "text-templates-modal", onClick: (
|
|
4631
|
+
return f ? /* @__PURE__ */ i.jsx("div", { className: "text-templates-modal-overlay", onClick: o, children: /* @__PURE__ */ i.jsxs("div", { className: "text-templates-modal", onClick: (u) => u.stopPropagation(), children: [
|
|
4632
4632
|
/* @__PURE__ */ i.jsxs("div", { className: "modal-header", children: [
|
|
4633
4633
|
/* @__PURE__ */ i.jsx("h2", { children: "Text Templates" }),
|
|
4634
4634
|
/* @__PURE__ */ i.jsx("button", { className: "close-btn", onClick: o, "aria-label": "Close", children: "×" })
|
|
@@ -4640,25 +4640,25 @@ const Mt = {
|
|
|
4640
4640
|
type: "text",
|
|
4641
4641
|
placeholder: "Search templates...",
|
|
4642
4642
|
value: s,
|
|
4643
|
-
onChange: (
|
|
4643
|
+
onChange: (u) => h(u.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: d.map((u) => /* @__PURE__ */ i.jsxs(
|
|
4648
4648
|
"button",
|
|
4649
4649
|
{
|
|
4650
|
-
className: `category-tab ${
|
|
4651
|
-
onClick: () => l(
|
|
4650
|
+
className: `category-tab ${x === u.name ? "active" : ""}`,
|
|
4651
|
+
onClick: () => l(u.name),
|
|
4652
4652
|
children: [
|
|
4653
|
-
|
|
4653
|
+
u.name,
|
|
4654
4654
|
/* @__PURE__ */ i.jsxs("span", { className: "count", children: [
|
|
4655
4655
|
"(",
|
|
4656
|
-
|
|
4656
|
+
u.count,
|
|
4657
4657
|
")"
|
|
4658
4658
|
] })
|
|
4659
4659
|
]
|
|
4660
4660
|
},
|
|
4661
|
-
|
|
4661
|
+
u.name
|
|
4662
4662
|
)) })
|
|
4663
4663
|
] }),
|
|
4664
4664
|
/* @__PURE__ */ i.jsxs("div", { className: "templates-grid", children: [
|
|
@@ -4666,38 +4666,38 @@ const Mt = {
|
|
|
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
|
-
F.map((
|
|
4669
|
+
F.map((u) => /* @__PURE__ */ i.jsxs(
|
|
4670
4670
|
"div",
|
|
4671
4671
|
{
|
|
4672
4672
|
className: "template-item",
|
|
4673
|
-
onClick: () =>
|
|
4673
|
+
onClick: () => T(u),
|
|
4674
4674
|
children: [
|
|
4675
4675
|
/* @__PURE__ */ i.jsx(
|
|
4676
4676
|
"div",
|
|
4677
4677
|
{
|
|
4678
4678
|
className: "template-preview",
|
|
4679
4679
|
style: {
|
|
4680
|
-
fontFamily:
|
|
4681
|
-
fontSize: `${Math.min(
|
|
4682
|
-
fontWeight:
|
|
4683
|
-
fontStyle:
|
|
4684
|
-
color:
|
|
4685
|
-
backgroundColor:
|
|
4686
|
-
textAlign:
|
|
4687
|
-
textTransform:
|
|
4688
|
-
letterSpacing:
|
|
4689
|
-
textShadow:
|
|
4680
|
+
fontFamily: u.fontFamily,
|
|
4681
|
+
fontSize: `${Math.min(u.fontSize * 0.6, 18)}px`,
|
|
4682
|
+
fontWeight: u.fontWeight,
|
|
4683
|
+
fontStyle: u.fontStyle,
|
|
4684
|
+
color: u.fill,
|
|
4685
|
+
backgroundColor: u.hasBackground ? u.backgroundColor : "transparent",
|
|
4686
|
+
textAlign: u.textAlign || "left",
|
|
4687
|
+
textTransform: u.textTransform || "none",
|
|
4688
|
+
letterSpacing: u.letterSpacing ? `${u.letterSpacing}px` : "normal",
|
|
4689
|
+
textShadow: u.hasTextShadow ? `${u.textShadowX}px ${u.textShadowY}px ${u.textShadowBlur}px ${u.textShadowColor}` : "none"
|
|
4690
4690
|
},
|
|
4691
|
-
children:
|
|
4691
|
+
children: u.text
|
|
4692
4692
|
}
|
|
4693
4693
|
),
|
|
4694
4694
|
/* @__PURE__ */ i.jsxs("div", { className: "template-info", children: [
|
|
4695
|
-
/* @__PURE__ */ i.jsx("span", { className: "template-category", children:
|
|
4696
|
-
/* @__PURE__ */ i.jsx("span", { className: "template-font", children:
|
|
4695
|
+
/* @__PURE__ */ i.jsx("span", { className: "template-category", children: u.category }),
|
|
4696
|
+
/* @__PURE__ */ i.jsx("span", { className: "template-font", children: u.fontFamily })
|
|
4697
4697
|
] })
|
|
4698
4698
|
]
|
|
4699
4699
|
},
|
|
4700
|
-
|
|
4700
|
+
u.id
|
|
4701
4701
|
))
|
|
4702
4702
|
] }),
|
|
4703
4703
|
/* @__PURE__ */ i.jsx("div", { className: "modal-footer", children: /* @__PURE__ */ i.jsxs("div", { className: "results-count", children: [
|
|
@@ -4707,56 +4707,56 @@ const Mt = {
|
|
|
4707
4707
|
" found"
|
|
4708
4708
|
] }) })
|
|
4709
4709
|
] }) }) : null;
|
|
4710
|
-
},
|
|
4710
|
+
}, ti = ({
|
|
4711
4711
|
onAddElement: f,
|
|
4712
4712
|
onDeleteElement: o,
|
|
4713
4713
|
onDuplicateElement: a,
|
|
4714
|
-
onUndo:
|
|
4714
|
+
onUndo: n,
|
|
4715
4715
|
onRedo: s,
|
|
4716
4716
|
onToggleGrid: h,
|
|
4717
|
-
onToggleRulers:
|
|
4717
|
+
onToggleRulers: x,
|
|
4718
4718
|
onToggleSnap: l,
|
|
4719
|
-
onImageUpload:
|
|
4719
|
+
onImageUpload: d,
|
|
4720
4720
|
canUndo: F,
|
|
4721
|
-
canRedo:
|
|
4721
|
+
canRedo: T,
|
|
4722
4722
|
showGrid: R,
|
|
4723
|
-
showRulers:
|
|
4723
|
+
showRulers: u,
|
|
4724
4724
|
snapToGrid: E,
|
|
4725
|
-
selectedElement:
|
|
4725
|
+
selectedElement: z,
|
|
4726
4726
|
theme: S,
|
|
4727
|
-
readOnly:
|
|
4728
|
-
apiKey:
|
|
4727
|
+
readOnly: j,
|
|
4728
|
+
apiKey: K,
|
|
4729
4729
|
apiEndpoint: C
|
|
4730
4730
|
}) => {
|
|
4731
|
-
const [
|
|
4732
|
-
const
|
|
4733
|
-
|
|
4734
|
-
},
|
|
4731
|
+
const [Q, k] = N(!1), [st, W] = N(!1), [ht, O] = N(!1), [ct, $] = N(!1), [ot, L] = N(!1), [lt, J] = N(!1), [nt, _] = N(!1), P = (U) => {
|
|
4732
|
+
const X = U.target.files[0];
|
|
4733
|
+
X && X.type.startsWith("image/") && d(X), U.target.value = "";
|
|
4734
|
+
}, p = (U) => {
|
|
4735
4735
|
f("icon", {
|
|
4736
|
-
iconData:
|
|
4737
|
-
text:
|
|
4736
|
+
iconData: U,
|
|
4737
|
+
text: U.symbol,
|
|
4738
4738
|
fontSize: 48,
|
|
4739
4739
|
fontFamily: "Arial",
|
|
4740
4740
|
fill: "#000000"
|
|
4741
4741
|
});
|
|
4742
|
-
},
|
|
4743
|
-
f("qrcode",
|
|
4744
|
-
}, y = (
|
|
4745
|
-
f("barcode",
|
|
4746
|
-
}, I = (
|
|
4747
|
-
f("sticker",
|
|
4748
|
-
},
|
|
4749
|
-
f("embroidery",
|
|
4750
|
-
}, H = (
|
|
4751
|
-
f(
|
|
4742
|
+
}, Z = (U) => {
|
|
4743
|
+
f("qrcode", U);
|
|
4744
|
+
}, y = (U) => {
|
|
4745
|
+
f("barcode", U);
|
|
4746
|
+
}, I = (U) => {
|
|
4747
|
+
f("sticker", U);
|
|
4748
|
+
}, M = (U) => {
|
|
4749
|
+
f("embroidery", U);
|
|
4750
|
+
}, H = (U, X) => {
|
|
4751
|
+
f(U, X);
|
|
4752
4752
|
}, G = () => {
|
|
4753
|
-
|
|
4754
|
-
},
|
|
4755
|
-
_(!nt),
|
|
4756
|
-
}, q = (
|
|
4757
|
-
|
|
4758
|
-
}, Y = (
|
|
4759
|
-
f(
|
|
4753
|
+
J(!lt), _(!1);
|
|
4754
|
+
}, tt = () => {
|
|
4755
|
+
_(!nt), J(!1);
|
|
4756
|
+
}, q = (U) => {
|
|
4757
|
+
U === "custom" ? f("text") : U === "templates" && L(!0), J(!1);
|
|
4758
|
+
}, Y = (U) => {
|
|
4759
|
+
f(U), _(!1);
|
|
4760
4760
|
};
|
|
4761
4761
|
return /* @__PURE__ */ i.jsxs("div", { className: "toolbar", children: [
|
|
4762
4762
|
/* @__PURE__ */ i.jsxs("div", { className: "toolbar-section", children: [
|
|
@@ -4765,8 +4765,8 @@ const Mt = {
|
|
|
4765
4765
|
"button",
|
|
4766
4766
|
{
|
|
4767
4767
|
className: "toolbar-btn compact",
|
|
4768
|
-
onClick:
|
|
4769
|
-
disabled: !F ||
|
|
4768
|
+
onClick: n,
|
|
4769
|
+
disabled: !F || j,
|
|
4770
4770
|
title: "Undo (Ctrl+Z)",
|
|
4771
4771
|
children: [
|
|
4772
4772
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "↶" }),
|
|
@@ -4779,7 +4779,7 @@ const Mt = {
|
|
|
4779
4779
|
{
|
|
4780
4780
|
className: "toolbar-btn compact",
|
|
4781
4781
|
onClick: s,
|
|
4782
|
-
disabled: !
|
|
4782
|
+
disabled: !T || j,
|
|
4783
4783
|
title: "Redo (Ctrl+Y)",
|
|
4784
4784
|
children: [
|
|
4785
4785
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "↷" }),
|
|
@@ -4795,7 +4795,7 @@ const Mt = {
|
|
|
4795
4795
|
"button",
|
|
4796
4796
|
{
|
|
4797
4797
|
className: "toolbar-btn compact dropdown-trigger",
|
|
4798
|
-
disabled:
|
|
4798
|
+
disabled: j,
|
|
4799
4799
|
title: "Add Text",
|
|
4800
4800
|
onClick: G,
|
|
4801
4801
|
children: [
|
|
@@ -4821,8 +4821,8 @@ const Mt = {
|
|
|
4821
4821
|
"button",
|
|
4822
4822
|
{
|
|
4823
4823
|
className: "toolbar-btn compact dropdown-trigger",
|
|
4824
|
-
disabled:
|
|
4825
|
-
onClick:
|
|
4824
|
+
disabled: j,
|
|
4825
|
+
onClick: tt,
|
|
4826
4826
|
children: [
|
|
4827
4827
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "◩" }),
|
|
4828
4828
|
/* @__PURE__ */ i.jsx("span", { className: "label", children: "Shapes" }),
|
|
@@ -4882,7 +4882,7 @@ const Mt = {
|
|
|
4882
4882
|
] })
|
|
4883
4883
|
] }),
|
|
4884
4884
|
/* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
|
|
4885
|
-
/* @__PURE__ */ i.jsxs("label", { className: "toolbar-btn compact file-upload", style: { cursor:
|
|
4885
|
+
/* @__PURE__ */ i.jsxs("label", { className: "toolbar-btn compact file-upload", style: { cursor: j ? "not-allowed" : "pointer" }, children: [
|
|
4886
4886
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "☁️" }),
|
|
4887
4887
|
/* @__PURE__ */ i.jsx("span", { className: "label", children: "Upload" }),
|
|
4888
4888
|
/* @__PURE__ */ i.jsx(
|
|
@@ -4890,19 +4890,19 @@ const Mt = {
|
|
|
4890
4890
|
{
|
|
4891
4891
|
type: "file",
|
|
4892
4892
|
accept: "image/*",
|
|
4893
|
-
onChange:
|
|
4894
|
-
disabled:
|
|
4893
|
+
onChange: P,
|
|
4894
|
+
disabled: j
|
|
4895
4895
|
}
|
|
4896
4896
|
)
|
|
4897
4897
|
] }),
|
|
4898
4898
|
/* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
|
|
4899
|
-
/* @__PURE__ */ i.jsx(
|
|
4899
|
+
/* @__PURE__ */ i.jsx(_e, { onSelectIcon: p, theme: S, disabled: j }),
|
|
4900
4900
|
/* @__PURE__ */ i.jsxs(
|
|
4901
4901
|
"button",
|
|
4902
4902
|
{
|
|
4903
4903
|
className: "toolbar-btn compact",
|
|
4904
4904
|
onClick: () => O(!0),
|
|
4905
|
-
disabled:
|
|
4905
|
+
disabled: j,
|
|
4906
4906
|
title: "Add Sticker",
|
|
4907
4907
|
children: [
|
|
4908
4908
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "🎨" }),
|
|
@@ -4916,7 +4916,7 @@ const Mt = {
|
|
|
4916
4916
|
{
|
|
4917
4917
|
className: "toolbar-btn compact",
|
|
4918
4918
|
onClick: () => k(!0),
|
|
4919
|
-
disabled:
|
|
4919
|
+
disabled: j,
|
|
4920
4920
|
title: "Add QR Code",
|
|
4921
4921
|
children: [
|
|
4922
4922
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "▦" }),
|
|
@@ -4928,8 +4928,8 @@ const Mt = {
|
|
|
4928
4928
|
"button",
|
|
4929
4929
|
{
|
|
4930
4930
|
className: "toolbar-btn compact",
|
|
4931
|
-
onClick: () =>
|
|
4932
|
-
disabled:
|
|
4931
|
+
onClick: () => W(!0),
|
|
4932
|
+
disabled: j,
|
|
4933
4933
|
title: "Add Barcode",
|
|
4934
4934
|
children: [
|
|
4935
4935
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "▤" }),
|
|
@@ -4943,8 +4943,8 @@ const Mt = {
|
|
|
4943
4943
|
"button",
|
|
4944
4944
|
{
|
|
4945
4945
|
className: "toolbar-btn compact",
|
|
4946
|
-
onClick: () =>
|
|
4947
|
-
disabled:
|
|
4946
|
+
onClick: () => $(!0),
|
|
4947
|
+
disabled: j,
|
|
4948
4948
|
title: "Add Embroidery Design",
|
|
4949
4949
|
children: [
|
|
4950
4950
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "🧵" }),
|
|
@@ -4952,7 +4952,7 @@ const Mt = {
|
|
|
4952
4952
|
]
|
|
4953
4953
|
}
|
|
4954
4954
|
) }),
|
|
4955
|
-
|
|
4955
|
+
z && /* @__PURE__ */ i.jsxs(i.Fragment, { children: [
|
|
4956
4956
|
/* @__PURE__ */ i.jsx("div", { className: "toolbar-separator" }),
|
|
4957
4957
|
/* @__PURE__ */ i.jsxs("div", { className: "toolbar-group", children: [
|
|
4958
4958
|
/* @__PURE__ */ i.jsxs(
|
|
@@ -4960,7 +4960,7 @@ const Mt = {
|
|
|
4960
4960
|
{
|
|
4961
4961
|
className: "toolbar-btn compact success",
|
|
4962
4962
|
onClick: a,
|
|
4963
|
-
disabled:
|
|
4963
|
+
disabled: j,
|
|
4964
4964
|
title: "Duplicate Element (Ctrl+D)",
|
|
4965
4965
|
children: [
|
|
4966
4966
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "⧉" }),
|
|
@@ -4973,7 +4973,7 @@ const Mt = {
|
|
|
4973
4973
|
{
|
|
4974
4974
|
className: "toolbar-btn compact danger",
|
|
4975
4975
|
onClick: o,
|
|
4976
|
-
disabled:
|
|
4976
|
+
disabled: j,
|
|
4977
4977
|
title: "Delete Element (Delete)",
|
|
4978
4978
|
children: [
|
|
4979
4979
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "🗑️" }),
|
|
@@ -5000,8 +5000,8 @@ const Mt = {
|
|
|
5000
5000
|
/* @__PURE__ */ i.jsxs(
|
|
5001
5001
|
"button",
|
|
5002
5002
|
{
|
|
5003
|
-
className: `toolbar-btn compact ${
|
|
5004
|
-
onClick:
|
|
5003
|
+
className: `toolbar-btn compact ${u ? "active" : ""}`,
|
|
5004
|
+
onClick: x,
|
|
5005
5005
|
title: "Toggle Rulers",
|
|
5006
5006
|
children: [
|
|
5007
5007
|
/* @__PURE__ */ i.jsx("span", { className: "icon", children: "📐" }),
|
|
@@ -5024,72 +5024,72 @@ const Mt = {
|
|
|
5024
5024
|
] })
|
|
5025
5025
|
] }),
|
|
5026
5026
|
/* @__PURE__ */ i.jsx(
|
|
5027
|
-
|
|
5027
|
+
Ye,
|
|
5028
5028
|
{
|
|
5029
|
-
isOpen:
|
|
5029
|
+
isOpen: Q,
|
|
5030
5030
|
onClose: () => k(!1),
|
|
5031
|
-
onAddQRCode:
|
|
5031
|
+
onAddQRCode: Z,
|
|
5032
5032
|
theme: S
|
|
5033
5033
|
}
|
|
5034
5034
|
),
|
|
5035
5035
|
/* @__PURE__ */ i.jsx(
|
|
5036
|
-
|
|
5036
|
+
qe,
|
|
5037
5037
|
{
|
|
5038
5038
|
isOpen: st,
|
|
5039
|
-
onClose: () =>
|
|
5039
|
+
onClose: () => W(!1),
|
|
5040
5040
|
onAddBarcode: y,
|
|
5041
5041
|
theme: S
|
|
5042
5042
|
}
|
|
5043
5043
|
),
|
|
5044
5044
|
/* @__PURE__ */ i.jsx(
|
|
5045
|
-
|
|
5045
|
+
Xe,
|
|
5046
5046
|
{
|
|
5047
5047
|
isOpen: ht,
|
|
5048
5048
|
onClose: () => O(!1),
|
|
5049
5049
|
onAddSticker: I,
|
|
5050
5050
|
theme: S,
|
|
5051
|
-
apiKey:
|
|
5051
|
+
apiKey: K,
|
|
5052
5052
|
apiEndpoint: C
|
|
5053
5053
|
}
|
|
5054
5054
|
),
|
|
5055
5055
|
/* @__PURE__ */ i.jsx(
|
|
5056
|
-
|
|
5056
|
+
Ke,
|
|
5057
5057
|
{
|
|
5058
5058
|
isOpen: ct,
|
|
5059
|
-
onClose: () =>
|
|
5060
|
-
onAddEmbroidery:
|
|
5059
|
+
onClose: () => $(!1),
|
|
5060
|
+
onAddEmbroidery: M,
|
|
5061
5061
|
theme: S,
|
|
5062
|
-
apiKey:
|
|
5062
|
+
apiKey: K,
|
|
5063
5063
|
apiEndpoint: C
|
|
5064
5064
|
}
|
|
5065
5065
|
),
|
|
5066
5066
|
/* @__PURE__ */ i.jsx(
|
|
5067
|
-
|
|
5067
|
+
Ze,
|
|
5068
5068
|
{
|
|
5069
|
-
isOpen:
|
|
5070
|
-
onClose: () =>
|
|
5069
|
+
isOpen: ot,
|
|
5070
|
+
onClose: () => L(!1),
|
|
5071
5071
|
onAddText: H,
|
|
5072
5072
|
theme: S
|
|
5073
5073
|
}
|
|
5074
5074
|
)
|
|
5075
5075
|
] });
|
|
5076
|
-
},
|
|
5076
|
+
}, ei = ({
|
|
5077
5077
|
selectedElement: f,
|
|
5078
5078
|
onUpdate: o,
|
|
5079
5079
|
onMoveLayer: a,
|
|
5080
|
-
availableFonts:
|
|
5080
|
+
availableFonts: n,
|
|
5081
5081
|
theme: s
|
|
5082
5082
|
}) => {
|
|
5083
|
-
const [h,
|
|
5083
|
+
const [h, x] = N(!1);
|
|
5084
5084
|
if (!f)
|
|
5085
5085
|
return /* @__PURE__ */ i.jsxs("div", { className: "properties-panel", children: [
|
|
5086
5086
|
/* @__PURE__ */ i.jsx("h3", { children: "Properties" }),
|
|
5087
5087
|
/* @__PURE__ */ i.jsx("p", { className: "no-selection", children: "Select an element to edit its properties" })
|
|
5088
5088
|
] });
|
|
5089
|
-
const l = (S,
|
|
5090
|
-
o(f.id, { [S]:
|
|
5091
|
-
},
|
|
5092
|
-
var S,
|
|
5089
|
+
const l = (S, j) => {
|
|
5090
|
+
o(f.id, { [S]: j });
|
|
5091
|
+
}, d = () => {
|
|
5092
|
+
var S, j, K;
|
|
5093
5093
|
return /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
|
|
5094
5094
|
/* @__PURE__ */ i.jsx("h4", { children: "Text Content" }),
|
|
5095
5095
|
/* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
@@ -5111,7 +5111,7 @@ const Mt = {
|
|
|
5111
5111
|
{
|
|
5112
5112
|
value: f.fontFamily || "Arial",
|
|
5113
5113
|
onChange: (C) => l("fontFamily", C.target.value),
|
|
5114
|
-
children:
|
|
5114
|
+
children: n.map((C) => /* @__PURE__ */ i.jsx("option", { value: C, children: C }, C))
|
|
5115
5115
|
}
|
|
5116
5116
|
)
|
|
5117
5117
|
] }),
|
|
@@ -5193,8 +5193,8 @@ const Mt = {
|
|
|
5193
5193
|
{
|
|
5194
5194
|
className: (S = f.textDecoration) != null && S.includes("underline") ? "active" : "",
|
|
5195
5195
|
onClick: () => {
|
|
5196
|
-
const C = f.textDecoration || "",
|
|
5197
|
-
C.includes("underline") ||
|
|
5196
|
+
const C = f.textDecoration || "", Q = C.split(" ").filter((k) => k && k !== "underline");
|
|
5197
|
+
C.includes("underline") || Q.push("underline"), l("textDecoration", Q.join(" ").trim());
|
|
5198
5198
|
},
|
|
5199
5199
|
title: "Underline",
|
|
5200
5200
|
children: /* @__PURE__ */ i.jsx("u", { children: "U" })
|
|
@@ -5203,10 +5203,10 @@ const Mt = {
|
|
|
5203
5203
|
/* @__PURE__ */ i.jsx(
|
|
5204
5204
|
"button",
|
|
5205
5205
|
{
|
|
5206
|
-
className: (
|
|
5206
|
+
className: (j = f.textDecoration) != null && j.includes("overline") ? "active" : "",
|
|
5207
5207
|
onClick: () => {
|
|
5208
|
-
const C = f.textDecoration || "",
|
|
5209
|
-
C.includes("overline") ||
|
|
5208
|
+
const C = f.textDecoration || "", Q = C.split(" ").filter((k) => k && k !== "overline");
|
|
5209
|
+
C.includes("overline") || Q.push("overline"), l("textDecoration", Q.join(" ").trim());
|
|
5210
5210
|
},
|
|
5211
5211
|
title: "Overline",
|
|
5212
5212
|
children: /* @__PURE__ */ i.jsx("span", { style: { textDecoration: "overline" }, children: "O" })
|
|
@@ -5215,10 +5215,10 @@ const Mt = {
|
|
|
5215
5215
|
/* @__PURE__ */ i.jsx(
|
|
5216
5216
|
"button",
|
|
5217
5217
|
{
|
|
5218
|
-
className: (
|
|
5218
|
+
className: (K = f.textDecoration) != null && K.includes("line-through") ? "active" : "",
|
|
5219
5219
|
onClick: () => {
|
|
5220
|
-
const C = f.textDecoration || "",
|
|
5221
|
-
C.includes("line-through") ||
|
|
5220
|
+
const C = f.textDecoration || "", Q = C.split(" ").filter((k) => k && k !== "line-through");
|
|
5221
|
+
C.includes("line-through") || Q.push("line-through"), l("textDecoration", Q.join(" ").trim());
|
|
5222
5222
|
},
|
|
5223
5223
|
title: "Strikethrough",
|
|
5224
5224
|
children: /* @__PURE__ */ i.jsx("s", { children: "S" })
|
|
@@ -5615,7 +5615,7 @@ const Mt = {
|
|
|
5615
5615
|
}
|
|
5616
5616
|
)
|
|
5617
5617
|
] })
|
|
5618
|
-
] }),
|
|
5618
|
+
] }), T = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
|
|
5619
5619
|
/* @__PURE__ */ i.jsx("h4", { children: "Image Properties" }),
|
|
5620
5620
|
/* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
5621
5621
|
/* @__PURE__ */ i.jsx("label", { children: "Opacity" }),
|
|
@@ -5717,7 +5717,7 @@ const Mt = {
|
|
|
5717
5717
|
"°"
|
|
5718
5718
|
] })
|
|
5719
5719
|
] })
|
|
5720
|
-
] }),
|
|
5720
|
+
] }), u = () => /* @__PURE__ */ i.jsxs("div", { className: "property-group", children: [
|
|
5721
5721
|
/* @__PURE__ */ i.jsx("h4", { children: "Line Properties" }),
|
|
5722
5722
|
/* @__PURE__ */ i.jsxs("div", { className: "property-row", children: [
|
|
5723
5723
|
/* @__PURE__ */ i.jsxs("div", { className: "input-group", children: [
|
|
@@ -5728,8 +5728,8 @@ const Mt = {
|
|
|
5728
5728
|
type: "number",
|
|
5729
5729
|
value: f.strokeWidth || f.height || 2,
|
|
5730
5730
|
onChange: (S) => {
|
|
5731
|
-
const
|
|
5732
|
-
l("strokeWidth",
|
|
5731
|
+
const j = parseInt(S.target.value);
|
|
5732
|
+
l("strokeWidth", j), l("height", j);
|
|
5733
5733
|
},
|
|
5734
5734
|
min: "1",
|
|
5735
5735
|
max: "50"
|
|
@@ -5784,7 +5784,7 @@ const Mt = {
|
|
|
5784
5784
|
/* @__PURE__ */ i.jsx("button", { onClick: () => a(f.id, "down"), children: "Send Backward" }),
|
|
5785
5785
|
/* @__PURE__ */ i.jsx("button", { onClick: () => a(f.id, "bottom"), children: "Send to Back" })
|
|
5786
5786
|
] })
|
|
5787
|
-
] }),
|
|
5787
|
+
] }), z = [
|
|
5788
5788
|
"rectangle",
|
|
5789
5789
|
"circle",
|
|
5790
5790
|
"triangle",
|
|
@@ -5803,17 +5803,17 @@ const Mt = {
|
|
|
5803
5803
|
/* @__PURE__ */ i.jsx("span", { className: "element-type", children: f.type })
|
|
5804
5804
|
] }),
|
|
5805
5805
|
/* @__PURE__ */ i.jsxs("div", { className: "panel-content", children: [
|
|
5806
|
-
f.type === "text" &&
|
|
5807
|
-
|
|
5808
|
-
f.type === "image" &&
|
|
5809
|
-
f.type === "horizontalLine" &&
|
|
5806
|
+
f.type === "text" && d(),
|
|
5807
|
+
z.includes(f.type) && F(),
|
|
5808
|
+
f.type === "image" && T(),
|
|
5809
|
+
f.type === "horizontalLine" && u(),
|
|
5810
5810
|
R(),
|
|
5811
5811
|
E(),
|
|
5812
5812
|
/* @__PURE__ */ i.jsx("div", { className: "property-group", children: /* @__PURE__ */ i.jsxs(
|
|
5813
5813
|
"button",
|
|
5814
5814
|
{
|
|
5815
5815
|
className: "toggle-advanced",
|
|
5816
|
-
onClick: () =>
|
|
5816
|
+
onClick: () => x(!h),
|
|
5817
5817
|
children: [
|
|
5818
5818
|
h ? "Hide" : "Show",
|
|
5819
5819
|
" Advanced Options"
|
|
@@ -5822,16 +5822,16 @@ const Mt = {
|
|
|
5822
5822
|
) })
|
|
5823
5823
|
] })
|
|
5824
5824
|
] });
|
|
5825
|
-
},
|
|
5825
|
+
}, ii = ({
|
|
5826
5826
|
elements: f,
|
|
5827
5827
|
selectedElement: o,
|
|
5828
5828
|
onSelectElement: a,
|
|
5829
|
-
onMoveLayer:
|
|
5829
|
+
onMoveLayer: n,
|
|
5830
5830
|
onDeleteElement: s,
|
|
5831
5831
|
theme: h
|
|
5832
5832
|
}) => {
|
|
5833
|
-
const
|
|
5834
|
-
switch (
|
|
5833
|
+
const x = (d, F) => {
|
|
5834
|
+
switch (d) {
|
|
5835
5835
|
case "text":
|
|
5836
5836
|
return "T";
|
|
5837
5837
|
case "rectangle":
|
|
@@ -5871,40 +5871,40 @@ const Mt = {
|
|
|
5871
5871
|
default:
|
|
5872
5872
|
return "?";
|
|
5873
5873
|
}
|
|
5874
|
-
}, l = (
|
|
5875
|
-
var F,
|
|
5876
|
-
if (
|
|
5877
|
-
return
|
|
5878
|
-
if (
|
|
5879
|
-
return `QR Code: ${(
|
|
5880
|
-
if (
|
|
5881
|
-
const R =
|
|
5882
|
-
return `Barcode (${R}): ${
|
|
5874
|
+
}, l = (d) => {
|
|
5875
|
+
var F, T;
|
|
5876
|
+
if (d.type === "text")
|
|
5877
|
+
return d.isIcon && d.iconData ? `Icon: ${d.iconData.name}` : ((F = d.text) == null ? void 0 : F.substring(0, 20)) + (((T = d.text) == null ? void 0 : T.length) > 20 ? "..." : "") || "Text";
|
|
5878
|
+
if (d.type === "qrcode")
|
|
5879
|
+
return `QR Code: ${(d.data || "").substring(0, 15) + ((d.data || "").length > 15 ? "..." : "")}`;
|
|
5880
|
+
if (d.type === "barcode") {
|
|
5881
|
+
const R = d.format || "CODE128", u = d.data || "";
|
|
5882
|
+
return `Barcode (${R}): ${u.substring(0, 10) + (u.length > 10 ? "..." : "")}`;
|
|
5883
5883
|
}
|
|
5884
|
-
return
|
|
5884
|
+
return d.type === "sticker" ? `Sticker: ${(d.name || "Untitled").substring(0, 15)}` : d.type === "embroidery" ? `Embroidery: ${(d.name || "Design").substring(0, 15)}` : d.type.charAt(0).toUpperCase() + d.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: f.length })
|
|
5890
5890
|
] }),
|
|
5891
|
-
/* @__PURE__ */ i.jsx("div", { className: "layers-list", children: f.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...f].reverse().map((
|
|
5891
|
+
/* @__PURE__ */ i.jsx("div", { className: "layers-list", children: f.length === 0 ? /* @__PURE__ */ i.jsx("div", { className: "no-layers", children: "No elements added yet" }) : [...f].reverse().map((d, F) => /* @__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) === d.id ? "selected" : ""}`,
|
|
5895
|
+
onClick: () => a(d),
|
|
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: l(
|
|
5898
|
+
/* @__PURE__ */ i.jsx("span", { className: "layer-icon", children: x(d.type) }),
|
|
5899
|
+
/* @__PURE__ */ i.jsx("span", { className: "layer-name", children: l(d) })
|
|
5900
5900
|
] }),
|
|
5901
5901
|
/* @__PURE__ */ i.jsxs("div", { className: "layer-controls", children: [
|
|
5902
5902
|
/* @__PURE__ */ i.jsx(
|
|
5903
5903
|
"button",
|
|
5904
5904
|
{
|
|
5905
5905
|
className: "layer-btn",
|
|
5906
|
-
onClick: (
|
|
5907
|
-
|
|
5906
|
+
onClick: (T) => {
|
|
5907
|
+
T.stopPropagation(), n(d.id, "up");
|
|
5908
5908
|
},
|
|
5909
5909
|
disabled: F === 0,
|
|
5910
5910
|
title: "Move Up",
|
|
@@ -5915,8 +5915,8 @@ const Mt = {
|
|
|
5915
5915
|
"button",
|
|
5916
5916
|
{
|
|
5917
5917
|
className: "layer-btn",
|
|
5918
|
-
onClick: (
|
|
5919
|
-
|
|
5918
|
+
onClick: (T) => {
|
|
5919
|
+
T.stopPropagation(), n(d.id, "down");
|
|
5920
5920
|
},
|
|
5921
5921
|
disabled: F === f.length - 1,
|
|
5922
5922
|
title: "Move Down",
|
|
@@ -5927,8 +5927,8 @@ const Mt = {
|
|
|
5927
5927
|
"button",
|
|
5928
5928
|
{
|
|
5929
5929
|
className: "layer-btn delete",
|
|
5930
|
-
onClick: (
|
|
5931
|
-
|
|
5930
|
+
onClick: (T) => {
|
|
5931
|
+
T.stopPropagation(), s(d.id);
|
|
5932
5932
|
},
|
|
5933
5933
|
title: "Delete",
|
|
5934
5934
|
children: "×"
|
|
@@ -5937,36 +5937,36 @@ const Mt = {
|
|
|
5937
5937
|
] })
|
|
5938
5938
|
]
|
|
5939
5939
|
},
|
|
5940
|
-
|
|
5940
|
+
d.id
|
|
5941
5941
|
)) })
|
|
5942
5942
|
] });
|
|
5943
5943
|
};
|
|
5944
|
-
class
|
|
5944
|
+
class oi {
|
|
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,
|
|
5949
|
+
async exportAllSections(o, a, n, s, h = "png", x = !0) {
|
|
5950
5950
|
const l = {};
|
|
5951
|
-
for (const
|
|
5952
|
-
const F =
|
|
5953
|
-
if (!
|
|
5951
|
+
for (const d of a) {
|
|
5952
|
+
const F = d.id || d.sectionName, T = o[F];
|
|
5953
|
+
if (!T || !T.elements || T.elements.length === 0) {
|
|
5954
5954
|
console.log(`Skipping section ${F} - no elements`);
|
|
5955
5955
|
continue;
|
|
5956
5956
|
}
|
|
5957
|
-
if (this.canvas.width =
|
|
5958
|
-
const
|
|
5959
|
-
if (
|
|
5957
|
+
if (this.canvas.width = n, this.canvas.height = s, this.ctx.clearRect(0, 0, n, s), x) {
|
|
5958
|
+
const u = d.image || d.sectionImage;
|
|
5959
|
+
if (u)
|
|
5960
5960
|
try {
|
|
5961
|
-
const E = await this.loadImage(
|
|
5962
|
-
await this.processImageColor(E,
|
|
5961
|
+
const E = await this.loadImage(u);
|
|
5962
|
+
await this.processImageColor(E, T.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, n, s);
|
|
5963
5963
|
} catch (E) {
|
|
5964
5964
|
console.warn("Failed to load background image:", E);
|
|
5965
5965
|
}
|
|
5966
5966
|
} else
|
|
5967
|
-
this.ctx.clearRect(0, 0,
|
|
5968
|
-
for (const
|
|
5969
|
-
await this.drawElement(
|
|
5967
|
+
this.ctx.clearRect(0, 0, n, s);
|
|
5968
|
+
for (const u of T.elements)
|
|
5969
|
+
await this.drawElement(u);
|
|
5970
5970
|
const R = this.canvas.toDataURL(`image/${h}`, h === "jpeg" ? 0.9 : void 0);
|
|
5971
5971
|
l[F] = {
|
|
5972
5972
|
dataUrl: R,
|
|
@@ -5977,57 +5977,57 @@ class ci {
|
|
|
5977
5977
|
}
|
|
5978
5978
|
// Also add a method to download all exports
|
|
5979
5979
|
async downloadExports(o, a = "design") {
|
|
5980
|
-
const
|
|
5981
|
-
if (
|
|
5980
|
+
const n = Object.keys(o);
|
|
5981
|
+
if (n.length === 0) {
|
|
5982
5982
|
alert("No designs to export");
|
|
5983
5983
|
return;
|
|
5984
5984
|
}
|
|
5985
|
-
if (
|
|
5986
|
-
const s =
|
|
5987
|
-
l.href =
|
|
5985
|
+
if (n.length === 1) {
|
|
5986
|
+
const s = n[0], { blob: h } = o[s], x = URL.createObjectURL(h), l = document.createElement("a");
|
|
5987
|
+
l.href = x, l.download = `${a}-${s}.png`, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(x);
|
|
5988
5988
|
} else
|
|
5989
|
-
for (const s of
|
|
5990
|
-
const { blob: h } = o[s],
|
|
5991
|
-
l.href =
|
|
5989
|
+
for (const s of n) {
|
|
5990
|
+
const { blob: h } = o[s], x = URL.createObjectURL(h), l = document.createElement("a");
|
|
5991
|
+
l.href = x, l.download = `${a}-${s}.png`, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(x), await new Promise((d) => setTimeout(d, 100));
|
|
5992
5992
|
}
|
|
5993
5993
|
}
|
|
5994
5994
|
async loadImage(o) {
|
|
5995
|
-
return new Promise((a,
|
|
5995
|
+
return new Promise((a, n) => {
|
|
5996
5996
|
const s = new Image();
|
|
5997
|
-
s.crossOrigin = "anonymous", s.onload = () => a(s), s.onerror =
|
|
5997
|
+
s.crossOrigin = "anonymous", s.onload = () => a(s), s.onerror = n, s.src = o;
|
|
5998
5998
|
});
|
|
5999
5999
|
}
|
|
6000
6000
|
// Update the processImageColor method in ExportManager class
|
|
6001
6001
|
// Add the getLuma utility function at the top of the class
|
|
6002
|
-
getLuma(o, a,
|
|
6003
|
-
return (0.2126 * o + 0.7152 * a + 0.0722 *
|
|
6002
|
+
getLuma(o, a, n) {
|
|
6003
|
+
return (0.2126 * o + 0.7152 * a + 0.0722 * n) / 255;
|
|
6004
6004
|
}
|
|
6005
6005
|
async processImageColor(o, a) {
|
|
6006
|
-
const
|
|
6007
|
-
|
|
6008
|
-
const h = s.getImageData(0, 0,
|
|
6006
|
+
const n = document.createElement("canvas"), s = n.getContext("2d");
|
|
6007
|
+
n.width = o.width, n.height = o.height, s.clearRect(0, 0, n.width, n.height), s.drawImage(o, 0, 0);
|
|
6008
|
+
const h = s.getImageData(0, 0, n.width, n.height), x = h.data, l = this.hexToRgb(a);
|
|
6009
6009
|
if (!l) {
|
|
6010
6010
|
console.warn("Invalid target color:", a);
|
|
6011
6011
|
return;
|
|
6012
6012
|
}
|
|
6013
|
-
const { r:
|
|
6014
|
-
for (let R = 0; R <
|
|
6015
|
-
if (
|
|
6016
|
-
const E = this.getLuma(
|
|
6017
|
-
|
|
6013
|
+
const { r: d, g: F, b: T } = l;
|
|
6014
|
+
for (let R = 0; R < x.length; R += 4) {
|
|
6015
|
+
if (x[R + 3] === 0) continue;
|
|
6016
|
+
const E = this.getLuma(x[R], x[R + 1], x[R + 2]);
|
|
6017
|
+
x[R] = Math.round(d * E), x[R + 1] = Math.round(F * E), x[R + 2] = Math.round(T * E);
|
|
6018
6018
|
}
|
|
6019
6019
|
return s.putImageData(h, 0, 0), this.processedImage = new Image(), new Promise((R) => {
|
|
6020
6020
|
this.processedImage.onload = () => {
|
|
6021
6021
|
R();
|
|
6022
6022
|
}, this.processedImage.onerror = () => {
|
|
6023
6023
|
console.error("Failed to create processed image"), R();
|
|
6024
|
-
}, this.processedImage.src =
|
|
6024
|
+
}, this.processedImage.src = n.toDataURL("image/png");
|
|
6025
6025
|
});
|
|
6026
6026
|
}
|
|
6027
6027
|
async drawElement(o) {
|
|
6028
6028
|
this.ctx.save();
|
|
6029
|
-
const a = o.x + o.width / 2,
|
|
6030
|
-
switch (this.ctx.translate(a,
|
|
6029
|
+
const a = o.x + o.width / 2, n = o.y + o.height / 2;
|
|
6030
|
+
switch (this.ctx.translate(a, n), o.rotation && this.ctx.rotate(o.rotation * Math.PI / 180), this.ctx.translate(-o.width / 2, -o.height / 2), o.type) {
|
|
6031
6031
|
case "text":
|
|
6032
6032
|
this.drawText(o);
|
|
6033
6033
|
break;
|
|
@@ -6088,41 +6088,41 @@ class ci {
|
|
|
6088
6088
|
drawText(o) {
|
|
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
|
+
`), n = (o.fontSize || 20) * 1.2;
|
|
6092
6092
|
a.forEach((s, h) => {
|
|
6093
|
-
const
|
|
6094
|
-
o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0,
|
|
6093
|
+
const x = h * n;
|
|
6094
|
+
o.stroke && o.strokeWidth > 0 && this.ctx.strokeText(s, 0, x), this.ctx.fillText(s, 0, x);
|
|
6095
6095
|
});
|
|
6096
6096
|
}
|
|
6097
6097
|
drawRectangle(o) {
|
|
6098
6098
|
o.fill && o.fill !== "transparent" && (this.ctx.fillStyle = o.fill, this.ctx.fillRect(0, 0, o.width, o.height)), o.stroke && o.strokeWidth > 0 && (this.ctx.strokeStyle = o.stroke, this.ctx.lineWidth = o.strokeWidth, this.ctx.strokeRect(0, 0, o.width, o.height));
|
|
6099
6099
|
}
|
|
6100
6100
|
drawCircle(o) {
|
|
6101
|
-
const a = Math.min(o.width, o.height) / 2,
|
|
6102
|
-
this.ctx.beginPath(), this.ctx.arc(
|
|
6101
|
+
const a = Math.min(o.width, o.height) / 2, n = o.width / 2, s = o.height / 2;
|
|
6102
|
+
this.ctx.beginPath(), this.ctx.arc(n, s, a, 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());
|
|
6103
6103
|
}
|
|
6104
6104
|
drawTriangle(o) {
|
|
6105
6105
|
const a = o.width / 2;
|
|
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,
|
|
6109
|
+
const a = o.width / 2, n = o.height / 2, s = Math.min(o.width, o.height) / 2, h = s * 0.4, x = o.numPoints || 5;
|
|
6110
6110
|
this.ctx.beginPath();
|
|
6111
|
-
for (let l = 0; l <
|
|
6112
|
-
const
|
|
6113
|
-
l === 0 ? this.ctx.moveTo(
|
|
6111
|
+
for (let l = 0; l < x * 2; l++) {
|
|
6112
|
+
const d = l % 2 === 0 ? s : h, F = l * Math.PI / x, T = a + Math.cos(F) * d, R = n + Math.sin(F) * d;
|
|
6113
|
+
l === 0 ? this.ctx.moveTo(T, R) : this.ctx.lineTo(T, R);
|
|
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());
|
|
6116
6116
|
}
|
|
6117
6117
|
drawArrow(o) {
|
|
6118
|
-
const a = o.width,
|
|
6119
|
-
this.ctx.beginPath(), this.ctx.moveTo(a / 2, 0), this.ctx.lineTo(a,
|
|
6118
|
+
const a = o.width, n = o.height, s = a * 0.3;
|
|
6119
|
+
this.ctx.beginPath(), this.ctx.moveTo(a / 2, 0), this.ctx.lineTo(a, n * 0.6), this.ctx.lineTo(a - s, n * 0.6), this.ctx.lineTo(a - s, n), this.ctx.lineTo(s, n), this.ctx.lineTo(s, n * 0.6), this.ctx.lineTo(0, n * 0.6), 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
6120
|
}
|
|
6121
6121
|
async dataUrlToBlob(o) {
|
|
6122
6122
|
return new Promise((a) => {
|
|
6123
|
-
const
|
|
6123
|
+
const n = document.createElement("canvas"), s = n.getContext("2d"), h = new Image();
|
|
6124
6124
|
h.onload = () => {
|
|
6125
|
-
|
|
6125
|
+
n.width = h.width, n.height = h.height, s.drawImage(h, 0, 0), n.toBlob(a);
|
|
6126
6126
|
}, h.src = o;
|
|
6127
6127
|
});
|
|
6128
6128
|
}
|
|
@@ -6136,71 +6136,71 @@ class ci {
|
|
|
6136
6136
|
}
|
|
6137
6137
|
// Add the new shape drawing methods to ExportManager
|
|
6138
6138
|
drawDiamond(o) {
|
|
6139
|
-
const a = o.width / 2,
|
|
6140
|
-
this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(o.width,
|
|
6139
|
+
const a = o.width / 2, n = o.height / 2;
|
|
6140
|
+
this.ctx.beginPath(), this.ctx.moveTo(a, 0), this.ctx.lineTo(o.width, n), this.ctx.lineTo(a, o.height), this.ctx.lineTo(0, n), 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,
|
|
6143
|
+
const a = o.width / 2, n = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 6;
|
|
6144
6144
|
this.ctx.beginPath();
|
|
6145
|
-
for (let
|
|
6146
|
-
const l =
|
|
6147
|
-
|
|
6145
|
+
for (let x = 0; x < h; x++) {
|
|
6146
|
+
const l = x * 2 * Math.PI / h - Math.PI / 2, d = a + s * Math.cos(l), F = n + s * Math.sin(l);
|
|
6147
|
+
x === 0 ? this.ctx.moveTo(d, F) : this.ctx.lineTo(d, F);
|
|
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,
|
|
6152
|
+
const a = o.width / 2, n = o.height / 2, s = Math.min(o.width, o.height) / 2, h = 5;
|
|
6153
6153
|
this.ctx.beginPath();
|
|
6154
|
-
for (let
|
|
6155
|
-
const l =
|
|
6156
|
-
|
|
6154
|
+
for (let x = 0; x < h; x++) {
|
|
6155
|
+
const l = x * 2 * Math.PI / h - Math.PI / 2, d = a + s * Math.cos(l), F = n + s * Math.sin(l);
|
|
6156
|
+
x === 0 ? this.ctx.moveTo(d, F) : this.ctx.lineTo(d, F);
|
|
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,
|
|
6161
|
+
const a = o.width, n = o.height, s = 0, h = 0;
|
|
6162
6162
|
this.ctx.beginPath();
|
|
6163
|
-
const
|
|
6164
|
-
this.ctx.moveTo(s + a / 2, h +
|
|
6163
|
+
const x = n * 0.3;
|
|
6164
|
+
this.ctx.moveTo(s + a / 2, h + x), this.ctx.bezierCurveTo(
|
|
6165
6165
|
s + a / 2,
|
|
6166
6166
|
h,
|
|
6167
6167
|
s,
|
|
6168
6168
|
h,
|
|
6169
6169
|
s,
|
|
6170
|
-
h +
|
|
6170
|
+
h + x
|
|
6171
6171
|
), this.ctx.bezierCurveTo(
|
|
6172
6172
|
s,
|
|
6173
|
-
h + (
|
|
6173
|
+
h + (n + x) / 2,
|
|
6174
6174
|
s + a / 2,
|
|
6175
|
-
h + (
|
|
6175
|
+
h + (n + x) / 2,
|
|
6176
6176
|
s + a / 2,
|
|
6177
|
-
h +
|
|
6177
|
+
h + n
|
|
6178
6178
|
), this.ctx.bezierCurveTo(
|
|
6179
6179
|
s + a / 2,
|
|
6180
|
-
h + (
|
|
6180
|
+
h + (n + x) / 2,
|
|
6181
6181
|
s + a,
|
|
6182
|
-
h + (
|
|
6182
|
+
h + (n + x) / 2,
|
|
6183
6183
|
s + a,
|
|
6184
|
-
h +
|
|
6184
|
+
h + x
|
|
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
|
-
h +
|
|
6191
|
+
h + x
|
|
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,
|
|
6196
|
-
this.ctx.beginPath(), this.ctx.ellipse(a,
|
|
6195
|
+
const a = o.width / 2, n = o.height / 2, s = o.width / 2, h = o.height / 2;
|
|
6196
|
+
this.ctx.beginPath(), this.ctx.ellipse(a, n, 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,
|
|
6203
|
-
this.ctx.beginPath(), this.ctx.moveTo(o + h, a), this.ctx.lineTo(o +
|
|
6202
|
+
drawRoundedRect(o, a, n, s, h) {
|
|
6203
|
+
this.ctx.beginPath(), this.ctx.moveTo(o + h, a), this.ctx.lineTo(o + n - h, a), this.ctx.quadraticCurveTo(o + n, a, o + n, a + h), this.ctx.lineTo(o + n, a + s - h), this.ctx.quadraticCurveTo(o + n, a + s, o + n - 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)
|
|
@@ -6239,8 +6239,8 @@ class ci {
|
|
|
6239
6239
|
else if (o.imageData)
|
|
6240
6240
|
a = o.imageData;
|
|
6241
6241
|
else if (o.src || o.image) {
|
|
6242
|
-
const
|
|
6243
|
-
a = await this.loadImage(
|
|
6242
|
+
const n = o.src || o.image;
|
|
6243
|
+
a = await this.loadImage(n);
|
|
6244
6244
|
} else o.data && o.data.image && (a = await this.loadImage(o.data.image));
|
|
6245
6245
|
a ? (o.opacity !== void 0 && (this.ctx.globalAlpha = o.opacity), this.ctx.drawImage(a, 0, 0, o.width, o.height)) : (this.ctx.fillStyle = "#f0f0f0", this.ctx.fillRect(0, 0, o.width, o.height), this.ctx.strokeStyle = "#ccc", this.ctx.strokeRect(0, 0, o.width, o.height), this.ctx.fillStyle = "#666", this.ctx.font = "12px Arial", this.ctx.textAlign = "center", this.ctx.textBaseline = "middle", this.ctx.fillText("Sticker", o.width / 2, o.height / 2));
|
|
6246
6246
|
} catch (a) {
|
|
@@ -6255,8 +6255,8 @@ class ci {
|
|
|
6255
6255
|
else if (o.imageData)
|
|
6256
6256
|
a = o.imageData;
|
|
6257
6257
|
else if (o.src || o.image) {
|
|
6258
|
-
const
|
|
6259
|
-
a = await this.loadImage(
|
|
6258
|
+
const n = o.src || o.image;
|
|
6259
|
+
a = await this.loadImage(n);
|
|
6260
6260
|
} else o.data && o.data.image && (a = await this.loadImage(o.data.image));
|
|
6261
6261
|
a ? (o.opacity !== void 0 && (this.ctx.globalAlpha = o.opacity), this.ctx.drawImage(a, 0, 0, o.width, o.height)) : (this.ctx.fillStyle = "#f0f0f0", this.ctx.fillRect(0, 0, o.width, o.height), this.ctx.strokeStyle = "#ccc", this.ctx.strokeRect(0, 0, o.width, o.height), this.ctx.fillStyle = "#666", this.ctx.font = "12px Arial", this.ctx.textAlign = "center", this.ctx.textBaseline = "middle", this.ctx.fillText("Embroidery", o.width / 2, o.height / 2));
|
|
6262
6262
|
} catch (a) {
|
|
@@ -6266,88 +6266,88 @@ class ci {
|
|
|
6266
6266
|
/**Export to JSON formats**/
|
|
6267
6267
|
// Add these new methods to the ExportManager class
|
|
6268
6268
|
// Helper method to convert blob to File
|
|
6269
|
-
async blobToFile(o, a,
|
|
6269
|
+
async blobToFile(o, a, n = "image/png") {
|
|
6270
6270
|
return new File([o], a, {
|
|
6271
|
-
type:
|
|
6271
|
+
type: n,
|
|
6272
6272
|
lastModified: Date.now()
|
|
6273
6273
|
});
|
|
6274
6274
|
}
|
|
6275
6275
|
// Export all sections as JSON with File objects
|
|
6276
|
-
async exportAllSectionsAsJSON(o, a,
|
|
6277
|
-
const
|
|
6276
|
+
async exportAllSectionsAsJSON(o, a, n, s, h = "png") {
|
|
6277
|
+
const x = [], l = [];
|
|
6278
6278
|
for (const F of a) {
|
|
6279
|
-
const
|
|
6279
|
+
const T = F.id || F.sectionName, R = o[T];
|
|
6280
6280
|
if (!R || !R.elements || R.elements.length === 0) {
|
|
6281
|
-
console.log(`Skipping section ${
|
|
6281
|
+
console.log(`Skipping section ${T} - no elements`);
|
|
6282
6282
|
continue;
|
|
6283
6283
|
}
|
|
6284
|
-
const
|
|
6284
|
+
const u = await this.exportSectionAsBlob(
|
|
6285
6285
|
R,
|
|
6286
6286
|
F,
|
|
6287
|
-
|
|
6287
|
+
n,
|
|
6288
6288
|
s,
|
|
6289
6289
|
h,
|
|
6290
6290
|
!0
|
|
6291
6291
|
);
|
|
6292
|
-
if (
|
|
6293
|
-
const
|
|
6294
|
-
|
|
6295
|
-
`${
|
|
6292
|
+
if (u) {
|
|
6293
|
+
const z = await this.blobToFile(
|
|
6294
|
+
u,
|
|
6295
|
+
`${T}-full.${h}`,
|
|
6296
6296
|
`image/${h}`
|
|
6297
6297
|
);
|
|
6298
|
-
|
|
6299
|
-
sectionName:
|
|
6300
|
-
sectionImage:
|
|
6298
|
+
x.push({
|
|
6299
|
+
sectionName: T,
|
|
6300
|
+
sectionImage: z
|
|
6301
6301
|
});
|
|
6302
6302
|
}
|
|
6303
6303
|
const E = await this.exportSectionAsBlob(
|
|
6304
6304
|
R,
|
|
6305
6305
|
F,
|
|
6306
|
-
|
|
6306
|
+
n,
|
|
6307
6307
|
s,
|
|
6308
6308
|
h,
|
|
6309
6309
|
!1
|
|
6310
6310
|
);
|
|
6311
6311
|
if (E) {
|
|
6312
|
-
const
|
|
6312
|
+
const z = await this.blobToFile(
|
|
6313
6313
|
E,
|
|
6314
|
-
`${
|
|
6314
|
+
`${T}-print.${h}`,
|
|
6315
6315
|
`image/${h}`
|
|
6316
6316
|
);
|
|
6317
6317
|
l.push({
|
|
6318
|
-
sectionName:
|
|
6319
|
-
sectionImage:
|
|
6318
|
+
sectionName: T,
|
|
6319
|
+
sectionImage: z
|
|
6320
6320
|
});
|
|
6321
6321
|
}
|
|
6322
6322
|
}
|
|
6323
|
-
const
|
|
6323
|
+
const d = {
|
|
6324
6324
|
sections: o,
|
|
6325
|
-
canvasWidth:
|
|
6325
|
+
canvasWidth: n,
|
|
6326
6326
|
canvasHeight: s,
|
|
6327
6327
|
format: h,
|
|
6328
6328
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6329
6329
|
version: "1.0"
|
|
6330
6330
|
};
|
|
6331
6331
|
return {
|
|
6332
|
-
fullDesign:
|
|
6332
|
+
fullDesign: x,
|
|
6333
6333
|
printReady: l,
|
|
6334
|
-
designFile: JSON.stringify(
|
|
6334
|
+
designFile: JSON.stringify(d)
|
|
6335
6335
|
};
|
|
6336
6336
|
}
|
|
6337
6337
|
// Helper method to export a single section as blob
|
|
6338
|
-
async exportSectionAsBlob(o, a,
|
|
6338
|
+
async exportSectionAsBlob(o, a, n, s, h = "png", x = !0) {
|
|
6339
6339
|
try {
|
|
6340
|
-
if (this.canvas.width =
|
|
6340
|
+
if (this.canvas.width = n, this.canvas.height = s, this.ctx.clearRect(0, 0, n, s), x) {
|
|
6341
6341
|
const l = a.image || a.sectionImage;
|
|
6342
6342
|
if (l)
|
|
6343
6343
|
try {
|
|
6344
|
-
const
|
|
6345
|
-
await this.processImageColor(
|
|
6346
|
-
} catch (
|
|
6347
|
-
console.warn("Failed to load background image:",
|
|
6344
|
+
const d = await this.loadImage(l);
|
|
6345
|
+
await this.processImageColor(d, o.selectedColor || "#FFFFFF"), this.ctx.drawImage(this.processedImage, 0, 0, n, s);
|
|
6346
|
+
} catch (d) {
|
|
6347
|
+
console.warn("Failed to load background image:", d);
|
|
6348
6348
|
}
|
|
6349
6349
|
} else
|
|
6350
|
-
this.ctx.clearRect(0, 0,
|
|
6350
|
+
this.ctx.clearRect(0, 0, n, s);
|
|
6351
6351
|
for (const l of o.elements)
|
|
6352
6352
|
await this.drawElement(l);
|
|
6353
6353
|
return new Promise((l) => {
|
|
@@ -6357,35 +6357,81 @@ class ci {
|
|
|
6357
6357
|
return console.error("Error exporting section as blob:", l), null;
|
|
6358
6358
|
}
|
|
6359
6359
|
}
|
|
6360
|
-
//
|
|
6360
|
+
// Add this method to the ExportManager class
|
|
6361
6361
|
async exportCurrentSectionAsJSON(o, a = "png") {
|
|
6362
|
-
var
|
|
6363
|
-
const
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6362
|
+
var R, u, E;
|
|
6363
|
+
const n = ((R = o.activeSection) == null ? void 0 : R.sectionName) || "main", s = {
|
|
6364
|
+
elements: o.elements,
|
|
6365
|
+
selectedColor: o.selectedColor,
|
|
6366
|
+
canvasWidth: o.canvasWidth,
|
|
6367
|
+
canvasHeight: o.canvasHeight
|
|
6368
|
+
}, h = {
|
|
6369
|
+
id: n,
|
|
6370
|
+
sectionName: n,
|
|
6371
|
+
image: (u = o.activeSection) == null ? void 0 : u.sectionImage,
|
|
6372
|
+
sectionImage: (E = o.activeSection) == null ? void 0 : E.sectionImage
|
|
6373
|
+
}, x = [], l = [], d = await this.exportSectionAsBlob(
|
|
6374
|
+
s,
|
|
6375
|
+
h,
|
|
6376
|
+
o.canvasWidth,
|
|
6377
|
+
o.canvasHeight,
|
|
6378
|
+
a,
|
|
6379
|
+
!0
|
|
6380
|
+
);
|
|
6381
|
+
if (d) {
|
|
6382
|
+
const z = await this.blobToFile(
|
|
6383
|
+
d,
|
|
6384
|
+
`${n}-full.${a}`,
|
|
6385
|
+
`image/${a}`
|
|
6386
|
+
);
|
|
6387
|
+
x.push({
|
|
6388
|
+
sectionName: n,
|
|
6389
|
+
sectionImage: z
|
|
6390
|
+
});
|
|
6391
|
+
}
|
|
6392
|
+
const F = await this.exportSectionAsBlob(
|
|
6373
6393
|
s,
|
|
6394
|
+
h,
|
|
6374
6395
|
o.canvasWidth,
|
|
6375
6396
|
o.canvasHeight,
|
|
6376
|
-
a
|
|
6397
|
+
a,
|
|
6398
|
+
!1
|
|
6377
6399
|
);
|
|
6400
|
+
if (F) {
|
|
6401
|
+
const z = await this.blobToFile(
|
|
6402
|
+
F,
|
|
6403
|
+
`${n}-print.${a}`,
|
|
6404
|
+
`image/${a}`
|
|
6405
|
+
);
|
|
6406
|
+
l.push({
|
|
6407
|
+
sectionName: n,
|
|
6408
|
+
sectionImage: z
|
|
6409
|
+
});
|
|
6410
|
+
}
|
|
6411
|
+
const T = {
|
|
6412
|
+
sections: { [n]: s },
|
|
6413
|
+
canvasWidth: o.canvasWidth,
|
|
6414
|
+
canvasHeight: o.canvasHeight,
|
|
6415
|
+
format: a,
|
|
6416
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6417
|
+
version: "1.0"
|
|
6418
|
+
};
|
|
6419
|
+
return {
|
|
6420
|
+
fullDesign: x,
|
|
6421
|
+
printReady: l,
|
|
6422
|
+
designFile: JSON.stringify(T)
|
|
6423
|
+
};
|
|
6378
6424
|
}
|
|
6379
6425
|
}
|
|
6380
|
-
class
|
|
6426
|
+
class ri {
|
|
6381
6427
|
constructor(o = "localStorage") {
|
|
6382
6428
|
this.storage = o === "sessionStorage" ? sessionStorage : localStorage, this.STORAGE_PREFIX = "mypixia_canvas_", this.DESIGNS_LIST_KEY = "mypixia_saved_designs";
|
|
6383
6429
|
}
|
|
6384
6430
|
// Save complete canvas design
|
|
6385
6431
|
saveDesign(o, a) {
|
|
6386
|
-
var
|
|
6432
|
+
var n;
|
|
6387
6433
|
try {
|
|
6388
|
-
const s = this.generateDesignId(o), h = (/* @__PURE__ */ new Date()).toISOString(),
|
|
6434
|
+
const s = this.generateDesignId(o), h = (/* @__PURE__ */ new Date()).toISOString(), x = {
|
|
6389
6435
|
id: s,
|
|
6390
6436
|
name: o,
|
|
6391
6437
|
timestamp: h,
|
|
@@ -6403,12 +6449,12 @@ class di {
|
|
|
6403
6449
|
snapToGrid: a.snapToGrid || !0
|
|
6404
6450
|
},
|
|
6405
6451
|
metadata: {
|
|
6406
|
-
elementCount: ((
|
|
6452
|
+
elementCount: ((n = a.elements) == null ? void 0 : n.length) || 0,
|
|
6407
6453
|
lastModified: h,
|
|
6408
6454
|
thumbnail: a.thumbnail || null
|
|
6409
6455
|
}
|
|
6410
6456
|
};
|
|
6411
|
-
return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(
|
|
6457
|
+
return this.storage.setItem(this.STORAGE_PREFIX + s, JSON.stringify(x)), this.updateDesignsList(s, o, h), { success: !0, designId: s, message: "Design saved successfully" };
|
|
6412
6458
|
} catch (s) {
|
|
6413
6459
|
return console.error("Error saving design:", s), { success: !1, error: s.message };
|
|
6414
6460
|
}
|
|
@@ -6418,13 +6464,13 @@ class di {
|
|
|
6418
6464
|
try {
|
|
6419
6465
|
let a = o;
|
|
6420
6466
|
if (!o.startsWith("design_")) {
|
|
6421
|
-
const
|
|
6422
|
-
if (!
|
|
6467
|
+
const x = this.getAllDesigns().find((l) => l.name === o);
|
|
6468
|
+
if (!x)
|
|
6423
6469
|
return { success: !1, error: "Design not found" };
|
|
6424
|
-
a =
|
|
6470
|
+
a = x.id;
|
|
6425
6471
|
}
|
|
6426
|
-
const
|
|
6427
|
-
return
|
|
6472
|
+
const n = this.storage.getItem(this.STORAGE_PREFIX + a);
|
|
6473
|
+
return n ? { success: !0, data: JSON.parse(n) } : { success: !1, error: "Design not found" };
|
|
6428
6474
|
} catch (a) {
|
|
6429
6475
|
return console.error("Error loading design:", a), { success: !1, error: a.message };
|
|
6430
6476
|
}
|
|
@@ -6442,8 +6488,8 @@ class di {
|
|
|
6442
6488
|
deleteDesign(o) {
|
|
6443
6489
|
try {
|
|
6444
6490
|
this.storage.removeItem(this.STORAGE_PREFIX + o);
|
|
6445
|
-
const
|
|
6446
|
-
return this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(
|
|
6491
|
+
const n = this.getAllDesigns().filter((s) => s.id !== o);
|
|
6492
|
+
return this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(n)), { success: !0, message: "Design deleted successfully" };
|
|
6447
6493
|
} catch (a) {
|
|
6448
6494
|
return console.error("Error deleting design:", a), { success: !1, error: a.message };
|
|
6449
6495
|
}
|
|
@@ -6454,8 +6500,8 @@ class di {
|
|
|
6454
6500
|
const a = this.loadDesign(o);
|
|
6455
6501
|
if (!a.success)
|
|
6456
6502
|
return a;
|
|
6457
|
-
const
|
|
6458
|
-
return l.href =
|
|
6503
|
+
const n = a.data, s = JSON.stringify(n, null, 2), h = new Blob([s], { type: "application/json" }), x = URL.createObjectURL(h), l = document.createElement("a");
|
|
6504
|
+
return l.href = x, l.download = `${n.name}_${n.id}.json`, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(x), { success: !0, message: "Design exported successfully" };
|
|
6459
6505
|
} catch (a) {
|
|
6460
6506
|
return console.error("Error exporting design:", a), { success: !1, error: a.message };
|
|
6461
6507
|
}
|
|
@@ -6464,34 +6510,34 @@ class di {
|
|
|
6464
6510
|
importDesignFromFile(o) {
|
|
6465
6511
|
return new Promise((a) => {
|
|
6466
6512
|
try {
|
|
6467
|
-
const
|
|
6468
|
-
|
|
6513
|
+
const n = new FileReader();
|
|
6514
|
+
n.onload = (s) => {
|
|
6469
6515
|
try {
|
|
6470
6516
|
const h = JSON.parse(s.target.result);
|
|
6471
6517
|
if (!this.validateDesignData(h)) {
|
|
6472
6518
|
a({ success: !1, error: "Invalid design file format" });
|
|
6473
6519
|
return;
|
|
6474
6520
|
}
|
|
6475
|
-
const
|
|
6476
|
-
h.id =
|
|
6521
|
+
const x = this.generateDesignId(h.name + "_imported");
|
|
6522
|
+
h.id = x, h.name += "_imported", h.timestamp = (/* @__PURE__ */ new Date()).toISOString(), h.metadata.lastModified = h.timestamp, this.storage.setItem(this.STORAGE_PREFIX + x, JSON.stringify(h)), this.updateDesignsList(x, h.name, h.timestamp), a({ success: !0, data: h, message: "Design imported successfully" });
|
|
6477
6523
|
} catch {
|
|
6478
6524
|
a({ success: !1, error: "Failed to parse design file" });
|
|
6479
6525
|
}
|
|
6480
|
-
},
|
|
6481
|
-
} catch (
|
|
6482
|
-
a({ success: !1, error:
|
|
6526
|
+
}, n.readAsText(o);
|
|
6527
|
+
} catch (n) {
|
|
6528
|
+
a({ success: !1, error: n.message });
|
|
6483
6529
|
}
|
|
6484
6530
|
});
|
|
6485
6531
|
}
|
|
6486
6532
|
// Auto-save functionality
|
|
6487
6533
|
autoSave(o, a) {
|
|
6488
|
-
const
|
|
6534
|
+
const n = this.STORAGE_PREFIX + "autosave_" + o;
|
|
6489
6535
|
try {
|
|
6490
6536
|
const s = {
|
|
6491
6537
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6492
6538
|
canvasData: a
|
|
6493
6539
|
};
|
|
6494
|
-
return this.storage.setItem(
|
|
6540
|
+
return this.storage.setItem(n, JSON.stringify(s)), !0;
|
|
6495
6541
|
} catch (s) {
|
|
6496
6542
|
return console.error("Auto-save failed:", s), !1;
|
|
6497
6543
|
}
|
|
@@ -6500,10 +6546,10 @@ class di {
|
|
|
6500
6546
|
loadAutoSave(o) {
|
|
6501
6547
|
const a = this.STORAGE_PREFIX + "autosave_" + o;
|
|
6502
6548
|
try {
|
|
6503
|
-
const
|
|
6504
|
-
return
|
|
6505
|
-
} catch (
|
|
6506
|
-
return console.error("Failed to load auto-save:",
|
|
6549
|
+
const n = this.storage.getItem(a);
|
|
6550
|
+
return n ? JSON.parse(n) : null;
|
|
6551
|
+
} catch (n) {
|
|
6552
|
+
return console.error("Failed to load auto-save:", n), null;
|
|
6507
6553
|
}
|
|
6508
6554
|
}
|
|
6509
6555
|
// Clear auto-save
|
|
@@ -6515,8 +6561,8 @@ class di {
|
|
|
6515
6561
|
getStorageInfo() {
|
|
6516
6562
|
const o = this.getAllDesigns();
|
|
6517
6563
|
let a = 0;
|
|
6518
|
-
return o.forEach((
|
|
6519
|
-
const s = this.storage.getItem(this.STORAGE_PREFIX +
|
|
6564
|
+
return o.forEach((n) => {
|
|
6565
|
+
const s = this.storage.getItem(this.STORAGE_PREFIX + n.id);
|
|
6520
6566
|
s && (a += new Blob([s]).size);
|
|
6521
6567
|
}), {
|
|
6522
6568
|
designCount: o.length,
|
|
@@ -6537,25 +6583,25 @@ class di {
|
|
|
6537
6583
|
}
|
|
6538
6584
|
// Private helper methods
|
|
6539
6585
|
generateDesignId(o) {
|
|
6540
|
-
const a = Date.now(),
|
|
6541
|
-
return `design_${a}_${
|
|
6586
|
+
const a = Date.now(), n = Math.random().toString(36).substring(2, 8);
|
|
6587
|
+
return `design_${a}_${n}`;
|
|
6542
6588
|
}
|
|
6543
|
-
updateDesignsList(o, a,
|
|
6544
|
-
const s = this.getAllDesigns(), h = s.findIndex((l) => l.id === o),
|
|
6589
|
+
updateDesignsList(o, a, n) {
|
|
6590
|
+
const s = this.getAllDesigns(), h = s.findIndex((l) => l.id === o), x = {
|
|
6545
6591
|
id: o,
|
|
6546
6592
|
name: a,
|
|
6547
|
-
timestamp:
|
|
6548
|
-
lastModified:
|
|
6593
|
+
timestamp: n,
|
|
6594
|
+
lastModified: n
|
|
6549
6595
|
};
|
|
6550
|
-
h >= 0 ? s[h] =
|
|
6596
|
+
h >= 0 ? s[h] = x : s.push(x), s.sort((l, d) => new Date(d.timestamp) - new Date(l.timestamp)), this.storage.setItem(this.DESIGNS_LIST_KEY, JSON.stringify(s));
|
|
6551
6597
|
}
|
|
6552
6598
|
validateDesignData(o) {
|
|
6553
6599
|
return o && o.id && o.name && o.canvasData && Array.isArray(o.canvasData.elements);
|
|
6554
6600
|
}
|
|
6555
6601
|
formatBytes(o) {
|
|
6556
6602
|
if (o === 0) return "0 Bytes";
|
|
6557
|
-
const a = 1024,
|
|
6558
|
-
return parseFloat((o / Math.pow(a, s)).toFixed(2)) + " " +
|
|
6603
|
+
const a = 1024, n = ["Bytes", "KB", "MB", "GB"], s = Math.floor(Math.log(o) / Math.log(a));
|
|
6604
|
+
return parseFloat((o / Math.pow(a, s)).toFixed(2)) + " " + n[s];
|
|
6559
6605
|
}
|
|
6560
6606
|
getStorageLimit() {
|
|
6561
6607
|
try {
|
|
@@ -6567,14 +6613,14 @@ class di {
|
|
|
6567
6613
|
return "Unknown";
|
|
6568
6614
|
}
|
|
6569
6615
|
}
|
|
6570
|
-
const
|
|
6616
|
+
const ai = Me((f, o) => {
|
|
6571
6617
|
const {
|
|
6572
6618
|
theme: a = {
|
|
6573
6619
|
primaryColor: "#000000",
|
|
6574
6620
|
secondaryColor: "#cf7e52",
|
|
6575
6621
|
tertiaryColor: "#FFFFFF"
|
|
6576
6622
|
},
|
|
6577
|
-
canvasId:
|
|
6623
|
+
canvasId: n = null,
|
|
6578
6624
|
readOnly: s = !1,
|
|
6579
6625
|
product: h = {
|
|
6580
6626
|
name: "Premium Crew Neck T-Shirt",
|
|
@@ -6598,64 +6644,51 @@ const fi = $e((f, o) => {
|
|
|
6598
6644
|
}
|
|
6599
6645
|
]
|
|
6600
6646
|
}
|
|
6601
|
-
} = f, [
|
|
6647
|
+
} = f, [x, l] = N([]), [d, F] = N(null), [T, R] = N(!1), [u, E] = N(!1), [z, S] = N(!1), [j, K] = N({ x: 0, y: 0 }), [C, Q] = N(null), [k, st] = N(800), [W, ht] = N(600), [O, ct] = N(1), [$, ot] = N(h.colorSettings[0]), [L, lt] = N(!1), [J, nt] = N(!0), [_, P] = N(!0), [p, Z] = N(h.sections[0]), [y, I] = N(!1), [M, H] = N({}), [G, tt] = N([]), [q, Y] = N(-1), [U] = N(new ri("localStorage")), X = xt(null), bt = xt(null), ft = xt(null), yt = xt(null), Bt = xt(null), It = xt(new oi()), pt = xt(!1), rt = at(() => {
|
|
6602
6648
|
const e = {
|
|
6603
|
-
elements: JSON.parse(JSON.stringify(
|
|
6604
|
-
selectedElement:
|
|
6649
|
+
elements: JSON.parse(JSON.stringify(x)),
|
|
6650
|
+
selectedElement: d ? { ...d } : null,
|
|
6605
6651
|
timestamp: Date.now()
|
|
6606
6652
|
}, t = G.slice(0, q + 1);
|
|
6607
|
-
t.push(e), t.length > 50 ? t.shift() : Y(q + 1),
|
|
6608
|
-
}, [
|
|
6609
|
-
elements:
|
|
6653
|
+
t.push(e), t.length > 50 ? t.shift() : Y(q + 1), tt(t);
|
|
6654
|
+
}, [x, d, G, q]), vt = at(() => ({
|
|
6655
|
+
elements: x,
|
|
6610
6656
|
canvasWidth: k,
|
|
6611
|
-
canvasHeight:
|
|
6612
|
-
selectedColor:
|
|
6613
|
-
activeSection:
|
|
6657
|
+
canvasHeight: W,
|
|
6658
|
+
selectedColor: $,
|
|
6659
|
+
activeSection: p,
|
|
6614
6660
|
product: h,
|
|
6615
|
-
sectionDesigns:
|
|
6661
|
+
sectionDesigns: M,
|
|
6616
6662
|
zoomLevel: O,
|
|
6617
|
-
showGrid:
|
|
6663
|
+
showGrid: L,
|
|
6618
6664
|
snapToGrid: _,
|
|
6619
|
-
selectedElement:
|
|
6620
|
-
canvasRef:
|
|
6665
|
+
selectedElement: d ? { ...d } : null,
|
|
6666
|
+
canvasRef: X
|
|
6621
6667
|
// Include reference for thumbnail generation
|
|
6622
|
-
}), [
|
|
6623
|
-
|
|
6624
|
-
Lt((/* @__PURE__ */ new Date()).toISOString()), t && L.clearAutoSave(t), console.log("Design saved:", e, t);
|
|
6625
|
-
}, [L]), et((e, t) => {
|
|
6626
|
-
var r;
|
|
6668
|
+
}), [x, k, W, $, p, h, M, O, L, _, d]);
|
|
6669
|
+
at((e, t) => {
|
|
6627
6670
|
try {
|
|
6628
|
-
l(e.elements || []), st(e.canvasWidth || 800), ht(e.canvasHeight || 600),
|
|
6629
|
-
|
|
6630
|
-
}, 100)
|
|
6631
|
-
} catch (
|
|
6632
|
-
console.error("Error loading design:",
|
|
6671
|
+
l(e.elements || []), st(e.canvasWidth || 800), ht(e.canvasHeight || 600), ot(e.selectedColor || h.colorSettings[0]), ct(e.zoomLevel || 1), lt(e.showGrid || !1), P(e.snapToGrid || !0), F(null), e.sectionDesigns && H(e.sectionDesigns), e.activeSection && Z(e.activeSection), tt([]), Y(-1), setTimeout(() => {
|
|
6672
|
+
rt();
|
|
6673
|
+
}, 100);
|
|
6674
|
+
} catch (r) {
|
|
6675
|
+
console.error("Error loading design:", r);
|
|
6633
6676
|
}
|
|
6634
|
-
}, [h.colorSettings,
|
|
6635
|
-
const Ut = et(() => {
|
|
6636
|
-
if (!ot || g.length === 0) return;
|
|
6637
|
-
const e = `autosave_${(u == null ? void 0 : u.sectionName) || "main"}_${Date.now()}`, t = wt();
|
|
6638
|
-
L.autoSave(e, t) && console.log("Auto-saved at:", (/* @__PURE__ */ new Date()).toLocaleTimeString());
|
|
6639
|
-
}, [ot, g.length, u == null ? void 0 : u.sectionName, wt, L]);
|
|
6640
|
-
it(() => (ot && g.length > 0 && (kt.current && clearTimeout(kt.current), kt.current = setTimeout(() => {
|
|
6641
|
-
Ut();
|
|
6642
|
-
}, 3e4)), () => {
|
|
6643
|
-
kt.current && clearTimeout(kt.current);
|
|
6644
|
-
}), [g, Q, u, ot, Ut]), it(() => {
|
|
6677
|
+
}, [h.colorSettings, rt]), it(() => {
|
|
6645
6678
|
const t = setTimeout(() => {
|
|
6646
|
-
if (
|
|
6647
|
-
const c = "Arial",
|
|
6679
|
+
if (x.length === 0 && G.length <= 1) {
|
|
6680
|
+
const c = "Arial", g = "Change me", w = document.createElement("canvas").getContext("2d");
|
|
6648
6681
|
w.font = `24px ${c}`;
|
|
6649
|
-
const b = w.measureText(
|
|
6682
|
+
const b = w.measureText(g).width, A = {
|
|
6650
6683
|
id: dt(),
|
|
6651
6684
|
type: "text",
|
|
6652
6685
|
x: k / 2 - b / 2,
|
|
6653
6686
|
// Center the actual text width
|
|
6654
|
-
y:
|
|
6687
|
+
y: W / 2 - 24 / 2,
|
|
6655
6688
|
// Center based on font size
|
|
6656
6689
|
width: b,
|
|
6657
6690
|
height: 24,
|
|
6658
|
-
text:
|
|
6691
|
+
text: g,
|
|
6659
6692
|
fontSize: 24,
|
|
6660
6693
|
fontFamily: c,
|
|
6661
6694
|
fontWeight: "normal",
|
|
@@ -6669,28 +6702,28 @@ const fi = $e((f, o) => {
|
|
|
6669
6702
|
opacity: 1
|
|
6670
6703
|
};
|
|
6671
6704
|
l([A]), F(A), setTimeout(() => {
|
|
6672
|
-
|
|
6705
|
+
rt();
|
|
6673
6706
|
}, 100);
|
|
6674
6707
|
}
|
|
6675
6708
|
}, 300);
|
|
6676
6709
|
return () => clearTimeout(t);
|
|
6677
6710
|
}, []);
|
|
6678
|
-
const
|
|
6679
|
-
const r =
|
|
6680
|
-
return h.sections,
|
|
6681
|
-
{ [(
|
|
6711
|
+
const Rt = at((e = "png", t = !0) => {
|
|
6712
|
+
const r = vt();
|
|
6713
|
+
return h.sections, It.current.exportAllSections(
|
|
6714
|
+
{ [(p == null ? void 0 : p.sectionName) || "main"]: r },
|
|
6682
6715
|
[{
|
|
6683
|
-
id: (
|
|
6684
|
-
sectionName: (
|
|
6685
|
-
image:
|
|
6686
|
-
sectionImage:
|
|
6716
|
+
id: (p == null ? void 0 : p.sectionName) || "main",
|
|
6717
|
+
sectionName: (p == null ? void 0 : p.sectionName) || "main",
|
|
6718
|
+
image: p == null ? void 0 : p.sectionImage,
|
|
6719
|
+
sectionImage: p == null ? void 0 : p.sectionImage
|
|
6687
6720
|
}],
|
|
6688
6721
|
k,
|
|
6689
|
-
|
|
6722
|
+
W,
|
|
6690
6723
|
e,
|
|
6691
6724
|
t
|
|
6692
6725
|
);
|
|
6693
|
-
}, [
|
|
6726
|
+
}, [vt, h.sections, p, k, W]), oe = [
|
|
6694
6727
|
"Arial",
|
|
6695
6728
|
"Helvetica",
|
|
6696
6729
|
"Times New Roman",
|
|
@@ -6706,19 +6739,19 @@ const fi = $e((f, o) => {
|
|
|
6706
6739
|
"Bookman",
|
|
6707
6740
|
"Avant Garde",
|
|
6708
6741
|
"Century Gothic"
|
|
6709
|
-
],
|
|
6742
|
+
], jt = 20;
|
|
6710
6743
|
it(() => {
|
|
6711
6744
|
const e = () => I(window.innerWidth < 768);
|
|
6712
6745
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
6713
6746
|
}, []), it(() => {
|
|
6714
6747
|
const e = document.createElement("canvas");
|
|
6715
|
-
e.width = k, e.height =
|
|
6716
|
-
}, [k,
|
|
6717
|
-
G.length === 0 &&
|
|
6748
|
+
e.width = k, e.height = W, Bt.current = e;
|
|
6749
|
+
}, [k, W]), it(() => {
|
|
6750
|
+
G.length === 0 && rt();
|
|
6718
6751
|
}, []);
|
|
6719
|
-
const
|
|
6720
|
-
e.beginPath(), e.moveTo(t +
|
|
6721
|
-
},
|
|
6752
|
+
const Tt = (e, t, r, c, g, m) => {
|
|
6753
|
+
e.beginPath(), e.moveTo(t + m, r), e.lineTo(t + c - m, r), e.quadraticCurveTo(t + c, r, t + c, r + m), e.lineTo(t + c, r + g - m), e.quadraticCurveTo(t + c, r + g, t + c - m, r + g), e.lineTo(t + m, r + g), e.quadraticCurveTo(t, r + g, t, r + g - m), e.lineTo(t, r + m), e.quadraticCurveTo(t, r, t + m, r), e.closePath();
|
|
6754
|
+
}, Wt = (e, t) => {
|
|
6722
6755
|
if (!t.isIcon)
|
|
6723
6756
|
return {
|
|
6724
6757
|
x: t.x,
|
|
@@ -6729,11 +6762,11 @@ const fi = $e((f, o) => {
|
|
|
6729
6762
|
cy: t.y + t.height / 2
|
|
6730
6763
|
};
|
|
6731
6764
|
e.save(), e.font = `${t.fontStyle || ""} ${t.fontWeight || ""} ${t.fontSize}px ${t.fontFamily}`, e.textBaseline = "alphabetic", e.textAlign = "left";
|
|
6732
|
-
const r = e.measureText(t.text), c = r.actualBoundingBoxAscent ?? t.fontSize * 0.8,
|
|
6733
|
-
return e.restore(), { x:
|
|
6734
|
-
},
|
|
6765
|
+
const r = e.measureText(t.text), c = r.actualBoundingBoxAscent ?? t.fontSize * 0.8, g = r.actualBoundingBoxDescent ?? t.fontSize * 0.2, m = r.actualBoundingBoxLeft ?? 0, w = r.actualBoundingBoxRight ?? r.width, v = m + w, b = c + g, A = t.x, D = t.y, B = A - v / 2 - m, et = D - b / 2 - c;
|
|
6766
|
+
return e.restore(), { x: B, y: et, width: v, height: b, cx: A, cy: D };
|
|
6767
|
+
}, re = (e, t) => {
|
|
6735
6768
|
if (!t) return;
|
|
6736
|
-
const r = 8, c = 8,
|
|
6769
|
+
const r = 8, c = 8, g = 4, m = 30, w = Wt(e, t), v = t.isIcon ? Math.max(r, 12) : r, b = {
|
|
6737
6770
|
x: -w.width / 2 - v,
|
|
6738
6771
|
y: -w.height / 2 - v,
|
|
6739
6772
|
w: w.width + v * 2,
|
|
@@ -6746,41 +6779,41 @@ const fi = $e((f, o) => {
|
|
|
6746
6779
|
b.x + b.w,
|
|
6747
6780
|
b.y + b.h
|
|
6748
6781
|
);
|
|
6749
|
-
A.addColorStop(0, "#3b82f6"), A.addColorStop(0.5, "#1d4ed8"), A.addColorStop(1, "#3b82f6"), e.strokeStyle = "rgba(59,130,246,.3)", e.lineWidth = 3,
|
|
6782
|
+
A.addColorStop(0, "#3b82f6"), A.addColorStop(0.5, "#1d4ed8"), A.addColorStop(1, "#3b82f6"), e.strokeStyle = "rgba(59,130,246,.3)", e.lineWidth = 3, Tt(
|
|
6750
6783
|
e,
|
|
6751
6784
|
b.x - 1,
|
|
6752
6785
|
b.y - 1,
|
|
6753
6786
|
b.w + 2,
|
|
6754
6787
|
b.h + 2,
|
|
6755
|
-
|
|
6756
|
-
), e.stroke(), e.strokeStyle = A, e.lineWidth = 2, e.setLineDash([8, 4]),
|
|
6788
|
+
g + 1
|
|
6789
|
+
), e.stroke(), e.strokeStyle = A, e.lineWidth = 2, e.setLineDash([8, 4]), Tt(e, b.x, b.y, b.w, b.h, g), e.stroke(), e.lineDashOffset = -(Date.now() / 50) % 12, e.strokeStyle = "#ffffff", e.lineWidth = 1, e.setLineDash([4, 8]), Tt(e, b.x, b.y, b.w, b.h, g), e.stroke(), e.setLineDash([]), e.lineDashOffset = 0, [
|
|
6757
6790
|
{ x: b.x, y: b.y },
|
|
6758
6791
|
{ x: b.x + b.w, y: b.y },
|
|
6759
6792
|
{ x: b.x + b.w, y: b.y + b.h },
|
|
6760
6793
|
{ x: b.x, y: b.y + b.h }
|
|
6761
|
-
].forEach((
|
|
6794
|
+
].forEach((et) => {
|
|
6762
6795
|
e.fillStyle = "rgba(0,0,0,.2)", e.fillRect(
|
|
6763
|
-
|
|
6764
|
-
|
|
6796
|
+
et.x - c / 2 + 1,
|
|
6797
|
+
et.y - c / 2 + 1,
|
|
6765
6798
|
c,
|
|
6766
6799
|
c
|
|
6767
6800
|
), e.fillStyle = "#ffffff", e.fillRect(
|
|
6768
|
-
|
|
6769
|
-
|
|
6801
|
+
et.x - c / 2,
|
|
6802
|
+
et.y - c / 2,
|
|
6770
6803
|
c,
|
|
6771
6804
|
c
|
|
6772
6805
|
), e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.strokeRect(
|
|
6773
|
-
|
|
6774
|
-
|
|
6806
|
+
et.x - c / 2,
|
|
6807
|
+
et.y - c / 2,
|
|
6775
6808
|
c,
|
|
6776
6809
|
c
|
|
6777
6810
|
);
|
|
6778
6811
|
});
|
|
6779
|
-
const D = 0,
|
|
6780
|
-
e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(D,
|
|
6781
|
-
},
|
|
6812
|
+
const D = 0, B = b.y - m;
|
|
6813
|
+
e.strokeStyle = "#3b82f6", e.lineWidth = 1, e.setLineDash([2, 2]), e.beginPath(), e.moveTo(D, B + 12), e.lineTo(D, b.y), e.stroke(), e.setLineDash([]), e.beginPath(), e.arc(D, B, 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, B, 6, -Math.PI / 2, Math.PI, !1), e.stroke(), e.beginPath(), e.moveTo(D - 6, B), e.lineTo(D - 3, B - 3), e.lineTo(D - 3, B + 3), e.closePath(), e.fillStyle = "#ffffff", e.fill(), e.restore();
|
|
6814
|
+
}, ae = (e, t) => {
|
|
6782
6815
|
if (!t) return [];
|
|
6783
|
-
const r =
|
|
6816
|
+
const r = Wt(e, t), c = t.isIcon ? Math.max(8, 12) : 8, g = 8, m = 30, w = (t.rotation || 0) * Math.PI / 180, v = {
|
|
6784
6817
|
x: -r.width / 2 - c,
|
|
6785
6818
|
y: -r.height / 2 - c,
|
|
6786
6819
|
w: r.width + c * 2,
|
|
@@ -6790,65 +6823,65 @@ const fi = $e((f, o) => {
|
|
|
6790
6823
|
{ x: v.x + v.w, y: v.y, type: "ne-resize" },
|
|
6791
6824
|
{ x: v.x + v.w, y: v.y + v.h, type: "se-resize" },
|
|
6792
6825
|
{ x: v.x, y: v.y + v.h, type: "sw-resize" },
|
|
6793
|
-
{ x: 0, y: v.y -
|
|
6826
|
+
{ x: 0, y: v.y - m, type: "rotate" }
|
|
6794
6827
|
], A = Math.cos(w), D = Math.sin(w);
|
|
6795
|
-
return b.map((
|
|
6796
|
-
x: r.cx + (
|
|
6797
|
-
y: r.cy + (
|
|
6798
|
-
type:
|
|
6799
|
-
size:
|
|
6828
|
+
return b.map((B) => ({
|
|
6829
|
+
x: r.cx + (B.x * A - B.y * D),
|
|
6830
|
+
y: r.cy + (B.x * D + B.y * A),
|
|
6831
|
+
type: B.type,
|
|
6832
|
+
size: B.type === "rotate" ? 24 : g
|
|
6800
6833
|
}));
|
|
6801
|
-
},
|
|
6834
|
+
}, Mt = (e, t, r) => {
|
|
6802
6835
|
if (!r) return null;
|
|
6803
|
-
const c =
|
|
6836
|
+
const c = X.current;
|
|
6804
6837
|
if (!c) return null;
|
|
6805
|
-
const
|
|
6806
|
-
for (const w of
|
|
6838
|
+
const g = c.getContext("2d"), m = ae(g, r);
|
|
6839
|
+
for (const w of m) {
|
|
6807
6840
|
const v = e - w.x, b = t - w.y;
|
|
6808
6841
|
if (Math.sqrt(v * v + b * b) <= w.size / 2)
|
|
6809
6842
|
return w.type;
|
|
6810
6843
|
}
|
|
6811
6844
|
return null;
|
|
6812
|
-
},
|
|
6845
|
+
}, kt = at(() => {
|
|
6813
6846
|
if (q > 0) {
|
|
6814
6847
|
const e = G[q - 1];
|
|
6815
6848
|
l(e.elements), F(e.selectedElement), Y(q - 1);
|
|
6816
6849
|
}
|
|
6817
|
-
}, [G, q]),
|
|
6850
|
+
}, [G, q]), wt = at(() => {
|
|
6818
6851
|
if (q < G.length - 1) {
|
|
6819
6852
|
const e = G[q + 1];
|
|
6820
6853
|
l(e.elements), F(e.selectedElement), Y(q + 1);
|
|
6821
6854
|
}
|
|
6822
|
-
}, [G, q]),
|
|
6855
|
+
}, [G, q]), ut = (e) => _ ? Math.round(e / jt) * jt : e;
|
|
6823
6856
|
it(() => {
|
|
6824
|
-
if (
|
|
6825
|
-
|
|
6826
|
-
const e =
|
|
6827
|
-
e && (e.getContext("2d").clearRect(0, 0, k,
|
|
6857
|
+
if (p != null && p.sectionImage) {
|
|
6858
|
+
ft.current = null, yt.current = null;
|
|
6859
|
+
const e = X.current;
|
|
6860
|
+
e && (e.getContext("2d").clearRect(0, 0, k, W), console.log("cleared canvas"));
|
|
6828
6861
|
const t = new Image();
|
|
6829
6862
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
6830
|
-
|
|
6863
|
+
ft.current = t, Nt(t, $);
|
|
6831
6864
|
}, t.onerror = () => {
|
|
6832
|
-
console.error("Failed to load background image:",
|
|
6833
|
-
}, t.src =
|
|
6865
|
+
console.error("Failed to load background image:", p.sectionImage), V();
|
|
6866
|
+
}, t.src = p.sectionImage;
|
|
6834
6867
|
} else
|
|
6835
|
-
|
|
6836
|
-
}, [
|
|
6868
|
+
ft.current = null, yt.current = null, V();
|
|
6869
|
+
}, [p == null ? void 0 : p.sectionImage]), it(() => {
|
|
6837
6870
|
const e = (t) => {
|
|
6838
6871
|
const r = document.activeElement;
|
|
6839
6872
|
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable))) {
|
|
6840
|
-
if ((t.key === "Delete" || t.key === "Backspace") &&
|
|
6873
|
+
if ((t.key === "Delete" || t.key === "Backspace") && d && !s) {
|
|
6841
6874
|
t.preventDefault();
|
|
6842
|
-
const
|
|
6843
|
-
l((
|
|
6875
|
+
const g = d;
|
|
6876
|
+
l((m) => m.filter((w) => w.id !== g.id)), F(null), rt();
|
|
6844
6877
|
}
|
|
6845
6878
|
if (t.ctrlKey || t.metaKey)
|
|
6846
6879
|
switch (t.key) {
|
|
6847
6880
|
case "z":
|
|
6848
|
-
t.shiftKey ? (t.preventDefault(),
|
|
6881
|
+
t.shiftKey ? (t.preventDefault(), wt()) : (t.preventDefault(), kt());
|
|
6849
6882
|
break;
|
|
6850
6883
|
case "y":
|
|
6851
|
-
t.preventDefault(),
|
|
6884
|
+
t.preventDefault(), wt();
|
|
6852
6885
|
break;
|
|
6853
6886
|
}
|
|
6854
6887
|
}
|
|
@@ -6856,82 +6889,82 @@ const fi = $e((f, o) => {
|
|
|
6856
6889
|
return document.addEventListener("keydown", e), () => {
|
|
6857
6890
|
document.removeEventListener("keydown", e);
|
|
6858
6891
|
};
|
|
6859
|
-
}, [
|
|
6860
|
-
const
|
|
6892
|
+
}, [d, s, kt, wt, rt]);
|
|
6893
|
+
const se = (e) => {
|
|
6861
6894
|
const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
|
|
6862
6895
|
return t ? {
|
|
6863
6896
|
r: parseInt(t[1], 16),
|
|
6864
6897
|
g: parseInt(t[2], 16),
|
|
6865
6898
|
b: parseInt(t[3], 16)
|
|
6866
6899
|
} : null;
|
|
6867
|
-
}, dt = () => `element_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
|
|
6900
|
+
}, dt = () => `element_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`, le = (e) => {
|
|
6868
6901
|
e.strokeStyle = "#e0e0e0", e.lineWidth = 1, e.setLineDash([1, 1]);
|
|
6869
|
-
for (let t = 0; t <= k; t +=
|
|
6870
|
-
e.beginPath(), e.moveTo(t, 0), e.lineTo(t,
|
|
6871
|
-
for (let t = 0; t <=
|
|
6902
|
+
for (let t = 0; t <= k; t += jt)
|
|
6903
|
+
e.beginPath(), e.moveTo(t, 0), e.lineTo(t, W), e.stroke();
|
|
6904
|
+
for (let t = 0; t <= W; t += jt)
|
|
6872
6905
|
e.beginPath(), e.moveTo(0, t), e.lineTo(k, t), e.stroke();
|
|
6873
6906
|
e.setLineDash([]);
|
|
6874
|
-
},
|
|
6907
|
+
}, ne = (e, t) => {
|
|
6875
6908
|
e.save();
|
|
6876
6909
|
const r = t.x + t.width / 2, c = t.y + t.height / 2;
|
|
6877
6910
|
switch (e.translate(r, c), t.rotation && e.rotate(t.rotation * Math.PI / 180), e.translate(-t.width / 2, -t.height / 2), t.type) {
|
|
6878
6911
|
case "text":
|
|
6879
|
-
|
|
6912
|
+
fe(e, t);
|
|
6880
6913
|
break;
|
|
6881
6914
|
case "rectangle":
|
|
6882
|
-
|
|
6915
|
+
he(e, t);
|
|
6883
6916
|
break;
|
|
6884
6917
|
case "circle":
|
|
6885
|
-
|
|
6918
|
+
ge(e, t);
|
|
6886
6919
|
break;
|
|
6887
6920
|
case "triangle":
|
|
6888
|
-
|
|
6921
|
+
xe(e, t);
|
|
6889
6922
|
break;
|
|
6890
6923
|
case "star":
|
|
6891
|
-
|
|
6924
|
+
ye(e, t);
|
|
6892
6925
|
break;
|
|
6893
6926
|
case "arrow":
|
|
6894
|
-
|
|
6927
|
+
ue(e, t);
|
|
6895
6928
|
break;
|
|
6896
6929
|
case "diamond":
|
|
6897
|
-
|
|
6930
|
+
me(e, t);
|
|
6898
6931
|
break;
|
|
6899
6932
|
case "hexagon":
|
|
6900
|
-
|
|
6933
|
+
pe(e, t);
|
|
6901
6934
|
break;
|
|
6902
6935
|
case "pentagon":
|
|
6903
|
-
|
|
6936
|
+
we(e, t);
|
|
6904
6937
|
break;
|
|
6905
6938
|
case "heart":
|
|
6906
|
-
|
|
6939
|
+
be(e, t);
|
|
6907
6940
|
break;
|
|
6908
6941
|
case "oval":
|
|
6909
|
-
|
|
6942
|
+
ve(e, t);
|
|
6910
6943
|
break;
|
|
6911
6944
|
case "roundedRectangle":
|
|
6912
|
-
|
|
6945
|
+
ke(e, t);
|
|
6913
6946
|
break;
|
|
6914
6947
|
case "image":
|
|
6915
|
-
|
|
6948
|
+
Fe(e, t);
|
|
6916
6949
|
break;
|
|
6917
6950
|
case "qrcode":
|
|
6918
|
-
|
|
6951
|
+
de(e, t);
|
|
6919
6952
|
break;
|
|
6920
6953
|
case "barcode":
|
|
6921
|
-
|
|
6954
|
+
ce(e, t);
|
|
6922
6955
|
break;
|
|
6923
6956
|
case "sticker":
|
|
6924
|
-
|
|
6957
|
+
Ce(e, t);
|
|
6925
6958
|
break;
|
|
6926
6959
|
case "horizontalLine":
|
|
6927
|
-
|
|
6960
|
+
Se(e, t);
|
|
6928
6961
|
break;
|
|
6929
6962
|
case "embroidery":
|
|
6930
|
-
|
|
6963
|
+
je(e, t);
|
|
6931
6964
|
break;
|
|
6932
6965
|
}
|
|
6933
6966
|
e.restore();
|
|
6934
|
-
},
|
|
6967
|
+
}, ce = (e, t) => {
|
|
6935
6968
|
if (t.imageObject)
|
|
6936
6969
|
e.drawImage(t.imageObject, 0, 0, t.width, t.height);
|
|
6937
6970
|
else if (t.src && !t.imageLoading) {
|
|
@@ -6940,18 +6973,18 @@ const fi = $e((f, o) => {
|
|
|
6940
6973
|
r.onload = () => {
|
|
6941
6974
|
l(
|
|
6942
6975
|
(c) => c.map(
|
|
6943
|
-
(
|
|
6976
|
+
(g) => g.id === t.id ? { ...g, imageObject: r, imageLoading: !1 } : g
|
|
6944
6977
|
)
|
|
6945
6978
|
);
|
|
6946
6979
|
}, r.onerror = () => {
|
|
6947
6980
|
l(
|
|
6948
6981
|
(c) => c.map(
|
|
6949
|
-
(
|
|
6982
|
+
(g) => g.id === t.id ? { ...g, imageLoading: !1 } : g
|
|
6950
6983
|
)
|
|
6951
6984
|
);
|
|
6952
6985
|
}, 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);
|
|
6953
6986
|
} else t.imageLoading ? (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)) : (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("No Barcode", t.width / 2, t.height / 2));
|
|
6954
|
-
},
|
|
6987
|
+
}, de = (e, t) => {
|
|
6955
6988
|
if (t.imageObject)
|
|
6956
6989
|
e.drawImage(t.imageObject, 0, 0, t.width, t.height);
|
|
6957
6990
|
else if (t.src && !t.imageLoading) {
|
|
@@ -6960,18 +6993,18 @@ const fi = $e((f, o) => {
|
|
|
6960
6993
|
r.onload = () => {
|
|
6961
6994
|
l(
|
|
6962
6995
|
(c) => c.map(
|
|
6963
|
-
(
|
|
6996
|
+
(g) => g.id === t.id ? { ...g, imageObject: r, imageLoading: !1 } : g
|
|
6964
6997
|
)
|
|
6965
6998
|
);
|
|
6966
6999
|
}, r.onerror = () => {
|
|
6967
7000
|
l(
|
|
6968
7001
|
(c) => c.map(
|
|
6969
|
-
(
|
|
7002
|
+
(g) => g.id === t.id ? { ...g, imageLoading: !1 } : g
|
|
6970
7003
|
)
|
|
6971
7004
|
);
|
|
6972
7005
|
}, 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);
|
|
6973
7006
|
} else t.imageLoading ? (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)) : (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("No QR Data", t.width / 2, t.height / 2));
|
|
6974
|
-
},
|
|
7007
|
+
}, fe = (e, t) => {
|
|
6975
7008
|
e.save();
|
|
6976
7009
|
let r = t.text || "Text";
|
|
6977
7010
|
if (t.textTransform)
|
|
@@ -6988,137 +7021,137 @@ const fi = $e((f, o) => {
|
|
|
6988
7021
|
}
|
|
6989
7022
|
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);
|
|
6990
7023
|
const c = r.split(`
|
|
6991
|
-
`),
|
|
7024
|
+
`), g = (t.fontSize || 20) * (t.lineHeight || 1.2), m = Math.max(...c.map((v) => e.measureText(v).width)), w = c.length * g;
|
|
6992
7025
|
if (t.backgroundColor && t.backgroundColor !== "transparent") {
|
|
6993
7026
|
e.fillStyle = t.backgroundColor;
|
|
6994
7027
|
const v = t.backgroundPadding || 4;
|
|
6995
7028
|
e.fillRect(
|
|
6996
7029
|
-v,
|
|
6997
7030
|
-v,
|
|
6998
|
-
|
|
7031
|
+
m + v * 2,
|
|
6999
7032
|
w + v * 2
|
|
7000
7033
|
), e.fillStyle = t.fill || "#000000";
|
|
7001
7034
|
}
|
|
7002
7035
|
c.forEach((v, b) => {
|
|
7003
|
-
const A = b *
|
|
7036
|
+
const A = b * g, D = e.measureText(v).width;
|
|
7004
7037
|
t.stroke && t.strokeWidth > 0 && e.strokeText(v, 0, A), e.fillText(v, 0, A);
|
|
7005
|
-
const
|
|
7006
|
-
if (e.strokeStyle =
|
|
7007
|
-
const
|
|
7008
|
-
e.beginPath(), e.moveTo(0,
|
|
7038
|
+
const B = t.fontSize || 20, et = t.decorationColor || t.fill || "#000000", gt = Math.max(1, B / 20);
|
|
7039
|
+
if (e.strokeStyle = et, e.lineWidth = gt, t.textDecoration === "underline" || t.underline) {
|
|
7040
|
+
const mt = A + B + 2;
|
|
7041
|
+
e.beginPath(), e.moveTo(0, mt), e.lineTo(D, mt), e.stroke();
|
|
7009
7042
|
}
|
|
7010
7043
|
if (t.textDecoration === "overline" || t.overline) {
|
|
7011
|
-
const
|
|
7012
|
-
e.beginPath(), e.moveTo(0,
|
|
7044
|
+
const mt = A - 2;
|
|
7045
|
+
e.beginPath(), e.moveTo(0, mt), e.lineTo(D, mt), e.stroke();
|
|
7013
7046
|
}
|
|
7014
7047
|
if (t.textDecoration === "line-through" || t.strikethrough) {
|
|
7015
|
-
const
|
|
7016
|
-
e.beginPath(), e.moveTo(0,
|
|
7048
|
+
const mt = A + B / 2;
|
|
7049
|
+
e.beginPath(), e.moveTo(0, mt), e.lineTo(D, mt), e.stroke();
|
|
7017
7050
|
}
|
|
7018
|
-
typeof t.textDecoration == "string" && t.textDecoration.includes(" ") && t.textDecoration.split(" ").forEach((
|
|
7019
|
-
switch (
|
|
7051
|
+
typeof t.textDecoration == "string" && t.textDecoration.includes(" ") && t.textDecoration.split(" ").forEach((Be) => {
|
|
7052
|
+
switch (Be.trim()) {
|
|
7020
7053
|
case "underline":
|
|
7021
|
-
const
|
|
7022
|
-
e.beginPath(), e.moveTo(0,
|
|
7054
|
+
const Yt = A + B + 2;
|
|
7055
|
+
e.beginPath(), e.moveTo(0, Yt), e.lineTo(D, Yt), e.stroke();
|
|
7023
7056
|
break;
|
|
7024
7057
|
case "overline":
|
|
7025
|
-
const
|
|
7026
|
-
e.beginPath(), e.moveTo(0,
|
|
7058
|
+
const qt = A - 2;
|
|
7059
|
+
e.beginPath(), e.moveTo(0, qt), e.lineTo(D, qt), e.stroke();
|
|
7027
7060
|
break;
|
|
7028
7061
|
case "line-through":
|
|
7029
|
-
const
|
|
7030
|
-
e.beginPath(), e.moveTo(0,
|
|
7062
|
+
const Vt = A + B / 2;
|
|
7063
|
+
e.beginPath(), e.moveTo(0, Vt), e.lineTo(D, Vt), e.stroke();
|
|
7031
7064
|
break;
|
|
7032
7065
|
}
|
|
7033
7066
|
});
|
|
7034
7067
|
}), e.restore();
|
|
7035
|
-
},
|
|
7068
|
+
}, he = (e, t) => {
|
|
7036
7069
|
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));
|
|
7037
|
-
},
|
|
7038
|
-
const r = Math.min(t.width, t.height) / 2, c = t.width / 2,
|
|
7039
|
-
e.beginPath(), e.arc(c,
|
|
7040
|
-
},
|
|
7070
|
+
}, ge = (e, t) => {
|
|
7071
|
+
const r = Math.min(t.width, t.height) / 2, c = t.width / 2, g = t.height / 2;
|
|
7072
|
+
e.beginPath(), e.arc(c, g, 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());
|
|
7073
|
+
}, xe = (e, t) => {
|
|
7041
7074
|
const r = t.width / 2;
|
|
7042
7075
|
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());
|
|
7043
|
-
},
|
|
7044
|
-
const r = t.width / 2, c = t.height / 2,
|
|
7076
|
+
}, ye = (e, t) => {
|
|
7077
|
+
const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = g * 0.4, w = t.numPoints || 5;
|
|
7045
7078
|
e.beginPath();
|
|
7046
7079
|
for (let v = 0; v < w * 2; v++) {
|
|
7047
|
-
const b = v % 2 === 0 ?
|
|
7048
|
-
v === 0 ? e.moveTo(D,
|
|
7080
|
+
const b = v % 2 === 0 ? g : m, A = v * Math.PI / w, D = r + Math.cos(A) * b, B = c + Math.sin(A) * b;
|
|
7081
|
+
v === 0 ? e.moveTo(D, B) : e.lineTo(D, B);
|
|
7049
7082
|
}
|
|
7050
7083
|
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());
|
|
7051
|
-
},
|
|
7052
|
-
const r = t.width, c = t.height,
|
|
7053
|
-
e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, c * 0.6), e.lineTo(r -
|
|
7054
|
-
},
|
|
7084
|
+
}, ue = (e, t) => {
|
|
7085
|
+
const r = t.width, c = t.height, g = r * 0.3;
|
|
7086
|
+
e.beginPath(), e.moveTo(r / 2, 0), e.lineTo(r, c * 0.6), e.lineTo(r - g, c * 0.6), e.lineTo(r - g, c), e.lineTo(g, c), e.lineTo(g, c * 0.6), e.lineTo(0, c * 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());
|
|
7087
|
+
}, me = (e, t) => {
|
|
7055
7088
|
const r = t.width / 2, c = t.height / 2;
|
|
7056
7089
|
e.beginPath(), e.moveTo(r, 0), e.lineTo(t.width, c), e.lineTo(r, t.height), e.lineTo(0, c), 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());
|
|
7057
|
-
},
|
|
7058
|
-
const r = t.width / 2, c = t.height / 2,
|
|
7090
|
+
}, pe = (e, t) => {
|
|
7091
|
+
const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = 6;
|
|
7059
7092
|
e.beginPath();
|
|
7060
|
-
for (let w = 0; w <
|
|
7061
|
-
const v = w * 2 * Math.PI /
|
|
7093
|
+
for (let w = 0; w < m; w++) {
|
|
7094
|
+
const v = w * 2 * Math.PI / m - Math.PI / 2, b = r + g * Math.cos(v), A = c + g * Math.sin(v);
|
|
7062
7095
|
w === 0 ? e.moveTo(b, A) : e.lineTo(b, A);
|
|
7063
7096
|
}
|
|
7064
7097
|
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());
|
|
7065
|
-
},
|
|
7066
|
-
const r = t.width / 2, c = t.height / 2,
|
|
7098
|
+
}, we = (e, t) => {
|
|
7099
|
+
const r = t.width / 2, c = t.height / 2, g = Math.min(t.width, t.height) / 2, m = 5;
|
|
7067
7100
|
e.beginPath();
|
|
7068
|
-
for (let w = 0; w <
|
|
7069
|
-
const v = w * 2 * Math.PI /
|
|
7101
|
+
for (let w = 0; w < m; w++) {
|
|
7102
|
+
const v = w * 2 * Math.PI / m - Math.PI / 2, b = r + g * Math.cos(v), A = c + g * Math.sin(v);
|
|
7070
7103
|
w === 0 ? e.moveTo(b, A) : e.lineTo(b, A);
|
|
7071
7104
|
}
|
|
7072
7105
|
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());
|
|
7073
|
-
},
|
|
7074
|
-
const r = t.width, c = t.height,
|
|
7106
|
+
}, be = (e, t) => {
|
|
7107
|
+
const r = t.width, c = t.height, g = 0, m = 0;
|
|
7075
7108
|
e.beginPath();
|
|
7076
7109
|
const w = c * 0.3;
|
|
7077
|
-
e.moveTo(
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7110
|
+
e.moveTo(g + r / 2, m + w), e.bezierCurveTo(
|
|
7111
|
+
g + r / 2,
|
|
7112
|
+
m,
|
|
7113
|
+
g,
|
|
7114
|
+
m,
|
|
7115
|
+
g,
|
|
7116
|
+
m + w
|
|
7084
7117
|
), e.bezierCurveTo(
|
|
7085
|
-
|
|
7086
|
-
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7118
|
+
g,
|
|
7119
|
+
m + (c + w) / 2,
|
|
7120
|
+
g + r / 2,
|
|
7121
|
+
m + (c + w) / 2,
|
|
7122
|
+
g + r / 2,
|
|
7123
|
+
m + c
|
|
7091
7124
|
), e.bezierCurveTo(
|
|
7092
|
-
|
|
7093
|
-
|
|
7094
|
-
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7125
|
+
g + r / 2,
|
|
7126
|
+
m + (c + w) / 2,
|
|
7127
|
+
g + r,
|
|
7128
|
+
m + (c + w) / 2,
|
|
7129
|
+
g + r,
|
|
7130
|
+
m + w
|
|
7098
7131
|
), e.bezierCurveTo(
|
|
7099
|
-
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7132
|
+
g + r,
|
|
7133
|
+
m,
|
|
7134
|
+
g + r / 2,
|
|
7135
|
+
m,
|
|
7136
|
+
g + r / 2,
|
|
7137
|
+
m + w
|
|
7105
7138
|
), 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());
|
|
7106
|
-
},
|
|
7107
|
-
const r = t.width / 2, c = t.height / 2,
|
|
7108
|
-
e.beginPath(), e.ellipse(r, c,
|
|
7109
|
-
},
|
|
7139
|
+
}, ve = (e, t) => {
|
|
7140
|
+
const r = t.width / 2, c = t.height / 2, g = t.width / 2, m = t.height / 2;
|
|
7141
|
+
e.beginPath(), e.ellipse(r, c, g, m, 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());
|
|
7142
|
+
}, ke = (e, t) => {
|
|
7110
7143
|
const r = Math.min(t.width, t.height) * 0.1;
|
|
7111
|
-
|
|
7112
|
-
},
|
|
7144
|
+
Tt(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());
|
|
7145
|
+
}, Se = (e, t) => {
|
|
7113
7146
|
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();
|
|
7114
|
-
},
|
|
7147
|
+
}, Fe = (e, t) => {
|
|
7115
7148
|
if (t.imageData)
|
|
7116
7149
|
try {
|
|
7117
7150
|
t.imageData.complete && t.imageData.naturalHeight !== 0 ? e.drawImage(t.imageData, 0, 0, t.width, t.height) : (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));
|
|
7118
7151
|
} catch (r) {
|
|
7119
7152
|
console.error("Error drawing image:", r), 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);
|
|
7120
7153
|
}
|
|
7121
|
-
},
|
|
7154
|
+
}, Ce = (e, t) => {
|
|
7122
7155
|
if (t.src && !t.imageLoading && !t.loadedImage) {
|
|
7123
7156
|
t.imageLoading = !0;
|
|
7124
7157
|
const r = new Image();
|
|
@@ -7128,7 +7161,7 @@ const fi = $e((f, o) => {
|
|
|
7128
7161
|
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);
|
|
7129
7162
|
}, r.src = t.src;
|
|
7130
7163
|
} 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));
|
|
7131
|
-
},
|
|
7164
|
+
}, je = (e, t) => {
|
|
7132
7165
|
if (t.imageObject)
|
|
7133
7166
|
e.drawImage(t.imageObject, 0, 0, t.width, t.height);
|
|
7134
7167
|
else if (t.src && !t.imageLoading) {
|
|
@@ -7137,49 +7170,49 @@ const fi = $e((f, o) => {
|
|
|
7137
7170
|
r.crossOrigin = "anonymous", r.onload = () => {
|
|
7138
7171
|
t.imageObject = r, t.imageLoading = !1, V();
|
|
7139
7172
|
}, r.onerror = () => {
|
|
7140
|
-
t.imageLoading = !1, console.error("Failed to load embroidery image:", t.src),
|
|
7141
|
-
}, r.src = t.src,
|
|
7173
|
+
t.imageLoading = !1, console.error("Failed to load embroidery image:", t.src), Dt(e, t);
|
|
7174
|
+
}, r.src = t.src, Dt(e, t, "Loading...");
|
|
7142
7175
|
} else
|
|
7143
|
-
|
|
7144
|
-
},
|
|
7176
|
+
Dt(e, t);
|
|
7177
|
+
}, Dt = (e, t, r = "Embroidery") => {
|
|
7145
7178
|
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);
|
|
7146
|
-
},
|
|
7179
|
+
}, Lt = (e, t, r) => {
|
|
7147
7180
|
if (!r) return !1;
|
|
7148
|
-
const c = r.x + r.width / 2,
|
|
7149
|
-
return D >= -
|
|
7150
|
-
},
|
|
7151
|
-
(
|
|
7152
|
-
const e =
|
|
7181
|
+
const c = r.x + r.width / 2, g = r.y + r.height / 2, m = e - c, w = t - g, v = -(r.rotation || 0) * Math.PI / 180, b = Math.cos(v), A = Math.sin(v), D = m * b - w * A, B = m * A + w * b, et = r.width / 2, gt = r.height / 2;
|
|
7182
|
+
return D >= -et && D <= et && B >= -gt && B <= gt;
|
|
7183
|
+
}, Te = at(() => {
|
|
7184
|
+
(T || u || z) && rt(), R(!1), E(!1), S(!1), Q(null);
|
|
7185
|
+
const e = X.current;
|
|
7153
7186
|
e && (e.style.cursor = "default");
|
|
7154
|
-
}, [
|
|
7187
|
+
}, [T, u, z, rt]);
|
|
7155
7188
|
it(() => {
|
|
7156
7189
|
const e = (t) => {
|
|
7157
7190
|
if (s) return;
|
|
7158
7191
|
const r = document.activeElement;
|
|
7159
|
-
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(),
|
|
7192
|
+
if (!(r && (r.tagName === "INPUT" || r.tagName === "TEXTAREA" || r.tagName === "SELECT" || r.isContentEditable)) && ((t.ctrlKey || t.metaKey) && (t.key === "z" && !t.shiftKey ? (t.preventDefault(), kt()) : (t.key === "z" && t.shiftKey || t.key === "y") && (t.preventDefault(), wt())), (t.key === "Delete" || t.key === "Backspace") && d && (Et(d.id), t.preventDefault()), (t.ctrlKey || t.metaKey) && t.key === "d" && d && (Ut(d.id), t.preventDefault()), d && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(t.key))) {
|
|
7160
7193
|
t.preventDefault();
|
|
7161
|
-
const
|
|
7162
|
-
let
|
|
7194
|
+
const g = t.shiftKey ? 10 : 1;
|
|
7195
|
+
let m = {};
|
|
7163
7196
|
switch (t.key) {
|
|
7164
7197
|
case "ArrowUp":
|
|
7165
|
-
|
|
7198
|
+
m.y = d.y - g;
|
|
7166
7199
|
break;
|
|
7167
7200
|
case "ArrowDown":
|
|
7168
|
-
|
|
7201
|
+
m.y = d.y + g;
|
|
7169
7202
|
break;
|
|
7170
7203
|
case "ArrowLeft":
|
|
7171
|
-
|
|
7204
|
+
m.x = d.x - g;
|
|
7172
7205
|
break;
|
|
7173
7206
|
case "ArrowRight":
|
|
7174
|
-
|
|
7207
|
+
m.x = d.x + g;
|
|
7175
7208
|
break;
|
|
7176
7209
|
}
|
|
7177
|
-
|
|
7210
|
+
Pt(d.id, m), rt();
|
|
7178
7211
|
}
|
|
7179
7212
|
};
|
|
7180
7213
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
7181
|
-
}, [
|
|
7182
|
-
const
|
|
7214
|
+
}, [d, kt, wt, s]);
|
|
7215
|
+
const Ne = (e, t = {}) => {
|
|
7183
7216
|
const r = {
|
|
7184
7217
|
id: dt(),
|
|
7185
7218
|
type: e,
|
|
@@ -7204,16 +7237,16 @@ const fi = $e((f, o) => {
|
|
|
7204
7237
|
r.id = dt(), r.imageData = t.imageData || null, r.width = t.width || 200, r.height = t.height || 200;
|
|
7205
7238
|
break;
|
|
7206
7239
|
case "qrcode":
|
|
7207
|
-
r.id = dt(), r.type = "qrcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 100) / 2, r.y = (t == null ? void 0 : t.y) ||
|
|
7240
|
+
r.id = dt(), r.type = "qrcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 100) / 2, r.y = (t == null ? void 0 : t.y) || W / 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;
|
|
7208
7241
|
break;
|
|
7209
7242
|
case "barcode":
|
|
7210
|
-
r.id = dt(), r.type = "barcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 200) / 2, r.y = (t == null ? void 0 : t.y) ||
|
|
7243
|
+
r.id = dt(), r.type = "barcode", r.x = (t == null ? void 0 : t.x) || k / 2 - ((t == null ? void 0 : t.width) || 200) / 2, r.y = (t == null ? void 0 : t.y) || W / 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;
|
|
7211
7244
|
break;
|
|
7212
7245
|
case "sticker":
|
|
7213
7246
|
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;
|
|
7214
7247
|
break;
|
|
7215
7248
|
case "horizontalLine":
|
|
7216
|
-
r.id = dt(), r.type = "horizontalLine", r.x = k / 2 - 100, r.y =
|
|
7249
|
+
r.id = dt(), r.type = "horizontalLine", r.x = k / 2 - 100, r.y = W / 2 - 1, r.width = 200, r.height = 2, r.fill = "#000000", r.stroke = "#000000", r.strokeWidth = 2, r.rotation = 0, r.opacity = 1;
|
|
7217
7250
|
break;
|
|
7218
7251
|
case "embroidery":
|
|
7219
7252
|
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;
|
|
@@ -7234,15 +7267,15 @@ const fi = $e((f, o) => {
|
|
|
7234
7267
|
console.warn(`Unknown element type: ${e}`);
|
|
7235
7268
|
return;
|
|
7236
7269
|
}
|
|
7237
|
-
l((c) => [...c, r]), F(r),
|
|
7238
|
-
},
|
|
7270
|
+
l((c) => [...c, r]), F(r), rt();
|
|
7271
|
+
}, Pt = (e, t) => {
|
|
7239
7272
|
l((r) => r.map(
|
|
7240
7273
|
(c) => c.id === e ? { ...c, ...t } : c
|
|
7241
|
-
)),
|
|
7242
|
-
},
|
|
7243
|
-
|
|
7244
|
-
}, [
|
|
7245
|
-
const t =
|
|
7274
|
+
)), d && d.id === e && F((r) => ({ ...r, ...t }));
|
|
7275
|
+
}, Et = at(() => {
|
|
7276
|
+
d && (l((e) => e.filter((t) => t.id !== d.id)), F(null), rt());
|
|
7277
|
+
}, [d, rt]), Ut = (e) => {
|
|
7278
|
+
const t = x.find((r) => r.id === e);
|
|
7246
7279
|
if (t) {
|
|
7247
7280
|
const r = {
|
|
7248
7281
|
...t,
|
|
@@ -7250,49 +7283,56 @@ const fi = $e((f, o) => {
|
|
|
7250
7283
|
x: t.x + 20,
|
|
7251
7284
|
y: t.y + 20
|
|
7252
7285
|
};
|
|
7253
|
-
l((c) => [...c, r]), F(r),
|
|
7286
|
+
l((c) => [...c, r]), F(r), rt();
|
|
7254
7287
|
}
|
|
7255
|
-
},
|
|
7256
|
-
const r =
|
|
7288
|
+
}, Ot = (e, t) => {
|
|
7289
|
+
const r = x.findIndex((m) => m.id === e);
|
|
7257
7290
|
if (r === -1) return;
|
|
7258
|
-
const c = [...
|
|
7259
|
-
t === "up" && r < c.length - 1 ? (c[r] = c[r + 1], c[r + 1] =
|
|
7291
|
+
const c = [...x], g = c[r];
|
|
7292
|
+
t === "up" && r < c.length - 1 ? (c[r] = c[r + 1], c[r + 1] = g) : t === "down" && r > 0 ? (c[r] = c[r - 1], c[r - 1] = g) : t === "top" ? (c.splice(r, 1), c.push(g)) : t === "bottom" && (c.splice(r, 1), c.unshift(g)), l(c), rt();
|
|
7260
7293
|
};
|
|
7261
|
-
|
|
7262
|
-
|
|
7294
|
+
at(() => {
|
|
7295
|
+
p && H((e) => ({
|
|
7263
7296
|
...e,
|
|
7264
|
-
[
|
|
7265
|
-
elements: [...
|
|
7266
|
-
selectedColor:
|
|
7297
|
+
[p.sectionName]: {
|
|
7298
|
+
elements: [...x],
|
|
7299
|
+
selectedColor: $
|
|
7267
7300
|
}
|
|
7268
7301
|
}));
|
|
7269
|
-
}, [
|
|
7270
|
-
const [,
|
|
7302
|
+
}, [p, x, $]);
|
|
7303
|
+
const [, Ae] = Le((e) => e + 1, 0);
|
|
7271
7304
|
setTimeout(() => {
|
|
7272
|
-
|
|
7273
|
-
}, 20),
|
|
7274
|
-
handleSectionChange:
|
|
7305
|
+
Ae();
|
|
7306
|
+
}, 20), Pe(o, () => ({
|
|
7307
|
+
handleSectionChange: Qt,
|
|
7275
7308
|
// Export methods that return download-ready data
|
|
7276
|
-
exportPrintReady: async (e = "png") => await
|
|
7277
|
-
exportFullDesign: async (e = "png") => await
|
|
7309
|
+
exportPrintReady: async (e = "png") => await Rt(e, !1),
|
|
7310
|
+
exportFullDesign: async (e = "png") => await Rt(e, !0),
|
|
7278
7311
|
// Access to the existing exportDesign method
|
|
7279
|
-
exportDesign:
|
|
7312
|
+
exportDesign: Rt,
|
|
7280
7313
|
// Get canvas data for custom exports
|
|
7281
|
-
getCanvasData: () =>
|
|
7314
|
+
getCanvasData: () => vt(),
|
|
7282
7315
|
// NEW: Export methods that return JSON with File objects
|
|
7283
7316
|
exportAllDesignsAsJSON: async (e = "png") => {
|
|
7284
7317
|
try {
|
|
7285
|
-
const t =
|
|
7286
|
-
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
7318
|
+
const t = vt(), r = {}, c = (p == null ? void 0 : p.sectionName) || "main";
|
|
7319
|
+
r[c] = {
|
|
7320
|
+
elements: t.elements,
|
|
7321
|
+
selectedColor: t.selectedColor,
|
|
7322
|
+
canvasWidth: t.canvasWidth,
|
|
7323
|
+
canvasHeight: t.canvasHeight
|
|
7324
|
+
}, t.sectionDesigns && typeof t.sectionDesigns == "object" && Object.assign(r, t.sectionDesigns);
|
|
7325
|
+
const g = h.sections && h.sections.length > 0 ? h.sections : [{
|
|
7326
|
+
id: c,
|
|
7327
|
+
sectionName: c,
|
|
7328
|
+
image: p == null ? void 0 : p.sectionImage,
|
|
7329
|
+
sectionImage: p == null ? void 0 : p.sectionImage
|
|
7330
|
+
}];
|
|
7331
|
+
return await It.current.exportAllSectionsAsJSON(
|
|
7332
|
+
r,
|
|
7333
|
+
g,
|
|
7294
7334
|
k,
|
|
7295
|
-
|
|
7335
|
+
W,
|
|
7296
7336
|
e
|
|
7297
7337
|
);
|
|
7298
7338
|
} catch (t) {
|
|
@@ -7301,182 +7341,182 @@ const fi = $e((f, o) => {
|
|
|
7301
7341
|
},
|
|
7302
7342
|
exportCurrentSectionAsJSON: async (e = "png") => {
|
|
7303
7343
|
try {
|
|
7304
|
-
const t =
|
|
7305
|
-
return await
|
|
7344
|
+
const t = vt();
|
|
7345
|
+
return await It.current.exportCurrentSectionAsJSON(t, e);
|
|
7306
7346
|
} catch (t) {
|
|
7307
7347
|
throw console.error("Export current section as JSON failed:", t), t;
|
|
7308
7348
|
}
|
|
7309
7349
|
}
|
|
7310
7350
|
})), it(() => {
|
|
7311
|
-
|
|
7312
|
-
const e =
|
|
7313
|
-
if (e && e.getContext("2d").clearRect(0, 0, k,
|
|
7351
|
+
ft.current = null, yt.current = null;
|
|
7352
|
+
const e = X.current;
|
|
7353
|
+
if (e && e.getContext("2d").clearRect(0, 0, k, W), p != null && p.sectionImage) {
|
|
7314
7354
|
const t = new Image();
|
|
7315
7355
|
t.crossOrigin = "anonymous", t.onload = () => {
|
|
7316
|
-
t.src ===
|
|
7356
|
+
t.src === p.sectionImage && (ft.current = t, Nt(t, $));
|
|
7317
7357
|
}, t.onerror = () => {
|
|
7318
|
-
console.error("Failed to load background image:",
|
|
7319
|
-
}, t.src =
|
|
7358
|
+
console.error("Failed to load background image:", p.sectionImage), V();
|
|
7359
|
+
}, t.src = p.sectionImage;
|
|
7320
7360
|
} else
|
|
7321
7361
|
V();
|
|
7322
|
-
}, [
|
|
7323
|
-
const V =
|
|
7324
|
-
const e =
|
|
7362
|
+
}, [p == null ? void 0 : p.sectionImage]);
|
|
7363
|
+
const V = at(() => {
|
|
7364
|
+
const e = X.current;
|
|
7325
7365
|
if (!e) return;
|
|
7326
7366
|
const t = e.getContext("2d");
|
|
7327
|
-
t.clearRect(0, 0, k,
|
|
7328
|
-
|
|
7329
|
-
}),
|
|
7330
|
-
}, [
|
|
7367
|
+
t.clearRect(0, 0, k, W), yt.current && t.drawImage(yt.current, 0, 0, k, W), L && le(t), x.forEach((r) => {
|
|
7368
|
+
ne(t, r);
|
|
7369
|
+
}), d && re(t, d), requestAnimationFrame(V);
|
|
7370
|
+
}, [x, d, k, W, L, yt]), Ie = at((e) => {
|
|
7331
7371
|
if (s) return;
|
|
7332
|
-
const r =
|
|
7333
|
-
if (
|
|
7334
|
-
const w =
|
|
7372
|
+
const r = X.current.getBoundingClientRect(), c = (e.clientX - r.left) / O, g = (e.clientY - r.top) / O;
|
|
7373
|
+
if (K({ x: c, y: g }), d) {
|
|
7374
|
+
const w = Mt(c, g, d);
|
|
7335
7375
|
if (w) {
|
|
7336
7376
|
if (w === "rotate") {
|
|
7337
7377
|
S(!0);
|
|
7338
|
-
const v =
|
|
7339
|
-
|
|
7378
|
+
const v = d.x + d.width / 2, b = d.y + d.height / 2, A = Math.atan2(g - b, c - v) * 180 / Math.PI;
|
|
7379
|
+
K({
|
|
7340
7380
|
x: c,
|
|
7341
|
-
y:
|
|
7381
|
+
y: g,
|
|
7342
7382
|
initialAngle: A,
|
|
7343
|
-
initialRotation:
|
|
7383
|
+
initialRotation: d.rotation || 0
|
|
7344
7384
|
});
|
|
7345
7385
|
} else
|
|
7346
|
-
E(!0),
|
|
7386
|
+
E(!0), Q(w), K({
|
|
7347
7387
|
x: c,
|
|
7348
|
-
y:
|
|
7349
|
-
initialWidth:
|
|
7350
|
-
initialHeight:
|
|
7351
|
-
initialX:
|
|
7352
|
-
initialY:
|
|
7388
|
+
y: g,
|
|
7389
|
+
initialWidth: d.width,
|
|
7390
|
+
initialHeight: d.height,
|
|
7391
|
+
initialX: d.x,
|
|
7392
|
+
initialY: d.y
|
|
7353
7393
|
});
|
|
7354
7394
|
return;
|
|
7355
7395
|
}
|
|
7356
7396
|
}
|
|
7357
|
-
let
|
|
7358
|
-
for (let w =
|
|
7359
|
-
if (
|
|
7360
|
-
|
|
7397
|
+
let m = null;
|
|
7398
|
+
for (let w = x.length - 1; w >= 0; w--)
|
|
7399
|
+
if (Lt(c, g, x[w])) {
|
|
7400
|
+
m = x[w];
|
|
7361
7401
|
break;
|
|
7362
7402
|
}
|
|
7363
|
-
|
|
7403
|
+
m ? (F(m), R(!0), K({
|
|
7364
7404
|
x: c,
|
|
7365
|
-
y:
|
|
7366
|
-
offsetX: c -
|
|
7367
|
-
offsetY:
|
|
7405
|
+
y: g,
|
|
7406
|
+
offsetX: c - m.x,
|
|
7407
|
+
offsetY: g - m.y
|
|
7368
7408
|
})) : F(null), V();
|
|
7369
|
-
}, [s, O,
|
|
7409
|
+
}, [s, O, d, x, V]), Re = at((e) => {
|
|
7370
7410
|
if (s) return;
|
|
7371
|
-
const t =
|
|
7372
|
-
if (
|
|
7373
|
-
const
|
|
7374
|
-
|
|
7411
|
+
const t = X.current, r = t.getBoundingClientRect(), c = (e.clientX - r.left) / O, g = (e.clientY - r.top) / O;
|
|
7412
|
+
if (d && !T && !u && !z) {
|
|
7413
|
+
const m = Mt(c, g, d);
|
|
7414
|
+
m ? m === "rotate" ? t.style.cursor = "grab" : t.style.cursor = m : Lt(c, g, d) ? t.style.cursor = "move" : t.style.cursor = "default";
|
|
7375
7415
|
} else
|
|
7376
|
-
t.style.cursor =
|
|
7377
|
-
if (
|
|
7378
|
-
const
|
|
7379
|
-
let A =
|
|
7416
|
+
t.style.cursor = T ? "grabbing" : "default";
|
|
7417
|
+
if (z && d) {
|
|
7418
|
+
const m = d.x + d.width / 2, w = d.y + d.height / 2, b = Math.atan2(g - w, c - m) * 180 / Math.PI - j.initialAngle;
|
|
7419
|
+
let A = j.initialRotation + b;
|
|
7380
7420
|
e.shiftKey && (A = Math.round(A / 15) * 15), A = (A % 360 + 360) % 360, l(
|
|
7381
7421
|
(D) => D.map(
|
|
7382
|
-
(
|
|
7422
|
+
(B) => B.id === d.id ? { ...B, rotation: A } : B
|
|
7383
7423
|
)
|
|
7384
7424
|
), F((D) => ({ ...D, rotation: A })), V();
|
|
7385
7425
|
return;
|
|
7386
7426
|
}
|
|
7387
|
-
if (
|
|
7388
|
-
const
|
|
7389
|
-
let v =
|
|
7427
|
+
if (u && d && C) {
|
|
7428
|
+
const m = c - j.x, w = g - j.y;
|
|
7429
|
+
let v = j.initialWidth, b = j.initialHeight, A = j.initialX, D = j.initialY;
|
|
7390
7430
|
switch (C) {
|
|
7391
7431
|
case "se-resize":
|
|
7392
|
-
v = Math.max(20,
|
|
7432
|
+
v = Math.max(20, j.initialWidth + m), b = Math.max(20, j.initialHeight + w);
|
|
7393
7433
|
break;
|
|
7394
7434
|
case "sw-resize":
|
|
7395
|
-
v = Math.max(20,
|
|
7435
|
+
v = Math.max(20, j.initialWidth - m), b = Math.max(20, j.initialHeight + w), A = j.initialX + (j.initialWidth - v);
|
|
7396
7436
|
break;
|
|
7397
7437
|
case "ne-resize":
|
|
7398
|
-
v = Math.max(20,
|
|
7438
|
+
v = Math.max(20, j.initialWidth + m), b = Math.max(20, j.initialHeight - w), D = j.initialY + (j.initialHeight - b);
|
|
7399
7439
|
break;
|
|
7400
7440
|
case "nw-resize":
|
|
7401
|
-
v = Math.max(20,
|
|
7441
|
+
v = Math.max(20, j.initialWidth - m), b = Math.max(20, j.initialHeight - w), A = j.initialX + (j.initialWidth - v), D = j.initialY + (j.initialHeight - b);
|
|
7402
7442
|
break;
|
|
7403
7443
|
}
|
|
7404
|
-
if (e.shiftKey &&
|
|
7405
|
-
const
|
|
7406
|
-
C.includes("e"), b = v /
|
|
7444
|
+
if (e.shiftKey && d.type !== "text") {
|
|
7445
|
+
const et = j.initialWidth / j.initialHeight;
|
|
7446
|
+
C.includes("e"), b = v / et, C.includes("n") && (D = j.initialY + (j.initialHeight - b));
|
|
7407
7447
|
}
|
|
7408
|
-
_ && (A =
|
|
7409
|
-
const
|
|
7410
|
-
...
|
|
7448
|
+
_ && (A = ut(A), D = ut(D), v = ut(v), b = ut(b));
|
|
7449
|
+
const B = {
|
|
7450
|
+
...d,
|
|
7411
7451
|
x: A,
|
|
7412
7452
|
y: D,
|
|
7413
7453
|
width: v,
|
|
7414
7454
|
height: b
|
|
7415
7455
|
};
|
|
7416
7456
|
l(
|
|
7417
|
-
(
|
|
7418
|
-
(gt) => gt.id ===
|
|
7457
|
+
(et) => et.map(
|
|
7458
|
+
(gt) => gt.id === d.id ? B : gt
|
|
7419
7459
|
)
|
|
7420
|
-
), F(
|
|
7460
|
+
), F(B), V();
|
|
7421
7461
|
return;
|
|
7422
7462
|
}
|
|
7423
|
-
if (
|
|
7424
|
-
let
|
|
7425
|
-
_ && (
|
|
7463
|
+
if (T && d) {
|
|
7464
|
+
let m = c - j.offsetX, w = g - j.offsetY;
|
|
7465
|
+
_ && (m = ut(m), w = ut(w)), m = Math.max(0, Math.min(k - d.width, m)), w = Math.max(0, Math.min(W - d.height, w));
|
|
7426
7466
|
const v = {
|
|
7427
|
-
...
|
|
7428
|
-
x:
|
|
7467
|
+
...d,
|
|
7468
|
+
x: m,
|
|
7429
7469
|
y: w
|
|
7430
7470
|
};
|
|
7431
7471
|
l(
|
|
7432
7472
|
(b) => b.map(
|
|
7433
|
-
(A) => A.id ===
|
|
7473
|
+
(A) => A.id === d.id ? v : A
|
|
7434
7474
|
)
|
|
7435
7475
|
), F(v), V();
|
|
7436
7476
|
}
|
|
7437
|
-
}, [s, O,
|
|
7438
|
-
|
|
7477
|
+
}, [s, O, d, T, u, z, C, j, _, k, W, x, V]), Qt = at((e) => {
|
|
7478
|
+
p && H((r) => ({
|
|
7439
7479
|
...r,
|
|
7440
|
-
[
|
|
7441
|
-
elements:
|
|
7480
|
+
[p.sectionName]: {
|
|
7481
|
+
elements: x.map((c) => c.type === "image" ? {
|
|
7442
7482
|
...c,
|
|
7443
7483
|
// Keep the image data reference
|
|
7444
7484
|
imageData: c.imageData,
|
|
7445
7485
|
src: c.src
|
|
7446
7486
|
} : c),
|
|
7447
|
-
selectedColor:
|
|
7487
|
+
selectedColor: $
|
|
7448
7488
|
}
|
|
7449
7489
|
}));
|
|
7450
|
-
const t =
|
|
7490
|
+
const t = M[e.sectionName];
|
|
7451
7491
|
if (t) {
|
|
7452
7492
|
const r = t.elements.map((c) => {
|
|
7453
7493
|
if (c.type === "image" && c.src && !c.imageData) {
|
|
7454
|
-
const
|
|
7455
|
-
return
|
|
7494
|
+
const g = new Image();
|
|
7495
|
+
return g.onload = () => {
|
|
7456
7496
|
l(
|
|
7457
|
-
(
|
|
7458
|
-
(w) => w.id === c.id ? { ...w, imageData:
|
|
7497
|
+
(m) => m.map(
|
|
7498
|
+
(w) => w.id === c.id ? { ...w, imageData: g } : w
|
|
7459
7499
|
)
|
|
7460
7500
|
), V();
|
|
7461
|
-
},
|
|
7501
|
+
}, g.src = c.src, { ...c, imageData: g };
|
|
7462
7502
|
}
|
|
7463
7503
|
return c;
|
|
7464
7504
|
});
|
|
7465
|
-
l(r),
|
|
7505
|
+
l(r), ot(t.selectedColor || $);
|
|
7466
7506
|
} else
|
|
7467
7507
|
l([]);
|
|
7468
|
-
|
|
7469
|
-
}, [
|
|
7508
|
+
Z(e), F(null);
|
|
7509
|
+
}, [p, x, $, M, V]), De = at((e) => {
|
|
7470
7510
|
if (e && e.type.startsWith("image/")) {
|
|
7471
7511
|
const t = new FileReader();
|
|
7472
7512
|
t.onload = (r) => {
|
|
7473
7513
|
const c = new Image();
|
|
7474
7514
|
c.onload = () => {
|
|
7475
|
-
const
|
|
7515
|
+
const g = {
|
|
7476
7516
|
id: dt(),
|
|
7477
7517
|
type: "image",
|
|
7478
|
-
x:
|
|
7479
|
-
y:
|
|
7518
|
+
x: ut(k / 2 - 100),
|
|
7519
|
+
y: ut(W / 2 - 100),
|
|
7480
7520
|
width: Math.min(c.width, 200),
|
|
7481
7521
|
// Limit initial size
|
|
7482
7522
|
height: Math.min(c.height, 200),
|
|
@@ -7485,8 +7525,8 @@ const fi = $e((f, o) => {
|
|
|
7485
7525
|
src: r.target.result,
|
|
7486
7526
|
originalWidth: c.width,
|
|
7487
7527
|
originalHeight: c.height
|
|
7488
|
-
},
|
|
7489
|
-
|
|
7528
|
+
}, m = c.width / c.height;
|
|
7529
|
+
g.width / g.height !== m && (g.width / m <= 200 ? g.height = g.width / m : g.width = g.height * m), l((w) => [...w, g]), F(g), rt();
|
|
7490
7530
|
}, c.onerror = () => {
|
|
7491
7531
|
console.error("Failed to load uploaded image"), alert("Failed to load the uploaded image. Please try again.");
|
|
7492
7532
|
}, c.src = r.target.result;
|
|
@@ -7495,70 +7535,70 @@ const fi = $e((f, o) => {
|
|
|
7495
7535
|
}, t.readAsDataURL(e);
|
|
7496
7536
|
} else
|
|
7497
7537
|
alert("Please select a valid image file.");
|
|
7498
|
-
}, [k,
|
|
7538
|
+
}, [k, W, ut, dt, rt]);
|
|
7499
7539
|
it(() => {
|
|
7500
|
-
if (
|
|
7501
|
-
|
|
7540
|
+
if (p != null && p.sectionImage) {
|
|
7541
|
+
pt.current = !0, ft.current = null, yt.current = null;
|
|
7502
7542
|
const e = new Image();
|
|
7503
7543
|
e.crossOrigin = "anonymous", e.onload = () => {
|
|
7504
|
-
|
|
7544
|
+
ft.current = e, Nt(e, $);
|
|
7505
7545
|
}, e.onerror = () => {
|
|
7506
|
-
console.error("Failed to load background image:",
|
|
7507
|
-
}, e.src =
|
|
7546
|
+
console.error("Failed to load background image:", p.sectionImage), pt.current = !1, V();
|
|
7547
|
+
}, e.src = p.sectionImage;
|
|
7508
7548
|
} else
|
|
7509
|
-
|
|
7510
|
-
}, [
|
|
7511
|
-
const
|
|
7512
|
-
|
|
7549
|
+
ft.current = null, yt.current = null, pt.current = !1, V();
|
|
7550
|
+
}, [p == null ? void 0 : p.sectionImage, $]);
|
|
7551
|
+
const $t = at(
|
|
7552
|
+
Ee(() => {
|
|
7513
7553
|
V();
|
|
7514
7554
|
}, 16),
|
|
7515
7555
|
// 60fps limit
|
|
7516
7556
|
[V]
|
|
7517
7557
|
);
|
|
7518
7558
|
it(() => {
|
|
7519
|
-
|
|
7520
|
-
}, [
|
|
7521
|
-
function
|
|
7559
|
+
pt.current || $t();
|
|
7560
|
+
}, [x, d, L, $t]);
|
|
7561
|
+
function Ee(e, t) {
|
|
7522
7562
|
let r;
|
|
7523
|
-
return function(...
|
|
7524
|
-
const
|
|
7525
|
-
clearTimeout(r), e(...
|
|
7563
|
+
return function(...g) {
|
|
7564
|
+
const m = () => {
|
|
7565
|
+
clearTimeout(r), e(...g);
|
|
7526
7566
|
};
|
|
7527
|
-
clearTimeout(r), r = setTimeout(
|
|
7567
|
+
clearTimeout(r), r = setTimeout(m, t);
|
|
7528
7568
|
};
|
|
7529
7569
|
}
|
|
7530
7570
|
it(() => {
|
|
7531
|
-
|
|
7532
|
-
}, [
|
|
7571
|
+
ft.current && Nt(ft.current, $);
|
|
7572
|
+
}, [$]), it(() => {
|
|
7533
7573
|
V();
|
|
7534
7574
|
}, [V]);
|
|
7535
|
-
const
|
|
7536
|
-
const r =
|
|
7537
|
-
r.width = k, r.height =
|
|
7538
|
-
const
|
|
7575
|
+
const ze = (e, t, r) => (0.2126 * e + 0.7152 * t + 0.0722 * r) / 255, Nt = at((e, t) => {
|
|
7576
|
+
const r = Bt.current, c = r.getContext("2d");
|
|
7577
|
+
r.width = k, r.height = W, c.clearRect(0, 0, k, W), c.drawImage(e, 0, 0, k, W);
|
|
7578
|
+
const g = c.getImageData(0, 0, k, W), m = g.data, w = se(t);
|
|
7539
7579
|
if (!w) {
|
|
7540
|
-
|
|
7580
|
+
pt.current = !1;
|
|
7541
7581
|
return;
|
|
7542
7582
|
}
|
|
7543
7583
|
const { r: v, g: b, b: A } = w;
|
|
7544
|
-
for (let
|
|
7545
|
-
if (
|
|
7546
|
-
const gt =
|
|
7547
|
-
|
|
7584
|
+
for (let B = 0; B < m.length; B += 4) {
|
|
7585
|
+
if (m[B + 3] === 0) continue;
|
|
7586
|
+
const gt = ze(m[B], m[B + 1], m[B + 2]);
|
|
7587
|
+
m[B] = Math.round(v * gt), m[B + 1] = Math.round(b * gt), m[B + 2] = Math.round(A * gt);
|
|
7548
7588
|
}
|
|
7549
|
-
c.putImageData(
|
|
7589
|
+
c.putImageData(g, 0, 0);
|
|
7550
7590
|
const D = new Image();
|
|
7551
7591
|
D.onload = () => {
|
|
7552
|
-
|
|
7592
|
+
yt.current = D, pt.current = !1, V();
|
|
7553
7593
|
}, D.src = r.toDataURL("image/png");
|
|
7554
|
-
}, [k,
|
|
7555
|
-
if (!
|
|
7594
|
+
}, [k, W, V]), Ht = (e) => {
|
|
7595
|
+
if (!J) return { horizontal: [], vertical: [] };
|
|
7556
7596
|
const t = document.querySelector(".ruler-horizontal"), r = document.querySelector(".ruler-vertical");
|
|
7557
7597
|
if (!t || !r)
|
|
7558
7598
|
return { horizontal: [], vertical: [] };
|
|
7559
|
-
const c = t.getBoundingClientRect(),
|
|
7560
|
-
for (let D = v; D <=
|
|
7561
|
-
D <=
|
|
7599
|
+
const c = t.getBoundingClientRect(), g = r.getBoundingClientRect(), m = c.width, w = g.height, v = 50, b = [], A = [];
|
|
7600
|
+
for (let D = v; D <= m; D += v)
|
|
7601
|
+
D <= m - 20 && b.push({
|
|
7562
7602
|
position: D,
|
|
7563
7603
|
value: Math.round(D / e)
|
|
7564
7604
|
});
|
|
@@ -7568,12 +7608,12 @@ const fi = $e((f, o) => {
|
|
|
7568
7608
|
value: Math.round(D / e)
|
|
7569
7609
|
});
|
|
7570
7610
|
return { horizontal: b, vertical: A };
|
|
7571
|
-
}, [
|
|
7611
|
+
}, [Gt, _t] = N({ horizontal: [], vertical: [] });
|
|
7572
7612
|
return it(() => {
|
|
7573
7613
|
const e = () => {
|
|
7574
7614
|
setTimeout(() => {
|
|
7575
|
-
const c =
|
|
7576
|
-
|
|
7615
|
+
const c = Ht(O);
|
|
7616
|
+
_t(c);
|
|
7577
7617
|
}, 50);
|
|
7578
7618
|
};
|
|
7579
7619
|
e();
|
|
@@ -7584,33 +7624,33 @@ const fi = $e((f, o) => {
|
|
|
7584
7624
|
return window.addEventListener("resize", r), () => {
|
|
7585
7625
|
window.removeEventListener("resize", r), clearTimeout(t);
|
|
7586
7626
|
};
|
|
7587
|
-
}, [O,
|
|
7588
|
-
if (
|
|
7627
|
+
}, [O, J]), it(() => {
|
|
7628
|
+
if (J && !y) {
|
|
7589
7629
|
const e = setTimeout(() => {
|
|
7590
|
-
const t =
|
|
7591
|
-
|
|
7630
|
+
const t = Ht(O);
|
|
7631
|
+
_t(t);
|
|
7592
7632
|
}, 100);
|
|
7593
7633
|
return () => clearTimeout(e);
|
|
7594
7634
|
}
|
|
7595
|
-
}, [
|
|
7635
|
+
}, [J, y, O]), /* @__PURE__ */ i.jsxs("div", { className: "pure-canvas-designer", children: [
|
|
7596
7636
|
/* @__PURE__ */ i.jsx("div", { className: "designer-header", children: /* @__PURE__ */ i.jsx(
|
|
7597
|
-
|
|
7637
|
+
ti,
|
|
7598
7638
|
{
|
|
7599
|
-
onAddElement:
|
|
7600
|
-
onDeleteElement: () =>
|
|
7601
|
-
onDuplicateElement: () =>
|
|
7602
|
-
onUndo:
|
|
7603
|
-
onRedo:
|
|
7604
|
-
onToggleGrid: () => lt(!
|
|
7605
|
-
onToggleRulers: () => nt(!
|
|
7606
|
-
onToggleSnap: () =>
|
|
7607
|
-
onImageUpload:
|
|
7639
|
+
onAddElement: Ne,
|
|
7640
|
+
onDeleteElement: () => d && Et(d.id),
|
|
7641
|
+
onDuplicateElement: () => d && Ut(d.id),
|
|
7642
|
+
onUndo: kt,
|
|
7643
|
+
onRedo: wt,
|
|
7644
|
+
onToggleGrid: () => lt(!L),
|
|
7645
|
+
onToggleRulers: () => nt(!J),
|
|
7646
|
+
onToggleSnap: () => P(!_),
|
|
7647
|
+
onImageUpload: De,
|
|
7608
7648
|
canUndo: q > 0,
|
|
7609
7649
|
canRedo: q < G.length - 1,
|
|
7610
|
-
showGrid:
|
|
7611
|
-
showRulers:
|
|
7650
|
+
showGrid: L,
|
|
7651
|
+
showRulers: J,
|
|
7612
7652
|
snapToGrid: _,
|
|
7613
|
-
selectedElement:
|
|
7653
|
+
selectedElement: d,
|
|
7614
7654
|
theme: a,
|
|
7615
7655
|
readOnly: s,
|
|
7616
7656
|
apiKey: f.apiKey,
|
|
@@ -7618,8 +7658,8 @@ const fi = $e((f, o) => {
|
|
|
7618
7658
|
}
|
|
7619
7659
|
) }),
|
|
7620
7660
|
/* @__PURE__ */ i.jsxs("div", { className: "designer-content", children: [
|
|
7621
|
-
|
|
7622
|
-
/* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal", children: /* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal-numbers", children:
|
|
7661
|
+
J && !y && /* @__PURE__ */ i.jsxs("div", { className: "rulers", children: [
|
|
7662
|
+
/* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal", children: /* @__PURE__ */ i.jsx("div", { className: "ruler-horizontal-numbers", children: Gt.horizontal.map((e, t) => /* @__PURE__ */ i.jsx(
|
|
7623
7663
|
"span",
|
|
7624
7664
|
{
|
|
7625
7665
|
className: "ruler-number horizontal",
|
|
@@ -7628,7 +7668,7 @@ const fi = $e((f, o) => {
|
|
|
7628
7668
|
},
|
|
7629
7669
|
t
|
|
7630
7670
|
)) }) }),
|
|
7631
|
-
/* @__PURE__ */ i.jsx("div", { className: "ruler-vertical", children: /* @__PURE__ */ i.jsx("div", { className: "ruler-vertical-numbers", children:
|
|
7671
|
+
/* @__PURE__ */ i.jsx("div", { className: "ruler-vertical", children: /* @__PURE__ */ i.jsx("div", { className: "ruler-vertical-numbers", children: Gt.vertical.map((e, t) => /* @__PURE__ */ i.jsx(
|
|
7632
7672
|
"span",
|
|
7633
7673
|
{
|
|
7634
7674
|
className: "ruler-number vertical",
|
|
@@ -7638,18 +7678,18 @@ const fi = $e((f, o) => {
|
|
|
7638
7678
|
t
|
|
7639
7679
|
)) }) })
|
|
7640
7680
|
] }),
|
|
7641
|
-
/* @__PURE__ */ i.jsx("div", { className: "canvas-container", ref:
|
|
7681
|
+
/* @__PURE__ */ i.jsx("div", { className: "canvas-container", ref: bt, children: /* @__PURE__ */ i.jsx(
|
|
7642
7682
|
"canvas",
|
|
7643
7683
|
{
|
|
7644
|
-
ref:
|
|
7684
|
+
ref: X,
|
|
7645
7685
|
width: k,
|
|
7646
|
-
height:
|
|
7647
|
-
onMouseDown:
|
|
7648
|
-
onMouseMove:
|
|
7649
|
-
onMouseUp:
|
|
7686
|
+
height: W,
|
|
7687
|
+
onMouseDown: Ie,
|
|
7688
|
+
onMouseMove: Re,
|
|
7689
|
+
onMouseUp: Te,
|
|
7650
7690
|
style: {
|
|
7651
7691
|
border: "1px solid #e2e8f0",
|
|
7652
|
-
cursor:
|
|
7692
|
+
cursor: T ? "grabbing" : "default",
|
|
7653
7693
|
transform: `scale(${O})`,
|
|
7654
7694
|
transformOrigin: "top left"
|
|
7655
7695
|
}
|
|
@@ -7657,23 +7697,23 @@ const fi = $e((f, o) => {
|
|
|
7657
7697
|
) }),
|
|
7658
7698
|
/* @__PURE__ */ i.jsxs("div", { className: "side-panels", children: [
|
|
7659
7699
|
/* @__PURE__ */ i.jsx(
|
|
7660
|
-
|
|
7700
|
+
ei,
|
|
7661
7701
|
{
|
|
7662
|
-
selectedElement:
|
|
7663
|
-
onUpdate:
|
|
7664
|
-
onMoveLayer:
|
|
7665
|
-
availableFonts:
|
|
7702
|
+
selectedElement: d,
|
|
7703
|
+
onUpdate: Pt,
|
|
7704
|
+
onMoveLayer: Ot,
|
|
7705
|
+
availableFonts: oe,
|
|
7666
7706
|
theme: a
|
|
7667
7707
|
}
|
|
7668
7708
|
),
|
|
7669
7709
|
/* @__PURE__ */ i.jsx(
|
|
7670
|
-
|
|
7710
|
+
ii,
|
|
7671
7711
|
{
|
|
7672
|
-
elements:
|
|
7673
|
-
selectedElement:
|
|
7712
|
+
elements: x,
|
|
7713
|
+
selectedElement: d,
|
|
7674
7714
|
onSelectElement: F,
|
|
7675
|
-
onMoveLayer:
|
|
7676
|
-
onDeleteElement:
|
|
7715
|
+
onMoveLayer: Ot,
|
|
7716
|
+
onDeleteElement: Et,
|
|
7677
7717
|
theme: a
|
|
7678
7718
|
}
|
|
7679
7719
|
)
|
|
@@ -7686,15 +7726,15 @@ const fi = $e((f, o) => {
|
|
|
7686
7726
|
/* @__PURE__ */ i.jsx("u", { children: h.name })
|
|
7687
7727
|
] }),
|
|
7688
7728
|
/* @__PURE__ */ i.jsx("div", { className: "thumbnails-container", children: h.sections.map((e) => {
|
|
7689
|
-
const t =
|
|
7729
|
+
const t = M[e.sectionName] && M[e.sectionName].elements && M[e.sectionName].elements.length > 0;
|
|
7690
7730
|
return /* @__PURE__ */ i.jsxs(
|
|
7691
7731
|
"div",
|
|
7692
7732
|
{
|
|
7693
|
-
className: `section-thumbnail compact ${
|
|
7733
|
+
className: `section-thumbnail compact ${p.sectionName === e.sectionName ? "active" : ""}`,
|
|
7694
7734
|
onClick: (r) => {
|
|
7695
7735
|
r.stopPropagation();
|
|
7696
|
-
const c = h.sections.find((
|
|
7697
|
-
|
|
7736
|
+
const c = h.sections.find((g) => g.sectionName === e.sectionName);
|
|
7737
|
+
Qt(c);
|
|
7698
7738
|
},
|
|
7699
7739
|
title: e.sectionName,
|
|
7700
7740
|
children: [
|
|
@@ -7726,9 +7766,9 @@ const fi = $e((f, o) => {
|
|
|
7726
7766
|
h.colorSettings.slice(0, 3).map((e, t) => /* @__PURE__ */ i.jsxs(
|
|
7727
7767
|
"div",
|
|
7728
7768
|
{
|
|
7729
|
-
className: `color-swatch-enhanced compact ${
|
|
7769
|
+
className: `color-swatch-enhanced compact ${$ === e ? "active" : ""}`,
|
|
7730
7770
|
onClick: (r) => {
|
|
7731
|
-
r.stopPropagation(),
|
|
7771
|
+
r.stopPropagation(), ot(e);
|
|
7732
7772
|
},
|
|
7733
7773
|
title: `Change product to ${e}`,
|
|
7734
7774
|
children: [
|
|
@@ -7739,7 +7779,7 @@ const fi = $e((f, o) => {
|
|
|
7739
7779
|
style: { backgroundColor: e }
|
|
7740
7780
|
}
|
|
7741
7781
|
),
|
|
7742
|
-
|
|
7782
|
+
$ === e && /* @__PURE__ */ i.jsx("div", { className: "color-selection-ring compact" })
|
|
7743
7783
|
]
|
|
7744
7784
|
},
|
|
7745
7785
|
e
|
|
@@ -7765,9 +7805,9 @@ const fi = $e((f, o) => {
|
|
|
7765
7805
|
/* @__PURE__ */ i.jsx("div", { className: "color-dropdown-menu", style: { display: "none" }, children: h.colorSettings.slice(3).map((e, t) => /* @__PURE__ */ i.jsxs(
|
|
7766
7806
|
"div",
|
|
7767
7807
|
{
|
|
7768
|
-
className: `color-swatch-dropdown ${
|
|
7808
|
+
className: `color-swatch-dropdown ${$ === e ? "active" : ""}`,
|
|
7769
7809
|
onClick: (r) => {
|
|
7770
|
-
r.stopPropagation(),
|
|
7810
|
+
r.stopPropagation(), ot(e), r.currentTarget.parentElement.style.display = "none";
|
|
7771
7811
|
},
|
|
7772
7812
|
title: `Change product to ${e}`,
|
|
7773
7813
|
children: [
|
|
@@ -7854,7 +7894,7 @@ const fi = $e((f, o) => {
|
|
|
7854
7894
|
] })
|
|
7855
7895
|
] });
|
|
7856
7896
|
});
|
|
7857
|
-
|
|
7897
|
+
ai.displayName = "Mypixia";
|
|
7858
7898
|
export {
|
|
7859
|
-
|
|
7899
|
+
ai as default
|
|
7860
7900
|
};
|