img-upload-kit 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/LICENSE +21 -0
  3. package/MIGRATION.md +192 -0
  4. package/README.md +242 -2
  5. package/dist/bin.js +1186 -0
  6. package/dist/bin.js.map +1 -0
  7. package/dist/blur.cjs +41 -0
  8. package/dist/blur.cjs.map +1 -0
  9. package/dist/blur.d.cts +17 -0
  10. package/dist/blur.d.ts +17 -0
  11. package/dist/blur.js +41 -0
  12. package/dist/blur.js.map +1 -0
  13. package/dist/blurDataUtils-DveBRtqE.d.cts +43 -0
  14. package/dist/blurDataUtils-yx9Q6HlU.d.ts +43 -0
  15. package/dist/blurService-D5TpMNji.d.ts +83 -0
  16. package/dist/blurService-DacwylJx.d.cts +83 -0
  17. package/dist/chunk-2OVNXHTN.cjs +514 -0
  18. package/dist/chunk-2OVNXHTN.cjs.map +1 -0
  19. package/dist/chunk-3ICG2SLL.cjs +135 -0
  20. package/dist/chunk-3ICG2SLL.cjs.map +1 -0
  21. package/dist/chunk-4ASFG3KB.js +514 -0
  22. package/dist/chunk-4ASFG3KB.js.map +1 -0
  23. package/dist/chunk-AI3JJLSA.js +2370 -0
  24. package/dist/chunk-AI3JJLSA.js.map +1 -0
  25. package/dist/chunk-CV23O4YU.js +145 -0
  26. package/dist/chunk-CV23O4YU.js.map +1 -0
  27. package/dist/chunk-G7LLSKBV.js +158 -0
  28. package/dist/chunk-G7LLSKBV.js.map +1 -0
  29. package/dist/chunk-IB3TEDLR.js +294 -0
  30. package/dist/chunk-IB3TEDLR.js.map +1 -0
  31. package/dist/chunk-KJVYWKIG.cjs +158 -0
  32. package/dist/chunk-KJVYWKIG.cjs.map +1 -0
  33. package/dist/chunk-NEDBIIE3.cjs +226 -0
  34. package/dist/chunk-NEDBIIE3.cjs.map +1 -0
  35. package/dist/chunk-QHU7FUO4.cjs +37 -0
  36. package/dist/chunk-QHU7FUO4.cjs.map +1 -0
  37. package/dist/chunk-QQHZJKNA.js +135 -0
  38. package/dist/chunk-QQHZJKNA.js.map +1 -0
  39. package/dist/chunk-S2IFAWJK.js +37 -0
  40. package/dist/chunk-S2IFAWJK.js.map +1 -0
  41. package/dist/chunk-TT5C7K3Q.js +226 -0
  42. package/dist/chunk-TT5C7K3Q.js.map +1 -0
  43. package/dist/chunk-U2TWTEBY.cjs +2370 -0
  44. package/dist/chunk-U2TWTEBY.cjs.map +1 -0
  45. package/dist/chunk-WISG74VL.cjs +294 -0
  46. package/dist/chunk-WISG74VL.cjs.map +1 -0
  47. package/dist/chunk-YRXXQUDE.cjs +145 -0
  48. package/dist/chunk-YRXXQUDE.cjs.map +1 -0
  49. package/dist/cli.cjs +1241 -0
  50. package/dist/cli.cjs.map +1 -0
  51. package/dist/cli.d.cts +99 -0
  52. package/dist/cli.d.ts +99 -0
  53. package/dist/cli.js +1194 -0
  54. package/dist/cli.js.map +1 -0
  55. package/dist/headless.cjs +27 -0
  56. package/dist/headless.cjs.map +1 -0
  57. package/dist/headless.d.cts +4 -0
  58. package/dist/headless.d.ts +4 -0
  59. package/dist/headless.js +27 -0
  60. package/dist/headless.js.map +1 -0
  61. package/dist/index-BIdnqtW8.d.ts +234 -0
  62. package/dist/index-Brk_uHs6.d.cts +234 -0
  63. package/dist/index-CPMlaQsC.d.ts +635 -0
  64. package/dist/index-DHINe-rA.d.cts +635 -0
  65. package/dist/index.cjs +65 -0
  66. package/dist/index.cjs.map +1 -0
  67. package/dist/index.d.cts +43 -0
  68. package/dist/index.d.ts +43 -0
  69. package/dist/index.js +65 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/memoryAdapter-Ck0ccZbF.d.cts +25 -0
  72. package/dist/memoryAdapter-DxEKaG0b.d.ts +25 -0
  73. package/dist/placeholders-C4ftwaII.d.ts +5 -0
  74. package/dist/placeholders-x_3rt65M.d.cts +5 -0
  75. package/dist/react.cjs +3779 -0
  76. package/dist/react.cjs.map +1 -0
  77. package/dist/react.d.cts +476 -0
  78. package/dist/react.d.ts +476 -0
  79. package/dist/react.js +3779 -0
  80. package/dist/react.js.map +1 -0
  81. package/dist/server-handler.cjs +14 -0
  82. package/dist/server-handler.cjs.map +1 -0
  83. package/dist/server-handler.d.cts +3 -0
  84. package/dist/server-handler.d.ts +3 -0
  85. package/dist/server-handler.js +14 -0
  86. package/dist/server-handler.js.map +1 -0
  87. package/dist/server.cjs +1801 -0
  88. package/dist/server.cjs.map +1 -0
  89. package/dist/server.d.cts +142 -0
  90. package/dist/server.d.ts +142 -0
  91. package/dist/server.js +1801 -0
  92. package/dist/server.js.map +1 -0
  93. package/dist/storage.cjs +447 -0
  94. package/dist/storage.cjs.map +1 -0
  95. package/dist/storage.d.cts +163 -0
  96. package/dist/storage.d.ts +163 -0
  97. package/dist/storage.js +447 -0
  98. package/dist/storage.js.map +1 -0
  99. package/dist/styles/animated-image.css +112 -0
  100. package/dist/styles/dropzone-and-tiles.css +247 -0
  101. package/dist/styles/modals-and-dock.css +248 -0
  102. package/dist/styles/primitives.css +197 -0
  103. package/dist/styles/quality-and-inputs.css +184 -0
  104. package/dist/styles/tokens.css +123 -0
  105. package/dist/styles.css +1122 -0
  106. package/dist/types-BrP-o9nd.d.cts +85 -0
  107. package/dist/types-sZ3KoFQY.d.ts +85 -0
  108. package/dist/types-yShGNQnW.d.cts +61 -0
  109. package/dist/types-yShGNQnW.d.ts +61 -0
  110. package/dist/upload-C5Trd6Dh.d.cts +154 -0
  111. package/dist/upload-C5Trd6Dh.d.ts +154 -0
  112. package/package.json +198 -4
package/dist/react.cjs ADDED
@@ -0,0 +1,3779 @@
1
+ 'use client';
2
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3
+
4
+
5
+ var _chunkWISG74VLcjs = require('./chunk-WISG74VL.cjs');
6
+
7
+
8
+ var _chunk3ICG2SLLcjs = require('./chunk-3ICG2SLL.cjs');
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ var _chunkU2TWTEBYcjs = require('./chunk-U2TWTEBY.cjs');
47
+
48
+
49
+
50
+
51
+ var _chunkKJVYWKIGcjs = require('./chunk-KJVYWKIG.cjs');
52
+
53
+
54
+
55
+
56
+ var _chunkNEDBIIE3cjs = require('./chunk-NEDBIIE3.cjs');
57
+
58
+ // src/react/hooks/index.ts
59
+ var _react = require('react');
60
+
61
+ // src/react/hooks/useBlurService.ts
62
+
63
+ function useBlurDataURL(imageSrc, options = {}) {
64
+ const { type = "default", size = "small" } = options;
65
+ return _react.useMemo.call(void 0, () => {
66
+ if (!imageSrc) return _chunkWISG74VLcjs.DEFAULT_PLACEHOLDERS[type];
67
+ return _chunkWISG74VLcjs.blurService.getBlurDataURL(imageSrc, { type, size });
68
+ }, [imageSrc, type, size]);
69
+ }
70
+ function useBulkBlurData(imageSrcs, options = {}) {
71
+ const { type = "default", size = "small" } = options;
72
+ return _react.useMemo.call(void 0, () => {
73
+ return _chunkWISG74VLcjs.blurService.getBulkBlurData(imageSrcs, { type, size });
74
+ }, [imageSrcs, type, size]);
75
+ }
76
+ function useProgressiveBlur(imageSrc, size = "small") {
77
+ return _react.useMemo.call(void 0, () => {
78
+ if (!imageSrc) {
79
+ return {
80
+ color: "#E5E7EB",
81
+ blur: _chunkWISG74VLcjs.DEFAULT_PLACEHOLDERS.default,
82
+ hasBlur: false
83
+ };
84
+ }
85
+ return _chunkWISG74VLcjs.blurService.getProgressiveData(imageSrc, size);
86
+ }, [imageSrc, size]);
87
+ }
88
+ function useHasBlurHash(imageSrc) {
89
+ return _react.useMemo.call(void 0, () => {
90
+ if (!imageSrc) return false;
91
+ return _chunkWISG74VLcjs.blurService.hasBlurHash(imageSrc);
92
+ }, [imageSrc]);
93
+ }
94
+ function useDominantColor(imageSrc) {
95
+ return _react.useMemo.call(void 0, () => {
96
+ if (!imageSrc) return "#E5E7EB";
97
+ return _chunkWISG74VLcjs.blurService.getDominantColor(imageSrc);
98
+ }, [imageSrc]);
99
+ }
100
+ function useBlurMetadata() {
101
+ return _react.useMemo.call(void 0, () => {
102
+ return _chunkWISG74VLcjs.blurService.getMetadata();
103
+ }, []);
104
+ }
105
+ function useBlurHash(imageSrc) {
106
+ return _react.useMemo.call(void 0, () => {
107
+ if (!imageSrc) return null;
108
+ return _chunkWISG74VLcjs.blurService.getBlurHash(imageSrc);
109
+ }, [imageSrc]);
110
+ }
111
+ function useBlurDataWithColor(imageSrc, size = "small") {
112
+ return _react.useMemo.call(void 0, () => {
113
+ if (!imageSrc) {
114
+ return {
115
+ blurDataUrl: _chunkWISG74VLcjs.DEFAULT_PLACEHOLDERS.default,
116
+ blurColor: "#E5E7EB",
117
+ hasBlur: false
118
+ };
119
+ }
120
+ const progressive = _chunkWISG74VLcjs.blurService.getProgressiveData(imageSrc, size);
121
+ return {
122
+ blurDataUrl: progressive.blur,
123
+ blurColor: progressive.color,
124
+ hasBlur: progressive.hasBlur
125
+ };
126
+ }, [imageSrc, size]);
127
+ }
128
+ function useBlurVariant(imageSrc, size = "small", type = "default") {
129
+ return _react.useMemo.call(void 0, () => {
130
+ if (!imageSrc) return _chunkWISG74VLcjs.DEFAULT_PLACEHOLDERS[type];
131
+ return _chunkWISG74VLcjs.blurService.getBlurDataURL(imageSrc, { type, size });
132
+ }, [imageSrc, size, type]);
133
+ }
134
+
135
+ // src/react/hooks/useDialog.ts
136
+
137
+ var FOCUSABLE_SELECTOR = [
138
+ "button:not(:disabled)",
139
+ "[href]",
140
+ 'input:not(:disabled):not([type="hidden"])',
141
+ "select:not(:disabled)",
142
+ "textarea:not(:disabled)",
143
+ '[tabindex]:not([tabindex="-1"])'
144
+ ].join(", ");
145
+ function useDialog({
146
+ isOpen,
147
+ onClose,
148
+ initialFocusRef,
149
+ lockScroll = true
150
+ }) {
151
+ const dialogRef = _react.useRef.call(void 0, null);
152
+ const onCloseRef = _react.useRef.call(void 0, onClose);
153
+ onCloseRef.current = onClose;
154
+ const titleId = _react.useId.call(void 0, );
155
+ const descriptionId = _react.useId.call(void 0, );
156
+ _react.useEffect.call(void 0, () => {
157
+ if (!isOpen || typeof document === "undefined") return;
158
+ const previouslyFocused = document.activeElement instanceof HTMLElement ? document.activeElement : null;
159
+ const prevOverflow = document.body.style.overflow;
160
+ if (lockScroll) {
161
+ document.body.style.overflow = "hidden";
162
+ }
163
+ const focusInitial = () => {
164
+ const container = dialogRef.current;
165
+ if (!container) return;
166
+ if (_optionalChain([initialFocusRef, 'optionalAccess', _ => _.current])) {
167
+ initialFocusRef.current.focus();
168
+ return;
169
+ }
170
+ if (document.activeElement && container.contains(document.activeElement)) {
171
+ return;
172
+ }
173
+ const focusables = Array.from(
174
+ container.querySelectorAll(FOCUSABLE_SELECTOR)
175
+ );
176
+ if (focusables.length > 0) {
177
+ focusables[0].focus();
178
+ } else {
179
+ container.focus();
180
+ }
181
+ };
182
+ focusInitial();
183
+ const handleKeyDown = (event) => {
184
+ if (event.key === "Escape" && onCloseRef.current) {
185
+ event.stopPropagation();
186
+ onCloseRef.current();
187
+ return;
188
+ }
189
+ if (event.key !== "Tab") return;
190
+ const container = dialogRef.current;
191
+ if (!container) return;
192
+ const focusables = Array.from(
193
+ container.querySelectorAll(FOCUSABLE_SELECTOR)
194
+ );
195
+ if (focusables.length === 0) {
196
+ event.preventDefault();
197
+ return;
198
+ }
199
+ const first = focusables[0];
200
+ const last = focusables[focusables.length - 1];
201
+ const active = document.activeElement;
202
+ if (event.shiftKey) {
203
+ if (!active || active === first || !container.contains(active)) {
204
+ event.preventDefault();
205
+ last.focus();
206
+ }
207
+ } else if (!active || active === last || !container.contains(active)) {
208
+ event.preventDefault();
209
+ first.focus();
210
+ }
211
+ };
212
+ document.addEventListener("keydown", handleKeyDown);
213
+ return () => {
214
+ document.removeEventListener("keydown", handleKeyDown);
215
+ if (lockScroll) {
216
+ document.body.style.overflow = prevOverflow;
217
+ }
218
+ if (previouslyFocused && typeof previouslyFocused.focus === "function") {
219
+ try {
220
+ previouslyFocused.focus();
221
+ } catch (e2) {
222
+ }
223
+ }
224
+ };
225
+ }, [isOpen, lockScroll, initialFocusRef]);
226
+ return {
227
+ dialogRef,
228
+ titleId,
229
+ descriptionId
230
+ };
231
+ }
232
+
233
+ // src/react/hooks/index.ts
234
+ var useProgressiveImage = useProgressiveBlur;
235
+ function useBlurPreload(imageSrcs, size = "small") {
236
+ _react.useEffect.call(void 0, () => {
237
+ if (imageSrcs.length > 0) {
238
+ _chunkWISG74VLcjs.blurService.preloadBlurData(imageSrcs, size);
239
+ }
240
+ }, [imageSrcs, size]);
241
+ }
242
+
243
+ // src/react/icons.tsx
244
+ var _jsxruntime = require('react/jsx-runtime');
245
+ function createIcon(name, nodes) {
246
+ const Icon = ({
247
+ size = 24,
248
+ strokeWidth = 2,
249
+ color = "currentColor",
250
+ className,
251
+ children,
252
+ ...rest
253
+ }) => {
254
+ const labelled = rest["aria-label"] !== void 0 || rest["aria-labelledby"] !== void 0;
255
+ const baseClass = `iuk-icon iuk-icon--${name}`;
256
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
257
+ "svg",
258
+ {
259
+ xmlns: "http://www.w3.org/2000/svg",
260
+ width: size,
261
+ height: size,
262
+ viewBox: "0 0 24 24",
263
+ fill: "none",
264
+ stroke: color,
265
+ strokeWidth,
266
+ strokeLinecap: "round",
267
+ strokeLinejoin: "round",
268
+ className: className ? `${baseClass} ${className}` : baseClass,
269
+ "aria-hidden": labelled ? void 0 : true,
270
+ focusable: "false",
271
+ ...rest,
272
+ children: [
273
+ nodes.map(([Tag, attrs], index) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tag, { ...attrs }, index)),
274
+ children
275
+ ]
276
+ }
277
+ );
278
+ };
279
+ Icon.displayName = `Icon(${name})`;
280
+ return Icon;
281
+ }
282
+ var p = (d) => ["path", { d }];
283
+ var c = (cx2, cy, r, fill) => {
284
+ const attrs = { cx: cx2, cy, r };
285
+ if (fill) attrs.fill = fill;
286
+ return ["circle", attrs];
287
+ };
288
+ var UPLOAD_TRAY = "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4";
289
+ var UploadIcon = createIcon("upload", [
290
+ p("M12 3v12"),
291
+ p("m17 8-5-5-5 5"),
292
+ p(UPLOAD_TRAY)
293
+ ]);
294
+ var DownloadIcon = createIcon("download", [
295
+ p("M12 15V3"),
296
+ p(UPLOAD_TRAY),
297
+ p("m7 10 5 5 5-5")
298
+ ]);
299
+ var ImagePlusIcon = createIcon("image-plus", [
300
+ p("M16 5h6"),
301
+ p("M19 2v6"),
302
+ p("M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5"),
303
+ p("m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"),
304
+ c("9", "9", "2")
305
+ ]);
306
+ var XIcon = createIcon("x", [p("M18 6 6 18"), p("m6 6 12 12")]);
307
+ var CheckIcon = createIcon("check", [p("M20 6 9 17l-5-5")]);
308
+ var MinusIcon = createIcon("minus", [p("M5 12h14")]);
309
+ var LoaderIcon = createIcon("loader", [
310
+ p("M21 12a9 9 0 1 1-6.219-8.56")
311
+ ]);
312
+ var ChevronUpIcon = createIcon("chevron-up", [p("m18 15-6-6-6 6")]);
313
+ var ChevronDownIcon = createIcon("chevron-down", [p("m6 9 6 6 6-6")]);
314
+ var AlertTriangleIcon = createIcon("alert-triangle", [
315
+ p("m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"),
316
+ p("M12 9v4"),
317
+ p("M12 17h.01")
318
+ ]);
319
+ var SaveIcon = createIcon("save", [
320
+ p(
321
+ "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"
322
+ ),
323
+ p("M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"),
324
+ p("M7 3v4a1 1 0 0 0 1 1h7")
325
+ ]);
326
+ var EyeIcon = createIcon("eye", [
327
+ p(
328
+ "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"
329
+ ),
330
+ c("12", "12", "3")
331
+ ]);
332
+ var InfoIcon = createIcon("info", [
333
+ c("12", "12", "10"),
334
+ p("M12 16v-4"),
335
+ p("M12 8h.01")
336
+ ]);
337
+ var ZapIcon = createIcon("zap", [
338
+ p(
339
+ "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"
340
+ )
341
+ ]);
342
+ var CheckCircleIcon = createIcon("check-circle", [
343
+ c("12", "12", "10"),
344
+ p("m9 12 2 2 4-4")
345
+ ]);
346
+ var XCircleIcon = createIcon("x-circle", [
347
+ c("12", "12", "10"),
348
+ p("m15 9-6 6"),
349
+ p("m9 9 6 6")
350
+ ]);
351
+ var TypeIcon = createIcon("type", [
352
+ p("M12 4v16"),
353
+ p("M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"),
354
+ p("M9 20h6")
355
+ ]);
356
+ var FolderOpenIcon = createIcon("folder-open", [
357
+ p(
358
+ "m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"
359
+ )
360
+ ]);
361
+ var PenToolIcon = createIcon("pen-tool", [
362
+ p(
363
+ "M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z"
364
+ ),
365
+ p(
366
+ "m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18"
367
+ ),
368
+ p("m2.3 2.3 7.286 7.286"),
369
+ c("11", "11", "2")
370
+ ]);
371
+ var WandIcon = createIcon("wand", [
372
+ p(
373
+ "m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72"
374
+ ),
375
+ p("m14 7 3 3"),
376
+ p("M5 6v4"),
377
+ p("M19 14v4"),
378
+ p("M10 2v2"),
379
+ p("M7 8H3"),
380
+ p("M21 16h-4"),
381
+ p("M11 3H9")
382
+ ]);
383
+ var TrashIcon = createIcon("trash", [
384
+ p("M10 11v6"),
385
+ p("M14 11v6"),
386
+ p("M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"),
387
+ p("M3 6h18"),
388
+ p("M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2")
389
+ ]);
390
+ var PaletteIcon = createIcon("palette", [
391
+ p(
392
+ "M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"
393
+ ),
394
+ c("13.5", "6.5", ".5", "currentColor"),
395
+ c("17.5", "10.5", ".5", "currentColor"),
396
+ c("6.5", "12.5", ".5", "currentColor"),
397
+ c("8.5", "7.5", ".5", "currentColor")
398
+ ]);
399
+
400
+ // src/react/components/AltTextInput.tsx
401
+
402
+
403
+ function AltTextInput({
404
+ value,
405
+ onChange,
406
+ disabled = false,
407
+ placeholder,
408
+ maxLength = 200,
409
+ label,
410
+ showHint = true,
411
+ locale: propLocale,
412
+ translations,
413
+ unstyled: propUnstyled
414
+ }) {
415
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
416
+ const isUnstyled = _nullishCoalesce(propUnstyled, () => ( ctx.unstyled));
417
+ const locale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, propLocale || ctx.locale);
418
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, locale, translations || ctx.translations);
419
+ const resolvedPlaceholder = placeholder || ui.describeImagePlaceholder;
420
+ const resolvedLabel = label || ui.addImageDescription;
421
+ const inputId = _react.useId.call(void 0, );
422
+ const hintId = showHint ? `${inputId}-hint` : void 0;
423
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
424
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
425
+ "div",
426
+ {
427
+ "data-slot": "alt-input",
428
+ "data-unstyled": isUnstyled || void 0,
429
+ className: cls("iuk-alt-input"),
430
+ dir: locale === "ar" ? "rtl" : "ltr",
431
+ children: [
432
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-alt-input__header"), children: [
433
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TypeIcon, { size: 16 }),
434
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { htmlFor: inputId, className: cls("iuk-alt-input__label"), children: resolvedLabel })
435
+ ] }),
436
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
437
+ "input",
438
+ {
439
+ id: inputId,
440
+ type: "text",
441
+ value,
442
+ onChange: (e) => onChange(e.target.value),
443
+ placeholder: resolvedPlaceholder,
444
+ className: cls("iuk-alt-input__field"),
445
+ disabled,
446
+ maxLength,
447
+ "aria-describedby": hintId
448
+ }
449
+ ),
450
+ showHint && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: cls("iuk-alt-input__hint"), id: hintId, children: [
451
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
452
+ value.length,
453
+ "/",
454
+ maxLength,
455
+ " ",
456
+ ui.characters
457
+ ] }),
458
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.usedForA11ySeo })
459
+ ] })
460
+ ]
461
+ }
462
+ );
463
+ }
464
+
465
+ // src/react/components/AltTextModal.tsx
466
+
467
+ var _reactdom = require('react-dom');
468
+
469
+ // src/react/components/BlurImage.tsx
470
+
471
+
472
+
473
+
474
+
475
+
476
+
477
+ function BlurImage({
478
+ src,
479
+ alt,
480
+ blurDataUrl,
481
+ blurColor,
482
+ blurHash,
483
+ objectFit = "cover",
484
+ className = "",
485
+ imageClassName = "",
486
+ style,
487
+ renderImage: propRenderImage,
488
+ onImageLoad
489
+ }) {
490
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
491
+ const renderImage = propRenderImage || ctx.renderImage;
492
+ const [loadedSrc, setLoadedSrc] = _react.useState.call(void 0, null);
493
+ const [failedSrc, setFailedSrc] = _react.useState.call(void 0, null);
494
+ const imgRef = _react.useRef.call(void 0, null);
495
+ const onImageLoadRef = _react.useRef.call(void 0, onImageLoad);
496
+ onImageLoadRef.current = onImageLoad;
497
+ const decodedHashUrl = _react.useMemo.call(void 0, () => {
498
+ if (blurDataUrl || !blurHash) return null;
499
+ return _chunk3ICG2SLLcjs.decodeBlurHashToDataURL.call(void 0, blurHash, 32, 32);
500
+ }, [blurDataUrl, blurHash]);
501
+ const effectiveBlurUrl = blurDataUrl || decodedHashUrl || void 0;
502
+ const isLoaded = loadedSrc === src;
503
+ const hasFailed = failedSrc === src;
504
+ _react.useEffect.call(void 0, () => {
505
+ const el = imgRef.current;
506
+ if (el && el.complete && el.naturalWidth > 0) {
507
+ setLoadedSrc(src);
508
+ _optionalChain([onImageLoadRef, 'access', _2 => _2.current, 'optionalCall', _3 => _3(el)]);
509
+ }
510
+ }, [src]);
511
+ const imgStyle = {
512
+ width: "100%",
513
+ height: "100%",
514
+ objectFit,
515
+ opacity: isLoaded || hasFailed || !effectiveBlurUrl ? 1 : 0,
516
+ transition: "opacity 0.28s ease-out"
517
+ };
518
+ const escapedBlurUrl = effectiveBlurUrl ? effectiveBlurUrl.replace(/"/g, '\\"') : void 0;
519
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
520
+ "div",
521
+ {
522
+ className: `iuk-blur-image-wrap ${className}`.trim(),
523
+ style: {
524
+ backgroundColor: blurColor || "var(--iuk-placeholder-bg, #f3f4f6)",
525
+ ...style
526
+ },
527
+ children: [
528
+ escapedBlurUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
529
+ "div",
530
+ {
531
+ "aria-hidden": "true",
532
+ className: `iuk-blur-image-backdrop ${isLoaded ? "iuk-blur-image-backdrop--hidden" : ""}`,
533
+ style: {
534
+ backgroundImage: `url("${escapedBlurUrl}")`,
535
+ backgroundSize: objectFit === "contain" ? "contain" : "cover"
536
+ }
537
+ }
538
+ ),
539
+ renderImage ? renderImage({
540
+ src,
541
+ alt,
542
+ className: `iuk-blur-image-el ${imageClassName}`.trim(),
543
+ style: imgStyle,
544
+ onLoad: (el) => {
545
+ setLoadedSrc(src);
546
+ _optionalChain([onImageLoadRef, 'access', _4 => _4.current, 'optionalCall', _5 => _5(el)]);
547
+ }
548
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
549
+ "img",
550
+ {
551
+ ref: imgRef,
552
+ src,
553
+ alt,
554
+ loading: "lazy",
555
+ decoding: "async",
556
+ className: `iuk-blur-image-el ${imageClassName}`.trim(),
557
+ style: imgStyle,
558
+ onLoad: (e) => {
559
+ setLoadedSrc(src);
560
+ _optionalChain([onImageLoadRef, 'access', _6 => _6.current, 'optionalCall', _7 => _7(e.currentTarget)]);
561
+ },
562
+ onError: () => {
563
+ setFailedSrc(src);
564
+ }
565
+ }
566
+ )
567
+ ]
568
+ }
569
+ );
570
+ }
571
+
572
+ // src/react/components/AltTextModal.tsx
573
+
574
+ function AltTextModal({
575
+ imageUrl,
576
+ initialAltText = "",
577
+ onSave,
578
+ onClose,
579
+ locale: propLocale,
580
+ translations,
581
+ renderImage,
582
+ unstyled: propUnstyled
583
+ }) {
584
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
585
+ const isUnstyled = _nullishCoalesce(propUnstyled, () => ( ctx.unstyled));
586
+ const locale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, propLocale || ctx.locale);
587
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, locale, translations || ctx.translations);
588
+ const [localAltText, setLocalAltText] = _react.useState.call(void 0, initialAltText);
589
+ const inputRef = _react.useRef.call(void 0, null);
590
+ const { dialogRef, titleId, descriptionId } = useDialog({
591
+ isOpen: true,
592
+ onClose,
593
+ initialFocusRef: inputRef
594
+ });
595
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
596
+ const handleSave = () => {
597
+ onSave(localAltText);
598
+ onClose();
599
+ };
600
+ const content = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
601
+ "div",
602
+ {
603
+ "data-slot": "alt-modal-backdrop",
604
+ "data-unstyled": isUnstyled || void 0,
605
+ className: cls("iuk-modal-backdrop"),
606
+ dir: locale === "ar" ? "rtl" : "ltr",
607
+ onClick: onClose,
608
+ role: "dialog",
609
+ "aria-modal": "true",
610
+ "aria-labelledby": titleId,
611
+ "aria-describedby": descriptionId,
612
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
613
+ "div",
614
+ {
615
+ ref: dialogRef,
616
+ "data-slot": "alt-modal",
617
+ className: cls("iuk-alt-modal"),
618
+ onClick: (e) => e.stopPropagation(),
619
+ children: [
620
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-alt-modal__header"), children: [
621
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-alt-modal__title"), children: [
622
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TypeIcon, { size: 18 }),
623
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { id: titleId, children: ui.addImageDescription })
624
+ ] }),
625
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
626
+ "button",
627
+ {
628
+ type: "button",
629
+ className: cls("iuk-icon-btn"),
630
+ onClick: onClose,
631
+ title: ui.close,
632
+ "aria-label": ui.close,
633
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { size: 18 })
634
+ }
635
+ )
636
+ ] }),
637
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-alt-modal__preview"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
638
+ BlurImage,
639
+ {
640
+ src: imageUrl,
641
+ alt: ui.previewAlt,
642
+ objectFit: "contain",
643
+ renderImage
644
+ }
645
+ ) }),
646
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
647
+ "input",
648
+ {
649
+ ref: inputRef,
650
+ type: "text",
651
+ className: cls("iuk-alt-input__field"),
652
+ value: localAltText,
653
+ onChange: (e) => setLocalAltText(e.target.value),
654
+ onKeyDown: (e) => {
655
+ if (e.key === "Enter") {
656
+ e.preventDefault();
657
+ handleSave();
658
+ }
659
+ },
660
+ placeholder: ui.describeImagePlaceholder,
661
+ maxLength: 200,
662
+ "aria-labelledby": titleId,
663
+ "aria-describedby": descriptionId
664
+ }
665
+ ),
666
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { id: descriptionId, className: cls("iuk-alt-input__hint"), children: [
667
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
668
+ localAltText.length,
669
+ "/200 ",
670
+ ui.characters
671
+ ] }),
672
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.usedForA11ySeo })
673
+ ] }),
674
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-alt-modal__actions"), children: [
675
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
676
+ "button",
677
+ {
678
+ type: "button",
679
+ className: cls("iuk-btn iuk-btn--secondary"),
680
+ onClick: onClose,
681
+ children: ui.cancel
682
+ }
683
+ ),
684
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
685
+ "button",
686
+ {
687
+ type: "button",
688
+ className: cls("iuk-btn iuk-btn--primary"),
689
+ onClick: handleSave,
690
+ children: [
691
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCircleIcon, { size: 16 }),
692
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.saveDescription })
693
+ ]
694
+ }
695
+ )
696
+ ] })
697
+ ]
698
+ }
699
+ )
700
+ }
701
+ );
702
+ if (typeof document !== "undefined") {
703
+ return _reactdom.createPortal.call(void 0, content, document.body);
704
+ }
705
+ return content;
706
+ }
707
+
708
+ // src/react/components/AnimatedImage/AnimatedImage.tsx
709
+
710
+
711
+ // src/react/components/AnimatedImage/placeholder.ts
712
+ var DEFAULT_NEUTRAL_COLORS = [
713
+ "#1a1a1a",
714
+ "#121212",
715
+ "#000000",
716
+ "#000",
717
+ "#e5e7eb",
718
+ "#ffffff",
719
+ "#fff"
720
+ ];
721
+ var HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
722
+ var FUNC_COLOR = /^(?:rgb|rgba|hsl|hsla|oklch|oklab)\([\d\s.,%/+-]+\)$/i;
723
+ var CSS_VAR_COLOR = /^var\(--[a-zA-Z0-9_-]+(?:\s*,\s*[^;{}<>()]+)?\)$/;
724
+ function isNeutralColor(value, neutralColors) {
725
+ if (neutralColors.length === 0) return false;
726
+ const lower = value.toLowerCase();
727
+ for (const item of neutralColors) {
728
+ if (item.toLowerCase() === lower) return true;
729
+ }
730
+ return false;
731
+ }
732
+ function resolveMeaningfulColor(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
733
+ const value = _optionalChain([color, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]);
734
+ if (!value) return void 0;
735
+ if (isNeutralColor(value, neutralColors)) return void 0;
736
+ if (!HEX_COLOR.test(value) && !FUNC_COLOR.test(value)) return void 0;
737
+ return value;
738
+ }
739
+ function resolveBackgroundColor(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
740
+ const value = _optionalChain([color, 'optionalAccess', _10 => _10.trim, 'call', _11 => _11()]);
741
+ if (!value) return void 0;
742
+ if (isNeutralColor(value, neutralColors)) return void 0;
743
+ if (HEX_COLOR.test(value) || FUNC_COLOR.test(value) || CSS_VAR_COLOR.test(value)) {
744
+ return value;
745
+ }
746
+ return void 0;
747
+ }
748
+ function createFallbackBlurSvg(color, neutralColors = DEFAULT_NEUTRAL_COLORS) {
749
+ const meaningful = resolveMeaningfulColor(color, neutralColors);
750
+ const stop1 = _nullishCoalesce(meaningful, () => ( "#2c3340"));
751
+ const stop2 = meaningful ? "#0f172a" : "#1e242d";
752
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="100%" height="100%"><defs><linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%"><stop offset="0%" stop-color="${stop1}" stop-opacity="1"/><stop offset="55%" stop-color="${stop1}" stop-opacity="0.78"/><stop offset="100%" stop-color="${stop2}" stop-opacity="0.96"/></linearGradient><radialGradient id="h" cx="24%" cy="22%" r="65%"><stop offset="0%" stop-color="#ffffff" stop-opacity="0.22"/><stop offset="100%" stop-color="#ffffff" stop-opacity="0"/></radialGradient></defs><rect width="100%" height="100%" fill="url(#g)"/><rect width="100%" height="100%" fill="url(#h)"/></svg>`;
753
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
754
+ }
755
+ function resolveIntrinsicPlaceholderUrl({
756
+ blurDataUrl,
757
+ blurHash
758
+ }) {
759
+ const dataUrl = _optionalChain([blurDataUrl, 'optionalAccess', _12 => _12.trim, 'call', _13 => _13()]);
760
+ if (dataUrl) return dataUrl;
761
+ if (blurHash && typeof document !== "undefined") {
762
+ try {
763
+ const decoded = _chunk3ICG2SLLcjs.decodeBlurHashToDataURL.call(void 0, blurHash, 32, 32);
764
+ if (decoded) return decoded;
765
+ } catch (e3) {
766
+ }
767
+ }
768
+ return void 0;
769
+ }
770
+ function resolvePlaceholderUrl({
771
+ blurDataUrl,
772
+ blurHash,
773
+ blurColor,
774
+ neutralColors = DEFAULT_NEUTRAL_COLORS
775
+ }) {
776
+ const intrinsic = resolveIntrinsicPlaceholderUrl({ blurDataUrl, blurHash });
777
+ if (intrinsic) return intrinsic;
778
+ return createFallbackBlurSvg(blurColor, neutralColors);
779
+ }
780
+
781
+ // src/react/components/AnimatedImage/useImageReveal.ts
782
+
783
+ var PLACEHOLDER_UNMOUNT_BUFFER_MS = 50;
784
+ function useImageReveal({
785
+ srcKey,
786
+ fallbackSrc,
787
+ animationDuration,
788
+ onLoad
789
+ }) {
790
+ const [prevSrc, setPrevSrc] = _react.useState.call(void 0, srcKey);
791
+ const [usingFallback, setUsingFallback] = _react.useState.call(void 0, false);
792
+ const [retryKey, setRetryKey] = _react.useState.call(void 0, 0);
793
+ const [isLoaded, setIsLoaded] = _react.useState.call(void 0, false);
794
+ const [showPlaceholder, setShowPlaceholder] = _react.useState.call(void 0, true);
795
+ const [hasError, setHasError] = _react.useState.call(void 0, false);
796
+ const [node, setNode] = _react.useState.call(void 0, null);
797
+ const timeoutRef = _react.useRef.call(void 0, null);
798
+ const mountedRef = _react.useRef.call(void 0, true);
799
+ const activeSrc = usingFallback && fallbackSrc ? fallbackSrc : srcKey;
800
+ const activeSrcRef = _react.useRef.call(void 0, activeSrc);
801
+ const onLoadRef = _react.useRef.call(void 0, onLoad);
802
+ _react.useEffect.call(void 0, () => {
803
+ onLoadRef.current = onLoad;
804
+ }, [onLoad]);
805
+ const clearTimer = _react.useCallback.call(void 0, () => {
806
+ if (timeoutRef.current) {
807
+ clearTimeout(timeoutRef.current);
808
+ timeoutRef.current = null;
809
+ }
810
+ }, []);
811
+ if (prevSrc !== srcKey) {
812
+ setPrevSrc(srcKey);
813
+ setUsingFallback(false);
814
+ setIsLoaded(false);
815
+ setShowPlaceholder(true);
816
+ setHasError(false);
817
+ }
818
+ _react.useEffect.call(void 0, () => {
819
+ activeSrcRef.current = activeSrc;
820
+ clearTimer();
821
+ }, [activeSrc, clearTimer]);
822
+ _react.useEffect.call(void 0, () => {
823
+ mountedRef.current = true;
824
+ return () => {
825
+ mountedRef.current = false;
826
+ clearTimer();
827
+ };
828
+ }, [clearTimer]);
829
+ const handleLoad = _react.useCallback.call(void 0,
830
+ (img) => {
831
+ const el = _nullishCoalesce(img, () => ( node));
832
+ const loadedFor = activeSrcRef.current;
833
+ const reveal = () => {
834
+ if (!mountedRef.current || loadedFor !== activeSrcRef.current) return;
835
+ setHasError(false);
836
+ setIsLoaded(true);
837
+ clearTimer();
838
+ const duration = Math.max(0, animationDuration);
839
+ timeoutRef.current = setTimeout(() => {
840
+ if (mountedRef.current) setShowPlaceholder(false);
841
+ timeoutRef.current = null;
842
+ }, duration + PLACEHOLDER_UNMOUNT_BUFFER_MS);
843
+ _optionalChain([onLoadRef, 'access', _14 => _14.current, 'optionalCall', _15 => _15(_nullishCoalesce(el, () => ( null)))]);
844
+ };
845
+ if (el && typeof el.decode === "function") {
846
+ el.decode().then(reveal, reveal);
847
+ } else {
848
+ reveal();
849
+ }
850
+ },
851
+ [animationDuration, clearTimer, node]
852
+ );
853
+ const handleError = _react.useCallback.call(void 0, () => {
854
+ if (!mountedRef.current) return false;
855
+ clearTimer();
856
+ if (fallbackSrc && !usingFallback && fallbackSrc !== srcKey) {
857
+ setUsingFallback(true);
858
+ setIsLoaded(false);
859
+ setShowPlaceholder(true);
860
+ setHasError(false);
861
+ return false;
862
+ }
863
+ setHasError(true);
864
+ setIsLoaded(false);
865
+ setShowPlaceholder(true);
866
+ return true;
867
+ }, [clearTimer, fallbackSrc, srcKey, usingFallback]);
868
+ const retry = _react.useCallback.call(void 0, () => {
869
+ clearTimer();
870
+ setUsingFallback(false);
871
+ setHasError(false);
872
+ setIsLoaded(false);
873
+ setShowPlaceholder(true);
874
+ setRetryKey((prev) => prev + 1);
875
+ }, [clearTimer]);
876
+ _react.useEffect.call(void 0, () => {
877
+ if (!node || !node.complete || node.naturalWidth === 0) return;
878
+ if (typeof requestAnimationFrame !== "function") {
879
+ handleLoad(node);
880
+ return;
881
+ }
882
+ const rafId = requestAnimationFrame(() => handleLoad(node));
883
+ return () => cancelAnimationFrame(rafId);
884
+ }, [node, activeSrc, retryKey, handleLoad]);
885
+ return {
886
+ activeSrc,
887
+ retryKey,
888
+ isLoaded,
889
+ showPlaceholder,
890
+ hasError,
891
+ imgRef: setNode,
892
+ handleLoad,
893
+ handleError,
894
+ retry
895
+ };
896
+ }
897
+
898
+ // src/react/components/AnimatedImage/AnimatedImage.tsx
899
+
900
+ var preventDrag = (event) => event.preventDefault();
901
+ var cn = (...classes) => _chunkU2TWTEBYcjs.cx.call(void 0, ...classes) || void 0;
902
+ function AnimatedImage({
903
+ image,
904
+ src: srcProp,
905
+ alt: altProp,
906
+ blurDataUrl: blurDataUrlProp,
907
+ blurHash: blurHashProp,
908
+ blurColor: blurColorProp,
909
+ colorPlaceholder = "flat",
910
+ neutralColors = DEFAULT_NEUTRAL_COLORS,
911
+ width: widthProp,
912
+ height: heightProp,
913
+ fill = false,
914
+ priority,
915
+ quality,
916
+ objectFit = "cover",
917
+ objectPosition = "center",
918
+ showShimmer = false,
919
+ animationDuration = 600,
920
+ revealScale = 1.02,
921
+ fallbackSrc,
922
+ renderError,
923
+ as: ImageComponent,
924
+ imageComponentProps,
925
+ unstyled = false,
926
+ wrapperClassName,
927
+ wrapperStyle,
928
+ wrapperProps,
929
+ placeholderClassName,
930
+ className,
931
+ style,
932
+ loading: loadingProp,
933
+ decoding = "async",
934
+ draggable = false,
935
+ onLoad,
936
+ onError,
937
+ ...imgProps
938
+ }) {
939
+ const src = _nullishCoalesce(_nullishCoalesce(srcProp, () => ( _optionalChain([image, 'optionalAccess', _16 => _16.url]))), () => ( ""));
940
+ const alt = _nullishCoalesce(_nullishCoalesce(altProp, () => ( _optionalChain([image, 'optionalAccess', _17 => _17.altText]))), () => ( ""));
941
+ const blurDataUrl = _nullishCoalesce(blurDataUrlProp, () => ( _optionalChain([image, 'optionalAccess', _18 => _18.blurDataUrl])));
942
+ const blurHash = _nullishCoalesce(blurHashProp, () => ( _optionalChain([image, 'optionalAccess', _19 => _19.blurHash])));
943
+ const blurColor = _nullishCoalesce(blurColorProp, () => ( _optionalChain([image, 'optionalAccess', _20 => _20.blurColor])));
944
+ const width = _nullishCoalesce(widthProp, () => ( (!fill ? _optionalChain([image, 'optionalAccess', _21 => _21.width]) : void 0)));
945
+ const height = _nullishCoalesce(heightProp, () => ( (!fill ? _optionalChain([image, 'optionalAccess', _22 => _22.height]) : void 0)));
946
+ const {
947
+ activeSrc,
948
+ retryKey,
949
+ isLoaded,
950
+ showPlaceholder,
951
+ hasError,
952
+ imgRef,
953
+ handleLoad,
954
+ handleError,
955
+ retry
956
+ } = useImageReveal({
957
+ srcKey: src,
958
+ fallbackSrc,
959
+ animationDuration,
960
+ onLoad
961
+ });
962
+ const state = hasError ? "error" : isLoaded ? "loaded" : "loading";
963
+ const resolvedObjectFit = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _23 => _23.objectFit]), () => ( objectFit));
964
+ const isContain = resolvedObjectFit === "contain";
965
+ const placeholderUrl = _react.useMemo.call(void 0,
966
+ () => colorPlaceholder === "gradient" || isContain ? resolvePlaceholderUrl({ blurDataUrl, blurHash, blurColor, neutralColors }) : resolveIntrinsicPlaceholderUrl({ blurDataUrl, blurHash }),
967
+ [blurDataUrl, blurHash, blurColor, colorPlaceholder, isContain, neutralColors]
968
+ );
969
+ const cls = (name) => unstyled ? void 0 : name;
970
+ const duration = Math.max(0, animationDuration);
971
+ const placeholderFadeDuration = Math.round(duration * (5 / 6));
972
+ const containerStyle = {
973
+ backgroundColor: _nullishCoalesce(resolveBackgroundColor(blurColor, neutralColors), () => ( (unstyled ? void 0 : "var(--iuk-animated-image-bg, var(--background-card, rgba(38, 45, 56, 0.4)))"))),
974
+ ...unstyled ? void 0 : {
975
+ ["--iuk-animated-image-duration"]: `${duration}ms`,
976
+ ["--iuk-ai-ph-dur"]: `${placeholderFadeDuration}ms`,
977
+ ["--iuk-animated-image-reveal-scale"]: String(revealScale)
978
+ },
979
+ ...wrapperStyle
980
+ };
981
+ const placeholderStyle = {
982
+ objectFit: "cover",
983
+ transitionDuration: `${placeholderFadeDuration}ms`
984
+ };
985
+ const imageStyle = {
986
+ objectFit: resolvedObjectFit,
987
+ objectPosition,
988
+ transitionDuration: `${duration}ms`,
989
+ ...style,
990
+ ...hasError ? { opacity: 0, visibility: "hidden" } : void 0
991
+ };
992
+ const isCustom = Boolean(ImageComponent);
993
+ const loadingAttr = priority ? isCustom ? void 0 : "eager" : _nullishCoalesce(loadingProp, () => ( (isCustom ? void 0 : "lazy")));
994
+ const priorityProps = isCustom ? {
995
+ ...priority !== void 0 ? { priority } : {},
996
+ ...quality !== void 0 ? { quality } : {}
997
+ } : priority ? { fetchPriority: "high" } : {};
998
+ const derivedImageSrcSet = !isCustom && activeSrc === src ? _nullishCoalesce(_optionalChain([image, 'optionalAccess', _24 => _24.srcSet]), () => ( (_optionalChain([image, 'optionalAccess', _25 => _25.variants, 'optionalAccess', _26 => _26.length]) ? [
999
+ ...[...image.variants].sort((a, b) => a.width - b.width).map((v) => `${v.url} ${v.width}w`),
1000
+ ...image.width ? [`${src} ${image.width}w`] : []
1001
+ ].join(", ") : void 0))) : void 0;
1002
+ const resolvedSrcSet = _nullishCoalesce(imgProps.srcSet, () => ( derivedImageSrcSet));
1003
+ const resolvedSizes = !isCustom && resolvedSrcSet && fill && imgProps.sizes === void 0 ? "100vw" : imgProps.sizes;
1004
+ const sharedImgProps = {
1005
+ ...priorityProps,
1006
+ ...imgProps,
1007
+ ...resolvedSrcSet !== void 0 ? { srcSet: resolvedSrcSet } : {},
1008
+ ...resolvedSizes !== void 0 ? { sizes: resolvedSizes } : {},
1009
+ ...width !== void 0 ? { width } : {},
1010
+ ...height !== void 0 ? { height } : {},
1011
+ ...loadingAttr !== void 0 ? { loading: loadingAttr } : {},
1012
+ src: activeSrc,
1013
+ alt,
1014
+ decoding,
1015
+ draggable,
1016
+ ref: imgRef,
1017
+ className: cn(cls("iuk-animated-image__img"), className),
1018
+ style: imageStyle,
1019
+ "data-state": state,
1020
+ onDragStart: _nullishCoalesce(imgProps.onDragStart, () => ( preventDrag)),
1021
+ onLoad: (event) => handleLoad(event.currentTarget),
1022
+ onError: (event) => {
1023
+ const isTerminal = handleError();
1024
+ if (isTerminal) {
1025
+ _optionalChain([onError, 'optionalCall', _27 => _27(event)]);
1026
+ }
1027
+ }
1028
+ };
1029
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1030
+ "div",
1031
+ {
1032
+ ...wrapperProps,
1033
+ className: cn(
1034
+ cls("iuk-animated-image"),
1035
+ fill && cls("iuk-animated-image--fill"),
1036
+ isContain && cls("iuk-animated-image--contain"),
1037
+ wrapperClassName,
1038
+ _optionalChain([wrapperProps, 'optionalAccess', _28 => _28.className])
1039
+ ),
1040
+ style: { ...containerStyle, ..._optionalChain([wrapperProps, 'optionalAccess', _29 => _29.style]) },
1041
+ "data-slot": "animated-image",
1042
+ "data-state": state,
1043
+ "aria-busy": state === "loading" || void 0,
1044
+ children: [
1045
+ (showPlaceholder || isContain) && placeholderUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1046
+ "img",
1047
+ {
1048
+ src: placeholderUrl,
1049
+ alt: "",
1050
+ "aria-hidden": "true",
1051
+ draggable: false,
1052
+ onDragStart: preventDrag,
1053
+ "data-slot": "animated-image-placeholder",
1054
+ className: cn(
1055
+ cls("iuk-animated-image__placeholder"),
1056
+ isLoaded && !isContain && cls("iuk-animated-image__placeholder--hidden"),
1057
+ placeholderClassName
1058
+ ),
1059
+ style: placeholderStyle
1060
+ }
1061
+ ),
1062
+ showShimmer && !isLoaded && !hasError && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1063
+ "div",
1064
+ {
1065
+ "aria-hidden": "true",
1066
+ "data-slot": "animated-image-shimmer",
1067
+ className: cn(cls("iuk-animated-image__shimmer"))
1068
+ }
1069
+ ),
1070
+ ImageComponent ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1071
+ ImageComponent,
1072
+ {
1073
+ ...sharedImgProps,
1074
+ ...fill ? { fill: true } : {},
1075
+ ...imageComponentProps
1076
+ },
1077
+ retryKey > 0 ? retryKey : void 0
1078
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "img", { ...sharedImgProps }, retryKey > 0 ? retryKey : void 0),
1079
+ hasError && renderError ? renderError({ src: activeSrc, retry }) : null
1080
+ ]
1081
+ }
1082
+ );
1083
+ }
1084
+
1085
+ // src/react/components/BlurServiceDebugger.tsx
1086
+
1087
+ function BlurServiceDebugger() {
1088
+ _react.useEffect.call(void 0, () => {
1089
+ if (typeof window === "undefined") return void 0;
1090
+ const target = window;
1091
+ target.blurService = _chunkWISG74VLcjs.blurService;
1092
+ return () => {
1093
+ if (target.blurService === _chunkWISG74VLcjs.blurService) {
1094
+ delete target.blurService;
1095
+ }
1096
+ };
1097
+ }, []);
1098
+ return null;
1099
+ }
1100
+
1101
+ // src/react/components/BlurVisualizationModal.tsx
1102
+
1103
+
1104
+
1105
+ // src/react/utils/canvasSampler.ts
1106
+ function drawImageToCanvas(img, canvasRef) {
1107
+ const canvas = canvasRef.current;
1108
+ const ctx = _optionalChain([canvas, 'optionalAccess', _30 => _30.getContext, 'call', _31 => _31("2d")]);
1109
+ if (!canvas || !ctx) return;
1110
+ const width = img.naturalWidth || img.width;
1111
+ const height = img.naturalHeight || img.height;
1112
+ if (!width || !height) return;
1113
+ canvas.width = width;
1114
+ canvas.height = height;
1115
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
1116
+ try {
1117
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
1118
+ } catch (e4) {
1119
+ }
1120
+ }
1121
+ function sampleCanvasPixelHex(event, canvasRef) {
1122
+ const canvas = canvasRef.current;
1123
+ const context = _optionalChain([canvas, 'optionalAccess', _32 => _32.getContext, 'call', _33 => _33("2d")]);
1124
+ if (!canvas || !context || canvas.width === 0 || canvas.height === 0) {
1125
+ return null;
1126
+ }
1127
+ const rect = event.currentTarget.getBoundingClientRect();
1128
+ if (!rect.width || !rect.height) return null;
1129
+ const relX = (event.clientX - rect.left) / rect.width;
1130
+ const relY = (event.clientY - rect.top) / rect.height;
1131
+ if (relX < 0 || relY < 0 || relX > 1 || relY > 1) return null;
1132
+ const x = Math.min(
1133
+ Math.max(Math.floor(relX * canvas.width), 0),
1134
+ canvas.width - 1
1135
+ );
1136
+ const y = Math.min(
1137
+ Math.max(Math.floor(relY * canvas.height), 0),
1138
+ canvas.height - 1
1139
+ );
1140
+ let pixel;
1141
+ try {
1142
+ pixel = context.getImageData(x, y, 1, 1).data;
1143
+ } catch (e5) {
1144
+ return null;
1145
+ }
1146
+ const [r, g, b, alpha] = pixel;
1147
+ if (alpha === 0) return null;
1148
+ return _chunkNEDBIIE3cjs.rgbToHex.call(void 0, r, g, b);
1149
+ }
1150
+
1151
+ // src/react/components/BlurColorControls.tsx
1152
+
1153
+ function BlurColorControls({
1154
+ localColor,
1155
+ hexInput,
1156
+ penModeActive,
1157
+ detectedColor,
1158
+ sampledColor,
1159
+ tModal,
1160
+ onColorPickerChange,
1161
+ onHexInputChange,
1162
+ onTogglePenMode,
1163
+ onUseDetectedColor
1164
+ }) {
1165
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__controls", children: [
1166
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "iuk-blur-modal__section-title", children: tModal.adjustColor }),
1167
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "iuk-blur-modal__subtitle", children: penModeActive ? `\u{1F3A8} ${tModal.clickToSample}` : tModal.pickColorNote }),
1168
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__picker-row", children: [
1169
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "label", { className: "iuk-blur-modal__color-well", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1170
+ "input",
1171
+ {
1172
+ type: "color",
1173
+ value: localColor,
1174
+ onChange: onColorPickerChange,
1175
+ "aria-label": tModal.adjustColor
1176
+ }
1177
+ ) }),
1178
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__hex-group", children: [
1179
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__hex-field", children: [
1180
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: "#" }),
1181
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1182
+ "input",
1183
+ {
1184
+ type: "text",
1185
+ value: hexInput,
1186
+ onChange: onHexInputChange,
1187
+ maxLength: 6,
1188
+ spellCheck: false,
1189
+ "aria-label": tModal.enterHexColor,
1190
+ placeholder: tModal.hexPlaceholder
1191
+ }
1192
+ )
1193
+ ] }),
1194
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__swatch-chip", children: [
1195
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1196
+ "span",
1197
+ {
1198
+ className: "iuk-blur-modal__swatch-dot",
1199
+ style: { backgroundColor: localColor },
1200
+ "aria-hidden": "true"
1201
+ }
1202
+ ),
1203
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children: localColor })
1204
+ ] })
1205
+ ] })
1206
+ ] }),
1207
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "iuk-blur-modal__actions-row", children: [
1208
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1209
+ "button",
1210
+ {
1211
+ type: "button",
1212
+ onClick: onTogglePenMode,
1213
+ className: `iuk-btn iuk-btn--secondary ${penModeActive ? "iuk-btn--active" : ""}`,
1214
+ "aria-label": penModeActive ? tModal.disablePenMode : tModal.enablePenMode,
1215
+ children: [
1216
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PenToolIcon, { size: 14 }),
1217
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: penModeActive ? tModal.penModeActive : tModal.enablePenMode })
1218
+ ]
1219
+ }
1220
+ ),
1221
+ detectedColor && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1222
+ "button",
1223
+ {
1224
+ type: "button",
1225
+ className: "iuk-btn iuk-btn--secondary",
1226
+ onClick: onUseDetectedColor,
1227
+ children: [
1228
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WandIcon, { size: 14 }),
1229
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: tModal.resetToDetected }),
1230
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children: detectedColor.toUpperCase() })
1231
+ ]
1232
+ }
1233
+ ),
1234
+ sampledColor && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "iuk-badge iuk-badge--accent", children: [
1235
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PenToolIcon, { size: 12 }),
1236
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
1237
+ tModal.sampled,
1238
+ " ",
1239
+ sampledColor
1240
+ ] })
1241
+ ] })
1242
+ ] })
1243
+ ] });
1244
+ }
1245
+
1246
+ // src/react/components/SaveButton.tsx
1247
+
1248
+ function SaveButton({
1249
+ icon,
1250
+ unstyled = false,
1251
+ children,
1252
+ className = "",
1253
+ type = "button",
1254
+ ...rest
1255
+ }) {
1256
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1257
+ "button",
1258
+ {
1259
+ type,
1260
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-save-button", unstyled, className),
1261
+ ...rest,
1262
+ children: [
1263
+ icon && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-save-button__icon", unstyled), children: icon }),
1264
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children })
1265
+ ]
1266
+ }
1267
+ );
1268
+ }
1269
+
1270
+ // src/react/components/BlurVisualizationModal.tsx
1271
+
1272
+ var DEBOUNCE_MS = 250;
1273
+ function BlurVisualizationModal({
1274
+ isOpen,
1275
+ onClose,
1276
+ imageUrl,
1277
+ blurDataUrl,
1278
+ blurColor,
1279
+ altText,
1280
+ originalSize,
1281
+ optimizedSize,
1282
+ detectedColor,
1283
+ onChangeColor,
1284
+ onUseDetectedColor,
1285
+ onChangeAltText,
1286
+ locale: propLocale,
1287
+ translations,
1288
+ renderImage,
1289
+ unstyled: propUnstyled
1290
+ }) {
1291
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
1292
+ const isUnstyled = _nullishCoalesce(propUnstyled, () => ( ctx.unstyled));
1293
+ const locale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, propLocale || ctx.locale);
1294
+ const tModal = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, locale, translations || ctx.translations).blurModal;
1295
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
1296
+ const { dialogRef, titleId } = useDialog({ isOpen, onClose });
1297
+ const textareaId = _react.useId.call(void 0, );
1298
+ const baseColor = _react.useMemo.call(void 0, () => (blurColor || detectedColor || "#F5F5F5").toUpperCase(), [blurColor, detectedColor]);
1299
+ const [localColor, setLocalColor] = _react.useState.call(void 0, baseColor);
1300
+ const [hexInput, setHexInput] = _react.useState.call(void 0, baseColor.replace("#", ""));
1301
+ const [sampledColor, setSampledColor] = _react.useState.call(void 0, null);
1302
+ const [penModeActive, setPenModeActive] = _react.useState.call(void 0, false);
1303
+ const [localAltText, setLocalAltText] = _react.useState.call(void 0, altText || "");
1304
+ const liveCanvasRef = _react.useRef.call(void 0, null);
1305
+ const colorTimerRef = _react.useRef.call(void 0, null);
1306
+ const altTimerRef = _react.useRef.call(void 0, null);
1307
+ const pendingColorRef = _react.useRef.call(void 0, null);
1308
+ const pendingAltRef = _react.useRef.call(void 0, null);
1309
+ _react.useEffect.call(void 0, () => {
1310
+ if (!isOpen) return;
1311
+ setLocalColor(baseColor);
1312
+ setHexInput(baseColor.replace("#", ""));
1313
+ setLocalAltText(altText || "");
1314
+ }, [isOpen, baseColor, altText, blurDataUrl, imageUrl, blurColor]);
1315
+ _react.useEffect.call(void 0, () => () => {
1316
+ if (colorTimerRef.current) clearTimeout(colorTimerRef.current);
1317
+ if (altTimerRef.current) clearTimeout(altTimerRef.current);
1318
+ }, []);
1319
+ _react.useEffect.call(void 0, () => {
1320
+ if (!isOpen) return;
1321
+ const srcToLoad = imageUrl || blurDataUrl;
1322
+ if (!srcToLoad) return;
1323
+ const img = new window.Image();
1324
+ img.crossOrigin = "anonymous";
1325
+ img.onload = () => drawImageToCanvas(img, liveCanvasRef);
1326
+ img.onerror = () => {
1327
+ if (blurDataUrl && srcToLoad !== blurDataUrl) {
1328
+ const fallbackImg = new window.Image();
1329
+ fallbackImg.onload = () => drawImageToCanvas(fallbackImg, liveCanvasRef);
1330
+ fallbackImg.src = blurDataUrl;
1331
+ }
1332
+ };
1333
+ img.src = srcToLoad;
1334
+ return () => {
1335
+ img.onload = null;
1336
+ img.onerror = null;
1337
+ };
1338
+ }, [imageUrl, blurDataUrl, isOpen]);
1339
+ _react.useEffect.call(void 0, () => {
1340
+ if (!sampledColor) return;
1341
+ const timer = window.setTimeout(() => setSampledColor(null), 2e3);
1342
+ return () => window.clearTimeout(timer);
1343
+ }, [sampledColor]);
1344
+ if (!isOpen || typeof document === "undefined") return null;
1345
+ const scheduleColorEmit = (hex) => {
1346
+ pendingColorRef.current = hex;
1347
+ if (colorTimerRef.current) clearTimeout(colorTimerRef.current);
1348
+ colorTimerRef.current = setTimeout(() => {
1349
+ colorTimerRef.current = null;
1350
+ const next = pendingColorRef.current;
1351
+ pendingColorRef.current = null;
1352
+ if (next !== null) _optionalChain([onChangeColor, 'optionalCall', _34 => _34(next)]);
1353
+ }, DEBOUNCE_MS);
1354
+ };
1355
+ const scheduleAltEmit = (nextAlt) => {
1356
+ pendingAltRef.current = nextAlt;
1357
+ if (altTimerRef.current) clearTimeout(altTimerRef.current);
1358
+ altTimerRef.current = setTimeout(() => {
1359
+ altTimerRef.current = null;
1360
+ const next = pendingAltRef.current;
1361
+ pendingAltRef.current = null;
1362
+ if (next !== null) _optionalChain([onChangeAltText, 'optionalCall', _35 => _35(next)]);
1363
+ }, DEBOUNCE_MS);
1364
+ };
1365
+ const flushPendingChanges = () => {
1366
+ if (colorTimerRef.current) {
1367
+ clearTimeout(colorTimerRef.current);
1368
+ colorTimerRef.current = null;
1369
+ }
1370
+ if (pendingColorRef.current !== null) {
1371
+ _optionalChain([onChangeColor, 'optionalCall', _36 => _36(pendingColorRef.current)]);
1372
+ pendingColorRef.current = null;
1373
+ }
1374
+ if (altTimerRef.current) {
1375
+ clearTimeout(altTimerRef.current);
1376
+ altTimerRef.current = null;
1377
+ }
1378
+ if (pendingAltRef.current !== null) {
1379
+ _optionalChain([onChangeAltText, 'optionalCall', _37 => _37(pendingAltRef.current)]);
1380
+ pendingAltRef.current = null;
1381
+ }
1382
+ };
1383
+ const handleClose = () => {
1384
+ flushPendingChanges();
1385
+ onClose();
1386
+ };
1387
+ const syncLocalHex = (hex, notify = true) => {
1388
+ setLocalColor(hex);
1389
+ setHexInput(hex.replace("#", ""));
1390
+ if (notify) scheduleColorEmit(hex);
1391
+ };
1392
+ const handleColorPickerChange = (e) => syncLocalHex(e.target.value.toUpperCase());
1393
+ const handleHexInputChange = (event) => {
1394
+ const sanitized = event.target.value.replace(/[^0-9a-fA-F]/g, "").slice(0, 6);
1395
+ setHexInput(sanitized.toUpperCase());
1396
+ if (sanitized.length === 3 || sanitized.length === 6) {
1397
+ const normalized = _chunkNEDBIIE3cjs.normalizeColorInput.call(void 0, `#${sanitized}`);
1398
+ if (normalized) {
1399
+ setLocalColor(normalized);
1400
+ scheduleColorEmit(normalized);
1401
+ }
1402
+ }
1403
+ };
1404
+ const handlePenSample = (event) => {
1405
+ if (!penModeActive) {
1406
+ if (event.pointerType === "pen") setPenModeActive(true);
1407
+ else return;
1408
+ }
1409
+ const sampled = sampleCanvasPixelHex(event, liveCanvasRef);
1410
+ if (!sampled) return;
1411
+ setSampledColor(sampled);
1412
+ syncLocalHex(sampled);
1413
+ };
1414
+ const handleUseDetectedColor = () => {
1415
+ if (!detectedColor) return;
1416
+ if (colorTimerRef.current) {
1417
+ clearTimeout(colorTimerRef.current);
1418
+ colorTimerRef.current = null;
1419
+ pendingColorRef.current = null;
1420
+ }
1421
+ const normalized = _chunkNEDBIIE3cjs.normalizeColorInput.call(void 0, detectedColor) || detectedColor.toUpperCase();
1422
+ setLocalColor(normalized);
1423
+ setHexInput(normalized.replace("#", ""));
1424
+ if (onUseDetectedColor) onUseDetectedColor();
1425
+ else _optionalChain([onChangeColor, 'optionalCall', _38 => _38(normalized)]);
1426
+ };
1427
+ const displayColor = localColor || blurColor || "#F5F5F5";
1428
+ return _reactdom.createPortal.call(void 0,
1429
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1430
+ "div",
1431
+ {
1432
+ "data-slot": "blur-modal-backdrop",
1433
+ "data-unstyled": isUnstyled || void 0,
1434
+ className: cls("iuk-modal-backdrop"),
1435
+ dir: locale === "ar" ? "rtl" : "ltr",
1436
+ onClick: handleClose,
1437
+ role: "dialog",
1438
+ "aria-modal": "true",
1439
+ "aria-labelledby": titleId,
1440
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1441
+ "div",
1442
+ {
1443
+ ref: dialogRef,
1444
+ "data-slot": "blur-modal",
1445
+ className: cls("iuk-blur-modal"),
1446
+ onClick: (e) => e.stopPropagation(),
1447
+ children: [
1448
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__header"), children: [
1449
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__title-row"), children: [
1450
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EyeIcon, { size: 20, className: cls("iuk-blur-modal__title-icon") }),
1451
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h2", { id: titleId, className: cls("iuk-blur-modal__title"), children: tModal.title }),
1452
+ optimizedSize ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-badge"), children: _chunkKJVYWKIGcjs.formatFileSize.call(void 0, optimizedSize) }) : null
1453
+ ] }),
1454
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", onClick: handleClose, className: cls("iuk-icon-btn"), "aria-label": tModal.closeModal, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { size: 18 }) })
1455
+ ] }),
1456
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__body"), children: [
1457
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__grid"), children: [
1458
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1459
+ BlurColorControls,
1460
+ {
1461
+ localColor,
1462
+ hexInput,
1463
+ penModeActive,
1464
+ detectedColor,
1465
+ sampledColor,
1466
+ tModal,
1467
+ onColorPickerChange: handleColorPickerChange,
1468
+ onHexInputChange: handleHexInputChange,
1469
+ onTogglePenMode: () => setPenModeActive((prev) => !prev),
1470
+ onUseDetectedColor: handleUseDetectedColor
1471
+ }
1472
+ ),
1473
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__preview-col"), children: [
1474
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: cls("iuk-blur-modal__section-title"), children: tModal.livePreview }),
1475
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1476
+ "div",
1477
+ {
1478
+ className: cls(`iuk-blur-modal__stage ${penModeActive ? "iuk-blur-modal__stage--sampling" : ""}`.trim()),
1479
+ style: { backgroundColor: displayColor },
1480
+ onPointerDown: handlePenSample,
1481
+ children: [
1482
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1483
+ BlurImage,
1484
+ {
1485
+ src: imageUrl,
1486
+ alt: altText || tModal.livePreview,
1487
+ blurDataUrl,
1488
+ blurColor: displayColor,
1489
+ objectFit: "contain",
1490
+ renderImage,
1491
+ onImageLoad: (img) => {
1492
+ if (img) drawImageToCanvas(img, liveCanvasRef);
1493
+ }
1494
+ }
1495
+ ),
1496
+ !blurDataUrl && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-blur-modal__no-blur-note"), children: tModal.showingOriginal })
1497
+ ]
1498
+ }
1499
+ ),
1500
+ optimizedSize && originalSize && originalSize > optimizedSize ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__savings"), children: [
1501
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: tModal.saved }),
1502
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
1503
+ _chunkKJVYWKIGcjs.formatFileSize.call(void 0, originalSize - optimizedSize),
1504
+ " (",
1505
+ Math.round((originalSize - optimizedSize) / originalSize * 100),
1506
+ "%)"
1507
+ ] })
1508
+ ] }) : null
1509
+ ] })
1510
+ ] }),
1511
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-blur-modal__alt-section"), children: [
1512
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { htmlFor: textareaId, className: cls("iuk-blur-modal__section-title"), children: [
1513
+ tModal.accessibility,
1514
+ " \u2014 ",
1515
+ tModal.altText
1516
+ ] }),
1517
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1518
+ "textarea",
1519
+ {
1520
+ id: textareaId,
1521
+ value: localAltText,
1522
+ onChange: (e) => {
1523
+ setLocalAltText(e.target.value);
1524
+ scheduleAltEmit(e.target.value);
1525
+ },
1526
+ className: cls("iuk-blur-modal__textarea"),
1527
+ placeholder: tModal.altTextPlaceholder,
1528
+ rows: 2
1529
+ }
1530
+ )
1531
+ ] }),
1532
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "canvas", { ref: liveCanvasRef, style: { display: "none" }, "aria-hidden": "true" })
1533
+ ] }),
1534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-blur-modal__footer"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SaveButton, { unstyled: isUnstyled, onClick: handleClose, children: tModal.saveAndClose }) })
1535
+ ]
1536
+ }
1537
+ )
1538
+ }
1539
+ ),
1540
+ document.body
1541
+ );
1542
+ }
1543
+
1544
+ // src/react/components/ImageUpload.tsx
1545
+
1546
+
1547
+
1548
+
1549
+
1550
+
1551
+
1552
+ // src/react/components/MultiImageUpload.tsx
1553
+
1554
+
1555
+
1556
+
1557
+
1558
+
1559
+
1560
+
1561
+
1562
+ // src/react/components/MultiDropzoneViews.tsx
1563
+
1564
+ function MultiEmptyDropzone({
1565
+ isDragging,
1566
+ disabled = false,
1567
+ hasError = false,
1568
+ required = false,
1569
+ enablePaste = true,
1570
+ visualState: propVisualState,
1571
+ allowFolder = true,
1572
+ maxSizeMB,
1573
+ ui,
1574
+ dragHandlers,
1575
+ onPaste,
1576
+ onSelectFiles,
1577
+ onSelectFolder,
1578
+ unstyled,
1579
+ providerClassNames: pCls,
1580
+ classNames: cCls,
1581
+ providerStyles: pSty,
1582
+ styles: cSty
1583
+ }) {
1584
+ const visualState = _nullishCoalesce(propVisualState, () => ( _chunkU2TWTEBYcjs.resolveUploadDataState.call(void 0, { disabled, hasError, isDragging })));
1585
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([pCls, 'optionalAccess', _39 => _39[slot]]), _optionalChain([cCls, 'optionalAccess', _40 => _40[slot]]));
1586
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _41 => _41[slot]]), _optionalChain([cSty, 'optionalAccess', _42 => _42[slot]]));
1587
+ const rootClassName = _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
1588
+ _chunkU2TWTEBYcjs.cx.call(void 0,
1589
+ "iuk-multi__empty",
1590
+ isDragging && "iuk-multi__empty--dragging",
1591
+ disabled && "iuk-multi__empty--disabled",
1592
+ hasError && "iuk-multi__empty--error"
1593
+ ),
1594
+ unstyled,
1595
+ _optionalChain([pCls, 'optionalAccess', _43 => _43.emptyDropzone]),
1596
+ _optionalChain([cCls, 'optionalAccess', _44 => _44.emptyDropzone]),
1597
+ isDragging && _optionalChain([pCls, 'optionalAccess', _45 => _45.emptyDropzoneDragging]),
1598
+ isDragging && _optionalChain([cCls, 'optionalAccess', _46 => _46.emptyDropzoneDragging]),
1599
+ disabled && _optionalChain([pCls, 'optionalAccess', _47 => _47.emptyDropzoneDisabled]),
1600
+ disabled && _optionalChain([cCls, 'optionalAccess', _48 => _48.emptyDropzoneDisabled]),
1601
+ hasError && _optionalChain([pCls, 'optionalAccess', _49 => _49.emptyDropzoneError]),
1602
+ hasError && _optionalChain([cCls, 'optionalAccess', _50 => _50.emptyDropzoneError])
1603
+ );
1604
+ const rootStyle = _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0,
1605
+ _optionalChain([pSty, 'optionalAccess', _51 => _51.emptyDropzone]),
1606
+ _optionalChain([cSty, 'optionalAccess', _52 => _52.emptyDropzone]),
1607
+ isDragging ? _optionalChain([pSty, 'optionalAccess', _53 => _53.emptyDropzoneDragging]) : void 0,
1608
+ isDragging ? _optionalChain([cSty, 'optionalAccess', _54 => _54.emptyDropzoneDragging]) : void 0,
1609
+ disabled ? _optionalChain([pSty, 'optionalAccess', _55 => _55.emptyDropzoneDisabled]) : void 0,
1610
+ disabled ? _optionalChain([cSty, 'optionalAccess', _56 => _56.emptyDropzoneDisabled]) : void 0,
1611
+ hasError ? _optionalChain([pSty, 'optionalAccess', _57 => _57.emptyDropzoneError]) : void 0,
1612
+ hasError ? _optionalChain([cSty, 'optionalAccess', _58 => _58.emptyDropzoneError]) : void 0
1613
+ );
1614
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1615
+ "div",
1616
+ {
1617
+ "data-slot": "empty-dropzone",
1618
+ "data-state": visualState,
1619
+ "data-dragging": isDragging || void 0,
1620
+ "data-disabled": disabled || void 0,
1621
+ "data-error": hasError || void 0,
1622
+ tabIndex: disabled ? -1 : 0,
1623
+ "aria-required": required || void 0,
1624
+ "aria-invalid": hasError || void 0,
1625
+ className: rootClassName,
1626
+ style: rootStyle,
1627
+ onPaste,
1628
+ ...dragHandlers,
1629
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-dropzone__prompt", unstyled), children: [
1630
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-dropzone__icon", unstyled), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImagePlusIcon, { size: 40, strokeWidth: 1.5 }) }),
1631
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1632
+ "h3",
1633
+ {
1634
+ "data-slot": "empty-title",
1635
+ className: slotClass("emptyTitle", "iuk-multi__title"),
1636
+ style: slotStyle("emptyTitle"),
1637
+ children: isDragging ? ui.dropImagesHere : ui.uploadImages
1638
+ }
1639
+ ),
1640
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1641
+ "p",
1642
+ {
1643
+ "data-slot": "empty-hint",
1644
+ className: slotClass("emptyHint", "iuk-dropzone__hint"),
1645
+ style: slotStyle("emptyHint"),
1646
+ children: isDragging ? ui.releaseToUpload : `${ui.dragDropOrChoose}${enablePaste ? ` (${ui.pasteHint})` : ""}`
1647
+ }
1648
+ ),
1649
+ !isDragging && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1650
+ "div",
1651
+ {
1652
+ "data-slot": "empty-actions",
1653
+ className: slotClass("emptyActions", "iuk-multi__btn-row"),
1654
+ style: slotStyle("emptyActions"),
1655
+ children: [
1656
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1657
+ "button",
1658
+ {
1659
+ type: "button",
1660
+ onClick: onSelectFiles,
1661
+ className: slotClass("primaryButton", "iuk-btn iuk-btn--primary"),
1662
+ style: slotStyle("primaryButton"),
1663
+ disabled,
1664
+ children: [
1665
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UploadIcon, { size: 16 }),
1666
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.selectFiles })
1667
+ ]
1668
+ }
1669
+ ),
1670
+ allowFolder && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1671
+ "button",
1672
+ {
1673
+ type: "button",
1674
+ onClick: onSelectFolder,
1675
+ className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary"),
1676
+ style: slotStyle("secondaryButton"),
1677
+ disabled,
1678
+ children: [
1679
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FolderOpenIcon, { size: 16 }),
1680
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.selectFolder })
1681
+ ]
1682
+ }
1683
+ )
1684
+ ]
1685
+ }
1686
+ ),
1687
+ !isDragging && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1688
+ "p",
1689
+ {
1690
+ "data-slot": "empty-subtext",
1691
+ className: slotClass("emptySubtext", "iuk-multi__subtext"),
1692
+ style: slotStyle("emptySubtext"),
1693
+ children: [
1694
+ ui.supportsFormats,
1695
+ " \u2022",
1696
+ " ",
1697
+ ui.maxPerFile.replace("{size}", String(maxSizeMB))
1698
+ ]
1699
+ }
1700
+ )
1701
+ ] })
1702
+ }
1703
+ );
1704
+ }
1705
+ function MultiAddMoreTile({
1706
+ isDragging,
1707
+ disabled = false,
1708
+ allowFolder = true,
1709
+ ui,
1710
+ dragHandlers,
1711
+ onSelectFiles,
1712
+ onSelectFolder,
1713
+ unstyled,
1714
+ providerClassNames: pCls,
1715
+ classNames: cCls,
1716
+ providerStyles: pSty,
1717
+ styles: cSty
1718
+ }) {
1719
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([pCls, 'optionalAccess', _59 => _59[slot]]), _optionalChain([cCls, 'optionalAccess', _60 => _60[slot]]));
1720
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _61 => _61[slot]]), _optionalChain([cSty, 'optionalAccess', _62 => _62[slot]]));
1721
+ const rootClassName = _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
1722
+ _chunkU2TWTEBYcjs.cx.call(void 0,
1723
+ "iuk-tile iuk-tile--add-more",
1724
+ isDragging && "iuk-tile--dragging",
1725
+ disabled && "iuk-tile--disabled"
1726
+ ),
1727
+ unstyled,
1728
+ _optionalChain([pCls, 'optionalAccess', _63 => _63.addMoreTile]),
1729
+ _optionalChain([cCls, 'optionalAccess', _64 => _64.addMoreTile]),
1730
+ isDragging && _optionalChain([pCls, 'optionalAccess', _65 => _65.addMoreTileDragging]),
1731
+ isDragging && _optionalChain([cCls, 'optionalAccess', _66 => _66.addMoreTileDragging])
1732
+ );
1733
+ const rootStyle = _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0,
1734
+ _optionalChain([pSty, 'optionalAccess', _67 => _67.addMoreTile]),
1735
+ _optionalChain([cSty, 'optionalAccess', _68 => _68.addMoreTile]),
1736
+ isDragging ? _optionalChain([pSty, 'optionalAccess', _69 => _69.addMoreTileDragging]) : void 0,
1737
+ isDragging ? _optionalChain([cSty, 'optionalAccess', _70 => _70.addMoreTileDragging]) : void 0
1738
+ );
1739
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1740
+ "div",
1741
+ {
1742
+ "data-slot": "add-more",
1743
+ "data-dragging": isDragging || void 0,
1744
+ "data-disabled": disabled || void 0,
1745
+ className: rootClassName,
1746
+ style: rootStyle,
1747
+ ...dragHandlers,
1748
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1749
+ "div",
1750
+ {
1751
+ "data-slot": "add-more-content",
1752
+ className: slotClass("addMoreContent", "iuk-tile__add-content"),
1753
+ style: slotStyle("addMoreContent"),
1754
+ children: [
1755
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImagePlusIcon, { size: 28, strokeWidth: 1.5 }),
1756
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: isDragging ? ui.dropHere : ui.addMore }),
1757
+ !isDragging && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1758
+ "div",
1759
+ {
1760
+ "data-slot": "add-more-actions",
1761
+ className: slotClass("addMoreActions", "iuk-tile__add-btns"),
1762
+ style: slotStyle("addMoreActions"),
1763
+ children: [
1764
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1765
+ "button",
1766
+ {
1767
+ type: "button",
1768
+ onClick: onSelectFiles,
1769
+ className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
1770
+ style: slotStyle("secondaryButton"),
1771
+ disabled,
1772
+ children: [
1773
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UploadIcon, { size: 13 }),
1774
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.files })
1775
+ ]
1776
+ }
1777
+ ),
1778
+ allowFolder && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1779
+ "button",
1780
+ {
1781
+ type: "button",
1782
+ onClick: onSelectFolder,
1783
+ className: slotClass("secondaryButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
1784
+ style: slotStyle("secondaryButton"),
1785
+ disabled,
1786
+ children: [
1787
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FolderOpenIcon, { size: 13 }),
1788
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.folder })
1789
+ ]
1790
+ }
1791
+ )
1792
+ ]
1793
+ }
1794
+ )
1795
+ ]
1796
+ }
1797
+ )
1798
+ }
1799
+ );
1800
+ }
1801
+
1802
+ // src/react/components/MultiUploadHeaderAlerts.tsx
1803
+
1804
+ function MultiUploadHeaderAlerts({
1805
+ label,
1806
+ labelId,
1807
+ inputId,
1808
+ required = false,
1809
+ disabled = false,
1810
+ totalCount,
1811
+ selectedCount,
1812
+ uploadingCount,
1813
+ missingAltCount,
1814
+ isUploading,
1815
+ hasFailedUploads,
1816
+ infoMessage,
1817
+ showMissingAltWarning,
1818
+ uploadStats,
1819
+ locale = "en",
1820
+ translations,
1821
+ ui,
1822
+ onSelectAll,
1823
+ onDeselectAll,
1824
+ onRemoveSelected,
1825
+ onRetryFailed,
1826
+ unstyled,
1827
+ providerClassNames,
1828
+ classNames,
1829
+ providerStyles,
1830
+ styles
1831
+ }) {
1832
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([providerClassNames, 'optionalAccess', _71 => _71[slot]]), _optionalChain([classNames, 'optionalAccess', _72 => _72[slot]]));
1833
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([providerStyles, 'optionalAccess', _73 => _73[slot]]), _optionalChain([styles, 'optionalAccess', _74 => _74[slot]]));
1834
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1835
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "header", className: slotClass("header", "iuk-multi__header"), style: slotStyle("header"), children: [
1836
+ (label || ui.uploadImages) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1837
+ "label",
1838
+ {
1839
+ id: labelId,
1840
+ htmlFor: inputId,
1841
+ "data-slot": "label",
1842
+ className: slotClass("label", "iuk-label"),
1843
+ style: slotStyle("label"),
1844
+ children: [
1845
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: label || ui.uploadImages }),
1846
+ required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-required", unstyled), children: "*" }),
1847
+ totalCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { "data-slot": "count", className: slotClass("count", "iuk-multi__count"), style: slotStyle("count"), children: [
1848
+ "(",
1849
+ totalCount,
1850
+ ")"
1851
+ ] })
1852
+ ]
1853
+ }
1854
+ ),
1855
+ totalCount > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-slot": "bulk-actions", className: slotClass("bulkActions", "iuk-multi__bulk"), style: slotStyle("bulkActions"), children: selectedCount === 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1856
+ "button",
1857
+ {
1858
+ type: "button",
1859
+ onClick: onSelectAll,
1860
+ disabled,
1861
+ className: slotClass("bulkButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
1862
+ style: slotStyle("bulkButton"),
1863
+ children: ui.selectAll
1864
+ }
1865
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1866
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1867
+ "button",
1868
+ {
1869
+ type: "button",
1870
+ onClick: onDeselectAll,
1871
+ disabled,
1872
+ className: slotClass("bulkButton", "iuk-btn iuk-btn--secondary iuk-btn--sm"),
1873
+ style: slotStyle("bulkButton"),
1874
+ children: [
1875
+ ui.deselectAll,
1876
+ " (",
1877
+ selectedCount,
1878
+ ")"
1879
+ ]
1880
+ }
1881
+ ),
1882
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1883
+ "button",
1884
+ {
1885
+ type: "button",
1886
+ onClick: onRemoveSelected,
1887
+ disabled,
1888
+ className: slotClass("bulkDangerButton", "iuk-btn iuk-btn--danger iuk-btn--sm"),
1889
+ style: slotStyle("bulkDangerButton"),
1890
+ children: [
1891
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TrashIcon, { size: 14 }),
1892
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.removeSelected })
1893
+ ]
1894
+ }
1895
+ )
1896
+ ] }) })
1897
+ ] }),
1898
+ isUploading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1899
+ "div",
1900
+ {
1901
+ "data-slot": "alert",
1902
+ role: "status",
1903
+ "aria-live": "polite",
1904
+ className: slotClass("alert", "iuk-alert iuk-alert--info"),
1905
+ style: slotStyle("alert"),
1906
+ children: [
1907
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-alert__row", unstyled), children: [
1908
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderIcon, { size: 16, className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-spin", unstyled) }),
1909
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
1910
+ _chunkU2TWTEBYcjs.formatUploadingCount.call(void 0, ui, uploadingCount, locale, translations),
1911
+ "..."
1912
+ ] })
1913
+ ] }),
1914
+ uploadStats.total > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "strong", { children: [
1915
+ uploadStats.completed + uploadStats.failed,
1916
+ " / ",
1917
+ uploadStats.total
1918
+ ] })
1919
+ ]
1920
+ }
1921
+ ),
1922
+ hasFailedUploads && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1923
+ "div",
1924
+ {
1925
+ "data-slot": "alert",
1926
+ role: "alert",
1927
+ className: slotClass("alert", "iuk-alert iuk-alert--error"),
1928
+ style: slotStyle("alert"),
1929
+ children: [
1930
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XCircleIcon, { size: 16 }),
1931
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
1932
+ ui.someUploadsFailed,
1933
+ " ",
1934
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1935
+ "button",
1936
+ {
1937
+ type: "button",
1938
+ onClick: onRetryFailed,
1939
+ disabled: isUploading || disabled,
1940
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-link-btn", unstyled),
1941
+ children: ui.retryFailedUploads
1942
+ }
1943
+ )
1944
+ ] })
1945
+ ]
1946
+ }
1947
+ ),
1948
+ infoMessage && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1949
+ "div",
1950
+ {
1951
+ "data-slot": "alert",
1952
+ role: "status",
1953
+ className: slotClass("alert", "iuk-alert iuk-alert--success"),
1954
+ style: slotStyle("alert"),
1955
+ children: [
1956
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCircleIcon, { size: 16 }),
1957
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: infoMessage })
1958
+ ]
1959
+ }
1960
+ ),
1961
+ showMissingAltWarning && missingAltCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1962
+ "div",
1963
+ {
1964
+ "data-slot": "alert",
1965
+ role: "alert",
1966
+ className: slotClass("alert", "iuk-alert iuk-alert--warning"),
1967
+ style: slotStyle("alert"),
1968
+ children: [
1969
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertTriangleIcon, { size: 16 }),
1970
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunkU2TWTEBYcjs.formatNeedsAltMessage.call(void 0, ui, missingAltCount, locale) })
1971
+ ]
1972
+ }
1973
+ )
1974
+ ] });
1975
+ }
1976
+ function MultiFooterSection({
1977
+ helperText,
1978
+ displayError,
1979
+ statusTextId,
1980
+ isOpen,
1981
+ hasPreviews,
1982
+ hasCompletedPreviews,
1983
+ isUploading,
1984
+ disabled,
1985
+ requireAltText,
1986
+ missingAltCount,
1987
+ onSave,
1988
+ ui,
1989
+ unstyled,
1990
+ providerClassNames,
1991
+ classNames,
1992
+ providerStyles,
1993
+ styles
1994
+ }) {
1995
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([providerClassNames, 'optionalAccess', _75 => _75[slot]]), _optionalChain([classNames, 'optionalAccess', _76 => _76[slot]]));
1996
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([providerStyles, 'optionalAccess', _77 => _77[slot]]), _optionalChain([styles, 'optionalAccess', _78 => _78[slot]]));
1997
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1998
+ (helperText || displayError) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1999
+ "p",
2000
+ {
2001
+ id: statusTextId,
2002
+ role: displayError ? "alert" : void 0,
2003
+ "data-slot": displayError ? "error-text" : "helper-text",
2004
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
2005
+ _chunkU2TWTEBYcjs.cx.call(void 0, "iuk-helper-text", Boolean(displayError) && "iuk-helper-text--error"),
2006
+ unstyled,
2007
+ _optionalChain([providerClassNames, 'optionalAccess', _79 => _79.helperText]),
2008
+ _optionalChain([classNames, 'optionalAccess', _80 => _80.helperText]),
2009
+ Boolean(displayError) && _optionalChain([providerClassNames, 'optionalAccess', _81 => _81.errorText]),
2010
+ Boolean(displayError) && _optionalChain([classNames, 'optionalAccess', _82 => _82.errorText])
2011
+ ),
2012
+ style: _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0,
2013
+ _optionalChain([providerStyles, 'optionalAccess', _83 => _83.helperText]),
2014
+ _optionalChain([styles, 'optionalAccess', _84 => _84.helperText]),
2015
+ displayError ? _optionalChain([providerStyles, 'optionalAccess', _85 => _85.errorText]) : void 0,
2016
+ displayError ? _optionalChain([styles, 'optionalAccess', _86 => _86.errorText]) : void 0
2017
+ ),
2018
+ children: displayError || helperText
2019
+ }
2020
+ ),
2021
+ isOpen && hasPreviews && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "commit-bar", className: slotClass("commitBar", "iuk-commit-bar"), style: slotStyle("commitBar"), children: [
2022
+ requireAltText && missingAltCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-badge iuk-badge--warning", unstyled), children: [
2023
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertTriangleIcon, { size: 13 }),
2024
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.withoutAltText.replace("{count}", String(missingAltCount)) })
2025
+ ] }),
2026
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2027
+ SaveButton,
2028
+ {
2029
+ unstyled,
2030
+ className: slotClass("saveButton"),
2031
+ style: slotStyle("saveButton"),
2032
+ onClick: onSave,
2033
+ disabled: isUploading || disabled || !hasCompletedPreviews || requireAltText && missingAltCount > 0,
2034
+ icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SaveIcon, { size: 16 }),
2035
+ children: ui.saveImages
2036
+ }
2037
+ )
2038
+ ] })
2039
+ ] });
2040
+ }
2041
+
2042
+ // src/react/components/PreviewTile.tsx
2043
+
2044
+
2045
+ function PreviewTile({
2046
+ preview,
2047
+ onRemove,
2048
+ onCancel,
2049
+ onRetry,
2050
+ disabled = false,
2051
+ blurType = "card",
2052
+ isSelected = false,
2053
+ onToggleSelect,
2054
+ onEditAltText,
2055
+ showCheckbox = true,
2056
+ onAdjustColor,
2057
+ onChangeColor,
2058
+ onChangeAltText,
2059
+ appendCacheBuster: appendBuster = false,
2060
+ locale: propLocale,
2061
+ translations,
2062
+ renderImage,
2063
+ unstyled: propUnstyled,
2064
+ className,
2065
+ style
2066
+ }) {
2067
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
2068
+ const isUnstyled = _nullishCoalesce(propUnstyled, () => ( ctx.unstyled));
2069
+ const locale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, propLocale || ctx.locale);
2070
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, locale, translations || ctx.translations);
2071
+ const [showBlurModal, setShowBlurModal] = _react.useState.call(void 0, false);
2072
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
2073
+ const isSvg = Boolean(
2074
+ _optionalChain([preview, 'access', _87 => _87.url, 'optionalAccess', _88 => _88.toLowerCase, 'call', _89 => _89(), 'access', _90 => _90.includes, 'call', _91 => _91(".svg")]) || _optionalChain([preview, 'access', _92 => _92.data, 'optionalAccess', _93 => _93.format]) === "svg" || _optionalChain([preview, 'access', _94 => _94.url, 'optionalAccess', _95 => _95.includes, 'call', _96 => _96("image/svg+xml")])
2075
+ );
2076
+ const displayUrl = _react.useMemo.call(void 0,
2077
+ () => _chunkU2TWTEBYcjs.appendCacheBuster.call(void 0, preview.url, {
2078
+ enabled: appendBuster,
2079
+ token: _optionalChain([preview, 'access', _97 => _97.data, 'optionalAccess', _98 => _98.contentHash]) || _optionalChain([preview, 'access', _99 => _99.data, 'optionalAccess', _100 => _100.uploadedAt])
2080
+ }),
2081
+ [preview.url, _optionalChain([preview, 'access', _101 => _101.data, 'optionalAccess', _102 => _102.contentHash]), _optionalChain([preview, 'access', _103 => _103.data, 'optionalAccess', _104 => _104.uploadedAt]), appendBuster]
2082
+ );
2083
+ const fallbackBlurDataURL = useBlurDataURL(preview.url, { type: blurType, size: "small" });
2084
+ const actualBlurDataUrl = _optionalChain([preview, 'access', _105 => _105.data, 'optionalAccess', _106 => _106.blurDataUrl]) || fallbackBlurDataURL;
2085
+ const actualBlurColor = preview.blurColor || _optionalChain([preview, 'access', _107 => _107.data, 'optionalAccess', _108 => _108.blurColor]);
2086
+ const isUploading = Boolean(preview.isUploading);
2087
+ const hasError = Boolean(preview.error);
2088
+ const visualState = _chunkU2TWTEBYcjs.resolveUploadDataState.call(void 0, {
2089
+ disabled,
2090
+ hasError,
2091
+ isUploading,
2092
+ hasContent: true
2093
+ });
2094
+ const isSuccess = Boolean(
2095
+ !isUploading && !hasError && preview.originalSize && preview.optimizedSize
2096
+ );
2097
+ const reductionPercent = isSuccess && preview.originalSize && preview.optimizedSize ? Math.round(
2098
+ (preview.originalSize - preview.optimizedSize) / preview.originalSize * 100
2099
+ ) : 0;
2100
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2101
+ "div",
2102
+ {
2103
+ "data-slot": "tile",
2104
+ "data-state": visualState,
2105
+ "data-selected": isSelected || void 0,
2106
+ "data-uploading": isUploading || void 0,
2107
+ "data-error": hasError || void 0,
2108
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
2109
+ _chunkU2TWTEBYcjs.cx.call(void 0, "iuk-tile", isSelected && "iuk-tile--selected", hasError && "iuk-tile--error"),
2110
+ isUnstyled,
2111
+ className
2112
+ ),
2113
+ style,
2114
+ onClick: () => onToggleSelect && !disabled && onToggleSelect(preview.id),
2115
+ children: [
2116
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "tile-media", className: cls("iuk-tile__media"), children: [
2117
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2118
+ BlurImage,
2119
+ {
2120
+ src: displayUrl,
2121
+ alt: preview.altText || ui.previewAlt,
2122
+ blurDataUrl: !isSvg ? actualBlurDataUrl : void 0,
2123
+ blurColor: actualBlurColor,
2124
+ blurHash: _optionalChain([preview, 'access', _109 => _109.data, 'optionalAccess', _110 => _110.blurHash]),
2125
+ objectFit: isSvg ? "contain" : "cover",
2126
+ style: isSvg ? { padding: "8px" } : void 0,
2127
+ renderImage
2128
+ }
2129
+ ),
2130
+ showCheckbox && !disabled && !isUploading && onToggleSelect && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2131
+ "div",
2132
+ {
2133
+ "data-slot": "tile-checkbox",
2134
+ className: cls("iuk-tile__checkbox"),
2135
+ onClick: (e) => e.stopPropagation(),
2136
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2137
+ "input",
2138
+ {
2139
+ type: "checkbox",
2140
+ checked: isSelected,
2141
+ onChange: () => onToggleSelect(preview.id),
2142
+ "aria-label": ui.selectImageAria
2143
+ }
2144
+ )
2145
+ }
2146
+ ),
2147
+ !disabled && onEditAltText && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2148
+ "button",
2149
+ {
2150
+ type: "button",
2151
+ "data-slot": "tile-alt-btn",
2152
+ className: cls(
2153
+ _chunkU2TWTEBYcjs.cx.call(void 0,
2154
+ "iuk-tile__action iuk-tile__action--alt",
2155
+ Boolean(preview.altText) && "iuk-tile__action--has-alt"
2156
+ )
2157
+ ),
2158
+ onClick: (e) => {
2159
+ e.stopPropagation();
2160
+ onEditAltText(preview.id);
2161
+ },
2162
+ "aria-label": preview.altText ? ui.editAltTextAria : ui.addAltTextAria,
2163
+ title: preview.altText ? ui.editPrefix.replace("{title}", preview.altText) : ui.addDescriptionForA11y,
2164
+ children: preview.altText ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCircleIcon, { size: 14 }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TypeIcon, { size: 14 })
2165
+ }
2166
+ ),
2167
+ !disabled && !isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2168
+ "button",
2169
+ {
2170
+ type: "button",
2171
+ "data-slot": "tile-blur-btn",
2172
+ className: cls("iuk-tile__action iuk-tile__action--blur"),
2173
+ onClick: (e) => {
2174
+ e.stopPropagation();
2175
+ if (onAdjustColor) onAdjustColor(preview.id);
2176
+ else setShowBlurModal(true);
2177
+ },
2178
+ "aria-label": ui.adjustBlurColorAria,
2179
+ title: ui.adjustBlurColorTitle,
2180
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PaletteIcon, { size: 14 })
2181
+ }
2182
+ ),
2183
+ !disabled && !isUploading && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2184
+ "button",
2185
+ {
2186
+ type: "button",
2187
+ "data-slot": "tile-remove-btn",
2188
+ className: cls("iuk-tile__action iuk-tile__action--remove"),
2189
+ onClick: (e) => {
2190
+ e.stopPropagation();
2191
+ onRemove(preview.id);
2192
+ },
2193
+ "aria-label": ui.removeImageAria,
2194
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { size: 15 })
2195
+ }
2196
+ ),
2197
+ isUploading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "tile-overlay", className: cls("iuk-tile__overlay"), children: [
2198
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderIcon, { size: 24, className: cls("iuk-spin") }),
2199
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: cls("iuk-tile__status"), children: preview.uploadMessage || `${ui.uploading}...` }),
2200
+ preview.progress !== void 0 && preview.progress > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2201
+ "div",
2202
+ {
2203
+ role: "progressbar",
2204
+ "aria-valuenow": Math.round(preview.progress),
2205
+ "aria-valuemin": 0,
2206
+ "aria-valuemax": 100,
2207
+ "aria-label": ui.uploading,
2208
+ className: cls("iuk-progress-bar"),
2209
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2210
+ "div",
2211
+ {
2212
+ className: cls("iuk-progress-bar__fill"),
2213
+ style: { width: `${preview.progress}%` }
2214
+ }
2215
+ )
2216
+ }
2217
+ ),
2218
+ !disabled && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2219
+ "button",
2220
+ {
2221
+ type: "button",
2222
+ "data-slot": "tile-cancel",
2223
+ className: cls("iuk-btn iuk-btn--secondary iuk-btn--sm iuk-tile__cancel-btn"),
2224
+ onClick: (e) => {
2225
+ e.stopPropagation();
2226
+ (_nullishCoalesce(onCancel, () => ( onRemove)))(preview.id);
2227
+ },
2228
+ "aria-label": ui.cancelUpload,
2229
+ children: [
2230
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { size: 13 }),
2231
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.cancelUpload })
2232
+ ]
2233
+ }
2234
+ )
2235
+ ] }),
2236
+ isSuccess && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "tile-badge", className: cls("iuk-tile__badge iuk-tile__badge--success"), children: [
2237
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckCircleIcon, { size: 13 }),
2238
+ reductionPercent > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
2239
+ "-",
2240
+ reductionPercent,
2241
+ "%"
2242
+ ] })
2243
+ ] }),
2244
+ !disabled && !isUploading && !hasError && actualBlurColor && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "tile-color-badge", className: cls("iuk-tile__badge iuk-tile__badge--color"), children: [
2245
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-tile__color-dot"), style: { backgroundColor: actualBlurColor } }),
2246
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { children: actualBlurColor.toUpperCase() })
2247
+ ] }),
2248
+ hasError && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2249
+ "div",
2250
+ {
2251
+ "data-slot": "tile-error",
2252
+ role: "alert",
2253
+ className: cls("iuk-tile__overlay iuk-tile__overlay--error"),
2254
+ children: [
2255
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XCircleIcon, { size: 22 }),
2256
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { children: preview.error }),
2257
+ !disabled && onRetry && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2258
+ "button",
2259
+ {
2260
+ type: "button",
2261
+ "data-slot": "tile-retry",
2262
+ className: cls("iuk-btn iuk-btn--secondary iuk-btn--sm iuk-tile__retry-btn"),
2263
+ onClick: (e) => {
2264
+ e.stopPropagation();
2265
+ onRetry(preview.id);
2266
+ },
2267
+ "aria-label": ui.retryUpload,
2268
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.retryUpload })
2269
+ }
2270
+ )
2271
+ ]
2272
+ }
2273
+ )
2274
+ ] }),
2275
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2276
+ BlurVisualizationModal,
2277
+ {
2278
+ isOpen: showBlurModal,
2279
+ onClose: () => setShowBlurModal(false),
2280
+ imageUrl: preview.url,
2281
+ blurDataUrl: actualBlurDataUrl,
2282
+ blurColor: actualBlurColor,
2283
+ detectedColor: _optionalChain([preview, 'access', _111 => _111.data, 'optionalAccess', _112 => _112.blurColor]),
2284
+ altText: preview.altText,
2285
+ originalSize: preview.originalSize,
2286
+ optimizedSize: preview.optimizedSize,
2287
+ locale,
2288
+ translations,
2289
+ renderImage,
2290
+ unstyled: isUnstyled,
2291
+ onChangeColor: (hex) => _optionalChain([onChangeColor, 'optionalCall', _113 => _113(preview.id, hex)]),
2292
+ onUseDetectedColor: onChangeColor && _optionalChain([preview, 'access', _114 => _114.data, 'optionalAccess', _115 => _115.blurColor]) ? () => onChangeColor(preview.id, preview.data.blurColor) : void 0,
2293
+ onChangeAltText: (nextAlt) => _optionalChain([onChangeAltText, 'optionalCall', _116 => _116(preview.id, nextAlt)])
2294
+ }
2295
+ )
2296
+ ]
2297
+ }
2298
+ );
2299
+ }
2300
+
2301
+ // src/react/components/QualitySelector.tsx
2302
+
2303
+ function formatBytesCompact(bytes) {
2304
+ if (bytes < 1024) return `${bytes} B`;
2305
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
2306
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
2307
+ }
2308
+ function QualitySelector({
2309
+ value,
2310
+ onChange,
2311
+ preset,
2312
+ recommendedLevel,
2313
+ recommendationNote,
2314
+ originalFileSize,
2315
+ locale,
2316
+ translations,
2317
+ disabled = false,
2318
+ unstyled = false
2319
+ }) {
2320
+ const resolvedLocale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, locale);
2321
+ const isAr = resolvedLocale === "ar";
2322
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, resolvedLocale, translations);
2323
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled);
2324
+ const standardPreset = preset ? _chunkNEDBIIE3cjs.STANDARD_PRESETS[preset] : void 0;
2325
+ const recommended = recommendedLevel || _optionalChain([standardPreset, 'optionalAccess', _117 => _117.recommendedQualityLevel]) || "high";
2326
+ const note = recommendationNote || _optionalChain([standardPreset, 'optionalAccess', _118 => _118.recommendationNote]);
2327
+ const selected = _chunkKJVYWKIGcjs.QUALITY_PRESETS[value];
2328
+ const levels = Object.keys(_chunkKJVYWKIGcjs.QUALITY_PRESETS);
2329
+ const estimatedSize = originalFileSize !== void 0 ? _chunkKJVYWKIGcjs.estimateOutputSize.call(void 0, originalFileSize, value) : null;
2330
+ const saving = Math.round((1 - selected.compressionRatio) * 100);
2331
+ const handleRadioGroupKeyDown = (event) => {
2332
+ if (disabled) return;
2333
+ const currentIndex = Math.max(0, levels.indexOf(value));
2334
+ let nextIndex = -1;
2335
+ if (event.key === "ArrowRight" || event.key === "ArrowDown") {
2336
+ const step = event.key === "ArrowRight" && isAr ? -1 : 1;
2337
+ nextIndex = (currentIndex + step + levels.length) % levels.length;
2338
+ } else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
2339
+ const step = event.key === "ArrowLeft" && isAr ? 1 : -1;
2340
+ nextIndex = (currentIndex + step + levels.length) % levels.length;
2341
+ } else if (event.key === "Home") {
2342
+ nextIndex = 0;
2343
+ } else if (event.key === "End") {
2344
+ nextIndex = levels.length - 1;
2345
+ }
2346
+ if (nextIndex >= 0) {
2347
+ event.preventDefault();
2348
+ const nextLevel = levels[nextIndex];
2349
+ onChange(nextLevel);
2350
+ const buttons = event.currentTarget.querySelectorAll('[role="radio"]');
2351
+ _optionalChain([buttons, 'access', _119 => _119[nextIndex], 'optionalAccess', _120 => _120.focus, 'call', _121 => _121()]);
2352
+ }
2353
+ };
2354
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2355
+ "div",
2356
+ {
2357
+ "data-slot": "quality-root",
2358
+ "data-unstyled": unstyled || void 0,
2359
+ className: cls("iuk-quality"),
2360
+ dir: isAr ? "rtl" : "ltr",
2361
+ children: [
2362
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-quality__header"), children: [
2363
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-quality__title"), children: ui.qualityTitle }),
2364
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls(`iuk-quality__pill iuk-quality__pill--${value}`), children: [
2365
+ isAr ? selected.labelAr : selected.label,
2366
+ " \xB7 Q",
2367
+ selected.value
2368
+ ] })
2369
+ ] }),
2370
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2371
+ "div",
2372
+ {
2373
+ className: cls("iuk-quality__tabs"),
2374
+ role: "radiogroup",
2375
+ "aria-label": ui.qualityLevelAria,
2376
+ onKeyDown: handleRadioGroupKeyDown,
2377
+ children: levels.map((level) => {
2378
+ const item = _chunkKJVYWKIGcjs.QUALITY_PRESETS[level];
2379
+ const isSelected = value === level;
2380
+ const isRecommended = level === recommended;
2381
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2382
+ "button",
2383
+ {
2384
+ type: "button",
2385
+ role: "radio",
2386
+ "aria-checked": isSelected,
2387
+ tabIndex: disabled ? -1 : isSelected ? 0 : -1,
2388
+ disabled,
2389
+ onClick: () => !disabled && onChange(level),
2390
+ className: cls(
2391
+ _chunkU2TWTEBYcjs.cx.call(void 0,
2392
+ "iuk-quality__tab",
2393
+ isSelected && "iuk-quality__tab--selected",
2394
+ isRecommended && !isSelected && "iuk-quality__tab--recommended",
2395
+ disabled && "iuk-quality__tab--disabled"
2396
+ )
2397
+ ),
2398
+ children: [
2399
+ isSelected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CheckIcon, { size: 11, strokeWidth: 3, "aria-hidden": "true" }),
2400
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: isAr ? item.labelAr : item.label }),
2401
+ isRecommended && !isSelected && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-quality__star"), "aria-hidden": "true", children: "\u2605" })
2402
+ ]
2403
+ },
2404
+ level
2405
+ );
2406
+ })
2407
+ }
2408
+ ),
2409
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls(`iuk-quality__detail iuk-quality__detail--${value}`), children: [
2410
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: cls("iuk-quality__desc"), children: isAr ? selected.descriptionAr : selected.description }),
2411
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-quality__meta"), children: [
2412
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-quality__tag"), children: [
2413
+ "Q",
2414
+ selected.value
2415
+ ] }),
2416
+ estimatedSize !== null && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
2417
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-quality__dot"), "aria-hidden": "true" }),
2418
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ZapIcon, { size: 11, "aria-hidden": "true" }),
2419
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { children: [
2420
+ "~",
2421
+ formatBytesCompact(estimatedSize)
2422
+ ] }),
2423
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-quality__dot"), "aria-hidden": "true" }),
2424
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-quality__saving"), children: [
2425
+ saving,
2426
+ "% ",
2427
+ ui.qualitySaved
2428
+ ] })
2429
+ ] }),
2430
+ value === recommended && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-quality__rec-badge"), children: [
2431
+ "\u2B50 ",
2432
+ ui.qualityRecommended
2433
+ ] })
2434
+ ] })
2435
+ ] }),
2436
+ note && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-quality__note"), children: [
2437
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InfoIcon, { size: 12, "aria-hidden": "true", className: cls("iuk-quality__note-icon") }),
2438
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: isAr ? note.ar || note.en : note.en })
2439
+ ] })
2440
+ ]
2441
+ }
2442
+ );
2443
+ }
2444
+
2445
+ // src/react/components/UploadProgressPanel.tsx
2446
+
2447
+
2448
+ var PROGRESS_PANEL_DISMISS_DELAY_MS = 2500;
2449
+ function useRetainedProgressItems(uploadingPreviews, previews) {
2450
+ const [retainedItems, setRetainedItems] = _react.useState.call(void 0, null);
2451
+ const activeBatchRef = _react.useRef.call(void 0, /* @__PURE__ */ new Map());
2452
+ const dismissTimerRef = _react.useRef.call(void 0, null);
2453
+ const prevUploadingCountRef = _react.useRef.call(void 0, 0);
2454
+ const isUploading = uploadingPreviews.length > 0;
2455
+ _react.useEffect.call(void 0, () => {
2456
+ if (isUploading) {
2457
+ if (dismissTimerRef.current) {
2458
+ clearTimeout(dismissTimerRef.current);
2459
+ dismissTimerRef.current = null;
2460
+ activeBatchRef.current.clear();
2461
+ }
2462
+ setRetainedItems(null);
2463
+ for (const p2 of uploadingPreviews) {
2464
+ activeBatchRef.current.set(p2.id, {
2465
+ id: p2.id,
2466
+ url: p2.url,
2467
+ fileName: p2.fileName || _optionalChain([p2, 'access', _122 => _122.file, 'optionalAccess', _123 => _123.name]),
2468
+ message: p2.uploadMessage || void 0,
2469
+ progress: p2.progress
2470
+ });
2471
+ }
2472
+ } else if (prevUploadingCountRef.current > 0 && activeBatchRef.current.size > 0) {
2473
+ const completed = Array.from(activeBatchRef.current.values()).map((it) => {
2474
+ const found = previews.find((p2) => p2.id === it.id);
2475
+ return {
2476
+ ...it,
2477
+ progress: _nullishCoalesce(_optionalChain([found, 'optionalAccess', _124 => _124.progress]), () => ( 100)),
2478
+ message: _optionalChain([found, 'optionalAccess', _125 => _125.error]) ? found.error : _optionalChain([found, 'optionalAccess', _126 => _126.uploadMessage]) || void 0
2479
+ };
2480
+ });
2481
+ setRetainedItems(completed);
2482
+ dismissTimerRef.current = setTimeout(() => {
2483
+ setRetainedItems(null);
2484
+ activeBatchRef.current.clear();
2485
+ dismissTimerRef.current = null;
2486
+ }, PROGRESS_PANEL_DISMISS_DELAY_MS);
2487
+ }
2488
+ prevUploadingCountRef.current = uploadingPreviews.length;
2489
+ }, [isUploading, uploadingPreviews, previews]);
2490
+ _react.useEffect.call(void 0, () => () => {
2491
+ if (dismissTimerRef.current) clearTimeout(dismissTimerRef.current);
2492
+ }, []);
2493
+ return isUploading ? uploadingPreviews.map((p2) => ({
2494
+ id: p2.id,
2495
+ url: p2.url,
2496
+ fileName: p2.fileName || _optionalChain([p2, 'access', _127 => _127.file, 'optionalAccess', _128 => _128.name]),
2497
+ message: p2.uploadMessage || void 0,
2498
+ progress: p2.progress
2499
+ })) : _nullishCoalesce(retainedItems, () => ( []));
2500
+ }
2501
+ function UploadProgressPanel({
2502
+ items,
2503
+ completedCount,
2504
+ totalCount,
2505
+ locale: propLocale,
2506
+ translations,
2507
+ renderImage,
2508
+ unstyled: propUnstyled
2509
+ }) {
2510
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
2511
+ const isUnstyled = _nullishCoalesce(propUnstyled, () => ( ctx.unstyled));
2512
+ const locale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, propLocale || ctx.locale);
2513
+ const effectiveOverrides = translations || ctx.translations;
2514
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0, locale, effectiveOverrides);
2515
+ const [isMinimized, setIsMinimized] = _react.useState.call(void 0, false);
2516
+ const uploadingCount = items.length;
2517
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
2518
+ if (uploadingCount === 0) return null;
2519
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2520
+ "div",
2521
+ {
2522
+ "data-upload-progress-dock": true,
2523
+ "data-slot": "progress-dock",
2524
+ "data-unstyled": isUnstyled || void 0,
2525
+ dir: locale === "ar" ? "rtl" : "ltr",
2526
+ className: cls(
2527
+ _chunkU2TWTEBYcjs.cx.call(void 0, "iuk-progress-dock", isMinimized && "iuk-progress-dock--collapsed")
2528
+ ),
2529
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2530
+ "div",
2531
+ {
2532
+ className: cls(
2533
+ _chunkU2TWTEBYcjs.cx.call(void 0, "iuk-progress-panel", isMinimized && "iuk-progress-panel--minimized")
2534
+ ),
2535
+ children: [
2536
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2537
+ "button",
2538
+ {
2539
+ type: "button",
2540
+ className: cls("iuk-progress-panel__header"),
2541
+ "aria-expanded": !isMinimized,
2542
+ onClick: () => setIsMinimized((prev) => !prev),
2543
+ children: [
2544
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-progress-panel__title"), children: [
2545
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderIcon, { size: 16, className: cls("iuk-spin") }),
2546
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: _chunkU2TWTEBYcjs.formatUploadingCount.call(void 0, ui, uploadingCount, locale, effectiveOverrides) }),
2547
+ totalCount > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-progress-panel__count"), children: [
2548
+ "(",
2549
+ completedCount,
2550
+ "/",
2551
+ totalCount,
2552
+ ")"
2553
+ ] })
2554
+ ] }),
2555
+ isMinimized ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronUpIcon, { size: 18 }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronDownIcon, { size: 18 })
2556
+ ]
2557
+ }
2558
+ ),
2559
+ !isMinimized && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-progress-panel__body"), children: items.map((item) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-progress-item"), children: [
2560
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-progress-item__thumb"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2561
+ BlurImage,
2562
+ {
2563
+ src: item.url,
2564
+ alt: ui.uploadingAlt,
2565
+ objectFit: "cover",
2566
+ renderImage
2567
+ }
2568
+ ) }),
2569
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-progress-item__info"), children: [
2570
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-progress-item__name"), children: item.fileName || ui.image }),
2571
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-progress-item__status"), children: item.message || ui.processing }),
2572
+ item.progress !== void 0 && item.progress > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2573
+ "div",
2574
+ {
2575
+ role: "progressbar",
2576
+ "aria-valuenow": Math.round(item.progress),
2577
+ "aria-valuemin": 0,
2578
+ "aria-valuemax": 100,
2579
+ "aria-label": item.fileName || ui.uploading,
2580
+ className: cls("iuk-progress-bar"),
2581
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2582
+ "div",
2583
+ {
2584
+ className: cls("iuk-progress-bar__fill"),
2585
+ style: { width: `${item.progress}%` }
2586
+ }
2587
+ )
2588
+ }
2589
+ )
2590
+ ] })
2591
+ ] }, item.id)) })
2592
+ ]
2593
+ }
2594
+ )
2595
+ }
2596
+ );
2597
+ }
2598
+
2599
+ // src/react/components/MultiImageUpload.tsx
2600
+
2601
+ var DEFAULT_ACCEPT = "image/jpeg,image/png,image/webp,image/avif,image/svg+xml";
2602
+ var FOLDER_INPUT_ATTRS = { webkitdirectory: "", directory: "" };
2603
+ function MultiImageUploadInner(props, ref) {
2604
+ const {
2605
+ preset,
2606
+ translations,
2607
+ renderImage,
2608
+ label,
2609
+ error,
2610
+ helperText,
2611
+ className,
2612
+ style,
2613
+ recommendedQuality,
2614
+ qualityNote,
2615
+ isOpen,
2616
+ maxImages = 999,
2617
+ accept = DEFAULT_ACCEPT,
2618
+ allowFolder = true,
2619
+ disabled = false,
2620
+ required = false,
2621
+ blurType = "card",
2622
+ showQualitySelector = true,
2623
+ capture,
2624
+ enablePaste = true,
2625
+ pasteTarget = "dropzone",
2626
+ name,
2627
+ onBlur,
2628
+ classNames: cCls,
2629
+ styles: cSty,
2630
+ renderHeader,
2631
+ renderEmptyDropzone,
2632
+ renderTile,
2633
+ renderAddMore
2634
+ } = props;
2635
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
2636
+ const isUnstyled = _nullishCoalesce(props.unstyled, () => ( ctx.unstyled));
2637
+ const pCls = ctx.multiClassNames;
2638
+ const pSty = ctx.multiStyles;
2639
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled, _optionalChain([pCls, 'optionalAccess', _129 => _129[slot]]), _optionalChain([cCls, 'optionalAccess', _130 => _130[slot]]));
2640
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _131 => _131[slot]]), _optionalChain([cSty, 'optionalAccess', _132 => _132[slot]]));
2641
+ const state = _chunkU2TWTEBYcjs.useMultiImageState.call(void 0, props);
2642
+ const { locale, ui, previews, selectedPreviews, uploadingPreviews, imagesWithoutAlt, editingTarget } = state;
2643
+ const rootRef = _react.useRef.call(void 0, null);
2644
+ const labelId = _react.useId.call(void 0, );
2645
+ const inputId = _react.useId.call(void 0, );
2646
+ const statusTextId = _react.useId.call(void 0, );
2647
+ const fileInputRef = _react.useRef.call(void 0, null);
2648
+ const folderInputRef = _react.useRef.call(void 0, null);
2649
+ const dockItems = useRetainedProgressItems(uploadingPreviews, previews);
2650
+ const { isDragging, dragHandlers } = _chunkU2TWTEBYcjs.useDragAndDrop.call(void 0, {
2651
+ disabled,
2652
+ onDrop: (files) => void state.handleFileSelect(files)
2653
+ });
2654
+ const { onPaste } = _chunkU2TWTEBYcjs.useClipboardPaste.call(void 0, {
2655
+ enabled: enablePaste,
2656
+ pasteTarget,
2657
+ disabled,
2658
+ multiple: true,
2659
+ onPasteFiles: (files) => {
2660
+ void state.handleFileSelect(files);
2661
+ }
2662
+ });
2663
+ const openFilePicker = () => {
2664
+ if (!disabled) _optionalChain([fileInputRef, 'access', _133 => _133.current, 'optionalAccess', _134 => _134.click, 'call', _135 => _135()]);
2665
+ };
2666
+ const openFolderPicker = () => {
2667
+ if (!disabled) _optionalChain([folderInputRef, 'access', _136 => _136.current, 'optionalAccess', _137 => _137.click, 'call', _138 => _138()]);
2668
+ };
2669
+ const selectAll = () => state.setSelectedPreviews(new Set(previews.map((p2) => p2.id)));
2670
+ const clearSelection = () => state.setSelectedPreviews(/* @__PURE__ */ new Set());
2671
+ const retryFailed = () => void state.handleRetryFailed();
2672
+ _react.useImperativeHandle.call(void 0, ref, () => ({
2673
+ focus: () => {
2674
+ const focusable = _optionalChain([rootRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.querySelector, 'call', _141 => _141(
2675
+ '[data-slot="empty-dropzone"], [data-slot="empty-actions"] button, [data-slot="add-more"] button'
2676
+ )]);
2677
+ _optionalChain([(_nullishCoalesce(focusable, () => ( rootRef.current))), 'optionalAccess', _142 => _142.focus, 'call', _143 => _143()]);
2678
+ },
2679
+ open: openFilePicker,
2680
+ clear: () => state.handleClearAll()
2681
+ }));
2682
+ const handleFilesInputChange = (e) => {
2683
+ if (e.target.files && e.target.files.length > 0) void state.handleFileSelect(e.target.files);
2684
+ e.target.value = "";
2685
+ };
2686
+ const displayError = error || state.validationError;
2687
+ const hasError = Boolean(displayError) || state.hasFailedUploads;
2688
+ const hasStatusText = Boolean(helperText || displayError);
2689
+ const visualState = _chunkU2TWTEBYcjs.resolveUploadDataState.call(void 0, {
2690
+ disabled,
2691
+ hasError,
2692
+ isUploading: state.isUploading,
2693
+ isDragging,
2694
+ hasContent: previews.length > 0
2695
+ });
2696
+ const dropzoneProps = {
2697
+ ...dragHandlers,
2698
+ onPaste,
2699
+ role: "button",
2700
+ tabIndex: disabled ? -1 : 0,
2701
+ "aria-label": ui.selectFilesAria,
2702
+ "aria-disabled": disabled || void 0,
2703
+ "aria-required": required || void 0,
2704
+ "aria-invalid": hasError || void 0,
2705
+ "aria-describedby": hasStatusText ? statusTextId : void 0,
2706
+ "data-state": visualState,
2707
+ onClick: () => {
2708
+ if (!disabled) openFilePicker();
2709
+ },
2710
+ onKeyDown: (event) => {
2711
+ if (!disabled && (event.key === "Enter" || event.key === " ")) {
2712
+ event.preventDefault();
2713
+ openFilePicker();
2714
+ }
2715
+ }
2716
+ };
2717
+ const slotStylingProps = {
2718
+ unstyled: isUnstyled,
2719
+ providerClassNames: pCls,
2720
+ classNames: cCls,
2721
+ providerStyles: pSty,
2722
+ styles: cSty
2723
+ };
2724
+ const hiddenInputClass = _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-hidden-input", isUnstyled);
2725
+ const hiddenInputStyle = isUnstyled ? _chunkU2TWTEBYcjs.HIDDEN_INPUT_STYLE : void 0;
2726
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
2727
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2728
+ "div",
2729
+ {
2730
+ ref: rootRef,
2731
+ "data-slot": "multi-root",
2732
+ "data-state": visualState,
2733
+ "data-unstyled": isUnstyled || void 0,
2734
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-multi", isUnstyled, _optionalChain([pCls, 'optionalAccess', _144 => _144.root]), _optionalChain([cCls, 'optionalAccess', _145 => _145.root]), className),
2735
+ style: _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _146 => _146.root]), _optionalChain([cSty, 'optionalAccess', _147 => _147.root]), style),
2736
+ dir: locale === "ar" ? "rtl" : "ltr",
2737
+ onPaste,
2738
+ onBlur: onBlur ? (e) => {
2739
+ if (!e.currentTarget.contains(e.relatedTarget)) onBlur();
2740
+ } : void 0,
2741
+ children: [
2742
+ name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", { type: "hidden", name, value: state.serializedFormValue, required, "data-slot": "form-input" }),
2743
+ renderHeader ? renderHeader({
2744
+ label,
2745
+ required,
2746
+ disabled,
2747
+ totalCount: previews.length,
2748
+ selectedCount: selectedPreviews.size,
2749
+ uploadingCount: uploadingPreviews.length,
2750
+ isUploading: state.isUploading,
2751
+ hasFailedUploads: state.hasFailedUploads,
2752
+ selectAll,
2753
+ clearSelection,
2754
+ removeSelected: state.handleRemoveSelected,
2755
+ retryFailed,
2756
+ locale,
2757
+ ui
2758
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2759
+ MultiUploadHeaderAlerts,
2760
+ {
2761
+ label,
2762
+ labelId,
2763
+ inputId,
2764
+ required,
2765
+ disabled,
2766
+ totalCount: previews.length,
2767
+ selectedCount: selectedPreviews.size,
2768
+ uploadingCount: uploadingPreviews.length,
2769
+ missingAltCount: imagesWithoutAlt.length,
2770
+ isUploading: state.isUploading,
2771
+ hasFailedUploads: state.hasFailedUploads,
2772
+ infoMessage: state.infoMessage,
2773
+ showMissingAltWarning: state.showMissingAltWarning,
2774
+ uploadStats: state.uploadStats,
2775
+ locale,
2776
+ translations,
2777
+ ui,
2778
+ onSelectAll: selectAll,
2779
+ onDeselectAll: clearSelection,
2780
+ onRemoveSelected: state.handleRemoveSelected,
2781
+ onRetryFailed: retryFailed,
2782
+ ...slotStylingProps
2783
+ }
2784
+ ),
2785
+ showQualitySelector && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-slot": "quality-selector", className: slotClass("qualitySelector"), style: slotStyle("qualitySelector"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2786
+ QualitySelector,
2787
+ {
2788
+ value: state.qualityLevel,
2789
+ onChange: state.setQualityLevel,
2790
+ preset,
2791
+ recommendedLevel: recommendedQuality,
2792
+ recommendationNote: qualityNote,
2793
+ locale,
2794
+ disabled: state.isUploading || disabled,
2795
+ unstyled: isUnstyled
2796
+ }
2797
+ ) }),
2798
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2799
+ "input",
2800
+ {
2801
+ id: inputId,
2802
+ ref: fileInputRef,
2803
+ type: "file",
2804
+ accept,
2805
+ capture,
2806
+ onChange: handleFilesInputChange,
2807
+ className: hiddenInputClass,
2808
+ style: hiddenInputStyle,
2809
+ disabled,
2810
+ multiple: true,
2811
+ "aria-label": ui.selectFilesAria,
2812
+ "aria-invalid": hasError || void 0,
2813
+ "aria-describedby": hasStatusText ? statusTextId : void 0
2814
+ }
2815
+ ),
2816
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2817
+ "input",
2818
+ {
2819
+ ref: folderInputRef,
2820
+ type: "file",
2821
+ accept,
2822
+ onChange: handleFilesInputChange,
2823
+ className: hiddenInputClass,
2824
+ style: hiddenInputStyle,
2825
+ disabled,
2826
+ ...FOLDER_INPUT_ATTRS,
2827
+ "aria-label": ui.selectFolderAria
2828
+ }
2829
+ ),
2830
+ previews.length === 0 ? renderEmptyDropzone ? renderEmptyDropzone({
2831
+ state: visualState,
2832
+ isDragging,
2833
+ disabled,
2834
+ allowFolder,
2835
+ maxSizeMB: state.maxSizeMB,
2836
+ maxImages,
2837
+ error: displayError || void 0,
2838
+ openFileDialog: openFilePicker,
2839
+ openFolderDialog: openFolderPicker,
2840
+ dropzoneProps,
2841
+ locale,
2842
+ ui
2843
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2844
+ MultiEmptyDropzone,
2845
+ {
2846
+ isDragging,
2847
+ disabled,
2848
+ hasError: Boolean(displayError),
2849
+ required,
2850
+ enablePaste,
2851
+ visualState,
2852
+ allowFolder,
2853
+ maxSizeMB: state.maxSizeMB,
2854
+ ui,
2855
+ dragHandlers,
2856
+ onPaste,
2857
+ onSelectFiles: openFilePicker,
2858
+ onSelectFolder: openFolderPicker,
2859
+ ...slotStylingProps
2860
+ }
2861
+ ) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { "data-slot": "grid", className: slotClass("grid", "iuk-multi__grid"), style: slotStyle("grid"), children: [
2862
+ previews.map(
2863
+ (item, index) => renderTile ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderTile({
2864
+ item,
2865
+ index,
2866
+ isSelected: selectedPreviews.has(item.id),
2867
+ disabled,
2868
+ toggleSelect: () => state.toggleSelect(item.id),
2869
+ remove: () => state.handleRemove(item.id),
2870
+ cancel: () => state.handleCancelUpload(item.id),
2871
+ retry: () => void state.handleRetryUpload(item.id),
2872
+ openAltTextModal: () => state.setEditingAltTextId(item.id),
2873
+ setAltText: (altText) => state.handleAltTextSave(item.id, altText),
2874
+ setBlurColor: (hex) => state.handleColorChange(item.id, hex),
2875
+ locale,
2876
+ ui
2877
+ }) }, item.id) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2878
+ PreviewTile,
2879
+ {
2880
+ preview: item,
2881
+ onRemove: state.handleRemove,
2882
+ onCancel: state.handleCancelUpload,
2883
+ onRetry: (id) => void state.handleRetryUpload(id),
2884
+ disabled,
2885
+ blurType,
2886
+ isSelected: selectedPreviews.has(item.id),
2887
+ onToggleSelect: state.toggleSelect,
2888
+ onEditAltText: (id) => state.setEditingAltTextId(id),
2889
+ onChangeAltText: state.handleAltTextSave,
2890
+ onChangeColor: state.handleColorChange,
2891
+ locale,
2892
+ translations,
2893
+ renderImage,
2894
+ unstyled: isUnstyled,
2895
+ className: slotClass("tile"),
2896
+ style: slotStyle("tile")
2897
+ },
2898
+ item.id
2899
+ )
2900
+ ),
2901
+ renderAddMore ? renderAddMore({
2902
+ isDragging,
2903
+ disabled,
2904
+ allowFolder,
2905
+ remainingCount: Math.max(0, maxImages - previews.length),
2906
+ openFileDialog: openFilePicker,
2907
+ openFolderDialog: openFolderPicker,
2908
+ dropzoneProps,
2909
+ locale,
2910
+ ui
2911
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2912
+ MultiAddMoreTile,
2913
+ {
2914
+ isDragging,
2915
+ disabled,
2916
+ allowFolder,
2917
+ ui,
2918
+ dragHandlers,
2919
+ onSelectFiles: openFilePicker,
2920
+ onSelectFolder: openFolderPicker,
2921
+ ...slotStylingProps
2922
+ }
2923
+ )
2924
+ ] }),
2925
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2926
+ MultiFooterSection,
2927
+ {
2928
+ helperText,
2929
+ displayError,
2930
+ statusTextId,
2931
+ isOpen,
2932
+ hasPreviews: previews.length > 0,
2933
+ hasCompletedPreviews: state.completedPreviews.length > 0,
2934
+ isUploading: state.isUploading,
2935
+ disabled,
2936
+ requireAltText: state.requireAltText,
2937
+ missingAltCount: imagesWithoutAlt.length,
2938
+ onSave: state.handleSaveImages,
2939
+ ui,
2940
+ ...slotStylingProps
2941
+ }
2942
+ )
2943
+ ]
2944
+ }
2945
+ ),
2946
+ editingTarget && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2947
+ AltTextModal,
2948
+ {
2949
+ imageUrl: editingTarget.url,
2950
+ initialAltText: editingTarget.altText,
2951
+ onSave: (nextAlt) => state.handleAltTextSave(editingTarget.id, nextAlt),
2952
+ onClose: () => state.setEditingAltTextId(null),
2953
+ locale,
2954
+ translations,
2955
+ renderImage,
2956
+ unstyled: isUnstyled
2957
+ }
2958
+ ),
2959
+ typeof document !== "undefined" && dockItems.length > 0 && _reactdom.createPortal.call(void 0,
2960
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2961
+ UploadProgressPanel,
2962
+ {
2963
+ items: dockItems,
2964
+ completedCount: state.uploadStats.completed,
2965
+ totalCount: state.uploadStats.total,
2966
+ locale,
2967
+ translations,
2968
+ renderImage,
2969
+ unstyled: isUnstyled
2970
+ }
2971
+ ),
2972
+ document.body
2973
+ )
2974
+ ] });
2975
+ }
2976
+ var MultiImageUpload = _react.forwardRef.call(void 0, MultiImageUploadInner);
2977
+
2978
+ // src/react/components/SingleImageUpload.tsx
2979
+
2980
+
2981
+
2982
+
2983
+
2984
+
2985
+
2986
+ // src/react/components/SingleDropzoneContent.tsx
2987
+
2988
+ function formatCompactBytes(bytes) {
2989
+ if (bytes < 1024) return `${bytes} B`;
2990
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
2991
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
2992
+ }
2993
+ function resolveSingleDropzoneSlot(flags, styling) {
2994
+ const { isDragging, hasPreview, disabled, hasError } = flags;
2995
+ const { unstyled, providerClassNames: pCls, classNames: cCls, providerStyles: pSty, styles: cSty } = styling;
2996
+ return {
2997
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
2998
+ _chunkU2TWTEBYcjs.cx.call(void 0,
2999
+ "iuk-dropzone",
3000
+ isDragging && "iuk-dropzone--dragging",
3001
+ hasPreview && "iuk-dropzone--has-image",
3002
+ disabled && "iuk-dropzone--disabled",
3003
+ hasError && "iuk-dropzone--error"
3004
+ ),
3005
+ unstyled,
3006
+ _optionalChain([pCls, 'optionalAccess', _148 => _148.dropzone]),
3007
+ _optionalChain([cCls, 'optionalAccess', _149 => _149.dropzone]),
3008
+ isDragging && _optionalChain([pCls, 'optionalAccess', _150 => _150.dropzoneDragging]),
3009
+ isDragging && _optionalChain([cCls, 'optionalAccess', _151 => _151.dropzoneDragging]),
3010
+ hasPreview && _optionalChain([pCls, 'optionalAccess', _152 => _152.dropzoneHasImage]),
3011
+ hasPreview && _optionalChain([cCls, 'optionalAccess', _153 => _153.dropzoneHasImage]),
3012
+ disabled && _optionalChain([pCls, 'optionalAccess', _154 => _154.dropzoneDisabled]),
3013
+ disabled && _optionalChain([cCls, 'optionalAccess', _155 => _155.dropzoneDisabled]),
3014
+ hasError && _optionalChain([pCls, 'optionalAccess', _156 => _156.dropzoneError]),
3015
+ hasError && _optionalChain([cCls, 'optionalAccess', _157 => _157.dropzoneError])
3016
+ ),
3017
+ style: _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0,
3018
+ _optionalChain([pSty, 'optionalAccess', _158 => _158.dropzone]),
3019
+ _optionalChain([cSty, 'optionalAccess', _159 => _159.dropzone]),
3020
+ isDragging ? _optionalChain([pSty, 'optionalAccess', _160 => _160.dropzoneDragging]) : void 0,
3021
+ isDragging ? _optionalChain([cSty, 'optionalAccess', _161 => _161.dropzoneDragging]) : void 0,
3022
+ hasPreview ? _optionalChain([pSty, 'optionalAccess', _162 => _162.dropzoneHasImage]) : void 0,
3023
+ hasPreview ? _optionalChain([cSty, 'optionalAccess', _163 => _163.dropzoneHasImage]) : void 0,
3024
+ disabled ? _optionalChain([pSty, 'optionalAccess', _164 => _164.dropzoneDisabled]) : void 0,
3025
+ disabled ? _optionalChain([cSty, 'optionalAccess', _165 => _165.dropzoneDisabled]) : void 0,
3026
+ hasError ? _optionalChain([pSty, 'optionalAccess', _166 => _166.dropzoneError]) : void 0,
3027
+ hasError ? _optionalChain([cSty, 'optionalAccess', _167 => _167.dropzoneError]) : void 0
3028
+ )
3029
+ };
3030
+ }
3031
+ function SingleDropzoneEmptyPrompt({
3032
+ isUploading,
3033
+ uploadMessage,
3034
+ showProgress,
3035
+ progress,
3036
+ maxSizeMB,
3037
+ enablePaste = true,
3038
+ ui,
3039
+ unstyled,
3040
+ providerClassNames,
3041
+ classNames,
3042
+ providerStyles,
3043
+ styles
3044
+ }) {
3045
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([providerClassNames, 'optionalAccess', _168 => _168[slot]]), _optionalChain([classNames, 'optionalAccess', _169 => _169[slot]]));
3046
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([providerStyles, 'optionalAccess', _170 => _170[slot]]), _optionalChain([styles, 'optionalAccess', _171 => _171[slot]]));
3047
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3048
+ "div",
3049
+ {
3050
+ "data-slot": "dropzone-prompt",
3051
+ className: slotClass("dropzonePrompt", "iuk-dropzone__prompt"),
3052
+ style: slotStyle("dropzonePrompt"),
3053
+ children: [
3054
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3055
+ "div",
3056
+ {
3057
+ "data-slot": "dropzone-icon",
3058
+ className: slotClass("dropzoneIcon", "iuk-dropzone__icon"),
3059
+ style: slotStyle("dropzoneIcon"),
3060
+ children: isUploading ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-spinner", unstyled) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ImagePlusIcon, { size: 36, strokeWidth: 1.5 })
3061
+ }
3062
+ ),
3063
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3064
+ "p",
3065
+ {
3066
+ "data-slot": "dropzone-text",
3067
+ className: slotClass("dropzoneText", "iuk-dropzone__text"),
3068
+ style: slotStyle("dropzoneText"),
3069
+ children: isUploading ? uploadMessage || `${ui.uploading}...` : ui.dragDropOrClickToUpload
3070
+ }
3071
+ ),
3072
+ isUploading && showProgress && progress > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3073
+ "p",
3074
+ {
3075
+ "data-slot": "dropzone-progress",
3076
+ role: "progressbar",
3077
+ "aria-valuenow": Math.round(progress),
3078
+ "aria-valuemin": 0,
3079
+ "aria-valuemax": 100,
3080
+ "aria-label": ui.uploading,
3081
+ className: slotClass("dropzoneProgress", "iuk-dropzone__progress"),
3082
+ style: slotStyle("dropzoneProgress"),
3083
+ children: [
3084
+ progress,
3085
+ "%"
3086
+ ]
3087
+ }
3088
+ ),
3089
+ !isUploading && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3090
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3091
+ "p",
3092
+ {
3093
+ "data-slot": "dropzone-hint",
3094
+ className: slotClass("dropzoneHint", "iuk-dropzone__hint"),
3095
+ style: slotStyle("dropzoneHint"),
3096
+ children: [
3097
+ ui.upToSizeMB.replace("{size}", String(maxSizeMB)),
3098
+ enablePaste ? ` \u2022 ${ui.pasteHint}` : ""
3099
+ ]
3100
+ }
3101
+ ),
3102
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3103
+ "span",
3104
+ {
3105
+ "data-slot": "browse-button",
3106
+ className: slotClass("browseButton", "iuk-btn iuk-btn--secondary"),
3107
+ style: slotStyle("browseButton"),
3108
+ children: [
3109
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UploadIcon, { size: 15 }),
3110
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.browseFiles })
3111
+ ]
3112
+ }
3113
+ )
3114
+ ] })
3115
+ ]
3116
+ }
3117
+ );
3118
+ }
3119
+ function SingleStatusFooter({
3120
+ showMissingAltWarning,
3121
+ hasPreview,
3122
+ hasAltText,
3123
+ uploadMessage,
3124
+ isUploading,
3125
+ sizeInfo,
3126
+ canDownload,
3127
+ onDownload,
3128
+ helperText,
3129
+ displayError,
3130
+ statusTextId,
3131
+ isOpen,
3132
+ requireAltText,
3133
+ disabled,
3134
+ onSave,
3135
+ ui,
3136
+ unstyled,
3137
+ providerClassNames,
3138
+ classNames,
3139
+ providerStyles,
3140
+ styles
3141
+ }) {
3142
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, unstyled, _optionalChain([providerClassNames, 'optionalAccess', _172 => _172[slot]]), _optionalChain([classNames, 'optionalAccess', _173 => _173[slot]]));
3143
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([providerStyles, 'optionalAccess', _174 => _174[slot]]), _optionalChain([styles, 'optionalAccess', _175 => _175[slot]]));
3144
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3145
+ showMissingAltWarning && hasPreview && !hasAltText && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3146
+ "div",
3147
+ {
3148
+ "data-slot": "alert",
3149
+ role: "alert",
3150
+ className: slotClass("alert", "iuk-alert iuk-alert--warning"),
3151
+ style: slotStyle("alert"),
3152
+ children: [
3153
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertTriangleIcon, { size: 16 }),
3154
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.addAltBeforeSaving })
3155
+ ]
3156
+ }
3157
+ ),
3158
+ uploadMessage && !isUploading && sizeInfo && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3159
+ "div",
3160
+ {
3161
+ "data-slot": "alert",
3162
+ role: "status",
3163
+ className: slotClass("alert", "iuk-alert iuk-alert--success"),
3164
+ style: slotStyle("alert"),
3165
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: uploadMessage })
3166
+ }
3167
+ ),
3168
+ hasPreview && canDownload && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3169
+ "button",
3170
+ {
3171
+ type: "button",
3172
+ "data-slot": "download-button",
3173
+ className: slotClass("downloadButton", "iuk-btn iuk-btn--secondary iuk-single__download"),
3174
+ style: slotStyle("downloadButton"),
3175
+ onClick: onDownload,
3176
+ disabled: isUploading,
3177
+ "aria-label": ui.downloadImage,
3178
+ children: [
3179
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DownloadIcon, { size: 15, "aria-hidden": "true" }),
3180
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.downloadImage }),
3181
+ sizeInfo && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-badge", unstyled), children: formatCompactBytes(sizeInfo.optimized) })
3182
+ ]
3183
+ }
3184
+ ),
3185
+ (helperText || displayError) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3186
+ "p",
3187
+ {
3188
+ id: statusTextId,
3189
+ role: displayError ? "alert" : void 0,
3190
+ "data-slot": displayError ? "error-text" : "helper-text",
3191
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0,
3192
+ _chunkU2TWTEBYcjs.cx.call(void 0, "iuk-helper-text", Boolean(displayError) && "iuk-helper-text--error"),
3193
+ unstyled,
3194
+ _optionalChain([providerClassNames, 'optionalAccess', _176 => _176.helperText]),
3195
+ _optionalChain([classNames, 'optionalAccess', _177 => _177.helperText]),
3196
+ Boolean(displayError) && _optionalChain([providerClassNames, 'optionalAccess', _178 => _178.errorText]),
3197
+ Boolean(displayError) && _optionalChain([classNames, 'optionalAccess', _179 => _179.errorText])
3198
+ ),
3199
+ style: _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0,
3200
+ _optionalChain([providerStyles, 'optionalAccess', _180 => _180.helperText]),
3201
+ _optionalChain([styles, 'optionalAccess', _181 => _181.helperText]),
3202
+ displayError ? _optionalChain([providerStyles, 'optionalAccess', _182 => _182.errorText]) : void 0,
3203
+ displayError ? _optionalChain([styles, 'optionalAccess', _183 => _183.errorText]) : void 0
3204
+ ),
3205
+ children: displayError || helperText
3206
+ }
3207
+ ),
3208
+ isOpen && hasPreview && onSave && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3209
+ "div",
3210
+ {
3211
+ "data-slot": "commit-bar",
3212
+ className: slotClass("commitBar", "iuk-commit-bar"),
3213
+ style: slotStyle("commitBar"),
3214
+ children: [
3215
+ requireAltText && !hasAltText && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-badge iuk-badge--warning", unstyled), children: [
3216
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AlertTriangleIcon, { size: 13 }),
3217
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: ui.missingDescription })
3218
+ ] }),
3219
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3220
+ SaveButton,
3221
+ {
3222
+ unstyled,
3223
+ className: slotClass("saveButton"),
3224
+ style: slotStyle("saveButton"),
3225
+ onClick: onSave,
3226
+ disabled: isUploading || disabled || Boolean(requireAltText && !hasAltText),
3227
+ icon: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SaveIcon, { size: 16 }),
3228
+ children: ui.saveImage
3229
+ }
3230
+ )
3231
+ ]
3232
+ }
3233
+ )
3234
+ ] });
3235
+ }
3236
+
3237
+ // src/react/components/SingleImageUpload.tsx
3238
+
3239
+ function SingleImageUploadInner(props, ref) {
3240
+ const {
3241
+ preset,
3242
+ translations,
3243
+ renderImage,
3244
+ label,
3245
+ error,
3246
+ helperText,
3247
+ className,
3248
+ style,
3249
+ accept = "image/jpeg,image/png,image/webp,image/avif,image/svg+xml",
3250
+ disabled = false,
3251
+ required = false,
3252
+ blurType = "card",
3253
+ showProgress = false,
3254
+ showQualitySelector = true,
3255
+ recommendedQuality,
3256
+ qualityNote,
3257
+ isOpen,
3258
+ capture,
3259
+ enablePaste = true,
3260
+ pasteTarget = "dropzone",
3261
+ name,
3262
+ onBlur,
3263
+ classNames: cCls,
3264
+ styles: cSty,
3265
+ renderDropzone,
3266
+ renderPreview
3267
+ } = props;
3268
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
3269
+ const isUnstyled = _nullishCoalesce(props.unstyled, () => ( ctx.unstyled));
3270
+ const pCls = ctx.singleClassNames;
3271
+ const pSty = ctx.singleStyles;
3272
+ const slotClass = (slot, defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled, _optionalChain([pCls, 'optionalAccess', _184 => _184[slot]]), _optionalChain([cCls, 'optionalAccess', _185 => _185[slot]]));
3273
+ const slotStyle = (slot) => _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _186 => _186[slot]]), _optionalChain([cSty, 'optionalAccess', _187 => _187[slot]]));
3274
+ const state = _chunkU2TWTEBYcjs.useSingleImageState.call(void 0, props);
3275
+ const { isDragging, dragHandlers } = _chunkU2TWTEBYcjs.useDragAndDrop.call(void 0, { disabled, onDrop: state.handleFileSelect });
3276
+ const { onPaste } = _chunkU2TWTEBYcjs.useClipboardPaste.call(void 0, {
3277
+ enabled: enablePaste,
3278
+ pasteTarget,
3279
+ disabled,
3280
+ multiple: false,
3281
+ onPasteFiles: (files) => {
3282
+ void state.handleFileSelect(files);
3283
+ }
3284
+ });
3285
+ const dropzoneRef = _react.useRef.call(void 0, null);
3286
+ const labelId = _react.useId.call(void 0, );
3287
+ const inputId = _react.useId.call(void 0, );
3288
+ const statusTextId = _react.useId.call(void 0, );
3289
+ const openFileDialog = () => {
3290
+ if (!disabled) _optionalChain([state, 'access', _188 => _188.fileInputRef, 'access', _189 => _189.current, 'optionalAccess', _190 => _190.click, 'call', _191 => _191()]);
3291
+ };
3292
+ _react.useImperativeHandle.call(void 0, ref, () => ({
3293
+ focus: () => {
3294
+ _optionalChain([dropzoneRef, 'access', _192 => _192.current, 'optionalAccess', _193 => _193.focus, 'call', _194 => _194()]);
3295
+ },
3296
+ open: openFileDialog,
3297
+ clear: () => state.handleRemoveTile()
3298
+ }));
3299
+ const handleInputChange = (event) => {
3300
+ const files = event.target.files;
3301
+ if (files && files.length > 0) void state.handleFileSelect(files);
3302
+ event.target.value = "";
3303
+ };
3304
+ const displayError = error || state.validationError;
3305
+ const hasPreview = Boolean(state.preview);
3306
+ const hasError = Boolean(displayError);
3307
+ const hasLabel = Boolean(label || state.ui.uploadImage);
3308
+ const hasStatusText = Boolean(helperText || displayError);
3309
+ const visualState = _chunkU2TWTEBYcjs.resolveUploadDataState.call(void 0, {
3310
+ disabled,
3311
+ hasError,
3312
+ isUploading: state.isUploading,
3313
+ isDragging,
3314
+ hasContent: hasPreview
3315
+ });
3316
+ const dropzoneProps = hasPreview ? { ...dragHandlers, onPaste, "aria-disabled": disabled || void 0 } : {
3317
+ ...dragHandlers,
3318
+ onPaste,
3319
+ onClick: () => {
3320
+ if (!disabled) openFileDialog();
3321
+ },
3322
+ onKeyDown: (event) => {
3323
+ if (!disabled && (event.key === "Enter" || event.key === " ")) {
3324
+ event.preventDefault();
3325
+ openFileDialog();
3326
+ }
3327
+ },
3328
+ role: "button",
3329
+ tabIndex: disabled ? -1 : 0,
3330
+ "aria-label": state.ui.uploadImageAria,
3331
+ "aria-labelledby": hasLabel ? labelId : void 0,
3332
+ "aria-required": required || void 0,
3333
+ "aria-invalid": hasError || void 0,
3334
+ "aria-describedby": hasStatusText ? statusTextId : void 0,
3335
+ "aria-disabled": disabled || void 0
3336
+ };
3337
+ const slotStylingProps = {
3338
+ unstyled: isUnstyled,
3339
+ providerClassNames: pCls,
3340
+ classNames: cCls,
3341
+ providerStyles: pSty,
3342
+ styles: cSty
3343
+ };
3344
+ const dropzoneSlot = resolveSingleDropzoneSlot(
3345
+ { isDragging, hasPreview, disabled, hasError },
3346
+ slotStylingProps
3347
+ );
3348
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3349
+ "div",
3350
+ {
3351
+ "data-slot": "single-root",
3352
+ "data-state": visualState,
3353
+ "data-unstyled": isUnstyled || void 0,
3354
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-single", isUnstyled, _optionalChain([pCls, 'optionalAccess', _195 => _195.root]), _optionalChain([cCls, 'optionalAccess', _196 => _196.root]), className),
3355
+ style: _chunkU2TWTEBYcjs.resolveSlotStyle.call(void 0, _optionalChain([pSty, 'optionalAccess', _197 => _197.root]), _optionalChain([cSty, 'optionalAccess', _198 => _198.root]), style),
3356
+ dir: state.locale === "ar" ? "rtl" : "ltr",
3357
+ onBlur: onBlur ? (e) => {
3358
+ if (!e.currentTarget.contains(e.relatedTarget)) onBlur();
3359
+ } : void 0,
3360
+ children: [
3361
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "status", "aria-live": "polite", "aria-atomic": "true", style: _chunkU2TWTEBYcjs.HIDDEN_INPUT_STYLE, children: state.liveAnnouncement }),
3362
+ name && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "input", { type: "hidden", name, value: state.serializedFormValue, required, "data-slot": "form-input" }),
3363
+ hasLabel && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "label", { id: labelId, htmlFor: inputId, "data-slot": "label", className: slotClass("label", "iuk-label"), style: slotStyle("label"), children: [
3364
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: label || state.ui.uploadImage }),
3365
+ required && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-required", isUnstyled), children: "*" })
3366
+ ] }),
3367
+ showQualitySelector && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-slot": "quality-selector", className: slotClass("qualitySelector"), style: slotStyle("qualitySelector"), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3368
+ QualitySelector,
3369
+ {
3370
+ value: state.qualityLevel,
3371
+ onChange: state.setQualityLevel,
3372
+ preset,
3373
+ recommendedLevel: recommendedQuality,
3374
+ recommendationNote: qualityNote,
3375
+ originalFileSize: _optionalChain([state, 'access', _199 => _199.selectedFile, 'optionalAccess', _200 => _200.size]),
3376
+ locale: state.locale,
3377
+ disabled: disabled || state.isUploading,
3378
+ unstyled: isUnstyled
3379
+ }
3380
+ ) }),
3381
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3382
+ "input",
3383
+ {
3384
+ id: inputId,
3385
+ ref: state.fileInputRef,
3386
+ type: "file",
3387
+ accept,
3388
+ capture,
3389
+ onChange: handleInputChange,
3390
+ className: _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, "iuk-hidden-input", isUnstyled),
3391
+ style: isUnstyled ? _chunkU2TWTEBYcjs.HIDDEN_INPUT_STYLE : void 0,
3392
+ disabled,
3393
+ "aria-label": state.ui.fileInputAria,
3394
+ "aria-invalid": hasError || void 0,
3395
+ "aria-describedby": hasStatusText ? statusTextId : void 0
3396
+ }
3397
+ ),
3398
+ !state.preview && renderDropzone ? renderDropzone({
3399
+ state: visualState,
3400
+ isDragging,
3401
+ isUploading: state.isUploading,
3402
+ progress: state.progress,
3403
+ uploadMessage: state.uploadMessage,
3404
+ maxSizeMB: state.maxSizeMB,
3405
+ disabled,
3406
+ error: displayError || void 0,
3407
+ qualityLevel: state.qualityLevel,
3408
+ setQualityLevel: state.setQualityLevel,
3409
+ openFileDialog,
3410
+ dropzoneProps,
3411
+ locale: state.locale,
3412
+ ui: state.ui
3413
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3414
+ "div",
3415
+ {
3416
+ ref: dropzoneRef,
3417
+ "data-slot": "dropzone",
3418
+ "data-state": visualState,
3419
+ "data-dragging": isDragging || void 0,
3420
+ "data-uploading": state.isUploading || void 0,
3421
+ "data-disabled": disabled || void 0,
3422
+ "data-error": hasError || void 0,
3423
+ className: dropzoneSlot.className,
3424
+ style: dropzoneSlot.style,
3425
+ ...dropzoneProps,
3426
+ children: state.preview ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3427
+ "div",
3428
+ {
3429
+ "data-slot": "preview-wrap",
3430
+ className: slotClass("previewWrap", "iuk-single__preview-wrap"),
3431
+ style: slotStyle("previewWrap"),
3432
+ onClick: (event) => event.stopPropagation(),
3433
+ children: renderPreview ? renderPreview({
3434
+ previewUrl: state.preview,
3435
+ uploadedData: state.uploadedData,
3436
+ altText: state.altText,
3437
+ blurColor: _nullishCoalesce(_optionalChain([state, 'access', _201 => _201.uploadedData, 'optionalAccess', _202 => _202.blurColor]), () => ( state.blurColor)),
3438
+ blurDataUrl: state.blurDataUrlState || _optionalChain([state, 'access', _203 => _203.currentImageData, 'optionalAccess', _204 => _204.blurDataUrl]) || "",
3439
+ isUploading: state.isUploading,
3440
+ progress: state.progress,
3441
+ uploadMessage: state.uploadMessage,
3442
+ sizeInfo: state.sizeInfo,
3443
+ disabled,
3444
+ openFileDialog,
3445
+ remove: () => state.handleRemoveTile(),
3446
+ cancel: () => state.handleCancelUpload(),
3447
+ openAltTextModal: () => state.setEditingAltText(true),
3448
+ openBlurInspector: () => state.setIsBlurModalOpen(true),
3449
+ download: state.handleDownload,
3450
+ locale: state.locale,
3451
+ ui: state.ui
3452
+ }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3453
+ PreviewTile,
3454
+ {
3455
+ preview: {
3456
+ id: "single",
3457
+ url: state.preview,
3458
+ altText: state.altText,
3459
+ isUploading: state.isUploading,
3460
+ progress: state.progress,
3461
+ uploadMessage: state.uploadMessage || null,
3462
+ originalSize: _optionalChain([state, 'access', _205 => _205.sizeInfo, 'optionalAccess', _206 => _206.original]),
3463
+ optimizedSize: _nullishCoalesce(_optionalChain([state, 'access', _207 => _207.sizeInfo, 'optionalAccess', _208 => _208.optimized]), () => ( null)),
3464
+ data: _nullishCoalesce(state.uploadedData, () => ( void 0)),
3465
+ blurColor: _nullishCoalesce(_optionalChain([state, 'access', _209 => _209.uploadedData, 'optionalAccess', _210 => _210.blurColor]), () => ( state.blurColor))
3466
+ },
3467
+ onRemove: () => state.handleRemoveTile(),
3468
+ onCancel: () => state.handleCancelUpload(),
3469
+ disabled,
3470
+ blurType,
3471
+ showCheckbox: false,
3472
+ onEditAltText: () => state.setEditingAltText(true),
3473
+ onAdjustColor: () => state.setIsBlurModalOpen(true),
3474
+ locale: state.locale,
3475
+ translations,
3476
+ renderImage,
3477
+ unstyled: isUnstyled,
3478
+ className: slotClass("tile"),
3479
+ style: slotStyle("tile")
3480
+ }
3481
+ )
3482
+ }
3483
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3484
+ SingleDropzoneEmptyPrompt,
3485
+ {
3486
+ isUploading: state.isUploading,
3487
+ uploadMessage: state.uploadMessage,
3488
+ showProgress,
3489
+ progress: state.progress,
3490
+ maxSizeMB: state.maxSizeMB,
3491
+ enablePaste,
3492
+ ui: state.ui,
3493
+ ...slotStylingProps
3494
+ }
3495
+ )
3496
+ }
3497
+ ),
3498
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3499
+ SingleStatusFooter,
3500
+ {
3501
+ showMissingAltWarning: state.showMissingAltWarning,
3502
+ hasPreview,
3503
+ hasAltText: Boolean(_optionalChain([state, 'access', _211 => _211.altText, 'optionalAccess', _212 => _212.trim, 'call', _213 => _213()])),
3504
+ uploadMessage: state.uploadMessage,
3505
+ isUploading: state.isUploading,
3506
+ sizeInfo: state.sizeInfo,
3507
+ canDownload: state.canDownload,
3508
+ onDownload: () => void state.handleDownload(),
3509
+ helperText,
3510
+ displayError,
3511
+ statusTextId,
3512
+ isOpen,
3513
+ requireAltText: state.requireAltText,
3514
+ disabled,
3515
+ onSave: state.handleSaveImage,
3516
+ ui: state.ui,
3517
+ ...slotStylingProps
3518
+ }
3519
+ ),
3520
+ state.editingAltText && state.preview && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3521
+ AltTextModal,
3522
+ {
3523
+ imageUrl: state.preview,
3524
+ initialAltText: state.altText,
3525
+ onSave: state.handleAltTextSave,
3526
+ onClose: () => state.setEditingAltText(false),
3527
+ locale: state.locale,
3528
+ translations,
3529
+ renderImage
3530
+ }
3531
+ ),
3532
+ state.preview && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3533
+ BlurVisualizationModal,
3534
+ {
3535
+ isOpen: state.isBlurModalOpen,
3536
+ onClose: () => state.setIsBlurModalOpen(false),
3537
+ imageUrl: state.preview,
3538
+ blurDataUrl: state.blurDataUrlState || _optionalChain([state, 'access', _214 => _214.currentImageData, 'optionalAccess', _215 => _215.blurDataUrl]),
3539
+ blurColor: state.blurColor,
3540
+ altText: state.altText,
3541
+ originalSize: _nullishCoalesce(_optionalChain([state, 'access', _216 => _216.sizeInfo, 'optionalAccess', _217 => _217.original]), () => ( _optionalChain([state, 'access', _218 => _218.currentImageData, 'optionalAccess', _219 => _219.originalSize]))),
3542
+ optimizedSize: _nullishCoalesce(_nullishCoalesce(_optionalChain([state, 'access', _220 => _220.sizeInfo, 'optionalAccess', _221 => _221.optimized]), () => ( _optionalChain([state, 'access', _222 => _222.currentImageData, 'optionalAccess', _223 => _223.size]))), () => ( null)),
3543
+ detectedColor: state.detectedBlurColor,
3544
+ onChangeColor: (hex) => state.applyBlurColor(hex),
3545
+ onUseDetectedColor: state.handleResetColor,
3546
+ onChangeAltText: (nextAlt) => state.handleAltTextSave(nextAlt),
3547
+ locale: state.locale,
3548
+ translations,
3549
+ renderImage
3550
+ }
3551
+ )
3552
+ ]
3553
+ }
3554
+ );
3555
+ }
3556
+ var SingleImageUpload = _react.forwardRef.call(void 0, SingleImageUploadInner);
3557
+
3558
+ // src/react/components/ImageUpload.tsx
3559
+
3560
+ function ImageUploadInner(props, ref) {
3561
+ const ctx = _chunkU2TWTEBYcjs.useImageUploadContext.call(void 0, );
3562
+ const isUnstyled = _nullishCoalesce(props.unstyled, () => ( ctx.unstyled));
3563
+ const uploadLocale = _chunkU2TWTEBYcjs.normalizeUploadLocale.call(void 0, props.locale || ctx.locale);
3564
+ const ui = _chunkU2TWTEBYcjs.resolveTranslations.call(void 0,
3565
+ uploadLocale,
3566
+ props.translations || ctx.translations
3567
+ );
3568
+ const dir = uploadLocale === "ar" ? "rtl" : "ltr";
3569
+ const { isOpen, onClose, title, modeVariant } = props;
3570
+ const [isMinimized, setIsMinimized] = _react.useState.call(void 0, false);
3571
+ const [dockNode, setDockNode] = _react.useState.call(void 0, null);
3572
+ const cls = (defaultClass) => _chunkU2TWTEBYcjs.resolveSlotClass.call(void 0, defaultClass, isUnstyled);
3573
+ _react.useEffect.call(void 0, () => {
3574
+ if (!isOpen) {
3575
+ setIsMinimized(false);
3576
+ }
3577
+ }, [isOpen]);
3578
+ const { dialogRef, titleId } = useDialog({
3579
+ isOpen: Boolean(isOpen) && !isMinimized,
3580
+ onClose
3581
+ });
3582
+ _react.useEffect.call(void 0, () => {
3583
+ if (typeof window === "undefined" || !isOpen || !isMinimized) {
3584
+ setDockNode(null);
3585
+ return;
3586
+ }
3587
+ const updateDockReference = () => {
3588
+ const node = document.querySelector("[data-upload-progress-dock]");
3589
+ setDockNode(
3590
+ (prev) => node instanceof HTMLElement ? node === prev ? prev : node : null
3591
+ );
3592
+ };
3593
+ updateDockReference();
3594
+ const observer = new MutationObserver(() => updateDockReference());
3595
+ observer.observe(document.body, {
3596
+ childList: true,
3597
+ subtree: true
3598
+ });
3599
+ return () => observer.disconnect();
3600
+ }, [isOpen, isMinimized]);
3601
+ const content = props.mode === "multiple" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MultiImageUpload, { ref, ...props }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SingleImageUpload, { ref, ...props });
3602
+ if (isOpen === void 0) {
3603
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3604
+ "div",
3605
+ {
3606
+ "data-slot": "upload-root",
3607
+ "data-unstyled": isUnstyled || void 0,
3608
+ className: cls("iuk-root"),
3609
+ dir,
3610
+ "data-upload-locale": uploadLocale,
3611
+ children: content
3612
+ }
3613
+ );
3614
+ }
3615
+ if (!isOpen) return null;
3616
+ const minimizedButton = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3617
+ "button",
3618
+ {
3619
+ type: "button",
3620
+ "data-slot": "minimized-pill",
3621
+ className: cls("iuk-minimized-pill"),
3622
+ onClick: () => setIsMinimized(false),
3623
+ title: ui.restoreUploadWindow,
3624
+ children: [
3625
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoaderIcon, { size: 16, className: cls("iuk-spin") }),
3626
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: cls("iuk-minimized-pill__copy"), children: [
3627
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-minimized-pill__primary"), children: ui.uploadWindow }),
3628
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: cls("iuk-minimized-pill__secondary"), children: ui.tapToResume })
3629
+ ] }),
3630
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ChevronUpIcon, { size: 16 })
3631
+ ]
3632
+ }
3633
+ );
3634
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
3635
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3636
+ "div",
3637
+ {
3638
+ "data-slot": "upload-modal-backdrop",
3639
+ "data-unstyled": isUnstyled || void 0,
3640
+ className: cls(
3641
+ `iuk-root iuk-modal-backdrop ${isMinimized ? "iuk-modal-backdrop--hidden" : ""}`.trim()
3642
+ ),
3643
+ dir,
3644
+ "data-upload-locale": uploadLocale,
3645
+ role: "dialog",
3646
+ "aria-modal": !isMinimized,
3647
+ "aria-hidden": isMinimized,
3648
+ "aria-labelledby": title ? titleId : void 0,
3649
+ "aria-label": !title ? ui.uploadWindow : void 0,
3650
+ onClick: () => _optionalChain([onClose, 'optionalCall', _224 => _224()]),
3651
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3652
+ "div",
3653
+ {
3654
+ ref: dialogRef,
3655
+ "data-slot": "upload-dialog",
3656
+ className: cls(
3657
+ `iuk-upload-dialog ${isMinimized ? "iuk-upload-dialog--hidden" : ""}`.trim()
3658
+ ),
3659
+ onClick: (e) => e.stopPropagation(),
3660
+ children: [
3661
+ onClose && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: cls("iuk-upload-dialog__controls"), children: [
3662
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3663
+ "button",
3664
+ {
3665
+ type: "button",
3666
+ className: cls("iuk-icon-btn iuk-icon-btn--floating"),
3667
+ onClick: () => setIsMinimized(true),
3668
+ "aria-label": ui.minimize,
3669
+ title: ui.minimizeUploader,
3670
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MinusIcon, { size: 18 })
3671
+ }
3672
+ ),
3673
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
3674
+ "button",
3675
+ {
3676
+ type: "button",
3677
+ className: cls("iuk-icon-btn iuk-icon-btn--floating"),
3678
+ onClick: onClose,
3679
+ "aria-label": ui.close,
3680
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { size: 18 })
3681
+ }
3682
+ )
3683
+ ] }),
3684
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
3685
+ "div",
3686
+ {
3687
+ className: cls("iuk-upload-dialog__card"),
3688
+ onClick: (e) => e.stopPropagation(),
3689
+ children: [
3690
+ title && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { id: titleId, className: cls("iuk-upload-dialog__title"), children: modeVariant === "edit" ? ui.editPrefix.replace("{title}", title) : title }),
3691
+ content
3692
+ ]
3693
+ }
3694
+ )
3695
+ ]
3696
+ }
3697
+ )
3698
+ }
3699
+ ),
3700
+ isMinimized && typeof document !== "undefined" && (dockNode ? _reactdom.createPortal.call(void 0,
3701
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-minimized-portal"), children: minimizedButton }),
3702
+ dockNode
3703
+ ) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: cls("iuk-minimized-dock"), children: minimizedButton }))
3704
+ ] });
3705
+ }
3706
+ var ImageUpload = _react.forwardRef.call(void 0, ImageUploadInner);
3707
+ var UnifiedImageUpload = ImageUpload;
3708
+
3709
+
3710
+
3711
+
3712
+
3713
+
3714
+
3715
+
3716
+
3717
+
3718
+
3719
+
3720
+
3721
+
3722
+
3723
+
3724
+
3725
+
3726
+
3727
+
3728
+
3729
+
3730
+
3731
+
3732
+
3733
+
3734
+
3735
+
3736
+
3737
+
3738
+
3739
+
3740
+
3741
+
3742
+
3743
+
3744
+
3745
+
3746
+
3747
+
3748
+
3749
+
3750
+
3751
+
3752
+
3753
+
3754
+
3755
+
3756
+
3757
+
3758
+
3759
+
3760
+
3761
+
3762
+
3763
+
3764
+
3765
+
3766
+
3767
+
3768
+
3769
+
3770
+
3771
+
3772
+
3773
+
3774
+
3775
+
3776
+
3777
+
3778
+ exports.ARABIC_UPLOAD_TRANSLATIONS = _chunkU2TWTEBYcjs.ARABIC_UPLOAD_TRANSLATIONS; exports.AltTextInput = AltTextInput; exports.AltTextModal = AltTextModal; exports.AnimatedImage = AnimatedImage; exports.BlurImage = BlurImage; exports.BlurServiceDebugger = BlurServiceDebugger; exports.BlurVisualizationModal = BlurVisualizationModal; exports.DEFAULT_NEUTRAL_COLORS = DEFAULT_NEUTRAL_COLORS; exports.DEFAULT_PLACEHOLDERS = _chunkWISG74VLcjs.DEFAULT_PLACEHOLDERS; exports.DEFAULT_UPLOAD_TRANSLATIONS = _chunkU2TWTEBYcjs.DEFAULT_UPLOAD_TRANSLATIONS; exports.HIDDEN_INPUT_STYLE = _chunkU2TWTEBYcjs.HIDDEN_INPUT_STYLE; exports.HeadlessMultiUpload = _chunkU2TWTEBYcjs.HeadlessMultiUpload; exports.HeadlessSingleUpload = _chunkU2TWTEBYcjs.HeadlessSingleUpload; exports.ImageUpload = ImageUpload; exports.ImageUploadProvider = _chunkU2TWTEBYcjs.ImageUploadProvider; exports.MultiImageUpload = MultiImageUpload; exports.PreviewTile = PreviewTile; exports.QualitySelector = QualitySelector; exports.SaveButton = SaveButton; exports.SingleImageUpload = SingleImageUpload; exports.UnifiedImageUpload = UnifiedImageUpload; exports.UploadProgressPanel = UploadProgressPanel; exports.arTranslations = _chunkU2TWTEBYcjs.arTranslations; exports.blurService = _chunkWISG74VLcjs.blurService; exports.buildUploadFormData = _chunkU2TWTEBYcjs.buildUploadFormData; exports.createFallbackBlurSvg = createFallbackBlurSvg; exports.createUploadAbortError = _chunkU2TWTEBYcjs.createUploadAbortError; exports.cx = _chunkU2TWTEBYcjs.cx; exports.enTranslations = _chunkU2TWTEBYcjs.enTranslations; exports.extractClipboardImageFiles = _chunkU2TWTEBYcjs.extractClipboardImageFiles; exports.formatNeedsAltMessage = _chunkU2TWTEBYcjs.formatNeedsAltMessage; exports.formatSkippedImagesMessage = _chunkU2TWTEBYcjs.formatSkippedImagesMessage; exports.formatUploadingCount = _chunkU2TWTEBYcjs.formatUploadingCount; exports.isUploadAbortError = _chunkU2TWTEBYcjs.isUploadAbortError; exports.normalizeUploadLocale = _chunkU2TWTEBYcjs.normalizeUploadLocale; exports.parseErrorPayload = _chunkU2TWTEBYcjs.parseErrorPayload; exports.resolveBackgroundColor = resolveBackgroundColor; exports.resolveIntrinsicPlaceholderUrl = resolveIntrinsicPlaceholderUrl; exports.resolveMeaningfulColor = resolveMeaningfulColor; exports.resolvePlaceholderUrl = resolvePlaceholderUrl; exports.resolveSlotClass = _chunkU2TWTEBYcjs.resolveSlotClass; exports.resolveSlotStyle = _chunkU2TWTEBYcjs.resolveSlotStyle; exports.resolveTranslations = _chunkU2TWTEBYcjs.resolveTranslations; exports.resolveUploadDataState = _chunkU2TWTEBYcjs.resolveUploadDataState; exports.selectPluralCategory = _chunkU2TWTEBYcjs.selectPluralCategory; exports.toFileListLike = _chunkU2TWTEBYcjs.toFileListLike; exports.uploadText = _chunkU2TWTEBYcjs.uploadText; exports.uploadViaXhr = _chunkU2TWTEBYcjs.uploadViaXhr; exports.useBlurDataURL = useBlurDataURL; exports.useBlurDataWithColor = useBlurDataWithColor; exports.useBlurHash = useBlurHash; exports.useBlurMetadata = useBlurMetadata; exports.useBlurPreload = useBlurPreload; exports.useBlurVariant = useBlurVariant; exports.useBulkBlurData = useBulkBlurData; exports.useClipboardPaste = _chunkU2TWTEBYcjs.useClipboardPaste; exports.useDialog = useDialog; exports.useDominantColor = useDominantColor; exports.useDragAndDrop = _chunkU2TWTEBYcjs.useDragAndDrop; exports.useDropzone = _chunkU2TWTEBYcjs.useDragAndDrop; exports.useFilePreview = _chunkU2TWTEBYcjs.useFilePreview; exports.useHasBlurHash = useHasBlurHash; exports.useImageReveal = useImageReveal; exports.useImageUpload = _chunkU2TWTEBYcjs.useImageUpload; exports.useImageUploadContext = _chunkU2TWTEBYcjs.useImageUploadContext; exports.useMultiUpload = _chunkU2TWTEBYcjs.useMultiUpload; exports.useProgressiveBlur = useProgressiveBlur; exports.useProgressiveImage = useProgressiveImage; exports.useSingleUpload = _chunkU2TWTEBYcjs.useSingleUpload;
3779
+ //# sourceMappingURL=react.cjs.map