@fraczled/sdk 1.30.66 → 1.31.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/README.md CHANGED
@@ -11,7 +11,7 @@ npm install @fraczled/sdk
11
11
  ## Server-gated delivery (required)
12
12
 
13
13
  To prevent unauthorized usage, always gate the SDK bundle through your backend.
14
- Use `/api/editor/init` to validate the license, then serve the SDK from `/api/editor/sdk`.
14
+ Use `/v1/editor/init` to validate the license, then serve the SDK from `/v1/editor/sdk`.
15
15
  See `docs/license-enforcement.md` for the full flow.
16
16
 
17
17
  ## Quick Start
@@ -0,0 +1,637 @@
1
+ import { g as Q, b as K, a as J, t as L, c as m, d as I, e as x, f as tt, h as ot, i as G, j as st, k as ft, l as ct, m as ht, s as dt, n as ut, E as B, o as gt, p as rt, q as et, r as nt, u as pt } from "./index-C2qSvudu.js";
2
+ const yt = {
3
+ normal: "source-over",
4
+ dissolve: "source-over",
5
+ darken: "darken",
6
+ multiply: "multiply",
7
+ "color-burn": "color-burn",
8
+ "linear-burn": "color-burn",
9
+ "darker-color": "darken",
10
+ lighten: "lighten",
11
+ screen: "screen",
12
+ "color-dodge": "color-dodge",
13
+ "linear-dodge": "screen",
14
+ "lighter-color": "lighten",
15
+ overlay: "overlay",
16
+ "soft-light": "soft-light",
17
+ "hard-light": "hard-light",
18
+ "vivid-light": "hard-light",
19
+ "linear-light": "hard-light",
20
+ "pin-light": "hard-light",
21
+ "hard-mix": "hard-light",
22
+ difference: "difference",
23
+ exclusion: "exclusion",
24
+ subtract: "difference",
25
+ divide: "difference",
26
+ hue: "hue",
27
+ saturation: "saturation",
28
+ color: "color",
29
+ luminosity: "luminosity"
30
+ }, wt = (t) => t && yt[t] || "source-over", bt = (t = "behind") => {
31
+ const o = ["adjustments"];
32
+ return t === "behind" && o.push("stroke-behind"), o.push("effect", "fill"), t === "front" && o.push("stroke-front"), o;
33
+ }, kt = (t, o) => !o || o === "none" ? t : o === "uppercase" ? t.toUpperCase() : o === "lowercase" ? t.toLowerCase() : o === "capitalize" ? t.replace(/\b\w/g, (s) => s.toUpperCase()) : t, R = (t, o, s) => o ? t.measureText(o).width + (o.length > 1 ? s * (o.length - 1) : 0) : 0, St = (t, o, s, n) => {
34
+ const a = [], e = o.split(`
35
+ `);
36
+ return e.forEach((i, f) => {
37
+ if (s === void 0 || s <= 0) {
38
+ a.push({ text: i, width: R(t, i, n) }), f < e.length - 1 && i === "" && a.push({ text: "", width: 0 });
39
+ return;
40
+ }
41
+ const r = i.split(/(\s+)/).filter((c) => c.length > 0);
42
+ let l = "";
43
+ r.forEach((c) => {
44
+ const d = l + c;
45
+ if (!l && (R(t, c, n) <= s || c.trim() === "")) {
46
+ l = c;
47
+ return;
48
+ }
49
+ if (R(t, d, n) <= s) {
50
+ l = d;
51
+ return;
52
+ }
53
+ if (l && a.push({ text: l, width: R(t, l, n) }), R(t, c, n) <= s) {
54
+ l = c;
55
+ return;
56
+ }
57
+ let h = "";
58
+ for (const g of c) {
59
+ const b = h + g;
60
+ if (!h || R(t, b, n) <= s) {
61
+ h = b;
62
+ continue;
63
+ }
64
+ a.push({ text: h, width: R(t, h, n) }), h = g;
65
+ }
66
+ l = h;
67
+ }), l && a.push({ text: l, width: R(t, l, n) }), f < e.length - 1 && i === "" && a.push({ text: "", width: 0 });
68
+ }), a;
69
+ }, Ct = (t, o, s) => {
70
+ const n = o.fontSize || 24, a = ft(
71
+ n,
72
+ o.fontFamily || "sans-serif",
73
+ o.fontWeight || "normal",
74
+ o.fontStyle || "normal"
75
+ ), e = (o.lineHeight ?? 1.4) * n, i = (o.letterSpacing ?? 0) * n, f = o.textAlign || "left", r = o.autoWidth ? void 0 : s, l = kt(o.content || "", o.textTransform);
76
+ t.save(), t.font = a;
77
+ const c = St(t, l, r, i), d = ct({
78
+ ctx: t,
79
+ fontSize: n,
80
+ fontFamily: o.fontFamily || "sans-serif",
81
+ fontWeight: o.fontWeight || "normal",
82
+ fontStyle: o.fontStyle || "normal",
83
+ lineHeight: o.lineHeight ?? 1.4,
84
+ sampleText: "Hg"
85
+ });
86
+ return t.restore(), {
87
+ lines: c,
88
+ lineHeight: e,
89
+ letterSpacing: i,
90
+ width: s,
91
+ align: f,
92
+ font: a,
93
+ offsetY: d.baselineOffset
94
+ };
95
+ }, U = (t, o, s, n, a, e) => {
96
+ if (!o) return;
97
+ if (a === 0) {
98
+ e === "fill" ? t.fillText(o, s, n) : t.strokeText(o, s, n);
99
+ return;
100
+ }
101
+ let i = s;
102
+ for (const f of o)
103
+ e === "fill" ? t.fillText(f, i, n) : t.strokeText(f, i, n), i += t.measureText(f).width + a;
104
+ }, C = (t, o, s) => {
105
+ const { lines: n, lineHeight: a, letterSpacing: e, width: i, align: f, font: r } = o, l = s.offsetX ?? 0, c = (o.offsetY ?? 0) + (s.offsetY ?? 0);
106
+ t.save(), t.font = r, t.textBaseline = "alphabetic", t.textAlign = "left", s.fillStyle && (t.fillStyle = s.fillStyle), s.strokeStyle && s.strokeWidth && (t.strokeStyle = s.strokeStyle, t.lineWidth = s.strokeWidth, t.lineJoin = s.lineJoin ?? "round", t.lineCap = s.lineCap ?? "round"), n.forEach((d, y) => {
107
+ const u = y * a + c, h = d.width;
108
+ let g = l;
109
+ f === "center" ? g = i / 2 - h / 2 + l : f === "right" && (g = i - h + l), s.strokeStyle && s.strokeWidth && U(t, d.text, g, u, e, "stroke"), s.fillStyle && U(t, d.text, g, u, e, "fill");
110
+ }), t.restore();
111
+ }, vt = (t, o, s, n, a, e) => {
112
+ const i = (n - 90) * Math.PI / 180, f = Math.cos(i), r = Math.sin(i), l = o / 2 - f * (o / 2), c = s / 2 - r * (s / 2), d = o / 2 + f * (o / 2), y = s / 2 + r * (s / 2), u = t.createLinearGradient(l, c, d, y);
113
+ return u.addColorStop(0, a), u.addColorStop(1, e), u;
114
+ }, Mt = (t, o, s) => {
115
+ const { lines: n, lineHeight: a, width: e, align: i } = o, f = s.spread, r = Math.max(0, s.roundness);
116
+ n.forEach((l, c) => {
117
+ const d = l.width;
118
+ let y = 0;
119
+ i === "center" ? y = e / 2 - d / 2 : i === "right" && (y = e - d);
120
+ const u = c * a, h = y - f, g = u, b = d + f * 2, v = a;
121
+ if (t.save(), t.fillStyle = s.fillStyle, t.beginPath(), r <= 0)
122
+ t.rect(h, g, b, v);
123
+ else {
124
+ const w = Math.min(r, b / 2, v / 2);
125
+ t.moveTo(h + w, g), t.lineTo(h + b - w, g), t.arcTo(h + b, g, h + b, g + w, w), t.lineTo(h + b, g + v - w), t.arcTo(h + b, g + v, h + b - w, g + v, w), t.lineTo(h + w, g + v), t.arcTo(h, g + v, h, g + v - w, w), t.lineTo(h, g + w), t.arcTo(h, g, h + w, g, w), t.closePath();
126
+ }
127
+ t.fill(), t.restore();
128
+ });
129
+ }, V = (t, o, s, n, a, e) => {
130
+ var W;
131
+ const i = Ct(t, o, s);
132
+ if (i.lines.length === 0) return;
133
+ const f = o.color || "#000000", r = Q(e, f), l = K((W = o.effect) == null ? void 0 : W.adjustments), c = e.blurAmount ?? 5, d = a === "blur" ? `${l} blur(${c}px)` : l, y = o.textStrokeWidth ?? 0, u = o.textStrokeColor || "#000000", h = o.textStrokePosition || "behind", g = o.textStrokeStyle || "round", b = g === "round" ? "round" : "miter", v = g === "round" ? "round" : "butt", w = () => {
134
+ y <= 0 || C(t, i, {
135
+ strokeStyle: u,
136
+ strokeWidth: y,
137
+ lineJoin: b,
138
+ lineCap: v
139
+ });
140
+ }, T = bt(h === "front" ? "front" : "behind");
141
+ t.save(), t.filter = d, T.forEach((D) => {
142
+ switch (D) {
143
+ case "stroke-behind":
144
+ w();
145
+ break;
146
+ case "effect": {
147
+ switch (a) {
148
+ case "shadow": {
149
+ const { offsetX: p, offsetY: S } = I(e), M = e.blur ?? 0, Y = J(e), k = L(r, Y);
150
+ t.save(), t.shadowColor = k, t.shadowBlur = M, t.shadowOffsetX = p, t.shadowOffsetY = S, C(t, i, { fillStyle: f }), t.restore();
151
+ break;
152
+ }
153
+ case "lift": {
154
+ const p = st(e), S = `rgba(0,0,0, ${0.5 * p})`;
155
+ t.save(), t.shadowColor = S, t.shadowBlur = 20 * p, t.shadowOffsetX = 0, t.shadowOffsetY = 10 * p, C(t, i, { fillStyle: f }), t.restore();
156
+ break;
157
+ }
158
+ case "neon": {
159
+ const p = G(e), S = e.textColor || "#ffffff";
160
+ t.save(), [p * 5, p * 3, p].forEach((M) => {
161
+ t.shadowColor = r, t.shadowBlur = M, t.shadowOffsetX = 0, t.shadowOffsetY = 0, C(t, i, { fillStyle: S });
162
+ }), C(t, i, { fillStyle: S }), t.restore();
163
+ break;
164
+ }
165
+ case "outline": {
166
+ const p = ot(e);
167
+ C(t, i, {
168
+ strokeStyle: r,
169
+ strokeWidth: p,
170
+ lineJoin: "round",
171
+ lineCap: "round",
172
+ fillStyle: f
173
+ });
174
+ break;
175
+ }
176
+ case "hollow": {
177
+ const p = tt(e);
178
+ C(t, i, {
179
+ strokeStyle: r,
180
+ strokeWidth: p,
181
+ lineJoin: "round",
182
+ lineCap: "round"
183
+ });
184
+ break;
185
+ }
186
+ case "splice": {
187
+ const p = x(e), { offsetX: S, offsetY: M } = I(e);
188
+ t.save(), t.shadowColor = "rgba(0,0,0,0.2)", t.shadowBlur = 0, t.shadowOffsetX = S, t.shadowOffsetY = M, C(t, i, {
189
+ strokeStyle: r,
190
+ strokeWidth: p,
191
+ lineJoin: "round",
192
+ lineCap: "round"
193
+ }), t.restore(), C(t, i, {
194
+ strokeStyle: r,
195
+ strokeWidth: p,
196
+ lineJoin: "round",
197
+ lineCap: "round"
198
+ });
199
+ break;
200
+ }
201
+ case "echo": {
202
+ const { offsetX: p, offsetY: S } = I(e);
203
+ C(t, i, { fillStyle: L(r, 0.5), offsetX: p, offsetY: S }), C(t, i, {
204
+ fillStyle: L(r, 0.3),
205
+ offsetX: p * 2,
206
+ offsetY: S * 2
207
+ }), C(t, i, { fillStyle: f });
208
+ break;
209
+ }
210
+ case "glitch": {
211
+ const p = m(e);
212
+ C(t, i, { fillStyle: "#0ea5e9", offsetX: -p, offsetY: 0 }), C(t, i, { fillStyle: "#f43f5e", offsetX: p, offsetY: 0 }), C(t, i, { fillStyle: f });
213
+ break;
214
+ }
215
+ case "blur": {
216
+ C(t, i, { fillStyle: f });
217
+ break;
218
+ }
219
+ case "duotone": {
220
+ const p = e.duotoneLight || "#f472b6", S = e.duotoneDark || "#1e40af";
221
+ C(t, i, { fillStyle: p, offsetX: 1, offsetY: 1 }), C(t, i, { fillStyle: p, offsetX: -1, offsetY: -1 }), C(t, i, { fillStyle: S });
222
+ break;
223
+ }
224
+ case "reflection": {
225
+ const p = (e.reflectionOpacity ?? 50) / 100, S = e.reflectionDistance ?? 5, M = `rgba(0,0,0, ${p * 0.3})`;
226
+ t.save(), t.shadowColor = M, t.shadowBlur = S, t.shadowOffsetX = 0, t.shadowOffsetY = S + 10, C(t, i, { fillStyle: f }), t.restore();
227
+ break;
228
+ }
229
+ case "background": {
230
+ const p = J(e), S = (e.spread ?? 50) / 5, M = (e.roundness ?? 0) / 2;
231
+ Mt(t, i, {
232
+ fillStyle: L(r, p),
233
+ spread: S,
234
+ roundness: M
235
+ });
236
+ break;
237
+ }
238
+ case "gradient_overlay": {
239
+ const p = e.gradientColor1 || "#667eea", S = e.gradientColor2 || "#764ba2", M = e.gradientAngle || 135, Y = vt(t, s, n, M, p, S);
240
+ C(t, i, { fillStyle: Y });
241
+ break;
242
+ }
243
+ default:
244
+ C(t, i, { fillStyle: f });
245
+ }
246
+ break;
247
+ }
248
+ case "fill":
249
+ a === "background" && C(t, i, { fillStyle: f });
250
+ break;
251
+ case "stroke-front":
252
+ w();
253
+ break;
254
+ }
255
+ }), t.restore();
256
+ }, A = {
257
+ triangle: "50,0 100,100 0,100",
258
+ star: "50,0 61,35 98,35 68,57 79,91 50,70 21,91 32,57 2,35 39,35",
259
+ hexagon: "25,0 75,0 100,50 75,100 25,100 0,50",
260
+ pentagon: "50,0 95,35 77,90 23,90 5,35",
261
+ diamond: "50,0 100,50 50,100 0,50",
262
+ arrow: "0,35 60,35 60,15 100,50 60,85 60,65 0,65",
263
+ heart: "50,20 55,15 65,10 80,10 95,25 95,45 50,90 5,45 5,25 20,10 35,10 45,15"
264
+ }, $ = (t, o, s) => {
265
+ const n = document.createElement("canvas");
266
+ n.width = Math.max(1, Math.ceil(t * s)), n.height = Math.max(1, Math.ceil(o * s));
267
+ const a = n.getContext("2d");
268
+ if (!a)
269
+ throw new Error("Failed to get canvas context");
270
+ return a.setTransform(1, 0, 0, 1, 0, 0), a.scale(s, s), { canvas: n, ctx: a };
271
+ }, X = (t, o) => ({ path: t, transform: o }), j = (t, o, s) => {
272
+ o.transform ? (t.save(), t.transform(o.transform.a, o.transform.b, o.transform.c, o.transform.d, o.transform.e, o.transform.f), s(o.path), t.restore()) : s(o.path);
273
+ }, N = (t, o) => {
274
+ if (o.transform && typeof t.getTransform == "function") {
275
+ const s = t.getTransform();
276
+ t.transform(o.transform.a, o.transform.b, o.transform.c, o.transform.d, o.transform.e, o.transform.f), t.clip(o.path), t.setTransform(s);
277
+ return;
278
+ }
279
+ t.clip(o.path);
280
+ }, _ = (t) => {
281
+ if (!t)
282
+ return { x: 0, y: 0, width: 0, height: 0 };
283
+ const o = t.split(/[\s,]+/).map((s) => Number.parseFloat(s)).filter((s) => !Number.isNaN(s));
284
+ return o.length >= 4 ? { x: o[0], y: o[1], width: o[2], height: o[3] } : { x: 0, y: 0, width: 0, height: 0 };
285
+ }, Tt = (t) => {
286
+ try {
287
+ let o = "linear", s = 90, n = "";
288
+ if (t.includes("radial-gradient")) {
289
+ o = "radial";
290
+ const e = t.match(/radial-gradient\((.*)\)/);
291
+ if (!e) return null;
292
+ const f = e[1].split(/,(?![^()]*\))/).map((r) => r.trim());
293
+ f[0].includes("circle") || f[0].includes("ellipse") || f[0].includes("at ") ? n = f.slice(1).join(",") : n = f.join(",");
294
+ } else {
295
+ const e = t.match(/linear-gradient\((.*)\)/);
296
+ if (!e) return null;
297
+ const f = e[1].split(/,(?![^()]*\))/).map((r) => r.trim());
298
+ f[0].includes("deg") ? (s = parseInt(f[0], 10), n = f.slice(1).join(",")) : f[0].includes("to ") ? (f[0] === "to right" ? s = 90 : f[0] === "to bottom" ? s = 180 : f[0] === "to left" ? s = 270 : f[0] === "to top" ? s = 0 : s = 180, n = f.slice(1).join(",")) : (s = 180, n = f.join(","));
299
+ }
300
+ const a = n.split(/,(?![^()]*\))/).map((e) => e.trim()).map((e) => {
301
+ const i = e.match(/(.+)\s+(\d+)%$/);
302
+ return i ? { color: i[1], offset: i[2] + "%" } : { color: e, offset: "" };
303
+ }).filter((e) => e.color);
304
+ return a.length === 2 && (a[0].offset || (a[0].offset = "0%"), a[1].offset || (a[1].offset = "100%")), { type: o, angle: s, stops: a };
305
+ } catch {
306
+ return null;
307
+ }
308
+ }, at = (t, o, s, n) => {
309
+ const a = (n - 90) * Math.PI / 180, e = Math.cos(a), i = Math.sin(a), f = o / 2 - e * (o / 2), r = s / 2 - i * (s / 2), l = o / 2 + e * (o / 2), c = s / 2 + i * (s / 2);
310
+ return t.createLinearGradient(f, r, l, c);
311
+ }, Pt = (t, o, s) => {
312
+ const n = Math.min(o, s) / 2;
313
+ if (typeof t == "number") {
314
+ const l = Math.max(0, Math.min(t, n));
315
+ return { tl: l, tr: l, br: l, bl: l };
316
+ }
317
+ const a = t, e = Math.max(0, Math.min((a == null ? void 0 : a.tl) ?? 0, n)), i = Math.max(0, Math.min((a == null ? void 0 : a.tr) ?? 0, n)), f = Math.max(0, Math.min((a == null ? void 0 : a.br) ?? 0, n)), r = Math.max(0, Math.min((a == null ? void 0 : a.bl) ?? 0, n));
318
+ return { tl: e, tr: i, br: f, bl: r };
319
+ }, z = (t, o, s, n, a, e) => {
320
+ const { tl: i, tr: f, br: r, bl: l } = Pt(e, n, a);
321
+ if (i === 0 && f === 0 && r === 0 && l === 0) {
322
+ t.rect(o, s, n, a);
323
+ return;
324
+ }
325
+ t.moveTo(o + i, s), t.lineTo(o + n - f, s), t.arcTo(o + n, s, o + n, s + f, f), t.lineTo(o + n, s + a - r), t.arcTo(o + n, s + a, o + n - r, s + a, r), t.lineTo(o + l, s + a), t.arcTo(o, s + a, o, s + a - l, l), t.lineTo(o, s + i), t.arcTo(o, s, o + i, s, i), t.closePath();
326
+ }, it = (t, o, s, n) => {
327
+ const a = t.split(" ").map((r) => {
328
+ const [l, c] = r.split(",").map(Number);
329
+ return { x: l / 100 * s, y: c / 100 * n };
330
+ }), e = typeof o == "number";
331
+ if (e && o <= 0)
332
+ return `M ${a.map((r) => `${r.x},${r.y}`).join(" L ")} Z`;
333
+ const i = a.length;
334
+ let f = "";
335
+ for (let r = 0; r < i; r++) {
336
+ const l = a[(r - 1 + i) % i], c = a[r], d = a[(r + 1) % i], y = { x: l.x - c.x, y: l.y - c.y }, u = { x: d.x - c.x, y: d.y - c.y }, h = Math.sqrt(y.x * y.x + y.y * y.y), g = Math.sqrt(u.x * u.x + u.y * u.y), b = Math.min(h, g) / 2;
337
+ let v = 0;
338
+ e ? v = o : v = o[`p${r}`] ?? 0;
339
+ const w = Math.min(v, b);
340
+ if (w <= 0) {
341
+ r === 0 ? f += `M ${c.x},${c.y} ` : f += `L ${c.x},${c.y} `;
342
+ continue;
343
+ }
344
+ const T = { x: c.x + y.x / h * w, y: c.y + y.y / h * w }, W = { x: c.x + u.x / g * w, y: c.y + u.y / g * w };
345
+ r === 0 ? f += `M ${T.x},${T.y} ` : f += `L ${T.x},${T.y} `, f += `Q ${c.x},${c.y} ${W.x},${W.y} `;
346
+ }
347
+ return f += "Z", f;
348
+ }, Ot = (t) => {
349
+ const o = t.clip;
350
+ if (!o) return null;
351
+ const s = Math.max(0, o.left ?? 0), n = Math.max(0, o.top ?? 0), a = Math.max(0, o.right ?? 0), e = Math.max(0, o.bottom ?? 0);
352
+ if (!(n > 0 || a > 0 || e > 0 || s > 0)) return null;
353
+ const f = t.width - s - a, r = t.height - n - e;
354
+ return f <= 0 || r <= 0 ? null : {
355
+ left: s,
356
+ top: n,
357
+ width: f,
358
+ height: r,
359
+ originX: s + f / 2,
360
+ originY: n + r / 2
361
+ };
362
+ }, Wt = (t) => {
363
+ var a, e, i, f;
364
+ const o = (e = (a = t.effect) == null ? void 0 : a.style) == null ? void 0 : e.type, s = ((f = (i = t.effect) == null ? void 0 : i.style) == null ? void 0 : f.params) || {};
365
+ if (!o || o === "none") return 0;
366
+ const n = (r, l) => r ?? l;
367
+ switch (o) {
368
+ case "shadow": {
369
+ const r = n(s.blur, 10), l = n(s.offset, 50) / 5;
370
+ return r + l + 10;
371
+ }
372
+ case "lift": {
373
+ const r = n(s.intensity, 50) / 50, l = 20 * r, c = 10 * r;
374
+ return l + c + 10;
375
+ }
376
+ case "neon":
377
+ return G(s) * 5 + 6;
378
+ case "outline":
379
+ return ot(s) * 2 + 2;
380
+ case "hollow":
381
+ return tt(s) * 2 + 2;
382
+ case "splice": {
383
+ const r = x(s), { offsetX: l, offsetY: c } = I(s);
384
+ return Math.max(Math.abs(l), Math.abs(c)) + r * 2 + 4;
385
+ }
386
+ case "echo": {
387
+ const { offsetX: r, offsetY: l } = I(s);
388
+ return Math.max(Math.abs(r), Math.abs(l)) * 2 + 4;
389
+ }
390
+ case "glitch":
391
+ return Math.abs(m(s)) + 4;
392
+ case "blur":
393
+ return n(s.blurAmount, 5) * 2 + 4;
394
+ case "duotone":
395
+ case "gradient_overlay":
396
+ case "background":
397
+ return 2;
398
+ case "reflection": {
399
+ const r = n(s.reflectionDistance, 5), l = r, c = r + 10;
400
+ return Math.abs(c) + l + 6;
401
+ }
402
+ default:
403
+ return 0;
404
+ }
405
+ }, lt = (t) => {
406
+ const o = [], s = /d=\"([^\"]+)\"/g;
407
+ let n = null;
408
+ for (; (n = s.exec(t)) !== null; )
409
+ o.push(n[1]);
410
+ return o;
411
+ }, Dt = (t, o, s) => {
412
+ if (t.type === "shape") {
413
+ const n = t.content, a = rt(n);
414
+ if (a && typeof DOMMatrix < "u") {
415
+ const e = lt(a.markup);
416
+ if (e.length > 0) {
417
+ const { x: i, y: f, width: r, height: l } = _(a.viewBox), c = r > 0 ? o / r : 1, d = l > 0 ? s / l : 1, y = new DOMMatrix().translate(-i, -f).scale(c, d), u = new Path2D(e.join(" "));
418
+ return X(u, y);
419
+ }
420
+ }
421
+ if (n === "rect") {
422
+ const e = new Path2D(), i = t.cornerRadius || 0;
423
+ return z(e, 0, 0, o, s, i), X(e);
424
+ }
425
+ if (n === "circle") {
426
+ const e = new Path2D();
427
+ return e.ellipse(o / 2, s / 2, o / 2, s / 2, 0, 0, Math.PI * 2), X(e);
428
+ }
429
+ if (n === "line") {
430
+ const e = new Path2D();
431
+ return e.moveTo(0, s / 2), e.lineTo(o, s / 2), X(e);
432
+ }
433
+ if (A[n]) {
434
+ const e = t.cornerRadius || 0, i = it(A[n], e, o, s);
435
+ return X(new Path2D(i));
436
+ }
437
+ }
438
+ return null;
439
+ }, F = (t, o, s) => {
440
+ if (t.type === "image" && t.clipShape) {
441
+ const n = rt(t.clipShape);
442
+ if (n) {
443
+ const a = lt(n.markup);
444
+ if (a.length > 0 && typeof DOMMatrix < "u") {
445
+ const { x: e, y: i, width: f, height: r } = _(n.viewBox), l = f > 0 ? o / f : 1, c = r > 0 ? s / r : 1, d = new DOMMatrix().translate(-e, -i).scale(l, c), y = new Path2D(a.join(" "));
446
+ return X(y, d);
447
+ }
448
+ }
449
+ if (t.clipShape === "circle") {
450
+ const a = new Path2D();
451
+ return a.ellipse(o / 2, s / 2, o / 2, s / 2, 0, 0, Math.PI * 2), X(a);
452
+ }
453
+ if (t.clipShape === "path" && t.path) {
454
+ const a = et(t.path);
455
+ return X(new Path2D(a));
456
+ }
457
+ if (A[t.clipShape]) {
458
+ const a = t.cornerRadius || 0, e = it(A[t.clipShape], a, o, s);
459
+ return X(new Path2D(e));
460
+ }
461
+ }
462
+ return null;
463
+ }, Yt = (t, o, s, n) => {
464
+ const a = o.backgroundColor || "transparent", e = a.includes("gradient") ? Tt(a) : null;
465
+ if (e)
466
+ if (e.type === "radial") {
467
+ const l = t.createRadialGradient(s / 2, n / 2, 0, s / 2, n / 2, Math.max(s, n) / 2);
468
+ e.stops.forEach((c, d) => {
469
+ const y = e.stops.length > 1 ? d / (e.stops.length - 1) : 0, u = c.offset ? Number.parseFloat(c.offset) / 100 : y;
470
+ l.addColorStop(Number.isFinite(u) ? u : y, c.color);
471
+ }), t.fillStyle = l;
472
+ } else {
473
+ const l = at(t, s, n, e.angle);
474
+ e.stops.forEach((c, d) => {
475
+ const y = e.stops.length > 1 ? d / (e.stops.length - 1) : 0, u = c.offset ? Number.parseFloat(c.offset) / 100 : y;
476
+ l.addColorStop(Number.isFinite(u) ? u : y, c.color);
477
+ }), t.fillStyle = l;
478
+ }
479
+ else
480
+ t.fillStyle = a;
481
+ const i = Dt(o, s, n);
482
+ i ? j(t, i, (l) => t.fill(l)) : t.fillRect(0, 0, s, n);
483
+ const f = o.content === "line" ? Math.max(2, o.strokeWidth || 4) : o.strokeWidth || 0, r = o.strokeColor || "transparent";
484
+ f > 0 && r !== "transparent" && (t.save(), t.strokeStyle = r, t.lineWidth = f, t.lineJoin = "round", t.lineCap = o.strokeStyle === "round" ? "round" : "butt", o.strokeStyle === "dashed" ? t.setLineDash([6, 4]) : o.strokeStyle === "dotted" ? t.setLineDash([2, 2]) : t.setLineDash([]), i ? j(t, i, (l) => t.stroke(l)) : t.strokeRect(0, 0, s, n), t.restore());
485
+ }, Xt = (t, o, s) => {
486
+ if (o === "none") return t;
487
+ const n = t.width / s, a = t.height / s, { canvas: e, ctx: i } = $(n, a, s);
488
+ return i.filter = o, i.drawImage(t, 0, 0, n, a), e;
489
+ }, Rt = (t) => new Promise((o, s) => {
490
+ const n = new Image(), a = nt(t);
491
+ n.decoding = "async", a.crossOrigin && (n.crossOrigin = a.crossOrigin), n.onload = () => o(n), n.onerror = (e) => s(e), n.src = a.src;
492
+ }), It = async (t, o, s, n, a) => {
493
+ if (o.isIcon && o.iconPaths && o.iconPaths.length > 0) {
494
+ const { x: D, y: p, width: S, height: M } = _(
495
+ o.iconViewBox || `0 0 ${s} ${n}`
496
+ ), Y = S > 0 ? s / S : 1, k = M > 0 ? n / M : 1;
497
+ t.save(), t.fillStyle = o.color || "#000000", t.translate(-D * Y, -p * k), t.scale(Y, k), o.iconPaths.forEach((O) => {
498
+ const P = new Path2D(O);
499
+ t.fill(P);
500
+ }), t.restore();
501
+ return;
502
+ }
503
+ const e = o.content;
504
+ if (!e) return;
505
+ const f = nt(e).src;
506
+ let r = a.get(f);
507
+ r || (r = await Rt(f), a.set(f, r));
508
+ const l = r.naturalWidth || r.width || s, c = r.naturalHeight || r.height || n, d = pt(o.crop, s, n, l, c), y = d.width * l, u = d.height * c, h = s / y, g = n / u, b = l * h, v = c * g, w = -(d.x * l) * h, T = -(d.y * c) * g, W = (o.imageRotation ?? 0) * (Math.PI / 180);
509
+ if (o.backgroundColor && o.backgroundColor !== "transparent" && (t.save(), t.fillStyle = o.backgroundColor, t.fillRect(0, 0, s, n), t.restore()), t.save(), W) {
510
+ const D = w + b / 2, p = T + v / 2;
511
+ t.translate(D, p), t.rotate(W), t.translate(-D, -p);
512
+ }
513
+ t.drawImage(r, w, T, b, v), t.restore();
514
+ }, Lt = (t, o) => {
515
+ if (!o.path) return;
516
+ const s = et(o.path);
517
+ if (!s) return;
518
+ const n = new Path2D(s), a = o.backgroundColor ?? o.path.fillColor ?? "transparent", e = o.strokeColor ?? o.path.strokeColor ?? "transparent", i = o.strokeWidth ?? o.path.strokeWidth ?? 0;
519
+ a && a !== "transparent" && (t.save(), t.fillStyle = a, t.fill(n), t.restore()), i > 0 && e && e !== "transparent" && (t.save(), t.strokeStyle = e, t.lineWidth = i, t.lineCap = o.path.lineCap, t.lineJoin = o.path.lineJoin, o.strokeStyle === "dashed" ? t.setLineDash([6, 4]) : o.strokeStyle === "dotted" ? t.setLineDash([2, 2]) : t.setLineDash([]), t.stroke(n), t.restore());
520
+ }, $t = async (t, o, s) => {
521
+ var D, p, S, M, Y;
522
+ const n = Wt(t), a = typeof n == "number" ? n : 0, e = t.width + a * 2, i = t.height + a * 2, { canvas: f, ctx: r } = $(e, i, o);
523
+ r.save(), r.translate(a, a);
524
+ const l = Ot(t), c = ((p = (D = t.effect) == null ? void 0 : D.style) == null ? void 0 : p.type) ?? "none", d = ((M = (S = t.effect) == null ? void 0 : S.style) == null ? void 0 : M.params) ?? {}, y = K((Y = t.effect) == null ? void 0 : Y.adjustments), { canvas: u, ctx: h } = $(t.width, t.height, o);
525
+ if (t.type === "text")
526
+ l ? (h.save(), h.beginPath(), h.rect(l.left, l.top, l.width, l.height), h.clip(), V(h, t, t.width, t.height, c, d), h.restore()) : V(h, t, t.width, t.height, c, d);
527
+ else {
528
+ if (h.save(), l)
529
+ h.beginPath(), h.rect(l.left, l.top, l.width, l.height), h.clip();
530
+ else {
531
+ const k = F(t, t.width, t.height);
532
+ k ? N(h, k) : t.type === "image" && t.cornerRadius && (h.beginPath(), z(h, 0, 0, t.width, t.height, t.cornerRadius), h.clip());
533
+ }
534
+ if (t.type === "shape" ? Yt(h, t, t.width, t.height) : t.type === "image" ? await It(h, t, t.width, t.height, s) : t.type === "path" ? Lt(h, t) : (h.fillStyle = t.backgroundColor || "transparent", h.fillRect(0, 0, t.width, t.height)), h.restore(), t.type === "image" && (t.strokeWidth || 0) > 0) {
535
+ const k = F(t, t.width, t.height);
536
+ h.save(), h.strokeStyle = t.strokeColor || "#000000", h.lineWidth = t.strokeWidth || 0, h.lineJoin = "round", h.lineCap = t.strokeStyle === "round" ? "round" : "butt", t.strokeStyle === "dashed" ? h.setLineDash([6, 4]) : t.strokeStyle === "dotted" ? h.setLineDash([2, 2]) : h.setLineDash([]), k ? j(h, k, (O) => h.stroke(O)) : t.cornerRadius ? (h.beginPath(), z(h, 0, 0, t.width, t.height, t.cornerRadius), h.stroke()) : h.strokeRect(0, 0, t.width, t.height), h.restore();
537
+ }
538
+ }
539
+ const g = t.type === "text", b = [];
540
+ if (!g) {
541
+ if (y && b.push(y), c === "blur") {
542
+ const k = d.blurAmount ?? 5;
543
+ b.push(`blur(${k}px)`);
544
+ }
545
+ c === "duotone" && b.push("grayscale(100%)");
546
+ }
547
+ const v = b.join(" ").trim() || "none", w = !g && c === "blur", T = g || w ? u : Xt(u, v, o);
548
+ if (!g && (c === "shadow" || c === "lift" || c === "neon")) {
549
+ if (r.save(), r.filter = "none", c === "shadow") {
550
+ const { offsetX: k, offsetY: O } = I(d), P = d.blur ?? 0, E = J(d);
551
+ r.shadowColor = L(Q(d, "#000000"), E), r.shadowBlur = P, r.shadowOffsetX = k, r.shadowOffsetY = O, r.drawImage(T, 0, 0, t.width, t.height);
552
+ } else if (c === "lift") {
553
+ const k = st(d);
554
+ r.shadowColor = `rgba(0,0,0, ${0.5 * k})`, r.shadowBlur = 20 * k, r.shadowOffsetX = 0, r.shadowOffsetY = 10 * k, r.drawImage(T, 0, 0, t.width, t.height);
555
+ } else if (c === "neon") {
556
+ const k = G(d), O = d.color || "#00ff00";
557
+ [k * 5, k * 3, k].forEach((P) => {
558
+ r.shadowColor = O, r.shadowBlur = P, r.shadowOffsetX = 0, r.shadowOffsetY = 0, r.drawImage(T, 0, 0, t.width, t.height);
559
+ });
560
+ }
561
+ r.restore();
562
+ }
563
+ if (!g && c === "reflection") {
564
+ const k = (d.reflectionOpacity ?? 50) / 100, O = d.reflectionDistance ?? 5, P = 0.35;
565
+ r.save(), r.drawImage(T, 0, 0, t.width, t.height), r.translate(0, t.height + O), r.scale(1, -1), r.globalAlpha = k, r.drawImage(
566
+ T,
567
+ 0,
568
+ t.height - t.height * P,
569
+ t.width,
570
+ t.height * P,
571
+ 0,
572
+ 0,
573
+ t.width,
574
+ t.height * P
575
+ ), r.restore();
576
+ } else
577
+ w ? (r.save(), r.filter = v, r.drawImage(u, 0, 0, t.width, t.height), r.restore()) : r.drawImage(T, 0, 0, t.width, t.height);
578
+ if (!g && c === "gradient_overlay") {
579
+ const k = d.gradientColor1 || "#667eea", O = d.gradientColor2 || "#764ba2", P = d.gradientAngle || 135, E = (d.transparency ?? 80) / 100;
580
+ r.save(), r.globalAlpha = E, r.filter = y || "none", r.globalCompositeOperation = "overlay";
581
+ const H = at(r, t.width, t.height, P);
582
+ H.addColorStop(0, k), H.addColorStop(1, O), r.fillStyle = H;
583
+ const q = F(t, t.width, t.height);
584
+ q ? (r.save(), N(r, q), r.fillRect(0, 0, t.width, t.height), r.restore()) : r.fillRect(0, 0, t.width, t.height), r.restore();
585
+ }
586
+ if (!g && c === "duotone") {
587
+ const k = d.duotoneLight || "#f472b6", O = d.duotoneDark || "#1e40af", P = F(t, t.width, t.height);
588
+ r.save(), r.filter = y || "none", P && N(r, P), r.globalCompositeOperation = "multiply", r.fillStyle = O, r.fillRect(0, 0, t.width, t.height), r.globalCompositeOperation = "screen", r.globalAlpha = 0.6, r.fillStyle = k, r.fillRect(0, 0, t.width, t.height), r.restore();
589
+ }
590
+ r.restore();
591
+ const W = l ? { x: l.originX, y: l.originY } : { x: t.width / 2, y: t.height / 2 };
592
+ return {
593
+ canvas: f,
594
+ padding: a,
595
+ origin: W,
596
+ width: e,
597
+ height: i
598
+ };
599
+ }, Z = async (t, o) => {
600
+ const { page: s, settings: n, bleed: a, backgroundColor: e, pixelRatio: i } = o, f = o.width, r = o.height, l = a, c = a;
601
+ e !== "transparent" && (t.save(), t.fillStyle = e || n.backgroundColor || "#ffffff", t.fillRect(0, 0, f, r), t.restore());
602
+ const d = [...s.elements].filter((u) => u.visible !== !1).sort((u, h) => u.zIndex - h.zIndex), y = /* @__PURE__ */ new Map();
603
+ for (const u of d) {
604
+ const { canvas: h, padding: g, origin: b, width: v, height: w } = await $t(
605
+ u,
606
+ i,
607
+ y
608
+ );
609
+ t.save(), t.globalCompositeOperation = wt(u.blendMode), t.globalAlpha = u.opacity ?? 1, t.translate(l + u.x, c + u.y), t.translate(b.x, b.y), t.rotate((u.rotation ?? 0) * Math.PI / 180), t.scale(u.flipX ? -1 : 1, u.flipY ? -1 : 1), t.translate(-b.x, -b.y), t.drawImage(h, -g, -g, v, w), t.restore();
610
+ }
611
+ }, At = async (t) => {
612
+ await ht(document);
613
+ const o = t.width, s = t.height;
614
+ if (!dt(
615
+ o,
616
+ s,
617
+ t.pixelRatio,
618
+ 8192,
619
+ 67108864
620
+ )) {
621
+ const { canvas: i, ctx: f } = $(o, s, t.pixelRatio);
622
+ return await Z(f, t), i;
623
+ }
624
+ const a = ut(o, s, {
625
+ tileWidth: B.tileSize,
626
+ tileHeight: B.tileSize,
627
+ overlap: B.tileOverlap
628
+ }), e = [];
629
+ for (const i of a.tiles) {
630
+ const { canvas: f, ctx: r } = $(i.width, i.height, t.pixelRatio);
631
+ r.translate(-i.x, -i.y), await Z(r, t), e.push({ rect: i, canvas: f });
632
+ }
633
+ return gt(e, o, s, t.pixelRatio);
634
+ };
635
+ export {
636
+ At as capturePageCanvas
637
+ };
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import "react-dom/client";
3
- import { S as o, y as p, x as c, z as i } from "./index-Cu0YlsyW.js";
3
+ import { S as o, y as p, x as c, z as i } from "./index-C2qSvudu.js";
4
4
  export {
5
5
  o as Store,
6
6
  p as createFraczledEditor,