useblocks 1.1.71 → 1.1.81

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 (61) hide show
  1. package/CHANGELOG.md +426 -0
  2. package/README.md +38 -0
  3. package/iframe/js/amp.Da_6yDxX.js +1 -0
  4. package/iframe/js/iframe-eblock.js +1 -1
  5. package/iframe/js/iframe.js +1 -1
  6. package/iframe/js/rules.4N5s3OV-.js +1 -1
  7. package/package.json +30 -9
  8. package/static/core/1ab52017.js +2134 -0
  9. package/static/core/4296ff4b.js +3280 -0
  10. package/static/core/{63206e112.js → 496a28e52.js} +2682 -2421
  11. package/static/core/{9ab1c444.js → 5cc21a00.js} +2302 -2432
  12. package/static/core/{b9b92e01.js → 6a3ea43c.js} +15 -15
  13. package/static/core/{e02024fb2.js → 6fc5508e2.js} +69 -69
  14. package/static/core/{ea6c5c93.js → 7cff1d56.js} +3327 -2997
  15. package/static/core/87de8255.js +1098 -0
  16. package/static/core/{3f22a9d32.js → 909c874d2.js} +1196 -1123
  17. package/static/core/{c3b45fb6.js → ace7c2d1.js} +7 -7
  18. package/static/core/{5e082e16.js → c287f8b6.js} +38 -38
  19. package/static/core/{585259872.js → cc4c61c42.js} +108 -108
  20. package/static/core/{222d29d9.js → d2293148.js} +272 -248
  21. package/static/core/{e4d01015.js → d70b5c31.js} +22367 -19437
  22. package/static/core/{68ec11c8.js → dfbad00e.js} +4 -4
  23. package/static/core/{ce9be2ec2.js → f2b0c97b2.js} +2138 -2086
  24. package/static/core/{d3bbb05e.js → f7e3905a.js} +3 -3
  25. package/static/core/{513594a8.js → fc514220.js} +34 -34
  26. package/static/umd-runtime/ui-kit.js +1171 -1103
  27. package/ui-kit/index.js +1541 -1469
  28. package/{useblocks-core.77131b3d.js → useblocks-core.0a682f7d.js} +6 -6
  29. package/useblocks-esm.js +4 -4
  30. package/{useblocks-po.77131b3d.js → useblocks-po.0a682f7d.js} +1 -1
  31. package/useblocks.d.ts +66 -0
  32. package/useblocks.js +3 -3
  33. package/favicon-b.ico +0 -0
  34. package/favicon.ico +0 -0
  35. package/fonts/SegoeUI-Bold.woff2 +0 -0
  36. package/fonts/SegoeUI-Semibold.woff2 +0 -0
  37. package/fonts/SegoeUI.woff2 +0 -0
  38. package/iframe/js/amp.DllX-Im0.js +0 -1
  39. package/js/amplitude.min.js +0 -10859
  40. package/js/sourcebuster.min.js +0 -672
  41. package/manifest.json +0 -17
  42. package/npm-publish.manifest.json +0 -51
  43. package/static/core/23546a64.js +0 -925
  44. package/static/core/35ad3ae5.js +0 -3150
  45. package/static/core/36bf6931.js +0 -2119
  46. package/static/media/image-editor/images/samples/large_sample.jpg +0 -0
  47. package/static/media/image-editor/images/samples/sample1.jpg +0 -0
  48. package/static/media/image-editor/images/samples/sample1_thumbnail.jpg +0 -0
  49. package/static/media/image-editor/images/samples/sample2.jpg +0 -0
  50. package/static/media/image-editor/images/samples/sample2_thumbnail.jpg +0 -0
  51. package/static/media/image-editor/images/samples/sample3.jpg +0 -0
  52. package/static/media/image-editor/images/samples/sample3_thumbnail.jpg +0 -0
  53. package/static/media/image-editor/images/samples/sample4.json +0 -871
  54. package/static/media/image-editor/images/samples/sample4_preview.jpg +0 -0
  55. package/test-font.otf +0 -0
  56. package/test-font.ttf +0 -0
  57. package/test-font.woff2 +0 -0
  58. package/tsconfig.json +0 -14
  59. package/two_step_headless_plugin.html +0 -558
  60. /package/iframe/{iframe-eblock.77131b3d.html → iframe-eblock.0a682f7d.html} +0 -0
  61. /package/iframe/{iframe.77131b3d.html → iframe.0a682f7d.html} +0 -0
@@ -1,2119 +0,0 @@
1
- (function(){try{if(typeof document<"u"){var o=document.createElement("style");o.setAttribute("data-useblocks","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(--ub-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(--ub-colorPrimary);border-color:var(--ub-colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary:hover{background:var(--ub-colorPrimaryHover);border-color:var(--ub-colorPrimaryHover)}.blocks-app .image-editor-modal .pi .text-on-primary.rounded-full{border-radius:calc(var(--ub-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(--ub-colorPrimary)}.blocks-app .image-editor-modal .pi .bg-white\\/50{background-color:var(--ub-colorPrimary)}.blocks-app .image-editor-modal .pi .text-on-primary{color:var(--ub-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(--ub-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(--ub-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(--ub-borderWidth) * 1px);border-color:var(--ub-colorFillSecondaryDarken);border-radius:calc(var(--ub-borderRadius) * 1px);width:100%;padding-left:0;display:inline-flex}.blocks-app .image-ai .image-ai__input-affix-wrapper:hover{border-color:var(--ub-borderColorHover)}.blocks-app .image-ai .image-ai__input-affix-wrapper.ant-input-affix-wrapper-focused{border-color:var(--ub-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(--ub-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(--ub-colorBorderSecondary);background:linear-gradient(180deg, var(--ub-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(--ub-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(--ub-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(--ub-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
- __useblocks__.define("static/core/36bf6931.js", [
3
- "require",
4
- "exports",
5
- "module",
6
- "static/core/df237243.js",
7
- "static/core/ea6c5c93.js",
8
- "static/core/23546a64.js",
9
- "static/core/35ad3ae5.js",
10
- "static/core/3f22a9d32.js",
11
- "static/core/63206e112.js",
12
- "static/core/cf655a1a.js",
13
- "static/core/6e2a0152.js",
14
- "react",
15
- "react/jsx-runtime"
16
- ], function(ce, ht, fn) {
17
- const Ze = ce("./df237243.js"), u = ce("./ea6c5c93.js"), Z = ce("./23546a64.js"), ne = ce("./35ad3ae5.js"), p = ce("./3f22a9d32.js"), N = ce("./63206e112.js"), yt = ce("./cf655a1a.js"), Xe = ce("./6e2a0152.js");
18
- let n = ce("react");
19
- n = Ze.__toESM(n);
20
- let r = ce("react/jsx-runtime");
21
- var vt = Ze.__toESM(ne.require_prop_types());
22
- function Ct(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 a = t.trim(), o = e?.trim() || "application/octet-stream";
110
- const i = a.indexOf(",");
111
- if (a.startsWith("data:") && i >= 0) {
112
- const f = a.slice(5, i).split(";")[0]?.trim();
113
- f && (o = f), a = a.slice(i + 1);
114
- }
115
- const l = a.replace(/\s/g, ""), d = atob(l), g = new Uint8Array(d.length);
116
- for (let f = 0; f < d.length; f++) g[f] = d.charCodeAt(f);
117
- return new Blob([g], { type: o });
118
- }
119
- var bt = "static/media/image-editor", wt = { 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 At(t, e, a, o) {
238
- if (e.type === "linear") {
239
- const i = t.createLinearGradient(a + e.coords.x1, o + e.coords.y1, a + e.coords.x2, o + e.coords.y2);
240
- return e.colorStops.forEach((l) => i.addColorStop(l.offset, l.color)), i;
241
- }
242
- if (e.type === "radial") {
243
- const i = t.createRadialGradient(a + e.coords.x1, o + e.coords.y1, e.coords.r1 ?? 0, a + e.coords.x2, o + e.coords.y2, e.coords.r2 ?? 0);
244
- return e.colorStops.forEach((l) => i.addColorStop(l.offset, l.color)), i;
245
- }
246
- throw new Error("Unknown gradient type");
247
- }
248
- function xt(t) {
249
- if (!this.backgroundColor) return;
250
- const e = this._getNonTransformedDimensions(), a = -e.x / 2, o = -e.y / 2, i = e.x, l = e.y, d = this.backgroundColor;
251
- if (typeof d == "string" || d instanceof CanvasGradient || d instanceof CanvasPattern) t.fillStyle = d, t.fillRect(a, o, i, l);
252
- else if (typeof d == "object" && "type" in d && (d.type === "linear" || d.type === "radial")) t.fillStyle = At(t, d, a, o), t.fillRect(a, o, i, l);
253
- else if ("source" in d && (d.source instanceof HTMLImageElement || d.source instanceof HTMLCanvasElement)) if (d.repeat) {
254
- const g = t.createPattern(d.source, d.repeat);
255
- g && (t.fillStyle = g, t.fillRect(a, o, i, l));
256
- } else t.drawImage(d.source, a, o, i, l);
257
- this._removeShadow(t);
258
- }
259
- function It(t) {
260
- t?.fabric && t.fabric.on("object:added", (e) => {
261
- const a = e.target;
262
- a && a.name === "text" && (a._renderBackground = xt);
263
- });
264
- }
265
- function St(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 a = `image/${t}`;
269
- return Je(e.replace(/data:image\/([a-z]*)?;base64,/, ""), a);
270
- }
271
- var Rt = ({ currentImageLink: t, prefetchedBlob: e, resolveImageBlob: a, onSave: o, uploadImageResultIsLoading: i }) => {
272
- const l = N.useCookieManager(), [d, g] = (0, n.useState)(), [f, C] = (0, n.useState)(), { __: I } = p.useI18n();
273
- let w = u.useDispatch();
274
- const b = u.useStore(), R = u.useAppConfig(), v = u.useSelector(u.selectedCurrentUser), L = u.useSelector(Z.selectSecondModal), A = u.useSelector(u.selectProject), G = (0, n.useMemo)(() => {
275
- if (!R?.icons) return;
276
- const j = {};
277
- for (const [P, E] of Object.entries(R.icons)) typeof E == "string" && (j[P] = N.sanitizeHtml(E));
278
- return Object.keys(j).length > 0 ? j : void 0;
279
- }, [R?.icons]), O = (0, n.useRef)(!1), [D, H] = (0, n.useState)(), B = u.useEventEmitter(u.events.FILE_PROXY_EVENT_ID);
280
- (0, n.useEffect)(() => {
281
- let j = !1;
282
- return (async () => {
283
- const E = t;
284
- if (!E && !e) return;
285
- let x = e;
286
- if (!x && E) try {
287
- typeof a == "function" ? x = await a(E) : x = await (await fetch(E)).blob();
288
- } catch {
289
- if (j) return;
290
- if (x = await B.fire({
291
- url: E,
292
- project: A
293
- }).filter((U) => U instanceof Blob)[0], !x) {
294
- const U = l.get(u.APP_COOKIES.em_token) || await u.di.getInstance(b, Z.TOKEN_ID);
295
- x = await (await fetch(`https://app.useblocks.io/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(E)}`, { headers: { authorization: `Bearer ${U}` } })).blob();
296
- }
297
- }
298
- if (j || !x) return;
299
- const S = new FileReader();
300
- S.onload = () => {
301
- if (j) return;
302
- const U = S.result;
303
- typeof U == "string" && (g(U), C(x.type), D?.tools.import.openBackgroundImage(U));
304
- }, S.onerror = () => {}, S.readAsDataURL(x);
305
- })().catch((E) => {}), () => {
306
- j = !0;
307
- };
308
- }, [
309
- t,
310
- e,
311
- a,
312
- l,
313
- D,
314
- B,
315
- A,
316
- b
317
- ]);
318
- const z = (0, n.useCallback)(() => {
319
- g(null), C(null), w(Z.closeSecondModal()), w(Z.closeModal(u.MODALS.UPLOAD_IMAGE_MODAL));
320
- }, [w]), V = (0, n.useRef)();
321
- V.current = async function(j, P, E) {
322
- try {
323
- const x = St(E, j);
324
- o && await o(new File([x], P, {
325
- lastModified: Date.now(),
326
- type: x.type
327
- }));
328
- } catch (x) {
329
- throw x;
330
- }
331
- };
332
- const ee = (0, n.useCallback)((j) => {
333
- if (j && !(O.current && D)) {
334
- O.current = !0;
335
- const P = v.locale ? v.locale.replace("_", "-") : "en-US", E = v.theme === "system" ? matchMedia("(prefers-color-scheme: dark)").matches ? u.DARK : u.LIGHT : v.theme;
336
- yt.Tf.init({
337
- selector: "#pixie-editor",
338
- baseUrl: p.getBundledHostAssetUrl(bt),
339
- image: d,
340
- activeLanguage: P,
341
- languages: Ct(P, I),
342
- tools: wt,
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)(p.EmIcons, {
359
- icon: "HistoryOutlined",
360
- configIcons: G,
361
- style: { fontSize: 20 }
362
- }),
363
- align: "right",
364
- desktopOnly: !0,
365
- action: (x) => {
366
- x.togglePanel("history");
367
- }
368
- },
369
- {
370
- type: "button",
371
- icon: (0, r.jsx)(p.EmIcons, {
372
- icon: "CloseOutlined",
373
- configIcons: G,
374
- style: { fontSize: 20 }
375
- }),
376
- align: "right",
377
- desktopOnly: !0,
378
- action: () => z()
379
- }
380
- ]
381
- },
382
- nav: { position: "top" },
383
- activeTheme: E,
384
- mode: "inline",
385
- forceOverlayModeOnMobile: !1
386
- },
387
- onSave: async function(x, S, U) {
388
- try {
389
- await V.current(x, S, U);
390
- } catch {}
391
- }
392
- }).then((x) => {
393
- It(x), H(x);
394
- }).catch((x) => {});
395
- }
396
- }, [
397
- v.theme,
398
- d,
399
- D,
400
- H,
401
- v.locale,
402
- I,
403
- z,
404
- G
405
- ]), q = (0, n.useCallback)(() => {
406
- D?.tools.export.save(t?.split("/").pop().split(".")[0], f?.split("/")[1]);
407
- }, [
408
- D,
409
- t,
410
- f
411
- ]);
412
- return (0, r.jsxs)(p.Modal, {
413
- afterOpenChange: ee,
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: L,
425
- footer: [(0, r.jsx)(p.Button, {
426
- className: "em-analytics__profile-cancel",
427
- onClick: z,
428
- children: I("Cancel")
429
- }, "Cancel"), (0, r.jsx)(p.Button, {
430
- className: "em-analytics__profile-updapixiete",
431
- id: "save",
432
- type: "primary",
433
- onClick: q,
434
- children: I("Update")
435
- }, "Ok")],
436
- children: [i && (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)(p.Spin, { size: "large" })
449
- }), (0, r.jsx)("div", { id: "pixie-editor" })]
450
- });
451
- }, kt = ({ currentImageLink: t, newLink: e, previewDisplayUrl: a, resolvedPreviewObjectUrl: o, resolvedPreviewBlob: i, resolveImageBlob: l, onSave: d, uploadImageResultIsLoading: g }) => {
452
- const f = a || o;
453
- return (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)("div", { children: (0, r.jsxs)("div", {
454
- className: "image-preview",
455
- children: [g && (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)(p.Spin, { size: "large" })
468
- }), f && (0, r.jsx)("img", {
469
- alt: "uploadedImage",
470
- src: f
471
- })]
472
- }) }), (0, r.jsx)(Rt, {
473
- currentImageLink: t,
474
- prefetchedBlob: i,
475
- resolveImageBlob: l,
476
- newLink: e,
477
- onSave: d,
478
- uploadImageResultIsLoading: g
479
- })] });
480
- }, Re = {
481
- Pixel: "Pixel",
482
- Percent: "Percent"
483
- }, $e = {
484
- unit: Re.Percent,
485
- value: 80
486
- };
487
- function Et(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 jt(t, e) {
500
- const a = Et(t);
501
- let o;
502
- return a.unit === Re.Pixel ? o = `${a.value}px` : o = `${100 - a.value}%`, e ? `${o} 0px 0px 0px` : `0px 0px ${o} 0px`;
503
- }
504
- function et({ next: t, hasMore: e, children: a, loader: o, scrollThreshold: i = .8, endMessage: l, style: d, height: g, scrollableTarget: f, hasChildren: C, inverse: I = !1, pullDownToRefresh: w = !1, pullDownToRefreshContent: b, releaseToRefreshContent: R, pullDownToRefreshThreshold: v = 100, refreshFunction: L, onScroll: A, dataLength: G, initialScrollY: O, className: D = "", role: H, tabIndex: B, id: z, ...V }) {
505
- const [ee, q] = (0, n.useState)(!1), [j, P] = (0, n.useState)(!1), [E, x] = (0, n.useState)(0), S = (0, n.useRef)(null), U = (0, n.useRef)(null), _ = (0, n.useRef)(null), W = (0, n.useRef)(t);
506
- W.current = t;
507
- const s = (0, n.useRef)(L);
508
- s.current = L;
509
- const y = (0, n.useRef)(v);
510
- y.current = v;
511
- const K = (0, n.useRef)(!1), me = (0, n.useRef)(!1), T = (0, n.useRef)(0), J = (0, n.useRef)(0), $ = (0, n.useRef)(0), F = (0, n.useCallback)(() => f instanceof HTMLElement ? f : typeof f == "string" ? document.getElementById(f) : null, [f]);
512
- (0, n.useEffect)(() => {
513
- if (typeof G > "u") throw new Error("mandatory prop \"dataLength\" is missing. The prop is needed when loading more content. Check README.md for usage");
514
- if (w && typeof L != "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 O == "number") {
518
- const Y = g ? S.current : F();
519
- Y && Y.scrollHeight > O && Y.scrollTo(0, O);
520
- }
521
- }, []), (0, n.useEffect)(() => {
522
- K.current = !1, q(!1);
523
- }, [G]), (0, n.useEffect)(() => {
524
- if (!e || typeof IntersectionObserver > "u") return;
525
- const Y = U.current;
526
- if (!Y) return;
527
- const re = g ? S.current : F(), M = new IntersectionObserver(([ae]) => {
528
- !ae.isIntersecting || K.current || (K.current = !0, q(!0), W.current());
529
- }, {
530
- root: re,
531
- rootMargin: jt(i, I),
532
- threshold: 0
533
- });
534
- return M.observe(Y), () => M.disconnect();
535
- }, [
536
- e,
537
- i,
538
- I,
539
- g,
540
- F
541
- ]), (0, n.useEffect)(() => {
542
- var Y;
543
- if (!A) return;
544
- const re = (Y = g ? S.current : F()) !== null && Y !== void 0 ? Y : typeof window < "u" ? window : null;
545
- if (!re) return;
546
- const M = (ae) => {
547
- setTimeout(() => A(ae), 0);
548
- };
549
- return re.addEventListener("scroll", M), () => re.removeEventListener("scroll", M);
550
- }, [
551
- A,
552
- g,
553
- F
554
- ]), (0, n.useEffect)(() => {
555
- var Y, re;
556
- if (!w) return;
557
- const M = (Y = g ? S.current : F()) !== null && Y !== void 0 ? Y : typeof window < "u" ? window : null;
558
- if (!M) return;
559
- if (!((re = _.current) === null || re === void 0) && re.firstChild) {
560
- const X = _.current.firstChild.getBoundingClientRect().height;
561
- $.current = X, x(X);
562
- }
563
- const ae = (X) => {
564
- (M instanceof HTMLElement ? M.scrollTop : document.documentElement.scrollTop) > 0 || (me.current = !0, X instanceof MouseEvent ? T.current = X.pageY : X instanceof TouchEvent && (T.current = X.touches[0].pageY), J.current = T.current, S.current && (S.current.style.willChange = "transform", S.current.style.transition = "transform 0.2s cubic-bezier(0,0,0.31,1)"));
565
- }, h = (X) => {
566
- if (!me.current || (X instanceof MouseEvent ? J.current = X.pageY : X instanceof TouchEvent && (J.current = X.touches[0].pageY), J.current < T.current)) return;
567
- const ue = J.current - T.current;
568
- ue >= y.current && P(!0), !(ue > $.current * 1.5) && S.current && (S.current.style.overflow = "visible", S.current.style.transform = `translate3d(0px, ${ue}px, 0px)`);
569
- }, te = () => {
570
- T.current = 0, J.current = 0, me.current = !1, P((X) => {
571
- var ue;
572
- return X && ((ue = s.current) === null || ue === void 0 || ue.call(s)), !1;
573
- }), requestAnimationFrame(() => {
574
- S.current && (S.current.style.overflow = "auto", S.current.style.transform = "none", S.current.style.willChange = "unset");
575
- });
576
- };
577
- return M.addEventListener("touchstart", ae), M.addEventListener("touchmove", h), M.addEventListener("touchend", te), M.addEventListener("mousedown", ae), M.addEventListener("mousemove", h), M.addEventListener("mouseup", te), () => {
578
- M.removeEventListener("touchstart", ae), M.removeEventListener("touchmove", h), M.removeEventListener("touchend", te), M.removeEventListener("mousedown", ae), M.removeEventListener("mousemove", h), M.removeEventListener("mouseup", te);
579
- };
580
- }, [
581
- w,
582
- g,
583
- F
584
- ]);
585
- const he = {
586
- height: g ?? "auto",
587
- overflow: "auto",
588
- WebkitOverflowScrolling: "touch",
589
- ...d
590
- }, ie = C || !!(a && a instanceof Array && a.length), pe = w && g ? { overflow: "auto" } : {}, Ae = e ? (0, r.jsx)("div", {
591
- ref: U,
592
- style: { height: 1 }
593
- }) : null;
594
- return (0, r.jsx)("div", {
595
- style: pe,
596
- className: "infinite-scroll-component__outerdiv",
597
- children: (0, r.jsxs)("div", {
598
- ...V,
599
- role: H,
600
- tabIndex: B,
601
- id: z,
602
- className: ["infinite-scroll-component", D].filter(Boolean).join(" "),
603
- ref: S,
604
- style: he,
605
- children: [
606
- w && (0, r.jsx)("div", {
607
- style: { position: "relative" },
608
- ref: _,
609
- children: (0, r.jsx)("div", {
610
- style: {
611
- position: "absolute",
612
- left: 0,
613
- right: 0,
614
- top: -1 * E
615
- },
616
- children: j ? R : b
617
- })
618
- }),
619
- a,
620
- !ee && !ie && e && o,
621
- ee && e && o,
622
- Ae,
623
- !e && l
624
- ]
625
- })
626
- });
627
- }
628
- function Ot(t, e) {
629
- if (t == null) return {};
630
- var a = Lt(t, e), o, i;
631
- if (Object.getOwnPropertySymbols) {
632
- var l = Object.getOwnPropertySymbols(t);
633
- for (i = 0; i < l.length; i++) o = l[i], !(e.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(t, o) && (a[o] = t[o]);
634
- }
635
- return a;
636
- }
637
- function Lt(t, e) {
638
- if (t == null) return {};
639
- var a = {}, o = Object.keys(t), i, l;
640
- for (l = 0; l < o.length; l++) i = o[l], !(e.indexOf(i) >= 0) && (a[i] = t[i]);
641
- return a;
642
- }
643
- function De() {
644
- return De = Object.assign || function(t) {
645
- for (var e = 1; e < arguments.length; e++) {
646
- var a = arguments[e];
647
- for (var o in a) Object.prototype.hasOwnProperty.call(a, o) && (t[o] = a[o]);
648
- }
649
- return t;
650
- }, De.apply(this, arguments);
651
- }
652
- function tt(t, e) {
653
- var a = Object.keys(t);
654
- if (Object.getOwnPropertySymbols) {
655
- var o = Object.getOwnPropertySymbols(t);
656
- e && (o = o.filter(function(i) {
657
- return Object.getOwnPropertyDescriptor(t, i).enumerable;
658
- })), a.push.apply(a, o);
659
- }
660
- return a;
661
- }
662
- function ke(t) {
663
- for (var e = 1; e < arguments.length; e++) {
664
- var a = arguments[e] != null ? arguments[e] : {};
665
- e % 2 ? tt(Object(a), !0).forEach(function(o) {
666
- Dt(t, o, a[o]);
667
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(a)) : tt(Object(a)).forEach(function(o) {
668
- Object.defineProperty(t, o, Object.getOwnPropertyDescriptor(a, o));
669
- });
670
- }
671
- return t;
672
- }
673
- function Dt(t, e, a) {
674
- return e in t ? Object.defineProperty(t, e, {
675
- value: a,
676
- enumerable: !0,
677
- configurable: !0,
678
- writable: !0
679
- }) : t[e] = a, t;
680
- }
681
- var Bt = {
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
- }, Te = 2, Ne = 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) || Te, 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) || Te });
716
- let a = Infinity, o = e.default || Te;
717
- for (let i in e) {
718
- const l = parseInt(i);
719
- l > 0 && t <= l && l < a && (a = l, o = e[i]);
720
- }
721
- o = Math.max(1, parseInt(o) || 1), this.state.columnCount !== o && this.setState({ columnCount: o });
722
- }
723
- itemsInColumns() {
724
- const t = this.state.columnCount, e = new Array(t), a = n.default.Children.toArray(this.props.children);
725
- for (let o = 0; o < a.length; o++) {
726
- const i = o % t;
727
- e[i] || (e[i] = []), e[i].push(a[o]);
728
- }
729
- return e;
730
- }
731
- renderColumns() {
732
- const { column: t, columnAttrs: e = {}, columnClassName: a } = this.props, o = this.itemsInColumns(), i = `${100 / o.length}%`;
733
- let l = a;
734
- l && typeof l != "string" && (this.logDeprecated("The property \"columnClassName\" requires a string"), typeof l > "u" && (l = "my-masonry-grid_column"));
735
- const d = ke(ke(ke({}, t), e), {}, {
736
- style: ke(ke({}, e.style), {}, { width: i }),
737
- className: l
738
- });
739
- return o.map((g, f) => n.default.createElement("div", De({}, d, { key: f }), g));
740
- }
741
- logDeprecated(t) {}
742
- render() {
743
- const t = this.props, { children: e, breakpointCols: a, columnClassName: o, columnAttrs: i, column: l, className: d } = t, g = Ot(t, [
744
- "children",
745
- "breakpointCols",
746
- "columnClassName",
747
- "columnAttrs",
748
- "column",
749
- "className"
750
- ]);
751
- let f = d;
752
- return typeof d != "string" && (this.logDeprecated("The property \"className\" requires a string"), typeof d > "u" && (f = "my-masonry-grid")), n.default.createElement("div", De({}, g, { className: f }), this.renderColumns());
753
- }
754
- };
755
- Ne.defaultProps = Bt;
756
- function Ge(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: a, createController: o }) {
766
- const [i, l] = (0, n.useState)({}), d = (0, n.useRef)(new Map()), g = (0, n.useCallback)((f) => {
767
- const C = e(f), I = a(f), w = `${C}:${I}`;
768
- if (d.current.has(w)) return {
769
- itemId: C,
770
- requestUrl: I,
771
- cacheKey: w,
772
- controller: d.current.get(w)
773
- };
774
- const b = o(I);
775
- return d.current.set(w, b), {
776
- itemId: C,
777
- requestUrl: I,
778
- cacheKey: w,
779
- controller: b
780
- };
781
- }, [
782
- o,
783
- e,
784
- a
785
- ]);
786
- return (0, n.useEffect)(() => {
787
- const f = new Set(), C = {}, I = t.map((w) => {
788
- const { itemId: b, cacheKey: R, controller: v } = g(w);
789
- f.add(R), C[b] = v.src;
790
- const L = Ge(v.handleChangeSrc?.(), v.src);
791
- return L?.changed && L.src && (C[b] = L.src), v.subscribeToSrcChange?.((A) => {
792
- const G = Ge(A, v.src);
793
- !G?.changed || !G.src || l((O) => O[b] === G.src ? O : {
794
- ...O,
795
- [b]: G.src
796
- });
797
- });
798
- }).filter(Boolean);
799
- return d.current.forEach((w, b) => {
800
- f.has(b) || d.current.delete(b);
801
- }), l(C), () => {
802
- I.forEach((w) => w?.());
803
- };
804
- }, [g, t]), {
805
- getDisplaySrc: (0, n.useCallback)((f) => {
806
- const { itemId: C, requestUrl: I, controller: w } = g(f);
807
- return i[C] || w.src || I;
808
- }, [i, g]),
809
- handleLoad: (0, n.useCallback)((f) => {
810
- g(f).controller.handleSuccess();
811
- }, [g]),
812
- handleError: (0, n.useCallback)((f) => {
813
- const { itemId: C, controller: I } = g(f), w = Ge(I.handleError(), I.src);
814
- w?.changed && w.src && l((b) => ({
815
- ...b,
816
- [C]: w.src
817
- }));
818
- }, [g])
819
- };
820
- }
821
- var rt = "blocks", Ut = ({ setCurrentImageLink: t, setModalHeight: e, setModalWidth: a, setImageStockList: o, imageStockList: i, currentReq: l, setCurrentReq: d, inputRef: g, setStockLink: f, customRequest: C }) => {
822
- const I = u.useAppConfig(), w = u.useIsStandalone(), [b, R] = (0, n.useState)(!1), [v, L] = (0, n.useState)(2), { __: A } = p.useI18n(), G = p.useNotification(), [O] = Z.useLazyGetUnsplashImageQuery(), [D] = Z.useLazyGetSearchImageQuery(), H = (0, n.useCallback)((s) => s instanceof Error || typeof s?.message == "string" && s.message ? s.message : typeof s?.error?.message == "string" && s.error.message ? s.error.message : A("Failed to load stock images through the configured proxy chain."), [A]), B = (0, n.useCallback)((s) => {
823
- G.error({
824
- id: "STOCK_IMAGES_SEARCH_FAILED",
825
- title: A("Failed to load stock images"),
826
- description: H(s)
827
- });
828
- }, [
829
- A,
830
- H,
831
- G
832
- ]), z = async () => {
833
- b || (R(!0), D({
834
- query: l,
835
- page: v
836
- }).then((s) => {
837
- if (s?.error) {
838
- B(s.error), R(!1);
839
- return;
840
- }
841
- const y = s?.data?.results || [];
842
- o((K) => [...K, ...y]), R(!1), L((K) => K + 1);
843
- }).catch(() => {
844
- R(!1);
845
- }));
846
- };
847
- (0, n.useEffect)(() => {
848
- l.keywords !== "" && V();
849
- }, [l.color, l.orientation]);
850
- const V = async () => {
851
- const s = await D({
852
- query: l,
853
- page: 1
854
- });
855
- if (s?.error) {
856
- B(s.error), o([]);
857
- return;
858
- }
859
- const y = s?.data?.results || [];
860
- y.length > 0 ? (o(y), setTimeout(() => {
861
- a(1060), e("84vh");
862
- }, 0)) : o([]);
863
- }, [ee, q] = (0, n.useState)(null), j = (0, n.useCallback)((s, y, K) => `${s}${s.includes("?") ? "&" : "?"}w=${y}&q=${K}`, []), P = (0, n.useCallback)((s) => u.getProxiedUrl(s, {
864
- config: I,
865
- standalone: w,
866
- resourceType: "stockImages",
867
- intent: "display"
868
- }), [I, w]), { getDisplaySrc: E, handleLoad: x, handleError: S } = nt({
869
- items: i,
870
- getItemId: (0, n.useCallback)((s) => s.id, []),
871
- getRequestUrl: (0, n.useCallback)((s) => j(s.urls.raw, 644, 96), [j]),
872
- createController: P
873
- }), U = (s) => (y) => {
874
- x(s), y.target.parentNode.classList.add("loaded");
875
- }, _ = (s) => () => {
876
- S(s);
877
- }, W = (s, y, K) => {
878
- O(y.download_location), q(K), setTimeout(() => q(null), 2e3), f(`${s.raw}&w=1200&q=96`), t(`${s.raw}&w=1200&q=96`), C(`${s.raw}&w=1200&q=96`);
879
- };
880
- return (0, r.jsxs)("div", {
881
- className: "stock-tab",
882
- children: [(0, r.jsxs)(p.Form, {
883
- onValuesChange: V,
884
- className: i.length > 0 ? "serach-results" : "",
885
- children: [(0, r.jsxs)(p.Row, {
886
- gutter: 24,
887
- children: [(0, r.jsx)(p.Col, {
888
- span: i.length > 0 ? "" : 24,
889
- children: (0, r.jsx)(p.Form.Item, {
890
- className: "stock-search-input",
891
- children: (0, r.jsx)(p.SearchInput, {
892
- onSearch: V,
893
- allowClear: !0,
894
- size: i.length > 0 ? "medium" : "large",
895
- placeholder: A("Search image"),
896
- value: l.keywords,
897
- onChange: (s) => d((y) => ({
898
- ...y,
899
- keywords: s.target.value
900
- })),
901
- ref: g,
902
- spellCheck: "false",
903
- enterButton: !1
904
- })
905
- })
906
- }), i.length > 0 && (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)(p.Col, { children: (0, r.jsxs)(p.Radio.Group, {
907
- defaultValue: "",
908
- onChange: (s) => d((y) => ({
909
- ...y,
910
- orientation: s.target.value
911
- })),
912
- children: [
913
- (0, r.jsx)(p.Tooltip, {
914
- title: A("All"),
915
- placement: "top",
916
- children: (0, r.jsx)(p.Radio.Button, {
917
- value: "",
918
- children: (0, r.jsx)(N.EmIcons, { icon: "MixedView" })
919
- })
920
- }),
921
- (0, r.jsx)(p.Tooltip, {
922
- title: A("Landscape"),
923
- placement: "top",
924
- children: (0, r.jsx)(p.Radio.Button, {
925
- value: "landscape",
926
- children: (0, r.jsx)(N.EmIcons, { icon: "LandscapeView" })
927
- })
928
- }),
929
- (0, r.jsx)(p.Tooltip, {
930
- title: A("Portrait"),
931
- placement: "top",
932
- children: (0, r.jsx)(p.Radio.Button, {
933
- value: "portrait",
934
- children: (0, r.jsx)(N.EmIcons, { icon: "PortraitView" })
935
- })
936
- }),
937
- (0, r.jsx)(p.Tooltip, {
938
- title: A("Squarish"),
939
- placement: "top",
940
- children: (0, r.jsx)(p.Radio.Button, {
941
- value: "squarish",
942
- children: (0, r.jsx)(N.EmIcons, { icon: "SquareView" })
943
- })
944
- })
945
- ]
946
- }) }), (0, r.jsx)(p.Col, { children: (0, r.jsx)(p.RadioColorFilter, {
947
- defaultValue: "",
948
- onChange: (s) => d((y) => ({
949
- ...y,
950
- color: s.target.value
951
- })),
952
- options: [
953
- {
954
- value: "",
955
- colorClass: "all-colors",
956
- label: A("All")
957
- },
958
- {
959
- value: "black",
960
- colorClass: "black-color",
961
- label: A("Black")
962
- },
963
- {
964
- value: "black_and_white",
965
- colorClass: "bw-color",
966
- label: A("Black and White")
967
- },
968
- {
969
- value: "white",
970
- colorClass: "white-color",
971
- label: A("White")
972
- },
973
- {
974
- value: "orange",
975
- colorClass: "orange-color",
976
- label: A("Orange")
977
- },
978
- {
979
- value: "red",
980
- colorClass: "red-color",
981
- label: A("Red")
982
- },
983
- {
984
- value: "purple",
985
- colorClass: "purple-color",
986
- label: A("Purple")
987
- },
988
- {
989
- value: "magenta",
990
- colorClass: "magenta-color",
991
- label: A("Magenta")
992
- },
993
- {
994
- value: "green",
995
- colorClass: "green-color",
996
- label: A("Green")
997
- },
998
- {
999
- value: "teal",
1000
- colorClass: "teal-color",
1001
- label: A("Teal")
1002
- },
1003
- {
1004
- value: "blue",
1005
- colorClass: "blue-color",
1006
- label: A("Blue")
1007
- }
1008
- ],
1009
- tooltipPlacement: "top"
1010
- }) })] })]
1011
- }), i.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: i.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: i && i.length,
1036
- next: z,
1037
- hasMore: i,
1038
- endMessage: (0, r.jsxs)(p.Divider, {
1039
- plain: !0,
1040
- children: [A("That`s all we could find."), " 🤐"]
1041
- }),
1042
- scrollableTarget: "scrollableDiv",
1043
- style: { overflow: "visible" },
1044
- loader: null,
1045
- children: (0, r.jsx)(Ne, {
1046
- breakpointCols: { default: 3 },
1047
- className: "my-masonry-grid",
1048
- columnClassName: "my-masonry-grid_column",
1049
- children: i.map((s) => (0, r.jsxs)("div", {
1050
- className: "list-item",
1051
- onClick: () => W(s.urls, s.links, s.id),
1052
- children: [
1053
- (0, r.jsx)("img", {
1054
- className: ee === s.id ? "loaded-image" : "",
1055
- width: "322px",
1056
- src: E(s),
1057
- alt: s.description,
1058
- onLoad: U(s),
1059
- onError: _(s)
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: `${s.user.links.html}?utm_source=${rt}&utm_medium=referral`,
1070
- rel: "noreferrer",
1071
- children: s.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
- ee === s.id && (0, r.jsx)(p.Spin, {
1085
- className: "ant-spin",
1086
- size: "small"
1087
- })
1088
- ]
1089
- }, s.id))
1090
- })
1091
- })
1092
- })
1093
- })]
1094
- });
1095
- };
1096
- function st(t) {
1097
- return /^(https?:)?\/\//i.test(t.trim());
1098
- }
1099
- function Mt(t) {
1100
- const e = t.trim();
1101
- return st(e) || /^data:/i.test(e) ? e : `data:image/jpeg;base64, ${t}`;
1102
- }
1103
- var Pt = ({ images: t, transitionDuration: e = 1e3 }) => {
1104
- const [a, o] = (0, n.useState)([]);
1105
- return (0, n.useEffect)(() => {
1106
- if (t.length > 0) {
1107
- const i = t[t.length - 1];
1108
- o((l) => [...l, {
1109
- src: i,
1110
- opacity: 0
1111
- }]), setTimeout(() => {
1112
- o((l) => l.map((d, g) => g === l.length - 1 ? {
1113
- ...d,
1114
- opacity: 1
1115
- } : d));
1116
- }, 1e3);
1117
- }
1118
- }, [t]), (0, r.jsx)("div", {
1119
- className: "slideshow-container",
1120
- children: a.map((i, l) => (0, r.jsx)("img", {
1121
- src: Mt(i.src),
1122
- alt: `Slide ${l + 1}`,
1123
- className: "slideshow-image",
1124
- style: {
1125
- opacity: i.opacity,
1126
- transition: `opacity ${e}ms linear`
1127
- }
1128
- }, l))
1129
- });
1130
- };
1131
- function Tt({ setModalHeight: t, customRequest: e, aiTabRef: a, isImageUploaded: o, setIsImageUploaded: i, aiImageRequest: l, imageAiList: d, setImageAiList: g, isLoadingAi: f, setIsLoadingAi: C, onPluginAiImageLimitExceeded: I, onImageGenerateLimitExceeded: w }) {
1132
- const { __: b } = p.useI18n(), R = u.useAppConfig(), v = p.useNotification(), L = u.usePushToDataLayer(), { emailId: A, blockId: G, projectId: O } = u.useParams(), [D] = Z.useLazySendAiImageRequestQuery(), [H, { data: B = [] }] = Z.useLazyGetAiImageSSEQuery(), [z] = Z.useLazyGetLimitsStatsByTypeQuery(), V = R?.sendAIImageRequest || D, ee = R?.trigger || H, q = R?.handleLimitUsageEmitter || u.useEventEmitter(u.events.ON_LIMIT_ID), [j, P] = (0, n.useState)(0), [E, x] = (0, n.useState)(null), [S, U] = (0, n.useState)(!1), [_, W] = (0, n.useState)(b("Evaluating the task")), [s, y] = (0, n.useState)(!1), K = A || G, { limits: me } = R?.limits ? R : { limits: { ai_img_limit: 0 } }, { ai_img_limit: T } = me, J = !!(R.limits && R.counters) && u.PLUGIN.isPlugin, $ = u.useEventEmitter(u.events.AI_IMAGE_REQUEST_ID).hasListeners(), F = ne.shouldCountAiUsage({
1133
- limitsInPlugin: J,
1134
- hostedAiActive: $
1135
- }), he = !$ && T > 0 && j >= T, ie = (0, n.useCallback)(() => {
1136
- q.fire({
1137
- name: "AiImgCount",
1138
- count: j + 1
1139
- });
1140
- }, [q, j]), pe = (0, n.useMemo)(() => !he && (!F || T === 0 || j < T), [
1141
- he,
1142
- F,
1143
- j,
1144
- T
1145
- ]), Ae = (0, n.useCallback)(async () => {
1146
- W(b("Evaluating the task")), l !== "" && !f && (C(!0), y(!0), g([]), L({
1147
- event: "submit_form",
1148
- action: "ai_image_generation",
1149
- entity_id: A,
1150
- project_id: O
1151
- }), V({ body: {
1152
- project_id: O,
1153
- request: "create-image",
1154
- connection: "midjourney",
1155
- message: l
1156
- } }).then(({ data: h, error: te }) => {
1157
- if (te) throw te;
1158
- if (h.data.status === 401) throw new Error(u.ERROR);
1159
- if (h?.data?._eventResult) {
1160
- g(h.data.task.images), C(!1), y(!1), W(b("Evaluating the task"));
1161
- return;
1162
- }
1163
- h?.data.status === 200 ? (h?.data.task.id && (W(h.data.task.message), x(h.data.task.id)), h.message && v.success({
1164
- id: "AI_IMAGE_SEND_SUCCESS",
1165
- title: h.message,
1166
- placement: "bottomRight",
1167
- data: l
1168
- }), ee({
1169
- task_id: h?.data.task.id,
1170
- entity_id: K
1171
- })) : (C(!1), y(!1), v.error({
1172
- id: "AI_IMAGE_SEND_ERROR",
1173
- title: h?.message || b("Something went wrong, please try again"),
1174
- placement: "bottomRight",
1175
- data: l,
1176
- innerException: h
1177
- }));
1178
- }).catch((h) => {
1179
- C(!1), y(!1), (h?.error || h?.data) && v.fromError("AI_IMAGE_SEND_ERROR", l, h.error || h);
1180
- }));
1181
- }, [
1182
- l,
1183
- f,
1184
- C,
1185
- y,
1186
- g,
1187
- L,
1188
- A,
1189
- O,
1190
- V,
1191
- v,
1192
- ee,
1193
- K,
1194
- b
1195
- ]), Y = (0, n.useCallback)(async () => {
1196
- if (pe) {
1197
- if (!u.PLUGIN.isPlugin && !$) {
1198
- const h = N.resolveLimitActionPreflightExceededForType("image_generate", (await z("image_generate")).data?.stats);
1199
- if (h) {
1200
- w?.(h);
1201
- return;
1202
- }
1203
- }
1204
- F && (P((h) => h + 1), ie()), Ae();
1205
- } else J && (I ? I() : v.error({
1206
- title: b("The usage limit has been exceeded"),
1207
- description: b(`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
- pe,
1213
- J,
1214
- $,
1215
- F,
1216
- z,
1217
- w,
1218
- P,
1219
- ie,
1220
- Ae,
1221
- v,
1222
- b,
1223
- I
1224
- ]);
1225
- (0, n.useEffect)(() => {
1226
- J && P(R?.counters?.ai_img_counter || 0);
1227
- }, [R, J]);
1228
- const re = u.useEventEmitter(u.events.AI_IMAGE_PROGRESS_ID);
1229
- (0, n.useEffect)(() => {
1230
- const h = re.event(({ progress: te, status: X }) => {
1231
- W(X || `${Math.round(te)}%`);
1232
- });
1233
- return () => h.dispose();
1234
- }, [re]);
1235
- const M = (0, n.useCallback)(async (h) => {
1236
- if (!o) {
1237
- i(!0);
1238
- try {
1239
- const te = st(h) ? await (await fetch(h)).blob() : Je(h);
1240
- e({ file: new File([te], "image.jpeg", { type: te.type || "image/jpeg" }) });
1241
- } catch {
1242
- i(!1);
1243
- }
1244
- }
1245
- }, [
1246
- o,
1247
- i,
1248
- e
1249
- ]), ae = (0, n.useCallback)((h) => {
1250
- h.status !== "error" && h.status !== "Canceled" ? h.images ? (W(h.status), h.progress === 100 && (g(h.images), W(b("Evaluating the task")), x(null), y(!1))) : (g([h.data]), C(!1)) : (C(!1), y(!1), v.error({
1251
- id: "AI_IMAGE_GET_ERROR",
1252
- title: b("Something went wrong, please try again"),
1253
- placement: "bottomRight",
1254
- data: E
1255
- }));
1256
- }, [
1257
- g,
1258
- W,
1259
- b,
1260
- C,
1261
- t,
1262
- E,
1263
- v,
1264
- y
1265
- ]);
1266
- return (0, n.useEffect)(() => {
1267
- B.length > 1 && ae(B[B.length - 1]);
1268
- }, [B, ae]), (0, n.useEffect)(() => {
1269
- (f || d.length > 0) && setTimeout(() => {
1270
- let h = 550;
1271
- a.current && (h = a.current.offsetHeight + 68), t(h);
1272
- }, 0);
1273
- }, [
1274
- a,
1275
- B,
1276
- d.length,
1277
- f,
1278
- t
1279
- ]), {
1280
- aiImageCounter: j,
1281
- setAiImageCounter: P,
1282
- currentAiImgLimits: T,
1283
- isFieldsDisabled: he,
1284
- canGenerateImage: pe,
1285
- aiImageRequest: l,
1286
- imageAiList: d,
1287
- setImageAiList: g,
1288
- isLoadingAi: f,
1289
- setIsLoadingAi: C,
1290
- loadingDuringGeneration: s,
1291
- setLoadingDuringGeneration: y,
1292
- requestStatus: _,
1293
- setRequestStatus: W,
1294
- handleGenerate: Y,
1295
- handleLimitAiImgCount: ie,
1296
- convertBase64ToFile: M,
1297
- isShiftPressed: S,
1298
- setIsShiftPressed: U,
1299
- currentReqId: E,
1300
- setCurrentReqId: x,
1301
- limitsInPlugin: J
1302
- };
1303
- }
1304
- var Nt = ({ setModalHeight: t, customRequest: e, aiTabRef: a, inputAiRef: o, isImageUploaded: i, setIsImageUploaded: l, aiImageRequest: d, setAiImageRequest: g, imageAiList: f, setImageAiList: C, isLoadingAi: I, setIsLoadingAi: w }) => {
1305
- const b = u.useNavigate(), R = u.useDispatch(), { __: v, _n: L } = p.useI18n(), A = u.useAppConfig(), [G, O] = (0, n.useState)(!1), [D, H] = (0, n.useState)(null), { aiImageCounter: B, currentAiImgLimits: z, loadingDuringGeneration: V, requestStatus: ee, handleGenerate: q, convertBase64ToFile: j, isShiftPressed: P, setIsShiftPressed: E, limitsInPlugin: x } = Tt({
1306
- setModalHeight: t,
1307
- customRequest: e,
1308
- aiTabRef: a,
1309
- isImageUploaded: i,
1310
- setIsImageUploaded: l,
1311
- aiImageRequest: d,
1312
- imageAiList: f,
1313
- setImageAiList: C,
1314
- isLoadingAi: I,
1315
- setIsLoadingAi: w,
1316
- onPluginAiImageLimitExceeded: () => O(!0),
1317
- onImageGenerateLimitExceeded: H
1318
- }), S = G && z > 0 ? ne.getAiTariffUpgradeStep(z) : null, U = S ? N.getLimitUpgradePresetDefinition(S.presetId) : null, _ = D ? N.getLimitUpgradePresetDefinition(D.presetId) : null, [W, s] = (0, n.useState)(!1), y = (0, n.useCallback)(() => s(!0), []), K = (0, n.useCallback)(() => s(!1), []), me = (0, n.useCallback)((F) => g(F.target.value), [g]), T = (0, n.useCallback)((F) => {
1319
- F.key === "Shift" ? E(!0) : F.key === "Enter" && !P && (F.preventDefault(), q());
1320
- }, [
1321
- P,
1322
- q,
1323
- E
1324
- ]), J = (0, n.useCallback)((F) => {
1325
- F.key === "Shift" && E(!1);
1326
- }, [E]), $ = f[f.length - 1];
1327
- return (0, r.jsxs)("div", {
1328
- className: "image-ai",
1329
- children: [
1330
- U && S ? (0, r.jsx)(N.LimitUpgradeModal, {
1331
- open: !0,
1332
- onClose: () => O(!1),
1333
- title: v(U.titleKey),
1334
- subtitle: v(U.subtitleKey),
1335
- usageResource: U.usageResource,
1336
- previousDisplay: N.presetLimitDisplay(S.previousLimit),
1337
- nextDisplay: N.presetLimitDisplay(S.nextLimit),
1338
- onChangePlan: () => {
1339
- O(!1), document.body.classList.remove("editor"), b("/billing"), R(Z.openModal(u.MODALS.SWITCH_TO_PLAN_MODAL));
1340
- }
1341
- }) : null,
1342
- _ && D ? (0, r.jsx)(N.LimitUpgradeModal, {
1343
- open: !0,
1344
- onClose: () => H(null),
1345
- title: v(_.titleKey),
1346
- subtitle: v(_.subtitleKey),
1347
- usageResource: _.usageResource,
1348
- previousDisplay: N.presetLimitDisplay(D.previousLimit),
1349
- nextDisplay: N.presetLimitDisplay(D.nextLimit),
1350
- onChangePlan: () => {
1351
- H(null), document.body.classList.remove("editor"), b("/billing"), R(Z.openModal(u.MODALS.SWITCH_TO_PLAN_MODAL));
1352
- }
1353
- }) : null,
1354
- x && (0, r.jsx)(p.LimitsCounter, {
1355
- text: `${B} ${v("of")} ${z > 0 ? z : "∞"} images ${L("was used", "were used", B)}`,
1356
- exceeded: z > 0 && B >= z,
1357
- style: { marginTop: -25 },
1358
- extra: (0, r.jsx)("span", {
1359
- style: {
1360
- textDecoration: "underline",
1361
- cursor: "pointer"
1362
- },
1363
- onClick: () => b(A.billingPageUrl || u.APP_ROUTES.billing),
1364
- children: v("Need more?")
1365
- })
1366
- }),
1367
- (0, r.jsx)(p.Row, {
1368
- gutter: 24,
1369
- className: "image-ai__row",
1370
- children: (0, r.jsx)(p.Col, {
1371
- span: 24,
1372
- children: (0, r.jsx)(p.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${W ? " ant-input-affix-wrapper-focused" : ""}`,
1376
- children: [(0, r.jsx)(p.TextArea, {
1377
- ref: o,
1378
- onKeyDown: T,
1379
- onKeyUp: J,
1380
- onFocus: y,
1381
- onBlur: K,
1382
- autoSize: !0,
1383
- allowClear: !0,
1384
- className: "text-area-input-hybrid image-ai__textarea",
1385
- placeholder: v("Generate image"),
1386
- value: d,
1387
- onChange: me,
1388
- spellCheck: "false"
1389
- }), (0, r.jsx)("span", {
1390
- className: "ant-input-suffix image-ai__input-suffix",
1391
- children: I || V ? (0, r.jsx)(N.EmIcons, {
1392
- icon: "LoadingOutlined",
1393
- className: "input-icon image-ai__input-icon",
1394
- spin: !0
1395
- }) : (0, r.jsx)(N.EmIcons, {
1396
- icon: "AI",
1397
- className: "input-icon image-ai__input-icon",
1398
- onClick: q
1399
- })
1400
- })]
1401
- })
1402
- })
1403
- })
1404
- }),
1405
- (I || f.length > 0) && (0, r.jsxs)("div", {
1406
- className: "image-ai__preview",
1407
- children: [I && f.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)(N.EmIcons, {
1412
- icon: "LoadingOutlined",
1413
- style: { fontSize: 48 },
1414
- spin: !0
1415
- }), (0, r.jsx)("p", {
1416
- className: "status",
1417
- children: ee
1418
- })]
1419
- })
1420
- }), f.length > 0 && (0, r.jsxs)("div", {
1421
- className: "image-ai__image-item",
1422
- children: [(0, r.jsx)(Pt, { images: f }), (0, r.jsx)("div", {
1423
- className: "buttons",
1424
- children: (0, r.jsx)(p.Button, {
1425
- onClick: () => j($),
1426
- icon: (0, r.jsx)(N.EmIcons, { icon: "CheckOutlined" }),
1427
- children: v("Use this one")
1428
- })
1429
- })]
1430
- })]
1431
- })
1432
- ]
1433
- });
1434
- }, Gt = ({ setNewLink: t, setCurrentImageLink: e, setModalHeight: a, setModalWidth: o, setImageGifList: i, imageGifList: l, currentReqGif: d, setCurrentReqGif: g, inputRef: f, setStockLink: C, customRequest: I }) => {
1435
- const { __: w } = p.useI18n(), b = u.useAppConfig(), R = u.useIsStandalone(), v = p.useNotification(), [L, A] = (0, n.useState)(null), [G, O] = (0, n.useState)(!1), [D, H] = (0, n.useState)(25), [B] = Z.useLazyGetSearchGifQuery(), z = (0, n.useCallback)((s) => s instanceof Error || typeof s?.message == "string" && s.message ? s.message : typeof s?.error?.message == "string" && s.error.message ? s.error.message : w("Failed to load GIFs through the configured proxy chain."), [w]), V = (0, n.useCallback)((s) => {
1436
- v.error({
1437
- id: "STOCK_GIFS_SEARCH_FAILED",
1438
- title: w("Failed to load GIFs"),
1439
- description: z(s)
1440
- });
1441
- }, [
1442
- w,
1443
- z,
1444
- v
1445
- ]), ee = async () => {
1446
- G || (O(!0), B({
1447
- query: d,
1448
- page: D
1449
- }).then((s) => {
1450
- if (s?.error) {
1451
- V(s.error), O(!1);
1452
- return;
1453
- }
1454
- i((y) => [...y, ...s.data.data]), O(!1), H((y) => y + 25);
1455
- }).catch(() => {
1456
- O(!1);
1457
- }));
1458
- }, q = async () => {
1459
- const s = await B({
1460
- query: d,
1461
- page: 0
1462
- });
1463
- if (s?.error) {
1464
- V(s.error), i([]);
1465
- return;
1466
- }
1467
- s?.data?.data?.length > 0 && (i(s.data.data), setTimeout(() => {
1468
- a("84vh"), o(1060);
1469
- }, 0));
1470
- }, j = (s, y) => {
1471
- A(y), setTimeout(() => {
1472
- A(null);
1473
- }, 2e3), C(`${s}`), e(`${s}`), I(`${s}`);
1474
- }, P = { default: 3 }, E = (0, n.useCallback)((s) => u.getProxiedUrl(s, {
1475
- config: b,
1476
- standalone: R,
1477
- resourceType: "generic",
1478
- intent: "display"
1479
- }), [b, R]), { getDisplaySrc: x, handleLoad: S, handleError: U } = nt({
1480
- items: l,
1481
- getItemId: (0, n.useCallback)((s) => s.id, []),
1482
- getRequestUrl: (0, n.useCallback)((s) => s.images.downsized.url, []),
1483
- createController: E
1484
- }), _ = (s) => (y) => {
1485
- S(s), y.target.parentNode.classList.add("loaded");
1486
- }, W = (s) => () => {
1487
- U(s);
1488
- };
1489
- return (0, r.jsxs)("div", {
1490
- className: "stock-tab",
1491
- children: [(0, r.jsxs)(p.Form, {
1492
- onValuesChange: q,
1493
- className: l.length > 0 ? "serach-results" : "",
1494
- children: [(0, r.jsx)(p.Row, {
1495
- gutter: 24,
1496
- children: (0, r.jsx)(p.Col, {
1497
- span: l.length > 0 ? "" : 24,
1498
- children: (0, r.jsx)(p.Form.Item, {
1499
- className: "stock-search-input",
1500
- children: (0, r.jsx)(p.SearchInput, {
1501
- onSearch: q,
1502
- allowClear: !0,
1503
- size: l.length > 0 ? "medium" : "large",
1504
- placeholder: w("Search GIFs"),
1505
- value: d.keywords,
1506
- onChange: (s) => g((y) => ({
1507
- ...y,
1508
- keywords: s.target.value
1509
- })),
1510
- ref: f,
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: ee,
1542
- hasMore: l,
1543
- endMessage: (0, r.jsxs)(p.Divider, {
1544
- plain: !0,
1545
- children: [w("That`s all we could find."), " 🤐"]
1546
- }),
1547
- scrollableTarget: "scrollableDiv",
1548
- style: { overflow: "visible" },
1549
- loader: (0, r.jsx)(p.Spin, { size: "small" }),
1550
- children: (0, r.jsx)(Ne, {
1551
- breakpointCols: P,
1552
- className: "my-masonry-grid",
1553
- columnClassName: "my-masonry-grid_column",
1554
- children: l.map((s, y) => (0, r.jsxs)("div", {
1555
- className: "list-item",
1556
- onClick: () => j(s.images.downsized.url, s.id),
1557
- children: [
1558
- (0, r.jsx)("img", {
1559
- className: L === s.id ? "loaded-image" : "",
1560
- width: "322px",
1561
- src: x(s),
1562
- alt: s.title,
1563
- onLoad: _(s),
1564
- onError: W(s)
1565
- }),
1566
- (0, r.jsx)("a", {
1567
- rel: "noreferrer",
1568
- href: "https://giphy.com/",
1569
- target: "_blank",
1570
- onClick: (K) => K.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
- L === s.id && (0, r.jsx)(p.Spin, {
1577
- className: "ant-spin",
1578
- size: "small"
1579
- })
1580
- ]
1581
- }, s.id + y))
1582
- })
1583
- })
1584
- })
1585
- })]
1586
- });
1587
- };
1588
- function Ft(t) {
1589
- if (!(t == null || t === "")) return t;
1590
- }
1591
- async function zt(t, e) {
1592
- if (t) {
1593
- if (t.url) return t.url;
1594
- if (typeof e.getFileById == "function" && t.id) {
1595
- const a = await e.getFileById(t.id);
1596
- if (a?.url) return a.url;
1597
- if (a?.thumbnailUrl) return a.thumbnailUrl;
1598
- if (a?.thumbnail) return a.thumbnail;
1599
- }
1600
- if (typeof e.getFileUrl == "function" && t.folderId !== void 0 && t.name) {
1601
- const a = await e.getFileUrl(t.folderId || "", t.name);
1602
- if (a) return a;
1603
- }
1604
- if (typeof e.getUrl == "function" && t.name) {
1605
- const a = await e.getUrl(t);
1606
- if (a) return a;
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 Kt(t, e, a) {
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 ?? a ?? "",
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 Ht(t, e, a) {
1635
- if (!e) return;
1636
- const o = Ft(a ?? e.rootId);
1637
- let i;
1638
- typeof e.uploadFiles == "function" ? i = Wt(await e.uploadFiles({
1639
- folderId: o,
1640
- items: [{
1641
- name: t.name,
1642
- size: t.size,
1643
- type: t.type,
1644
- folderId: o,
1645
- data: t
1646
- }]
1647
- })) : typeof e.uploadFile == "function" && (i = Kt(await e.uploadFile({
1648
- name: t.name,
1649
- size: t.size,
1650
- type: t.type,
1651
- folderId: o,
1652
- data: t
1653
- }), t, o));
1654
- const l = await zt(i, e);
1655
- return l ? {
1656
- item: i,
1657
- url: l
1658
- } : void 0;
1659
- }
1660
- var at = "IMG", ot = "BACKGROUND", Vt = "GALLERY", we = "EDITOR", fe = "UPLOAD", Fe = "STOCK", ze = "GIF", We = "AI", qt = { mode: "select" }, Qt = { mode: "save" }, { Dragger: _t } = p.Upload, Yt = (t, e = "image") => Z.decodeFileNameFromUrl(t) ?? e, Ee = ne.normalizeImageFormatForDisplay, Zt = (t, e) => {
1661
- const a = Ee(e);
1662
- return !a || t.includes(".") ? t : `${t}.${a}`;
1663
- }, Xt = (t, e) => new File([t], Zt(Yt(e), t.type), { type: t.type || "application/octet-stream" }), it = ({ dataProvider: t }) => {
1664
- const e = u.useAppConfig(), a = u.useIsStandalone(), { __: o } = p.useI18n(), i = u.useDispatch(), { projectId: l } = u.useParams(), [d] = Z.useLazyGetImageInfoQuery(), { modal: g } = p.App.useApp(), f = p.useNotification(), C = u.useSelector(Z.selectActiveModal), { request: I, resolveImagePicker: w } = N.useImagePicker(), [b, R] = (0, n.useState)(""), [v, L] = (0, n.useState)(""), [A, G] = (0, n.useState)(""), [O, D] = (0, n.useState)(""), [H, B] = (0, n.useState)(fe), [z, V] = (0, n.useState)({
1665
- width: "",
1666
- height: "",
1667
- size: "",
1668
- format: ""
1669
- }), [ee, q] = (0, n.useState)("success"), [j, P] = (0, n.useState)(!1), E = n.default.useRef(null), x = n.default.useRef(null), S = n.default.useRef(null), U = n.default.useRef(null), _ = n.default.useRef(null), W = n.default.useRef(null), s = n.default.useRef(null), y = n.default.useRef(null), K = n.default.useRef(null), [me, T] = (0, n.useState)("auto"), [J, $] = (0, n.useState)(572), [F, he] = (0, n.useState)(!1), [ie, pe] = (0, n.useState)({
1670
- keywords: "",
1671
- color: "",
1672
- orientation: ""
1673
- }), [Ae, Y] = (0, n.useState)({ keywords: "" }), [re, M] = (0, n.useState)([]), [ae, h] = (0, n.useState)([]), [te, X] = (0, n.useState)([]), [ue, lt] = (0, n.useState)(!1), [ct, Ke] = (0, n.useState)(""), [Jt, je] = (0, n.useState)(!1), [$t, Be] = (0, n.useState)(0), He = u.useSelector(u.selectProject), ut = He?.id !== void 0 ? String(He.id) : l || "", dt = u.useEventEmitter(u.events.UPLOAD_EVENT_ID), xe = n.default.useRef(ne.createImageUrlBlobResolver()), Ve = n.default.useRef(""), Ce = n.default.useRef(0), Ie = n.default.useRef(""), [en, ft] = (0, n.useState)(""), [tn, mt] = (0, n.useState)(null), [nn, qe] = (0, n.useState)(""), Ue = (0, n.useCallback)((c) => {
1674
- if (!(c instanceof Blob)) return;
1675
- Ie.current && URL.revokeObjectURL(Ie.current);
1676
- const m = URL.createObjectURL(c);
1677
- Ie.current = m, ft(m), mt(c);
1678
- }, []), ge = (0, n.useCallback)(() => {
1679
- Ie.current && (URL.revokeObjectURL(Ie.current), Ie.current = ""), ft(""), mt(null);
1680
- }, []), le = (0, n.useCallback)(() => {
1681
- qe("");
1682
- }, []), ye = N.isEditorLockedByPlan(He, { isPlugin: u.PLUGIN.isPlugin }), rn = (c) => {
1683
- L(c.target.value);
1684
- }, Me = (0, n.useCallback)((c, m, k = o("The image could not be uploaded.")) => {
1685
- const Q = m instanceof Error ? m.message : k;
1686
- f.error({
1687
- id: "IMAGE_UPLOAD_ERROR",
1688
- data: c,
1689
- title: o("Upload failed"),
1690
- description: Q
1691
- });
1692
- }, [o, f]), sn = (0, n.useCallback)(async (c) => N.pickUploadImageUrlFromFireResults(await dt.fire({
1693
- file: c,
1694
- project: ut
1695
- })), [ut, dt]), be = ne.useImageBlobFetch(), an = (0, n.useCallback)((c) => xe.current.resolve(ne.canonicalImageUrlKey(c), void 0, be), [be]), Pe = async (c) => {
1696
- if (c) try {
1697
- const m = await on(c);
1698
- m && _e(m) ? await Oe({ file: m }) : m || Me({ url: c }, null, o("Failed to download image from URL."));
1699
- } catch (m) {
1700
- Me({ url: c }, m, o("Failed to process image URL."));
1701
- }
1702
- }, pt = n.default.useRef(Pe);
1703
- pt.current = Pe, n.default.useEffect(() => {
1704
- if (H !== fe || !O) return;
1705
- const c = v.trim();
1706
- if (!c || !c.toLowerCase().startsWith("http")) return;
1707
- const m = setTimeout(() => {
1708
- pt.current(c);
1709
- }, 1e3);
1710
- return () => {
1711
- clearTimeout(m);
1712
- };
1713
- }, [
1714
- v,
1715
- H,
1716
- O
1717
- ]);
1718
- const on = async (c) => {
1719
- try {
1720
- const m = ne.canonicalImageUrlKey(c);
1721
- return Xt(await xe.current.resolve(m, void 0, be), m);
1722
- } catch {}
1723
- };
1724
- document.onpaste = function(c) {
1725
- const m = c.clipboardData?.items?.[0];
1726
- if (H === fe && O) {
1727
- if (m?.type?.indexOf("image") === 0 && e.imageCenterLocalUploadEnabled !== !1) {
1728
- const Q = m.getAsFile();
1729
- _e(Q);
1730
- const oe = { file: Q };
1731
- L(""), Oe(oe);
1732
- return;
1733
- }
1734
- const k = c.clipboardData?.getData("text/plain");
1735
- if (k && k.trim().toLowerCase().startsWith("http")) {
1736
- c.preventDefault(), c.stopPropagation(), L(k.trim());
1737
- return;
1738
- }
1739
- m?.type?.indexOf("text") === 0 && m.getAsString((Q) => {
1740
- if (Q.trim().toLowerCase().startsWith("http")) L(Q.trim());
1741
- else if (Q.toString().slice(1, 5) === "meta") {
1742
- const oe = Q.toString().split("\"")[1];
1743
- oe && L(oe);
1744
- }
1745
- });
1746
- }
1747
- }, (0, n.useEffect)(() => {
1748
- const c = (m) => {
1749
- let k = null;
1750
- I?.kind === "background" ? (k = ot, D(ot)) : I?.kind === "img" && (D(at), k = at), I?.currentUrl && k && (R(I.currentUrl), B(m));
1751
- };
1752
- C === u.MODALS.UPLOAD_IMAGE_MODAL || C === u.MODALS.UPLOAD_BACKGROUND_MODAL ? c(we) : C === u.MODALS.UPLOAD_IMAGE_MODAL_AI || C === u.MODALS.UPLOAD_BACKGROUND_MODAL_AI ? (ye ? (je(!0), Be(2)) : c(We), setTimeout(() => K.current?.focus({ cursor: "start" }), 100)) : C === u.MODALS.UPLOAD_IMAGE_MODAL_UPLOAD || C === u.MODALS.UPLOAD_BACKGROUND_MODAL_UPLOAD ? (c(fe), setTimeout(() => W.current?.focus({ cursor: "start" }), 100)) : C === u.MODALS.UPLOAD_IMAGE_MODAL_STOCK || C === u.MODALS.UPLOAD_BACKGROUND_MODAL_STOCK ? (ye ? (je(!0), Be(3)) : c(Fe), setTimeout(() => y.current?.focus({ cursor: "start" }), 100)) : C === u.MODALS.UPLOAD_IMAGE_MODAL_GIF || C === u.MODALS.UPLOAD_BACKGROUND_MODAL_GIF ? (ye ? (je(!0), Be(3)) : c(ze), setTimeout(() => s.current?.focus({ cursor: "start" }), 100)) : C === u.MODALS.UPLOAD_IMAGE_MODAL_EDIT || C === u.MODALS.UPLOAD_BACKGROUND_MODAL_EDIT ? (ye ? (je(!0), Be(5)) : c(we), i(Z.openSecondModal(u.MODALS.IMAGE_EDITOR_MODAL))) : D("");
1753
- }, [
1754
- C,
1755
- i,
1756
- ye,
1757
- I
1758
- ]);
1759
- const Qe = (0, n.useCallback)(({ url: c = b || "", meta: m = qt }) => {
1760
- R(c), w({
1761
- url: c,
1762
- meta: m
1763
- }), setTimeout(() => {
1764
- le(), ge(), pe({
1765
- keywords: "",
1766
- color: "",
1767
- orientation: ""
1768
- }), Y({ keywords: "" }), h([]), M([]), D(""), Ke(""), lt(!1), G(""), L(""), B(fe);
1769
- }, 200), i(Z.closeModal()), i(Z.closeSecondModal());
1770
- }, [
1771
- b,
1772
- le,
1773
- i,
1774
- w,
1775
- ge
1776
- ]), gt = (0, n.useCallback)((c, m) => (T("auto"), P(!1), Qe({
1777
- url: c,
1778
- meta: Qt
1779
- }), f.success({
1780
- id: "IMAGE_UPLOAD_SUCCESS",
1781
- data: m,
1782
- title: o("The image was successfully uploaded.")
1783
- }), c), [
1784
- o,
1785
- Qe,
1786
- f
1787
- ]);
1788
- (0, n.useEffect)(() => {
1789
- const c = v || A, m = ne.canonicalImageUrlKey(c);
1790
- if (!c || !m) {
1791
- q(""), Ve.current = "", le(), ge(), xe.current.invalidateAll();
1792
- return;
1793
- }
1794
- const k = Ve.current;
1795
- k && k !== m && (xe.current.abandonKey(k), le(), ge()), Ve.current = m;
1796
- const Q = new AbortController(), oe = v ? 800 : 0, se = ++Ce.current, Ye = setTimeout(async () => {
1797
- try {
1798
- const Se = async () => {
1799
- const de = await xe.current.resolve(m, Q.signal, be);
1800
- if (se !== Ce.current) return;
1801
- const { width: ve, height: dn } = await ne.getImageDimensionsFromBlob(de);
1802
- se === Ce.current && (V({
1803
- width: ve,
1804
- height: dn,
1805
- size: (de.size / 1024).toFixed(2),
1806
- format: Ee(de.type)
1807
- }), le(), Ue(de));
1808
- };
1809
- if (a) await Se();
1810
- else {
1811
- const de = await ne.resolveDataProviderPreview(t, m);
1812
- if (de?.previewUrl && se === Ce.current) {
1813
- qe(de.previewUrl), ge();
1814
- try {
1815
- const { data: ve } = await d(m);
1816
- if (se !== Ce.current) return;
1817
- ve ? V({
1818
- width: ve?.width,
1819
- height: ve?.height,
1820
- size: ve?.fileSize != null ? (ve.fileSize / 1024).toFixed(2) : "",
1821
- format: Ee(ve?.format)
1822
- }) : await Se();
1823
- } catch {
1824
- await Se();
1825
- }
1826
- } else await Se();
1827
- }
1828
- if (se !== Ce.current) return;
1829
- q("success"), R(c), $(572), setTimeout(() => {
1830
- let de = 0;
1831
- x.current && (de = x.current.offsetHeight + 62), T(de);
1832
- }, 0);
1833
- } catch (Se) {
1834
- if (Se?.name === "AbortError" || Q.signal.aborted || se !== Ce.current) return;
1835
- le(), ge(), q("error");
1836
- }
1837
- }, oe);
1838
- return () => {
1839
- clearTimeout(Ye), Q.abort();
1840
- };
1841
- }, [
1842
- v,
1843
- A,
1844
- a,
1845
- le,
1846
- be,
1847
- d,
1848
- ge,
1849
- t,
1850
- Ue
1851
- ]), (0, n.useEffect)(() => {
1852
- if (!b || v || A) return;
1853
- const c = ne.canonicalImageUrlKey(b), m = new AbortController();
1854
- let k = !1;
1855
- const Q = async () => {
1856
- const oe = await xe.current.resolve(c, m.signal, be);
1857
- if (k) return;
1858
- const { width: se, height: Ye } = await ne.getImageDimensionsFromBlob(oe);
1859
- k || (le(), Ue(oe), V({
1860
- width: se,
1861
- height: Ye,
1862
- size: (oe.size / 1024).toFixed(2),
1863
- format: Ee(oe.type)
1864
- }));
1865
- };
1866
- return (async () => {
1867
- try {
1868
- if (!a) {
1869
- const oe = await ne.resolveDataProviderPreview(t, c);
1870
- if (oe?.previewUrl && !k) {
1871
- qe(oe.previewUrl), ge();
1872
- try {
1873
- const { data: se } = await d(c);
1874
- if (k) return;
1875
- se ? V({
1876
- width: se?.width,
1877
- height: se?.height,
1878
- size: se?.fileSize != null ? (se.fileSize / 1024).toFixed(2) : "",
1879
- format: Ee(se?.format)
1880
- }) : await Q();
1881
- return;
1882
- } catch {
1883
- await Q();
1884
- }
1885
- }
1886
- }
1887
- await Q();
1888
- } catch {
1889
- k || le();
1890
- }
1891
- })(), () => {
1892
- k = !0, m.abort();
1893
- };
1894
- }, [
1895
- a,
1896
- le,
1897
- b,
1898
- be,
1899
- d,
1900
- t,
1901
- v,
1902
- A,
1903
- Ue
1904
- ]);
1905
- const ln = () => {
1906
- i(Z.closeModal()), setTimeout(() => {
1907
- le(), ge(), R(""), L(""), h([]), h([]), pe({
1908
- keywords: "",
1909
- color: "",
1910
- orientation: ""
1911
- }), Y({ keywords: "" }), T("auto"), !ue && Ke(""), $(572), B(fe);
1912
- }, 200);
1913
- }, cn = (c) => {
1914
- c === Vt ? g.success({
1915
- mask: { closable: !0 },
1916
- centered: !0,
1917
- title: o("Coming soon"),
1918
- content: o("The feature is under development."),
1919
- okText: o("Ok. I'll be waiting"),
1920
- onOk: () => {}
1921
- }) : c === we && b === "" ? g.warning({
1922
- mask: { closable: !0 },
1923
- centered: !0,
1924
- title: o(""),
1925
- content: o("To preview and edit the uploaded image"),
1926
- okText: o("Upload Image"),
1927
- onOk: () => {
1928
- B(fe);
1929
- }
1930
- }) : (setTimeout(() => {
1931
- let m = 0, k = 0;
1932
- c === fe && E.current ? (ie.keywords === "" && W.current?.focus({ cursor: "start" }), m = 300, k = 572) : c === we && x.current ? (m = x.current.offsetHeight + 62, k = 572) : c === Fe && S.current ? (ie.keywords === "" && y.current?.focus({ cursor: "start" }), m = 130, k = 572, ae.length > 0 && (k = 1060, m = "84vh")) : c === ze && U.current ? (ie.keywords === "" && s.current?.focus({ cursor: "start" }), m = 130, k = 572, re.length > 0 && (k = 1060, m = "84vh")) : c === We && _.current && (ct === "" && te.length === 0 ? (K.current?.focus({ cursor: "start" }), m = 130) : m = _.current.offsetHeight + 82, k = 572), T(m), $(k);
1933
- }, 0), B(c));
1934
- };
1935
- (0, n.useEffect)(() => {
1936
- ie.keywords === "" && (W?.current?.focus({ cursor: "start" }), h([]), setTimeout(() => {
1937
- T("auto"), $(572);
1938
- }, 0));
1939
- }, [
1940
- ie,
1941
- h,
1942
- T,
1943
- $
1944
- ]);
1945
- const _e = (c) => {
1946
- const m = 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";
1947
- return m || f.error({
1948
- id: "IMAGE_UPLOAD_WRONG_FORMAT",
1949
- data: c,
1950
- title: "Upload",
1951
- description: "You can only upload JPG/JPEG/PNG/WEBP/GIF/SVG file!"
1952
- }), m;
1953
- }, Oe = async ({ file: c }) => {
1954
- try {
1955
- he(!0);
1956
- const m = await ne.prepareImageForEditorUpload(c, e), k = await sn(m);
1957
- if (k) return gt(k, m), k;
1958
- const Q = await Ht(m, t);
1959
- if (Q?.url) return gt(Q.url, m), Q.url;
1960
- Me(m, null);
1961
- return;
1962
- } catch (m) {
1963
- Me(c, m);
1964
- return;
1965
- } finally {
1966
- he(!1);
1967
- }
1968
- }, un = (c) => Oe({ file: c });
1969
- let Le = [{
1970
- label: o("Upload"),
1971
- key: fe,
1972
- children: (0, r.jsxs)("div", {
1973
- ref: E,
1974
- style: { paddingBottom: 24 },
1975
- children: [e.imageCenterLocalUploadEnabled !== !1 && (0, r.jsxs)(_t, {
1976
- showUploadList: !1,
1977
- name: "Image",
1978
- beforeUpload: _e,
1979
- customRequest: Oe,
1980
- style: { marginBottom: 10 },
1981
- multiple: !1,
1982
- accept: "image/png, image/jpeg, image/jpg, image/webp, image/gif, image/svg+xml",
1983
- children: [
1984
- (0, r.jsx)("p", {
1985
- className: "ant-upload-drag-icon",
1986
- children: (0, r.jsx)(N.EmIcons, { icon: "InboxOutlined" })
1987
- }),
1988
- (0, r.jsx)("p", {
1989
- className: "ant-upload-text",
1990
- children: o("Click to select, paste from the clipboard, or drag and drop")
1991
- }),
1992
- (0, r.jsx)("p", {
1993
- className: "ant-upload-hint",
1994
- children: o("Accepted formats: PNG, JPG, WEBP, SVG or GIF.")
1995
- })
1996
- ]
1997
- }), (0, r.jsx)(p.Form, {
1998
- style: { padding: "0 2px 0 2px" },
1999
- children: (0, r.jsx)(p.Form.Item, {
2000
- validateStatus: ee,
2001
- children: (0, r.jsx)(p.Input, {
2002
- ref: W,
2003
- allowClear: !0,
2004
- size: "large",
2005
- placeholder: o("Paste image URL here"),
2006
- value: v,
2007
- onChange: rn,
2008
- spellCheck: "false"
2009
- })
2010
- })
2011
- })]
2012
- })
2013
- }];
2014
- return e.imageCenterStockEnabled && !ye && Le.push({
2015
- label: o("Stock"),
2016
- key: Fe,
2017
- children: (0, r.jsx)("div", {
2018
- ref: S,
2019
- style: { paddingBottom: 24 },
2020
- children: (0, r.jsx)(Ut, {
2021
- currentReq: ie,
2022
- setCurrentReq: pe,
2023
- imageStockList: ae,
2024
- setImageStockList: h,
2025
- setModalWidth: $,
2026
- setModalHeight: T,
2027
- setStockLink: G,
2028
- setCurrentImageLink: R,
2029
- inputRef: y,
2030
- customRequest: Pe
2031
- })
2032
- })
2033
- }), e.imageCenterGifEnabled && !ye && Le.push({
2034
- label: o("GIF"),
2035
- key: ze,
2036
- children: (0, r.jsx)("div", {
2037
- ref: U,
2038
- style: { paddingBottom: 24 },
2039
- children: (0, r.jsx)(Gt, {
2040
- currentReqGif: Ae,
2041
- setCurrentReqGif: Y,
2042
- imageGifList: re,
2043
- setImageGifList: M,
2044
- setModalWidth: $,
2045
- setModalHeight: T,
2046
- setStockLink: G,
2047
- setCurrentImageLink: R,
2048
- inputRef: s,
2049
- customRequest: Pe
2050
- })
2051
- })
2052
- }), e.elementAIimageEnabled && !ye && Le.push({
2053
- label: o("AI"),
2054
- key: We,
2055
- children: (0, r.jsx)("div", {
2056
- ref: _,
2057
- style: { paddingBottom: 24 },
2058
- children: (0, r.jsx)(Nt, {
2059
- setModalHeight: T,
2060
- customRequest: Oe,
2061
- aiImageRequest: ct,
2062
- setAiImageRequest: Ke,
2063
- imageAiList: te,
2064
- setImageAiList: X,
2065
- isLoadingAi: ue,
2066
- setIsLoadingAi: lt,
2067
- aiTabRef: _,
2068
- inputAiRef: K,
2069
- isImageUploaded: j,
2070
- setIsImageUploaded: P
2071
- })
2072
- })
2073
- }), e.imageCenterEditorEnabled && Le.push({
2074
- label: "",
2075
- key: we,
2076
- children: (0, r.jsx)("div", {
2077
- ref: x,
2078
- children: (0, r.jsx)(kt, {
2079
- currentImageLink: b,
2080
- newLink: v,
2081
- previewDisplayUrl: nn,
2082
- resolvedPreviewObjectUrl: en,
2083
- resolvedPreviewBlob: tn,
2084
- resolveImageBlob: an,
2085
- imageSize: z,
2086
- onSave: un,
2087
- uploadImageResultIsLoading: F || !1
2088
- })
2089
- })
2090
- }), (0, r.jsxs)(r.Fragment, { children: [(0, r.jsx)(p.Modal, {
2091
- width: J,
2092
- className: "image-center",
2093
- title: o("Image Center"),
2094
- style: { minHeight: 390 },
2095
- open: !!O,
2096
- onOk: Qe,
2097
- onCancel: ln,
2098
- footer: H === we ? (0, r.jsx)(r.Fragment, {}) : null,
2099
- children: (0, r.jsx)(p.Spin, {
2100
- spinning: F,
2101
- children: (0, r.jsx)(p.Tabs, {
2102
- activeKey: H,
2103
- onChange: cn,
2104
- items: Le,
2105
- className: "modal-tabs",
2106
- style: {
2107
- height: me,
2108
- minHeight: 130
2109
- }
2110
- })
2111
- })
2112
- }), (0, r.jsx)(N.PlanUpgradePrompt, {
2113
- open: Jt,
2114
- onCancel: () => je(!1),
2115
- initialSlide: $t
2116
- })] });
2117
- };
2118
- it.propTypes = { dataProvider: vt.default.object }, ht.default = it;
2119
- });