@emailmaker/emailmaker 1.1.72 → 1.1.75

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 (54) hide show
  1. package/CHANGELOG.md +376 -0
  2. package/README.md +37 -1
  3. package/{emailmaker-core.bd3c8144.js → emailmaker-core.705f9cde.js} +6 -6
  4. package/emailmaker-esm.js +4 -4
  5. package/{emailmaker-po.bd3c8144.js → emailmaker-po.705f9cde.js} +1 -1
  6. package/emailmaker.d.ts +4 -0
  7. package/emailmaker.js +3 -3
  8. package/iframe/js/amp.CcyAlXr8.js +1 -0
  9. package/iframe/js/iframe-eblock.js +1 -1
  10. package/iframe/js/iframe.js +1 -1
  11. package/iframe/js/rules.B-wCbIo7.js +1 -1
  12. package/package.json +30 -9
  13. package/static/core/{84e7cbac.js → 1f9bc4c3.js} +3 -3
  14. package/static/core/{ce8ca64c.js → 23d0be47.js} +3 -3
  15. package/static/core/{893bd50e.js → 3af12861.js} +17559 -15293
  16. package/static/core/{fab6e3c1.js → 4efbc972.js} +5 -5
  17. package/static/core/{34b3c6f9.js → 7093b78e.js} +53 -53
  18. package/static/core/{98529d8d2.js → 7af547562.js} +1304 -1240
  19. package/static/core/{dda6d713.js → 8e559366.js} +4 -4
  20. package/static/core/aaa151dc.js +2129 -0
  21. package/static/core/{ec8d567d2.js → baee7d8b2.js} +864 -819
  22. package/static/core/{ab6da7f5.js → d6093d8d.js} +7 -7
  23. package/static/core/{8815169a.js → e430193d.js} +5 -5
  24. package/static/core/{dd625043.js → e44c2cac.js} +6 -6
  25. package/static/core/{5da8610f.js → fb14792c.js} +1512 -1260
  26. package/static/umd-runtime/ui-kit.js +1171 -1103
  27. package/ui-kit/index.js +1541 -1469
  28. package/favicon-b.ico +0 -0
  29. package/favicon.ico +0 -0
  30. package/fonts/SegoeUI-Bold.woff2 +0 -0
  31. package/fonts/SegoeUI-Semibold.woff2 +0 -0
  32. package/fonts/SegoeUI.woff2 +0 -0
  33. package/iframe/js/amp.D4LpeCG3.js +0 -1
  34. package/js/amplitude.min.js +0 -10859
  35. package/js/sourcebuster.min.js +0 -672
  36. package/manifest.json +0 -17
  37. package/npm-publish.manifest.json +0 -65
  38. package/static/core/e84eccff.js +0 -2122
  39. package/static/media/image-editor/images/samples/large_sample.jpg +0 -0
  40. package/static/media/image-editor/images/samples/sample1.jpg +0 -0
  41. package/static/media/image-editor/images/samples/sample1_thumbnail.jpg +0 -0
  42. package/static/media/image-editor/images/samples/sample2.jpg +0 -0
  43. package/static/media/image-editor/images/samples/sample2_thumbnail.jpg +0 -0
  44. package/static/media/image-editor/images/samples/sample3.jpg +0 -0
  45. package/static/media/image-editor/images/samples/sample3_thumbnail.jpg +0 -0
  46. package/static/media/image-editor/images/samples/sample4.json +0 -871
  47. package/static/media/image-editor/images/samples/sample4_preview.jpg +0 -0
  48. package/test-font.otf +0 -0
  49. package/test-font.ttf +0 -0
  50. package/test-font.woff2 +0 -0
  51. package/tsconfig.json +0 -14
  52. package/two_step_headless_plugin.html +0 -558
  53. /package/iframe/{iframe-eblock.bd3c8144.html → iframe-eblock.705f9cde.html} +0 -0
  54. /package/iframe/{iframe.bd3c8144.html → iframe.705f9cde.html} +0 -0
@@ -0,0 +1,2129 @@
1
+ (function(){try{if(typeof document<"u"){var o=document.createElement("style");o.setAttribute("data-emailmaker","true"),o.appendChild(document.createTextNode(".blocks-app .image-preview{text-align:center;min-height:100px;position:relative}.blocks-app .image-preview .image-editor-modal{border:1px solid red}.blocks-app .image-preview__edit-button{position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-preview img{border:1px solid var(--em-colorBorder);border-radius:6px;max-width:100%;max-height:500px}.blocks-app .image-editor-modal .ant-modal-container{flex-direction:column;min-height:100vh;display:flex;border-radius:0!important}.blocks-app .image-editor-modal .ant-modal-body{flex-grow:1;display:flex}.blocks-app .image-editor-modal .ant-modal-body #pixie-editor{flex-grow:1;height:calc(100vh - 70px);min-height:calc(100vh - 70px);overflow:hidden}.blocks-app .image-editor-modal .pi .text-on-primary{background:var(--em-colorPrimary);border-color:var(--em-colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--em-colorPrimaryHover);border-color:var(--em-colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--em-borderRadius) * 1px)}.blocks-app .image-editor-modal .pi .shadow-xl{box-shadow:none}.blocks-app .image-editor-modal .w-\\[4ch\\].text-sm.text-center{width:5ch}.blocks-app .image-editor-modal .pi .border-white{border-color:var(--em-colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--em-colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--em-colorWhite)}.blocks-app .serach-results .ant-row{align-items:center}.blocks-app .serach-results .blocks-search__divider-wrapper{margin-top:12px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{border-top:1px solid var(--em-colorBorderSecondary);background:0 0;width:100%;height:1px;min-height:0;margin:0;position:static}.blocks-app .slideshow-container{width:524px;height:350px;margin:auto;position:relative;overflow:hidden}.blocks-app .slideshow-image{opacity:0;width:100%;height:100%;position:absolute;top:0;left:0}.blocks-app .image-ai .slideshow-image{width:auto;height:auto}.blocks-app .image-ai__image-item{text-align:center;border-radius:6px;justify-content:center;align-items:center;min-height:100px;display:flex;position:relative}.blocks-app .image-ai__image-item .buttons{justify-content:space-between;display:flex;position:absolute;bottom:10px;left:50%;transform:translate(-50%)}.blocks-app .image-ai .text-area-input-hybrid{border:none;outline:none;min-height:0;padding:0 0 0 1px}.blocks-app .image-ai .text-area-input-hybrid textarea{height:32px;min-height:32px;padding:3px 11px;line-height:26px}.blocks-app .image-ai__loading{justify-content:center;align-items:center;min-height:150px;display:flex}.blocks-app .image-ai__loading .spin{flex-direction:column;justify-content:center;align-items:center;height:150px;display:flex}.blocks-app .image-ai__loading .status{margin:3px 0 0}.blocks-app .image-ai__preview{border-radius:6px;margin-top:24px;overflow:hidden}.blocks-app .image-ai__preview .image-ai__image-item img{border-radius:calc(var(--em-borderRadius) * 1px);object-fit:contain;max-height:100%;transition:height 1s;top:50%;left:50%;overflow:hidden;transform:translate(-50%,-50%)}.blocks-app .image-ai .small{width:302px;height:202px}.blocks-app .image-ai .large{width:524px;height:350px}.blocks-app .image-ai .image-ai__row{padding:0 2px}.blocks-app .image-ai .image-ai__input-affix-wrapper{border-style:solid;border-width:calc(var(--em-borderWidth) * 1px);border-color:var(--em-colorFillSecondaryDarken);border-radius:calc(var(--em-borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--em-borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--em-colorPrimaryBorder)}.blocks-app .image-ai .image-ai__textarea{font-size:16px}.blocks-app .image-ai .image-ai__input-icon{font-size:16px;top:0;right:0}.dark .blocks-app .image-ai .image-ai__preview .image-ai__image-item img{background:#2b2b2b;border:1px solid #434343}.dark .blocks-app .image-ai .ant-btn{background:#1f1f1f}.dark .blocks-app .image-ai .ant-btn:hover{color:var(--em-colorPrimary)}.blocks-app .stock-tab img{border-radius:0;max-width:none;max-height:none}.blocks-app .stock-tab .stock-search-input{padding:0 2px}.blocks-app .stock-tab .my-masonry-grid{text-align:center;width:auto;display:flex}.blocks-app .stock-tab .my-masonry-grid_column{background-clip:padding-box}.blocks-app .stock-tab .list-item{cursor:pointer;background:#f0f2f5;border:1px solid #f0f2f5;border-radius:6px;min-height:100px;max-height:100px;margin-bottom:20px;transition:all .3s;display:inline-block;position:relative;overflow:hidden}.blocks-app .stock-tab .list-item .overlay-image{opacity:0;background-size:cover;width:110px;height:40px;transition:opacity .5s;position:absolute;bottom:10px;right:10px}.blocks-app .stock-tab .list-item .ant-spin{color:#f0f2f5;font-size:20px;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.blocks-app .stock-tab .list-item img{object-fit:cover;opacity:0;border-radius:6px;height:auto;transition:opacity .5s ease-in-out;display:block}.blocks-app .stock-tab .list-item.loaded{border:1px solid #d9d9d9;max-height:1000px}.blocks-app .stock-tab .list-item.loaded img{opacity:1;height:100%}.blocks-app .stock-tab .list-item.loaded .loaded-image{opacity:.5}.blocks-app .stock-tab .list-item:hover{box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #00000017}.blocks-app .stock-tab .list-item:hover p.creator-info,.blocks-app .stock-tab .list-item:hover .overlay-image{opacity:1}.blocks-app .stock-tab .list-item p.creator-info{color:#fff;opacity:0;background-color:#00000080;border-radius:0 0 6px;margin:0;padding:5px;font-size:10px;line-height:1.2;position:absolute;bottom:0;right:0}.blocks-app .stock-tab .list-item p.creator-info:hover a{color:#fff;text-decoration:underline}.blocks-app .stock-tab .list-item p.creator-info a{color:#fff;text-decoration:none}.blocks-app .stock-color-filter{display:flex}.blocks-app .stock-color-filter label{border-width:1px;width:24px;height:24px;margin:4px;padding:0;font-size:0;border-radius:6px!important}.blocks-app .stock-color-filter label.all-colors{background-image:linear-gradient(135deg,red,#ff7f00,#ff0,#0f0,#00f,#8b00ff)}.blocks-app .stock-color-filter label.black-color{background:#222}.blocks-app .stock-color-filter label.bw-color{background-image:linear-gradient(135deg,#222 50%,#fff 50%)}.blocks-app .stock-color-filter label.white-color{background:#fff}.blocks-app .stock-color-filter label.orange-color{background:#fa8c16}.blocks-app .stock-color-filter label.red-color{background:#f5222d}.blocks-app .stock-color-filter label.purple-color{background:#722ed1}.blocks-app .stock-color-filter label.magenta-color{background:#eb2f96}.blocks-app .stock-color-filter label.green-color{background:#52c41a}.blocks-app .stock-color-filter label.teal-color{background:#43c3c3}.blocks-app .stock-color-filter label.blue-color{background:#1677ff}.blocks-app .stock-color-filter .ant-radio-button-wrapper:not(:first-child):before{display:none}.blocks-app .serach-results{padding-top:6px}.blocks-app .serach-results .stock-search-input{width:322px;padding:0 2px}.blocks-app .serach-results .blocks-search__divider-wrapper{width:calc(100% + 48px);margin-top:12px;margin-left:-24px;margin-right:-24px;position:relative}.blocks-app .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{pointer-events:none;border-top:1px solid var(--em-colorBorderSecondary);background:linear-gradient(180deg, var(--em-colorBgContainerDisabled), transparent 40%);border-bottom:none;width:100%;height:20px;min-height:20px;margin:0;position:relative;bottom:auto;left:auto;right:auto}.dark .blocks-app .image-center .stock-tab .serach-results .blocks-search__divider-wrapper .ant-divider-horizontal{background:linear-gradient(180deg, var(--em-colorBgBase), transparent 40%)}.dark .blocks-app .stock-tab .list-item{background:#2b2b2b;border:1px solid #2b2b2b}.dark .blocks-app .stock-tab .list-item.loaded{border:1px solid #434343}.blocks-app .image-center .image-center-image-preview{justify-content:center;align-items:center;display:flex}.blocks-app .image-center .ant-divider-horizontal{pointer-events:none;z-index:1;background:linear-gradient(180deg, var(--em-colorBgContainerDisabled), transparent 40%);width:calc(100% + 48px);height:20px;margin:24px -24px 0;position:absolute;bottom:-19px}.dark .blocks-app .image-center .ant-divider-horizontal{background:linear-gradient(180deg, var(--em-colorBgBase), transparent 40%)}.blocks-app .image-center .ant-divider-horizontal.ant-divider-with-text{background:0 0;width:calc(100% + 38px);margin:0 -24px 20px;position:relative;top:0}.blocks-app .image-center img{border-radius:4px;max-width:524px;max-height:352px}.blocks-app .image-center .image-size{justify-content:center;margin-top:6px;font-size:14px;line-height:22px;display:flex}.blocks-app .image-center .ant-upload.ant-upload-drag{border-radius:6px}.blocks-app .image-center .ant-modal-body .stock-search-input{margin-bottom:0}.blocks-app .image-center .ant-modal-body .serach-results .stock-search-input{margin-bottom:10px}.blocks-app .image-center .ant-modal-body .ant-form:not(.serach-results) .ant-form-item:last-child{margin-bottom:0}.blocks-app .image-center .ant-modal-body .ant-tabs{transition:all .7s cubic-bezier(.075,.82,.165,1)}.blocks-app .image-center .ant-modal-body .ant-tabs .ant-tabs-content-holder{overflow-y:clip}.blocks-app .ant-modal{transition:width .7s ease-in-out}")),document.head.appendChild(o)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
+ __emailmaker__.define("static/core/aaa151dc.js", [
3
+ "require",
4
+ "exports",
5
+ "module",
6
+ "static/core/7df48ae1.js",
7
+ "static/core/fb14792c.js",
8
+ "static/core/1f9bc4c3.js",
9
+ "static/core/e430193d.js",
10
+ "static/core/7af547562.js",
11
+ "static/core/baee7d8b2.js",
12
+ "static/core/4c113afa.js",
13
+ "static/core/fc878f95.js",
14
+ "react",
15
+ "react/jsx-runtime"
16
+ ], function(ue, yt, mn) {
17
+ const Ze = ue("./7df48ae1.js"), u = ue("./fb14792c.js"), Q = ue("./1f9bc4c3.js"), ne = ue("./e430193d.js"), f = ue("./7af547562.js"), B = ue("./baee7d8b2.js"), vt = ue("./4c113afa.js"), Xe = ue("./fc878f95.js");
18
+ let n = ue("react");
19
+ n = Ze.__toESM(n);
20
+ let r = ue("react/jsx-runtime");
21
+ var Ct = Ze.__toESM(ne.require_prop_types());
22
+ function bt(t, e) {
23
+ return { [t]: {
24
+ Filter: e("Filter"),
25
+ filter: e("filter"),
26
+ Resize: e("Resize"),
27
+ resize: e("resize"),
28
+ Crop: e("Crop"),
29
+ Width: e("Width"),
30
+ width: e("width"),
31
+ Height: e("Height"),
32
+ height: e("height"),
33
+ "Background color": e("Background color"),
34
+ Cancel: e("Cancel"),
35
+ Create: e("Create"),
36
+ Objects: e("Objects"),
37
+ Quality: e("Quality"),
38
+ Save: e("Save"),
39
+ "Loading Canvas": e("Loading Canvas"),
40
+ "Loading Image": e("Loading Image"),
41
+ "Loading State": e("Loading State"),
42
+ "Processing Image": e("Processing Image"),
43
+ Close: e("Close"),
44
+ Apply: e("Apply"),
45
+ Font: e("Font"),
46
+ Color: e("Color"),
47
+ Background: e("Background"),
48
+ Image: e("Image"),
49
+ Opacity: e("Opacity"),
50
+ Outline: e("Outline"),
51
+ Shadow: e("Shadow"),
52
+ Gradient: e("Gradient"),
53
+ Texture: e("Texture"),
54
+ "Replace Image": e("Replace Image"),
55
+ "Outline Color": e("Outline Color"),
56
+ "Shadow Color": e("Shadow Color"),
57
+ "Font Size": e("Font Size"),
58
+ Radius: e("Radius"),
59
+ "Brush Color": e("Brush Color"),
60
+ "Brush Type": e("Brush Type"),
61
+ "Brush Size": e("Brush Size"),
62
+ History: e("History"),
63
+ "Maintain aspect ratio": e("Maintain aspect ratio"),
64
+ "New Text": e("New Text"),
65
+ Size: e("Size"),
66
+ Draw: e("Draw"),
67
+ Text: e("Text"),
68
+ Stickers: e("Stickers"),
69
+ Frame: e("Frame"),
70
+ Shapes: e("Shapes"),
71
+ Corners: e("Corners"),
72
+ corners: e("corners"),
73
+ Done: e("Done"),
74
+ "Applied Filters": e("Applied Filters"),
75
+ "Resized Image": e("Resized Image"),
76
+ "Cropped Image": e("Cropped Image"),
77
+ "Added Drawing": e("Added Drawing"),
78
+ "Added Text": e("Added Text"),
79
+ "Added Shape": e("Added Shape"),
80
+ "Added Sticker": e("Added Sticker"),
81
+ "Added Frame": e("Added Frame"),
82
+ "Merged Objects": e("Merged Objects"),
83
+ "Rounded Corner": e("Rounded Corner"),
84
+ "Replaced Background Image": e("Replaced Background Image"),
85
+ "Added Image": e("Added Image"),
86
+ Initial: e("Initial"),
87
+ "Loaded State": e("Loaded State"),
88
+ "Changed Style": e("Changed Style"),
89
+ "Deleted object": e("Deleted object"),
90
+ Merge: e("Merge"),
91
+ Emoticons: e("Emoticons"),
92
+ Doodles: e("Doodles"),
93
+ Landmarks: e("Landmarks"),
94
+ Bubbles: e("Bubbles"),
95
+ Transportation: e("Transportation"),
96
+ Beach: e("Beach"),
97
+ PencilBrush: e("PencilBrush"),
98
+ SprayBrush: e("SprayBrush"),
99
+ CircleBrush: e("CircleBrush"),
100
+ DiamondBrush: e("DiamondBrush"),
101
+ VLineBrush: e("VLineBrush"),
102
+ HLineBrush: e("HLineBrush"),
103
+ SquareBrush: e("SquareBrush"),
104
+ Square: e("Square"),
105
+ square: e("square")
106
+ } };
107
+ }
108
+ function Je(t, e = "application/octet-stream") {
109
+ let s = t.trim(), i = e?.trim() || "application/octet-stream";
110
+ const o = s.indexOf(",");
111
+ if (s.startsWith("data:") && o >= 0) {
112
+ const g = s.slice(5, o).split(";")[0]?.trim();
113
+ g && (i = g), s = s.slice(o + 1);
114
+ }
115
+ const l = s.replace(/\s/g, ""), m = atob(l), p = new Uint8Array(m.length);
116
+ for (let g = 0; g < m.length; g++) p[g] = m.charCodeAt(g);
117
+ return new Blob([p], { type: i });
118
+ }
119
+ var wt = "static/media/image-editor", At = { text: {
120
+ replaceDefaultItems: !0,
121
+ defaultText: "Handwriting",
122
+ items: [
123
+ {
124
+ family: "Inter",
125
+ src: "fonts/inter-v20-cyrillic_latin-regular.woff2"
126
+ },
127
+ {
128
+ family: "Commissioner",
129
+ src: "fonts/commissioner-v24-cyrillic_latin-regular.woff2"
130
+ },
131
+ {
132
+ family: "Montserrat Light",
133
+ src: "fonts/Montserrat-Light.woff2"
134
+ },
135
+ {
136
+ family: "Montserrat Regular",
137
+ src: "fonts/Montserrat-Regular.woff2"
138
+ },
139
+ {
140
+ family: "Montserrat Bold",
141
+ src: "fonts/Montserrat-Bold.woff2"
142
+ },
143
+ {
144
+ family: "Montserrat Black",
145
+ src: "fonts/Montserrat-Black.woff2"
146
+ },
147
+ {
148
+ family: "Roboto Light",
149
+ src: "fonts/Roboto-Light.woff2"
150
+ },
151
+ {
152
+ family: "Roboto Regular",
153
+ src: "fonts/Roboto-Regular.woff2"
154
+ },
155
+ {
156
+ family: "Roboto Bold",
157
+ src: "fonts/Roboto-Bold.woff2"
158
+ },
159
+ {
160
+ family: "Roboto Black",
161
+ src: "fonts/Roboto-Black.woff2"
162
+ },
163
+ {
164
+ family: "Lato Light",
165
+ src: "fonts/Lato-Light.woff2"
166
+ },
167
+ {
168
+ family: "Lato Regular",
169
+ src: "fonts/Lato-Regular.woff2"
170
+ },
171
+ {
172
+ family: "Lato Bold",
173
+ src: "fonts/Lato-Bold.woff2"
174
+ },
175
+ {
176
+ family: "Lato Black",
177
+ src: "fonts/Lato-Black.woff2"
178
+ },
179
+ {
180
+ family: "Rubik Light",
181
+ src: "fonts/Rubik-Light.woff2"
182
+ },
183
+ {
184
+ family: "Rubik Regular",
185
+ src: "fonts/Rubik-Regular.woff2"
186
+ },
187
+ {
188
+ family: "Rubik Bold",
189
+ src: "fonts/Rubik-Bold.woff2"
190
+ },
191
+ {
192
+ family: "Rubik Black",
193
+ src: "fonts/Rubik-Black.woff2"
194
+ },
195
+ {
196
+ family: "Bebas Neue Light",
197
+ src: "fonts/BebasNeueLight.woff2"
198
+ },
199
+ {
200
+ family: "Bebas Neue Regular",
201
+ src: "fonts/BebasNeueRegular.woff2"
202
+ },
203
+ {
204
+ family: "Bebas Neue Book",
205
+ src: "fonts/BebasNeueBook.woff2"
206
+ },
207
+ {
208
+ family: "Bebas Neue Bold",
209
+ src: "fonts/BebasNeueBold.woff2"
210
+ },
211
+ {
212
+ family: "Fira Sans",
213
+ src: "fonts/fira-sans-v11-latin-ext_latin_cyrillic-regular.woff2"
214
+ },
215
+ {
216
+ family: "Lobster",
217
+ src: "fonts/Lobster.woff2"
218
+ },
219
+ {
220
+ family: "Pacifico",
221
+ src: "fonts/pacifico-v23-cyrillic_latin-regular.woff2"
222
+ },
223
+ {
224
+ family: "Playfair Display",
225
+ src: "fonts/playfair-display-v40-cyrillic_latin-regular.woff2"
226
+ },
227
+ {
228
+ family: "Oswald",
229
+ src: "fonts/oswald-v57-cyrillic_latin-regular.woff2"
230
+ },
231
+ {
232
+ family: "Caveat",
233
+ src: "fonts/caveat-v23-cyrillic_latin-regular.woff2"
234
+ }
235
+ ]
236
+ } };
237
+ function It(t, e, s, i) {
238
+ if (e.type === "linear") {
239
+ const o = t.createLinearGradient(s + e.coords.x1, i + e.coords.y1, s + e.coords.x2, i + e.coords.y2);
240
+ return e.colorStops.forEach((l) => o.addColorStop(l.offset, l.color)), o;
241
+ }
242
+ if (e.type === "radial") {
243
+ const o = t.createRadialGradient(s + e.coords.x1, i + e.coords.y1, e.coords.r1 ?? 0, s + e.coords.x2, i + e.coords.y2, e.coords.r2 ?? 0);
244
+ return e.colorStops.forEach((l) => o.addColorStop(l.offset, l.color)), o;
245
+ }
246
+ throw new Error("Unknown gradient type");
247
+ }
248
+ function xt(t) {
249
+ if (!this.backgroundColor) return;
250
+ const e = this._getNonTransformedDimensions(), s = -e.x / 2, i = -e.y / 2, o = e.x, l = e.y, m = this.backgroundColor;
251
+ if (typeof m == "string" || m instanceof CanvasGradient || m instanceof CanvasPattern) t.fillStyle = m, t.fillRect(s, i, o, l);
252
+ else if (typeof m == "object" && "type" in m && (m.type === "linear" || m.type === "radial")) t.fillStyle = It(t, m, s, i), t.fillRect(s, i, o, l);
253
+ else if ("source" in m && (m.source instanceof HTMLImageElement || m.source instanceof HTMLCanvasElement)) if (m.repeat) {
254
+ const p = t.createPattern(m.source, m.repeat);
255
+ p && (t.fillStyle = p, t.fillRect(s, i, o, l));
256
+ } else t.drawImage(m.source, s, i, o, l);
257
+ this._removeShadow(t);
258
+ }
259
+ function St(t) {
260
+ t?.fabric && t.fabric.on("object:added", (e) => {
261
+ const s = e.target;
262
+ s && s.name === "text" && (s._renderBackground = xt);
263
+ });
264
+ }
265
+ function Rt(t, e) {
266
+ if (t === "json") return new Blob([e], { type: "application/json" });
267
+ if (t === "svg") return new Blob([e], { type: "image/svg+xml" });
268
+ const s = `image/${t}`;
269
+ return Je(e.replace(/data:image\/([a-z]*)?;base64,/, ""), s);
270
+ }
271
+ var kt = ({ currentImageLink: t, prefetchedBlob: e, resolveImageBlob: s, onSave: i, uploadImageResultIsLoading: o }) => {
272
+ const l = B.useCookieManager(), [m, p] = (0, n.useState)(), [g, x] = (0, n.useState)(), { __: h } = f.useI18n();
273
+ let v = u.useDispatch();
274
+ const A = u.useStore(), k = u.useAppConfig(), b = u.useSelector(u.selectedCurrentUser), O = u.useSelector(Q.selectSecondModal), w = u.useSelector(u.selectProject), U = (0, n.useMemo)(() => {
275
+ if (!k?.icons) return;
276
+ const E = {};
277
+ for (const [z, j] of Object.entries(k.icons)) typeof j == "string" && (E[z] = B.sanitizeHtml(j));
278
+ return Object.keys(E).length > 0 ? E : void 0;
279
+ }, [k?.icons]), L = (0, n.useRef)(!1), [M, V] = (0, n.useState)(), P = u.useEventEmitter(u.events.FILE_PROXY_EVENT_ID);
280
+ (0, n.useEffect)(() => {
281
+ let E = !1;
282
+ return (async () => {
283
+ const j = t;
284
+ if (!j && !e) return;
285
+ let S = e;
286
+ if (!S && j) try {
287
+ typeof s == "function" ? S = await s(j) : S = await (await fetch(j)).blob();
288
+ } catch {
289
+ if (E) return;
290
+ if (S = await P.fire({
291
+ url: j,
292
+ project: w
293
+ }).filter((N) => N instanceof Blob)[0], !S) {
294
+ const N = l.get(u.APP_COOKIES.em_token) || await u.di.getInstance(A, Q.TOKEN_ID);
295
+ S = await (await fetch(`https://app.emailmaker.ru/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(j)}`, { headers: { authorization: `Bearer ${N}` } })).blob();
296
+ }
297
+ }
298
+ if (E || !S) return;
299
+ const I = new FileReader();
300
+ I.onload = () => {
301
+ if (E) return;
302
+ const N = I.result;
303
+ typeof N == "string" && (p(N), x(S.type), M?.tools.import.openBackgroundImage(N));
304
+ }, I.onerror = () => {}, I.readAsDataURL(S);
305
+ })().catch((j) => {}), () => {
306
+ E = !0;
307
+ };
308
+ }, [
309
+ t,
310
+ e,
311
+ s,
312
+ l,
313
+ M,
314
+ P,
315
+ w,
316
+ A
317
+ ]);
318
+ const T = (0, n.useCallback)(() => {
319
+ p(null), x(null), v(Q.closeSecondModal()), v(Q.closeModal(u.MODALS.UPLOAD_IMAGE_MODAL));
320
+ }, [v]), X = (0, n.useRef)();
321
+ X.current = async function(E, z, j) {
322
+ try {
323
+ const S = Rt(j, E);
324
+ i && await i(new File([S], z, {
325
+ lastModified: Date.now(),
326
+ type: S.type
327
+ }));
328
+ } catch (S) {
329
+ throw S;
330
+ }
331
+ };
332
+ const _ = (0, n.useCallback)((E) => {
333
+ if (E && !(L.current && M)) {
334
+ L.current = !0;
335
+ const z = b.locale ? b.locale.replace("_", "-") : "ru-RU", j = b.theme === "system" ? matchMedia("(prefers-color-scheme: dark)").matches ? u.DARK : u.LIGHT : b.theme;
336
+ vt.Tf.init({
337
+ selector: "#pixie-editor",
338
+ baseUrl: f.getBundledHostAssetUrl(wt),
339
+ image: m,
340
+ activeLanguage: z,
341
+ languages: bt(z, h),
342
+ tools: At,
343
+ ui: {
344
+ menubar: {
345
+ replaceDefaultItems: !0,
346
+ items: [
347
+ {
348
+ type: "undoWidget",
349
+ align: "left"
350
+ },
351
+ {
352
+ type: "zoomWidget",
353
+ align: "center",
354
+ desktopOnly: !0
355
+ },
356
+ {
357
+ type: "button",
358
+ icon: (0, r.jsx)(f.EmIcons, {
359
+ icon: "HistoryOutlined",
360
+ configIcons: U,
361
+ style: { fontSize: 20 }
362
+ }),
363
+ align: "right",
364
+ desktopOnly: !0,
365
+ action: (S) => {
366
+ S.togglePanel("history");
367
+ }
368
+ },
369
+ {
370
+ type: "button",
371
+ icon: (0, r.jsx)(f.EmIcons, {
372
+ icon: "CloseOutlined",
373
+ configIcons: U,
374
+ style: { fontSize: 20 }
375
+ }),
376
+ align: "right",
377
+ desktopOnly: !0,
378
+ action: () => T()
379
+ }
380
+ ]
381
+ },
382
+ nav: { position: "top" },
383
+ activeTheme: j,
384
+ mode: "inline",
385
+ forceOverlayModeOnMobile: !1
386
+ },
387
+ onSave: async function(S, I, N) {
388
+ try {
389
+ await X.current(S, I, N);
390
+ } catch {}
391
+ }
392
+ }).then((S) => {
393
+ St(S), V(S);
394
+ }).catch((S) => {});
395
+ }
396
+ }, [
397
+ b.theme,
398
+ m,
399
+ M,
400
+ V,
401
+ b.locale,
402
+ h,
403
+ T,
404
+ U
405
+ ]), Y = (0, n.useCallback)(() => {
406
+ M?.tools.export.save(t?.split("/").pop().split(".")[0], g?.split("/")[1]);
407
+ }, [
408
+ M,
409
+ t,
410
+ g
411
+ ]);
412
+ return (0, r.jsxs)(f.Modal, {
413
+ afterOpenChange: _,
414
+ width: "100%",
415
+ style: {
416
+ maxWidth: "100%",
417
+ minHeight: "100vh"
418
+ },
419
+ className: "image-editor-modal",
420
+ centered: !0,
421
+ closable: !1,
422
+ zIndex: 1100,
423
+ mask: !1,
424
+ open: O,
425
+ footer: [(0, r.jsx)(f.Button, {
426
+ className: "em-analytics__profile-cancel",
427
+ onClick: T,
428
+ children: h("Cancel")
429
+ }, "Cancel"), (0, r.jsx)(f.Button, {
430
+ className: "em-analytics__profile-updapixiete",
431
+ id: "save",
432
+ type: "primary",
433
+ onClick: Y,
434
+ children: h("Update")
435
+ }, "Ok")],
436
+ children: [o && (0, r.jsx)("div", {
437
+ style: {
438
+ position: "absolute",
439
+ height: "100%",
440
+ width: "100%",
441
+ display: "flex",
442
+ alignItems: "center",
443
+ justifyContent: "center",
444
+ background: Xe.emCssVar("colorBgLayout"),
445
+ zIndex: 10,
446
+ opacity: .7
447
+ },
448
+ children: (0, r.jsx)(f.Spin, { size: "large" })
449
+ }), (0, r.jsx)("div", { id: "pixie-editor" })]
450
+ });
451
+ }, Et = ({ currentImageLink: t, newLink: e, previewDisplayUrl: s, resolvedPreviewObjectUrl: i, resolvedPreviewBlob: o, resolveImageBlob: l, onSave: m, uploadImageResultIsLoading: p }) => {
452
+ const g = s || i;
453
+ return (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)("div", { children: (0, r.jsxs)("div", {
454
+ className: "image-preview",
455
+ children: [p && (0, r.jsx)("div", {
456
+ style: {
457
+ position: "absolute",
458
+ height: "100%",
459
+ width: "100%",
460
+ display: "flex",
461
+ alignItems: "center",
462
+ justifyContent: "center",
463
+ background: Xe.emCssVar("colorBgLayout"),
464
+ zIndex: 10,
465
+ opacity: .7
466
+ },
467
+ children: (0, r.jsx)(f.Spin, { size: "large" })
468
+ }), g && (0, r.jsx)("img", {
469
+ alt: "uploadedImage",
470
+ src: g
471
+ })]
472
+ }) }), (0, r.jsx)(kt, {
473
+ currentImageLink: t,
474
+ prefetchedBlob: o,
475
+ resolveImageBlob: l,
476
+ newLink: e,
477
+ onSave: m,
478
+ uploadImageResultIsLoading: p
479
+ })] });
480
+ }, Re = {
481
+ Pixel: "Pixel",
482
+ Percent: "Percent"
483
+ }, $e = {
484
+ unit: Re.Percent,
485
+ value: 80
486
+ };
487
+ function jt(t) {
488
+ return typeof t == "number" ? {
489
+ unit: Re.Percent,
490
+ value: t * 100
491
+ } : typeof t == "string" ? /^(\d*(\.\d+)?)px$/.exec(t) ? {
492
+ unit: Re.Pixel,
493
+ value: parseFloat(t)
494
+ } : /^(\d*(\.\d+)?)%$/.exec(t) ? {
495
+ unit: Re.Percent,
496
+ value: parseFloat(t)
497
+ } : $e : $e;
498
+ }
499
+ function Ot(t, e) {
500
+ const s = jt(t);
501
+ let i;
502
+ return s.unit === Re.Pixel ? i = `${s.value}px` : i = `${100 - s.value}%`, e ? `${i} 0px 0px 0px` : `0px 0px ${i} 0px`;
503
+ }
504
+ function et({ next: t, hasMore: e, children: s, loader: i, scrollThreshold: o = .8, endMessage: l, style: m, height: p, scrollableTarget: g, hasChildren: x, inverse: h = !1, pullDownToRefresh: v = !1, pullDownToRefreshContent: A, releaseToRefreshContent: k, pullDownToRefreshThreshold: b = 100, refreshFunction: O, onScroll: w, dataLength: U, initialScrollY: L, className: M = "", role: V, tabIndex: P, id: T, ...X }) {
505
+ const [_, Y] = (0, n.useState)(!1), [E, z] = (0, n.useState)(!1), [j, S] = (0, n.useState)(0), I = (0, n.useRef)(null), N = (0, n.useRef)(null), J = (0, n.useRef)(null), K = (0, n.useRef)(t);
506
+ K.current = t;
507
+ const a = (0, n.useRef)(O);
508
+ a.current = O;
509
+ const y = (0, n.useRef)(b);
510
+ y.current = b;
511
+ const W = (0, n.useRef)(!1), ie = (0, n.useRef)(!1), ee = (0, n.useRef)(0), F = (0, n.useRef)(0), le = (0, n.useRef)(0), D = (0, n.useCallback)(() => g instanceof HTMLElement ? g : typeof g == "string" ? document.getElementById(g) : null, [g]);
512
+ (0, n.useEffect)(() => {
513
+ if (typeof U > "u") throw new Error("mandatory prop \"dataLength\" is missing. The prop is needed when loading more content. Check README.md for usage");
514
+ if (v && typeof O != "function") throw new Error(`Mandatory prop "refreshFunction" missing.
515
+ Pull Down To Refresh functionality will not work
516
+ as expected. Check README.md for usage'`);
517
+ if (typeof L == "number") {
518
+ const $ = p ? I.current : D();
519
+ $ && $.scrollHeight > L && $.scrollTo(0, L);
520
+ }
521
+ }, []), (0, n.useEffect)(() => {
522
+ W.current = !1, Y(!1);
523
+ }, [U]), (0, n.useEffect)(() => {
524
+ if (!e || typeof IntersectionObserver > "u") return;
525
+ const $ = N.current;
526
+ if (!$) return;
527
+ const te = p ? I.current : D(), G = new IntersectionObserver(([ae]) => {
528
+ !ae.isIntersecting || W.current || (W.current = !0, Y(!0), K.current());
529
+ }, {
530
+ root: te,
531
+ rootMargin: Ot(o, h),
532
+ threshold: 0
533
+ });
534
+ return G.observe($), () => G.disconnect();
535
+ }, [
536
+ e,
537
+ o,
538
+ h,
539
+ p,
540
+ D
541
+ ]), (0, n.useEffect)(() => {
542
+ var $;
543
+ if (!w) return;
544
+ const te = ($ = p ? I.current : D()) !== null && $ !== void 0 ? $ : typeof window < "u" ? window : null;
545
+ if (!te) return;
546
+ const G = (ae) => {
547
+ setTimeout(() => w(ae), 0);
548
+ };
549
+ return te.addEventListener("scroll", G), () => te.removeEventListener("scroll", G);
550
+ }, [
551
+ w,
552
+ p,
553
+ D
554
+ ]), (0, n.useEffect)(() => {
555
+ var $, te;
556
+ if (!v) return;
557
+ const G = ($ = p ? I.current : D()) !== null && $ !== void 0 ? $ : typeof window < "u" ? window : null;
558
+ if (!G) return;
559
+ if (!((te = J.current) === null || te === void 0) && te.firstChild) {
560
+ const Z = J.current.firstChild.getBoundingClientRect().height;
561
+ le.current = Z, S(Z);
562
+ }
563
+ const ae = (Z) => {
564
+ (G instanceof HTMLElement ? G.scrollTop : document.documentElement.scrollTop) > 0 || (ie.current = !0, Z instanceof MouseEvent ? ee.current = Z.pageY : Z instanceof TouchEvent && (ee.current = Z.touches[0].pageY), F.current = ee.current, I.current && (I.current.style.willChange = "transform", I.current.style.transition = "transform 0.2s cubic-bezier(0,0,0.31,1)"));
565
+ }, C = (Z) => {
566
+ if (!ie.current || (Z instanceof MouseEvent ? F.current = Z.pageY : Z instanceof TouchEvent && (F.current = Z.touches[0].pageY), F.current < ee.current)) return;
567
+ const me = F.current - ee.current;
568
+ me >= y.current && z(!0), !(me > le.current * 1.5) && I.current && (I.current.style.overflow = "visible", I.current.style.transform = `translate3d(0px, ${me}px, 0px)`);
569
+ }, q = () => {
570
+ ee.current = 0, F.current = 0, ie.current = !1, z((Z) => {
571
+ var me;
572
+ return Z && ((me = a.current) === null || me === void 0 || me.call(a)), !1;
573
+ }), requestAnimationFrame(() => {
574
+ I.current && (I.current.style.overflow = "auto", I.current.style.transform = "none", I.current.style.willChange = "unset");
575
+ });
576
+ };
577
+ return G.addEventListener("touchstart", ae), G.addEventListener("touchmove", C), G.addEventListener("touchend", q), G.addEventListener("mousedown", ae), G.addEventListener("mousemove", C), G.addEventListener("mouseup", q), () => {
578
+ G.removeEventListener("touchstart", ae), G.removeEventListener("touchmove", C), G.removeEventListener("touchend", q), G.removeEventListener("mousedown", ae), G.removeEventListener("mousemove", C), G.removeEventListener("mouseup", q);
579
+ };
580
+ }, [
581
+ v,
582
+ p,
583
+ D
584
+ ]);
585
+ const he = {
586
+ height: p ?? "auto",
587
+ overflow: "auto",
588
+ WebkitOverflowScrolling: "touch",
589
+ ...m
590
+ }, ye = x || !!(s && s instanceof Array && s.length), oe = v && p ? { overflow: "auto" } : {}, ve = e ? (0, r.jsx)("div", {
591
+ ref: N,
592
+ style: { height: 1 }
593
+ }) : null;
594
+ return (0, r.jsx)("div", {
595
+ style: oe,
596
+ className: "infinite-scroll-component__outerdiv",
597
+ children: (0, r.jsxs)("div", {
598
+ ...X,
599
+ role: V,
600
+ tabIndex: P,
601
+ id: T,
602
+ className: ["infinite-scroll-component", M].filter(Boolean).join(" "),
603
+ ref: I,
604
+ style: he,
605
+ children: [
606
+ v && (0, r.jsx)("div", {
607
+ style: { position: "relative" },
608
+ ref: J,
609
+ children: (0, r.jsx)("div", {
610
+ style: {
611
+ position: "absolute",
612
+ left: 0,
613
+ right: 0,
614
+ top: -1 * j
615
+ },
616
+ children: E ? k : A
617
+ })
618
+ }),
619
+ s,
620
+ !_ && !ye && e && i,
621
+ _ && e && i,
622
+ ve,
623
+ !e && l
624
+ ]
625
+ })
626
+ });
627
+ }
628
+ function Lt(t, e) {
629
+ if (t == null) return {};
630
+ var s = Dt(t, e), i, o;
631
+ if (Object.getOwnPropertySymbols) {
632
+ var l = Object.getOwnPropertySymbols(t);
633
+ for (o = 0; o < l.length; o++) i = l[o], !(e.indexOf(i) >= 0) && Object.prototype.propertyIsEnumerable.call(t, i) && (s[i] = t[i]);
634
+ }
635
+ return s;
636
+ }
637
+ function Dt(t, e) {
638
+ if (t == null) return {};
639
+ var s = {}, i = Object.keys(t), o, l;
640
+ for (l = 0; l < i.length; l++) o = i[l], !(e.indexOf(o) >= 0) && (s[o] = t[o]);
641
+ return s;
642
+ }
643
+ function Ue() {
644
+ return Ue = Object.assign || function(t) {
645
+ for (var e = 1; e < arguments.length; e++) {
646
+ var s = arguments[e];
647
+ for (var i in s) Object.prototype.hasOwnProperty.call(s, i) && (t[i] = s[i]);
648
+ }
649
+ return t;
650
+ }, Ue.apply(this, arguments);
651
+ }
652
+ function tt(t, e) {
653
+ var s = Object.keys(t);
654
+ if (Object.getOwnPropertySymbols) {
655
+ var i = Object.getOwnPropertySymbols(t);
656
+ e && (i = i.filter(function(o) {
657
+ return Object.getOwnPropertyDescriptor(t, o).enumerable;
658
+ })), s.push.apply(s, i);
659
+ }
660
+ return s;
661
+ }
662
+ function ke(t) {
663
+ for (var e = 1; e < arguments.length; e++) {
664
+ var s = arguments[e] != null ? arguments[e] : {};
665
+ e % 2 ? tt(Object(s), !0).forEach(function(i) {
666
+ Bt(t, i, s[i]);
667
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(s)) : tt(Object(s)).forEach(function(i) {
668
+ Object.defineProperty(t, i, Object.getOwnPropertyDescriptor(s, i));
669
+ });
670
+ }
671
+ return t;
672
+ }
673
+ function Bt(t, e, s) {
674
+ return e in t ? Object.defineProperty(t, e, {
675
+ value: s,
676
+ enumerable: !0,
677
+ configurable: !0,
678
+ writable: !0
679
+ }) : t[e] = s, t;
680
+ }
681
+ var Ut = {
682
+ breakpointCols: void 0,
683
+ className: void 0,
684
+ columnClassName: void 0,
685
+ children: void 0,
686
+ columnAttrs: void 0,
687
+ column: void 0
688
+ }, Ne = 2, Ge = class extends n.default.Component {
689
+ constructor(t) {
690
+ super(t), this.reCalculateColumnCount = this.reCalculateColumnCount.bind(this), this.reCalculateColumnCountDebounce = this.reCalculateColumnCountDebounce.bind(this);
691
+ let e;
692
+ this.props.breakpointCols && this.props.breakpointCols.default ? e = this.props.breakpointCols.default : e = parseInt(this.props.breakpointCols) || Ne, this.state = { columnCount: e };
693
+ }
694
+ componentDidMount() {
695
+ this.reCalculateColumnCount(), window && window.addEventListener("resize", this.reCalculateColumnCountDebounce);
696
+ }
697
+ componentDidUpdate() {
698
+ this.reCalculateColumnCount();
699
+ }
700
+ componentWillUnmount() {
701
+ window && window.removeEventListener("resize", this.reCalculateColumnCountDebounce);
702
+ }
703
+ reCalculateColumnCountDebounce() {
704
+ if (!window || !window.requestAnimationFrame) {
705
+ this.reCalculateColumnCount();
706
+ return;
707
+ }
708
+ window.cancelAnimationFrame && window.cancelAnimationFrame(this._lastRecalculateAnimationFrame), this._lastRecalculateAnimationFrame = window.requestAnimationFrame(() => {
709
+ this.reCalculateColumnCount();
710
+ });
711
+ }
712
+ reCalculateColumnCount() {
713
+ const t = window && window.innerWidth || Infinity;
714
+ let e = this.props.breakpointCols;
715
+ typeof e != "object" && (e = { default: parseInt(e) || Ne });
716
+ let s = Infinity, i = e.default || Ne;
717
+ for (let o in e) {
718
+ const l = parseInt(o);
719
+ l > 0 && t <= l && l < s && (s = l, i = e[o]);
720
+ }
721
+ i = Math.max(1, parseInt(i) || 1), this.state.columnCount !== i && this.setState({ columnCount: i });
722
+ }
723
+ itemsInColumns() {
724
+ const t = this.state.columnCount, e = new Array(t), s = n.default.Children.toArray(this.props.children);
725
+ for (let i = 0; i < s.length; i++) {
726
+ const o = i % t;
727
+ e[o] || (e[o] = []), e[o].push(s[i]);
728
+ }
729
+ return e;
730
+ }
731
+ renderColumns() {
732
+ const { column: t, columnAttrs: e = {}, columnClassName: s } = this.props, i = this.itemsInColumns(), o = `${100 / i.length}%`;
733
+ let l = s;
734
+ l && typeof l != "string" && (this.logDeprecated("The property \"columnClassName\" requires a string"), typeof l > "u" && (l = "my-masonry-grid_column"));
735
+ const m = ke(ke(ke({}, t), e), {}, {
736
+ style: ke(ke({}, e.style), {}, { width: o }),
737
+ className: l
738
+ });
739
+ return i.map((p, g) => n.default.createElement("div", Ue({}, m, { key: g }), p));
740
+ }
741
+ logDeprecated(t) {}
742
+ render() {
743
+ const t = this.props, { children: e, breakpointCols: s, columnClassName: i, columnAttrs: o, column: l, className: m } = t, p = Lt(t, [
744
+ "children",
745
+ "breakpointCols",
746
+ "columnClassName",
747
+ "columnAttrs",
748
+ "column",
749
+ "className"
750
+ ]);
751
+ let g = m;
752
+ return typeof m != "string" && (this.logDeprecated("The property \"className\" requires a string"), typeof m > "u" && (g = "my-masonry-grid")), n.default.createElement("div", Ue({}, p, { className: g }), this.renderColumns());
753
+ }
754
+ };
755
+ Ge.defaultProps = Ut;
756
+ function Fe(t, e) {
757
+ return t ? t.exhausted ? {
758
+ ...t,
759
+ src: null
760
+ } : {
761
+ ...t,
762
+ src: t.src || e || null
763
+ } : null;
764
+ }
765
+ function nt({ items: t, getItemId: e, getRequestUrl: s, createController: i }) {
766
+ const [o, l] = (0, n.useState)({}), m = (0, n.useRef)(new Map()), p = (0, n.useCallback)((g) => {
767
+ const x = e(g), h = s(g), v = `${x}:${h}`;
768
+ if (m.current.has(v)) return {
769
+ itemId: x,
770
+ requestUrl: h,
771
+ cacheKey: v,
772
+ controller: m.current.get(v)
773
+ };
774
+ const A = i(h);
775
+ return m.current.set(v, A), {
776
+ itemId: x,
777
+ requestUrl: h,
778
+ cacheKey: v,
779
+ controller: A
780
+ };
781
+ }, [
782
+ i,
783
+ e,
784
+ s
785
+ ]);
786
+ return (0, n.useEffect)(() => {
787
+ const g = new Set(), x = {}, h = t.map((v) => {
788
+ const { itemId: A, cacheKey: k, controller: b } = p(v);
789
+ g.add(k), x[A] = b.src;
790
+ const O = Fe(b.handleChangeSrc?.(), b.src);
791
+ return O?.changed && O.src && (x[A] = O.src), b.subscribeToSrcChange?.((w) => {
792
+ const U = Fe(w, b.src);
793
+ !U?.changed || !U.src || l((L) => L[A] === U.src ? L : {
794
+ ...L,
795
+ [A]: U.src
796
+ });
797
+ });
798
+ }).filter(Boolean);
799
+ return m.current.forEach((v, A) => {
800
+ g.has(A) || m.current.delete(A);
801
+ }), l(x), () => {
802
+ h.forEach((v) => v?.());
803
+ };
804
+ }, [p, t]), {
805
+ getDisplaySrc: (0, n.useCallback)((g) => {
806
+ const { itemId: x, requestUrl: h, controller: v } = p(g);
807
+ return o[x] || v.src || h;
808
+ }, [o, p]),
809
+ handleLoad: (0, n.useCallback)((g) => {
810
+ p(g).controller.handleSuccess();
811
+ }, [p]),
812
+ handleError: (0, n.useCallback)((g) => {
813
+ const { itemId: x, controller: h } = p(g), v = Fe(h.handleError(), h.src);
814
+ v?.changed && v.src && l((A) => ({
815
+ ...A,
816
+ [x]: v.src
817
+ }));
818
+ }, [p])
819
+ };
820
+ }
821
+ var rt = "blocks", Mt = ({ setCurrentImageLink: t, setModalHeight: e, setModalWidth: s, setImageStockList: i, imageStockList: o, currentReq: l, setCurrentReq: m, inputRef: p, setStockLink: g, customRequest: x }) => {
822
+ const h = u.useAppConfig(), v = u.useIsStandalone(), [A, k] = (0, n.useState)(!1), [b, O] = (0, n.useState)(2), { __: w } = f.useI18n(), U = f.useNotification(), [L] = Q.useLazyGetUnsplashImageQuery(), [M] = Q.useLazyGetSearchImageQuery(), V = (0, n.useCallback)((a) => a instanceof Error || typeof a?.message == "string" && a.message ? a.message : typeof a?.error?.message == "string" && a.error.message ? a.error.message : w("Failed to load stock images through the configured proxy chain."), [w]), P = (0, n.useCallback)((a) => {
823
+ U.error({
824
+ id: "STOCK_IMAGES_SEARCH_FAILED",
825
+ title: w("Failed to load stock images"),
826
+ description: V(a)
827
+ });
828
+ }, [
829
+ w,
830
+ V,
831
+ U
832
+ ]), T = async () => {
833
+ A || (k(!0), M({
834
+ query: l,
835
+ page: b
836
+ }).then((a) => {
837
+ if (a?.error) {
838
+ P(a.error), k(!1);
839
+ return;
840
+ }
841
+ const y = a?.data?.results || [];
842
+ i((W) => [...W, ...y]), k(!1), O((W) => W + 1);
843
+ }).catch(() => {
844
+ k(!1);
845
+ }));
846
+ };
847
+ (0, n.useEffect)(() => {
848
+ l.keywords !== "" && X();
849
+ }, [l.color, l.orientation]);
850
+ const X = async () => {
851
+ const a = await M({
852
+ query: l,
853
+ page: 1
854
+ });
855
+ if (a?.error) {
856
+ P(a.error), i([]);
857
+ return;
858
+ }
859
+ const y = a?.data?.results || [];
860
+ y.length > 0 ? (i(y), setTimeout(() => {
861
+ s(1060), e("84vh");
862
+ }, 0)) : i([]);
863
+ }, [_, Y] = (0, n.useState)(null), E = (0, n.useCallback)((a, y, W) => `${a}${a.includes("?") ? "&" : "?"}w=${y}&q=${W}`, []), z = (0, n.useCallback)((a) => u.getProxiedUrl(a, {
864
+ config: h,
865
+ standalone: v,
866
+ resourceType: "stockImages",
867
+ intent: "display"
868
+ }), [h, v]), { getDisplaySrc: j, handleLoad: S, handleError: I } = nt({
869
+ items: o,
870
+ getItemId: (0, n.useCallback)((a) => a.id, []),
871
+ getRequestUrl: (0, n.useCallback)((a) => E(a.urls.raw, 644, 96), [E]),
872
+ createController: z
873
+ }), N = (a) => (y) => {
874
+ S(a), y.target.parentNode.classList.add("loaded");
875
+ }, J = (a) => () => {
876
+ I(a);
877
+ }, K = (a, y, W) => {
878
+ L(y.download_location), Y(W), setTimeout(() => Y(null), 2e3), g(`${a.raw}&w=1200&q=96`), t(`${a.raw}&w=1200&q=96`), x(`${a.raw}&w=1200&q=96`);
879
+ };
880
+ return (0, r.jsxs)("div", {
881
+ className: "stock-tab",
882
+ children: [(0, r.jsxs)(f.Form, {
883
+ onValuesChange: X,
884
+ className: o.length > 0 ? "serach-results" : "",
885
+ children: [(0, r.jsxs)(f.Row, {
886
+ gutter: 24,
887
+ children: [(0, r.jsx)(f.Col, {
888
+ span: o.length > 0 ? "" : 24,
889
+ children: (0, r.jsx)(f.Form.Item, {
890
+ className: "stock-search-input",
891
+ children: (0, r.jsx)(f.SearchInput, {
892
+ onSearch: X,
893
+ allowClear: !0,
894
+ size: o.length > 0 ? "medium" : "large",
895
+ placeholder: w("Search image"),
896
+ value: l.keywords,
897
+ onChange: (a) => m((y) => ({
898
+ ...y,
899
+ keywords: a.target.value
900
+ })),
901
+ ref: p,
902
+ spellCheck: "false",
903
+ enterButton: !1
904
+ })
905
+ })
906
+ }), o.length > 0 && (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)(f.Col, { children: (0, r.jsxs)(f.Radio.Group, {
907
+ defaultValue: "",
908
+ onChange: (a) => m((y) => ({
909
+ ...y,
910
+ orientation: a.target.value
911
+ })),
912
+ children: [
913
+ (0, r.jsx)(f.Tooltip, {
914
+ title: w("All"),
915
+ placement: "top",
916
+ children: (0, r.jsx)(f.Radio.Button, {
917
+ value: "",
918
+ children: (0, r.jsx)(B.EmIcons, { icon: "MixedView" })
919
+ })
920
+ }),
921
+ (0, r.jsx)(f.Tooltip, {
922
+ title: w("Landscape"),
923
+ placement: "top",
924
+ children: (0, r.jsx)(f.Radio.Button, {
925
+ value: "landscape",
926
+ children: (0, r.jsx)(B.EmIcons, { icon: "LandscapeView" })
927
+ })
928
+ }),
929
+ (0, r.jsx)(f.Tooltip, {
930
+ title: w("Portrait"),
931
+ placement: "top",
932
+ children: (0, r.jsx)(f.Radio.Button, {
933
+ value: "portrait",
934
+ children: (0, r.jsx)(B.EmIcons, { icon: "PortraitView" })
935
+ })
936
+ }),
937
+ (0, r.jsx)(f.Tooltip, {
938
+ title: w("Squarish"),
939
+ placement: "top",
940
+ children: (0, r.jsx)(f.Radio.Button, {
941
+ value: "squarish",
942
+ children: (0, r.jsx)(B.EmIcons, { icon: "SquareView" })
943
+ })
944
+ })
945
+ ]
946
+ }) }), (0, r.jsx)(f.Col, { children: (0, r.jsx)(f.RadioColorFilter, {
947
+ defaultValue: "",
948
+ onChange: (a) => m((y) => ({
949
+ ...y,
950
+ color: a.target.value
951
+ })),
952
+ options: [
953
+ {
954
+ value: "",
955
+ colorClass: "all-colors",
956
+ label: w("All")
957
+ },
958
+ {
959
+ value: "black",
960
+ colorClass: "black-color",
961
+ label: w("Black")
962
+ },
963
+ {
964
+ value: "black_and_white",
965
+ colorClass: "bw-color",
966
+ label: w("Black and White")
967
+ },
968
+ {
969
+ value: "white",
970
+ colorClass: "white-color",
971
+ label: w("White")
972
+ },
973
+ {
974
+ value: "orange",
975
+ colorClass: "orange-color",
976
+ label: w("Orange")
977
+ },
978
+ {
979
+ value: "red",
980
+ colorClass: "red-color",
981
+ label: w("Red")
982
+ },
983
+ {
984
+ value: "purple",
985
+ colorClass: "purple-color",
986
+ label: w("Purple")
987
+ },
988
+ {
989
+ value: "magenta",
990
+ colorClass: "magenta-color",
991
+ label: w("Magenta")
992
+ },
993
+ {
994
+ value: "green",
995
+ colorClass: "green-color",
996
+ label: w("Green")
997
+ },
998
+ {
999
+ value: "teal",
1000
+ colorClass: "teal-color",
1001
+ label: w("Teal")
1002
+ },
1003
+ {
1004
+ value: "blue",
1005
+ colorClass: "blue-color",
1006
+ label: w("Blue")
1007
+ }
1008
+ ],
1009
+ tooltipPlacement: "top"
1010
+ }) })] })]
1011
+ }), o.length > 0 && (0, r.jsx)("div", {
1012
+ className: "blocks-search__divider-wrapper",
1013
+ children: (0, r.jsx)("div", {
1014
+ className: "ant-divider ant-divider-horizontal",
1015
+ role: "separator"
1016
+ })
1017
+ })]
1018
+ }), (0, r.jsx)("div", {
1019
+ className: "serach-output-wrapper",
1020
+ style: { marginRight: -10 },
1021
+ children: o.length > 0 && (0, r.jsx)("div", {
1022
+ id: "scrollableDiv",
1023
+ style: {
1024
+ width: "100%",
1025
+ height: "calc(84vh - 148px)",
1026
+ overflow: "auto",
1027
+ paddingTop: 24,
1028
+ paddingRight: 14,
1029
+ paddingLeft: 24,
1030
+ marginLeft: -24,
1031
+ lineHeight: "0",
1032
+ boxSizing: "unset"
1033
+ },
1034
+ children: (0, r.jsx)(et, {
1035
+ dataLength: o && o.length,
1036
+ next: T,
1037
+ hasMore: o,
1038
+ endMessage: (0, r.jsxs)(f.Divider, {
1039
+ plain: !0,
1040
+ children: [w("That`s all we could find."), " 🤐"]
1041
+ }),
1042
+ scrollableTarget: "scrollableDiv",
1043
+ style: { overflow: "visible" },
1044
+ loader: null,
1045
+ children: (0, r.jsx)(Ge, {
1046
+ breakpointCols: { default: 3 },
1047
+ className: "my-masonry-grid",
1048
+ columnClassName: "my-masonry-grid_column",
1049
+ children: o.map((a) => (0, r.jsxs)("div", {
1050
+ className: "list-item",
1051
+ onClick: () => K(a.urls, a.links, a.id),
1052
+ children: [
1053
+ (0, r.jsx)("img", {
1054
+ className: _ === a.id ? "loaded-image" : "",
1055
+ width: "322px",
1056
+ src: j(a),
1057
+ alt: a.description,
1058
+ onLoad: N(a),
1059
+ onError: J(a)
1060
+ }),
1061
+ (0, r.jsxs)("p", {
1062
+ className: "creator-info",
1063
+ onClick: (y) => y.stopPropagation(),
1064
+ children: [
1065
+ "Photo by",
1066
+ " ",
1067
+ (0, r.jsx)("a", {
1068
+ target: "_blank",
1069
+ href: `${a.user.links.html}?utm_source=${rt}&utm_medium=referral`,
1070
+ rel: "noreferrer",
1071
+ children: a.user.name
1072
+ }),
1073
+ " ",
1074
+ "on",
1075
+ " ",
1076
+ (0, r.jsx)("a", {
1077
+ target: "_blank",
1078
+ href: `https://unsplash.com/?utm_source=${rt}&utm_medium=referral`,
1079
+ rel: "noreferrer",
1080
+ children: "Unsplash"
1081
+ })
1082
+ ]
1083
+ }),
1084
+ _ === a.id && (0, r.jsx)(f.Spin, {
1085
+ className: "ant-spin",
1086
+ size: "small"
1087
+ })
1088
+ ]
1089
+ }, a.id))
1090
+ })
1091
+ })
1092
+ })
1093
+ })]
1094
+ });
1095
+ };
1096
+ function at(t) {
1097
+ return /^(https?:)?\/\//i.test(t.trim());
1098
+ }
1099
+ function Pt(t) {
1100
+ const e = t.trim();
1101
+ return at(e) || /^data:/i.test(e) ? e : `data:image/jpeg;base64, ${t}`;
1102
+ }
1103
+ var Tt = ({ images: t, transitionDuration: e = 1e3 }) => {
1104
+ const [s, i] = (0, n.useState)([]);
1105
+ return (0, n.useEffect)(() => {
1106
+ if (t.length > 0) {
1107
+ const o = t[t.length - 1];
1108
+ i((l) => [...l, {
1109
+ src: o,
1110
+ opacity: 0
1111
+ }]), setTimeout(() => {
1112
+ i((l) => l.map((m, p) => p === l.length - 1 ? {
1113
+ ...m,
1114
+ opacity: 1
1115
+ } : m));
1116
+ }, 1e3);
1117
+ }
1118
+ }, [t]), (0, r.jsx)("div", {
1119
+ className: "slideshow-container",
1120
+ children: s.map((o, l) => (0, r.jsx)("img", {
1121
+ src: Pt(o.src),
1122
+ alt: `Slide ${l + 1}`,
1123
+ className: "slideshow-image",
1124
+ style: {
1125
+ opacity: o.opacity,
1126
+ transition: `opacity ${e}ms linear`
1127
+ }
1128
+ }, l))
1129
+ });
1130
+ };
1131
+ function Nt({ setModalHeight: t, customRequest: e, aiTabRef: s, isImageUploaded: i, setIsImageUploaded: o, aiImageRequest: l, imageAiList: m, setImageAiList: p, isLoadingAi: g, setIsLoadingAi: x, onPluginAiImageLimitExceeded: h, onImageGenerateLimitExceeded: v }) {
1132
+ const { __: A } = f.useI18n(), k = u.useAppConfig(), b = f.useNotification(), O = u.usePushToDataLayer(), { blockId: w, projectId: U } = u.useParams(), L = B.useRouteEmailId(), [M] = Q.useLazySendAiImageRequestQuery(), [V, { data: P = [] }] = Q.useLazyGetAiImageSSEQuery(), [T] = Q.useLazyGetLimitsStatsByTypeQuery(), X = k?.sendAIImageRequest || M, _ = k?.trigger || V, Y = k?.handleLimitUsageEmitter || u.useEventEmitter(u.events.ON_LIMIT_ID), [E, z] = (0, n.useState)(0), [j, S] = (0, n.useState)(null), [I, N] = (0, n.useState)(!1), [J, K] = (0, n.useState)(A("Evaluating the task")), [a, y] = (0, n.useState)(!1), W = L || w, { limits: ie } = k?.limits ? k : { limits: { ai_img_limit: 0 } }, { ai_img_limit: ee } = ie, F = !!(k.limits && k.counters) && u.PLUGIN.isPlugin, le = u.useEventEmitter(u.events.AI_IMAGE_REQUEST_ID).hasListeners(), D = ne.shouldCountAiUsage({
1133
+ limitsInPlugin: F,
1134
+ hostedAiActive: le
1135
+ }), he = !le && ee > 0 && E >= ee, ye = (0, n.useCallback)(() => {
1136
+ Y.fire({
1137
+ name: "AiImgCount",
1138
+ count: E + 1
1139
+ });
1140
+ }, [Y, E]), oe = (0, n.useMemo)(() => !he && (!D || ee === 0 || E < ee), [
1141
+ he,
1142
+ D,
1143
+ E,
1144
+ ee
1145
+ ]), ve = (0, n.useCallback)(async () => {
1146
+ K(A("Evaluating the task")), l !== "" && !g && (x(!0), y(!0), p([]), O({
1147
+ event: "submit_form",
1148
+ action: "ai_image_generation",
1149
+ entity_id: L,
1150
+ project_id: U
1151
+ }), X({ body: {
1152
+ project_id: U,
1153
+ request: "create-image",
1154
+ connection: "midjourney",
1155
+ message: l
1156
+ } }).then(({ data: C, error: q }) => {
1157
+ if (q) throw q;
1158
+ if (C.data.status === 401) throw new Error(u.ERROR);
1159
+ if (C?.data?._eventResult) {
1160
+ p(C.data.task.images), x(!1), y(!1), K(A("Evaluating the task"));
1161
+ return;
1162
+ }
1163
+ C?.data.status === 200 ? (C?.data.task.id && (K(C.data.task.message), S(C.data.task.id)), C.message && b.success({
1164
+ id: "AI_IMAGE_SEND_SUCCESS",
1165
+ title: C.message,
1166
+ placement: "bottomRight",
1167
+ data: l
1168
+ }), _({
1169
+ task_id: C?.data.task.id,
1170
+ entity_id: W
1171
+ })) : (x(!1), y(!1), b.error({
1172
+ id: "AI_IMAGE_SEND_ERROR",
1173
+ title: C?.message || A("Something went wrong, please try again"),
1174
+ placement: "bottomRight",
1175
+ data: l,
1176
+ innerException: C
1177
+ }));
1178
+ }).catch((C) => {
1179
+ x(!1), y(!1), (C?.error || C?.data) && b.fromError("AI_IMAGE_SEND_ERROR", l, C.error || C);
1180
+ }));
1181
+ }, [
1182
+ l,
1183
+ g,
1184
+ x,
1185
+ y,
1186
+ p,
1187
+ O,
1188
+ L,
1189
+ U,
1190
+ X,
1191
+ b,
1192
+ _,
1193
+ W,
1194
+ A
1195
+ ]), $ = (0, n.useCallback)(async () => {
1196
+ if (oe) {
1197
+ if (!u.PLUGIN.isPlugin && !le) {
1198
+ const C = B.resolveLimitActionPreflightExceededForType("image_generate", (await T("image_generate")).data?.stats);
1199
+ if (C) {
1200
+ v?.(C);
1201
+ return;
1202
+ }
1203
+ }
1204
+ D && (z((C) => C + 1), ye()), ve();
1205
+ } else F && (h ? h() : b.error({
1206
+ title: A("The usage limit has been exceeded"),
1207
+ description: A(`The maximum number of requests for the current subscription period has been reached.
1208
+ Select the appropriate plan to fulfil more requests`),
1209
+ placement: "bottomRight"
1210
+ }));
1211
+ }, [
1212
+ oe,
1213
+ F,
1214
+ le,
1215
+ D,
1216
+ T,
1217
+ v,
1218
+ z,
1219
+ ye,
1220
+ ve,
1221
+ b,
1222
+ A,
1223
+ h
1224
+ ]);
1225
+ (0, n.useEffect)(() => {
1226
+ F && z(k?.counters?.ai_img_counter || 0);
1227
+ }, [k, F]);
1228
+ const te = u.useEventEmitter(u.events.AI_IMAGE_PROGRESS_ID);
1229
+ (0, n.useEffect)(() => {
1230
+ const C = te.event(({ progress: q, status: Z }) => {
1231
+ K(Z || `${Math.round(q)}%`);
1232
+ });
1233
+ return () => C.dispose();
1234
+ }, [te]);
1235
+ const G = (0, n.useCallback)(async (C) => {
1236
+ if (!i) {
1237
+ o(!0);
1238
+ try {
1239
+ const q = at(C) ? await (await fetch(C)).blob() : Je(C);
1240
+ e({ file: new File([q], "image.jpeg", { type: q.type || "image/jpeg" }) });
1241
+ } catch {
1242
+ o(!1);
1243
+ }
1244
+ }
1245
+ }, [
1246
+ i,
1247
+ o,
1248
+ e
1249
+ ]), ae = (0, n.useCallback)((C) => {
1250
+ C.status !== "error" && C.status !== "Canceled" ? C.images ? (K(C.status), C.progress === 100 && (p(C.images), K(A("Evaluating the task")), S(null), y(!1))) : (p([C.data]), x(!1)) : (x(!1), y(!1), b.error({
1251
+ id: "AI_IMAGE_GET_ERROR",
1252
+ title: A("Something went wrong, please try again"),
1253
+ placement: "bottomRight",
1254
+ data: j
1255
+ }));
1256
+ }, [
1257
+ p,
1258
+ K,
1259
+ A,
1260
+ x,
1261
+ t,
1262
+ j,
1263
+ b,
1264
+ y
1265
+ ]);
1266
+ return (0, n.useEffect)(() => {
1267
+ P.length > 1 && ae(P[P.length - 1]);
1268
+ }, [P, ae]), (0, n.useEffect)(() => {
1269
+ (g || m.length > 0) && setTimeout(() => {
1270
+ let C = 550;
1271
+ s.current && (C = s.current.offsetHeight + 68), t(C);
1272
+ }, 0);
1273
+ }, [
1274
+ s,
1275
+ P,
1276
+ m.length,
1277
+ g,
1278
+ t
1279
+ ]), {
1280
+ aiImageCounter: E,
1281
+ setAiImageCounter: z,
1282
+ currentAiImgLimits: ee,
1283
+ isFieldsDisabled: he,
1284
+ canGenerateImage: oe,
1285
+ aiImageRequest: l,
1286
+ imageAiList: m,
1287
+ setImageAiList: p,
1288
+ isLoadingAi: g,
1289
+ setIsLoadingAi: x,
1290
+ loadingDuringGeneration: a,
1291
+ setLoadingDuringGeneration: y,
1292
+ requestStatus: J,
1293
+ setRequestStatus: K,
1294
+ handleGenerate: $,
1295
+ handleLimitAiImgCount: ye,
1296
+ convertBase64ToFile: G,
1297
+ isShiftPressed: I,
1298
+ setIsShiftPressed: N,
1299
+ currentReqId: j,
1300
+ setCurrentReqId: S,
1301
+ limitsInPlugin: F
1302
+ };
1303
+ }
1304
+ var Gt = ({ setModalHeight: t, customRequest: e, aiTabRef: s, inputAiRef: i, isImageUploaded: o, setIsImageUploaded: l, aiImageRequest: m, setAiImageRequest: p, imageAiList: g, setImageAiList: x, isLoadingAi: h, setIsLoadingAi: v }) => {
1305
+ const A = u.useNavigate(), k = u.useDispatch(), { __: b, _n: O } = f.useI18n(), w = u.useAppConfig(), [U, L] = (0, n.useState)(!1), [M, V] = (0, n.useState)(null), { aiImageCounter: P, currentAiImgLimits: T, loadingDuringGeneration: X, requestStatus: _, handleGenerate: Y, convertBase64ToFile: E, isShiftPressed: z, setIsShiftPressed: j, limitsInPlugin: S } = Nt({
1306
+ setModalHeight: t,
1307
+ customRequest: e,
1308
+ aiTabRef: s,
1309
+ isImageUploaded: o,
1310
+ setIsImageUploaded: l,
1311
+ aiImageRequest: m,
1312
+ imageAiList: g,
1313
+ setImageAiList: x,
1314
+ isLoadingAi: h,
1315
+ setIsLoadingAi: v,
1316
+ onPluginAiImageLimitExceeded: () => L(!0),
1317
+ onImageGenerateLimitExceeded: V
1318
+ }), I = U && T > 0 ? ne.getAiTariffUpgradeStep(T) : null, N = I ? B.getLimitUpgradePresetDefinition(I.presetId) : null, J = M ? B.getLimitUpgradePresetDefinition(M.presetId) : null, [K, a] = (0, n.useState)(!1), y = (0, n.useCallback)(() => a(!0), []), W = (0, n.useCallback)(() => a(!1), []), ie = (0, n.useCallback)((D) => p(D.target.value), [p]), ee = (0, n.useCallback)((D) => {
1319
+ D.key === "Shift" ? j(!0) : D.key === "Enter" && !z && (D.preventDefault(), Y());
1320
+ }, [
1321
+ z,
1322
+ Y,
1323
+ j
1324
+ ]), F = (0, n.useCallback)((D) => {
1325
+ D.key === "Shift" && j(!1);
1326
+ }, [j]), le = g[g.length - 1];
1327
+ return (0, r.jsxs)("div", {
1328
+ className: "image-ai",
1329
+ children: [
1330
+ N && I ? (0, r.jsx)(B.LimitUpgradeModal, {
1331
+ open: !0,
1332
+ onClose: () => L(!1),
1333
+ title: b(N.titleKey),
1334
+ subtitle: b(N.subtitleKey),
1335
+ usageResource: N.usageResource,
1336
+ previousDisplay: B.presetLimitDisplay(I.previousLimit),
1337
+ nextDisplay: B.presetLimitDisplay(I.nextLimit),
1338
+ onChangePlan: () => {
1339
+ L(!1), document.body.classList.remove("editor"), A("/billing"), k(Q.openModal(u.MODALS.SWITCH_TO_PLAN_MODAL));
1340
+ }
1341
+ }) : null,
1342
+ J && M ? (0, r.jsx)(B.LimitUpgradeModal, {
1343
+ open: !0,
1344
+ onClose: () => V(null),
1345
+ title: b(J.titleKey),
1346
+ subtitle: b(J.subtitleKey),
1347
+ usageResource: J.usageResource,
1348
+ previousDisplay: B.presetLimitDisplay(M.previousLimit),
1349
+ nextDisplay: B.presetLimitDisplay(M.nextLimit),
1350
+ onChangePlan: () => {
1351
+ V(null), document.body.classList.remove("editor"), A("/billing"), k(Q.openModal(u.MODALS.SWITCH_TO_PLAN_MODAL));
1352
+ }
1353
+ }) : null,
1354
+ S && (0, r.jsx)(f.LimitsCounter, {
1355
+ text: `${P} ${b("of")} ${T > 0 ? T : "∞"} images ${O("was used", "were used", P)}`,
1356
+ exceeded: T > 0 && P >= T,
1357
+ style: { marginTop: -25 },
1358
+ extra: (0, r.jsx)("span", {
1359
+ style: {
1360
+ textDecoration: "underline",
1361
+ cursor: "pointer"
1362
+ },
1363
+ onClick: () => A(w.billingPageUrl || u.APP_ROUTES.billing),
1364
+ children: b("Need more?")
1365
+ })
1366
+ }),
1367
+ (0, r.jsx)(f.Row, {
1368
+ gutter: 24,
1369
+ className: "image-ai__row",
1370
+ children: (0, r.jsx)(f.Col, {
1371
+ span: 24,
1372
+ children: (0, r.jsx)(f.Form.Item, {
1373
+ style: { margin: 0 },
1374
+ children: (0, r.jsxs)("span", {
1375
+ className: `ant-input-affix-wrapper ant-input-affix-wrapper-lg image-ai__input-affix-wrapper${K ? " ant-input-affix-wrapper-focused" : ""}`,
1376
+ children: [(0, r.jsx)(f.TextArea, {
1377
+ ref: i,
1378
+ onKeyDown: ee,
1379
+ onKeyUp: F,
1380
+ onFocus: y,
1381
+ onBlur: W,
1382
+ autoSize: !0,
1383
+ allowClear: !0,
1384
+ className: "text-area-input-hybrid image-ai__textarea",
1385
+ placeholder: b("Generate image"),
1386
+ value: m,
1387
+ onChange: ie,
1388
+ spellCheck: "false"
1389
+ }), (0, r.jsx)("span", {
1390
+ className: "ant-input-suffix image-ai__input-suffix",
1391
+ children: h || X ? (0, r.jsx)(B.EmIcons, {
1392
+ icon: "LoadingOutlined",
1393
+ className: "input-icon image-ai__input-icon",
1394
+ spin: !0
1395
+ }) : (0, r.jsx)(B.EmIcons, {
1396
+ icon: "AI",
1397
+ className: "input-icon image-ai__input-icon",
1398
+ onClick: Y
1399
+ })
1400
+ })]
1401
+ })
1402
+ })
1403
+ })
1404
+ }),
1405
+ (h || g.length > 0) && (0, r.jsxs)("div", {
1406
+ className: "image-ai__preview",
1407
+ children: [h && g.length === 0 && (0, r.jsx)("div", {
1408
+ className: "image-ai__loading",
1409
+ children: (0, r.jsxs)("div", {
1410
+ className: "spin",
1411
+ children: [(0, r.jsx)(B.EmIcons, {
1412
+ icon: "LoadingOutlined",
1413
+ style: { fontSize: 48 },
1414
+ spin: !0
1415
+ }), (0, r.jsx)("p", {
1416
+ className: "status",
1417
+ children: _
1418
+ })]
1419
+ })
1420
+ }), g.length > 0 && (0, r.jsxs)("div", {
1421
+ className: "image-ai__image-item",
1422
+ children: [(0, r.jsx)(Tt, { images: g }), (0, r.jsx)("div", {
1423
+ className: "buttons",
1424
+ children: (0, r.jsx)(f.Button, {
1425
+ onClick: () => E(le),
1426
+ icon: (0, r.jsx)(B.EmIcons, { icon: "CheckOutlined" }),
1427
+ children: b("Use this one")
1428
+ })
1429
+ })]
1430
+ })]
1431
+ })
1432
+ ]
1433
+ });
1434
+ }, Ft = ({ setNewLink: t, setCurrentImageLink: e, setModalHeight: s, setModalWidth: i, setImageGifList: o, imageGifList: l, currentReqGif: m, setCurrentReqGif: p, inputRef: g, setStockLink: x, customRequest: h }) => {
1435
+ const { __: v } = f.useI18n(), A = u.useAppConfig(), k = u.useIsStandalone(), b = f.useNotification(), [O, w] = (0, n.useState)(null), [U, L] = (0, n.useState)(!1), [M, V] = (0, n.useState)(25), [P] = Q.useLazyGetSearchGifQuery(), T = (0, n.useCallback)((a) => a instanceof Error || typeof a?.message == "string" && a.message ? a.message : typeof a?.error?.message == "string" && a.error.message ? a.error.message : v("Failed to load GIFs through the configured proxy chain."), [v]), X = (0, n.useCallback)((a) => {
1436
+ b.error({
1437
+ id: "STOCK_GIFS_SEARCH_FAILED",
1438
+ title: v("Failed to load GIFs"),
1439
+ description: T(a)
1440
+ });
1441
+ }, [
1442
+ v,
1443
+ T,
1444
+ b
1445
+ ]), _ = async () => {
1446
+ U || (L(!0), P({
1447
+ query: m,
1448
+ page: M
1449
+ }).then((a) => {
1450
+ if (a?.error) {
1451
+ X(a.error), L(!1);
1452
+ return;
1453
+ }
1454
+ o((y) => [...y, ...a.data.data]), L(!1), V((y) => y + 25);
1455
+ }).catch(() => {
1456
+ L(!1);
1457
+ }));
1458
+ }, Y = async () => {
1459
+ const a = await P({
1460
+ query: m,
1461
+ page: 0
1462
+ });
1463
+ if (a?.error) {
1464
+ X(a.error), o([]);
1465
+ return;
1466
+ }
1467
+ a?.data?.data?.length > 0 && (o(a.data.data), setTimeout(() => {
1468
+ s("84vh"), i(1060);
1469
+ }, 0));
1470
+ }, E = (a, y) => {
1471
+ w(y), setTimeout(() => {
1472
+ w(null);
1473
+ }, 2e3), x(`${a}`), e(`${a}`), h(`${a}`);
1474
+ }, z = { default: 3 }, j = (0, n.useCallback)((a) => u.getProxiedUrl(a, {
1475
+ config: A,
1476
+ standalone: k,
1477
+ resourceType: "generic",
1478
+ intent: "display"
1479
+ }), [A, k]), { getDisplaySrc: S, handleLoad: I, handleError: N } = nt({
1480
+ items: l,
1481
+ getItemId: (0, n.useCallback)((a) => a.id, []),
1482
+ getRequestUrl: (0, n.useCallback)((a) => a.images.downsized.url, []),
1483
+ createController: j
1484
+ }), J = (a) => (y) => {
1485
+ I(a), y.target.parentNode.classList.add("loaded");
1486
+ }, K = (a) => () => {
1487
+ N(a);
1488
+ };
1489
+ return (0, r.jsxs)("div", {
1490
+ className: "stock-tab",
1491
+ children: [(0, r.jsxs)(f.Form, {
1492
+ onValuesChange: Y,
1493
+ className: l.length > 0 ? "serach-results" : "",
1494
+ children: [(0, r.jsx)(f.Row, {
1495
+ gutter: 24,
1496
+ children: (0, r.jsx)(f.Col, {
1497
+ span: l.length > 0 ? "" : 24,
1498
+ children: (0, r.jsx)(f.Form.Item, {
1499
+ className: "stock-search-input",
1500
+ children: (0, r.jsx)(f.SearchInput, {
1501
+ onSearch: Y,
1502
+ allowClear: !0,
1503
+ size: l.length > 0 ? "medium" : "large",
1504
+ placeholder: v("Search GIFs"),
1505
+ value: m.keywords,
1506
+ onChange: (a) => p((y) => ({
1507
+ ...y,
1508
+ keywords: a.target.value
1509
+ })),
1510
+ ref: g,
1511
+ spellCheck: "false",
1512
+ enterButton: !1
1513
+ })
1514
+ })
1515
+ })
1516
+ }), l.length > 0 && (0, r.jsx)("div", {
1517
+ className: "blocks-search__divider-wrapper",
1518
+ children: (0, r.jsx)("div", {
1519
+ className: "ant-divider ant-divider-horizontal",
1520
+ role: "separator"
1521
+ })
1522
+ })]
1523
+ }), (0, r.jsx)("div", {
1524
+ className: "serach-output-wrapper",
1525
+ style: { marginRight: -10 },
1526
+ children: l.length > 0 && (0, r.jsx)("div", {
1527
+ id: "scrollableDiv",
1528
+ style: {
1529
+ width: "100%",
1530
+ height: "calc(84vh - 148px)",
1531
+ overflow: "auto",
1532
+ paddingTop: 24,
1533
+ paddingRight: 14,
1534
+ paddingLeft: 24,
1535
+ marginLeft: -24,
1536
+ lineHeight: "0",
1537
+ boxSizing: "unset"
1538
+ },
1539
+ children: (0, r.jsx)(et, {
1540
+ dataLength: l && l.length,
1541
+ next: _,
1542
+ hasMore: l,
1543
+ endMessage: (0, r.jsxs)(f.Divider, {
1544
+ plain: !0,
1545
+ children: [v("That`s all we could find."), " 🤐"]
1546
+ }),
1547
+ scrollableTarget: "scrollableDiv",
1548
+ style: { overflow: "visible" },
1549
+ loader: (0, r.jsx)(f.Spin, { size: "small" }),
1550
+ children: (0, r.jsx)(Ge, {
1551
+ breakpointCols: z,
1552
+ className: "my-masonry-grid",
1553
+ columnClassName: "my-masonry-grid_column",
1554
+ children: l.map((a, y) => (0, r.jsxs)("div", {
1555
+ className: "list-item",
1556
+ onClick: () => E(a.images.downsized.url, a.id),
1557
+ children: [
1558
+ (0, r.jsx)("img", {
1559
+ className: O === a.id ? "loaded-image" : "",
1560
+ width: "322px",
1561
+ src: S(a),
1562
+ alt: a.title,
1563
+ onLoad: J(a),
1564
+ onError: K(a)
1565
+ }),
1566
+ (0, r.jsx)("a", {
1567
+ rel: "noreferrer",
1568
+ href: "https://giphy.com/",
1569
+ target: "_blank",
1570
+ onClick: (W) => W.stopPropagation(),
1571
+ children: (0, r.jsx)("div", {
1572
+ className: "overlay-image",
1573
+ style: { backgroundImage: "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAAAkCAYAAAB/up84AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABSBJREFUeNrsWjFv2zoQVoMW8BZ18xaN3qLRW9QtW9OtW92to98vaPoP3K1b1S1b3c2jvWlUNm3lw1s8Mpu3PAo4Iocr70jKlp0COuCQlpKPx/t43x1pv3h8fEwGeT5yNoTgeclLZvza6NgxXoNaGRktjE6MpjC2NVqh92bwt4HxBI1ro0s0dgN2tvD5a8a/9vkq0M+xYKdG81A7Gp6pyBjZddrnO6N36Hkbqyn8u4L3vYC0hjLHeAbPVhC4TwAK/ewNvLsEhyxgFXLK2l/D4tvnOVrUiPEh1k/JjvLYyWENdeTcKazBBr6AdY4AqBTmbkIzhO4gvMumYLxAYKzgPTvhBBajYNwCksHYhOyYiow1KONaKYlfO8bPEWyGEfi5Iu+Vjizg7EzB3xvwWTMxWkHG4mDnMF6BnSnYncLzHWGG4BqiwZkKQMC7I0cOVTCJhvRUKNgNCmCOxhNmrBEWzwGi0Y6rIihbsnOH/JgE2hshKrLZv4Px9yhj1twafRlid/UIGWvlFdlVLirIkIM12nETGLeO2tTPECBUZuT/a7JBMpSxUybYLjulUCN2iEpHQoyuGWZJUCa8R/VGSZvGB0iOdjAO9n8EtC2zUxICSIoW0ICTmA53DCDKQzWZg89XAXZ2B2iMavBnjDKpBX6B1tnAM5aqQgGhnU2D6GmHuqw7AkaOPmP/bsHpFC1kTLqVhglS6fFNgX1MCXUHO1zR1h5AFOoSc1jjmKx/An/1PoBQasBSoZZ3hpyaOrg0IW2sRkG8JsU8CaCaLckAhfi6AG0cmeuzkyMQMtL+SiySkY3oA/EgGeICK0UOZYQKVsQpDAjm2BpsaAGQLMKnMdok3yLtpKS70yT7OUBcm7UTHb5grk5y1Csrj40MqUbUpgW7NXo+RunckODkQvdXM37iwm7b1VA7lAaVB4jUUZOUIzNxfOougAwy3GUN0qWG2IJJ09V2NcvIFE8c54nQelEHFM6C6chUhI+WZjjffDQkrenPhqmlrAC9Naof/aLhXZeNNfMZOk+MtPOVRjNmTpfcCut0+biGZ3PBj1ywWTOfqV3v+yjLFuDPRs8Ddu05vLtmsuHQ0s73wehvR0t7aGkPevfCM5fcGr0MbOW9NSSFwF52cP5KcLIv+X4EUGbCemcOqpoz73/haE4CZNkRjAR20vwENXHRc2bWEMyQuUuGVe4hc6K6rBmg7pKN0XdGX7dts9E3Rr8afUATFl1PqgLAG6T3AoX1nSVtMP9l5r5FVyiu+D14/YssRHOheGVQYNMeinrhsMcV2WVPRR1rIRT4QmiA5r4G6oxp0y6ZzFh4LvhmB84MHz1xta9vWQMrcFR/3iF+7DmEu2YoyTshRbuMvGE9hnwGPQR1tdR04aCueKrqAIgiu/AqcCf1JXPhfuoYosGHn4Hgqa6AnCK4IfSkCa1eCJRxLGnn+mX0rfDOJok4AsQAUpwQlND2++HIgNiOVO1LVRIgtXDPs0bpunEU08vktHLMpoJS1/d9qEo6h6gAzq7RRaPV+QmBeICzUUh2fIHzk0s3HedXwkEy2ReQmjn4XDzDjqkN4D/J04/y/np5KbSrrtbwAyx+kTxdf9tfpvSZIW9O3FScHJAF8PEFc5F2lQzSi5wJheoG3U/t0xYOcgBAcOHuAkr7mY9ditoAiCz2q8uvEcD8gJpSDuGNl5hfnaTJ0/fpheMUr4CitHCO6fqdesj359xh1tWiqggfdUCmcz9ZivZ7+BnQM5P/BRgABx8sJWqTxoYAAAAASUVORK5CYII=)" }
1574
+ })
1575
+ }),
1576
+ O === a.id && (0, r.jsx)(f.Spin, {
1577
+ className: "ant-spin",
1578
+ size: "small"
1579
+ })
1580
+ ]
1581
+ }, a.id + y))
1582
+ })
1583
+ })
1584
+ })
1585
+ })]
1586
+ });
1587
+ };
1588
+ function zt(t) {
1589
+ if (!(t == null || t === "")) return t;
1590
+ }
1591
+ async function Kt(t, e) {
1592
+ if (t) {
1593
+ if (t.url) return t.url;
1594
+ if (typeof e.getFileById == "function" && t.id) {
1595
+ const s = await e.getFileById(t.id);
1596
+ if (s?.url) return s.url;
1597
+ if (s?.thumbnailUrl) return s.thumbnailUrl;
1598
+ if (s?.thumbnail) return s.thumbnail;
1599
+ }
1600
+ if (typeof e.getFileUrl == "function" && t.folderId !== void 0 && t.name) {
1601
+ const s = await e.getFileUrl(t.folderId || "", t.name);
1602
+ if (s) return s;
1603
+ }
1604
+ if (typeof e.getUrl == "function" && t.name) {
1605
+ const s = await e.getUrl(t);
1606
+ if (s) return s;
1607
+ }
1608
+ return t.thumbnail || t.thumbnailUrl;
1609
+ }
1610
+ }
1611
+ function Wt(t) {
1612
+ if (!(!t?.success || !Array.isArray(t.detailed))) return t.detailed.find((e) => e?.success && e.data)?.data;
1613
+ }
1614
+ function Ht(t, e, s) {
1615
+ if (t) return {
1616
+ id: t.id,
1617
+ name: t.name || e.name,
1618
+ size: t.size ?? e.size,
1619
+ type: t.type || e.type,
1620
+ folderId: t.folderId ?? s ?? "",
1621
+ url: t.url,
1622
+ thumbnail: t.thumbnail,
1623
+ thumbnailUrl: t.thumbnailUrl,
1624
+ date: t.date,
1625
+ dimensions: t.dimensions,
1626
+ aspectRatio: t.aspectRatio,
1627
+ extension: t.extension,
1628
+ selected: t.selected,
1629
+ isFolder: t.isFolder,
1630
+ lastEdited: t.lastEdited,
1631
+ childrenCount: t.childrenCount
1632
+ };
1633
+ }
1634
+ async function Vt(t, e, s) {
1635
+ if (!e) return;
1636
+ const i = zt(s ?? e.rootId);
1637
+ let o;
1638
+ typeof e.uploadFiles == "function" ? o = Wt(await e.uploadFiles({
1639
+ folderId: i,
1640
+ items: [{
1641
+ name: t.name,
1642
+ size: t.size,
1643
+ type: t.type,
1644
+ folderId: i,
1645
+ data: t
1646
+ }]
1647
+ })) : typeof e.uploadFile == "function" && (o = Ht(await e.uploadFile({
1648
+ name: t.name,
1649
+ size: t.size,
1650
+ type: t.type,
1651
+ folderId: i,
1652
+ data: t
1653
+ }), t, i));
1654
+ const l = await Kt(o, e);
1655
+ return l ? {
1656
+ item: o,
1657
+ url: l
1658
+ } : void 0;
1659
+ }
1660
+ var st = "IMG", ot = "BACKGROUND", qt = "GALLERY", Ie = "EDITOR", fe = "UPLOAD", ze = "STOCK", Ke = "GIF", We = "AI", Qt = { mode: "select" }, _t = { mode: "save" }, { Dragger: Yt } = f.Upload, Zt = (t, e = "image") => Q.decodeFileNameFromUrl(t) ?? e, Ee = ne.normalizeImageFormatForDisplay, Xt = (t, e) => {
1661
+ const s = Ee(e);
1662
+ return !s || t.includes(".") ? t : `${t}.${s}`;
1663
+ }, Jt = (t, e) => new File([t], Xt(Zt(e), t.type), { type: t.type || "application/octet-stream" }), it = ({ dataProvider: t, usesBuiltInStorage: e }) => {
1664
+ const s = u.useAppConfig(), i = u.useIsStandalone(), { __: o } = f.useI18n(), l = u.useDispatch(), { projectId: m } = u.useParams(), [p] = Q.useLazyGetImageInfoQuery(), { modal: g } = f.App.useApp(), x = f.useNotification(), h = u.useSelector(Q.selectActiveModal), { request: v, resolveImagePicker: A } = B.useImagePicker(), [k, b] = (0, n.useState)(""), [O, w] = (0, n.useState)(""), [U, L] = (0, n.useState)(""), [M, V] = (0, n.useState)(""), [P, T] = (0, n.useState)(fe), [X, _] = (0, n.useState)({
1665
+ width: "",
1666
+ height: "",
1667
+ size: "",
1668
+ format: ""
1669
+ }), [Y, E] = (0, n.useState)("success"), [z, j] = (0, n.useState)(!1), S = n.default.useRef(null), I = n.default.useRef(null), N = n.default.useRef(null), J = n.default.useRef(null), K = n.default.useRef(null), a = n.default.useRef(null), y = n.default.useRef(null), W = n.default.useRef(null), ie = n.default.useRef(null), [ee, F] = (0, n.useState)("auto"), [le, D] = (0, n.useState)(572), [he, ye] = (0, n.useState)(!1), [oe, ve] = (0, n.useState)({
1670
+ keywords: "",
1671
+ color: "",
1672
+ orientation: ""
1673
+ }), [$, te] = (0, n.useState)({ keywords: "" }), [G, ae] = (0, n.useState)([]), [C, q] = (0, n.useState)([]), [Z, me] = (0, n.useState)([]), [lt, ct] = (0, n.useState)(!1), [ut, He] = (0, n.useState)(""), [$t, je] = (0, n.useState)(!1), [en, Me] = (0, n.useState)(0), Ve = u.useSelector(u.selectProject), dt = Ve?.id !== void 0 ? String(Ve.id) : m || "", ft = u.useEventEmitter(u.events.UPLOAD_EVENT_ID), pe = ne.useImageBlobResolver(), Oe = n.default.useRef(""), we = n.default.useRef(0), xe = n.default.useRef(""), [tn, mt] = (0, n.useState)(""), [nn, pt] = (0, n.useState)(null), [rn, qe] = (0, n.useState)(""), Pe = (0, n.useCallback)((c) => {
1674
+ if (!(c instanceof Blob)) return;
1675
+ xe.current && URL.revokeObjectURL(xe.current);
1676
+ const d = URL.createObjectURL(c);
1677
+ xe.current = d, mt(d), pt(c);
1678
+ }, []), ge = (0, n.useCallback)(() => {
1679
+ xe.current && (URL.revokeObjectURL(xe.current), xe.current = ""), mt(""), pt(null);
1680
+ }, []), ce = (0, n.useCallback)(() => {
1681
+ qe("");
1682
+ }, []), Ce = B.isEditorLockedByPlan(Ve, { isPlugin: u.PLUGIN.isPlugin }), an = (c) => {
1683
+ w(c.target.value);
1684
+ }, Le = (0, n.useCallback)((c, d, R = o("The image could not be uploaded.")) => {
1685
+ const H = d instanceof Error ? d.message : R;
1686
+ x.error({
1687
+ id: "IMAGE_UPLOAD_ERROR",
1688
+ data: c,
1689
+ title: o("Upload failed"),
1690
+ description: H
1691
+ });
1692
+ }, [o, x]), sn = (0, n.useCallback)((c) => B.fireUploadImageEvent(ft, {
1693
+ file: c,
1694
+ project: dt
1695
+ }), [dt, ft]), Ae = ne.useImageBlobFetch(), on = (0, n.useCallback)((c) => pe.resolve(ne.canonicalImageUrlKey(c), void 0, Ae), [Ae, pe]), Te = async (c) => {
1696
+ if (c) try {
1697
+ const d = await ln(c);
1698
+ d && _e(d) ? await De({ file: d }) : d || Le({ url: c }, null, o("Failed to download image from URL."));
1699
+ } catch (d) {
1700
+ Le({ url: c }, d, o("Failed to process image URL."));
1701
+ }
1702
+ }, gt = n.default.useRef(Te);
1703
+ gt.current = Te, n.default.useEffect(() => {
1704
+ if (P !== fe || !M) return;
1705
+ const c = O.trim();
1706
+ if (!c || !c.toLowerCase().startsWith("http")) return;
1707
+ const d = setTimeout(() => {
1708
+ gt.current(c);
1709
+ }, 1e3);
1710
+ return () => {
1711
+ clearTimeout(d);
1712
+ };
1713
+ }, [
1714
+ O,
1715
+ P,
1716
+ M
1717
+ ]);
1718
+ const ln = async (c) => {
1719
+ try {
1720
+ const d = ne.canonicalImageUrlKey(c);
1721
+ return Jt(await pe.resolve(d, void 0, Ae), d);
1722
+ } catch {}
1723
+ };
1724
+ document.onpaste = function(c) {
1725
+ const d = c.clipboardData?.items?.[0];
1726
+ if (P === fe && M) {
1727
+ if (d?.type?.indexOf("image") === 0 && s.imageCenterLocalUploadEnabled !== !1) {
1728
+ const H = d.getAsFile();
1729
+ _e(H);
1730
+ const se = { file: H };
1731
+ w(""), De(se);
1732
+ return;
1733
+ }
1734
+ const R = c.clipboardData?.getData("text/plain");
1735
+ if (R && R.trim().toLowerCase().startsWith("http")) {
1736
+ c.preventDefault(), c.stopPropagation(), w(R.trim());
1737
+ return;
1738
+ }
1739
+ d?.type?.indexOf("text") === 0 && d.getAsString((H) => {
1740
+ if (H.trim().toLowerCase().startsWith("http")) w(H.trim());
1741
+ else if (H.toString().slice(1, 5) === "meta") {
1742
+ const se = H.toString().split("\"")[1];
1743
+ se && w(se);
1744
+ }
1745
+ });
1746
+ }
1747
+ }, (0, n.useEffect)(() => {
1748
+ const c = (d) => {
1749
+ let R = null;
1750
+ v?.kind === "background" ? (R = ot, V(ot)) : v?.kind === "img" && (V(st), R = st), v?.currentUrl && R && (b(v.currentUrl), T(d));
1751
+ };
1752
+ h === u.MODALS.UPLOAD_IMAGE_MODAL || h === u.MODALS.UPLOAD_BACKGROUND_MODAL ? c(Ie) : h === u.MODALS.UPLOAD_IMAGE_MODAL_AI || h === u.MODALS.UPLOAD_BACKGROUND_MODAL_AI ? (Ce ? (je(!0), Me(2)) : c(We), setTimeout(() => ie.current?.focus({ cursor: "start" }), 100)) : h === u.MODALS.UPLOAD_IMAGE_MODAL_UPLOAD || h === u.MODALS.UPLOAD_BACKGROUND_MODAL_UPLOAD ? (c(fe), setTimeout(() => a.current?.focus({ cursor: "start" }), 100)) : h === u.MODALS.UPLOAD_IMAGE_MODAL_STOCK || h === u.MODALS.UPLOAD_BACKGROUND_MODAL_STOCK ? (Ce ? (je(!0), Me(3)) : c(ze), setTimeout(() => W.current?.focus({ cursor: "start" }), 100)) : h === u.MODALS.UPLOAD_IMAGE_MODAL_GIF || h === u.MODALS.UPLOAD_BACKGROUND_MODAL_GIF ? (Ce ? (je(!0), Me(3)) : c(Ke), setTimeout(() => y.current?.focus({ cursor: "start" }), 100)) : h === u.MODALS.UPLOAD_IMAGE_MODAL_EDIT || h === u.MODALS.UPLOAD_BACKGROUND_MODAL_EDIT ? (Ce ? (je(!0), Me(5)) : c(Ie), l(Q.openSecondModal(u.MODALS.IMAGE_EDITOR_MODAL))) : V("");
1753
+ }, [
1754
+ h,
1755
+ l,
1756
+ Ce,
1757
+ v
1758
+ ]);
1759
+ const Qe = (0, n.useCallback)(({ url: c = k || "", meta: d = Qt }) => {
1760
+ b(c), A({
1761
+ url: c,
1762
+ meta: d
1763
+ }), setTimeout(() => {
1764
+ ce(), ge(), ve({
1765
+ keywords: "",
1766
+ color: "",
1767
+ orientation: ""
1768
+ }), te({ keywords: "" }), q([]), ae([]), V(""), He(""), ct(!1), L(""), w(""), T(fe);
1769
+ }, 200), l(Q.closeModal()), l(Q.closeSecondModal());
1770
+ }, [
1771
+ k,
1772
+ ce,
1773
+ l,
1774
+ A,
1775
+ ge
1776
+ ]), ht = (0, n.useCallback)((c, d) => (F("auto"), j(!1), Qe({
1777
+ url: c,
1778
+ meta: _t
1779
+ }), x.success({
1780
+ id: "IMAGE_UPLOAD_SUCCESS",
1781
+ data: d,
1782
+ title: o("The image was successfully uploaded.")
1783
+ }), c), [
1784
+ o,
1785
+ Qe,
1786
+ x
1787
+ ]);
1788
+ (0, n.useEffect)(() => {
1789
+ const c = O || U, d = ne.canonicalImageUrlKey(c);
1790
+ if (!c || !d) {
1791
+ E(""), Oe.current && pe.abandonKey(Oe.current), Oe.current = "", ce(), ge();
1792
+ return;
1793
+ }
1794
+ const R = Oe.current;
1795
+ R && R !== d && (pe.abandonKey(R), ce(), ge()), Oe.current = d;
1796
+ const H = new AbortController(), se = O ? 800 : 0, re = ++we.current, Ye = setTimeout(async () => {
1797
+ try {
1798
+ const Se = async () => {
1799
+ const de = await pe.resolve(d, H.signal, Ae);
1800
+ if (re !== we.current) return;
1801
+ const { width: be, height: fn } = await ne.getImageDimensionsFromBlob(de);
1802
+ re === we.current && (_({
1803
+ width: be,
1804
+ height: fn,
1805
+ size: (de.size / 1024).toFixed(2),
1806
+ format: Ee(de.type)
1807
+ }), ce(), Pe(de));
1808
+ };
1809
+ if (i) await Se();
1810
+ else {
1811
+ const de = await ne.resolveDataProviderPreview(t, d);
1812
+ if (de?.previewUrl && re === we.current) {
1813
+ qe(de.previewUrl), ge();
1814
+ try {
1815
+ const { data: be } = await p(d);
1816
+ if (re !== we.current) return;
1817
+ be ? _({
1818
+ width: be?.width,
1819
+ height: be?.height,
1820
+ size: be?.fileSize != null ? (be.fileSize / 1024).toFixed(2) : "",
1821
+ format: Ee(be?.format)
1822
+ }) : await Se();
1823
+ } catch {
1824
+ await Se();
1825
+ }
1826
+ } else await Se();
1827
+ }
1828
+ if (re !== we.current) return;
1829
+ E("success"), b(c), D(572), setTimeout(() => {
1830
+ let de = 0;
1831
+ I.current && (de = I.current.offsetHeight + 62), F(de);
1832
+ }, 0);
1833
+ } catch (Se) {
1834
+ if (Se?.name === "AbortError" || H.signal.aborted || re !== we.current) return;
1835
+ ce(), ge(), E("error");
1836
+ }
1837
+ }, se);
1838
+ return () => {
1839
+ clearTimeout(Ye), H.abort();
1840
+ };
1841
+ }, [
1842
+ O,
1843
+ U,
1844
+ i,
1845
+ ce,
1846
+ Ae,
1847
+ p,
1848
+ pe,
1849
+ ge,
1850
+ t,
1851
+ Pe
1852
+ ]), (0, n.useEffect)(() => {
1853
+ if (!k || O || U || !h) return;
1854
+ const c = ne.canonicalImageUrlKey(k), d = new AbortController();
1855
+ let R = !1;
1856
+ const H = async () => {
1857
+ const se = await pe.resolve(c, d.signal, Ae);
1858
+ if (R) return;
1859
+ const { width: re, height: Ye } = await ne.getImageDimensionsFromBlob(se);
1860
+ R || (ce(), Pe(se), _({
1861
+ width: re,
1862
+ height: Ye,
1863
+ size: (se.size / 1024).toFixed(2),
1864
+ format: Ee(se.type)
1865
+ }));
1866
+ };
1867
+ return (async () => {
1868
+ try {
1869
+ if (!i) {
1870
+ const se = await ne.resolveDataProviderPreview(t, c);
1871
+ if (se?.previewUrl && !R) {
1872
+ qe(se.previewUrl), ge();
1873
+ try {
1874
+ const { data: re } = await p(c);
1875
+ if (R) return;
1876
+ re ? _({
1877
+ width: re?.width,
1878
+ height: re?.height,
1879
+ size: re?.fileSize != null ? (re.fileSize / 1024).toFixed(2) : "",
1880
+ format: Ee(re?.format)
1881
+ }) : await H();
1882
+ return;
1883
+ } catch {
1884
+ await H();
1885
+ }
1886
+ }
1887
+ }
1888
+ await H();
1889
+ } catch {
1890
+ R || ce();
1891
+ }
1892
+ })(), () => {
1893
+ R = !0, d.abort();
1894
+ };
1895
+ }, [
1896
+ i,
1897
+ h,
1898
+ ce,
1899
+ k,
1900
+ Ae,
1901
+ p,
1902
+ pe,
1903
+ t,
1904
+ O,
1905
+ U,
1906
+ Pe
1907
+ ]);
1908
+ const cn = () => {
1909
+ l(Q.closeModal()), setTimeout(() => {
1910
+ ce(), ge(), b(""), w(""), q([]), q([]), ve({
1911
+ keywords: "",
1912
+ color: "",
1913
+ orientation: ""
1914
+ }), te({ keywords: "" }), F("auto"), !lt && He(""), D(572), T(fe);
1915
+ }, 200);
1916
+ }, un = (c) => {
1917
+ c === qt ? g.success({
1918
+ mask: { closable: !0 },
1919
+ centered: !0,
1920
+ title: o("Coming soon"),
1921
+ content: o("The feature is under development."),
1922
+ okText: o("Ok. I'll be waiting"),
1923
+ onOk: () => {}
1924
+ }) : c === Ie && k === "" ? g.warning({
1925
+ mask: { closable: !0 },
1926
+ centered: !0,
1927
+ title: o(""),
1928
+ content: o("To preview and edit the uploaded image"),
1929
+ okText: o("Upload Image"),
1930
+ onOk: () => {
1931
+ T(fe);
1932
+ }
1933
+ }) : (setTimeout(() => {
1934
+ let d = 0, R = 0;
1935
+ c === fe && S.current ? (oe.keywords === "" && a.current?.focus({ cursor: "start" }), d = 300, R = 572) : c === Ie && I.current ? (d = I.current.offsetHeight + 62, R = 572) : c === ze && N.current ? (oe.keywords === "" && W.current?.focus({ cursor: "start" }), d = 130, R = 572, C.length > 0 && (R = 1060, d = "84vh")) : c === Ke && J.current ? (oe.keywords === "" && y.current?.focus({ cursor: "start" }), d = 130, R = 572, G.length > 0 && (R = 1060, d = "84vh")) : c === We && K.current && (ut === "" && Z.length === 0 ? (ie.current?.focus({ cursor: "start" }), d = 130) : d = K.current.offsetHeight + 82, R = 572), F(d), D(R);
1936
+ }, 0), T(c));
1937
+ };
1938
+ (0, n.useEffect)(() => {
1939
+ oe.keywords === "" && (a?.current?.focus({ cursor: "start" }), q([]), setTimeout(() => {
1940
+ F("auto"), D(572);
1941
+ }, 0));
1942
+ }, [
1943
+ oe,
1944
+ q,
1945
+ F,
1946
+ D
1947
+ ]);
1948
+ const _e = (c) => {
1949
+ const d = c.type === "image/jpeg" || c.type === "image/png" || c.type === "image/jpg" || c.type === "image/webp" || c.type === "image/gif" || c.type === "image/svg+xml";
1950
+ return d || x.error({
1951
+ id: "IMAGE_UPLOAD_WRONG_FORMAT",
1952
+ data: c,
1953
+ title: "Upload",
1954
+ description: "You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!"
1955
+ }), d;
1956
+ }, De = async ({ file: c }) => {
1957
+ try {
1958
+ ye(!0);
1959
+ const d = await ne.prepareImageForEditorUpload(c, s), R = await sn(d);
1960
+ if (R.url) return ht(R.url, d), R.url;
1961
+ if (!B.shouldFallbackToBuiltInUpload(R, {
1962
+ isStandalone: i,
1963
+ targetIsOurBackend: !!e
1964
+ })) {
1965
+ Le(d, B.toUploadImageError(R));
1966
+ return;
1967
+ }
1968
+ const H = await Vt(d, t);
1969
+ if (H?.url) return ht(H.url, d), H.url;
1970
+ Le(d, null);
1971
+ return;
1972
+ } catch (d) {
1973
+ Le(c, d);
1974
+ return;
1975
+ } finally {
1976
+ ye(!1);
1977
+ }
1978
+ }, dn = (c) => De({ file: c });
1979
+ let Be = [{
1980
+ label: o("Upload"),
1981
+ key: fe,
1982
+ children: (0, r.jsxs)("div", {
1983
+ ref: S,
1984
+ style: { paddingBottom: 24 },
1985
+ children: [s.imageCenterLocalUploadEnabled !== !1 && (0, r.jsxs)(Yt, {
1986
+ showUploadList: !1,
1987
+ name: "Image",
1988
+ beforeUpload: _e,
1989
+ customRequest: De,
1990
+ style: { marginBottom: 10 },
1991
+ multiple: !1,
1992
+ accept: "image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml",
1993
+ children: [
1994
+ (0, r.jsx)("p", {
1995
+ className: "ant-upload-drag-icon",
1996
+ children: (0, r.jsx)(B.EmIcons, { icon: "InboxOutlined" })
1997
+ }),
1998
+ (0, r.jsx)("p", {
1999
+ className: "ant-upload-text",
2000
+ children: o("Click to select, paste from the clipboard, or drag and drop")
2001
+ }),
2002
+ (0, r.jsx)("p", {
2003
+ className: "ant-upload-hint",
2004
+ children: o("Accepted formats: PNG, JPG, WEBP, SVG or GIF.")
2005
+ })
2006
+ ]
2007
+ }), (0, r.jsx)(f.Form, {
2008
+ style: { padding: "0 2px 0 2px" },
2009
+ children: (0, r.jsx)(f.Form.Item, {
2010
+ validateStatus: Y,
2011
+ children: (0, r.jsx)(f.Input, {
2012
+ ref: a,
2013
+ allowClear: !0,
2014
+ size: "large",
2015
+ placeholder: o("Paste image URL here"),
2016
+ value: O,
2017
+ onChange: an,
2018
+ spellCheck: "false"
2019
+ })
2020
+ })
2021
+ })]
2022
+ })
2023
+ }];
2024
+ return s.imageCenterStockEnabled && !Ce && Be.push({
2025
+ label: o("Stock"),
2026
+ key: ze,
2027
+ children: (0, r.jsx)("div", {
2028
+ ref: N,
2029
+ style: { paddingBottom: 24 },
2030
+ children: (0, r.jsx)(Mt, {
2031
+ currentReq: oe,
2032
+ setCurrentReq: ve,
2033
+ imageStockList: C,
2034
+ setImageStockList: q,
2035
+ setModalWidth: D,
2036
+ setModalHeight: F,
2037
+ setStockLink: L,
2038
+ setCurrentImageLink: b,
2039
+ inputRef: W,
2040
+ customRequest: Te
2041
+ })
2042
+ })
2043
+ }), s.imageCenterGifEnabled && !Ce && Be.push({
2044
+ label: o("GIF"),
2045
+ key: Ke,
2046
+ children: (0, r.jsx)("div", {
2047
+ ref: J,
2048
+ style: { paddingBottom: 24 },
2049
+ children: (0, r.jsx)(Ft, {
2050
+ currentReqGif: $,
2051
+ setCurrentReqGif: te,
2052
+ imageGifList: G,
2053
+ setImageGifList: ae,
2054
+ setModalWidth: D,
2055
+ setModalHeight: F,
2056
+ setStockLink: L,
2057
+ setCurrentImageLink: b,
2058
+ inputRef: y,
2059
+ customRequest: Te
2060
+ })
2061
+ })
2062
+ }), s.elementAIimageEnabled && !Ce && Be.push({
2063
+ label: o("AI"),
2064
+ key: We,
2065
+ children: (0, r.jsx)("div", {
2066
+ ref: K,
2067
+ style: { paddingBottom: 24 },
2068
+ children: (0, r.jsx)(Gt, {
2069
+ setModalHeight: F,
2070
+ customRequest: De,
2071
+ aiImageRequest: ut,
2072
+ setAiImageRequest: He,
2073
+ imageAiList: Z,
2074
+ setImageAiList: me,
2075
+ isLoadingAi: lt,
2076
+ setIsLoadingAi: ct,
2077
+ aiTabRef: K,
2078
+ inputAiRef: ie,
2079
+ isImageUploaded: z,
2080
+ setIsImageUploaded: j
2081
+ })
2082
+ })
2083
+ }), s.imageCenterEditorEnabled && Be.push({
2084
+ label: "",
2085
+ key: Ie,
2086
+ children: (0, r.jsx)("div", {
2087
+ ref: I,
2088
+ children: (0, r.jsx)(Et, {
2089
+ currentImageLink: k,
2090
+ newLink: O,
2091
+ previewDisplayUrl: rn,
2092
+ resolvedPreviewObjectUrl: tn,
2093
+ resolvedPreviewBlob: nn,
2094
+ resolveImageBlob: on,
2095
+ imageSize: X,
2096
+ onSave: dn,
2097
+ uploadImageResultIsLoading: he || !1
2098
+ })
2099
+ })
2100
+ }), (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)(f.Modal, {
2101
+ width: le,
2102
+ className: "image-center",
2103
+ title: o("Image Center"),
2104
+ style: { minHeight: 390 },
2105
+ open: !!M,
2106
+ onOk: Qe,
2107
+ onCancel: cn,
2108
+ footer: P === Ie ? (0, r.jsx)(r.Fragment, {}) : null,
2109
+ children: (0, r.jsx)(f.Spin, {
2110
+ spinning: he,
2111
+ children: (0, r.jsx)(f.Tabs, {
2112
+ activeKey: P,
2113
+ onChange: un,
2114
+ items: Be,
2115
+ className: "modal-tabs",
2116
+ style: {
2117
+ height: ee,
2118
+ minHeight: 130
2119
+ }
2120
+ })
2121
+ })
2122
+ }), (0, r.jsx)(B.PlanUpgradePrompt, {
2123
+ open: $t,
2124
+ onCancel: () => je(!1),
2125
+ initialSlide: en
2126
+ })] });
2127
+ };
2128
+ it.propTypes = { dataProvider: Ct.default.object }, yt.default = it;
2129
+ });