PluginProbe
Gutenberg / 23.1.0
Gutenberg v23.1.0
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / routes / pattern-list / content.js

content.js in Gutenberg 23.1.0, at build/routes/pattern-list/content.js

18,673 lines 633.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var __create = Object.create;
2 var __defProp = Object.defineProperty;
3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4 var __getOwnPropNames = Object.getOwnPropertyNames;
5 var __getProtoOf = Object.getPrototypeOf;
6 var __hasOwnProp = Object.prototype.hasOwnProperty;
7 var __commonJS = (cb, mod) => function __require() {
8 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9 };
10 var __copyProps = (to, from, except, desc) => {
11 if (from && typeof from === "object" || typeof from === "function") {
12 for (let key of __getOwnPropNames(from))
13 if (!__hasOwnProp.call(to, key) && key !== except)
14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15 }
16 return to;
17 };
18 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19 // If the importer is in node compatibility mode or this is not an ESM
20 // file that has been converted to a CommonJS file using a Babel-
21 // compatible transform (i.e. "__esModule" has not been set), then set
22 // "default" to the CommonJS "module.exports" for node compatibility.
23 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24 mod
25 ));
26
27 // package-external:@wordpress/element
28 var require_element = __commonJS({
29 "package-external:@wordpress/element"(exports, module) {
30 module.exports = window.wp.element;
31 }
32 });
33
34 // package-external:@wordpress/data
35 var require_data = __commonJS({
36 "package-external:@wordpress/data"(exports, module) {
37 module.exports = window.wp.data;
38 }
39 });
40
41 // package-external:@wordpress/preferences
42 var require_preferences = __commonJS({
43 "package-external:@wordpress/preferences"(exports, module) {
44 module.exports = window.wp.preferences;
45 }
46 });
47
48 // package-external:@wordpress/core-data
49 var require_core_data = __commonJS({
50 "package-external:@wordpress/core-data"(exports, module) {
51 module.exports = window.wp.coreData;
52 }
53 });
54
55 // package-external:@wordpress/private-apis
56 var require_private_apis = __commonJS({
57 "package-external:@wordpress/private-apis"(exports, module) {
58 module.exports = window.wp.privateApis;
59 }
60 });
61
62 // package-external:@wordpress/compose
63 var require_compose = __commonJS({
64 "package-external:@wordpress/compose"(exports, module) {
65 module.exports = window.wp.compose;
66 }
67 });
68
69 // vendor-external:react
70 var require_react = __commonJS({
71 "vendor-external:react"(exports, module) {
72 module.exports = window.React;
73 }
74 });
75
76 // vendor-external:react/jsx-runtime
77 var require_jsx_runtime = __commonJS({
78 "vendor-external:react/jsx-runtime"(exports, module) {
79 module.exports = window.ReactJSXRuntime;
80 }
81 });
82
83 // vendor-external:react-dom
84 var require_react_dom = __commonJS({
85 "vendor-external:react-dom"(exports, module) {
86 module.exports = window.ReactDOM;
87 }
88 });
89
90 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
91 var require_use_sync_external_store_shim_development = __commonJS({
92 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
93 "use strict";
94 (function() {
95 function is(x2, y2) {
96 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
97 }
98 function useSyncExternalStore$2(subscribe2, getSnapshot) {
99 didWarnOld18Alpha || void 0 === React9.startTransition || (didWarnOld18Alpha = true, console.error(
100 "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."
101 ));
102 var value = getSnapshot();
103 if (!didWarnUncachedGetSnapshot) {
104 var cachedValue = getSnapshot();
105 objectIs(value, cachedValue) || (console.error(
106 "The result of getSnapshot should be cached to avoid an infinite loop"
107 ), didWarnUncachedGetSnapshot = true);
108 }
109 cachedValue = useState25({
110 inst: { value, getSnapshot }
111 });
112 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
113 useLayoutEffect3(
114 function() {
115 inst.value = value;
116 inst.getSnapshot = getSnapshot;
117 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
118 },
119 [subscribe2, value, getSnapshot]
120 );
121 useEffect21(
122 function() {
123 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
124 return subscribe2(function() {
125 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
126 });
127 },
128 [subscribe2]
129 );
130 useDebugValue(value);
131 return value;
132 }
133 function checkIfSnapshotChanged(inst) {
134 var latestGetSnapshot = inst.getSnapshot;
135 inst = inst.value;
136 try {
137 var nextValue = latestGetSnapshot();
138 return !objectIs(inst, nextValue);
139 } catch (error) {
140 return true;
141 }
142 }
143 function useSyncExternalStore$1(subscribe2, getSnapshot) {
144 return getSnapshot();
145 }
146 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
147 var React9 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState25 = React9.useState, useEffect21 = React9.useEffect, useLayoutEffect3 = React9.useLayoutEffect, useDebugValue = React9.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
148 exports.useSyncExternalStore = void 0 !== React9.useSyncExternalStore ? React9.useSyncExternalStore : shim;
149 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
150 })();
151 }
152 });
153
154 // node_modules/use-sync-external-store/shim/index.js
155 var require_shim = __commonJS({
156 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
157 "use strict";
158 if (false) {
159 module.exports = null;
160 } else {
161 module.exports = require_use_sync_external_store_shim_development();
162 }
163 }
164 });
165
166 // package-external:@wordpress/i18n
167 var require_i18n = __commonJS({
168 "package-external:@wordpress/i18n"(exports, module) {
169 module.exports = window.wp.i18n;
170 }
171 });
172
173 // package-external:@wordpress/primitives
174 var require_primitives = __commonJS({
175 "package-external:@wordpress/primitives"(exports, module) {
176 module.exports = window.wp.primitives;
177 }
178 });
179
180 // package-external:@wordpress/components
181 var require_components = __commonJS({
182 "package-external:@wordpress/components"(exports, module) {
183 module.exports = window.wp.components;
184 }
185 });
186
187 // package-external:@wordpress/keycodes
188 var require_keycodes = __commonJS({
189 "package-external:@wordpress/keycodes"(exports, module) {
190 module.exports = window.wp.keycodes;
191 }
192 });
193
194 // node_modules/remove-accents/index.js
195 var require_remove_accents = __commonJS({
196 "node_modules/remove-accents/index.js"(exports, module) {
197 var characterMap = {
198 "\xC0": "A",
199 "\xC1": "A",
200 "\xC2": "A",
201 "\xC3": "A",
202 "\xC4": "A",
203 "\xC5": "A",
204 "\u1EA4": "A",
205 "\u1EAE": "A",
206 "\u1EB2": "A",
207 "\u1EB4": "A",
208 "\u1EB6": "A",
209 "\xC6": "AE",
210 "\u1EA6": "A",
211 "\u1EB0": "A",
212 "\u0202": "A",
213 "\u1EA2": "A",
214 "\u1EA0": "A",
215 "\u1EA8": "A",
216 "\u1EAA": "A",
217 "\u1EAC": "A",
218 "\xC7": "C",
219 "\u1E08": "C",
220 "\xC8": "E",
221 "\xC9": "E",
222 "\xCA": "E",
223 "\xCB": "E",
224 "\u1EBE": "E",
225 "\u1E16": "E",
226 "\u1EC0": "E",
227 "\u1E14": "E",
228 "\u1E1C": "E",
229 "\u0206": "E",
230 "\u1EBA": "E",
231 "\u1EBC": "E",
232 "\u1EB8": "E",
233 "\u1EC2": "E",
234 "\u1EC4": "E",
235 "\u1EC6": "E",
236 "\xCC": "I",
237 "\xCD": "I",
238 "\xCE": "I",
239 "\xCF": "I",
240 "\u1E2E": "I",
241 "\u020A": "I",
242 "\u1EC8": "I",
243 "\u1ECA": "I",
244 "\xD0": "D",
245 "\xD1": "N",
246 "\xD2": "O",
247 "\xD3": "O",
248 "\xD4": "O",
249 "\xD5": "O",
250 "\xD6": "O",
251 "\xD8": "O",
252 "\u1ED0": "O",
253 "\u1E4C": "O",
254 "\u1E52": "O",
255 "\u020E": "O",
256 "\u1ECE": "O",
257 "\u1ECC": "O",
258 "\u1ED4": "O",
259 "\u1ED6": "O",
260 "\u1ED8": "O",
261 "\u1EDC": "O",
262 "\u1EDE": "O",
263 "\u1EE0": "O",
264 "\u1EDA": "O",
265 "\u1EE2": "O",
266 "\xD9": "U",
267 "\xDA": "U",
268 "\xDB": "U",
269 "\xDC": "U",
270 "\u1EE6": "U",
271 "\u1EE4": "U",
272 "\u1EEC": "U",
273 "\u1EEE": "U",
274 "\u1EF0": "U",
275 "\xDD": "Y",
276 "\xE0": "a",
277 "\xE1": "a",
278 "\xE2": "a",
279 "\xE3": "a",
280 "\xE4": "a",
281 "\xE5": "a",
282 "\u1EA5": "a",
283 "\u1EAF": "a",
284 "\u1EB3": "a",
285 "\u1EB5": "a",
286 "\u1EB7": "a",
287 "\xE6": "ae",
288 "\u1EA7": "a",
289 "\u1EB1": "a",
290 "\u0203": "a",
291 "\u1EA3": "a",
292 "\u1EA1": "a",
293 "\u1EA9": "a",
294 "\u1EAB": "a",
295 "\u1EAD": "a",
296 "\xE7": "c",
297 "\u1E09": "c",
298 "\xE8": "e",
299 "\xE9": "e",
300 "\xEA": "e",
301 "\xEB": "e",
302 "\u1EBF": "e",
303 "\u1E17": "e",
304 "\u1EC1": "e",
305 "\u1E15": "e",
306 "\u1E1D": "e",
307 "\u0207": "e",
308 "\u1EBB": "e",
309 "\u1EBD": "e",
310 "\u1EB9": "e",
311 "\u1EC3": "e",
312 "\u1EC5": "e",
313 "\u1EC7": "e",
314 "\xEC": "i",
315 "\xED": "i",
316 "\xEE": "i",
317 "\xEF": "i",
318 "\u1E2F": "i",
319 "\u020B": "i",
320 "\u1EC9": "i",
321 "\u1ECB": "i",
322 "\xF0": "d",
323 "\xF1": "n",
324 "\xF2": "o",
325 "\xF3": "o",
326 "\xF4": "o",
327 "\xF5": "o",
328 "\xF6": "o",
329 "\xF8": "o",
330 "\u1ED1": "o",
331 "\u1E4D": "o",
332 "\u1E53": "o",
333 "\u020F": "o",
334 "\u1ECF": "o",
335 "\u1ECD": "o",
336 "\u1ED5": "o",
337 "\u1ED7": "o",
338 "\u1ED9": "o",
339 "\u1EDD": "o",
340 "\u1EDF": "o",
341 "\u1EE1": "o",
342 "\u1EDB": "o",
343 "\u1EE3": "o",
344 "\xF9": "u",
345 "\xFA": "u",
346 "\xFB": "u",
347 "\xFC": "u",
348 "\u1EE7": "u",
349 "\u1EE5": "u",
350 "\u1EED": "u",
351 "\u1EEF": "u",
352 "\u1EF1": "u",
353 "\xFD": "y",
354 "\xFF": "y",
355 "\u0100": "A",
356 "\u0101": "a",
357 "\u0102": "A",
358 "\u0103": "a",
359 "\u0104": "A",
360 "\u0105": "a",
361 "\u0106": "C",
362 "\u0107": "c",
363 "\u0108": "C",
364 "\u0109": "c",
365 "\u010A": "C",
366 "\u010B": "c",
367 "\u010C": "C",
368 "\u010D": "c",
369 "C\u0306": "C",
370 "c\u0306": "c",
371 "\u010E": "D",
372 "\u010F": "d",
373 "\u0110": "D",
374 "\u0111": "d",
375 "\u0112": "E",
376 "\u0113": "e",
377 "\u0114": "E",
378 "\u0115": "e",
379 "\u0116": "E",
380 "\u0117": "e",
381 "\u0118": "E",
382 "\u0119": "e",
383 "\u011A": "E",
384 "\u011B": "e",
385 "\u011C": "G",
386 "\u01F4": "G",
387 "\u011D": "g",
388 "\u01F5": "g",
389 "\u011E": "G",
390 "\u011F": "g",
391 "\u0120": "G",
392 "\u0121": "g",
393 "\u0122": "G",
394 "\u0123": "g",
395 "\u0124": "H",
396 "\u0125": "h",
397 "\u0126": "H",
398 "\u0127": "h",
399 "\u1E2A": "H",
400 "\u1E2B": "h",
401 "\u0128": "I",
402 "\u0129": "i",
403 "\u012A": "I",
404 "\u012B": "i",
405 "\u012C": "I",
406 "\u012D": "i",
407 "\u012E": "I",
408 "\u012F": "i",
409 "\u0130": "I",
410 "\u0131": "i",
411 "\u0132": "IJ",
412 "\u0133": "ij",
413 "\u0134": "J",
414 "\u0135": "j",
415 "\u0136": "K",
416 "\u0137": "k",
417 "\u1E30": "K",
418 "\u1E31": "k",
419 "K\u0306": "K",
420 "k\u0306": "k",
421 "\u0139": "L",
422 "\u013A": "l",
423 "\u013B": "L",
424 "\u013C": "l",
425 "\u013D": "L",
426 "\u013E": "l",
427 "\u013F": "L",
428 "\u0140": "l",
429 "\u0141": "l",
430 "\u0142": "l",
431 "\u1E3E": "M",
432 "\u1E3F": "m",
433 "M\u0306": "M",
434 "m\u0306": "m",
435 "\u0143": "N",
436 "\u0144": "n",
437 "\u0145": "N",
438 "\u0146": "n",
439 "\u0147": "N",
440 "\u0148": "n",
441 "\u0149": "n",
442 "N\u0306": "N",
443 "n\u0306": "n",
444 "\u014C": "O",
445 "\u014D": "o",
446 "\u014E": "O",
447 "\u014F": "o",
448 "\u0150": "O",
449 "\u0151": "o",
450 "\u0152": "OE",
451 "\u0153": "oe",
452 "P\u0306": "P",
453 "p\u0306": "p",
454 "\u0154": "R",
455 "\u0155": "r",
456 "\u0156": "R",
457 "\u0157": "r",
458 "\u0158": "R",
459 "\u0159": "r",
460 "R\u0306": "R",
461 "r\u0306": "r",
462 "\u0212": "R",
463 "\u0213": "r",
464 "\u015A": "S",
465 "\u015B": "s",
466 "\u015C": "S",
467 "\u015D": "s",
468 "\u015E": "S",
469 "\u0218": "S",
470 "\u0219": "s",
471 "\u015F": "s",
472 "\u0160": "S",
473 "\u0161": "s",
474 "\u0162": "T",
475 "\u0163": "t",
476 "\u021B": "t",
477 "\u021A": "T",
478 "\u0164": "T",
479 "\u0165": "t",
480 "\u0166": "T",
481 "\u0167": "t",
482 "T\u0306": "T",
483 "t\u0306": "t",
484 "\u0168": "U",
485 "\u0169": "u",
486 "\u016A": "U",
487 "\u016B": "u",
488 "\u016C": "U",
489 "\u016D": "u",
490 "\u016E": "U",
491 "\u016F": "u",
492 "\u0170": "U",
493 "\u0171": "u",
494 "\u0172": "U",
495 "\u0173": "u",
496 "\u0216": "U",
497 "\u0217": "u",
498 "V\u0306": "V",
499 "v\u0306": "v",
500 "\u0174": "W",
501 "\u0175": "w",
502 "\u1E82": "W",
503 "\u1E83": "w",
504 "X\u0306": "X",
505 "x\u0306": "x",
506 "\u0176": "Y",
507 "\u0177": "y",
508 "\u0178": "Y",
509 "Y\u0306": "Y",
510 "y\u0306": "y",
511 "\u0179": "Z",
512 "\u017A": "z",
513 "\u017B": "Z",
514 "\u017C": "z",
515 "\u017D": "Z",
516 "\u017E": "z",
517 "\u017F": "s",
518 "\u0192": "f",
519 "\u01A0": "O",
520 "\u01A1": "o",
521 "\u01AF": "U",
522 "\u01B0": "u",
523 "\u01CD": "A",
524 "\u01CE": "a",
525 "\u01CF": "I",
526 "\u01D0": "i",
527 "\u01D1": "O",
528 "\u01D2": "o",
529 "\u01D3": "U",
530 "\u01D4": "u",
531 "\u01D5": "U",
532 "\u01D6": "u",
533 "\u01D7": "U",
534 "\u01D8": "u",
535 "\u01D9": "U",
536 "\u01DA": "u",
537 "\u01DB": "U",
538 "\u01DC": "u",
539 "\u1EE8": "U",
540 "\u1EE9": "u",
541 "\u1E78": "U",
542 "\u1E79": "u",
543 "\u01FA": "A",
544 "\u01FB": "a",
545 "\u01FC": "AE",
546 "\u01FD": "ae",
547 "\u01FE": "O",
548 "\u01FF": "o",
549 "\xDE": "TH",
550 "\xFE": "th",
551 "\u1E54": "P",
552 "\u1E55": "p",
553 "\u1E64": "S",
554 "\u1E65": "s",
555 "X\u0301": "X",
556 "x\u0301": "x",
557 "\u0403": "\u0413",
558 "\u0453": "\u0433",
559 "\u040C": "\u041A",
560 "\u045C": "\u043A",
561 "A\u030B": "A",
562 "a\u030B": "a",
563 "E\u030B": "E",
564 "e\u030B": "e",
565 "I\u030B": "I",
566 "i\u030B": "i",
567 "\u01F8": "N",
568 "\u01F9": "n",
569 "\u1ED2": "O",
570 "\u1ED3": "o",
571 "\u1E50": "O",
572 "\u1E51": "o",
573 "\u1EEA": "U",
574 "\u1EEB": "u",
575 "\u1E80": "W",
576 "\u1E81": "w",
577 "\u1EF2": "Y",
578 "\u1EF3": "y",
579 "\u0200": "A",
580 "\u0201": "a",
581 "\u0204": "E",
582 "\u0205": "e",
583 "\u0208": "I",
584 "\u0209": "i",
585 "\u020C": "O",
586 "\u020D": "o",
587 "\u0210": "R",
588 "\u0211": "r",
589 "\u0214": "U",
590 "\u0215": "u",
591 "B\u030C": "B",
592 "b\u030C": "b",
593 "\u010C\u0323": "C",
594 "\u010D\u0323": "c",
595 "\xCA\u030C": "E",
596 "\xEA\u030C": "e",
597 "F\u030C": "F",
598 "f\u030C": "f",
599 "\u01E6": "G",
600 "\u01E7": "g",
601 "\u021E": "H",
602 "\u021F": "h",
603 "J\u030C": "J",
604 "\u01F0": "j",
605 "\u01E8": "K",
606 "\u01E9": "k",
607 "M\u030C": "M",
608 "m\u030C": "m",
609 "P\u030C": "P",
610 "p\u030C": "p",
611 "Q\u030C": "Q",
612 "q\u030C": "q",
613 "\u0158\u0329": "R",
614 "\u0159\u0329": "r",
615 "\u1E66": "S",
616 "\u1E67": "s",
617 "V\u030C": "V",
618 "v\u030C": "v",
619 "W\u030C": "W",
620 "w\u030C": "w",
621 "X\u030C": "X",
622 "x\u030C": "x",
623 "Y\u030C": "Y",
624 "y\u030C": "y",
625 "A\u0327": "A",
626 "a\u0327": "a",
627 "B\u0327": "B",
628 "b\u0327": "b",
629 "\u1E10": "D",
630 "\u1E11": "d",
631 "\u0228": "E",
632 "\u0229": "e",
633 "\u0190\u0327": "E",
634 "\u025B\u0327": "e",
635 "\u1E28": "H",
636 "\u1E29": "h",
637 "I\u0327": "I",
638 "i\u0327": "i",
639 "\u0197\u0327": "I",
640 "\u0268\u0327": "i",
641 "M\u0327": "M",
642 "m\u0327": "m",
643 "O\u0327": "O",
644 "o\u0327": "o",
645 "Q\u0327": "Q",
646 "q\u0327": "q",
647 "U\u0327": "U",
648 "u\u0327": "u",
649 "X\u0327": "X",
650 "x\u0327": "x",
651 "Z\u0327": "Z",
652 "z\u0327": "z",
653 "\u0439": "\u0438",
654 "\u0419": "\u0418",
655 "\u0451": "\u0435",
656 "\u0401": "\u0415"
657 };
658 var chars = Object.keys(characterMap).join("|");
659 var allAccents = new RegExp(chars, "g");
660 var firstAccent = new RegExp(chars, "");
661 function matcher(match2) {
662 return characterMap[match2];
663 }
664 var removeAccents3 = function(string) {
665 return string.replace(allAccents, matcher);
666 };
667 var hasAccents = function(string) {
668 return !!string.match(firstAccent);
669 };
670 module.exports = removeAccents3;
671 module.exports.has = hasAccents;
672 module.exports.remove = removeAccents3;
673 }
674 });
675
676 // node_modules/fast-deep-equal/es6/index.js
677 var require_es6 = __commonJS({
678 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
679 "use strict";
680 module.exports = function equal(a2, b2) {
681 if (a2 === b2) return true;
682 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
683 if (a2.constructor !== b2.constructor) return false;
684 var length, i2, keys;
685 if (Array.isArray(a2)) {
686 length = a2.length;
687 if (length != b2.length) return false;
688 for (i2 = length; i2-- !== 0; )
689 if (!equal(a2[i2], b2[i2])) return false;
690 return true;
691 }
692 if (a2 instanceof Map && b2 instanceof Map) {
693 if (a2.size !== b2.size) return false;
694 for (i2 of a2.entries())
695 if (!b2.has(i2[0])) return false;
696 for (i2 of a2.entries())
697 if (!equal(i2[1], b2.get(i2[0]))) return false;
698 return true;
699 }
700 if (a2 instanceof Set && b2 instanceof Set) {
701 if (a2.size !== b2.size) return false;
702 for (i2 of a2.entries())
703 if (!b2.has(i2[0])) return false;
704 return true;
705 }
706 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
707 length = a2.length;
708 if (length != b2.length) return false;
709 for (i2 = length; i2-- !== 0; )
710 if (a2[i2] !== b2[i2]) return false;
711 return true;
712 }
713 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
714 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
715 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
716 keys = Object.keys(a2);
717 length = keys.length;
718 if (length !== Object.keys(b2).length) return false;
719 for (i2 = length; i2-- !== 0; )
720 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
721 for (i2 = length; i2-- !== 0; ) {
722 var key = keys[i2];
723 if (!equal(a2[key], b2[key])) return false;
724 }
725 return true;
726 }
727 return a2 !== a2 && b2 !== b2;
728 };
729 }
730 });
731
732 // package-external:@wordpress/date
733 var require_date = __commonJS({
734 "package-external:@wordpress/date"(exports, module) {
735 module.exports = window.wp.date;
736 }
737 });
738
739 // package-external:@wordpress/warning
740 var require_warning = __commonJS({
741 "package-external:@wordpress/warning"(exports, module) {
742 module.exports = window.wp.warning;
743 }
744 });
745
746 // package-external:@wordpress/deprecated
747 var require_deprecated = __commonJS({
748 "package-external:@wordpress/deprecated"(exports, module) {
749 module.exports = window.wp.deprecated;
750 }
751 });
752
753 // package-external:@wordpress/editor
754 var require_editor = __commonJS({
755 "package-external:@wordpress/editor"(exports, module) {
756 module.exports = window.wp.editor;
757 }
758 });
759
760 // package-external:@wordpress/patterns
761 var require_patterns = __commonJS({
762 "package-external:@wordpress/patterns"(exports, module) {
763 module.exports = window.wp.patterns;
764 }
765 });
766
767 // package-external:@wordpress/block-editor
768 var require_block_editor = __commonJS({
769 "package-external:@wordpress/block-editor"(exports, module) {
770 module.exports = window.wp.blockEditor;
771 }
772 });
773
774 // routes/pattern-list/stage.tsx
775 import {
776 useParams,
777 useNavigate,
778 useSearch,
779 Link,
780 useInvalidate
781 } from "@wordpress/route";
782
783 // node_modules/dequal/dist/index.mjs
784 var has = Object.prototype.hasOwnProperty;
785 function find(iter, tar, key) {
786 for (key of iter.keys()) {
787 if (dequal(key, tar)) return key;
788 }
789 }
790 function dequal(foo, bar) {
791 var ctor, len, tmp;
792 if (foo === bar) return true;
793 if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
794 if (ctor === Date) return foo.getTime() === bar.getTime();
795 if (ctor === RegExp) return foo.toString() === bar.toString();
796 if (ctor === Array) {
797 if ((len = foo.length) === bar.length) {
798 while (len-- && dequal(foo[len], bar[len])) ;
799 }
800 return len === -1;
801 }
802 if (ctor === Set) {
803 if (foo.size !== bar.size) {
804 return false;
805 }
806 for (len of foo) {
807 tmp = len;
808 if (tmp && typeof tmp === "object") {
809 tmp = find(bar, tmp);
810 if (!tmp) return false;
811 }
812 if (!bar.has(tmp)) return false;
813 }
814 return true;
815 }
816 if (ctor === Map) {
817 if (foo.size !== bar.size) {
818 return false;
819 }
820 for (len of foo) {
821 tmp = len[0];
822 if (tmp && typeof tmp === "object") {
823 tmp = find(bar, tmp);
824 if (!tmp) return false;
825 }
826 if (!dequal(len[1], bar.get(tmp))) {
827 return false;
828 }
829 }
830 return true;
831 }
832 if (ctor === ArrayBuffer) {
833 foo = new Uint8Array(foo);
834 bar = new Uint8Array(bar);
835 } else if (ctor === DataView) {
836 if ((len = foo.byteLength) === bar.byteLength) {
837 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
838 }
839 return len === -1;
840 }
841 if (ArrayBuffer.isView(foo)) {
842 if ((len = foo.byteLength) === bar.byteLength) {
843 while (len-- && foo[len] === bar[len]) ;
844 }
845 return len === -1;
846 }
847 if (!ctor || typeof foo === "object") {
848 len = 0;
849 for (ctor in foo) {
850 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
851 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
852 }
853 return Object.keys(bar).length === len;
854 }
855 }
856 return foo !== foo && bar !== bar;
857 }
858
859 // packages/views/build-module/use-view.mjs
860 var import_element = __toESM(require_element(), 1);
861 var import_data = __toESM(require_data(), 1);
862 var import_preferences = __toESM(require_preferences(), 1);
863
864 // packages/views/build-module/preference-keys.mjs
865 function generatePreferenceKey(kind, name, slug) {
866 return `dataviews-${kind}-${name}-${slug}`;
867 }
868
869 // packages/views/build-module/filter-utils.mjs
870 var SCALAR_VALUES = [
871 "titleField",
872 "mediaField",
873 "descriptionField",
874 "showTitle",
875 "showMedia",
876 "showDescription",
877 "showLevels",
878 "infiniteScrollEnabled"
879 ];
880 function mergeActiveViewOverrides(view, activeViewOverrides, defaultView) {
881 if (!activeViewOverrides) {
882 return view;
883 }
884 let result = view;
885 for (const key of SCALAR_VALUES) {
886 if (key in activeViewOverrides) {
887 result = { ...result, [key]: activeViewOverrides[key] };
888 }
889 }
890 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
891 const activeFields = new Set(
892 activeViewOverrides.filters.map((f2) => f2.field)
893 );
894 const preserved = (view.filters ?? []).filter(
895 (f2) => !activeFields.has(f2.field)
896 );
897 result = {
898 ...result,
899 filters: [...preserved, ...activeViewOverrides.filters]
900 };
901 }
902 if (activeViewOverrides.sort) {
903 const isDefaultSort = defaultView && view.sort?.field === defaultView.sort?.field && view.sort?.direction === defaultView.sort?.direction;
904 if (isDefaultSort) {
905 result = {
906 ...result,
907 sort: activeViewOverrides.sort
908 };
909 }
910 }
911 if (activeViewOverrides.layout) {
912 result = {
913 ...result,
914 layout: {
915 ...result.layout,
916 ...activeViewOverrides.layout
917 }
918 };
919 }
920 if (activeViewOverrides.groupBy) {
921 result = {
922 ...result,
923 groupBy: activeViewOverrides.groupBy
924 };
925 }
926 return result;
927 }
928 function stripActiveViewOverrides(view, activeViewOverrides, defaultView) {
929 if (!activeViewOverrides) {
930 return view;
931 }
932 let result = view;
933 for (const key of SCALAR_VALUES) {
934 if (key in activeViewOverrides) {
935 const { [key]: _, ...rest } = result;
936 result = rest;
937 }
938 }
939 if (activeViewOverrides.filters && activeViewOverrides.filters.length > 0) {
940 const activeFields = new Set(
941 activeViewOverrides.filters.map((f2) => f2.field)
942 );
943 result = {
944 ...result,
945 filters: (view.filters ?? []).filter(
946 (f2) => !activeFields.has(f2.field)
947 )
948 };
949 }
950 if (activeViewOverrides.sort && view.sort?.field === activeViewOverrides.sort.field && view.sort?.direction === activeViewOverrides.sort.direction) {
951 result = {
952 ...result,
953 sort: defaultView?.sort
954 };
955 }
956 if (activeViewOverrides.layout && "layout" in result && result.layout) {
957 const layout = { ...result.layout };
958 for (const key of Object.keys(activeViewOverrides.layout)) {
959 delete layout[key];
960 }
961 result = {
962 ...result,
963 layout: Object.keys(layout).length > 0 ? layout : void 0
964 };
965 }
966 if (activeViewOverrides.groupBy && "groupBy" in result) {
967 const { groupBy: _, ...rest } = result;
968 result = rest;
969 }
970 return result;
971 }
972
973 // packages/views/build-module/use-view.mjs
974 function omit(obj, keys) {
975 const result = { ...obj };
976 for (const key of keys) {
977 delete result[key];
978 }
979 return result;
980 }
981 function useView(config) {
982 const {
983 kind,
984 name,
985 slug,
986 defaultView,
987 activeViewOverrides,
988 queryParams,
989 onChangeQueryParams
990 } = config;
991 const preferenceKey = generatePreferenceKey(kind, name, slug);
992 const persistedView = (0, import_data.useSelect)(
993 (select2) => {
994 return select2(import_preferences.store).get(
995 "core/views",
996 preferenceKey
997 );
998 },
999 [preferenceKey]
1000 );
1001 const { set: set2 } = (0, import_data.useDispatch)(import_preferences.store);
1002 const baseView = (0, import_element.useMemo)(
1003 () => persistedView ?? defaultView ?? {},
1004 [persistedView, defaultView]
1005 );
1006 const page = Number(queryParams?.page ?? baseView.page ?? 1);
1007 const search = queryParams?.search ?? baseView.search ?? "";
1008 const combinedOverrides = (0, import_element.useMemo)(() => {
1009 const rawDefaults = config.defaultLayouts?.[baseView.type];
1010 const layoutTypeDefaults = !rawDefaults || rawDefaults === true ? {} : rawDefaults;
1011 return { ...layoutTypeDefaults, ...activeViewOverrides };
1012 }, [config.defaultLayouts, baseView.type, activeViewOverrides]);
1013 const view = (0, import_element.useMemo)(() => {
1014 return mergeActiveViewOverrides(
1015 {
1016 ...baseView,
1017 page,
1018 search
1019 },
1020 combinedOverrides,
1021 defaultView
1022 );
1023 }, [baseView, page, search, combinedOverrides, defaultView]);
1024 const isModified = !!persistedView;
1025 const updateView = (0, import_element.useCallback)(
1026 (newView) => {
1027 const urlParams = {
1028 page: newView?.page,
1029 search: newView?.search
1030 };
1031 const preferenceView = stripActiveViewOverrides(
1032 omit(newView, ["page", "search"]),
1033 combinedOverrides,
1034 defaultView
1035 );
1036 if (onChangeQueryParams && !dequal(urlParams, { page, search })) {
1037 onChangeQueryParams(urlParams);
1038 }
1039 const comparableBaseView = stripActiveViewOverrides(
1040 baseView,
1041 combinedOverrides,
1042 defaultView
1043 );
1044 const comparableDefaultView = stripActiveViewOverrides(
1045 defaultView,
1046 combinedOverrides,
1047 defaultView
1048 );
1049 if (!dequal(comparableBaseView, preferenceView)) {
1050 if (dequal(preferenceView, comparableDefaultView)) {
1051 set2("core/views", preferenceKey, void 0);
1052 } else {
1053 set2("core/views", preferenceKey, preferenceView);
1054 }
1055 }
1056 },
1057 [
1058 onChangeQueryParams,
1059 page,
1060 search,
1061 baseView,
1062 defaultView,
1063 combinedOverrides,
1064 set2,
1065 preferenceKey
1066 ]
1067 );
1068 const resetToDefault = (0, import_element.useCallback)(() => {
1069 set2("core/views", preferenceKey, void 0);
1070 }, [preferenceKey, set2]);
1071 return {
1072 view,
1073 isModified,
1074 updateView,
1075 resetToDefault
1076 };
1077 }
1078
1079 // packages/views/build-module/load-view.mjs
1080 var import_data2 = __toESM(require_data(), 1);
1081 var import_preferences2 = __toESM(require_preferences(), 1);
1082
1083 // packages/views/build-module/use-view-config.mjs
1084 var import_data3 = __toESM(require_data(), 1);
1085 var import_core_data = __toESM(require_core_data(), 1);
1086
1087 // packages/views/build-module/lock-unlock.mjs
1088 var import_private_apis = __toESM(require_private_apis(), 1);
1089 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1090 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1091 "@wordpress/views"
1092 );
1093
1094 // node_modules/clsx/dist/clsx.mjs
1095 function r(e2) {
1096 var t2, f2, n2 = "";
1097 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
1098 else if ("object" == typeof e2) if (Array.isArray(e2)) {
1099 var o2 = e2.length;
1100 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
1101 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
1102 return n2;
1103 }
1104 function clsx() {
1105 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
1106 return n2;
1107 }
1108 var clsx_default = clsx;
1109
1110 // packages/dataviews/build-module/dataviews/index.mjs
1111 var import_element60 = __toESM(require_element(), 1);
1112 var import_compose12 = __toESM(require_compose(), 1);
1113
1114 // node_modules/@base-ui/utils/esm/useRefWithInit.js
1115 var React2 = __toESM(require_react(), 1);
1116 var UNINITIALIZED = {};
1117 function useRefWithInit(init2, initArg) {
1118 const ref = React2.useRef(UNINITIALIZED);
1119 if (ref.current === UNINITIALIZED) {
1120 ref.current = init2(initArg);
1121 }
1122 return ref;
1123 }
1124
1125 // node_modules/@base-ui/utils/esm/warn.js
1126 var set;
1127 if (true) {
1128 set = /* @__PURE__ */ new Set();
1129 }
1130 function warn(...messages) {
1131 if (true) {
1132 const messageKey = messages.join(" ");
1133 if (!set.has(messageKey)) {
1134 set.add(messageKey);
1135 console.warn(`Base UI: ${messageKey}`);
1136 }
1137 }
1138 }
1139
1140 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1141 var React5 = __toESM(require_react(), 1);
1142
1143 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1144 function useMergedRefs(a2, b2, c2, d2) {
1145 const forkRef = useRefWithInit(createForkRef).current;
1146 if (didChange(forkRef, a2, b2, c2, d2)) {
1147 update(forkRef, [a2, b2, c2, d2]);
1148 }
1149 return forkRef.callback;
1150 }
1151 function useMergedRefsN(refs) {
1152 const forkRef = useRefWithInit(createForkRef).current;
1153 if (didChangeN(forkRef, refs)) {
1154 update(forkRef, refs);
1155 }
1156 return forkRef.callback;
1157 }
1158 function createForkRef() {
1159 return {
1160 callback: null,
1161 cleanup: null,
1162 refs: []
1163 };
1164 }
1165 function didChange(forkRef, a2, b2, c2, d2) {
1166 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1167 }
1168 function didChangeN(forkRef, newRefs) {
1169 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1170 }
1171 function update(forkRef, refs) {
1172 forkRef.refs = refs;
1173 if (refs.every((ref) => ref == null)) {
1174 forkRef.callback = null;
1175 return;
1176 }
1177 forkRef.callback = (instance) => {
1178 if (forkRef.cleanup) {
1179 forkRef.cleanup();
1180 forkRef.cleanup = null;
1181 }
1182 if (instance != null) {
1183 const cleanupCallbacks = Array(refs.length).fill(null);
1184 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1185 const ref = refs[i2];
1186 if (ref == null) {
1187 continue;
1188 }
1189 switch (typeof ref) {
1190 case "function": {
1191 const refCleanup = ref(instance);
1192 if (typeof refCleanup === "function") {
1193 cleanupCallbacks[i2] = refCleanup;
1194 }
1195 break;
1196 }
1197 case "object": {
1198 ref.current = instance;
1199 break;
1200 }
1201 default:
1202 }
1203 }
1204 forkRef.cleanup = () => {
1205 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1206 const ref = refs[i2];
1207 if (ref == null) {
1208 continue;
1209 }
1210 switch (typeof ref) {
1211 case "function": {
1212 const cleanupCallback = cleanupCallbacks[i2];
1213 if (typeof cleanupCallback === "function") {
1214 cleanupCallback();
1215 } else {
1216 ref(null);
1217 }
1218 break;
1219 }
1220 case "object": {
1221 ref.current = null;
1222 break;
1223 }
1224 default:
1225 }
1226 }
1227 };
1228 }
1229 };
1230 }
1231
1232 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1233 var React4 = __toESM(require_react(), 1);
1234
1235 // node_modules/@base-ui/utils/esm/reactVersion.js
1236 var React3 = __toESM(require_react(), 1);
1237 var majorVersion = parseInt(React3.version, 10);
1238 function isReactVersionAtLeast(reactVersionToCheck) {
1239 return majorVersion >= reactVersionToCheck;
1240 }
1241
1242 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1243 function getReactElementRef(element) {
1244 if (!/* @__PURE__ */ React4.isValidElement(element)) {
1245 return null;
1246 }
1247 const reactElement = element;
1248 const propsWithRef = reactElement.props;
1249 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1250 }
1251
1252 // node_modules/@base-ui/utils/esm/mergeObjects.js
1253 function mergeObjects(a2, b2) {
1254 if (a2 && !b2) {
1255 return a2;
1256 }
1257 if (!a2 && b2) {
1258 return b2;
1259 }
1260 if (a2 || b2) {
1261 return {
1262 ...a2,
1263 ...b2
1264 };
1265 }
1266 return void 0;
1267 }
1268
1269 // node_modules/@base-ui/utils/esm/empty.js
1270 var EMPTY_ARRAY = Object.freeze([]);
1271 var EMPTY_OBJECT = Object.freeze({});
1272
1273 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1274 function getStateAttributesProps(state, customMapping) {
1275 const props = {};
1276 for (const key in state) {
1277 const value = state[key];
1278 if (customMapping?.hasOwnProperty(key)) {
1279 const customProps = customMapping[key](value);
1280 if (customProps != null) {
1281 Object.assign(props, customProps);
1282 }
1283 continue;
1284 }
1285 if (value === true) {
1286 props[`data-${key.toLowerCase()}`] = "";
1287 } else if (value) {
1288 props[`data-${key.toLowerCase()}`] = value.toString();
1289 }
1290 }
1291 return props;
1292 }
1293
1294 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1295 function resolveClassName(className, state) {
1296 return typeof className === "function" ? className(state) : className;
1297 }
1298
1299 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1300 function resolveStyle(style, state) {
1301 return typeof style === "function" ? style(state) : style;
1302 }
1303
1304 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1305 var EMPTY_PROPS = {};
1306 function mergeProps(a2, b2, c2, d2, e2) {
1307 if (!c2 && !d2 && !e2 && !a2) {
1308 return createInitialMergedProps(b2);
1309 }
1310 let merged = createInitialMergedProps(a2);
1311 if (b2) {
1312 merged = mergeInto(merged, b2);
1313 }
1314 if (c2) {
1315 merged = mergeInto(merged, c2);
1316 }
1317 if (d2) {
1318 merged = mergeInto(merged, d2);
1319 }
1320 if (e2) {
1321 merged = mergeInto(merged, e2);
1322 }
1323 return merged;
1324 }
1325 function mergePropsN(props) {
1326 if (props.length === 0) {
1327 return EMPTY_PROPS;
1328 }
1329 if (props.length === 1) {
1330 return createInitialMergedProps(props[0]);
1331 }
1332 let merged = createInitialMergedProps(props[0]);
1333 for (let i2 = 1; i2 < props.length; i2 += 1) {
1334 merged = mergeInto(merged, props[i2]);
1335 }
1336 return merged;
1337 }
1338 function createInitialMergedProps(inputProps) {
1339 if (isPropsGetter(inputProps)) {
1340 return {
1341 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1342 };
1343 }
1344 return copyInitialProps(inputProps);
1345 }
1346 function mergeInto(merged, inputProps) {
1347 if (isPropsGetter(inputProps)) {
1348 return resolvePropsGetter(inputProps, merged);
1349 }
1350 return mutablyMergeInto(merged, inputProps);
1351 }
1352 function copyInitialProps(inputProps) {
1353 const copiedProps = {
1354 ...inputProps
1355 };
1356 for (const propName in copiedProps) {
1357 const propValue = copiedProps[propName];
1358 if (isEventHandler(propName, propValue)) {
1359 copiedProps[propName] = wrapEventHandler(propValue);
1360 }
1361 }
1362 return copiedProps;
1363 }
1364 function mutablyMergeInto(mergedProps, externalProps) {
1365 if (!externalProps) {
1366 return mergedProps;
1367 }
1368 for (const propName in externalProps) {
1369 const externalPropValue = externalProps[propName];
1370 switch (propName) {
1371 case "style": {
1372 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1373 break;
1374 }
1375 case "className": {
1376 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1377 break;
1378 }
1379 default: {
1380 if (isEventHandler(propName, externalPropValue)) {
1381 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1382 } else {
1383 mergedProps[propName] = externalPropValue;
1384 }
1385 }
1386 }
1387 }
1388 return mergedProps;
1389 }
1390 function isEventHandler(key, value) {
1391 const code0 = key.charCodeAt(0);
1392 const code1 = key.charCodeAt(1);
1393 const code2 = key.charCodeAt(2);
1394 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1395 }
1396 function isPropsGetter(inputProps) {
1397 return typeof inputProps === "function";
1398 }
1399 function resolvePropsGetter(inputProps, previousProps) {
1400 if (isPropsGetter(inputProps)) {
1401 return inputProps(previousProps);
1402 }
1403 return inputProps ?? EMPTY_PROPS;
1404 }
1405 function mergeEventHandlers(ourHandler, theirHandler) {
1406 if (!theirHandler) {
1407 return ourHandler;
1408 }
1409 if (!ourHandler) {
1410 return wrapEventHandler(theirHandler);
1411 }
1412 return (...args) => {
1413 const event = args[0];
1414 if (isSyntheticEvent(event)) {
1415 const baseUIEvent = event;
1416 makeEventPreventable(baseUIEvent);
1417 const result2 = theirHandler(...args);
1418 if (!baseUIEvent.baseUIHandlerPrevented) {
1419 ourHandler?.(...args);
1420 }
1421 return result2;
1422 }
1423 const result = theirHandler(...args);
1424 ourHandler?.(...args);
1425 return result;
1426 };
1427 }
1428 function wrapEventHandler(handler) {
1429 if (!handler) {
1430 return handler;
1431 }
1432 return (...args) => {
1433 const event = args[0];
1434 if (isSyntheticEvent(event)) {
1435 makeEventPreventable(event);
1436 }
1437 return handler(...args);
1438 };
1439 }
1440 function makeEventPreventable(event) {
1441 event.preventBaseUIHandler = () => {
1442 event.baseUIHandlerPrevented = true;
1443 };
1444 return event;
1445 }
1446 function mergeClassNames(ourClassName, theirClassName) {
1447 if (theirClassName) {
1448 if (ourClassName) {
1449 return theirClassName + " " + ourClassName;
1450 }
1451 return theirClassName;
1452 }
1453 return ourClassName;
1454 }
1455 function isSyntheticEvent(event) {
1456 return event != null && typeof event === "object" && "nativeEvent" in event;
1457 }
1458
1459 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1460 var import_react = __toESM(require_react(), 1);
1461 function useRenderElement(element, componentProps, params = {}) {
1462 const renderProp = componentProps.render;
1463 const outProps = useRenderElementProps(componentProps, params);
1464 if (params.enabled === false) {
1465 return null;
1466 }
1467 const state = params.state ?? EMPTY_OBJECT;
1468 return evaluateRenderProp(element, renderProp, outProps, state);
1469 }
1470 function useRenderElementProps(componentProps, params = {}) {
1471 const {
1472 className: classNameProp,
1473 style: styleProp,
1474 render: renderProp
1475 } = componentProps;
1476 const {
1477 state = EMPTY_OBJECT,
1478 ref,
1479 props,
1480 stateAttributesMapping,
1481 enabled = true
1482 } = params;
1483 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1484 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1485 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1486 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1487 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1488 if (typeof document !== "undefined") {
1489 if (!enabled) {
1490 useMergedRefs(null, null);
1491 } else if (Array.isArray(ref)) {
1492 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1493 } else {
1494 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1495 }
1496 }
1497 if (!enabled) {
1498 return EMPTY_OBJECT;
1499 }
1500 if (className !== void 0) {
1501 outProps.className = mergeClassNames(outProps.className, className);
1502 }
1503 if (style !== void 0) {
1504 outProps.style = mergeObjects(outProps.style, style);
1505 }
1506 return outProps;
1507 }
1508 function resolveRenderFunctionProps(props) {
1509 if (Array.isArray(props)) {
1510 return mergePropsN(props);
1511 }
1512 return mergeProps(void 0, props);
1513 }
1514 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1515 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1516 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1517 function evaluateRenderProp(element, render4, props, state) {
1518 if (render4) {
1519 if (typeof render4 === "function") {
1520 if (true) {
1521 warnIfRenderPropLooksLikeComponent(render4);
1522 }
1523 return render4(props, state);
1524 }
1525 const mergedProps = mergeProps(props, render4.props);
1526 mergedProps.ref = props.ref;
1527 let newElement = render4;
1528 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1529 const children = React5.Children.toArray(render4);
1530 newElement = children[0];
1531 }
1532 if (true) {
1533 if (!/* @__PURE__ */ React5.isValidElement(newElement)) {
1534 throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
1535 }
1536 }
1537 return /* @__PURE__ */ React5.cloneElement(newElement, mergedProps);
1538 }
1539 if (element) {
1540 if (typeof element === "string") {
1541 return renderTag(element, props);
1542 }
1543 }
1544 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1545 }
1546 function warnIfRenderPropLooksLikeComponent(renderFn) {
1547 const functionName = renderFn.name;
1548 if (functionName.length === 0) {
1549 return;
1550 }
1551 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1552 return;
1553 }
1554 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1555 return;
1556 }
1557 warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
1558 }
1559 function renderTag(Tag, props) {
1560 if (Tag === "button") {
1561 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1562 type: "button",
1563 ...props,
1564 key: props.key
1565 });
1566 }
1567 if (Tag === "img") {
1568 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1569 alt: "",
1570 ...props,
1571 key: props.key
1572 });
1573 }
1574 return /* @__PURE__ */ React5.createElement(Tag, props);
1575 }
1576
1577 // node_modules/@base-ui/react/esm/use-render/useRender.js
1578 function useRender(params) {
1579 return useRenderElement(params.defaultTagName ?? "div", params, params);
1580 }
1581
1582 // packages/ui/build-module/text/text.mjs
1583 var import_element2 = __toESM(require_element(), 1);
1584 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='4130d64bea']")) {
1585 const style = document.createElement("style");
1586 style.setAttribute("data-wp-hash", "4130d64bea");
1587 style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}'));
1588 document.head.appendChild(style);
1589 }
1590 var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
1591 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
1592 const style = document.createElement("style");
1593 style.setAttribute("data-wp-hash", "1fb29d3a3c");
1594 style.appendChild(document.createTextNode("._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,#0000);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 #0000);color:var(--_gcd-input-color,var(--wpds-color-fg-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,#0000);border-color:var(--_gcd-input-border-color-disabled,#0000);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid #0000)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-fg-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid #0000);transition:var(--_gcd-a-transition,none)}"));
1595 document.head.appendChild(style);
1596 }
1597 var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
1598 var Text = (0, import_element2.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
1599 const element = useRender({
1600 render: render4,
1601 defaultTagName: "span",
1602 ref,
1603 props: mergeProps(props, {
1604 className: clsx_default(
1605 style_default.text,
1606 global_css_defense_default.heading,
1607 global_css_defense_default.p,
1608 style_default[variant],
1609 className
1610 )
1611 })
1612 });
1613 return element;
1614 });
1615
1616 // packages/icons/build-module/library/arrow-down.mjs
1617 var import_primitives = __toESM(require_primitives(), 1);
1618 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
1619 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" }) });
1620
1621 // packages/icons/build-module/library/arrow-left.mjs
1622 var import_primitives2 = __toESM(require_primitives(), 1);
1623 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
1624 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" }) });
1625
1626 // packages/icons/build-module/library/arrow-right.mjs
1627 var import_primitives3 = __toESM(require_primitives(), 1);
1628 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
1629 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" }) });
1630
1631 // packages/icons/build-module/library/arrow-up.mjs
1632 var import_primitives4 = __toESM(require_primitives(), 1);
1633 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
1634 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" }) });
1635
1636 // packages/icons/build-module/library/block-table.mjs
1637 var import_primitives5 = __toESM(require_primitives(), 1);
1638 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
1639 var block_table_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: "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" }) });
1640
1641 // packages/icons/build-module/library/category.mjs
1642 var import_primitives6 = __toESM(require_primitives(), 1);
1643 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
1644 var category_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, { 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" }) });
1645
1646 // packages/icons/build-module/library/check.mjs
1647 var import_primitives7 = __toESM(require_primitives(), 1);
1648 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
1649 var check_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, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
1650
1651 // packages/icons/build-module/library/close-small.mjs
1652 var import_primitives8 = __toESM(require_primitives(), 1);
1653 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
1654 var close_small_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: "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" }) });
1655
1656 // packages/icons/build-module/library/cog.mjs
1657 var import_primitives9 = __toESM(require_primitives(), 1);
1658 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
1659 var cog_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, { 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" }) });
1660
1661 // packages/icons/build-module/library/envelope.mjs
1662 var import_primitives10 = __toESM(require_primitives(), 1);
1663 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
1664 var envelope_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: "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" }) });
1665
1666 // packages/icons/build-module/library/error.mjs
1667 var import_primitives11 = __toESM(require_primitives(), 1);
1668 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
1669 var error_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: "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" }) });
1670
1671 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
1672 var import_primitives12 = __toESM(require_primitives(), 1);
1673 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
1674 var format_list_bullets_rtl_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, { 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" }) });
1675
1676 // packages/icons/build-module/library/format-list-bullets.mjs
1677 var import_primitives13 = __toESM(require_primitives(), 1);
1678 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
1679 var format_list_bullets_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, { 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" }) });
1680
1681 // packages/icons/build-module/library/funnel.mjs
1682 var import_primitives14 = __toESM(require_primitives(), 1);
1683 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
1684 var funnel_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, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
1685
1686 // packages/icons/build-module/library/link.mjs
1687 var import_primitives15 = __toESM(require_primitives(), 1);
1688 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
1689 var link_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: "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" }) });
1690
1691 // packages/icons/build-module/library/mobile.mjs
1692 var import_primitives16 = __toESM(require_primitives(), 1);
1693 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
1694 var mobile_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: "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" }) });
1695
1696 // packages/icons/build-module/library/more-vertical.mjs
1697 var import_primitives17 = __toESM(require_primitives(), 1);
1698 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
1699 var more_vertical_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: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
1700
1701 // packages/icons/build-module/library/next.mjs
1702 var import_primitives18 = __toESM(require_primitives(), 1);
1703 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
1704 var next_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: "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" }) });
1705
1706 // packages/icons/build-module/library/previous.mjs
1707 var import_primitives19 = __toESM(require_primitives(), 1);
1708 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
1709 var previous_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: "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" }) });
1710
1711 // packages/icons/build-module/library/scheduled.mjs
1712 var import_primitives20 = __toESM(require_primitives(), 1);
1713 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
1714 var scheduled_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, { 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" }) });
1715
1716 // packages/icons/build-module/library/search.mjs
1717 var import_primitives21 = __toESM(require_primitives(), 1);
1718 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
1719 var search_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 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" }) });
1720
1721 // packages/icons/build-module/library/seen.mjs
1722 var import_primitives22 = __toESM(require_primitives(), 1);
1723 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
1724 var seen_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: "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" }) });
1725
1726 // packages/icons/build-module/library/unseen.mjs
1727 var import_primitives23 = __toESM(require_primitives(), 1);
1728 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
1729 var unseen_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: "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" }) });
1730
1731 // packages/ui/build-module/stack/stack.mjs
1732 var import_element3 = __toESM(require_element(), 1);
1733 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
1734 const style = document.createElement("style");
1735 style.setAttribute("data-wp-hash", "b51ff41489");
1736 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}}"));
1737 document.head.appendChild(style);
1738 }
1739 var style_default2 = { "stack": "_19ce0419607e1896__stack" };
1740 var gapTokens = {
1741 xs: "var(--wpds-dimension-gap-xs, 4px)",
1742 sm: "var(--wpds-dimension-gap-sm, 8px)",
1743 md: "var(--wpds-dimension-gap-md, 12px)",
1744 lg: "var(--wpds-dimension-gap-lg, 16px)",
1745 xl: "var(--wpds-dimension-gap-xl, 24px)",
1746 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
1747 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
1748 };
1749 var Stack = (0, import_element3.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
1750 const style = {
1751 gap: gap && gapTokens[gap],
1752 alignItems: align,
1753 justifyContent: justify,
1754 flexDirection: direction,
1755 flexWrap: wrap
1756 };
1757 const element = useRender({
1758 render: render4,
1759 ref,
1760 props: mergeProps(props, { style, className: style_default2.stack })
1761 });
1762 return element;
1763 });
1764
1765 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
1766 var import_element4 = __toESM(require_element(), 1);
1767 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c46e8cb841']")) {
1768 const style = document.createElement("style");
1769 style.setAttribute("data-wp-hash", "c46e8cb841");
1770 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}"));
1771 document.head.appendChild(style);
1772 }
1773 var style_default3 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
1774 var VisuallyHidden = (0, import_element4.forwardRef)(
1775 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
1776 const element = useRender({
1777 render: render4,
1778 ref,
1779 props: mergeProps(
1780 { className: style_default3["visually-hidden"] },
1781 restProps,
1782 {
1783 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
1784 "data-visually-hidden": ""
1785 }
1786 )
1787 });
1788 return element;
1789 }
1790 );
1791
1792 // packages/dataviews/build-module/components/dataviews-context/index.mjs
1793 var import_element5 = __toESM(require_element(), 1);
1794
1795 // packages/dataviews/build-module/constants.mjs
1796 var import_i18n = __toESM(require_i18n(), 1);
1797 var OPERATOR_IS_ANY = "isAny";
1798 var OPERATOR_IS_NONE = "isNone";
1799 var OPERATOR_IS_ALL = "isAll";
1800 var OPERATOR_IS_NOT_ALL = "isNotAll";
1801 var OPERATOR_BETWEEN = "between";
1802 var OPERATOR_IN_THE_PAST = "inThePast";
1803 var OPERATOR_OVER = "over";
1804 var OPERATOR_IS = "is";
1805 var OPERATOR_IS_NOT = "isNot";
1806 var OPERATOR_LESS_THAN = "lessThan";
1807 var OPERATOR_GREATER_THAN = "greaterThan";
1808 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
1809 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
1810 var OPERATOR_BEFORE = "before";
1811 var OPERATOR_AFTER = "after";
1812 var OPERATOR_BEFORE_INC = "beforeInc";
1813 var OPERATOR_AFTER_INC = "afterInc";
1814 var OPERATOR_CONTAINS = "contains";
1815 var OPERATOR_NOT_CONTAINS = "notContains";
1816 var OPERATOR_STARTS_WITH = "startsWith";
1817 var OPERATOR_ON = "on";
1818 var OPERATOR_NOT_ON = "notOn";
1819 var SORTING_DIRECTIONS = ["asc", "desc"];
1820 var sortArrows = { asc: "\u2191", desc: "\u2193" };
1821 var sortValues = { asc: "ascending", desc: "descending" };
1822 var sortLabels = {
1823 asc: (0, import_i18n.__)("Sort ascending"),
1824 desc: (0, import_i18n.__)("Sort descending")
1825 };
1826 var sortIcons = {
1827 asc: arrow_up_default,
1828 desc: arrow_down_default
1829 };
1830 var LAYOUT_TABLE = "table";
1831 var LAYOUT_GRID = "grid";
1832 var LAYOUT_LIST = "list";
1833 var LAYOUT_ACTIVITY = "activity";
1834 var LAYOUT_PICKER_GRID = "pickerGrid";
1835 var LAYOUT_PICKER_TABLE = "pickerTable";
1836
1837 // packages/dataviews/build-module/components/dataviews-context/index.mjs
1838 var DataViewsContext = (0, import_element5.createContext)({
1839 view: { type: LAYOUT_TABLE },
1840 onChangeView: () => {
1841 },
1842 fields: [],
1843 data: [],
1844 paginationInfo: {
1845 totalItems: 0,
1846 totalPages: 0
1847 },
1848 selection: [],
1849 onChangeSelection: () => {
1850 },
1851 setOpenedFilter: () => {
1852 },
1853 openedFilter: null,
1854 getItemId: (item) => item.id,
1855 isItemClickable: () => true,
1856 renderItemLink: void 0,
1857 containerWidth: 0,
1858 containerRef: (0, import_element5.createRef)(),
1859 resizeObserverRef: () => {
1860 },
1861 defaultLayouts: { list: {}, grid: {}, table: {} },
1862 filters: [],
1863 isShowingFilter: false,
1864 setIsShowingFilter: () => {
1865 },
1866 hasInitiallyLoaded: false,
1867 config: {
1868 perPageSizes: []
1869 },
1870 intersectionObserver: null
1871 });
1872 DataViewsContext.displayName = "DataViewsContext";
1873 var dataviews_context_default = DataViewsContext;
1874
1875 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
1876 var import_i18n21 = __toESM(require_i18n(), 1);
1877
1878 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
1879 var import_i18n9 = __toESM(require_i18n(), 1);
1880 var import_components6 = __toESM(require_components(), 1);
1881 var import_element13 = __toESM(require_element(), 1);
1882 var import_keycodes = __toESM(require_keycodes(), 1);
1883
1884 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
1885 var import_components = __toESM(require_components(), 1);
1886 var import_i18n2 = __toESM(require_i18n(), 1);
1887 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
1888 function DataViewsSelectionCheckbox({
1889 selection,
1890 onChangeSelection,
1891 item,
1892 getItemId,
1893 titleField,
1894 disabled,
1895 ...extraProps
1896 }) {
1897 const id = getItemId(item);
1898 const isInSelectionArray = selection.includes(id);
1899 const checked = !disabled && isInSelectionArray;
1900 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
1901 return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1902 import_components.CheckboxControl,
1903 {
1904 className: "dataviews-selection-checkbox",
1905 "aria-label": selectionLabel,
1906 "aria-disabled": disabled,
1907 checked,
1908 onChange: () => {
1909 if (disabled) {
1910 return;
1911 }
1912 onChangeSelection(
1913 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
1914 );
1915 },
1916 ...extraProps
1917 }
1918 );
1919 }
1920
1921 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
1922 var import_components2 = __toESM(require_components(), 1);
1923 var import_i18n3 = __toESM(require_i18n(), 1);
1924 var import_element6 = __toESM(require_element(), 1);
1925 var import_data4 = __toESM(require_data(), 1);
1926 var import_compose = __toESM(require_compose(), 1);
1927
1928 // packages/dataviews/build-module/lock-unlock.mjs
1929 var import_private_apis2 = __toESM(require_private_apis(), 1);
1930 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
1931 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
1932 "@wordpress/dataviews"
1933 );
1934
1935 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
1936 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
1937 var { Menu, kebabCase } = unlock2(import_components2.privateApis);
1938 function ButtonTrigger({
1939 action,
1940 onClick,
1941 items,
1942 variant
1943 }) {
1944 const label = typeof action.label === "string" ? action.label : action.label(items);
1945 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1946 import_components2.Button,
1947 {
1948 disabled: !!action.disabled,
1949 accessibleWhenDisabled: true,
1950 size: "compact",
1951 variant,
1952 onClick,
1953 children: label
1954 }
1955 );
1956 }
1957 function MenuItemTrigger({
1958 action,
1959 onClick,
1960 items
1961 }) {
1962 const label = typeof action.label === "string" ? action.label : action.label(items);
1963 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.ItemLabel, { children: label }) });
1964 }
1965 function ActionModal({
1966 action,
1967 items,
1968 closeModal
1969 }) {
1970 const label = typeof action.label === "string" ? action.label : action.label(items);
1971 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
1972 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1973 import_components2.Modal,
1974 {
1975 title: modalHeader || label,
1976 __experimentalHideHeader: !!action.hideModalHeader,
1977 onRequestClose: closeModal,
1978 focusOnMount: action.modalFocusOnMount ?? true,
1979 size: action.modalSize || "medium",
1980 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
1981 action.id
1982 )}`,
1983 children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(action.RenderModal, { items, closeModal })
1984 }
1985 );
1986 }
1987 function ActionsMenuGroup({
1988 actions,
1989 item,
1990 registry,
1991 setActiveModalAction
1992 }) {
1993 const { primaryActions, regularActions } = (0, import_element6.useMemo)(() => {
1994 return actions.reduce(
1995 (acc, action) => {
1996 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
1997 return acc;
1998 },
1999 {
2000 primaryActions: [],
2001 regularActions: []
2002 }
2003 );
2004 }, [actions]);
2005 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2006 MenuItemTrigger,
2007 {
2008 action,
2009 onClick: () => {
2010 if ("RenderModal" in action) {
2011 setActiveModalAction(action);
2012 return;
2013 }
2014 action.callback([item], { registry });
2015 },
2016 items: [item]
2017 },
2018 action.id
2019 ));
2020 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Menu.Group, { children: [
2021 renderActionGroup(primaryActions),
2022 renderActionGroup(regularActions)
2023 ] });
2024 }
2025 function ItemActions({
2026 item,
2027 actions,
2028 isCompact
2029 }) {
2030 const registry = (0, import_data4.useRegistry)();
2031 const { primaryActions, eligibleActions } = (0, import_element6.useMemo)(() => {
2032 const _eligibleActions = actions.filter(
2033 (action) => !action.isEligible || action.isEligible(item)
2034 );
2035 const _primaryActions = _eligibleActions.filter(
2036 (action) => action.isPrimary
2037 );
2038 return {
2039 primaryActions: _primaryActions,
2040 eligibleActions: _eligibleActions
2041 };
2042 }, [actions, item]);
2043 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2044 if (isCompact) {
2045 return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2046 CompactItemActions,
2047 {
2048 item,
2049 actions: eligibleActions,
2050 isSmall: true,
2051 registry
2052 }
2053 );
2054 }
2055 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
2056 Stack,
2057 {
2058 direction: "row",
2059 justify: "flex-end",
2060 className: "dataviews-item-actions",
2061 style: {
2062 flexShrink: 0,
2063 width: "auto"
2064 },
2065 children: [
2066 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2067 PrimaryActions,
2068 {
2069 item,
2070 actions: primaryActions,
2071 registry
2072 }
2073 ),
2074 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
2075 // there if there are any actions at all.
2076 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2077 CompactItemActions,
2078 {
2079 item,
2080 actions: eligibleActions,
2081 registry
2082 }
2083 )
2084 ]
2085 }
2086 );
2087 }
2088 function CompactItemActions({
2089 item,
2090 actions,
2091 isSmall,
2092 registry
2093 }) {
2094 const [activeModalAction, setActiveModalAction] = (0, import_element6.useState)(
2095 null
2096 );
2097 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2098 /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(Menu, { placement: "bottom-end", children: [
2099 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2100 Menu.TriggerButton,
2101 {
2102 render: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2103 import_components2.Button,
2104 {
2105 size: isSmall ? "small" : "compact",
2106 icon: more_vertical_default,
2107 label: (0, import_i18n3.__)("Actions"),
2108 accessibleWhenDisabled: true,
2109 disabled: !actions.length,
2110 className: "dataviews-all-actions-button"
2111 }
2112 )
2113 }
2114 ),
2115 /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2116 ActionsMenuGroup,
2117 {
2118 actions,
2119 item,
2120 registry,
2121 setActiveModalAction
2122 }
2123 ) })
2124 ] }),
2125 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2126 ActionModal,
2127 {
2128 action: activeModalAction,
2129 items: [item],
2130 closeModal: () => setActiveModalAction(null)
2131 }
2132 )
2133 ] });
2134 }
2135 function PrimaryActions({
2136 item,
2137 actions,
2138 registry,
2139 buttonVariant
2140 }) {
2141 const [activeModalAction, setActiveModalAction] = (0, import_element6.useState)(null);
2142 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
2143 if (isMobileViewport) {
2144 return null;
2145 }
2146 if (!Array.isArray(actions) || actions.length === 0) {
2147 return null;
2148 }
2149 return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(import_jsx_runtime25.Fragment, { children: [
2150 actions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2151 ButtonTrigger,
2152 {
2153 action,
2154 onClick: () => {
2155 if ("RenderModal" in action) {
2156 setActiveModalAction(action);
2157 return;
2158 }
2159 action.callback([item], { registry });
2160 },
2161 items: [item],
2162 variant: buttonVariant
2163 },
2164 action.id
2165 )),
2166 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
2167 ActionModal,
2168 {
2169 action: activeModalAction,
2170 items: [item],
2171 closeModal: () => setActiveModalAction(null)
2172 }
2173 )
2174 ] });
2175 }
2176
2177 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2178 var import_components3 = __toESM(require_components(), 1);
2179 var import_i18n5 = __toESM(require_i18n(), 1);
2180 var import_element7 = __toESM(require_element(), 1);
2181 var import_data5 = __toESM(require_data(), 1);
2182 var import_compose2 = __toESM(require_compose(), 1);
2183
2184 // packages/dataviews/build-module/utils/get-footer-message.mjs
2185 var import_i18n4 = __toESM(require_i18n(), 1);
2186 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
2187 if (selectionCount > 0) {
2188 return (0, import_i18n4.sprintf)(
2189 /* translators: %d: number of items. */
2190 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
2191 selectionCount
2192 );
2193 }
2194 if (onlyTotalCount || totalItems <= itemsCount) {
2195 return (0, import_i18n4.sprintf)(
2196 /* translators: %d: number of items. */
2197 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
2198 totalItems
2199 );
2200 }
2201 return (0, import_i18n4.sprintf)(
2202 /* translators: %1$d: number of items. %2$d: total number of items. */
2203 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
2204 itemsCount,
2205 totalItems
2206 );
2207 }
2208
2209 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
2210 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
2211 function ActionWithModal({
2212 action,
2213 items,
2214 ActionTriggerComponent
2215 }) {
2216 const [isModalOpen, setIsModalOpen] = (0, import_element7.useState)(false);
2217 const actionTriggerProps = {
2218 action,
2219 onClick: () => {
2220 setIsModalOpen(true);
2221 },
2222 items
2223 };
2224 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
2225 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
2226 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2227 ActionModal,
2228 {
2229 action,
2230 items,
2231 closeModal: () => setIsModalOpen(false)
2232 }
2233 )
2234 ] });
2235 }
2236 function useHasAPossibleBulkAction(actions, item) {
2237 return (0, import_element7.useMemo)(() => {
2238 return actions.some((action) => {
2239 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2240 });
2241 }, [actions, item]);
2242 }
2243 function useSomeItemHasAPossibleBulkAction(actions, data) {
2244 return (0, import_element7.useMemo)(() => {
2245 return data.some((item) => {
2246 return actions.some((action) => {
2247 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
2248 });
2249 });
2250 }, [actions, data]);
2251 }
2252 function BulkSelectionCheckbox({
2253 selection,
2254 onChangeSelection,
2255 data,
2256 actions,
2257 getItemId,
2258 disableSelectAll = false
2259 }) {
2260 const selectableItems = (0, import_element7.useMemo)(() => {
2261 return data.filter((item) => {
2262 return actions.some(
2263 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
2264 );
2265 });
2266 }, [data, actions]);
2267 const selectedItems = data.filter(
2268 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2269 );
2270 const hasSelection = selection.length > 0;
2271 const areAllSelected = selectedItems.length === selectableItems.length;
2272 if (disableSelectAll) {
2273 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2274 import_components3.CheckboxControl,
2275 {
2276 className: "dataviews-view-table-selection-checkbox",
2277 checked: hasSelection,
2278 disabled: !hasSelection,
2279 onChange: () => {
2280 onChangeSelection([]);
2281 },
2282 "aria-label": (0, import_i18n5.__)("Deselect all")
2283 }
2284 );
2285 }
2286 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2287 import_components3.CheckboxControl,
2288 {
2289 className: "dataviews-view-table-selection-checkbox",
2290 checked: areAllSelected,
2291 indeterminate: !areAllSelected && !!selectedItems.length,
2292 onChange: () => {
2293 if (areAllSelected) {
2294 onChangeSelection([]);
2295 } else {
2296 onChangeSelection(
2297 selectableItems.map((item) => getItemId(item))
2298 );
2299 }
2300 },
2301 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
2302 }
2303 );
2304 }
2305 function ActionTrigger({
2306 action,
2307 onClick,
2308 isBusy,
2309 items
2310 }) {
2311 const label = typeof action.label === "string" ? action.label : action.label(items);
2312 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
2313 if (isMobile) {
2314 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2315 import_components3.Button,
2316 {
2317 disabled: isBusy,
2318 accessibleWhenDisabled: true,
2319 label,
2320 icon: action.icon,
2321 size: "compact",
2322 onClick,
2323 isBusy
2324 }
2325 );
2326 }
2327 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2328 import_components3.Button,
2329 {
2330 disabled: isBusy,
2331 accessibleWhenDisabled: true,
2332 size: "compact",
2333 onClick,
2334 isBusy,
2335 children: label
2336 }
2337 );
2338 }
2339 var EMPTY_ARRAY2 = [];
2340 function ActionButton({
2341 action,
2342 selectedItems,
2343 actionInProgress,
2344 setActionInProgress
2345 }) {
2346 const registry = (0, import_data5.useRegistry)();
2347 const selectedEligibleItems = (0, import_element7.useMemo)(() => {
2348 return selectedItems.filter((item) => {
2349 return !action.isEligible || action.isEligible(item);
2350 });
2351 }, [action, selectedItems]);
2352 if ("RenderModal" in action) {
2353 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2354 ActionWithModal,
2355 {
2356 action,
2357 items: selectedEligibleItems,
2358 ActionTriggerComponent: ActionTrigger
2359 },
2360 action.id
2361 );
2362 }
2363 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2364 ActionTrigger,
2365 {
2366 action,
2367 onClick: async () => {
2368 setActionInProgress(action.id);
2369 await action.callback(selectedItems, {
2370 registry
2371 });
2372 setActionInProgress(null);
2373 },
2374 items: selectedEligibleItems,
2375 isBusy: actionInProgress === action.id
2376 },
2377 action.id
2378 );
2379 }
2380 function renderFooterContent(data, actions, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
2381 const message2 = getFooterMessage(
2382 selection.length,
2383 data.length,
2384 paginationInfo.totalItems,
2385 isInfiniteScroll
2386 );
2387 return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
2388 Stack,
2389 {
2390 direction: "row",
2391 className: "dataviews-bulk-actions-footer__container",
2392 gap: "md",
2393 align: "center",
2394 children: [
2395 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2396 BulkSelectionCheckbox,
2397 {
2398 selection,
2399 onChangeSelection,
2400 data,
2401 actions,
2402 getItemId,
2403 disableSelectAll: isInfiniteScroll
2404 }
2405 ),
2406 /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
2407 /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
2408 Stack,
2409 {
2410 direction: "row",
2411 className: "dataviews-bulk-actions-footer__action-buttons",
2412 gap: "xs",
2413 children: [
2414 actionsToShow.map((action) => {
2415 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2416 ActionButton,
2417 {
2418 action,
2419 selectedItems,
2420 actionInProgress,
2421 setActionInProgress
2422 },
2423 action.id
2424 );
2425 }),
2426 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2427 import_components3.Button,
2428 {
2429 icon: close_small_default,
2430 showTooltip: true,
2431 tooltipPosition: "top",
2432 size: "compact",
2433 label: (0, import_i18n5.__)("Cancel"),
2434 disabled: !!actionInProgress,
2435 accessibleWhenDisabled: false,
2436 onClick: () => {
2437 onChangeSelection(EMPTY_ARRAY2);
2438 }
2439 }
2440 )
2441 ]
2442 }
2443 )
2444 ]
2445 }
2446 );
2447 }
2448 function FooterContent({
2449 selection,
2450 actions,
2451 onChangeSelection,
2452 data,
2453 getItemId,
2454 isInfiniteScroll,
2455 paginationInfo
2456 }) {
2457 const [actionInProgress, setActionInProgress] = (0, import_element7.useState)(
2458 null
2459 );
2460 const footerContentRef = (0, import_element7.useRef)(void 0);
2461 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
2462 const bulkActions = (0, import_element7.useMemo)(
2463 () => actions.filter((action) => action.supportsBulk),
2464 [actions]
2465 );
2466 const selectableItems = (0, import_element7.useMemo)(() => {
2467 return data.filter((item) => {
2468 return bulkActions.some(
2469 (action) => !action.isEligible || action.isEligible(item)
2470 );
2471 });
2472 }, [data, bulkActions]);
2473 const selectedItems = (0, import_element7.useMemo)(() => {
2474 return data.filter(
2475 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
2476 );
2477 }, [selection, data, getItemId, selectableItems]);
2478 const actionsToShow = (0, import_element7.useMemo)(
2479 () => actions.filter((action) => {
2480 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
2481 (item) => !action.isEligible || action.isEligible(item)
2482 );
2483 }),
2484 [actions, selectedItems, isMobile]
2485 );
2486 if (!actionInProgress) {
2487 if (footerContentRef.current) {
2488 footerContentRef.current = void 0;
2489 }
2490 return renderFooterContent(
2491 data,
2492 actions,
2493 getItemId,
2494 isInfiniteScroll,
2495 selection,
2496 actionsToShow,
2497 selectedItems,
2498 actionInProgress,
2499 setActionInProgress,
2500 onChangeSelection,
2501 paginationInfo
2502 );
2503 } else if (!footerContentRef.current) {
2504 footerContentRef.current = renderFooterContent(
2505 data,
2506 actions,
2507 getItemId,
2508 isInfiniteScroll,
2509 selection,
2510 actionsToShow,
2511 selectedItems,
2512 actionInProgress,
2513 setActionInProgress,
2514 onChangeSelection,
2515 paginationInfo
2516 );
2517 }
2518 return footerContentRef.current;
2519 }
2520 function BulkActionsFooter() {
2521 const {
2522 data,
2523 selection,
2524 actions = EMPTY_ARRAY2,
2525 onChangeSelection,
2526 getItemId,
2527 paginationInfo,
2528 view
2529 } = (0, import_element7.useContext)(dataviews_context_default);
2530 return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
2531 FooterContent,
2532 {
2533 selection,
2534 onChangeSelection,
2535 data,
2536 actions,
2537 getItemId,
2538 isInfiniteScroll: !!view.infiniteScrollEnabled,
2539 paginationInfo
2540 }
2541 );
2542 }
2543
2544 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2545 var import_i18n6 = __toESM(require_i18n(), 1);
2546 var import_components4 = __toESM(require_components(), 1);
2547 var import_element8 = __toESM(require_element(), 1);
2548
2549 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
2550 function getHideableFields(view, fields) {
2551 const togglableFields = [
2552 view?.titleField,
2553 view?.mediaField,
2554 view?.descriptionField
2555 ].filter(Boolean);
2556 return fields.filter(
2557 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
2558 );
2559 }
2560
2561 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
2562 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
2563 var { Menu: Menu2 } = unlock2(import_components4.privateApis);
2564 function WithMenuSeparators({ children }) {
2565 return import_element8.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_element8.Fragment, { children: [
2566 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Separator, {}),
2567 child
2568 ] }, i2));
2569 }
2570 var _HeaderMenu = (0, import_element8.forwardRef)(function HeaderMenu({
2571 fieldId,
2572 view,
2573 fields,
2574 onChangeView,
2575 onHide,
2576 setOpenedFilter,
2577 canMove = true,
2578 canInsertLeft = true,
2579 canInsertRight = true
2580 }, ref) {
2581 const visibleFieldIds = view.fields ?? [];
2582 const index = visibleFieldIds?.indexOf(fieldId);
2583 const isSorted = view.sort?.field === fieldId;
2584 let isHidable = false;
2585 let isSortable = false;
2586 let canAddFilter = false;
2587 let operators = [];
2588 const field = fields.find((f2) => f2.id === fieldId);
2589 const { setIsShowingFilter } = (0, import_element8.useContext)(dataviews_context_default);
2590 if (!field) {
2591 return null;
2592 }
2593 isHidable = field.enableHiding !== false;
2594 isSortable = field.enableSorting !== false;
2595 const header = field.header;
2596 operators = !!field.filterBy && field.filterBy?.operators || [];
2597 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
2598 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
2599 return header;
2600 }
2601 const hiddenFields = getHideableFields(view, fields).filter(
2602 (f2) => !visibleFieldIds.includes(f2.id)
2603 );
2604 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
2605 const isRtl = (0, import_i18n6.isRTL)();
2606 return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2607 /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
2608 Menu2.TriggerButton,
2609 {
2610 render: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2611 import_components4.Button,
2612 {
2613 size: "compact",
2614 className: "dataviews-view-table-header-button",
2615 ref,
2616 variant: "tertiary"
2617 }
2618 ),
2619 children: [
2620 header,
2621 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
2622 ]
2623 }
2624 ),
2625 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(WithMenuSeparators, { children: [
2626 isSortable && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
2627 (direction) => {
2628 const isChecked = view.sort && isSorted && view.sort.direction === direction;
2629 const value = `${fieldId}-${direction}`;
2630 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2631 Menu2.RadioItem,
2632 {
2633 name: "view-table-sorting",
2634 value,
2635 checked: isChecked,
2636 onChange: () => {
2637 onChangeView({
2638 ...view,
2639 sort: {
2640 field: fieldId,
2641 direction
2642 },
2643 showLevels: false
2644 });
2645 },
2646 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
2647 },
2648 value
2649 );
2650 }
2651 ) }),
2652 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2653 Menu2.Item,
2654 {
2655 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: funnel_default }),
2656 onClick: () => {
2657 setOpenedFilter(fieldId);
2658 setIsShowingFilter(true);
2659 onChangeView({
2660 ...view,
2661 page: 1,
2662 filters: [
2663 ...view.filters || [],
2664 {
2665 field: fieldId,
2666 value: void 0,
2667 operator: operators[0]
2668 }
2669 ]
2670 });
2671 },
2672 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
2673 }
2674 ) }),
2675 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2.Group, { children: [
2676 canMove && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2677 Menu2.Item,
2678 {
2679 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: arrow_left_default }),
2680 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
2681 onClick: () => {
2682 const targetIndex = isRtl ? index + 1 : index - 1;
2683 const newFields = [
2684 ...visibleFieldIds
2685 ];
2686 newFields.splice(index, 1);
2687 newFields.splice(
2688 targetIndex,
2689 0,
2690 fieldId
2691 );
2692 onChangeView({
2693 ...view,
2694 fields: newFields
2695 });
2696 },
2697 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
2698 }
2699 ),
2700 canMove && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2701 Menu2.Item,
2702 {
2703 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: arrow_right_default }),
2704 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
2705 onClick: () => {
2706 const targetIndex = isRtl ? index - 1 : index + 1;
2707 const newFields = [
2708 ...visibleFieldIds
2709 ];
2710 newFields.splice(index, 1);
2711 newFields.splice(
2712 targetIndex,
2713 0,
2714 fieldId
2715 );
2716 onChangeView({
2717 ...view,
2718 fields: newFields
2719 });
2720 },
2721 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
2722 }
2723 ),
2724 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2725 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
2726 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2727 const insertIndex = isRtl ? index + 1 : index;
2728 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2729 Menu2.Item,
2730 {
2731 onClick: () => {
2732 onChangeView({
2733 ...view,
2734 fields: [
2735 ...visibleFieldIds.slice(
2736 0,
2737 insertIndex
2738 ),
2739 hiddenField.id,
2740 ...visibleFieldIds.slice(
2741 insertIndex
2742 )
2743 ]
2744 });
2745 },
2746 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2747 },
2748 hiddenField.id
2749 );
2750 }) })
2751 ] }),
2752 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(Menu2, { children: [
2753 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
2754 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
2755 const insertIndex = isRtl ? index : index + 1;
2756 return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2757 Menu2.Item,
2758 {
2759 onClick: () => {
2760 onChangeView({
2761 ...view,
2762 fields: [
2763 ...visibleFieldIds.slice(
2764 0,
2765 insertIndex
2766 ),
2767 hiddenField.id,
2768 ...visibleFieldIds.slice(
2769 insertIndex
2770 )
2771 ]
2772 });
2773 },
2774 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
2775 },
2776 hiddenField.id
2777 );
2778 }) })
2779 ] }),
2780 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2781 Menu2.Item,
2782 {
2783 prefix: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components4.Icon, { icon: unseen_default }),
2784 onClick: () => {
2785 onHide(field);
2786 onChangeView({
2787 ...view,
2788 fields: visibleFieldIds.filter(
2789 (id) => id !== fieldId
2790 )
2791 });
2792 },
2793 children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
2794 }
2795 )
2796 ] })
2797 ] }) })
2798 ] });
2799 });
2800 var ColumnHeaderMenu = _HeaderMenu;
2801 var column_header_menu_default = ColumnHeaderMenu;
2802
2803 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
2804 var import_element9 = __toESM(require_element(), 1);
2805 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
2806 function getClickableItemProps({
2807 item,
2808 isItemClickable,
2809 onClickItem,
2810 className
2811 }) {
2812 if (!isItemClickable(item) || !onClickItem) {
2813 return { className };
2814 }
2815 return {
2816 className: className ? `${className} ${className}--clickable` : void 0,
2817 role: "button",
2818 tabIndex: 0,
2819 onClick: (event) => {
2820 event.stopPropagation();
2821 onClickItem(item);
2822 },
2823 onKeyDown: (event) => {
2824 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2825 event.stopPropagation();
2826 onClickItem(item);
2827 }
2828 }
2829 };
2830 }
2831 function ItemClickWrapper({
2832 item,
2833 isItemClickable,
2834 onClickItem,
2835 renderItemLink,
2836 className,
2837 children,
2838 ...extraProps
2839 }) {
2840 if (!isItemClickable(item)) {
2841 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className, ...extraProps, children });
2842 }
2843 if (renderItemLink) {
2844 const renderedElement = renderItemLink({
2845 item,
2846 className: `${className} ${className}--clickable`,
2847 ...extraProps,
2848 children
2849 });
2850 return (0, import_element9.cloneElement)(renderedElement, {
2851 onClick: (event) => {
2852 event.stopPropagation();
2853 if (renderedElement.props.onClick) {
2854 renderedElement.props.onClick(event);
2855 }
2856 },
2857 onKeyDown: (event) => {
2858 if (event.key === "Enter" || event.key === "" || event.key === " ") {
2859 event.stopPropagation();
2860 if (renderedElement.props.onKeyDown) {
2861 renderedElement.props.onKeyDown(event);
2862 }
2863 }
2864 }
2865 });
2866 }
2867 const clickProps = getClickableItemProps({
2868 item,
2869 isItemClickable,
2870 onClickItem,
2871 className
2872 });
2873 return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { ...clickProps, ...extraProps, children });
2874 }
2875
2876 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
2877 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
2878 function ColumnPrimary({
2879 item,
2880 level,
2881 titleField,
2882 mediaField,
2883 descriptionField,
2884 onClickItem,
2885 renderItemLink,
2886 isItemClickable
2887 }) {
2888 return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
2889 mediaField && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2890 ItemClickWrapper,
2891 {
2892 item,
2893 isItemClickable,
2894 onClickItem,
2895 renderItemLink,
2896 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
2897 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
2898 children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2899 mediaField.render,
2900 {
2901 item,
2902 field: mediaField,
2903 config: { sizes: "32px" }
2904 }
2905 )
2906 }
2907 ),
2908 /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2909 Stack,
2910 {
2911 direction: "column",
2912 align: "flex-start",
2913 className: "dataviews-view-table__primary-column-content",
2914 children: [
2915 titleField && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
2916 ItemClickWrapper,
2917 {
2918 item,
2919 isItemClickable,
2920 onClickItem,
2921 renderItemLink,
2922 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
2923 children: [
2924 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("span", { className: "dataviews-view-table__level", children: [
2925 Array(level).fill("\u2014").join(" "),
2926 "\xA0"
2927 ] }),
2928 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(titleField.render, { item, field: titleField })
2929 ]
2930 }
2931 ),
2932 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
2933 descriptionField.render,
2934 {
2935 item,
2936 field: descriptionField
2937 }
2938 )
2939 ]
2940 }
2941 )
2942 ] });
2943 }
2944 var column_primary_default = ColumnPrimary;
2945
2946 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
2947 var import_element10 = __toESM(require_element(), 1);
2948 var import_i18n7 = __toESM(require_i18n(), 1);
2949 var isScrolledToEnd = (element) => {
2950 if ((0, import_i18n7.isRTL)()) {
2951 const scrollLeft = Math.abs(element.scrollLeft);
2952 return scrollLeft <= 1;
2953 }
2954 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
2955 };
2956 function useScrollState({
2957 scrollContainerRef,
2958 enabledHorizontal = false
2959 }) {
2960 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element10.useState)(false);
2961 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element10.useState)(false);
2962 const handleScroll = (0, import_element10.useCallback)(() => {
2963 const scrollContainer = scrollContainerRef.current;
2964 if (!scrollContainer) {
2965 return;
2966 }
2967 if (enabledHorizontal) {
2968 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
2969 }
2970 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
2971 }, [scrollContainerRef, enabledHorizontal]);
2972 (0, import_element10.useEffect)(() => {
2973 if (typeof window === "undefined" || !scrollContainerRef.current) {
2974 return () => {
2975 };
2976 }
2977 const scrollContainer = scrollContainerRef.current;
2978 handleScroll();
2979 scrollContainer.addEventListener("scroll", handleScroll);
2980 window.addEventListener("resize", handleScroll);
2981 return () => {
2982 scrollContainer.removeEventListener("scroll", handleScroll);
2983 window.removeEventListener("resize", handleScroll);
2984 };
2985 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
2986 return { isHorizontalScrollEnd, isVerticallyScrolled };
2987 }
2988
2989 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
2990 function getDataByGroup(data, groupByField) {
2991 return data.reduce((groups, item) => {
2992 const groupName = groupByField.getValue({ item });
2993 if (!groups.has(groupName)) {
2994 groups.set(groupName, []);
2995 }
2996 groups.get(groupName)?.push(item);
2997 return groups;
2998 }, /* @__PURE__ */ new Map());
2999 }
3000
3001 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
3002 var import_components5 = __toESM(require_components(), 1);
3003 var import_i18n8 = __toESM(require_i18n(), 1);
3004 var import_element11 = __toESM(require_element(), 1);
3005 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3006 function FieldItem({
3007 field,
3008 isVisible: isVisible2,
3009 onToggleVisibility
3010 }) {
3011 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
3012 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.Icon, { icon: check_default }) }),
3013 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
3014 ] }) });
3015 }
3016 function isDefined(item) {
3017 return !!item;
3018 }
3019 function PropertiesSection({
3020 showLabel = true
3021 }) {
3022 const { view, fields, onChangeView } = (0, import_element11.useContext)(dataviews_context_default);
3023 const regularFields = getHideableFields(view, fields);
3024 if (!regularFields?.length) {
3025 return null;
3026 }
3027 const titleField = fields.find((f2) => f2.id === view.titleField);
3028 const previewField2 = fields.find((f2) => f2.id === view.mediaField);
3029 const descriptionField = fields.find(
3030 (f2) => f2.id === view.descriptionField
3031 );
3032 const lockedFields = [
3033 {
3034 field: titleField,
3035 isVisibleFlag: "showTitle"
3036 },
3037 {
3038 field: previewField2,
3039 isVisibleFlag: "showMedia"
3040 },
3041 {
3042 field: descriptionField,
3043 isVisibleFlag: "showDescription"
3044 }
3045 ].filter(({ field }) => isDefined(field));
3046 const visibleFieldIds = view.fields ?? [];
3047 const visibleRegularFieldsCount = regularFields.filter(
3048 (f2) => visibleFieldIds.includes(f2.id)
3049 ).length;
3050 const visibleLockedFields = lockedFields.filter(
3051 ({ isVisibleFlag }) => (
3052 // @ts-expect-error
3053 view[isVisibleFlag] ?? true
3054 )
3055 );
3056 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
3057 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
3058 return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
3059 showLabel && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_components5.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
3060 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3061 Stack,
3062 {
3063 direction: "column",
3064 className: "dataviews-view-config__properties",
3065 children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_components5.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
3066 lockedFields.map(({ field, isVisibleFlag }) => {
3067 const isVisible2 = view[isVisibleFlag] ?? true;
3068 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
3069 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3070 FieldItem,
3071 {
3072 field: fieldToRender,
3073 isVisible: isVisible2,
3074 onToggleVisibility: () => {
3075 onChangeView({
3076 ...view,
3077 [isVisibleFlag]: !isVisible2
3078 });
3079 }
3080 },
3081 field.id
3082 );
3083 }),
3084 regularFields.map((field) => {
3085 const isVisible2 = visibleFieldIds.includes(field.id);
3086 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
3087 return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
3088 FieldItem,
3089 {
3090 field: fieldToRender,
3091 isVisible: isVisible2,
3092 onToggleVisibility: () => {
3093 onChangeView({
3094 ...view,
3095 fields: isVisible2 ? visibleFieldIds.filter(
3096 (fieldId) => fieldId !== field.id
3097 ) : [...visibleFieldIds, field.id]
3098 });
3099 }
3100 },
3101 field.id
3102 );
3103 })
3104 ] })
3105 }
3106 )
3107 ] });
3108 }
3109
3110 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
3111 var import_element12 = __toESM(require_element(), 1);
3112 function useDelayedLoading(isLoading, options = { delay: 400 }) {
3113 const [showLoader, setShowLoader] = (0, import_element12.useState)(false);
3114 (0, import_element12.useEffect)(() => {
3115 if (!isLoading) {
3116 return;
3117 }
3118 const timeout = setTimeout(() => {
3119 setShowLoader(true);
3120 }, options.delay);
3121 return () => {
3122 clearTimeout(timeout);
3123 setShowLoader(false);
3124 };
3125 }, [isLoading, options.delay]);
3126 return showLoader;
3127 }
3128
3129 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3130 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3131 function getEffectiveAlign(explicitAlign, fieldType) {
3132 if (explicitAlign) {
3133 return explicitAlign;
3134 }
3135 if (fieldType === "integer" || fieldType === "number") {
3136 return "end";
3137 }
3138 return void 0;
3139 }
3140 function TableColumnField({
3141 item,
3142 fields,
3143 column,
3144 align
3145 }) {
3146 const field = fields.find((f2) => f2.id === column);
3147 if (!field) {
3148 return null;
3149 }
3150 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
3151 "dataviews-view-table__cell-align-end": align === "end",
3152 "dataviews-view-table__cell-align-center": align === "center"
3153 });
3154 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(field.render, { item, field }) });
3155 }
3156 function TableRow({
3157 hasBulkActions,
3158 item,
3159 level,
3160 actions,
3161 fields,
3162 id,
3163 view,
3164 titleField,
3165 mediaField,
3166 descriptionField,
3167 selection,
3168 getItemId,
3169 isItemClickable,
3170 onClickItem,
3171 renderItemLink,
3172 onChangeSelection,
3173 isActionsColumnSticky,
3174 posinset
3175 }) {
3176 const { paginationInfo } = (0, import_element13.useContext)(dataviews_context_default);
3177 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item);
3178 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
3179 const {
3180 showTitle = true,
3181 showMedia = true,
3182 showDescription = true,
3183 infiniteScrollEnabled
3184 } = view;
3185 const isTouchDeviceRef = (0, import_element13.useRef)(false);
3186 const columns = view.fields ?? [];
3187 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
3188 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3189 "tr",
3190 {
3191 className: clsx_default("dataviews-view-table__row", {
3192 "is-selected": hasPossibleBulkAction && isSelected2,
3193 "has-bulk-actions": hasPossibleBulkAction
3194 }),
3195 onTouchStart: () => {
3196 isTouchDeviceRef.current = true;
3197 },
3198 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
3199 "aria-posinset": posinset,
3200 role: infiniteScrollEnabled ? "article" : void 0,
3201 onMouseDown: (event) => {
3202 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3203 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
3204 event?.preventDefault();
3205 }
3206 },
3207 onClick: (event) => {
3208 if (!hasPossibleBulkAction) {
3209 return;
3210 }
3211 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
3212 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
3213 onChangeSelection(
3214 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3215 );
3216 }
3217 },
3218 children: [
3219 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3220 DataViewsSelectionCheckbox,
3221 {
3222 item,
3223 selection,
3224 onChangeSelection,
3225 getItemId,
3226 titleField,
3227 disabled: !hasPossibleBulkAction
3228 }
3229 ) }) }),
3230 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3231 column_primary_default,
3232 {
3233 item,
3234 level,
3235 titleField: showTitle ? titleField : void 0,
3236 mediaField: showMedia ? mediaField : void 0,
3237 descriptionField: showDescription ? descriptionField : void 0,
3238 isItemClickable,
3239 onClickItem,
3240 renderItemLink
3241 }
3242 ) }),
3243 columns.map((column) => {
3244 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3245 const field = fields.find((f2) => f2.id === column);
3246 const effectiveAlign = getEffectiveAlign(align, field?.type);
3247 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3248 "td",
3249 {
3250 style: {
3251 width,
3252 maxWidth,
3253 minWidth
3254 },
3255 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3256 TableColumnField,
3257 {
3258 fields,
3259 item,
3260 column,
3261 align: effectiveAlign
3262 }
3263 )
3264 },
3265 column
3266 );
3267 }),
3268 !!actions?.length && // Disable reason: we are not making the element interactive,
3269 // but preventing any click events from bubbling up to the
3270 // table row. This allows us to add a click handler to the row
3271 // itself (to toggle row selection) without erroneously
3272 // intercepting click events from ItemActions.
3273 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3274 "td",
3275 {
3276 className: clsx_default("dataviews-view-table__actions-column", {
3277 "dataviews-view-table__actions-column--sticky": true,
3278 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
3279 }),
3280 onClick: (e2) => e2.stopPropagation(),
3281 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(ItemActions, { item, actions })
3282 }
3283 )
3284 ]
3285 }
3286 );
3287 }
3288 function ViewTable({
3289 actions,
3290 data,
3291 fields,
3292 getItemId,
3293 getItemLevel,
3294 isLoading = false,
3295 onChangeView,
3296 onChangeSelection,
3297 selection,
3298 setOpenedFilter,
3299 onClickItem,
3300 isItemClickable,
3301 renderItemLink,
3302 view,
3303 className,
3304 empty
3305 }) {
3306 const { containerRef } = (0, import_element13.useContext)(dataviews_context_default);
3307 const isDelayedLoading = useDelayedLoading(isLoading);
3308 const headerMenuRefs = (0, import_element13.useRef)(/* @__PURE__ */ new Map());
3309 const headerMenuToFocusRef = (0, import_element13.useRef)(void 0);
3310 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element13.useState)();
3311 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element13.useState)(null);
3312 (0, import_element13.useEffect)(() => {
3313 if (headerMenuToFocusRef.current) {
3314 headerMenuToFocusRef.current.focus();
3315 headerMenuToFocusRef.current = void 0;
3316 }
3317 });
3318 const tableNoticeId = (0, import_element13.useId)();
3319 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
3320 scrollContainerRef: containerRef,
3321 enabledHorizontal: !!actions?.length
3322 });
3323 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3324 if (nextHeaderMenuToFocus) {
3325 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
3326 setNextHeaderMenuToFocus(void 0);
3327 return;
3328 }
3329 const onHide = (field) => {
3330 const hidden = headerMenuRefs.current.get(field.id);
3331 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
3332 setNextHeaderMenuToFocus(fallback?.node);
3333 };
3334 const handleHeaderContextMenu = (event) => {
3335 event.preventDefault();
3336 event.stopPropagation();
3337 const virtualAnchor = {
3338 getBoundingClientRect: () => ({
3339 x: event.clientX,
3340 y: event.clientY,
3341 top: event.clientY,
3342 left: event.clientX,
3343 right: event.clientX,
3344 bottom: event.clientY,
3345 width: 0,
3346 height: 0,
3347 toJSON: () => ({})
3348 })
3349 };
3350 window.requestAnimationFrame(() => {
3351 setContextMenuAnchor(virtualAnchor);
3352 });
3353 };
3354 const hasData = !!data?.length;
3355 const titleField = fields.find((field) => field.id === view.titleField);
3356 const mediaField = fields.find((field) => field.id === view.mediaField);
3357 const descriptionField = fields.find(
3358 (field) => field.id === view.descriptionField
3359 );
3360 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
3361 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
3362 const { showTitle = true, showMedia = true, showDescription = true } = view;
3363 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
3364 const columns = view.fields ?? [];
3365 const headerMenuRef = (column, index) => (node) => {
3366 if (node) {
3367 headerMenuRefs.current.set(column, {
3368 node,
3369 fallback: columns[index > 0 ? index - 1 : 1]
3370 });
3371 } else {
3372 headerMenuRefs.current.delete(column);
3373 }
3374 };
3375 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
3376 const isRtl = (0, import_i18n9.isRTL)();
3377 if (!hasData) {
3378 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3379 "div",
3380 {
3381 className: clsx_default("dataviews-no-results", {
3382 "is-refreshing": isDelayedLoading
3383 }),
3384 id: tableNoticeId,
3385 children: empty
3386 }
3387 );
3388 }
3389 return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
3390 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(
3391 "table",
3392 {
3393 className: clsx_default("dataviews-view-table", className, {
3394 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
3395 view.layout.density
3396 ),
3397 "has-bulk-actions": hasBulkActions,
3398 "is-refreshing": !isInfiniteScroll && isDelayedLoading
3399 }),
3400 "aria-busy": isLoading,
3401 "aria-describedby": tableNoticeId,
3402 role: isInfiniteScroll ? "feed" : void 0,
3403 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
3404 children: [
3405 /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("colgroup", { children: [
3406 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
3407 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
3408 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3409 "col",
3410 {
3411 className: clsx_default(
3412 `dataviews-view-table__col-${column}`,
3413 {
3414 "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
3415 }
3416 )
3417 },
3418 `col-${column}`
3419 )),
3420 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("col", { className: "dataviews-view-table__col-actions" })
3421 ] }),
3422 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3423 import_components6.Popover,
3424 {
3425 anchor: contextMenuAnchor,
3426 onClose: () => setContextMenuAnchor(null),
3427 placement: "bottom-start",
3428 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(PropertiesSection, { showLabel: false })
3429 }
3430 ),
3431 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3432 "thead",
3433 {
3434 className: clsx_default({
3435 "dataviews-view-table__thead--stuck": isVerticallyScrolled
3436 }),
3437 onContextMenu: handleHeaderContextMenu,
3438 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("tr", { className: "dataviews-view-table__row", children: [
3439 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3440 "th",
3441 {
3442 className: "dataviews-view-table__checkbox-column",
3443 scope: "col",
3444 onContextMenu: handleHeaderContextMenu,
3445 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3446 BulkSelectionCheckbox,
3447 {
3448 selection,
3449 onChangeSelection,
3450 data,
3451 actions,
3452 getItemId
3453 }
3454 )
3455 }
3456 ),
3457 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3458 column_header_menu_default,
3459 {
3460 ref: headerMenuRef(
3461 titleField.id,
3462 0
3463 ),
3464 fieldId: titleField.id,
3465 view,
3466 fields,
3467 onChangeView,
3468 onHide,
3469 setOpenedFilter,
3470 canMove: false,
3471 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
3472 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
3473 }
3474 ) }),
3475 columns.map((column, index) => {
3476 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
3477 const field = fields.find(
3478 (f2) => f2.id === column
3479 );
3480 const effectiveAlign = getEffectiveAlign(
3481 align,
3482 field?.type
3483 );
3484 const canInsertOrMove = view.layout?.enableMoving ?? true;
3485 return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3486 "th",
3487 {
3488 style: {
3489 width,
3490 maxWidth,
3491 minWidth,
3492 textAlign: effectiveAlign
3493 },
3494 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
3495 scope: "col",
3496 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3497 column_header_menu_default,
3498 {
3499 ref: headerMenuRef(column, index),
3500 fieldId: column,
3501 view,
3502 fields,
3503 onChangeView,
3504 onHide,
3505 setOpenedFilter,
3506 canMove: canInsertOrMove,
3507 canInsertLeft: canInsertOrMove,
3508 canInsertRight: canInsertOrMove
3509 }
3510 )
3511 },
3512 column
3513 );
3514 }),
3515 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3516 "th",
3517 {
3518 className: clsx_default(
3519 "dataviews-view-table__actions-column",
3520 {
3521 "dataviews-view-table__actions-column--sticky": true,
3522 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
3523 }
3524 ),
3525 children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
3526 }
3527 )
3528 ] })
3529 }
3530 ),
3531 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
3532 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("tbody", { children: [
3533 /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3534 "td",
3535 {
3536 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions?.length ? 1 : 0),
3537 className: "dataviews-view-table__group-header-cell",
3538 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
3539 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
3540 (0, import_i18n9.__)("%1$s: %2$s"),
3541 groupField.label,
3542 groupName
3543 )
3544 }
3545 ) }),
3546 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3547 TableRow,
3548 {
3549 item,
3550 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3551 hasBulkActions,
3552 actions,
3553 fields,
3554 id: getItemId(item) || index.toString(),
3555 view,
3556 titleField,
3557 mediaField,
3558 descriptionField,
3559 selection,
3560 getItemId,
3561 onChangeSelection,
3562 onClickItem,
3563 renderItemLink,
3564 isItemClickable,
3565 isActionsColumnSticky: !isHorizontalScrollEnd
3566 },
3567 getItemId(item)
3568 ))
3569 ] }, `group-${groupName}`)
3570 ) : /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
3571 TableRow,
3572 {
3573 item,
3574 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
3575 hasBulkActions,
3576 actions,
3577 fields,
3578 id: getItemId(item) || index.toString(),
3579 view,
3580 titleField,
3581 mediaField,
3582 descriptionField,
3583 selection,
3584 getItemId,
3585 onChangeSelection,
3586 onClickItem,
3587 renderItemLink,
3588 isItemClickable,
3589 isActionsColumnSticky: !isHorizontalScrollEnd,
3590 posinset: isInfiniteScroll ? index + 1 : void 0
3591 },
3592 getItemId(item)
3593 )) })
3594 ]
3595 }
3596 ),
3597 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components6.Spinner, {}) }) })
3598 ] });
3599 }
3600 var table_default = ViewTable;
3601
3602 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
3603 var import_components9 = __toESM(require_components(), 1);
3604 var import_i18n12 = __toESM(require_i18n(), 1);
3605
3606 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3607 var import_components8 = __toESM(require_components(), 1);
3608 var import_i18n11 = __toESM(require_i18n(), 1);
3609 var import_compose3 = __toESM(require_compose(), 1);
3610 var import_keycodes2 = __toESM(require_keycodes(), 1);
3611 var import_element17 = __toESM(require_element(), 1);
3612
3613 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
3614 var import_components7 = __toESM(require_components(), 1);
3615 var import_i18n10 = __toESM(require_i18n(), 1);
3616 var import_element14 = __toESM(require_element(), 1);
3617 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3618 var imageSizes = [
3619 {
3620 value: 120,
3621 breakpoint: 1
3622 },
3623 {
3624 value: 170,
3625 breakpoint: 1
3626 },
3627 {
3628 value: 230,
3629 breakpoint: 1
3630 },
3631 {
3632 value: 290,
3633 breakpoint: 1112
3634 // at minimum image width, 4 images display at this container size
3635 },
3636 {
3637 value: 350,
3638 breakpoint: 1636
3639 // at minimum image width, 6 images display at this container size
3640 },
3641 {
3642 value: 430,
3643 breakpoint: 588
3644 // at minimum image width, 2 images display at this container size
3645 }
3646 ];
3647 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
3648 function useGridColumns() {
3649 const context = (0, import_element14.useContext)(dataviews_context_default);
3650 const view = context.view;
3651 return (0, import_element14.useMemo)(() => {
3652 const containerWidth = context.containerWidth;
3653 const gap = 32;
3654 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
3655 const columns = Math.floor(
3656 (containerWidth + gap) / (previewSize + gap)
3657 );
3658 return Math.max(1, columns);
3659 }, [context.containerWidth, view.layout?.previewSize]);
3660 }
3661
3662 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
3663 var import_element15 = __toESM(require_element(), 1);
3664 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3665 var GridItems = (0, import_element15.forwardRef)(({ className, previewSize, ...props }, ref) => {
3666 return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
3667 "div",
3668 {
3669 ref,
3670 className: clsx_default("dataviews-view-grid-items", className),
3671 style: {
3672 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
3673 },
3674 ...props
3675 }
3676 );
3677 });
3678
3679 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
3680 var import_element16 = __toESM(require_element(), 1);
3681 function useIntersectionObserver(elementRef, posinset) {
3682 const { intersectionObserver } = (0, import_element16.useContext)(dataviews_context_default);
3683 (0, import_element16.useEffect)(() => {
3684 const element = elementRef.current;
3685 if (!element || posinset === void 0 || !intersectionObserver) {
3686 return;
3687 }
3688 intersectionObserver.observe(element);
3689 return () => {
3690 intersectionObserver.unobserve(element);
3691 };
3692 }, [elementRef, intersectionObserver, posinset]);
3693 }
3694 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
3695 const hasData = !!data?.length;
3696 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
3697 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
3698 }
3699
3700 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
3701 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3702 var { Badge: WCBadge } = unlock2(import_components8.privateApis);
3703 function chunk(array, size) {
3704 const chunks = [];
3705 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
3706 chunks.push(array.slice(i2, i2 + size));
3707 }
3708 return chunks;
3709 }
3710 var GridItem = (0, import_element17.forwardRef)(
3711 function GridItem2({
3712 view,
3713 selection,
3714 onChangeSelection,
3715 onClickItem,
3716 isItemClickable,
3717 renderItemLink,
3718 getItemId,
3719 item,
3720 actions,
3721 mediaField,
3722 titleField,
3723 descriptionField,
3724 regularFields,
3725 badgeFields,
3726 hasBulkActions,
3727 config,
3728 posinset,
3729 setsize,
3730 ...props
3731 }, forwardedRef) {
3732 const {
3733 showTitle = true,
3734 showMedia = true,
3735 showDescription = true
3736 } = view;
3737 const hasBulkAction = useHasAPossibleBulkAction(actions, item);
3738 const id = getItemId(item);
3739 const elementRef = (0, import_element17.useRef)(null);
3740 const setRefs = (0, import_element17.useCallback)(
3741 (node) => {
3742 elementRef.current = node;
3743 if (typeof forwardedRef === "function") {
3744 forwardedRef(node);
3745 } else if (forwardedRef) {
3746 forwardedRef.current = node;
3747 }
3748 },
3749 [forwardedRef]
3750 );
3751 useIntersectionObserver(elementRef, posinset);
3752 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
3753 const isSelected2 = selection.includes(id);
3754 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
3755 const rendersMediaField = showMedia && mediaField?.render;
3756 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3757 mediaField.render,
3758 {
3759 item,
3760 field: mediaField,
3761 config
3762 }
3763 ) : mediaPlaceholder;
3764 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(titleField.render, { item, field: titleField }) : null;
3765 let mediaA11yProps;
3766 let titleA11yProps;
3767 if (isItemClickable(item) && onClickItem) {
3768 if (renderedTitleField) {
3769 mediaA11yProps = {
3770 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
3771 };
3772 titleA11yProps = {
3773 id: `dataviews-view-grid__title-field-${instanceId}`
3774 };
3775 } else {
3776 mediaA11yProps = {
3777 "aria-label": (0, import_i18n11.__)("Navigate to item")
3778 };
3779 }
3780 }
3781 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
3782 Stack,
3783 {
3784 direction: "column",
3785 ...props,
3786 ref: setRefs,
3787 "aria-setsize": setsize,
3788 "aria-posinset": posinset,
3789 className: clsx_default(
3790 props.className,
3791 "dataviews-view-grid__row__gridcell",
3792 "dataviews-view-grid__card",
3793 {
3794 "is-selected": hasBulkAction && isSelected2
3795 }
3796 ),
3797 onClickCapture: (event) => {
3798 props.onClickCapture?.(event);
3799 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
3800 event.stopPropagation();
3801 event.preventDefault();
3802 if (!hasBulkAction) {
3803 return;
3804 }
3805 onChangeSelection(
3806 isSelected2 ? selection.filter(
3807 (itemId) => id !== itemId
3808 ) : [...selection, id]
3809 );
3810 }
3811 },
3812 children: [
3813 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3814 ItemClickWrapper,
3815 {
3816 item,
3817 isItemClickable,
3818 onClickItem,
3819 renderItemLink,
3820 className: clsx_default("dataviews-view-grid__media", {
3821 "dataviews-view-grid__media--placeholder": !rendersMediaField
3822 }),
3823 ...mediaA11yProps,
3824 children: renderedMediaField
3825 }
3826 ),
3827 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3828 DataViewsSelectionCheckbox,
3829 {
3830 item,
3831 selection,
3832 onChangeSelection,
3833 getItemId,
3834 titleField,
3835 disabled: !hasBulkAction
3836 }
3837 ),
3838 !!actions?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3839 ItemActions,
3840 {
3841 item,
3842 actions,
3843 isCompact: true
3844 }
3845 ) }),
3846 showTitle && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3847 ItemClickWrapper,
3848 {
3849 item,
3850 isItemClickable,
3851 onClickItem,
3852 renderItemLink,
3853 className: "dataviews-view-grid__title-field dataviews-title-field",
3854 ...titleA11yProps,
3855 title: titleField?.getValueFormatted({
3856 item,
3857 field: titleField
3858 }) || void 0,
3859 children: renderedTitleField
3860 }
3861 ) }),
3862 /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(Stack, { direction: "column", gap: "xs", children: [
3863 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3864 descriptionField.render,
3865 {
3866 item,
3867 field: descriptionField
3868 }
3869 ),
3870 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3871 Stack,
3872 {
3873 direction: "row",
3874 className: "dataviews-view-grid__badge-fields",
3875 gap: "sm",
3876 wrap: "wrap",
3877 align: "top",
3878 justify: "flex-start",
3879 children: badgeFields.map((field) => {
3880 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3881 WCBadge,
3882 {
3883 className: "dataviews-view-grid__field-value",
3884 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3885 field.render,
3886 {
3887 item,
3888 field
3889 }
3890 )
3891 },
3892 field.id
3893 );
3894 })
3895 }
3896 ),
3897 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3898 Stack,
3899 {
3900 direction: "column",
3901 className: "dataviews-view-grid__fields",
3902 gap: "xs",
3903 children: regularFields.map((field) => {
3904 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3905 import_components8.Flex,
3906 {
3907 className: "dataviews-view-grid__field",
3908 gap: 1,
3909 justify: "flex-start",
3910 expanded: true,
3911 style: { height: "auto" },
3912 direction: "row",
3913 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, { children: [
3914 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components8.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
3915 /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3916 import_components8.FlexItem,
3917 {
3918 className: "dataviews-view-grid__field-value",
3919 style: { maxHeight: "none" },
3920 children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3921 field.render,
3922 {
3923 item,
3924 field
3925 }
3926 )
3927 }
3928 )
3929 ] })
3930 },
3931 field.id
3932 );
3933 })
3934 }
3935 )
3936 ] })
3937 ]
3938 }
3939 );
3940 }
3941 );
3942 function CompositeGrid({
3943 data,
3944 isInfiniteScroll,
3945 className,
3946 inert,
3947 isLoading,
3948 view,
3949 fields,
3950 selection,
3951 onChangeSelection,
3952 onClickItem,
3953 isItemClickable,
3954 renderItemLink,
3955 getItemId,
3956 actions
3957 }) {
3958 const { paginationInfo, resizeObserverRef } = (0, import_element17.useContext)(dataviews_context_default);
3959 const gridColumns = useGridColumns();
3960 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data);
3961 const titleField = fields.find(
3962 (field) => field.id === view?.titleField
3963 );
3964 const mediaField = fields.find(
3965 (field) => field.id === view?.mediaField
3966 );
3967 const descriptionField = fields.find(
3968 (field) => field.id === view?.descriptionField
3969 );
3970 const otherFields = view.fields ?? [];
3971 const { regularFields, badgeFields } = otherFields.reduce(
3972 (accumulator, fieldId) => {
3973 const field = fields.find((f2) => f2.id === fieldId);
3974 if (!field) {
3975 return accumulator;
3976 }
3977 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
3978 accumulator[key].push(field);
3979 return accumulator;
3980 },
3981 { regularFields: [], badgeFields: [] }
3982 );
3983 const size = "900px";
3984 const totalRows = Math.ceil(data.length / gridColumns);
3985 const placeholdersNeeded = usePlaceholdersNeeded(
3986 data,
3987 isInfiniteScroll,
3988 gridColumns
3989 );
3990 return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_jsx_runtime34.Fragment, {
3991 // Render infinite scroll layout (no rows, feed semantics)
3992 children: [
3993 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
3994 import_components8.Composite,
3995 {
3996 render: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
3997 GridItems,
3998 {
3999 className: clsx_default(
4000 "dataviews-view-grid-infinite-scroll",
4001 className,
4002 {
4003 [`has-${view.layout?.density}-density`]: view.layout?.density && [
4004 "compact",
4005 "comfortable"
4006 ].includes(view.layout.density)
4007 }
4008 ),
4009 previewSize: view.layout?.previewSize,
4010 "aria-busy": isLoading,
4011 ref: resizeObserverRef
4012 }
4013 ),
4014 role: "feed",
4015 focusWrap: true,
4016 inert,
4017 children: [
4018 Array.from({ length: placeholdersNeeded }).map(
4019 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4020 import_components8.Composite.Item,
4021 {
4022 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4023 Stack,
4024 {
4025 ...props,
4026 direction: "column",
4027 role: "article",
4028 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
4029 }
4030 ),
4031 "aria-hidden": true,
4032 tabIndex: -1
4033 },
4034 `placeholder-${index}`
4035 )
4036 ),
4037 data.map((item) => {
4038 const itemId = getItemId(item);
4039 const stablePosition = item.position;
4040 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4041 import_components8.Composite.Item,
4042 {
4043 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4044 GridItem,
4045 {
4046 ...props,
4047 id: itemId,
4048 role: "article",
4049 view,
4050 selection,
4051 onChangeSelection,
4052 onClickItem,
4053 isItemClickable,
4054 renderItemLink,
4055 getItemId,
4056 item,
4057 actions,
4058 mediaField,
4059 titleField,
4060 descriptionField,
4061 regularFields,
4062 badgeFields,
4063 hasBulkActions,
4064 posinset: stablePosition,
4065 setsize: paginationInfo.totalItems,
4066 config: {
4067 sizes: size
4068 }
4069 }
4070 )
4071 },
4072 itemId
4073 );
4074 })
4075 ]
4076 }
4077 ),
4078 // Render standard grid layout (with rows, grid semantics)
4079 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4080 import_components8.Composite,
4081 {
4082 role: "grid",
4083 className: clsx_default("dataviews-view-grid", className, {
4084 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4085 view.layout.density
4086 )
4087 }),
4088 focusWrap: true,
4089 "aria-busy": isLoading,
4090 "aria-rowcount": totalRows,
4091 ref: resizeObserverRef,
4092 inert,
4093 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4094 import_components8.Composite.Row,
4095 {
4096 render: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4097 "div",
4098 {
4099 role: "row",
4100 "aria-rowindex": i2 + 1,
4101 "aria-label": (0, import_i18n11.sprintf)(
4102 /* translators: %d: The row number in the grid */
4103 (0, import_i18n11.__)("Row %d"),
4104 i2 + 1
4105 ),
4106 className: "dataviews-view-grid__row",
4107 style: {
4108 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
4109 }
4110 }
4111 ),
4112 children: row.map((item) => {
4113 const itemId = getItemId(item);
4114 return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4115 import_components8.Composite.Item,
4116 {
4117 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
4118 GridItem,
4119 {
4120 ...props,
4121 id: itemId,
4122 role: "gridcell",
4123 view,
4124 selection,
4125 onChangeSelection,
4126 onClickItem,
4127 isItemClickable,
4128 renderItemLink,
4129 getItemId,
4130 item,
4131 actions,
4132 mediaField,
4133 titleField,
4134 descriptionField,
4135 regularFields,
4136 badgeFields,
4137 hasBulkActions,
4138 config: {
4139 sizes: size
4140 }
4141 }
4142 )
4143 },
4144 itemId
4145 );
4146 })
4147 },
4148 i2
4149 ))
4150 }
4151 )
4152 ]
4153 });
4154 }
4155
4156 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
4157 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
4158 function ViewGrid({
4159 actions,
4160 data,
4161 fields,
4162 getItemId,
4163 isLoading,
4164 onChangeSelection,
4165 onClickItem,
4166 isItemClickable,
4167 renderItemLink,
4168 selection,
4169 view,
4170 className,
4171 empty
4172 }) {
4173 const isDelayedLoading = useDelayedLoading(!!isLoading);
4174 const hasData = !!data?.length;
4175 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
4176 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
4177 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4178 if (!hasData) {
4179 return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4180 "div",
4181 {
4182 className: clsx_default("dataviews-no-results", {
4183 "is-refreshing": isDelayedLoading
4184 }),
4185 children: empty
4186 }
4187 );
4188 }
4189 const gridProps = {
4190 className: clsx_default(className, {
4191 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4192 }),
4193 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4194 isLoading,
4195 view,
4196 fields,
4197 selection,
4198 onChangeSelection,
4199 onClickItem,
4200 isItemClickable,
4201 renderItemLink,
4202 getItemId,
4203 actions
4204 };
4205 return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, {
4206 // Render multiple groups.
4207 children: [
4208 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
4209 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
4210 Stack,
4211 {
4212 direction: "column",
4213 gap: "sm",
4214 children: [
4215 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
4216 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4217 (0, import_i18n12.__)("%1$s: %2$s"),
4218 groupField.label,
4219 groupName
4220 ) }),
4221 /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4222 CompositeGrid,
4223 {
4224 ...gridProps,
4225 data: groupItems,
4226 isInfiniteScroll: false
4227 }
4228 )
4229 ]
4230 },
4231 groupName
4232 )
4233 ) }),
4234 // Render a single grid with all data.
4235 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
4236 CompositeGrid,
4237 {
4238 ...gridProps,
4239 data,
4240 isInfiniteScroll: !!isInfiniteScroll
4241 }
4242 ),
4243 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_components9.Spinner, {}) })
4244 ]
4245 });
4246 }
4247 var grid_default = ViewGrid;
4248
4249 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
4250 var import_compose4 = __toESM(require_compose(), 1);
4251 var import_components10 = __toESM(require_components(), 1);
4252 var import_element18 = __toESM(require_element(), 1);
4253 var import_i18n13 = __toESM(require_i18n(), 1);
4254 var import_data6 = __toESM(require_data(), 1);
4255 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
4256 var { Menu: Menu3 } = unlock2(import_components10.privateApis);
4257 function generateItemWrapperCompositeId(idPrefix) {
4258 return `${idPrefix}-item-wrapper`;
4259 }
4260 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
4261 return `${idPrefix}-primary-action-${primaryActionId}`;
4262 }
4263 function generateDropdownTriggerCompositeId(idPrefix) {
4264 return `${idPrefix}-dropdown`;
4265 }
4266 function PrimaryActionGridCell({
4267 idPrefix,
4268 primaryAction,
4269 item
4270 }) {
4271 const registry = (0, import_data6.useRegistry)();
4272 const [isModalOpen, setIsModalOpen] = (0, import_element18.useState)(false);
4273 const compositeItemId = generatePrimaryActionCompositeId(
4274 idPrefix,
4275 primaryAction.id
4276 );
4277 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
4278 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4279 import_components10.Composite.Item,
4280 {
4281 id: compositeItemId,
4282 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4283 import_components10.Button,
4284 {
4285 disabled: !!primaryAction.disabled,
4286 accessibleWhenDisabled: true,
4287 text: label,
4288 size: "small",
4289 onClick: () => setIsModalOpen(true)
4290 }
4291 ),
4292 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4293 ActionModal,
4294 {
4295 action: primaryAction,
4296 items: [item],
4297 closeModal: () => setIsModalOpen(false)
4298 }
4299 )
4300 }
4301 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4302 import_components10.Composite.Item,
4303 {
4304 id: compositeItemId,
4305 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4306 import_components10.Button,
4307 {
4308 disabled: !!primaryAction.disabled,
4309 accessibleWhenDisabled: true,
4310 size: "small",
4311 onClick: () => {
4312 primaryAction.callback([item], { registry });
4313 },
4314 children: label
4315 }
4316 )
4317 }
4318 ) }, primaryAction.id);
4319 }
4320 function ListItem({
4321 view,
4322 actions,
4323 idPrefix,
4324 isSelected: isSelected2,
4325 item,
4326 titleField,
4327 mediaField,
4328 descriptionField,
4329 onSelect,
4330 otherFields,
4331 onDropdownTriggerKeyDown,
4332 posinset
4333 }) {
4334 const {
4335 showTitle = true,
4336 showMedia = true,
4337 showDescription = true,
4338 infiniteScrollEnabled
4339 } = view;
4340 const itemRef = (0, import_element18.useRef)(null);
4341 const labelId = `${idPrefix}-label`;
4342 const descriptionId = `${idPrefix}-description`;
4343 const registry = (0, import_data6.useRegistry)();
4344 const [isHovered, setIsHovered] = (0, import_element18.useState)(false);
4345 const [activeModalAction, setActiveModalAction] = (0, import_element18.useState)(
4346 null
4347 );
4348 const handleHover = ({ type }) => {
4349 const isHover = type === "mouseenter";
4350 setIsHovered(isHover);
4351 };
4352 const { paginationInfo } = (0, import_element18.useContext)(dataviews_context_default);
4353 (0, import_element18.useEffect)(() => {
4354 if (isSelected2) {
4355 itemRef.current?.scrollIntoView({
4356 behavior: "auto",
4357 block: "nearest",
4358 inline: "nearest"
4359 });
4360 }
4361 }, [isSelected2]);
4362 const { primaryAction, eligibleActions } = (0, import_element18.useMemo)(() => {
4363 const _eligibleActions = actions.filter(
4364 (action) => !action.isEligible || action.isEligible(item)
4365 );
4366 const _primaryActions = _eligibleActions.filter(
4367 (action) => action.isPrimary
4368 );
4369 return {
4370 primaryAction: _primaryActions[0],
4371 eligibleActions: _eligibleActions
4372 };
4373 }, [actions, item]);
4374 const hasOnlyOnePrimaryAction = primaryAction && actions.length === 1;
4375 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4376 mediaField.render,
4377 {
4378 item,
4379 field: mediaField,
4380 config: { sizes: "52px" }
4381 }
4382 ) }) : null;
4383 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(titleField.render, { item, field: titleField }) : null;
4384 const renderDescription = showDescription && descriptionField?.render;
4385 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
4386 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4387 Stack,
4388 {
4389 direction: "row",
4390 gap: "md",
4391 className: "dataviews-view-list__item-actions",
4392 children: [
4393 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4394 PrimaryActionGridCell,
4395 {
4396 idPrefix,
4397 primaryAction,
4398 item
4399 }
4400 ),
4401 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { role: "gridcell", children: [
4402 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Menu3, { placement: "bottom-end", children: [
4403 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4404 Menu3.TriggerButton,
4405 {
4406 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4407 import_components10.Composite.Item,
4408 {
4409 id: generateDropdownTriggerCompositeId(
4410 idPrefix
4411 ),
4412 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4413 import_components10.Button,
4414 {
4415 size: "small",
4416 icon: more_vertical_default,
4417 label: (0, import_i18n13.__)("Actions"),
4418 accessibleWhenDisabled: true,
4419 disabled: !actions.length,
4420 onKeyDown: onDropdownTriggerKeyDown
4421 }
4422 )
4423 }
4424 )
4425 }
4426 ),
4427 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4428 ActionsMenuGroup,
4429 {
4430 actions: eligibleActions,
4431 item,
4432 registry,
4433 setActiveModalAction
4434 }
4435 ) })
4436 ] }),
4437 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4438 ActionModal,
4439 {
4440 action: activeModalAction,
4441 items: [item],
4442 closeModal: () => setActiveModalAction(null)
4443 }
4444 )
4445 ] })
4446 ]
4447 }
4448 );
4449 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4450 import_components10.Composite.Row,
4451 {
4452 ref: itemRef,
4453 render: (
4454 /* aria-posinset breaks Composite.Row if passed to it directly. */
4455 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4456 "div",
4457 {
4458 "aria-posinset": posinset,
4459 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
4460 }
4461 )
4462 ),
4463 role: infiniteScrollEnabled ? "article" : "row",
4464 className: clsx_default({
4465 "is-selected": isSelected2,
4466 "is-hovered": isHovered
4467 }),
4468 onMouseEnter: handleHover,
4469 onMouseLeave: handleHover,
4470 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4471 Stack,
4472 {
4473 direction: "row",
4474 className: "dataviews-view-list__item-wrapper",
4475 children: [
4476 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4477 import_components10.Composite.Item,
4478 {
4479 id: generateItemWrapperCompositeId(idPrefix),
4480 "aria-pressed": isSelected2,
4481 "aria-labelledby": labelId,
4482 "aria-describedby": descriptionId,
4483 className: "dataviews-view-list__item",
4484 onClick: () => onSelect(item)
4485 }
4486 ) }),
4487 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4488 Stack,
4489 {
4490 direction: "row",
4491 gap: "md",
4492 justify: "start",
4493 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
4494 style: { flex: 1, minWidth: 0 },
4495 children: [
4496 renderedMediaField,
4497 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4498 Stack,
4499 {
4500 direction: "column",
4501 gap: "xs",
4502 className: "dataviews-view-list__field-wrapper",
4503 children: [
4504 /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(Stack, { direction: "row", align: "center", children: [
4505 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4506 "div",
4507 {
4508 className: "dataviews-title-field dataviews-view-list__title-field",
4509 id: labelId,
4510 children: renderedTitleField
4511 }
4512 ),
4513 usedActions
4514 ] }),
4515 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4516 descriptionField.render,
4517 {
4518 item,
4519 field: descriptionField
4520 }
4521 ) }),
4522 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4523 "div",
4524 {
4525 className: "dataviews-view-list__fields",
4526 id: descriptionId,
4527 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4528 "div",
4529 {
4530 className: "dataviews-view-list__field",
4531 children: [
4532 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4533 VisuallyHidden,
4534 {
4535 className: "dataviews-view-list__field-label",
4536 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", {}),
4537 children: field.label
4538 }
4539 ),
4540 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4541 field.render,
4542 {
4543 item,
4544 field
4545 }
4546 ) })
4547 ]
4548 },
4549 field.id
4550 ))
4551 }
4552 )
4553 ]
4554 }
4555 )
4556 ]
4557 }
4558 )
4559 ]
4560 }
4561 )
4562 }
4563 );
4564 }
4565 function isDefined2(item) {
4566 return !!item;
4567 }
4568 function ViewList(props) {
4569 const {
4570 actions,
4571 data,
4572 fields,
4573 getItemId,
4574 isLoading,
4575 onChangeSelection,
4576 selection,
4577 view,
4578 className,
4579 empty
4580 } = props;
4581 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
4582 const isDelayedLoading = useDelayedLoading(!!isLoading);
4583 const selectedItem = data?.findLast(
4584 (item) => selection.includes(getItemId(item))
4585 );
4586 const titleField = fields.find((field) => field.id === view.titleField);
4587 const mediaField = fields.find((field) => field.id === view.mediaField);
4588 const descriptionField = fields.find(
4589 (field) => field.id === view.descriptionField
4590 );
4591 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined2);
4592 const onSelect = (item) => onChangeSelection([getItemId(item)]);
4593 const generateCompositeItemIdPrefix = (0, import_element18.useCallback)(
4594 (item) => `${baseId}-${getItemId(item)}`,
4595 [baseId, getItemId]
4596 );
4597 const isActiveCompositeItem = (0, import_element18.useCallback)(
4598 (item, idToCheck) => {
4599 return idToCheck.startsWith(
4600 generateCompositeItemIdPrefix(item)
4601 );
4602 },
4603 [generateCompositeItemIdPrefix]
4604 );
4605 const [activeCompositeId, setActiveCompositeId] = (0, import_element18.useState)(void 0);
4606 const compositeRef = (0, import_element18.useRef)(null);
4607 (0, import_element18.useEffect)(() => {
4608 if (selectedItem) {
4609 setActiveCompositeId(
4610 generateItemWrapperCompositeId(
4611 generateCompositeItemIdPrefix(selectedItem)
4612 )
4613 );
4614 }
4615 }, [selectedItem, generateCompositeItemIdPrefix]);
4616 const activeItemIndex = data.findIndex(
4617 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
4618 );
4619 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
4620 const isActiveIdInList = activeItemIndex !== -1;
4621 const selectCompositeItem = (0, import_element18.useCallback)(
4622 (targetIndex, generateCompositeId) => {
4623 const clampedIndex = Math.min(
4624 data.length - 1,
4625 Math.max(0, targetIndex)
4626 );
4627 if (!data[clampedIndex]) {
4628 return;
4629 }
4630 const itemIdPrefix = generateCompositeItemIdPrefix(
4631 data[clampedIndex]
4632 );
4633 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
4634 setActiveCompositeId(targetCompositeItemId);
4635 if (compositeRef.current?.contains(
4636 compositeRef.current.ownerDocument.activeElement
4637 )) {
4638 document.getElementById(targetCompositeItemId)?.focus();
4639 }
4640 },
4641 [data, generateCompositeItemIdPrefix]
4642 );
4643 (0, import_element18.useEffect)(() => {
4644 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
4645 if (!isActiveIdInList && wasActiveIdInList) {
4646 selectCompositeItem(
4647 previousActiveItemIndex,
4648 generateItemWrapperCompositeId
4649 );
4650 }
4651 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
4652 const onDropdownTriggerKeyDown = (0, import_element18.useCallback)(
4653 (event) => {
4654 if (event.key === "ArrowDown") {
4655 event.preventDefault();
4656 selectCompositeItem(
4657 activeItemIndex + 1,
4658 generateDropdownTriggerCompositeId
4659 );
4660 }
4661 if (event.key === "ArrowUp") {
4662 event.preventDefault();
4663 selectCompositeItem(
4664 activeItemIndex - 1,
4665 generateDropdownTriggerCompositeId
4666 );
4667 }
4668 },
4669 [selectCompositeItem, activeItemIndex]
4670 );
4671 const hasData = !!data?.length;
4672 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
4673 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
4674 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
4675 if (!hasData) {
4676 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4677 "div",
4678 {
4679 className: clsx_default("dataviews-no-results", {
4680 "is-refreshing": isDelayedLoading
4681 }),
4682 children: empty
4683 }
4684 );
4685 }
4686 if (hasData && groupField && dataByGroup) {
4687 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4688 import_components10.Composite,
4689 {
4690 ref: compositeRef,
4691 id: `${baseId}`,
4692 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", {}),
4693 className: "dataviews-view-list__group",
4694 role: "grid",
4695 activeId: activeCompositeId,
4696 setActiveId: setActiveCompositeId,
4697 children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4698 Stack,
4699 {
4700 direction: "column",
4701 gap: "lg",
4702 className: clsx_default("dataviews-view-list", className),
4703 children: Array.from(dataByGroup.entries()).map(
4704 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
4705 Stack,
4706 {
4707 direction: "column",
4708 gap: "sm",
4709 children: [
4710 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
4711 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
4712 (0, import_i18n13.__)("%1$s: %2$s"),
4713 groupField.label,
4714 groupName
4715 ) }),
4716 groupItems.map((item) => {
4717 const id = generateCompositeItemIdPrefix(item);
4718 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4719 ListItem,
4720 {
4721 view,
4722 idPrefix: id,
4723 actions,
4724 item,
4725 isSelected: item === selectedItem,
4726 onSelect,
4727 mediaField,
4728 titleField,
4729 descriptionField,
4730 otherFields,
4731 onDropdownTriggerKeyDown
4732 },
4733 id
4734 );
4735 })
4736 ]
4737 },
4738 groupName
4739 )
4740 )
4741 }
4742 )
4743 }
4744 );
4745 }
4746 return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
4747 /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4748 import_components10.Composite,
4749 {
4750 ref: compositeRef,
4751 id: baseId,
4752 render: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", {}),
4753 className: clsx_default("dataviews-view-list", className, {
4754 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
4755 view.layout.density
4756 ),
4757 "is-refreshing": !isInfiniteScroll && isDelayedLoading
4758 }),
4759 role: view.infiniteScrollEnabled ? "feed" : "grid",
4760 activeId: activeCompositeId,
4761 setActiveId: setActiveCompositeId,
4762 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
4763 children: data.map((item, index) => {
4764 const id = generateCompositeItemIdPrefix(item);
4765 return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
4766 ListItem,
4767 {
4768 view,
4769 idPrefix: id,
4770 actions,
4771 item,
4772 isSelected: item === selectedItem,
4773 onSelect,
4774 mediaField,
4775 titleField,
4776 descriptionField,
4777 otherFields,
4778 onDropdownTriggerKeyDown,
4779 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
4780 },
4781 id
4782 );
4783 })
4784 }
4785 ),
4786 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components10.Spinner, {}) })
4787 ] });
4788 }
4789
4790 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
4791 var import_components11 = __toESM(require_components(), 1);
4792
4793 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
4794 var import_i18n14 = __toESM(require_i18n(), 1);
4795 var import_element19 = __toESM(require_element(), 1);
4796 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
4797 function ActivityGroup({
4798 groupName,
4799 groupData,
4800 groupField,
4801 showLabel = true,
4802 children
4803 }) {
4804 const groupHeader = showLabel ? (0, import_element19.createInterpolateElement)(
4805 // translators: %s: The label of the field e.g. "Status".
4806 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
4807 {
4808 groupName: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
4809 groupField.render,
4810 {
4811 item: groupData[0],
4812 field: groupField
4813 }
4814 )
4815 }
4816 ) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(groupField.render, { item: groupData[0], field: groupField });
4817 return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
4818 Stack,
4819 {
4820 direction: "column",
4821 className: "dataviews-view-activity__group",
4822 children: [
4823 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
4824 children
4825 ]
4826 },
4827 groupName
4828 );
4829 }
4830
4831 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
4832 var import_element20 = __toESM(require_element(), 1);
4833 var import_data7 = __toESM(require_data(), 1);
4834 var import_compose5 = __toESM(require_compose(), 1);
4835 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
4836 function ActivityItem(props) {
4837 const {
4838 view,
4839 actions,
4840 item,
4841 titleField,
4842 mediaField,
4843 descriptionField,
4844 otherFields,
4845 posinset,
4846 onClickItem,
4847 renderItemLink,
4848 isItemClickable
4849 } = props;
4850 const {
4851 showTitle = true,
4852 showMedia = true,
4853 showDescription = true,
4854 infiniteScrollEnabled
4855 } = view;
4856 const itemRef = (0, import_element20.useRef)(null);
4857 const registry = (0, import_data7.useRegistry)();
4858 const { paginationInfo } = (0, import_element20.useContext)(dataviews_context_default);
4859 const { primaryActions, eligibleActions } = (0, import_element20.useMemo)(() => {
4860 const _eligibleActions = actions.filter(
4861 (action) => !action.isEligible || action.isEligible(item)
4862 );
4863 const _primaryActions = _eligibleActions.filter(
4864 (action) => action.isPrimary
4865 );
4866 return {
4867 primaryActions: _primaryActions,
4868 eligibleActions: _eligibleActions
4869 };
4870 }, [actions, item]);
4871 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
4872 const density = view.layout?.density ?? "balanced";
4873 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4874 mediaField.render,
4875 {
4876 item,
4877 field: mediaField,
4878 config: {
4879 sizes: density === "comfortable" ? "32px" : "24px"
4880 }
4881 }
4882 ) : null;
4883 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4884 "span",
4885 {
4886 className: "dataviews-view-activity__item-bullet",
4887 "aria-hidden": "true"
4888 }
4889 ) });
4890 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(titleField.render, { item, field: titleField }) : null;
4891 const verticalGap = (0, import_element20.useMemo)(() => {
4892 switch (density) {
4893 case "comfortable":
4894 return "md";
4895 default:
4896 return "sm";
4897 }
4898 }, [density]);
4899 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4900 "div",
4901 {
4902 ref: itemRef,
4903 role: infiniteScrollEnabled ? "article" : void 0,
4904 "aria-posinset": posinset,
4905 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
4906 className: clsx_default(
4907 "dataviews-view-activity__item",
4908 density === "compact" && "is-compact",
4909 density === "balanced" && "is-balanced",
4910 density === "comfortable" && "is-comfortable"
4911 ),
4912 children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
4913 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4914 Stack,
4915 {
4916 direction: "column",
4917 gap: "xs",
4918 align: "center",
4919 className: "dataviews-view-activity__item-type",
4920 children: renderedMediaField
4921 }
4922 ),
4923 /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
4924 Stack,
4925 {
4926 direction: "column",
4927 gap: verticalGap,
4928 align: "flex-start",
4929 className: "dataviews-view-activity__item-content",
4930 children: [
4931 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4932 ItemClickWrapper,
4933 {
4934 item,
4935 isItemClickable,
4936 onClickItem,
4937 renderItemLink,
4938 className: "dataviews-view-activity__item-title",
4939 children: renderedTitleField
4940 }
4941 ),
4942 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4943 descriptionField.render,
4944 {
4945 item,
4946 field: descriptionField
4947 }
4948 ) }),
4949 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
4950 "div",
4951 {
4952 className: "dataviews-view-activity__item-field",
4953 children: [
4954 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4955 VisuallyHidden,
4956 {
4957 className: "dataviews-view-activity__item-field-label",
4958 render: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", {}),
4959 children: field.label
4960 }
4961 ),
4962 /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4963 field.render,
4964 {
4965 item,
4966 field
4967 }
4968 ) })
4969 ]
4970 },
4971 field.id
4972 )) }),
4973 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4974 PrimaryActions,
4975 {
4976 item,
4977 actions: primaryActions,
4978 registry,
4979 buttonVariant: "secondary"
4980 }
4981 )
4982 ]
4983 }
4984 ),
4985 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
4986 // there if there are any actions at all.
4987 isMobileViewport && // At the same time, only show the menu if there are actions to show.
4988 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
4989 ItemActions,
4990 {
4991 item,
4992 actions: eligibleActions,
4993 isCompact: true
4994 }
4995 ) })
4996 ] })
4997 }
4998 );
4999 }
5000 var activity_item_default = ActivityItem;
5001
5002 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
5003 var import_react5 = __toESM(require_react(), 1);
5004 function isDefined3(item) {
5005 return !!item;
5006 }
5007 function ActivityItems(props) {
5008 const { data, fields, getItemId, view } = props;
5009 const titleField = fields.find((field) => field.id === view.titleField);
5010 const mediaField = fields.find((field) => field.id === view.mediaField);
5011 const descriptionField = fields.find(
5012 (field) => field.id === view.descriptionField
5013 );
5014 const otherFields = (view?.fields ?? []).map((fieldId) => fields.find((f2) => fieldId === f2.id)).filter(isDefined3);
5015 return data.map((item, index) => {
5016 return /* @__PURE__ */ (0, import_react5.createElement)(
5017 activity_item_default,
5018 {
5019 ...props,
5020 key: getItemId(item),
5021 item,
5022 mediaField,
5023 titleField,
5024 descriptionField,
5025 otherFields,
5026 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
5027 }
5028 );
5029 });
5030 }
5031
5032 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
5033 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
5034 function ViewActivity(props) {
5035 const { empty, data, fields, isLoading, view, className } = props;
5036 const isDelayedLoading = useDelayedLoading(!!isLoading);
5037 const hasData = !!data?.length;
5038 const groupField = view.groupBy?.field ? fields.find((field) => field.id === view.groupBy?.field) : null;
5039 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
5040 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5041 if (!hasData) {
5042 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5043 "div",
5044 {
5045 className: clsx_default("dataviews-no-results", {
5046 "is-refreshing": isDelayedLoading
5047 }),
5048 children: empty
5049 }
5050 );
5051 }
5052 const isInert = !isInfiniteScroll && !!isLoading;
5053 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
5054 "is-refreshing": !isInfiniteScroll && isDelayedLoading
5055 });
5056 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
5057 if (hasData && groupField && dataByGroup) {
5058 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5059 Stack,
5060 {
5061 direction: "column",
5062 gap: "sm",
5063 className: wrapperClassName,
5064 inert: isInert ? "true" : void 0,
5065 children: groupedEntries.map(
5066 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5067 ActivityGroup,
5068 {
5069 groupName,
5070 groupData,
5071 groupField,
5072 showLabel: view.groupBy?.showLabel !== false,
5073 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5074 ActivityItems,
5075 {
5076 ...props,
5077 data: groupData
5078 }
5079 )
5080 },
5081 groupName
5082 )
5083 )
5084 }
5085 );
5086 }
5087 return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(import_jsx_runtime39.Fragment, { children: [
5088 /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
5089 "div",
5090 {
5091 className: wrapperClassName,
5092 role: view.infiniteScrollEnabled ? "feed" : void 0,
5093 inert: isInert ? "true" : void 0,
5094 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(ActivityItems, { ...props })
5095 }
5096 ),
5097 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_components11.Spinner, {}) })
5098 ] });
5099 }
5100
5101 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5102 var import_components14 = __toESM(require_components(), 1);
5103 var import_i18n17 = __toESM(require_i18n(), 1);
5104 var import_compose6 = __toESM(require_compose(), 1);
5105 var import_element23 = __toESM(require_element(), 1);
5106
5107 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5108 var import_components13 = __toESM(require_components(), 1);
5109 var import_data8 = __toESM(require_data(), 1);
5110 var import_element22 = __toESM(require_element(), 1);
5111 var import_i18n16 = __toESM(require_i18n(), 1);
5112
5113 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
5114 var import_components12 = __toESM(require_components(), 1);
5115 var import_element21 = __toESM(require_element(), 1);
5116 var import_i18n15 = __toESM(require_i18n(), 1);
5117 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
5118 function DataViewsPagination() {
5119 const {
5120 view,
5121 onChangeView,
5122 paginationInfo: { totalItems = 0, totalPages }
5123 } = (0, import_element21.useContext)(dataviews_context_default);
5124 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
5125 return null;
5126 }
5127 const currentPage = view.page ?? 1;
5128 const pageSelectOptions = Array.from(Array(totalPages)).map(
5129 (_, i2) => {
5130 const page = i2 + 1;
5131 return {
5132 value: page.toString(),
5133 label: page.toString(),
5134 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
5135 // translators: 1: current page number. 2: total number of pages.
5136 (0, import_i18n15.__)("Page %1$d of %2$d"),
5137 currentPage,
5138 totalPages
5139 ) : page.toString()
5140 };
5141 }
5142 );
5143 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(
5144 Stack,
5145 {
5146 direction: "row",
5147 className: "dataviews-pagination",
5148 justify: "end",
5149 align: "center",
5150 gap: "xl",
5151 children: [
5152 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5153 Stack,
5154 {
5155 direction: "row",
5156 justify: "flex-start",
5157 align: "center",
5158 gap: "xs",
5159 className: "dataviews-pagination__page-select",
5160 children: (0, import_element21.createInterpolateElement)(
5161 (0, import_i18n15.sprintf)(
5162 // translators: 1: Current page number, 2: Total number of pages.
5163 (0, import_i18n15._x)(
5164 "<div>Page</div>%1$s<div>of %2$d</div>",
5165 "paging"
5166 ),
5167 "<CurrentPage />",
5168 totalPages
5169 ),
5170 {
5171 div: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { "aria-hidden": true }),
5172 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
5173 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5174 import_components12.SelectControl,
5175 {
5176 "aria-label": (0, import_i18n15.__)("Current page"),
5177 value: currentPage.toString(),
5178 options: pageSelectOptions,
5179 onChange: (newValue) => {
5180 onChangeView({
5181 ...view,
5182 page: +newValue
5183 });
5184 },
5185 size: "small",
5186 variant: "minimal"
5187 }
5188 )
5189 }
5190 )
5191 }
5192 ),
5193 /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
5194 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5195 import_components12.Button,
5196 {
5197 onClick: () => onChangeView({
5198 ...view,
5199 page: currentPage - 1
5200 }),
5201 disabled: currentPage === 1,
5202 accessibleWhenDisabled: true,
5203 label: (0, import_i18n15.__)("Previous page"),
5204 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
5205 showTooltip: true,
5206 size: "compact",
5207 tooltipPosition: "top"
5208 }
5209 ),
5210 /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
5211 import_components12.Button,
5212 {
5213 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
5214 disabled: currentPage >= totalPages,
5215 accessibleWhenDisabled: true,
5216 label: (0, import_i18n15.__)("Next page"),
5217 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
5218 showTooltip: true,
5219 size: "compact",
5220 tooltipPosition: "top"
5221 }
5222 )
5223 ] })
5224 ]
5225 }
5226 );
5227 }
5228 var dataviews_pagination_default = (0, import_element21.memo)(DataViewsPagination);
5229
5230 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
5231 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
5232 function useIsMultiselectPicker(actions) {
5233 return (0, import_element22.useMemo)(() => {
5234 return actions?.every((action) => action.supportsBulk);
5235 }, [actions]);
5236 }
5237
5238 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
5239 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
5240 var { Badge: WCBadge2 } = unlock2(import_components14.privateApis);
5241 function GridItem3({
5242 view,
5243 multiselect,
5244 selection,
5245 onChangeSelection,
5246 getItemId,
5247 item,
5248 mediaField,
5249 titleField,
5250 descriptionField,
5251 regularFields,
5252 badgeFields,
5253 config,
5254 posinset,
5255 setsize
5256 }) {
5257 const { showTitle = true, showMedia = true, showDescription = true } = view;
5258 const id = getItemId(item);
5259 const elementRef = (0, import_element23.useRef)(null);
5260 const isSelected2 = selection.includes(id);
5261 useIntersectionObserver(elementRef, posinset);
5262 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5263 mediaField.render,
5264 {
5265 item,
5266 field: mediaField,
5267 config
5268 }
5269 ) : null;
5270 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(titleField.render, { item, field: titleField }) : null;
5271 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5272 import_components14.Composite.Item,
5273 {
5274 ref: elementRef,
5275 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
5276 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Stack, { direction: "column", children, ...props }),
5277 role: "option",
5278 "aria-posinset": posinset,
5279 "aria-setsize": setsize,
5280 className: clsx_default("dataviews-view-picker-grid__card", {
5281 "is-selected": isSelected2
5282 }),
5283 "aria-selected": isSelected2,
5284 onClick: () => {
5285 if (isSelected2) {
5286 onChangeSelection(
5287 selection.filter((itemId) => id !== itemId)
5288 );
5289 } else {
5290 const newSelection = multiselect ? [...selection, id] : [id];
5291 onChangeSelection(newSelection);
5292 }
5293 },
5294 children: [
5295 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
5296 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5297 DataViewsSelectionCheckbox,
5298 {
5299 item,
5300 selection,
5301 onChangeSelection,
5302 getItemId,
5303 titleField,
5304 disabled: false,
5305 "aria-hidden": true,
5306 tabIndex: -1
5307 }
5308 ),
5309 showTitle && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5310 Stack,
5311 {
5312 direction: "row",
5313 justify: "space-between",
5314 className: "dataviews-view-picker-grid__title-actions",
5315 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
5316 }
5317 ),
5318 /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5319 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5320 descriptionField.render,
5321 {
5322 item,
5323 field: descriptionField
5324 }
5325 ),
5326 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5327 Stack,
5328 {
5329 direction: "row",
5330 className: "dataviews-view-picker-grid__badge-fields",
5331 gap: "sm",
5332 wrap: "wrap",
5333 align: "top",
5334 justify: "flex-start",
5335 children: badgeFields.map((field) => {
5336 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5337 WCBadge2,
5338 {
5339 className: "dataviews-view-picker-grid__field-value",
5340 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5341 field.render,
5342 {
5343 item,
5344 field
5345 }
5346 )
5347 },
5348 field.id
5349 );
5350 })
5351 }
5352 ),
5353 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5354 Stack,
5355 {
5356 direction: "column",
5357 className: "dataviews-view-picker-grid__fields",
5358 gap: "xs",
5359 children: regularFields.map((field) => {
5360 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5361 import_components14.Flex,
5362 {
5363 className: "dataviews-view-picker-grid__field",
5364 gap: 1,
5365 justify: "flex-start",
5366 expanded: true,
5367 style: { height: "auto" },
5368 direction: "row",
5369 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, { children: [
5370 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
5371 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5372 import_components14.FlexItem,
5373 {
5374 className: "dataviews-view-picker-grid__field-value",
5375 style: { maxHeight: "none" },
5376 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5377 field.render,
5378 {
5379 item,
5380 field
5381 }
5382 )
5383 }
5384 )
5385 ] })
5386 },
5387 field.id
5388 );
5389 })
5390 }
5391 )
5392 ] })
5393 ]
5394 },
5395 id
5396 );
5397 }
5398 function GridGroup({
5399 groupName,
5400 groupField,
5401 showLabel = true,
5402 children
5403 }) {
5404 const headerId = (0, import_compose6.useInstanceId)(
5405 GridGroup,
5406 "dataviews-view-picker-grid-group__header"
5407 );
5408 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5409 Stack,
5410 {
5411 direction: "column",
5412 gap: "sm",
5413 role: "group",
5414 "aria-labelledby": headerId,
5415 children: [
5416 /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5417 "h3",
5418 {
5419 className: "dataviews-view-picker-grid-group__header",
5420 id: headerId,
5421 children: showLabel ? (0, import_i18n17.sprintf)(
5422 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5423 (0, import_i18n17.__)("%1$s: %2$s"),
5424 groupField.label,
5425 groupName
5426 ) : groupName
5427 }
5428 ),
5429 children
5430 ]
5431 },
5432 groupName
5433 );
5434 }
5435 function ViewPickerGrid({
5436 actions,
5437 data,
5438 fields,
5439 getItemId,
5440 isLoading,
5441 onChangeSelection,
5442 selection,
5443 view,
5444 className,
5445 empty
5446 }) {
5447 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element23.useContext)(dataviews_context_default);
5448 const titleField = fields.find(
5449 (field) => field.id === view?.titleField
5450 );
5451 const mediaField = fields.find(
5452 (field) => field.id === view?.mediaField
5453 );
5454 const descriptionField = fields.find(
5455 (field) => field.id === view?.descriptionField
5456 );
5457 const otherFields = view.fields ?? [];
5458 const { regularFields, badgeFields } = otherFields.reduce(
5459 (accumulator, fieldId) => {
5460 const field = fields.find((f2) => f2.id === fieldId);
5461 if (!field) {
5462 return accumulator;
5463 }
5464 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5465 accumulator[key].push(field);
5466 return accumulator;
5467 },
5468 { regularFields: [], badgeFields: [] }
5469 );
5470 const hasData = !!data?.length;
5471 const usedPreviewSize = view.layout?.previewSize;
5472 const isMultiselect = useIsMultiselectPicker(actions);
5473 const size = "900px";
5474 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5475 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5476 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
5477 const currentPage = view?.page ?? 1;
5478 const perPage = view?.perPage ?? 0;
5479 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
5480 const gridColumns = useGridColumns();
5481 const placeholdersNeeded = usePlaceholdersNeeded(
5482 data,
5483 isInfiniteScroll,
5484 gridColumns
5485 );
5486 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(import_jsx_runtime42.Fragment, {
5487 // Render multiple groups.
5488 children: [
5489 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5490 import_components14.Composite,
5491 {
5492 virtualFocus: true,
5493 orientation: "horizontal",
5494 role: "listbox",
5495 "aria-multiselectable": isMultiselect,
5496 className: clsx_default(
5497 "dataviews-view-picker-grid",
5498 className,
5499 {
5500 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5501 view.layout.density
5502 )
5503 }
5504 ),
5505 "aria-label": itemListLabel,
5506 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5507 Stack,
5508 {
5509 direction: "column",
5510 gap: "lg",
5511 children,
5512 ...props
5513 }
5514 ),
5515 children: Array.from(dataByGroup.entries()).map(
5516 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5517 GridGroup,
5518 {
5519 groupName,
5520 groupField,
5521 showLabel: view.groupBy?.showLabel !== false,
5522 children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5523 GridItems,
5524 {
5525 previewSize: usedPreviewSize,
5526 style: {
5527 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
5528 },
5529 "aria-busy": isLoading,
5530 ref: resizeObserverRef,
5531 children: groupItems.map((item) => {
5532 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
5533 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5534 GridItem3,
5535 {
5536 view,
5537 multiselect: isMultiselect,
5538 selection,
5539 onChangeSelection,
5540 getItemId,
5541 item,
5542 mediaField,
5543 titleField,
5544 descriptionField,
5545 regularFields,
5546 badgeFields,
5547 config: {
5548 sizes: size
5549 },
5550 posinset: posInSet,
5551 setsize: setSize
5552 },
5553 getItemId(item)
5554 );
5555 })
5556 }
5557 )
5558 },
5559 groupName
5560 )
5561 )
5562 }
5563 ),
5564 // Render a single grid with all data.
5565 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
5566 import_components14.Composite,
5567 {
5568 render: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5569 GridItems,
5570 {
5571 className: clsx_default(
5572 "dataviews-view-picker-grid",
5573 className,
5574 {
5575 [`has-${view.layout?.density}-density`]: view.layout?.density && [
5576 "compact",
5577 "comfortable"
5578 ].includes(view.layout.density)
5579 }
5580 ),
5581 previewSize: usedPreviewSize,
5582 "aria-busy": isLoading,
5583 ref: resizeObserverRef
5584 }
5585 ),
5586 virtualFocus: true,
5587 orientation: "horizontal",
5588 role: "listbox",
5589 "aria-multiselectable": isMultiselect,
5590 "aria-label": itemListLabel,
5591 children: [
5592 Array.from({ length: placeholdersNeeded }).map(
5593 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5594 import_components14.Composite.Item,
5595 {
5596 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5597 Stack,
5598 {
5599 direction: "column",
5600 children,
5601 ...props
5602 }
5603 ),
5604 role: "option",
5605 "aria-hidden": true,
5606 tabIndex: -1,
5607 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
5608 },
5609 `placeholder-${index}`
5610 )
5611 ),
5612 data.map((item) => {
5613 const posinset = item.position;
5614 return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5615 GridItem3,
5616 {
5617 view,
5618 multiselect: isMultiselect,
5619 selection,
5620 onChangeSelection,
5621 getItemId,
5622 item,
5623 mediaField,
5624 titleField,
5625 descriptionField,
5626 regularFields,
5627 badgeFields,
5628 config: {
5629 sizes: size
5630 },
5631 posinset,
5632 setsize: setSize
5633 },
5634 getItemId(item)
5635 );
5636 })
5637 ]
5638 }
5639 ),
5640 // Render empty state.
5641 !hasData && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
5642 "div",
5643 {
5644 className: clsx_default({
5645 "dataviews-loading": isLoading,
5646 "dataviews-no-results": !isLoading
5647 }),
5648 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.Spinner, {}) }) : empty
5649 }
5650 ),
5651 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_components14.Spinner, {}) })
5652 ]
5653 });
5654 }
5655 var picker_grid_default = ViewPickerGrid;
5656
5657 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
5658 var import_i18n18 = __toESM(require_i18n(), 1);
5659 var import_components15 = __toESM(require_components(), 1);
5660 var import_element24 = __toESM(require_element(), 1);
5661 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
5662 function TableColumnField2({
5663 item,
5664 fields,
5665 column,
5666 align
5667 }) {
5668 const field = fields.find((f2) => f2.id === column);
5669 if (!field) {
5670 return null;
5671 }
5672 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5673 "dataviews-view-table__cell-align-end": align === "end",
5674 "dataviews-view-table__cell-align-center": align === "center"
5675 });
5676 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(field.render, { item, field }) });
5677 }
5678 function TableRow2({
5679 item,
5680 fields,
5681 id,
5682 view,
5683 titleField,
5684 mediaField,
5685 descriptionField,
5686 selection,
5687 getItemId,
5688 onChangeSelection,
5689 multiselect,
5690 posinset
5691 }) {
5692 const { paginationInfo } = (0, import_element24.useContext)(dataviews_context_default);
5693 const isSelected2 = selection.includes(id);
5694 const [isHovered, setIsHovered] = (0, import_element24.useState)(false);
5695 const elementRef = (0, import_element24.useRef)(null);
5696 useIntersectionObserver(elementRef, posinset);
5697 const {
5698 showTitle = true,
5699 showMedia = true,
5700 showDescription = true,
5701 infiniteScrollEnabled
5702 } = view;
5703 const handleMouseEnter = () => {
5704 setIsHovered(true);
5705 };
5706 const handleMouseLeave = () => {
5707 setIsHovered(false);
5708 };
5709 const columns = view.fields ?? [];
5710 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5711 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
5712 import_components15.Composite.Item,
5713 {
5714 ref: elementRef,
5715 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5716 "tr",
5717 {
5718 className: clsx_default("dataviews-view-table__row", {
5719 "is-selected": isSelected2,
5720 "is-hovered": isHovered
5721 }),
5722 onMouseEnter: handleMouseEnter,
5723 onMouseLeave: handleMouseLeave,
5724 children,
5725 ...props
5726 }
5727 ),
5728 "aria-selected": isSelected2,
5729 "aria-setsize": paginationInfo.totalItems || void 0,
5730 "aria-posinset": posinset,
5731 role: infiniteScrollEnabled ? "article" : "option",
5732 onClick: () => {
5733 if (isSelected2) {
5734 onChangeSelection(
5735 selection.filter((itemId) => id !== itemId)
5736 );
5737 } else {
5738 const newSelection = multiselect ? [...selection, id] : [id];
5739 onChangeSelection(newSelection);
5740 }
5741 },
5742 children: [
5743 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5744 "td",
5745 {
5746 className: "dataviews-view-table__checkbox-column",
5747 role: "presentation",
5748 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5749 DataViewsSelectionCheckbox,
5750 {
5751 item,
5752 selection,
5753 onChangeSelection,
5754 getItemId,
5755 titleField,
5756 disabled: false,
5757 "aria-hidden": true,
5758 tabIndex: -1
5759 }
5760 ) })
5761 }
5762 ),
5763 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5764 "td",
5765 {
5766 role: "presentation",
5767 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5768 column_primary_default,
5769 {
5770 item,
5771 titleField: showTitle ? titleField : void 0,
5772 mediaField: showMedia ? mediaField : void 0,
5773 descriptionField: showDescription ? descriptionField : void 0,
5774 isItemClickable: () => false
5775 }
5776 )
5777 }
5778 ),
5779 columns.map((column) => {
5780 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5781 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5782 "td",
5783 {
5784 style: {
5785 width,
5786 maxWidth,
5787 minWidth
5788 },
5789 role: "presentation",
5790 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5791 TableColumnField2,
5792 {
5793 fields,
5794 item,
5795 column,
5796 align
5797 }
5798 )
5799 },
5800 column
5801 );
5802 })
5803 ]
5804 },
5805 id
5806 );
5807 }
5808 function ViewPickerTable({
5809 actions,
5810 data,
5811 fields,
5812 getItemId,
5813 isLoading = false,
5814 onChangeView,
5815 onChangeSelection,
5816 selection,
5817 setOpenedFilter,
5818 view,
5819 className,
5820 empty
5821 }) {
5822 const headerMenuRefs = (0, import_element24.useRef)(/* @__PURE__ */ new Map());
5823 const headerMenuToFocusRef = (0, import_element24.useRef)(void 0);
5824 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element24.useState)();
5825 const isMultiselect = useIsMultiselectPicker(actions) ?? false;
5826 (0, import_element24.useEffect)(() => {
5827 if (headerMenuToFocusRef.current) {
5828 headerMenuToFocusRef.current.focus();
5829 headerMenuToFocusRef.current = void 0;
5830 }
5831 });
5832 const groupField = view.groupBy?.field ? fields.find((f2) => f2.id === view.groupBy?.field) : null;
5833 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5834 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5835 const tableNoticeId = (0, import_element24.useId)();
5836 if (nextHeaderMenuToFocus) {
5837 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
5838 setNextHeaderMenuToFocus(void 0);
5839 return;
5840 }
5841 const onHide = (field) => {
5842 const hidden = headerMenuRefs.current.get(field.id);
5843 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
5844 setNextHeaderMenuToFocus(fallback?.node);
5845 };
5846 const hasData = !!data?.length;
5847 const titleField = fields.find((field) => field.id === view.titleField);
5848 const mediaField = fields.find((field) => field.id === view.mediaField);
5849 const descriptionField = fields.find(
5850 (field) => field.id === view.descriptionField
5851 );
5852 const { showTitle = true, showMedia = true, showDescription = true } = view;
5853 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5854 const columns = view.fields ?? [];
5855 const headerMenuRef = (column, index) => (node) => {
5856 if (node) {
5857 headerMenuRefs.current.set(column, {
5858 node,
5859 fallback: columns[index > 0 ? index - 1 : 1]
5860 });
5861 } else {
5862 headerMenuRefs.current.delete(column);
5863 }
5864 };
5865 return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(import_jsx_runtime43.Fragment, { children: [
5866 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
5867 "table",
5868 {
5869 className: clsx_default(
5870 "dataviews-view-table",
5871 "dataviews-view-picker-table",
5872 className,
5873 {
5874 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5875 view.layout.density
5876 )
5877 }
5878 ),
5879 "aria-busy": isLoading,
5880 "aria-describedby": tableNoticeId,
5881 role: isInfiniteScroll ? "feed" : "listbox",
5882 children: [
5883 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
5884 "tr",
5885 {
5886 className: "dataviews-view-table__row",
5887 role: "presentation",
5888 children: [
5889 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5890 BulkSelectionCheckbox,
5891 {
5892 selection,
5893 onChangeSelection,
5894 data,
5895 actions,
5896 getItemId,
5897 disableSelectAll: isInfiniteScroll
5898 }
5899 ) }),
5900 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5901 column_header_menu_default,
5902 {
5903 ref: headerMenuRef(
5904 titleField.id,
5905 0
5906 ),
5907 fieldId: titleField.id,
5908 view,
5909 fields,
5910 onChangeView,
5911 onHide,
5912 setOpenedFilter,
5913 canMove: false
5914 }
5915 ) }),
5916 columns.map((column, index) => {
5917 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5918 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5919 "th",
5920 {
5921 style: {
5922 width,
5923 maxWidth,
5924 minWidth,
5925 textAlign: align
5926 },
5927 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
5928 scope: "col",
5929 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5930 column_header_menu_default,
5931 {
5932 ref: headerMenuRef(column, index),
5933 fieldId: column,
5934 view,
5935 fields,
5936 onChangeView,
5937 onHide,
5938 setOpenedFilter,
5939 canMove: view.layout?.enableMoving ?? true
5940 }
5941 )
5942 },
5943 column
5944 );
5945 })
5946 ]
5947 }
5948 ) }),
5949 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
5950 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
5951 import_components15.Composite,
5952 {
5953 virtualFocus: true,
5954 orientation: "vertical",
5955 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tbody", { role: "group" }),
5956 children: [
5957 /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5958 "tr",
5959 {
5960 className: "dataviews-view-table__group-header-row",
5961 role: "presentation",
5962 children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5963 "td",
5964 {
5965 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
5966 className: "dataviews-view-table__group-header-cell",
5967 role: "presentation",
5968 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
5969 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5970 (0, import_i18n18.__)("%1$s: %2$s"),
5971 groupField.label,
5972 groupName
5973 )
5974 }
5975 )
5976 }
5977 ),
5978 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
5979 TableRow2,
5980 {
5981 item,
5982 fields,
5983 id: getItemId(item) || index.toString(),
5984 view,
5985 titleField,
5986 mediaField,
5987 descriptionField,
5988 selection,
5989 getItemId,
5990 onChangeSelection,
5991 multiselect: isMultiselect
5992 },
5993 getItemId(item)
5994 ))
5995 ]
5996 },
5997 `group-${groupName}`
5998 )
5999 ) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6000 import_components15.Composite,
6001 {
6002 render: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("tbody", { role: "presentation" }),
6003 virtualFocus: true,
6004 orientation: "vertical",
6005 children: hasData && data.map((item, index) => {
6006 const itemId = getItemId(item);
6007 const posinset = item.position;
6008 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
6009 TableRow2,
6010 {
6011 item,
6012 fields,
6013 id: itemId || index.toString(),
6014 view,
6015 titleField,
6016 mediaField,
6017 descriptionField,
6018 selection,
6019 getItemId,
6020 onChangeSelection,
6021 multiselect: isMultiselect,
6022 posinset
6023 },
6024 itemId
6025 );
6026 })
6027 }
6028 )
6029 ]
6030 }
6031 ),
6032 /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
6033 "div",
6034 {
6035 className: clsx_default({
6036 "dataviews-loading": isLoading,
6037 "dataviews-no-results": !hasData && !isLoading
6038 }),
6039 id: tableNoticeId,
6040 children: [
6041 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components15.Spinner, {}) }) : empty),
6042 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_components15.Spinner, {}) })
6043 ]
6044 }
6045 )
6046 ] });
6047 }
6048 var picker_table_default = ViewPickerTable;
6049
6050 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
6051 var import_components16 = __toESM(require_components(), 1);
6052 var import_i18n19 = __toESM(require_i18n(), 1);
6053 var import_element25 = __toESM(require_element(), 1);
6054 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
6055 function DensityPicker() {
6056 const context = (0, import_element25.useContext)(dataviews_context_default);
6057 const view = context.view;
6058 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
6059 import_components16.__experimentalToggleGroupControl,
6060 {
6061 size: "__unstable-large",
6062 label: (0, import_i18n19.__)("Density"),
6063 value: view.layout?.density || "balanced",
6064 onChange: (value) => {
6065 context.onChangeView({
6066 ...view,
6067 layout: {
6068 ...view.layout,
6069 density: value
6070 }
6071 });
6072 },
6073 isBlock: true,
6074 children: [
6075 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6076 import_components16.__experimentalToggleGroupControlOption,
6077 {
6078 value: "comfortable",
6079 label: (0, import_i18n19._x)(
6080 "Comfortable",
6081 "Density option for DataView layout"
6082 )
6083 },
6084 "comfortable"
6085 ),
6086 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6087 import_components16.__experimentalToggleGroupControlOption,
6088 {
6089 value: "balanced",
6090 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout")
6091 },
6092 "balanced"
6093 ),
6094 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
6095 import_components16.__experimentalToggleGroupControlOption,
6096 {
6097 value: "compact",
6098 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout")
6099 },
6100 "compact"
6101 )
6102 ]
6103 }
6104 );
6105 }
6106
6107 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
6108 var import_components17 = __toESM(require_components(), 1);
6109 var import_i18n20 = __toESM(require_i18n(), 1);
6110 var import_element26 = __toESM(require_element(), 1);
6111 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
6112 var imageSizes2 = [
6113 {
6114 value: 120,
6115 breakpoint: 1
6116 },
6117 {
6118 value: 170,
6119 breakpoint: 1
6120 },
6121 {
6122 value: 230,
6123 breakpoint: 1
6124 },
6125 {
6126 value: 290,
6127 breakpoint: 1112
6128 // at minimum image width, 4 images display at this container size
6129 },
6130 {
6131 value: 350,
6132 breakpoint: 1636
6133 // at minimum image width, 6 images display at this container size
6134 },
6135 {
6136 value: 430,
6137 breakpoint: 588
6138 // at minimum image width, 2 images display at this container size
6139 }
6140 ];
6141 function PreviewSizePicker() {
6142 const context = (0, import_element26.useContext)(dataviews_context_default);
6143 const view = context.view;
6144 const breakValues = imageSizes2.filter((size) => {
6145 return context.containerWidth >= size.breakpoint;
6146 });
6147 const layoutPreviewSize = view.layout?.previewSize ?? 230;
6148 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
6149 const marks = breakValues.map((size, index) => {
6150 return {
6151 value: index
6152 };
6153 });
6154 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
6155 import_components17.RangeControl,
6156 {
6157 __next40pxDefaultSize: true,
6158 showTooltip: false,
6159 label: (0, import_i18n20.__)("Preview size"),
6160 value: previewSizeToUse,
6161 min: 0,
6162 max: breakValues.length - 1,
6163 withInputField: false,
6164 onChange: (value = 0) => {
6165 context.onChangeView({
6166 ...view,
6167 layout: {
6168 ...view.layout,
6169 previewSize: breakValues[value].value
6170 }
6171 });
6172 },
6173 step: 1,
6174 marks
6175 }
6176 );
6177 }
6178
6179 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
6180 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
6181 function GridConfigOptions() {
6182 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_jsx_runtime46.Fragment, { children: [
6183 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(DensityPicker, {}),
6184 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PreviewSizePicker, {})
6185 ] });
6186 }
6187
6188 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
6189 var VIEW_LAYOUTS = [
6190 {
6191 type: LAYOUT_TABLE,
6192 label: (0, import_i18n21.__)("Table"),
6193 component: table_default,
6194 icon: block_table_default,
6195 viewConfigOptions: DensityPicker
6196 },
6197 {
6198 type: LAYOUT_GRID,
6199 label: (0, import_i18n21.__)("Grid"),
6200 component: grid_default,
6201 icon: category_default,
6202 viewConfigOptions: GridConfigOptions
6203 },
6204 {
6205 type: LAYOUT_LIST,
6206 label: (0, import_i18n21.__)("List"),
6207 component: ViewList,
6208 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
6209 viewConfigOptions: DensityPicker
6210 },
6211 {
6212 type: LAYOUT_ACTIVITY,
6213 label: (0, import_i18n21.__)("Activity"),
6214 component: ViewActivity,
6215 icon: scheduled_default,
6216 viewConfigOptions: DensityPicker
6217 },
6218 {
6219 type: LAYOUT_PICKER_GRID,
6220 label: (0, import_i18n21.__)("Grid"),
6221 component: picker_grid_default,
6222 icon: category_default,
6223 viewConfigOptions: GridConfigOptions,
6224 isPicker: true
6225 },
6226 {
6227 type: LAYOUT_PICKER_TABLE,
6228 label: (0, import_i18n21.__)("Table"),
6229 component: picker_table_default,
6230 icon: block_table_default,
6231 viewConfigOptions: DensityPicker,
6232 isPicker: true
6233 }
6234 ];
6235
6236 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
6237 var import_element34 = __toESM(require_element(), 1);
6238
6239 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
6240 var import_components20 = __toESM(require_components(), 1);
6241 var import_i18n24 = __toESM(require_i18n(), 1);
6242 var import_element31 = __toESM(require_element(), 1);
6243
6244 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
6245 function noop(..._) {
6246 }
6247 function applyState(argument, currentValue) {
6248 if (isUpdater(argument)) {
6249 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
6250 return argument(value);
6251 }
6252 return argument;
6253 }
6254 function isUpdater(argument) {
6255 return typeof argument === "function";
6256 }
6257 function isLazyValue(value) {
6258 return typeof value === "function";
6259 }
6260 function hasOwnProperty(object, prop) {
6261 if (typeof Object.hasOwn === "function") {
6262 return Object.hasOwn(object, prop);
6263 }
6264 return Object.prototype.hasOwnProperty.call(object, prop);
6265 }
6266 function chain(...fns) {
6267 return (...args) => {
6268 for (const fn of fns) {
6269 if (typeof fn === "function") {
6270 fn(...args);
6271 }
6272 }
6273 };
6274 }
6275 function normalizeString(str) {
6276 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
6277 }
6278 function omit2(object, keys) {
6279 const result = { ...object };
6280 for (const key of keys) {
6281 if (hasOwnProperty(result, key)) {
6282 delete result[key];
6283 }
6284 }
6285 return result;
6286 }
6287 function pick(object, paths) {
6288 const result = {};
6289 for (const key of paths) {
6290 if (hasOwnProperty(object, key)) {
6291 result[key] = object[key];
6292 }
6293 }
6294 return result;
6295 }
6296 function identity(value) {
6297 return value;
6298 }
6299 function invariant(condition, message2) {
6300 if (condition) return;
6301 if (typeof message2 !== "string") throw new Error("Invariant failed");
6302 throw new Error(message2);
6303 }
6304 function getKeys(obj) {
6305 return Object.keys(obj);
6306 }
6307 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
6308 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
6309 if (result == null) return false;
6310 return !result;
6311 }
6312 function disabledFromProps(props) {
6313 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
6314 }
6315 function removeUndefinedValues(obj) {
6316 const result = {};
6317 for (const key in obj) {
6318 if (obj[key] !== void 0) {
6319 result[key] = obj[key];
6320 }
6321 }
6322 return result;
6323 }
6324 function defaultValue(...values) {
6325 for (const value of values) {
6326 if (value !== void 0) return value;
6327 }
6328 return void 0;
6329 }
6330
6331 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
6332 var import_react6 = __toESM(require_react(), 1);
6333 function setRef(ref, value) {
6334 if (typeof ref === "function") {
6335 ref(value);
6336 } else if (ref) {
6337 ref.current = value;
6338 }
6339 }
6340 function isValidElementWithRef(element) {
6341 if (!element) return false;
6342 if (!(0, import_react6.isValidElement)(element)) return false;
6343 if ("ref" in element.props) return true;
6344 if ("ref" in element) return true;
6345 return false;
6346 }
6347 function getRefProperty(element) {
6348 if (!isValidElementWithRef(element)) return null;
6349 const props = { ...element.props };
6350 return props.ref || element.ref;
6351 }
6352 function mergeProps2(base, overrides) {
6353 const props = { ...base };
6354 for (const key in overrides) {
6355 if (!hasOwnProperty(overrides, key)) continue;
6356 if (key === "className") {
6357 const prop = "className";
6358 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
6359 continue;
6360 }
6361 if (key === "style") {
6362 const prop = "style";
6363 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
6364 continue;
6365 }
6366 const overrideValue = overrides[key];
6367 if (typeof overrideValue === "function" && key.startsWith("on")) {
6368 const baseValue = base[key];
6369 if (typeof baseValue === "function") {
6370 props[key] = (...args) => {
6371 overrideValue(...args);
6372 baseValue(...args);
6373 };
6374 continue;
6375 }
6376 }
6377 props[key] = overrideValue;
6378 }
6379 return props;
6380 }
6381
6382 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
6383 var canUseDOM = checkIsBrowser();
6384 function checkIsBrowser() {
6385 var _a;
6386 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
6387 }
6388 function getDocument(node) {
6389 if (!node) return document;
6390 if ("self" in node) return node.document;
6391 return node.ownerDocument || document;
6392 }
6393 function getActiveElement(node, activeDescendant = false) {
6394 var _a;
6395 const { activeElement } = getDocument(node);
6396 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
6397 return null;
6398 }
6399 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
6400 return getActiveElement(
6401 activeElement.contentDocument.body,
6402 activeDescendant
6403 );
6404 }
6405 if (activeDescendant) {
6406 const id = activeElement.getAttribute("aria-activedescendant");
6407 if (id) {
6408 const element = getDocument(activeElement).getElementById(id);
6409 if (element) {
6410 return element;
6411 }
6412 }
6413 }
6414 return activeElement;
6415 }
6416 function contains(parent, child) {
6417 return parent === child || parent.contains(child);
6418 }
6419 function isFrame(element) {
6420 return element.tagName === "IFRAME";
6421 }
6422 function isButton(element) {
6423 const tagName = element.tagName.toLowerCase();
6424 if (tagName === "button") return true;
6425 if (tagName === "input" && element.type) {
6426 return buttonInputTypes.indexOf(element.type) !== -1;
6427 }
6428 return false;
6429 }
6430 var buttonInputTypes = [
6431 "button",
6432 "color",
6433 "file",
6434 "image",
6435 "reset",
6436 "submit"
6437 ];
6438 function isVisible(element) {
6439 if (typeof element.checkVisibility === "function") {
6440 return element.checkVisibility();
6441 }
6442 const htmlElement = element;
6443 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
6444 }
6445 function isTextField(element) {
6446 try {
6447 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
6448 const isTextArea = element.tagName === "TEXTAREA";
6449 return isTextInput || isTextArea || false;
6450 } catch (_error) {
6451 return false;
6452 }
6453 }
6454 function isTextbox(element) {
6455 return element.isContentEditable || isTextField(element);
6456 }
6457 function getTextboxValue(element) {
6458 if (isTextField(element)) {
6459 return element.value;
6460 }
6461 if (element.isContentEditable) {
6462 const range = getDocument(element).createRange();
6463 range.selectNodeContents(element);
6464 return range.toString();
6465 }
6466 return "";
6467 }
6468 function getTextboxSelection(element) {
6469 let start = 0;
6470 let end = 0;
6471 if (isTextField(element)) {
6472 start = element.selectionStart || 0;
6473 end = element.selectionEnd || 0;
6474 } else if (element.isContentEditable) {
6475 const selection = getDocument(element).getSelection();
6476 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
6477 const range = selection.getRangeAt(0);
6478 const nextRange = range.cloneRange();
6479 nextRange.selectNodeContents(element);
6480 nextRange.setEnd(range.startContainer, range.startOffset);
6481 start = nextRange.toString().length;
6482 nextRange.setEnd(range.endContainer, range.endOffset);
6483 end = nextRange.toString().length;
6484 }
6485 }
6486 return { start, end };
6487 }
6488 function getPopupRole(element, fallback) {
6489 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
6490 const role = element == null ? void 0 : element.getAttribute("role");
6491 if (role && allowedPopupRoles.indexOf(role) !== -1) {
6492 return role;
6493 }
6494 return fallback;
6495 }
6496 function getScrollingElement(element) {
6497 if (!element) return null;
6498 const isScrollableOverflow = (overflow) => {
6499 if (overflow === "auto") return true;
6500 if (overflow === "scroll") return true;
6501 return false;
6502 };
6503 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
6504 const { overflowY } = getComputedStyle(element);
6505 if (isScrollableOverflow(overflowY)) return element;
6506 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
6507 const { overflowX } = getComputedStyle(element);
6508 if (isScrollableOverflow(overflowX)) return element;
6509 }
6510 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
6511 }
6512 function setSelectionRange(element, ...args) {
6513 if (/text|search|password|tel|url/i.test(element.type)) {
6514 element.setSelectionRange(...args);
6515 }
6516 }
6517 function sortBasedOnDOMPosition(items, getElement) {
6518 const pairs = items.map((item, index) => [index, item]);
6519 let isOrderDifferent = false;
6520 pairs.sort(([indexA, a2], [indexB, b2]) => {
6521 const elementA = getElement(a2);
6522 const elementB = getElement(b2);
6523 if (elementA === elementB) return 0;
6524 if (!elementA || !elementB) return 0;
6525 if (isElementPreceding(elementA, elementB)) {
6526 if (indexA > indexB) {
6527 isOrderDifferent = true;
6528 }
6529 return -1;
6530 }
6531 if (indexA < indexB) {
6532 isOrderDifferent = true;
6533 }
6534 return 1;
6535 });
6536 if (isOrderDifferent) {
6537 return pairs.map(([_, item]) => item);
6538 }
6539 return items;
6540 }
6541 function isElementPreceding(a2, b2) {
6542 return Boolean(
6543 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
6544 );
6545 }
6546
6547 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
6548 function isTouchDevice() {
6549 return canUseDOM && !!navigator.maxTouchPoints;
6550 }
6551 function isApple() {
6552 if (!canUseDOM) return false;
6553 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
6554 }
6555 function isSafari() {
6556 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
6557 }
6558 function isFirefox() {
6559 return canUseDOM && /firefox\//i.test(navigator.userAgent);
6560 }
6561
6562 // node_modules/@ariakit/core/esm/utils/events.js
6563 function isPortalEvent(event) {
6564 return Boolean(
6565 event.currentTarget && !contains(event.currentTarget, event.target)
6566 );
6567 }
6568 function isSelfTarget(event) {
6569 return event.target === event.currentTarget;
6570 }
6571 function isOpeningInNewTab(event) {
6572 const element = event.currentTarget;
6573 if (!element) return false;
6574 const isAppleDevice = isApple();
6575 if (isAppleDevice && !event.metaKey) return false;
6576 if (!isAppleDevice && !event.ctrlKey) return false;
6577 const tagName = element.tagName.toLowerCase();
6578 if (tagName === "a") return true;
6579 if (tagName === "button" && element.type === "submit") return true;
6580 if (tagName === "input" && element.type === "submit") return true;
6581 return false;
6582 }
6583 function isDownloading(event) {
6584 const element = event.currentTarget;
6585 if (!element) return false;
6586 const tagName = element.tagName.toLowerCase();
6587 if (!event.altKey) return false;
6588 if (tagName === "a") return true;
6589 if (tagName === "button" && element.type === "submit") return true;
6590 if (tagName === "input" && element.type === "submit") return true;
6591 return false;
6592 }
6593 function fireBlurEvent(element, eventInit) {
6594 const event = new FocusEvent("blur", eventInit);
6595 const defaultAllowed = element.dispatchEvent(event);
6596 const bubbleInit = { ...eventInit, bubbles: true };
6597 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
6598 return defaultAllowed;
6599 }
6600 function fireKeyboardEvent(element, type, eventInit) {
6601 const event = new KeyboardEvent(type, eventInit);
6602 return element.dispatchEvent(event);
6603 }
6604 function fireClickEvent(element, eventInit) {
6605 const event = new MouseEvent("click", eventInit);
6606 return element.dispatchEvent(event);
6607 }
6608 function isFocusEventOutside(event, container) {
6609 const containerElement = container || event.currentTarget;
6610 const relatedTarget = event.relatedTarget;
6611 return !relatedTarget || !contains(containerElement, relatedTarget);
6612 }
6613 function queueBeforeEvent(element, type, callback, timeout) {
6614 const createTimer = (callback2) => {
6615 if (timeout) {
6616 const timerId2 = setTimeout(callback2, timeout);
6617 return () => clearTimeout(timerId2);
6618 }
6619 const timerId = requestAnimationFrame(callback2);
6620 return () => cancelAnimationFrame(timerId);
6621 };
6622 const cancelTimer = createTimer(() => {
6623 element.removeEventListener(type, callSync, true);
6624 callback();
6625 });
6626 const callSync = () => {
6627 cancelTimer();
6628 callback();
6629 };
6630 element.addEventListener(type, callSync, { once: true, capture: true });
6631 return cancelTimer;
6632 }
6633 function addGlobalEventListener(type, listener, options, scope = window) {
6634 const children = [];
6635 try {
6636 scope.document.addEventListener(type, listener, options);
6637 for (const frame of Array.from(scope.frames)) {
6638 children.push(addGlobalEventListener(type, listener, options, frame));
6639 }
6640 } catch (e2) {
6641 }
6642 const removeEventListener = () => {
6643 try {
6644 scope.document.removeEventListener(type, listener, options);
6645 } catch (e2) {
6646 }
6647 for (const remove of children) {
6648 remove();
6649 }
6650 };
6651 return removeEventListener;
6652 }
6653
6654 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
6655 var React6 = __toESM(require_react(), 1);
6656 var import_react7 = __toESM(require_react(), 1);
6657 var _React = { ...React6 };
6658 var useReactId = _React.useId;
6659 var useReactDeferredValue = _React.useDeferredValue;
6660 var useReactInsertionEffect = _React.useInsertionEffect;
6661 var useSafeLayoutEffect = canUseDOM ? import_react7.useLayoutEffect : import_react7.useEffect;
6662 function useInitialValue(value) {
6663 const [initialValue] = (0, import_react7.useState)(value);
6664 return initialValue;
6665 }
6666 function useLiveRef(value) {
6667 const ref = (0, import_react7.useRef)(value);
6668 useSafeLayoutEffect(() => {
6669 ref.current = value;
6670 });
6671 return ref;
6672 }
6673 function useEvent(callback) {
6674 const ref = (0, import_react7.useRef)(() => {
6675 throw new Error("Cannot call an event handler while rendering.");
6676 });
6677 if (useReactInsertionEffect) {
6678 useReactInsertionEffect(() => {
6679 ref.current = callback;
6680 });
6681 } else {
6682 ref.current = callback;
6683 }
6684 return (0, import_react7.useCallback)((...args) => {
6685 var _a;
6686 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
6687 }, []);
6688 }
6689 function useTransactionState(callback) {
6690 const [state, setState] = (0, import_react7.useState)(null);
6691 useSafeLayoutEffect(() => {
6692 if (state == null) return;
6693 if (!callback) return;
6694 let prevState = null;
6695 callback((prev) => {
6696 prevState = prev;
6697 return state;
6698 });
6699 return () => {
6700 callback(prevState);
6701 };
6702 }, [state, callback]);
6703 return [state, setState];
6704 }
6705 function useMergeRefs(...refs) {
6706 return (0, import_react7.useMemo)(() => {
6707 if (!refs.some(Boolean)) return;
6708 return (value) => {
6709 for (const ref of refs) {
6710 setRef(ref, value);
6711 }
6712 };
6713 }, refs);
6714 }
6715 function useId3(defaultId) {
6716 if (useReactId) {
6717 const reactId = useReactId();
6718 if (defaultId) return defaultId;
6719 return reactId;
6720 }
6721 const [id, setId] = (0, import_react7.useState)(defaultId);
6722 useSafeLayoutEffect(() => {
6723 if (defaultId || id) return;
6724 const random = Math.random().toString(36).slice(2, 8);
6725 setId(`id-${random}`);
6726 }, [defaultId, id]);
6727 return defaultId || id;
6728 }
6729 function useTagName(refOrElement, type) {
6730 const stringOrUndefined = (type2) => {
6731 if (typeof type2 !== "string") return;
6732 return type2;
6733 };
6734 const [tagName, setTagName] = (0, import_react7.useState)(() => stringOrUndefined(type));
6735 useSafeLayoutEffect(() => {
6736 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6737 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
6738 }, [refOrElement, type]);
6739 return tagName;
6740 }
6741 function useAttribute(refOrElement, attributeName, defaultValue2) {
6742 const initialValue = useInitialValue(defaultValue2);
6743 const [attribute, setAttribute] = (0, import_react7.useState)(initialValue);
6744 (0, import_react7.useEffect)(() => {
6745 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
6746 if (!element) return;
6747 const callback = () => {
6748 const value = element.getAttribute(attributeName);
6749 setAttribute(value == null ? initialValue : value);
6750 };
6751 const observer = new MutationObserver(callback);
6752 observer.observe(element, { attributeFilter: [attributeName] });
6753 callback();
6754 return () => observer.disconnect();
6755 }, [refOrElement, attributeName, initialValue]);
6756 return attribute;
6757 }
6758 function useUpdateEffect(effect, deps) {
6759 const mounted = (0, import_react7.useRef)(false);
6760 (0, import_react7.useEffect)(() => {
6761 if (mounted.current) {
6762 return effect();
6763 }
6764 mounted.current = true;
6765 }, deps);
6766 (0, import_react7.useEffect)(
6767 () => () => {
6768 mounted.current = false;
6769 },
6770 []
6771 );
6772 }
6773 function useUpdateLayoutEffect(effect, deps) {
6774 const mounted = (0, import_react7.useRef)(false);
6775 useSafeLayoutEffect(() => {
6776 if (mounted.current) {
6777 return effect();
6778 }
6779 mounted.current = true;
6780 }, deps);
6781 useSafeLayoutEffect(
6782 () => () => {
6783 mounted.current = false;
6784 },
6785 []
6786 );
6787 }
6788 function useForceUpdate() {
6789 return (0, import_react7.useReducer)(() => [], []);
6790 }
6791 function useBooleanEvent(booleanOrCallback) {
6792 return useEvent(
6793 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
6794 );
6795 }
6796 function useWrapElement(props, callback, deps = []) {
6797 const wrapElement = (0, import_react7.useCallback)(
6798 (element) => {
6799 if (props.wrapElement) {
6800 element = props.wrapElement(element);
6801 }
6802 return callback(element);
6803 },
6804 [...deps, props.wrapElement]
6805 );
6806 return { ...props, wrapElement };
6807 }
6808 function useMetadataProps(props, key, value) {
6809 const parent = props.onLoadedMetadataCapture;
6810 const onLoadedMetadataCapture = (0, import_react7.useMemo)(() => {
6811 return Object.assign(() => {
6812 }, { ...parent, [key]: value });
6813 }, [parent, key, value]);
6814 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
6815 }
6816 var hasInstalledGlobalEventListeners = false;
6817 function useIsMouseMoving() {
6818 (0, import_react7.useEffect)(() => {
6819 if (hasInstalledGlobalEventListeners) return;
6820 addGlobalEventListener("mousemove", setMouseMoving, true);
6821 addGlobalEventListener("mousedown", resetMouseMoving, true);
6822 addGlobalEventListener("mouseup", resetMouseMoving, true);
6823 addGlobalEventListener("keydown", resetMouseMoving, true);
6824 addGlobalEventListener("scroll", resetMouseMoving, true);
6825 hasInstalledGlobalEventListeners = true;
6826 }, []);
6827 const isMouseMoving = useEvent(() => mouseMoving);
6828 return isMouseMoving;
6829 }
6830 var mouseMoving = false;
6831 var previousScreenX = 0;
6832 var previousScreenY = 0;
6833 function hasMouseMovement(event) {
6834 const movementX = event.movementX || event.screenX - previousScreenX;
6835 const movementY = event.movementY || event.screenY - previousScreenY;
6836 previousScreenX = event.screenX;
6837 previousScreenY = event.screenY;
6838 return movementX || movementY || false;
6839 }
6840 function setMouseMoving(event) {
6841 if (!hasMouseMovement(event)) return;
6842 mouseMoving = true;
6843 }
6844 function resetMouseMoving() {
6845 mouseMoving = false;
6846 }
6847
6848 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
6849 var React7 = __toESM(require_react(), 1);
6850 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
6851 function forwardRef22(render4) {
6852 const Role = React7.forwardRef(
6853 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6854 (props, ref) => render4({ ...props, ref })
6855 );
6856 Role.displayName = render4.displayName || render4.name;
6857 return Role;
6858 }
6859 function memo22(Component, propsAreEqual) {
6860 return React7.memo(Component, propsAreEqual);
6861 }
6862 function createElement3(Type, props) {
6863 const { wrapElement, render: render4, ...rest } = props;
6864 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
6865 let element;
6866 if (React7.isValidElement(render4)) {
6867 const renderProps = {
6868 // @ts-ignore Incompatible with React 19 types. Ignore for now.
6869 ...render4.props,
6870 ref: mergedRef
6871 };
6872 element = React7.cloneElement(render4, mergeProps2(rest, renderProps));
6873 } else if (render4) {
6874 element = render4(rest);
6875 } else {
6876 element = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Type, { ...rest });
6877 }
6878 if (wrapElement) {
6879 return wrapElement(element);
6880 }
6881 return element;
6882 }
6883 function createHook(useProps) {
6884 const useRole = (props = {}) => {
6885 return useProps(props);
6886 };
6887 useRole.displayName = useProps.name;
6888 return useRole;
6889 }
6890 function createStoreContext(providers = [], scopedProviders = []) {
6891 const context = React7.createContext(void 0);
6892 const scopedContext = React7.createContext(void 0);
6893 const useContext29 = () => React7.useContext(context);
6894 const useScopedContext = (onlyScoped = false) => {
6895 const scoped = React7.useContext(scopedContext);
6896 const store = useContext29();
6897 if (onlyScoped) return scoped;
6898 return scoped || store;
6899 };
6900 const useProviderContext = () => {
6901 const scoped = React7.useContext(scopedContext);
6902 const store = useContext29();
6903 if (scoped && scoped === store) return;
6904 return store;
6905 };
6906 const ContextProvider = (props) => {
6907 return providers.reduceRight(
6908 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Provider, { ...props, children }),
6909 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(context.Provider, { ...props })
6910 );
6911 };
6912 const ScopedContextProvider = (props) => {
6913 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
6914 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(Provider, { ...props, children }),
6915 /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(scopedContext.Provider, { ...props })
6916 ) });
6917 };
6918 return {
6919 context,
6920 scopedContext,
6921 useContext: useContext29,
6922 useScopedContext,
6923 useProviderContext,
6924 ContextProvider,
6925 ScopedContextProvider
6926 };
6927 }
6928
6929 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
6930 var ctx = createStoreContext();
6931 var useCollectionContext = ctx.useContext;
6932 var useCollectionScopedContext = ctx.useScopedContext;
6933 var useCollectionProviderContext = ctx.useProviderContext;
6934 var CollectionContextProvider = ctx.ContextProvider;
6935 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
6936
6937 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
6938 var import_react8 = __toESM(require_react(), 1);
6939 var ctx2 = createStoreContext(
6940 [CollectionContextProvider],
6941 [CollectionScopedContextProvider]
6942 );
6943 var useCompositeContext = ctx2.useContext;
6944 var useCompositeScopedContext = ctx2.useScopedContext;
6945 var useCompositeProviderContext = ctx2.useProviderContext;
6946 var CompositeContextProvider = ctx2.ContextProvider;
6947 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
6948 var CompositeItemContext = (0, import_react8.createContext)(
6949 void 0
6950 );
6951 var CompositeRowContext = (0, import_react8.createContext)(
6952 void 0
6953 );
6954
6955 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
6956 function findFirstEnabledItem(items, excludeId) {
6957 return items.find((item) => {
6958 if (excludeId) {
6959 return !item.disabled && item.id !== excludeId;
6960 }
6961 return !item.disabled;
6962 });
6963 }
6964 function getEnabledItem(store, id) {
6965 if (!id) return null;
6966 return store.item(id) || null;
6967 }
6968 function groupItemsByRows(items) {
6969 const rows = [];
6970 for (const item of items) {
6971 const row = rows.find((currentRow) => {
6972 var _a;
6973 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
6974 });
6975 if (row) {
6976 row.push(item);
6977 } else {
6978 rows.push([item]);
6979 }
6980 }
6981 return rows;
6982 }
6983 function selectTextField(element, collapseToEnd = false) {
6984 if (isTextField(element)) {
6985 element.setSelectionRange(
6986 collapseToEnd ? element.value.length : 0,
6987 element.value.length
6988 );
6989 } else if (element.isContentEditable) {
6990 const selection = getDocument(element).getSelection();
6991 selection == null ? void 0 : selection.selectAllChildren(element);
6992 if (collapseToEnd) {
6993 selection == null ? void 0 : selection.collapseToEnd();
6994 }
6995 }
6996 }
6997 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
6998 function focusSilently(element) {
6999 element[FOCUS_SILENTLY] = true;
7000 element.focus({ preventScroll: true });
7001 }
7002 function silentlyFocused(element) {
7003 const isSilentlyFocused = element[FOCUS_SILENTLY];
7004 delete element[FOCUS_SILENTLY];
7005 return isSilentlyFocused;
7006 }
7007 function isItem(store, element, exclude) {
7008 if (!element) return false;
7009 if (element === exclude) return false;
7010 const item = store.item(element.id);
7011 if (!item) return false;
7012 if (exclude && item.element === exclude) return false;
7013 return true;
7014 }
7015
7016 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
7017 var import_react9 = __toESM(require_react(), 1);
7018 var TagName = "div";
7019 var useCollectionItem = createHook(
7020 function useCollectionItem2({
7021 store,
7022 shouldRegisterItem = true,
7023 getItem = identity,
7024 // @ts-expect-error This prop may come from a collection renderer.
7025 element,
7026 ...props
7027 }) {
7028 const context = useCollectionContext();
7029 store = store || context;
7030 const id = useId3(props.id);
7031 const ref = (0, import_react9.useRef)(element);
7032 (0, import_react9.useEffect)(() => {
7033 const element2 = ref.current;
7034 if (!id) return;
7035 if (!element2) return;
7036 if (!shouldRegisterItem) return;
7037 const item = getItem({ id, element: element2 });
7038 return store == null ? void 0 : store.renderItem(item);
7039 }, [id, shouldRegisterItem, getItem, store]);
7040 props = {
7041 ...props,
7042 ref: useMergeRefs(ref, props.ref)
7043 };
7044 return removeUndefinedValues(props);
7045 }
7046 );
7047 var CollectionItem = forwardRef22(function CollectionItem2(props) {
7048 const htmlProps = useCollectionItem(props);
7049 return createElement3(TagName, htmlProps);
7050 });
7051
7052 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
7053 var import_react10 = __toESM(require_react(), 1);
7054 var FocusableContext = (0, import_react10.createContext)(true);
7055
7056 // node_modules/@ariakit/core/esm/utils/focus.js
7057 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'])";
7058 function isFocusable(element) {
7059 if (!element.matches(selector)) return false;
7060 if (!isVisible(element)) return false;
7061 if (element.closest("[inert]")) return false;
7062 return true;
7063 }
7064 function getClosestFocusable(element) {
7065 while (element && !isFocusable(element)) {
7066 element = element.closest(selector);
7067 }
7068 return element || null;
7069 }
7070 function hasFocus(element) {
7071 const activeElement = getActiveElement(element);
7072 if (!activeElement) return false;
7073 if (activeElement === element) return true;
7074 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7075 if (!activeDescendant) return false;
7076 return activeDescendant === element.id;
7077 }
7078 function hasFocusWithin(element) {
7079 const activeElement = getActiveElement(element);
7080 if (!activeElement) return false;
7081 if (contains(element, activeElement)) return true;
7082 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
7083 if (!activeDescendant) return false;
7084 if (!("id" in element)) return false;
7085 if (activeDescendant === element.id) return true;
7086 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
7087 }
7088 function focusIfNeeded(element) {
7089 if (!hasFocusWithin(element) && isFocusable(element)) {
7090 element.focus();
7091 }
7092 }
7093 function focusIntoView(element, options) {
7094 if (!("scrollIntoView" in element)) {
7095 element.focus();
7096 } else {
7097 element.focus({ preventScroll: true });
7098 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
7099 }
7100 }
7101
7102 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
7103 var import_react11 = __toESM(require_react(), 1);
7104 var TagName2 = "div";
7105 var isSafariBrowser = isSafari();
7106 var alwaysFocusVisibleInputTypes = [
7107 "text",
7108 "search",
7109 "url",
7110 "tel",
7111 "email",
7112 "password",
7113 "number",
7114 "date",
7115 "month",
7116 "week",
7117 "time",
7118 "datetime",
7119 "datetime-local"
7120 ];
7121 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
7122 function markSafariFocusAncestor(element, value) {
7123 if (!element) return;
7124 element[safariFocusAncestorSymbol] = value;
7125 }
7126 function isAlwaysFocusVisible(element) {
7127 const { tagName, readOnly, type } = element;
7128 if (tagName === "TEXTAREA" && !readOnly) return true;
7129 if (tagName === "SELECT" && !readOnly) return true;
7130 if (tagName === "INPUT" && !readOnly) {
7131 return alwaysFocusVisibleInputTypes.includes(type);
7132 }
7133 if (element.isContentEditable) return true;
7134 const role = element.getAttribute("role");
7135 if (role === "combobox" && element.dataset.name) {
7136 return true;
7137 }
7138 return false;
7139 }
7140 function getLabels(element) {
7141 if ("labels" in element) {
7142 return element.labels;
7143 }
7144 return null;
7145 }
7146 function isNativeCheckboxOrRadio(element) {
7147 const tagName = element.tagName.toLowerCase();
7148 if (tagName === "input" && element.type) {
7149 return element.type === "radio" || element.type === "checkbox";
7150 }
7151 return false;
7152 }
7153 function isNativeTabbable(tagName) {
7154 if (!tagName) return true;
7155 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
7156 }
7157 function supportsDisabledAttribute(tagName) {
7158 if (!tagName) return true;
7159 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
7160 }
7161 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
7162 if (!focusable) {
7163 return tabIndexProp;
7164 }
7165 if (trulyDisabled) {
7166 if (nativeTabbable && !supportsDisabled) {
7167 return -1;
7168 }
7169 return;
7170 }
7171 if (nativeTabbable) {
7172 return tabIndexProp;
7173 }
7174 return tabIndexProp || 0;
7175 }
7176 function useDisableEvent(onEvent, disabled) {
7177 return useEvent((event) => {
7178 onEvent == null ? void 0 : onEvent(event);
7179 if (event.defaultPrevented) return;
7180 if (disabled) {
7181 event.stopPropagation();
7182 event.preventDefault();
7183 }
7184 });
7185 }
7186 var hasInstalledGlobalEventListeners2 = false;
7187 var isKeyboardModality = true;
7188 function onGlobalMouseDown(event) {
7189 const target = event.target;
7190 if (target && "hasAttribute" in target) {
7191 if (!target.hasAttribute("data-focus-visible")) {
7192 isKeyboardModality = false;
7193 }
7194 }
7195 }
7196 function onGlobalKeyDown(event) {
7197 if (event.metaKey) return;
7198 if (event.ctrlKey) return;
7199 if (event.altKey) return;
7200 isKeyboardModality = true;
7201 }
7202 var useFocusable = createHook(
7203 function useFocusable2({
7204 focusable = true,
7205 accessibleWhenDisabled,
7206 autoFocus,
7207 onFocusVisible,
7208 ...props
7209 }) {
7210 const ref = (0, import_react11.useRef)(null);
7211 (0, import_react11.useEffect)(() => {
7212 if (!focusable) return;
7213 if (hasInstalledGlobalEventListeners2) return;
7214 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
7215 addGlobalEventListener("keydown", onGlobalKeyDown, true);
7216 hasInstalledGlobalEventListeners2 = true;
7217 }, [focusable]);
7218 if (isSafariBrowser) {
7219 (0, import_react11.useEffect)(() => {
7220 if (!focusable) return;
7221 const element = ref.current;
7222 if (!element) return;
7223 if (!isNativeCheckboxOrRadio(element)) return;
7224 const labels = getLabels(element);
7225 if (!labels) return;
7226 const onMouseUp = () => queueMicrotask(() => element.focus());
7227 for (const label of labels) {
7228 label.addEventListener("mouseup", onMouseUp);
7229 }
7230 return () => {
7231 for (const label of labels) {
7232 label.removeEventListener("mouseup", onMouseUp);
7233 }
7234 };
7235 }, [focusable]);
7236 }
7237 const disabled = focusable && disabledFromProps(props);
7238 const trulyDisabled = !!disabled && !accessibleWhenDisabled;
7239 const [focusVisible, setFocusVisible] = (0, import_react11.useState)(false);
7240 (0, import_react11.useEffect)(() => {
7241 if (!focusable) return;
7242 if (trulyDisabled && focusVisible) {
7243 setFocusVisible(false);
7244 }
7245 }, [focusable, trulyDisabled, focusVisible]);
7246 (0, import_react11.useEffect)(() => {
7247 if (!focusable) return;
7248 if (!focusVisible) return;
7249 const element = ref.current;
7250 if (!element) return;
7251 if (typeof IntersectionObserver === "undefined") return;
7252 const observer = new IntersectionObserver(() => {
7253 if (!isFocusable(element)) {
7254 setFocusVisible(false);
7255 }
7256 });
7257 observer.observe(element);
7258 return () => observer.disconnect();
7259 }, [focusable, focusVisible]);
7260 const onKeyPressCapture = useDisableEvent(
7261 props.onKeyPressCapture,
7262 disabled
7263 );
7264 const onMouseDownCapture = useDisableEvent(
7265 props.onMouseDownCapture,
7266 disabled
7267 );
7268 const onClickCapture = useDisableEvent(props.onClickCapture, disabled);
7269 const onMouseDownProp = props.onMouseDown;
7270 const onMouseDown = useEvent((event) => {
7271 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
7272 if (event.defaultPrevented) return;
7273 if (!focusable) return;
7274 const element = event.currentTarget;
7275 if (!isSafariBrowser) return;
7276 if (isPortalEvent(event)) return;
7277 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
7278 let receivedFocus = false;
7279 const onFocus = () => {
7280 receivedFocus = true;
7281 };
7282 const options = { capture: true, once: true };
7283 element.addEventListener("focusin", onFocus, options);
7284 const focusableContainer = getClosestFocusable(element.parentElement);
7285 markSafariFocusAncestor(focusableContainer, true);
7286 queueBeforeEvent(element, "mouseup", () => {
7287 element.removeEventListener("focusin", onFocus, true);
7288 markSafariFocusAncestor(focusableContainer, false);
7289 if (receivedFocus) return;
7290 focusIfNeeded(element);
7291 });
7292 });
7293 const handleFocusVisible = (event, currentTarget) => {
7294 if (currentTarget) {
7295 event.currentTarget = currentTarget;
7296 }
7297 if (!focusable) return;
7298 const element = event.currentTarget;
7299 if (!element) return;
7300 if (!hasFocus(element)) return;
7301 onFocusVisible == null ? void 0 : onFocusVisible(event);
7302 if (event.defaultPrevented) return;
7303 element.dataset.focusVisible = "true";
7304 setFocusVisible(true);
7305 };
7306 const onKeyDownCaptureProp = props.onKeyDownCapture;
7307 const onKeyDownCapture = useEvent((event) => {
7308 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
7309 if (event.defaultPrevented) return;
7310 if (!focusable) return;
7311 if (focusVisible) return;
7312 if (event.metaKey) return;
7313 if (event.altKey) return;
7314 if (event.ctrlKey) return;
7315 if (!isSelfTarget(event)) return;
7316 const element = event.currentTarget;
7317 const applyFocusVisible = () => handleFocusVisible(event, element);
7318 queueBeforeEvent(element, "focusout", applyFocusVisible);
7319 });
7320 const onFocusCaptureProp = props.onFocusCapture;
7321 const onFocusCapture = useEvent((event) => {
7322 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
7323 if (event.defaultPrevented) return;
7324 if (!focusable) return;
7325 if (!isSelfTarget(event)) {
7326 setFocusVisible(false);
7327 return;
7328 }
7329 const element = event.currentTarget;
7330 const applyFocusVisible = () => handleFocusVisible(event, element);
7331 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
7332 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
7333 } else {
7334 setFocusVisible(false);
7335 }
7336 });
7337 const onBlurProp = props.onBlur;
7338 const onBlur = useEvent((event) => {
7339 onBlurProp == null ? void 0 : onBlurProp(event);
7340 if (!focusable) return;
7341 if (!isFocusEventOutside(event)) return;
7342 event.currentTarget.removeAttribute("data-focus-visible");
7343 setFocusVisible(false);
7344 });
7345 const autoFocusOnShow = (0, import_react11.useContext)(FocusableContext);
7346 const autoFocusRef = useEvent((element) => {
7347 if (!focusable) return;
7348 if (!autoFocus) return;
7349 if (!element) return;
7350 if (!autoFocusOnShow) return;
7351 queueMicrotask(() => {
7352 if (hasFocus(element)) return;
7353 if (!isFocusable(element)) return;
7354 element.focus();
7355 });
7356 });
7357 const tagName = useTagName(ref);
7358 const nativeTabbable = focusable && isNativeTabbable(tagName);
7359 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
7360 const styleProp = props.style;
7361 const style = (0, import_react11.useMemo)(() => {
7362 if (trulyDisabled) {
7363 return { pointerEvents: "none", ...styleProp };
7364 }
7365 return styleProp;
7366 }, [trulyDisabled, styleProp]);
7367 props = {
7368 "data-focus-visible": focusable && focusVisible || void 0,
7369 "data-autofocus": autoFocus || void 0,
7370 "aria-disabled": disabled || void 0,
7371 ...props,
7372 ref: useMergeRefs(ref, autoFocusRef, props.ref),
7373 style,
7374 tabIndex: getTabIndex(
7375 focusable,
7376 trulyDisabled,
7377 nativeTabbable,
7378 supportsDisabled,
7379 props.tabIndex
7380 ),
7381 disabled: supportsDisabled && trulyDisabled ? true : void 0,
7382 // TODO: Test Focusable contentEditable.
7383 contentEditable: disabled ? void 0 : props.contentEditable,
7384 onKeyPressCapture,
7385 onClickCapture,
7386 onMouseDownCapture,
7387 onMouseDown,
7388 onKeyDownCapture,
7389 onFocusCapture,
7390 onBlur
7391 };
7392 return removeUndefinedValues(props);
7393 }
7394 );
7395 var Focusable = forwardRef22(function Focusable2(props) {
7396 const htmlProps = useFocusable(props);
7397 return createElement3(TagName2, htmlProps);
7398 });
7399
7400 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
7401 var import_react12 = __toESM(require_react(), 1);
7402 var TagName3 = "button";
7403 function isNativeClick(event) {
7404 if (!event.isTrusted) return false;
7405 const element = event.currentTarget;
7406 if (event.key === "Enter") {
7407 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
7408 }
7409 if (event.key === " ") {
7410 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
7411 }
7412 return false;
7413 }
7414 var symbol = /* @__PURE__ */ Symbol("command");
7415 var useCommand = createHook(
7416 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
7417 const ref = (0, import_react12.useRef)(null);
7418 const [isNativeButton, setIsNativeButton] = (0, import_react12.useState)(false);
7419 (0, import_react12.useEffect)(() => {
7420 if (!ref.current) return;
7421 setIsNativeButton(isButton(ref.current));
7422 }, []);
7423 const [active, setActive] = (0, import_react12.useState)(false);
7424 const activeRef = (0, import_react12.useRef)(false);
7425 const disabled = disabledFromProps(props);
7426 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
7427 const onKeyDownProp = props.onKeyDown;
7428 const onKeyDown = useEvent((event) => {
7429 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
7430 const element = event.currentTarget;
7431 if (event.defaultPrevented) return;
7432 if (isDuplicate) return;
7433 if (disabled) return;
7434 if (!isSelfTarget(event)) return;
7435 if (isTextField(element)) return;
7436 if (element.isContentEditable) return;
7437 const isEnter = clickOnEnter && event.key === "Enter";
7438 const isSpace = clickOnSpace && event.key === " ";
7439 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
7440 const shouldPreventSpace = event.key === " " && !clickOnSpace;
7441 if (shouldPreventEnter || shouldPreventSpace) {
7442 event.preventDefault();
7443 return;
7444 }
7445 if (isEnter || isSpace) {
7446 const nativeClick = isNativeClick(event);
7447 if (isEnter) {
7448 if (!nativeClick) {
7449 event.preventDefault();
7450 const { view, ...eventInit } = event;
7451 const click = () => fireClickEvent(element, eventInit);
7452 if (isFirefox()) {
7453 queueBeforeEvent(element, "keyup", click);
7454 } else {
7455 queueMicrotask(click);
7456 }
7457 }
7458 } else if (isSpace) {
7459 activeRef.current = true;
7460 if (!nativeClick) {
7461 event.preventDefault();
7462 setActive(true);
7463 }
7464 }
7465 }
7466 });
7467 const onKeyUpProp = props.onKeyUp;
7468 const onKeyUp = useEvent((event) => {
7469 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
7470 if (event.defaultPrevented) return;
7471 if (isDuplicate) return;
7472 if (disabled) return;
7473 if (event.metaKey) return;
7474 const isSpace = clickOnSpace && event.key === " ";
7475 if (activeRef.current && isSpace) {
7476 activeRef.current = false;
7477 if (!isNativeClick(event)) {
7478 event.preventDefault();
7479 setActive(false);
7480 const element = event.currentTarget;
7481 const { view, ...eventInit } = event;
7482 queueMicrotask(() => fireClickEvent(element, eventInit));
7483 }
7484 }
7485 });
7486 props = {
7487 "data-active": active || void 0,
7488 type: isNativeButton ? "button" : void 0,
7489 ...metadataProps,
7490 ...props,
7491 ref: useMergeRefs(ref, props.ref),
7492 onKeyDown,
7493 onKeyUp
7494 };
7495 props = useFocusable(props);
7496 return props;
7497 }
7498 );
7499 var Command = forwardRef22(function Command2(props) {
7500 const htmlProps = useCommand(props);
7501 return createElement3(TagName3, htmlProps);
7502 });
7503
7504 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
7505 function getInternal(store, key) {
7506 const internals = store.__unstableInternals;
7507 invariant(internals, "Invalid store");
7508 return internals[key];
7509 }
7510 function createStore(initialState, ...stores) {
7511 let state = initialState;
7512 let prevStateBatch = state;
7513 let lastUpdate = /* @__PURE__ */ Symbol();
7514 let destroy = noop;
7515 const instances = /* @__PURE__ */ new Set();
7516 const updatedKeys = /* @__PURE__ */ new Set();
7517 const setups = /* @__PURE__ */ new Set();
7518 const listeners = /* @__PURE__ */ new Set();
7519 const batchListeners = /* @__PURE__ */ new Set();
7520 const disposables = /* @__PURE__ */ new WeakMap();
7521 const listenerKeys = /* @__PURE__ */ new WeakMap();
7522 const storeSetup = (callback) => {
7523 setups.add(callback);
7524 return () => setups.delete(callback);
7525 };
7526 const storeInit = () => {
7527 const initialized = instances.size;
7528 const instance = /* @__PURE__ */ Symbol();
7529 instances.add(instance);
7530 const maybeDestroy = () => {
7531 instances.delete(instance);
7532 if (instances.size) return;
7533 destroy();
7534 };
7535 if (initialized) return maybeDestroy;
7536 const desyncs = getKeys(state).map(
7537 (key) => chain(
7538 ...stores.map((store) => {
7539 var _a;
7540 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store);
7541 if (!storeState) return;
7542 if (!hasOwnProperty(storeState, key)) return;
7543 return sync(store, [key], (state2) => {
7544 setState(
7545 key,
7546 state2[key],
7547 // @ts-expect-error - Not public API. This is just to prevent
7548 // infinite loops.
7549 true
7550 );
7551 });
7552 })
7553 )
7554 );
7555 const teardowns = [];
7556 for (const setup2 of setups) {
7557 teardowns.push(setup2());
7558 }
7559 const cleanups = stores.map(init);
7560 destroy = chain(...desyncs, ...teardowns, ...cleanups);
7561 return maybeDestroy;
7562 };
7563 const sub = (keys, listener, set2 = listeners) => {
7564 set2.add(listener);
7565 listenerKeys.set(listener, keys);
7566 return () => {
7567 var _a;
7568 (_a = disposables.get(listener)) == null ? void 0 : _a();
7569 disposables.delete(listener);
7570 listenerKeys.delete(listener);
7571 set2.delete(listener);
7572 };
7573 };
7574 const storeSubscribe = (keys, listener) => sub(keys, listener);
7575 const storeSync = (keys, listener) => {
7576 disposables.set(listener, listener(state, state));
7577 return sub(keys, listener);
7578 };
7579 const storeBatch = (keys, listener) => {
7580 disposables.set(listener, listener(state, prevStateBatch));
7581 return sub(keys, listener, batchListeners);
7582 };
7583 const storePick = (keys) => createStore(pick(state, keys), finalStore);
7584 const storeOmit = (keys) => createStore(omit2(state, keys), finalStore);
7585 const getState = () => state;
7586 const setState = (key, value, fromStores = false) => {
7587 var _a;
7588 if (!hasOwnProperty(state, key)) return;
7589 const nextValue = applyState(value, state[key]);
7590 if (nextValue === state[key]) return;
7591 if (!fromStores) {
7592 for (const store of stores) {
7593 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue);
7594 }
7595 }
7596 const prevState = state;
7597 state = { ...state, [key]: nextValue };
7598 const thisUpdate = /* @__PURE__ */ Symbol();
7599 lastUpdate = thisUpdate;
7600 updatedKeys.add(key);
7601 const run = (listener, prev, uKeys) => {
7602 var _a2;
7603 const keys = listenerKeys.get(listener);
7604 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
7605 if (!keys || keys.some(updated)) {
7606 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
7607 disposables.set(listener, listener(state, prev));
7608 }
7609 };
7610 for (const listener of listeners) {
7611 run(listener, prevState);
7612 }
7613 queueMicrotask(() => {
7614 if (lastUpdate !== thisUpdate) return;
7615 const snapshot = state;
7616 for (const listener of batchListeners) {
7617 run(listener, prevStateBatch, updatedKeys);
7618 }
7619 prevStateBatch = snapshot;
7620 updatedKeys.clear();
7621 });
7622 };
7623 const finalStore = {
7624 getState,
7625 setState,
7626 __unstableInternals: {
7627 setup: storeSetup,
7628 init: storeInit,
7629 subscribe: storeSubscribe,
7630 sync: storeSync,
7631 batch: storeBatch,
7632 pick: storePick,
7633 omit: storeOmit
7634 }
7635 };
7636 return finalStore;
7637 }
7638 function setup(store, ...args) {
7639 if (!store) return;
7640 return getInternal(store, "setup")(...args);
7641 }
7642 function init(store, ...args) {
7643 if (!store) return;
7644 return getInternal(store, "init")(...args);
7645 }
7646 function subscribe(store, ...args) {
7647 if (!store) return;
7648 return getInternal(store, "subscribe")(...args);
7649 }
7650 function sync(store, ...args) {
7651 if (!store) return;
7652 return getInternal(store, "sync")(...args);
7653 }
7654 function batch(store, ...args) {
7655 if (!store) return;
7656 return getInternal(store, "batch")(...args);
7657 }
7658 function omit22(store, ...args) {
7659 if (!store) return;
7660 return getInternal(store, "omit")(...args);
7661 }
7662 function pick2(store, ...args) {
7663 if (!store) return;
7664 return getInternal(store, "pick")(...args);
7665 }
7666 function mergeStore(...stores) {
7667 var _a;
7668 const initialState = {};
7669 for (const store2 of stores) {
7670 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
7671 if (nextState) {
7672 Object.assign(initialState, nextState);
7673 }
7674 }
7675 const store = createStore(initialState, ...stores);
7676 return Object.assign({}, ...stores, store);
7677 }
7678 function throwOnConflictingProps(props, store) {
7679 if (false) return;
7680 if (!store) return;
7681 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
7682 var _a;
7683 const stateKey = key.replace("default", "");
7684 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
7685 });
7686 if (!defaultKeys.length) return;
7687 const storeState = store.getState();
7688 const conflictingProps = defaultKeys.filter(
7689 (key) => hasOwnProperty(storeState, key)
7690 );
7691 if (!conflictingProps.length) return;
7692 throw new Error(
7693 `Passing a store prop in conjunction with a default state is not supported.
7694
7695 const store = useSelectStore();
7696 <SelectProvider store={store} defaultValue="Apple" />
7697 ^ ^
7698
7699 Instead, pass the default state to the topmost store:
7700
7701 const store = useSelectStore({ defaultValue: "Apple" });
7702 <SelectProvider store={store} />
7703
7704 See https://github.com/ariakit/ariakit/pull/2745 for more details.
7705
7706 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
7707 `
7708 );
7709 }
7710
7711 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
7712 var React8 = __toESM(require_react(), 1);
7713 var import_shim = __toESM(require_shim(), 1);
7714 var { useSyncExternalStore } = import_shim.default;
7715 var noopSubscribe = () => () => {
7716 };
7717 function useStoreState(store, keyOrSelector = identity) {
7718 const storeSubscribe = React8.useCallback(
7719 (callback) => {
7720 if (!store) return noopSubscribe();
7721 return subscribe(store, null, callback);
7722 },
7723 [store]
7724 );
7725 const getSnapshot = () => {
7726 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
7727 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
7728 const state = store == null ? void 0 : store.getState();
7729 if (selector2) return selector2(state);
7730 if (!state) return;
7731 if (!key) return;
7732 if (!hasOwnProperty(state, key)) return;
7733 return state[key];
7734 };
7735 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7736 }
7737 function useStoreStateObject(store, object) {
7738 const objRef = React8.useRef(
7739 {}
7740 );
7741 const storeSubscribe = React8.useCallback(
7742 (callback) => {
7743 if (!store) return noopSubscribe();
7744 return subscribe(store, null, callback);
7745 },
7746 [store]
7747 );
7748 const getSnapshot = () => {
7749 const state = store == null ? void 0 : store.getState();
7750 let updated = false;
7751 const obj = objRef.current;
7752 for (const prop in object) {
7753 const keyOrSelector = object[prop];
7754 if (typeof keyOrSelector === "function") {
7755 const value = keyOrSelector(state);
7756 if (value !== obj[prop]) {
7757 obj[prop] = value;
7758 updated = true;
7759 }
7760 }
7761 if (typeof keyOrSelector === "string") {
7762 if (!state) continue;
7763 if (!hasOwnProperty(state, keyOrSelector)) continue;
7764 const value = state[keyOrSelector];
7765 if (value !== obj[prop]) {
7766 obj[prop] = value;
7767 updated = true;
7768 }
7769 }
7770 }
7771 if (updated) {
7772 objRef.current = { ...obj };
7773 }
7774 return objRef.current;
7775 };
7776 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
7777 }
7778 function useStoreProps(store, props, key, setKey) {
7779 const value = hasOwnProperty(props, key) ? props[key] : void 0;
7780 const setValue = setKey ? props[setKey] : void 0;
7781 const propsRef = useLiveRef({ value, setValue });
7782 useSafeLayoutEffect(() => {
7783 return sync(store, [key], (state, prev) => {
7784 const { value: value2, setValue: setValue2 } = propsRef.current;
7785 if (!setValue2) return;
7786 if (state[key] === prev[key]) return;
7787 if (state[key] === value2) return;
7788 setValue2(state[key]);
7789 });
7790 }, [store, key]);
7791 useSafeLayoutEffect(() => {
7792 if (value === void 0) return;
7793 store.setState(key, value);
7794 return batch(store, [key], () => {
7795 if (value === void 0) return;
7796 store.setState(key, value);
7797 });
7798 });
7799 }
7800 function useStore(createStore2, props) {
7801 const [store, setStore] = React8.useState(() => createStore2(props));
7802 useSafeLayoutEffect(() => init(store), [store]);
7803 const useState25 = React8.useCallback(
7804 (keyOrSelector) => useStoreState(store, keyOrSelector),
7805 [store]
7806 );
7807 const memoizedStore = React8.useMemo(
7808 () => ({ ...store, useState: useState25 }),
7809 [store, useState25]
7810 );
7811 const updateStore = useEvent(() => {
7812 setStore((store2) => createStore2({ ...props, ...store2.getState() }));
7813 });
7814 return [memoizedStore, updateStore];
7815 }
7816
7817 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
7818 var import_react13 = __toESM(require_react(), 1);
7819 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
7820 var TagName4 = "button";
7821 function isEditableElement(element) {
7822 if (isTextbox(element)) return true;
7823 return element.tagName === "INPUT" && !isButton(element);
7824 }
7825 function getNextPageOffset(scrollingElement, pageUp = false) {
7826 const height = scrollingElement.clientHeight;
7827 const { top } = scrollingElement.getBoundingClientRect();
7828 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
7829 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
7830 if (scrollingElement.tagName === "HTML") {
7831 return pageOffset + scrollingElement.scrollTop;
7832 }
7833 return pageOffset;
7834 }
7835 function getItemOffset(itemElement, pageUp = false) {
7836 const { top } = itemElement.getBoundingClientRect();
7837 if (pageUp) {
7838 return top + itemElement.clientHeight;
7839 }
7840 return top;
7841 }
7842 function findNextPageItemId(element, store, next, pageUp = false) {
7843 var _a;
7844 if (!store) return;
7845 if (!next) return;
7846 const { renderedItems } = store.getState();
7847 const scrollingElement = getScrollingElement(element);
7848 if (!scrollingElement) return;
7849 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
7850 let id;
7851 let prevDifference;
7852 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
7853 const previousId = id;
7854 id = next(i2);
7855 if (!id) break;
7856 if (id === previousId) continue;
7857 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element;
7858 if (!itemElement) continue;
7859 const itemOffset = getItemOffset(itemElement, pageUp);
7860 const difference = itemOffset - nextPageOffset;
7861 const absDifference = Math.abs(difference);
7862 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
7863 if (prevDifference !== void 0 && prevDifference < absDifference) {
7864 id = previousId;
7865 }
7866 break;
7867 }
7868 prevDifference = absDifference;
7869 }
7870 return id;
7871 }
7872 function targetIsAnotherItem(event, store) {
7873 if (isSelfTarget(event)) return false;
7874 return isItem(store, event.target);
7875 }
7876 var useCompositeItem = createHook(
7877 function useCompositeItem2({
7878 store,
7879 rowId: rowIdProp,
7880 preventScrollOnKeyDown = false,
7881 moveOnKeyPress = true,
7882 tabbable = false,
7883 getItem: getItemProp,
7884 "aria-setsize": ariaSetSizeProp,
7885 "aria-posinset": ariaPosInSetProp,
7886 ...props
7887 }) {
7888 const context = useCompositeContext();
7889 store = store || context;
7890 const id = useId3(props.id);
7891 const ref = (0, import_react13.useRef)(null);
7892 const row = (0, import_react13.useContext)(CompositeRowContext);
7893 const disabled = disabledFromProps(props);
7894 const trulyDisabled = disabled && !props.accessibleWhenDisabled;
7895 const {
7896 rowId,
7897 baseElement,
7898 isActiveItem,
7899 ariaSetSize,
7900 ariaPosInSet,
7901 isTabbable
7902 } = useStoreStateObject(store, {
7903 rowId(state) {
7904 if (rowIdProp) return rowIdProp;
7905 if (!state) return;
7906 if (!(row == null ? void 0 : row.baseElement)) return;
7907 if (row.baseElement !== state.baseElement) return;
7908 return row.id;
7909 },
7910 baseElement(state) {
7911 return (state == null ? void 0 : state.baseElement) || void 0;
7912 },
7913 isActiveItem(state) {
7914 return !!state && state.activeId === id;
7915 },
7916 ariaSetSize(state) {
7917 if (ariaSetSizeProp != null) return ariaSetSizeProp;
7918 if (!state) return;
7919 if (!(row == null ? void 0 : row.ariaSetSize)) return;
7920 if (row.baseElement !== state.baseElement) return;
7921 return row.ariaSetSize;
7922 },
7923 ariaPosInSet(state) {
7924 if (ariaPosInSetProp != null) return ariaPosInSetProp;
7925 if (!state) return;
7926 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
7927 if (row.baseElement !== state.baseElement) return;
7928 const itemsInRow = state.renderedItems.filter(
7929 (item) => item.rowId === rowId
7930 );
7931 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
7932 },
7933 isTabbable(state) {
7934 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
7935 if (state.virtualFocus) return false;
7936 if (tabbable) return true;
7937 if (state.activeId === null) return false;
7938 const item = store == null ? void 0 : store.item(state.activeId);
7939 if (item == null ? void 0 : item.disabled) return true;
7940 if (!(item == null ? void 0 : item.element)) return true;
7941 return state.activeId === id;
7942 }
7943 });
7944 const getItem = (0, import_react13.useCallback)(
7945 (item) => {
7946 var _a;
7947 const nextItem = {
7948 ...item,
7949 id: id || item.id,
7950 rowId,
7951 disabled: !!trulyDisabled,
7952 children: (_a = item.element) == null ? void 0 : _a.textContent
7953 };
7954 if (getItemProp) {
7955 return getItemProp(nextItem);
7956 }
7957 return nextItem;
7958 },
7959 [id, rowId, trulyDisabled, getItemProp]
7960 );
7961 const onFocusProp = props.onFocus;
7962 const hasFocusedComposite = (0, import_react13.useRef)(false);
7963 const onFocus = useEvent((event) => {
7964 onFocusProp == null ? void 0 : onFocusProp(event);
7965 if (event.defaultPrevented) return;
7966 if (isPortalEvent(event)) return;
7967 if (!id) return;
7968 if (!store) return;
7969 if (targetIsAnotherItem(event, store)) return;
7970 const { virtualFocus, baseElement: baseElement2 } = store.getState();
7971 store.setActiveId(id);
7972 if (isTextbox(event.currentTarget)) {
7973 selectTextField(event.currentTarget);
7974 }
7975 if (!virtualFocus) return;
7976 if (!isSelfTarget(event)) return;
7977 if (isEditableElement(event.currentTarget)) return;
7978 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
7979 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
7980 event.currentTarget.scrollIntoView({
7981 block: "nearest",
7982 inline: "nearest"
7983 });
7984 }
7985 hasFocusedComposite.current = true;
7986 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget);
7987 if (fromComposite) {
7988 focusSilently(baseElement2);
7989 } else {
7990 baseElement2.focus();
7991 }
7992 });
7993 const onBlurCaptureProp = props.onBlurCapture;
7994 const onBlurCapture = useEvent((event) => {
7995 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
7996 if (event.defaultPrevented) return;
7997 const state = store == null ? void 0 : store.getState();
7998 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
7999 hasFocusedComposite.current = false;
8000 event.preventDefault();
8001 event.stopPropagation();
8002 }
8003 });
8004 const onKeyDownProp = props.onKeyDown;
8005 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
8006 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8007 const onKeyDown = useEvent((event) => {
8008 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8009 if (event.defaultPrevented) return;
8010 if (!isSelfTarget(event)) return;
8011 if (!store) return;
8012 const { currentTarget } = event;
8013 const state = store.getState();
8014 const item = store.item(id);
8015 const isGrid2 = !!(item == null ? void 0 : item.rowId);
8016 const isVertical = state.orientation !== "horizontal";
8017 const isHorizontal = state.orientation !== "vertical";
8018 const canHomeEnd = () => {
8019 if (isGrid2) return true;
8020 if (isHorizontal) return true;
8021 if (!state.baseElement) return true;
8022 if (!isTextField(state.baseElement)) return true;
8023 return false;
8024 };
8025 const keyMap = {
8026 ArrowUp: (isGrid2 || isVertical) && store.up,
8027 ArrowRight: (isGrid2 || isHorizontal) && store.next,
8028 ArrowDown: (isGrid2 || isVertical) && store.down,
8029 ArrowLeft: (isGrid2 || isHorizontal) && store.previous,
8030 Home: () => {
8031 if (!canHomeEnd()) return;
8032 if (!isGrid2 || event.ctrlKey) {
8033 return store == null ? void 0 : store.first();
8034 }
8035 return store == null ? void 0 : store.previous(-1);
8036 },
8037 End: () => {
8038 if (!canHomeEnd()) return;
8039 if (!isGrid2 || event.ctrlKey) {
8040 return store == null ? void 0 : store.last();
8041 }
8042 return store == null ? void 0 : store.next(-1);
8043 },
8044 PageUp: () => {
8045 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true);
8046 },
8047 PageDown: () => {
8048 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down);
8049 }
8050 };
8051 const action = keyMap[event.key];
8052 if (action) {
8053 if (isTextbox(currentTarget)) {
8054 const selection = getTextboxSelection(currentTarget);
8055 const isLeft = isHorizontal && event.key === "ArrowLeft";
8056 const isRight = isHorizontal && event.key === "ArrowRight";
8057 const isUp = isVertical && event.key === "ArrowUp";
8058 const isDown = isVertical && event.key === "ArrowDown";
8059 if (isRight || isDown) {
8060 const { length: valueLength } = getTextboxValue(currentTarget);
8061 if (selection.end !== valueLength) return;
8062 } else if ((isLeft || isUp) && selection.start !== 0) return;
8063 }
8064 const nextId = action();
8065 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
8066 if (!moveOnKeyPressProp(event)) return;
8067 event.preventDefault();
8068 store.move(nextId);
8069 }
8070 }
8071 });
8072 const providerValue = (0, import_react13.useMemo)(
8073 () => ({ id, baseElement }),
8074 [id, baseElement]
8075 );
8076 props = useWrapElement(
8077 props,
8078 (element) => /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
8079 [providerValue]
8080 );
8081 props = {
8082 id,
8083 "data-active-item": isActiveItem || void 0,
8084 ...props,
8085 ref: useMergeRefs(ref, props.ref),
8086 tabIndex: isTabbable ? props.tabIndex : -1,
8087 onFocus,
8088 onBlurCapture,
8089 onKeyDown
8090 };
8091 props = useCommand(props);
8092 props = useCollectionItem({
8093 store,
8094 ...props,
8095 getItem,
8096 shouldRegisterItem: id ? props.shouldRegisterItem : false
8097 });
8098 return removeUndefinedValues({
8099 ...props,
8100 "aria-setsize": ariaSetSize,
8101 "aria-posinset": ariaPosInSet
8102 });
8103 }
8104 );
8105 var CompositeItem = memo22(
8106 forwardRef22(function CompositeItem2(props) {
8107 const htmlProps = useCompositeItem(props);
8108 return createElement3(TagName4, htmlProps);
8109 })
8110 );
8111
8112 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
8113 function toArray(arg) {
8114 if (Array.isArray(arg)) {
8115 return arg;
8116 }
8117 return typeof arg !== "undefined" ? [arg] : [];
8118 }
8119 function flatten2DArray(array) {
8120 const flattened = [];
8121 for (const row of array) {
8122 flattened.push(...row);
8123 }
8124 return flattened;
8125 }
8126 function reverseArray(array) {
8127 return array.slice().reverse();
8128 }
8129
8130 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
8131 var import_react14 = __toESM(require_react(), 1);
8132 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
8133 var TagName5 = "div";
8134 function isGrid(items) {
8135 return items.some((item) => !!item.rowId);
8136 }
8137 function isPrintableKey(event) {
8138 const target = event.target;
8139 if (target && !isTextField(target)) return false;
8140 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
8141 }
8142 function isModifierKey(event) {
8143 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
8144 }
8145 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) {
8146 return useEvent((event) => {
8147 var _a;
8148 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
8149 if (event.defaultPrevented) return;
8150 if (event.isPropagationStopped()) return;
8151 if (!isSelfTarget(event)) return;
8152 if (isModifierKey(event)) return;
8153 if (isPrintableKey(event)) return;
8154 const state = store.getState();
8155 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element;
8156 if (!activeElement) return;
8157 const { view, ...eventInit } = event;
8158 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
8159 if (activeElement !== previousElement) {
8160 activeElement.focus();
8161 }
8162 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
8163 event.preventDefault();
8164 }
8165 if (event.currentTarget.contains(activeElement)) {
8166 event.stopPropagation();
8167 }
8168 });
8169 }
8170 function findFirstEnabledItemInTheLastRow(items) {
8171 return findFirstEnabledItem(
8172 flatten2DArray(reverseArray(groupItemsByRows(items)))
8173 );
8174 }
8175 function useScheduleFocus(store) {
8176 const [scheduled, setScheduled] = (0, import_react14.useState)(false);
8177 const schedule = (0, import_react14.useCallback)(() => setScheduled(true), []);
8178 const activeItem = store.useState(
8179 (state) => getEnabledItem(store, state.activeId)
8180 );
8181 (0, import_react14.useEffect)(() => {
8182 const activeElement = activeItem == null ? void 0 : activeItem.element;
8183 if (!scheduled) return;
8184 if (!activeElement) return;
8185 setScheduled(false);
8186 activeElement.focus({ preventScroll: true });
8187 }, [activeItem, scheduled]);
8188 return schedule;
8189 }
8190 var useComposite = createHook(
8191 function useComposite2({
8192 store,
8193 composite = true,
8194 focusOnMove = composite,
8195 moveOnKeyPress = true,
8196 ...props
8197 }) {
8198 const context = useCompositeProviderContext();
8199 store = store || context;
8200 invariant(
8201 store,
8202 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
8203 );
8204 const ref = (0, import_react14.useRef)(null);
8205 const previousElementRef = (0, import_react14.useRef)(null);
8206 const scheduleFocus = useScheduleFocus(store);
8207 const moves = store.useState("moves");
8208 const [, setBaseElement] = useTransactionState(
8209 composite ? store.setBaseElement : null
8210 );
8211 (0, import_react14.useEffect)(() => {
8212 var _a;
8213 if (!store) return;
8214 if (!moves) return;
8215 if (!composite) return;
8216 if (!focusOnMove) return;
8217 const { activeId: activeId2 } = store.getState();
8218 const itemElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8219 if (!itemElement) return;
8220 focusIntoView(itemElement);
8221 }, [store, moves, composite, focusOnMove]);
8222 useSafeLayoutEffect(() => {
8223 if (!store) return;
8224 if (!moves) return;
8225 if (!composite) return;
8226 const { baseElement, activeId: activeId2 } = store.getState();
8227 const isSelfAcive = activeId2 === null;
8228 if (!isSelfAcive) return;
8229 if (!baseElement) return;
8230 const previousElement = previousElementRef.current;
8231 previousElementRef.current = null;
8232 if (previousElement) {
8233 fireBlurEvent(previousElement, { relatedTarget: baseElement });
8234 }
8235 if (!hasFocus(baseElement)) {
8236 baseElement.focus();
8237 }
8238 }, [store, moves, composite]);
8239 const activeId = store.useState("activeId");
8240 const virtualFocus = store.useState("virtualFocus");
8241 useSafeLayoutEffect(() => {
8242 var _a;
8243 if (!store) return;
8244 if (!composite) return;
8245 if (!virtualFocus) return;
8246 const previousElement = previousElementRef.current;
8247 previousElementRef.current = null;
8248 if (!previousElement) return;
8249 const activeElement = (_a = getEnabledItem(store, activeId)) == null ? void 0 : _a.element;
8250 const relatedTarget = activeElement || getActiveElement(previousElement);
8251 if (relatedTarget === previousElement) return;
8252 fireBlurEvent(previousElement, { relatedTarget });
8253 }, [store, activeId, virtualFocus, composite]);
8254 const onKeyDownCapture = useKeyboardEventProxy(
8255 store,
8256 props.onKeyDownCapture,
8257 previousElementRef
8258 );
8259 const onKeyUpCapture = useKeyboardEventProxy(
8260 store,
8261 props.onKeyUpCapture,
8262 previousElementRef
8263 );
8264 const onFocusCaptureProp = props.onFocusCapture;
8265 const onFocusCapture = useEvent((event) => {
8266 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
8267 if (event.defaultPrevented) return;
8268 if (!store) return;
8269 const { virtualFocus: virtualFocus2 } = store.getState();
8270 if (!virtualFocus2) return;
8271 const previousActiveElement = event.relatedTarget;
8272 const isSilentlyFocused = silentlyFocused(event.currentTarget);
8273 if (isSelfTarget(event) && isSilentlyFocused) {
8274 event.stopPropagation();
8275 previousElementRef.current = previousActiveElement;
8276 }
8277 });
8278 const onFocusProp = props.onFocus;
8279 const onFocus = useEvent((event) => {
8280 onFocusProp == null ? void 0 : onFocusProp(event);
8281 if (event.defaultPrevented) return;
8282 if (!composite) return;
8283 if (!store) return;
8284 const { relatedTarget } = event;
8285 const { virtualFocus: virtualFocus2 } = store.getState();
8286 if (virtualFocus2) {
8287 if (isSelfTarget(event) && !isItem(store, relatedTarget)) {
8288 queueMicrotask(scheduleFocus);
8289 }
8290 } else if (isSelfTarget(event)) {
8291 store.setActiveId(null);
8292 }
8293 });
8294 const onBlurCaptureProp = props.onBlurCapture;
8295 const onBlurCapture = useEvent((event) => {
8296 var _a;
8297 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
8298 if (event.defaultPrevented) return;
8299 if (!store) return;
8300 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState();
8301 if (!virtualFocus2) return;
8302 const activeElement = (_a = getEnabledItem(store, activeId2)) == null ? void 0 : _a.element;
8303 const nextActiveElement = event.relatedTarget;
8304 const nextActiveElementIsItem = isItem(store, nextActiveElement);
8305 const previousElement = previousElementRef.current;
8306 previousElementRef.current = null;
8307 if (isSelfTarget(event) && nextActiveElementIsItem) {
8308 if (nextActiveElement === activeElement) {
8309 if (previousElement && previousElement !== nextActiveElement) {
8310 fireBlurEvent(previousElement, event);
8311 }
8312 } else if (activeElement) {
8313 fireBlurEvent(activeElement, event);
8314 } else if (previousElement) {
8315 fireBlurEvent(previousElement, event);
8316 }
8317 event.stopPropagation();
8318 } else {
8319 const targetIsItem = isItem(store, event.target);
8320 if (!targetIsItem && activeElement) {
8321 fireBlurEvent(activeElement, event);
8322 }
8323 }
8324 });
8325 const onKeyDownProp = props.onKeyDown;
8326 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
8327 const onKeyDown = useEvent((event) => {
8328 var _a;
8329 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
8330 if (event.nativeEvent.isComposing) return;
8331 if (event.defaultPrevented) return;
8332 if (!store) return;
8333 if (!isSelfTarget(event)) return;
8334 const { orientation, renderedItems, activeId: activeId2 } = store.getState();
8335 const activeItem = getEnabledItem(store, activeId2);
8336 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
8337 const isVertical = orientation !== "horizontal";
8338 const isHorizontal = orientation !== "vertical";
8339 const grid = isGrid(renderedItems);
8340 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
8341 if (isHorizontalKey && isTextField(event.currentTarget)) return;
8342 const up = () => {
8343 if (grid) {
8344 const item = findFirstEnabledItemInTheLastRow(renderedItems);
8345 return item == null ? void 0 : item.id;
8346 }
8347 return store == null ? void 0 : store.last();
8348 };
8349 const keyMap = {
8350 ArrowUp: (grid || isVertical) && up,
8351 ArrowRight: (grid || isHorizontal) && store.first,
8352 ArrowDown: (grid || isVertical) && store.first,
8353 ArrowLeft: (grid || isHorizontal) && store.last,
8354 Home: store.first,
8355 End: store.last,
8356 PageUp: store.first,
8357 PageDown: store.last
8358 };
8359 const action = keyMap[event.key];
8360 if (action) {
8361 const id = action();
8362 if (id !== void 0) {
8363 if (!moveOnKeyPressProp(event)) return;
8364 event.preventDefault();
8365 store.move(id);
8366 }
8367 }
8368 });
8369 props = useWrapElement(
8370 props,
8371 (element) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(CompositeContextProvider, { value: store, children: element }),
8372 [store]
8373 );
8374 const activeDescendant = store.useState((state) => {
8375 var _a;
8376 if (!store) return;
8377 if (!composite) return;
8378 if (!state.virtualFocus) return;
8379 return (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.id;
8380 });
8381 props = {
8382 "aria-activedescendant": activeDescendant,
8383 ...props,
8384 ref: useMergeRefs(ref, setBaseElement, props.ref),
8385 onKeyDownCapture,
8386 onKeyUpCapture,
8387 onFocusCapture,
8388 onFocus,
8389 onBlurCapture,
8390 onKeyDown
8391 };
8392 const focusable = store.useState(
8393 (state) => composite && (state.virtualFocus || state.activeId === null)
8394 );
8395 props = useFocusable({ focusable, ...props });
8396 return props;
8397 }
8398 );
8399 var Composite5 = forwardRef22(function Composite22(props) {
8400 const htmlProps = useComposite(props);
8401 return createElement3(TagName5, htmlProps);
8402 });
8403
8404 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
8405 var ctx3 = createStoreContext();
8406 var useDisclosureContext = ctx3.useContext;
8407 var useDisclosureScopedContext = ctx3.useScopedContext;
8408 var useDisclosureProviderContext = ctx3.useProviderContext;
8409 var DisclosureContextProvider = ctx3.ContextProvider;
8410 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
8411
8412 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
8413 var import_react15 = __toESM(require_react(), 1);
8414 var ctx4 = createStoreContext(
8415 [DisclosureContextProvider],
8416 [DisclosureScopedContextProvider]
8417 );
8418 var useDialogContext = ctx4.useContext;
8419 var useDialogScopedContext = ctx4.useScopedContext;
8420 var useDialogProviderContext = ctx4.useProviderContext;
8421 var DialogContextProvider = ctx4.ContextProvider;
8422 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
8423 var DialogHeadingContext = (0, import_react15.createContext)(void 0);
8424 var DialogDescriptionContext = (0, import_react15.createContext)(void 0);
8425
8426 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
8427 var import_react16 = __toESM(require_react(), 1);
8428 var import_react_dom = __toESM(require_react_dom(), 1);
8429 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
8430 var TagName6 = "div";
8431 function afterTimeout(timeoutMs, cb) {
8432 const timeoutId = setTimeout(cb, timeoutMs);
8433 return () => clearTimeout(timeoutId);
8434 }
8435 function afterPaint2(cb) {
8436 let raf = requestAnimationFrame(() => {
8437 raf = requestAnimationFrame(cb);
8438 });
8439 return () => cancelAnimationFrame(raf);
8440 }
8441 function parseCSSTime(...times) {
8442 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
8443 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
8444 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
8445 if (currentTime > longestTime) return currentTime;
8446 return longestTime;
8447 }, 0);
8448 }
8449 function isHidden(mounted, hidden, alwaysVisible) {
8450 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
8451 }
8452 var useDisclosureContent = createHook(function useDisclosureContent2({ store, alwaysVisible, ...props }) {
8453 const context = useDisclosureProviderContext();
8454 store = store || context;
8455 invariant(
8456 store,
8457 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
8458 );
8459 const ref = (0, import_react16.useRef)(null);
8460 const id = useId3(props.id);
8461 const [transition, setTransition] = (0, import_react16.useState)(null);
8462 const open = store.useState("open");
8463 const mounted = store.useState("mounted");
8464 const animated = store.useState("animated");
8465 const contentElement = store.useState("contentElement");
8466 const otherElement = useStoreState(store.disclosure, "contentElement");
8467 useSafeLayoutEffect(() => {
8468 if (!ref.current) return;
8469 store == null ? void 0 : store.setContentElement(ref.current);
8470 }, [store]);
8471 useSafeLayoutEffect(() => {
8472 let previousAnimated;
8473 store == null ? void 0 : store.setState("animated", (animated2) => {
8474 previousAnimated = animated2;
8475 return true;
8476 });
8477 return () => {
8478 if (previousAnimated === void 0) return;
8479 store == null ? void 0 : store.setState("animated", previousAnimated);
8480 };
8481 }, [store]);
8482 useSafeLayoutEffect(() => {
8483 if (!animated) return;
8484 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
8485 setTransition(null);
8486 return;
8487 }
8488 return afterPaint2(() => {
8489 setTransition(open ? "enter" : mounted ? "leave" : null);
8490 });
8491 }, [animated, contentElement, open, mounted]);
8492 useSafeLayoutEffect(() => {
8493 if (!store) return;
8494 if (!animated) return;
8495 if (!transition) return;
8496 if (!contentElement) return;
8497 const stopAnimation = () => store == null ? void 0 : store.setState("animating", false);
8498 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
8499 if (transition === "leave" && open) return;
8500 if (transition === "enter" && !open) return;
8501 if (typeof animated === "number") {
8502 const timeout2 = animated;
8503 return afterTimeout(timeout2, stopAnimationSync);
8504 }
8505 const {
8506 transitionDuration,
8507 animationDuration,
8508 transitionDelay,
8509 animationDelay
8510 } = getComputedStyle(contentElement);
8511 const {
8512 transitionDuration: transitionDuration2 = "0",
8513 animationDuration: animationDuration2 = "0",
8514 transitionDelay: transitionDelay2 = "0",
8515 animationDelay: animationDelay2 = "0"
8516 } = otherElement ? getComputedStyle(otherElement) : {};
8517 const delay = parseCSSTime(
8518 transitionDelay,
8519 animationDelay,
8520 transitionDelay2,
8521 animationDelay2
8522 );
8523 const duration = parseCSSTime(
8524 transitionDuration,
8525 animationDuration,
8526 transitionDuration2,
8527 animationDuration2
8528 );
8529 const timeout = delay + duration;
8530 if (!timeout) {
8531 if (transition === "enter") {
8532 store.setState("animated", false);
8533 }
8534 stopAnimation();
8535 return;
8536 }
8537 const frameRate = 1e3 / 60;
8538 const maxTimeout = Math.max(timeout - frameRate, 0);
8539 return afterTimeout(maxTimeout, stopAnimationSync);
8540 }, [store, animated, contentElement, otherElement, open, transition]);
8541 props = useWrapElement(
8542 props,
8543 (element) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DialogScopedContextProvider, { value: store, children: element }),
8544 [store]
8545 );
8546 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
8547 const styleProp = props.style;
8548 const style = (0, import_react16.useMemo)(() => {
8549 if (hidden) {
8550 return { ...styleProp, display: "none" };
8551 }
8552 return styleProp;
8553 }, [hidden, styleProp]);
8554 props = {
8555 id,
8556 "data-open": open || void 0,
8557 "data-enter": transition === "enter" || void 0,
8558 "data-leave": transition === "leave" || void 0,
8559 hidden,
8560 ...props,
8561 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref),
8562 style
8563 };
8564 return removeUndefinedValues(props);
8565 });
8566 var DisclosureContentImpl = forwardRef22(function DisclosureContentImpl2(props) {
8567 const htmlProps = useDisclosureContent(props);
8568 return createElement3(TagName6, htmlProps);
8569 });
8570 var DisclosureContent = forwardRef22(function DisclosureContent2({
8571 unmountOnHide,
8572 ...props
8573 }) {
8574 const context = useDisclosureProviderContext();
8575 const store = props.store || context;
8576 const mounted = useStoreState(
8577 store,
8578 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
8579 );
8580 if (mounted === false) return null;
8581 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(DisclosureContentImpl, { ...props });
8582 });
8583
8584 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
8585 function createDisclosureStore(props = {}) {
8586 const store = mergeStore(
8587 props.store,
8588 omit22(props.disclosure, ["contentElement", "disclosureElement"])
8589 );
8590 throwOnConflictingProps(props, store);
8591 const syncState = store == null ? void 0 : store.getState();
8592 const open = defaultValue(
8593 props.open,
8594 syncState == null ? void 0 : syncState.open,
8595 props.defaultOpen,
8596 false
8597 );
8598 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
8599 const initialState = {
8600 open,
8601 animated,
8602 animating: !!animated && open,
8603 mounted: open,
8604 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
8605 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
8606 };
8607 const disclosure = createStore(initialState, store);
8608 setup(
8609 disclosure,
8610 () => sync(disclosure, ["animated", "animating"], (state) => {
8611 if (state.animated) return;
8612 disclosure.setState("animating", false);
8613 })
8614 );
8615 setup(
8616 disclosure,
8617 () => subscribe(disclosure, ["open"], () => {
8618 if (!disclosure.getState().animated) return;
8619 disclosure.setState("animating", true);
8620 })
8621 );
8622 setup(
8623 disclosure,
8624 () => sync(disclosure, ["open", "animating"], (state) => {
8625 disclosure.setState("mounted", state.open || state.animating);
8626 })
8627 );
8628 return {
8629 ...disclosure,
8630 disclosure: props.disclosure,
8631 setOpen: (value) => disclosure.setState("open", value),
8632 show: () => disclosure.setState("open", true),
8633 hide: () => disclosure.setState("open", false),
8634 toggle: () => disclosure.setState("open", (open2) => !open2),
8635 stopAnimation: () => disclosure.setState("animating", false),
8636 setContentElement: (value) => disclosure.setState("contentElement", value),
8637 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
8638 };
8639 }
8640
8641 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
8642 function useDisclosureStoreProps(store, update2, props) {
8643 useUpdateEffect(update2, [props.store, props.disclosure]);
8644 useStoreProps(store, props, "open", "setOpen");
8645 useStoreProps(store, props, "mounted", "setMounted");
8646 useStoreProps(store, props, "animated");
8647 return Object.assign(store, { disclosure: props.disclosure });
8648 }
8649
8650 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
8651 var ctx5 = createStoreContext(
8652 [DialogContextProvider],
8653 [DialogScopedContextProvider]
8654 );
8655 var usePopoverContext = ctx5.useContext;
8656 var usePopoverScopedContext = ctx5.useScopedContext;
8657 var usePopoverProviderContext = ctx5.useProviderContext;
8658 var PopoverContextProvider = ctx5.ContextProvider;
8659 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
8660
8661 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
8662 function getCommonParent(items) {
8663 var _a;
8664 const firstItem = items.find((item) => !!item.element);
8665 const lastItem = [...items].reverse().find((item) => !!item.element);
8666 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
8667 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
8668 const parent = parentElement;
8669 if (lastItem && parent.contains(lastItem.element)) {
8670 return parentElement;
8671 }
8672 parentElement = parentElement.parentElement;
8673 }
8674 return getDocument(parentElement).body;
8675 }
8676 function getPrivateStore(store) {
8677 return store == null ? void 0 : store.__unstablePrivateStore;
8678 }
8679 function createCollectionStore(props = {}) {
8680 var _a;
8681 throwOnConflictingProps(props, props.store);
8682 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8683 const items = defaultValue(
8684 props.items,
8685 syncState == null ? void 0 : syncState.items,
8686 props.defaultItems,
8687 []
8688 );
8689 const itemsMap = new Map(items.map((item) => [item.id, item]));
8690 const initialState = {
8691 items,
8692 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
8693 };
8694 const syncPrivateStore = getPrivateStore(props.store);
8695 const privateStore = createStore(
8696 { items, renderedItems: initialState.renderedItems },
8697 syncPrivateStore
8698 );
8699 const collection = createStore(initialState, props.store);
8700 const sortItems = (renderedItems) => {
8701 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
8702 privateStore.setState("renderedItems", sortedItems);
8703 collection.setState("renderedItems", sortedItems);
8704 };
8705 setup(collection, () => init(privateStore));
8706 setup(privateStore, () => {
8707 return batch(privateStore, ["items"], (state) => {
8708 collection.setState("items", state.items);
8709 });
8710 });
8711 setup(privateStore, () => {
8712 return batch(privateStore, ["renderedItems"], (state) => {
8713 let firstRun = true;
8714 let raf = requestAnimationFrame(() => {
8715 const { renderedItems } = collection.getState();
8716 if (state.renderedItems === renderedItems) return;
8717 sortItems(state.renderedItems);
8718 });
8719 if (typeof IntersectionObserver !== "function") {
8720 return () => cancelAnimationFrame(raf);
8721 }
8722 const ioCallback = () => {
8723 if (firstRun) {
8724 firstRun = false;
8725 return;
8726 }
8727 cancelAnimationFrame(raf);
8728 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
8729 };
8730 const root = getCommonParent(state.renderedItems);
8731 const observer = new IntersectionObserver(ioCallback, { root });
8732 for (const item of state.renderedItems) {
8733 if (!item.element) continue;
8734 observer.observe(item.element);
8735 }
8736 return () => {
8737 cancelAnimationFrame(raf);
8738 observer.disconnect();
8739 };
8740 });
8741 });
8742 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
8743 let prevItem;
8744 setItems((items2) => {
8745 const index = items2.findIndex(({ id }) => id === item.id);
8746 const nextItems = items2.slice();
8747 if (index !== -1) {
8748 prevItem = items2[index];
8749 const nextItem = { ...prevItem, ...item };
8750 nextItems[index] = nextItem;
8751 itemsMap.set(item.id, nextItem);
8752 } else {
8753 nextItems.push(item);
8754 itemsMap.set(item.id, item);
8755 }
8756 return nextItems;
8757 });
8758 const unmergeItem = () => {
8759 setItems((items2) => {
8760 if (!prevItem) {
8761 if (canDeleteFromMap) {
8762 itemsMap.delete(item.id);
8763 }
8764 return items2.filter(({ id }) => id !== item.id);
8765 }
8766 const index = items2.findIndex(({ id }) => id === item.id);
8767 if (index === -1) return items2;
8768 const nextItems = items2.slice();
8769 nextItems[index] = prevItem;
8770 itemsMap.set(item.id, prevItem);
8771 return nextItems;
8772 });
8773 };
8774 return unmergeItem;
8775 };
8776 const registerItem = (item) => mergeItem(
8777 item,
8778 (getItems) => privateStore.setState("items", getItems),
8779 true
8780 );
8781 return {
8782 ...collection,
8783 registerItem,
8784 renderItem: (item) => chain(
8785 registerItem(item),
8786 mergeItem(
8787 item,
8788 (getItems) => privateStore.setState("renderedItems", getItems)
8789 )
8790 ),
8791 item: (id) => {
8792 if (!id) return null;
8793 let item = itemsMap.get(id);
8794 if (!item) {
8795 const { items: items2 } = privateStore.getState();
8796 item = items2.find((item2) => item2.id === id);
8797 if (item) {
8798 itemsMap.set(id, item);
8799 }
8800 }
8801 return item || null;
8802 },
8803 // @ts-expect-error Internal
8804 __unstablePrivateStore: privateStore
8805 };
8806 }
8807
8808 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
8809 function useCollectionStoreProps(store, update2, props) {
8810 useUpdateEffect(update2, [props.store]);
8811 useStoreProps(store, props, "items", "setItems");
8812 return store;
8813 }
8814
8815 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
8816 var NULL_ITEM = { id: null };
8817 function findFirstEnabledItem2(items, excludeId) {
8818 return items.find((item) => {
8819 if (excludeId) {
8820 return !item.disabled && item.id !== excludeId;
8821 }
8822 return !item.disabled;
8823 });
8824 }
8825 function getEnabledItems(items, excludeId) {
8826 return items.filter((item) => {
8827 if (excludeId) {
8828 return !item.disabled && item.id !== excludeId;
8829 }
8830 return !item.disabled;
8831 });
8832 }
8833 function getItemsInRow(items, rowId) {
8834 return items.filter((item) => item.rowId === rowId);
8835 }
8836 function flipItems(items, activeId, shouldInsertNullItem = false) {
8837 const index = items.findIndex((item) => item.id === activeId);
8838 return [
8839 ...items.slice(index + 1),
8840 ...shouldInsertNullItem ? [NULL_ITEM] : [],
8841 ...items.slice(0, index)
8842 ];
8843 }
8844 function groupItemsByRows2(items) {
8845 const rows = [];
8846 for (const item of items) {
8847 const row = rows.find((currentRow) => {
8848 var _a;
8849 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
8850 });
8851 if (row) {
8852 row.push(item);
8853 } else {
8854 rows.push([item]);
8855 }
8856 }
8857 return rows;
8858 }
8859 function getMaxRowLength(array) {
8860 let maxLength = 0;
8861 for (const { length } of array) {
8862 if (length > maxLength) {
8863 maxLength = length;
8864 }
8865 }
8866 return maxLength;
8867 }
8868 function createEmptyItem(rowId) {
8869 return {
8870 id: "__EMPTY_ITEM__",
8871 disabled: true,
8872 rowId
8873 };
8874 }
8875 function normalizeRows(rows, activeId, focusShift) {
8876 const maxLength = getMaxRowLength(rows);
8877 for (const row of rows) {
8878 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8879 const item = row[i2];
8880 if (!item || focusShift && item.disabled) {
8881 const isFirst = i2 === 0;
8882 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
8883 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
8884 }
8885 }
8886 }
8887 return rows;
8888 }
8889 function verticalizeItems(items) {
8890 const rows = groupItemsByRows2(items);
8891 const maxLength = getMaxRowLength(rows);
8892 const verticalized = [];
8893 for (let i2 = 0; i2 < maxLength; i2 += 1) {
8894 for (const row of rows) {
8895 const item = row[i2];
8896 if (item) {
8897 verticalized.push({
8898 ...item,
8899 // If there's no rowId, it means that it's not a grid composite, but
8900 // a single row instead. So, instead of verticalizing it, that is,
8901 // assigning a different rowId based on the column index, we keep it
8902 // undefined so they will be part of the same row. This is useful
8903 // when using up/down on one-dimensional composites.
8904 rowId: item.rowId ? `${i2}` : void 0
8905 });
8906 }
8907 }
8908 }
8909 return verticalized;
8910 }
8911 function createCompositeStore(props = {}) {
8912 var _a;
8913 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
8914 const collection = createCollectionStore(props);
8915 const activeId = defaultValue(
8916 props.activeId,
8917 syncState == null ? void 0 : syncState.activeId,
8918 props.defaultActiveId
8919 );
8920 const initialState = {
8921 ...collection.getState(),
8922 id: defaultValue(
8923 props.id,
8924 syncState == null ? void 0 : syncState.id,
8925 `id-${Math.random().toString(36).slice(2, 8)}`
8926 ),
8927 activeId,
8928 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
8929 includesBaseElement: defaultValue(
8930 props.includesBaseElement,
8931 syncState == null ? void 0 : syncState.includesBaseElement,
8932 activeId === null
8933 ),
8934 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
8935 orientation: defaultValue(
8936 props.orientation,
8937 syncState == null ? void 0 : syncState.orientation,
8938 "both"
8939 ),
8940 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
8941 virtualFocus: defaultValue(
8942 props.virtualFocus,
8943 syncState == null ? void 0 : syncState.virtualFocus,
8944 false
8945 ),
8946 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
8947 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
8948 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
8949 };
8950 const composite = createStore(initialState, collection, props.store);
8951 setup(
8952 composite,
8953 () => sync(composite, ["renderedItems", "activeId"], (state) => {
8954 composite.setState("activeId", (activeId2) => {
8955 var _a2;
8956 if (activeId2 !== void 0) return activeId2;
8957 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
8958 });
8959 })
8960 );
8961 const getNextId = (direction = "next", options = {}) => {
8962 var _a2, _b;
8963 const defaultState = composite.getState();
8964 const {
8965 skip = 0,
8966 activeId: activeId2 = defaultState.activeId,
8967 focusShift = defaultState.focusShift,
8968 focusLoop = defaultState.focusLoop,
8969 focusWrap = defaultState.focusWrap,
8970 includesBaseElement = defaultState.includesBaseElement,
8971 renderedItems = defaultState.renderedItems,
8972 rtl = defaultState.rtl
8973 } = options;
8974 const isVerticalDirection = direction === "up" || direction === "down";
8975 const isNextDirection = direction === "next" || direction === "down";
8976 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
8977 const canShift = focusShift && !skip;
8978 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
8979 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
8980 );
8981 items = canReverse ? reverseArray(items) : items;
8982 items = isVerticalDirection ? verticalizeItems(items) : items;
8983 if (activeId2 == null) {
8984 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
8985 }
8986 const activeItem = items.find((item) => item.id === activeId2);
8987 if (!activeItem) {
8988 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
8989 }
8990 const isGrid2 = items.some((item) => item.rowId);
8991 const activeIndex = items.indexOf(activeItem);
8992 const nextItems = items.slice(activeIndex + 1);
8993 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
8994 if (skip) {
8995 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
8996 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
8997 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
8998 return nextItem2 == null ? void 0 : nextItem2.id;
8999 }
9000 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
9001 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
9002 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
9003 if (canLoop) {
9004 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
9005 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
9006 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
9007 return nextItem2 == null ? void 0 : nextItem2.id;
9008 }
9009 if (canWrap) {
9010 const nextItem2 = findFirstEnabledItem2(
9011 // We can use nextItems, which contains all the next items, including
9012 // items from other rows, to wrap between rows. However, if there is a
9013 // null item (the composite container), we'll only use the next items in
9014 // the row. So moving next from the last item will focus on the
9015 // composite container. On grid composites, horizontal navigation never
9016 // focuses on the composite container, only vertical.
9017 hasNullItem ? nextItemsInRow : nextItems,
9018 activeId2
9019 );
9020 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
9021 return nextId;
9022 }
9023 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
9024 if (!nextItem && hasNullItem) {
9025 return null;
9026 }
9027 return nextItem == null ? void 0 : nextItem.id;
9028 };
9029 return {
9030 ...collection,
9031 ...composite,
9032 setBaseElement: (element) => composite.setState("baseElement", element),
9033 setActiveId: (id) => composite.setState("activeId", id),
9034 move: (id) => {
9035 if (id === void 0) return;
9036 composite.setState("activeId", id);
9037 composite.setState("moves", (moves) => moves + 1);
9038 },
9039 first: () => {
9040 var _a2;
9041 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
9042 },
9043 last: () => {
9044 var _a2;
9045 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
9046 },
9047 next: (options) => {
9048 if (options !== void 0 && typeof options === "number") {
9049 options = { skip: options };
9050 }
9051 return getNextId("next", options);
9052 },
9053 previous: (options) => {
9054 if (options !== void 0 && typeof options === "number") {
9055 options = { skip: options };
9056 }
9057 return getNextId("previous", options);
9058 },
9059 down: (options) => {
9060 if (options !== void 0 && typeof options === "number") {
9061 options = { skip: options };
9062 }
9063 return getNextId("down", options);
9064 },
9065 up: (options) => {
9066 if (options !== void 0 && typeof options === "number") {
9067 options = { skip: options };
9068 }
9069 return getNextId("up", options);
9070 }
9071 };
9072 }
9073
9074 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
9075 function useCompositeStoreOptions(props) {
9076 const id = useId3(props.id);
9077 return { id, ...props };
9078 }
9079 function useCompositeStoreProps(store, update2, props) {
9080 store = useCollectionStoreProps(store, update2, props);
9081 useStoreProps(store, props, "activeId", "setActiveId");
9082 useStoreProps(store, props, "includesBaseElement");
9083 useStoreProps(store, props, "virtualFocus");
9084 useStoreProps(store, props, "orientation");
9085 useStoreProps(store, props, "rtl");
9086 useStoreProps(store, props, "focusLoop");
9087 useStoreProps(store, props, "focusWrap");
9088 useStoreProps(store, props, "focusShift");
9089 return store;
9090 }
9091
9092 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
9093 var import_react17 = __toESM(require_react(), 1);
9094 var ComboboxListRoleContext = (0, import_react17.createContext)(
9095 void 0
9096 );
9097 var ctx6 = createStoreContext(
9098 [PopoverContextProvider, CompositeContextProvider],
9099 [PopoverScopedContextProvider, CompositeScopedContextProvider]
9100 );
9101 var useComboboxContext = ctx6.useContext;
9102 var useComboboxScopedContext = ctx6.useScopedContext;
9103 var useComboboxProviderContext = ctx6.useProviderContext;
9104 var ComboboxContextProvider = ctx6.ContextProvider;
9105 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
9106 var ComboboxItemValueContext = (0, import_react17.createContext)(
9107 void 0
9108 );
9109 var ComboboxItemCheckedContext = (0, import_react17.createContext)(false);
9110
9111 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
9112 function createDialogStore(props = {}) {
9113 return createDisclosureStore(props);
9114 }
9115
9116 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
9117 function useDialogStoreProps(store, update2, props) {
9118 return useDisclosureStoreProps(store, update2, props);
9119 }
9120
9121 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
9122 function createPopoverStore({
9123 popover: otherPopover,
9124 ...props
9125 } = {}) {
9126 const store = mergeStore(
9127 props.store,
9128 omit22(otherPopover, [
9129 "arrowElement",
9130 "anchorElement",
9131 "contentElement",
9132 "popoverElement",
9133 "disclosureElement"
9134 ])
9135 );
9136 throwOnConflictingProps(props, store);
9137 const syncState = store == null ? void 0 : store.getState();
9138 const dialog = createDialogStore({ ...props, store });
9139 const placement = defaultValue(
9140 props.placement,
9141 syncState == null ? void 0 : syncState.placement,
9142 "bottom"
9143 );
9144 const initialState = {
9145 ...dialog.getState(),
9146 placement,
9147 currentPlacement: placement,
9148 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
9149 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
9150 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
9151 rendered: /* @__PURE__ */ Symbol("rendered")
9152 };
9153 const popover = createStore(initialState, dialog, store);
9154 return {
9155 ...dialog,
9156 ...popover,
9157 setAnchorElement: (element) => popover.setState("anchorElement", element),
9158 setPopoverElement: (element) => popover.setState("popoverElement", element),
9159 setArrowElement: (element) => popover.setState("arrowElement", element),
9160 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
9161 };
9162 }
9163
9164 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
9165 function usePopoverStoreProps(store, update2, props) {
9166 useUpdateEffect(update2, [props.popover]);
9167 useStoreProps(store, props, "placement");
9168 return useDialogStoreProps(store, update2, props);
9169 }
9170
9171 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
9172 var TagName7 = "div";
9173 var usePopoverAnchor = createHook(
9174 function usePopoverAnchor2({ store, ...props }) {
9175 const context = usePopoverProviderContext();
9176 store = store || context;
9177 props = {
9178 ...props,
9179 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref)
9180 };
9181 return props;
9182 }
9183 );
9184 var PopoverAnchor = forwardRef22(function PopoverAnchor2(props) {
9185 const htmlProps = usePopoverAnchor(props);
9186 return createElement3(TagName7, htmlProps);
9187 });
9188
9189 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
9190 var import_react18 = __toESM(require_react(), 1);
9191 var TagName8 = "div";
9192 function getMouseDestination(event) {
9193 const relatedTarget = event.relatedTarget;
9194 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
9195 return relatedTarget;
9196 }
9197 return null;
9198 }
9199 function hoveringInside(event) {
9200 const nextElement = getMouseDestination(event);
9201 if (!nextElement) return false;
9202 return contains(event.currentTarget, nextElement);
9203 }
9204 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
9205 function movingToAnotherItem(event) {
9206 let dest = getMouseDestination(event);
9207 if (!dest) return false;
9208 do {
9209 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
9210 dest = dest.parentElement;
9211 } while (dest);
9212 return false;
9213 }
9214 var useCompositeHover = createHook(
9215 function useCompositeHover2({
9216 store,
9217 focusOnHover = true,
9218 blurOnHoverEnd = !!focusOnHover,
9219 ...props
9220 }) {
9221 const context = useCompositeContext();
9222 store = store || context;
9223 invariant(
9224 store,
9225 "CompositeHover must be wrapped in a Composite component."
9226 );
9227 const isMouseMoving = useIsMouseMoving();
9228 const onMouseMoveProp = props.onMouseMove;
9229 const focusOnHoverProp = useBooleanEvent(focusOnHover);
9230 const onMouseMove = useEvent((event) => {
9231 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
9232 if (event.defaultPrevented) return;
9233 if (!isMouseMoving()) return;
9234 if (!focusOnHoverProp(event)) return;
9235 if (!hasFocusWithin(event.currentTarget)) {
9236 const baseElement = store == null ? void 0 : store.getState().baseElement;
9237 if (baseElement && !hasFocus(baseElement)) {
9238 baseElement.focus();
9239 }
9240 }
9241 store == null ? void 0 : store.setActiveId(event.currentTarget.id);
9242 });
9243 const onMouseLeaveProp = props.onMouseLeave;
9244 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
9245 const onMouseLeave = useEvent((event) => {
9246 var _a;
9247 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
9248 if (event.defaultPrevented) return;
9249 if (!isMouseMoving()) return;
9250 if (hoveringInside(event)) return;
9251 if (movingToAnotherItem(event)) return;
9252 if (!focusOnHoverProp(event)) return;
9253 if (!blurOnHoverEndProp(event)) return;
9254 store == null ? void 0 : store.setActiveId(null);
9255 (_a = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a.focus();
9256 });
9257 const ref = (0, import_react18.useCallback)((element) => {
9258 if (!element) return;
9259 element[symbol2] = true;
9260 }, []);
9261 props = {
9262 ...props,
9263 ref: useMergeRefs(ref, props.ref),
9264 onMouseMove,
9265 onMouseLeave
9266 };
9267 return removeUndefinedValues(props);
9268 }
9269 );
9270 var CompositeHover = memo22(
9271 forwardRef22(function CompositeHover2(props) {
9272 const htmlProps = useCompositeHover(props);
9273 return createElement3(TagName8, htmlProps);
9274 })
9275 );
9276
9277 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
9278 var import_react19 = __toESM(require_react(), 1);
9279 var TagName9 = "input";
9280 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
9281 if (!autoSelect) return false;
9282 const firstItem = items.find((item) => !item.disabled && item.value);
9283 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
9284 }
9285 function hasCompletionString(value, activeValue) {
9286 if (!activeValue) return false;
9287 if (value == null) return false;
9288 value = normalizeString(value);
9289 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
9290 }
9291 function isInputEvent(event) {
9292 return event.type === "input";
9293 }
9294 function isAriaAutoCompleteValue(value) {
9295 return value === "inline" || value === "list" || value === "both" || value === "none";
9296 }
9297 function getDefaultAutoSelectId(items) {
9298 const item = items.find((item2) => {
9299 var _a;
9300 if (item2.disabled) return false;
9301 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
9302 });
9303 return item == null ? void 0 : item.id;
9304 }
9305 var useCombobox = createHook(
9306 function useCombobox2({
9307 store,
9308 focusable = true,
9309 autoSelect: autoSelectProp = false,
9310 getAutoSelectId,
9311 setValueOnChange,
9312 showMinLength = 0,
9313 showOnChange,
9314 showOnMouseDown,
9315 showOnClick = showOnMouseDown,
9316 showOnKeyDown,
9317 showOnKeyPress = showOnKeyDown,
9318 blurActiveItemOnClick,
9319 setValueOnClick = true,
9320 moveOnKeyPress = true,
9321 autoComplete = "list",
9322 ...props
9323 }) {
9324 const context = useComboboxProviderContext();
9325 store = store || context;
9326 invariant(
9327 store,
9328 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
9329 );
9330 const ref = (0, import_react19.useRef)(null);
9331 const [valueUpdated, forceValueUpdate] = useForceUpdate();
9332 const canAutoSelectRef = (0, import_react19.useRef)(false);
9333 const composingRef = (0, import_react19.useRef)(false);
9334 const autoSelect = store.useState(
9335 (state) => state.virtualFocus && autoSelectProp
9336 );
9337 const inline = autoComplete === "inline" || autoComplete === "both";
9338 const [canInline, setCanInline] = (0, import_react19.useState)(inline);
9339 useUpdateLayoutEffect(() => {
9340 if (!inline) return;
9341 setCanInline(true);
9342 }, [inline]);
9343 const storeValue = store.useState("value");
9344 const prevSelectedValueRef = (0, import_react19.useRef)(void 0);
9345 (0, import_react19.useEffect)(() => {
9346 return sync(store, ["selectedValue", "activeId"], (_, prev) => {
9347 prevSelectedValueRef.current = prev.selectedValue;
9348 });
9349 }, []);
9350 const inlineActiveValue = store.useState((state) => {
9351 var _a;
9352 if (!inline) return;
9353 if (!canInline) return;
9354 if (state.activeValue && Array.isArray(state.selectedValue)) {
9355 if (state.selectedValue.includes(state.activeValue)) return;
9356 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
9357 }
9358 return state.activeValue;
9359 });
9360 const items = store.useState("renderedItems");
9361 const open = store.useState("open");
9362 const contentElement = store.useState("contentElement");
9363 const value = (0, import_react19.useMemo)(() => {
9364 if (!inline) return storeValue;
9365 if (!canInline) return storeValue;
9366 const firstItemAutoSelected = isFirstItemAutoSelected(
9367 items,
9368 inlineActiveValue,
9369 autoSelect
9370 );
9371 if (firstItemAutoSelected) {
9372 if (hasCompletionString(storeValue, inlineActiveValue)) {
9373 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
9374 return storeValue + slice;
9375 }
9376 return storeValue;
9377 }
9378 return inlineActiveValue || storeValue;
9379 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
9380 (0, import_react19.useEffect)(() => {
9381 const element = ref.current;
9382 if (!element) return;
9383 const onCompositeItemMove = () => setCanInline(true);
9384 element.addEventListener("combobox-item-move", onCompositeItemMove);
9385 return () => {
9386 element.removeEventListener("combobox-item-move", onCompositeItemMove);
9387 };
9388 }, []);
9389 (0, import_react19.useEffect)(() => {
9390 if (!inline) return;
9391 if (!canInline) return;
9392 if (!inlineActiveValue) return;
9393 const firstItemAutoSelected = isFirstItemAutoSelected(
9394 items,
9395 inlineActiveValue,
9396 autoSelect
9397 );
9398 if (!firstItemAutoSelected) return;
9399 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
9400 let cleanup = noop;
9401 queueMicrotask(() => {
9402 const element = ref.current;
9403 if (!element) return;
9404 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
9405 const nextStart = storeValue.length;
9406 const nextEnd = inlineActiveValue.length;
9407 setSelectionRange(element, nextStart, nextEnd);
9408 cleanup = () => {
9409 if (!hasFocus(element)) return;
9410 const { start, end } = getTextboxSelection(element);
9411 if (start !== nextStart) return;
9412 if (end !== nextEnd) return;
9413 setSelectionRange(element, prevStart, prevEnd);
9414 };
9415 });
9416 return () => cleanup();
9417 }, [
9418 valueUpdated,
9419 inline,
9420 canInline,
9421 inlineActiveValue,
9422 items,
9423 autoSelect,
9424 storeValue
9425 ]);
9426 const scrollingElementRef = (0, import_react19.useRef)(null);
9427 const getAutoSelectIdProp = useEvent(getAutoSelectId);
9428 const autoSelectIdRef = (0, import_react19.useRef)(null);
9429 (0, import_react19.useEffect)(() => {
9430 if (!open) return;
9431 if (!contentElement) return;
9432 const scrollingElement = getScrollingElement(contentElement);
9433 if (!scrollingElement) return;
9434 scrollingElementRef.current = scrollingElement;
9435 const onUserScroll = () => {
9436 canAutoSelectRef.current = false;
9437 };
9438 const onScroll = () => {
9439 if (!store) return;
9440 if (!canAutoSelectRef.current) return;
9441 const { activeId } = store.getState();
9442 if (activeId === null) return;
9443 if (activeId === autoSelectIdRef.current) return;
9444 canAutoSelectRef.current = false;
9445 };
9446 const options = { passive: true, capture: true };
9447 scrollingElement.addEventListener("wheel", onUserScroll, options);
9448 scrollingElement.addEventListener("touchmove", onUserScroll, options);
9449 scrollingElement.addEventListener("scroll", onScroll, options);
9450 return () => {
9451 scrollingElement.removeEventListener("wheel", onUserScroll, true);
9452 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
9453 scrollingElement.removeEventListener("scroll", onScroll, true);
9454 };
9455 }, [open, contentElement, store]);
9456 useSafeLayoutEffect(() => {
9457 if (!storeValue) return;
9458 if (composingRef.current) return;
9459 canAutoSelectRef.current = true;
9460 }, [storeValue]);
9461 useSafeLayoutEffect(() => {
9462 if (autoSelect !== "always" && open) return;
9463 canAutoSelectRef.current = open;
9464 }, [autoSelect, open]);
9465 const resetValueOnSelect = store.useState("resetValueOnSelect");
9466 useUpdateEffect(() => {
9467 var _a, _b;
9468 const canAutoSelect = canAutoSelectRef.current;
9469 if (!store) return;
9470 if (!open) return;
9471 if (!canAutoSelect && !resetValueOnSelect) return;
9472 const { baseElement, contentElement: contentElement2, activeId } = store.getState();
9473 if (baseElement && !hasFocus(baseElement)) return;
9474 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
9475 const observer = new MutationObserver(forceValueUpdate);
9476 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
9477 return () => observer.disconnect();
9478 }
9479 if (autoSelect && canAutoSelect) {
9480 const userAutoSelectId = getAutoSelectIdProp(items);
9481 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store.first();
9482 autoSelectIdRef.current = autoSelectId;
9483 store.move(autoSelectId != null ? autoSelectId : null);
9484 } else {
9485 const element = (_b = store.item(activeId || store.first())) == null ? void 0 : _b.element;
9486 if (element && "scrollIntoView" in element) {
9487 element.scrollIntoView({ block: "nearest", inline: "nearest" });
9488 }
9489 }
9490 return;
9491 }, [
9492 store,
9493 open,
9494 valueUpdated,
9495 storeValue,
9496 autoSelect,
9497 resetValueOnSelect,
9498 getAutoSelectIdProp,
9499 items
9500 ]);
9501 (0, import_react19.useEffect)(() => {
9502 if (!inline) return;
9503 const combobox = ref.current;
9504 if (!combobox) return;
9505 const elements = [combobox, contentElement].filter(
9506 (value2) => !!value2
9507 );
9508 const onBlur2 = (event) => {
9509 if (elements.every((el) => isFocusEventOutside(event, el))) {
9510 store == null ? void 0 : store.setValue(value);
9511 }
9512 };
9513 for (const element of elements) {
9514 element.addEventListener("focusout", onBlur2);
9515 }
9516 return () => {
9517 for (const element of elements) {
9518 element.removeEventListener("focusout", onBlur2);
9519 }
9520 };
9521 }, [inline, contentElement, store, value]);
9522 const canShow = (event) => {
9523 const currentTarget = event.currentTarget;
9524 return currentTarget.value.length >= showMinLength;
9525 };
9526 const onChangeProp = props.onChange;
9527 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
9528 const setValueOnChangeProp = useBooleanEvent(
9529 // If the combobox is combined with tags, the value will be set by the tag
9530 // input component.
9531 setValueOnChange != null ? setValueOnChange : !store.tag
9532 );
9533 const onChange = useEvent((event) => {
9534 onChangeProp == null ? void 0 : onChangeProp(event);
9535 if (event.defaultPrevented) return;
9536 if (!store) return;
9537 const currentTarget = event.currentTarget;
9538 const { value: value2, selectionStart, selectionEnd } = currentTarget;
9539 const nativeEvent = event.nativeEvent;
9540 canAutoSelectRef.current = true;
9541 if (isInputEvent(nativeEvent)) {
9542 if (nativeEvent.isComposing) {
9543 canAutoSelectRef.current = false;
9544 composingRef.current = true;
9545 }
9546 if (inline) {
9547 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
9548 const caretAtEnd = selectionStart === value2.length;
9549 setCanInline(textInserted && caretAtEnd);
9550 }
9551 }
9552 if (setValueOnChangeProp(event)) {
9553 const isSameValue = value2 === store.getState().value;
9554 store.setValue(value2);
9555 queueMicrotask(() => {
9556 setSelectionRange(currentTarget, selectionStart, selectionEnd);
9557 });
9558 if (inline && autoSelect && isSameValue) {
9559 forceValueUpdate();
9560 }
9561 }
9562 if (showOnChangeProp(event)) {
9563 store.show();
9564 }
9565 if (!autoSelect || !canAutoSelectRef.current) {
9566 store.setActiveId(null);
9567 }
9568 });
9569 const onCompositionEndProp = props.onCompositionEnd;
9570 const onCompositionEnd = useEvent((event) => {
9571 canAutoSelectRef.current = true;
9572 composingRef.current = false;
9573 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
9574 if (event.defaultPrevented) return;
9575 if (!autoSelect) return;
9576 forceValueUpdate();
9577 });
9578 const onMouseDownProp = props.onMouseDown;
9579 const blurActiveItemOnClickProp = useBooleanEvent(
9580 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store == null ? void 0 : store.getState().includesBaseElement))
9581 );
9582 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9583 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
9584 const onMouseDown = useEvent((event) => {
9585 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9586 if (event.defaultPrevented) return;
9587 if (event.button) return;
9588 if (event.ctrlKey) return;
9589 if (!store) return;
9590 if (blurActiveItemOnClickProp(event)) {
9591 store.setActiveId(null);
9592 }
9593 if (setValueOnClickProp(event)) {
9594 store.setValue(value);
9595 }
9596 if (showOnClickProp(event)) {
9597 queueBeforeEvent(event.currentTarget, "mouseup", store.show);
9598 }
9599 });
9600 const onKeyDownProp = props.onKeyDown;
9601 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
9602 const onKeyDown = useEvent((event) => {
9603 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9604 if (!event.repeat) {
9605 canAutoSelectRef.current = false;
9606 }
9607 if (event.defaultPrevented) return;
9608 if (event.ctrlKey) return;
9609 if (event.altKey) return;
9610 if (event.shiftKey) return;
9611 if (event.metaKey) return;
9612 if (!store) return;
9613 const { open: open2 } = store.getState();
9614 if (open2) return;
9615 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
9616 if (showOnKeyPressProp(event)) {
9617 event.preventDefault();
9618 store.show();
9619 }
9620 }
9621 });
9622 const onBlurProp = props.onBlur;
9623 const onBlur = useEvent((event) => {
9624 canAutoSelectRef.current = false;
9625 onBlurProp == null ? void 0 : onBlurProp(event);
9626 if (event.defaultPrevented) return;
9627 });
9628 const id = useId3(props.id);
9629 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
9630 const isActiveItem = store.useState((state) => state.activeId === null);
9631 props = {
9632 id,
9633 role: "combobox",
9634 "aria-autocomplete": ariaAutoComplete,
9635 "aria-haspopup": getPopupRole(contentElement, "listbox"),
9636 "aria-expanded": open,
9637 "aria-controls": contentElement == null ? void 0 : contentElement.id,
9638 "data-active-item": isActiveItem || void 0,
9639 value,
9640 ...props,
9641 ref: useMergeRefs(ref, props.ref),
9642 onChange,
9643 onCompositionEnd,
9644 onMouseDown,
9645 onKeyDown,
9646 onBlur
9647 };
9648 props = useComposite({
9649 store,
9650 focusable,
9651 ...props,
9652 // Enable inline autocomplete when the user moves from the combobox input
9653 // to an item.
9654 moveOnKeyPress: (event) => {
9655 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
9656 if (inline) setCanInline(true);
9657 return true;
9658 }
9659 });
9660 props = usePopoverAnchor({ store, ...props });
9661 return { autoComplete: "off", ...props };
9662 }
9663 );
9664 var Combobox = forwardRef22(function Combobox2(props) {
9665 const htmlProps = useCombobox(props);
9666 return createElement3(TagName9, htmlProps);
9667 });
9668
9669 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
9670 var import_react20 = __toESM(require_react(), 1);
9671 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
9672 var TagName10 = "div";
9673 function isSelected(storeValue, itemValue) {
9674 if (itemValue == null) return;
9675 if (storeValue == null) return false;
9676 if (Array.isArray(storeValue)) {
9677 return storeValue.includes(itemValue);
9678 }
9679 return storeValue === itemValue;
9680 }
9681 function getItemRole(popupRole) {
9682 var _a;
9683 const itemRoleByPopupRole = {
9684 menu: "menuitem",
9685 listbox: "option",
9686 tree: "treeitem"
9687 };
9688 const key = popupRole;
9689 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
9690 }
9691 var useComboboxItem = createHook(
9692 function useComboboxItem2({
9693 store,
9694 value,
9695 hideOnClick,
9696 setValueOnClick,
9697 selectValueOnClick = true,
9698 resetValueOnSelect,
9699 focusOnHover = false,
9700 moveOnKeyPress = true,
9701 getItem: getItemProp,
9702 ...props
9703 }) {
9704 var _a;
9705 const context = useComboboxScopedContext();
9706 store = store || context;
9707 invariant(
9708 store,
9709 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
9710 );
9711 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store, {
9712 resetValueOnSelectState: "resetValueOnSelect",
9713 multiSelectable(state) {
9714 return Array.isArray(state.selectedValue);
9715 },
9716 selected(state) {
9717 return isSelected(state.selectedValue, value);
9718 }
9719 });
9720 const getItem = (0, import_react20.useCallback)(
9721 (item) => {
9722 const nextItem = { ...item, value };
9723 if (getItemProp) {
9724 return getItemProp(nextItem);
9725 }
9726 return nextItem;
9727 },
9728 [value, getItemProp]
9729 );
9730 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
9731 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
9732 const onClickProp = props.onClick;
9733 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
9734 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
9735 const resetValueOnSelectProp = useBooleanEvent(
9736 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
9737 );
9738 const hideOnClickProp = useBooleanEvent(hideOnClick);
9739 const onClick = useEvent((event) => {
9740 onClickProp == null ? void 0 : onClickProp(event);
9741 if (event.defaultPrevented) return;
9742 if (isDownloading(event)) return;
9743 if (isOpeningInNewTab(event)) return;
9744 if (value != null) {
9745 if (selectValueOnClickProp(event)) {
9746 if (resetValueOnSelectProp(event)) {
9747 store == null ? void 0 : store.resetValue();
9748 }
9749 store == null ? void 0 : store.setSelectedValue((prevValue) => {
9750 if (!Array.isArray(prevValue)) return value;
9751 if (prevValue.includes(value)) {
9752 return prevValue.filter((v2) => v2 !== value);
9753 }
9754 return [...prevValue, value];
9755 });
9756 }
9757 if (setValueOnClickProp(event)) {
9758 store == null ? void 0 : store.setValue(value);
9759 }
9760 }
9761 if (hideOnClickProp(event)) {
9762 store == null ? void 0 : store.hide();
9763 }
9764 });
9765 const onKeyDownProp = props.onKeyDown;
9766 const onKeyDown = useEvent((event) => {
9767 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9768 if (event.defaultPrevented) return;
9769 const baseElement = store == null ? void 0 : store.getState().baseElement;
9770 if (!baseElement) return;
9771 if (hasFocus(baseElement)) return;
9772 const printable = event.key.length === 1;
9773 if (printable || event.key === "Backspace" || event.key === "Delete") {
9774 queueMicrotask(() => baseElement.focus());
9775 if (isTextField(baseElement)) {
9776 store == null ? void 0 : store.setValue(baseElement.value);
9777 }
9778 }
9779 });
9780 if (multiSelectable && selected != null) {
9781 props = {
9782 "aria-selected": selected,
9783 ...props
9784 };
9785 }
9786 props = useWrapElement(
9787 props,
9788 (element) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
9789 [value, selected]
9790 );
9791 const popupRole = (0, import_react20.useContext)(ComboboxListRoleContext);
9792 props = {
9793 role: getItemRole(popupRole),
9794 children: value,
9795 ...props,
9796 onClick,
9797 onKeyDown
9798 };
9799 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
9800 props = useCompositeItem({
9801 store,
9802 ...props,
9803 getItem,
9804 // Dispatch a custom event on the combobox input when moving to an item
9805 // with the keyboard so the Combobox component can enable inline
9806 // autocompletion.
9807 moveOnKeyPress: (event) => {
9808 if (!moveOnKeyPressProp(event)) return false;
9809 const moveEvent = new Event("combobox-item-move");
9810 const baseElement = store == null ? void 0 : store.getState().baseElement;
9811 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
9812 return true;
9813 }
9814 });
9815 props = useCompositeHover({ store, focusOnHover, ...props });
9816 return props;
9817 }
9818 );
9819 var ComboboxItem = memo22(
9820 forwardRef22(function ComboboxItem2(props) {
9821 const htmlProps = useComboboxItem(props);
9822 return createElement3(TagName10, htmlProps);
9823 })
9824 );
9825
9826 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
9827 var import_react21 = __toESM(require_react(), 1);
9828 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
9829 var TagName11 = "span";
9830 function normalizeValue(value) {
9831 return normalizeString(value).toLowerCase();
9832 }
9833 function getOffsets(string, values) {
9834 const offsets = [];
9835 for (const value of values) {
9836 let pos = 0;
9837 const length = value.length;
9838 while (string.indexOf(value, pos) !== -1) {
9839 const index = string.indexOf(value, pos);
9840 if (index !== -1) {
9841 offsets.push([index, length]);
9842 }
9843 pos = index + 1;
9844 }
9845 }
9846 return offsets;
9847 }
9848 function filterOverlappingOffsets(offsets) {
9849 return offsets.filter(([offset, length], i2, arr) => {
9850 return !arr.some(
9851 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
9852 );
9853 });
9854 }
9855 function sortOffsets(offsets) {
9856 return offsets.sort(([a2], [b2]) => a2 - b2);
9857 }
9858 function splitValue(itemValue, userValue) {
9859 if (!itemValue) return itemValue;
9860 if (!userValue) return itemValue;
9861 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
9862 const parts = [];
9863 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
9864 "span",
9865 {
9866 "data-autocomplete-value": autocomplete ? "" : void 0,
9867 "data-user-value": autocomplete ? void 0 : "",
9868 children: value
9869 },
9870 parts.length
9871 );
9872 const offsets = sortOffsets(
9873 filterOverlappingOffsets(
9874 // Convert userValues into a set to avoid duplicates
9875 getOffsets(normalizeValue(itemValue), new Set(userValues))
9876 )
9877 );
9878 if (!offsets.length) {
9879 parts.push(span(itemValue, true));
9880 return parts;
9881 }
9882 const [firstOffset] = offsets[0];
9883 const values = [
9884 itemValue.slice(0, firstOffset),
9885 ...offsets.flatMap(([offset, length], i2) => {
9886 var _a;
9887 const value = itemValue.slice(offset, offset + length);
9888 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
9889 const nextValue = itemValue.slice(offset + length, nextOffset);
9890 return [value, nextValue];
9891 })
9892 ];
9893 values.forEach((value, i2) => {
9894 if (!value) return;
9895 parts.push(span(value, i2 % 2 === 0));
9896 });
9897 return parts;
9898 }
9899 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store, value, userValue, ...props }) {
9900 const context = useComboboxScopedContext();
9901 store = store || context;
9902 const itemContext = (0, import_react21.useContext)(ComboboxItemValueContext);
9903 const itemValue = value != null ? value : itemContext;
9904 const inputValue = useStoreState(store, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
9905 const children = (0, import_react21.useMemo)(() => {
9906 if (!itemValue) return;
9907 if (!inputValue) return itemValue;
9908 return splitValue(itemValue, inputValue);
9909 }, [itemValue, inputValue]);
9910 props = {
9911 children,
9912 ...props
9913 };
9914 return removeUndefinedValues(props);
9915 });
9916 var ComboboxItemValue = forwardRef22(function ComboboxItemValue2(props) {
9917 const htmlProps = useComboboxItemValue(props);
9918 return createElement3(TagName11, htmlProps);
9919 });
9920
9921 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
9922 var TagName12 = "label";
9923 var useComboboxLabel = createHook(
9924 function useComboboxLabel2({ store, ...props }) {
9925 const context = useComboboxProviderContext();
9926 store = store || context;
9927 invariant(
9928 store,
9929 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
9930 );
9931 const comboboxId = store.useState((state) => {
9932 var _a;
9933 return (_a = state.baseElement) == null ? void 0 : _a.id;
9934 });
9935 props = {
9936 htmlFor: comboboxId,
9937 ...props
9938 };
9939 return removeUndefinedValues(props);
9940 }
9941 );
9942 var ComboboxLabel = memo22(
9943 forwardRef22(function ComboboxLabel2(props) {
9944 const htmlProps = useComboboxLabel(props);
9945 return createElement3(TagName12, htmlProps);
9946 })
9947 );
9948
9949 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
9950 var import_react22 = __toESM(require_react(), 1);
9951 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
9952 var TagName13 = "div";
9953 var useComboboxList = createHook(
9954 function useComboboxList2({ store, alwaysVisible, ...props }) {
9955 const scopedContext = useComboboxScopedContext(true);
9956 const context = useComboboxContext();
9957 store = store || context;
9958 const scopedContextSameStore = !!store && store === scopedContext;
9959 invariant(
9960 store,
9961 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
9962 );
9963 const ref = (0, import_react22.useRef)(null);
9964 const id = useId3(props.id);
9965 const mounted = store.useState("mounted");
9966 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
9967 const style = hidden ? { ...props.style, display: "none" } : props.style;
9968 const multiSelectable = store.useState(
9969 (state) => Array.isArray(state.selectedValue)
9970 );
9971 const role = useAttribute(ref, "role", props.role);
9972 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
9973 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
9974 const [hasListboxInside, setHasListboxInside] = (0, import_react22.useState)(false);
9975 const contentElement = store.useState("contentElement");
9976 useSafeLayoutEffect(() => {
9977 if (!mounted) return;
9978 const element = ref.current;
9979 if (!element) return;
9980 if (contentElement !== element) return;
9981 const callback = () => {
9982 setHasListboxInside(!!element.querySelector("[role='listbox']"));
9983 };
9984 const observer = new MutationObserver(callback);
9985 observer.observe(element, {
9986 subtree: true,
9987 childList: true,
9988 attributeFilter: ["role"]
9989 });
9990 callback();
9991 return () => observer.disconnect();
9992 }, [mounted, contentElement]);
9993 if (!hasListboxInside) {
9994 props = {
9995 role: "listbox",
9996 "aria-multiselectable": ariaMultiSelectable,
9997 ...props
9998 };
9999 }
10000 props = useWrapElement(
10001 props,
10002 (element) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ComboboxScopedContextProvider, { value: store, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
10003 [store, role]
10004 );
10005 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store.setContentElement : null;
10006 props = {
10007 id,
10008 hidden,
10009 ...props,
10010 ref: useMergeRefs(setContentElement, ref, props.ref),
10011 style
10012 };
10013 return removeUndefinedValues(props);
10014 }
10015 );
10016 var ComboboxList = forwardRef22(function ComboboxList2(props) {
10017 const htmlProps = useComboboxList(props);
10018 return createElement3(TagName13, htmlProps);
10019 });
10020
10021 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
10022 var import_react23 = __toESM(require_react(), 1);
10023 var TagValueContext = (0, import_react23.createContext)(null);
10024 var TagRemoveIdContext = (0, import_react23.createContext)(
10025 null
10026 );
10027 var ctx7 = createStoreContext(
10028 [CompositeContextProvider],
10029 [CompositeScopedContextProvider]
10030 );
10031 var useTagContext = ctx7.useContext;
10032 var useTagScopedContext = ctx7.useScopedContext;
10033 var useTagProviderContext = ctx7.useProviderContext;
10034 var TagContextProvider = ctx7.ContextProvider;
10035 var TagScopedContextProvider = ctx7.ScopedContextProvider;
10036
10037 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
10038 var isTouchSafari = isSafari() && isTouchDevice();
10039 function createComboboxStore({
10040 tag,
10041 ...props
10042 } = {}) {
10043 const store = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
10044 throwOnConflictingProps(props, store);
10045 const tagState = tag == null ? void 0 : tag.getState();
10046 const syncState = store == null ? void 0 : store.getState();
10047 const activeId = defaultValue(
10048 props.activeId,
10049 syncState == null ? void 0 : syncState.activeId,
10050 props.defaultActiveId,
10051 null
10052 );
10053 const composite = createCompositeStore({
10054 ...props,
10055 activeId,
10056 includesBaseElement: defaultValue(
10057 props.includesBaseElement,
10058 syncState == null ? void 0 : syncState.includesBaseElement,
10059 true
10060 ),
10061 orientation: defaultValue(
10062 props.orientation,
10063 syncState == null ? void 0 : syncState.orientation,
10064 "vertical"
10065 ),
10066 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
10067 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
10068 virtualFocus: defaultValue(
10069 props.virtualFocus,
10070 syncState == null ? void 0 : syncState.virtualFocus,
10071 true
10072 )
10073 });
10074 const popover = createPopoverStore({
10075 ...props,
10076 placement: defaultValue(
10077 props.placement,
10078 syncState == null ? void 0 : syncState.placement,
10079 "bottom-start"
10080 )
10081 });
10082 const value = defaultValue(
10083 props.value,
10084 syncState == null ? void 0 : syncState.value,
10085 props.defaultValue,
10086 ""
10087 );
10088 const selectedValue = defaultValue(
10089 props.selectedValue,
10090 syncState == null ? void 0 : syncState.selectedValue,
10091 tagState == null ? void 0 : tagState.values,
10092 props.defaultSelectedValue,
10093 ""
10094 );
10095 const multiSelectable = Array.isArray(selectedValue);
10096 const initialState = {
10097 ...composite.getState(),
10098 ...popover.getState(),
10099 value,
10100 selectedValue,
10101 resetValueOnSelect: defaultValue(
10102 props.resetValueOnSelect,
10103 syncState == null ? void 0 : syncState.resetValueOnSelect,
10104 multiSelectable
10105 ),
10106 resetValueOnHide: defaultValue(
10107 props.resetValueOnHide,
10108 syncState == null ? void 0 : syncState.resetValueOnHide,
10109 multiSelectable && !tag
10110 ),
10111 activeValue: syncState == null ? void 0 : syncState.activeValue
10112 };
10113 const combobox = createStore(initialState, composite, popover, store);
10114 if (isTouchSafari) {
10115 setup(
10116 combobox,
10117 () => sync(combobox, ["virtualFocus"], () => {
10118 combobox.setState("virtualFocus", false);
10119 })
10120 );
10121 }
10122 setup(combobox, () => {
10123 if (!tag) return;
10124 return chain(
10125 sync(combobox, ["selectedValue"], (state) => {
10126 if (!Array.isArray(state.selectedValue)) return;
10127 tag.setValues(state.selectedValue);
10128 }),
10129 sync(tag, ["values"], (state) => {
10130 combobox.setState("selectedValue", state.values);
10131 })
10132 );
10133 });
10134 setup(
10135 combobox,
10136 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
10137 if (!state.resetValueOnHide) return;
10138 if (state.mounted) return;
10139 combobox.setState("value", value);
10140 })
10141 );
10142 setup(
10143 combobox,
10144 () => sync(combobox, ["open"], (state) => {
10145 if (state.open) return;
10146 combobox.setState("activeId", activeId);
10147 combobox.setState("moves", 0);
10148 })
10149 );
10150 setup(
10151 combobox,
10152 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
10153 if (state.moves === prevState.moves) {
10154 combobox.setState("activeValue", void 0);
10155 }
10156 })
10157 );
10158 setup(
10159 combobox,
10160 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
10161 if (state.moves === prev.moves) return;
10162 const { activeId: activeId2 } = combobox.getState();
10163 const activeItem = composite.item(activeId2);
10164 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
10165 })
10166 );
10167 return {
10168 ...popover,
10169 ...composite,
10170 ...combobox,
10171 tag,
10172 setValue: (value2) => combobox.setState("value", value2),
10173 resetValue: () => combobox.setState("value", initialState.value),
10174 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
10175 };
10176 }
10177
10178 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
10179 function useComboboxStoreOptions(props) {
10180 const tag = useTagContext();
10181 props = {
10182 ...props,
10183 tag: props.tag !== void 0 ? props.tag : tag
10184 };
10185 return useCompositeStoreOptions(props);
10186 }
10187 function useComboboxStoreProps(store, update2, props) {
10188 useUpdateEffect(update2, [props.tag]);
10189 useStoreProps(store, props, "value", "setValue");
10190 useStoreProps(store, props, "selectedValue", "setSelectedValue");
10191 useStoreProps(store, props, "resetValueOnHide");
10192 useStoreProps(store, props, "resetValueOnSelect");
10193 return Object.assign(
10194 useCompositeStoreProps(
10195 usePopoverStoreProps(store, update2, props),
10196 update2,
10197 props
10198 ),
10199 { tag: props.tag }
10200 );
10201 }
10202 function useComboboxStore(props = {}) {
10203 props = useComboboxStoreOptions(props);
10204 const [store, update2] = useStore(createComboboxStore, props);
10205 return useComboboxStoreProps(store, update2, props);
10206 }
10207
10208 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
10209 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
10210 function ComboboxProvider(props = {}) {
10211 const store = useComboboxStore(props);
10212 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(ComboboxContextProvider, { value: store, children: props.children });
10213 }
10214
10215 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10216 var import_remove_accents = __toESM(require_remove_accents(), 1);
10217 var import_compose7 = __toESM(require_compose(), 1);
10218 var import_i18n22 = __toESM(require_i18n(), 1);
10219 var import_element28 = __toESM(require_element(), 1);
10220 var import_components18 = __toESM(require_components(), 1);
10221
10222 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
10223 var EMPTY_ARRAY3 = [];
10224 var getCurrentValue = (filterDefinition, currentFilter) => {
10225 if (filterDefinition.singleSelection) {
10226 return currentFilter?.value;
10227 }
10228 if (Array.isArray(currentFilter?.value)) {
10229 return currentFilter.value;
10230 }
10231 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
10232 return [currentFilter.value];
10233 }
10234 return EMPTY_ARRAY3;
10235 };
10236
10237 // packages/dataviews/build-module/hooks/use-elements.mjs
10238 var import_element27 = __toESM(require_element(), 1);
10239 var EMPTY_ARRAY4 = [];
10240 function useElements({
10241 elements,
10242 getElements
10243 }) {
10244 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
10245 const [records, setRecords] = (0, import_element27.useState)(staticElements);
10246 const [isLoading, setIsLoading] = (0, import_element27.useState)(false);
10247 (0, import_element27.useEffect)(() => {
10248 if (!getElements) {
10249 setRecords(staticElements);
10250 return;
10251 }
10252 let cancelled = false;
10253 setIsLoading(true);
10254 getElements().then((fetchedElements) => {
10255 if (!cancelled) {
10256 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
10257 setRecords(dynamicElements);
10258 }
10259 }).catch(() => {
10260 if (!cancelled) {
10261 setRecords(staticElements);
10262 }
10263 }).finally(() => {
10264 if (!cancelled) {
10265 setIsLoading(false);
10266 }
10267 });
10268 return () => {
10269 cancelled = true;
10270 };
10271 }, [getElements, staticElements]);
10272 return {
10273 elements: records,
10274 isLoading
10275 };
10276 }
10277
10278 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
10279 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
10280 function normalizeSearchInput(input = "") {
10281 return (0, import_remove_accents.default)(input.trim().toLowerCase());
10282 }
10283 var getNewValue = (filterDefinition, currentFilter, value) => {
10284 if (filterDefinition.singleSelection) {
10285 return value;
10286 }
10287 if (Array.isArray(currentFilter?.value)) {
10288 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
10289 }
10290 return [value];
10291 };
10292 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
10293 return `${prefix}-${filterElementValue}`;
10294 }
10295 var MultiSelectionOption = ({ selected }) => {
10296 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10297 "span",
10298 {
10299 className: clsx_default(
10300 "dataviews-filters__search-widget-listitem-multi-selection",
10301 { "is-selected": selected }
10302 ),
10303 children: selected && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Icon, { icon: check_default })
10304 }
10305 );
10306 };
10307 var SingleSelectionOption = ({ selected }) => {
10308 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10309 "span",
10310 {
10311 className: clsx_default(
10312 "dataviews-filters__search-widget-listitem-single-selection",
10313 { "is-selected": selected }
10314 )
10315 }
10316 );
10317 };
10318 function ListBox({ view, filter, onChangeView }) {
10319 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
10320 const [activeCompositeId, setActiveCompositeId] = (0, import_element28.useState)(
10321 // When there are one or less operators, the first item is set as active
10322 // (by setting the initial `activeId` to `undefined`).
10323 // With 2 or more operators, the focus is moved on the operators control
10324 // (by setting the initial `activeId` to `null`), meaning that there won't
10325 // be an active item initially. Focus is then managed via the
10326 // `onFocusVisible` callback.
10327 filter.operators?.length === 1 ? void 0 : null
10328 );
10329 const currentFilter = view.filters?.find(
10330 (f2) => f2.field === filter.field
10331 );
10332 const currentValue = getCurrentValue(filter, currentFilter);
10333 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10334 import_components18.Composite,
10335 {
10336 virtualFocus: true,
10337 focusLoop: true,
10338 activeId: activeCompositeId,
10339 setActiveId: setActiveCompositeId,
10340 role: "listbox",
10341 className: "dataviews-filters__search-widget-listbox",
10342 "aria-label": (0, import_i18n22.sprintf)(
10343 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
10344 (0, import_i18n22.__)("List of: %1$s"),
10345 filter.name
10346 ),
10347 onFocusVisible: () => {
10348 if (!activeCompositeId && filter.elements.length) {
10349 setActiveCompositeId(
10350 generateFilterElementCompositeItemId(
10351 baseId,
10352 filter.elements[0].value
10353 )
10354 );
10355 }
10356 },
10357 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Composite.Typeahead, {}),
10358 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10359 import_components18.Composite.Hover,
10360 {
10361 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10362 import_components18.Composite.Item,
10363 {
10364 id: generateFilterElementCompositeItemId(
10365 baseId,
10366 element.value
10367 ),
10368 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10369 "div",
10370 {
10371 "aria-label": element.label,
10372 role: "option",
10373 className: "dataviews-filters__search-widget-listitem"
10374 }
10375 ),
10376 onClick: () => {
10377 const newFilters = currentFilter ? [
10378 ...(view.filters ?? []).map(
10379 (_filter) => {
10380 if (_filter.field === filter.field) {
10381 return {
10382 ..._filter,
10383 operator: currentFilter.operator || filter.operators[0],
10384 value: getNewValue(
10385 filter,
10386 currentFilter,
10387 element.value
10388 )
10389 };
10390 }
10391 return _filter;
10392 }
10393 )
10394 ] : [
10395 ...view.filters ?? [],
10396 {
10397 field: filter.field,
10398 operator: filter.operators[0],
10399 value: getNewValue(
10400 filter,
10401 currentFilter,
10402 element.value
10403 )
10404 }
10405 ];
10406 onChangeView({
10407 ...view,
10408 page: 1,
10409 filters: newFilters
10410 });
10411 }
10412 }
10413 ),
10414 children: [
10415 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10416 SingleSelectionOption,
10417 {
10418 selected: currentValue === element.value
10419 }
10420 ),
10421 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10422 MultiSelectionOption,
10423 {
10424 selected: currentValue.includes(element.value)
10425 }
10426 ),
10427 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10428 "span",
10429 {
10430 className: "dataviews-filters__search-widget-listitem-value",
10431 title: element.label,
10432 children: element.label
10433 }
10434 )
10435 ]
10436 },
10437 element.value
10438 ))
10439 }
10440 );
10441 }
10442 function ComboboxList22({ view, filter, onChangeView }) {
10443 const [searchValue, setSearchValue] = (0, import_element28.useState)("");
10444 const deferredSearchValue = (0, import_element28.useDeferredValue)(searchValue);
10445 const currentFilter = view.filters?.find(
10446 (_filter) => _filter.field === filter.field
10447 );
10448 const currentValue = getCurrentValue(filter, currentFilter);
10449 const matches = (0, import_element28.useMemo)(() => {
10450 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
10451 return filter.elements.filter(
10452 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
10453 );
10454 }, [filter.elements, deferredSearchValue]);
10455 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10456 ComboboxProvider,
10457 {
10458 selectedValue: currentValue,
10459 setSelectedValue: (value) => {
10460 const newFilters = currentFilter ? [
10461 ...(view.filters ?? []).map((_filter) => {
10462 if (_filter.field === filter.field) {
10463 return {
10464 ..._filter,
10465 operator: currentFilter.operator || filter.operators[0],
10466 value
10467 };
10468 }
10469 return _filter;
10470 })
10471 ] : [
10472 ...view.filters ?? [],
10473 {
10474 field: filter.field,
10475 operator: filter.operators[0],
10476 value
10477 }
10478 ];
10479 onChangeView({
10480 ...view,
10481 page: 1,
10482 filters: newFilters
10483 });
10484 },
10485 setValue: setSearchValue,
10486 children: [
10487 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
10488 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }),
10489 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10490 Combobox,
10491 {
10492 autoSelect: "always",
10493 placeholder: (0, import_i18n22.__)("Search"),
10494 className: "dataviews-filters__search-widget-filter-combobox__input"
10495 }
10496 ),
10497 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Icon, { icon: search_default }) })
10498 ] }),
10499 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10500 ComboboxList,
10501 {
10502 className: "dataviews-filters__search-widget-filter-combobox-list",
10503 alwaysVisible: true,
10504 children: [
10505 matches.map((element) => {
10506 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10507 ComboboxItem,
10508 {
10509 resetValueOnSelect: false,
10510 value: element.value,
10511 className: "dataviews-filters__search-widget-listitem",
10512 hideOnClick: false,
10513 setValueOnClick: false,
10514 focusOnHover: true,
10515 children: [
10516 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10517 SingleSelectionOption,
10518 {
10519 selected: currentValue === element.value
10520 }
10521 ),
10522 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10523 MultiSelectionOption,
10524 {
10525 selected: currentValue.includes(
10526 element.value
10527 )
10528 }
10529 ),
10530 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
10531 "span",
10532 {
10533 className: "dataviews-filters__search-widget-listitem-value",
10534 title: element.label,
10535 children: [
10536 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
10537 ComboboxItemValue,
10538 {
10539 className: "dataviews-filters__search-widget-filter-combobox-item-value",
10540 value: element.label
10541 }
10542 ),
10543 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
10544 ]
10545 }
10546 )
10547 ]
10548 },
10549 element.value
10550 );
10551 }),
10552 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { children: (0, import_i18n22.__)("No results found") })
10553 ]
10554 }
10555 )
10556 ]
10557 }
10558 );
10559 }
10560 function SearchWidget(props) {
10561 const { elements, isLoading } = useElements({
10562 elements: props.filter.elements,
10563 getElements: props.filter.getElements
10564 });
10565 if (isLoading) {
10566 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components18.Spinner, {}) });
10567 }
10568 if (elements.length === 0) {
10569 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") });
10570 }
10571 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
10572 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
10573 }
10574
10575 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
10576 var import_es6 = __toESM(require_es6(), 1);
10577 var import_compose8 = __toESM(require_compose(), 1);
10578 var import_element29 = __toESM(require_element(), 1);
10579 var import_components19 = __toESM(require_components(), 1);
10580 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
10581 function InputWidget({
10582 filter,
10583 view,
10584 onChangeView,
10585 fields
10586 }) {
10587 const currentFilter = view.filters?.find(
10588 (f2) => f2.field === filter.field
10589 );
10590 const currentValue = getCurrentValue(filter, currentFilter);
10591 const field = (0, import_element29.useMemo)(() => {
10592 const currentField = fields.find((f2) => f2.id === filter.field);
10593 if (currentField) {
10594 return {
10595 ...currentField,
10596 // Deactivate validation for filters.
10597 isValid: {},
10598 // Filter controls are always enabled.
10599 isDisabled: () => false,
10600 // Filter controls are always visible.
10601 isVisible: () => true,
10602 // Configure getValue/setValue as if Item was a plain object.
10603 getValue: ({ item }) => item[currentField.id],
10604 setValue: ({ value }) => ({
10605 [currentField.id]: value
10606 })
10607 };
10608 }
10609 return currentField;
10610 }, [fields, filter.field]);
10611 const data = (0, import_element29.useMemo)(() => {
10612 return (view.filters ?? []).reduce(
10613 (acc, activeFilter) => {
10614 acc[activeFilter.field] = activeFilter.value;
10615 return acc;
10616 },
10617 {}
10618 );
10619 }, [view.filters]);
10620 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
10621 if (!field || !currentFilter) {
10622 return;
10623 }
10624 const nextValue = field.getValue({ item: updatedData });
10625 if ((0, import_es6.default)(nextValue, currentValue)) {
10626 return;
10627 }
10628 onChangeView({
10629 ...view,
10630 filters: (view.filters ?? []).map(
10631 (_filter) => _filter.field === filter.field ? {
10632 ..._filter,
10633 operator: currentFilter.operator || filter.operators[0],
10634 // Consider empty strings as undefined:
10635 //
10636 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
10637 // - empty string as value means "search empty string": returns only the records that have an empty string as value
10638 //
10639 // In practice, this means the filter will not be able to find an empty string as the value.
10640 value: nextValue === "" ? void 0 : nextValue
10641 } : _filter
10642 )
10643 });
10644 });
10645 if (!field || !field.Edit || !currentFilter) {
10646 return null;
10647 }
10648 return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
10649 import_components19.Flex,
10650 {
10651 className: "dataviews-filters__user-input-widget",
10652 gap: 2.5,
10653 direction: "column",
10654 children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
10655 field.Edit,
10656 {
10657 hideLabelFromVision: true,
10658 data,
10659 field,
10660 operator: currentFilter.operator,
10661 onChange: handleChange
10662 }
10663 )
10664 }
10665 );
10666 }
10667
10668 // packages/dataviews/node_modules/date-fns/constants.js
10669 var daysInYear = 365.2425;
10670 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
10671 var minTime = -maxTime;
10672 var millisecondsInWeek = 6048e5;
10673 var millisecondsInDay = 864e5;
10674 var secondsInHour = 3600;
10675 var secondsInDay = secondsInHour * 24;
10676 var secondsInWeek = secondsInDay * 7;
10677 var secondsInYear = secondsInDay * daysInYear;
10678 var secondsInMonth = secondsInYear / 12;
10679 var secondsInQuarter = secondsInMonth * 3;
10680 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
10681
10682 // packages/dataviews/node_modules/date-fns/constructFrom.js
10683 function constructFrom(date, value) {
10684 if (typeof date === "function") return date(value);
10685 if (date && typeof date === "object" && constructFromSymbol in date)
10686 return date[constructFromSymbol](value);
10687 if (date instanceof Date) return new date.constructor(value);
10688 return new Date(value);
10689 }
10690
10691 // packages/dataviews/node_modules/date-fns/toDate.js
10692 function toDate(argument, context) {
10693 return constructFrom(context || argument, argument);
10694 }
10695
10696 // packages/dataviews/node_modules/date-fns/addDays.js
10697 function addDays(date, amount, options) {
10698 const _date = toDate(date, options?.in);
10699 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10700 if (!amount) return _date;
10701 _date.setDate(_date.getDate() + amount);
10702 return _date;
10703 }
10704
10705 // packages/dataviews/node_modules/date-fns/addMonths.js
10706 function addMonths(date, amount, options) {
10707 const _date = toDate(date, options?.in);
10708 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
10709 if (!amount) {
10710 return _date;
10711 }
10712 const dayOfMonth = _date.getDate();
10713 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
10714 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
10715 const daysInMonth = endOfDesiredMonth.getDate();
10716 if (dayOfMonth >= daysInMonth) {
10717 return endOfDesiredMonth;
10718 } else {
10719 _date.setFullYear(
10720 endOfDesiredMonth.getFullYear(),
10721 endOfDesiredMonth.getMonth(),
10722 dayOfMonth
10723 );
10724 return _date;
10725 }
10726 }
10727
10728 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
10729 var defaultOptions = {};
10730 function getDefaultOptions() {
10731 return defaultOptions;
10732 }
10733
10734 // packages/dataviews/node_modules/date-fns/startOfWeek.js
10735 function startOfWeek(date, options) {
10736 const defaultOptions2 = getDefaultOptions();
10737 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
10738 const _date = toDate(date, options?.in);
10739 const day = _date.getDay();
10740 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
10741 _date.setDate(_date.getDate() - diff);
10742 _date.setHours(0, 0, 0, 0);
10743 return _date;
10744 }
10745
10746 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
10747 function startOfISOWeek(date, options) {
10748 return startOfWeek(date, { ...options, weekStartsOn: 1 });
10749 }
10750
10751 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
10752 function getISOWeekYear(date, options) {
10753 const _date = toDate(date, options?.in);
10754 const year = _date.getFullYear();
10755 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
10756 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
10757 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
10758 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
10759 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
10760 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
10761 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
10762 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
10763 if (_date.getTime() >= startOfNextYear.getTime()) {
10764 return year + 1;
10765 } else if (_date.getTime() >= startOfThisYear.getTime()) {
10766 return year;
10767 } else {
10768 return year - 1;
10769 }
10770 }
10771
10772 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
10773 function getTimezoneOffsetInMilliseconds(date) {
10774 const _date = toDate(date);
10775 const utcDate = new Date(
10776 Date.UTC(
10777 _date.getFullYear(),
10778 _date.getMonth(),
10779 _date.getDate(),
10780 _date.getHours(),
10781 _date.getMinutes(),
10782 _date.getSeconds(),
10783 _date.getMilliseconds()
10784 )
10785 );
10786 utcDate.setUTCFullYear(_date.getFullYear());
10787 return +date - +utcDate;
10788 }
10789
10790 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
10791 function normalizeDates(context, ...dates) {
10792 const normalize = constructFrom.bind(
10793 null,
10794 context || dates.find((date) => typeof date === "object")
10795 );
10796 return dates.map(normalize);
10797 }
10798
10799 // packages/dataviews/node_modules/date-fns/startOfDay.js
10800 function startOfDay(date, options) {
10801 const _date = toDate(date, options?.in);
10802 _date.setHours(0, 0, 0, 0);
10803 return _date;
10804 }
10805
10806 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
10807 function differenceInCalendarDays(laterDate, earlierDate, options) {
10808 const [laterDate_, earlierDate_] = normalizeDates(
10809 options?.in,
10810 laterDate,
10811 earlierDate
10812 );
10813 const laterStartOfDay = startOfDay(laterDate_);
10814 const earlierStartOfDay = startOfDay(earlierDate_);
10815 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
10816 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
10817 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
10818 }
10819
10820 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
10821 function startOfISOWeekYear(date, options) {
10822 const year = getISOWeekYear(date, options);
10823 const fourthOfJanuary = constructFrom(options?.in || date, 0);
10824 fourthOfJanuary.setFullYear(year, 0, 4);
10825 fourthOfJanuary.setHours(0, 0, 0, 0);
10826 return startOfISOWeek(fourthOfJanuary);
10827 }
10828
10829 // packages/dataviews/node_modules/date-fns/addWeeks.js
10830 function addWeeks(date, amount, options) {
10831 return addDays(date, amount * 7, options);
10832 }
10833
10834 // packages/dataviews/node_modules/date-fns/addYears.js
10835 function addYears(date, amount, options) {
10836 return addMonths(date, amount * 12, options);
10837 }
10838
10839 // packages/dataviews/node_modules/date-fns/isDate.js
10840 function isDate(value) {
10841 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
10842 }
10843
10844 // packages/dataviews/node_modules/date-fns/isValid.js
10845 function isValid(date) {
10846 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
10847 }
10848
10849 // packages/dataviews/node_modules/date-fns/startOfMonth.js
10850 function startOfMonth(date, options) {
10851 const _date = toDate(date, options?.in);
10852 _date.setDate(1);
10853 _date.setHours(0, 0, 0, 0);
10854 return _date;
10855 }
10856
10857 // packages/dataviews/node_modules/date-fns/startOfYear.js
10858 function startOfYear(date, options) {
10859 const date_ = toDate(date, options?.in);
10860 date_.setFullYear(date_.getFullYear(), 0, 1);
10861 date_.setHours(0, 0, 0, 0);
10862 return date_;
10863 }
10864
10865 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
10866 var formatDistanceLocale = {
10867 lessThanXSeconds: {
10868 one: "less than a second",
10869 other: "less than {{count}} seconds"
10870 },
10871 xSeconds: {
10872 one: "1 second",
10873 other: "{{count}} seconds"
10874 },
10875 halfAMinute: "half a minute",
10876 lessThanXMinutes: {
10877 one: "less than a minute",
10878 other: "less than {{count}} minutes"
10879 },
10880 xMinutes: {
10881 one: "1 minute",
10882 other: "{{count}} minutes"
10883 },
10884 aboutXHours: {
10885 one: "about 1 hour",
10886 other: "about {{count}} hours"
10887 },
10888 xHours: {
10889 one: "1 hour",
10890 other: "{{count}} hours"
10891 },
10892 xDays: {
10893 one: "1 day",
10894 other: "{{count}} days"
10895 },
10896 aboutXWeeks: {
10897 one: "about 1 week",
10898 other: "about {{count}} weeks"
10899 },
10900 xWeeks: {
10901 one: "1 week",
10902 other: "{{count}} weeks"
10903 },
10904 aboutXMonths: {
10905 one: "about 1 month",
10906 other: "about {{count}} months"
10907 },
10908 xMonths: {
10909 one: "1 month",
10910 other: "{{count}} months"
10911 },
10912 aboutXYears: {
10913 one: "about 1 year",
10914 other: "about {{count}} years"
10915 },
10916 xYears: {
10917 one: "1 year",
10918 other: "{{count}} years"
10919 },
10920 overXYears: {
10921 one: "over 1 year",
10922 other: "over {{count}} years"
10923 },
10924 almostXYears: {
10925 one: "almost 1 year",
10926 other: "almost {{count}} years"
10927 }
10928 };
10929 var formatDistance = (token, count, options) => {
10930 let result;
10931 const tokenValue = formatDistanceLocale[token];
10932 if (typeof tokenValue === "string") {
10933 result = tokenValue;
10934 } else if (count === 1) {
10935 result = tokenValue.one;
10936 } else {
10937 result = tokenValue.other.replace("{{count}}", count.toString());
10938 }
10939 if (options?.addSuffix) {
10940 if (options.comparison && options.comparison > 0) {
10941 return "in " + result;
10942 } else {
10943 return result + " ago";
10944 }
10945 }
10946 return result;
10947 };
10948
10949 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
10950 function buildFormatLongFn(args) {
10951 return (options = {}) => {
10952 const width = options.width ? String(options.width) : args.defaultWidth;
10953 const format6 = args.formats[width] || args.formats[args.defaultWidth];
10954 return format6;
10955 };
10956 }
10957
10958 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
10959 var dateFormats = {
10960 full: "EEEE, MMMM do, y",
10961 long: "MMMM do, y",
10962 medium: "MMM d, y",
10963 short: "MM/dd/yyyy"
10964 };
10965 var timeFormats = {
10966 full: "h:mm:ss a zzzz",
10967 long: "h:mm:ss a z",
10968 medium: "h:mm:ss a",
10969 short: "h:mm a"
10970 };
10971 var dateTimeFormats = {
10972 full: "{{date}} 'at' {{time}}",
10973 long: "{{date}} 'at' {{time}}",
10974 medium: "{{date}}, {{time}}",
10975 short: "{{date}}, {{time}}"
10976 };
10977 var formatLong = {
10978 date: buildFormatLongFn({
10979 formats: dateFormats,
10980 defaultWidth: "full"
10981 }),
10982 time: buildFormatLongFn({
10983 formats: timeFormats,
10984 defaultWidth: "full"
10985 }),
10986 dateTime: buildFormatLongFn({
10987 formats: dateTimeFormats,
10988 defaultWidth: "full"
10989 })
10990 };
10991
10992 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
10993 var formatRelativeLocale = {
10994 lastWeek: "'last' eeee 'at' p",
10995 yesterday: "'yesterday at' p",
10996 today: "'today at' p",
10997 tomorrow: "'tomorrow at' p",
10998 nextWeek: "eeee 'at' p",
10999 other: "P"
11000 };
11001 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
11002
11003 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
11004 function buildLocalizeFn(args) {
11005 return (value, options) => {
11006 const context = options?.context ? String(options.context) : "standalone";
11007 let valuesArray;
11008 if (context === "formatting" && args.formattingValues) {
11009 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
11010 const width = options?.width ? String(options.width) : defaultWidth;
11011 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
11012 } else {
11013 const defaultWidth = args.defaultWidth;
11014 const width = options?.width ? String(options.width) : args.defaultWidth;
11015 valuesArray = args.values[width] || args.values[defaultWidth];
11016 }
11017 const index = args.argumentCallback ? args.argumentCallback(value) : value;
11018 return valuesArray[index];
11019 };
11020 }
11021
11022 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
11023 var eraValues = {
11024 narrow: ["B", "A"],
11025 abbreviated: ["BC", "AD"],
11026 wide: ["Before Christ", "Anno Domini"]
11027 };
11028 var quarterValues = {
11029 narrow: ["1", "2", "3", "4"],
11030 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
11031 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
11032 };
11033 var monthValues = {
11034 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
11035 abbreviated: [
11036 "Jan",
11037 "Feb",
11038 "Mar",
11039 "Apr",
11040 "May",
11041 "Jun",
11042 "Jul",
11043 "Aug",
11044 "Sep",
11045 "Oct",
11046 "Nov",
11047 "Dec"
11048 ],
11049 wide: [
11050 "January",
11051 "February",
11052 "March",
11053 "April",
11054 "May",
11055 "June",
11056 "July",
11057 "August",
11058 "September",
11059 "October",
11060 "November",
11061 "December"
11062 ]
11063 };
11064 var dayValues = {
11065 narrow: ["S", "M", "T", "W", "T", "F", "S"],
11066 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
11067 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
11068 wide: [
11069 "Sunday",
11070 "Monday",
11071 "Tuesday",
11072 "Wednesday",
11073 "Thursday",
11074 "Friday",
11075 "Saturday"
11076 ]
11077 };
11078 var dayPeriodValues = {
11079 narrow: {
11080 am: "a",
11081 pm: "p",
11082 midnight: "mi",
11083 noon: "n",
11084 morning: "morning",
11085 afternoon: "afternoon",
11086 evening: "evening",
11087 night: "night"
11088 },
11089 abbreviated: {
11090 am: "AM",
11091 pm: "PM",
11092 midnight: "midnight",
11093 noon: "noon",
11094 morning: "morning",
11095 afternoon: "afternoon",
11096 evening: "evening",
11097 night: "night"
11098 },
11099 wide: {
11100 am: "a.m.",
11101 pm: "p.m.",
11102 midnight: "midnight",
11103 noon: "noon",
11104 morning: "morning",
11105 afternoon: "afternoon",
11106 evening: "evening",
11107 night: "night"
11108 }
11109 };
11110 var formattingDayPeriodValues = {
11111 narrow: {
11112 am: "a",
11113 pm: "p",
11114 midnight: "mi",
11115 noon: "n",
11116 morning: "in the morning",
11117 afternoon: "in the afternoon",
11118 evening: "in the evening",
11119 night: "at night"
11120 },
11121 abbreviated: {
11122 am: "AM",
11123 pm: "PM",
11124 midnight: "midnight",
11125 noon: "noon",
11126 morning: "in the morning",
11127 afternoon: "in the afternoon",
11128 evening: "in the evening",
11129 night: "at night"
11130 },
11131 wide: {
11132 am: "a.m.",
11133 pm: "p.m.",
11134 midnight: "midnight",
11135 noon: "noon",
11136 morning: "in the morning",
11137 afternoon: "in the afternoon",
11138 evening: "in the evening",
11139 night: "at night"
11140 }
11141 };
11142 var ordinalNumber = (dirtyNumber, _options) => {
11143 const number = Number(dirtyNumber);
11144 const rem100 = number % 100;
11145 if (rem100 > 20 || rem100 < 10) {
11146 switch (rem100 % 10) {
11147 case 1:
11148 return number + "st";
11149 case 2:
11150 return number + "nd";
11151 case 3:
11152 return number + "rd";
11153 }
11154 }
11155 return number + "th";
11156 };
11157 var localize = {
11158 ordinalNumber,
11159 era: buildLocalizeFn({
11160 values: eraValues,
11161 defaultWidth: "wide"
11162 }),
11163 quarter: buildLocalizeFn({
11164 values: quarterValues,
11165 defaultWidth: "wide",
11166 argumentCallback: (quarter) => quarter - 1
11167 }),
11168 month: buildLocalizeFn({
11169 values: monthValues,
11170 defaultWidth: "wide"
11171 }),
11172 day: buildLocalizeFn({
11173 values: dayValues,
11174 defaultWidth: "wide"
11175 }),
11176 dayPeriod: buildLocalizeFn({
11177 values: dayPeriodValues,
11178 defaultWidth: "wide",
11179 formattingValues: formattingDayPeriodValues,
11180 defaultFormattingWidth: "wide"
11181 })
11182 };
11183
11184 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
11185 function buildMatchFn(args) {
11186 return (string, options = {}) => {
11187 const width = options.width;
11188 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
11189 const matchResult = string.match(matchPattern);
11190 if (!matchResult) {
11191 return null;
11192 }
11193 const matchedString = matchResult[0];
11194 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
11195 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
11196 // [TODO] -- I challenge you to fix the type
11197 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
11198 );
11199 let value;
11200 value = args.valueCallback ? args.valueCallback(key) : key;
11201 value = options.valueCallback ? (
11202 // [TODO] -- I challenge you to fix the type
11203 options.valueCallback(value)
11204 ) : value;
11205 const rest = string.slice(matchedString.length);
11206 return { value, rest };
11207 };
11208 }
11209 function findKey(object, predicate) {
11210 for (const key in object) {
11211 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
11212 return key;
11213 }
11214 }
11215 return void 0;
11216 }
11217 function findIndex(array, predicate) {
11218 for (let key = 0; key < array.length; key++) {
11219 if (predicate(array[key])) {
11220 return key;
11221 }
11222 }
11223 return void 0;
11224 }
11225
11226 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
11227 function buildMatchPatternFn(args) {
11228 return (string, options = {}) => {
11229 const matchResult = string.match(args.matchPattern);
11230 if (!matchResult) return null;
11231 const matchedString = matchResult[0];
11232 const parseResult = string.match(args.parsePattern);
11233 if (!parseResult) return null;
11234 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
11235 value = options.valueCallback ? options.valueCallback(value) : value;
11236 const rest = string.slice(matchedString.length);
11237 return { value, rest };
11238 };
11239 }
11240
11241 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
11242 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
11243 var parseOrdinalNumberPattern = /\d+/i;
11244 var matchEraPatterns = {
11245 narrow: /^(b|a)/i,
11246 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
11247 wide: /^(before christ|before common era|anno domini|common era)/i
11248 };
11249 var parseEraPatterns = {
11250 any: [/^b/i, /^(a|c)/i]
11251 };
11252 var matchQuarterPatterns = {
11253 narrow: /^[1234]/i,
11254 abbreviated: /^q[1234]/i,
11255 wide: /^[1234](th|st|nd|rd)? quarter/i
11256 };
11257 var parseQuarterPatterns = {
11258 any: [/1/i, /2/i, /3/i, /4/i]
11259 };
11260 var matchMonthPatterns = {
11261 narrow: /^[jfmasond]/i,
11262 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
11263 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
11264 };
11265 var parseMonthPatterns = {
11266 narrow: [
11267 /^j/i,
11268 /^f/i,
11269 /^m/i,
11270 /^a/i,
11271 /^m/i,
11272 /^j/i,
11273 /^j/i,
11274 /^a/i,
11275 /^s/i,
11276 /^o/i,
11277 /^n/i,
11278 /^d/i
11279 ],
11280 any: [
11281 /^ja/i,
11282 /^f/i,
11283 /^mar/i,
11284 /^ap/i,
11285 /^may/i,
11286 /^jun/i,
11287 /^jul/i,
11288 /^au/i,
11289 /^s/i,
11290 /^o/i,
11291 /^n/i,
11292 /^d/i
11293 ]
11294 };
11295 var matchDayPatterns = {
11296 narrow: /^[smtwf]/i,
11297 short: /^(su|mo|tu|we|th|fr|sa)/i,
11298 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
11299 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
11300 };
11301 var parseDayPatterns = {
11302 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
11303 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
11304 };
11305 var matchDayPeriodPatterns = {
11306 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
11307 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
11308 };
11309 var parseDayPeriodPatterns = {
11310 any: {
11311 am: /^a/i,
11312 pm: /^p/i,
11313 midnight: /^mi/i,
11314 noon: /^no/i,
11315 morning: /morning/i,
11316 afternoon: /afternoon/i,
11317 evening: /evening/i,
11318 night: /night/i
11319 }
11320 };
11321 var match = {
11322 ordinalNumber: buildMatchPatternFn({
11323 matchPattern: matchOrdinalNumberPattern,
11324 parsePattern: parseOrdinalNumberPattern,
11325 valueCallback: (value) => parseInt(value, 10)
11326 }),
11327 era: buildMatchFn({
11328 matchPatterns: matchEraPatterns,
11329 defaultMatchWidth: "wide",
11330 parsePatterns: parseEraPatterns,
11331 defaultParseWidth: "any"
11332 }),
11333 quarter: buildMatchFn({
11334 matchPatterns: matchQuarterPatterns,
11335 defaultMatchWidth: "wide",
11336 parsePatterns: parseQuarterPatterns,
11337 defaultParseWidth: "any",
11338 valueCallback: (index) => index + 1
11339 }),
11340 month: buildMatchFn({
11341 matchPatterns: matchMonthPatterns,
11342 defaultMatchWidth: "wide",
11343 parsePatterns: parseMonthPatterns,
11344 defaultParseWidth: "any"
11345 }),
11346 day: buildMatchFn({
11347 matchPatterns: matchDayPatterns,
11348 defaultMatchWidth: "wide",
11349 parsePatterns: parseDayPatterns,
11350 defaultParseWidth: "any"
11351 }),
11352 dayPeriod: buildMatchFn({
11353 matchPatterns: matchDayPeriodPatterns,
11354 defaultMatchWidth: "any",
11355 parsePatterns: parseDayPeriodPatterns,
11356 defaultParseWidth: "any"
11357 })
11358 };
11359
11360 // packages/dataviews/node_modules/date-fns/locale/en-US.js
11361 var enUS = {
11362 code: "en-US",
11363 formatDistance,
11364 formatLong,
11365 formatRelative,
11366 localize,
11367 match,
11368 options: {
11369 weekStartsOn: 0,
11370 firstWeekContainsDate: 1
11371 }
11372 };
11373
11374 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
11375 function getDayOfYear(date, options) {
11376 const _date = toDate(date, options?.in);
11377 const diff = differenceInCalendarDays(_date, startOfYear(_date));
11378 const dayOfYear = diff + 1;
11379 return dayOfYear;
11380 }
11381
11382 // packages/dataviews/node_modules/date-fns/getISOWeek.js
11383 function getISOWeek(date, options) {
11384 const _date = toDate(date, options?.in);
11385 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
11386 return Math.round(diff / millisecondsInWeek) + 1;
11387 }
11388
11389 // packages/dataviews/node_modules/date-fns/getWeekYear.js
11390 function getWeekYear(date, options) {
11391 const _date = toDate(date, options?.in);
11392 const year = _date.getFullYear();
11393 const defaultOptions2 = getDefaultOptions();
11394 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11395 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
11396 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
11397 firstWeekOfNextYear.setHours(0, 0, 0, 0);
11398 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
11399 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
11400 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
11401 firstWeekOfThisYear.setHours(0, 0, 0, 0);
11402 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
11403 if (+_date >= +startOfNextYear) {
11404 return year + 1;
11405 } else if (+_date >= +startOfThisYear) {
11406 return year;
11407 } else {
11408 return year - 1;
11409 }
11410 }
11411
11412 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
11413 function startOfWeekYear(date, options) {
11414 const defaultOptions2 = getDefaultOptions();
11415 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
11416 const year = getWeekYear(date, options);
11417 const firstWeek = constructFrom(options?.in || date, 0);
11418 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
11419 firstWeek.setHours(0, 0, 0, 0);
11420 const _date = startOfWeek(firstWeek, options);
11421 return _date;
11422 }
11423
11424 // packages/dataviews/node_modules/date-fns/getWeek.js
11425 function getWeek(date, options) {
11426 const _date = toDate(date, options?.in);
11427 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
11428 return Math.round(diff / millisecondsInWeek) + 1;
11429 }
11430
11431 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
11432 function addLeadingZeros(number, targetLength) {
11433 const sign = number < 0 ? "-" : "";
11434 const output = Math.abs(number).toString().padStart(targetLength, "0");
11435 return sign + output;
11436 }
11437
11438 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
11439 var lightFormatters = {
11440 // Year
11441 y(date, token) {
11442 const signedYear = date.getFullYear();
11443 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11444 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
11445 },
11446 // Month
11447 M(date, token) {
11448 const month = date.getMonth();
11449 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
11450 },
11451 // Day of the month
11452 d(date, token) {
11453 return addLeadingZeros(date.getDate(), token.length);
11454 },
11455 // AM or PM
11456 a(date, token) {
11457 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
11458 switch (token) {
11459 case "a":
11460 case "aa":
11461 return dayPeriodEnumValue.toUpperCase();
11462 case "aaa":
11463 return dayPeriodEnumValue;
11464 case "aaaaa":
11465 return dayPeriodEnumValue[0];
11466 case "aaaa":
11467 default:
11468 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
11469 }
11470 },
11471 // Hour [1-12]
11472 h(date, token) {
11473 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
11474 },
11475 // Hour [0-23]
11476 H(date, token) {
11477 return addLeadingZeros(date.getHours(), token.length);
11478 },
11479 // Minute
11480 m(date, token) {
11481 return addLeadingZeros(date.getMinutes(), token.length);
11482 },
11483 // Second
11484 s(date, token) {
11485 return addLeadingZeros(date.getSeconds(), token.length);
11486 },
11487 // Fraction of second
11488 S(date, token) {
11489 const numberOfDigits = token.length;
11490 const milliseconds = date.getMilliseconds();
11491 const fractionalSeconds = Math.trunc(
11492 milliseconds * Math.pow(10, numberOfDigits - 3)
11493 );
11494 return addLeadingZeros(fractionalSeconds, token.length);
11495 }
11496 };
11497
11498 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
11499 var dayPeriodEnum = {
11500 am: "am",
11501 pm: "pm",
11502 midnight: "midnight",
11503 noon: "noon",
11504 morning: "morning",
11505 afternoon: "afternoon",
11506 evening: "evening",
11507 night: "night"
11508 };
11509 var formatters = {
11510 // Era
11511 G: function(date, token, localize2) {
11512 const era = date.getFullYear() > 0 ? 1 : 0;
11513 switch (token) {
11514 // AD, BC
11515 case "G":
11516 case "GG":
11517 case "GGG":
11518 return localize2.era(era, { width: "abbreviated" });
11519 // A, B
11520 case "GGGGG":
11521 return localize2.era(era, { width: "narrow" });
11522 // Anno Domini, Before Christ
11523 case "GGGG":
11524 default:
11525 return localize2.era(era, { width: "wide" });
11526 }
11527 },
11528 // Year
11529 y: function(date, token, localize2) {
11530 if (token === "yo") {
11531 const signedYear = date.getFullYear();
11532 const year = signedYear > 0 ? signedYear : 1 - signedYear;
11533 return localize2.ordinalNumber(year, { unit: "year" });
11534 }
11535 return lightFormatters.y(date, token);
11536 },
11537 // Local week-numbering year
11538 Y: function(date, token, localize2, options) {
11539 const signedWeekYear = getWeekYear(date, options);
11540 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
11541 if (token === "YY") {
11542 const twoDigitYear = weekYear % 100;
11543 return addLeadingZeros(twoDigitYear, 2);
11544 }
11545 if (token === "Yo") {
11546 return localize2.ordinalNumber(weekYear, { unit: "year" });
11547 }
11548 return addLeadingZeros(weekYear, token.length);
11549 },
11550 // ISO week-numbering year
11551 R: function(date, token) {
11552 const isoWeekYear = getISOWeekYear(date);
11553 return addLeadingZeros(isoWeekYear, token.length);
11554 },
11555 // Extended year. This is a single number designating the year of this calendar system.
11556 // The main difference between `y` and `u` localizers are B.C. years:
11557 // | Year | `y` | `u` |
11558 // |------|-----|-----|
11559 // | AC 1 | 1 | 1 |
11560 // | BC 1 | 1 | 0 |
11561 // | BC 2 | 2 | -1 |
11562 // Also `yy` always returns the last two digits of a year,
11563 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
11564 u: function(date, token) {
11565 const year = date.getFullYear();
11566 return addLeadingZeros(year, token.length);
11567 },
11568 // Quarter
11569 Q: function(date, token, localize2) {
11570 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11571 switch (token) {
11572 // 1, 2, 3, 4
11573 case "Q":
11574 return String(quarter);
11575 // 01, 02, 03, 04
11576 case "QQ":
11577 return addLeadingZeros(quarter, 2);
11578 // 1st, 2nd, 3rd, 4th
11579 case "Qo":
11580 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11581 // Q1, Q2, Q3, Q4
11582 case "QQQ":
11583 return localize2.quarter(quarter, {
11584 width: "abbreviated",
11585 context: "formatting"
11586 });
11587 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11588 case "QQQQQ":
11589 return localize2.quarter(quarter, {
11590 width: "narrow",
11591 context: "formatting"
11592 });
11593 // 1st quarter, 2nd quarter, ...
11594 case "QQQQ":
11595 default:
11596 return localize2.quarter(quarter, {
11597 width: "wide",
11598 context: "formatting"
11599 });
11600 }
11601 },
11602 // Stand-alone quarter
11603 q: function(date, token, localize2) {
11604 const quarter = Math.ceil((date.getMonth() + 1) / 3);
11605 switch (token) {
11606 // 1, 2, 3, 4
11607 case "q":
11608 return String(quarter);
11609 // 01, 02, 03, 04
11610 case "qq":
11611 return addLeadingZeros(quarter, 2);
11612 // 1st, 2nd, 3rd, 4th
11613 case "qo":
11614 return localize2.ordinalNumber(quarter, { unit: "quarter" });
11615 // Q1, Q2, Q3, Q4
11616 case "qqq":
11617 return localize2.quarter(quarter, {
11618 width: "abbreviated",
11619 context: "standalone"
11620 });
11621 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
11622 case "qqqqq":
11623 return localize2.quarter(quarter, {
11624 width: "narrow",
11625 context: "standalone"
11626 });
11627 // 1st quarter, 2nd quarter, ...
11628 case "qqqq":
11629 default:
11630 return localize2.quarter(quarter, {
11631 width: "wide",
11632 context: "standalone"
11633 });
11634 }
11635 },
11636 // Month
11637 M: function(date, token, localize2) {
11638 const month = date.getMonth();
11639 switch (token) {
11640 case "M":
11641 case "MM":
11642 return lightFormatters.M(date, token);
11643 // 1st, 2nd, ..., 12th
11644 case "Mo":
11645 return localize2.ordinalNumber(month + 1, { unit: "month" });
11646 // Jan, Feb, ..., Dec
11647 case "MMM":
11648 return localize2.month(month, {
11649 width: "abbreviated",
11650 context: "formatting"
11651 });
11652 // J, F, ..., D
11653 case "MMMMM":
11654 return localize2.month(month, {
11655 width: "narrow",
11656 context: "formatting"
11657 });
11658 // January, February, ..., December
11659 case "MMMM":
11660 default:
11661 return localize2.month(month, { width: "wide", context: "formatting" });
11662 }
11663 },
11664 // Stand-alone month
11665 L: function(date, token, localize2) {
11666 const month = date.getMonth();
11667 switch (token) {
11668 // 1, 2, ..., 12
11669 case "L":
11670 return String(month + 1);
11671 // 01, 02, ..., 12
11672 case "LL":
11673 return addLeadingZeros(month + 1, 2);
11674 // 1st, 2nd, ..., 12th
11675 case "Lo":
11676 return localize2.ordinalNumber(month + 1, { unit: "month" });
11677 // Jan, Feb, ..., Dec
11678 case "LLL":
11679 return localize2.month(month, {
11680 width: "abbreviated",
11681 context: "standalone"
11682 });
11683 // J, F, ..., D
11684 case "LLLLL":
11685 return localize2.month(month, {
11686 width: "narrow",
11687 context: "standalone"
11688 });
11689 // January, February, ..., December
11690 case "LLLL":
11691 default:
11692 return localize2.month(month, { width: "wide", context: "standalone" });
11693 }
11694 },
11695 // Local week of year
11696 w: function(date, token, localize2, options) {
11697 const week = getWeek(date, options);
11698 if (token === "wo") {
11699 return localize2.ordinalNumber(week, { unit: "week" });
11700 }
11701 return addLeadingZeros(week, token.length);
11702 },
11703 // ISO week of year
11704 I: function(date, token, localize2) {
11705 const isoWeek = getISOWeek(date);
11706 if (token === "Io") {
11707 return localize2.ordinalNumber(isoWeek, { unit: "week" });
11708 }
11709 return addLeadingZeros(isoWeek, token.length);
11710 },
11711 // Day of the month
11712 d: function(date, token, localize2) {
11713 if (token === "do") {
11714 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
11715 }
11716 return lightFormatters.d(date, token);
11717 },
11718 // Day of year
11719 D: function(date, token, localize2) {
11720 const dayOfYear = getDayOfYear(date);
11721 if (token === "Do") {
11722 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
11723 }
11724 return addLeadingZeros(dayOfYear, token.length);
11725 },
11726 // Day of week
11727 E: function(date, token, localize2) {
11728 const dayOfWeek = date.getDay();
11729 switch (token) {
11730 // Tue
11731 case "E":
11732 case "EE":
11733 case "EEE":
11734 return localize2.day(dayOfWeek, {
11735 width: "abbreviated",
11736 context: "formatting"
11737 });
11738 // T
11739 case "EEEEE":
11740 return localize2.day(dayOfWeek, {
11741 width: "narrow",
11742 context: "formatting"
11743 });
11744 // Tu
11745 case "EEEEEE":
11746 return localize2.day(dayOfWeek, {
11747 width: "short",
11748 context: "formatting"
11749 });
11750 // Tuesday
11751 case "EEEE":
11752 default:
11753 return localize2.day(dayOfWeek, {
11754 width: "wide",
11755 context: "formatting"
11756 });
11757 }
11758 },
11759 // Local day of week
11760 e: function(date, token, localize2, options) {
11761 const dayOfWeek = date.getDay();
11762 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11763 switch (token) {
11764 // Numerical value (Nth day of week with current locale or weekStartsOn)
11765 case "e":
11766 return String(localDayOfWeek);
11767 // Padded numerical value
11768 case "ee":
11769 return addLeadingZeros(localDayOfWeek, 2);
11770 // 1st, 2nd, ..., 7th
11771 case "eo":
11772 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11773 case "eee":
11774 return localize2.day(dayOfWeek, {
11775 width: "abbreviated",
11776 context: "formatting"
11777 });
11778 // T
11779 case "eeeee":
11780 return localize2.day(dayOfWeek, {
11781 width: "narrow",
11782 context: "formatting"
11783 });
11784 // Tu
11785 case "eeeeee":
11786 return localize2.day(dayOfWeek, {
11787 width: "short",
11788 context: "formatting"
11789 });
11790 // Tuesday
11791 case "eeee":
11792 default:
11793 return localize2.day(dayOfWeek, {
11794 width: "wide",
11795 context: "formatting"
11796 });
11797 }
11798 },
11799 // Stand-alone local day of week
11800 c: function(date, token, localize2, options) {
11801 const dayOfWeek = date.getDay();
11802 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
11803 switch (token) {
11804 // Numerical value (same as in `e`)
11805 case "c":
11806 return String(localDayOfWeek);
11807 // Padded numerical value
11808 case "cc":
11809 return addLeadingZeros(localDayOfWeek, token.length);
11810 // 1st, 2nd, ..., 7th
11811 case "co":
11812 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
11813 case "ccc":
11814 return localize2.day(dayOfWeek, {
11815 width: "abbreviated",
11816 context: "standalone"
11817 });
11818 // T
11819 case "ccccc":
11820 return localize2.day(dayOfWeek, {
11821 width: "narrow",
11822 context: "standalone"
11823 });
11824 // Tu
11825 case "cccccc":
11826 return localize2.day(dayOfWeek, {
11827 width: "short",
11828 context: "standalone"
11829 });
11830 // Tuesday
11831 case "cccc":
11832 default:
11833 return localize2.day(dayOfWeek, {
11834 width: "wide",
11835 context: "standalone"
11836 });
11837 }
11838 },
11839 // ISO day of week
11840 i: function(date, token, localize2) {
11841 const dayOfWeek = date.getDay();
11842 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
11843 switch (token) {
11844 // 2
11845 case "i":
11846 return String(isoDayOfWeek);
11847 // 02
11848 case "ii":
11849 return addLeadingZeros(isoDayOfWeek, token.length);
11850 // 2nd
11851 case "io":
11852 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
11853 // Tue
11854 case "iii":
11855 return localize2.day(dayOfWeek, {
11856 width: "abbreviated",
11857 context: "formatting"
11858 });
11859 // T
11860 case "iiiii":
11861 return localize2.day(dayOfWeek, {
11862 width: "narrow",
11863 context: "formatting"
11864 });
11865 // Tu
11866 case "iiiiii":
11867 return localize2.day(dayOfWeek, {
11868 width: "short",
11869 context: "formatting"
11870 });
11871 // Tuesday
11872 case "iiii":
11873 default:
11874 return localize2.day(dayOfWeek, {
11875 width: "wide",
11876 context: "formatting"
11877 });
11878 }
11879 },
11880 // AM or PM
11881 a: function(date, token, localize2) {
11882 const hours = date.getHours();
11883 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11884 switch (token) {
11885 case "a":
11886 case "aa":
11887 return localize2.dayPeriod(dayPeriodEnumValue, {
11888 width: "abbreviated",
11889 context: "formatting"
11890 });
11891 case "aaa":
11892 return localize2.dayPeriod(dayPeriodEnumValue, {
11893 width: "abbreviated",
11894 context: "formatting"
11895 }).toLowerCase();
11896 case "aaaaa":
11897 return localize2.dayPeriod(dayPeriodEnumValue, {
11898 width: "narrow",
11899 context: "formatting"
11900 });
11901 case "aaaa":
11902 default:
11903 return localize2.dayPeriod(dayPeriodEnumValue, {
11904 width: "wide",
11905 context: "formatting"
11906 });
11907 }
11908 },
11909 // AM, PM, midnight, noon
11910 b: function(date, token, localize2) {
11911 const hours = date.getHours();
11912 let dayPeriodEnumValue;
11913 if (hours === 12) {
11914 dayPeriodEnumValue = dayPeriodEnum.noon;
11915 } else if (hours === 0) {
11916 dayPeriodEnumValue = dayPeriodEnum.midnight;
11917 } else {
11918 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
11919 }
11920 switch (token) {
11921 case "b":
11922 case "bb":
11923 return localize2.dayPeriod(dayPeriodEnumValue, {
11924 width: "abbreviated",
11925 context: "formatting"
11926 });
11927 case "bbb":
11928 return localize2.dayPeriod(dayPeriodEnumValue, {
11929 width: "abbreviated",
11930 context: "formatting"
11931 }).toLowerCase();
11932 case "bbbbb":
11933 return localize2.dayPeriod(dayPeriodEnumValue, {
11934 width: "narrow",
11935 context: "formatting"
11936 });
11937 case "bbbb":
11938 default:
11939 return localize2.dayPeriod(dayPeriodEnumValue, {
11940 width: "wide",
11941 context: "formatting"
11942 });
11943 }
11944 },
11945 // in the morning, in the afternoon, in the evening, at night
11946 B: function(date, token, localize2) {
11947 const hours = date.getHours();
11948 let dayPeriodEnumValue;
11949 if (hours >= 17) {
11950 dayPeriodEnumValue = dayPeriodEnum.evening;
11951 } else if (hours >= 12) {
11952 dayPeriodEnumValue = dayPeriodEnum.afternoon;
11953 } else if (hours >= 4) {
11954 dayPeriodEnumValue = dayPeriodEnum.morning;
11955 } else {
11956 dayPeriodEnumValue = dayPeriodEnum.night;
11957 }
11958 switch (token) {
11959 case "B":
11960 case "BB":
11961 case "BBB":
11962 return localize2.dayPeriod(dayPeriodEnumValue, {
11963 width: "abbreviated",
11964 context: "formatting"
11965 });
11966 case "BBBBB":
11967 return localize2.dayPeriod(dayPeriodEnumValue, {
11968 width: "narrow",
11969 context: "formatting"
11970 });
11971 case "BBBB":
11972 default:
11973 return localize2.dayPeriod(dayPeriodEnumValue, {
11974 width: "wide",
11975 context: "formatting"
11976 });
11977 }
11978 },
11979 // Hour [1-12]
11980 h: function(date, token, localize2) {
11981 if (token === "ho") {
11982 let hours = date.getHours() % 12;
11983 if (hours === 0) hours = 12;
11984 return localize2.ordinalNumber(hours, { unit: "hour" });
11985 }
11986 return lightFormatters.h(date, token);
11987 },
11988 // Hour [0-23]
11989 H: function(date, token, localize2) {
11990 if (token === "Ho") {
11991 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
11992 }
11993 return lightFormatters.H(date, token);
11994 },
11995 // Hour [0-11]
11996 K: function(date, token, localize2) {
11997 const hours = date.getHours() % 12;
11998 if (token === "Ko") {
11999 return localize2.ordinalNumber(hours, { unit: "hour" });
12000 }
12001 return addLeadingZeros(hours, token.length);
12002 },
12003 // Hour [1-24]
12004 k: function(date, token, localize2) {
12005 let hours = date.getHours();
12006 if (hours === 0) hours = 24;
12007 if (token === "ko") {
12008 return localize2.ordinalNumber(hours, { unit: "hour" });
12009 }
12010 return addLeadingZeros(hours, token.length);
12011 },
12012 // Minute
12013 m: function(date, token, localize2) {
12014 if (token === "mo") {
12015 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
12016 }
12017 return lightFormatters.m(date, token);
12018 },
12019 // Second
12020 s: function(date, token, localize2) {
12021 if (token === "so") {
12022 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
12023 }
12024 return lightFormatters.s(date, token);
12025 },
12026 // Fraction of second
12027 S: function(date, token) {
12028 return lightFormatters.S(date, token);
12029 },
12030 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
12031 X: function(date, token, _localize) {
12032 const timezoneOffset = date.getTimezoneOffset();
12033 if (timezoneOffset === 0) {
12034 return "Z";
12035 }
12036 switch (token) {
12037 // Hours and optional minutes
12038 case "X":
12039 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12040 // Hours, minutes and optional seconds without `:` delimiter
12041 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12042 // so this token always has the same output as `XX`
12043 case "XXXX":
12044 case "XX":
12045 return formatTimezone(timezoneOffset);
12046 // Hours, minutes and optional seconds with `:` delimiter
12047 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12048 // so this token always has the same output as `XXX`
12049 case "XXXXX":
12050 case "XXX":
12051 // Hours and minutes with `:` delimiter
12052 default:
12053 return formatTimezone(timezoneOffset, ":");
12054 }
12055 },
12056 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
12057 x: function(date, token, _localize) {
12058 const timezoneOffset = date.getTimezoneOffset();
12059 switch (token) {
12060 // Hours and optional minutes
12061 case "x":
12062 return formatTimezoneWithOptionalMinutes(timezoneOffset);
12063 // Hours, minutes and optional seconds without `:` delimiter
12064 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12065 // so this token always has the same output as `xx`
12066 case "xxxx":
12067 case "xx":
12068 return formatTimezone(timezoneOffset);
12069 // Hours, minutes and optional seconds with `:` delimiter
12070 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
12071 // so this token always has the same output as `xxx`
12072 case "xxxxx":
12073 case "xxx":
12074 // Hours and minutes with `:` delimiter
12075 default:
12076 return formatTimezone(timezoneOffset, ":");
12077 }
12078 },
12079 // Timezone (GMT)
12080 O: function(date, token, _localize) {
12081 const timezoneOffset = date.getTimezoneOffset();
12082 switch (token) {
12083 // Short
12084 case "O":
12085 case "OO":
12086 case "OOO":
12087 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12088 // Long
12089 case "OOOO":
12090 default:
12091 return "GMT" + formatTimezone(timezoneOffset, ":");
12092 }
12093 },
12094 // Timezone (specific non-location)
12095 z: function(date, token, _localize) {
12096 const timezoneOffset = date.getTimezoneOffset();
12097 switch (token) {
12098 // Short
12099 case "z":
12100 case "zz":
12101 case "zzz":
12102 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
12103 // Long
12104 case "zzzz":
12105 default:
12106 return "GMT" + formatTimezone(timezoneOffset, ":");
12107 }
12108 },
12109 // Seconds timestamp
12110 t: function(date, token, _localize) {
12111 const timestamp = Math.trunc(+date / 1e3);
12112 return addLeadingZeros(timestamp, token.length);
12113 },
12114 // Milliseconds timestamp
12115 T: function(date, token, _localize) {
12116 return addLeadingZeros(+date, token.length);
12117 }
12118 };
12119 function formatTimezoneShort(offset, delimiter = "") {
12120 const sign = offset > 0 ? "-" : "+";
12121 const absOffset = Math.abs(offset);
12122 const hours = Math.trunc(absOffset / 60);
12123 const minutes = absOffset % 60;
12124 if (minutes === 0) {
12125 return sign + String(hours);
12126 }
12127 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
12128 }
12129 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
12130 if (offset % 60 === 0) {
12131 const sign = offset > 0 ? "-" : "+";
12132 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
12133 }
12134 return formatTimezone(offset, delimiter);
12135 }
12136 function formatTimezone(offset, delimiter = "") {
12137 const sign = offset > 0 ? "-" : "+";
12138 const absOffset = Math.abs(offset);
12139 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
12140 const minutes = addLeadingZeros(absOffset % 60, 2);
12141 return sign + hours + delimiter + minutes;
12142 }
12143
12144 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
12145 var dateLongFormatter = (pattern, formatLong2) => {
12146 switch (pattern) {
12147 case "P":
12148 return formatLong2.date({ width: "short" });
12149 case "PP":
12150 return formatLong2.date({ width: "medium" });
12151 case "PPP":
12152 return formatLong2.date({ width: "long" });
12153 case "PPPP":
12154 default:
12155 return formatLong2.date({ width: "full" });
12156 }
12157 };
12158 var timeLongFormatter = (pattern, formatLong2) => {
12159 switch (pattern) {
12160 case "p":
12161 return formatLong2.time({ width: "short" });
12162 case "pp":
12163 return formatLong2.time({ width: "medium" });
12164 case "ppp":
12165 return formatLong2.time({ width: "long" });
12166 case "pppp":
12167 default:
12168 return formatLong2.time({ width: "full" });
12169 }
12170 };
12171 var dateTimeLongFormatter = (pattern, formatLong2) => {
12172 const matchResult = pattern.match(/(P+)(p+)?/) || [];
12173 const datePattern = matchResult[1];
12174 const timePattern = matchResult[2];
12175 if (!timePattern) {
12176 return dateLongFormatter(pattern, formatLong2);
12177 }
12178 let dateTimeFormat;
12179 switch (datePattern) {
12180 case "P":
12181 dateTimeFormat = formatLong2.dateTime({ width: "short" });
12182 break;
12183 case "PP":
12184 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
12185 break;
12186 case "PPP":
12187 dateTimeFormat = formatLong2.dateTime({ width: "long" });
12188 break;
12189 case "PPPP":
12190 default:
12191 dateTimeFormat = formatLong2.dateTime({ width: "full" });
12192 break;
12193 }
12194 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
12195 };
12196 var longFormatters = {
12197 p: timeLongFormatter,
12198 P: dateTimeLongFormatter
12199 };
12200
12201 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
12202 var dayOfYearTokenRE = /^D+$/;
12203 var weekYearTokenRE = /^Y+$/;
12204 var throwTokens = ["D", "DD", "YY", "YYYY"];
12205 function isProtectedDayOfYearToken(token) {
12206 return dayOfYearTokenRE.test(token);
12207 }
12208 function isProtectedWeekYearToken(token) {
12209 return weekYearTokenRE.test(token);
12210 }
12211 function warnOrThrowProtectedError(token, format6, input) {
12212 const _message = message(token, format6, input);
12213 console.warn(_message);
12214 if (throwTokens.includes(token)) throw new RangeError(_message);
12215 }
12216 function message(token, format6, input) {
12217 const subject = token[0] === "Y" ? "years" : "days of the month";
12218 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`;
12219 }
12220
12221 // packages/dataviews/node_modules/date-fns/format.js
12222 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
12223 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
12224 var escapedStringRegExp = /^'([^]*?)'?$/;
12225 var doubleQuoteRegExp = /''/g;
12226 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
12227 function format(date, formatStr, options) {
12228 const defaultOptions2 = getDefaultOptions();
12229 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
12230 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
12231 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12232 const originalDate = toDate(date, options?.in);
12233 if (!isValid(originalDate)) {
12234 throw new RangeError("Invalid time value");
12235 }
12236 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
12237 const firstCharacter = substring[0];
12238 if (firstCharacter === "p" || firstCharacter === "P") {
12239 const longFormatter = longFormatters[firstCharacter];
12240 return longFormatter(substring, locale.formatLong);
12241 }
12242 return substring;
12243 }).join("").match(formattingTokensRegExp).map((substring) => {
12244 if (substring === "''") {
12245 return { isToken: false, value: "'" };
12246 }
12247 const firstCharacter = substring[0];
12248 if (firstCharacter === "'") {
12249 return { isToken: false, value: cleanEscapedString(substring) };
12250 }
12251 if (formatters[firstCharacter]) {
12252 return { isToken: true, value: substring };
12253 }
12254 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
12255 throw new RangeError(
12256 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
12257 );
12258 }
12259 return { isToken: false, value: substring };
12260 });
12261 if (locale.localize.preprocessor) {
12262 parts = locale.localize.preprocessor(originalDate, parts);
12263 }
12264 const formatterOptions = {
12265 firstWeekContainsDate,
12266 weekStartsOn,
12267 locale
12268 };
12269 return parts.map((part) => {
12270 if (!part.isToken) return part.value;
12271 const token = part.value;
12272 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
12273 warnOrThrowProtectedError(token, formatStr, String(date));
12274 }
12275 const formatter = formatters[token[0]];
12276 return formatter(originalDate, token, locale.localize, formatterOptions);
12277 }).join("");
12278 }
12279 function cleanEscapedString(input) {
12280 const matched = input.match(escapedStringRegExp);
12281 if (!matched) {
12282 return input;
12283 }
12284 return matched[1].replace(doubleQuoteRegExp, "'");
12285 }
12286
12287 // packages/dataviews/node_modules/date-fns/subDays.js
12288 function subDays(date, amount, options) {
12289 return addDays(date, -amount, options);
12290 }
12291
12292 // packages/dataviews/node_modules/date-fns/subMonths.js
12293 function subMonths(date, amount, options) {
12294 return addMonths(date, -amount, options);
12295 }
12296
12297 // packages/dataviews/node_modules/date-fns/subWeeks.js
12298 function subWeeks(date, amount, options) {
12299 return addWeeks(date, -amount, options);
12300 }
12301
12302 // packages/dataviews/node_modules/date-fns/subYears.js
12303 function subYears(date, amount, options) {
12304 return addYears(date, -amount, options);
12305 }
12306
12307 // packages/dataviews/build-module/utils/operators.mjs
12308 var import_i18n23 = __toESM(require_i18n(), 1);
12309 var import_element30 = __toESM(require_element(), 1);
12310 var import_date = __toESM(require_date(), 1);
12311 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
12312 var filterTextWrappers = {
12313 Name: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
12314 Value: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
12315 };
12316 function getRelativeDate(value, unit) {
12317 switch (unit) {
12318 case "days":
12319 return subDays(/* @__PURE__ */ new Date(), value);
12320 case "weeks":
12321 return subWeeks(/* @__PURE__ */ new Date(), value);
12322 case "months":
12323 return subMonths(/* @__PURE__ */ new Date(), value);
12324 case "years":
12325 return subYears(/* @__PURE__ */ new Date(), value);
12326 default:
12327 return /* @__PURE__ */ new Date();
12328 }
12329 }
12330 var isNoneOperatorDefinition = {
12331 /* translators: DataViews operator name */
12332 label: (0, import_i18n23.__)("Is none of"),
12333 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12334 (0, import_i18n23.sprintf)(
12335 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
12336 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
12337 filter.name,
12338 activeElements.map((element) => element.label).join(", ")
12339 ),
12340 filterTextWrappers
12341 ),
12342 filter: ((item, field, filterValue) => {
12343 if (!filterValue?.length) {
12344 return true;
12345 }
12346 const fieldValue = field.getValue({ item });
12347 if (Array.isArray(fieldValue)) {
12348 return !filterValue.some(
12349 (fv) => fieldValue.includes(fv)
12350 );
12351 } else if (typeof fieldValue === "string") {
12352 return !filterValue.includes(fieldValue);
12353 }
12354 return false;
12355 }),
12356 selection: "multi"
12357 };
12358 var OPERATORS = [
12359 {
12360 name: OPERATOR_IS_ANY,
12361 /* translators: DataViews operator name */
12362 label: (0, import_i18n23.__)("Includes"),
12363 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12364 (0, import_i18n23.sprintf)(
12365 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
12366 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
12367 filter.name,
12368 activeElements.map((element) => element.label).join(", ")
12369 ),
12370 filterTextWrappers
12371 ),
12372 filter(item, field, filterValue) {
12373 if (!filterValue?.length) {
12374 return true;
12375 }
12376 const fieldValue = field.getValue({ item });
12377 if (Array.isArray(fieldValue)) {
12378 return filterValue.some(
12379 (fv) => fieldValue.includes(fv)
12380 );
12381 } else if (typeof fieldValue === "string") {
12382 return filterValue.includes(fieldValue);
12383 }
12384 return false;
12385 },
12386 selection: "multi"
12387 },
12388 {
12389 name: OPERATOR_IS_NONE,
12390 ...isNoneOperatorDefinition
12391 },
12392 {
12393 name: OPERATOR_IS_ALL,
12394 /* translators: DataViews operator name */
12395 label: (0, import_i18n23.__)("Includes all"),
12396 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12397 (0, import_i18n23.sprintf)(
12398 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
12399 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
12400 filter.name,
12401 activeElements.map((element) => element.label).join(", ")
12402 ),
12403 filterTextWrappers
12404 ),
12405 filter(item, field, filterValue) {
12406 if (!filterValue?.length) {
12407 return true;
12408 }
12409 return filterValue.every((value) => {
12410 return field.getValue({ item })?.includes(value);
12411 });
12412 },
12413 selection: "multi"
12414 },
12415 {
12416 name: OPERATOR_IS_NOT_ALL,
12417 ...isNoneOperatorDefinition
12418 },
12419 {
12420 name: OPERATOR_BETWEEN,
12421 /* translators: DataViews operator name */
12422 label: (0, import_i18n23.__)("Between (inc)"),
12423 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12424 (0, import_i18n23.sprintf)(
12425 /* 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". */
12426 (0, import_i18n23.__)(
12427 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
12428 ),
12429 filter.name,
12430 activeElements[0].label[0],
12431 activeElements[0].label[1]
12432 ),
12433 filterTextWrappers
12434 ),
12435 filter(item, field, filterValue) {
12436 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
12437 return true;
12438 }
12439 const fieldValue = field.getValue({ item });
12440 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
12441 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
12442 }
12443 return false;
12444 },
12445 selection: "custom"
12446 },
12447 {
12448 name: OPERATOR_IN_THE_PAST,
12449 /* translators: DataViews operator name */
12450 label: (0, import_i18n23.__)("In the past"),
12451 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12452 (0, import_i18n23.sprintf)(
12453 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
12454 (0, import_i18n23.__)(
12455 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
12456 ),
12457 filter.name,
12458 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12459 ),
12460 filterTextWrappers
12461 ),
12462 filter(item, field, filterValue) {
12463 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12464 return true;
12465 }
12466 const targetDate = getRelativeDate(
12467 filterValue.value,
12468 filterValue.unit
12469 );
12470 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12471 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
12472 },
12473 selection: "custom"
12474 },
12475 {
12476 name: OPERATOR_OVER,
12477 /* translators: DataViews operator name */
12478 label: (0, import_i18n23.__)("Over"),
12479 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12480 (0, import_i18n23.sprintf)(
12481 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
12482 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
12483 filter.name,
12484 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
12485 ),
12486 filterTextWrappers
12487 ),
12488 filter(item, field, filterValue) {
12489 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
12490 return true;
12491 }
12492 const targetDate = getRelativeDate(
12493 filterValue.value,
12494 filterValue.unit
12495 );
12496 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
12497 return fieldValue < targetDate;
12498 },
12499 selection: "custom"
12500 },
12501 {
12502 name: OPERATOR_IS,
12503 /* translators: DataViews operator name */
12504 label: (0, import_i18n23.__)("Is"),
12505 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12506 (0, import_i18n23.sprintf)(
12507 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
12508 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12509 filter.name,
12510 activeElements[0].label
12511 ),
12512 filterTextWrappers
12513 ),
12514 filter(item, field, filterValue) {
12515 return filterValue === field.getValue({ item }) || filterValue === void 0;
12516 },
12517 selection: "single"
12518 },
12519 {
12520 name: OPERATOR_IS_NOT,
12521 /* translators: DataViews operator name */
12522 label: (0, import_i18n23.__)("Is not"),
12523 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12524 (0, import_i18n23.sprintf)(
12525 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
12526 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12527 filter.name,
12528 activeElements[0].label
12529 ),
12530 filterTextWrappers
12531 ),
12532 filter(item, field, filterValue) {
12533 return filterValue !== field.getValue({ item });
12534 },
12535 selection: "single"
12536 },
12537 {
12538 name: OPERATOR_LESS_THAN,
12539 /* translators: DataViews operator name */
12540 label: (0, import_i18n23.__)("Less than"),
12541 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12542 (0, import_i18n23.sprintf)(
12543 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
12544 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
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,
12561 /* translators: DataViews operator name */
12562 label: (0, import_i18n23.__)("Greater than"),
12563 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12564 (0, import_i18n23.sprintf)(
12565 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
12566 (0, import_i18n23.__)(
12567 "<Name>%1$s is greater than: </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_LESS_THAN_OR_EQUAL,
12585 /* translators: DataViews operator name */
12586 label: (0, import_i18n23.__)("Less than or equal"),
12587 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12588 (0, import_i18n23.sprintf)(
12589 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
12590 (0, import_i18n23.__)(
12591 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
12592 ),
12593 filter.name,
12594 activeElements[0].label
12595 ),
12596 filterTextWrappers
12597 ),
12598 filter(item, field, filterValue) {
12599 if (filterValue === void 0) {
12600 return true;
12601 }
12602 const fieldValue = field.getValue({ item });
12603 return fieldValue <= filterValue;
12604 },
12605 selection: "single"
12606 },
12607 {
12608 name: OPERATOR_GREATER_THAN_OR_EQUAL,
12609 /* translators: DataViews operator name */
12610 label: (0, import_i18n23.__)("Greater than or equal"),
12611 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12612 (0, import_i18n23.sprintf)(
12613 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
12614 (0, import_i18n23.__)(
12615 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
12616 ),
12617 filter.name,
12618 activeElements[0].label
12619 ),
12620 filterTextWrappers
12621 ),
12622 filter(item, field, filterValue) {
12623 if (filterValue === void 0) {
12624 return true;
12625 }
12626 const fieldValue = field.getValue({ item });
12627 return fieldValue >= filterValue;
12628 },
12629 selection: "single"
12630 },
12631 {
12632 name: OPERATOR_BEFORE,
12633 /* translators: DataViews operator name */
12634 label: (0, import_i18n23.__)("Before"),
12635 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12636 (0, import_i18n23.sprintf)(
12637 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
12638 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
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,
12656 /* translators: DataViews operator name */
12657 label: (0, import_i18n23.__)("After"),
12658 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12659 (0, import_i18n23.sprintf)(
12660 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
12661 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
12662 filter.name,
12663 activeElements[0].label
12664 ),
12665 filterTextWrappers
12666 ),
12667 filter(item, field, filterValue) {
12668 if (filterValue === void 0) {
12669 return true;
12670 }
12671 const filterDate = (0, import_date.getDate)(filterValue);
12672 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12673 return fieldDate > filterDate;
12674 },
12675 selection: "single"
12676 },
12677 {
12678 name: OPERATOR_BEFORE_INC,
12679 /* translators: DataViews operator name */
12680 label: (0, import_i18n23.__)("Before (inc)"),
12681 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12682 (0, import_i18n23.sprintf)(
12683 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
12684 (0, import_i18n23.__)(
12685 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
12686 ),
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 filterDate = (0, import_date.getDate)(filterValue);
12697 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12698 return fieldDate <= filterDate;
12699 },
12700 selection: "single"
12701 },
12702 {
12703 name: OPERATOR_AFTER_INC,
12704 /* translators: DataViews operator name */
12705 label: (0, import_i18n23.__)("After (inc)"),
12706 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12707 (0, import_i18n23.sprintf)(
12708 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
12709 (0, import_i18n23.__)(
12710 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
12711 ),
12712 filter.name,
12713 activeElements[0].label
12714 ),
12715 filterTextWrappers
12716 ),
12717 filter(item, field, filterValue) {
12718 if (filterValue === void 0) {
12719 return true;
12720 }
12721 const filterDate = (0, import_date.getDate)(filterValue);
12722 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12723 return fieldDate >= filterDate;
12724 },
12725 selection: "single"
12726 },
12727 {
12728 name: OPERATOR_CONTAINS,
12729 /* translators: DataViews operator name */
12730 label: (0, import_i18n23.__)("Contains"),
12731 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12732 (0, import_i18n23.sprintf)(
12733 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
12734 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
12735 filter.name,
12736 activeElements[0].label
12737 ),
12738 filterTextWrappers
12739 ),
12740 filter(item, field, filterValue) {
12741 if (filterValue === void 0) {
12742 return true;
12743 }
12744 const fieldValue = field.getValue({ item });
12745 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12746 },
12747 selection: "single"
12748 },
12749 {
12750 name: OPERATOR_NOT_CONTAINS,
12751 /* translators: DataViews operator name */
12752 label: (0, import_i18n23.__)("Doesn't contain"),
12753 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12754 (0, import_i18n23.sprintf)(
12755 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
12756 (0, import_i18n23.__)(
12757 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
12758 ),
12759 filter.name,
12760 activeElements[0].label
12761 ),
12762 filterTextWrappers
12763 ),
12764 filter(item, field, filterValue) {
12765 if (filterValue === void 0) {
12766 return true;
12767 }
12768 const fieldValue = field.getValue({ item });
12769 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
12770 },
12771 selection: "single"
12772 },
12773 {
12774 name: OPERATOR_STARTS_WITH,
12775 /* translators: DataViews operator name */
12776 label: (0, import_i18n23.__)("Starts with"),
12777 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12778 (0, import_i18n23.sprintf)(
12779 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
12780 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
12781 filter.name,
12782 activeElements[0].label
12783 ),
12784 filterTextWrappers
12785 ),
12786 filter(item, field, filterValue) {
12787 if (filterValue === void 0) {
12788 return true;
12789 }
12790 const fieldValue = field.getValue({ item });
12791 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
12792 },
12793 selection: "single"
12794 },
12795 {
12796 name: OPERATOR_ON,
12797 /* translators: DataViews operator name */
12798 label: (0, import_i18n23.__)("On"),
12799 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12800 (0, import_i18n23.sprintf)(
12801 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
12802 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
12803 filter.name,
12804 activeElements[0].label
12805 ),
12806 filterTextWrappers
12807 ),
12808 filter(item, field, filterValue) {
12809 if (filterValue === void 0) {
12810 return true;
12811 }
12812 const filterDate = (0, import_date.getDate)(filterValue);
12813 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12814 return filterDate.getTime() === fieldDate.getTime();
12815 },
12816 selection: "single"
12817 },
12818 {
12819 name: OPERATOR_NOT_ON,
12820 /* translators: DataViews operator name */
12821 label: (0, import_i18n23.__)("Not on"),
12822 filterText: (filter, activeElements) => (0, import_element30.createInterpolateElement)(
12823 (0, import_i18n23.sprintf)(
12824 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
12825 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
12826 filter.name,
12827 activeElements[0].label
12828 ),
12829 filterTextWrappers
12830 ),
12831 filter(item, field, filterValue) {
12832 if (filterValue === void 0) {
12833 return true;
12834 }
12835 const filterDate = (0, import_date.getDate)(filterValue);
12836 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
12837 return filterDate.getTime() !== fieldDate.getTime();
12838 },
12839 selection: "single"
12840 }
12841 ];
12842 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
12843 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
12844 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
12845 (op) => op.name === name
12846 );
12847 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
12848
12849 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
12850 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
12851 var ENTER = "Enter";
12852 var SPACE = " ";
12853 var FilterText = ({
12854 activeElements,
12855 filterInView,
12856 filter
12857 }) => {
12858 if (activeElements === void 0 || activeElements.length === 0) {
12859 return filter.name;
12860 }
12861 const operator = getOperatorByName(filterInView?.operator);
12862 if (operator !== void 0) {
12863 return operator.filterText(filter, activeElements);
12864 }
12865 return (0, import_i18n24.sprintf)(
12866 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
12867 (0, import_i18n24.__)("Unknown status for %1$s"),
12868 filter.name
12869 );
12870 };
12871 function OperatorSelector({
12872 filter,
12873 view,
12874 onChangeView
12875 }) {
12876 const operatorOptions = filter.operators?.map((operator) => ({
12877 value: operator,
12878 label: getOperatorByName(operator)?.label || operator
12879 }));
12880 const currentFilter = view.filters?.find(
12881 (_filter) => _filter.field === filter.field
12882 );
12883 const value = currentFilter?.operator || filter.operators[0];
12884 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(
12885 Stack,
12886 {
12887 direction: "row",
12888 gap: "sm",
12889 justify: "flex-start",
12890 className: "dataviews-filters__summary-operators-container",
12891 align: "center",
12892 children: [
12893 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components20.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
12894 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
12895 import_components20.SelectControl,
12896 {
12897 className: "dataviews-filters__summary-operators-filter-select",
12898 label: (0, import_i18n24.__)("Conditions"),
12899 value,
12900 options: operatorOptions,
12901 onChange: (newValue) => {
12902 const newOperator = newValue;
12903 const currentOperator = currentFilter?.operator;
12904 const newFilters = currentFilter ? [
12905 ...(view.filters ?? []).map(
12906 (_filter) => {
12907 if (_filter.field === filter.field) {
12908 const currentOpSelectionModel = getOperatorByName(
12909 currentOperator
12910 )?.selection;
12911 const newOpSelectionModel = getOperatorByName(
12912 newOperator
12913 )?.selection;
12914 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
12915 currentOpSelectionModel,
12916 newOpSelectionModel
12917 ].includes("custom");
12918 return {
12919 ..._filter,
12920 value: shouldResetValue ? void 0 : _filter.value,
12921 operator: newOperator
12922 };
12923 }
12924 return _filter;
12925 }
12926 )
12927 ] : [
12928 ...view.filters ?? [],
12929 {
12930 field: filter.field,
12931 operator: newOperator,
12932 value: void 0
12933 }
12934 ];
12935 onChangeView({
12936 ...view,
12937 page: 1,
12938 filters: newFilters
12939 });
12940 },
12941 size: "small",
12942 variant: "minimal",
12943 hideLabelFromVision: true
12944 }
12945 )
12946 ]
12947 }
12948 );
12949 }
12950 function Filter({
12951 addFilterRef,
12952 openedFilter,
12953 fields,
12954 ...commonProps
12955 }) {
12956 const toggleRef = (0, import_element31.useRef)(null);
12957 const { filter, view, onChangeView } = commonProps;
12958 const filterInView = view.filters?.find(
12959 (f2) => f2.field === filter.field
12960 );
12961 let activeElements = [];
12962 const field = (0, import_element31.useMemo)(() => {
12963 const currentField = fields.find((f2) => f2.id === filter.field);
12964 if (currentField) {
12965 return {
12966 ...currentField,
12967 // Configure getValue as if Item was a plain object.
12968 // See related input-widget.tsx
12969 getValue: ({ item }) => item[currentField.id]
12970 };
12971 }
12972 return currentField;
12973 }, [fields, filter.field]);
12974 const { elements } = useElements({
12975 elements: filter.elements,
12976 getElements: filter.getElements
12977 });
12978 if (elements.length > 0) {
12979 activeElements = elements.filter((element) => {
12980 if (filter.singleSelection) {
12981 return element.value === filterInView?.value;
12982 }
12983 return filterInView?.value?.includes(element.value);
12984 });
12985 } else if (Array.isArray(filterInView?.value)) {
12986 const label = filterInView.value.map((v2) => {
12987 const formattedValue = field?.getValueFormatted({
12988 item: { [field.id]: v2 },
12989 field
12990 });
12991 return formattedValue || String(v2);
12992 });
12993 activeElements = [
12994 {
12995 value: filterInView.value,
12996 // @ts-ignore
12997 label
12998 }
12999 ];
13000 } else if (typeof filterInView?.value === "object") {
13001 activeElements = [
13002 { value: filterInView.value, label: filterInView.value }
13003 ];
13004 } else if (filterInView?.value !== void 0) {
13005 const label = field !== void 0 ? field.getValueFormatted({
13006 item: { [field.id]: filterInView.value },
13007 field
13008 }) : String(filterInView.value);
13009 activeElements = [
13010 {
13011 value: filterInView.value,
13012 label
13013 }
13014 ];
13015 }
13016 const isPrimary = filter.isPrimary;
13017 const isLocked = filterInView?.isLocked;
13018 const hasValues = !isLocked && filterInView?.value !== void 0;
13019 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
13020 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13021 import_components20.Dropdown,
13022 {
13023 defaultOpen: openedFilter === filter.field,
13024 contentClassName: "dataviews-filters__summary-popover",
13025 popoverProps: { placement: "bottom-start", role: "dialog" },
13026 onClose: () => {
13027 toggleRef.current?.focus();
13028 },
13029 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
13030 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13031 import_components20.Tooltip,
13032 {
13033 text: (0, import_i18n24.sprintf)(
13034 /* translators: 1: Filter name. */
13035 (0, import_i18n24.__)("Filter by: %1$s"),
13036 filter.name.toLowerCase()
13037 ),
13038 placement: "top",
13039 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13040 "div",
13041 {
13042 className: clsx_default(
13043 "dataviews-filters__summary-chip",
13044 {
13045 "has-reset": canResetOrRemove,
13046 "has-values": hasValues,
13047 "is-not-clickable": isLocked
13048 }
13049 ),
13050 role: "button",
13051 tabIndex: isLocked ? -1 : 0,
13052 onClick: () => {
13053 if (!isLocked) {
13054 onToggle();
13055 }
13056 },
13057 onKeyDown: (event) => {
13058 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
13059 onToggle();
13060 event.preventDefault();
13061 }
13062 },
13063 "aria-disabled": isLocked,
13064 "aria-pressed": isOpen,
13065 "aria-expanded": isOpen,
13066 ref: toggleRef,
13067 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13068 FilterText,
13069 {
13070 activeElements,
13071 filterInView,
13072 filter
13073 }
13074 )
13075 }
13076 )
13077 }
13078 ),
13079 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13080 import_components20.Tooltip,
13081 {
13082 text: isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove"),
13083 placement: "top",
13084 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13085 "button",
13086 {
13087 className: clsx_default(
13088 "dataviews-filters__summary-chip-remove",
13089 { "has-values": hasValues }
13090 ),
13091 onClick: () => {
13092 onChangeView({
13093 ...view,
13094 page: 1,
13095 filters: view.filters?.filter(
13096 (_filter) => _filter.field !== filter.field
13097 )
13098 });
13099 if (!isPrimary) {
13100 addFilterRef.current?.focus();
13101 } else {
13102 toggleRef.current?.focus();
13103 }
13104 },
13105 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components20.Icon, { icon: close_small_default })
13106 }
13107 )
13108 }
13109 )
13110 ] }),
13111 renderContent: () => {
13112 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
13113 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(OperatorSelector, { ...commonProps }),
13114 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
13115 SearchWidget,
13116 {
13117 ...commonProps,
13118 filter: {
13119 ...commonProps.filter,
13120 elements
13121 }
13122 }
13123 ) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(InputWidget, { ...commonProps, fields })
13124 ] });
13125 }
13126 }
13127 );
13128 }
13129
13130 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
13131 var import_components21 = __toESM(require_components(), 1);
13132 var import_i18n25 = __toESM(require_i18n(), 1);
13133 var import_element32 = __toESM(require_element(), 1);
13134 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
13135 var { Menu: Menu4 } = unlock2(import_components21.privateApis);
13136 function AddFilterMenu({
13137 filters,
13138 view,
13139 onChangeView,
13140 setOpenedFilter,
13141 triggerProps
13142 }) {
13143 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13144 return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Menu4, { children: [
13145 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.TriggerButton, { ...triggerProps }),
13146 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
13147 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13148 Menu4.Item,
13149 {
13150 onClick: () => {
13151 setOpenedFilter(filter.field);
13152 onChangeView({
13153 ...view,
13154 page: 1,
13155 filters: [
13156 ...view.filters || [],
13157 {
13158 field: filter.field,
13159 value: void 0,
13160 operator: filter.operators[0]
13161 }
13162 ]
13163 });
13164 },
13165 children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(Menu4.ItemLabel, { children: filter.name })
13166 },
13167 filter.field
13168 );
13169 }) })
13170 ] });
13171 }
13172 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
13173 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
13174 return null;
13175 }
13176 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
13177 return /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13178 AddFilterMenu,
13179 {
13180 triggerProps: {
13181 render: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
13182 import_components21.Button,
13183 {
13184 accessibleWhenDisabled: true,
13185 size: "compact",
13186 className: "dataviews-filters-button",
13187 variant: "tertiary",
13188 disabled: !inactiveFilters.length,
13189 ref
13190 }
13191 ),
13192 children: (0, import_i18n25.__)("Add filter")
13193 },
13194 ...{ filters, view, onChangeView, setOpenedFilter }
13195 }
13196 );
13197 }
13198 var add_filter_default = (0, import_element32.forwardRef)(AddFilter);
13199
13200 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
13201 var import_components22 = __toESM(require_components(), 1);
13202 var import_i18n26 = __toESM(require_i18n(), 1);
13203 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
13204 function ResetFilter({
13205 filters,
13206 view,
13207 onChangeView
13208 }) {
13209 const isPrimary = (field) => filters.some(
13210 (_filter) => _filter.field === field && _filter.isPrimary
13211 );
13212 const isDisabled = !view.search && !view.filters?.some(
13213 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
13214 );
13215 return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
13216 import_components22.Button,
13217 {
13218 disabled: isDisabled,
13219 accessibleWhenDisabled: true,
13220 size: "compact",
13221 variant: "tertiary",
13222 className: "dataviews-filters__reset-button",
13223 onClick: () => {
13224 onChangeView({
13225 ...view,
13226 page: 1,
13227 search: "",
13228 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
13229 });
13230 },
13231 children: (0, import_i18n26.__)("Reset")
13232 }
13233 );
13234 }
13235
13236 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
13237 var import_element33 = __toESM(require_element(), 1);
13238 function useFilters(fields, view) {
13239 return (0, import_element33.useMemo)(() => {
13240 const filters = [];
13241 fields.forEach((field) => {
13242 if (field.filterBy === false || !field.hasElements && !field.Edit) {
13243 return;
13244 }
13245 const operators = field.filterBy.operators;
13246 const isPrimary = !!field.filterBy?.isPrimary;
13247 const isLocked = view.filters?.some(
13248 (f2) => f2.field === field.id && !!f2.isLocked
13249 ) ?? false;
13250 filters.push({
13251 field: field.id,
13252 name: field.label,
13253 elements: field.elements,
13254 getElements: field.getElements,
13255 hasElements: field.hasElements,
13256 singleSelection: operators.some(
13257 (op) => isSingleSelectionOperator(op)
13258 ),
13259 operators,
13260 isVisible: isLocked || isPrimary || !!view.filters?.some(
13261 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
13262 ),
13263 isPrimary,
13264 isLocked
13265 });
13266 });
13267 filters.sort((a2, b2) => {
13268 if (a2.isLocked && !b2.isLocked) {
13269 return -1;
13270 }
13271 if (!a2.isLocked && b2.isLocked) {
13272 return 1;
13273 }
13274 if (a2.isPrimary && !b2.isPrimary) {
13275 return -1;
13276 }
13277 if (!a2.isPrimary && b2.isPrimary) {
13278 return 1;
13279 }
13280 return a2.name.localeCompare(b2.name);
13281 });
13282 return filters;
13283 }, [fields, view]);
13284 }
13285 var use_filters_default = useFilters;
13286
13287 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
13288 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
13289 function Filters({ className }) {
13290 const { fields, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element34.useContext)(dataviews_context_default);
13291 const addFilterRef = (0, import_element34.useRef)(null);
13292 const filters = use_filters_default(fields, view);
13293 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13294 add_filter_default,
13295 {
13296 filters,
13297 view,
13298 onChangeView,
13299 ref: addFilterRef,
13300 setOpenedFilter
13301 },
13302 "add-filter"
13303 );
13304 const visibleFilters = filters.filter((filter) => filter.isVisible);
13305 if (visibleFilters.length === 0) {
13306 return null;
13307 }
13308 const filterComponents = [
13309 ...visibleFilters.map((filter) => {
13310 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13311 Filter,
13312 {
13313 filter,
13314 view,
13315 fields,
13316 onChangeView,
13317 addFilterRef,
13318 openedFilter
13319 },
13320 filter.field
13321 );
13322 }),
13323 addFilter
13324 ];
13325 filterComponents.push(
13326 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13327 ResetFilter,
13328 {
13329 filters,
13330 view,
13331 onChangeView
13332 },
13333 "reset-filters"
13334 )
13335 );
13336 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
13337 Stack,
13338 {
13339 direction: "row",
13340 justify: "flex-start",
13341 gap: "sm",
13342 style: { width: "fit-content" },
13343 wrap: "wrap",
13344 className,
13345 children: filterComponents
13346 }
13347 );
13348 }
13349 var filters_default = (0, import_element34.memo)(Filters);
13350
13351 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
13352 var import_element35 = __toESM(require_element(), 1);
13353 var import_components23 = __toESM(require_components(), 1);
13354 var import_i18n27 = __toESM(require_i18n(), 1);
13355 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
13356 function FiltersToggle() {
13357 const {
13358 filters,
13359 view,
13360 onChangeView,
13361 setOpenedFilter,
13362 isShowingFilter,
13363 setIsShowingFilter
13364 } = (0, import_element35.useContext)(dataviews_context_default);
13365 const buttonRef = (0, import_element35.useRef)(null);
13366 const onChangeViewWithFilterVisibility = (0, import_element35.useCallback)(
13367 (_view) => {
13368 onChangeView(_view);
13369 setIsShowingFilter(true);
13370 },
13371 [onChangeView, setIsShowingFilter]
13372 );
13373 if (filters.length === 0) {
13374 return null;
13375 }
13376 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
13377 const addFilterButtonProps = {
13378 label: (0, import_i18n27.__)("Add filter"),
13379 "aria-expanded": false,
13380 isPressed: false
13381 };
13382 const toggleFiltersButtonProps = {
13383 label: (0, import_i18n27._x)("Filter", "verb"),
13384 "aria-expanded": isShowingFilter,
13385 isPressed: isShowingFilter,
13386 onClick: () => {
13387 if (!isShowingFilter) {
13388 setOpenedFilter(null);
13389 }
13390 setIsShowingFilter(!isShowingFilter);
13391 }
13392 };
13393 const hasPrimaryOrLockedFilters = filters.some(
13394 (filter) => filter.isPrimary || filter.isLocked
13395 );
13396 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13397 import_components23.Button,
13398 {
13399 ref: buttonRef,
13400 className: "dataviews-filters__visibility-toggle",
13401 size: "compact",
13402 icon: funnel_default,
13403 disabled: hasPrimaryOrLockedFilters,
13404 accessibleWhenDisabled: true,
13405 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
13406 }
13407 );
13408 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13409 AddFilterMenu,
13410 {
13411 filters,
13412 view,
13413 onChangeView: onChangeViewWithFilterVisibility,
13414 setOpenedFilter,
13415 triggerProps: { render: buttonComponent }
13416 }
13417 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
13418 FilterVisibilityToggle,
13419 {
13420 buttonRef,
13421 filtersCount: view.filters?.length,
13422 children: buttonComponent
13423 }
13424 ) });
13425 }
13426 function FilterVisibilityToggle({
13427 buttonRef,
13428 filtersCount,
13429 children
13430 }) {
13431 (0, import_element35.useEffect)(
13432 () => () => {
13433 buttonRef.current?.focus();
13434 },
13435 [buttonRef]
13436 );
13437 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
13438 children,
13439 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
13440 ] });
13441 }
13442 var toggle_default = FiltersToggle;
13443
13444 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
13445 var import_element36 = __toESM(require_element(), 1);
13446 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
13447 function FiltersToggled(props) {
13448 const { isShowingFilter } = (0, import_element36.useContext)(dataviews_context_default);
13449 if (!isShowingFilter) {
13450 return null;
13451 }
13452 return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(filters_default, { ...props });
13453 }
13454 var filters_toggled_default = FiltersToggled;
13455
13456 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
13457 var import_element37 = __toESM(require_element(), 1);
13458 var import_components24 = __toESM(require_components(), 1);
13459 var import_i18n28 = __toESM(require_i18n(), 1);
13460 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
13461 function DataViewsLayout({ className }) {
13462 const {
13463 actions = [],
13464 data,
13465 fields,
13466 getItemId,
13467 getItemLevel,
13468 hasInitiallyLoaded,
13469 isLoading,
13470 view,
13471 onChangeView,
13472 selection,
13473 onChangeSelection,
13474 setOpenedFilter,
13475 onClickItem,
13476 isItemClickable,
13477 renderItemLink,
13478 defaultLayouts,
13479 containerRef,
13480 empty = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { children: (0, import_i18n28.__)("No results") })
13481 } = (0, import_element37.useContext)(dataviews_context_default);
13482 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
13483 delay: 200
13484 });
13485 if (!hasInitiallyLoaded) {
13486 if (!isDelayedInitialLoading) {
13487 return null;
13488 }
13489 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_components24.Spinner, {}) }) });
13490 }
13491 const ViewComponent = VIEW_LAYOUTS.find(
13492 (v2) => v2.type === view.type && defaultLayouts[v2.type]
13493 )?.component;
13494 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
13495 ViewComponent,
13496 {
13497 className,
13498 actions,
13499 data,
13500 fields,
13501 getItemId,
13502 getItemLevel,
13503 isLoading,
13504 onChangeView,
13505 onChangeSelection,
13506 selection,
13507 setOpenedFilter,
13508 onClickItem,
13509 renderItemLink,
13510 isItemClickable,
13511 view,
13512 empty
13513 }
13514 ) });
13515 }
13516
13517 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
13518 var import_element38 = __toESM(require_element(), 1);
13519 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
13520 var EMPTY_ARRAY5 = [];
13521 function DataViewsFooter() {
13522 const {
13523 view,
13524 paginationInfo: { totalItems = 0, totalPages },
13525 data,
13526 actions = EMPTY_ARRAY5,
13527 isLoading,
13528 hasInitiallyLoaded
13529 } = (0, import_element38.useContext)(dataviews_context_default);
13530 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
13531 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
13532 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
13533 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
13534 return null;
13535 }
13536 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
13537 "div",
13538 {
13539 className: "dataviews-footer",
13540 inert: isRefreshing ? "true" : void 0,
13541 children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
13542 Stack,
13543 {
13544 direction: "row",
13545 justify: "end",
13546 align: "center",
13547 className: clsx_default("dataviews-footer__content", {
13548 "is-refreshing": isDelayedRefreshing
13549 }),
13550 gap: "sm",
13551 children: [
13552 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(BulkActionsFooter, {}),
13553 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(dataviews_pagination_default, {})
13554 ]
13555 }
13556 )
13557 }
13558 );
13559 }
13560
13561 // packages/dataviews/build-module/components/dataviews-search/index.mjs
13562 var import_i18n29 = __toESM(require_i18n(), 1);
13563 var import_element39 = __toESM(require_element(), 1);
13564 var import_components25 = __toESM(require_components(), 1);
13565 var import_compose9 = __toESM(require_compose(), 1);
13566 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
13567 var DataViewsSearch = (0, import_element39.memo)(function Search({ label }) {
13568 const { view, onChangeView } = (0, import_element39.useContext)(dataviews_context_default);
13569 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
13570 view.search
13571 );
13572 (0, import_element39.useEffect)(() => {
13573 if (view.search !== debouncedSearch) {
13574 setSearch(view.search ?? "");
13575 }
13576 }, [view.search, setSearch]);
13577 const onChangeViewRef = (0, import_element39.useRef)(onChangeView);
13578 const viewRef = (0, import_element39.useRef)(view);
13579 (0, import_element39.useEffect)(() => {
13580 onChangeViewRef.current = onChangeView;
13581 viewRef.current = view;
13582 }, [onChangeView, view]);
13583 (0, import_element39.useEffect)(() => {
13584 if (debouncedSearch !== viewRef.current?.search) {
13585 onChangeViewRef.current({
13586 ...viewRef.current,
13587 page: view.page ? 1 : void 0,
13588 startPosition: view.startPosition ? 1 : void 0,
13589 search: debouncedSearch
13590 });
13591 }
13592 }, [debouncedSearch]);
13593 const searchLabel = label || (0, import_i18n29.__)("Search");
13594 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
13595 import_components25.SearchControl,
13596 {
13597 className: "dataviews-search",
13598 onChange: setSearch,
13599 value: search,
13600 label: searchLabel,
13601 placeholder: searchLabel,
13602 size: "compact"
13603 }
13604 );
13605 });
13606 var dataviews_search_default = DataViewsSearch;
13607
13608 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
13609 var import_components26 = __toESM(require_components(), 1);
13610 var import_i18n30 = __toESM(require_i18n(), 1);
13611 var import_element40 = __toESM(require_element(), 1);
13612 var import_warning = __toESM(require_warning(), 1);
13613 var import_compose10 = __toESM(require_compose(), 1);
13614 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
13615 var { Menu: Menu5 } = unlock2(import_components26.privateApis);
13616 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
13617 className: "dataviews-config__popover",
13618 placement: "bottom-end",
13619 offset: 9
13620 };
13621 function ViewTypeMenu() {
13622 const { view, onChangeView, defaultLayouts } = (0, import_element40.useContext)(dataviews_context_default);
13623 const availableLayouts = Object.keys(defaultLayouts);
13624 if (availableLayouts.length <= 1) {
13625 return null;
13626 }
13627 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
13628 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Menu5, { children: [
13629 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13630 Menu5.TriggerButton,
13631 {
13632 render: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13633 import_components26.Button,
13634 {
13635 size: "compact",
13636 icon: activeView?.icon,
13637 label: (0, import_i18n30.__)("Layout")
13638 }
13639 )
13640 }
13641 ),
13642 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
13643 const config = VIEW_LAYOUTS.find(
13644 (v2) => v2.type === layout
13645 );
13646 if (!config) {
13647 return null;
13648 }
13649 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13650 Menu5.RadioItem,
13651 {
13652 value: layout,
13653 name: "view-actions-available-view",
13654 checked: layout === view.type,
13655 hideOnClick: true,
13656 onChange: (e2) => {
13657 switch (e2.target.value) {
13658 case "list":
13659 case "grid":
13660 case "table":
13661 case "pickerGrid":
13662 case "pickerTable":
13663 case "activity":
13664 const viewWithoutLayout = { ...view };
13665 if ("layout" in viewWithoutLayout) {
13666 delete viewWithoutLayout.layout;
13667 }
13668 return onChangeView({
13669 ...viewWithoutLayout,
13670 type: e2.target.value,
13671 ...defaultLayouts[e2.target.value]
13672 });
13673 }
13674 (0, import_warning.default)("Invalid dataview");
13675 },
13676 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Menu5.ItemLabel, { children: config.label })
13677 },
13678 layout
13679 );
13680 }) })
13681 ] });
13682 }
13683 function SortFieldControl() {
13684 const { view, fields, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13685 const orderOptions = (0, import_element40.useMemo)(() => {
13686 const sortableFields = fields.filter(
13687 (field) => field.enableSorting !== false
13688 );
13689 return sortableFields.map((field) => {
13690 return {
13691 label: field.label,
13692 value: field.id
13693 };
13694 });
13695 }, [fields]);
13696 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13697 import_components26.SelectControl,
13698 {
13699 __next40pxDefaultSize: true,
13700 label: (0, import_i18n30.__)("Sort by"),
13701 value: view.sort?.field,
13702 options: orderOptions,
13703 onChange: (value) => {
13704 onChangeView({
13705 ...view,
13706 sort: {
13707 direction: view?.sort?.direction || "desc",
13708 field: value
13709 },
13710 showLevels: false
13711 });
13712 }
13713 }
13714 );
13715 }
13716 function SortDirectionControl() {
13717 const { view, fields, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13718 const sortableFields = fields.filter(
13719 (field) => field.enableSorting !== false
13720 );
13721 if (sortableFields.length === 0) {
13722 return null;
13723 }
13724 let value = view.sort?.direction;
13725 if (!value && view.sort?.field) {
13726 value = "desc";
13727 }
13728 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13729 import_components26.__experimentalToggleGroupControl,
13730 {
13731 className: "dataviews-view-config__sort-direction",
13732 __next40pxDefaultSize: true,
13733 isBlock: true,
13734 label: (0, import_i18n30.__)("Order"),
13735 value,
13736 onChange: (newDirection) => {
13737 if (newDirection === "asc" || newDirection === "desc") {
13738 onChangeView({
13739 ...view,
13740 sort: {
13741 direction: newDirection,
13742 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
13743 fields.find(
13744 (field) => field.enableSorting !== false
13745 )?.id || ""
13746 },
13747 showLevels: false
13748 });
13749 return;
13750 }
13751 (0, import_warning.default)("Invalid direction");
13752 },
13753 children: SORTING_DIRECTIONS.map((direction) => {
13754 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13755 import_components26.__experimentalToggleGroupControlOptionIcon,
13756 {
13757 value: direction,
13758 icon: sortIcons[direction],
13759 label: sortLabels[direction]
13760 },
13761 direction
13762 );
13763 })
13764 }
13765 );
13766 }
13767 function ItemsPerPageControl() {
13768 const { view, config, onChangeView } = (0, import_element40.useContext)(dataviews_context_default);
13769 const { infiniteScrollEnabled } = view;
13770 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
13771 return null;
13772 }
13773 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13774 import_components26.__experimentalToggleGroupControl,
13775 {
13776 __next40pxDefaultSize: true,
13777 isBlock: true,
13778 label: (0, import_i18n30.__)("Items per page"),
13779 value: view.perPage || 10,
13780 disabled: !view?.sort?.field,
13781 onChange: (newItemsPerPage) => {
13782 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
13783 onChangeView({
13784 ...view,
13785 perPage: newItemsPerPageNumber,
13786 page: 1
13787 });
13788 },
13789 children: config.perPageSizes.map((value) => {
13790 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13791 import_components26.__experimentalToggleGroupControlOption,
13792 {
13793 value,
13794 label: value.toString()
13795 },
13796 value
13797 );
13798 })
13799 }
13800 );
13801 }
13802 function ResetViewButton() {
13803 const { onReset } = (0, import_element40.useContext)(dataviews_context_default);
13804 if (onReset === void 0) {
13805 return null;
13806 }
13807 const isDisabled = onReset === false;
13808 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13809 import_components26.Button,
13810 {
13811 variant: "tertiary",
13812 size: "compact",
13813 disabled: isDisabled,
13814 accessibleWhenDisabled: true,
13815 className: "dataviews-view-config__reset-button",
13816 onClick: () => {
13817 if (typeof onReset === "function") {
13818 onReset();
13819 }
13820 },
13821 children: (0, import_i18n30.__)("Reset view")
13822 }
13823 );
13824 }
13825 function DataviewsViewConfigDropdown() {
13826 const { view, onReset } = (0, import_element40.useContext)(dataviews_context_default);
13827 const popoverId = (0, import_compose10.useInstanceId)(
13828 _DataViewsViewConfig,
13829 "dataviews-view-config-dropdown"
13830 );
13831 const activeLayout = VIEW_LAYOUTS.find(
13832 (layout) => layout.type === view.type
13833 );
13834 const isModified = typeof onReset === "function";
13835 return /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13836 import_components26.Dropdown,
13837 {
13838 expandOnMobile: true,
13839 popoverProps: {
13840 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
13841 id: popoverId
13842 },
13843 renderToggle: ({ onToggle, isOpen }) => {
13844 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
13845 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13846 import_components26.Button,
13847 {
13848 size: "compact",
13849 icon: cog_default,
13850 label: (0, import_i18n30._x)(
13851 "View options",
13852 "View is used as a noun"
13853 ),
13854 onClick: onToggle,
13855 "aria-expanded": isOpen ? "true" : "false",
13856 "aria-controls": popoverId
13857 }
13858 ),
13859 isModified && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
13860 ] });
13861 },
13862 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13863 import_components26.__experimentalDropdownContentWrapper,
13864 {
13865 paddingSize: "medium",
13866 className: "dataviews-config__popover-content-wrapper",
13867 children: /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13868 Stack,
13869 {
13870 direction: "column",
13871 className: "dataviews-view-config",
13872 gap: "xl",
13873 children: [
13874 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13875 Stack,
13876 {
13877 direction: "row",
13878 justify: "space-between",
13879 align: "center",
13880 className: "dataviews-view-config__header",
13881 children: [
13882 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
13883 import_components26.__experimentalHeading,
13884 {
13885 level: 2,
13886 className: "dataviews-settings-section__title",
13887 children: (0, import_i18n30.__)("Appearance")
13888 }
13889 ),
13890 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ResetViewButton, {})
13891 ]
13892 }
13893 ),
13894 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(Stack, { direction: "column", gap: "lg", children: [
13895 /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(
13896 Stack,
13897 {
13898 direction: "row",
13899 gap: "sm",
13900 className: "dataviews-view-config__sort-controls",
13901 children: [
13902 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SortFieldControl, {}),
13903 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(SortDirectionControl, {})
13904 ]
13905 }
13906 ),
13907 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(activeLayout.viewConfigOptions, {}),
13908 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ItemsPerPageControl, {}),
13909 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(PropertiesSection, {})
13910 ] })
13911 ]
13912 }
13913 )
13914 }
13915 )
13916 }
13917 );
13918 }
13919 function _DataViewsViewConfig() {
13920 return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_jsx_runtime67.Fragment, { children: [
13921 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(ViewTypeMenu, {}),
13922 /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(DataviewsViewConfigDropdown, {})
13923 ] });
13924 }
13925 var DataViewsViewConfig = (0, import_element40.memo)(_DataViewsViewConfig);
13926 var dataviews_view_config_default = DataViewsViewConfig;
13927
13928 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13929 var import_components27 = __toESM(require_components(), 1);
13930 var import_element41 = __toESM(require_element(), 1);
13931
13932 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
13933 function getCustomValidity(isValid2, validity) {
13934 let customValidity;
13935 if (isValid2?.required && validity?.required) {
13936 customValidity = validity?.required?.message ? validity.required : void 0;
13937 } else if (isValid2?.pattern && validity?.pattern) {
13938 customValidity = validity.pattern;
13939 } else if (isValid2?.min && validity?.min) {
13940 customValidity = validity.min;
13941 } else if (isValid2?.max && validity?.max) {
13942 customValidity = validity.max;
13943 } else if (isValid2?.minLength && validity?.minLength) {
13944 customValidity = validity.minLength;
13945 } else if (isValid2?.maxLength && validity?.maxLength) {
13946 customValidity = validity.maxLength;
13947 } else if (isValid2?.elements && validity?.elements) {
13948 customValidity = validity.elements;
13949 } else if (validity?.custom) {
13950 customValidity = validity.custom;
13951 }
13952 return customValidity;
13953 }
13954
13955 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
13956 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
13957 var { ValidatedCheckboxControl } = unlock2(import_components27.privateApis);
13958 function Checkbox({
13959 field,
13960 onChange,
13961 data,
13962 hideLabelFromVision,
13963 markWhenOptional,
13964 validity
13965 }) {
13966 const { getValue, setValue, label, description, isValid: isValid2 } = field;
13967 const disabled = field.isDisabled({ item: data, field });
13968 const onChangeControl = (0, import_element41.useCallback)(() => {
13969 onChange(
13970 setValue({ item: data, value: !getValue({ item: data }) })
13971 );
13972 }, [data, getValue, onChange, setValue]);
13973 return /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(
13974 ValidatedCheckboxControl,
13975 {
13976 required: !!field.isValid?.required,
13977 markWhenOptional,
13978 customValidity: getCustomValidity(isValid2, validity),
13979 hidden: hideLabelFromVision,
13980 label,
13981 help: description,
13982 checked: getValue({ item: data }),
13983 onChange: onChangeControl,
13984 disabled
13985 }
13986 );
13987 }
13988
13989 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
13990 var import_components28 = __toESM(require_components(), 1);
13991 var import_element42 = __toESM(require_element(), 1);
13992 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
13993 var { ValidatedComboboxControl } = unlock2(import_components28.privateApis);
13994 function Combobox3({
13995 data,
13996 field,
13997 onChange,
13998 hideLabelFromVision,
13999 validity
14000 }) {
14001 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
14002 const value = getValue({ item: data }) ?? "";
14003 const onChangeControl = (0, import_element42.useCallback)(
14004 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
14005 [data, onChange, setValue]
14006 );
14007 const { elements, isLoading } = useElements({
14008 elements: field.elements,
14009 getElements: field.getElements
14010 });
14011 if (isLoading) {
14012 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_components28.Spinner, {});
14013 }
14014 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
14015 ValidatedComboboxControl,
14016 {
14017 required: !!field.isValid?.required,
14018 customValidity: getCustomValidity(isValid2, validity),
14019 label,
14020 value,
14021 help: description,
14022 placeholder,
14023 options: elements,
14024 onChange: onChangeControl,
14025 hideLabelFromVision,
14026 allowReset: true,
14027 expandOnFocus: true
14028 }
14029 );
14030 }
14031
14032 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14033 var import_components30 = __toESM(require_components(), 1);
14034 var import_element45 = __toESM(require_element(), 1);
14035 var import_i18n32 = __toESM(require_i18n(), 1);
14036 var import_date3 = __toESM(require_date(), 1);
14037
14038 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
14039 var import_components29 = __toESM(require_components(), 1);
14040 var import_element43 = __toESM(require_element(), 1);
14041 var import_i18n31 = __toESM(require_i18n(), 1);
14042 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
14043 var TIME_UNITS_OPTIONS = {
14044 [OPERATOR_IN_THE_PAST]: [
14045 { value: "days", label: (0, import_i18n31.__)("Days") },
14046 { value: "weeks", label: (0, import_i18n31.__)("Weeks") },
14047 { value: "months", label: (0, import_i18n31.__)("Months") },
14048 { value: "years", label: (0, import_i18n31.__)("Years") }
14049 ],
14050 [OPERATOR_OVER]: [
14051 { value: "days", label: (0, import_i18n31.__)("Days ago") },
14052 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") },
14053 { value: "months", label: (0, import_i18n31.__)("Months ago") },
14054 { value: "years", label: (0, import_i18n31.__)("Years ago") }
14055 ]
14056 };
14057 function RelativeDateControl({
14058 className,
14059 data,
14060 field,
14061 onChange,
14062 hideLabelFromVision,
14063 operator
14064 }) {
14065 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
14066 const { id, label, description, getValue, setValue } = field;
14067 const disabled = field.isDisabled({ item: data, field });
14068 const fieldValue = getValue({ item: data });
14069 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
14070 const onChangeValue = (0, import_element43.useCallback)(
14071 (newValue) => onChange(
14072 setValue({
14073 item: data,
14074 value: { value: Number(newValue), unit }
14075 })
14076 ),
14077 [onChange, setValue, data, unit]
14078 );
14079 const onChangeUnit = (0, import_element43.useCallback)(
14080 (newUnit) => onChange(
14081 setValue({
14082 item: data,
14083 value: { value: relValue, unit: newUnit }
14084 })
14085 ),
14086 [onChange, setValue, data, relValue]
14087 );
14088 return /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14089 import_components29.BaseControl,
14090 {
14091 id,
14092 className: clsx_default(className, "dataviews-controls__relative-date"),
14093 label,
14094 hideLabelFromVision,
14095 help: description,
14096 children: /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(Stack, { direction: "row", gap: "sm", children: [
14097 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14098 import_components29.__experimentalNumberControl,
14099 {
14100 __next40pxDefaultSize: true,
14101 className: "dataviews-controls__relative-date-number",
14102 spinControls: "none",
14103 min: 1,
14104 step: 1,
14105 value: relValue,
14106 onChange: onChangeValue,
14107 disabled
14108 }
14109 ),
14110 /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
14111 import_components29.SelectControl,
14112 {
14113 className: "dataviews-controls__relative-date-unit",
14114 __next40pxDefaultSize: true,
14115 label: (0, import_i18n31.__)("Unit"),
14116 value: unit,
14117 options,
14118 onChange: onChangeUnit,
14119 hideLabelFromVision: true,
14120 disabled
14121 }
14122 )
14123 ] })
14124 }
14125 );
14126 }
14127
14128 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
14129 var import_element44 = __toESM(require_element(), 1);
14130 function useDisabledDateMatchers(isValid2, parseDateFn) {
14131 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
14132 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
14133 const disabledMatchers = (0, import_element44.useMemo)(() => {
14134 const matchers = [];
14135 if (minConstraint) {
14136 const minDate = parseDateFn(minConstraint);
14137 if (minDate) {
14138 matchers.push({ before: minDate });
14139 }
14140 }
14141 if (maxConstraint) {
14142 const maxDate = parseDateFn(maxConstraint);
14143 if (maxDate) {
14144 matchers.push({ after: maxDate });
14145 }
14146 }
14147 return matchers.length > 0 ? matchers : void 0;
14148 }, [minConstraint, maxConstraint, parseDateFn]);
14149 return { minConstraint, maxConstraint, disabledMatchers };
14150 }
14151
14152 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
14153 var import_date2 = __toESM(require_date(), 1);
14154 function parseDateTime(dateTimeString) {
14155 if (!dateTimeString) {
14156 return null;
14157 }
14158 const parsed = (0, import_date2.getDate)(dateTimeString);
14159 return parsed && isValid(parsed) ? parsed : null;
14160 }
14161
14162 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
14163 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
14164 var { DateCalendar, ValidatedInputControl } = unlock2(import_components30.privateApis);
14165 var formatDateTime = (value) => {
14166 if (!value) {
14167 return "";
14168 }
14169 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
14170 };
14171 function CalendarDateTimeControl({
14172 data,
14173 field,
14174 onChange,
14175 hideLabelFromVision,
14176 markWhenOptional,
14177 validity,
14178 config
14179 }) {
14180 const { compact } = config || {};
14181 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
14182 const disabled = field.isDisabled({ item: data, field });
14183 const fieldValue = getValue({ item: data });
14184 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14185 const [calendarMonth, setCalendarMonth] = (0, import_element45.useState)(() => {
14186 const parsedDate = parseDateTime(value);
14187 return parsedDate || /* @__PURE__ */ new Date();
14188 });
14189 const inputControlRef = (0, import_element45.useRef)(null);
14190 const validationTimeoutRef = (0, import_element45.useRef)(void 0);
14191 const previousFocusRef = (0, import_element45.useRef)(null);
14192 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
14193 const onChangeCallback = (0, import_element45.useCallback)(
14194 (newValue) => onChange(setValue({ item: data, value: newValue })),
14195 [data, onChange, setValue]
14196 );
14197 (0, import_element45.useEffect)(() => {
14198 return () => {
14199 if (validationTimeoutRef.current) {
14200 clearTimeout(validationTimeoutRef.current);
14201 }
14202 };
14203 }, []);
14204 const onSelectDate = (0, import_element45.useCallback)(
14205 (newDate) => {
14206 let dateTimeValue;
14207 if (newDate) {
14208 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
14209 let wpTime;
14210 if (value) {
14211 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
14212 } else {
14213 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
14214 }
14215 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
14216 dateTimeValue = finalDateTime.toISOString();
14217 onChangeCallback(dateTimeValue);
14218 if (validationTimeoutRef.current) {
14219 clearTimeout(validationTimeoutRef.current);
14220 }
14221 } else {
14222 onChangeCallback(void 0);
14223 }
14224 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
14225 validationTimeoutRef.current = setTimeout(() => {
14226 if (inputControlRef.current) {
14227 inputControlRef.current.focus();
14228 inputControlRef.current.blur();
14229 onChangeCallback(dateTimeValue);
14230 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
14231 previousFocusRef.current.focus();
14232 }
14233 }
14234 }, 0);
14235 },
14236 [onChangeCallback, value]
14237 );
14238 const handleManualDateTimeChange = (0, import_element45.useCallback)(
14239 (newValue) => {
14240 if (newValue) {
14241 const dateTime = (0, import_date3.getDate)(newValue);
14242 onChangeCallback(dateTime.toISOString());
14243 const parsedDate = parseDateTime(dateTime.toISOString());
14244 if (parsedDate) {
14245 setCalendarMonth(parsedDate);
14246 }
14247 } else {
14248 onChangeCallback(void 0);
14249 }
14250 },
14251 [onChangeCallback]
14252 );
14253 const { format: fieldFormat } = field;
14254 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
14255 const {
14256 timezone: { string: timezoneString }
14257 } = (0, import_date3.getSettings)();
14258 let displayLabel = label;
14259 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
14260 displayLabel = `${label} (${(0, import_i18n32.__)("Required")})`;
14261 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
14262 displayLabel = `${label} (${(0, import_i18n32.__)("Optional")})`;
14263 }
14264 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14265 import_components30.BaseControl,
14266 {
14267 id,
14268 label: displayLabel,
14269 help: description,
14270 hideLabelFromVision,
14271 children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14272 /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14273 ValidatedInputControl,
14274 {
14275 ref: inputControlRef,
14276 __next40pxDefaultSize: true,
14277 required: !!isValid2?.required,
14278 customValidity: getCustomValidity(isValid2, validity),
14279 type: "datetime-local",
14280 label: (0, import_i18n32.__)("Date time"),
14281 hideLabelFromVision: true,
14282 value: formatDateTime(value),
14283 onChange: handleManualDateTimeChange,
14284 disabled,
14285 min: minConstraint ? formatDateTime(minConstraint) : void 0,
14286 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
14287 }
14288 ),
14289 !compact && /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14290 DateCalendar,
14291 {
14292 style: { width: "100%" },
14293 selected: value ? parseDateTime(value) || void 0 : void 0,
14294 onSelect: onSelectDate,
14295 month: calendarMonth,
14296 onMonthChange: setCalendarMonth,
14297 timeZone: timezoneString || void 0,
14298 weekStartsOn,
14299 disabled: disabled || disabledMatchers
14300 }
14301 )
14302 ] })
14303 }
14304 );
14305 }
14306 function DateTime({
14307 data,
14308 field,
14309 onChange,
14310 hideLabelFromVision,
14311 markWhenOptional,
14312 operator,
14313 validity,
14314 config
14315 }) {
14316 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14317 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14318 RelativeDateControl,
14319 {
14320 className: "dataviews-controls__datetime",
14321 data,
14322 field,
14323 onChange,
14324 hideLabelFromVision,
14325 operator
14326 }
14327 );
14328 }
14329 return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
14330 CalendarDateTimeControl,
14331 {
14332 data,
14333 field,
14334 onChange,
14335 hideLabelFromVision,
14336 markWhenOptional,
14337 validity,
14338 config
14339 }
14340 );
14341 }
14342
14343 // packages/dataviews/build-module/components/dataform-controls/date.mjs
14344 var import_components31 = __toESM(require_components(), 1);
14345 var import_element46 = __toESM(require_element(), 1);
14346 var import_i18n33 = __toESM(require_i18n(), 1);
14347 var import_date4 = __toESM(require_date(), 1);
14348 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
14349 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock2(import_components31.privateApis);
14350 var DATE_PRESETS = [
14351 {
14352 id: "today",
14353 label: (0, import_i18n33.__)("Today"),
14354 getValue: () => (0, import_date4.getDate)(null)
14355 },
14356 {
14357 id: "yesterday",
14358 label: (0, import_i18n33.__)("Yesterday"),
14359 getValue: () => {
14360 const today = (0, import_date4.getDate)(null);
14361 return subDays(today, 1);
14362 }
14363 },
14364 {
14365 id: "past-week",
14366 label: (0, import_i18n33.__)("Past week"),
14367 getValue: () => {
14368 const today = (0, import_date4.getDate)(null);
14369 return subDays(today, 7);
14370 }
14371 },
14372 {
14373 id: "past-month",
14374 label: (0, import_i18n33.__)("Past month"),
14375 getValue: () => {
14376 const today = (0, import_date4.getDate)(null);
14377 return subMonths(today, 1);
14378 }
14379 }
14380 ];
14381 var DATE_RANGE_PRESETS = [
14382 {
14383 id: "last-7-days",
14384 label: (0, import_i18n33.__)("Last 7 days"),
14385 getValue: () => {
14386 const today = (0, import_date4.getDate)(null);
14387 return [subDays(today, 7), today];
14388 }
14389 },
14390 {
14391 id: "last-30-days",
14392 label: (0, import_i18n33.__)("Last 30 days"),
14393 getValue: () => {
14394 const today = (0, import_date4.getDate)(null);
14395 return [subDays(today, 30), today];
14396 }
14397 },
14398 {
14399 id: "month-to-date",
14400 label: (0, import_i18n33.__)("Month to date"),
14401 getValue: () => {
14402 const today = (0, import_date4.getDate)(null);
14403 return [startOfMonth(today), today];
14404 }
14405 },
14406 {
14407 id: "last-year",
14408 label: (0, import_i18n33.__)("Last year"),
14409 getValue: () => {
14410 const today = (0, import_date4.getDate)(null);
14411 return [subYears(today, 1), today];
14412 }
14413 },
14414 {
14415 id: "year-to-date",
14416 label: (0, import_i18n33.__)("Year to date"),
14417 getValue: () => {
14418 const today = (0, import_date4.getDate)(null);
14419 return [startOfYear(today), today];
14420 }
14421 }
14422 ];
14423 var parseDate = (dateString) => {
14424 if (!dateString) {
14425 return null;
14426 }
14427 const parsed = (0, import_date4.getDate)(dateString);
14428 return parsed && isValid(parsed) ? parsed : null;
14429 };
14430 var formatDate = (date) => {
14431 if (!date) {
14432 return "";
14433 }
14434 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
14435 };
14436 function ValidatedDateControl({
14437 field,
14438 validity,
14439 inputRefs,
14440 isTouched,
14441 setIsTouched,
14442 children
14443 }) {
14444 const { isValid: isValid2 } = field;
14445 const [customValidity, setCustomValidity] = (0, import_element46.useState)(void 0);
14446 const validateRefs = (0, import_element46.useCallback)(() => {
14447 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14448 for (const ref of refs) {
14449 const input = ref.current;
14450 if (input && !input.validity.valid) {
14451 setCustomValidity({
14452 type: "invalid",
14453 message: input.validationMessage
14454 });
14455 return;
14456 }
14457 }
14458 setCustomValidity(void 0);
14459 }, [inputRefs]);
14460 (0, import_element46.useEffect)(() => {
14461 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14462 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14463 for (const ref of refs) {
14464 const input = ref.current;
14465 if (input) {
14466 input.setCustomValidity(
14467 result?.type === "invalid" && result.message ? result.message : ""
14468 );
14469 }
14470 }
14471 }, [inputRefs, isValid2, validity]);
14472 (0, import_element46.useEffect)(() => {
14473 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
14474 const handleInvalid = (event) => {
14475 event.preventDefault();
14476 setIsTouched(true);
14477 };
14478 for (const ref of refs) {
14479 ref.current?.addEventListener("invalid", handleInvalid);
14480 }
14481 return () => {
14482 for (const ref of refs) {
14483 ref.current?.removeEventListener("invalid", handleInvalid);
14484 }
14485 };
14486 }, [inputRefs, setIsTouched]);
14487 (0, import_element46.useEffect)(() => {
14488 if (!isTouched) {
14489 return;
14490 }
14491 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
14492 if (result) {
14493 setCustomValidity(result);
14494 } else {
14495 validateRefs();
14496 }
14497 }, [isTouched, isValid2, validity, validateRefs]);
14498 const onBlur = (event) => {
14499 if (isTouched) {
14500 return;
14501 }
14502 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
14503 setIsTouched(true);
14504 }
14505 };
14506 return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { onBlur, children: [
14507 children,
14508 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14509 "p",
14510 {
14511 className: clsx_default(
14512 "components-validated-control__indicator",
14513 customValidity.type === "invalid" ? "is-invalid" : void 0
14514 ),
14515 children: [
14516 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14517 import_components31.Icon,
14518 {
14519 className: "components-validated-control__indicator-icon",
14520 icon: error_default,
14521 size: 16,
14522 fill: "currentColor"
14523 }
14524 ),
14525 customValidity.message
14526 ]
14527 }
14528 ) })
14529 ] });
14530 }
14531 function CalendarDateControl({
14532 data,
14533 field,
14534 onChange,
14535 hideLabelFromVision,
14536 markWhenOptional,
14537 validity
14538 }) {
14539 const {
14540 id,
14541 label,
14542 description,
14543 setValue,
14544 getValue,
14545 isValid: isValid2,
14546 format: fieldFormat
14547 } = field;
14548 const disabled = field.isDisabled({ item: data, field });
14549 const [selectedPresetId, setSelectedPresetId] = (0, import_element46.useState)(
14550 null
14551 );
14552 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14553 const fieldValue = getValue({ item: data });
14554 const value = typeof fieldValue === "string" ? fieldValue : void 0;
14555 const [calendarMonth, setCalendarMonth] = (0, import_element46.useState)(() => {
14556 const parsedDate = parseDate(value);
14557 return parsedDate || /* @__PURE__ */ new Date();
14558 });
14559 const [isTouched, setIsTouched] = (0, import_element46.useState)(false);
14560 const validityTargetRef = (0, import_element46.useRef)(null);
14561 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
14562 const onChangeCallback = (0, import_element46.useCallback)(
14563 (newValue) => onChange(setValue({ item: data, value: newValue })),
14564 [data, onChange, setValue]
14565 );
14566 const onSelectDate = (0, import_element46.useCallback)(
14567 (newDate) => {
14568 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
14569 onChangeCallback(dateValue);
14570 setSelectedPresetId(null);
14571 setIsTouched(true);
14572 },
14573 [onChangeCallback]
14574 );
14575 const handlePresetClick = (0, import_element46.useCallback)(
14576 (preset) => {
14577 const presetDate = preset.getValue();
14578 const dateValue = formatDate(presetDate);
14579 setCalendarMonth(presetDate);
14580 onChangeCallback(dateValue);
14581 setSelectedPresetId(preset.id);
14582 setIsTouched(true);
14583 },
14584 [onChangeCallback]
14585 );
14586 const handleManualDateChange = (0, import_element46.useCallback)(
14587 (newValue) => {
14588 onChangeCallback(newValue);
14589 if (newValue) {
14590 const parsedDate = parseDate(newValue);
14591 if (parsedDate) {
14592 setCalendarMonth(parsedDate);
14593 }
14594 }
14595 setSelectedPresetId(null);
14596 setIsTouched(true);
14597 },
14598 [onChangeCallback]
14599 );
14600 const {
14601 timezone: { string: timezoneString }
14602 } = (0, import_date4.getSettings)();
14603 let displayLabel = label;
14604 if (isValid2?.required && !markWhenOptional) {
14605 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
14606 } else if (!isValid2?.required && markWhenOptional) {
14607 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
14608 }
14609 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14610 ValidatedDateControl,
14611 {
14612 field,
14613 validity,
14614 inputRefs: validityTargetRef,
14615 isTouched,
14616 setIsTouched,
14617 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14618 import_components31.BaseControl,
14619 {
14620 id,
14621 className: "dataviews-controls__date",
14622 label: displayLabel,
14623 help: description,
14624 hideLabelFromVision,
14625 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14626 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14627 Stack,
14628 {
14629 direction: "row",
14630 gap: "sm",
14631 wrap: "wrap",
14632 justify: "flex-start",
14633 children: [
14634 DATE_PRESETS.map((preset) => {
14635 const isSelected2 = selectedPresetId === preset.id;
14636 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14637 import_components31.Button,
14638 {
14639 className: "dataviews-controls__date-preset",
14640 variant: "tertiary",
14641 isPressed: isSelected2,
14642 size: "small",
14643 disabled,
14644 accessibleWhenDisabled: true,
14645 onClick: () => handlePresetClick(preset),
14646 children: preset.label
14647 },
14648 preset.id
14649 );
14650 }),
14651 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14652 import_components31.Button,
14653 {
14654 className: "dataviews-controls__date-preset",
14655 variant: "tertiary",
14656 isPressed: !selectedPresetId,
14657 size: "small",
14658 disabled: !!selectedPresetId || disabled,
14659 accessibleWhenDisabled: true,
14660 children: (0, import_i18n33.__)("Custom")
14661 }
14662 )
14663 ]
14664 }
14665 ),
14666 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14667 import_components31.__experimentalInputControl,
14668 {
14669 __next40pxDefaultSize: true,
14670 ref: validityTargetRef,
14671 type: "date",
14672 label: (0, import_i18n33.__)("Date"),
14673 hideLabelFromVision: true,
14674 value,
14675 onChange: handleManualDateChange,
14676 required: !!field.isValid?.required,
14677 disabled,
14678 min: minConstraint,
14679 max: maxConstraint
14680 }
14681 ),
14682 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14683 DateCalendar2,
14684 {
14685 style: { width: "100%" },
14686 selected: value ? parseDate(value) || void 0 : void 0,
14687 onSelect: onSelectDate,
14688 month: calendarMonth,
14689 onMonthChange: setCalendarMonth,
14690 timeZone: timezoneString || void 0,
14691 weekStartsOn,
14692 disabled: disabled || disabledMatchers,
14693 disableNavigation: disabled
14694 }
14695 )
14696 ] })
14697 }
14698 )
14699 }
14700 );
14701 }
14702 function CalendarDateRangeControl({
14703 data,
14704 field,
14705 onChange,
14706 hideLabelFromVision,
14707 markWhenOptional,
14708 validity
14709 }) {
14710 const {
14711 id,
14712 label,
14713 description,
14714 getValue,
14715 setValue,
14716 isValid: isValid2,
14717 format: fieldFormat
14718 } = field;
14719 const disabled = field.isDisabled({ item: data, field });
14720 let value;
14721 const fieldValue = getValue({ item: data });
14722 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
14723 value = fieldValue;
14724 }
14725 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
14726 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
14727 const onChangeCallback = (0, import_element46.useCallback)(
14728 (newValue) => {
14729 onChange(
14730 setValue({
14731 item: data,
14732 value: newValue
14733 })
14734 );
14735 },
14736 [data, onChange, setValue]
14737 );
14738 const [selectedPresetId, setSelectedPresetId] = (0, import_element46.useState)(
14739 null
14740 );
14741 const selectedRange = (0, import_element46.useMemo)(() => {
14742 if (!value) {
14743 return { from: void 0, to: void 0 };
14744 }
14745 const [from, to] = value;
14746 return {
14747 from: parseDate(from) || void 0,
14748 to: parseDate(to) || void 0
14749 };
14750 }, [value]);
14751 const [calendarMonth, setCalendarMonth] = (0, import_element46.useState)(() => {
14752 return selectedRange.from || /* @__PURE__ */ new Date();
14753 });
14754 const [isTouched, setIsTouched] = (0, import_element46.useState)(false);
14755 const fromInputRef = (0, import_element46.useRef)(null);
14756 const toInputRef = (0, import_element46.useRef)(null);
14757 const updateDateRange = (0, import_element46.useCallback)(
14758 (fromDate, toDate2) => {
14759 if (fromDate && toDate2) {
14760 onChangeCallback([
14761 formatDate(fromDate),
14762 formatDate(toDate2)
14763 ]);
14764 } else if (!fromDate && !toDate2) {
14765 onChangeCallback(void 0);
14766 }
14767 },
14768 [onChangeCallback]
14769 );
14770 const onSelectCalendarRange = (0, import_element46.useCallback)(
14771 (newRange) => {
14772 updateDateRange(newRange?.from, newRange?.to);
14773 setSelectedPresetId(null);
14774 setIsTouched(true);
14775 },
14776 [updateDateRange]
14777 );
14778 const handlePresetClick = (0, import_element46.useCallback)(
14779 (preset) => {
14780 const [startDate, endDate] = preset.getValue();
14781 setCalendarMonth(startDate);
14782 updateDateRange(startDate, endDate);
14783 setSelectedPresetId(preset.id);
14784 setIsTouched(true);
14785 },
14786 [updateDateRange]
14787 );
14788 const handleManualDateChange = (0, import_element46.useCallback)(
14789 (fromOrTo, newValue) => {
14790 const [currentFrom, currentTo] = value || [
14791 void 0,
14792 void 0
14793 ];
14794 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
14795 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
14796 updateDateRange(updatedFrom, updatedTo);
14797 if (newValue) {
14798 const parsedDate = parseDate(newValue);
14799 if (parsedDate) {
14800 setCalendarMonth(parsedDate);
14801 }
14802 }
14803 setSelectedPresetId(null);
14804 setIsTouched(true);
14805 },
14806 [value, updateDateRange]
14807 );
14808 const { timezone } = (0, import_date4.getSettings)();
14809 let displayLabel = label;
14810 if (field.isValid?.required && !markWhenOptional) {
14811 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
14812 } else if (!field.isValid?.required && markWhenOptional) {
14813 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
14814 }
14815 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14816 ValidatedDateControl,
14817 {
14818 field,
14819 validity,
14820 inputRefs: [fromInputRef, toInputRef],
14821 isTouched,
14822 setIsTouched,
14823 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14824 import_components31.BaseControl,
14825 {
14826 id,
14827 className: "dataviews-controls__date",
14828 label: displayLabel,
14829 help: description,
14830 hideLabelFromVision,
14831 children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(Stack, { direction: "column", gap: "lg", children: [
14832 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14833 Stack,
14834 {
14835 direction: "row",
14836 gap: "sm",
14837 wrap: "wrap",
14838 justify: "flex-start",
14839 children: [
14840 DATE_RANGE_PRESETS.map((preset) => {
14841 const isSelected2 = selectedPresetId === preset.id;
14842 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14843 import_components31.Button,
14844 {
14845 className: "dataviews-controls__date-preset",
14846 variant: "tertiary",
14847 isPressed: isSelected2,
14848 size: "small",
14849 disabled,
14850 accessibleWhenDisabled: true,
14851 onClick: () => handlePresetClick(preset),
14852 children: preset.label
14853 },
14854 preset.id
14855 );
14856 }),
14857 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14858 import_components31.Button,
14859 {
14860 className: "dataviews-controls__date-preset",
14861 variant: "tertiary",
14862 isPressed: !selectedPresetId,
14863 size: "small",
14864 accessibleWhenDisabled: true,
14865 disabled: !!selectedPresetId || disabled,
14866 children: (0, import_i18n33.__)("Custom")
14867 }
14868 )
14869 ]
14870 }
14871 ),
14872 /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
14873 Stack,
14874 {
14875 direction: "row",
14876 gap: "sm",
14877 justify: "space-between",
14878 className: "dataviews-controls__date-range-inputs",
14879 children: [
14880 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14881 import_components31.__experimentalInputControl,
14882 {
14883 __next40pxDefaultSize: true,
14884 ref: fromInputRef,
14885 type: "date",
14886 label: (0, import_i18n33.__)("From"),
14887 hideLabelFromVision: true,
14888 value: value?.[0],
14889 onChange: (newValue) => handleManualDateChange("from", newValue),
14890 required: !!field.isValid?.required,
14891 disabled,
14892 min: minConstraint,
14893 max: maxConstraint
14894 }
14895 ),
14896 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14897 import_components31.__experimentalInputControl,
14898 {
14899 __next40pxDefaultSize: true,
14900 ref: toInputRef,
14901 type: "date",
14902 label: (0, import_i18n33.__)("To"),
14903 hideLabelFromVision: true,
14904 value: value?.[1],
14905 onChange: (newValue) => handleManualDateChange("to", newValue),
14906 required: !!field.isValid?.required,
14907 disabled,
14908 min: minConstraint,
14909 max: maxConstraint
14910 }
14911 )
14912 ]
14913 }
14914 ),
14915 /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14916 DateRangeCalendar,
14917 {
14918 style: { width: "100%" },
14919 selected: selectedRange,
14920 onSelect: onSelectCalendarRange,
14921 month: calendarMonth,
14922 onMonthChange: setCalendarMonth,
14923 timeZone: timezone.string || void 0,
14924 weekStartsOn,
14925 disabled: disabled || disabledMatchers
14926 }
14927 )
14928 ] })
14929 }
14930 )
14931 }
14932 );
14933 }
14934 function DateControl({
14935 data,
14936 field,
14937 onChange,
14938 hideLabelFromVision,
14939 markWhenOptional,
14940 operator,
14941 validity
14942 }) {
14943 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
14944 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14945 RelativeDateControl,
14946 {
14947 className: "dataviews-controls__date",
14948 data,
14949 field,
14950 onChange,
14951 hideLabelFromVision,
14952 operator
14953 }
14954 );
14955 }
14956 if (operator === OPERATOR_BETWEEN) {
14957 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14958 CalendarDateRangeControl,
14959 {
14960 data,
14961 field,
14962 onChange,
14963 hideLabelFromVision,
14964 markWhenOptional,
14965 validity
14966 }
14967 );
14968 }
14969 return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
14970 CalendarDateControl,
14971 {
14972 data,
14973 field,
14974 onChange,
14975 hideLabelFromVision,
14976 markWhenOptional,
14977 validity
14978 }
14979 );
14980 }
14981
14982 // packages/dataviews/build-module/components/dataform-controls/select.mjs
14983 var import_components32 = __toESM(require_components(), 1);
14984 var import_element47 = __toESM(require_element(), 1);
14985 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
14986 var { ValidatedSelectControl } = unlock2(import_components32.privateApis);
14987 function Select({
14988 data,
14989 field,
14990 onChange,
14991 hideLabelFromVision,
14992 markWhenOptional,
14993 validity
14994 }) {
14995 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
14996 const disabled = field.isDisabled({ item: data, field });
14997 const isMultiple = type === "array";
14998 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
14999 const onChangeControl = (0, import_element47.useCallback)(
15000 (newValue) => onChange(setValue({ item: data, value: newValue })),
15001 [data, onChange, setValue]
15002 );
15003 const { elements, isLoading } = useElements({
15004 elements: field.elements,
15005 getElements: field.getElements
15006 });
15007 if (isLoading) {
15008 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_components32.Spinner, {});
15009 }
15010 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
15011 ValidatedSelectControl,
15012 {
15013 required: !!field.isValid?.required,
15014 markWhenOptional,
15015 customValidity: getCustomValidity(isValid2, validity),
15016 label,
15017 value,
15018 help: description,
15019 options: elements,
15020 onChange: onChangeControl,
15021 __next40pxDefaultSize: true,
15022 hideLabelFromVision,
15023 multiple: isMultiple,
15024 disabled
15025 }
15026 );
15027 }
15028
15029 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
15030 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
15031 var ELEMENTS_THRESHOLD = 10;
15032 function AdaptiveSelect(props) {
15033 const { field } = props;
15034 const { elements } = useElements({
15035 elements: field.elements,
15036 getElements: field.getElements
15037 });
15038 if (elements.length >= ELEMENTS_THRESHOLD) {
15039 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Combobox3, { ...props });
15040 }
15041 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Select, { ...props });
15042 }
15043
15044 // packages/dataviews/build-module/components/dataform-controls/email.mjs
15045 var import_components34 = __toESM(require_components(), 1);
15046
15047 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
15048 var import_components33 = __toESM(require_components(), 1);
15049 var import_element48 = __toESM(require_element(), 1);
15050 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
15051 var { ValidatedInputControl: ValidatedInputControl2 } = unlock2(import_components33.privateApis);
15052 function ValidatedText({
15053 data,
15054 field,
15055 onChange,
15056 hideLabelFromVision,
15057 markWhenOptional,
15058 type,
15059 prefix,
15060 suffix,
15061 validity
15062 }) {
15063 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
15064 const value = getValue({ item: data });
15065 const disabled = field.isDisabled({ item: data, field });
15066 const onChangeControl = (0, import_element48.useCallback)(
15067 (newValue) => onChange(
15068 setValue({
15069 item: data,
15070 value: newValue
15071 })
15072 ),
15073 [data, setValue, onChange]
15074 );
15075 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
15076 ValidatedInputControl2,
15077 {
15078 required: !!isValid2.required,
15079 markWhenOptional,
15080 customValidity: getCustomValidity(isValid2, validity),
15081 label,
15082 placeholder,
15083 value: value ?? "",
15084 help: description,
15085 onChange: onChangeControl,
15086 hideLabelFromVision,
15087 type,
15088 prefix,
15089 suffix,
15090 disabled,
15091 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
15092 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15093 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15094 __next40pxDefaultSize: true
15095 }
15096 );
15097 }
15098
15099 // packages/dataviews/build-module/components/dataform-controls/email.mjs
15100 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15101 function Email({
15102 data,
15103 field,
15104 onChange,
15105 hideLabelFromVision,
15106 markWhenOptional,
15107 validity
15108 }) {
15109 return /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(
15110 ValidatedText,
15111 {
15112 ...{
15113 data,
15114 field,
15115 onChange,
15116 hideLabelFromVision,
15117 markWhenOptional,
15118 validity,
15119 type: "email",
15120 prefix: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components34.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_components34.Icon, { icon: envelope_default }) })
15121 }
15122 }
15123 );
15124 }
15125
15126 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
15127 var import_components35 = __toESM(require_components(), 1);
15128 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15129 function Telephone({
15130 data,
15131 field,
15132 onChange,
15133 hideLabelFromVision,
15134 markWhenOptional,
15135 validity
15136 }) {
15137 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15138 ValidatedText,
15139 {
15140 ...{
15141 data,
15142 field,
15143 onChange,
15144 hideLabelFromVision,
15145 markWhenOptional,
15146 validity,
15147 type: "tel",
15148 prefix: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components35.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components35.Icon, { icon: mobile_default }) })
15149 }
15150 }
15151 );
15152 }
15153
15154 // packages/dataviews/build-module/components/dataform-controls/url.mjs
15155 var import_components36 = __toESM(require_components(), 1);
15156 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15157 function Url({
15158 data,
15159 field,
15160 onChange,
15161 hideLabelFromVision,
15162 markWhenOptional,
15163 validity
15164 }) {
15165 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15166 ValidatedText,
15167 {
15168 ...{
15169 data,
15170 field,
15171 onChange,
15172 hideLabelFromVision,
15173 markWhenOptional,
15174 validity,
15175 type: "url",
15176 prefix: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_components36.Icon, { icon: link_default }) })
15177 }
15178 }
15179 );
15180 }
15181
15182 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
15183 var import_components37 = __toESM(require_components(), 1);
15184 var import_element49 = __toESM(require_element(), 1);
15185 var import_i18n34 = __toESM(require_i18n(), 1);
15186 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15187 var { ValidatedNumberControl } = unlock2(import_components37.privateApis);
15188 function toNumberOrEmpty(value) {
15189 if (value === "" || value === void 0) {
15190 return "";
15191 }
15192 const number = Number(value);
15193 return Number.isFinite(number) ? number : "";
15194 }
15195 function BetweenControls({
15196 value,
15197 onChange,
15198 hideLabelFromVision,
15199 step
15200 }) {
15201 const [min = "", max = ""] = value;
15202 const onChangeMin = (0, import_element49.useCallback)(
15203 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
15204 [onChange, max]
15205 );
15206 const onChangeMax = (0, import_element49.useCallback)(
15207 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
15208 [onChange, min]
15209 );
15210 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15211 import_components37.BaseControl,
15212 {
15213 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."),
15214 children: /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)(import_components37.Flex, { direction: "row", gap: 4, children: [
15215 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15216 import_components37.__experimentalNumberControl,
15217 {
15218 label: (0, import_i18n34.__)("Min."),
15219 value: min,
15220 max: max ? Number(max) - step : void 0,
15221 onChange: onChangeMin,
15222 __next40pxDefaultSize: true,
15223 hideLabelFromVision,
15224 step
15225 }
15226 ),
15227 /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15228 import_components37.__experimentalNumberControl,
15229 {
15230 label: (0, import_i18n34.__)("Max."),
15231 value: max,
15232 min: min ? Number(min) + step : void 0,
15233 onChange: onChangeMax,
15234 __next40pxDefaultSize: true,
15235 hideLabelFromVision,
15236 step
15237 }
15238 )
15239 ] })
15240 }
15241 );
15242 }
15243 function ValidatedNumber({
15244 data,
15245 field,
15246 onChange,
15247 hideLabelFromVision,
15248 markWhenOptional,
15249 operator,
15250 validity
15251 }) {
15252 const decimals = field.format?.decimals ?? 0;
15253 const step = Math.pow(10, Math.abs(decimals) * -1);
15254 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15255 const value = getValue({ item: data }) ?? "";
15256 const disabled = field.isDisabled({ item: data, field });
15257 const onChangeControl = (0, import_element49.useCallback)(
15258 (newValue) => {
15259 onChange(
15260 setValue({
15261 item: data,
15262 // Do not convert an empty string or undefined to a number,
15263 // otherwise there's a mismatch between the UI control (empty)
15264 // and the data relied by onChange (0).
15265 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
15266 })
15267 );
15268 },
15269 [data, onChange, setValue]
15270 );
15271 const onChangeBetweenControls = (0, import_element49.useCallback)(
15272 (newValue) => {
15273 onChange(
15274 setValue({
15275 item: data,
15276 value: newValue
15277 })
15278 );
15279 },
15280 [data, onChange, setValue]
15281 );
15282 if (operator === OPERATOR_BETWEEN) {
15283 let valueBetween = ["", ""];
15284 if (Array.isArray(value) && value.length === 2 && value.every(
15285 (element) => typeof element === "number" || element === ""
15286 )) {
15287 valueBetween = value;
15288 }
15289 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15290 BetweenControls,
15291 {
15292 value: valueBetween,
15293 onChange: onChangeBetweenControls,
15294 hideLabelFromVision,
15295 step
15296 }
15297 );
15298 }
15299 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15300 ValidatedNumberControl,
15301 {
15302 required: !!isValid2.required,
15303 markWhenOptional,
15304 customValidity: getCustomValidity(isValid2, validity),
15305 label,
15306 help: description,
15307 value,
15308 onChange: onChangeControl,
15309 __next40pxDefaultSize: true,
15310 hideLabelFromVision,
15311 step,
15312 min: isValid2.min ? isValid2.min.constraint : void 0,
15313 max: isValid2.max ? isValid2.max.constraint : void 0,
15314 disabled
15315 }
15316 );
15317 }
15318
15319 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
15320 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15321 function Integer(props) {
15322 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(ValidatedNumber, { ...props });
15323 }
15324
15325 // packages/dataviews/build-module/components/dataform-controls/number.mjs
15326 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15327 function Number2(props) {
15328 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(ValidatedNumber, { ...props });
15329 }
15330
15331 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
15332 var import_components38 = __toESM(require_components(), 1);
15333 var import_element50 = __toESM(require_element(), 1);
15334 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15335 var { ValidatedRadioControl } = unlock2(import_components38.privateApis);
15336 function Radio({
15337 data,
15338 field,
15339 onChange,
15340 hideLabelFromVision,
15341 markWhenOptional,
15342 validity
15343 }) {
15344 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15345 const disabled = field.isDisabled({ item: data, field });
15346 const { elements, isLoading } = useElements({
15347 elements: field.elements,
15348 getElements: field.getElements
15349 });
15350 const value = getValue({ item: data });
15351 const onChangeControl = (0, import_element50.useCallback)(
15352 (newValue) => onChange(setValue({ item: data, value: newValue })),
15353 [data, onChange, setValue]
15354 );
15355 if (isLoading) {
15356 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_components38.Spinner, {});
15357 }
15358 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
15359 ValidatedRadioControl,
15360 {
15361 required: !!field.isValid?.required,
15362 markWhenOptional,
15363 customValidity: getCustomValidity(isValid2, validity),
15364 label,
15365 help: description,
15366 onChange: onChangeControl,
15367 options: elements,
15368 selected: value,
15369 hideLabelFromVision,
15370 disabled
15371 }
15372 );
15373 }
15374
15375 // packages/dataviews/build-module/components/dataform-controls/text.mjs
15376 var import_element51 = __toESM(require_element(), 1);
15377 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15378 function Text3({
15379 data,
15380 field,
15381 onChange,
15382 hideLabelFromVision,
15383 markWhenOptional,
15384 config,
15385 validity
15386 }) {
15387 const { prefix, suffix } = config || {};
15388 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15389 ValidatedText,
15390 {
15391 ...{
15392 data,
15393 field,
15394 onChange,
15395 hideLabelFromVision,
15396 markWhenOptional,
15397 validity,
15398 prefix: prefix ? (0, import_element51.createElement)(prefix) : void 0,
15399 suffix: suffix ? (0, import_element51.createElement)(suffix) : void 0
15400 }
15401 }
15402 );
15403 }
15404
15405 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
15406 var import_components39 = __toESM(require_components(), 1);
15407 var import_element52 = __toESM(require_element(), 1);
15408 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15409 var { ValidatedToggleControl } = unlock2(import_components39.privateApis);
15410 function Toggle({
15411 field,
15412 onChange,
15413 data,
15414 hideLabelFromVision,
15415 markWhenOptional,
15416 validity
15417 }) {
15418 const { label, description, getValue, setValue, isValid: isValid2 } = field;
15419 const disabled = field.isDisabled({ item: data, field });
15420 const onChangeControl = (0, import_element52.useCallback)(() => {
15421 onChange(
15422 setValue({ item: data, value: !getValue({ item: data }) })
15423 );
15424 }, [onChange, setValue, data, getValue]);
15425 return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15426 ValidatedToggleControl,
15427 {
15428 required: !!isValid2.required,
15429 markWhenOptional,
15430 customValidity: getCustomValidity(isValid2, validity),
15431 hidden: hideLabelFromVision,
15432 label,
15433 help: description,
15434 checked: getValue({ item: data }),
15435 onChange: onChangeControl,
15436 disabled
15437 }
15438 );
15439 }
15440
15441 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
15442 var import_components40 = __toESM(require_components(), 1);
15443 var import_element53 = __toESM(require_element(), 1);
15444 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15445 var { ValidatedTextareaControl } = unlock2(import_components40.privateApis);
15446 function Textarea({
15447 data,
15448 field,
15449 onChange,
15450 hideLabelFromVision,
15451 markWhenOptional,
15452 config,
15453 validity
15454 }) {
15455 const { rows = 4 } = config || {};
15456 const disabled = field.isDisabled({ item: data, field });
15457 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15458 const value = field.getValue({ item: data });
15459 const onChangeControl = (0, import_element53.useCallback)(
15460 (newValue) => onChange(setValue({ item: data, value: newValue })),
15461 [data, onChange, setValue]
15462 );
15463 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
15464 ValidatedTextareaControl,
15465 {
15466 required: !!isValid2.required,
15467 markWhenOptional,
15468 customValidity: getCustomValidity(isValid2, validity),
15469 label,
15470 placeholder,
15471 value: value ?? "",
15472 help: description,
15473 onChange: onChangeControl,
15474 rows,
15475 disabled,
15476 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
15477 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
15478 __next40pxDefaultSize: true,
15479 hideLabelFromVision
15480 }
15481 );
15482 }
15483
15484 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
15485 var import_components41 = __toESM(require_components(), 1);
15486 var import_element54 = __toESM(require_element(), 1);
15487 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15488 var { ValidatedToggleGroupControl } = unlock2(import_components41.privateApis);
15489 function ToggleGroup({
15490 data,
15491 field,
15492 onChange,
15493 hideLabelFromVision,
15494 markWhenOptional,
15495 validity
15496 }) {
15497 const { getValue, setValue, isValid: isValid2 } = field;
15498 const disabled = field.isDisabled({ item: data, field });
15499 const value = getValue({ item: data });
15500 const onChangeControl = (0, import_element54.useCallback)(
15501 (newValue) => onChange(setValue({ item: data, value: newValue })),
15502 [data, onChange, setValue]
15503 );
15504 const { elements, isLoading } = useElements({
15505 elements: field.elements,
15506 getElements: field.getElements
15507 });
15508 if (isLoading) {
15509 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_components41.Spinner, {});
15510 }
15511 if (elements.length === 0) {
15512 return null;
15513 }
15514 const selectedOption = elements.find((el) => el.value === value);
15515 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15516 ValidatedToggleGroupControl,
15517 {
15518 required: !!field.isValid?.required,
15519 markWhenOptional,
15520 customValidity: getCustomValidity(isValid2, validity),
15521 __next40pxDefaultSize: true,
15522 isBlock: true,
15523 label: field.label,
15524 help: selectedOption?.description || field.description,
15525 onChange: onChangeControl,
15526 value,
15527 hideLabelFromVision,
15528 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15529 import_components41.__experimentalToggleGroupControlOption,
15530 {
15531 label: el.label,
15532 value: el.value,
15533 disabled
15534 },
15535 el.value
15536 ))
15537 }
15538 );
15539 }
15540
15541 // packages/dataviews/build-module/components/dataform-controls/array.mjs
15542 var import_components42 = __toESM(require_components(), 1);
15543 var import_element55 = __toESM(require_element(), 1);
15544 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15545 var { ValidatedFormTokenField } = unlock2(import_components42.privateApis);
15546 function ArrayControl({
15547 data,
15548 field,
15549 onChange,
15550 hideLabelFromVision,
15551 markWhenOptional,
15552 validity
15553 }) {
15554 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
15555 const value = getValue({ item: data });
15556 const disabled = field.isDisabled({ item: data, field });
15557 const { elements, isLoading } = useElements({
15558 elements: field.elements,
15559 getElements: field.getElements
15560 });
15561 const arrayValueAsElements = (0, import_element55.useMemo)(
15562 () => Array.isArray(value) ? value.map((token) => {
15563 const element = elements?.find(
15564 (suggestion) => suggestion.value === token
15565 );
15566 return element || { value: token, label: token };
15567 }) : [],
15568 [value, elements]
15569 );
15570 const onChangeControl = (0, import_element55.useCallback)(
15571 (tokens) => {
15572 const valueTokens = tokens.map((token) => {
15573 if (typeof token === "object" && "value" in token) {
15574 return token.value;
15575 }
15576 return token;
15577 });
15578 onChange(setValue({ item: data, value: valueTokens }));
15579 },
15580 [onChange, setValue, data]
15581 );
15582 if (isLoading) {
15583 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_components42.Spinner, {});
15584 }
15585 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15586 ValidatedFormTokenField,
15587 {
15588 required: !!isValid2?.required,
15589 markWhenOptional,
15590 customValidity: getCustomValidity(isValid2, validity),
15591 label: hideLabelFromVision ? void 0 : label,
15592 value: arrayValueAsElements,
15593 onChange: onChangeControl,
15594 placeholder,
15595 suggestions: elements?.map((element) => element.value),
15596 disabled,
15597 __experimentalValidateInput: (token) => {
15598 if (field.isValid?.elements && elements) {
15599 return elements.some(
15600 (element) => element.value === token || element.label === token
15601 );
15602 }
15603 return true;
15604 },
15605 __experimentalExpandOnFocus: elements && elements.length > 0,
15606 help: description ?? (field.isValid?.elements ? "" : void 0),
15607 displayTransform: (token) => {
15608 if (typeof token === "object" && "label" in token) {
15609 return token.label;
15610 }
15611 if (typeof token === "string" && elements) {
15612 const element = elements.find(
15613 (el) => el.value === token
15614 );
15615 return element?.label || token;
15616 }
15617 return token;
15618 },
15619 __experimentalRenderItem: ({ item }) => {
15620 if (typeof item === "string" && elements) {
15621 const element = elements.find(
15622 (el) => el.value === item
15623 );
15624 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { children: element?.label || item });
15625 }
15626 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("span", { children: item });
15627 }
15628 }
15629 );
15630 }
15631
15632 // node_modules/colord/index.mjs
15633 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
15634 var t = function(r3) {
15635 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
15636 };
15637 var n = function(r3, t2, n2) {
15638 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
15639 };
15640 var e = function(r3, t2, n2) {
15641 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
15642 };
15643 var u = function(r3) {
15644 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
15645 };
15646 var a = function(r3) {
15647 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
15648 };
15649 var o = function(r3) {
15650 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
15651 };
15652 var i = /^#([0-9a-f]{3,8})$/i;
15653 var s = function(r3) {
15654 var t2 = r3.toString(16);
15655 return t2.length < 2 ? "0" + t2 : t2;
15656 };
15657 var h = function(r3) {
15658 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;
15659 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
15660 };
15661 var b = function(r3) {
15662 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
15663 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
15664 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;
15665 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 };
15666 };
15667 var g = function(r3) {
15668 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
15669 };
15670 var d = function(r3) {
15671 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
15672 };
15673 var f = function(r3) {
15674 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 }));
15675 var t2, n2, e2;
15676 };
15677 var c = function(r3) {
15678 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 };
15679 var t2, n2, e2, u2;
15680 };
15681 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15682 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15683 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15684 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
15685 var y = { string: [[function(r3) {
15686 var t2 = i.exec(r3);
15687 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;
15688 }, "hex"], [function(r3) {
15689 var t2 = v.exec(r3) || m.exec(r3);
15690 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;
15691 }, "rgb"], [function(t2) {
15692 var n2 = l.exec(t2) || p.exec(t2);
15693 if (!n2) return null;
15694 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) });
15695 return f(a2);
15696 }, "hsl"]], object: [[function(r3) {
15697 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
15698 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
15699 }, "rgb"], [function(r3) {
15700 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
15701 if (!t(n2) || !t(e2) || !t(u2)) return null;
15702 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
15703 return f(i2);
15704 }, "hsl"], [function(r3) {
15705 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
15706 if (!t(n2) || !t(a2) || !t(o2)) return null;
15707 var h2 = (function(r4) {
15708 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
15709 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
15710 return b(h2);
15711 }, "hsv"]] };
15712 var N = function(r3, t2) {
15713 for (var n2 = 0; n2 < t2.length; n2++) {
15714 var e2 = t2[n2][0](r3);
15715 if (e2) return [e2, t2[n2][1]];
15716 }
15717 return [null, void 0];
15718 };
15719 var x = function(r3) {
15720 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
15721 };
15722 var M = function(r3, t2) {
15723 var n2 = c(r3);
15724 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
15725 };
15726 var H = function(r3) {
15727 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
15728 };
15729 var $ = function(r3, t2) {
15730 var n2 = c(r3);
15731 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
15732 };
15733 var j = (function() {
15734 function r3(r4) {
15735 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
15736 }
15737 return r3.prototype.isValid = function() {
15738 return null !== this.parsed;
15739 }, r3.prototype.brightness = function() {
15740 return n(H(this.rgba), 2);
15741 }, r3.prototype.isDark = function() {
15742 return H(this.rgba) < 0.5;
15743 }, r3.prototype.isLight = function() {
15744 return H(this.rgba) >= 0.5;
15745 }, r3.prototype.toHex = function() {
15746 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;
15747 var r4, t2, e2, u2, a2, i2;
15748 }, r3.prototype.toRgb = function() {
15749 return o(this.rgba);
15750 }, r3.prototype.toRgbString = function() {
15751 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 + ")";
15752 var r4, t2, n2, e2, u2;
15753 }, r3.prototype.toHsl = function() {
15754 return d(c(this.rgba));
15755 }, r3.prototype.toHslString = function() {
15756 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 + "%)";
15757 var r4, t2, n2, e2, u2;
15758 }, r3.prototype.toHsv = function() {
15759 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
15760 var r4;
15761 }, r3.prototype.invert = function() {
15762 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
15763 var r4;
15764 }, r3.prototype.saturate = function(r4) {
15765 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
15766 }, r3.prototype.desaturate = function(r4) {
15767 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
15768 }, r3.prototype.grayscale = function() {
15769 return w(M(this.rgba, -1));
15770 }, r3.prototype.lighten = function(r4) {
15771 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
15772 }, r3.prototype.darken = function(r4) {
15773 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
15774 }, r3.prototype.rotate = function(r4) {
15775 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
15776 }, r3.prototype.alpha = function(r4) {
15777 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
15778 var t2;
15779 }, r3.prototype.hue = function(r4) {
15780 var t2 = c(this.rgba);
15781 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
15782 }, r3.prototype.isEqual = function(r4) {
15783 return this.toHex() === w(r4).toHex();
15784 }, r3;
15785 })();
15786 var w = function(r3) {
15787 return r3 instanceof j ? r3 : new j(r3);
15788 };
15789
15790 // packages/dataviews/build-module/components/dataform-controls/color.mjs
15791 var import_components43 = __toESM(require_components(), 1);
15792 var import_element56 = __toESM(require_element(), 1);
15793 var import_i18n35 = __toESM(require_i18n(), 1);
15794 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
15795 var { ValidatedInputControl: ValidatedInputControl3 } = unlock2(import_components43.privateApis);
15796 var ColorPickerDropdown = ({
15797 color,
15798 onColorChange,
15799 disabled
15800 }) => {
15801 const validColor = color && w(color).isValid() ? color : "#ffffff";
15802 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15803 import_components43.Dropdown,
15804 {
15805 className: "dataviews-controls__color-picker-dropdown",
15806 popoverProps: { resize: false },
15807 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15808 import_components43.Button,
15809 {
15810 onClick: onToggle,
15811 "aria-label": (0, import_i18n35.__)("Open color picker"),
15812 size: "small",
15813 disabled,
15814 accessibleWhenDisabled: true,
15815 icon: () => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.ColorIndicator, { colorValue: validColor })
15816 }
15817 ),
15818 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15819 import_components43.ColorPicker,
15820 {
15821 color: validColor,
15822 onChange: onColorChange,
15823 enableAlpha: true
15824 }
15825 ) })
15826 }
15827 );
15828 };
15829 function Color({
15830 data,
15831 field,
15832 onChange,
15833 hideLabelFromVision,
15834 markWhenOptional,
15835 validity
15836 }) {
15837 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
15838 const disabled = field.isDisabled({ item: data, field });
15839 const value = field.getValue({ item: data }) || "";
15840 const handleColorChange = (0, import_element56.useCallback)(
15841 (newColor) => {
15842 onChange(setValue({ item: data, value: newColor }));
15843 },
15844 [data, onChange, setValue]
15845 );
15846 const handleInputChange = (0, import_element56.useCallback)(
15847 (newValue) => {
15848 onChange(setValue({ item: data, value: newValue || "" }));
15849 },
15850 [data, onChange, setValue]
15851 );
15852 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15853 ValidatedInputControl3,
15854 {
15855 required: !!field.isValid?.required,
15856 markWhenOptional,
15857 customValidity: getCustomValidity(isValid2, validity),
15858 label,
15859 placeholder,
15860 value,
15861 help: description,
15862 onChange: handleInputChange,
15863 hideLabelFromVision,
15864 type: "text",
15865 disabled,
15866 prefix: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components43.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15867 ColorPickerDropdown,
15868 {
15869 color: value,
15870 onColorChange: handleColorChange,
15871 disabled
15872 }
15873 ) })
15874 }
15875 );
15876 }
15877
15878 // packages/dataviews/build-module/components/dataform-controls/password.mjs
15879 var import_components44 = __toESM(require_components(), 1);
15880 var import_element57 = __toESM(require_element(), 1);
15881 var import_i18n36 = __toESM(require_i18n(), 1);
15882 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
15883 function Password({
15884 data,
15885 field,
15886 onChange,
15887 hideLabelFromVision,
15888 markWhenOptional,
15889 validity
15890 }) {
15891 const [isVisible2, setIsVisible] = (0, import_element57.useState)(false);
15892 const disabled = field.isDisabled({ item: data, field });
15893 const toggleVisibility = (0, import_element57.useCallback)(() => {
15894 setIsVisible((prev) => !prev);
15895 }, []);
15896 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15897 ValidatedText,
15898 {
15899 ...{
15900 data,
15901 field,
15902 onChange,
15903 hideLabelFromVision,
15904 markWhenOptional,
15905 validity,
15906 type: isVisible2 ? "text" : "password",
15907 suffix: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_components44.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15908 import_components44.Button,
15909 {
15910 icon: isVisible2 ? unseen_default : seen_default,
15911 onClick: toggleVisibility,
15912 size: "small",
15913 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"),
15914 disabled,
15915 accessibleWhenDisabled: true
15916 }
15917 ) })
15918 }
15919 }
15920 );
15921 }
15922
15923 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
15924 function hasElements(field) {
15925 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
15926 }
15927
15928 // packages/dataviews/build-module/components/dataform-controls/index.mjs
15929 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
15930 var FORM_CONTROLS = {
15931 adaptiveSelect: AdaptiveSelect,
15932 array: ArrayControl,
15933 checkbox: Checkbox,
15934 color: Color,
15935 combobox: Combobox3,
15936 datetime: DateTime,
15937 date: DateControl,
15938 email: Email,
15939 telephone: Telephone,
15940 url: Url,
15941 integer: Integer,
15942 number: Number2,
15943 password: Password,
15944 radio: Radio,
15945 select: Select,
15946 text: Text3,
15947 toggle: Toggle,
15948 textarea: Textarea,
15949 toggleGroup: ToggleGroup
15950 };
15951 function isEditConfig(value) {
15952 return value && typeof value === "object" && typeof value.control === "string";
15953 }
15954 function createConfiguredControl(config) {
15955 const { control, ...controlConfig } = config;
15956 const BaseControlType = getControlByType(control);
15957 if (BaseControlType === null) {
15958 return null;
15959 }
15960 return function ConfiguredControl(props) {
15961 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(BaseControlType, { ...props, config: controlConfig });
15962 };
15963 }
15964 function getControl(field, fallback) {
15965 if (typeof field.Edit === "function") {
15966 return field.Edit;
15967 }
15968 if (typeof field.Edit === "string") {
15969 return getControlByType(field.Edit);
15970 }
15971 if (isEditConfig(field.Edit)) {
15972 return createConfiguredControl(field.Edit);
15973 }
15974 if (hasElements(field) && field.type !== "array") {
15975 return getControlByType("adaptiveSelect");
15976 }
15977 if (fallback === null) {
15978 return null;
15979 }
15980 return getControlByType(fallback);
15981 }
15982 function getControlByType(type) {
15983 if (Object.keys(FORM_CONTROLS).includes(type)) {
15984 return FORM_CONTROLS[type];
15985 }
15986 return null;
15987 }
15988
15989 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
15990 function getFilterBy(field, defaultOperators, validOperators) {
15991 if (field.filterBy === false) {
15992 return false;
15993 }
15994 const operators = field.filterBy?.operators?.filter(
15995 (op) => validOperators.includes(op)
15996 ) ?? defaultOperators;
15997 if (operators.length === 0) {
15998 return false;
15999 }
16000 return {
16001 isPrimary: !!field.filterBy?.isPrimary,
16002 operators
16003 };
16004 }
16005 var get_filter_by_default = getFilterBy;
16006
16007 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
16008 var getValueFromId = (id) => ({ item }) => {
16009 const path = id.split(".");
16010 let value = item;
16011 for (const segment of path) {
16012 if (value.hasOwnProperty(segment)) {
16013 value = value[segment];
16014 } else {
16015 value = void 0;
16016 }
16017 }
16018 return value;
16019 };
16020 var get_value_from_id_default = getValueFromId;
16021
16022 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
16023 var setValueFromId = (id) => ({ value }) => {
16024 const path = id.split(".");
16025 const result = {};
16026 let current = result;
16027 for (const segment of path.slice(0, -1)) {
16028 current[segment] = {};
16029 current = current[segment];
16030 }
16031 current[path.at(-1)] = value;
16032 return result;
16033 };
16034 var set_value_from_id_default = setValueFromId;
16035
16036 // packages/dataviews/build-module/field-types/email.mjs
16037 var import_i18n37 = __toESM(require_i18n(), 1);
16038
16039 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
16040 function RenderFromElements({
16041 item,
16042 field
16043 }) {
16044 const { elements, isLoading } = useElements({
16045 elements: field.elements,
16046 getElements: field.getElements
16047 });
16048 const value = field.getValue({ item });
16049 if (isLoading) {
16050 return value;
16051 }
16052 if (elements.length === 0) {
16053 return value;
16054 }
16055 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
16056 }
16057
16058 // packages/dataviews/build-module/field-types/utils/render-default.mjs
16059 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16060 function render({
16061 item,
16062 field
16063 }) {
16064 if (field.hasElements) {
16065 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(RenderFromElements, { item, field });
16066 }
16067 return field.getValueFormatted({ item, field });
16068 }
16069
16070 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
16071 var sort_text_default = (a2, b2, direction) => {
16072 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
16073 };
16074
16075 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
16076 function isValidRequired(item, field) {
16077 const value = field.getValue({ item });
16078 return ![void 0, "", null].includes(value);
16079 }
16080
16081 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
16082 function isValidMinLength(item, field) {
16083 if (typeof field.isValid.minLength?.constraint !== "number") {
16084 return false;
16085 }
16086 const value = field.getValue({ item });
16087 if ([void 0, "", null].includes(value)) {
16088 return true;
16089 }
16090 return String(value).length >= field.isValid.minLength.constraint;
16091 }
16092
16093 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
16094 function isValidMaxLength(item, field) {
16095 if (typeof field.isValid.maxLength?.constraint !== "number") {
16096 return false;
16097 }
16098 const value = field.getValue({ item });
16099 if ([void 0, "", null].includes(value)) {
16100 return true;
16101 }
16102 return String(value).length <= field.isValid.maxLength.constraint;
16103 }
16104
16105 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
16106 function isValidPattern(item, field) {
16107 if (field.isValid.pattern?.constraint === void 0) {
16108 return true;
16109 }
16110 try {
16111 const regexp = new RegExp(field.isValid.pattern.constraint);
16112 const value = field.getValue({ item });
16113 if ([void 0, "", null].includes(value)) {
16114 return true;
16115 }
16116 return regexp.test(String(value));
16117 } catch {
16118 return false;
16119 }
16120 }
16121
16122 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
16123 function isValidElements(item, field) {
16124 const elements = field.elements ?? [];
16125 const validValues = elements.map((el) => el.value);
16126 if (validValues.length === 0) {
16127 return true;
16128 }
16129 const value = field.getValue({ item });
16130 return [].concat(value).every((v2) => validValues.includes(v2));
16131 }
16132
16133 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
16134 function getValueFormatted({
16135 item,
16136 field
16137 }) {
16138 return field.getValue({ item });
16139 }
16140 var get_value_formatted_default_default = getValueFormatted;
16141
16142 // packages/dataviews/build-module/field-types/email.mjs
16143 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])?)*$/;
16144 function isValidCustom(item, field) {
16145 const value = field.getValue({ item });
16146 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
16147 return (0, import_i18n37.__)("Value must be a valid email address.");
16148 }
16149 return null;
16150 }
16151 var email_default = {
16152 type: "email",
16153 render,
16154 Edit: "email",
16155 sort: sort_text_default,
16156 enableSorting: true,
16157 enableGlobalSearch: false,
16158 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16159 validOperators: [
16160 OPERATOR_IS,
16161 OPERATOR_IS_NOT,
16162 OPERATOR_CONTAINS,
16163 OPERATOR_NOT_CONTAINS,
16164 OPERATOR_STARTS_WITH,
16165 // Multiple selection
16166 OPERATOR_IS_ANY,
16167 OPERATOR_IS_NONE,
16168 OPERATOR_IS_ALL,
16169 OPERATOR_IS_NOT_ALL
16170 ],
16171 format: {},
16172 getValueFormatted: get_value_formatted_default_default,
16173 validate: {
16174 required: isValidRequired,
16175 pattern: isValidPattern,
16176 minLength: isValidMinLength,
16177 maxLength: isValidMaxLength,
16178 elements: isValidElements,
16179 custom: isValidCustom
16180 }
16181 };
16182
16183 // packages/dataviews/build-module/field-types/integer.mjs
16184 var import_i18n38 = __toESM(require_i18n(), 1);
16185
16186 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
16187 var sort_number_default = (a2, b2, direction) => {
16188 return direction === "asc" ? a2 - b2 : b2 - a2;
16189 };
16190
16191 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
16192 function isValidMin(item, field) {
16193 if (typeof field.isValid.min?.constraint !== "number") {
16194 return false;
16195 }
16196 const value = field.getValue({ item });
16197 if ([void 0, "", null].includes(value)) {
16198 return true;
16199 }
16200 return Number(value) >= field.isValid.min.constraint;
16201 }
16202
16203 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
16204 function isValidMax(item, field) {
16205 if (typeof field.isValid.max?.constraint !== "number") {
16206 return false;
16207 }
16208 const value = field.getValue({ item });
16209 if ([void 0, "", null].includes(value)) {
16210 return true;
16211 }
16212 return Number(value) <= field.isValid.max.constraint;
16213 }
16214
16215 // packages/dataviews/build-module/field-types/integer.mjs
16216 var format2 = {
16217 separatorThousand: ","
16218 };
16219 function getValueFormatted2({
16220 item,
16221 field
16222 }) {
16223 let value = field.getValue({ item });
16224 if (value === null || value === void 0) {
16225 return "";
16226 }
16227 value = Number(value);
16228 if (!Number.isFinite(value)) {
16229 return String(value);
16230 }
16231 let formatInteger;
16232 if (field.type !== "integer") {
16233 formatInteger = format2;
16234 } else {
16235 formatInteger = field.format;
16236 }
16237 const { separatorThousand } = formatInteger;
16238 const integerValue = Math.trunc(value);
16239 if (!separatorThousand) {
16240 return String(integerValue);
16241 }
16242 return String(integerValue).replace(
16243 /\B(?=(\d{3})+(?!\d))/g,
16244 separatorThousand
16245 );
16246 }
16247 function isValidCustom2(item, field) {
16248 const value = field.getValue({ item });
16249 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
16250 return (0, import_i18n38.__)("Value must be an integer.");
16251 }
16252 return null;
16253 }
16254 var integer_default = {
16255 type: "integer",
16256 render,
16257 Edit: "integer",
16258 sort: sort_number_default,
16259 enableSorting: true,
16260 enableGlobalSearch: false,
16261 defaultOperators: [
16262 OPERATOR_IS,
16263 OPERATOR_IS_NOT,
16264 OPERATOR_LESS_THAN,
16265 OPERATOR_GREATER_THAN,
16266 OPERATOR_LESS_THAN_OR_EQUAL,
16267 OPERATOR_GREATER_THAN_OR_EQUAL,
16268 OPERATOR_BETWEEN
16269 ],
16270 validOperators: [
16271 // Single-selection
16272 OPERATOR_IS,
16273 OPERATOR_IS_NOT,
16274 OPERATOR_LESS_THAN,
16275 OPERATOR_GREATER_THAN,
16276 OPERATOR_LESS_THAN_OR_EQUAL,
16277 OPERATOR_GREATER_THAN_OR_EQUAL,
16278 OPERATOR_BETWEEN,
16279 // Multiple-selection
16280 OPERATOR_IS_ANY,
16281 OPERATOR_IS_NONE,
16282 OPERATOR_IS_ALL,
16283 OPERATOR_IS_NOT_ALL
16284 ],
16285 format: format2,
16286 getValueFormatted: getValueFormatted2,
16287 validate: {
16288 required: isValidRequired,
16289 min: isValidMin,
16290 max: isValidMax,
16291 elements: isValidElements,
16292 custom: isValidCustom2
16293 }
16294 };
16295
16296 // packages/dataviews/build-module/field-types/number.mjs
16297 var import_i18n39 = __toESM(require_i18n(), 1);
16298 var format3 = {
16299 separatorThousand: ",",
16300 separatorDecimal: ".",
16301 decimals: 2
16302 };
16303 function getValueFormatted3({
16304 item,
16305 field
16306 }) {
16307 let value = field.getValue({ item });
16308 if (value === null || value === void 0) {
16309 return "";
16310 }
16311 value = Number(value);
16312 if (!Number.isFinite(value)) {
16313 return String(value);
16314 }
16315 let formatNumber;
16316 if (field.type !== "number") {
16317 formatNumber = format3;
16318 } else {
16319 formatNumber = field.format;
16320 }
16321 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
16322 const fixedValue = value.toFixed(decimals);
16323 const [integerPart, decimalPart] = fixedValue.split(".");
16324 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
16325 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
16326 }
16327 function isEmpty2(value) {
16328 return value === "" || value === void 0 || value === null;
16329 }
16330 function isValidCustom3(item, field) {
16331 const value = field.getValue({ item });
16332 if (!isEmpty2(value) && !Number.isFinite(value)) {
16333 return (0, import_i18n39.__)("Value must be a number.");
16334 }
16335 return null;
16336 }
16337 var number_default = {
16338 type: "number",
16339 render,
16340 Edit: "number",
16341 sort: sort_number_default,
16342 enableSorting: true,
16343 enableGlobalSearch: false,
16344 defaultOperators: [
16345 OPERATOR_IS,
16346 OPERATOR_IS_NOT,
16347 OPERATOR_LESS_THAN,
16348 OPERATOR_GREATER_THAN,
16349 OPERATOR_LESS_THAN_OR_EQUAL,
16350 OPERATOR_GREATER_THAN_OR_EQUAL,
16351 OPERATOR_BETWEEN
16352 ],
16353 validOperators: [
16354 // Single-selection
16355 OPERATOR_IS,
16356 OPERATOR_IS_NOT,
16357 OPERATOR_LESS_THAN,
16358 OPERATOR_GREATER_THAN,
16359 OPERATOR_LESS_THAN_OR_EQUAL,
16360 OPERATOR_GREATER_THAN_OR_EQUAL,
16361 OPERATOR_BETWEEN,
16362 // Multiple-selection
16363 OPERATOR_IS_ANY,
16364 OPERATOR_IS_NONE,
16365 OPERATOR_IS_ALL,
16366 OPERATOR_IS_NOT_ALL
16367 ],
16368 format: format3,
16369 getValueFormatted: getValueFormatted3,
16370 validate: {
16371 required: isValidRequired,
16372 min: isValidMin,
16373 max: isValidMax,
16374 elements: isValidElements,
16375 custom: isValidCustom3
16376 }
16377 };
16378
16379 // packages/dataviews/build-module/field-types/text.mjs
16380 var text_default = {
16381 type: "text",
16382 render,
16383 Edit: "text",
16384 sort: sort_text_default,
16385 enableSorting: true,
16386 enableGlobalSearch: false,
16387 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16388 validOperators: [
16389 // Single selection
16390 OPERATOR_IS,
16391 OPERATOR_IS_NOT,
16392 OPERATOR_CONTAINS,
16393 OPERATOR_NOT_CONTAINS,
16394 OPERATOR_STARTS_WITH,
16395 // Multiple selection
16396 OPERATOR_IS_ANY,
16397 OPERATOR_IS_NONE,
16398 OPERATOR_IS_ALL,
16399 OPERATOR_IS_NOT_ALL
16400 ],
16401 format: {},
16402 getValueFormatted: get_value_formatted_default_default,
16403 validate: {
16404 required: isValidRequired,
16405 pattern: isValidPattern,
16406 minLength: isValidMinLength,
16407 maxLength: isValidMaxLength,
16408 elements: isValidElements
16409 }
16410 };
16411
16412 // packages/dataviews/build-module/field-types/datetime.mjs
16413 var import_date7 = __toESM(require_date(), 1);
16414
16415 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
16416 var import_date6 = __toESM(require_date(), 1);
16417 function parseDateLike(value) {
16418 if (!value) {
16419 return null;
16420 }
16421 if (!isValid(new Date(value))) {
16422 return null;
16423 }
16424 const parsed = (0, import_date6.getDate)(value);
16425 return parsed && isValid(parsed) ? parsed : null;
16426 }
16427 function validateDateLikeBoundary(item, field, boundary) {
16428 const constraint = field.isValid[boundary]?.constraint;
16429 if (typeof constraint !== "string") {
16430 return false;
16431 }
16432 const value = field.getValue({ item });
16433 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
16434 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
16435 return true;
16436 }
16437 const parsedConstraint = parseDateLike(constraint);
16438 const parsedValue = parseDateLike(String(boundaryValue));
16439 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
16440 }
16441 function isValidMinDate(item, field) {
16442 return validateDateLikeBoundary(item, field, "min");
16443 }
16444 function isValidMaxDate(item, field) {
16445 return validateDateLikeBoundary(item, field, "max");
16446 }
16447
16448 // packages/dataviews/build-module/field-types/datetime.mjs
16449 var format4 = {
16450 datetime: (0, import_date7.getSettings)().formats.datetime,
16451 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
16452 };
16453 function getValueFormatted4({
16454 item,
16455 field
16456 }) {
16457 const value = field.getValue({ item });
16458 if (["", void 0, null].includes(value)) {
16459 return "";
16460 }
16461 let formatDatetime;
16462 if (field.type !== "datetime") {
16463 formatDatetime = format4;
16464 } else {
16465 formatDatetime = field.format;
16466 }
16467 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
16468 }
16469 var sort = (a2, b2, direction) => {
16470 const timeA = new Date(a2).getTime();
16471 const timeB = new Date(b2).getTime();
16472 return direction === "asc" ? timeA - timeB : timeB - timeA;
16473 };
16474 var datetime_default = {
16475 type: "datetime",
16476 render,
16477 Edit: "datetime",
16478 sort,
16479 enableSorting: true,
16480 enableGlobalSearch: false,
16481 defaultOperators: [
16482 OPERATOR_ON,
16483 OPERATOR_NOT_ON,
16484 OPERATOR_BEFORE,
16485 OPERATOR_AFTER,
16486 OPERATOR_BEFORE_INC,
16487 OPERATOR_AFTER_INC,
16488 OPERATOR_IN_THE_PAST,
16489 OPERATOR_OVER
16490 ],
16491 validOperators: [
16492 OPERATOR_ON,
16493 OPERATOR_NOT_ON,
16494 OPERATOR_BEFORE,
16495 OPERATOR_AFTER,
16496 OPERATOR_BEFORE_INC,
16497 OPERATOR_AFTER_INC,
16498 OPERATOR_IN_THE_PAST,
16499 OPERATOR_OVER
16500 ],
16501 format: format4,
16502 getValueFormatted: getValueFormatted4,
16503 validate: {
16504 required: isValidRequired,
16505 elements: isValidElements,
16506 min: isValidMinDate,
16507 max: isValidMaxDate
16508 }
16509 };
16510
16511 // packages/dataviews/build-module/field-types/date.mjs
16512 var import_date8 = __toESM(require_date(), 1);
16513 var format5 = {
16514 date: (0, import_date8.getSettings)().formats.date,
16515 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
16516 };
16517 function getValueFormatted5({
16518 item,
16519 field
16520 }) {
16521 const value = field.getValue({ item });
16522 if (["", void 0, null].includes(value)) {
16523 return "";
16524 }
16525 let formatDate2;
16526 if (field.type !== "date") {
16527 formatDate2 = format5;
16528 } else {
16529 formatDate2 = field.format;
16530 }
16531 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
16532 }
16533 var sort2 = (a2, b2, direction) => {
16534 const timeA = new Date(a2).getTime();
16535 const timeB = new Date(b2).getTime();
16536 return direction === "asc" ? timeA - timeB : timeB - timeA;
16537 };
16538 var date_default = {
16539 type: "date",
16540 render,
16541 Edit: "date",
16542 sort: sort2,
16543 enableSorting: true,
16544 enableGlobalSearch: false,
16545 defaultOperators: [
16546 OPERATOR_ON,
16547 OPERATOR_NOT_ON,
16548 OPERATOR_BEFORE,
16549 OPERATOR_AFTER,
16550 OPERATOR_BEFORE_INC,
16551 OPERATOR_AFTER_INC,
16552 OPERATOR_IN_THE_PAST,
16553 OPERATOR_OVER,
16554 OPERATOR_BETWEEN
16555 ],
16556 validOperators: [
16557 OPERATOR_ON,
16558 OPERATOR_NOT_ON,
16559 OPERATOR_BEFORE,
16560 OPERATOR_AFTER,
16561 OPERATOR_BEFORE_INC,
16562 OPERATOR_AFTER_INC,
16563 OPERATOR_IN_THE_PAST,
16564 OPERATOR_OVER,
16565 OPERATOR_BETWEEN
16566 ],
16567 format: format5,
16568 getValueFormatted: getValueFormatted5,
16569 validate: {
16570 required: isValidRequired,
16571 elements: isValidElements,
16572 min: isValidMinDate,
16573 max: isValidMaxDate
16574 }
16575 };
16576
16577 // packages/dataviews/build-module/field-types/boolean.mjs
16578 var import_i18n40 = __toESM(require_i18n(), 1);
16579
16580 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
16581 function isValidRequiredForBool(item, field) {
16582 const value = field.getValue({ item });
16583 return value === true;
16584 }
16585
16586 // packages/dataviews/build-module/field-types/boolean.mjs
16587 function getValueFormatted6({
16588 item,
16589 field
16590 }) {
16591 const value = field.getValue({ item });
16592 if (value === true) {
16593 return (0, import_i18n40.__)("True");
16594 }
16595 if (value === false) {
16596 return (0, import_i18n40.__)("False");
16597 }
16598 return "";
16599 }
16600 function isValidCustom4(item, field) {
16601 const value = field.getValue({ item });
16602 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
16603 return (0, import_i18n40.__)("Value must be true, false, or undefined");
16604 }
16605 return null;
16606 }
16607 var sort3 = (a2, b2, direction) => {
16608 const boolA = Boolean(a2);
16609 const boolB = Boolean(b2);
16610 if (boolA === boolB) {
16611 return 0;
16612 }
16613 if (direction === "asc") {
16614 return boolA ? 1 : -1;
16615 }
16616 return boolA ? -1 : 1;
16617 };
16618 var boolean_default = {
16619 type: "boolean",
16620 render,
16621 Edit: "checkbox",
16622 sort: sort3,
16623 validate: {
16624 required: isValidRequiredForBool,
16625 elements: isValidElements,
16626 custom: isValidCustom4
16627 },
16628 enableSorting: true,
16629 enableGlobalSearch: false,
16630 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16631 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16632 format: {},
16633 getValueFormatted: getValueFormatted6
16634 };
16635
16636 // packages/dataviews/build-module/field-types/media.mjs
16637 var media_default = {
16638 type: "media",
16639 render: () => null,
16640 Edit: null,
16641 sort: () => 0,
16642 enableSorting: false,
16643 enableGlobalSearch: false,
16644 defaultOperators: [],
16645 validOperators: [],
16646 format: {},
16647 getValueFormatted: get_value_formatted_default_default,
16648 // cannot validate any constraint, so
16649 // the only available validation for the field author
16650 // would be providing a custom validator.
16651 validate: {}
16652 };
16653
16654 // packages/dataviews/build-module/field-types/array.mjs
16655 var import_i18n41 = __toESM(require_i18n(), 1);
16656
16657 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
16658 function isValidRequiredForArray(item, field) {
16659 const value = field.getValue({ item });
16660 return Array.isArray(value) && value.length > 0 && value.every(
16661 (element) => ![void 0, "", null].includes(element)
16662 );
16663 }
16664
16665 // packages/dataviews/build-module/field-types/array.mjs
16666 function getValueFormatted7({
16667 item,
16668 field
16669 }) {
16670 const value = field.getValue({ item });
16671 const arr = Array.isArray(value) ? value : [];
16672 return arr.join(", ");
16673 }
16674 function render2({ item, field }) {
16675 return getValueFormatted7({ item, field });
16676 }
16677 function isValidCustom5(item, field) {
16678 const value = field.getValue({ item });
16679 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
16680 return (0, import_i18n41.__)("Value must be an array.");
16681 }
16682 if (!value.every((v2) => typeof v2 === "string")) {
16683 return (0, import_i18n41.__)("Every value must be a string.");
16684 }
16685 return null;
16686 }
16687 var sort4 = (a2, b2, direction) => {
16688 const arrA = Array.isArray(a2) ? a2 : [];
16689 const arrB = Array.isArray(b2) ? b2 : [];
16690 if (arrA.length !== arrB.length) {
16691 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
16692 }
16693 const joinedA = arrA.join(",");
16694 const joinedB = arrB.join(",");
16695 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
16696 };
16697 var array_default = {
16698 type: "array",
16699 render: render2,
16700 Edit: "array",
16701 sort: sort4,
16702 enableSorting: true,
16703 enableGlobalSearch: false,
16704 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16705 validOperators: [
16706 OPERATOR_IS_ANY,
16707 OPERATOR_IS_NONE,
16708 OPERATOR_IS_ALL,
16709 OPERATOR_IS_NOT_ALL
16710 ],
16711 format: {},
16712 getValueFormatted: getValueFormatted7,
16713 validate: {
16714 required: isValidRequiredForArray,
16715 elements: isValidElements,
16716 custom: isValidCustom5
16717 }
16718 };
16719
16720 // packages/dataviews/build-module/field-types/password.mjs
16721 function getValueFormatted8({
16722 item,
16723 field
16724 }) {
16725 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
16726 }
16727 var password_default = {
16728 type: "password",
16729 render,
16730 Edit: "password",
16731 sort: () => 0,
16732 // Passwords should not be sortable for security reasons
16733 enableSorting: false,
16734 enableGlobalSearch: false,
16735 defaultOperators: [],
16736 validOperators: [],
16737 format: {},
16738 getValueFormatted: getValueFormatted8,
16739 validate: {
16740 required: isValidRequired,
16741 pattern: isValidPattern,
16742 minLength: isValidMinLength,
16743 maxLength: isValidMaxLength,
16744 elements: isValidElements
16745 }
16746 };
16747
16748 // packages/dataviews/build-module/field-types/telephone.mjs
16749 var telephone_default = {
16750 type: "telephone",
16751 render,
16752 Edit: "telephone",
16753 sort: sort_text_default,
16754 enableSorting: true,
16755 enableGlobalSearch: false,
16756 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16757 validOperators: [
16758 OPERATOR_IS,
16759 OPERATOR_IS_NOT,
16760 OPERATOR_CONTAINS,
16761 OPERATOR_NOT_CONTAINS,
16762 OPERATOR_STARTS_WITH,
16763 // Multiple selection
16764 OPERATOR_IS_ANY,
16765 OPERATOR_IS_NONE,
16766 OPERATOR_IS_ALL,
16767 OPERATOR_IS_NOT_ALL
16768 ],
16769 format: {},
16770 getValueFormatted: get_value_formatted_default_default,
16771 validate: {
16772 required: isValidRequired,
16773 pattern: isValidPattern,
16774 minLength: isValidMinLength,
16775 maxLength: isValidMaxLength,
16776 elements: isValidElements
16777 }
16778 };
16779
16780 // packages/dataviews/build-module/field-types/color.mjs
16781 var import_i18n42 = __toESM(require_i18n(), 1);
16782 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
16783 function render3({ item, field }) {
16784 if (field.hasElements) {
16785 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(RenderFromElements, { item, field });
16786 }
16787 const value = get_value_formatted_default_default({ item, field });
16788 if (!value || !w(value).isValid()) {
16789 return value;
16790 }
16791 return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
16792 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16793 "div",
16794 {
16795 style: {
16796 width: "16px",
16797 height: "16px",
16798 borderRadius: "50%",
16799 backgroundColor: value,
16800 border: "1px solid #ddd",
16801 flexShrink: 0
16802 }
16803 }
16804 ),
16805 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: value })
16806 ] });
16807 }
16808 function isValidCustom6(item, field) {
16809 const value = field.getValue({ item });
16810 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
16811 return (0, import_i18n42.__)("Value must be a valid color.");
16812 }
16813 return null;
16814 }
16815 var sort5 = (a2, b2, direction) => {
16816 const colorA = w(a2);
16817 const colorB = w(b2);
16818 if (!colorA.isValid() && !colorB.isValid()) {
16819 return 0;
16820 }
16821 if (!colorA.isValid()) {
16822 return direction === "asc" ? 1 : -1;
16823 }
16824 if (!colorB.isValid()) {
16825 return direction === "asc" ? -1 : 1;
16826 }
16827 const hslA = colorA.toHsl();
16828 const hslB = colorB.toHsl();
16829 if (hslA.h !== hslB.h) {
16830 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
16831 }
16832 if (hslA.s !== hslB.s) {
16833 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
16834 }
16835 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
16836 };
16837 var color_default = {
16838 type: "color",
16839 render: render3,
16840 Edit: "color",
16841 sort: sort5,
16842 enableSorting: true,
16843 enableGlobalSearch: false,
16844 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16845 validOperators: [
16846 OPERATOR_IS,
16847 OPERATOR_IS_NOT,
16848 OPERATOR_IS_ANY,
16849 OPERATOR_IS_NONE
16850 ],
16851 format: {},
16852 getValueFormatted: get_value_formatted_default_default,
16853 validate: {
16854 required: isValidRequired,
16855 elements: isValidElements,
16856 custom: isValidCustom6
16857 }
16858 };
16859
16860 // packages/dataviews/build-module/field-types/url.mjs
16861 var url_default = {
16862 type: "url",
16863 render,
16864 Edit: "url",
16865 sort: sort_text_default,
16866 enableSorting: true,
16867 enableGlobalSearch: false,
16868 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
16869 validOperators: [
16870 OPERATOR_IS,
16871 OPERATOR_IS_NOT,
16872 OPERATOR_CONTAINS,
16873 OPERATOR_NOT_CONTAINS,
16874 OPERATOR_STARTS_WITH,
16875 // Multiple selection
16876 OPERATOR_IS_ANY,
16877 OPERATOR_IS_NONE,
16878 OPERATOR_IS_ALL,
16879 OPERATOR_IS_NOT_ALL
16880 ],
16881 format: {},
16882 getValueFormatted: get_value_formatted_default_default,
16883 validate: {
16884 required: isValidRequired,
16885 pattern: isValidPattern,
16886 minLength: isValidMinLength,
16887 maxLength: isValidMaxLength,
16888 elements: isValidElements
16889 }
16890 };
16891
16892 // packages/dataviews/build-module/field-types/no-type.mjs
16893 var sort6 = (a2, b2, direction) => {
16894 if (typeof a2 === "number" && typeof b2 === "number") {
16895 return sort_number_default(a2, b2, direction);
16896 }
16897 return sort_text_default(a2, b2, direction);
16898 };
16899 var no_type_default = {
16900 // type: no type for this one
16901 render,
16902 Edit: null,
16903 sort: sort6,
16904 enableSorting: true,
16905 enableGlobalSearch: false,
16906 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
16907 validOperators: getAllOperatorNames(),
16908 format: {},
16909 getValueFormatted: get_value_formatted_default_default,
16910 validate: {
16911 required: isValidRequired,
16912 elements: isValidElements
16913 }
16914 };
16915
16916 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
16917 function supportsNumericRangeConstraint(type) {
16918 return type === "integer" || type === "number";
16919 }
16920 function supportsDateRangeConstraint(type) {
16921 return type === "date" || type === "datetime";
16922 }
16923 function normalizeRangeRule(value, fieldType, key) {
16924 const validator = fieldType.validate[key];
16925 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
16926 return { constraint: value, validate: validator };
16927 }
16928 return void 0;
16929 }
16930 function getIsValid(field, fieldType) {
16931 const rules = field.isValid;
16932 let required;
16933 if (rules?.required === true && fieldType.validate.required !== void 0) {
16934 required = {
16935 constraint: true,
16936 validate: fieldType.validate.required
16937 };
16938 }
16939 let elements;
16940 if ((rules?.elements === true || // elements is enabled unless the field opts-out
16941 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
16942 elements = {
16943 constraint: true,
16944 validate: fieldType.validate.elements
16945 };
16946 }
16947 const min = normalizeRangeRule(rules?.min, fieldType, "min");
16948 const max = normalizeRangeRule(rules?.max, fieldType, "max");
16949 const minLengthValue = rules?.minLength;
16950 let minLength;
16951 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
16952 minLength = {
16953 constraint: minLengthValue,
16954 validate: fieldType.validate.minLength
16955 };
16956 }
16957 const maxLengthValue = rules?.maxLength;
16958 let maxLength;
16959 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
16960 maxLength = {
16961 constraint: maxLengthValue,
16962 validate: fieldType.validate.maxLength
16963 };
16964 }
16965 const patternValue = rules?.pattern;
16966 let pattern;
16967 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
16968 pattern = {
16969 constraint: patternValue,
16970 validate: fieldType.validate.pattern
16971 };
16972 }
16973 const custom = rules?.custom ?? fieldType.validate.custom;
16974 return {
16975 required,
16976 elements,
16977 min,
16978 max,
16979 minLength,
16980 maxLength,
16981 pattern,
16982 custom
16983 };
16984 }
16985
16986 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
16987 function getFilter(fieldType) {
16988 return fieldType.validOperators.reduce((accumulator, operator) => {
16989 const operatorObj = getOperatorByName(operator);
16990 if (operatorObj?.filter) {
16991 accumulator[operator] = operatorObj.filter;
16992 }
16993 return accumulator;
16994 }, {});
16995 }
16996
16997 // packages/dataviews/build-module/field-types/utils/get-format.mjs
16998 function getFormat(field, fieldType) {
16999 return {
17000 ...fieldType.format,
17001 ...field.format
17002 };
17003 }
17004 var get_format_default = getFormat;
17005
17006 // packages/dataviews/build-module/field-types/index.mjs
17007 function getFieldTypeByName(type) {
17008 const found = [
17009 email_default,
17010 integer_default,
17011 number_default,
17012 text_default,
17013 datetime_default,
17014 date_default,
17015 boolean_default,
17016 media_default,
17017 array_default,
17018 password_default,
17019 telephone_default,
17020 color_default,
17021 url_default
17022 ].find((fieldType) => fieldType?.type === type);
17023 if (!!found) {
17024 return found;
17025 }
17026 return no_type_default;
17027 }
17028 function normalizeFields(fields) {
17029 return fields.map((field) => {
17030 const fieldType = getFieldTypeByName(field.type);
17031 const getValue = field.getValue || get_value_from_id_default(field.id);
17032 const sort7 = function(a2, b2, direction) {
17033 const aValue = getValue({ item: a2 });
17034 const bValue = getValue({ item: b2 });
17035 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
17036 };
17037 return {
17038 id: field.id,
17039 label: field.label || field.id,
17040 header: field.header || field.label || field.id,
17041 description: field.description,
17042 placeholder: field.placeholder,
17043 getValue,
17044 setValue: field.setValue || set_value_from_id_default(field.id),
17045 elements: field.elements,
17046 getElements: field.getElements,
17047 hasElements: hasElements(field),
17048 isVisible: field.isVisible,
17049 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
17050 enableHiding: field.enableHiding ?? true,
17051 readOnly: field.readOnly ?? false,
17052 // The type provides defaults for the following props
17053 type: fieldType.type,
17054 render: field.render ?? fieldType.render,
17055 Edit: getControl(field, fieldType.Edit),
17056 sort: sort7,
17057 enableSorting: field.enableSorting ?? fieldType.enableSorting,
17058 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
17059 isValid: getIsValid(field, fieldType),
17060 filterBy: get_filter_by_default(
17061 field,
17062 fieldType.defaultOperators,
17063 fieldType.validOperators
17064 ),
17065 filter: getFilter(fieldType),
17066 format: get_format_default(field, fieldType),
17067 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
17068 };
17069 });
17070 }
17071
17072 // packages/dataviews/build-module/hooks/use-data.mjs
17073 var import_element58 = __toESM(require_element(), 1);
17074 function useData({
17075 view,
17076 data: shownData,
17077 getItemId,
17078 isLoading,
17079 paginationInfo,
17080 selection
17081 }) {
17082 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
17083 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element58.useState)(
17084 !isLoading
17085 );
17086 (0, import_element58.useEffect)(() => {
17087 if (!isLoading) {
17088 setHasInitiallyLoaded(true);
17089 }
17090 }, [isLoading]);
17091 const previousDataRef = (0, import_element58.useRef)(shownData);
17092 const previousPaginationInfoRef = (0, import_element58.useRef)(paginationInfo);
17093 (0, import_element58.useEffect)(() => {
17094 if (!isLoading) {
17095 previousDataRef.current = shownData;
17096 previousPaginationInfoRef.current = paginationInfo;
17097 }
17098 }, [shownData, isLoading, paginationInfo]);
17099 const [visibleEntries, setVisibleEntries] = (0, import_element58.useState)([]);
17100 const positionMapRef = (0, import_element58.useRef)(/* @__PURE__ */ new Map());
17101 const allLoadedRecordsRef = (0, import_element58.useRef)([]);
17102 const prevViewParamsRef = (0, import_element58.useRef)({
17103 search: void 0,
17104 filters: void 0,
17105 perPage: void 0
17106 });
17107 const scrollDirectionRef = (0, import_element58.useRef)(void 0);
17108 const prevStartPositionRef = (0, import_element58.useRef)(void 0);
17109 const hasInitializedRef = (0, import_element58.useRef)(false);
17110 const allLoadedRecords = (0, import_element58.useMemo)(() => {
17111 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
17112 if (view.startPosition < prevStartPositionRef.current) {
17113 scrollDirectionRef.current = "up";
17114 } else if (view.startPosition > prevStartPositionRef.current) {
17115 scrollDirectionRef.current = "down";
17116 }
17117 }
17118 prevStartPositionRef.current = view.startPosition;
17119 const currentFiltersKey = JSON.stringify(view.filters ?? []);
17120 const prevFiltersKey = prevViewParamsRef.current.filters;
17121 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
17122 hasInitializedRef.current = true;
17123 prevViewParamsRef.current = {
17124 search: view.search,
17125 filters: currentFiltersKey,
17126 perPage: view.perPage
17127 };
17128 if (shouldReset) {
17129 positionMapRef.current.clear();
17130 scrollDirectionRef.current = void 0;
17131 const startPosition = view.search ? 1 : view.startPosition ?? 1;
17132 const records = shownData.map((record, index) => {
17133 const position = startPosition + index;
17134 positionMapRef.current.set(getItemId(record), position);
17135 return {
17136 ...record,
17137 position
17138 };
17139 });
17140 allLoadedRecordsRef.current = records;
17141 return records;
17142 }
17143 const prev = allLoadedRecordsRef.current;
17144 const shownDataIds = new Set(shownData.map(getItemId));
17145 const scrollDirection = scrollDirectionRef.current;
17146 const basePosition = view.search ? 1 : view.startPosition ?? 1;
17147 const newRecords = shownData.map((record, index) => {
17148 const itemId = getItemId(record);
17149 const position = view.infiniteScrollEnabled ? basePosition + index : void 0;
17150 if (position !== void 0) {
17151 positionMapRef.current.set(itemId, position);
17152 }
17153 return {
17154 ...record,
17155 position
17156 };
17157 });
17158 if (newRecords.length === 0) {
17159 return prev;
17160 }
17161 const prevWithoutDuplicates = prev.filter(
17162 (record) => !shownDataIds.has(getItemId(record))
17163 );
17164 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
17165 allRecords.sort((a2, b2) => {
17166 const posA = a2.position;
17167 const posB = b2.position;
17168 return posA - posB;
17169 });
17170 let result = allRecords;
17171 if (visibleEntries.length > 0) {
17172 const visibleMin = Math.min(...visibleEntries);
17173 const visibleMax = Math.max(...visibleEntries);
17174 const buffer = 20;
17175 const recordPositions = allRecords.map(
17176 (r3) => r3.position
17177 );
17178 const minRecordPos = Math.min(...recordPositions);
17179 const maxRecordPos = Math.max(...recordPositions);
17180 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
17181 if (hasOverlap) {
17182 result = allRecords.filter((record) => {
17183 const itemId = getItemId(record);
17184 const isSelected2 = selection?.includes(itemId);
17185 if (isSelected2) {
17186 return true;
17187 }
17188 const itemPosition = record.position;
17189 if (scrollDirection === "up") {
17190 return itemPosition <= visibleMax + buffer;
17191 } else if (scrollDirection === "down") {
17192 return itemPosition >= visibleMin - buffer;
17193 }
17194 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
17195 });
17196 }
17197 }
17198 allLoadedRecordsRef.current = result;
17199 return result;
17200 }, [
17201 shownData,
17202 view.search,
17203 view.filters,
17204 view.perPage,
17205 view.startPosition,
17206 view.infiniteScrollEnabled,
17207 visibleEntries,
17208 selection,
17209 getItemId
17210 ]);
17211 if (!isInfiniteScrollEnabled) {
17212 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
17213 return {
17214 data: dataToReturn.map((item) => ({
17215 ...item,
17216 position: void 0
17217 })),
17218 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
17219 hasInitiallyLoaded,
17220 setVisibleEntries: void 0
17221 };
17222 }
17223 return {
17224 data: allLoadedRecords,
17225 paginationInfo,
17226 hasInitiallyLoaded,
17227 setVisibleEntries
17228 };
17229 }
17230
17231 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
17232 var import_element59 = __toESM(require_element(), 1);
17233 var import_compose11 = __toESM(require_compose(), 1);
17234 function captureAnchorElement(container, anchorElementRef, direction) {
17235 const containerRect = container.getBoundingClientRect();
17236 const centerY = containerRect.top + containerRect.height / 2;
17237 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
17238 if (items.length === 0) {
17239 return false;
17240 }
17241 const bestAnchor = items.reduce((best, item) => {
17242 const itemRect = item.getBoundingClientRect();
17243 const itemCenterY = itemRect.top + itemRect.height / 2;
17244 const distance = Math.abs(itemCenterY - centerY);
17245 const bestRect = best.getBoundingClientRect();
17246 const bestCenterY = bestRect.top + bestRect.height / 2;
17247 const bestDistance = Math.abs(bestCenterY - centerY);
17248 return distance < bestDistance ? item : best;
17249 });
17250 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
17251 const anchorRect = bestAnchor.getBoundingClientRect();
17252 anchorElementRef.current = {
17253 posinset,
17254 viewportOffset: anchorRect.top - containerRect.top,
17255 direction
17256 };
17257 return true;
17258 }
17259 function useInfiniteScroll({
17260 view,
17261 onChangeView,
17262 isLoading,
17263 paginationInfo,
17264 containerRef,
17265 setVisibleEntries
17266 }) {
17267 const anchorElementRef = (0, import_element59.useRef)(null);
17268 const viewRef = (0, import_element59.useRef)(view);
17269 const isLoadingRef = (0, import_element59.useRef)(isLoading);
17270 const onChangeViewRef = (0, import_element59.useRef)(onChangeView);
17271 const totalItemsRef = (0, import_element59.useRef)(paginationInfo.totalItems);
17272 (0, import_element59.useLayoutEffect)(() => {
17273 viewRef.current = view;
17274 isLoadingRef.current = isLoading;
17275 onChangeViewRef.current = onChangeView;
17276 totalItemsRef.current = paginationInfo.totalItems;
17277 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
17278 const intersectionObserverCallback = (0, import_element59.useCallback)(
17279 (entries) => {
17280 if (!setVisibleEntries) {
17281 return;
17282 }
17283 setVisibleEntries((prev) => {
17284 const newVisibleEntries = new Set(prev);
17285 let hasChanged = false;
17286 entries.forEach((entry) => {
17287 const posInSet = Number(
17288 entry.target?.attributes?.getNamedItem(
17289 "aria-posinset"
17290 )?.value
17291 );
17292 if (isNaN(posInSet)) {
17293 return;
17294 }
17295 if (entry.isIntersecting) {
17296 if (!newVisibleEntries.has(posInSet)) {
17297 newVisibleEntries.add(posInSet);
17298 hasChanged = true;
17299 }
17300 } else if (newVisibleEntries.has(posInSet)) {
17301 newVisibleEntries.delete(posInSet);
17302 hasChanged = true;
17303 }
17304 });
17305 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
17306 });
17307 },
17308 [setVisibleEntries]
17309 );
17310 (0, import_element59.useLayoutEffect)(() => {
17311 const container = containerRef.current;
17312 const anchor = anchorElementRef.current;
17313 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
17314 return;
17315 }
17316 const anchorElement = container.querySelector(
17317 `[aria-posinset="${anchor.posinset}"]`
17318 );
17319 if (anchorElement) {
17320 const containerRect = container.getBoundingClientRect();
17321 const anchorRect = anchorElement.getBoundingClientRect();
17322 const currentOffset = anchorRect.top - containerRect.top;
17323 const scrollAdjustment = currentOffset - anchor.viewportOffset;
17324 if (Math.abs(scrollAdjustment) > 1) {
17325 container.scrollTop += scrollAdjustment;
17326 }
17327 }
17328 anchorElementRef.current = null;
17329 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
17330 const intersectionObserverRef = (0, import_element59.useRef)(
17331 null
17332 );
17333 (0, import_element59.useEffect)(() => {
17334 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
17335 if (intersectionObserverRef.current) {
17336 intersectionObserverRef.current.disconnect();
17337 intersectionObserverRef.current = null;
17338 }
17339 return;
17340 }
17341 intersectionObserverRef.current = new IntersectionObserver(
17342 intersectionObserverCallback,
17343 { root: null, rootMargin: "0px", threshold: 0.1 }
17344 );
17345 return () => {
17346 if (intersectionObserverRef.current) {
17347 intersectionObserverRef.current.disconnect();
17348 intersectionObserverRef.current = null;
17349 }
17350 };
17351 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
17352 (0, import_element59.useEffect)(() => {
17353 if (!view.infiniteScrollEnabled || !containerRef.current) {
17354 return;
17355 }
17356 let lastScrollTop = 0;
17357 const BOTTOM_THRESHOLD = 600;
17358 const TOP_THRESHOLD = 800;
17359 const handleScroll = (0, import_compose11.throttle)((event) => {
17360 const currentView = viewRef.current;
17361 const totalItems = totalItemsRef.current;
17362 const target = event.target;
17363 const scrollTop = target.scrollTop;
17364 const scrollHeight = target.scrollHeight;
17365 const clientHeight = target.clientHeight;
17366 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
17367 lastScrollTop = scrollTop;
17368 if (isLoadingRef.current) {
17369 return;
17370 }
17371 const currentStartPosition = currentView.startPosition || 1;
17372 const batchSize = currentView.perPage || 10;
17373 const currentEndPosition = Math.min(
17374 currentStartPosition + batchSize,
17375 totalItems
17376 );
17377 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
17378 if (currentEndPosition < totalItems) {
17379 const newStartPosition = currentEndPosition;
17380 captureAnchorElement(target, anchorElementRef, "down");
17381 onChangeViewRef.current({
17382 ...currentView,
17383 startPosition: newStartPosition
17384 });
17385 }
17386 }
17387 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
17388 if (currentStartPosition > 1) {
17389 const calculatedStartPosition = currentStartPosition - batchSize;
17390 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
17391 captureAnchorElement(target, anchorElementRef, "up");
17392 onChangeViewRef.current({
17393 ...currentView,
17394 startPosition: newStartPosition
17395 });
17396 }
17397 }
17398 }, 50);
17399 const container = containerRef.current;
17400 container.addEventListener("scroll", handleScroll);
17401 return () => {
17402 container.removeEventListener("scroll", handleScroll);
17403 handleScroll.cancel();
17404 };
17405 }, [containerRef, view.infiniteScrollEnabled]);
17406 return {
17407 intersectionObserver: intersectionObserverRef.current
17408 };
17409 }
17410
17411 // packages/dataviews/build-module/dataviews/index.mjs
17412 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17413 var defaultGetItemId = (item) => item.id;
17414 var defaultIsItemClickable = () => true;
17415 var EMPTY_ARRAY6 = [];
17416 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
17417 var dataViewsLayouts = VIEW_LAYOUTS.filter(
17418 (viewLayout) => !viewLayout.isPicker
17419 );
17420 function DefaultUI({
17421 header,
17422 search = true,
17423 searchLabel = void 0
17424 }) {
17425 const { view } = (0, import_element60.useContext)(dataviews_context_default);
17426 const isInfiniteScroll = view.infiniteScrollEnabled;
17427 return /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(import_jsx_runtime93.Fragment, { children: [
17428 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17429 Stack,
17430 {
17431 direction: "row",
17432 align: "top",
17433 justify: "space-between",
17434 className: clsx_default("dataviews__view-actions", {
17435 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
17436 }),
17437 gap: "xs",
17438 children: [
17439 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(
17440 Stack,
17441 {
17442 direction: "row",
17443 justify: "start",
17444 gap: "sm",
17445 className: "dataviews__search",
17446 children: [
17447 search && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(dataviews_search_default, { label: searchLabel }),
17448 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(toggle_default, {})
17449 ]
17450 }
17451 ),
17452 /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
17453 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(dataviews_view_config_default, {}),
17454 header
17455 ] })
17456 ]
17457 }
17458 ),
17459 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
17460 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(DataViewsLayout, {}),
17461 /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(DataViewsFooter, {})
17462 ] });
17463 }
17464 function DataViews({
17465 view,
17466 onChangeView,
17467 fields,
17468 search = true,
17469 searchLabel = void 0,
17470 actions = EMPTY_ARRAY6,
17471 data,
17472 getItemId = defaultGetItemId,
17473 getItemLevel,
17474 isLoading = false,
17475 paginationInfo,
17476 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
17477 selection: selectionProperty,
17478 onChangeSelection,
17479 onClickItem,
17480 renderItemLink,
17481 isItemClickable = defaultIsItemClickable,
17482 header,
17483 children,
17484 config = { perPageSizes: [10, 20, 50, 100] },
17485 empty,
17486 onReset
17487 }) {
17488 const [selectionState, setSelectionState] = (0, import_element60.useState)([]);
17489 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
17490 const selection = isUncontrolled ? selectionState : selectionProperty;
17491 const {
17492 data: displayData,
17493 paginationInfo: displayPaginationInfo,
17494 hasInitiallyLoaded,
17495 setVisibleEntries
17496 } = useData({
17497 view,
17498 data,
17499 getItemId,
17500 isLoading,
17501 selection,
17502 paginationInfo
17503 });
17504 const containerRef = (0, import_element60.useRef)(null);
17505 const [containerWidth, setContainerWidth] = (0, import_element60.useState)(0);
17506 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
17507 (resizeObserverEntries) => {
17508 setContainerWidth(
17509 resizeObserverEntries[0].borderBoxSize[0].inlineSize
17510 );
17511 },
17512 { box: "border-box" }
17513 );
17514 const [openedFilter, setOpenedFilter] = (0, import_element60.useState)(null);
17515 function setSelectionWithChange(value) {
17516 const newValue = typeof value === "function" ? value(selection) : value;
17517 if (isUncontrolled) {
17518 setSelectionState(newValue);
17519 }
17520 if (onChangeSelection) {
17521 onChangeSelection(newValue);
17522 }
17523 }
17524 const _fields = (0, import_element60.useMemo)(() => normalizeFields(fields), [fields]);
17525 const _selection = (0, import_element60.useMemo)(() => {
17526 if (view.infiniteScrollEnabled) {
17527 return selection;
17528 }
17529 return selection.filter(
17530 (id) => data.some((item) => getItemId(item) === id)
17531 );
17532 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
17533 const filters = use_filters_default(_fields, view);
17534 const hasPrimaryOrLockedFilters = (0, import_element60.useMemo)(
17535 () => (filters || []).some(
17536 (filter) => filter.isPrimary || filter.isLocked
17537 ),
17538 [filters]
17539 );
17540 const [isShowingFilter, setIsShowingFilter] = (0, import_element60.useState)(
17541 hasPrimaryOrLockedFilters
17542 );
17543 const { intersectionObserver } = useInfiniteScroll({
17544 view,
17545 onChangeView,
17546 isLoading,
17547 paginationInfo,
17548 containerRef,
17549 setVisibleEntries
17550 });
17551 (0, import_element60.useEffect)(() => {
17552 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
17553 setIsShowingFilter(true);
17554 }
17555 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
17556 const defaultLayouts = (0, import_element60.useMemo)(
17557 () => Object.fromEntries(
17558 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
17559 return dataViewsLayouts.some(
17560 (viewLayout) => viewLayout.type === layoutType
17561 );
17562 }).map(([key, value]) => [
17563 key,
17564 value === true ? {} : value
17565 ])
17566 ),
17567 [defaultLayoutsProperty]
17568 );
17569 if (!defaultLayouts[view.type]) {
17570 return null;
17571 }
17572 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17573 dataviews_context_default.Provider,
17574 {
17575 value: {
17576 view,
17577 onChangeView,
17578 fields: _fields,
17579 actions,
17580 data: displayData,
17581 isLoading,
17582 paginationInfo: displayPaginationInfo,
17583 selection: _selection,
17584 onChangeSelection: setSelectionWithChange,
17585 openedFilter,
17586 setOpenedFilter,
17587 getItemId,
17588 getItemLevel,
17589 isItemClickable,
17590 onClickItem,
17591 renderItemLink,
17592 containerWidth,
17593 containerRef,
17594 resizeObserverRef,
17595 defaultLayouts,
17596 filters,
17597 isShowingFilter,
17598 setIsShowingFilter,
17599 config,
17600 empty,
17601 hasInitiallyLoaded,
17602 onReset,
17603 intersectionObserver
17604 },
17605 children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(
17606 DefaultUI,
17607 {
17608 header,
17609 search,
17610 searchLabel
17611 }
17612 ) })
17613 }
17614 );
17615 }
17616 var DataViewsSubComponents = DataViews;
17617 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
17618 DataViewsSubComponents.Filters = filters_default;
17619 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
17620 DataViewsSubComponents.FiltersToggle = toggle_default;
17621 DataViewsSubComponents.Layout = DataViewsLayout;
17622 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
17623 DataViewsSubComponents.Pagination = DataViewsPagination;
17624 DataViewsSubComponents.Search = dataviews_search_default;
17625 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
17626 DataViewsSubComponents.Footer = DataViewsFooter;
17627 var dataviews_default = DataViewsSubComponents;
17628
17629 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
17630 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
17631 var import_deprecated = __toESM(require_deprecated(), 1);
17632 function normalizeSearchInput2(input = "") {
17633 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
17634 }
17635 var EMPTY_ARRAY7 = [];
17636 function filterSortAndPaginate(data, view, fields) {
17637 if (!data) {
17638 return {
17639 data: EMPTY_ARRAY7,
17640 paginationInfo: { totalItems: 0, totalPages: 0 }
17641 };
17642 }
17643 const _fields = normalizeFields(fields);
17644 let filteredData = [...data];
17645 if (view.search) {
17646 const normalizedSearch = normalizeSearchInput2(view.search);
17647 filteredData = filteredData.filter((item) => {
17648 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
17649 const fieldValue = field.getValue({ item });
17650 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
17651 return values.some(
17652 (value) => normalizeSearchInput2(String(value)).includes(
17653 normalizedSearch
17654 )
17655 );
17656 });
17657 });
17658 }
17659 if (view.filters && view.filters?.length > 0) {
17660 view.filters.forEach((filter) => {
17661 const field = _fields.find(
17662 (_field) => _field.id === filter.field
17663 );
17664 if (field) {
17665 if (filter.operator === OPERATOR_IS_NOT_ALL) {
17666 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
17667 since: "7.0",
17668 alternative: "'isNone'"
17669 });
17670 }
17671 const handler = field.filter[filter.operator];
17672 if (handler) {
17673 filteredData = filteredData.filter(
17674 (item) => handler(item, field, filter.value)
17675 );
17676 }
17677 }
17678 });
17679 }
17680 const sortByField = view.sort?.field ? _fields.find((field) => {
17681 return field.enableSorting !== false && field.id === view.sort?.field;
17682 }) : null;
17683 const groupByField = view.groupBy?.field ? _fields.find((field) => {
17684 return field.enableSorting !== false && field.id === view.groupBy?.field;
17685 }) : null;
17686 if (sortByField || groupByField) {
17687 filteredData.sort((a2, b2) => {
17688 if (groupByField) {
17689 const groupCompare = groupByField.sort(
17690 a2,
17691 b2,
17692 view.groupBy?.direction ?? "asc"
17693 );
17694 if (groupCompare !== 0) {
17695 return groupCompare;
17696 }
17697 }
17698 if (sortByField) {
17699 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
17700 }
17701 return 0;
17702 });
17703 }
17704 let totalItems = filteredData.length;
17705 let totalPages = 1;
17706 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
17707 const start = view.startPosition - 1;
17708 const end = Math.min(start + view.perPage, totalItems);
17709 filteredData = filteredData?.slice(start, end);
17710 } else if (view.page !== void 0 && view.perPage !== void 0) {
17711 const start = (view.page - 1) * view.perPage;
17712 totalItems = filteredData?.length || 0;
17713 totalPages = Math.ceil(totalItems / view.perPage);
17714 filteredData = filteredData?.slice(start, start + view.perPage);
17715 }
17716 return {
17717 data: filteredData,
17718 paginationInfo: {
17719 totalItems,
17720 totalPages
17721 }
17722 };
17723 }
17724
17725 // packages/admin-ui/build-module/navigable-region/index.mjs
17726 var import_element61 = __toESM(require_element(), 1);
17727 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17728 var NavigableRegion = (0, import_element61.forwardRef)(
17729 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
17730 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17731 Tag,
17732 {
17733 ref,
17734 className: clsx_default("admin-ui-navigable-region", className),
17735 "aria-label": ariaLabel,
17736 role: "region",
17737 tabIndex: "-1",
17738 ...props,
17739 children
17740 }
17741 );
17742 }
17743 );
17744 NavigableRegion.displayName = "NavigableRegion";
17745 var navigable_region_default = NavigableRegion;
17746
17747 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
17748 var import_components45 = __toESM(require_components(), 1);
17749 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components45.createSlotFill)("SidebarToggle");
17750
17751 // packages/admin-ui/build-module/page/header.mjs
17752 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
17753 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='aa9c241ccc']")) {
17754 const style = document.createElement("style");
17755 style.setAttribute("data-wp-hash", "aa9c241ccc");
17756 style.appendChild(document.createTextNode("._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"));
17757 document.head.appendChild(style);
17758 }
17759 var style_default4 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
17760 function Header({
17761 headingLevel = 1,
17762 breadcrumbs,
17763 badges,
17764 visual,
17765 title,
17766 subTitle,
17767 actions,
17768 showSidebarToggle = true
17769 }) {
17770 const HeadingTag = `h${headingLevel}`;
17771 return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
17772 Stack,
17773 {
17774 direction: "column",
17775 className: style_default4.header,
17776 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("header", {}),
17777 children: [
17778 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
17779 Stack,
17780 {
17781 className: style_default4["header-content"],
17782 direction: "row",
17783 gap: "sm",
17784 justify: "space-between",
17785 children: [
17786 /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
17787 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17788 SidebarToggleSlot,
17789 {
17790 bubblesVirtually: true,
17791 className: style_default4["sidebar-toggle-slot"]
17792 }
17793 ),
17794 visual && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17795 "div",
17796 {
17797 className: style_default4["header-visual"],
17798 "aria-hidden": "true",
17799 children: visual
17800 }
17801 ),
17802 title && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17803 Text,
17804 {
17805 className: style_default4["header-title"],
17806 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(HeadingTag, {}),
17807 variant: "heading-lg",
17808 children: title
17809 }
17810 ),
17811 breadcrumbs,
17812 badges
17813 ] }),
17814 actions && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17815 Stack,
17816 {
17817 align: "center",
17818 className: style_default4["header-actions"],
17819 direction: "row",
17820 gap: "sm",
17821 children: actions
17822 }
17823 )
17824 ]
17825 }
17826 ),
17827 subTitle && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17828 Text,
17829 {
17830 render: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("p", {}),
17831 variant: "body-md",
17832 className: style_default4["header-subtitle"],
17833 children: subTitle
17834 }
17835 )
17836 ]
17837 }
17838 );
17839 }
17840
17841 // packages/admin-ui/build-module/page/index.mjs
17842 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
17843 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='aa9c241ccc']")) {
17844 const style = document.createElement("style");
17845 style.setAttribute("data-wp-hash", "aa9c241ccc");
17846 style.appendChild(document.createTextNode("._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-bg-surface-neutral,#fcfcfc);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-bg-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:calc(var(--wpds-dimension-base, 4px)*8)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:calc(var(--wpds-dimension-base, 4px)*6);width:calc(var(--wpds-dimension-base, 4px)*6);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-fg-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}"));
17847 document.head.appendChild(style);
17848 }
17849 var style_default5 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
17850 function Page({
17851 headingLevel,
17852 breadcrumbs,
17853 badges,
17854 visual,
17855 title,
17856 subTitle,
17857 children,
17858 className,
17859 actions,
17860 ariaLabel,
17861 hasPadding = false,
17862 showSidebarToggle = true
17863 }) {
17864 const classes = clsx_default(style_default5.page, className);
17865 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
17866 return /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
17867 (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17868 Header,
17869 {
17870 headingLevel,
17871 breadcrumbs,
17872 badges,
17873 visual,
17874 title,
17875 subTitle,
17876 actions,
17877 showSidebarToggle
17878 }
17879 ),
17880 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17881 "div",
17882 {
17883 className: clsx_default(
17884 style_default5.content,
17885 style_default5["has-padding"]
17886 ),
17887 children
17888 }
17889 ) : children
17890 ] });
17891 }
17892 Page.SidebarToggleFill = SidebarToggleFill;
17893 var page_default = Page;
17894
17895 // routes/pattern-list/stage.tsx
17896 var import_core_data4 = __toESM(require_core_data());
17897 var import_components46 = __toESM(require_components());
17898 var import_data11 = __toESM(require_data());
17899 var import_element64 = __toESM(require_element());
17900 var import_editor = __toESM(require_editor());
17901 var import_patterns3 = __toESM(require_patterns());
17902 var import_i18n47 = __toESM(require_i18n());
17903
17904 // routes/lock-unlock.ts
17905 var import_private_apis3 = __toESM(require_private_apis());
17906 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
17907 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
17908 "@wordpress/routes"
17909 );
17910
17911 // routes/pattern-list/view-utils.ts
17912 var import_i18n43 = __toESM(require_i18n());
17913 var LAYOUT_GRID2 = "grid";
17914 var LAYOUT_TABLE2 = "table";
17915 var DEFAULT_VIEW = {
17916 type: LAYOUT_GRID2,
17917 perPage: 20,
17918 sort: {
17919 field: "title",
17920 direction: "asc"
17921 },
17922 filters: [],
17923 fields: ["sync-status"],
17924 layout: {
17925 badgeFields: ["sync-status"]
17926 },
17927 titleField: "title",
17928 mediaField: "preview"
17929 };
17930 var DEFAULT_VIEWS = [
17931 {
17932 slug: "all",
17933 label: (0, import_i18n43.__)("All patterns")
17934 },
17935 {
17936 slug: "my-patterns",
17937 label: (0, import_i18n43.__)("My patterns")
17938 },
17939 {
17940 slug: "registered",
17941 label: (0, import_i18n43.__)("Registered")
17942 }
17943 ];
17944 var DEFAULT_LAYOUTS2 = {
17945 [LAYOUT_TABLE2]: true,
17946 [LAYOUT_GRID2]: {
17947 layout: {
17948 badgeFields: ["sync-status"]
17949 }
17950 }
17951 };
17952
17953 // routes/pattern-list/fields/preview.tsx
17954 var import_i18n44 = __toESM(require_i18n());
17955 import { Preview } from "@wordpress/lazy-editor";
17956 function PreviewField({ item }) {
17957 return /* @__PURE__ */ React.createElement(
17958 Preview,
17959 {
17960 blocks: item.blocks,
17961 content: item.content,
17962 description: item.description
17963 }
17964 );
17965 }
17966 var previewField = {
17967 label: (0, import_i18n44.__)("Preview"),
17968 id: "preview",
17969 render: PreviewField,
17970 enableSorting: false
17971 };
17972
17973 // routes/pattern-list/fields/sync-status.tsx
17974 var import_i18n45 = __toESM(require_i18n());
17975 var import_patterns = __toESM(require_patterns());
17976 var { PATTERN_SYNC_TYPES } = unlock3(import_patterns.privateApis);
17977 var OPERATOR_IS2 = "is";
17978 var SYNC_FILTERS = [
17979 {
17980 value: PATTERN_SYNC_TYPES.full,
17981 label: (0, import_i18n45._x)("Synced", "pattern (singular)"),
17982 description: (0, import_i18n45.__)("Patterns that are kept in sync across the site.")
17983 },
17984 {
17985 value: PATTERN_SYNC_TYPES.unsynced,
17986 label: (0, import_i18n45._x)("Not synced", "pattern (singular)"),
17987 description: (0, import_i18n45.__)(
17988 "Patterns that can be changed freely without affecting the site."
17989 )
17990 }
17991 ];
17992 var patternStatusField = {
17993 label: (0, import_i18n45.__)("Sync status"),
17994 id: "sync-status",
17995 render: ({ item }) => {
17996 const syncStatus = item.syncStatus;
17997 return /* @__PURE__ */ React.createElement(
17998 "span",
17999 {
18000 className: `routes-pattern-list__field-sync-status-${syncStatus}`
18001 },
18002 SYNC_FILTERS.find(({ value }) => value === syncStatus)?.label
18003 );
18004 },
18005 elements: SYNC_FILTERS,
18006 filterBy: {
18007 operators: [OPERATOR_IS2],
18008 isPrimary: true
18009 },
18010 enableSorting: false
18011 };
18012
18013 // routes/pattern-list/fields/category.tsx
18014 var import_i18n46 = __toESM(require_i18n());
18015 var import_data9 = __toESM(require_data());
18016 var import_core_data2 = __toESM(require_core_data());
18017 var import_element62 = __toESM(require_element());
18018 var OPERATOR_IS3 = "is";
18019 function CategoryField({ item }) {
18020 const blockPatternCategories = (0, import_data9.useSelect)(
18021 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
18022 []
18023 );
18024 const categoryLabels = (0, import_element62.useMemo)(() => {
18025 if (!item.categories || !Array.isArray(item.categories)) {
18026 return [];
18027 }
18028 return item.categories.map((catSlug) => {
18029 const category = blockPatternCategories?.find(
18030 (cat) => cat.name === catSlug
18031 );
18032 return category ? category.label || category.name : null;
18033 }).filter(Boolean);
18034 }, [item.categories, blockPatternCategories]);
18035 if (categoryLabels.length === 0) {
18036 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field__empty" }, "\u2014");
18037 }
18038 return /* @__PURE__ */ React.createElement("span", { className: "pattern-category-field" }, categoryLabels.join(", "));
18039 }
18040 function usePatternCategories() {
18041 const userPatternCategories = (0, import_data9.useSelect)(
18042 (select2) => select2(import_core_data2.store).getUserPatternCategories(),
18043 []
18044 );
18045 const blockPatternCategories = (0, import_data9.useSelect)(
18046 (select2) => select2(import_core_data2.store).getBlockPatternCategories(),
18047 []
18048 );
18049 return (0, import_element62.useMemo)(() => {
18050 const categoryMap = /* @__PURE__ */ new Map();
18051 userPatternCategories?.forEach((cat) => {
18052 if (!categoryMap.has(cat.name)) {
18053 categoryMap.set(cat.name, {
18054 value: cat.name,
18055 label: cat.label || cat.name
18056 });
18057 }
18058 });
18059 blockPatternCategories?.forEach((cat) => {
18060 if (!categoryMap.has(cat.name)) {
18061 categoryMap.set(cat.name, {
18062 value: cat.name,
18063 label: cat.label || cat.name
18064 });
18065 }
18066 });
18067 return Array.from(categoryMap.values()).sort(
18068 (a2, b2) => a2.label.localeCompare(b2.label)
18069 );
18070 }, [userPatternCategories, blockPatternCategories]);
18071 }
18072 function usePatternCategoryField() {
18073 const categories = usePatternCategories();
18074 return {
18075 label: (0, import_i18n46.__)("Category"),
18076 id: "category",
18077 render: CategoryField,
18078 elements: categories,
18079 getValue: ({ item }) => {
18080 return item.categories;
18081 },
18082 filterBy: {
18083 operators: [OPERATOR_IS3],
18084 isPrimary: true
18085 },
18086 enableSorting: false
18087 };
18088 }
18089
18090 // routes/pattern-list/use-patterns.ts
18091 var import_data10 = __toESM(require_data());
18092 var import_core_data3 = __toESM(require_core_data());
18093 var import_element63 = __toESM(require_element());
18094 var import_patterns2 = __toESM(require_patterns());
18095 var import_block_editor = __toESM(require_block_editor());
18096
18097 // routes/pattern-list/utils.ts
18098 var filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex((item) => currentItem.name === item.name);
18099
18100 // routes/pattern-list/use-patterns.ts
18101 var {
18102 PATTERN_TYPES,
18103 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES2,
18104 EXCLUDED_PATTERN_SOURCES,
18105 PATTERN_DEFAULT_CATEGORY
18106 } = unlock3(import_patterns2.privateApis);
18107 var { extractWords, getNormalizedSearchTerms, normalizeString: normalizeString2 } = unlock3(
18108 import_block_editor.privateApis
18109 );
18110 function normalizeThemePattern(pattern) {
18111 return {
18112 id: pattern.name,
18113 title: pattern.title,
18114 content: pattern.content,
18115 keywords: pattern.keywords || [],
18116 type: PATTERN_TYPES.theme,
18117 // Normalize categories to always be an array of slugs
18118 categories: pattern.categories || [],
18119 // Theme patterns are always unsynced
18120 syncStatus: PATTERN_SYNC_TYPES2.unsynced,
18121 description: pattern.description || ""
18122 };
18123 }
18124 function normalizeUserPattern(pattern, userPatternCategories) {
18125 const categories = [];
18126 if (pattern.wp_pattern_category && Array.isArray(pattern.wp_pattern_category)) {
18127 pattern.wp_pattern_category.forEach((catId) => {
18128 const category = userPatternCategories?.find(
18129 (cat) => cat.id === catId
18130 );
18131 if (category) {
18132 categories.push(category.name);
18133 }
18134 });
18135 }
18136 const numericId = pattern.id;
18137 return {
18138 id: pattern.name || pattern.id.toString(),
18139 _recordId: numericId,
18140 // Keep numeric ID for permissions lookup
18141 keywords: [],
18142 type: PATTERN_TYPES.user,
18143 // Normalize categories to always be an array of slugs
18144 categories,
18145 // Normalize sync status
18146 syncStatus: pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES2.full,
18147 title: typeof pattern.title === "string" ? pattern.title : pattern.title.raw,
18148 content: typeof pattern.content === "string" ? pattern.content : pattern.content.raw,
18149 description: pattern.excerpt?.raw || "",
18150 blocks: pattern.blocks
18151 };
18152 }
18153 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => {
18154 return unmatchedTerms.filter(
18155 (term) => !getNormalizedSearchTerms(unprocessedTerms).some(
18156 (unprocessedTerm) => unprocessedTerm.includes(term)
18157 )
18158 );
18159 };
18160 function getItemSearchRank(item, searchTerm, config) {
18161 const { categoryId, hasCategory, onlyFilterByCategory } = config;
18162 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === "my-patterns" && item.type === PATTERN_TYPES.user || hasCategory && hasCategory(item, categoryId || "") ? 1 : 0;
18163 if (!rank || onlyFilterByCategory) {
18164 return rank;
18165 }
18166 const normalizedSearchInput = normalizeString2(searchTerm);
18167 const normalizedTitle = normalizeString2(item.title);
18168 if (normalizedSearchInput === normalizedTitle) {
18169 rank += 30;
18170 } else if (normalizedTitle.startsWith(normalizedSearchInput)) {
18171 rank += 20;
18172 } else {
18173 const terms = [
18174 item.id,
18175 item.title,
18176 item.description,
18177 ...item.keywords
18178 ].join(" ");
18179 const normalizedSearchTerms = extractWords(normalizedSearchInput);
18180 const unmatchedTerms = removeMatchingTerms(
18181 normalizedSearchTerms,
18182 terms
18183 );
18184 if (unmatchedTerms.length === 0) {
18185 rank += 10;
18186 }
18187 }
18188 return rank;
18189 }
18190 function searchItems(items = [], searchInput = "", config = {}) {
18191 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput);
18192 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length;
18193 const searchRankConfig = { ...config, onlyFilterByCategory };
18194 const threshold = onlyFilterByCategory ? 0 : 1;
18195 const rankedItems = items.map((item) => {
18196 return [
18197 item,
18198 getItemSearchRank(item, searchInput, searchRankConfig)
18199 ];
18200 }).filter(([, rank]) => rank > threshold);
18201 if (normalizedSearchTerms.length === 0) {
18202 return rankedItems.map(([item]) => item);
18203 }
18204 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1);
18205 return rankedItems.map(([item]) => item);
18206 }
18207 var selectThemePatterns = (0, import_data10.createSelector)(
18208 (select2) => {
18209 const { getBlockPatterns } = select2(import_core_data3.store);
18210 const { isResolving: isResolvingSelector } = select2(import_core_data3.store);
18211 const restBlockPatterns = getBlockPatterns();
18212 const patterns = (restBlockPatterns || []).filter(
18213 (pattern) => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)
18214 ).filter(filterOutDuplicatesByName).filter((pattern) => pattern.inserter !== false).map(normalizeThemePattern);
18215 return {
18216 patterns,
18217 isResolving: isResolvingSelector("getBlockPatterns")
18218 };
18219 },
18220 (select2) => [
18221 select2(import_core_data3.store).getBlockPatterns(),
18222 select2(import_core_data3.store).isResolving("getBlockPatterns")
18223 ]
18224 );
18225 var selectUserPatterns = (0, import_data10.createSelector)(
18226 (select2, syncStatus = void 0, search = "") => {
18227 const {
18228 getEntityRecords,
18229 isResolving: isResolvingSelector,
18230 getUserPatternCategories
18231 } = select2(import_core_data3.store);
18232 const query = { per_page: -1 };
18233 const patternPosts = getEntityRecords(
18234 "postType",
18235 PATTERN_TYPES.user,
18236 query
18237 );
18238 const userPatternCategories = getUserPatternCategories();
18239 let patterns = (patternPosts ?? []).map(
18240 (pattern) => normalizeUserPattern(pattern, userPatternCategories)
18241 );
18242 const isResolving = isResolvingSelector("getEntityRecords", [
18243 "postType",
18244 PATTERN_TYPES.user,
18245 query
18246 ]);
18247 if (syncStatus) {
18248 patterns = patterns.filter(
18249 (pattern) => pattern.syncStatus === syncStatus
18250 );
18251 }
18252 patterns = searchItems(patterns, search, {
18253 // We exit user pattern retrieval early if we aren't in the
18254 // catch-all category for user created patterns, so it has
18255 // to be in the category.
18256 categoryId: PATTERN_DEFAULT_CATEGORY,
18257 hasCategory: () => true
18258 });
18259 return {
18260 patterns,
18261 isResolving,
18262 categories: userPatternCategories
18263 };
18264 },
18265 (select2) => [
18266 select2(import_core_data3.store).getEntityRecords("postType", PATTERN_TYPES.user, {
18267 per_page: -1
18268 }),
18269 select2(import_core_data3.store).isResolving("getEntityRecords", [
18270 "postType",
18271 PATTERN_TYPES.user,
18272 { per_page: -1 }
18273 ]),
18274 select2(import_core_data3.store).getUserPatternCategories()
18275 ]
18276 );
18277 var selectPatterns = (0, import_data10.createSelector)(
18278 (select2, categoryId, syncStatus, search = "") => {
18279 const {
18280 patterns: themePatterns,
18281 isResolving: isResolvingThemePatterns
18282 } = selectThemePatterns(select2);
18283 const { patterns: userPatterns, isResolving: isResolvingUserPatterns } = selectUserPatterns(select2);
18284 let patterns = [
18285 ...themePatterns || [],
18286 ...userPatterns || []
18287 ];
18288 if (syncStatus) {
18289 patterns = patterns.filter(
18290 (pattern) => pattern.syncStatus === syncStatus
18291 );
18292 }
18293 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18294 patterns = searchItems(patterns, search, {
18295 categoryId,
18296 hasCategory: (item, currentCategory) => {
18297 return item.categories?.includes(currentCategory);
18298 }
18299 });
18300 } else {
18301 patterns = searchItems(patterns, search, {
18302 categoryId: PATTERN_DEFAULT_CATEGORY,
18303 hasCategory: () => true
18304 });
18305 }
18306 return {
18307 patterns,
18308 isResolving: isResolvingThemePatterns || isResolvingUserPatterns
18309 };
18310 },
18311 (select2) => [
18312 selectThemePatterns(select2),
18313 selectUserPatterns(select2)
18314 ]
18315 );
18316 function useAugmentPatternsWithPermissions(patterns) {
18317 const idsAndTypes = (0, import_element63.useMemo)(
18318 () => patterns?.filter((record) => record.type !== PATTERN_TYPES.theme).map((record) => [
18319 record.type,
18320 record._recordId,
18321 record.id
18322 ]) ?? [],
18323 [patterns]
18324 );
18325 const permissions = (0, import_data10.useSelect)(
18326 (select2) => {
18327 const { getEntityRecordPermissions } = unlock3(
18328 select2(import_core_data3.store)
18329 );
18330 return idsAndTypes.reduce(
18331 (acc, [type, numericId, stringId]) => {
18332 acc[stringId] = getEntityRecordPermissions(
18333 "postType",
18334 type,
18335 numericId
18336 );
18337 return acc;
18338 },
18339 {}
18340 );
18341 },
18342 [idsAndTypes]
18343 );
18344 return (0, import_element63.useMemo)(
18345 () => patterns?.map((record) => ({
18346 ...record,
18347 permissions: permissions?.[record.id] ?? {}
18348 })) ?? [],
18349 [patterns, permissions]
18350 );
18351 }
18352 var usePatterns = (postType, categoryId, { search = "", syncStatus } = {}) => {
18353 return (0, import_data10.useSelect)(
18354 (select2) => {
18355 if (postType === PATTERN_TYPES.user) {
18356 const result = selectUserPatterns(select2, syncStatus, search);
18357 let { patterns } = result;
18358 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18359 patterns = patterns.filter(
18360 (pattern) => pattern.categories.includes(categoryId)
18361 );
18362 }
18363 return {
18364 patterns,
18365 isResolving: result.isResolving
18366 };
18367 } else if (postType === PATTERN_TYPES.theme) {
18368 const result = selectThemePatterns(select2);
18369 let { patterns } = result;
18370 if (categoryId && categoryId !== PATTERN_DEFAULT_CATEGORY) {
18371 patterns = patterns.filter(
18372 (pattern) => pattern.categories.includes(categoryId)
18373 );
18374 }
18375 patterns = searchItems(patterns, search, {
18376 categoryId: categoryId || PATTERN_DEFAULT_CATEGORY,
18377 hasCategory: () => true
18378 });
18379 return {
18380 patterns,
18381 isResolving: result.isResolving
18382 };
18383 }
18384 return selectPatterns(select2, categoryId, syncStatus, search);
18385 },
18386 [categoryId, postType, search, syncStatus]
18387 );
18388 };
18389 var use_patterns_default = usePatterns;
18390
18391 // routes/pattern-list/style.scss
18392 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c329396b1f']")) {
18393 const style = document.createElement("style");
18394 style.setAttribute("data-wp-hash", "c329396b1f");
18395 style.appendChild(document.createTextNode(":root{--wp-block-synced-color:#7a00df;--wp-block-synced-color--rgb:122,0,223;--wp-bound-block-color:var(--wp-block-synced-color);--wp-editor-canvas-background:#ddd;--wp-admin-theme-color:#007cba;--wp-admin-theme-color--rgb:0,124,186;--wp-admin-theme-color-darker-10:#006ba1;--wp-admin-theme-color-darker-10--rgb:0,107,160.5;--wp-admin-theme-color-darker-20:#005a87;--wp-admin-theme-color-darker-20--rgb:0,90,135;--wp-admin-border-width-focus:2px}@media (min-resolution:192dpi){:root{--wp-admin-border-width-focus:1.5px}}.patterns-menu-items__convert-modal{z-index:1000001}.patterns-menu-items__convert-modal [role=dialog]>[role=document]{width:350px}.patterns-menu-items__convert-modal .patterns-menu-items__convert-modal-categories{position:relative}.patterns-menu-items__convert-modal .components-form-token-field__suggestions-list:not(:empty){background-color:#fff;border:1px solid var(--wp-admin-theme-color);border-bottom-left-radius:2px;border-bottom-right-radius:2px;box-shadow:0 0 .5px .5px var(--wp-admin-theme-color);box-sizing:border-box;left:-1px;max-height:96px;min-width:auto;position:absolute;width:calc(100% + 2px);z-index:1}.patterns-create-modal__name-input input[type=text]{margin:0}.patterns-rename-pattern-category-modal__validation-message{color:#cc1818}@media (min-width:782px){.patterns-rename-pattern-category-modal__validation-message{width:320px}}.pattern-overrides-control__allow-overrides-button{justify-content:center;width:100%}.routes-pattern-list__tabs-wrapper{border-bottom:1px solid #f0f0f0;padding:0 24px}.dataviews-view-grid__badge-fields .dataviews-view-grid__field-value:has(.routes-pattern-list__field-sync-status-fully){background:rgba(var(--wp-block-synced-color--rgb),.04);color:var(--wp-block-synced-color)}"));
18396 document.head.appendChild(style);
18397 }
18398
18399 // routes/pattern-list/stage.tsx
18400 var { usePostActions, patternTitleField } = unlock3(import_editor.privateApis);
18401 var { Tabs } = unlock3(import_components46.privateApis);
18402 var { PATTERN_TYPES: PATTERN_TYPES2, CreatePatternModal } = unlock3(import_patterns3.privateApis);
18403 function PatternList() {
18404 const invalidate = useInvalidate();
18405 const { type = "all" } = useParams({
18406 from: "/patterns/list/$type"
18407 });
18408 const navigate = useNavigate();
18409 const searchParams = useSearch({ from: "/patterns/list/$type" });
18410 const postTypeObject = (0, import_data11.useSelect)(
18411 (select2) => select2(import_core_data4.store).getPostType("wp_block"),
18412 []
18413 );
18414 const labels = postTypeObject?.labels;
18415 const canCreateRecord = (0, import_data11.useSelect)(
18416 (select2) => select2(import_core_data4.store).canUser("create", {
18417 kind: "postType",
18418 name: "wp_block"
18419 }),
18420 []
18421 );
18422 const [showPatternModal, setShowPatternModal] = (0, import_element64.useState)(false);
18423 const handleQueryParamsChange = (0, import_element64.useCallback)(
18424 (params) => {
18425 navigate({
18426 search: {
18427 ...searchParams,
18428 ...params
18429 }
18430 });
18431 },
18432 [searchParams, navigate]
18433 );
18434 const { view, isModified, updateView, resetToDefault } = useView({
18435 kind: "postType",
18436 name: "wp_block",
18437 slug: "default-new",
18438 defaultView: DEFAULT_VIEW,
18439 queryParams: searchParams,
18440 onChangeQueryParams: handleQueryParamsChange
18441 });
18442 const onReset = () => {
18443 resetToDefault();
18444 invalidate();
18445 };
18446 const onChangeView = (newView) => {
18447 updateView(newView);
18448 if (newView.type !== view.type) {
18449 invalidate();
18450 }
18451 };
18452 const categoryFilter = (0, import_element64.useMemo)(() => {
18453 const filter = view.filters?.find((f2) => f2.field === "category");
18454 return filter?.value || "all-patterns";
18455 }, [view.filters]);
18456 const syncStatusFilter = (0, import_element64.useMemo)(() => {
18457 const filter = view.filters?.find((f2) => f2.field === "sync-status");
18458 return filter?.value;
18459 }, [view.filters]);
18460 const patternType = (0, import_element64.useMemo)(() => {
18461 if (type === "my-patterns") {
18462 return PATTERN_TYPES2.user;
18463 } else if (type === "registered") {
18464 return PATTERN_TYPES2.theme;
18465 }
18466 return null;
18467 }, [type]);
18468 const { patterns, isResolving } = use_patterns_default(
18469 patternType,
18470 categoryFilter,
18471 {
18472 search: view.search,
18473 syncStatus: syncStatusFilter
18474 }
18475 );
18476 const patternsWithPermissions = useAugmentPatternsWithPermissions(patterns);
18477 const patternCategoryField = usePatternCategoryField();
18478 const fields = (0, import_element64.useMemo)(() => {
18479 const patternFields = [
18480 previewField,
18481 patternTitleField,
18482 patternCategoryField
18483 ];
18484 if (type === "my-patterns" || type === "all") {
18485 patternFields.push(patternStatusField);
18486 }
18487 return patternFields;
18488 }, [type, patternCategoryField]);
18489 const { data: posts, paginationInfo } = (0, import_element64.useMemo)(() => {
18490 const viewWithoutFilters = { ...view };
18491 delete viewWithoutFilters.search;
18492 viewWithoutFilters.filters = [];
18493 return filterSortAndPaginate(
18494 patternsWithPermissions,
18495 viewWithoutFilters,
18496 fields
18497 );
18498 }, [patternsWithPermissions, view, fields]);
18499 const { totalItems, totalPages } = paginationInfo;
18500 const cleanupDeletedPostIdsFromUrl = (0, import_element64.useCallback)(
18501 (deletedItems) => {
18502 const deletedIds = deletedItems.map((item) => item.id);
18503 const currentPostIds = searchParams.postIds || [];
18504 const remainingPostIds = currentPostIds.filter(
18505 (id) => !deletedIds.includes(id)
18506 );
18507 if (remainingPostIds.length !== currentPostIds.length) {
18508 navigate({
18509 search: {
18510 ...searchParams,
18511 postIds: remainingPostIds.length > 0 ? remainingPostIds : void 0
18512 }
18513 });
18514 } else {
18515 invalidate();
18516 }
18517 },
18518 [invalidate, searchParams, navigate]
18519 );
18520 const postTypeActions = usePostActions({
18521 postType: "wp_block",
18522 context: "list",
18523 onActionPerformed: (actionId, items) => {
18524 if (actionId === "move-to-trash" || actionId === "permanently-delete") {
18525 cleanupDeletedPostIdsFromUrl(items);
18526 }
18527 }
18528 });
18529 const actions = (0, import_element64.useMemo)(() => {
18530 return [
18531 ...postTypeActions?.flatMap((action) => {
18532 if (action.id === "view-post-revisions") {
18533 return [];
18534 }
18535 return [action];
18536 })
18537 ];
18538 }, [postTypeActions]);
18539 const handleTabChange = (0, import_element64.useCallback)(
18540 (typeSlug) => {
18541 navigate({
18542 to: `/patterns/list/${typeSlug}`
18543 });
18544 },
18545 [navigate]
18546 );
18547 if (!postTypeObject) {
18548 return null;
18549 }
18550 const selection = searchParams.postIds ?? [];
18551 if (view.type === "list" && selection.length === 0 && posts?.length > 0) {
18552 selection.push(posts[0].id);
18553 }
18554 if (view.type === "list") {
18555 selection.splice(1);
18556 }
18557 return /* @__PURE__ */ React.createElement(
18558 page_default,
18559 {
18560 title: (0, import_i18n47.__)("Patterns"),
18561 headingLevel: 2,
18562 subTitle: (0, import_i18n47.__)(
18563 "Reusable design elements for your site. Create once, use everywhere."
18564 ),
18565 className: "pattern-page",
18566 actions: labels?.add_new_item && canCreateRecord && /* @__PURE__ */ React.createElement(
18567 import_components46.Button,
18568 {
18569 variant: "primary",
18570 onClick: () => setShowPatternModal(true),
18571 size: "compact"
18572 },
18573 labels.add_new_item
18574 ),
18575 hasPadding: false
18576 },
18577 DEFAULT_VIEWS.length > 1 && /* @__PURE__ */ React.createElement("div", { className: "routes-pattern-list__tabs-wrapper" }, /* @__PURE__ */ React.createElement(
18578 Tabs,
18579 {
18580 onSelect: handleTabChange,
18581 selectedTabId: type ?? "all"
18582 },
18583 /* @__PURE__ */ React.createElement(Tabs.TabList, null, DEFAULT_VIEWS.map(
18584 (filter) => /* @__PURE__ */ React.createElement(
18585 Tabs.Tab,
18586 {
18587 tabId: filter.slug,
18588 key: filter.slug
18589 },
18590 filter.label
18591 )
18592 ))
18593 )),
18594 /* @__PURE__ */ React.createElement(
18595 dataviews_default,
18596 {
18597 data: posts,
18598 fields,
18599 view,
18600 onChangeView,
18601 actions,
18602 isLoading: isResolving,
18603 paginationInfo: {
18604 totalItems,
18605 totalPages
18606 },
18607 defaultLayouts: DEFAULT_LAYOUTS2,
18608 selection,
18609 onReset: isModified ? onReset : false,
18610 onChangeSelection: (items) => {
18611 navigate({
18612 search: {
18613 ...searchParams,
18614 postIds: items.length > 0 ? items : void 0,
18615 edit: items.length === 0 ? void 0 : searchParams.edit
18616 }
18617 });
18618 },
18619 isItemClickable: (item) => item.type !== PATTERN_TYPES2.theme,
18620 renderItemLink: ({
18621 item,
18622 ...props
18623 }) => /* @__PURE__ */ React.createElement(
18624 Link,
18625 {
18626 to: `/types/wp_block/edit/${encodeURIComponent(
18627 item.id
18628 )}`,
18629 ...props,
18630 onClick: (event) => {
18631 event.stopPropagation();
18632 }
18633 }
18634 )
18635 }
18636 ),
18637 showPatternModal && /* @__PURE__ */ React.createElement(
18638 CreatePatternModal,
18639 {
18640 onClose: () => setShowPatternModal(false),
18641 onSuccess: ({
18642 pattern
18643 }) => {
18644 setShowPatternModal(false);
18645 navigate({
18646 to: `/types/wp_block/edit/${encodeURIComponent(
18647 pattern.id
18648 )}`
18649 });
18650 },
18651 content: []
18652 }
18653 )
18654 );
18655 }
18656 var stage = PatternList;
18657 export {
18658 stage
18659 };
18660 /*! Bundled license information:
18661
18662 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
18663 (**
18664 * @license React
18665 * use-sync-external-store-shim.development.js
18666 *
18667 * Copyright (c) Meta Platforms, Inc. and affiliates.
18668 *
18669 * This source code is licensed under the MIT license found in the
18670 * LICENSE file in the root directory of this source tree.
18671 *)
18672 */
18673