@picsart/react-photo-editor 1.0.0

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.js ADDED
@@ -0,0 +1,1850 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var merge = require('lodash/merge');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var merge__default = /*#__PURE__*/_interopDefault(merge);
10
+
11
+ // src/PhotoEditor.tsx
12
+
13
+ // src/core/fontsList.js
14
+ var fontsList_default = [{
15
+ font_name: "Abril Fatface",
16
+ font_src: "https://fonts.gstatic.com/s/abrilfatface/v11/zOL64pLDlL1D99S8g8PtiKchm-BsjOLhZBY.ttf",
17
+ preview_url: "https://cdn140.picsart.com/25386885332449700051.png",
18
+ meta_data: {
19
+ font_name: "Abril Fatface"
20
+ }
21
+ }, {
22
+ font_name: "Alfa Slab One",
23
+ font_src: "https://fonts.gstatic.com/s/alfaslabone/v9/6NUQ8FmMKwSEKjnm5-4v-4Jh6dVretWvYmE.ttf",
24
+ preview_url: "https://cdn130.picsart.com/53956840285132480830.png",
25
+ meta_data: {
26
+ font_name: "Alfa Slab One"
27
+ }
28
+ }, {
29
+ font_name: "Anton",
30
+ font_src: "https://fonts.gstatic.com/s/anton/v11/1Ptgg87LROyAm0K08i4gS7lu.ttf",
31
+ preview_url: "https://cdn140.picsart.com/98137588707333945131.png",
32
+ meta_data: {
33
+ font_name: "Anton"
34
+ }
35
+ }, {
36
+ font_name: "Arbutus Slab",
37
+ font_src: "https://fonts.gstatic.com/s/arbutusslab/v8/oY1Z8e7OuLXkJGbXtr5ba7ZVa68dJlaFAQ.ttf",
38
+ preview_url: "https://cdn130.picsart.com/27819557168994204830.png",
39
+ meta_data: {
40
+ font_name: "Arbutus Slab"
41
+ }
42
+ }, {
43
+ font_name: "Asap",
44
+ font_src: "https://fonts.gstatic.com/s/asap/v11/KFOoCniXp96a-zwU4UROGzY.ttf",
45
+ preview_url: "https://cdn140.picsart.com/60809597155772951620.png",
46
+ meta_data: {
47
+ font_name: "Asap"
48
+ }
49
+ }, {
50
+ font_name: "Bad Script",
51
+ font_src: "https://fonts.gstatic.com/s/badscript/v8/6NUT8F6PJgbFWQn47_x7lOwuzd1AZtw.ttf",
52
+ preview_url: "https://cdn140.picsart.com/13128634343141786843.png",
53
+ meta_data: {
54
+ font_name: "Bad Script"
55
+ }
56
+ }, {
57
+ font_name: "Bangers",
58
+ font_src: "https://fonts.gstatic.com/s/bangers/v12/FeVQS0BTqb0h60ACL5la2bxii28.ttf",
59
+ preview_url: "https://cdn140.picsart.com/44707958769094196908.png",
60
+ meta_data: {
61
+ font_name: "Bangers"
62
+ }
63
+ }, {
64
+ font_name: "Bebas Neue",
65
+ font_src: "https://fonts.gstatic.com/s/bebasneue/v1/JTUSjIg69CK48gW7PXooxW5rygbi49c.ttf",
66
+ preview_url: "https://cdn130.picsart.com/98334325782617391670.png",
67
+ meta_data: {
68
+ font_name: "Bebas Neue"
69
+ }
70
+ }, {
71
+ font_name: "Big Shoulders Text",
72
+ font_src: "https://fonts.gstatic.com/s/bigshoulderstext/v1/55xxezRtP9G3CGPIf49hxc8P0eytUxBsnIx7QMISdQ.ttf",
73
+ preview_url: "https://cdn130.picsart.com/12121726167610188875.png",
74
+ meta_data: {
75
+ font_name: "Big Shoulders Text"
76
+ }
77
+ }, {
78
+ font_name: "Chivo",
79
+ font_src: "https://fonts.gstatic.com/s/chivo/v11/va9I4kzIxd1KFoBvS-J3kbDP.ttf",
80
+ preview_url: "https://cdn140.picsart.com/58052000465919491577.png",
81
+ meta_data: {
82
+ font_name: "Chivo"
83
+ }
84
+ }, {
85
+ font_name: "Cormorant Garamond",
86
+ font_src: "https://fonts.gstatic.com/s/cormorantgaramond/v7/co3bmX5slCNuHLi8bLeY9MK7whWMhyjornFLsS6V7w.ttf",
87
+ preview_url: "https://pastatic.picsart.com/93140072008531375848.png",
88
+ meta_data: {
89
+ font_name: "Cormorant Garamond"
90
+ }
91
+ }, {
92
+ font_name: "Crimson Text",
93
+ font_src: "https://fonts.gstatic.com/s/crimsontext/v10/wlp2gwHKFkZgtmSR3NB0oRJvaAJSA_JN3Q.ttf",
94
+ preview_url: "https://cdn140.picsart.com/69167876914314732943.png",
95
+ meta_data: {
96
+ font_name: "Crimson Text"
97
+ }
98
+ }, {
99
+ font_name: "DM Serif Text",
100
+ font_src: "https://fonts.gstatic.com/s/dmseriftext/v4/rnCu-xZa_krGokauCeNq1wWyafOPXHIJErY.ttf",
101
+ preview_url: "https://cdn130.picsart.com/55282901287078186246.png",
102
+ meta_data: {
103
+ font_name: "DM Serif Text"
104
+ }
105
+ }, {
106
+ font_name: "Dancing Script",
107
+ font_src: "https://fonts.gstatic.com/s/dancingscript/v13/If2cXTr6YS-zF4S-kcSWSVi_sxjsohD9F50Ruu7BMSoHTeB9ptDqpw.ttf",
108
+ preview_url: "https://cdn140.picsart.com/24219941301405950625.png",
109
+ meta_data: {
110
+ font_name: "Dancing Script"
111
+ }
112
+ }, {
113
+ font_name: "EB Garamond",
114
+ font_src: "https://fonts.gstatic.com/s/ebgaramond/v12/SlGDmQSNjdsmc35JDF1K5E55YMjF_7DPuGi-6_RUA4V-e6yHgQ.ttf",
115
+ preview_url: "https://cdn140.picsart.com/74991851353912958783.png",
116
+ meta_data: {
117
+ font_name: "EB Garamond"
118
+ }
119
+ }, {
120
+ font_name: "Great Vibes",
121
+ font_src: "https://fonts.gstatic.com/s/greatvibes/v7/RWmMoKWR9v4ksMfaWd_JN-XCg6UKDXlq.ttf",
122
+ preview_url: "https://cdn140.picsart.com/22644934000530171740.png",
123
+ meta_data: {
124
+ font_name: "Great Vibes"
125
+ }
126
+ }, {
127
+ font_name: "Heebo",
128
+ font_src: "https://fonts.gstatic.com/s/heebo/v5/NGS6v5_NC0k9P-HxR7BDsbMB.ttf",
129
+ preview_url: "https://cdn140.picsart.com/52315751355339412370.png",
130
+ meta_data: {
131
+ font_name: "Heebo"
132
+ }
133
+ }, {
134
+ font_name: "Inria Serif",
135
+ font_src: "https://fonts.gstatic.com/s/inriaserif/v1/fC1lPYxPY3rXxEndZJAzN0SsfSzNr0Ck.ttf",
136
+ preview_url: "https://cdn130.picsart.com/94780437423766762060.png",
137
+ meta_data: {
138
+ font_name: "Inria Serif"
139
+ }
140
+ }, {
141
+ font_name: "Merienda One",
142
+ font_src: "https://fonts.gstatic.com/s/meriendaone/v10/H4cgBXaMndbflEq6kyZ1ht6YgoyyYzFzFw.ttf",
143
+ preview_url: "https://cdn140.picsart.com/21041524504352927265.png",
144
+ meta_data: {
145
+ font_name: "Merienda One"
146
+ }
147
+ }, {
148
+ font_name: "Merriweather",
149
+ font_src: "https://fonts.gstatic.com/s/merriweather/v21/u-440qyriQwlOrhSvowK_l5OeyxNV-bnrw.ttf",
150
+ preview_url: "https://cdn130.picsart.com/69929375998507772789.png",
151
+ meta_data: {
152
+ font_name: "Merriweather"
153
+ }
154
+ }, {
155
+ font_name: "Open Sans",
156
+ font_src: "https://fonts.gstatic.com/s/opensans/v17/mem8YaGs126MiZpBA-U1UpcaXcl0Aw.ttf",
157
+ preview_url: "https://cdn140.picsart.com/35428599082644159320.png",
158
+ meta_data: {
159
+ font_name: "Open Sans"
160
+ }
161
+ }, {
162
+ font_name: "Oswald",
163
+ font_src: "https://fonts.gstatic.com/s/oswald/v29/TK3_WkUHHAIjg75cFRf3bXL8LICs1_FvgUFoZAaRliE.ttf",
164
+ preview_url: "https://cdn130.picsart.com/71974891250077960293.png",
165
+ meta_data: {
166
+ font_name: "Oswald"
167
+ }
168
+ }, {
169
+ font_name: "Parisienne",
170
+ font_src: "https://fonts.gstatic.com/s/parisienne/v7/E21i_d3kivvAkxhLEVZpcy96DuKuavM.ttf",
171
+ preview_url: "https://cdn130.picsart.com/84449816304575771854.png",
172
+ meta_data: {
173
+ font_name: "Parisienne"
174
+ }
175
+ }, {
176
+ font_name: "Source Code Pro",
177
+ font_src: "https://fonts.gstatic.com/s/sourcecodepro/v11/HI_SiYsKILxRpg3hIP6sJ7fM7PqVOuHXvMY3xw.ttf",
178
+ preview_url: "https://cdn130.picsart.com/40590227740456995315.png",
179
+ meta_data: {
180
+ font_name: "Source Code Pro"
181
+ }
182
+ }, {
183
+ font_name: "Staatliches",
184
+ font_src: "https://fonts.gstatic.com/s/staatliches/v3/HI_OiY8KO6hCsQSoAPmtMbectJG9O9PS.ttf",
185
+ preview_url: "https://cdn130.picsart.com/73687792431864727223.png",
186
+ meta_data: {
187
+ font_name: "Staatliches"
188
+ }
189
+ }, {
190
+ font_name: "Vollkorn",
191
+ font_src: "https://fonts.gstatic.com/s/vollkorn/v10/0yb9GDoxxrvAnPhYGykuYkw2rQg1.ttf",
192
+ preview_url: "https://cdn140.picsart.com/80348853381420089213.png",
193
+ meta_data: {
194
+ font_name: "Vollkorn"
195
+ }
196
+ }, {
197
+ font_name: "Zilla Slab Highlight",
198
+ font_src: "https://fonts.gstatic.com/s/zillaslabhighlight/v7/gNMbW2BrTpK8-inLtBJgMMfbm6uNVDvRxhtIY2DwSXlM.ttf",
199
+ preview_url: "https://cdn140.picsart.com/29550039543117905772.png",
200
+ meta_data: {
201
+ font_name: "Zilla Slab Highlight"
202
+ }
203
+ }, {
204
+ font_name: "Amatic SC",
205
+ font_src: "https://fonts.gstatic.com/s/amaticsc/v13/TUZyzwprpvBS1izr_vO0De6ecZQf1A.ttf",
206
+ preview_url: "https://cdn140.picsart.com/76133169940323953167.png",
207
+ meta_data: {
208
+ font_name: "Amatic SC"
209
+ }
210
+ }, {
211
+ font_name: "Bungee Hairline",
212
+ font_src: "https://fonts.gstatic.com/s/bungeehairline/v5/snfys0G548t04270a_ljTLUVrv-7YB2dQ5ZPqQ.ttf",
213
+ preview_url: "https://cdn130.picsart.com/45339044762932607722.png",
214
+ meta_data: {
215
+ font_name: "Bungee Hairline"
216
+ }
217
+ }, {
218
+ font_name: "Bungee Shade",
219
+ font_src: "https://fonts.gstatic.com/s/bungeeshade/v5/DtVkJxarWL0t2KdzK3oI_jks7iLSrwFUlw.ttf",
220
+ preview_url: "https://cdn130.picsart.com/30429614379741731995.png",
221
+ meta_data: {
222
+ font_name: "Bungee Shade"
223
+ }
224
+ }, {
225
+ font_name: "Caveat",
226
+ font_src: "https://fonts.gstatic.com/s/caveat/v7/Wnz6HAc5bAfYB2QLYTwZqg_MPQ.ttf",
227
+ preview_url: "https://cdn140.picsart.com/99600177644972122868.png",
228
+ meta_data: {
229
+ font_name: "Caveat"
230
+ }
231
+ }, {
232
+ font_name: "Changa One",
233
+ font_src: "https://fonts.gstatic.com/s/changaone/v12/xfu00W3wXn3QLUJXhzq46AbouLfbK64.ttf",
234
+ preview_url: "https://cdn140.picsart.com/08678826250924492860.png",
235
+ meta_data: {
236
+ font_name: "Changa One"
237
+ }
238
+ }, {
239
+ font_name: "Codystar",
240
+ font_src: "https://fonts.gstatic.com/s/codystar/v7/FwZY7-Q1xVk-40qxOt6A4sijpFu_.ttf",
241
+ preview_url: "https://cdn140.picsart.com/47765983021350681268.png",
242
+ meta_data: {
243
+ font_name: "Codystar"
244
+ }
245
+ }, {
246
+ font_name: "Concert One",
247
+ font_src: "https://fonts.gstatic.com/s/concertone/v10/VEM1Ro9xs5PjtzCu-srDqRTlhv-CuVAQ.ttf",
248
+ preview_url: "https://cdn130.picsart.com/76388331921052823333.png",
249
+ meta_data: {
250
+ font_name: "Concert One"
251
+ }
252
+ }, {
253
+ font_name: "Crete Round",
254
+ font_src: "https://fonts.gstatic.com/s/creteround/v8/55xoey1sJNPjPiv1ZZZrxJ1827zAKnxN.ttf",
255
+ preview_url: "https://cdn140.picsart.com/73227707607828188588.png",
256
+ meta_data: {
257
+ font_name: "Crete Round"
258
+ }
259
+ }, {
260
+ font_name: "Dr Sugiyama",
261
+ font_src: "https://fonts.gstatic.com/s/drsugiyama/v9/HTxoL2k4N3O9n5I1boGI7abRM4-t-g7y.ttf",
262
+ preview_url: "https://cdn130.picsart.com/66294513859724732016.png",
263
+ meta_data: {
264
+ font_name: "Dr Sugiyama"
265
+ }
266
+ }, {
267
+ font_name: "Fredericka the Great",
268
+ font_src: "https://fonts.gstatic.com/s/frederickathegreat/v9/9Bt33CxNwt7aOctW2xjbCstzwVKsIBVV-9Skz7Ylch2L.ttf",
269
+ preview_url: "https://cdn130.picsart.com/92007141600631385660.png",
270
+ meta_data: {
271
+ font_name: "Fredericka the Great"
272
+ }
273
+ }, {
274
+ font_name: "Frijole",
275
+ font_src: "https://fonts.gstatic.com/s/frijole/v8/uU9PCBUR8oakM2BQ7xPb3vyHmlI.ttf",
276
+ preview_url: "https://cdn130.picsart.com/29077552055373747063.png",
277
+ meta_data: {
278
+ font_name: "Frijole"
279
+ }
280
+ }, {
281
+ font_name: "Henny Penny",
282
+ font_src: "https://fonts.gstatic.com/s/hennypenny/v7/wXKvE3UZookzsxz_kjGSfMQqt3M7tMDT.ttf",
283
+ preview_url: "https://cdn130.picsart.com/93810668391587565745.png",
284
+ meta_data: {
285
+ font_name: "Henny Penny"
286
+ }
287
+ }, {
288
+ font_name: "IM Fell English SC",
289
+ font_src: "https://fonts.gstatic.com/s/imfellenglishsc/v9/a8IENpD3CDX-4zrWfr1VY879qFF05pZLO4gOg0shzA.ttf",
290
+ preview_url: "https://cdn130.picsart.com/04660082970457630430.png",
291
+ meta_data: {
292
+ font_name: "IM Fell English SC"
293
+ }
294
+ }, {
295
+ font_name: "Julius Sans One",
296
+ font_src: "https://fonts.gstatic.com/s/juliussansone/v8/1Pt2g8TAX_SGgBGUi0tGOYEga5W-xXEW6aGXHw.ttf",
297
+ preview_url: "https://cdn140.picsart.com/45176589609511593985.png",
298
+ meta_data: {
299
+ font_name: "Julius Sans One"
300
+ }
301
+ }, {
302
+ font_name: "League Script",
303
+ font_src: "https://fonts.gstatic.com/s/leaguescript/v11/CSR54zpSlumSWj9CGVsoBZdeaNNUuOwkC2s.ttf",
304
+ preview_url: "https://cdn140.picsart.com/40896784254023474235.png",
305
+ meta_data: {
306
+ font_name: "League Script"
307
+ }
308
+ }, {
309
+ font_name: "Leckerli One",
310
+ font_src: "https://fonts.gstatic.com/s/leckerlione/v10/V8mCoQH8VCsNttEnxnGQ-1itLZxcBtItFw.ttf",
311
+ preview_url: "https://cdn130.picsart.com/76382168072777436281.png",
312
+ meta_data: {
313
+ font_name: "Leckerli One"
314
+ }
315
+ }, {
316
+ font_name: "Lobster",
317
+ font_src: "https://fonts.gstatic.com/s/lobster/v22/neILzCirqoswsqX9_oWsMqEzSJQ.ttf",
318
+ preview_url: "https://cdn140.picsart.com/60206260212877767907.png",
319
+ meta_data: {
320
+ font_name: "Lobster"
321
+ }
322
+ }, {
323
+ font_name: "Long Cang",
324
+ font_src: "https://fonts.gstatic.com/s/longcang/v5/LYjAdGP8kkgoTec8zkRgrXArXN7HWQ.ttf",
325
+ preview_url: "https://cdn140.picsart.com/37794032314052223165.png",
326
+ meta_data: {
327
+ font_name: "Long Cang"
328
+ }
329
+ }, {
330
+ font_name: "Lora",
331
+ font_src: "https://fonts.gstatic.com/s/lora/v14/0QIvMX1D_JOuAw3xItNPh_A.ttf",
332
+ preview_url: "https://cdn140.picsart.com/30097693383754699804.png",
333
+ meta_data: {
334
+ font_name: "Lora"
335
+ }
336
+ }, {
337
+ font_name: "Major Mono Display",
338
+ font_src: "https://fonts.gstatic.com/s/majormonodisplay/v4/RWmVoLyb5fEqtsfBX9PDZIGr2tFubRhLCn2QIndPww.ttf",
339
+ preview_url: "https://cdn140.picsart.com/16985850342092279724.png",
340
+ meta_data: {
341
+ font_name: "Major Mono Display"
342
+ }
343
+ }, {
344
+ font_name: "Mali",
345
+ font_src: "https://fonts.gstatic.com/s/mali/v3/N0ba2SRONuN4eCrODlxxOd8.ttf",
346
+ preview_url: "https://cdn130.picsart.com/34820611090914930892.png",
347
+ meta_data: {
348
+ font_name: "Mali"
349
+ }
350
+ }, {
351
+ font_name: "Mansalva",
352
+ font_src: "https://fonts.gstatic.com/s/mansalva/v1/aWB4m0aacbtDfvq5NJllI47vdyBg.ttf",
353
+ preview_url: "https://cdn130.picsart.com/84697180082457451630.png",
354
+ meta_data: {
355
+ font_name: "Mansalva"
356
+ }
357
+ }, {
358
+ font_name: "Marck Script",
359
+ font_src: "https://fonts.gstatic.com/s/marckscript/v10/nwpTtK2oNgBA3Or78gapdwuCzyI-aMPF7Q.ttf",
360
+ preview_url: "https://cdn130.picsart.com/57318081978554768069.png",
361
+ meta_data: {
362
+ font_name: "Marck Script"
363
+ }
364
+ }, {
365
+ font_name: "Nanum Brush Script",
366
+ font_src: "https://fonts.gstatic.com/s/nanumbrushscript/v17/wXK2E2wfpokopxzthSqPbcR5_gVaxazyjqBr1lO97Q.ttf",
367
+ preview_url: "https://cdn130.picsart.com/82999967921594322943.png",
368
+ meta_data: {
369
+ font_name: "Nanum Brush Script"
370
+ }
371
+ }, {
372
+ font_name: "Paprika",
373
+ font_src: "https://fonts.gstatic.com/s/paprika/v7/8QIJdijZitv49rDfuIgOq7jkAOw.ttf",
374
+ preview_url: "https://cdn140.picsart.com/51347254242869641933.png",
375
+ meta_data: {
376
+ font_name: "Paprika"
377
+ }
378
+ }, {
379
+ font_name: "Pathway Gothic One",
380
+ font_src: "https://fonts.gstatic.com/s/pathwaygothicone/v8/MwQrbgD32-KAvjkYGNUUxAtW7pEBwx-dTFxeb80flQ.ttf",
381
+ preview_url: "https://cdn130.picsart.com/37863778924817299018.png",
382
+ meta_data: {
383
+ font_name: "Pathway Gothic One"
384
+ }
385
+ }, {
386
+ font_name: "Quicksand",
387
+ font_src: "https://fonts.gstatic.com/s/quicksand/v19/6xK-dSZaM9iE8KbpRA_LJ3z8mH9BOJvgkP8o18G0wx40QDw.ttf",
388
+ preview_url: "https://cdn140.picsart.com/15573473827666789357.png",
389
+ meta_data: {
390
+ font_name: "Quicksand"
391
+ }
392
+ }, {
393
+ font_name: "Reenie Beanie",
394
+ font_src: "https://fonts.gstatic.com/s/reeniebeanie/v10/z7NSdR76eDkaJKZJFkkjuvWxbP2_qoOgf_w.ttf",
395
+ preview_url: "https://cdn140.picsart.com/81953552784397470347.png",
396
+ meta_data: {
397
+ font_name: "Reenie Beanie"
398
+ }
399
+ }, {
400
+ font_name: "Sacramento",
401
+ font_src: "https://fonts.gstatic.com/s/sacramento/v7/buEzpo6gcdjy0EiZMBUG0CoV_NxLeiw.ttf",
402
+ preview_url: "https://cdn130.picsart.com/33129819049263984903.png",
403
+ meta_data: {
404
+ font_name: "Sacramento"
405
+ }
406
+ }, {
407
+ font_name: "Satisfy",
408
+ font_src: "https://fonts.gstatic.com/s/satisfy/v10/rP2Hp2yn6lkG50LoOZSCHBeHFl0.ttf",
409
+ preview_url: "https://cdn140.picsart.com/40423524857848743546.png",
410
+ meta_data: {
411
+ font_name: "Satisfy"
412
+ }
413
+ }, {
414
+ font_name: "Seaweed Script",
415
+ font_src: "https://fonts.gstatic.com/s/seaweedscript/v7/bx6cNx6Tne2pxOATYE8C_Rsoe0WJ-KcGVbLW.ttf",
416
+ preview_url: "https://cdn130.picsart.com/36743659579852331137.png",
417
+ meta_data: {
418
+ font_name: "Seaweed Script"
419
+ }
420
+ }, {
421
+ font_name: "Srisakdi",
422
+ font_src: "https://fonts.gstatic.com/s/srisakdi/v3/yMJRMIlvdpDbkB0A-jq8fSx5i814.ttf",
423
+ preview_url: "https://cdn140.picsart.com/60734086227056523665.png",
424
+ meta_data: {
425
+ font_name: "Srisakdi"
426
+ }
427
+ }, {
428
+ font_name: "Tangerine",
429
+ font_src: "https://fonts.gstatic.com/s/tangerine/v11/IurY6Y5j_oScZZow4VOBDpxNhLBQ4Q.ttf",
430
+ preview_url: "https://cdn140.picsart.com/66743549317724920262.png",
431
+ meta_data: {
432
+ font_name: "Tangerine"
433
+ }
434
+ }, {
435
+ font_name: "Vast Shadow",
436
+ font_src: "https://fonts.gstatic.com/s/vastshadow/v9/pe0qMImKOZ1V62ZwbVY9dfe6Kdpickwp.ttf",
437
+ preview_url: "https://cdn130.picsart.com/77776772587774873556.png",
438
+ meta_data: {
439
+ font_name: "Vast Shadow"
440
+ }
441
+ }];
442
+
443
+ // src/core/defaultShapes.js
444
+ var defaultShapes_default = [
445
+ {
446
+ id: 345303412001900,
447
+ shapeURL: "https://pastatic.picsart.com/67674838747034922127.svg",
448
+ previewURL: "https://pastatic.picsart.com/39063950453406823106.svg",
449
+ shapeData: {},
450
+ height: 80,
451
+ width: 80
452
+ },
453
+ {
454
+ id: 345303412006900,
455
+ shapeURL: "https://pastatic.picsart.com/98272467955195325128.svg",
456
+ previewURL: "https://pastatic.picsart.com/05206144264858143619.svg",
457
+ shapeData: {},
458
+ height: 200,
459
+ width: 200
460
+ },
461
+ {
462
+ id: 345303412002900,
463
+ shapeURL: "https://pastatic.picsart.com/57791726628432881396.svg",
464
+ previewURL: "https://pastatic.picsart.com/63067569913637571198.svg",
465
+ shapeData: {},
466
+ height: 200,
467
+ width: 200
468
+ },
469
+ {
470
+ id: 345303412011900,
471
+ shapeURL: "https://pastatic.picsart.com/46559167057824445884.svg",
472
+ previewURL: "https://pastatic.picsart.com/12360977754442257483.svg",
473
+ shapeData: {},
474
+ height: 201,
475
+ width: 233
476
+ },
477
+ {
478
+ id: 345303412009900,
479
+ shapeURL: "https://pastatic.picsart.com/89599633680779280911.svg",
480
+ previewURL: "https://pastatic.picsart.com/63267229478005739326.svg",
481
+ shapeData: {},
482
+ height: 141,
483
+ width: 264
484
+ },
485
+ {
486
+ id: 345303412010900,
487
+ shapeURL: "https://pastatic.picsart.com/78485030174201737552.svg",
488
+ previewURL: "https://pastatic.picsart.com/86263046247610758102.svg",
489
+ meta_data: {},
490
+ height: 199,
491
+ width: 200
492
+ },
493
+ {
494
+ id: 345303412012900,
495
+ shapeURL: "https://pastatic.picsart.com/24634984538216308784.svg",
496
+ previewURL: "https://pastatic.picsart.com/62784000735717431696.svg",
497
+ meta_data: {},
498
+ height: 200,
499
+ width: 181
500
+ },
501
+ {
502
+ id: 345303412017900,
503
+ shapeURL: "https://pastatic.picsart.com/54207421235588996849.svg",
504
+ previewURL: "https://pastatic.picsart.com/01167396734591686010.svg",
505
+ shapeData: {},
506
+ height: 232,
507
+ width: 240
508
+ },
509
+ {
510
+ id: 345303412015900,
511
+ shapeURL: "https://pastatic.picsart.com/15320122074878532844.svg",
512
+ previewURL: "https://pastatic.picsart.com/74335799754416069084.svg",
513
+ meta_data: {},
514
+ height: 200,
515
+ width: 195
516
+ },
517
+ {
518
+ id: 345303412016900,
519
+ shapeURL: "https://pastatic.picsart.com/06832702078758556506.svg",
520
+ previewURL: "https://pastatic.picsart.com/71342560555351334228.svg",
521
+ shapeData: {},
522
+ height: 200,
523
+ width: 200
524
+ },
525
+ {
526
+ id: 345303412019900,
527
+ shapeURL: "https://pastatic.picsart.com/64264690279601930886.svg",
528
+ previewURL: "https://pastatic.picsart.com/90493137861472273324.svg",
529
+ meta_data: {},
530
+ height: 200,
531
+ width: 240
532
+ },
533
+ {
534
+ id: 345303412020900,
535
+ shapeURL: "https://pastatic.picsart.com/96644793285407212882.svg",
536
+ previewURL: "https://pastatic.picsart.com/00682611258560241631.svg",
537
+ meta_data: {},
538
+ height: 80,
539
+ width: 80
540
+ },
541
+ {
542
+ id: 345632150027900,
543
+ shapeURL: "https://pastatic.picsart.com/43281069001980185600.svg",
544
+ previewURL: "https://pastatic.picsart.com/54482957936732253406.svg",
545
+ shapeData: {},
546
+ height: 150,
547
+ width: 150
548
+ },
549
+ {
550
+ id: 345632901034900,
551
+ shapeURL: "https://pastatic.picsart.com/16979764773159337615.svg",
552
+ previewURL: "https://pastatic.picsart.com/15126367804291641171.svg",
553
+ shapeData: {},
554
+ height: 150,
555
+ width: 79
556
+ },
557
+ {
558
+ id: 345632901024900,
559
+ shapeURL: "https://pastatic.picsart.com/38992226894190707969.svg",
560
+ previewURL: "https://pastatic.picsart.com/16528511082002358061.svg",
561
+ shapeData: {},
562
+ height: 150,
563
+ width: 150
564
+ },
565
+ {
566
+ id: 345632901026900,
567
+ shapeURL: "https://pastatic.picsart.com/70713047862835243809.svg",
568
+ previewURL: "https://pastatic.picsart.com/93054071608107947709.svg",
569
+ shapeData: {},
570
+ height: 150,
571
+ width: 150
572
+ }
573
+ ];
574
+
575
+ // src/core/defaultStickerShapes.js
576
+ var defaultStickerShapes_default = [
577
+ {
578
+ id: 1,
579
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/ae0dbf05-3df3-4703-91b2-49471ff40cfa.svg",
580
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/ae0dbf05-3df3-4703-91b2-49471ff40cfa.svg",
581
+ shapeData: {},
582
+ height: 100,
583
+ width: 100,
584
+ aspectRatio: "1:1",
585
+ path: void 0
586
+ },
587
+ {
588
+ id: 2,
589
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/4aff343f-2f06-4c1d-bdc3-a16800a536a4.svg",
590
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/4aff343f-2f06-4c1d-bdc3-a16800a536a4.svg",
591
+ shapeData: {},
592
+ height: 100,
593
+ width: 100,
594
+ aspectRatio: "1:1",
595
+ path: "M 0,0.5\n a 0.5,0.5 0 1,0 1,0\n a 0.5,0.5 0 1,0 -1,0"
596
+ },
597
+ {
598
+ id: 3,
599
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/5852cf85-2f78-4915-b6ca-59d50de81729.svg",
600
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/5852cf85-2f78-4915-b6ca-59d50de81729.svg",
601
+ shapeData: {},
602
+ height: 100,
603
+ width: 100,
604
+ aspectRatio: "4:3",
605
+ path: "M 0,0.5 a 0.5,0.5 0 1,0 1,0 a 0.5,0.5 0 1,0 -1,0"
606
+ },
607
+ {
608
+ id: 4,
609
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/42d502bc-2550-413b-80f6-eec2d67a924a.svg",
610
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/42d502bc-2550-413b-80f6-eec2d67a924a.svg",
611
+ shapeData: {},
612
+ height: 100,
613
+ width: 100,
614
+ aspectRatio: "3:4",
615
+ path: "M 0,0.5 a 0.5,0.5 0 1,0 1,0 a 0.5,0.5 0 1,0 -1,0"
616
+ },
617
+ {
618
+ id: 5,
619
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/d22d17be-382a-410e-9eb7-e0c6f84a8484.svg",
620
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/d22d17be-382a-410e-9eb7-e0c6f84a8484.svg",
621
+ shapeData: {},
622
+ height: 100,
623
+ width: 100,
624
+ aspectRatio: "1:1",
625
+ path: "M 0,0 H 1 V 1 H 0 V 0 Z"
626
+ },
627
+ {
628
+ id: 6,
629
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/fee313c8-f93e-4545-9e3c-040a1b741849.svg",
630
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/fee313c8-f93e-4545-9e3c-040a1b741849.svg",
631
+ shapeData: {},
632
+ height: 100,
633
+ width: 100,
634
+ aspectRatio: "1:1",
635
+ path: "M 0.1,0 H 0.9 A 0.1,0.1 0 0 1 1,0.1 V 0.9 A 0.1,0.1 0 0 1 0.9,1 H 0.1 A 0.1,0.1 0 0 1 0,0.9 V 0.1 A 0.1,0.1 0 0 1 0.1,0 Z"
636
+ },
637
+ {
638
+ id: 7,
639
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/94c0c7ba-499f-47e0-a1c3-4b8d96acf7b1.svg",
640
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/94c0c7ba-499f-47e0-a1c3-4b8d96acf7b1.svg",
641
+ shapeData: {},
642
+ height: 100,
643
+ width: 100,
644
+ aspectRatio: "4:3",
645
+ path: "M 0,0 H 1 V 1 H 0 V 0 Z"
646
+ },
647
+ {
648
+ id: 8,
649
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/d158f176-47a4-46ad-94df-17a92f4165da.svg",
650
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/d158f176-47a4-46ad-94df-17a92f4165da.svg",
651
+ shapeData: {},
652
+ height: 100,
653
+ width: 100,
654
+ aspectRatio: "3:4",
655
+ path: "M 0,0 H 1 V 1 H 0 V 0 Z"
656
+ },
657
+ {
658
+ id: 9,
659
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/b8be9e0c-0c44-4c79-b5e4-e655dc53eabc.svg",
660
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/b8be9e0c-0c44-4c79-b5e4-e655dc53eabc.svg",
661
+ shapeData: {},
662
+ height: 100,
663
+ width: 100,
664
+ aspectRatio: "1:1",
665
+ path: "M 0.5,0.020000000000000018 L 0.9945493884734798,0.3793111629250274 L 0.8056483311920861,0.9606888370749727 L 0.194351668807914,0.9606888370749727 L 0.005450611526520099,0.3793111629250274 Z"
666
+ },
667
+ {
668
+ id: 10,
669
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/dd8a0225-45b5-43b5-9d12-f556af64acf1.svg",
670
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/dd8a0225-45b5-43b5-9d12-f556af64acf1.svg",
671
+ shapeData: {},
672
+ height: 100,
673
+ width: 100,
674
+ aspectRatio: "1:1",
675
+ path: "M 0.5,0 L 0.9330127018922193,0.25 L 0.9330127018922194,0.7499999999999999 L 0.5,1 L 0.06698729810778076,0.7500000000000002 L 0.0669872981077807,0.24999999999999994 Z"
676
+ },
677
+ {
678
+ id: 11,
679
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/6fac991b-1058-4148-a47a-362f57acac01.svg",
680
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/6fac991b-1058-4148-a47a-362f57acac01.svg",
681
+ shapeData: {},
682
+ height: 100,
683
+ width: 100,
684
+ aspectRatio: "1:1",
685
+ path: "M 0.5,0 L 0.8535533905932737,0.14644660940672627 L 1,0.5 L 0.8535533905932737,0.8535533905932737 L 0.5,1 L 0.14644660940672627,0.8535533905932737 L 0,0.5000000000000001 L 0.14644660940672616,0.14644660940672627 Z"
686
+ },
687
+ {
688
+ id: 12,
689
+ shapeURL: "https://pastatic.picsart.com/cms-pastatic/c577e9a6-7e13-4eb9-b9df-a8c33cac2563.svg",
690
+ previewURL: "https://pastatic.picsart.com/cms-pastatic/c577e9a6-7e13-4eb9-b9df-a8c33cac2563.svg",
691
+ shapeData: {},
692
+ height: 100,
693
+ width: 100,
694
+ aspectRatio: "1:1",
695
+ path: "M 0.5,0.030000000000000027 L 0.6293127555043441,0.37201626123751164 L 0.9945493884734798,0.38931116292502743 L 0.7092324335849338,0.6179837387624885 L 0.8056483311920861,0.9706888370749727 L 0.5,0.77 L 0.194351668807914,0.9706888370749727 L 0.2907675664150662,0.6179837387624885 L 0.005450611526520099,0.38931116292502743 L 0.3706872444956559,0.37201626123751164 Z"
696
+ }
697
+ ];
698
+
699
+ // src/core/constants.js
700
+ var PICSART_PROP_NAME = "Picsart";
701
+ var PICSART_FONT_NAME = "Picsart-Fonts";
702
+ var FONT_DEFAULTS = {
703
+ size: 16,
704
+ family: "Arial"
705
+ };
706
+ var EXPORT_FORMATS = {
707
+ IMAGE_JPEG: "image/jpeg",
708
+ IMAGE_PNG: "image/png",
709
+ IMAGE_WEBP: "image/webp",
710
+ PRINT_PDF: "print/pdf",
711
+ PREVIEW_PDF: "preview/pdf",
712
+ PDF: "pdf",
713
+ REPLAY: "replay",
714
+ VIDEO_MP4: "video/mp4"
715
+ };
716
+ var DEFAULT_FORMAT = EXPORT_FORMATS.IMAGE_PNG;
717
+ var ALLOWED_FORMATS = [
718
+ EXPORT_FORMATS.IMAGE_JPEG,
719
+ EXPORT_FORMATS.IMAGE_PNG,
720
+ EXPORT_FORMATS.IMAGE_WEBP,
721
+ EXPORT_FORMATS.PRINT_PDF,
722
+ EXPORT_FORMATS.PREVIEW_PDF,
723
+ EXPORT_FORMATS.PDF,
724
+ EXPORT_FORMATS.REPLAY,
725
+ EXPORT_FORMATS.VIDEO_MP4
726
+ ];
727
+ var MAX_COLORS_AMOUNT = 21;
728
+ function readNodeEnv(key) {
729
+ if (typeof globalThis === "undefined") return void 0;
730
+ const proc = globalThis.process;
731
+ if (proc == null || typeof proc !== "object") return void 0;
732
+ const env = proc.env;
733
+ return env && typeof env === "object" ? env[key] : void 0;
734
+ }
735
+ var AI_API_KEY = readNodeEnv("AI_API_KEY");
736
+ var USE_PICSART_INVENTORY_MSG = "It is forbidden to provide data";
737
+ var getParentDomain = () => typeof window !== "undefined" ? window.location.origin : "";
738
+ var MEASUREMENTS_MAP = {
739
+ in: "inch",
740
+ cm: "centimeter",
741
+ mm: "millimeter",
742
+ px: "pixel"
743
+ };
744
+ var measurements = [
745
+ MEASUREMENTS_MAP.in,
746
+ MEASUREMENTS_MAP.cm,
747
+ MEASUREMENTS_MAP.mm,
748
+ MEASUREMENTS_MAP.px
749
+ ];
750
+ var EDITOR_MODE = {
751
+ print: "print",
752
+ video: "video",
753
+ image: "image"
754
+ };
755
+ var DEFAULT_EXPORT_SETTINGS = {
756
+ "print/pdf": {
757
+ colorProfile: "rgb"
758
+ }
759
+ };
760
+ var EXPORT_TYPES = {
761
+ buffer: "buffer",
762
+ blob: "blob",
763
+ base64: "base64"
764
+ };
765
+ var SHAPES_DATA = {
766
+ type: "shape_mask",
767
+ items: [],
768
+ shop_item_uid: "package_simple_shapes",
769
+ name: "Simple Shapes",
770
+ commercial: true,
771
+ icon: "https://easycdn.picsart.com/62940820781500116332.png",
772
+ is_monotype: false
773
+ };
774
+ var UPLOAD_TYPES = {
775
+ audio: "Audio"};
776
+ var WHITELIST_CDN_URLS = ["picsart.com"];
777
+ var TOOLS_REPLACEMENT_MAP = {
778
+ tool_removeBG: "remove-background"
779
+ };
780
+
781
+ // src/core/utils.js
782
+ var blobToBase64 = (blob) => new Promise((resolve, reject) => {
783
+ const reader = new FileReader();
784
+ reader.onloadend = () => resolve(reader.result);
785
+ reader.onerror = () => reject(reader.error);
786
+ reader.readAsDataURL(blob);
787
+ });
788
+ var blobToArrayBuffer = (blob) => new Promise((resolve, reject) => {
789
+ const reader = new FileReader();
790
+ reader.onloadend = () => resolve(reader.result);
791
+ reader.onerror = () => reject(reader.error);
792
+ reader.readAsArrayBuffer(blob);
793
+ });
794
+ var arrayBufferToBase64 = (buffer) => {
795
+ let binary = "";
796
+ const bytes = new Uint8Array(buffer);
797
+ const len = bytes.byteLength;
798
+ for (let i = 0; i < len; i++) {
799
+ binary += String.fromCharCode(bytes[i]);
800
+ }
801
+ return window.btoa(binary);
802
+ };
803
+ var noop = () => {
804
+ };
805
+ var getImageData = (buffer, exportType, mediaType = "base64") => {
806
+ const blob = new Blob([buffer], { type: exportType });
807
+ const url = URL.createObjectURL(blob);
808
+ switch (exportType) {
809
+ case EXPORT_TYPES.buffer:
810
+ return buffer;
811
+ case EXPORT_TYPES.blob:
812
+ return blob;
813
+ case EXPORT_TYPES.base64:
814
+ return `data:${mediaType};base64,${arrayBufferToBase64(buffer)}`;
815
+ default:
816
+ return url;
817
+ }
818
+ };
819
+ var getReplayData = (replay, exportType) => {
820
+ const buffer = replay.buffer;
821
+ switch (exportType) {
822
+ case EXPORT_TYPES.buffer:
823
+ return buffer;
824
+ case EXPORT_TYPES.blob:
825
+ return new Blob([buffer], { type: "application/zip+replay" });
826
+ case EXPORT_TYPES.base64:
827
+ return arrayBufferToBase64(buffer);
828
+ default:
829
+ return replay;
830
+ }
831
+ };
832
+ var getPrintData = async (blob, exportType) => {
833
+ const buffer = await blobToArrayBuffer(blob);
834
+ switch (exportType) {
835
+ case EXPORT_TYPES.buffer:
836
+ return buffer;
837
+ case EXPORT_TYPES.blob:
838
+ return blob;
839
+ case EXPORT_TYPES.base64:
840
+ const base64 = await blobToBase64(blob);
841
+ return base64;
842
+ default:
843
+ return blob;
844
+ }
845
+ };
846
+ var getCustomTheme = (branding) => {
847
+ const {
848
+ main,
849
+ texts,
850
+ accents,
851
+ hover,
852
+ background,
853
+ fonts,
854
+ language
855
+ } = branding;
856
+ const customTheme = {
857
+ ...main && { backgrounds: main },
858
+ ...texts && { texts },
859
+ ...fonts && { fonts: fonts.map((item) => ({ ...item, fontFamily: PICSART_FONT_NAME })) },
860
+ ...language && { language }
861
+ };
862
+ if (background) {
863
+ customTheme.canvasBackLayer = background;
864
+ }
865
+ if (accents) {
866
+ const colors = {
867
+ base: {
868
+ default: accents,
869
+ action: hover || accents
870
+ }
871
+ };
872
+ customTheme.accents = {
873
+ primary: colors,
874
+ secondary: colors
875
+ };
876
+ customTheme.accentIllustrations = {
877
+ primary: {
878
+ tint4: accents
879
+ }
880
+ };
881
+ }
882
+ return customTheme;
883
+ };
884
+ var makeQuery = (params = {}, settings = {}) => {
885
+ const query = new URLSearchParams();
886
+ const replayUrl = params.replayUrl ?? settings.replayUrl;
887
+ const videoURL = params.videoUrl ?? settings.videoUrl;
888
+ const subtitleURL = params.subtitleUrl ?? settings.subtitleUrl;
889
+ const template = params.templateId ?? settings.templateId;
890
+ const category = params.selectedCategory ?? settings.selectedCategory;
891
+ const canvasSize = params.canvasSize ?? settings.canvasSize;
892
+ const templateSize = params.templateSize ?? settings.templateSize;
893
+ const templatesFilters = params.templatesFilters ?? settings.templatesFilters;
894
+ const clientUpload = params.onUpload ?? settings.onUpload;
895
+ const templatesTitleText = params.templatesTitleText ?? settings.templatesTitleText;
896
+ const templatesSubTitle = params.templatesSubTitle ?? settings.templatesSubTitle;
897
+ const imageUrl = params.imageUrl ?? settings.imageUrl;
898
+ const stickerText = params.stickerText ?? settings.stickerText;
899
+ const stickerImageUrl = params.stickerImageUrl ?? settings.stickerImageUrl;
900
+ const logo = params.logo ?? settings.logo;
901
+ const parentDomain = params.parentDomain ?? settings.parentDomain ?? (typeof window !== "undefined" ? window.location.origin : "");
902
+ const queryParams = {
903
+ settings: JSON.stringify(settings),
904
+ parentDomain,
905
+ instanceId: settings.instanceId,
906
+ ...replayUrl && { replayUrl },
907
+ ...videoURL && { videoURL },
908
+ ...subtitleURL && { subtitleURL },
909
+ ...template && { template },
910
+ ...category && { category },
911
+ ...canvasSize && { customSize: canvasSize },
912
+ ...canvasSize && { shouldFit: true },
913
+ ...templateSize && { templateSize },
914
+ ...templatesFilters && { templatesFilters: JSON.stringify(templatesFilters) },
915
+ ...clientUpload && { clientUpload: true },
916
+ ...templatesTitleText && { templatesTitleText },
917
+ ...templatesSubTitle && { templatesSubTitle },
918
+ ...imageUrl && { image: imageUrl },
919
+ ...stickerImageUrl && { stickerImageUrl },
920
+ ...stickerText && { stickerText },
921
+ ...logo && { logo }
922
+ };
923
+ for (const [key, value] of Object.entries(queryParams)) {
924
+ if (value) query.set(key, value);
925
+ }
926
+ return query;
927
+ };
928
+
929
+ // src/core/getSettings.js
930
+ var isBoolean = (val) => typeof val === "boolean";
931
+ var mapTools = (tools) => tools.map((tool) => TOOLS_REPLACEMENT_MAP[tool] || tool);
932
+ var applyBooleanFields = (target, source, fields) => {
933
+ fields.forEach((field) => {
934
+ if (isBoolean(source[field])) {
935
+ target[field] = source[field];
936
+ delete source[field];
937
+ }
938
+ });
939
+ };
940
+ function getSettings(settings, params) {
941
+ const categories = params.categories || settings.categories;
942
+ const settingsWidgetOptions = params.features?.settingsWidgetOptions || settings.features?.settingsWidgetOptions;
943
+ const features = {
944
+ ...settings.features,
945
+ ...params.features
946
+ };
947
+ if (!features.toolbar) features.toolbar = {};
948
+ if (features.tools) {
949
+ features.toolbar.tools = mapTools(features.tools);
950
+ delete features.tools;
951
+ }
952
+ const editorSettings = {
953
+ ...features,
954
+ canvasOptions: { ...features.canvasOptions },
955
+ categories: categories || {},
956
+ printing: {
957
+ ...features.printing,
958
+ resolution: {
959
+ ...features.printing?.resolution
960
+ }
961
+ },
962
+ header: {
963
+ ...features.header,
964
+ export: {
965
+ ...features.header?.export
966
+ }
967
+ },
968
+ footer: {
969
+ ...features.footer,
970
+ ...settingsWidgetOptions?.length && { helpWidgetList: settingsWidgetOptions }
971
+ },
972
+ ...categories && { sidebar: Object.keys(categories).map((item) => item.toUpperCase()).filter((cat) => cat !== "MINIAPPS"), categories }
973
+ };
974
+ editorSettings.categories.text = {
975
+ ...editorSettings.categories.text || {},
976
+ ...settings.textSettings,
977
+ ...params.textSettings
978
+ };
979
+ applyBooleanFields(editorSettings.categories.elements || {}, editorSettings, [
980
+ "gradientForShapes",
981
+ "shapeToCollage"
982
+ ]);
983
+ applyBooleanFields(editorSettings.categories.uploads || {}, editorSettings, [
984
+ "uploadAndDrawVideo",
985
+ "uploadAndDrawImage",
986
+ "allowVideoUpload",
987
+ "showUploadLoader"
988
+ ]);
989
+ applyBooleanFields(editorSettings.categories.videos || {}, editorSettings, [
990
+ "videoTools",
991
+ "volume",
992
+ "video"
993
+ ]);
994
+ applyBooleanFields(editorSettings.toolbar, editorSettings, [
995
+ "hideTextStylesToolbarButton"
996
+ ]);
997
+ applyBooleanFields(editorSettings.footer, editorSettings, [
998
+ "zoomControls"
999
+ ]);
1000
+ applyBooleanFields(editorSettings.printing, editorSettings, [
1001
+ "fitBackgroundToBleedArea",
1002
+ "showPrintBleedByDefault"
1003
+ ]);
1004
+ applyBooleanFields(editorSettings.printing.resolution, editorSettings, [
1005
+ "PPI"
1006
+ ]);
1007
+ applyBooleanFields(editorSettings.header.export, editorSettings, [
1008
+ "exportTemplateData"
1009
+ ]);
1010
+ if (editorSettings.multiCanvasSupport) {
1011
+ editorSettings.canvasOptions = {
1012
+ ...editorSettings.canvasOptions,
1013
+ multiCanvasEnabled: editorSettings.multiCanvasSupport
1014
+ };
1015
+ delete editorSettings.multiCanvasSupport;
1016
+ }
1017
+ if (settings.usePicsartInventory) {
1018
+ ["layout", "text", "photos", "templates"].forEach((key) => {
1019
+ editorSettings.categories[key] = {
1020
+ ...editorSettings.categories[key],
1021
+ get: true,
1022
+ provideData: false,
1023
+ ...key === "text" && { customFontList: false }
1024
+ };
1025
+ });
1026
+ }
1027
+ if (settings.mode === EDITOR_MODE.print) {
1028
+ editorSettings.printing.printablePdf = true;
1029
+ Object.assign(editorSettings.categories.elements || {}, {
1030
+ unsupportedColorTypes: ["shadow"]
1031
+ });
1032
+ Object.assign(editorSettings.categories.text || {}, {
1033
+ unsupportedColorTypes: ["shadow"],
1034
+ unsupportedTextAligns: ["space-justify"]
1035
+ });
1036
+ editorSettings.exportFormats = settings.exportFormats?.filter((format) => !format.includes("video")) || [EXPORT_FORMATS.PRINT_PDF];
1037
+ }
1038
+ if (settings.mode === EDITOR_MODE.video) {
1039
+ editorSettings.toolbar.colorOptionTabs = false;
1040
+ editorSettings.categories.videos = { ...editorSettings.categories.videos, videoEnable: true, videoTools: true };
1041
+ if (editorSettings.categories.uploads) {
1042
+ editorSettings.categories.uploads.type = UPLOAD_TYPES.audio;
1043
+ }
1044
+ editorSettings.exportFormats = settings.exportFormats?.filter((format) => !format.includes("pdf")) || [EXPORT_FORMATS.VIDEO_MP4];
1045
+ }
1046
+ if (settings.mode !== EDITOR_MODE.image) {
1047
+ editorSettings.toolbar.disableBlendModes = true;
1048
+ }
1049
+ if (settings.exportFormats.some((item) => [EXPORT_FORMATS.PRINT_PDF, EXPORT_FORMATS.PREVIEW_PDF, EXPORT_FORMATS.PDF].includes(item))) {
1050
+ editorSettings.toolbar.colorOptionTabs = false;
1051
+ }
1052
+ if (categories?.uploads?.blackAndWhite) editorSettings.toolbar.colorOptionTabs = false;
1053
+ if (settings.branding) editorSettings.branding = getCustomTheme(settings.branding);
1054
+ if (settings.onUpload) editorSettings.clientUpload = true;
1055
+ return editorSettings;
1056
+ }
1057
+
1058
+ // src/core/cmsSettings.js
1059
+ var cmsSettings_default = {
1060
+ exportSettings: {
1061
+ "print/pdf": {
1062
+ emptyMargin: true
1063
+ }
1064
+ },
1065
+ textSettings: {
1066
+ recents: true,
1067
+ search: true,
1068
+ fontStyle: true
1069
+ },
1070
+ features: {
1071
+ cdnUploadApiKey: "60b37071-370e-413c-a855-95483e870190",
1072
+ showPrintBleedByDefault: true,
1073
+ segments: "ul35, l7xj",
1074
+ pulse: false,
1075
+ hslAdjust: true,
1076
+ exportTemplateData: true,
1077
+ hideRemoveBackgroundSidebarIcon: false,
1078
+ hideMultiCanvasToolbar: false,
1079
+ applyRemoveBackground: false,
1080
+ hideTextStylesToolbarButton: false,
1081
+ hideRemoveObjectTool: false,
1082
+ storeImagesInReplay: false,
1083
+ offlineUploads: false,
1084
+ hidePremiumIcons: false,
1085
+ tools: [
1086
+ "effects",
1087
+ "eraser",
1088
+ "tool_removeBG",
1089
+ "remover",
1090
+ "duplicate",
1091
+ "adjust",
1092
+ "edit",
1093
+ "color",
1094
+ "gradient",
1095
+ "font",
1096
+ "border",
1097
+ "outline",
1098
+ "shadow",
1099
+ "replace",
1100
+ "remove",
1101
+ "animation",
1102
+ "flip_rotate",
1103
+ "position"
1104
+ ],
1105
+ settingsWidgetOptions: [
1106
+ "update",
1107
+ "hint",
1108
+ "shortcut",
1109
+ "feedback",
1110
+ "help",
1111
+ "language",
1112
+ "theme",
1113
+ "report",
1114
+ "bleed"
1115
+ ]
1116
+ },
1117
+ categories: {
1118
+ templates: {
1119
+ provideData: false,
1120
+ header: true,
1121
+ showRecent: true,
1122
+ title: false,
1123
+ applyMultiPageOnClick: true
1124
+ },
1125
+ layout: {
1126
+ customSize: true,
1127
+ provideData: false,
1128
+ title: false
1129
+ },
1130
+ uploads: {
1131
+ linkUpload: false,
1132
+ header: true,
1133
+ tabs: [
1134
+ "Images",
1135
+ "Fonts"
1136
+ ]
1137
+ },
1138
+ collage: {},
1139
+ photos: {
1140
+ provideData: false,
1141
+ uploadTab: false,
1142
+ thumbnailFooter: true,
1143
+ showRecent: true,
1144
+ title: false,
1145
+ fitToImageSize: false
1146
+ },
1147
+ stickers: {
1148
+ provideData: false,
1149
+ header: true,
1150
+ thumbnailFooter: true,
1151
+ showRecent: true,
1152
+ showTags: true,
1153
+ title: false
1154
+ },
1155
+ text: {
1156
+ provideData: false,
1157
+ showRecent: true,
1158
+ library: true,
1159
+ toggleView: true,
1160
+ title: false,
1161
+ miniapps: true
1162
+ },
1163
+ overlays: {},
1164
+ elements: {
1165
+ provideData: false,
1166
+ header: true,
1167
+ title: false,
1168
+ viewExpanded: false,
1169
+ backBtn: true,
1170
+ hidePreview: false
1171
+ },
1172
+ background: {
1173
+ tabs: ["Texture", "Color", "Library"]
1174
+ },
1175
+ miniapps: {}
1176
+ }
1177
+ };
1178
+
1179
+ // src/core/Picsart.js
1180
+ var Picsart = class {
1181
+ constructor(settings) {
1182
+ const defaultSettings = {
1183
+ containerId: "containerId",
1184
+ accessibilityTitle: "Picsart",
1185
+ iframeClassName: "iframe",
1186
+ debug: false,
1187
+ fxView: "groups",
1188
+ instanceId: Math.random().toString(16).slice(2),
1189
+ exportFormats: [DEFAULT_FORMAT],
1190
+ templatesFilters: {},
1191
+ theme: "dark",
1192
+ exportType: "blob"
1193
+ };
1194
+ this.settings = {
1195
+ ...defaultSettings,
1196
+ ...settings.cms && cmsSettings_default,
1197
+ ...settings,
1198
+ domain: settings.domain ?? (typeof process !== "undefined" && process.env && process.env.EDITOR_DOMAIN) ?? ""
1199
+ };
1200
+ this.settings.exportFormats = this.settings.exportFormats.length ? this.settings.exportFormats.filter((item) => ALLOWED_FORMATS.includes(item)) : [DEFAULT_FORMAT];
1201
+ this.provideShapesData = { data: defaultShapes_default };
1202
+ this.isEditorReady = false;
1203
+ this.onExportCb = noop;
1204
+ this.messageListener = this.handleMessage.bind(this);
1205
+ this.isMessageListenerAttached = false;
1206
+ this.attachMessageListener();
1207
+ }
1208
+ log(...args) {
1209
+ if (this.settings.debug) console.log(...args);
1210
+ }
1211
+ onOpen(callback) {
1212
+ this.openCallBack = callback;
1213
+ return this;
1214
+ }
1215
+ renderNew(src) {
1216
+ this.attachMessageListener();
1217
+ const iframe = document.createElement("iframe");
1218
+ iframe.src = src;
1219
+ iframe.title = this.settings.accessibilityTitle;
1220
+ this.settings.iframeClassName && iframe.classList.add(this.settings.iframeClassName);
1221
+ iframe.style.width = "100%";
1222
+ iframe.style.height = "100%";
1223
+ iframe.style.pointerEvents = "auto";
1224
+ iframe.style.userSelect = "none";
1225
+ const container = document.getElementById(this.settings.containerId) || document.body;
1226
+ container.appendChild(iframe);
1227
+ this.iframe = iframe;
1228
+ this.isEditorReady = false;
1229
+ this.iframe.onload = () => {
1230
+ this.iframe.focus();
1231
+ this.log("Picsart iframe loaded");
1232
+ this.openCallBack && this.openCallBack();
1233
+ };
1234
+ }
1235
+ // TODO: This is only for versions before 1.13 (remote settings)
1236
+ // use renderNew instead, I keep it only for information purposes
1237
+ render(src) {
1238
+ this.attachMessageListener();
1239
+ const iframe = document.createElement("iframe");
1240
+ iframe.src = src;
1241
+ iframe.title = this.settings.accessibilityTitle;
1242
+ this.settings.iframeClassName && iframe.classList.add(this.settings.iframeClassName);
1243
+ iframe.style.width = "100%";
1244
+ iframe.style.height = "100%";
1245
+ iframe.style.pointerEvents = "auto";
1246
+ iframe.style.userSelect = "none";
1247
+ const container = document.getElementById(this.settings.containerId) || document.body;
1248
+ container.appendChild(iframe);
1249
+ this.iframe = iframe;
1250
+ this.isEditorReady = false;
1251
+ this.iframe.onload = () => {
1252
+ this.iframe.focus();
1253
+ this.log("Picsart iframe loaded");
1254
+ this.openCallBack && this.openCallBack();
1255
+ };
1256
+ }
1257
+ close() {
1258
+ this.callCloseHandlers();
1259
+ this.resetTempData();
1260
+ if (this.iframe) {
1261
+ this.iframe.parentNode.removeChild(this.iframe);
1262
+ this.iframe = null;
1263
+ this.log("Picsart iframe closed");
1264
+ }
1265
+ this.isEditorReady = false;
1266
+ this.detachMessageListener();
1267
+ return this;
1268
+ }
1269
+ hide() {
1270
+ if (this.iframe) this.iframe.style.display = "none";
1271
+ }
1272
+ callCloseHandlers() {
1273
+ this.cbClose && this.cbClose();
1274
+ this.tempOnClose && this.tempOnClose();
1275
+ }
1276
+ resetTempData() {
1277
+ this.tempOnClose = noop;
1278
+ this.tempOnExport = noop;
1279
+ this.tempExportType = "";
1280
+ this.tempExportSettings = null;
1281
+ }
1282
+ onClose(cb = noop) {
1283
+ this.cbClose = cb;
1284
+ return this;
1285
+ }
1286
+ /**
1287
+ * @param {(payload: any) => void} [cb]
1288
+ */
1289
+ onError(cb = noop) {
1290
+ this.cbError = cb;
1291
+ return this;
1292
+ }
1293
+ clear() {
1294
+ if (this.iframe) this.sendMessage("clearCanvas");
1295
+ return this;
1296
+ }
1297
+ applySettings(settings) {
1298
+ if (settings) this.sendMessage("applySettings", settings);
1299
+ }
1300
+ isIframeLoaded() {
1301
+ return this.iframe && this.isEditorReady;
1302
+ }
1303
+ // left for compatibility with older versions. Delete later
1304
+ onReady(cb = noop) {
1305
+ cb();
1306
+ return this;
1307
+ }
1308
+ async exportData(payload, cb) {
1309
+ const exportType = this.tempExportType || this.settings.exportType;
1310
+ const {
1311
+ buffer,
1312
+ replay,
1313
+ printData,
1314
+ // pdf for print with print marks
1315
+ printDataPreview,
1316
+ // pdf for print without print marks
1317
+ pdfData: rasterisedPdf,
1318
+ // rasterised pdf
1319
+ previews,
1320
+ imageFormat,
1321
+ videoData,
1322
+ videoUrl,
1323
+ ...rest
1324
+ } = payload;
1325
+ const previewsData = previews ? previews.map((item) => getImageData(item, exportType, imageFormat)) : null;
1326
+ const replayData = exportType && replay ? getReplayData(replay, exportType) : replay;
1327
+ const pdfForPrintData = exportType && printData ? await getPrintData(printData, exportType) : printData;
1328
+ const pdfForPrintDataPreview = exportType && printDataPreview ? await getPrintData(printDataPreview, exportType) : printDataPreview;
1329
+ const rasterisedPdfData = exportType && rasterisedPdf ? await getPrintData(rasterisedPdf, exportType) : rasterisedPdf;
1330
+ const result = {
1331
+ data: {
1332
+ ...replayData && { replayData },
1333
+ ...pdfForPrintData && { printData: pdfForPrintData },
1334
+ ...pdfForPrintDataPreview && { previewPdfData: pdfForPrintDataPreview },
1335
+ ...rasterisedPdfData && { pdfData: rasterisedPdfData },
1336
+ ...previewsData && { previewsData, imageData: previewsData[0] },
1337
+ ...videoData && { videoData },
1338
+ ...videoUrl && { videoUrl }
1339
+ },
1340
+ ...rest
1341
+ };
1342
+ cb(result);
1343
+ this.tempOnExport(result);
1344
+ }
1345
+ handleUpload(data) {
1346
+ const { uploadId, file, mimeType } = data;
1347
+ this.settings.onUpload(file, mimeType).then((res) => {
1348
+ this.sendMessage("upload", {
1349
+ ...res,
1350
+ uploadId
1351
+ });
1352
+ }).catch((err) => {
1353
+ this.sendMessage("upload", {
1354
+ error: err,
1355
+ uploadId
1356
+ });
1357
+ });
1358
+ }
1359
+ onUpload(handler) {
1360
+ this.settings.onUpload = handler;
1361
+ }
1362
+ /**
1363
+ * @param {(result: any) => void} [cb]
1364
+ */
1365
+ onExport(cb = noop) {
1366
+ this.onExportCb = cb;
1367
+ return this;
1368
+ }
1369
+ export() {
1370
+ this.sendMessage("export");
1371
+ }
1372
+ getEditorSettings(params) {
1373
+ return getSettings(this.settings, params);
1374
+ }
1375
+ open(params = {}) {
1376
+ if (!this.settings.domain) {
1377
+ throw new Error(
1378
+ "Picsart: `domain` is required (full editor URL, e.g. https://pe.picsart.io). Pass `domain` in constructor settings."
1379
+ );
1380
+ }
1381
+ if (!this.iframe) {
1382
+ const query = makeQuery(params, this.settings);
1383
+ this.tempOnClose = params.onClose || noop;
1384
+ this.tempOnExport = params.onExport || noop;
1385
+ this.tempExportType = params.exportType || "";
1386
+ this.tempExportSettings = params.exportSettings || null;
1387
+ const src = `${this.settings.domain}?${query.toString()}`;
1388
+ this.renderNew(src);
1389
+ } else if (this.iframe.style.display === "none") {
1390
+ this.iframe.style.display = "block";
1391
+ } else {
1392
+ params.onError && params.onError("Iframe is already opened");
1393
+ }
1394
+ return this;
1395
+ }
1396
+ openOld(params = {}) {
1397
+ if (!this.iframe) {
1398
+ const query = new URLSearchParams();
1399
+ const editorSettings = this.getEditorSettings(params);
1400
+ const measurement = params.measurement || this.settings.measurement;
1401
+ const checkedMeasurement = measurements.includes(measurement) ? measurement : MEASUREMENTS_MAP.px;
1402
+ const queryParams = {
1403
+ fitExportPDFSizeResult: params.fitExportPDFSizeResult || this.settings.fitExportPDFSizeResult,
1404
+ settings: JSON.stringify(editorSettings),
1405
+ instanceId: this.settings.instanceId,
1406
+ logo: params.logo || this.settings.logo,
1407
+ propertyId: params.propertyId || this.settings.propertyId,
1408
+ theme: params.theme || this.settings.theme,
1409
+ apiKey: params.apiKey || this.settings.apiKey || AI_API_KEY,
1410
+ replayUrl: params.replayURL || this.settings.replayURL,
1411
+ videoURL: params.videoURL || this.settings.videoURL,
1412
+ subtitleURL: params.subtitleURL || this.settings.subtitleURL,
1413
+ image: params.imageURL || this.settings.imageURL,
1414
+ customSize: params.customSize || this.settings.customSize,
1415
+ exportDPI: params.exportDPI || this.settings.exportDPI,
1416
+ exportQuality: params.quality || this.settings.quality,
1417
+ // TODO: fix - not implemented (quality)
1418
+ parentDomain: getParentDomain(),
1419
+ measurement: checkedMeasurement,
1420
+ fitBackgroundToBleedArea: params.fitBackgroundToBleedArea || this.settings.fitBackgroundToBleedArea,
1421
+ exportSettings: JSON.stringify(params.exportSettings || this.settings.exportSettings),
1422
+ templatesLoadSettings: JSON.stringify(params.templatesLoadSettings || this.settings.templatesLoadSettings),
1423
+ advancedText: this.settings.advancedText || params.advancedText,
1424
+ whitelistCdnUrls: JSON.stringify(WHITELIST_CDN_URLS),
1425
+ miniapps: JSON.stringify(this.settings.miniapps || params.miniapps),
1426
+ backgroundColor: params.backgroundColor || this.settings.backgroundColor
1427
+ };
1428
+ for (const [key, value] of Object.entries(queryParams)) {
1429
+ if (value) query.set(key, value);
1430
+ }
1431
+ const exportFormats = params.exportFormats || this.settings.exportFormats;
1432
+ if (exportFormats) exportFormats.forEach((item) => query.append("exportFormats", item));
1433
+ const defaultTemplateId = params.defaultTemplateId || this.settings.defaultTemplateId;
1434
+ if (defaultTemplateId && !queryParams.image && !params.templateSize && !queryParams.customSize && !queryParams.replayUrl) {
1435
+ query.set("template", defaultTemplateId);
1436
+ }
1437
+ const selectedTool = params.selectedTool || this.settings.selectedTool;
1438
+ if (selectedTool && (!editorSettings.sidebar || editorSettings.sidebar?.includes(selectedTool.toUpperCase()))) {
1439
+ query.set("category", selectedTool);
1440
+ }
1441
+ if (params.title) query.set("title", params.title);
1442
+ if (params.templateSize) query.set("templateSize", params.templateSize);
1443
+ const templatesFilters = params.templatesFilters || this.settings.templatesFilters;
1444
+ if (templatesFilters) query.set("templatesFilters", JSON.stringify(templatesFilters));
1445
+ this.tempOnClose = params.onClose || noop;
1446
+ this.tempOnExport = params.onExport || noop;
1447
+ this.tempExportType = params.exportType || "";
1448
+ this.tempExportSettings = params.exportSettings || null;
1449
+ const src = `${this.settings.domain}?${query.toString()}`;
1450
+ this.render(src);
1451
+ } else if (this.iframe.style.display === "none") {
1452
+ this.iframe.style.display = "block";
1453
+ } else {
1454
+ params.onError && params.onError("Iframe is already opened");
1455
+ }
1456
+ return this;
1457
+ }
1458
+ sendMessage(type, data) {
1459
+ this.iframe.contentWindow.postMessage({
1460
+ type,
1461
+ payload: data
1462
+ }, this.settings.domain);
1463
+ }
1464
+ attachMessageListener() {
1465
+ if (this.isMessageListenerAttached) return;
1466
+ window.addEventListener("message", this.messageListener);
1467
+ this.isMessageListenerAttached = true;
1468
+ }
1469
+ detachMessageListener() {
1470
+ if (!this.isMessageListenerAttached) return;
1471
+ window.removeEventListener("message", this.messageListener);
1472
+ this.isMessageListenerAttached = false;
1473
+ }
1474
+ handleMessage({ data, origin }) {
1475
+ if (!data || origin !== new URL(this.settings.domain).origin || data.instanceId !== this.settings.instanceId) return;
1476
+ const { type, payload } = data;
1477
+ this.log(`Picsart '${type}' event: `, payload);
1478
+ if (type === "ready") {
1479
+ this.handleEditorReady();
1480
+ return;
1481
+ }
1482
+ if (type === "error") {
1483
+ this.cbError(payload);
1484
+ } else if (type === "upload") {
1485
+ this.handleUpload(payload);
1486
+ } else if (type === "cancel") {
1487
+ this.close();
1488
+ } else {
1489
+ this.exportData(payload, this.onExportCb);
1490
+ }
1491
+ }
1492
+ handleEditorReady() {
1493
+ if (this.isEditorReady) return;
1494
+ if (!this.iframe) return;
1495
+ this.isEditorReady = true;
1496
+ this.log("Picsart editor ready");
1497
+ this.flushPendingData();
1498
+ }
1499
+ flushPendingData() {
1500
+ this.sendMessage("textSettingsData", fontsList_default);
1501
+ this.provideExportSettings();
1502
+ if (this.provideCanvasSizesData) this.provideCanvasSizes(this.provideCanvasSizesData);
1503
+ if (this.provideTemplatesData) this.provideTemplates(this.provideTemplatesData);
1504
+ if (this.provideStickersData) this.provideStickers(this.provideStickersData);
1505
+ if (this.provideShapesData) this.provideShapes(this.provideShapesData);
1506
+ if (this.provideStickerShapes) this.provideStickerShapes(this.provideShapesData);
1507
+ if (this.provideColorsData) this.provideColors(this.provideColorsData);
1508
+ if (this.providePhotosData) this.providePhotos(this.providePhotosData);
1509
+ if (this.provideLabelsData) this.provideLabels(this.provideLabelsData);
1510
+ if (this.provideFontsData) this.provideFonts(this.provideFontsData);
1511
+ if (this.provideTextsData) this.provideTexts(this.provideTextsData);
1512
+ if (this.provideImageData) this.provideImage(this.provideImageData);
1513
+ }
1514
+ async getFetch(url) {
1515
+ try {
1516
+ const res = await fetch(url);
1517
+ const resJson = await res.json();
1518
+ return resJson;
1519
+ } catch (e) {
1520
+ this.log("Get data error: ", e);
1521
+ }
1522
+ }
1523
+ async getCategoriesData(data) {
1524
+ const categoriesData = [];
1525
+ for (const item of data) {
1526
+ if (item.url) {
1527
+ const resJson = await this.getFetch(item.url);
1528
+ categoriesData.push({ ...resJson, _id: item.id || resJson._id });
1529
+ } else {
1530
+ categoriesData.push(item);
1531
+ }
1532
+ }
1533
+ return categoriesData;
1534
+ }
1535
+ async provideTemplates({ data, dataURL }) {
1536
+ if (this.settings.usePicsartInventory) {
1537
+ this.log(USE_PICSART_INVENTORY_MSG);
1538
+ return;
1539
+ }
1540
+ if (!this.isIframeLoaded()) {
1541
+ this.provideTemplatesData = { data, dataURL };
1542
+ return;
1543
+ }
1544
+ let templatesData = data;
1545
+ if (dataURL) {
1546
+ const res = await this.getFetch(dataURL);
1547
+ templatesData = await this.getCategoriesData(res);
1548
+ }
1549
+ const preparedData = templatesData.map((item) => ({
1550
+ ...item,
1551
+ ...item.previewURL && { preview_url: item.previewURL },
1552
+ ...item.previewWidth && { preview_width: item.previewWidth },
1553
+ ...item.previewHeight && { preview_height: item.previewHeight }
1554
+ }));
1555
+ this.sendMessage("templatesAdd", preparedData);
1556
+ return this;
1557
+ }
1558
+ async provideShapes({ data, dataURL }) {
1559
+ if (!this.isIframeLoaded()) {
1560
+ this.provideShapesData = data || dataURL ? { data, dataURL } : this.provideShapesData;
1561
+ return;
1562
+ }
1563
+ let items = data;
1564
+ if (dataURL) {
1565
+ const res = await this.getFetch(dataURL);
1566
+ items = await this.getCategoriesData(res);
1567
+ }
1568
+ const shapesDataItems = items.map((item) => ({
1569
+ ...item,
1570
+ preview_url: item.previewURL,
1571
+ url: item.shapeURL,
1572
+ meta_data: item.shapeData
1573
+ }));
1574
+ this.sendMessage("shapesAdd", [{ ...SHAPES_DATA, items: shapesDataItems }]);
1575
+ return this;
1576
+ }
1577
+ async provideStickerShapes() {
1578
+ const stickerShapesDataItems = defaultStickerShapes_default.map((item) => ({
1579
+ ...item,
1580
+ preview_url: item.previewURL,
1581
+ url: item.shapeURL,
1582
+ meta_data: item.shapeData
1583
+ }));
1584
+ this.sendMessage("stickerShapesAdd", stickerShapesDataItems);
1585
+ return this;
1586
+ }
1587
+ async provideTexts({ data, dataURL }) {
1588
+ if (this.settings.usePicsartInventory) {
1589
+ this.log(USE_PICSART_INVENTORY_MSG);
1590
+ return;
1591
+ }
1592
+ if (!this.isIframeLoaded()) {
1593
+ this.provideTextsData = { data, dataURL };
1594
+ return;
1595
+ }
1596
+ const textsData = dataURL ? await this.getFetch(dataURL) : data;
1597
+ if (textsData) {
1598
+ this.sendMessage("textsAdd", textsData.map((item) => ({
1599
+ ...item,
1600
+ font_size: item.fontSize || FONT_DEFAULTS.size,
1601
+ title: item.previewText || item.text,
1602
+ font_family: item.fontFamily || FONT_DEFAULTS.family
1603
+ })));
1604
+ }
1605
+ return this;
1606
+ }
1607
+ provideColors(data) {
1608
+ if (!this.isIframeLoaded()) {
1609
+ this.provideColorsData = data;
1610
+ return;
1611
+ }
1612
+ const colorsData = {};
1613
+ if (data.palette?.colors) {
1614
+ colorsData.palette = { ...data.palette, title: data.palette.title || "Popular Colors" };
1615
+ if (data.palette.colors.length > MAX_COLORS_AMOUNT) colorsData.palette.colors.length = MAX_COLORS_AMOUNT;
1616
+ }
1617
+ if (data.presets?.colors) {
1618
+ colorsData.presets = { ...data.presets, title: data.presets.title || "Presets" };
1619
+ if (data.presets.colors.length > MAX_COLORS_AMOUNT) colorsData.presets.colors.length = MAX_COLORS_AMOUNT;
1620
+ }
1621
+ this.sendMessage("colorsAdd", colorsData);
1622
+ return this;
1623
+ }
1624
+ async providePhotos({ data, dataURL }) {
1625
+ if (this.settings.usePicsartInventory) {
1626
+ this.log(USE_PICSART_INVENTORY_MSG);
1627
+ return;
1628
+ }
1629
+ if (!this.isIframeLoaded()) {
1630
+ this.providePhotosData = { data, dataURL };
1631
+ return;
1632
+ }
1633
+ const photosData = dataURL ? await this.getFetch(dataURL) : data;
1634
+ if (photosData) {
1635
+ const preparedData = photosData.map(({
1636
+ id,
1637
+ previewURL,
1638
+ imageURL,
1639
+ width,
1640
+ height
1641
+ }) => ({
1642
+ id,
1643
+ url: previewURL || imageURL,
1644
+ data_url: imageURL,
1645
+ width,
1646
+ height
1647
+ }));
1648
+ this.sendMessage("photosAdd", preparedData);
1649
+ }
1650
+ return this;
1651
+ }
1652
+ async provideStickers({ data, dataURL }) {
1653
+ if (this.settings.usePicsartInventory) {
1654
+ this.log(USE_PICSART_INVENTORY_MSG);
1655
+ return;
1656
+ }
1657
+ if (!this.isIframeLoaded()) {
1658
+ this.provideStickersData = { data, dataURL };
1659
+ return;
1660
+ }
1661
+ const stickersData = dataURL ? await this.getFetch(dataURL) : data;
1662
+ if (stickersData) {
1663
+ const preparedData = stickersData.map(({ id, previewURL, stickerURL }) => ({ id, url: previewURL || stickerURL, data_url: stickerURL }));
1664
+ this.sendMessage("stickersAdd", preparedData);
1665
+ }
1666
+ return this;
1667
+ }
1668
+ async provideFonts({ data, dataURL }) {
1669
+ if (this.settings.usePicsartInventory) {
1670
+ this.log(USE_PICSART_INVENTORY_MSG);
1671
+ return;
1672
+ }
1673
+ if (!this.isIframeLoaded()) {
1674
+ this.provideFontsData = { data, dataURL };
1675
+ return;
1676
+ }
1677
+ const fontsData = dataURL ? await this.getFetch(dataURL) : data;
1678
+ if (fontsData) {
1679
+ const msg = fontsData.map(({
1680
+ fontFamily,
1681
+ previewURL,
1682
+ url,
1683
+ licenseInfo
1684
+ }) => ({
1685
+ id: fontFamily,
1686
+ font_family: fontFamily,
1687
+ font_src: url,
1688
+ preview_url: previewURL,
1689
+ url: previewURL,
1690
+ ...licenseInfo && { license: licenseInfo },
1691
+ meta_data: {
1692
+ font_name: fontFamily
1693
+ }
1694
+ }));
1695
+ this.sendMessage("fontsAdd", msg);
1696
+ }
1697
+ return this;
1698
+ }
1699
+ async provideCanvasSizes({ data, dataURL }) {
1700
+ if (this.settings.usePicsartInventory) {
1701
+ this.log(USE_PICSART_INVENTORY_MSG);
1702
+ return;
1703
+ }
1704
+ if (!this.isIframeLoaded()) {
1705
+ this.provideCanvasSizesData = { data, dataURL };
1706
+ return;
1707
+ }
1708
+ const canvasSizesData = dataURL ? await this.getFetch(dataURL) : data;
1709
+ if (canvasSizesData) this.sendMessage("canvasSizesAdd", canvasSizesData);
1710
+ return this;
1711
+ }
1712
+ provideLabels(data) {
1713
+ if (!this.isIframeLoaded()) {
1714
+ this.provideLabelsData = data;
1715
+ return;
1716
+ }
1717
+ if (data) this.sendMessage("labelsAdd", data);
1718
+ return this;
1719
+ }
1720
+ provideExportSettings() {
1721
+ const exportSettings = merge__default.default(DEFAULT_EXPORT_SETTINGS, this.settings.exportSettings, this.tempExportSettings);
1722
+ this.sendMessage("exportSettings", exportSettings);
1723
+ }
1724
+ };
1725
+ if (typeof window !== "undefined") {
1726
+ window[PICSART_PROP_NAME] = window[PICSART_PROP_NAME] || Picsart;
1727
+ }
1728
+ var Picsart_default = Picsart;
1729
+ function readBundledEnv(key) {
1730
+ const proc = globalThis.process;
1731
+ return proc?.env?.[key];
1732
+ }
1733
+ function resolveEditorDomain(explicit) {
1734
+ if (explicit) return explicit;
1735
+ const fromEnv = readBundledEnv("NEXT_PUBLIC_PICSART_EDITOR_DOMAIN") || readBundledEnv("PICSART_EDITOR_DOMAIN") || readBundledEnv("EDITOR_DOMAIN");
1736
+ return fromEnv || "";
1737
+ }
1738
+ function resolveParentDomain(explicit) {
1739
+ if (explicit) return explicit;
1740
+ return readBundledEnv("NEXT_PUBLIC_PICSART_PARENT_DOMAIN") || readBundledEnv("VITE_PICSART_PARENT_DOMAIN") || readBundledEnv("PICSART_PARENT_DOMAIN") || "";
1741
+ }
1742
+ var PhotoEditor = react.forwardRef(
1743
+ function PhotoEditor2({
1744
+ apiKey,
1745
+ customerId,
1746
+ propertyId,
1747
+ editorDomain,
1748
+ parentDomain: parentDomainProp,
1749
+ className,
1750
+ style,
1751
+ title,
1752
+ imageUrl,
1753
+ cms = true,
1754
+ debug = false,
1755
+ onExport,
1756
+ onError,
1757
+ onClose,
1758
+ onOpen,
1759
+ picsartSettings,
1760
+ openParams
1761
+ }, ref) {
1762
+ const reactId = react.useId().replace(/:/g, "");
1763
+ const containerId = react.useMemo(() => `picsart-react-${reactId}`, [reactId]);
1764
+ const instanceRef = react.useRef(null);
1765
+ const domain = react.useMemo(() => resolveEditorDomain(editorDomain), [editorDomain]);
1766
+ const parentDomain = react.useMemo(
1767
+ () => resolveParentDomain(parentDomainProp),
1768
+ [parentDomainProp]
1769
+ );
1770
+ react.useImperativeHandle(
1771
+ ref,
1772
+ () => ({
1773
+ get picsart() {
1774
+ return instanceRef.current;
1775
+ },
1776
+ open: (params) => instanceRef.current.open(params),
1777
+ close: () => instanceRef.current.close()
1778
+ }),
1779
+ []
1780
+ );
1781
+ react.useEffect(() => {
1782
+ if (!domain) {
1783
+ console.error(
1784
+ "PhotoEditor: set `editorDomain` or env NEXT_PUBLIC_PICSART_EDITOR_DOMAIN / PICSART_EDITOR_DOMAIN / EDITOR_DOMAIN."
1785
+ );
1786
+ return void 0;
1787
+ }
1788
+ if (typeof window !== "undefined") {
1789
+ const insecureLocal = window.location.protocol === "http:" && (window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1");
1790
+ if (insecureLocal && !parentDomain) {
1791
+ console.warn(
1792
+ "[PhotoEditor] You are on http://localhost without `parentDomain`. The editor SDK often rejects this for postMessage / auth. Use an HTTPS tunnel (ngrok, Cloudflare Tunnel, \u2026) and set `parentDomain` or `VITE_PICSART_PARENT_DOMAIN` / `NEXT_PUBLIC_PICSART_PARENT_DOMAIN` to that https origin."
1793
+ );
1794
+ }
1795
+ }
1796
+ const instance = new Picsart_default({
1797
+ ...picsartSettings || {},
1798
+ containerId,
1799
+ domain,
1800
+ apiKey,
1801
+ customerId,
1802
+ ...parentDomain ? { parentDomain } : {},
1803
+ ...propertyId != null && propertyId !== "" ? { propertyId } : {},
1804
+ cms,
1805
+ debug
1806
+ });
1807
+ instanceRef.current = instance;
1808
+ if (onExport) instance.onExport(onExport);
1809
+ if (onError) instance.onError(onError);
1810
+ if (onClose) instance.onClose(onClose);
1811
+ if (onOpen) instance.onOpen(onOpen);
1812
+ instance.open({
1813
+ ...title ? { title } : {},
1814
+ ...imageUrl ? { imageUrl } : {},
1815
+ ...openParams || {}
1816
+ });
1817
+ return () => {
1818
+ instance.close();
1819
+ instanceRef.current = null;
1820
+ };
1821
+ }, [
1822
+ apiKey,
1823
+ customerId,
1824
+ propertyId,
1825
+ domain,
1826
+ parentDomain,
1827
+ containerId,
1828
+ cms,
1829
+ debug,
1830
+ JSON.stringify(picsartSettings || {}),
1831
+ JSON.stringify(openParams || {}),
1832
+ imageUrl,
1833
+ title
1834
+ ]);
1835
+ return /* @__PURE__ */ jsxRuntime.jsx(
1836
+ "div",
1837
+ {
1838
+ id: containerId,
1839
+ className,
1840
+ style: { width: "100%", height: "100%", minHeight: 480, ...style }
1841
+ }
1842
+ );
1843
+ }
1844
+ );
1845
+ var PhotoEditor_default = PhotoEditor;
1846
+
1847
+ exports.PhotoEditor = PhotoEditor_default;
1848
+ exports.Picsart = Picsart_default;
1849
+ //# sourceMappingURL=index.js.map
1850
+ //# sourceMappingURL=index.js.map