PluginProbe
Gutenberg / 22.7.0
Gutenberg v22.7.0
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / scripts / media-utils / index.js

index.js in Gutenberg 22.7.0, at build/scripts/media-utils/index.js

18,204 lines 639.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 "use strict";
2 var wp;
3 (wp ||= {}).mediaUtils = (() => {
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7 var __getOwnPropNames = Object.getOwnPropertyNames;
8 var __getProtoOf = Object.getPrototypeOf;
9 var __hasOwnProp = Object.prototype.hasOwnProperty;
10 var __commonJS = (cb, mod) => function __require() {
11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12 };
13 var __export = (target, all) => {
14 for (var name in all)
15 __defProp(target, name, { get: all[name], enumerable: true });
16 };
17 var __copyProps = (to, from, except, desc) => {
18 if (from && typeof from === "object" || typeof from === "function") {
19 for (let key of __getOwnPropNames(from))
20 if (!__hasOwnProp.call(to, key) && key !== except)
21 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22 }
23 return to;
24 };
25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26 // If the importer is in node compatibility mode or this is not an ESM
27 // file that has been converted to a CommonJS file using a Babel-
28 // compatible transform (i.e. "__esModule" has not been set), then set
29 // "default" to the CommonJS "module.exports" for node compatibility.
30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31 mod
32 ));
33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
35 // package-external:@wordpress/element
36 var require_element = __commonJS({
37 "package-external:@wordpress/element"(exports, module) {
38 module.exports = window.wp.element;
39 }
40 });
41
42 // package-external:@wordpress/i18n
43 var require_i18n = __commonJS({
44 "package-external:@wordpress/i18n"(exports, module) {
45 module.exports = window.wp.i18n;
46 }
47 });
48
49 // package-external:@wordpress/blob
50 var require_blob = __commonJS({
51 "package-external:@wordpress/blob"(exports, module) {
52 module.exports = window.wp.blob;
53 }
54 });
55
56 // package-external:@wordpress/api-fetch
57 var require_api_fetch = __commonJS({
58 "package-external:@wordpress/api-fetch"(exports, module) {
59 module.exports = window.wp.apiFetch;
60 }
61 });
62
63 // package-external:@wordpress/core-data
64 var require_core_data = __commonJS({
65 "package-external:@wordpress/core-data"(exports, module) {
66 module.exports = window.wp.coreData;
67 }
68 });
69
70 // package-external:@wordpress/data
71 var require_data = __commonJS({
72 "package-external:@wordpress/data"(exports, module) {
73 module.exports = window.wp.data;
74 }
75 });
76
77 // package-external:@wordpress/components
78 var require_components = __commonJS({
79 "package-external:@wordpress/components"(exports, module) {
80 module.exports = window.wp.components;
81 }
82 });
83
84 // package-external:@wordpress/primitives
85 var require_primitives = __commonJS({
86 "package-external:@wordpress/primitives"(exports, module) {
87 module.exports = window.wp.primitives;
88 }
89 });
90
91 // vendor-external:react/jsx-runtime
92 var require_jsx_runtime = __commonJS({
93 "vendor-external:react/jsx-runtime"(exports, module) {
94 module.exports = window.ReactJSXRuntime;
95 }
96 });
97
98 // package-external:@wordpress/compose
99 var require_compose = __commonJS({
100 "package-external:@wordpress/compose"(exports, module) {
101 module.exports = window.wp.compose;
102 }
103 });
104
105 // vendor-external:react
106 var require_react = __commonJS({
107 "vendor-external:react"(exports, module) {
108 module.exports = window.React;
109 }
110 });
111
112 // vendor-external:react-dom
113 var require_react_dom = __commonJS({
114 "vendor-external:react-dom"(exports, module) {
115 module.exports = window.ReactDOM;
116 }
117 });
118
119 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
120 var require_use_sync_external_store_shim_development = __commonJS({
121 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
122 "use strict";
123 (function() {
124 function is(x2, y2) {
125 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
126 }
127 function useSyncExternalStore$2(subscribe2, getSnapshot) {
128 didWarnOld18Alpha || void 0 === React8.startTransition || (didWarnOld18Alpha = true, console.error(
129 "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
130 ));
131 var value = getSnapshot();
132 if (!didWarnUncachedGetSnapshot) {
133 var cachedValue = getSnapshot();
134 objectIs(value, cachedValue) || (console.error(
135 "The result of getSnapshot should be cached to avoid an infinite loop"
136 ), didWarnUncachedGetSnapshot = true);
137 }
138 cachedValue = useState28({
139 inst: { value, getSnapshot }
140 });
141 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
142 useLayoutEffect3(
143 function() {
144 inst.value = value;
145 inst.getSnapshot = getSnapshot;
146 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
147 },
148 [subscribe2, value, getSnapshot]
149 );
150 useEffect20(
151 function() {
152 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
153 return subscribe2(function() {
154 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
155 });
156 },
157 [subscribe2]
158 );
159 useDebugValue(value);
160 return value;
161 }
162 function checkIfSnapshotChanged(inst) {
163 var latestGetSnapshot = inst.getSnapshot;
164 inst = inst.value;
165 try {
166 var nextValue = latestGetSnapshot();
167 return !objectIs(inst, nextValue);
168 } catch (error) {
169 return true;
170 }
171 }
172 function useSyncExternalStore$1(subscribe2, getSnapshot) {
173 return getSnapshot();
174 }
175 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
176 var React8 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState28 = React8.useState, useEffect20 = React8.useEffect, useLayoutEffect3 = React8.useLayoutEffect, useDebugValue = React8.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
177 exports.useSyncExternalStore = void 0 !== React8.useSyncExternalStore ? React8.useSyncExternalStore : shim;
178 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
179 })();
180 }
181 });
182
183 // node_modules/use-sync-external-store/shim/index.js
184 var require_shim = __commonJS({
185 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
186 "use strict";
187 if (false) {
188 module.exports = null;
189 } else {
190 module.exports = require_use_sync_external_store_shim_development();
191 }
192 }
193 });
194
195 // package-external:@wordpress/private-apis
196 var require_private_apis = __commonJS({
197 "package-external:@wordpress/private-apis"(exports, module) {
198 module.exports = window.wp.privateApis;
199 }
200 });
201
202 // package-external:@wordpress/keycodes
203 var require_keycodes = __commonJS({
204 "package-external:@wordpress/keycodes"(exports, module) {
205 module.exports = window.wp.keycodes;
206 }
207 });
208
209 // node_modules/remove-accents/index.js
210 var require_remove_accents = __commonJS({
211 "node_modules/remove-accents/index.js"(exports, module) {
212 var characterMap = {
213 "\xC0": "A",
214 "\xC1": "A",
215 "\xC2": "A",
216 "\xC3": "A",
217 "\xC4": "A",
218 "\xC5": "A",
219 "\u1EA4": "A",
220 "\u1EAE": "A",
221 "\u1EB2": "A",
222 "\u1EB4": "A",
223 "\u1EB6": "A",
224 "\xC6": "AE",
225 "\u1EA6": "A",
226 "\u1EB0": "A",
227 "\u0202": "A",
228 "\u1EA2": "A",
229 "\u1EA0": "A",
230 "\u1EA8": "A",
231 "\u1EAA": "A",
232 "\u1EAC": "A",
233 "\xC7": "C",
234 "\u1E08": "C",
235 "\xC8": "E",
236 "\xC9": "E",
237 "\xCA": "E",
238 "\xCB": "E",
239 "\u1EBE": "E",
240 "\u1E16": "E",
241 "\u1EC0": "E",
242 "\u1E14": "E",
243 "\u1E1C": "E",
244 "\u0206": "E",
245 "\u1EBA": "E",
246 "\u1EBC": "E",
247 "\u1EB8": "E",
248 "\u1EC2": "E",
249 "\u1EC4": "E",
250 "\u1EC6": "E",
251 "\xCC": "I",
252 "\xCD": "I",
253 "\xCE": "I",
254 "\xCF": "I",
255 "\u1E2E": "I",
256 "\u020A": "I",
257 "\u1EC8": "I",
258 "\u1ECA": "I",
259 "\xD0": "D",
260 "\xD1": "N",
261 "\xD2": "O",
262 "\xD3": "O",
263 "\xD4": "O",
264 "\xD5": "O",
265 "\xD6": "O",
266 "\xD8": "O",
267 "\u1ED0": "O",
268 "\u1E4C": "O",
269 "\u1E52": "O",
270 "\u020E": "O",
271 "\u1ECE": "O",
272 "\u1ECC": "O",
273 "\u1ED4": "O",
274 "\u1ED6": "O",
275 "\u1ED8": "O",
276 "\u1EDC": "O",
277 "\u1EDE": "O",
278 "\u1EE0": "O",
279 "\u1EDA": "O",
280 "\u1EE2": "O",
281 "\xD9": "U",
282 "\xDA": "U",
283 "\xDB": "U",
284 "\xDC": "U",
285 "\u1EE6": "U",
286 "\u1EE4": "U",
287 "\u1EEC": "U",
288 "\u1EEE": "U",
289 "\u1EF0": "U",
290 "\xDD": "Y",
291 "\xE0": "a",
292 "\xE1": "a",
293 "\xE2": "a",
294 "\xE3": "a",
295 "\xE4": "a",
296 "\xE5": "a",
297 "\u1EA5": "a",
298 "\u1EAF": "a",
299 "\u1EB3": "a",
300 "\u1EB5": "a",
301 "\u1EB7": "a",
302 "\xE6": "ae",
303 "\u1EA7": "a",
304 "\u1EB1": "a",
305 "\u0203": "a",
306 "\u1EA3": "a",
307 "\u1EA1": "a",
308 "\u1EA9": "a",
309 "\u1EAB": "a",
310 "\u1EAD": "a",
311 "\xE7": "c",
312 "\u1E09": "c",
313 "\xE8": "e",
314 "\xE9": "e",
315 "\xEA": "e",
316 "\xEB": "e",
317 "\u1EBF": "e",
318 "\u1E17": "e",
319 "\u1EC1": "e",
320 "\u1E15": "e",
321 "\u1E1D": "e",
322 "\u0207": "e",
323 "\u1EBB": "e",
324 "\u1EBD": "e",
325 "\u1EB9": "e",
326 "\u1EC3": "e",
327 "\u1EC5": "e",
328 "\u1EC7": "e",
329 "\xEC": "i",
330 "\xED": "i",
331 "\xEE": "i",
332 "\xEF": "i",
333 "\u1E2F": "i",
334 "\u020B": "i",
335 "\u1EC9": "i",
336 "\u1ECB": "i",
337 "\xF0": "d",
338 "\xF1": "n",
339 "\xF2": "o",
340 "\xF3": "o",
341 "\xF4": "o",
342 "\xF5": "o",
343 "\xF6": "o",
344 "\xF8": "o",
345 "\u1ED1": "o",
346 "\u1E4D": "o",
347 "\u1E53": "o",
348 "\u020F": "o",
349 "\u1ECF": "o",
350 "\u1ECD": "o",
351 "\u1ED5": "o",
352 "\u1ED7": "o",
353 "\u1ED9": "o",
354 "\u1EDD": "o",
355 "\u1EDF": "o",
356 "\u1EE1": "o",
357 "\u1EDB": "o",
358 "\u1EE3": "o",
359 "\xF9": "u",
360 "\xFA": "u",
361 "\xFB": "u",
362 "\xFC": "u",
363 "\u1EE7": "u",
364 "\u1EE5": "u",
365 "\u1EED": "u",
366 "\u1EEF": "u",
367 "\u1EF1": "u",
368 "\xFD": "y",
369 "\xFF": "y",
370 "\u0100": "A",
371 "\u0101": "a",
372 "\u0102": "A",
373 "\u0103": "a",
374 "\u0104": "A",
375 "\u0105": "a",
376 "\u0106": "C",
377 "\u0107": "c",
378 "\u0108": "C",
379 "\u0109": "c",
380 "\u010A": "C",
381 "\u010B": "c",
382 "\u010C": "C",
383 "\u010D": "c",
384 "C\u0306": "C",
385 "c\u0306": "c",
386 "\u010E": "D",
387 "\u010F": "d",
388 "\u0110": "D",
389 "\u0111": "d",
390 "\u0112": "E",
391 "\u0113": "e",
392 "\u0114": "E",
393 "\u0115": "e",
394 "\u0116": "E",
395 "\u0117": "e",
396 "\u0118": "E",
397 "\u0119": "e",
398 "\u011A": "E",
399 "\u011B": "e",
400 "\u011C": "G",
401 "\u01F4": "G",
402 "\u011D": "g",
403 "\u01F5": "g",
404 "\u011E": "G",
405 "\u011F": "g",
406 "\u0120": "G",
407 "\u0121": "g",
408 "\u0122": "G",
409 "\u0123": "g",
410 "\u0124": "H",
411 "\u0125": "h",
412 "\u0126": "H",
413 "\u0127": "h",
414 "\u1E2A": "H",
415 "\u1E2B": "h",
416 "\u0128": "I",
417 "\u0129": "i",
418 "\u012A": "I",
419 "\u012B": "i",
420 "\u012C": "I",
421 "\u012D": "i",
422 "\u012E": "I",
423 "\u012F": "i",
424 "\u0130": "I",
425 "\u0131": "i",
426 "\u0132": "IJ",
427 "\u0133": "ij",
428 "\u0134": "J",
429 "\u0135": "j",
430 "\u0136": "K",
431 "\u0137": "k",
432 "\u1E30": "K",
433 "\u1E31": "k",
434 "K\u0306": "K",
435 "k\u0306": "k",
436 "\u0139": "L",
437 "\u013A": "l",
438 "\u013B": "L",
439 "\u013C": "l",
440 "\u013D": "L",
441 "\u013E": "l",
442 "\u013F": "L",
443 "\u0140": "l",
444 "\u0141": "l",
445 "\u0142": "l",
446 "\u1E3E": "M",
447 "\u1E3F": "m",
448 "M\u0306": "M",
449 "m\u0306": "m",
450 "\u0143": "N",
451 "\u0144": "n",
452 "\u0145": "N",
453 "\u0146": "n",
454 "\u0147": "N",
455 "\u0148": "n",
456 "\u0149": "n",
457 "N\u0306": "N",
458 "n\u0306": "n",
459 "\u014C": "O",
460 "\u014D": "o",
461 "\u014E": "O",
462 "\u014F": "o",
463 "\u0150": "O",
464 "\u0151": "o",
465 "\u0152": "OE",
466 "\u0153": "oe",
467 "P\u0306": "P",
468 "p\u0306": "p",
469 "\u0154": "R",
470 "\u0155": "r",
471 "\u0156": "R",
472 "\u0157": "r",
473 "\u0158": "R",
474 "\u0159": "r",
475 "R\u0306": "R",
476 "r\u0306": "r",
477 "\u0212": "R",
478 "\u0213": "r",
479 "\u015A": "S",
480 "\u015B": "s",
481 "\u015C": "S",
482 "\u015D": "s",
483 "\u015E": "S",
484 "\u0218": "S",
485 "\u0219": "s",
486 "\u015F": "s",
487 "\u0160": "S",
488 "\u0161": "s",
489 "\u0162": "T",
490 "\u0163": "t",
491 "\u021B": "t",
492 "\u021A": "T",
493 "\u0164": "T",
494 "\u0165": "t",
495 "\u0166": "T",
496 "\u0167": "t",
497 "T\u0306": "T",
498 "t\u0306": "t",
499 "\u0168": "U",
500 "\u0169": "u",
501 "\u016A": "U",
502 "\u016B": "u",
503 "\u016C": "U",
504 "\u016D": "u",
505 "\u016E": "U",
506 "\u016F": "u",
507 "\u0170": "U",
508 "\u0171": "u",
509 "\u0172": "U",
510 "\u0173": "u",
511 "\u0216": "U",
512 "\u0217": "u",
513 "V\u0306": "V",
514 "v\u0306": "v",
515 "\u0174": "W",
516 "\u0175": "w",
517 "\u1E82": "W",
518 "\u1E83": "w",
519 "X\u0306": "X",
520 "x\u0306": "x",
521 "\u0176": "Y",
522 "\u0177": "y",
523 "\u0178": "Y",
524 "Y\u0306": "Y",
525 "y\u0306": "y",
526 "\u0179": "Z",
527 "\u017A": "z",
528 "\u017B": "Z",
529 "\u017C": "z",
530 "\u017D": "Z",
531 "\u017E": "z",
532 "\u017F": "s",
533 "\u0192": "f",
534 "\u01A0": "O",
535 "\u01A1": "o",
536 "\u01AF": "U",
537 "\u01B0": "u",
538 "\u01CD": "A",
539 "\u01CE": "a",
540 "\u01CF": "I",
541 "\u01D0": "i",
542 "\u01D1": "O",
543 "\u01D2": "o",
544 "\u01D3": "U",
545 "\u01D4": "u",
546 "\u01D5": "U",
547 "\u01D6": "u",
548 "\u01D7": "U",
549 "\u01D8": "u",
550 "\u01D9": "U",
551 "\u01DA": "u",
552 "\u01DB": "U",
553 "\u01DC": "u",
554 "\u1EE8": "U",
555 "\u1EE9": "u",
556 "\u1E78": "U",
557 "\u1E79": "u",
558 "\u01FA": "A",
559 "\u01FB": "a",
560 "\u01FC": "AE",
561 "\u01FD": "ae",
562 "\u01FE": "O",
563 "\u01FF": "o",
564 "\xDE": "TH",
565 "\xFE": "th",
566 "\u1E54": "P",
567 "\u1E55": "p",
568 "\u1E64": "S",
569 "\u1E65": "s",
570 "X\u0301": "X",
571 "x\u0301": "x",
572 "\u0403": "\u0413",
573 "\u0453": "\u0433",
574 "\u040C": "\u041A",
575 "\u045C": "\u043A",
576 "A\u030B": "A",
577 "a\u030B": "a",
578 "E\u030B": "E",
579 "e\u030B": "e",
580 "I\u030B": "I",
581 "i\u030B": "i",
582 "\u01F8": "N",
583 "\u01F9": "n",
584 "\u1ED2": "O",
585 "\u1ED3": "o",
586 "\u1E50": "O",
587 "\u1E51": "o",
588 "\u1EEA": "U",
589 "\u1EEB": "u",
590 "\u1E80": "W",
591 "\u1E81": "w",
592 "\u1EF2": "Y",
593 "\u1EF3": "y",
594 "\u0200": "A",
595 "\u0201": "a",
596 "\u0204": "E",
597 "\u0205": "e",
598 "\u0208": "I",
599 "\u0209": "i",
600 "\u020C": "O",
601 "\u020D": "o",
602 "\u0210": "R",
603 "\u0211": "r",
604 "\u0214": "U",
605 "\u0215": "u",
606 "B\u030C": "B",
607 "b\u030C": "b",
608 "\u010C\u0323": "C",
609 "\u010D\u0323": "c",
610 "\xCA\u030C": "E",
611 "\xEA\u030C": "e",
612 "F\u030C": "F",
613 "f\u030C": "f",
614 "\u01E6": "G",
615 "\u01E7": "g",
616 "\u021E": "H",
617 "\u021F": "h",
618 "J\u030C": "J",
619 "\u01F0": "j",
620 "\u01E8": "K",
621 "\u01E9": "k",
622 "M\u030C": "M",
623 "m\u030C": "m",
624 "P\u030C": "P",
625 "p\u030C": "p",
626 "Q\u030C": "Q",
627 "q\u030C": "q",
628 "\u0158\u0329": "R",
629 "\u0159\u0329": "r",
630 "\u1E66": "S",
631 "\u1E67": "s",
632 "V\u030C": "V",
633 "v\u030C": "v",
634 "W\u030C": "W",
635 "w\u030C": "w",
636 "X\u030C": "X",
637 "x\u030C": "x",
638 "Y\u030C": "Y",
639 "y\u030C": "y",
640 "A\u0327": "A",
641 "a\u0327": "a",
642 "B\u0327": "B",
643 "b\u0327": "b",
644 "\u1E10": "D",
645 "\u1E11": "d",
646 "\u0228": "E",
647 "\u0229": "e",
648 "\u0190\u0327": "E",
649 "\u025B\u0327": "e",
650 "\u1E28": "H",
651 "\u1E29": "h",
652 "I\u0327": "I",
653 "i\u0327": "i",
654 "\u0197\u0327": "I",
655 "\u0268\u0327": "i",
656 "M\u0327": "M",
657 "m\u0327": "m",
658 "O\u0327": "O",
659 "o\u0327": "o",
660 "Q\u0327": "Q",
661 "q\u0327": "q",
662 "U\u0327": "U",
663 "u\u0327": "u",
664 "X\u0327": "X",
665 "x\u0327": "x",
666 "Z\u0327": "Z",
667 "z\u0327": "z",
668 "\u0439": "\u0438",
669 "\u0419": "\u0418",
670 "\u0451": "\u0435",
671 "\u0401": "\u0415"
672 };
673 var chars = Object.keys(characterMap).join("|");
674 var allAccents = new RegExp(chars, "g");
675 var firstAccent = new RegExp(chars, "");
676 function matcher(match2) {
677 return characterMap[match2];
678 }
679 var removeAccents2 = function(string) {
680 return string.replace(allAccents, matcher);
681 };
682 var hasAccents = function(string) {
683 return !!string.match(firstAccent);
684 };
685 module.exports = removeAccents2;
686 module.exports.has = hasAccents;
687 module.exports.remove = removeAccents2;
688 }
689 });
690
691 // node_modules/fast-deep-equal/es6/index.js
692 var require_es6 = __commonJS({
693 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
694 "use strict";
695 module.exports = function equal(a2, b2) {
696 if (a2 === b2) return true;
697 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
698 if (a2.constructor !== b2.constructor) return false;
699 var length, i2, keys;
700 if (Array.isArray(a2)) {
701 length = a2.length;
702 if (length != b2.length) return false;
703 for (i2 = length; i2-- !== 0; )
704 if (!equal(a2[i2], b2[i2])) return false;
705 return true;
706 }
707 if (a2 instanceof Map && b2 instanceof Map) {
708 if (a2.size !== b2.size) return false;
709 for (i2 of a2.entries())
710 if (!b2.has(i2[0])) return false;
711 for (i2 of a2.entries())
712 if (!equal(i2[1], b2.get(i2[0]))) return false;
713 return true;
714 }
715 if (a2 instanceof Set && b2 instanceof Set) {
716 if (a2.size !== b2.size) return false;
717 for (i2 of a2.entries())
718 if (!b2.has(i2[0])) return false;
719 return true;
720 }
721 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
722 length = a2.length;
723 if (length != b2.length) return false;
724 for (i2 = length; i2-- !== 0; )
725 if (a2[i2] !== b2[i2]) return false;
726 return true;
727 }
728 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
729 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
730 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
731 keys = Object.keys(a2);
732 length = keys.length;
733 if (length !== Object.keys(b2).length) return false;
734 for (i2 = length; i2-- !== 0; )
735 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
736 for (i2 = length; i2-- !== 0; ) {
737 var key = keys[i2];
738 if (!equal(a2[key], b2[key])) return false;
739 }
740 return true;
741 }
742 return a2 !== a2 && b2 !== b2;
743 };
744 }
745 });
746
747 // package-external:@wordpress/date
748 var require_date = __commonJS({
749 "package-external:@wordpress/date"(exports, module) {
750 module.exports = window.wp.date;
751 }
752 });
753
754 // package-external:@wordpress/warning
755 var require_warning = __commonJS({
756 "package-external:@wordpress/warning"(exports, module) {
757 module.exports = window.wp.warning;
758 }
759 });
760
761 // package-external:@wordpress/url
762 var require_url = __commonJS({
763 "package-external:@wordpress/url"(exports, module) {
764 module.exports = window.wp.url;
765 }
766 });
767
768 // package-external:@wordpress/notices
769 var require_notices = __commonJS({
770 "package-external:@wordpress/notices"(exports, module) {
771 module.exports = window.wp.notices;
772 }
773 });
774
775 // packages/media-utils/build-module/index.mjs
776 var index_exports = {};
777 __export(index_exports, {
778 MediaUpload: () => media_upload_default,
779 privateApis: () => privateApis12,
780 transformAttachment: () => transformAttachment,
781 uploadMedia: () => uploadMedia,
782 validateFileSize: () => validateFileSize,
783 validateMimeType: () => validateMimeType,
784 validateMimeTypeForUser: () => validateMimeTypeForUser
785 });
786
787 // packages/media-utils/build-module/components/media-upload/index.mjs
788 var import_element = __toESM(require_element(), 1);
789 var import_i18n = __toESM(require_i18n(), 1);
790 var DEFAULT_EMPTY_GALLERY = [];
791 var getFeaturedImageMediaFrame = () => {
792 const { wp } = window;
793 return wp.media.view.MediaFrame.Select.extend({
794 /**
795 * Enables the Set Featured Image Button.
796 *
797 * @param {Object} toolbar toolbar for featured image state
798 * @return {void}
799 */
800 featuredImageToolbar(toolbar) {
801 this.createSelectToolbar(toolbar, {
802 text: wp.media.view.l10n.setFeaturedImage,
803 state: this.options.state
804 });
805 },
806 /**
807 * Handle the edit state requirements of selected media item.
808 *
809 * @return {void}
810 */
811 editState() {
812 const selection = this.state("featured-image").get("selection");
813 const view = new wp.media.view.EditImage({
814 model: selection.single(),
815 controller: this
816 }).render();
817 this.content.set(view);
818 view.loadEditor();
819 },
820 /**
821 * Create the default states.
822 *
823 * @return {void}
824 */
825 createStates: function createStates() {
826 this.on(
827 "toolbar:create:featured-image",
828 this.featuredImageToolbar,
829 this
830 );
831 this.on("content:render:edit-image", this.editState, this);
832 this.states.add([
833 new wp.media.controller.FeaturedImage(),
834 new wp.media.controller.EditImage({
835 model: this.options.editImage
836 })
837 ]);
838 }
839 });
840 };
841 var getSingleMediaFrame = () => {
842 const { wp } = window;
843 return wp.media.view.MediaFrame.Select.extend({
844 /**
845 * Create the default states on the frame.
846 */
847 createStates() {
848 const options = this.options;
849 if (this.options.states) {
850 return;
851 }
852 this.states.add([
853 // Main states.
854 new wp.media.controller.Library({
855 library: wp.media.query(options.library),
856 multiple: options.multiple,
857 title: options.title,
858 priority: 20,
859 filterable: "uploaded"
860 // Allow filtering by uploaded images.
861 }),
862 new wp.media.controller.EditImage({
863 model: options.editImage
864 })
865 ]);
866 }
867 });
868 };
869 var getGalleryDetailsMediaFrame = () => {
870 const { wp } = window;
871 return wp.media.view.MediaFrame.Post.extend({
872 /**
873 * Set up gallery toolbar.
874 *
875 * @return {void}
876 */
877 galleryToolbar() {
878 const editing = this.state().get("editing");
879 this.toolbar.set(
880 new wp.media.view.Toolbar({
881 controller: this,
882 items: {
883 insert: {
884 style: "primary",
885 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
886 priority: 80,
887 requires: { library: true },
888 /**
889 * @fires wp.media.controller.State#update
890 */
891 click() {
892 const controller = this.controller, state = controller.state();
893 controller.close();
894 state.trigger(
895 "update",
896 state.get("library")
897 );
898 controller.setState(controller.options.state);
899 controller.reset();
900 }
901 }
902 }
903 })
904 );
905 },
906 /**
907 * Handle the edit state requirements of selected media item.
908 *
909 * @return {void}
910 */
911 editState() {
912 const selection = this.state("gallery").get("selection");
913 const view = new wp.media.view.EditImage({
914 model: selection.single(),
915 controller: this
916 }).render();
917 this.content.set(view);
918 view.loadEditor();
919 },
920 /**
921 * Create the default states.
922 *
923 * @return {void}
924 */
925 createStates: function createStates() {
926 this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
927 this.on("content:render:edit-image", this.editState, this);
928 this.states.add([
929 new wp.media.controller.Library({
930 id: "gallery",
931 title: wp.media.view.l10n.createGalleryTitle,
932 priority: 40,
933 toolbar: "main-gallery",
934 filterable: "uploaded",
935 multiple: "add",
936 editable: false,
937 library: wp.media.query({
938 type: "image",
939 ...this.options.library
940 })
941 }),
942 new wp.media.controller.EditImage({
943 model: this.options.editImage
944 }),
945 new wp.media.controller.GalleryEdit({
946 library: this.options.selection,
947 editing: this.options.editing,
948 menu: "gallery",
949 displaySettings: false,
950 multiple: true
951 }),
952 new wp.media.controller.GalleryAdd()
953 ]);
954 }
955 });
956 };
957 var slimImageObject = (img) => {
958 const attrSet = [
959 "sizes",
960 "mime",
961 "type",
962 "subtype",
963 "id",
964 "url",
965 "alt",
966 "link",
967 "caption"
968 ];
969 return attrSet.reduce((result, key) => {
970 if (img?.hasOwnProperty(key)) {
971 result[key] = img[key];
972 }
973 return result;
974 }, {});
975 };
976 var getAttachmentsCollection = (ids) => {
977 const { wp } = window;
978 return wp.media.query({
979 order: "ASC",
980 orderby: "post__in",
981 post__in: ids,
982 posts_per_page: -1,
983 query: true,
984 type: "image"
985 });
986 };
987 var MediaUpload = class extends import_element.Component {
988 constructor() {
989 super(...arguments);
990 this.openModal = this.openModal.bind(this);
991 this.onOpen = this.onOpen.bind(this);
992 this.onSelect = this.onSelect.bind(this);
993 this.onUpdate = this.onUpdate.bind(this);
994 this.onClose = this.onClose.bind(this);
995 }
996 initializeListeners() {
997 this.frame.on("select", this.onSelect);
998 this.frame.on("update", this.onUpdate);
999 this.frame.on("open", this.onOpen);
1000 this.frame.on("close", this.onClose);
1001 }
1002 /**
1003 * Sets the Gallery frame and initializes listeners.
1004 *
1005 * @return {void}
1006 */
1007 buildAndSetGalleryFrame() {
1008 const {
1009 addToGallery = false,
1010 allowedTypes,
1011 multiple = false,
1012 value = DEFAULT_EMPTY_GALLERY
1013 } = this.props;
1014 if (value === this.lastGalleryValue) {
1015 return;
1016 }
1017 const { wp } = window;
1018 this.lastGalleryValue = value;
1019 if (this.frame) {
1020 this.frame.remove();
1021 }
1022 let currentState;
1023 if (addToGallery) {
1024 currentState = "gallery-library";
1025 } else {
1026 currentState = value && value.length ? "gallery-edit" : "gallery";
1027 }
1028 if (!this.GalleryDetailsMediaFrame) {
1029 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1030 }
1031 const attachments = getAttachmentsCollection(value);
1032 const selection = new wp.media.model.Selection(attachments.models, {
1033 props: attachments.props.toJSON(),
1034 multiple
1035 });
1036 this.frame = new this.GalleryDetailsMediaFrame({
1037 mimeType: allowedTypes,
1038 state: currentState,
1039 multiple,
1040 selection,
1041 editing: !!value?.length
1042 });
1043 wp.media.frame = this.frame;
1044 this.initializeListeners();
1045 }
1046 /**
1047 * Initializes the Media Library requirements for the featured image flow.
1048 *
1049 * @return {void}
1050 */
1051 buildAndSetFeatureImageFrame() {
1052 const { wp } = window;
1053 const { value: featuredImageId, multiple, allowedTypes } = this.props;
1054 const featuredImageFrame = getFeaturedImageMediaFrame();
1055 const attachments = getAttachmentsCollection(featuredImageId);
1056 const selection = new wp.media.model.Selection(attachments.models, {
1057 props: attachments.props.toJSON()
1058 });
1059 this.frame = new featuredImageFrame({
1060 mimeType: allowedTypes,
1061 state: "featured-image",
1062 multiple,
1063 selection,
1064 editing: featuredImageId
1065 });
1066 wp.media.frame = this.frame;
1067 wp.media.view.settings.post = {
1068 ...wp.media.view.settings.post,
1069 featuredImageId: featuredImageId || -1
1070 };
1071 }
1072 /**
1073 * Initializes the Media Library requirements for the single image flow.
1074 *
1075 * @return {void}
1076 */
1077 buildAndSetSingleMediaFrame() {
1078 const { wp } = window;
1079 const {
1080 allowedTypes,
1081 multiple = false,
1082 title = (0, import_i18n.__)("Select or Upload Media"),
1083 value
1084 } = this.props;
1085 const frameConfig = {
1086 title,
1087 multiple
1088 };
1089 if (!!allowedTypes) {
1090 frameConfig.library = { type: allowedTypes };
1091 }
1092 if (this.frame) {
1093 this.frame.remove();
1094 }
1095 const singleImageFrame = getSingleMediaFrame();
1096 const attachments = getAttachmentsCollection(value);
1097 const selection = new wp.media.model.Selection(attachments.models, {
1098 props: attachments.props.toJSON()
1099 });
1100 this.frame = new singleImageFrame({
1101 mimeType: allowedTypes,
1102 multiple,
1103 selection,
1104 ...frameConfig
1105 });
1106 wp.media.frame = this.frame;
1107 }
1108 componentWillUnmount() {
1109 this.frame?.remove();
1110 }
1111 onUpdate(selections) {
1112 const { onSelect, multiple = false } = this.props;
1113 const state = this.frame.state();
1114 const selectedImages = selections || state.get("selection");
1115 if (!selectedImages || !selectedImages.models.length) {
1116 return;
1117 }
1118 if (multiple) {
1119 onSelect(
1120 selectedImages.models.map(
1121 (model) => slimImageObject(model.toJSON())
1122 )
1123 );
1124 } else {
1125 onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1126 }
1127 }
1128 onSelect() {
1129 const { onSelect, multiple = false } = this.props;
1130 const attachment = this.frame.state().get("selection").toJSON();
1131 onSelect(multiple ? attachment : attachment[0]);
1132 }
1133 onOpen() {
1134 const { wp } = window;
1135 const { value } = this.props;
1136 this.updateCollection();
1137 if (this.props.mode) {
1138 this.frame.content.mode(this.props.mode);
1139 }
1140 const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1141 if (!hasMedia) {
1142 return;
1143 }
1144 const isGallery = this.props.gallery;
1145 const selection = this.frame.state().get("selection");
1146 const valueArray = Array.isArray(value) ? value : [value];
1147 if (!isGallery) {
1148 valueArray.forEach((id) => {
1149 selection.add(wp.media.attachment(id));
1150 });
1151 }
1152 const attachments = getAttachmentsCollection(valueArray);
1153 attachments.more().done(function() {
1154 if (isGallery && attachments?.models?.length) {
1155 selection.add(attachments.models);
1156 }
1157 });
1158 }
1159 onClose() {
1160 const { onClose } = this.props;
1161 if (onClose) {
1162 onClose();
1163 }
1164 this.frame.detach();
1165 }
1166 updateCollection() {
1167 const frameContent = this.frame.content.get();
1168 if (frameContent && frameContent.collection) {
1169 const collection = frameContent.collection;
1170 collection.toArray().forEach((model) => model.trigger("destroy", model));
1171 collection.mirroring._hasMore = true;
1172 collection.more();
1173 }
1174 }
1175 openModal() {
1176 const {
1177 gallery = false,
1178 unstableFeaturedImageFlow = false,
1179 modalClass
1180 } = this.props;
1181 if (gallery) {
1182 this.buildAndSetGalleryFrame();
1183 } else {
1184 this.buildAndSetSingleMediaFrame();
1185 }
1186 if (modalClass) {
1187 this.frame.$el.addClass(modalClass);
1188 }
1189 if (unstableFeaturedImageFlow) {
1190 this.buildAndSetFeatureImageFrame();
1191 }
1192 this.initializeListeners();
1193 this.frame.open();
1194 }
1195 render() {
1196 return this.props.render({ open: this.openModal });
1197 }
1198 };
1199 var media_upload_default = MediaUpload;
1200
1201 // packages/media-utils/build-module/utils/upload-media.mjs
1202 var import_i18n5 = __toESM(require_i18n(), 1);
1203 var import_blob = __toESM(require_blob(), 1);
1204
1205 // packages/media-utils/build-module/utils/upload-to-server.mjs
1206 var import_api_fetch = __toESM(require_api_fetch(), 1);
1207
1208 // packages/media-utils/build-module/utils/flatten-form-data.mjs
1209 function isPlainObject(data) {
1210 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1211 }
1212 function flattenFormData(formData, key, data) {
1213 if (isPlainObject(data)) {
1214 for (const [name, value] of Object.entries(data)) {
1215 flattenFormData(formData, `${key}[${name}]`, value);
1216 }
1217 } else if (data !== void 0) {
1218 formData.append(key, String(data));
1219 }
1220 }
1221
1222 // packages/media-utils/build-module/utils/transform-attachment.mjs
1223 function transformAttachment(attachment) {
1224 const { alt_text, source_url, ...savedMediaProps } = attachment;
1225 return {
1226 ...savedMediaProps,
1227 alt: attachment.alt_text,
1228 caption: attachment.caption?.raw ?? "",
1229 title: attachment.title.raw,
1230 url: attachment.source_url,
1231 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1232 };
1233 }
1234
1235 // packages/media-utils/build-module/utils/upload-to-server.mjs
1236 async function uploadToServer(file, additionalData = {}, signal) {
1237 const data = new FormData();
1238 data.append("file", file, file.name || file.type.replace("/", "."));
1239 for (const [key, value] of Object.entries(additionalData)) {
1240 flattenFormData(
1241 data,
1242 key,
1243 value
1244 );
1245 }
1246 return transformAttachment(
1247 await (0, import_api_fetch.default)({
1248 // This allows the video block to directly get a video's poster image.
1249 path: "/wp/v2/media?_embed=wp:featuredmedia",
1250 body: data,
1251 method: "POST",
1252 signal
1253 })
1254 );
1255 }
1256
1257 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1258 var import_i18n2 = __toESM(require_i18n(), 1);
1259
1260 // packages/media-utils/build-module/utils/upload-error.mjs
1261 var UploadError = class extends Error {
1262 code;
1263 file;
1264 constructor({ code, message: message2, file, cause }) {
1265 super(message2, { cause });
1266 Object.setPrototypeOf(this, new.target.prototype);
1267 this.code = code;
1268 this.file = file;
1269 }
1270 };
1271
1272 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1273 function validateMimeType(file, allowedTypes) {
1274 if (!allowedTypes) {
1275 return;
1276 }
1277 const isAllowedType = allowedTypes.some((allowedType) => {
1278 if (allowedType.includes("/")) {
1279 return allowedType === file.type;
1280 }
1281 return file.type.startsWith(`${allowedType}/`);
1282 });
1283 if (file.type && !isAllowedType) {
1284 throw new UploadError({
1285 code: "MIME_TYPE_NOT_SUPPORTED",
1286 message: (0, import_i18n2.sprintf)(
1287 // translators: %s: file name.
1288 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1289 file.name
1290 ),
1291 file
1292 });
1293 }
1294 }
1295
1296 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1297 var import_i18n3 = __toESM(require_i18n(), 1);
1298
1299 // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1300 function getMimeTypesArray(wpMimeTypesObject) {
1301 if (!wpMimeTypesObject) {
1302 return null;
1303 }
1304 return Object.entries(wpMimeTypesObject).flatMap(
1305 ([extensionsString, mime]) => {
1306 const [type] = mime.split("/");
1307 const extensions = extensionsString.split("|");
1308 return [
1309 mime,
1310 ...extensions.map(
1311 (extension) => `${type}/${extension}`
1312 )
1313 ];
1314 }
1315 );
1316 }
1317
1318 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1319 function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1320 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1321 if (!allowedMimeTypesForUser) {
1322 return;
1323 }
1324 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1325 file.type
1326 );
1327 if (file.type && !isAllowedMimeTypeForUser) {
1328 throw new UploadError({
1329 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1330 message: (0, import_i18n3.sprintf)(
1331 // translators: %s: file name.
1332 (0, import_i18n3.__)(
1333 "%s: Sorry, you are not allowed to upload this file type."
1334 ),
1335 file.name
1336 ),
1337 file
1338 });
1339 }
1340 }
1341
1342 // packages/media-utils/build-module/utils/validate-file-size.mjs
1343 var import_i18n4 = __toESM(require_i18n(), 1);
1344 function validateFileSize(file, maxUploadFileSize) {
1345 if (file.size <= 0) {
1346 throw new UploadError({
1347 code: "EMPTY_FILE",
1348 message: (0, import_i18n4.sprintf)(
1349 // translators: %s: file name.
1350 (0, import_i18n4.__)("%s: This file is empty."),
1351 file.name
1352 ),
1353 file
1354 });
1355 }
1356 if (maxUploadFileSize && file.size > maxUploadFileSize) {
1357 throw new UploadError({
1358 code: "SIZE_ABOVE_LIMIT",
1359 message: (0, import_i18n4.sprintf)(
1360 // translators: %s: file name.
1361 (0, import_i18n4.__)(
1362 "%s: This file exceeds the maximum upload size for this site."
1363 ),
1364 file.name
1365 ),
1366 file
1367 });
1368 }
1369 }
1370
1371 // packages/media-utils/build-module/utils/upload-media.mjs
1372 function uploadMedia({
1373 wpAllowedMimeTypes,
1374 allowedTypes,
1375 additionalData = {},
1376 filesList,
1377 maxUploadFileSize,
1378 onError,
1379 onFileChange,
1380 signal,
1381 multiple = true
1382 }) {
1383 if (!multiple && filesList.length > 1) {
1384 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1385 return;
1386 }
1387 const validFiles = [];
1388 const filesSet = [];
1389 const setAndUpdateFiles = (index, value) => {
1390 if (!window.__clientSideMediaProcessing) {
1391 if (filesSet[index]?.url) {
1392 (0, import_blob.revokeBlobURL)(filesSet[index].url);
1393 }
1394 }
1395 filesSet[index] = value;
1396 onFileChange?.(
1397 filesSet.filter((attachment) => attachment !== null)
1398 );
1399 };
1400 for (const mediaFile of filesList) {
1401 try {
1402 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1403 } catch (error) {
1404 onError?.(error);
1405 continue;
1406 }
1407 try {
1408 validateMimeType(mediaFile, allowedTypes);
1409 } catch (error) {
1410 onError?.(error);
1411 continue;
1412 }
1413 try {
1414 validateFileSize(mediaFile, maxUploadFileSize);
1415 } catch (error) {
1416 onError?.(error);
1417 continue;
1418 }
1419 validFiles.push(mediaFile);
1420 if (!window.__clientSideMediaProcessing) {
1421 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1422 onFileChange?.(filesSet);
1423 }
1424 }
1425 validFiles.map(async (file, index) => {
1426 try {
1427 const attachment = await uploadToServer(
1428 file,
1429 additionalData,
1430 signal
1431 );
1432 setAndUpdateFiles(index, attachment);
1433 } catch (error) {
1434 setAndUpdateFiles(index, null);
1435 let message2;
1436 if (typeof error === "object" && error !== null && "message" in error) {
1437 message2 = typeof error.message === "string" ? error.message : String(error.message);
1438 } else {
1439 message2 = (0, import_i18n5.sprintf)(
1440 // translators: %s: file name
1441 (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1442 file.name
1443 );
1444 }
1445 onError?.(
1446 new UploadError({
1447 code: "GENERAL",
1448 message: message2,
1449 file,
1450 cause: error instanceof Error ? error : void 0
1451 })
1452 );
1453 }
1454 });
1455 }
1456
1457 // packages/media-utils/build-module/utils/sideload-media.mjs
1458 var import_i18n6 = __toESM(require_i18n(), 1);
1459
1460 // packages/media-utils/build-module/utils/sideload-to-server.mjs
1461 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1462 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1463 const data = new FormData();
1464 data.append("file", file, file.name || file.type.replace("/", "."));
1465 for (const [key, value] of Object.entries(additionalData)) {
1466 flattenFormData(
1467 data,
1468 key,
1469 value
1470 );
1471 }
1472 return transformAttachment(
1473 await (0, import_api_fetch2.default)({
1474 path: `/wp/v2/media/${attachmentId}/sideload`,
1475 body: data,
1476 method: "POST",
1477 signal
1478 })
1479 );
1480 }
1481
1482 // packages/media-utils/build-module/utils/sideload-media.mjs
1483 var noop = () => {
1484 };
1485 async function sideloadMedia({
1486 file,
1487 attachmentId,
1488 additionalData = {},
1489 signal,
1490 onFileChange,
1491 onError = noop
1492 }) {
1493 try {
1494 const attachment = await sideloadToServer(
1495 file,
1496 attachmentId,
1497 additionalData,
1498 signal
1499 );
1500 onFileChange?.([attachment]);
1501 } catch (error) {
1502 let message2;
1503 if (error instanceof Error) {
1504 message2 = error.message;
1505 } else {
1506 message2 = (0, import_i18n6.sprintf)(
1507 // translators: %s: file name
1508 (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1509 file.name
1510 );
1511 }
1512 onError(
1513 new UploadError({
1514 code: "GENERAL",
1515 message: message2,
1516 file,
1517 cause: error instanceof Error ? error : void 0
1518 })
1519 );
1520 }
1521 }
1522
1523 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1524 var import_element60 = __toESM(require_element(), 1);
1525 var import_i18n66 = __toESM(require_i18n(), 1);
1526 var import_core_data4 = __toESM(require_core_data(), 1);
1527 var import_data9 = __toESM(require_data(), 1);
1528 var import_components53 = __toESM(require_components(), 1);
1529
1530 // packages/icons/build-module/library/arrow-down.mjs
1531 var import_primitives = __toESM(require_primitives(), 1);
1532 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1533 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_primitives.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) });
1534
1535 // packages/icons/build-module/library/arrow-left.mjs
1536 var import_primitives2 = __toESM(require_primitives(), 1);
1537 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1538 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_primitives2.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
1539
1540 // packages/icons/build-module/library/arrow-right.mjs
1541 var import_primitives3 = __toESM(require_primitives(), 1);
1542 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1543 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives3.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
1544
1545 // packages/icons/build-module/library/arrow-up.mjs
1546 var import_primitives4 = __toESM(require_primitives(), 1);
1547 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1548 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives4.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
1549
1550 // packages/icons/build-module/library/audio.mjs
1551 var import_primitives5 = __toESM(require_primitives(), 1);
1552 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1553 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives5.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) });
1554
1555 // packages/icons/build-module/library/block-table.mjs
1556 var import_primitives6 = __toESM(require_primitives(), 1);
1557 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1558 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives6.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" }) });
1559
1560 // packages/icons/build-module/library/category.mjs
1561 var import_primitives7 = __toESM(require_primitives(), 1);
1562 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1563 var category_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives7.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z" }) });
1564
1565 // packages/icons/build-module/library/check.mjs
1566 var import_primitives8 = __toESM(require_primitives(), 1);
1567 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1568 var check_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives8.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1569
1570 // packages/icons/build-module/library/close-small.mjs
1571 var import_primitives9 = __toESM(require_primitives(), 1);
1572 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1573 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives9.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) });
1574
1575 // packages/icons/build-module/library/cog.mjs
1576 var import_primitives10 = __toESM(require_primitives(), 1);
1577 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1578 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives10.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z" }) });
1579
1580 // packages/icons/build-module/library/comment-author-avatar.mjs
1581 var import_primitives11 = __toESM(require_primitives(), 1);
1582 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1583 var comment_author_avatar_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives11.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z" }) });
1584
1585 // packages/icons/build-module/library/envelope.mjs
1586 var import_primitives12 = __toESM(require_primitives(), 1);
1587 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1588 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives12.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z" }) });
1589
1590 // packages/icons/build-module/library/error.mjs
1591 var import_primitives13 = __toESM(require_primitives(), 1);
1592 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1593 var error_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives13.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z" }) });
1594
1595 // packages/icons/build-module/library/file.mjs
1596 var import_primitives14 = __toESM(require_primitives(), 1);
1597 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1598 var file_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives14.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" }) });
1599
1600 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1601 var import_primitives15 = __toESM(require_primitives(), 1);
1602 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1603 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives15.Path, { d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" }) });
1604
1605 // packages/icons/build-module/library/format-list-bullets.mjs
1606 var import_primitives16 = __toESM(require_primitives(), 1);
1607 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1608 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives16.Path, { d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
1609
1610 // packages/icons/build-module/library/funnel.mjs
1611 var import_primitives17 = __toESM(require_primitives(), 1);
1612 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1613 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives17.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1614
1615 // packages/icons/build-module/library/image.mjs
1616 var import_primitives18 = __toESM(require_primitives(), 1);
1617 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1618 var image_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives18.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) });
1619
1620 // packages/icons/build-module/library/link.mjs
1621 var import_primitives19 = __toESM(require_primitives(), 1);
1622 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1623 var link_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives19.Path, { d: "M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z" }) });
1624
1625 // packages/icons/build-module/library/mobile.mjs
1626 var import_primitives20 = __toESM(require_primitives(), 1);
1627 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1628 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives20.Path, { d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z" }) });
1629
1630 // packages/icons/build-module/library/more-vertical.mjs
1631 var import_primitives21 = __toESM(require_primitives(), 1);
1632 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1633 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives21.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1634
1635 // packages/icons/build-module/library/next.mjs
1636 var import_primitives22 = __toESM(require_primitives(), 1);
1637 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1638 var next_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives22.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });
1639
1640 // packages/icons/build-module/library/previous.mjs
1641 var import_primitives23 = __toESM(require_primitives(), 1);
1642 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1643 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives23.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });
1644
1645 // packages/icons/build-module/library/scheduled.mjs
1646 var import_primitives24 = __toESM(require_primitives(), 1);
1647 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1648 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives24.Path, { fillRule: "evenodd", clipRule: "evenodd", d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z" }) });
1649
1650 // packages/icons/build-module/library/search.mjs
1651 var import_primitives25 = __toESM(require_primitives(), 1);
1652 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1653 var search_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives25.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) });
1654
1655 // packages/icons/build-module/library/seen.mjs
1656 var import_primitives26 = __toESM(require_primitives(), 1);
1657 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1658 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives26.Path, { d: "M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z" }) });
1659
1660 // packages/icons/build-module/library/unseen.mjs
1661 var import_primitives27 = __toESM(require_primitives(), 1);
1662 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1663 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives27.Path, { d: "M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z" }) });
1664
1665 // packages/icons/build-module/library/upload.mjs
1666 var import_primitives28 = __toESM(require_primitives(), 1);
1667 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1668 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives28.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) });
1669
1670 // packages/icons/build-module/library/video.mjs
1671 var import_primitives29 = __toESM(require_primitives(), 1);
1672 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1673 var video_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives29.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) });
1674
1675 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1676 var React = __toESM(require_react(), 1);
1677 var UNINITIALIZED = {};
1678 function useRefWithInit(init2, initArg) {
1679 const ref = React.useRef(UNINITIALIZED);
1680 if (ref.current === UNINITIALIZED) {
1681 ref.current = init2(initArg);
1682 }
1683 return ref;
1684 }
1685
1686 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1687 var React4 = __toESM(require_react(), 1);
1688
1689 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1690 function useMergedRefs(a2, b2, c2, d2) {
1691 const forkRef = useRefWithInit(createForkRef).current;
1692 if (didChange(forkRef, a2, b2, c2, d2)) {
1693 update(forkRef, [a2, b2, c2, d2]);
1694 }
1695 return forkRef.callback;
1696 }
1697 function useMergedRefsN(refs) {
1698 const forkRef = useRefWithInit(createForkRef).current;
1699 if (didChangeN(forkRef, refs)) {
1700 update(forkRef, refs);
1701 }
1702 return forkRef.callback;
1703 }
1704 function createForkRef() {
1705 return {
1706 callback: null,
1707 cleanup: null,
1708 refs: []
1709 };
1710 }
1711 function didChange(forkRef, a2, b2, c2, d2) {
1712 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1713 }
1714 function didChangeN(forkRef, newRefs) {
1715 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1716 }
1717 function update(forkRef, refs) {
1718 forkRef.refs = refs;
1719 if (refs.every((ref) => ref == null)) {
1720 forkRef.callback = null;
1721 return;
1722 }
1723 forkRef.callback = (instance) => {
1724 if (forkRef.cleanup) {
1725 forkRef.cleanup();
1726 forkRef.cleanup = null;
1727 }
1728 if (instance != null) {
1729 const cleanupCallbacks = Array(refs.length).fill(null);
1730 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1731 const ref = refs[i2];
1732 if (ref == null) {
1733 continue;
1734 }
1735 switch (typeof ref) {
1736 case "function": {
1737 const refCleanup = ref(instance);
1738 if (typeof refCleanup === "function") {
1739 cleanupCallbacks[i2] = refCleanup;
1740 }
1741 break;
1742 }
1743 case "object": {
1744 ref.current = instance;
1745 break;
1746 }
1747 default:
1748 }
1749 }
1750 forkRef.cleanup = () => {
1751 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1752 const ref = refs[i2];
1753 if (ref == null) {
1754 continue;
1755 }
1756 switch (typeof ref) {
1757 case "function": {
1758 const cleanupCallback = cleanupCallbacks[i2];
1759 if (typeof cleanupCallback === "function") {
1760 cleanupCallback();
1761 } else {
1762 ref(null);
1763 }
1764 break;
1765 }
1766 case "object": {
1767 ref.current = null;
1768 break;
1769 }
1770 default:
1771 }
1772 }
1773 };
1774 }
1775 };
1776 }
1777
1778 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1779 var React3 = __toESM(require_react(), 1);
1780
1781 // node_modules/@base-ui/utils/esm/reactVersion.js
1782 var React2 = __toESM(require_react(), 1);
1783 var majorVersion = parseInt(React2.version, 10);
1784 function isReactVersionAtLeast(reactVersionToCheck) {
1785 return majorVersion >= reactVersionToCheck;
1786 }
1787
1788 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1789 function getReactElementRef(element) {
1790 if (!/* @__PURE__ */ React3.isValidElement(element)) {
1791 return null;
1792 }
1793 const reactElement = element;
1794 const propsWithRef = reactElement.props;
1795 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1796 }
1797
1798 // node_modules/@base-ui/utils/esm/mergeObjects.js
1799 function mergeObjects(a2, b2) {
1800 if (a2 && !b2) {
1801 return a2;
1802 }
1803 if (!a2 && b2) {
1804 return b2;
1805 }
1806 if (a2 || b2) {
1807 return {
1808 ...a2,
1809 ...b2
1810 };
1811 }
1812 return void 0;
1813 }
1814
1815 // node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
1816 function getStateAttributesProps(state, customMapping) {
1817 const props = {};
1818 for (const key in state) {
1819 const value = state[key];
1820 if (customMapping?.hasOwnProperty(key)) {
1821 const customProps = customMapping[key](value);
1822 if (customProps != null) {
1823 Object.assign(props, customProps);
1824 }
1825 continue;
1826 }
1827 if (value === true) {
1828 props[`data-${key.toLowerCase()}`] = "";
1829 } else if (value) {
1830 props[`data-${key.toLowerCase()}`] = value.toString();
1831 }
1832 }
1833 return props;
1834 }
1835
1836 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1837 function resolveClassName(className, state) {
1838 return typeof className === "function" ? className(state) : className;
1839 }
1840
1841 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1842 function resolveStyle(style, state) {
1843 return typeof style === "function" ? style(state) : style;
1844 }
1845
1846 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1847 var EMPTY_PROPS = {};
1848 function mergeProps(a2, b2, c2, d2, e2) {
1849 let merged = {
1850 ...resolvePropsGetter(a2, EMPTY_PROPS)
1851 };
1852 if (b2) {
1853 merged = mergeOne(merged, b2);
1854 }
1855 if (c2) {
1856 merged = mergeOne(merged, c2);
1857 }
1858 if (d2) {
1859 merged = mergeOne(merged, d2);
1860 }
1861 if (e2) {
1862 merged = mergeOne(merged, e2);
1863 }
1864 return merged;
1865 }
1866 function mergePropsN(props) {
1867 if (props.length === 0) {
1868 return EMPTY_PROPS;
1869 }
1870 if (props.length === 1) {
1871 return resolvePropsGetter(props[0], EMPTY_PROPS);
1872 }
1873 let merged = {
1874 ...resolvePropsGetter(props[0], EMPTY_PROPS)
1875 };
1876 for (let i2 = 1; i2 < props.length; i2 += 1) {
1877 merged = mergeOne(merged, props[i2]);
1878 }
1879 return merged;
1880 }
1881 function mergeOne(merged, inputProps) {
1882 if (isPropsGetter(inputProps)) {
1883 return inputProps(merged);
1884 }
1885 return mutablyMergeInto(merged, inputProps);
1886 }
1887 function mutablyMergeInto(mergedProps, externalProps) {
1888 if (!externalProps) {
1889 return mergedProps;
1890 }
1891 for (const propName in externalProps) {
1892 const externalPropValue = externalProps[propName];
1893 switch (propName) {
1894 case "style": {
1895 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1896 break;
1897 }
1898 case "className": {
1899 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1900 break;
1901 }
1902 default: {
1903 if (isEventHandler(propName, externalPropValue)) {
1904 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1905 } else {
1906 mergedProps[propName] = externalPropValue;
1907 }
1908 }
1909 }
1910 }
1911 return mergedProps;
1912 }
1913 function isEventHandler(key, value) {
1914 const code0 = key.charCodeAt(0);
1915 const code1 = key.charCodeAt(1);
1916 const code2 = key.charCodeAt(2);
1917 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1918 }
1919 function isPropsGetter(inputProps) {
1920 return typeof inputProps === "function";
1921 }
1922 function resolvePropsGetter(inputProps, previousProps) {
1923 if (isPropsGetter(inputProps)) {
1924 return inputProps(previousProps);
1925 }
1926 return inputProps ?? EMPTY_PROPS;
1927 }
1928 function mergeEventHandlers(ourHandler, theirHandler) {
1929 if (!theirHandler) {
1930 return ourHandler;
1931 }
1932 if (!ourHandler) {
1933 return theirHandler;
1934 }
1935 return (event) => {
1936 if (isSyntheticEvent(event)) {
1937 const baseUIEvent = event;
1938 makeEventPreventable(baseUIEvent);
1939 const result2 = theirHandler(baseUIEvent);
1940 if (!baseUIEvent.baseUIHandlerPrevented) {
1941 ourHandler?.(baseUIEvent);
1942 }
1943 return result2;
1944 }
1945 const result = theirHandler(event);
1946 ourHandler?.(event);
1947 return result;
1948 };
1949 }
1950 function makeEventPreventable(event) {
1951 event.preventBaseUIHandler = () => {
1952 event.baseUIHandlerPrevented = true;
1953 };
1954 return event;
1955 }
1956 function mergeClassNames(ourClassName, theirClassName) {
1957 if (theirClassName) {
1958 if (ourClassName) {
1959 return theirClassName + " " + ourClassName;
1960 }
1961 return theirClassName;
1962 }
1963 return ourClassName;
1964 }
1965 function isSyntheticEvent(event) {
1966 return event != null && typeof event === "object" && "nativeEvent" in event;
1967 }
1968
1969 // node_modules/@base-ui/utils/esm/empty.js
1970 var EMPTY_ARRAY = Object.freeze([]);
1971 var EMPTY_OBJECT = Object.freeze({});
1972
1973 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1974 var import_react = __toESM(require_react(), 1);
1975 function useRenderElement(element, componentProps, params = {}) {
1976 const renderProp = componentProps.render;
1977 const outProps = useRenderElementProps(componentProps, params);
1978 if (params.enabled === false) {
1979 return null;
1980 }
1981 const state = params.state ?? EMPTY_OBJECT;
1982 return evaluateRenderProp(element, renderProp, outProps, state);
1983 }
1984 function useRenderElementProps(componentProps, params = {}) {
1985 const {
1986 className: classNameProp,
1987 style: styleProp,
1988 render: renderProp
1989 } = componentProps;
1990 const {
1991 state = EMPTY_OBJECT,
1992 ref,
1993 props,
1994 stateAttributesMapping,
1995 enabled = true
1996 } = params;
1997 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1998 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1999 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
2000 const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
2001 if (typeof document !== "undefined") {
2002 if (!enabled) {
2003 useMergedRefs(null, null);
2004 } else if (Array.isArray(ref)) {
2005 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2006 } else {
2007 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2008 }
2009 }
2010 if (!enabled) {
2011 return EMPTY_OBJECT;
2012 }
2013 if (className !== void 0) {
2014 outProps.className = mergeClassNames(outProps.className, className);
2015 }
2016 if (style !== void 0) {
2017 outProps.style = mergeObjects(outProps.style, style);
2018 }
2019 return outProps;
2020 }
2021 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2022 function evaluateRenderProp(element, render4, props, state) {
2023 if (render4) {
2024 if (typeof render4 === "function") {
2025 return render4(props, state);
2026 }
2027 const mergedProps = mergeProps(props, render4.props);
2028 mergedProps.ref = props.ref;
2029 let newElement = render4;
2030 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2031 const children = React4.Children.toArray(render4);
2032 newElement = children[0];
2033 }
2034 if (true) {
2035 if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
2036 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
2037 }
2038 }
2039 return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
2040 }
2041 if (element) {
2042 if (typeof element === "string") {
2043 return renderTag(element, props);
2044 }
2045 }
2046 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
2047 }
2048 function renderTag(Tag, props) {
2049 if (Tag === "button") {
2050 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2051 type: "button",
2052 ...props,
2053 key: props.key
2054 });
2055 }
2056 if (Tag === "img") {
2057 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2058 alt: "",
2059 ...props,
2060 key: props.key
2061 });
2062 }
2063 return /* @__PURE__ */ React4.createElement(Tag, props);
2064 }
2065
2066 // node_modules/@base-ui/react/esm/use-render/useRender.js
2067 function useRender(params) {
2068 return useRenderElement(params.defaultTagName ?? "div", params, params);
2069 }
2070
2071 // node_modules/clsx/dist/clsx.mjs
2072 function r(e2) {
2073 var t2, f2, n2 = "";
2074 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
2075 else if ("object" == typeof e2) if (Array.isArray(e2)) {
2076 var o2 = e2.length;
2077 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
2078 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
2079 return n2;
2080 }
2081 function clsx() {
2082 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
2083 return n2;
2084 }
2085 var clsx_default = clsx;
2086
2087 // packages/ui/build-module/stack/stack.mjs
2088 var import_element2 = __toESM(require_element(), 1);
2089 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
2090 const style = document.createElement("style");
2091 style.setAttribute("data-wp-hash", "71d20935c2");
2092 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
2093 document.head.appendChild(style);
2094 }
2095 var style_default = { "stack": "_19ce0419607e1896__stack" };
2096 var gapTokens = {
2097 xs: "var(--wpds-dimension-gap-xs, 4px)",
2098 sm: "var(--wpds-dimension-gap-sm, 8px)",
2099 md: "var(--wpds-dimension-gap-md, 12px)",
2100 lg: "var(--wpds-dimension-gap-lg, 16px)",
2101 xl: "var(--wpds-dimension-gap-xl, 24px)",
2102 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2103 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2104 };
2105 var Stack = (0, import_element2.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
2106 const style = {
2107 gap: gap && gapTokens[gap],
2108 alignItems: align,
2109 justifyContent: justify,
2110 flexDirection: direction,
2111 flexWrap: wrap
2112 };
2113 const element = useRender({
2114 render: render4,
2115 ref,
2116 props: mergeProps(props, { style, className: style_default.stack })
2117 });
2118 return element;
2119 });
2120
2121 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2122 var import_element3 = __toESM(require_element(), 1);
2123
2124 // packages/dataviews/build-module/constants.mjs
2125 var import_i18n7 = __toESM(require_i18n(), 1);
2126 var OPERATOR_IS_ANY = "isAny";
2127 var OPERATOR_IS_NONE = "isNone";
2128 var OPERATOR_IS_ALL = "isAll";
2129 var OPERATOR_IS_NOT_ALL = "isNotAll";
2130 var OPERATOR_BETWEEN = "between";
2131 var OPERATOR_IN_THE_PAST = "inThePast";
2132 var OPERATOR_OVER = "over";
2133 var OPERATOR_IS = "is";
2134 var OPERATOR_IS_NOT = "isNot";
2135 var OPERATOR_LESS_THAN = "lessThan";
2136 var OPERATOR_GREATER_THAN = "greaterThan";
2137 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
2138 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
2139 var OPERATOR_BEFORE = "before";
2140 var OPERATOR_AFTER = "after";
2141 var OPERATOR_BEFORE_INC = "beforeInc";
2142 var OPERATOR_AFTER_INC = "afterInc";
2143 var OPERATOR_CONTAINS = "contains";
2144 var OPERATOR_NOT_CONTAINS = "notContains";
2145 var OPERATOR_STARTS_WITH = "startsWith";
2146 var OPERATOR_ON = "on";
2147 var OPERATOR_NOT_ON = "notOn";
2148 var SORTING_DIRECTIONS = ["asc", "desc"];
2149 var sortArrows = { asc: "\u2191", desc: "\u2193" };
2150 var sortValues = { asc: "ascending", desc: "descending" };
2151 var sortLabels = {
2152 asc: (0, import_i18n7.__)("Sort ascending"),
2153 desc: (0, import_i18n7.__)("Sort descending")
2154 };
2155 var sortIcons = {
2156 asc: arrow_up_default,
2157 desc: arrow_down_default
2158 };
2159 var LAYOUT_TABLE = "table";
2160 var LAYOUT_GRID = "grid";
2161 var LAYOUT_LIST = "list";
2162 var LAYOUT_ACTIVITY = "activity";
2163 var LAYOUT_PICKER_GRID = "pickerGrid";
2164 var LAYOUT_PICKER_TABLE = "pickerTable";
2165
2166 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2167 var DataViewsContext = (0, import_element3.createContext)({
2168 view: { type: LAYOUT_TABLE },
2169 onChangeView: () => {
2170 },
2171 fields: [],
2172 data: [],
2173 paginationInfo: {
2174 totalItems: 0,
2175 totalPages: 0
2176 },
2177 selection: [],
2178 onChangeSelection: () => {
2179 },
2180 setOpenedFilter: () => {
2181 },
2182 openedFilter: null,
2183 getItemId: (item) => item.id,
2184 isItemClickable: () => true,
2185 renderItemLink: void 0,
2186 containerWidth: 0,
2187 containerRef: (0, import_element3.createRef)(),
2188 resizeObserverRef: () => {
2189 },
2190 defaultLayouts: { list: {}, grid: {}, table: {} },
2191 filters: [],
2192 isShowingFilter: false,
2193 setIsShowingFilter: () => {
2194 },
2195 hasInitiallyLoaded: false,
2196 hasInfiniteScrollHandler: false,
2197 config: {
2198 perPageSizes: []
2199 }
2200 });
2201 DataViewsContext.displayName = "DataViewsContext";
2202 var dataviews_context_default = DataViewsContext;
2203
2204 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
2205 var import_i18n27 = __toESM(require_i18n(), 1);
2206
2207 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
2208 var import_i18n15 = __toESM(require_i18n(), 1);
2209 var import_components6 = __toESM(require_components(), 1);
2210 var import_element11 = __toESM(require_element(), 1);
2211 var import_keycodes = __toESM(require_keycodes(), 1);
2212
2213 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
2214 var import_components = __toESM(require_components(), 1);
2215 var import_i18n8 = __toESM(require_i18n(), 1);
2216 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
2217 function DataViewsSelectionCheckbox({
2218 selection,
2219 onChangeSelection,
2220 item,
2221 getItemId,
2222 titleField,
2223 disabled,
2224 ...extraProps
2225 }) {
2226 const id = getItemId(item);
2227 const checked = !disabled && selection.includes(id);
2228 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n8.__)("(no title)");
2229 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
2230 import_components.CheckboxControl,
2231 {
2232 className: "dataviews-selection-checkbox",
2233 "aria-label": selectionLabel,
2234 "aria-disabled": disabled,
2235 checked,
2236 onChange: () => {
2237 if (disabled) {
2238 return;
2239 }
2240 onChangeSelection(
2241 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
2242 );
2243 },
2244 ...extraProps
2245 }
2246 );
2247 }
2248
2249 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2250 var import_components2 = __toESM(require_components(), 1);
2251 var import_i18n9 = __toESM(require_i18n(), 1);
2252 var import_element4 = __toESM(require_element(), 1);
2253 var import_data = __toESM(require_data(), 1);
2254 var import_compose = __toESM(require_compose(), 1);
2255
2256 // packages/dataviews/build-module/lock-unlock.mjs
2257 var import_private_apis = __toESM(require_private_apis(), 1);
2258 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
2259 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
2260 "@wordpress/dataviews"
2261 );
2262
2263 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2264 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
2265 var { Menu, kebabCase } = unlock(import_components2.privateApis);
2266 function ButtonTrigger({
2267 action,
2268 onClick,
2269 items,
2270 variant
2271 }) {
2272 const label = typeof action.label === "string" ? action.label : action.label(items);
2273 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2274 import_components2.Button,
2275 {
2276 disabled: !!action.disabled,
2277 accessibleWhenDisabled: true,
2278 size: "compact",
2279 variant,
2280 onClick,
2281 children: label
2282 }
2283 );
2284 }
2285 function MenuItemTrigger({
2286 action,
2287 onClick,
2288 items
2289 }) {
2290 const label = typeof action.label === "string" ? action.label : action.label(items);
2291 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.ItemLabel, { children: label }) });
2292 }
2293 function ActionModal({
2294 action,
2295 items,
2296 closeModal
2297 }) {
2298 const label = typeof action.label === "string" ? action.label : action.label(items);
2299 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
2300 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2301 import_components2.Modal,
2302 {
2303 title: modalHeader || label,
2304 __experimentalHideHeader: !!action.hideModalHeader,
2305 onRequestClose: closeModal,
2306 focusOnMount: action.modalFocusOnMount ?? true,
2307 size: action.modalSize || "medium",
2308 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
2309 action.id
2310 )}`,
2311 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(action.RenderModal, { items, closeModal })
2312 }
2313 );
2314 }
2315 function ActionsMenuGroup({
2316 actions,
2317 item,
2318 registry,
2319 setActiveModalAction
2320 }) {
2321 const { primaryActions, regularActions } = (0, import_element4.useMemo)(() => {
2322 return actions.reduce(
2323 (acc, action) => {
2324 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
2325 return acc;
2326 },
2327 {
2328 primaryActions: [],
2329 regularActions: []
2330 }
2331 );
2332 }, [actions]);
2333 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2334 MenuItemTrigger,
2335 {
2336 action,
2337 onClick: () => {
2338 if ("RenderModal" in action) {
2339 setActiveModalAction(action);
2340 return;
2341 }
2342 action.callback([item], { registry });
2343 },
2344 items: [item]
2345 },
2346 action.id
2347 ));
2348 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu.Group, { children: [
2349 renderActionGroup(primaryActions),
2350 renderActionGroup(regularActions)
2351 ] });
2352 }
2353 function ItemActions({
2354 item,
2355 actions,
2356 isCompact
2357 }) {
2358 const registry = (0, import_data.useRegistry)();
2359 const { primaryActions, eligibleActions } = (0, import_element4.useMemo)(() => {
2360 const _eligibleActions = actions.filter(
2361 (action) => !action.isEligible || action.isEligible(item)
2362 );
2363 const _primaryActions = _eligibleActions.filter(
2364 (action) => action.isPrimary
2365 );
2366 return {
2367 primaryActions: _primaryActions,
2368 eligibleActions: _eligibleActions
2369 };
2370 }, [actions, item]);
2371 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2372 if (isCompact) {
2373 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2374 CompactItemActions,
2375 {
2376 item,
2377 actions: eligibleActions,
2378 isSmall: true,
2379 registry
2380 }
2381 );
2382 }
2383 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2384 Stack,
2385 {
2386 direction: "row",
2387 justify: "flex-end",
2388 className: "dataviews-item-actions",
2389 style: {
2390 flexShrink: 0,
2391 width: "auto"
2392 },
2393 children: [
2394 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2395 PrimaryActions,
2396 {
2397 item,
2398 actions: primaryActions,
2399 registry
2400 }
2401 ),
2402 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
2403 // there if there are any actions at all.
2404 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2405 CompactItemActions,
2406 {
2407 item,
2408 actions: eligibleActions,
2409 registry
2410 }
2411 )
2412 ]
2413 }
2414 );
2415 }
2416 function CompactItemActions({
2417 item,
2418 actions,
2419 isSmall,
2420 registry
2421 }) {
2422 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)(
2423 null
2424 );
2425 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2426 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu, { placement: "bottom-end", children: [
2427 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2428 Menu.TriggerButton,
2429 {
2430 render: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2431 import_components2.Button,
2432 {
2433 size: isSmall ? "small" : "compact",
2434 icon: more_vertical_default,
2435 label: (0, import_i18n9.__)("Actions"),
2436 accessibleWhenDisabled: true,
2437 disabled: !actions.length,
2438 className: "dataviews-all-actions-button"
2439 }
2440 )
2441 }
2442 ),
2443 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2444 ActionsMenuGroup,
2445 {
2446 actions,
2447 item,
2448 registry,
2449 setActiveModalAction
2450 }
2451 ) })
2452 ] }),
2453 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2454 ActionModal,
2455 {
2456 action: activeModalAction,
2457 items: [item],
2458 closeModal: () => setActiveModalAction(null)
2459 }
2460 )
2461 ] });
2462 }
2463 function PrimaryActions({
2464 item,
2465 actions,
2466 registry,
2467 buttonVariant
2468 }) {
2469 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)(null);
2470 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2471 if (isMobileViewport) {
2472 return null;
2473 }
2474 if (!Array.isArray(actions) || actions.length === 0) {
2475 return null;
2476 }
2477 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2478 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2479 ButtonTrigger,
2480 {
2481 action,
2482 onClick: () => {
2483 if ("RenderModal" in action) {
2484 setActiveModalAction(action);
2485 return;
2486 }
2487 action.callback([item], { registry });
2488 },
2489 items: [item],
2490 variant: buttonVariant
2491 },
2492 action.id
2493 )),
2494 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2495 ActionModal,
2496 {
2497 action: activeModalAction,
2498 items: [item],
2499 closeModal: () => setActiveModalAction(null)
2500 }
2501 )
2502 ] });
2503 }
2504
2505 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2506 var import_components3 = __toESM(require_components(), 1);
2507 var import_i18n11 = __toESM(require_i18n(), 1);
2508 var import_element5 = __toESM(require_element(), 1);
2509 var import_data2 = __toESM(require_data(), 1);
2510 var import_compose2 = __toESM(require_compose(), 1);
2511
2512 // packages/dataviews/build-module/utils/get-footer-message.mjs
2513 var import_i18n10 = __toESM(require_i18n(), 1);
2514 function getFooterMessage(selectionCount, itemsCount, totalItems) {
2515 if (selectionCount > 0) {
2516 return (0, import_i18n10.sprintf)(
2517 /* translators: %d: number of items. */
2518 (0, import_i18n10._n)("%d Item selected", "%d Items selected", selectionCount),
2519 selectionCount
2520 );
2521 }
2522 if (totalItems > itemsCount) {
2523 return (0, import_i18n10.sprintf)(
2524 /* translators: %1$d: number of items. %2$d: total number of items. */
2525 (0, import_i18n10._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
2526 itemsCount,
2527 totalItems
2528 );
2529 }
2530 return (0, import_i18n10.sprintf)(
2531 /* translators: %d: number of items. */
2532 (0, import_i18n10._n)("%d Item", "%d Items", itemsCount),
2533 itemsCount
2534 );
2535 }
2536
2537 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2538 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
2539 function useHasAPossibleBulkAction(actions, item) {
2540 return (0, import_element5.useMemo)(() => {
2541 return actions.some((action) => {
2542 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2543 });
2544 }, [actions, item]);
2545 }
2546 function useSomeItemHasAPossibleBulkAction(actions, data) {
2547 return (0, import_element5.useMemo)(() => {
2548 return data.some((item) => {
2549 return actions.some((action) => {
2550 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2551 });
2552 });
2553 }, [actions, data]);
2554 }
2555 function BulkSelectionCheckbox({
2556 selection,
2557 onChangeSelection,
2558 data,
2559 actions,
2560 getItemId
2561 }) {
2562 const selectableItems = (0, import_element5.useMemo)(() => {
2563 return data.filter((item) => {
2564 return actions.some(
2565 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
2566 );
2567 });
2568 }, [data, actions]);
2569 const selectedItems = data.filter(
2570 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2571 );
2572 const areAllSelected = selectedItems.length === selectableItems.length;
2573 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2574 import_components3.CheckboxControl,
2575 {
2576 className: "dataviews-view-table-selection-checkbox",
2577 checked: areAllSelected,
2578 indeterminate: !areAllSelected && !!selectedItems.length,
2579 onChange: () => {
2580 if (areAllSelected) {
2581 onChangeSelection([]);
2582 } else {
2583 onChangeSelection(
2584 selectableItems.map((item) => getItemId(item))
2585 );
2586 }
2587 },
2588 "aria-label": areAllSelected ? (0, import_i18n11.__)("Deselect all") : (0, import_i18n11.__)("Select all")
2589 }
2590 );
2591 }
2592
2593 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2594 var import_i18n12 = __toESM(require_i18n(), 1);
2595 var import_components4 = __toESM(require_components(), 1);
2596 var import_element6 = __toESM(require_element(), 1);
2597
2598 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
2599 function getHideableFields(view, fields) {
2600 const togglableFields = [
2601 view?.titleField,
2602 view?.mediaField,
2603 view?.descriptionField
2604 ].filter(Boolean);
2605 return fields.filter(
2606 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
2607 );
2608 }
2609
2610 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2611 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
2612 var { Menu: Menu2 } = unlock(import_components4.privateApis);
2613 function WithMenuSeparators({ children }) {
2614 return import_element6.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_element6.Fragment, { children: [
2615 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Separator, {}),
2616 child
2617 ] }, i2));
2618 }
2619 var _HeaderMenu = (0, import_element6.forwardRef)(function HeaderMenu({
2620 fieldId,
2621 view,
2622 fields,
2623 onChangeView,
2624 onHide,
2625 setOpenedFilter,
2626 canMove = true,
2627 canInsertLeft = true,
2628 canInsertRight = true
2629 }, ref) {
2630 const visibleFieldIds = view.fields ?? [];
2631 const index = visibleFieldIds?.indexOf(fieldId);
2632 const isSorted = view.sort?.field === fieldId;
2633 let isHidable = false;
2634 let isSortable = false;
2635 let canAddFilter = false;
2636 let operators = [];
2637 const field = fields.find((f2) => f2.id === fieldId);
2638 const { setIsShowingFilter } = (0, import_element6.useContext)(dataviews_context_default);
2639 if (!field) {
2640 return null;
2641 }
2642 isHidable = field.enableHiding !== false;
2643 isSortable = field.enableSorting !== false;
2644 const header = field.header;
2645 operators = !!field.filterBy && field.filterBy?.operators || [];
2646 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
2647 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
2648 return header;
2649 }
2650 const hiddenFields = getHideableFields(view, fields).filter(
2651 (f2) => !visibleFieldIds.includes(f2.id)
2652 );
2653 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
2654 const isRtl = (0, import_i18n12.isRTL)();
2655 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2656 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
2657 Menu2.TriggerButton,
2658 {
2659 render: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2660 import_components4.Button,
2661 {
2662 size: "compact",
2663 className: "dataviews-view-table-header-button",
2664 ref,
2665 variant: "tertiary"
2666 }
2667 ),
2668 children: [
2669 header,
2670 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
2671 ]
2672 }
2673 ),
2674 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(WithMenuSeparators, { children: [
2675 isSortable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
2676 (direction) => {
2677 const isChecked = view.sort && isSorted && view.sort.direction === direction;
2678 const value = `${fieldId}-${direction}`;
2679 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2680 Menu2.RadioItem,
2681 {
2682 name: "view-table-sorting",
2683 value,
2684 checked: isChecked,
2685 onChange: () => {
2686 onChangeView({
2687 ...view,
2688 sort: {
2689 field: fieldId,
2690 direction
2691 },
2692 showLevels: false
2693 });
2694 },
2695 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
2696 },
2697 value
2698 );
2699 }
2700 ) }),
2701 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2702 Menu2.Item,
2703 {
2704 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: funnel_default }),
2705 onClick: () => {
2706 setOpenedFilter(fieldId);
2707 setIsShowingFilter(true);
2708 onChangeView({
2709 ...view,
2710 page: 1,
2711 filters: [
2712 ...view.filters || [],
2713 {
2714 field: fieldId,
2715 value: void 0,
2716 operator: operators[0]
2717 }
2718 ]
2719 });
2720 },
2721 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Add filter") })
2722 }
2723 ) }),
2724 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2.Group, { children: [
2725 canMove && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2726 Menu2.Item,
2727 {
2728 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: arrow_left_default }),
2729 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
2730 onClick: () => {
2731 const targetIndex = isRtl ? index + 1 : index - 1;
2732 const newFields = [
2733 ...visibleFieldIds
2734 ];
2735 newFields.splice(index, 1);
2736 newFields.splice(
2737 targetIndex,
2738 0,
2739 fieldId
2740 );
2741 onChangeView({
2742 ...view,
2743 fields: newFields
2744 });
2745 },
2746 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move left") })
2747 }
2748 ),
2749 canMove && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2750 Menu2.Item,
2751 {
2752 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: arrow_right_default }),
2753 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
2754 onClick: () => {
2755 const targetIndex = isRtl ? index - 1 : index + 1;
2756 const newFields = [
2757 ...visibleFieldIds
2758 ];
2759 newFields.splice(index, 1);
2760 newFields.splice(
2761 targetIndex,
2762 0,
2763 fieldId
2764 );
2765 onChangeView({
2766 ...view,
2767 fields: newFields
2768 });
2769 },
2770 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move right") })
2771 }
2772 ),
2773 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2774 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert left") }) }),
2775 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2776 const insertIndex = isRtl ? index + 1 : index;
2777 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2778 Menu2.Item,
2779 {
2780 onClick: () => {
2781 onChangeView({
2782 ...view,
2783 fields: [
2784 ...visibleFieldIds.slice(
2785 0,
2786 insertIndex
2787 ),
2788 hiddenField.id,
2789 ...visibleFieldIds.slice(
2790 insertIndex
2791 )
2792 ]
2793 });
2794 },
2795 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2796 },
2797 hiddenField.id
2798 );
2799 }) })
2800 ] }),
2801 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2802 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert right") }) }),
2803 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2804 const insertIndex = isRtl ? index : index + 1;
2805 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2806 Menu2.Item,
2807 {
2808 onClick: () => {
2809 onChangeView({
2810 ...view,
2811 fields: [
2812 ...visibleFieldIds.slice(
2813 0,
2814 insertIndex
2815 ),
2816 hiddenField.id,
2817 ...visibleFieldIds.slice(
2818 insertIndex
2819 )
2820 ]
2821 });
2822 },
2823 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2824 },
2825 hiddenField.id
2826 );
2827 }) })
2828 ] }),
2829 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2830 Menu2.Item,
2831 {
2832 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: unseen_default }),
2833 onClick: () => {
2834 onHide(field);
2835 onChangeView({
2836 ...view,
2837 fields: visibleFieldIds.filter(
2838 (id) => id !== fieldId
2839 )
2840 });
2841 },
2842 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Hide column") })
2843 }
2844 )
2845 ] })
2846 ] }) })
2847 ] });
2848 });
2849 var ColumnHeaderMenu = _HeaderMenu;
2850 var column_header_menu_default = ColumnHeaderMenu;
2851
2852 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
2853 var import_element7 = __toESM(require_element(), 1);
2854 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
2855 function getClickableItemProps({
2856 item,
2857 isItemClickable: isItemClickable2,
2858 onClickItem,
2859 className
2860 }) {
2861 if (!isItemClickable2(item) || !onClickItem) {
2862 return { className };
2863 }
2864 return {
2865 className: className ? `${className} ${className}--clickable` : void 0,
2866 role: "button",
2867 tabIndex: 0,
2868 onClick: (event) => {
2869 event.stopPropagation();
2870 onClickItem(item);
2871 },
2872 onKeyDown: (event) => {
2873 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2874 event.stopPropagation();
2875 onClickItem(item);
2876 }
2877 }
2878 };
2879 }
2880 function ItemClickWrapper({
2881 item,
2882 isItemClickable: isItemClickable2,
2883 onClickItem,
2884 renderItemLink,
2885 className,
2886 children,
2887 ...extraProps
2888 }) {
2889 if (!isItemClickable2(item)) {
2890 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className, ...extraProps, children });
2891 }
2892 if (renderItemLink) {
2893 const renderedElement = renderItemLink({
2894 item,
2895 className: `${className} ${className}--clickable`,
2896 ...extraProps,
2897 children
2898 });
2899 return (0, import_element7.cloneElement)(renderedElement, {
2900 onClick: (event) => {
2901 event.stopPropagation();
2902 if (renderedElement.props.onClick) {
2903 renderedElement.props.onClick(event);
2904 }
2905 },
2906 onKeyDown: (event) => {
2907 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2908 event.stopPropagation();
2909 if (renderedElement.props.onKeyDown) {
2910 renderedElement.props.onKeyDown(event);
2911 }
2912 }
2913 }
2914 });
2915 }
2916 const clickProps = getClickableItemProps({
2917 item,
2918 isItemClickable: isItemClickable2,
2919 onClickItem,
2920 className
2921 });
2922 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...clickProps, ...extraProps, children });
2923 }
2924
2925 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
2926 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
2927 function ColumnPrimary({
2928 item,
2929 level,
2930 titleField,
2931 mediaField,
2932 descriptionField: descriptionField2,
2933 onClickItem,
2934 renderItemLink,
2935 isItemClickable: isItemClickable2
2936 }) {
2937 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
2938 mediaField && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2939 ItemClickWrapper,
2940 {
2941 item,
2942 isItemClickable: isItemClickable2,
2943 onClickItem,
2944 renderItemLink,
2945 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
2946 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
2947 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2948 mediaField.render,
2949 {
2950 item,
2951 field: mediaField,
2952 config: { sizes: "32px" }
2953 }
2954 )
2955 }
2956 ),
2957 /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
2958 Stack,
2959 {
2960 direction: "column",
2961 align: "flex-start",
2962 className: "dataviews-view-table__primary-column-content",
2963 children: [
2964 titleField && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
2965 ItemClickWrapper,
2966 {
2967 item,
2968 isItemClickable: isItemClickable2,
2969 onClickItem,
2970 renderItemLink,
2971 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
2972 children: [
2973 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "dataviews-view-table__level", children: [
2974 Array(level).fill("\u2014").join(" "),
2975 "\xA0"
2976 ] }),
2977 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(titleField.render, { item, field: titleField })
2978 ]
2979 }
2980 ),
2981 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2982 descriptionField2.render,
2983 {
2984 item,
2985 field: descriptionField2
2986 }
2987 )
2988 ]
2989 }
2990 )
2991 ] });
2992 }
2993 var column_primary_default = ColumnPrimary;
2994
2995 // packages/dataviews/build-module/components/dataviews-layouts/table/use-is-horizontal-scroll-end.mjs
2996 var import_compose3 = __toESM(require_compose(), 1);
2997 var import_element8 = __toESM(require_element(), 1);
2998 var import_i18n13 = __toESM(require_i18n(), 1);
2999 var isScrolledToEnd = (element) => {
3000 if ((0, import_i18n13.isRTL)()) {
3001 const scrollLeft = Math.abs(element.scrollLeft);
3002 return scrollLeft <= 1;
3003 }
3004 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
3005 };
3006 function useIsHorizontalScrollEnd({
3007 scrollContainerRef,
3008 enabled = false
3009 }) {
3010 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element8.useState)(false);
3011 const handleIsHorizontalScrollEnd = (0, import_compose3.useDebounce)(
3012 (0, import_element8.useCallback)(() => {
3013 const scrollContainer = scrollContainerRef.current;
3014 if (scrollContainer) {
3015 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
3016 }
3017 }, [scrollContainerRef, setIsHorizontalScrollEnd]),
3018 200
3019 );
3020 (0, import_element8.useEffect)(() => {
3021 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) {
3022 return () => {
3023 };
3024 }
3025 handleIsHorizontalScrollEnd();
3026 scrollContainerRef.current.addEventListener(
3027 "scroll",
3028 handleIsHorizontalScrollEnd
3029 );
3030 window.addEventListener("resize", handleIsHorizontalScrollEnd);
3031 return () => {
3032 scrollContainerRef.current?.removeEventListener(
3033 "scroll",
3034 handleIsHorizontalScrollEnd
3035 );
3036 window.removeEventListener("resize", handleIsHorizontalScrollEnd);
3037 };
3038 }, [scrollContainerRef, enabled]);
3039 return isHorizontalScrollEnd;
3040 }
3041
3042 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
3043 function getDataByGroup(data, groupByField) {
3044 return data.reduce((groups, item) => {
3045 const groupName = groupByField.getValue({ item });
3046 if (!groups.has(groupName)) {
3047 groups.set(groupName, []);
3048 }
3049 groups.get(groupName)?.push(item);
3050 return groups;
3051 }, /* @__PURE__ */ new Map());
3052 }
3053
3054 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
3055 var import_components5 = __toESM(require_components(), 1);
3056 var import_i18n14 = __toESM(require_i18n(), 1);
3057 var import_element9 = __toESM(require_element(), 1);
3058 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3059 function FieldItem({
3060 field,
3061 isVisible: isVisible2,
3062 onToggleVisibility
3063 }) {
3064 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
3065 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components5.Icon, { icon: check_default }) }),
3066 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
3067 ] }) });
3068 }
3069 function isDefined(item) {
3070 return !!item;
3071 }
3072 function PropertiesSection({
3073 showLabel = true
3074 }) {
3075 const { view, fields, onChangeView } = (0, import_element9.useContext)(dataviews_context_default);
3076 const regularFields = getHideableFields(view, fields);
3077 if (!regularFields?.length) {
3078 return null;
3079 }
3080 const titleField = fields.find((f2) => f2.id === view.titleField);
3081 const previewField = fields.find((f2) => f2.id === view.mediaField);
3082 const descriptionField2 = fields.find(
3083 (f2) => f2.id === view.descriptionField
3084 );
3085 const lockedFields = [
3086 {
3087 field: titleField,
3088 isVisibleFlag: "showTitle"
3089 },
3090 {
3091 field: previewField,
3092 isVisibleFlag: "showMedia"
3093 },
3094 {
3095 field: descriptionField2,
3096 isVisibleFlag: "showDescription"
3097 }
3098 ].filter(({ field }) => isDefined(field));
3099 const visibleFieldIds = view.fields ?? [];
3100 const visibleRegularFieldsCount = regularFields.filter(
3101 (f2) => visibleFieldIds.includes(f2.id)
3102 ).length;
3103 const visibleLockedFields = lockedFields.filter(
3104 ({ isVisibleFlag }) => (
3105 // @ts-expect-error
3106 view[isVisibleFlag] ?? true
3107 )
3108 );
3109 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
3110 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
3111 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
3112 showLabel && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n14.__)("Properties") }),
3113 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3114 Stack,
3115 {
3116 direction: "column",
3117 className: "dataviews-view-config__properties",
3118 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
3119 lockedFields.map(({ field, isVisibleFlag }) => {
3120 const isVisible2 = view[isVisibleFlag] ?? true;
3121 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
3122 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3123 FieldItem,
3124 {
3125 field: fieldToRender,
3126 isVisible: isVisible2,
3127 onToggleVisibility: () => {
3128 onChangeView({
3129 ...view,
3130 [isVisibleFlag]: !isVisible2
3131 });
3132 }
3133 },
3134 field.id
3135 );
3136 }),
3137 regularFields.map((field) => {
3138 const isVisible2 = visibleFieldIds.includes(field.id);
3139 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
3140 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3141 FieldItem,
3142 {
3143 field: fieldToRender,
3144 isVisible: isVisible2,
3145 onToggleVisibility: () => {
3146 onChangeView({
3147 ...view,
3148 fields: isVisible2 ? visibleFieldIds.filter(
3149 (fieldId) => fieldId !== field.id
3150 ) : [...visibleFieldIds, field.id]
3151 });
3152 }
3153 },
3154 field.id
3155 );
3156 })
3157 ] })
3158 }
3159 )
3160 ] });
3161 }
3162
3163 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
3164 var import_element10 = __toESM(require_element(), 1);
3165 function useDelayedLoading(isLoading, options = { delay: 400 }) {
3166 const [showLoader, setShowLoader] = (0, import_element10.useState)(false);
3167 (0, import_element10.useEffect)(() => {
3168 if (!isLoading) {
3169 return;
3170 }
3171 const timeout = setTimeout(() => {
3172 setShowLoader(true);
3173 }, options.delay);
3174 return () => {
3175 clearTimeout(timeout);
3176 setShowLoader(false);
3177 };
3178 }, [isLoading, options.delay]);
3179 return showLoader;
3180 }
3181
3182 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3183 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3184 function getEffectiveAlign(explicitAlign, fieldType) {
3185 if (explicitAlign) {
3186 return explicitAlign;
3187 }
3188 if (fieldType === "integer" || fieldType === "number") {
3189 return "end";
3190 }
3191 return void 0;
3192 }
3193 function TableColumnField({
3194 item,
3195 fields,
3196 column,
3197 align
3198 }) {
3199 const field = fields.find((f2) => f2.id === column);
3200 if (!field) {
3201 return null;
3202 }
3203 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
3204 "dataviews-view-table__cell-align-end": align === "end",
3205 "dataviews-view-table__cell-align-center": align === "center"
3206 });
3207 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(field.render, { item, field }) });
3208 }
3209 function TableRow({
3210 hasBulkActions,
3211 item,
3212 level,
3213 actions,
3214 fields,
3215 id,
3216 view,
3217 titleField,
3218 mediaField,
3219 descriptionField: descriptionField2,
3220 selection,
3221 getItemId,
3222 isItemClickable: isItemClickable2,
3223 onClickItem,
3224 renderItemLink,
3225 onChangeSelection,
3226 isActionsColumnSticky,
3227 posinset
3228 }) {
3229 const { paginationInfo } = (0, import_element11.useContext)(dataviews_context_default);
3230 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
3231 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
3232 const {
3233 showTitle = true,
3234 showMedia = true,
3235 showDescription = true,
3236 infiniteScrollEnabled
3237 } = view;
3238 const isTouchDeviceRef = (0, import_element11.useRef)(false);
3239 const columns = view.fields ?? [];
3240 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
3241 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3242 "tr",
3243 {
3244 className: clsx_default("dataviews-view-table__row", {
3245 "is-selected": hasPossibleBulkAction && isSelected2,
3246 "has-bulk-actions": hasPossibleBulkAction
3247 }),
3248 onTouchStart: () => {
3249 isTouchDeviceRef.current = true;
3250 },
3251 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
3252 "aria-posinset": posinset,
3253 role: infiniteScrollEnabled ? "article" : void 0,
3254 onMouseDown: (event) => {
3255 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3256 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
3257 event?.preventDefault();
3258 }
3259 },
3260 onClick: (event) => {
3261 if (!hasPossibleBulkAction) {
3262 return;
3263 }
3264 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3265 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
3266 onChangeSelection(
3267 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3268 );
3269 }
3270 },
3271 children: [
3272 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3273 DataViewsSelectionCheckbox,
3274 {
3275 item,
3276 selection,
3277 onChangeSelection,
3278 getItemId,
3279 titleField,
3280 disabled: !hasPossibleBulkAction
3281 }
3282 ) }) }),
3283 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3284 column_primary_default,
3285 {
3286 item,
3287 level,
3288 titleField: showTitle ? titleField : void 0,
3289 mediaField: showMedia ? mediaField : void 0,
3290 descriptionField: showDescription ? descriptionField2 : void 0,
3291 isItemClickable: isItemClickable2,
3292 onClickItem,
3293 renderItemLink
3294 }
3295 ) }),
3296 columns.map((column) => {
3297 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3298 const field = fields.find((f2) => f2.id === column);
3299 const effectiveAlign = getEffectiveAlign(align, field?.type);
3300 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3301 "td",
3302 {
3303 style: {
3304 width,
3305 maxWidth,
3306 minWidth
3307 },
3308 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3309 TableColumnField,
3310 {
3311 fields,
3312 item,
3313 column,
3314 align: effectiveAlign
3315 }
3316 )
3317 },
3318 column
3319 );
3320 }),
3321 !!actions?.length && // Disable reason: we are not making the element interactive,
3322 // but preventing any click events from bubbling up to the
3323 // table row. This allows us to add a click handler to the row
3324 // itself (to toggle row selection) without erroneously
3325 // intercepting click events from ItemActions.
3326 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */
3327 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3328 "td",
3329 {
3330 className: clsx_default("dataviews-view-table__actions-column", {
3331 "dataviews-view-table__actions-column--sticky": true,
3332 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
3333 }),
3334 onClick: (e2) => e2.stopPropagation(),
3335 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ItemActions, { item, actions })
3336 }
3337 )
3338 ]
3339 }
3340 );
3341 }
3342 function ViewTable({
3343 actions,
3344 data,
3345 fields,
3346 getItemId,
3347 getItemLevel,
3348 isLoading = false,
3349 onChangeView,
3350 onChangeSelection,
3351 selection,
3352 setOpenedFilter,
3353 onClickItem,
3354 isItemClickable: isItemClickable2,
3355 renderItemLink,
3356 view,
3357 className,
3358 empty
3359 }) {
3360 const { containerRef } = (0, import_element11.useContext)(dataviews_context_default);
3361 const isDelayedLoading = useDelayedLoading(isLoading);
3362 const headerMenuRefs = (0, import_element11.useRef)(/* @__PURE__ */ new Map());
3363 const headerMenuToFocusRef = (0, import_element11.useRef)(void 0);
3364 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element11.useState)();
3365 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element11.useState)(null);
3366 (0, import_element11.useEffect)(() => {
3367 if (headerMenuToFocusRef.current) {
3368 headerMenuToFocusRef.current.focus();
3369 headerMenuToFocusRef.current = void 0;
3370 }
3371 });
3372 const tableNoticeId = (0, import_element11.useId)();
3373 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({
3374 scrollContainerRef: containerRef,
3375 enabled: !!actions?.length
3376 });
3377 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3378 if (nextHeaderMenuToFocus) {
3379 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
3380 setNextHeaderMenuToFocus(void 0);
3381 return;
3382 }
3383 const onHide = (field) => {
3384 const hidden = headerMenuRefs.current.get(field.id);
3385 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
3386 setNextHeaderMenuToFocus(fallback?.node);
3387 };
3388 const handleHeaderContextMenu = (event) => {
3389 event.preventDefault();
3390 event.stopPropagation();
3391 const virtualAnchor = {
3392 getBoundingClientRect: () => ({
3393 x: event.clientX,
3394 y: event.clientY,
3395 top: event.clientY,
3396 left: event.clientX,
3397 right: event.clientX,
3398 bottom: event.clientY,
3399 width: 0,
3400 height: 0,
3401 toJSON: () => ({})
3402 })
3403 };
3404 window.requestAnimationFrame(() => {
3405 setContextMenuAnchor(virtualAnchor);
3406 });
3407 };
3408 const hasData = !!data?.length;
3409 const titleField = fields.find((field) => field.id === view.titleField);
3410 const mediaField = fields.find((field) => field.id === view.mediaField);
3411 const descriptionField2 = fields.find(
3412 (field) => field.id === view.descriptionField
3413 );
3414 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
3415 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
3416 const { showTitle = true, showMedia = true, showDescription = true } = view;
3417 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
3418 const columns = view.fields ?? [];
3419 const headerMenuRef = (column, index) => (node) => {
3420 if (node) {
3421 headerMenuRefs.current.set(column, {
3422 node,
3423 fallback: columns[index > 0 ? index - 1 : 1]
3424 });
3425 } else {
3426 headerMenuRefs.current.delete(column);
3427 }
3428 };
3429 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
3430 const isRtl = (0, import_i18n15.isRTL)();
3431 if (!hasData) {
3432 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3433 "div",
3434 {
3435 className: clsx_default("dataviews-no-results", {
3436 "is-refreshing": isDelayedLoading
3437 }),
3438 id: tableNoticeId,
3439 children: empty
3440 }
3441 );
3442 }
3443 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3444 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3445 "table",
3446 {
3447 className: clsx_default("dataviews-view-table", className, {
3448 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
3449 view.layout.density
3450 ),
3451 "has-bulk-actions": hasBulkActions,
3452 "is-refreshing": !isInfiniteScroll && isDelayedLoading
3453 }),
3454 "aria-busy": isLoading,
3455 "aria-describedby": tableNoticeId,
3456 role: isInfiniteScroll ? "feed" : void 0,
3457 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
3458 children: [
3459 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("colgroup", { children: [
3460 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
3461 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
3462 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3463 "col",
3464 {
3465 className: clsx_default(
3466 `dataviews-view-table__col-${column}`,
3467 {
3468 "dataviews-view-table__col-first-expand": !hasPrimaryColumn && index === columns.length - 1
3469 }
3470 )
3471 },
3472 `col-${column}`
3473 )),
3474 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-actions" })
3475 ] }),
3476 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3477 import_components6.Popover,
3478 {
3479 anchor: contextMenuAnchor,
3480 onClose: () => setContextMenuAnchor(null),
3481 placement: "bottom-start",
3482 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(PropertiesSection, { showLabel: false })
3483 }
3484 ),
3485 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("tr", { className: "dataviews-view-table__row", children: [
3486 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3487 "th",
3488 {
3489 className: "dataviews-view-table__checkbox-column",
3490 scope: "col",
3491 onContextMenu: handleHeaderContextMenu,
3492 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3493 BulkSelectionCheckbox,
3494 {
3495 selection,
3496 onChangeSelection,
3497 data,
3498 actions,
3499 getItemId
3500 }
3501 )
3502 }
3503 ),
3504 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3505 column_header_menu_default,
3506 {
3507 ref: headerMenuRef(
3508 titleField.id,
3509 0
3510 ),
3511 fieldId: titleField.id,
3512 view,
3513 fields,
3514 onChangeView,
3515 onHide,
3516 setOpenedFilter,
3517 canMove: false,
3518 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
3519 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
3520 }
3521 ) }),
3522 columns.map((column, index) => {
3523 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3524 const field = fields.find(
3525 (f2) => f2.id === column
3526 );
3527 const effectiveAlign = getEffectiveAlign(
3528 align,
3529 field?.type
3530 );
3531 const canInsertOrMove = view.layout?.enableMoving ?? true;
3532 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3533 "th",
3534 {
3535 style: {
3536 width,
3537 maxWidth,
3538 minWidth,
3539 textAlign: effectiveAlign
3540 },
3541 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
3542 scope: "col",
3543 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3544 column_header_menu_default,
3545 {
3546 ref: headerMenuRef(column, index),
3547 fieldId: column,
3548 view,
3549 fields,
3550 onChangeView,
3551 onHide,
3552 setOpenedFilter,
3553 canMove: canInsertOrMove,
3554 canInsertLeft: canInsertOrMove,
3555 canInsertRight: canInsertOrMove
3556 }
3557 )
3558 },
3559 column
3560 );
3561 }),
3562 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3563 "th",
3564 {
3565 className: clsx_default(
3566 "dataviews-view-table__actions-column",
3567 {
3568 "dataviews-view-table__actions-column--sticky": true,
3569 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
3570 }
3571 ),
3572 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n15.__)("Actions") })
3573 }
3574 )
3575 ] }) }),
3576 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
3577 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("tbody", { children: [
3578 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3579 "td",
3580 {
3581 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
3582 className: "dataviews-view-table__group-header-cell",
3583 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
3584 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
3585 (0, import_i18n15.__)("%1$s: %2$s"),
3586 groupField.label,
3587 groupName
3588 )
3589 }
3590 ) }),
3591 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3592 TableRow,
3593 {
3594 item,
3595 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3596 hasBulkActions,
3597 actions,
3598 fields,
3599 id: getItemId(item) || index.toString(),
3600 view,
3601 titleField,
3602 mediaField,
3603 descriptionField: descriptionField2,
3604 selection,
3605 getItemId,
3606 onChangeSelection,
3607 onClickItem,
3608 renderItemLink,
3609 isItemClickable: isItemClickable2,
3610 isActionsColumnSticky: !isHorizontalScrollEnd
3611 },
3612 getItemId(item)
3613 ))
3614 ] }, `group-${groupName}`)
3615 ) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3616 TableRow,
3617 {
3618 item,
3619 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3620 hasBulkActions,
3621 actions,
3622 fields,
3623 id: getItemId(item) || index.toString(),
3624 view,
3625 titleField,
3626 mediaField,
3627 descriptionField: descriptionField2,
3628 selection,
3629 getItemId,
3630 onChangeSelection,
3631 onClickItem,
3632 renderItemLink,
3633 isItemClickable: isItemClickable2,
3634 isActionsColumnSticky: !isHorizontalScrollEnd,
3635 posinset: isInfiniteScroll ? index + 1 : void 0
3636 },
3637 getItemId(item)
3638 )) })
3639 ]
3640 }
3641 ),
3642 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components6.Spinner, {}) }) })
3643 ] });
3644 }
3645 var table_default = ViewTable;
3646
3647 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
3648 var import_components9 = __toESM(require_components(), 1);
3649 var import_i18n18 = __toESM(require_i18n(), 1);
3650
3651 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3652 var import_components8 = __toESM(require_components(), 1);
3653 var import_i18n17 = __toESM(require_i18n(), 1);
3654 var import_compose4 = __toESM(require_compose(), 1);
3655 var import_keycodes2 = __toESM(require_keycodes(), 1);
3656 var import_element13 = __toESM(require_element(), 1);
3657
3658 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
3659 var import_components7 = __toESM(require_components(), 1);
3660 var import_i18n16 = __toESM(require_i18n(), 1);
3661 var import_element12 = __toESM(require_element(), 1);
3662 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3663 var imageSizes = [
3664 {
3665 value: 120,
3666 breakpoint: 1
3667 },
3668 {
3669 value: 170,
3670 breakpoint: 1
3671 },
3672 {
3673 value: 230,
3674 breakpoint: 1
3675 },
3676 {
3677 value: 290,
3678 breakpoint: 1112
3679 // at minimum image width, 4 images display at this container size
3680 },
3681 {
3682 value: 350,
3683 breakpoint: 1636
3684 // at minimum image width, 6 images display at this container size
3685 },
3686 {
3687 value: 430,
3688 breakpoint: 588
3689 // at minimum image width, 2 images display at this container size
3690 }
3691 ];
3692 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
3693 function useGridColumns() {
3694 const context = (0, import_element12.useContext)(dataviews_context_default);
3695 const view = context.view;
3696 return (0, import_element12.useMemo)(() => {
3697 const containerWidth = context.containerWidth;
3698 const gap = 32;
3699 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
3700 const columns = Math.floor(
3701 (containerWidth + gap) / (previewSize + gap)
3702 );
3703 return Math.max(1, columns);
3704 }, [context.containerWidth, view.layout?.previewSize]);
3705 }
3706
3707 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3708 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3709 var { Badge } = unlock(import_components8.privateApis);
3710 function chunk(array, size) {
3711 const chunks = [];
3712 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
3713 chunks.push(array.slice(i2, i2 + size));
3714 }
3715 return chunks;
3716 }
3717 var GridItem = (0, import_element13.forwardRef)(function GridItem2({
3718 view,
3719 selection,
3720 onChangeSelection,
3721 onClickItem,
3722 isItemClickable: isItemClickable2,
3723 renderItemLink,
3724 getItemId,
3725 item,
3726 actions,
3727 mediaField,
3728 titleField,
3729 descriptionField: descriptionField2,
3730 regularFields,
3731 badgeFields,
3732 hasBulkActions,
3733 config,
3734 ...props
3735 }, ref) {
3736 const { showTitle = true, showMedia = true, showDescription = true } = view;
3737 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
3738 const id = getItemId(item);
3739 const instanceId = (0, import_compose4.useInstanceId)(GridItem2);
3740 const isSelected2 = selection.includes(id);
3741 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
3742 const rendersMediaField = showMedia && mediaField?.render;
3743 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3744 mediaField.render,
3745 {
3746 item,
3747 field: mediaField,
3748 config
3749 }
3750 ) : mediaPlaceholder;
3751 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(titleField.render, { item, field: titleField }) : null;
3752 let mediaA11yProps;
3753 let titleA11yProps;
3754 if (isItemClickable2(item) && onClickItem) {
3755 if (renderedTitleField) {
3756 mediaA11yProps = {
3757 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
3758 };
3759 titleA11yProps = {
3760 id: `dataviews-view-grid__title-field-${instanceId}`
3761 };
3762 } else {
3763 mediaA11yProps = {
3764 "aria-label": (0, import_i18n17.__)("Navigate to item")
3765 };
3766 }
3767 }
3768 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
3769 Stack,
3770 {
3771 direction: "column",
3772 ...props,
3773 ref,
3774 className: clsx_default(
3775 props.className,
3776 "dataviews-view-grid__row__gridcell",
3777 "dataviews-view-grid__card",
3778 {
3779 "is-selected": hasBulkAction && isSelected2
3780 }
3781 ),
3782 onClickCapture: (event) => {
3783 props.onClickCapture?.(event);
3784 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
3785 event.stopPropagation();
3786 event.preventDefault();
3787 if (!hasBulkAction) {
3788 return;
3789 }
3790 onChangeSelection(
3791 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3792 );
3793 }
3794 },
3795 children: [
3796 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3797 ItemClickWrapper,
3798 {
3799 item,
3800 isItemClickable: isItemClickable2,
3801 onClickItem,
3802 renderItemLink,
3803 className: clsx_default("dataviews-view-grid__media", {
3804 "dataviews-view-grid__media--placeholder": !rendersMediaField
3805 }),
3806 ...mediaA11yProps,
3807 children: renderedMediaField
3808 }
3809 ),
3810 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3811 DataViewsSelectionCheckbox,
3812 {
3813 item,
3814 selection,
3815 onChangeSelection,
3816 getItemId,
3817 titleField,
3818 disabled: !hasBulkAction
3819 }
3820 ),
3821 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ItemActions, { item, actions, isCompact: true }) }),
3822 showTitle && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3823 ItemClickWrapper,
3824 {
3825 item,
3826 isItemClickable: isItemClickable2,
3827 onClickItem,
3828 renderItemLink,
3829 className: "dataviews-view-grid__title-field dataviews-title-field",
3830 ...titleA11yProps,
3831 title: titleField?.getValueFormatted({
3832 item,
3833 field: titleField
3834 }) || void 0,
3835 children: renderedTitleField
3836 }
3837 ) }),
3838 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Stack, { direction: "column", gap: "xs", children: [
3839 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3840 descriptionField2.render,
3841 {
3842 item,
3843 field: descriptionField2
3844 }
3845 ),
3846 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3847 Stack,
3848 {
3849 direction: "row",
3850 className: "dataviews-view-grid__badge-fields",
3851 gap: "sm",
3852 wrap: "wrap",
3853 align: "top",
3854 justify: "flex-start",
3855 children: badgeFields.map((field) => {
3856 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3857 Badge,
3858 {
3859 className: "dataviews-view-grid__field-value",
3860 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3861 field.render,
3862 {
3863 item,
3864 field
3865 }
3866 )
3867 },
3868 field.id
3869 );
3870 })
3871 }
3872 ),
3873 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3874 Stack,
3875 {
3876 direction: "column",
3877 className: "dataviews-view-grid__fields",
3878 gap: "xs",
3879 children: regularFields.map((field) => {
3880 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3881 import_components8.Flex,
3882 {
3883 className: "dataviews-view-grid__field",
3884 gap: 1,
3885 justify: "flex-start",
3886 expanded: true,
3887 style: { height: "auto" },
3888 direction: "row",
3889 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
3890 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components8.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
3891 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3892 import_components8.FlexItem,
3893 {
3894 className: "dataviews-view-grid__field-value",
3895 style: { maxHeight: "none" },
3896 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3897 field.render,
3898 {
3899 item,
3900 field
3901 }
3902 )
3903 }
3904 )
3905 ] })
3906 },
3907 field.id
3908 );
3909 })
3910 }
3911 )
3912 ] })
3913 ]
3914 }
3915 );
3916 });
3917 function CompositeGrid({
3918 data,
3919 isInfiniteScroll,
3920 className,
3921 inert,
3922 isLoading,
3923 view,
3924 fields,
3925 selection,
3926 onChangeSelection,
3927 onClickItem,
3928 isItemClickable: isItemClickable2,
3929 renderItemLink,
3930 getItemId,
3931 actions
3932 }) {
3933 const { paginationInfo, resizeObserverRef } = (0, import_element13.useContext)(dataviews_context_default);
3934 const gridColumns = useGridColumns();
3935 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3936 const titleField = fields.find(
3937 (field) => field.id === view?.titleField
3938 );
3939 const mediaField = fields.find(
3940 (field) => field.id === view?.mediaField
3941 );
3942 const descriptionField2 = fields.find(
3943 (field) => field.id === view?.descriptionField
3944 );
3945 const otherFields = view.fields ?? [];
3946 const { regularFields, badgeFields } = otherFields.reduce(
3947 (accumulator, fieldId) => {
3948 const field = fields.find((f2) => f2.id === fieldId);
3949 if (!field) {
3950 return accumulator;
3951 }
3952 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
3953 accumulator[key].push(field);
3954 return accumulator;
3955 },
3956 { regularFields: [], badgeFields: [] }
3957 );
3958 const size = "900px";
3959 const totalRows = Math.ceil(data.length / gridColumns);
3960 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3961 import_components8.Composite,
3962 {
3963 role: isInfiniteScroll ? "feed" : "grid",
3964 className: clsx_default("dataviews-view-grid", className),
3965 focusWrap: true,
3966 "aria-busy": isLoading,
3967 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows,
3968 ref: resizeObserverRef,
3969 inert,
3970 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3971 import_components8.Composite.Row,
3972 {
3973 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3974 "div",
3975 {
3976 role: "row",
3977 "aria-rowindex": i2 + 1,
3978 "aria-label": (0, import_i18n17.sprintf)(
3979 /* translators: %d: The row number in the grid */
3980 (0, import_i18n17.__)("Row %d"),
3981 i2 + 1
3982 ),
3983 className: "dataviews-view-grid__row",
3984 style: {
3985 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
3986 }
3987 }
3988 ),
3989 children: row.map((item, indexInRow) => {
3990 const index = i2 * gridColumns + indexInRow;
3991 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3992 import_components8.Composite.Item,
3993 {
3994 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3995 GridItem,
3996 {
3997 ...props,
3998 role: isInfiniteScroll ? "article" : "gridcell",
3999 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0,
4000 "aria-posinset": isInfiniteScroll ? index + 1 : void 0,
4001 view,
4002 selection,
4003 onChangeSelection,
4004 onClickItem,
4005 isItemClickable: isItemClickable2,
4006 renderItemLink,
4007 getItemId,
4008 item,
4009 actions,
4010 mediaField,
4011 titleField,
4012 descriptionField: descriptionField2,
4013 regularFields,
4014 badgeFields,
4015 hasBulkActions,
4016 config: {
4017 sizes: size
4018 }
4019 }
4020 )
4021 },
4022 getItemId(item)
4023 );
4024 })
4025 },
4026 i2
4027 ))
4028 }
4029 );
4030 }
4031
4032 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
4033 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4034 function ViewGrid({
4035 actions,
4036 data,
4037 fields,
4038 getItemId,
4039 isLoading,
4040 onChangeSelection,
4041 onClickItem,
4042 isItemClickable: isItemClickable2,
4043 renderItemLink,
4044 selection,
4045 view,
4046 className,
4047 empty
4048 }) {
4049 const isDelayedLoading = useDelayedLoading(!!isLoading);
4050 const hasData = !!data?.length;
4051 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
4052 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
4053 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4054 if (!hasData) {
4055 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4056 "div",
4057 {
4058 className: clsx_default("dataviews-no-results", {
4059 "is-refreshing": isDelayedLoading
4060 }),
4061 children: empty
4062 }
4063 );
4064 }
4065 const gridProps = {
4066 className: clsx_default(className, {
4067 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4068 }),
4069 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4070 isLoading,
4071 view,
4072 fields,
4073 selection,
4074 onChangeSelection,
4075 onClickItem,
4076 isItemClickable: isItemClickable2,
4077 renderItemLink,
4078 getItemId,
4079 actions
4080 };
4081 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, {
4082 // Render multiple groups.
4083 children: [
4084 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
4085 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
4086 Stack,
4087 {
4088 direction: "column",
4089 gap: "sm",
4090 children: [
4091 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
4092 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4093 (0, import_i18n18.__)("%1$s: %2$s"),
4094 groupField.label,
4095 groupName
4096 ) }),
4097 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4098 CompositeGrid,
4099 {
4100 ...gridProps,
4101 data: groupItems,
4102 isInfiniteScroll: false
4103 }
4104 )
4105 ]
4106 },
4107 groupName
4108 )
4109 ) }),
4110 // Render a single grid with all data.
4111 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4112 CompositeGrid,
4113 {
4114 ...gridProps,
4115 data,
4116 isInfiniteScroll: !!isInfiniteScroll
4117 }
4118 ),
4119 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components9.Spinner, {}) })
4120 ]
4121 });
4122 }
4123 var grid_default = ViewGrid;
4124
4125 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
4126 var import_compose5 = __toESM(require_compose(), 1);
4127 var import_components10 = __toESM(require_components(), 1);
4128 var import_element14 = __toESM(require_element(), 1);
4129 var import_i18n19 = __toESM(require_i18n(), 1);
4130 var import_data3 = __toESM(require_data(), 1);
4131 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4132 var { Menu: Menu3 } = unlock(import_components10.privateApis);
4133 function generateItemWrapperCompositeId(idPrefix) {
4134 return `${idPrefix}-item-wrapper`;
4135 }
4136 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
4137 return `${idPrefix}-primary-action-${primaryActionId}`;
4138 }
4139 function generateDropdownTriggerCompositeId(idPrefix) {
4140 return `${idPrefix}-dropdown`;
4141 }
4142 function PrimaryActionGridCell({
4143 idPrefix,
4144 primaryAction,
4145 item
4146 }) {
4147 const registry = (0, import_data3.useRegistry)();
4148 const [isModalOpen, setIsModalOpen] = (0, import_element14.useState)(false);
4149 const compositeItemId = generatePrimaryActionCompositeId(
4150 idPrefix,
4151 primaryAction.id
4152 );
4153 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
4154 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4155 import_components10.Composite.Item,
4156 {
4157 id: compositeItemId,
4158 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4159 import_components10.Button,
4160 {
4161 disabled: !!primaryAction.disabled,
4162 accessibleWhenDisabled: true,
4163 text: label,
4164 size: "small",
4165 onClick: () => setIsModalOpen(true)
4166 }
4167 ),
4168 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4169 ActionModal,
4170 {
4171 action: primaryAction,
4172 items: [item],
4173 closeModal: () => setIsModalOpen(false)
4174 }
4175 )
4176 }
4177 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4178 import_components10.Composite.Item,
4179 {
4180 id: compositeItemId,
4181 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4182 import_components10.Button,
4183 {
4184 disabled: !!primaryAction.disabled,
4185 accessibleWhenDisabled: true,
4186 size: "small",
4187 onClick: () => {
4188 primaryAction.callback([item], { registry });
4189 },
4190 children: label
4191 }
4192 )
4193 }
4194 ) }, primaryAction.id);
4195 }
4196 function ListItem({
4197 view,
4198 actions,
4199 idPrefix,
4200 isSelected: isSelected2,
4201 item,
4202 titleField,
4203 mediaField,
4204 descriptionField: descriptionField2,
4205 onSelect,
4206 otherFields,
4207 onDropdownTriggerKeyDown,
4208 posinset
4209 }) {
4210 const {
4211 showTitle = true,
4212 showMedia = true,
4213 showDescription = true,
4214 infiniteScrollEnabled
4215 } = view;
4216 const itemRef = (0, import_element14.useRef)(null);
4217 const labelId = `${idPrefix}-label`;
4218 const descriptionId = `${idPrefix}-description`;
4219 const registry = (0, import_data3.useRegistry)();
4220 const [isHovered, setIsHovered] = (0, import_element14.useState)(false);
4221 const [activeModalAction, setActiveModalAction] = (0, import_element14.useState)(
4222 null
4223 );
4224 const handleHover = ({ type }) => {
4225 const isHover = type === "mouseenter";
4226 setIsHovered(isHover);
4227 };
4228 const { paginationInfo } = (0, import_element14.useContext)(dataviews_context_default);
4229 (0, import_element14.useEffect)(() => {
4230 if (isSelected2) {
4231 itemRef.current?.scrollIntoView({
4232 behavior: "auto",
4233 block: "nearest",
4234 inline: "nearest"
4235 });
4236 }
4237 }, [isSelected2]);
4238 const { primaryAction, eligibleActions } = (0, import_element14.useMemo)(() => {
4239 const _eligibleActions = actions.filter(
4240 (action) => !action.isEligible || action.isEligible(item)
4241 );
4242 const _primaryActions = _eligibleActions.filter(
4243 (action) => action.isPrimary
4244 );
4245 return {
4246 primaryAction: _primaryActions[0],
4247 eligibleActions: _eligibleActions
4248 };
4249 }, [actions, item]);
4250 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
4251 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4252 mediaField.render,
4253 {
4254 item,
4255 field: mediaField,
4256 config: { sizes: "52px" }
4257 }
4258 ) }) : null;
4259 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(titleField.render, { item, field: titleField }) : null;
4260 const renderDescription = showDescription && descriptionField2?.render;
4261 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
4262 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4263 Stack,
4264 {
4265 direction: "row",
4266 gap: "md",
4267 className: "dataviews-view-list__item-actions",
4268 children: [
4269 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4270 PrimaryActionGridCell,
4271 {
4272 idPrefix,
4273 primaryAction,
4274 item
4275 }
4276 ),
4277 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "gridcell", children: [
4278 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu3, { placement: "bottom-end", children: [
4279 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4280 Menu3.TriggerButton,
4281 {
4282 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4283 import_components10.Composite.Item,
4284 {
4285 id: generateDropdownTriggerCompositeId(
4286 idPrefix
4287 ),
4288 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4289 import_components10.Button,
4290 {
4291 size: "small",
4292 icon: more_vertical_default,
4293 label: (0, import_i18n19.__)("Actions"),
4294 accessibleWhenDisabled: true,
4295 disabled: !actions.length,
4296 onKeyDown: onDropdownTriggerKeyDown
4297 }
4298 )
4299 }
4300 )
4301 }
4302 ),
4303 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4304 ActionsMenuGroup,
4305 {
4306 actions: eligibleActions,
4307 item,
4308 registry,
4309 setActiveModalAction
4310 }
4311 ) })
4312 ] }),
4313 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4314 ActionModal,
4315 {
4316 action: activeModalAction,
4317 items: [item],
4318 closeModal: () => setActiveModalAction(null)
4319 }
4320 )
4321 ] })
4322 ]
4323 }
4324 );
4325 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4326 import_components10.Composite.Row,
4327 {
4328 ref: itemRef,
4329 render: (
4330 /* aria-posinset breaks Composite.Row if passed to it directly. */
4331 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4332 "div",
4333 {
4334 "aria-posinset": posinset,
4335 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
4336 }
4337 )
4338 ),
4339 role: infiniteScrollEnabled ? "article" : "row",
4340 className: clsx_default({
4341 "is-selected": isSelected2,
4342 "is-hovered": isHovered
4343 }),
4344 onMouseEnter: handleHover,
4345 onMouseLeave: handleHover,
4346 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4347 Stack,
4348 {
4349 direction: "row",
4350 className: "dataviews-view-list__item-wrapper",
4351 children: [
4352 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4353 import_components10.Composite.Item,
4354 {
4355 id: generateItemWrapperCompositeId(idPrefix),
4356 "aria-pressed": isSelected2,
4357 "aria-labelledby": labelId,
4358 "aria-describedby": descriptionId,
4359 className: "dataviews-view-list__item",
4360 onClick: () => onSelect(item)
4361 }
4362 ) }),
4363 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4364 Stack,
4365 {
4366 direction: "row",
4367 gap: "md",
4368 justify: "start",
4369 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
4370 style: { flex: 1, minWidth: 0 },
4371 children: [
4372 renderedMediaField,
4373 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4374 Stack,
4375 {
4376 direction: "column",
4377 gap: "xs",
4378 className: "dataviews-view-list__field-wrapper",
4379 children: [
4380 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", align: "center", children: [
4381 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4382 "div",
4383 {
4384 className: "dataviews-title-field dataviews-view-list__title-field",
4385 id: labelId,
4386 children: renderedTitleField
4387 }
4388 ),
4389 usedActions
4390 ] }),
4391 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4392 descriptionField2.render,
4393 {
4394 item,
4395 field: descriptionField2
4396 }
4397 ) }),
4398 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4399 "div",
4400 {
4401 className: "dataviews-view-list__fields",
4402 id: descriptionId,
4403 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4404 "div",
4405 {
4406 className: "dataviews-view-list__field",
4407 children: [
4408 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4409 import_components10.VisuallyHidden,
4410 {
4411 as: "span",
4412 className: "dataviews-view-list__field-label",
4413 children: field.label
4414 }
4415 ),
4416 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4417 field.render,
4418 {
4419 item,
4420 field
4421 }
4422 ) })
4423 ]
4424 },
4425 field.id
4426 ))
4427 }
4428 )
4429 ]
4430 }
4431 )
4432 ]
4433 }
4434 )
4435 ]
4436 }
4437 )
4438 }
4439 );
4440 }
4441 function isDefined2(item) {
4442 return !!item;
4443 }
4444 function ViewList(props) {
4445 const {
4446 actions,
4447 data,
4448 fields,
4449 getItemId,
4450 isLoading,
4451 onChangeSelection,
4452 selection,
4453 view,
4454 className,
4455 empty
4456 } = props;
4457 const baseId = (0, import_compose5.useInstanceId)(ViewList, "view-list");
4458 const isDelayedLoading = useDelayedLoading(!!isLoading);
4459 const selectedItem = data?.findLast(
4460 (item) => selection.includes(getItemId(item))
4461 );
4462 const titleField = fields.find((field) => field.id === view.titleField);
4463 const mediaField = fields.find((field) => field.id === view.mediaField);
4464 const descriptionField2 = fields.find(
4465 (field) => field.id === view.descriptionField
4466 );
4467 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
4468 const onSelect = (item) => onChangeSelection([getItemId(item)]);
4469 const generateCompositeItemIdPrefix = (0, import_element14.useCallback)(
4470 (item) => `${baseId}-${getItemId(item)}`,
4471 [baseId, getItemId]
4472 );
4473 const isActiveCompositeItem = (0, import_element14.useCallback)(
4474 (item, idToCheck) => {
4475 return idToCheck.startsWith(
4476 generateCompositeItemIdPrefix(item)
4477 );
4478 },
4479 [generateCompositeItemIdPrefix]
4480 );
4481 const [activeCompositeId, setActiveCompositeId] = (0, import_element14.useState)(void 0);
4482 const compositeRef = (0, import_element14.useRef)(null);
4483 (0, import_element14.useEffect)(() => {
4484 if (selectedItem) {
4485 setActiveCompositeId(
4486 generateItemWrapperCompositeId(
4487 generateCompositeItemIdPrefix(selectedItem)
4488 )
4489 );
4490 }
4491 }, [selectedItem, generateCompositeItemIdPrefix]);
4492 const activeItemIndex = data.findIndex(
4493 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
4494 );
4495 const previousActiveItemIndex = (0, import_compose5.usePrevious)(activeItemIndex);
4496 const isActiveIdInList = activeItemIndex !== -1;
4497 const selectCompositeItem = (0, import_element14.useCallback)(
4498 (targetIndex, generateCompositeId) => {
4499 const clampedIndex = Math.min(
4500 data.length - 1,
4501 Math.max(0, targetIndex)
4502 );
4503 if (!data[clampedIndex]) {
4504 return;
4505 }
4506 const itemIdPrefix = generateCompositeItemIdPrefix(
4507 data[clampedIndex]
4508 );
4509 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
4510 setActiveCompositeId(targetCompositeItemId);
4511 if (compositeRef.current?.contains(
4512 compositeRef.current.ownerDocument.activeElement
4513 )) {
4514 document.getElementById(targetCompositeItemId)?.focus();
4515 }
4516 },
4517 [data, generateCompositeItemIdPrefix]
4518 );
4519 (0, import_element14.useEffect)(() => {
4520 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
4521 if (!isActiveIdInList && wasActiveIdInList) {
4522 selectCompositeItem(
4523 previousActiveItemIndex,
4524 generateItemWrapperCompositeId
4525 );
4526 }
4527 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
4528 const onDropdownTriggerKeyDown = (0, import_element14.useCallback)(
4529 (event) => {
4530 if (event.key === "ArrowDown") {
4531 event.preventDefault();
4532 selectCompositeItem(
4533 activeItemIndex + 1,
4534 generateDropdownTriggerCompositeId
4535 );
4536 }
4537 if (event.key === "ArrowUp") {
4538 event.preventDefault();
4539 selectCompositeItem(
4540 activeItemIndex - 1,
4541 generateDropdownTriggerCompositeId
4542 );
4543 }
4544 },
4545 [selectCompositeItem, activeItemIndex]
4546 );
4547 const hasData = !!data?.length;
4548 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4549 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4550 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4551 if (!hasData) {
4552 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4553 "div",
4554 {
4555 className: clsx_default("dataviews-no-results", {
4556 "is-refreshing": isDelayedLoading
4557 }),
4558 children: empty
4559 }
4560 );
4561 }
4562 if (hasData && groupField && dataByGroup) {
4563 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4564 import_components10.Composite,
4565 {
4566 ref: compositeRef,
4567 id: `${baseId}`,
4568 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", {}),
4569 className: "dataviews-view-list__group",
4570 role: "grid",
4571 activeId: activeCompositeId,
4572 setActiveId: setActiveCompositeId,
4573 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4574 Stack,
4575 {
4576 direction: "column",
4577 gap: "lg",
4578 className: clsx_default("dataviews-view-list", className),
4579 children: Array.from(dataByGroup.entries()).map(
4580 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4581 Stack,
4582 {
4583 direction: "column",
4584 gap: "sm",
4585 children: [
4586 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
4587 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4588 (0, import_i18n19.__)("%1$s: %2$s"),
4589 groupField.label,
4590 groupName
4591 ) }),
4592 groupItems.map((item) => {
4593 const id = generateCompositeItemIdPrefix(item);
4594 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4595 ListItem,
4596 {
4597 view,
4598 idPrefix: id,
4599 actions,
4600 item,
4601 isSelected: item === selectedItem,
4602 onSelect,
4603 mediaField,
4604 titleField,
4605 descriptionField: descriptionField2,
4606 otherFields,
4607 onDropdownTriggerKeyDown
4608 },
4609 id
4610 );
4611 })
4612 ]
4613 },
4614 groupName
4615 )
4616 )
4617 }
4618 )
4619 }
4620 );
4621 }
4622 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
4623 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4624 import_components10.Composite,
4625 {
4626 ref: compositeRef,
4627 id: baseId,
4628 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", {}),
4629 className: clsx_default("dataviews-view-list", className, {
4630 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4631 view.layout.density
4632 ),
4633 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4634 }),
4635 role: view.infiniteScrollEnabled ? "feed" : "grid",
4636 activeId: activeCompositeId,
4637 setActiveId: setActiveCompositeId,
4638 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4639 children: data.map((item, index) => {
4640 const id = generateCompositeItemIdPrefix(item);
4641 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4642 ListItem,
4643 {
4644 view,
4645 idPrefix: id,
4646 actions,
4647 item,
4648 isSelected: item === selectedItem,
4649 onSelect,
4650 mediaField,
4651 titleField,
4652 descriptionField: descriptionField2,
4653 otherFields,
4654 onDropdownTriggerKeyDown,
4655 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
4656 },
4657 id
4658 );
4659 })
4660 }
4661 ),
4662 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_components10.Spinner, {}) })
4663 ] });
4664 }
4665
4666 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
4667 var import_components12 = __toESM(require_components(), 1);
4668
4669 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
4670 var import_i18n20 = __toESM(require_i18n(), 1);
4671 var import_element15 = __toESM(require_element(), 1);
4672 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4673 function ActivityGroup({
4674 groupName,
4675 groupData,
4676 groupField,
4677 showLabel = true,
4678 children
4679 }) {
4680 const groupHeader = showLabel ? (0, import_element15.createInterpolateElement)(
4681 // translators: %s: The label of the field e.g. "Status".
4682 (0, import_i18n20.sprintf)((0, import_i18n20.__)("%s: <groupName />"), groupField.label).trim(),
4683 {
4684 groupName: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4685 groupField.render,
4686 {
4687 item: groupData[0],
4688 field: groupField
4689 }
4690 )
4691 }
4692 ) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(groupField.render, { item: groupData[0], field: groupField });
4693 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
4694 Stack,
4695 {
4696 direction: "column",
4697 className: "dataviews-view-activity__group",
4698 children: [
4699 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
4700 children
4701 ]
4702 },
4703 groupName
4704 );
4705 }
4706
4707 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
4708 var import_components11 = __toESM(require_components(), 1);
4709 var import_element16 = __toESM(require_element(), 1);
4710 var import_data4 = __toESM(require_data(), 1);
4711 var import_compose6 = __toESM(require_compose(), 1);
4712 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4713 function ActivityItem(props) {
4714 const {
4715 view,
4716 actions,
4717 item,
4718 titleField,
4719 mediaField,
4720 descriptionField: descriptionField2,
4721 otherFields,
4722 posinset,
4723 onClickItem,
4724 renderItemLink,
4725 isItemClickable: isItemClickable2
4726 } = props;
4727 const {
4728 showTitle = true,
4729 showMedia = true,
4730 showDescription = true,
4731 infiniteScrollEnabled
4732 } = view;
4733 const itemRef = (0, import_element16.useRef)(null);
4734 const registry = (0, import_data4.useRegistry)();
4735 const { paginationInfo } = (0, import_element16.useContext)(dataviews_context_default);
4736 const { primaryActions, eligibleActions } = (0, import_element16.useMemo)(() => {
4737 const _eligibleActions = actions.filter(
4738 (action) => !action.isEligible || action.isEligible(item)
4739 );
4740 const _primaryActions = _eligibleActions.filter(
4741 (action) => action.isPrimary
4742 );
4743 return {
4744 primaryActions: _primaryActions,
4745 eligibleActions: _eligibleActions
4746 };
4747 }, [actions, item]);
4748 const isMobileViewport = (0, import_compose6.useViewportMatch)("medium", "<");
4749 const density = view.layout?.density ?? "balanced";
4750 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4751 mediaField.render,
4752 {
4753 item,
4754 field: mediaField,
4755 config: {
4756 sizes: density === "comfortable" ? "32px" : "24px"
4757 }
4758 }
4759 ) : null;
4760 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4761 "span",
4762 {
4763 className: "dataviews-view-activity__item-bullet",
4764 "aria-hidden": "true"
4765 }
4766 ) });
4767 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(titleField.render, { item, field: titleField }) : null;
4768 const verticalGap = (0, import_element16.useMemo)(() => {
4769 switch (density) {
4770 case "comfortable":
4771 return "md";
4772 default:
4773 return "sm";
4774 }
4775 }, [density]);
4776 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4777 "div",
4778 {
4779 ref: itemRef,
4780 role: infiniteScrollEnabled ? "article" : void 0,
4781 "aria-posinset": posinset,
4782 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
4783 className: clsx_default(
4784 "dataviews-view-activity__item",
4785 density === "compact" && "is-compact",
4786 density === "balanced" && "is-balanced",
4787 density === "comfortable" && "is-comfortable"
4788 ),
4789 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
4790 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4791 Stack,
4792 {
4793 direction: "column",
4794 gap: "xs",
4795 align: "center",
4796 className: "dataviews-view-activity__item-type",
4797 children: renderedMediaField
4798 }
4799 ),
4800 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
4801 Stack,
4802 {
4803 direction: "column",
4804 gap: verticalGap,
4805 align: "flex-start",
4806 className: "dataviews-view-activity__item-content",
4807 children: [
4808 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4809 ItemClickWrapper,
4810 {
4811 item,
4812 isItemClickable: isItemClickable2,
4813 onClickItem,
4814 renderItemLink,
4815 className: "dataviews-view-activity__item-title",
4816 children: renderedTitleField
4817 }
4818 ),
4819 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4820 descriptionField2.render,
4821 {
4822 item,
4823 field: descriptionField2
4824 }
4825 ) }),
4826 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
4827 "div",
4828 {
4829 className: "dataviews-view-activity__item-field",
4830 children: [
4831 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4832 import_components11.VisuallyHidden,
4833 {
4834 as: "span",
4835 className: "dataviews-view-activity__item-field-label",
4836 children: field.label
4837 }
4838 ),
4839 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4840 field.render,
4841 {
4842 item,
4843 field
4844 }
4845 ) })
4846 ]
4847 },
4848 field.id
4849 )) }),
4850 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4851 PrimaryActions,
4852 {
4853 item,
4854 actions: primaryActions,
4855 registry,
4856 buttonVariant: "secondary"
4857 }
4858 )
4859 ]
4860 }
4861 ),
4862 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
4863 // there if there are any actions at all.
4864 isMobileViewport && // At the same time, only show the menu if there are actions to show.
4865 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4866 ItemActions,
4867 {
4868 item,
4869 actions: eligibleActions,
4870 isCompact: true
4871 }
4872 ) })
4873 ] })
4874 }
4875 );
4876 }
4877 var activity_item_default = ActivityItem;
4878
4879 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
4880 var import_react3 = __toESM(require_react(), 1);
4881 function isDefined3(item) {
4882 return !!item;
4883 }
4884 function ActivityItems(props) {
4885 const { data, fields, getItemId, view } = props;
4886 const titleField = fields.find((field) => field.id === view.titleField);
4887 const mediaField = fields.find((field) => field.id === view.mediaField);
4888 const descriptionField2 = fields.find(
4889 (field) => field.id === view.descriptionField
4890 );
4891 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
4892 return data.map((item, index) => {
4893 return /* @__PURE__ */ (0, import_react3.createElement)(
4894 activity_item_default,
4895 {
4896 ...props,
4897 key: getItemId(item),
4898 item,
4899 mediaField,
4900 titleField,
4901 descriptionField: descriptionField2,
4902 otherFields,
4903 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
4904 }
4905 );
4906 });
4907 }
4908
4909 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
4910 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4911 function ViewActivity(props) {
4912 const { empty, data, fields, isLoading, view, className } = props;
4913 const isDelayedLoading = useDelayedLoading(!!isLoading);
4914 const hasData = !!data?.length;
4915 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4916 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4917 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4918 if (!hasData) {
4919 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4920 "div",
4921 {
4922 className: clsx_default("dataviews-no-results", {
4923 "is-refreshing": isDelayedLoading
4924 }),
4925 children: empty
4926 }
4927 );
4928 }
4929 const isInert = !isInfiniteScroll && !!isLoading;
4930 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
4931 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4932 });
4933 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
4934 if (hasData && groupField && dataByGroup) {
4935 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4936 Stack,
4937 {
4938 direction: "column",
4939 gap: "sm",
4940 className: wrapperClassName,
4941 inert: isInert ? "true" : void 0,
4942 children: groupedEntries.map(
4943 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4944 ActivityGroup,
4945 {
4946 groupName,
4947 groupData,
4948 groupField,
4949 showLabel: view.groupBy?.showLabel !== false,
4950 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4951 ActivityItems,
4952 {
4953 ...props,
4954 data: groupData
4955 }
4956 )
4957 },
4958 groupName
4959 )
4960 )
4961 }
4962 );
4963 }
4964 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4965 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4966 "div",
4967 {
4968 className: wrapperClassName,
4969 role: view.infiniteScrollEnabled ? "feed" : void 0,
4970 inert: isInert ? "true" : void 0,
4971 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ActivityItems, { ...props })
4972 }
4973 ),
4974 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components12.Spinner, {}) })
4975 ] });
4976 }
4977
4978 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
4979 var import_components15 = __toESM(require_components(), 1);
4980 var import_i18n23 = __toESM(require_i18n(), 1);
4981 var import_compose7 = __toESM(require_compose(), 1);
4982 var import_element20 = __toESM(require_element(), 1);
4983
4984 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
4985 var import_components14 = __toESM(require_components(), 1);
4986 var import_data5 = __toESM(require_data(), 1);
4987 var import_element18 = __toESM(require_element(), 1);
4988 var import_i18n22 = __toESM(require_i18n(), 1);
4989
4990 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
4991 var import_components13 = __toESM(require_components(), 1);
4992 var import_element17 = __toESM(require_element(), 1);
4993 var import_i18n21 = __toESM(require_i18n(), 1);
4994 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4995 function DataViewsPagination() {
4996 const {
4997 view,
4998 onChangeView,
4999 paginationInfo: { totalItems = 0, totalPages }
5000 } = (0, import_element17.useContext)(dataviews_context_default);
5001 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
5002 return null;
5003 }
5004 const currentPage = view.page ?? 1;
5005 const pageSelectOptions = Array.from(Array(totalPages)).map(
5006 (_, i2) => {
5007 const page = i2 + 1;
5008 return {
5009 value: page.toString(),
5010 label: page.toString(),
5011 "aria-label": currentPage === page ? (0, import_i18n21.sprintf)(
5012 // translators: 1: current page number. 2: total number of pages.
5013 (0, import_i18n21.__)("Page %1$d of %2$d"),
5014 currentPage,
5015 totalPages
5016 ) : page.toString()
5017 };
5018 }
5019 );
5020 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5021 Stack,
5022 {
5023 direction: "row",
5024 className: "dataviews-pagination",
5025 justify: "end",
5026 align: "center",
5027 gap: "xl",
5028 children: [
5029 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5030 Stack,
5031 {
5032 direction: "row",
5033 justify: "flex-start",
5034 align: "center",
5035 gap: "xs",
5036 className: "dataviews-pagination__page-select",
5037 children: (0, import_element17.createInterpolateElement)(
5038 (0, import_i18n21.sprintf)(
5039 // translators: 1: Current page number, 2: Total number of pages.
5040 (0, import_i18n21._x)(
5041 "<div>Page</div>%1$s<div>of %2$d</div>",
5042 "paging"
5043 ),
5044 "<CurrentPage />",
5045 totalPages
5046 ),
5047 {
5048 div: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { "aria-hidden": true }),
5049 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5050 import_components13.SelectControl,
5051 {
5052 "aria-label": (0, import_i18n21.__)("Current page"),
5053 value: currentPage.toString(),
5054 options: pageSelectOptions,
5055 onChange: (newValue) => {
5056 onChangeView({
5057 ...view,
5058 page: +newValue
5059 });
5060 },
5061 size: "small",
5062 variant: "minimal"
5063 }
5064 )
5065 }
5066 )
5067 }
5068 ),
5069 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
5070 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5071 import_components13.Button,
5072 {
5073 onClick: () => onChangeView({
5074 ...view,
5075 page: currentPage - 1
5076 }),
5077 disabled: currentPage === 1,
5078 accessibleWhenDisabled: true,
5079 label: (0, import_i18n21.__)("Previous page"),
5080 icon: (0, import_i18n21.isRTL)() ? next_default : previous_default,
5081 showTooltip: true,
5082 size: "compact",
5083 tooltipPosition: "top"
5084 }
5085 ),
5086 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5087 import_components13.Button,
5088 {
5089 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
5090 disabled: currentPage >= totalPages,
5091 accessibleWhenDisabled: true,
5092 label: (0, import_i18n21.__)("Next page"),
5093 icon: (0, import_i18n21.isRTL)() ? previous_default : next_default,
5094 showTooltip: true,
5095 size: "compact",
5096 tooltipPosition: "top"
5097 }
5098 )
5099 ] })
5100 ]
5101 }
5102 );
5103 }
5104 var dataviews_pagination_default = (0, import_element17.memo)(DataViewsPagination);
5105
5106 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5107 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
5108 var EMPTY_ARRAY2 = [];
5109 function useIsMultiselectPicker(actions) {
5110 return (0, import_element18.useMemo)(() => {
5111 return actions?.every((action) => action.supportsBulk);
5112 }, [actions]);
5113 }
5114 function BulkSelectionCheckbox2({
5115 selection,
5116 selectedItems,
5117 onChangeSelection,
5118 data,
5119 getItemId
5120 }) {
5121 const areAllSelected = selectedItems.length === data.length;
5122 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5123 import_components14.CheckboxControl,
5124 {
5125 className: "dataviews-view-table-selection-checkbox",
5126 checked: areAllSelected,
5127 indeterminate: !areAllSelected && !!selectedItems.length,
5128 onChange: () => {
5129 if (areAllSelected) {
5130 onChangeSelection(
5131 selection.filter(
5132 (id) => !data.some(
5133 (item) => id === getItemId(item)
5134 )
5135 )
5136 );
5137 } else {
5138 const selectionSet = /* @__PURE__ */ new Set([
5139 ...selection,
5140 ...data.map((item) => getItemId(item))
5141 ]);
5142 onChangeSelection(Array.from(selectionSet));
5143 }
5144 },
5145 "aria-label": areAllSelected ? (0, import_i18n22.__)("Deselect all") : (0, import_i18n22.__)("Select all")
5146 }
5147 );
5148 }
5149 function ActionButtons({
5150 actions,
5151 items,
5152 selection
5153 }) {
5154 const registry = (0, import_data5.useRegistry)();
5155 const [actionInProgress, setActionInProgress] = (0, import_element18.useState)(
5156 null
5157 );
5158 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
5159 if (!("callback" in action)) {
5160 return null;
5161 }
5162 const { id, label, icon, isPrimary, callback } = action;
5163 const _label = typeof label === "string" ? label : label(items);
5164 const variant = isPrimary ? "primary" : "tertiary";
5165 const isInProgress = id === actionInProgress;
5166 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5167 import_components14.Button,
5168 {
5169 accessibleWhenDisabled: true,
5170 icon,
5171 disabled: isInProgress || !selection?.length,
5172 isBusy: isInProgress,
5173 onClick: async () => {
5174 setActionInProgress(id);
5175 await callback(items, {
5176 registry
5177 });
5178 setActionInProgress(null);
5179 },
5180 size: "compact",
5181 variant,
5182 children: _label
5183 },
5184 id
5185 );
5186 }) });
5187 }
5188 function DataViewsPickerFooter() {
5189 const {
5190 data,
5191 selection,
5192 onChangeSelection,
5193 getItemId,
5194 actions = EMPTY_ARRAY2,
5195 paginationInfo
5196 } = (0, import_element18.useContext)(dataviews_context_default);
5197 const isMultiselect = useIsMultiselectPicker(actions);
5198 const message2 = getFooterMessage(
5199 selection.length,
5200 data.length,
5201 paginationInfo.totalItems
5202 );
5203 const selectedItems = (0, import_element18.useMemo)(
5204 () => data.filter((item) => selection.includes(getItemId(item))),
5205 [selection, getItemId, data]
5206 );
5207 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5208 Stack,
5209 {
5210 direction: "row",
5211 justify: "space-between",
5212 align: "center",
5213 className: "dataviews-footer",
5214 gap: "sm",
5215 children: [
5216 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5217 Stack,
5218 {
5219 direction: "row",
5220 className: "dataviews-picker-footer__bulk-selection",
5221 gap: "md",
5222 align: "center",
5223 children: [
5224 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5225 BulkSelectionCheckbox2,
5226 {
5227 selection,
5228 selectedItems,
5229 onChangeSelection,
5230 data,
5231 getItemId
5232 }
5233 ),
5234 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
5235 ]
5236 }
5237 ),
5238 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(dataviews_pagination_default, {}),
5239 Boolean(actions?.length) && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5240 ActionButtons,
5241 {
5242 actions,
5243 items: selectedItems,
5244 selection
5245 }
5246 ) })
5247 ]
5248 }
5249 );
5250 }
5251
5252 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
5253 var import_element19 = __toESM(require_element(), 1);
5254 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
5255 var GridItems = (0, import_element19.forwardRef)(({ className, previewSize, ...props }, ref) => {
5256 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
5257 "div",
5258 {
5259 ref,
5260 className: clsx_default("dataviews-view-grid-items", className),
5261 style: {
5262 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
5263 },
5264 ...props
5265 }
5266 );
5267 });
5268
5269 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5270 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
5271 var { Badge: Badge2 } = unlock(import_components15.privateApis);
5272 function GridItem3({
5273 view,
5274 multiselect,
5275 selection,
5276 onChangeSelection,
5277 getItemId,
5278 item,
5279 mediaField,
5280 titleField,
5281 descriptionField: descriptionField2,
5282 regularFields,
5283 badgeFields,
5284 config,
5285 posinset,
5286 setsize
5287 }) {
5288 const { showTitle = true, showMedia = true, showDescription = true } = view;
5289 const id = getItemId(item);
5290 const isSelected2 = selection.includes(id);
5291 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5292 mediaField.render,
5293 {
5294 item,
5295 field: mediaField,
5296 config
5297 }
5298 ) : null;
5299 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(titleField.render, { item, field: titleField }) : null;
5300 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5301 import_components15.Composite.Item,
5302 {
5303 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n23.__)("(no title)") : void 0,
5304 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Stack, { direction: "column", children, ...props }),
5305 role: "option",
5306 "aria-posinset": posinset,
5307 "aria-setsize": setsize,
5308 className: clsx_default("dataviews-view-picker-grid__card", {
5309 "is-selected": isSelected2
5310 }),
5311 "aria-selected": isSelected2,
5312 onClick: () => {
5313 if (isSelected2) {
5314 onChangeSelection(
5315 selection.filter((itemId) => id !== itemId)
5316 );
5317 } else {
5318 const newSelection = multiselect ? [...selection, id] : [id];
5319 onChangeSelection(newSelection);
5320 }
5321 },
5322 children: [
5323 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
5324 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5325 DataViewsSelectionCheckbox,
5326 {
5327 item,
5328 selection,
5329 onChangeSelection,
5330 getItemId,
5331 titleField,
5332 disabled: false,
5333 "aria-hidden": true,
5334 tabIndex: -1
5335 }
5336 ),
5337 showTitle && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5338 Stack,
5339 {
5340 direction: "row",
5341 justify: "space-between",
5342 className: "dataviews-view-picker-grid__title-actions",
5343 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
5344 }
5345 ),
5346 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5347 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5348 descriptionField2.render,
5349 {
5350 item,
5351 field: descriptionField2
5352 }
5353 ),
5354 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5355 Stack,
5356 {
5357 direction: "row",
5358 className: "dataviews-view-picker-grid__badge-fields",
5359 gap: "sm",
5360 wrap: "wrap",
5361 align: "top",
5362 justify: "flex-start",
5363 children: badgeFields.map((field) => {
5364 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5365 Badge2,
5366 {
5367 className: "dataviews-view-picker-grid__field-value",
5368 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5369 field.render,
5370 {
5371 item,
5372 field
5373 }
5374 )
5375 },
5376 field.id
5377 );
5378 })
5379 }
5380 ),
5381 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5382 Stack,
5383 {
5384 direction: "column",
5385 className: "dataviews-view-picker-grid__fields",
5386 gap: "xs",
5387 children: regularFields.map((field) => {
5388 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5389 import_components15.Flex,
5390 {
5391 className: "dataviews-view-picker-grid__field",
5392 gap: 1,
5393 justify: "flex-start",
5394 expanded: true,
5395 style: { height: "auto" },
5396 direction: "row",
5397 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
5398 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
5399 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5400 import_components15.FlexItem,
5401 {
5402 className: "dataviews-view-picker-grid__field-value",
5403 style: { maxHeight: "none" },
5404 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5405 field.render,
5406 {
5407 item,
5408 field
5409 }
5410 )
5411 }
5412 )
5413 ] })
5414 },
5415 field.id
5416 );
5417 })
5418 }
5419 )
5420 ] })
5421 ]
5422 },
5423 id
5424 );
5425 }
5426 function GridGroup({
5427 groupName,
5428 groupField,
5429 showLabel = true,
5430 children
5431 }) {
5432 const headerId = (0, import_compose7.useInstanceId)(
5433 GridGroup,
5434 "dataviews-view-picker-grid-group__header"
5435 );
5436 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5437 Stack,
5438 {
5439 direction: "column",
5440 gap: "sm",
5441 role: "group",
5442 "aria-labelledby": headerId,
5443 children: [
5444 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5445 "h3",
5446 {
5447 className: "dataviews-view-picker-grid-group__header",
5448 id: headerId,
5449 children: showLabel ? (0, import_i18n23.sprintf)(
5450 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5451 (0, import_i18n23.__)("%1$s: %2$s"),
5452 groupField.label,
5453 groupName
5454 ) : groupName
5455 }
5456 ),
5457 children
5458 ]
5459 },
5460 groupName
5461 );
5462 }
5463 function ViewPickerGrid({
5464 actions,
5465 data,
5466 fields,
5467 getItemId,
5468 isLoading,
5469 onChangeSelection,
5470 selection,
5471 view,
5472 className,
5473 empty
5474 }) {
5475 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element20.useContext)(dataviews_context_default);
5476 const titleField = fields.find(
5477 (field) => field.id === view?.titleField
5478 );
5479 const mediaField = fields.find(
5480 (field) => field.id === view?.mediaField
5481 );
5482 const descriptionField2 = fields.find(
5483 (field) => field.id === view?.descriptionField
5484 );
5485 const otherFields = view.fields ?? [];
5486 const { regularFields, badgeFields } = otherFields.reduce(
5487 (accumulator, fieldId) => {
5488 const field = fields.find((f2) => f2.id === fieldId);
5489 if (!field) {
5490 return accumulator;
5491 }
5492 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5493 accumulator[key].push(field);
5494 return accumulator;
5495 },
5496 { regularFields: [], badgeFields: [] }
5497 );
5498 const hasData = !!data?.length;
5499 const usedPreviewSize = view.layout?.previewSize;
5500 const isMultiselect = useIsMultiselectPicker(actions);
5501 const size = "900px";
5502 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5503 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5504 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5505 const currentPage = view?.page ?? 1;
5506 const perPage = view?.perPage ?? 0;
5507 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
5508 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, {
5509 // Render multiple groups.
5510 children: [
5511 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5512 import_components15.Composite,
5513 {
5514 virtualFocus: true,
5515 orientation: "horizontal",
5516 role: "listbox",
5517 "aria-multiselectable": isMultiselect,
5518 className: clsx_default(
5519 "dataviews-view-picker-grid",
5520 className
5521 ),
5522 "aria-label": itemListLabel,
5523 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5524 Stack,
5525 {
5526 direction: "column",
5527 gap: "lg",
5528 children,
5529 ...props
5530 }
5531 ),
5532 children: Array.from(dataByGroup.entries()).map(
5533 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5534 GridGroup,
5535 {
5536 groupName,
5537 groupField,
5538 showLabel: view.groupBy?.showLabel !== false,
5539 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5540 GridItems,
5541 {
5542 previewSize: usedPreviewSize,
5543 style: {
5544 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
5545 },
5546 "aria-busy": isLoading,
5547 ref: resizeObserverRef,
5548 children: groupItems.map((item) => {
5549 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1;
5550 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5551 GridItem3,
5552 {
5553 view,
5554 multiselect: isMultiselect,
5555 selection,
5556 onChangeSelection,
5557 getItemId,
5558 item,
5559 mediaField,
5560 titleField,
5561 descriptionField: descriptionField2,
5562 regularFields,
5563 badgeFields,
5564 config: {
5565 sizes: size
5566 },
5567 posinset: posInSet,
5568 setsize: setSize
5569 },
5570 getItemId(item)
5571 );
5572 })
5573 }
5574 )
5575 },
5576 groupName
5577 )
5578 )
5579 }
5580 ),
5581 // Render a single grid with all data.
5582 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5583 import_components15.Composite,
5584 {
5585 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5586 GridItems,
5587 {
5588 className: clsx_default(
5589 "dataviews-view-picker-grid",
5590 className
5591 ),
5592 previewSize: usedPreviewSize,
5593 "aria-busy": isLoading,
5594 ref: resizeObserverRef
5595 }
5596 ),
5597 virtualFocus: true,
5598 orientation: "horizontal",
5599 role: "listbox",
5600 "aria-multiselectable": isMultiselect,
5601 "aria-label": itemListLabel,
5602 children: data.map((item, index) => {
5603 let posinset = isInfiniteScroll ? index + 1 : void 0;
5604 if (!isInfiniteScroll) {
5605 posinset = (currentPage - 1) * perPage + index + 1;
5606 }
5607 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5608 GridItem3,
5609 {
5610 view,
5611 multiselect: isMultiselect,
5612 selection,
5613 onChangeSelection,
5614 getItemId,
5615 item,
5616 mediaField,
5617 titleField,
5618 descriptionField: descriptionField2,
5619 regularFields,
5620 badgeFields,
5621 config: {
5622 sizes: size
5623 },
5624 posinset,
5625 setsize: setSize
5626 },
5627 getItemId(item)
5628 );
5629 })
5630 }
5631 ),
5632 // Render empty state.
5633 !hasData && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5634 "div",
5635 {
5636 className: clsx_default({
5637 "dataviews-loading": isLoading,
5638 "dataviews-no-results": !isLoading
5639 }),
5640 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.Spinner, {}) }) : empty
5641 }
5642 ),
5643 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.Spinner, {}) })
5644 ]
5645 });
5646 }
5647 var picker_grid_default = ViewPickerGrid;
5648
5649 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
5650 var import_i18n24 = __toESM(require_i18n(), 1);
5651 var import_components16 = __toESM(require_components(), 1);
5652 var import_element21 = __toESM(require_element(), 1);
5653 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
5654 function TableColumnField2({
5655 item,
5656 fields,
5657 column,
5658 align
5659 }) {
5660 const field = fields.find((f2) => f2.id === column);
5661 if (!field) {
5662 return null;
5663 }
5664 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5665 "dataviews-view-table__cell-align-end": align === "end",
5666 "dataviews-view-table__cell-align-center": align === "center"
5667 });
5668 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(field.render, { item, field }) });
5669 }
5670 function TableRow2({
5671 item,
5672 fields,
5673 id,
5674 view,
5675 titleField,
5676 mediaField,
5677 descriptionField: descriptionField2,
5678 selection,
5679 getItemId,
5680 onChangeSelection,
5681 multiselect,
5682 posinset
5683 }) {
5684 const { paginationInfo } = (0, import_element21.useContext)(dataviews_context_default);
5685 const isSelected2 = selection.includes(id);
5686 const [isHovered, setIsHovered] = (0, import_element21.useState)(false);
5687 const {
5688 showTitle = true,
5689 showMedia = true,
5690 showDescription = true,
5691 infiniteScrollEnabled
5692 } = view;
5693 const handleMouseEnter = () => {
5694 setIsHovered(true);
5695 };
5696 const handleMouseLeave = () => {
5697 setIsHovered(false);
5698 };
5699 const columns = view.fields ?? [];
5700 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
5701 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5702 import_components16.Composite.Item,
5703 {
5704 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5705 "tr",
5706 {
5707 className: clsx_default("dataviews-view-table__row", {
5708 "is-selected": isSelected2,
5709 "is-hovered": isHovered
5710 }),
5711 onMouseEnter: handleMouseEnter,
5712 onMouseLeave: handleMouseLeave,
5713 children,
5714 ...props
5715 }
5716 ),
5717 "aria-selected": isSelected2,
5718 "aria-setsize": paginationInfo.totalItems || void 0,
5719 "aria-posinset": posinset,
5720 role: infiniteScrollEnabled ? "article" : "option",
5721 onClick: () => {
5722 if (isSelected2) {
5723 onChangeSelection(
5724 selection.filter((itemId) => id !== itemId)
5725 );
5726 } else {
5727 const newSelection = multiselect ? [...selection, id] : [id];
5728 onChangeSelection(newSelection);
5729 }
5730 },
5731 children: [
5732 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5733 "td",
5734 {
5735 className: "dataviews-view-table__checkbox-column",
5736 role: "presentation",
5737 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5738 DataViewsSelectionCheckbox,
5739 {
5740 item,
5741 selection,
5742 onChangeSelection,
5743 getItemId,
5744 titleField,
5745 disabled: false,
5746 "aria-hidden": true,
5747 tabIndex: -1
5748 }
5749 ) })
5750 }
5751 ),
5752 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5753 column_primary_default,
5754 {
5755 item,
5756 titleField: showTitle ? titleField : void 0,
5757 mediaField: showMedia ? mediaField : void 0,
5758 descriptionField: showDescription ? descriptionField2 : void 0,
5759 isItemClickable: () => false
5760 }
5761 ) }),
5762 columns.map((column) => {
5763 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5764 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5765 "td",
5766 {
5767 style: {
5768 width,
5769 maxWidth,
5770 minWidth
5771 },
5772 role: "presentation",
5773 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5774 TableColumnField2,
5775 {
5776 fields,
5777 item,
5778 column,
5779 align
5780 }
5781 )
5782 },
5783 column
5784 );
5785 })
5786 ]
5787 },
5788 id
5789 );
5790 }
5791 function ViewPickerTable({
5792 actions,
5793 data,
5794 fields,
5795 getItemId,
5796 isLoading = false,
5797 onChangeView,
5798 onChangeSelection,
5799 selection,
5800 setOpenedFilter,
5801 view,
5802 className,
5803 empty
5804 }) {
5805 const headerMenuRefs = (0, import_element21.useRef)(/* @__PURE__ */ new Map());
5806 const headerMenuToFocusRef = (0, import_element21.useRef)(void 0);
5807 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element21.useState)();
5808 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
5809 (0, import_element21.useEffect)(() => {
5810 if (headerMenuToFocusRef.current) {
5811 headerMenuToFocusRef.current.focus();
5812 headerMenuToFocusRef.current = void 0;
5813 }
5814 });
5815 const tableNoticeId = (0, import_element21.useId)();
5816 if (nextHeaderMenuToFocus) {
5817 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
5818 setNextHeaderMenuToFocus(void 0);
5819 return;
5820 }
5821 const onHide = (field) => {
5822 const hidden = headerMenuRefs.current.get(field.id);
5823 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
5824 setNextHeaderMenuToFocus(fallback?.node);
5825 };
5826 const hasData = !!data?.length;
5827 const titleField = fields.find((field) => field.id === view.titleField);
5828 const mediaField = fields.find((field) => field.id === view.mediaField);
5829 const descriptionField2 = fields.find(
5830 (field) => field.id === view.descriptionField
5831 );
5832 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5833 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5834 const { showTitle = true, showMedia = true, showDescription = true } = view;
5835 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
5836 const columns = view.fields ?? [];
5837 const headerMenuRef = (column, index) => (node) => {
5838 if (node) {
5839 headerMenuRefs.current.set(column, {
5840 node,
5841 fallback: columns[index > 0 ? index - 1 : 1]
5842 });
5843 } else {
5844 headerMenuRefs.current.delete(column);
5845 }
5846 };
5847 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5848 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
5849 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5850 "table",
5851 {
5852 className: clsx_default(
5853 "dataviews-view-table",
5854 "dataviews-view-picker-table",
5855 className,
5856 {
5857 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5858 view.layout.density
5859 )
5860 }
5861 ),
5862 "aria-busy": isLoading,
5863 "aria-describedby": tableNoticeId,
5864 role: isInfiniteScroll ? "feed" : "listbox",
5865 children: [
5866 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5867 "tr",
5868 {
5869 className: "dataviews-view-table__row",
5870 role: "presentation",
5871 children: [
5872 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5873 BulkSelectionCheckbox,
5874 {
5875 selection,
5876 onChangeSelection,
5877 data,
5878 actions,
5879 getItemId
5880 }
5881 ) }),
5882 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5883 column_header_menu_default,
5884 {
5885 ref: headerMenuRef(
5886 titleField.id,
5887 0
5888 ),
5889 fieldId: titleField.id,
5890 view,
5891 fields,
5892 onChangeView,
5893 onHide,
5894 setOpenedFilter,
5895 canMove: false
5896 }
5897 ) }),
5898 columns.map((column, index) => {
5899 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5900 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5901 "th",
5902 {
5903 style: {
5904 width,
5905 maxWidth,
5906 minWidth,
5907 textAlign: align
5908 },
5909 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
5910 scope: "col",
5911 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5912 column_header_menu_default,
5913 {
5914 ref: headerMenuRef(column, index),
5915 fieldId: column,
5916 view,
5917 fields,
5918 onChangeView,
5919 onHide,
5920 setOpenedFilter,
5921 canMove: view.layout?.enableMoving ?? true
5922 }
5923 )
5924 },
5925 column
5926 );
5927 })
5928 ]
5929 }
5930 ) }),
5931 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
5932 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5933 import_components16.Composite,
5934 {
5935 virtualFocus: true,
5936 orientation: "vertical",
5937 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tbody", { role: "group" }),
5938 children: [
5939 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5940 "tr",
5941 {
5942 className: "dataviews-view-table__group-header-row",
5943 role: "presentation",
5944 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5945 "td",
5946 {
5947 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
5948 className: "dataviews-view-table__group-header-cell",
5949 role: "presentation",
5950 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n24.sprintf)(
5951 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5952 (0, import_i18n24.__)("%1$s: %2$s"),
5953 groupField.label,
5954 groupName
5955 )
5956 }
5957 )
5958 }
5959 ),
5960 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5961 TableRow2,
5962 {
5963 item,
5964 fields,
5965 id: getItemId(item) || index.toString(),
5966 view,
5967 titleField,
5968 mediaField,
5969 descriptionField: descriptionField2,
5970 selection,
5971 getItemId,
5972 onChangeSelection,
5973 multiselect: isMultiselect
5974 },
5975 getItemId(item)
5976 ))
5977 ]
5978 },
5979 `group-${groupName}`
5980 )
5981 ) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5982 import_components16.Composite,
5983 {
5984 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tbody", { role: "presentation" }),
5985 virtualFocus: true,
5986 orientation: "vertical",
5987 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5988 TableRow2,
5989 {
5990 item,
5991 fields,
5992 id: getItemId(item) || index.toString(),
5993 view,
5994 titleField,
5995 mediaField,
5996 descriptionField: descriptionField2,
5997 selection,
5998 getItemId,
5999 onChangeSelection,
6000 multiselect: isMultiselect,
6001 posinset: index + 1
6002 },
6003 getItemId(item)
6004 ))
6005 }
6006 )
6007 ]
6008 }
6009 ),
6010 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
6011 "div",
6012 {
6013 className: clsx_default({
6014 "dataviews-loading": isLoading,
6015 "dataviews-no-results": !hasData && !isLoading
6016 }),
6017 id: tableNoticeId,
6018 children: [
6019 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components16.Spinner, {}) }) : empty),
6020 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components16.Spinner, {}) })
6021 ]
6022 }
6023 )
6024 ] });
6025 }
6026 var picker_table_default = ViewPickerTable;
6027
6028 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
6029 var import_components17 = __toESM(require_components(), 1);
6030 var import_i18n25 = __toESM(require_i18n(), 1);
6031 var import_element22 = __toESM(require_element(), 1);
6032 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
6033 var imageSizes2 = [
6034 {
6035 value: 120,
6036 breakpoint: 1
6037 },
6038 {
6039 value: 170,
6040 breakpoint: 1
6041 },
6042 {
6043 value: 230,
6044 breakpoint: 1
6045 },
6046 {
6047 value: 290,
6048 breakpoint: 1112
6049 // at minimum image width, 4 images display at this container size
6050 },
6051 {
6052 value: 350,
6053 breakpoint: 1636
6054 // at minimum image width, 6 images display at this container size
6055 },
6056 {
6057 value: 430,
6058 breakpoint: 588
6059 // at minimum image width, 2 images display at this container size
6060 }
6061 ];
6062 function PreviewSizePicker() {
6063 const context = (0, import_element22.useContext)(dataviews_context_default);
6064 const view = context.view;
6065 const breakValues = imageSizes2.filter((size) => {
6066 return context.containerWidth >= size.breakpoint;
6067 });
6068 const layoutPreviewSize = view.layout?.previewSize ?? 230;
6069 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
6070 const marks = breakValues.map((size, index) => {
6071 return {
6072 value: index
6073 };
6074 });
6075 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6076 import_components17.RangeControl,
6077 {
6078 __next40pxDefaultSize: true,
6079 showTooltip: false,
6080 label: (0, import_i18n25.__)("Preview size"),
6081 value: previewSizeToUse,
6082 min: 0,
6083 max: breakValues.length - 1,
6084 withInputField: false,
6085 onChange: (value = 0) => {
6086 context.onChangeView({
6087 ...view,
6088 layout: {
6089 ...view.layout,
6090 previewSize: breakValues[value].value
6091 }
6092 });
6093 },
6094 step: 1,
6095 marks
6096 }
6097 );
6098 }
6099
6100 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
6101 var import_components18 = __toESM(require_components(), 1);
6102 var import_i18n26 = __toESM(require_i18n(), 1);
6103 var import_element23 = __toESM(require_element(), 1);
6104 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
6105 function DensityPicker() {
6106 const context = (0, import_element23.useContext)(dataviews_context_default);
6107 const view = context.view;
6108 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
6109 import_components18.__experimentalToggleGroupControl,
6110 {
6111 size: "__unstable-large",
6112 label: (0, import_i18n26.__)("Density"),
6113 value: view.layout?.density || "balanced",
6114 onChange: (value) => {
6115 context.onChangeView({
6116 ...view,
6117 layout: {
6118 ...view.layout,
6119 density: value
6120 }
6121 });
6122 },
6123 isBlock: true,
6124 children: [
6125 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6126 import_components18.__experimentalToggleGroupControlOption,
6127 {
6128 value: "comfortable",
6129 label: (0, import_i18n26._x)(
6130 "Comfortable",
6131 "Density option for DataView layout"
6132 )
6133 },
6134 "comfortable"
6135 ),
6136 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6137 import_components18.__experimentalToggleGroupControlOption,
6138 {
6139 value: "balanced",
6140 label: (0, import_i18n26._x)("Balanced", "Density option for DataView layout")
6141 },
6142 "balanced"
6143 ),
6144 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6145 import_components18.__experimentalToggleGroupControlOption,
6146 {
6147 value: "compact",
6148 label: (0, import_i18n26._x)("Compact", "Density option for DataView layout")
6149 },
6150 "compact"
6151 )
6152 ]
6153 }
6154 );
6155 }
6156
6157 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
6158 var VIEW_LAYOUTS = [
6159 {
6160 type: LAYOUT_TABLE,
6161 label: (0, import_i18n27.__)("Table"),
6162 component: table_default,
6163 icon: block_table_default,
6164 viewConfigOptions: DensityPicker
6165 },
6166 {
6167 type: LAYOUT_GRID,
6168 label: (0, import_i18n27.__)("Grid"),
6169 component: grid_default,
6170 icon: category_default,
6171 viewConfigOptions: PreviewSizePicker
6172 },
6173 {
6174 type: LAYOUT_LIST,
6175 label: (0, import_i18n27.__)("List"),
6176 component: ViewList,
6177 icon: (0, import_i18n27.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
6178 viewConfigOptions: DensityPicker
6179 },
6180 {
6181 type: LAYOUT_ACTIVITY,
6182 label: (0, import_i18n27.__)("Activity"),
6183 component: ViewActivity,
6184 icon: scheduled_default,
6185 viewConfigOptions: DensityPicker
6186 },
6187 {
6188 type: LAYOUT_PICKER_GRID,
6189 label: (0, import_i18n27.__)("Grid"),
6190 component: picker_grid_default,
6191 icon: category_default,
6192 viewConfigOptions: PreviewSizePicker,
6193 isPicker: true
6194 },
6195 {
6196 type: LAYOUT_PICKER_TABLE,
6197 label: (0, import_i18n27.__)("Table"),
6198 component: picker_table_default,
6199 icon: block_table_default,
6200 viewConfigOptions: DensityPicker,
6201 isPicker: true
6202 }
6203 ];
6204
6205 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
6206 var import_element31 = __toESM(require_element(), 1);
6207
6208 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
6209 var import_components21 = __toESM(require_components(), 1);
6210 var import_i18n30 = __toESM(require_i18n(), 1);
6211 var import_element28 = __toESM(require_element(), 1);
6212
6213 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
6214 function noop2(..._) {
6215 }
6216 function applyState(argument, currentValue) {
6217 if (isUpdater(argument)) {
6218 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
6219 return argument(value);
6220 }
6221 return argument;
6222 }
6223 function isUpdater(argument) {
6224 return typeof argument === "function";
6225 }
6226 function isLazyValue(value) {
6227 return typeof value === "function";
6228 }
6229 function hasOwnProperty(object, prop) {
6230 if (typeof Object.hasOwn === "function") {
6231 return Object.hasOwn(object, prop);
6232 }
6233 return Object.prototype.hasOwnProperty.call(object, prop);
6234 }
6235 function chain(...fns) {
6236 return (...args) => {
6237 for (const fn of fns) {
6238 if (typeof fn === "function") {
6239 fn(...args);
6240 }
6241 }
6242 };
6243 }
6244 function normalizeString(str) {
6245 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
6246 }
6247 function omit(object, keys) {
6248 const result = { ...object };
6249 for (const key of keys) {
6250 if (hasOwnProperty(result, key)) {
6251 delete result[key];
6252 }
6253 }
6254 return result;
6255 }
6256 function pick(object, paths) {
6257 const result = {};
6258 for (const key of paths) {
6259 if (hasOwnProperty(object, key)) {
6260 result[key] = object[key];
6261 }
6262 }
6263 return result;
6264 }
6265 function identity(value) {
6266 return value;
6267 }
6268 function invariant(condition, message2) {
6269 if (condition) return;
6270 if (typeof message2 !== "string") throw new Error("Invariant failed");
6271 throw new Error(message2);
6272 }
6273 function getKeys(obj) {
6274 return Object.keys(obj);
6275 }
6276 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
6277 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
6278 if (result == null) return false;
6279 return !result;
6280 }
6281 function disabledFromProps(props) {
6282 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
6283 }
6284 function removeUndefinedValues(obj) {
6285 const result = {};
6286 for (const key in obj) {
6287 if (obj[key] !== void 0) {
6288 result[key] = obj[key];
6289 }
6290 }
6291 return result;
6292 }
6293 function defaultValue(...values) {
6294 for (const value of values) {
6295 if (value !== void 0) return value;
6296 }
6297 return void 0;
6298 }
6299
6300 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
6301 var import_react4 = __toESM(require_react(), 1);
6302 function setRef(ref, value) {
6303 if (typeof ref === "function") {
6304 ref(value);
6305 } else if (ref) {
6306 ref.current = value;
6307 }
6308 }
6309 function isValidElementWithRef(element) {
6310 if (!element) return false;
6311 if (!(0, import_react4.isValidElement)(element)) return false;
6312 if ("ref" in element.props) return true;
6313 if ("ref" in element) return true;
6314 return false;
6315 }
6316 function getRefProperty(element) {
6317 if (!isValidElementWithRef(element)) return null;
6318 const props = { ...element.props };
6319 return props.ref || element.ref;
6320 }
6321 function mergeProps2(base, overrides) {
6322 const props = { ...base };
6323 for (const key in overrides) {
6324 if (!hasOwnProperty(overrides, key)) continue;
6325 if (key === "className") {
6326 const prop = "className";
6327 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
6328 continue;
6329 }
6330 if (key === "style") {
6331 const prop = "style";
6332 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
6333 continue;
6334 }
6335 const overrideValue = overrides[key];
6336 if (typeof overrideValue === "function" && key.startsWith("on")) {
6337 const baseValue = base[key];
6338 if (typeof baseValue === "function") {
6339 props[key] = (...args) => {
6340 overrideValue(...args);
6341 baseValue(...args);
6342 };
6343 continue;
6344 }
6345 }
6346 props[key] = overrideValue;
6347 }
6348 return props;
6349 }
6350
6351 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
6352 var canUseDOM = checkIsBrowser();
6353 function checkIsBrowser() {
6354 var _a;
6355 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
6356 }
6357 function getDocument(node) {
6358 if (!node) return document;
6359 if ("self" in node) return node.document;
6360 return node.ownerDocument || document;
6361 }
6362 function getActiveElement(node, activeDescendant = false) {
6363 var _a;
6364 const { activeElement } = getDocument(node);
6365 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
6366 return null;
6367 }
6368 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
6369 return getActiveElement(
6370 activeElement.contentDocument.body,
6371 activeDescendant
6372 );
6373 }
6374 if (activeDescendant) {
6375 const id = activeElement.getAttribute("aria-activedescendant");
6376 if (id) {
6377 const element = getDocument(activeElement).getElementById(id);
6378 if (element) {
6379 return element;
6380 }
6381 }
6382 }
6383 return activeElement;
6384 }
6385 function contains(parent, child) {
6386 return parent === child || parent.contains(child);
6387 }
6388 function isFrame(element) {
6389 return element.tagName === "IFRAME";
6390 }
6391 function isButton(element) {
6392 const tagName = element.tagName.toLowerCase();
6393 if (tagName === "button") return true;
6394 if (tagName === "input" && element.type) {
6395 return buttonInputTypes.indexOf(element.type) !== -1;
6396 }
6397 return false;
6398 }
6399 var buttonInputTypes = [
6400 "button",
6401 "color",
6402 "file",
6403 "image",
6404 "reset",
6405 "submit"
6406 ];
6407 function isVisible(element) {
6408 if (typeof element.checkVisibility === "function") {
6409 return element.checkVisibility();
6410 }
6411 const htmlElement = element;
6412 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
6413 }
6414 function isTextField(element) {
6415 try {
6416 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
6417 const isTextArea = element.tagName === "TEXTAREA";
6418 return isTextInput || isTextArea || false;
6419 } catch (_error) {
6420 return false;
6421 }
6422 }
6423 function isTextbox(element) {
6424 return element.isContentEditable || isTextField(element);
6425 }
6426 function getTextboxValue(element) {
6427 if (isTextField(element)) {
6428 return element.value;
6429 }
6430 if (element.isContentEditable) {
6431 const range = getDocument(element).createRange();
6432 range.selectNodeContents(element);
6433 return range.toString();
6434 }
6435 return "";
6436 }
6437 function getTextboxSelection(element) {
6438 let start = 0;
6439 let end = 0;
6440 if (isTextField(element)) {
6441 start = element.selectionStart || 0;
6442 end = element.selectionEnd || 0;
6443 } else if (element.isContentEditable) {
6444 const selection = getDocument(element).getSelection();
6445 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
6446 const range = selection.getRangeAt(0);
6447 const nextRange = range.cloneRange();
6448 nextRange.selectNodeContents(element);
6449 nextRange.setEnd(range.startContainer, range.startOffset);
6450 start = nextRange.toString().length;
6451 nextRange.setEnd(range.endContainer, range.endOffset);
6452 end = nextRange.toString().length;
6453 }
6454 }
6455 return { start, end };
6456 }
6457 function getPopupRole(element, fallback) {
6458 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
6459 const role = element == null ? void 0 : element.getAttribute("role");
6460 if (role && allowedPopupRoles.indexOf(role) !== -1) {
6461 return role;
6462 }
6463 return fallback;
6464 }
6465 function getScrollingElement(element) {
6466 if (!element) return null;
6467 const isScrollableOverflow = (overflow) => {
6468 if (overflow === "auto") return true;
6469 if (overflow === "scroll") return true;
6470 return false;
6471 };
6472 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
6473 const { overflowY } = getComputedStyle(element);
6474 if (isScrollableOverflow(overflowY)) return element;
6475 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
6476 const { overflowX } = getComputedStyle(element);
6477 if (isScrollableOverflow(overflowX)) return element;
6478 }
6479 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
6480 }
6481 function setSelectionRange(element, ...args) {
6482 if (/text|search|password|tel|url/i.test(element.type)) {
6483 element.setSelectionRange(...args);
6484 }
6485 }
6486 function sortBasedOnDOMPosition(items, getElement) {
6487 const pairs = items.map((item, index) => [index, item]);
6488 let isOrderDifferent = false;
6489 pairs.sort(([indexA, a2], [indexB, b2]) => {
6490 const elementA = getElement(a2);
6491 const elementB = getElement(b2);
6492 if (elementA === elementB) return 0;
6493 if (!elementA || !elementB) return 0;
6494 if (isElementPreceding(elementA, elementB)) {
6495 if (indexA > indexB) {
6496 isOrderDifferent = true;
6497 }
6498 return -1;
6499 }
6500 if (indexA < indexB) {
6501 isOrderDifferent = true;
6502 }
6503 return 1;
6504 });
6505 if (isOrderDifferent) {
6506 return pairs.map(([_, item]) => item);
6507 }
6508 return items;
6509 }
6510 function isElementPreceding(a2, b2) {
6511 return Boolean(
6512 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
6513 );
6514 }
6515
6516 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
6517 function isTouchDevice() {
6518 return canUseDOM && !!navigator.maxTouchPoints;
6519 }
6520 function isApple() {
6521 if (!canUseDOM) return false;
6522 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
6523 }
6524 function isSafari() {
6525 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
6526 }
6527 function isFirefox() {
6528 return canUseDOM && /firefox\//i.test(navigator.userAgent);
6529 }
6530
6531 // node_modules/@ariakit/core/esm/utils/events.js
6532 function isPortalEvent(event) {
6533 return Boolean(
6534 event.currentTarget && !contains(event.currentTarget, event.target)
6535 );
6536 }
6537 function isSelfTarget(event) {
6538 return event.target === event.currentTarget;
6539 }
6540 function isOpeningInNewTab(event) {
6541 const element = event.currentTarget;
6542 if (!element) return false;
6543 const isAppleDevice = isApple();
6544 if (isAppleDevice && !event.metaKey) return false;
6545 if (!isAppleDevice && !event.ctrlKey) return false;
6546 const tagName = element.tagName.toLowerCase();
6547 if (tagName === "a") return true;
6548 if (tagName === "button" && element.type === "submit") return true;
6549 if (tagName === "input" && element.type === "submit") return true;
6550 return false;
6551 }
6552 function isDownloading(event) {
6553 const element = event.currentTarget;
6554 if (!element) return false;
6555 const tagName = element.tagName.toLowerCase();
6556 if (!event.altKey) return false;
6557 if (tagName === "a") return true;
6558 if (tagName === "button" && element.type === "submit") return true;
6559 if (tagName === "input" && element.type === "submit") return true;
6560 return false;
6561 }
6562 function fireBlurEvent(element, eventInit) {
6563 const event = new FocusEvent("blur", eventInit);
6564 const defaultAllowed = element.dispatchEvent(event);
6565 const bubbleInit = { ...eventInit, bubbles: true };
6566 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
6567 return defaultAllowed;
6568 }
6569 function fireKeyboardEvent(element, type, eventInit) {
6570 const event = new KeyboardEvent(type, eventInit);
6571 return element.dispatchEvent(event);
6572 }
6573 function fireClickEvent(element, eventInit) {
6574 const event = new MouseEvent("click", eventInit);
6575 return element.dispatchEvent(event);
6576 }
6577 function isFocusEventOutside(event, container) {
6578 const containerElement = container || event.currentTarget;
6579 const relatedTarget = event.relatedTarget;
6580 return !relatedTarget || !contains(containerElement, relatedTarget);
6581 }
6582 function queueBeforeEvent(element, type, callback, timeout) {
6583 const createTimer = (callback2) => {
6584 if (timeout) {
6585 const timerId2 = setTimeout(callback2, timeout);
6586 return () => clearTimeout(timerId2);
6587 }
6588 const timerId = requestAnimationFrame(callback2);
6589 return () => cancelAnimationFrame(timerId);
6590 };
6591 const cancelTimer = createTimer(() => {
6592 element.removeEventListener(type, callSync, true);
6593 callback();
6594 });
6595 const callSync = () => {
6596 cancelTimer();
6597 callback();
6598 };
6599 element.addEventListener(type, callSync, { once: true, capture: true });
6600 return cancelTimer;
6601 }
6602 function addGlobalEventListener(type, listener, options, scope = window) {
6603 const children = [];
6604 try {
6605 scope.document.addEventListener(type, listener, options);
6606 for (const frame of Array.from(scope.frames)) {
6607 children.push(addGlobalEventListener(type, listener, options, frame));
6608 }
6609 } catch (e2) {
6610 }
6611 const removeEventListener = () => {
6612 try {
6613 scope.document.removeEventListener(type, listener, options);
6614 } catch (e2) {
6615 }
6616 for (const remove of children) {
6617 remove();
6618 }
6619 };
6620 return removeEventListener;
6621 }
6622
6623 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
6624 var React5 = __toESM(require_react(), 1);
6625 var import_react5 = __toESM(require_react(), 1);
6626 var _React = { ...React5 };
6627 var useReactId = _React.useId;
6628 var useReactDeferredValue = _React.useDeferredValue;
6629 var useReactInsertionEffect = _React.useInsertionEffect;
6630 var useSafeLayoutEffect = canUseDOM ? import_react5.useLayoutEffect : import_react5.useEffect;
6631 function useInitialValue(value) {
6632 const [initialValue] = (0, import_react5.useState)(value);
6633 return initialValue;
6634 }
6635 function useLiveRef(value) {
6636 const ref = (0, import_react5.useRef)(value);
6637 useSafeLayoutEffect(() => {
6638 ref.current = value;
6639 });
6640 return ref;
6641 }
6642 function useEvent(callback) {
6643 const ref = (0, import_react5.useRef)(() => {
6644 throw new Error("Cannot call an event handler while rendering.");
6645 });
6646 if (useReactInsertionEffect) {
6647 useReactInsertionEffect(() => {
6648 ref.current = callback;
6649 });
6650 } else {
6651 ref.current = callback;
6652 }
6653 return (0, import_react5.useCallback)((...args) => {
6654 var _a;
6655 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
6656 }, []);
6657 }
6658 function useTransactionState(callback) {
6659 const [state, setState] = (0, import_react5.useState)(null);
6660 useSafeLayoutEffect(() => {
6661 if (state == null) return;
6662 if (!callback) return;
6663 let prevState = null;
6664 callback((prev) => {
6665 prevState = prev;
6666 return state;
6667 });
6668 return () => {
6669 callback(prevState);
6670 };
6671 }, [state, callback]);
6672 return [state, setState];
6673 }
6674 function useMergeRefs(...refs) {
6675 return (0, import_react5.useMemo)(() => {
6676 if (!refs.some(Boolean)) return;
6677 return (value) => {
6678 for (const ref of refs) {
6679 setRef(ref, value);
6680 }
6681 };
6682 }, refs);
6683 }
6684 function useId3(defaultId) {
6685 if (useReactId) {
6686 const reactId = useReactId();
6687 if (defaultId) return defaultId;
6688 return reactId;
6689 }
6690 const [id, setId] = (0, import_react5.useState)(defaultId);
6691 useSafeLayoutEffect(() => {
6692 if (defaultId || id) return;
6693 const random = Math.random().toString(36).slice(2, 8);
6694 setId(`id-${random}`);
6695 }, [defaultId, id]);
6696 return defaultId || id;
6697 }
6698 function useTagName(refOrElement, type) {
6699 const stringOrUndefined = (type2) => {
6700 if (typeof type2 !== "string") return;
6701 return type2;
6702 };
6703 const [tagName, setTagName] = (0, import_react5.useState)(() => stringOrUndefined(type));
6704 useSafeLayoutEffect(() => {
6705 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6706 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
6707 }, [refOrElement, type]);
6708 return tagName;
6709 }
6710 function useAttribute(refOrElement, attributeName, defaultValue2) {
6711 const initialValue = useInitialValue(defaultValue2);
6712 const [attribute, setAttribute] = (0, import_react5.useState)(initialValue);
6713 (0, import_react5.useEffect)(() => {
6714 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6715 if (!element) return;
6716 const callback = () => {
6717 const value = element.getAttribute(attributeName);
6718 setAttribute(value == null ? initialValue : value);
6719 };
6720 const observer = new MutationObserver(callback);
6721 observer.observe(element, { attributeFilter: [attributeName] });
6722 callback();
6723 return () => observer.disconnect();
6724 }, [refOrElement, attributeName, initialValue]);
6725 return attribute;
6726 }
6727 function useUpdateEffect(effect, deps) {
6728 const mounted = (0, import_react5.useRef)(false);
6729 (0, import_react5.useEffect)(() => {
6730 if (mounted.current) {
6731 return effect();
6732 }
6733 mounted.current = true;
6734 }, deps);
6735 (0, import_react5.useEffect)(
6736 () => () => {
6737 mounted.current = false;
6738 },
6739 []
6740 );
6741 }
6742 function useUpdateLayoutEffect(effect, deps) {
6743 const mounted = (0, import_react5.useRef)(false);
6744 useSafeLayoutEffect(() => {
6745 if (mounted.current) {
6746 return effect();
6747 }
6748 mounted.current = true;
6749 }, deps);
6750 useSafeLayoutEffect(
6751 () => () => {
6752 mounted.current = false;
6753 },
6754 []
6755 );
6756 }
6757 function useForceUpdate() {
6758 return (0, import_react5.useReducer)(() => [], []);
6759 }
6760 function useBooleanEvent(booleanOrCallback) {
6761 return useEvent(
6762 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
6763 );
6764 }
6765 function useWrapElement(props, callback, deps = []) {
6766 const wrapElement = (0, import_react5.useCallback)(
6767 (element) => {
6768 if (props.wrapElement) {
6769 element = props.wrapElement(element);
6770 }
6771 return callback(element);
6772 },
6773 [...deps, props.wrapElement]
6774 );
6775 return { ...props, wrapElement };
6776 }
6777 function useMetadataProps(props, key, value) {
6778 const parent = props.onLoadedMetadataCapture;
6779 const onLoadedMetadataCapture = (0, import_react5.useMemo)(() => {
6780 return Object.assign(() => {
6781 }, { ...parent, [key]: value });
6782 }, [parent, key, value]);
6783 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
6784 }
6785 var hasInstalledGlobalEventListeners = false;
6786 function useIsMouseMoving() {
6787 (0, import_react5.useEffect)(() => {
6788 if (hasInstalledGlobalEventListeners) return;
6789 addGlobalEventListener("mousemove", setMouseMoving, true);
6790 addGlobalEventListener("mousedown", resetMouseMoving, true);
6791 addGlobalEventListener("mouseup", resetMouseMoving, true);
6792 addGlobalEventListener("keydown", resetMouseMoving, true);
6793 addGlobalEventListener("scroll", resetMouseMoving, true);
6794 hasInstalledGlobalEventListeners = true;
6795 }, []);
6796 const isMouseMoving = useEvent(() => mouseMoving);
6797 return isMouseMoving;
6798 }
6799 var mouseMoving = false;
6800 var previousScreenX = 0;
6801 var previousScreenY = 0;
6802 function hasMouseMovement(event) {
6803 const movementX = event.movementX || event.screenX - previousScreenX;
6804 const movementY = event.movementY || event.screenY - previousScreenY;
6805 previousScreenX = event.screenX;
6806 previousScreenY = event.screenY;
6807 return movementX || movementY || false;
6808 }
6809 function setMouseMoving(event) {
6810 if (!hasMouseMovement(event)) return;
6811 mouseMoving = true;
6812 }
6813 function resetMouseMoving() {
6814 mouseMoving = false;
6815 }
6816
6817 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
6818 var React6 = __toESM(require_react(), 1);
6819 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
6820 function forwardRef22(render4) {
6821 const Role = React6.forwardRef(
6822 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6823 (props, ref) => render4({ ...props, ref })
6824 );
6825 Role.displayName = render4.displayName || render4.name;
6826 return Role;
6827 }
6828 function memo22(Component2, propsAreEqual) {
6829 return React6.memo(Component2, propsAreEqual);
6830 }
6831 function createElement3(Type, props) {
6832 const { wrapElement, render: render4, ...rest } = props;
6833 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
6834 let element;
6835 if (React6.isValidElement(render4)) {
6836 const renderProps = {
6837 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6838 ...render4.props,
6839 ref: mergedRef
6840 };
6841 element = React6.cloneElement(render4, mergeProps2(rest, renderProps));
6842 } else if (render4) {
6843 element = render4(rest);
6844 } else {
6845 element = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Type, { ...rest });
6846 }
6847 if (wrapElement) {
6848 return wrapElement(element);
6849 }
6850 return element;
6851 }
6852 function createHook(useProps) {
6853 const useRole = (props = {}) => {
6854 return useProps(props);
6855 };
6856 useRole.displayName = useProps.name;
6857 return useRole;
6858 }
6859 function createStoreContext(providers = [], scopedProviders = []) {
6860 const context = React6.createContext(void 0);
6861 const scopedContext = React6.createContext(void 0);
6862 const useContext27 = () => React6.useContext(context);
6863 const useScopedContext = (onlyScoped = false) => {
6864 const scoped = React6.useContext(scopedContext);
6865 const store = useContext27();
6866 if (onlyScoped) return scoped;
6867 return scoped || store;
6868 };
6869 const useProviderContext = () => {
6870 const scoped = React6.useContext(scopedContext);
6871 const store = useContext27();
6872 if (scoped && scoped === store) return;
6873 return store;
6874 };
6875 const ContextProvider = (props) => {
6876 return providers.reduceRight(
6877 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Provider, { ...props, children }),
6878 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(context.Provider, { ...props })
6879 );
6880 };
6881 const ScopedContextProvider = (props) => {
6882 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
6883 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Provider, { ...props, children }),
6884 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(scopedContext.Provider, { ...props })
6885 ) });
6886 };
6887 return {
6888 context,
6889 scopedContext,
6890 useContext: useContext27,
6891 useScopedContext,
6892 useProviderContext,
6893 ContextProvider,
6894 ScopedContextProvider
6895 };
6896 }
6897
6898 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
6899 var ctx = createStoreContext();
6900 var useCollectionContext = ctx.useContext;
6901 var useCollectionScopedContext = ctx.useScopedContext;
6902 var useCollectionProviderContext = ctx.useProviderContext;
6903 var CollectionContextProvider = ctx.ContextProvider;
6904 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
6905
6906 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
6907 var import_react6 = __toESM(require_react(), 1);
6908 var ctx2 = createStoreContext(
6909 [CollectionContextProvider],
6910 [CollectionScopedContextProvider]
6911 );
6912 var useCompositeContext = ctx2.useContext;
6913 var useCompositeScopedContext = ctx2.useScopedContext;
6914 var useCompositeProviderContext = ctx2.useProviderContext;
6915 var CompositeContextProvider = ctx2.ContextProvider;
6916 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
6917 var CompositeItemContext = (0, import_react6.createContext)(
6918 void 0
6919 );
6920 var CompositeRowContext = (0, import_react6.createContext)(
6921 void 0
6922 );
6923
6924 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
6925 function findFirstEnabledItem(items, excludeId) {
6926 return items.find((item) => {
6927 if (excludeId) {
6928 return !item.disabled && item.id !== excludeId;
6929 }
6930 return !item.disabled;
6931 });
6932 }
6933 function getEnabledItem(store, id) {
6934 if (!id) return null;
6935 return store.item(id) || null;
6936 }
6937 function groupItemsByRows(items) {
6938 const rows = [];
6939 for (const item of items) {
6940 const row = rows.find((currentRow) => {
6941 var _a;
6942 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
6943 });
6944 if (row) {
6945 row.push(item);
6946 } else {
6947 rows.push([item]);
6948 }
6949 }
6950 return rows;
6951 }
6952 function selectTextField(element, collapseToEnd = false) {
6953 if (isTextField(element)) {
6954 element.setSelectionRange(
6955 collapseToEnd ? element.value.length : 0,
6956 element.value.length
6957 );
6958 } else if (element.isContentEditable) {
6959 const selection = getDocument(element).getSelection();
6960 selection == null ? void 0 : selection.selectAllChildren(element);
6961 if (collapseToEnd) {
6962 selection == null ? void 0 : selection.collapseToEnd();
6963 }
6964 }
6965 }
6966 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
6967 function focusSilently(element) {
6968 element[FOCUS_SILENTLY] = true;
6969 element.focus({ preventScroll: true });
6970 }
6971 function silentlyFocused(element) {
6972 const isSilentlyFocused = element[FOCUS_SILENTLY];
6973 delete element[FOCUS_SILENTLY];
6974 return isSilentlyFocused;
6975 }
6976 function isItem(store, element, exclude) {
6977 if (!element) return false;
6978 if (element === exclude) return false;
6979 const item = store.item(element.id);
6980 if (!item) return false;
6981 if (exclude && item.element === exclude) return false;
6982 return true;
6983 }
6984
6985 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
6986 var import_react7 = __toESM(require_react(), 1);
6987 var TagName = "div";
6988 var useCollectionItem = createHook(
6989 function useCollectionItem2({
6990 store,
6991 shouldRegisterItem = true,
6992 getItem = identity,
6993 // @ts-expect-error This prop may come from a collection renderer.
6994 element,
6995 ...props
6996 }) {
6997 const context = useCollectionContext();
6998 store = store || context;
6999 const id = useId3(props.id);
7000 const ref = (0, import_react7.useRef)(element);
7001 (0, import_react7.useEffect)(() => {
7002 const element2 = ref.current;
7003 if (!id) return;
7004 if (!element2) return;
7005 if (!shouldRegisterItem) return;
7006 const item = getItem({ id, element: element2 });
7007 return store == null ? void 0 : store.renderItem(item);
7008 }, [id, shouldRegisterItem, getItem, store]);
7009 props = {
7010 ...props,
7011 ref: useMergeRefs(ref, props.ref)
7012 };
7013 return removeUndefinedValues(props);
7014 }
7015 );
7016 var CollectionItem = forwardRef22(function CollectionItem2(props) {
7017 const htmlProps = useCollectionItem(props);
7018 return createElement3(TagName, htmlProps);
7019 });
7020
7021 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
7022 var import_react8 = __toESM(require_react(), 1);
7023 var FocusableContext = (0, import_react8.createContext)(true);
7024
7025 // node_modules/@ariakit/core/esm/utils/focus.js
7026 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])";
7027 function isFocusable(element) {
7028 if (!element.matches(selector)) return false;
7029 if (!isVisible(element)) return false;
7030 if (element.closest("[inert]")) return false;
7031 return true;
7032 }
7033 function getClosestFocusable(element) {
7034 while (element && !isFocusable(element)) {
7035 element = element.closest(selector);
7036 }
7037 return element || null;
7038 }
7039 function hasFocus(element) {
7040 const activeElement = getActiveElement(element);
7041 if (!activeElement) return false;
7042 if (activeElement === element) return true;
7043 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7044 if (!activeDescendant) return false;
7045 return activeDescendant === element.id;
7046 }
7047 function hasFocusWithin(element) {
7048 const activeElement = getActiveElement(element);
7049 if (!activeElement) return false;
7050 if (contains(element, activeElement)) return true;
7051 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7052 if (!activeDescendant) return false;
7053 if (!("id" in element)) return false;
7054 if (activeDescendant === element.id) return true;
7055 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
7056 }
7057 function focusIfNeeded(element) {
7058 if (!hasFocusWithin(element) && isFocusable(element)) {
7059 element.focus();
7060 }
7061 }
7062 function focusIntoView(element, options) {
7063 if (!("scrollIntoView" in element)) {
7064 element.focus();
7065 } else {
7066 element.focus({ preventScroll: true });
7067 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
7068 }
7069 }
7070
7071 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
7072 var import_react9 = __toESM(require_react(), 1);
7073 var TagName2 = "div";
7074 var isSafariBrowser = isSafari();
7075 var alwaysFocusVisibleInputTypes = [
7076 "text",
7077 "search",
7078 "url",
7079 "tel",
7080 "email",
7081 "password",
7082 "number",
7083 "date",
7084 "month",
7085 "week",
7086 "time",
7087 "datetime",
7088 "datetime-local"
7089 ];
7090 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
7091 function markSafariFocusAncestor(element, value) {
7092 if (!element) return;
7093 element[safariFocusAncestorSymbol] = value;
7094 }
7095 function isAlwaysFocusVisible(element) {
7096 const { tagName, readOnly, type } = element;
7097 if (tagName === "TEXTAREA" && !readOnly) return true;
7098 if (tagName === "SELECT" && !readOnly) return true;
7099 if (tagName === "INPUT" && !readOnly) {
7100 return alwaysFocusVisibleInputTypes.includes(type);
7101 }
7102 if (element.isContentEditable) return true;
7103 const role = element.getAttribute("role");
7104 if (role === "combobox" && element.dataset.name) {
7105 return true;
7106 }
7107 return false;
7108 }
7109 function getLabels(element) {
7110 if ("labels" in element) {
7111 return element.labels;
7112 }
7113 return null;
7114 }
7115 function isNativeCheckboxOrRadio(element) {
7116 const tagName = element.tagName.toLowerCase();
7117 if (tagName === "input" && element.type) {
7118 return element.type === "radio" || element.type === "checkbox";
7119 }
7120 return false;
7121 }
7122 function isNativeTabbable(tagName) {
7123 if (!tagName) return true;
7124 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
7125 }
7126 function supportsDisabledAttribute(tagName) {
7127 if (!tagName) return true;
7128 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
7129 }
7130 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
7131 if (!focusable) {
7132 return tabIndexProp;
7133 }
7134 if (trulyDisabled) {
7135 if (nativeTabbable && !supportsDisabled) {
7136 return -1;
7137 }
7138 return;
7139 }
7140 if (nativeTabbable) {
7141 return tabIndexProp;
7142 }
7143 return tabIndexProp || 0;
7144 }
7145 function useDisableEvent(onEvent, disabled) {
7146 return useEvent((event) => {
7147 onEvent == null ? void 0 : onEvent(event);
7148 if (event.defaultPrevented) return;
7149 if (disabled) {
7150 event.stopPropagation();
7151 event.preventDefault();
7152 }
7153 });
7154 }
7155 var hasInstalledGlobalEventListeners2 = false;
7156 var isKeyboardModality = true;
7157 function onGlobalMouseDown(event) {
7158 const target = event.target;
7159 if (target && "hasAttribute" in target) {
7160 if (!target.hasAttribute("data-focus-visible")) {
7161 isKeyboardModality = false;
7162 }
7163 }
7164 }
7165 function onGlobalKeyDown(event) {
7166 if (event.metaKey) return;
7167 if (event.ctrlKey) return;
7168 if (event.altKey) return;
7169 isKeyboardModality = true;
7170 }
7171 var useFocusable = createHook(
7172 function useFocusable2({
7173 focusable = true,
7174 accessibleWhenDisabled,
7175 autoFocus,
7176 onFocusVisible,
7177 ...props
7178 }) {
7179 const ref = (0, import_react9.useRef)(null);
7180 (0, import_react9.useEffect)(() => {
7181 if (!focusable) return;
7182 if (hasInstalledGlobalEventListeners2) return;
7183 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
7184 addGlobalEventListener("keydown", onGlobalKeyDown, true);
7185 hasInstalledGlobalEventListeners2 = true;
7186 }, [focusable]);
7187 if (isSafariBrowser) {
7188 (0, import_react9.useEffect)(() => {
7189 if (!focusable) return;
7190 const element = ref.current;
7191 if (!element) return;
7192 if (!isNativeCheckboxOrRadio(element)) return;
7193 const labels = getLabels(element);
7194 if (!labels) return;
7195 const onMouseUp = () => queueMicrotask(() => element.focus());
7196 for (const label of labels) {
7197 label.addEventListener("mouseup", onMouseUp);
7198 }
7199 return () => {
7200 for (const label of labels) {
7201 label.removeEventListener("mouseup", onMouseUp);
7202 }
7203 };
7204 }, [focusable]);
7205 }
7206 const disabled = focusable && disabledFromProps(props);
7207 const trulyDisabled = !!disabled && !accessibleWhenDisabled;
7208 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
7209 (0, import_react9.useEffect)(() => {
7210 if (!focusable) return;
7211 if (trulyDisabled && focusVisible) {
7212 setFocusVisible(false);
7213 }
7214 }, [focusable, trulyDisabled, focusVisible]);
7215 (0, import_react9.useEffect)(() => {
7216 if (!focusable) return;
7217 if (!focusVisible) return;
7218 const element = ref.current;
7219 if (!element) return;
7220 if (typeof IntersectionObserver === "undefined") return;
7221 const observer = new IntersectionObserver(() => {
7222 if (!isFocusable(element)) {
7223 setFocusVisible(false);
7224 }
7225 });
7226 observer.observe(element);
7227 return () => observer.disconnect();
7228 }, [focusable, focusVisible]);
7229 const onKeyPressCapture = useDisableEvent(
7230 props.onKeyPressCapture,
7231 disabled
7232 );
7233 const onMouseDownCapture = useDisableEvent(
7234 props.onMouseDownCapture,
7235 disabled
7236 );
7237 const onClickCapture = useDisableEvent(props.onClickCapture, disabled);
7238 const onMouseDownProp = props.onMouseDown;
7239 const onMouseDown = useEvent((event) => {
7240 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
7241 if (event.defaultPrevented) return;
7242 if (!focusable) return;
7243 const element = event.currentTarget;
7244 if (!isSafariBrowser) return;
7245 if (isPortalEvent(event)) return;
7246 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
7247 let receivedFocus = false;
7248 const onFocus = () => {
7249 receivedFocus = true;
7250 };
7251 const options = { capture: true, once: true };
7252 element.addEventListener("focusin", onFocus, options);
7253 const focusableContainer = getClosestFocusable(element.parentElement);
7254 markSafariFocusAncestor(focusableContainer, true);
7255 queueBeforeEvent(element, "mouseup", () => {
7256 element.removeEventListener("focusin", onFocus, true);
7257 markSafariFocusAncestor(focusableContainer, false);
7258 if (receivedFocus) return;
7259 focusIfNeeded(element);
7260 });
7261 });
7262 const handleFocusVisible = (event, currentTarget) => {
7263 if (currentTarget) {
7264 event.currentTarget = currentTarget;
7265 }
7266 if (!focusable) return;
7267 const element = event.currentTarget;
7268 if (!element) return;
7269 if (!hasFocus(element)) return;
7270 onFocusVisible == null ? void 0 : onFocusVisible(event);
7271 if (event.defaultPrevented) return;
7272 element.dataset.focusVisible = "true";
7273 setFocusVisible(true);
7274 };
7275 const onKeyDownCaptureProp = props.onKeyDownCapture;
7276 const onKeyDownCapture = useEvent((event) => {
7277 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
7278 if (event.defaultPrevented) return;
7279 if (!focusable) return;
7280 if (focusVisible) return;
7281 if (event.metaKey) return;
7282 if (event.altKey) return;
7283 if (event.ctrlKey) return;
7284 if (!isSelfTarget(event)) return;
7285 const element = event.currentTarget;
7286 const applyFocusVisible = () => handleFocusVisible(event, element);
7287 queueBeforeEvent(element, "focusout", applyFocusVisible);
7288 });
7289 const onFocusCaptureProp = props.onFocusCapture;
7290 const onFocusCapture = useEvent((event) => {
7291 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
7292 if (event.defaultPrevented) return;
7293 if (!focusable) return;
7294 if (!isSelfTarget(event)) {
7295 setFocusVisible(false);
7296 return;
7297 }
7298 const element = event.currentTarget;
7299 const applyFocusVisible = () => handleFocusVisible(event, element);
7300 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
7301 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
7302 } else {
7303 setFocusVisible(false);
7304 }
7305 });
7306 const onBlurProp = props.onBlur;
7307 const onBlur = useEvent((event) => {
7308 onBlurProp == null ? void 0 : onBlurProp(event);
7309 if (!focusable) return;
7310 if (!isFocusEventOutside(event)) return;
7311 event.currentTarget.removeAttribute("data-focus-visible");
7312 setFocusVisible(false);
7313 });
7314 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
7315 const autoFocusRef = useEvent((element) => {
7316 if (!focusable) return;
7317 if (!autoFocus) return;
7318 if (!element) return;
7319 if (!autoFocusOnShow) return;
7320 queueMicrotask(() => {
7321 if (hasFocus(element)) return;
7322 if (!isFocusable(element)) return;
7323 element.focus();
7324 });
7325 });
7326 const tagName = useTagName(ref);
7327 const nativeTabbable = focusable && isNativeTabbable(tagName);
7328 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
7329 const styleProp = props.style;
7330 const style = (0, import_react9.useMemo)(() => {
7331 if (trulyDisabled) {
7332 return { pointerEvents: "none", ...styleProp };
7333 }
7334 return styleProp;
7335 }, [trulyDisabled, styleProp]);
7336 props = {
7337 "data-focus-visible": focusable && focusVisible || void 0,
7338 "data-autofocus": autoFocus || void 0,
7339 "aria-disabled": disabled || void 0,
7340 ...props,
7341 ref: useMergeRefs(ref, autoFocusRef, props.ref),
7342 style,
7343 tabIndex: getTabIndex(
7344 focusable,
7345 trulyDisabled,
7346 nativeTabbable,
7347 supportsDisabled,
7348 props.tabIndex
7349 ),
7350 disabled: supportsDisabled && trulyDisabled ? true : void 0,
7351 // TODO: Test Focusable contentEditable.
7352 contentEditable: disabled ? void 0 : props.contentEditable,
7353 onKeyPressCapture,
7354 onClickCapture,
7355 onMouseDownCapture,
7356 onMouseDown,
7357 onKeyDownCapture,
7358 onFocusCapture,
7359 onBlur
7360 };
7361 return removeUndefinedValues(props);
7362 }
7363 );
7364 var Focusable = forwardRef22(function Focusable2(props) {
7365 const htmlProps = useFocusable(props);
7366 return createElement3(TagName2, htmlProps);
7367 });
7368
7369 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
7370 var import_react10 = __toESM(require_react(), 1);
7371 var TagName3 = "button";
7372 function isNativeClick(event) {
7373 if (!event.isTrusted) return false;
7374 const element = event.currentTarget;
7375 if (event.key === "Enter") {
7376 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
7377 }
7378 if (event.key === " ") {
7379 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
7380 }
7381 return false;
7382 }
7383 var symbol = /* @__PURE__ */ Symbol("command");
7384 var useCommand = createHook(
7385 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
7386 const ref = (0, import_react10.useRef)(null);
7387 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
7388 (0, import_react10.useEffect)(() => {
7389 if (!ref.current) return;
7390 setIsNativeButton(isButton(ref.current));
7391 }, []);
7392 const [active, setActive] = (0, import_react10.useState)(false);
7393 const activeRef = (0, import_react10.useRef)(false);
7394 const disabled = disabledFromProps(props);
7395 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
7396 const onKeyDownProp = props.onKeyDown;
7397 const onKeyDown = useEvent((event) => {
7398 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7399 const element = event.currentTarget;
7400 if (event.defaultPrevented) return;
7401 if (isDuplicate) return;
7402 if (disabled) return;
7403 if (!isSelfTarget(event)) return;
7404 if (isTextField(element)) return;
7405 if (element.isContentEditable) return;
7406 const isEnter = clickOnEnter && event.key === "Enter";
7407 const isSpace = clickOnSpace && event.key === " ";
7408 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
7409 const shouldPreventSpace = event.key === " " && !clickOnSpace;
7410 if (shouldPreventEnter || shouldPreventSpace) {
7411 event.preventDefault();
7412 return;
7413 }
7414 if (isEnter || isSpace) {
7415 const nativeClick = isNativeClick(event);
7416 if (isEnter) {
7417 if (!nativeClick) {
7418 event.preventDefault();
7419 const { view, ...eventInit } = event;
7420 const click = () => fireClickEvent(element, eventInit);
7421 if (isFirefox()) {
7422 queueBeforeEvent(element, "keyup", click);
7423 } else {
7424 queueMicrotask(click);
7425 }
7426 }
7427 } else if (isSpace) {
7428 activeRef.current = true;
7429 if (!nativeClick) {
7430 event.preventDefault();
7431 setActive(true);
7432 }
7433 }
7434 }
7435 });
7436 const onKeyUpProp = props.onKeyUp;
7437 const onKeyUp = useEvent((event) => {
7438 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
7439 if (event.defaultPrevented) return;
7440 if (isDuplicate) return;
7441 if (disabled) return;
7442 if (event.metaKey) return;
7443 const isSpace = clickOnSpace && event.key === " ";
7444 if (activeRef.current && isSpace) {
7445 activeRef.current = false;
7446 if (!isNativeClick(event)) {
7447 event.preventDefault();
7448 setActive(false);
7449 const element = event.currentTarget;
7450 const { view, ...eventInit } = event;
7451 queueMicrotask(() => fireClickEvent(element, eventInit));
7452 }
7453 }
7454 });
7455 props = {
7456 "data-active": active || void 0,
7457 type: isNativeButton ? "button" : void 0,
7458 ...metadataProps,
7459 ...props,
7460 ref: useMergeRefs(ref, props.ref),
7461 onKeyDown,
7462 onKeyUp
7463 };
7464 props = useFocusable(props);
7465 return props;
7466 }
7467 );
7468 var Command = forwardRef22(function Command2(props) {
7469 const htmlProps = useCommand(props);
7470 return createElement3(TagName3, htmlProps);
7471 });
7472
7473 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
7474 function getInternal(store, key) {
7475 const internals = store.__unstableInternals;
7476 invariant(internals, "Invalid store");
7477 return internals[key];
7478 }
7479 function createStore(initialState, ...stores) {
7480 let state = initialState;
7481 let prevStateBatch = state;
7482 let lastUpdate = /* @__PURE__ */ Symbol();
7483 let destroy = noop2;
7484 const instances = /* @__PURE__ */ new Set();
7485 const updatedKeys = /* @__PURE__ */ new Set();
7486 const setups = /* @__PURE__ */ new Set();
7487 const listeners = /* @__PURE__ */ new Set();
7488 const batchListeners = /* @__PURE__ */ new Set();
7489 const disposables = /* @__PURE__ */ new WeakMap();
7490 const listenerKeys = /* @__PURE__ */ new WeakMap();
7491 const storeSetup = (callback) => {
7492 setups.add(callback);
7493 return () => setups.delete(callback);
7494 };
7495 const storeInit = () => {
7496 const initialized = instances.size;
7497 const instance = /* @__PURE__ */ Symbol();
7498 instances.add(instance);
7499 const maybeDestroy = () => {
7500 instances.delete(instance);
7501 if (instances.size) return;
7502 destroy();
7503 };
7504 if (initialized) return maybeDestroy;
7505 const desyncs = getKeys(state).map(
7506 (key) => chain(
7507 ...stores.map((store) => {
7508 var _a;
7509 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
7510 if (!storeState) return;
7511 if (!hasOwnProperty(storeState, key)) return;
7512 return sync(store, [key], (state2) => {
7513 setState(
7514 key,
7515 state2[key],
7516 // @ts-expect-error - Not public API. This is just to prevent
7517 // infinite loops.
7518 true
7519 );
7520 });
7521 })
7522 )
7523 );
7524 const teardowns = [];
7525 for (const setup2 of setups) {
7526 teardowns.push(setup2());
7527 }
7528 const cleanups = stores.map(init);
7529 destroy = chain(...desyncs, ...teardowns, ...cleanups);
7530 return maybeDestroy;
7531 };
7532 const sub = (keys, listener, set = listeners) => {
7533 set.add(listener);
7534 listenerKeys.set(listener, keys);
7535 return () => {
7536 var _a;
7537 (_a = disposables.get(listener)) == null ? void 0 : _a();
7538 disposables.delete(listener);
7539 listenerKeys.delete(listener);
7540 set.delete(listener);
7541 };
7542 };
7543 const storeSubscribe = (keys, listener) => sub(keys, listener);
7544 const storeSync = (keys, listener) => {
7545 disposables.set(listener, listener(state, state));
7546 return sub(keys, listener);
7547 };
7548 const storeBatch = (keys, listener) => {
7549 disposables.set(listener, listener(state, prevStateBatch));
7550 return sub(keys, listener, batchListeners);
7551 };
7552 const storePick = (keys) => createStore(pick(state, keys), finalStore);
7553 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
7554 const getState = () => state;
7555 const setState = (key, value, fromStores = false) => {
7556 var _a;
7557 if (!hasOwnProperty(state, key)) return;
7558 const nextValue = applyState(value, state[key]);
7559 if (nextValue === state[key]) return;
7560 if (!fromStores) {
7561 for (const store of stores) {
7562 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
7563 }
7564 }
7565 const prevState = state;
7566 state = { ...state, [key]: nextValue };
7567 const thisUpdate = /* @__PURE__ */ Symbol();
7568 lastUpdate = thisUpdate;
7569 updatedKeys.add(key);
7570 const run = (listener, prev, uKeys) => {
7571 var _a2;
7572 const keys = listenerKeys.get(listener);
7573 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
7574 if (!keys || keys.some(updated)) {
7575 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
7576 disposables.set(listener, listener(state, prev));
7577 }
7578 };
7579 for (const listener of listeners) {
7580 run(listener, prevState);
7581 }
7582 queueMicrotask(() => {
7583 if (lastUpdate !== thisUpdate) return;
7584 const snapshot = state;
7585 for (const listener of batchListeners) {
7586 run(listener, prevStateBatch, updatedKeys);
7587 }
7588 prevStateBatch = snapshot;
7589 updatedKeys.clear();
7590 });
7591 };
7592 const finalStore = {
7593 getState,
7594 setState,
7595 __unstableInternals: {
7596 setup: storeSetup,
7597 init: storeInit,
7598 subscribe: storeSubscribe,
7599 sync: storeSync,
7600 batch: storeBatch,
7601 pick: storePick,
7602 omit: storeOmit
7603 }
7604 };
7605 return finalStore;
7606 }
7607 function setup(store, ...args) {
7608 if (!store) return;
7609 return getInternal(store, "setup")(...args);
7610 }
7611 function init(store, ...args) {
7612 if (!store) return;
7613 return getInternal(store, "init")(...args);
7614 }
7615 function subscribe(store, ...args) {
7616 if (!store) return;
7617 return getInternal(store, "subscribe")(...args);
7618 }
7619 function sync(store, ...args) {
7620 if (!store) return;
7621 return getInternal(store, "sync")(...args);
7622 }
7623 function batch(store, ...args) {
7624 if (!store) return;
7625 return getInternal(store, "batch")(...args);
7626 }
7627 function omit2(store, ...args) {
7628 if (!store) return;
7629 return getInternal(store, "omit")(...args);
7630 }
7631 function pick2(store, ...args) {
7632 if (!store) return;
7633 return getInternal(store, "pick")(...args);
7634 }
7635 function mergeStore(...stores) {
7636 var _a;
7637 const initialState = {};
7638 for (const store2 of stores) {
7639 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
7640 if (nextState) {
7641 Object.assign(initialState, nextState);
7642 }
7643 }
7644 const store = createStore(initialState, ...stores);
7645 return Object.assign({}, ...stores, store);
7646 }
7647 function throwOnConflictingProps(props, store) {
7648 if (false) return;
7649 if (!store) return;
7650 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
7651 var _a;
7652 const stateKey = key.replace("default", "");
7653 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
7654 });
7655 if (!defaultKeys.length) return;
7656 const storeState = store.getState();
7657 const conflictingProps = defaultKeys.filter(
7658 (key) => hasOwnProperty(storeState, key)
7659 );
7660 if (!conflictingProps.length) return;
7661 throw new Error(
7662 `Passing a store prop in conjunction with a default state is not supported.
7663
7664 const store = useSelectStore();
7665 <SelectProvider store={store} defaultValue="Apple" />
7666 ^ ^
7667
7668 Instead, pass the default state to the topmost store:
7669
7670 const store = useSelectStore({ defaultValue: "Apple" });
7671 <SelectProvider store={store} />
7672
7673 See https://github.com/ariakit/ariakit/pull/2745 for more details.
7674
7675 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
7676 `
7677 );
7678 }
7679
7680 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
7681 var React7 = __toESM(require_react(), 1);
7682 var import_shim = __toESM(require_shim(), 1);
7683 var { useSyncExternalStore } = import_shim.default;
7684 var noopSubscribe = () => () => {
7685 };
7686 function useStoreState(store, keyOrSelector = identity) {
7687 const storeSubscribe = React7.useCallback(
7688 (callback) => {
7689 if (!store) return noopSubscribe();
7690 return subscribe(store, null, callback);
7691 },
7692 [store]
7693 );
7694 const getSnapshot = () => {
7695 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
7696 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
7697 const state = store == null ? void 0 : store.getState();
7698 if (selector2) return selector2(state);
7699 if (!state) return;
7700 if (!key) return;
7701 if (!hasOwnProperty(state, key)) return;
7702 return state[key];
7703 };
7704 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7705 }
7706 function useStoreStateObject(store, object) {
7707 const objRef = React7.useRef(
7708 {}
7709 );
7710 const storeSubscribe = React7.useCallback(
7711 (callback) => {
7712 if (!store) return noopSubscribe();
7713 return subscribe(store, null, callback);
7714 },
7715 [store]
7716 );
7717 const getSnapshot = () => {
7718 const state = store == null ? void 0 : store.getState();
7719 let updated = false;
7720 const obj = objRef.current;
7721 for (const prop in object) {
7722 const keyOrSelector = object[prop];
7723 if (typeof keyOrSelector === "function") {
7724 const value = keyOrSelector(state);
7725 if (value !== obj[prop]) {
7726 obj[prop] = value;
7727 updated = true;
7728 }
7729 }
7730 if (typeof keyOrSelector === "string") {
7731 if (!state) continue;
7732 if (!hasOwnProperty(state, keyOrSelector)) continue;
7733 const value = state[keyOrSelector];
7734 if (value !== obj[prop]) {
7735 obj[prop] = value;
7736 updated = true;
7737 }
7738 }
7739 }
7740 if (updated) {
7741 objRef.current = { ...obj };
7742 }
7743 return objRef.current;
7744 };
7745 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7746 }
7747 function useStoreProps(store, props, key, setKey) {
7748 const value = hasOwnProperty(props, key) ? props[key] : void 0;
7749 const setValue = setKey ? props[setKey] : void 0;
7750 const propsRef = useLiveRef({ value, setValue });
7751 useSafeLayoutEffect(() => {
7752 return sync(store, [key], (state, prev) => {
7753 const { value: value2, setValue: setValue2 } = propsRef.current;
7754 if (!setValue2) return;
7755 if (state[key] === prev[key]) return;
7756 if (state[key] === value2) return;
7757 setValue2(state[key]);
7758 });
7759 }, [store, key]);
7760 useSafeLayoutEffect(() => {
7761 if (value === void 0) return;
7762 store.setState(key, value);
7763 return batch(store, [key], () => {
7764 if (value === void 0) return;
7765 store.setState(key, value);
7766 });
7767 });
7768 }
7769 function useStore(createStore2, props) {
7770 const [store, setStore] = React7.useState(() => createStore2(props));
7771 useSafeLayoutEffect(() => init(store), [store]);
7772 const useState28 = React7.useCallback(
7773 (keyOrSelector) => useStoreState(store, keyOrSelector),
7774 [store]
7775 );
7776 const memoizedStore = React7.useMemo(
7777 () => ({ ...store, useState: useState28 }),
7778 [store, useState28]
7779 );
7780 const updateStore = useEvent(() => {
7781 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
7782 });
7783 return [memoizedStore, updateStore];
7784 }
7785
7786 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
7787 var import_react11 = __toESM(require_react(), 1);
7788 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
7789 var TagName4 = "button";
7790 function isEditableElement(element) {
7791 if (isTextbox(element)) return true;
7792 return element.tagName === "INPUT" && !isButton(element);
7793 }
7794 function getNextPageOffset(scrollingElement, pageUp = false) {
7795 const height = scrollingElement.clientHeight;
7796 const { top } = scrollingElement.getBoundingClientRect();
7797 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
7798 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
7799 if (scrollingElement.tagName === "HTML") {
7800 return pageOffset + scrollingElement.scrollTop;
7801 }
7802 return pageOffset;
7803 }
7804 function getItemOffset(itemElement, pageUp = false) {
7805 const { top } = itemElement.getBoundingClientRect();
7806 if (pageUp) {
7807 return top + itemElement.clientHeight;
7808 }
7809 return top;
7810 }
7811 function findNextPageItemId(element, store, next, pageUp = false) {
7812 var _a;
7813 if (!store) return;
7814 if (!next) return;
7815 const { renderedItems } = store.getState();
7816 const scrollingElement = getScrollingElement(element);
7817 if (!scrollingElement) return;
7818 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
7819 let id;
7820 let prevDifference;
7821 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
7822 const previousId = id;
7823 id = next(i2);
7824 if (!id) break;
7825 if (id === previousId) continue;
7826 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
7827 if (!itemElement) continue;
7828 const itemOffset = getItemOffset(itemElement, pageUp);
7829 const difference = itemOffset - nextPageOffset;
7830 const absDifference = Math.abs(difference);
7831 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
7832 if (prevDifference !== void 0 && prevDifference < absDifference) {
7833 id = previousId;
7834 }
7835 break;
7836 }
7837 prevDifference = absDifference;
7838 }
7839 return id;
7840 }
7841 function targetIsAnotherItem(event, store) {
7842 if (isSelfTarget(event)) return false;
7843 return isItem(store, event.target);
7844 }
7845 var useCompositeItem = createHook(
7846 function useCompositeItem2({
7847 store,
7848 rowId: rowIdProp,
7849 preventScrollOnKeyDown = false,
7850 moveOnKeyPress = true,
7851 tabbable = false,
7852 getItem: getItemProp,
7853 "aria-setsize": ariaSetSizeProp,
7854 "aria-posinset": ariaPosInSetProp,
7855 ...props
7856 }) {
7857 const context = useCompositeContext();
7858 store = store || context;
7859 const id = useId3(props.id);
7860 const ref = (0, import_react11.useRef)(null);
7861 const row = (0, import_react11.useContext)(CompositeRowContext);
7862 const disabled = disabledFromProps(props);
7863 const trulyDisabled = disabled && !props.accessibleWhenDisabled;
7864 const {
7865 rowId,
7866 baseElement,
7867 isActiveItem,
7868 ariaSetSize,
7869 ariaPosInSet,
7870 isTabbable
7871 } = useStoreStateObject(store, {
7872 rowId(state) {
7873 if (rowIdProp) return rowIdProp;
7874 if (!state) return;
7875 if (!(row == null ? void 0 : row.baseElement)) return;
7876 if (row.baseElement !== state.baseElement) return;
7877 return row.id;
7878 },
7879 baseElement(state) {
7880 return (state == null ? void 0 : state.baseElement) || void 0;
7881 },
7882 isActiveItem(state) {
7883 return !!state && state.activeId === id;
7884 },
7885 ariaSetSize(state) {
7886 if (ariaSetSizeProp != null) return ariaSetSizeProp;
7887 if (!state) return;
7888 if (!(row == null ? void 0 : row.ariaSetSize)) return;
7889 if (row.baseElement !== state.baseElement) return;
7890 return row.ariaSetSize;
7891 },
7892 ariaPosInSet(state) {
7893 if (ariaPosInSetProp != null) return ariaPosInSetProp;
7894 if (!state) return;
7895 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
7896 if (row.baseElement !== state.baseElement) return;
7897 const itemsInRow = state.renderedItems.filter(
7898 (item) => item.rowId === rowId
7899 );
7900 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
7901 },
7902 isTabbable(state) {
7903 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
7904 if (state.virtualFocus) return false;
7905 if (tabbable) return true;
7906 if (state.activeId === null) return false;
7907 const item = store == null ? void 0 : store.item(state.activeId);
7908 if (item == null ? void 0 : item.disabled) return true;
7909 if (!(item == null ? void 0 : item.element)) return true;
7910 return state.activeId === id;
7911 }
7912 });
7913 const getItem = (0, import_react11.useCallback)(
7914 (item) => {
7915 var _a;
7916 const nextItem = {
7917 ...item,
7918 id: id || item.id,
7919 rowId,
7920 disabled: !!trulyDisabled,
7921 children: (_a = item.element) == null ? void 0 : _a.textContent
7922 };
7923 if (getItemProp) {
7924 return getItemProp(nextItem);
7925 }
7926 return nextItem;
7927 },
7928 [id, rowId, trulyDisabled, getItemProp]
7929 );
7930 const onFocusProp = props.onFocus;
7931 const hasFocusedComposite = (0, import_react11.useRef)(false);
7932 const onFocus = useEvent((event) => {
7933 onFocusProp == null ? void 0 : onFocusProp(event);
7934 if (event.defaultPrevented) return;
7935 if (isPortalEvent(event)) return;
7936 if (!id) return;
7937 if (!store) return;
7938 if (targetIsAnotherItem(event, store)) return;
7939 const { virtualFocus, baseElement: baseElement2 } = store.getState();
7940 store.setActiveId(id);
7941 if (isTextbox(event.currentTarget)) {
7942 selectTextField(event.currentTarget);
7943 }
7944 if (!virtualFocus) return;
7945 if (!isSelfTarget(event)) return;
7946 if (isEditableElement(event.currentTarget)) return;
7947 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
7948 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
7949 event.currentTarget.scrollIntoView({
7950 block: "nearest",
7951 inline: "nearest"
7952 });
7953 }
7954 hasFocusedComposite.current = true;
7955 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
7956 if (fromComposite) {
7957 focusSilently(baseElement2);
7958 } else {
7959 baseElement2.focus();
7960 }
7961 });
7962 const onBlurCaptureProp = props.onBlurCapture;
7963 const onBlurCapture = useEvent((event) => {
7964 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
7965 if (event.defaultPrevented) return;
7966 const state = store == null ? void 0 : store.getState();
7967 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
7968 hasFocusedComposite.current = false;
7969 event.preventDefault();
7970 event.stopPropagation();
7971 }
7972 });
7973 const onKeyDownProp = props.onKeyDown;
7974 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
7975 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
7976 const onKeyDown = useEvent((event) => {
7977 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7978 if (event.defaultPrevented) return;
7979 if (!isSelfTarget(event)) return;
7980 if (!store) return;
7981 const { currentTarget } = event;
7982 const state = store.getState();
7983 const item = store.item(id);
7984 const isGrid2 = !!(item == null ? void 0 : item.rowId);
7985 const isVertical = state.orientation !== "horizontal";
7986 const isHorizontal = state.orientation !== "vertical";
7987 const canHomeEnd = () => {
7988 if (isGrid2) return true;
7989 if (isHorizontal) return true;
7990 if (!state.baseElement) return true;
7991 if (!isTextField(state.baseElement)) return true;
7992 return false;
7993 };
7994 const keyMap = {
7995 ArrowUp: (isGrid2 || isVertical) && store.up,
7996 ArrowRight: (isGrid2 || isHorizontal) && store.next,
7997 ArrowDown: (isGrid2 || isVertical) && store.down,
7998 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
7999 Home: () => {
8000 if (!canHomeEnd()) return;
8001 if (!isGrid2 || event.ctrlKey) {
8002 return store == null ? void 0 : store.first();
8003 }
8004 return store == null ? void 0 : store.previous(-1);
8005 },
8006 End: () => {
8007 if (!canHomeEnd()) return;
8008 if (!isGrid2 || event.ctrlKey) {
8009 return store == null ? void 0 : store.last();
8010 }
8011 return store == null ? void 0 : store.next(-1);
8012 },
8013 PageUp: () => {
8014 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
8015 },
8016 PageDown: () => {
8017 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
8018 }
8019 };
8020 const action = keyMap[event.key];
8021 if (action) {
8022 if (isTextbox(currentTarget)) {
8023 const selection = getTextboxSelection(currentTarget);
8024 const isLeft = isHorizontal && event.key === "ArrowLeft";
8025 const isRight = isHorizontal && event.key === "ArrowRight";
8026 const isUp = isVertical && event.key === "ArrowUp";
8027 const isDown = isVertical && event.key === "ArrowDown";
8028 if (isRight || isDown) {
8029 const { length: valueLength } = getTextboxValue(currentTarget);
8030 if (selection.end !== valueLength) return;
8031 } else if ((isLeft || isUp) && selection.start !== 0) return;
8032 }
8033 const nextId = action();
8034 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
8035 if (!moveOnKeyPressProp(event)) return;
8036 event.preventDefault();
8037 store.move(nextId);
8038 }
8039 }
8040 });
8041 const providerValue = (0, import_react11.useMemo)(
8042 () => ({ id, baseElement }),
8043 [id, baseElement]
8044 );
8045 props = useWrapElement(
8046 props,
8047 (element) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
8048 [providerValue]
8049 );
8050 props = {
8051 id,
8052 "data-active-item": isActiveItem || void 0,
8053 ...props,
8054 ref: useMergeRefs(ref, props.ref),
8055 tabIndex: isTabbable ? props.tabIndex : -1,
8056 onFocus,
8057 onBlurCapture,
8058 onKeyDown
8059 };
8060 props = useCommand(props);
8061 props = useCollectionItem({
8062 store,
8063 ...props,
8064 getItem,
8065 shouldRegisterItem: id ? props.shouldRegisterItem : false
8066 });
8067 return removeUndefinedValues({
8068 ...props,
8069 "aria-setsize": ariaSetSize,
8070 "aria-posinset": ariaPosInSet
8071 });
8072 }
8073 );
8074 var CompositeItem = memo22(
8075 forwardRef22(function CompositeItem2(props) {
8076 const htmlProps = useCompositeItem(props);
8077 return createElement3(TagName4, htmlProps);
8078 })
8079 );
8080
8081 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
8082 function toArray(arg) {
8083 if (Array.isArray(arg)) {
8084 return arg;
8085 }
8086 return typeof arg !== "undefined" ? [arg] : [];
8087 }
8088 function flatten2DArray(array) {
8089 const flattened = [];
8090 for (const row of array) {
8091 flattened.push(...row);
8092 }
8093 return flattened;
8094 }
8095 function reverseArray(array) {
8096 return array.slice().reverse();
8097 }
8098
8099 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
8100 var import_react12 = __toESM(require_react(), 1);
8101 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
8102 var TagName5 = "div";
8103 function isGrid(items) {
8104 return items.some((item) => !!item.rowId);
8105 }
8106 function isPrintableKey(event) {
8107 const target = event.target;
8108 if (target && !isTextField(target)) return false;
8109 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
8110 }
8111 function isModifierKey(event) {
8112 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
8113 }
8114 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
8115 return useEvent((event) => {
8116 var _a;
8117 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
8118 if (event.defaultPrevented) return;
8119 if (event.isPropagationStopped()) return;
8120 if (!isSelfTarget(event)) return;
8121 if (isModifierKey(event)) return;
8122 if (isPrintableKey(event)) return;
8123 const state = store.getState();
8124 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
8125 if (!activeElement) return;
8126 const { view, ...eventInit } = event;
8127 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
8128 if (activeElement !== previousElement) {
8129 activeElement.focus();
8130 }
8131 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
8132 event.preventDefault();
8133 }
8134 if (event.currentTarget.contains(activeElement)) {
8135 event.stopPropagation();
8136 }
8137 });
8138 }
8139 function findFirstEnabledItemInTheLastRow(items) {
8140 return findFirstEnabledItem(
8141 flatten2DArray(reverseArray(groupItemsByRows(items)))
8142 );
8143 }
8144 function useScheduleFocus(store) {
8145 const [scheduled, setScheduled] = (0, import_react12.useState)(false);
8146 const schedule = (0, import_react12.useCallback)(() => setScheduled(true), []);
8147 const activeItem = store.useState(
8148 (state) => getEnabledItem(store, state.activeId)
8149 );
8150 (0, import_react12.useEffect)(() => {
8151 const activeElement = activeItem == null ? void 0 : activeItem.element;
8152 if (!scheduled) return;
8153 if (!activeElement) return;
8154 setScheduled(false);
8155 activeElement.focus({ preventScroll: true });
8156 }, [activeItem, scheduled]);
8157 return schedule;
8158 }
8159 var useComposite = createHook(
8160 function useComposite2({
8161 store,
8162 composite = true,
8163 focusOnMove = composite,
8164 moveOnKeyPress = true,
8165 ...props
8166 }) {
8167 const context = useCompositeProviderContext();
8168 store = store || context;
8169 invariant(
8170 store,
8171 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
8172 );
8173 const ref = (0, import_react12.useRef)(null);
8174 const previousElementRef = (0, import_react12.useRef)(null);
8175 const scheduleFocus = useScheduleFocus(store);
8176 const moves = store.useState("moves");
8177 const [, setBaseElement] = useTransactionState(
8178 composite ? store.setBaseElement : null
8179 );
8180 (0, import_react12.useEffect)(() => {
8181 var _a;
8182 if (!store) return;
8183 if (!moves) return;
8184 if (!composite) return;
8185 if (!focusOnMove) return;
8186 const { activeId: activeId2 } = store.getState();
8187 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8188 if (!itemElement) return;
8189 focusIntoView(itemElement);
8190 }, [store, moves, composite, focusOnMove]);
8191 useSafeLayoutEffect(() => {
8192 if (!store) return;
8193 if (!moves) return;
8194 if (!composite) return;
8195 const { baseElement, activeId: activeId2 } = store.getState();
8196 const isSelfAcive = activeId2 === null;
8197 if (!isSelfAcive) return;
8198 if (!baseElement) return;
8199 const previousElement = previousElementRef.current;
8200 previousElementRef.current = null;
8201 if (previousElement) {
8202 fireBlurEvent(previousElement, { relatedTarget: baseElement });
8203 }
8204 if (!hasFocus(baseElement)) {
8205 baseElement.focus();
8206 }
8207 }, [store, moves, composite]);
8208 const activeId = store.useState("activeId");
8209 const virtualFocus = store.useState("virtualFocus");
8210 useSafeLayoutEffect(() => {
8211 var _a;
8212 if (!store) return;
8213 if (!composite) return;
8214 if (!virtualFocus) return;
8215 const previousElement = previousElementRef.current;
8216 previousElementRef.current = null;
8217 if (!previousElement) return;
8218 const activeElement = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
8219 const relatedTarget = activeElement || getActiveElement(previousElement);
8220 if (relatedTarget === previousElement) return;
8221 fireBlurEvent(previousElement, { relatedTarget });
8222 }, [store, activeId, virtualFocus, composite]);
8223 const onKeyDownCapture = useKeyboardEventProxy(
8224 store,
8225 props.onKeyDownCapture,
8226 previousElementRef
8227 );
8228 const onKeyUpCapture = useKeyboardEventProxy(
8229 store,
8230 props.onKeyUpCapture,
8231 previousElementRef
8232 );
8233 const onFocusCaptureProp = props.onFocusCapture;
8234 const onFocusCapture = useEvent((event) => {
8235 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
8236 if (event.defaultPrevented) return;
8237 if (!store) return;
8238 const { virtualFocus: virtualFocus2 } = store.getState();
8239 if (!virtualFocus2) return;
8240 const previousActiveElement = event.relatedTarget;
8241 const isSilentlyFocused = silentlyFocused(event.currentTarget);
8242 if (isSelfTarget(event) && isSilentlyFocused) {
8243 event.stopPropagation();
8244 previousElementRef.current = previousActiveElement;
8245 }
8246 });
8247 const onFocusProp = props.onFocus;
8248 const onFocus = useEvent((event) => {
8249 onFocusProp == null ? void 0 : onFocusProp(event);
8250 if (event.defaultPrevented) return;
8251 if (!composite) return;
8252 if (!store) return;
8253 const { relatedTarget } = event;
8254 const { virtualFocus: virtualFocus2 } = store.getState();
8255 if (virtualFocus2) {
8256 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
8257 queueMicrotask(scheduleFocus);
8258 }
8259 } else if (isSelfTarget(event)) {
8260 store.setActiveId(null);
8261 }
8262 });
8263 const onBlurCaptureProp = props.onBlurCapture;
8264 const onBlurCapture = useEvent((event) => {
8265 var _a;
8266 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
8267 if (event.defaultPrevented) return;
8268 if (!store) return;
8269 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
8270 if (!virtualFocus2) return;
8271 const activeElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8272 const nextActiveElement = event.relatedTarget;
8273 const nextActiveElementIsItem = isItem(store, nextActiveElement);
8274 const previousElement = previousElementRef.current;
8275 previousElementRef.current = null;
8276 if (isSelfTarget(event) && nextActiveElementIsItem) {
8277 if (nextActiveElement === activeElement) {
8278 if (previousElement && previousElement !== nextActiveElement) {
8279 fireBlurEvent(previousElement, event);
8280 }
8281 } else if (activeElement) {
8282 fireBlurEvent(activeElement, event);
8283 } else if (previousElement) {
8284 fireBlurEvent(previousElement, event);
8285 }
8286 event.stopPropagation();
8287 } else {
8288 const targetIsItem = isItem(store, event.target);
8289 if (!targetIsItem && activeElement) {
8290 fireBlurEvent(activeElement, event);
8291 }
8292 }
8293 });
8294 const onKeyDownProp = props.onKeyDown;
8295 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8296 const onKeyDown = useEvent((event) => {
8297 var _a;
8298 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8299 if (event.nativeEvent.isComposing) return;
8300 if (event.defaultPrevented) return;
8301 if (!store) return;
8302 if (!isSelfTarget(event)) return;
8303 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
8304 const activeItem = getEnabledItem(store, activeId2);
8305 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
8306 const isVertical = orientation !== "horizontal";
8307 const isHorizontal = orientation !== "vertical";
8308 const grid = isGrid(renderedItems);
8309 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
8310 if (isHorizontalKey && isTextField(event.currentTarget)) return;
8311 const up = () => {
8312 if (grid) {
8313 const item = findFirstEnabledItemInTheLastRow(renderedItems);
8314 return item == null ? void 0 : item.id;
8315 }
8316 return store == null ? void 0 : store.last();
8317 };
8318 const keyMap = {
8319 ArrowUp: (grid || isVertical) && up,
8320 ArrowRight: (grid || isHorizontal) && store.first,
8321 ArrowDown: (grid || isVertical) && store.first,
8322 ArrowLeft: (grid || isHorizontal) && store.last,
8323 Home: store.first,
8324 End: store.last,
8325 PageUp: store.first,
8326 PageDown: store.last
8327 };
8328 const action = keyMap[event.key];
8329 if (action) {
8330 const id = action();
8331 if (id !== void 0) {
8332 if (!moveOnKeyPressProp(event)) return;
8333 event.preventDefault();
8334 store.move(id);
8335 }
8336 }
8337 });
8338 props = useWrapElement(
8339 props,
8340 (element) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(CompositeContextProvider, { value: store, children: element }),
8341 [store]
8342 );
8343 const activeDescendant = store.useState((state) => {
8344 var _a;
8345 if (!store) return;
8346 if (!composite) return;
8347 if (!state.virtualFocus) return;
8348 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
8349 });
8350 props = {
8351 "aria-activedescendant": activeDescendant,
8352 ...props,
8353 ref: useMergeRefs(ref, setBaseElement, props.ref),
8354 onKeyDownCapture,
8355 onKeyUpCapture,
8356 onFocusCapture,
8357 onFocus,
8358 onBlurCapture,
8359 onKeyDown
8360 };
8361 const focusable = store.useState(
8362 (state) => composite && (state.virtualFocus || state.activeId === null)
8363 );
8364 props = useFocusable({ focusable, ...props });
8365 return props;
8366 }
8367 );
8368 var Composite5 = forwardRef22(function Composite22(props) {
8369 const htmlProps = useComposite(props);
8370 return createElement3(TagName5, htmlProps);
8371 });
8372
8373 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
8374 var ctx3 = createStoreContext();
8375 var useDisclosureContext = ctx3.useContext;
8376 var useDisclosureScopedContext = ctx3.useScopedContext;
8377 var useDisclosureProviderContext = ctx3.useProviderContext;
8378 var DisclosureContextProvider = ctx3.ContextProvider;
8379 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
8380
8381 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
8382 var import_react13 = __toESM(require_react(), 1);
8383 var ctx4 = createStoreContext(
8384 [DisclosureContextProvider],
8385 [DisclosureScopedContextProvider]
8386 );
8387 var useDialogContext = ctx4.useContext;
8388 var useDialogScopedContext = ctx4.useScopedContext;
8389 var useDialogProviderContext = ctx4.useProviderContext;
8390 var DialogContextProvider = ctx4.ContextProvider;
8391 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
8392 var DialogHeadingContext = (0, import_react13.createContext)(void 0);
8393 var DialogDescriptionContext = (0, import_react13.createContext)(void 0);
8394
8395 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
8396 var import_react14 = __toESM(require_react(), 1);
8397 var import_react_dom = __toESM(require_react_dom(), 1);
8398 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
8399 var TagName6 = "div";
8400 function afterTimeout(timeoutMs, cb) {
8401 const timeoutId = setTimeout(cb, timeoutMs);
8402 return () => clearTimeout(timeoutId);
8403 }
8404 function afterPaint2(cb) {
8405 let raf = requestAnimationFrame(() => {
8406 raf = requestAnimationFrame(cb);
8407 });
8408 return () => cancelAnimationFrame(raf);
8409 }
8410 function parseCSSTime(...times) {
8411 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
8412 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
8413 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
8414 if (currentTime > longestTime) return currentTime;
8415 return longestTime;
8416 }, 0);
8417 }
8418 function isHidden(mounted, hidden, alwaysVisible) {
8419 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
8420 }
8421 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
8422 const context = useDisclosureProviderContext();
8423 store = store || context;
8424 invariant(
8425 store,
8426 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
8427 );
8428 const ref = (0, import_react14.useRef)(null);
8429 const id = useId3(props.id);
8430 const [transition, setTransition] = (0, import_react14.useState)(null);
8431 const open = store.useState("open");
8432 const mounted = store.useState("mounted");
8433 const animated = store.useState("animated");
8434 const contentElement = store.useState("contentElement");
8435 const otherElement = useStoreState(store.disclosure, "contentElement");
8436 useSafeLayoutEffect(() => {
8437 if (!ref.current) return;
8438 store == null ? void 0 : store.setContentElement(ref.current);
8439 }, [store]);
8440 useSafeLayoutEffect(() => {
8441 let previousAnimated;
8442 store == null ? void 0 : store.setState("animated", (animated2) => {
8443 previousAnimated = animated2;
8444 return true;
8445 });
8446 return () => {
8447 if (previousAnimated === void 0) return;
8448 store == null ? void 0 : store.setState("animated", previousAnimated);
8449 };
8450 }, [store]);
8451 useSafeLayoutEffect(() => {
8452 if (!animated) return;
8453 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
8454 setTransition(null);
8455 return;
8456 }
8457 return afterPaint2(() => {
8458 setTransition(open ? "enter" : mounted ? "leave" : null);
8459 });
8460 }, [animated, contentElement, open, mounted]);
8461 useSafeLayoutEffect(() => {
8462 if (!store) return;
8463 if (!animated) return;
8464 if (!transition) return;
8465 if (!contentElement) return;
8466 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
8467 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
8468 if (transition === "leave" && open) return;
8469 if (transition === "enter" && !open) return;
8470 if (typeof animated === "number") {
8471 const timeout2 = animated;
8472 return afterTimeout(timeout2, stopAnimationSync);
8473 }
8474 const {
8475 transitionDuration,
8476 animationDuration,
8477 transitionDelay,
8478 animationDelay
8479 } = getComputedStyle(contentElement);
8480 const {
8481 transitionDuration: transitionDuration2 = "0",
8482 animationDuration: animationDuration2 = "0",
8483 transitionDelay: transitionDelay2 = "0",
8484 animationDelay: animationDelay2 = "0"
8485 } = otherElement ? getComputedStyle(otherElement) : {};
8486 const delay = parseCSSTime(
8487 transitionDelay,
8488 animationDelay,
8489 transitionDelay2,
8490 animationDelay2
8491 );
8492 const duration = parseCSSTime(
8493 transitionDuration,
8494 animationDuration,
8495 transitionDuration2,
8496 animationDuration2
8497 );
8498 const timeout = delay + duration;
8499 if (!timeout) {
8500 if (transition === "enter") {
8501 store.setState("animated", false);
8502 }
8503 stopAnimation();
8504 return;
8505 }
8506 const frameRate = 1e3 / 60;
8507 const maxTimeout = Math.max(timeout - frameRate, 0);
8508 return afterTimeout(maxTimeout, stopAnimationSync);
8509 }, [store, animated, contentElement, otherElement, open, transition]);
8510 props = useWrapElement(
8511 props,
8512 (element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DialogScopedContextProvider, { value: store, children: element }),
8513 [store]
8514 );
8515 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
8516 const styleProp = props.style;
8517 const style = (0, import_react14.useMemo)(() => {
8518 if (hidden) {
8519 return { ...styleProp, display: "none" };
8520 }
8521 return styleProp;
8522 }, [hidden, styleProp]);
8523 props = {
8524 id,
8525 "data-open": open || void 0,
8526 "data-enter": transition === "enter" || void 0,
8527 "data-leave": transition === "leave" || void 0,
8528 hidden,
8529 ...props,
8530 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
8531 style
8532 };
8533 return removeUndefinedValues(props);
8534 });
8535 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
8536 const htmlProps = useDisclosureContent(props);
8537 return createElement3(TagName6, htmlProps);
8538 });
8539 var DisclosureContent = forwardRef22(function DisclosureContent2({
8540 unmountOnHide,
8541 ...props
8542 }) {
8543 const context = useDisclosureProviderContext();
8544 const store = props.store || context;
8545 const mounted = useStoreState(
8546 store,
8547 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
8548 );
8549 if (mounted === false) return null;
8550 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DisclosureContentImpl, { ...props });
8551 });
8552
8553 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
8554 function createDisclosureStore(props = {}) {
8555 const store = mergeStore(
8556 props.store,
8557 omit2(props.disclosure, ["contentElement", "disclosureElement"])
8558 );
8559 throwOnConflictingProps(props, store);
8560 const syncState = store == null ? void 0 : store.getState();
8561 const open = defaultValue(
8562 props.open,
8563 syncState == null ? void 0 : syncState.open,
8564 props.defaultOpen,
8565 false
8566 );
8567 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
8568 const initialState = {
8569 open,
8570 animated,
8571 animating: !!animated && open,
8572 mounted: open,
8573 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
8574 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
8575 };
8576 const disclosure = createStore(initialState, store);
8577 setup(
8578 disclosure,
8579 () => sync(disclosure, ["animated", "animating"], (state) => {
8580 if (state.animated) return;
8581 disclosure.setState("animating", false);
8582 })
8583 );
8584 setup(
8585 disclosure,
8586 () => subscribe(disclosure, ["open"], () => {
8587 if (!disclosure.getState().animated) return;
8588 disclosure.setState("animating", true);
8589 })
8590 );
8591 setup(
8592 disclosure,
8593 () => sync(disclosure, ["open", "animating"], (state) => {
8594 disclosure.setState("mounted", state.open || state.animating);
8595 })
8596 );
8597 return {
8598 ...disclosure,
8599 disclosure: props.disclosure,
8600 setOpen: (value) => disclosure.setState("open", value),
8601 show: () => disclosure.setState("open", true),
8602 hide: () => disclosure.setState("open", false),
8603 toggle: () => disclosure.setState("open", (open2) => !open2),
8604 stopAnimation: () => disclosure.setState("animating", false),
8605 setContentElement: (value) => disclosure.setState("contentElement", value),
8606 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
8607 };
8608 }
8609
8610 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
8611 function useDisclosureStoreProps(store, update2, props) {
8612 useUpdateEffect(update2, [props.store, props.disclosure]);
8613 useStoreProps(store, props, "open", "setOpen");
8614 useStoreProps(store, props, "mounted", "setMounted");
8615 useStoreProps(store, props, "animated");
8616 return Object.assign(store, { disclosure: props.disclosure });
8617 }
8618
8619 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
8620 var ctx5 = createStoreContext(
8621 [DialogContextProvider],
8622 [DialogScopedContextProvider]
8623 );
8624 var usePopoverContext = ctx5.useContext;
8625 var usePopoverScopedContext = ctx5.useScopedContext;
8626 var usePopoverProviderContext = ctx5.useProviderContext;
8627 var PopoverContextProvider = ctx5.ContextProvider;
8628 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
8629
8630 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
8631 function getCommonParent(items) {
8632 var _a;
8633 const firstItem = items.find((item) => !!item.element);
8634 const lastItem = [...items].reverse().find((item) => !!item.element);
8635 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
8636 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
8637 const parent = parentElement;
8638 if (lastItem && parent.contains(lastItem.element)) {
8639 return parentElement;
8640 }
8641 parentElement = parentElement.parentElement;
8642 }
8643 return getDocument(parentElement).body;
8644 }
8645 function getPrivateStore(store) {
8646 return store == null ? void 0 : store.__unstablePrivateStore;
8647 }
8648 function createCollectionStore(props = {}) {
8649 var _a;
8650 throwOnConflictingProps(props, props.store);
8651 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8652 const items = defaultValue(
8653 props.items,
8654 syncState == null ? void 0 : syncState.items,
8655 props.defaultItems,
8656 []
8657 );
8658 const itemsMap = new Map(items.map((item) => [item.id, item]));
8659 const initialState = {
8660 items,
8661 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
8662 };
8663 const syncPrivateStore = getPrivateStore(props.store);
8664 const privateStore = createStore(
8665 { items, renderedItems: initialState.renderedItems },
8666 syncPrivateStore
8667 );
8668 const collection = createStore(initialState, props.store);
8669 const sortItems = (renderedItems) => {
8670 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
8671 privateStore.setState("renderedItems", sortedItems);
8672 collection.setState("renderedItems", sortedItems);
8673 };
8674 setup(collection, () => init(privateStore));
8675 setup(privateStore, () => {
8676 return batch(privateStore, ["items"], (state) => {
8677 collection.setState("items", state.items);
8678 });
8679 });
8680 setup(privateStore, () => {
8681 return batch(privateStore, ["renderedItems"], (state) => {
8682 let firstRun = true;
8683 let raf = requestAnimationFrame(() => {
8684 const { renderedItems } = collection.getState();
8685 if (state.renderedItems === renderedItems) return;
8686 sortItems(state.renderedItems);
8687 });
8688 if (typeof IntersectionObserver !== "function") {
8689 return () => cancelAnimationFrame(raf);
8690 }
8691 const ioCallback = () => {
8692 if (firstRun) {
8693 firstRun = false;
8694 return;
8695 }
8696 cancelAnimationFrame(raf);
8697 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
8698 };
8699 const root = getCommonParent(state.renderedItems);
8700 const observer = new IntersectionObserver(ioCallback, { root });
8701 for (const item of state.renderedItems) {
8702 if (!item.element) continue;
8703 observer.observe(item.element);
8704 }
8705 return () => {
8706 cancelAnimationFrame(raf);
8707 observer.disconnect();
8708 };
8709 });
8710 });
8711 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
8712 let prevItem;
8713 setItems((items2) => {
8714 const index = items2.findIndex(({ id }) => id === item.id);
8715 const nextItems = items2.slice();
8716 if (index !== -1) {
8717 prevItem = items2[index];
8718 const nextItem = { ...prevItem, ...item };
8719 nextItems[index] = nextItem;
8720 itemsMap.set(item.id, nextItem);
8721 } else {
8722 nextItems.push(item);
8723 itemsMap.set(item.id, item);
8724 }
8725 return nextItems;
8726 });
8727 const unmergeItem = () => {
8728 setItems((items2) => {
8729 if (!prevItem) {
8730 if (canDeleteFromMap) {
8731 itemsMap.delete(item.id);
8732 }
8733 return items2.filter(({ id }) => id !== item.id);
8734 }
8735 const index = items2.findIndex(({ id }) => id === item.id);
8736 if (index === -1) return items2;
8737 const nextItems = items2.slice();
8738 nextItems[index] = prevItem;
8739 itemsMap.set(item.id, prevItem);
8740 return nextItems;
8741 });
8742 };
8743 return unmergeItem;
8744 };
8745 const registerItem = (item) => mergeItem(
8746 item,
8747 (getItems) => privateStore.setState("items", getItems),
8748 true
8749 );
8750 return {
8751 ...collection,
8752 registerItem,
8753 renderItem: (item) => chain(
8754 registerItem(item),
8755 mergeItem(
8756 item,
8757 (getItems) => privateStore.setState("renderedItems", getItems)
8758 )
8759 ),
8760 item: (id) => {
8761 if (!id) return null;
8762 let item = itemsMap.get(id);
8763 if (!item) {
8764 const { items: items2 } = privateStore.getState();
8765 item = items2.find((item2) => item2.id === id);
8766 if (item) {
8767 itemsMap.set(id, item);
8768 }
8769 }
8770 return item || null;
8771 },
8772 // @ts-expect-error Internal
8773 __unstablePrivateStore: privateStore
8774 };
8775 }
8776
8777 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
8778 function useCollectionStoreProps(store, update2, props) {
8779 useUpdateEffect(update2, [props.store]);
8780 useStoreProps(store, props, "items", "setItems");
8781 return store;
8782 }
8783
8784 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
8785 var NULL_ITEM = { id: null };
8786 function findFirstEnabledItem2(items, excludeId) {
8787 return items.find((item) => {
8788 if (excludeId) {
8789 return !item.disabled && item.id !== excludeId;
8790 }
8791 return !item.disabled;
8792 });
8793 }
8794 function getEnabledItems(items, excludeId) {
8795 return items.filter((item) => {
8796 if (excludeId) {
8797 return !item.disabled && item.id !== excludeId;
8798 }
8799 return !item.disabled;
8800 });
8801 }
8802 function getItemsInRow(items, rowId) {
8803 return items.filter((item) => item.rowId === rowId);
8804 }
8805 function flipItems(items, activeId, shouldInsertNullItem = false) {
8806 const index = items.findIndex((item) => item.id === activeId);
8807 return [
8808 ...items.slice(index + 1),
8809 ...shouldInsertNullItem ? [NULL_ITEM] : [],
8810 ...items.slice(0, index)
8811 ];
8812 }
8813 function groupItemsByRows2(items) {
8814 const rows = [];
8815 for (const item of items) {
8816 const row = rows.find((currentRow) => {
8817 var _a;
8818 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
8819 });
8820 if (row) {
8821 row.push(item);
8822 } else {
8823 rows.push([item]);
8824 }
8825 }
8826 return rows;
8827 }
8828 function getMaxRowLength(array) {
8829 let maxLength = 0;
8830 for (const { length } of array) {
8831 if (length > maxLength) {
8832 maxLength = length;
8833 }
8834 }
8835 return maxLength;
8836 }
8837 function createEmptyItem(rowId) {
8838 return {
8839 id: "__EMPTY_ITEM__",
8840 disabled: true,
8841 rowId
8842 };
8843 }
8844 function normalizeRows(rows, activeId, focusShift) {
8845 const maxLength = getMaxRowLength(rows);
8846 for (const row of rows) {
8847 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8848 const item = row[i2];
8849 if (!item || focusShift && item.disabled) {
8850 const isFirst = i2 === 0;
8851 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
8852 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
8853 }
8854 }
8855 }
8856 return rows;
8857 }
8858 function verticalizeItems(items) {
8859 const rows = groupItemsByRows2(items);
8860 const maxLength = getMaxRowLength(rows);
8861 const verticalized = [];
8862 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8863 for (const row of rows) {
8864 const item = row[i2];
8865 if (item) {
8866 verticalized.push({
8867 ...item,
8868 // If there's no rowId, it means that it's not a grid composite, but
8869 // a single row instead. So, instead of verticalizing it, that is,
8870 // assigning a different rowId based on the column index, we keep it
8871 // undefined so they will be part of the same row. This is useful
8872 // when using up/down on one-dimensional composites.
8873 rowId: item.rowId ? `${i2}` : void 0
8874 });
8875 }
8876 }
8877 }
8878 return verticalized;
8879 }
8880 function createCompositeStore(props = {}) {
8881 var _a;
8882 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8883 const collection = createCollectionStore(props);
8884 const activeId = defaultValue(
8885 props.activeId,
8886 syncState == null ? void 0 : syncState.activeId,
8887 props.defaultActiveId
8888 );
8889 const initialState = {
8890 ...collection.getState(),
8891 id: defaultValue(
8892 props.id,
8893 syncState == null ? void 0 : syncState.id,
8894 `id-${Math.random().toString(36).slice(2, 8)}`
8895 ),
8896 activeId,
8897 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
8898 includesBaseElement: defaultValue(
8899 props.includesBaseElement,
8900 syncState == null ? void 0 : syncState.includesBaseElement,
8901 activeId === null
8902 ),
8903 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
8904 orientation: defaultValue(
8905 props.orientation,
8906 syncState == null ? void 0 : syncState.orientation,
8907 "both"
8908 ),
8909 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
8910 virtualFocus: defaultValue(
8911 props.virtualFocus,
8912 syncState == null ? void 0 : syncState.virtualFocus,
8913 false
8914 ),
8915 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
8916 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
8917 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
8918 };
8919 const composite = createStore(initialState, collection, props.store);
8920 setup(
8921 composite,
8922 () => sync(composite, ["renderedItems", "activeId"], (state) => {
8923 composite.setState("activeId", (activeId2) => {
8924 var _a2;
8925 if (activeId2 !== void 0) return activeId2;
8926 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
8927 });
8928 })
8929 );
8930 const getNextId = (direction = "next", options = {}) => {
8931 var _a2, _b;
8932 const defaultState = composite.getState();
8933 const {
8934 skip = 0,
8935 activeId: activeId2 = defaultState.activeId,
8936 focusShift = defaultState.focusShift,
8937 focusLoop = defaultState.focusLoop,
8938 focusWrap = defaultState.focusWrap,
8939 includesBaseElement = defaultState.includesBaseElement,
8940 renderedItems = defaultState.renderedItems,
8941 rtl = defaultState.rtl
8942 } = options;
8943 const isVerticalDirection = direction === "up" || direction === "down";
8944 const isNextDirection = direction === "next" || direction === "down";
8945 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
8946 const canShift = focusShift && !skip;
8947 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
8948 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
8949 );
8950 items = canReverse ? reverseArray(items) : items;
8951 items = isVerticalDirection ? verticalizeItems(items) : items;
8952 if (activeId2 == null) {
8953 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
8954 }
8955 const activeItem = items.find((item) => item.id === activeId2);
8956 if (!activeItem) {
8957 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
8958 }
8959 const isGrid2 = items.some((item) => item.rowId);
8960 const activeIndex = items.indexOf(activeItem);
8961 const nextItems = items.slice(activeIndex + 1);
8962 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
8963 if (skip) {
8964 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
8965 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
8966 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
8967 return nextItem2 == null ? void 0 : nextItem2.id;
8968 }
8969 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
8970 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
8971 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
8972 if (canLoop) {
8973 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
8974 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
8975 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
8976 return nextItem2 == null ? void 0 : nextItem2.id;
8977 }
8978 if (canWrap) {
8979 const nextItem2 = findFirstEnabledItem2(
8980 // We can use nextItems, which contains all the next items, including
8981 // items from other rows, to wrap between rows. However, if there is a
8982 // null item (the composite container), we'll only use the next items in
8983 // the row. So moving next from the last item will focus on the
8984 // composite container. On grid composites, horizontal navigation never
8985 // focuses on the composite container, only vertical.
8986 hasNullItem ? nextItemsInRow : nextItems,
8987 activeId2
8988 );
8989 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
8990 return nextId;
8991 }
8992 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
8993 if (!nextItem && hasNullItem) {
8994 return null;
8995 }
8996 return nextItem == null ? void 0 : nextItem.id;
8997 };
8998 return {
8999 ...collection,
9000 ...composite,
9001 setBaseElement: (element) => composite.setState("baseElement", element),
9002 setActiveId: (id) => composite.setState("activeId", id),
9003 move: (id) => {
9004 if (id === void 0) return;
9005 composite.setState("activeId", id);
9006 composite.setState("moves", (moves) => moves + 1);
9007 },
9008 first: () => {
9009 var _a2;
9010 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
9011 },
9012 last: () => {
9013 var _a2;
9014 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
9015 },
9016 next: (options) => {
9017 if (options !== void 0 && typeof options === "number") {
9018 options = { skip: options };
9019 }
9020 return getNextId("next", options);
9021 },
9022 previous: (options) => {
9023 if (options !== void 0 && typeof options === "number") {
9024 options = { skip: options };
9025 }
9026 return getNextId("previous", options);
9027 },
9028 down: (options) => {
9029 if (options !== void 0 && typeof options === "number") {
9030 options = { skip: options };
9031 }
9032 return getNextId("down", options);
9033 },
9034 up: (options) => {
9035 if (options !== void 0 && typeof options === "number") {
9036 options = { skip: options };
9037 }
9038 return getNextId("up", options);
9039 }
9040 };
9041 }
9042
9043 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
9044 function useCompositeStoreOptions(props) {
9045 const id = useId3(props.id);
9046 return { id, ...props };
9047 }
9048 function useCompositeStoreProps(store, update2, props) {
9049 store = useCollectionStoreProps(store, update2, props);
9050 useStoreProps(store, props, "activeId", "setActiveId");
9051 useStoreProps(store, props, "includesBaseElement");
9052 useStoreProps(store, props, "virtualFocus");
9053 useStoreProps(store, props, "orientation");
9054 useStoreProps(store, props, "rtl");
9055 useStoreProps(store, props, "focusLoop");
9056 useStoreProps(store, props, "focusWrap");
9057 useStoreProps(store, props, "focusShift");
9058 return store;
9059 }
9060
9061 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
9062 var import_react15 = __toESM(require_react(), 1);
9063 var ComboboxListRoleContext = (0, import_react15.createContext)(
9064 void 0
9065 );
9066 var ctx6 = createStoreContext(
9067 [PopoverContextProvider, CompositeContextProvider],
9068 [PopoverScopedContextProvider, CompositeScopedContextProvider]
9069 );
9070 var useComboboxContext = ctx6.useContext;
9071 var useComboboxScopedContext = ctx6.useScopedContext;
9072 var useComboboxProviderContext = ctx6.useProviderContext;
9073 var ComboboxContextProvider = ctx6.ContextProvider;
9074 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
9075 var ComboboxItemValueContext = (0, import_react15.createContext)(
9076 void 0
9077 );
9078 var ComboboxItemCheckedContext = (0, import_react15.createContext)(false);
9079
9080 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
9081 function createDialogStore(props = {}) {
9082 return createDisclosureStore(props);
9083 }
9084
9085 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
9086 function useDialogStoreProps(store, update2, props) {
9087 return useDisclosureStoreProps(store, update2, props);
9088 }
9089
9090 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
9091 function createPopoverStore({
9092 popover: otherPopover,
9093 ...props
9094 } = {}) {
9095 const store = mergeStore(
9096 props.store,
9097 omit2(otherPopover, [
9098 "arrowElement",
9099 "anchorElement",
9100 "contentElement",
9101 "popoverElement",
9102 "disclosureElement"
9103 ])
9104 );
9105 throwOnConflictingProps(props, store);
9106 const syncState = store == null ? void 0 : store.getState();
9107 const dialog = createDialogStore({ ...props, store });
9108 const placement = defaultValue(
9109 props.placement,
9110 syncState == null ? void 0 : syncState.placement,
9111 "bottom"
9112 );
9113 const initialState = {
9114 ...dialog.getState(),
9115 placement,
9116 currentPlacement: placement,
9117 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
9118 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
9119 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
9120 rendered: /* @__PURE__ */ Symbol("rendered")
9121 };
9122 const popover = createStore(initialState, dialog, store);
9123 return {
9124 ...dialog,
9125 ...popover,
9126 setAnchorElement: (element) => popover.setState("anchorElement", element),
9127 setPopoverElement: (element) => popover.setState("popoverElement", element),
9128 setArrowElement: (element) => popover.setState("arrowElement", element),
9129 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
9130 };
9131 }
9132
9133 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
9134 function usePopoverStoreProps(store, update2, props) {
9135 useUpdateEffect(update2, [props.popover]);
9136 useStoreProps(store, props, "placement");
9137 return useDialogStoreProps(store, update2, props);
9138 }
9139
9140 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
9141 var TagName7 = "div";
9142 var usePopoverAnchor = createHook(
9143 function usePopoverAnchor2({ store, ...props }) {
9144 const context = usePopoverProviderContext();
9145 store = store || context;
9146 props = {
9147 ...props,
9148 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
9149 };
9150 return props;
9151 }
9152 );
9153 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
9154 const htmlProps = usePopoverAnchor(props);
9155 return createElement3(TagName7, htmlProps);
9156 });
9157
9158 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
9159 var import_react16 = __toESM(require_react(), 1);
9160 var TagName8 = "div";
9161 function getMouseDestination(event) {
9162 const relatedTarget = event.relatedTarget;
9163 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
9164 return relatedTarget;
9165 }
9166 return null;
9167 }
9168 function hoveringInside(event) {
9169 const nextElement = getMouseDestination(event);
9170 if (!nextElement) return false;
9171 return contains(event.currentTarget, nextElement);
9172 }
9173 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
9174 function movingToAnotherItem(event) {
9175 let dest = getMouseDestination(event);
9176 if (!dest) return false;
9177 do {
9178 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
9179 dest = dest.parentElement;
9180 } while (dest);
9181 return false;
9182 }
9183 var useCompositeHover = createHook(
9184 function useCompositeHover2({
9185 store,
9186 focusOnHover = true,
9187 blurOnHoverEnd = !!focusOnHover,
9188 ...props
9189 }) {
9190 const context = useCompositeContext();
9191 store = store || context;
9192 invariant(
9193 store,
9194 "CompositeHover must be wrapped in a Composite component."
9195 );
9196 const isMouseMoving = useIsMouseMoving();
9197 const onMouseMoveProp = props.onMouseMove;
9198 const focusOnHoverProp = useBooleanEvent(focusOnHover);
9199 const onMouseMove = useEvent((event) => {
9200 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
9201 if (event.defaultPrevented) return;
9202 if (!isMouseMoving()) return;
9203 if (!focusOnHoverProp(event)) return;
9204 if (!hasFocusWithin(event.currentTarget)) {
9205 const baseElement = store == null ? void 0 : store.getState().baseElement;
9206 if (baseElement && !hasFocus(baseElement)) {
9207 baseElement.focus();
9208 }
9209 }
9210 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
9211 });
9212 const onMouseLeaveProp = props.onMouseLeave;
9213 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
9214 const onMouseLeave = useEvent((event) => {
9215 var _a;
9216 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
9217 if (event.defaultPrevented) return;
9218 if (!isMouseMoving()) return;
9219 if (hoveringInside(event)) return;
9220 if (movingToAnotherItem(event)) return;
9221 if (!focusOnHoverProp(event)) return;
9222 if (!blurOnHoverEndProp(event)) return;
9223 store == null ? void 0 : store.setActiveId(null);
9224 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
9225 });
9226 const ref = (0, import_react16.useCallback)((element) => {
9227 if (!element) return;
9228 element[symbol2] = true;
9229 }, []);
9230 props = {
9231 ...props,
9232 ref: useMergeRefs(ref, props.ref),
9233 onMouseMove,
9234 onMouseLeave
9235 };
9236 return removeUndefinedValues(props);
9237 }
9238 );
9239 var CompositeHover = memo22(
9240 forwardRef22(function CompositeHover2(props) {
9241 const htmlProps = useCompositeHover(props);
9242 return createElement3(TagName8, htmlProps);
9243 })
9244 );
9245
9246 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
9247 var import_react17 = __toESM(require_react(), 1);
9248 var TagName9 = "input";
9249 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
9250 if (!autoSelect) return false;
9251 const firstItem = items.find((item) => !item.disabled && item.value);
9252 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
9253 }
9254 function hasCompletionString(value, activeValue) {
9255 if (!activeValue) return false;
9256 if (value == null) return false;
9257 value = normalizeString(value);
9258 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
9259 }
9260 function isInputEvent(event) {
9261 return event.type === "input";
9262 }
9263 function isAriaAutoCompleteValue(value) {
9264 return value === "inline" || value === "list" || value === "both" || value === "none";
9265 }
9266 function getDefaultAutoSelectId(items) {
9267 const item = items.find((item2) => {
9268 var _a;
9269 if (item2.disabled) return false;
9270 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
9271 });
9272 return item == null ? void 0 : item.id;
9273 }
9274 var useCombobox = createHook(
9275 function useCombobox2({
9276 store,
9277 focusable = true,
9278 autoSelect: autoSelectProp = false,
9279 getAutoSelectId,
9280 setValueOnChange,
9281 showMinLength = 0,
9282 showOnChange,
9283 showOnMouseDown,
9284 showOnClick = showOnMouseDown,
9285 showOnKeyDown,
9286 showOnKeyPress = showOnKeyDown,
9287 blurActiveItemOnClick,
9288 setValueOnClick = true,
9289 moveOnKeyPress = true,
9290 autoComplete = "list",
9291 ...props
9292 }) {
9293 const context = useComboboxProviderContext();
9294 store = store || context;
9295 invariant(
9296 store,
9297 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
9298 );
9299 const ref = (0, import_react17.useRef)(null);
9300 const [valueUpdated, forceValueUpdate] = useForceUpdate();
9301 const canAutoSelectRef = (0, import_react17.useRef)(false);
9302 const composingRef = (0, import_react17.useRef)(false);
9303 const autoSelect = store.useState(
9304 (state) => state.virtualFocus && autoSelectProp
9305 );
9306 const inline = autoComplete === "inline" || autoComplete === "both";
9307 const [canInline, setCanInline] = (0, import_react17.useState)(inline);
9308 useUpdateLayoutEffect(() => {
9309 if (!inline) return;
9310 setCanInline(true);
9311 }, [inline]);
9312 const storeValue = store.useState("value");
9313 const prevSelectedValueRef = (0, import_react17.useRef)(void 0);
9314 (0, import_react17.useEffect)(() => {
9315 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
9316 prevSelectedValueRef.current = prev.selectedValue;
9317 });
9318 }, []);
9319 const inlineActiveValue = store.useState((state) => {
9320 var _a;
9321 if (!inline) return;
9322 if (!canInline) return;
9323 if (state.activeValue && Array.isArray(state.selectedValue)) {
9324 if (state.selectedValue.includes(state.activeValue)) return;
9325 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
9326 }
9327 return state.activeValue;
9328 });
9329 const items = store.useState("renderedItems");
9330 const open = store.useState("open");
9331 const contentElement = store.useState("contentElement");
9332 const value = (0, import_react17.useMemo)(() => {
9333 if (!inline) return storeValue;
9334 if (!canInline) return storeValue;
9335 const firstItemAutoSelected = isFirstItemAutoSelected(
9336 items,
9337 inlineActiveValue,
9338 autoSelect
9339 );
9340 if (firstItemAutoSelected) {
9341 if (hasCompletionString(storeValue, inlineActiveValue)) {
9342 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
9343 return storeValue + slice;
9344 }
9345 return storeValue;
9346 }
9347 return inlineActiveValue || storeValue;
9348 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
9349 (0, import_react17.useEffect)(() => {
9350 const element = ref.current;
9351 if (!element) return;
9352 const onCompositeItemMove = () => setCanInline(true);
9353 element.addEventListener("combobox-item-move", onCompositeItemMove);
9354 return () => {
9355 element.removeEventListener("combobox-item-move", onCompositeItemMove);
9356 };
9357 }, []);
9358 (0, import_react17.useEffect)(() => {
9359 if (!inline) return;
9360 if (!canInline) return;
9361 if (!inlineActiveValue) return;
9362 const firstItemAutoSelected = isFirstItemAutoSelected(
9363 items,
9364 inlineActiveValue,
9365 autoSelect
9366 );
9367 if (!firstItemAutoSelected) return;
9368 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
9369 let cleanup = noop2;
9370 queueMicrotask(() => {
9371 const element = ref.current;
9372 if (!element) return;
9373 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
9374 const nextStart = storeValue.length;
9375 const nextEnd = inlineActiveValue.length;
9376 setSelectionRange(element, nextStart, nextEnd);
9377 cleanup = () => {
9378 if (!hasFocus(element)) return;
9379 const { start, end } = getTextboxSelection(element);
9380 if (start !== nextStart) return;
9381 if (end !== nextEnd) return;
9382 setSelectionRange(element, prevStart, prevEnd);
9383 };
9384 });
9385 return () => cleanup();
9386 }, [
9387 valueUpdated,
9388 inline,
9389 canInline,
9390 inlineActiveValue,
9391 items,
9392 autoSelect,
9393 storeValue
9394 ]);
9395 const scrollingElementRef = (0, import_react17.useRef)(null);
9396 const getAutoSelectIdProp = useEvent(getAutoSelectId);
9397 const autoSelectIdRef = (0, import_react17.useRef)(null);
9398 (0, import_react17.useEffect)(() => {
9399 if (!open) return;
9400 if (!contentElement) return;
9401 const scrollingElement = getScrollingElement(contentElement);
9402 if (!scrollingElement) return;
9403 scrollingElementRef.current = scrollingElement;
9404 const onUserScroll = () => {
9405 canAutoSelectRef.current = false;
9406 };
9407 const onScroll = () => {
9408 if (!store) return;
9409 if (!canAutoSelectRef.current) return;
9410 const { activeId } = store.getState();
9411 if (activeId === null) return;
9412 if (activeId === autoSelectIdRef.current) return;
9413 canAutoSelectRef.current = false;
9414 };
9415 const options = { passive: true, capture: true };
9416 scrollingElement.addEventListener("wheel", onUserScroll, options);
9417 scrollingElement.addEventListener("touchmove", onUserScroll, options);
9418 scrollingElement.addEventListener("scroll", onScroll, options);
9419 return () => {
9420 scrollingElement.removeEventListener("wheel", onUserScroll, true);
9421 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
9422 scrollingElement.removeEventListener("scroll", onScroll, true);
9423 };
9424 }, [open, contentElement, store]);
9425 useSafeLayoutEffect(() => {
9426 if (!storeValue) return;
9427 if (composingRef.current) return;
9428 canAutoSelectRef.current = true;
9429 }, [storeValue]);
9430 useSafeLayoutEffect(() => {
9431 if (autoSelect !== "always" && open) return;
9432 canAutoSelectRef.current = open;
9433 }, [autoSelect, open]);
9434 const resetValueOnSelect = store.useState("resetValueOnSelect");
9435 useUpdateEffect(() => {
9436 var _a, _b;
9437 const canAutoSelect = canAutoSelectRef.current;
9438 if (!store) return;
9439 if (!open) return;
9440 if (!canAutoSelect && !resetValueOnSelect) return;
9441 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
9442 if (baseElement && !hasFocus(baseElement)) return;
9443 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
9444 const observer = new MutationObserver(forceValueUpdate);
9445 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
9446 return () => observer.disconnect();
9447 }
9448 if (autoSelect && canAutoSelect) {
9449 const userAutoSelectId = getAutoSelectIdProp(items);
9450 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
9451 autoSelectIdRef.current = autoSelectId;
9452 store.move(autoSelectId != null ? autoSelectId : null);
9453 } else {
9454 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
9455 if (element && "scrollIntoView" in element) {
9456 element.scrollIntoView({ block: "nearest", inline: "nearest" });
9457 }
9458 }
9459 return;
9460 }, [
9461 store,
9462 open,
9463 valueUpdated,
9464 storeValue,
9465 autoSelect,
9466 resetValueOnSelect,
9467 getAutoSelectIdProp,
9468 items
9469 ]);
9470 (0, import_react17.useEffect)(() => {
9471 if (!inline) return;
9472 const combobox = ref.current;
9473 if (!combobox) return;
9474 const elements = [combobox, contentElement].filter(
9475 (value2) => !!value2
9476 );
9477 const onBlur2 = (event) => {
9478 if (elements.every((el) => isFocusEventOutside(event, el))) {
9479 store == null ? void 0 : store.setValue(value);
9480 }
9481 };
9482 for (const element of elements) {
9483 element.addEventListener("focusout", onBlur2);
9484 }
9485 return () => {
9486 for (const element of elements) {
9487 element.removeEventListener("focusout", onBlur2);
9488 }
9489 };
9490 }, [inline, contentElement, store, value]);
9491 const canShow = (event) => {
9492 const currentTarget = event.currentTarget;
9493 return currentTarget.value.length >= showMinLength;
9494 };
9495 const onChangeProp = props.onChange;
9496 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
9497 const setValueOnChangeProp = useBooleanEvent(
9498 // If the combobox is combined with tags, the value will be set by the tag
9499 // input component.
9500 setValueOnChange != null ? setValueOnChange : !store.tag
9501 );
9502 const onChange = useEvent((event) => {
9503 onChangeProp == null ? void 0 : onChangeProp(event);
9504 if (event.defaultPrevented) return;
9505 if (!store) return;
9506 const currentTarget = event.currentTarget;
9507 const { value: value2, selectionStart, selectionEnd } = currentTarget;
9508 const nativeEvent = event.nativeEvent;
9509 canAutoSelectRef.current = true;
9510 if (isInputEvent(nativeEvent)) {
9511 if (nativeEvent.isComposing) {
9512 canAutoSelectRef.current = false;
9513 composingRef.current = true;
9514 }
9515 if (inline) {
9516 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
9517 const caretAtEnd = selectionStart === value2.length;
9518 setCanInline(textInserted && caretAtEnd);
9519 }
9520 }
9521 if (setValueOnChangeProp(event)) {
9522 const isSameValue = value2 === store.getState().value;
9523 store.setValue(value2);
9524 queueMicrotask(() => {
9525 setSelectionRange(currentTarget, selectionStart, selectionEnd);
9526 });
9527 if (inline && autoSelect && isSameValue) {
9528 forceValueUpdate();
9529 }
9530 }
9531 if (showOnChangeProp(event)) {
9532 store.show();
9533 }
9534 if (!autoSelect || !canAutoSelectRef.current) {
9535 store.setActiveId(null);
9536 }
9537 });
9538 const onCompositionEndProp = props.onCompositionEnd;
9539 const onCompositionEnd = useEvent((event) => {
9540 canAutoSelectRef.current = true;
9541 composingRef.current = false;
9542 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
9543 if (event.defaultPrevented) return;
9544 if (!autoSelect) return;
9545 forceValueUpdate();
9546 });
9547 const onMouseDownProp = props.onMouseDown;
9548 const blurActiveItemOnClickProp = useBooleanEvent(
9549 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
9550 );
9551 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9552 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
9553 const onMouseDown = useEvent((event) => {
9554 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9555 if (event.defaultPrevented) return;
9556 if (event.button) return;
9557 if (event.ctrlKey) return;
9558 if (!store) return;
9559 if (blurActiveItemOnClickProp(event)) {
9560 store.setActiveId(null);
9561 }
9562 if (setValueOnClickProp(event)) {
9563 store.setValue(value);
9564 }
9565 if (showOnClickProp(event)) {
9566 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
9567 }
9568 });
9569 const onKeyDownProp = props.onKeyDown;
9570 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
9571 const onKeyDown = useEvent((event) => {
9572 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9573 if (!event.repeat) {
9574 canAutoSelectRef.current = false;
9575 }
9576 if (event.defaultPrevented) return;
9577 if (event.ctrlKey) return;
9578 if (event.altKey) return;
9579 if (event.shiftKey) return;
9580 if (event.metaKey) return;
9581 if (!store) return;
9582 const { open: open2 } = store.getState();
9583 if (open2) return;
9584 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
9585 if (showOnKeyPressProp(event)) {
9586 event.preventDefault();
9587 store.show();
9588 }
9589 }
9590 });
9591 const onBlurProp = props.onBlur;
9592 const onBlur = useEvent((event) => {
9593 canAutoSelectRef.current = false;
9594 onBlurProp == null ? void 0 : onBlurProp(event);
9595 if (event.defaultPrevented) return;
9596 });
9597 const id = useId3(props.id);
9598 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
9599 const isActiveItem = store.useState((state) => state.activeId === null);
9600 props = {
9601 id,
9602 role: "combobox",
9603 "aria-autocomplete": ariaAutoComplete,
9604 "aria-haspopup": getPopupRole(contentElement, "listbox"),
9605 "aria-expanded": open,
9606 "aria-controls": contentElement == null ? void 0 : contentElement.id,
9607 "data-active-item": isActiveItem || void 0,
9608 value,
9609 ...props,
9610 ref: useMergeRefs(ref, props.ref),
9611 onChange,
9612 onCompositionEnd,
9613 onMouseDown,
9614 onKeyDown,
9615 onBlur
9616 };
9617 props = useComposite({
9618 store,
9619 focusable,
9620 ...props,
9621 // Enable inline autocomplete when the user moves from the combobox input
9622 // to an item.
9623 moveOnKeyPress: (event) => {
9624 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
9625 if (inline) setCanInline(true);
9626 return true;
9627 }
9628 });
9629 props = usePopoverAnchor({ store, ...props });
9630 return { autoComplete: "off", ...props };
9631 }
9632 );
9633 var Combobox = forwardRef22(function Combobox2(props) {
9634 const htmlProps = useCombobox(props);
9635 return createElement3(TagName9, htmlProps);
9636 });
9637
9638 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
9639 var import_react18 = __toESM(require_react(), 1);
9640 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
9641 var TagName10 = "div";
9642 function isSelected(storeValue, itemValue) {
9643 if (itemValue == null) return;
9644 if (storeValue == null) return false;
9645 if (Array.isArray(storeValue)) {
9646 return storeValue.includes(itemValue);
9647 }
9648 return storeValue === itemValue;
9649 }
9650 function getItemRole(popupRole) {
9651 var _a;
9652 const itemRoleByPopupRole = {
9653 menu: "menuitem",
9654 listbox: "option",
9655 tree: "treeitem"
9656 };
9657 const key = popupRole;
9658 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
9659 }
9660 var useComboboxItem = createHook(
9661 function useComboboxItem2({
9662 store,
9663 value,
9664 hideOnClick,
9665 setValueOnClick,
9666 selectValueOnClick = true,
9667 resetValueOnSelect,
9668 focusOnHover = false,
9669 moveOnKeyPress = true,
9670 getItem: getItemProp,
9671 ...props
9672 }) {
9673 var _a;
9674 const context = useComboboxScopedContext();
9675 store = store || context;
9676 invariant(
9677 store,
9678 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
9679 );
9680 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
9681 resetValueOnSelectState: "resetValueOnSelect",
9682 multiSelectable(state) {
9683 return Array.isArray(state.selectedValue);
9684 },
9685 selected(state) {
9686 return isSelected(state.selectedValue, value);
9687 }
9688 });
9689 const getItem = (0, import_react18.useCallback)(
9690 (item) => {
9691 const nextItem = { ...item, value };
9692 if (getItemProp) {
9693 return getItemProp(nextItem);
9694 }
9695 return nextItem;
9696 },
9697 [value, getItemProp]
9698 );
9699 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
9700 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
9701 const onClickProp = props.onClick;
9702 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9703 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
9704 const resetValueOnSelectProp = useBooleanEvent(
9705 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
9706 );
9707 const hideOnClickProp = useBooleanEvent(hideOnClick);
9708 const onClick = useEvent((event) => {
9709 onClickProp == null ? void 0 : onClickProp(event);
9710 if (event.defaultPrevented) return;
9711 if (isDownloading(event)) return;
9712 if (isOpeningInNewTab(event)) return;
9713 if (value != null) {
9714 if (selectValueOnClickProp(event)) {
9715 if (resetValueOnSelectProp(event)) {
9716 store == null ? void 0 : store.resetValue();
9717 }
9718 store == null ? void 0 : store.setSelectedValue((prevValue) => {
9719 if (!Array.isArray(prevValue)) return value;
9720 if (prevValue.includes(value)) {
9721 return prevValue.filter((v2) => v2 !== value);
9722 }
9723 return [...prevValue, value];
9724 });
9725 }
9726 if (setValueOnClickProp(event)) {
9727 store == null ? void 0 : store.setValue(value);
9728 }
9729 }
9730 if (hideOnClickProp(event)) {
9731 store == null ? void 0 : store.hide();
9732 }
9733 });
9734 const onKeyDownProp = props.onKeyDown;
9735 const onKeyDown = useEvent((event) => {
9736 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9737 if (event.defaultPrevented) return;
9738 const baseElement = store == null ? void 0 : store.getState().baseElement;
9739 if (!baseElement) return;
9740 if (hasFocus(baseElement)) return;
9741 const printable = event.key.length === 1;
9742 if (printable || event.key === "Backspace" || event.key === "Delete") {
9743 queueMicrotask(() => baseElement.focus());
9744 if (isTextField(baseElement)) {
9745 store == null ? void 0 : store.setValue(baseElement.value);
9746 }
9747 }
9748 });
9749 if (multiSelectable && selected != null) {
9750 props = {
9751 "aria-selected": selected,
9752 ...props
9753 };
9754 }
9755 props = useWrapElement(
9756 props,
9757 (element) => /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
9758 [value, selected]
9759 );
9760 const popupRole = (0, import_react18.useContext)(ComboboxListRoleContext);
9761 props = {
9762 role: getItemRole(popupRole),
9763 children: value,
9764 ...props,
9765 onClick,
9766 onKeyDown
9767 };
9768 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
9769 props = useCompositeItem({
9770 store,
9771 ...props,
9772 getItem,
9773 // Dispatch a custom event on the combobox input when moving to an item
9774 // with the keyboard so the Combobox component can enable inline
9775 // autocompletion.
9776 moveOnKeyPress: (event) => {
9777 if (!moveOnKeyPressProp(event)) return false;
9778 const moveEvent = new Event("combobox-item-move");
9779 const baseElement = store == null ? void 0 : store.getState().baseElement;
9780 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
9781 return true;
9782 }
9783 });
9784 props = useCompositeHover({ store, focusOnHover, ...props });
9785 return props;
9786 }
9787 );
9788 var ComboboxItem = memo22(
9789 forwardRef22(function ComboboxItem2(props) {
9790 const htmlProps = useComboboxItem(props);
9791 return createElement3(TagName10, htmlProps);
9792 })
9793 );
9794
9795 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
9796 var import_react19 = __toESM(require_react(), 1);
9797 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
9798 var TagName11 = "span";
9799 function normalizeValue(value) {
9800 return normalizeString(value).toLowerCase();
9801 }
9802 function getOffsets(string, values) {
9803 const offsets = [];
9804 for (const value of values) {
9805 let pos = 0;
9806 const length = value.length;
9807 while (string.indexOf(value, pos) !== -1) {
9808 const index = string.indexOf(value, pos);
9809 if (index !== -1) {
9810 offsets.push([index, length]);
9811 }
9812 pos = index + 1;
9813 }
9814 }
9815 return offsets;
9816 }
9817 function filterOverlappingOffsets(offsets) {
9818 return offsets.filter(([offset, length], i2, arr) => {
9819 return !arr.some(
9820 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
9821 );
9822 });
9823 }
9824 function sortOffsets(offsets) {
9825 return offsets.sort(([a2], [b2]) => a2 - b2);
9826 }
9827 function splitValue(itemValue, userValue) {
9828 if (!itemValue) return itemValue;
9829 if (!userValue) return itemValue;
9830 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
9831 const parts = [];
9832 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
9833 "span",
9834 {
9835 "data-autocomplete-value": autocomplete ? "" : void 0,
9836 "data-user-value": autocomplete ? void 0 : "",
9837 children: value
9838 },
9839 parts.length
9840 );
9841 const offsets = sortOffsets(
9842 filterOverlappingOffsets(
9843 // Convert userValues into a set to avoid duplicates
9844 getOffsets(normalizeValue(itemValue), new Set(userValues))
9845 )
9846 );
9847 if (!offsets.length) {
9848 parts.push(span(itemValue, true));
9849 return parts;
9850 }
9851 const [firstOffset] = offsets[0];
9852 const values = [
9853 itemValue.slice(0, firstOffset),
9854 ...offsets.flatMap(([offset, length], i2) => {
9855 var _a;
9856 const value = itemValue.slice(offset, offset + length);
9857 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
9858 const nextValue = itemValue.slice(offset + length, nextOffset);
9859 return [value, nextValue];
9860 })
9861 ];
9862 values.forEach((value, i2) => {
9863 if (!value) return;
9864 parts.push(span(value, i2 % 2 === 0));
9865 });
9866 return parts;
9867 }
9868 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
9869 const context = useComboboxScopedContext();
9870 store = store || context;
9871 const itemContext = (0, import_react19.useContext)(ComboboxItemValueContext);
9872 const itemValue = value != null ? value : itemContext;
9873 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
9874 const children = (0, import_react19.useMemo)(() => {
9875 if (!itemValue) return;
9876 if (!inputValue) return itemValue;
9877 return splitValue(itemValue, inputValue);
9878 }, [itemValue, inputValue]);
9879 props = {
9880 children,
9881 ...props
9882 };
9883 return removeUndefinedValues(props);
9884 });
9885 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
9886 const htmlProps = useComboboxItemValue(props);
9887 return createElement3(TagName11, htmlProps);
9888 });
9889
9890 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
9891 var TagName12 = "label";
9892 var useComboboxLabel = createHook(
9893 function useComboboxLabel2({ store, ...props }) {
9894 const context = useComboboxProviderContext();
9895 store = store || context;
9896 invariant(
9897 store,
9898 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
9899 );
9900 const comboboxId = store.useState((state) => {
9901 var _a;
9902 return (_a = state.baseElement) == null ? void 0 : _a.id;
9903 });
9904 props = {
9905 htmlFor: comboboxId,
9906 ...props
9907 };
9908 return removeUndefinedValues(props);
9909 }
9910 );
9911 var ComboboxLabel = memo22(
9912 forwardRef22(function ComboboxLabel2(props) {
9913 const htmlProps = useComboboxLabel(props);
9914 return createElement3(TagName12, htmlProps);
9915 })
9916 );
9917
9918 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
9919 var import_react20 = __toESM(require_react(), 1);
9920 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
9921 var TagName13 = "div";
9922 var useComboboxList = createHook(
9923 function useComboboxList2({ store, alwaysVisible, ...props }) {
9924 const scopedContext = useComboboxScopedContext(true);
9925 const context = useComboboxContext();
9926 store = store || context;
9927 const scopedContextSameStore = !!store && store === scopedContext;
9928 invariant(
9929 store,
9930 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
9931 );
9932 const ref = (0, import_react20.useRef)(null);
9933 const id = useId3(props.id);
9934 const mounted = store.useState("mounted");
9935 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
9936 const style = hidden ? { ...props.style, display: "none" } : props.style;
9937 const multiSelectable = store.useState(
9938 (state) => Array.isArray(state.selectedValue)
9939 );
9940 const role = useAttribute(ref, "role", props.role);
9941 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
9942 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
9943 const [hasListboxInside, setHasListboxInside] = (0, import_react20.useState)(false);
9944 const contentElement = store.useState("contentElement");
9945 useSafeLayoutEffect(() => {
9946 if (!mounted) return;
9947 const element = ref.current;
9948 if (!element) return;
9949 if (contentElement !== element) return;
9950 const callback = () => {
9951 setHasListboxInside(!!element.querySelector("[role='listbox']"));
9952 };
9953 const observer = new MutationObserver(callback);
9954 observer.observe(element, {
9955 subtree: true,
9956 childList: true,
9957 attributeFilter: ["role"]
9958 });
9959 callback();
9960 return () => observer.disconnect();
9961 }, [mounted, contentElement]);
9962 if (!hasListboxInside) {
9963 props = {
9964 role: "listbox",
9965 "aria-multiselectable": ariaMultiSelectable,
9966 ...props
9967 };
9968 }
9969 props = useWrapElement(
9970 props,
9971 (element) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
9972 [store, role]
9973 );
9974 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
9975 props = {
9976 id,
9977 hidden,
9978 ...props,
9979 ref: useMergeRefs(setContentElement, ref, props.ref),
9980 style
9981 };
9982 return removeUndefinedValues(props);
9983 }
9984 );
9985 var ComboboxList = forwardRef22(function ComboboxList2(props) {
9986 const htmlProps = useComboboxList(props);
9987 return createElement3(TagName13, htmlProps);
9988 });
9989
9990 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
9991 var import_react21 = __toESM(require_react(), 1);
9992 var TagValueContext = (0, import_react21.createContext)(null);
9993 var TagRemoveIdContext = (0, import_react21.createContext)(
9994 null
9995 );
9996 var ctx7 = createStoreContext(
9997 [CompositeContextProvider],
9998 [CompositeScopedContextProvider]
9999 );
10000 var useTagContext = ctx7.useContext;
10001 var useTagScopedContext = ctx7.useScopedContext;
10002 var useTagProviderContext = ctx7.useProviderContext;
10003 var TagContextProvider = ctx7.ContextProvider;
10004 var TagScopedContextProvider = ctx7.ScopedContextProvider;
10005
10006 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
10007 var isTouchSafari = isSafari() && isTouchDevice();
10008 function createComboboxStore({
10009 tag,
10010 ...props
10011 } = {}) {
10012 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
10013 throwOnConflictingProps(props, store);
10014 const tagState = tag == null ? void 0 : tag.getState();
10015 const syncState = store == null ? void 0 : store.getState();
10016 const activeId = defaultValue(
10017 props.activeId,
10018 syncState == null ? void 0 : syncState.activeId,
10019 props.defaultActiveId,
10020 null
10021 );
10022 const composite = createCompositeStore({
10023 ...props,
10024 activeId,
10025 includesBaseElement: defaultValue(
10026 props.includesBaseElement,
10027 syncState == null ? void 0 : syncState.includesBaseElement,
10028 true
10029 ),
10030 orientation: defaultValue(
10031 props.orientation,
10032 syncState == null ? void 0 : syncState.orientation,
10033 "vertical"
10034 ),
10035 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
10036 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
10037 virtualFocus: defaultValue(
10038 props.virtualFocus,
10039 syncState == null ? void 0 : syncState.virtualFocus,
10040 true
10041 )
10042 });
10043 const popover = createPopoverStore({
10044 ...props,
10045 placement: defaultValue(
10046 props.placement,
10047 syncState == null ? void 0 : syncState.placement,
10048 "bottom-start"
10049 )
10050 });
10051 const value = defaultValue(
10052 props.value,
10053 syncState == null ? void 0 : syncState.value,
10054 props.defaultValue,
10055 ""
10056 );
10057 const selectedValue = defaultValue(
10058 props.selectedValue,
10059 syncState == null ? void 0 : syncState.selectedValue,
10060 tagState == null ? void 0 : tagState.values,
10061 props.defaultSelectedValue,
10062 ""
10063 );
10064 const multiSelectable = Array.isArray(selectedValue);
10065 const initialState = {
10066 ...composite.getState(),
10067 ...popover.getState(),
10068 value,
10069 selectedValue,
10070 resetValueOnSelect: defaultValue(
10071 props.resetValueOnSelect,
10072 syncState == null ? void 0 : syncState.resetValueOnSelect,
10073 multiSelectable
10074 ),
10075 resetValueOnHide: defaultValue(
10076 props.resetValueOnHide,
10077 syncState == null ? void 0 : syncState.resetValueOnHide,
10078 multiSelectable && !tag
10079 ),
10080 activeValue: syncState == null ? void 0 : syncState.activeValue
10081 };
10082 const combobox = createStore(initialState, composite, popover, store);
10083 if (isTouchSafari) {
10084 setup(
10085 combobox,
10086 () => sync(combobox, ["virtualFocus"], () => {
10087 combobox.setState("virtualFocus", false);
10088 })
10089 );
10090 }
10091 setup(combobox, () => {
10092 if (!tag) return;
10093 return chain(
10094 sync(combobox, ["selectedValue"], (state) => {
10095 if (!Array.isArray(state.selectedValue)) return;
10096 tag.setValues(state.selectedValue);
10097 }),
10098 sync(tag, ["values"], (state) => {
10099 combobox.setState("selectedValue", state.values);
10100 })
10101 );
10102 });
10103 setup(
10104 combobox,
10105 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
10106 if (!state.resetValueOnHide) return;
10107 if (state.mounted) return;
10108 combobox.setState("value", value);
10109 })
10110 );
10111 setup(
10112 combobox,
10113 () => sync(combobox, ["open"], (state) => {
10114 if (state.open) return;
10115 combobox.setState("activeId", activeId);
10116 combobox.setState("moves", 0);
10117 })
10118 );
10119 setup(
10120 combobox,
10121 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
10122 if (state.moves === prevState.moves) {
10123 combobox.setState("activeValue", void 0);
10124 }
10125 })
10126 );
10127 setup(
10128 combobox,
10129 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
10130 if (state.moves === prev.moves) return;
10131 const { activeId: activeId2 } = combobox.getState();
10132 const activeItem = composite.item(activeId2);
10133 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
10134 })
10135 );
10136 return {
10137 ...popover,
10138 ...composite,
10139 ...combobox,
10140 tag,
10141 setValue: (value2) => combobox.setState("value", value2),
10142 resetValue: () => combobox.setState("value", initialState.value),
10143 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
10144 };
10145 }
10146
10147 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
10148 function useComboboxStoreOptions(props) {
10149 const tag = useTagContext();
10150 props = {
10151 ...props,
10152 tag: props.tag !== void 0 ? props.tag : tag
10153 };
10154 return useCompositeStoreOptions(props);
10155 }
10156 function useComboboxStoreProps(store, update2, props) {
10157 useUpdateEffect(update2, [props.tag]);
10158 useStoreProps(store, props, "value", "setValue");
10159 useStoreProps(store, props, "selectedValue", "setSelectedValue");
10160 useStoreProps(store, props, "resetValueOnHide");
10161 useStoreProps(store, props, "resetValueOnSelect");
10162 return Object.assign(
10163 useCompositeStoreProps(
10164 usePopoverStoreProps(store, update2, props),
10165 update2,
10166 props
10167 ),
10168 { tag: props.tag }
10169 );
10170 }
10171 function useComboboxStore(props = {}) {
10172 props = useComboboxStoreOptions(props);
10173 const [store, update2] = useStore(createComboboxStore, props);
10174 return useComboboxStoreProps(store, update2, props);
10175 }
10176
10177 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
10178 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
10179 function ComboboxProvider(props = {}) {
10180 const store = useComboboxStore(props);
10181 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ComboboxContextProvider, { value: store, children: props.children });
10182 }
10183
10184 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10185 var import_remove_accents = __toESM(require_remove_accents(), 1);
10186 var import_compose8 = __toESM(require_compose(), 1);
10187 var import_i18n28 = __toESM(require_i18n(), 1);
10188 var import_element25 = __toESM(require_element(), 1);
10189 var import_components19 = __toESM(require_components(), 1);
10190
10191 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
10192 var EMPTY_ARRAY3 = [];
10193 var getCurrentValue = (filterDefinition, currentFilter) => {
10194 if (filterDefinition.singleSelection) {
10195 return currentFilter?.value;
10196 }
10197 if (Array.isArray(currentFilter?.value)) {
10198 return currentFilter.value;
10199 }
10200 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
10201 return [currentFilter.value];
10202 }
10203 return EMPTY_ARRAY3;
10204 };
10205
10206 // packages/dataviews/build-module/hooks/use-elements.mjs
10207 var import_element24 = __toESM(require_element(), 1);
10208 var EMPTY_ARRAY4 = [];
10209 function useElements({
10210 elements,
10211 getElements
10212 }) {
10213 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
10214 const [records, setRecords] = (0, import_element24.useState)(staticElements);
10215 const [isLoading, setIsLoading] = (0, import_element24.useState)(false);
10216 (0, import_element24.useEffect)(() => {
10217 if (!getElements) {
10218 setRecords(staticElements);
10219 return;
10220 }
10221 let cancelled = false;
10222 setIsLoading(true);
10223 getElements().then((fetchedElements) => {
10224 if (!cancelled) {
10225 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
10226 setRecords(dynamicElements);
10227 }
10228 }).catch(() => {
10229 if (!cancelled) {
10230 setRecords(staticElements);
10231 }
10232 }).finally(() => {
10233 if (!cancelled) {
10234 setIsLoading(false);
10235 }
10236 });
10237 return () => {
10238 cancelled = true;
10239 };
10240 }, [getElements, staticElements]);
10241 return {
10242 elements: records,
10243 isLoading
10244 };
10245 }
10246
10247 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10248 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
10249 function normalizeSearchInput(input = "") {
10250 return (0, import_remove_accents.default)(input.trim().toLowerCase());
10251 }
10252 var getNewValue = (filterDefinition, currentFilter, value) => {
10253 if (filterDefinition.singleSelection) {
10254 return value;
10255 }
10256 if (Array.isArray(currentFilter?.value)) {
10257 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
10258 }
10259 return [value];
10260 };
10261 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
10262 return `${prefix}-${filterElementValue}`;
10263 }
10264 var MultiSelectionOption = ({ selected }) => {
10265 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10266 "span",
10267 {
10268 className: clsx_default(
10269 "dataviews-filters__search-widget-listitem-multi-selection",
10270 { "is-selected": selected }
10271 ),
10272 children: selected && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Icon, { icon: check_default })
10273 }
10274 );
10275 };
10276 var SingleSelectionOption = ({ selected }) => {
10277 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10278 "span",
10279 {
10280 className: clsx_default(
10281 "dataviews-filters__search-widget-listitem-single-selection",
10282 { "is-selected": selected }
10283 )
10284 }
10285 );
10286 };
10287 function ListBox({ view, filter, onChangeView }) {
10288 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
10289 const [activeCompositeId, setActiveCompositeId] = (0, import_element25.useState)(
10290 // When there are one or less operators, the first item is set as active
10291 // (by setting the initial `activeId` to `undefined`).
10292 // With 2 or more operators, the focus is moved on the operators control
10293 // (by setting the initial `activeId` to `null`), meaning that there won't
10294 // be an active item initially. Focus is then managed via the
10295 // `onFocusVisible` callback.
10296 filter.operators?.length === 1 ? void 0 : null
10297 );
10298 const currentFilter = view.filters?.find(
10299 (f2) => f2.field === filter.field
10300 );
10301 const currentValue = getCurrentValue(filter, currentFilter);
10302 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10303 import_components19.Composite,
10304 {
10305 virtualFocus: true,
10306 focusLoop: true,
10307 activeId: activeCompositeId,
10308 setActiveId: setActiveCompositeId,
10309 role: "listbox",
10310 className: "dataviews-filters__search-widget-listbox",
10311 "aria-label": (0, import_i18n28.sprintf)(
10312 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
10313 (0, import_i18n28.__)("List of: %1$s"),
10314 filter.name
10315 ),
10316 onFocusVisible: () => {
10317 if (!activeCompositeId && filter.elements.length) {
10318 setActiveCompositeId(
10319 generateFilterElementCompositeItemId(
10320 baseId,
10321 filter.elements[0].value
10322 )
10323 );
10324 }
10325 },
10326 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Composite.Typeahead, {}),
10327 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10328 import_components19.Composite.Hover,
10329 {
10330 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10331 import_components19.Composite.Item,
10332 {
10333 id: generateFilterElementCompositeItemId(
10334 baseId,
10335 element.value
10336 ),
10337 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10338 "div",
10339 {
10340 "aria-label": element.label,
10341 role: "option",
10342 className: "dataviews-filters__search-widget-listitem"
10343 }
10344 ),
10345 onClick: () => {
10346 const newFilters = currentFilter ? [
10347 ...(view.filters ?? []).map(
10348 (_filter) => {
10349 if (_filter.field === filter.field) {
10350 return {
10351 ..._filter,
10352 operator: currentFilter.operator || filter.operators[0],
10353 value: getNewValue(
10354 filter,
10355 currentFilter,
10356 element.value
10357 )
10358 };
10359 }
10360 return _filter;
10361 }
10362 )
10363 ] : [
10364 ...view.filters ?? [],
10365 {
10366 field: filter.field,
10367 operator: filter.operators[0],
10368 value: getNewValue(
10369 filter,
10370 currentFilter,
10371 element.value
10372 )
10373 }
10374 ];
10375 onChangeView({
10376 ...view,
10377 page: 1,
10378 filters: newFilters
10379 });
10380 }
10381 }
10382 ),
10383 children: [
10384 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10385 SingleSelectionOption,
10386 {
10387 selected: currentValue === element.value
10388 }
10389 ),
10390 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10391 MultiSelectionOption,
10392 {
10393 selected: currentValue.includes(element.value)
10394 }
10395 ),
10396 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10397 "span",
10398 {
10399 className: "dataviews-filters__search-widget-listitem-value",
10400 title: element.label,
10401 children: element.label
10402 }
10403 )
10404 ]
10405 },
10406 element.value
10407 ))
10408 }
10409 );
10410 }
10411 function ComboboxList22({ view, filter, onChangeView }) {
10412 const [searchValue, setSearchValue] = (0, import_element25.useState)("");
10413 const deferredSearchValue = (0, import_element25.useDeferredValue)(searchValue);
10414 const currentFilter = view.filters?.find(
10415 (_filter) => _filter.field === filter.field
10416 );
10417 const currentValue = getCurrentValue(filter, currentFilter);
10418 const matches = (0, import_element25.useMemo)(() => {
10419 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
10420 return filter.elements.filter(
10421 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
10422 );
10423 }, [filter.elements, deferredSearchValue]);
10424 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10425 ComboboxProvider,
10426 {
10427 selectedValue: currentValue,
10428 setSelectedValue: (value) => {
10429 const newFilters = currentFilter ? [
10430 ...(view.filters ?? []).map((_filter) => {
10431 if (_filter.field === filter.field) {
10432 return {
10433 ..._filter,
10434 operator: currentFilter.operator || filter.operators[0],
10435 value
10436 };
10437 }
10438 return _filter;
10439 })
10440 ] : [
10441 ...view.filters ?? [],
10442 {
10443 field: filter.field,
10444 operator: filter.operators[0],
10445 value
10446 }
10447 ];
10448 onChangeView({
10449 ...view,
10450 page: 1,
10451 filters: newFilters
10452 });
10453 },
10454 setValue: setSearchValue,
10455 children: [
10456 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
10457 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10458 ComboboxLabel,
10459 {
10460 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.VisuallyHidden, { children: (0, import_i18n28.__)("Search items") }),
10461 children: (0, import_i18n28.__)("Search items")
10462 }
10463 ),
10464 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10465 Combobox,
10466 {
10467 autoSelect: "always",
10468 placeholder: (0, import_i18n28.__)("Search"),
10469 className: "dataviews-filters__search-widget-filter-combobox__input"
10470 }
10471 ),
10472 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Icon, { icon: search_default }) })
10473 ] }),
10474 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10475 ComboboxList,
10476 {
10477 className: "dataviews-filters__search-widget-filter-combobox-list",
10478 alwaysVisible: true,
10479 children: [
10480 matches.map((element) => {
10481 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10482 ComboboxItem,
10483 {
10484 resetValueOnSelect: false,
10485 value: element.value,
10486 className: "dataviews-filters__search-widget-listitem",
10487 hideOnClick: false,
10488 setValueOnClick: false,
10489 focusOnHover: true,
10490 children: [
10491 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10492 SingleSelectionOption,
10493 {
10494 selected: currentValue === element.value
10495 }
10496 ),
10497 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10498 MultiSelectionOption,
10499 {
10500 selected: currentValue.includes(
10501 element.value
10502 )
10503 }
10504 ),
10505 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10506 "span",
10507 {
10508 className: "dataviews-filters__search-widget-listitem-value",
10509 title: element.label,
10510 children: [
10511 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10512 ComboboxItemValue,
10513 {
10514 className: "dataviews-filters__search-widget-filter-combobox-item-value",
10515 value: element.label
10516 }
10517 ),
10518 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
10519 ]
10520 }
10521 )
10522 ]
10523 },
10524 element.value
10525 );
10526 }),
10527 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: (0, import_i18n28.__)("No results found") })
10528 ]
10529 }
10530 )
10531 ]
10532 }
10533 );
10534 }
10535 function SearchWidget(props) {
10536 const { elements, isLoading } = useElements({
10537 elements: props.filter.elements,
10538 getElements: props.filter.getElements
10539 });
10540 if (isLoading) {
10541 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Spinner, {}) });
10542 }
10543 if (elements.length === 0) {
10544 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n28.__)("No elements found") });
10545 }
10546 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
10547 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
10548 }
10549
10550 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
10551 var import_es6 = __toESM(require_es6(), 1);
10552 var import_compose9 = __toESM(require_compose(), 1);
10553 var import_element26 = __toESM(require_element(), 1);
10554 var import_components20 = __toESM(require_components(), 1);
10555 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
10556 function InputWidget({
10557 filter,
10558 view,
10559 onChangeView,
10560 fields
10561 }) {
10562 const currentFilter = view.filters?.find(
10563 (f2) => f2.field === filter.field
10564 );
10565 const currentValue = getCurrentValue(filter, currentFilter);
10566 const field = (0, import_element26.useMemo)(() => {
10567 const currentField = fields.find((f2) => f2.id === filter.field);
10568 if (currentField) {
10569 return {
10570 ...currentField,
10571 // Deactivate validation for filters.
10572 isValid: {},
10573 // Configure getValue/setValue as if Item was a plain object.
10574 getValue: ({ item }) => item[currentField.id],
10575 setValue: ({ value }) => ({
10576 [currentField.id]: value
10577 })
10578 };
10579 }
10580 return currentField;
10581 }, [fields, filter.field]);
10582 const data = (0, import_element26.useMemo)(() => {
10583 return (view.filters ?? []).reduce(
10584 (acc, activeFilter) => {
10585 acc[activeFilter.field] = activeFilter.value;
10586 return acc;
10587 },
10588 {}
10589 );
10590 }, [view.filters]);
10591 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
10592 if (!field || !currentFilter) {
10593 return;
10594 }
10595 const nextValue = field.getValue({ item: updatedData });
10596 if ((0, import_es6.default)(nextValue, currentValue)) {
10597 return;
10598 }
10599 onChangeView({
10600 ...view,
10601 filters: (view.filters ?? []).map(
10602 (_filter) => _filter.field === filter.field ? {
10603 ..._filter,
10604 operator: currentFilter.operator || filter.operators[0],
10605 // Consider empty strings as undefined:
10606 //
10607 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
10608 // - empty string as value means "search empty string": returns only the records that have an empty string as value
10609 //
10610 // In practice, this means the filter will not be able to find an empty string as the value.
10611 value: nextValue === "" ? void 0 : nextValue
10612 } : _filter
10613 )
10614 });
10615 });
10616 if (!field || !field.Edit || !currentFilter) {
10617 return null;
10618 }
10619 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
10620 import_components20.Flex,
10621 {
10622 className: "dataviews-filters__user-input-widget",
10623 gap: 2.5,
10624 direction: "column",
10625 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
10626 field.Edit,
10627 {
10628 hideLabelFromVision: true,
10629 data,
10630 field,
10631 operator: currentFilter.operator,
10632 onChange: handleChange
10633 }
10634 )
10635 }
10636 );
10637 }
10638
10639 // packages/dataviews/node_modules/date-fns/constants.js
10640 var daysInYear = 365.2425;
10641 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
10642 var minTime = -maxTime;
10643 var millisecondsInWeek = 6048e5;
10644 var millisecondsInDay = 864e5;
10645 var secondsInHour = 3600;
10646 var secondsInDay = secondsInHour * 24;
10647 var secondsInWeek = secondsInDay * 7;
10648 var secondsInYear = secondsInDay * daysInYear;
10649 var secondsInMonth = secondsInYear / 12;
10650 var secondsInQuarter = secondsInMonth * 3;
10651 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
10652
10653 // packages/dataviews/node_modules/date-fns/constructFrom.js
10654 function constructFrom(date, value) {
10655 if (typeof date === "function") return date(value);
10656 if (date && typeof date === "object" && constructFromSymbol in date)
10657 return date[constructFromSymbol](value);
10658 if (date instanceof Date) return new date.constructor(value);
10659 return new Date(value);
10660 }
10661
10662 // packages/dataviews/node_modules/date-fns/toDate.js
10663 function toDate(argument, context) {
10664 return constructFrom(context || argument, argument);
10665 }
10666
10667 // packages/dataviews/node_modules/date-fns/addDays.js
10668 function addDays(date, amount, options) {
10669 const _date = toDate(date, options?.in);
10670 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10671 if (!amount) return _date;
10672 _date.setDate(_date.getDate() + amount);
10673 return _date;
10674 }
10675
10676 // packages/dataviews/node_modules/date-fns/addMonths.js
10677 function addMonths(date, amount, options) {
10678 const _date = toDate(date, options?.in);
10679 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10680 if (!amount) {
10681 return _date;
10682 }
10683 const dayOfMonth = _date.getDate();
10684 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
10685 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
10686 const daysInMonth = endOfDesiredMonth.getDate();
10687 if (dayOfMonth >= daysInMonth) {
10688 return endOfDesiredMonth;
10689 } else {
10690 _date.setFullYear(
10691 endOfDesiredMonth.getFullYear(),
10692 endOfDesiredMonth.getMonth(),
10693 dayOfMonth
10694 );
10695 return _date;
10696 }
10697 }
10698
10699 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
10700 var defaultOptions = {};
10701 function getDefaultOptions() {
10702 return defaultOptions;
10703 }
10704
10705 // packages/dataviews/node_modules/date-fns/startOfWeek.js
10706 function startOfWeek(date, options) {
10707 const defaultOptions2 = getDefaultOptions();
10708 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
10709 const _date = toDate(date, options?.in);
10710 const day = _date.getDay();
10711 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
10712 _date.setDate(_date.getDate() - diff);
10713 _date.setHours(0, 0, 0, 0);
10714 return _date;
10715 }
10716
10717 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
10718 function startOfISOWeek(date, options) {
10719 return startOfWeek(date, { ...options, weekStartsOn: 1 });
10720 }
10721
10722 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
10723 function getISOWeekYear(date, options) {
10724 const _date = toDate(date, options?.in);
10725 const year = _date.getFullYear();
10726 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
10727 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
10728 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
10729 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
10730 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
10731 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
10732 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
10733 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
10734 if (_date.getTime() >= startOfNextYear.getTime()) {
10735 return year + 1;
10736 } else if (_date.getTime() >= startOfThisYear.getTime()) {
10737 return year;
10738 } else {
10739 return year - 1;
10740 }
10741 }
10742
10743 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
10744 function getTimezoneOffsetInMilliseconds(date) {
10745 const _date = toDate(date);
10746 const utcDate = new Date(
10747 Date.UTC(
10748 _date.getFullYear(),
10749 _date.getMonth(),
10750 _date.getDate(),
10751 _date.getHours(),
10752 _date.getMinutes(),
10753 _date.getSeconds(),
10754 _date.getMilliseconds()
10755 )
10756 );
10757 utcDate.setUTCFullYear(_date.getFullYear());
10758 return +date - +utcDate;
10759 }
10760
10761 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
10762 function normalizeDates(context, ...dates) {
10763 const normalize = constructFrom.bind(
10764 null,
10765 context || dates.find((date) => typeof date === "object")
10766 );
10767 return dates.map(normalize);
10768 }
10769
10770 // packages/dataviews/node_modules/date-fns/startOfDay.js
10771 function startOfDay(date, options) {
10772 const _date = toDate(date, options?.in);
10773 _date.setHours(0, 0, 0, 0);
10774 return _date;
10775 }
10776
10777 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
10778 function differenceInCalendarDays(laterDate, earlierDate, options) {
10779 const [laterDate_, earlierDate_] = normalizeDates(
10780 options?.in,
10781 laterDate,
10782 earlierDate
10783 );
10784 const laterStartOfDay = startOfDay(laterDate_);
10785 const earlierStartOfDay = startOfDay(earlierDate_);
10786 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
10787 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
10788 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
10789 }
10790
10791 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
10792 function startOfISOWeekYear(date, options) {
10793 const year = getISOWeekYear(date, options);
10794 const fourthOfJanuary = constructFrom(options?.in || date, 0);
10795 fourthOfJanuary.setFullYear(year, 0, 4);
10796 fourthOfJanuary.setHours(0, 0, 0, 0);
10797 return startOfISOWeek(fourthOfJanuary);
10798 }
10799
10800 // packages/dataviews/node_modules/date-fns/addWeeks.js
10801 function addWeeks(date, amount, options) {
10802 return addDays(date, amount * 7, options);
10803 }
10804
10805 // packages/dataviews/node_modules/date-fns/addYears.js
10806 function addYears(date, amount, options) {
10807 return addMonths(date, amount * 12, options);
10808 }
10809
10810 // packages/dataviews/node_modules/date-fns/isDate.js
10811 function isDate(value) {
10812 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
10813 }
10814
10815 // packages/dataviews/node_modules/date-fns/isValid.js
10816 function isValid(date) {
10817 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
10818 }
10819
10820 // packages/dataviews/node_modules/date-fns/startOfMonth.js
10821 function startOfMonth(date, options) {
10822 const _date = toDate(date, options?.in);
10823 _date.setDate(1);
10824 _date.setHours(0, 0, 0, 0);
10825 return _date;
10826 }
10827
10828 // packages/dataviews/node_modules/date-fns/startOfYear.js
10829 function startOfYear(date, options) {
10830 const date_ = toDate(date, options?.in);
10831 date_.setFullYear(date_.getFullYear(), 0, 1);
10832 date_.setHours(0, 0, 0, 0);
10833 return date_;
10834 }
10835
10836 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
10837 var formatDistanceLocale = {
10838 lessThanXSeconds: {
10839 one: "less than a second",
10840 other: "less than {{count}} seconds"
10841 },
10842 xSeconds: {
10843 one: "1 second",
10844 other: "{{count}} seconds"
10845 },
10846 halfAMinute: "half a minute",
10847 lessThanXMinutes: {
10848 one: "less than a minute",
10849 other: "less than {{count}} minutes"
10850 },
10851 xMinutes: {
10852 one: "1 minute",
10853 other: "{{count}} minutes"
10854 },
10855 aboutXHours: {
10856 one: "about 1 hour",
10857 other: "about {{count}} hours"
10858 },
10859 xHours: {
10860 one: "1 hour",
10861 other: "{{count}} hours"
10862 },
10863 xDays: {
10864 one: "1 day",
10865 other: "{{count}} days"
10866 },
10867 aboutXWeeks: {
10868 one: "about 1 week",
10869 other: "about {{count}} weeks"
10870 },
10871 xWeeks: {
10872 one: "1 week",
10873 other: "{{count}} weeks"
10874 },
10875 aboutXMonths: {
10876 one: "about 1 month",
10877 other: "about {{count}} months"
10878 },
10879 xMonths: {
10880 one: "1 month",
10881 other: "{{count}} months"
10882 },
10883 aboutXYears: {
10884 one: "about 1 year",
10885 other: "about {{count}} years"
10886 },
10887 xYears: {
10888 one: "1 year",
10889 other: "{{count}} years"
10890 },
10891 overXYears: {
10892 one: "over 1 year",
10893 other: "over {{count}} years"
10894 },
10895 almostXYears: {
10896 one: "almost 1 year",
10897 other: "almost {{count}} years"
10898 }
10899 };
10900 var formatDistance = (token, count, options) => {
10901 let result;
10902 const tokenValue = formatDistanceLocale[token];
10903 if (typeof tokenValue === "string") {
10904 result = tokenValue;
10905 } else if (count === 1) {
10906 result = tokenValue.one;
10907 } else {
10908 result = tokenValue.other.replace("{{count}}", count.toString());
10909 }
10910 if (options?.addSuffix) {
10911 if (options.comparison && options.comparison > 0) {
10912 return "in " + result;
10913 } else {
10914 return result + " ago";
10915 }
10916 }
10917 return result;
10918 };
10919
10920 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
10921 function buildFormatLongFn(args) {
10922 return (options = {}) => {
10923 const width = options.width ? String(options.width) : args.defaultWidth;
10924 const format6 = args.formats[width] || args.formats[args.defaultWidth];
10925 return format6;
10926 };
10927 }
10928
10929 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
10930 var dateFormats = {
10931 full: "EEEE, MMMM do, y",
10932 long: "MMMM do, y",
10933 medium: "MMM d, y",
10934 short: "MM/dd/yyyy"
10935 };
10936 var timeFormats = {
10937 full: "h:mm:ss a zzzz",
10938 long: "h:mm:ss a z",
10939 medium: "h:mm:ss a",
10940 short: "h:mm a"
10941 };
10942 var dateTimeFormats = {
10943 full: "{{date}} 'at' {{time}}",
10944 long: "{{date}} 'at' {{time}}",
10945 medium: "{{date}}, {{time}}",
10946 short: "{{date}}, {{time}}"
10947 };
10948 var formatLong = {
10949 date: buildFormatLongFn({
10950 formats: dateFormats,
10951 defaultWidth: "full"
10952 }),
10953 time: buildFormatLongFn({
10954 formats: timeFormats,
10955 defaultWidth: "full"
10956 }),
10957 dateTime: buildFormatLongFn({
10958 formats: dateTimeFormats,
10959 defaultWidth: "full"
10960 })
10961 };
10962
10963 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
10964 var formatRelativeLocale = {
10965 lastWeek: "'last' eeee 'at' p",
10966 yesterday: "'yesterday at' p",
10967 today: "'today at' p",
10968 tomorrow: "'tomorrow at' p",
10969 nextWeek: "eeee 'at' p",
10970 other: "P"
10971 };
10972 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
10973
10974 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
10975 function buildLocalizeFn(args) {
10976 return (value, options) => {
10977 const context = options?.context ? String(options.context) : "standalone";
10978 let valuesArray;
10979 if (context === "formatting" && args.formattingValues) {
10980 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
10981 const width = options?.width ? String(options.width) : defaultWidth;
10982 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
10983 } else {
10984 const defaultWidth = args.defaultWidth;
10985 const width = options?.width ? String(options.width) : args.defaultWidth;
10986 valuesArray = args.values[width] || args.values[defaultWidth];
10987 }
10988 const index = args.argumentCallback ? args.argumentCallback(value) : value;
10989 return valuesArray[index];
10990 };
10991 }
10992
10993 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
10994 var eraValues = {
10995 narrow: ["B", "A"],
10996 abbreviated: ["BC", "AD"],
10997 wide: ["Before Christ", "Anno Domini"]
10998 };
10999 var quarterValues = {
11000 narrow: ["1", "2", "3", "4"],
11001 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
11002 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
11003 };
11004 var monthValues = {
11005 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
11006 abbreviated: [
11007 "Jan",
11008 "Feb",
11009 "Mar",
11010 "Apr",
11011 "May",
11012 "Jun",
11013 "Jul",
11014 "Aug",
11015 "Sep",
11016 "Oct",
11017 "Nov",
11018 "Dec"
11019 ],
11020 wide: [
11021 "January",
11022 "February",
11023 "March",
11024 "April",
11025 "May",
11026 "June",
11027 "July",
11028 "August",
11029 "September",
11030 "October",
11031 "November",
11032 "December"
11033 ]
11034 };
11035 var dayValues = {
11036 narrow: ["S", "M", "T", "W", "T", "F", "S"],
11037 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
11038 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
11039 wide: [
11040 "Sunday",
11041 "Monday",
11042 "Tuesday",
11043 "Wednesday",
11044 "Thursday",
11045 "Friday",
11046 "Saturday"
11047 ]
11048 };
11049 var dayPeriodValues = {
11050 narrow: {
11051 am: "a",
11052 pm: "p",
11053 midnight: "mi",
11054 noon: "n",
11055 morning: "morning",
11056 afternoon: "afternoon",
11057 evening: "evening",
11058 night: "night"
11059 },
11060 abbreviated: {
11061 am: "AM",
11062 pm: "PM",
11063 midnight: "midnight",
11064 noon: "noon",
11065 morning: "morning",
11066 afternoon: "afternoon",
11067 evening: "evening",
11068 night: "night"
11069 },
11070 wide: {
11071 am: "a.m.",
11072 pm: "p.m.",
11073 midnight: "midnight",
11074 noon: "noon",
11075 morning: "morning",
11076 afternoon: "afternoon",
11077 evening: "evening",
11078 night: "night"
11079 }
11080 };
11081 var formattingDayPeriodValues = {
11082 narrow: {
11083 am: "a",
11084 pm: "p",
11085 midnight: "mi",
11086 noon: "n",
11087 morning: "in the morning",
11088 afternoon: "in the afternoon",
11089 evening: "in the evening",
11090 night: "at night"
11091 },
11092 abbreviated: {
11093 am: "AM",
11094 pm: "PM",
11095 midnight: "midnight",
11096 noon: "noon",
11097 morning: "in the morning",
11098 afternoon: "in the afternoon",
11099 evening: "in the evening",
11100 night: "at night"
11101 },
11102 wide: {
11103 am: "a.m.",
11104 pm: "p.m.",
11105 midnight: "midnight",
11106 noon: "noon",
11107 morning: "in the morning",
11108 afternoon: "in the afternoon",
11109 evening: "in the evening",
11110 night: "at night"
11111 }
11112 };
11113 var ordinalNumber = (dirtyNumber, _options) => {
11114 const number = Number(dirtyNumber);
11115 const rem100 = number % 100;
11116 if (rem100 > 20 || rem100 < 10) {
11117 switch (rem100 % 10) {
11118 case 1:
11119 return number + "st";
11120 case 2:
11121 return number + "nd";
11122 case 3:
11123 return number + "rd";
11124 }
11125 }
11126 return number + "th";
11127 };
11128 var localize = {
11129 ordinalNumber,
11130 era: buildLocalizeFn({
11131 values: eraValues,
11132 defaultWidth: "wide"
11133 }),
11134 quarter: buildLocalizeFn({
11135 values: quarterValues,
11136 defaultWidth: "wide",
11137 argumentCallback: (quarter) => quarter - 1
11138 }),
11139 month: buildLocalizeFn({
11140 values: monthValues,
11141 defaultWidth: "wide"
11142 }),
11143 day: buildLocalizeFn({
11144 values: dayValues,
11145 defaultWidth: "wide"
11146 }),
11147 dayPeriod: buildLocalizeFn({
11148 values: dayPeriodValues,
11149 defaultWidth: "wide",
11150 formattingValues: formattingDayPeriodValues,
11151 defaultFormattingWidth: "wide"
11152 })
11153 };
11154
11155 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
11156 function buildMatchFn(args) {
11157 return (string, options = {}) => {
11158 const width = options.width;
11159 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
11160 const matchResult = string.match(matchPattern);
11161 if (!matchResult) {
11162 return null;
11163 }
11164 const matchedString = matchResult[0];
11165 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
11166 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
11167 // [TODO] -- I challenge you to fix the type
11168 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
11169 );
11170 let value;
11171 value = args.valueCallback ? args.valueCallback(key) : key;
11172 value = options.valueCallback ? (
11173 // [TODO] -- I challenge you to fix the type
11174 options.valueCallback(value)
11175 ) : value;
11176 const rest = string.slice(matchedString.length);
11177 return { value, rest };
11178 };
11179 }
11180 function findKey(object, predicate) {
11181 for (const key in object) {
11182 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
11183 return key;
11184 }
11185 }
11186 return void 0;
11187 }
11188 function findIndex(array, predicate) {
11189 for (let key = 0; key < array.length; key++) {
11190 if (predicate(array[key])) {
11191 return key;
11192 }
11193 }
11194 return void 0;
11195 }
11196
11197 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
11198 function buildMatchPatternFn(args) {
11199 return (string, options = {}) => {
11200 const matchResult = string.match(args.matchPattern);
11201 if (!matchResult) return null;
11202 const matchedString = matchResult[0];
11203 const parseResult = string.match(args.parsePattern);
11204 if (!parseResult) return null;
11205 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
11206 value = options.valueCallback ? options.valueCallback(value) : value;
11207 const rest = string.slice(matchedString.length);
11208 return { value, rest };
11209 };
11210 }
11211
11212 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
11213 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
11214 var parseOrdinalNumberPattern = /\d+/i;
11215 var matchEraPatterns = {
11216 narrow: /^(b|a)/i,
11217 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
11218 wide: /^(before christ|before common era|anno domini|common era)/i
11219 };
11220 var parseEraPatterns = {
11221 any: [/^b/i, /^(a|c)/i]
11222 };
11223 var matchQuarterPatterns = {
11224 narrow: /^[1234]/i,
11225 abbreviated: /^q[1234]/i,
11226 wide: /^[1234](th|st|nd|rd)? quarter/i
11227 };
11228 var parseQuarterPatterns = {
11229 any: [/1/i, /2/i, /3/i, /4/i]
11230 };
11231 var matchMonthPatterns = {
11232 narrow: /^[jfmasond]/i,
11233 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
11234 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
11235 };
11236 var parseMonthPatterns = {
11237 narrow: [
11238 /^j/i,
11239 /^f/i,
11240 /^m/i,
11241 /^a/i,
11242 /^m/i,
11243 /^j/i,
11244 /^j/i,
11245 /^a/i,
11246 /^s/i,
11247 /^o/i,
11248 /^n/i,
11249 /^d/i
11250 ],
11251 any: [
11252 /^ja/i,
11253 /^f/i,
11254 /^mar/i,
11255 /^ap/i,
11256 /^may/i,
11257 /^jun/i,
11258 /^jul/i,
11259 /^au/i,
11260 /^s/i,
11261 /^o/i,
11262 /^n/i,
11263 /^d/i
11264 ]
11265 };
11266 var matchDayPatterns = {
11267 narrow: /^[smtwf]/i,
11268 short: /^(su|mo|tu|we|th|fr|sa)/i,
11269 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
11270 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
11271 };
11272 var parseDayPatterns = {
11273 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
11274 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
11275 };
11276 var matchDayPeriodPatterns = {
11277 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
11278 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
11279 };
11280 var parseDayPeriodPatterns = {
11281 any: {
11282 am: /^a/i,
11283 pm: /^p/i,
11284 midnight: /^mi/i,
11285 noon: /^no/i,
11286 morning: /morning/i,
11287 afternoon: /afternoon/i,
11288 evening: /evening/i,
11289 night: /night/i
11290 }
11291 };
11292 var match = {
11293 ordinalNumber: buildMatchPatternFn({
11294 matchPattern: matchOrdinalNumberPattern,
11295 parsePattern: parseOrdinalNumberPattern,
11296 valueCallback: (value) => parseInt(value, 10)
11297 }),
11298 era: buildMatchFn({
11299 matchPatterns: matchEraPatterns,
11300 defaultMatchWidth: "wide",
11301 parsePatterns: parseEraPatterns,
11302 defaultParseWidth: "any"
11303 }),
11304 quarter: buildMatchFn({
11305 matchPatterns: matchQuarterPatterns,
11306 defaultMatchWidth: "wide",
11307 parsePatterns: parseQuarterPatterns,
11308 defaultParseWidth: "any",
11309 valueCallback: (index) => index + 1
11310 }),
11311 month: buildMatchFn({
11312 matchPatterns: matchMonthPatterns,
11313 defaultMatchWidth: "wide",
11314 parsePatterns: parseMonthPatterns,
11315 defaultParseWidth: "any"
11316 }),
11317 day: buildMatchFn({
11318 matchPatterns: matchDayPatterns,
11319 defaultMatchWidth: "wide",
11320 parsePatterns: parseDayPatterns,
11321 defaultParseWidth: "any"
11322 }),
11323 dayPeriod: buildMatchFn({
11324 matchPatterns: matchDayPeriodPatterns,
11325 defaultMatchWidth: "any",
11326 parsePatterns: parseDayPeriodPatterns,
11327 defaultParseWidth: "any"
11328 })
11329 };
11330
11331 // packages/dataviews/node_modules/date-fns/locale/en-US.js
11332 var enUS = {
11333 code: "en-US",
11334 formatDistance,
11335 formatLong,
11336 formatRelative,
11337 localize,
11338 match,
11339 options: {
11340 weekStartsOn: 0,
11341 firstWeekContainsDate: 1
11342 }
11343 };
11344
11345 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
11346 function getDayOfYear(date, options) {
11347 const _date = toDate(date, options?.in);
11348 const diff = differenceInCalendarDays(_date, startOfYear(_date));
11349 const dayOfYear = diff + 1;
11350 return dayOfYear;
11351 }
11352
11353 // packages/dataviews/node_modules/date-fns/getISOWeek.js
11354 function getISOWeek(date, options) {
11355 const _date = toDate(date, options?.in);
11356 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
11357 return Math.round(diff / millisecondsInWeek) + 1;
11358 }
11359
11360 // packages/dataviews/node_modules/date-fns/getWeekYear.js
11361 function getWeekYear(date, options) {
11362 const _date = toDate(date, options?.in);
11363 const year = _date.getFullYear();
11364 const defaultOptions2 = getDefaultOptions();
11365 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11366 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
11367 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
11368 firstWeekOfNextYear.setHours(0, 0, 0, 0);
11369 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
11370 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
11371 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
11372 firstWeekOfThisYear.setHours(0, 0, 0, 0);
11373 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
11374 if (+_date >= +startOfNextYear) {
11375 return year + 1;
11376 } else if (+_date >= +startOfThisYear) {
11377 return year;
11378 } else {
11379 return year - 1;
11380 }
11381 }
11382
11383 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
11384 function startOfWeekYear(date, options) {
11385 const defaultOptions2 = getDefaultOptions();
11386 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11387 const year = getWeekYear(date, options);
11388 const firstWeek = constructFrom(options?.in || date, 0);
11389 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
11390 firstWeek.setHours(0, 0, 0, 0);
11391 const _date = startOfWeek(firstWeek, options);
11392 return _date;
11393 }
11394
11395 // packages/dataviews/node_modules/date-fns/getWeek.js
11396 function getWeek(date, options) {
11397 const _date = toDate(date, options?.in);
11398 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
11399 return Math.round(diff / millisecondsInWeek) + 1;
11400 }
11401
11402 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
11403 function addLeadingZeros(number, targetLength) {
11404 const sign = number < 0 ? "-" : "";
11405 const output = Math.abs(number).toString().padStart(targetLength, "0");
11406 return sign + output;
11407 }
11408
11409 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
11410 var lightFormatters = {
11411 // Year
11412 y(date, token) {
11413 const signedYear = date.getFullYear();
11414 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11415 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
11416 },
11417 // Month
11418 M(date, token) {
11419 const month = date.getMonth();
11420 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
11421 },
11422 // Day of the month
11423 d(date, token) {
11424 return addLeadingZeros(date.getDate(), token.length);
11425 },
11426 // AM or PM
11427 a(date, token) {
11428 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
11429 switch (token) {
11430 case "a":
11431 case "aa":
11432 return dayPeriodEnumValue.toUpperCase();
11433 case "aaa":
11434 return dayPeriodEnumValue;
11435 case "aaaaa":
11436 return dayPeriodEnumValue[0];
11437 case "aaaa":
11438 default:
11439 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
11440 }
11441 },
11442 // Hour [1-12]
11443 h(date, token) {
11444 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
11445 },
11446 // Hour [0-23]
11447 H(date, token) {
11448 return addLeadingZeros(date.getHours(), token.length);
11449 },
11450 // Minute
11451 m(date, token) {
11452 return addLeadingZeros(date.getMinutes(), token.length);
11453 },
11454 // Second
11455 s(date, token) {
11456 return addLeadingZeros(date.getSeconds(), token.length);
11457 },
11458 // Fraction of second
11459 S(date, token) {
11460 const numberOfDigits = token.length;
11461 const milliseconds = date.getMilliseconds();
11462 const fractionalSeconds = Math.trunc(
11463 milliseconds * Math.pow(10, numberOfDigits - 3)
11464 );
11465 return addLeadingZeros(fractionalSeconds, token.length);
11466 }
11467 };
11468
11469 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
11470 var dayPeriodEnum = {
11471 am: "am",
11472 pm: "pm",
11473 midnight: "midnight",
11474 noon: "noon",
11475 morning: "morning",
11476 afternoon: "afternoon",
11477 evening: "evening",
11478 night: "night"
11479 };
11480 var formatters = {
11481 // Era
11482 G: function(date, token, localize2) {
11483 const era = date.getFullYear() > 0 ? 1 : 0;
11484 switch (token) {
11485 // AD, BC
11486 case "G":
11487 case "GG":
11488 case "GGG":
11489 return localize2.era(era, { width: "abbreviated" });
11490 // A, B
11491 case "GGGGG":
11492 return localize2.era(era, { width: "narrow" });
11493 // Anno Domini, Before Christ
11494 case "GGGG":
11495 default:
11496 return localize2.era(era, { width: "wide" });
11497 }
11498 },
11499 // Year
11500 y: function(date, token, localize2) {
11501 if (token === "yo") {
11502 const signedYear = date.getFullYear();
11503 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11504 return localize2.ordinalNumber(year, { unit: "year" });
11505 }
11506 return lightFormatters.y(date, token);
11507 },
11508 // Local week-numbering year
11509 Y: function(date, token, localize2, options) {
11510 const signedWeekYear = getWeekYear(date, options);
11511 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
11512 if (token === "YY") {
11513 const twoDigitYear = weekYear % 100;
11514 return addLeadingZeros(twoDigitYear, 2);
11515 }
11516 if (token === "Yo") {
11517 return localize2.ordinalNumber(weekYear, { unit: "year" });
11518 }
11519 return addLeadingZeros(weekYear, token.length);
11520 },
11521 // ISO week-numbering year
11522 R: function(date, token) {
11523 const isoWeekYear = getISOWeekYear(date);
11524 return addLeadingZeros(isoWeekYear, token.length);
11525 },
11526 // Extended year. This is a single number designating the year of this calendar system.
11527 // The main difference between `y` and `u` localizers are B.C. years:
11528 // | Year | `y` | `u` |
11529 // |------|-----|-----|
11530 // | AC 1 | 1 | 1 |
11531 // | BC 1 | 1 | 0 |
11532 // | BC 2 | 2 | -1 |
11533 // Also `yy` always returns the last two digits of a year,
11534 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
11535 u: function(date, token) {
11536 const year = date.getFullYear();
11537 return addLeadingZeros(year, token.length);
11538 },
11539 // Quarter
11540 Q: function(date, token, localize2) {
11541 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11542 switch (token) {
11543 // 1, 2, 3, 4
11544 case "Q":
11545 return String(quarter);
11546 // 01, 02, 03, 04
11547 case "QQ":
11548 return addLeadingZeros(quarter, 2);
11549 // 1st, 2nd, 3rd, 4th
11550 case "Qo":
11551 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11552 // Q1, Q2, Q3, Q4
11553 case "QQQ":
11554 return localize2.quarter(quarter, {
11555 width: "abbreviated",
11556 context: "formatting"
11557 });
11558 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11559 case "QQQQQ":
11560 return localize2.quarter(quarter, {
11561 width: "narrow",
11562 context: "formatting"
11563 });
11564 // 1st quarter, 2nd quarter, ...
11565 case "QQQQ":
11566 default:
11567 return localize2.quarter(quarter, {
11568 width: "wide",
11569 context: "formatting"
11570 });
11571 }
11572 },
11573 // Stand-alone quarter
11574 q: function(date, token, localize2) {
11575 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11576 switch (token) {
11577 // 1, 2, 3, 4
11578 case "q":
11579 return String(quarter);
11580 // 01, 02, 03, 04
11581 case "qq":
11582 return addLeadingZeros(quarter, 2);
11583 // 1st, 2nd, 3rd, 4th
11584 case "qo":
11585 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11586 // Q1, Q2, Q3, Q4
11587 case "qqq":
11588 return localize2.quarter(quarter, {
11589 width: "abbreviated",
11590 context: "standalone"
11591 });
11592 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11593 case "qqqqq":
11594 return localize2.quarter(quarter, {
11595 width: "narrow",
11596 context: "standalone"
11597 });
11598 // 1st quarter, 2nd quarter, ...
11599 case "qqqq":
11600 default:
11601 return localize2.quarter(quarter, {
11602 width: "wide",
11603 context: "standalone"
11604 });
11605 }
11606 },
11607 // Month
11608 M: function(date, token, localize2) {
11609 const month = date.getMonth();
11610 switch (token) {
11611 case "M":
11612 case "MM":
11613 return lightFormatters.M(date, token);
11614 // 1st, 2nd, ..., 12th
11615 case "Mo":
11616 return localize2.ordinalNumber(month + 1, { unit: "month" });
11617 // Jan, Feb, ..., Dec
11618 case "MMM":
11619 return localize2.month(month, {
11620 width: "abbreviated",
11621 context: "formatting"
11622 });
11623 // J, F, ..., D
11624 case "MMMMM":
11625 return localize2.month(month, {
11626 width: "narrow",
11627 context: "formatting"
11628 });
11629 // January, February, ..., December
11630 case "MMMM":
11631 default:
11632 return localize2.month(month, { width: "wide", context: "formatting" });
11633 }
11634 },
11635 // Stand-alone month
11636 L: function(date, token, localize2) {
11637 const month = date.getMonth();
11638 switch (token) {
11639 // 1, 2, ..., 12
11640 case "L":
11641 return String(month + 1);
11642 // 01, 02, ..., 12
11643 case "LL":
11644 return addLeadingZeros(month + 1, 2);
11645 // 1st, 2nd, ..., 12th
11646 case "Lo":
11647 return localize2.ordinalNumber(month + 1, { unit: "month" });
11648 // Jan, Feb, ..., Dec
11649 case "LLL":
11650 return localize2.month(month, {
11651 width: "abbreviated",
11652 context: "standalone"
11653 });
11654 // J, F, ..., D
11655 case "LLLLL":
11656 return localize2.month(month, {
11657 width: "narrow",
11658 context: "standalone"
11659 });
11660 // January, February, ..., December
11661 case "LLLL":
11662 default:
11663 return localize2.month(month, { width: "wide", context: "standalone" });
11664 }
11665 },
11666 // Local week of year
11667 w: function(date, token, localize2, options) {
11668 const week = getWeek(date, options);
11669 if (token === "wo") {
11670 return localize2.ordinalNumber(week, { unit: "week" });
11671 }
11672 return addLeadingZeros(week, token.length);
11673 },
11674 // ISO week of year
11675 I: function(date, token, localize2) {
11676 const isoWeek = getISOWeek(date);
11677 if (token === "Io") {
11678 return localize2.ordinalNumber(isoWeek, { unit: "week" });
11679 }
11680 return addLeadingZeros(isoWeek, token.length);
11681 },
11682 // Day of the month
11683 d: function(date, token, localize2) {
11684 if (token === "do") {
11685 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
11686 }
11687 return lightFormatters.d(date, token);
11688 },
11689 // Day of year
11690 D: function(date, token, localize2) {
11691 const dayOfYear = getDayOfYear(date);
11692 if (token === "Do") {
11693 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
11694 }
11695 return addLeadingZeros(dayOfYear, token.length);
11696 },
11697 // Day of week
11698 E: function(date, token, localize2) {
11699 const dayOfWeek = date.getDay();
11700 switch (token) {
11701 // Tue
11702 case "E":
11703 case "EE":
11704 case "EEE":
11705 return localize2.day(dayOfWeek, {
11706 width: "abbreviated",
11707 context: "formatting"
11708 });
11709 // T
11710 case "EEEEE":
11711 return localize2.day(dayOfWeek, {
11712 width: "narrow",
11713 context: "formatting"
11714 });
11715 // Tu
11716 case "EEEEEE":
11717 return localize2.day(dayOfWeek, {
11718 width: "short",
11719 context: "formatting"
11720 });
11721 // Tuesday
11722 case "EEEE":
11723 default:
11724 return localize2.day(dayOfWeek, {
11725 width: "wide",
11726 context: "formatting"
11727 });
11728 }
11729 },
11730 // Local day of week
11731 e: function(date, token, localize2, options) {
11732 const dayOfWeek = date.getDay();
11733 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11734 switch (token) {
11735 // Numerical value (Nth day of week with current locale or weekStartsOn)
11736 case "e":
11737 return String(localDayOfWeek);
11738 // Padded numerical value
11739 case "ee":
11740 return addLeadingZeros(localDayOfWeek, 2);
11741 // 1st, 2nd, ..., 7th
11742 case "eo":
11743 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11744 case "eee":
11745 return localize2.day(dayOfWeek, {
11746 width: "abbreviated",
11747 context: "formatting"
11748 });
11749 // T
11750 case "eeeee":
11751 return localize2.day(dayOfWeek, {
11752 width: "narrow",
11753 context: "formatting"
11754 });
11755 // Tu
11756 case "eeeeee":
11757 return localize2.day(dayOfWeek, {
11758 width: "short",
11759 context: "formatting"
11760 });
11761 // Tuesday
11762 case "eeee":
11763 default:
11764 return localize2.day(dayOfWeek, {
11765 width: "wide",
11766 context: "formatting"
11767 });
11768 }
11769 },
11770 // Stand-alone local day of week
11771 c: function(date, token, localize2, options) {
11772 const dayOfWeek = date.getDay();
11773 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11774 switch (token) {
11775 // Numerical value (same as in `e`)
11776 case "c":
11777 return String(localDayOfWeek);
11778 // Padded numerical value
11779 case "cc":
11780 return addLeadingZeros(localDayOfWeek, token.length);
11781 // 1st, 2nd, ..., 7th
11782 case "co":
11783 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11784 case "ccc":
11785 return localize2.day(dayOfWeek, {
11786 width: "abbreviated",
11787 context: "standalone"
11788 });
11789 // T
11790 case "ccccc":
11791 return localize2.day(dayOfWeek, {
11792 width: "narrow",
11793 context: "standalone"
11794 });
11795 // Tu
11796 case "cccccc":
11797 return localize2.day(dayOfWeek, {
11798 width: "short",
11799 context: "standalone"
11800 });
11801 // Tuesday
11802 case "cccc":
11803 default:
11804 return localize2.day(dayOfWeek, {
11805 width: "wide",
11806 context: "standalone"
11807 });
11808 }
11809 },
11810 // ISO day of week
11811 i: function(date, token, localize2) {
11812 const dayOfWeek = date.getDay();
11813 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
11814 switch (token) {
11815 // 2
11816 case "i":
11817 return String(isoDayOfWeek);
11818 // 02
11819 case "ii":
11820 return addLeadingZeros(isoDayOfWeek, token.length);
11821 // 2nd
11822 case "io":
11823 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
11824 // Tue
11825 case "iii":
11826 return localize2.day(dayOfWeek, {
11827 width: "abbreviated",
11828 context: "formatting"
11829 });
11830 // T
11831 case "iiiii":
11832 return localize2.day(dayOfWeek, {
11833 width: "narrow",
11834 context: "formatting"
11835 });
11836 // Tu
11837 case "iiiiii":
11838 return localize2.day(dayOfWeek, {
11839 width: "short",
11840 context: "formatting"
11841 });
11842 // Tuesday
11843 case "iiii":
11844 default:
11845 return localize2.day(dayOfWeek, {
11846 width: "wide",
11847 context: "formatting"
11848 });
11849 }
11850 },
11851 // AM or PM
11852 a: function(date, token, localize2) {
11853 const hours = date.getHours();
11854 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11855 switch (token) {
11856 case "a":
11857 case "aa":
11858 return localize2.dayPeriod(dayPeriodEnumValue, {
11859 width: "abbreviated",
11860 context: "formatting"
11861 });
11862 case "aaa":
11863 return localize2.dayPeriod(dayPeriodEnumValue, {
11864 width: "abbreviated",
11865 context: "formatting"
11866 }).toLowerCase();
11867 case "aaaaa":
11868 return localize2.dayPeriod(dayPeriodEnumValue, {
11869 width: "narrow",
11870 context: "formatting"
11871 });
11872 case "aaaa":
11873 default:
11874 return localize2.dayPeriod(dayPeriodEnumValue, {
11875 width: "wide",
11876 context: "formatting"
11877 });
11878 }
11879 },
11880 // AM, PM, midnight, noon
11881 b: function(date, token, localize2) {
11882 const hours = date.getHours();
11883 let dayPeriodEnumValue;
11884 if (hours === 12) {
11885 dayPeriodEnumValue = dayPeriodEnum.noon;
11886 } else if (hours === 0) {
11887 dayPeriodEnumValue = dayPeriodEnum.midnight;
11888 } else {
11889 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11890 }
11891 switch (token) {
11892 case "b":
11893 case "bb":
11894 return localize2.dayPeriod(dayPeriodEnumValue, {
11895 width: "abbreviated",
11896 context: "formatting"
11897 });
11898 case "bbb":
11899 return localize2.dayPeriod(dayPeriodEnumValue, {
11900 width: "abbreviated",
11901 context: "formatting"
11902 }).toLowerCase();
11903 case "bbbbb":
11904 return localize2.dayPeriod(dayPeriodEnumValue, {
11905 width: "narrow",
11906 context: "formatting"
11907 });
11908 case "bbbb":
11909 default:
11910 return localize2.dayPeriod(dayPeriodEnumValue, {
11911 width: "wide",
11912 context: "formatting"
11913 });
11914 }
11915 },
11916 // in the morning, in the afternoon, in the evening, at night
11917 B: function(date, token, localize2) {
11918 const hours = date.getHours();
11919 let dayPeriodEnumValue;
11920 if (hours >= 17) {
11921 dayPeriodEnumValue = dayPeriodEnum.evening;
11922 } else if (hours >= 12) {
11923 dayPeriodEnumValue = dayPeriodEnum.afternoon;
11924 } else if (hours >= 4) {
11925 dayPeriodEnumValue = dayPeriodEnum.morning;
11926 } else {
11927 dayPeriodEnumValue = dayPeriodEnum.night;
11928 }
11929 switch (token) {
11930 case "B":
11931 case "BB":
11932 case "BBB":
11933 return localize2.dayPeriod(dayPeriodEnumValue, {
11934 width: "abbreviated",
11935 context: "formatting"
11936 });
11937 case "BBBBB":
11938 return localize2.dayPeriod(dayPeriodEnumValue, {
11939 width: "narrow",
11940 context: "formatting"
11941 });
11942 case "BBBB":
11943 default:
11944 return localize2.dayPeriod(dayPeriodEnumValue, {
11945 width: "wide",
11946 context: "formatting"
11947 });
11948 }
11949 },
11950 // Hour [1-12]
11951 h: function(date, token, localize2) {
11952 if (token === "ho") {
11953 let hours = date.getHours() % 12;
11954 if (hours === 0) hours = 12;
11955 return localize2.ordinalNumber(hours, { unit: "hour" });
11956 }
11957 return lightFormatters.h(date, token);
11958 },
11959 // Hour [0-23]
11960 H: function(date, token, localize2) {
11961 if (token === "Ho") {
11962 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
11963 }
11964 return lightFormatters.H(date, token);
11965 },
11966 // Hour [0-11]
11967 K: function(date, token, localize2) {
11968 const hours = date.getHours() % 12;
11969 if (token === "Ko") {
11970 return localize2.ordinalNumber(hours, { unit: "hour" });
11971 }
11972 return addLeadingZeros(hours, token.length);
11973 },
11974 // Hour [1-24]
11975 k: function(date, token, localize2) {
11976 let hours = date.getHours();
11977 if (hours === 0) hours = 24;
11978 if (token === "ko") {
11979 return localize2.ordinalNumber(hours, { unit: "hour" });
11980 }
11981 return addLeadingZeros(hours, token.length);
11982 },
11983 // Minute
11984 m: function(date, token, localize2) {
11985 if (token === "mo") {
11986 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
11987 }
11988 return lightFormatters.m(date, token);
11989 },
11990 // Second
11991 s: function(date, token, localize2) {
11992 if (token === "so") {
11993 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
11994 }
11995 return lightFormatters.s(date, token);
11996 },
11997 // Fraction of second
11998 S: function(date, token) {
11999 return lightFormatters.S(date, token);
12000 },
12001 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
12002 X: function(date, token, _localize) {
12003 const timezoneOffset = date.getTimezoneOffset();
12004 if (timezoneOffset === 0) {
12005 return "Z";
12006 }
12007 switch (token) {
12008 // Hours and optional minutes
12009 case "X":
12010 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12011 // Hours, minutes and optional seconds without `:` delimiter
12012 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12013 // so this token always has the same output as `XX`
12014 case "XXXX":
12015 case "XX":
12016 return formatTimezone(timezoneOffset);
12017 // Hours, minutes and optional seconds with `:` delimiter
12018 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12019 // so this token always has the same output as `XXX`
12020 case "XXXXX":
12021 case "XXX":
12022 // Hours and minutes with `:` delimiter
12023 default:
12024 return formatTimezone(timezoneOffset, ":");
12025 }
12026 },
12027 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
12028 x: function(date, token, _localize) {
12029 const timezoneOffset = date.getTimezoneOffset();
12030 switch (token) {
12031 // Hours and optional minutes
12032 case "x":
12033 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12034 // Hours, minutes and optional seconds without `:` delimiter
12035 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12036 // so this token always has the same output as `xx`
12037 case "xxxx":
12038 case "xx":
12039 return formatTimezone(timezoneOffset);
12040 // Hours, minutes and optional seconds with `:` delimiter
12041 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12042 // so this token always has the same output as `xxx`
12043 case "xxxxx":
12044 case "xxx":
12045 // Hours and minutes with `:` delimiter
12046 default:
12047 return formatTimezone(timezoneOffset, ":");
12048 }
12049 },
12050 // Timezone (GMT)
12051 O: function(date, token, _localize) {
12052 const timezoneOffset = date.getTimezoneOffset();
12053 switch (token) {
12054 // Short
12055 case "O":
12056 case "OO":
12057 case "OOO":
12058 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12059 // Long
12060 case "OOOO":
12061 default:
12062 return "GMT" + formatTimezone(timezoneOffset, ":");
12063 }
12064 },
12065 // Timezone (specific non-location)
12066 z: function(date, token, _localize) {
12067 const timezoneOffset = date.getTimezoneOffset();
12068 switch (token) {
12069 // Short
12070 case "z":
12071 case "zz":
12072 case "zzz":
12073 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12074 // Long
12075 case "zzzz":
12076 default:
12077 return "GMT" + formatTimezone(timezoneOffset, ":");
12078 }
12079 },
12080 // Seconds timestamp
12081 t: function(date, token, _localize) {
12082 const timestamp = Math.trunc(+date / 1e3);
12083 return addLeadingZeros(timestamp, token.length);
12084 },
12085 // Milliseconds timestamp
12086 T: function(date, token, _localize) {
12087 return addLeadingZeros(+date, token.length);
12088 }
12089 };
12090 function formatTimezoneShort(offset, delimiter = "") {
12091 const sign = offset > 0 ? "-" : "+";
12092 const absOffset = Math.abs(offset);
12093 const hours = Math.trunc(absOffset / 60);
12094 const minutes = absOffset % 60;
12095 if (minutes === 0) {
12096 return sign + String(hours);
12097 }
12098 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
12099 }
12100 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
12101 if (offset % 60 === 0) {
12102 const sign = offset > 0 ? "-" : "+";
12103 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
12104 }
12105 return formatTimezone(offset, delimiter);
12106 }
12107 function formatTimezone(offset, delimiter = "") {
12108 const sign = offset > 0 ? "-" : "+";
12109 const absOffset = Math.abs(offset);
12110 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
12111 const minutes = addLeadingZeros(absOffset % 60, 2);
12112 return sign + hours + delimiter + minutes;
12113 }
12114
12115 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
12116 var dateLongFormatter = (pattern, formatLong2) => {
12117 switch (pattern) {
12118 case "P":
12119 return formatLong2.date({ width: "short" });
12120 case "PP":
12121 return formatLong2.date({ width: "medium" });
12122 case "PPP":
12123 return formatLong2.date({ width: "long" });
12124 case "PPPP":
12125 default:
12126 return formatLong2.date({ width: "full" });
12127 }
12128 };
12129 var timeLongFormatter = (pattern, formatLong2) => {
12130 switch (pattern) {
12131 case "p":
12132 return formatLong2.time({ width: "short" });
12133 case "pp":
12134 return formatLong2.time({ width: "medium" });
12135 case "ppp":
12136 return formatLong2.time({ width: "long" });
12137 case "pppp":
12138 default:
12139 return formatLong2.time({ width: "full" });
12140 }
12141 };
12142 var dateTimeLongFormatter = (pattern, formatLong2) => {
12143 const matchResult = pattern.match(/(P+)(p+)?/) || [];
12144 const datePattern = matchResult[1];
12145 const timePattern = matchResult[2];
12146 if (!timePattern) {
12147 return dateLongFormatter(pattern, formatLong2);
12148 }
12149 let dateTimeFormat;
12150 switch (datePattern) {
12151 case "P":
12152 dateTimeFormat = formatLong2.dateTime({ width: "short" });
12153 break;
12154 case "PP":
12155 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
12156 break;
12157 case "PPP":
12158 dateTimeFormat = formatLong2.dateTime({ width: "long" });
12159 break;
12160 case "PPPP":
12161 default:
12162 dateTimeFormat = formatLong2.dateTime({ width: "full" });
12163 break;
12164 }
12165 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
12166 };
12167 var longFormatters = {
12168 p: timeLongFormatter,
12169 P: dateTimeLongFormatter
12170 };
12171
12172 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
12173 var dayOfYearTokenRE = /^D+$/;
12174 var weekYearTokenRE = /^Y+$/;
12175 var throwTokens = ["D", "DD", "YY", "YYYY"];
12176 function isProtectedDayOfYearToken(token) {
12177 return dayOfYearTokenRE.test(token);
12178 }
12179 function isProtectedWeekYearToken(token) {
12180 return weekYearTokenRE.test(token);
12181 }
12182 function warnOrThrowProtectedError(token, format6, input) {
12183 const _message = message(token, format6, input);
12184 console.warn(_message);
12185 if (throwTokens.includes(token)) throw new RangeError(_message);
12186 }
12187 function message(token, format6, input) {
12188 const subject = token[0] === "Y" ? "years" : "days of the month";
12189 return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format6}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
12190 }
12191
12192 // packages/dataviews/node_modules/date-fns/format.js
12193 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
12194 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
12195 var escapedStringRegExp = /^'([^]*?)'?$/;
12196 var doubleQuoteRegExp = /''/g;
12197 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
12198 function format(date, formatStr, options) {
12199 const defaultOptions2 = getDefaultOptions();
12200 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
12201 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
12202 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12203 const originalDate = toDate(date, options?.in);
12204 if (!isValid(originalDate)) {
12205 throw new RangeError("Invalid time value");
12206 }
12207 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
12208 const firstCharacter = substring[0];
12209 if (firstCharacter === "p" || firstCharacter === "P") {
12210 const longFormatter = longFormatters[firstCharacter];
12211 return longFormatter(substring, locale.formatLong);
12212 }
12213 return substring;
12214 }).join("").match(formattingTokensRegExp).map((substring) => {
12215 if (substring === "''") {
12216 return { isToken: false, value: "'" };
12217 }
12218 const firstCharacter = substring[0];
12219 if (firstCharacter === "'") {
12220 return { isToken: false, value: cleanEscapedString(substring) };
12221 }
12222 if (formatters[firstCharacter]) {
12223 return { isToken: true, value: substring };
12224 }
12225 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
12226 throw new RangeError(
12227 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
12228 );
12229 }
12230 return { isToken: false, value: substring };
12231 });
12232 if (locale.localize.preprocessor) {
12233 parts = locale.localize.preprocessor(originalDate, parts);
12234 }
12235 const formatterOptions = {
12236 firstWeekContainsDate,
12237 weekStartsOn,
12238 locale
12239 };
12240 return parts.map((part) => {
12241 if (!part.isToken) return part.value;
12242 const token = part.value;
12243 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
12244 warnOrThrowProtectedError(token, formatStr, String(date));
12245 }
12246 const formatter = formatters[token[0]];
12247 return formatter(originalDate, token, locale.localize, formatterOptions);
12248 }).join("");
12249 }
12250 function cleanEscapedString(input) {
12251 const matched = input.match(escapedStringRegExp);
12252 if (!matched) {
12253 return input;
12254 }
12255 return matched[1].replace(doubleQuoteRegExp, "'");
12256 }
12257
12258 // packages/dataviews/node_modules/date-fns/subDays.js
12259 function subDays(date, amount, options) {
12260 return addDays(date, -amount, options);
12261 }
12262
12263 // packages/dataviews/node_modules/date-fns/subMonths.js
12264 function subMonths(date, amount, options) {
12265 return addMonths(date, -amount, options);
12266 }
12267
12268 // packages/dataviews/node_modules/date-fns/subWeeks.js
12269 function subWeeks(date, amount, options) {
12270 return addWeeks(date, -amount, options);
12271 }
12272
12273 // packages/dataviews/node_modules/date-fns/subYears.js
12274 function subYears(date, amount, options) {
12275 return addYears(date, -amount, options);
12276 }
12277
12278 // packages/dataviews/build-module/utils/operators.mjs
12279 var import_i18n29 = __toESM(require_i18n(), 1);
12280 var import_element27 = __toESM(require_element(), 1);
12281 var import_date = __toESM(require_date(), 1);
12282 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
12283 var filterTextWrappers = {
12284 Name: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
12285 Value: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
12286 };
12287 function getRelativeDate(value, unit) {
12288 switch (unit) {
12289 case "days":
12290 return subDays(/* @__PURE__ */ new Date(), value);
12291 case "weeks":
12292 return subWeeks(/* @__PURE__ */ new Date(), value);
12293 case "months":
12294 return subMonths(/* @__PURE__ */ new Date(), value);
12295 case "years":
12296 return subYears(/* @__PURE__ */ new Date(), value);
12297 default:
12298 return /* @__PURE__ */ new Date();
12299 }
12300 }
12301 var isNoneOperatorDefinition = {
12302 /* translators: DataViews operator name */
12303 label: (0, import_i18n29.__)("Is none of"),
12304 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12305 (0, import_i18n29.sprintf)(
12306 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
12307 (0, import_i18n29.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
12308 filter.name,
12309 activeElements.map((element) => element.label).join(", ")
12310 ),
12311 filterTextWrappers
12312 ),
12313 filter: ((item, field, filterValue) => {
12314 if (!filterValue?.length) {
12315 return true;
12316 }
12317 const fieldValue = field.getValue({ item });
12318 if (Array.isArray(fieldValue)) {
12319 return !filterValue.some(
12320 (fv) => fieldValue.includes(fv)
12321 );
12322 } else if (typeof fieldValue === "string") {
12323 return !filterValue.includes(fieldValue);
12324 }
12325 return false;
12326 }),
12327 selection: "multi"
12328 };
12329 var OPERATORS = [
12330 {
12331 name: OPERATOR_IS_ANY,
12332 /* translators: DataViews operator name */
12333 label: (0, import_i18n29.__)("Includes"),
12334 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12335 (0, import_i18n29.sprintf)(
12336 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
12337 (0, import_i18n29.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
12338 filter.name,
12339 activeElements.map((element) => element.label).join(", ")
12340 ),
12341 filterTextWrappers
12342 ),
12343 filter(item, field, filterValue) {
12344 if (!filterValue?.length) {
12345 return true;
12346 }
12347 const fieldValue = field.getValue({ item });
12348 if (Array.isArray(fieldValue)) {
12349 return filterValue.some(
12350 (fv) => fieldValue.includes(fv)
12351 );
12352 } else if (typeof fieldValue === "string") {
12353 return filterValue.includes(fieldValue);
12354 }
12355 return false;
12356 },
12357 selection: "multi"
12358 },
12359 {
12360 name: OPERATOR_IS_NONE,
12361 ...isNoneOperatorDefinition
12362 },
12363 {
12364 name: OPERATOR_IS_ALL,
12365 /* translators: DataViews operator name */
12366 label: (0, import_i18n29.__)("Includes all"),
12367 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12368 (0, import_i18n29.sprintf)(
12369 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
12370 (0, import_i18n29.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
12371 filter.name,
12372 activeElements.map((element) => element.label).join(", ")
12373 ),
12374 filterTextWrappers
12375 ),
12376 filter(item, field, filterValue) {
12377 if (!filterValue?.length) {
12378 return true;
12379 }
12380 return filterValue.every((value) => {
12381 return field.getValue({ item })?.includes(value);
12382 });
12383 },
12384 selection: "multi"
12385 },
12386 {
12387 name: OPERATOR_IS_NOT_ALL,
12388 ...isNoneOperatorDefinition
12389 },
12390 {
12391 name: OPERATOR_BETWEEN,
12392 /* translators: DataViews operator name */
12393 label: (0, import_i18n29.__)("Between (inc)"),
12394 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12395 (0, import_i18n29.sprintf)(
12396 /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */
12397 (0, import_i18n29.__)(
12398 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
12399 ),
12400 filter.name,
12401 activeElements[0].label[0],
12402 activeElements[0].label[1]
12403 ),
12404 filterTextWrappers
12405 ),
12406 filter(item, field, filterValue) {
12407 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
12408 return true;
12409 }
12410 const fieldValue = field.getValue({ item });
12411 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
12412 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
12413 }
12414 return false;
12415 },
12416 selection: "custom"
12417 },
12418 {
12419 name: OPERATOR_IN_THE_PAST,
12420 /* translators: DataViews operator name */
12421 label: (0, import_i18n29.__)("In the past"),
12422 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12423 (0, import_i18n29.sprintf)(
12424 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
12425 (0, import_i18n29.__)(
12426 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
12427 ),
12428 filter.name,
12429 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12430 ),
12431 filterTextWrappers
12432 ),
12433 filter(item, field, filterValue) {
12434 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12435 return true;
12436 }
12437 const targetDate = getRelativeDate(
12438 filterValue.value,
12439 filterValue.unit
12440 );
12441 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12442 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
12443 },
12444 selection: "custom"
12445 },
12446 {
12447 name: OPERATOR_OVER,
12448 /* translators: DataViews operator name */
12449 label: (0, import_i18n29.__)("Over"),
12450 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12451 (0, import_i18n29.sprintf)(
12452 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
12453 (0, import_i18n29.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
12454 filter.name,
12455 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12456 ),
12457 filterTextWrappers
12458 ),
12459 filter(item, field, filterValue) {
12460 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12461 return true;
12462 }
12463 const targetDate = getRelativeDate(
12464 filterValue.value,
12465 filterValue.unit
12466 );
12467 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12468 return fieldValue < targetDate;
12469 },
12470 selection: "custom"
12471 },
12472 {
12473 name: OPERATOR_IS,
12474 /* translators: DataViews operator name */
12475 label: (0, import_i18n29.__)("Is"),
12476 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12477 (0, import_i18n29.sprintf)(
12478 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
12479 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12480 filter.name,
12481 activeElements[0].label
12482 ),
12483 filterTextWrappers
12484 ),
12485 filter(item, field, filterValue) {
12486 return filterValue === field.getValue({ item }) || filterValue === void 0;
12487 },
12488 selection: "single"
12489 },
12490 {
12491 name: OPERATOR_IS_NOT,
12492 /* translators: DataViews operator name */
12493 label: (0, import_i18n29.__)("Is not"),
12494 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12495 (0, import_i18n29.sprintf)(
12496 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
12497 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12498 filter.name,
12499 activeElements[0].label
12500 ),
12501 filterTextWrappers
12502 ),
12503 filter(item, field, filterValue) {
12504 return filterValue !== field.getValue({ item });
12505 },
12506 selection: "single"
12507 },
12508 {
12509 name: OPERATOR_LESS_THAN,
12510 /* translators: DataViews operator name */
12511 label: (0, import_i18n29.__)("Less than"),
12512 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12513 (0, import_i18n29.sprintf)(
12514 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
12515 (0, import_i18n29.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
12516 filter.name,
12517 activeElements[0].label
12518 ),
12519 filterTextWrappers
12520 ),
12521 filter(item, field, filterValue) {
12522 if (filterValue === void 0) {
12523 return true;
12524 }
12525 const fieldValue = field.getValue({ item });
12526 return fieldValue < filterValue;
12527 },
12528 selection: "single"
12529 },
12530 {
12531 name: OPERATOR_GREATER_THAN,
12532 /* translators: DataViews operator name */
12533 label: (0, import_i18n29.__)("Greater than"),
12534 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12535 (0, import_i18n29.sprintf)(
12536 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
12537 (0, import_i18n29.__)(
12538 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
12539 ),
12540 filter.name,
12541 activeElements[0].label
12542 ),
12543 filterTextWrappers
12544 ),
12545 filter(item, field, filterValue) {
12546 if (filterValue === void 0) {
12547 return true;
12548 }
12549 const fieldValue = field.getValue({ item });
12550 return fieldValue > filterValue;
12551 },
12552 selection: "single"
12553 },
12554 {
12555 name: OPERATOR_LESS_THAN_OR_EQUAL,
12556 /* translators: DataViews operator name */
12557 label: (0, import_i18n29.__)("Less than or equal"),
12558 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12559 (0, import_i18n29.sprintf)(
12560 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
12561 (0, import_i18n29.__)(
12562 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
12563 ),
12564 filter.name,
12565 activeElements[0].label
12566 ),
12567 filterTextWrappers
12568 ),
12569 filter(item, field, filterValue) {
12570 if (filterValue === void 0) {
12571 return true;
12572 }
12573 const fieldValue = field.getValue({ item });
12574 return fieldValue <= filterValue;
12575 },
12576 selection: "single"
12577 },
12578 {
12579 name: OPERATOR_GREATER_THAN_OR_EQUAL,
12580 /* translators: DataViews operator name */
12581 label: (0, import_i18n29.__)("Greater than or equal"),
12582 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12583 (0, import_i18n29.sprintf)(
12584 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
12585 (0, import_i18n29.__)(
12586 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
12587 ),
12588 filter.name,
12589 activeElements[0].label
12590 ),
12591 filterTextWrappers
12592 ),
12593 filter(item, field, filterValue) {
12594 if (filterValue === void 0) {
12595 return true;
12596 }
12597 const fieldValue = field.getValue({ item });
12598 return fieldValue >= filterValue;
12599 },
12600 selection: "single"
12601 },
12602 {
12603 name: OPERATOR_BEFORE,
12604 /* translators: DataViews operator name */
12605 label: (0, import_i18n29.__)("Before"),
12606 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12607 (0, import_i18n29.sprintf)(
12608 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
12609 (0, import_i18n29.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
12610 filter.name,
12611 activeElements[0].label
12612 ),
12613 filterTextWrappers
12614 ),
12615 filter(item, field, filterValue) {
12616 if (filterValue === void 0) {
12617 return true;
12618 }
12619 const filterDate = (0, import_date.getDate)(filterValue);
12620 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12621 return fieldDate < filterDate;
12622 },
12623 selection: "single"
12624 },
12625 {
12626 name: OPERATOR_AFTER,
12627 /* translators: DataViews operator name */
12628 label: (0, import_i18n29.__)("After"),
12629 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12630 (0, import_i18n29.sprintf)(
12631 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
12632 (0, import_i18n29.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
12633 filter.name,
12634 activeElements[0].label
12635 ),
12636 filterTextWrappers
12637 ),
12638 filter(item, field, filterValue) {
12639 if (filterValue === void 0) {
12640 return true;
12641 }
12642 const filterDate = (0, import_date.getDate)(filterValue);
12643 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12644 return fieldDate > filterDate;
12645 },
12646 selection: "single"
12647 },
12648 {
12649 name: OPERATOR_BEFORE_INC,
12650 /* translators: DataViews operator name */
12651 label: (0, import_i18n29.__)("Before (inc)"),
12652 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12653 (0, import_i18n29.sprintf)(
12654 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
12655 (0, import_i18n29.__)(
12656 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
12657 ),
12658 filter.name,
12659 activeElements[0].label
12660 ),
12661 filterTextWrappers
12662 ),
12663 filter(item, field, filterValue) {
12664 if (filterValue === void 0) {
12665 return true;
12666 }
12667 const filterDate = (0, import_date.getDate)(filterValue);
12668 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12669 return fieldDate <= filterDate;
12670 },
12671 selection: "single"
12672 },
12673 {
12674 name: OPERATOR_AFTER_INC,
12675 /* translators: DataViews operator name */
12676 label: (0, import_i18n29.__)("After (inc)"),
12677 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12678 (0, import_i18n29.sprintf)(
12679 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
12680 (0, import_i18n29.__)(
12681 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
12682 ),
12683 filter.name,
12684 activeElements[0].label
12685 ),
12686 filterTextWrappers
12687 ),
12688 filter(item, field, filterValue) {
12689 if (filterValue === void 0) {
12690 return true;
12691 }
12692 const filterDate = (0, import_date.getDate)(filterValue);
12693 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12694 return fieldDate >= filterDate;
12695 },
12696 selection: "single"
12697 },
12698 {
12699 name: OPERATOR_CONTAINS,
12700 /* translators: DataViews operator name */
12701 label: (0, import_i18n29.__)("Contains"),
12702 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12703 (0, import_i18n29.sprintf)(
12704 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
12705 (0, import_i18n29.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
12706 filter.name,
12707 activeElements[0].label
12708 ),
12709 filterTextWrappers
12710 ),
12711 filter(item, field, filterValue) {
12712 if (filterValue === void 0) {
12713 return true;
12714 }
12715 const fieldValue = field.getValue({ item });
12716 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12717 },
12718 selection: "single"
12719 },
12720 {
12721 name: OPERATOR_NOT_CONTAINS,
12722 /* translators: DataViews operator name */
12723 label: (0, import_i18n29.__)("Doesn't contain"),
12724 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12725 (0, import_i18n29.sprintf)(
12726 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
12727 (0, import_i18n29.__)(
12728 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
12729 ),
12730 filter.name,
12731 activeElements[0].label
12732 ),
12733 filterTextWrappers
12734 ),
12735 filter(item, field, filterValue) {
12736 if (filterValue === void 0) {
12737 return true;
12738 }
12739 const fieldValue = field.getValue({ item });
12740 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12741 },
12742 selection: "single"
12743 },
12744 {
12745 name: OPERATOR_STARTS_WITH,
12746 /* translators: DataViews operator name */
12747 label: (0, import_i18n29.__)("Starts with"),
12748 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12749 (0, import_i18n29.sprintf)(
12750 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
12751 (0, import_i18n29.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
12752 filter.name,
12753 activeElements[0].label
12754 ),
12755 filterTextWrappers
12756 ),
12757 filter(item, field, filterValue) {
12758 if (filterValue === void 0) {
12759 return true;
12760 }
12761 const fieldValue = field.getValue({ item });
12762 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
12763 },
12764 selection: "single"
12765 },
12766 {
12767 name: OPERATOR_ON,
12768 /* translators: DataViews operator name */
12769 label: (0, import_i18n29.__)("On"),
12770 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12771 (0, import_i18n29.sprintf)(
12772 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
12773 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12774 filter.name,
12775 activeElements[0].label
12776 ),
12777 filterTextWrappers
12778 ),
12779 filter(item, field, filterValue) {
12780 if (filterValue === void 0) {
12781 return true;
12782 }
12783 const filterDate = (0, import_date.getDate)(filterValue);
12784 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12785 return filterDate.getTime() === fieldDate.getTime();
12786 },
12787 selection: "single"
12788 },
12789 {
12790 name: OPERATOR_NOT_ON,
12791 /* translators: DataViews operator name */
12792 label: (0, import_i18n29.__)("Not on"),
12793 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12794 (0, import_i18n29.sprintf)(
12795 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
12796 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12797 filter.name,
12798 activeElements[0].label
12799 ),
12800 filterTextWrappers
12801 ),
12802 filter(item, field, filterValue) {
12803 if (filterValue === void 0) {
12804 return true;
12805 }
12806 const filterDate = (0, import_date.getDate)(filterValue);
12807 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12808 return filterDate.getTime() !== fieldDate.getTime();
12809 },
12810 selection: "single"
12811 }
12812 ];
12813 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
12814 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
12815 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
12816 (op) => op.name === name
12817 );
12818 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
12819
12820 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
12821 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
12822 var ENTER = "Enter";
12823 var SPACE = " ";
12824 var FilterText = ({
12825 activeElements,
12826 filterInView,
12827 filter
12828 }) => {
12829 if (activeElements === void 0 || activeElements.length === 0) {
12830 return filter.name;
12831 }
12832 const operator = getOperatorByName(filterInView?.operator);
12833 if (operator !== void 0) {
12834 return operator.filterText(filter, activeElements);
12835 }
12836 return (0, import_i18n30.sprintf)(
12837 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
12838 (0, import_i18n30.__)("Unknown status for %1$s"),
12839 filter.name
12840 );
12841 };
12842 function OperatorSelector({
12843 filter,
12844 view,
12845 onChangeView
12846 }) {
12847 const operatorOptions = filter.operators?.map((operator) => ({
12848 value: operator,
12849 label: getOperatorByName(operator)?.label || operator
12850 }));
12851 const currentFilter = view.filters?.find(
12852 (_filter) => _filter.field === filter.field
12853 );
12854 const value = currentFilter?.operator || filter.operators[0];
12855 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
12856 Stack,
12857 {
12858 direction: "row",
12859 gap: "sm",
12860 justify: "flex-start",
12861 className: "dataviews-filters__summary-operators-container",
12862 align: "center",
12863 children: [
12864 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
12865 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12866 import_components21.SelectControl,
12867 {
12868 className: "dataviews-filters__summary-operators-filter-select",
12869 label: (0, import_i18n30.__)("Conditions"),
12870 value,
12871 options: operatorOptions,
12872 onChange: (newValue) => {
12873 const newOperator = newValue;
12874 const currentOperator = currentFilter?.operator;
12875 const newFilters = currentFilter ? [
12876 ...(view.filters ?? []).map(
12877 (_filter) => {
12878 if (_filter.field === filter.field) {
12879 const currentOpSelectionModel = getOperatorByName(
12880 currentOperator
12881 )?.selection;
12882 const newOpSelectionModel = getOperatorByName(
12883 newOperator
12884 )?.selection;
12885 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
12886 currentOpSelectionModel,
12887 newOpSelectionModel
12888 ].includes("custom");
12889 return {
12890 ..._filter,
12891 value: shouldResetValue ? void 0 : _filter.value,
12892 operator: newOperator
12893 };
12894 }
12895 return _filter;
12896 }
12897 )
12898 ] : [
12899 ...view.filters ?? [],
12900 {
12901 field: filter.field,
12902 operator: newOperator,
12903 value: void 0
12904 }
12905 ];
12906 onChangeView({
12907 ...view,
12908 page: 1,
12909 filters: newFilters
12910 });
12911 },
12912 size: "small",
12913 variant: "minimal",
12914 hideLabelFromVision: true
12915 }
12916 )
12917 ]
12918 }
12919 );
12920 }
12921 function Filter({
12922 addFilterRef,
12923 openedFilter,
12924 fields,
12925 ...commonProps
12926 }) {
12927 const toggleRef = (0, import_element28.useRef)(null);
12928 const { filter, view, onChangeView } = commonProps;
12929 const filterInView = view.filters?.find(
12930 (f2) => f2.field === filter.field
12931 );
12932 let activeElements = [];
12933 const field = (0, import_element28.useMemo)(() => {
12934 const currentField = fields.find((f2) => f2.id === filter.field);
12935 if (currentField) {
12936 return {
12937 ...currentField,
12938 // Configure getValue as if Item was a plain object.
12939 // See related input-widget.tsx
12940 getValue: ({ item }) => item[currentField.id]
12941 };
12942 }
12943 return currentField;
12944 }, [fields, filter.field]);
12945 const { elements } = useElements({
12946 elements: filter.elements,
12947 getElements: filter.getElements
12948 });
12949 if (elements.length > 0) {
12950 activeElements = elements.filter((element) => {
12951 if (filter.singleSelection) {
12952 return element.value === filterInView?.value;
12953 }
12954 return filterInView?.value?.includes(element.value);
12955 });
12956 } else if (Array.isArray(filterInView?.value)) {
12957 const label = filterInView.value.map((v2) => {
12958 const formattedValue = field?.getValueFormatted({
12959 item: { [field.id]: v2 },
12960 field
12961 });
12962 return formattedValue || String(v2);
12963 });
12964 activeElements = [
12965 {
12966 value: filterInView.value,
12967 // @ts-ignore
12968 label
12969 }
12970 ];
12971 } else if (typeof filterInView?.value === "object") {
12972 activeElements = [
12973 { value: filterInView.value, label: filterInView.value }
12974 ];
12975 } else if (filterInView?.value !== void 0) {
12976 const label = field !== void 0 ? field.getValueFormatted({
12977 item: { [field.id]: filterInView.value },
12978 field
12979 }) : String(filterInView.value);
12980 activeElements = [
12981 {
12982 value: filterInView.value,
12983 label
12984 }
12985 ];
12986 }
12987 const isPrimary = filter.isPrimary;
12988 const isLocked = filterInView?.isLocked;
12989 const hasValues = !isLocked && filterInView?.value !== void 0;
12990 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
12991 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12992 import_components21.Dropdown,
12993 {
12994 defaultOpen: openedFilter === filter.field,
12995 contentClassName: "dataviews-filters__summary-popover",
12996 popoverProps: { placement: "bottom-start", role: "dialog" },
12997 onClose: () => {
12998 toggleRef.current?.focus();
12999 },
13000 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
13001 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13002 import_components21.Tooltip,
13003 {
13004 text: (0, import_i18n30.sprintf)(
13005 /* translators: 1: Filter name. */
13006 (0, import_i18n30.__)("Filter by: %1$s"),
13007 filter.name.toLowerCase()
13008 ),
13009 placement: "top",
13010 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13011 "div",
13012 {
13013 className: clsx_default(
13014 "dataviews-filters__summary-chip",
13015 {
13016 "has-reset": canResetOrRemove,
13017 "has-values": hasValues,
13018 "is-not-clickable": isLocked
13019 }
13020 ),
13021 role: "button",
13022 tabIndex: isLocked ? -1 : 0,
13023 onClick: () => {
13024 if (!isLocked) {
13025 onToggle();
13026 }
13027 },
13028 onKeyDown: (event) => {
13029 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
13030 onToggle();
13031 event.preventDefault();
13032 }
13033 },
13034 "aria-disabled": isLocked,
13035 "aria-pressed": isOpen,
13036 "aria-expanded": isOpen,
13037 ref: toggleRef,
13038 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13039 FilterText,
13040 {
13041 activeElements,
13042 filterInView,
13043 filter
13044 }
13045 )
13046 }
13047 )
13048 }
13049 ),
13050 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13051 import_components21.Tooltip,
13052 {
13053 text: isPrimary ? (0, import_i18n30.__)("Reset") : (0, import_i18n30.__)("Remove"),
13054 placement: "top",
13055 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13056 "button",
13057 {
13058 className: clsx_default(
13059 "dataviews-filters__summary-chip-remove",
13060 { "has-values": hasValues }
13061 ),
13062 onClick: () => {
13063 onChangeView({
13064 ...view,
13065 page: 1,
13066 filters: view.filters?.filter(
13067 (_filter) => _filter.field !== filter.field
13068 )
13069 });
13070 if (!isPrimary) {
13071 addFilterRef.current?.focus();
13072 } else {
13073 toggleRef.current?.focus();
13074 }
13075 },
13076 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components21.Icon, { icon: close_small_default })
13077 }
13078 )
13079 }
13080 )
13081 ] }),
13082 renderContent: () => {
13083 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
13084 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(OperatorSelector, { ...commonProps }),
13085 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13086 SearchWidget,
13087 {
13088 ...commonProps,
13089 filter: {
13090 ...commonProps.filter,
13091 elements
13092 }
13093 }
13094 ) : /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(InputWidget, { ...commonProps, fields })
13095 ] });
13096 }
13097 }
13098 );
13099 }
13100
13101 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
13102 var import_components22 = __toESM(require_components(), 1);
13103 var import_i18n31 = __toESM(require_i18n(), 1);
13104 var import_element29 = __toESM(require_element(), 1);
13105 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13106 var { Menu: Menu4 } = unlock(import_components22.privateApis);
13107 function AddFilterMenu({
13108 filters,
13109 view,
13110 onChangeView,
13111 setOpenedFilter,
13112 triggerProps
13113 }) {
13114 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13115 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Menu4, { children: [
13116 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.TriggerButton, { ...triggerProps }),
13117 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
13118 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13119 Menu4.Item,
13120 {
13121 onClick: () => {
13122 setOpenedFilter(filter.field);
13123 onChangeView({
13124 ...view,
13125 page: 1,
13126 filters: [
13127 ...view.filters || [],
13128 {
13129 field: filter.field,
13130 value: void 0,
13131 operator: filter.operators[0]
13132 }
13133 ]
13134 });
13135 },
13136 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.ItemLabel, { children: filter.name })
13137 },
13138 filter.field
13139 );
13140 }) })
13141 ] });
13142 }
13143 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
13144 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
13145 return null;
13146 }
13147 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13148 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13149 AddFilterMenu,
13150 {
13151 triggerProps: {
13152 render: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13153 import_components22.Button,
13154 {
13155 accessibleWhenDisabled: true,
13156 size: "compact",
13157 className: "dataviews-filters-button",
13158 variant: "tertiary",
13159 disabled: !inactiveFilters.length,
13160 ref
13161 }
13162 ),
13163 children: (0, import_i18n31.__)("Add filter")
13164 },
13165 ...{ filters, view, onChangeView, setOpenedFilter }
13166 }
13167 );
13168 }
13169 var add_filter_default = (0, import_element29.forwardRef)(AddFilter);
13170
13171 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
13172 var import_components23 = __toESM(require_components(), 1);
13173 var import_i18n32 = __toESM(require_i18n(), 1);
13174 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13175 function ResetFilter({
13176 filters,
13177 view,
13178 onChangeView
13179 }) {
13180 const isPrimary = (field) => filters.some(
13181 (_filter) => _filter.field === field && _filter.isPrimary
13182 );
13183 const isDisabled = !view.search && !view.filters?.some(
13184 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
13185 );
13186 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13187 import_components23.Button,
13188 {
13189 disabled: isDisabled,
13190 accessibleWhenDisabled: true,
13191 size: "compact",
13192 variant: "tertiary",
13193 className: "dataviews-filters__reset-button",
13194 onClick: () => {
13195 onChangeView({
13196 ...view,
13197 page: 1,
13198 search: "",
13199 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
13200 });
13201 },
13202 children: (0, import_i18n32.__)("Reset")
13203 }
13204 );
13205 }
13206
13207 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
13208 var import_element30 = __toESM(require_element(), 1);
13209 function useFilters(fields, view) {
13210 return (0, import_element30.useMemo)(() => {
13211 const filters = [];
13212 fields.forEach((field) => {
13213 if (field.filterBy === false || !field.hasElements && !field.Edit) {
13214 return;
13215 }
13216 const operators = field.filterBy.operators;
13217 const isPrimary = !!field.filterBy?.isPrimary;
13218 const isLocked = view.filters?.some(
13219 (f2) => f2.field === field.id && !!f2.isLocked
13220 ) ?? false;
13221 filters.push({
13222 field: field.id,
13223 name: field.label,
13224 elements: field.elements,
13225 getElements: field.getElements,
13226 hasElements: field.hasElements,
13227 singleSelection: operators.some(
13228 (op) => isSingleSelectionOperator(op)
13229 ),
13230 operators,
13231 isVisible: isLocked || isPrimary || !!view.filters?.some(
13232 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
13233 ),
13234 isPrimary,
13235 isLocked
13236 });
13237 });
13238 filters.sort((a2, b2) => {
13239 if (a2.isLocked && !b2.isLocked) {
13240 return -1;
13241 }
13242 if (!a2.isLocked && b2.isLocked) {
13243 return 1;
13244 }
13245 if (a2.isPrimary && !b2.isPrimary) {
13246 return -1;
13247 }
13248 if (!a2.isPrimary && b2.isPrimary) {
13249 return 1;
13250 }
13251 return a2.name.localeCompare(b2.name);
13252 });
13253 return filters;
13254 }, [fields, view]);
13255 }
13256 var use_filters_default = useFilters;
13257
13258 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
13259 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13260 function Filters({ className }) {
13261 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element31.useContext)(dataviews_context_default);
13262 const addFilterRef = (0, import_element31.useRef)(null);
13263 const filters = use_filters_default(fields, view);
13264 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13265 add_filter_default,
13266 {
13267 filters,
13268 view,
13269 onChangeView,
13270 ref: addFilterRef,
13271 setOpenedFilter
13272 },
13273 "add-filter"
13274 );
13275 const visibleFilters = filters.filter((filter) => filter.isVisible);
13276 if (visibleFilters.length === 0) {
13277 return null;
13278 }
13279 const filterComponents = [
13280 ...visibleFilters.map((filter) => {
13281 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13282 Filter,
13283 {
13284 filter,
13285 view,
13286 fields,
13287 onChangeView,
13288 addFilterRef,
13289 openedFilter
13290 },
13291 filter.field
13292 );
13293 }),
13294 addFilter
13295 ];
13296 filterComponents.push(
13297 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13298 ResetFilter,
13299 {
13300 filters,
13301 view,
13302 onChangeView
13303 },
13304 "reset-filters"
13305 )
13306 );
13307 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13308 Stack,
13309 {
13310 direction: "row",
13311 justify: "flex-start",
13312 gap: "sm",
13313 style: { width: "fit-content" },
13314 wrap: "wrap",
13315 className,
13316 children: filterComponents
13317 }
13318 );
13319 }
13320 var filters_default = (0, import_element31.memo)(Filters);
13321
13322 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
13323 var import_element32 = __toESM(require_element(), 1);
13324 var import_components24 = __toESM(require_components(), 1);
13325 var import_i18n33 = __toESM(require_i18n(), 1);
13326 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13327 function FiltersToggle() {
13328 const {
13329 filters,
13330 view,
13331 onChangeView,
13332 setOpenedFilter,
13333 isShowingFilter,
13334 setIsShowingFilter
13335 } = (0, import_element32.useContext)(dataviews_context_default);
13336 const buttonRef = (0, import_element32.useRef)(null);
13337 const onChangeViewWithFilterVisibility = (0, import_element32.useCallback)(
13338 (_view) => {
13339 onChangeView(_view);
13340 setIsShowingFilter(true);
13341 },
13342 [onChangeView, setIsShowingFilter]
13343 );
13344 if (filters.length === 0) {
13345 return null;
13346 }
13347 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
13348 const addFilterButtonProps = {
13349 label: (0, import_i18n33.__)("Add filter"),
13350 "aria-expanded": false,
13351 isPressed: false
13352 };
13353 const toggleFiltersButtonProps = {
13354 label: (0, import_i18n33._x)("Filter", "verb"),
13355 "aria-expanded": isShowingFilter,
13356 isPressed: isShowingFilter,
13357 onClick: () => {
13358 if (!isShowingFilter) {
13359 setOpenedFilter(null);
13360 }
13361 setIsShowingFilter(!isShowingFilter);
13362 }
13363 };
13364 const hasPrimaryOrLockedFilters = filters.some(
13365 (filter) => filter.isPrimary || filter.isLocked
13366 );
13367 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13368 import_components24.Button,
13369 {
13370 ref: buttonRef,
13371 className: "dataviews-filters__visibility-toggle",
13372 size: "compact",
13373 icon: funnel_default,
13374 disabled: hasPrimaryOrLockedFilters,
13375 accessibleWhenDisabled: true,
13376 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
13377 }
13378 );
13379 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13380 AddFilterMenu,
13381 {
13382 filters,
13383 view,
13384 onChangeView: onChangeViewWithFilterVisibility,
13385 setOpenedFilter,
13386 triggerProps: { render: buttonComponent }
13387 }
13388 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13389 FilterVisibilityToggle,
13390 {
13391 buttonRef,
13392 filtersCount: view.filters?.length,
13393 children: buttonComponent
13394 }
13395 ) });
13396 }
13397 function FilterVisibilityToggle({
13398 buttonRef,
13399 filtersCount,
13400 children
13401 }) {
13402 (0, import_element32.useEffect)(
13403 () => () => {
13404 buttonRef.current?.focus();
13405 },
13406 [buttonRef]
13407 );
13408 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13409 children,
13410 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
13411 ] });
13412 }
13413 var toggle_default = FiltersToggle;
13414
13415 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
13416 var import_element33 = __toESM(require_element(), 1);
13417 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13418 function FiltersToggled(props) {
13419 const { isShowingFilter } = (0, import_element33.useContext)(dataviews_context_default);
13420 if (!isShowingFilter) {
13421 return null;
13422 }
13423 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(filters_default, { ...props });
13424 }
13425 var filters_toggled_default = FiltersToggled;
13426
13427 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
13428 var import_element34 = __toESM(require_element(), 1);
13429 var import_i18n34 = __toESM(require_i18n(), 1);
13430 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
13431 function DataViewsLayout({ className }) {
13432 const {
13433 actions = [],
13434 data,
13435 fields,
13436 getItemId,
13437 getItemLevel,
13438 hasInitiallyLoaded,
13439 isLoading,
13440 view,
13441 onChangeView,
13442 selection,
13443 onChangeSelection,
13444 setOpenedFilter,
13445 onClickItem,
13446 isItemClickable: isItemClickable2,
13447 renderItemLink,
13448 defaultLayouts,
13449 empty = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { children: (0, import_i18n34.__)("No results") })
13450 } = (0, import_element34.useContext)(dataviews_context_default);
13451 if (!hasInitiallyLoaded) {
13452 return null;
13453 }
13454 const ViewComponent = VIEW_LAYOUTS.find(
13455 (v2) => v2.type === view.type && defaultLayouts[v2.type]
13456 )?.component;
13457 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
13458 ViewComponent,
13459 {
13460 className,
13461 actions,
13462 data,
13463 fields,
13464 getItemId,
13465 getItemLevel,
13466 isLoading,
13467 onChangeView,
13468 onChangeSelection,
13469 selection,
13470 setOpenedFilter,
13471 onClickItem,
13472 renderItemLink,
13473 isItemClickable: isItemClickable2,
13474 view,
13475 empty
13476 }
13477 );
13478 }
13479
13480 // packages/dataviews/build-module/components/dataviews-search/index.mjs
13481 var import_i18n35 = __toESM(require_i18n(), 1);
13482 var import_element35 = __toESM(require_element(), 1);
13483 var import_components25 = __toESM(require_components(), 1);
13484 var import_compose10 = __toESM(require_compose(), 1);
13485 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
13486 var DataViewsSearch = (0, import_element35.memo)(function Search({ label }) {
13487 const { view, onChangeView } = (0, import_element35.useContext)(dataviews_context_default);
13488 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
13489 view.search
13490 );
13491 (0, import_element35.useEffect)(() => {
13492 if (view.search !== debouncedSearch) {
13493 setSearch(view.search ?? "");
13494 }
13495 }, [view.search, setSearch]);
13496 const onChangeViewRef = (0, import_element35.useRef)(onChangeView);
13497 const viewRef = (0, import_element35.useRef)(view);
13498 (0, import_element35.useEffect)(() => {
13499 onChangeViewRef.current = onChangeView;
13500 viewRef.current = view;
13501 }, [onChangeView, view]);
13502 (0, import_element35.useEffect)(() => {
13503 if (debouncedSearch !== viewRef.current?.search) {
13504 onChangeViewRef.current({
13505 ...viewRef.current,
13506 page: 1,
13507 search: debouncedSearch
13508 });
13509 }
13510 }, [debouncedSearch]);
13511 const searchLabel = label || (0, import_i18n35.__)("Search");
13512 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13513 import_components25.SearchControl,
13514 {
13515 className: "dataviews-search",
13516 onChange: setSearch,
13517 value: search,
13518 label: searchLabel,
13519 placeholder: searchLabel,
13520 size: "compact"
13521 }
13522 );
13523 });
13524 var dataviews_search_default = DataViewsSearch;
13525
13526 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13527 var import_components27 = __toESM(require_components(), 1);
13528 var import_i18n37 = __toESM(require_i18n(), 1);
13529 var import_element37 = __toESM(require_element(), 1);
13530 var import_warning = __toESM(require_warning(), 1);
13531 var import_compose11 = __toESM(require_compose(), 1);
13532
13533 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.mjs
13534 var import_components26 = __toESM(require_components(), 1);
13535 var import_i18n36 = __toESM(require_i18n(), 1);
13536 var import_element36 = __toESM(require_element(), 1);
13537 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
13538 function InfiniteScrollToggle() {
13539 const context = (0, import_element36.useContext)(dataviews_context_default);
13540 const { view, onChangeView } = context;
13541 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false;
13542 if (!context.hasInfiniteScrollHandler) {
13543 return null;
13544 }
13545 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
13546 import_components26.ToggleControl,
13547 {
13548 label: (0, import_i18n36.__)("Enable infinite scroll"),
13549 help: (0, import_i18n36.__)(
13550 "Automatically load more content as you scroll, instead of showing pagination links."
13551 ),
13552 checked: infiniteScrollEnabled,
13553 onChange: (newValue) => {
13554 onChangeView({
13555 ...view,
13556 infiniteScrollEnabled: newValue
13557 });
13558 }
13559 }
13560 );
13561 }
13562
13563 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13564 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
13565 var { Menu: Menu5 } = unlock(import_components27.privateApis);
13566 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
13567 className: "dataviews-config__popover",
13568 placement: "bottom-end",
13569 offset: 9
13570 };
13571 function ViewTypeMenu() {
13572 const { view, onChangeView, defaultLayouts } = (0, import_element37.useContext)(dataviews_context_default);
13573 const availableLayouts = Object.keys(defaultLayouts);
13574 if (availableLayouts.length <= 1) {
13575 return null;
13576 }
13577 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
13578 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Menu5, { children: [
13579 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13580 Menu5.TriggerButton,
13581 {
13582 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13583 import_components27.Button,
13584 {
13585 size: "compact",
13586 icon: activeView?.icon,
13587 label: (0, import_i18n37.__)("Layout")
13588 }
13589 )
13590 }
13591 ),
13592 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
13593 const config = VIEW_LAYOUTS.find(
13594 (v2) => v2.type === layout
13595 );
13596 if (!config) {
13597 return null;
13598 }
13599 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13600 Menu5.RadioItem,
13601 {
13602 value: layout,
13603 name: "view-actions-available-view",
13604 checked: layout === view.type,
13605 hideOnClick: true,
13606 onChange: (e2) => {
13607 switch (e2.target.value) {
13608 case "list":
13609 case "grid":
13610 case "table":
13611 case "pickerGrid":
13612 case "pickerTable":
13613 case "activity":
13614 const viewWithoutLayout = { ...view };
13615 if ("layout" in viewWithoutLayout) {
13616 delete viewWithoutLayout.layout;
13617 }
13618 return onChangeView({
13619 ...viewWithoutLayout,
13620 type: e2.target.value,
13621 ...defaultLayouts[e2.target.value]
13622 });
13623 }
13624 (0, import_warning.default)("Invalid dataview");
13625 },
13626 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.ItemLabel, { children: config.label })
13627 },
13628 layout
13629 );
13630 }) })
13631 ] });
13632 }
13633 function SortFieldControl() {
13634 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13635 const orderOptions = (0, import_element37.useMemo)(() => {
13636 const sortableFields = fields.filter(
13637 (field) => field.enableSorting !== false
13638 );
13639 return sortableFields.map((field) => {
13640 return {
13641 label: field.label,
13642 value: field.id
13643 };
13644 });
13645 }, [fields]);
13646 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13647 import_components27.SelectControl,
13648 {
13649 __next40pxDefaultSize: true,
13650 label: (0, import_i18n37.__)("Sort by"),
13651 value: view.sort?.field,
13652 options: orderOptions,
13653 onChange: (value) => {
13654 onChangeView({
13655 ...view,
13656 sort: {
13657 direction: view?.sort?.direction || "desc",
13658 field: value
13659 },
13660 showLevels: false
13661 });
13662 }
13663 }
13664 );
13665 }
13666 function SortDirectionControl() {
13667 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13668 const sortableFields = fields.filter(
13669 (field) => field.enableSorting !== false
13670 );
13671 if (sortableFields.length === 0) {
13672 return null;
13673 }
13674 let value = view.sort?.direction;
13675 if (!value && view.sort?.field) {
13676 value = "desc";
13677 }
13678 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13679 import_components27.__experimentalToggleGroupControl,
13680 {
13681 className: "dataviews-view-config__sort-direction",
13682 __next40pxDefaultSize: true,
13683 isBlock: true,
13684 label: (0, import_i18n37.__)("Order"),
13685 value,
13686 onChange: (newDirection) => {
13687 if (newDirection === "asc" || newDirection === "desc") {
13688 onChangeView({
13689 ...view,
13690 sort: {
13691 direction: newDirection,
13692 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
13693 fields.find(
13694 (field) => field.enableSorting !== false
13695 )?.id || ""
13696 },
13697 showLevels: false
13698 });
13699 return;
13700 }
13701 (0, import_warning.default)("Invalid direction");
13702 },
13703 children: SORTING_DIRECTIONS.map((direction) => {
13704 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13705 import_components27.__experimentalToggleGroupControlOptionIcon,
13706 {
13707 value: direction,
13708 icon: sortIcons[direction],
13709 label: sortLabels[direction]
13710 },
13711 direction
13712 );
13713 })
13714 }
13715 );
13716 }
13717 function ItemsPerPageControl() {
13718 const { view, config, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13719 const { infiniteScrollEnabled } = view;
13720 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
13721 return null;
13722 }
13723 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13724 import_components27.__experimentalToggleGroupControl,
13725 {
13726 __next40pxDefaultSize: true,
13727 isBlock: true,
13728 label: (0, import_i18n37.__)("Items per page"),
13729 value: view.perPage || 10,
13730 disabled: !view?.sort?.field,
13731 onChange: (newItemsPerPage) => {
13732 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
13733 onChangeView({
13734 ...view,
13735 perPage: newItemsPerPageNumber,
13736 page: 1
13737 });
13738 },
13739 children: config.perPageSizes.map((value) => {
13740 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13741 import_components27.__experimentalToggleGroupControlOption,
13742 {
13743 value,
13744 label: value.toString()
13745 },
13746 value
13747 );
13748 })
13749 }
13750 );
13751 }
13752 function ResetViewButton() {
13753 const { onReset } = (0, import_element37.useContext)(dataviews_context_default);
13754 if (onReset === void 0) {
13755 return null;
13756 }
13757 const isDisabled = onReset === false;
13758 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13759 import_components27.Button,
13760 {
13761 variant: "tertiary",
13762 size: "compact",
13763 disabled: isDisabled,
13764 accessibleWhenDisabled: true,
13765 className: "dataviews-view-config__reset-button",
13766 onClick: () => {
13767 if (typeof onReset === "function") {
13768 onReset();
13769 }
13770 },
13771 children: (0, import_i18n37.__)("Reset view")
13772 }
13773 );
13774 }
13775 function DataviewsViewConfigDropdown() {
13776 const { view, onReset } = (0, import_element37.useContext)(dataviews_context_default);
13777 const popoverId = (0, import_compose11.useInstanceId)(
13778 _DataViewsViewConfig,
13779 "dataviews-view-config-dropdown"
13780 );
13781 const activeLayout = VIEW_LAYOUTS.find(
13782 (layout) => layout.type === view.type
13783 );
13784 const isModified = typeof onReset === "function";
13785 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13786 import_components27.Dropdown,
13787 {
13788 expandOnMobile: true,
13789 popoverProps: {
13790 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
13791 id: popoverId
13792 },
13793 renderToggle: ({ onToggle, isOpen }) => {
13794 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
13795 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13796 import_components27.Button,
13797 {
13798 size: "compact",
13799 icon: cog_default,
13800 label: (0, import_i18n37._x)(
13801 "View options",
13802 "View is used as a noun"
13803 ),
13804 onClick: onToggle,
13805 "aria-expanded": isOpen ? "true" : "false",
13806 "aria-controls": popoverId
13807 }
13808 ),
13809 isModified && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
13810 ] });
13811 },
13812 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13813 import_components27.__experimentalDropdownContentWrapper,
13814 {
13815 paddingSize: "medium",
13816 className: "dataviews-config__popover-content-wrapper",
13817 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13818 Stack,
13819 {
13820 direction: "column",
13821 className: "dataviews-view-config",
13822 gap: "xl",
13823 children: [
13824 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13825 Stack,
13826 {
13827 direction: "row",
13828 justify: "space-between",
13829 align: "center",
13830 className: "dataviews-view-config__header",
13831 children: [
13832 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13833 import_components27.__experimentalHeading,
13834 {
13835 level: 2,
13836 className: "dataviews-settings-section__title",
13837 children: (0, import_i18n37.__)("Appearance")
13838 }
13839 ),
13840 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ResetViewButton, {})
13841 ]
13842 }
13843 ),
13844 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
13845 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13846 Stack,
13847 {
13848 direction: "row",
13849 gap: "sm",
13850 className: "dataviews-view-config__sort-controls",
13851 children: [
13852 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortFieldControl, {}),
13853 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortDirectionControl, {})
13854 ]
13855 }
13856 ),
13857 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(activeLayout.viewConfigOptions, {}),
13858 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(InfiniteScrollToggle, {}),
13859 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemsPerPageControl, {}),
13860 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, {})
13861 ] })
13862 ]
13863 }
13864 )
13865 }
13866 )
13867 }
13868 );
13869 }
13870 function _DataViewsViewConfig() {
13871 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
13872 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ViewTypeMenu, {}),
13873 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DataviewsViewConfigDropdown, {})
13874 ] });
13875 }
13876 var DataViewsViewConfig = (0, import_element37.memo)(_DataViewsViewConfig);
13877 var dataviews_view_config_default = DataViewsViewConfig;
13878
13879 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13880 var import_components28 = __toESM(require_components(), 1);
13881 var import_element38 = __toESM(require_element(), 1);
13882
13883 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
13884 function getCustomValidity(isValid2, validity) {
13885 let customValidity;
13886 if (isValid2?.required && validity?.required) {
13887 customValidity = validity?.required?.message ? validity.required : void 0;
13888 } else if (isValid2?.pattern && validity?.pattern) {
13889 customValidity = validity.pattern;
13890 } else if (isValid2?.min && validity?.min) {
13891 customValidity = validity.min;
13892 } else if (isValid2?.max && validity?.max) {
13893 customValidity = validity.max;
13894 } else if (isValid2?.minLength && validity?.minLength) {
13895 customValidity = validity.minLength;
13896 } else if (isValid2?.maxLength && validity?.maxLength) {
13897 customValidity = validity.maxLength;
13898 } else if (isValid2?.elements && validity?.elements) {
13899 customValidity = validity.elements;
13900 } else if (validity?.custom) {
13901 customValidity = validity.custom;
13902 }
13903 return customValidity;
13904 }
13905
13906 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13907 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
13908 var { ValidatedCheckboxControl } = unlock(import_components28.privateApis);
13909 function Checkbox({
13910 field,
13911 onChange,
13912 data,
13913 hideLabelFromVision,
13914 markWhenOptional,
13915 validity
13916 }) {
13917 const { getValue, setValue, label, description, isValid: isValid2 } = field;
13918 const onChangeControl = (0, import_element38.useCallback)(() => {
13919 onChange(
13920 setValue({ item: data, value: !getValue({ item: data }) })
13921 );
13922 }, [data, getValue, onChange, setValue]);
13923 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
13924 ValidatedCheckboxControl,
13925 {
13926 required: !!field.isValid?.required,
13927 markWhenOptional,
13928 customValidity: getCustomValidity(isValid2, validity),
13929 hidden: hideLabelFromVision,
13930 label,
13931 help: description,
13932 checked: getValue({ item: data }),
13933 onChange: onChangeControl
13934 }
13935 );
13936 }
13937
13938 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
13939 var import_components29 = __toESM(require_components(), 1);
13940 var import_element39 = __toESM(require_element(), 1);
13941 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
13942 var { ValidatedComboboxControl } = unlock(import_components29.privateApis);
13943 function Combobox3({
13944 data,
13945 field,
13946 onChange,
13947 hideLabelFromVision,
13948 validity
13949 }) {
13950 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
13951 const value = getValue({ item: data }) ?? "";
13952 const onChangeControl = (0, import_element39.useCallback)(
13953 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
13954 [data, onChange, setValue]
13955 );
13956 const { elements, isLoading } = useElements({
13957 elements: field.elements,
13958 getElements: field.getElements
13959 });
13960 if (isLoading) {
13961 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components29.Spinner, {});
13962 }
13963 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13964 ValidatedComboboxControl,
13965 {
13966 required: !!field.isValid?.required,
13967 customValidity: getCustomValidity(isValid2, validity),
13968 label,
13969 value,
13970 help: description,
13971 placeholder,
13972 options: elements,
13973 onChange: onChangeControl,
13974 hideLabelFromVision,
13975 allowReset: true,
13976 expandOnFocus: true
13977 }
13978 );
13979 }
13980
13981 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
13982 var import_components31 = __toESM(require_components(), 1);
13983 var import_element41 = __toESM(require_element(), 1);
13984 var import_i18n39 = __toESM(require_i18n(), 1);
13985 var import_date3 = __toESM(require_date(), 1);
13986
13987 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
13988 var import_components30 = __toESM(require_components(), 1);
13989 var import_element40 = __toESM(require_element(), 1);
13990 var import_i18n38 = __toESM(require_i18n(), 1);
13991 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
13992 var TIME_UNITS_OPTIONS = {
13993 [OPERATOR_IN_THE_PAST]: [
13994 { value: "days", label: (0, import_i18n38.__)("Days") },
13995 { value: "weeks", label: (0, import_i18n38.__)("Weeks") },
13996 { value: "months", label: (0, import_i18n38.__)("Months") },
13997 { value: "years", label: (0, import_i18n38.__)("Years") }
13998 ],
13999 [OPERATOR_OVER]: [
14000 { value: "days", label: (0, import_i18n38.__)("Days ago") },
14001 { value: "weeks", label: (0, import_i18n38.__)("Weeks ago") },
14002 { value: "months", label: (0, import_i18n38.__)("Months ago") },
14003 { value: "years", label: (0, import_i18n38.__)("Years ago") }
14004 ]
14005 };
14006 function RelativeDateControl({
14007 className,
14008 data,
14009 field,
14010 onChange,
14011 hideLabelFromVision,
14012 operator
14013 }) {
14014 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
14015 const { id, label, getValue, setValue } = field;
14016 const fieldValue = getValue({ item: data });
14017 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
14018 const onChangeValue = (0, import_element40.useCallback)(
14019 (newValue) => onChange(
14020 setValue({
14021 item: data,
14022 value: { value: Number(newValue), unit }
14023 })
14024 ),
14025 [onChange, setValue, data, unit]
14026 );
14027 const onChangeUnit = (0, import_element40.useCallback)(
14028 (newUnit) => onChange(
14029 setValue({
14030 item: data,
14031 value: { value: relValue, unit: newUnit }
14032 })
14033 ),
14034 [onChange, setValue, data, relValue]
14035 );
14036 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14037 import_components30.BaseControl,
14038 {
14039 id,
14040 className: clsx_default(className, "dataviews-controls__relative-date"),
14041 label,
14042 hideLabelFromVision,
14043 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "row", gap: "sm", children: [
14044 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14045 import_components30.__experimentalNumberControl,
14046 {
14047 __next40pxDefaultSize: true,
14048 className: "dataviews-controls__relative-date-number",
14049 spinControls: "none",
14050 min: 1,
14051 step: 1,
14052 value: relValue,
14053 onChange: onChangeValue
14054 }
14055 ),
14056 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14057 import_components30.SelectControl,
14058 {
14059 className: "dataviews-controls__relative-date-unit",
14060 __next40pxDefaultSize: true,
14061 label: (0, import_i18n38.__)("Unit"),
14062 value: unit,
14063 options,
14064 onChange: onChangeUnit,
14065 hideLabelFromVision: true
14066 }
14067 )
14068 ] })
14069 }
14070 );
14071 }
14072
14073 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
14074 var import_date2 = __toESM(require_date(), 1);
14075 function parseDateTime(dateTimeString) {
14076 if (!dateTimeString) {
14077 return null;
14078 }
14079 const parsed = (0, import_date2.getDate)(dateTimeString);
14080 return parsed && isValid(parsed) ? parsed : null;
14081 }
14082
14083 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14084 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
14085 var { DateCalendar, ValidatedInputControl } = unlock(import_components31.privateApis);
14086 var formatDateTime = (date) => {
14087 if (!date) {
14088 return "";
14089 }
14090 if (typeof date === "string") {
14091 return date;
14092 }
14093 return format(date, "yyyy-MM-dd'T'HH:mm");
14094 };
14095 function CalendarDateTimeControl({
14096 data,
14097 field,
14098 onChange,
14099 hideLabelFromVision,
14100 markWhenOptional,
14101 validity
14102 }) {
14103 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
14104 const fieldValue = getValue({ item: data });
14105 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14106 const [calendarMonth, setCalendarMonth] = (0, import_element41.useState)(() => {
14107 const parsedDate = parseDateTime(value);
14108 return parsedDate || /* @__PURE__ */ new Date();
14109 });
14110 const inputControlRef = (0, import_element41.useRef)(null);
14111 const validationTimeoutRef = (0, import_element41.useRef)(void 0);
14112 const previousFocusRef = (0, import_element41.useRef)(null);
14113 const onChangeCallback = (0, import_element41.useCallback)(
14114 (newValue) => onChange(setValue({ item: data, value: newValue })),
14115 [data, onChange, setValue]
14116 );
14117 (0, import_element41.useEffect)(() => {
14118 return () => {
14119 if (validationTimeoutRef.current) {
14120 clearTimeout(validationTimeoutRef.current);
14121 }
14122 };
14123 }, []);
14124 const onSelectDate = (0, import_element41.useCallback)(
14125 (newDate) => {
14126 let dateTimeValue;
14127 if (newDate) {
14128 let finalDateTime = newDate;
14129 if (value) {
14130 const currentDateTime = parseDateTime(value);
14131 if (currentDateTime) {
14132 finalDateTime = new Date(newDate);
14133 finalDateTime.setHours(currentDateTime.getHours());
14134 finalDateTime.setMinutes(
14135 currentDateTime.getMinutes()
14136 );
14137 }
14138 }
14139 dateTimeValue = finalDateTime.toISOString();
14140 onChangeCallback(dateTimeValue);
14141 if (validationTimeoutRef.current) {
14142 clearTimeout(validationTimeoutRef.current);
14143 }
14144 } else {
14145 onChangeCallback(void 0);
14146 }
14147 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
14148 validationTimeoutRef.current = setTimeout(() => {
14149 if (inputControlRef.current) {
14150 inputControlRef.current.focus();
14151 inputControlRef.current.blur();
14152 onChangeCallback(dateTimeValue);
14153 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
14154 previousFocusRef.current.focus();
14155 }
14156 }
14157 }, 0);
14158 },
14159 [onChangeCallback, value]
14160 );
14161 const handleManualDateTimeChange = (0, import_element41.useCallback)(
14162 (newValue) => {
14163 if (newValue) {
14164 const dateTime = new Date(newValue);
14165 onChangeCallback(dateTime.toISOString());
14166 const parsedDate = parseDateTime(dateTime.toISOString());
14167 if (parsedDate) {
14168 setCalendarMonth(parsedDate);
14169 }
14170 } else {
14171 onChangeCallback(void 0);
14172 }
14173 },
14174 [onChangeCallback]
14175 );
14176 const { format: fieldFormat } = field;
14177 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
14178 const {
14179 timezone: { string: timezoneString }
14180 } = (0, import_date3.getSettings)();
14181 let displayLabel = label;
14182 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
14183 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
14184 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
14185 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
14186 }
14187 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14188 import_components31.BaseControl,
14189 {
14190 id,
14191 label: displayLabel,
14192 help: description,
14193 hideLabelFromVision,
14194 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14195 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14196 DateCalendar,
14197 {
14198 style: { width: "100%" },
14199 selected: value ? parseDateTime(value) || void 0 : void 0,
14200 onSelect: onSelectDate,
14201 month: calendarMonth,
14202 onMonthChange: setCalendarMonth,
14203 timeZone: timezoneString || void 0,
14204 weekStartsOn
14205 }
14206 ),
14207 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14208 ValidatedInputControl,
14209 {
14210 ref: inputControlRef,
14211 __next40pxDefaultSize: true,
14212 required: !!isValid2?.required,
14213 customValidity: getCustomValidity(isValid2, validity),
14214 type: "datetime-local",
14215 label: (0, import_i18n39.__)("Date time"),
14216 hideLabelFromVision: true,
14217 value: value ? formatDateTime(
14218 parseDateTime(value) || void 0
14219 ) : "",
14220 onChange: handleManualDateTimeChange
14221 }
14222 )
14223 ] })
14224 }
14225 );
14226 }
14227 function DateTime({
14228 data,
14229 field,
14230 onChange,
14231 hideLabelFromVision,
14232 markWhenOptional,
14233 operator,
14234 validity
14235 }) {
14236 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14237 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14238 RelativeDateControl,
14239 {
14240 className: "dataviews-controls__datetime",
14241 data,
14242 field,
14243 onChange,
14244 hideLabelFromVision,
14245 operator
14246 }
14247 );
14248 }
14249 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14250 CalendarDateTimeControl,
14251 {
14252 data,
14253 field,
14254 onChange,
14255 hideLabelFromVision,
14256 markWhenOptional,
14257 validity
14258 }
14259 );
14260 }
14261
14262 // packages/dataviews/build-module/components/dataform-controls/date.mjs
14263 var import_components32 = __toESM(require_components(), 1);
14264 var import_element42 = __toESM(require_element(), 1);
14265 var import_i18n40 = __toESM(require_i18n(), 1);
14266 var import_date4 = __toESM(require_date(), 1);
14267 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
14268 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components32.privateApis);
14269 var DATE_PRESETS = [
14270 {
14271 id: "today",
14272 label: (0, import_i18n40.__)("Today"),
14273 getValue: () => (0, import_date4.getDate)(null)
14274 },
14275 {
14276 id: "yesterday",
14277 label: (0, import_i18n40.__)("Yesterday"),
14278 getValue: () => {
14279 const today = (0, import_date4.getDate)(null);
14280 return subDays(today, 1);
14281 }
14282 },
14283 {
14284 id: "past-week",
14285 label: (0, import_i18n40.__)("Past week"),
14286 getValue: () => {
14287 const today = (0, import_date4.getDate)(null);
14288 return subDays(today, 7);
14289 }
14290 },
14291 {
14292 id: "past-month",
14293 label: (0, import_i18n40.__)("Past month"),
14294 getValue: () => {
14295 const today = (0, import_date4.getDate)(null);
14296 return subMonths(today, 1);
14297 }
14298 }
14299 ];
14300 var DATE_RANGE_PRESETS = [
14301 {
14302 id: "last-7-days",
14303 label: (0, import_i18n40.__)("Last 7 days"),
14304 getValue: () => {
14305 const today = (0, import_date4.getDate)(null);
14306 return [subDays(today, 7), today];
14307 }
14308 },
14309 {
14310 id: "last-30-days",
14311 label: (0, import_i18n40.__)("Last 30 days"),
14312 getValue: () => {
14313 const today = (0, import_date4.getDate)(null);
14314 return [subDays(today, 30), today];
14315 }
14316 },
14317 {
14318 id: "month-to-date",
14319 label: (0, import_i18n40.__)("Month to date"),
14320 getValue: () => {
14321 const today = (0, import_date4.getDate)(null);
14322 return [startOfMonth(today), today];
14323 }
14324 },
14325 {
14326 id: "last-year",
14327 label: (0, import_i18n40.__)("Last year"),
14328 getValue: () => {
14329 const today = (0, import_date4.getDate)(null);
14330 return [subYears(today, 1), today];
14331 }
14332 },
14333 {
14334 id: "year-to-date",
14335 label: (0, import_i18n40.__)("Year to date"),
14336 getValue: () => {
14337 const today = (0, import_date4.getDate)(null);
14338 return [startOfYear(today), today];
14339 }
14340 }
14341 ];
14342 var parseDate = (dateString) => {
14343 if (!dateString) {
14344 return null;
14345 }
14346 const parsed = (0, import_date4.getDate)(dateString);
14347 return parsed && isValid(parsed) ? parsed : null;
14348 };
14349 var formatDate = (date) => {
14350 if (!date) {
14351 return "";
14352 }
14353 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
14354 };
14355 function ValidatedDateControl({
14356 field,
14357 validity,
14358 inputRefs,
14359 isTouched,
14360 setIsTouched,
14361 children
14362 }) {
14363 const { isValid: isValid2 } = field;
14364 const [customValidity, setCustomValidity] = (0, import_element42.useState)(void 0);
14365 const validateRefs = (0, import_element42.useCallback)(() => {
14366 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14367 for (const ref of refs) {
14368 const input = ref.current;
14369 if (input && !input.validity.valid) {
14370 setCustomValidity({
14371 type: "invalid",
14372 message: input.validationMessage
14373 });
14374 return;
14375 }
14376 }
14377 setCustomValidity(void 0);
14378 }, [inputRefs]);
14379 (0, import_element42.useEffect)(() => {
14380 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14381 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14382 for (const ref of refs) {
14383 const input = ref.current;
14384 if (input) {
14385 input.setCustomValidity(
14386 result?.type === "invalid" && result.message ? result.message : ""
14387 );
14388 }
14389 }
14390 }, [inputRefs, isValid2, validity]);
14391 (0, import_element42.useEffect)(() => {
14392 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14393 const handleInvalid = (event) => {
14394 event.preventDefault();
14395 setIsTouched(true);
14396 };
14397 for (const ref of refs) {
14398 ref.current?.addEventListener("invalid", handleInvalid);
14399 }
14400 return () => {
14401 for (const ref of refs) {
14402 ref.current?.removeEventListener("invalid", handleInvalid);
14403 }
14404 };
14405 }, [inputRefs, setIsTouched]);
14406 (0, import_element42.useEffect)(() => {
14407 if (!isTouched) {
14408 return;
14409 }
14410 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14411 if (result) {
14412 setCustomValidity(result);
14413 } else {
14414 validateRefs();
14415 }
14416 }, [isTouched, isValid2, validity, validateRefs]);
14417 const onBlur = (event) => {
14418 if (isTouched) {
14419 return;
14420 }
14421 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
14422 setIsTouched(true);
14423 }
14424 };
14425 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { onBlur, children: [
14426 children,
14427 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14428 "p",
14429 {
14430 className: clsx_default(
14431 "components-validated-control__indicator",
14432 customValidity.type === "invalid" ? "is-invalid" : void 0
14433 ),
14434 children: [
14435 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14436 import_components32.Icon,
14437 {
14438 className: "components-validated-control__indicator-icon",
14439 icon: error_default,
14440 size: 16,
14441 fill: "currentColor"
14442 }
14443 ),
14444 customValidity.message
14445 ]
14446 }
14447 ) })
14448 ] });
14449 }
14450 function CalendarDateControl({
14451 data,
14452 field,
14453 onChange,
14454 hideLabelFromVision,
14455 markWhenOptional,
14456 validity
14457 }) {
14458 const {
14459 id,
14460 label,
14461 setValue,
14462 getValue,
14463 isValid: isValid2,
14464 format: fieldFormat
14465 } = field;
14466 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)(
14467 null
14468 );
14469 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14470 const fieldValue = getValue({ item: data });
14471 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14472 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => {
14473 const parsedDate = parseDate(value);
14474 return parsedDate || /* @__PURE__ */ new Date();
14475 });
14476 const [isTouched, setIsTouched] = (0, import_element42.useState)(false);
14477 const validityTargetRef = (0, import_element42.useRef)(null);
14478 const onChangeCallback = (0, import_element42.useCallback)(
14479 (newValue) => onChange(setValue({ item: data, value: newValue })),
14480 [data, onChange, setValue]
14481 );
14482 const onSelectDate = (0, import_element42.useCallback)(
14483 (newDate) => {
14484 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
14485 onChangeCallback(dateValue);
14486 setSelectedPresetId(null);
14487 setIsTouched(true);
14488 },
14489 [onChangeCallback]
14490 );
14491 const handlePresetClick = (0, import_element42.useCallback)(
14492 (preset) => {
14493 const presetDate = preset.getValue();
14494 const dateValue = formatDate(presetDate);
14495 setCalendarMonth(presetDate);
14496 onChangeCallback(dateValue);
14497 setSelectedPresetId(preset.id);
14498 setIsTouched(true);
14499 },
14500 [onChangeCallback]
14501 );
14502 const handleManualDateChange = (0, import_element42.useCallback)(
14503 (newValue) => {
14504 onChangeCallback(newValue);
14505 if (newValue) {
14506 const parsedDate = parseDate(newValue);
14507 if (parsedDate) {
14508 setCalendarMonth(parsedDate);
14509 }
14510 }
14511 setSelectedPresetId(null);
14512 setIsTouched(true);
14513 },
14514 [onChangeCallback]
14515 );
14516 const {
14517 timezone: { string: timezoneString }
14518 } = (0, import_date4.getSettings)();
14519 let displayLabel = label;
14520 if (isValid2?.required && !markWhenOptional) {
14521 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
14522 } else if (!isValid2?.required && markWhenOptional) {
14523 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
14524 }
14525 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14526 ValidatedDateControl,
14527 {
14528 field,
14529 validity,
14530 inputRefs: validityTargetRef,
14531 isTouched,
14532 setIsTouched,
14533 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14534 import_components32.BaseControl,
14535 {
14536 id,
14537 className: "dataviews-controls__date",
14538 label: displayLabel,
14539 hideLabelFromVision,
14540 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14541 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14542 Stack,
14543 {
14544 direction: "row",
14545 gap: "sm",
14546 wrap: "wrap",
14547 justify: "flex-start",
14548 children: [
14549 DATE_PRESETS.map((preset) => {
14550 const isSelected2 = selectedPresetId === preset.id;
14551 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14552 import_components32.Button,
14553 {
14554 className: "dataviews-controls__date-preset",
14555 variant: "tertiary",
14556 isPressed: isSelected2,
14557 size: "small",
14558 onClick: () => handlePresetClick(preset),
14559 children: preset.label
14560 },
14561 preset.id
14562 );
14563 }),
14564 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14565 import_components32.Button,
14566 {
14567 className: "dataviews-controls__date-preset",
14568 variant: "tertiary",
14569 isPressed: !selectedPresetId,
14570 size: "small",
14571 disabled: !!selectedPresetId,
14572 accessibleWhenDisabled: false,
14573 children: (0, import_i18n40.__)("Custom")
14574 }
14575 )
14576 ]
14577 }
14578 ),
14579 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14580 import_components32.__experimentalInputControl,
14581 {
14582 __next40pxDefaultSize: true,
14583 ref: validityTargetRef,
14584 type: "date",
14585 label: (0, import_i18n40.__)("Date"),
14586 hideLabelFromVision: true,
14587 value,
14588 onChange: handleManualDateChange,
14589 required: !!field.isValid?.required
14590 }
14591 ),
14592 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14593 DateCalendar2,
14594 {
14595 style: { width: "100%" },
14596 selected: value ? parseDate(value) || void 0 : void 0,
14597 onSelect: onSelectDate,
14598 month: calendarMonth,
14599 onMonthChange: setCalendarMonth,
14600 timeZone: timezoneString || void 0,
14601 weekStartsOn
14602 }
14603 )
14604 ] })
14605 }
14606 )
14607 }
14608 );
14609 }
14610 function CalendarDateRangeControl({
14611 data,
14612 field,
14613 onChange,
14614 hideLabelFromVision,
14615 markWhenOptional,
14616 validity
14617 }) {
14618 const { id, label, getValue, setValue, format: fieldFormat } = field;
14619 let value;
14620 const fieldValue = getValue({ item: data });
14621 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
14622 value = fieldValue;
14623 }
14624 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14625 const onChangeCallback = (0, import_element42.useCallback)(
14626 (newValue) => {
14627 onChange(
14628 setValue({
14629 item: data,
14630 value: newValue
14631 })
14632 );
14633 },
14634 [data, onChange, setValue]
14635 );
14636 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)(
14637 null
14638 );
14639 const selectedRange = (0, import_element42.useMemo)(() => {
14640 if (!value) {
14641 return { from: void 0, to: void 0 };
14642 }
14643 const [from, to] = value;
14644 return {
14645 from: parseDate(from) || void 0,
14646 to: parseDate(to) || void 0
14647 };
14648 }, [value]);
14649 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => {
14650 return selectedRange.from || /* @__PURE__ */ new Date();
14651 });
14652 const [isTouched, setIsTouched] = (0, import_element42.useState)(false);
14653 const fromInputRef = (0, import_element42.useRef)(null);
14654 const toInputRef = (0, import_element42.useRef)(null);
14655 const updateDateRange = (0, import_element42.useCallback)(
14656 (fromDate, toDate2) => {
14657 if (fromDate && toDate2) {
14658 onChangeCallback([
14659 formatDate(fromDate),
14660 formatDate(toDate2)
14661 ]);
14662 } else if (!fromDate && !toDate2) {
14663 onChangeCallback(void 0);
14664 }
14665 },
14666 [onChangeCallback]
14667 );
14668 const onSelectCalendarRange = (0, import_element42.useCallback)(
14669 (newRange) => {
14670 updateDateRange(newRange?.from, newRange?.to);
14671 setSelectedPresetId(null);
14672 setIsTouched(true);
14673 },
14674 [updateDateRange]
14675 );
14676 const handlePresetClick = (0, import_element42.useCallback)(
14677 (preset) => {
14678 const [startDate, endDate] = preset.getValue();
14679 setCalendarMonth(startDate);
14680 updateDateRange(startDate, endDate);
14681 setSelectedPresetId(preset.id);
14682 setIsTouched(true);
14683 },
14684 [updateDateRange]
14685 );
14686 const handleManualDateChange = (0, import_element42.useCallback)(
14687 (fromOrTo, newValue) => {
14688 const [currentFrom, currentTo] = value || [
14689 void 0,
14690 void 0
14691 ];
14692 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
14693 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
14694 updateDateRange(updatedFrom, updatedTo);
14695 if (newValue) {
14696 const parsedDate = parseDate(newValue);
14697 if (parsedDate) {
14698 setCalendarMonth(parsedDate);
14699 }
14700 }
14701 setSelectedPresetId(null);
14702 setIsTouched(true);
14703 },
14704 [value, updateDateRange]
14705 );
14706 const { timezone } = (0, import_date4.getSettings)();
14707 let displayLabel = label;
14708 if (field.isValid?.required && !markWhenOptional) {
14709 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
14710 } else if (!field.isValid?.required && markWhenOptional) {
14711 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
14712 }
14713 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14714 ValidatedDateControl,
14715 {
14716 field,
14717 validity,
14718 inputRefs: [fromInputRef, toInputRef],
14719 isTouched,
14720 setIsTouched,
14721 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14722 import_components32.BaseControl,
14723 {
14724 id,
14725 className: "dataviews-controls__date",
14726 label: displayLabel,
14727 hideLabelFromVision,
14728 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14729 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14730 Stack,
14731 {
14732 direction: "row",
14733 gap: "sm",
14734 wrap: "wrap",
14735 justify: "flex-start",
14736 children: [
14737 DATE_RANGE_PRESETS.map((preset) => {
14738 const isSelected2 = selectedPresetId === preset.id;
14739 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14740 import_components32.Button,
14741 {
14742 className: "dataviews-controls__date-preset",
14743 variant: "tertiary",
14744 isPressed: isSelected2,
14745 size: "small",
14746 onClick: () => handlePresetClick(preset),
14747 children: preset.label
14748 },
14749 preset.id
14750 );
14751 }),
14752 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14753 import_components32.Button,
14754 {
14755 className: "dataviews-controls__date-preset",
14756 variant: "tertiary",
14757 isPressed: !selectedPresetId,
14758 size: "small",
14759 accessibleWhenDisabled: false,
14760 disabled: !!selectedPresetId,
14761 children: (0, import_i18n40.__)("Custom")
14762 }
14763 )
14764 ]
14765 }
14766 ),
14767 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14768 Stack,
14769 {
14770 direction: "row",
14771 gap: "sm",
14772 justify: "space-between",
14773 className: "dataviews-controls__date-range-inputs",
14774 children: [
14775 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14776 import_components32.__experimentalInputControl,
14777 {
14778 __next40pxDefaultSize: true,
14779 ref: fromInputRef,
14780 type: "date",
14781 label: (0, import_i18n40.__)("From"),
14782 hideLabelFromVision: true,
14783 value: value?.[0],
14784 onChange: (newValue) => handleManualDateChange("from", newValue),
14785 required: !!field.isValid?.required
14786 }
14787 ),
14788 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14789 import_components32.__experimentalInputControl,
14790 {
14791 __next40pxDefaultSize: true,
14792 ref: toInputRef,
14793 type: "date",
14794 label: (0, import_i18n40.__)("To"),
14795 hideLabelFromVision: true,
14796 value: value?.[1],
14797 onChange: (newValue) => handleManualDateChange("to", newValue),
14798 required: !!field.isValid?.required
14799 }
14800 )
14801 ]
14802 }
14803 ),
14804 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14805 DateRangeCalendar,
14806 {
14807 style: { width: "100%" },
14808 selected: selectedRange,
14809 onSelect: onSelectCalendarRange,
14810 month: calendarMonth,
14811 onMonthChange: setCalendarMonth,
14812 timeZone: timezone.string || void 0,
14813 weekStartsOn
14814 }
14815 )
14816 ] })
14817 }
14818 )
14819 }
14820 );
14821 }
14822 function DateControl({
14823 data,
14824 field,
14825 onChange,
14826 hideLabelFromVision,
14827 markWhenOptional,
14828 operator,
14829 validity
14830 }) {
14831 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14832 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14833 RelativeDateControl,
14834 {
14835 className: "dataviews-controls__date",
14836 data,
14837 field,
14838 onChange,
14839 hideLabelFromVision,
14840 operator
14841 }
14842 );
14843 }
14844 if (operator === OPERATOR_BETWEEN) {
14845 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14846 CalendarDateRangeControl,
14847 {
14848 data,
14849 field,
14850 onChange,
14851 hideLabelFromVision,
14852 markWhenOptional,
14853 validity
14854 }
14855 );
14856 }
14857 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14858 CalendarDateControl,
14859 {
14860 data,
14861 field,
14862 onChange,
14863 hideLabelFromVision,
14864 markWhenOptional,
14865 validity
14866 }
14867 );
14868 }
14869
14870 // packages/dataviews/build-module/components/dataform-controls/select.mjs
14871 var import_components33 = __toESM(require_components(), 1);
14872 var import_element43 = __toESM(require_element(), 1);
14873 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
14874 var { ValidatedSelectControl } = unlock(import_components33.privateApis);
14875 function Select({
14876 data,
14877 field,
14878 onChange,
14879 hideLabelFromVision,
14880 markWhenOptional,
14881 validity
14882 }) {
14883 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
14884 const isMultiple = type === "array";
14885 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
14886 const onChangeControl = (0, import_element43.useCallback)(
14887 (newValue) => onChange(setValue({ item: data, value: newValue })),
14888 [data, onChange, setValue]
14889 );
14890 const { elements, isLoading } = useElements({
14891 elements: field.elements,
14892 getElements: field.getElements
14893 });
14894 if (isLoading) {
14895 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components33.Spinner, {});
14896 }
14897 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14898 ValidatedSelectControl,
14899 {
14900 required: !!field.isValid?.required,
14901 markWhenOptional,
14902 customValidity: getCustomValidity(isValid2, validity),
14903 label,
14904 value,
14905 help: description,
14906 options: elements,
14907 onChange: onChangeControl,
14908 __next40pxDefaultSize: true,
14909 hideLabelFromVision,
14910 multiple: isMultiple
14911 }
14912 );
14913 }
14914
14915 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
14916 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
14917 var ELEMENTS_THRESHOLD = 10;
14918 function AdaptiveSelect(props) {
14919 const { field } = props;
14920 const { elements } = useElements({
14921 elements: field.elements,
14922 getElements: field.getElements
14923 });
14924 if (elements.length >= ELEMENTS_THRESHOLD) {
14925 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Combobox3, { ...props });
14926 }
14927 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Select, { ...props });
14928 }
14929
14930 // packages/dataviews/build-module/components/dataform-controls/email.mjs
14931 var import_components35 = __toESM(require_components(), 1);
14932
14933 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
14934 var import_components34 = __toESM(require_components(), 1);
14935 var import_element44 = __toESM(require_element(), 1);
14936 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
14937 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components34.privateApis);
14938 function ValidatedText({
14939 data,
14940 field,
14941 onChange,
14942 hideLabelFromVision,
14943 markWhenOptional,
14944 type,
14945 prefix,
14946 suffix,
14947 validity
14948 }) {
14949 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
14950 const value = getValue({ item: data });
14951 const onChangeControl = (0, import_element44.useCallback)(
14952 (newValue) => onChange(
14953 setValue({
14954 item: data,
14955 value: newValue
14956 })
14957 ),
14958 [data, setValue, onChange]
14959 );
14960 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
14961 ValidatedInputControl2,
14962 {
14963 required: !!isValid2.required,
14964 markWhenOptional,
14965 customValidity: getCustomValidity(isValid2, validity),
14966 label,
14967 placeholder,
14968 value: value ?? "",
14969 help: description,
14970 onChange: onChangeControl,
14971 hideLabelFromVision,
14972 type,
14973 prefix,
14974 suffix,
14975 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
14976 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
14977 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
14978 __next40pxDefaultSize: true
14979 }
14980 );
14981 }
14982
14983 // packages/dataviews/build-module/components/dataform-controls/email.mjs
14984 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
14985 function Email({
14986 data,
14987 field,
14988 onChange,
14989 hideLabelFromVision,
14990 markWhenOptional,
14991 validity
14992 }) {
14993 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
14994 ValidatedText,
14995 {
14996 ...{
14997 data,
14998 field,
14999 onChange,
15000 hideLabelFromVision,
15001 markWhenOptional,
15002 validity,
15003 type: "email",
15004 prefix: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components35.Icon, { icon: envelope_default }) })
15005 }
15006 }
15007 );
15008 }
15009
15010 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
15011 var import_components36 = __toESM(require_components(), 1);
15012 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15013 function Telephone({
15014 data,
15015 field,
15016 onChange,
15017 hideLabelFromVision,
15018 markWhenOptional,
15019 validity
15020 }) {
15021 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
15022 ValidatedText,
15023 {
15024 ...{
15025 data,
15026 field,
15027 onChange,
15028 hideLabelFromVision,
15029 markWhenOptional,
15030 validity,
15031 type: "tel",
15032 prefix: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components36.Icon, { icon: mobile_default }) })
15033 }
15034 }
15035 );
15036 }
15037
15038 // packages/dataviews/build-module/components/dataform-controls/url.mjs
15039 var import_components37 = __toESM(require_components(), 1);
15040 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15041 function Url({
15042 data,
15043 field,
15044 onChange,
15045 hideLabelFromVision,
15046 markWhenOptional,
15047 validity
15048 }) {
15049 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15050 ValidatedText,
15051 {
15052 ...{
15053 data,
15054 field,
15055 onChange,
15056 hideLabelFromVision,
15057 markWhenOptional,
15058 validity,
15059 type: "url",
15060 prefix: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components37.Icon, { icon: link_default }) })
15061 }
15062 }
15063 );
15064 }
15065
15066 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
15067 var import_components38 = __toESM(require_components(), 1);
15068 var import_element45 = __toESM(require_element(), 1);
15069 var import_i18n41 = __toESM(require_i18n(), 1);
15070 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15071 var { ValidatedNumberControl } = unlock(import_components38.privateApis);
15072 function toNumberOrEmpty(value) {
15073 if (value === "" || value === void 0) {
15074 return "";
15075 }
15076 const number = Number(value);
15077 return Number.isFinite(number) ? number : "";
15078 }
15079 function BetweenControls({
15080 value,
15081 onChange,
15082 hideLabelFromVision,
15083 step
15084 }) {
15085 const [min = "", max = ""] = value;
15086 const onChangeMin = (0, import_element45.useCallback)(
15087 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
15088 [onChange, max]
15089 );
15090 const onChangeMax = (0, import_element45.useCallback)(
15091 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
15092 [onChange, min]
15093 );
15094 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15095 import_components38.BaseControl,
15096 {
15097 help: (0, import_i18n41.__)("The max. value must be greater than the min. value."),
15098 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_components38.Flex, { direction: "row", gap: 4, children: [
15099 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15100 import_components38.__experimentalNumberControl,
15101 {
15102 label: (0, import_i18n41.__)("Min."),
15103 value: min,
15104 max: max ? Number(max) - step : void 0,
15105 onChange: onChangeMin,
15106 __next40pxDefaultSize: true,
15107 hideLabelFromVision,
15108 step
15109 }
15110 ),
15111 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15112 import_components38.__experimentalNumberControl,
15113 {
15114 label: (0, import_i18n41.__)("Max."),
15115 value: max,
15116 min: min ? Number(min) + step : void 0,
15117 onChange: onChangeMax,
15118 __next40pxDefaultSize: true,
15119 hideLabelFromVision,
15120 step
15121 }
15122 )
15123 ] })
15124 }
15125 );
15126 }
15127 function ValidatedNumber({
15128 data,
15129 field,
15130 onChange,
15131 hideLabelFromVision,
15132 markWhenOptional,
15133 operator,
15134 validity
15135 }) {
15136 const decimals = field.format?.decimals ?? 0;
15137 const step = Math.pow(10, Math.abs(decimals) * -1);
15138 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15139 const value = getValue({ item: data }) ?? "";
15140 const onChangeControl = (0, import_element45.useCallback)(
15141 (newValue) => {
15142 onChange(
15143 setValue({
15144 item: data,
15145 // Do not convert an empty string or undefined to a number,
15146 // otherwise there's a mismatch between the UI control (empty)
15147 // and the data relied by onChange (0).
15148 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
15149 })
15150 );
15151 },
15152 [data, onChange, setValue]
15153 );
15154 const onChangeBetweenControls = (0, import_element45.useCallback)(
15155 (newValue) => {
15156 onChange(
15157 setValue({
15158 item: data,
15159 value: newValue
15160 })
15161 );
15162 },
15163 [data, onChange, setValue]
15164 );
15165 if (operator === OPERATOR_BETWEEN) {
15166 let valueBetween = ["", ""];
15167 if (Array.isArray(value) && value.length === 2 && value.every(
15168 (element) => typeof element === "number" || element === ""
15169 )) {
15170 valueBetween = value;
15171 }
15172 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15173 BetweenControls,
15174 {
15175 value: valueBetween,
15176 onChange: onChangeBetweenControls,
15177 hideLabelFromVision,
15178 step
15179 }
15180 );
15181 }
15182 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15183 ValidatedNumberControl,
15184 {
15185 required: !!isValid2.required,
15186 markWhenOptional,
15187 customValidity: getCustomValidity(isValid2, validity),
15188 label,
15189 help: description,
15190 value,
15191 onChange: onChangeControl,
15192 __next40pxDefaultSize: true,
15193 hideLabelFromVision,
15194 step,
15195 min: isValid2.min ? isValid2.min.constraint : void 0,
15196 max: isValid2.max ? isValid2.max.constraint : void 0
15197 }
15198 );
15199 }
15200
15201 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
15202 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15203 function Integer(props) {
15204 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ValidatedNumber, { ...props });
15205 }
15206
15207 // packages/dataviews/build-module/components/dataform-controls/number.mjs
15208 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15209 function Number2(props) {
15210 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ValidatedNumber, { ...props });
15211 }
15212
15213 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
15214 var import_components39 = __toESM(require_components(), 1);
15215 var import_element46 = __toESM(require_element(), 1);
15216 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15217 var { ValidatedRadioControl } = unlock(import_components39.privateApis);
15218 function Radio({
15219 data,
15220 field,
15221 onChange,
15222 hideLabelFromVision,
15223 markWhenOptional,
15224 validity
15225 }) {
15226 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15227 const { elements, isLoading } = useElements({
15228 elements: field.elements,
15229 getElements: field.getElements
15230 });
15231 const value = getValue({ item: data });
15232 const onChangeControl = (0, import_element46.useCallback)(
15233 (newValue) => onChange(setValue({ item: data, value: newValue })),
15234 [data, onChange, setValue]
15235 );
15236 if (isLoading) {
15237 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components39.Spinner, {});
15238 }
15239 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15240 ValidatedRadioControl,
15241 {
15242 required: !!field.isValid?.required,
15243 markWhenOptional,
15244 customValidity: getCustomValidity(isValid2, validity),
15245 label,
15246 help: description,
15247 onChange: onChangeControl,
15248 options: elements,
15249 selected: value,
15250 hideLabelFromVision
15251 }
15252 );
15253 }
15254
15255 // packages/dataviews/build-module/components/dataform-controls/text.mjs
15256 var import_element47 = __toESM(require_element(), 1);
15257 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
15258 function Text({
15259 data,
15260 field,
15261 onChange,
15262 hideLabelFromVision,
15263 markWhenOptional,
15264 config,
15265 validity
15266 }) {
15267 const { prefix, suffix } = config || {};
15268 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15269 ValidatedText,
15270 {
15271 ...{
15272 data,
15273 field,
15274 onChange,
15275 hideLabelFromVision,
15276 markWhenOptional,
15277 validity,
15278 prefix: prefix ? (0, import_element47.createElement)(prefix) : void 0,
15279 suffix: suffix ? (0, import_element47.createElement)(suffix) : void 0
15280 }
15281 }
15282 );
15283 }
15284
15285 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
15286 var import_components40 = __toESM(require_components(), 1);
15287 var import_element48 = __toESM(require_element(), 1);
15288 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
15289 var { ValidatedToggleControl } = unlock(import_components40.privateApis);
15290 function Toggle({
15291 field,
15292 onChange,
15293 data,
15294 hideLabelFromVision,
15295 markWhenOptional,
15296 validity
15297 }) {
15298 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15299 const onChangeControl = (0, import_element48.useCallback)(() => {
15300 onChange(
15301 setValue({ item: data, value: !getValue({ item: data }) })
15302 );
15303 }, [onChange, setValue, data, getValue]);
15304 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15305 ValidatedToggleControl,
15306 {
15307 required: !!isValid2.required,
15308 markWhenOptional,
15309 customValidity: getCustomValidity(isValid2, validity),
15310 hidden: hideLabelFromVision,
15311 label,
15312 help: description,
15313 checked: getValue({ item: data }),
15314 onChange: onChangeControl
15315 }
15316 );
15317 }
15318
15319 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
15320 var import_components41 = __toESM(require_components(), 1);
15321 var import_element49 = __toESM(require_element(), 1);
15322 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
15323 var { ValidatedTextareaControl } = unlock(import_components41.privateApis);
15324 function Textarea({
15325 data,
15326 field,
15327 onChange,
15328 hideLabelFromVision,
15329 markWhenOptional,
15330 config,
15331 validity
15332 }) {
15333 const { rows = 4 } = config || {};
15334 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15335 const value = field.getValue({ item: data });
15336 const onChangeControl = (0, import_element49.useCallback)(
15337 (newValue) => onChange(setValue({ item: data, value: newValue })),
15338 [data, onChange, setValue]
15339 );
15340 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
15341 ValidatedTextareaControl,
15342 {
15343 required: !!isValid2.required,
15344 markWhenOptional,
15345 customValidity: getCustomValidity(isValid2, validity),
15346 label,
15347 placeholder,
15348 value: value ?? "",
15349 help: description,
15350 onChange: onChangeControl,
15351 rows,
15352 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15353 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15354 __next40pxDefaultSize: true,
15355 hideLabelFromVision
15356 }
15357 );
15358 }
15359
15360 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
15361 var import_components42 = __toESM(require_components(), 1);
15362 var import_element50 = __toESM(require_element(), 1);
15363 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
15364 var { ValidatedToggleGroupControl } = unlock(import_components42.privateApis);
15365 function ToggleGroup({
15366 data,
15367 field,
15368 onChange,
15369 hideLabelFromVision,
15370 markWhenOptional,
15371 validity
15372 }) {
15373 const { getValue, setValue, isValid: isValid2 } = field;
15374 const value = getValue({ item: data });
15375 const onChangeControl = (0, import_element50.useCallback)(
15376 (newValue) => onChange(setValue({ item: data, value: newValue })),
15377 [data, onChange, setValue]
15378 );
15379 const { elements, isLoading } = useElements({
15380 elements: field.elements,
15381 getElements: field.getElements
15382 });
15383 if (isLoading) {
15384 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components42.Spinner, {});
15385 }
15386 if (elements.length === 0) {
15387 return null;
15388 }
15389 const selectedOption = elements.find((el) => el.value === value);
15390 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
15391 ValidatedToggleGroupControl,
15392 {
15393 required: !!field.isValid?.required,
15394 markWhenOptional,
15395 customValidity: getCustomValidity(isValid2, validity),
15396 __next40pxDefaultSize: true,
15397 isBlock: true,
15398 label: field.label,
15399 help: selectedOption?.description || field.description,
15400 onChange: onChangeControl,
15401 value,
15402 hideLabelFromVision,
15403 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
15404 import_components42.__experimentalToggleGroupControlOption,
15405 {
15406 label: el.label,
15407 value: el.value
15408 },
15409 el.value
15410 ))
15411 }
15412 );
15413 }
15414
15415 // packages/dataviews/build-module/components/dataform-controls/array.mjs
15416 var import_components43 = __toESM(require_components(), 1);
15417 var import_element51 = __toESM(require_element(), 1);
15418 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
15419 var { ValidatedFormTokenField } = unlock(import_components43.privateApis);
15420 function ArrayControl({
15421 data,
15422 field,
15423 onChange,
15424 hideLabelFromVision,
15425 markWhenOptional,
15426 validity
15427 }) {
15428 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field;
15429 const value = getValue({ item: data });
15430 const { elements, isLoading } = useElements({
15431 elements: field.elements,
15432 getElements: field.getElements
15433 });
15434 const arrayValueAsElements = (0, import_element51.useMemo)(
15435 () => Array.isArray(value) ? value.map((token) => {
15436 const element = elements?.find(
15437 (suggestion) => suggestion.value === token
15438 );
15439 return element || { value: token, label: token };
15440 }) : [],
15441 [value, elements]
15442 );
15443 const onChangeControl = (0, import_element51.useCallback)(
15444 (tokens) => {
15445 const valueTokens = tokens.map((token) => {
15446 if (typeof token === "object" && "value" in token) {
15447 return token.value;
15448 }
15449 return token;
15450 });
15451 onChange(setValue({ item: data, value: valueTokens }));
15452 },
15453 [onChange, setValue, data]
15454 );
15455 if (isLoading) {
15456 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components43.Spinner, {});
15457 }
15458 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
15459 ValidatedFormTokenField,
15460 {
15461 required: !!isValid2?.required,
15462 markWhenOptional,
15463 customValidity: getCustomValidity(isValid2, validity),
15464 label: hideLabelFromVision ? void 0 : label,
15465 value: arrayValueAsElements,
15466 onChange: onChangeControl,
15467 placeholder,
15468 suggestions: elements?.map((element) => element.value),
15469 __experimentalValidateInput: (token) => {
15470 if (field.isValid?.elements && elements) {
15471 return elements.some(
15472 (element) => element.value === token || element.label === token
15473 );
15474 }
15475 return true;
15476 },
15477 __experimentalExpandOnFocus: elements && elements.length > 0,
15478 __experimentalShowHowTo: !field.isValid?.elements,
15479 displayTransform: (token) => {
15480 if (typeof token === "object" && "label" in token) {
15481 return token.label;
15482 }
15483 if (typeof token === "string" && elements) {
15484 const element = elements.find(
15485 (el) => el.value === token
15486 );
15487 return element?.label || token;
15488 }
15489 return token;
15490 },
15491 __experimentalRenderItem: ({ item }) => {
15492 if (typeof item === "string" && elements) {
15493 const element = elements.find(
15494 (el) => el.value === item
15495 );
15496 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: element?.label || item });
15497 }
15498 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: item });
15499 }
15500 }
15501 );
15502 }
15503
15504 // node_modules/colord/index.mjs
15505 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
15506 var t = function(r3) {
15507 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
15508 };
15509 var n = function(r3, t2, n2) {
15510 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
15511 };
15512 var e = function(r3, t2, n2) {
15513 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
15514 };
15515 var u = function(r3) {
15516 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
15517 };
15518 var a = function(r3) {
15519 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
15520 };
15521 var o = function(r3) {
15522 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
15523 };
15524 var i = /^#([0-9a-f]{3,8})$/i;
15525 var s = function(r3) {
15526 var t2 = r3.toString(16);
15527 return t2.length < 2 ? "0" + t2 : t2;
15528 };
15529 var h = function(r3) {
15530 var t2 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t2, n2, e2), o2 = a2 - Math.min(t2, n2, e2), i2 = o2 ? a2 === t2 ? (n2 - e2) / o2 : a2 === n2 ? 2 + (e2 - t2) / o2 : 4 + (t2 - n2) / o2 : 0;
15531 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
15532 };
15533 var b = function(r3) {
15534 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
15535 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
15536 var a2 = Math.floor(t2), o2 = e2 * (1 - n2), i2 = e2 * (1 - (t2 - a2) * n2), s2 = e2 * (1 - (1 - t2 + a2) * n2), h2 = a2 % 6;
15537 return { r: 255 * [e2, i2, o2, o2, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o2, o2][h2], b: 255 * [o2, o2, s2, e2, e2, i2][h2], a: u2 };
15538 };
15539 var g = function(r3) {
15540 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
15541 };
15542 var d = function(r3) {
15543 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
15544 };
15545 var f = function(r3) {
15546 return b((n2 = (t2 = r3).s, { h: t2.h, s: (n2 *= ((e2 = t2.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t2.a }));
15547 var t2, n2, e2;
15548 };
15549 var c = function(r3) {
15550 return { h: (t2 = h(r3)).h, s: (u2 = (200 - (n2 = t2.s)) * (e2 = t2.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t2.a };
15551 var t2, n2, e2, u2;
15552 };
15553 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15554 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15555 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15556 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15557 var y = { string: [[function(r3) {
15558 var t2 = i.exec(r3);
15559 return t2 ? (r3 = t2[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
15560 }, "hex"], [function(r3) {
15561 var t2 = v.exec(r3) || m.exec(r3);
15562 return t2 ? t2[2] !== t2[4] || t2[4] !== t2[6] ? null : a({ r: Number(t2[1]) / (t2[2] ? 100 / 255 : 1), g: Number(t2[3]) / (t2[4] ? 100 / 255 : 1), b: Number(t2[5]) / (t2[6] ? 100 / 255 : 1), a: void 0 === t2[7] ? 1 : Number(t2[7]) / (t2[8] ? 100 : 1) }) : null;
15563 }, "rgb"], [function(t2) {
15564 var n2 = l.exec(t2) || p.exec(t2);
15565 if (!n2) return null;
15566 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
15567 return f(a2);
15568 }, "hsl"]], object: [[function(r3) {
15569 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
15570 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
15571 }, "rgb"], [function(r3) {
15572 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
15573 if (!t(n2) || !t(e2) || !t(u2)) return null;
15574 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
15575 return f(i2);
15576 }, "hsl"], [function(r3) {
15577 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
15578 if (!t(n2) || !t(a2) || !t(o2)) return null;
15579 var h2 = (function(r4) {
15580 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
15581 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
15582 return b(h2);
15583 }, "hsv"]] };
15584 var N = function(r3, t2) {
15585 for (var n2 = 0; n2 < t2.length; n2++) {
15586 var e2 = t2[n2][0](r3);
15587 if (e2) return [e2, t2[n2][1]];
15588 }
15589 return [null, void 0];
15590 };
15591 var x = function(r3) {
15592 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
15593 };
15594 var M = function(r3, t2) {
15595 var n2 = c(r3);
15596 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
15597 };
15598 var H = function(r3) {
15599 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
15600 };
15601 var $ = function(r3, t2) {
15602 var n2 = c(r3);
15603 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
15604 };
15605 var j = (function() {
15606 function r3(r4) {
15607 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
15608 }
15609 return r3.prototype.isValid = function() {
15610 return null !== this.parsed;
15611 }, r3.prototype.brightness = function() {
15612 return n(H(this.rgba), 2);
15613 }, r3.prototype.isDark = function() {
15614 return H(this.rgba) < 0.5;
15615 }, r3.prototype.isLight = function() {
15616 return H(this.rgba) >= 0.5;
15617 }, r3.prototype.toHex = function() {
15618 return r4 = o(this.rgba), t2 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t2) + s(e2) + s(u2) + i2;
15619 var r4, t2, e2, u2, a2, i2;
15620 }, r3.prototype.toRgb = function() {
15621 return o(this.rgba);
15622 }, r3.prototype.toRgbString = function() {
15623 return r4 = o(this.rgba), t2 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t2 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t2 + ", " + n2 + ", " + e2 + ")";
15624 var r4, t2, n2, e2, u2;
15625 }, r3.prototype.toHsl = function() {
15626 return d(c(this.rgba));
15627 }, r3.prototype.toHslString = function() {
15628 return r4 = d(c(this.rgba)), t2 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t2 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t2 + ", " + n2 + "%, " + e2 + "%)";
15629 var r4, t2, n2, e2, u2;
15630 }, r3.prototype.toHsv = function() {
15631 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
15632 var r4;
15633 }, r3.prototype.invert = function() {
15634 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
15635 var r4;
15636 }, r3.prototype.saturate = function(r4) {
15637 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
15638 }, r3.prototype.desaturate = function(r4) {
15639 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
15640 }, r3.prototype.grayscale = function() {
15641 return w(M(this.rgba, -1));
15642 }, r3.prototype.lighten = function(r4) {
15643 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
15644 }, r3.prototype.darken = function(r4) {
15645 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
15646 }, r3.prototype.rotate = function(r4) {
15647 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
15648 }, r3.prototype.alpha = function(r4) {
15649 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
15650 var t2;
15651 }, r3.prototype.hue = function(r4) {
15652 var t2 = c(this.rgba);
15653 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
15654 }, r3.prototype.isEqual = function(r4) {
15655 return this.toHex() === w(r4).toHex();
15656 }, r3;
15657 })();
15658 var w = function(r3) {
15659 return r3 instanceof j ? r3 : new j(r3);
15660 };
15661
15662 // packages/dataviews/build-module/components/dataform-controls/color.mjs
15663 var import_components44 = __toESM(require_components(), 1);
15664 var import_element52 = __toESM(require_element(), 1);
15665 var import_i18n42 = __toESM(require_i18n(), 1);
15666 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
15667 var { ValidatedInputControl: ValidatedInputControl3 } = unlock(import_components44.privateApis);
15668 var ColorPickerDropdown = ({
15669 color,
15670 onColorChange
15671 }) => {
15672 const validColor = color && w(color).isValid() ? color : "#ffffff";
15673 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15674 import_components44.Dropdown,
15675 {
15676 className: "dataviews-controls__color-picker-dropdown",
15677 popoverProps: { resize: false },
15678 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15679 import_components44.Button,
15680 {
15681 onClick: onToggle,
15682 "aria-label": (0, import_i18n42.__)("Open color picker"),
15683 size: "small",
15684 icon: () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components44.ColorIndicator, { colorValue: validColor })
15685 }
15686 ),
15687 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components44.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15688 import_components44.ColorPicker,
15689 {
15690 color: validColor,
15691 onChange: onColorChange,
15692 enableAlpha: true
15693 }
15694 ) })
15695 }
15696 );
15697 };
15698 function Color({
15699 data,
15700 field,
15701 onChange,
15702 hideLabelFromVision,
15703 markWhenOptional,
15704 validity
15705 }) {
15706 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15707 const value = field.getValue({ item: data }) || "";
15708 const handleColorChange = (0, import_element52.useCallback)(
15709 (newColor) => {
15710 onChange(setValue({ item: data, value: newColor }));
15711 },
15712 [data, onChange, setValue]
15713 );
15714 const handleInputChange = (0, import_element52.useCallback)(
15715 (newValue) => {
15716 onChange(setValue({ item: data, value: newValue || "" }));
15717 },
15718 [data, onChange, setValue]
15719 );
15720 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15721 ValidatedInputControl3,
15722 {
15723 required: !!field.isValid?.required,
15724 markWhenOptional,
15725 customValidity: getCustomValidity(isValid2, validity),
15726 label,
15727 placeholder,
15728 value,
15729 help: description,
15730 onChange: handleInputChange,
15731 hideLabelFromVision,
15732 type: "text",
15733 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components44.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15734 ColorPickerDropdown,
15735 {
15736 color: value,
15737 onColorChange: handleColorChange
15738 }
15739 ) })
15740 }
15741 );
15742 }
15743
15744 // packages/dataviews/build-module/components/dataform-controls/password.mjs
15745 var import_components45 = __toESM(require_components(), 1);
15746 var import_element53 = __toESM(require_element(), 1);
15747 var import_i18n43 = __toESM(require_i18n(), 1);
15748 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
15749 function Password({
15750 data,
15751 field,
15752 onChange,
15753 hideLabelFromVision,
15754 markWhenOptional,
15755 validity
15756 }) {
15757 const [isVisible2, setIsVisible] = (0, import_element53.useState)(false);
15758 const toggleVisibility = (0, import_element53.useCallback)(() => {
15759 setIsVisible((prev) => !prev);
15760 }, []);
15761 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
15762 ValidatedText,
15763 {
15764 ...{
15765 data,
15766 field,
15767 onChange,
15768 hideLabelFromVision,
15769 markWhenOptional,
15770 validity,
15771 type: isVisible2 ? "text" : "password",
15772 suffix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components45.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
15773 import_components45.Button,
15774 {
15775 icon: isVisible2 ? unseen_default : seen_default,
15776 onClick: toggleVisibility,
15777 size: "small",
15778 label: isVisible2 ? (0, import_i18n43.__)("Hide password") : (0, import_i18n43.__)("Show password")
15779 }
15780 ) })
15781 }
15782 }
15783 );
15784 }
15785
15786 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
15787 function hasElements(field) {
15788 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
15789 }
15790
15791 // packages/dataviews/build-module/components/dataform-controls/index.mjs
15792 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
15793 var FORM_CONTROLS = {
15794 adaptiveSelect: AdaptiveSelect,
15795 array: ArrayControl,
15796 checkbox: Checkbox,
15797 color: Color,
15798 combobox: Combobox3,
15799 datetime: DateTime,
15800 date: DateControl,
15801 email: Email,
15802 telephone: Telephone,
15803 url: Url,
15804 integer: Integer,
15805 number: Number2,
15806 password: Password,
15807 radio: Radio,
15808 select: Select,
15809 text: Text,
15810 toggle: Toggle,
15811 textarea: Textarea,
15812 toggleGroup: ToggleGroup
15813 };
15814 function isEditConfig(value) {
15815 return value && typeof value === "object" && typeof value.control === "string";
15816 }
15817 function createConfiguredControl(config) {
15818 const { control, ...controlConfig } = config;
15819 const BaseControlType = getControlByType(control);
15820 if (BaseControlType === null) {
15821 return null;
15822 }
15823 return function ConfiguredControl(props) {
15824 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(BaseControlType, { ...props, config: controlConfig });
15825 };
15826 }
15827 function getControl(field, fallback) {
15828 if (typeof field.Edit === "function") {
15829 return field.Edit;
15830 }
15831 if (typeof field.Edit === "string") {
15832 return getControlByType(field.Edit);
15833 }
15834 if (isEditConfig(field.Edit)) {
15835 return createConfiguredControl(field.Edit);
15836 }
15837 if (hasElements(field) && field.type !== "array") {
15838 return getControlByType("adaptiveSelect");
15839 }
15840 if (fallback === null) {
15841 return null;
15842 }
15843 return getControlByType(fallback);
15844 }
15845 function getControlByType(type) {
15846 if (Object.keys(FORM_CONTROLS).includes(type)) {
15847 return FORM_CONTROLS[type];
15848 }
15849 return null;
15850 }
15851
15852 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
15853 function getFilterBy(field, defaultOperators, validOperators) {
15854 if (field.filterBy === false) {
15855 return false;
15856 }
15857 const operators = field.filterBy?.operators?.filter(
15858 (op) => validOperators.includes(op)
15859 ) ?? defaultOperators;
15860 if (operators.length === 0) {
15861 return false;
15862 }
15863 return {
15864 isPrimary: !!field.filterBy?.isPrimary,
15865 operators
15866 };
15867 }
15868 var get_filter_by_default = getFilterBy;
15869
15870 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
15871 var getValueFromId = (id) => ({ item }) => {
15872 const path = id.split(".");
15873 let value = item;
15874 for (const segment of path) {
15875 if (value.hasOwnProperty(segment)) {
15876 value = value[segment];
15877 } else {
15878 value = void 0;
15879 }
15880 }
15881 return value;
15882 };
15883 var get_value_from_id_default = getValueFromId;
15884
15885 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
15886 var setValueFromId = (id) => ({ value }) => {
15887 const path = id.split(".");
15888 const result = {};
15889 let current = result;
15890 for (const segment of path.slice(0, -1)) {
15891 current[segment] = {};
15892 current = current[segment];
15893 }
15894 current[path.at(-1)] = value;
15895 return result;
15896 };
15897 var set_value_from_id_default = setValueFromId;
15898
15899 // packages/dataviews/build-module/field-types/email.mjs
15900 var import_i18n44 = __toESM(require_i18n(), 1);
15901
15902 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
15903 function RenderFromElements({
15904 item,
15905 field
15906 }) {
15907 const { elements, isLoading } = useElements({
15908 elements: field.elements,
15909 getElements: field.getElements
15910 });
15911 const value = field.getValue({ item });
15912 if (isLoading) {
15913 return value;
15914 }
15915 if (elements.length === 0) {
15916 return value;
15917 }
15918 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
15919 }
15920
15921 // packages/dataviews/build-module/field-types/utils/render-default.mjs
15922 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
15923 function render({
15924 item,
15925 field
15926 }) {
15927 if (field.hasElements) {
15928 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RenderFromElements, { item, field });
15929 }
15930 return field.getValueFormatted({ item, field });
15931 }
15932
15933 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
15934 var sort_text_default = (a2, b2, direction) => {
15935 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
15936 };
15937
15938 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
15939 function isValidRequired(item, field) {
15940 const value = field.getValue({ item });
15941 return ![void 0, "", null].includes(value);
15942 }
15943
15944 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
15945 function isValidMinLength(item, field) {
15946 if (typeof field.isValid.minLength?.constraint !== "number") {
15947 return false;
15948 }
15949 const value = field.getValue({ item });
15950 if ([void 0, "", null].includes(value)) {
15951 return true;
15952 }
15953 return String(value).length >= field.isValid.minLength.constraint;
15954 }
15955
15956 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
15957 function isValidMaxLength(item, field) {
15958 if (typeof field.isValid.maxLength?.constraint !== "number") {
15959 return false;
15960 }
15961 const value = field.getValue({ item });
15962 if ([void 0, "", null].includes(value)) {
15963 return true;
15964 }
15965 return String(value).length <= field.isValid.maxLength.constraint;
15966 }
15967
15968 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
15969 function isValidPattern(item, field) {
15970 if (field.isValid.pattern?.constraint === void 0) {
15971 return true;
15972 }
15973 try {
15974 const regexp = new RegExp(field.isValid.pattern.constraint);
15975 const value = field.getValue({ item });
15976 if ([void 0, "", null].includes(value)) {
15977 return true;
15978 }
15979 return regexp.test(String(value));
15980 } catch {
15981 return false;
15982 }
15983 }
15984
15985 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
15986 function isValidElements(item, field) {
15987 const elements = field.elements ?? [];
15988 const validValues = elements.map((el) => el.value);
15989 if (validValues.length === 0) {
15990 return true;
15991 }
15992 const value = field.getValue({ item });
15993 return [].concat(value).every((v2) => validValues.includes(v2));
15994 }
15995
15996 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
15997 function getValueFormatted({
15998 item,
15999 field
16000 }) {
16001 return field.getValue({ item });
16002 }
16003 var get_value_formatted_default_default = getValueFormatted;
16004
16005 // packages/dataviews/build-module/field-types/email.mjs
16006 var emailRegex = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
16007 function isValidCustom(item, field) {
16008 const value = field.getValue({ item });
16009 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
16010 return (0, import_i18n44.__)("Value must be a valid email address.");
16011 }
16012 return null;
16013 }
16014 var email_default = {
16015 type: "email",
16016 render,
16017 Edit: "email",
16018 sort: sort_text_default,
16019 enableSorting: true,
16020 enableGlobalSearch: false,
16021 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16022 validOperators: [
16023 OPERATOR_IS,
16024 OPERATOR_IS_NOT,
16025 OPERATOR_CONTAINS,
16026 OPERATOR_NOT_CONTAINS,
16027 OPERATOR_STARTS_WITH,
16028 // Multiple selection
16029 OPERATOR_IS_ANY,
16030 OPERATOR_IS_NONE,
16031 OPERATOR_IS_ALL,
16032 OPERATOR_IS_NOT_ALL
16033 ],
16034 format: {},
16035 getValueFormatted: get_value_formatted_default_default,
16036 validate: {
16037 required: isValidRequired,
16038 pattern: isValidPattern,
16039 minLength: isValidMinLength,
16040 maxLength: isValidMaxLength,
16041 elements: isValidElements,
16042 custom: isValidCustom
16043 }
16044 };
16045
16046 // packages/dataviews/build-module/field-types/integer.mjs
16047 var import_i18n45 = __toESM(require_i18n(), 1);
16048
16049 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
16050 var sort_number_default = (a2, b2, direction) => {
16051 return direction === "asc" ? a2 - b2 : b2 - a2;
16052 };
16053
16054 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
16055 function isValidMin(item, field) {
16056 if (typeof field.isValid.min?.constraint !== "number") {
16057 return false;
16058 }
16059 const value = field.getValue({ item });
16060 if ([void 0, "", null].includes(value)) {
16061 return true;
16062 }
16063 return Number(value) >= field.isValid.min.constraint;
16064 }
16065
16066 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
16067 function isValidMax(item, field) {
16068 if (typeof field.isValid.max?.constraint !== "number") {
16069 return false;
16070 }
16071 const value = field.getValue({ item });
16072 if ([void 0, "", null].includes(value)) {
16073 return true;
16074 }
16075 return Number(value) <= field.isValid.max.constraint;
16076 }
16077
16078 // packages/dataviews/build-module/field-types/integer.mjs
16079 var format2 = {
16080 separatorThousand: ","
16081 };
16082 function getValueFormatted2({
16083 item,
16084 field
16085 }) {
16086 let value = field.getValue({ item });
16087 if (value === null || value === void 0) {
16088 return "";
16089 }
16090 value = Number(value);
16091 if (!Number.isFinite(value)) {
16092 return String(value);
16093 }
16094 let formatInteger;
16095 if (field.type !== "integer") {
16096 formatInteger = format2;
16097 } else {
16098 formatInteger = field.format;
16099 }
16100 const { separatorThousand } = formatInteger;
16101 const integerValue = Math.trunc(value);
16102 if (!separatorThousand) {
16103 return String(integerValue);
16104 }
16105 return String(integerValue).replace(
16106 /\B(?=(\d{3})+(?!\d))/g,
16107 separatorThousand
16108 );
16109 }
16110 function isValidCustom2(item, field) {
16111 const value = field.getValue({ item });
16112 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
16113 return (0, import_i18n45.__)("Value must be an integer.");
16114 }
16115 return null;
16116 }
16117 var integer_default = {
16118 type: "integer",
16119 render,
16120 Edit: "integer",
16121 sort: sort_number_default,
16122 enableSorting: true,
16123 enableGlobalSearch: false,
16124 defaultOperators: [
16125 OPERATOR_IS,
16126 OPERATOR_IS_NOT,
16127 OPERATOR_LESS_THAN,
16128 OPERATOR_GREATER_THAN,
16129 OPERATOR_LESS_THAN_OR_EQUAL,
16130 OPERATOR_GREATER_THAN_OR_EQUAL,
16131 OPERATOR_BETWEEN
16132 ],
16133 validOperators: [
16134 // Single-selection
16135 OPERATOR_IS,
16136 OPERATOR_IS_NOT,
16137 OPERATOR_LESS_THAN,
16138 OPERATOR_GREATER_THAN,
16139 OPERATOR_LESS_THAN_OR_EQUAL,
16140 OPERATOR_GREATER_THAN_OR_EQUAL,
16141 OPERATOR_BETWEEN,
16142 // Multiple-selection
16143 OPERATOR_IS_ANY,
16144 OPERATOR_IS_NONE,
16145 OPERATOR_IS_ALL,
16146 OPERATOR_IS_NOT_ALL
16147 ],
16148 format: format2,
16149 getValueFormatted: getValueFormatted2,
16150 validate: {
16151 required: isValidRequired,
16152 min: isValidMin,
16153 max: isValidMax,
16154 elements: isValidElements,
16155 custom: isValidCustom2
16156 }
16157 };
16158
16159 // packages/dataviews/build-module/field-types/number.mjs
16160 var import_i18n46 = __toESM(require_i18n(), 1);
16161 var format3 = {
16162 separatorThousand: ",",
16163 separatorDecimal: ".",
16164 decimals: 2
16165 };
16166 function getValueFormatted3({
16167 item,
16168 field
16169 }) {
16170 let value = field.getValue({ item });
16171 if (value === null || value === void 0) {
16172 return "";
16173 }
16174 value = Number(value);
16175 if (!Number.isFinite(value)) {
16176 return String(value);
16177 }
16178 let formatNumber;
16179 if (field.type !== "number") {
16180 formatNumber = format3;
16181 } else {
16182 formatNumber = field.format;
16183 }
16184 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
16185 const fixedValue = value.toFixed(decimals);
16186 const [integerPart, decimalPart] = fixedValue.split(".");
16187 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
16188 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
16189 }
16190 function isEmpty2(value) {
16191 return value === "" || value === void 0 || value === null;
16192 }
16193 function isValidCustom3(item, field) {
16194 const value = field.getValue({ item });
16195 if (!isEmpty2(value) && !Number.isFinite(value)) {
16196 return (0, import_i18n46.__)("Value must be a number.");
16197 }
16198 return null;
16199 }
16200 var number_default = {
16201 type: "number",
16202 render,
16203 Edit: "number",
16204 sort: sort_number_default,
16205 enableSorting: true,
16206 enableGlobalSearch: false,
16207 defaultOperators: [
16208 OPERATOR_IS,
16209 OPERATOR_IS_NOT,
16210 OPERATOR_LESS_THAN,
16211 OPERATOR_GREATER_THAN,
16212 OPERATOR_LESS_THAN_OR_EQUAL,
16213 OPERATOR_GREATER_THAN_OR_EQUAL,
16214 OPERATOR_BETWEEN
16215 ],
16216 validOperators: [
16217 // Single-selection
16218 OPERATOR_IS,
16219 OPERATOR_IS_NOT,
16220 OPERATOR_LESS_THAN,
16221 OPERATOR_GREATER_THAN,
16222 OPERATOR_LESS_THAN_OR_EQUAL,
16223 OPERATOR_GREATER_THAN_OR_EQUAL,
16224 OPERATOR_BETWEEN,
16225 // Multiple-selection
16226 OPERATOR_IS_ANY,
16227 OPERATOR_IS_NONE,
16228 OPERATOR_IS_ALL,
16229 OPERATOR_IS_NOT_ALL
16230 ],
16231 format: format3,
16232 getValueFormatted: getValueFormatted3,
16233 validate: {
16234 required: isValidRequired,
16235 min: isValidMin,
16236 max: isValidMax,
16237 elements: isValidElements,
16238 custom: isValidCustom3
16239 }
16240 };
16241
16242 // packages/dataviews/build-module/field-types/text.mjs
16243 var text_default = {
16244 type: "text",
16245 render,
16246 Edit: "text",
16247 sort: sort_text_default,
16248 enableSorting: true,
16249 enableGlobalSearch: false,
16250 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16251 validOperators: [
16252 // Single selection
16253 OPERATOR_IS,
16254 OPERATOR_IS_NOT,
16255 OPERATOR_CONTAINS,
16256 OPERATOR_NOT_CONTAINS,
16257 OPERATOR_STARTS_WITH,
16258 // Multiple selection
16259 OPERATOR_IS_ANY,
16260 OPERATOR_IS_NONE,
16261 OPERATOR_IS_ALL,
16262 OPERATOR_IS_NOT_ALL
16263 ],
16264 format: {},
16265 getValueFormatted: get_value_formatted_default_default,
16266 validate: {
16267 required: isValidRequired,
16268 pattern: isValidPattern,
16269 minLength: isValidMinLength,
16270 maxLength: isValidMaxLength,
16271 elements: isValidElements
16272 }
16273 };
16274
16275 // packages/dataviews/build-module/field-types/datetime.mjs
16276 var import_date6 = __toESM(require_date(), 1);
16277 var format4 = {
16278 datetime: (0, import_date6.getSettings)().formats.datetime,
16279 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek
16280 };
16281 function getValueFormatted4({
16282 item,
16283 field
16284 }) {
16285 const value = field.getValue({ item });
16286 if (["", void 0, null].includes(value)) {
16287 return "";
16288 }
16289 let formatDatetime;
16290 if (field.type !== "datetime") {
16291 formatDatetime = format4;
16292 } else {
16293 formatDatetime = field.format;
16294 }
16295 return (0, import_date6.dateI18n)(formatDatetime.datetime, (0, import_date6.getDate)(value));
16296 }
16297 var sort = (a2, b2, direction) => {
16298 const timeA = new Date(a2).getTime();
16299 const timeB = new Date(b2).getTime();
16300 return direction === "asc" ? timeA - timeB : timeB - timeA;
16301 };
16302 var datetime_default = {
16303 type: "datetime",
16304 render,
16305 Edit: "datetime",
16306 sort,
16307 enableSorting: true,
16308 enableGlobalSearch: false,
16309 defaultOperators: [
16310 OPERATOR_ON,
16311 OPERATOR_NOT_ON,
16312 OPERATOR_BEFORE,
16313 OPERATOR_AFTER,
16314 OPERATOR_BEFORE_INC,
16315 OPERATOR_AFTER_INC,
16316 OPERATOR_IN_THE_PAST,
16317 OPERATOR_OVER
16318 ],
16319 validOperators: [
16320 OPERATOR_ON,
16321 OPERATOR_NOT_ON,
16322 OPERATOR_BEFORE,
16323 OPERATOR_AFTER,
16324 OPERATOR_BEFORE_INC,
16325 OPERATOR_AFTER_INC,
16326 OPERATOR_IN_THE_PAST,
16327 OPERATOR_OVER
16328 ],
16329 format: format4,
16330 getValueFormatted: getValueFormatted4,
16331 validate: {
16332 required: isValidRequired,
16333 elements: isValidElements
16334 }
16335 };
16336
16337 // packages/dataviews/build-module/field-types/date.mjs
16338 var import_date7 = __toESM(require_date(), 1);
16339 var format5 = {
16340 date: (0, import_date7.getSettings)().formats.date,
16341 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
16342 };
16343 function getValueFormatted5({
16344 item,
16345 field
16346 }) {
16347 const value = field.getValue({ item });
16348 if (["", void 0, null].includes(value)) {
16349 return "";
16350 }
16351 let formatDate2;
16352 if (field.type !== "date") {
16353 formatDate2 = format5;
16354 } else {
16355 formatDate2 = field.format;
16356 }
16357 return (0, import_date7.dateI18n)(formatDate2.date, (0, import_date7.getDate)(value));
16358 }
16359 var sort2 = (a2, b2, direction) => {
16360 const timeA = new Date(a2).getTime();
16361 const timeB = new Date(b2).getTime();
16362 return direction === "asc" ? timeA - timeB : timeB - timeA;
16363 };
16364 var date_default = {
16365 type: "date",
16366 render,
16367 Edit: "date",
16368 sort: sort2,
16369 enableSorting: true,
16370 enableGlobalSearch: false,
16371 defaultOperators: [
16372 OPERATOR_ON,
16373 OPERATOR_NOT_ON,
16374 OPERATOR_BEFORE,
16375 OPERATOR_AFTER,
16376 OPERATOR_BEFORE_INC,
16377 OPERATOR_AFTER_INC,
16378 OPERATOR_IN_THE_PAST,
16379 OPERATOR_OVER,
16380 OPERATOR_BETWEEN
16381 ],
16382 validOperators: [
16383 OPERATOR_ON,
16384 OPERATOR_NOT_ON,
16385 OPERATOR_BEFORE,
16386 OPERATOR_AFTER,
16387 OPERATOR_BEFORE_INC,
16388 OPERATOR_AFTER_INC,
16389 OPERATOR_IN_THE_PAST,
16390 OPERATOR_OVER,
16391 OPERATOR_BETWEEN
16392 ],
16393 format: format5,
16394 getValueFormatted: getValueFormatted5,
16395 validate: {
16396 required: isValidRequired,
16397 elements: isValidElements
16398 }
16399 };
16400
16401 // packages/dataviews/build-module/field-types/boolean.mjs
16402 var import_i18n47 = __toESM(require_i18n(), 1);
16403
16404 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
16405 function isValidRequiredForBool(item, field) {
16406 const value = field.getValue({ item });
16407 return value === true;
16408 }
16409
16410 // packages/dataviews/build-module/field-types/boolean.mjs
16411 function getValueFormatted6({
16412 item,
16413 field
16414 }) {
16415 const value = field.getValue({ item });
16416 if (value === true) {
16417 return (0, import_i18n47.__)("True");
16418 }
16419 if (value === false) {
16420 return (0, import_i18n47.__)("False");
16421 }
16422 return "";
16423 }
16424 function isValidCustom4(item, field) {
16425 const value = field.getValue({ item });
16426 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
16427 return (0, import_i18n47.__)("Value must be true, false, or undefined");
16428 }
16429 return null;
16430 }
16431 var sort3 = (a2, b2, direction) => {
16432 const boolA = Boolean(a2);
16433 const boolB = Boolean(b2);
16434 if (boolA === boolB) {
16435 return 0;
16436 }
16437 if (direction === "asc") {
16438 return boolA ? 1 : -1;
16439 }
16440 return boolA ? -1 : 1;
16441 };
16442 var boolean_default = {
16443 type: "boolean",
16444 render,
16445 Edit: "checkbox",
16446 sort: sort3,
16447 validate: {
16448 required: isValidRequiredForBool,
16449 elements: isValidElements,
16450 custom: isValidCustom4
16451 },
16452 enableSorting: true,
16453 enableGlobalSearch: false,
16454 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16455 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16456 format: {},
16457 getValueFormatted: getValueFormatted6
16458 };
16459
16460 // packages/dataviews/build-module/field-types/media.mjs
16461 var media_default = {
16462 type: "media",
16463 render: () => null,
16464 Edit: null,
16465 sort: () => 0,
16466 enableSorting: false,
16467 enableGlobalSearch: false,
16468 defaultOperators: [],
16469 validOperators: [],
16470 format: {},
16471 getValueFormatted: get_value_formatted_default_default,
16472 // cannot validate any constraint, so
16473 // the only available validation for the field author
16474 // would be providing a custom validator.
16475 validate: {}
16476 };
16477
16478 // packages/dataviews/build-module/field-types/array.mjs
16479 var import_i18n48 = __toESM(require_i18n(), 1);
16480
16481 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
16482 function isValidRequiredForArray(item, field) {
16483 const value = field.getValue({ item });
16484 return Array.isArray(value) && value.length > 0 && value.every(
16485 (element) => ![void 0, "", null].includes(element)
16486 );
16487 }
16488
16489 // packages/dataviews/build-module/field-types/array.mjs
16490 function getValueFormatted7({
16491 item,
16492 field
16493 }) {
16494 const value = field.getValue({ item });
16495 const arr = Array.isArray(value) ? value : [];
16496 return arr.join(", ");
16497 }
16498 function render2({ item, field }) {
16499 return getValueFormatted7({ item, field });
16500 }
16501 function isValidCustom5(item, field) {
16502 const value = field.getValue({ item });
16503 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
16504 return (0, import_i18n48.__)("Value must be an array.");
16505 }
16506 if (!value.every((v2) => typeof v2 === "string")) {
16507 return (0, import_i18n48.__)("Every value must be a string.");
16508 }
16509 return null;
16510 }
16511 var sort4 = (a2, b2, direction) => {
16512 const arrA = Array.isArray(a2) ? a2 : [];
16513 const arrB = Array.isArray(b2) ? b2 : [];
16514 if (arrA.length !== arrB.length) {
16515 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
16516 }
16517 const joinedA = arrA.join(",");
16518 const joinedB = arrB.join(",");
16519 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
16520 };
16521 var array_default = {
16522 type: "array",
16523 render: render2,
16524 Edit: "array",
16525 sort: sort4,
16526 enableSorting: true,
16527 enableGlobalSearch: false,
16528 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16529 validOperators: [
16530 OPERATOR_IS_ANY,
16531 OPERATOR_IS_NONE,
16532 OPERATOR_IS_ALL,
16533 OPERATOR_IS_NOT_ALL
16534 ],
16535 format: {},
16536 getValueFormatted: getValueFormatted7,
16537 validate: {
16538 required: isValidRequiredForArray,
16539 elements: isValidElements,
16540 custom: isValidCustom5
16541 }
16542 };
16543
16544 // packages/dataviews/build-module/field-types/password.mjs
16545 function getValueFormatted8({
16546 item,
16547 field
16548 }) {
16549 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
16550 }
16551 var password_default = {
16552 type: "password",
16553 render,
16554 Edit: "password",
16555 sort: () => 0,
16556 // Passwords should not be sortable for security reasons
16557 enableSorting: false,
16558 enableGlobalSearch: false,
16559 defaultOperators: [],
16560 validOperators: [],
16561 format: {},
16562 getValueFormatted: getValueFormatted8,
16563 validate: {
16564 required: isValidRequired,
16565 pattern: isValidPattern,
16566 minLength: isValidMinLength,
16567 maxLength: isValidMaxLength,
16568 elements: isValidElements
16569 }
16570 };
16571
16572 // packages/dataviews/build-module/field-types/telephone.mjs
16573 var telephone_default = {
16574 type: "telephone",
16575 render,
16576 Edit: "telephone",
16577 sort: sort_text_default,
16578 enableSorting: true,
16579 enableGlobalSearch: false,
16580 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16581 validOperators: [
16582 OPERATOR_IS,
16583 OPERATOR_IS_NOT,
16584 OPERATOR_CONTAINS,
16585 OPERATOR_NOT_CONTAINS,
16586 OPERATOR_STARTS_WITH,
16587 // Multiple selection
16588 OPERATOR_IS_ANY,
16589 OPERATOR_IS_NONE,
16590 OPERATOR_IS_ALL,
16591 OPERATOR_IS_NOT_ALL
16592 ],
16593 format: {},
16594 getValueFormatted: get_value_formatted_default_default,
16595 validate: {
16596 required: isValidRequired,
16597 pattern: isValidPattern,
16598 minLength: isValidMinLength,
16599 maxLength: isValidMaxLength,
16600 elements: isValidElements
16601 }
16602 };
16603
16604 // packages/dataviews/build-module/field-types/color.mjs
16605 var import_i18n49 = __toESM(require_i18n(), 1);
16606 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
16607 function render3({ item, field }) {
16608 if (field.hasElements) {
16609 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(RenderFromElements, { item, field });
16610 }
16611 const value = get_value_formatted_default_default({ item, field });
16612 if (!value || !w(value).isValid()) {
16613 return value;
16614 }
16615 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
16616 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
16617 "div",
16618 {
16619 style: {
16620 width: "16px",
16621 height: "16px",
16622 borderRadius: "50%",
16623 backgroundColor: value,
16624 border: "1px solid #ddd",
16625 flexShrink: 0
16626 }
16627 }
16628 ),
16629 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { children: value })
16630 ] });
16631 }
16632 function isValidCustom6(item, field) {
16633 const value = field.getValue({ item });
16634 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
16635 return (0, import_i18n49.__)("Value must be a valid color.");
16636 }
16637 return null;
16638 }
16639 var sort5 = (a2, b2, direction) => {
16640 const colorA = w(a2);
16641 const colorB = w(b2);
16642 if (!colorA.isValid() && !colorB.isValid()) {
16643 return 0;
16644 }
16645 if (!colorA.isValid()) {
16646 return direction === "asc" ? 1 : -1;
16647 }
16648 if (!colorB.isValid()) {
16649 return direction === "asc" ? -1 : 1;
16650 }
16651 const hslA = colorA.toHsl();
16652 const hslB = colorB.toHsl();
16653 if (hslA.h !== hslB.h) {
16654 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
16655 }
16656 if (hslA.s !== hslB.s) {
16657 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
16658 }
16659 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
16660 };
16661 var color_default = {
16662 type: "color",
16663 render: render3,
16664 Edit: "color",
16665 sort: sort5,
16666 enableSorting: true,
16667 enableGlobalSearch: false,
16668 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16669 validOperators: [
16670 OPERATOR_IS,
16671 OPERATOR_IS_NOT,
16672 OPERATOR_IS_ANY,
16673 OPERATOR_IS_NONE
16674 ],
16675 format: {},
16676 getValueFormatted: get_value_formatted_default_default,
16677 validate: {
16678 required: isValidRequired,
16679 elements: isValidElements,
16680 custom: isValidCustom6
16681 }
16682 };
16683
16684 // packages/dataviews/build-module/field-types/url.mjs
16685 var url_default = {
16686 type: "url",
16687 render,
16688 Edit: "url",
16689 sort: sort_text_default,
16690 enableSorting: true,
16691 enableGlobalSearch: false,
16692 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16693 validOperators: [
16694 OPERATOR_IS,
16695 OPERATOR_IS_NOT,
16696 OPERATOR_CONTAINS,
16697 OPERATOR_NOT_CONTAINS,
16698 OPERATOR_STARTS_WITH,
16699 // Multiple selection
16700 OPERATOR_IS_ANY,
16701 OPERATOR_IS_NONE,
16702 OPERATOR_IS_ALL,
16703 OPERATOR_IS_NOT_ALL
16704 ],
16705 format: {},
16706 getValueFormatted: get_value_formatted_default_default,
16707 validate: {
16708 required: isValidRequired,
16709 pattern: isValidPattern,
16710 minLength: isValidMinLength,
16711 maxLength: isValidMaxLength,
16712 elements: isValidElements
16713 }
16714 };
16715
16716 // packages/dataviews/build-module/field-types/no-type.mjs
16717 var sort6 = (a2, b2, direction) => {
16718 if (typeof a2 === "number" && typeof b2 === "number") {
16719 return sort_number_default(a2, b2, direction);
16720 }
16721 return sort_text_default(a2, b2, direction);
16722 };
16723 var no_type_default = {
16724 // type: no type for this one
16725 render,
16726 Edit: null,
16727 sort: sort6,
16728 enableSorting: true,
16729 enableGlobalSearch: false,
16730 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16731 validOperators: getAllOperatorNames(),
16732 format: {},
16733 getValueFormatted: get_value_formatted_default_default,
16734 validate: {
16735 required: isValidRequired,
16736 elements: isValidElements
16737 }
16738 };
16739
16740 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
16741 function getIsValid(field, fieldType) {
16742 let required;
16743 if (field.isValid?.required === true && fieldType.validate.required !== void 0) {
16744 required = {
16745 constraint: true,
16746 validate: fieldType.validate.required
16747 };
16748 }
16749 let elements;
16750 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out
16751 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
16752 elements = {
16753 constraint: true,
16754 validate: fieldType.validate.elements
16755 };
16756 }
16757 let min;
16758 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) {
16759 min = {
16760 constraint: field.isValid.min,
16761 validate: fieldType.validate.min
16762 };
16763 }
16764 let max;
16765 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) {
16766 max = {
16767 constraint: field.isValid.max,
16768 validate: fieldType.validate.max
16769 };
16770 }
16771 let minLength;
16772 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) {
16773 minLength = {
16774 constraint: field.isValid.minLength,
16775 validate: fieldType.validate.minLength
16776 };
16777 }
16778 let maxLength;
16779 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) {
16780 maxLength = {
16781 constraint: field.isValid.maxLength,
16782 validate: fieldType.validate.maxLength
16783 };
16784 }
16785 let pattern;
16786 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) {
16787 pattern = {
16788 constraint: field.isValid?.pattern,
16789 validate: fieldType.validate.pattern
16790 };
16791 }
16792 const custom = field.isValid?.custom ?? fieldType.validate.custom;
16793 return {
16794 required,
16795 elements,
16796 min,
16797 max,
16798 minLength,
16799 maxLength,
16800 pattern,
16801 custom
16802 };
16803 }
16804
16805 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
16806 function getFilter(fieldType) {
16807 return fieldType.validOperators.reduce((accumulator, operator) => {
16808 const operatorObj = getOperatorByName(operator);
16809 if (operatorObj?.filter) {
16810 accumulator[operator] = operatorObj.filter;
16811 }
16812 return accumulator;
16813 }, {});
16814 }
16815
16816 // packages/dataviews/build-module/field-types/utils/get-format.mjs
16817 function getFormat(field, fieldType) {
16818 return {
16819 ...fieldType.format,
16820 ...field.format
16821 };
16822 }
16823 var get_format_default = getFormat;
16824
16825 // packages/dataviews/build-module/field-types/index.mjs
16826 function getFieldTypeByName(type) {
16827 const found = [
16828 email_default,
16829 integer_default,
16830 number_default,
16831 text_default,
16832 datetime_default,
16833 date_default,
16834 boolean_default,
16835 media_default,
16836 array_default,
16837 password_default,
16838 telephone_default,
16839 color_default,
16840 url_default
16841 ].find((fieldType) => fieldType?.type === type);
16842 if (!!found) {
16843 return found;
16844 }
16845 return no_type_default;
16846 }
16847 function normalizeFields(fields) {
16848 return fields.map((field) => {
16849 const fieldType = getFieldTypeByName(field.type);
16850 const getValue = field.getValue || get_value_from_id_default(field.id);
16851 const sort7 = function(a2, b2, direction) {
16852 const aValue = getValue({ item: a2 });
16853 const bValue = getValue({ item: b2 });
16854 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
16855 };
16856 return {
16857 id: field.id,
16858 label: field.label || field.id,
16859 header: field.header || field.label || field.id,
16860 description: field.description,
16861 placeholder: field.placeholder,
16862 getValue,
16863 setValue: field.setValue || set_value_from_id_default(field.id),
16864 elements: field.elements,
16865 getElements: field.getElements,
16866 hasElements: hasElements(field),
16867 isVisible: field.isVisible,
16868 enableHiding: field.enableHiding ?? true,
16869 readOnly: field.readOnly ?? false,
16870 // The type provides defaults for the following props
16871 type: fieldType.type,
16872 render: field.render ?? fieldType.render,
16873 Edit: getControl(field, fieldType.Edit),
16874 sort: sort7,
16875 enableSorting: field.enableSorting ?? fieldType.enableSorting,
16876 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
16877 isValid: getIsValid(field, fieldType),
16878 filterBy: get_filter_by_default(
16879 field,
16880 fieldType.defaultOperators,
16881 fieldType.validOperators
16882 ),
16883 filter: getFilter(fieldType),
16884 format: get_format_default(field, fieldType),
16885 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
16886 };
16887 });
16888 }
16889
16890 // packages/dataviews/build-module/dataviews-picker/index.mjs
16891 var import_element54 = __toESM(require_element(), 1);
16892 var import_compose12 = __toESM(require_compose(), 1);
16893 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
16894 var isItemClickable = () => false;
16895 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
16896 (viewLayout) => viewLayout.isPicker
16897 );
16898 var defaultGetItemId = (item) => item.id;
16899 var EMPTY_ARRAY5 = [];
16900 function DefaultUI({
16901 search = true,
16902 searchLabel = void 0
16903 }) {
16904 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, { children: [
16905 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
16906 Stack,
16907 {
16908 direction: "row",
16909 align: "top",
16910 justify: "space-between",
16911 className: "dataviews__view-actions",
16912 gap: "xs",
16913 children: [
16914 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
16915 Stack,
16916 {
16917 direction: "row",
16918 gap: "sm",
16919 justify: "start",
16920 className: "dataviews__search",
16921 children: [
16922 search && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(dataviews_search_default, { label: searchLabel }),
16923 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(toggle_default, {})
16924 ]
16925 }
16926 ),
16927 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(dataviews_view_config_default, {}) })
16928 ]
16929 }
16930 ),
16931 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
16932 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DataViewsLayout, {}),
16933 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DataViewsPickerFooter, {})
16934 ] });
16935 }
16936 function DataViewsPicker({
16937 view,
16938 onChangeView,
16939 fields,
16940 search = true,
16941 searchLabel = void 0,
16942 actions = EMPTY_ARRAY5,
16943 data,
16944 getItemId = defaultGetItemId,
16945 isLoading = false,
16946 paginationInfo,
16947 defaultLayouts: defaultLayoutsProperty,
16948 selection,
16949 onChangeSelection,
16950 children,
16951 config = { perPageSizes: [10, 20, 50, 100] },
16952 itemListLabel,
16953 empty
16954 }) {
16955 const { infiniteScrollHandler } = paginationInfo;
16956 const containerRef = (0, import_element54.useRef)(null);
16957 const [containerWidth, setContainerWidth] = (0, import_element54.useState)(0);
16958 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
16959 (resizeObserverEntries) => {
16960 setContainerWidth(
16961 resizeObserverEntries[0].borderBoxSize[0].inlineSize
16962 );
16963 },
16964 { box: "border-box" }
16965 );
16966 const [openedFilter, setOpenedFilter] = (0, import_element54.useState)(null);
16967 function setSelectionWithChange(value) {
16968 const newValue = typeof value === "function" ? value(selection) : value;
16969 if (onChangeSelection) {
16970 onChangeSelection(newValue);
16971 }
16972 }
16973 const _fields = (0, import_element54.useMemo)(() => normalizeFields(fields), [fields]);
16974 const filters = use_filters_default(_fields, view);
16975 const hasPrimaryOrLockedFilters = (0, import_element54.useMemo)(
16976 () => (filters || []).some(
16977 (filter) => filter.isPrimary || filter.isLocked
16978 ),
16979 [filters]
16980 );
16981 const [isShowingFilter, setIsShowingFilter] = (0, import_element54.useState)(
16982 hasPrimaryOrLockedFilters
16983 );
16984 (0, import_element54.useEffect)(() => {
16985 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
16986 setIsShowingFilter(true);
16987 }
16988 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
16989 (0, import_element54.useEffect)(() => {
16990 if (!view.infiniteScrollEnabled || !containerRef.current) {
16991 return;
16992 }
16993 const handleScroll = (0, import_compose12.throttle)((event) => {
16994 const target = event.target;
16995 const scrollTop = target.scrollTop;
16996 const scrollHeight = target.scrollHeight;
16997 const clientHeight = target.clientHeight;
16998 if (scrollTop + clientHeight >= scrollHeight - 100) {
16999 infiniteScrollHandler?.();
17000 }
17001 }, 100);
17002 const container = containerRef.current;
17003 container.addEventListener("scroll", handleScroll);
17004 return () => {
17005 container.removeEventListener("scroll", handleScroll);
17006 handleScroll.cancel();
17007 };
17008 }, [infiniteScrollHandler, view.infiniteScrollEnabled]);
17009 const defaultLayouts = (0, import_element54.useMemo)(
17010 () => Object.fromEntries(
17011 Object.entries(defaultLayoutsProperty).filter(
17012 ([layoutType]) => {
17013 return dataViewsPickerLayouts.some(
17014 (viewLayout) => viewLayout.type === layoutType
17015 );
17016 }
17017 )
17018 ),
17019 [defaultLayoutsProperty]
17020 );
17021 if (!defaultLayouts[view.type]) {
17022 return null;
17023 }
17024 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17025 dataviews_context_default.Provider,
17026 {
17027 value: {
17028 view,
17029 onChangeView,
17030 fields: _fields,
17031 actions,
17032 data,
17033 isLoading,
17034 paginationInfo,
17035 isItemClickable,
17036 selection,
17037 onChangeSelection: setSelectionWithChange,
17038 openedFilter,
17039 setOpenedFilter,
17040 getItemId,
17041 containerWidth,
17042 containerRef,
17043 resizeObserverRef,
17044 defaultLayouts,
17045 filters,
17046 isShowingFilter,
17047 setIsShowingFilter,
17048 config,
17049 itemListLabel,
17050 empty,
17051 hasInitiallyLoaded: true,
17052 hasInfiniteScrollHandler: !!infiniteScrollHandler
17053 },
17054 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsx)("div", { className: "dataviews-picker-wrapper", ref: containerRef, children: children ?? /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DefaultUI, { search, searchLabel }) })
17055 }
17056 );
17057 }
17058 var DataViewsPickerSubComponents = DataViewsPicker;
17059 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerFooter;
17060 DataViewsPickerSubComponents.Filters = filters_default;
17061 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
17062 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
17063 DataViewsPickerSubComponents.Layout = DataViewsLayout;
17064 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
17065 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
17066 DataViewsPickerSubComponents.Search = dataviews_search_default;
17067 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
17068 var dataviews_picker_default = DataViewsPickerSubComponents;
17069
17070 // packages/media-fields/build-module/alt_text/index.mjs
17071 var import_i18n50 = __toESM(require_i18n(), 1);
17072 var import_components46 = __toESM(require_components(), 1);
17073 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
17074 var altTextField = {
17075 id: "alt_text",
17076 type: "text",
17077 label: (0, import_i18n50.__)("Alt text"),
17078 isVisible: (item) => item?.media_type === "image",
17079 render: ({ item }) => item?.alt_text || "-",
17080 Edit: ({ field, onChange, data }) => {
17081 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
17082 import_components46.TextareaControl,
17083 {
17084 label: field.label,
17085 value: data.alt_text || "",
17086 onChange: (value) => onChange({ alt_text: value }),
17087 rows: 2
17088 }
17089 );
17090 },
17091 enableSorting: false,
17092 filterBy: false
17093 };
17094 var alt_text_default = altTextField;
17095
17096 // packages/media-fields/build-module/attached_to/index.mjs
17097 var import_i18n53 = __toESM(require_i18n(), 1);
17098
17099 // packages/media-fields/build-module/attached_to/view.mjs
17100 var import_element55 = __toESM(require_element(), 1);
17101 var import_i18n51 = __toESM(require_i18n(), 1);
17102
17103 // packages/media-fields/build-module/utils/get-rendered-content.mjs
17104 function getRenderedContent(content) {
17105 if (!content) {
17106 return "";
17107 }
17108 if (typeof content === "string") {
17109 return content;
17110 }
17111 if (typeof content === "object") {
17112 return content.rendered || content.raw || "";
17113 }
17114 return "";
17115 }
17116
17117 // packages/media-fields/build-module/attached_to/view.mjs
17118 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
17119 function MediaAttachedToView({
17120 item
17121 }) {
17122 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element55.useState)(null);
17123 const parentId = item.post;
17124 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
17125 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
17126 (0, import_element55.useEffect)(() => {
17127 if (!!parentId && parentId === embeddedPostId) {
17128 setAttachedPostTitle(
17129 getRenderedContent(embeddedPostTitle) || embeddedPostId?.toString() || ""
17130 );
17131 }
17132 if (!parentId) {
17133 setAttachedPostTitle((0, import_i18n51.__)("(Unattached)"));
17134 }
17135 }, [parentId, embeddedPostId, embeddedPostTitle]);
17136 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_jsx_runtime100.Fragment, { children: attachedPostTitle });
17137 }
17138
17139 // packages/media-fields/build-module/attached_to/edit.mjs
17140 var import_core_data = __toESM(require_core_data(), 1);
17141 var import_components47 = __toESM(require_components(), 1);
17142 var import_i18n52 = __toESM(require_i18n(), 1);
17143 var import_element56 = __toESM(require_element(), 1);
17144 var import_compose13 = __toESM(require_compose(), 1);
17145 var import_data6 = __toESM(require_data(), 1);
17146 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
17147 function MediaAttachedToEdit({
17148 data,
17149 onChange
17150 }) {
17151 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
17152 {
17153 label: getRenderedContent(
17154 data._embedded?.["wp:attached-to"]?.[0]?.title
17155 ),
17156 value: data.post.toString()
17157 }
17158 ] : [];
17159 const [options, setOptions] = (0, import_element56.useState)(defaultPost);
17160 const [searchResults, setSearchResults] = (0, import_element56.useState)(
17161 []
17162 );
17163 const [isLoading, setIsLoading] = (0, import_element56.useState)(false);
17164 const [value, setValue] = (0, import_element56.useState)(
17165 data?.post?.toString() ?? null
17166 );
17167 const postTypes = (0, import_data6.useSelect)(
17168 (select) => select(import_core_data.store).getPostTypes(),
17169 []
17170 );
17171 const handleDetach = () => {
17172 onChange({
17173 post: 0,
17174 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
17175 });
17176 setOptions([]);
17177 };
17178 const onValueChange = async (filterValue) => {
17179 setIsLoading(true);
17180 const results = await (0, import_core_data.__experimentalFetchLinkSuggestions)(
17181 filterValue,
17182 /*
17183 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
17184 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
17185 */
17186 { type: "post", isInitialSuggestions: true },
17187 {}
17188 );
17189 setSearchResults(results);
17190 const mappedSuggestions = results.map((result) => {
17191 return {
17192 label: result.title,
17193 value: result.id.toString()
17194 };
17195 });
17196 setOptions(mappedSuggestions);
17197 setIsLoading(false);
17198 };
17199 const handleSelectOption = (selectedPostId) => {
17200 if (!selectedPostId) {
17201 handleDetach();
17202 return;
17203 }
17204 setValue(selectedPostId);
17205 if (selectedPostId) {
17206 const selectedPost = searchResults.find(
17207 (result) => result.id === Number(selectedPostId)
17208 );
17209 if (selectedPost && postTypes) {
17210 const postType = postTypes.find(
17211 (_postType) => _postType.slug === selectedPost?.type
17212 );
17213 const attachedTo = {
17214 ...postType && { type: postType.slug },
17215 id: Number(selectedPostId),
17216 title: {
17217 raw: selectedPost.title,
17218 rendered: selectedPost.title
17219 }
17220 };
17221 onChange({
17222 post: Number(selectedPostId),
17223 _embedded: {
17224 ...data?._embedded,
17225 "wp:attached-to": [attachedTo]
17226 }
17227 });
17228 }
17229 }
17230 };
17231 const help = !!data.post ? (0, import_element56.createInterpolateElement)(
17232 (0, import_i18n52.__)(
17233 "Search for a post or page to attach this media to or <button>detach current</button>."
17234 ),
17235 {
17236 button: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17237 import_components47.Button,
17238 {
17239 __next40pxDefaultSize: true,
17240 onClick: handleDetach,
17241 variant: "link",
17242 accessibleWhenDisabled: true
17243 }
17244 )
17245 }
17246 ) : (0, import_i18n52.__)("Search for a post or page to attach this media to.");
17247 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17248 import_components47.ComboboxControl,
17249 {
17250 className: "dataviews-media-field__attached-to",
17251 __next40pxDefaultSize: true,
17252 isLoading,
17253 label: (0, import_i18n52.__)("Attached to"),
17254 help,
17255 value,
17256 options,
17257 onFilterValueChange: (0, import_compose13.debounce)(
17258 (filterValue) => onValueChange(filterValue),
17259 300
17260 ),
17261 onChange: handleSelectOption,
17262 hideLabelFromVision: true
17263 }
17264 );
17265 }
17266
17267 // packages/media-fields/build-module/attached_to/index.mjs
17268 var attachedToField = {
17269 id: "attached_to",
17270 type: "text",
17271 label: (0, import_i18n53.__)("Attached to"),
17272 Edit: MediaAttachedToEdit,
17273 render: MediaAttachedToView,
17274 enableSorting: false,
17275 filterBy: false
17276 };
17277 var attached_to_default = attachedToField;
17278
17279 // packages/media-fields/build-module/author/index.mjs
17280 var import_i18n55 = __toESM(require_i18n(), 1);
17281 var import_data7 = __toESM(require_data(), 1);
17282 var import_core_data2 = __toESM(require_core_data(), 1);
17283
17284 // packages/media-fields/build-module/author/view.mjs
17285 var import_i18n54 = __toESM(require_i18n(), 1);
17286 var import_element57 = __toESM(require_element(), 1);
17287 var import_components48 = __toESM(require_components(), 1);
17288 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
17289 function AuthorView({
17290 item
17291 }) {
17292 const author = item?._embedded?.author?.[0];
17293 const text = author?.name;
17294 const imageUrl = author?.avatar_urls?.[48];
17295 const [loadingState, setLoadingState] = (0, import_element57.useState)("loading");
17296 (0, import_element57.useEffect)(() => {
17297 setLoadingState("loading");
17298 }, [imageUrl]);
17299 const imgRef = (0, import_element57.useCallback)((img) => {
17300 if (img?.complete) {
17301 setLoadingState("instant");
17302 }
17303 }, []);
17304 const handleLoad = () => {
17305 if (loadingState === "loading") {
17306 setLoadingState("loaded");
17307 }
17308 };
17309 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_components48.__experimentalHStack, { alignment: "left", spacing: 0, children: [
17310 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17311 "div",
17312 {
17313 className: clsx_default("media-author-field__avatar", {
17314 "is-loading": loadingState === "loading",
17315 "is-loaded": loadingState === "loaded"
17316 }),
17317 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17318 "img",
17319 {
17320 ref: imgRef,
17321 onLoad: handleLoad,
17322 alt: (0, import_i18n54.__)("Author avatar"),
17323 src: imageUrl
17324 }
17325 )
17326 }
17327 ),
17328 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components48.Icon, { icon: comment_author_avatar_default }) }),
17329 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "media-author-field__name", children: text })
17330 ] });
17331 }
17332
17333 // packages/media-fields/build-module/author/index.mjs
17334 var authorField = {
17335 label: (0, import_i18n55.__)("Author"),
17336 id: "author",
17337 type: "integer",
17338 getElements: async () => {
17339 const authors = await (0, import_data7.resolveSelect)(import_core_data2.store).getEntityRecords(
17340 "root",
17341 "user",
17342 {
17343 per_page: -1,
17344 who: "authors",
17345 _fields: "id,name",
17346 context: "view"
17347 }
17348 ) ?? [];
17349 return authors.map(({ id, name }) => ({
17350 value: id,
17351 label: name
17352 }));
17353 },
17354 render: AuthorView,
17355 sort: (a2, b2, direction) => {
17356 const nameA = a2._embedded?.author?.[0]?.name || "";
17357 const nameB = b2._embedded?.author?.[0]?.name || "";
17358 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
17359 },
17360 filterBy: {
17361 operators: ["isAny", "isNone"]
17362 },
17363 readOnly: true
17364 };
17365 var author_default = authorField;
17366
17367 // packages/media-fields/build-module/caption/index.mjs
17368 var import_i18n56 = __toESM(require_i18n(), 1);
17369 var import_components49 = __toESM(require_components(), 1);
17370
17371 // packages/media-fields/build-module/utils/get-raw-content.mjs
17372 function getRawContent(content) {
17373 if (!content) {
17374 return "";
17375 }
17376 if (typeof content === "string") {
17377 return content;
17378 }
17379 if (typeof content === "object" && "raw" in content) {
17380 return content.raw || "";
17381 }
17382 return "";
17383 }
17384
17385 // packages/media-fields/build-module/caption/index.mjs
17386 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
17387 var captionField = {
17388 id: "caption",
17389 type: "text",
17390 label: (0, import_i18n56.__)("Caption"),
17391 getValue: ({ item }) => getRawContent(item?.caption),
17392 render: ({ item }) => getRawContent(item?.caption) || "-",
17393 Edit: ({ field, onChange, data }) => {
17394 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
17395 import_components49.TextareaControl,
17396 {
17397 label: field.label,
17398 value: getRawContent(data.caption) || "",
17399 onChange: (value) => onChange({ caption: value }),
17400 rows: 2
17401 }
17402 );
17403 },
17404 enableSorting: false,
17405 filterBy: false
17406 };
17407 var caption_default = captionField;
17408
17409 // packages/media-fields/build-module/date_added/index.mjs
17410 var import_i18n57 = __toESM(require_i18n(), 1);
17411 var import_date9 = __toESM(require_date(), 1);
17412 var dateAddedField = {
17413 id: "date",
17414 type: "datetime",
17415 label: (0, import_i18n57.__)("Date added"),
17416 filterBy: {
17417 operators: ["before", "after"]
17418 },
17419 format: {
17420 datetime: (0, import_date9.getSettings)().formats.datetimeAbbreviated
17421 },
17422 readOnly: true
17423 };
17424 var date_added_default = dateAddedField;
17425
17426 // packages/media-fields/build-module/date_modified/index.mjs
17427 var import_i18n58 = __toESM(require_i18n(), 1);
17428 var import_date10 = __toESM(require_date(), 1);
17429 var dateModifiedField = {
17430 id: "modified",
17431 type: "datetime",
17432 label: (0, import_i18n58.__)("Date modified"),
17433 filterBy: {
17434 operators: ["before", "after"]
17435 },
17436 format: {
17437 datetime: (0, import_date10.getSettings)().formats.datetimeAbbreviated
17438 },
17439 readOnly: true
17440 };
17441 var date_modified_default = dateModifiedField;
17442
17443 // packages/media-fields/build-module/description/index.mjs
17444 var import_i18n59 = __toESM(require_i18n(), 1);
17445 var import_components50 = __toESM(require_components(), 1);
17446 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
17447 var descriptionField = {
17448 id: "description",
17449 type: "text",
17450 label: (0, import_i18n59.__)("Description"),
17451 getValue: ({ item }) => getRawContent(item?.description),
17452 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { children: getRawContent(item?.description) || "-" }),
17453 Edit: ({ field, onChange, data }) => {
17454 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
17455 import_components50.TextareaControl,
17456 {
17457 label: field.label,
17458 value: getRawContent(data.description) || "",
17459 onChange: (value) => onChange({ description: value }),
17460 rows: 5
17461 }
17462 );
17463 },
17464 enableSorting: false,
17465 filterBy: false
17466 };
17467 var description_default = descriptionField;
17468
17469 // packages/media-fields/build-module/filename/index.mjs
17470 var import_i18n60 = __toESM(require_i18n(), 1);
17471 var import_url4 = __toESM(require_url(), 1);
17472
17473 // packages/media-fields/build-module/filename/view.mjs
17474 var import_components51 = __toESM(require_components(), 1);
17475 var import_element58 = __toESM(require_element(), 1);
17476 var import_url3 = __toESM(require_url(), 1);
17477 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
17478 var TRUNCATE_LENGTH = 15;
17479 function FileNameView({
17480 item
17481 }) {
17482 const fileName = (0, import_element58.useMemo)(
17483 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
17484 [item?.source_url]
17485 );
17486 if (!fileName) {
17487 return "";
17488 }
17489 return fileName.length > TRUNCATE_LENGTH ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components51.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components51.__experimentalTruncate, { limit: TRUNCATE_LENGTH, ellipsizeMode: "tail", children: fileName }) }) : /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_jsx_runtime105.Fragment, { children: fileName });
17490 }
17491
17492 // packages/media-fields/build-module/filename/index.mjs
17493 var filenameField = {
17494 id: "filename",
17495 type: "text",
17496 label: (0, import_i18n60.__)("File name"),
17497 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
17498 render: FileNameView,
17499 enableSorting: false,
17500 filterBy: false,
17501 readOnly: true
17502 };
17503 var filename_default = filenameField;
17504
17505 // packages/media-fields/build-module/filesize/index.mjs
17506 var import_i18n61 = __toESM(require_i18n(), 1);
17507 var KB_IN_BYTES = 1024;
17508 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
17509 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
17510 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
17511 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
17512 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
17513 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
17514 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
17515 function getBytesString(bytes, unitSymbol, decimals = 2) {
17516 return (0, import_i18n61.sprintf)(
17517 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
17518 (0, import_i18n61._x)("%1$s %2$s", "file size"),
17519 bytes.toLocaleString(void 0, {
17520 minimumFractionDigits: 0,
17521 maximumFractionDigits: decimals
17522 }),
17523 unitSymbol
17524 );
17525 }
17526 function formatFileSize(bytes, decimals = 2) {
17527 if (bytes === 0) {
17528 return getBytesString(0, (0, import_i18n61._x)("B", "unit symbol"), decimals);
17529 }
17530 const quant = {
17531 /* translators: Unit symbol for yottabyte. */
17532 [(0, import_i18n61._x)("YB", "unit symbol")]: YB_IN_BYTES,
17533 /* translators: Unit symbol for zettabyte. */
17534 [(0, import_i18n61._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
17535 /* translators: Unit symbol for exabyte. */
17536 [(0, import_i18n61._x)("EB", "unit symbol")]: EB_IN_BYTES,
17537 /* translators: Unit symbol for petabyte. */
17538 [(0, import_i18n61._x)("PB", "unit symbol")]: PB_IN_BYTES,
17539 /* translators: Unit symbol for terabyte. */
17540 [(0, import_i18n61._x)("TB", "unit symbol")]: TB_IN_BYTES,
17541 /* translators: Unit symbol for gigabyte. */
17542 [(0, import_i18n61._x)("GB", "unit symbol")]: GB_IN_BYTES,
17543 /* translators: Unit symbol for megabyte. */
17544 [(0, import_i18n61._x)("MB", "unit symbol")]: MB_IN_BYTES,
17545 /* translators: Unit symbol for kilobyte. */
17546 [(0, import_i18n61._x)("KB", "unit symbol")]: KB_IN_BYTES,
17547 /* translators: Unit symbol for byte. */
17548 [(0, import_i18n61._x)("B", "unit symbol")]: 1
17549 };
17550 for (const [unit, mag] of Object.entries(quant)) {
17551 if (bytes >= mag) {
17552 return getBytesString(bytes / mag, unit, decimals);
17553 }
17554 }
17555 return "";
17556 }
17557 var filesizeField = {
17558 id: "filesize",
17559 type: "text",
17560 label: (0, import_i18n61.__)("File size"),
17561 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
17562 isVisible: (item) => {
17563 return !!item?.media_details?.filesize;
17564 },
17565 enableSorting: false,
17566 filterBy: false,
17567 readOnly: true
17568 };
17569 var filesize_default = filesizeField;
17570
17571 // packages/media-fields/build-module/media_dimensions/index.mjs
17572 var import_i18n62 = __toESM(require_i18n(), 1);
17573 var mediaDimensionsField = {
17574 id: "media_dimensions",
17575 type: "text",
17576 label: (0, import_i18n62.__)("Dimensions"),
17577 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n62.sprintf)(
17578 // translators: 1: Width. 2: Height.
17579 (0, import_i18n62._x)("%1$s \xD7 %2$s", "image dimensions"),
17580 item?.media_details?.width?.toString(),
17581 item?.media_details?.height?.toString()
17582 ) : "",
17583 isVisible: (item) => {
17584 return !!(item?.media_details?.width && item?.media_details?.height);
17585 },
17586 enableSorting: false,
17587 filterBy: false,
17588 readOnly: true
17589 };
17590 var media_dimensions_default = mediaDimensionsField;
17591
17592 // packages/media-fields/build-module/media_thumbnail/index.mjs
17593 var import_i18n64 = __toESM(require_i18n(), 1);
17594
17595 // packages/media-fields/build-module/media_thumbnail/view.mjs
17596 var import_data8 = __toESM(require_data(), 1);
17597 var import_core_data3 = __toESM(require_core_data(), 1);
17598 var import_components52 = __toESM(require_components(), 1);
17599 var import_element59 = __toESM(require_element(), 1);
17600 var import_url5 = __toESM(require_url(), 1);
17601
17602 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
17603 var import_i18n63 = __toESM(require_i18n(), 1);
17604 function getMediaTypeFromMimeType(mimeType) {
17605 if (mimeType.startsWith("image/")) {
17606 return {
17607 type: "image",
17608 label: (0, import_i18n63.__)("Image"),
17609 icon: image_default
17610 };
17611 }
17612 if (mimeType.startsWith("video/")) {
17613 return {
17614 type: "video",
17615 label: (0, import_i18n63.__)("Video"),
17616 icon: video_default
17617 };
17618 }
17619 if (mimeType.startsWith("audio/")) {
17620 return {
17621 type: "audio",
17622 label: (0, import_i18n63.__)("Audio"),
17623 icon: audio_default
17624 };
17625 }
17626 return {
17627 type: "application",
17628 label: (0, import_i18n63.__)("Application"),
17629 icon: file_default
17630 };
17631 }
17632
17633 // packages/media-fields/build-module/media_thumbnail/view.mjs
17634 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
17635 function getBestImageUrl(featuredMedia, configSizes) {
17636 const sizes = featuredMedia?.media_details?.sizes;
17637 if (!sizes) {
17638 return featuredMedia.source_url;
17639 }
17640 const sizeEntries = Object.values(sizes);
17641 if (!sizeEntries.length) {
17642 return featuredMedia.source_url;
17643 }
17644 const targetWidth = configSizes ? parseInt(configSizes, 10) : NaN;
17645 if (!Number.isNaN(targetWidth)) {
17646 const validEntries = sizeEntries.filter(
17647 (s2) => typeof s2.width === "number" && !Number.isNaN(s2.width)
17648 );
17649 if (!validEntries.length) {
17650 return featuredMedia.source_url;
17651 }
17652 const sorted = [...validEntries].sort(
17653 (a2, b2) => a2.width - b2.width
17654 );
17655 const match2 = sorted.find((s2) => s2.width >= targetWidth);
17656 if (match2) {
17657 return match2.source_url;
17658 }
17659 return sorted[sorted.length - 1].source_url;
17660 }
17661 return featuredMedia.source_url;
17662 }
17663 function FallbackView({
17664 item,
17665 filename
17666 }) {
17667 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
17668 import_components52.__experimentalVStack,
17669 {
17670 justify: "center",
17671 alignment: "center",
17672 className: "dataviews-media-field__media-thumbnail__stack",
17673 spacing: 0,
17674 children: [
17675 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17676 import_components52.Icon,
17677 {
17678 className: "dataviews-media-field__media-thumbnail--icon",
17679 icon: getMediaTypeFromMimeType(item.mime_type).icon,
17680 size: 24
17681 }
17682 ),
17683 !!filename && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components52.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
17684 ]
17685 }
17686 ) });
17687 }
17688 function ImageView({
17689 item,
17690 configSizes,
17691 onError
17692 }) {
17693 const imageUrl = getBestImageUrl(item, configSizes);
17694 const imgRef = (0, import_element59.useRef)(null);
17695 const [loadingState, setLoadingState] = (0, import_element59.useState)("loading");
17696 (0, import_element59.useLayoutEffect)(() => {
17697 if (imgRef.current?.complete) {
17698 setLoadingState("instant");
17699 } else {
17700 setLoadingState("loading");
17701 }
17702 }, [imageUrl]);
17703 const handleLoad = () => {
17704 if (loadingState === "loading") {
17705 setLoadingState("loaded");
17706 }
17707 };
17708 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17709 "div",
17710 {
17711 className: clsx_default("dataviews-media-field__media-thumbnail", {
17712 "is-loading": loadingState === "loading",
17713 "is-loaded": loadingState === "loaded"
17714 }),
17715 children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17716 "img",
17717 {
17718 ref: imgRef,
17719 className: "dataviews-media-field__media-thumbnail--image",
17720 src: imageUrl,
17721 alt: item.alt_text || item.title.raw,
17722 onLoad: handleLoad,
17723 onError,
17724 loading: "lazy"
17725 }
17726 )
17727 }
17728 );
17729 }
17730 function MediaThumbnailView({
17731 item,
17732 config
17733 }) {
17734 const [imageError, setImageError] = (0, import_element59.useState)(false);
17735 const _featuredMedia = (0, import_data8.useSelect)(
17736 (select) => {
17737 if (!item.featured_media) {
17738 return;
17739 }
17740 return select(import_core_data3.store).getEntityRecord(
17741 "postType",
17742 "attachment",
17743 item.featured_media
17744 );
17745 },
17746 [item.featured_media]
17747 );
17748 const featuredMedia = item.featured_media ? _featuredMedia : item;
17749 if (!featuredMedia) {
17750 return null;
17751 }
17752 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
17753 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
17754 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
17755 }
17756 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17757 ImageView,
17758 {
17759 item: featuredMedia,
17760 configSizes: config?.sizes,
17761 onError: () => setImageError(true)
17762 }
17763 );
17764 }
17765
17766 // packages/media-fields/build-module/media_thumbnail/index.mjs
17767 var mediaThumbnailField = {
17768 id: "media_thumbnail",
17769 type: "media",
17770 label: (0, import_i18n64.__)("Thumbnail"),
17771 render: MediaThumbnailView,
17772 enableSorting: false,
17773 filterBy: false
17774 };
17775 var media_thumbnail_default = mediaThumbnailField;
17776
17777 // packages/media-fields/build-module/mime_type/index.mjs
17778 var import_i18n65 = __toESM(require_i18n(), 1);
17779 var mimeTypeField = {
17780 id: "mime_type",
17781 type: "text",
17782 label: (0, import_i18n65.__)("File type"),
17783 getValue: ({ item }) => item?.mime_type || "",
17784 render: ({ item }) => item?.mime_type || "-",
17785 // Disable sorting until REST API support for ordering my `mime_type` is added.
17786 // See: https://core.trac.wordpress.org/ticket/64073
17787 enableSorting: false,
17788 filterBy: false,
17789 readOnly: true
17790 };
17791 var mime_type_default = mimeTypeField;
17792
17793 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
17794 var import_notices = __toESM(require_notices(), 1);
17795 var import_blob2 = __toESM(require_blob(), 1);
17796
17797 // packages/media-utils/build-module/lock-unlock.mjs
17798 var import_private_apis2 = __toESM(require_private_apis(), 1);
17799 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
17800 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
17801 "@wordpress/media-utils"
17802 );
17803
17804 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
17805 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
17806 var { useEntityRecordsWithPermissions } = unlock2(import_core_data4.privateApis);
17807 var LAYOUT_PICKER_GRID2 = "pickerGrid";
17808 var LAYOUT_PICKER_TABLE2 = "pickerTable";
17809 var NOTICES_CONTEXT = "media-modal";
17810 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
17811 function MediaUploadModal({
17812 allowedTypes,
17813 multiple = false,
17814 value,
17815 onSelect,
17816 onClose,
17817 onUpload,
17818 title = (0, import_i18n66.__)("Select Media"),
17819 isOpen,
17820 isDismissible = true,
17821 modalClass,
17822 search = true,
17823 searchLabel = (0, import_i18n66.__)("Search media")
17824 }) {
17825 const [selection, setSelection] = (0, import_element60.useState)(() => {
17826 if (!value) {
17827 return [];
17828 }
17829 return Array.isArray(value) ? value.map(String) : [String(value)];
17830 });
17831 const { createSuccessNotice, createErrorNotice, createInfoNotice } = (0, import_data9.useDispatch)(import_notices.store);
17832 const { invalidateResolution } = (0, import_data9.useDispatch)(import_core_data4.store);
17833 const [view, setView] = (0, import_element60.useState)(() => ({
17834 type: LAYOUT_PICKER_GRID2,
17835 fields: [],
17836 showTitle: false,
17837 titleField: "title",
17838 mediaField: "media_thumbnail",
17839 search: "",
17840 page: 1,
17841 perPage: 20,
17842 filters: [],
17843 layout: {
17844 previewSize: 170
17845 }
17846 }));
17847 const queryArgs = (0, import_element60.useMemo)(() => {
17848 const filters = {};
17849 view.filters?.forEach((filter) => {
17850 if (filter.field === "media_type") {
17851 filters.media_type = filter.value;
17852 }
17853 if (filter.field === "author") {
17854 if (filter.operator === "isAny") {
17855 filters.author = filter.value;
17856 } else if (filter.operator === "isNone") {
17857 filters.author_exclude = filter.value;
17858 }
17859 }
17860 if (filter.field === "date" || filter.field === "modified") {
17861 if (filter.operator === "before") {
17862 filters.before = filter.value;
17863 } else if (filter.operator === "after") {
17864 filters.after = filter.value;
17865 }
17866 }
17867 if (filter.field === "mime_type") {
17868 filters.mime_type = filter.value;
17869 }
17870 });
17871 if (!filters.media_type) {
17872 filters.media_type = allowedTypes?.includes("*") ? void 0 : allowedTypes;
17873 }
17874 return {
17875 per_page: view.perPage || 20,
17876 page: view.page || 1,
17877 status: "inherit",
17878 order: view.sort?.direction,
17879 orderby: view.sort?.field,
17880 search: view.search,
17881 _embed: "author,wp:attached-to",
17882 ...filters
17883 };
17884 }, [view, allowedTypes]);
17885 const {
17886 records: mediaRecords,
17887 isResolving: isLoading,
17888 totalItems,
17889 totalPages
17890 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
17891 const fields = (0, import_element60.useMemo)(
17892 () => [
17893 // Media field definitions from @wordpress/media-fields
17894 // Cast is safe because RestAttachment has the same properties as Attachment
17895 {
17896 ...media_thumbnail_default,
17897 enableHiding: false
17898 // Within the modal, the thumbnail should always be shown.
17899 },
17900 {
17901 id: "title",
17902 type: "text",
17903 label: (0, import_i18n66.__)("Title"),
17904 getValue: ({ item }) => {
17905 const titleValue = item.title.raw || item.title.rendered;
17906 return titleValue || (0, import_i18n66.__)("(no title)");
17907 }
17908 },
17909 alt_text_default,
17910 caption_default,
17911 description_default,
17912 date_added_default,
17913 date_modified_default,
17914 author_default,
17915 filename_default,
17916 filesize_default,
17917 media_dimensions_default,
17918 mime_type_default,
17919 attached_to_default
17920 ],
17921 []
17922 );
17923 const actions = (0, import_element60.useMemo)(
17924 () => [
17925 {
17926 id: "select",
17927 label: multiple ? (0, import_i18n66.__)("Select") : (0, import_i18n66.__)("Select"),
17928 isPrimary: true,
17929 supportsBulk: multiple,
17930 async callback() {
17931 if (selection.length === 0) {
17932 return;
17933 }
17934 const selectedPostsQuery = {
17935 include: selection,
17936 per_page: -1
17937 };
17938 const selectedPosts = await (0, import_data9.resolveSelect)(
17939 import_core_data4.store
17940 ).getEntityRecords(
17941 "postType",
17942 "attachment",
17943 selectedPostsQuery
17944 );
17945 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
17946 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
17947 onSelect(selectedItems);
17948 }
17949 }
17950 ],
17951 [multiple, onSelect, selection]
17952 );
17953 const handleModalClose = (0, import_element60.useCallback)(() => {
17954 onClose?.();
17955 }, [onClose]);
17956 const handleUpload = onUpload || uploadMedia;
17957 const handleUploadComplete = (0, import_element60.useCallback)(
17958 (attachments) => {
17959 const allComplete = attachments.every(
17960 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
17961 );
17962 if (allComplete && attachments.length > 0) {
17963 createSuccessNotice(
17964 (0, import_i18n66.sprintf)(
17965 // translators: %s: number of files
17966 (0, import_i18n66._n)(
17967 "Uploaded %s file",
17968 "Uploaded %s files",
17969 attachments.length
17970 ),
17971 attachments.length.toLocaleString()
17972 ),
17973 {
17974 type: "snackbar",
17975 context: NOTICES_CONTEXT,
17976 id: NOTICE_ID_UPLOAD_PROGRESS
17977 }
17978 );
17979 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
17980 if (multiple) {
17981 setSelection((prev) => [...prev, ...uploadedIds]);
17982 } else {
17983 setSelection(uploadedIds.slice(0, 1));
17984 }
17985 invalidateResolution("getEntityRecords", [
17986 "postType",
17987 "attachment",
17988 queryArgs
17989 ]);
17990 }
17991 },
17992 [createSuccessNotice, invalidateResolution, queryArgs, multiple]
17993 );
17994 const handleUploadError = (0, import_element60.useCallback)(
17995 (error) => {
17996 createErrorNotice(error.message, {
17997 type: "snackbar",
17998 context: NOTICES_CONTEXT,
17999 id: NOTICE_ID_UPLOAD_PROGRESS
18000 });
18001 },
18002 [createErrorNotice]
18003 );
18004 const handleFileSelect = (0, import_element60.useCallback)(
18005 (event) => {
18006 const files = event.target.files;
18007 if (files && files.length > 0) {
18008 const filesArray = Array.from(files);
18009 createInfoNotice(
18010 (0, import_i18n66.sprintf)(
18011 // translators: %s: number of files
18012 (0, import_i18n66._n)(
18013 "Uploading %s file",
18014 "Uploading %s files",
18015 filesArray.length
18016 ),
18017 filesArray.length.toLocaleString()
18018 ),
18019 {
18020 type: "snackbar",
18021 context: NOTICES_CONTEXT,
18022 id: NOTICE_ID_UPLOAD_PROGRESS,
18023 explicitDismiss: true
18024 }
18025 );
18026 handleUpload({
18027 allowedTypes,
18028 filesList: filesArray,
18029 onFileChange: handleUploadComplete,
18030 onError: handleUploadError
18031 });
18032 }
18033 },
18034 [
18035 allowedTypes,
18036 handleUpload,
18037 createInfoNotice,
18038 handleUploadComplete,
18039 handleUploadError
18040 ]
18041 );
18042 const paginationInfo = (0, import_element60.useMemo)(
18043 () => ({
18044 totalItems,
18045 totalPages
18046 }),
18047 [totalItems, totalPages]
18048 );
18049 const defaultLayouts = (0, import_element60.useMemo)(
18050 () => ({
18051 [LAYOUT_PICKER_GRID2]: {
18052 fields: [],
18053 showTitle: false
18054 },
18055 [LAYOUT_PICKER_TABLE2]: {
18056 fields: [
18057 "filename",
18058 "filesize",
18059 "media_dimensions",
18060 "author",
18061 "date"
18062 ],
18063 showTitle: true
18064 }
18065 }),
18066 []
18067 );
18068 const acceptTypes = (0, import_element60.useMemo)(() => {
18069 if (allowedTypes?.includes("*")) {
18070 return void 0;
18071 }
18072 return allowedTypes?.join(",");
18073 }, [allowedTypes]);
18074 if (!isOpen) {
18075 return null;
18076 }
18077 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
18078 import_components53.Modal,
18079 {
18080 title,
18081 onRequestClose: handleModalClose,
18082 isDismissible,
18083 className: modalClass,
18084 overlayClassName: "media-upload-modal",
18085 size: "fill",
18086 headerActions: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18087 import_components53.FormFileUpload,
18088 {
18089 accept: acceptTypes,
18090 multiple: true,
18091 onChange: handleFileSelect,
18092 __next40pxDefaultSize: true,
18093 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18094 import_components53.Button,
18095 {
18096 onClick: openFileDialog,
18097 icon: upload_default,
18098 __next40pxDefaultSize: true,
18099 children: (0, import_i18n66.__)("Upload media")
18100 }
18101 )
18102 }
18103 ),
18104 children: [
18105 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18106 import_components53.DropZone,
18107 {
18108 onFilesDrop: (files) => {
18109 let filteredFiles = files;
18110 if (allowedTypes && !allowedTypes.includes("*")) {
18111 filteredFiles = files.filter(
18112 (file) => allowedTypes.some((allowedType) => {
18113 return file.type === allowedType || file.type.startsWith(
18114 allowedType.replace("*", "")
18115 );
18116 })
18117 );
18118 }
18119 if (filteredFiles.length > 0) {
18120 createInfoNotice(
18121 (0, import_i18n66.sprintf)(
18122 // translators: %s: number of files
18123 (0, import_i18n66._n)(
18124 "Uploading %s file",
18125 "Uploading %s files",
18126 filteredFiles.length
18127 ),
18128 filteredFiles.length.toLocaleString()
18129 ),
18130 {
18131 type: "snackbar",
18132 context: NOTICES_CONTEXT,
18133 id: NOTICE_ID_UPLOAD_PROGRESS,
18134 explicitDismiss: true
18135 }
18136 );
18137 handleUpload({
18138 allowedTypes,
18139 filesList: filteredFiles,
18140 onFileChange: handleUploadComplete,
18141 onError: handleUploadError
18142 });
18143 }
18144 },
18145 label: (0, import_i18n66.__)("Drop files to upload")
18146 }
18147 ),
18148 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18149 dataviews_picker_default,
18150 {
18151 data: mediaRecords || [],
18152 fields,
18153 view,
18154 onChangeView: setView,
18155 actions,
18156 selection,
18157 onChangeSelection: setSelection,
18158 isLoading,
18159 paginationInfo,
18160 defaultLayouts,
18161 getItemId: (item) => String(item.id),
18162 search,
18163 searchLabel,
18164 itemListLabel: (0, import_i18n66.__)("Media items")
18165 }
18166 ),
18167 (0, import_element60.createPortal)(
18168 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18169 import_notices.SnackbarNotices,
18170 {
18171 className: "media-upload-modal__snackbar",
18172 context: NOTICES_CONTEXT
18173 }
18174 ),
18175 document.body
18176 )
18177 ]
18178 }
18179 );
18180 }
18181
18182 // packages/media-utils/build-module/private-apis.mjs
18183 var privateApis12 = {};
18184 lock2(privateApis12, {
18185 sideloadMedia,
18186 MediaUploadModal
18187 });
18188 return __toCommonJS(index_exports);
18189 })();
18190 /*! Bundled license information:
18191
18192 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
18193 (**
18194 * @license React
18195 * use-sync-external-store-shim.development.js
18196 *
18197 * Copyright (c) Meta Platforms, Inc. and affiliates.
18198 *
18199 * This source code is licensed under the MIT license found in the
18200 * LICENSE file in the root directory of this source tree.
18201 *)
18202 */
18203 //# sourceMappingURL=index.js.map
18204