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 / guidelines / content.js

content.js in Gutenberg 23.1.0, at build/routes/guidelines/content.js

22,929 lines 794.5 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 __export = (target, all) => {
11 for (var name in all)
12 __defProp(target, name, { get: all[name], enumerable: true });
13 };
14 var __copyProps = (to, from, except, desc) => {
15 if (from && typeof from === "object" || typeof from === "function") {
16 for (let key of __getOwnPropNames(from))
17 if (!__hasOwnProp.call(to, key) && key !== except)
18 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19 }
20 return to;
21 };
22 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23 // If the importer is in node compatibility mode or this is not an ESM
24 // file that has been converted to a CommonJS file using a Babel-
25 // compatible transform (i.e. "__esModule" has not been set), then set
26 // "default" to the CommonJS "module.exports" for node compatibility.
27 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28 mod
29 ));
30
31 // package-external:@wordpress/i18n
32 var require_i18n = __commonJS({
33 "package-external:@wordpress/i18n"(exports, module) {
34 module.exports = window.wp.i18n;
35 }
36 });
37
38 // package-external:@wordpress/element
39 var require_element = __commonJS({
40 "package-external:@wordpress/element"(exports, module) {
41 module.exports = window.wp.element;
42 }
43 });
44
45 // vendor-external:react
46 var require_react = __commonJS({
47 "vendor-external:react"(exports, module) {
48 module.exports = window.React;
49 }
50 });
51
52 // vendor-external:react/jsx-runtime
53 var require_jsx_runtime = __commonJS({
54 "vendor-external:react/jsx-runtime"(exports, module) {
55 module.exports = window.ReactJSXRuntime;
56 }
57 });
58
59 // vendor-external:react-dom
60 var require_react_dom = __commonJS({
61 "vendor-external:react-dom"(exports, module) {
62 module.exports = window.ReactDOM;
63 }
64 });
65
66 // node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
67 var require_use_sync_external_store_shim_development = __commonJS({
68 "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
69 "use strict";
70 (function() {
71 function is(x2, y2) {
72 return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
73 }
74 function useSyncExternalStore$2(subscribe2, getSnapshot) {
75 didWarnOld18Alpha || void 0 === React26.startTransition || (didWarnOld18Alpha = true, console.error(
76 "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."
77 ));
78 var value = getSnapshot();
79 if (!didWarnUncachedGetSnapshot) {
80 var cachedValue = getSnapshot();
81 objectIs(value, cachedValue) || (console.error(
82 "The result of getSnapshot should be cached to avoid an infinite loop"
83 ), didWarnUncachedGetSnapshot = true);
84 }
85 cachedValue = useState41({
86 inst: { value, getSnapshot }
87 });
88 var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
89 useLayoutEffect5(
90 function() {
91 inst.value = value;
92 inst.getSnapshot = getSnapshot;
93 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
94 },
95 [subscribe2, value, getSnapshot]
96 );
97 useEffect36(
98 function() {
99 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
100 return subscribe2(function() {
101 checkIfSnapshotChanged(inst) && forceUpdate({ inst });
102 });
103 },
104 [subscribe2]
105 );
106 useDebugValue(value);
107 return value;
108 }
109 function checkIfSnapshotChanged(inst) {
110 var latestGetSnapshot = inst.getSnapshot;
111 inst = inst.value;
112 try {
113 var nextValue = latestGetSnapshot();
114 return !objectIs(inst, nextValue);
115 } catch (error2) {
116 return true;
117 }
118 }
119 function useSyncExternalStore$1(subscribe2, getSnapshot) {
120 return getSnapshot();
121 }
122 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
123 var React26 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState41 = React26.useState, useEffect36 = React26.useEffect, useLayoutEffect5 = React26.useLayoutEffect, useDebugValue = React26.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
124 exports.useSyncExternalStore = void 0 !== React26.useSyncExternalStore ? React26.useSyncExternalStore : shim;
125 "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
126 })();
127 }
128 });
129
130 // node_modules/use-sync-external-store/shim/index.js
131 var require_shim = __commonJS({
132 "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
133 "use strict";
134 if (false) {
135 module.exports = null;
136 } else {
137 module.exports = require_use_sync_external_store_shim_development();
138 }
139 }
140 });
141
142 // package-external:@wordpress/primitives
143 var require_primitives = __commonJS({
144 "package-external:@wordpress/primitives"(exports, module) {
145 module.exports = window.wp.primitives;
146 }
147 });
148
149 // package-external:@wordpress/compose
150 var require_compose = __commonJS({
151 "package-external:@wordpress/compose"(exports, module) {
152 module.exports = window.wp.compose;
153 }
154 });
155
156 // package-external:@wordpress/private-apis
157 var require_private_apis = __commonJS({
158 "package-external:@wordpress/private-apis"(exports, module) {
159 module.exports = window.wp.privateApis;
160 }
161 });
162
163 // package-external:@wordpress/components
164 var require_components = __commonJS({
165 "package-external:@wordpress/components"(exports, module) {
166 module.exports = window.wp.components;
167 }
168 });
169
170 // package-external:@wordpress/keycodes
171 var require_keycodes = __commonJS({
172 "package-external:@wordpress/keycodes"(exports, module) {
173 module.exports = window.wp.keycodes;
174 }
175 });
176
177 // package-external:@wordpress/data
178 var require_data = __commonJS({
179 "package-external:@wordpress/data"(exports, module) {
180 module.exports = window.wp.data;
181 }
182 });
183
184 // node_modules/remove-accents/index.js
185 var require_remove_accents = __commonJS({
186 "node_modules/remove-accents/index.js"(exports, module) {
187 var characterMap = {
188 "\xC0": "A",
189 "\xC1": "A",
190 "\xC2": "A",
191 "\xC3": "A",
192 "\xC4": "A",
193 "\xC5": "A",
194 "\u1EA4": "A",
195 "\u1EAE": "A",
196 "\u1EB2": "A",
197 "\u1EB4": "A",
198 "\u1EB6": "A",
199 "\xC6": "AE",
200 "\u1EA6": "A",
201 "\u1EB0": "A",
202 "\u0202": "A",
203 "\u1EA2": "A",
204 "\u1EA0": "A",
205 "\u1EA8": "A",
206 "\u1EAA": "A",
207 "\u1EAC": "A",
208 "\xC7": "C",
209 "\u1E08": "C",
210 "\xC8": "E",
211 "\xC9": "E",
212 "\xCA": "E",
213 "\xCB": "E",
214 "\u1EBE": "E",
215 "\u1E16": "E",
216 "\u1EC0": "E",
217 "\u1E14": "E",
218 "\u1E1C": "E",
219 "\u0206": "E",
220 "\u1EBA": "E",
221 "\u1EBC": "E",
222 "\u1EB8": "E",
223 "\u1EC2": "E",
224 "\u1EC4": "E",
225 "\u1EC6": "E",
226 "\xCC": "I",
227 "\xCD": "I",
228 "\xCE": "I",
229 "\xCF": "I",
230 "\u1E2E": "I",
231 "\u020A": "I",
232 "\u1EC8": "I",
233 "\u1ECA": "I",
234 "\xD0": "D",
235 "\xD1": "N",
236 "\xD2": "O",
237 "\xD3": "O",
238 "\xD4": "O",
239 "\xD5": "O",
240 "\xD6": "O",
241 "\xD8": "O",
242 "\u1ED0": "O",
243 "\u1E4C": "O",
244 "\u1E52": "O",
245 "\u020E": "O",
246 "\u1ECE": "O",
247 "\u1ECC": "O",
248 "\u1ED4": "O",
249 "\u1ED6": "O",
250 "\u1ED8": "O",
251 "\u1EDC": "O",
252 "\u1EDE": "O",
253 "\u1EE0": "O",
254 "\u1EDA": "O",
255 "\u1EE2": "O",
256 "\xD9": "U",
257 "\xDA": "U",
258 "\xDB": "U",
259 "\xDC": "U",
260 "\u1EE6": "U",
261 "\u1EE4": "U",
262 "\u1EEC": "U",
263 "\u1EEE": "U",
264 "\u1EF0": "U",
265 "\xDD": "Y",
266 "\xE0": "a",
267 "\xE1": "a",
268 "\xE2": "a",
269 "\xE3": "a",
270 "\xE4": "a",
271 "\xE5": "a",
272 "\u1EA5": "a",
273 "\u1EAF": "a",
274 "\u1EB3": "a",
275 "\u1EB5": "a",
276 "\u1EB7": "a",
277 "\xE6": "ae",
278 "\u1EA7": "a",
279 "\u1EB1": "a",
280 "\u0203": "a",
281 "\u1EA3": "a",
282 "\u1EA1": "a",
283 "\u1EA9": "a",
284 "\u1EAB": "a",
285 "\u1EAD": "a",
286 "\xE7": "c",
287 "\u1E09": "c",
288 "\xE8": "e",
289 "\xE9": "e",
290 "\xEA": "e",
291 "\xEB": "e",
292 "\u1EBF": "e",
293 "\u1E17": "e",
294 "\u1EC1": "e",
295 "\u1E15": "e",
296 "\u1E1D": "e",
297 "\u0207": "e",
298 "\u1EBB": "e",
299 "\u1EBD": "e",
300 "\u1EB9": "e",
301 "\u1EC3": "e",
302 "\u1EC5": "e",
303 "\u1EC7": "e",
304 "\xEC": "i",
305 "\xED": "i",
306 "\xEE": "i",
307 "\xEF": "i",
308 "\u1E2F": "i",
309 "\u020B": "i",
310 "\u1EC9": "i",
311 "\u1ECB": "i",
312 "\xF0": "d",
313 "\xF1": "n",
314 "\xF2": "o",
315 "\xF3": "o",
316 "\xF4": "o",
317 "\xF5": "o",
318 "\xF6": "o",
319 "\xF8": "o",
320 "\u1ED1": "o",
321 "\u1E4D": "o",
322 "\u1E53": "o",
323 "\u020F": "o",
324 "\u1ECF": "o",
325 "\u1ECD": "o",
326 "\u1ED5": "o",
327 "\u1ED7": "o",
328 "\u1ED9": "o",
329 "\u1EDD": "o",
330 "\u1EDF": "o",
331 "\u1EE1": "o",
332 "\u1EDB": "o",
333 "\u1EE3": "o",
334 "\xF9": "u",
335 "\xFA": "u",
336 "\xFB": "u",
337 "\xFC": "u",
338 "\u1EE7": "u",
339 "\u1EE5": "u",
340 "\u1EED": "u",
341 "\u1EEF": "u",
342 "\u1EF1": "u",
343 "\xFD": "y",
344 "\xFF": "y",
345 "\u0100": "A",
346 "\u0101": "a",
347 "\u0102": "A",
348 "\u0103": "a",
349 "\u0104": "A",
350 "\u0105": "a",
351 "\u0106": "C",
352 "\u0107": "c",
353 "\u0108": "C",
354 "\u0109": "c",
355 "\u010A": "C",
356 "\u010B": "c",
357 "\u010C": "C",
358 "\u010D": "c",
359 "C\u0306": "C",
360 "c\u0306": "c",
361 "\u010E": "D",
362 "\u010F": "d",
363 "\u0110": "D",
364 "\u0111": "d",
365 "\u0112": "E",
366 "\u0113": "e",
367 "\u0114": "E",
368 "\u0115": "e",
369 "\u0116": "E",
370 "\u0117": "e",
371 "\u0118": "E",
372 "\u0119": "e",
373 "\u011A": "E",
374 "\u011B": "e",
375 "\u011C": "G",
376 "\u01F4": "G",
377 "\u011D": "g",
378 "\u01F5": "g",
379 "\u011E": "G",
380 "\u011F": "g",
381 "\u0120": "G",
382 "\u0121": "g",
383 "\u0122": "G",
384 "\u0123": "g",
385 "\u0124": "H",
386 "\u0125": "h",
387 "\u0126": "H",
388 "\u0127": "h",
389 "\u1E2A": "H",
390 "\u1E2B": "h",
391 "\u0128": "I",
392 "\u0129": "i",
393 "\u012A": "I",
394 "\u012B": "i",
395 "\u012C": "I",
396 "\u012D": "i",
397 "\u012E": "I",
398 "\u012F": "i",
399 "\u0130": "I",
400 "\u0131": "i",
401 "\u0132": "IJ",
402 "\u0133": "ij",
403 "\u0134": "J",
404 "\u0135": "j",
405 "\u0136": "K",
406 "\u0137": "k",
407 "\u1E30": "K",
408 "\u1E31": "k",
409 "K\u0306": "K",
410 "k\u0306": "k",
411 "\u0139": "L",
412 "\u013A": "l",
413 "\u013B": "L",
414 "\u013C": "l",
415 "\u013D": "L",
416 "\u013E": "l",
417 "\u013F": "L",
418 "\u0140": "l",
419 "\u0141": "l",
420 "\u0142": "l",
421 "\u1E3E": "M",
422 "\u1E3F": "m",
423 "M\u0306": "M",
424 "m\u0306": "m",
425 "\u0143": "N",
426 "\u0144": "n",
427 "\u0145": "N",
428 "\u0146": "n",
429 "\u0147": "N",
430 "\u0148": "n",
431 "\u0149": "n",
432 "N\u0306": "N",
433 "n\u0306": "n",
434 "\u014C": "O",
435 "\u014D": "o",
436 "\u014E": "O",
437 "\u014F": "o",
438 "\u0150": "O",
439 "\u0151": "o",
440 "\u0152": "OE",
441 "\u0153": "oe",
442 "P\u0306": "P",
443 "p\u0306": "p",
444 "\u0154": "R",
445 "\u0155": "r",
446 "\u0156": "R",
447 "\u0157": "r",
448 "\u0158": "R",
449 "\u0159": "r",
450 "R\u0306": "R",
451 "r\u0306": "r",
452 "\u0212": "R",
453 "\u0213": "r",
454 "\u015A": "S",
455 "\u015B": "s",
456 "\u015C": "S",
457 "\u015D": "s",
458 "\u015E": "S",
459 "\u0218": "S",
460 "\u0219": "s",
461 "\u015F": "s",
462 "\u0160": "S",
463 "\u0161": "s",
464 "\u0162": "T",
465 "\u0163": "t",
466 "\u021B": "t",
467 "\u021A": "T",
468 "\u0164": "T",
469 "\u0165": "t",
470 "\u0166": "T",
471 "\u0167": "t",
472 "T\u0306": "T",
473 "t\u0306": "t",
474 "\u0168": "U",
475 "\u0169": "u",
476 "\u016A": "U",
477 "\u016B": "u",
478 "\u016C": "U",
479 "\u016D": "u",
480 "\u016E": "U",
481 "\u016F": "u",
482 "\u0170": "U",
483 "\u0171": "u",
484 "\u0172": "U",
485 "\u0173": "u",
486 "\u0216": "U",
487 "\u0217": "u",
488 "V\u0306": "V",
489 "v\u0306": "v",
490 "\u0174": "W",
491 "\u0175": "w",
492 "\u1E82": "W",
493 "\u1E83": "w",
494 "X\u0306": "X",
495 "x\u0306": "x",
496 "\u0176": "Y",
497 "\u0177": "y",
498 "\u0178": "Y",
499 "Y\u0306": "Y",
500 "y\u0306": "y",
501 "\u0179": "Z",
502 "\u017A": "z",
503 "\u017B": "Z",
504 "\u017C": "z",
505 "\u017D": "Z",
506 "\u017E": "z",
507 "\u017F": "s",
508 "\u0192": "f",
509 "\u01A0": "O",
510 "\u01A1": "o",
511 "\u01AF": "U",
512 "\u01B0": "u",
513 "\u01CD": "A",
514 "\u01CE": "a",
515 "\u01CF": "I",
516 "\u01D0": "i",
517 "\u01D1": "O",
518 "\u01D2": "o",
519 "\u01D3": "U",
520 "\u01D4": "u",
521 "\u01D5": "U",
522 "\u01D6": "u",
523 "\u01D7": "U",
524 "\u01D8": "u",
525 "\u01D9": "U",
526 "\u01DA": "u",
527 "\u01DB": "U",
528 "\u01DC": "u",
529 "\u1EE8": "U",
530 "\u1EE9": "u",
531 "\u1E78": "U",
532 "\u1E79": "u",
533 "\u01FA": "A",
534 "\u01FB": "a",
535 "\u01FC": "AE",
536 "\u01FD": "ae",
537 "\u01FE": "O",
538 "\u01FF": "o",
539 "\xDE": "TH",
540 "\xFE": "th",
541 "\u1E54": "P",
542 "\u1E55": "p",
543 "\u1E64": "S",
544 "\u1E65": "s",
545 "X\u0301": "X",
546 "x\u0301": "x",
547 "\u0403": "\u0413",
548 "\u0453": "\u0433",
549 "\u040C": "\u041A",
550 "\u045C": "\u043A",
551 "A\u030B": "A",
552 "a\u030B": "a",
553 "E\u030B": "E",
554 "e\u030B": "e",
555 "I\u030B": "I",
556 "i\u030B": "i",
557 "\u01F8": "N",
558 "\u01F9": "n",
559 "\u1ED2": "O",
560 "\u1ED3": "o",
561 "\u1E50": "O",
562 "\u1E51": "o",
563 "\u1EEA": "U",
564 "\u1EEB": "u",
565 "\u1E80": "W",
566 "\u1E81": "w",
567 "\u1EF2": "Y",
568 "\u1EF3": "y",
569 "\u0200": "A",
570 "\u0201": "a",
571 "\u0204": "E",
572 "\u0205": "e",
573 "\u0208": "I",
574 "\u0209": "i",
575 "\u020C": "O",
576 "\u020D": "o",
577 "\u0210": "R",
578 "\u0211": "r",
579 "\u0214": "U",
580 "\u0215": "u",
581 "B\u030C": "B",
582 "b\u030C": "b",
583 "\u010C\u0323": "C",
584 "\u010D\u0323": "c",
585 "\xCA\u030C": "E",
586 "\xEA\u030C": "e",
587 "F\u030C": "F",
588 "f\u030C": "f",
589 "\u01E6": "G",
590 "\u01E7": "g",
591 "\u021E": "H",
592 "\u021F": "h",
593 "J\u030C": "J",
594 "\u01F0": "j",
595 "\u01E8": "K",
596 "\u01E9": "k",
597 "M\u030C": "M",
598 "m\u030C": "m",
599 "P\u030C": "P",
600 "p\u030C": "p",
601 "Q\u030C": "Q",
602 "q\u030C": "q",
603 "\u0158\u0329": "R",
604 "\u0159\u0329": "r",
605 "\u1E66": "S",
606 "\u1E67": "s",
607 "V\u030C": "V",
608 "v\u030C": "v",
609 "W\u030C": "W",
610 "w\u030C": "w",
611 "X\u030C": "X",
612 "x\u030C": "x",
613 "Y\u030C": "Y",
614 "y\u030C": "y",
615 "A\u0327": "A",
616 "a\u0327": "a",
617 "B\u0327": "B",
618 "b\u0327": "b",
619 "\u1E10": "D",
620 "\u1E11": "d",
621 "\u0228": "E",
622 "\u0229": "e",
623 "\u0190\u0327": "E",
624 "\u025B\u0327": "e",
625 "\u1E28": "H",
626 "\u1E29": "h",
627 "I\u0327": "I",
628 "i\u0327": "i",
629 "\u0197\u0327": "I",
630 "\u0268\u0327": "i",
631 "M\u0327": "M",
632 "m\u0327": "m",
633 "O\u0327": "O",
634 "o\u0327": "o",
635 "Q\u0327": "Q",
636 "q\u0327": "q",
637 "U\u0327": "U",
638 "u\u0327": "u",
639 "X\u0327": "X",
640 "x\u0327": "x",
641 "Z\u0327": "Z",
642 "z\u0327": "z",
643 "\u0439": "\u0438",
644 "\u0419": "\u0418",
645 "\u0451": "\u0435",
646 "\u0401": "\u0415"
647 };
648 var chars = Object.keys(characterMap).join("|");
649 var allAccents = new RegExp(chars, "g");
650 var firstAccent = new RegExp(chars, "");
651 function matcher(match2) {
652 return characterMap[match2];
653 }
654 var removeAccents3 = function(string) {
655 return string.replace(allAccents, matcher);
656 };
657 var hasAccents = function(string) {
658 return !!string.match(firstAccent);
659 };
660 module.exports = removeAccents3;
661 module.exports.has = hasAccents;
662 module.exports.remove = removeAccents3;
663 }
664 });
665
666 // node_modules/fast-deep-equal/es6/index.js
667 var require_es6 = __commonJS({
668 "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
669 "use strict";
670 module.exports = function equal(a2, b2) {
671 if (a2 === b2) return true;
672 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
673 if (a2.constructor !== b2.constructor) return false;
674 var length, i2, keys;
675 if (Array.isArray(a2)) {
676 length = a2.length;
677 if (length != b2.length) return false;
678 for (i2 = length; i2-- !== 0; )
679 if (!equal(a2[i2], b2[i2])) return false;
680 return true;
681 }
682 if (a2 instanceof Map && b2 instanceof Map) {
683 if (a2.size !== b2.size) return false;
684 for (i2 of a2.entries())
685 if (!b2.has(i2[0])) return false;
686 for (i2 of a2.entries())
687 if (!equal(i2[1], b2.get(i2[0]))) return false;
688 return true;
689 }
690 if (a2 instanceof Set && b2 instanceof Set) {
691 if (a2.size !== b2.size) return false;
692 for (i2 of a2.entries())
693 if (!b2.has(i2[0])) return false;
694 return true;
695 }
696 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
697 length = a2.length;
698 if (length != b2.length) return false;
699 for (i2 = length; i2-- !== 0; )
700 if (a2[i2] !== b2[i2]) return false;
701 return true;
702 }
703 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
704 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
705 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
706 keys = Object.keys(a2);
707 length = keys.length;
708 if (length !== Object.keys(b2).length) return false;
709 for (i2 = length; i2-- !== 0; )
710 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
711 for (i2 = length; i2-- !== 0; ) {
712 var key = keys[i2];
713 if (!equal(a2[key], b2[key])) return false;
714 }
715 return true;
716 }
717 return a2 !== a2 && b2 !== b2;
718 };
719 }
720 });
721
722 // package-external:@wordpress/date
723 var require_date = __commonJS({
724 "package-external:@wordpress/date"(exports, module) {
725 module.exports = window.wp.date;
726 }
727 });
728
729 // package-external:@wordpress/warning
730 var require_warning = __commonJS({
731 "package-external:@wordpress/warning"(exports, module) {
732 module.exports = window.wp.warning;
733 }
734 });
735
736 // node_modules/deepmerge/dist/cjs.js
737 var require_cjs = __commonJS({
738 "node_modules/deepmerge/dist/cjs.js"(exports, module) {
739 "use strict";
740 var isMergeableObject = function isMergeableObject2(value) {
741 return isNonNullObject(value) && !isSpecial(value);
742 };
743 function isNonNullObject(value) {
744 return !!value && typeof value === "object";
745 }
746 function isSpecial(value) {
747 var stringValue = Object.prototype.toString.call(value);
748 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
749 }
750 var canUseSymbol = typeof Symbol === "function" && Symbol.for;
751 var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
752 function isReactElement(value) {
753 return value.$$typeof === REACT_ELEMENT_TYPE;
754 }
755 function emptyTarget(val) {
756 return Array.isArray(val) ? [] : {};
757 }
758 function cloneUnlessOtherwiseSpecified(value, options) {
759 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
760 }
761 function defaultArrayMerge(target, source, options) {
762 return target.concat(source).map(function(element) {
763 return cloneUnlessOtherwiseSpecified(element, options);
764 });
765 }
766 function getMergeFunction(key, options) {
767 if (!options.customMerge) {
768 return deepmerge;
769 }
770 var customMerge = options.customMerge(key);
771 return typeof customMerge === "function" ? customMerge : deepmerge;
772 }
773 function getEnumerableOwnPropertySymbols(target) {
774 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol3) {
775 return Object.propertyIsEnumerable.call(target, symbol3);
776 }) : [];
777 }
778 function getKeys2(target) {
779 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
780 }
781 function propertyIsOnObject(object, property) {
782 try {
783 return property in object;
784 } catch (_) {
785 return false;
786 }
787 }
788 function propertyIsUnsafe(target, key) {
789 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
790 }
791 function mergeObject(target, source, options) {
792 var destination = {};
793 if (options.isMergeableObject(target)) {
794 getKeys2(target).forEach(function(key) {
795 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
796 });
797 }
798 getKeys2(source).forEach(function(key) {
799 if (propertyIsUnsafe(target, key)) {
800 return;
801 }
802 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
803 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
804 } else {
805 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
806 }
807 });
808 return destination;
809 }
810 function deepmerge(target, source, options) {
811 options = options || {};
812 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
813 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
814 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
815 var sourceIsArray = Array.isArray(source);
816 var targetIsArray = Array.isArray(target);
817 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
818 if (!sourceAndTargetTypesMatch) {
819 return cloneUnlessOtherwiseSpecified(source, options);
820 } else if (sourceIsArray) {
821 return options.arrayMerge(target, source, options);
822 } else {
823 return mergeObject(target, source, options);
824 }
825 }
826 deepmerge.all = function deepmergeAll(array, options) {
827 if (!Array.isArray(array)) {
828 throw new Error("first argument should be an array");
829 }
830 return array.reduce(function(prev, next) {
831 return deepmerge(prev, next, options);
832 }, {});
833 };
834 var deepmerge_1 = deepmerge;
835 module.exports = deepmerge_1;
836 }
837 });
838
839 // package-external:@wordpress/deprecated
840 var require_deprecated = __commonJS({
841 "package-external:@wordpress/deprecated"(exports, module) {
842 module.exports = window.wp.deprecated;
843 }
844 });
845
846 // package-external:@wordpress/notices
847 var require_notices = __commonJS({
848 "package-external:@wordpress/notices"(exports, module) {
849 module.exports = window.wp.notices;
850 }
851 });
852
853 // package-external:@wordpress/api-fetch
854 var require_api_fetch = __commonJS({
855 "package-external:@wordpress/api-fetch"(exports, module) {
856 module.exports = window.wp.apiFetch;
857 }
858 });
859
860 // package-external:@wordpress/blob
861 var require_blob = __commonJS({
862 "package-external:@wordpress/blob"(exports, module) {
863 module.exports = window.wp.blob;
864 }
865 });
866
867 // package-external:@wordpress/blocks
868 var require_blocks = __commonJS({
869 "package-external:@wordpress/blocks"(exports, module) {
870 module.exports = window.wp.blocks;
871 }
872 });
873
874 // node_modules/clsx/dist/clsx.mjs
875 function r(e2) {
876 var t2, f2, n2 = "";
877 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
878 else if ("object" == typeof e2) if (Array.isArray(e2)) {
879 var o2 = e2.length;
880 for (t2 = 0; t2 < o2; t2++) e2[t2] && (f2 = r(e2[t2])) && (n2 && (n2 += " "), n2 += f2);
881 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
882 return n2;
883 }
884 function clsx() {
885 for (var e2, t2, f2 = 0, n2 = "", o2 = arguments.length; f2 < o2; f2++) (e2 = arguments[f2]) && (t2 = r(e2)) && (n2 && (n2 += " "), n2 += t2);
886 return n2;
887 }
888 var clsx_default = clsx;
889
890 // packages/ui/build-module/badge/badge.mjs
891 var import_element2 = __toESM(require_element(), 1);
892
893 // node_modules/@base-ui/utils/esm/useControlled.js
894 var React2 = __toESM(require_react(), 1);
895
896 // node_modules/@base-ui/utils/esm/error.js
897 var set;
898 if (true) {
899 set = /* @__PURE__ */ new Set();
900 }
901 function error(...messages) {
902 if (true) {
903 const messageKey = messages.join(" ");
904 if (!set.has(messageKey)) {
905 set.add(messageKey);
906 console.error(`Base UI: ${messageKey}`);
907 }
908 }
909 }
910
911 // node_modules/@base-ui/utils/esm/useControlled.js
912 function useControlled({
913 controlled,
914 default: defaultProp,
915 name,
916 state = "value"
917 }) {
918 const {
919 current: isControlled
920 } = React2.useRef(controlled !== void 0);
921 const [valueState, setValue] = React2.useState(defaultProp);
922 const value = isControlled ? controlled : valueState;
923 if (true) {
924 React2.useEffect(() => {
925 if (isControlled !== (controlled !== void 0)) {
926 error([`A component is changing the ${isControlled ? "" : "un"}controlled ${state} state of ${name} to be ${isControlled ? "un" : ""}controlled.`, "Elements should not switch from uncontrolled to controlled (or vice versa).", `Decide between using a controlled or uncontrolled ${name} element for the lifetime of the component.`, "The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.", "More info: https://fb.me/react-controlled-components"].join("\n"));
927 }
928 }, [state, name, controlled]);
929 const {
930 current: defaultValue2
931 } = React2.useRef(defaultProp);
932 React2.useEffect(() => {
933 if (!isControlled && serializeToDevModeString(defaultValue2) !== serializeToDevModeString(defaultProp)) {
934 error([`A component is changing the default ${state} state of an uncontrolled ${name} after being initialized. To suppress this warning opt to use a controlled ${name}.`].join("\n"));
935 }
936 }, [defaultProp]);
937 }
938 const setValueIfUncontrolled = React2.useCallback((newValue) => {
939 if (!isControlled) {
940 setValue(newValue);
941 }
942 }, []);
943 return [value, setValueIfUncontrolled];
944 }
945 function serializeToDevModeString(input) {
946 let nextId = 0;
947 const seen = /* @__PURE__ */ new WeakMap();
948 try {
949 const result = JSON.stringify(input, function replacer(key, value) {
950 if (key === "_owner" && this != null && typeof this === "object" && "$$typeof" in this) {
951 return void 0;
952 }
953 if (typeof value === "bigint") {
954 return `__bigint__:${value}`;
955 }
956 if (value !== null && typeof value === "object") {
957 const id = seen.get(value);
958 if (id !== void 0) {
959 return `__object__:${id}`;
960 }
961 seen.set(value, nextId);
962 nextId += 1;
963 }
964 return value;
965 });
966 return result ?? `__top__:${typeof input}`;
967 } catch {
968 return "__unserializable__";
969 }
970 }
971
972 // node_modules/@base-ui/utils/esm/useStableCallback.js
973 var React4 = __toESM(require_react(), 1);
974
975 // node_modules/@base-ui/utils/esm/useRefWithInit.js
976 var React3 = __toESM(require_react(), 1);
977 var UNINITIALIZED = {};
978 function useRefWithInit(init2, initArg) {
979 const ref = React3.useRef(UNINITIALIZED);
980 if (ref.current === UNINITIALIZED) {
981 ref.current = init2(initArg);
982 }
983 return ref;
984 }
985
986 // node_modules/@base-ui/utils/esm/useStableCallback.js
987 var useInsertionEffect = React4[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)];
988 var useSafeInsertionEffect = (
989 // React 17 doesn't have useInsertionEffect.
990 useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
991 useInsertionEffect !== React4.useLayoutEffect ? useInsertionEffect : (fn) => fn()
992 );
993 function useStableCallback(callback) {
994 const stable = useRefWithInit(createStableCallback).current;
995 stable.next = callback;
996 useSafeInsertionEffect(stable.effect);
997 return stable.trampoline;
998 }
999 function createStableCallback() {
1000 const stable = {
1001 next: void 0,
1002 callback: assertNotCalled,
1003 trampoline: (...args) => stable.callback?.(...args),
1004 effect: () => {
1005 stable.callback = stable.next;
1006 }
1007 };
1008 return stable;
1009 }
1010 function assertNotCalled() {
1011 if (true) {
1012 throw (
1013 /* minify-error-disabled */
1014 new Error("Base UI: Cannot call an event handler while rendering.")
1015 );
1016 }
1017 }
1018
1019 // node_modules/@base-ui/utils/esm/useIsoLayoutEffect.js
1020 var React5 = __toESM(require_react(), 1);
1021 var noop = () => {
1022 };
1023 var useIsoLayoutEffect = typeof document !== "undefined" ? React5.useLayoutEffect : noop;
1024
1025 // node_modules/@base-ui/utils/esm/warn.js
1026 var set2;
1027 if (true) {
1028 set2 = /* @__PURE__ */ new Set();
1029 }
1030 function warn(...messages) {
1031 if (true) {
1032 const messageKey = messages.join(" ");
1033 if (!set2.has(messageKey)) {
1034 set2.add(messageKey);
1035 console.warn(`Base UI: ${messageKey}`);
1036 }
1037 }
1038 }
1039
1040 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1041 var React8 = __toESM(require_react(), 1);
1042
1043 // node_modules/@base-ui/utils/esm/useMergedRefs.js
1044 function useMergedRefs(a2, b2, c2, d2) {
1045 const forkRef = useRefWithInit(createForkRef).current;
1046 if (didChange(forkRef, a2, b2, c2, d2)) {
1047 update(forkRef, [a2, b2, c2, d2]);
1048 }
1049 return forkRef.callback;
1050 }
1051 function useMergedRefsN(refs) {
1052 const forkRef = useRefWithInit(createForkRef).current;
1053 if (didChangeN(forkRef, refs)) {
1054 update(forkRef, refs);
1055 }
1056 return forkRef.callback;
1057 }
1058 function createForkRef() {
1059 return {
1060 callback: null,
1061 cleanup: null,
1062 refs: []
1063 };
1064 }
1065 function didChange(forkRef, a2, b2, c2, d2) {
1066 return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
1067 }
1068 function didChangeN(forkRef, newRefs) {
1069 return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1070 }
1071 function update(forkRef, refs) {
1072 forkRef.refs = refs;
1073 if (refs.every((ref) => ref == null)) {
1074 forkRef.callback = null;
1075 return;
1076 }
1077 forkRef.callback = (instance) => {
1078 if (forkRef.cleanup) {
1079 forkRef.cleanup();
1080 forkRef.cleanup = null;
1081 }
1082 if (instance != null) {
1083 const cleanupCallbacks = Array(refs.length).fill(null);
1084 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1085 const ref = refs[i2];
1086 if (ref == null) {
1087 continue;
1088 }
1089 switch (typeof ref) {
1090 case "function": {
1091 const refCleanup = ref(instance);
1092 if (typeof refCleanup === "function") {
1093 cleanupCallbacks[i2] = refCleanup;
1094 }
1095 break;
1096 }
1097 case "object": {
1098 ref.current = instance;
1099 break;
1100 }
1101 default:
1102 }
1103 }
1104 forkRef.cleanup = () => {
1105 for (let i2 = 0; i2 < refs.length; i2 += 1) {
1106 const ref = refs[i2];
1107 if (ref == null) {
1108 continue;
1109 }
1110 switch (typeof ref) {
1111 case "function": {
1112 const cleanupCallback = cleanupCallbacks[i2];
1113 if (typeof cleanupCallback === "function") {
1114 cleanupCallback();
1115 } else {
1116 ref(null);
1117 }
1118 break;
1119 }
1120 case "object": {
1121 ref.current = null;
1122 break;
1123 }
1124 default:
1125 }
1126 }
1127 };
1128 }
1129 };
1130 }
1131
1132 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1133 var React7 = __toESM(require_react(), 1);
1134
1135 // node_modules/@base-ui/utils/esm/reactVersion.js
1136 var React6 = __toESM(require_react(), 1);
1137 var majorVersion = parseInt(React6.version, 10);
1138 function isReactVersionAtLeast(reactVersionToCheck) {
1139 return majorVersion >= reactVersionToCheck;
1140 }
1141
1142 // node_modules/@base-ui/utils/esm/getReactElementRef.js
1143 function getReactElementRef(element) {
1144 if (!/* @__PURE__ */ React7.isValidElement(element)) {
1145 return null;
1146 }
1147 const reactElement = element;
1148 const propsWithRef = reactElement.props;
1149 return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1150 }
1151
1152 // node_modules/@base-ui/utils/esm/mergeObjects.js
1153 function mergeObjects(a2, b2) {
1154 if (a2 && !b2) {
1155 return a2;
1156 }
1157 if (!a2 && b2) {
1158 return b2;
1159 }
1160 if (a2 || b2) {
1161 return {
1162 ...a2,
1163 ...b2
1164 };
1165 }
1166 return void 0;
1167 }
1168
1169 // node_modules/@base-ui/utils/esm/empty.js
1170 var EMPTY_ARRAY = Object.freeze([]);
1171 var EMPTY_OBJECT = Object.freeze({});
1172
1173 // node_modules/@base-ui/react/esm/internals/getStateAttributesProps.js
1174 function getStateAttributesProps(state, customMapping) {
1175 const props = {};
1176 for (const key in state) {
1177 const value = state[key];
1178 if (customMapping?.hasOwnProperty(key)) {
1179 const customProps = customMapping[key](value);
1180 if (customProps != null) {
1181 Object.assign(props, customProps);
1182 }
1183 continue;
1184 }
1185 if (value === true) {
1186 props[`data-${key.toLowerCase()}`] = "";
1187 } else if (value) {
1188 props[`data-${key.toLowerCase()}`] = value.toString();
1189 }
1190 }
1191 return props;
1192 }
1193
1194 // node_modules/@base-ui/react/esm/utils/resolveClassName.js
1195 function resolveClassName(className, state) {
1196 return typeof className === "function" ? className(state) : className;
1197 }
1198
1199 // node_modules/@base-ui/react/esm/utils/resolveStyle.js
1200 function resolveStyle(style, state) {
1201 return typeof style === "function" ? style(state) : style;
1202 }
1203
1204 // node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1205 var EMPTY_PROPS = {};
1206 function mergeProps(a2, b2, c2, d2, e2) {
1207 if (!c2 && !d2 && !e2 && !a2) {
1208 return createInitialMergedProps(b2);
1209 }
1210 let merged = createInitialMergedProps(a2);
1211 if (b2) {
1212 merged = mergeInto(merged, b2);
1213 }
1214 if (c2) {
1215 merged = mergeInto(merged, c2);
1216 }
1217 if (d2) {
1218 merged = mergeInto(merged, d2);
1219 }
1220 if (e2) {
1221 merged = mergeInto(merged, e2);
1222 }
1223 return merged;
1224 }
1225 function mergePropsN(props) {
1226 if (props.length === 0) {
1227 return EMPTY_PROPS;
1228 }
1229 if (props.length === 1) {
1230 return createInitialMergedProps(props[0]);
1231 }
1232 let merged = createInitialMergedProps(props[0]);
1233 for (let i2 = 1; i2 < props.length; i2 += 1) {
1234 merged = mergeInto(merged, props[i2]);
1235 }
1236 return merged;
1237 }
1238 function createInitialMergedProps(inputProps) {
1239 if (isPropsGetter(inputProps)) {
1240 return {
1241 ...resolvePropsGetter(inputProps, EMPTY_PROPS)
1242 };
1243 }
1244 return copyInitialProps(inputProps);
1245 }
1246 function mergeInto(merged, inputProps) {
1247 if (isPropsGetter(inputProps)) {
1248 return resolvePropsGetter(inputProps, merged);
1249 }
1250 return mutablyMergeInto(merged, inputProps);
1251 }
1252 function copyInitialProps(inputProps) {
1253 const copiedProps = {
1254 ...inputProps
1255 };
1256 for (const propName in copiedProps) {
1257 const propValue = copiedProps[propName];
1258 if (isEventHandler(propName, propValue)) {
1259 copiedProps[propName] = wrapEventHandler(propValue);
1260 }
1261 }
1262 return copiedProps;
1263 }
1264 function mutablyMergeInto(mergedProps, externalProps) {
1265 if (!externalProps) {
1266 return mergedProps;
1267 }
1268 for (const propName in externalProps) {
1269 const externalPropValue = externalProps[propName];
1270 switch (propName) {
1271 case "style": {
1272 mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1273 break;
1274 }
1275 case "className": {
1276 mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1277 break;
1278 }
1279 default: {
1280 if (isEventHandler(propName, externalPropValue)) {
1281 mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1282 } else {
1283 mergedProps[propName] = externalPropValue;
1284 }
1285 }
1286 }
1287 }
1288 return mergedProps;
1289 }
1290 function isEventHandler(key, value) {
1291 const code0 = key.charCodeAt(0);
1292 const code1 = key.charCodeAt(1);
1293 const code2 = key.charCodeAt(2);
1294 return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1295 }
1296 function isPropsGetter(inputProps) {
1297 return typeof inputProps === "function";
1298 }
1299 function resolvePropsGetter(inputProps, previousProps) {
1300 if (isPropsGetter(inputProps)) {
1301 return inputProps(previousProps);
1302 }
1303 return inputProps ?? EMPTY_PROPS;
1304 }
1305 function mergeEventHandlers(ourHandler, theirHandler) {
1306 if (!theirHandler) {
1307 return ourHandler;
1308 }
1309 if (!ourHandler) {
1310 return wrapEventHandler(theirHandler);
1311 }
1312 return (...args) => {
1313 const event = args[0];
1314 if (isSyntheticEvent(event)) {
1315 const baseUIEvent = event;
1316 makeEventPreventable(baseUIEvent);
1317 const result2 = theirHandler(...args);
1318 if (!baseUIEvent.baseUIHandlerPrevented) {
1319 ourHandler?.(...args);
1320 }
1321 return result2;
1322 }
1323 const result = theirHandler(...args);
1324 ourHandler?.(...args);
1325 return result;
1326 };
1327 }
1328 function wrapEventHandler(handler) {
1329 if (!handler) {
1330 return handler;
1331 }
1332 return (...args) => {
1333 const event = args[0];
1334 if (isSyntheticEvent(event)) {
1335 makeEventPreventable(event);
1336 }
1337 return handler(...args);
1338 };
1339 }
1340 function makeEventPreventable(event) {
1341 event.preventBaseUIHandler = () => {
1342 event.baseUIHandlerPrevented = true;
1343 };
1344 return event;
1345 }
1346 function mergeClassNames(ourClassName, theirClassName) {
1347 if (theirClassName) {
1348 if (ourClassName) {
1349 return theirClassName + " " + ourClassName;
1350 }
1351 return theirClassName;
1352 }
1353 return ourClassName;
1354 }
1355 function isSyntheticEvent(event) {
1356 return event != null && typeof event === "object" && "nativeEvent" in event;
1357 }
1358
1359 // node_modules/@base-ui/react/esm/internals/useRenderElement.js
1360 var import_react = __toESM(require_react(), 1);
1361 function useRenderElement(element, componentProps, params = {}) {
1362 const renderProp = componentProps.render;
1363 const outProps = useRenderElementProps(componentProps, params);
1364 if (params.enabled === false) {
1365 return null;
1366 }
1367 const state = params.state ?? EMPTY_OBJECT;
1368 return evaluateRenderProp(element, renderProp, outProps, state);
1369 }
1370 function useRenderElementProps(componentProps, params = {}) {
1371 const {
1372 className: classNameProp,
1373 style: styleProp,
1374 render: renderProp
1375 } = componentProps;
1376 const {
1377 state = EMPTY_OBJECT,
1378 ref,
1379 props,
1380 stateAttributesMapping: stateAttributesMapping2,
1381 enabled = true
1382 } = params;
1383 const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1384 const style = enabled ? resolveStyle(styleProp, state) : void 0;
1385 const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping2) : EMPTY_OBJECT;
1386 const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1387 const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1388 if (typeof document !== "undefined") {
1389 if (!enabled) {
1390 useMergedRefs(null, null);
1391 } else if (Array.isArray(ref)) {
1392 outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1393 } else {
1394 outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1395 }
1396 }
1397 if (!enabled) {
1398 return EMPTY_OBJECT;
1399 }
1400 if (className !== void 0) {
1401 outProps.className = mergeClassNames(outProps.className, className);
1402 }
1403 if (style !== void 0) {
1404 outProps.style = mergeObjects(outProps.style, style);
1405 }
1406 return outProps;
1407 }
1408 function resolveRenderFunctionProps(props) {
1409 if (Array.isArray(props)) {
1410 return mergePropsN(props);
1411 }
1412 return mergeProps(void 0, props);
1413 }
1414 var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
1415 var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1416 var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1417 function evaluateRenderProp(element, render4, props, state) {
1418 if (render4) {
1419 if (typeof render4 === "function") {
1420 if (true) {
1421 warnIfRenderPropLooksLikeComponent(render4);
1422 }
1423 return render4(props, state);
1424 }
1425 const mergedProps = mergeProps(props, render4.props);
1426 mergedProps.ref = props.ref;
1427 let newElement = render4;
1428 if (newElement?.$$typeof === REACT_LAZY_TYPE) {
1429 const children = React8.Children.toArray(render4);
1430 newElement = children[0];
1431 }
1432 if (true) {
1433 if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
1434 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"));
1435 }
1436 }
1437 return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
1438 }
1439 if (element) {
1440 if (typeof element === "string") {
1441 return renderTag(element, props);
1442 }
1443 }
1444 throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
1445 }
1446 function warnIfRenderPropLooksLikeComponent(renderFn) {
1447 const functionName = renderFn.name;
1448 if (functionName.length === 0) {
1449 return;
1450 }
1451 if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
1452 return;
1453 }
1454 if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
1455 return;
1456 }
1457 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");
1458 }
1459 function renderTag(Tag, props) {
1460 if (Tag === "button") {
1461 return /* @__PURE__ */ (0, import_react.createElement)("button", {
1462 type: "button",
1463 ...props,
1464 key: props.key
1465 });
1466 }
1467 if (Tag === "img") {
1468 return /* @__PURE__ */ (0, import_react.createElement)("img", {
1469 alt: "",
1470 ...props,
1471 key: props.key
1472 });
1473 }
1474 return /* @__PURE__ */ React8.createElement(Tag, props);
1475 }
1476
1477 // node_modules/@base-ui/react/esm/internals/reason-parts.js
1478 var reason_parts_exports = {};
1479 __export(reason_parts_exports, {
1480 cancelOpen: () => cancelOpen,
1481 chipRemovePress: () => chipRemovePress,
1482 clearPress: () => clearPress,
1483 closePress: () => closePress,
1484 closeWatcher: () => closeWatcher,
1485 decrementPress: () => decrementPress,
1486 disabled: () => disabled,
1487 drag: () => drag,
1488 escapeKey: () => escapeKey,
1489 focusOut: () => focusOut,
1490 imperativeAction: () => imperativeAction,
1491 incrementPress: () => incrementPress,
1492 inputBlur: () => inputBlur,
1493 inputChange: () => inputChange,
1494 inputClear: () => inputClear,
1495 inputPaste: () => inputPaste,
1496 inputPress: () => inputPress,
1497 itemPress: () => itemPress,
1498 keyboard: () => keyboard,
1499 linkPress: () => linkPress,
1500 listNavigation: () => listNavigation,
1501 none: () => none,
1502 outsidePress: () => outsidePress,
1503 pointer: () => pointer,
1504 scrub: () => scrub,
1505 siblingOpen: () => siblingOpen,
1506 swipe: () => swipe,
1507 trackPress: () => trackPress,
1508 triggerFocus: () => triggerFocus,
1509 triggerHover: () => triggerHover,
1510 triggerPress: () => triggerPress,
1511 wheel: () => wheel,
1512 windowResize: () => windowResize
1513 });
1514 var none = "none";
1515 var triggerPress = "trigger-press";
1516 var triggerHover = "trigger-hover";
1517 var triggerFocus = "trigger-focus";
1518 var outsidePress = "outside-press";
1519 var itemPress = "item-press";
1520 var closePress = "close-press";
1521 var linkPress = "link-press";
1522 var clearPress = "clear-press";
1523 var chipRemovePress = "chip-remove-press";
1524 var trackPress = "track-press";
1525 var incrementPress = "increment-press";
1526 var decrementPress = "decrement-press";
1527 var inputChange = "input-change";
1528 var inputClear = "input-clear";
1529 var inputBlur = "input-blur";
1530 var inputPaste = "input-paste";
1531 var inputPress = "input-press";
1532 var focusOut = "focus-out";
1533 var escapeKey = "escape-key";
1534 var closeWatcher = "close-watcher";
1535 var listNavigation = "list-navigation";
1536 var keyboard = "keyboard";
1537 var pointer = "pointer";
1538 var drag = "drag";
1539 var wheel = "wheel";
1540 var scrub = "scrub";
1541 var cancelOpen = "cancel-open";
1542 var siblingOpen = "sibling-open";
1543 var disabled = "disabled";
1544 var imperativeAction = "imperative-action";
1545 var swipe = "swipe";
1546 var windowResize = "window-resize";
1547
1548 // node_modules/@base-ui/react/esm/internals/createBaseUIEventDetails.js
1549 function createChangeEventDetails(reason, event, trigger, customProperties) {
1550 let canceled = false;
1551 let allowPropagation = false;
1552 const custom = customProperties ?? EMPTY_OBJECT;
1553 const details = {
1554 reason,
1555 event: event ?? new Event("base-ui"),
1556 cancel() {
1557 canceled = true;
1558 },
1559 allowPropagation() {
1560 allowPropagation = true;
1561 },
1562 get isCanceled() {
1563 return canceled;
1564 },
1565 get isPropagationAllowed() {
1566 return allowPropagation;
1567 },
1568 trigger,
1569 ...custom
1570 };
1571 return details;
1572 }
1573
1574 // node_modules/@base-ui/utils/esm/useId.js
1575 var React10 = __toESM(require_react(), 1);
1576
1577 // node_modules/@base-ui/utils/esm/safeReact.js
1578 var React9 = __toESM(require_react(), 1);
1579 var SafeReact = {
1580 ...React9
1581 };
1582
1583 // node_modules/@base-ui/utils/esm/useId.js
1584 var globalId = 0;
1585 function useGlobalId(idOverride, prefix = "mui") {
1586 const [defaultId, setDefaultId] = React10.useState(idOverride);
1587 const id = idOverride || defaultId;
1588 React10.useEffect(() => {
1589 if (defaultId == null) {
1590 globalId += 1;
1591 setDefaultId(`${prefix}-${globalId}`);
1592 }
1593 }, [defaultId, prefix]);
1594 return id;
1595 }
1596 var maybeReactUseId = SafeReact.useId;
1597 function useId(idOverride, prefix) {
1598 if (maybeReactUseId !== void 0) {
1599 const reactId = maybeReactUseId();
1600 return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
1601 }
1602 return useGlobalId(idOverride, prefix);
1603 }
1604
1605 // node_modules/@base-ui/react/esm/internals/useBaseUiId.js
1606 function useBaseUiId(idOverride) {
1607 return useId(idOverride, "base-ui");
1608 }
1609
1610 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1611 var React13 = __toESM(require_react(), 1);
1612
1613 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1614 var ReactDOM = __toESM(require_react_dom(), 1);
1615
1616 // node_modules/@base-ui/utils/esm/useOnMount.js
1617 var React11 = __toESM(require_react(), 1);
1618 var EMPTY = [];
1619 function useOnMount(fn) {
1620 React11.useEffect(fn, EMPTY);
1621 }
1622
1623 // node_modules/@base-ui/utils/esm/useAnimationFrame.js
1624 var EMPTY2 = null;
1625 var LAST_RAF = globalThis.requestAnimationFrame;
1626 var Scheduler = class {
1627 /* This implementation uses an array as a backing data-structure for frame callbacks.
1628 * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
1629 * never calls the native `cancelAnimationFrame` if there are no frames left. This can
1630 * be much more efficient if there is a call pattern that alterns as
1631 * "request-cancel-request-cancel-…".
1632 * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
1633 * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
1634 callbacks = [];
1635 callbacksCount = 0;
1636 nextId = 1;
1637 startId = 1;
1638 isScheduled = false;
1639 tick = (timestamp) => {
1640 this.isScheduled = false;
1641 const currentCallbacks = this.callbacks;
1642 const currentCallbacksCount = this.callbacksCount;
1643 this.callbacks = [];
1644 this.callbacksCount = 0;
1645 this.startId = this.nextId;
1646 if (currentCallbacksCount > 0) {
1647 for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
1648 currentCallbacks[i2]?.(timestamp);
1649 }
1650 }
1651 };
1652 request(fn) {
1653 const id = this.nextId;
1654 this.nextId += 1;
1655 this.callbacks.push(fn);
1656 this.callbacksCount += 1;
1657 const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
1658 if (!this.isScheduled || didRAFChange) {
1659 requestAnimationFrame(this.tick);
1660 this.isScheduled = true;
1661 }
1662 return id;
1663 }
1664 cancel(id) {
1665 const index = id - this.startId;
1666 if (index < 0 || index >= this.callbacks.length) {
1667 return;
1668 }
1669 this.callbacks[index] = null;
1670 this.callbacksCount -= 1;
1671 }
1672 };
1673 var scheduler = new Scheduler();
1674 var AnimationFrame = class _AnimationFrame {
1675 static create() {
1676 return new _AnimationFrame();
1677 }
1678 static request(fn) {
1679 return scheduler.request(fn);
1680 }
1681 static cancel(id) {
1682 return scheduler.cancel(id);
1683 }
1684 currentId = EMPTY2;
1685 /**
1686 * Executes `fn` after `delay`, clearing any previously scheduled call.
1687 */
1688 request(fn) {
1689 this.cancel();
1690 this.currentId = scheduler.request(() => {
1691 this.currentId = EMPTY2;
1692 fn();
1693 });
1694 }
1695 cancel = () => {
1696 if (this.currentId !== EMPTY2) {
1697 scheduler.cancel(this.currentId);
1698 this.currentId = EMPTY2;
1699 }
1700 };
1701 disposeEffect = () => {
1702 return this.cancel;
1703 };
1704 };
1705 function useAnimationFrame() {
1706 const timeout = useRefWithInit(AnimationFrame.create).current;
1707 useOnMount(timeout.disposeEffect);
1708 return timeout;
1709 }
1710
1711 // node_modules/@base-ui/react/esm/utils/resolveRef.js
1712 function resolveRef(maybeRef) {
1713 if (maybeRef == null) {
1714 return maybeRef;
1715 }
1716 return "current" in maybeRef ? maybeRef.current : maybeRef;
1717 }
1718
1719 // node_modules/@base-ui/react/esm/internals/stateAttributesMapping.js
1720 var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
1721 TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
1722 TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
1723 return TransitionStatusDataAttributes2;
1724 })({});
1725 var STARTING_HOOK = {
1726 [TransitionStatusDataAttributes.startingStyle]: ""
1727 };
1728 var ENDING_HOOK = {
1729 [TransitionStatusDataAttributes.endingStyle]: ""
1730 };
1731 var transitionStatusMapping = {
1732 transitionStatus(value) {
1733 if (value === "starting") {
1734 return STARTING_HOOK;
1735 }
1736 if (value === "ending") {
1737 return ENDING_HOOK;
1738 }
1739 return null;
1740 }
1741 };
1742
1743 // node_modules/@base-ui/react/esm/internals/useAnimationsFinished.js
1744 function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
1745 const frame = useAnimationFrame();
1746 return useStableCallback((fnToExecute, signal = null) => {
1747 frame.cancel();
1748 const element = resolveRef(elementOrRef);
1749 if (element == null) {
1750 return;
1751 }
1752 const resolvedElement = element;
1753 const done = () => {
1754 ReactDOM.flushSync(fnToExecute);
1755 };
1756 if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
1757 fnToExecute();
1758 return;
1759 }
1760 function exec() {
1761 Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
1762 if (!signal?.aborted) {
1763 done();
1764 }
1765 }).catch(() => {
1766 if (treatAbortedAsFinished) {
1767 if (!signal?.aborted) {
1768 done();
1769 }
1770 return;
1771 }
1772 const currentAnimations = resolvedElement.getAnimations();
1773 if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
1774 exec();
1775 }
1776 });
1777 }
1778 if (waitForStartingStyleRemoved) {
1779 const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
1780 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1781 frame.request(exec);
1782 return;
1783 }
1784 const attributeObserver = new MutationObserver(() => {
1785 if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
1786 attributeObserver.disconnect();
1787 exec();
1788 }
1789 });
1790 attributeObserver.observe(resolvedElement, {
1791 attributes: true,
1792 attributeFilter: [startingStyleAttribute]
1793 });
1794 signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
1795 once: true
1796 });
1797 return;
1798 }
1799 frame.request(exec);
1800 });
1801 }
1802
1803 // node_modules/@base-ui/react/esm/internals/useTransitionStatus.js
1804 var React12 = __toESM(require_react(), 1);
1805 function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
1806 const [transitionStatus, setTransitionStatus] = React12.useState(open && enableIdleState ? "idle" : void 0);
1807 const [mounted, setMounted] = React12.useState(open);
1808 if (open && !mounted) {
1809 setMounted(true);
1810 setTransitionStatus("starting");
1811 }
1812 if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
1813 setTransitionStatus("ending");
1814 }
1815 if (!open && !mounted && transitionStatus === "ending") {
1816 setTransitionStatus(void 0);
1817 }
1818 useIsoLayoutEffect(() => {
1819 if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
1820 const frame = AnimationFrame.request(() => {
1821 setTransitionStatus("ending");
1822 });
1823 return () => {
1824 AnimationFrame.cancel(frame);
1825 };
1826 }
1827 return void 0;
1828 }, [open, mounted, transitionStatus, deferEndingState]);
1829 useIsoLayoutEffect(() => {
1830 if (!open || enableIdleState) {
1831 return void 0;
1832 }
1833 const frame = AnimationFrame.request(() => {
1834 setTransitionStatus(void 0);
1835 });
1836 return () => {
1837 AnimationFrame.cancel(frame);
1838 };
1839 }, [enableIdleState, open]);
1840 useIsoLayoutEffect(() => {
1841 if (!open || !enableIdleState) {
1842 return void 0;
1843 }
1844 if (open && mounted && transitionStatus !== "idle") {
1845 setTransitionStatus("starting");
1846 }
1847 const frame = AnimationFrame.request(() => {
1848 setTransitionStatus("idle");
1849 });
1850 return () => {
1851 AnimationFrame.cancel(frame);
1852 };
1853 }, [enableIdleState, open, mounted, transitionStatus]);
1854 return {
1855 mounted,
1856 setMounted,
1857 transitionStatus
1858 };
1859 }
1860
1861 // node_modules/@base-ui/react/esm/collapsible/root/useCollapsibleRoot.js
1862 function useCollapsibleRoot(parameters) {
1863 const {
1864 open: openParam,
1865 defaultOpen,
1866 onOpenChange,
1867 disabled: disabled2
1868 } = parameters;
1869 const isControlled = openParam !== void 0;
1870 const [open, setOpen] = useControlled({
1871 controlled: openParam,
1872 default: defaultOpen,
1873 name: "Collapsible",
1874 state: "open"
1875 });
1876 const {
1877 mounted,
1878 setMounted,
1879 transitionStatus
1880 } = useTransitionStatus(open, true, true);
1881 const [visible, setVisible] = React13.useState(open);
1882 const [{
1883 height,
1884 width
1885 }, setDimensions] = React13.useState({
1886 height: void 0,
1887 width: void 0
1888 });
1889 const defaultPanelId = useBaseUiId();
1890 const [panelIdState, setPanelIdState] = React13.useState();
1891 const panelId = panelIdState ?? defaultPanelId;
1892 const [hiddenUntilFound, setHiddenUntilFound] = React13.useState(false);
1893 const [keepMounted, setKeepMounted] = React13.useState(false);
1894 const abortControllerRef = React13.useRef(null);
1895 const animationTypeRef = React13.useRef(null);
1896 const transitionDimensionRef = React13.useRef(null);
1897 const panelRef = React13.useRef(null);
1898 const runOnceAnimationsFinish = useAnimationsFinished(panelRef, false);
1899 const handleTrigger = useStableCallback((event) => {
1900 const nextOpen = !open;
1901 const eventDetails = createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent);
1902 onOpenChange(nextOpen, eventDetails);
1903 if (eventDetails.isCanceled) {
1904 return;
1905 }
1906 const panel = panelRef.current;
1907 if (animationTypeRef.current === "css-animation" && panel != null) {
1908 panel.style.removeProperty("animation-name");
1909 }
1910 if (!hiddenUntilFound && !keepMounted) {
1911 if (animationTypeRef.current != null && animationTypeRef.current !== "css-animation") {
1912 if (!mounted && nextOpen) {
1913 setMounted(true);
1914 }
1915 }
1916 if (animationTypeRef.current === "css-animation") {
1917 if (!visible && nextOpen) {
1918 setVisible(true);
1919 }
1920 if (!mounted && nextOpen) {
1921 setMounted(true);
1922 }
1923 }
1924 }
1925 setOpen(nextOpen);
1926 if (animationTypeRef.current === "none" && mounted && !nextOpen) {
1927 setMounted(false);
1928 }
1929 });
1930 useIsoLayoutEffect(() => {
1931 if (isControlled && animationTypeRef.current === "none" && !open) {
1932 setMounted(false);
1933 }
1934 }, [isControlled, open, openParam, setMounted]);
1935 return React13.useMemo(() => ({
1936 abortControllerRef,
1937 animationTypeRef,
1938 disabled: disabled2,
1939 handleTrigger,
1940 height,
1941 mounted,
1942 open,
1943 panelId,
1944 panelRef,
1945 runOnceAnimationsFinish,
1946 setDimensions,
1947 setHiddenUntilFound,
1948 setKeepMounted,
1949 setMounted,
1950 setOpen,
1951 setPanelIdState,
1952 setVisible,
1953 transitionDimensionRef,
1954 transitionStatus,
1955 visible,
1956 width
1957 }), [abortControllerRef, animationTypeRef, disabled2, handleTrigger, height, mounted, open, panelId, panelRef, runOnceAnimationsFinish, setDimensions, setHiddenUntilFound, setKeepMounted, setMounted, setOpen, setVisible, transitionDimensionRef, transitionStatus, visible, width]);
1958 }
1959
1960 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRootContext.js
1961 var React14 = __toESM(require_react(), 1);
1962 var CollapsibleRootContext = /* @__PURE__ */ React14.createContext(void 0);
1963 if (true) CollapsibleRootContext.displayName = "CollapsibleRootContext";
1964 function useCollapsibleRootContext() {
1965 const context = React14.useContext(CollapsibleRootContext);
1966 if (context === void 0) {
1967 throw new Error(true ? "Base UI: CollapsibleRootContext is missing. Collapsible parts must be placed within <Collapsible.Root>." : formatErrorMessage_default(15));
1968 }
1969 return context;
1970 }
1971
1972 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelDataAttributes.js
1973 var CollapsiblePanelDataAttributes = (function(CollapsiblePanelDataAttributes2) {
1974 CollapsiblePanelDataAttributes2["open"] = "data-open";
1975 CollapsiblePanelDataAttributes2["closed"] = "data-closed";
1976 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
1977 CollapsiblePanelDataAttributes2[CollapsiblePanelDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
1978 return CollapsiblePanelDataAttributes2;
1979 })({});
1980
1981 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTriggerDataAttributes.js
1982 var CollapsibleTriggerDataAttributes = /* @__PURE__ */ (function(CollapsibleTriggerDataAttributes2) {
1983 CollapsibleTriggerDataAttributes2["panelOpen"] = "data-panel-open";
1984 return CollapsibleTriggerDataAttributes2;
1985 })({});
1986
1987 // node_modules/@base-ui/react/esm/utils/collapsibleOpenStateMapping.js
1988 var PANEL_OPEN_HOOK = {
1989 [CollapsiblePanelDataAttributes.open]: ""
1990 };
1991 var PANEL_CLOSED_HOOK = {
1992 [CollapsiblePanelDataAttributes.closed]: ""
1993 };
1994 var triggerOpenStateMapping = {
1995 open(value) {
1996 if (value) {
1997 return {
1998 [CollapsibleTriggerDataAttributes.panelOpen]: ""
1999 };
2000 }
2001 return null;
2002 }
2003 };
2004 var collapsibleOpenStateMapping = {
2005 open(value) {
2006 if (value) {
2007 return PANEL_OPEN_HOOK;
2008 }
2009 return PANEL_CLOSED_HOOK;
2010 }
2011 };
2012
2013 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2014 var React17 = __toESM(require_react(), 1);
2015
2016 // node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
2017 function hasWindow() {
2018 return typeof window !== "undefined";
2019 }
2020 function getWindow(node) {
2021 var _node$ownerDocument;
2022 return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2023 }
2024 function isHTMLElement(value) {
2025 if (!hasWindow()) {
2026 return false;
2027 }
2028 return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2029 }
2030
2031 // node_modules/@base-ui/react/esm/internals/composite/root/CompositeRootContext.js
2032 var React15 = __toESM(require_react(), 1);
2033 var CompositeRootContext = /* @__PURE__ */ React15.createContext(void 0);
2034 if (true) CompositeRootContext.displayName = "CompositeRootContext";
2035 function useCompositeRootContext(optional = false) {
2036 const context = React15.useContext(CompositeRootContext);
2037 if (context === void 0 && !optional) {
2038 throw new Error(true ? "Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>." : formatErrorMessage_default(16));
2039 }
2040 return context;
2041 }
2042
2043 // node_modules/@base-ui/react/esm/utils/useFocusableWhenDisabled.js
2044 var React16 = __toESM(require_react(), 1);
2045 function useFocusableWhenDisabled(parameters) {
2046 const {
2047 focusableWhenDisabled,
2048 disabled: disabled2,
2049 composite = false,
2050 tabIndex: tabIndexProp = 0,
2051 isNativeButton
2052 } = parameters;
2053 const isFocusableComposite = composite && focusableWhenDisabled !== false;
2054 const isNonFocusableComposite = composite && focusableWhenDisabled === false;
2055 const props = React16.useMemo(() => {
2056 const additionalProps = {
2057 // allow Tabbing away from focusableWhenDisabled elements
2058 onKeyDown(event) {
2059 if (disabled2 && focusableWhenDisabled && event.key !== "Tab") {
2060 event.preventDefault();
2061 }
2062 }
2063 };
2064 if (!composite) {
2065 additionalProps.tabIndex = tabIndexProp;
2066 if (!isNativeButton && disabled2) {
2067 additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;
2068 }
2069 }
2070 if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled2) {
2071 additionalProps["aria-disabled"] = disabled2;
2072 }
2073 if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {
2074 additionalProps.disabled = disabled2;
2075 }
2076 return additionalProps;
2077 }, [composite, disabled2, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);
2078 return {
2079 props
2080 };
2081 }
2082
2083 // node_modules/@base-ui/react/esm/internals/use-button/useButton.js
2084 function useButton(parameters = {}) {
2085 const {
2086 disabled: disabled2 = false,
2087 focusableWhenDisabled,
2088 tabIndex = 0,
2089 native: isNativeButton = true,
2090 composite: compositeProp
2091 } = parameters;
2092 const elementRef = React17.useRef(null);
2093 const compositeRootContext = useCompositeRootContext(true);
2094 const isCompositeItem = compositeProp ?? compositeRootContext !== void 0;
2095 const {
2096 props: focusableWhenDisabledProps
2097 } = useFocusableWhenDisabled({
2098 focusableWhenDisabled,
2099 disabled: disabled2,
2100 composite: isCompositeItem,
2101 tabIndex,
2102 isNativeButton
2103 });
2104 if (true) {
2105 React17.useEffect(() => {
2106 if (!elementRef.current) {
2107 return;
2108 }
2109 const isButtonTag = isButtonElement(elementRef.current);
2110 if (isNativeButton) {
2111 if (!isButtonTag) {
2112 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2113 const message2 = "A component that acts as a button expected a native <button> because the `nativeButton` prop is true. Rendering a non-<button> removes native button semantics, which can impact forms and accessibility. Use a real <button> in the `render` prop, or set `nativeButton` to `false`.";
2114 error(`${message2}${ownerStackMessage}`);
2115 }
2116 } else if (isButtonTag) {
2117 const ownerStackMessage = SafeReact.captureOwnerStack?.() || "";
2118 const message2 = "A component that acts as a button expected a non-<button> because the `nativeButton` prop is false. Rendering a <button> keeps native behavior while Base UI applies non-native attributes and handlers, which can add unintended extra attributes (such as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set `nativeButton` to `true`.";
2119 error(`${message2}${ownerStackMessage}`);
2120 }
2121 }, [isNativeButton]);
2122 }
2123 const updateDisabled = React17.useCallback(() => {
2124 const element = elementRef.current;
2125 if (!isButtonElement(element)) {
2126 return;
2127 }
2128 if (isCompositeItem && disabled2 && focusableWhenDisabledProps.disabled === void 0 && element.disabled) {
2129 element.disabled = false;
2130 }
2131 }, [disabled2, focusableWhenDisabledProps.disabled, isCompositeItem]);
2132 useIsoLayoutEffect(updateDisabled, [updateDisabled]);
2133 const getButtonProps = React17.useCallback((externalProps = {}) => {
2134 const {
2135 onClick: externalOnClick,
2136 onMouseDown: externalOnMouseDown,
2137 onKeyUp: externalOnKeyUp,
2138 onKeyDown: externalOnKeyDown,
2139 onPointerDown: externalOnPointerDown,
2140 ...otherExternalProps
2141 } = externalProps;
2142 const type = isNativeButton ? "button" : void 0;
2143 return mergeProps({
2144 type,
2145 onClick(event) {
2146 if (disabled2) {
2147 event.preventDefault();
2148 return;
2149 }
2150 externalOnClick?.(event);
2151 },
2152 onMouseDown(event) {
2153 if (!disabled2) {
2154 externalOnMouseDown?.(event);
2155 }
2156 },
2157 onKeyDown(event) {
2158 if (disabled2) {
2159 return;
2160 }
2161 makeEventPreventable(event);
2162 externalOnKeyDown?.(event);
2163 if (event.baseUIHandlerPrevented) {
2164 return;
2165 }
2166 const isCurrentTarget = event.target === event.currentTarget;
2167 const currentTarget = event.currentTarget;
2168 const isButton2 = isButtonElement(currentTarget);
2169 const isLink = !isNativeButton && isValidLinkElement(currentTarget);
2170 const shouldClick = isCurrentTarget && (isNativeButton ? isButton2 : !isLink);
2171 const isEnterKey = event.key === "Enter";
2172 const isSpaceKey = event.key === " ";
2173 const role = currentTarget.getAttribute("role");
2174 const isTextNavigationRole = role?.startsWith("menuitem") || role === "option" || role === "gridcell";
2175 if (isCurrentTarget && isCompositeItem && isSpaceKey) {
2176 if (event.defaultPrevented && isTextNavigationRole) {
2177 return;
2178 }
2179 event.preventDefault();
2180 if (isLink || isNativeButton && isButton2) {
2181 currentTarget.click();
2182 event.preventBaseUIHandler();
2183 } else if (shouldClick) {
2184 externalOnClick?.(event);
2185 event.preventBaseUIHandler();
2186 }
2187 return;
2188 }
2189 if (shouldClick) {
2190 if (!isNativeButton && (isSpaceKey || isEnterKey)) {
2191 event.preventDefault();
2192 }
2193 if (!isNativeButton && isEnterKey) {
2194 externalOnClick?.(event);
2195 }
2196 }
2197 },
2198 onKeyUp(event) {
2199 if (disabled2) {
2200 return;
2201 }
2202 makeEventPreventable(event);
2203 externalOnKeyUp?.(event);
2204 if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === " ") {
2205 event.preventDefault();
2206 return;
2207 }
2208 if (event.baseUIHandlerPrevented) {
2209 return;
2210 }
2211 if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && event.key === " ") {
2212 externalOnClick?.(event);
2213 }
2214 },
2215 onPointerDown(event) {
2216 if (disabled2) {
2217 event.preventDefault();
2218 return;
2219 }
2220 externalOnPointerDown?.(event);
2221 }
2222 }, !isNativeButton ? {
2223 role: "button"
2224 } : void 0, focusableWhenDisabledProps, otherExternalProps);
2225 }, [disabled2, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);
2226 const buttonRef = useStableCallback((element) => {
2227 elementRef.current = element;
2228 updateDisabled();
2229 });
2230 return {
2231 getButtonProps,
2232 buttonRef
2233 };
2234 }
2235 function isButtonElement(elem) {
2236 return isHTMLElement(elem) && elem.tagName === "BUTTON";
2237 }
2238 function isValidLinkElement(elem) {
2239 return Boolean(elem?.tagName === "A" && elem?.href);
2240 }
2241
2242 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2243 var React18 = __toESM(require_react(), 1);
2244
2245 // node_modules/@base-ui/utils/esm/addEventListener.js
2246 function addEventListener(target, type, listener, options) {
2247 target.addEventListener(type, listener, options);
2248 return () => {
2249 target.removeEventListener(type, listener, options);
2250 };
2251 }
2252
2253 // node_modules/@base-ui/react/esm/accordion/root/AccordionRootDataAttributes.js
2254 var AccordionRootDataAttributes = /* @__PURE__ */ (function(AccordionRootDataAttributes2) {
2255 AccordionRootDataAttributes2["disabled"] = "data-disabled";
2256 AccordionRootDataAttributes2["orientation"] = "data-orientation";
2257 return AccordionRootDataAttributes2;
2258 })({});
2259
2260 // node_modules/@base-ui/react/esm/collapsible/panel/useCollapsiblePanel.js
2261 function useCollapsiblePanel(parameters) {
2262 const {
2263 abortControllerRef,
2264 animationTypeRef,
2265 externalRef,
2266 height,
2267 hiddenUntilFound,
2268 keepMounted,
2269 id: idParam,
2270 mounted,
2271 onOpenChange,
2272 open,
2273 panelRef,
2274 runOnceAnimationsFinish,
2275 setDimensions,
2276 setMounted,
2277 setOpen,
2278 setVisible,
2279 transitionDimensionRef,
2280 visible,
2281 width
2282 } = parameters;
2283 const isBeforeMatchRef = React18.useRef(false);
2284 const latestAnimationNameRef = React18.useRef(null);
2285 const shouldCancelInitialOpenAnimationRef = React18.useRef(open);
2286 const shouldCancelInitialOpenTransitionRef = React18.useRef(open);
2287 const endingStyleFrame = useAnimationFrame();
2288 const hidden = React18.useMemo(() => {
2289 if (animationTypeRef.current === "css-animation") {
2290 return !visible;
2291 }
2292 return !open && !mounted;
2293 }, [open, mounted, visible, animationTypeRef]);
2294 const handlePanelRef = useStableCallback((element) => {
2295 if (!element) {
2296 return void 0;
2297 }
2298 if (animationTypeRef.current == null || transitionDimensionRef.current == null) {
2299 const panelStyles = getComputedStyle(element);
2300 const hasAnimation = panelStyles.animationName !== "none" && panelStyles.animationName !== "";
2301 const hasTransition = panelStyles.transitionDuration !== "0s" && panelStyles.transitionDuration !== "";
2302 if (hasAnimation && hasTransition) {
2303 if (true) {
2304 warn("CSS transitions and CSS animations both detected on Collapsible or Accordion panel.", "Only one of either animation type should be used.");
2305 }
2306 } else if (panelStyles.animationName === "none" && panelStyles.transitionDuration !== "0s") {
2307 animationTypeRef.current = "css-transition";
2308 } else if (panelStyles.animationName !== "none" && panelStyles.transitionDuration === "0s") {
2309 animationTypeRef.current = "css-animation";
2310 } else {
2311 animationTypeRef.current = "none";
2312 }
2313 if (element.getAttribute(AccordionRootDataAttributes.orientation) === "horizontal" || panelStyles.transitionProperty.indexOf("width") > -1) {
2314 transitionDimensionRef.current = "width";
2315 } else {
2316 transitionDimensionRef.current = "height";
2317 }
2318 }
2319 if (animationTypeRef.current !== "css-transition") {
2320 return void 0;
2321 }
2322 if (height === void 0 || width === void 0) {
2323 setDimensions({
2324 height: element.scrollHeight,
2325 width: element.scrollWidth
2326 });
2327 if (shouldCancelInitialOpenTransitionRef.current) {
2328 element.style.setProperty("transition-duration", "0s");
2329 }
2330 }
2331 let frame = -1;
2332 let nextFrame = -1;
2333 frame = AnimationFrame.request(() => {
2334 shouldCancelInitialOpenTransitionRef.current = false;
2335 nextFrame = AnimationFrame.request(() => {
2336 setTimeout(() => {
2337 element.style.removeProperty("transition-duration");
2338 });
2339 });
2340 });
2341 return () => {
2342 AnimationFrame.cancel(frame);
2343 AnimationFrame.cancel(nextFrame);
2344 };
2345 });
2346 const mergedPanelRef = useMergedRefs(externalRef, panelRef, handlePanelRef);
2347 useIsoLayoutEffect(() => {
2348 if (animationTypeRef.current !== "css-transition") {
2349 return void 0;
2350 }
2351 const panel = panelRef.current;
2352 if (!panel) {
2353 return void 0;
2354 }
2355 let resizeFrame = -1;
2356 if (abortControllerRef.current != null) {
2357 abortControllerRef.current.abort();
2358 abortControllerRef.current = null;
2359 }
2360 if (open) {
2361 const originalLayoutStyles = {
2362 "justify-content": panel.style.justifyContent,
2363 "align-items": panel.style.alignItems,
2364 "align-content": panel.style.alignContent,
2365 "justify-items": panel.style.justifyItems
2366 };
2367 Object.keys(originalLayoutStyles).forEach((key) => {
2368 panel.style.setProperty(key, "initial", "important");
2369 });
2370 if (!shouldCancelInitialOpenTransitionRef.current && !keepMounted) {
2371 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
2372 }
2373 setDimensions({
2374 height: panel.scrollHeight,
2375 width: panel.scrollWidth
2376 });
2377 resizeFrame = AnimationFrame.request(() => {
2378 Object.entries(originalLayoutStyles).forEach(([key, value]) => {
2379 if (value === "") {
2380 panel.style.removeProperty(key);
2381 } else {
2382 panel.style.setProperty(key, value);
2383 }
2384 });
2385 });
2386 } else {
2387 if (panel.scrollHeight === 0 && panel.scrollWidth === 0) {
2388 return void 0;
2389 }
2390 setDimensions({
2391 height: panel.scrollHeight,
2392 width: panel.scrollWidth
2393 });
2394 const abortController = new AbortController();
2395 abortControllerRef.current = abortController;
2396 const signal = abortController.signal;
2397 let attributeObserver = null;
2398 const endingStyleAttribute = CollapsiblePanelDataAttributes.endingStyle;
2399 attributeObserver = new MutationObserver((mutationList) => {
2400 const hasEndingStyle = mutationList.some((mutation) => mutation.type === "attributes" && mutation.attributeName === endingStyleAttribute);
2401 if (hasEndingStyle) {
2402 attributeObserver?.disconnect();
2403 attributeObserver = null;
2404 runOnceAnimationsFinish(() => {
2405 setDimensions({
2406 height: 0,
2407 width: 0
2408 });
2409 panel.style.removeProperty("content-visibility");
2410 setMounted(false);
2411 if (abortControllerRef.current === abortController) {
2412 abortControllerRef.current = null;
2413 }
2414 }, signal);
2415 }
2416 });
2417 attributeObserver.observe(panel, {
2418 attributes: true,
2419 attributeFilter: [endingStyleAttribute]
2420 });
2421 return () => {
2422 attributeObserver?.disconnect();
2423 endingStyleFrame.cancel();
2424 if (abortControllerRef.current === abortController) {
2425 abortController.abort();
2426 abortControllerRef.current = null;
2427 }
2428 };
2429 }
2430 return () => {
2431 AnimationFrame.cancel(resizeFrame);
2432 };
2433 }, [abortControllerRef, animationTypeRef, endingStyleFrame, hiddenUntilFound, keepMounted, mounted, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted]);
2434 useIsoLayoutEffect(() => {
2435 if (animationTypeRef.current !== "css-animation") {
2436 return;
2437 }
2438 const panel = panelRef.current;
2439 if (!panel) {
2440 return;
2441 }
2442 latestAnimationNameRef.current = panel.style.animationName || latestAnimationNameRef.current;
2443 panel.style.setProperty("animation-name", "none");
2444 setDimensions({
2445 height: panel.scrollHeight,
2446 width: panel.scrollWidth
2447 });
2448 if (!shouldCancelInitialOpenAnimationRef.current && !isBeforeMatchRef.current) {
2449 panel.style.removeProperty("animation-name");
2450 }
2451 if (open) {
2452 if (abortControllerRef.current != null) {
2453 abortControllerRef.current.abort();
2454 abortControllerRef.current = null;
2455 }
2456 setMounted(true);
2457 setVisible(true);
2458 } else {
2459 abortControllerRef.current = new AbortController();
2460 runOnceAnimationsFinish(() => {
2461 setMounted(false);
2462 setVisible(false);
2463 abortControllerRef.current = null;
2464 }, abortControllerRef.current.signal);
2465 }
2466 }, [abortControllerRef, animationTypeRef, open, panelRef, runOnceAnimationsFinish, setDimensions, setMounted, setVisible, visible]);
2467 useOnMount(() => {
2468 const frame = AnimationFrame.request(() => {
2469 shouldCancelInitialOpenAnimationRef.current = false;
2470 });
2471 return () => AnimationFrame.cancel(frame);
2472 });
2473 useIsoLayoutEffect(() => {
2474 if (!hiddenUntilFound) {
2475 return void 0;
2476 }
2477 const panel = panelRef.current;
2478 if (!panel) {
2479 return void 0;
2480 }
2481 let frame = -1;
2482 let nextFrame = -1;
2483 if (open && isBeforeMatchRef.current) {
2484 panel.style.transitionDuration = "0s";
2485 setDimensions({
2486 height: panel.scrollHeight,
2487 width: panel.scrollWidth
2488 });
2489 frame = AnimationFrame.request(() => {
2490 isBeforeMatchRef.current = false;
2491 nextFrame = AnimationFrame.request(() => {
2492 setTimeout(() => {
2493 panel.style.removeProperty("transition-duration");
2494 });
2495 });
2496 });
2497 }
2498 return () => {
2499 AnimationFrame.cancel(frame);
2500 AnimationFrame.cancel(nextFrame);
2501 };
2502 }, [hiddenUntilFound, open, panelRef, setDimensions]);
2503 useIsoLayoutEffect(() => {
2504 const panel = panelRef.current;
2505 if (panel && hiddenUntilFound && hidden) {
2506 panel.setAttribute("hidden", "until-found");
2507 if (animationTypeRef.current === "css-transition") {
2508 panel.setAttribute(CollapsiblePanelDataAttributes.startingStyle, "");
2509 }
2510 }
2511 }, [hiddenUntilFound, hidden, animationTypeRef, panelRef]);
2512 React18.useEffect(function registerBeforeMatchListener() {
2513 const panel = panelRef.current;
2514 if (!panel) {
2515 return void 0;
2516 }
2517 function handleBeforeMatch(event) {
2518 isBeforeMatchRef.current = true;
2519 setOpen(true);
2520 onOpenChange(true, createChangeEventDetails(reason_parts_exports.none, event));
2521 }
2522 return addEventListener(panel, "beforematch", handleBeforeMatch);
2523 }, [onOpenChange, panelRef, setOpen]);
2524 return React18.useMemo(() => ({
2525 props: {
2526 hidden,
2527 id: idParam,
2528 ref: mergedPanelRef
2529 }
2530 }), [hidden, idParam, mergedPanelRef]);
2531 }
2532
2533 // node_modules/@base-ui/react/esm/internals/useOpenChangeComplete.js
2534 var React19 = __toESM(require_react(), 1);
2535 function useOpenChangeComplete(parameters) {
2536 const {
2537 enabled = true,
2538 open,
2539 ref,
2540 onComplete: onCompleteParam
2541 } = parameters;
2542 const onComplete = useStableCallback(onCompleteParam);
2543 const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
2544 React19.useEffect(() => {
2545 if (!enabled) {
2546 return void 0;
2547 }
2548 const abortController = new AbortController();
2549 runOnceAnimationsFinish(onComplete, abortController.signal);
2550 return () => {
2551 abortController.abort();
2552 };
2553 }, [enabled, open, onComplete, runOnceAnimationsFinish]);
2554 }
2555
2556 // node_modules/@base-ui/react/esm/collapsible/index.parts.js
2557 var index_parts_exports = {};
2558 __export(index_parts_exports, {
2559 Panel: () => CollapsiblePanel,
2560 Root: () => CollapsibleRoot,
2561 Trigger: () => CollapsibleTrigger
2562 });
2563
2564 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
2565 var React20 = __toESM(require_react(), 1);
2566
2567 // node_modules/@base-ui/react/esm/collapsible/root/stateAttributesMapping.js
2568 var collapsibleStateAttributesMapping = {
2569 ...collapsibleOpenStateMapping,
2570 ...transitionStatusMapping
2571 };
2572
2573 // node_modules/@base-ui/react/esm/collapsible/root/CollapsibleRoot.js
2574 var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
2575 var CollapsibleRoot = /* @__PURE__ */ React20.forwardRef(function CollapsibleRoot2(componentProps, forwardedRef) {
2576 const {
2577 render: render4,
2578 className,
2579 defaultOpen = false,
2580 disabled: disabled2 = false,
2581 onOpenChange: onOpenChangeProp,
2582 open,
2583 style,
2584 ...elementProps
2585 } = componentProps;
2586 const onOpenChange = useStableCallback(onOpenChangeProp);
2587 const collapsible = useCollapsibleRoot({
2588 open,
2589 defaultOpen,
2590 onOpenChange,
2591 disabled: disabled2
2592 });
2593 const state = React20.useMemo(() => ({
2594 open: collapsible.open,
2595 disabled: collapsible.disabled,
2596 transitionStatus: collapsible.transitionStatus
2597 }), [collapsible.open, collapsible.disabled, collapsible.transitionStatus]);
2598 const contextValue = React20.useMemo(() => ({
2599 ...collapsible,
2600 onOpenChange,
2601 state
2602 }), [collapsible, onOpenChange, state]);
2603 const element = useRenderElement("div", componentProps, {
2604 state,
2605 ref: forwardedRef,
2606 props: elementProps,
2607 stateAttributesMapping: collapsibleStateAttributesMapping
2608 });
2609 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CollapsibleRootContext.Provider, {
2610 value: contextValue,
2611 children: element
2612 });
2613 });
2614 if (true) CollapsibleRoot.displayName = "CollapsibleRoot";
2615
2616 // node_modules/@base-ui/react/esm/collapsible/trigger/CollapsibleTrigger.js
2617 var React21 = __toESM(require_react(), 1);
2618 var stateAttributesMapping = {
2619 ...triggerOpenStateMapping,
2620 ...transitionStatusMapping
2621 };
2622 var CollapsibleTrigger = /* @__PURE__ */ React21.forwardRef(function CollapsibleTrigger2(componentProps, forwardedRef) {
2623 const {
2624 panelId,
2625 open,
2626 handleTrigger,
2627 state,
2628 disabled: contextDisabled
2629 } = useCollapsibleRootContext();
2630 const {
2631 className,
2632 disabled: disabled2 = contextDisabled,
2633 id,
2634 render: render4,
2635 nativeButton = true,
2636 style,
2637 ...elementProps
2638 } = componentProps;
2639 const {
2640 getButtonProps,
2641 buttonRef
2642 } = useButton({
2643 disabled: disabled2,
2644 focusableWhenDisabled: true,
2645 native: nativeButton
2646 });
2647 const props = React21.useMemo(() => ({
2648 "aria-controls": open ? panelId : void 0,
2649 "aria-expanded": open,
2650 onClick: handleTrigger
2651 }), [panelId, open, handleTrigger]);
2652 const element = useRenderElement("button", componentProps, {
2653 state,
2654 ref: [forwardedRef, buttonRef],
2655 props: [props, elementProps, getButtonProps],
2656 stateAttributesMapping
2657 });
2658 return element;
2659 });
2660 if (true) CollapsibleTrigger.displayName = "CollapsibleTrigger";
2661
2662 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
2663 var React22 = __toESM(require_react(), 1);
2664
2665 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanelCssVars.js
2666 var CollapsiblePanelCssVars = /* @__PURE__ */ (function(CollapsiblePanelCssVars2) {
2667 CollapsiblePanelCssVars2["collapsiblePanelHeight"] = "--collapsible-panel-height";
2668 CollapsiblePanelCssVars2["collapsiblePanelWidth"] = "--collapsible-panel-width";
2669 return CollapsiblePanelCssVars2;
2670 })({});
2671
2672 // node_modules/@base-ui/react/esm/collapsible/panel/CollapsiblePanel.js
2673 var CollapsiblePanel = /* @__PURE__ */ React22.forwardRef(function CollapsiblePanel2(componentProps, forwardedRef) {
2674 const {
2675 className,
2676 hiddenUntilFound: hiddenUntilFoundProp,
2677 keepMounted: keepMountedProp,
2678 render: render4,
2679 id: idProp,
2680 style,
2681 ...elementProps
2682 } = componentProps;
2683 if (true) {
2684 useIsoLayoutEffect(() => {
2685 if (hiddenUntilFoundProp && keepMountedProp === false) {
2686 warn("The `keepMounted={false}` prop on a Collapsible will be ignored when using `hiddenUntilFound` since it requires the Panel to remain mounted even when closed.");
2687 }
2688 }, [hiddenUntilFoundProp, keepMountedProp]);
2689 }
2690 const {
2691 abortControllerRef,
2692 animationTypeRef,
2693 height,
2694 mounted,
2695 onOpenChange,
2696 open,
2697 panelId,
2698 panelRef,
2699 runOnceAnimationsFinish,
2700 setDimensions,
2701 setHiddenUntilFound,
2702 setKeepMounted,
2703 setMounted,
2704 setPanelIdState,
2705 setOpen,
2706 setVisible,
2707 state,
2708 transitionDimensionRef,
2709 visible,
2710 width,
2711 transitionStatus
2712 } = useCollapsibleRootContext();
2713 const hiddenUntilFound = hiddenUntilFoundProp ?? false;
2714 const keepMounted = keepMountedProp ?? false;
2715 useIsoLayoutEffect(() => {
2716 if (idProp) {
2717 setPanelIdState(idProp);
2718 return () => {
2719 setPanelIdState(void 0);
2720 };
2721 }
2722 return void 0;
2723 }, [idProp, setPanelIdState]);
2724 useIsoLayoutEffect(() => {
2725 setHiddenUntilFound(hiddenUntilFound);
2726 }, [setHiddenUntilFound, hiddenUntilFound]);
2727 useIsoLayoutEffect(() => {
2728 setKeepMounted(keepMounted);
2729 }, [setKeepMounted, keepMounted]);
2730 const {
2731 props
2732 } = useCollapsiblePanel({
2733 abortControllerRef,
2734 animationTypeRef,
2735 externalRef: forwardedRef,
2736 height,
2737 hiddenUntilFound,
2738 id: panelId,
2739 keepMounted,
2740 mounted,
2741 onOpenChange,
2742 open,
2743 panelRef,
2744 runOnceAnimationsFinish,
2745 setDimensions,
2746 setMounted,
2747 setOpen,
2748 setVisible,
2749 transitionDimensionRef,
2750 visible,
2751 width
2752 });
2753 useOpenChangeComplete({
2754 open: open && transitionStatus === "idle",
2755 ref: panelRef,
2756 onComplete() {
2757 if (!open) {
2758 return;
2759 }
2760 setDimensions({
2761 height: void 0,
2762 width: void 0
2763 });
2764 }
2765 });
2766 const panelState = React22.useMemo(() => ({
2767 ...state,
2768 transitionStatus
2769 }), [state, transitionStatus]);
2770 const element = useRenderElement("div", componentProps, {
2771 state: panelState,
2772 ref: [forwardedRef, panelRef],
2773 props: [props, {
2774 style: {
2775 [CollapsiblePanelCssVars.collapsiblePanelHeight]: height === void 0 ? "auto" : `${height}px`,
2776 [CollapsiblePanelCssVars.collapsiblePanelWidth]: width === void 0 ? "auto" : `${width}px`
2777 }
2778 }, elementProps],
2779 stateAttributesMapping: collapsibleStateAttributesMapping
2780 });
2781 const shouldRender = keepMounted || hiddenUntilFound || mounted;
2782 if (!shouldRender) {
2783 return null;
2784 }
2785 return element;
2786 });
2787 if (true) CollapsiblePanel.displayName = "CollapsiblePanel";
2788
2789 // node_modules/@base-ui/react/esm/use-render/useRender.js
2790 function useRender(params) {
2791 return useRenderElement(params.defaultTagName ?? "div", params, params);
2792 }
2793
2794 // packages/ui/build-module/text/text.mjs
2795 var import_element = __toESM(require_element(), 1);
2796 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='4130d64bea']")) {
2797 const style = document.createElement("style");
2798 style.setAttribute("data-wp-hash", "4130d64bea");
2799 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)}}'));
2800 document.head.appendChild(style);
2801 }
2802 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" };
2803 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
2804 const style = document.createElement("style");
2805 style.setAttribute("data-wp-hash", "1fb29d3a3c");
2806 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)}"));
2807 document.head.appendChild(style);
2808 }
2809 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" };
2810 var Text = (0, import_element.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
2811 const element = useRender({
2812 render: render4,
2813 defaultTagName: "span",
2814 ref,
2815 props: mergeProps(props, {
2816 className: clsx_default(
2817 style_default.text,
2818 global_css_defense_default.heading,
2819 global_css_defense_default.p,
2820 style_default[variant],
2821 className
2822 )
2823 })
2824 });
2825 return element;
2826 });
2827
2828 // packages/ui/build-module/badge/badge.mjs
2829 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2830 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='d6a685e1aa']")) {
2831 const style = document.createElement("style");
2832 style.setAttribute("data-wp-hash", "d6a685e1aa");
2833 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._96e6251aad1a6136__badge{border-radius:var(--wpds-border-radius-lg,8px);padding-block:var(--wpds-dimension-padding-xs,4px);padding-inline:var(--wpds-dimension-padding-sm,8px)}._99f7158cb520f750__is-high-intent{background-color:var(--wpds-color-bg-surface-error,#f6e6e3);color:var(--wpds-color-fg-content-error,#470000)}.c20ebef2365bc8b7__is-medium-intent{background-color:var(--wpds-color-bg-surface-warning,#fde6be);color:var(--wpds-color-fg-content-warning,#2e1900)}._365e1626c6202e52__is-low-intent{background-color:var(--wpds-color-bg-surface-caution,#fee995);color:var(--wpds-color-fg-content-caution,#281d00)}._33f8198127ddf4ef__is-stable-intent{background-color:var(--wpds-color-bg-surface-success,#c6f7cd);color:var(--wpds-color-fg-content-success,#002900)}._04c1aca8fc449412__is-informational-intent{background-color:var(--wpds-color-bg-surface-info,#deebfa);color:var(--wpds-color-fg-content-info,#001b4f)}._90726e69d495ec19__is-draft-intent{background-color:var(--wpds-color-bg-surface-neutral-weak,#f4f4f4);color:var(--wpds-color-fg-content-neutral,#1e1e1e)}._898f4a544993bd39__is-none-intent{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);color:var(--wpds-color-fg-content-neutral,#1e1e1e);padding-block:calc(var(--wpds-dimension-padding-xs, 4px) - var(--wpds-border-width-xs, 1px));padding-inline:calc(var(--wpds-dimension-padding-sm, 8px) - var(--wpds-border-width-xs, 1px))}}"));
2834 document.head.appendChild(style);
2835 }
2836 var style_default2 = { "badge": "_96e6251aad1a6136__badge", "is-high-intent": "_99f7158cb520f750__is-high-intent", "is-medium-intent": "c20ebef2365bc8b7__is-medium-intent", "is-low-intent": "_365e1626c6202e52__is-low-intent", "is-stable-intent": "_33f8198127ddf4ef__is-stable-intent", "is-informational-intent": "_04c1aca8fc449412__is-informational-intent", "is-draft-intent": "_90726e69d495ec19__is-draft-intent", "is-none-intent": "_898f4a544993bd39__is-none-intent" };
2837 var Badge = (0, import_element2.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
2838 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2839 Text,
2840 {
2841 ref,
2842 className: clsx_default(
2843 style_default2.badge,
2844 style_default2[`is-${intent}-intent`],
2845 className
2846 ),
2847 ...props,
2848 variant: "body-sm"
2849 }
2850 );
2851 });
2852
2853 // packages/ui/build-module/icon/icon.mjs
2854 var import_element3 = __toESM(require_element(), 1);
2855 var import_primitives = __toESM(require_primitives(), 1);
2856 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
2857 var Icon = (0, import_element3.forwardRef)(function Icon2({ icon, size = 24, ...restProps }, ref) {
2858 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2859 import_primitives.SVG,
2860 {
2861 ref,
2862 fill: "currentColor",
2863 ...icon.props,
2864 ...restProps,
2865 width: size,
2866 height: size
2867 }
2868 );
2869 });
2870
2871 // packages/ui/build-module/card/index.mjs
2872 var card_exports = {};
2873 __export(card_exports, {
2874 Content: () => Content,
2875 FullBleed: () => FullBleed,
2876 Header: () => Header,
2877 Root: () => Root,
2878 Title: () => Title
2879 });
2880
2881 // packages/ui/build-module/card/root.mjs
2882 var import_element4 = __toESM(require_element(), 1);
2883 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='e3ae230cea']")) {
2884 const style = document.createElement("style");
2885 style.setAttribute("data-wp-hash", "e3ae230cea");
2886 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}"));
2887 document.head.appendChild(style);
2888 }
2889 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
2890 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2891 const style = document.createElement("style");
2892 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2893 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2894 document.head.appendChild(style);
2895 }
2896 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2897 var Root = (0, import_element4.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
2898 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]);
2899 const element = useRender({
2900 defaultTagName: "div",
2901 render: render4,
2902 ref,
2903 props: mergeProps({ className: mergedClassName }, restProps)
2904 });
2905 return element;
2906 });
2907
2908 // packages/ui/build-module/card/header.mjs
2909 var import_element5 = __toESM(require_element(), 1);
2910 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2911 const style = document.createElement("style");
2912 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2913 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2914 document.head.appendChild(style);
2915 }
2916 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2917 var Header = (0, import_element5.forwardRef)(
2918 function CardHeader({ render: render4, ...props }, ref) {
2919 const element = useRender({
2920 defaultTagName: "div",
2921 render: render4,
2922 ref,
2923 props: mergeProps({ className: style_default4.header }, props)
2924 });
2925 return element;
2926 }
2927 );
2928
2929 // packages/ui/build-module/card/content.mjs
2930 var import_element6 = __toESM(require_element(), 1);
2931 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2932 const style = document.createElement("style");
2933 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2934 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2935 document.head.appendChild(style);
2936 }
2937 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2938 var Content = (0, import_element6.forwardRef)(
2939 function CardContent({ render: render4, ...props }, ref) {
2940 const element = useRender({
2941 defaultTagName: "div",
2942 render: render4,
2943 ref,
2944 props: mergeProps({ className: style_default5.content }, props)
2945 });
2946 return element;
2947 }
2948 );
2949
2950 // packages/ui/build-module/card/full-bleed.mjs
2951 var import_element7 = __toESM(require_element(), 1);
2952 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='14f5e9ddeb']")) {
2953 const style = document.createElement("style");
2954 style.setAttribute("data-wp-hash", "14f5e9ddeb");
2955 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._02872bf298eadc43__root{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);--wp-ui-card-header-content-gap:var(--wpds-dimension-gap-xl,24px);--wp-ui-card-header-content-margin:calc(var(--wp-ui-card-header-content-gap) - var(--wp-ui-card-padding));background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#e4e4e4);border-radius:var(--wpds-border-radius-lg,8px);color:var(--wpds-color-fg-content-neutral,#1e1e1e);display:flex;flex-direction:column;overflow:clip}._5dffdaf2a6e669ac__content,.bbccc92e6ba5662d__header{padding:var(--wp-ui-card-padding);&:not(:first-child):not(:last-child){padding-block-end:0}}.bbccc92e6ba5662d__header+._5dffdaf2a6e669ac__content{margin-block-start:var(--wp-ui-card-header-content-margin);padding-block-start:0}.c1fa192587e1b4a6__fullbleed{margin-inline:calc(var(--wp-ui-card-padding)*-1);width:calc(100% + var(--wp-ui-card-padding)*2)}}"));
2956 document.head.appendChild(style);
2957 }
2958 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
2959 var FullBleed = (0, import_element7.forwardRef)(
2960 function CardFullBleed({ render: render4, ...props }, ref) {
2961 const element = useRender({
2962 defaultTagName: "div",
2963 render: render4,
2964 ref,
2965 props: mergeProps(
2966 { className: style_default6.fullbleed },
2967 props
2968 )
2969 });
2970 return element;
2971 }
2972 );
2973
2974 // packages/ui/build-module/card/title.mjs
2975 var import_element8 = __toESM(require_element(), 1);
2976 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
2977 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", {});
2978 var Title = (0, import_element8.forwardRef)(
2979 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
2980 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2981 Text,
2982 {
2983 ref,
2984 variant: "heading-lg",
2985 render: render4,
2986 ...props,
2987 children
2988 }
2989 );
2990 }
2991 );
2992
2993 // packages/ui/build-module/collapsible/panel.mjs
2994 var import_element9 = __toESM(require_element(), 1);
2995 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
2996 var Panel = (0, import_element9.forwardRef)(
2997 function CollapsiblePanel3(props, forwardedRef) {
2998 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
2999 }
3000 );
3001
3002 // packages/ui/build-module/collapsible/root.mjs
3003 var import_element10 = __toESM(require_element(), 1);
3004 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
3005 var Root2 = (0, import_element10.forwardRef)(
3006 function CollapsibleRoot3(props, forwardedRef) {
3007 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
3008 }
3009 );
3010
3011 // packages/ui/build-module/collapsible/trigger.mjs
3012 var import_element11 = __toESM(require_element(), 1);
3013 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
3014 var Trigger = (0, import_element11.forwardRef)(
3015 function CollapsibleTrigger3(props, forwardedRef) {
3016 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
3017 }
3018 );
3019
3020 // packages/ui/build-module/collapsible-card/index.mjs
3021 var collapsible_card_exports = {};
3022 __export(collapsible_card_exports, {
3023 Content: () => Content2,
3024 Header: () => Header2,
3025 HeaderDescription: () => HeaderDescription,
3026 Root: () => Root3
3027 });
3028
3029 // packages/ui/build-module/collapsible-card/root.mjs
3030 var import_element12 = __toESM(require_element(), 1);
3031 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
3032 var Root3 = (0, import_element12.forwardRef)(
3033 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
3034 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3035 Root2,
3036 {
3037 ref,
3038 render: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Root, { render: render4 }),
3039 ...restProps
3040 }
3041 );
3042 }
3043 );
3044
3045 // packages/ui/build-module/collapsible-card/header.mjs
3046 var import_element14 = __toESM(require_element(), 1);
3047
3048 // packages/icons/build-module/library/arrow-down.mjs
3049 var import_primitives2 = __toESM(require_primitives(), 1);
3050 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
3051 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives2.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" }) });
3052
3053 // packages/icons/build-module/library/arrow-left.mjs
3054 var import_primitives3 = __toESM(require_primitives(), 1);
3055 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
3056 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives3.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) });
3057
3058 // packages/icons/build-module/library/arrow-right.mjs
3059 var import_primitives4 = __toESM(require_primitives(), 1);
3060 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
3061 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives4.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) });
3062
3063 // packages/icons/build-module/library/arrow-up.mjs
3064 var import_primitives5 = __toESM(require_primitives(), 1);
3065 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
3066 var arrow_up_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives5.Path, { d: "M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z" }) });
3067
3068 // packages/icons/build-module/library/block-default.mjs
3069 var import_primitives6 = __toESM(require_primitives(), 1);
3070 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
3071 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives6.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) });
3072
3073 // packages/icons/build-module/library/block-table.mjs
3074 var import_primitives7 = __toESM(require_primitives(), 1);
3075 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
3076 var block_table_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives7.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" }) });
3077
3078 // packages/icons/build-module/library/category.mjs
3079 var import_primitives8 = __toESM(require_primitives(), 1);
3080 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
3081 var category_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives8.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" }) });
3082
3083 // packages/icons/build-module/library/check.mjs
3084 var import_primitives9 = __toESM(require_primitives(), 1);
3085 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
3086 var check_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives9.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
3087
3088 // packages/icons/build-module/library/chevron-down.mjs
3089 var import_primitives10 = __toESM(require_primitives(), 1);
3090 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
3091 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives10.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives10.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) });
3092
3093 // packages/icons/build-module/library/chevron-left.mjs
3094 var import_primitives11 = __toESM(require_primitives(), 1);
3095 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
3096 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives11.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
3097
3098 // packages/icons/build-module/library/chevron-right.mjs
3099 var import_primitives12 = __toESM(require_primitives(), 1);
3100 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
3101 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives12.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives12.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
3102
3103 // packages/icons/build-module/library/close-small.mjs
3104 var import_primitives13 = __toESM(require_primitives(), 1);
3105 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
3106 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives13.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" }) });
3107
3108 // packages/icons/build-module/library/cog.mjs
3109 var import_primitives14 = __toESM(require_primitives(), 1);
3110 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
3111 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives14.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives14.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" }) });
3112
3113 // packages/icons/build-module/library/envelope.mjs
3114 var import_primitives15 = __toESM(require_primitives(), 1);
3115 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
3116 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives15.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" }) });
3117
3118 // packages/icons/build-module/library/error.mjs
3119 var import_primitives16 = __toESM(require_primitives(), 1);
3120 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
3121 var error_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives16.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" }) });
3122
3123 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
3124 var import_primitives17 = __toESM(require_primitives(), 1);
3125 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
3126 var format_list_bullets_rtl_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives17.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" }) });
3127
3128 // packages/icons/build-module/library/format-list-bullets.mjs
3129 var import_primitives18 = __toESM(require_primitives(), 1);
3130 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
3131 var format_list_bullets_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives18.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" }) });
3132
3133 // packages/icons/build-module/library/funnel.mjs
3134 var import_primitives19 = __toESM(require_primitives(), 1);
3135 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3136 var funnel_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives19.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives19.Path, { d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" }) });
3137
3138 // packages/icons/build-module/library/link.mjs
3139 var import_primitives20 = __toESM(require_primitives(), 1);
3140 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3141 var link_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives20.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" }) });
3142
3143 // packages/icons/build-module/library/mobile.mjs
3144 var import_primitives21 = __toESM(require_primitives(), 1);
3145 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3146 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives21.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" }) });
3147
3148 // packages/icons/build-module/library/more-vertical.mjs
3149 var import_primitives22 = __toESM(require_primitives(), 1);
3150 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3151 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives22.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });
3152
3153 // packages/icons/build-module/library/next.mjs
3154 var import_primitives23 = __toESM(require_primitives(), 1);
3155 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3156 var next_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives23.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" }) });
3157
3158 // packages/icons/build-module/library/pencil.mjs
3159 var import_primitives24 = __toESM(require_primitives(), 1);
3160 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3161 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives24.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) });
3162
3163 // packages/icons/build-module/library/previous.mjs
3164 var import_primitives25 = __toESM(require_primitives(), 1);
3165 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3166 var previous_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives25.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" }) });
3167
3168 // packages/icons/build-module/library/scheduled.mjs
3169 var import_primitives26 = __toESM(require_primitives(), 1);
3170 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3171 var scheduled_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives26.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" }) });
3172
3173 // packages/icons/build-module/library/search.mjs
3174 var import_primitives27 = __toESM(require_primitives(), 1);
3175 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3176 var search_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives27.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" }) });
3177
3178 // packages/icons/build-module/library/seen.mjs
3179 var import_primitives28 = __toESM(require_primitives(), 1);
3180 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3181 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives28.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" }) });
3182
3183 // packages/icons/build-module/library/unseen.mjs
3184 var import_primitives29 = __toESM(require_primitives(), 1);
3185 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3186 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives29.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" }) });
3187
3188 // packages/ui/build-module/collapsible-card/context.mjs
3189 var import_element13 = __toESM(require_element(), 1);
3190 var HeaderDescriptionIdContext = (0, import_element13.createContext)({
3191 setDescriptionId: () => {
3192 }
3193 });
3194
3195 // packages/ui/build-module/collapsible-card/header.mjs
3196 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3197 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b49ef575a8']")) {
3198 const style = document.createElement("style");
3199 style.setAttribute("data-wp-hash", "b49ef575a8");
3200 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
3201 document.head.appendChild(style);
3202 }
3203 var style_default7 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
3204 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='1fb29d3a3c']")) {
3205 const style = document.createElement("style");
3206 style.setAttribute("data-wp-hash", "1fb29d3a3c");
3207 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)}"));
3208 document.head.appendChild(style);
3209 }
3210 var global_css_defense_default2 = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
3211 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='2a5ab8f3a7']")) {
3212 const style = document.createElement("style");
3213 style.setAttribute("data-wp-hash", "2a5ab8f3a7");
3214 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._08e8a2e44959f892__outset-ring--focus,._970d04df7376df67__outset-ring--focus-within-except-active,.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible,.cd83dfc2126a0846__outset-ring--focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active,.ecadb9e080e2dfa5__outset-ring--focus-parent-visible{@media not (prefers-reduced-motion){--_gcd-a-transition:outline 0.1s ease-out;transition:outline .1s ease-out}outline:0 solid #0000;outline-offset:1px}._08e8a2e44959f892__outset-ring--focus:focus,._970d04df7376df67__outset-ring--focus-within-except-active:focus-within:not(:has(:active)),.c5cb3ee4bddaa8e4__outset-ring--focus-within-visible:focus-within:has(:focus-visible),.cd83dfc2126a0846__outset-ring--focus-within:focus-within,.d0541bc9dd9dc7b6__outset-ring--focus-visible:focus-visible,.e25b2bdd7aa21721__outset-ring--focus-except-active:focus:not(:active),:focus-visible .ecadb9e080e2dfa5__outset-ring--focus-parent-visible{--_gcd-a-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));--_gcd-div-outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9));outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus-brand,var(--wp-admin-theme-color,#3858e9))}}"));
3215 document.head.appendChild(style);
3216 }
3217 var focus_default = { "outset-ring--focus": "_08e8a2e44959f892__outset-ring--focus", "outset-ring--focus-except-active": "e25b2bdd7aa21721__outset-ring--focus-except-active", "outset-ring--focus-visible": "d0541bc9dd9dc7b6__outset-ring--focus-visible", "outset-ring--focus-within": "cd83dfc2126a0846__outset-ring--focus-within", "outset-ring--focus-within-except-active": "_970d04df7376df67__outset-ring--focus-within-except-active", "outset-ring--focus-within-visible": "c5cb3ee4bddaa8e4__outset-ring--focus-within-visible", "outset-ring--focus-parent-visible": "ecadb9e080e2dfa5__outset-ring--focus-parent-visible" };
3218 var Header2 = (0, import_element14.forwardRef)(
3219 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
3220 const [descriptionId, setDescriptionId] = (0, import_element14.useState)();
3221 const contextValue = (0, import_element14.useMemo)(
3222 () => ({ setDescriptionId }),
3223 [setDescriptionId]
3224 );
3225 return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3226 Trigger,
3227 {
3228 className: clsx_default(style_default7.header, className),
3229 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3230 Header,
3231 {
3232 ref,
3233 render: render4,
3234 ...restProps
3235 }
3236 ),
3237 nativeButton: false,
3238 "aria-describedby": descriptionId,
3239 children: [
3240 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: style_default7["header-content"], children }),
3241 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3242 "div",
3243 {
3244 className: clsx_default(
3245 style_default7["header-trigger-positioner"]
3246 ),
3247 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3248 "div",
3249 {
3250 className: clsx_default(
3251 style_default7["header-trigger-wrapper"],
3252 global_css_defense_default2.div,
3253 // While the interactive trigger element is the whole header,
3254 // the focus ring will be displayed only on the icon to visually
3255 // emulate it being the button.
3256 focus_default["outset-ring--focus-parent-visible"]
3257 ),
3258 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3259 Icon,
3260 {
3261 icon: chevron_down_default,
3262 className: style_default7["header-trigger"]
3263 }
3264 )
3265 }
3266 )
3267 }
3268 )
3269 ]
3270 }
3271 ) });
3272 }
3273 );
3274
3275 // packages/ui/build-module/collapsible-card/header-description.mjs
3276 var import_element15 = __toESM(require_element(), 1);
3277 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3278 var HeaderDescription = (0, import_element15.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
3279 const descriptionId = (0, import_element15.useId)();
3280 const { setDescriptionId } = (0, import_element15.useContext)(HeaderDescriptionIdContext);
3281 (0, import_element15.useEffect)(() => {
3282 setDescriptionId(descriptionId);
3283 return () => setDescriptionId(void 0);
3284 }, [descriptionId, setDescriptionId]);
3285 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3286 "div",
3287 {
3288 ref,
3289 id: descriptionId,
3290 "aria-hidden": "true",
3291 className,
3292 ...restProps,
3293 children
3294 }
3295 );
3296 });
3297
3298 // packages/ui/build-module/collapsible-card/content.mjs
3299 var import_element16 = __toESM(require_element(), 1);
3300 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3301 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b49ef575a8']")) {
3302 const style = document.createElement("style");
3303 style.setAttribute("data-wp-hash", "b49ef575a8");
3304 style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.cab17c7a373cb60d__header-content{flex:1;min-width:0}.dd89d27c4f15912d__header-trigger-positioner{align-self:center;flex-shrink:0;max-height:0;overflow:visible}.bcfab5f2448bafef__header-trigger-wrapper{border-radius:var(--wpds-border-radius-sm,2px);display:flex;translate:0 -50%}._3106f8d2b0330faa__header-trigger{@media not (prefers-reduced-motion){transition:rotate .15s ease-out}}._5d2dfcb4085c6d0f__header[data-panel-open] ._3106f8d2b0330faa__header-trigger{rotate:180deg}._5d2dfcb4085c6d0f__header[data-disabled] ._3106f8d2b0330faa__header-trigger{color:var(--wpds-color-fg-interactive-neutral-disabled,#8d8d8d)}.e34cf37ccd0d81e0__content{height:var(--collapsible-panel-height);margin-block-start:var(--wp-ui-card-header-content-margin);overflow:hidden;&._165c4572592944b2__overflowVisible{overflow:visible}&[hidden]:not([hidden=until-found]){display:none}&[data-ending-style],&[data-starting-style]{height:0}@media not (prefers-reduced-motion){transition:all .15s ease-out}}}@layer wp-ui-compositions{._41bfdbf7b6c087c2__content-inner{padding-block-start:0}._5d2dfcb4085c6d0f__header{align-items:stretch;display:flex;flex-direction:row;gap:var(--wpds-dimension-gap-sm,8px);outline:none;&:not([data-disabled]){cursor:var(--wpds-cursor-control,pointer)}}}"));
3305 document.head.appendChild(style);
3306 }
3307 var style_default8 = { "header-content": "cab17c7a373cb60d__header-content", "header-trigger-positioner": "dd89d27c4f15912d__header-trigger-positioner", "header-trigger-wrapper": "bcfab5f2448bafef__header-trigger-wrapper", "header-trigger": "_3106f8d2b0330faa__header-trigger", "header": "_5d2dfcb4085c6d0f__header", "content": "e34cf37ccd0d81e0__content", "overflowVisible": "_165c4572592944b2__overflowVisible", "content-inner": "_41bfdbf7b6c087c2__content-inner" };
3308 var Content2 = (0, import_element16.forwardRef)(
3309 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
3310 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3311 Panel,
3312 {
3313 ref,
3314 className: (state) => clsx_default(
3315 style_default8.content,
3316 state.open && state.transitionStatus === "idle" && style_default8.overflowVisible,
3317 className
3318 ),
3319 hiddenUntilFound,
3320 ...restProps,
3321 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3322 Content,
3323 {
3324 className: style_default8["content-inner"],
3325 render: render4,
3326 children
3327 }
3328 )
3329 }
3330 );
3331 }
3332 );
3333
3334 // packages/ui/build-module/stack/stack.mjs
3335 var import_element17 = __toESM(require_element(), 1);
3336 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
3337 const style = document.createElement("style");
3338 style.setAttribute("data-wp-hash", "b51ff41489");
3339 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}}"));
3340 document.head.appendChild(style);
3341 }
3342 var style_default9 = { "stack": "_19ce0419607e1896__stack" };
3343 var gapTokens = {
3344 xs: "var(--wpds-dimension-gap-xs, 4px)",
3345 sm: "var(--wpds-dimension-gap-sm, 8px)",
3346 md: "var(--wpds-dimension-gap-md, 12px)",
3347 lg: "var(--wpds-dimension-gap-lg, 16px)",
3348 xl: "var(--wpds-dimension-gap-xl, 24px)",
3349 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
3350 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
3351 };
3352 var Stack = (0, import_element17.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
3353 const style = {
3354 gap: gap && gapTokens[gap],
3355 alignItems: align,
3356 justifyContent: justify,
3357 flexDirection: direction,
3358 flexWrap: wrap
3359 };
3360 const element = useRender({
3361 render: render4,
3362 ref,
3363 props: mergeProps(props, { style, className: style_default9.stack })
3364 });
3365 return element;
3366 });
3367
3368 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
3369 var import_element18 = __toESM(require_element(), 1);
3370 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='c46e8cb841']")) {
3371 const style = document.createElement("style");
3372 style.setAttribute("data-wp-hash", "c46e8cb841");
3373 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}}"));
3374 document.head.appendChild(style);
3375 }
3376 var style_default10 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
3377 var VisuallyHidden = (0, import_element18.forwardRef)(
3378 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
3379 const element = useRender({
3380 render: render4,
3381 ref,
3382 props: mergeProps(
3383 { className: style_default10["visually-hidden"] },
3384 restProps,
3385 {
3386 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
3387 "data-visually-hidden": ""
3388 }
3389 )
3390 });
3391 return element;
3392 }
3393 );
3394
3395 // packages/admin-ui/build-module/navigable-region/index.mjs
3396 var import_element19 = __toESM(require_element(), 1);
3397 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
3398 var NavigableRegion = (0, import_element19.forwardRef)(
3399 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
3400 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
3401 Tag,
3402 {
3403 ref,
3404 className: clsx_default("admin-ui-navigable-region", className),
3405 "aria-label": ariaLabel,
3406 role: "region",
3407 tabIndex: "-1",
3408 ...props,
3409 children
3410 }
3411 );
3412 }
3413 );
3414 NavigableRegion.displayName = "NavigableRegion";
3415 var navigable_region_default = NavigableRegion;
3416
3417 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
3418 var import_components = __toESM(require_components(), 1);
3419 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
3420
3421 // packages/admin-ui/build-module/page/header.mjs
3422 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
3423 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='aa9c241ccc']")) {
3424 const style = document.createElement("style");
3425 style.setAttribute("data-wp-hash", "aa9c241ccc");
3426 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)}}"));
3427 document.head.appendChild(style);
3428 }
3429 var style_default11 = { "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" };
3430 function Header3({
3431 headingLevel = 1,
3432 breadcrumbs,
3433 badges,
3434 visual,
3435 title,
3436 subTitle,
3437 actions: actions2,
3438 showSidebarToggle = true
3439 }) {
3440 const HeadingTag = `h${headingLevel}`;
3441 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
3442 Stack,
3443 {
3444 direction: "column",
3445 className: style_default11.header,
3446 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("header", {}),
3447 children: [
3448 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
3449 Stack,
3450 {
3451 className: style_default11["header-content"],
3452 direction: "row",
3453 gap: "sm",
3454 justify: "space-between",
3455 children: [
3456 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
3457 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3458 SidebarToggleSlot,
3459 {
3460 bubblesVirtually: true,
3461 className: style_default11["sidebar-toggle-slot"]
3462 }
3463 ),
3464 visual && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3465 "div",
3466 {
3467 className: style_default11["header-visual"],
3468 "aria-hidden": "true",
3469 children: visual
3470 }
3471 ),
3472 title && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3473 Text,
3474 {
3475 className: style_default11["header-title"],
3476 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(HeadingTag, {}),
3477 variant: "heading-lg",
3478 children: title
3479 }
3480 ),
3481 breadcrumbs,
3482 badges
3483 ] }),
3484 actions2 && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3485 Stack,
3486 {
3487 align: "center",
3488 className: style_default11["header-actions"],
3489 direction: "row",
3490 gap: "sm",
3491 children: actions2
3492 }
3493 )
3494 ]
3495 }
3496 ),
3497 subTitle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
3498 Text,
3499 {
3500 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", {}),
3501 variant: "body-md",
3502 className: style_default11["header-subtitle"],
3503 children: subTitle
3504 }
3505 )
3506 ]
3507 }
3508 );
3509 }
3510
3511 // packages/admin-ui/build-module/page/index.mjs
3512 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
3513 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='aa9c241ccc']")) {
3514 const style = document.createElement("style");
3515 style.setAttribute("data-wp-hash", "aa9c241ccc");
3516 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)}}"));
3517 document.head.appendChild(style);
3518 }
3519 var style_default12 = { "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" };
3520 function Page({
3521 headingLevel,
3522 breadcrumbs,
3523 badges,
3524 visual,
3525 title,
3526 subTitle,
3527 children,
3528 className,
3529 actions: actions2,
3530 ariaLabel,
3531 hasPadding = false,
3532 showSidebarToggle = true
3533 }) {
3534 const classes = clsx_default(style_default12.page, className);
3535 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
3536 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
3537 (title || breadcrumbs || badges || actions2 || visual) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3538 Header3,
3539 {
3540 headingLevel,
3541 breadcrumbs,
3542 badges,
3543 visual,
3544 title,
3545 subTitle,
3546 actions: actions2,
3547 showSidebarToggle
3548 }
3549 ),
3550 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
3551 "div",
3552 {
3553 className: clsx_default(
3554 style_default12.content,
3555 style_default12["has-padding"]
3556 ),
3557 children
3558 }
3559 ) : children
3560 ] });
3561 }
3562 Page.SidebarToggleFill = SidebarToggleFill;
3563 var page_default = Page;
3564
3565 // routes/guidelines/stage.tsx
3566 var import_i18n56 = __toESM(require_i18n());
3567 var import_element94 = __toESM(require_element());
3568 var import_components59 = __toESM(require_components());
3569
3570 // routes/guidelines/style.scss
3571 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='15b2061f96']")) {
3572 const style = document.createElement("style");
3573 style.setAttribute("data-wp-hash", "15b2061f96");
3574 style.appendChild(document.createTextNode(".guidelines__content{border-radius:8px;margin-top:0;padding:24px}.guidelines__list{display:flex;flex-direction:column;gap:16px;list-style:none;margin:0;padding:0}.guidelines__list-item{margin:0 auto;width:min(680px,100%)}.guidelines__loading{align-items:center;display:flex;justify-content:center;margin-top:16px}.guidelines__revision-history{display:flex;flex-direction:column;gap:16px;padding:24px}.guidelines__revision-history .dataviews-wrapper{margin-left:-24px;margin-right:-24px}.guidelines__revision-history-back{align-self:flex-start;color:#1e1e1e;font-weight:500;margin-left:-16px}.guidelines__error-description{margin:8px 0 0}.guidelines__revision-description{padding-left:8px}.guidelines__restore-modal-actions{margin-top:24px}"));
3575 document.head.appendChild(style);
3576 }
3577
3578 // routes/guidelines/components/guideline-accordion.tsx
3579 var import_components2 = __toESM(require_components());
3580 var import_i18n = __toESM(require_i18n());
3581 var import_element20 = __toESM(require_element());
3582
3583 // routes/guidelines/components/guideline-accordion.scss
3584 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='0de3dafc3a']")) {
3585 const style = document.createElement("style");
3586 style.setAttribute("data-wp-hash", "0de3dafc3a");
3587 style.appendChild(document.createTextNode(".guidelines__accordion{padding:16px 24px}.guidelines__accordion-trigger{background:none;border:none;cursor:var(--wpds-cursor-control,pointer);display:block;height:auto;margin:0;padding:0;text-align:left;width:100%}.guidelines__accordion-trigger:focus{box-shadow:none!important}.guidelines__accordion-trigger:focus-visible{box-shadow:0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color,#3858e9)!important}.guidelines__accordion-chevron-up{transform:rotate(180deg);transition:transform .3s ease-in-out}.guidelines__accordion-chevron-down{transform:rotate(0deg);transition:transform .3s ease-in-out}.guidelines__accordion-header{color:#1e1e1e;padding-top:4px}.guidelines__accordion-description{color:#757575;padding-bottom:4px}.guidelines__accordion-form{margin-top:24px}"));
3588 document.head.appendChild(style);
3589 }
3590
3591 // routes/guidelines/components/guideline-accordion.tsx
3592 function GuidelineAccordion({
3593 title,
3594 description,
3595 children,
3596 contentId,
3597 headingId,
3598 descriptionId
3599 }) {
3600 const [isOpen, setIsOpen] = (0, import_element20.useState)(false);
3601 return /* @__PURE__ */ React.createElement(import_components2.Card, { className: "guidelines__accordion" }, /* @__PURE__ */ React.createElement(
3602 import_components2.Button,
3603 {
3604 className: "guidelines__accordion-trigger",
3605 onClick: () => setIsOpen(!isOpen),
3606 "aria-expanded": isOpen,
3607 "aria-controls": contentId,
3608 "aria-describedby": descriptionId,
3609 "aria-label": isOpen ? (0, import_i18n.sprintf)(
3610 /* translators: %s: Guideline title */
3611 (0, import_i18n.__)("Collapse %s guidelines"),
3612 title
3613 ) : (0, import_i18n.sprintf)(
3614 /* translators: %s: Guideline title */
3615 (0, import_i18n.__)("Expand %s guidelines"),
3616 title
3617 )
3618 },
3619 /* @__PURE__ */ React.createElement(import_components2.__experimentalHStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components2.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(
3620 import_components2.__experimentalHeading,
3621 {
3622 id: headingId,
3623 className: "guidelines__accordion-header",
3624 level: 2,
3625 size: 15,
3626 weight: 400
3627 },
3628 title
3629 ), /* @__PURE__ */ React.createElement(
3630 import_components2.__experimentalText,
3631 {
3632 id: descriptionId,
3633 className: "guidelines__accordion-description",
3634 size: 13,
3635 weight: 400,
3636 variant: "muted"
3637 },
3638 description
3639 )), /* @__PURE__ */ React.createElement(
3640 import_components2.Icon,
3641 {
3642 icon: chevron_down_default,
3643 className: isOpen ? "guidelines__accordion-chevron-up" : "guidelines__accordion-chevron-down"
3644 }
3645 ))
3646 ), /* @__PURE__ */ React.createElement("div", { hidden: !isOpen }, children));
3647 }
3648
3649 // routes/guidelines/components/guideline-accordion-form.tsx
3650 var import_components53 = __toESM(require_components());
3651
3652 // packages/dataviews/build-module/dataviews/index.mjs
3653 var import_element76 = __toESM(require_element(), 1);
3654 var import_compose12 = __toESM(require_compose(), 1);
3655
3656 // packages/dataviews/build-module/components/dataviews-context/index.mjs
3657 var import_element21 = __toESM(require_element(), 1);
3658
3659 // packages/dataviews/build-module/constants.mjs
3660 var import_i18n2 = __toESM(require_i18n(), 1);
3661 var OPERATOR_IS_ANY = "isAny";
3662 var OPERATOR_IS_NONE = "isNone";
3663 var OPERATOR_IS_ALL = "isAll";
3664 var OPERATOR_IS_NOT_ALL = "isNotAll";
3665 var OPERATOR_BETWEEN = "between";
3666 var OPERATOR_IN_THE_PAST = "inThePast";
3667 var OPERATOR_OVER = "over";
3668 var OPERATOR_IS = "is";
3669 var OPERATOR_IS_NOT = "isNot";
3670 var OPERATOR_LESS_THAN = "lessThan";
3671 var OPERATOR_GREATER_THAN = "greaterThan";
3672 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
3673 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
3674 var OPERATOR_BEFORE = "before";
3675 var OPERATOR_AFTER = "after";
3676 var OPERATOR_BEFORE_INC = "beforeInc";
3677 var OPERATOR_AFTER_INC = "afterInc";
3678 var OPERATOR_CONTAINS = "contains";
3679 var OPERATOR_NOT_CONTAINS = "notContains";
3680 var OPERATOR_STARTS_WITH = "startsWith";
3681 var OPERATOR_ON = "on";
3682 var OPERATOR_NOT_ON = "notOn";
3683 var SORTING_DIRECTIONS = ["asc", "desc"];
3684 var sortArrows = { asc: "\u2191", desc: "\u2193" };
3685 var sortValues = { asc: "ascending", desc: "descending" };
3686 var sortLabels = {
3687 asc: (0, import_i18n2.__)("Sort ascending"),
3688 desc: (0, import_i18n2.__)("Sort descending")
3689 };
3690 var sortIcons = {
3691 asc: arrow_up_default,
3692 desc: arrow_down_default
3693 };
3694 var LAYOUT_TABLE = "table";
3695 var LAYOUT_GRID = "grid";
3696 var LAYOUT_LIST = "list";
3697 var LAYOUT_ACTIVITY = "activity";
3698 var LAYOUT_PICKER_GRID = "pickerGrid";
3699 var LAYOUT_PICKER_TABLE = "pickerTable";
3700
3701 // packages/dataviews/build-module/components/dataviews-context/index.mjs
3702 var DataViewsContext = (0, import_element21.createContext)({
3703 view: { type: LAYOUT_TABLE },
3704 onChangeView: () => {
3705 },
3706 fields: [],
3707 data: [],
3708 paginationInfo: {
3709 totalItems: 0,
3710 totalPages: 0
3711 },
3712 selection: [],
3713 onChangeSelection: () => {
3714 },
3715 setOpenedFilter: () => {
3716 },
3717 openedFilter: null,
3718 getItemId: (item) => item.id,
3719 isItemClickable: () => true,
3720 renderItemLink: void 0,
3721 containerWidth: 0,
3722 containerRef: (0, import_element21.createRef)(),
3723 resizeObserverRef: () => {
3724 },
3725 defaultLayouts: { list: {}, grid: {}, table: {} },
3726 filters: [],
3727 isShowingFilter: false,
3728 setIsShowingFilter: () => {
3729 },
3730 hasInitiallyLoaded: false,
3731 config: {
3732 perPageSizes: []
3733 },
3734 intersectionObserver: null
3735 });
3736 DataViewsContext.displayName = "DataViewsContext";
3737 var dataviews_context_default = DataViewsContext;
3738
3739 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
3740 var import_i18n22 = __toESM(require_i18n(), 1);
3741
3742 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
3743 var import_i18n10 = __toESM(require_i18n(), 1);
3744 var import_components8 = __toESM(require_components(), 1);
3745 var import_element29 = __toESM(require_element(), 1);
3746 var import_keycodes = __toESM(require_keycodes(), 1);
3747
3748 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
3749 var import_components3 = __toESM(require_components(), 1);
3750 var import_i18n3 = __toESM(require_i18n(), 1);
3751 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
3752 function DataViewsSelectionCheckbox({
3753 selection,
3754 onChangeSelection,
3755 item,
3756 getItemId,
3757 titleField,
3758 disabled: disabled2,
3759 ...extraProps
3760 }) {
3761 const id = getItemId(item);
3762 const isInSelectionArray = selection.includes(id);
3763 const checked = !disabled2 && isInSelectionArray;
3764 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n3.__)("(no title)");
3765 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
3766 import_components3.CheckboxControl,
3767 {
3768 className: "dataviews-selection-checkbox",
3769 "aria-label": selectionLabel,
3770 "aria-disabled": disabled2,
3771 checked,
3772 onChange: () => {
3773 if (disabled2) {
3774 return;
3775 }
3776 onChangeSelection(
3777 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
3778 );
3779 },
3780 ...extraProps
3781 }
3782 );
3783 }
3784
3785 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
3786 var import_components4 = __toESM(require_components(), 1);
3787 var import_i18n4 = __toESM(require_i18n(), 1);
3788 var import_element22 = __toESM(require_element(), 1);
3789 var import_data = __toESM(require_data(), 1);
3790 var import_compose = __toESM(require_compose(), 1);
3791
3792 // packages/dataviews/build-module/lock-unlock.mjs
3793 var import_private_apis = __toESM(require_private_apis(), 1);
3794 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
3795 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
3796 "@wordpress/dataviews"
3797 );
3798
3799 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
3800 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
3801 var { Menu, kebabCase } = unlock(import_components4.privateApis);
3802 function ButtonTrigger({
3803 action,
3804 onClick,
3805 items,
3806 variant
3807 }) {
3808 const label = typeof action.label === "string" ? action.label : action.label(items);
3809 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3810 import_components4.Button,
3811 {
3812 disabled: !!action.disabled,
3813 accessibleWhenDisabled: true,
3814 size: "compact",
3815 variant,
3816 onClick,
3817 children: label
3818 }
3819 );
3820 }
3821 function MenuItemTrigger({
3822 action,
3823 onClick,
3824 items
3825 }) {
3826 const label = typeof action.label === "string" ? action.label : action.label(items);
3827 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.ItemLabel, { children: label }) });
3828 }
3829 function ActionModal({
3830 action,
3831 items,
3832 closeModal
3833 }) {
3834 const label = typeof action.label === "string" ? action.label : action.label(items);
3835 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
3836 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3837 import_components4.Modal,
3838 {
3839 title: modalHeader || label,
3840 __experimentalHideHeader: !!action.hideModalHeader,
3841 onRequestClose: closeModal,
3842 focusOnMount: action.modalFocusOnMount ?? true,
3843 size: action.modalSize || "medium",
3844 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
3845 action.id
3846 )}`,
3847 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(action.RenderModal, { items, closeModal })
3848 }
3849 );
3850 }
3851 function ActionsMenuGroup({
3852 actions: actions2,
3853 item,
3854 registry,
3855 setActiveModalAction
3856 }) {
3857 const { primaryActions, regularActions } = (0, import_element22.useMemo)(() => {
3858 return actions2.reduce(
3859 (acc, action) => {
3860 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
3861 return acc;
3862 },
3863 {
3864 primaryActions: [],
3865 regularActions: []
3866 }
3867 );
3868 }, [actions2]);
3869 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3870 MenuItemTrigger,
3871 {
3872 action,
3873 onClick: () => {
3874 if ("RenderModal" in action) {
3875 setActiveModalAction(action);
3876 return;
3877 }
3878 action.callback([item], { registry });
3879 },
3880 items: [item]
3881 },
3882 action.id
3883 ));
3884 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu.Group, { children: [
3885 renderActionGroup(primaryActions),
3886 renderActionGroup(regularActions)
3887 ] });
3888 }
3889 function ItemActions({
3890 item,
3891 actions: actions2,
3892 isCompact
3893 }) {
3894 const registry = (0, import_data.useRegistry)();
3895 const { primaryActions, eligibleActions } = (0, import_element22.useMemo)(() => {
3896 const _eligibleActions = actions2.filter(
3897 (action) => !action.isEligible || action.isEligible(item)
3898 );
3899 const _primaryActions = _eligibleActions.filter(
3900 (action) => action.isPrimary
3901 );
3902 return {
3903 primaryActions: _primaryActions,
3904 eligibleActions: _eligibleActions
3905 };
3906 }, [actions2, item]);
3907 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
3908 if (isCompact) {
3909 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3910 CompactItemActions,
3911 {
3912 item,
3913 actions: eligibleActions,
3914 isSmall: true,
3915 registry
3916 }
3917 );
3918 }
3919 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
3920 Stack,
3921 {
3922 direction: "row",
3923 justify: "flex-end",
3924 className: "dataviews-item-actions",
3925 style: {
3926 flexShrink: 0,
3927 width: "auto"
3928 },
3929 children: [
3930 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3931 PrimaryActions,
3932 {
3933 item,
3934 actions: primaryActions,
3935 registry
3936 }
3937 ),
3938 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
3939 // there if there are any actions at all.
3940 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3941 CompactItemActions,
3942 {
3943 item,
3944 actions: eligibleActions,
3945 registry
3946 }
3947 )
3948 ]
3949 }
3950 );
3951 }
3952 function CompactItemActions({
3953 item,
3954 actions: actions2,
3955 isSmall,
3956 registry
3957 }) {
3958 const [activeModalAction, setActiveModalAction] = (0, import_element22.useState)(
3959 null
3960 );
3961 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
3962 /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu, { placement: "bottom-end", children: [
3963 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3964 Menu.TriggerButton,
3965 {
3966 render: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3967 import_components4.Button,
3968 {
3969 size: isSmall ? "small" : "compact",
3970 icon: more_vertical_default,
3971 label: (0, import_i18n4.__)("Actions"),
3972 accessibleWhenDisabled: true,
3973 disabled: !actions2.length,
3974 className: "dataviews-all-actions-button"
3975 }
3976 )
3977 }
3978 ),
3979 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3980 ActionsMenuGroup,
3981 {
3982 actions: actions2,
3983 item,
3984 registry,
3985 setActiveModalAction
3986 }
3987 ) })
3988 ] }),
3989 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
3990 ActionModal,
3991 {
3992 action: activeModalAction,
3993 items: [item],
3994 closeModal: () => setActiveModalAction(null)
3995 }
3996 )
3997 ] });
3998 }
3999 function PrimaryActions({
4000 item,
4001 actions: actions2,
4002 registry,
4003 buttonVariant
4004 }) {
4005 const [activeModalAction, setActiveModalAction] = (0, import_element22.useState)(null);
4006 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
4007 if (isMobileViewport) {
4008 return null;
4009 }
4010 if (!Array.isArray(actions2) || actions2.length === 0) {
4011 return null;
4012 }
4013 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4014 actions2.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4015 ButtonTrigger,
4016 {
4017 action,
4018 onClick: () => {
4019 if ("RenderModal" in action) {
4020 setActiveModalAction(action);
4021 return;
4022 }
4023 action.callback([item], { registry });
4024 },
4025 items: [item],
4026 variant: buttonVariant
4027 },
4028 action.id
4029 )),
4030 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4031 ActionModal,
4032 {
4033 action: activeModalAction,
4034 items: [item],
4035 closeModal: () => setActiveModalAction(null)
4036 }
4037 )
4038 ] });
4039 }
4040
4041 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
4042 var import_components5 = __toESM(require_components(), 1);
4043 var import_i18n6 = __toESM(require_i18n(), 1);
4044 var import_element23 = __toESM(require_element(), 1);
4045 var import_data2 = __toESM(require_data(), 1);
4046 var import_compose2 = __toESM(require_compose(), 1);
4047
4048 // packages/dataviews/build-module/utils/get-footer-message.mjs
4049 var import_i18n5 = __toESM(require_i18n(), 1);
4050 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
4051 if (selectionCount > 0) {
4052 return (0, import_i18n5.sprintf)(
4053 /* translators: %d: number of items. */
4054 (0, import_i18n5._n)("%d Item selected", "%d Items selected", selectionCount),
4055 selectionCount
4056 );
4057 }
4058 if (onlyTotalCount || totalItems <= itemsCount) {
4059 return (0, import_i18n5.sprintf)(
4060 /* translators: %d: number of items. */
4061 (0, import_i18n5._n)("%d Item", "%d Items", totalItems),
4062 totalItems
4063 );
4064 }
4065 return (0, import_i18n5.sprintf)(
4066 /* translators: %1$d: number of items. %2$d: total number of items. */
4067 (0, import_i18n5._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
4068 itemsCount,
4069 totalItems
4070 );
4071 }
4072
4073 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
4074 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4075 function ActionWithModal({
4076 action,
4077 items,
4078 ActionTriggerComponent
4079 }) {
4080 const [isModalOpen, setIsModalOpen] = (0, import_element23.useState)(false);
4081 const actionTriggerProps = {
4082 action,
4083 onClick: () => {
4084 setIsModalOpen(true);
4085 },
4086 items
4087 };
4088 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4089 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
4090 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4091 ActionModal,
4092 {
4093 action,
4094 items,
4095 closeModal: () => setIsModalOpen(false)
4096 }
4097 )
4098 ] });
4099 }
4100 function useHasAPossibleBulkAction(actions2, item) {
4101 return (0, import_element23.useMemo)(() => {
4102 return actions2.some((action) => {
4103 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4104 });
4105 }, [actions2, item]);
4106 }
4107 function useSomeItemHasAPossibleBulkAction(actions2, data) {
4108 return (0, import_element23.useMemo)(() => {
4109 return data.some((item) => {
4110 return actions2.some((action) => {
4111 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4112 });
4113 });
4114 }, [actions2, data]);
4115 }
4116 function BulkSelectionCheckbox({
4117 selection,
4118 onChangeSelection,
4119 data,
4120 actions: actions2,
4121 getItemId,
4122 disableSelectAll = false
4123 }) {
4124 const selectableItems = (0, import_element23.useMemo)(() => {
4125 return data.filter((item) => {
4126 return actions2.some(
4127 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
4128 );
4129 });
4130 }, [data, actions2]);
4131 const selectedItems = data.filter(
4132 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
4133 );
4134 const hasSelection = selection.length > 0;
4135 const areAllSelected = selectedItems.length === selectableItems.length;
4136 if (disableSelectAll) {
4137 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4138 import_components5.CheckboxControl,
4139 {
4140 className: "dataviews-view-table-selection-checkbox",
4141 checked: hasSelection,
4142 disabled: !hasSelection,
4143 onChange: () => {
4144 onChangeSelection([]);
4145 },
4146 "aria-label": (0, import_i18n6.__)("Deselect all")
4147 }
4148 );
4149 }
4150 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4151 import_components5.CheckboxControl,
4152 {
4153 className: "dataviews-view-table-selection-checkbox",
4154 checked: areAllSelected,
4155 indeterminate: !areAllSelected && !!selectedItems.length,
4156 onChange: () => {
4157 if (areAllSelected) {
4158 onChangeSelection([]);
4159 } else {
4160 onChangeSelection(
4161 selectableItems.map((item) => getItemId(item))
4162 );
4163 }
4164 },
4165 "aria-label": areAllSelected ? (0, import_i18n6.__)("Deselect all") : (0, import_i18n6.__)("Select all")
4166 }
4167 );
4168 }
4169 function ActionTrigger({
4170 action,
4171 onClick,
4172 isBusy,
4173 items
4174 }) {
4175 const label = typeof action.label === "string" ? action.label : action.label(items);
4176 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
4177 if (isMobile) {
4178 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4179 import_components5.Button,
4180 {
4181 disabled: isBusy,
4182 accessibleWhenDisabled: true,
4183 label,
4184 icon: action.icon,
4185 size: "compact",
4186 onClick,
4187 isBusy
4188 }
4189 );
4190 }
4191 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4192 import_components5.Button,
4193 {
4194 disabled: isBusy,
4195 accessibleWhenDisabled: true,
4196 size: "compact",
4197 onClick,
4198 isBusy,
4199 children: label
4200 }
4201 );
4202 }
4203 var EMPTY_ARRAY2 = [];
4204 function ActionButton({
4205 action,
4206 selectedItems,
4207 actionInProgress,
4208 setActionInProgress
4209 }) {
4210 const registry = (0, import_data2.useRegistry)();
4211 const selectedEligibleItems = (0, import_element23.useMemo)(() => {
4212 return selectedItems.filter((item) => {
4213 return !action.isEligible || action.isEligible(item);
4214 });
4215 }, [action, selectedItems]);
4216 if ("RenderModal" in action) {
4217 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4218 ActionWithModal,
4219 {
4220 action,
4221 items: selectedEligibleItems,
4222 ActionTriggerComponent: ActionTrigger
4223 },
4224 action.id
4225 );
4226 }
4227 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4228 ActionTrigger,
4229 {
4230 action,
4231 onClick: async () => {
4232 setActionInProgress(action.id);
4233 await action.callback(selectedItems, {
4234 registry
4235 });
4236 setActionInProgress(null);
4237 },
4238 items: selectedEligibleItems,
4239 isBusy: actionInProgress === action.id
4240 },
4241 action.id
4242 );
4243 }
4244 function renderFooterContent(data, actions2, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
4245 const message2 = getFooterMessage(
4246 selection.length,
4247 data.length,
4248 paginationInfo.totalItems,
4249 isInfiniteScroll
4250 );
4251 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4252 Stack,
4253 {
4254 direction: "row",
4255 className: "dataviews-bulk-actions-footer__container",
4256 gap: "md",
4257 align: "center",
4258 children: [
4259 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4260 BulkSelectionCheckbox,
4261 {
4262 selection,
4263 onChangeSelection,
4264 data,
4265 actions: actions2,
4266 getItemId,
4267 disableSelectAll: isInfiniteScroll
4268 }
4269 ),
4270 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
4271 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
4272 Stack,
4273 {
4274 direction: "row",
4275 className: "dataviews-bulk-actions-footer__action-buttons",
4276 gap: "xs",
4277 children: [
4278 actionsToShow.map((action) => {
4279 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4280 ActionButton,
4281 {
4282 action,
4283 selectedItems,
4284 actionInProgress,
4285 setActionInProgress
4286 },
4287 action.id
4288 );
4289 }),
4290 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4291 import_components5.Button,
4292 {
4293 icon: close_small_default,
4294 showTooltip: true,
4295 tooltipPosition: "top",
4296 size: "compact",
4297 label: (0, import_i18n6.__)("Cancel"),
4298 disabled: !!actionInProgress,
4299 accessibleWhenDisabled: false,
4300 onClick: () => {
4301 onChangeSelection(EMPTY_ARRAY2);
4302 }
4303 }
4304 )
4305 ]
4306 }
4307 )
4308 ]
4309 }
4310 );
4311 }
4312 function FooterContent({
4313 selection,
4314 actions: actions2,
4315 onChangeSelection,
4316 data,
4317 getItemId,
4318 isInfiniteScroll,
4319 paginationInfo
4320 }) {
4321 const [actionInProgress, setActionInProgress] = (0, import_element23.useState)(
4322 null
4323 );
4324 const footerContentRef = (0, import_element23.useRef)(void 0);
4325 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
4326 const bulkActions = (0, import_element23.useMemo)(
4327 () => actions2.filter((action) => action.supportsBulk),
4328 [actions2]
4329 );
4330 const selectableItems = (0, import_element23.useMemo)(() => {
4331 return data.filter((item) => {
4332 return bulkActions.some(
4333 (action) => !action.isEligible || action.isEligible(item)
4334 );
4335 });
4336 }, [data, bulkActions]);
4337 const selectedItems = (0, import_element23.useMemo)(() => {
4338 return data.filter(
4339 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
4340 );
4341 }, [selection, data, getItemId, selectableItems]);
4342 const actionsToShow = (0, import_element23.useMemo)(
4343 () => actions2.filter((action) => {
4344 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
4345 (item) => !action.isEligible || action.isEligible(item)
4346 );
4347 }),
4348 [actions2, selectedItems, isMobile]
4349 );
4350 if (!actionInProgress) {
4351 if (footerContentRef.current) {
4352 footerContentRef.current = void 0;
4353 }
4354 return renderFooterContent(
4355 data,
4356 actions2,
4357 getItemId,
4358 isInfiniteScroll,
4359 selection,
4360 actionsToShow,
4361 selectedItems,
4362 actionInProgress,
4363 setActionInProgress,
4364 onChangeSelection,
4365 paginationInfo
4366 );
4367 } else if (!footerContentRef.current) {
4368 footerContentRef.current = renderFooterContent(
4369 data,
4370 actions2,
4371 getItemId,
4372 isInfiniteScroll,
4373 selection,
4374 actionsToShow,
4375 selectedItems,
4376 actionInProgress,
4377 setActionInProgress,
4378 onChangeSelection,
4379 paginationInfo
4380 );
4381 }
4382 return footerContentRef.current;
4383 }
4384 function BulkActionsFooter() {
4385 const {
4386 data,
4387 selection,
4388 actions: actions2 = EMPTY_ARRAY2,
4389 onChangeSelection,
4390 getItemId,
4391 paginationInfo,
4392 view
4393 } = (0, import_element23.useContext)(dataviews_context_default);
4394 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4395 FooterContent,
4396 {
4397 selection,
4398 onChangeSelection,
4399 data,
4400 actions: actions2,
4401 getItemId,
4402 isInfiniteScroll: !!view.infiniteScrollEnabled,
4403 paginationInfo
4404 }
4405 );
4406 }
4407
4408 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
4409 var import_i18n7 = __toESM(require_i18n(), 1);
4410 var import_components6 = __toESM(require_components(), 1);
4411 var import_element24 = __toESM(require_element(), 1);
4412
4413 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
4414 function getHideableFields(view, fields2) {
4415 const togglableFields = [
4416 view?.titleField,
4417 view?.mediaField,
4418 view?.descriptionField
4419 ].filter(Boolean);
4420 return fields2.filter(
4421 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
4422 );
4423 }
4424
4425 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
4426 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
4427 var { Menu: Menu2 } = unlock(import_components6.privateApis);
4428 function WithMenuSeparators({ children }) {
4429 return import_element24.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_element24.Fragment, { children: [
4430 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Separator, {}),
4431 child
4432 ] }, i2));
4433 }
4434 var _HeaderMenu = (0, import_element24.forwardRef)(function HeaderMenu({
4435 fieldId,
4436 view,
4437 fields: fields2,
4438 onChangeView,
4439 onHide,
4440 setOpenedFilter,
4441 canMove = true,
4442 canInsertLeft = true,
4443 canInsertRight = true
4444 }, ref) {
4445 const visibleFieldIds = view.fields ?? [];
4446 const index = visibleFieldIds?.indexOf(fieldId);
4447 const isSorted = view.sort?.field === fieldId;
4448 let isHidable = false;
4449 let isSortable = false;
4450 let canAddFilter = false;
4451 let operators = [];
4452 const field = fields2.find((f2) => f2.id === fieldId);
4453 const { setIsShowingFilter } = (0, import_element24.useContext)(dataviews_context_default);
4454 if (!field) {
4455 return null;
4456 }
4457 isHidable = field.enableHiding !== false;
4458 isSortable = field.enableSorting !== false;
4459 const header = field.header;
4460 operators = !!field.filterBy && field.filterBy?.operators || [];
4461 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
4462 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
4463 return header;
4464 }
4465 const hiddenFields = getHideableFields(view, fields2).filter(
4466 (f2) => !visibleFieldIds.includes(f2.id)
4467 );
4468 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
4469 const isRtl = (0, import_i18n7.isRTL)();
4470 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4471 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
4472 Menu2.TriggerButton,
4473 {
4474 render: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4475 import_components6.Button,
4476 {
4477 size: "compact",
4478 className: "dataviews-view-table-header-button",
4479 ref,
4480 variant: "tertiary"
4481 }
4482 ),
4483 children: [
4484 header,
4485 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
4486 ]
4487 }
4488 ),
4489 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(WithMenuSeparators, { children: [
4490 isSortable && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
4491 (direction) => {
4492 const isChecked = view.sort && isSorted && view.sort.direction === direction;
4493 const value = `${fieldId}-${direction}`;
4494 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4495 Menu2.RadioItem,
4496 {
4497 name: "view-table-sorting",
4498 value,
4499 checked: isChecked,
4500 onChange: () => {
4501 onChangeView({
4502 ...view,
4503 sort: {
4504 field: fieldId,
4505 direction
4506 },
4507 showLevels: false
4508 });
4509 },
4510 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
4511 },
4512 value
4513 );
4514 }
4515 ) }),
4516 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4517 Menu2.Item,
4518 {
4519 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: funnel_default }),
4520 onClick: () => {
4521 setOpenedFilter(fieldId);
4522 setIsShowingFilter(true);
4523 onChangeView({
4524 ...view,
4525 page: 1,
4526 filters: [
4527 ...view.filters || [],
4528 {
4529 field: fieldId,
4530 value: void 0,
4531 operator: operators[0]
4532 }
4533 ]
4534 });
4535 },
4536 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Add filter") })
4537 }
4538 ) }),
4539 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2.Group, { children: [
4540 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4541 Menu2.Item,
4542 {
4543 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_left_default }),
4544 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
4545 onClick: () => {
4546 const targetIndex = isRtl ? index + 1 : index - 1;
4547 const newFields = [
4548 ...visibleFieldIds
4549 ];
4550 newFields.splice(index, 1);
4551 newFields.splice(
4552 targetIndex,
4553 0,
4554 fieldId
4555 );
4556 onChangeView({
4557 ...view,
4558 fields: newFields
4559 });
4560 },
4561 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move left") })
4562 }
4563 ),
4564 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4565 Menu2.Item,
4566 {
4567 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_right_default }),
4568 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
4569 onClick: () => {
4570 const targetIndex = isRtl ? index - 1 : index + 1;
4571 const newFields = [
4572 ...visibleFieldIds
4573 ];
4574 newFields.splice(index, 1);
4575 newFields.splice(
4576 targetIndex,
4577 0,
4578 fieldId
4579 );
4580 onChangeView({
4581 ...view,
4582 fields: newFields
4583 });
4584 },
4585 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Move right") })
4586 }
4587 ),
4588 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4589 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert left") }) }),
4590 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
4591 const insertIndex = isRtl ? index + 1 : index;
4592 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4593 Menu2.Item,
4594 {
4595 onClick: () => {
4596 onChangeView({
4597 ...view,
4598 fields: [
4599 ...visibleFieldIds.slice(
4600 0,
4601 insertIndex
4602 ),
4603 hiddenField.id,
4604 ...visibleFieldIds.slice(
4605 insertIndex
4606 )
4607 ]
4608 });
4609 },
4610 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
4611 },
4612 hiddenField.id
4613 );
4614 }) })
4615 ] }),
4616 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
4617 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Insert right") }) }),
4618 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
4619 const insertIndex = isRtl ? index : index + 1;
4620 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4621 Menu2.Item,
4622 {
4623 onClick: () => {
4624 onChangeView({
4625 ...view,
4626 fields: [
4627 ...visibleFieldIds.slice(
4628 0,
4629 insertIndex
4630 ),
4631 hiddenField.id,
4632 ...visibleFieldIds.slice(
4633 insertIndex
4634 )
4635 ]
4636 });
4637 },
4638 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
4639 },
4640 hiddenField.id
4641 );
4642 }) })
4643 ] }),
4644 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
4645 Menu2.Item,
4646 {
4647 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: unseen_default }),
4648 onClick: () => {
4649 onHide(field);
4650 onChangeView({
4651 ...view,
4652 fields: visibleFieldIds.filter(
4653 (id) => id !== fieldId
4654 )
4655 });
4656 },
4657 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n7.__)("Hide column") })
4658 }
4659 )
4660 ] })
4661 ] }) })
4662 ] });
4663 });
4664 var ColumnHeaderMenu = _HeaderMenu;
4665 var column_header_menu_default = ColumnHeaderMenu;
4666
4667 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
4668 var import_element25 = __toESM(require_element(), 1);
4669 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
4670 function getClickableItemProps({
4671 item,
4672 isItemClickable,
4673 onClickItem,
4674 className
4675 }) {
4676 if (!isItemClickable(item) || !onClickItem) {
4677 return { className };
4678 }
4679 return {
4680 className: className ? `${className} ${className}--clickable` : void 0,
4681 role: "button",
4682 tabIndex: 0,
4683 onClick: (event) => {
4684 event.stopPropagation();
4685 onClickItem(item);
4686 },
4687 onKeyDown: (event) => {
4688 if (event.key === "Enter" || event.key === "" || event.key === " ") {
4689 event.stopPropagation();
4690 onClickItem(item);
4691 }
4692 }
4693 };
4694 }
4695 function ItemClickWrapper({
4696 item,
4697 isItemClickable,
4698 onClickItem,
4699 renderItemLink,
4700 className,
4701 children,
4702 ...extraProps
4703 }) {
4704 if (!isItemClickable(item)) {
4705 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, ...extraProps, children });
4706 }
4707 if (renderItemLink) {
4708 const renderedElement = renderItemLink({
4709 item,
4710 className: `${className} ${className}--clickable`,
4711 ...extraProps,
4712 children
4713 });
4714 return (0, import_element25.cloneElement)(renderedElement, {
4715 onClick: (event) => {
4716 event.stopPropagation();
4717 if (renderedElement.props.onClick) {
4718 renderedElement.props.onClick(event);
4719 }
4720 },
4721 onKeyDown: (event) => {
4722 if (event.key === "Enter" || event.key === "" || event.key === " ") {
4723 event.stopPropagation();
4724 if (renderedElement.props.onKeyDown) {
4725 renderedElement.props.onKeyDown(event);
4726 }
4727 }
4728 }
4729 });
4730 }
4731 const clickProps = getClickableItemProps({
4732 item,
4733 isItemClickable,
4734 onClickItem,
4735 className
4736 });
4737 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ...clickProps, ...extraProps, children });
4738 }
4739
4740 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
4741 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
4742 function ColumnPrimary({
4743 item,
4744 level,
4745 titleField,
4746 mediaField,
4747 descriptionField,
4748 onClickItem,
4749 renderItemLink,
4750 isItemClickable
4751 }) {
4752 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
4753 mediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4754 ItemClickWrapper,
4755 {
4756 item,
4757 isItemClickable,
4758 onClickItem,
4759 renderItemLink,
4760 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
4761 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
4762 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4763 mediaField.render,
4764 {
4765 item,
4766 field: mediaField,
4767 config: { sizes: "32px" }
4768 }
4769 )
4770 }
4771 ),
4772 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4773 Stack,
4774 {
4775 direction: "column",
4776 align: "flex-start",
4777 className: "dataviews-view-table__primary-column-content",
4778 children: [
4779 titleField && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
4780 ItemClickWrapper,
4781 {
4782 item,
4783 isItemClickable,
4784 onClickItem,
4785 renderItemLink,
4786 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
4787 children: [
4788 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "dataviews-view-table__level", children: [
4789 Array(level).fill("\u2014").join(" "),
4790 "\xA0"
4791 ] }),
4792 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(titleField.render, { item, field: titleField })
4793 ]
4794 }
4795 ),
4796 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
4797 descriptionField.render,
4798 {
4799 item,
4800 field: descriptionField
4801 }
4802 )
4803 ]
4804 }
4805 )
4806 ] });
4807 }
4808 var column_primary_default = ColumnPrimary;
4809
4810 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
4811 var import_element26 = __toESM(require_element(), 1);
4812 var import_i18n8 = __toESM(require_i18n(), 1);
4813 var isScrolledToEnd = (element) => {
4814 if ((0, import_i18n8.isRTL)()) {
4815 const scrollLeft = Math.abs(element.scrollLeft);
4816 return scrollLeft <= 1;
4817 }
4818 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
4819 };
4820 function useScrollState({
4821 scrollContainerRef,
4822 enabledHorizontal = false
4823 }) {
4824 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element26.useState)(false);
4825 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element26.useState)(false);
4826 const handleScroll = (0, import_element26.useCallback)(() => {
4827 const scrollContainer = scrollContainerRef.current;
4828 if (!scrollContainer) {
4829 return;
4830 }
4831 if (enabledHorizontal) {
4832 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
4833 }
4834 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
4835 }, [scrollContainerRef, enabledHorizontal]);
4836 (0, import_element26.useEffect)(() => {
4837 if (typeof window === "undefined" || !scrollContainerRef.current) {
4838 return () => {
4839 };
4840 }
4841 const scrollContainer = scrollContainerRef.current;
4842 handleScroll();
4843 scrollContainer.addEventListener("scroll", handleScroll);
4844 window.addEventListener("resize", handleScroll);
4845 return () => {
4846 scrollContainer.removeEventListener("scroll", handleScroll);
4847 window.removeEventListener("resize", handleScroll);
4848 };
4849 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
4850 return { isHorizontalScrollEnd, isVerticallyScrolled };
4851 }
4852
4853 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
4854 function getDataByGroup(data, groupByField) {
4855 return data.reduce((groups, item) => {
4856 const groupName = groupByField.getValue({ item });
4857 if (!groups.has(groupName)) {
4858 groups.set(groupName, []);
4859 }
4860 groups.get(groupName)?.push(item);
4861 return groups;
4862 }, /* @__PURE__ */ new Map());
4863 }
4864
4865 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
4866 var import_components7 = __toESM(require_components(), 1);
4867 var import_i18n9 = __toESM(require_i18n(), 1);
4868 var import_element27 = __toESM(require_element(), 1);
4869 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
4870 function FieldItem({
4871 field,
4872 isVisible: isVisible2,
4873 onToggleVisibility
4874 }) {
4875 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.__experimentalItem, { onClick: field.enableHiding ? onToggleVisibility : void 0, children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Stack, { direction: "row", gap: "sm", justify: "flex-start", align: "center", children: [
4876 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { style: { height: 24, width: 24 }, children: isVisible2 && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.Icon, { icon: check_default }) }),
4877 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
4878 ] }) });
4879 }
4880 function isDefined(item) {
4881 return !!item;
4882 }
4883 function PropertiesSection({
4884 showLabel = true
4885 }) {
4886 const { view, fields: fields2, onChangeView } = (0, import_element27.useContext)(dataviews_context_default);
4887 const regularFields = getHideableFields(view, fields2);
4888 if (!regularFields?.length) {
4889 return null;
4890 }
4891 const titleField = fields2.find((f2) => f2.id === view.titleField);
4892 const previewField = fields2.find((f2) => f2.id === view.mediaField);
4893 const descriptionField = fields2.find(
4894 (f2) => f2.id === view.descriptionField
4895 );
4896 const lockedFields = [
4897 {
4898 field: titleField,
4899 isVisibleFlag: "showTitle"
4900 },
4901 {
4902 field: previewField,
4903 isVisibleFlag: "showMedia"
4904 },
4905 {
4906 field: descriptionField,
4907 isVisibleFlag: "showDescription"
4908 }
4909 ].filter(({ field }) => isDefined(field));
4910 const visibleFieldIds = view.fields ?? [];
4911 const visibleRegularFieldsCount = regularFields.filter(
4912 (f2) => visibleFieldIds.includes(f2.id)
4913 ).length;
4914 const visibleLockedFields = lockedFields.filter(
4915 ({ isVisibleFlag }) => (
4916 // @ts-expect-error
4917 view[isVisibleFlag] ?? true
4918 )
4919 );
4920 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
4921 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
4922 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
4923 showLabel && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n9.__)("Properties") }),
4924 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4925 Stack,
4926 {
4927 direction: "column",
4928 className: "dataviews-view-config__properties",
4929 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
4930 lockedFields.map(({ field, isVisibleFlag }) => {
4931 const isVisible2 = view[isVisibleFlag] ?? true;
4932 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
4933 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4934 FieldItem,
4935 {
4936 field: fieldToRender,
4937 isVisible: isVisible2,
4938 onToggleVisibility: () => {
4939 onChangeView({
4940 ...view,
4941 [isVisibleFlag]: !isVisible2
4942 });
4943 }
4944 },
4945 field.id
4946 );
4947 }),
4948 regularFields.map((field) => {
4949 const isVisible2 = visibleFieldIds.includes(field.id);
4950 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
4951 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
4952 FieldItem,
4953 {
4954 field: fieldToRender,
4955 isVisible: isVisible2,
4956 onToggleVisibility: () => {
4957 onChangeView({
4958 ...view,
4959 fields: isVisible2 ? visibleFieldIds.filter(
4960 (fieldId) => fieldId !== field.id
4961 ) : [...visibleFieldIds, field.id]
4962 });
4963 }
4964 },
4965 field.id
4966 );
4967 })
4968 ] })
4969 }
4970 )
4971 ] });
4972 }
4973
4974 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
4975 var import_element28 = __toESM(require_element(), 1);
4976 function useDelayedLoading(isLoading, options = { delay: 400 }) {
4977 const [showLoader, setShowLoader] = (0, import_element28.useState)(false);
4978 (0, import_element28.useEffect)(() => {
4979 if (!isLoading) {
4980 return;
4981 }
4982 const timeout = setTimeout(() => {
4983 setShowLoader(true);
4984 }, options.delay);
4985 return () => {
4986 clearTimeout(timeout);
4987 setShowLoader(false);
4988 };
4989 }, [isLoading, options.delay]);
4990 return showLoader;
4991 }
4992
4993 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
4994 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
4995 function getEffectiveAlign(explicitAlign, fieldType) {
4996 if (explicitAlign) {
4997 return explicitAlign;
4998 }
4999 if (fieldType === "integer" || fieldType === "number") {
5000 return "end";
5001 }
5002 return void 0;
5003 }
5004 function TableColumnField({
5005 item,
5006 fields: fields2,
5007 column,
5008 align
5009 }) {
5010 const field = fields2.find((f2) => f2.id === column);
5011 if (!field) {
5012 return null;
5013 }
5014 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5015 "dataviews-view-table__cell-align-end": align === "end",
5016 "dataviews-view-table__cell-align-center": align === "center"
5017 });
5018 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(field.render, { item, field }) });
5019 }
5020 function TableRow({
5021 hasBulkActions,
5022 item,
5023 level,
5024 actions: actions2,
5025 fields: fields2,
5026 id,
5027 view,
5028 titleField,
5029 mediaField,
5030 descriptionField,
5031 selection,
5032 getItemId,
5033 isItemClickable,
5034 onClickItem,
5035 renderItemLink,
5036 onChangeSelection,
5037 isActionsColumnSticky,
5038 posinset
5039 }) {
5040 const { paginationInfo } = (0, import_element29.useContext)(dataviews_context_default);
5041 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions2, item);
5042 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
5043 const {
5044 showTitle = true,
5045 showMedia = true,
5046 showDescription = true,
5047 infiniteScrollEnabled
5048 } = view;
5049 const isTouchDeviceRef = (0, import_element29.useRef)(false);
5050 const columns = view.fields ?? [];
5051 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5052 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5053 "tr",
5054 {
5055 className: clsx_default("dataviews-view-table__row", {
5056 "is-selected": hasPossibleBulkAction && isSelected2,
5057 "has-bulk-actions": hasPossibleBulkAction
5058 }),
5059 onTouchStart: () => {
5060 isTouchDeviceRef.current = true;
5061 },
5062 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
5063 "aria-posinset": posinset,
5064 role: infiniteScrollEnabled ? "article" : void 0,
5065 onMouseDown: (event) => {
5066 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
5067 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
5068 event?.preventDefault();
5069 }
5070 },
5071 onClick: (event) => {
5072 if (!hasPossibleBulkAction) {
5073 return;
5074 }
5075 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
5076 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
5077 onChangeSelection(
5078 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
5079 );
5080 }
5081 },
5082 children: [
5083 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { className: "dataviews-view-table__checkbox-column", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5084 DataViewsSelectionCheckbox,
5085 {
5086 item,
5087 selection,
5088 onChangeSelection,
5089 getItemId,
5090 titleField,
5091 disabled: !hasPossibleBulkAction
5092 }
5093 ) }) }),
5094 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5095 column_primary_default,
5096 {
5097 item,
5098 level,
5099 titleField: showTitle ? titleField : void 0,
5100 mediaField: showMedia ? mediaField : void 0,
5101 descriptionField: showDescription ? descriptionField : void 0,
5102 isItemClickable,
5103 onClickItem,
5104 renderItemLink
5105 }
5106 ) }),
5107 columns.map((column) => {
5108 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5109 const field = fields2.find((f2) => f2.id === column);
5110 const effectiveAlign = getEffectiveAlign(align, field?.type);
5111 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5112 "td",
5113 {
5114 style: {
5115 width,
5116 maxWidth,
5117 minWidth
5118 },
5119 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5120 TableColumnField,
5121 {
5122 fields: fields2,
5123 item,
5124 column,
5125 align: effectiveAlign
5126 }
5127 )
5128 },
5129 column
5130 );
5131 }),
5132 !!actions2?.length && // Disable reason: we are not making the element interactive,
5133 // but preventing any click events from bubbling up to the
5134 // table row. This allows us to add a click handler to the row
5135 // itself (to toggle row selection) without erroneously
5136 // intercepting click events from ItemActions.
5137 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5138 "td",
5139 {
5140 className: clsx_default("dataviews-view-table__actions-column", {
5141 "dataviews-view-table__actions-column--sticky": true,
5142 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
5143 }),
5144 onClick: (e2) => e2.stopPropagation(),
5145 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ItemActions, { item, actions: actions2 })
5146 }
5147 )
5148 ]
5149 }
5150 );
5151 }
5152 function ViewTable({
5153 actions: actions2,
5154 data,
5155 fields: fields2,
5156 getItemId,
5157 getItemLevel,
5158 isLoading = false,
5159 onChangeView,
5160 onChangeSelection,
5161 selection,
5162 setOpenedFilter,
5163 onClickItem,
5164 isItemClickable,
5165 renderItemLink,
5166 view,
5167 className,
5168 empty
5169 }) {
5170 const { containerRef } = (0, import_element29.useContext)(dataviews_context_default);
5171 const isDelayedLoading = useDelayedLoading(isLoading);
5172 const headerMenuRefs = (0, import_element29.useRef)(/* @__PURE__ */ new Map());
5173 const headerMenuToFocusRef = (0, import_element29.useRef)(void 0);
5174 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element29.useState)();
5175 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element29.useState)(null);
5176 (0, import_element29.useEffect)(() => {
5177 if (headerMenuToFocusRef.current) {
5178 headerMenuToFocusRef.current.focus();
5179 headerMenuToFocusRef.current = void 0;
5180 }
5181 });
5182 const tableNoticeId = (0, import_element29.useId)();
5183 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
5184 scrollContainerRef: containerRef,
5185 enabledHorizontal: !!actions2?.length
5186 });
5187 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
5188 if (nextHeaderMenuToFocus) {
5189 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
5190 setNextHeaderMenuToFocus(void 0);
5191 return;
5192 }
5193 const onHide = (field) => {
5194 const hidden = headerMenuRefs.current.get(field.id);
5195 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
5196 setNextHeaderMenuToFocus(fallback?.node);
5197 };
5198 const handleHeaderContextMenu = (event) => {
5199 event.preventDefault();
5200 event.stopPropagation();
5201 const virtualAnchor = {
5202 getBoundingClientRect: () => ({
5203 x: event.clientX,
5204 y: event.clientY,
5205 top: event.clientY,
5206 left: event.clientX,
5207 right: event.clientX,
5208 bottom: event.clientY,
5209 width: 0,
5210 height: 0,
5211 toJSON: () => ({})
5212 })
5213 };
5214 window.requestAnimationFrame(() => {
5215 setContextMenuAnchor(virtualAnchor);
5216 });
5217 };
5218 const hasData = !!data?.length;
5219 const titleField = fields2.find((field) => field.id === view.titleField);
5220 const mediaField = fields2.find((field) => field.id === view.mediaField);
5221 const descriptionField = fields2.find(
5222 (field) => field.id === view.descriptionField
5223 );
5224 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
5225 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
5226 const { showTitle = true, showMedia = true, showDescription = true } = view;
5227 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5228 const columns = view.fields ?? [];
5229 const headerMenuRef = (column, index) => (node) => {
5230 if (node) {
5231 headerMenuRefs.current.set(column, {
5232 node,
5233 fallback: columns[index > 0 ? index - 1 : 1]
5234 });
5235 } else {
5236 headerMenuRefs.current.delete(column);
5237 }
5238 };
5239 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
5240 const isRtl = (0, import_i18n10.isRTL)();
5241 if (!hasData) {
5242 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5243 "div",
5244 {
5245 className: clsx_default("dataviews-no-results", {
5246 "is-refreshing": isDelayedLoading
5247 }),
5248 id: tableNoticeId,
5249 children: empty
5250 }
5251 );
5252 }
5253 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
5254 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5255 "table",
5256 {
5257 className: clsx_default("dataviews-view-table", className, {
5258 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5259 view.layout.density
5260 ),
5261 "has-bulk-actions": hasBulkActions,
5262 "is-refreshing": !isInfiniteScroll && isDelayedLoading
5263 }),
5264 "aria-busy": isLoading,
5265 "aria-describedby": tableNoticeId,
5266 role: isInfiniteScroll ? "feed" : void 0,
5267 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
5268 children: [
5269 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("colgroup", { children: [
5270 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
5271 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
5272 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5273 "col",
5274 {
5275 className: clsx_default(
5276 `dataviews-view-table__col-${column}`,
5277 {
5278 "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
5279 }
5280 )
5281 },
5282 `col-${column}`
5283 )),
5284 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-actions" })
5285 ] }),
5286 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5287 import_components8.Popover,
5288 {
5289 anchor: contextMenuAnchor,
5290 onClose: () => setContextMenuAnchor(null),
5291 placement: "bottom-start",
5292 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PropertiesSection, { showLabel: false })
5293 }
5294 ),
5295 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5296 "thead",
5297 {
5298 className: clsx_default({
5299 "dataviews-view-table__thead--stuck": isVerticallyScrolled
5300 }),
5301 onContextMenu: handleHeaderContextMenu,
5302 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tr", { className: "dataviews-view-table__row", children: [
5303 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5304 "th",
5305 {
5306 className: "dataviews-view-table__checkbox-column",
5307 scope: "col",
5308 onContextMenu: handleHeaderContextMenu,
5309 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5310 BulkSelectionCheckbox,
5311 {
5312 selection,
5313 onChangeSelection,
5314 data,
5315 actions: actions2,
5316 getItemId
5317 }
5318 )
5319 }
5320 ),
5321 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5322 column_header_menu_default,
5323 {
5324 ref: headerMenuRef(
5325 titleField.id,
5326 0
5327 ),
5328 fieldId: titleField.id,
5329 view,
5330 fields: fields2,
5331 onChangeView,
5332 onHide,
5333 setOpenedFilter,
5334 canMove: false,
5335 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
5336 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
5337 }
5338 ) }),
5339 columns.map((column, index) => {
5340 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5341 const field = fields2.find(
5342 (f2) => f2.id === column
5343 );
5344 const effectiveAlign = getEffectiveAlign(
5345 align,
5346 field?.type
5347 );
5348 const canInsertOrMove = view.layout?.enableMoving ?? true;
5349 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5350 "th",
5351 {
5352 style: {
5353 width,
5354 maxWidth,
5355 minWidth,
5356 textAlign: effectiveAlign
5357 },
5358 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
5359 scope: "col",
5360 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5361 column_header_menu_default,
5362 {
5363 ref: headerMenuRef(column, index),
5364 fieldId: column,
5365 view,
5366 fields: fields2,
5367 onChangeView,
5368 onHide,
5369 setOpenedFilter,
5370 canMove: canInsertOrMove,
5371 canInsertLeft: canInsertOrMove,
5372 canInsertRight: canInsertOrMove
5373 }
5374 )
5375 },
5376 column
5377 );
5378 }),
5379 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5380 "th",
5381 {
5382 className: clsx_default(
5383 "dataviews-view-table__actions-column",
5384 {
5385 "dataviews-view-table__actions-column--sticky": true,
5386 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
5387 }
5388 ),
5389 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n10.__)("Actions") })
5390 }
5391 )
5392 ] })
5393 }
5394 ),
5395 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
5396 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tbody", { children: [
5397 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5398 "td",
5399 {
5400 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions2?.length ? 1 : 0),
5401 className: "dataviews-view-table__group-header-cell",
5402 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n10.sprintf)(
5403 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
5404 (0, import_i18n10.__)("%1$s: %2$s"),
5405 groupField.label,
5406 groupName
5407 )
5408 }
5409 ) }),
5410 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5411 TableRow,
5412 {
5413 item,
5414 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
5415 hasBulkActions,
5416 actions: actions2,
5417 fields: fields2,
5418 id: getItemId(item) || index.toString(),
5419 view,
5420 titleField,
5421 mediaField,
5422 descriptionField,
5423 selection,
5424 getItemId,
5425 onChangeSelection,
5426 onClickItem,
5427 renderItemLink,
5428 isItemClickable,
5429 isActionsColumnSticky: !isHorizontalScrollEnd
5430 },
5431 getItemId(item)
5432 ))
5433 ] }, `group-${groupName}`)
5434 ) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5435 TableRow,
5436 {
5437 item,
5438 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
5439 hasBulkActions,
5440 actions: actions2,
5441 fields: fields2,
5442 id: getItemId(item) || index.toString(),
5443 view,
5444 titleField,
5445 mediaField,
5446 descriptionField,
5447 selection,
5448 getItemId,
5449 onChangeSelection,
5450 onClickItem,
5451 renderItemLink,
5452 isItemClickable,
5453 isActionsColumnSticky: !isHorizontalScrollEnd,
5454 posinset: isInfiniteScroll ? index + 1 : void 0
5455 },
5456 getItemId(item)
5457 )) })
5458 ]
5459 }
5460 ),
5461 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "dataviews-loading", id: tableNoticeId, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components8.Spinner, {}) }) })
5462 ] });
5463 }
5464 var table_default = ViewTable;
5465
5466 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
5467 var import_components11 = __toESM(require_components(), 1);
5468 var import_i18n13 = __toESM(require_i18n(), 1);
5469
5470 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
5471 var import_components10 = __toESM(require_components(), 1);
5472 var import_i18n12 = __toESM(require_i18n(), 1);
5473 var import_compose3 = __toESM(require_compose(), 1);
5474 var import_keycodes2 = __toESM(require_keycodes(), 1);
5475 var import_element33 = __toESM(require_element(), 1);
5476
5477 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
5478 var import_components9 = __toESM(require_components(), 1);
5479 var import_i18n11 = __toESM(require_i18n(), 1);
5480 var import_element30 = __toESM(require_element(), 1);
5481 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
5482 var imageSizes = [
5483 {
5484 value: 120,
5485 breakpoint: 1
5486 },
5487 {
5488 value: 170,
5489 breakpoint: 1
5490 },
5491 {
5492 value: 230,
5493 breakpoint: 1
5494 },
5495 {
5496 value: 290,
5497 breakpoint: 1112
5498 // at minimum image width, 4 images display at this container size
5499 },
5500 {
5501 value: 350,
5502 breakpoint: 1636
5503 // at minimum image width, 6 images display at this container size
5504 },
5505 {
5506 value: 430,
5507 breakpoint: 588
5508 // at minimum image width, 2 images display at this container size
5509 }
5510 ];
5511 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
5512 function useGridColumns() {
5513 const context = (0, import_element30.useContext)(dataviews_context_default);
5514 const view = context.view;
5515 return (0, import_element30.useMemo)(() => {
5516 const containerWidth = context.containerWidth;
5517 const gap = 32;
5518 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
5519 const columns = Math.floor(
5520 (containerWidth + gap) / (previewSize + gap)
5521 );
5522 return Math.max(1, columns);
5523 }, [context.containerWidth, view.layout?.previewSize]);
5524 }
5525
5526 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
5527 var import_element31 = __toESM(require_element(), 1);
5528 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
5529 var GridItems = (0, import_element31.forwardRef)(({ className, previewSize, ...props }, ref) => {
5530 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
5531 "div",
5532 {
5533 ref,
5534 className: clsx_default("dataviews-view-grid-items", className),
5535 style: {
5536 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
5537 },
5538 ...props
5539 }
5540 );
5541 });
5542
5543 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
5544 var import_element32 = __toESM(require_element(), 1);
5545 function useIntersectionObserver(elementRef, posinset) {
5546 const { intersectionObserver } = (0, import_element32.useContext)(dataviews_context_default);
5547 (0, import_element32.useEffect)(() => {
5548 const element = elementRef.current;
5549 if (!element || posinset === void 0 || !intersectionObserver) {
5550 return;
5551 }
5552 intersectionObserver.observe(element);
5553 return () => {
5554 intersectionObserver.unobserve(element);
5555 };
5556 }, [elementRef, intersectionObserver, posinset]);
5557 }
5558 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
5559 const hasData = !!data?.length;
5560 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
5561 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
5562 }
5563
5564 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
5565 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
5566 var { Badge: WCBadge } = unlock(import_components10.privateApis);
5567 function chunk(array, size) {
5568 const chunks = [];
5569 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
5570 chunks.push(array.slice(i2, i2 + size));
5571 }
5572 return chunks;
5573 }
5574 var GridItem = (0, import_element33.forwardRef)(
5575 function GridItem2({
5576 view,
5577 selection,
5578 onChangeSelection,
5579 onClickItem,
5580 isItemClickable,
5581 renderItemLink,
5582 getItemId,
5583 item,
5584 actions: actions2,
5585 mediaField,
5586 titleField,
5587 descriptionField,
5588 regularFields,
5589 badgeFields,
5590 hasBulkActions,
5591 config,
5592 posinset,
5593 setsize,
5594 ...props
5595 }, forwardedRef) {
5596 const {
5597 showTitle = true,
5598 showMedia = true,
5599 showDescription = true
5600 } = view;
5601 const hasBulkAction = useHasAPossibleBulkAction(actions2, item);
5602 const id = getItemId(item);
5603 const elementRef = (0, import_element33.useRef)(null);
5604 const setRefs = (0, import_element33.useCallback)(
5605 (node) => {
5606 elementRef.current = node;
5607 if (typeof forwardedRef === "function") {
5608 forwardedRef(node);
5609 } else if (forwardedRef) {
5610 forwardedRef.current = node;
5611 }
5612 },
5613 [forwardedRef]
5614 );
5615 useIntersectionObserver(elementRef, posinset);
5616 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
5617 const isSelected2 = selection.includes(id);
5618 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
5619 const rendersMediaField = showMedia && mediaField?.render;
5620 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5621 mediaField.render,
5622 {
5623 item,
5624 field: mediaField,
5625 config
5626 }
5627 ) : mediaPlaceholder;
5628 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField }) : null;
5629 let mediaA11yProps;
5630 let titleA11yProps;
5631 if (isItemClickable(item) && onClickItem) {
5632 if (renderedTitleField) {
5633 mediaA11yProps = {
5634 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
5635 };
5636 titleA11yProps = {
5637 id: `dataviews-view-grid__title-field-${instanceId}`
5638 };
5639 } else {
5640 mediaA11yProps = {
5641 "aria-label": (0, import_i18n12.__)("Navigate to item")
5642 };
5643 }
5644 }
5645 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5646 Stack,
5647 {
5648 direction: "column",
5649 ...props,
5650 ref: setRefs,
5651 "aria-setsize": setsize,
5652 "aria-posinset": posinset,
5653 className: clsx_default(
5654 props.className,
5655 "dataviews-view-grid__row__gridcell",
5656 "dataviews-view-grid__card",
5657 {
5658 "is-selected": hasBulkAction && isSelected2
5659 }
5660 ),
5661 onClickCapture: (event) => {
5662 props.onClickCapture?.(event);
5663 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
5664 event.stopPropagation();
5665 event.preventDefault();
5666 if (!hasBulkAction) {
5667 return;
5668 }
5669 onChangeSelection(
5670 isSelected2 ? selection.filter(
5671 (itemId) => id !== itemId
5672 ) : [...selection, id]
5673 );
5674 }
5675 },
5676 children: [
5677 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5678 ItemClickWrapper,
5679 {
5680 item,
5681 isItemClickable,
5682 onClickItem,
5683 renderItemLink,
5684 className: clsx_default("dataviews-view-grid__media", {
5685 "dataviews-view-grid__media--placeholder": !rendersMediaField
5686 }),
5687 ...mediaA11yProps,
5688 children: renderedMediaField
5689 }
5690 ),
5691 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5692 DataViewsSelectionCheckbox,
5693 {
5694 item,
5695 selection,
5696 onChangeSelection,
5697 getItemId,
5698 titleField,
5699 disabled: !hasBulkAction
5700 }
5701 ),
5702 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5703 ItemActions,
5704 {
5705 item,
5706 actions: actions2,
5707 isCompact: true
5708 }
5709 ) }),
5710 showTitle && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5711 ItemClickWrapper,
5712 {
5713 item,
5714 isItemClickable,
5715 onClickItem,
5716 renderItemLink,
5717 className: "dataviews-view-grid__title-field dataviews-title-field",
5718 ...titleA11yProps,
5719 title: titleField?.getValueFormatted({
5720 item,
5721 field: titleField
5722 }) || void 0,
5723 children: renderedTitleField
5724 }
5725 ) }),
5726 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", gap: "xs", children: [
5727 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5728 descriptionField.render,
5729 {
5730 item,
5731 field: descriptionField
5732 }
5733 ),
5734 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5735 Stack,
5736 {
5737 direction: "row",
5738 className: "dataviews-view-grid__badge-fields",
5739 gap: "sm",
5740 wrap: "wrap",
5741 align: "top",
5742 justify: "flex-start",
5743 children: badgeFields.map((field) => {
5744 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5745 WCBadge,
5746 {
5747 className: "dataviews-view-grid__field-value",
5748 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5749 field.render,
5750 {
5751 item,
5752 field
5753 }
5754 )
5755 },
5756 field.id
5757 );
5758 })
5759 }
5760 ),
5761 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5762 Stack,
5763 {
5764 direction: "column",
5765 className: "dataviews-view-grid__fields",
5766 gap: "xs",
5767 children: regularFields.map((field) => {
5768 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5769 import_components10.Flex,
5770 {
5771 className: "dataviews-view-grid__field",
5772 gap: 1,
5773 justify: "flex-start",
5774 expanded: true,
5775 style: { height: "auto" },
5776 direction: "row",
5777 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
5778 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components10.Tooltip, { text: field.label, children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components10.FlexItem, { className: "dataviews-view-grid__field-name", children: field.header }) }),
5779 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5780 import_components10.FlexItem,
5781 {
5782 className: "dataviews-view-grid__field-value",
5783 style: { maxHeight: "none" },
5784 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5785 field.render,
5786 {
5787 item,
5788 field
5789 }
5790 )
5791 }
5792 )
5793 ] })
5794 },
5795 field.id
5796 );
5797 })
5798 }
5799 )
5800 ] })
5801 ]
5802 }
5803 );
5804 }
5805 );
5806 function CompositeGrid({
5807 data,
5808 isInfiniteScroll,
5809 className,
5810 inert,
5811 isLoading,
5812 view,
5813 fields: fields2,
5814 selection,
5815 onChangeSelection,
5816 onClickItem,
5817 isItemClickable,
5818 renderItemLink,
5819 getItemId,
5820 actions: actions2
5821 }) {
5822 const { paginationInfo, resizeObserverRef } = (0, import_element33.useContext)(dataviews_context_default);
5823 const gridColumns = useGridColumns();
5824 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
5825 const titleField = fields2.find(
5826 (field) => field.id === view?.titleField
5827 );
5828 const mediaField = fields2.find(
5829 (field) => field.id === view?.mediaField
5830 );
5831 const descriptionField = fields2.find(
5832 (field) => field.id === view?.descriptionField
5833 );
5834 const otherFields = view.fields ?? [];
5835 const { regularFields, badgeFields } = otherFields.reduce(
5836 (accumulator, fieldId) => {
5837 const field = fields2.find((f2) => f2.id === fieldId);
5838 if (!field) {
5839 return accumulator;
5840 }
5841 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
5842 accumulator[key].push(field);
5843 return accumulator;
5844 },
5845 { regularFields: [], badgeFields: [] }
5846 );
5847 const size = "900px";
5848 const totalRows = Math.ceil(data.length / gridColumns);
5849 const placeholdersNeeded = usePlaceholdersNeeded(
5850 data,
5851 isInfiniteScroll,
5852 gridColumns
5853 );
5854 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, {
5855 // Render infinite scroll layout (no rows, feed semantics)
5856 children: [
5857 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
5858 import_components10.Composite,
5859 {
5860 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5861 GridItems,
5862 {
5863 className: clsx_default(
5864 "dataviews-view-grid-infinite-scroll",
5865 className,
5866 {
5867 [`has-${view.layout?.density}-density`]: view.layout?.density && [
5868 "compact",
5869 "comfortable"
5870 ].includes(view.layout.density)
5871 }
5872 ),
5873 previewSize: view.layout?.previewSize,
5874 "aria-busy": isLoading,
5875 ref: resizeObserverRef
5876 }
5877 ),
5878 role: "feed",
5879 focusWrap: true,
5880 inert,
5881 children: [
5882 Array.from({ length: placeholdersNeeded }).map(
5883 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5884 import_components10.Composite.Item,
5885 {
5886 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5887 Stack,
5888 {
5889 ...props,
5890 direction: "column",
5891 role: "article",
5892 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
5893 }
5894 ),
5895 "aria-hidden": true,
5896 tabIndex: -1
5897 },
5898 `placeholder-${index}`
5899 )
5900 ),
5901 data.map((item) => {
5902 const itemId = getItemId(item);
5903 const stablePosition = item.position;
5904 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5905 import_components10.Composite.Item,
5906 {
5907 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5908 GridItem,
5909 {
5910 ...props,
5911 id: itemId,
5912 role: "article",
5913 view,
5914 selection,
5915 onChangeSelection,
5916 onClickItem,
5917 isItemClickable,
5918 renderItemLink,
5919 getItemId,
5920 item,
5921 actions: actions2,
5922 mediaField,
5923 titleField,
5924 descriptionField,
5925 regularFields,
5926 badgeFields,
5927 hasBulkActions,
5928 posinset: stablePosition,
5929 setsize: paginationInfo.totalItems,
5930 config: {
5931 sizes: size
5932 }
5933 }
5934 )
5935 },
5936 itemId
5937 );
5938 })
5939 ]
5940 }
5941 ),
5942 // Render standard grid layout (with rows, grid semantics)
5943 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5944 import_components10.Composite,
5945 {
5946 role: "grid",
5947 className: clsx_default("dataviews-view-grid", className, {
5948 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
5949 view.layout.density
5950 )
5951 }),
5952 focusWrap: true,
5953 "aria-busy": isLoading,
5954 "aria-rowcount": totalRows,
5955 ref: resizeObserverRef,
5956 inert,
5957 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5958 import_components10.Composite.Row,
5959 {
5960 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5961 "div",
5962 {
5963 role: "row",
5964 "aria-rowindex": i2 + 1,
5965 "aria-label": (0, import_i18n12.sprintf)(
5966 /* translators: %d: The row number in the grid */
5967 (0, import_i18n12.__)("Row %d"),
5968 i2 + 1
5969 ),
5970 className: "dataviews-view-grid__row",
5971 style: {
5972 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
5973 }
5974 }
5975 ),
5976 children: row.map((item) => {
5977 const itemId = getItemId(item);
5978 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5979 import_components10.Composite.Item,
5980 {
5981 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
5982 GridItem,
5983 {
5984 ...props,
5985 id: itemId,
5986 role: "gridcell",
5987 view,
5988 selection,
5989 onChangeSelection,
5990 onClickItem,
5991 isItemClickable,
5992 renderItemLink,
5993 getItemId,
5994 item,
5995 actions: actions2,
5996 mediaField,
5997 titleField,
5998 descriptionField,
5999 regularFields,
6000 badgeFields,
6001 hasBulkActions,
6002 config: {
6003 sizes: size
6004 }
6005 }
6006 )
6007 },
6008 itemId
6009 );
6010 })
6011 },
6012 i2
6013 ))
6014 }
6015 )
6016 ]
6017 });
6018 }
6019
6020 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
6021 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
6022 function ViewGrid({
6023 actions: actions2,
6024 data,
6025 fields: fields2,
6026 getItemId,
6027 isLoading,
6028 onChangeSelection,
6029 onClickItem,
6030 isItemClickable,
6031 renderItemLink,
6032 selection,
6033 view,
6034 className,
6035 empty
6036 }) {
6037 const isDelayedLoading = useDelayedLoading(!!isLoading);
6038 const hasData = !!data?.length;
6039 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
6040 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
6041 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6042 if (!hasData) {
6043 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6044 "div",
6045 {
6046 className: clsx_default("dataviews-no-results", {
6047 "is-refreshing": isDelayedLoading
6048 }),
6049 children: empty
6050 }
6051 );
6052 }
6053 const gridProps = {
6054 className: clsx_default(className, {
6055 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6056 }),
6057 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
6058 isLoading,
6059 view,
6060 fields: fields2,
6061 selection,
6062 onChangeSelection,
6063 onClickItem,
6064 isItemClickable,
6065 renderItemLink,
6066 getItemId,
6067 actions: actions2
6068 };
6069 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, {
6070 // Render multiple groups.
6071 children: [
6072 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
6073 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
6074 Stack,
6075 {
6076 direction: "column",
6077 gap: "sm",
6078 children: [
6079 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
6080 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6081 (0, import_i18n13.__)("%1$s: %2$s"),
6082 groupField.label,
6083 groupName
6084 ) }),
6085 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6086 CompositeGrid,
6087 {
6088 ...gridProps,
6089 data: groupItems,
6090 isInfiniteScroll: false
6091 }
6092 )
6093 ]
6094 },
6095 groupName
6096 )
6097 ) }),
6098 // Render a single grid with all data.
6099 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6100 CompositeGrid,
6101 {
6102 ...gridProps,
6103 data,
6104 isInfiniteScroll: !!isInfiniteScroll
6105 }
6106 ),
6107 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components11.Spinner, {}) })
6108 ]
6109 });
6110 }
6111 var grid_default = ViewGrid;
6112
6113 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
6114 var import_compose4 = __toESM(require_compose(), 1);
6115 var import_components12 = __toESM(require_components(), 1);
6116 var import_element34 = __toESM(require_element(), 1);
6117 var import_i18n14 = __toESM(require_i18n(), 1);
6118 var import_data3 = __toESM(require_data(), 1);
6119 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
6120 var { Menu: Menu3 } = unlock(import_components12.privateApis);
6121 function generateItemWrapperCompositeId(idPrefix) {
6122 return `${idPrefix}-item-wrapper`;
6123 }
6124 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
6125 return `${idPrefix}-primary-action-${primaryActionId}`;
6126 }
6127 function generateDropdownTriggerCompositeId(idPrefix) {
6128 return `${idPrefix}-dropdown`;
6129 }
6130 function PrimaryActionGridCell({
6131 idPrefix,
6132 primaryAction,
6133 item
6134 }) {
6135 const registry = (0, import_data3.useRegistry)();
6136 const [isModalOpen, setIsModalOpen] = (0, import_element34.useState)(false);
6137 const compositeItemId = generatePrimaryActionCompositeId(
6138 idPrefix,
6139 primaryAction.id
6140 );
6141 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
6142 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6143 import_components12.Composite.Item,
6144 {
6145 id: compositeItemId,
6146 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6147 import_components12.Button,
6148 {
6149 disabled: !!primaryAction.disabled,
6150 accessibleWhenDisabled: true,
6151 text: label,
6152 size: "small",
6153 onClick: () => setIsModalOpen(true)
6154 }
6155 ),
6156 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6157 ActionModal,
6158 {
6159 action: primaryAction,
6160 items: [item],
6161 closeModal: () => setIsModalOpen(false)
6162 }
6163 )
6164 }
6165 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6166 import_components12.Composite.Item,
6167 {
6168 id: compositeItemId,
6169 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6170 import_components12.Button,
6171 {
6172 disabled: !!primaryAction.disabled,
6173 accessibleWhenDisabled: true,
6174 size: "small",
6175 onClick: () => {
6176 primaryAction.callback([item], { registry });
6177 },
6178 children: label
6179 }
6180 )
6181 }
6182 ) }, primaryAction.id);
6183 }
6184 function ListItem({
6185 view,
6186 actions: actions2,
6187 idPrefix,
6188 isSelected: isSelected2,
6189 item,
6190 titleField,
6191 mediaField,
6192 descriptionField,
6193 onSelect,
6194 otherFields,
6195 onDropdownTriggerKeyDown,
6196 posinset
6197 }) {
6198 const {
6199 showTitle = true,
6200 showMedia = true,
6201 showDescription = true,
6202 infiniteScrollEnabled
6203 } = view;
6204 const itemRef = (0, import_element34.useRef)(null);
6205 const labelId = `${idPrefix}-label`;
6206 const descriptionId = `${idPrefix}-description`;
6207 const registry = (0, import_data3.useRegistry)();
6208 const [isHovered, setIsHovered] = (0, import_element34.useState)(false);
6209 const [activeModalAction, setActiveModalAction] = (0, import_element34.useState)(
6210 null
6211 );
6212 const handleHover = ({ type }) => {
6213 const isHover = type === "mouseenter";
6214 setIsHovered(isHover);
6215 };
6216 const { paginationInfo } = (0, import_element34.useContext)(dataviews_context_default);
6217 (0, import_element34.useEffect)(() => {
6218 if (isSelected2) {
6219 itemRef.current?.scrollIntoView({
6220 behavior: "auto",
6221 block: "nearest",
6222 inline: "nearest"
6223 });
6224 }
6225 }, [isSelected2]);
6226 const { primaryAction, eligibleActions } = (0, import_element34.useMemo)(() => {
6227 const _eligibleActions = actions2.filter(
6228 (action) => !action.isEligible || action.isEligible(item)
6229 );
6230 const _primaryActions = _eligibleActions.filter(
6231 (action) => action.isPrimary
6232 );
6233 return {
6234 primaryAction: _primaryActions[0],
6235 eligibleActions: _eligibleActions
6236 };
6237 }, [actions2, item]);
6238 const hasOnlyOnePrimaryAction = primaryAction && actions2.length === 1;
6239 const renderedMediaField = showMedia && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-list__media-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6240 mediaField.render,
6241 {
6242 item,
6243 field: mediaField,
6244 config: { sizes: "52px" }
6245 }
6246 ) }) : null;
6247 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(titleField.render, { item, field: titleField }) : null;
6248 const renderDescription = showDescription && descriptionField?.render;
6249 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
6250 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6251 Stack,
6252 {
6253 direction: "row",
6254 gap: "md",
6255 className: "dataviews-view-list__item-actions",
6256 children: [
6257 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6258 PrimaryActionGridCell,
6259 {
6260 idPrefix,
6261 primaryAction,
6262 item
6263 }
6264 ),
6265 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { role: "gridcell", children: [
6266 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Menu3, { placement: "bottom-end", children: [
6267 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6268 Menu3.TriggerButton,
6269 {
6270 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6271 import_components12.Composite.Item,
6272 {
6273 id: generateDropdownTriggerCompositeId(
6274 idPrefix
6275 ),
6276 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6277 import_components12.Button,
6278 {
6279 size: "small",
6280 icon: more_vertical_default,
6281 label: (0, import_i18n14.__)("Actions"),
6282 accessibleWhenDisabled: true,
6283 disabled: !actions2.length,
6284 onKeyDown: onDropdownTriggerKeyDown
6285 }
6286 )
6287 }
6288 )
6289 }
6290 ),
6291 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6292 ActionsMenuGroup,
6293 {
6294 actions: eligibleActions,
6295 item,
6296 registry,
6297 setActiveModalAction
6298 }
6299 ) })
6300 ] }),
6301 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6302 ActionModal,
6303 {
6304 action: activeModalAction,
6305 items: [item],
6306 closeModal: () => setActiveModalAction(null)
6307 }
6308 )
6309 ] })
6310 ]
6311 }
6312 );
6313 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6314 import_components12.Composite.Row,
6315 {
6316 ref: itemRef,
6317 render: (
6318 /* aria-posinset breaks Composite.Row if passed to it directly. */
6319 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6320 "div",
6321 {
6322 "aria-posinset": posinset,
6323 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
6324 }
6325 )
6326 ),
6327 role: infiniteScrollEnabled ? "article" : "row",
6328 className: clsx_default({
6329 "is-selected": isSelected2,
6330 "is-hovered": isHovered
6331 }),
6332 onMouseEnter: handleHover,
6333 onMouseLeave: handleHover,
6334 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6335 Stack,
6336 {
6337 direction: "row",
6338 className: "dataviews-view-list__item-wrapper",
6339 children: [
6340 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6341 import_components12.Composite.Item,
6342 {
6343 id: generateItemWrapperCompositeId(idPrefix),
6344 "aria-pressed": isSelected2,
6345 "aria-labelledby": labelId,
6346 "aria-describedby": descriptionId,
6347 className: "dataviews-view-list__item",
6348 onClick: () => onSelect(item)
6349 }
6350 ) }),
6351 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6352 Stack,
6353 {
6354 direction: "row",
6355 gap: "md",
6356 justify: "start",
6357 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
6358 style: { flex: 1, minWidth: 0 },
6359 children: [
6360 renderedMediaField,
6361 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6362 Stack,
6363 {
6364 direction: "column",
6365 gap: "xs",
6366 className: "dataviews-view-list__field-wrapper",
6367 children: [
6368 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { direction: "row", align: "center", children: [
6369 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6370 "div",
6371 {
6372 className: "dataviews-title-field dataviews-view-list__title-field",
6373 id: labelId,
6374 children: renderedTitleField
6375 }
6376 ),
6377 usedActions
6378 ] }),
6379 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6380 descriptionField.render,
6381 {
6382 item,
6383 field: descriptionField
6384 }
6385 ) }),
6386 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6387 "div",
6388 {
6389 className: "dataviews-view-list__fields",
6390 id: descriptionId,
6391 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6392 "div",
6393 {
6394 className: "dataviews-view-list__field",
6395 children: [
6396 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6397 VisuallyHidden,
6398 {
6399 className: "dataviews-view-list__field-label",
6400 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", {}),
6401 children: field.label
6402 }
6403 ),
6404 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6405 field.render,
6406 {
6407 item,
6408 field
6409 }
6410 ) })
6411 ]
6412 },
6413 field.id
6414 ))
6415 }
6416 )
6417 ]
6418 }
6419 )
6420 ]
6421 }
6422 )
6423 ]
6424 }
6425 )
6426 }
6427 );
6428 }
6429 function isDefined2(item) {
6430 return !!item;
6431 }
6432 function ViewList(props) {
6433 const {
6434 actions: actions2,
6435 data,
6436 fields: fields2,
6437 getItemId,
6438 isLoading,
6439 onChangeSelection,
6440 selection,
6441 view,
6442 className,
6443 empty
6444 } = props;
6445 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
6446 const isDelayedLoading = useDelayedLoading(!!isLoading);
6447 const selectedItem = data?.findLast(
6448 (item) => selection.includes(getItemId(item))
6449 );
6450 const titleField = fields2.find((field) => field.id === view.titleField);
6451 const mediaField = fields2.find((field) => field.id === view.mediaField);
6452 const descriptionField = fields2.find(
6453 (field) => field.id === view.descriptionField
6454 );
6455 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2);
6456 const onSelect = (item) => onChangeSelection([getItemId(item)]);
6457 const generateCompositeItemIdPrefix = (0, import_element34.useCallback)(
6458 (item) => `${baseId}-${getItemId(item)}`,
6459 [baseId, getItemId]
6460 );
6461 const isActiveCompositeItem = (0, import_element34.useCallback)(
6462 (item, idToCheck) => {
6463 return idToCheck.startsWith(
6464 generateCompositeItemIdPrefix(item)
6465 );
6466 },
6467 [generateCompositeItemIdPrefix]
6468 );
6469 const [activeCompositeId, setActiveCompositeId] = (0, import_element34.useState)(void 0);
6470 const compositeRef = (0, import_element34.useRef)(null);
6471 (0, import_element34.useEffect)(() => {
6472 if (selectedItem) {
6473 setActiveCompositeId(
6474 generateItemWrapperCompositeId(
6475 generateCompositeItemIdPrefix(selectedItem)
6476 )
6477 );
6478 }
6479 }, [selectedItem, generateCompositeItemIdPrefix]);
6480 const activeItemIndex = data.findIndex(
6481 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
6482 );
6483 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
6484 const isActiveIdInList = activeItemIndex !== -1;
6485 const selectCompositeItem = (0, import_element34.useCallback)(
6486 (targetIndex, generateCompositeId) => {
6487 const clampedIndex = Math.min(
6488 data.length - 1,
6489 Math.max(0, targetIndex)
6490 );
6491 if (!data[clampedIndex]) {
6492 return;
6493 }
6494 const itemIdPrefix = generateCompositeItemIdPrefix(
6495 data[clampedIndex]
6496 );
6497 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
6498 setActiveCompositeId(targetCompositeItemId);
6499 if (compositeRef.current?.contains(
6500 compositeRef.current.ownerDocument.activeElement
6501 )) {
6502 document.getElementById(targetCompositeItemId)?.focus();
6503 }
6504 },
6505 [data, generateCompositeItemIdPrefix]
6506 );
6507 (0, import_element34.useEffect)(() => {
6508 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
6509 if (!isActiveIdInList && wasActiveIdInList) {
6510 selectCompositeItem(
6511 previousActiveItemIndex,
6512 generateItemWrapperCompositeId
6513 );
6514 }
6515 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
6516 const onDropdownTriggerKeyDown = (0, import_element34.useCallback)(
6517 (event) => {
6518 if (event.key === "ArrowDown") {
6519 event.preventDefault();
6520 selectCompositeItem(
6521 activeItemIndex + 1,
6522 generateDropdownTriggerCompositeId
6523 );
6524 }
6525 if (event.key === "ArrowUp") {
6526 event.preventDefault();
6527 selectCompositeItem(
6528 activeItemIndex - 1,
6529 generateDropdownTriggerCompositeId
6530 );
6531 }
6532 },
6533 [selectCompositeItem, activeItemIndex]
6534 );
6535 const hasData = !!data?.length;
6536 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
6537 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
6538 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6539 if (!hasData) {
6540 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6541 "div",
6542 {
6543 className: clsx_default("dataviews-no-results", {
6544 "is-refreshing": isDelayedLoading
6545 }),
6546 children: empty
6547 }
6548 );
6549 }
6550 if (hasData && groupField && dataByGroup) {
6551 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6552 import_components12.Composite,
6553 {
6554 ref: compositeRef,
6555 id: `${baseId}`,
6556 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
6557 className: "dataviews-view-list__group",
6558 role: "grid",
6559 activeId: activeCompositeId,
6560 setActiveId: setActiveCompositeId,
6561 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6562 Stack,
6563 {
6564 direction: "column",
6565 gap: "lg",
6566 className: clsx_default("dataviews-view-list", className),
6567 children: Array.from(dataByGroup.entries()).map(
6568 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6569 Stack,
6570 {
6571 direction: "column",
6572 gap: "sm",
6573 children: [
6574 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n14.sprintf)(
6575 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6576 (0, import_i18n14.__)("%1$s: %2$s"),
6577 groupField.label,
6578 groupName
6579 ) }),
6580 groupItems.map((item) => {
6581 const id = generateCompositeItemIdPrefix(item);
6582 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6583 ListItem,
6584 {
6585 view,
6586 idPrefix: id,
6587 actions: actions2,
6588 item,
6589 isSelected: item === selectedItem,
6590 onSelect,
6591 mediaField,
6592 titleField,
6593 descriptionField,
6594 otherFields,
6595 onDropdownTriggerKeyDown
6596 },
6597 id
6598 );
6599 })
6600 ]
6601 },
6602 groupName
6603 )
6604 )
6605 }
6606 )
6607 }
6608 );
6609 }
6610 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
6611 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6612 import_components12.Composite,
6613 {
6614 ref: compositeRef,
6615 id: baseId,
6616 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
6617 className: clsx_default("dataviews-view-list", className, {
6618 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
6619 view.layout.density
6620 ),
6621 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6622 }),
6623 role: view.infiniteScrollEnabled ? "feed" : "grid",
6624 activeId: activeCompositeId,
6625 setActiveId: setActiveCompositeId,
6626 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
6627 children: data.map((item, index) => {
6628 const id = generateCompositeItemIdPrefix(item);
6629 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6630 ListItem,
6631 {
6632 view,
6633 idPrefix: id,
6634 actions: actions2,
6635 item,
6636 isSelected: item === selectedItem,
6637 onSelect,
6638 mediaField,
6639 titleField,
6640 descriptionField,
6641 otherFields,
6642 onDropdownTriggerKeyDown,
6643 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
6644 },
6645 id
6646 );
6647 })
6648 }
6649 ),
6650 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components12.Spinner, {}) })
6651 ] });
6652 }
6653
6654 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
6655 var import_components13 = __toESM(require_components(), 1);
6656
6657 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
6658 var import_i18n15 = __toESM(require_i18n(), 1);
6659 var import_element35 = __toESM(require_element(), 1);
6660 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
6661 function ActivityGroup({
6662 groupName,
6663 groupData,
6664 groupField,
6665 showLabel = true,
6666 children
6667 }) {
6668 const groupHeader = showLabel ? (0, import_element35.createInterpolateElement)(
6669 // translators: %s: The label of the field e.g. "Status".
6670 (0, import_i18n15.sprintf)((0, import_i18n15.__)("%s: <groupName />"), groupField.label).trim(),
6671 {
6672 groupName: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6673 groupField.render,
6674 {
6675 item: groupData[0],
6676 field: groupField
6677 }
6678 )
6679 }
6680 ) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(groupField.render, { item: groupData[0], field: groupField });
6681 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
6682 Stack,
6683 {
6684 direction: "column",
6685 className: "dataviews-view-activity__group",
6686 children: [
6687 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
6688 children
6689 ]
6690 },
6691 groupName
6692 );
6693 }
6694
6695 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
6696 var import_element36 = __toESM(require_element(), 1);
6697 var import_data4 = __toESM(require_data(), 1);
6698 var import_compose5 = __toESM(require_compose(), 1);
6699 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
6700 function ActivityItem(props) {
6701 const {
6702 view,
6703 actions: actions2,
6704 item,
6705 titleField,
6706 mediaField,
6707 descriptionField,
6708 otherFields,
6709 posinset,
6710 onClickItem,
6711 renderItemLink,
6712 isItemClickable
6713 } = props;
6714 const {
6715 showTitle = true,
6716 showMedia = true,
6717 showDescription = true,
6718 infiniteScrollEnabled
6719 } = view;
6720 const itemRef = (0, import_element36.useRef)(null);
6721 const registry = (0, import_data4.useRegistry)();
6722 const { paginationInfo } = (0, import_element36.useContext)(dataviews_context_default);
6723 const { primaryActions, eligibleActions } = (0, import_element36.useMemo)(() => {
6724 const _eligibleActions = actions2.filter(
6725 (action) => !action.isEligible || action.isEligible(item)
6726 );
6727 const _primaryActions = _eligibleActions.filter(
6728 (action) => action.isPrimary
6729 );
6730 return {
6731 primaryActions: _primaryActions,
6732 eligibleActions: _eligibleActions
6733 };
6734 }, [actions2, item]);
6735 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
6736 const density = view.layout?.density ?? "balanced";
6737 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6738 mediaField.render,
6739 {
6740 item,
6741 field: mediaField,
6742 config: {
6743 sizes: density === "comfortable" ? "32px" : "24px"
6744 }
6745 }
6746 ) : null;
6747 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6748 "span",
6749 {
6750 className: "dataviews-view-activity__item-bullet",
6751 "aria-hidden": "true"
6752 }
6753 ) });
6754 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
6755 const verticalGap = (0, import_element36.useMemo)(() => {
6756 switch (density) {
6757 case "comfortable":
6758 return "md";
6759 default:
6760 return "sm";
6761 }
6762 }, [density]);
6763 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6764 "div",
6765 {
6766 ref: itemRef,
6767 role: infiniteScrollEnabled ? "article" : void 0,
6768 "aria-posinset": posinset,
6769 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
6770 className: clsx_default(
6771 "dataviews-view-activity__item",
6772 density === "compact" && "is-compact",
6773 density === "balanced" && "is-balanced",
6774 density === "comfortable" && "is-comfortable"
6775 ),
6776 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
6777 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6778 Stack,
6779 {
6780 direction: "column",
6781 gap: "xs",
6782 align: "center",
6783 className: "dataviews-view-activity__item-type",
6784 children: renderedMediaField
6785 }
6786 ),
6787 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
6788 Stack,
6789 {
6790 direction: "column",
6791 gap: verticalGap,
6792 align: "flex-start",
6793 className: "dataviews-view-activity__item-content",
6794 children: [
6795 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6796 ItemClickWrapper,
6797 {
6798 item,
6799 isItemClickable,
6800 onClickItem,
6801 renderItemLink,
6802 className: "dataviews-view-activity__item-title",
6803 children: renderedTitleField
6804 }
6805 ),
6806 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6807 descriptionField.render,
6808 {
6809 item,
6810 field: descriptionField
6811 }
6812 ) }),
6813 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
6814 "div",
6815 {
6816 className: "dataviews-view-activity__item-field",
6817 children: [
6818 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6819 VisuallyHidden,
6820 {
6821 className: "dataviews-view-activity__item-field-label",
6822 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", {}),
6823 children: field.label
6824 }
6825 ),
6826 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6827 field.render,
6828 {
6829 item,
6830 field
6831 }
6832 ) })
6833 ]
6834 },
6835 field.id
6836 )) }),
6837 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6838 PrimaryActions,
6839 {
6840 item,
6841 actions: primaryActions,
6842 registry,
6843 buttonVariant: "secondary"
6844 }
6845 )
6846 ]
6847 }
6848 ),
6849 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
6850 // there if there are any actions at all.
6851 isMobileViewport && // At the same time, only show the menu if there are actions to show.
6852 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
6853 ItemActions,
6854 {
6855 item,
6856 actions: eligibleActions,
6857 isCompact: true
6858 }
6859 ) })
6860 ] })
6861 }
6862 );
6863 }
6864 var activity_item_default = ActivityItem;
6865
6866 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
6867 var import_react9 = __toESM(require_react(), 1);
6868 function isDefined3(item) {
6869 return !!item;
6870 }
6871 function ActivityItems(props) {
6872 const { data, fields: fields2, getItemId, view } = props;
6873 const titleField = fields2.find((field) => field.id === view.titleField);
6874 const mediaField = fields2.find((field) => field.id === view.mediaField);
6875 const descriptionField = fields2.find(
6876 (field) => field.id === view.descriptionField
6877 );
6878 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3);
6879 return data.map((item, index) => {
6880 return /* @__PURE__ */ (0, import_react9.createElement)(
6881 activity_item_default,
6882 {
6883 ...props,
6884 key: getItemId(item),
6885 item,
6886 mediaField,
6887 titleField,
6888 descriptionField,
6889 otherFields,
6890 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
6891 }
6892 );
6893 });
6894 }
6895
6896 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
6897 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
6898 function ViewActivity(props) {
6899 const { empty, data, fields: fields2, isLoading, view, className } = props;
6900 const isDelayedLoading = useDelayedLoading(!!isLoading);
6901 const hasData = !!data?.length;
6902 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
6903 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
6904 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6905 if (!hasData) {
6906 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6907 "div",
6908 {
6909 className: clsx_default("dataviews-no-results", {
6910 "is-refreshing": isDelayedLoading
6911 }),
6912 children: empty
6913 }
6914 );
6915 }
6916 const isInert = !isInfiniteScroll && !!isLoading;
6917 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
6918 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6919 });
6920 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
6921 if (hasData && groupField && dataByGroup) {
6922 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6923 Stack,
6924 {
6925 direction: "column",
6926 gap: "sm",
6927 className: wrapperClassName,
6928 inert: isInert ? "true" : void 0,
6929 children: groupedEntries.map(
6930 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6931 ActivityGroup,
6932 {
6933 groupName,
6934 groupData,
6935 groupField,
6936 showLabel: view.groupBy?.showLabel !== false,
6937 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6938 ActivityItems,
6939 {
6940 ...props,
6941 data: groupData
6942 }
6943 )
6944 },
6945 groupName
6946 )
6947 )
6948 }
6949 );
6950 }
6951 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
6952 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
6953 "div",
6954 {
6955 className: wrapperClassName,
6956 role: view.infiniteScrollEnabled ? "feed" : void 0,
6957 inert: isInert ? "true" : void 0,
6958 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ActivityItems, { ...props })
6959 }
6960 ),
6961 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components13.Spinner, {}) })
6962 ] });
6963 }
6964
6965 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
6966 var import_components16 = __toESM(require_components(), 1);
6967 var import_i18n18 = __toESM(require_i18n(), 1);
6968 var import_compose6 = __toESM(require_compose(), 1);
6969 var import_element39 = __toESM(require_element(), 1);
6970
6971 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
6972 var import_components15 = __toESM(require_components(), 1);
6973 var import_data5 = __toESM(require_data(), 1);
6974 var import_element38 = __toESM(require_element(), 1);
6975 var import_i18n17 = __toESM(require_i18n(), 1);
6976
6977 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
6978 var import_components14 = __toESM(require_components(), 1);
6979 var import_element37 = __toESM(require_element(), 1);
6980 var import_i18n16 = __toESM(require_i18n(), 1);
6981 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
6982 function DataViewsPagination() {
6983 const {
6984 view,
6985 onChangeView,
6986 paginationInfo: { totalItems = 0, totalPages }
6987 } = (0, import_element37.useContext)(dataviews_context_default);
6988 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
6989 return null;
6990 }
6991 const currentPage = view.page ?? 1;
6992 const pageSelectOptions = Array.from(Array(totalPages)).map(
6993 (_, i2) => {
6994 const page = i2 + 1;
6995 return {
6996 value: page.toString(),
6997 label: page.toString(),
6998 "aria-label": currentPage === page ? (0, import_i18n16.sprintf)(
6999 // translators: 1: current page number. 2: total number of pages.
7000 (0, import_i18n16.__)("Page %1$d of %2$d"),
7001 currentPage,
7002 totalPages
7003 ) : page.toString()
7004 };
7005 }
7006 );
7007 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
7008 Stack,
7009 {
7010 direction: "row",
7011 className: "dataviews-pagination",
7012 justify: "end",
7013 align: "center",
7014 gap: "xl",
7015 children: [
7016 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7017 Stack,
7018 {
7019 direction: "row",
7020 justify: "flex-start",
7021 align: "center",
7022 gap: "xs",
7023 className: "dataviews-pagination__page-select",
7024 children: (0, import_element37.createInterpolateElement)(
7025 (0, import_i18n16.sprintf)(
7026 // translators: 1: Current page number, 2: Total number of pages.
7027 (0, import_i18n16._x)(
7028 "<div>Page</div>%1$s<div>of %2$d</div>",
7029 "paging"
7030 ),
7031 "<CurrentPage />",
7032 totalPages
7033 ),
7034 {
7035 div: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { "aria-hidden": true }),
7036 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
7037 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7038 import_components14.SelectControl,
7039 {
7040 "aria-label": (0, import_i18n16.__)("Current page"),
7041 value: currentPage.toString(),
7042 options: pageSelectOptions,
7043 onChange: (newValue) => {
7044 onChangeView({
7045 ...view,
7046 page: +newValue
7047 });
7048 },
7049 size: "small",
7050 variant: "minimal"
7051 }
7052 )
7053 }
7054 )
7055 }
7056 ),
7057 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
7058 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7059 import_components14.Button,
7060 {
7061 onClick: () => onChangeView({
7062 ...view,
7063 page: currentPage - 1
7064 }),
7065 disabled: currentPage === 1,
7066 accessibleWhenDisabled: true,
7067 label: (0, import_i18n16.__)("Previous page"),
7068 icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
7069 showTooltip: true,
7070 size: "compact",
7071 tooltipPosition: "top"
7072 }
7073 ),
7074 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7075 import_components14.Button,
7076 {
7077 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
7078 disabled: currentPage >= totalPages,
7079 accessibleWhenDisabled: true,
7080 label: (0, import_i18n16.__)("Next page"),
7081 icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
7082 showTooltip: true,
7083 size: "compact",
7084 tooltipPosition: "top"
7085 }
7086 )
7087 ] })
7088 ]
7089 }
7090 );
7091 }
7092 var dataviews_pagination_default = (0, import_element37.memo)(DataViewsPagination);
7093
7094 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
7095 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
7096 function useIsMultiselectPicker(actions2) {
7097 return (0, import_element38.useMemo)(() => {
7098 return actions2?.every((action) => action.supportsBulk);
7099 }, [actions2]);
7100 }
7101
7102 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
7103 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
7104 var { Badge: WCBadge2 } = unlock(import_components16.privateApis);
7105 function GridItem3({
7106 view,
7107 multiselect,
7108 selection,
7109 onChangeSelection,
7110 getItemId,
7111 item,
7112 mediaField,
7113 titleField,
7114 descriptionField,
7115 regularFields,
7116 badgeFields,
7117 config,
7118 posinset,
7119 setsize
7120 }) {
7121 const { showTitle = true, showMedia = true, showDescription = true } = view;
7122 const id = getItemId(item);
7123 const elementRef = (0, import_element39.useRef)(null);
7124 const isSelected2 = selection.includes(id);
7125 useIntersectionObserver(elementRef, posinset);
7126 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7127 mediaField.render,
7128 {
7129 item,
7130 field: mediaField,
7131 config
7132 }
7133 ) : null;
7134 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
7135 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7136 import_components16.Composite.Item,
7137 {
7138 ref: elementRef,
7139 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n18.__)("(no title)") : void 0,
7140 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Stack, { direction: "column", children, ...props }),
7141 role: "option",
7142 "aria-posinset": posinset,
7143 "aria-setsize": setsize,
7144 className: clsx_default("dataviews-view-picker-grid__card", {
7145 "is-selected": isSelected2
7146 }),
7147 "aria-selected": isSelected2,
7148 onClick: () => {
7149 if (isSelected2) {
7150 onChangeSelection(
7151 selection.filter((itemId) => id !== itemId)
7152 );
7153 } else {
7154 const newSelection = multiselect ? [...selection, id] : [id];
7155 onChangeSelection(newSelection);
7156 }
7157 },
7158 children: [
7159 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
7160 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7161 DataViewsSelectionCheckbox,
7162 {
7163 item,
7164 selection,
7165 onChangeSelection,
7166 getItemId,
7167 titleField,
7168 disabled: false,
7169 "aria-hidden": true,
7170 tabIndex: -1
7171 }
7172 ),
7173 showTitle && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7174 Stack,
7175 {
7176 direction: "row",
7177 justify: "space-between",
7178 className: "dataviews-view-picker-grid__title-actions",
7179 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
7180 }
7181 ),
7182 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "column", gap: "xs", children: [
7183 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7184 descriptionField.render,
7185 {
7186 item,
7187 field: descriptionField
7188 }
7189 ),
7190 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7191 Stack,
7192 {
7193 direction: "row",
7194 className: "dataviews-view-picker-grid__badge-fields",
7195 gap: "sm",
7196 wrap: "wrap",
7197 align: "top",
7198 justify: "flex-start",
7199 children: badgeFields.map((field) => {
7200 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7201 WCBadge2,
7202 {
7203 className: "dataviews-view-picker-grid__field-value",
7204 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7205 field.render,
7206 {
7207 item,
7208 field
7209 }
7210 )
7211 },
7212 field.id
7213 );
7214 })
7215 }
7216 ),
7217 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7218 Stack,
7219 {
7220 direction: "column",
7221 className: "dataviews-view-picker-grid__fields",
7222 gap: "xs",
7223 children: regularFields.map((field) => {
7224 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7225 import_components16.Flex,
7226 {
7227 className: "dataviews-view-picker-grid__field",
7228 gap: 1,
7229 justify: "flex-start",
7230 expanded: true,
7231 style: { height: "auto" },
7232 direction: "row",
7233 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
7234 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
7235 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7236 import_components16.FlexItem,
7237 {
7238 className: "dataviews-view-picker-grid__field-value",
7239 style: { maxHeight: "none" },
7240 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7241 field.render,
7242 {
7243 item,
7244 field
7245 }
7246 )
7247 }
7248 )
7249 ] })
7250 },
7251 field.id
7252 );
7253 })
7254 }
7255 )
7256 ] })
7257 ]
7258 },
7259 id
7260 );
7261 }
7262 function GridGroup({
7263 groupName,
7264 groupField,
7265 showLabel = true,
7266 children
7267 }) {
7268 const headerId = (0, import_compose6.useInstanceId)(
7269 GridGroup,
7270 "dataviews-view-picker-grid-group__header"
7271 );
7272 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7273 Stack,
7274 {
7275 direction: "column",
7276 gap: "sm",
7277 role: "group",
7278 "aria-labelledby": headerId,
7279 children: [
7280 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7281 "h3",
7282 {
7283 className: "dataviews-view-picker-grid-group__header",
7284 id: headerId,
7285 children: showLabel ? (0, import_i18n18.sprintf)(
7286 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
7287 (0, import_i18n18.__)("%1$s: %2$s"),
7288 groupField.label,
7289 groupName
7290 ) : groupName
7291 }
7292 ),
7293 children
7294 ]
7295 },
7296 groupName
7297 );
7298 }
7299 function ViewPickerGrid({
7300 actions: actions2,
7301 data,
7302 fields: fields2,
7303 getItemId,
7304 isLoading,
7305 onChangeSelection,
7306 selection,
7307 view,
7308 className,
7309 empty
7310 }) {
7311 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element39.useContext)(dataviews_context_default);
7312 const titleField = fields2.find(
7313 (field) => field.id === view?.titleField
7314 );
7315 const mediaField = fields2.find(
7316 (field) => field.id === view?.mediaField
7317 );
7318 const descriptionField = fields2.find(
7319 (field) => field.id === view?.descriptionField
7320 );
7321 const otherFields = view.fields ?? [];
7322 const { regularFields, badgeFields } = otherFields.reduce(
7323 (accumulator, fieldId) => {
7324 const field = fields2.find((f2) => f2.id === fieldId);
7325 if (!field) {
7326 return accumulator;
7327 }
7328 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
7329 accumulator[key].push(field);
7330 return accumulator;
7331 },
7332 { regularFields: [], badgeFields: [] }
7333 );
7334 const hasData = !!data?.length;
7335 const usedPreviewSize = view.layout?.previewSize;
7336 const isMultiselect = useIsMultiselectPicker(actions2);
7337 const size = "900px";
7338 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
7339 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
7340 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
7341 const currentPage = view?.page ?? 1;
7342 const perPage = view?.perPage ?? 0;
7343 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
7344 const gridColumns = useGridColumns();
7345 const placeholdersNeeded = usePlaceholdersNeeded(
7346 data,
7347 isInfiniteScroll,
7348 gridColumns
7349 );
7350 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, {
7351 // Render multiple groups.
7352 children: [
7353 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7354 import_components16.Composite,
7355 {
7356 virtualFocus: true,
7357 orientation: "horizontal",
7358 role: "listbox",
7359 "aria-multiselectable": isMultiselect,
7360 className: clsx_default(
7361 "dataviews-view-picker-grid",
7362 className,
7363 {
7364 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
7365 view.layout.density
7366 )
7367 }
7368 ),
7369 "aria-label": itemListLabel,
7370 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7371 Stack,
7372 {
7373 direction: "column",
7374 gap: "lg",
7375 children,
7376 ...props
7377 }
7378 ),
7379 children: Array.from(dataByGroup.entries()).map(
7380 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7381 GridGroup,
7382 {
7383 groupName,
7384 groupField,
7385 showLabel: view.groupBy?.showLabel !== false,
7386 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7387 GridItems,
7388 {
7389 previewSize: usedPreviewSize,
7390 style: {
7391 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
7392 },
7393 "aria-busy": isLoading,
7394 ref: resizeObserverRef,
7395 children: groupItems.map((item) => {
7396 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
7397 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7398 GridItem3,
7399 {
7400 view,
7401 multiselect: isMultiselect,
7402 selection,
7403 onChangeSelection,
7404 getItemId,
7405 item,
7406 mediaField,
7407 titleField,
7408 descriptionField,
7409 regularFields,
7410 badgeFields,
7411 config: {
7412 sizes: size
7413 },
7414 posinset: posInSet,
7415 setsize: setSize
7416 },
7417 getItemId(item)
7418 );
7419 })
7420 }
7421 )
7422 },
7423 groupName
7424 )
7425 )
7426 }
7427 ),
7428 // Render a single grid with all data.
7429 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7430 import_components16.Composite,
7431 {
7432 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7433 GridItems,
7434 {
7435 className: clsx_default(
7436 "dataviews-view-picker-grid",
7437 className,
7438 {
7439 [`has-${view.layout?.density}-density`]: view.layout?.density && [
7440 "compact",
7441 "comfortable"
7442 ].includes(view.layout.density)
7443 }
7444 ),
7445 previewSize: usedPreviewSize,
7446 "aria-busy": isLoading,
7447 ref: resizeObserverRef
7448 }
7449 ),
7450 virtualFocus: true,
7451 orientation: "horizontal",
7452 role: "listbox",
7453 "aria-multiselectable": isMultiselect,
7454 "aria-label": itemListLabel,
7455 children: [
7456 Array.from({ length: placeholdersNeeded }).map(
7457 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7458 import_components16.Composite.Item,
7459 {
7460 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7461 Stack,
7462 {
7463 direction: "column",
7464 children,
7465 ...props
7466 }
7467 ),
7468 role: "option",
7469 "aria-hidden": true,
7470 tabIndex: -1,
7471 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
7472 },
7473 `placeholder-${index}`
7474 )
7475 ),
7476 data.map((item) => {
7477 const posinset = item.position;
7478 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7479 GridItem3,
7480 {
7481 view,
7482 multiselect: isMultiselect,
7483 selection,
7484 onChangeSelection,
7485 getItemId,
7486 item,
7487 mediaField,
7488 titleField,
7489 descriptionField,
7490 regularFields,
7491 badgeFields,
7492 config: {
7493 sizes: size
7494 },
7495 posinset,
7496 setsize: setSize
7497 },
7498 getItemId(item)
7499 );
7500 })
7501 ]
7502 }
7503 ),
7504 // Render empty state.
7505 !hasData && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7506 "div",
7507 {
7508 className: clsx_default({
7509 "dataviews-loading": isLoading,
7510 "dataviews-no-results": !isLoading
7511 }),
7512 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.Spinner, {}) }) : empty
7513 }
7514 ),
7515 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.Spinner, {}) })
7516 ]
7517 });
7518 }
7519 var picker_grid_default = ViewPickerGrid;
7520
7521 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
7522 var import_i18n19 = __toESM(require_i18n(), 1);
7523 var import_components17 = __toESM(require_components(), 1);
7524 var import_element40 = __toESM(require_element(), 1);
7525 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
7526 function TableColumnField2({
7527 item,
7528 fields: fields2,
7529 column,
7530 align
7531 }) {
7532 const field = fields2.find((f2) => f2.id === column);
7533 if (!field) {
7534 return null;
7535 }
7536 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
7537 "dataviews-view-table__cell-align-end": align === "end",
7538 "dataviews-view-table__cell-align-center": align === "center"
7539 });
7540 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(field.render, { item, field }) });
7541 }
7542 function TableRow2({
7543 item,
7544 fields: fields2,
7545 id,
7546 view,
7547 titleField,
7548 mediaField,
7549 descriptionField,
7550 selection,
7551 getItemId,
7552 onChangeSelection,
7553 multiselect,
7554 posinset
7555 }) {
7556 const { paginationInfo } = (0, import_element40.useContext)(dataviews_context_default);
7557 const isSelected2 = selection.includes(id);
7558 const [isHovered, setIsHovered] = (0, import_element40.useState)(false);
7559 const elementRef = (0, import_element40.useRef)(null);
7560 useIntersectionObserver(elementRef, posinset);
7561 const {
7562 showTitle = true,
7563 showMedia = true,
7564 showDescription = true,
7565 infiniteScrollEnabled
7566 } = view;
7567 const handleMouseEnter = () => {
7568 setIsHovered(true);
7569 };
7570 const handleMouseLeave = () => {
7571 setIsHovered(false);
7572 };
7573 const columns = view.fields ?? [];
7574 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
7575 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7576 import_components17.Composite.Item,
7577 {
7578 ref: elementRef,
7579 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7580 "tr",
7581 {
7582 className: clsx_default("dataviews-view-table__row", {
7583 "is-selected": isSelected2,
7584 "is-hovered": isHovered
7585 }),
7586 onMouseEnter: handleMouseEnter,
7587 onMouseLeave: handleMouseLeave,
7588 children,
7589 ...props
7590 }
7591 ),
7592 "aria-selected": isSelected2,
7593 "aria-setsize": paginationInfo.totalItems || void 0,
7594 "aria-posinset": posinset,
7595 role: infiniteScrollEnabled ? "article" : "option",
7596 onClick: () => {
7597 if (isSelected2) {
7598 onChangeSelection(
7599 selection.filter((itemId) => id !== itemId)
7600 );
7601 } else {
7602 const newSelection = multiselect ? [...selection, id] : [id];
7603 onChangeSelection(newSelection);
7604 }
7605 },
7606 children: [
7607 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7608 "td",
7609 {
7610 className: "dataviews-view-table__checkbox-column",
7611 role: "presentation",
7612 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7613 DataViewsSelectionCheckbox,
7614 {
7615 item,
7616 selection,
7617 onChangeSelection,
7618 getItemId,
7619 titleField,
7620 disabled: false,
7621 "aria-hidden": true,
7622 tabIndex: -1
7623 }
7624 ) })
7625 }
7626 ),
7627 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7628 "td",
7629 {
7630 role: "presentation",
7631 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7632 column_primary_default,
7633 {
7634 item,
7635 titleField: showTitle ? titleField : void 0,
7636 mediaField: showMedia ? mediaField : void 0,
7637 descriptionField: showDescription ? descriptionField : void 0,
7638 isItemClickable: () => false
7639 }
7640 )
7641 }
7642 ),
7643 columns.map((column) => {
7644 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
7645 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7646 "td",
7647 {
7648 style: {
7649 width,
7650 maxWidth,
7651 minWidth
7652 },
7653 role: "presentation",
7654 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7655 TableColumnField2,
7656 {
7657 fields: fields2,
7658 item,
7659 column,
7660 align
7661 }
7662 )
7663 },
7664 column
7665 );
7666 })
7667 ]
7668 },
7669 id
7670 );
7671 }
7672 function ViewPickerTable({
7673 actions: actions2,
7674 data,
7675 fields: fields2,
7676 getItemId,
7677 isLoading = false,
7678 onChangeView,
7679 onChangeSelection,
7680 selection,
7681 setOpenedFilter,
7682 view,
7683 className,
7684 empty
7685 }) {
7686 const headerMenuRefs = (0, import_element40.useRef)(/* @__PURE__ */ new Map());
7687 const headerMenuToFocusRef = (0, import_element40.useRef)(void 0);
7688 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element40.useState)();
7689 const isMultiselect = useIsMultiselectPicker(actions2) ?? false;
7690 (0, import_element40.useEffect)(() => {
7691 if (headerMenuToFocusRef.current) {
7692 headerMenuToFocusRef.current.focus();
7693 headerMenuToFocusRef.current = void 0;
7694 }
7695 });
7696 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
7697 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
7698 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
7699 const tableNoticeId = (0, import_element40.useId)();
7700 if (nextHeaderMenuToFocus) {
7701 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
7702 setNextHeaderMenuToFocus(void 0);
7703 return;
7704 }
7705 const onHide = (field) => {
7706 const hidden = headerMenuRefs.current.get(field.id);
7707 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
7708 setNextHeaderMenuToFocus(fallback?.node);
7709 };
7710 const hasData = !!data?.length;
7711 const titleField = fields2.find((field) => field.id === view.titleField);
7712 const mediaField = fields2.find((field) => field.id === view.mediaField);
7713 const descriptionField = fields2.find(
7714 (field) => field.id === view.descriptionField
7715 );
7716 const { showTitle = true, showMedia = true, showDescription = true } = view;
7717 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
7718 const columns = view.fields ?? [];
7719 const headerMenuRef = (column, index) => (node) => {
7720 if (node) {
7721 headerMenuRefs.current.set(column, {
7722 node,
7723 fallback: columns[index > 0 ? index - 1 : 1]
7724 });
7725 } else {
7726 headerMenuRefs.current.delete(column);
7727 }
7728 };
7729 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
7730 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7731 "table",
7732 {
7733 className: clsx_default(
7734 "dataviews-view-table",
7735 "dataviews-view-picker-table",
7736 className,
7737 {
7738 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
7739 view.layout.density
7740 )
7741 }
7742 ),
7743 "aria-busy": isLoading,
7744 "aria-describedby": tableNoticeId,
7745 role: isInfiniteScroll ? "feed" : "listbox",
7746 children: [
7747 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7748 "tr",
7749 {
7750 className: "dataviews-view-table__row",
7751 role: "presentation",
7752 children: [
7753 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7754 BulkSelectionCheckbox,
7755 {
7756 selection,
7757 onChangeSelection,
7758 data,
7759 actions: actions2,
7760 getItemId,
7761 disableSelectAll: isInfiniteScroll
7762 }
7763 ) }),
7764 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7765 column_header_menu_default,
7766 {
7767 ref: headerMenuRef(
7768 titleField.id,
7769 0
7770 ),
7771 fieldId: titleField.id,
7772 view,
7773 fields: fields2,
7774 onChangeView,
7775 onHide,
7776 setOpenedFilter,
7777 canMove: false
7778 }
7779 ) }),
7780 columns.map((column, index) => {
7781 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
7782 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7783 "th",
7784 {
7785 style: {
7786 width,
7787 maxWidth,
7788 minWidth,
7789 textAlign: align
7790 },
7791 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
7792 scope: "col",
7793 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7794 column_header_menu_default,
7795 {
7796 ref: headerMenuRef(column, index),
7797 fieldId: column,
7798 view,
7799 fields: fields2,
7800 onChangeView,
7801 onHide,
7802 setOpenedFilter,
7803 canMove: view.layout?.enableMoving ?? true
7804 }
7805 )
7806 },
7807 column
7808 );
7809 })
7810 ]
7811 }
7812 ) }),
7813 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
7814 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7815 import_components17.Composite,
7816 {
7817 virtualFocus: true,
7818 orientation: "vertical",
7819 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "group" }),
7820 children: [
7821 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7822 "tr",
7823 {
7824 className: "dataviews-view-table__group-header-row",
7825 role: "presentation",
7826 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7827 "td",
7828 {
7829 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
7830 className: "dataviews-view-table__group-header-cell",
7831 role: "presentation",
7832 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n19.sprintf)(
7833 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
7834 (0, import_i18n19.__)("%1$s: %2$s"),
7835 groupField.label,
7836 groupName
7837 )
7838 }
7839 )
7840 }
7841 ),
7842 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7843 TableRow2,
7844 {
7845 item,
7846 fields: fields2,
7847 id: getItemId(item) || index.toString(),
7848 view,
7849 titleField,
7850 mediaField,
7851 descriptionField,
7852 selection,
7853 getItemId,
7854 onChangeSelection,
7855 multiselect: isMultiselect
7856 },
7857 getItemId(item)
7858 ))
7859 ]
7860 },
7861 `group-${groupName}`
7862 )
7863 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7864 import_components17.Composite,
7865 {
7866 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "presentation" }),
7867 virtualFocus: true,
7868 orientation: "vertical",
7869 children: hasData && data.map((item, index) => {
7870 const itemId = getItemId(item);
7871 const posinset = item.position;
7872 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
7873 TableRow2,
7874 {
7875 item,
7876 fields: fields2,
7877 id: itemId || index.toString(),
7878 view,
7879 titleField,
7880 mediaField,
7881 descriptionField,
7882 selection,
7883 getItemId,
7884 onChangeSelection,
7885 multiselect: isMultiselect,
7886 posinset
7887 },
7888 itemId
7889 );
7890 })
7891 }
7892 )
7893 ]
7894 }
7895 ),
7896 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
7897 "div",
7898 {
7899 className: clsx_default({
7900 "dataviews-loading": isLoading,
7901 "dataviews-no-results": !hasData && !isLoading
7902 }),
7903 id: tableNoticeId,
7904 children: [
7905 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components17.Spinner, {}) }) : empty),
7906 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components17.Spinner, {}) })
7907 ]
7908 }
7909 )
7910 ] });
7911 }
7912 var picker_table_default = ViewPickerTable;
7913
7914 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
7915 var import_components18 = __toESM(require_components(), 1);
7916 var import_i18n20 = __toESM(require_i18n(), 1);
7917 var import_element41 = __toESM(require_element(), 1);
7918 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
7919 function DensityPicker() {
7920 const context = (0, import_element41.useContext)(dataviews_context_default);
7921 const view = context.view;
7922 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
7923 import_components18.__experimentalToggleGroupControl,
7924 {
7925 size: "__unstable-large",
7926 label: (0, import_i18n20.__)("Density"),
7927 value: view.layout?.density || "balanced",
7928 onChange: (value) => {
7929 context.onChangeView({
7930 ...view,
7931 layout: {
7932 ...view.layout,
7933 density: value
7934 }
7935 });
7936 },
7937 isBlock: true,
7938 children: [
7939 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7940 import_components18.__experimentalToggleGroupControlOption,
7941 {
7942 value: "comfortable",
7943 label: (0, import_i18n20._x)(
7944 "Comfortable",
7945 "Density option for DataView layout"
7946 )
7947 },
7948 "comfortable"
7949 ),
7950 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7951 import_components18.__experimentalToggleGroupControlOption,
7952 {
7953 value: "balanced",
7954 label: (0, import_i18n20._x)("Balanced", "Density option for DataView layout")
7955 },
7956 "balanced"
7957 ),
7958 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
7959 import_components18.__experimentalToggleGroupControlOption,
7960 {
7961 value: "compact",
7962 label: (0, import_i18n20._x)("Compact", "Density option for DataView layout")
7963 },
7964 "compact"
7965 )
7966 ]
7967 }
7968 );
7969 }
7970
7971 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
7972 var import_components19 = __toESM(require_components(), 1);
7973 var import_i18n21 = __toESM(require_i18n(), 1);
7974 var import_element42 = __toESM(require_element(), 1);
7975 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
7976 var imageSizes2 = [
7977 {
7978 value: 120,
7979 breakpoint: 1
7980 },
7981 {
7982 value: 170,
7983 breakpoint: 1
7984 },
7985 {
7986 value: 230,
7987 breakpoint: 1
7988 },
7989 {
7990 value: 290,
7991 breakpoint: 1112
7992 // at minimum image width, 4 images display at this container size
7993 },
7994 {
7995 value: 350,
7996 breakpoint: 1636
7997 // at minimum image width, 6 images display at this container size
7998 },
7999 {
8000 value: 430,
8001 breakpoint: 588
8002 // at minimum image width, 2 images display at this container size
8003 }
8004 ];
8005 function PreviewSizePicker() {
8006 const context = (0, import_element42.useContext)(dataviews_context_default);
8007 const view = context.view;
8008 const breakValues = imageSizes2.filter((size) => {
8009 return context.containerWidth >= size.breakpoint;
8010 });
8011 const layoutPreviewSize = view.layout?.previewSize ?? 230;
8012 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
8013 const marks = breakValues.map((size, index) => {
8014 return {
8015 value: index
8016 };
8017 });
8018 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
8019 import_components19.RangeControl,
8020 {
8021 __next40pxDefaultSize: true,
8022 showTooltip: false,
8023 label: (0, import_i18n21.__)("Preview size"),
8024 value: previewSizeToUse,
8025 min: 0,
8026 max: breakValues.length - 1,
8027 withInputField: false,
8028 onChange: (value = 0) => {
8029 context.onChangeView({
8030 ...view,
8031 layout: {
8032 ...view.layout,
8033 previewSize: breakValues[value].value
8034 }
8035 });
8036 },
8037 step: 1,
8038 marks
8039 }
8040 );
8041 }
8042
8043 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
8044 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
8045 function GridConfigOptions() {
8046 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
8047 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DensityPicker, {}),
8048 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PreviewSizePicker, {})
8049 ] });
8050 }
8051
8052 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
8053 var VIEW_LAYOUTS = [
8054 {
8055 type: LAYOUT_TABLE,
8056 label: (0, import_i18n22.__)("Table"),
8057 component: table_default,
8058 icon: block_table_default,
8059 viewConfigOptions: DensityPicker
8060 },
8061 {
8062 type: LAYOUT_GRID,
8063 label: (0, import_i18n22.__)("Grid"),
8064 component: grid_default,
8065 icon: category_default,
8066 viewConfigOptions: GridConfigOptions
8067 },
8068 {
8069 type: LAYOUT_LIST,
8070 label: (0, import_i18n22.__)("List"),
8071 component: ViewList,
8072 icon: (0, import_i18n22.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
8073 viewConfigOptions: DensityPicker
8074 },
8075 {
8076 type: LAYOUT_ACTIVITY,
8077 label: (0, import_i18n22.__)("Activity"),
8078 component: ViewActivity,
8079 icon: scheduled_default,
8080 viewConfigOptions: DensityPicker
8081 },
8082 {
8083 type: LAYOUT_PICKER_GRID,
8084 label: (0, import_i18n22.__)("Grid"),
8085 component: picker_grid_default,
8086 icon: category_default,
8087 viewConfigOptions: GridConfigOptions,
8088 isPicker: true
8089 },
8090 {
8091 type: LAYOUT_PICKER_TABLE,
8092 label: (0, import_i18n22.__)("Table"),
8093 component: picker_table_default,
8094 icon: block_table_default,
8095 viewConfigOptions: DensityPicker,
8096 isPicker: true
8097 }
8098 ];
8099
8100 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
8101 var import_element50 = __toESM(require_element(), 1);
8102
8103 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
8104 var import_components22 = __toESM(require_components(), 1);
8105 var import_i18n25 = __toESM(require_i18n(), 1);
8106 var import_element47 = __toESM(require_element(), 1);
8107
8108 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
8109 function noop2(..._) {
8110 }
8111 function applyState(argument, currentValue) {
8112 if (isUpdater(argument)) {
8113 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
8114 return argument(value);
8115 }
8116 return argument;
8117 }
8118 function isUpdater(argument) {
8119 return typeof argument === "function";
8120 }
8121 function isLazyValue(value) {
8122 return typeof value === "function";
8123 }
8124 function hasOwnProperty(object, prop) {
8125 if (typeof Object.hasOwn === "function") {
8126 return Object.hasOwn(object, prop);
8127 }
8128 return Object.prototype.hasOwnProperty.call(object, prop);
8129 }
8130 function chain(...fns) {
8131 return (...args) => {
8132 for (const fn of fns) {
8133 if (typeof fn === "function") {
8134 fn(...args);
8135 }
8136 }
8137 };
8138 }
8139 function normalizeString(str) {
8140 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
8141 }
8142 function omit(object, keys) {
8143 const result = { ...object };
8144 for (const key of keys) {
8145 if (hasOwnProperty(result, key)) {
8146 delete result[key];
8147 }
8148 }
8149 return result;
8150 }
8151 function pick(object, paths) {
8152 const result = {};
8153 for (const key of paths) {
8154 if (hasOwnProperty(object, key)) {
8155 result[key] = object[key];
8156 }
8157 }
8158 return result;
8159 }
8160 function identity(value) {
8161 return value;
8162 }
8163 function invariant(condition, message2) {
8164 if (condition) return;
8165 if (typeof message2 !== "string") throw new Error("Invariant failed");
8166 throw new Error(message2);
8167 }
8168 function getKeys(obj) {
8169 return Object.keys(obj);
8170 }
8171 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
8172 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
8173 if (result == null) return false;
8174 return !result;
8175 }
8176 function disabledFromProps(props) {
8177 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
8178 }
8179 function removeUndefinedValues(obj) {
8180 const result = {};
8181 for (const key in obj) {
8182 if (obj[key] !== void 0) {
8183 result[key] = obj[key];
8184 }
8185 }
8186 return result;
8187 }
8188 function defaultValue(...values) {
8189 for (const value of values) {
8190 if (value !== void 0) return value;
8191 }
8192 return void 0;
8193 }
8194
8195 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
8196 var import_react10 = __toESM(require_react(), 1);
8197 function setRef(ref, value) {
8198 if (typeof ref === "function") {
8199 ref(value);
8200 } else if (ref) {
8201 ref.current = value;
8202 }
8203 }
8204 function isValidElementWithRef(element) {
8205 if (!element) return false;
8206 if (!(0, import_react10.isValidElement)(element)) return false;
8207 if ("ref" in element.props) return true;
8208 if ("ref" in element) return true;
8209 return false;
8210 }
8211 function getRefProperty(element) {
8212 if (!isValidElementWithRef(element)) return null;
8213 const props = { ...element.props };
8214 return props.ref || element.ref;
8215 }
8216 function mergeProps2(base, overrides) {
8217 const props = { ...base };
8218 for (const key in overrides) {
8219 if (!hasOwnProperty(overrides, key)) continue;
8220 if (key === "className") {
8221 const prop = "className";
8222 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
8223 continue;
8224 }
8225 if (key === "style") {
8226 const prop = "style";
8227 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
8228 continue;
8229 }
8230 const overrideValue = overrides[key];
8231 if (typeof overrideValue === "function" && key.startsWith("on")) {
8232 const baseValue = base[key];
8233 if (typeof baseValue === "function") {
8234 props[key] = (...args) => {
8235 overrideValue(...args);
8236 baseValue(...args);
8237 };
8238 continue;
8239 }
8240 }
8241 props[key] = overrideValue;
8242 }
8243 return props;
8244 }
8245
8246 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
8247 var canUseDOM = checkIsBrowser();
8248 function checkIsBrowser() {
8249 var _a;
8250 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
8251 }
8252 function getDocument(node) {
8253 if (!node) return document;
8254 if ("self" in node) return node.document;
8255 return node.ownerDocument || document;
8256 }
8257 function getActiveElement(node, activeDescendant = false) {
8258 var _a;
8259 const { activeElement } = getDocument(node);
8260 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
8261 return null;
8262 }
8263 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
8264 return getActiveElement(
8265 activeElement.contentDocument.body,
8266 activeDescendant
8267 );
8268 }
8269 if (activeDescendant) {
8270 const id = activeElement.getAttribute("aria-activedescendant");
8271 if (id) {
8272 const element = getDocument(activeElement).getElementById(id);
8273 if (element) {
8274 return element;
8275 }
8276 }
8277 }
8278 return activeElement;
8279 }
8280 function contains(parent, child) {
8281 return parent === child || parent.contains(child);
8282 }
8283 function isFrame(element) {
8284 return element.tagName === "IFRAME";
8285 }
8286 function isButton(element) {
8287 const tagName = element.tagName.toLowerCase();
8288 if (tagName === "button") return true;
8289 if (tagName === "input" && element.type) {
8290 return buttonInputTypes.indexOf(element.type) !== -1;
8291 }
8292 return false;
8293 }
8294 var buttonInputTypes = [
8295 "button",
8296 "color",
8297 "file",
8298 "image",
8299 "reset",
8300 "submit"
8301 ];
8302 function isVisible(element) {
8303 if (typeof element.checkVisibility === "function") {
8304 return element.checkVisibility();
8305 }
8306 const htmlElement = element;
8307 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
8308 }
8309 function isTextField(element) {
8310 try {
8311 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
8312 const isTextArea = element.tagName === "TEXTAREA";
8313 return isTextInput || isTextArea || false;
8314 } catch (_error) {
8315 return false;
8316 }
8317 }
8318 function isTextbox(element) {
8319 return element.isContentEditable || isTextField(element);
8320 }
8321 function getTextboxValue(element) {
8322 if (isTextField(element)) {
8323 return element.value;
8324 }
8325 if (element.isContentEditable) {
8326 const range = getDocument(element).createRange();
8327 range.selectNodeContents(element);
8328 return range.toString();
8329 }
8330 return "";
8331 }
8332 function getTextboxSelection(element) {
8333 let start = 0;
8334 let end = 0;
8335 if (isTextField(element)) {
8336 start = element.selectionStart || 0;
8337 end = element.selectionEnd || 0;
8338 } else if (element.isContentEditable) {
8339 const selection = getDocument(element).getSelection();
8340 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
8341 const range = selection.getRangeAt(0);
8342 const nextRange = range.cloneRange();
8343 nextRange.selectNodeContents(element);
8344 nextRange.setEnd(range.startContainer, range.startOffset);
8345 start = nextRange.toString().length;
8346 nextRange.setEnd(range.endContainer, range.endOffset);
8347 end = nextRange.toString().length;
8348 }
8349 }
8350 return { start, end };
8351 }
8352 function getPopupRole(element, fallback) {
8353 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
8354 const role = element == null ? void 0 : element.getAttribute("role");
8355 if (role && allowedPopupRoles.indexOf(role) !== -1) {
8356 return role;
8357 }
8358 return fallback;
8359 }
8360 function getScrollingElement(element) {
8361 if (!element) return null;
8362 const isScrollableOverflow = (overflow) => {
8363 if (overflow === "auto") return true;
8364 if (overflow === "scroll") return true;
8365 return false;
8366 };
8367 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
8368 const { overflowY } = getComputedStyle(element);
8369 if (isScrollableOverflow(overflowY)) return element;
8370 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
8371 const { overflowX } = getComputedStyle(element);
8372 if (isScrollableOverflow(overflowX)) return element;
8373 }
8374 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
8375 }
8376 function setSelectionRange(element, ...args) {
8377 if (/text|search|password|tel|url/i.test(element.type)) {
8378 element.setSelectionRange(...args);
8379 }
8380 }
8381 function sortBasedOnDOMPosition(items, getElement) {
8382 const pairs = items.map((item, index) => [index, item]);
8383 let isOrderDifferent = false;
8384 pairs.sort(([indexA, a2], [indexB, b2]) => {
8385 const elementA = getElement(a2);
8386 const elementB = getElement(b2);
8387 if (elementA === elementB) return 0;
8388 if (!elementA || !elementB) return 0;
8389 if (isElementPreceding(elementA, elementB)) {
8390 if (indexA > indexB) {
8391 isOrderDifferent = true;
8392 }
8393 return -1;
8394 }
8395 if (indexA < indexB) {
8396 isOrderDifferent = true;
8397 }
8398 return 1;
8399 });
8400 if (isOrderDifferent) {
8401 return pairs.map(([_, item]) => item);
8402 }
8403 return items;
8404 }
8405 function isElementPreceding(a2, b2) {
8406 return Boolean(
8407 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
8408 );
8409 }
8410
8411 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
8412 function isTouchDevice() {
8413 return canUseDOM && !!navigator.maxTouchPoints;
8414 }
8415 function isApple() {
8416 if (!canUseDOM) return false;
8417 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
8418 }
8419 function isSafari() {
8420 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
8421 }
8422 function isFirefox() {
8423 return canUseDOM && /firefox\//i.test(navigator.userAgent);
8424 }
8425
8426 // node_modules/@ariakit/core/esm/utils/events.js
8427 function isPortalEvent(event) {
8428 return Boolean(
8429 event.currentTarget && !contains(event.currentTarget, event.target)
8430 );
8431 }
8432 function isSelfTarget(event) {
8433 return event.target === event.currentTarget;
8434 }
8435 function isOpeningInNewTab(event) {
8436 const element = event.currentTarget;
8437 if (!element) return false;
8438 const isAppleDevice = isApple();
8439 if (isAppleDevice && !event.metaKey) return false;
8440 if (!isAppleDevice && !event.ctrlKey) return false;
8441 const tagName = element.tagName.toLowerCase();
8442 if (tagName === "a") return true;
8443 if (tagName === "button" && element.type === "submit") return true;
8444 if (tagName === "input" && element.type === "submit") return true;
8445 return false;
8446 }
8447 function isDownloading(event) {
8448 const element = event.currentTarget;
8449 if (!element) return false;
8450 const tagName = element.tagName.toLowerCase();
8451 if (!event.altKey) return false;
8452 if (tagName === "a") return true;
8453 if (tagName === "button" && element.type === "submit") return true;
8454 if (tagName === "input" && element.type === "submit") return true;
8455 return false;
8456 }
8457 function fireBlurEvent(element, eventInit) {
8458 const event = new FocusEvent("blur", eventInit);
8459 const defaultAllowed = element.dispatchEvent(event);
8460 const bubbleInit = { ...eventInit, bubbles: true };
8461 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
8462 return defaultAllowed;
8463 }
8464 function fireKeyboardEvent(element, type, eventInit) {
8465 const event = new KeyboardEvent(type, eventInit);
8466 return element.dispatchEvent(event);
8467 }
8468 function fireClickEvent(element, eventInit) {
8469 const event = new MouseEvent("click", eventInit);
8470 return element.dispatchEvent(event);
8471 }
8472 function isFocusEventOutside(event, container) {
8473 const containerElement = container || event.currentTarget;
8474 const relatedTarget = event.relatedTarget;
8475 return !relatedTarget || !contains(containerElement, relatedTarget);
8476 }
8477 function queueBeforeEvent(element, type, callback, timeout) {
8478 const createTimer = (callback2) => {
8479 if (timeout) {
8480 const timerId2 = setTimeout(callback2, timeout);
8481 return () => clearTimeout(timerId2);
8482 }
8483 const timerId = requestAnimationFrame(callback2);
8484 return () => cancelAnimationFrame(timerId);
8485 };
8486 const cancelTimer = createTimer(() => {
8487 element.removeEventListener(type, callSync, true);
8488 callback();
8489 });
8490 const callSync = () => {
8491 cancelTimer();
8492 callback();
8493 };
8494 element.addEventListener(type, callSync, { once: true, capture: true });
8495 return cancelTimer;
8496 }
8497 function addGlobalEventListener(type, listener, options, scope = window) {
8498 const children = [];
8499 try {
8500 scope.document.addEventListener(type, listener, options);
8501 for (const frame of Array.from(scope.frames)) {
8502 children.push(addGlobalEventListener(type, listener, options, frame));
8503 }
8504 } catch (e2) {
8505 }
8506 const removeEventListener = () => {
8507 try {
8508 scope.document.removeEventListener(type, listener, options);
8509 } catch (e2) {
8510 }
8511 for (const remove of children) {
8512 remove();
8513 }
8514 };
8515 return removeEventListener;
8516 }
8517
8518 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
8519 var React23 = __toESM(require_react(), 1);
8520 var import_react11 = __toESM(require_react(), 1);
8521 var _React = { ...React23 };
8522 var useReactId = _React.useId;
8523 var useReactDeferredValue = _React.useDeferredValue;
8524 var useReactInsertionEffect = _React.useInsertionEffect;
8525 var useSafeLayoutEffect = canUseDOM ? import_react11.useLayoutEffect : import_react11.useEffect;
8526 function useInitialValue(value) {
8527 const [initialValue] = (0, import_react11.useState)(value);
8528 return initialValue;
8529 }
8530 function useLiveRef(value) {
8531 const ref = (0, import_react11.useRef)(value);
8532 useSafeLayoutEffect(() => {
8533 ref.current = value;
8534 });
8535 return ref;
8536 }
8537 function useEvent(callback) {
8538 const ref = (0, import_react11.useRef)(() => {
8539 throw new Error("Cannot call an event handler while rendering.");
8540 });
8541 if (useReactInsertionEffect) {
8542 useReactInsertionEffect(() => {
8543 ref.current = callback;
8544 });
8545 } else {
8546 ref.current = callback;
8547 }
8548 return (0, import_react11.useCallback)((...args) => {
8549 var _a;
8550 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
8551 }, []);
8552 }
8553 function useTransactionState(callback) {
8554 const [state, setState] = (0, import_react11.useState)(null);
8555 useSafeLayoutEffect(() => {
8556 if (state == null) return;
8557 if (!callback) return;
8558 let prevState = null;
8559 callback((prev) => {
8560 prevState = prev;
8561 return state;
8562 });
8563 return () => {
8564 callback(prevState);
8565 };
8566 }, [state, callback]);
8567 return [state, setState];
8568 }
8569 function useMergeRefs(...refs) {
8570 return (0, import_react11.useMemo)(() => {
8571 if (!refs.some(Boolean)) return;
8572 return (value) => {
8573 for (const ref of refs) {
8574 setRef(ref, value);
8575 }
8576 };
8577 }, refs);
8578 }
8579 function useId5(defaultId) {
8580 if (useReactId) {
8581 const reactId = useReactId();
8582 if (defaultId) return defaultId;
8583 return reactId;
8584 }
8585 const [id, setId] = (0, import_react11.useState)(defaultId);
8586 useSafeLayoutEffect(() => {
8587 if (defaultId || id) return;
8588 const random = Math.random().toString(36).slice(2, 8);
8589 setId(`id-${random}`);
8590 }, [defaultId, id]);
8591 return defaultId || id;
8592 }
8593 function useTagName(refOrElement, type) {
8594 const stringOrUndefined = (type2) => {
8595 if (typeof type2 !== "string") return;
8596 return type2;
8597 };
8598 const [tagName, setTagName] = (0, import_react11.useState)(() => stringOrUndefined(type));
8599 useSafeLayoutEffect(() => {
8600 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
8601 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
8602 }, [refOrElement, type]);
8603 return tagName;
8604 }
8605 function useAttribute(refOrElement, attributeName, defaultValue2) {
8606 const initialValue = useInitialValue(defaultValue2);
8607 const [attribute, setAttribute] = (0, import_react11.useState)(initialValue);
8608 (0, import_react11.useEffect)(() => {
8609 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
8610 if (!element) return;
8611 const callback = () => {
8612 const value = element.getAttribute(attributeName);
8613 setAttribute(value == null ? initialValue : value);
8614 };
8615 const observer = new MutationObserver(callback);
8616 observer.observe(element, { attributeFilter: [attributeName] });
8617 callback();
8618 return () => observer.disconnect();
8619 }, [refOrElement, attributeName, initialValue]);
8620 return attribute;
8621 }
8622 function useUpdateEffect(effect, deps) {
8623 const mounted = (0, import_react11.useRef)(false);
8624 (0, import_react11.useEffect)(() => {
8625 if (mounted.current) {
8626 return effect();
8627 }
8628 mounted.current = true;
8629 }, deps);
8630 (0, import_react11.useEffect)(
8631 () => () => {
8632 mounted.current = false;
8633 },
8634 []
8635 );
8636 }
8637 function useUpdateLayoutEffect(effect, deps) {
8638 const mounted = (0, import_react11.useRef)(false);
8639 useSafeLayoutEffect(() => {
8640 if (mounted.current) {
8641 return effect();
8642 }
8643 mounted.current = true;
8644 }, deps);
8645 useSafeLayoutEffect(
8646 () => () => {
8647 mounted.current = false;
8648 },
8649 []
8650 );
8651 }
8652 function useForceUpdate() {
8653 return (0, import_react11.useReducer)(() => [], []);
8654 }
8655 function useBooleanEvent(booleanOrCallback) {
8656 return useEvent(
8657 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
8658 );
8659 }
8660 function useWrapElement(props, callback, deps = []) {
8661 const wrapElement = (0, import_react11.useCallback)(
8662 (element) => {
8663 if (props.wrapElement) {
8664 element = props.wrapElement(element);
8665 }
8666 return callback(element);
8667 },
8668 [...deps, props.wrapElement]
8669 );
8670 return { ...props, wrapElement };
8671 }
8672 function useMetadataProps(props, key, value) {
8673 const parent = props.onLoadedMetadataCapture;
8674 const onLoadedMetadataCapture = (0, import_react11.useMemo)(() => {
8675 return Object.assign(() => {
8676 }, { ...parent, [key]: value });
8677 }, [parent, key, value]);
8678 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
8679 }
8680 var hasInstalledGlobalEventListeners = false;
8681 function useIsMouseMoving() {
8682 (0, import_react11.useEffect)(() => {
8683 if (hasInstalledGlobalEventListeners) return;
8684 addGlobalEventListener("mousemove", setMouseMoving, true);
8685 addGlobalEventListener("mousedown", resetMouseMoving, true);
8686 addGlobalEventListener("mouseup", resetMouseMoving, true);
8687 addGlobalEventListener("keydown", resetMouseMoving, true);
8688 addGlobalEventListener("scroll", resetMouseMoving, true);
8689 hasInstalledGlobalEventListeners = true;
8690 }, []);
8691 const isMouseMoving = useEvent(() => mouseMoving);
8692 return isMouseMoving;
8693 }
8694 var mouseMoving = false;
8695 var previousScreenX = 0;
8696 var previousScreenY = 0;
8697 function hasMouseMovement(event) {
8698 const movementX = event.movementX || event.screenX - previousScreenX;
8699 const movementY = event.movementY || event.screenY - previousScreenY;
8700 previousScreenX = event.screenX;
8701 previousScreenY = event.screenY;
8702 return movementX || movementY || false;
8703 }
8704 function setMouseMoving(event) {
8705 if (!hasMouseMovement(event)) return;
8706 mouseMoving = true;
8707 }
8708 function resetMouseMoving() {
8709 mouseMoving = false;
8710 }
8711
8712 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
8713 var React24 = __toESM(require_react(), 1);
8714 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
8715 function forwardRef26(render4) {
8716 const Role = React24.forwardRef(
8717 // @ts-ignore Incompatible with React 19 types. Ignore for now.
8718 (props, ref) => render4({ ...props, ref })
8719 );
8720 Role.displayName = render4.displayName || render4.name;
8721 return Role;
8722 }
8723 function memo22(Component, propsAreEqual) {
8724 return React24.memo(Component, propsAreEqual);
8725 }
8726 function createElement3(Type, props) {
8727 const { wrapElement, render: render4, ...rest } = props;
8728 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
8729 let element;
8730 if (React24.isValidElement(render4)) {
8731 const renderProps = {
8732 // @ts-ignore Incompatible with React 19 types. Ignore for now.
8733 ...render4.props,
8734 ref: mergedRef
8735 };
8736 element = React24.cloneElement(render4, mergeProps2(rest, renderProps));
8737 } else if (render4) {
8738 element = render4(rest);
8739 } else {
8740 element = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Type, { ...rest });
8741 }
8742 if (wrapElement) {
8743 return wrapElement(element);
8744 }
8745 return element;
8746 }
8747 function createHook(useProps) {
8748 const useRole = (props = {}) => {
8749 return useProps(props);
8750 };
8751 useRole.displayName = useProps.name;
8752 return useRole;
8753 }
8754 function createStoreContext(providers = [], scopedProviders = []) {
8755 const context = React24.createContext(void 0);
8756 const scopedContext = React24.createContext(void 0);
8757 const useContext210 = () => React24.useContext(context);
8758 const useScopedContext = (onlyScoped = false) => {
8759 const scoped = React24.useContext(scopedContext);
8760 const store2 = useContext210();
8761 if (onlyScoped) return scoped;
8762 return scoped || store2;
8763 };
8764 const useProviderContext = () => {
8765 const scoped = React24.useContext(scopedContext);
8766 const store2 = useContext210();
8767 if (scoped && scoped === store2) return;
8768 return store2;
8769 };
8770 const ContextProvider = (props) => {
8771 return providers.reduceRight(
8772 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
8773 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(context.Provider, { ...props })
8774 );
8775 };
8776 const ScopedContextProvider = (props) => {
8777 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
8778 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
8779 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(scopedContext.Provider, { ...props })
8780 ) });
8781 };
8782 return {
8783 context,
8784 scopedContext,
8785 useContext: useContext210,
8786 useScopedContext,
8787 useProviderContext,
8788 ContextProvider,
8789 ScopedContextProvider
8790 };
8791 }
8792
8793 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
8794 var ctx = createStoreContext();
8795 var useCollectionContext = ctx.useContext;
8796 var useCollectionScopedContext = ctx.useScopedContext;
8797 var useCollectionProviderContext = ctx.useProviderContext;
8798 var CollectionContextProvider = ctx.ContextProvider;
8799 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
8800
8801 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
8802 var import_react12 = __toESM(require_react(), 1);
8803 var ctx2 = createStoreContext(
8804 [CollectionContextProvider],
8805 [CollectionScopedContextProvider]
8806 );
8807 var useCompositeContext = ctx2.useContext;
8808 var useCompositeScopedContext = ctx2.useScopedContext;
8809 var useCompositeProviderContext = ctx2.useProviderContext;
8810 var CompositeContextProvider = ctx2.ContextProvider;
8811 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
8812 var CompositeItemContext = (0, import_react12.createContext)(
8813 void 0
8814 );
8815 var CompositeRowContext = (0, import_react12.createContext)(
8816 void 0
8817 );
8818
8819 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
8820 function findFirstEnabledItem(items, excludeId) {
8821 return items.find((item) => {
8822 if (excludeId) {
8823 return !item.disabled && item.id !== excludeId;
8824 }
8825 return !item.disabled;
8826 });
8827 }
8828 function getEnabledItem(store2, id) {
8829 if (!id) return null;
8830 return store2.item(id) || null;
8831 }
8832 function groupItemsByRows(items) {
8833 const rows = [];
8834 for (const item of items) {
8835 const row = rows.find((currentRow) => {
8836 var _a;
8837 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
8838 });
8839 if (row) {
8840 row.push(item);
8841 } else {
8842 rows.push([item]);
8843 }
8844 }
8845 return rows;
8846 }
8847 function selectTextField(element, collapseToEnd = false) {
8848 if (isTextField(element)) {
8849 element.setSelectionRange(
8850 collapseToEnd ? element.value.length : 0,
8851 element.value.length
8852 );
8853 } else if (element.isContentEditable) {
8854 const selection = getDocument(element).getSelection();
8855 selection == null ? void 0 : selection.selectAllChildren(element);
8856 if (collapseToEnd) {
8857 selection == null ? void 0 : selection.collapseToEnd();
8858 }
8859 }
8860 }
8861 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
8862 function focusSilently(element) {
8863 element[FOCUS_SILENTLY] = true;
8864 element.focus({ preventScroll: true });
8865 }
8866 function silentlyFocused(element) {
8867 const isSilentlyFocused = element[FOCUS_SILENTLY];
8868 delete element[FOCUS_SILENTLY];
8869 return isSilentlyFocused;
8870 }
8871 function isItem(store2, element, exclude) {
8872 if (!element) return false;
8873 if (element === exclude) return false;
8874 const item = store2.item(element.id);
8875 if (!item) return false;
8876 if (exclude && item.element === exclude) return false;
8877 return true;
8878 }
8879
8880 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
8881 var import_react13 = __toESM(require_react(), 1);
8882 var TagName = "div";
8883 var useCollectionItem = createHook(
8884 function useCollectionItem2({
8885 store: store2,
8886 shouldRegisterItem = true,
8887 getItem = identity,
8888 // @ts-expect-error This prop may come from a collection renderer.
8889 element,
8890 ...props
8891 }) {
8892 const context = useCollectionContext();
8893 store2 = store2 || context;
8894 const id = useId5(props.id);
8895 const ref = (0, import_react13.useRef)(element);
8896 (0, import_react13.useEffect)(() => {
8897 const element2 = ref.current;
8898 if (!id) return;
8899 if (!element2) return;
8900 if (!shouldRegisterItem) return;
8901 const item = getItem({ id, element: element2 });
8902 return store2 == null ? void 0 : store2.renderItem(item);
8903 }, [id, shouldRegisterItem, getItem, store2]);
8904 props = {
8905 ...props,
8906 ref: useMergeRefs(ref, props.ref)
8907 };
8908 return removeUndefinedValues(props);
8909 }
8910 );
8911 var CollectionItem = forwardRef26(function CollectionItem2(props) {
8912 const htmlProps = useCollectionItem(props);
8913 return createElement3(TagName, htmlProps);
8914 });
8915
8916 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
8917 var import_react14 = __toESM(require_react(), 1);
8918 var FocusableContext = (0, import_react14.createContext)(true);
8919
8920 // node_modules/@ariakit/core/esm/utils/focus.js
8921 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'])";
8922 function isFocusable(element) {
8923 if (!element.matches(selector)) return false;
8924 if (!isVisible(element)) return false;
8925 if (element.closest("[inert]")) return false;
8926 return true;
8927 }
8928 function getClosestFocusable(element) {
8929 while (element && !isFocusable(element)) {
8930 element = element.closest(selector);
8931 }
8932 return element || null;
8933 }
8934 function hasFocus(element) {
8935 const activeElement = getActiveElement(element);
8936 if (!activeElement) return false;
8937 if (activeElement === element) return true;
8938 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
8939 if (!activeDescendant) return false;
8940 return activeDescendant === element.id;
8941 }
8942 function hasFocusWithin(element) {
8943 const activeElement = getActiveElement(element);
8944 if (!activeElement) return false;
8945 if (contains(element, activeElement)) return true;
8946 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
8947 if (!activeDescendant) return false;
8948 if (!("id" in element)) return false;
8949 if (activeDescendant === element.id) return true;
8950 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
8951 }
8952 function focusIfNeeded(element) {
8953 if (!hasFocusWithin(element) && isFocusable(element)) {
8954 element.focus();
8955 }
8956 }
8957 function focusIntoView(element, options) {
8958 if (!("scrollIntoView" in element)) {
8959 element.focus();
8960 } else {
8961 element.focus({ preventScroll: true });
8962 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
8963 }
8964 }
8965
8966 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
8967 var import_react15 = __toESM(require_react(), 1);
8968 var TagName2 = "div";
8969 var isSafariBrowser = isSafari();
8970 var alwaysFocusVisibleInputTypes = [
8971 "text",
8972 "search",
8973 "url",
8974 "tel",
8975 "email",
8976 "password",
8977 "number",
8978 "date",
8979 "month",
8980 "week",
8981 "time",
8982 "datetime",
8983 "datetime-local"
8984 ];
8985 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
8986 function markSafariFocusAncestor(element, value) {
8987 if (!element) return;
8988 element[safariFocusAncestorSymbol] = value;
8989 }
8990 function isAlwaysFocusVisible(element) {
8991 const { tagName, readOnly, type } = element;
8992 if (tagName === "TEXTAREA" && !readOnly) return true;
8993 if (tagName === "SELECT" && !readOnly) return true;
8994 if (tagName === "INPUT" && !readOnly) {
8995 return alwaysFocusVisibleInputTypes.includes(type);
8996 }
8997 if (element.isContentEditable) return true;
8998 const role = element.getAttribute("role");
8999 if (role === "combobox" && element.dataset.name) {
9000 return true;
9001 }
9002 return false;
9003 }
9004 function getLabels(element) {
9005 if ("labels" in element) {
9006 return element.labels;
9007 }
9008 return null;
9009 }
9010 function isNativeCheckboxOrRadio(element) {
9011 const tagName = element.tagName.toLowerCase();
9012 if (tagName === "input" && element.type) {
9013 return element.type === "radio" || element.type === "checkbox";
9014 }
9015 return false;
9016 }
9017 function isNativeTabbable(tagName) {
9018 if (!tagName) return true;
9019 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
9020 }
9021 function supportsDisabledAttribute(tagName) {
9022 if (!tagName) return true;
9023 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
9024 }
9025 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
9026 if (!focusable) {
9027 return tabIndexProp;
9028 }
9029 if (trulyDisabled) {
9030 if (nativeTabbable && !supportsDisabled) {
9031 return -1;
9032 }
9033 return;
9034 }
9035 if (nativeTabbable) {
9036 return tabIndexProp;
9037 }
9038 return tabIndexProp || 0;
9039 }
9040 function useDisableEvent(onEvent, disabled2) {
9041 return useEvent((event) => {
9042 onEvent == null ? void 0 : onEvent(event);
9043 if (event.defaultPrevented) return;
9044 if (disabled2) {
9045 event.stopPropagation();
9046 event.preventDefault();
9047 }
9048 });
9049 }
9050 var hasInstalledGlobalEventListeners2 = false;
9051 var isKeyboardModality = true;
9052 function onGlobalMouseDown(event) {
9053 const target = event.target;
9054 if (target && "hasAttribute" in target) {
9055 if (!target.hasAttribute("data-focus-visible")) {
9056 isKeyboardModality = false;
9057 }
9058 }
9059 }
9060 function onGlobalKeyDown(event) {
9061 if (event.metaKey) return;
9062 if (event.ctrlKey) return;
9063 if (event.altKey) return;
9064 isKeyboardModality = true;
9065 }
9066 var useFocusable = createHook(
9067 function useFocusable2({
9068 focusable = true,
9069 accessibleWhenDisabled,
9070 autoFocus,
9071 onFocusVisible,
9072 ...props
9073 }) {
9074 const ref = (0, import_react15.useRef)(null);
9075 (0, import_react15.useEffect)(() => {
9076 if (!focusable) return;
9077 if (hasInstalledGlobalEventListeners2) return;
9078 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
9079 addGlobalEventListener("keydown", onGlobalKeyDown, true);
9080 hasInstalledGlobalEventListeners2 = true;
9081 }, [focusable]);
9082 if (isSafariBrowser) {
9083 (0, import_react15.useEffect)(() => {
9084 if (!focusable) return;
9085 const element = ref.current;
9086 if (!element) return;
9087 if (!isNativeCheckboxOrRadio(element)) return;
9088 const labels = getLabels(element);
9089 if (!labels) return;
9090 const onMouseUp = () => queueMicrotask(() => element.focus());
9091 for (const label of labels) {
9092 label.addEventListener("mouseup", onMouseUp);
9093 }
9094 return () => {
9095 for (const label of labels) {
9096 label.removeEventListener("mouseup", onMouseUp);
9097 }
9098 };
9099 }, [focusable]);
9100 }
9101 const disabled2 = focusable && disabledFromProps(props);
9102 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
9103 const [focusVisible, setFocusVisible] = (0, import_react15.useState)(false);
9104 (0, import_react15.useEffect)(() => {
9105 if (!focusable) return;
9106 if (trulyDisabled && focusVisible) {
9107 setFocusVisible(false);
9108 }
9109 }, [focusable, trulyDisabled, focusVisible]);
9110 (0, import_react15.useEffect)(() => {
9111 if (!focusable) return;
9112 if (!focusVisible) return;
9113 const element = ref.current;
9114 if (!element) return;
9115 if (typeof IntersectionObserver === "undefined") return;
9116 const observer = new IntersectionObserver(() => {
9117 if (!isFocusable(element)) {
9118 setFocusVisible(false);
9119 }
9120 });
9121 observer.observe(element);
9122 return () => observer.disconnect();
9123 }, [focusable, focusVisible]);
9124 const onKeyPressCapture = useDisableEvent(
9125 props.onKeyPressCapture,
9126 disabled2
9127 );
9128 const onMouseDownCapture = useDisableEvent(
9129 props.onMouseDownCapture,
9130 disabled2
9131 );
9132 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
9133 const onMouseDownProp = props.onMouseDown;
9134 const onMouseDown = useEvent((event) => {
9135 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9136 if (event.defaultPrevented) return;
9137 if (!focusable) return;
9138 const element = event.currentTarget;
9139 if (!isSafariBrowser) return;
9140 if (isPortalEvent(event)) return;
9141 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
9142 let receivedFocus = false;
9143 const onFocus = () => {
9144 receivedFocus = true;
9145 };
9146 const options = { capture: true, once: true };
9147 element.addEventListener("focusin", onFocus, options);
9148 const focusableContainer = getClosestFocusable(element.parentElement);
9149 markSafariFocusAncestor(focusableContainer, true);
9150 queueBeforeEvent(element, "mouseup", () => {
9151 element.removeEventListener("focusin", onFocus, true);
9152 markSafariFocusAncestor(focusableContainer, false);
9153 if (receivedFocus) return;
9154 focusIfNeeded(element);
9155 });
9156 });
9157 const handleFocusVisible = (event, currentTarget) => {
9158 if (currentTarget) {
9159 event.currentTarget = currentTarget;
9160 }
9161 if (!focusable) return;
9162 const element = event.currentTarget;
9163 if (!element) return;
9164 if (!hasFocus(element)) return;
9165 onFocusVisible == null ? void 0 : onFocusVisible(event);
9166 if (event.defaultPrevented) return;
9167 element.dataset.focusVisible = "true";
9168 setFocusVisible(true);
9169 };
9170 const onKeyDownCaptureProp = props.onKeyDownCapture;
9171 const onKeyDownCapture = useEvent((event) => {
9172 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
9173 if (event.defaultPrevented) return;
9174 if (!focusable) return;
9175 if (focusVisible) return;
9176 if (event.metaKey) return;
9177 if (event.altKey) return;
9178 if (event.ctrlKey) return;
9179 if (!isSelfTarget(event)) return;
9180 const element = event.currentTarget;
9181 const applyFocusVisible = () => handleFocusVisible(event, element);
9182 queueBeforeEvent(element, "focusout", applyFocusVisible);
9183 });
9184 const onFocusCaptureProp = props.onFocusCapture;
9185 const onFocusCapture = useEvent((event) => {
9186 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
9187 if (event.defaultPrevented) return;
9188 if (!focusable) return;
9189 if (!isSelfTarget(event)) {
9190 setFocusVisible(false);
9191 return;
9192 }
9193 const element = event.currentTarget;
9194 const applyFocusVisible = () => handleFocusVisible(event, element);
9195 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
9196 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
9197 } else {
9198 setFocusVisible(false);
9199 }
9200 });
9201 const onBlurProp = props.onBlur;
9202 const onBlur = useEvent((event) => {
9203 onBlurProp == null ? void 0 : onBlurProp(event);
9204 if (!focusable) return;
9205 if (!isFocusEventOutside(event)) return;
9206 event.currentTarget.removeAttribute("data-focus-visible");
9207 setFocusVisible(false);
9208 });
9209 const autoFocusOnShow = (0, import_react15.useContext)(FocusableContext);
9210 const autoFocusRef = useEvent((element) => {
9211 if (!focusable) return;
9212 if (!autoFocus) return;
9213 if (!element) return;
9214 if (!autoFocusOnShow) return;
9215 queueMicrotask(() => {
9216 if (hasFocus(element)) return;
9217 if (!isFocusable(element)) return;
9218 element.focus();
9219 });
9220 });
9221 const tagName = useTagName(ref);
9222 const nativeTabbable = focusable && isNativeTabbable(tagName);
9223 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
9224 const styleProp = props.style;
9225 const style = (0, import_react15.useMemo)(() => {
9226 if (trulyDisabled) {
9227 return { pointerEvents: "none", ...styleProp };
9228 }
9229 return styleProp;
9230 }, [trulyDisabled, styleProp]);
9231 props = {
9232 "data-focus-visible": focusable && focusVisible || void 0,
9233 "data-autofocus": autoFocus || void 0,
9234 "aria-disabled": disabled2 || void 0,
9235 ...props,
9236 ref: useMergeRefs(ref, autoFocusRef, props.ref),
9237 style,
9238 tabIndex: getTabIndex(
9239 focusable,
9240 trulyDisabled,
9241 nativeTabbable,
9242 supportsDisabled,
9243 props.tabIndex
9244 ),
9245 disabled: supportsDisabled && trulyDisabled ? true : void 0,
9246 // TODO: Test Focusable contentEditable.
9247 contentEditable: disabled2 ? void 0 : props.contentEditable,
9248 onKeyPressCapture,
9249 onClickCapture,
9250 onMouseDownCapture,
9251 onMouseDown,
9252 onKeyDownCapture,
9253 onFocusCapture,
9254 onBlur
9255 };
9256 return removeUndefinedValues(props);
9257 }
9258 );
9259 var Focusable = forwardRef26(function Focusable2(props) {
9260 const htmlProps = useFocusable(props);
9261 return createElement3(TagName2, htmlProps);
9262 });
9263
9264 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
9265 var import_react16 = __toESM(require_react(), 1);
9266 var TagName3 = "button";
9267 function isNativeClick(event) {
9268 if (!event.isTrusted) return false;
9269 const element = event.currentTarget;
9270 if (event.key === "Enter") {
9271 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
9272 }
9273 if (event.key === " ") {
9274 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
9275 }
9276 return false;
9277 }
9278 var symbol = /* @__PURE__ */ Symbol("command");
9279 var useCommand = createHook(
9280 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
9281 const ref = (0, import_react16.useRef)(null);
9282 const [isNativeButton, setIsNativeButton] = (0, import_react16.useState)(false);
9283 (0, import_react16.useEffect)(() => {
9284 if (!ref.current) return;
9285 setIsNativeButton(isButton(ref.current));
9286 }, []);
9287 const [active, setActive] = (0, import_react16.useState)(false);
9288 const activeRef = (0, import_react16.useRef)(false);
9289 const disabled2 = disabledFromProps(props);
9290 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
9291 const onKeyDownProp = props.onKeyDown;
9292 const onKeyDown = useEvent((event) => {
9293 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9294 const element = event.currentTarget;
9295 if (event.defaultPrevented) return;
9296 if (isDuplicate) return;
9297 if (disabled2) return;
9298 if (!isSelfTarget(event)) return;
9299 if (isTextField(element)) return;
9300 if (element.isContentEditable) return;
9301 const isEnter = clickOnEnter && event.key === "Enter";
9302 const isSpace = clickOnSpace && event.key === " ";
9303 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
9304 const shouldPreventSpace = event.key === " " && !clickOnSpace;
9305 if (shouldPreventEnter || shouldPreventSpace) {
9306 event.preventDefault();
9307 return;
9308 }
9309 if (isEnter || isSpace) {
9310 const nativeClick = isNativeClick(event);
9311 if (isEnter) {
9312 if (!nativeClick) {
9313 event.preventDefault();
9314 const { view, ...eventInit } = event;
9315 const click = () => fireClickEvent(element, eventInit);
9316 if (isFirefox()) {
9317 queueBeforeEvent(element, "keyup", click);
9318 } else {
9319 queueMicrotask(click);
9320 }
9321 }
9322 } else if (isSpace) {
9323 activeRef.current = true;
9324 if (!nativeClick) {
9325 event.preventDefault();
9326 setActive(true);
9327 }
9328 }
9329 }
9330 });
9331 const onKeyUpProp = props.onKeyUp;
9332 const onKeyUp = useEvent((event) => {
9333 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
9334 if (event.defaultPrevented) return;
9335 if (isDuplicate) return;
9336 if (disabled2) return;
9337 if (event.metaKey) return;
9338 const isSpace = clickOnSpace && event.key === " ";
9339 if (activeRef.current && isSpace) {
9340 activeRef.current = false;
9341 if (!isNativeClick(event)) {
9342 event.preventDefault();
9343 setActive(false);
9344 const element = event.currentTarget;
9345 const { view, ...eventInit } = event;
9346 queueMicrotask(() => fireClickEvent(element, eventInit));
9347 }
9348 }
9349 });
9350 props = {
9351 "data-active": active || void 0,
9352 type: isNativeButton ? "button" : void 0,
9353 ...metadataProps,
9354 ...props,
9355 ref: useMergeRefs(ref, props.ref),
9356 onKeyDown,
9357 onKeyUp
9358 };
9359 props = useFocusable(props);
9360 return props;
9361 }
9362 );
9363 var Command = forwardRef26(function Command2(props) {
9364 const htmlProps = useCommand(props);
9365 return createElement3(TagName3, htmlProps);
9366 });
9367
9368 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
9369 function getInternal(store2, key) {
9370 const internals = store2.__unstableInternals;
9371 invariant(internals, "Invalid store");
9372 return internals[key];
9373 }
9374 function createStore(initialState, ...stores) {
9375 let state = initialState;
9376 let prevStateBatch = state;
9377 let lastUpdate = /* @__PURE__ */ Symbol();
9378 let destroy = noop2;
9379 const instances = /* @__PURE__ */ new Set();
9380 const updatedKeys = /* @__PURE__ */ new Set();
9381 const setups = /* @__PURE__ */ new Set();
9382 const listeners = /* @__PURE__ */ new Set();
9383 const batchListeners = /* @__PURE__ */ new Set();
9384 const disposables = /* @__PURE__ */ new WeakMap();
9385 const listenerKeys = /* @__PURE__ */ new WeakMap();
9386 const storeSetup = (callback) => {
9387 setups.add(callback);
9388 return () => setups.delete(callback);
9389 };
9390 const storeInit = () => {
9391 const initialized = instances.size;
9392 const instance = /* @__PURE__ */ Symbol();
9393 instances.add(instance);
9394 const maybeDestroy = () => {
9395 instances.delete(instance);
9396 if (instances.size) return;
9397 destroy();
9398 };
9399 if (initialized) return maybeDestroy;
9400 const desyncs = getKeys(state).map(
9401 (key) => chain(
9402 ...stores.map((store2) => {
9403 var _a;
9404 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
9405 if (!storeState) return;
9406 if (!hasOwnProperty(storeState, key)) return;
9407 return sync(store2, [key], (state2) => {
9408 setState(
9409 key,
9410 state2[key],
9411 // @ts-expect-error - Not public API. This is just to prevent
9412 // infinite loops.
9413 true
9414 );
9415 });
9416 })
9417 )
9418 );
9419 const teardowns = [];
9420 for (const setup2 of setups) {
9421 teardowns.push(setup2());
9422 }
9423 const cleanups = stores.map(init);
9424 destroy = chain(...desyncs, ...teardowns, ...cleanups);
9425 return maybeDestroy;
9426 };
9427 const sub = (keys, listener, set3 = listeners) => {
9428 set3.add(listener);
9429 listenerKeys.set(listener, keys);
9430 return () => {
9431 var _a;
9432 (_a = disposables.get(listener)) == null ? void 0 : _a();
9433 disposables.delete(listener);
9434 listenerKeys.delete(listener);
9435 set3.delete(listener);
9436 };
9437 };
9438 const storeSubscribe = (keys, listener) => sub(keys, listener);
9439 const storeSync = (keys, listener) => {
9440 disposables.set(listener, listener(state, state));
9441 return sub(keys, listener);
9442 };
9443 const storeBatch = (keys, listener) => {
9444 disposables.set(listener, listener(state, prevStateBatch));
9445 return sub(keys, listener, batchListeners);
9446 };
9447 const storePick = (keys) => createStore(pick(state, keys), finalStore);
9448 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
9449 const getState = () => state;
9450 const setState = (key, value, fromStores = false) => {
9451 var _a;
9452 if (!hasOwnProperty(state, key)) return;
9453 const nextValue = applyState(value, state[key]);
9454 if (nextValue === state[key]) return;
9455 if (!fromStores) {
9456 for (const store2 of stores) {
9457 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue);
9458 }
9459 }
9460 const prevState = state;
9461 state = { ...state, [key]: nextValue };
9462 const thisUpdate = /* @__PURE__ */ Symbol();
9463 lastUpdate = thisUpdate;
9464 updatedKeys.add(key);
9465 const run = (listener, prev, uKeys) => {
9466 var _a2;
9467 const keys = listenerKeys.get(listener);
9468 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
9469 if (!keys || keys.some(updated)) {
9470 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
9471 disposables.set(listener, listener(state, prev));
9472 }
9473 };
9474 for (const listener of listeners) {
9475 run(listener, prevState);
9476 }
9477 queueMicrotask(() => {
9478 if (lastUpdate !== thisUpdate) return;
9479 const snapshot = state;
9480 for (const listener of batchListeners) {
9481 run(listener, prevStateBatch, updatedKeys);
9482 }
9483 prevStateBatch = snapshot;
9484 updatedKeys.clear();
9485 });
9486 };
9487 const finalStore = {
9488 getState,
9489 setState,
9490 __unstableInternals: {
9491 setup: storeSetup,
9492 init: storeInit,
9493 subscribe: storeSubscribe,
9494 sync: storeSync,
9495 batch: storeBatch,
9496 pick: storePick,
9497 omit: storeOmit
9498 }
9499 };
9500 return finalStore;
9501 }
9502 function setup(store2, ...args) {
9503 if (!store2) return;
9504 return getInternal(store2, "setup")(...args);
9505 }
9506 function init(store2, ...args) {
9507 if (!store2) return;
9508 return getInternal(store2, "init")(...args);
9509 }
9510 function subscribe(store2, ...args) {
9511 if (!store2) return;
9512 return getInternal(store2, "subscribe")(...args);
9513 }
9514 function sync(store2, ...args) {
9515 if (!store2) return;
9516 return getInternal(store2, "sync")(...args);
9517 }
9518 function batch(store2, ...args) {
9519 if (!store2) return;
9520 return getInternal(store2, "batch")(...args);
9521 }
9522 function omit2(store2, ...args) {
9523 if (!store2) return;
9524 return getInternal(store2, "omit")(...args);
9525 }
9526 function pick2(store2, ...args) {
9527 if (!store2) return;
9528 return getInternal(store2, "pick")(...args);
9529 }
9530 function mergeStore(...stores) {
9531 var _a;
9532 const initialState = {};
9533 for (const store22 of stores) {
9534 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22);
9535 if (nextState) {
9536 Object.assign(initialState, nextState);
9537 }
9538 }
9539 const store2 = createStore(initialState, ...stores);
9540 return Object.assign({}, ...stores, store2);
9541 }
9542 function throwOnConflictingProps(props, store2) {
9543 if (false) return;
9544 if (!store2) return;
9545 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
9546 var _a;
9547 const stateKey = key.replace("default", "");
9548 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
9549 });
9550 if (!defaultKeys.length) return;
9551 const storeState = store2.getState();
9552 const conflictingProps = defaultKeys.filter(
9553 (key) => hasOwnProperty(storeState, key)
9554 );
9555 if (!conflictingProps.length) return;
9556 throw new Error(
9557 `Passing a store prop in conjunction with a default state is not supported.
9558
9559 const store = useSelectStore();
9560 <SelectProvider store={store} defaultValue="Apple" />
9561 ^ ^
9562
9563 Instead, pass the default state to the topmost store:
9564
9565 const store = useSelectStore({ defaultValue: "Apple" });
9566 <SelectProvider store={store} />
9567
9568 See https://github.com/ariakit/ariakit/pull/2745 for more details.
9569
9570 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
9571 `
9572 );
9573 }
9574
9575 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
9576 var React25 = __toESM(require_react(), 1);
9577 var import_shim = __toESM(require_shim(), 1);
9578 var { useSyncExternalStore } = import_shim.default;
9579 var noopSubscribe = () => () => {
9580 };
9581 function useStoreState(store2, keyOrSelector = identity) {
9582 const storeSubscribe = React25.useCallback(
9583 (callback) => {
9584 if (!store2) return noopSubscribe();
9585 return subscribe(store2, null, callback);
9586 },
9587 [store2]
9588 );
9589 const getSnapshot = () => {
9590 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
9591 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
9592 const state = store2 == null ? void 0 : store2.getState();
9593 if (selector2) return selector2(state);
9594 if (!state) return;
9595 if (!key) return;
9596 if (!hasOwnProperty(state, key)) return;
9597 return state[key];
9598 };
9599 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
9600 }
9601 function useStoreStateObject(store2, object) {
9602 const objRef = React25.useRef(
9603 {}
9604 );
9605 const storeSubscribe = React25.useCallback(
9606 (callback) => {
9607 if (!store2) return noopSubscribe();
9608 return subscribe(store2, null, callback);
9609 },
9610 [store2]
9611 );
9612 const getSnapshot = () => {
9613 const state = store2 == null ? void 0 : store2.getState();
9614 let updated = false;
9615 const obj = objRef.current;
9616 for (const prop in object) {
9617 const keyOrSelector = object[prop];
9618 if (typeof keyOrSelector === "function") {
9619 const value = keyOrSelector(state);
9620 if (value !== obj[prop]) {
9621 obj[prop] = value;
9622 updated = true;
9623 }
9624 }
9625 if (typeof keyOrSelector === "string") {
9626 if (!state) continue;
9627 if (!hasOwnProperty(state, keyOrSelector)) continue;
9628 const value = state[keyOrSelector];
9629 if (value !== obj[prop]) {
9630 obj[prop] = value;
9631 updated = true;
9632 }
9633 }
9634 }
9635 if (updated) {
9636 objRef.current = { ...obj };
9637 }
9638 return objRef.current;
9639 };
9640 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
9641 }
9642 function useStoreProps(store2, props, key, setKey) {
9643 const value = hasOwnProperty(props, key) ? props[key] : void 0;
9644 const setValue = setKey ? props[setKey] : void 0;
9645 const propsRef = useLiveRef({ value, setValue });
9646 useSafeLayoutEffect(() => {
9647 return sync(store2, [key], (state, prev) => {
9648 const { value: value2, setValue: setValue2 } = propsRef.current;
9649 if (!setValue2) return;
9650 if (state[key] === prev[key]) return;
9651 if (state[key] === value2) return;
9652 setValue2(state[key]);
9653 });
9654 }, [store2, key]);
9655 useSafeLayoutEffect(() => {
9656 if (value === void 0) return;
9657 store2.setState(key, value);
9658 return batch(store2, [key], () => {
9659 if (value === void 0) return;
9660 store2.setState(key, value);
9661 });
9662 });
9663 }
9664 function useStore(createStore2, props) {
9665 const [store2, setStore] = React25.useState(() => createStore2(props));
9666 useSafeLayoutEffect(() => init(store2), [store2]);
9667 const useState210 = React25.useCallback(
9668 (keyOrSelector) => useStoreState(store2, keyOrSelector),
9669 [store2]
9670 );
9671 const memoizedStore = React25.useMemo(
9672 () => ({ ...store2, useState: useState210 }),
9673 [store2, useState210]
9674 );
9675 const updateStore = useEvent(() => {
9676 setStore((store22) => createStore2({ ...props, ...store22.getState() }));
9677 });
9678 return [memoizedStore, updateStore];
9679 }
9680
9681 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
9682 var import_react17 = __toESM(require_react(), 1);
9683 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
9684 var TagName4 = "button";
9685 function isEditableElement(element) {
9686 if (isTextbox(element)) return true;
9687 return element.tagName === "INPUT" && !isButton(element);
9688 }
9689 function getNextPageOffset(scrollingElement, pageUp = false) {
9690 const height = scrollingElement.clientHeight;
9691 const { top } = scrollingElement.getBoundingClientRect();
9692 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
9693 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
9694 if (scrollingElement.tagName === "HTML") {
9695 return pageOffset + scrollingElement.scrollTop;
9696 }
9697 return pageOffset;
9698 }
9699 function getItemOffset(itemElement, pageUp = false) {
9700 const { top } = itemElement.getBoundingClientRect();
9701 if (pageUp) {
9702 return top + itemElement.clientHeight;
9703 }
9704 return top;
9705 }
9706 function findNextPageItemId(element, store2, next, pageUp = false) {
9707 var _a;
9708 if (!store2) return;
9709 if (!next) return;
9710 const { renderedItems } = store2.getState();
9711 const scrollingElement = getScrollingElement(element);
9712 if (!scrollingElement) return;
9713 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
9714 let id;
9715 let prevDifference;
9716 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
9717 const previousId = id;
9718 id = next(i2);
9719 if (!id) break;
9720 if (id === previousId) continue;
9721 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element;
9722 if (!itemElement) continue;
9723 const itemOffset = getItemOffset(itemElement, pageUp);
9724 const difference = itemOffset - nextPageOffset;
9725 const absDifference = Math.abs(difference);
9726 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
9727 if (prevDifference !== void 0 && prevDifference < absDifference) {
9728 id = previousId;
9729 }
9730 break;
9731 }
9732 prevDifference = absDifference;
9733 }
9734 return id;
9735 }
9736 function targetIsAnotherItem(event, store2) {
9737 if (isSelfTarget(event)) return false;
9738 return isItem(store2, event.target);
9739 }
9740 var useCompositeItem = createHook(
9741 function useCompositeItem2({
9742 store: store2,
9743 rowId: rowIdProp,
9744 preventScrollOnKeyDown = false,
9745 moveOnKeyPress = true,
9746 tabbable = false,
9747 getItem: getItemProp,
9748 "aria-setsize": ariaSetSizeProp,
9749 "aria-posinset": ariaPosInSetProp,
9750 ...props
9751 }) {
9752 const context = useCompositeContext();
9753 store2 = store2 || context;
9754 const id = useId5(props.id);
9755 const ref = (0, import_react17.useRef)(null);
9756 const row = (0, import_react17.useContext)(CompositeRowContext);
9757 const disabled2 = disabledFromProps(props);
9758 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
9759 const {
9760 rowId,
9761 baseElement,
9762 isActiveItem,
9763 ariaSetSize,
9764 ariaPosInSet,
9765 isTabbable
9766 } = useStoreStateObject(store2, {
9767 rowId(state) {
9768 if (rowIdProp) return rowIdProp;
9769 if (!state) return;
9770 if (!(row == null ? void 0 : row.baseElement)) return;
9771 if (row.baseElement !== state.baseElement) return;
9772 return row.id;
9773 },
9774 baseElement(state) {
9775 return (state == null ? void 0 : state.baseElement) || void 0;
9776 },
9777 isActiveItem(state) {
9778 return !!state && state.activeId === id;
9779 },
9780 ariaSetSize(state) {
9781 if (ariaSetSizeProp != null) return ariaSetSizeProp;
9782 if (!state) return;
9783 if (!(row == null ? void 0 : row.ariaSetSize)) return;
9784 if (row.baseElement !== state.baseElement) return;
9785 return row.ariaSetSize;
9786 },
9787 ariaPosInSet(state) {
9788 if (ariaPosInSetProp != null) return ariaPosInSetProp;
9789 if (!state) return;
9790 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
9791 if (row.baseElement !== state.baseElement) return;
9792 const itemsInRow = state.renderedItems.filter(
9793 (item) => item.rowId === rowId
9794 );
9795 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
9796 },
9797 isTabbable(state) {
9798 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
9799 if (state.virtualFocus) return false;
9800 if (tabbable) return true;
9801 if (state.activeId === null) return false;
9802 const item = store2 == null ? void 0 : store2.item(state.activeId);
9803 if (item == null ? void 0 : item.disabled) return true;
9804 if (!(item == null ? void 0 : item.element)) return true;
9805 return state.activeId === id;
9806 }
9807 });
9808 const getItem = (0, import_react17.useCallback)(
9809 (item) => {
9810 var _a;
9811 const nextItem = {
9812 ...item,
9813 id: id || item.id,
9814 rowId,
9815 disabled: !!trulyDisabled,
9816 children: (_a = item.element) == null ? void 0 : _a.textContent
9817 };
9818 if (getItemProp) {
9819 return getItemProp(nextItem);
9820 }
9821 return nextItem;
9822 },
9823 [id, rowId, trulyDisabled, getItemProp]
9824 );
9825 const onFocusProp = props.onFocus;
9826 const hasFocusedComposite = (0, import_react17.useRef)(false);
9827 const onFocus = useEvent((event) => {
9828 onFocusProp == null ? void 0 : onFocusProp(event);
9829 if (event.defaultPrevented) return;
9830 if (isPortalEvent(event)) return;
9831 if (!id) return;
9832 if (!store2) return;
9833 if (targetIsAnotherItem(event, store2)) return;
9834 const { virtualFocus, baseElement: baseElement2 } = store2.getState();
9835 store2.setActiveId(id);
9836 if (isTextbox(event.currentTarget)) {
9837 selectTextField(event.currentTarget);
9838 }
9839 if (!virtualFocus) return;
9840 if (!isSelfTarget(event)) return;
9841 if (isEditableElement(event.currentTarget)) return;
9842 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
9843 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
9844 event.currentTarget.scrollIntoView({
9845 block: "nearest",
9846 inline: "nearest"
9847 });
9848 }
9849 hasFocusedComposite.current = true;
9850 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget);
9851 if (fromComposite) {
9852 focusSilently(baseElement2);
9853 } else {
9854 baseElement2.focus();
9855 }
9856 });
9857 const onBlurCaptureProp = props.onBlurCapture;
9858 const onBlurCapture = useEvent((event) => {
9859 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
9860 if (event.defaultPrevented) return;
9861 const state = store2 == null ? void 0 : store2.getState();
9862 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
9863 hasFocusedComposite.current = false;
9864 event.preventDefault();
9865 event.stopPropagation();
9866 }
9867 });
9868 const onKeyDownProp = props.onKeyDown;
9869 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
9870 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
9871 const onKeyDown = useEvent((event) => {
9872 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
9873 if (event.defaultPrevented) return;
9874 if (!isSelfTarget(event)) return;
9875 if (!store2) return;
9876 const { currentTarget } = event;
9877 const state = store2.getState();
9878 const item = store2.item(id);
9879 const isGrid2 = !!(item == null ? void 0 : item.rowId);
9880 const isVertical = state.orientation !== "horizontal";
9881 const isHorizontal = state.orientation !== "vertical";
9882 const canHomeEnd = () => {
9883 if (isGrid2) return true;
9884 if (isHorizontal) return true;
9885 if (!state.baseElement) return true;
9886 if (!isTextField(state.baseElement)) return true;
9887 return false;
9888 };
9889 const keyMap = {
9890 ArrowUp: (isGrid2 || isVertical) && store2.up,
9891 ArrowRight: (isGrid2 || isHorizontal) && store2.next,
9892 ArrowDown: (isGrid2 || isVertical) && store2.down,
9893 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous,
9894 Home: () => {
9895 if (!canHomeEnd()) return;
9896 if (!isGrid2 || event.ctrlKey) {
9897 return store2 == null ? void 0 : store2.first();
9898 }
9899 return store2 == null ? void 0 : store2.previous(-1);
9900 },
9901 End: () => {
9902 if (!canHomeEnd()) return;
9903 if (!isGrid2 || event.ctrlKey) {
9904 return store2 == null ? void 0 : store2.last();
9905 }
9906 return store2 == null ? void 0 : store2.next(-1);
9907 },
9908 PageUp: () => {
9909 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true);
9910 },
9911 PageDown: () => {
9912 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down);
9913 }
9914 };
9915 const action = keyMap[event.key];
9916 if (action) {
9917 if (isTextbox(currentTarget)) {
9918 const selection = getTextboxSelection(currentTarget);
9919 const isLeft = isHorizontal && event.key === "ArrowLeft";
9920 const isRight = isHorizontal && event.key === "ArrowRight";
9921 const isUp = isVertical && event.key === "ArrowUp";
9922 const isDown = isVertical && event.key === "ArrowDown";
9923 if (isRight || isDown) {
9924 const { length: valueLength } = getTextboxValue(currentTarget);
9925 if (selection.end !== valueLength) return;
9926 } else if ((isLeft || isUp) && selection.start !== 0) return;
9927 }
9928 const nextId = action();
9929 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
9930 if (!moveOnKeyPressProp(event)) return;
9931 event.preventDefault();
9932 store2.move(nextId);
9933 }
9934 }
9935 });
9936 const providerValue = (0, import_react17.useMemo)(
9937 () => ({ id, baseElement }),
9938 [id, baseElement]
9939 );
9940 props = useWrapElement(
9941 props,
9942 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
9943 [providerValue]
9944 );
9945 props = {
9946 id,
9947 "data-active-item": isActiveItem || void 0,
9948 ...props,
9949 ref: useMergeRefs(ref, props.ref),
9950 tabIndex: isTabbable ? props.tabIndex : -1,
9951 onFocus,
9952 onBlurCapture,
9953 onKeyDown
9954 };
9955 props = useCommand(props);
9956 props = useCollectionItem({
9957 store: store2,
9958 ...props,
9959 getItem,
9960 shouldRegisterItem: id ? props.shouldRegisterItem : false
9961 });
9962 return removeUndefinedValues({
9963 ...props,
9964 "aria-setsize": ariaSetSize,
9965 "aria-posinset": ariaPosInSet
9966 });
9967 }
9968 );
9969 var CompositeItem = memo22(
9970 forwardRef26(function CompositeItem2(props) {
9971 const htmlProps = useCompositeItem(props);
9972 return createElement3(TagName4, htmlProps);
9973 })
9974 );
9975
9976 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
9977 function toArray(arg) {
9978 if (Array.isArray(arg)) {
9979 return arg;
9980 }
9981 return typeof arg !== "undefined" ? [arg] : [];
9982 }
9983 function flatten2DArray(array) {
9984 const flattened = [];
9985 for (const row of array) {
9986 flattened.push(...row);
9987 }
9988 return flattened;
9989 }
9990 function reverseArray(array) {
9991 return array.slice().reverse();
9992 }
9993
9994 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
9995 var import_react18 = __toESM(require_react(), 1);
9996 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
9997 var TagName5 = "div";
9998 function isGrid(items) {
9999 return items.some((item) => !!item.rowId);
10000 }
10001 function isPrintableKey(event) {
10002 const target = event.target;
10003 if (target && !isTextField(target)) return false;
10004 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
10005 }
10006 function isModifierKey(event) {
10007 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
10008 }
10009 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) {
10010 return useEvent((event) => {
10011 var _a;
10012 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
10013 if (event.defaultPrevented) return;
10014 if (event.isPropagationStopped()) return;
10015 if (!isSelfTarget(event)) return;
10016 if (isModifierKey(event)) return;
10017 if (isPrintableKey(event)) return;
10018 const state = store2.getState();
10019 const activeElement = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element;
10020 if (!activeElement) return;
10021 const { view, ...eventInit } = event;
10022 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
10023 if (activeElement !== previousElement) {
10024 activeElement.focus();
10025 }
10026 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
10027 event.preventDefault();
10028 }
10029 if (event.currentTarget.contains(activeElement)) {
10030 event.stopPropagation();
10031 }
10032 });
10033 }
10034 function findFirstEnabledItemInTheLastRow(items) {
10035 return findFirstEnabledItem(
10036 flatten2DArray(reverseArray(groupItemsByRows(items)))
10037 );
10038 }
10039 function useScheduleFocus(store2) {
10040 const [scheduled, setScheduled] = (0, import_react18.useState)(false);
10041 const schedule = (0, import_react18.useCallback)(() => setScheduled(true), []);
10042 const activeItem = store2.useState(
10043 (state) => getEnabledItem(store2, state.activeId)
10044 );
10045 (0, import_react18.useEffect)(() => {
10046 const activeElement = activeItem == null ? void 0 : activeItem.element;
10047 if (!scheduled) return;
10048 if (!activeElement) return;
10049 setScheduled(false);
10050 activeElement.focus({ preventScroll: true });
10051 }, [activeItem, scheduled]);
10052 return schedule;
10053 }
10054 var useComposite = createHook(
10055 function useComposite2({
10056 store: store2,
10057 composite = true,
10058 focusOnMove = composite,
10059 moveOnKeyPress = true,
10060 ...props
10061 }) {
10062 const context = useCompositeProviderContext();
10063 store2 = store2 || context;
10064 invariant(
10065 store2,
10066 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
10067 );
10068 const ref = (0, import_react18.useRef)(null);
10069 const previousElementRef = (0, import_react18.useRef)(null);
10070 const scheduleFocus = useScheduleFocus(store2);
10071 const moves = store2.useState("moves");
10072 const [, setBaseElement] = useTransactionState(
10073 composite ? store2.setBaseElement : null
10074 );
10075 (0, import_react18.useEffect)(() => {
10076 var _a;
10077 if (!store2) return;
10078 if (!moves) return;
10079 if (!composite) return;
10080 if (!focusOnMove) return;
10081 const { activeId: activeId2 } = store2.getState();
10082 const itemElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
10083 if (!itemElement) return;
10084 focusIntoView(itemElement);
10085 }, [store2, moves, composite, focusOnMove]);
10086 useSafeLayoutEffect(() => {
10087 if (!store2) return;
10088 if (!moves) return;
10089 if (!composite) return;
10090 const { baseElement, activeId: activeId2 } = store2.getState();
10091 const isSelfAcive = activeId2 === null;
10092 if (!isSelfAcive) return;
10093 if (!baseElement) return;
10094 const previousElement = previousElementRef.current;
10095 previousElementRef.current = null;
10096 if (previousElement) {
10097 fireBlurEvent(previousElement, { relatedTarget: baseElement });
10098 }
10099 if (!hasFocus(baseElement)) {
10100 baseElement.focus();
10101 }
10102 }, [store2, moves, composite]);
10103 const activeId = store2.useState("activeId");
10104 const virtualFocus = store2.useState("virtualFocus");
10105 useSafeLayoutEffect(() => {
10106 var _a;
10107 if (!store2) return;
10108 if (!composite) return;
10109 if (!virtualFocus) return;
10110 const previousElement = previousElementRef.current;
10111 previousElementRef.current = null;
10112 if (!previousElement) return;
10113 const activeElement = (_a = getEnabledItem(store2, activeId)) == null ? void 0 : _a.element;
10114 const relatedTarget = activeElement || getActiveElement(previousElement);
10115 if (relatedTarget === previousElement) return;
10116 fireBlurEvent(previousElement, { relatedTarget });
10117 }, [store2, activeId, virtualFocus, composite]);
10118 const onKeyDownCapture = useKeyboardEventProxy(
10119 store2,
10120 props.onKeyDownCapture,
10121 previousElementRef
10122 );
10123 const onKeyUpCapture = useKeyboardEventProxy(
10124 store2,
10125 props.onKeyUpCapture,
10126 previousElementRef
10127 );
10128 const onFocusCaptureProp = props.onFocusCapture;
10129 const onFocusCapture = useEvent((event) => {
10130 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
10131 if (event.defaultPrevented) return;
10132 if (!store2) return;
10133 const { virtualFocus: virtualFocus2 } = store2.getState();
10134 if (!virtualFocus2) return;
10135 const previousActiveElement = event.relatedTarget;
10136 const isSilentlyFocused = silentlyFocused(event.currentTarget);
10137 if (isSelfTarget(event) && isSilentlyFocused) {
10138 event.stopPropagation();
10139 previousElementRef.current = previousActiveElement;
10140 }
10141 });
10142 const onFocusProp = props.onFocus;
10143 const onFocus = useEvent((event) => {
10144 onFocusProp == null ? void 0 : onFocusProp(event);
10145 if (event.defaultPrevented) return;
10146 if (!composite) return;
10147 if (!store2) return;
10148 const { relatedTarget } = event;
10149 const { virtualFocus: virtualFocus2 } = store2.getState();
10150 if (virtualFocus2) {
10151 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) {
10152 queueMicrotask(scheduleFocus);
10153 }
10154 } else if (isSelfTarget(event)) {
10155 store2.setActiveId(null);
10156 }
10157 });
10158 const onBlurCaptureProp = props.onBlurCapture;
10159 const onBlurCapture = useEvent((event) => {
10160 var _a;
10161 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
10162 if (event.defaultPrevented) return;
10163 if (!store2) return;
10164 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState();
10165 if (!virtualFocus2) return;
10166 const activeElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
10167 const nextActiveElement = event.relatedTarget;
10168 const nextActiveElementIsItem = isItem(store2, nextActiveElement);
10169 const previousElement = previousElementRef.current;
10170 previousElementRef.current = null;
10171 if (isSelfTarget(event) && nextActiveElementIsItem) {
10172 if (nextActiveElement === activeElement) {
10173 if (previousElement && previousElement !== nextActiveElement) {
10174 fireBlurEvent(previousElement, event);
10175 }
10176 } else if (activeElement) {
10177 fireBlurEvent(activeElement, event);
10178 } else if (previousElement) {
10179 fireBlurEvent(previousElement, event);
10180 }
10181 event.stopPropagation();
10182 } else {
10183 const targetIsItem = isItem(store2, event.target);
10184 if (!targetIsItem && activeElement) {
10185 fireBlurEvent(activeElement, event);
10186 }
10187 }
10188 });
10189 const onKeyDownProp = props.onKeyDown;
10190 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
10191 const onKeyDown = useEvent((event) => {
10192 var _a;
10193 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
10194 if (event.nativeEvent.isComposing) return;
10195 if (event.defaultPrevented) return;
10196 if (!store2) return;
10197 if (!isSelfTarget(event)) return;
10198 const { orientation, renderedItems, activeId: activeId2 } = store2.getState();
10199 const activeItem = getEnabledItem(store2, activeId2);
10200 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
10201 const isVertical = orientation !== "horizontal";
10202 const isHorizontal = orientation !== "vertical";
10203 const grid = isGrid(renderedItems);
10204 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
10205 if (isHorizontalKey && isTextField(event.currentTarget)) return;
10206 const up = () => {
10207 if (grid) {
10208 const item = findFirstEnabledItemInTheLastRow(renderedItems);
10209 return item == null ? void 0 : item.id;
10210 }
10211 return store2 == null ? void 0 : store2.last();
10212 };
10213 const keyMap = {
10214 ArrowUp: (grid || isVertical) && up,
10215 ArrowRight: (grid || isHorizontal) && store2.first,
10216 ArrowDown: (grid || isVertical) && store2.first,
10217 ArrowLeft: (grid || isHorizontal) && store2.last,
10218 Home: store2.first,
10219 End: store2.last,
10220 PageUp: store2.first,
10221 PageDown: store2.last
10222 };
10223 const action = keyMap[event.key];
10224 if (action) {
10225 const id = action();
10226 if (id !== void 0) {
10227 if (!moveOnKeyPressProp(event)) return;
10228 event.preventDefault();
10229 store2.move(id);
10230 }
10231 }
10232 });
10233 props = useWrapElement(
10234 props,
10235 (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CompositeContextProvider, { value: store2, children: element }),
10236 [store2]
10237 );
10238 const activeDescendant = store2.useState((state) => {
10239 var _a;
10240 if (!store2) return;
10241 if (!composite) return;
10242 if (!state.virtualFocus) return;
10243 return (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.id;
10244 });
10245 props = {
10246 "aria-activedescendant": activeDescendant,
10247 ...props,
10248 ref: useMergeRefs(ref, setBaseElement, props.ref),
10249 onKeyDownCapture,
10250 onKeyUpCapture,
10251 onFocusCapture,
10252 onFocus,
10253 onBlurCapture,
10254 onKeyDown
10255 };
10256 const focusable = store2.useState(
10257 (state) => composite && (state.virtualFocus || state.activeId === null)
10258 );
10259 props = useFocusable({ focusable, ...props });
10260 return props;
10261 }
10262 );
10263 var Composite5 = forwardRef26(function Composite22(props) {
10264 const htmlProps = useComposite(props);
10265 return createElement3(TagName5, htmlProps);
10266 });
10267
10268 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
10269 var ctx3 = createStoreContext();
10270 var useDisclosureContext = ctx3.useContext;
10271 var useDisclosureScopedContext = ctx3.useScopedContext;
10272 var useDisclosureProviderContext = ctx3.useProviderContext;
10273 var DisclosureContextProvider = ctx3.ContextProvider;
10274 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
10275
10276 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
10277 var import_react19 = __toESM(require_react(), 1);
10278 var ctx4 = createStoreContext(
10279 [DisclosureContextProvider],
10280 [DisclosureScopedContextProvider]
10281 );
10282 var useDialogContext = ctx4.useContext;
10283 var useDialogScopedContext = ctx4.useScopedContext;
10284 var useDialogProviderContext = ctx4.useProviderContext;
10285 var DialogContextProvider = ctx4.ContextProvider;
10286 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
10287 var DialogHeadingContext = (0, import_react19.createContext)(void 0);
10288 var DialogDescriptionContext = (0, import_react19.createContext)(void 0);
10289
10290 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
10291 var import_react20 = __toESM(require_react(), 1);
10292 var import_react_dom = __toESM(require_react_dom(), 1);
10293 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
10294 var TagName6 = "div";
10295 function afterTimeout(timeoutMs, cb) {
10296 const timeoutId = setTimeout(cb, timeoutMs);
10297 return () => clearTimeout(timeoutId);
10298 }
10299 function afterPaint2(cb) {
10300 let raf = requestAnimationFrame(() => {
10301 raf = requestAnimationFrame(cb);
10302 });
10303 return () => cancelAnimationFrame(raf);
10304 }
10305 function parseCSSTime(...times) {
10306 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
10307 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
10308 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
10309 if (currentTime > longestTime) return currentTime;
10310 return longestTime;
10311 }, 0);
10312 }
10313 function isHidden(mounted, hidden, alwaysVisible) {
10314 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
10315 }
10316 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, ...props }) {
10317 const context = useDisclosureProviderContext();
10318 store2 = store2 || context;
10319 invariant(
10320 store2,
10321 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
10322 );
10323 const ref = (0, import_react20.useRef)(null);
10324 const id = useId5(props.id);
10325 const [transition, setTransition] = (0, import_react20.useState)(null);
10326 const open = store2.useState("open");
10327 const mounted = store2.useState("mounted");
10328 const animated = store2.useState("animated");
10329 const contentElement = store2.useState("contentElement");
10330 const otherElement = useStoreState(store2.disclosure, "contentElement");
10331 useSafeLayoutEffect(() => {
10332 if (!ref.current) return;
10333 store2 == null ? void 0 : store2.setContentElement(ref.current);
10334 }, [store2]);
10335 useSafeLayoutEffect(() => {
10336 let previousAnimated;
10337 store2 == null ? void 0 : store2.setState("animated", (animated2) => {
10338 previousAnimated = animated2;
10339 return true;
10340 });
10341 return () => {
10342 if (previousAnimated === void 0) return;
10343 store2 == null ? void 0 : store2.setState("animated", previousAnimated);
10344 };
10345 }, [store2]);
10346 useSafeLayoutEffect(() => {
10347 if (!animated) return;
10348 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
10349 setTransition(null);
10350 return;
10351 }
10352 return afterPaint2(() => {
10353 setTransition(open ? "enter" : mounted ? "leave" : null);
10354 });
10355 }, [animated, contentElement, open, mounted]);
10356 useSafeLayoutEffect(() => {
10357 if (!store2) return;
10358 if (!animated) return;
10359 if (!transition) return;
10360 if (!contentElement) return;
10361 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false);
10362 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
10363 if (transition === "leave" && open) return;
10364 if (transition === "enter" && !open) return;
10365 if (typeof animated === "number") {
10366 const timeout2 = animated;
10367 return afterTimeout(timeout2, stopAnimationSync);
10368 }
10369 const {
10370 transitionDuration,
10371 animationDuration,
10372 transitionDelay,
10373 animationDelay
10374 } = getComputedStyle(contentElement);
10375 const {
10376 transitionDuration: transitionDuration2 = "0",
10377 animationDuration: animationDuration2 = "0",
10378 transitionDelay: transitionDelay2 = "0",
10379 animationDelay: animationDelay2 = "0"
10380 } = otherElement ? getComputedStyle(otherElement) : {};
10381 const delay = parseCSSTime(
10382 transitionDelay,
10383 animationDelay,
10384 transitionDelay2,
10385 animationDelay2
10386 );
10387 const duration = parseCSSTime(
10388 transitionDuration,
10389 animationDuration,
10390 transitionDuration2,
10391 animationDuration2
10392 );
10393 const timeout = delay + duration;
10394 if (!timeout) {
10395 if (transition === "enter") {
10396 store2.setState("animated", false);
10397 }
10398 stopAnimation();
10399 return;
10400 }
10401 const frameRate = 1e3 / 60;
10402 const maxTimeout = Math.max(timeout - frameRate, 0);
10403 return afterTimeout(maxTimeout, stopAnimationSync);
10404 }, [store2, animated, contentElement, otherElement, open, transition]);
10405 props = useWrapElement(
10406 props,
10407 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DialogScopedContextProvider, { value: store2, children: element }),
10408 [store2]
10409 );
10410 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
10411 const styleProp = props.style;
10412 const style = (0, import_react20.useMemo)(() => {
10413 if (hidden) {
10414 return { ...styleProp, display: "none" };
10415 }
10416 return styleProp;
10417 }, [hidden, styleProp]);
10418 props = {
10419 id,
10420 "data-open": open || void 0,
10421 "data-enter": transition === "enter" || void 0,
10422 "data-leave": transition === "leave" || void 0,
10423 hidden,
10424 ...props,
10425 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref),
10426 style
10427 };
10428 return removeUndefinedValues(props);
10429 });
10430 var DisclosureContentImpl = forwardRef26(function DisclosureContentImpl2(props) {
10431 const htmlProps = useDisclosureContent(props);
10432 return createElement3(TagName6, htmlProps);
10433 });
10434 var DisclosureContent = forwardRef26(function DisclosureContent2({
10435 unmountOnHide,
10436 ...props
10437 }) {
10438 const context = useDisclosureProviderContext();
10439 const store2 = props.store || context;
10440 const mounted = useStoreState(
10441 store2,
10442 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
10443 );
10444 if (mounted === false) return null;
10445 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DisclosureContentImpl, { ...props });
10446 });
10447
10448 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
10449 function createDisclosureStore(props = {}) {
10450 const store2 = mergeStore(
10451 props.store,
10452 omit2(props.disclosure, ["contentElement", "disclosureElement"])
10453 );
10454 throwOnConflictingProps(props, store2);
10455 const syncState = store2 == null ? void 0 : store2.getState();
10456 const open = defaultValue(
10457 props.open,
10458 syncState == null ? void 0 : syncState.open,
10459 props.defaultOpen,
10460 false
10461 );
10462 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
10463 const initialState = {
10464 open,
10465 animated,
10466 animating: !!animated && open,
10467 mounted: open,
10468 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
10469 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
10470 };
10471 const disclosure = createStore(initialState, store2);
10472 setup(
10473 disclosure,
10474 () => sync(disclosure, ["animated", "animating"], (state) => {
10475 if (state.animated) return;
10476 disclosure.setState("animating", false);
10477 })
10478 );
10479 setup(
10480 disclosure,
10481 () => subscribe(disclosure, ["open"], () => {
10482 if (!disclosure.getState().animated) return;
10483 disclosure.setState("animating", true);
10484 })
10485 );
10486 setup(
10487 disclosure,
10488 () => sync(disclosure, ["open", "animating"], (state) => {
10489 disclosure.setState("mounted", state.open || state.animating);
10490 })
10491 );
10492 return {
10493 ...disclosure,
10494 disclosure: props.disclosure,
10495 setOpen: (value) => disclosure.setState("open", value),
10496 show: () => disclosure.setState("open", true),
10497 hide: () => disclosure.setState("open", false),
10498 toggle: () => disclosure.setState("open", (open2) => !open2),
10499 stopAnimation: () => disclosure.setState("animating", false),
10500 setContentElement: (value) => disclosure.setState("contentElement", value),
10501 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
10502 };
10503 }
10504
10505 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
10506 function useDisclosureStoreProps(store2, update2, props) {
10507 useUpdateEffect(update2, [props.store, props.disclosure]);
10508 useStoreProps(store2, props, "open", "setOpen");
10509 useStoreProps(store2, props, "mounted", "setMounted");
10510 useStoreProps(store2, props, "animated");
10511 return Object.assign(store2, { disclosure: props.disclosure });
10512 }
10513
10514 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
10515 var ctx5 = createStoreContext(
10516 [DialogContextProvider],
10517 [DialogScopedContextProvider]
10518 );
10519 var usePopoverContext = ctx5.useContext;
10520 var usePopoverScopedContext = ctx5.useScopedContext;
10521 var usePopoverProviderContext = ctx5.useProviderContext;
10522 var PopoverContextProvider = ctx5.ContextProvider;
10523 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
10524
10525 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
10526 function getCommonParent(items) {
10527 var _a;
10528 const firstItem = items.find((item) => !!item.element);
10529 const lastItem = [...items].reverse().find((item) => !!item.element);
10530 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
10531 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
10532 const parent = parentElement;
10533 if (lastItem && parent.contains(lastItem.element)) {
10534 return parentElement;
10535 }
10536 parentElement = parentElement.parentElement;
10537 }
10538 return getDocument(parentElement).body;
10539 }
10540 function getPrivateStore(store2) {
10541 return store2 == null ? void 0 : store2.__unstablePrivateStore;
10542 }
10543 function createCollectionStore(props = {}) {
10544 var _a;
10545 throwOnConflictingProps(props, props.store);
10546 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
10547 const items = defaultValue(
10548 props.items,
10549 syncState == null ? void 0 : syncState.items,
10550 props.defaultItems,
10551 []
10552 );
10553 const itemsMap = new Map(items.map((item) => [item.id, item]));
10554 const initialState = {
10555 items,
10556 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
10557 };
10558 const syncPrivateStore = getPrivateStore(props.store);
10559 const privateStore = createStore(
10560 { items, renderedItems: initialState.renderedItems },
10561 syncPrivateStore
10562 );
10563 const collection = createStore(initialState, props.store);
10564 const sortItems = (renderedItems) => {
10565 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
10566 privateStore.setState("renderedItems", sortedItems);
10567 collection.setState("renderedItems", sortedItems);
10568 };
10569 setup(collection, () => init(privateStore));
10570 setup(privateStore, () => {
10571 return batch(privateStore, ["items"], (state) => {
10572 collection.setState("items", state.items);
10573 });
10574 });
10575 setup(privateStore, () => {
10576 return batch(privateStore, ["renderedItems"], (state) => {
10577 let firstRun = true;
10578 let raf = requestAnimationFrame(() => {
10579 const { renderedItems } = collection.getState();
10580 if (state.renderedItems === renderedItems) return;
10581 sortItems(state.renderedItems);
10582 });
10583 if (typeof IntersectionObserver !== "function") {
10584 return () => cancelAnimationFrame(raf);
10585 }
10586 const ioCallback = () => {
10587 if (firstRun) {
10588 firstRun = false;
10589 return;
10590 }
10591 cancelAnimationFrame(raf);
10592 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
10593 };
10594 const root = getCommonParent(state.renderedItems);
10595 const observer = new IntersectionObserver(ioCallback, { root });
10596 for (const item of state.renderedItems) {
10597 if (!item.element) continue;
10598 observer.observe(item.element);
10599 }
10600 return () => {
10601 cancelAnimationFrame(raf);
10602 observer.disconnect();
10603 };
10604 });
10605 });
10606 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
10607 let prevItem;
10608 setItems((items2) => {
10609 const index = items2.findIndex(({ id }) => id === item.id);
10610 const nextItems = items2.slice();
10611 if (index !== -1) {
10612 prevItem = items2[index];
10613 const nextItem = { ...prevItem, ...item };
10614 nextItems[index] = nextItem;
10615 itemsMap.set(item.id, nextItem);
10616 } else {
10617 nextItems.push(item);
10618 itemsMap.set(item.id, item);
10619 }
10620 return nextItems;
10621 });
10622 const unmergeItem = () => {
10623 setItems((items2) => {
10624 if (!prevItem) {
10625 if (canDeleteFromMap) {
10626 itemsMap.delete(item.id);
10627 }
10628 return items2.filter(({ id }) => id !== item.id);
10629 }
10630 const index = items2.findIndex(({ id }) => id === item.id);
10631 if (index === -1) return items2;
10632 const nextItems = items2.slice();
10633 nextItems[index] = prevItem;
10634 itemsMap.set(item.id, prevItem);
10635 return nextItems;
10636 });
10637 };
10638 return unmergeItem;
10639 };
10640 const registerItem = (item) => mergeItem(
10641 item,
10642 (getItems) => privateStore.setState("items", getItems),
10643 true
10644 );
10645 return {
10646 ...collection,
10647 registerItem,
10648 renderItem: (item) => chain(
10649 registerItem(item),
10650 mergeItem(
10651 item,
10652 (getItems) => privateStore.setState("renderedItems", getItems)
10653 )
10654 ),
10655 item: (id) => {
10656 if (!id) return null;
10657 let item = itemsMap.get(id);
10658 if (!item) {
10659 const { items: items2 } = privateStore.getState();
10660 item = items2.find((item2) => item2.id === id);
10661 if (item) {
10662 itemsMap.set(id, item);
10663 }
10664 }
10665 return item || null;
10666 },
10667 // @ts-expect-error Internal
10668 __unstablePrivateStore: privateStore
10669 };
10670 }
10671
10672 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
10673 function useCollectionStoreProps(store2, update2, props) {
10674 useUpdateEffect(update2, [props.store]);
10675 useStoreProps(store2, props, "items", "setItems");
10676 return store2;
10677 }
10678
10679 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
10680 var NULL_ITEM = { id: null };
10681 function findFirstEnabledItem2(items, excludeId) {
10682 return items.find((item) => {
10683 if (excludeId) {
10684 return !item.disabled && item.id !== excludeId;
10685 }
10686 return !item.disabled;
10687 });
10688 }
10689 function getEnabledItems(items, excludeId) {
10690 return items.filter((item) => {
10691 if (excludeId) {
10692 return !item.disabled && item.id !== excludeId;
10693 }
10694 return !item.disabled;
10695 });
10696 }
10697 function getItemsInRow(items, rowId) {
10698 return items.filter((item) => item.rowId === rowId);
10699 }
10700 function flipItems(items, activeId, shouldInsertNullItem = false) {
10701 const index = items.findIndex((item) => item.id === activeId);
10702 return [
10703 ...items.slice(index + 1),
10704 ...shouldInsertNullItem ? [NULL_ITEM] : [],
10705 ...items.slice(0, index)
10706 ];
10707 }
10708 function groupItemsByRows2(items) {
10709 const rows = [];
10710 for (const item of items) {
10711 const row = rows.find((currentRow) => {
10712 var _a;
10713 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
10714 });
10715 if (row) {
10716 row.push(item);
10717 } else {
10718 rows.push([item]);
10719 }
10720 }
10721 return rows;
10722 }
10723 function getMaxRowLength(array) {
10724 let maxLength = 0;
10725 for (const { length } of array) {
10726 if (length > maxLength) {
10727 maxLength = length;
10728 }
10729 }
10730 return maxLength;
10731 }
10732 function createEmptyItem(rowId) {
10733 return {
10734 id: "__EMPTY_ITEM__",
10735 disabled: true,
10736 rowId
10737 };
10738 }
10739 function normalizeRows(rows, activeId, focusShift) {
10740 const maxLength = getMaxRowLength(rows);
10741 for (const row of rows) {
10742 for (let i2 = 0; i2 < maxLength; i2 += 1) {
10743 const item = row[i2];
10744 if (!item || focusShift && item.disabled) {
10745 const isFirst = i2 === 0;
10746 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
10747 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
10748 }
10749 }
10750 }
10751 return rows;
10752 }
10753 function verticalizeItems(items) {
10754 const rows = groupItemsByRows2(items);
10755 const maxLength = getMaxRowLength(rows);
10756 const verticalized = [];
10757 for (let i2 = 0; i2 < maxLength; i2 += 1) {
10758 for (const row of rows) {
10759 const item = row[i2];
10760 if (item) {
10761 verticalized.push({
10762 ...item,
10763 // If there's no rowId, it means that it's not a grid composite, but
10764 // a single row instead. So, instead of verticalizing it, that is,
10765 // assigning a different rowId based on the column index, we keep it
10766 // undefined so they will be part of the same row. This is useful
10767 // when using up/down on one-dimensional composites.
10768 rowId: item.rowId ? `${i2}` : void 0
10769 });
10770 }
10771 }
10772 }
10773 return verticalized;
10774 }
10775 function createCompositeStore(props = {}) {
10776 var _a;
10777 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
10778 const collection = createCollectionStore(props);
10779 const activeId = defaultValue(
10780 props.activeId,
10781 syncState == null ? void 0 : syncState.activeId,
10782 props.defaultActiveId
10783 );
10784 const initialState = {
10785 ...collection.getState(),
10786 id: defaultValue(
10787 props.id,
10788 syncState == null ? void 0 : syncState.id,
10789 `id-${Math.random().toString(36).slice(2, 8)}`
10790 ),
10791 activeId,
10792 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
10793 includesBaseElement: defaultValue(
10794 props.includesBaseElement,
10795 syncState == null ? void 0 : syncState.includesBaseElement,
10796 activeId === null
10797 ),
10798 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
10799 orientation: defaultValue(
10800 props.orientation,
10801 syncState == null ? void 0 : syncState.orientation,
10802 "both"
10803 ),
10804 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
10805 virtualFocus: defaultValue(
10806 props.virtualFocus,
10807 syncState == null ? void 0 : syncState.virtualFocus,
10808 false
10809 ),
10810 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
10811 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
10812 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
10813 };
10814 const composite = createStore(initialState, collection, props.store);
10815 setup(
10816 composite,
10817 () => sync(composite, ["renderedItems", "activeId"], (state) => {
10818 composite.setState("activeId", (activeId2) => {
10819 var _a2;
10820 if (activeId2 !== void 0) return activeId2;
10821 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
10822 });
10823 })
10824 );
10825 const getNextId = (direction = "next", options = {}) => {
10826 var _a2, _b;
10827 const defaultState = composite.getState();
10828 const {
10829 skip = 0,
10830 activeId: activeId2 = defaultState.activeId,
10831 focusShift = defaultState.focusShift,
10832 focusLoop = defaultState.focusLoop,
10833 focusWrap = defaultState.focusWrap,
10834 includesBaseElement = defaultState.includesBaseElement,
10835 renderedItems = defaultState.renderedItems,
10836 rtl = defaultState.rtl
10837 } = options;
10838 const isVerticalDirection = direction === "up" || direction === "down";
10839 const isNextDirection = direction === "next" || direction === "down";
10840 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
10841 const canShift = focusShift && !skip;
10842 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
10843 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
10844 );
10845 items = canReverse ? reverseArray(items) : items;
10846 items = isVerticalDirection ? verticalizeItems(items) : items;
10847 if (activeId2 == null) {
10848 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
10849 }
10850 const activeItem = items.find((item) => item.id === activeId2);
10851 if (!activeItem) {
10852 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
10853 }
10854 const isGrid2 = items.some((item) => item.rowId);
10855 const activeIndex = items.indexOf(activeItem);
10856 const nextItems = items.slice(activeIndex + 1);
10857 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
10858 if (skip) {
10859 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
10860 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
10861 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
10862 return nextItem2 == null ? void 0 : nextItem2.id;
10863 }
10864 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
10865 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
10866 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
10867 if (canLoop) {
10868 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
10869 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
10870 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
10871 return nextItem2 == null ? void 0 : nextItem2.id;
10872 }
10873 if (canWrap) {
10874 const nextItem2 = findFirstEnabledItem2(
10875 // We can use nextItems, which contains all the next items, including
10876 // items from other rows, to wrap between rows. However, if there is a
10877 // null item (the composite container), we'll only use the next items in
10878 // the row. So moving next from the last item will focus on the
10879 // composite container. On grid composites, horizontal navigation never
10880 // focuses on the composite container, only vertical.
10881 hasNullItem ? nextItemsInRow : nextItems,
10882 activeId2
10883 );
10884 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
10885 return nextId;
10886 }
10887 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
10888 if (!nextItem && hasNullItem) {
10889 return null;
10890 }
10891 return nextItem == null ? void 0 : nextItem.id;
10892 };
10893 return {
10894 ...collection,
10895 ...composite,
10896 setBaseElement: (element) => composite.setState("baseElement", element),
10897 setActiveId: (id) => composite.setState("activeId", id),
10898 move: (id) => {
10899 if (id === void 0) return;
10900 composite.setState("activeId", id);
10901 composite.setState("moves", (moves) => moves + 1);
10902 },
10903 first: () => {
10904 var _a2;
10905 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
10906 },
10907 last: () => {
10908 var _a2;
10909 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
10910 },
10911 next: (options) => {
10912 if (options !== void 0 && typeof options === "number") {
10913 options = { skip: options };
10914 }
10915 return getNextId("next", options);
10916 },
10917 previous: (options) => {
10918 if (options !== void 0 && typeof options === "number") {
10919 options = { skip: options };
10920 }
10921 return getNextId("previous", options);
10922 },
10923 down: (options) => {
10924 if (options !== void 0 && typeof options === "number") {
10925 options = { skip: options };
10926 }
10927 return getNextId("down", options);
10928 },
10929 up: (options) => {
10930 if (options !== void 0 && typeof options === "number") {
10931 options = { skip: options };
10932 }
10933 return getNextId("up", options);
10934 }
10935 };
10936 }
10937
10938 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
10939 function useCompositeStoreOptions(props) {
10940 const id = useId5(props.id);
10941 return { id, ...props };
10942 }
10943 function useCompositeStoreProps(store2, update2, props) {
10944 store2 = useCollectionStoreProps(store2, update2, props);
10945 useStoreProps(store2, props, "activeId", "setActiveId");
10946 useStoreProps(store2, props, "includesBaseElement");
10947 useStoreProps(store2, props, "virtualFocus");
10948 useStoreProps(store2, props, "orientation");
10949 useStoreProps(store2, props, "rtl");
10950 useStoreProps(store2, props, "focusLoop");
10951 useStoreProps(store2, props, "focusWrap");
10952 useStoreProps(store2, props, "focusShift");
10953 return store2;
10954 }
10955
10956 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
10957 var import_react21 = __toESM(require_react(), 1);
10958 var ComboboxListRoleContext = (0, import_react21.createContext)(
10959 void 0
10960 );
10961 var ctx6 = createStoreContext(
10962 [PopoverContextProvider, CompositeContextProvider],
10963 [PopoverScopedContextProvider, CompositeScopedContextProvider]
10964 );
10965 var useComboboxContext = ctx6.useContext;
10966 var useComboboxScopedContext = ctx6.useScopedContext;
10967 var useComboboxProviderContext = ctx6.useProviderContext;
10968 var ComboboxContextProvider = ctx6.ContextProvider;
10969 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
10970 var ComboboxItemValueContext = (0, import_react21.createContext)(
10971 void 0
10972 );
10973 var ComboboxItemCheckedContext = (0, import_react21.createContext)(false);
10974
10975 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
10976 function createDialogStore(props = {}) {
10977 return createDisclosureStore(props);
10978 }
10979
10980 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
10981 function useDialogStoreProps(store2, update2, props) {
10982 return useDisclosureStoreProps(store2, update2, props);
10983 }
10984
10985 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
10986 function createPopoverStore({
10987 popover: otherPopover,
10988 ...props
10989 } = {}) {
10990 const store2 = mergeStore(
10991 props.store,
10992 omit2(otherPopover, [
10993 "arrowElement",
10994 "anchorElement",
10995 "contentElement",
10996 "popoverElement",
10997 "disclosureElement"
10998 ])
10999 );
11000 throwOnConflictingProps(props, store2);
11001 const syncState = store2 == null ? void 0 : store2.getState();
11002 const dialog = createDialogStore({ ...props, store: store2 });
11003 const placement = defaultValue(
11004 props.placement,
11005 syncState == null ? void 0 : syncState.placement,
11006 "bottom"
11007 );
11008 const initialState = {
11009 ...dialog.getState(),
11010 placement,
11011 currentPlacement: placement,
11012 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
11013 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
11014 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
11015 rendered: /* @__PURE__ */ Symbol("rendered")
11016 };
11017 const popover = createStore(initialState, dialog, store2);
11018 return {
11019 ...dialog,
11020 ...popover,
11021 setAnchorElement: (element) => popover.setState("anchorElement", element),
11022 setPopoverElement: (element) => popover.setState("popoverElement", element),
11023 setArrowElement: (element) => popover.setState("arrowElement", element),
11024 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
11025 };
11026 }
11027
11028 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
11029 function usePopoverStoreProps(store2, update2, props) {
11030 useUpdateEffect(update2, [props.popover]);
11031 useStoreProps(store2, props, "placement");
11032 return useDialogStoreProps(store2, update2, props);
11033 }
11034
11035 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
11036 var TagName7 = "div";
11037 var usePopoverAnchor = createHook(
11038 function usePopoverAnchor2({ store: store2, ...props }) {
11039 const context = usePopoverProviderContext();
11040 store2 = store2 || context;
11041 props = {
11042 ...props,
11043 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref)
11044 };
11045 return props;
11046 }
11047 );
11048 var PopoverAnchor = forwardRef26(function PopoverAnchor2(props) {
11049 const htmlProps = usePopoverAnchor(props);
11050 return createElement3(TagName7, htmlProps);
11051 });
11052
11053 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
11054 var import_react22 = __toESM(require_react(), 1);
11055 var TagName8 = "div";
11056 function getMouseDestination(event) {
11057 const relatedTarget = event.relatedTarget;
11058 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
11059 return relatedTarget;
11060 }
11061 return null;
11062 }
11063 function hoveringInside(event) {
11064 const nextElement = getMouseDestination(event);
11065 if (!nextElement) return false;
11066 return contains(event.currentTarget, nextElement);
11067 }
11068 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
11069 function movingToAnotherItem(event) {
11070 let dest = getMouseDestination(event);
11071 if (!dest) return false;
11072 do {
11073 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
11074 dest = dest.parentElement;
11075 } while (dest);
11076 return false;
11077 }
11078 var useCompositeHover = createHook(
11079 function useCompositeHover2({
11080 store: store2,
11081 focusOnHover = true,
11082 blurOnHoverEnd = !!focusOnHover,
11083 ...props
11084 }) {
11085 const context = useCompositeContext();
11086 store2 = store2 || context;
11087 invariant(
11088 store2,
11089 "CompositeHover must be wrapped in a Composite component."
11090 );
11091 const isMouseMoving = useIsMouseMoving();
11092 const onMouseMoveProp = props.onMouseMove;
11093 const focusOnHoverProp = useBooleanEvent(focusOnHover);
11094 const onMouseMove = useEvent((event) => {
11095 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
11096 if (event.defaultPrevented) return;
11097 if (!isMouseMoving()) return;
11098 if (!focusOnHoverProp(event)) return;
11099 if (!hasFocusWithin(event.currentTarget)) {
11100 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11101 if (baseElement && !hasFocus(baseElement)) {
11102 baseElement.focus();
11103 }
11104 }
11105 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id);
11106 });
11107 const onMouseLeaveProp = props.onMouseLeave;
11108 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
11109 const onMouseLeave = useEvent((event) => {
11110 var _a;
11111 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
11112 if (event.defaultPrevented) return;
11113 if (!isMouseMoving()) return;
11114 if (hoveringInside(event)) return;
11115 if (movingToAnotherItem(event)) return;
11116 if (!focusOnHoverProp(event)) return;
11117 if (!blurOnHoverEndProp(event)) return;
11118 store2 == null ? void 0 : store2.setActiveId(null);
11119 (_a = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a.focus();
11120 });
11121 const ref = (0, import_react22.useCallback)((element) => {
11122 if (!element) return;
11123 element[symbol2] = true;
11124 }, []);
11125 props = {
11126 ...props,
11127 ref: useMergeRefs(ref, props.ref),
11128 onMouseMove,
11129 onMouseLeave
11130 };
11131 return removeUndefinedValues(props);
11132 }
11133 );
11134 var CompositeHover = memo22(
11135 forwardRef26(function CompositeHover2(props) {
11136 const htmlProps = useCompositeHover(props);
11137 return createElement3(TagName8, htmlProps);
11138 })
11139 );
11140
11141 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
11142 var import_react23 = __toESM(require_react(), 1);
11143 var TagName9 = "input";
11144 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
11145 if (!autoSelect) return false;
11146 const firstItem = items.find((item) => !item.disabled && item.value);
11147 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
11148 }
11149 function hasCompletionString(value, activeValue) {
11150 if (!activeValue) return false;
11151 if (value == null) return false;
11152 value = normalizeString(value);
11153 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
11154 }
11155 function isInputEvent(event) {
11156 return event.type === "input";
11157 }
11158 function isAriaAutoCompleteValue(value) {
11159 return value === "inline" || value === "list" || value === "both" || value === "none";
11160 }
11161 function getDefaultAutoSelectId(items) {
11162 const item = items.find((item2) => {
11163 var _a;
11164 if (item2.disabled) return false;
11165 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
11166 });
11167 return item == null ? void 0 : item.id;
11168 }
11169 var useCombobox = createHook(
11170 function useCombobox2({
11171 store: store2,
11172 focusable = true,
11173 autoSelect: autoSelectProp = false,
11174 getAutoSelectId,
11175 setValueOnChange,
11176 showMinLength = 0,
11177 showOnChange,
11178 showOnMouseDown,
11179 showOnClick = showOnMouseDown,
11180 showOnKeyDown,
11181 showOnKeyPress = showOnKeyDown,
11182 blurActiveItemOnClick,
11183 setValueOnClick = true,
11184 moveOnKeyPress = true,
11185 autoComplete = "list",
11186 ...props
11187 }) {
11188 const context = useComboboxProviderContext();
11189 store2 = store2 || context;
11190 invariant(
11191 store2,
11192 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
11193 );
11194 const ref = (0, import_react23.useRef)(null);
11195 const [valueUpdated, forceValueUpdate] = useForceUpdate();
11196 const canAutoSelectRef = (0, import_react23.useRef)(false);
11197 const composingRef = (0, import_react23.useRef)(false);
11198 const autoSelect = store2.useState(
11199 (state) => state.virtualFocus && autoSelectProp
11200 );
11201 const inline = autoComplete === "inline" || autoComplete === "both";
11202 const [canInline, setCanInline] = (0, import_react23.useState)(inline);
11203 useUpdateLayoutEffect(() => {
11204 if (!inline) return;
11205 setCanInline(true);
11206 }, [inline]);
11207 const storeValue = store2.useState("value");
11208 const prevSelectedValueRef = (0, import_react23.useRef)(void 0);
11209 (0, import_react23.useEffect)(() => {
11210 return sync(store2, ["selectedValue", "activeId"], (_, prev) => {
11211 prevSelectedValueRef.current = prev.selectedValue;
11212 });
11213 }, []);
11214 const inlineActiveValue = store2.useState((state) => {
11215 var _a;
11216 if (!inline) return;
11217 if (!canInline) return;
11218 if (state.activeValue && Array.isArray(state.selectedValue)) {
11219 if (state.selectedValue.includes(state.activeValue)) return;
11220 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
11221 }
11222 return state.activeValue;
11223 });
11224 const items = store2.useState("renderedItems");
11225 const open = store2.useState("open");
11226 const contentElement = store2.useState("contentElement");
11227 const value = (0, import_react23.useMemo)(() => {
11228 if (!inline) return storeValue;
11229 if (!canInline) return storeValue;
11230 const firstItemAutoSelected = isFirstItemAutoSelected(
11231 items,
11232 inlineActiveValue,
11233 autoSelect
11234 );
11235 if (firstItemAutoSelected) {
11236 if (hasCompletionString(storeValue, inlineActiveValue)) {
11237 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
11238 return storeValue + slice;
11239 }
11240 return storeValue;
11241 }
11242 return inlineActiveValue || storeValue;
11243 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
11244 (0, import_react23.useEffect)(() => {
11245 const element = ref.current;
11246 if (!element) return;
11247 const onCompositeItemMove = () => setCanInline(true);
11248 element.addEventListener("combobox-item-move", onCompositeItemMove);
11249 return () => {
11250 element.removeEventListener("combobox-item-move", onCompositeItemMove);
11251 };
11252 }, []);
11253 (0, import_react23.useEffect)(() => {
11254 if (!inline) return;
11255 if (!canInline) return;
11256 if (!inlineActiveValue) return;
11257 const firstItemAutoSelected = isFirstItemAutoSelected(
11258 items,
11259 inlineActiveValue,
11260 autoSelect
11261 );
11262 if (!firstItemAutoSelected) return;
11263 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
11264 let cleanup = noop2;
11265 queueMicrotask(() => {
11266 const element = ref.current;
11267 if (!element) return;
11268 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
11269 const nextStart = storeValue.length;
11270 const nextEnd = inlineActiveValue.length;
11271 setSelectionRange(element, nextStart, nextEnd);
11272 cleanup = () => {
11273 if (!hasFocus(element)) return;
11274 const { start, end } = getTextboxSelection(element);
11275 if (start !== nextStart) return;
11276 if (end !== nextEnd) return;
11277 setSelectionRange(element, prevStart, prevEnd);
11278 };
11279 });
11280 return () => cleanup();
11281 }, [
11282 valueUpdated,
11283 inline,
11284 canInline,
11285 inlineActiveValue,
11286 items,
11287 autoSelect,
11288 storeValue
11289 ]);
11290 const scrollingElementRef = (0, import_react23.useRef)(null);
11291 const getAutoSelectIdProp = useEvent(getAutoSelectId);
11292 const autoSelectIdRef = (0, import_react23.useRef)(null);
11293 (0, import_react23.useEffect)(() => {
11294 if (!open) return;
11295 if (!contentElement) return;
11296 const scrollingElement = getScrollingElement(contentElement);
11297 if (!scrollingElement) return;
11298 scrollingElementRef.current = scrollingElement;
11299 const onUserScroll = () => {
11300 canAutoSelectRef.current = false;
11301 };
11302 const onScroll = () => {
11303 if (!store2) return;
11304 if (!canAutoSelectRef.current) return;
11305 const { activeId } = store2.getState();
11306 if (activeId === null) return;
11307 if (activeId === autoSelectIdRef.current) return;
11308 canAutoSelectRef.current = false;
11309 };
11310 const options = { passive: true, capture: true };
11311 scrollingElement.addEventListener("wheel", onUserScroll, options);
11312 scrollingElement.addEventListener("touchmove", onUserScroll, options);
11313 scrollingElement.addEventListener("scroll", onScroll, options);
11314 return () => {
11315 scrollingElement.removeEventListener("wheel", onUserScroll, true);
11316 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
11317 scrollingElement.removeEventListener("scroll", onScroll, true);
11318 };
11319 }, [open, contentElement, store2]);
11320 useSafeLayoutEffect(() => {
11321 if (!storeValue) return;
11322 if (composingRef.current) return;
11323 canAutoSelectRef.current = true;
11324 }, [storeValue]);
11325 useSafeLayoutEffect(() => {
11326 if (autoSelect !== "always" && open) return;
11327 canAutoSelectRef.current = open;
11328 }, [autoSelect, open]);
11329 const resetValueOnSelect = store2.useState("resetValueOnSelect");
11330 useUpdateEffect(() => {
11331 var _a, _b;
11332 const canAutoSelect = canAutoSelectRef.current;
11333 if (!store2) return;
11334 if (!open) return;
11335 if (!canAutoSelect && !resetValueOnSelect) return;
11336 const { baseElement, contentElement: contentElement2, activeId } = store2.getState();
11337 if (baseElement && !hasFocus(baseElement)) return;
11338 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
11339 const observer = new MutationObserver(forceValueUpdate);
11340 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
11341 return () => observer.disconnect();
11342 }
11343 if (autoSelect && canAutoSelect) {
11344 const userAutoSelectId = getAutoSelectIdProp(items);
11345 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store2.first();
11346 autoSelectIdRef.current = autoSelectId;
11347 store2.move(autoSelectId != null ? autoSelectId : null);
11348 } else {
11349 const element = (_b = store2.item(activeId || store2.first())) == null ? void 0 : _b.element;
11350 if (element && "scrollIntoView" in element) {
11351 element.scrollIntoView({ block: "nearest", inline: "nearest" });
11352 }
11353 }
11354 return;
11355 }, [
11356 store2,
11357 open,
11358 valueUpdated,
11359 storeValue,
11360 autoSelect,
11361 resetValueOnSelect,
11362 getAutoSelectIdProp,
11363 items
11364 ]);
11365 (0, import_react23.useEffect)(() => {
11366 if (!inline) return;
11367 const combobox = ref.current;
11368 if (!combobox) return;
11369 const elements = [combobox, contentElement].filter(
11370 (value2) => !!value2
11371 );
11372 const onBlur2 = (event) => {
11373 if (elements.every((el) => isFocusEventOutside(event, el))) {
11374 store2 == null ? void 0 : store2.setValue(value);
11375 }
11376 };
11377 for (const element of elements) {
11378 element.addEventListener("focusout", onBlur2);
11379 }
11380 return () => {
11381 for (const element of elements) {
11382 element.removeEventListener("focusout", onBlur2);
11383 }
11384 };
11385 }, [inline, contentElement, store2, value]);
11386 const canShow = (event) => {
11387 const currentTarget = event.currentTarget;
11388 return currentTarget.value.length >= showMinLength;
11389 };
11390 const onChangeProp = props.onChange;
11391 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
11392 const setValueOnChangeProp = useBooleanEvent(
11393 // If the combobox is combined with tags, the value will be set by the tag
11394 // input component.
11395 setValueOnChange != null ? setValueOnChange : !store2.tag
11396 );
11397 const onChange = useEvent((event) => {
11398 onChangeProp == null ? void 0 : onChangeProp(event);
11399 if (event.defaultPrevented) return;
11400 if (!store2) return;
11401 const currentTarget = event.currentTarget;
11402 const { value: value2, selectionStart, selectionEnd } = currentTarget;
11403 const nativeEvent = event.nativeEvent;
11404 canAutoSelectRef.current = true;
11405 if (isInputEvent(nativeEvent)) {
11406 if (nativeEvent.isComposing) {
11407 canAutoSelectRef.current = false;
11408 composingRef.current = true;
11409 }
11410 if (inline) {
11411 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
11412 const caretAtEnd = selectionStart === value2.length;
11413 setCanInline(textInserted && caretAtEnd);
11414 }
11415 }
11416 if (setValueOnChangeProp(event)) {
11417 const isSameValue = value2 === store2.getState().value;
11418 store2.setValue(value2);
11419 queueMicrotask(() => {
11420 setSelectionRange(currentTarget, selectionStart, selectionEnd);
11421 });
11422 if (inline && autoSelect && isSameValue) {
11423 forceValueUpdate();
11424 }
11425 }
11426 if (showOnChangeProp(event)) {
11427 store2.show();
11428 }
11429 if (!autoSelect || !canAutoSelectRef.current) {
11430 store2.setActiveId(null);
11431 }
11432 });
11433 const onCompositionEndProp = props.onCompositionEnd;
11434 const onCompositionEnd = useEvent((event) => {
11435 canAutoSelectRef.current = true;
11436 composingRef.current = false;
11437 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
11438 if (event.defaultPrevented) return;
11439 if (!autoSelect) return;
11440 forceValueUpdate();
11441 });
11442 const onMouseDownProp = props.onMouseDown;
11443 const blurActiveItemOnClickProp = useBooleanEvent(
11444 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store2 == null ? void 0 : store2.getState().includesBaseElement))
11445 );
11446 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
11447 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
11448 const onMouseDown = useEvent((event) => {
11449 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
11450 if (event.defaultPrevented) return;
11451 if (event.button) return;
11452 if (event.ctrlKey) return;
11453 if (!store2) return;
11454 if (blurActiveItemOnClickProp(event)) {
11455 store2.setActiveId(null);
11456 }
11457 if (setValueOnClickProp(event)) {
11458 store2.setValue(value);
11459 }
11460 if (showOnClickProp(event)) {
11461 queueBeforeEvent(event.currentTarget, "mouseup", store2.show);
11462 }
11463 });
11464 const onKeyDownProp = props.onKeyDown;
11465 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
11466 const onKeyDown = useEvent((event) => {
11467 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
11468 if (!event.repeat) {
11469 canAutoSelectRef.current = false;
11470 }
11471 if (event.defaultPrevented) return;
11472 if (event.ctrlKey) return;
11473 if (event.altKey) return;
11474 if (event.shiftKey) return;
11475 if (event.metaKey) return;
11476 if (!store2) return;
11477 const { open: open2 } = store2.getState();
11478 if (open2) return;
11479 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
11480 if (showOnKeyPressProp(event)) {
11481 event.preventDefault();
11482 store2.show();
11483 }
11484 }
11485 });
11486 const onBlurProp = props.onBlur;
11487 const onBlur = useEvent((event) => {
11488 canAutoSelectRef.current = false;
11489 onBlurProp == null ? void 0 : onBlurProp(event);
11490 if (event.defaultPrevented) return;
11491 });
11492 const id = useId5(props.id);
11493 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
11494 const isActiveItem = store2.useState((state) => state.activeId === null);
11495 props = {
11496 id,
11497 role: "combobox",
11498 "aria-autocomplete": ariaAutoComplete,
11499 "aria-haspopup": getPopupRole(contentElement, "listbox"),
11500 "aria-expanded": open,
11501 "aria-controls": contentElement == null ? void 0 : contentElement.id,
11502 "data-active-item": isActiveItem || void 0,
11503 value,
11504 ...props,
11505 ref: useMergeRefs(ref, props.ref),
11506 onChange,
11507 onCompositionEnd,
11508 onMouseDown,
11509 onKeyDown,
11510 onBlur
11511 };
11512 props = useComposite({
11513 store: store2,
11514 focusable,
11515 ...props,
11516 // Enable inline autocomplete when the user moves from the combobox input
11517 // to an item.
11518 moveOnKeyPress: (event) => {
11519 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
11520 if (inline) setCanInline(true);
11521 return true;
11522 }
11523 });
11524 props = usePopoverAnchor({ store: store2, ...props });
11525 return { autoComplete: "off", ...props };
11526 }
11527 );
11528 var Combobox = forwardRef26(function Combobox2(props) {
11529 const htmlProps = useCombobox(props);
11530 return createElement3(TagName9, htmlProps);
11531 });
11532
11533 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
11534 var import_react24 = __toESM(require_react(), 1);
11535 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
11536 var TagName10 = "div";
11537 function isSelected(storeValue, itemValue) {
11538 if (itemValue == null) return;
11539 if (storeValue == null) return false;
11540 if (Array.isArray(storeValue)) {
11541 return storeValue.includes(itemValue);
11542 }
11543 return storeValue === itemValue;
11544 }
11545 function getItemRole(popupRole) {
11546 var _a;
11547 const itemRoleByPopupRole = {
11548 menu: "menuitem",
11549 listbox: "option",
11550 tree: "treeitem"
11551 };
11552 const key = popupRole;
11553 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
11554 }
11555 var useComboboxItem = createHook(
11556 function useComboboxItem2({
11557 store: store2,
11558 value,
11559 hideOnClick,
11560 setValueOnClick,
11561 selectValueOnClick = true,
11562 resetValueOnSelect,
11563 focusOnHover = false,
11564 moveOnKeyPress = true,
11565 getItem: getItemProp,
11566 ...props
11567 }) {
11568 var _a;
11569 const context = useComboboxScopedContext();
11570 store2 = store2 || context;
11571 invariant(
11572 store2,
11573 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
11574 );
11575 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, {
11576 resetValueOnSelectState: "resetValueOnSelect",
11577 multiSelectable(state) {
11578 return Array.isArray(state.selectedValue);
11579 },
11580 selected(state) {
11581 return isSelected(state.selectedValue, value);
11582 }
11583 });
11584 const getItem = (0, import_react24.useCallback)(
11585 (item) => {
11586 const nextItem = { ...item, value };
11587 if (getItemProp) {
11588 return getItemProp(nextItem);
11589 }
11590 return nextItem;
11591 },
11592 [value, getItemProp]
11593 );
11594 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
11595 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
11596 const onClickProp = props.onClick;
11597 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
11598 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
11599 const resetValueOnSelectProp = useBooleanEvent(
11600 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
11601 );
11602 const hideOnClickProp = useBooleanEvent(hideOnClick);
11603 const onClick = useEvent((event) => {
11604 onClickProp == null ? void 0 : onClickProp(event);
11605 if (event.defaultPrevented) return;
11606 if (isDownloading(event)) return;
11607 if (isOpeningInNewTab(event)) return;
11608 if (value != null) {
11609 if (selectValueOnClickProp(event)) {
11610 if (resetValueOnSelectProp(event)) {
11611 store2 == null ? void 0 : store2.resetValue();
11612 }
11613 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => {
11614 if (!Array.isArray(prevValue)) return value;
11615 if (prevValue.includes(value)) {
11616 return prevValue.filter((v2) => v2 !== value);
11617 }
11618 return [...prevValue, value];
11619 });
11620 }
11621 if (setValueOnClickProp(event)) {
11622 store2 == null ? void 0 : store2.setValue(value);
11623 }
11624 }
11625 if (hideOnClickProp(event)) {
11626 store2 == null ? void 0 : store2.hide();
11627 }
11628 });
11629 const onKeyDownProp = props.onKeyDown;
11630 const onKeyDown = useEvent((event) => {
11631 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
11632 if (event.defaultPrevented) return;
11633 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11634 if (!baseElement) return;
11635 if (hasFocus(baseElement)) return;
11636 const printable = event.key.length === 1;
11637 if (printable || event.key === "Backspace" || event.key === "Delete") {
11638 queueMicrotask(() => baseElement.focus());
11639 if (isTextField(baseElement)) {
11640 store2 == null ? void 0 : store2.setValue(baseElement.value);
11641 }
11642 }
11643 });
11644 if (multiSelectable && selected != null) {
11645 props = {
11646 "aria-selected": selected,
11647 ...props
11648 };
11649 }
11650 props = useWrapElement(
11651 props,
11652 (element) => /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }),
11653 [value, selected]
11654 );
11655 const popupRole = (0, import_react24.useContext)(ComboboxListRoleContext);
11656 props = {
11657 role: getItemRole(popupRole),
11658 children: value,
11659 ...props,
11660 onClick,
11661 onKeyDown
11662 };
11663 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
11664 props = useCompositeItem({
11665 store: store2,
11666 ...props,
11667 getItem,
11668 // Dispatch a custom event on the combobox input when moving to an item
11669 // with the keyboard so the Combobox component can enable inline
11670 // autocompletion.
11671 moveOnKeyPress: (event) => {
11672 if (!moveOnKeyPressProp(event)) return false;
11673 const moveEvent = new Event("combobox-item-move");
11674 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11675 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
11676 return true;
11677 }
11678 });
11679 props = useCompositeHover({ store: store2, focusOnHover, ...props });
11680 return props;
11681 }
11682 );
11683 var ComboboxItem = memo22(
11684 forwardRef26(function ComboboxItem2(props) {
11685 const htmlProps = useComboboxItem(props);
11686 return createElement3(TagName10, htmlProps);
11687 })
11688 );
11689
11690 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
11691 var import_react25 = __toESM(require_react(), 1);
11692 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
11693 var TagName11 = "span";
11694 function normalizeValue(value) {
11695 return normalizeString(value).toLowerCase();
11696 }
11697 function getOffsets(string, values) {
11698 const offsets = [];
11699 for (const value of values) {
11700 let pos = 0;
11701 const length = value.length;
11702 while (string.indexOf(value, pos) !== -1) {
11703 const index = string.indexOf(value, pos);
11704 if (index !== -1) {
11705 offsets.push([index, length]);
11706 }
11707 pos = index + 1;
11708 }
11709 }
11710 return offsets;
11711 }
11712 function filterOverlappingOffsets(offsets) {
11713 return offsets.filter(([offset, length], i2, arr) => {
11714 return !arr.some(
11715 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
11716 );
11717 });
11718 }
11719 function sortOffsets(offsets) {
11720 return offsets.sort(([a2], [b2]) => a2 - b2);
11721 }
11722 function splitValue(itemValue, userValue) {
11723 if (!itemValue) return itemValue;
11724 if (!userValue) return itemValue;
11725 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
11726 const parts = [];
11727 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
11728 "span",
11729 {
11730 "data-autocomplete-value": autocomplete ? "" : void 0,
11731 "data-user-value": autocomplete ? void 0 : "",
11732 children: value
11733 },
11734 parts.length
11735 );
11736 const offsets = sortOffsets(
11737 filterOverlappingOffsets(
11738 // Convert userValues into a set to avoid duplicates
11739 getOffsets(normalizeValue(itemValue), new Set(userValues))
11740 )
11741 );
11742 if (!offsets.length) {
11743 parts.push(span(itemValue, true));
11744 return parts;
11745 }
11746 const [firstOffset] = offsets[0];
11747 const values = [
11748 itemValue.slice(0, firstOffset),
11749 ...offsets.flatMap(([offset, length], i2) => {
11750 var _a;
11751 const value = itemValue.slice(offset, offset + length);
11752 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
11753 const nextValue = itemValue.slice(offset + length, nextOffset);
11754 return [value, nextValue];
11755 })
11756 ];
11757 values.forEach((value, i2) => {
11758 if (!value) return;
11759 parts.push(span(value, i2 % 2 === 0));
11760 });
11761 return parts;
11762 }
11763 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) {
11764 const context = useComboboxScopedContext();
11765 store2 = store2 || context;
11766 const itemContext = (0, import_react25.useContext)(ComboboxItemValueContext);
11767 const itemValue = value != null ? value : itemContext;
11768 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
11769 const children = (0, import_react25.useMemo)(() => {
11770 if (!itemValue) return;
11771 if (!inputValue) return itemValue;
11772 return splitValue(itemValue, inputValue);
11773 }, [itemValue, inputValue]);
11774 props = {
11775 children,
11776 ...props
11777 };
11778 return removeUndefinedValues(props);
11779 });
11780 var ComboboxItemValue = forwardRef26(function ComboboxItemValue2(props) {
11781 const htmlProps = useComboboxItemValue(props);
11782 return createElement3(TagName11, htmlProps);
11783 });
11784
11785 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
11786 var TagName12 = "label";
11787 var useComboboxLabel = createHook(
11788 function useComboboxLabel2({ store: store2, ...props }) {
11789 const context = useComboboxProviderContext();
11790 store2 = store2 || context;
11791 invariant(
11792 store2,
11793 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
11794 );
11795 const comboboxId = store2.useState((state) => {
11796 var _a;
11797 return (_a = state.baseElement) == null ? void 0 : _a.id;
11798 });
11799 props = {
11800 htmlFor: comboboxId,
11801 ...props
11802 };
11803 return removeUndefinedValues(props);
11804 }
11805 );
11806 var ComboboxLabel = memo22(
11807 forwardRef26(function ComboboxLabel2(props) {
11808 const htmlProps = useComboboxLabel(props);
11809 return createElement3(TagName12, htmlProps);
11810 })
11811 );
11812
11813 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
11814 var import_react26 = __toESM(require_react(), 1);
11815 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
11816 var TagName13 = "div";
11817 var useComboboxList = createHook(
11818 function useComboboxList2({ store: store2, alwaysVisible, ...props }) {
11819 const scopedContext = useComboboxScopedContext(true);
11820 const context = useComboboxContext();
11821 store2 = store2 || context;
11822 const scopedContextSameStore = !!store2 && store2 === scopedContext;
11823 invariant(
11824 store2,
11825 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
11826 );
11827 const ref = (0, import_react26.useRef)(null);
11828 const id = useId5(props.id);
11829 const mounted = store2.useState("mounted");
11830 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
11831 const style = hidden ? { ...props.style, display: "none" } : props.style;
11832 const multiSelectable = store2.useState(
11833 (state) => Array.isArray(state.selectedValue)
11834 );
11835 const role = useAttribute(ref, "role", props.role);
11836 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
11837 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
11838 const [hasListboxInside, setHasListboxInside] = (0, import_react26.useState)(false);
11839 const contentElement = store2.useState("contentElement");
11840 useSafeLayoutEffect(() => {
11841 if (!mounted) return;
11842 const element = ref.current;
11843 if (!element) return;
11844 if (contentElement !== element) return;
11845 const callback = () => {
11846 setHasListboxInside(!!element.querySelector("[role='listbox']"));
11847 };
11848 const observer = new MutationObserver(callback);
11849 observer.observe(element, {
11850 subtree: true,
11851 childList: true,
11852 attributeFilter: ["role"]
11853 });
11854 callback();
11855 return () => observer.disconnect();
11856 }, [mounted, contentElement]);
11857 if (!hasListboxInside) {
11858 props = {
11859 role: "listbox",
11860 "aria-multiselectable": ariaMultiSelectable,
11861 ...props
11862 };
11863 }
11864 props = useWrapElement(
11865 props,
11866 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
11867 [store2, role]
11868 );
11869 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null;
11870 props = {
11871 id,
11872 hidden,
11873 ...props,
11874 ref: useMergeRefs(setContentElement, ref, props.ref),
11875 style
11876 };
11877 return removeUndefinedValues(props);
11878 }
11879 );
11880 var ComboboxList = forwardRef26(function ComboboxList2(props) {
11881 const htmlProps = useComboboxList(props);
11882 return createElement3(TagName13, htmlProps);
11883 });
11884
11885 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
11886 var import_react27 = __toESM(require_react(), 1);
11887 var TagValueContext = (0, import_react27.createContext)(null);
11888 var TagRemoveIdContext = (0, import_react27.createContext)(
11889 null
11890 );
11891 var ctx7 = createStoreContext(
11892 [CompositeContextProvider],
11893 [CompositeScopedContextProvider]
11894 );
11895 var useTagContext = ctx7.useContext;
11896 var useTagScopedContext = ctx7.useScopedContext;
11897 var useTagProviderContext = ctx7.useProviderContext;
11898 var TagContextProvider = ctx7.ContextProvider;
11899 var TagScopedContextProvider = ctx7.ScopedContextProvider;
11900
11901 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
11902 var isTouchSafari = isSafari() && isTouchDevice();
11903 function createComboboxStore({
11904 tag,
11905 ...props
11906 } = {}) {
11907 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
11908 throwOnConflictingProps(props, store2);
11909 const tagState = tag == null ? void 0 : tag.getState();
11910 const syncState = store2 == null ? void 0 : store2.getState();
11911 const activeId = defaultValue(
11912 props.activeId,
11913 syncState == null ? void 0 : syncState.activeId,
11914 props.defaultActiveId,
11915 null
11916 );
11917 const composite = createCompositeStore({
11918 ...props,
11919 activeId,
11920 includesBaseElement: defaultValue(
11921 props.includesBaseElement,
11922 syncState == null ? void 0 : syncState.includesBaseElement,
11923 true
11924 ),
11925 orientation: defaultValue(
11926 props.orientation,
11927 syncState == null ? void 0 : syncState.orientation,
11928 "vertical"
11929 ),
11930 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
11931 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
11932 virtualFocus: defaultValue(
11933 props.virtualFocus,
11934 syncState == null ? void 0 : syncState.virtualFocus,
11935 true
11936 )
11937 });
11938 const popover = createPopoverStore({
11939 ...props,
11940 placement: defaultValue(
11941 props.placement,
11942 syncState == null ? void 0 : syncState.placement,
11943 "bottom-start"
11944 )
11945 });
11946 const value = defaultValue(
11947 props.value,
11948 syncState == null ? void 0 : syncState.value,
11949 props.defaultValue,
11950 ""
11951 );
11952 const selectedValue = defaultValue(
11953 props.selectedValue,
11954 syncState == null ? void 0 : syncState.selectedValue,
11955 tagState == null ? void 0 : tagState.values,
11956 props.defaultSelectedValue,
11957 ""
11958 );
11959 const multiSelectable = Array.isArray(selectedValue);
11960 const initialState = {
11961 ...composite.getState(),
11962 ...popover.getState(),
11963 value,
11964 selectedValue,
11965 resetValueOnSelect: defaultValue(
11966 props.resetValueOnSelect,
11967 syncState == null ? void 0 : syncState.resetValueOnSelect,
11968 multiSelectable
11969 ),
11970 resetValueOnHide: defaultValue(
11971 props.resetValueOnHide,
11972 syncState == null ? void 0 : syncState.resetValueOnHide,
11973 multiSelectable && !tag
11974 ),
11975 activeValue: syncState == null ? void 0 : syncState.activeValue
11976 };
11977 const combobox = createStore(initialState, composite, popover, store2);
11978 if (isTouchSafari) {
11979 setup(
11980 combobox,
11981 () => sync(combobox, ["virtualFocus"], () => {
11982 combobox.setState("virtualFocus", false);
11983 })
11984 );
11985 }
11986 setup(combobox, () => {
11987 if (!tag) return;
11988 return chain(
11989 sync(combobox, ["selectedValue"], (state) => {
11990 if (!Array.isArray(state.selectedValue)) return;
11991 tag.setValues(state.selectedValue);
11992 }),
11993 sync(tag, ["values"], (state) => {
11994 combobox.setState("selectedValue", state.values);
11995 })
11996 );
11997 });
11998 setup(
11999 combobox,
12000 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
12001 if (!state.resetValueOnHide) return;
12002 if (state.mounted) return;
12003 combobox.setState("value", value);
12004 })
12005 );
12006 setup(
12007 combobox,
12008 () => sync(combobox, ["open"], (state) => {
12009 if (state.open) return;
12010 combobox.setState("activeId", activeId);
12011 combobox.setState("moves", 0);
12012 })
12013 );
12014 setup(
12015 combobox,
12016 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
12017 if (state.moves === prevState.moves) {
12018 combobox.setState("activeValue", void 0);
12019 }
12020 })
12021 );
12022 setup(
12023 combobox,
12024 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
12025 if (state.moves === prev.moves) return;
12026 const { activeId: activeId2 } = combobox.getState();
12027 const activeItem = composite.item(activeId2);
12028 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
12029 })
12030 );
12031 return {
12032 ...popover,
12033 ...composite,
12034 ...combobox,
12035 tag,
12036 setValue: (value2) => combobox.setState("value", value2),
12037 resetValue: () => combobox.setState("value", initialState.value),
12038 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
12039 };
12040 }
12041
12042 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
12043 function useComboboxStoreOptions(props) {
12044 const tag = useTagContext();
12045 props = {
12046 ...props,
12047 tag: props.tag !== void 0 ? props.tag : tag
12048 };
12049 return useCompositeStoreOptions(props);
12050 }
12051 function useComboboxStoreProps(store2, update2, props) {
12052 useUpdateEffect(update2, [props.tag]);
12053 useStoreProps(store2, props, "value", "setValue");
12054 useStoreProps(store2, props, "selectedValue", "setSelectedValue");
12055 useStoreProps(store2, props, "resetValueOnHide");
12056 useStoreProps(store2, props, "resetValueOnSelect");
12057 return Object.assign(
12058 useCompositeStoreProps(
12059 usePopoverStoreProps(store2, update2, props),
12060 update2,
12061 props
12062 ),
12063 { tag: props.tag }
12064 );
12065 }
12066 function useComboboxStore(props = {}) {
12067 props = useComboboxStoreOptions(props);
12068 const [store2, update2] = useStore(createComboboxStore, props);
12069 return useComboboxStoreProps(store2, update2, props);
12070 }
12071
12072 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
12073 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
12074 function ComboboxProvider(props = {}) {
12075 const store2 = useComboboxStore(props);
12076 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ComboboxContextProvider, { value: store2, children: props.children });
12077 }
12078
12079 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
12080 var import_remove_accents = __toESM(require_remove_accents(), 1);
12081 var import_compose7 = __toESM(require_compose(), 1);
12082 var import_i18n23 = __toESM(require_i18n(), 1);
12083 var import_element44 = __toESM(require_element(), 1);
12084 var import_components20 = __toESM(require_components(), 1);
12085
12086 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
12087 var EMPTY_ARRAY3 = [];
12088 var getCurrentValue = (filterDefinition, currentFilter) => {
12089 if (filterDefinition.singleSelection) {
12090 return currentFilter?.value;
12091 }
12092 if (Array.isArray(currentFilter?.value)) {
12093 return currentFilter.value;
12094 }
12095 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
12096 return [currentFilter.value];
12097 }
12098 return EMPTY_ARRAY3;
12099 };
12100
12101 // packages/dataviews/build-module/hooks/use-elements.mjs
12102 var import_element43 = __toESM(require_element(), 1);
12103 var EMPTY_ARRAY4 = [];
12104 function useElements({
12105 elements,
12106 getElements
12107 }) {
12108 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
12109 const [records, setRecords] = (0, import_element43.useState)(staticElements);
12110 const [isLoading, setIsLoading] = (0, import_element43.useState)(false);
12111 (0, import_element43.useEffect)(() => {
12112 if (!getElements) {
12113 setRecords(staticElements);
12114 return;
12115 }
12116 let cancelled = false;
12117 setIsLoading(true);
12118 getElements().then((fetchedElements) => {
12119 if (!cancelled) {
12120 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
12121 setRecords(dynamicElements);
12122 }
12123 }).catch(() => {
12124 if (!cancelled) {
12125 setRecords(staticElements);
12126 }
12127 }).finally(() => {
12128 if (!cancelled) {
12129 setIsLoading(false);
12130 }
12131 });
12132 return () => {
12133 cancelled = true;
12134 };
12135 }, [getElements, staticElements]);
12136 return {
12137 elements: records,
12138 isLoading
12139 };
12140 }
12141
12142 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
12143 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
12144 function normalizeSearchInput(input = "") {
12145 return (0, import_remove_accents.default)(input.trim().toLowerCase());
12146 }
12147 var getNewValue = (filterDefinition, currentFilter, value) => {
12148 if (filterDefinition.singleSelection) {
12149 return value;
12150 }
12151 if (Array.isArray(currentFilter?.value)) {
12152 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
12153 }
12154 return [value];
12155 };
12156 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
12157 return `${prefix}-${filterElementValue}`;
12158 }
12159 var MultiSelectionOption = ({ selected }) => {
12160 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12161 "span",
12162 {
12163 className: clsx_default(
12164 "dataviews-filters__search-widget-listitem-multi-selection",
12165 { "is-selected": selected }
12166 ),
12167 children: selected && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Icon, { icon: check_default })
12168 }
12169 );
12170 };
12171 var SingleSelectionOption = ({ selected }) => {
12172 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12173 "span",
12174 {
12175 className: clsx_default(
12176 "dataviews-filters__search-widget-listitem-single-selection",
12177 { "is-selected": selected }
12178 )
12179 }
12180 );
12181 };
12182 function ListBox({ view, filter, onChangeView }) {
12183 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
12184 const [activeCompositeId, setActiveCompositeId] = (0, import_element44.useState)(
12185 // When there are one or less operators, the first item is set as active
12186 // (by setting the initial `activeId` to `undefined`).
12187 // With 2 or more operators, the focus is moved on the operators control
12188 // (by setting the initial `activeId` to `null`), meaning that there won't
12189 // be an active item initially. Focus is then managed via the
12190 // `onFocusVisible` callback.
12191 filter.operators?.length === 1 ? void 0 : null
12192 );
12193 const currentFilter = view.filters?.find(
12194 (f2) => f2.field === filter.field
12195 );
12196 const currentValue = getCurrentValue(filter, currentFilter);
12197 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12198 import_components20.Composite,
12199 {
12200 virtualFocus: true,
12201 focusLoop: true,
12202 activeId: activeCompositeId,
12203 setActiveId: setActiveCompositeId,
12204 role: "listbox",
12205 className: "dataviews-filters__search-widget-listbox",
12206 "aria-label": (0, import_i18n23.sprintf)(
12207 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
12208 (0, import_i18n23.__)("List of: %1$s"),
12209 filter.name
12210 ),
12211 onFocusVisible: () => {
12212 if (!activeCompositeId && filter.elements.length) {
12213 setActiveCompositeId(
12214 generateFilterElementCompositeItemId(
12215 baseId,
12216 filter.elements[0].value
12217 )
12218 );
12219 }
12220 },
12221 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Composite.Typeahead, {}),
12222 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12223 import_components20.Composite.Hover,
12224 {
12225 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12226 import_components20.Composite.Item,
12227 {
12228 id: generateFilterElementCompositeItemId(
12229 baseId,
12230 element.value
12231 ),
12232 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12233 "div",
12234 {
12235 "aria-label": element.label,
12236 role: "option",
12237 className: "dataviews-filters__search-widget-listitem"
12238 }
12239 ),
12240 onClick: () => {
12241 const newFilters = currentFilter ? [
12242 ...(view.filters ?? []).map(
12243 (_filter) => {
12244 if (_filter.field === filter.field) {
12245 return {
12246 ..._filter,
12247 operator: currentFilter.operator || filter.operators[0],
12248 value: getNewValue(
12249 filter,
12250 currentFilter,
12251 element.value
12252 )
12253 };
12254 }
12255 return _filter;
12256 }
12257 )
12258 ] : [
12259 ...view.filters ?? [],
12260 {
12261 field: filter.field,
12262 operator: filter.operators[0],
12263 value: getNewValue(
12264 filter,
12265 currentFilter,
12266 element.value
12267 )
12268 }
12269 ];
12270 onChangeView({
12271 ...view,
12272 page: 1,
12273 filters: newFilters
12274 });
12275 }
12276 }
12277 ),
12278 children: [
12279 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12280 SingleSelectionOption,
12281 {
12282 selected: currentValue === element.value
12283 }
12284 ),
12285 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12286 MultiSelectionOption,
12287 {
12288 selected: currentValue.includes(element.value)
12289 }
12290 ),
12291 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12292 "span",
12293 {
12294 className: "dataviews-filters__search-widget-listitem-value",
12295 title: element.label,
12296 children: element.label
12297 }
12298 )
12299 ]
12300 },
12301 element.value
12302 ))
12303 }
12304 );
12305 }
12306 function ComboboxList22({ view, filter, onChangeView }) {
12307 const [searchValue, setSearchValue] = (0, import_element44.useState)("");
12308 const deferredSearchValue = (0, import_element44.useDeferredValue)(searchValue);
12309 const currentFilter = view.filters?.find(
12310 (_filter) => _filter.field === filter.field
12311 );
12312 const currentValue = getCurrentValue(filter, currentFilter);
12313 const matches = (0, import_element44.useMemo)(() => {
12314 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
12315 return filter.elements.filter(
12316 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
12317 );
12318 }, [filter.elements, deferredSearchValue]);
12319 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12320 ComboboxProvider,
12321 {
12322 selectedValue: currentValue,
12323 setSelectedValue: (value) => {
12324 const newFilters = currentFilter ? [
12325 ...(view.filters ?? []).map((_filter) => {
12326 if (_filter.field === filter.field) {
12327 return {
12328 ..._filter,
12329 operator: currentFilter.operator || filter.operators[0],
12330 value
12331 };
12332 }
12333 return _filter;
12334 })
12335 ] : [
12336 ...view.filters ?? [],
12337 {
12338 field: filter.field,
12339 operator: filter.operators[0],
12340 value
12341 }
12342 ];
12343 onChangeView({
12344 ...view,
12345 page: 1,
12346 filters: newFilters
12347 });
12348 },
12349 setValue: setSearchValue,
12350 children: [
12351 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
12352 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxLabel, {}), children: (0, import_i18n23.__)("Search items") }),
12353 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12354 Combobox,
12355 {
12356 autoSelect: "always",
12357 placeholder: (0, import_i18n23.__)("Search"),
12358 className: "dataviews-filters__search-widget-filter-combobox__input"
12359 }
12360 ),
12361 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-filter-combobox__icon", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Icon, { icon: search_default }) })
12362 ] }),
12363 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12364 ComboboxList,
12365 {
12366 className: "dataviews-filters__search-widget-filter-combobox-list",
12367 alwaysVisible: true,
12368 children: [
12369 matches.map((element) => {
12370 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12371 ComboboxItem,
12372 {
12373 resetValueOnSelect: false,
12374 value: element.value,
12375 className: "dataviews-filters__search-widget-listitem",
12376 hideOnClick: false,
12377 setValueOnClick: false,
12378 focusOnHover: true,
12379 children: [
12380 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12381 SingleSelectionOption,
12382 {
12383 selected: currentValue === element.value
12384 }
12385 ),
12386 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12387 MultiSelectionOption,
12388 {
12389 selected: currentValue.includes(
12390 element.value
12391 )
12392 }
12393 ),
12394 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
12395 "span",
12396 {
12397 className: "dataviews-filters__search-widget-listitem-value",
12398 title: element.label,
12399 children: [
12400 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
12401 ComboboxItemValue,
12402 {
12403 className: "dataviews-filters__search-widget-filter-combobox-item-value",
12404 value: element.label
12405 }
12406 ),
12407 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
12408 ]
12409 }
12410 )
12411 ]
12412 },
12413 element.value
12414 );
12415 }),
12416 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { children: (0, import_i18n23.__)("No results found") })
12417 ]
12418 }
12419 )
12420 ]
12421 }
12422 );
12423 }
12424 function SearchWidget(props) {
12425 const { elements, isLoading } = useElements({
12426 elements: props.filter.elements,
12427 getElements: props.filter.getElements
12428 });
12429 if (isLoading) {
12430 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Spinner, {}) });
12431 }
12432 if (elements.length === 0) {
12433 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n23.__)("No elements found") });
12434 }
12435 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
12436 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
12437 }
12438
12439 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
12440 var import_es6 = __toESM(require_es6(), 1);
12441 var import_compose8 = __toESM(require_compose(), 1);
12442 var import_element45 = __toESM(require_element(), 1);
12443 var import_components21 = __toESM(require_components(), 1);
12444 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
12445 function InputWidget({
12446 filter,
12447 view,
12448 onChangeView,
12449 fields: fields2
12450 }) {
12451 const currentFilter = view.filters?.find(
12452 (f2) => f2.field === filter.field
12453 );
12454 const currentValue = getCurrentValue(filter, currentFilter);
12455 const field = (0, import_element45.useMemo)(() => {
12456 const currentField = fields2.find((f2) => f2.id === filter.field);
12457 if (currentField) {
12458 return {
12459 ...currentField,
12460 // Deactivate validation for filters.
12461 isValid: {},
12462 // Filter controls are always enabled.
12463 isDisabled: () => false,
12464 // Filter controls are always visible.
12465 isVisible: () => true,
12466 // Configure getValue/setValue as if Item was a plain object.
12467 getValue: ({ item }) => item[currentField.id],
12468 setValue: ({ value }) => ({
12469 [currentField.id]: value
12470 })
12471 };
12472 }
12473 return currentField;
12474 }, [fields2, filter.field]);
12475 const data = (0, import_element45.useMemo)(() => {
12476 return (view.filters ?? []).reduce(
12477 (acc, activeFilter) => {
12478 acc[activeFilter.field] = activeFilter.value;
12479 return acc;
12480 },
12481 {}
12482 );
12483 }, [view.filters]);
12484 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
12485 if (!field || !currentFilter) {
12486 return;
12487 }
12488 const nextValue = field.getValue({ item: updatedData });
12489 if ((0, import_es6.default)(nextValue, currentValue)) {
12490 return;
12491 }
12492 onChangeView({
12493 ...view,
12494 filters: (view.filters ?? []).map(
12495 (_filter) => _filter.field === filter.field ? {
12496 ..._filter,
12497 operator: currentFilter.operator || filter.operators[0],
12498 // Consider empty strings as undefined:
12499 //
12500 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
12501 // - empty string as value means "search empty string": returns only the records that have an empty string as value
12502 //
12503 // In practice, this means the filter will not be able to find an empty string as the value.
12504 value: nextValue === "" ? void 0 : nextValue
12505 } : _filter
12506 )
12507 });
12508 });
12509 if (!field || !field.Edit || !currentFilter) {
12510 return null;
12511 }
12512 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
12513 import_components21.Flex,
12514 {
12515 className: "dataviews-filters__user-input-widget",
12516 gap: 2.5,
12517 direction: "column",
12518 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
12519 field.Edit,
12520 {
12521 hideLabelFromVision: true,
12522 data,
12523 field,
12524 operator: currentFilter.operator,
12525 onChange: handleChange
12526 }
12527 )
12528 }
12529 );
12530 }
12531
12532 // packages/dataviews/node_modules/date-fns/constants.js
12533 var daysInYear = 365.2425;
12534 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
12535 var minTime = -maxTime;
12536 var millisecondsInWeek = 6048e5;
12537 var millisecondsInDay = 864e5;
12538 var secondsInHour = 3600;
12539 var secondsInDay = secondsInHour * 24;
12540 var secondsInWeek = secondsInDay * 7;
12541 var secondsInYear = secondsInDay * daysInYear;
12542 var secondsInMonth = secondsInYear / 12;
12543 var secondsInQuarter = secondsInMonth * 3;
12544 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
12545
12546 // packages/dataviews/node_modules/date-fns/constructFrom.js
12547 function constructFrom(date, value) {
12548 if (typeof date === "function") return date(value);
12549 if (date && typeof date === "object" && constructFromSymbol in date)
12550 return date[constructFromSymbol](value);
12551 if (date instanceof Date) return new date.constructor(value);
12552 return new Date(value);
12553 }
12554
12555 // packages/dataviews/node_modules/date-fns/toDate.js
12556 function toDate(argument, context) {
12557 return constructFrom(context || argument, argument);
12558 }
12559
12560 // packages/dataviews/node_modules/date-fns/addDays.js
12561 function addDays(date, amount, options) {
12562 const _date = toDate(date, options?.in);
12563 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
12564 if (!amount) return _date;
12565 _date.setDate(_date.getDate() + amount);
12566 return _date;
12567 }
12568
12569 // packages/dataviews/node_modules/date-fns/addMonths.js
12570 function addMonths(date, amount, options) {
12571 const _date = toDate(date, options?.in);
12572 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
12573 if (!amount) {
12574 return _date;
12575 }
12576 const dayOfMonth = _date.getDate();
12577 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
12578 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
12579 const daysInMonth = endOfDesiredMonth.getDate();
12580 if (dayOfMonth >= daysInMonth) {
12581 return endOfDesiredMonth;
12582 } else {
12583 _date.setFullYear(
12584 endOfDesiredMonth.getFullYear(),
12585 endOfDesiredMonth.getMonth(),
12586 dayOfMonth
12587 );
12588 return _date;
12589 }
12590 }
12591
12592 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js
12593 var defaultOptions = {};
12594 function getDefaultOptions() {
12595 return defaultOptions;
12596 }
12597
12598 // packages/dataviews/node_modules/date-fns/startOfWeek.js
12599 function startOfWeek(date, options) {
12600 const defaultOptions2 = getDefaultOptions();
12601 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
12602 const _date = toDate(date, options?.in);
12603 const day = _date.getDay();
12604 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
12605 _date.setDate(_date.getDate() - diff);
12606 _date.setHours(0, 0, 0, 0);
12607 return _date;
12608 }
12609
12610 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js
12611 function startOfISOWeek(date, options) {
12612 return startOfWeek(date, { ...options, weekStartsOn: 1 });
12613 }
12614
12615 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js
12616 function getISOWeekYear(date, options) {
12617 const _date = toDate(date, options?.in);
12618 const year = _date.getFullYear();
12619 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
12620 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
12621 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
12622 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
12623 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
12624 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
12625 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
12626 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
12627 if (_date.getTime() >= startOfNextYear.getTime()) {
12628 return year + 1;
12629 } else if (_date.getTime() >= startOfThisYear.getTime()) {
12630 return year;
12631 } else {
12632 return year - 1;
12633 }
12634 }
12635
12636 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
12637 function getTimezoneOffsetInMilliseconds(date) {
12638 const _date = toDate(date);
12639 const utcDate = new Date(
12640 Date.UTC(
12641 _date.getFullYear(),
12642 _date.getMonth(),
12643 _date.getDate(),
12644 _date.getHours(),
12645 _date.getMinutes(),
12646 _date.getSeconds(),
12647 _date.getMilliseconds()
12648 )
12649 );
12650 utcDate.setUTCFullYear(_date.getFullYear());
12651 return +date - +utcDate;
12652 }
12653
12654 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js
12655 function normalizeDates(context, ...dates) {
12656 const normalize = constructFrom.bind(
12657 null,
12658 context || dates.find((date) => typeof date === "object")
12659 );
12660 return dates.map(normalize);
12661 }
12662
12663 // packages/dataviews/node_modules/date-fns/startOfDay.js
12664 function startOfDay(date, options) {
12665 const _date = toDate(date, options?.in);
12666 _date.setHours(0, 0, 0, 0);
12667 return _date;
12668 }
12669
12670 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js
12671 function differenceInCalendarDays(laterDate, earlierDate, options) {
12672 const [laterDate_, earlierDate_] = normalizeDates(
12673 options?.in,
12674 laterDate,
12675 earlierDate
12676 );
12677 const laterStartOfDay = startOfDay(laterDate_);
12678 const earlierStartOfDay = startOfDay(earlierDate_);
12679 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
12680 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
12681 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
12682 }
12683
12684 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js
12685 function startOfISOWeekYear(date, options) {
12686 const year = getISOWeekYear(date, options);
12687 const fourthOfJanuary = constructFrom(options?.in || date, 0);
12688 fourthOfJanuary.setFullYear(year, 0, 4);
12689 fourthOfJanuary.setHours(0, 0, 0, 0);
12690 return startOfISOWeek(fourthOfJanuary);
12691 }
12692
12693 // packages/dataviews/node_modules/date-fns/addWeeks.js
12694 function addWeeks(date, amount, options) {
12695 return addDays(date, amount * 7, options);
12696 }
12697
12698 // packages/dataviews/node_modules/date-fns/addYears.js
12699 function addYears(date, amount, options) {
12700 return addMonths(date, amount * 12, options);
12701 }
12702
12703 // packages/dataviews/node_modules/date-fns/isDate.js
12704 function isDate(value) {
12705 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
12706 }
12707
12708 // packages/dataviews/node_modules/date-fns/isValid.js
12709 function isValid(date) {
12710 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
12711 }
12712
12713 // packages/dataviews/node_modules/date-fns/startOfMonth.js
12714 function startOfMonth(date, options) {
12715 const _date = toDate(date, options?.in);
12716 _date.setDate(1);
12717 _date.setHours(0, 0, 0, 0);
12718 return _date;
12719 }
12720
12721 // packages/dataviews/node_modules/date-fns/startOfYear.js
12722 function startOfYear(date, options) {
12723 const date_ = toDate(date, options?.in);
12724 date_.setFullYear(date_.getFullYear(), 0, 1);
12725 date_.setHours(0, 0, 0, 0);
12726 return date_;
12727 }
12728
12729 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js
12730 var formatDistanceLocale = {
12731 lessThanXSeconds: {
12732 one: "less than a second",
12733 other: "less than {{count}} seconds"
12734 },
12735 xSeconds: {
12736 one: "1 second",
12737 other: "{{count}} seconds"
12738 },
12739 halfAMinute: "half a minute",
12740 lessThanXMinutes: {
12741 one: "less than a minute",
12742 other: "less than {{count}} minutes"
12743 },
12744 xMinutes: {
12745 one: "1 minute",
12746 other: "{{count}} minutes"
12747 },
12748 aboutXHours: {
12749 one: "about 1 hour",
12750 other: "about {{count}} hours"
12751 },
12752 xHours: {
12753 one: "1 hour",
12754 other: "{{count}} hours"
12755 },
12756 xDays: {
12757 one: "1 day",
12758 other: "{{count}} days"
12759 },
12760 aboutXWeeks: {
12761 one: "about 1 week",
12762 other: "about {{count}} weeks"
12763 },
12764 xWeeks: {
12765 one: "1 week",
12766 other: "{{count}} weeks"
12767 },
12768 aboutXMonths: {
12769 one: "about 1 month",
12770 other: "about {{count}} months"
12771 },
12772 xMonths: {
12773 one: "1 month",
12774 other: "{{count}} months"
12775 },
12776 aboutXYears: {
12777 one: "about 1 year",
12778 other: "about {{count}} years"
12779 },
12780 xYears: {
12781 one: "1 year",
12782 other: "{{count}} years"
12783 },
12784 overXYears: {
12785 one: "over 1 year",
12786 other: "over {{count}} years"
12787 },
12788 almostXYears: {
12789 one: "almost 1 year",
12790 other: "almost {{count}} years"
12791 }
12792 };
12793 var formatDistance = (token, count, options) => {
12794 let result;
12795 const tokenValue = formatDistanceLocale[token];
12796 if (typeof tokenValue === "string") {
12797 result = tokenValue;
12798 } else if (count === 1) {
12799 result = tokenValue.one;
12800 } else {
12801 result = tokenValue.other.replace("{{count}}", count.toString());
12802 }
12803 if (options?.addSuffix) {
12804 if (options.comparison && options.comparison > 0) {
12805 return "in " + result;
12806 } else {
12807 return result + " ago";
12808 }
12809 }
12810 return result;
12811 };
12812
12813 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js
12814 function buildFormatLongFn(args) {
12815 return (options = {}) => {
12816 const width = options.width ? String(options.width) : args.defaultWidth;
12817 const format6 = args.formats[width] || args.formats[args.defaultWidth];
12818 return format6;
12819 };
12820 }
12821
12822 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js
12823 var dateFormats = {
12824 full: "EEEE, MMMM do, y",
12825 long: "MMMM do, y",
12826 medium: "MMM d, y",
12827 short: "MM/dd/yyyy"
12828 };
12829 var timeFormats = {
12830 full: "h:mm:ss a zzzz",
12831 long: "h:mm:ss a z",
12832 medium: "h:mm:ss a",
12833 short: "h:mm a"
12834 };
12835 var dateTimeFormats = {
12836 full: "{{date}} 'at' {{time}}",
12837 long: "{{date}} 'at' {{time}}",
12838 medium: "{{date}}, {{time}}",
12839 short: "{{date}}, {{time}}"
12840 };
12841 var formatLong = {
12842 date: buildFormatLongFn({
12843 formats: dateFormats,
12844 defaultWidth: "full"
12845 }),
12846 time: buildFormatLongFn({
12847 formats: timeFormats,
12848 defaultWidth: "full"
12849 }),
12850 dateTime: buildFormatLongFn({
12851 formats: dateTimeFormats,
12852 defaultWidth: "full"
12853 })
12854 };
12855
12856 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js
12857 var formatRelativeLocale = {
12858 lastWeek: "'last' eeee 'at' p",
12859 yesterday: "'yesterday at' p",
12860 today: "'today at' p",
12861 tomorrow: "'tomorrow at' p",
12862 nextWeek: "eeee 'at' p",
12863 other: "P"
12864 };
12865 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
12866
12867 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js
12868 function buildLocalizeFn(args) {
12869 return (value, options) => {
12870 const context = options?.context ? String(options.context) : "standalone";
12871 let valuesArray;
12872 if (context === "formatting" && args.formattingValues) {
12873 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
12874 const width = options?.width ? String(options.width) : defaultWidth;
12875 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
12876 } else {
12877 const defaultWidth = args.defaultWidth;
12878 const width = options?.width ? String(options.width) : args.defaultWidth;
12879 valuesArray = args.values[width] || args.values[defaultWidth];
12880 }
12881 const index = args.argumentCallback ? args.argumentCallback(value) : value;
12882 return valuesArray[index];
12883 };
12884 }
12885
12886 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js
12887 var eraValues = {
12888 narrow: ["B", "A"],
12889 abbreviated: ["BC", "AD"],
12890 wide: ["Before Christ", "Anno Domini"]
12891 };
12892 var quarterValues = {
12893 narrow: ["1", "2", "3", "4"],
12894 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
12895 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
12896 };
12897 var monthValues = {
12898 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
12899 abbreviated: [
12900 "Jan",
12901 "Feb",
12902 "Mar",
12903 "Apr",
12904 "May",
12905 "Jun",
12906 "Jul",
12907 "Aug",
12908 "Sep",
12909 "Oct",
12910 "Nov",
12911 "Dec"
12912 ],
12913 wide: [
12914 "January",
12915 "February",
12916 "March",
12917 "April",
12918 "May",
12919 "June",
12920 "July",
12921 "August",
12922 "September",
12923 "October",
12924 "November",
12925 "December"
12926 ]
12927 };
12928 var dayValues = {
12929 narrow: ["S", "M", "T", "W", "T", "F", "S"],
12930 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
12931 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
12932 wide: [
12933 "Sunday",
12934 "Monday",
12935 "Tuesday",
12936 "Wednesday",
12937 "Thursday",
12938 "Friday",
12939 "Saturday"
12940 ]
12941 };
12942 var dayPeriodValues = {
12943 narrow: {
12944 am: "a",
12945 pm: "p",
12946 midnight: "mi",
12947 noon: "n",
12948 morning: "morning",
12949 afternoon: "afternoon",
12950 evening: "evening",
12951 night: "night"
12952 },
12953 abbreviated: {
12954 am: "AM",
12955 pm: "PM",
12956 midnight: "midnight",
12957 noon: "noon",
12958 morning: "morning",
12959 afternoon: "afternoon",
12960 evening: "evening",
12961 night: "night"
12962 },
12963 wide: {
12964 am: "a.m.",
12965 pm: "p.m.",
12966 midnight: "midnight",
12967 noon: "noon",
12968 morning: "morning",
12969 afternoon: "afternoon",
12970 evening: "evening",
12971 night: "night"
12972 }
12973 };
12974 var formattingDayPeriodValues = {
12975 narrow: {
12976 am: "a",
12977 pm: "p",
12978 midnight: "mi",
12979 noon: "n",
12980 morning: "in the morning",
12981 afternoon: "in the afternoon",
12982 evening: "in the evening",
12983 night: "at night"
12984 },
12985 abbreviated: {
12986 am: "AM",
12987 pm: "PM",
12988 midnight: "midnight",
12989 noon: "noon",
12990 morning: "in the morning",
12991 afternoon: "in the afternoon",
12992 evening: "in the evening",
12993 night: "at night"
12994 },
12995 wide: {
12996 am: "a.m.",
12997 pm: "p.m.",
12998 midnight: "midnight",
12999 noon: "noon",
13000 morning: "in the morning",
13001 afternoon: "in the afternoon",
13002 evening: "in the evening",
13003 night: "at night"
13004 }
13005 };
13006 var ordinalNumber = (dirtyNumber, _options) => {
13007 const number = Number(dirtyNumber);
13008 const rem100 = number % 100;
13009 if (rem100 > 20 || rem100 < 10) {
13010 switch (rem100 % 10) {
13011 case 1:
13012 return number + "st";
13013 case 2:
13014 return number + "nd";
13015 case 3:
13016 return number + "rd";
13017 }
13018 }
13019 return number + "th";
13020 };
13021 var localize = {
13022 ordinalNumber,
13023 era: buildLocalizeFn({
13024 values: eraValues,
13025 defaultWidth: "wide"
13026 }),
13027 quarter: buildLocalizeFn({
13028 values: quarterValues,
13029 defaultWidth: "wide",
13030 argumentCallback: (quarter) => quarter - 1
13031 }),
13032 month: buildLocalizeFn({
13033 values: monthValues,
13034 defaultWidth: "wide"
13035 }),
13036 day: buildLocalizeFn({
13037 values: dayValues,
13038 defaultWidth: "wide"
13039 }),
13040 dayPeriod: buildLocalizeFn({
13041 values: dayPeriodValues,
13042 defaultWidth: "wide",
13043 formattingValues: formattingDayPeriodValues,
13044 defaultFormattingWidth: "wide"
13045 })
13046 };
13047
13048 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js
13049 function buildMatchFn(args) {
13050 return (string, options = {}) => {
13051 const width = options.width;
13052 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
13053 const matchResult = string.match(matchPattern);
13054 if (!matchResult) {
13055 return null;
13056 }
13057 const matchedString = matchResult[0];
13058 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
13059 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
13060 // [TODO] -- I challenge you to fix the type
13061 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
13062 );
13063 let value;
13064 value = args.valueCallback ? args.valueCallback(key) : key;
13065 value = options.valueCallback ? (
13066 // [TODO] -- I challenge you to fix the type
13067 options.valueCallback(value)
13068 ) : value;
13069 const rest = string.slice(matchedString.length);
13070 return { value, rest };
13071 };
13072 }
13073 function findKey(object, predicate) {
13074 for (const key in object) {
13075 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
13076 return key;
13077 }
13078 }
13079 return void 0;
13080 }
13081 function findIndex(array, predicate) {
13082 for (let key = 0; key < array.length; key++) {
13083 if (predicate(array[key])) {
13084 return key;
13085 }
13086 }
13087 return void 0;
13088 }
13089
13090 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
13091 function buildMatchPatternFn(args) {
13092 return (string, options = {}) => {
13093 const matchResult = string.match(args.matchPattern);
13094 if (!matchResult) return null;
13095 const matchedString = matchResult[0];
13096 const parseResult = string.match(args.parsePattern);
13097 if (!parseResult) return null;
13098 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
13099 value = options.valueCallback ? options.valueCallback(value) : value;
13100 const rest = string.slice(matchedString.length);
13101 return { value, rest };
13102 };
13103 }
13104
13105 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js
13106 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
13107 var parseOrdinalNumberPattern = /\d+/i;
13108 var matchEraPatterns = {
13109 narrow: /^(b|a)/i,
13110 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
13111 wide: /^(before christ|before common era|anno domini|common era)/i
13112 };
13113 var parseEraPatterns = {
13114 any: [/^b/i, /^(a|c)/i]
13115 };
13116 var matchQuarterPatterns = {
13117 narrow: /^[1234]/i,
13118 abbreviated: /^q[1234]/i,
13119 wide: /^[1234](th|st|nd|rd)? quarter/i
13120 };
13121 var parseQuarterPatterns = {
13122 any: [/1/i, /2/i, /3/i, /4/i]
13123 };
13124 var matchMonthPatterns = {
13125 narrow: /^[jfmasond]/i,
13126 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
13127 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
13128 };
13129 var parseMonthPatterns = {
13130 narrow: [
13131 /^j/i,
13132 /^f/i,
13133 /^m/i,
13134 /^a/i,
13135 /^m/i,
13136 /^j/i,
13137 /^j/i,
13138 /^a/i,
13139 /^s/i,
13140 /^o/i,
13141 /^n/i,
13142 /^d/i
13143 ],
13144 any: [
13145 /^ja/i,
13146 /^f/i,
13147 /^mar/i,
13148 /^ap/i,
13149 /^may/i,
13150 /^jun/i,
13151 /^jul/i,
13152 /^au/i,
13153 /^s/i,
13154 /^o/i,
13155 /^n/i,
13156 /^d/i
13157 ]
13158 };
13159 var matchDayPatterns = {
13160 narrow: /^[smtwf]/i,
13161 short: /^(su|mo|tu|we|th|fr|sa)/i,
13162 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
13163 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
13164 };
13165 var parseDayPatterns = {
13166 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
13167 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
13168 };
13169 var matchDayPeriodPatterns = {
13170 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
13171 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
13172 };
13173 var parseDayPeriodPatterns = {
13174 any: {
13175 am: /^a/i,
13176 pm: /^p/i,
13177 midnight: /^mi/i,
13178 noon: /^no/i,
13179 morning: /morning/i,
13180 afternoon: /afternoon/i,
13181 evening: /evening/i,
13182 night: /night/i
13183 }
13184 };
13185 var match = {
13186 ordinalNumber: buildMatchPatternFn({
13187 matchPattern: matchOrdinalNumberPattern,
13188 parsePattern: parseOrdinalNumberPattern,
13189 valueCallback: (value) => parseInt(value, 10)
13190 }),
13191 era: buildMatchFn({
13192 matchPatterns: matchEraPatterns,
13193 defaultMatchWidth: "wide",
13194 parsePatterns: parseEraPatterns,
13195 defaultParseWidth: "any"
13196 }),
13197 quarter: buildMatchFn({
13198 matchPatterns: matchQuarterPatterns,
13199 defaultMatchWidth: "wide",
13200 parsePatterns: parseQuarterPatterns,
13201 defaultParseWidth: "any",
13202 valueCallback: (index) => index + 1
13203 }),
13204 month: buildMatchFn({
13205 matchPatterns: matchMonthPatterns,
13206 defaultMatchWidth: "wide",
13207 parsePatterns: parseMonthPatterns,
13208 defaultParseWidth: "any"
13209 }),
13210 day: buildMatchFn({
13211 matchPatterns: matchDayPatterns,
13212 defaultMatchWidth: "wide",
13213 parsePatterns: parseDayPatterns,
13214 defaultParseWidth: "any"
13215 }),
13216 dayPeriod: buildMatchFn({
13217 matchPatterns: matchDayPeriodPatterns,
13218 defaultMatchWidth: "any",
13219 parsePatterns: parseDayPeriodPatterns,
13220 defaultParseWidth: "any"
13221 })
13222 };
13223
13224 // packages/dataviews/node_modules/date-fns/locale/en-US.js
13225 var enUS = {
13226 code: "en-US",
13227 formatDistance,
13228 formatLong,
13229 formatRelative,
13230 localize,
13231 match,
13232 options: {
13233 weekStartsOn: 0,
13234 firstWeekContainsDate: 1
13235 }
13236 };
13237
13238 // packages/dataviews/node_modules/date-fns/getDayOfYear.js
13239 function getDayOfYear(date, options) {
13240 const _date = toDate(date, options?.in);
13241 const diff = differenceInCalendarDays(_date, startOfYear(_date));
13242 const dayOfYear = diff + 1;
13243 return dayOfYear;
13244 }
13245
13246 // packages/dataviews/node_modules/date-fns/getISOWeek.js
13247 function getISOWeek(date, options) {
13248 const _date = toDate(date, options?.in);
13249 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
13250 return Math.round(diff / millisecondsInWeek) + 1;
13251 }
13252
13253 // packages/dataviews/node_modules/date-fns/getWeekYear.js
13254 function getWeekYear(date, options) {
13255 const _date = toDate(date, options?.in);
13256 const year = _date.getFullYear();
13257 const defaultOptions2 = getDefaultOptions();
13258 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
13259 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
13260 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
13261 firstWeekOfNextYear.setHours(0, 0, 0, 0);
13262 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
13263 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
13264 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
13265 firstWeekOfThisYear.setHours(0, 0, 0, 0);
13266 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
13267 if (+_date >= +startOfNextYear) {
13268 return year + 1;
13269 } else if (+_date >= +startOfThisYear) {
13270 return year;
13271 } else {
13272 return year - 1;
13273 }
13274 }
13275
13276 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js
13277 function startOfWeekYear(date, options) {
13278 const defaultOptions2 = getDefaultOptions();
13279 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
13280 const year = getWeekYear(date, options);
13281 const firstWeek = constructFrom(options?.in || date, 0);
13282 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
13283 firstWeek.setHours(0, 0, 0, 0);
13284 const _date = startOfWeek(firstWeek, options);
13285 return _date;
13286 }
13287
13288 // packages/dataviews/node_modules/date-fns/getWeek.js
13289 function getWeek(date, options) {
13290 const _date = toDate(date, options?.in);
13291 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
13292 return Math.round(diff / millisecondsInWeek) + 1;
13293 }
13294
13295 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js
13296 function addLeadingZeros(number, targetLength) {
13297 const sign = number < 0 ? "-" : "";
13298 const output = Math.abs(number).toString().padStart(targetLength, "0");
13299 return sign + output;
13300 }
13301
13302 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js
13303 var lightFormatters = {
13304 // Year
13305 y(date, token) {
13306 const signedYear = date.getFullYear();
13307 const year = signedYear > 0 ? signedYear : 1 - signedYear;
13308 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
13309 },
13310 // Month
13311 M(date, token) {
13312 const month = date.getMonth();
13313 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
13314 },
13315 // Day of the month
13316 d(date, token) {
13317 return addLeadingZeros(date.getDate(), token.length);
13318 },
13319 // AM or PM
13320 a(date, token) {
13321 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
13322 switch (token) {
13323 case "a":
13324 case "aa":
13325 return dayPeriodEnumValue.toUpperCase();
13326 case "aaa":
13327 return dayPeriodEnumValue;
13328 case "aaaaa":
13329 return dayPeriodEnumValue[0];
13330 case "aaaa":
13331 default:
13332 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
13333 }
13334 },
13335 // Hour [1-12]
13336 h(date, token) {
13337 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
13338 },
13339 // Hour [0-23]
13340 H(date, token) {
13341 return addLeadingZeros(date.getHours(), token.length);
13342 },
13343 // Minute
13344 m(date, token) {
13345 return addLeadingZeros(date.getMinutes(), token.length);
13346 },
13347 // Second
13348 s(date, token) {
13349 return addLeadingZeros(date.getSeconds(), token.length);
13350 },
13351 // Fraction of second
13352 S(date, token) {
13353 const numberOfDigits = token.length;
13354 const milliseconds = date.getMilliseconds();
13355 const fractionalSeconds = Math.trunc(
13356 milliseconds * Math.pow(10, numberOfDigits - 3)
13357 );
13358 return addLeadingZeros(fractionalSeconds, token.length);
13359 }
13360 };
13361
13362 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js
13363 var dayPeriodEnum = {
13364 am: "am",
13365 pm: "pm",
13366 midnight: "midnight",
13367 noon: "noon",
13368 morning: "morning",
13369 afternoon: "afternoon",
13370 evening: "evening",
13371 night: "night"
13372 };
13373 var formatters = {
13374 // Era
13375 G: function(date, token, localize2) {
13376 const era = date.getFullYear() > 0 ? 1 : 0;
13377 switch (token) {
13378 // AD, BC
13379 case "G":
13380 case "GG":
13381 case "GGG":
13382 return localize2.era(era, { width: "abbreviated" });
13383 // A, B
13384 case "GGGGG":
13385 return localize2.era(era, { width: "narrow" });
13386 // Anno Domini, Before Christ
13387 case "GGGG":
13388 default:
13389 return localize2.era(era, { width: "wide" });
13390 }
13391 },
13392 // Year
13393 y: function(date, token, localize2) {
13394 if (token === "yo") {
13395 const signedYear = date.getFullYear();
13396 const year = signedYear > 0 ? signedYear : 1 - signedYear;
13397 return localize2.ordinalNumber(year, { unit: "year" });
13398 }
13399 return lightFormatters.y(date, token);
13400 },
13401 // Local week-numbering year
13402 Y: function(date, token, localize2, options) {
13403 const signedWeekYear = getWeekYear(date, options);
13404 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
13405 if (token === "YY") {
13406 const twoDigitYear = weekYear % 100;
13407 return addLeadingZeros(twoDigitYear, 2);
13408 }
13409 if (token === "Yo") {
13410 return localize2.ordinalNumber(weekYear, { unit: "year" });
13411 }
13412 return addLeadingZeros(weekYear, token.length);
13413 },
13414 // ISO week-numbering year
13415 R: function(date, token) {
13416 const isoWeekYear = getISOWeekYear(date);
13417 return addLeadingZeros(isoWeekYear, token.length);
13418 },
13419 // Extended year. This is a single number designating the year of this calendar system.
13420 // The main difference between `y` and `u` localizers are B.C. years:
13421 // | Year | `y` | `u` |
13422 // |------|-----|-----|
13423 // | AC 1 | 1 | 1 |
13424 // | BC 1 | 1 | 0 |
13425 // | BC 2 | 2 | -1 |
13426 // Also `yy` always returns the last two digits of a year,
13427 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
13428 u: function(date, token) {
13429 const year = date.getFullYear();
13430 return addLeadingZeros(year, token.length);
13431 },
13432 // Quarter
13433 Q: function(date, token, localize2) {
13434 const quarter = Math.ceil((date.getMonth() + 1) / 3);
13435 switch (token) {
13436 // 1, 2, 3, 4
13437 case "Q":
13438 return String(quarter);
13439 // 01, 02, 03, 04
13440 case "QQ":
13441 return addLeadingZeros(quarter, 2);
13442 // 1st, 2nd, 3rd, 4th
13443 case "Qo":
13444 return localize2.ordinalNumber(quarter, { unit: "quarter" });
13445 // Q1, Q2, Q3, Q4
13446 case "QQQ":
13447 return localize2.quarter(quarter, {
13448 width: "abbreviated",
13449 context: "formatting"
13450 });
13451 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
13452 case "QQQQQ":
13453 return localize2.quarter(quarter, {
13454 width: "narrow",
13455 context: "formatting"
13456 });
13457 // 1st quarter, 2nd quarter, ...
13458 case "QQQQ":
13459 default:
13460 return localize2.quarter(quarter, {
13461 width: "wide",
13462 context: "formatting"
13463 });
13464 }
13465 },
13466 // Stand-alone quarter
13467 q: function(date, token, localize2) {
13468 const quarter = Math.ceil((date.getMonth() + 1) / 3);
13469 switch (token) {
13470 // 1, 2, 3, 4
13471 case "q":
13472 return String(quarter);
13473 // 01, 02, 03, 04
13474 case "qq":
13475 return addLeadingZeros(quarter, 2);
13476 // 1st, 2nd, 3rd, 4th
13477 case "qo":
13478 return localize2.ordinalNumber(quarter, { unit: "quarter" });
13479 // Q1, Q2, Q3, Q4
13480 case "qqq":
13481 return localize2.quarter(quarter, {
13482 width: "abbreviated",
13483 context: "standalone"
13484 });
13485 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
13486 case "qqqqq":
13487 return localize2.quarter(quarter, {
13488 width: "narrow",
13489 context: "standalone"
13490 });
13491 // 1st quarter, 2nd quarter, ...
13492 case "qqqq":
13493 default:
13494 return localize2.quarter(quarter, {
13495 width: "wide",
13496 context: "standalone"
13497 });
13498 }
13499 },
13500 // Month
13501 M: function(date, token, localize2) {
13502 const month = date.getMonth();
13503 switch (token) {
13504 case "M":
13505 case "MM":
13506 return lightFormatters.M(date, token);
13507 // 1st, 2nd, ..., 12th
13508 case "Mo":
13509 return localize2.ordinalNumber(month + 1, { unit: "month" });
13510 // Jan, Feb, ..., Dec
13511 case "MMM":
13512 return localize2.month(month, {
13513 width: "abbreviated",
13514 context: "formatting"
13515 });
13516 // J, F, ..., D
13517 case "MMMMM":
13518 return localize2.month(month, {
13519 width: "narrow",
13520 context: "formatting"
13521 });
13522 // January, February, ..., December
13523 case "MMMM":
13524 default:
13525 return localize2.month(month, { width: "wide", context: "formatting" });
13526 }
13527 },
13528 // Stand-alone month
13529 L: function(date, token, localize2) {
13530 const month = date.getMonth();
13531 switch (token) {
13532 // 1, 2, ..., 12
13533 case "L":
13534 return String(month + 1);
13535 // 01, 02, ..., 12
13536 case "LL":
13537 return addLeadingZeros(month + 1, 2);
13538 // 1st, 2nd, ..., 12th
13539 case "Lo":
13540 return localize2.ordinalNumber(month + 1, { unit: "month" });
13541 // Jan, Feb, ..., Dec
13542 case "LLL":
13543 return localize2.month(month, {
13544 width: "abbreviated",
13545 context: "standalone"
13546 });
13547 // J, F, ..., D
13548 case "LLLLL":
13549 return localize2.month(month, {
13550 width: "narrow",
13551 context: "standalone"
13552 });
13553 // January, February, ..., December
13554 case "LLLL":
13555 default:
13556 return localize2.month(month, { width: "wide", context: "standalone" });
13557 }
13558 },
13559 // Local week of year
13560 w: function(date, token, localize2, options) {
13561 const week = getWeek(date, options);
13562 if (token === "wo") {
13563 return localize2.ordinalNumber(week, { unit: "week" });
13564 }
13565 return addLeadingZeros(week, token.length);
13566 },
13567 // ISO week of year
13568 I: function(date, token, localize2) {
13569 const isoWeek = getISOWeek(date);
13570 if (token === "Io") {
13571 return localize2.ordinalNumber(isoWeek, { unit: "week" });
13572 }
13573 return addLeadingZeros(isoWeek, token.length);
13574 },
13575 // Day of the month
13576 d: function(date, token, localize2) {
13577 if (token === "do") {
13578 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
13579 }
13580 return lightFormatters.d(date, token);
13581 },
13582 // Day of year
13583 D: function(date, token, localize2) {
13584 const dayOfYear = getDayOfYear(date);
13585 if (token === "Do") {
13586 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
13587 }
13588 return addLeadingZeros(dayOfYear, token.length);
13589 },
13590 // Day of week
13591 E: function(date, token, localize2) {
13592 const dayOfWeek = date.getDay();
13593 switch (token) {
13594 // Tue
13595 case "E":
13596 case "EE":
13597 case "EEE":
13598 return localize2.day(dayOfWeek, {
13599 width: "abbreviated",
13600 context: "formatting"
13601 });
13602 // T
13603 case "EEEEE":
13604 return localize2.day(dayOfWeek, {
13605 width: "narrow",
13606 context: "formatting"
13607 });
13608 // Tu
13609 case "EEEEEE":
13610 return localize2.day(dayOfWeek, {
13611 width: "short",
13612 context: "formatting"
13613 });
13614 // Tuesday
13615 case "EEEE":
13616 default:
13617 return localize2.day(dayOfWeek, {
13618 width: "wide",
13619 context: "formatting"
13620 });
13621 }
13622 },
13623 // Local day of week
13624 e: function(date, token, localize2, options) {
13625 const dayOfWeek = date.getDay();
13626 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
13627 switch (token) {
13628 // Numerical value (Nth day of week with current locale or weekStartsOn)
13629 case "e":
13630 return String(localDayOfWeek);
13631 // Padded numerical value
13632 case "ee":
13633 return addLeadingZeros(localDayOfWeek, 2);
13634 // 1st, 2nd, ..., 7th
13635 case "eo":
13636 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
13637 case "eee":
13638 return localize2.day(dayOfWeek, {
13639 width: "abbreviated",
13640 context: "formatting"
13641 });
13642 // T
13643 case "eeeee":
13644 return localize2.day(dayOfWeek, {
13645 width: "narrow",
13646 context: "formatting"
13647 });
13648 // Tu
13649 case "eeeeee":
13650 return localize2.day(dayOfWeek, {
13651 width: "short",
13652 context: "formatting"
13653 });
13654 // Tuesday
13655 case "eeee":
13656 default:
13657 return localize2.day(dayOfWeek, {
13658 width: "wide",
13659 context: "formatting"
13660 });
13661 }
13662 },
13663 // Stand-alone local day of week
13664 c: function(date, token, localize2, options) {
13665 const dayOfWeek = date.getDay();
13666 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
13667 switch (token) {
13668 // Numerical value (same as in `e`)
13669 case "c":
13670 return String(localDayOfWeek);
13671 // Padded numerical value
13672 case "cc":
13673 return addLeadingZeros(localDayOfWeek, token.length);
13674 // 1st, 2nd, ..., 7th
13675 case "co":
13676 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
13677 case "ccc":
13678 return localize2.day(dayOfWeek, {
13679 width: "abbreviated",
13680 context: "standalone"
13681 });
13682 // T
13683 case "ccccc":
13684 return localize2.day(dayOfWeek, {
13685 width: "narrow",
13686 context: "standalone"
13687 });
13688 // Tu
13689 case "cccccc":
13690 return localize2.day(dayOfWeek, {
13691 width: "short",
13692 context: "standalone"
13693 });
13694 // Tuesday
13695 case "cccc":
13696 default:
13697 return localize2.day(dayOfWeek, {
13698 width: "wide",
13699 context: "standalone"
13700 });
13701 }
13702 },
13703 // ISO day of week
13704 i: function(date, token, localize2) {
13705 const dayOfWeek = date.getDay();
13706 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
13707 switch (token) {
13708 // 2
13709 case "i":
13710 return String(isoDayOfWeek);
13711 // 02
13712 case "ii":
13713 return addLeadingZeros(isoDayOfWeek, token.length);
13714 // 2nd
13715 case "io":
13716 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
13717 // Tue
13718 case "iii":
13719 return localize2.day(dayOfWeek, {
13720 width: "abbreviated",
13721 context: "formatting"
13722 });
13723 // T
13724 case "iiiii":
13725 return localize2.day(dayOfWeek, {
13726 width: "narrow",
13727 context: "formatting"
13728 });
13729 // Tu
13730 case "iiiiii":
13731 return localize2.day(dayOfWeek, {
13732 width: "short",
13733 context: "formatting"
13734 });
13735 // Tuesday
13736 case "iiii":
13737 default:
13738 return localize2.day(dayOfWeek, {
13739 width: "wide",
13740 context: "formatting"
13741 });
13742 }
13743 },
13744 // AM or PM
13745 a: function(date, token, localize2) {
13746 const hours = date.getHours();
13747 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
13748 switch (token) {
13749 case "a":
13750 case "aa":
13751 return localize2.dayPeriod(dayPeriodEnumValue, {
13752 width: "abbreviated",
13753 context: "formatting"
13754 });
13755 case "aaa":
13756 return localize2.dayPeriod(dayPeriodEnumValue, {
13757 width: "abbreviated",
13758 context: "formatting"
13759 }).toLowerCase();
13760 case "aaaaa":
13761 return localize2.dayPeriod(dayPeriodEnumValue, {
13762 width: "narrow",
13763 context: "formatting"
13764 });
13765 case "aaaa":
13766 default:
13767 return localize2.dayPeriod(dayPeriodEnumValue, {
13768 width: "wide",
13769 context: "formatting"
13770 });
13771 }
13772 },
13773 // AM, PM, midnight, noon
13774 b: function(date, token, localize2) {
13775 const hours = date.getHours();
13776 let dayPeriodEnumValue;
13777 if (hours === 12) {
13778 dayPeriodEnumValue = dayPeriodEnum.noon;
13779 } else if (hours === 0) {
13780 dayPeriodEnumValue = dayPeriodEnum.midnight;
13781 } else {
13782 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
13783 }
13784 switch (token) {
13785 case "b":
13786 case "bb":
13787 return localize2.dayPeriod(dayPeriodEnumValue, {
13788 width: "abbreviated",
13789 context: "formatting"
13790 });
13791 case "bbb":
13792 return localize2.dayPeriod(dayPeriodEnumValue, {
13793 width: "abbreviated",
13794 context: "formatting"
13795 }).toLowerCase();
13796 case "bbbbb":
13797 return localize2.dayPeriod(dayPeriodEnumValue, {
13798 width: "narrow",
13799 context: "formatting"
13800 });
13801 case "bbbb":
13802 default:
13803 return localize2.dayPeriod(dayPeriodEnumValue, {
13804 width: "wide",
13805 context: "formatting"
13806 });
13807 }
13808 },
13809 // in the morning, in the afternoon, in the evening, at night
13810 B: function(date, token, localize2) {
13811 const hours = date.getHours();
13812 let dayPeriodEnumValue;
13813 if (hours >= 17) {
13814 dayPeriodEnumValue = dayPeriodEnum.evening;
13815 } else if (hours >= 12) {
13816 dayPeriodEnumValue = dayPeriodEnum.afternoon;
13817 } else if (hours >= 4) {
13818 dayPeriodEnumValue = dayPeriodEnum.morning;
13819 } else {
13820 dayPeriodEnumValue = dayPeriodEnum.night;
13821 }
13822 switch (token) {
13823 case "B":
13824 case "BB":
13825 case "BBB":
13826 return localize2.dayPeriod(dayPeriodEnumValue, {
13827 width: "abbreviated",
13828 context: "formatting"
13829 });
13830 case "BBBBB":
13831 return localize2.dayPeriod(dayPeriodEnumValue, {
13832 width: "narrow",
13833 context: "formatting"
13834 });
13835 case "BBBB":
13836 default:
13837 return localize2.dayPeriod(dayPeriodEnumValue, {
13838 width: "wide",
13839 context: "formatting"
13840 });
13841 }
13842 },
13843 // Hour [1-12]
13844 h: function(date, token, localize2) {
13845 if (token === "ho") {
13846 let hours = date.getHours() % 12;
13847 if (hours === 0) hours = 12;
13848 return localize2.ordinalNumber(hours, { unit: "hour" });
13849 }
13850 return lightFormatters.h(date, token);
13851 },
13852 // Hour [0-23]
13853 H: function(date, token, localize2) {
13854 if (token === "Ho") {
13855 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
13856 }
13857 return lightFormatters.H(date, token);
13858 },
13859 // Hour [0-11]
13860 K: function(date, token, localize2) {
13861 const hours = date.getHours() % 12;
13862 if (token === "Ko") {
13863 return localize2.ordinalNumber(hours, { unit: "hour" });
13864 }
13865 return addLeadingZeros(hours, token.length);
13866 },
13867 // Hour [1-24]
13868 k: function(date, token, localize2) {
13869 let hours = date.getHours();
13870 if (hours === 0) hours = 24;
13871 if (token === "ko") {
13872 return localize2.ordinalNumber(hours, { unit: "hour" });
13873 }
13874 return addLeadingZeros(hours, token.length);
13875 },
13876 // Minute
13877 m: function(date, token, localize2) {
13878 if (token === "mo") {
13879 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
13880 }
13881 return lightFormatters.m(date, token);
13882 },
13883 // Second
13884 s: function(date, token, localize2) {
13885 if (token === "so") {
13886 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
13887 }
13888 return lightFormatters.s(date, token);
13889 },
13890 // Fraction of second
13891 S: function(date, token) {
13892 return lightFormatters.S(date, token);
13893 },
13894 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
13895 X: function(date, token, _localize) {
13896 const timezoneOffset = date.getTimezoneOffset();
13897 if (timezoneOffset === 0) {
13898 return "Z";
13899 }
13900 switch (token) {
13901 // Hours and optional minutes
13902 case "X":
13903 return formatTimezoneWithOptionalMinutes(timezoneOffset);
13904 // Hours, minutes and optional seconds without `:` delimiter
13905 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13906 // so this token always has the same output as `XX`
13907 case "XXXX":
13908 case "XX":
13909 return formatTimezone(timezoneOffset);
13910 // Hours, minutes and optional seconds with `:` delimiter
13911 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13912 // so this token always has the same output as `XXX`
13913 case "XXXXX":
13914 case "XXX":
13915 // Hours and minutes with `:` delimiter
13916 default:
13917 return formatTimezone(timezoneOffset, ":");
13918 }
13919 },
13920 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
13921 x: function(date, token, _localize) {
13922 const timezoneOffset = date.getTimezoneOffset();
13923 switch (token) {
13924 // Hours and optional minutes
13925 case "x":
13926 return formatTimezoneWithOptionalMinutes(timezoneOffset);
13927 // Hours, minutes and optional seconds without `:` delimiter
13928 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13929 // so this token always has the same output as `xx`
13930 case "xxxx":
13931 case "xx":
13932 return formatTimezone(timezoneOffset);
13933 // Hours, minutes and optional seconds with `:` delimiter
13934 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
13935 // so this token always has the same output as `xxx`
13936 case "xxxxx":
13937 case "xxx":
13938 // Hours and minutes with `:` delimiter
13939 default:
13940 return formatTimezone(timezoneOffset, ":");
13941 }
13942 },
13943 // Timezone (GMT)
13944 O: function(date, token, _localize) {
13945 const timezoneOffset = date.getTimezoneOffset();
13946 switch (token) {
13947 // Short
13948 case "O":
13949 case "OO":
13950 case "OOO":
13951 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
13952 // Long
13953 case "OOOO":
13954 default:
13955 return "GMT" + formatTimezone(timezoneOffset, ":");
13956 }
13957 },
13958 // Timezone (specific non-location)
13959 z: function(date, token, _localize) {
13960 const timezoneOffset = date.getTimezoneOffset();
13961 switch (token) {
13962 // Short
13963 case "z":
13964 case "zz":
13965 case "zzz":
13966 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
13967 // Long
13968 case "zzzz":
13969 default:
13970 return "GMT" + formatTimezone(timezoneOffset, ":");
13971 }
13972 },
13973 // Seconds timestamp
13974 t: function(date, token, _localize) {
13975 const timestamp = Math.trunc(+date / 1e3);
13976 return addLeadingZeros(timestamp, token.length);
13977 },
13978 // Milliseconds timestamp
13979 T: function(date, token, _localize) {
13980 return addLeadingZeros(+date, token.length);
13981 }
13982 };
13983 function formatTimezoneShort(offset, delimiter = "") {
13984 const sign = offset > 0 ? "-" : "+";
13985 const absOffset = Math.abs(offset);
13986 const hours = Math.trunc(absOffset / 60);
13987 const minutes = absOffset % 60;
13988 if (minutes === 0) {
13989 return sign + String(hours);
13990 }
13991 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
13992 }
13993 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
13994 if (offset % 60 === 0) {
13995 const sign = offset > 0 ? "-" : "+";
13996 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
13997 }
13998 return formatTimezone(offset, delimiter);
13999 }
14000 function formatTimezone(offset, delimiter = "") {
14001 const sign = offset > 0 ? "-" : "+";
14002 const absOffset = Math.abs(offset);
14003 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
14004 const minutes = addLeadingZeros(absOffset % 60, 2);
14005 return sign + hours + delimiter + minutes;
14006 }
14007
14008 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js
14009 var dateLongFormatter = (pattern, formatLong2) => {
14010 switch (pattern) {
14011 case "P":
14012 return formatLong2.date({ width: "short" });
14013 case "PP":
14014 return formatLong2.date({ width: "medium" });
14015 case "PPP":
14016 return formatLong2.date({ width: "long" });
14017 case "PPPP":
14018 default:
14019 return formatLong2.date({ width: "full" });
14020 }
14021 };
14022 var timeLongFormatter = (pattern, formatLong2) => {
14023 switch (pattern) {
14024 case "p":
14025 return formatLong2.time({ width: "short" });
14026 case "pp":
14027 return formatLong2.time({ width: "medium" });
14028 case "ppp":
14029 return formatLong2.time({ width: "long" });
14030 case "pppp":
14031 default:
14032 return formatLong2.time({ width: "full" });
14033 }
14034 };
14035 var dateTimeLongFormatter = (pattern, formatLong2) => {
14036 const matchResult = pattern.match(/(P+)(p+)?/) || [];
14037 const datePattern = matchResult[1];
14038 const timePattern = matchResult[2];
14039 if (!timePattern) {
14040 return dateLongFormatter(pattern, formatLong2);
14041 }
14042 let dateTimeFormat;
14043 switch (datePattern) {
14044 case "P":
14045 dateTimeFormat = formatLong2.dateTime({ width: "short" });
14046 break;
14047 case "PP":
14048 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
14049 break;
14050 case "PPP":
14051 dateTimeFormat = formatLong2.dateTime({ width: "long" });
14052 break;
14053 case "PPPP":
14054 default:
14055 dateTimeFormat = formatLong2.dateTime({ width: "full" });
14056 break;
14057 }
14058 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
14059 };
14060 var longFormatters = {
14061 p: timeLongFormatter,
14062 P: dateTimeLongFormatter
14063 };
14064
14065 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js
14066 var dayOfYearTokenRE = /^D+$/;
14067 var weekYearTokenRE = /^Y+$/;
14068 var throwTokens = ["D", "DD", "YY", "YYYY"];
14069 function isProtectedDayOfYearToken(token) {
14070 return dayOfYearTokenRE.test(token);
14071 }
14072 function isProtectedWeekYearToken(token) {
14073 return weekYearTokenRE.test(token);
14074 }
14075 function warnOrThrowProtectedError(token, format6, input) {
14076 const _message = message(token, format6, input);
14077 console.warn(_message);
14078 if (throwTokens.includes(token)) throw new RangeError(_message);
14079 }
14080 function message(token, format6, input) {
14081 const subject = token[0] === "Y" ? "years" : "days of the month";
14082 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`;
14083 }
14084
14085 // packages/dataviews/node_modules/date-fns/format.js
14086 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
14087 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
14088 var escapedStringRegExp = /^'([^]*?)'?$/;
14089 var doubleQuoteRegExp = /''/g;
14090 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
14091 function format(date, formatStr, options) {
14092 const defaultOptions2 = getDefaultOptions();
14093 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
14094 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
14095 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
14096 const originalDate = toDate(date, options?.in);
14097 if (!isValid(originalDate)) {
14098 throw new RangeError("Invalid time value");
14099 }
14100 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
14101 const firstCharacter = substring[0];
14102 if (firstCharacter === "p" || firstCharacter === "P") {
14103 const longFormatter = longFormatters[firstCharacter];
14104 return longFormatter(substring, locale.formatLong);
14105 }
14106 return substring;
14107 }).join("").match(formattingTokensRegExp).map((substring) => {
14108 if (substring === "''") {
14109 return { isToken: false, value: "'" };
14110 }
14111 const firstCharacter = substring[0];
14112 if (firstCharacter === "'") {
14113 return { isToken: false, value: cleanEscapedString(substring) };
14114 }
14115 if (formatters[firstCharacter]) {
14116 return { isToken: true, value: substring };
14117 }
14118 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
14119 throw new RangeError(
14120 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
14121 );
14122 }
14123 return { isToken: false, value: substring };
14124 });
14125 if (locale.localize.preprocessor) {
14126 parts = locale.localize.preprocessor(originalDate, parts);
14127 }
14128 const formatterOptions = {
14129 firstWeekContainsDate,
14130 weekStartsOn,
14131 locale
14132 };
14133 return parts.map((part) => {
14134 if (!part.isToken) return part.value;
14135 const token = part.value;
14136 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
14137 warnOrThrowProtectedError(token, formatStr, String(date));
14138 }
14139 const formatter = formatters[token[0]];
14140 return formatter(originalDate, token, locale.localize, formatterOptions);
14141 }).join("");
14142 }
14143 function cleanEscapedString(input) {
14144 const matched = input.match(escapedStringRegExp);
14145 if (!matched) {
14146 return input;
14147 }
14148 return matched[1].replace(doubleQuoteRegExp, "'");
14149 }
14150
14151 // packages/dataviews/node_modules/date-fns/subDays.js
14152 function subDays(date, amount, options) {
14153 return addDays(date, -amount, options);
14154 }
14155
14156 // packages/dataviews/node_modules/date-fns/subMonths.js
14157 function subMonths(date, amount, options) {
14158 return addMonths(date, -amount, options);
14159 }
14160
14161 // packages/dataviews/node_modules/date-fns/subWeeks.js
14162 function subWeeks(date, amount, options) {
14163 return addWeeks(date, -amount, options);
14164 }
14165
14166 // packages/dataviews/node_modules/date-fns/subYears.js
14167 function subYears(date, amount, options) {
14168 return addYears(date, -amount, options);
14169 }
14170
14171 // packages/dataviews/build-module/utils/operators.mjs
14172 var import_i18n24 = __toESM(require_i18n(), 1);
14173 var import_element46 = __toESM(require_element(), 1);
14174 var import_date = __toESM(require_date(), 1);
14175 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
14176 var filterTextWrappers = {
14177 Name: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
14178 Value: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
14179 };
14180 function getRelativeDate(value, unit) {
14181 switch (unit) {
14182 case "days":
14183 return subDays(/* @__PURE__ */ new Date(), value);
14184 case "weeks":
14185 return subWeeks(/* @__PURE__ */ new Date(), value);
14186 case "months":
14187 return subMonths(/* @__PURE__ */ new Date(), value);
14188 case "years":
14189 return subYears(/* @__PURE__ */ new Date(), value);
14190 default:
14191 return /* @__PURE__ */ new Date();
14192 }
14193 }
14194 var isNoneOperatorDefinition = {
14195 /* translators: DataViews operator name */
14196 label: (0, import_i18n24.__)("Is none of"),
14197 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14198 (0, import_i18n24.sprintf)(
14199 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
14200 (0, import_i18n24.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
14201 filter.name,
14202 activeElements.map((element) => element.label).join(", ")
14203 ),
14204 filterTextWrappers
14205 ),
14206 filter: ((item, field, filterValue) => {
14207 if (!filterValue?.length) {
14208 return true;
14209 }
14210 const fieldValue = field.getValue({ item });
14211 if (Array.isArray(fieldValue)) {
14212 return !filterValue.some(
14213 (fv) => fieldValue.includes(fv)
14214 );
14215 } else if (typeof fieldValue === "string") {
14216 return !filterValue.includes(fieldValue);
14217 }
14218 return false;
14219 }),
14220 selection: "multi"
14221 };
14222 var OPERATORS = [
14223 {
14224 name: OPERATOR_IS_ANY,
14225 /* translators: DataViews operator name */
14226 label: (0, import_i18n24.__)("Includes"),
14227 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14228 (0, import_i18n24.sprintf)(
14229 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
14230 (0, import_i18n24.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
14231 filter.name,
14232 activeElements.map((element) => element.label).join(", ")
14233 ),
14234 filterTextWrappers
14235 ),
14236 filter(item, field, filterValue) {
14237 if (!filterValue?.length) {
14238 return true;
14239 }
14240 const fieldValue = field.getValue({ item });
14241 if (Array.isArray(fieldValue)) {
14242 return filterValue.some(
14243 (fv) => fieldValue.includes(fv)
14244 );
14245 } else if (typeof fieldValue === "string") {
14246 return filterValue.includes(fieldValue);
14247 }
14248 return false;
14249 },
14250 selection: "multi"
14251 },
14252 {
14253 name: OPERATOR_IS_NONE,
14254 ...isNoneOperatorDefinition
14255 },
14256 {
14257 name: OPERATOR_IS_ALL,
14258 /* translators: DataViews operator name */
14259 label: (0, import_i18n24.__)("Includes all"),
14260 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14261 (0, import_i18n24.sprintf)(
14262 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
14263 (0, import_i18n24.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
14264 filter.name,
14265 activeElements.map((element) => element.label).join(", ")
14266 ),
14267 filterTextWrappers
14268 ),
14269 filter(item, field, filterValue) {
14270 if (!filterValue?.length) {
14271 return true;
14272 }
14273 return filterValue.every((value) => {
14274 return field.getValue({ item })?.includes(value);
14275 });
14276 },
14277 selection: "multi"
14278 },
14279 {
14280 name: OPERATOR_IS_NOT_ALL,
14281 ...isNoneOperatorDefinition
14282 },
14283 {
14284 name: OPERATOR_BETWEEN,
14285 /* translators: DataViews operator name */
14286 label: (0, import_i18n24.__)("Between (inc)"),
14287 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14288 (0, import_i18n24.sprintf)(
14289 /* 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". */
14290 (0, import_i18n24.__)(
14291 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
14292 ),
14293 filter.name,
14294 activeElements[0].label[0],
14295 activeElements[0].label[1]
14296 ),
14297 filterTextWrappers
14298 ),
14299 filter(item, field, filterValue) {
14300 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
14301 return true;
14302 }
14303 const fieldValue = field.getValue({ item });
14304 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
14305 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
14306 }
14307 return false;
14308 },
14309 selection: "custom"
14310 },
14311 {
14312 name: OPERATOR_IN_THE_PAST,
14313 /* translators: DataViews operator name */
14314 label: (0, import_i18n24.__)("In the past"),
14315 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14316 (0, import_i18n24.sprintf)(
14317 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
14318 (0, import_i18n24.__)(
14319 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
14320 ),
14321 filter.name,
14322 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
14323 ),
14324 filterTextWrappers
14325 ),
14326 filter(item, field, filterValue) {
14327 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
14328 return true;
14329 }
14330 const targetDate = getRelativeDate(
14331 filterValue.value,
14332 filterValue.unit
14333 );
14334 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
14335 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
14336 },
14337 selection: "custom"
14338 },
14339 {
14340 name: OPERATOR_OVER,
14341 /* translators: DataViews operator name */
14342 label: (0, import_i18n24.__)("Over"),
14343 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14344 (0, import_i18n24.sprintf)(
14345 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
14346 (0, import_i18n24.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
14347 filter.name,
14348 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
14349 ),
14350 filterTextWrappers
14351 ),
14352 filter(item, field, filterValue) {
14353 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
14354 return true;
14355 }
14356 const targetDate = getRelativeDate(
14357 filterValue.value,
14358 filterValue.unit
14359 );
14360 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
14361 return fieldValue < targetDate;
14362 },
14363 selection: "custom"
14364 },
14365 {
14366 name: OPERATOR_IS,
14367 /* translators: DataViews operator name */
14368 label: (0, import_i18n24.__)("Is"),
14369 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14370 (0, import_i18n24.sprintf)(
14371 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
14372 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
14373 filter.name,
14374 activeElements[0].label
14375 ),
14376 filterTextWrappers
14377 ),
14378 filter(item, field, filterValue) {
14379 return filterValue === field.getValue({ item }) || filterValue === void 0;
14380 },
14381 selection: "single"
14382 },
14383 {
14384 name: OPERATOR_IS_NOT,
14385 /* translators: DataViews operator name */
14386 label: (0, import_i18n24.__)("Is not"),
14387 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14388 (0, import_i18n24.sprintf)(
14389 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
14390 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
14391 filter.name,
14392 activeElements[0].label
14393 ),
14394 filterTextWrappers
14395 ),
14396 filter(item, field, filterValue) {
14397 return filterValue !== field.getValue({ item });
14398 },
14399 selection: "single"
14400 },
14401 {
14402 name: OPERATOR_LESS_THAN,
14403 /* translators: DataViews operator name */
14404 label: (0, import_i18n24.__)("Less than"),
14405 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14406 (0, import_i18n24.sprintf)(
14407 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
14408 (0, import_i18n24.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
14409 filter.name,
14410 activeElements[0].label
14411 ),
14412 filterTextWrappers
14413 ),
14414 filter(item, field, filterValue) {
14415 if (filterValue === void 0) {
14416 return true;
14417 }
14418 const fieldValue = field.getValue({ item });
14419 return fieldValue < filterValue;
14420 },
14421 selection: "single"
14422 },
14423 {
14424 name: OPERATOR_GREATER_THAN,
14425 /* translators: DataViews operator name */
14426 label: (0, import_i18n24.__)("Greater than"),
14427 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14428 (0, import_i18n24.sprintf)(
14429 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
14430 (0, import_i18n24.__)(
14431 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
14432 ),
14433 filter.name,
14434 activeElements[0].label
14435 ),
14436 filterTextWrappers
14437 ),
14438 filter(item, field, filterValue) {
14439 if (filterValue === void 0) {
14440 return true;
14441 }
14442 const fieldValue = field.getValue({ item });
14443 return fieldValue > filterValue;
14444 },
14445 selection: "single"
14446 },
14447 {
14448 name: OPERATOR_LESS_THAN_OR_EQUAL,
14449 /* translators: DataViews operator name */
14450 label: (0, import_i18n24.__)("Less than or equal"),
14451 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14452 (0, import_i18n24.sprintf)(
14453 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
14454 (0, import_i18n24.__)(
14455 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
14456 ),
14457 filter.name,
14458 activeElements[0].label
14459 ),
14460 filterTextWrappers
14461 ),
14462 filter(item, field, filterValue) {
14463 if (filterValue === void 0) {
14464 return true;
14465 }
14466 const fieldValue = field.getValue({ item });
14467 return fieldValue <= filterValue;
14468 },
14469 selection: "single"
14470 },
14471 {
14472 name: OPERATOR_GREATER_THAN_OR_EQUAL,
14473 /* translators: DataViews operator name */
14474 label: (0, import_i18n24.__)("Greater than or equal"),
14475 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14476 (0, import_i18n24.sprintf)(
14477 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
14478 (0, import_i18n24.__)(
14479 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
14480 ),
14481 filter.name,
14482 activeElements[0].label
14483 ),
14484 filterTextWrappers
14485 ),
14486 filter(item, field, filterValue) {
14487 if (filterValue === void 0) {
14488 return true;
14489 }
14490 const fieldValue = field.getValue({ item });
14491 return fieldValue >= filterValue;
14492 },
14493 selection: "single"
14494 },
14495 {
14496 name: OPERATOR_BEFORE,
14497 /* translators: DataViews operator name */
14498 label: (0, import_i18n24.__)("Before"),
14499 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14500 (0, import_i18n24.sprintf)(
14501 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
14502 (0, import_i18n24.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
14503 filter.name,
14504 activeElements[0].label
14505 ),
14506 filterTextWrappers
14507 ),
14508 filter(item, field, filterValue) {
14509 if (filterValue === void 0) {
14510 return true;
14511 }
14512 const filterDate = (0, import_date.getDate)(filterValue);
14513 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14514 return fieldDate < filterDate;
14515 },
14516 selection: "single"
14517 },
14518 {
14519 name: OPERATOR_AFTER,
14520 /* translators: DataViews operator name */
14521 label: (0, import_i18n24.__)("After"),
14522 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14523 (0, import_i18n24.sprintf)(
14524 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
14525 (0, import_i18n24.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
14526 filter.name,
14527 activeElements[0].label
14528 ),
14529 filterTextWrappers
14530 ),
14531 filter(item, field, filterValue) {
14532 if (filterValue === void 0) {
14533 return true;
14534 }
14535 const filterDate = (0, import_date.getDate)(filterValue);
14536 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14537 return fieldDate > filterDate;
14538 },
14539 selection: "single"
14540 },
14541 {
14542 name: OPERATOR_BEFORE_INC,
14543 /* translators: DataViews operator name */
14544 label: (0, import_i18n24.__)("Before (inc)"),
14545 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14546 (0, import_i18n24.sprintf)(
14547 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
14548 (0, import_i18n24.__)(
14549 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
14550 ),
14551 filter.name,
14552 activeElements[0].label
14553 ),
14554 filterTextWrappers
14555 ),
14556 filter(item, field, filterValue) {
14557 if (filterValue === void 0) {
14558 return true;
14559 }
14560 const filterDate = (0, import_date.getDate)(filterValue);
14561 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14562 return fieldDate <= filterDate;
14563 },
14564 selection: "single"
14565 },
14566 {
14567 name: OPERATOR_AFTER_INC,
14568 /* translators: DataViews operator name */
14569 label: (0, import_i18n24.__)("After (inc)"),
14570 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14571 (0, import_i18n24.sprintf)(
14572 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
14573 (0, import_i18n24.__)(
14574 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
14575 ),
14576 filter.name,
14577 activeElements[0].label
14578 ),
14579 filterTextWrappers
14580 ),
14581 filter(item, field, filterValue) {
14582 if (filterValue === void 0) {
14583 return true;
14584 }
14585 const filterDate = (0, import_date.getDate)(filterValue);
14586 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14587 return fieldDate >= filterDate;
14588 },
14589 selection: "single"
14590 },
14591 {
14592 name: OPERATOR_CONTAINS,
14593 /* translators: DataViews operator name */
14594 label: (0, import_i18n24.__)("Contains"),
14595 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14596 (0, import_i18n24.sprintf)(
14597 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
14598 (0, import_i18n24.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
14599 filter.name,
14600 activeElements[0].label
14601 ),
14602 filterTextWrappers
14603 ),
14604 filter(item, field, filterValue) {
14605 if (filterValue === void 0) {
14606 return true;
14607 }
14608 const fieldValue = field.getValue({ item });
14609 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
14610 },
14611 selection: "single"
14612 },
14613 {
14614 name: OPERATOR_NOT_CONTAINS,
14615 /* translators: DataViews operator name */
14616 label: (0, import_i18n24.__)("Doesn't contain"),
14617 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14618 (0, import_i18n24.sprintf)(
14619 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
14620 (0, import_i18n24.__)(
14621 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
14622 ),
14623 filter.name,
14624 activeElements[0].label
14625 ),
14626 filterTextWrappers
14627 ),
14628 filter(item, field, filterValue) {
14629 if (filterValue === void 0) {
14630 return true;
14631 }
14632 const fieldValue = field.getValue({ item });
14633 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
14634 },
14635 selection: "single"
14636 },
14637 {
14638 name: OPERATOR_STARTS_WITH,
14639 /* translators: DataViews operator name */
14640 label: (0, import_i18n24.__)("Starts with"),
14641 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14642 (0, import_i18n24.sprintf)(
14643 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
14644 (0, import_i18n24.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
14645 filter.name,
14646 activeElements[0].label
14647 ),
14648 filterTextWrappers
14649 ),
14650 filter(item, field, filterValue) {
14651 if (filterValue === void 0) {
14652 return true;
14653 }
14654 const fieldValue = field.getValue({ item });
14655 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
14656 },
14657 selection: "single"
14658 },
14659 {
14660 name: OPERATOR_ON,
14661 /* translators: DataViews operator name */
14662 label: (0, import_i18n24.__)("On"),
14663 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14664 (0, import_i18n24.sprintf)(
14665 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
14666 (0, import_i18n24.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
14667 filter.name,
14668 activeElements[0].label
14669 ),
14670 filterTextWrappers
14671 ),
14672 filter(item, field, filterValue) {
14673 if (filterValue === void 0) {
14674 return true;
14675 }
14676 const filterDate = (0, import_date.getDate)(filterValue);
14677 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14678 return filterDate.getTime() === fieldDate.getTime();
14679 },
14680 selection: "single"
14681 },
14682 {
14683 name: OPERATOR_NOT_ON,
14684 /* translators: DataViews operator name */
14685 label: (0, import_i18n24.__)("Not on"),
14686 filterText: (filter, activeElements) => (0, import_element46.createInterpolateElement)(
14687 (0, import_i18n24.sprintf)(
14688 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
14689 (0, import_i18n24.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
14690 filter.name,
14691 activeElements[0].label
14692 ),
14693 filterTextWrappers
14694 ),
14695 filter(item, field, filterValue) {
14696 if (filterValue === void 0) {
14697 return true;
14698 }
14699 const filterDate = (0, import_date.getDate)(filterValue);
14700 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
14701 return filterDate.getTime() !== fieldDate.getTime();
14702 },
14703 selection: "single"
14704 }
14705 ];
14706 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
14707 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
14708 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
14709 (op) => op.name === name
14710 );
14711 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
14712
14713 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
14714 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
14715 var ENTER = "Enter";
14716 var SPACE = " ";
14717 var FilterText = ({
14718 activeElements,
14719 filterInView,
14720 filter
14721 }) => {
14722 if (activeElements === void 0 || activeElements.length === 0) {
14723 return filter.name;
14724 }
14725 const operator = getOperatorByName(filterInView?.operator);
14726 if (operator !== void 0) {
14727 return operator.filterText(filter, activeElements);
14728 }
14729 return (0, import_i18n25.sprintf)(
14730 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
14731 (0, import_i18n25.__)("Unknown status for %1$s"),
14732 filter.name
14733 );
14734 };
14735 function OperatorSelector({
14736 filter,
14737 view,
14738 onChangeView
14739 }) {
14740 const operatorOptions = filter.operators?.map((operator) => ({
14741 value: operator,
14742 label: getOperatorByName(operator)?.label || operator
14743 }));
14744 const currentFilter = view.filters?.find(
14745 (_filter) => _filter.field === filter.field
14746 );
14747 const value = currentFilter?.operator || filter.operators[0];
14748 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
14749 Stack,
14750 {
14751 direction: "row",
14752 gap: "sm",
14753 justify: "flex-start",
14754 className: "dataviews-filters__summary-operators-container",
14755 align: "center",
14756 children: [
14757 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components22.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
14758 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14759 import_components22.SelectControl,
14760 {
14761 className: "dataviews-filters__summary-operators-filter-select",
14762 label: (0, import_i18n25.__)("Conditions"),
14763 value,
14764 options: operatorOptions,
14765 onChange: (newValue) => {
14766 const newOperator = newValue;
14767 const currentOperator = currentFilter?.operator;
14768 const newFilters = currentFilter ? [
14769 ...(view.filters ?? []).map(
14770 (_filter) => {
14771 if (_filter.field === filter.field) {
14772 const currentOpSelectionModel = getOperatorByName(
14773 currentOperator
14774 )?.selection;
14775 const newOpSelectionModel = getOperatorByName(
14776 newOperator
14777 )?.selection;
14778 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
14779 currentOpSelectionModel,
14780 newOpSelectionModel
14781 ].includes("custom");
14782 return {
14783 ..._filter,
14784 value: shouldResetValue ? void 0 : _filter.value,
14785 operator: newOperator
14786 };
14787 }
14788 return _filter;
14789 }
14790 )
14791 ] : [
14792 ...view.filters ?? [],
14793 {
14794 field: filter.field,
14795 operator: newOperator,
14796 value: void 0
14797 }
14798 ];
14799 onChangeView({
14800 ...view,
14801 page: 1,
14802 filters: newFilters
14803 });
14804 },
14805 size: "small",
14806 variant: "minimal",
14807 hideLabelFromVision: true
14808 }
14809 )
14810 ]
14811 }
14812 );
14813 }
14814 function Filter({
14815 addFilterRef,
14816 openedFilter,
14817 fields: fields2,
14818 ...commonProps
14819 }) {
14820 const toggleRef = (0, import_element47.useRef)(null);
14821 const { filter, view, onChangeView } = commonProps;
14822 const filterInView = view.filters?.find(
14823 (f2) => f2.field === filter.field
14824 );
14825 let activeElements = [];
14826 const field = (0, import_element47.useMemo)(() => {
14827 const currentField = fields2.find((f2) => f2.id === filter.field);
14828 if (currentField) {
14829 return {
14830 ...currentField,
14831 // Configure getValue as if Item was a plain object.
14832 // See related input-widget.tsx
14833 getValue: ({ item }) => item[currentField.id]
14834 };
14835 }
14836 return currentField;
14837 }, [fields2, filter.field]);
14838 const { elements } = useElements({
14839 elements: filter.elements,
14840 getElements: filter.getElements
14841 });
14842 if (elements.length > 0) {
14843 activeElements = elements.filter((element) => {
14844 if (filter.singleSelection) {
14845 return element.value === filterInView?.value;
14846 }
14847 return filterInView?.value?.includes(element.value);
14848 });
14849 } else if (Array.isArray(filterInView?.value)) {
14850 const label = filterInView.value.map((v2) => {
14851 const formattedValue = field?.getValueFormatted({
14852 item: { [field.id]: v2 },
14853 field
14854 });
14855 return formattedValue || String(v2);
14856 });
14857 activeElements = [
14858 {
14859 value: filterInView.value,
14860 // @ts-ignore
14861 label
14862 }
14863 ];
14864 } else if (typeof filterInView?.value === "object") {
14865 activeElements = [
14866 { value: filterInView.value, label: filterInView.value }
14867 ];
14868 } else if (filterInView?.value !== void 0) {
14869 const label = field !== void 0 ? field.getValueFormatted({
14870 item: { [field.id]: filterInView.value },
14871 field
14872 }) : String(filterInView.value);
14873 activeElements = [
14874 {
14875 value: filterInView.value,
14876 label
14877 }
14878 ];
14879 }
14880 const isPrimary = filter.isPrimary;
14881 const isLocked = filterInView?.isLocked;
14882 const hasValues = !isLocked && filterInView?.value !== void 0;
14883 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
14884 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14885 import_components22.Dropdown,
14886 {
14887 defaultOpen: openedFilter === filter.field,
14888 contentClassName: "dataviews-filters__summary-popover",
14889 popoverProps: { placement: "bottom-start", role: "dialog" },
14890 onClose: () => {
14891 toggleRef.current?.focus();
14892 },
14893 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
14894 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14895 import_components22.Tooltip,
14896 {
14897 text: (0, import_i18n25.sprintf)(
14898 /* translators: 1: Filter name. */
14899 (0, import_i18n25.__)("Filter by: %1$s"),
14900 filter.name.toLowerCase()
14901 ),
14902 placement: "top",
14903 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14904 "div",
14905 {
14906 className: clsx_default(
14907 "dataviews-filters__summary-chip",
14908 {
14909 "has-reset": canResetOrRemove,
14910 "has-values": hasValues,
14911 "is-not-clickable": isLocked
14912 }
14913 ),
14914 role: "button",
14915 tabIndex: isLocked ? -1 : 0,
14916 onClick: () => {
14917 if (!isLocked) {
14918 onToggle();
14919 }
14920 },
14921 onKeyDown: (event) => {
14922 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
14923 onToggle();
14924 event.preventDefault();
14925 }
14926 },
14927 "aria-disabled": isLocked,
14928 "aria-pressed": isOpen,
14929 "aria-expanded": isOpen,
14930 ref: toggleRef,
14931 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14932 FilterText,
14933 {
14934 activeElements,
14935 filterInView,
14936 filter
14937 }
14938 )
14939 }
14940 )
14941 }
14942 ),
14943 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14944 import_components22.Tooltip,
14945 {
14946 text: isPrimary ? (0, import_i18n25.__)("Reset") : (0, import_i18n25.__)("Remove"),
14947 placement: "top",
14948 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14949 "button",
14950 {
14951 className: clsx_default(
14952 "dataviews-filters__summary-chip-remove",
14953 { "has-values": hasValues }
14954 ),
14955 onClick: () => {
14956 onChangeView({
14957 ...view,
14958 page: 1,
14959 filters: view.filters?.filter(
14960 (_filter) => _filter.field !== filter.field
14961 )
14962 });
14963 if (!isPrimary) {
14964 addFilterRef.current?.focus();
14965 } else {
14966 toggleRef.current?.focus();
14967 }
14968 },
14969 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components22.Icon, { icon: close_small_default })
14970 }
14971 )
14972 }
14973 )
14974 ] }),
14975 renderContent: () => {
14976 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
14977 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(OperatorSelector, { ...commonProps }),
14978 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
14979 SearchWidget,
14980 {
14981 ...commonProps,
14982 filter: {
14983 ...commonProps.filter,
14984 elements
14985 }
14986 }
14987 ) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(InputWidget, { ...commonProps, fields: fields2 })
14988 ] });
14989 }
14990 }
14991 );
14992 }
14993
14994 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
14995 var import_components23 = __toESM(require_components(), 1);
14996 var import_i18n26 = __toESM(require_i18n(), 1);
14997 var import_element48 = __toESM(require_element(), 1);
14998 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
14999 var { Menu: Menu4 } = unlock(import_components23.privateApis);
15000 function AddFilterMenu({
15001 filters,
15002 view,
15003 onChangeView,
15004 setOpenedFilter,
15005 triggerProps
15006 }) {
15007 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
15008 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(Menu4, { children: [
15009 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.TriggerButton, { ...triggerProps }),
15010 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
15011 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15012 Menu4.Item,
15013 {
15014 onClick: () => {
15015 setOpenedFilter(filter.field);
15016 onChangeView({
15017 ...view,
15018 page: 1,
15019 filters: [
15020 ...view.filters || [],
15021 {
15022 field: filter.field,
15023 value: void 0,
15024 operator: filter.operators[0]
15025 }
15026 ]
15027 });
15028 },
15029 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.ItemLabel, { children: filter.name })
15030 },
15031 filter.field
15032 );
15033 }) })
15034 ] });
15035 }
15036 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
15037 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
15038 return null;
15039 }
15040 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
15041 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15042 AddFilterMenu,
15043 {
15044 triggerProps: {
15045 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15046 import_components23.Button,
15047 {
15048 accessibleWhenDisabled: true,
15049 size: "compact",
15050 className: "dataviews-filters-button",
15051 variant: "tertiary",
15052 disabled: !inactiveFilters.length,
15053 ref
15054 }
15055 ),
15056 children: (0, import_i18n26.__)("Add filter")
15057 },
15058 ...{ filters, view, onChangeView, setOpenedFilter }
15059 }
15060 );
15061 }
15062 var add_filter_default = (0, import_element48.forwardRef)(AddFilter);
15063
15064 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
15065 var import_components24 = __toESM(require_components(), 1);
15066 var import_i18n27 = __toESM(require_i18n(), 1);
15067 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15068 function ResetFilter({
15069 filters,
15070 view,
15071 onChangeView
15072 }) {
15073 const isPrimary = (field) => filters.some(
15074 (_filter) => _filter.field === field && _filter.isPrimary
15075 );
15076 const isDisabled = !view.search && !view.filters?.some(
15077 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
15078 );
15079 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15080 import_components24.Button,
15081 {
15082 disabled: isDisabled,
15083 accessibleWhenDisabled: true,
15084 size: "compact",
15085 variant: "tertiary",
15086 className: "dataviews-filters__reset-button",
15087 onClick: () => {
15088 onChangeView({
15089 ...view,
15090 page: 1,
15091 search: "",
15092 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
15093 });
15094 },
15095 children: (0, import_i18n27.__)("Reset")
15096 }
15097 );
15098 }
15099
15100 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
15101 var import_element49 = __toESM(require_element(), 1);
15102 function useFilters(fields2, view) {
15103 return (0, import_element49.useMemo)(() => {
15104 const filters = [];
15105 fields2.forEach((field) => {
15106 if (field.filterBy === false || !field.hasElements && !field.Edit) {
15107 return;
15108 }
15109 const operators = field.filterBy.operators;
15110 const isPrimary = !!field.filterBy?.isPrimary;
15111 const isLocked = view.filters?.some(
15112 (f2) => f2.field === field.id && !!f2.isLocked
15113 ) ?? false;
15114 filters.push({
15115 field: field.id,
15116 name: field.label,
15117 elements: field.elements,
15118 getElements: field.getElements,
15119 hasElements: field.hasElements,
15120 singleSelection: operators.some(
15121 (op) => isSingleSelectionOperator(op)
15122 ),
15123 operators,
15124 isVisible: isLocked || isPrimary || !!view.filters?.some(
15125 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
15126 ),
15127 isPrimary,
15128 isLocked
15129 });
15130 });
15131 filters.sort((a2, b2) => {
15132 if (a2.isLocked && !b2.isLocked) {
15133 return -1;
15134 }
15135 if (!a2.isLocked && b2.isLocked) {
15136 return 1;
15137 }
15138 if (a2.isPrimary && !b2.isPrimary) {
15139 return -1;
15140 }
15141 if (!a2.isPrimary && b2.isPrimary) {
15142 return 1;
15143 }
15144 return a2.name.localeCompare(b2.name);
15145 });
15146 return filters;
15147 }, [fields2, view]);
15148 }
15149 var use_filters_default = useFilters;
15150
15151 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
15152 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
15153 function Filters({ className }) {
15154 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element50.useContext)(dataviews_context_default);
15155 const addFilterRef = (0, import_element50.useRef)(null);
15156 const filters = use_filters_default(fields2, view);
15157 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15158 add_filter_default,
15159 {
15160 filters,
15161 view,
15162 onChangeView,
15163 ref: addFilterRef,
15164 setOpenedFilter
15165 },
15166 "add-filter"
15167 );
15168 const visibleFilters = filters.filter((filter) => filter.isVisible);
15169 if (visibleFilters.length === 0) {
15170 return null;
15171 }
15172 const filterComponents = [
15173 ...visibleFilters.map((filter) => {
15174 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15175 Filter,
15176 {
15177 filter,
15178 view,
15179 fields: fields2,
15180 onChangeView,
15181 addFilterRef,
15182 openedFilter
15183 },
15184 filter.field
15185 );
15186 }),
15187 addFilter
15188 ];
15189 filterComponents.push(
15190 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15191 ResetFilter,
15192 {
15193 filters,
15194 view,
15195 onChangeView
15196 },
15197 "reset-filters"
15198 )
15199 );
15200 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
15201 Stack,
15202 {
15203 direction: "row",
15204 justify: "flex-start",
15205 gap: "sm",
15206 style: { width: "fit-content" },
15207 wrap: "wrap",
15208 className,
15209 children: filterComponents
15210 }
15211 );
15212 }
15213 var filters_default = (0, import_element50.memo)(Filters);
15214
15215 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
15216 var import_element51 = __toESM(require_element(), 1);
15217 var import_components25 = __toESM(require_components(), 1);
15218 var import_i18n28 = __toESM(require_i18n(), 1);
15219 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
15220 function FiltersToggle() {
15221 const {
15222 filters,
15223 view,
15224 onChangeView,
15225 setOpenedFilter,
15226 isShowingFilter,
15227 setIsShowingFilter
15228 } = (0, import_element51.useContext)(dataviews_context_default);
15229 const buttonRef = (0, import_element51.useRef)(null);
15230 const onChangeViewWithFilterVisibility = (0, import_element51.useCallback)(
15231 (_view) => {
15232 onChangeView(_view);
15233 setIsShowingFilter(true);
15234 },
15235 [onChangeView, setIsShowingFilter]
15236 );
15237 if (filters.length === 0) {
15238 return null;
15239 }
15240 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
15241 const addFilterButtonProps = {
15242 label: (0, import_i18n28.__)("Add filter"),
15243 "aria-expanded": false,
15244 isPressed: false
15245 };
15246 const toggleFiltersButtonProps = {
15247 label: (0, import_i18n28._x)("Filter", "verb"),
15248 "aria-expanded": isShowingFilter,
15249 isPressed: isShowingFilter,
15250 onClick: () => {
15251 if (!isShowingFilter) {
15252 setOpenedFilter(null);
15253 }
15254 setIsShowingFilter(!isShowingFilter);
15255 }
15256 };
15257 const hasPrimaryOrLockedFilters = filters.some(
15258 (filter) => filter.isPrimary || filter.isLocked
15259 );
15260 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15261 import_components25.Button,
15262 {
15263 ref: buttonRef,
15264 className: "dataviews-filters__visibility-toggle",
15265 size: "compact",
15266 icon: funnel_default,
15267 disabled: hasPrimaryOrLockedFilters,
15268 accessibleWhenDisabled: true,
15269 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
15270 }
15271 );
15272 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15273 AddFilterMenu,
15274 {
15275 filters,
15276 view,
15277 onChangeView: onChangeViewWithFilterVisibility,
15278 setOpenedFilter,
15279 triggerProps: { render: buttonComponent }
15280 }
15281 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
15282 FilterVisibilityToggle,
15283 {
15284 buttonRef,
15285 filtersCount: view.filters?.length,
15286 children: buttonComponent
15287 }
15288 ) });
15289 }
15290 function FilterVisibilityToggle({
15291 buttonRef,
15292 filtersCount,
15293 children
15294 }) {
15295 (0, import_element51.useEffect)(
15296 () => () => {
15297 buttonRef.current?.focus();
15298 },
15299 [buttonRef]
15300 );
15301 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
15302 children,
15303 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
15304 ] });
15305 }
15306 var toggle_default = FiltersToggle;
15307
15308 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
15309 var import_element52 = __toESM(require_element(), 1);
15310 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
15311 function FiltersToggled(props) {
15312 const { isShowingFilter } = (0, import_element52.useContext)(dataviews_context_default);
15313 if (!isShowingFilter) {
15314 return null;
15315 }
15316 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(filters_default, { ...props });
15317 }
15318 var filters_toggled_default = FiltersToggled;
15319
15320 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
15321 var import_element53 = __toESM(require_element(), 1);
15322 var import_components26 = __toESM(require_components(), 1);
15323 var import_i18n29 = __toESM(require_i18n(), 1);
15324 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
15325 function DataViewsLayout({ className }) {
15326 const {
15327 actions: actions2 = [],
15328 data,
15329 fields: fields2,
15330 getItemId,
15331 getItemLevel,
15332 hasInitiallyLoaded,
15333 isLoading,
15334 view,
15335 onChangeView,
15336 selection,
15337 onChangeSelection,
15338 setOpenedFilter,
15339 onClickItem,
15340 isItemClickable,
15341 renderItemLink,
15342 defaultLayouts,
15343 containerRef,
15344 empty = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: (0, import_i18n29.__)("No results") })
15345 } = (0, import_element53.useContext)(dataviews_context_default);
15346 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
15347 delay: 200
15348 });
15349 if (!hasInitiallyLoaded) {
15350 if (!isDelayedInitialLoading) {
15351 return null;
15352 }
15353 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-loading", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_components26.Spinner, {}) }) });
15354 }
15355 const ViewComponent = VIEW_LAYOUTS.find(
15356 (v2) => v2.type === view.type && defaultLayouts[v2.type]
15357 )?.component;
15358 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
15359 ViewComponent,
15360 {
15361 className,
15362 actions: actions2,
15363 data,
15364 fields: fields2,
15365 getItemId,
15366 getItemLevel,
15367 isLoading,
15368 onChangeView,
15369 onChangeSelection,
15370 selection,
15371 setOpenedFilter,
15372 onClickItem,
15373 renderItemLink,
15374 isItemClickable,
15375 view,
15376 empty
15377 }
15378 ) });
15379 }
15380
15381 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
15382 var import_element54 = __toESM(require_element(), 1);
15383 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
15384 var EMPTY_ARRAY5 = [];
15385 function DataViewsFooter() {
15386 const {
15387 view,
15388 paginationInfo: { totalItems = 0, totalPages },
15389 data,
15390 actions: actions2 = EMPTY_ARRAY5,
15391 isLoading,
15392 hasInitiallyLoaded
15393 } = (0, import_element54.useContext)(dataviews_context_default);
15394 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
15395 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
15396 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
15397 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
15398 return null;
15399 }
15400 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
15401 "div",
15402 {
15403 className: "dataviews-footer",
15404 inert: isRefreshing ? "true" : void 0,
15405 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
15406 Stack,
15407 {
15408 direction: "row",
15409 justify: "end",
15410 align: "center",
15411 className: clsx_default("dataviews-footer__content", {
15412 "is-refreshing": isDelayedRefreshing
15413 }),
15414 gap: "sm",
15415 children: [
15416 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(BulkActionsFooter, {}),
15417 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(dataviews_pagination_default, {})
15418 ]
15419 }
15420 )
15421 }
15422 );
15423 }
15424
15425 // packages/dataviews/build-module/components/dataviews-search/index.mjs
15426 var import_i18n30 = __toESM(require_i18n(), 1);
15427 var import_element55 = __toESM(require_element(), 1);
15428 var import_components27 = __toESM(require_components(), 1);
15429 var import_compose9 = __toESM(require_compose(), 1);
15430 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
15431 var DataViewsSearch = (0, import_element55.memo)(function Search({ label }) {
15432 const { view, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
15433 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
15434 view.search
15435 );
15436 (0, import_element55.useEffect)(() => {
15437 if (view.search !== debouncedSearch) {
15438 setSearch(view.search ?? "");
15439 }
15440 }, [view.search, setSearch]);
15441 const onChangeViewRef = (0, import_element55.useRef)(onChangeView);
15442 const viewRef = (0, import_element55.useRef)(view);
15443 (0, import_element55.useEffect)(() => {
15444 onChangeViewRef.current = onChangeView;
15445 viewRef.current = view;
15446 }, [onChangeView, view]);
15447 (0, import_element55.useEffect)(() => {
15448 if (debouncedSearch !== viewRef.current?.search) {
15449 onChangeViewRef.current({
15450 ...viewRef.current,
15451 page: view.page ? 1 : void 0,
15452 startPosition: view.startPosition ? 1 : void 0,
15453 search: debouncedSearch
15454 });
15455 }
15456 }, [debouncedSearch]);
15457 const searchLabel = label || (0, import_i18n30.__)("Search");
15458 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
15459 import_components27.SearchControl,
15460 {
15461 className: "dataviews-search",
15462 onChange: setSearch,
15463 value: search,
15464 label: searchLabel,
15465 placeholder: searchLabel,
15466 size: "compact"
15467 }
15468 );
15469 });
15470 var dataviews_search_default = DataViewsSearch;
15471
15472 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
15473 var import_components28 = __toESM(require_components(), 1);
15474 var import_i18n31 = __toESM(require_i18n(), 1);
15475 var import_element56 = __toESM(require_element(), 1);
15476 var import_warning = __toESM(require_warning(), 1);
15477 var import_compose10 = __toESM(require_compose(), 1);
15478 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
15479 var { Menu: Menu5 } = unlock(import_components28.privateApis);
15480 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
15481 className: "dataviews-config__popover",
15482 placement: "bottom-end",
15483 offset: 9
15484 };
15485 function ViewTypeMenu() {
15486 const { view, onChangeView, defaultLayouts } = (0, import_element56.useContext)(dataviews_context_default);
15487 const availableLayouts = Object.keys(defaultLayouts);
15488 if (availableLayouts.length <= 1) {
15489 return null;
15490 }
15491 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
15492 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Menu5, { children: [
15493 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15494 Menu5.TriggerButton,
15495 {
15496 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15497 import_components28.Button,
15498 {
15499 size: "compact",
15500 icon: activeView?.icon,
15501 label: (0, import_i18n31.__)("Layout")
15502 }
15503 )
15504 }
15505 ),
15506 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
15507 const config = VIEW_LAYOUTS.find(
15508 (v2) => v2.type === layout
15509 );
15510 if (!config) {
15511 return null;
15512 }
15513 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15514 Menu5.RadioItem,
15515 {
15516 value: layout,
15517 name: "view-actions-available-view",
15518 checked: layout === view.type,
15519 hideOnClick: true,
15520 onChange: (e2) => {
15521 switch (e2.target.value) {
15522 case "list":
15523 case "grid":
15524 case "table":
15525 case "pickerGrid":
15526 case "pickerTable":
15527 case "activity":
15528 const viewWithoutLayout = { ...view };
15529 if ("layout" in viewWithoutLayout) {
15530 delete viewWithoutLayout.layout;
15531 }
15532 return onChangeView({
15533 ...viewWithoutLayout,
15534 type: e2.target.value,
15535 ...defaultLayouts[e2.target.value]
15536 });
15537 }
15538 (0, import_warning.default)("Invalid dataview");
15539 },
15540 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.ItemLabel, { children: config.label })
15541 },
15542 layout
15543 );
15544 }) })
15545 ] });
15546 }
15547 function SortFieldControl() {
15548 const { view, fields: fields2, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
15549 const orderOptions = (0, import_element56.useMemo)(() => {
15550 const sortableFields = fields2.filter(
15551 (field) => field.enableSorting !== false
15552 );
15553 return sortableFields.map((field) => {
15554 return {
15555 label: field.label,
15556 value: field.id
15557 };
15558 });
15559 }, [fields2]);
15560 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15561 import_components28.SelectControl,
15562 {
15563 __next40pxDefaultSize: true,
15564 label: (0, import_i18n31.__)("Sort by"),
15565 value: view.sort?.field,
15566 options: orderOptions,
15567 onChange: (value) => {
15568 onChangeView({
15569 ...view,
15570 sort: {
15571 direction: view?.sort?.direction || "desc",
15572 field: value
15573 },
15574 showLevels: false
15575 });
15576 }
15577 }
15578 );
15579 }
15580 function SortDirectionControl() {
15581 const { view, fields: fields2, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
15582 const sortableFields = fields2.filter(
15583 (field) => field.enableSorting !== false
15584 );
15585 if (sortableFields.length === 0) {
15586 return null;
15587 }
15588 let value = view.sort?.direction;
15589 if (!value && view.sort?.field) {
15590 value = "desc";
15591 }
15592 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15593 import_components28.__experimentalToggleGroupControl,
15594 {
15595 className: "dataviews-view-config__sort-direction",
15596 __next40pxDefaultSize: true,
15597 isBlock: true,
15598 label: (0, import_i18n31.__)("Order"),
15599 value,
15600 onChange: (newDirection) => {
15601 if (newDirection === "asc" || newDirection === "desc") {
15602 onChangeView({
15603 ...view,
15604 sort: {
15605 direction: newDirection,
15606 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
15607 fields2.find(
15608 (field) => field.enableSorting !== false
15609 )?.id || ""
15610 },
15611 showLevels: false
15612 });
15613 return;
15614 }
15615 (0, import_warning.default)("Invalid direction");
15616 },
15617 children: SORTING_DIRECTIONS.map((direction) => {
15618 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15619 import_components28.__experimentalToggleGroupControlOptionIcon,
15620 {
15621 value: direction,
15622 icon: sortIcons[direction],
15623 label: sortLabels[direction]
15624 },
15625 direction
15626 );
15627 })
15628 }
15629 );
15630 }
15631 function ItemsPerPageControl() {
15632 const { view, config, onChangeView } = (0, import_element56.useContext)(dataviews_context_default);
15633 const { infiniteScrollEnabled } = view;
15634 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
15635 return null;
15636 }
15637 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15638 import_components28.__experimentalToggleGroupControl,
15639 {
15640 __next40pxDefaultSize: true,
15641 isBlock: true,
15642 label: (0, import_i18n31.__)("Items per page"),
15643 value: view.perPage || 10,
15644 disabled: !view?.sort?.field,
15645 onChange: (newItemsPerPage) => {
15646 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
15647 onChangeView({
15648 ...view,
15649 perPage: newItemsPerPageNumber,
15650 page: 1
15651 });
15652 },
15653 children: config.perPageSizes.map((value) => {
15654 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15655 import_components28.__experimentalToggleGroupControlOption,
15656 {
15657 value,
15658 label: value.toString()
15659 },
15660 value
15661 );
15662 })
15663 }
15664 );
15665 }
15666 function ResetViewButton() {
15667 const { onReset } = (0, import_element56.useContext)(dataviews_context_default);
15668 if (onReset === void 0) {
15669 return null;
15670 }
15671 const isDisabled = onReset === false;
15672 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15673 import_components28.Button,
15674 {
15675 variant: "tertiary",
15676 size: "compact",
15677 disabled: isDisabled,
15678 accessibleWhenDisabled: true,
15679 className: "dataviews-view-config__reset-button",
15680 onClick: () => {
15681 if (typeof onReset === "function") {
15682 onReset();
15683 }
15684 },
15685 children: (0, import_i18n31.__)("Reset view")
15686 }
15687 );
15688 }
15689 function DataviewsViewConfigDropdown() {
15690 const { view, onReset } = (0, import_element56.useContext)(dataviews_context_default);
15691 const popoverId = (0, import_compose10.useInstanceId)(
15692 _DataViewsViewConfig,
15693 "dataviews-view-config-dropdown"
15694 );
15695 const activeLayout = VIEW_LAYOUTS.find(
15696 (layout) => layout.type === view.type
15697 );
15698 const isModified = typeof onReset === "function";
15699 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15700 import_components28.Dropdown,
15701 {
15702 expandOnMobile: true,
15703 popoverProps: {
15704 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
15705 id: popoverId
15706 },
15707 renderToggle: ({ onToggle, isOpen }) => {
15708 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
15709 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15710 import_components28.Button,
15711 {
15712 size: "compact",
15713 icon: cog_default,
15714 label: (0, import_i18n31._x)(
15715 "View options",
15716 "View is used as a noun"
15717 ),
15718 onClick: onToggle,
15719 "aria-expanded": isOpen ? "true" : "false",
15720 "aria-controls": popoverId
15721 }
15722 ),
15723 isModified && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
15724 ] });
15725 },
15726 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15727 import_components28.__experimentalDropdownContentWrapper,
15728 {
15729 paddingSize: "medium",
15730 className: "dataviews-config__popover-content-wrapper",
15731 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15732 Stack,
15733 {
15734 direction: "column",
15735 className: "dataviews-view-config",
15736 gap: "xl",
15737 children: [
15738 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15739 Stack,
15740 {
15741 direction: "row",
15742 justify: "space-between",
15743 align: "center",
15744 className: "dataviews-view-config__header",
15745 children: [
15746 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
15747 import_components28.__experimentalHeading,
15748 {
15749 level: 2,
15750 className: "dataviews-settings-section__title",
15751 children: (0, import_i18n31.__)("Appearance")
15752 }
15753 ),
15754 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ResetViewButton, {})
15755 ]
15756 }
15757 ),
15758 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "column", gap: "lg", children: [
15759 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
15760 Stack,
15761 {
15762 direction: "row",
15763 gap: "sm",
15764 className: "dataviews-view-config__sort-controls",
15765 children: [
15766 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortFieldControl, {}),
15767 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortDirectionControl, {})
15768 ]
15769 }
15770 ),
15771 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(activeLayout.viewConfigOptions, {}),
15772 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ItemsPerPageControl, {}),
15773 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(PropertiesSection, {})
15774 ] })
15775 ]
15776 }
15777 )
15778 }
15779 )
15780 }
15781 );
15782 }
15783 function _DataViewsViewConfig() {
15784 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
15785 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ViewTypeMenu, {}),
15786 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(DataviewsViewConfigDropdown, {})
15787 ] });
15788 }
15789 var DataViewsViewConfig = (0, import_element56.memo)(_DataViewsViewConfig);
15790 var dataviews_view_config_default = DataViewsViewConfig;
15791
15792 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
15793 var import_components29 = __toESM(require_components(), 1);
15794 var import_element57 = __toESM(require_element(), 1);
15795
15796 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
15797 function getCustomValidity(isValid2, validity) {
15798 let customValidity;
15799 if (isValid2?.required && validity?.required) {
15800 customValidity = validity?.required?.message ? validity.required : void 0;
15801 } else if (isValid2?.pattern && validity?.pattern) {
15802 customValidity = validity.pattern;
15803 } else if (isValid2?.min && validity?.min) {
15804 customValidity = validity.min;
15805 } else if (isValid2?.max && validity?.max) {
15806 customValidity = validity.max;
15807 } else if (isValid2?.minLength && validity?.minLength) {
15808 customValidity = validity.minLength;
15809 } else if (isValid2?.maxLength && validity?.maxLength) {
15810 customValidity = validity.maxLength;
15811 } else if (isValid2?.elements && validity?.elements) {
15812 customValidity = validity.elements;
15813 } else if (validity?.custom) {
15814 customValidity = validity.custom;
15815 }
15816 return customValidity;
15817 }
15818
15819 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
15820 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
15821 var { ValidatedCheckboxControl } = unlock(import_components29.privateApis);
15822 function Checkbox({
15823 field,
15824 onChange,
15825 data,
15826 hideLabelFromVision,
15827 markWhenOptional,
15828 validity
15829 }) {
15830 const { getValue, setValue, label, description, isValid: isValid2 } = field;
15831 const disabled2 = field.isDisabled({ item: data, field });
15832 const onChangeControl = (0, import_element57.useCallback)(() => {
15833 onChange(
15834 setValue({ item: data, value: !getValue({ item: data }) })
15835 );
15836 }, [data, getValue, onChange, setValue]);
15837 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
15838 ValidatedCheckboxControl,
15839 {
15840 required: !!field.isValid?.required,
15841 markWhenOptional,
15842 customValidity: getCustomValidity(isValid2, validity),
15843 hidden: hideLabelFromVision,
15844 label,
15845 help: description,
15846 checked: getValue({ item: data }),
15847 onChange: onChangeControl,
15848 disabled: disabled2
15849 }
15850 );
15851 }
15852
15853 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
15854 var import_components30 = __toESM(require_components(), 1);
15855 var import_element58 = __toESM(require_element(), 1);
15856 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
15857 var { ValidatedComboboxControl } = unlock(import_components30.privateApis);
15858 function Combobox3({
15859 data,
15860 field,
15861 onChange,
15862 hideLabelFromVision,
15863 validity
15864 }) {
15865 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
15866 const value = getValue({ item: data }) ?? "";
15867 const onChangeControl = (0, import_element58.useCallback)(
15868 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
15869 [data, onChange, setValue]
15870 );
15871 const { elements, isLoading } = useElements({
15872 elements: field.elements,
15873 getElements: field.getElements
15874 });
15875 if (isLoading) {
15876 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components30.Spinner, {});
15877 }
15878 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
15879 ValidatedComboboxControl,
15880 {
15881 required: !!field.isValid?.required,
15882 customValidity: getCustomValidity(isValid2, validity),
15883 label,
15884 value,
15885 help: description,
15886 placeholder,
15887 options: elements,
15888 onChange: onChangeControl,
15889 hideLabelFromVision,
15890 allowReset: true,
15891 expandOnFocus: true
15892 }
15893 );
15894 }
15895
15896 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
15897 var import_components32 = __toESM(require_components(), 1);
15898 var import_element61 = __toESM(require_element(), 1);
15899 var import_i18n33 = __toESM(require_i18n(), 1);
15900 var import_date3 = __toESM(require_date(), 1);
15901
15902 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
15903 var import_components31 = __toESM(require_components(), 1);
15904 var import_element59 = __toESM(require_element(), 1);
15905 var import_i18n32 = __toESM(require_i18n(), 1);
15906 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
15907 var TIME_UNITS_OPTIONS = {
15908 [OPERATOR_IN_THE_PAST]: [
15909 { value: "days", label: (0, import_i18n32.__)("Days") },
15910 { value: "weeks", label: (0, import_i18n32.__)("Weeks") },
15911 { value: "months", label: (0, import_i18n32.__)("Months") },
15912 { value: "years", label: (0, import_i18n32.__)("Years") }
15913 ],
15914 [OPERATOR_OVER]: [
15915 { value: "days", label: (0, import_i18n32.__)("Days ago") },
15916 { value: "weeks", label: (0, import_i18n32.__)("Weeks ago") },
15917 { value: "months", label: (0, import_i18n32.__)("Months ago") },
15918 { value: "years", label: (0, import_i18n32.__)("Years ago") }
15919 ]
15920 };
15921 function RelativeDateControl({
15922 className,
15923 data,
15924 field,
15925 onChange,
15926 hideLabelFromVision,
15927 operator
15928 }) {
15929 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
15930 const { id, label, description, getValue, setValue } = field;
15931 const disabled2 = field.isDisabled({ item: data, field });
15932 const fieldValue = getValue({ item: data });
15933 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
15934 const onChangeValue = (0, import_element59.useCallback)(
15935 (newValue) => onChange(
15936 setValue({
15937 item: data,
15938 value: { value: Number(newValue), unit }
15939 })
15940 ),
15941 [onChange, setValue, data, unit]
15942 );
15943 const onChangeUnit = (0, import_element59.useCallback)(
15944 (newUnit) => onChange(
15945 setValue({
15946 item: data,
15947 value: { value: relValue, unit: newUnit }
15948 })
15949 ),
15950 [onChange, setValue, data, relValue]
15951 );
15952 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15953 import_components31.BaseControl,
15954 {
15955 id,
15956 className: clsx_default(className, "dataviews-controls__relative-date"),
15957 label,
15958 hideLabelFromVision,
15959 help: description,
15960 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "row", gap: "sm", children: [
15961 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15962 import_components31.__experimentalNumberControl,
15963 {
15964 __next40pxDefaultSize: true,
15965 className: "dataviews-controls__relative-date-number",
15966 spinControls: "none",
15967 min: 1,
15968 step: 1,
15969 value: relValue,
15970 onChange: onChangeValue,
15971 disabled: disabled2
15972 }
15973 ),
15974 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
15975 import_components31.SelectControl,
15976 {
15977 className: "dataviews-controls__relative-date-unit",
15978 __next40pxDefaultSize: true,
15979 label: (0, import_i18n32.__)("Unit"),
15980 value: unit,
15981 options,
15982 onChange: onChangeUnit,
15983 hideLabelFromVision: true,
15984 disabled: disabled2
15985 }
15986 )
15987 ] })
15988 }
15989 );
15990 }
15991
15992 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
15993 var import_element60 = __toESM(require_element(), 1);
15994 function useDisabledDateMatchers(isValid2, parseDateFn) {
15995 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
15996 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
15997 const disabledMatchers = (0, import_element60.useMemo)(() => {
15998 const matchers = [];
15999 if (minConstraint) {
16000 const minDate = parseDateFn(minConstraint);
16001 if (minDate) {
16002 matchers.push({ before: minDate });
16003 }
16004 }
16005 if (maxConstraint) {
16006 const maxDate = parseDateFn(maxConstraint);
16007 if (maxDate) {
16008 matchers.push({ after: maxDate });
16009 }
16010 }
16011 return matchers.length > 0 ? matchers : void 0;
16012 }, [minConstraint, maxConstraint, parseDateFn]);
16013 return { minConstraint, maxConstraint, disabledMatchers };
16014 }
16015
16016 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
16017 var import_date2 = __toESM(require_date(), 1);
16018 function parseDateTime(dateTimeString) {
16019 if (!dateTimeString) {
16020 return null;
16021 }
16022 const parsed = (0, import_date2.getDate)(dateTimeString);
16023 return parsed && isValid(parsed) ? parsed : null;
16024 }
16025
16026 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
16027 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
16028 var { DateCalendar, ValidatedInputControl } = unlock(import_components32.privateApis);
16029 var formatDateTime = (value) => {
16030 if (!value) {
16031 return "";
16032 }
16033 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
16034 };
16035 function CalendarDateTimeControl({
16036 data,
16037 field,
16038 onChange,
16039 hideLabelFromVision,
16040 markWhenOptional,
16041 validity,
16042 config
16043 }) {
16044 const { compact } = config || {};
16045 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
16046 const disabled2 = field.isDisabled({ item: data, field });
16047 const fieldValue = getValue({ item: data });
16048 const value = typeof fieldValue === "string" ? fieldValue : void 0;
16049 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
16050 const parsedDate = parseDateTime(value);
16051 return parsedDate || /* @__PURE__ */ new Date();
16052 });
16053 const inputControlRef = (0, import_element61.useRef)(null);
16054 const validationTimeoutRef = (0, import_element61.useRef)(void 0);
16055 const previousFocusRef = (0, import_element61.useRef)(null);
16056 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
16057 const onChangeCallback = (0, import_element61.useCallback)(
16058 (newValue) => onChange(setValue({ item: data, value: newValue })),
16059 [data, onChange, setValue]
16060 );
16061 (0, import_element61.useEffect)(() => {
16062 return () => {
16063 if (validationTimeoutRef.current) {
16064 clearTimeout(validationTimeoutRef.current);
16065 }
16066 };
16067 }, []);
16068 const onSelectDate = (0, import_element61.useCallback)(
16069 (newDate) => {
16070 let dateTimeValue;
16071 if (newDate) {
16072 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
16073 let wpTime;
16074 if (value) {
16075 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
16076 } else {
16077 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
16078 }
16079 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
16080 dateTimeValue = finalDateTime.toISOString();
16081 onChangeCallback(dateTimeValue);
16082 if (validationTimeoutRef.current) {
16083 clearTimeout(validationTimeoutRef.current);
16084 }
16085 } else {
16086 onChangeCallback(void 0);
16087 }
16088 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
16089 validationTimeoutRef.current = setTimeout(() => {
16090 if (inputControlRef.current) {
16091 inputControlRef.current.focus();
16092 inputControlRef.current.blur();
16093 onChangeCallback(dateTimeValue);
16094 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
16095 previousFocusRef.current.focus();
16096 }
16097 }
16098 }, 0);
16099 },
16100 [onChangeCallback, value]
16101 );
16102 const handleManualDateTimeChange = (0, import_element61.useCallback)(
16103 (newValue) => {
16104 if (newValue) {
16105 const dateTime = (0, import_date3.getDate)(newValue);
16106 onChangeCallback(dateTime.toISOString());
16107 const parsedDate = parseDateTime(dateTime.toISOString());
16108 if (parsedDate) {
16109 setCalendarMonth(parsedDate);
16110 }
16111 } else {
16112 onChangeCallback(void 0);
16113 }
16114 },
16115 [onChangeCallback]
16116 );
16117 const { format: fieldFormat } = field;
16118 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
16119 const {
16120 timezone: { string: timezoneString }
16121 } = (0, import_date3.getSettings)();
16122 let displayLabel = label;
16123 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
16124 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
16125 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
16126 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
16127 }
16128 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16129 import_components32.BaseControl,
16130 {
16131 id,
16132 label: displayLabel,
16133 help: description,
16134 hideLabelFromVision,
16135 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16136 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16137 ValidatedInputControl,
16138 {
16139 ref: inputControlRef,
16140 __next40pxDefaultSize: true,
16141 required: !!isValid2?.required,
16142 customValidity: getCustomValidity(isValid2, validity),
16143 type: "datetime-local",
16144 label: (0, import_i18n33.__)("Date time"),
16145 hideLabelFromVision: true,
16146 value: formatDateTime(value),
16147 onChange: handleManualDateTimeChange,
16148 disabled: disabled2,
16149 min: minConstraint ? formatDateTime(minConstraint) : void 0,
16150 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
16151 }
16152 ),
16153 !compact && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16154 DateCalendar,
16155 {
16156 style: { width: "100%" },
16157 selected: value ? parseDateTime(value) || void 0 : void 0,
16158 onSelect: onSelectDate,
16159 month: calendarMonth,
16160 onMonthChange: setCalendarMonth,
16161 timeZone: timezoneString || void 0,
16162 weekStartsOn,
16163 disabled: disabled2 || disabledMatchers
16164 }
16165 )
16166 ] })
16167 }
16168 );
16169 }
16170 function DateTime({
16171 data,
16172 field,
16173 onChange,
16174 hideLabelFromVision,
16175 markWhenOptional,
16176 operator,
16177 validity,
16178 config
16179 }) {
16180 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
16181 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16182 RelativeDateControl,
16183 {
16184 className: "dataviews-controls__datetime",
16185 data,
16186 field,
16187 onChange,
16188 hideLabelFromVision,
16189 operator
16190 }
16191 );
16192 }
16193 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16194 CalendarDateTimeControl,
16195 {
16196 data,
16197 field,
16198 onChange,
16199 hideLabelFromVision,
16200 markWhenOptional,
16201 validity,
16202 config
16203 }
16204 );
16205 }
16206
16207 // packages/dataviews/build-module/components/dataform-controls/date.mjs
16208 var import_components33 = __toESM(require_components(), 1);
16209 var import_element62 = __toESM(require_element(), 1);
16210 var import_i18n34 = __toESM(require_i18n(), 1);
16211 var import_date4 = __toESM(require_date(), 1);
16212 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
16213 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components33.privateApis);
16214 var DATE_PRESETS = [
16215 {
16216 id: "today",
16217 label: (0, import_i18n34.__)("Today"),
16218 getValue: () => (0, import_date4.getDate)(null)
16219 },
16220 {
16221 id: "yesterday",
16222 label: (0, import_i18n34.__)("Yesterday"),
16223 getValue: () => {
16224 const today = (0, import_date4.getDate)(null);
16225 return subDays(today, 1);
16226 }
16227 },
16228 {
16229 id: "past-week",
16230 label: (0, import_i18n34.__)("Past week"),
16231 getValue: () => {
16232 const today = (0, import_date4.getDate)(null);
16233 return subDays(today, 7);
16234 }
16235 },
16236 {
16237 id: "past-month",
16238 label: (0, import_i18n34.__)("Past month"),
16239 getValue: () => {
16240 const today = (0, import_date4.getDate)(null);
16241 return subMonths(today, 1);
16242 }
16243 }
16244 ];
16245 var DATE_RANGE_PRESETS = [
16246 {
16247 id: "last-7-days",
16248 label: (0, import_i18n34.__)("Last 7 days"),
16249 getValue: () => {
16250 const today = (0, import_date4.getDate)(null);
16251 return [subDays(today, 7), today];
16252 }
16253 },
16254 {
16255 id: "last-30-days",
16256 label: (0, import_i18n34.__)("Last 30 days"),
16257 getValue: () => {
16258 const today = (0, import_date4.getDate)(null);
16259 return [subDays(today, 30), today];
16260 }
16261 },
16262 {
16263 id: "month-to-date",
16264 label: (0, import_i18n34.__)("Month to date"),
16265 getValue: () => {
16266 const today = (0, import_date4.getDate)(null);
16267 return [startOfMonth(today), today];
16268 }
16269 },
16270 {
16271 id: "last-year",
16272 label: (0, import_i18n34.__)("Last year"),
16273 getValue: () => {
16274 const today = (0, import_date4.getDate)(null);
16275 return [subYears(today, 1), today];
16276 }
16277 },
16278 {
16279 id: "year-to-date",
16280 label: (0, import_i18n34.__)("Year to date"),
16281 getValue: () => {
16282 const today = (0, import_date4.getDate)(null);
16283 return [startOfYear(today), today];
16284 }
16285 }
16286 ];
16287 var parseDate = (dateString) => {
16288 if (!dateString) {
16289 return null;
16290 }
16291 const parsed = (0, import_date4.getDate)(dateString);
16292 return parsed && isValid(parsed) ? parsed : null;
16293 };
16294 var formatDate = (date) => {
16295 if (!date) {
16296 return "";
16297 }
16298 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
16299 };
16300 function ValidatedDateControl({
16301 field,
16302 validity,
16303 inputRefs,
16304 isTouched,
16305 setIsTouched,
16306 children
16307 }) {
16308 const { isValid: isValid2 } = field;
16309 const [customValidity, setCustomValidity] = (0, import_element62.useState)(void 0);
16310 const validateRefs = (0, import_element62.useCallback)(() => {
16311 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16312 for (const ref of refs) {
16313 const input = ref.current;
16314 if (input && !input.validity.valid) {
16315 setCustomValidity({
16316 type: "invalid",
16317 message: input.validationMessage
16318 });
16319 return;
16320 }
16321 }
16322 setCustomValidity(void 0);
16323 }, [inputRefs]);
16324 (0, import_element62.useEffect)(() => {
16325 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16326 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
16327 for (const ref of refs) {
16328 const input = ref.current;
16329 if (input) {
16330 input.setCustomValidity(
16331 result?.type === "invalid" && result.message ? result.message : ""
16332 );
16333 }
16334 }
16335 }, [inputRefs, isValid2, validity]);
16336 (0, import_element62.useEffect)(() => {
16337 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
16338 const handleInvalid = (event) => {
16339 event.preventDefault();
16340 setIsTouched(true);
16341 };
16342 for (const ref of refs) {
16343 ref.current?.addEventListener("invalid", handleInvalid);
16344 }
16345 return () => {
16346 for (const ref of refs) {
16347 ref.current?.removeEventListener("invalid", handleInvalid);
16348 }
16349 };
16350 }, [inputRefs, setIsTouched]);
16351 (0, import_element62.useEffect)(() => {
16352 if (!isTouched) {
16353 return;
16354 }
16355 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
16356 if (result) {
16357 setCustomValidity(result);
16358 } else {
16359 validateRefs();
16360 }
16361 }, [isTouched, isValid2, validity, validateRefs]);
16362 const onBlur = (event) => {
16363 if (isTouched) {
16364 return;
16365 }
16366 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
16367 setIsTouched(true);
16368 }
16369 };
16370 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { onBlur, children: [
16371 children,
16372 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16373 "p",
16374 {
16375 className: clsx_default(
16376 "components-validated-control__indicator",
16377 customValidity.type === "invalid" ? "is-invalid" : void 0
16378 ),
16379 children: [
16380 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16381 import_components33.Icon,
16382 {
16383 className: "components-validated-control__indicator-icon",
16384 icon: error_default,
16385 size: 16,
16386 fill: "currentColor"
16387 }
16388 ),
16389 customValidity.message
16390 ]
16391 }
16392 ) })
16393 ] });
16394 }
16395 function CalendarDateControl({
16396 data,
16397 field,
16398 onChange,
16399 hideLabelFromVision,
16400 markWhenOptional,
16401 validity
16402 }) {
16403 const {
16404 id,
16405 label,
16406 description,
16407 setValue,
16408 getValue,
16409 isValid: isValid2,
16410 format: fieldFormat
16411 } = field;
16412 const disabled2 = field.isDisabled({ item: data, field });
16413 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
16414 null
16415 );
16416 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
16417 const fieldValue = getValue({ item: data });
16418 const value = typeof fieldValue === "string" ? fieldValue : void 0;
16419 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
16420 const parsedDate = parseDate(value);
16421 return parsedDate || /* @__PURE__ */ new Date();
16422 });
16423 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
16424 const validityTargetRef = (0, import_element62.useRef)(null);
16425 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
16426 const onChangeCallback = (0, import_element62.useCallback)(
16427 (newValue) => onChange(setValue({ item: data, value: newValue })),
16428 [data, onChange, setValue]
16429 );
16430 const onSelectDate = (0, import_element62.useCallback)(
16431 (newDate) => {
16432 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
16433 onChangeCallback(dateValue);
16434 setSelectedPresetId(null);
16435 setIsTouched(true);
16436 },
16437 [onChangeCallback]
16438 );
16439 const handlePresetClick = (0, import_element62.useCallback)(
16440 (preset) => {
16441 const presetDate = preset.getValue();
16442 const dateValue = formatDate(presetDate);
16443 setCalendarMonth(presetDate);
16444 onChangeCallback(dateValue);
16445 setSelectedPresetId(preset.id);
16446 setIsTouched(true);
16447 },
16448 [onChangeCallback]
16449 );
16450 const handleManualDateChange = (0, import_element62.useCallback)(
16451 (newValue) => {
16452 onChangeCallback(newValue);
16453 if (newValue) {
16454 const parsedDate = parseDate(newValue);
16455 if (parsedDate) {
16456 setCalendarMonth(parsedDate);
16457 }
16458 }
16459 setSelectedPresetId(null);
16460 setIsTouched(true);
16461 },
16462 [onChangeCallback]
16463 );
16464 const {
16465 timezone: { string: timezoneString }
16466 } = (0, import_date4.getSettings)();
16467 let displayLabel = label;
16468 if (isValid2?.required && !markWhenOptional) {
16469 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
16470 } else if (!isValid2?.required && markWhenOptional) {
16471 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
16472 }
16473 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16474 ValidatedDateControl,
16475 {
16476 field,
16477 validity,
16478 inputRefs: validityTargetRef,
16479 isTouched,
16480 setIsTouched,
16481 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16482 import_components33.BaseControl,
16483 {
16484 id,
16485 className: "dataviews-controls__date",
16486 label: displayLabel,
16487 help: description,
16488 hideLabelFromVision,
16489 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16490 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16491 Stack,
16492 {
16493 direction: "row",
16494 gap: "sm",
16495 wrap: "wrap",
16496 justify: "flex-start",
16497 children: [
16498 DATE_PRESETS.map((preset) => {
16499 const isSelected2 = selectedPresetId === preset.id;
16500 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16501 import_components33.Button,
16502 {
16503 className: "dataviews-controls__date-preset",
16504 variant: "tertiary",
16505 isPressed: isSelected2,
16506 size: "small",
16507 disabled: disabled2,
16508 accessibleWhenDisabled: true,
16509 onClick: () => handlePresetClick(preset),
16510 children: preset.label
16511 },
16512 preset.id
16513 );
16514 }),
16515 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16516 import_components33.Button,
16517 {
16518 className: "dataviews-controls__date-preset",
16519 variant: "tertiary",
16520 isPressed: !selectedPresetId,
16521 size: "small",
16522 disabled: !!selectedPresetId || disabled2,
16523 accessibleWhenDisabled: true,
16524 children: (0, import_i18n34.__)("Custom")
16525 }
16526 )
16527 ]
16528 }
16529 ),
16530 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16531 import_components33.__experimentalInputControl,
16532 {
16533 __next40pxDefaultSize: true,
16534 ref: validityTargetRef,
16535 type: "date",
16536 label: (0, import_i18n34.__)("Date"),
16537 hideLabelFromVision: true,
16538 value,
16539 onChange: handleManualDateChange,
16540 required: !!field.isValid?.required,
16541 disabled: disabled2,
16542 min: minConstraint,
16543 max: maxConstraint
16544 }
16545 ),
16546 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16547 DateCalendar2,
16548 {
16549 style: { width: "100%" },
16550 selected: value ? parseDate(value) || void 0 : void 0,
16551 onSelect: onSelectDate,
16552 month: calendarMonth,
16553 onMonthChange: setCalendarMonth,
16554 timeZone: timezoneString || void 0,
16555 weekStartsOn,
16556 disabled: disabled2 || disabledMatchers,
16557 disableNavigation: disabled2
16558 }
16559 )
16560 ] })
16561 }
16562 )
16563 }
16564 );
16565 }
16566 function CalendarDateRangeControl({
16567 data,
16568 field,
16569 onChange,
16570 hideLabelFromVision,
16571 markWhenOptional,
16572 validity
16573 }) {
16574 const {
16575 id,
16576 label,
16577 description,
16578 getValue,
16579 setValue,
16580 isValid: isValid2,
16581 format: fieldFormat
16582 } = field;
16583 const disabled2 = field.isDisabled({ item: data, field });
16584 let value;
16585 const fieldValue = getValue({ item: data });
16586 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
16587 value = fieldValue;
16588 }
16589 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
16590 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
16591 const onChangeCallback = (0, import_element62.useCallback)(
16592 (newValue) => {
16593 onChange(
16594 setValue({
16595 item: data,
16596 value: newValue
16597 })
16598 );
16599 },
16600 [data, onChange, setValue]
16601 );
16602 const [selectedPresetId, setSelectedPresetId] = (0, import_element62.useState)(
16603 null
16604 );
16605 const selectedRange = (0, import_element62.useMemo)(() => {
16606 if (!value) {
16607 return { from: void 0, to: void 0 };
16608 }
16609 const [from, to] = value;
16610 return {
16611 from: parseDate(from) || void 0,
16612 to: parseDate(to) || void 0
16613 };
16614 }, [value]);
16615 const [calendarMonth, setCalendarMonth] = (0, import_element62.useState)(() => {
16616 return selectedRange.from || /* @__PURE__ */ new Date();
16617 });
16618 const [isTouched, setIsTouched] = (0, import_element62.useState)(false);
16619 const fromInputRef = (0, import_element62.useRef)(null);
16620 const toInputRef = (0, import_element62.useRef)(null);
16621 const updateDateRange = (0, import_element62.useCallback)(
16622 (fromDate, toDate2) => {
16623 if (fromDate && toDate2) {
16624 onChangeCallback([
16625 formatDate(fromDate),
16626 formatDate(toDate2)
16627 ]);
16628 } else if (!fromDate && !toDate2) {
16629 onChangeCallback(void 0);
16630 }
16631 },
16632 [onChangeCallback]
16633 );
16634 const onSelectCalendarRange = (0, import_element62.useCallback)(
16635 (newRange) => {
16636 updateDateRange(newRange?.from, newRange?.to);
16637 setSelectedPresetId(null);
16638 setIsTouched(true);
16639 },
16640 [updateDateRange]
16641 );
16642 const handlePresetClick = (0, import_element62.useCallback)(
16643 (preset) => {
16644 const [startDate, endDate] = preset.getValue();
16645 setCalendarMonth(startDate);
16646 updateDateRange(startDate, endDate);
16647 setSelectedPresetId(preset.id);
16648 setIsTouched(true);
16649 },
16650 [updateDateRange]
16651 );
16652 const handleManualDateChange = (0, import_element62.useCallback)(
16653 (fromOrTo, newValue) => {
16654 const [currentFrom, currentTo] = value || [
16655 void 0,
16656 void 0
16657 ];
16658 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
16659 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
16660 updateDateRange(updatedFrom, updatedTo);
16661 if (newValue) {
16662 const parsedDate = parseDate(newValue);
16663 if (parsedDate) {
16664 setCalendarMonth(parsedDate);
16665 }
16666 }
16667 setSelectedPresetId(null);
16668 setIsTouched(true);
16669 },
16670 [value, updateDateRange]
16671 );
16672 const { timezone } = (0, import_date4.getSettings)();
16673 let displayLabel = label;
16674 if (field.isValid?.required && !markWhenOptional) {
16675 displayLabel = `${label} (${(0, import_i18n34.__)("Required")})`;
16676 } else if (!field.isValid?.required && markWhenOptional) {
16677 displayLabel = `${label} (${(0, import_i18n34.__)("Optional")})`;
16678 }
16679 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16680 ValidatedDateControl,
16681 {
16682 field,
16683 validity,
16684 inputRefs: [fromInputRef, toInputRef],
16685 isTouched,
16686 setIsTouched,
16687 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16688 import_components33.BaseControl,
16689 {
16690 id,
16691 className: "dataviews-controls__date",
16692 label: displayLabel,
16693 help: description,
16694 hideLabelFromVision,
16695 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16696 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16697 Stack,
16698 {
16699 direction: "row",
16700 gap: "sm",
16701 wrap: "wrap",
16702 justify: "flex-start",
16703 children: [
16704 DATE_RANGE_PRESETS.map((preset) => {
16705 const isSelected2 = selectedPresetId === preset.id;
16706 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16707 import_components33.Button,
16708 {
16709 className: "dataviews-controls__date-preset",
16710 variant: "tertiary",
16711 isPressed: isSelected2,
16712 size: "small",
16713 disabled: disabled2,
16714 accessibleWhenDisabled: true,
16715 onClick: () => handlePresetClick(preset),
16716 children: preset.label
16717 },
16718 preset.id
16719 );
16720 }),
16721 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16722 import_components33.Button,
16723 {
16724 className: "dataviews-controls__date-preset",
16725 variant: "tertiary",
16726 isPressed: !selectedPresetId,
16727 size: "small",
16728 accessibleWhenDisabled: true,
16729 disabled: !!selectedPresetId || disabled2,
16730 children: (0, import_i18n34.__)("Custom")
16731 }
16732 )
16733 ]
16734 }
16735 ),
16736 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
16737 Stack,
16738 {
16739 direction: "row",
16740 gap: "sm",
16741 justify: "space-between",
16742 className: "dataviews-controls__date-range-inputs",
16743 children: [
16744 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16745 import_components33.__experimentalInputControl,
16746 {
16747 __next40pxDefaultSize: true,
16748 ref: fromInputRef,
16749 type: "date",
16750 label: (0, import_i18n34.__)("From"),
16751 hideLabelFromVision: true,
16752 value: value?.[0],
16753 onChange: (newValue) => handleManualDateChange("from", newValue),
16754 required: !!field.isValid?.required,
16755 disabled: disabled2,
16756 min: minConstraint,
16757 max: maxConstraint
16758 }
16759 ),
16760 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16761 import_components33.__experimentalInputControl,
16762 {
16763 __next40pxDefaultSize: true,
16764 ref: toInputRef,
16765 type: "date",
16766 label: (0, import_i18n34.__)("To"),
16767 hideLabelFromVision: true,
16768 value: value?.[1],
16769 onChange: (newValue) => handleManualDateChange("to", newValue),
16770 required: !!field.isValid?.required,
16771 disabled: disabled2,
16772 min: minConstraint,
16773 max: maxConstraint
16774 }
16775 )
16776 ]
16777 }
16778 ),
16779 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16780 DateRangeCalendar,
16781 {
16782 style: { width: "100%" },
16783 selected: selectedRange,
16784 onSelect: onSelectCalendarRange,
16785 month: calendarMonth,
16786 onMonthChange: setCalendarMonth,
16787 timeZone: timezone.string || void 0,
16788 weekStartsOn,
16789 disabled: disabled2 || disabledMatchers
16790 }
16791 )
16792 ] })
16793 }
16794 )
16795 }
16796 );
16797 }
16798 function DateControl({
16799 data,
16800 field,
16801 onChange,
16802 hideLabelFromVision,
16803 markWhenOptional,
16804 operator,
16805 validity
16806 }) {
16807 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
16808 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16809 RelativeDateControl,
16810 {
16811 className: "dataviews-controls__date",
16812 data,
16813 field,
16814 onChange,
16815 hideLabelFromVision,
16816 operator
16817 }
16818 );
16819 }
16820 if (operator === OPERATOR_BETWEEN) {
16821 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16822 CalendarDateRangeControl,
16823 {
16824 data,
16825 field,
16826 onChange,
16827 hideLabelFromVision,
16828 markWhenOptional,
16829 validity
16830 }
16831 );
16832 }
16833 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
16834 CalendarDateControl,
16835 {
16836 data,
16837 field,
16838 onChange,
16839 hideLabelFromVision,
16840 markWhenOptional,
16841 validity
16842 }
16843 );
16844 }
16845
16846 // packages/dataviews/build-module/components/dataform-controls/select.mjs
16847 var import_components34 = __toESM(require_components(), 1);
16848 var import_element63 = __toESM(require_element(), 1);
16849 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
16850 var { ValidatedSelectControl } = unlock(import_components34.privateApis);
16851 function Select({
16852 data,
16853 field,
16854 onChange,
16855 hideLabelFromVision,
16856 markWhenOptional,
16857 validity
16858 }) {
16859 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
16860 const disabled2 = field.isDisabled({ item: data, field });
16861 const isMultiple = type === "array";
16862 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
16863 const onChangeControl = (0, import_element63.useCallback)(
16864 (newValue) => onChange(setValue({ item: data, value: newValue })),
16865 [data, onChange, setValue]
16866 );
16867 const { elements, isLoading } = useElements({
16868 elements: field.elements,
16869 getElements: field.getElements
16870 });
16871 if (isLoading) {
16872 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.Spinner, {});
16873 }
16874 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
16875 ValidatedSelectControl,
16876 {
16877 required: !!field.isValid?.required,
16878 markWhenOptional,
16879 customValidity: getCustomValidity(isValid2, validity),
16880 label,
16881 value,
16882 help: description,
16883 options: elements,
16884 onChange: onChangeControl,
16885 __next40pxDefaultSize: true,
16886 hideLabelFromVision,
16887 multiple: isMultiple,
16888 disabled: disabled2
16889 }
16890 );
16891 }
16892
16893 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
16894 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
16895 var ELEMENTS_THRESHOLD = 10;
16896 function AdaptiveSelect(props) {
16897 const { field } = props;
16898 const { elements } = useElements({
16899 elements: field.elements,
16900 getElements: field.getElements
16901 });
16902 if (elements.length >= ELEMENTS_THRESHOLD) {
16903 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Combobox3, { ...props });
16904 }
16905 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Select, { ...props });
16906 }
16907
16908 // packages/dataviews/build-module/components/dataform-controls/email.mjs
16909 var import_components36 = __toESM(require_components(), 1);
16910
16911 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
16912 var import_components35 = __toESM(require_components(), 1);
16913 var import_element64 = __toESM(require_element(), 1);
16914 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
16915 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components35.privateApis);
16916 function ValidatedText({
16917 data,
16918 field,
16919 onChange,
16920 hideLabelFromVision,
16921 markWhenOptional,
16922 type,
16923 prefix,
16924 suffix,
16925 validity
16926 }) {
16927 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
16928 const value = getValue({ item: data });
16929 const disabled2 = field.isDisabled({ item: data, field });
16930 const onChangeControl = (0, import_element64.useCallback)(
16931 (newValue) => onChange(
16932 setValue({
16933 item: data,
16934 value: newValue
16935 })
16936 ),
16937 [data, setValue, onChange]
16938 );
16939 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
16940 ValidatedInputControl2,
16941 {
16942 required: !!isValid2.required,
16943 markWhenOptional,
16944 customValidity: getCustomValidity(isValid2, validity),
16945 label,
16946 placeholder,
16947 value: value ?? "",
16948 help: description,
16949 onChange: onChangeControl,
16950 hideLabelFromVision,
16951 type,
16952 prefix,
16953 suffix,
16954 disabled: disabled2,
16955 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
16956 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
16957 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
16958 __next40pxDefaultSize: true
16959 }
16960 );
16961 }
16962
16963 // packages/dataviews/build-module/components/dataform-controls/email.mjs
16964 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
16965 function Email({
16966 data,
16967 field,
16968 onChange,
16969 hideLabelFromVision,
16970 markWhenOptional,
16971 validity
16972 }) {
16973 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
16974 ValidatedText,
16975 {
16976 ...{
16977 data,
16978 field,
16979 onChange,
16980 hideLabelFromVision,
16981 markWhenOptional,
16982 validity,
16983 type: "email",
16984 prefix: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components36.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_components36.Icon, { icon: envelope_default }) })
16985 }
16986 }
16987 );
16988 }
16989
16990 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
16991 var import_components37 = __toESM(require_components(), 1);
16992 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
16993 function Telephone({
16994 data,
16995 field,
16996 onChange,
16997 hideLabelFromVision,
16998 markWhenOptional,
16999 validity
17000 }) {
17001 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17002 ValidatedText,
17003 {
17004 ...{
17005 data,
17006 field,
17007 onChange,
17008 hideLabelFromVision,
17009 markWhenOptional,
17010 validity,
17011 type: "tel",
17012 prefix: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components37.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_components37.Icon, { icon: mobile_default }) })
17013 }
17014 }
17015 );
17016 }
17017
17018 // packages/dataviews/build-module/components/dataform-controls/url.mjs
17019 var import_components38 = __toESM(require_components(), 1);
17020 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
17021 function Url({
17022 data,
17023 field,
17024 onChange,
17025 hideLabelFromVision,
17026 markWhenOptional,
17027 validity
17028 }) {
17029 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
17030 ValidatedText,
17031 {
17032 ...{
17033 data,
17034 field,
17035 onChange,
17036 hideLabelFromVision,
17037 markWhenOptional,
17038 validity,
17039 type: "url",
17040 prefix: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components38.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_components38.Icon, { icon: link_default }) })
17041 }
17042 }
17043 );
17044 }
17045
17046 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
17047 var import_components39 = __toESM(require_components(), 1);
17048 var import_element65 = __toESM(require_element(), 1);
17049 var import_i18n35 = __toESM(require_i18n(), 1);
17050 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
17051 var { ValidatedNumberControl } = unlock(import_components39.privateApis);
17052 function toNumberOrEmpty(value) {
17053 if (value === "" || value === void 0) {
17054 return "";
17055 }
17056 const number = Number(value);
17057 return Number.isFinite(number) ? number : "";
17058 }
17059 function BetweenControls({
17060 value,
17061 onChange,
17062 hideLabelFromVision,
17063 step
17064 }) {
17065 const [min = "", max = ""] = value;
17066 const onChangeMin = (0, import_element65.useCallback)(
17067 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
17068 [onChange, max]
17069 );
17070 const onChangeMax = (0, import_element65.useCallback)(
17071 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
17072 [onChange, min]
17073 );
17074 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17075 import_components39.BaseControl,
17076 {
17077 help: (0, import_i18n35.__)("The max. value must be greater than the min. value."),
17078 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [
17079 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17080 import_components39.__experimentalNumberControl,
17081 {
17082 label: (0, import_i18n35.__)("Min."),
17083 value: min,
17084 max: max ? Number(max) - step : void 0,
17085 onChange: onChangeMin,
17086 __next40pxDefaultSize: true,
17087 hideLabelFromVision,
17088 step
17089 }
17090 ),
17091 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17092 import_components39.__experimentalNumberControl,
17093 {
17094 label: (0, import_i18n35.__)("Max."),
17095 value: max,
17096 min: min ? Number(min) + step : void 0,
17097 onChange: onChangeMax,
17098 __next40pxDefaultSize: true,
17099 hideLabelFromVision,
17100 step
17101 }
17102 )
17103 ] })
17104 }
17105 );
17106 }
17107 function ValidatedNumber({
17108 data,
17109 field,
17110 onChange,
17111 hideLabelFromVision,
17112 markWhenOptional,
17113 operator,
17114 validity
17115 }) {
17116 const decimals = field.format?.decimals ?? 0;
17117 const step = Math.pow(10, Math.abs(decimals) * -1);
17118 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17119 const value = getValue({ item: data }) ?? "";
17120 const disabled2 = field.isDisabled({ item: data, field });
17121 const onChangeControl = (0, import_element65.useCallback)(
17122 (newValue) => {
17123 onChange(
17124 setValue({
17125 item: data,
17126 // Do not convert an empty string or undefined to a number,
17127 // otherwise there's a mismatch between the UI control (empty)
17128 // and the data relied by onChange (0).
17129 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
17130 })
17131 );
17132 },
17133 [data, onChange, setValue]
17134 );
17135 const onChangeBetweenControls = (0, import_element65.useCallback)(
17136 (newValue) => {
17137 onChange(
17138 setValue({
17139 item: data,
17140 value: newValue
17141 })
17142 );
17143 },
17144 [data, onChange, setValue]
17145 );
17146 if (operator === OPERATOR_BETWEEN) {
17147 let valueBetween = ["", ""];
17148 if (Array.isArray(value) && value.length === 2 && value.every(
17149 (element) => typeof element === "number" || element === ""
17150 )) {
17151 valueBetween = value;
17152 }
17153 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17154 BetweenControls,
17155 {
17156 value: valueBetween,
17157 onChange: onChangeBetweenControls,
17158 hideLabelFromVision,
17159 step
17160 }
17161 );
17162 }
17163 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17164 ValidatedNumberControl,
17165 {
17166 required: !!isValid2.required,
17167 markWhenOptional,
17168 customValidity: getCustomValidity(isValid2, validity),
17169 label,
17170 help: description,
17171 value,
17172 onChange: onChangeControl,
17173 __next40pxDefaultSize: true,
17174 hideLabelFromVision,
17175 step,
17176 min: isValid2.min ? isValid2.min.constraint : void 0,
17177 max: isValid2.max ? isValid2.max.constraint : void 0,
17178 disabled: disabled2
17179 }
17180 );
17181 }
17182
17183 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
17184 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
17185 function Integer(props) {
17186 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ValidatedNumber, { ...props });
17187 }
17188
17189 // packages/dataviews/build-module/components/dataform-controls/number.mjs
17190 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
17191 function Number2(props) {
17192 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ValidatedNumber, { ...props });
17193 }
17194
17195 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
17196 var import_components40 = __toESM(require_components(), 1);
17197 var import_element66 = __toESM(require_element(), 1);
17198 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
17199 var { ValidatedRadioControl } = unlock(import_components40.privateApis);
17200 function Radio({
17201 data,
17202 field,
17203 onChange,
17204 hideLabelFromVision,
17205 markWhenOptional,
17206 validity
17207 }) {
17208 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17209 const disabled2 = field.isDisabled({ item: data, field });
17210 const { elements, isLoading } = useElements({
17211 elements: field.elements,
17212 getElements: field.getElements
17213 });
17214 const value = getValue({ item: data });
17215 const onChangeControl = (0, import_element66.useCallback)(
17216 (newValue) => onChange(setValue({ item: data, value: newValue })),
17217 [data, onChange, setValue]
17218 );
17219 if (isLoading) {
17220 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components40.Spinner, {});
17221 }
17222 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
17223 ValidatedRadioControl,
17224 {
17225 required: !!field.isValid?.required,
17226 markWhenOptional,
17227 customValidity: getCustomValidity(isValid2, validity),
17228 label,
17229 help: description,
17230 onChange: onChangeControl,
17231 options: elements,
17232 selected: value,
17233 hideLabelFromVision,
17234 disabled: disabled2
17235 }
17236 );
17237 }
17238
17239 // packages/dataviews/build-module/components/dataform-controls/text.mjs
17240 var import_element67 = __toESM(require_element(), 1);
17241 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
17242 function Text3({
17243 data,
17244 field,
17245 onChange,
17246 hideLabelFromVision,
17247 markWhenOptional,
17248 config,
17249 validity
17250 }) {
17251 const { prefix, suffix } = config || {};
17252 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
17253 ValidatedText,
17254 {
17255 ...{
17256 data,
17257 field,
17258 onChange,
17259 hideLabelFromVision,
17260 markWhenOptional,
17261 validity,
17262 prefix: prefix ? (0, import_element67.createElement)(prefix) : void 0,
17263 suffix: suffix ? (0, import_element67.createElement)(suffix) : void 0
17264 }
17265 }
17266 );
17267 }
17268
17269 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
17270 var import_components41 = __toESM(require_components(), 1);
17271 var import_element68 = __toESM(require_element(), 1);
17272 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
17273 var { ValidatedToggleControl } = unlock(import_components41.privateApis);
17274 function Toggle({
17275 field,
17276 onChange,
17277 data,
17278 hideLabelFromVision,
17279 markWhenOptional,
17280 validity
17281 }) {
17282 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17283 const disabled2 = field.isDisabled({ item: data, field });
17284 const onChangeControl = (0, import_element68.useCallback)(() => {
17285 onChange(
17286 setValue({ item: data, value: !getValue({ item: data }) })
17287 );
17288 }, [onChange, setValue, data, getValue]);
17289 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
17290 ValidatedToggleControl,
17291 {
17292 required: !!isValid2.required,
17293 markWhenOptional,
17294 customValidity: getCustomValidity(isValid2, validity),
17295 hidden: hideLabelFromVision,
17296 label,
17297 help: description,
17298 checked: getValue({ item: data }),
17299 onChange: onChangeControl,
17300 disabled: disabled2
17301 }
17302 );
17303 }
17304
17305 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
17306 var import_components42 = __toESM(require_components(), 1);
17307 var import_element69 = __toESM(require_element(), 1);
17308 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
17309 var { ValidatedTextareaControl } = unlock(import_components42.privateApis);
17310 function Textarea({
17311 data,
17312 field,
17313 onChange,
17314 hideLabelFromVision,
17315 markWhenOptional,
17316 config,
17317 validity
17318 }) {
17319 const { rows = 4 } = config || {};
17320 const disabled2 = field.isDisabled({ item: data, field });
17321 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
17322 const value = field.getValue({ item: data });
17323 const onChangeControl = (0, import_element69.useCallback)(
17324 (newValue) => onChange(setValue({ item: data, value: newValue })),
17325 [data, onChange, setValue]
17326 );
17327 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
17328 ValidatedTextareaControl,
17329 {
17330 required: !!isValid2.required,
17331 markWhenOptional,
17332 customValidity: getCustomValidity(isValid2, validity),
17333 label,
17334 placeholder,
17335 value: value ?? "",
17336 help: description,
17337 onChange: onChangeControl,
17338 rows,
17339 disabled: disabled2,
17340 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
17341 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
17342 __next40pxDefaultSize: true,
17343 hideLabelFromVision
17344 }
17345 );
17346 }
17347
17348 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
17349 var import_components43 = __toESM(require_components(), 1);
17350 var import_element70 = __toESM(require_element(), 1);
17351 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
17352 var { ValidatedToggleGroupControl } = unlock(import_components43.privateApis);
17353 function ToggleGroup({
17354 data,
17355 field,
17356 onChange,
17357 hideLabelFromVision,
17358 markWhenOptional,
17359 validity
17360 }) {
17361 const { getValue, setValue, isValid: isValid2 } = field;
17362 const disabled2 = field.isDisabled({ item: data, field });
17363 const value = getValue({ item: data });
17364 const onChangeControl = (0, import_element70.useCallback)(
17365 (newValue) => onChange(setValue({ item: data, value: newValue })),
17366 [data, onChange, setValue]
17367 );
17368 const { elements, isLoading } = useElements({
17369 elements: field.elements,
17370 getElements: field.getElements
17371 });
17372 if (isLoading) {
17373 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components43.Spinner, {});
17374 }
17375 if (elements.length === 0) {
17376 return null;
17377 }
17378 const selectedOption = elements.find((el) => el.value === value);
17379 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
17380 ValidatedToggleGroupControl,
17381 {
17382 required: !!field.isValid?.required,
17383 markWhenOptional,
17384 customValidity: getCustomValidity(isValid2, validity),
17385 __next40pxDefaultSize: true,
17386 isBlock: true,
17387 label: field.label,
17388 help: selectedOption?.description || field.description,
17389 onChange: onChangeControl,
17390 value,
17391 hideLabelFromVision,
17392 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
17393 import_components43.__experimentalToggleGroupControlOption,
17394 {
17395 label: el.label,
17396 value: el.value,
17397 disabled: disabled2
17398 },
17399 el.value
17400 ))
17401 }
17402 );
17403 }
17404
17405 // packages/dataviews/build-module/components/dataform-controls/array.mjs
17406 var import_components44 = __toESM(require_components(), 1);
17407 var import_element71 = __toESM(require_element(), 1);
17408 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
17409 var { ValidatedFormTokenField } = unlock(import_components44.privateApis);
17410 function ArrayControl({
17411 data,
17412 field,
17413 onChange,
17414 hideLabelFromVision,
17415 markWhenOptional,
17416 validity
17417 }) {
17418 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
17419 const value = getValue({ item: data });
17420 const disabled2 = field.isDisabled({ item: data, field });
17421 const { elements, isLoading } = useElements({
17422 elements: field.elements,
17423 getElements: field.getElements
17424 });
17425 const arrayValueAsElements = (0, import_element71.useMemo)(
17426 () => Array.isArray(value) ? value.map((token) => {
17427 const element = elements?.find(
17428 (suggestion) => suggestion.value === token
17429 );
17430 return element || { value: token, label: token };
17431 }) : [],
17432 [value, elements]
17433 );
17434 const onChangeControl = (0, import_element71.useCallback)(
17435 (tokens) => {
17436 const valueTokens = tokens.map((token) => {
17437 if (typeof token === "object" && "value" in token) {
17438 return token.value;
17439 }
17440 return token;
17441 });
17442 onChange(setValue({ item: data, value: valueTokens }));
17443 },
17444 [onChange, setValue, data]
17445 );
17446 if (isLoading) {
17447 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components44.Spinner, {});
17448 }
17449 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
17450 ValidatedFormTokenField,
17451 {
17452 required: !!isValid2?.required,
17453 markWhenOptional,
17454 customValidity: getCustomValidity(isValid2, validity),
17455 label: hideLabelFromVision ? void 0 : label,
17456 value: arrayValueAsElements,
17457 onChange: onChangeControl,
17458 placeholder,
17459 suggestions: elements?.map((element) => element.value),
17460 disabled: disabled2,
17461 __experimentalValidateInput: (token) => {
17462 if (field.isValid?.elements && elements) {
17463 return elements.some(
17464 (element) => element.value === token || element.label === token
17465 );
17466 }
17467 return true;
17468 },
17469 __experimentalExpandOnFocus: elements && elements.length > 0,
17470 help: description ?? (field.isValid?.elements ? "" : void 0),
17471 displayTransform: (token) => {
17472 if (typeof token === "object" && "label" in token) {
17473 return token.label;
17474 }
17475 if (typeof token === "string" && elements) {
17476 const element = elements.find(
17477 (el) => el.value === token
17478 );
17479 return element?.label || token;
17480 }
17481 return token;
17482 },
17483 __experimentalRenderItem: ({ item }) => {
17484 if (typeof item === "string" && elements) {
17485 const element = elements.find(
17486 (el) => el.value === item
17487 );
17488 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: element?.label || item });
17489 }
17490 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: item });
17491 }
17492 }
17493 );
17494 }
17495
17496 // node_modules/colord/index.mjs
17497 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
17498 var t = function(r3) {
17499 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
17500 };
17501 var n = function(r3, t2, n2) {
17502 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
17503 };
17504 var e = function(r3, t2, n2) {
17505 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
17506 };
17507 var u = function(r3) {
17508 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
17509 };
17510 var a = function(r3) {
17511 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
17512 };
17513 var o = function(r3) {
17514 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
17515 };
17516 var i = /^#([0-9a-f]{3,8})$/i;
17517 var s = function(r3) {
17518 var t2 = r3.toString(16);
17519 return t2.length < 2 ? "0" + t2 : t2;
17520 };
17521 var h = function(r3) {
17522 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;
17523 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
17524 };
17525 var b = function(r3) {
17526 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
17527 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
17528 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;
17529 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 };
17530 };
17531 var g = function(r3) {
17532 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
17533 };
17534 var d = function(r3) {
17535 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
17536 };
17537 var f = function(r3) {
17538 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 }));
17539 var t2, n2, e2;
17540 };
17541 var c = function(r3) {
17542 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 };
17543 var t2, n2, e2, u2;
17544 };
17545 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17546 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17547 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17548 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
17549 var y = { string: [[function(r3) {
17550 var t2 = i.exec(r3);
17551 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;
17552 }, "hex"], [function(r3) {
17553 var t2 = v.exec(r3) || m.exec(r3);
17554 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;
17555 }, "rgb"], [function(t2) {
17556 var n2 = l.exec(t2) || p.exec(t2);
17557 if (!n2) return null;
17558 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) });
17559 return f(a2);
17560 }, "hsl"]], object: [[function(r3) {
17561 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
17562 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
17563 }, "rgb"], [function(r3) {
17564 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
17565 if (!t(n2) || !t(e2) || !t(u2)) return null;
17566 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
17567 return f(i2);
17568 }, "hsl"], [function(r3) {
17569 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
17570 if (!t(n2) || !t(a2) || !t(o2)) return null;
17571 var h2 = (function(r4) {
17572 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
17573 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
17574 return b(h2);
17575 }, "hsv"]] };
17576 var N = function(r3, t2) {
17577 for (var n2 = 0; n2 < t2.length; n2++) {
17578 var e2 = t2[n2][0](r3);
17579 if (e2) return [e2, t2[n2][1]];
17580 }
17581 return [null, void 0];
17582 };
17583 var x = function(r3) {
17584 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
17585 };
17586 var M = function(r3, t2) {
17587 var n2 = c(r3);
17588 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
17589 };
17590 var H = function(r3) {
17591 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
17592 };
17593 var $ = function(r3, t2) {
17594 var n2 = c(r3);
17595 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
17596 };
17597 var j = (function() {
17598 function r3(r4) {
17599 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
17600 }
17601 return r3.prototype.isValid = function() {
17602 return null !== this.parsed;
17603 }, r3.prototype.brightness = function() {
17604 return n(H(this.rgba), 2);
17605 }, r3.prototype.isDark = function() {
17606 return H(this.rgba) < 0.5;
17607 }, r3.prototype.isLight = function() {
17608 return H(this.rgba) >= 0.5;
17609 }, r3.prototype.toHex = function() {
17610 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;
17611 var r4, t2, e2, u2, a2, i2;
17612 }, r3.prototype.toRgb = function() {
17613 return o(this.rgba);
17614 }, r3.prototype.toRgbString = function() {
17615 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 + ")";
17616 var r4, t2, n2, e2, u2;
17617 }, r3.prototype.toHsl = function() {
17618 return d(c(this.rgba));
17619 }, r3.prototype.toHslString = function() {
17620 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 + "%)";
17621 var r4, t2, n2, e2, u2;
17622 }, r3.prototype.toHsv = function() {
17623 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
17624 var r4;
17625 }, r3.prototype.invert = function() {
17626 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
17627 var r4;
17628 }, r3.prototype.saturate = function(r4) {
17629 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
17630 }, r3.prototype.desaturate = function(r4) {
17631 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
17632 }, r3.prototype.grayscale = function() {
17633 return w(M(this.rgba, -1));
17634 }, r3.prototype.lighten = function(r4) {
17635 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
17636 }, r3.prototype.darken = function(r4) {
17637 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
17638 }, r3.prototype.rotate = function(r4) {
17639 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
17640 }, r3.prototype.alpha = function(r4) {
17641 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
17642 var t2;
17643 }, r3.prototype.hue = function(r4) {
17644 var t2 = c(this.rgba);
17645 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
17646 }, r3.prototype.isEqual = function(r4) {
17647 return this.toHex() === w(r4).toHex();
17648 }, r3;
17649 })();
17650 var w = function(r3) {
17651 return r3 instanceof j ? r3 : new j(r3);
17652 };
17653
17654 // packages/dataviews/build-module/components/dataform-controls/color.mjs
17655 var import_components45 = __toESM(require_components(), 1);
17656 var import_element72 = __toESM(require_element(), 1);
17657 var import_i18n36 = __toESM(require_i18n(), 1);
17658 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
17659 var { ValidatedInputControl: ValidatedInputControl3 } = unlock(import_components45.privateApis);
17660 var ColorPickerDropdown = ({
17661 color,
17662 onColorChange,
17663 disabled: disabled2
17664 }) => {
17665 const validColor = color && w(color).isValid() ? color : "#ffffff";
17666 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17667 import_components45.Dropdown,
17668 {
17669 className: "dataviews-controls__color-picker-dropdown",
17670 popoverProps: { resize: false },
17671 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17672 import_components45.Button,
17673 {
17674 onClick: onToggle,
17675 "aria-label": (0, import_i18n36.__)("Open color picker"),
17676 size: "small",
17677 disabled: disabled2,
17678 accessibleWhenDisabled: true,
17679 icon: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
17680 }
17681 ),
17682 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17683 import_components45.ColorPicker,
17684 {
17685 color: validColor,
17686 onChange: onColorChange,
17687 enableAlpha: true
17688 }
17689 ) })
17690 }
17691 );
17692 };
17693 function Color({
17694 data,
17695 field,
17696 onChange,
17697 hideLabelFromVision,
17698 markWhenOptional,
17699 validity
17700 }) {
17701 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
17702 const disabled2 = field.isDisabled({ item: data, field });
17703 const value = field.getValue({ item: data }) || "";
17704 const handleColorChange = (0, import_element72.useCallback)(
17705 (newColor) => {
17706 onChange(setValue({ item: data, value: newColor }));
17707 },
17708 [data, onChange, setValue]
17709 );
17710 const handleInputChange = (0, import_element72.useCallback)(
17711 (newValue) => {
17712 onChange(setValue({ item: data, value: newValue || "" }));
17713 },
17714 [data, onChange, setValue]
17715 );
17716 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17717 ValidatedInputControl3,
17718 {
17719 required: !!field.isValid?.required,
17720 markWhenOptional,
17721 customValidity: getCustomValidity(isValid2, validity),
17722 label,
17723 placeholder,
17724 value,
17725 help: description,
17726 onChange: handleInputChange,
17727 hideLabelFromVision,
17728 type: "text",
17729 disabled: disabled2,
17730 prefix: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
17731 ColorPickerDropdown,
17732 {
17733 color: value,
17734 onColorChange: handleColorChange,
17735 disabled: disabled2
17736 }
17737 ) })
17738 }
17739 );
17740 }
17741
17742 // packages/dataviews/build-module/components/dataform-controls/password.mjs
17743 var import_components46 = __toESM(require_components(), 1);
17744 var import_element73 = __toESM(require_element(), 1);
17745 var import_i18n37 = __toESM(require_i18n(), 1);
17746 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
17747 function Password({
17748 data,
17749 field,
17750 onChange,
17751 hideLabelFromVision,
17752 markWhenOptional,
17753 validity
17754 }) {
17755 const [isVisible2, setIsVisible] = (0, import_element73.useState)(false);
17756 const disabled2 = field.isDisabled({ item: data, field });
17757 const toggleVisibility = (0, import_element73.useCallback)(() => {
17758 setIsVisible((prev) => !prev);
17759 }, []);
17760 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
17761 ValidatedText,
17762 {
17763 ...{
17764 data,
17765 field,
17766 onChange,
17767 hideLabelFromVision,
17768 markWhenOptional,
17769 validity,
17770 type: isVisible2 ? "text" : "password",
17771 suffix: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
17772 import_components46.Button,
17773 {
17774 icon: isVisible2 ? unseen_default : seen_default,
17775 onClick: toggleVisibility,
17776 size: "small",
17777 label: isVisible2 ? (0, import_i18n37.__)("Hide password") : (0, import_i18n37.__)("Show password"),
17778 disabled: disabled2,
17779 accessibleWhenDisabled: true
17780 }
17781 ) })
17782 }
17783 }
17784 );
17785 }
17786
17787 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
17788 function hasElements(field) {
17789 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
17790 }
17791
17792 // packages/dataviews/build-module/components/dataform-controls/index.mjs
17793 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
17794 var FORM_CONTROLS = {
17795 adaptiveSelect: AdaptiveSelect,
17796 array: ArrayControl,
17797 checkbox: Checkbox,
17798 color: Color,
17799 combobox: Combobox3,
17800 datetime: DateTime,
17801 date: DateControl,
17802 email: Email,
17803 telephone: Telephone,
17804 url: Url,
17805 integer: Integer,
17806 number: Number2,
17807 password: Password,
17808 radio: Radio,
17809 select: Select,
17810 text: Text3,
17811 toggle: Toggle,
17812 textarea: Textarea,
17813 toggleGroup: ToggleGroup
17814 };
17815 function isEditConfig(value) {
17816 return value && typeof value === "object" && typeof value.control === "string";
17817 }
17818 function createConfiguredControl(config) {
17819 const { control, ...controlConfig } = config;
17820 const BaseControlType = getControlByType(control);
17821 if (BaseControlType === null) {
17822 return null;
17823 }
17824 return function ConfiguredControl(props) {
17825 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(BaseControlType, { ...props, config: controlConfig });
17826 };
17827 }
17828 function getControl(field, fallback) {
17829 if (typeof field.Edit === "function") {
17830 return field.Edit;
17831 }
17832 if (typeof field.Edit === "string") {
17833 return getControlByType(field.Edit);
17834 }
17835 if (isEditConfig(field.Edit)) {
17836 return createConfiguredControl(field.Edit);
17837 }
17838 if (hasElements(field) && field.type !== "array") {
17839 return getControlByType("adaptiveSelect");
17840 }
17841 if (fallback === null) {
17842 return null;
17843 }
17844 return getControlByType(fallback);
17845 }
17846 function getControlByType(type) {
17847 if (Object.keys(FORM_CONTROLS).includes(type)) {
17848 return FORM_CONTROLS[type];
17849 }
17850 return null;
17851 }
17852
17853 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
17854 function getFilterBy(field, defaultOperators, validOperators) {
17855 if (field.filterBy === false) {
17856 return false;
17857 }
17858 const operators = field.filterBy?.operators?.filter(
17859 (op) => validOperators.includes(op)
17860 ) ?? defaultOperators;
17861 if (operators.length === 0) {
17862 return false;
17863 }
17864 return {
17865 isPrimary: !!field.filterBy?.isPrimary,
17866 operators
17867 };
17868 }
17869 var get_filter_by_default = getFilterBy;
17870
17871 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
17872 var getValueFromId = (id) => ({ item }) => {
17873 const path = id.split(".");
17874 let value = item;
17875 for (const segment of path) {
17876 if (value.hasOwnProperty(segment)) {
17877 value = value[segment];
17878 } else {
17879 value = void 0;
17880 }
17881 }
17882 return value;
17883 };
17884 var get_value_from_id_default = getValueFromId;
17885
17886 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
17887 var setValueFromId = (id) => ({ value }) => {
17888 const path = id.split(".");
17889 const result = {};
17890 let current = result;
17891 for (const segment of path.slice(0, -1)) {
17892 current[segment] = {};
17893 current = current[segment];
17894 }
17895 current[path.at(-1)] = value;
17896 return result;
17897 };
17898 var set_value_from_id_default = setValueFromId;
17899
17900 // packages/dataviews/build-module/field-types/email.mjs
17901 var import_i18n38 = __toESM(require_i18n(), 1);
17902
17903 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
17904 function RenderFromElements({
17905 item,
17906 field
17907 }) {
17908 const { elements, isLoading } = useElements({
17909 elements: field.elements,
17910 getElements: field.getElements
17911 });
17912 const value = field.getValue({ item });
17913 if (isLoading) {
17914 return value;
17915 }
17916 if (elements.length === 0) {
17917 return value;
17918 }
17919 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
17920 }
17921
17922 // packages/dataviews/build-module/field-types/utils/render-default.mjs
17923 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
17924 function render({
17925 item,
17926 field
17927 }) {
17928 if (field.hasElements) {
17929 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(RenderFromElements, { item, field });
17930 }
17931 return field.getValueFormatted({ item, field });
17932 }
17933
17934 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
17935 var sort_text_default = (a2, b2, direction) => {
17936 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
17937 };
17938
17939 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
17940 function isValidRequired(item, field) {
17941 const value = field.getValue({ item });
17942 return ![void 0, "", null].includes(value);
17943 }
17944
17945 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
17946 function isValidMinLength(item, field) {
17947 if (typeof field.isValid.minLength?.constraint !== "number") {
17948 return false;
17949 }
17950 const value = field.getValue({ item });
17951 if ([void 0, "", null].includes(value)) {
17952 return true;
17953 }
17954 return String(value).length >= field.isValid.minLength.constraint;
17955 }
17956
17957 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
17958 function isValidMaxLength(item, field) {
17959 if (typeof field.isValid.maxLength?.constraint !== "number") {
17960 return false;
17961 }
17962 const value = field.getValue({ item });
17963 if ([void 0, "", null].includes(value)) {
17964 return true;
17965 }
17966 return String(value).length <= field.isValid.maxLength.constraint;
17967 }
17968
17969 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
17970 function isValidPattern(item, field) {
17971 if (field.isValid.pattern?.constraint === void 0) {
17972 return true;
17973 }
17974 try {
17975 const regexp = new RegExp(field.isValid.pattern.constraint);
17976 const value = field.getValue({ item });
17977 if ([void 0, "", null].includes(value)) {
17978 return true;
17979 }
17980 return regexp.test(String(value));
17981 } catch {
17982 return false;
17983 }
17984 }
17985
17986 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
17987 function isValidElements(item, field) {
17988 const elements = field.elements ?? [];
17989 const validValues = elements.map((el) => el.value);
17990 if (validValues.length === 0) {
17991 return true;
17992 }
17993 const value = field.getValue({ item });
17994 return [].concat(value).every((v2) => validValues.includes(v2));
17995 }
17996
17997 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
17998 function getValueFormatted({
17999 item,
18000 field
18001 }) {
18002 return field.getValue({ item });
18003 }
18004 var get_value_formatted_default_default = getValueFormatted;
18005
18006 // packages/dataviews/build-module/field-types/email.mjs
18007 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])?)*$/;
18008 function isValidCustom(item, field) {
18009 const value = field.getValue({ item });
18010 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
18011 return (0, import_i18n38.__)("Value must be a valid email address.");
18012 }
18013 return null;
18014 }
18015 var email_default = {
18016 type: "email",
18017 render,
18018 Edit: "email",
18019 sort: sort_text_default,
18020 enableSorting: true,
18021 enableGlobalSearch: false,
18022 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18023 validOperators: [
18024 OPERATOR_IS,
18025 OPERATOR_IS_NOT,
18026 OPERATOR_CONTAINS,
18027 OPERATOR_NOT_CONTAINS,
18028 OPERATOR_STARTS_WITH,
18029 // Multiple selection
18030 OPERATOR_IS_ANY,
18031 OPERATOR_IS_NONE,
18032 OPERATOR_IS_ALL,
18033 OPERATOR_IS_NOT_ALL
18034 ],
18035 format: {},
18036 getValueFormatted: get_value_formatted_default_default,
18037 validate: {
18038 required: isValidRequired,
18039 pattern: isValidPattern,
18040 minLength: isValidMinLength,
18041 maxLength: isValidMaxLength,
18042 elements: isValidElements,
18043 custom: isValidCustom
18044 }
18045 };
18046
18047 // packages/dataviews/build-module/field-types/integer.mjs
18048 var import_i18n39 = __toESM(require_i18n(), 1);
18049
18050 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
18051 var sort_number_default = (a2, b2, direction) => {
18052 return direction === "asc" ? a2 - b2 : b2 - a2;
18053 };
18054
18055 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
18056 function isValidMin(item, field) {
18057 if (typeof field.isValid.min?.constraint !== "number") {
18058 return false;
18059 }
18060 const value = field.getValue({ item });
18061 if ([void 0, "", null].includes(value)) {
18062 return true;
18063 }
18064 return Number(value) >= field.isValid.min.constraint;
18065 }
18066
18067 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
18068 function isValidMax(item, field) {
18069 if (typeof field.isValid.max?.constraint !== "number") {
18070 return false;
18071 }
18072 const value = field.getValue({ item });
18073 if ([void 0, "", null].includes(value)) {
18074 return true;
18075 }
18076 return Number(value) <= field.isValid.max.constraint;
18077 }
18078
18079 // packages/dataviews/build-module/field-types/integer.mjs
18080 var format2 = {
18081 separatorThousand: ","
18082 };
18083 function getValueFormatted2({
18084 item,
18085 field
18086 }) {
18087 let value = field.getValue({ item });
18088 if (value === null || value === void 0) {
18089 return "";
18090 }
18091 value = Number(value);
18092 if (!Number.isFinite(value)) {
18093 return String(value);
18094 }
18095 let formatInteger;
18096 if (field.type !== "integer") {
18097 formatInteger = format2;
18098 } else {
18099 formatInteger = field.format;
18100 }
18101 const { separatorThousand } = formatInteger;
18102 const integerValue = Math.trunc(value);
18103 if (!separatorThousand) {
18104 return String(integerValue);
18105 }
18106 return String(integerValue).replace(
18107 /\B(?=(\d{3})+(?!\d))/g,
18108 separatorThousand
18109 );
18110 }
18111 function isValidCustom2(item, field) {
18112 const value = field.getValue({ item });
18113 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
18114 return (0, import_i18n39.__)("Value must be an integer.");
18115 }
18116 return null;
18117 }
18118 var integer_default = {
18119 type: "integer",
18120 render,
18121 Edit: "integer",
18122 sort: sort_number_default,
18123 enableSorting: true,
18124 enableGlobalSearch: false,
18125 defaultOperators: [
18126 OPERATOR_IS,
18127 OPERATOR_IS_NOT,
18128 OPERATOR_LESS_THAN,
18129 OPERATOR_GREATER_THAN,
18130 OPERATOR_LESS_THAN_OR_EQUAL,
18131 OPERATOR_GREATER_THAN_OR_EQUAL,
18132 OPERATOR_BETWEEN
18133 ],
18134 validOperators: [
18135 // Single-selection
18136 OPERATOR_IS,
18137 OPERATOR_IS_NOT,
18138 OPERATOR_LESS_THAN,
18139 OPERATOR_GREATER_THAN,
18140 OPERATOR_LESS_THAN_OR_EQUAL,
18141 OPERATOR_GREATER_THAN_OR_EQUAL,
18142 OPERATOR_BETWEEN,
18143 // Multiple-selection
18144 OPERATOR_IS_ANY,
18145 OPERATOR_IS_NONE,
18146 OPERATOR_IS_ALL,
18147 OPERATOR_IS_NOT_ALL
18148 ],
18149 format: format2,
18150 getValueFormatted: getValueFormatted2,
18151 validate: {
18152 required: isValidRequired,
18153 min: isValidMin,
18154 max: isValidMax,
18155 elements: isValidElements,
18156 custom: isValidCustom2
18157 }
18158 };
18159
18160 // packages/dataviews/build-module/field-types/number.mjs
18161 var import_i18n40 = __toESM(require_i18n(), 1);
18162 var format3 = {
18163 separatorThousand: ",",
18164 separatorDecimal: ".",
18165 decimals: 2
18166 };
18167 function getValueFormatted3({
18168 item,
18169 field
18170 }) {
18171 let value = field.getValue({ item });
18172 if (value === null || value === void 0) {
18173 return "";
18174 }
18175 value = Number(value);
18176 if (!Number.isFinite(value)) {
18177 return String(value);
18178 }
18179 let formatNumber;
18180 if (field.type !== "number") {
18181 formatNumber = format3;
18182 } else {
18183 formatNumber = field.format;
18184 }
18185 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
18186 const fixedValue = value.toFixed(decimals);
18187 const [integerPart, decimalPart] = fixedValue.split(".");
18188 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
18189 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
18190 }
18191 function isEmpty2(value) {
18192 return value === "" || value === void 0 || value === null;
18193 }
18194 function isValidCustom3(item, field) {
18195 const value = field.getValue({ item });
18196 if (!isEmpty2(value) && !Number.isFinite(value)) {
18197 return (0, import_i18n40.__)("Value must be a number.");
18198 }
18199 return null;
18200 }
18201 var number_default = {
18202 type: "number",
18203 render,
18204 Edit: "number",
18205 sort: sort_number_default,
18206 enableSorting: true,
18207 enableGlobalSearch: false,
18208 defaultOperators: [
18209 OPERATOR_IS,
18210 OPERATOR_IS_NOT,
18211 OPERATOR_LESS_THAN,
18212 OPERATOR_GREATER_THAN,
18213 OPERATOR_LESS_THAN_OR_EQUAL,
18214 OPERATOR_GREATER_THAN_OR_EQUAL,
18215 OPERATOR_BETWEEN
18216 ],
18217 validOperators: [
18218 // Single-selection
18219 OPERATOR_IS,
18220 OPERATOR_IS_NOT,
18221 OPERATOR_LESS_THAN,
18222 OPERATOR_GREATER_THAN,
18223 OPERATOR_LESS_THAN_OR_EQUAL,
18224 OPERATOR_GREATER_THAN_OR_EQUAL,
18225 OPERATOR_BETWEEN,
18226 // Multiple-selection
18227 OPERATOR_IS_ANY,
18228 OPERATOR_IS_NONE,
18229 OPERATOR_IS_ALL,
18230 OPERATOR_IS_NOT_ALL
18231 ],
18232 format: format3,
18233 getValueFormatted: getValueFormatted3,
18234 validate: {
18235 required: isValidRequired,
18236 min: isValidMin,
18237 max: isValidMax,
18238 elements: isValidElements,
18239 custom: isValidCustom3
18240 }
18241 };
18242
18243 // packages/dataviews/build-module/field-types/text.mjs
18244 var text_default = {
18245 type: "text",
18246 render,
18247 Edit: "text",
18248 sort: sort_text_default,
18249 enableSorting: true,
18250 enableGlobalSearch: false,
18251 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18252 validOperators: [
18253 // Single selection
18254 OPERATOR_IS,
18255 OPERATOR_IS_NOT,
18256 OPERATOR_CONTAINS,
18257 OPERATOR_NOT_CONTAINS,
18258 OPERATOR_STARTS_WITH,
18259 // Multiple selection
18260 OPERATOR_IS_ANY,
18261 OPERATOR_IS_NONE,
18262 OPERATOR_IS_ALL,
18263 OPERATOR_IS_NOT_ALL
18264 ],
18265 format: {},
18266 getValueFormatted: get_value_formatted_default_default,
18267 validate: {
18268 required: isValidRequired,
18269 pattern: isValidPattern,
18270 minLength: isValidMinLength,
18271 maxLength: isValidMaxLength,
18272 elements: isValidElements
18273 }
18274 };
18275
18276 // packages/dataviews/build-module/field-types/datetime.mjs
18277 var import_date7 = __toESM(require_date(), 1);
18278
18279 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
18280 var import_date6 = __toESM(require_date(), 1);
18281 function parseDateLike(value) {
18282 if (!value) {
18283 return null;
18284 }
18285 if (!isValid(new Date(value))) {
18286 return null;
18287 }
18288 const parsed = (0, import_date6.getDate)(value);
18289 return parsed && isValid(parsed) ? parsed : null;
18290 }
18291 function validateDateLikeBoundary(item, field, boundary) {
18292 const constraint = field.isValid[boundary]?.constraint;
18293 if (typeof constraint !== "string") {
18294 return false;
18295 }
18296 const value = field.getValue({ item });
18297 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
18298 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
18299 return true;
18300 }
18301 const parsedConstraint = parseDateLike(constraint);
18302 const parsedValue = parseDateLike(String(boundaryValue));
18303 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
18304 }
18305 function isValidMinDate(item, field) {
18306 return validateDateLikeBoundary(item, field, "min");
18307 }
18308 function isValidMaxDate(item, field) {
18309 return validateDateLikeBoundary(item, field, "max");
18310 }
18311
18312 // packages/dataviews/build-module/field-types/datetime.mjs
18313 var format4 = {
18314 datetime: (0, import_date7.getSettings)().formats.datetime,
18315 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
18316 };
18317 function getValueFormatted4({
18318 item,
18319 field
18320 }) {
18321 const value = field.getValue({ item });
18322 if (["", void 0, null].includes(value)) {
18323 return "";
18324 }
18325 let formatDatetime;
18326 if (field.type !== "datetime") {
18327 formatDatetime = format4;
18328 } else {
18329 formatDatetime = field.format;
18330 }
18331 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
18332 }
18333 var sort = (a2, b2, direction) => {
18334 const timeA = new Date(a2).getTime();
18335 const timeB = new Date(b2).getTime();
18336 return direction === "asc" ? timeA - timeB : timeB - timeA;
18337 };
18338 var datetime_default = {
18339 type: "datetime",
18340 render,
18341 Edit: "datetime",
18342 sort,
18343 enableSorting: true,
18344 enableGlobalSearch: false,
18345 defaultOperators: [
18346 OPERATOR_ON,
18347 OPERATOR_NOT_ON,
18348 OPERATOR_BEFORE,
18349 OPERATOR_AFTER,
18350 OPERATOR_BEFORE_INC,
18351 OPERATOR_AFTER_INC,
18352 OPERATOR_IN_THE_PAST,
18353 OPERATOR_OVER
18354 ],
18355 validOperators: [
18356 OPERATOR_ON,
18357 OPERATOR_NOT_ON,
18358 OPERATOR_BEFORE,
18359 OPERATOR_AFTER,
18360 OPERATOR_BEFORE_INC,
18361 OPERATOR_AFTER_INC,
18362 OPERATOR_IN_THE_PAST,
18363 OPERATOR_OVER
18364 ],
18365 format: format4,
18366 getValueFormatted: getValueFormatted4,
18367 validate: {
18368 required: isValidRequired,
18369 elements: isValidElements,
18370 min: isValidMinDate,
18371 max: isValidMaxDate
18372 }
18373 };
18374
18375 // packages/dataviews/build-module/field-types/date.mjs
18376 var import_date8 = __toESM(require_date(), 1);
18377 var format5 = {
18378 date: (0, import_date8.getSettings)().formats.date,
18379 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
18380 };
18381 function getValueFormatted5({
18382 item,
18383 field
18384 }) {
18385 const value = field.getValue({ item });
18386 if (["", void 0, null].includes(value)) {
18387 return "";
18388 }
18389 let formatDate2;
18390 if (field.type !== "date") {
18391 formatDate2 = format5;
18392 } else {
18393 formatDate2 = field.format;
18394 }
18395 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
18396 }
18397 var sort2 = (a2, b2, direction) => {
18398 const timeA = new Date(a2).getTime();
18399 const timeB = new Date(b2).getTime();
18400 return direction === "asc" ? timeA - timeB : timeB - timeA;
18401 };
18402 var date_default = {
18403 type: "date",
18404 render,
18405 Edit: "date",
18406 sort: sort2,
18407 enableSorting: true,
18408 enableGlobalSearch: false,
18409 defaultOperators: [
18410 OPERATOR_ON,
18411 OPERATOR_NOT_ON,
18412 OPERATOR_BEFORE,
18413 OPERATOR_AFTER,
18414 OPERATOR_BEFORE_INC,
18415 OPERATOR_AFTER_INC,
18416 OPERATOR_IN_THE_PAST,
18417 OPERATOR_OVER,
18418 OPERATOR_BETWEEN
18419 ],
18420 validOperators: [
18421 OPERATOR_ON,
18422 OPERATOR_NOT_ON,
18423 OPERATOR_BEFORE,
18424 OPERATOR_AFTER,
18425 OPERATOR_BEFORE_INC,
18426 OPERATOR_AFTER_INC,
18427 OPERATOR_IN_THE_PAST,
18428 OPERATOR_OVER,
18429 OPERATOR_BETWEEN
18430 ],
18431 format: format5,
18432 getValueFormatted: getValueFormatted5,
18433 validate: {
18434 required: isValidRequired,
18435 elements: isValidElements,
18436 min: isValidMinDate,
18437 max: isValidMaxDate
18438 }
18439 };
18440
18441 // packages/dataviews/build-module/field-types/boolean.mjs
18442 var import_i18n41 = __toESM(require_i18n(), 1);
18443
18444 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
18445 function isValidRequiredForBool(item, field) {
18446 const value = field.getValue({ item });
18447 return value === true;
18448 }
18449
18450 // packages/dataviews/build-module/field-types/boolean.mjs
18451 function getValueFormatted6({
18452 item,
18453 field
18454 }) {
18455 const value = field.getValue({ item });
18456 if (value === true) {
18457 return (0, import_i18n41.__)("True");
18458 }
18459 if (value === false) {
18460 return (0, import_i18n41.__)("False");
18461 }
18462 return "";
18463 }
18464 function isValidCustom4(item, field) {
18465 const value = field.getValue({ item });
18466 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
18467 return (0, import_i18n41.__)("Value must be true, false, or undefined");
18468 }
18469 return null;
18470 }
18471 var sort3 = (a2, b2, direction) => {
18472 const boolA = Boolean(a2);
18473 const boolB = Boolean(b2);
18474 if (boolA === boolB) {
18475 return 0;
18476 }
18477 if (direction === "asc") {
18478 return boolA ? 1 : -1;
18479 }
18480 return boolA ? -1 : 1;
18481 };
18482 var boolean_default = {
18483 type: "boolean",
18484 render,
18485 Edit: "checkbox",
18486 sort: sort3,
18487 validate: {
18488 required: isValidRequiredForBool,
18489 elements: isValidElements,
18490 custom: isValidCustom4
18491 },
18492 enableSorting: true,
18493 enableGlobalSearch: false,
18494 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18495 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18496 format: {},
18497 getValueFormatted: getValueFormatted6
18498 };
18499
18500 // packages/dataviews/build-module/field-types/media.mjs
18501 var media_default = {
18502 type: "media",
18503 render: () => null,
18504 Edit: null,
18505 sort: () => 0,
18506 enableSorting: false,
18507 enableGlobalSearch: false,
18508 defaultOperators: [],
18509 validOperators: [],
18510 format: {},
18511 getValueFormatted: get_value_formatted_default_default,
18512 // cannot validate any constraint, so
18513 // the only available validation for the field author
18514 // would be providing a custom validator.
18515 validate: {}
18516 };
18517
18518 // packages/dataviews/build-module/field-types/array.mjs
18519 var import_i18n42 = __toESM(require_i18n(), 1);
18520
18521 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
18522 function isValidRequiredForArray(item, field) {
18523 const value = field.getValue({ item });
18524 return Array.isArray(value) && value.length > 0 && value.every(
18525 (element) => ![void 0, "", null].includes(element)
18526 );
18527 }
18528
18529 // packages/dataviews/build-module/field-types/array.mjs
18530 function getValueFormatted7({
18531 item,
18532 field
18533 }) {
18534 const value = field.getValue({ item });
18535 const arr = Array.isArray(value) ? value : [];
18536 return arr.join(", ");
18537 }
18538 function render2({ item, field }) {
18539 return getValueFormatted7({ item, field });
18540 }
18541 function isValidCustom5(item, field) {
18542 const value = field.getValue({ item });
18543 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
18544 return (0, import_i18n42.__)("Value must be an array.");
18545 }
18546 if (!value.every((v2) => typeof v2 === "string")) {
18547 return (0, import_i18n42.__)("Every value must be a string.");
18548 }
18549 return null;
18550 }
18551 var sort4 = (a2, b2, direction) => {
18552 const arrA = Array.isArray(a2) ? a2 : [];
18553 const arrB = Array.isArray(b2) ? b2 : [];
18554 if (arrA.length !== arrB.length) {
18555 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
18556 }
18557 const joinedA = arrA.join(",");
18558 const joinedB = arrB.join(",");
18559 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
18560 };
18561 var array_default = {
18562 type: "array",
18563 render: render2,
18564 Edit: "array",
18565 sort: sort4,
18566 enableSorting: true,
18567 enableGlobalSearch: false,
18568 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18569 validOperators: [
18570 OPERATOR_IS_ANY,
18571 OPERATOR_IS_NONE,
18572 OPERATOR_IS_ALL,
18573 OPERATOR_IS_NOT_ALL
18574 ],
18575 format: {},
18576 getValueFormatted: getValueFormatted7,
18577 validate: {
18578 required: isValidRequiredForArray,
18579 elements: isValidElements,
18580 custom: isValidCustom5
18581 }
18582 };
18583
18584 // packages/dataviews/build-module/field-types/password.mjs
18585 function getValueFormatted8({
18586 item,
18587 field
18588 }) {
18589 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
18590 }
18591 var password_default = {
18592 type: "password",
18593 render,
18594 Edit: "password",
18595 sort: () => 0,
18596 // Passwords should not be sortable for security reasons
18597 enableSorting: false,
18598 enableGlobalSearch: false,
18599 defaultOperators: [],
18600 validOperators: [],
18601 format: {},
18602 getValueFormatted: getValueFormatted8,
18603 validate: {
18604 required: isValidRequired,
18605 pattern: isValidPattern,
18606 minLength: isValidMinLength,
18607 maxLength: isValidMaxLength,
18608 elements: isValidElements
18609 }
18610 };
18611
18612 // packages/dataviews/build-module/field-types/telephone.mjs
18613 var telephone_default = {
18614 type: "telephone",
18615 render,
18616 Edit: "telephone",
18617 sort: sort_text_default,
18618 enableSorting: true,
18619 enableGlobalSearch: false,
18620 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18621 validOperators: [
18622 OPERATOR_IS,
18623 OPERATOR_IS_NOT,
18624 OPERATOR_CONTAINS,
18625 OPERATOR_NOT_CONTAINS,
18626 OPERATOR_STARTS_WITH,
18627 // Multiple selection
18628 OPERATOR_IS_ANY,
18629 OPERATOR_IS_NONE,
18630 OPERATOR_IS_ALL,
18631 OPERATOR_IS_NOT_ALL
18632 ],
18633 format: {},
18634 getValueFormatted: get_value_formatted_default_default,
18635 validate: {
18636 required: isValidRequired,
18637 pattern: isValidPattern,
18638 minLength: isValidMinLength,
18639 maxLength: isValidMaxLength,
18640 elements: isValidElements
18641 }
18642 };
18643
18644 // packages/dataviews/build-module/field-types/color.mjs
18645 var import_i18n43 = __toESM(require_i18n(), 1);
18646 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
18647 function render3({ item, field }) {
18648 if (field.hasElements) {
18649 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RenderFromElements, { item, field });
18650 }
18651 const value = get_value_formatted_default_default({ item, field });
18652 if (!value || !w(value).isValid()) {
18653 return value;
18654 }
18655 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
18656 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
18657 "div",
18658 {
18659 style: {
18660 width: "16px",
18661 height: "16px",
18662 borderRadius: "50%",
18663 backgroundColor: value,
18664 border: "1px solid #ddd",
18665 flexShrink: 0
18666 }
18667 }
18668 ),
18669 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: value })
18670 ] });
18671 }
18672 function isValidCustom6(item, field) {
18673 const value = field.getValue({ item });
18674 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
18675 return (0, import_i18n43.__)("Value must be a valid color.");
18676 }
18677 return null;
18678 }
18679 var sort5 = (a2, b2, direction) => {
18680 const colorA = w(a2);
18681 const colorB = w(b2);
18682 if (!colorA.isValid() && !colorB.isValid()) {
18683 return 0;
18684 }
18685 if (!colorA.isValid()) {
18686 return direction === "asc" ? 1 : -1;
18687 }
18688 if (!colorB.isValid()) {
18689 return direction === "asc" ? -1 : 1;
18690 }
18691 const hslA = colorA.toHsl();
18692 const hslB = colorB.toHsl();
18693 if (hslA.h !== hslB.h) {
18694 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
18695 }
18696 if (hslA.s !== hslB.s) {
18697 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
18698 }
18699 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
18700 };
18701 var color_default = {
18702 type: "color",
18703 render: render3,
18704 Edit: "color",
18705 sort: sort5,
18706 enableSorting: true,
18707 enableGlobalSearch: false,
18708 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18709 validOperators: [
18710 OPERATOR_IS,
18711 OPERATOR_IS_NOT,
18712 OPERATOR_IS_ANY,
18713 OPERATOR_IS_NONE
18714 ],
18715 format: {},
18716 getValueFormatted: get_value_formatted_default_default,
18717 validate: {
18718 required: isValidRequired,
18719 elements: isValidElements,
18720 custom: isValidCustom6
18721 }
18722 };
18723
18724 // packages/dataviews/build-module/field-types/url.mjs
18725 var url_default = {
18726 type: "url",
18727 render,
18728 Edit: "url",
18729 sort: sort_text_default,
18730 enableSorting: true,
18731 enableGlobalSearch: false,
18732 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18733 validOperators: [
18734 OPERATOR_IS,
18735 OPERATOR_IS_NOT,
18736 OPERATOR_CONTAINS,
18737 OPERATOR_NOT_CONTAINS,
18738 OPERATOR_STARTS_WITH,
18739 // Multiple selection
18740 OPERATOR_IS_ANY,
18741 OPERATOR_IS_NONE,
18742 OPERATOR_IS_ALL,
18743 OPERATOR_IS_NOT_ALL
18744 ],
18745 format: {},
18746 getValueFormatted: get_value_formatted_default_default,
18747 validate: {
18748 required: isValidRequired,
18749 pattern: isValidPattern,
18750 minLength: isValidMinLength,
18751 maxLength: isValidMaxLength,
18752 elements: isValidElements
18753 }
18754 };
18755
18756 // packages/dataviews/build-module/field-types/no-type.mjs
18757 var sort6 = (a2, b2, direction) => {
18758 if (typeof a2 === "number" && typeof b2 === "number") {
18759 return sort_number_default(a2, b2, direction);
18760 }
18761 return sort_text_default(a2, b2, direction);
18762 };
18763 var no_type_default = {
18764 // type: no type for this one
18765 render,
18766 Edit: null,
18767 sort: sort6,
18768 enableSorting: true,
18769 enableGlobalSearch: false,
18770 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
18771 validOperators: getAllOperatorNames(),
18772 format: {},
18773 getValueFormatted: get_value_formatted_default_default,
18774 validate: {
18775 required: isValidRequired,
18776 elements: isValidElements
18777 }
18778 };
18779
18780 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
18781 function supportsNumericRangeConstraint(type) {
18782 return type === "integer" || type === "number";
18783 }
18784 function supportsDateRangeConstraint(type) {
18785 return type === "date" || type === "datetime";
18786 }
18787 function normalizeRangeRule(value, fieldType, key) {
18788 const validator = fieldType.validate[key];
18789 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
18790 return { constraint: value, validate: validator };
18791 }
18792 return void 0;
18793 }
18794 function getIsValid(field, fieldType) {
18795 const rules = field.isValid;
18796 let required;
18797 if (rules?.required === true && fieldType.validate.required !== void 0) {
18798 required = {
18799 constraint: true,
18800 validate: fieldType.validate.required
18801 };
18802 }
18803 let elements;
18804 if ((rules?.elements === true || // elements is enabled unless the field opts-out
18805 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
18806 elements = {
18807 constraint: true,
18808 validate: fieldType.validate.elements
18809 };
18810 }
18811 const min = normalizeRangeRule(rules?.min, fieldType, "min");
18812 const max = normalizeRangeRule(rules?.max, fieldType, "max");
18813 const minLengthValue = rules?.minLength;
18814 let minLength;
18815 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
18816 minLength = {
18817 constraint: minLengthValue,
18818 validate: fieldType.validate.minLength
18819 };
18820 }
18821 const maxLengthValue = rules?.maxLength;
18822 let maxLength;
18823 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
18824 maxLength = {
18825 constraint: maxLengthValue,
18826 validate: fieldType.validate.maxLength
18827 };
18828 }
18829 const patternValue = rules?.pattern;
18830 let pattern;
18831 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
18832 pattern = {
18833 constraint: patternValue,
18834 validate: fieldType.validate.pattern
18835 };
18836 }
18837 const custom = rules?.custom ?? fieldType.validate.custom;
18838 return {
18839 required,
18840 elements,
18841 min,
18842 max,
18843 minLength,
18844 maxLength,
18845 pattern,
18846 custom
18847 };
18848 }
18849
18850 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
18851 function getFilter(fieldType) {
18852 return fieldType.validOperators.reduce((accumulator, operator) => {
18853 const operatorObj = getOperatorByName(operator);
18854 if (operatorObj?.filter) {
18855 accumulator[operator] = operatorObj.filter;
18856 }
18857 return accumulator;
18858 }, {});
18859 }
18860
18861 // packages/dataviews/build-module/field-types/utils/get-format.mjs
18862 function getFormat(field, fieldType) {
18863 return {
18864 ...fieldType.format,
18865 ...field.format
18866 };
18867 }
18868 var get_format_default = getFormat;
18869
18870 // packages/dataviews/build-module/field-types/index.mjs
18871 function getFieldTypeByName(type) {
18872 const found = [
18873 email_default,
18874 integer_default,
18875 number_default,
18876 text_default,
18877 datetime_default,
18878 date_default,
18879 boolean_default,
18880 media_default,
18881 array_default,
18882 password_default,
18883 telephone_default,
18884 color_default,
18885 url_default
18886 ].find((fieldType) => fieldType?.type === type);
18887 if (!!found) {
18888 return found;
18889 }
18890 return no_type_default;
18891 }
18892 function normalizeFields(fields2) {
18893 return fields2.map((field) => {
18894 const fieldType = getFieldTypeByName(field.type);
18895 const getValue = field.getValue || get_value_from_id_default(field.id);
18896 const sort7 = function(a2, b2, direction) {
18897 const aValue = getValue({ item: a2 });
18898 const bValue = getValue({ item: b2 });
18899 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
18900 };
18901 return {
18902 id: field.id,
18903 label: field.label || field.id,
18904 header: field.header || field.label || field.id,
18905 description: field.description,
18906 placeholder: field.placeholder,
18907 getValue,
18908 setValue: field.setValue || set_value_from_id_default(field.id),
18909 elements: field.elements,
18910 getElements: field.getElements,
18911 hasElements: hasElements(field),
18912 isVisible: field.isVisible,
18913 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
18914 enableHiding: field.enableHiding ?? true,
18915 readOnly: field.readOnly ?? false,
18916 // The type provides defaults for the following props
18917 type: fieldType.type,
18918 render: field.render ?? fieldType.render,
18919 Edit: getControl(field, fieldType.Edit),
18920 sort: sort7,
18921 enableSorting: field.enableSorting ?? fieldType.enableSorting,
18922 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
18923 isValid: getIsValid(field, fieldType),
18924 filterBy: get_filter_by_default(
18925 field,
18926 fieldType.defaultOperators,
18927 fieldType.validOperators
18928 ),
18929 filter: getFilter(fieldType),
18930 format: get_format_default(field, fieldType),
18931 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
18932 };
18933 });
18934 }
18935
18936 // packages/dataviews/build-module/hooks/use-data.mjs
18937 var import_element74 = __toESM(require_element(), 1);
18938 function useData({
18939 view,
18940 data: shownData,
18941 getItemId,
18942 isLoading,
18943 paginationInfo,
18944 selection
18945 }) {
18946 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
18947 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element74.useState)(
18948 !isLoading
18949 );
18950 (0, import_element74.useEffect)(() => {
18951 if (!isLoading) {
18952 setHasInitiallyLoaded(true);
18953 }
18954 }, [isLoading]);
18955 const previousDataRef = (0, import_element74.useRef)(shownData);
18956 const previousPaginationInfoRef = (0, import_element74.useRef)(paginationInfo);
18957 (0, import_element74.useEffect)(() => {
18958 if (!isLoading) {
18959 previousDataRef.current = shownData;
18960 previousPaginationInfoRef.current = paginationInfo;
18961 }
18962 }, [shownData, isLoading, paginationInfo]);
18963 const [visibleEntries, setVisibleEntries] = (0, import_element74.useState)([]);
18964 const positionMapRef = (0, import_element74.useRef)(/* @__PURE__ */ new Map());
18965 const allLoadedRecordsRef = (0, import_element74.useRef)([]);
18966 const prevViewParamsRef = (0, import_element74.useRef)({
18967 search: void 0,
18968 filters: void 0,
18969 perPage: void 0
18970 });
18971 const scrollDirectionRef = (0, import_element74.useRef)(void 0);
18972 const prevStartPositionRef = (0, import_element74.useRef)(void 0);
18973 const hasInitializedRef = (0, import_element74.useRef)(false);
18974 const allLoadedRecords = (0, import_element74.useMemo)(() => {
18975 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
18976 if (view.startPosition < prevStartPositionRef.current) {
18977 scrollDirectionRef.current = "up";
18978 } else if (view.startPosition > prevStartPositionRef.current) {
18979 scrollDirectionRef.current = "down";
18980 }
18981 }
18982 prevStartPositionRef.current = view.startPosition;
18983 const currentFiltersKey = JSON.stringify(view.filters ?? []);
18984 const prevFiltersKey = prevViewParamsRef.current.filters;
18985 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
18986 hasInitializedRef.current = true;
18987 prevViewParamsRef.current = {
18988 search: view.search,
18989 filters: currentFiltersKey,
18990 perPage: view.perPage
18991 };
18992 if (shouldReset) {
18993 positionMapRef.current.clear();
18994 scrollDirectionRef.current = void 0;
18995 const startPosition = view.search ? 1 : view.startPosition ?? 1;
18996 const records = shownData.map((record, index) => {
18997 const position = startPosition + index;
18998 positionMapRef.current.set(getItemId(record), position);
18999 return {
19000 ...record,
19001 position
19002 };
19003 });
19004 allLoadedRecordsRef.current = records;
19005 return records;
19006 }
19007 const prev = allLoadedRecordsRef.current;
19008 const shownDataIds = new Set(shownData.map(getItemId));
19009 const scrollDirection = scrollDirectionRef.current;
19010 const basePosition = view.search ? 1 : view.startPosition ?? 1;
19011 const newRecords = shownData.map((record, index) => {
19012 const itemId = getItemId(record);
19013 const position = view.infiniteScrollEnabled ? basePosition + index : void 0;
19014 if (position !== void 0) {
19015 positionMapRef.current.set(itemId, position);
19016 }
19017 return {
19018 ...record,
19019 position
19020 };
19021 });
19022 if (newRecords.length === 0) {
19023 return prev;
19024 }
19025 const prevWithoutDuplicates = prev.filter(
19026 (record) => !shownDataIds.has(getItemId(record))
19027 );
19028 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
19029 allRecords.sort((a2, b2) => {
19030 const posA = a2.position;
19031 const posB = b2.position;
19032 return posA - posB;
19033 });
19034 let result = allRecords;
19035 if (visibleEntries.length > 0) {
19036 const visibleMin = Math.min(...visibleEntries);
19037 const visibleMax = Math.max(...visibleEntries);
19038 const buffer = 20;
19039 const recordPositions = allRecords.map(
19040 (r3) => r3.position
19041 );
19042 const minRecordPos = Math.min(...recordPositions);
19043 const maxRecordPos = Math.max(...recordPositions);
19044 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
19045 if (hasOverlap) {
19046 result = allRecords.filter((record) => {
19047 const itemId = getItemId(record);
19048 const isSelected2 = selection?.includes(itemId);
19049 if (isSelected2) {
19050 return true;
19051 }
19052 const itemPosition = record.position;
19053 if (scrollDirection === "up") {
19054 return itemPosition <= visibleMax + buffer;
19055 } else if (scrollDirection === "down") {
19056 return itemPosition >= visibleMin - buffer;
19057 }
19058 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
19059 });
19060 }
19061 }
19062 allLoadedRecordsRef.current = result;
19063 return result;
19064 }, [
19065 shownData,
19066 view.search,
19067 view.filters,
19068 view.perPage,
19069 view.startPosition,
19070 view.infiniteScrollEnabled,
19071 visibleEntries,
19072 selection,
19073 getItemId
19074 ]);
19075 if (!isInfiniteScrollEnabled) {
19076 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
19077 return {
19078 data: dataToReturn.map((item) => ({
19079 ...item,
19080 position: void 0
19081 })),
19082 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
19083 hasInitiallyLoaded,
19084 setVisibleEntries: void 0
19085 };
19086 }
19087 return {
19088 data: allLoadedRecords,
19089 paginationInfo,
19090 hasInitiallyLoaded,
19091 setVisibleEntries
19092 };
19093 }
19094
19095 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
19096 var import_element75 = __toESM(require_element(), 1);
19097 var import_compose11 = __toESM(require_compose(), 1);
19098 function captureAnchorElement(container, anchorElementRef, direction) {
19099 const containerRect = container.getBoundingClientRect();
19100 const centerY = containerRect.top + containerRect.height / 2;
19101 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
19102 if (items.length === 0) {
19103 return false;
19104 }
19105 const bestAnchor = items.reduce((best, item) => {
19106 const itemRect = item.getBoundingClientRect();
19107 const itemCenterY = itemRect.top + itemRect.height / 2;
19108 const distance = Math.abs(itemCenterY - centerY);
19109 const bestRect = best.getBoundingClientRect();
19110 const bestCenterY = bestRect.top + bestRect.height / 2;
19111 const bestDistance = Math.abs(bestCenterY - centerY);
19112 return distance < bestDistance ? item : best;
19113 });
19114 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
19115 const anchorRect = bestAnchor.getBoundingClientRect();
19116 anchorElementRef.current = {
19117 posinset,
19118 viewportOffset: anchorRect.top - containerRect.top,
19119 direction
19120 };
19121 return true;
19122 }
19123 function useInfiniteScroll({
19124 view,
19125 onChangeView,
19126 isLoading,
19127 paginationInfo,
19128 containerRef,
19129 setVisibleEntries
19130 }) {
19131 const anchorElementRef = (0, import_element75.useRef)(null);
19132 const viewRef = (0, import_element75.useRef)(view);
19133 const isLoadingRef = (0, import_element75.useRef)(isLoading);
19134 const onChangeViewRef = (0, import_element75.useRef)(onChangeView);
19135 const totalItemsRef = (0, import_element75.useRef)(paginationInfo.totalItems);
19136 (0, import_element75.useLayoutEffect)(() => {
19137 viewRef.current = view;
19138 isLoadingRef.current = isLoading;
19139 onChangeViewRef.current = onChangeView;
19140 totalItemsRef.current = paginationInfo.totalItems;
19141 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
19142 const intersectionObserverCallback = (0, import_element75.useCallback)(
19143 (entries) => {
19144 if (!setVisibleEntries) {
19145 return;
19146 }
19147 setVisibleEntries((prev) => {
19148 const newVisibleEntries = new Set(prev);
19149 let hasChanged = false;
19150 entries.forEach((entry) => {
19151 const posInSet = Number(
19152 entry.target?.attributes?.getNamedItem(
19153 "aria-posinset"
19154 )?.value
19155 );
19156 if (isNaN(posInSet)) {
19157 return;
19158 }
19159 if (entry.isIntersecting) {
19160 if (!newVisibleEntries.has(posInSet)) {
19161 newVisibleEntries.add(posInSet);
19162 hasChanged = true;
19163 }
19164 } else if (newVisibleEntries.has(posInSet)) {
19165 newVisibleEntries.delete(posInSet);
19166 hasChanged = true;
19167 }
19168 });
19169 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
19170 });
19171 },
19172 [setVisibleEntries]
19173 );
19174 (0, import_element75.useLayoutEffect)(() => {
19175 const container = containerRef.current;
19176 const anchor = anchorElementRef.current;
19177 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
19178 return;
19179 }
19180 const anchorElement = container.querySelector(
19181 `[aria-posinset="${anchor.posinset}"]`
19182 );
19183 if (anchorElement) {
19184 const containerRect = container.getBoundingClientRect();
19185 const anchorRect = anchorElement.getBoundingClientRect();
19186 const currentOffset = anchorRect.top - containerRect.top;
19187 const scrollAdjustment = currentOffset - anchor.viewportOffset;
19188 if (Math.abs(scrollAdjustment) > 1) {
19189 container.scrollTop += scrollAdjustment;
19190 }
19191 }
19192 anchorElementRef.current = null;
19193 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
19194 const intersectionObserverRef = (0, import_element75.useRef)(
19195 null
19196 );
19197 (0, import_element75.useEffect)(() => {
19198 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
19199 if (intersectionObserverRef.current) {
19200 intersectionObserverRef.current.disconnect();
19201 intersectionObserverRef.current = null;
19202 }
19203 return;
19204 }
19205 intersectionObserverRef.current = new IntersectionObserver(
19206 intersectionObserverCallback,
19207 { root: null, rootMargin: "0px", threshold: 0.1 }
19208 );
19209 return () => {
19210 if (intersectionObserverRef.current) {
19211 intersectionObserverRef.current.disconnect();
19212 intersectionObserverRef.current = null;
19213 }
19214 };
19215 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
19216 (0, import_element75.useEffect)(() => {
19217 if (!view.infiniteScrollEnabled || !containerRef.current) {
19218 return;
19219 }
19220 let lastScrollTop = 0;
19221 const BOTTOM_THRESHOLD = 600;
19222 const TOP_THRESHOLD = 800;
19223 const handleScroll = (0, import_compose11.throttle)((event) => {
19224 const currentView = viewRef.current;
19225 const totalItems = totalItemsRef.current;
19226 const target = event.target;
19227 const scrollTop = target.scrollTop;
19228 const scrollHeight = target.scrollHeight;
19229 const clientHeight = target.clientHeight;
19230 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
19231 lastScrollTop = scrollTop;
19232 if (isLoadingRef.current) {
19233 return;
19234 }
19235 const currentStartPosition = currentView.startPosition || 1;
19236 const batchSize = currentView.perPage || 10;
19237 const currentEndPosition = Math.min(
19238 currentStartPosition + batchSize,
19239 totalItems
19240 );
19241 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
19242 if (currentEndPosition < totalItems) {
19243 const newStartPosition = currentEndPosition;
19244 captureAnchorElement(target, anchorElementRef, "down");
19245 onChangeViewRef.current({
19246 ...currentView,
19247 startPosition: newStartPosition
19248 });
19249 }
19250 }
19251 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
19252 if (currentStartPosition > 1) {
19253 const calculatedStartPosition = currentStartPosition - batchSize;
19254 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
19255 captureAnchorElement(target, anchorElementRef, "up");
19256 onChangeViewRef.current({
19257 ...currentView,
19258 startPosition: newStartPosition
19259 });
19260 }
19261 }
19262 }, 50);
19263 const container = containerRef.current;
19264 container.addEventListener("scroll", handleScroll);
19265 return () => {
19266 container.removeEventListener("scroll", handleScroll);
19267 handleScroll.cancel();
19268 };
19269 }, [containerRef, view.infiniteScrollEnabled]);
19270 return {
19271 intersectionObserver: intersectionObserverRef.current
19272 };
19273 }
19274
19275 // packages/dataviews/build-module/dataviews/index.mjs
19276 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
19277 var defaultGetItemId = (item) => item.id;
19278 var defaultIsItemClickable = () => true;
19279 var EMPTY_ARRAY6 = [];
19280 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
19281 var dataViewsLayouts = VIEW_LAYOUTS.filter(
19282 (viewLayout) => !viewLayout.isPicker
19283 );
19284 function DefaultUI({
19285 header,
19286 search = true,
19287 searchLabel = void 0
19288 }) {
19289 const { view } = (0, import_element76.useContext)(dataviews_context_default);
19290 const isInfiniteScroll = view.infiniteScrollEnabled;
19291 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_jsx_runtime112.Fragment, { children: [
19292 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
19293 Stack,
19294 {
19295 direction: "row",
19296 align: "top",
19297 justify: "space-between",
19298 className: clsx_default("dataviews__view-actions", {
19299 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
19300 }),
19301 gap: "xs",
19302 children: [
19303 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
19304 Stack,
19305 {
19306 direction: "row",
19307 justify: "start",
19308 gap: "sm",
19309 className: "dataviews__search",
19310 children: [
19311 search && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_search_default, { label: searchLabel }),
19312 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(toggle_default, {})
19313 ]
19314 }
19315 ),
19316 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
19317 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_view_config_default, {}),
19318 header
19319 ] })
19320 ]
19321 }
19322 ),
19323 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
19324 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsLayout, {}),
19325 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsFooter, {})
19326 ] });
19327 }
19328 function DataViews({
19329 view,
19330 onChangeView,
19331 fields: fields2,
19332 search = true,
19333 searchLabel = void 0,
19334 actions: actions2 = EMPTY_ARRAY6,
19335 data,
19336 getItemId = defaultGetItemId,
19337 getItemLevel,
19338 isLoading = false,
19339 paginationInfo,
19340 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
19341 selection: selectionProperty,
19342 onChangeSelection,
19343 onClickItem,
19344 renderItemLink,
19345 isItemClickable = defaultIsItemClickable,
19346 header,
19347 children,
19348 config = { perPageSizes: [10, 20, 50, 100] },
19349 empty,
19350 onReset
19351 }) {
19352 const [selectionState, setSelectionState] = (0, import_element76.useState)([]);
19353 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
19354 const selection = isUncontrolled ? selectionState : selectionProperty;
19355 const {
19356 data: displayData,
19357 paginationInfo: displayPaginationInfo,
19358 hasInitiallyLoaded,
19359 setVisibleEntries
19360 } = useData({
19361 view,
19362 data,
19363 getItemId,
19364 isLoading,
19365 selection,
19366 paginationInfo
19367 });
19368 const containerRef = (0, import_element76.useRef)(null);
19369 const [containerWidth, setContainerWidth] = (0, import_element76.useState)(0);
19370 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
19371 (resizeObserverEntries) => {
19372 setContainerWidth(
19373 resizeObserverEntries[0].borderBoxSize[0].inlineSize
19374 );
19375 },
19376 { box: "border-box" }
19377 );
19378 const [openedFilter, setOpenedFilter] = (0, import_element76.useState)(null);
19379 function setSelectionWithChange(value) {
19380 const newValue = typeof value === "function" ? value(selection) : value;
19381 if (isUncontrolled) {
19382 setSelectionState(newValue);
19383 }
19384 if (onChangeSelection) {
19385 onChangeSelection(newValue);
19386 }
19387 }
19388 const _fields = (0, import_element76.useMemo)(() => normalizeFields(fields2), [fields2]);
19389 const _selection = (0, import_element76.useMemo)(() => {
19390 if (view.infiniteScrollEnabled) {
19391 return selection;
19392 }
19393 return selection.filter(
19394 (id) => data.some((item) => getItemId(item) === id)
19395 );
19396 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
19397 const filters = use_filters_default(_fields, view);
19398 const hasPrimaryOrLockedFilters = (0, import_element76.useMemo)(
19399 () => (filters || []).some(
19400 (filter) => filter.isPrimary || filter.isLocked
19401 ),
19402 [filters]
19403 );
19404 const [isShowingFilter, setIsShowingFilter] = (0, import_element76.useState)(
19405 hasPrimaryOrLockedFilters
19406 );
19407 const { intersectionObserver } = useInfiniteScroll({
19408 view,
19409 onChangeView,
19410 isLoading,
19411 paginationInfo,
19412 containerRef,
19413 setVisibleEntries
19414 });
19415 (0, import_element76.useEffect)(() => {
19416 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
19417 setIsShowingFilter(true);
19418 }
19419 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
19420 const defaultLayouts = (0, import_element76.useMemo)(
19421 () => Object.fromEntries(
19422 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
19423 return dataViewsLayouts.some(
19424 (viewLayout) => viewLayout.type === layoutType
19425 );
19426 }).map(([key, value]) => [
19427 key,
19428 value === true ? {} : value
19429 ])
19430 ),
19431 [defaultLayoutsProperty]
19432 );
19433 if (!defaultLayouts[view.type]) {
19434 return null;
19435 }
19436 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
19437 dataviews_context_default.Provider,
19438 {
19439 value: {
19440 view,
19441 onChangeView,
19442 fields: _fields,
19443 actions: actions2,
19444 data: displayData,
19445 isLoading,
19446 paginationInfo: displayPaginationInfo,
19447 selection: _selection,
19448 onChangeSelection: setSelectionWithChange,
19449 openedFilter,
19450 setOpenedFilter,
19451 getItemId,
19452 getItemLevel,
19453 isItemClickable,
19454 onClickItem,
19455 renderItemLink,
19456 containerWidth,
19457 containerRef,
19458 resizeObserverRef,
19459 defaultLayouts,
19460 filters,
19461 isShowingFilter,
19462 setIsShowingFilter,
19463 config,
19464 empty,
19465 hasInitiallyLoaded,
19466 onReset,
19467 intersectionObserver
19468 },
19469 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
19470 DefaultUI,
19471 {
19472 header,
19473 search,
19474 searchLabel
19475 }
19476 ) })
19477 }
19478 );
19479 }
19480 var DataViewsSubComponents = DataViews;
19481 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
19482 DataViewsSubComponents.Filters = filters_default;
19483 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
19484 DataViewsSubComponents.FiltersToggle = toggle_default;
19485 DataViewsSubComponents.Layout = DataViewsLayout;
19486 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
19487 DataViewsSubComponents.Pagination = DataViewsPagination;
19488 DataViewsSubComponents.Search = dataviews_search_default;
19489 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
19490 DataViewsSubComponents.Footer = DataViewsFooter;
19491 var dataviews_default = DataViewsSubComponents;
19492
19493 // packages/dataviews/build-module/dataform/index.mjs
19494 var import_element88 = __toESM(require_element(), 1);
19495
19496 // packages/dataviews/build-module/components/dataform-context/index.mjs
19497 var import_element77 = __toESM(require_element(), 1);
19498 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
19499 var DataFormContext = (0, import_element77.createContext)({
19500 fields: []
19501 });
19502 DataFormContext.displayName = "DataFormContext";
19503 function DataFormProvider({
19504 fields: fields2,
19505 children
19506 }) {
19507 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children });
19508 }
19509 var dataform_context_default = DataFormContext;
19510
19511 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
19512 var import_element87 = __toESM(require_element(), 1);
19513
19514 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
19515 var import_element78 = __toESM(require_element(), 1);
19516 var import_components47 = __toESM(require_components(), 1);
19517
19518 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
19519 var import_i18n44 = __toESM(require_i18n(), 1);
19520 var DEFAULT_LAYOUT = {
19521 type: "regular",
19522 labelPosition: "top"
19523 };
19524 var normalizeCardSummaryField = (sum) => {
19525 if (typeof sum === "string") {
19526 return [{ id: sum, visibility: "when-collapsed" }];
19527 }
19528 return sum.map((item) => {
19529 if (typeof item === "string") {
19530 return { id: item, visibility: "when-collapsed" };
19531 }
19532 return { id: item.id, visibility: item.visibility };
19533 });
19534 };
19535 function normalizeLayout(layout) {
19536 let normalizedLayout = DEFAULT_LAYOUT;
19537 if (layout?.type === "regular") {
19538 normalizedLayout = {
19539 type: "regular",
19540 labelPosition: layout?.labelPosition ?? "top"
19541 };
19542 } else if (layout?.type === "panel") {
19543 const summary = layout.summary ?? [];
19544 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
19545 const openAs = layout?.openAs;
19546 let normalizedOpenAs;
19547 if (typeof openAs === "object" && openAs.type === "modal") {
19548 normalizedOpenAs = {
19549 type: "modal",
19550 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n44.__)("Apply"),
19551 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n44.__)("Cancel")
19552 };
19553 } else if (openAs === "modal") {
19554 normalizedOpenAs = {
19555 type: "modal",
19556 applyLabel: (0, import_i18n44.__)("Apply"),
19557 cancelLabel: (0, import_i18n44.__)("Cancel")
19558 };
19559 } else {
19560 normalizedOpenAs = { type: "dropdown" };
19561 }
19562 normalizedLayout = {
19563 type: "panel",
19564 labelPosition: layout?.labelPosition ?? "side",
19565 openAs: normalizedOpenAs,
19566 summary: normalizedSummary,
19567 editVisibility: layout?.editVisibility ?? "on-hover"
19568 };
19569 } else if (layout?.type === "card") {
19570 if (layout.withHeader === false) {
19571 normalizedLayout = {
19572 type: "card",
19573 withHeader: false,
19574 isOpened: true,
19575 summary: [],
19576 isCollapsible: false
19577 };
19578 } else {
19579 const summary = layout.summary ?? [];
19580 normalizedLayout = {
19581 type: "card",
19582 withHeader: true,
19583 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
19584 summary: normalizeCardSummaryField(summary),
19585 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
19586 };
19587 }
19588 } else if (layout?.type === "row") {
19589 normalizedLayout = {
19590 type: "row",
19591 alignment: layout?.alignment ?? "center",
19592 styles: layout?.styles ?? {}
19593 };
19594 } else if (layout?.type === "details") {
19595 normalizedLayout = {
19596 type: "details",
19597 summary: layout?.summary ?? ""
19598 };
19599 }
19600 return normalizedLayout;
19601 }
19602 function normalizeForm(form) {
19603 const normalizedFormLayout = normalizeLayout(form?.layout);
19604 const normalizedFields = (form.fields ?? []).map(
19605 (field) => {
19606 if (typeof field === "string") {
19607 return {
19608 id: field,
19609 layout: normalizedFormLayout
19610 };
19611 }
19612 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
19613 return {
19614 id: field.id,
19615 layout: fieldLayout,
19616 ...!!field.label && { label: field.label },
19617 ...!!field.description && {
19618 description: field.description
19619 },
19620 ..."children" in field && Array.isArray(field.children) && {
19621 children: normalizeForm({
19622 fields: field.children,
19623 layout: DEFAULT_LAYOUT
19624 }).fields
19625 }
19626 };
19627 }
19628 );
19629 return {
19630 layout: normalizedFormLayout,
19631 fields: normalizedFields
19632 };
19633 }
19634 var normalize_form_default = normalizeForm;
19635
19636 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
19637 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
19638 function Header4({ title }) {
19639 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19640 Stack,
19641 {
19642 direction: "column",
19643 className: "dataforms-layouts-regular__header",
19644 gap: "lg",
19645 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components47.__experimentalHeading, { level: 2, size: 13, children: title }) })
19646 }
19647 );
19648 }
19649 function FormRegularField({
19650 data,
19651 field,
19652 onChange,
19653 hideLabelFromVision,
19654 markWhenOptional,
19655 validity
19656 }) {
19657 const { fields: fields2 } = (0, import_element78.useContext)(dataform_context_default);
19658 const layout = field.layout;
19659 const form = (0, import_element78.useMemo)(
19660 () => ({
19661 layout: DEFAULT_LAYOUT,
19662 fields: !!field.children ? field.children : []
19663 }),
19664 [field]
19665 );
19666 if (!!field.children) {
19667 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
19668 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Header4, { title: field.label }),
19669 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19670 DataFormLayout,
19671 {
19672 data,
19673 form,
19674 onChange,
19675 validity: validity?.children
19676 }
19677 )
19678 ] });
19679 }
19680 const labelPosition = layout.labelPosition;
19681 const fieldDefinition = fields2.find(
19682 (fieldDef) => fieldDef.id === field.id
19683 );
19684 if (!fieldDefinition || !fieldDefinition.Edit) {
19685 return null;
19686 }
19687 if (labelPosition === "side") {
19688 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
19689 Stack,
19690 {
19691 direction: "row",
19692 className: "dataforms-layouts-regular__field",
19693 gap: "sm",
19694 children: [
19695 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19696 "div",
19697 {
19698 className: clsx_default(
19699 "dataforms-layouts-regular__field-label",
19700 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
19701 ),
19702 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label })
19703 }
19704 ),
19705 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19706 fieldDefinition.render,
19707 {
19708 item: data,
19709 field: fieldDefinition
19710 }
19711 ) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19712 fieldDefinition.Edit,
19713 {
19714 data,
19715 field: fieldDefinition,
19716 onChange,
19717 hideLabelFromVision: true,
19718 markWhenOptional,
19719 validity
19720 },
19721 fieldDefinition.id
19722 ) })
19723 ]
19724 }
19725 );
19726 }
19727 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_jsx_runtime114.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
19728 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }),
19729 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19730 fieldDefinition.render,
19731 {
19732 item: data,
19733 field: fieldDefinition
19734 }
19735 )
19736 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
19737 fieldDefinition.Edit,
19738 {
19739 data,
19740 field: fieldDefinition,
19741 onChange,
19742 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
19743 markWhenOptional,
19744 validity
19745 }
19746 ) });
19747 }
19748
19749 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
19750 var import_deepmerge2 = __toESM(require_cjs(), 1);
19751 var import_components50 = __toESM(require_components(), 1);
19752 var import_element83 = __toESM(require_element(), 1);
19753 var import_compose14 = __toESM(require_compose(), 1);
19754
19755 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
19756 var import_components49 = __toESM(require_components(), 1);
19757 var import_i18n45 = __toESM(require_i18n(), 1);
19758 var import_compose13 = __toESM(require_compose(), 1);
19759 var import_element79 = __toESM(require_element(), 1);
19760
19761 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
19762 function getLabelClassName(labelPosition, showError) {
19763 return clsx_default(
19764 "dataforms-layouts-panel__field-label",
19765 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
19766 { "has-error": showError }
19767 );
19768 }
19769 var get_label_classname_default = getLabelClassName;
19770
19771 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
19772 var import_components48 = __toESM(require_components(), 1);
19773 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
19774 function getLabelContent(showError, errorMessage, fieldLabel) {
19775 return showError ? /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components48.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsxs)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: [
19776 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components48.Icon, { icon: error_default, size: 16 }),
19777 fieldLabel
19778 ] }) }) : fieldLabel;
19779 }
19780 var get_label_content_default = getLabelContent;
19781
19782 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
19783 function getFirstValidationError(validity) {
19784 if (!validity) {
19785 return void 0;
19786 }
19787 const validityRules = Object.keys(validity).filter(
19788 (key) => key !== "children"
19789 );
19790 for (const key of validityRules) {
19791 const rule = validity[key];
19792 if (rule === void 0) {
19793 continue;
19794 }
19795 if (rule.type === "invalid") {
19796 if (rule.message) {
19797 return rule.message;
19798 }
19799 if (key === "required") {
19800 return "A required field is empty";
19801 }
19802 return "Unidentified validation error";
19803 }
19804 }
19805 if (validity.children) {
19806 for (const childValidity of Object.values(validity.children)) {
19807 const childError = getFirstValidationError(childValidity);
19808 if (childError) {
19809 return childError;
19810 }
19811 }
19812 }
19813 return void 0;
19814 }
19815 var get_first_validation_error_default = getFirstValidationError;
19816
19817 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
19818 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
19819 function SummaryButton({
19820 data,
19821 field,
19822 fieldLabel,
19823 summaryFields,
19824 validity,
19825 touched,
19826 disabled: disabled2,
19827 onClick,
19828 "aria-expanded": ariaExpanded
19829 }) {
19830 const { labelPosition, editVisibility } = field.layout;
19831 const errorMessage = get_first_validation_error_default(validity);
19832 const showError = touched && !!errorMessage;
19833 const labelClassName = get_label_classname_default(labelPosition, showError);
19834 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
19835 const className = clsx_default(
19836 "dataforms-layouts-panel__field-trigger",
19837 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
19838 {
19839 "is-disabled": disabled2,
19840 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
19841 }
19842 );
19843 const controlId = (0, import_compose13.useInstanceId)(
19844 SummaryButton,
19845 "dataforms-layouts-panel__field-control"
19846 );
19847 const ariaLabel = showError ? (0, import_i18n45.sprintf)(
19848 // translators: %s: Field name.
19849 (0, import_i18n45._x)("Edit %s (has errors)", "field"),
19850 fieldLabel || ""
19851 ) : (0, import_i18n45.sprintf)(
19852 // translators: %s: Field name.
19853 (0, import_i18n45._x)("Edit %s", "field"),
19854 fieldLabel || ""
19855 );
19856 const rowRef = (0, import_element79.useRef)(null);
19857 const handleRowClick = () => {
19858 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
19859 if (selection && selection.toString().length > 0) {
19860 return;
19861 }
19862 onClick();
19863 };
19864 const handleKeyDown = (event) => {
19865 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
19866 event.preventDefault();
19867 onClick();
19868 }
19869 };
19870 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
19871 "div",
19872 {
19873 ref: rowRef,
19874 className,
19875 onClick: !disabled2 ? handleRowClick : void 0,
19876 onKeyDown: !disabled2 ? handleKeyDown : void 0,
19877 children: [
19878 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: labelClassName, children: labelContent }),
19879 labelPosition === "none" && showError && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components49.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: "dataforms-layouts-panel__field-label-error-content", children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components49.Icon, { icon: error_default, size: 16 }) }) }),
19880 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19881 "span",
19882 {
19883 id: `${controlId}`,
19884 className: "dataforms-layouts-panel__field-control",
19885 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19886 "span",
19887 {
19888 style: {
19889 display: "flex",
19890 flexDirection: "column",
19891 alignItems: "flex-start",
19892 width: "100%",
19893 gap: "2px"
19894 },
19895 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19896 "span",
19897 {
19898 style: { width: "100%" },
19899 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19900 summaryField.render,
19901 {
19902 item: data,
19903 field: summaryField
19904 }
19905 )
19906 },
19907 summaryField.id
19908 ))
19909 }
19910 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19911 summaryField.render,
19912 {
19913 item: data,
19914 field: summaryField
19915 },
19916 summaryField.id
19917 ))
19918 }
19919 ),
19920 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
19921 import_components49.Button,
19922 {
19923 className: "dataforms-layouts-panel__field-trigger-icon",
19924 label: ariaLabel,
19925 icon: pencil_default,
19926 size: "small",
19927 "aria-expanded": ariaExpanded,
19928 "aria-haspopup": "dialog",
19929 "aria-describedby": `${controlId}`
19930 }
19931 )
19932 ]
19933 }
19934 );
19935 }
19936
19937 // packages/dataviews/build-module/hooks/use-form-validity.mjs
19938 var import_deepmerge = __toESM(require_cjs(), 1);
19939 var import_es62 = __toESM(require_es6(), 1);
19940 var import_element80 = __toESM(require_element(), 1);
19941 var import_i18n46 = __toESM(require_i18n(), 1);
19942 function isFormValid(formValidity) {
19943 if (!formValidity) {
19944 return true;
19945 }
19946 return Object.values(formValidity).every((fieldValidation) => {
19947 return Object.entries(fieldValidation).every(
19948 ([key, validation]) => {
19949 if (key === "children" && validation && typeof validation === "object") {
19950 return isFormValid(validation);
19951 }
19952 return validation.type !== "invalid" && validation.type !== "validating";
19953 }
19954 );
19955 });
19956 }
19957 function getFormFieldsToValidate(form, fields2) {
19958 const normalizedForm = normalize_form_default(form);
19959 if (normalizedForm.fields.length === 0) {
19960 return [];
19961 }
19962 const fieldsMap = /* @__PURE__ */ new Map();
19963 fields2.forEach((field) => {
19964 fieldsMap.set(field.id, field);
19965 });
19966 function processFormField(formField) {
19967 if ("children" in formField && Array.isArray(formField.children)) {
19968 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
19969 if (processedChildren.length === 0) {
19970 return null;
19971 }
19972 const fieldDef2 = fieldsMap.get(formField.id);
19973 if (fieldDef2) {
19974 const [normalizedField2] = normalizeFields([
19975 fieldDef2
19976 ]);
19977 return {
19978 id: formField.id,
19979 children: processedChildren,
19980 field: normalizedField2
19981 };
19982 }
19983 return {
19984 id: formField.id,
19985 children: processedChildren
19986 };
19987 }
19988 const fieldDef = fieldsMap.get(formField.id);
19989 if (!fieldDef) {
19990 return null;
19991 }
19992 const [normalizedField] = normalizeFields([fieldDef]);
19993 return {
19994 id: formField.id,
19995 children: [],
19996 field: normalizedField
19997 };
19998 }
19999 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
20000 return toValidate;
20001 }
20002 function setValidityAtPath(formValidity, fieldValidity, path) {
20003 if (!formValidity) {
20004 formValidity = {};
20005 }
20006 if (path.length === 0) {
20007 return formValidity;
20008 }
20009 const result = { ...formValidity };
20010 let current = result;
20011 for (let i2 = 0; i2 < path.length - 1; i2++) {
20012 const segment = path[i2];
20013 if (!current[segment]) {
20014 current[segment] = {};
20015 }
20016 current[segment] = { ...current[segment] };
20017 current = current[segment];
20018 }
20019 const finalKey = path[path.length - 1];
20020 current[finalKey] = {
20021 ...current[finalKey] || {},
20022 ...fieldValidity
20023 };
20024 return result;
20025 }
20026 function removeValidationProperty(formValidity, path, property) {
20027 if (!formValidity || path.length === 0) {
20028 return formValidity;
20029 }
20030 const result = { ...formValidity };
20031 let current = result;
20032 for (let i2 = 0; i2 < path.length - 1; i2++) {
20033 const segment = path[i2];
20034 if (!current[segment]) {
20035 return formValidity;
20036 }
20037 current[segment] = { ...current[segment] };
20038 current = current[segment];
20039 }
20040 const finalKey = path[path.length - 1];
20041 if (!current[finalKey]) {
20042 return formValidity;
20043 }
20044 const fieldValidity = { ...current[finalKey] };
20045 delete fieldValidity[property];
20046 if (Object.keys(fieldValidity).length === 0) {
20047 delete current[finalKey];
20048 } else {
20049 current[finalKey] = fieldValidity;
20050 }
20051 if (Object.keys(result).length === 0) {
20052 return void 0;
20053 }
20054 return result;
20055 }
20056 function handleElementsValidationAsync(promise, formField, promiseHandler) {
20057 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
20058 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
20059 elementsCounterRef.current[formField.id] = currentToken;
20060 promise.then((result) => {
20061 if (currentToken !== elementsCounterRef.current[formField.id]) {
20062 return;
20063 }
20064 if (!Array.isArray(result)) {
20065 setFormValidity((prev) => {
20066 const newFormValidity = setValidityAtPath(
20067 prev,
20068 {
20069 elements: {
20070 type: "invalid",
20071 message: (0, import_i18n46.__)("Could not validate elements.")
20072 }
20073 },
20074 [...path, formField.id]
20075 );
20076 return newFormValidity;
20077 });
20078 return;
20079 }
20080 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
20081 ...formField.field,
20082 elements: result
20083 })) {
20084 setFormValidity((prev) => {
20085 const newFormValidity = setValidityAtPath(
20086 prev,
20087 {
20088 elements: {
20089 type: "invalid",
20090 message: (0, import_i18n46.__)(
20091 "Value must be one of the elements."
20092 )
20093 }
20094 },
20095 [...path, formField.id]
20096 );
20097 return newFormValidity;
20098 });
20099 } else {
20100 setFormValidity((prev) => {
20101 return removeValidationProperty(
20102 prev,
20103 [...path, formField.id],
20104 "elements"
20105 );
20106 });
20107 }
20108 }).catch((error2) => {
20109 if (currentToken !== elementsCounterRef.current[formField.id]) {
20110 return;
20111 }
20112 let errorMessage;
20113 if (error2 instanceof Error) {
20114 errorMessage = error2.message;
20115 } else {
20116 errorMessage = String(error2) || (0, import_i18n46.__)(
20117 "Unknown error when running elements validation asynchronously."
20118 );
20119 }
20120 setFormValidity((prev) => {
20121 const newFormValidity = setValidityAtPath(
20122 prev,
20123 {
20124 elements: {
20125 type: "invalid",
20126 message: errorMessage
20127 }
20128 },
20129 [...path, formField.id]
20130 );
20131 return newFormValidity;
20132 });
20133 });
20134 }
20135 function handleCustomValidationAsync(promise, formField, promiseHandler) {
20136 const { customCounterRef, setFormValidity, path } = promiseHandler;
20137 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
20138 customCounterRef.current[formField.id] = currentToken;
20139 promise.then((result) => {
20140 if (currentToken !== customCounterRef.current[formField.id]) {
20141 return;
20142 }
20143 if (result === null) {
20144 setFormValidity((prev) => {
20145 return removeValidationProperty(
20146 prev,
20147 [...path, formField.id],
20148 "custom"
20149 );
20150 });
20151 return;
20152 }
20153 if (typeof result === "string") {
20154 setFormValidity((prev) => {
20155 const newFormValidity = setValidityAtPath(
20156 prev,
20157 {
20158 custom: {
20159 type: "invalid",
20160 message: result
20161 }
20162 },
20163 [...path, formField.id]
20164 );
20165 return newFormValidity;
20166 });
20167 return;
20168 }
20169 setFormValidity((prev) => {
20170 const newFormValidity = setValidityAtPath(
20171 prev,
20172 {
20173 custom: {
20174 type: "invalid",
20175 message: (0, import_i18n46.__)("Validation could not be processed.")
20176 }
20177 },
20178 [...path, formField.id]
20179 );
20180 return newFormValidity;
20181 });
20182 }).catch((error2) => {
20183 if (currentToken !== customCounterRef.current[formField.id]) {
20184 return;
20185 }
20186 let errorMessage;
20187 if (error2 instanceof Error) {
20188 errorMessage = error2.message;
20189 } else {
20190 errorMessage = String(error2) || (0, import_i18n46.__)(
20191 "Unknown error when running custom validation asynchronously."
20192 );
20193 }
20194 setFormValidity((prev) => {
20195 const newFormValidity = setValidityAtPath(
20196 prev,
20197 {
20198 custom: {
20199 type: "invalid",
20200 message: errorMessage
20201 }
20202 },
20203 [...path, formField.id]
20204 );
20205 return newFormValidity;
20206 });
20207 });
20208 }
20209 function validateFormField(item, formField, promiseHandler) {
20210 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
20211 return {
20212 required: { type: "invalid" }
20213 };
20214 }
20215 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
20216 return {
20217 pattern: {
20218 type: "invalid",
20219 message: (0, import_i18n46.__)("Value does not match the required pattern.")
20220 }
20221 };
20222 }
20223 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
20224 return {
20225 min: {
20226 type: "invalid",
20227 message: (0, import_i18n46.__)("Value is below the minimum.")
20228 }
20229 };
20230 }
20231 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
20232 return {
20233 max: {
20234 type: "invalid",
20235 message: (0, import_i18n46.__)("Value is above the maximum.")
20236 }
20237 };
20238 }
20239 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
20240 return {
20241 minLength: {
20242 type: "invalid",
20243 message: (0, import_i18n46.__)("Value is too short.")
20244 }
20245 };
20246 }
20247 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
20248 return {
20249 maxLength: {
20250 type: "invalid",
20251 message: (0, import_i18n46.__)("Value is too long.")
20252 }
20253 };
20254 }
20255 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
20256 return {
20257 elements: {
20258 type: "invalid",
20259 message: (0, import_i18n46.__)("Value must be one of the elements.")
20260 }
20261 };
20262 }
20263 let customError;
20264 if (!!formField.field && formField.field.isValid.custom) {
20265 try {
20266 const value = formField.field.getValue({ item });
20267 customError = formField.field.isValid.custom(
20268 (0, import_deepmerge.default)(
20269 item,
20270 formField.field.setValue({
20271 item,
20272 value
20273 })
20274 ),
20275 formField.field
20276 );
20277 } catch (error2) {
20278 let errorMessage;
20279 if (error2 instanceof Error) {
20280 errorMessage = error2.message;
20281 } else {
20282 errorMessage = String(error2) || (0, import_i18n46.__)("Unknown error when running custom validation.");
20283 }
20284 return {
20285 custom: {
20286 type: "invalid",
20287 message: errorMessage
20288 }
20289 };
20290 }
20291 }
20292 if (typeof customError === "string") {
20293 return {
20294 custom: {
20295 type: "invalid",
20296 message: customError
20297 }
20298 };
20299 }
20300 const fieldValidity = {};
20301 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
20302 handleElementsValidationAsync(
20303 formField.field.getElements(),
20304 formField,
20305 promiseHandler
20306 );
20307 fieldValidity.elements = {
20308 type: "validating",
20309 message: (0, import_i18n46.__)("Validating\u2026")
20310 };
20311 }
20312 if (customError instanceof Promise) {
20313 handleCustomValidationAsync(customError, formField, promiseHandler);
20314 fieldValidity.custom = {
20315 type: "validating",
20316 message: (0, import_i18n46.__)("Validating\u2026")
20317 };
20318 }
20319 if (Object.keys(fieldValidity).length > 0) {
20320 return fieldValidity;
20321 }
20322 if (formField.children.length > 0) {
20323 const result = {};
20324 formField.children.forEach((child) => {
20325 result[child.id] = validateFormField(item, child, {
20326 ...promiseHandler,
20327 path: [...promiseHandler.path, formField.id, "children"]
20328 });
20329 });
20330 const filteredResult = {};
20331 Object.entries(result).forEach(([key, value]) => {
20332 if (value !== void 0) {
20333 filteredResult[key] = value;
20334 }
20335 });
20336 if (Object.keys(filteredResult).length === 0) {
20337 return void 0;
20338 }
20339 return {
20340 children: filteredResult
20341 };
20342 }
20343 return void 0;
20344 }
20345 function getFormFieldValue(formField, item) {
20346 const fieldValue = formField?.field?.getValue({ item });
20347 if (formField.children.length === 0) {
20348 return fieldValue;
20349 }
20350 const childrenValues = formField.children.map(
20351 (child) => getFormFieldValue(child, item)
20352 );
20353 if (!childrenValues) {
20354 return fieldValue;
20355 }
20356 return {
20357 value: fieldValue,
20358 children: childrenValues
20359 };
20360 }
20361 function useFormValidity(item, fields2, form) {
20362 const [formValidity, setFormValidity] = (0, import_element80.useState)();
20363 const customCounterRef = (0, import_element80.useRef)({});
20364 const elementsCounterRef = (0, import_element80.useRef)({});
20365 const previousValuesRef = (0, import_element80.useRef)({});
20366 const validate = (0, import_element80.useCallback)(() => {
20367 const promiseHandler = {
20368 customCounterRef,
20369 elementsCounterRef,
20370 setFormValidity,
20371 path: [],
20372 item
20373 };
20374 const formFieldsToValidate = getFormFieldsToValidate(form, fields2);
20375 if (formFieldsToValidate.length === 0) {
20376 setFormValidity(void 0);
20377 return;
20378 }
20379 const newFormValidity = {};
20380 const untouchedFields = [];
20381 formFieldsToValidate.forEach((formField) => {
20382 const value = getFormFieldValue(formField, item);
20383 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
20384 previousValuesRef.current[formField.id],
20385 value
20386 )) {
20387 untouchedFields.push(formField.id);
20388 return;
20389 }
20390 previousValuesRef.current[formField.id] = value;
20391 const fieldValidity = validateFormField(
20392 item,
20393 formField,
20394 promiseHandler
20395 );
20396 if (fieldValidity !== void 0) {
20397 newFormValidity[formField.id] = fieldValidity;
20398 }
20399 });
20400 setFormValidity((existingFormValidity) => {
20401 let validity = {
20402 ...existingFormValidity,
20403 ...newFormValidity
20404 };
20405 const fieldsToKeep = [
20406 ...untouchedFields,
20407 ...Object.keys(newFormValidity)
20408 ];
20409 Object.keys(validity).forEach((key) => {
20410 if (validity && !fieldsToKeep.includes(key)) {
20411 delete validity[key];
20412 }
20413 });
20414 if (Object.keys(validity).length === 0) {
20415 validity = void 0;
20416 }
20417 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
20418 if (areEqual) {
20419 return existingFormValidity;
20420 }
20421 return validity;
20422 });
20423 }, [item, fields2, form]);
20424 (0, import_element80.useEffect)(() => {
20425 validate();
20426 }, [validate]);
20427 return {
20428 validity: formValidity,
20429 isValid: isFormValid(formValidity)
20430 };
20431 }
20432 var use_form_validity_default = useFormValidity;
20433
20434 // packages/dataviews/build-module/hooks/use-report-validity.mjs
20435 var import_element81 = __toESM(require_element(), 1);
20436 function useReportValidity(ref, shouldReport) {
20437 (0, import_element81.useEffect)(() => {
20438 if (shouldReport && ref.current) {
20439 const inputs = ref.current.querySelectorAll(
20440 "input, textarea, select"
20441 );
20442 inputs.forEach((input) => {
20443 input.reportValidity();
20444 });
20445 }
20446 }, [shouldReport, ref]);
20447 }
20448
20449 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
20450 var import_element82 = __toESM(require_element(), 1);
20451
20452 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
20453 function extractSummaryIds(summary) {
20454 if (Array.isArray(summary)) {
20455 return summary.map(
20456 (item) => typeof item === "string" ? item : item.id
20457 );
20458 }
20459 return [];
20460 }
20461 var getSummaryFields = (summaryField, fields2) => {
20462 if (Array.isArray(summaryField) && summaryField.length > 0) {
20463 const summaryIds = extractSummaryIds(summaryField);
20464 return summaryIds.map(
20465 (summaryId) => fields2.find((_field) => _field.id === summaryId)
20466 ).filter((_field) => _field !== void 0);
20467 }
20468 return [];
20469 };
20470
20471 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
20472 var getFieldDefinition = (field, fields2) => {
20473 const fieldDefinition = fields2.find((_field) => _field.id === field.id);
20474 if (!fieldDefinition) {
20475 return fields2.find((_field) => {
20476 if (!!field.children) {
20477 const simpleChildren = field.children.filter(
20478 (child) => !child.children
20479 );
20480 if (simpleChildren.length === 0) {
20481 return false;
20482 }
20483 return _field.id === simpleChildren[0].id;
20484 }
20485 return _field.id === field.id;
20486 });
20487 }
20488 return fieldDefinition;
20489 };
20490 function useFieldFromFormField(field) {
20491 const { fields: fields2 } = (0, import_element82.useContext)(dataform_context_default);
20492 const layout = field.layout;
20493 const summaryFields = getSummaryFields(layout.summary, fields2);
20494 const fieldDefinition = getFieldDefinition(field, fields2);
20495 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
20496 if (summaryFields.length === 0) {
20497 return {
20498 summaryFields: fieldDefinition ? [fieldDefinition] : [],
20499 fieldDefinition,
20500 fieldLabel
20501 };
20502 }
20503 return {
20504 summaryFields,
20505 fieldDefinition,
20506 fieldLabel
20507 };
20508 }
20509 var use_field_from_form_field_default = useFieldFromFormField;
20510
20511 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
20512 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
20513 function ModalContent({
20514 data,
20515 field,
20516 onChange,
20517 fieldLabel,
20518 onClose,
20519 touched
20520 }) {
20521 const { openAs } = field.layout;
20522 const { applyLabel, cancelLabel } = openAs;
20523 const { fields: fields2 } = (0, import_element83.useContext)(dataform_context_default);
20524 const [changes, setChanges] = (0, import_element83.useState)({});
20525 const modalData = (0, import_element83.useMemo)(() => {
20526 return (0, import_deepmerge2.default)(data, changes, {
20527 arrayMerge: (target, source) => source
20528 });
20529 }, [data, changes]);
20530 const form = (0, import_element83.useMemo)(
20531 () => ({
20532 layout: DEFAULT_LAYOUT,
20533 fields: !!field.children ? field.children : (
20534 // If not explicit children return the field id itself.
20535 [{ id: field.id, layout: DEFAULT_LAYOUT }]
20536 )
20537 }),
20538 [field]
20539 );
20540 const fieldsAsFieldType = fields2.map((f2) => ({
20541 ...f2,
20542 Edit: f2.Edit === null ? void 0 : f2.Edit,
20543 isValid: {
20544 required: f2.isValid.required?.constraint,
20545 elements: f2.isValid.elements?.constraint,
20546 min: f2.isValid.min?.constraint,
20547 max: f2.isValid.max?.constraint,
20548 pattern: f2.isValid.pattern?.constraint,
20549 minLength: f2.isValid.minLength?.constraint,
20550 maxLength: f2.isValid.maxLength?.constraint
20551 }
20552 }));
20553 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
20554 const onApply = () => {
20555 onChange(changes);
20556 onClose();
20557 };
20558 const handleOnChange = (newValue) => {
20559 setChanges(
20560 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
20561 arrayMerge: (target, source) => source
20562 })
20563 );
20564 };
20565 const focusOnMountRef = (0, import_compose14.useFocusOnMount)("firstInputElement");
20566 const contentRef = (0, import_element83.useRef)(null);
20567 const mergedRef = (0, import_compose14.useMergeRefs)([focusOnMountRef, contentRef]);
20568 useReportValidity(contentRef, touched);
20569 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
20570 import_components50.Modal,
20571 {
20572 className: "dataforms-layouts-panel__modal",
20573 onRequestClose: onClose,
20574 isFullScreen: false,
20575 title: fieldLabel,
20576 size: "medium",
20577 children: [
20578 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20579 DataFormLayout,
20580 {
20581 data: modalData,
20582 form,
20583 onChange: handleOnChange,
20584 validity,
20585 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20586 FieldLayout,
20587 {
20588 data: modalData,
20589 field: childField,
20590 onChange: handleOnChange,
20591 hideLabelFromVision: form.fields.length < 2,
20592 markWhenOptional,
20593 validity: childFieldValidity
20594 },
20595 childField.id
20596 )
20597 }
20598 ) }),
20599 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
20600 Stack,
20601 {
20602 direction: "row",
20603 className: "dataforms-layouts-panel__modal-footer",
20604 gap: "md",
20605 children: [
20606 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
20607 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20608 import_components50.Button,
20609 {
20610 variant: "tertiary",
20611 onClick: onClose,
20612 __next40pxDefaultSize: true,
20613 children: cancelLabel
20614 }
20615 ),
20616 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20617 import_components50.Button,
20618 {
20619 variant: "primary",
20620 onClick: onApply,
20621 __next40pxDefaultSize: true,
20622 children: applyLabel
20623 }
20624 )
20625 ]
20626 }
20627 )
20628 ]
20629 }
20630 );
20631 }
20632 function PanelModal({
20633 data,
20634 field,
20635 onChange,
20636 validity
20637 }) {
20638 const [touched, setTouched] = (0, import_element83.useState)(false);
20639 const [isOpen, setIsOpen] = (0, import_element83.useState)(false);
20640 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
20641 if (!fieldDefinition) {
20642 return null;
20643 }
20644 const handleClose = () => {
20645 setIsOpen(false);
20646 setTouched(true);
20647 };
20648 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
20649 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20650 SummaryButton,
20651 {
20652 data,
20653 field,
20654 fieldLabel,
20655 summaryFields,
20656 validity,
20657 touched,
20658 disabled: fieldDefinition.readOnly === true,
20659 onClick: () => setIsOpen(true),
20660 "aria-expanded": isOpen
20661 }
20662 ),
20663 isOpen && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
20664 ModalContent,
20665 {
20666 data,
20667 field,
20668 onChange,
20669 fieldLabel: fieldLabel ?? "",
20670 onClose: handleClose,
20671 touched
20672 }
20673 )
20674 ] });
20675 }
20676 var modal_default = PanelModal;
20677
20678 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
20679 var import_components51 = __toESM(require_components(), 1);
20680 var import_i18n47 = __toESM(require_i18n(), 1);
20681 var import_element84 = __toESM(require_element(), 1);
20682 var import_compose15 = __toESM(require_compose(), 1);
20683 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
20684 function DropdownHeader({
20685 title,
20686 onClose
20687 }) {
20688 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20689 Stack,
20690 {
20691 direction: "column",
20692 className: "dataforms-layouts-panel__dropdown-header",
20693 gap: "lg",
20694 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
20695 title && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }),
20696 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
20697 onClose && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20698 import_components51.Button,
20699 {
20700 label: (0, import_i18n47.__)("Close"),
20701 icon: close_small_default,
20702 onClick: onClose,
20703 size: "small"
20704 }
20705 )
20706 ] })
20707 }
20708 );
20709 }
20710 function DropdownContentWithValidation({
20711 touched,
20712 children
20713 }) {
20714 const ref = (0, import_element84.useRef)(null);
20715 useReportValidity(ref, touched);
20716 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { ref, children });
20717 }
20718 function PanelDropdown({
20719 data,
20720 field,
20721 onChange,
20722 validity
20723 }) {
20724 const [touched, setTouched] = (0, import_element84.useState)(false);
20725 const [popoverAnchor, setPopoverAnchor] = (0, import_element84.useState)(
20726 null
20727 );
20728 const popoverProps = (0, import_element84.useMemo)(
20729 () => ({
20730 // Anchor the popover to the middle of the entire row so that it doesn't
20731 // move around when the label changes.
20732 anchor: popoverAnchor,
20733 placement: "left-start",
20734 offset: 36,
20735 shift: true
20736 }),
20737 [popoverAnchor]
20738 );
20739 const [dialogRef, dialogProps] = (0, import_compose15.__experimentalUseDialog)({
20740 focusOnMount: "firstInputElement"
20741 });
20742 const form = (0, import_element84.useMemo)(
20743 () => ({
20744 layout: DEFAULT_LAYOUT,
20745 fields: !!field.children ? field.children : (
20746 // If not explicit children return the field id itself.
20747 [{ id: field.id, layout: DEFAULT_LAYOUT }]
20748 )
20749 }),
20750 [field]
20751 );
20752 const formValidity = (0, import_element84.useMemo)(() => {
20753 if (validity === void 0) {
20754 return void 0;
20755 }
20756 if (!!field.children) {
20757 return validity?.children;
20758 }
20759 return { [field.id]: validity };
20760 }, [validity, field]);
20761 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
20762 if (!fieldDefinition) {
20763 return null;
20764 }
20765 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20766 "div",
20767 {
20768 ref: setPopoverAnchor,
20769 className: "dataforms-layouts-panel__field-dropdown-anchor",
20770 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20771 import_components51.Dropdown,
20772 {
20773 contentClassName: "dataforms-layouts-panel__field-dropdown",
20774 popoverProps,
20775 focusOnMount: false,
20776 onToggle: (willOpen) => {
20777 if (!willOpen) {
20778 setTouched(true);
20779 }
20780 },
20781 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20782 SummaryButton,
20783 {
20784 data,
20785 field,
20786 fieldLabel,
20787 summaryFields,
20788 validity,
20789 touched,
20790 disabled: fieldDefinition.readOnly === true,
20791 onClick: onToggle,
20792 "aria-expanded": isOpen
20793 }
20794 ),
20795 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
20796 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20797 DropdownHeader,
20798 {
20799 title: fieldLabel,
20800 onClose
20801 }
20802 ),
20803 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20804 DataFormLayout,
20805 {
20806 data,
20807 form,
20808 onChange,
20809 validity: formValidity,
20810 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
20811 FieldLayout,
20812 {
20813 data,
20814 field: childField,
20815 onChange,
20816 hideLabelFromVision: (form?.fields ?? []).length < 2,
20817 markWhenOptional,
20818 validity: childFieldValidity
20819 },
20820 childField.id
20821 )
20822 }
20823 )
20824 ] }) })
20825 }
20826 )
20827 }
20828 );
20829 }
20830 var dropdown_default = PanelDropdown;
20831
20832 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
20833 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
20834 function FormPanelField({
20835 data,
20836 field,
20837 onChange,
20838 validity
20839 }) {
20840 const layout = field.layout;
20841 if (layout.openAs.type === "modal") {
20842 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
20843 modal_default,
20844 {
20845 data,
20846 field,
20847 onChange,
20848 validity
20849 }
20850 );
20851 }
20852 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
20853 dropdown_default,
20854 {
20855 data,
20856 field,
20857 onChange,
20858 validity
20859 }
20860 );
20861 }
20862
20863 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
20864 var import_element85 = __toESM(require_element(), 1);
20865
20866 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
20867 var import_i18n48 = __toESM(require_i18n(), 1);
20868 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
20869 function countInvalidFields(validity) {
20870 if (!validity) {
20871 return 0;
20872 }
20873 let count = 0;
20874 const validityRules = Object.keys(validity).filter(
20875 (key) => key !== "children"
20876 );
20877 for (const key of validityRules) {
20878 const rule = validity[key];
20879 if (rule?.type === "invalid") {
20880 count++;
20881 }
20882 }
20883 if (validity.children) {
20884 for (const childValidity of Object.values(validity.children)) {
20885 count += countInvalidFields(childValidity);
20886 }
20887 }
20888 return count;
20889 }
20890 function ValidationBadge({
20891 validity
20892 }) {
20893 const invalidCount = countInvalidFields(validity);
20894 if (invalidCount === 0) {
20895 return null;
20896 }
20897 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Badge, { intent: "high", children: (0, import_i18n48.sprintf)(
20898 /* translators: %d: Number of fields that need attention */
20899 (0, import_i18n48._n)(
20900 "%d field needs attention",
20901 "%d fields need attention",
20902 invalidCount
20903 ),
20904 invalidCount
20905 ) });
20906 }
20907
20908 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
20909 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
20910 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
20911 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
20912 return false;
20913 }
20914 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
20915 const fieldConfig = summaryConfigArray.find((config) => {
20916 if (typeof config === "string") {
20917 return config === summaryField.id;
20918 }
20919 if (typeof config === "object" && "id" in config) {
20920 return config.id === summaryField.id;
20921 }
20922 return false;
20923 });
20924 if (!fieldConfig) {
20925 return false;
20926 }
20927 if (typeof fieldConfig === "string") {
20928 return true;
20929 }
20930 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
20931 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
20932 }
20933 return true;
20934 }
20935 function HeaderContent({
20936 data,
20937 fields: fields2,
20938 label,
20939 layout,
20940 isOpen,
20941 touched,
20942 validity
20943 }) {
20944 const summaryFields = getSummaryFields(layout.summary, fields2);
20945 const visibleSummaryFields = summaryFields.filter(
20946 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
20947 );
20948 const hasBadge = touched && layout.isCollapsible;
20949 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
20950 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
20951 Stack,
20952 {
20953 align: "center",
20954 justify: "space-between",
20955 className: "dataforms-layouts-card__field-header-content",
20956 children: [
20957 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Title, { children: label }),
20958 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
20959 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ValidationBadge, { validity }),
20960 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20961 summaryField.render,
20962 {
20963 item: data,
20964 field: summaryField
20965 },
20966 summaryField.id
20967 )) })
20968 ] })
20969 ]
20970 }
20971 );
20972 }
20973 function BodyContent({
20974 data,
20975 field,
20976 form,
20977 onChange,
20978 hideLabelFromVision,
20979 markWhenOptional,
20980 validity,
20981 withHeader
20982 }) {
20983 if (field.children) {
20984 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
20985 field.description && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
20986 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
20987 DataFormLayout,
20988 {
20989 data,
20990 form,
20991 onChange,
20992 validity: validity?.children
20993 }
20994 )
20995 ] });
20996 }
20997 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
20998 if (!SingleFieldLayout) {
20999 return null;
21000 }
21001 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21002 SingleFieldLayout,
21003 {
21004 data,
21005 field,
21006 onChange,
21007 hideLabelFromVision: hideLabelFromVision || withHeader,
21008 markWhenOptional,
21009 validity
21010 }
21011 );
21012 }
21013 function FormCardField({
21014 data,
21015 field,
21016 onChange,
21017 hideLabelFromVision,
21018 markWhenOptional,
21019 validity
21020 }) {
21021 const { fields: fields2 } = (0, import_element85.useContext)(dataform_context_default);
21022 const layout = field.layout;
21023 const contentRef = (0, import_element85.useRef)(null);
21024 const form = (0, import_element85.useMemo)(
21025 () => ({
21026 layout: DEFAULT_LAYOUT,
21027 fields: field.children ?? []
21028 }),
21029 [field]
21030 );
21031 const { isOpened, isCollapsible } = layout;
21032 const [isOpen, setIsOpen] = (0, import_element85.useState)(isOpened);
21033 const [touched, setTouched] = (0, import_element85.useState)(false);
21034 (0, import_element85.useEffect)(() => {
21035 setIsOpen(isOpened);
21036 }, [isOpened]);
21037 const handleOpenChange = (0, import_element85.useCallback)((open) => {
21038 if (!open) {
21039 setTouched(true);
21040 }
21041 setIsOpen(open);
21042 }, []);
21043 const handleBlur = (0, import_element85.useCallback)(() => {
21044 setTouched(true);
21045 }, []);
21046 useReportValidity(
21047 contentRef,
21048 (isCollapsible ? isOpen : true) && touched
21049 );
21050 let label = field.label;
21051 let withHeader;
21052 if (field.children) {
21053 withHeader = !!label && layout.withHeader;
21054 } else {
21055 const fieldDefinition = fields2.find(
21056 (fieldDef) => fieldDef.id === field.id
21057 );
21058 if (!fieldDefinition || !fieldDefinition.Edit) {
21059 return null;
21060 }
21061 label = fieldDefinition.label;
21062 withHeader = !!label && layout.withHeader;
21063 }
21064 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21065 BodyContent,
21066 {
21067 data,
21068 field,
21069 form,
21070 onChange,
21071 hideLabelFromVision,
21072 markWhenOptional,
21073 validity,
21074 withHeader
21075 }
21076 );
21077 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21078 HeaderContent,
21079 {
21080 data,
21081 fields: fields2,
21082 label,
21083 layout,
21084 isOpen: isCollapsible ? !!isOpen : true,
21085 touched,
21086 validity
21087 }
21088 );
21089 if (withHeader && isCollapsible) {
21090 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
21091 collapsible_card_exports.Root,
21092 {
21093 className: "dataforms-layouts-card__field",
21094 open: isOpen,
21095 onOpenChange: handleOpenChange,
21096 children: [
21097 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(collapsible_card_exports.Header, { children: headerContent }),
21098 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21099 collapsible_card_exports.Content,
21100 {
21101 ref: contentRef,
21102 onBlur: handleBlur,
21103 children: bodyContent
21104 }
21105 )
21106 ]
21107 }
21108 );
21109 }
21110 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
21111 withHeader && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Header, { children: headerContent }),
21112 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
21113 ] });
21114 }
21115
21116 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
21117 var import_components52 = __toESM(require_components(), 1);
21118 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
21119 function Header5({ title }) {
21120 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21121 Stack,
21122 {
21123 direction: "column",
21124 className: "dataforms-layouts-row__header",
21125 gap: "lg",
21126 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { direction: "row", align: "center", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_components52.__experimentalHeading, { level: 2, size: 13, children: title }) })
21127 }
21128 );
21129 }
21130 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children });
21131 function FormRowField({
21132 data,
21133 field,
21134 onChange,
21135 hideLabelFromVision,
21136 markWhenOptional,
21137 validity
21138 }) {
21139 const layout = field.layout;
21140 if (!!field.children) {
21141 const form = {
21142 layout: DEFAULT_LAYOUT,
21143 fields: field.children
21144 };
21145 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
21146 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Header5, { title: field.label }),
21147 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21148 DataFormLayout,
21149 {
21150 data,
21151 form,
21152 onChange,
21153 validity: validity?.children,
21154 as: EMPTY_WRAPPER,
21155 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21156 "div",
21157 {
21158 className: "dataforms-layouts-row__field-control",
21159 style: layout.styles[childField.id],
21160 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21161 FieldLayout,
21162 {
21163 data,
21164 field: childField,
21165 onChange,
21166 hideLabelFromVision,
21167 markWhenOptional,
21168 validity: childFieldValidity
21169 }
21170 )
21171 },
21172 childField.id
21173 )
21174 }
21175 ) })
21176 ] });
21177 }
21178 const RegularLayout = getFormFieldLayout("regular")?.component;
21179 if (!RegularLayout) {
21180 return null;
21181 }
21182 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21183 RegularLayout,
21184 {
21185 data,
21186 field,
21187 onChange,
21188 markWhenOptional,
21189 validity
21190 }
21191 ) }) });
21192 }
21193
21194 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
21195 var import_element86 = __toESM(require_element(), 1);
21196 var import_i18n49 = __toESM(require_i18n(), 1);
21197 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
21198 function FormDetailsField({
21199 data,
21200 field,
21201 onChange,
21202 validity
21203 }) {
21204 const { fields: fields2 } = (0, import_element86.useContext)(dataform_context_default);
21205 const detailsRef = (0, import_element86.useRef)(null);
21206 const contentRef = (0, import_element86.useRef)(null);
21207 const [touched, setTouched] = (0, import_element86.useState)(false);
21208 const [isOpen, setIsOpen] = (0, import_element86.useState)(false);
21209 const form = (0, import_element86.useMemo)(
21210 () => ({
21211 layout: DEFAULT_LAYOUT,
21212 fields: field.children ?? []
21213 }),
21214 [field]
21215 );
21216 (0, import_element86.useEffect)(() => {
21217 const details = detailsRef.current;
21218 if (!details) {
21219 return;
21220 }
21221 const handleToggle = () => {
21222 const nowOpen = details.open;
21223 if (!nowOpen) {
21224 setTouched(true);
21225 }
21226 setIsOpen(nowOpen);
21227 };
21228 details.addEventListener("toggle", handleToggle);
21229 return () => {
21230 details.removeEventListener("toggle", handleToggle);
21231 };
21232 }, []);
21233 useReportValidity(contentRef, isOpen && touched);
21234 const handleBlur = (0, import_element86.useCallback)(() => {
21235 setTouched(true);
21236 }, []);
21237 if (!field.children) {
21238 return null;
21239 }
21240 const summaryFieldId = field.layout.summary ?? "";
21241 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
21242 let summaryContent;
21243 if (summaryField && summaryField.render) {
21244 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(summaryField.render, { item: data, field: summaryField });
21245 } else {
21246 summaryContent = field.label || (0, import_i18n49.__)("More details");
21247 }
21248 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
21249 "details",
21250 {
21251 ref: detailsRef,
21252 className: "dataforms-layouts-details__details",
21253 children: [
21254 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
21255 Stack,
21256 {
21257 direction: "row",
21258 align: "center",
21259 gap: "md",
21260 className: "dataforms-layouts-details__summary-content",
21261 children: [
21262 summaryContent,
21263 touched && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidationBadge, { validity })
21264 ]
21265 }
21266 ) }),
21267 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
21268 "div",
21269 {
21270 ref: contentRef,
21271 className: "dataforms-layouts-details__content",
21272 onBlur: handleBlur,
21273 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
21274 DataFormLayout,
21275 {
21276 data,
21277 form,
21278 onChange,
21279 validity: validity?.children
21280 }
21281 )
21282 }
21283 )
21284 ]
21285 }
21286 );
21287 }
21288
21289 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
21290 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
21291 var FORM_FIELD_LAYOUTS = [
21292 {
21293 type: "regular",
21294 component: FormRegularField,
21295 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21296 Stack,
21297 {
21298 direction: "column",
21299 className: "dataforms-layouts__wrapper",
21300 gap: "lg",
21301 children
21302 }
21303 )
21304 },
21305 {
21306 type: "panel",
21307 component: FormPanelField,
21308 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21309 Stack,
21310 {
21311 direction: "column",
21312 className: "dataforms-layouts__wrapper",
21313 gap: "md",
21314 children
21315 }
21316 )
21317 },
21318 {
21319 type: "card",
21320 component: FormCardField,
21321 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21322 Stack,
21323 {
21324 direction: "column",
21325 className: "dataforms-layouts__wrapper",
21326 gap: "xl",
21327 children
21328 }
21329 )
21330 },
21331 {
21332 type: "row",
21333 component: FormRowField,
21334 wrapper: ({
21335 children,
21336 layout
21337 }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21338 Stack,
21339 {
21340 direction: "column",
21341 className: "dataforms-layouts__wrapper",
21342 gap: "lg",
21343 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
21344 Stack,
21345 {
21346 direction: "row",
21347 gap: "lg",
21348 align: layout.alignment,
21349 children
21350 }
21351 ) })
21352 }
21353 )
21354 },
21355 {
21356 type: "details",
21357 component: FormDetailsField
21358 }
21359 ];
21360 function getFormFieldLayout(type) {
21361 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
21362 }
21363
21364 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
21365 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
21366 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
21367 function DataFormLayout({
21368 data,
21369 form,
21370 onChange,
21371 validity,
21372 children,
21373 as
21374 }) {
21375 const { fields: fieldDefinitions } = (0, import_element87.useContext)(dataform_context_default);
21376 const markWhenOptional = (0, import_element87.useMemo)(() => {
21377 const requiredCount = fieldDefinitions.filter(
21378 (f2) => !!f2.isValid?.required
21379 ).length;
21380 const optionalCount = fieldDefinitions.length - requiredCount;
21381 return requiredCount > optionalCount;
21382 }, [fieldDefinitions]);
21383 function getFieldDefinition2(field) {
21384 return fieldDefinitions.find(
21385 (fieldDefinition) => fieldDefinition.id === field.id
21386 );
21387 }
21388 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
21389 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
21390 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
21391 if (!FieldLayout) {
21392 return null;
21393 }
21394 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
21395 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
21396 return null;
21397 }
21398 if (children) {
21399 return children(
21400 FieldLayout,
21401 formField,
21402 validity?.[formField.id],
21403 markWhenOptional
21404 );
21405 }
21406 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
21407 FieldLayout,
21408 {
21409 data,
21410 field: formField,
21411 onChange,
21412 markWhenOptional,
21413 validity: validity?.[formField.id]
21414 },
21415 formField.id
21416 );
21417 }) });
21418 }
21419
21420 // packages/dataviews/build-module/dataform/index.mjs
21421 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
21422 function DataForm({
21423 data,
21424 form,
21425 fields: fields2,
21426 onChange,
21427 validity
21428 }) {
21429 const normalizedForm = (0, import_element88.useMemo)(() => normalize_form_default(form), [form]);
21430 const normalizedFields = (0, import_element88.useMemo)(
21431 () => normalizeFields(fields2),
21432 [fields2]
21433 );
21434 if (!form.fields) {
21435 return null;
21436 }
21437 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
21438 DataFormLayout,
21439 {
21440 data,
21441 form: normalizedForm,
21442 onChange,
21443 validity
21444 }
21445 ) });
21446 }
21447
21448 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
21449 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
21450 var import_deprecated = __toESM(require_deprecated(), 1);
21451 function normalizeSearchInput2(input = "") {
21452 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
21453 }
21454 var EMPTY_ARRAY7 = [];
21455 function filterSortAndPaginate(data, view, fields2) {
21456 if (!data) {
21457 return {
21458 data: EMPTY_ARRAY7,
21459 paginationInfo: { totalItems: 0, totalPages: 0 }
21460 };
21461 }
21462 const _fields = normalizeFields(fields2);
21463 let filteredData = [...data];
21464 if (view.search) {
21465 const normalizedSearch = normalizeSearchInput2(view.search);
21466 filteredData = filteredData.filter((item) => {
21467 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
21468 const fieldValue = field.getValue({ item });
21469 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
21470 return values.some(
21471 (value) => normalizeSearchInput2(String(value)).includes(
21472 normalizedSearch
21473 )
21474 );
21475 });
21476 });
21477 }
21478 if (view.filters && view.filters?.length > 0) {
21479 view.filters.forEach((filter) => {
21480 const field = _fields.find(
21481 (_field) => _field.id === filter.field
21482 );
21483 if (field) {
21484 if (filter.operator === OPERATOR_IS_NOT_ALL) {
21485 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
21486 since: "7.0",
21487 alternative: "'isNone'"
21488 });
21489 }
21490 const handler = field.filter[filter.operator];
21491 if (handler) {
21492 filteredData = filteredData.filter(
21493 (item) => handler(item, field, filter.value)
21494 );
21495 }
21496 }
21497 });
21498 }
21499 const sortByField = view.sort?.field ? _fields.find((field) => {
21500 return field.enableSorting !== false && field.id === view.sort?.field;
21501 }) : null;
21502 const groupByField = view.groupBy?.field ? _fields.find((field) => {
21503 return field.enableSorting !== false && field.id === view.groupBy?.field;
21504 }) : null;
21505 if (sortByField || groupByField) {
21506 filteredData.sort((a2, b2) => {
21507 if (groupByField) {
21508 const groupCompare = groupByField.sort(
21509 a2,
21510 b2,
21511 view.groupBy?.direction ?? "asc"
21512 );
21513 if (groupCompare !== 0) {
21514 return groupCompare;
21515 }
21516 }
21517 if (sortByField) {
21518 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
21519 }
21520 return 0;
21521 });
21522 }
21523 let totalItems = filteredData.length;
21524 let totalPages = 1;
21525 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
21526 const start = view.startPosition - 1;
21527 const end = Math.min(start + view.perPage, totalItems);
21528 filteredData = filteredData?.slice(start, end);
21529 } else if (view.page !== void 0 && view.perPage !== void 0) {
21530 const start = (view.page - 1) * view.perPage;
21531 totalItems = filteredData?.length || 0;
21532 totalPages = Math.ceil(totalItems / view.perPage);
21533 filteredData = filteredData?.slice(start, start + view.perPage);
21534 }
21535 return {
21536 data: filteredData,
21537 paginationInfo: {
21538 totalItems,
21539 totalPages
21540 }
21541 };
21542 }
21543
21544 // routes/guidelines/components/guideline-accordion-form.tsx
21545 var import_i18n51 = __toESM(require_i18n());
21546 var import_element89 = __toESM(require_element());
21547 var import_data8 = __toESM(require_data());
21548 var import_notices2 = __toESM(require_notices());
21549
21550 // routes/guidelines/store.ts
21551 var import_data6 = __toESM(require_data());
21552 var STORE_NAME = "core/guidelines";
21553 var DEFAULT_STATE = {
21554 id: null,
21555 status: null,
21556 categories: {
21557 site: "",
21558 copy: "",
21559 images: "",
21560 additional: "",
21561 blocks: {}
21562 }
21563 };
21564 var CATEGORIES = ["site", "copy", "images", "additional", "blocks"];
21565 var actions = {
21566 setFromResponse(response) {
21567 return {
21568 type: "SET_FROM_RESPONSE",
21569 response
21570 };
21571 },
21572 setGuideline(category, value) {
21573 return {
21574 type: "SET_GUIDELINE",
21575 category,
21576 value
21577 };
21578 },
21579 setBlockGuideline(blockName, value) {
21580 return {
21581 type: "SET_BLOCK_GUIDELINE",
21582 blockName,
21583 value
21584 };
21585 }
21586 };
21587 function parseResponse(response) {
21588 if (!response || typeof response !== "object") {
21589 return {};
21590 }
21591 const categoriesFromResponse = response.guideline_categories ?? {};
21592 const result = {
21593 id: response.id ?? null,
21594 status: response.status ?? null,
21595 categories: {
21596 site: "",
21597 copy: "",
21598 images: "",
21599 additional: "",
21600 blocks: {}
21601 }
21602 };
21603 CATEGORIES.forEach((category) => {
21604 const guidelines = categoriesFromResponse?.[category]?.guidelines;
21605 if (typeof guidelines === "string") {
21606 result.categories[category] = guidelines;
21607 } else if (category === "blocks") {
21608 const blocks = categoriesFromResponse?.blocks ?? {};
21609 for (const [blockName, blockData] of Object.entries(blocks)) {
21610 result.categories.blocks[blockName] = blockData?.guidelines;
21611 }
21612 }
21613 });
21614 return result;
21615 }
21616 function reducer(state = DEFAULT_STATE, action) {
21617 switch (action.type) {
21618 case "SET_FROM_RESPONSE":
21619 return {
21620 ...state,
21621 ...parseResponse(action.response)
21622 };
21623 case "SET_GUIDELINE":
21624 return {
21625 ...state,
21626 categories: {
21627 ...state.categories,
21628 [action.category]: action.value
21629 }
21630 };
21631 case "SET_BLOCK_GUIDELINE": {
21632 const blocks = {
21633 ...state.categories.blocks,
21634 [action.blockName]: action.value
21635 };
21636 if (action.value === void 0) {
21637 delete blocks[action.blockName];
21638 }
21639 return {
21640 ...state,
21641 categories: {
21642 ...state.categories,
21643 blocks
21644 }
21645 };
21646 }
21647 default:
21648 return state;
21649 }
21650 }
21651 var selectors = {
21652 getGuideline(state, category) {
21653 return state.categories[category];
21654 },
21655 getAllGuidelines(state) {
21656 return state.categories;
21657 },
21658 getBlockGuidelines(state) {
21659 return state.categories.blocks;
21660 },
21661 getBlockGuideline(state, blockName) {
21662 return state.categories.blocks[blockName] ?? "";
21663 },
21664 getId(state) {
21665 return state.id;
21666 },
21667 getStatus(state) {
21668 return state.status;
21669 }
21670 };
21671 var store = (0, import_data6.createReduxStore)(STORE_NAME, {
21672 reducer,
21673 actions,
21674 selectors
21675 });
21676 (0, import_data6.register)(store);
21677
21678 // routes/guidelines/api.ts
21679 var import_api_fetch = __toESM(require_api_fetch());
21680 var import_blob = __toESM(require_blob());
21681 var import_data7 = __toESM(require_data());
21682 var import_i18n50 = __toESM(require_i18n());
21683 var import_notices = __toESM(require_notices());
21684 var FLAT_CATEGORIES = ["site", "copy", "images", "additional"];
21685 function isValidGuidelinesImport(data) {
21686 return !!data && typeof data === "object" && "guideline_categories" in data && typeof data.guideline_categories === "object" && data.guideline_categories !== null;
21687 }
21688 async function fetchGuidelines() {
21689 const { setFromResponse } = (0, import_data7.dispatch)(store);
21690 const response = await (0, import_api_fetch.default)({
21691 path: "/wp/v2/content-guidelines?context=edit"
21692 });
21693 setFromResponse(response);
21694 return response;
21695 }
21696 async function saveGuidelines() {
21697 const { setFromResponse } = (0, import_data7.dispatch)(store);
21698 const guidelinesStore = (0, import_data7.select)(store);
21699 const id = guidelinesStore.getId();
21700 const status = guidelinesStore.getStatus() || "draft";
21701 const categories = guidelinesStore.getAllGuidelines();
21702 const response = await saveGuidelinesBypassingStore(
21703 id,
21704 status,
21705 categories
21706 );
21707 setFromResponse(response);
21708 return response;
21709 }
21710 async function saveGuidelinesBypassingStore(id, status, categories) {
21711 const data = {
21712 id,
21713 status,
21714 guideline_categories: {
21715 site: {
21716 guidelines: categories.site
21717 },
21718 copy: {
21719 guidelines: categories.copy
21720 },
21721 images: {
21722 guidelines: categories.images
21723 },
21724 additional: {
21725 guidelines: categories.additional
21726 },
21727 blocks: Object.fromEntries(
21728 Object.entries(categories.blocks).map(
21729 ([blockName, guidelines]) => [
21730 blockName,
21731 { guidelines }
21732 ]
21733 )
21734 )
21735 }
21736 };
21737 const path = id ? `/wp/v2/content-guidelines/${id}` : "/wp/v2/content-guidelines";
21738 const method = id ? "PUT" : "POST";
21739 const response = await (0, import_api_fetch.default)({
21740 path,
21741 method,
21742 data
21743 });
21744 return response;
21745 }
21746 async function importGuidelines(file) {
21747 const { setFromResponse } = (0, import_data7.dispatch)(store);
21748 const guidelinesStore = (0, import_data7.select)(store);
21749 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
21750 const parsed = JSON.parse(await file.text());
21751 if (!isValidGuidelinesImport(parsed)) {
21752 throw new Error(
21753 (0, import_i18n50.__)(
21754 "Check that your file contains valid JSON markup and try again."
21755 )
21756 );
21757 }
21758 const existingGuidelines = guidelinesStore.getAllGuidelines();
21759 const newGuidelines = {
21760 /**
21761 * Set empty string to all the simple guidelines so that if the category is not present
21762 * in the parsed data, the category gets removed.
21763 */
21764 ...Object.fromEntries(
21765 FLAT_CATEGORIES.map((category) => [category, ""])
21766 ),
21767 /**
21768 * Set empty string to all the existing block guidelines so that if the block is not present
21769 * in the parsed data, the block gets removed.
21770 */
21771 blocks: Object.fromEntries(
21772 Object.keys(existingGuidelines.blocks).map((block) => [
21773 block,
21774 ""
21775 ])
21776 )
21777 };
21778 for (const cat of FLAT_CATEGORIES) {
21779 const guidelines = parsed.guideline_categories[cat]?.guidelines || "";
21780 newGuidelines[cat] = guidelines;
21781 }
21782 const parsedBlocks = parsed.guideline_categories?.blocks ?? {};
21783 for (const [key, value] of Object.entries(parsedBlocks)) {
21784 newGuidelines.blocks[key] = value?.guidelines || "";
21785 }
21786 const response = await saveGuidelinesBypassingStore(
21787 guidelinesStore.getId(),
21788 guidelinesStore.getStatus() || "draft",
21789 newGuidelines
21790 );
21791 setFromResponse(response);
21792 createSuccessNotice((0, import_i18n50.__)("Guidelines imported."), {
21793 type: "snackbar"
21794 });
21795 }
21796 function exportGuidelines() {
21797 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
21798 const guidelinesStore = (0, import_data7.select)(store);
21799 const guidelinesCategories = guidelinesStore.getAllGuidelines();
21800 const blockGuidelines = guidelinesStore.getBlockGuidelines();
21801 const data = {
21802 guideline_categories: {
21803 ...Object.fromEntries(
21804 FLAT_CATEGORIES.map((guidelineCategory) => [
21805 guidelineCategory,
21806 {
21807 guidelines: guidelinesCategories[guidelineCategory] ?? ""
21808 }
21809 ])
21810 ),
21811 blocks: Object.fromEntries(
21812 Object.entries(blockGuidelines).map(
21813 ([blockName, guidelines]) => [
21814 blockName,
21815 { guidelines }
21816 ]
21817 )
21818 )
21819 }
21820 };
21821 const now = /* @__PURE__ */ new Date();
21822 const exportDate = [
21823 now.getFullYear(),
21824 String(now.getMonth() + 1).padStart(2, "0"),
21825 String(now.getDate()).padStart(2, "0")
21826 ].join("-");
21827 (0, import_blob.downloadBlob)(
21828 `guidelines-${exportDate}.json`,
21829 JSON.stringify(data, null, 2),
21830 "application/json"
21831 );
21832 createSuccessNotice((0, import_i18n50.__)("Guidelines exported."), {
21833 type: "snackbar"
21834 });
21835 }
21836 async function fetchGuidelinesRevisions({
21837 guidelinesId,
21838 page = 1,
21839 perPage = 10,
21840 search
21841 }) {
21842 const params = new URLSearchParams({
21843 page: String(page),
21844 per_page: String(perPage),
21845 _embed: "author",
21846 ...search ? { search } : {}
21847 });
21848 const response = await (0, import_api_fetch.default)({
21849 path: `/wp/v2/content-guidelines/${guidelinesId}/revisions?${params}`,
21850 parse: false
21851 });
21852 const revisions = await response.json();
21853 const total = parseInt(response.headers.get("X-WP-Total") ?? "0", 10);
21854 const totalPages = parseInt(
21855 response.headers.get("X-WP-TotalPages") ?? "0",
21856 10
21857 );
21858 return { revisions, total, totalPages };
21859 }
21860 async function restoreGuidelinesRevision(guidelinesId, revisionId) {
21861 return await (0, import_api_fetch.default)({
21862 path: `/wp/v2/content-guidelines/${guidelinesId}/revisions/${revisionId}/restore`,
21863 method: "POST"
21864 });
21865 }
21866
21867 // routes/guidelines/components/guideline-accordion-form.tsx
21868 function GuidelineAccordionForm({
21869 slug,
21870 contentId,
21871 headingId,
21872 descriptionId
21873 }) {
21874 const { setGuideline } = (0, import_data8.useDispatch)(store);
21875 const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices2.store);
21876 const [loading, setLoading] = (0, import_element89.useState)(false);
21877 const [error2, setError] = (0, import_element89.useState)(null);
21878 const [showClearConfirmation, setShowClearConfirmation] = (0, import_element89.useState)(false);
21879 const { value } = (0, import_data8.useSelect)(
21880 (select2) => ({
21881 value: select2(store).getGuideline(slug)
21882 }),
21883 [slug]
21884 );
21885 const [draft, setDraft] = (0, import_element89.useState)(value);
21886 (0, import_element89.useEffect)(() => setDraft(value), [value]);
21887 const data = (0, import_element89.useMemo)(() => ({ guidelines: draft }), [draft]);
21888 const fields2 = (0, import_element89.useMemo)(
21889 () => [
21890 {
21891 id: "guidelines",
21892 label: (0, import_i18n51.sprintf)(
21893 /* translators: %s: Guideline category. */
21894 (0, import_i18n51.__)("%s guidelines"),
21895 slug
21896 ),
21897 type: "text",
21898 Edit: "textarea"
21899 }
21900 ],
21901 [slug]
21902 );
21903 const form = (0, import_element89.useMemo)(
21904 () => ({
21905 layout: { type: "regular", labelPosition: "none" },
21906 fields: ["guidelines"]
21907 }),
21908 []
21909 );
21910 const handleSave = (event) => {
21911 event.preventDefault();
21912 setGuideline(slug, draft);
21913 setLoading(true);
21914 saveGuidelines().then(() => {
21915 setError(null);
21916 createSuccessNotice((0, import_i18n51.__)("Guidelines saved."), {
21917 type: "snackbar"
21918 });
21919 }).catch(
21920 (e2) => setError(
21921 (0, import_i18n51.sprintf)(
21922 /* translators: %s: Error message. */
21923 (0, import_i18n51.__)("Error saving guidelines: %s"),
21924 e2.message
21925 )
21926 )
21927 ).finally(() => setLoading(false));
21928 };
21929 const handleClearClick = () => setShowClearConfirmation(true);
21930 const handleClearConfirm = () => {
21931 const oldValue = draft;
21932 setGuideline(slug, "");
21933 setLoading(true);
21934 saveGuidelines().then(() => {
21935 setError(null);
21936 createSuccessNotice((0, import_i18n51.__)("Guidelines cleared."), {
21937 type: "snackbar"
21938 });
21939 }).catch((e2) => {
21940 setError(
21941 (0, import_i18n51.sprintf)(
21942 /* translators: %s: Error message. */
21943 (0, import_i18n51.__)("Error clearing guidelines: %s"),
21944 e2.message
21945 )
21946 );
21947 setGuideline(slug, oldValue);
21948 }).finally(() => {
21949 setLoading(false);
21950 setShowClearConfirmation(false);
21951 });
21952 };
21953 return /* @__PURE__ */ React.createElement(
21954 "form",
21955 {
21956 id: contentId,
21957 "aria-labelledby": headingId,
21958 "aria-describedby": descriptionId,
21959 onSubmit: handleSave,
21960 className: "guidelines__accordion-form"
21961 },
21962 /* @__PURE__ */ React.createElement(import_components53.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(
21963 DataForm,
21964 {
21965 data,
21966 fields: fields2,
21967 form,
21968 onChange: (edits) => setDraft(edits.guidelines ?? draft)
21969 }
21970 ), error2 && /* @__PURE__ */ React.createElement(import_components53.Notice, { status: "error", onRemove: () => setError(null) }, error2), /* @__PURE__ */ React.createElement(import_components53.__experimentalHStack, { spacing: 4, alignment: "left" }, /* @__PURE__ */ React.createElement(
21971 import_components53.Button,
21972 {
21973 variant: "primary",
21974 type: "submit",
21975 disabled: loading || !draft,
21976 accessibleWhenDisabled: true,
21977 isBusy: loading
21978 },
21979 (0, import_i18n51.__)("Save guidelines")
21980 ), /* @__PURE__ */ React.createElement(
21981 import_components53.Button,
21982 {
21983 variant: "tertiary",
21984 type: "button",
21985 disabled: loading || !value,
21986 accessibleWhenDisabled: true,
21987 isBusy: loading,
21988 onClick: handleClearClick
21989 },
21990 (0, import_i18n51.__)("Clear guidelines")
21991 ))),
21992 /* @__PURE__ */ React.createElement(
21993 import_components53.__experimentalConfirmDialog,
21994 {
21995 isOpen: showClearConfirmation,
21996 title: (0, import_i18n51.sprintf)(
21997 /* translators: %s: Guideline category. */
21998 (0, import_i18n51.__)("Clear %s guidelines"),
21999 slug
22000 ),
22001 __experimentalHideHeader: false,
22002 onConfirm: handleClearConfirm,
22003 onCancel: () => setShowClearConfirmation(false),
22004 confirmButtonText: (0, import_i18n51.__)("Clear guidelines"),
22005 isBusy: loading,
22006 size: "small"
22007 },
22008 (0, import_i18n51.sprintf)(
22009 /* translators: %s: Guideline category slug. */
22010 (0, import_i18n51.__)(
22011 "You are about to clear the %s guidelines. This can be undone from revision history."
22012 ),
22013 slug
22014 )
22015 )
22016 );
22017 }
22018
22019 // routes/guidelines/components/block-guidelines.tsx
22020 var import_components55 = __toESM(require_components());
22021 var import_i18n53 = __toESM(require_i18n());
22022 var import_element91 = __toESM(require_element());
22023 var import_data10 = __toESM(require_data());
22024 var import_blocks2 = __toESM(require_blocks());
22025 var import_notices4 = __toESM(require_notices());
22026
22027 // routes/guidelines/components/block-guideline-modal.tsx
22028 var import_components54 = __toESM(require_components());
22029 var import_i18n52 = __toESM(require_i18n());
22030 var import_element90 = __toESM(require_element());
22031 var import_data9 = __toESM(require_data());
22032 var import_blocks = __toESM(require_blocks());
22033 var import_notices3 = __toESM(require_notices());
22034
22035 // routes/lock-unlock.ts
22036 var import_private_apis2 = __toESM(require_private_apis());
22037 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
22038 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
22039 "@wordpress/routes"
22040 );
22041
22042 // routes/guidelines/components/block-guideline-modal.scss
22043 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='7c0ecac6c9']")) {
22044 const style = document.createElement("style");
22045 style.setAttribute("data-wp-hash", "7c0ecac6c9");
22046 style.appendChild(document.createTextNode(".block-guideline-modal{width:min(100%,660px)}.block-guideline-modal__actions{margin-top:8px}"));
22047 document.head.appendChild(style);
22048 }
22049
22050 // routes/guidelines/components/block-guideline-modal.tsx
22051 var { isContentBlock } = unlock2(import_blocks.privateApis);
22052 function BlockGuidelineModal({
22053 closeModal,
22054 initialBlock
22055 }) {
22056 const [selectedBlock, setSelectedBlock] = (0, import_element90.useState)(
22057 initialBlock
22058 );
22059 const [isSaving, setIsSaving] = (0, import_element90.useState)(false);
22060 const [error2, setError] = (0, import_element90.useState)(null);
22061 const [showRemoveConfirmation, setShowRemoveConfirmation] = (0, import_element90.useState)(false);
22062 const blockGuidelines = (0, import_data9.useSelect)(
22063 (select2) => select2(store).getBlockGuidelines(),
22064 []
22065 );
22066 const isEditing = !!initialBlock;
22067 const currentGuideline = blockGuidelines[selectedBlock] ?? "";
22068 const [guidelineText, setGuidelineText] = (0, import_element90.useState)(currentGuideline);
22069 const blockOptions = (0, import_data9.useSelect)(
22070 // @ts-ignore
22071 (select2) => select2(import_blocks.store).getBlockTypes(),
22072 []
22073 );
22074 const availableBlockOptions = (0, import_element90.useMemo)(() => {
22075 const set3 = new Set(Object.keys(blockGuidelines));
22076 if (initialBlock) {
22077 set3.delete(initialBlock);
22078 }
22079 if (selectedBlock) {
22080 set3.delete(selectedBlock);
22081 }
22082 return blockOptions.filter(
22083 (block) => isContentBlock(block.name) && !set3.has(block.name)
22084 ).map((block) => ({
22085 value: block.name,
22086 label: block.title
22087 }));
22088 }, [blockGuidelines, blockOptions, initialBlock, selectedBlock]);
22089 const selectedBlockLabel = (0, import_element90.useMemo)(
22090 () => blockOptions.find((block) => block.name === selectedBlock)?.title || "",
22091 [blockOptions, selectedBlock]
22092 );
22093 const { setBlockGuideline } = (0, import_data9.useDispatch)(store);
22094 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices3.store);
22095 const handleSave = (value) => {
22096 value = value.trim();
22097 if (!selectedBlock) {
22098 return;
22099 }
22100 setIsSaving(true);
22101 const oldValue = blockGuidelines[selectedBlock];
22102 setBlockGuideline(selectedBlock, value);
22103 saveGuidelines().then(() => {
22104 setError(null);
22105 createSuccessNotice(
22106 value ? (0, import_i18n52.__)("Guidelines saved.") : (0, import_i18n52.__)("Guidelines removed."),
22107 { type: "snackbar" }
22108 );
22109 closeModal();
22110 }).catch((e2) => {
22111 setError(e2.message);
22112 setBlockGuideline(selectedBlock, oldValue);
22113 }).finally(() => setIsSaving(false));
22114 };
22115 const canSubmit = selectedBlock && guidelineText.trim().length > 0;
22116 let submitButtonLabel = (0, import_i18n52.__)("Save guidelines");
22117 if (isSaving) {
22118 submitButtonLabel = (0, import_i18n52.__)("Saving\u2026");
22119 }
22120 return /* @__PURE__ */ React.createElement(
22121 import_components54.Modal,
22122 {
22123 className: "block-guideline-modal",
22124 title: isEditing ? (0, import_i18n52.__)("Edit guidelines") : (0, import_i18n52.__)("Add guidelines"),
22125 onRequestClose: closeModal
22126 },
22127 /* @__PURE__ */ React.createElement(import_components54.__experimentalVStack, { spacing: 4 }, isEditing ? /* @__PURE__ */ React.createElement(
22128 import_components54.TextControl,
22129 {
22130 __next40pxDefaultSize: true,
22131 label: (0, import_i18n52.__)("Block"),
22132 value: selectedBlockLabel,
22133 onChange: () => {
22134 },
22135 disabled: true
22136 }
22137 ) : /* @__PURE__ */ React.createElement(
22138 import_components54.ComboboxControl,
22139 {
22140 __next40pxDefaultSize: true,
22141 label: (0, import_i18n52.__)("Block"),
22142 options: availableBlockOptions,
22143 value: selectedBlock,
22144 onChange: (value) => setSelectedBlock(value ?? void 0),
22145 placeholder: (0, import_i18n52.__)("Search for a block\u2026")
22146 }
22147 ), /* @__PURE__ */ React.createElement(
22148 import_components54.TextareaControl,
22149 {
22150 label: (0, import_i18n52.__)("Guideline text"),
22151 value: guidelineText,
22152 onChange: setGuidelineText,
22153 placeholder: (0, import_i18n52.__)(
22154 "Enter guidelines for how this block should be used\u2026"
22155 ),
22156 rows: 6
22157 }
22158 ), error2 && /* @__PURE__ */ React.createElement(import_components54.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n52.sprintf)(
22159 /* translators: %s: Error message. */
22160 (0, import_i18n52.__)("Error: %s"),
22161 error2
22162 )), /* @__PURE__ */ React.createElement(
22163 import_components54.__experimentalHStack,
22164 {
22165 justify: "flex-end",
22166 spacing: 2,
22167 className: "block-guideline-modal__actions"
22168 },
22169 isEditing && /* @__PURE__ */ React.createElement(
22170 import_components54.Button,
22171 {
22172 variant: "tertiary",
22173 isDestructive: true,
22174 onClick: () => setShowRemoveConfirmation(true),
22175 disabled: isSaving,
22176 accessibleWhenDisabled: true,
22177 type: "button"
22178 },
22179 (0, import_i18n52.__)("Remove")
22180 ),
22181 /* @__PURE__ */ React.createElement(
22182 import_components54.Button,
22183 {
22184 variant: "primary",
22185 onClick: () => handleSave(guidelineText),
22186 disabled: !canSubmit || isSaving,
22187 isBusy: isSaving,
22188 accessibleWhenDisabled: true
22189 },
22190 submitButtonLabel
22191 )
22192 )),
22193 /* @__PURE__ */ React.createElement(
22194 import_components54.__experimentalConfirmDialog,
22195 {
22196 isOpen: showRemoveConfirmation,
22197 title: (0, import_i18n52.__)("Remove block guidelines"),
22198 __experimentalHideHeader: false,
22199 onConfirm: () => {
22200 handleSave("");
22201 setShowRemoveConfirmation(false);
22202 },
22203 onCancel: () => setShowRemoveConfirmation(false),
22204 confirmButtonText: (0, import_i18n52.__)("Remove"),
22205 isBusy: isSaving,
22206 size: "small"
22207 },
22208 (0, import_i18n52.sprintf)(
22209 /* translators: %s: Block name. */
22210 (0, import_i18n52.__)(
22211 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
22212 ),
22213 selectedBlockLabel
22214 )
22215 )
22216 );
22217 }
22218
22219 // routes/guidelines/components/block-guidelines.scss
22220 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='ac1d1fe86c']")) {
22221 const style = document.createElement("style");
22222 style.setAttribute("data-wp-hash", "ac1d1fe86c");
22223 style.appendChild(document.createTextNode(".block-guidelines{margin-top:24px}.block-guidelines .block-guidelines__icon{align-items:center;display:flex;height:100%;justify-content:center;width:100%}.block-guidelines .dataviews-view-list__field-wrapper{display:flex;justify-content:center}.block-guidelines .dataviews-wrapper{margin-left:-24px;margin-right:-24px}.block-guidelines .dataviews-search{margin-left:24px;margin-right:24px}"));
22224 document.head.appendChild(style);
22225 }
22226
22227 // routes/guidelines/components/block-guidelines.tsx
22228 var PER_PAGE = 5;
22229 var initialView = {
22230 type: "list",
22231 search: "",
22232 page: 1,
22233 perPage: PER_PAGE,
22234 filters: [],
22235 mediaField: "icon",
22236 showMedia: true,
22237 titleField: "label",
22238 layout: {
22239 density: "compact"
22240 }
22241 };
22242 var fields = [
22243 {
22244 id: "icon",
22245 label: (0, import_i18n53.__)("Icon"),
22246 type: "media",
22247 render: ({ item }) => /* @__PURE__ */ React.createElement("div", { className: "block-guidelines__icon" }, /* @__PURE__ */ React.createElement(import_components55.Icon, { icon: item.icon ?? block_default_default, size: 16 }))
22248 },
22249 {
22250 id: "label",
22251 label: (0, import_i18n53.__)("Label"),
22252 type: "text",
22253 enableGlobalSearch: true,
22254 getValue: ({ item }) => item.label,
22255 render: ({ item }) => item.label
22256 }
22257 ];
22258 function BlockGuidelines() {
22259 const [isOpen, setIsOpen] = (0, import_element91.useState)(false);
22260 const [view, setView] = (0, import_element91.useState)(initialView);
22261 const [selectedItem, setSelectedItem] = (0, import_element91.useState)();
22262 const [error2, setError] = (0, import_element91.useState)(null);
22263 const [busy, setBusy] = (0, import_element91.useState)(false);
22264 const [itemToDelete, setItemToDelete] = (0, import_element91.useState)(
22265 null
22266 );
22267 const { createSuccessNotice } = (0, import_data10.useDispatch)(import_notices4.store);
22268 const blockGuidelines = (0, import_data10.useSelect)(
22269 (select2) => select2(store).getBlockGuidelines(),
22270 []
22271 );
22272 const blockTypes = (0, import_data10.useSelect)(
22273 // @ts-ignore
22274 (select2) => select2(import_blocks2.store).getBlockTypes(),
22275 []
22276 );
22277 const rows = (0, import_element91.useMemo)(
22278 () => blockTypes.filter((blockType) => blockGuidelines[blockType.name]).map((blockType) => ({
22279 id: blockType.name,
22280 label: blockType.title,
22281 guidelines: blockGuidelines[blockType.name] ?? "",
22282 icon: blockType.icon?.src
22283 })),
22284 [blockGuidelines, blockTypes]
22285 );
22286 const { setBlockGuideline } = (0, import_data10.useDispatch)(store);
22287 const handleRowClick = (id) => {
22288 setSelectedItem(id);
22289 setIsOpen(true);
22290 };
22291 const actions2 = (0, import_element91.useMemo)(
22292 () => [
22293 {
22294 id: "edit",
22295 label: (0, import_i18n53.__)("Edit"),
22296 callback: (items) => {
22297 const item = items[0];
22298 handleRowClick(item.id);
22299 }
22300 },
22301 {
22302 id: "remove",
22303 label: (0, import_i18n53.__)("Remove"),
22304 callback: (items) => {
22305 const item = items[0];
22306 setItemToDelete(item);
22307 }
22308 }
22309 ],
22310 [setItemToDelete]
22311 );
22312 const handleDelete = () => {
22313 if (!itemToDelete) {
22314 return;
22315 }
22316 const oldValue = blockGuidelines[itemToDelete.id];
22317 setBlockGuideline(itemToDelete.id, "");
22318 setBusy(true);
22319 saveGuidelines().then(() => {
22320 setError(null);
22321 createSuccessNotice((0, import_i18n53.__)("Guidelines removed."), {
22322 type: "snackbar"
22323 });
22324 }).catch((e2) => {
22325 setError(e2.message);
22326 setBlockGuideline(itemToDelete.id, oldValue);
22327 }).finally(() => {
22328 setBusy(false);
22329 setItemToDelete(null);
22330 });
22331 };
22332 const { data: processedData, paginationInfo } = (0, import_element91.useMemo)(
22333 () => filterSortAndPaginate(rows, view, fields),
22334 [rows, view]
22335 );
22336 (0, import_element91.useEffect)(() => {
22337 const lastPage = Math.max(paginationInfo.totalPages, 1);
22338 if (view.page && view.page > lastPage) {
22339 setView(
22340 (currentView) => currentView.page && currentView.page > lastPage ? {
22341 ...currentView,
22342 page: lastPage
22343 } : currentView
22344 );
22345 }
22346 }, [paginationInfo.totalPages, view.page]);
22347 const closeModal = () => {
22348 setIsOpen(false);
22349 setSelectedItem(void 0);
22350 };
22351 const openModal = () => {
22352 setSelectedItem(void 0);
22353 setIsOpen(true);
22354 };
22355 const shouldShowDataViewControls = rows.length > PER_PAGE;
22356 return /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4, className: "block-guidelines" }, error2 && /* @__PURE__ */ React.createElement(import_components55.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n53.sprintf)(
22357 /* translators: %s: Error message. */
22358 (0, import_i18n53.__)("Error: %s"),
22359 error2
22360 )), rows.length > 0 && /* @__PURE__ */ React.createElement(
22361 dataviews_default,
22362 {
22363 paginationInfo,
22364 data: processedData,
22365 view,
22366 onChangeView: setView,
22367 fields,
22368 actions: actions2,
22369 config: { perPageSizes: [PER_PAGE] },
22370 onChangeSelection: (items) => {
22371 const id = items[0];
22372 handleRowClick(id);
22373 },
22374 defaultLayouts: {
22375 list: true
22376 }
22377 },
22378 /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4 }, shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Search, { label: (0, import_i18n53.__)("Search blocks") }), /* @__PURE__ */ React.createElement(dataviews_default.Layout, null), shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Footer, null))
22379 ), /* @__PURE__ */ React.createElement(import_components55.__experimentalHStack, null, /* @__PURE__ */ React.createElement(import_components55.Button, { variant: "primary", onClick: openModal }, (0, import_i18n53.__)("Add guidelines"))), isOpen && /* @__PURE__ */ React.createElement(
22380 BlockGuidelineModal,
22381 {
22382 closeModal,
22383 initialBlock: selectedItem
22384 }
22385 ), /* @__PURE__ */ React.createElement(
22386 import_components55.__experimentalConfirmDialog,
22387 {
22388 isOpen: !!itemToDelete,
22389 title: (0, import_i18n53.__)("Remove block guidelines"),
22390 __experimentalHideHeader: false,
22391 onConfirm: handleDelete,
22392 onCancel: () => setItemToDelete(null),
22393 confirmButtonText: (0, import_i18n53.__)("Remove"),
22394 isBusy: busy,
22395 size: "small"
22396 },
22397 (0, import_i18n53.sprintf)(
22398 /* translators: %s: Block name. */
22399 (0, import_i18n53.__)(
22400 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
22401 ),
22402 itemToDelete?.label ?? ""
22403 )
22404 ));
22405 }
22406
22407 // routes/guidelines/components/guideline-actions-section.tsx
22408 var import_components57 = __toESM(require_components());
22409 var import_i18n54 = __toESM(require_i18n());
22410 var import_element92 = __toESM(require_element());
22411
22412 // routes/guidelines/components/guideline-actions-section.scss
22413 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='9e2a8265d8']")) {
22414 const style = document.createElement("style");
22415 style.setAttribute("data-wp-hash", "9e2a8265d8");
22416 style.appendChild(document.createTextNode('.guidelines__actions{margin:16px auto 0;width:min(680px,100%)}.guidelines__actions-card{overflow:hidden;padding:0}.guidelines__actions-list{list-style:none;margin:0;padding:0}.guidelines__action-list-item{margin-bottom:0;position:relative}.guidelines__action-list-item:not(:first-child):before{background-color:#f0f0f0;content:"";height:1px;left:24px;position:absolute;right:24px;top:0}.guidelines__action-row{align-items:center;box-sizing:border-box;padding:16px 24px;width:100%}.guidelines__actions-card .guidelines__action-button{font-size:13px;font-weight:400;justify-content:center;min-width:100px}.guidelines__action-title{color:#1e1e1e}.guidelines__action-description{color:#757575}'));
22417 document.head.appendChild(style);
22418 }
22419
22420 // routes/guidelines/components/action-item.tsx
22421 var import_components56 = __toESM(require_components());
22422 function ActionItem({
22423 slug,
22424 title,
22425 description,
22426 buttonLabel,
22427 ariaLabel,
22428 onClick,
22429 disabled: disabled2,
22430 isBusy
22431 }) {
22432 const descriptionId = `guidelines-action-${slug}-description`;
22433 return /* @__PURE__ */ React.createElement(import_components56.__experimentalHStack, { justify: "space-between", className: "guidelines__action-row" }, /* @__PURE__ */ React.createElement(import_components56.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(
22434 import_components56.__experimentalHeading,
22435 {
22436 level: 3,
22437 size: 13,
22438 weight: 400,
22439 className: "guidelines__action-title"
22440 },
22441 title
22442 ), /* @__PURE__ */ React.createElement(
22443 import_components56.__experimentalText,
22444 {
22445 id: descriptionId,
22446 size: 13,
22447 weight: 400,
22448 variant: "muted",
22449 className: "guidelines__action-description"
22450 },
22451 description
22452 )), /* @__PURE__ */ React.createElement(
22453 import_components56.Button,
22454 {
22455 size: "compact",
22456 variant: "secondary",
22457 className: "guidelines__action-button",
22458 "aria-label": ariaLabel,
22459 "aria-describedby": descriptionId,
22460 onClick,
22461 isBusy,
22462 disabled: disabled2
22463 },
22464 buttonLabel
22465 ));
22466 }
22467
22468 // routes/guidelines/components/guideline-actions-section.tsx
22469 function getErrorMessage(err) {
22470 return err instanceof Error ? err.message : (0, import_i18n54.__)("Unknown error");
22471 }
22472 function GuidelineActionsSection() {
22473 const { goTo } = (0, import_components57.useNavigator)();
22474 const fileInputRef = (0, import_element92.useRef)(null);
22475 const [isImporting, setIsImporting] = (0, import_element92.useState)(false);
22476 const [error2, setError] = (0, import_element92.useState)(null);
22477 const [pendingImport, setPendingImport] = (0, import_element92.useState)(null);
22478 function handleImportClick() {
22479 fileInputRef.current?.click();
22480 }
22481 function handleFileChange(event) {
22482 const file = event.target.files?.[0];
22483 event.target.value = "";
22484 if (!file) {
22485 return;
22486 }
22487 setPendingImport(file);
22488 }
22489 async function handleModalContinue() {
22490 if (!pendingImport) {
22491 return;
22492 }
22493 const file = pendingImport;
22494 setPendingImport(null);
22495 setIsImporting(true);
22496 try {
22497 await importGuidelines(file);
22498 setError(null);
22499 } catch (err) {
22500 setError(
22501 (0, import_i18n54.sprintf)(
22502 /* translators: %s: Error message. */
22503 (0, import_i18n54.__)("We ran into a problem importing your guidelines: %s"),
22504 getErrorMessage(err)
22505 )
22506 );
22507 } finally {
22508 setIsImporting(false);
22509 }
22510 }
22511 async function handleExportClick() {
22512 try {
22513 exportGuidelines();
22514 setError(null);
22515 } catch (err) {
22516 setError(
22517 (0, import_i18n54.sprintf)(
22518 /* translators: %s: Error message. */
22519 (0, import_i18n54.__)("We ran into a problem exporting your guidelines: %s"),
22520 getErrorMessage(err)
22521 )
22522 );
22523 }
22524 }
22525 function navigateToRevisionHistory() {
22526 if (window?.location?.href) {
22527 const url = new URL(window.location.href);
22528 url.searchParams.set("view", "revision-history");
22529 window.history.replaceState({}, "", url.toString());
22530 }
22531 goTo("/revision-history");
22532 }
22533 const ACTIONS = [
22534 {
22535 slug: "import",
22536 title: (0, import_i18n54.__)("Import"),
22537 description: (0, import_i18n54.__)("Upload a JSON file to import your guidelines."),
22538 buttonLabel: (0, import_i18n54.__)("Upload"),
22539 ariaLabel: (0, import_i18n54.__)("Import guidelines"),
22540 onClick: handleImportClick,
22541 isBusy: isImporting,
22542 disabled: isImporting || !!pendingImport
22543 },
22544 {
22545 slug: "export",
22546 title: (0, import_i18n54.__)("Export"),
22547 description: (0, import_i18n54.__)("Export your guidelines to a JSON file."),
22548 buttonLabel: (0, import_i18n54.__)("Download"),
22549 ariaLabel: (0, import_i18n54.__)("Export guidelines"),
22550 onClick: handleExportClick
22551 },
22552 {
22553 slug: "revert",
22554 title: (0, import_i18n54.__)("Revert"),
22555 description: (0, import_i18n54.__)("Use a previous version of your guidelines."),
22556 buttonLabel: (0, import_i18n54.__)("View history"),
22557 ariaLabel: (0, import_i18n54.__)("View history of guidelines"),
22558 onClick: navigateToRevisionHistory
22559 }
22560 ];
22561 return /* @__PURE__ */ React.createElement(import_components57.__experimentalVStack, { spacing: 4, className: "guidelines__actions" }, /* @__PURE__ */ React.createElement(import_components57.__experimentalHeading, { level: 3, size: 15, weight: 500 }, (0, import_i18n54.__)("Actions")), /* @__PURE__ */ React.createElement(
22562 "input",
22563 {
22564 type: "file",
22565 accept: ".json",
22566 ref: fileInputRef,
22567 onChange: handleFileChange,
22568 style: { display: "none" }
22569 }
22570 ), error2 && /* @__PURE__ */ React.createElement(
22571 import_components57.Notice,
22572 {
22573 status: "error",
22574 onRemove: () => setError(null),
22575 isDismissible: true
22576 },
22577 error2
22578 ), /* @__PURE__ */ React.createElement(import_components57.Card, { className: "guidelines__actions-card" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__actions-list" }, ACTIONS.map((action) => /* @__PURE__ */ React.createElement(
22579 "li",
22580 {
22581 key: action.slug,
22582 className: "guidelines__action-list-item"
22583 },
22584 /* @__PURE__ */ React.createElement(ActionItem, { ...action })
22585 )))), /* @__PURE__ */ React.createElement(
22586 import_components57.__experimentalConfirmDialog,
22587 {
22588 isOpen: !!pendingImport,
22589 __experimentalHideHeader: false,
22590 title: (0, import_i18n54.__)("Import guidelines"),
22591 confirmButtonText: (0, import_i18n54.__)("Continue"),
22592 onConfirm: handleModalContinue,
22593 onCancel: () => setPendingImport(null),
22594 size: "small"
22595 },
22596 (0, import_i18n54.__)(
22597 "Importing new guidelines will replace your current guidelines. This can be undone from revision history."
22598 )
22599 ));
22600 }
22601
22602 // routes/guidelines/components/revision-history.tsx
22603 var import_components58 = __toESM(require_components());
22604 var import_i18n55 = __toESM(require_i18n());
22605 var import_element93 = __toESM(require_element());
22606 var import_data11 = __toESM(require_data());
22607 var import_date10 = __toESM(require_date());
22608 var import_notices5 = __toESM(require_notices());
22609 var DEFAULT_VIEW = {
22610 type: "table",
22611 fields: ["date", "author"],
22612 page: 1,
22613 perPage: 10,
22614 layout: {
22615 enableMoving: false
22616 }
22617 };
22618 function RevisionHistory() {
22619 const [view, setView] = (0, import_element93.useState)(DEFAULT_VIEW);
22620 const [revisions, setRevisions] = (0, import_element93.useState)([]);
22621 const [isLoading, setIsLoading] = (0, import_element93.useState)(false);
22622 const [revisionToRestore, setRevisionToRestore] = (0, import_element93.useState)(null);
22623 const [isRestoring, setIsRestoring] = (0, import_element93.useState)(false);
22624 const { createSuccessNotice, createErrorNotice } = (0, import_data11.useDispatch)(import_notices5.store);
22625 const guidelinesId = (0, import_data11.useSelect)(
22626 (select2) => select2(store).getId(),
22627 []
22628 );
22629 const loadRevisions = (0, import_element93.useCallback)(async () => {
22630 if (!guidelinesId) {
22631 return;
22632 }
22633 setIsLoading(true);
22634 try {
22635 const result = await fetchGuidelinesRevisions({
22636 guidelinesId,
22637 page: 1,
22638 perPage: 100
22639 });
22640 setRevisions(result.revisions);
22641 } catch {
22642 createErrorNotice(
22643 (0, import_i18n55.__)("Could not load revision history. Please try again."),
22644 { type: "snackbar" }
22645 );
22646 } finally {
22647 setIsLoading(false);
22648 }
22649 }, [guidelinesId, createErrorNotice]);
22650 (0, import_element93.useEffect)(() => {
22651 loadRevisions();
22652 }, [loadRevisions]);
22653 const authorElements = (0, import_element93.useMemo)(() => {
22654 return [
22655 ...new Set(
22656 revisions.map(
22657 (r3) => r3._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown")
22658 )
22659 )
22660 ].map((name) => ({ value: name, label: name }));
22661 }, [revisions]);
22662 const fields2 = (0, import_element93.useMemo)(
22663 () => [
22664 {
22665 id: "date",
22666 type: "date",
22667 label: (0, import_i18n55.__)("Date"),
22668 getValue: ({ item }) => item.date,
22669 render: ({ item }) => /* @__PURE__ */ React.createElement("time", { dateTime: item.date }, (0, import_date10.dateI18n)(
22670 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
22671 (0, import_date10.getDate)(item.date)
22672 )),
22673 enableSorting: false,
22674 enableHiding: false,
22675 filterBy: {
22676 operators: ["before", "after", "between", "inThePast"]
22677 }
22678 },
22679 {
22680 id: "author",
22681 label: (0, import_i18n55.__)("User"),
22682 getValue: ({ item }) => item._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown"),
22683 render: ({ item }) => /* @__PURE__ */ React.createElement("span", null, item._embedded?.author?.[0]?.name ?? (0, import_i18n55.__)("Unknown")),
22684 enableSorting: false,
22685 enableHiding: false,
22686 enableGlobalSearch: true,
22687 elements: authorElements,
22688 filterBy: {
22689 operators: ["isAny", "isNone"]
22690 }
22691 }
22692 ],
22693 [authorElements]
22694 );
22695 const actions2 = (0, import_element93.useMemo)(
22696 () => [
22697 {
22698 id: "restore-revision",
22699 label: (0, import_i18n55.__)("Restore"),
22700 callback: (items) => setRevisionToRestore(items[0])
22701 }
22702 ],
22703 [setRevisionToRestore]
22704 );
22705 const { data: displayedRevisions, paginationInfo: paginationToShow } = (0, import_element93.useMemo)(
22706 () => filterSortAndPaginate(revisions, view, fields2),
22707 [revisions, view, fields2]
22708 );
22709 async function handleRestore() {
22710 if (!guidelinesId || !revisionToRestore) {
22711 return;
22712 }
22713 setIsRestoring(true);
22714 try {
22715 await restoreGuidelinesRevision(
22716 guidelinesId,
22717 revisionToRestore.id
22718 );
22719 await fetchGuidelines();
22720 setRevisionToRestore(null);
22721 await loadRevisions();
22722 createSuccessNotice((0, import_i18n55.__)("Revision restored."), {
22723 type: "snackbar"
22724 });
22725 } catch {
22726 createErrorNotice(
22727 (0, import_i18n55.__)("Could not restore revision. Please try again."),
22728 { type: "snackbar" }
22729 );
22730 } finally {
22731 setIsRestoring(false);
22732 }
22733 }
22734 const navigateToGuidelines = () => {
22735 if (window?.location?.href) {
22736 const url = new URL(window.location.href);
22737 url.searchParams.delete("view");
22738 window.history.replaceState({}, "", url.toString());
22739 }
22740 };
22741 return /* @__PURE__ */ React.createElement("div", { className: "guidelines__revision-history" }, /* @__PURE__ */ React.createElement(
22742 import_components58.Navigator.BackButton,
22743 {
22744 icon: (0, import_i18n55.isRTL)() ? chevron_right_default : chevron_left_default,
22745 className: "guidelines__revision-history-back",
22746 onClick: navigateToGuidelines
22747 },
22748 (0, import_i18n55.__)("Revision history")
22749 ), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400, variant: "muted" }, (0, import_i18n55.__)("Use a previous version of your guidelines.")), /* @__PURE__ */ React.createElement(
22750 dataviews_default,
22751 {
22752 data: displayedRevisions,
22753 fields: fields2,
22754 view,
22755 onChangeView: setView,
22756 actions: actions2,
22757 isLoading,
22758 paginationInfo: paginationToShow,
22759 defaultLayouts: { table: true },
22760 getItemId: (item) => String(item.id),
22761 empty: isLoading && displayedRevisions.length === 0 ? /* @__PURE__ */ React.createElement(import_components58.Spinner, null) : (0, import_i18n55.__)("No revisions found.")
22762 }
22763 ), revisionToRestore && /* @__PURE__ */ React.createElement(
22764 import_components58.Modal,
22765 {
22766 title: (0, import_i18n55.__)("Restore guidelines"),
22767 onRequestClose: () => setRevisionToRestore(null),
22768 size: "medium"
22769 },
22770 /* @__PURE__ */ React.createElement(import_components58.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n55.sprintf)(
22771 /* translators: %s: formatted revision date */
22772 (0, import_i18n55.__)(
22773 "You are about to restore the guidelines from %s."
22774 ),
22775 (0, import_date10.dateI18n)(
22776 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
22777 (0, import_date10.getDate)(revisionToRestore.date)
22778 )
22779 )), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n55.__)(
22780 "You can undo this anytime from revision history."
22781 ))),
22782 /* @__PURE__ */ React.createElement(
22783 import_components58.__experimentalHStack,
22784 {
22785 justify: "flex-end",
22786 className: "guidelines__restore-modal-actions"
22787 },
22788 /* @__PURE__ */ React.createElement(
22789 import_components58.Button,
22790 {
22791 variant: "tertiary",
22792 onClick: () => setRevisionToRestore(null)
22793 },
22794 (0, import_i18n55.__)("Cancel")
22795 ),
22796 /* @__PURE__ */ React.createElement(
22797 import_components58.Button,
22798 {
22799 variant: "primary",
22800 onClick: handleRestore,
22801 isBusy: isRestoring,
22802 disabled: isRestoring,
22803 __next40pxDefaultSize: true
22804 },
22805 (0, import_i18n55.__)("Restore")
22806 )
22807 )
22808 ));
22809 }
22810
22811 // routes/guidelines/stage.tsx
22812 var GUIDELINE_ITEMS = [
22813 {
22814 title: (0, import_i18n56.__)("Site"),
22815 description: (0, import_i18n56.__)(
22816 "Describe your site's purpose, goals, and primary audience."
22817 ),
22818 slug: "site"
22819 },
22820 {
22821 title: (0, import_i18n56.__)("Copy"),
22822 description: (0, import_i18n56.__)(
22823 "Set your writing standards for tone, voice, style, and formatting."
22824 ),
22825 slug: "copy"
22826 },
22827 {
22828 title: (0, import_i18n56.__)("Images"),
22829 description: (0, import_i18n56.__)(
22830 "Outline your style, dimensions, formats, mood and aesthetic preferences."
22831 ),
22832 slug: "images"
22833 },
22834 {
22835 title: (0, import_i18n56.__)("Blocks"),
22836 description: (0, import_i18n56.__)(
22837 "Create tailored guidelines for specific block types."
22838 ),
22839 slug: "blocks"
22840 },
22841 {
22842 title: (0, import_i18n56.__)("Additional"),
22843 description: (0, import_i18n56.__)("Add additional guidelines."),
22844 slug: "additional"
22845 }
22846 ];
22847 var KNOWN_VIEWS = ["revision-history"];
22848 function getInitialNavigatorPath() {
22849 if (window?.location?.href) {
22850 const url = new URL(window.location.href);
22851 const view = url.searchParams.get("view") ?? "";
22852 if (KNOWN_VIEWS.includes(view)) {
22853 return `/${view}`;
22854 }
22855 }
22856 return "/";
22857 }
22858 function GuidelinesPage() {
22859 const [loading, setLoading] = (0, import_element94.useState)(true);
22860 const [error2, setError] = (0, import_element94.useState)(null);
22861 (0, import_element94.useEffect)(() => {
22862 fetchGuidelines().then(() => setError(null)).catch((e2) => setError(e2.message)).finally(() => setLoading(false));
22863 }, []);
22864 return /* @__PURE__ */ React.createElement(
22865 page_default,
22866 {
22867 title: (0, import_i18n56.__)("Guidelines"),
22868 subTitle: (0, import_i18n56.__)(
22869 "Set content standards that guide your team, inform plugins, and help AI tools generate content that matches your site's voice and requirements."
22870 )
22871 },
22872 error2 && /* @__PURE__ */ React.createElement("div", { className: "guidelines__content" }, /* @__PURE__ */ React.createElement(import_components59.Notice, { status: "error", isDismissible: false }, /* @__PURE__ */ React.createElement("strong", null, (0, import_i18n56.sprintf)(
22873 /* translators: %s: Error message. */
22874 (0, import_i18n56.__)("Error loading guidelines: %s"),
22875 error2
22876 )), /* @__PURE__ */ React.createElement("p", { className: "guidelines__error-description" }, (0, import_i18n56.__)(
22877 "Please try again. If the problem persists, contact support."
22878 )))),
22879 loading ? /* @__PURE__ */ React.createElement("div", { className: "guidelines__loading" }, /* @__PURE__ */ React.createElement(import_components59.Spinner, null)) : !error2 && /* @__PURE__ */ React.createElement(import_components59.Navigator, { initialPath: getInitialNavigatorPath() }, /* @__PURE__ */ React.createElement(import_components59.Navigator.Screen, { path: "/" }, /* @__PURE__ */ React.createElement(import_components59.__experimentalVStack, { className: "guidelines__content" }, /* @__PURE__ */ React.createElement("ul", { role: "list", className: "guidelines__list" }, GUIDELINE_ITEMS.map((item) => {
22880 const contentId = `guidelines-${item.slug}`;
22881 const headingId = `guidelines-${item.slug}-heading`;
22882 const descriptionId = `guidelines-${item.slug}-description`;
22883 return /* @__PURE__ */ React.createElement(
22884 "li",
22885 {
22886 key: item.slug,
22887 className: "guidelines__list-item"
22888 },
22889 /* @__PURE__ */ React.createElement("div", { className: "guidelines__accordion-item" }, /* @__PURE__ */ React.createElement(
22890 GuidelineAccordion,
22891 {
22892 title: item.title,
22893 description: item.description,
22894 contentId,
22895 headingId,
22896 descriptionId
22897 },
22898 item.slug === "blocks" ? /* @__PURE__ */ React.createElement(BlockGuidelines, null) : /* @__PURE__ */ React.createElement(
22899 GuidelineAccordionForm,
22900 {
22901 slug: item.slug,
22902 contentId,
22903 headingId,
22904 descriptionId
22905 }
22906 )
22907 ))
22908 );
22909 })), /* @__PURE__ */ React.createElement(GuidelineActionsSection, null))), /* @__PURE__ */ React.createElement(import_components59.Navigator.Screen, { path: "/revision-history" }, /* @__PURE__ */ React.createElement(RevisionHistory, null)))
22910 );
22911 }
22912 var stage = GuidelinesPage;
22913 export {
22914 stage
22915 };
22916 /*! Bundled license information:
22917
22918 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
22919 (**
22920 * @license React
22921 * use-sync-external-store-shim.development.js
22922 *
22923 * Copyright (c) Meta Platforms, Inc. and affiliates.
22924 *
22925 * This source code is licensed under the MIT license found in the
22926 * LICENSE file in the root directory of this source tree.
22927 *)
22928 */
22929