ablok-photobooth 0.2.39 → 0.2.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/ablok-photobooth.js +12 -0
  2. package/dist/chunks/color-booth.vue_vue_type_style_index_0_lang-Cxo8ZMRt.js +98 -0
  3. package/dist/chunks/creative-booth.vue_vue_type_style_index_0_lang-BHKoShl5.js +248 -0
  4. package/dist/chunks/fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js +318 -0
  5. package/dist/chunks/face-swap.vue_vue_type_style_index_0_lang-B0EJ4Q3T.js +229 -0
  6. package/dist/chunks/media-api-DcCOqndv.js +164 -0
  7. package/dist/chunks/photo-app.vue_vue_type_style_index_0_lang-CQsO0T0U.js +569 -0
  8. package/dist/color-booth.js +4 -0
  9. package/dist/creative-booth.js +6 -0
  10. package/dist/fabric-canvas.js +4 -0
  11. package/dist/face-swap.js +6 -0
  12. package/dist/photo-app.js +4 -0
  13. package/dist/{components → types/components}/creative-booth.vue.d.ts +39 -89
  14. package/dist/{components → types/components}/photo-app.vue.d.ts +2 -2
  15. package/package.json +49 -10
  16. package/dist/App.vue.d.ts +0 -2
  17. package/dist/ablok-photobooth.es.js +0 -1545
  18. package/dist/ablok-photobooth.umd.js +0 -1
  19. package/dist/histoire.setup.d.ts +0 -1
  20. package/dist/i18n.d.ts +0 -77
  21. package/dist/main.d.ts +0 -0
  22. /package/dist/{api → types/api}/media-api.d.ts +0 -0
  23. /package/dist/{components → types/components}/color-booth.vue.d.ts +0 -0
  24. /package/dist/{components → types/components}/fabric-canvas.vue.d.ts +0 -0
  25. /package/dist/{components → types/components}/face-swap.vue.d.ts +0 -0
  26. /package/dist/{components → types/components}/svg-canvas.vue.d.ts +0 -0
  27. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  28. /package/dist/{locales → types/locales}/en.d.ts +0 -0
  29. /package/dist/{utilities → types/utilities}/idb-keyval.d.ts +0 -0
  30. /package/dist/{utilities → types/utilities}/indexed-db-api.d.ts +0 -0
  31. /package/dist/{utilities → types/utilities}/media-helpers.d.ts +0 -0
@@ -0,0 +1,12 @@
1
+ import { _ as a } from "./chunks/photo-app.vue_vue_type_style_index_0_lang-CQsO0T0U.js";
2
+ import { _ as e } from "./chunks/fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js";
3
+ import { _ as s } from "./chunks/creative-booth.vue_vue_type_style_index_0_lang-BHKoShl5.js";
4
+ import { _ as m } from "./chunks/face-swap.vue_vue_type_style_index_0_lang-B0EJ4Q3T.js";
5
+ import { _ } from "./chunks/color-booth.vue_vue_type_style_index_0_lang-Cxo8ZMRt.js";
6
+ export {
7
+ _ as ColorBooth,
8
+ s as CreativeBooth,
9
+ e as FabricCanvas,
10
+ m as FaceSwap,
11
+ a as PhotoApp
12
+ };
@@ -0,0 +1,98 @@
1
+ import { defineComponent as g, ref as d, openBlock as p, createElementBlock as v, normalizeClass as S, createElementVNode as V, normalizeStyle as w, computed as A, onBeforeMount as b, createVNode as c, withCtx as x } from "vue";
2
+ import B from "ablok-components/components/molecules/color-palette/color-palette.vue";
3
+ import E from "ablok-components/components/templates/touch-wrapper/touch-wrapper.vue";
4
+ const F = ["innerHTML"], _ = /* @__PURE__ */ g({
5
+ __name: "svg-canvas",
6
+ props: {
7
+ modelValue: {
8
+ default: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>',
9
+ type: String
10
+ },
11
+ scale: {
12
+ type: Number,
13
+ default: 1
14
+ },
15
+ fillColor: String,
16
+ groupedFill: Boolean
17
+ },
18
+ emits: ["update:modelValue"],
19
+ setup(t, { emit: u }) {
20
+ const l = t, i = u, s = d();
21
+ function a(n) {
22
+ const e = n.target;
23
+ if (!e.closest(".read-only")) {
24
+ if (l.groupedFill && l.fillColor) {
25
+ const y = e.closest("[data-group-class]").dataset.groupClass, m = e.closest("svg")?.querySelectorAll(`.${y}`);
26
+ m && Array.from(m).forEach((f) => {
27
+ f.setAttribute("fill", l.fillColor), f.setAttribute("fill-opacity", "1");
28
+ });
29
+ } else l.fillColor && (e.setAttribute("fill", l.fillColor), e.setAttribute("fill-opacity", "1"));
30
+ const C = e.closest(".svg-canvas").querySelector("svg").outerHTML;
31
+ i("update:modelValue", C);
32
+ }
33
+ }
34
+ return (n, e) => (p(), v("div", {
35
+ class: S(["svg-canvas", `${t.scale > 1 ? "overflow-scroll" : ""}`])
36
+ }, [
37
+ V("div", {
38
+ ref_key: "svg",
39
+ ref: s,
40
+ class: "svg-wrapper",
41
+ innerHTML: t.modelValue,
42
+ style: w({ transform: `scale(${t.scale})` }),
43
+ onClick: e[0] || (e[0] = (o) => a(o))
44
+ }, null, 12, F)
45
+ ], 2));
46
+ }
47
+ }), $ = { class: "svg-editor" }, k = { class: "svg-editor__frame" }, H = /* @__PURE__ */ g({
48
+ __name: "color-booth",
49
+ props: {
50
+ modelValue: String,
51
+ name: String,
52
+ src: String,
53
+ required: Boolean,
54
+ colors: Array,
55
+ groupedFill: Boolean
56
+ },
57
+ emits: ["update:modelValue"],
58
+ setup(t, { emit: u }) {
59
+ const l = t, i = u, s = d(""), a = d(1), n = A({
60
+ get() {
61
+ return l.modelValue;
62
+ },
63
+ set(e) {
64
+ i("update:modelValue", e);
65
+ }
66
+ });
67
+ return b(() => {
68
+ s.value = l.colors?.length ? l.colors[0] : "";
69
+ }), (e, o) => (p(), v("div", $, [
70
+ V("div", k, [
71
+ c(E, {
72
+ modelValue: a.value,
73
+ "onUpdate:modelValue": o[1] || (o[1] = (r) => a.value = r)
74
+ }, {
75
+ default: x(() => [
76
+ c(_, {
77
+ modelValue: n.value,
78
+ "onUpdate:modelValue": o[0] || (o[0] = (r) => n.value = r),
79
+ fillColor: s.value,
80
+ scale: a.value,
81
+ "grouped-fill": t.groupedFill
82
+ }, null, 8, ["modelValue", "fillColor", "scale", "grouped-fill"])
83
+ ]),
84
+ _: 1
85
+ }, 8, ["modelValue"]),
86
+ c(B, {
87
+ modelValue: s.value,
88
+ "onUpdate:modelValue": o[2] || (o[2] = (r) => s.value = r),
89
+ colors: t.colors,
90
+ class: "mt-2"
91
+ }, null, 8, ["modelValue", "colors"])
92
+ ])
93
+ ]));
94
+ }
95
+ });
96
+ export {
97
+ H as _
98
+ };
@@ -0,0 +1,248 @@
1
+ import { defineComponent as x, ref as c, computed as l, watch as S, openBlock as u, createElementBlock as v, createElementVNode as h, createVNode as B, normalizeClass as M, createCommentVNode as b, createBlock as V } from "vue";
2
+ import w from "ablok-components/components/molecules/media-thumbnails/media-thumbnails.vue";
3
+ import { _ as A } from "./fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js";
4
+ const C = { class: "creative-booth" }, D = { class: "media-container" }, O = ["innerHTML"], E = { class: "creative-booth__thumbnails" }, F = [
5
+ {
6
+ type: "background",
7
+ thumbnail: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
8
+ src: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
9
+ mediaType: "image",
10
+ filters: ["asset-01", "asset-02"]
11
+ },
12
+ {
13
+ type: "background",
14
+ thumbnail: "/themes/corp/backgrounds/corp-background-09-white.jpg",
15
+ src: "/themes/corp/backgrounds/corp-background-09-white.jpg",
16
+ mediaType: "image",
17
+ filters: ["asset-01", "asset-02"]
18
+ },
19
+ {
20
+ type: "preset",
21
+ thumbnail: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
22
+ filters: ["asset-01"],
23
+ items: {
24
+ background: {
25
+ type: "background",
26
+ src: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
27
+ thumbnail: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
28
+ mediaType: "image"
29
+ },
30
+ overlay: {
31
+ type: "overlay",
32
+ src: "/themes/corp/overlays/corporate-your-overlay-1024x1024.png",
33
+ thumbnail: "/themes/corp/overlays/corporate-your-overlay-1024x1024.png",
34
+ mediaType: "image"
35
+ },
36
+ object: {
37
+ type: "object",
38
+ src: "/themes/corp/stickers/corporate-your-sticker-512x512.svg",
39
+ thumbnail: "/themes/corp/stickers/corporate-your-sticker-512x512.svg",
40
+ mediaType: "svg"
41
+ }
42
+ }
43
+ },
44
+ {
45
+ type: "overlay",
46
+ src: "/themes/corp/overlays/corporate-your-overlay-1024x1024.png",
47
+ mediaType: "image",
48
+ filters: ["asset-01"]
49
+ },
50
+ {
51
+ type: "overlay",
52
+ src: "/themes/corp/overlays/corp-overlay-02-white.png",
53
+ mediaType: "image",
54
+ filters: ["asset-01"]
55
+ },
56
+ {
57
+ type: "object",
58
+ src: "/themes/corp/stickers/corporate-your-sticker-512x512.svg",
59
+ mediaType: "svg",
60
+ filters: ["asset-02"]
61
+ },
62
+ {
63
+ type: "object",
64
+ src: "/themes/corp/stickers/corp-sticker-01.svg",
65
+ mediaType: "svg"
66
+ },
67
+ {
68
+ type: "object",
69
+ src: "/themes/corp/stickers/corp-sticker-02.svg",
70
+ mediaType: "svg",
71
+ filters: ["asset-01", "asset-02"]
72
+ }
73
+ ], I = /* @__PURE__ */ x({
74
+ __name: "creative-booth",
75
+ props: {
76
+ modelValue: {
77
+ default: null
78
+ },
79
+ jsonModel: {
80
+ type: null,
81
+ default: void 0
82
+ },
83
+ config: {
84
+ type: Object,
85
+ default: null
86
+ },
87
+ feature: {
88
+ type: String,
89
+ default: ""
90
+ },
91
+ required: {
92
+ type: Boolean,
93
+ default: !1
94
+ },
95
+ variant: {
96
+ type: String,
97
+ default: "light"
98
+ },
99
+ messages: {
100
+ type: Object,
101
+ default: {}
102
+ },
103
+ assets: {
104
+ type: Array,
105
+ default: () => F
106
+ },
107
+ assetFilters: {
108
+ type: Array,
109
+ default: () => []
110
+ },
111
+ exportToSvg: {
112
+ type: Boolean,
113
+ default: !1
114
+ },
115
+ resetState: {
116
+ type: Boolean,
117
+ default: !1
118
+ },
119
+ ratio: {
120
+ type: String,
121
+ default: "4x3"
122
+ },
123
+ themeData: {
124
+ type: Object,
125
+ default: () => ({})
126
+ },
127
+ autoSelect: Number,
128
+ ready: {
129
+ type: Boolean,
130
+ default: !1
131
+ },
132
+ pending: {
133
+ type: Boolean,
134
+ default: !1
135
+ },
136
+ emitPending: {
137
+ type: Boolean,
138
+ default: !1
139
+ },
140
+ animationDuration: {
141
+ type: Number,
142
+ default: 320
143
+ },
144
+ stackedThumbnails: {
145
+ type: Boolean,
146
+ default: !1
147
+ },
148
+ showThumbnailCount: {
149
+ type: Boolean,
150
+ default: !1
151
+ }
152
+ },
153
+ emits: ["update:modelValue", "update:jsonModel", "update:ready", "update:pending"],
154
+ setup(a, { emit: k }) {
155
+ const s = a, o = k, n = c(), j = c(), d = c(!1), i = l(
156
+ () => s.assetFilters && s.assetFilters.length > 0 ? s.assets.filter((e) => !e.filters || e.filters.length == 0 || s.assetFilters.some((t) => e.filters.includes(t))) : s.assets
157
+ ), p = l({
158
+ get() {
159
+ return s.modelValue;
160
+ },
161
+ set(e) {
162
+ o("update:modelValue", e);
163
+ }
164
+ }), m = l({
165
+ get() {
166
+ return s.jsonModel;
167
+ },
168
+ set(e) {
169
+ o("update:jsonModel", e);
170
+ }
171
+ }), y = l({
172
+ get() {
173
+ return s.pending;
174
+ },
175
+ set(e) {
176
+ s.ready && o("update:pending", e);
177
+ }
178
+ });
179
+ S(j, async (e, t) => {
180
+ e && e !== t && o("update:modelValue", e);
181
+ }, { deep: !0 });
182
+ function g(e) {
183
+ switch (e.type) {
184
+ case "background":
185
+ n.value?.setBackgroundImage(e);
186
+ break;
187
+ case "overlay":
188
+ n.value?.setOverlayImage(e);
189
+ break;
190
+ default:
191
+ n.value?.addCanvasObject(e);
192
+ }
193
+ }
194
+ function f(e) {
195
+ if (typeof e < "u") {
196
+ const t = i.value[e];
197
+ t.type === "preset" ? Object.values(t.items).forEach(g) : g(t);
198
+ }
199
+ }
200
+ const T = (async () => {
201
+ if (d.value = !0, s.autoSelect !== void 0) {
202
+ const e = s.autoSelect >= 0 ? s.autoSelect : Math.floor(Math.random() * i.value.length);
203
+ f(e);
204
+ }
205
+ o("update:ready", !0);
206
+ });
207
+ return (e, t) => (u(), v("div", C, [
208
+ h("div", D, [
209
+ B(A, {
210
+ modelValue: p.value,
211
+ "onUpdate:modelValue": t[0] || (t[0] = (r) => p.value = r),
212
+ "json-model": m.value,
213
+ "onUpdate:jsonModel": t[1] || (t[1] = (r) => m.value = r),
214
+ pending: y.value,
215
+ "onUpdate:pending": t[2] || (t[2] = (r) => y.value = r),
216
+ ref_key: "canvas",
217
+ ref: n,
218
+ "reset-state": a.resetState,
219
+ options: { themeData: a.themeData },
220
+ feature: a.feature,
221
+ required: a.required,
222
+ class: M(`${a.ratio ? `aspect-ratio aspect-ratio--${a.ratio}` : ""}`),
223
+ onOnReady: T,
224
+ "emit-pending": a.emitPending,
225
+ "animation-duration": a.animationDuration
226
+ }, null, 8, ["modelValue", "json-model", "pending", "reset-state", "options", "feature", "required", "class", "emit-pending", "animation-duration"])
227
+ ]),
228
+ a.messages.headline ? (u(), v("p", {
229
+ key: 0,
230
+ class: "headline",
231
+ innerHTML: a.messages.headline
232
+ }, null, 8, O)) : b("", !0),
233
+ h("div", E, [
234
+ d.value ? (u(), V(w, {
235
+ key: 0,
236
+ assets: i.value,
237
+ stacked: a.stackedThumbnails,
238
+ "show-count": a.showThumbnailCount,
239
+ onSelect: f
240
+ }, null, 8, ["assets", "stacked", "show-count"])) : b("", !0)
241
+ ])
242
+ ]));
243
+ }
244
+ });
245
+ export {
246
+ F as D,
247
+ I as _
248
+ };
@@ -0,0 +1,318 @@
1
+ import { defineComponent as Q, ref as j, watch as Z, onMounted as ee, openBlock as te, createElementBlock as ae, createElementVNode as B, renderSlot as oe } from "vue";
2
+ import { debounce as ne } from "lodash";
3
+ function C(s) {
4
+ return new Promise((c, l) => {
5
+ s.oncomplete = s.onsuccess = () => c(s.result), s.onabort = s.onerror = () => l(s.error);
6
+ });
7
+ }
8
+ function re(s, c) {
9
+ const l = indexedDB.open(s);
10
+ l.onupgradeneeded = () => l.result.createObjectStore(c);
11
+ const f = C(l);
12
+ return (p, y) => f.then(
13
+ (g) => y(g.transaction(c, p).objectStore(c))
14
+ );
15
+ }
16
+ let D;
17
+ function _() {
18
+ return D || (D = re("keyval-store", "keyval")), D;
19
+ }
20
+ function ie(s, c = _()) {
21
+ return c("readonly", (l) => C(l.get(s)));
22
+ }
23
+ function se(s, c, l = _()) {
24
+ return l("readwrite", (f) => (f.put(c, s), C(f.transaction)));
25
+ }
26
+ function le(s, c = _()) {
27
+ return c("readwrite", (l) => (l.delete(s), C(l.transaction)));
28
+ }
29
+ const ce = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23ffffffCC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='feather%20feather-rotate-cw'%3e%3cpolyline%20points='23%204%2023%2010%2017%2010'%3e%3c/polyline%3e%3cpath%20d='M20.49%2015a9%209%200%201%201-2.12-9.36L23%2010'%3e%3c/path%3e%3c/svg%3e", de = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23ffffffCC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='feather%20feather-x-circle'%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='none'%3e%3c/circle%3e%3cline%20x1='15'%20y1='9'%20x2='9'%20y2='15'%20fill='none'%3e%3c/line%3e%3cline%20x1='9'%20y1='9'%20x2='15'%20y2='15'%20fill='none'%3e%3c/line%3e%3c/svg%3e", ue = { class: "fabric-canvas__canvas" }, fe = {
30
+ id: "fabricCanvas",
31
+ ref: "canvasRef"
32
+ }, pe = /* @__PURE__ */ Q({
33
+ __name: "fabric-canvas",
34
+ props: {
35
+ modelValue: {
36
+ type: String,
37
+ default: ""
38
+ },
39
+ jsonModel: {
40
+ type: null,
41
+ default: void 0
42
+ },
43
+ exportToSvg: {
44
+ type: Boolean,
45
+ default: !1
46
+ },
47
+ resetState: {
48
+ type: Boolean,
49
+ default: !1
50
+ },
51
+ options: {
52
+ type: Object,
53
+ default: () => ({})
54
+ },
55
+ feature: {
56
+ type: String,
57
+ default: ""
58
+ },
59
+ required: {
60
+ type: Boolean,
61
+ default: !1
62
+ },
63
+ pending: {
64
+ type: Boolean,
65
+ default: !1
66
+ },
67
+ emitPending: {
68
+ type: Boolean,
69
+ default: !1
70
+ },
71
+ animationDuration: {
72
+ type: Number,
73
+ default: 0
74
+ }
75
+ },
76
+ emits: ["update:modelValue", "update:jsonModel", "update:pending", "on-ready"],
77
+ setup(s, { expose: c, emit: l }) {
78
+ let f, p, y, g, A, F, x, O;
79
+ const h = l;
80
+ c({ setBackgroundImage: M, setOverlayImage: Y, addCanvasObject: G });
81
+ const n = s, w = j(), d = j(0), u = j(0);
82
+ let a, R = !1;
83
+ const T = j();
84
+ async function H(e, t) {
85
+ return new Promise(async (o) => {
86
+ const r = JSON.parse(t);
87
+ if (r.backgroundImage) {
88
+ const i = await b(r.backgroundImage.src || r.backgroundImage.filename);
89
+ i.set({
90
+ opacity: 1
91
+ }), e.backgroundImage = i, e.centerObject(i);
92
+ }
93
+ if (r.overlayImage) {
94
+ const i = await b(r.overlayImage.src || r.overlayImage.filename);
95
+ i.set({
96
+ opacity: 1,
97
+ left: d.value / 2,
98
+ top: u.value / 2,
99
+ scaleX: d.value / i.width,
100
+ scaleY: u.value / i.height
101
+ }), e.overlayImage = i;
102
+ }
103
+ (await g.enlivenObjects(r.objects, {
104
+ reviver: void 0
105
+ })).forEach((i) => {
106
+ e.add(i);
107
+ }), o(e);
108
+ });
109
+ }
110
+ async function b(e) {
111
+ const t = await U(e);
112
+ e.includes("data:image") || (t.filename = e);
113
+ const o = g.findScaleToCover(t, a), r = t instanceof p;
114
+ return t.set({
115
+ left: 0,
116
+ top: 0,
117
+ opacity: r && n.animationDuration > 0 ? 0 : 1,
118
+ scaleX: o,
119
+ scaleY: o,
120
+ src: e
121
+ }), t;
122
+ }
123
+ async function k(e) {
124
+ !(e instanceof p) || n.animationDuration === 0 || (n.emitPending && h("update:pending", !0), await new Promise((o) => {
125
+ const r = n.animationDuration, S = Date.now(), i = () => {
126
+ const I = Date.now() - S, m = Math.min(I / r, 1);
127
+ e.set("opacity", m), a.renderAll(), m < 1 ? requestAnimationFrame(i) : (n.emitPending && h("update:pending", !1), o());
128
+ };
129
+ requestAnimationFrame(i);
130
+ }));
131
+ }
132
+ function V(e) {
133
+ const t = g.findScaleToCover(e, a);
134
+ return e.set({
135
+ scaleX: t,
136
+ scaleY: t
137
+ }), e;
138
+ }
139
+ async function M(e) {
140
+ const t = await b(e.src);
141
+ a.backgroundImage = t, a.centerObject(t), a.renderAll(), await k(t), v();
142
+ }
143
+ async function X(e) {
144
+ const t = await b(e.src);
145
+ t.selectable = !1, t.assetType = "foreground", a.add(t), a.centerObject(t), a.renderAll(), await k(t), v();
146
+ }
147
+ async function Y(e) {
148
+ const t = await b(e.src);
149
+ t.set({
150
+ left: d.value / 2,
151
+ top: u.value / 2,
152
+ scaleX: d.value / t.width,
153
+ scaleY: u.value / t.height
154
+ }), a.overlayImage = t, a.renderAll(), await k(t), v();
155
+ }
156
+ async function G(e) {
157
+ a.discardActiveObject();
158
+ const t = await U(e.src);
159
+ t.filename = e.src;
160
+ const o = d.value / 3, r = u.value / 3, S = o / t.width, i = r / t.height, I = Math.min(S, i);
161
+ t.set({
162
+ scaleX: I,
163
+ scaleY: I,
164
+ left: d.value / 2,
165
+ top: u.value / 2
166
+ }), t.id = e.id, t.padding = 8, a.add(t), a.setActiveObject(t), await k(t), a.renderAll();
167
+ }
168
+ function N(e, t) {
169
+ t.target.id;
170
+ const o = t.target;
171
+ return a.remove(o), a.requestRenderAll(), !0;
172
+ }
173
+ function P() {
174
+ if (d.value = w.value.offsetWidth, u.value = w.value.offsetHeight, a.setDimensions({ width: d.value, height: u.value }), a.backgroundImage && (a.backgroundImage = V(a.backgroundImage), a.centerObject(a.backgroundImage)), a.overlayImage) {
175
+ const e = a.overlayImage;
176
+ e.set({
177
+ scaleX: d.value / e.width,
178
+ scaleY: u.value / e.height
179
+ });
180
+ }
181
+ a.getObjects().forEach((e) => {
182
+ e.assetType === "foreground" && (e = V(e), a.centerObject(e));
183
+ }), a.renderAll();
184
+ }
185
+ const L = ne(() => {
186
+ P();
187
+ }, 200, { trailing: !0, leading: !1 });
188
+ function E(e) {
189
+ return (t, o, r, S, i) => {
190
+ t.save(), t.translate(o, r), t.rotate(g.degreesToRadians(i.angle)), t.fillStyle = n.options.themeData?.colors?.primary, t.fillRect(-24 / 2, -24 / 2, 24, 24);
191
+ const m = 20;
192
+ t.drawImage(e, -m / 2, -m / 2, m, m), t.restore();
193
+ };
194
+ }
195
+ function W() {
196
+ const e = document.createElement("img");
197
+ e.src = ce;
198
+ const t = document.createElement("img");
199
+ t.src = de, a.on("object:added", (o) => {
200
+ o.target && o.target.controls && (o.target.set({
201
+ transparentCorners: !1,
202
+ cornerSize: 16,
203
+ cornerStyle: "circle",
204
+ ...n.options.themeData?.colors?.primary ? {
205
+ cornerColor: n.options.themeData?.colors?.primary,
206
+ cornerStrokeColor: n.options.themeData?.colors?.primary,
207
+ borderColor: n.options.themeData?.colors?.primary
208
+ } : {}
209
+ }), o.target.controls.ml.visible = !1, o.target.controls.mr.visible = !1, o.target.controls.mb.visible = !1, o.target.controls.mt.visible = !1, o.target.controls.mtr.visible = !1, o.target.controls.rotate = new y({
210
+ x: 0.5,
211
+ y: -0.5,
212
+ offsetX: 32,
213
+ offsetY: 0,
214
+ cursorStyle: "pointer",
215
+ actionName: "rotate",
216
+ actionHandler: O.rotationWithSnapping,
217
+ cursorStyleHandler: O.rotationStyleHandler,
218
+ render: E(e)
219
+ }), o.target.controls.delete = new y({
220
+ x: 0.5,
221
+ y: -0.5,
222
+ offsetX: 32,
223
+ offsetY: 32,
224
+ cursorStyle: "pointer",
225
+ mouseUpHandler: N,
226
+ render: E(t)
227
+ }));
228
+ });
229
+ }
230
+ async function q() {
231
+ return await new Promise((e) => {
232
+ setTimeout(() => {
233
+ const t = n.exportToSvg ? a.toSVG() : a.toDataURL({ multiplier: 2 });
234
+ e(t);
235
+ }, 200);
236
+ });
237
+ }
238
+ function v() {
239
+ setTimeout(async () => {
240
+ const e = a.toDatalessJSON(["selectable", "assetType", "filename"]);
241
+ await se("fabric-canvas", JSON.stringify(e));
242
+ let t = !0;
243
+ if (n.required)
244
+ switch (t = !1, n.feature) {
245
+ case "overlay":
246
+ e.overlayImage && (t = !0);
247
+ break;
248
+ case "background":
249
+ e.backgroundImage && (t = !0);
250
+ break;
251
+ case "stickers":
252
+ e.objects.length > 1 && (t = !0);
253
+ break;
254
+ default:
255
+ (e.objects.length > 1 || e.backgroundImage || e.overlayImage) && (t = !0);
256
+ }
257
+ if (t) {
258
+ R = !0;
259
+ const o = await q();
260
+ h("update:modelValue", o), h("update:jsonModel", e);
261
+ }
262
+ }, 120);
263
+ }
264
+ async function J(e) {
265
+ try {
266
+ return await p.fromURL(e);
267
+ } catch (t) {
268
+ throw console.error("Error loading image:", t), t;
269
+ }
270
+ }
271
+ async function $(e) {
272
+ const { objects: t, options: o } = await A(e);
273
+ return g.groupSVGElements(t, o);
274
+ }
275
+ async function K(e) {
276
+ const { objects: t, options: o } = await F(e);
277
+ return g.groupSVGElements(t, o);
278
+ }
279
+ async function U(e) {
280
+ return e && typeof e == "string" && e.trim().startsWith("<") ? await K(e) : e && new RegExp(/([\w_/-]*\.svg$)|(image\/svg\+xml)/gi).test(e) ? await $(e) : await J(e);
281
+ }
282
+ async function z(e, t) {
283
+ e && !t && !R && X({ src: e });
284
+ }
285
+ return Z(() => n.modelValue, async (e, t) => {
286
+ z(e, t);
287
+ }), ee(async () => {
288
+ ({ Canvas: f, FabricImage: p, Control: y, util: g, loadSVGFromURL: A, loadSVGFromString: F, config: x, controlsUtils: O } = await import("fabric")), d.value = w.value.offsetWidth, u.value = w.value.offsetHeight, window.addEventListener("resize", L), x.NUM_FRACTION_DIGITS = 8;
289
+ const e = f.prototype._onTouchStart;
290
+ f.prototype._onTouchStart = function(t) {
291
+ const o = this.findTarget(t);
292
+ this.allowTouchScrolling && o.assetType && !this.isDrawingMode || e.call(this, t);
293
+ }, a = new f("fabricCanvas", {
294
+ width: d.value,
295
+ height: u.value,
296
+ // enableRetinaScaling: false,
297
+ skipOffscreen: !0,
298
+ // devicePixelRatio: 4,
299
+ allowTouchScrolling: !0
300
+ // backstoreOnly: true
301
+ }), n.resetState && await le("fabric-canvas"), T.value = await ie("fabric-canvas"), T.value ? (await H(a, T.value), a.requestRenderAll(), requestAnimationFrame(() => {
302
+ a.renderAll();
303
+ })) : n.modelValue && z(n.modelValue, ""), a.on("object:added", v), a.on("object:removed", v), a.on("object:modified", v), W(), a.renderAll(), h("on-ready", a);
304
+ }), (e, t) => (te(), ae("div", {
305
+ class: "fabric-canvas",
306
+ ref_key: "root",
307
+ ref: w
308
+ }, [
309
+ B("div", ue, [
310
+ B("canvas", fe, null, 512)
311
+ ]),
312
+ oe(e.$slots, "default")
313
+ ], 512));
314
+ }
315
+ });
316
+ export {
317
+ pe as _
318
+ };