PluginProbe
Gutenberg / 23.2.1
Gutenberg v23.2.1
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.2.1, at build/routes/guidelines/content.js

23,750 lines 815.8 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 = useState40({
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, useState40 = 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 var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
2797 function getRuntime() {
2798 const globalScope = globalThis;
2799 if (globalScope.__wpStyleRuntime) {
2800 return globalScope.__wpStyleRuntime;
2801 }
2802 globalScope.__wpStyleRuntime = {
2803 documents: /* @__PURE__ */ new Map(),
2804 styles: /* @__PURE__ */ new Map(),
2805 injectedStyles: /* @__PURE__ */ new WeakMap()
2806 };
2807 if (typeof document !== "undefined") {
2808 registerDocument(document);
2809 }
2810 return globalScope.__wpStyleRuntime;
2811 }
2812 function documentContainsStyleHash(targetDocument, hash) {
2813 if (!targetDocument.head) {
2814 return false;
2815 }
2816 for (const style of targetDocument.head.querySelectorAll(
2817 `style[${STYLE_HASH_ATTRIBUTE}]`
2818 )) {
2819 if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
2820 return true;
2821 }
2822 }
2823 return false;
2824 }
2825 function injectStyle(targetDocument, hash, css) {
2826 if (!targetDocument.head) {
2827 return;
2828 }
2829 const runtime = getRuntime();
2830 let injectedStyles = runtime.injectedStyles.get(targetDocument);
2831 if (!injectedStyles) {
2832 injectedStyles = /* @__PURE__ */ new Set();
2833 runtime.injectedStyles.set(targetDocument, injectedStyles);
2834 }
2835 if (injectedStyles.has(hash)) {
2836 return;
2837 }
2838 if (documentContainsStyleHash(targetDocument, hash)) {
2839 injectedStyles.add(hash);
2840 return;
2841 }
2842 const style = targetDocument.createElement("style");
2843 style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
2844 style.appendChild(targetDocument.createTextNode(css));
2845 targetDocument.head.appendChild(style);
2846 injectedStyles.add(hash);
2847 }
2848 function registerDocument(targetDocument) {
2849 const runtime = getRuntime();
2850 runtime.documents.set(
2851 targetDocument,
2852 (runtime.documents.get(targetDocument) ?? 0) + 1
2853 );
2854 for (const [hash, css] of runtime.styles) {
2855 injectStyle(targetDocument, hash, css);
2856 }
2857 return () => {
2858 const count = runtime.documents.get(targetDocument);
2859 if (count === void 0) {
2860 return;
2861 }
2862 if (count <= 1) {
2863 runtime.documents.delete(targetDocument);
2864 return;
2865 }
2866 runtime.documents.set(targetDocument, count - 1);
2867 };
2868 }
2869 function registerStyle(hash, css) {
2870 const runtime = getRuntime();
2871 runtime.styles.set(hash, css);
2872 for (const targetDocument of runtime.documents.keys()) {
2873 injectStyle(targetDocument, hash, css);
2874 }
2875 }
2876 if (typeof process === "undefined" || true) {
2877 registerStyle("0c8601dd83", '@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);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);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);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);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);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);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);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_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)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);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-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_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-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_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-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_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-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_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)}}');
2878 }
2879 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" };
2880 if (typeof process === "undefined" || true) {
2881 registerStyle("1fb29d3a3c", "._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)}");
2882 }
2883 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" };
2884 var Text = (0, import_element.forwardRef)(function Text2({ variant = "body-md", render: render4, className, ...props }, ref) {
2885 const element = useRender({
2886 render: render4,
2887 defaultTagName: "span",
2888 ref,
2889 props: mergeProps(props, {
2890 className: clsx_default(
2891 style_default.text,
2892 global_css_defense_default.heading,
2893 global_css_defense_default.p,
2894 style_default[variant],
2895 className
2896 )
2897 })
2898 });
2899 return element;
2900 });
2901
2902 // packages/ui/build-module/badge/badge.mjs
2903 var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
2904 var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
2905 function getRuntime2() {
2906 const globalScope = globalThis;
2907 if (globalScope.__wpStyleRuntime) {
2908 return globalScope.__wpStyleRuntime;
2909 }
2910 globalScope.__wpStyleRuntime = {
2911 documents: /* @__PURE__ */ new Map(),
2912 styles: /* @__PURE__ */ new Map(),
2913 injectedStyles: /* @__PURE__ */ new WeakMap()
2914 };
2915 if (typeof document !== "undefined") {
2916 registerDocument2(document);
2917 }
2918 return globalScope.__wpStyleRuntime;
2919 }
2920 function documentContainsStyleHash2(targetDocument, hash) {
2921 if (!targetDocument.head) {
2922 return false;
2923 }
2924 for (const style of targetDocument.head.querySelectorAll(
2925 `style[${STYLE_HASH_ATTRIBUTE2}]`
2926 )) {
2927 if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
2928 return true;
2929 }
2930 }
2931 return false;
2932 }
2933 function injectStyle2(targetDocument, hash, css) {
2934 if (!targetDocument.head) {
2935 return;
2936 }
2937 const runtime = getRuntime2();
2938 let injectedStyles = runtime.injectedStyles.get(targetDocument);
2939 if (!injectedStyles) {
2940 injectedStyles = /* @__PURE__ */ new Set();
2941 runtime.injectedStyles.set(targetDocument, injectedStyles);
2942 }
2943 if (injectedStyles.has(hash)) {
2944 return;
2945 }
2946 if (documentContainsStyleHash2(targetDocument, hash)) {
2947 injectedStyles.add(hash);
2948 return;
2949 }
2950 const style = targetDocument.createElement("style");
2951 style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
2952 style.appendChild(targetDocument.createTextNode(css));
2953 targetDocument.head.appendChild(style);
2954 injectedStyles.add(hash);
2955 }
2956 function registerDocument2(targetDocument) {
2957 const runtime = getRuntime2();
2958 runtime.documents.set(
2959 targetDocument,
2960 (runtime.documents.get(targetDocument) ?? 0) + 1
2961 );
2962 for (const [hash, css] of runtime.styles) {
2963 injectStyle2(targetDocument, hash, css);
2964 }
2965 return () => {
2966 const count = runtime.documents.get(targetDocument);
2967 if (count === void 0) {
2968 return;
2969 }
2970 if (count <= 1) {
2971 runtime.documents.delete(targetDocument);
2972 return;
2973 }
2974 runtime.documents.set(targetDocument, count - 1);
2975 };
2976 }
2977 function registerStyle2(hash, css) {
2978 const runtime = getRuntime2();
2979 runtime.styles.set(hash, css);
2980 for (const targetDocument of runtime.documents.keys()) {
2981 injectStyle2(targetDocument, hash, css);
2982 }
2983 }
2984 if (typeof process === "undefined" || true) {
2985 registerStyle2("d6a685e1aa", "@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))}}");
2986 }
2987 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" };
2988 var Badge = (0, import_element2.forwardRef)(function Badge2({ intent = "none", className, ...props }, ref) {
2989 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2990 Text,
2991 {
2992 ref,
2993 className: clsx_default(
2994 style_default2.badge,
2995 style_default2[`is-${intent}-intent`],
2996 className
2997 ),
2998 ...props,
2999 variant: "body-sm"
3000 }
3001 );
3002 });
3003
3004 // packages/ui/build-module/icon/icon.mjs
3005 var import_element3 = __toESM(require_element(), 1);
3006 var import_primitives = __toESM(require_primitives(), 1);
3007 var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
3008 var Icon = (0, import_element3.forwardRef)(function Icon2({ icon, size = 24, ...restProps }, ref) {
3009 return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3010 import_primitives.SVG,
3011 {
3012 ref,
3013 fill: "currentColor",
3014 ...icon.props,
3015 ...restProps,
3016 width: size,
3017 height: size
3018 }
3019 );
3020 });
3021
3022 // packages/ui/build-module/card/index.mjs
3023 var card_exports = {};
3024 __export(card_exports, {
3025 Content: () => Content,
3026 FullBleed: () => FullBleed,
3027 Header: () => Header,
3028 Root: () => Root,
3029 Title: () => Title
3030 });
3031
3032 // packages/ui/build-module/card/root.mjs
3033 var import_element4 = __toESM(require_element(), 1);
3034 var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
3035 function getRuntime3() {
3036 const globalScope = globalThis;
3037 if (globalScope.__wpStyleRuntime) {
3038 return globalScope.__wpStyleRuntime;
3039 }
3040 globalScope.__wpStyleRuntime = {
3041 documents: /* @__PURE__ */ new Map(),
3042 styles: /* @__PURE__ */ new Map(),
3043 injectedStyles: /* @__PURE__ */ new WeakMap()
3044 };
3045 if (typeof document !== "undefined") {
3046 registerDocument3(document);
3047 }
3048 return globalScope.__wpStyleRuntime;
3049 }
3050 function documentContainsStyleHash3(targetDocument, hash) {
3051 if (!targetDocument.head) {
3052 return false;
3053 }
3054 for (const style of targetDocument.head.querySelectorAll(
3055 `style[${STYLE_HASH_ATTRIBUTE3}]`
3056 )) {
3057 if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
3058 return true;
3059 }
3060 }
3061 return false;
3062 }
3063 function injectStyle3(targetDocument, hash, css) {
3064 if (!targetDocument.head) {
3065 return;
3066 }
3067 const runtime = getRuntime3();
3068 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3069 if (!injectedStyles) {
3070 injectedStyles = /* @__PURE__ */ new Set();
3071 runtime.injectedStyles.set(targetDocument, injectedStyles);
3072 }
3073 if (injectedStyles.has(hash)) {
3074 return;
3075 }
3076 if (documentContainsStyleHash3(targetDocument, hash)) {
3077 injectedStyles.add(hash);
3078 return;
3079 }
3080 const style = targetDocument.createElement("style");
3081 style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
3082 style.appendChild(targetDocument.createTextNode(css));
3083 targetDocument.head.appendChild(style);
3084 injectedStyles.add(hash);
3085 }
3086 function registerDocument3(targetDocument) {
3087 const runtime = getRuntime3();
3088 runtime.documents.set(
3089 targetDocument,
3090 (runtime.documents.get(targetDocument) ?? 0) + 1
3091 );
3092 for (const [hash, css] of runtime.styles) {
3093 injectStyle3(targetDocument, hash, css);
3094 }
3095 return () => {
3096 const count = runtime.documents.get(targetDocument);
3097 if (count === void 0) {
3098 return;
3099 }
3100 if (count <= 1) {
3101 runtime.documents.delete(targetDocument);
3102 return;
3103 }
3104 runtime.documents.set(targetDocument, count - 1);
3105 };
3106 }
3107 function registerStyle3(hash, css) {
3108 const runtime = getRuntime3();
3109 runtime.styles.set(hash, css);
3110 for (const targetDocument of runtime.documents.keys()) {
3111 injectStyle3(targetDocument, hash, css);
3112 }
3113 }
3114 if (typeof process === "undefined" || true) {
3115 registerStyle3("e3ae230cea", "@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}}}");
3116 }
3117 var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
3118 if (typeof process === "undefined" || true) {
3119 registerStyle3("14f5e9ddeb", "@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)}}");
3120 }
3121 var style_default3 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
3122 var Root = (0, import_element4.forwardRef)(function Card({ render: render4, ...restProps }, ref) {
3123 const mergedClassName = clsx_default(style_default3.root, resets_default["box-sizing"]);
3124 const element = useRender({
3125 defaultTagName: "div",
3126 render: render4,
3127 ref,
3128 props: mergeProps({ className: mergedClassName }, restProps)
3129 });
3130 return element;
3131 });
3132
3133 // packages/ui/build-module/card/header.mjs
3134 var import_element5 = __toESM(require_element(), 1);
3135 var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
3136 function getRuntime4() {
3137 const globalScope = globalThis;
3138 if (globalScope.__wpStyleRuntime) {
3139 return globalScope.__wpStyleRuntime;
3140 }
3141 globalScope.__wpStyleRuntime = {
3142 documents: /* @__PURE__ */ new Map(),
3143 styles: /* @__PURE__ */ new Map(),
3144 injectedStyles: /* @__PURE__ */ new WeakMap()
3145 };
3146 if (typeof document !== "undefined") {
3147 registerDocument4(document);
3148 }
3149 return globalScope.__wpStyleRuntime;
3150 }
3151 function documentContainsStyleHash4(targetDocument, hash) {
3152 if (!targetDocument.head) {
3153 return false;
3154 }
3155 for (const style of targetDocument.head.querySelectorAll(
3156 `style[${STYLE_HASH_ATTRIBUTE4}]`
3157 )) {
3158 if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
3159 return true;
3160 }
3161 }
3162 return false;
3163 }
3164 function injectStyle4(targetDocument, hash, css) {
3165 if (!targetDocument.head) {
3166 return;
3167 }
3168 const runtime = getRuntime4();
3169 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3170 if (!injectedStyles) {
3171 injectedStyles = /* @__PURE__ */ new Set();
3172 runtime.injectedStyles.set(targetDocument, injectedStyles);
3173 }
3174 if (injectedStyles.has(hash)) {
3175 return;
3176 }
3177 if (documentContainsStyleHash4(targetDocument, hash)) {
3178 injectedStyles.add(hash);
3179 return;
3180 }
3181 const style = targetDocument.createElement("style");
3182 style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
3183 style.appendChild(targetDocument.createTextNode(css));
3184 targetDocument.head.appendChild(style);
3185 injectedStyles.add(hash);
3186 }
3187 function registerDocument4(targetDocument) {
3188 const runtime = getRuntime4();
3189 runtime.documents.set(
3190 targetDocument,
3191 (runtime.documents.get(targetDocument) ?? 0) + 1
3192 );
3193 for (const [hash, css] of runtime.styles) {
3194 injectStyle4(targetDocument, hash, css);
3195 }
3196 return () => {
3197 const count = runtime.documents.get(targetDocument);
3198 if (count === void 0) {
3199 return;
3200 }
3201 if (count <= 1) {
3202 runtime.documents.delete(targetDocument);
3203 return;
3204 }
3205 runtime.documents.set(targetDocument, count - 1);
3206 };
3207 }
3208 function registerStyle4(hash, css) {
3209 const runtime = getRuntime4();
3210 runtime.styles.set(hash, css);
3211 for (const targetDocument of runtime.documents.keys()) {
3212 injectStyle4(targetDocument, hash, css);
3213 }
3214 }
3215 if (typeof process === "undefined" || true) {
3216 registerStyle4("14f5e9ddeb", "@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)}}");
3217 }
3218 var style_default4 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
3219 var Header = (0, import_element5.forwardRef)(
3220 function CardHeader({ render: render4, ...props }, ref) {
3221 const element = useRender({
3222 defaultTagName: "div",
3223 render: render4,
3224 ref,
3225 props: mergeProps({ className: style_default4.header }, props)
3226 });
3227 return element;
3228 }
3229 );
3230
3231 // packages/ui/build-module/card/content.mjs
3232 var import_element6 = __toESM(require_element(), 1);
3233 var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
3234 function getRuntime5() {
3235 const globalScope = globalThis;
3236 if (globalScope.__wpStyleRuntime) {
3237 return globalScope.__wpStyleRuntime;
3238 }
3239 globalScope.__wpStyleRuntime = {
3240 documents: /* @__PURE__ */ new Map(),
3241 styles: /* @__PURE__ */ new Map(),
3242 injectedStyles: /* @__PURE__ */ new WeakMap()
3243 };
3244 if (typeof document !== "undefined") {
3245 registerDocument5(document);
3246 }
3247 return globalScope.__wpStyleRuntime;
3248 }
3249 function documentContainsStyleHash5(targetDocument, hash) {
3250 if (!targetDocument.head) {
3251 return false;
3252 }
3253 for (const style of targetDocument.head.querySelectorAll(
3254 `style[${STYLE_HASH_ATTRIBUTE5}]`
3255 )) {
3256 if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
3257 return true;
3258 }
3259 }
3260 return false;
3261 }
3262 function injectStyle5(targetDocument, hash, css) {
3263 if (!targetDocument.head) {
3264 return;
3265 }
3266 const runtime = getRuntime5();
3267 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3268 if (!injectedStyles) {
3269 injectedStyles = /* @__PURE__ */ new Set();
3270 runtime.injectedStyles.set(targetDocument, injectedStyles);
3271 }
3272 if (injectedStyles.has(hash)) {
3273 return;
3274 }
3275 if (documentContainsStyleHash5(targetDocument, hash)) {
3276 injectedStyles.add(hash);
3277 return;
3278 }
3279 const style = targetDocument.createElement("style");
3280 style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
3281 style.appendChild(targetDocument.createTextNode(css));
3282 targetDocument.head.appendChild(style);
3283 injectedStyles.add(hash);
3284 }
3285 function registerDocument5(targetDocument) {
3286 const runtime = getRuntime5();
3287 runtime.documents.set(
3288 targetDocument,
3289 (runtime.documents.get(targetDocument) ?? 0) + 1
3290 );
3291 for (const [hash, css] of runtime.styles) {
3292 injectStyle5(targetDocument, hash, css);
3293 }
3294 return () => {
3295 const count = runtime.documents.get(targetDocument);
3296 if (count === void 0) {
3297 return;
3298 }
3299 if (count <= 1) {
3300 runtime.documents.delete(targetDocument);
3301 return;
3302 }
3303 runtime.documents.set(targetDocument, count - 1);
3304 };
3305 }
3306 function registerStyle5(hash, css) {
3307 const runtime = getRuntime5();
3308 runtime.styles.set(hash, css);
3309 for (const targetDocument of runtime.documents.keys()) {
3310 injectStyle5(targetDocument, hash, css);
3311 }
3312 }
3313 if (typeof process === "undefined" || true) {
3314 registerStyle5("14f5e9ddeb", "@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)}}");
3315 }
3316 var style_default5 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
3317 var Content = (0, import_element6.forwardRef)(
3318 function CardContent({ render: render4, ...props }, ref) {
3319 const element = useRender({
3320 defaultTagName: "div",
3321 render: render4,
3322 ref,
3323 props: mergeProps({ className: style_default5.content }, props)
3324 });
3325 return element;
3326 }
3327 );
3328
3329 // packages/ui/build-module/card/full-bleed.mjs
3330 var import_element7 = __toESM(require_element(), 1);
3331 var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
3332 function getRuntime6() {
3333 const globalScope = globalThis;
3334 if (globalScope.__wpStyleRuntime) {
3335 return globalScope.__wpStyleRuntime;
3336 }
3337 globalScope.__wpStyleRuntime = {
3338 documents: /* @__PURE__ */ new Map(),
3339 styles: /* @__PURE__ */ new Map(),
3340 injectedStyles: /* @__PURE__ */ new WeakMap()
3341 };
3342 if (typeof document !== "undefined") {
3343 registerDocument6(document);
3344 }
3345 return globalScope.__wpStyleRuntime;
3346 }
3347 function documentContainsStyleHash6(targetDocument, hash) {
3348 if (!targetDocument.head) {
3349 return false;
3350 }
3351 for (const style of targetDocument.head.querySelectorAll(
3352 `style[${STYLE_HASH_ATTRIBUTE6}]`
3353 )) {
3354 if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
3355 return true;
3356 }
3357 }
3358 return false;
3359 }
3360 function injectStyle6(targetDocument, hash, css) {
3361 if (!targetDocument.head) {
3362 return;
3363 }
3364 const runtime = getRuntime6();
3365 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3366 if (!injectedStyles) {
3367 injectedStyles = /* @__PURE__ */ new Set();
3368 runtime.injectedStyles.set(targetDocument, injectedStyles);
3369 }
3370 if (injectedStyles.has(hash)) {
3371 return;
3372 }
3373 if (documentContainsStyleHash6(targetDocument, hash)) {
3374 injectedStyles.add(hash);
3375 return;
3376 }
3377 const style = targetDocument.createElement("style");
3378 style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
3379 style.appendChild(targetDocument.createTextNode(css));
3380 targetDocument.head.appendChild(style);
3381 injectedStyles.add(hash);
3382 }
3383 function registerDocument6(targetDocument) {
3384 const runtime = getRuntime6();
3385 runtime.documents.set(
3386 targetDocument,
3387 (runtime.documents.get(targetDocument) ?? 0) + 1
3388 );
3389 for (const [hash, css] of runtime.styles) {
3390 injectStyle6(targetDocument, hash, css);
3391 }
3392 return () => {
3393 const count = runtime.documents.get(targetDocument);
3394 if (count === void 0) {
3395 return;
3396 }
3397 if (count <= 1) {
3398 runtime.documents.delete(targetDocument);
3399 return;
3400 }
3401 runtime.documents.set(targetDocument, count - 1);
3402 };
3403 }
3404 function registerStyle6(hash, css) {
3405 const runtime = getRuntime6();
3406 runtime.styles.set(hash, css);
3407 for (const targetDocument of runtime.documents.keys()) {
3408 injectStyle6(targetDocument, hash, css);
3409 }
3410 }
3411 if (typeof process === "undefined" || true) {
3412 registerStyle6("14f5e9ddeb", "@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)}}");
3413 }
3414 var style_default6 = { "root": "_02872bf298eadc43__root", "header": "bbccc92e6ba5662d__header", "content": "_5dffdaf2a6e669ac__content", "fullbleed": "c1fa192587e1b4a6__fullbleed" };
3415 var FullBleed = (0, import_element7.forwardRef)(
3416 function CardFullBleed({ render: render4, ...props }, ref) {
3417 const element = useRender({
3418 defaultTagName: "div",
3419 render: render4,
3420 ref,
3421 props: mergeProps(
3422 { className: style_default6.fullbleed },
3423 props
3424 )
3425 });
3426 return element;
3427 }
3428 );
3429
3430 // packages/ui/build-module/card/title.mjs
3431 var import_element8 = __toESM(require_element(), 1);
3432 var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
3433 var DEFAULT_TAG = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", {});
3434 var Title = (0, import_element8.forwardRef)(
3435 function CardTitle({ render: render4 = DEFAULT_TAG, children, ...props }, ref) {
3436 return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3437 Text,
3438 {
3439 ref,
3440 variant: "heading-lg",
3441 render: render4,
3442 ...props,
3443 children
3444 }
3445 );
3446 }
3447 );
3448
3449 // packages/ui/build-module/collapsible/panel.mjs
3450 var import_element9 = __toESM(require_element(), 1);
3451 var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
3452 var Panel = (0, import_element9.forwardRef)(
3453 function CollapsiblePanel3(props, forwardedRef) {
3454 return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(index_parts_exports.Panel, { ref: forwardedRef, ...props });
3455 }
3456 );
3457
3458 // packages/ui/build-module/collapsible/root.mjs
3459 var import_element10 = __toESM(require_element(), 1);
3460 var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
3461 var Root2 = (0, import_element10.forwardRef)(
3462 function CollapsibleRoot3(props, forwardedRef) {
3463 return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(index_parts_exports.Root, { ref: forwardedRef, ...props });
3464 }
3465 );
3466
3467 // packages/ui/build-module/collapsible/trigger.mjs
3468 var import_element11 = __toESM(require_element(), 1);
3469 var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
3470 var Trigger = (0, import_element11.forwardRef)(
3471 function CollapsibleTrigger3(props, forwardedRef) {
3472 return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(index_parts_exports.Trigger, { ref: forwardedRef, ...props });
3473 }
3474 );
3475
3476 // packages/ui/build-module/collapsible-card/index.mjs
3477 var collapsible_card_exports = {};
3478 __export(collapsible_card_exports, {
3479 Content: () => Content2,
3480 Header: () => Header2,
3481 HeaderDescription: () => HeaderDescription,
3482 Root: () => Root3
3483 });
3484
3485 // packages/ui/build-module/collapsible-card/root.mjs
3486 var import_element12 = __toESM(require_element(), 1);
3487 var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
3488 var Root3 = (0, import_element12.forwardRef)(
3489 function CollapsibleCardRoot({ render: render4, ...restProps }, ref) {
3490 return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
3491 Root2,
3492 {
3493 ref,
3494 render: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Root, { render: render4 }),
3495 ...restProps
3496 }
3497 );
3498 }
3499 );
3500
3501 // packages/ui/build-module/collapsible-card/header.mjs
3502 var import_element14 = __toESM(require_element(), 1);
3503
3504 // packages/icons/build-module/library/arrow-down.mjs
3505 var import_primitives2 = __toESM(require_primitives(), 1);
3506 var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
3507 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" }) });
3508
3509 // packages/icons/build-module/library/arrow-left.mjs
3510 var import_primitives3 = __toESM(require_primitives(), 1);
3511 var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
3512 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" }) });
3513
3514 // packages/icons/build-module/library/arrow-right.mjs
3515 var import_primitives4 = __toESM(require_primitives(), 1);
3516 var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
3517 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" }) });
3518
3519 // packages/icons/build-module/library/arrow-up.mjs
3520 var import_primitives5 = __toESM(require_primitives(), 1);
3521 var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
3522 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" }) });
3523
3524 // packages/icons/build-module/library/block-default.mjs
3525 var import_primitives6 = __toESM(require_primitives(), 1);
3526 var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
3527 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" }) });
3528
3529 // packages/icons/build-module/library/block-table.mjs
3530 var import_primitives7 = __toESM(require_primitives(), 1);
3531 var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
3532 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" }) });
3533
3534 // packages/icons/build-module/library/category.mjs
3535 var import_primitives8 = __toESM(require_primitives(), 1);
3536 var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
3537 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" }) });
3538
3539 // packages/icons/build-module/library/check.mjs
3540 var import_primitives9 = __toESM(require_primitives(), 1);
3541 var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
3542 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" }) });
3543
3544 // packages/icons/build-module/library/chevron-down.mjs
3545 var import_primitives10 = __toESM(require_primitives(), 1);
3546 var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
3547 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" }) });
3548
3549 // packages/icons/build-module/library/chevron-left.mjs
3550 var import_primitives11 = __toESM(require_primitives(), 1);
3551 var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
3552 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" }) });
3553
3554 // packages/icons/build-module/library/chevron-right.mjs
3555 var import_primitives12 = __toESM(require_primitives(), 1);
3556 var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
3557 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" }) });
3558
3559 // packages/icons/build-module/library/close-small.mjs
3560 var import_primitives13 = __toESM(require_primitives(), 1);
3561 var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
3562 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" }) });
3563
3564 // packages/icons/build-module/library/cog.mjs
3565 var import_primitives14 = __toESM(require_primitives(), 1);
3566 var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
3567 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" }) });
3568
3569 // packages/icons/build-module/library/envelope.mjs
3570 var import_primitives15 = __toESM(require_primitives(), 1);
3571 var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
3572 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" }) });
3573
3574 // packages/icons/build-module/library/error.mjs
3575 var import_primitives16 = __toESM(require_primitives(), 1);
3576 var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
3577 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" }) });
3578
3579 // packages/icons/build-module/library/format-list-bullets-rtl.mjs
3580 var import_primitives17 = __toESM(require_primitives(), 1);
3581 var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
3582 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" }) });
3583
3584 // packages/icons/build-module/library/format-list-bullets.mjs
3585 var import_primitives18 = __toESM(require_primitives(), 1);
3586 var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
3587 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" }) });
3588
3589 // packages/icons/build-module/library/funnel.mjs
3590 var import_primitives19 = __toESM(require_primitives(), 1);
3591 var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
3592 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" }) });
3593
3594 // packages/icons/build-module/library/link.mjs
3595 var import_primitives20 = __toESM(require_primitives(), 1);
3596 var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
3597 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" }) });
3598
3599 // packages/icons/build-module/library/mobile.mjs
3600 var import_primitives21 = __toESM(require_primitives(), 1);
3601 var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
3602 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" }) });
3603
3604 // packages/icons/build-module/library/more-vertical.mjs
3605 var import_primitives22 = __toESM(require_primitives(), 1);
3606 var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
3607 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" }) });
3608
3609 // packages/icons/build-module/library/next.mjs
3610 var import_primitives23 = __toESM(require_primitives(), 1);
3611 var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
3612 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" }) });
3613
3614 // packages/icons/build-module/library/pencil.mjs
3615 var import_primitives24 = __toESM(require_primitives(), 1);
3616 var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
3617 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" }) });
3618
3619 // packages/icons/build-module/library/previous.mjs
3620 var import_primitives25 = __toESM(require_primitives(), 1);
3621 var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
3622 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" }) });
3623
3624 // packages/icons/build-module/library/scheduled.mjs
3625 var import_primitives26 = __toESM(require_primitives(), 1);
3626 var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);
3627 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" }) });
3628
3629 // packages/icons/build-module/library/search.mjs
3630 var import_primitives27 = __toESM(require_primitives(), 1);
3631 var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
3632 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" }) });
3633
3634 // packages/icons/build-module/library/seen.mjs
3635 var import_primitives28 = __toESM(require_primitives(), 1);
3636 var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
3637 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" }) });
3638
3639 // packages/icons/build-module/library/unseen.mjs
3640 var import_primitives29 = __toESM(require_primitives(), 1);
3641 var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
3642 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" }) });
3643
3644 // packages/ui/build-module/collapsible-card/context.mjs
3645 var import_element13 = __toESM(require_element(), 1);
3646 var HeaderDescriptionIdContext = (0, import_element13.createContext)({
3647 setDescriptionId: () => {
3648 }
3649 });
3650
3651 // packages/ui/build-module/collapsible-card/header.mjs
3652 var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
3653 var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
3654 function getRuntime7() {
3655 const globalScope = globalThis;
3656 if (globalScope.__wpStyleRuntime) {
3657 return globalScope.__wpStyleRuntime;
3658 }
3659 globalScope.__wpStyleRuntime = {
3660 documents: /* @__PURE__ */ new Map(),
3661 styles: /* @__PURE__ */ new Map(),
3662 injectedStyles: /* @__PURE__ */ new WeakMap()
3663 };
3664 if (typeof document !== "undefined") {
3665 registerDocument7(document);
3666 }
3667 return globalScope.__wpStyleRuntime;
3668 }
3669 function documentContainsStyleHash7(targetDocument, hash) {
3670 if (!targetDocument.head) {
3671 return false;
3672 }
3673 for (const style of targetDocument.head.querySelectorAll(
3674 `style[${STYLE_HASH_ATTRIBUTE7}]`
3675 )) {
3676 if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
3677 return true;
3678 }
3679 }
3680 return false;
3681 }
3682 function injectStyle7(targetDocument, hash, css) {
3683 if (!targetDocument.head) {
3684 return;
3685 }
3686 const runtime = getRuntime7();
3687 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3688 if (!injectedStyles) {
3689 injectedStyles = /* @__PURE__ */ new Set();
3690 runtime.injectedStyles.set(targetDocument, injectedStyles);
3691 }
3692 if (injectedStyles.has(hash)) {
3693 return;
3694 }
3695 if (documentContainsStyleHash7(targetDocument, hash)) {
3696 injectedStyles.add(hash);
3697 return;
3698 }
3699 const style = targetDocument.createElement("style");
3700 style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
3701 style.appendChild(targetDocument.createTextNode(css));
3702 targetDocument.head.appendChild(style);
3703 injectedStyles.add(hash);
3704 }
3705 function registerDocument7(targetDocument) {
3706 const runtime = getRuntime7();
3707 runtime.documents.set(
3708 targetDocument,
3709 (runtime.documents.get(targetDocument) ?? 0) + 1
3710 );
3711 for (const [hash, css] of runtime.styles) {
3712 injectStyle7(targetDocument, hash, css);
3713 }
3714 return () => {
3715 const count = runtime.documents.get(targetDocument);
3716 if (count === void 0) {
3717 return;
3718 }
3719 if (count <= 1) {
3720 runtime.documents.delete(targetDocument);
3721 return;
3722 }
3723 runtime.documents.set(targetDocument, count - 1);
3724 };
3725 }
3726 function registerStyle7(hash, css) {
3727 const runtime = getRuntime7();
3728 runtime.styles.set(hash, css);
3729 for (const targetDocument of runtime.documents.keys()) {
3730 injectStyle7(targetDocument, hash, css);
3731 }
3732 }
3733 if (typeof process === "undefined" || true) {
3734 registerStyle7("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.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)}}}");
3735 }
3736 var style_default7 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "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" };
3737 if (typeof process === "undefined" || true) {
3738 registerStyle7("1fb29d3a3c", "._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)}");
3739 }
3740 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" };
3741 if (typeof process === "undefined" || true) {
3742 registerStyle7("2a5ab8f3a7", "@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))}}");
3743 }
3744 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" };
3745 var Header2 = (0, import_element14.forwardRef)(
3746 function CollapsibleCardHeader({ children, className, render: render4, ...restProps }, ref) {
3747 const [descriptionId, setDescriptionId] = (0, import_element14.useState)();
3748 const contextValue = (0, import_element14.useMemo)(
3749 () => ({ setDescriptionId }),
3750 [setDescriptionId]
3751 );
3752 return useRender({
3753 defaultTagName: "div",
3754 render: render4,
3755 ref,
3756 props: mergeProps(restProps, {
3757 className: clsx_default(
3758 global_css_defense_default2.heading,
3759 style_default7["heading-wrapper"],
3760 className
3761 ),
3762 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(HeaderDescriptionIdContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
3763 Trigger,
3764 {
3765 className: style_default7.header,
3766 render: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Header, {}),
3767 nativeButton: false,
3768 "aria-describedby": descriptionId,
3769 children: [
3770 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: style_default7["header-content"], children }),
3771 /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3772 "div",
3773 {
3774 className: clsx_default(
3775 style_default7["header-trigger-positioner"]
3776 ),
3777 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3778 "div",
3779 {
3780 className: clsx_default(
3781 style_default7["header-trigger-wrapper"],
3782 global_css_defense_default2.div,
3783 // While the interactive trigger element is the whole header,
3784 // the focus ring will be displayed only on the icon to visually
3785 // emulate it being the button.
3786 focus_default["outset-ring--focus-parent-visible"]
3787 ),
3788 children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3789 Icon,
3790 {
3791 icon: chevron_down_default,
3792 className: style_default7["header-trigger"]
3793 }
3794 )
3795 }
3796 )
3797 }
3798 )
3799 ]
3800 }
3801 ) })
3802 })
3803 });
3804 }
3805 );
3806
3807 // packages/ui/build-module/collapsible-card/header-description.mjs
3808 var import_element15 = __toESM(require_element(), 1);
3809 var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
3810 var HeaderDescription = (0, import_element15.forwardRef)(function CollapsibleCardHeaderDescription({ children, className, ...restProps }, ref) {
3811 const descriptionId = (0, import_element15.useId)();
3812 const { setDescriptionId } = (0, import_element15.useContext)(HeaderDescriptionIdContext);
3813 (0, import_element15.useEffect)(() => {
3814 setDescriptionId(descriptionId);
3815 return () => setDescriptionId(void 0);
3816 }, [descriptionId, setDescriptionId]);
3817 return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
3818 "div",
3819 {
3820 ref,
3821 id: descriptionId,
3822 "aria-hidden": "true",
3823 className,
3824 ...restProps,
3825 children
3826 }
3827 );
3828 });
3829
3830 // packages/ui/build-module/collapsible-card/content.mjs
3831 var import_element16 = __toESM(require_element(), 1);
3832 var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
3833 var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
3834 function getRuntime8() {
3835 const globalScope = globalThis;
3836 if (globalScope.__wpStyleRuntime) {
3837 return globalScope.__wpStyleRuntime;
3838 }
3839 globalScope.__wpStyleRuntime = {
3840 documents: /* @__PURE__ */ new Map(),
3841 styles: /* @__PURE__ */ new Map(),
3842 injectedStyles: /* @__PURE__ */ new WeakMap()
3843 };
3844 if (typeof document !== "undefined") {
3845 registerDocument8(document);
3846 }
3847 return globalScope.__wpStyleRuntime;
3848 }
3849 function documentContainsStyleHash8(targetDocument, hash) {
3850 if (!targetDocument.head) {
3851 return false;
3852 }
3853 for (const style of targetDocument.head.querySelectorAll(
3854 `style[${STYLE_HASH_ATTRIBUTE8}]`
3855 )) {
3856 if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
3857 return true;
3858 }
3859 }
3860 return false;
3861 }
3862 function injectStyle8(targetDocument, hash, css) {
3863 if (!targetDocument.head) {
3864 return;
3865 }
3866 const runtime = getRuntime8();
3867 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3868 if (!injectedStyles) {
3869 injectedStyles = /* @__PURE__ */ new Set();
3870 runtime.injectedStyles.set(targetDocument, injectedStyles);
3871 }
3872 if (injectedStyles.has(hash)) {
3873 return;
3874 }
3875 if (documentContainsStyleHash8(targetDocument, hash)) {
3876 injectedStyles.add(hash);
3877 return;
3878 }
3879 const style = targetDocument.createElement("style");
3880 style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
3881 style.appendChild(targetDocument.createTextNode(css));
3882 targetDocument.head.appendChild(style);
3883 injectedStyles.add(hash);
3884 }
3885 function registerDocument8(targetDocument) {
3886 const runtime = getRuntime8();
3887 runtime.documents.set(
3888 targetDocument,
3889 (runtime.documents.get(targetDocument) ?? 0) + 1
3890 );
3891 for (const [hash, css] of runtime.styles) {
3892 injectStyle8(targetDocument, hash, css);
3893 }
3894 return () => {
3895 const count = runtime.documents.get(targetDocument);
3896 if (count === void 0) {
3897 return;
3898 }
3899 if (count <= 1) {
3900 runtime.documents.delete(targetDocument);
3901 return;
3902 }
3903 runtime.documents.set(targetDocument, count - 1);
3904 };
3905 }
3906 function registerStyle8(hash, css) {
3907 const runtime = getRuntime8();
3908 runtime.styles.set(hash, css);
3909 for (const targetDocument of runtime.documents.keys()) {
3910 injectStyle8(targetDocument, hash, css);
3911 }
3912 }
3913 if (typeof process === "undefined" || true) {
3914 registerStyle8("f1b9bb6252", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._626190151275d6d3__heading-wrapper{--_gcd-heading-color:inherit;--_gcd-heading-font-size:inherit;--_gcd-heading-font-weight:inherit;--_gcd-heading-margin:0;font-family:inherit;line-height:inherit}.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)}}}");
3915 }
3916 var style_default8 = { "heading-wrapper": "_626190151275d6d3__heading-wrapper", "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" };
3917 var Content2 = (0, import_element16.forwardRef)(
3918 function CollapsibleCardContent({ className, render: render4, children, hiddenUntilFound = true, ...restProps }, ref) {
3919 return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3920 Panel,
3921 {
3922 ref,
3923 className: (state) => clsx_default(
3924 style_default8.content,
3925 state.open && state.transitionStatus === "idle" && style_default8.overflowVisible,
3926 className
3927 ),
3928 hiddenUntilFound,
3929 ...restProps,
3930 children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
3931 Content,
3932 {
3933 className: style_default8["content-inner"],
3934 render: render4,
3935 children
3936 }
3937 )
3938 }
3939 );
3940 }
3941 );
3942
3943 // packages/ui/build-module/stack/stack.mjs
3944 var import_element17 = __toESM(require_element(), 1);
3945 var STYLE_HASH_ATTRIBUTE9 = "data-wp-hash";
3946 function getRuntime9() {
3947 const globalScope = globalThis;
3948 if (globalScope.__wpStyleRuntime) {
3949 return globalScope.__wpStyleRuntime;
3950 }
3951 globalScope.__wpStyleRuntime = {
3952 documents: /* @__PURE__ */ new Map(),
3953 styles: /* @__PURE__ */ new Map(),
3954 injectedStyles: /* @__PURE__ */ new WeakMap()
3955 };
3956 if (typeof document !== "undefined") {
3957 registerDocument9(document);
3958 }
3959 return globalScope.__wpStyleRuntime;
3960 }
3961 function documentContainsStyleHash9(targetDocument, hash) {
3962 if (!targetDocument.head) {
3963 return false;
3964 }
3965 for (const style of targetDocument.head.querySelectorAll(
3966 `style[${STYLE_HASH_ATTRIBUTE9}]`
3967 )) {
3968 if (style.getAttribute(STYLE_HASH_ATTRIBUTE9) === hash) {
3969 return true;
3970 }
3971 }
3972 return false;
3973 }
3974 function injectStyle9(targetDocument, hash, css) {
3975 if (!targetDocument.head) {
3976 return;
3977 }
3978 const runtime = getRuntime9();
3979 let injectedStyles = runtime.injectedStyles.get(targetDocument);
3980 if (!injectedStyles) {
3981 injectedStyles = /* @__PURE__ */ new Set();
3982 runtime.injectedStyles.set(targetDocument, injectedStyles);
3983 }
3984 if (injectedStyles.has(hash)) {
3985 return;
3986 }
3987 if (documentContainsStyleHash9(targetDocument, hash)) {
3988 injectedStyles.add(hash);
3989 return;
3990 }
3991 const style = targetDocument.createElement("style");
3992 style.setAttribute(STYLE_HASH_ATTRIBUTE9, hash);
3993 style.appendChild(targetDocument.createTextNode(css));
3994 targetDocument.head.appendChild(style);
3995 injectedStyles.add(hash);
3996 }
3997 function registerDocument9(targetDocument) {
3998 const runtime = getRuntime9();
3999 runtime.documents.set(
4000 targetDocument,
4001 (runtime.documents.get(targetDocument) ?? 0) + 1
4002 );
4003 for (const [hash, css] of runtime.styles) {
4004 injectStyle9(targetDocument, hash, css);
4005 }
4006 return () => {
4007 const count = runtime.documents.get(targetDocument);
4008 if (count === void 0) {
4009 return;
4010 }
4011 if (count <= 1) {
4012 runtime.documents.delete(targetDocument);
4013 return;
4014 }
4015 runtime.documents.set(targetDocument, count - 1);
4016 };
4017 }
4018 function registerStyle9(hash, css) {
4019 const runtime = getRuntime9();
4020 runtime.styles.set(hash, css);
4021 for (const targetDocument of runtime.documents.keys()) {
4022 injectStyle9(targetDocument, hash, css);
4023 }
4024 }
4025 if (typeof process === "undefined" || true) {
4026 registerStyle9("b51ff41489", "@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}");
4027 }
4028 var style_default9 = { "stack": "_19ce0419607e1896__stack" };
4029 var gapTokens = {
4030 xs: "var(--wpds-dimension-gap-xs, 4px)",
4031 sm: "var(--wpds-dimension-gap-sm, 8px)",
4032 md: "var(--wpds-dimension-gap-md, 12px)",
4033 lg: "var(--wpds-dimension-gap-lg, 16px)",
4034 xl: "var(--wpds-dimension-gap-xl, 24px)",
4035 "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
4036 "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
4037 };
4038 var Stack = (0, import_element17.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render: render4, ...props }, ref) {
4039 const style = {
4040 gap: gap && gapTokens[gap],
4041 alignItems: align,
4042 justifyContent: justify,
4043 flexDirection: direction,
4044 flexWrap: wrap
4045 };
4046 const element = useRender({
4047 render: render4,
4048 ref,
4049 props: mergeProps(props, { style, className: style_default9.stack })
4050 });
4051 return element;
4052 });
4053
4054 // packages/ui/build-module/visually-hidden/visually-hidden.mjs
4055 var import_element18 = __toESM(require_element(), 1);
4056 var STYLE_HASH_ATTRIBUTE10 = "data-wp-hash";
4057 function getRuntime10() {
4058 const globalScope = globalThis;
4059 if (globalScope.__wpStyleRuntime) {
4060 return globalScope.__wpStyleRuntime;
4061 }
4062 globalScope.__wpStyleRuntime = {
4063 documents: /* @__PURE__ */ new Map(),
4064 styles: /* @__PURE__ */ new Map(),
4065 injectedStyles: /* @__PURE__ */ new WeakMap()
4066 };
4067 if (typeof document !== "undefined") {
4068 registerDocument10(document);
4069 }
4070 return globalScope.__wpStyleRuntime;
4071 }
4072 function documentContainsStyleHash10(targetDocument, hash) {
4073 if (!targetDocument.head) {
4074 return false;
4075 }
4076 for (const style of targetDocument.head.querySelectorAll(
4077 `style[${STYLE_HASH_ATTRIBUTE10}]`
4078 )) {
4079 if (style.getAttribute(STYLE_HASH_ATTRIBUTE10) === hash) {
4080 return true;
4081 }
4082 }
4083 return false;
4084 }
4085 function injectStyle10(targetDocument, hash, css) {
4086 if (!targetDocument.head) {
4087 return;
4088 }
4089 const runtime = getRuntime10();
4090 let injectedStyles = runtime.injectedStyles.get(targetDocument);
4091 if (!injectedStyles) {
4092 injectedStyles = /* @__PURE__ */ new Set();
4093 runtime.injectedStyles.set(targetDocument, injectedStyles);
4094 }
4095 if (injectedStyles.has(hash)) {
4096 return;
4097 }
4098 if (documentContainsStyleHash10(targetDocument, hash)) {
4099 injectedStyles.add(hash);
4100 return;
4101 }
4102 const style = targetDocument.createElement("style");
4103 style.setAttribute(STYLE_HASH_ATTRIBUTE10, hash);
4104 style.appendChild(targetDocument.createTextNode(css));
4105 targetDocument.head.appendChild(style);
4106 injectedStyles.add(hash);
4107 }
4108 function registerDocument10(targetDocument) {
4109 const runtime = getRuntime10();
4110 runtime.documents.set(
4111 targetDocument,
4112 (runtime.documents.get(targetDocument) ?? 0) + 1
4113 );
4114 for (const [hash, css] of runtime.styles) {
4115 injectStyle10(targetDocument, hash, css);
4116 }
4117 return () => {
4118 const count = runtime.documents.get(targetDocument);
4119 if (count === void 0) {
4120 return;
4121 }
4122 if (count <= 1) {
4123 runtime.documents.delete(targetDocument);
4124 return;
4125 }
4126 runtime.documents.set(targetDocument, count - 1);
4127 };
4128 }
4129 function registerStyle10(hash, css) {
4130 const runtime = getRuntime10();
4131 runtime.styles.set(hash, css);
4132 for (const targetDocument of runtime.documents.keys()) {
4133 injectStyle10(targetDocument, hash, css);
4134 }
4135 }
4136 if (typeof process === "undefined" || true) {
4137 registerStyle10("c46e8cb841", "@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}}");
4138 }
4139 var style_default10 = { "visually-hidden": "f37b9e2e191ebd66__visually-hidden" };
4140 var VisuallyHidden = (0, import_element18.forwardRef)(
4141 function VisuallyHidden2({ render: render4, ...restProps }, ref) {
4142 const element = useRender({
4143 render: render4,
4144 ref,
4145 props: mergeProps(
4146 { className: style_default10["visually-hidden"] },
4147 restProps,
4148 {
4149 // @ts-expect-error Arbitrary data-* attributes aren't indexable on the typed div props. Kept hardcoded so consumers can't change or remove it.
4150 "data-visually-hidden": ""
4151 }
4152 )
4153 });
4154 return element;
4155 }
4156 );
4157
4158 // packages/admin-ui/build-module/navigable-region/index.mjs
4159 var import_element19 = __toESM(require_element(), 1);
4160 var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);
4161 var NavigableRegion = (0, import_element19.forwardRef)(
4162 ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
4163 return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
4164 Tag,
4165 {
4166 ref,
4167 className: clsx_default("admin-ui-navigable-region", className),
4168 "aria-label": ariaLabel,
4169 role: "region",
4170 tabIndex: "-1",
4171 ...props,
4172 children
4173 }
4174 );
4175 }
4176 );
4177 NavigableRegion.displayName = "NavigableRegion";
4178 var navigable_region_default = NavigableRegion;
4179
4180 // packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
4181 var import_components = __toESM(require_components(), 1);
4182 var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");
4183
4184 // packages/admin-ui/build-module/page/header.mjs
4185 var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);
4186 var STYLE_HASH_ATTRIBUTE11 = "data-wp-hash";
4187 function getRuntime11() {
4188 const globalScope = globalThis;
4189 if (globalScope.__wpStyleRuntime) {
4190 return globalScope.__wpStyleRuntime;
4191 }
4192 globalScope.__wpStyleRuntime = {
4193 documents: /* @__PURE__ */ new Map(),
4194 styles: /* @__PURE__ */ new Map(),
4195 injectedStyles: /* @__PURE__ */ new WeakMap()
4196 };
4197 if (typeof document !== "undefined") {
4198 registerDocument11(document);
4199 }
4200 return globalScope.__wpStyleRuntime;
4201 }
4202 function documentContainsStyleHash11(targetDocument, hash) {
4203 if (!targetDocument.head) {
4204 return false;
4205 }
4206 for (const style of targetDocument.head.querySelectorAll(
4207 `style[${STYLE_HASH_ATTRIBUTE11}]`
4208 )) {
4209 if (style.getAttribute(STYLE_HASH_ATTRIBUTE11) === hash) {
4210 return true;
4211 }
4212 }
4213 return false;
4214 }
4215 function injectStyle11(targetDocument, hash, css) {
4216 if (!targetDocument.head) {
4217 return;
4218 }
4219 const runtime = getRuntime11();
4220 let injectedStyles = runtime.injectedStyles.get(targetDocument);
4221 if (!injectedStyles) {
4222 injectedStyles = /* @__PURE__ */ new Set();
4223 runtime.injectedStyles.set(targetDocument, injectedStyles);
4224 }
4225 if (injectedStyles.has(hash)) {
4226 return;
4227 }
4228 if (documentContainsStyleHash11(targetDocument, hash)) {
4229 injectedStyles.add(hash);
4230 return;
4231 }
4232 const style = targetDocument.createElement("style");
4233 style.setAttribute(STYLE_HASH_ATTRIBUTE11, hash);
4234 style.appendChild(targetDocument.createTextNode(css));
4235 targetDocument.head.appendChild(style);
4236 injectedStyles.add(hash);
4237 }
4238 function registerDocument11(targetDocument) {
4239 const runtime = getRuntime11();
4240 runtime.documents.set(
4241 targetDocument,
4242 (runtime.documents.get(targetDocument) ?? 0) + 1
4243 );
4244 for (const [hash, css] of runtime.styles) {
4245 injectStyle11(targetDocument, hash, css);
4246 }
4247 return () => {
4248 const count = runtime.documents.get(targetDocument);
4249 if (count === void 0) {
4250 return;
4251 }
4252 if (count <= 1) {
4253 runtime.documents.delete(targetDocument);
4254 return;
4255 }
4256 runtime.documents.set(targetDocument, count - 1);
4257 };
4258 }
4259 function registerStyle11(hash, css) {
4260 const runtime = getRuntime11();
4261 runtime.styles.set(hash, css);
4262 for (const targetDocument of runtime.documents.keys()) {
4263 injectStyle11(targetDocument, hash, css);
4264 }
4265 }
4266 if (typeof process === "undefined" || true) {
4267 registerStyle11("aa9c241ccc", "._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)}}");
4268 }
4269 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" };
4270 function Header3({
4271 headingLevel = 1,
4272 breadcrumbs,
4273 badges,
4274 visual,
4275 title,
4276 subTitle,
4277 actions: actions2,
4278 showSidebarToggle = true
4279 }) {
4280 const HeadingTag = `h${headingLevel}`;
4281 return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "column", className: style_default11.header, children: [
4282 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
4283 Stack,
4284 {
4285 className: style_default11["header-content"],
4286 direction: "row",
4287 gap: "sm",
4288 justify: "space-between",
4289 children: [
4290 /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
4291 showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4292 SidebarToggleSlot,
4293 {
4294 bubblesVirtually: true,
4295 className: style_default11["sidebar-toggle-slot"]
4296 }
4297 ),
4298 visual && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4299 "div",
4300 {
4301 className: style_default11["header-visual"],
4302 "aria-hidden": "true",
4303 children: visual
4304 }
4305 ),
4306 title && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4307 Text,
4308 {
4309 className: style_default11["header-title"],
4310 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(HeadingTag, {}),
4311 variant: "heading-lg",
4312 children: title
4313 }
4314 ),
4315 breadcrumbs,
4316 badges
4317 ] }),
4318 actions2 && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4319 Stack,
4320 {
4321 align: "center",
4322 className: style_default11["header-actions"],
4323 direction: "row",
4324 gap: "sm",
4325 children: actions2
4326 }
4327 )
4328 ]
4329 }
4330 ),
4331 subTitle && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
4332 Text,
4333 {
4334 render: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", {}),
4335 variant: "body-md",
4336 className: style_default11["header-subtitle"],
4337 children: subTitle
4338 }
4339 )
4340 ] });
4341 }
4342
4343 // packages/admin-ui/build-module/page/index.mjs
4344 var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
4345 var STYLE_HASH_ATTRIBUTE12 = "data-wp-hash";
4346 function getRuntime12() {
4347 const globalScope = globalThis;
4348 if (globalScope.__wpStyleRuntime) {
4349 return globalScope.__wpStyleRuntime;
4350 }
4351 globalScope.__wpStyleRuntime = {
4352 documents: /* @__PURE__ */ new Map(),
4353 styles: /* @__PURE__ */ new Map(),
4354 injectedStyles: /* @__PURE__ */ new WeakMap()
4355 };
4356 if (typeof document !== "undefined") {
4357 registerDocument12(document);
4358 }
4359 return globalScope.__wpStyleRuntime;
4360 }
4361 function documentContainsStyleHash12(targetDocument, hash) {
4362 if (!targetDocument.head) {
4363 return false;
4364 }
4365 for (const style of targetDocument.head.querySelectorAll(
4366 `style[${STYLE_HASH_ATTRIBUTE12}]`
4367 )) {
4368 if (style.getAttribute(STYLE_HASH_ATTRIBUTE12) === hash) {
4369 return true;
4370 }
4371 }
4372 return false;
4373 }
4374 function injectStyle12(targetDocument, hash, css) {
4375 if (!targetDocument.head) {
4376 return;
4377 }
4378 const runtime = getRuntime12();
4379 let injectedStyles = runtime.injectedStyles.get(targetDocument);
4380 if (!injectedStyles) {
4381 injectedStyles = /* @__PURE__ */ new Set();
4382 runtime.injectedStyles.set(targetDocument, injectedStyles);
4383 }
4384 if (injectedStyles.has(hash)) {
4385 return;
4386 }
4387 if (documentContainsStyleHash12(targetDocument, hash)) {
4388 injectedStyles.add(hash);
4389 return;
4390 }
4391 const style = targetDocument.createElement("style");
4392 style.setAttribute(STYLE_HASH_ATTRIBUTE12, hash);
4393 style.appendChild(targetDocument.createTextNode(css));
4394 targetDocument.head.appendChild(style);
4395 injectedStyles.add(hash);
4396 }
4397 function registerDocument12(targetDocument) {
4398 const runtime = getRuntime12();
4399 runtime.documents.set(
4400 targetDocument,
4401 (runtime.documents.get(targetDocument) ?? 0) + 1
4402 );
4403 for (const [hash, css] of runtime.styles) {
4404 injectStyle12(targetDocument, hash, css);
4405 }
4406 return () => {
4407 const count = runtime.documents.get(targetDocument);
4408 if (count === void 0) {
4409 return;
4410 }
4411 if (count <= 1) {
4412 runtime.documents.delete(targetDocument);
4413 return;
4414 }
4415 runtime.documents.set(targetDocument, count - 1);
4416 };
4417 }
4418 function registerStyle12(hash, css) {
4419 const runtime = getRuntime12();
4420 runtime.styles.set(hash, css);
4421 for (const targetDocument of runtime.documents.keys()) {
4422 injectStyle12(targetDocument, hash, css);
4423 }
4424 }
4425 if (typeof process === "undefined" || true) {
4426 registerStyle12("aa9c241ccc", "._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)}}");
4427 }
4428 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" };
4429 function Page({
4430 headingLevel,
4431 breadcrumbs,
4432 badges,
4433 visual,
4434 title,
4435 subTitle,
4436 children,
4437 className,
4438 actions: actions2,
4439 ariaLabel,
4440 hasPadding = false,
4441 showSidebarToggle = true
4442 }) {
4443 const classes = clsx_default(style_default12.page, className);
4444 const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
4445 return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
4446 (title || breadcrumbs || badges || actions2 || visual) && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4447 Header3,
4448 {
4449 headingLevel,
4450 breadcrumbs,
4451 badges,
4452 visual,
4453 title,
4454 subTitle,
4455 actions: actions2,
4456 showSidebarToggle
4457 }
4458 ),
4459 hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
4460 "div",
4461 {
4462 className: clsx_default(
4463 style_default12.content,
4464 style_default12["has-padding"]
4465 ),
4466 children
4467 }
4468 ) : children
4469 ] });
4470 }
4471 Page.SidebarToggleFill = SidebarToggleFill;
4472 var page_default = Page;
4473
4474 // routes/guidelines/stage.tsx
4475 var import_i18n55 = __toESM(require_i18n());
4476 var import_element93 = __toESM(require_element());
4477 var import_components59 = __toESM(require_components());
4478
4479 // routes/guidelines/style.scss
4480 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='15b2061f96']")) {
4481 const style = document.createElement("style");
4482 style.setAttribute("data-wp-hash", "15b2061f96");
4483 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}"));
4484 document.head.appendChild(style);
4485 }
4486
4487 // routes/guidelines/components/guideline-accordion.tsx
4488 var import_components2 = __toESM(require_components());
4489 function GuidelineAccordion({
4490 title,
4491 description,
4492 children
4493 }) {
4494 return /* @__PURE__ */ React.createElement(collapsible_card_exports.Root, null, /* @__PURE__ */ React.createElement(collapsible_card_exports.Header, { render: /* @__PURE__ */ React.createElement("h2", null) }, /* @__PURE__ */ React.createElement(import_components2.__experimentalVStack, { spacing: 1 }, /* @__PURE__ */ React.createElement(card_exports.Title, null, title), /* @__PURE__ */ React.createElement(collapsible_card_exports.HeaderDescription, null, /* @__PURE__ */ React.createElement(import_components2.__experimentalText, { variant: "muted" }, description)))), /* @__PURE__ */ React.createElement(collapsible_card_exports.Content, null, children));
4495 }
4496
4497 // routes/guidelines/components/guideline-accordion-form.tsx
4498 var import_components53 = __toESM(require_components());
4499
4500 // packages/dataviews/build-module/dataviews/index.mjs
4501 var import_element75 = __toESM(require_element(), 1);
4502 var import_compose12 = __toESM(require_compose(), 1);
4503
4504 // packages/dataviews/build-module/components/dataviews-context/index.mjs
4505 var import_element20 = __toESM(require_element(), 1);
4506
4507 // packages/dataviews/build-module/constants.mjs
4508 var import_i18n = __toESM(require_i18n(), 1);
4509 var OPERATOR_IS_ANY = "isAny";
4510 var OPERATOR_IS_NONE = "isNone";
4511 var OPERATOR_IS_ALL = "isAll";
4512 var OPERATOR_IS_NOT_ALL = "isNotAll";
4513 var OPERATOR_BETWEEN = "between";
4514 var OPERATOR_IN_THE_PAST = "inThePast";
4515 var OPERATOR_OVER = "over";
4516 var OPERATOR_IS = "is";
4517 var OPERATOR_IS_NOT = "isNot";
4518 var OPERATOR_LESS_THAN = "lessThan";
4519 var OPERATOR_GREATER_THAN = "greaterThan";
4520 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual";
4521 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual";
4522 var OPERATOR_BEFORE = "before";
4523 var OPERATOR_AFTER = "after";
4524 var OPERATOR_BEFORE_INC = "beforeInc";
4525 var OPERATOR_AFTER_INC = "afterInc";
4526 var OPERATOR_CONTAINS = "contains";
4527 var OPERATOR_NOT_CONTAINS = "notContains";
4528 var OPERATOR_STARTS_WITH = "startsWith";
4529 var OPERATOR_ON = "on";
4530 var OPERATOR_NOT_ON = "notOn";
4531 var SORTING_DIRECTIONS = ["asc", "desc"];
4532 var sortArrows = { asc: "\u2191", desc: "\u2193" };
4533 var sortValues = { asc: "ascending", desc: "descending" };
4534 var sortLabels = {
4535 asc: (0, import_i18n.__)("Sort ascending"),
4536 desc: (0, import_i18n.__)("Sort descending")
4537 };
4538 var sortIcons = {
4539 asc: arrow_up_default,
4540 desc: arrow_down_default
4541 };
4542 var LAYOUT_TABLE = "table";
4543 var LAYOUT_GRID = "grid";
4544 var LAYOUT_LIST = "list";
4545 var LAYOUT_ACTIVITY = "activity";
4546 var LAYOUT_PICKER_GRID = "pickerGrid";
4547 var LAYOUT_PICKER_TABLE = "pickerTable";
4548
4549 // packages/dataviews/build-module/components/dataviews-context/index.mjs
4550 var DataViewsContext = (0, import_element20.createContext)({
4551 view: { type: LAYOUT_TABLE },
4552 onChangeView: () => {
4553 },
4554 fields: [],
4555 data: [],
4556 paginationInfo: {
4557 totalItems: 0,
4558 totalPages: 0
4559 },
4560 selection: [],
4561 onChangeSelection: () => {
4562 },
4563 setOpenedFilter: () => {
4564 },
4565 openedFilter: null,
4566 getItemId: (item) => item.id,
4567 isItemClickable: () => true,
4568 renderItemLink: void 0,
4569 containerWidth: 0,
4570 containerRef: (0, import_element20.createRef)(),
4571 resizeObserverRef: () => {
4572 },
4573 defaultLayouts: { list: {}, grid: {}, table: {} },
4574 filters: [],
4575 isShowingFilter: false,
4576 setIsShowingFilter: () => {
4577 },
4578 hasInitiallyLoaded: false,
4579 config: {
4580 perPageSizes: []
4581 },
4582 intersectionObserver: null
4583 });
4584 DataViewsContext.displayName = "DataViewsContext";
4585 var dataviews_context_default = DataViewsContext;
4586
4587 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
4588 var import_i18n21 = __toESM(require_i18n(), 1);
4589
4590 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
4591 var import_i18n9 = __toESM(require_i18n(), 1);
4592 var import_components8 = __toESM(require_components(), 1);
4593 var import_element28 = __toESM(require_element(), 1);
4594 var import_keycodes = __toESM(require_keycodes(), 1);
4595
4596 // packages/dataviews/build-module/components/dataviews-selection-checkbox/index.mjs
4597 var import_components3 = __toESM(require_components(), 1);
4598 var import_i18n2 = __toESM(require_i18n(), 1);
4599 var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
4600 function DataViewsSelectionCheckbox({
4601 selection,
4602 onChangeSelection,
4603 item,
4604 getItemId,
4605 titleField,
4606 disabled: disabled2,
4607 ...extraProps
4608 }) {
4609 const id = getItemId(item);
4610 const isInSelectionArray = selection.includes(id);
4611 const checked = !disabled2 && isInSelectionArray;
4612 const selectionLabel = titleField?.getValue?.({ item }) || (0, import_i18n2.__)("(no title)");
4613 return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
4614 import_components3.CheckboxControl,
4615 {
4616 className: "dataviews-selection-checkbox",
4617 "aria-label": selectionLabel,
4618 "aria-disabled": disabled2,
4619 checked,
4620 onChange: () => {
4621 if (disabled2) {
4622 return;
4623 }
4624 onChangeSelection(
4625 isInSelectionArray ? selection.filter((itemId) => id !== itemId) : [...selection, id]
4626 );
4627 },
4628 ...extraProps
4629 }
4630 );
4631 }
4632
4633 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
4634 var import_components4 = __toESM(require_components(), 1);
4635 var import_i18n3 = __toESM(require_i18n(), 1);
4636 var import_element21 = __toESM(require_element(), 1);
4637 var import_data = __toESM(require_data(), 1);
4638 var import_compose = __toESM(require_compose(), 1);
4639
4640 // packages/dataviews/build-module/lock-unlock.mjs
4641 var import_private_apis = __toESM(require_private_apis(), 1);
4642 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
4643 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
4644 "@wordpress/dataviews"
4645 );
4646
4647 // packages/dataviews/build-module/components/dataviews-item-actions/index.mjs
4648 var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
4649 var { Menu, kebabCase } = unlock(import_components4.privateApis);
4650 function ButtonTrigger({
4651 action,
4652 onClick,
4653 items,
4654 variant
4655 }) {
4656 const label = typeof action.label === "string" ? action.label : action.label(items);
4657 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4658 import_components4.Button,
4659 {
4660 disabled: !!action.disabled,
4661 accessibleWhenDisabled: true,
4662 size: "compact",
4663 variant,
4664 onClick,
4665 children: label
4666 }
4667 );
4668 }
4669 function MenuItemTrigger({
4670 action,
4671 onClick,
4672 items
4673 }) {
4674 const label = typeof action.label === "string" ? action.label : action.label(items);
4675 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Item, { disabled: action.disabled, onClick, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.ItemLabel, { children: label }) });
4676 }
4677 function ActionModal({
4678 action,
4679 items,
4680 closeModal
4681 }) {
4682 const label = typeof action.label === "string" ? action.label : action.label(items);
4683 const modalHeader = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
4684 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4685 import_components4.Modal,
4686 {
4687 title: modalHeader || label,
4688 __experimentalHideHeader: !!action.hideModalHeader,
4689 onRequestClose: closeModal,
4690 focusOnMount: action.modalFocusOnMount ?? true,
4691 size: action.modalSize || "medium",
4692 overlayClassName: `dataviews-action-modal dataviews-action-modal__${kebabCase(
4693 action.id
4694 )}`,
4695 children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(action.RenderModal, { items, closeModal })
4696 }
4697 );
4698 }
4699 function ActionsMenuGroup({
4700 actions: actions2,
4701 item,
4702 registry,
4703 setActiveModalAction
4704 }) {
4705 const { primaryActions, regularActions } = (0, import_element21.useMemo)(() => {
4706 return actions2.reduce(
4707 (acc, action) => {
4708 (action.isPrimary ? acc.primaryActions : acc.regularActions).push(action);
4709 return acc;
4710 },
4711 {
4712 primaryActions: [],
4713 regularActions: []
4714 }
4715 );
4716 }, [actions2]);
4717 const renderActionGroup = (actionList) => actionList.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4718 MenuItemTrigger,
4719 {
4720 action,
4721 onClick: () => {
4722 if ("RenderModal" in action) {
4723 setActiveModalAction(action);
4724 return;
4725 }
4726 action.callback([item], { registry });
4727 },
4728 items: [item]
4729 },
4730 action.id
4731 ));
4732 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu.Group, { children: [
4733 renderActionGroup(primaryActions),
4734 renderActionGroup(regularActions)
4735 ] });
4736 }
4737 function ItemActions({
4738 item,
4739 actions: actions2,
4740 isCompact
4741 }) {
4742 const registry = (0, import_data.useRegistry)();
4743 const { primaryActions, eligibleActions } = (0, import_element21.useMemo)(() => {
4744 const _eligibleActions = actions2.filter(
4745 (action) => !action.isEligible || action.isEligible(item)
4746 );
4747 const _primaryActions = _eligibleActions.filter(
4748 (action) => action.isPrimary
4749 );
4750 return {
4751 primaryActions: _primaryActions,
4752 eligibleActions: _eligibleActions
4753 };
4754 }, [actions2, item]);
4755 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
4756 if (isCompact) {
4757 return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4758 CompactItemActions,
4759 {
4760 item,
4761 actions: eligibleActions,
4762 isSmall: true,
4763 registry
4764 }
4765 );
4766 }
4767 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
4768 Stack,
4769 {
4770 direction: "row",
4771 justify: "flex-end",
4772 className: "dataviews-item-actions",
4773 style: {
4774 flexShrink: 0,
4775 width: "auto"
4776 },
4777 children: [
4778 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4779 PrimaryActions,
4780 {
4781 item,
4782 actions: primaryActions,
4783 registry
4784 }
4785 ),
4786 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
4787 // there if there are any actions at all.
4788 isMobileViewport) && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4789 CompactItemActions,
4790 {
4791 item,
4792 actions: eligibleActions,
4793 registry
4794 }
4795 )
4796 ]
4797 }
4798 );
4799 }
4800 function CompactItemActions({
4801 item,
4802 actions: actions2,
4803 isSmall,
4804 registry
4805 }) {
4806 const [activeModalAction, setActiveModalAction] = (0, import_element21.useState)(
4807 null
4808 );
4809 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4810 /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(Menu, { placement: "bottom-end", children: [
4811 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4812 Menu.TriggerButton,
4813 {
4814 render: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4815 import_components4.Button,
4816 {
4817 size: isSmall ? "small" : "compact",
4818 icon: more_vertical_default,
4819 label: (0, import_i18n3.__)("Actions"),
4820 accessibleWhenDisabled: true,
4821 disabled: !actions2.length,
4822 className: "dataviews-all-actions-button"
4823 }
4824 )
4825 }
4826 ),
4827 /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Menu.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4828 ActionsMenuGroup,
4829 {
4830 actions: actions2,
4831 item,
4832 registry,
4833 setActiveModalAction
4834 }
4835 ) })
4836 ] }),
4837 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4838 ActionModal,
4839 {
4840 action: activeModalAction,
4841 items: [item],
4842 closeModal: () => setActiveModalAction(null)
4843 }
4844 )
4845 ] });
4846 }
4847 function PrimaryActions({
4848 item,
4849 actions: actions2,
4850 registry,
4851 buttonVariant
4852 }) {
4853 const [activeModalAction, setActiveModalAction] = (0, import_element21.useState)(null);
4854 const isMobileViewport = (0, import_compose.useViewportMatch)("medium", "<");
4855 if (isMobileViewport) {
4856 return null;
4857 }
4858 if (!Array.isArray(actions2) || actions2.length === 0) {
4859 return null;
4860 }
4861 return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
4862 actions2.map((action) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4863 ButtonTrigger,
4864 {
4865 action,
4866 onClick: () => {
4867 if ("RenderModal" in action) {
4868 setActiveModalAction(action);
4869 return;
4870 }
4871 action.callback([item], { registry });
4872 },
4873 items: [item],
4874 variant: buttonVariant
4875 },
4876 action.id
4877 )),
4878 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
4879 ActionModal,
4880 {
4881 action: activeModalAction,
4882 items: [item],
4883 closeModal: () => setActiveModalAction(null)
4884 }
4885 )
4886 ] });
4887 }
4888
4889 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
4890 var import_components5 = __toESM(require_components(), 1);
4891 var import_i18n5 = __toESM(require_i18n(), 1);
4892 var import_element22 = __toESM(require_element(), 1);
4893 var import_data2 = __toESM(require_data(), 1);
4894 var import_compose2 = __toESM(require_compose(), 1);
4895
4896 // packages/dataviews/build-module/utils/get-footer-message.mjs
4897 var import_i18n4 = __toESM(require_i18n(), 1);
4898 function getFooterMessage(selectionCount, itemsCount, totalItems, onlyTotalCount = false) {
4899 if (selectionCount > 0) {
4900 return (0, import_i18n4.sprintf)(
4901 /* translators: %d: number of items. */
4902 (0, import_i18n4._n)("%d Item selected", "%d Items selected", selectionCount),
4903 selectionCount
4904 );
4905 }
4906 if (onlyTotalCount || totalItems <= itemsCount) {
4907 return (0, import_i18n4.sprintf)(
4908 /* translators: %d: number of items. */
4909 (0, import_i18n4._n)("%d Item", "%d Items", totalItems),
4910 totalItems
4911 );
4912 }
4913 return (0, import_i18n4.sprintf)(
4914 /* translators: %1$d: number of items. %2$d: total number of items. */
4915 (0, import_i18n4._n)("%1$d of %2$d Item", "%1$d of %2$d Items", totalItems),
4916 itemsCount,
4917 totalItems
4918 );
4919 }
4920
4921 // packages/dataviews/build-module/components/dataviews-bulk-actions/index.mjs
4922 var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
4923 function ActionWithModal({
4924 action,
4925 items,
4926 ActionTriggerComponent
4927 }) {
4928 const [isModalOpen, setIsModalOpen] = (0, import_element22.useState)(false);
4929 const actionTriggerProps = {
4930 action,
4931 onClick: () => {
4932 setIsModalOpen(true);
4933 },
4934 items
4935 };
4936 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
4937 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(ActionTriggerComponent, { ...actionTriggerProps }),
4938 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4939 ActionModal,
4940 {
4941 action,
4942 items,
4943 closeModal: () => setIsModalOpen(false)
4944 }
4945 )
4946 ] });
4947 }
4948 function useHasAPossibleBulkAction(actions2, item) {
4949 return (0, import_element22.useMemo)(() => {
4950 return actions2.some((action) => {
4951 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4952 });
4953 }, [actions2, item]);
4954 }
4955 function useSomeItemHasAPossibleBulkAction(actions2, data) {
4956 return (0, import_element22.useMemo)(() => {
4957 return data.some((item) => {
4958 return actions2.some((action) => {
4959 return action.supportsBulk && (!action.isEligible || action.isEligible(item));
4960 });
4961 });
4962 }, [actions2, data]);
4963 }
4964 function BulkSelectionCheckbox({
4965 selection,
4966 onChangeSelection,
4967 data,
4968 actions: actions2,
4969 getItemId,
4970 disableSelectAll = false
4971 }) {
4972 const selectableItems = (0, import_element22.useMemo)(() => {
4973 return data.filter((item) => {
4974 return actions2.some(
4975 (action) => action.supportsBulk && (!action.isEligible || action.isEligible(item))
4976 );
4977 });
4978 }, [data, actions2]);
4979 const selectedItems = data.filter(
4980 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
4981 );
4982 const hasSelection = selection.length > 0;
4983 const areAllSelected = selectedItems.length === selectableItems.length;
4984 if (disableSelectAll) {
4985 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4986 import_components5.CheckboxControl,
4987 {
4988 className: "dataviews-view-table-selection-checkbox",
4989 checked: hasSelection,
4990 disabled: !hasSelection,
4991 onChange: () => {
4992 onChangeSelection([]);
4993 },
4994 "aria-label": (0, import_i18n5.__)("Deselect all")
4995 }
4996 );
4997 }
4998 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
4999 import_components5.CheckboxControl,
5000 {
5001 className: "dataviews-view-table-selection-checkbox",
5002 checked: areAllSelected,
5003 indeterminate: !areAllSelected && !!selectedItems.length,
5004 onChange: () => {
5005 if (areAllSelected) {
5006 onChangeSelection([]);
5007 } else {
5008 onChangeSelection(
5009 selectableItems.map((item) => getItemId(item))
5010 );
5011 }
5012 },
5013 "aria-label": areAllSelected ? (0, import_i18n5.__)("Deselect all") : (0, import_i18n5.__)("Select all")
5014 }
5015 );
5016 }
5017 function ActionTrigger({
5018 action,
5019 onClick,
5020 isBusy,
5021 items
5022 }) {
5023 const label = typeof action.label === "string" ? action.label : action.label(items);
5024 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
5025 if (isMobile) {
5026 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5027 import_components5.Button,
5028 {
5029 disabled: isBusy,
5030 accessibleWhenDisabled: true,
5031 label,
5032 icon: action.icon,
5033 size: "compact",
5034 onClick,
5035 isBusy
5036 }
5037 );
5038 }
5039 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5040 import_components5.Button,
5041 {
5042 disabled: isBusy,
5043 accessibleWhenDisabled: true,
5044 size: "compact",
5045 onClick,
5046 isBusy,
5047 children: label
5048 }
5049 );
5050 }
5051 var EMPTY_ARRAY2 = [];
5052 function ActionButton({
5053 action,
5054 selectedItems,
5055 actionInProgress,
5056 setActionInProgress
5057 }) {
5058 const registry = (0, import_data2.useRegistry)();
5059 const selectedEligibleItems = (0, import_element22.useMemo)(() => {
5060 return selectedItems.filter((item) => {
5061 return !action.isEligible || action.isEligible(item);
5062 });
5063 }, [action, selectedItems]);
5064 if ("RenderModal" in action) {
5065 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5066 ActionWithModal,
5067 {
5068 action,
5069 items: selectedEligibleItems,
5070 ActionTriggerComponent: ActionTrigger
5071 },
5072 action.id
5073 );
5074 }
5075 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5076 ActionTrigger,
5077 {
5078 action,
5079 onClick: async () => {
5080 setActionInProgress(action.id);
5081 await action.callback(selectedItems, {
5082 registry
5083 });
5084 setActionInProgress(null);
5085 },
5086 items: selectedEligibleItems,
5087 isBusy: actionInProgress === action.id
5088 },
5089 action.id
5090 );
5091 }
5092 function renderFooterContent(data, actions2, getItemId, isInfiniteScroll, selection, actionsToShow, selectedItems, actionInProgress, setActionInProgress, onChangeSelection, paginationInfo) {
5093 const message2 = getFooterMessage(
5094 selection.length,
5095 data.length,
5096 paginationInfo.totalItems,
5097 isInfiniteScroll
5098 );
5099 return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5100 Stack,
5101 {
5102 direction: "row",
5103 className: "dataviews-bulk-actions-footer__container",
5104 gap: "md",
5105 align: "center",
5106 children: [
5107 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5108 BulkSelectionCheckbox,
5109 {
5110 selection,
5111 onChangeSelection,
5112 data,
5113 actions: actions2,
5114 getItemId,
5115 disableSelectAll: isInfiniteScroll
5116 }
5117 ),
5118 /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "dataviews-bulk-actions-footer__item-count", children: message2 }),
5119 /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
5120 Stack,
5121 {
5122 direction: "row",
5123 className: "dataviews-bulk-actions-footer__action-buttons",
5124 gap: "xs",
5125 children: [
5126 actionsToShow.map((action) => {
5127 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5128 ActionButton,
5129 {
5130 action,
5131 selectedItems,
5132 actionInProgress,
5133 setActionInProgress
5134 },
5135 action.id
5136 );
5137 }),
5138 selectedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5139 import_components5.Button,
5140 {
5141 icon: close_small_default,
5142 showTooltip: true,
5143 tooltipPosition: "top",
5144 size: "compact",
5145 label: (0, import_i18n5.__)("Cancel"),
5146 disabled: !!actionInProgress,
5147 accessibleWhenDisabled: false,
5148 onClick: () => {
5149 onChangeSelection(EMPTY_ARRAY2);
5150 }
5151 }
5152 )
5153 ]
5154 }
5155 )
5156 ]
5157 }
5158 );
5159 }
5160 function FooterContent({
5161 selection,
5162 actions: actions2,
5163 onChangeSelection,
5164 data,
5165 getItemId,
5166 isInfiniteScroll,
5167 paginationInfo
5168 }) {
5169 const [actionInProgress, setActionInProgress] = (0, import_element22.useState)(
5170 null
5171 );
5172 const footerContentRef = (0, import_element22.useRef)(void 0);
5173 const isMobile = (0, import_compose2.useViewportMatch)("medium", "<");
5174 const bulkActions = (0, import_element22.useMemo)(
5175 () => actions2.filter((action) => action.supportsBulk),
5176 [actions2]
5177 );
5178 const selectableItems = (0, import_element22.useMemo)(() => {
5179 return data.filter((item) => {
5180 return bulkActions.some(
5181 (action) => !action.isEligible || action.isEligible(item)
5182 );
5183 });
5184 }, [data, bulkActions]);
5185 const selectedItems = (0, import_element22.useMemo)(() => {
5186 return data.filter(
5187 (item) => selection.includes(getItemId(item)) && selectableItems.includes(item)
5188 );
5189 }, [selection, data, getItemId, selectableItems]);
5190 const actionsToShow = (0, import_element22.useMemo)(
5191 () => actions2.filter((action) => {
5192 return action.supportsBulk && (!isMobile || action.icon) && selectedItems.some(
5193 (item) => !action.isEligible || action.isEligible(item)
5194 );
5195 }),
5196 [actions2, selectedItems, isMobile]
5197 );
5198 if (!actionInProgress) {
5199 if (footerContentRef.current) {
5200 footerContentRef.current = void 0;
5201 }
5202 return renderFooterContent(
5203 data,
5204 actions2,
5205 getItemId,
5206 isInfiniteScroll,
5207 selection,
5208 actionsToShow,
5209 selectedItems,
5210 actionInProgress,
5211 setActionInProgress,
5212 onChangeSelection,
5213 paginationInfo
5214 );
5215 } else if (!footerContentRef.current) {
5216 footerContentRef.current = renderFooterContent(
5217 data,
5218 actions2,
5219 getItemId,
5220 isInfiniteScroll,
5221 selection,
5222 actionsToShow,
5223 selectedItems,
5224 actionInProgress,
5225 setActionInProgress,
5226 onChangeSelection,
5227 paginationInfo
5228 );
5229 }
5230 return footerContentRef.current;
5231 }
5232 function BulkActionsFooter() {
5233 const {
5234 data,
5235 selection,
5236 actions: actions2 = EMPTY_ARRAY2,
5237 onChangeSelection,
5238 getItemId,
5239 paginationInfo,
5240 view
5241 } = (0, import_element22.useContext)(dataviews_context_default);
5242 return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
5243 FooterContent,
5244 {
5245 selection,
5246 onChangeSelection,
5247 data,
5248 actions: actions2,
5249 getItemId,
5250 isInfiniteScroll: !!view.infiniteScrollEnabled,
5251 paginationInfo
5252 }
5253 );
5254 }
5255
5256 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
5257 var import_i18n6 = __toESM(require_i18n(), 1);
5258 var import_components6 = __toESM(require_components(), 1);
5259 var import_element23 = __toESM(require_element(), 1);
5260
5261 // packages/dataviews/build-module/utils/get-hideable-fields.mjs
5262 function getHideableFields(view, fields2) {
5263 const togglableFields = [
5264 view?.titleField,
5265 view?.mediaField,
5266 view?.descriptionField
5267 ].filter(Boolean);
5268 return fields2.filter(
5269 (f2) => !togglableFields.includes(f2.id) && f2.type !== "media" && f2.enableHiding !== false
5270 );
5271 }
5272
5273 // packages/dataviews/build-module/components/dataviews-layouts/table/column-header-menu.mjs
5274 var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
5275 var { Menu: Menu2 } = unlock(import_components6.privateApis);
5276 function WithMenuSeparators({ children }) {
5277 return import_element23.Children.toArray(children).filter(Boolean).map((child, i2) => /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_element23.Fragment, { children: [
5278 i2 > 0 && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Separator, {}),
5279 child
5280 ] }, i2));
5281 }
5282 var _HeaderMenu = (0, import_element23.forwardRef)(function HeaderMenu({
5283 fieldId,
5284 view,
5285 fields: fields2,
5286 onChangeView,
5287 onHide,
5288 setOpenedFilter,
5289 canMove = true,
5290 canInsertLeft = true,
5291 canInsertRight = true
5292 }, ref) {
5293 const visibleFieldIds = view.fields ?? [];
5294 const index = visibleFieldIds?.indexOf(fieldId);
5295 const isSorted = view.sort?.field === fieldId;
5296 let isHidable = false;
5297 let isSortable = false;
5298 let canAddFilter = false;
5299 let operators = [];
5300 const field = fields2.find((f2) => f2.id === fieldId);
5301 const { setIsShowingFilter } = (0, import_element23.useContext)(dataviews_context_default);
5302 if (!field) {
5303 return null;
5304 }
5305 isHidable = field.enableHiding !== false;
5306 isSortable = field.enableSorting !== false;
5307 const header = field.header;
5308 operators = !!field.filterBy && field.filterBy?.operators || [];
5309 canAddFilter = !view.filters?.some((_filter) => fieldId === _filter.field) && !!(field.hasElements || field.Edit) && field.filterBy !== false && !field.filterBy?.isPrimary;
5310 if (!isSortable && !canMove && !isHidable && !canAddFilter) {
5311 return header;
5312 }
5313 const hiddenFields = getHideableFields(view, fields2).filter(
5314 (f2) => !visibleFieldIds.includes(f2.id)
5315 );
5316 const canInsert = (canInsertLeft || canInsertRight) && !!hiddenFields.length;
5317 const isRtl = (0, import_i18n6.isRTL)();
5318 return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
5319 /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
5320 Menu2.TriggerButton,
5321 {
5322 render: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5323 import_components6.Button,
5324 {
5325 size: "compact",
5326 className: "dataviews-view-table-header-button",
5327 ref,
5328 variant: "tertiary"
5329 }
5330 ),
5331 children: [
5332 header,
5333 view.sort && isSorted && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { "aria-hidden": "true", children: sortArrows[view.sort.direction] })
5334 ]
5335 }
5336 ),
5337 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { style: { minWidth: "240px" }, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(WithMenuSeparators, { children: [
5338 isSortable && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: SORTING_DIRECTIONS.map(
5339 (direction) => {
5340 const isChecked = view.sort && isSorted && view.sort.direction === direction;
5341 const value = `${fieldId}-${direction}`;
5342 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5343 Menu2.RadioItem,
5344 {
5345 name: "view-table-sorting",
5346 value,
5347 checked: isChecked,
5348 onChange: () => {
5349 onChangeView({
5350 ...view,
5351 sort: {
5352 field: fieldId,
5353 direction
5354 },
5355 showLevels: false
5356 });
5357 },
5358 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: sortLabels[direction] })
5359 },
5360 value
5361 );
5362 }
5363 ) }),
5364 canAddFilter && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5365 Menu2.Item,
5366 {
5367 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: funnel_default }),
5368 onClick: () => {
5369 setOpenedFilter(fieldId);
5370 setIsShowingFilter(true);
5371 onChangeView({
5372 ...view,
5373 page: 1,
5374 filters: [
5375 ...view.filters || [],
5376 {
5377 field: fieldId,
5378 value: void 0,
5379 operator: operators[0]
5380 }
5381 ]
5382 });
5383 },
5384 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Add filter") })
5385 }
5386 ) }),
5387 (canMove || isHidable || canInsert) && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2.Group, { children: [
5388 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5389 Menu2.Item,
5390 {
5391 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_left_default }),
5392 disabled: isRtl ? index >= visibleFieldIds.length - 1 : index < 1,
5393 onClick: () => {
5394 const targetIndex = isRtl ? index + 1 : index - 1;
5395 const newFields = [
5396 ...visibleFieldIds
5397 ];
5398 newFields.splice(index, 1);
5399 newFields.splice(
5400 targetIndex,
5401 0,
5402 fieldId
5403 );
5404 onChangeView({
5405 ...view,
5406 fields: newFields
5407 });
5408 },
5409 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move left") })
5410 }
5411 ),
5412 canMove && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5413 Menu2.Item,
5414 {
5415 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: arrow_right_default }),
5416 disabled: isRtl ? index < 1 : index >= visibleFieldIds.length - 1,
5417 onClick: () => {
5418 const targetIndex = isRtl ? index - 1 : index + 1;
5419 const newFields = [
5420 ...visibleFieldIds
5421 ];
5422 newFields.splice(index, 1);
5423 newFields.splice(
5424 targetIndex,
5425 0,
5426 fieldId
5427 );
5428 onChangeView({
5429 ...view,
5430 fields: newFields
5431 });
5432 },
5433 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Move right") })
5434 }
5435 ),
5436 canInsertLeft && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
5437 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert left") }) }),
5438 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
5439 const insertIndex = isRtl ? index + 1 : index;
5440 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5441 Menu2.Item,
5442 {
5443 onClick: () => {
5444 onChangeView({
5445 ...view,
5446 fields: [
5447 ...visibleFieldIds.slice(
5448 0,
5449 insertIndex
5450 ),
5451 hiddenField.id,
5452 ...visibleFieldIds.slice(
5453 insertIndex
5454 )
5455 ]
5456 });
5457 },
5458 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
5459 },
5460 hiddenField.id
5461 );
5462 }) })
5463 ] }),
5464 canInsertRight && !!hiddenFields.length && /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(Menu2, { children: [
5465 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Insert right") }) }),
5466 /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.Popover, { children: hiddenFields.map((hiddenField) => {
5467 const insertIndex = isRtl ? index : index + 1;
5468 return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5469 Menu2.Item,
5470 {
5471 onClick: () => {
5472 onChangeView({
5473 ...view,
5474 fields: [
5475 ...visibleFieldIds.slice(
5476 0,
5477 insertIndex
5478 ),
5479 hiddenField.id,
5480 ...visibleFieldIds.slice(
5481 insertIndex
5482 )
5483 ]
5484 });
5485 },
5486 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: hiddenField.label })
5487 },
5488 hiddenField.id
5489 );
5490 }) })
5491 ] }),
5492 isHidable && field && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
5493 Menu2.Item,
5494 {
5495 prefix: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_components6.Icon, { icon: unseen_default }),
5496 onClick: () => {
5497 onHide(field);
5498 onChangeView({
5499 ...view,
5500 fields: visibleFieldIds.filter(
5501 (id) => id !== fieldId
5502 )
5503 });
5504 },
5505 children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(Menu2.ItemLabel, { children: (0, import_i18n6.__)("Hide column") })
5506 }
5507 )
5508 ] })
5509 ] }) })
5510 ] });
5511 });
5512 var ColumnHeaderMenu = _HeaderMenu;
5513 var column_header_menu_default = ColumnHeaderMenu;
5514
5515 // packages/dataviews/build-module/components/dataviews-layouts/utils/item-click-wrapper.mjs
5516 var import_element24 = __toESM(require_element(), 1);
5517 var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
5518 function getClickableItemProps({
5519 item,
5520 isItemClickable,
5521 onClickItem,
5522 className
5523 }) {
5524 if (!isItemClickable(item) || !onClickItem) {
5525 return { className };
5526 }
5527 return {
5528 className: className ? `${className} ${className}--clickable` : void 0,
5529 role: "button",
5530 tabIndex: 0,
5531 onClick: (event) => {
5532 event.stopPropagation();
5533 onClickItem(item);
5534 },
5535 onKeyDown: (event) => {
5536 if (event.key === "Enter" || event.key === "" || event.key === " ") {
5537 event.stopPropagation();
5538 onClickItem(item);
5539 }
5540 }
5541 };
5542 }
5543 function ItemClickWrapper({
5544 item,
5545 isItemClickable,
5546 onClickItem,
5547 renderItemLink,
5548 className,
5549 children,
5550 ...extraProps
5551 }) {
5552 if (!isItemClickable(item)) {
5553 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className, ...extraProps, children });
5554 }
5555 if (renderItemLink) {
5556 const renderedElement = renderItemLink({
5557 item,
5558 className: `${className} ${className}--clickable`,
5559 ...extraProps,
5560 children
5561 });
5562 return (0, import_element24.cloneElement)(renderedElement, {
5563 onClick: (event) => {
5564 event.stopPropagation();
5565 if (renderedElement.props.onClick) {
5566 renderedElement.props.onClick(event);
5567 }
5568 },
5569 onKeyDown: (event) => {
5570 if (event.key === "Enter" || event.key === "" || event.key === " ") {
5571 event.stopPropagation();
5572 if (renderedElement.props.onKeyDown) {
5573 renderedElement.props.onKeyDown(event);
5574 }
5575 }
5576 }
5577 });
5578 }
5579 const clickProps = getClickableItemProps({
5580 item,
5581 isItemClickable,
5582 onClickItem,
5583 className
5584 });
5585 return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { ...clickProps, ...extraProps, children });
5586 }
5587
5588 // packages/dataviews/build-module/components/dataviews-layouts/table/column-primary.mjs
5589 var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
5590 function ColumnPrimary({
5591 item,
5592 level,
5593 titleField,
5594 mediaField,
5595 descriptionField,
5596 onClickItem,
5597 renderItemLink,
5598 isItemClickable
5599 }) {
5600 return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(Stack, { direction: "row", gap: "md", align: "flex-start", justify: "flex-start", children: [
5601 mediaField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5602 ItemClickWrapper,
5603 {
5604 item,
5605 isItemClickable,
5606 onClickItem,
5607 renderItemLink,
5608 className: "dataviews-view-table__cell-content-wrapper dataviews-column-primary__media",
5609 "aria-label": isItemClickable(item) && (!!onClickItem || !!renderItemLink) && !!titleField ? titleField.getValue?.({ item }) : void 0,
5610 children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5611 mediaField.render,
5612 {
5613 item,
5614 field: mediaField,
5615 config: { sizes: "32px" }
5616 }
5617 )
5618 }
5619 ),
5620 /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5621 Stack,
5622 {
5623 direction: "column",
5624 align: "flex-start",
5625 className: "dataviews-view-table__primary-column-content",
5626 children: [
5627 titleField && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
5628 ItemClickWrapper,
5629 {
5630 item,
5631 isItemClickable,
5632 onClickItem,
5633 renderItemLink,
5634 className: "dataviews-view-table__cell-content-wrapper dataviews-title-field",
5635 children: [
5636 level !== void 0 && level > 0 && /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("span", { className: "dataviews-view-table__level", children: [
5637 Array(level).fill("\u2014").join(" "),
5638 "\xA0"
5639 ] }),
5640 /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(titleField.render, { item, field: titleField })
5641 ]
5642 }
5643 ),
5644 descriptionField && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
5645 descriptionField.render,
5646 {
5647 item,
5648 field: descriptionField
5649 }
5650 )
5651 ]
5652 }
5653 )
5654 ] });
5655 }
5656 var column_primary_default = ColumnPrimary;
5657
5658 // packages/dataviews/build-module/components/dataviews-layouts/table/use-scroll-state.mjs
5659 var import_element25 = __toESM(require_element(), 1);
5660 var import_i18n7 = __toESM(require_i18n(), 1);
5661 var isScrolledToEnd = (element) => {
5662 if ((0, import_i18n7.isRTL)()) {
5663 const scrollLeft = Math.abs(element.scrollLeft);
5664 return scrollLeft <= 1;
5665 }
5666 return element.scrollLeft + element.clientWidth >= element.scrollWidth - 1;
5667 };
5668 function useScrollState({
5669 scrollContainerRef,
5670 enabledHorizontal = false
5671 }) {
5672 const [isHorizontalScrollEnd, setIsHorizontalScrollEnd] = (0, import_element25.useState)(false);
5673 const [isVerticallyScrolled, setIsVerticallyScrolled] = (0, import_element25.useState)(false);
5674 const handleScroll = (0, import_element25.useCallback)(() => {
5675 const scrollContainer = scrollContainerRef.current;
5676 if (!scrollContainer) {
5677 return;
5678 }
5679 if (enabledHorizontal) {
5680 setIsHorizontalScrollEnd(isScrolledToEnd(scrollContainer));
5681 }
5682 setIsVerticallyScrolled(scrollContainer.scrollTop > 0);
5683 }, [scrollContainerRef, enabledHorizontal]);
5684 (0, import_element25.useEffect)(() => {
5685 if (typeof window === "undefined" || !scrollContainerRef.current) {
5686 return () => {
5687 };
5688 }
5689 const scrollContainer = scrollContainerRef.current;
5690 handleScroll();
5691 scrollContainer.addEventListener("scroll", handleScroll);
5692 window.addEventListener("resize", handleScroll);
5693 return () => {
5694 scrollContainer.removeEventListener("scroll", handleScroll);
5695 window.removeEventListener("resize", handleScroll);
5696 };
5697 }, [scrollContainerRef, enabledHorizontal, handleScroll]);
5698 return { isHorizontalScrollEnd, isVerticallyScrolled };
5699 }
5700
5701 // packages/dataviews/build-module/components/dataviews-layouts/utils/get-data-by-group.mjs
5702 function getDataByGroup(data, groupByField) {
5703 return data.reduce((groups, item) => {
5704 const groupName = groupByField.getValue({ item });
5705 if (!groups.has(groupName)) {
5706 groups.set(groupName, []);
5707 }
5708 groups.get(groupName)?.push(item);
5709 return groups;
5710 }, /* @__PURE__ */ new Map());
5711 }
5712
5713 // packages/dataviews/build-module/components/dataviews-view-config/properties-section.mjs
5714 var import_components7 = __toESM(require_components(), 1);
5715 var import_i18n8 = __toESM(require_i18n(), 1);
5716 var import_element26 = __toESM(require_element(), 1);
5717 var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
5718 function FieldItem({
5719 field,
5720 isVisible: isVisible2,
5721 onToggleVisibility
5722 }) {
5723 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: [
5724 /* @__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 }) }),
5725 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "dataviews-view-config__label", children: field.label })
5726 ] }) });
5727 }
5728 function isDefined(item) {
5729 return !!item;
5730 }
5731 function PropertiesSection({
5732 showLabel = true
5733 }) {
5734 const { view, fields: fields2, onChangeView } = (0, import_element26.useContext)(dataviews_context_default);
5735 const regularFields = getHideableFields(view, fields2);
5736 if (!regularFields?.length) {
5737 return null;
5738 }
5739 const titleField = fields2.find((f2) => f2.id === view.titleField);
5740 const previewField = fields2.find((f2) => f2.id === view.mediaField);
5741 const descriptionField = fields2.find(
5742 (f2) => f2.id === view.descriptionField
5743 );
5744 const lockedFields = [
5745 {
5746 field: titleField,
5747 isVisibleFlag: "showTitle"
5748 },
5749 {
5750 field: previewField,
5751 isVisibleFlag: "showMedia"
5752 },
5753 {
5754 field: descriptionField,
5755 isVisibleFlag: "showDescription"
5756 }
5757 ].filter(({ field }) => isDefined(field));
5758 const visibleFieldIds = view.fields ?? [];
5759 const visibleRegularFieldsCount = regularFields.filter(
5760 (f2) => visibleFieldIds.includes(f2.id)
5761 ).length;
5762 const visibleLockedFields = lockedFields.filter(
5763 ({ isVisibleFlag }) => (
5764 // @ts-expect-error
5765 view[isVisibleFlag] ?? true
5766 )
5767 );
5768 const totalVisibleFields = visibleLockedFields.length + visibleRegularFieldsCount;
5769 const isSingleVisibleLockedField = totalVisibleFields === 1 && visibleLockedFields.length === 1;
5770 return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(Stack, { direction: "column", className: "dataviews-field-control", children: [
5771 showLabel && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components7.BaseControl.VisualLabel, { children: (0, import_i18n8.__)("Properties") }),
5772 /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5773 Stack,
5774 {
5775 direction: "column",
5776 className: "dataviews-view-config__properties",
5777 children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components7.__experimentalItemGroup, { isBordered: true, isSeparated: true, size: "medium", children: [
5778 lockedFields.map(({ field, isVisibleFlag }) => {
5779 const isVisible2 = view[isVisibleFlag] ?? true;
5780 const fieldToRender = isSingleVisibleLockedField && isVisible2 ? { ...field, enableHiding: false } : field;
5781 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5782 FieldItem,
5783 {
5784 field: fieldToRender,
5785 isVisible: isVisible2,
5786 onToggleVisibility: () => {
5787 onChangeView({
5788 ...view,
5789 [isVisibleFlag]: !isVisible2
5790 });
5791 }
5792 },
5793 field.id
5794 );
5795 }),
5796 regularFields.map((field) => {
5797 const isVisible2 = visibleFieldIds.includes(field.id);
5798 const fieldToRender = totalVisibleFields === 1 && isVisible2 ? { ...field, enableHiding: false } : field;
5799 return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
5800 FieldItem,
5801 {
5802 field: fieldToRender,
5803 isVisible: isVisible2,
5804 onToggleVisibility: () => {
5805 onChangeView({
5806 ...view,
5807 fields: isVisible2 ? visibleFieldIds.filter(
5808 (fieldId) => fieldId !== field.id
5809 ) : [...visibleFieldIds, field.id]
5810 });
5811 }
5812 },
5813 field.id
5814 );
5815 })
5816 ] })
5817 }
5818 )
5819 ] });
5820 }
5821
5822 // packages/dataviews/build-module/hooks/use-delayed-loading.mjs
5823 var import_element27 = __toESM(require_element(), 1);
5824 function useDelayedLoading(isLoading, options = { delay: 400 }) {
5825 const [showLoader, setShowLoader] = (0, import_element27.useState)(false);
5826 (0, import_element27.useEffect)(() => {
5827 if (!isLoading) {
5828 return;
5829 }
5830 const timeout = setTimeout(() => {
5831 setShowLoader(true);
5832 }, options.delay);
5833 return () => {
5834 clearTimeout(timeout);
5835 setShowLoader(false);
5836 };
5837 }, [isLoading, options.delay]);
5838 return showLoader;
5839 }
5840
5841 // packages/dataviews/build-module/components/dataviews-layouts/table/index.mjs
5842 var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
5843 function getEffectiveAlign(explicitAlign, fieldType) {
5844 if (explicitAlign) {
5845 return explicitAlign;
5846 }
5847 if (fieldType === "integer" || fieldType === "number") {
5848 return "end";
5849 }
5850 return void 0;
5851 }
5852 function TableColumnField({
5853 item,
5854 fields: fields2,
5855 column,
5856 align
5857 }) {
5858 const field = fields2.find((f2) => f2.id === column);
5859 if (!field) {
5860 return null;
5861 }
5862 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
5863 "dataviews-view-table__cell-align-end": align === "end",
5864 "dataviews-view-table__cell-align-center": align === "center"
5865 });
5866 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(field.render, { item, field }) });
5867 }
5868 function TableRow({
5869 hasBulkActions,
5870 item,
5871 level,
5872 actions: actions2,
5873 fields: fields2,
5874 id,
5875 view,
5876 titleField,
5877 mediaField,
5878 descriptionField,
5879 selection,
5880 getItemId,
5881 isItemClickable,
5882 onClickItem,
5883 renderItemLink,
5884 onChangeSelection,
5885 isActionsColumnSticky,
5886 posinset
5887 }) {
5888 const { paginationInfo } = (0, import_element28.useContext)(dataviews_context_default);
5889 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions2, item);
5890 const isSelected2 = hasPossibleBulkAction && selection.includes(id);
5891 const {
5892 showTitle = true,
5893 showMedia = true,
5894 showDescription = true,
5895 infiniteScrollEnabled
5896 } = view;
5897 const isTouchDeviceRef = (0, import_element28.useRef)(false);
5898 const columns = view.fields ?? [];
5899 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
5900 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
5901 "tr",
5902 {
5903 className: clsx_default("dataviews-view-table__row", {
5904 "is-selected": hasPossibleBulkAction && isSelected2,
5905 "has-bulk-actions": hasPossibleBulkAction
5906 }),
5907 onTouchStart: () => {
5908 isTouchDeviceRef.current = true;
5909 },
5910 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
5911 "aria-posinset": posinset,
5912 role: infiniteScrollEnabled ? "article" : void 0,
5913 onMouseDown: (event) => {
5914 const isMetaClick = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
5915 if (event.button === 0 && isMetaClick && window.navigator.userAgent.toLowerCase().includes("firefox")) {
5916 event?.preventDefault();
5917 }
5918 },
5919 onClick: (event) => {
5920 if (!hasPossibleBulkAction) {
5921 return;
5922 }
5923 const isModifierKeyPressed = (0, import_keycodes.isAppleOS)() ? event.metaKey : event.ctrlKey;
5924 if (isModifierKeyPressed && !isTouchDeviceRef.current && document.getSelection()?.type !== "Range") {
5925 onChangeSelection(
5926 selection.includes(id) ? selection.filter((itemId) => id !== itemId) : [...selection, id]
5927 );
5928 }
5929 },
5930 children: [
5931 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)(
5932 DataViewsSelectionCheckbox,
5933 {
5934 item,
5935 selection,
5936 onChangeSelection,
5937 getItemId,
5938 titleField,
5939 disabled: !hasPossibleBulkAction
5940 }
5941 ) }) }),
5942 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5943 column_primary_default,
5944 {
5945 item,
5946 level,
5947 titleField: showTitle ? titleField : void 0,
5948 mediaField: showMedia ? mediaField : void 0,
5949 descriptionField: showDescription ? descriptionField : void 0,
5950 isItemClickable,
5951 onClickItem,
5952 renderItemLink
5953 }
5954 ) }),
5955 columns.map((column) => {
5956 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
5957 const field = fields2.find((f2) => f2.id === column);
5958 const effectiveAlign = getEffectiveAlign(align, field?.type);
5959 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5960 "td",
5961 {
5962 style: {
5963 width,
5964 maxWidth,
5965 minWidth
5966 },
5967 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5968 TableColumnField,
5969 {
5970 fields: fields2,
5971 item,
5972 column,
5973 align: effectiveAlign
5974 }
5975 )
5976 },
5977 column
5978 );
5979 }),
5980 !!actions2?.length && // Disable reason: we are not making the element interactive,
5981 // but preventing any click events from bubbling up to the
5982 // table row. This allows us to add a click handler to the row
5983 // itself (to toggle row selection) without erroneously
5984 // intercepting click events from ItemActions.
5985 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
5986 "td",
5987 {
5988 className: clsx_default("dataviews-view-table__actions-column", {
5989 "dataviews-view-table__actions-column--sticky": true,
5990 "dataviews-view-table__actions-column--stuck": isActionsColumnSticky
5991 }),
5992 onClick: (e2) => e2.stopPropagation(),
5993 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(ItemActions, { item, actions: actions2 })
5994 }
5995 )
5996 ]
5997 }
5998 );
5999 }
6000 function ViewTable({
6001 actions: actions2,
6002 data,
6003 fields: fields2,
6004 getItemId,
6005 getItemLevel,
6006 isLoading = false,
6007 onChangeView,
6008 onChangeSelection,
6009 selection,
6010 setOpenedFilter,
6011 onClickItem,
6012 isItemClickable,
6013 renderItemLink,
6014 view,
6015 className,
6016 empty
6017 }) {
6018 const { containerRef } = (0, import_element28.useContext)(dataviews_context_default);
6019 const isDelayedLoading = useDelayedLoading(isLoading);
6020 const headerMenuRefs = (0, import_element28.useRef)(/* @__PURE__ */ new Map());
6021 const headerMenuToFocusRef = (0, import_element28.useRef)(void 0);
6022 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element28.useState)();
6023 const [contextMenuAnchor, setContextMenuAnchor] = (0, import_element28.useState)(null);
6024 (0, import_element28.useEffect)(() => {
6025 if (headerMenuToFocusRef.current) {
6026 headerMenuToFocusRef.current.focus();
6027 headerMenuToFocusRef.current = void 0;
6028 }
6029 });
6030 const tableNoticeId = (0, import_element28.useId)();
6031 const { isHorizontalScrollEnd, isVerticallyScrolled } = useScrollState({
6032 scrollContainerRef: containerRef,
6033 enabledHorizontal: !!actions2?.length
6034 });
6035 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
6036 if (nextHeaderMenuToFocus) {
6037 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
6038 setNextHeaderMenuToFocus(void 0);
6039 return;
6040 }
6041 const onHide = (field) => {
6042 const hidden = headerMenuRefs.current.get(field.id);
6043 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
6044 setNextHeaderMenuToFocus(fallback?.node);
6045 };
6046 const handleHeaderContextMenu = (event) => {
6047 event.preventDefault();
6048 event.stopPropagation();
6049 const virtualAnchor = {
6050 getBoundingClientRect: () => ({
6051 x: event.clientX,
6052 y: event.clientY,
6053 top: event.clientY,
6054 left: event.clientX,
6055 right: event.clientX,
6056 bottom: event.clientY,
6057 width: 0,
6058 height: 0,
6059 toJSON: () => ({})
6060 })
6061 };
6062 window.requestAnimationFrame(() => {
6063 setContextMenuAnchor(virtualAnchor);
6064 });
6065 };
6066 const hasData = !!data?.length;
6067 const titleField = fields2.find((field) => field.id === view.titleField);
6068 const mediaField = fields2.find((field) => field.id === view.mediaField);
6069 const descriptionField = fields2.find(
6070 (field) => field.id === view.descriptionField
6071 );
6072 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
6073 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
6074 const { showTitle = true, showMedia = true, showDescription = true } = view;
6075 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
6076 const columns = view.fields ?? [];
6077 const headerMenuRef = (column, index) => (node) => {
6078 if (node) {
6079 headerMenuRefs.current.set(column, {
6080 node,
6081 fallback: columns[index > 0 ? index - 1 : 1]
6082 });
6083 } else {
6084 headerMenuRefs.current.delete(column);
6085 }
6086 };
6087 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6088 const isRtl = (0, import_i18n9.isRTL)();
6089 if (!hasData) {
6090 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6091 "div",
6092 {
6093 className: clsx_default("dataviews-no-results", {
6094 "is-refreshing": isDelayedLoading
6095 }),
6096 id: tableNoticeId,
6097 children: empty
6098 }
6099 );
6100 }
6101 return /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_jsx_runtime50.Fragment, { children: [
6102 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(
6103 "table",
6104 {
6105 className: clsx_default("dataviews-view-table", className, {
6106 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
6107 view.layout.density
6108 ),
6109 "has-bulk-actions": hasBulkActions,
6110 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6111 }),
6112 "aria-busy": isLoading,
6113 "aria-describedby": tableNoticeId,
6114 role: isInfiniteScroll ? "feed" : void 0,
6115 inert: !isInfiniteScroll && isLoading ? "true" : void 0,
6116 children: [
6117 /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("colgroup", { children: [
6118 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-checkbox" }),
6119 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-first-data" }),
6120 columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6121 "col",
6122 {
6123 className: clsx_default(
6124 `dataviews-view-table__col-${column}`,
6125 {
6126 "dataviews-view-table__col-expand": !hasPrimaryColumn && index === columns.length - 1
6127 }
6128 )
6129 },
6130 `col-${column}`
6131 )),
6132 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { className: "dataviews-view-table__col-actions" })
6133 ] }),
6134 contextMenuAnchor && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6135 import_components8.Popover,
6136 {
6137 anchor: contextMenuAnchor,
6138 onClose: () => setContextMenuAnchor(null),
6139 placement: "bottom-start",
6140 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PropertiesSection, { showLabel: false })
6141 }
6142 ),
6143 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6144 "thead",
6145 {
6146 className: clsx_default({
6147 "dataviews-view-table__thead--stuck": isVerticallyScrolled
6148 }),
6149 onContextMenu: handleHeaderContextMenu,
6150 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tr", { className: "dataviews-view-table__row", children: [
6151 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6152 "th",
6153 {
6154 className: "dataviews-view-table__checkbox-column",
6155 scope: "col",
6156 onContextMenu: handleHeaderContextMenu,
6157 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6158 BulkSelectionCheckbox,
6159 {
6160 selection,
6161 onChangeSelection,
6162 data,
6163 actions: actions2,
6164 getItemId
6165 }
6166 )
6167 }
6168 ),
6169 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("th", { scope: "col", children: titleField && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6170 column_header_menu_default,
6171 {
6172 ref: headerMenuRef(
6173 titleField.id,
6174 0
6175 ),
6176 fieldId: titleField.id,
6177 view,
6178 fields: fields2,
6179 onChangeView,
6180 onHide,
6181 setOpenedFilter,
6182 canMove: false,
6183 canInsertLeft: isRtl ? view.layout?.enableMoving ?? true : false,
6184 canInsertRight: isRtl ? false : view.layout?.enableMoving ?? true
6185 }
6186 ) }),
6187 columns.map((column, index) => {
6188 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
6189 const field = fields2.find(
6190 (f2) => f2.id === column
6191 );
6192 const effectiveAlign = getEffectiveAlign(
6193 align,
6194 field?.type
6195 );
6196 const canInsertOrMove = view.layout?.enableMoving ?? true;
6197 return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6198 "th",
6199 {
6200 style: {
6201 width,
6202 maxWidth,
6203 minWidth,
6204 textAlign: effectiveAlign
6205 },
6206 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
6207 scope: "col",
6208 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6209 column_header_menu_default,
6210 {
6211 ref: headerMenuRef(column, index),
6212 fieldId: column,
6213 view,
6214 fields: fields2,
6215 onChangeView,
6216 onHide,
6217 setOpenedFilter,
6218 canMove: canInsertOrMove,
6219 canInsertLeft: canInsertOrMove,
6220 canInsertRight: canInsertOrMove
6221 }
6222 )
6223 },
6224 column
6225 );
6226 }),
6227 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6228 "th",
6229 {
6230 className: clsx_default(
6231 "dataviews-view-table__actions-column",
6232 {
6233 "dataviews-view-table__actions-column--sticky": true,
6234 "dataviews-view-table__actions-column--stuck": !isHorizontalScrollEnd
6235 }
6236 ),
6237 children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("span", { className: "dataviews-view-table-header", children: (0, import_i18n9.__)("Actions") })
6238 }
6239 )
6240 ] })
6241 }
6242 ),
6243 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
6244 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("tbody", { children: [
6245 /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tr", { className: "dataviews-view-table__group-header-row", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6246 "td",
6247 {
6248 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + (hasBulkActions ? 1 : 0) + (actions2?.length ? 1 : 0),
6249 className: "dataviews-view-table__group-header-cell",
6250 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n9.sprintf)(
6251 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6252 (0, import_i18n9.__)("%1$s: %2$s"),
6253 groupField.label,
6254 groupName
6255 )
6256 }
6257 ) }),
6258 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6259 TableRow,
6260 {
6261 item,
6262 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
6263 hasBulkActions,
6264 actions: actions2,
6265 fields: fields2,
6266 id: getItemId(item) || index.toString(),
6267 view,
6268 titleField,
6269 mediaField,
6270 descriptionField,
6271 selection,
6272 getItemId,
6273 onChangeSelection,
6274 onClickItem,
6275 renderItemLink,
6276 isItemClickable,
6277 isActionsColumnSticky: !isHorizontalScrollEnd
6278 },
6279 getItemId(item)
6280 ))
6281 ] }, `group-${groupName}`)
6282 ) : /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("tbody", { children: hasData && data.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
6283 TableRow,
6284 {
6285 item,
6286 level: view.showLevels && typeof getItemLevel === "function" ? getItemLevel(item) : void 0,
6287 hasBulkActions,
6288 actions: actions2,
6289 fields: fields2,
6290 id: getItemId(item) || index.toString(),
6291 view,
6292 titleField,
6293 mediaField,
6294 descriptionField,
6295 selection,
6296 getItemId,
6297 onChangeSelection,
6298 onClickItem,
6299 renderItemLink,
6300 isItemClickable,
6301 isActionsColumnSticky: !isHorizontalScrollEnd,
6302 posinset: isInfiniteScroll ? index + 1 : void 0
6303 },
6304 getItemId(item)
6305 )) })
6306 ]
6307 }
6308 ),
6309 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, {}) }) })
6310 ] });
6311 }
6312 var table_default = ViewTable;
6313
6314 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
6315 var import_components11 = __toESM(require_components(), 1);
6316 var import_i18n12 = __toESM(require_i18n(), 1);
6317
6318 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
6319 var import_components10 = __toESM(require_components(), 1);
6320 var import_i18n11 = __toESM(require_i18n(), 1);
6321 var import_compose3 = __toESM(require_compose(), 1);
6322 var import_keycodes2 = __toESM(require_keycodes(), 1);
6323 var import_element32 = __toESM(require_element(), 1);
6324
6325 // packages/dataviews/build-module/components/dataviews-layouts/grid/preview-size-picker.mjs
6326 var import_components9 = __toESM(require_components(), 1);
6327 var import_i18n10 = __toESM(require_i18n(), 1);
6328 var import_element29 = __toESM(require_element(), 1);
6329 var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
6330 var imageSizes = [
6331 {
6332 value: 120,
6333 breakpoint: 1
6334 },
6335 {
6336 value: 170,
6337 breakpoint: 1
6338 },
6339 {
6340 value: 230,
6341 breakpoint: 1
6342 },
6343 {
6344 value: 290,
6345 breakpoint: 1112
6346 // at minimum image width, 4 images display at this container size
6347 },
6348 {
6349 value: 350,
6350 breakpoint: 1636
6351 // at minimum image width, 6 images display at this container size
6352 },
6353 {
6354 value: 430,
6355 breakpoint: 588
6356 // at minimum image width, 2 images display at this container size
6357 }
6358 ];
6359 var DEFAULT_PREVIEW_SIZE = imageSizes[2].value;
6360 function useGridColumns() {
6361 const context = (0, import_element29.useContext)(dataviews_context_default);
6362 const view = context.view;
6363 return (0, import_element29.useMemo)(() => {
6364 const containerWidth = context.containerWidth;
6365 const gap = 32;
6366 const previewSize = view.layout?.previewSize ?? DEFAULT_PREVIEW_SIZE;
6367 const columns = Math.floor(
6368 (containerWidth + gap) / (previewSize + gap)
6369 );
6370 return Math.max(1, columns);
6371 }, [context.containerWidth, view.layout?.previewSize]);
6372 }
6373
6374 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-items.mjs
6375 var import_element30 = __toESM(require_element(), 1);
6376 var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
6377 var GridItems = (0, import_element30.forwardRef)(({ className, previewSize, ...props }, ref) => {
6378 return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
6379 "div",
6380 {
6381 ref,
6382 className: clsx_default("dataviews-view-grid-items", className),
6383 style: {
6384 gridTemplateColumns: previewSize && `repeat(auto-fill, minmax(${previewSize}px, 1fr))`
6385 },
6386 ...props
6387 }
6388 );
6389 });
6390
6391 // packages/dataviews/build-module/components/dataviews-layouts/utils/use-infinite-scroll.mjs
6392 var import_element31 = __toESM(require_element(), 1);
6393 function useIntersectionObserver(elementRef, posinset) {
6394 const { intersectionObserver } = (0, import_element31.useContext)(dataviews_context_default);
6395 (0, import_element31.useEffect)(() => {
6396 const element = elementRef.current;
6397 if (!element || posinset === void 0 || !intersectionObserver) {
6398 return;
6399 }
6400 intersectionObserver.observe(element);
6401 return () => {
6402 intersectionObserver.unobserve(element);
6403 };
6404 }, [elementRef, intersectionObserver, posinset]);
6405 }
6406 function usePlaceholdersNeeded(data, isInfiniteScroll, gridColumns) {
6407 const hasData = !!data?.length;
6408 const firstItemPosition = hasData && isInfiniteScroll ? data[0].position : void 0;
6409 return firstItemPosition && gridColumns ? (firstItemPosition - 1) % gridColumns : 0;
6410 }
6411
6412 // packages/dataviews/build-module/components/dataviews-layouts/grid/composite-grid.mjs
6413 var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
6414 var { Badge: WCBadge } = unlock(import_components10.privateApis);
6415 function chunk(array, size) {
6416 const chunks = [];
6417 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) {
6418 chunks.push(array.slice(i2, i2 + size));
6419 }
6420 return chunks;
6421 }
6422 var GridItem = (0, import_element32.forwardRef)(
6423 function GridItem2({
6424 view,
6425 selection,
6426 onChangeSelection,
6427 onClickItem,
6428 isItemClickable,
6429 renderItemLink,
6430 getItemId,
6431 item,
6432 actions: actions2,
6433 mediaField,
6434 titleField,
6435 descriptionField,
6436 regularFields,
6437 badgeFields,
6438 hasBulkActions,
6439 config,
6440 posinset,
6441 setsize,
6442 ...props
6443 }, forwardedRef) {
6444 const {
6445 showTitle = true,
6446 showMedia = true,
6447 showDescription = true
6448 } = view;
6449 const hasBulkAction = useHasAPossibleBulkAction(actions2, item);
6450 const id = getItemId(item);
6451 const elementRef = (0, import_element32.useRef)(null);
6452 const setRefs = (0, import_element32.useCallback)(
6453 (node) => {
6454 elementRef.current = node;
6455 if (typeof forwardedRef === "function") {
6456 forwardedRef(node);
6457 } else if (forwardedRef) {
6458 forwardedRef.current = node;
6459 }
6460 },
6461 [forwardedRef]
6462 );
6463 useIntersectionObserver(elementRef, posinset);
6464 const instanceId = (0, import_compose3.useInstanceId)(GridItem2);
6465 const isSelected2 = selection.includes(id);
6466 const mediaPlaceholder = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("span", { className: "dataviews-view-grid__media-placeholder" });
6467 const rendersMediaField = showMedia && mediaField?.render;
6468 const renderedMediaField = rendersMediaField ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6469 mediaField.render,
6470 {
6471 item,
6472 field: mediaField,
6473 config
6474 }
6475 ) : mediaPlaceholder;
6476 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(titleField.render, { item, field: titleField }) : null;
6477 let mediaA11yProps;
6478 let titleA11yProps;
6479 if (isItemClickable(item) && onClickItem) {
6480 if (renderedTitleField) {
6481 mediaA11yProps = {
6482 "aria-labelledby": `dataviews-view-grid__title-field-${instanceId}`
6483 };
6484 titleA11yProps = {
6485 id: `dataviews-view-grid__title-field-${instanceId}`
6486 };
6487 } else {
6488 mediaA11yProps = {
6489 "aria-label": (0, import_i18n11.__)("Navigate to item")
6490 };
6491 }
6492 }
6493 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
6494 Stack,
6495 {
6496 direction: "column",
6497 ...props,
6498 ref: setRefs,
6499 "aria-setsize": setsize,
6500 "aria-posinset": posinset,
6501 className: clsx_default(
6502 props.className,
6503 "dataviews-view-grid__row__gridcell",
6504 "dataviews-view-grid__card",
6505 {
6506 "is-selected": hasBulkAction && isSelected2
6507 }
6508 ),
6509 onClickCapture: (event) => {
6510 props.onClickCapture?.(event);
6511 if ((0, import_keycodes2.isAppleOS)() ? event.metaKey : event.ctrlKey) {
6512 event.stopPropagation();
6513 event.preventDefault();
6514 if (!hasBulkAction) {
6515 return;
6516 }
6517 onChangeSelection(
6518 isSelected2 ? selection.filter(
6519 (itemId) => id !== itemId
6520 ) : [...selection, id]
6521 );
6522 }
6523 },
6524 children: [
6525 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6526 ItemClickWrapper,
6527 {
6528 item,
6529 isItemClickable,
6530 onClickItem,
6531 renderItemLink,
6532 className: clsx_default("dataviews-view-grid__media", {
6533 "dataviews-view-grid__media--placeholder": !rendersMediaField
6534 }),
6535 ...mediaA11yProps,
6536 children: renderedMediaField
6537 }
6538 ),
6539 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6540 DataViewsSelectionCheckbox,
6541 {
6542 item,
6543 selection,
6544 onChangeSelection,
6545 getItemId,
6546 titleField,
6547 disabled: !hasBulkAction
6548 }
6549 ),
6550 !!actions2?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__media-actions", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6551 ItemActions,
6552 {
6553 item,
6554 actions: actions2,
6555 isCompact: true
6556 }
6557 ) }),
6558 showTitle && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "dataviews-view-grid__title", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6559 ItemClickWrapper,
6560 {
6561 item,
6562 isItemClickable,
6563 onClickItem,
6564 renderItemLink,
6565 className: "dataviews-view-grid__title-field dataviews-title-field",
6566 ...titleA11yProps,
6567 title: titleField?.getValueFormatted({
6568 item,
6569 field: titleField
6570 }) || void 0,
6571 children: renderedTitleField
6572 }
6573 ) }),
6574 /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(Stack, { direction: "column", gap: "xs", children: [
6575 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6576 descriptionField.render,
6577 {
6578 item,
6579 field: descriptionField
6580 }
6581 ),
6582 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6583 Stack,
6584 {
6585 direction: "row",
6586 className: "dataviews-view-grid__badge-fields",
6587 gap: "sm",
6588 wrap: "wrap",
6589 align: "top",
6590 justify: "flex-start",
6591 children: badgeFields.map((field) => {
6592 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6593 WCBadge,
6594 {
6595 className: "dataviews-view-grid__field-value",
6596 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6597 field.render,
6598 {
6599 item,
6600 field
6601 }
6602 )
6603 },
6604 field.id
6605 );
6606 })
6607 }
6608 ),
6609 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6610 Stack,
6611 {
6612 direction: "column",
6613 className: "dataviews-view-grid__fields",
6614 gap: "xs",
6615 children: regularFields.map((field) => {
6616 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6617 import_components10.Flex,
6618 {
6619 className: "dataviews-view-grid__field",
6620 gap: 1,
6621 justify: "flex-start",
6622 expanded: true,
6623 style: { height: "auto" },
6624 direction: "row",
6625 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, { children: [
6626 /* @__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 }) }),
6627 /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6628 import_components10.FlexItem,
6629 {
6630 className: "dataviews-view-grid__field-value",
6631 style: { maxHeight: "none" },
6632 children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6633 field.render,
6634 {
6635 item,
6636 field
6637 }
6638 )
6639 }
6640 )
6641 ] })
6642 },
6643 field.id
6644 );
6645 })
6646 }
6647 )
6648 ] })
6649 ]
6650 }
6651 );
6652 }
6653 );
6654 function CompositeGrid({
6655 data,
6656 isInfiniteScroll,
6657 className,
6658 inert,
6659 isLoading,
6660 view,
6661 fields: fields2,
6662 selection,
6663 onChangeSelection,
6664 onClickItem,
6665 isItemClickable,
6666 renderItemLink,
6667 getItemId,
6668 actions: actions2
6669 }) {
6670 const { paginationInfo, resizeObserverRef } = (0, import_element32.useContext)(dataviews_context_default);
6671 const gridColumns = useGridColumns();
6672 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data);
6673 const titleField = fields2.find(
6674 (field) => field.id === view?.titleField
6675 );
6676 const mediaField = fields2.find(
6677 (field) => field.id === view?.mediaField
6678 );
6679 const descriptionField = fields2.find(
6680 (field) => field.id === view?.descriptionField
6681 );
6682 const otherFields = view.fields ?? [];
6683 const { regularFields, badgeFields } = otherFields.reduce(
6684 (accumulator, fieldId) => {
6685 const field = fields2.find((f2) => f2.id === fieldId);
6686 if (!field) {
6687 return accumulator;
6688 }
6689 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
6690 accumulator[key].push(field);
6691 return accumulator;
6692 },
6693 { regularFields: [], badgeFields: [] }
6694 );
6695 const size = "900px";
6696 const totalRows = Math.ceil(data.length / gridColumns);
6697 const placeholdersNeeded = usePlaceholdersNeeded(
6698 data,
6699 isInfiniteScroll,
6700 gridColumns
6701 );
6702 return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_jsx_runtime53.Fragment, {
6703 // Render infinite scroll layout (no rows, feed semantics)
6704 children: [
6705 isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
6706 import_components10.Composite,
6707 {
6708 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6709 GridItems,
6710 {
6711 className: clsx_default(
6712 "dataviews-view-grid-infinite-scroll",
6713 className,
6714 {
6715 [`has-${view.layout?.density}-density`]: view.layout?.density && [
6716 "compact",
6717 "comfortable"
6718 ].includes(view.layout.density)
6719 }
6720 ),
6721 previewSize: view.layout?.previewSize,
6722 "aria-busy": isLoading,
6723 ref: resizeObserverRef
6724 }
6725 ),
6726 role: "feed",
6727 focusWrap: true,
6728 inert,
6729 children: [
6730 Array.from({ length: placeholdersNeeded }).map(
6731 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6732 import_components10.Composite.Item,
6733 {
6734 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6735 Stack,
6736 {
6737 ...props,
6738 direction: "column",
6739 role: "article",
6740 className: "dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder"
6741 }
6742 ),
6743 "aria-hidden": true,
6744 tabIndex: -1
6745 },
6746 `placeholder-${index}`
6747 )
6748 ),
6749 data.map((item) => {
6750 const itemId = getItemId(item);
6751 const stablePosition = item.position;
6752 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6753 import_components10.Composite.Item,
6754 {
6755 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6756 GridItem,
6757 {
6758 ...props,
6759 id: itemId,
6760 role: "article",
6761 view,
6762 selection,
6763 onChangeSelection,
6764 onClickItem,
6765 isItemClickable,
6766 renderItemLink,
6767 getItemId,
6768 item,
6769 actions: actions2,
6770 mediaField,
6771 titleField,
6772 descriptionField,
6773 regularFields,
6774 badgeFields,
6775 hasBulkActions,
6776 posinset: stablePosition,
6777 setsize: paginationInfo.totalItems,
6778 config: {
6779 sizes: size
6780 }
6781 }
6782 )
6783 },
6784 itemId
6785 );
6786 })
6787 ]
6788 }
6789 ),
6790 // Render standard grid layout (with rows, grid semantics)
6791 !isInfiniteScroll && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6792 import_components10.Composite,
6793 {
6794 role: "grid",
6795 className: clsx_default("dataviews-view-grid", className, {
6796 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
6797 view.layout.density
6798 )
6799 }),
6800 focusWrap: true,
6801 "aria-busy": isLoading,
6802 "aria-rowcount": totalRows,
6803 ref: resizeObserverRef,
6804 inert,
6805 children: chunk(data, gridColumns).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6806 import_components10.Composite.Row,
6807 {
6808 render: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6809 "div",
6810 {
6811 role: "row",
6812 "aria-rowindex": i2 + 1,
6813 "aria-label": (0, import_i18n11.sprintf)(
6814 /* translators: %d: The row number in the grid */
6815 (0, import_i18n11.__)("Row %d"),
6816 i2 + 1
6817 ),
6818 className: "dataviews-view-grid__row",
6819 style: {
6820 gridTemplateColumns: `repeat( ${gridColumns}, minmax(0, 1fr) )`
6821 }
6822 }
6823 ),
6824 children: row.map((item) => {
6825 const itemId = getItemId(item);
6826 return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6827 import_components10.Composite.Item,
6828 {
6829 render: (props) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
6830 GridItem,
6831 {
6832 ...props,
6833 id: itemId,
6834 role: "gridcell",
6835 view,
6836 selection,
6837 onChangeSelection,
6838 onClickItem,
6839 isItemClickable,
6840 renderItemLink,
6841 getItemId,
6842 item,
6843 actions: actions2,
6844 mediaField,
6845 titleField,
6846 descriptionField,
6847 regularFields,
6848 badgeFields,
6849 hasBulkActions,
6850 config: {
6851 sizes: size
6852 }
6853 }
6854 )
6855 },
6856 itemId
6857 );
6858 })
6859 },
6860 i2
6861 ))
6862 }
6863 )
6864 ]
6865 });
6866 }
6867
6868 // packages/dataviews/build-module/components/dataviews-layouts/grid/index.mjs
6869 var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
6870 function ViewGrid({
6871 actions: actions2,
6872 data,
6873 fields: fields2,
6874 getItemId,
6875 isLoading,
6876 onChangeSelection,
6877 onClickItem,
6878 isItemClickable,
6879 renderItemLink,
6880 selection,
6881 view,
6882 className,
6883 empty
6884 }) {
6885 const isDelayedLoading = useDelayedLoading(!!isLoading);
6886 const hasData = !!data?.length;
6887 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
6888 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
6889 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
6890 if (!hasData) {
6891 return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6892 "div",
6893 {
6894 className: clsx_default("dataviews-no-results", {
6895 "is-refreshing": isDelayedLoading
6896 }),
6897 children: empty
6898 }
6899 );
6900 }
6901 const gridProps = {
6902 className: clsx_default(className, {
6903 "is-refreshing": !isInfiniteScroll && isDelayedLoading
6904 }),
6905 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
6906 isLoading,
6907 view,
6908 fields: fields2,
6909 selection,
6910 onChangeSelection,
6911 onClickItem,
6912 isItemClickable,
6913 renderItemLink,
6914 getItemId,
6915 actions: actions2
6916 };
6917 return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(import_jsx_runtime54.Fragment, {
6918 // Render multiple groups.
6919 children: [
6920 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(Stack, { direction: "column", gap: "lg", children: Array.from(dataByGroup.entries()).map(
6921 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)(
6922 Stack,
6923 {
6924 direction: "column",
6925 gap: "sm",
6926 children: [
6927 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("h3", { className: "dataviews-view-grid__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n12.sprintf)(
6928 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
6929 (0, import_i18n12.__)("%1$s: %2$s"),
6930 groupField.label,
6931 groupName
6932 ) }),
6933 /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6934 CompositeGrid,
6935 {
6936 ...gridProps,
6937 data: groupItems,
6938 isInfiniteScroll: false
6939 }
6940 )
6941 ]
6942 },
6943 groupName
6944 )
6945 ) }),
6946 // Render a single grid with all data.
6947 !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
6948 CompositeGrid,
6949 {
6950 ...gridProps,
6951 data,
6952 isInfiniteScroll: !!isInfiniteScroll
6953 }
6954 ),
6955 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime54.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_components11.Spinner, {}) })
6956 ]
6957 });
6958 }
6959 var grid_default = ViewGrid;
6960
6961 // packages/dataviews/build-module/components/dataviews-layouts/list/index.mjs
6962 var import_compose4 = __toESM(require_compose(), 1);
6963 var import_components12 = __toESM(require_components(), 1);
6964 var import_element33 = __toESM(require_element(), 1);
6965 var import_i18n13 = __toESM(require_i18n(), 1);
6966 var import_data3 = __toESM(require_data(), 1);
6967 var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);
6968 var { Menu: Menu3 } = unlock(import_components12.privateApis);
6969 function generateItemWrapperCompositeId(idPrefix) {
6970 return `${idPrefix}-item-wrapper`;
6971 }
6972 function generatePrimaryActionCompositeId(idPrefix, primaryActionId) {
6973 return `${idPrefix}-primary-action-${primaryActionId}`;
6974 }
6975 function generateDropdownTriggerCompositeId(idPrefix) {
6976 return `${idPrefix}-dropdown`;
6977 }
6978 function PrimaryActionGridCell({
6979 idPrefix,
6980 primaryAction,
6981 item
6982 }) {
6983 const registry = (0, import_data3.useRegistry)();
6984 const [isModalOpen, setIsModalOpen] = (0, import_element33.useState)(false);
6985 const compositeItemId = generatePrimaryActionCompositeId(
6986 idPrefix,
6987 primaryAction.id
6988 );
6989 const label = typeof primaryAction.label === "string" ? primaryAction.label : primaryAction.label([item]);
6990 return "RenderModal" in primaryAction ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6991 import_components12.Composite.Item,
6992 {
6993 id: compositeItemId,
6994 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6995 import_components12.Button,
6996 {
6997 disabled: !!primaryAction.disabled,
6998 accessibleWhenDisabled: true,
6999 text: label,
7000 size: "small",
7001 onClick: () => setIsModalOpen(true)
7002 }
7003 ),
7004 children: isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7005 ActionModal,
7006 {
7007 action: primaryAction,
7008 items: [item],
7009 closeModal: () => setIsModalOpen(false)
7010 }
7011 )
7012 }
7013 ) }, primaryAction.id) : /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7014 import_components12.Composite.Item,
7015 {
7016 id: compositeItemId,
7017 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7018 import_components12.Button,
7019 {
7020 disabled: !!primaryAction.disabled,
7021 accessibleWhenDisabled: true,
7022 size: "small",
7023 onClick: () => {
7024 primaryAction.callback([item], { registry });
7025 },
7026 children: label
7027 }
7028 )
7029 }
7030 ) }, primaryAction.id);
7031 }
7032 function ListItem({
7033 view,
7034 actions: actions2,
7035 idPrefix,
7036 isSelected: isSelected2,
7037 item,
7038 titleField,
7039 mediaField,
7040 descriptionField,
7041 onSelect,
7042 otherFields,
7043 onDropdownTriggerKeyDown,
7044 posinset
7045 }) {
7046 const {
7047 showTitle = true,
7048 showMedia = true,
7049 showDescription = true,
7050 infiniteScrollEnabled
7051 } = view;
7052 const itemRef = (0, import_element33.useRef)(null);
7053 const labelId = `${idPrefix}-label`;
7054 const descriptionId = `${idPrefix}-description`;
7055 const registry = (0, import_data3.useRegistry)();
7056 const [isHovered, setIsHovered] = (0, import_element33.useState)(false);
7057 const [activeModalAction, setActiveModalAction] = (0, import_element33.useState)(
7058 null
7059 );
7060 const handleHover = ({ type }) => {
7061 const isHover = type === "mouseenter";
7062 setIsHovered(isHover);
7063 };
7064 const { paginationInfo } = (0, import_element33.useContext)(dataviews_context_default);
7065 (0, import_element33.useEffect)(() => {
7066 if (isSelected2) {
7067 itemRef.current?.scrollIntoView({
7068 behavior: "auto",
7069 block: "nearest",
7070 inline: "nearest"
7071 });
7072 }
7073 }, [isSelected2]);
7074 const { primaryAction, eligibleActions } = (0, import_element33.useMemo)(() => {
7075 const _eligibleActions = actions2.filter(
7076 (action) => !action.isEligible || action.isEligible(item)
7077 );
7078 const _primaryActions = _eligibleActions.filter(
7079 (action) => action.isPrimary
7080 );
7081 return {
7082 primaryAction: _primaryActions[0],
7083 eligibleActions: _eligibleActions
7084 };
7085 }, [actions2, item]);
7086 const hasOnlyOnePrimaryAction = primaryAction && actions2.length === 1;
7087 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)(
7088 mediaField.render,
7089 {
7090 item,
7091 field: mediaField,
7092 config: { sizes: "52px" }
7093 }
7094 ) }) : null;
7095 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(titleField.render, { item, field: titleField }) : null;
7096 const renderDescription = showDescription && descriptionField?.render;
7097 const hasOnlyMediaAndTitle = !!renderedMediaField && !renderDescription && !otherFields.length;
7098 const usedActions = eligibleActions?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7099 Stack,
7100 {
7101 direction: "row",
7102 gap: "md",
7103 className: "dataviews-view-list__item-actions",
7104 children: [
7105 primaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7106 PrimaryActionGridCell,
7107 {
7108 idPrefix,
7109 primaryAction,
7110 item
7111 }
7112 ),
7113 !hasOnlyOnePrimaryAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { role: "gridcell", children: [
7114 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Menu3, { placement: "bottom-end", children: [
7115 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7116 Menu3.TriggerButton,
7117 {
7118 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7119 import_components12.Composite.Item,
7120 {
7121 id: generateDropdownTriggerCompositeId(
7122 idPrefix
7123 ),
7124 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7125 import_components12.Button,
7126 {
7127 size: "small",
7128 icon: more_vertical_default,
7129 label: (0, import_i18n13.__)("Actions"),
7130 accessibleWhenDisabled: true,
7131 disabled: !actions2.length,
7132 onKeyDown: onDropdownTriggerKeyDown
7133 }
7134 )
7135 }
7136 )
7137 }
7138 ),
7139 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(Menu3.Popover, { children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7140 ActionsMenuGroup,
7141 {
7142 actions: eligibleActions,
7143 item,
7144 registry,
7145 setActiveModalAction
7146 }
7147 ) })
7148 ] }),
7149 !!activeModalAction && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7150 ActionModal,
7151 {
7152 action: activeModalAction,
7153 items: [item],
7154 closeModal: () => setActiveModalAction(null)
7155 }
7156 )
7157 ] })
7158 ]
7159 }
7160 );
7161 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7162 import_components12.Composite.Row,
7163 {
7164 ref: itemRef,
7165 render: (
7166 /* aria-posinset breaks Composite.Row if passed to it directly. */
7167 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7168 "div",
7169 {
7170 "aria-posinset": posinset,
7171 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0
7172 }
7173 )
7174 ),
7175 role: infiniteScrollEnabled ? "article" : "row",
7176 className: clsx_default({
7177 "is-selected": isSelected2,
7178 "is-hovered": isHovered
7179 }),
7180 onMouseEnter: handleHover,
7181 onMouseLeave: handleHover,
7182 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7183 Stack,
7184 {
7185 direction: "row",
7186 className: "dataviews-view-list__item-wrapper",
7187 children: [
7188 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7189 import_components12.Composite.Item,
7190 {
7191 id: generateItemWrapperCompositeId(idPrefix),
7192 "aria-pressed": isSelected2,
7193 "aria-labelledby": labelId,
7194 "aria-describedby": descriptionId,
7195 className: "dataviews-view-list__item",
7196 onClick: () => onSelect(item)
7197 }
7198 ) }),
7199 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7200 Stack,
7201 {
7202 direction: "row",
7203 gap: "md",
7204 justify: "start",
7205 align: hasOnlyMediaAndTitle ? "center" : "flex-start",
7206 style: { flex: 1, minWidth: 0 },
7207 children: [
7208 renderedMediaField,
7209 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7210 Stack,
7211 {
7212 direction: "column",
7213 gap: "xs",
7214 className: "dataviews-view-list__field-wrapper",
7215 children: [
7216 /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(Stack, { direction: "row", align: "center", children: [
7217 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7218 "div",
7219 {
7220 className: "dataviews-title-field dataviews-view-list__title-field",
7221 id: labelId,
7222 children: renderedTitleField
7223 }
7224 ),
7225 usedActions
7226 ] }),
7227 renderDescription && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "dataviews-view-list__field", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7228 descriptionField.render,
7229 {
7230 item,
7231 field: descriptionField
7232 }
7233 ) }),
7234 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7235 "div",
7236 {
7237 className: "dataviews-view-list__fields",
7238 id: descriptionId,
7239 children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7240 "div",
7241 {
7242 className: "dataviews-view-list__field",
7243 children: [
7244 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7245 VisuallyHidden,
7246 {
7247 className: "dataviews-view-list__field-label",
7248 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", {}),
7249 children: field.label
7250 }
7251 ),
7252 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "dataviews-view-list__field-value", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7253 field.render,
7254 {
7255 item,
7256 field
7257 }
7258 ) })
7259 ]
7260 },
7261 field.id
7262 ))
7263 }
7264 )
7265 ]
7266 }
7267 )
7268 ]
7269 }
7270 )
7271 ]
7272 }
7273 )
7274 }
7275 );
7276 }
7277 function isDefined2(item) {
7278 return !!item;
7279 }
7280 function ViewList(props) {
7281 const {
7282 actions: actions2,
7283 data,
7284 fields: fields2,
7285 getItemId,
7286 isLoading,
7287 onChangeSelection,
7288 selection,
7289 view,
7290 className,
7291 empty
7292 } = props;
7293 const baseId = (0, import_compose4.useInstanceId)(ViewList, "view-list");
7294 const isDelayedLoading = useDelayedLoading(!!isLoading);
7295 const selectedItem = data?.findLast(
7296 (item) => selection.includes(getItemId(item))
7297 );
7298 const titleField = fields2.find((field) => field.id === view.titleField);
7299 const mediaField = fields2.find((field) => field.id === view.mediaField);
7300 const descriptionField = fields2.find(
7301 (field) => field.id === view.descriptionField
7302 );
7303 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined2);
7304 const onSelect = (item) => onChangeSelection([getItemId(item)]);
7305 const generateCompositeItemIdPrefix = (0, import_element33.useCallback)(
7306 (item) => `${baseId}-${getItemId(item)}`,
7307 [baseId, getItemId]
7308 );
7309 const isActiveCompositeItem = (0, import_element33.useCallback)(
7310 (item, idToCheck) => {
7311 return idToCheck.startsWith(
7312 generateCompositeItemIdPrefix(item)
7313 );
7314 },
7315 [generateCompositeItemIdPrefix]
7316 );
7317 const [activeCompositeId, setActiveCompositeId] = (0, import_element33.useState)(void 0);
7318 const compositeRef = (0, import_element33.useRef)(null);
7319 (0, import_element33.useEffect)(() => {
7320 if (selectedItem) {
7321 setActiveCompositeId(
7322 generateItemWrapperCompositeId(
7323 generateCompositeItemIdPrefix(selectedItem)
7324 )
7325 );
7326 }
7327 }, [selectedItem, generateCompositeItemIdPrefix]);
7328 const activeItemIndex = data.findIndex(
7329 (item) => isActiveCompositeItem(item, activeCompositeId ?? "")
7330 );
7331 const previousActiveItemIndex = (0, import_compose4.usePrevious)(activeItemIndex);
7332 const isActiveIdInList = activeItemIndex !== -1;
7333 const selectCompositeItem = (0, import_element33.useCallback)(
7334 (targetIndex, generateCompositeId) => {
7335 const clampedIndex = Math.min(
7336 data.length - 1,
7337 Math.max(0, targetIndex)
7338 );
7339 if (!data[clampedIndex]) {
7340 return;
7341 }
7342 const itemIdPrefix = generateCompositeItemIdPrefix(
7343 data[clampedIndex]
7344 );
7345 const targetCompositeItemId = generateCompositeId(itemIdPrefix);
7346 setActiveCompositeId(targetCompositeItemId);
7347 if (compositeRef.current?.contains(
7348 compositeRef.current.ownerDocument.activeElement
7349 )) {
7350 document.getElementById(targetCompositeItemId)?.focus();
7351 }
7352 },
7353 [data, generateCompositeItemIdPrefix]
7354 );
7355 (0, import_element33.useEffect)(() => {
7356 const wasActiveIdInList = previousActiveItemIndex !== void 0 && previousActiveItemIndex !== -1;
7357 if (!isActiveIdInList && wasActiveIdInList) {
7358 selectCompositeItem(
7359 previousActiveItemIndex,
7360 generateItemWrapperCompositeId
7361 );
7362 }
7363 }, [isActiveIdInList, selectCompositeItem, previousActiveItemIndex]);
7364 const onDropdownTriggerKeyDown = (0, import_element33.useCallback)(
7365 (event) => {
7366 if (event.key === "ArrowDown") {
7367 event.preventDefault();
7368 selectCompositeItem(
7369 activeItemIndex + 1,
7370 generateDropdownTriggerCompositeId
7371 );
7372 }
7373 if (event.key === "ArrowUp") {
7374 event.preventDefault();
7375 selectCompositeItem(
7376 activeItemIndex - 1,
7377 generateDropdownTriggerCompositeId
7378 );
7379 }
7380 },
7381 [selectCompositeItem, activeItemIndex]
7382 );
7383 const hasData = !!data?.length;
7384 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
7385 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
7386 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
7387 if (!hasData) {
7388 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7389 "div",
7390 {
7391 className: clsx_default("dataviews-no-results", {
7392 "is-refreshing": isDelayedLoading
7393 }),
7394 children: empty
7395 }
7396 );
7397 }
7398 if (hasData && groupField && dataByGroup) {
7399 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7400 import_components12.Composite,
7401 {
7402 ref: compositeRef,
7403 id: `${baseId}`,
7404 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
7405 className: "dataviews-view-list__group",
7406 role: "grid",
7407 activeId: activeCompositeId,
7408 setActiveId: setActiveCompositeId,
7409 children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7410 Stack,
7411 {
7412 direction: "column",
7413 gap: "lg",
7414 className: clsx_default("dataviews-view-list", className),
7415 children: Array.from(dataByGroup.entries()).map(
7416 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
7417 Stack,
7418 {
7419 direction: "column",
7420 gap: "sm",
7421 children: [
7422 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("h3", { className: "dataviews-view-list__group-header", children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n13.sprintf)(
7423 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
7424 (0, import_i18n13.__)("%1$s: %2$s"),
7425 groupField.label,
7426 groupName
7427 ) }),
7428 groupItems.map((item) => {
7429 const id = generateCompositeItemIdPrefix(item);
7430 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7431 ListItem,
7432 {
7433 view,
7434 idPrefix: id,
7435 actions: actions2,
7436 item,
7437 isSelected: item === selectedItem,
7438 onSelect,
7439 mediaField,
7440 titleField,
7441 descriptionField,
7442 otherFields,
7443 onDropdownTriggerKeyDown
7444 },
7445 id
7446 );
7447 })
7448 ]
7449 },
7450 groupName
7451 )
7452 )
7453 }
7454 )
7455 }
7456 );
7457 }
7458 return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(import_jsx_runtime55.Fragment, { children: [
7459 /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7460 import_components12.Composite,
7461 {
7462 ref: compositeRef,
7463 id: baseId,
7464 render: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", {}),
7465 className: clsx_default("dataviews-view-list", className, {
7466 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
7467 view.layout.density
7468 ),
7469 "is-refreshing": !isInfiniteScroll && isDelayedLoading
7470 }),
7471 role: view.infiniteScrollEnabled ? "feed" : "grid",
7472 activeId: activeCompositeId,
7473 setActiveId: setActiveCompositeId,
7474 inert: !isInfiniteScroll && !!isLoading ? "true" : void 0,
7475 children: data.map((item, index) => {
7476 const id = generateCompositeItemIdPrefix(item);
7477 return /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
7478 ListItem,
7479 {
7480 view,
7481 idPrefix: id,
7482 actions: actions2,
7483 item,
7484 isSelected: item === selectedItem,
7485 onSelect,
7486 mediaField,
7487 titleField,
7488 descriptionField,
7489 otherFields,
7490 onDropdownTriggerKeyDown,
7491 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
7492 },
7493 id
7494 );
7495 })
7496 }
7497 ),
7498 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_components12.Spinner, {}) })
7499 ] });
7500 }
7501
7502 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
7503 var import_components13 = __toESM(require_components(), 1);
7504
7505 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-group.mjs
7506 var import_i18n14 = __toESM(require_i18n(), 1);
7507 var import_element34 = __toESM(require_element(), 1);
7508 var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
7509 function ActivityGroup({
7510 groupName,
7511 groupData,
7512 groupField,
7513 showLabel = true,
7514 children
7515 }) {
7516 const groupHeader = showLabel ? (0, import_element34.createInterpolateElement)(
7517 // translators: %s: The label of the field e.g. "Status".
7518 (0, import_i18n14.sprintf)((0, import_i18n14.__)("%s: <groupName />"), groupField.label).trim(),
7519 {
7520 groupName: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
7521 groupField.render,
7522 {
7523 item: groupData[0],
7524 field: groupField
7525 }
7526 )
7527 }
7528 ) : /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(groupField.render, { item: groupData[0], field: groupField });
7529 return /* @__PURE__ */ (0, import_jsx_runtime56.jsxs)(
7530 Stack,
7531 {
7532 direction: "column",
7533 className: "dataviews-view-activity__group",
7534 children: [
7535 /* @__PURE__ */ (0, import_jsx_runtime56.jsx)("h3", { className: "dataviews-view-activity__group-header", children: groupHeader }),
7536 children
7537 ]
7538 },
7539 groupName
7540 );
7541 }
7542
7543 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-item.mjs
7544 var import_element35 = __toESM(require_element(), 1);
7545 var import_data4 = __toESM(require_data(), 1);
7546 var import_compose5 = __toESM(require_compose(), 1);
7547 var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);
7548 function ActivityItem(props) {
7549 const {
7550 view,
7551 actions: actions2,
7552 item,
7553 titleField,
7554 mediaField,
7555 descriptionField,
7556 otherFields,
7557 posinset,
7558 onClickItem,
7559 renderItemLink,
7560 isItemClickable
7561 } = props;
7562 const {
7563 showTitle = true,
7564 showMedia = true,
7565 showDescription = true,
7566 infiniteScrollEnabled
7567 } = view;
7568 const itemRef = (0, import_element35.useRef)(null);
7569 const registry = (0, import_data4.useRegistry)();
7570 const { paginationInfo } = (0, import_element35.useContext)(dataviews_context_default);
7571 const { primaryActions, eligibleActions } = (0, import_element35.useMemo)(() => {
7572 const _eligibleActions = actions2.filter(
7573 (action) => !action.isEligible || action.isEligible(item)
7574 );
7575 const _primaryActions = _eligibleActions.filter(
7576 (action) => action.isPrimary
7577 );
7578 return {
7579 primaryActions: _primaryActions,
7580 eligibleActions: _eligibleActions
7581 };
7582 }, [actions2, item]);
7583 const isMobileViewport = (0, import_compose5.useViewportMatch)("medium", "<");
7584 const density = view.layout?.density ?? "balanced";
7585 const mediaContent = showMedia && density !== "compact" && mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7586 mediaField.render,
7587 {
7588 item,
7589 field: mediaField,
7590 config: {
7591 sizes: density === "comfortable" ? "32px" : "24px"
7592 }
7593 }
7594 ) : null;
7595 const renderedMediaField = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-type-icon", children: mediaContent || /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7596 "span",
7597 {
7598 className: "dataviews-view-activity__item-bullet",
7599 "aria-hidden": "true"
7600 }
7601 ) });
7602 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(titleField.render, { item, field: titleField }) : null;
7603 const verticalGap = (0, import_element35.useMemo)(() => {
7604 switch (density) {
7605 case "comfortable":
7606 return "md";
7607 default:
7608 return "sm";
7609 }
7610 }, [density]);
7611 return /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7612 "div",
7613 {
7614 ref: itemRef,
7615 role: infiniteScrollEnabled ? "article" : void 0,
7616 "aria-posinset": posinset,
7617 "aria-setsize": infiniteScrollEnabled ? paginationInfo.totalItems : void 0,
7618 className: clsx_default(
7619 "dataviews-view-activity__item",
7620 density === "compact" && "is-compact",
7621 density === "balanced" && "is-balanced",
7622 density === "comfortable" && "is-comfortable"
7623 ),
7624 children: /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(Stack, { direction: "row", gap: "lg", justify: "start", align: "flex-start", children: [
7625 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7626 Stack,
7627 {
7628 direction: "column",
7629 gap: "xs",
7630 align: "center",
7631 className: "dataviews-view-activity__item-type",
7632 children: renderedMediaField
7633 }
7634 ),
7635 /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
7636 Stack,
7637 {
7638 direction: "column",
7639 gap: verticalGap,
7640 align: "flex-start",
7641 className: "dataviews-view-activity__item-content",
7642 children: [
7643 renderedTitleField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7644 ItemClickWrapper,
7645 {
7646 item,
7647 isItemClickable,
7648 onClickItem,
7649 renderItemLink,
7650 className: "dataviews-view-activity__item-title",
7651 children: renderedTitleField
7652 }
7653 ),
7654 showDescription && descriptionField && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-description", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7655 descriptionField.render,
7656 {
7657 item,
7658 field: descriptionField
7659 }
7660 ) }),
7661 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-fields", children: otherFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime57.jsxs)(
7662 "div",
7663 {
7664 className: "dataviews-view-activity__item-field",
7665 children: [
7666 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7667 VisuallyHidden,
7668 {
7669 className: "dataviews-view-activity__item-field-label",
7670 render: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", {}),
7671 children: field.label
7672 }
7673 ),
7674 /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("span", { className: "dataviews-view-activity__item-field-value", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7675 field.render,
7676 {
7677 item,
7678 field
7679 }
7680 ) })
7681 ]
7682 },
7683 field.id
7684 )) }),
7685 !!primaryActions?.length && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7686 PrimaryActions,
7687 {
7688 item,
7689 actions: primaryActions,
7690 registry,
7691 buttonVariant: "secondary"
7692 }
7693 )
7694 ]
7695 }
7696 ),
7697 (primaryActions.length < eligibleActions.length || // Since we hide primary actions on mobile, we need to show the menu
7698 // there if there are any actions at all.
7699 isMobileViewport && // At the same time, only show the menu if there are actions to show.
7700 eligibleActions.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime57.jsx)("div", { className: "dataviews-view-activity__item-actions", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
7701 ItemActions,
7702 {
7703 item,
7704 actions: eligibleActions,
7705 isCompact: true
7706 }
7707 ) })
7708 ] })
7709 }
7710 );
7711 }
7712 var activity_item_default = ActivityItem;
7713
7714 // packages/dataviews/build-module/components/dataviews-layouts/activity/activity-items.mjs
7715 var import_react10 = __toESM(require_react(), 1);
7716 function isDefined3(item) {
7717 return !!item;
7718 }
7719 function ActivityItems(props) {
7720 const { data, fields: fields2, getItemId, view } = props;
7721 const titleField = fields2.find((field) => field.id === view.titleField);
7722 const mediaField = fields2.find((field) => field.id === view.mediaField);
7723 const descriptionField = fields2.find(
7724 (field) => field.id === view.descriptionField
7725 );
7726 const otherFields = (view?.fields ?? []).map((fieldId) => fields2.find((f2) => fieldId === f2.id)).filter(isDefined3);
7727 return data.map((item, index) => {
7728 return /* @__PURE__ */ (0, import_react10.createElement)(
7729 activity_item_default,
7730 {
7731 ...props,
7732 key: getItemId(item),
7733 item,
7734 mediaField,
7735 titleField,
7736 descriptionField,
7737 otherFields,
7738 posinset: view.infiniteScrollEnabled ? index + 1 : void 0
7739 }
7740 );
7741 });
7742 }
7743
7744 // packages/dataviews/build-module/components/dataviews-layouts/activity/index.mjs
7745 var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);
7746 function ViewActivity(props) {
7747 const { empty, data, fields: fields2, isLoading, view, className } = props;
7748 const isDelayedLoading = useDelayedLoading(!!isLoading);
7749 const hasData = !!data?.length;
7750 const groupField = view.groupBy?.field ? fields2.find((field) => field.id === view.groupBy?.field) : null;
7751 const dataByGroup = hasData && groupField ? getDataByGroup(data, groupField) : null;
7752 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
7753 if (!hasData) {
7754 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
7755 "div",
7756 {
7757 className: clsx_default("dataviews-no-results", {
7758 "is-refreshing": isDelayedLoading
7759 }),
7760 children: empty
7761 }
7762 );
7763 }
7764 const isInert = !isInfiniteScroll && !!isLoading;
7765 const wrapperClassName = clsx_default("dataviews-view-activity", className, {
7766 "is-refreshing": !isInfiniteScroll && isDelayedLoading
7767 });
7768 const groupedEntries = dataByGroup ? Array.from(dataByGroup.entries()) : [];
7769 if (hasData && groupField && dataByGroup) {
7770 return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
7771 Stack,
7772 {
7773 direction: "column",
7774 gap: "sm",
7775 className: wrapperClassName,
7776 inert: isInert ? "true" : void 0,
7777 children: groupedEntries.map(
7778 ([groupName, groupData]) => /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
7779 ActivityGroup,
7780 {
7781 groupName,
7782 groupData,
7783 groupField,
7784 showLabel: view.groupBy?.showLabel !== false,
7785 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
7786 ActivityItems,
7787 {
7788 ...props,
7789 data: groupData
7790 }
7791 )
7792 },
7793 groupName
7794 )
7795 )
7796 }
7797 );
7798 }
7799 return /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)(import_jsx_runtime58.Fragment, { children: [
7800 /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
7801 "div",
7802 {
7803 className: wrapperClassName,
7804 role: view.infiniteScrollEnabled ? "feed" : void 0,
7805 inert: isInert ? "true" : void 0,
7806 children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ActivityItems, { ...props })
7807 }
7808 ),
7809 isInfiniteScroll && isLoading && /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_components13.Spinner, {}) })
7810 ] });
7811 }
7812
7813 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
7814 var import_components16 = __toESM(require_components(), 1);
7815 var import_i18n17 = __toESM(require_i18n(), 1);
7816 var import_compose6 = __toESM(require_compose(), 1);
7817 var import_element38 = __toESM(require_element(), 1);
7818
7819 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
7820 var import_components15 = __toESM(require_components(), 1);
7821 var import_data5 = __toESM(require_data(), 1);
7822 var import_element37 = __toESM(require_element(), 1);
7823 var import_i18n16 = __toESM(require_i18n(), 1);
7824
7825 // packages/dataviews/build-module/components/dataviews-pagination/index.mjs
7826 var import_components14 = __toESM(require_components(), 1);
7827 var import_element36 = __toESM(require_element(), 1);
7828 var import_i18n15 = __toESM(require_i18n(), 1);
7829 var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
7830 function DataViewsPagination() {
7831 const {
7832 view,
7833 onChangeView,
7834 paginationInfo: { totalItems = 0, totalPages }
7835 } = (0, import_element36.useContext)(dataviews_context_default);
7836 if (!totalItems || !totalPages || view.infiniteScrollEnabled) {
7837 return null;
7838 }
7839 const currentPage = view.page ?? 1;
7840 const pageSelectOptions = Array.from(Array(totalPages)).map(
7841 (_, i2) => {
7842 const page = i2 + 1;
7843 return {
7844 value: page.toString(),
7845 label: page.toString(),
7846 "aria-label": currentPage === page ? (0, import_i18n15.sprintf)(
7847 // translators: 1: current page number. 2: total number of pages.
7848 (0, import_i18n15.__)("Page %1$d of %2$d"),
7849 currentPage,
7850 totalPages
7851 ) : page.toString()
7852 };
7853 }
7854 );
7855 return !!totalItems && totalPages !== 1 && /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
7856 Stack,
7857 {
7858 direction: "row",
7859 className: "dataviews-pagination",
7860 justify: "end",
7861 align: "center",
7862 gap: "xl",
7863 children: [
7864 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7865 Stack,
7866 {
7867 direction: "row",
7868 justify: "flex-start",
7869 align: "center",
7870 gap: "xs",
7871 className: "dataviews-pagination__page-select",
7872 children: (0, import_element36.createInterpolateElement)(
7873 (0, import_i18n15.sprintf)(
7874 // translators: 1: Current page number, 2: Total number of pages.
7875 (0, import_i18n15._x)(
7876 "<div>Page</div>%1$s<div>of %2$d</div>",
7877 "paging"
7878 ),
7879 "<CurrentPage />",
7880 totalPages
7881 ),
7882 {
7883 div: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)("div", { "aria-hidden": true }),
7884 // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
7885 CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7886 import_components14.SelectControl,
7887 {
7888 "aria-label": (0, import_i18n15.__)("Current page"),
7889 value: currentPage.toString(),
7890 options: pageSelectOptions,
7891 onChange: (newValue) => {
7892 onChangeView({
7893 ...view,
7894 page: +newValue
7895 });
7896 },
7897 size: "small",
7898 variant: "minimal"
7899 }
7900 )
7901 }
7902 )
7903 }
7904 ),
7905 /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(Stack, { direction: "row", gap: "xs", align: "center", children: [
7906 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7907 import_components14.Button,
7908 {
7909 onClick: () => onChangeView({
7910 ...view,
7911 page: currentPage - 1
7912 }),
7913 disabled: currentPage === 1,
7914 accessibleWhenDisabled: true,
7915 label: (0, import_i18n15.__)("Previous page"),
7916 icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
7917 showTooltip: true,
7918 size: "compact",
7919 tooltipPosition: "top"
7920 }
7921 ),
7922 /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(
7923 import_components14.Button,
7924 {
7925 onClick: () => onChangeView({ ...view, page: currentPage + 1 }),
7926 disabled: currentPage >= totalPages,
7927 accessibleWhenDisabled: true,
7928 label: (0, import_i18n15.__)("Next page"),
7929 icon: (0, import_i18n15.isRTL)() ? previous_default : next_default,
7930 showTooltip: true,
7931 size: "compact",
7932 tooltipPosition: "top"
7933 }
7934 )
7935 ] })
7936 ]
7937 }
7938 );
7939 }
7940 var dataviews_pagination_default = (0, import_element36.memo)(DataViewsPagination);
7941
7942 // packages/dataviews/build-module/components/dataviews-picker-footer/index.mjs
7943 var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);
7944 function useIsMultiselectPicker(actions2) {
7945 return (0, import_element37.useMemo)(() => {
7946 return actions2?.every((action) => action.supportsBulk);
7947 }, [actions2]);
7948 }
7949
7950 // packages/dataviews/build-module/components/dataviews-layouts/picker-grid/index.mjs
7951 var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
7952 var { Badge: WCBadge2 } = unlock(import_components16.privateApis);
7953 function GridItem3({
7954 view,
7955 multiselect,
7956 selection,
7957 onChangeSelection,
7958 getItemId,
7959 item,
7960 mediaField,
7961 titleField,
7962 descriptionField,
7963 regularFields,
7964 badgeFields,
7965 config,
7966 posinset,
7967 setsize
7968 }) {
7969 const { showTitle = true, showMedia = true, showDescription = true } = view;
7970 const id = getItemId(item);
7971 const elementRef = (0, import_element38.useRef)(null);
7972 const isSelected2 = selection.includes(id);
7973 useIntersectionObserver(elementRef, posinset);
7974 const renderedMediaField = mediaField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
7975 mediaField.render,
7976 {
7977 item,
7978 field: mediaField,
7979 config
7980 }
7981 ) : null;
7982 const renderedTitleField = showTitle && titleField?.render ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(titleField.render, { item, field: titleField }) : null;
7983 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
7984 import_components16.Composite.Item,
7985 {
7986 ref: elementRef,
7987 "aria-label": titleField ? titleField.getValue({ item }) || (0, import_i18n17.__)("(no title)") : void 0,
7988 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(Stack, { direction: "column", children, ...props }),
7989 role: "option",
7990 "aria-posinset": posinset,
7991 "aria-setsize": setsize,
7992 className: clsx_default("dataviews-view-picker-grid__card", {
7993 "is-selected": isSelected2
7994 }),
7995 "aria-selected": isSelected2,
7996 onClick: () => {
7997 if (isSelected2) {
7998 onChangeSelection(
7999 selection.filter((itemId) => id !== itemId)
8000 );
8001 } else {
8002 const newSelection = multiselect ? [...selection, id] : [id];
8003 onChangeSelection(newSelection);
8004 }
8005 },
8006 children: [
8007 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__media", children: renderedMediaField }),
8008 showMedia && renderedMediaField && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8009 DataViewsSelectionCheckbox,
8010 {
8011 item,
8012 selection,
8013 onChangeSelection,
8014 getItemId,
8015 titleField,
8016 disabled: false,
8017 "aria-hidden": true,
8018 tabIndex: -1
8019 }
8020 ),
8021 showTitle && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8022 Stack,
8023 {
8024 direction: "row",
8025 justify: "space-between",
8026 className: "dataviews-view-picker-grid__title-actions",
8027 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("div", { className: "dataviews-view-picker-grid__title-field dataviews-title-field", children: renderedTitleField })
8028 }
8029 ),
8030 /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(Stack, { direction: "column", gap: "xs", children: [
8031 showDescription && descriptionField?.render && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8032 descriptionField.render,
8033 {
8034 item,
8035 field: descriptionField
8036 }
8037 ),
8038 !!badgeFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8039 Stack,
8040 {
8041 direction: "row",
8042 className: "dataviews-view-picker-grid__badge-fields",
8043 gap: "sm",
8044 wrap: "wrap",
8045 align: "top",
8046 justify: "flex-start",
8047 children: badgeFields.map((field) => {
8048 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8049 WCBadge2,
8050 {
8051 className: "dataviews-view-picker-grid__field-value",
8052 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8053 field.render,
8054 {
8055 item,
8056 field
8057 }
8058 )
8059 },
8060 field.id
8061 );
8062 })
8063 }
8064 ),
8065 !!regularFields?.length && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8066 Stack,
8067 {
8068 direction: "column",
8069 className: "dataviews-view-picker-grid__fields",
8070 gap: "xs",
8071 children: regularFields.map((field) => {
8072 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8073 import_components16.Flex,
8074 {
8075 className: "dataviews-view-picker-grid__field",
8076 gap: 1,
8077 justify: "flex-start",
8078 expanded: true,
8079 style: { height: "auto" },
8080 direction: "row",
8081 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, { children: [
8082 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.FlexItem, { className: "dataviews-view-picker-grid__field-name", children: field.header }),
8083 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8084 import_components16.FlexItem,
8085 {
8086 className: "dataviews-view-picker-grid__field-value",
8087 style: { maxHeight: "none" },
8088 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8089 field.render,
8090 {
8091 item,
8092 field
8093 }
8094 )
8095 }
8096 )
8097 ] })
8098 },
8099 field.id
8100 );
8101 })
8102 }
8103 )
8104 ] })
8105 ]
8106 },
8107 id
8108 );
8109 }
8110 function GridGroup({
8111 groupName,
8112 groupField,
8113 showLabel = true,
8114 children
8115 }) {
8116 const headerId = (0, import_compose6.useInstanceId)(
8117 GridGroup,
8118 "dataviews-view-picker-grid-group__header"
8119 );
8120 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
8121 Stack,
8122 {
8123 direction: "column",
8124 gap: "sm",
8125 role: "group",
8126 "aria-labelledby": headerId,
8127 children: [
8128 /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8129 "h3",
8130 {
8131 className: "dataviews-view-picker-grid-group__header",
8132 id: headerId,
8133 children: showLabel ? (0, import_i18n17.sprintf)(
8134 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
8135 (0, import_i18n17.__)("%1$s: %2$s"),
8136 groupField.label,
8137 groupName
8138 ) : groupName
8139 }
8140 ),
8141 children
8142 ]
8143 },
8144 groupName
8145 );
8146 }
8147 function ViewPickerGrid({
8148 actions: actions2,
8149 data,
8150 fields: fields2,
8151 getItemId,
8152 isLoading,
8153 onChangeSelection,
8154 selection,
8155 view,
8156 className,
8157 empty
8158 }) {
8159 const { resizeObserverRef, paginationInfo, itemListLabel } = (0, import_element38.useContext)(dataviews_context_default);
8160 const titleField = fields2.find(
8161 (field) => field.id === view?.titleField
8162 );
8163 const mediaField = fields2.find(
8164 (field) => field.id === view?.mediaField
8165 );
8166 const descriptionField = fields2.find(
8167 (field) => field.id === view?.descriptionField
8168 );
8169 const otherFields = view.fields ?? [];
8170 const { regularFields, badgeFields } = otherFields.reduce(
8171 (accumulator, fieldId) => {
8172 const field = fields2.find((f2) => f2.id === fieldId);
8173 if (!field) {
8174 return accumulator;
8175 }
8176 const key = view.layout?.badgeFields?.includes(fieldId) ? "badgeFields" : "regularFields";
8177 accumulator[key].push(field);
8178 return accumulator;
8179 },
8180 { regularFields: [], badgeFields: [] }
8181 );
8182 const hasData = !!data?.length;
8183 const usedPreviewSize = view.layout?.previewSize;
8184 const isMultiselect = useIsMultiselectPicker(actions2);
8185 const size = "900px";
8186 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
8187 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
8188 const isInfiniteScroll = (view.infiniteScrollEnabled && !dataByGroup) ?? false;
8189 const currentPage = view?.page ?? 1;
8190 const perPage = view?.perPage ?? 0;
8191 const setSize = isInfiniteScroll ? paginationInfo?.totalItems : void 0;
8192 const gridColumns = useGridColumns();
8193 const placeholdersNeeded = usePlaceholdersNeeded(
8194 data,
8195 isInfiniteScroll,
8196 gridColumns
8197 );
8198 return /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(import_jsx_runtime61.Fragment, {
8199 // Render multiple groups.
8200 children: [
8201 hasData && groupField && dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8202 import_components16.Composite,
8203 {
8204 virtualFocus: true,
8205 orientation: "horizontal",
8206 role: "listbox",
8207 "aria-multiselectable": isMultiselect,
8208 className: clsx_default(
8209 "dataviews-view-picker-grid",
8210 className,
8211 {
8212 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
8213 view.layout.density
8214 )
8215 }
8216 ),
8217 "aria-label": itemListLabel,
8218 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8219 Stack,
8220 {
8221 direction: "column",
8222 gap: "lg",
8223 children,
8224 ...props
8225 }
8226 ),
8227 children: Array.from(dataByGroup.entries()).map(
8228 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8229 GridGroup,
8230 {
8231 groupName,
8232 groupField,
8233 showLabel: view.groupBy?.showLabel !== false,
8234 children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8235 GridItems,
8236 {
8237 previewSize: usedPreviewSize,
8238 style: {
8239 gridTemplateColumns: usedPreviewSize && `repeat(auto-fill, minmax(${usedPreviewSize}px, 1fr))`
8240 },
8241 "aria-busy": isLoading,
8242 ref: resizeObserverRef,
8243 children: groupItems.map((item) => {
8244 const posInSet = item.position ?? (currentPage - 1) * perPage + data.indexOf(item) + 1;
8245 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8246 GridItem3,
8247 {
8248 view,
8249 multiselect: isMultiselect,
8250 selection,
8251 onChangeSelection,
8252 getItemId,
8253 item,
8254 mediaField,
8255 titleField,
8256 descriptionField,
8257 regularFields,
8258 badgeFields,
8259 config: {
8260 sizes: size
8261 },
8262 posinset: posInSet,
8263 setsize: setSize
8264 },
8265 getItemId(item)
8266 );
8267 })
8268 }
8269 )
8270 },
8271 groupName
8272 )
8273 )
8274 }
8275 ),
8276 // Render a single grid with all data.
8277 hasData && !dataByGroup && /* @__PURE__ */ (0, import_jsx_runtime61.jsxs)(
8278 import_components16.Composite,
8279 {
8280 render: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8281 GridItems,
8282 {
8283 className: clsx_default(
8284 "dataviews-view-picker-grid",
8285 className,
8286 {
8287 [`has-${view.layout?.density}-density`]: view.layout?.density && [
8288 "compact",
8289 "comfortable"
8290 ].includes(view.layout.density)
8291 }
8292 ),
8293 previewSize: usedPreviewSize,
8294 "aria-busy": isLoading,
8295 ref: resizeObserverRef
8296 }
8297 ),
8298 virtualFocus: true,
8299 orientation: "horizontal",
8300 role: "listbox",
8301 "aria-multiselectable": isMultiselect,
8302 "aria-label": itemListLabel,
8303 children: [
8304 Array.from({ length: placeholdersNeeded }).map(
8305 (_, index) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8306 import_components16.Composite.Item,
8307 {
8308 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8309 Stack,
8310 {
8311 direction: "column",
8312 children,
8313 ...props
8314 }
8315 ),
8316 role: "option",
8317 "aria-hidden": true,
8318 tabIndex: -1,
8319 className: "dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder"
8320 },
8321 `placeholder-${index}`
8322 )
8323 ),
8324 data.map((item) => {
8325 const posinset = item.position;
8326 return /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8327 GridItem3,
8328 {
8329 view,
8330 multiselect: isMultiselect,
8331 selection,
8332 onChangeSelection,
8333 getItemId,
8334 item,
8335 mediaField,
8336 titleField,
8337 descriptionField,
8338 regularFields,
8339 badgeFields,
8340 config: {
8341 sizes: size
8342 },
8343 posinset,
8344 setsize: setSize
8345 },
8346 getItemId(item)
8347 );
8348 })
8349 ]
8350 }
8351 ),
8352 // Render empty state.
8353 !hasData && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(
8354 "div",
8355 {
8356 className: clsx_default({
8357 "dataviews-loading": isLoading,
8358 "dataviews-no-results": !isLoading
8359 }),
8360 children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.Spinner, {}) }) : empty
8361 }
8362 ),
8363 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_components16.Spinner, {}) })
8364 ]
8365 });
8366 }
8367 var picker_grid_default = ViewPickerGrid;
8368
8369 // packages/dataviews/build-module/components/dataviews-layouts/picker-table/index.mjs
8370 var import_i18n18 = __toESM(require_i18n(), 1);
8371 var import_components17 = __toESM(require_components(), 1);
8372 var import_element39 = __toESM(require_element(), 1);
8373 var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);
8374 function TableColumnField2({
8375 item,
8376 fields: fields2,
8377 column,
8378 align
8379 }) {
8380 const field = fields2.find((f2) => f2.id === column);
8381 if (!field) {
8382 return null;
8383 }
8384 const className = clsx_default("dataviews-view-table__cell-content-wrapper", {
8385 "dataviews-view-table__cell-align-end": align === "end",
8386 "dataviews-view-table__cell-align-center": align === "center"
8387 });
8388 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(field.render, { item, field }) });
8389 }
8390 function TableRow2({
8391 item,
8392 fields: fields2,
8393 id,
8394 view,
8395 titleField,
8396 mediaField,
8397 descriptionField,
8398 selection,
8399 getItemId,
8400 onChangeSelection,
8401 multiselect,
8402 posinset
8403 }) {
8404 const { paginationInfo } = (0, import_element39.useContext)(dataviews_context_default);
8405 const isSelected2 = selection.includes(id);
8406 const [isHovered, setIsHovered] = (0, import_element39.useState)(false);
8407 const elementRef = (0, import_element39.useRef)(null);
8408 useIntersectionObserver(elementRef, posinset);
8409 const {
8410 showTitle = true,
8411 showMedia = true,
8412 showDescription = true,
8413 infiniteScrollEnabled
8414 } = view;
8415 const handleMouseEnter = () => {
8416 setIsHovered(true);
8417 };
8418 const handleMouseLeave = () => {
8419 setIsHovered(false);
8420 };
8421 const columns = view.fields ?? [];
8422 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
8423 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
8424 import_components17.Composite.Item,
8425 {
8426 ref: elementRef,
8427 render: ({ children, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8428 "tr",
8429 {
8430 className: clsx_default("dataviews-view-table__row", {
8431 "is-selected": isSelected2,
8432 "is-hovered": isHovered
8433 }),
8434 onMouseEnter: handleMouseEnter,
8435 onMouseLeave: handleMouseLeave,
8436 children,
8437 ...props
8438 }
8439 ),
8440 "aria-selected": isSelected2,
8441 "aria-setsize": paginationInfo.totalItems || void 0,
8442 "aria-posinset": posinset,
8443 role: infiniteScrollEnabled ? "article" : "option",
8444 onClick: () => {
8445 if (isSelected2) {
8446 onChangeSelection(
8447 selection.filter((itemId) => id !== itemId)
8448 );
8449 } else {
8450 const newSelection = multiselect ? [...selection, id] : [id];
8451 onChangeSelection(newSelection);
8452 }
8453 },
8454 children: [
8455 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8456 "td",
8457 {
8458 className: "dataviews-view-table__checkbox-column",
8459 role: "presentation",
8460 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("div", { className: "dataviews-view-table__cell-content-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8461 DataViewsSelectionCheckbox,
8462 {
8463 item,
8464 selection,
8465 onChangeSelection,
8466 getItemId,
8467 titleField,
8468 disabled: false,
8469 "aria-hidden": true,
8470 tabIndex: -1
8471 }
8472 ) })
8473 }
8474 ),
8475 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8476 "td",
8477 {
8478 role: "presentation",
8479 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8480 column_primary_default,
8481 {
8482 item,
8483 titleField: showTitle ? titleField : void 0,
8484 mediaField: showMedia ? mediaField : void 0,
8485 descriptionField: showDescription ? descriptionField : void 0,
8486 isItemClickable: () => false
8487 }
8488 )
8489 }
8490 ),
8491 columns.map((column) => {
8492 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
8493 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8494 "td",
8495 {
8496 style: {
8497 width,
8498 maxWidth,
8499 minWidth
8500 },
8501 role: "presentation",
8502 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8503 TableColumnField2,
8504 {
8505 fields: fields2,
8506 item,
8507 column,
8508 align
8509 }
8510 )
8511 },
8512 column
8513 );
8514 })
8515 ]
8516 },
8517 id
8518 );
8519 }
8520 function ViewPickerTable({
8521 actions: actions2,
8522 data,
8523 fields: fields2,
8524 getItemId,
8525 isLoading = false,
8526 onChangeView,
8527 onChangeSelection,
8528 selection,
8529 setOpenedFilter,
8530 view,
8531 className,
8532 empty
8533 }) {
8534 const headerMenuRefs = (0, import_element39.useRef)(/* @__PURE__ */ new Map());
8535 const headerMenuToFocusRef = (0, import_element39.useRef)(void 0);
8536 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0, import_element39.useState)();
8537 const isMultiselect = useIsMultiselectPicker(actions2) ?? false;
8538 (0, import_element39.useEffect)(() => {
8539 if (headerMenuToFocusRef.current) {
8540 headerMenuToFocusRef.current.focus();
8541 headerMenuToFocusRef.current = void 0;
8542 }
8543 });
8544 const groupField = view.groupBy?.field ? fields2.find((f2) => f2.id === view.groupBy?.field) : null;
8545 const dataByGroup = groupField ? getDataByGroup(data, groupField) : null;
8546 const isInfiniteScroll = view.infiniteScrollEnabled && !dataByGroup;
8547 const tableNoticeId = (0, import_element39.useId)();
8548 if (nextHeaderMenuToFocus) {
8549 headerMenuToFocusRef.current = nextHeaderMenuToFocus;
8550 setNextHeaderMenuToFocus(void 0);
8551 return;
8552 }
8553 const onHide = (field) => {
8554 const hidden = headerMenuRefs.current.get(field.id);
8555 const fallback = hidden ? headerMenuRefs.current.get(hidden.fallback) : void 0;
8556 setNextHeaderMenuToFocus(fallback?.node);
8557 };
8558 const hasData = !!data?.length;
8559 const titleField = fields2.find((field) => field.id === view.titleField);
8560 const mediaField = fields2.find((field) => field.id === view.mediaField);
8561 const descriptionField = fields2.find(
8562 (field) => field.id === view.descriptionField
8563 );
8564 const { showTitle = true, showMedia = true, showDescription = true } = view;
8565 const hasPrimaryColumn = titleField && showTitle || mediaField && showMedia || descriptionField && showDescription;
8566 const columns = view.fields ?? [];
8567 const headerMenuRef = (column, index) => (node) => {
8568 if (node) {
8569 headerMenuRefs.current.set(column, {
8570 node,
8571 fallback: columns[index > 0 ? index - 1 : 1]
8572 });
8573 } else {
8574 headerMenuRefs.current.delete(column);
8575 }
8576 };
8577 return /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(import_jsx_runtime62.Fragment, { children: [
8578 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
8579 "table",
8580 {
8581 className: clsx_default(
8582 "dataviews-view-table",
8583 "dataviews-view-picker-table",
8584 className,
8585 {
8586 [`has-${view.layout?.density}-density`]: view.layout?.density && ["compact", "comfortable"].includes(
8587 view.layout.density
8588 )
8589 }
8590 ),
8591 "aria-busy": isLoading,
8592 "aria-describedby": tableNoticeId,
8593 role: isInfiniteScroll ? "feed" : "listbox",
8594 children: [
8595 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("thead", { role: "presentation", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
8596 "tr",
8597 {
8598 className: "dataviews-view-table__row",
8599 role: "presentation",
8600 children: [
8601 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { className: "dataviews-view-table__checkbox-column", children: isMultiselect && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8602 BulkSelectionCheckbox,
8603 {
8604 selection,
8605 onChangeSelection,
8606 data,
8607 actions: actions2,
8608 getItemId,
8609 disableSelectAll: isInfiniteScroll
8610 }
8611 ) }),
8612 hasPrimaryColumn && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("th", { children: titleField && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8613 column_header_menu_default,
8614 {
8615 ref: headerMenuRef(
8616 titleField.id,
8617 0
8618 ),
8619 fieldId: titleField.id,
8620 view,
8621 fields: fields2,
8622 onChangeView,
8623 onHide,
8624 setOpenedFilter,
8625 canMove: false
8626 }
8627 ) }),
8628 columns.map((column, index) => {
8629 const { width, maxWidth, minWidth, align } = view.layout?.styles?.[column] ?? {};
8630 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8631 "th",
8632 {
8633 style: {
8634 width,
8635 maxWidth,
8636 minWidth,
8637 textAlign: align
8638 },
8639 "aria-sort": view.sort?.direction && view.sort?.field === column ? sortValues[view.sort.direction] : void 0,
8640 scope: "col",
8641 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8642 column_header_menu_default,
8643 {
8644 ref: headerMenuRef(column, index),
8645 fieldId: column,
8646 view,
8647 fields: fields2,
8648 onChangeView,
8649 onHide,
8650 setOpenedFilter,
8651 canMove: view.layout?.enableMoving ?? true
8652 }
8653 )
8654 },
8655 column
8656 );
8657 })
8658 ]
8659 }
8660 ) }),
8661 hasData && groupField && dataByGroup ? Array.from(dataByGroup.entries()).map(
8662 ([groupName, groupItems]) => /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
8663 import_components17.Composite,
8664 {
8665 virtualFocus: true,
8666 orientation: "vertical",
8667 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "group" }),
8668 children: [
8669 /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8670 "tr",
8671 {
8672 className: "dataviews-view-table__group-header-row",
8673 role: "presentation",
8674 children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8675 "td",
8676 {
8677 colSpan: columns.length + (hasPrimaryColumn ? 1 : 0) + 1,
8678 className: "dataviews-view-table__group-header-cell",
8679 role: "presentation",
8680 children: view.groupBy?.showLabel === false ? groupName : (0, import_i18n18.sprintf)(
8681 // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022".
8682 (0, import_i18n18.__)("%1$s: %2$s"),
8683 groupField.label,
8684 groupName
8685 )
8686 }
8687 )
8688 }
8689 ),
8690 groupItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8691 TableRow2,
8692 {
8693 item,
8694 fields: fields2,
8695 id: getItemId(item) || index.toString(),
8696 view,
8697 titleField,
8698 mediaField,
8699 descriptionField,
8700 selection,
8701 getItemId,
8702 onChangeSelection,
8703 multiselect: isMultiselect
8704 },
8705 getItemId(item)
8706 ))
8707 ]
8708 },
8709 `group-${groupName}`
8710 )
8711 ) : /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8712 import_components17.Composite,
8713 {
8714 render: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("tbody", { role: "presentation" }),
8715 virtualFocus: true,
8716 orientation: "vertical",
8717 children: hasData && data.map((item, index) => {
8718 const itemId = getItemId(item);
8719 const posinset = item.position;
8720 return /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(
8721 TableRow2,
8722 {
8723 item,
8724 fields: fields2,
8725 id: itemId || index.toString(),
8726 view,
8727 titleField,
8728 mediaField,
8729 descriptionField,
8730 selection,
8731 getItemId,
8732 onChangeSelection,
8733 multiselect: isMultiselect,
8734 posinset
8735 },
8736 itemId
8737 );
8738 })
8739 }
8740 )
8741 ]
8742 }
8743 ),
8744 /* @__PURE__ */ (0, import_jsx_runtime62.jsxs)(
8745 "div",
8746 {
8747 className: clsx_default({
8748 "dataviews-loading": isLoading,
8749 "dataviews-no-results": !hasData && !isLoading
8750 }),
8751 id: tableNoticeId,
8752 children: [
8753 !hasData && (isLoading ? /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components17.Spinner, {}) }) : empty),
8754 hasData && isLoading && /* @__PURE__ */ (0, import_jsx_runtime62.jsx)("p", { className: "dataviews-loading-more", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_components17.Spinner, {}) })
8755 ]
8756 }
8757 )
8758 ] });
8759 }
8760 var picker_table_default = ViewPickerTable;
8761
8762 // packages/dataviews/build-module/components/dataviews-layouts/utils/density-picker.mjs
8763 var import_components18 = __toESM(require_components(), 1);
8764 var import_i18n19 = __toESM(require_i18n(), 1);
8765 var import_element40 = __toESM(require_element(), 1);
8766 var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
8767 function DensityPicker() {
8768 const context = (0, import_element40.useContext)(dataviews_context_default);
8769 const view = context.view;
8770 return /* @__PURE__ */ (0, import_jsx_runtime63.jsxs)(
8771 import_components18.__experimentalToggleGroupControl,
8772 {
8773 size: "__unstable-large",
8774 label: (0, import_i18n19.__)("Density"),
8775 value: view.layout?.density || "balanced",
8776 onChange: (value) => {
8777 context.onChangeView({
8778 ...view,
8779 layout: {
8780 ...view.layout,
8781 density: value
8782 }
8783 });
8784 },
8785 isBlock: true,
8786 children: [
8787 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
8788 import_components18.__experimentalToggleGroupControlOption,
8789 {
8790 value: "comfortable",
8791 label: (0, import_i18n19._x)(
8792 "Comfortable",
8793 "Density option for DataView layout"
8794 )
8795 },
8796 "comfortable"
8797 ),
8798 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
8799 import_components18.__experimentalToggleGroupControlOption,
8800 {
8801 value: "balanced",
8802 label: (0, import_i18n19._x)("Balanced", "Density option for DataView layout")
8803 },
8804 "balanced"
8805 ),
8806 /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
8807 import_components18.__experimentalToggleGroupControlOption,
8808 {
8809 value: "compact",
8810 label: (0, import_i18n19._x)("Compact", "Density option for DataView layout")
8811 },
8812 "compact"
8813 )
8814 ]
8815 }
8816 );
8817 }
8818
8819 // packages/dataviews/build-module/components/dataviews-layouts/utils/preview-size-picker.mjs
8820 var import_components19 = __toESM(require_components(), 1);
8821 var import_i18n20 = __toESM(require_i18n(), 1);
8822 var import_element41 = __toESM(require_element(), 1);
8823 var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
8824 var imageSizes2 = [
8825 {
8826 value: 120,
8827 breakpoint: 1
8828 },
8829 {
8830 value: 170,
8831 breakpoint: 1
8832 },
8833 {
8834 value: 230,
8835 breakpoint: 1
8836 },
8837 {
8838 value: 290,
8839 breakpoint: 1112
8840 // at minimum image width, 4 images display at this container size
8841 },
8842 {
8843 value: 350,
8844 breakpoint: 1636
8845 // at minimum image width, 6 images display at this container size
8846 },
8847 {
8848 value: 430,
8849 breakpoint: 588
8850 // at minimum image width, 2 images display at this container size
8851 }
8852 ];
8853 function PreviewSizePicker() {
8854 const context = (0, import_element41.useContext)(dataviews_context_default);
8855 const view = context.view;
8856 const breakValues = imageSizes2.filter((size) => {
8857 return context.containerWidth >= size.breakpoint;
8858 });
8859 const layoutPreviewSize = view.layout?.previewSize ?? 230;
8860 const previewSizeToUse = breakValues.map((size, index) => ({ ...size, index })).filter((size) => size.value <= layoutPreviewSize).sort((a2, b2) => b2.value - a2.value)[0]?.index ?? 0;
8861 const marks = breakValues.map((size, index) => {
8862 return {
8863 value: index
8864 };
8865 });
8866 return /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(
8867 import_components19.RangeControl,
8868 {
8869 __next40pxDefaultSize: true,
8870 showTooltip: false,
8871 label: (0, import_i18n20.__)("Preview size"),
8872 value: previewSizeToUse,
8873 min: 0,
8874 max: breakValues.length - 1,
8875 withInputField: false,
8876 onChange: (value = 0) => {
8877 context.onChangeView({
8878 ...view,
8879 layout: {
8880 ...view.layout,
8881 previewSize: breakValues[value].value
8882 }
8883 });
8884 },
8885 step: 1,
8886 marks
8887 }
8888 );
8889 }
8890
8891 // packages/dataviews/build-module/components/dataviews-layouts/utils/grid-config-options.mjs
8892 var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
8893 function GridConfigOptions() {
8894 return /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(import_jsx_runtime65.Fragment, { children: [
8895 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(DensityPicker, {}),
8896 /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PreviewSizePicker, {})
8897 ] });
8898 }
8899
8900 // packages/dataviews/build-module/components/dataviews-layouts/index.mjs
8901 var VIEW_LAYOUTS = [
8902 {
8903 type: LAYOUT_TABLE,
8904 label: (0, import_i18n21.__)("Table"),
8905 component: table_default,
8906 icon: block_table_default,
8907 viewConfigOptions: DensityPicker
8908 },
8909 {
8910 type: LAYOUT_GRID,
8911 label: (0, import_i18n21.__)("Grid"),
8912 component: grid_default,
8913 icon: category_default,
8914 viewConfigOptions: GridConfigOptions
8915 },
8916 {
8917 type: LAYOUT_LIST,
8918 label: (0, import_i18n21.__)("List"),
8919 component: ViewList,
8920 icon: (0, import_i18n21.isRTL)() ? format_list_bullets_rtl_default : format_list_bullets_default,
8921 viewConfigOptions: DensityPicker
8922 },
8923 {
8924 type: LAYOUT_ACTIVITY,
8925 label: (0, import_i18n21.__)("Activity"),
8926 component: ViewActivity,
8927 icon: scheduled_default,
8928 viewConfigOptions: DensityPicker
8929 },
8930 {
8931 type: LAYOUT_PICKER_GRID,
8932 label: (0, import_i18n21.__)("Grid"),
8933 component: picker_grid_default,
8934 icon: category_default,
8935 viewConfigOptions: GridConfigOptions,
8936 isPicker: true
8937 },
8938 {
8939 type: LAYOUT_PICKER_TABLE,
8940 label: (0, import_i18n21.__)("Table"),
8941 component: picker_table_default,
8942 icon: block_table_default,
8943 viewConfigOptions: DensityPicker,
8944 isPicker: true
8945 }
8946 ];
8947
8948 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
8949 var import_element49 = __toESM(require_element(), 1);
8950
8951 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
8952 var import_components22 = __toESM(require_components(), 1);
8953 var import_i18n24 = __toESM(require_i18n(), 1);
8954 var import_element46 = __toESM(require_element(), 1);
8955
8956 // node_modules/@ariakit/core/esm/__chunks/XMCVU3LR.js
8957 function noop2(..._) {
8958 }
8959 function applyState(argument, currentValue) {
8960 if (isUpdater(argument)) {
8961 const value = isLazyValue(currentValue) ? currentValue() : currentValue;
8962 return argument(value);
8963 }
8964 return argument;
8965 }
8966 function isUpdater(argument) {
8967 return typeof argument === "function";
8968 }
8969 function isLazyValue(value) {
8970 return typeof value === "function";
8971 }
8972 function hasOwnProperty(object, prop) {
8973 if (typeof Object.hasOwn === "function") {
8974 return Object.hasOwn(object, prop);
8975 }
8976 return Object.prototype.hasOwnProperty.call(object, prop);
8977 }
8978 function chain(...fns) {
8979 return (...args) => {
8980 for (const fn of fns) {
8981 if (typeof fn === "function") {
8982 fn(...args);
8983 }
8984 }
8985 };
8986 }
8987 function normalizeString(str) {
8988 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
8989 }
8990 function omit(object, keys) {
8991 const result = { ...object };
8992 for (const key of keys) {
8993 if (hasOwnProperty(result, key)) {
8994 delete result[key];
8995 }
8996 }
8997 return result;
8998 }
8999 function pick(object, paths) {
9000 const result = {};
9001 for (const key of paths) {
9002 if (hasOwnProperty(object, key)) {
9003 result[key] = object[key];
9004 }
9005 }
9006 return result;
9007 }
9008 function identity(value) {
9009 return value;
9010 }
9011 function invariant(condition, message2) {
9012 if (condition) return;
9013 if (typeof message2 !== "string") throw new Error("Invariant failed");
9014 throw new Error(message2);
9015 }
9016 function getKeys(obj) {
9017 return Object.keys(obj);
9018 }
9019 function isFalsyBooleanCallback(booleanOrCallback, ...args) {
9020 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback;
9021 if (result == null) return false;
9022 return !result;
9023 }
9024 function disabledFromProps(props) {
9025 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
9026 }
9027 function removeUndefinedValues(obj) {
9028 const result = {};
9029 for (const key in obj) {
9030 if (obj[key] !== void 0) {
9031 result[key] = obj[key];
9032 }
9033 }
9034 return result;
9035 }
9036 function defaultValue(...values) {
9037 for (const value of values) {
9038 if (value !== void 0) return value;
9039 }
9040 return void 0;
9041 }
9042
9043 // node_modules/@ariakit/react-core/esm/__chunks/YXGXYGQX.js
9044 var import_react11 = __toESM(require_react(), 1);
9045 function setRef(ref, value) {
9046 if (typeof ref === "function") {
9047 ref(value);
9048 } else if (ref) {
9049 ref.current = value;
9050 }
9051 }
9052 function isValidElementWithRef(element) {
9053 if (!element) return false;
9054 if (!(0, import_react11.isValidElement)(element)) return false;
9055 if ("ref" in element.props) return true;
9056 if ("ref" in element) return true;
9057 return false;
9058 }
9059 function getRefProperty(element) {
9060 if (!isValidElementWithRef(element)) return null;
9061 const props = { ...element.props };
9062 return props.ref || element.ref;
9063 }
9064 function mergeProps2(base, overrides) {
9065 const props = { ...base };
9066 for (const key in overrides) {
9067 if (!hasOwnProperty(overrides, key)) continue;
9068 if (key === "className") {
9069 const prop = "className";
9070 props[prop] = base[prop] ? `${base[prop]} ${overrides[prop]}` : overrides[prop];
9071 continue;
9072 }
9073 if (key === "style") {
9074 const prop = "style";
9075 props[prop] = base[prop] ? { ...base[prop], ...overrides[prop] } : overrides[prop];
9076 continue;
9077 }
9078 const overrideValue = overrides[key];
9079 if (typeof overrideValue === "function" && key.startsWith("on")) {
9080 const baseValue = base[key];
9081 if (typeof baseValue === "function") {
9082 props[key] = (...args) => {
9083 overrideValue(...args);
9084 baseValue(...args);
9085 };
9086 continue;
9087 }
9088 }
9089 props[key] = overrideValue;
9090 }
9091 return props;
9092 }
9093
9094 // node_modules/@ariakit/core/esm/__chunks/3DNM6L6E.js
9095 var canUseDOM = checkIsBrowser();
9096 function checkIsBrowser() {
9097 var _a;
9098 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement);
9099 }
9100 function getDocument(node) {
9101 if (!node) return document;
9102 if ("self" in node) return node.document;
9103 return node.ownerDocument || document;
9104 }
9105 function getActiveElement(node, activeDescendant = false) {
9106 var _a;
9107 const { activeElement } = getDocument(node);
9108 if (!(activeElement == null ? void 0 : activeElement.nodeName)) {
9109 return null;
9110 }
9111 if (isFrame(activeElement) && ((_a = activeElement.contentDocument) == null ? void 0 : _a.body)) {
9112 return getActiveElement(
9113 activeElement.contentDocument.body,
9114 activeDescendant
9115 );
9116 }
9117 if (activeDescendant) {
9118 const id = activeElement.getAttribute("aria-activedescendant");
9119 if (id) {
9120 const element = getDocument(activeElement).getElementById(id);
9121 if (element) {
9122 return element;
9123 }
9124 }
9125 }
9126 return activeElement;
9127 }
9128 function contains(parent, child) {
9129 return parent === child || parent.contains(child);
9130 }
9131 function isFrame(element) {
9132 return element.tagName === "IFRAME";
9133 }
9134 function isButton(element) {
9135 const tagName = element.tagName.toLowerCase();
9136 if (tagName === "button") return true;
9137 if (tagName === "input" && element.type) {
9138 return buttonInputTypes.indexOf(element.type) !== -1;
9139 }
9140 return false;
9141 }
9142 var buttonInputTypes = [
9143 "button",
9144 "color",
9145 "file",
9146 "image",
9147 "reset",
9148 "submit"
9149 ];
9150 function isVisible(element) {
9151 if (typeof element.checkVisibility === "function") {
9152 return element.checkVisibility();
9153 }
9154 const htmlElement = element;
9155 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0;
9156 }
9157 function isTextField(element) {
9158 try {
9159 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null;
9160 const isTextArea = element.tagName === "TEXTAREA";
9161 return isTextInput || isTextArea || false;
9162 } catch (_error) {
9163 return false;
9164 }
9165 }
9166 function isTextbox(element) {
9167 return element.isContentEditable || isTextField(element);
9168 }
9169 function getTextboxValue(element) {
9170 if (isTextField(element)) {
9171 return element.value;
9172 }
9173 if (element.isContentEditable) {
9174 const range = getDocument(element).createRange();
9175 range.selectNodeContents(element);
9176 return range.toString();
9177 }
9178 return "";
9179 }
9180 function getTextboxSelection(element) {
9181 let start = 0;
9182 let end = 0;
9183 if (isTextField(element)) {
9184 start = element.selectionStart || 0;
9185 end = element.selectionEnd || 0;
9186 } else if (element.isContentEditable) {
9187 const selection = getDocument(element).getSelection();
9188 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) {
9189 const range = selection.getRangeAt(0);
9190 const nextRange = range.cloneRange();
9191 nextRange.selectNodeContents(element);
9192 nextRange.setEnd(range.startContainer, range.startOffset);
9193 start = nextRange.toString().length;
9194 nextRange.setEnd(range.endContainer, range.endOffset);
9195 end = nextRange.toString().length;
9196 }
9197 }
9198 return { start, end };
9199 }
9200 function getPopupRole(element, fallback) {
9201 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"];
9202 const role = element == null ? void 0 : element.getAttribute("role");
9203 if (role && allowedPopupRoles.indexOf(role) !== -1) {
9204 return role;
9205 }
9206 return fallback;
9207 }
9208 function getScrollingElement(element) {
9209 if (!element) return null;
9210 const isScrollableOverflow = (overflow) => {
9211 if (overflow === "auto") return true;
9212 if (overflow === "scroll") return true;
9213 return false;
9214 };
9215 if (element.clientHeight && element.scrollHeight > element.clientHeight) {
9216 const { overflowY } = getComputedStyle(element);
9217 if (isScrollableOverflow(overflowY)) return element;
9218 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) {
9219 const { overflowX } = getComputedStyle(element);
9220 if (isScrollableOverflow(overflowX)) return element;
9221 }
9222 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body;
9223 }
9224 function setSelectionRange(element, ...args) {
9225 if (/text|search|password|tel|url/i.test(element.type)) {
9226 element.setSelectionRange(...args);
9227 }
9228 }
9229 function sortBasedOnDOMPosition(items, getElement) {
9230 const pairs = items.map((item, index) => [index, item]);
9231 let isOrderDifferent = false;
9232 pairs.sort(([indexA, a2], [indexB, b2]) => {
9233 const elementA = getElement(a2);
9234 const elementB = getElement(b2);
9235 if (elementA === elementB) return 0;
9236 if (!elementA || !elementB) return 0;
9237 if (isElementPreceding(elementA, elementB)) {
9238 if (indexA > indexB) {
9239 isOrderDifferent = true;
9240 }
9241 return -1;
9242 }
9243 if (indexA < indexB) {
9244 isOrderDifferent = true;
9245 }
9246 return 1;
9247 });
9248 if (isOrderDifferent) {
9249 return pairs.map(([_, item]) => item);
9250 }
9251 return items;
9252 }
9253 function isElementPreceding(a2, b2) {
9254 return Boolean(
9255 b2.compareDocumentPosition(a2) & Node.DOCUMENT_POSITION_PRECEDING
9256 );
9257 }
9258
9259 // node_modules/@ariakit/core/esm/__chunks/SNHYQNEZ.js
9260 function isTouchDevice() {
9261 return canUseDOM && !!navigator.maxTouchPoints;
9262 }
9263 function isApple() {
9264 if (!canUseDOM) return false;
9265 return /mac|iphone|ipad|ipod/i.test(navigator.platform);
9266 }
9267 function isSafari() {
9268 return canUseDOM && isApple() && /apple/i.test(navigator.vendor);
9269 }
9270 function isFirefox() {
9271 return canUseDOM && /firefox\//i.test(navigator.userAgent);
9272 }
9273
9274 // node_modules/@ariakit/core/esm/utils/events.js
9275 function isPortalEvent(event) {
9276 return Boolean(
9277 event.currentTarget && !contains(event.currentTarget, event.target)
9278 );
9279 }
9280 function isSelfTarget(event) {
9281 return event.target === event.currentTarget;
9282 }
9283 function isOpeningInNewTab(event) {
9284 const element = event.currentTarget;
9285 if (!element) return false;
9286 const isAppleDevice = isApple();
9287 if (isAppleDevice && !event.metaKey) return false;
9288 if (!isAppleDevice && !event.ctrlKey) return false;
9289 const tagName = element.tagName.toLowerCase();
9290 if (tagName === "a") return true;
9291 if (tagName === "button" && element.type === "submit") return true;
9292 if (tagName === "input" && element.type === "submit") return true;
9293 return false;
9294 }
9295 function isDownloading(event) {
9296 const element = event.currentTarget;
9297 if (!element) return false;
9298 const tagName = element.tagName.toLowerCase();
9299 if (!event.altKey) return false;
9300 if (tagName === "a") return true;
9301 if (tagName === "button" && element.type === "submit") return true;
9302 if (tagName === "input" && element.type === "submit") return true;
9303 return false;
9304 }
9305 function fireBlurEvent(element, eventInit) {
9306 const event = new FocusEvent("blur", eventInit);
9307 const defaultAllowed = element.dispatchEvent(event);
9308 const bubbleInit = { ...eventInit, bubbles: true };
9309 element.dispatchEvent(new FocusEvent("focusout", bubbleInit));
9310 return defaultAllowed;
9311 }
9312 function fireKeyboardEvent(element, type, eventInit) {
9313 const event = new KeyboardEvent(type, eventInit);
9314 return element.dispatchEvent(event);
9315 }
9316 function fireClickEvent(element, eventInit) {
9317 const event = new MouseEvent("click", eventInit);
9318 return element.dispatchEvent(event);
9319 }
9320 function isFocusEventOutside(event, container) {
9321 const containerElement = container || event.currentTarget;
9322 const relatedTarget = event.relatedTarget;
9323 return !relatedTarget || !contains(containerElement, relatedTarget);
9324 }
9325 function queueBeforeEvent(element, type, callback, timeout) {
9326 const createTimer = (callback2) => {
9327 if (timeout) {
9328 const timerId2 = setTimeout(callback2, timeout);
9329 return () => clearTimeout(timerId2);
9330 }
9331 const timerId = requestAnimationFrame(callback2);
9332 return () => cancelAnimationFrame(timerId);
9333 };
9334 const cancelTimer = createTimer(() => {
9335 element.removeEventListener(type, callSync, true);
9336 callback();
9337 });
9338 const callSync = () => {
9339 cancelTimer();
9340 callback();
9341 };
9342 element.addEventListener(type, callSync, { once: true, capture: true });
9343 return cancelTimer;
9344 }
9345 function addGlobalEventListener(type, listener, options, scope = window) {
9346 const children = [];
9347 try {
9348 scope.document.addEventListener(type, listener, options);
9349 for (const frame of Array.from(scope.frames)) {
9350 children.push(addGlobalEventListener(type, listener, options, frame));
9351 }
9352 } catch (e2) {
9353 }
9354 const removeEventListener = () => {
9355 try {
9356 scope.document.removeEventListener(type, listener, options);
9357 } catch (e2) {
9358 }
9359 for (const remove of children) {
9360 remove();
9361 }
9362 };
9363 return removeEventListener;
9364 }
9365
9366 // node_modules/@ariakit/react-core/esm/__chunks/KPHZR4MB.js
9367 var React23 = __toESM(require_react(), 1);
9368 var import_react12 = __toESM(require_react(), 1);
9369 var _React = { ...React23 };
9370 var useReactId = _React.useId;
9371 var useReactDeferredValue = _React.useDeferredValue;
9372 var useReactInsertionEffect = _React.useInsertionEffect;
9373 var useSafeLayoutEffect = canUseDOM ? import_react12.useLayoutEffect : import_react12.useEffect;
9374 function useInitialValue(value) {
9375 const [initialValue] = (0, import_react12.useState)(value);
9376 return initialValue;
9377 }
9378 function useLiveRef(value) {
9379 const ref = (0, import_react12.useRef)(value);
9380 useSafeLayoutEffect(() => {
9381 ref.current = value;
9382 });
9383 return ref;
9384 }
9385 function useEvent(callback) {
9386 const ref = (0, import_react12.useRef)(() => {
9387 throw new Error("Cannot call an event handler while rendering.");
9388 });
9389 if (useReactInsertionEffect) {
9390 useReactInsertionEffect(() => {
9391 ref.current = callback;
9392 });
9393 } else {
9394 ref.current = callback;
9395 }
9396 return (0, import_react12.useCallback)((...args) => {
9397 var _a;
9398 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args);
9399 }, []);
9400 }
9401 function useTransactionState(callback) {
9402 const [state, setState] = (0, import_react12.useState)(null);
9403 useSafeLayoutEffect(() => {
9404 if (state == null) return;
9405 if (!callback) return;
9406 let prevState = null;
9407 callback((prev) => {
9408 prevState = prev;
9409 return state;
9410 });
9411 return () => {
9412 callback(prevState);
9413 };
9414 }, [state, callback]);
9415 return [state, setState];
9416 }
9417 function useMergeRefs(...refs) {
9418 return (0, import_react12.useMemo)(() => {
9419 if (!refs.some(Boolean)) return;
9420 return (value) => {
9421 for (const ref of refs) {
9422 setRef(ref, value);
9423 }
9424 };
9425 }, refs);
9426 }
9427 function useId5(defaultId) {
9428 if (useReactId) {
9429 const reactId = useReactId();
9430 if (defaultId) return defaultId;
9431 return reactId;
9432 }
9433 const [id, setId] = (0, import_react12.useState)(defaultId);
9434 useSafeLayoutEffect(() => {
9435 if (defaultId || id) return;
9436 const random = Math.random().toString(36).slice(2, 8);
9437 setId(`id-${random}`);
9438 }, [defaultId, id]);
9439 return defaultId || id;
9440 }
9441 function useTagName(refOrElement, type) {
9442 const stringOrUndefined = (type2) => {
9443 if (typeof type2 !== "string") return;
9444 return type2;
9445 };
9446 const [tagName, setTagName] = (0, import_react12.useState)(() => stringOrUndefined(type));
9447 useSafeLayoutEffect(() => {
9448 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
9449 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type));
9450 }, [refOrElement, type]);
9451 return tagName;
9452 }
9453 function useAttribute(refOrElement, attributeName, defaultValue2) {
9454 const initialValue = useInitialValue(defaultValue2);
9455 const [attribute, setAttribute] = (0, import_react12.useState)(initialValue);
9456 (0, import_react12.useEffect)(() => {
9457 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement;
9458 if (!element) return;
9459 const callback = () => {
9460 const value = element.getAttribute(attributeName);
9461 setAttribute(value == null ? initialValue : value);
9462 };
9463 const observer = new MutationObserver(callback);
9464 observer.observe(element, { attributeFilter: [attributeName] });
9465 callback();
9466 return () => observer.disconnect();
9467 }, [refOrElement, attributeName, initialValue]);
9468 return attribute;
9469 }
9470 function useUpdateEffect(effect, deps) {
9471 const mounted = (0, import_react12.useRef)(false);
9472 (0, import_react12.useEffect)(() => {
9473 if (mounted.current) {
9474 return effect();
9475 }
9476 mounted.current = true;
9477 }, deps);
9478 (0, import_react12.useEffect)(
9479 () => () => {
9480 mounted.current = false;
9481 },
9482 []
9483 );
9484 }
9485 function useUpdateLayoutEffect(effect, deps) {
9486 const mounted = (0, import_react12.useRef)(false);
9487 useSafeLayoutEffect(() => {
9488 if (mounted.current) {
9489 return effect();
9490 }
9491 mounted.current = true;
9492 }, deps);
9493 useSafeLayoutEffect(
9494 () => () => {
9495 mounted.current = false;
9496 },
9497 []
9498 );
9499 }
9500 function useForceUpdate() {
9501 return (0, import_react12.useReducer)(() => [], []);
9502 }
9503 function useBooleanEvent(booleanOrCallback) {
9504 return useEvent(
9505 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback
9506 );
9507 }
9508 function useWrapElement(props, callback, deps = []) {
9509 const wrapElement = (0, import_react12.useCallback)(
9510 (element) => {
9511 if (props.wrapElement) {
9512 element = props.wrapElement(element);
9513 }
9514 return callback(element);
9515 },
9516 [...deps, props.wrapElement]
9517 );
9518 return { ...props, wrapElement };
9519 }
9520 function useMetadataProps(props, key, value) {
9521 const parent = props.onLoadedMetadataCapture;
9522 const onLoadedMetadataCapture = (0, import_react12.useMemo)(() => {
9523 return Object.assign(() => {
9524 }, { ...parent, [key]: value });
9525 }, [parent, key, value]);
9526 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }];
9527 }
9528 var hasInstalledGlobalEventListeners = false;
9529 function useIsMouseMoving() {
9530 (0, import_react12.useEffect)(() => {
9531 if (hasInstalledGlobalEventListeners) return;
9532 addGlobalEventListener("mousemove", setMouseMoving, true);
9533 addGlobalEventListener("mousedown", resetMouseMoving, true);
9534 addGlobalEventListener("mouseup", resetMouseMoving, true);
9535 addGlobalEventListener("keydown", resetMouseMoving, true);
9536 addGlobalEventListener("scroll", resetMouseMoving, true);
9537 hasInstalledGlobalEventListeners = true;
9538 }, []);
9539 const isMouseMoving = useEvent(() => mouseMoving);
9540 return isMouseMoving;
9541 }
9542 var mouseMoving = false;
9543 var previousScreenX = 0;
9544 var previousScreenY = 0;
9545 function hasMouseMovement(event) {
9546 const movementX = event.movementX || event.screenX - previousScreenX;
9547 const movementY = event.movementY || event.screenY - previousScreenY;
9548 previousScreenX = event.screenX;
9549 previousScreenY = event.screenY;
9550 return movementX || movementY || false;
9551 }
9552 function setMouseMoving(event) {
9553 if (!hasMouseMovement(event)) return;
9554 mouseMoving = true;
9555 }
9556 function resetMouseMoving() {
9557 mouseMoving = false;
9558 }
9559
9560 // node_modules/@ariakit/react-core/esm/__chunks/GWSL6KNJ.js
9561 var React24 = __toESM(require_react(), 1);
9562 var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
9563 function forwardRef26(render4) {
9564 const Role = React24.forwardRef(
9565 // @ts-ignore Incompatible with React 19 types. Ignore for now.
9566 (props, ref) => render4({ ...props, ref })
9567 );
9568 Role.displayName = render4.displayName || render4.name;
9569 return Role;
9570 }
9571 function memo22(Component, propsAreEqual) {
9572 return React24.memo(Component, propsAreEqual);
9573 }
9574 function createElement3(Type, props) {
9575 const { wrapElement, render: render4, ...rest } = props;
9576 const mergedRef = useMergeRefs(props.ref, getRefProperty(render4));
9577 let element;
9578 if (React24.isValidElement(render4)) {
9579 const renderProps = {
9580 // @ts-ignore Incompatible with React 19 types. Ignore for now.
9581 ...render4.props,
9582 ref: mergedRef
9583 };
9584 element = React24.cloneElement(render4, mergeProps2(rest, renderProps));
9585 } else if (render4) {
9586 element = render4(rest);
9587 } else {
9588 element = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Type, { ...rest });
9589 }
9590 if (wrapElement) {
9591 return wrapElement(element);
9592 }
9593 return element;
9594 }
9595 function createHook(useProps) {
9596 const useRole = (props = {}) => {
9597 return useProps(props);
9598 };
9599 useRole.displayName = useProps.name;
9600 return useRole;
9601 }
9602 function createStoreContext(providers = [], scopedProviders = []) {
9603 const context = React24.createContext(void 0);
9604 const scopedContext = React24.createContext(void 0);
9605 const useContext210 = () => React24.useContext(context);
9606 const useScopedContext = (onlyScoped = false) => {
9607 const scoped = React24.useContext(scopedContext);
9608 const store2 = useContext210();
9609 if (onlyScoped) return scoped;
9610 return scoped || store2;
9611 };
9612 const useProviderContext = () => {
9613 const scoped = React24.useContext(scopedContext);
9614 const store2 = useContext210();
9615 if (scoped && scoped === store2) return;
9616 return store2;
9617 };
9618 const ContextProvider = (props) => {
9619 return providers.reduceRight(
9620 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
9621 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(context.Provider, { ...props })
9622 );
9623 };
9624 const ScopedContextProvider = (props) => {
9625 return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(ContextProvider, { ...props, children: scopedProviders.reduceRight(
9626 (children, Provider) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(Provider, { ...props, children }),
9627 /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(scopedContext.Provider, { ...props })
9628 ) });
9629 };
9630 return {
9631 context,
9632 scopedContext,
9633 useContext: useContext210,
9634 useScopedContext,
9635 useProviderContext,
9636 ContextProvider,
9637 ScopedContextProvider
9638 };
9639 }
9640
9641 // node_modules/@ariakit/react-core/esm/__chunks/SMPCIMZM.js
9642 var ctx = createStoreContext();
9643 var useCollectionContext = ctx.useContext;
9644 var useCollectionScopedContext = ctx.useScopedContext;
9645 var useCollectionProviderContext = ctx.useProviderContext;
9646 var CollectionContextProvider = ctx.ContextProvider;
9647 var CollectionScopedContextProvider = ctx.ScopedContextProvider;
9648
9649 // node_modules/@ariakit/react-core/esm/__chunks/AVVXDJMZ.js
9650 var import_react13 = __toESM(require_react(), 1);
9651 var ctx2 = createStoreContext(
9652 [CollectionContextProvider],
9653 [CollectionScopedContextProvider]
9654 );
9655 var useCompositeContext = ctx2.useContext;
9656 var useCompositeScopedContext = ctx2.useScopedContext;
9657 var useCompositeProviderContext = ctx2.useProviderContext;
9658 var CompositeContextProvider = ctx2.ContextProvider;
9659 var CompositeScopedContextProvider = ctx2.ScopedContextProvider;
9660 var CompositeItemContext = (0, import_react13.createContext)(
9661 void 0
9662 );
9663 var CompositeRowContext = (0, import_react13.createContext)(
9664 void 0
9665 );
9666
9667 // node_modules/@ariakit/react-core/esm/__chunks/5VQZOHHZ.js
9668 function findFirstEnabledItem(items, excludeId) {
9669 return items.find((item) => {
9670 if (excludeId) {
9671 return !item.disabled && item.id !== excludeId;
9672 }
9673 return !item.disabled;
9674 });
9675 }
9676 function getEnabledItem(store2, id) {
9677 if (!id) return null;
9678 return store2.item(id) || null;
9679 }
9680 function groupItemsByRows(items) {
9681 const rows = [];
9682 for (const item of items) {
9683 const row = rows.find((currentRow) => {
9684 var _a;
9685 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
9686 });
9687 if (row) {
9688 row.push(item);
9689 } else {
9690 rows.push([item]);
9691 }
9692 }
9693 return rows;
9694 }
9695 function selectTextField(element, collapseToEnd = false) {
9696 if (isTextField(element)) {
9697 element.setSelectionRange(
9698 collapseToEnd ? element.value.length : 0,
9699 element.value.length
9700 );
9701 } else if (element.isContentEditable) {
9702 const selection = getDocument(element).getSelection();
9703 selection == null ? void 0 : selection.selectAllChildren(element);
9704 if (collapseToEnd) {
9705 selection == null ? void 0 : selection.collapseToEnd();
9706 }
9707 }
9708 }
9709 var FOCUS_SILENTLY = /* @__PURE__ */ Symbol("FOCUS_SILENTLY");
9710 function focusSilently(element) {
9711 element[FOCUS_SILENTLY] = true;
9712 element.focus({ preventScroll: true });
9713 }
9714 function silentlyFocused(element) {
9715 const isSilentlyFocused = element[FOCUS_SILENTLY];
9716 delete element[FOCUS_SILENTLY];
9717 return isSilentlyFocused;
9718 }
9719 function isItem(store2, element, exclude) {
9720 if (!element) return false;
9721 if (element === exclude) return false;
9722 const item = store2.item(element.id);
9723 if (!item) return false;
9724 if (exclude && item.element === exclude) return false;
9725 return true;
9726 }
9727
9728 // node_modules/@ariakit/react-core/esm/__chunks/Z2O3VLAQ.js
9729 var import_react14 = __toESM(require_react(), 1);
9730 var TagName = "div";
9731 var useCollectionItem = createHook(
9732 function useCollectionItem2({
9733 store: store2,
9734 shouldRegisterItem = true,
9735 getItem = identity,
9736 // @ts-expect-error This prop may come from a collection renderer.
9737 element,
9738 ...props
9739 }) {
9740 const context = useCollectionContext();
9741 store2 = store2 || context;
9742 const id = useId5(props.id);
9743 const ref = (0, import_react14.useRef)(element);
9744 (0, import_react14.useEffect)(() => {
9745 const element2 = ref.current;
9746 if (!id) return;
9747 if (!element2) return;
9748 if (!shouldRegisterItem) return;
9749 const item = getItem({ id, element: element2 });
9750 return store2 == null ? void 0 : store2.renderItem(item);
9751 }, [id, shouldRegisterItem, getItem, store2]);
9752 props = {
9753 ...props,
9754 ref: useMergeRefs(ref, props.ref)
9755 };
9756 return removeUndefinedValues(props);
9757 }
9758 );
9759 var CollectionItem = forwardRef26(function CollectionItem2(props) {
9760 const htmlProps = useCollectionItem(props);
9761 return createElement3(TagName, htmlProps);
9762 });
9763
9764 // node_modules/@ariakit/react-core/esm/__chunks/SWN3JYXT.js
9765 var import_react15 = __toESM(require_react(), 1);
9766 var FocusableContext = (0, import_react15.createContext)(true);
9767
9768 // node_modules/@ariakit/core/esm/utils/focus.js
9769 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'])";
9770 function isFocusable(element) {
9771 if (!element.matches(selector)) return false;
9772 if (!isVisible(element)) return false;
9773 if (element.closest("[inert]")) return false;
9774 return true;
9775 }
9776 function getClosestFocusable(element) {
9777 while (element && !isFocusable(element)) {
9778 element = element.closest(selector);
9779 }
9780 return element || null;
9781 }
9782 function hasFocus(element) {
9783 const activeElement = getActiveElement(element);
9784 if (!activeElement) return false;
9785 if (activeElement === element) return true;
9786 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
9787 if (!activeDescendant) return false;
9788 return activeDescendant === element.id;
9789 }
9790 function hasFocusWithin(element) {
9791 const activeElement = getActiveElement(element);
9792 if (!activeElement) return false;
9793 if (contains(element, activeElement)) return true;
9794 const activeDescendant = activeElement.getAttribute("aria-activedescendant");
9795 if (!activeDescendant) return false;
9796 if (!("id" in element)) return false;
9797 if (activeDescendant === element.id) return true;
9798 return !!element.querySelector(`#${CSS.escape(activeDescendant)}`);
9799 }
9800 function focusIfNeeded(element) {
9801 if (!hasFocusWithin(element) && isFocusable(element)) {
9802 element.focus();
9803 }
9804 }
9805 function focusIntoView(element, options) {
9806 if (!("scrollIntoView" in element)) {
9807 element.focus();
9808 } else {
9809 element.focus({ preventScroll: true });
9810 element.scrollIntoView({ block: "nearest", inline: "nearest", ...options });
9811 }
9812 }
9813
9814 // node_modules/@ariakit/react-core/esm/__chunks/U6HHPQDW.js
9815 var import_react16 = __toESM(require_react(), 1);
9816 var TagName2 = "div";
9817 var isSafariBrowser = isSafari();
9818 var alwaysFocusVisibleInputTypes = [
9819 "text",
9820 "search",
9821 "url",
9822 "tel",
9823 "email",
9824 "password",
9825 "number",
9826 "date",
9827 "month",
9828 "week",
9829 "time",
9830 "datetime",
9831 "datetime-local"
9832 ];
9833 var safariFocusAncestorSymbol = /* @__PURE__ */ Symbol("safariFocusAncestor");
9834 function markSafariFocusAncestor(element, value) {
9835 if (!element) return;
9836 element[safariFocusAncestorSymbol] = value;
9837 }
9838 function isAlwaysFocusVisible(element) {
9839 const { tagName, readOnly, type } = element;
9840 if (tagName === "TEXTAREA" && !readOnly) return true;
9841 if (tagName === "SELECT" && !readOnly) return true;
9842 if (tagName === "INPUT" && !readOnly) {
9843 return alwaysFocusVisibleInputTypes.includes(type);
9844 }
9845 if (element.isContentEditable) return true;
9846 const role = element.getAttribute("role");
9847 if (role === "combobox" && element.dataset.name) {
9848 return true;
9849 }
9850 return false;
9851 }
9852 function getLabels(element) {
9853 if ("labels" in element) {
9854 return element.labels;
9855 }
9856 return null;
9857 }
9858 function isNativeCheckboxOrRadio(element) {
9859 const tagName = element.tagName.toLowerCase();
9860 if (tagName === "input" && element.type) {
9861 return element.type === "radio" || element.type === "checkbox";
9862 }
9863 return false;
9864 }
9865 function isNativeTabbable(tagName) {
9866 if (!tagName) return true;
9867 return tagName === "button" || tagName === "summary" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a";
9868 }
9869 function supportsDisabledAttribute(tagName) {
9870 if (!tagName) return true;
9871 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea";
9872 }
9873 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) {
9874 if (!focusable) {
9875 return tabIndexProp;
9876 }
9877 if (trulyDisabled) {
9878 if (nativeTabbable && !supportsDisabled) {
9879 return -1;
9880 }
9881 return;
9882 }
9883 if (nativeTabbable) {
9884 return tabIndexProp;
9885 }
9886 return tabIndexProp || 0;
9887 }
9888 function useDisableEvent(onEvent, disabled2) {
9889 return useEvent((event) => {
9890 onEvent == null ? void 0 : onEvent(event);
9891 if (event.defaultPrevented) return;
9892 if (disabled2) {
9893 event.stopPropagation();
9894 event.preventDefault();
9895 }
9896 });
9897 }
9898 var hasInstalledGlobalEventListeners2 = false;
9899 var isKeyboardModality = true;
9900 function onGlobalMouseDown(event) {
9901 const target = event.target;
9902 if (target && "hasAttribute" in target) {
9903 if (!target.hasAttribute("data-focus-visible")) {
9904 isKeyboardModality = false;
9905 }
9906 }
9907 }
9908 function onGlobalKeyDown(event) {
9909 if (event.metaKey) return;
9910 if (event.ctrlKey) return;
9911 if (event.altKey) return;
9912 isKeyboardModality = true;
9913 }
9914 var useFocusable = createHook(
9915 function useFocusable2({
9916 focusable = true,
9917 accessibleWhenDisabled,
9918 autoFocus,
9919 onFocusVisible,
9920 ...props
9921 }) {
9922 const ref = (0, import_react16.useRef)(null);
9923 (0, import_react16.useEffect)(() => {
9924 if (!focusable) return;
9925 if (hasInstalledGlobalEventListeners2) return;
9926 addGlobalEventListener("mousedown", onGlobalMouseDown, true);
9927 addGlobalEventListener("keydown", onGlobalKeyDown, true);
9928 hasInstalledGlobalEventListeners2 = true;
9929 }, [focusable]);
9930 if (isSafariBrowser) {
9931 (0, import_react16.useEffect)(() => {
9932 if (!focusable) return;
9933 const element = ref.current;
9934 if (!element) return;
9935 if (!isNativeCheckboxOrRadio(element)) return;
9936 const labels = getLabels(element);
9937 if (!labels) return;
9938 const onMouseUp = () => queueMicrotask(() => element.focus());
9939 for (const label of labels) {
9940 label.addEventListener("mouseup", onMouseUp);
9941 }
9942 return () => {
9943 for (const label of labels) {
9944 label.removeEventListener("mouseup", onMouseUp);
9945 }
9946 };
9947 }, [focusable]);
9948 }
9949 const disabled2 = focusable && disabledFromProps(props);
9950 const trulyDisabled = !!disabled2 && !accessibleWhenDisabled;
9951 const [focusVisible, setFocusVisible] = (0, import_react16.useState)(false);
9952 (0, import_react16.useEffect)(() => {
9953 if (!focusable) return;
9954 if (trulyDisabled && focusVisible) {
9955 setFocusVisible(false);
9956 }
9957 }, [focusable, trulyDisabled, focusVisible]);
9958 (0, import_react16.useEffect)(() => {
9959 if (!focusable) return;
9960 if (!focusVisible) return;
9961 const element = ref.current;
9962 if (!element) return;
9963 if (typeof IntersectionObserver === "undefined") return;
9964 const observer = new IntersectionObserver(() => {
9965 if (!isFocusable(element)) {
9966 setFocusVisible(false);
9967 }
9968 });
9969 observer.observe(element);
9970 return () => observer.disconnect();
9971 }, [focusable, focusVisible]);
9972 const onKeyPressCapture = useDisableEvent(
9973 props.onKeyPressCapture,
9974 disabled2
9975 );
9976 const onMouseDownCapture = useDisableEvent(
9977 props.onMouseDownCapture,
9978 disabled2
9979 );
9980 const onClickCapture = useDisableEvent(props.onClickCapture, disabled2);
9981 const onMouseDownProp = props.onMouseDown;
9982 const onMouseDown = useEvent((event) => {
9983 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
9984 if (event.defaultPrevented) return;
9985 if (!focusable) return;
9986 const element = event.currentTarget;
9987 if (!isSafariBrowser) return;
9988 if (isPortalEvent(event)) return;
9989 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) return;
9990 let receivedFocus = false;
9991 const onFocus = () => {
9992 receivedFocus = true;
9993 };
9994 const options = { capture: true, once: true };
9995 element.addEventListener("focusin", onFocus, options);
9996 const focusableContainer = getClosestFocusable(element.parentElement);
9997 markSafariFocusAncestor(focusableContainer, true);
9998 queueBeforeEvent(element, "mouseup", () => {
9999 element.removeEventListener("focusin", onFocus, true);
10000 markSafariFocusAncestor(focusableContainer, false);
10001 if (receivedFocus) return;
10002 focusIfNeeded(element);
10003 });
10004 });
10005 const handleFocusVisible = (event, currentTarget) => {
10006 if (currentTarget) {
10007 event.currentTarget = currentTarget;
10008 }
10009 if (!focusable) return;
10010 const element = event.currentTarget;
10011 if (!element) return;
10012 if (!hasFocus(element)) return;
10013 onFocusVisible == null ? void 0 : onFocusVisible(event);
10014 if (event.defaultPrevented) return;
10015 element.dataset.focusVisible = "true";
10016 setFocusVisible(true);
10017 };
10018 const onKeyDownCaptureProp = props.onKeyDownCapture;
10019 const onKeyDownCapture = useEvent((event) => {
10020 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event);
10021 if (event.defaultPrevented) return;
10022 if (!focusable) return;
10023 if (focusVisible) return;
10024 if (event.metaKey) return;
10025 if (event.altKey) return;
10026 if (event.ctrlKey) return;
10027 if (!isSelfTarget(event)) return;
10028 const element = event.currentTarget;
10029 const applyFocusVisible = () => handleFocusVisible(event, element);
10030 queueBeforeEvent(element, "focusout", applyFocusVisible);
10031 });
10032 const onFocusCaptureProp = props.onFocusCapture;
10033 const onFocusCapture = useEvent((event) => {
10034 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
10035 if (event.defaultPrevented) return;
10036 if (!focusable) return;
10037 if (!isSelfTarget(event)) {
10038 setFocusVisible(false);
10039 return;
10040 }
10041 const element = event.currentTarget;
10042 const applyFocusVisible = () => handleFocusVisible(event, element);
10043 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) {
10044 queueBeforeEvent(event.target, "focusout", applyFocusVisible);
10045 } else {
10046 setFocusVisible(false);
10047 }
10048 });
10049 const onBlurProp = props.onBlur;
10050 const onBlur = useEvent((event) => {
10051 onBlurProp == null ? void 0 : onBlurProp(event);
10052 if (!focusable) return;
10053 if (!isFocusEventOutside(event)) return;
10054 event.currentTarget.removeAttribute("data-focus-visible");
10055 setFocusVisible(false);
10056 });
10057 const autoFocusOnShow = (0, import_react16.useContext)(FocusableContext);
10058 const autoFocusRef = useEvent((element) => {
10059 if (!focusable) return;
10060 if (!autoFocus) return;
10061 if (!element) return;
10062 if (!autoFocusOnShow) return;
10063 queueMicrotask(() => {
10064 if (hasFocus(element)) return;
10065 if (!isFocusable(element)) return;
10066 element.focus();
10067 });
10068 });
10069 const tagName = useTagName(ref);
10070 const nativeTabbable = focusable && isNativeTabbable(tagName);
10071 const supportsDisabled = focusable && supportsDisabledAttribute(tagName);
10072 const styleProp = props.style;
10073 const style = (0, import_react16.useMemo)(() => {
10074 if (trulyDisabled) {
10075 return { pointerEvents: "none", ...styleProp };
10076 }
10077 return styleProp;
10078 }, [trulyDisabled, styleProp]);
10079 props = {
10080 "data-focus-visible": focusable && focusVisible || void 0,
10081 "data-autofocus": autoFocus || void 0,
10082 "aria-disabled": disabled2 || void 0,
10083 ...props,
10084 ref: useMergeRefs(ref, autoFocusRef, props.ref),
10085 style,
10086 tabIndex: getTabIndex(
10087 focusable,
10088 trulyDisabled,
10089 nativeTabbable,
10090 supportsDisabled,
10091 props.tabIndex
10092 ),
10093 disabled: supportsDisabled && trulyDisabled ? true : void 0,
10094 // TODO: Test Focusable contentEditable.
10095 contentEditable: disabled2 ? void 0 : props.contentEditable,
10096 onKeyPressCapture,
10097 onClickCapture,
10098 onMouseDownCapture,
10099 onMouseDown,
10100 onKeyDownCapture,
10101 onFocusCapture,
10102 onBlur
10103 };
10104 return removeUndefinedValues(props);
10105 }
10106 );
10107 var Focusable = forwardRef26(function Focusable2(props) {
10108 const htmlProps = useFocusable(props);
10109 return createElement3(TagName2, htmlProps);
10110 });
10111
10112 // node_modules/@ariakit/react-core/esm/__chunks/PZ3OL7I2.js
10113 var import_react17 = __toESM(require_react(), 1);
10114 var TagName3 = "button";
10115 function isNativeClick(event) {
10116 if (!event.isTrusted) return false;
10117 const element = event.currentTarget;
10118 if (event.key === "Enter") {
10119 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A";
10120 }
10121 if (event.key === " ") {
10122 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT";
10123 }
10124 return false;
10125 }
10126 var symbol = /* @__PURE__ */ Symbol("command");
10127 var useCommand = createHook(
10128 function useCommand2({ clickOnEnter = true, clickOnSpace = true, ...props }) {
10129 const ref = (0, import_react17.useRef)(null);
10130 const [isNativeButton, setIsNativeButton] = (0, import_react17.useState)(false);
10131 (0, import_react17.useEffect)(() => {
10132 if (!ref.current) return;
10133 setIsNativeButton(isButton(ref.current));
10134 }, []);
10135 const [active, setActive] = (0, import_react17.useState)(false);
10136 const activeRef = (0, import_react17.useRef)(false);
10137 const disabled2 = disabledFromProps(props);
10138 const [isDuplicate, metadataProps] = useMetadataProps(props, symbol, true);
10139 const onKeyDownProp = props.onKeyDown;
10140 const onKeyDown = useEvent((event) => {
10141 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
10142 const element = event.currentTarget;
10143 if (event.defaultPrevented) return;
10144 if (isDuplicate) return;
10145 if (disabled2) return;
10146 if (!isSelfTarget(event)) return;
10147 if (isTextField(element)) return;
10148 if (element.isContentEditable) return;
10149 const isEnter = clickOnEnter && event.key === "Enter";
10150 const isSpace = clickOnSpace && event.key === " ";
10151 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter;
10152 const shouldPreventSpace = event.key === " " && !clickOnSpace;
10153 if (shouldPreventEnter || shouldPreventSpace) {
10154 event.preventDefault();
10155 return;
10156 }
10157 if (isEnter || isSpace) {
10158 const nativeClick = isNativeClick(event);
10159 if (isEnter) {
10160 if (!nativeClick) {
10161 event.preventDefault();
10162 const { view, ...eventInit } = event;
10163 const click = () => fireClickEvent(element, eventInit);
10164 if (isFirefox()) {
10165 queueBeforeEvent(element, "keyup", click);
10166 } else {
10167 queueMicrotask(click);
10168 }
10169 }
10170 } else if (isSpace) {
10171 activeRef.current = true;
10172 if (!nativeClick) {
10173 event.preventDefault();
10174 setActive(true);
10175 }
10176 }
10177 }
10178 });
10179 const onKeyUpProp = props.onKeyUp;
10180 const onKeyUp = useEvent((event) => {
10181 onKeyUpProp == null ? void 0 : onKeyUpProp(event);
10182 if (event.defaultPrevented) return;
10183 if (isDuplicate) return;
10184 if (disabled2) return;
10185 if (event.metaKey) return;
10186 const isSpace = clickOnSpace && event.key === " ";
10187 if (activeRef.current && isSpace) {
10188 activeRef.current = false;
10189 if (!isNativeClick(event)) {
10190 event.preventDefault();
10191 setActive(false);
10192 const element = event.currentTarget;
10193 const { view, ...eventInit } = event;
10194 queueMicrotask(() => fireClickEvent(element, eventInit));
10195 }
10196 }
10197 });
10198 props = {
10199 "data-active": active || void 0,
10200 type: isNativeButton ? "button" : void 0,
10201 ...metadataProps,
10202 ...props,
10203 ref: useMergeRefs(ref, props.ref),
10204 onKeyDown,
10205 onKeyUp
10206 };
10207 props = useFocusable(props);
10208 return props;
10209 }
10210 );
10211 var Command = forwardRef26(function Command2(props) {
10212 const htmlProps = useCommand(props);
10213 return createElement3(TagName3, htmlProps);
10214 });
10215
10216 // node_modules/@ariakit/core/esm/__chunks/SXKM4CGU.js
10217 function getInternal(store2, key) {
10218 const internals = store2.__unstableInternals;
10219 invariant(internals, "Invalid store");
10220 return internals[key];
10221 }
10222 function createStore(initialState, ...stores) {
10223 let state = initialState;
10224 let prevStateBatch = state;
10225 let lastUpdate = /* @__PURE__ */ Symbol();
10226 let destroy = noop2;
10227 const instances = /* @__PURE__ */ new Set();
10228 const updatedKeys = /* @__PURE__ */ new Set();
10229 const setups = /* @__PURE__ */ new Set();
10230 const listeners = /* @__PURE__ */ new Set();
10231 const batchListeners = /* @__PURE__ */ new Set();
10232 const disposables = /* @__PURE__ */ new WeakMap();
10233 const listenerKeys = /* @__PURE__ */ new WeakMap();
10234 const storeSetup = (callback) => {
10235 setups.add(callback);
10236 return () => setups.delete(callback);
10237 };
10238 const storeInit = () => {
10239 const initialized = instances.size;
10240 const instance = /* @__PURE__ */ Symbol();
10241 instances.add(instance);
10242 const maybeDestroy = () => {
10243 instances.delete(instance);
10244 if (instances.size) return;
10245 destroy();
10246 };
10247 if (initialized) return maybeDestroy;
10248 const desyncs = getKeys(state).map(
10249 (key) => chain(
10250 ...stores.map((store2) => {
10251 var _a;
10252 const storeState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2);
10253 if (!storeState) return;
10254 if (!hasOwnProperty(storeState, key)) return;
10255 return sync(store2, [key], (state2) => {
10256 setState(
10257 key,
10258 state2[key],
10259 // @ts-expect-error - Not public API. This is just to prevent
10260 // infinite loops.
10261 true
10262 );
10263 });
10264 })
10265 )
10266 );
10267 const teardowns = [];
10268 for (const setup2 of setups) {
10269 teardowns.push(setup2());
10270 }
10271 const cleanups = stores.map(init);
10272 destroy = chain(...desyncs, ...teardowns, ...cleanups);
10273 return maybeDestroy;
10274 };
10275 const sub = (keys, listener, set3 = listeners) => {
10276 set3.add(listener);
10277 listenerKeys.set(listener, keys);
10278 return () => {
10279 var _a;
10280 (_a = disposables.get(listener)) == null ? void 0 : _a();
10281 disposables.delete(listener);
10282 listenerKeys.delete(listener);
10283 set3.delete(listener);
10284 };
10285 };
10286 const storeSubscribe = (keys, listener) => sub(keys, listener);
10287 const storeSync = (keys, listener) => {
10288 disposables.set(listener, listener(state, state));
10289 return sub(keys, listener);
10290 };
10291 const storeBatch = (keys, listener) => {
10292 disposables.set(listener, listener(state, prevStateBatch));
10293 return sub(keys, listener, batchListeners);
10294 };
10295 const storePick = (keys) => createStore(pick(state, keys), finalStore);
10296 const storeOmit = (keys) => createStore(omit(state, keys), finalStore);
10297 const getState = () => state;
10298 const setState = (key, value, fromStores = false) => {
10299 var _a;
10300 if (!hasOwnProperty(state, key)) return;
10301 const nextValue = applyState(value, state[key]);
10302 if (nextValue === state[key]) return;
10303 if (!fromStores) {
10304 for (const store2 of stores) {
10305 (_a = store2 == null ? void 0 : store2.setState) == null ? void 0 : _a.call(store2, key, nextValue);
10306 }
10307 }
10308 const prevState = state;
10309 state = { ...state, [key]: nextValue };
10310 const thisUpdate = /* @__PURE__ */ Symbol();
10311 lastUpdate = thisUpdate;
10312 updatedKeys.add(key);
10313 const run = (listener, prev, uKeys) => {
10314 var _a2;
10315 const keys = listenerKeys.get(listener);
10316 const updated = (k) => uKeys ? uKeys.has(k) : k === key;
10317 if (!keys || keys.some(updated)) {
10318 (_a2 = disposables.get(listener)) == null ? void 0 : _a2();
10319 disposables.set(listener, listener(state, prev));
10320 }
10321 };
10322 for (const listener of listeners) {
10323 run(listener, prevState);
10324 }
10325 queueMicrotask(() => {
10326 if (lastUpdate !== thisUpdate) return;
10327 const snapshot = state;
10328 for (const listener of batchListeners) {
10329 run(listener, prevStateBatch, updatedKeys);
10330 }
10331 prevStateBatch = snapshot;
10332 updatedKeys.clear();
10333 });
10334 };
10335 const finalStore = {
10336 getState,
10337 setState,
10338 __unstableInternals: {
10339 setup: storeSetup,
10340 init: storeInit,
10341 subscribe: storeSubscribe,
10342 sync: storeSync,
10343 batch: storeBatch,
10344 pick: storePick,
10345 omit: storeOmit
10346 }
10347 };
10348 return finalStore;
10349 }
10350 function setup(store2, ...args) {
10351 if (!store2) return;
10352 return getInternal(store2, "setup")(...args);
10353 }
10354 function init(store2, ...args) {
10355 if (!store2) return;
10356 return getInternal(store2, "init")(...args);
10357 }
10358 function subscribe(store2, ...args) {
10359 if (!store2) return;
10360 return getInternal(store2, "subscribe")(...args);
10361 }
10362 function sync(store2, ...args) {
10363 if (!store2) return;
10364 return getInternal(store2, "sync")(...args);
10365 }
10366 function batch(store2, ...args) {
10367 if (!store2) return;
10368 return getInternal(store2, "batch")(...args);
10369 }
10370 function omit2(store2, ...args) {
10371 if (!store2) return;
10372 return getInternal(store2, "omit")(...args);
10373 }
10374 function pick2(store2, ...args) {
10375 if (!store2) return;
10376 return getInternal(store2, "pick")(...args);
10377 }
10378 function mergeStore(...stores) {
10379 var _a;
10380 const initialState = {};
10381 for (const store22 of stores) {
10382 const nextState = (_a = store22 == null ? void 0 : store22.getState) == null ? void 0 : _a.call(store22);
10383 if (nextState) {
10384 Object.assign(initialState, nextState);
10385 }
10386 }
10387 const store2 = createStore(initialState, ...stores);
10388 return Object.assign({}, ...stores, store2);
10389 }
10390 function throwOnConflictingProps(props, store2) {
10391 if (false) return;
10392 if (!store2) return;
10393 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => {
10394 var _a;
10395 const stateKey = key.replace("default", "");
10396 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}${stateKey.slice(1)}`;
10397 });
10398 if (!defaultKeys.length) return;
10399 const storeState = store2.getState();
10400 const conflictingProps = defaultKeys.filter(
10401 (key) => hasOwnProperty(storeState, key)
10402 );
10403 if (!conflictingProps.length) return;
10404 throw new Error(
10405 `Passing a store prop in conjunction with a default state is not supported.
10406
10407 const store = useSelectStore();
10408 <SelectProvider store={store} defaultValue="Apple" />
10409 ^ ^
10410
10411 Instead, pass the default state to the topmost store:
10412
10413 const store = useSelectStore({ defaultValue: "Apple" });
10414 <SelectProvider store={store} />
10415
10416 See https://github.com/ariakit/ariakit/pull/2745 for more details.
10417
10418 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit
10419 `
10420 );
10421 }
10422
10423 // node_modules/@ariakit/react-core/esm/__chunks/Q5W46E73.js
10424 var React25 = __toESM(require_react(), 1);
10425 var import_shim = __toESM(require_shim(), 1);
10426 var { useSyncExternalStore } = import_shim.default;
10427 var noopSubscribe = () => () => {
10428 };
10429 function useStoreState(store2, keyOrSelector = identity) {
10430 const storeSubscribe = React25.useCallback(
10431 (callback) => {
10432 if (!store2) return noopSubscribe();
10433 return subscribe(store2, null, callback);
10434 },
10435 [store2]
10436 );
10437 const getSnapshot = () => {
10438 const key = typeof keyOrSelector === "string" ? keyOrSelector : null;
10439 const selector2 = typeof keyOrSelector === "function" ? keyOrSelector : null;
10440 const state = store2 == null ? void 0 : store2.getState();
10441 if (selector2) return selector2(state);
10442 if (!state) return;
10443 if (!key) return;
10444 if (!hasOwnProperty(state, key)) return;
10445 return state[key];
10446 };
10447 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
10448 }
10449 function useStoreStateObject(store2, object) {
10450 const objRef = React25.useRef(
10451 {}
10452 );
10453 const storeSubscribe = React25.useCallback(
10454 (callback) => {
10455 if (!store2) return noopSubscribe();
10456 return subscribe(store2, null, callback);
10457 },
10458 [store2]
10459 );
10460 const getSnapshot = () => {
10461 const state = store2 == null ? void 0 : store2.getState();
10462 let updated = false;
10463 const obj = objRef.current;
10464 for (const prop in object) {
10465 const keyOrSelector = object[prop];
10466 if (typeof keyOrSelector === "function") {
10467 const value = keyOrSelector(state);
10468 if (value !== obj[prop]) {
10469 obj[prop] = value;
10470 updated = true;
10471 }
10472 }
10473 if (typeof keyOrSelector === "string") {
10474 if (!state) continue;
10475 if (!hasOwnProperty(state, keyOrSelector)) continue;
10476 const value = state[keyOrSelector];
10477 if (value !== obj[prop]) {
10478 obj[prop] = value;
10479 updated = true;
10480 }
10481 }
10482 }
10483 if (updated) {
10484 objRef.current = { ...obj };
10485 }
10486 return objRef.current;
10487 };
10488 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
10489 }
10490 function useStoreProps(store2, props, key, setKey) {
10491 const value = hasOwnProperty(props, key) ? props[key] : void 0;
10492 const setValue = setKey ? props[setKey] : void 0;
10493 const propsRef = useLiveRef({ value, setValue });
10494 useSafeLayoutEffect(() => {
10495 return sync(store2, [key], (state, prev) => {
10496 const { value: value2, setValue: setValue2 } = propsRef.current;
10497 if (!setValue2) return;
10498 if (state[key] === prev[key]) return;
10499 if (state[key] === value2) return;
10500 setValue2(state[key]);
10501 });
10502 }, [store2, key]);
10503 useSafeLayoutEffect(() => {
10504 if (value === void 0) return;
10505 store2.setState(key, value);
10506 return batch(store2, [key], () => {
10507 if (value === void 0) return;
10508 store2.setState(key, value);
10509 });
10510 });
10511 }
10512 function useStore(createStore2, props) {
10513 const [store2, setStore] = React25.useState(() => createStore2(props));
10514 useSafeLayoutEffect(() => init(store2), [store2]);
10515 const useState210 = React25.useCallback(
10516 (keyOrSelector) => useStoreState(store2, keyOrSelector),
10517 [store2]
10518 );
10519 const memoizedStore = React25.useMemo(
10520 () => ({ ...store2, useState: useState210 }),
10521 [store2, useState210]
10522 );
10523 const updateStore = useEvent(() => {
10524 setStore((store22) => createStore2({ ...props, ...store22.getState() }));
10525 });
10526 return [memoizedStore, updateStore];
10527 }
10528
10529 // node_modules/@ariakit/react-core/esm/__chunks/WZWDIE3S.js
10530 var import_react18 = __toESM(require_react(), 1);
10531 var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
10532 var TagName4 = "button";
10533 function isEditableElement(element) {
10534 if (isTextbox(element)) return true;
10535 return element.tagName === "INPUT" && !isButton(element);
10536 }
10537 function getNextPageOffset(scrollingElement, pageUp = false) {
10538 const height = scrollingElement.clientHeight;
10539 const { top } = scrollingElement.getBoundingClientRect();
10540 const pageSize = Math.max(height * 0.875, height - 40) * 1.5;
10541 const pageOffset = pageUp ? height - pageSize + top : pageSize + top;
10542 if (scrollingElement.tagName === "HTML") {
10543 return pageOffset + scrollingElement.scrollTop;
10544 }
10545 return pageOffset;
10546 }
10547 function getItemOffset(itemElement, pageUp = false) {
10548 const { top } = itemElement.getBoundingClientRect();
10549 if (pageUp) {
10550 return top + itemElement.clientHeight;
10551 }
10552 return top;
10553 }
10554 function findNextPageItemId(element, store2, next, pageUp = false) {
10555 var _a;
10556 if (!store2) return;
10557 if (!next) return;
10558 const { renderedItems } = store2.getState();
10559 const scrollingElement = getScrollingElement(element);
10560 if (!scrollingElement) return;
10561 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp);
10562 let id;
10563 let prevDifference;
10564 for (let i2 = 0; i2 < renderedItems.length; i2 += 1) {
10565 const previousId = id;
10566 id = next(i2);
10567 if (!id) break;
10568 if (id === previousId) continue;
10569 const itemElement = (_a = getEnabledItem(store2, id)) == null ? void 0 : _a.element;
10570 if (!itemElement) continue;
10571 const itemOffset = getItemOffset(itemElement, pageUp);
10572 const difference = itemOffset - nextPageOffset;
10573 const absDifference = Math.abs(difference);
10574 if (pageUp && difference <= 0 || !pageUp && difference >= 0) {
10575 if (prevDifference !== void 0 && prevDifference < absDifference) {
10576 id = previousId;
10577 }
10578 break;
10579 }
10580 prevDifference = absDifference;
10581 }
10582 return id;
10583 }
10584 function targetIsAnotherItem(event, store2) {
10585 if (isSelfTarget(event)) return false;
10586 return isItem(store2, event.target);
10587 }
10588 var useCompositeItem = createHook(
10589 function useCompositeItem2({
10590 store: store2,
10591 rowId: rowIdProp,
10592 preventScrollOnKeyDown = false,
10593 moveOnKeyPress = true,
10594 tabbable = false,
10595 getItem: getItemProp,
10596 "aria-setsize": ariaSetSizeProp,
10597 "aria-posinset": ariaPosInSetProp,
10598 ...props
10599 }) {
10600 const context = useCompositeContext();
10601 store2 = store2 || context;
10602 const id = useId5(props.id);
10603 const ref = (0, import_react18.useRef)(null);
10604 const row = (0, import_react18.useContext)(CompositeRowContext);
10605 const disabled2 = disabledFromProps(props);
10606 const trulyDisabled = disabled2 && !props.accessibleWhenDisabled;
10607 const {
10608 rowId,
10609 baseElement,
10610 isActiveItem,
10611 ariaSetSize,
10612 ariaPosInSet,
10613 isTabbable
10614 } = useStoreStateObject(store2, {
10615 rowId(state) {
10616 if (rowIdProp) return rowIdProp;
10617 if (!state) return;
10618 if (!(row == null ? void 0 : row.baseElement)) return;
10619 if (row.baseElement !== state.baseElement) return;
10620 return row.id;
10621 },
10622 baseElement(state) {
10623 return (state == null ? void 0 : state.baseElement) || void 0;
10624 },
10625 isActiveItem(state) {
10626 return !!state && state.activeId === id;
10627 },
10628 ariaSetSize(state) {
10629 if (ariaSetSizeProp != null) return ariaSetSizeProp;
10630 if (!state) return;
10631 if (!(row == null ? void 0 : row.ariaSetSize)) return;
10632 if (row.baseElement !== state.baseElement) return;
10633 return row.ariaSetSize;
10634 },
10635 ariaPosInSet(state) {
10636 if (ariaPosInSetProp != null) return ariaPosInSetProp;
10637 if (!state) return;
10638 if (!(row == null ? void 0 : row.ariaPosInSet)) return;
10639 if (row.baseElement !== state.baseElement) return;
10640 const itemsInRow = state.renderedItems.filter(
10641 (item) => item.rowId === rowId
10642 );
10643 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id);
10644 },
10645 isTabbable(state) {
10646 if (!(state == null ? void 0 : state.renderedItems.length)) return true;
10647 if (state.virtualFocus) return false;
10648 if (tabbable) return true;
10649 if (state.activeId === null) return false;
10650 const item = store2 == null ? void 0 : store2.item(state.activeId);
10651 if (item == null ? void 0 : item.disabled) return true;
10652 if (!(item == null ? void 0 : item.element)) return true;
10653 return state.activeId === id;
10654 }
10655 });
10656 const getItem = (0, import_react18.useCallback)(
10657 (item) => {
10658 var _a;
10659 const nextItem = {
10660 ...item,
10661 id: id || item.id,
10662 rowId,
10663 disabled: !!trulyDisabled,
10664 children: (_a = item.element) == null ? void 0 : _a.textContent
10665 };
10666 if (getItemProp) {
10667 return getItemProp(nextItem);
10668 }
10669 return nextItem;
10670 },
10671 [id, rowId, trulyDisabled, getItemProp]
10672 );
10673 const onFocusProp = props.onFocus;
10674 const hasFocusedComposite = (0, import_react18.useRef)(false);
10675 const onFocus = useEvent((event) => {
10676 onFocusProp == null ? void 0 : onFocusProp(event);
10677 if (event.defaultPrevented) return;
10678 if (isPortalEvent(event)) return;
10679 if (!id) return;
10680 if (!store2) return;
10681 if (targetIsAnotherItem(event, store2)) return;
10682 const { virtualFocus, baseElement: baseElement2 } = store2.getState();
10683 store2.setActiveId(id);
10684 if (isTextbox(event.currentTarget)) {
10685 selectTextField(event.currentTarget);
10686 }
10687 if (!virtualFocus) return;
10688 if (!isSelfTarget(event)) return;
10689 if (isEditableElement(event.currentTarget)) return;
10690 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) return;
10691 if (isSafari() && event.currentTarget.hasAttribute("data-autofocus")) {
10692 event.currentTarget.scrollIntoView({
10693 block: "nearest",
10694 inline: "nearest"
10695 });
10696 }
10697 hasFocusedComposite.current = true;
10698 const fromComposite = event.relatedTarget === baseElement2 || isItem(store2, event.relatedTarget);
10699 if (fromComposite) {
10700 focusSilently(baseElement2);
10701 } else {
10702 baseElement2.focus();
10703 }
10704 });
10705 const onBlurCaptureProp = props.onBlurCapture;
10706 const onBlurCapture = useEvent((event) => {
10707 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
10708 if (event.defaultPrevented) return;
10709 const state = store2 == null ? void 0 : store2.getState();
10710 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) {
10711 hasFocusedComposite.current = false;
10712 event.preventDefault();
10713 event.stopPropagation();
10714 }
10715 });
10716 const onKeyDownProp = props.onKeyDown;
10717 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown);
10718 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
10719 const onKeyDown = useEvent((event) => {
10720 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
10721 if (event.defaultPrevented) return;
10722 if (!isSelfTarget(event)) return;
10723 if (!store2) return;
10724 const { currentTarget } = event;
10725 const state = store2.getState();
10726 const item = store2.item(id);
10727 const isGrid2 = !!(item == null ? void 0 : item.rowId);
10728 const isVertical = state.orientation !== "horizontal";
10729 const isHorizontal = state.orientation !== "vertical";
10730 const canHomeEnd = () => {
10731 if (isGrid2) return true;
10732 if (isHorizontal) return true;
10733 if (!state.baseElement) return true;
10734 if (!isTextField(state.baseElement)) return true;
10735 return false;
10736 };
10737 const keyMap = {
10738 ArrowUp: (isGrid2 || isVertical) && store2.up,
10739 ArrowRight: (isGrid2 || isHorizontal) && store2.next,
10740 ArrowDown: (isGrid2 || isVertical) && store2.down,
10741 ArrowLeft: (isGrid2 || isHorizontal) && store2.previous,
10742 Home: () => {
10743 if (!canHomeEnd()) return;
10744 if (!isGrid2 || event.ctrlKey) {
10745 return store2 == null ? void 0 : store2.first();
10746 }
10747 return store2 == null ? void 0 : store2.previous(-1);
10748 },
10749 End: () => {
10750 if (!canHomeEnd()) return;
10751 if (!isGrid2 || event.ctrlKey) {
10752 return store2 == null ? void 0 : store2.last();
10753 }
10754 return store2 == null ? void 0 : store2.next(-1);
10755 },
10756 PageUp: () => {
10757 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.up, true);
10758 },
10759 PageDown: () => {
10760 return findNextPageItemId(currentTarget, store2, store2 == null ? void 0 : store2.down);
10761 }
10762 };
10763 const action = keyMap[event.key];
10764 if (action) {
10765 if (isTextbox(currentTarget)) {
10766 const selection = getTextboxSelection(currentTarget);
10767 const isLeft = isHorizontal && event.key === "ArrowLeft";
10768 const isRight = isHorizontal && event.key === "ArrowRight";
10769 const isUp = isVertical && event.key === "ArrowUp";
10770 const isDown = isVertical && event.key === "ArrowDown";
10771 if (isRight || isDown) {
10772 const { length: valueLength } = getTextboxValue(currentTarget);
10773 if (selection.end !== valueLength) return;
10774 } else if ((isLeft || isUp) && selection.start !== 0) return;
10775 }
10776 const nextId = action();
10777 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) {
10778 if (!moveOnKeyPressProp(event)) return;
10779 event.preventDefault();
10780 store2.move(nextId);
10781 }
10782 }
10783 });
10784 const providerValue = (0, import_react18.useMemo)(
10785 () => ({ id, baseElement }),
10786 [id, baseElement]
10787 );
10788 props = useWrapElement(
10789 props,
10790 (element) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }),
10791 [providerValue]
10792 );
10793 props = {
10794 id,
10795 "data-active-item": isActiveItem || void 0,
10796 ...props,
10797 ref: useMergeRefs(ref, props.ref),
10798 tabIndex: isTabbable ? props.tabIndex : -1,
10799 onFocus,
10800 onBlurCapture,
10801 onKeyDown
10802 };
10803 props = useCommand(props);
10804 props = useCollectionItem({
10805 store: store2,
10806 ...props,
10807 getItem,
10808 shouldRegisterItem: id ? props.shouldRegisterItem : false
10809 });
10810 return removeUndefinedValues({
10811 ...props,
10812 "aria-setsize": ariaSetSize,
10813 "aria-posinset": ariaPosInSet
10814 });
10815 }
10816 );
10817 var CompositeItem = memo22(
10818 forwardRef26(function CompositeItem2(props) {
10819 const htmlProps = useCompositeItem(props);
10820 return createElement3(TagName4, htmlProps);
10821 })
10822 );
10823
10824 // node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js
10825 function toArray(arg) {
10826 if (Array.isArray(arg)) {
10827 return arg;
10828 }
10829 return typeof arg !== "undefined" ? [arg] : [];
10830 }
10831 function flatten2DArray(array) {
10832 const flattened = [];
10833 for (const row of array) {
10834 flattened.push(...row);
10835 }
10836 return flattened;
10837 }
10838 function reverseArray(array) {
10839 return array.slice().reverse();
10840 }
10841
10842 // node_modules/@ariakit/react-core/esm/__chunks/ZMWF7ASR.js
10843 var import_react19 = __toESM(require_react(), 1);
10844 var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);
10845 var TagName5 = "div";
10846 function isGrid(items) {
10847 return items.some((item) => !!item.rowId);
10848 }
10849 function isPrintableKey(event) {
10850 const target = event.target;
10851 if (target && !isTextField(target)) return false;
10852 return event.key.length === 1 && !event.ctrlKey && !event.metaKey;
10853 }
10854 function isModifierKey(event) {
10855 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta";
10856 }
10857 function useKeyboardEventProxy(store2, onKeyboardEvent, previousElementRef) {
10858 return useEvent((event) => {
10859 var _a;
10860 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event);
10861 if (event.defaultPrevented) return;
10862 if (event.isPropagationStopped()) return;
10863 if (!isSelfTarget(event)) return;
10864 if (isModifierKey(event)) return;
10865 if (isPrintableKey(event)) return;
10866 const state = store2.getState();
10867 const activeElement = (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.element;
10868 if (!activeElement) return;
10869 const { view, ...eventInit } = event;
10870 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current;
10871 if (activeElement !== previousElement) {
10872 activeElement.focus();
10873 }
10874 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) {
10875 event.preventDefault();
10876 }
10877 if (event.currentTarget.contains(activeElement)) {
10878 event.stopPropagation();
10879 }
10880 });
10881 }
10882 function findFirstEnabledItemInTheLastRow(items) {
10883 return findFirstEnabledItem(
10884 flatten2DArray(reverseArray(groupItemsByRows(items)))
10885 );
10886 }
10887 function useScheduleFocus(store2) {
10888 const [scheduled, setScheduled] = (0, import_react19.useState)(false);
10889 const schedule = (0, import_react19.useCallback)(() => setScheduled(true), []);
10890 const activeItem = store2.useState(
10891 (state) => getEnabledItem(store2, state.activeId)
10892 );
10893 (0, import_react19.useEffect)(() => {
10894 const activeElement = activeItem == null ? void 0 : activeItem.element;
10895 if (!scheduled) return;
10896 if (!activeElement) return;
10897 setScheduled(false);
10898 activeElement.focus({ preventScroll: true });
10899 }, [activeItem, scheduled]);
10900 return schedule;
10901 }
10902 var useComposite = createHook(
10903 function useComposite2({
10904 store: store2,
10905 composite = true,
10906 focusOnMove = composite,
10907 moveOnKeyPress = true,
10908 ...props
10909 }) {
10910 const context = useCompositeProviderContext();
10911 store2 = store2 || context;
10912 invariant(
10913 store2,
10914 "Composite must receive a `store` prop or be wrapped in a CompositeProvider component."
10915 );
10916 const ref = (0, import_react19.useRef)(null);
10917 const previousElementRef = (0, import_react19.useRef)(null);
10918 const scheduleFocus = useScheduleFocus(store2);
10919 const moves = store2.useState("moves");
10920 const [, setBaseElement] = useTransactionState(
10921 composite ? store2.setBaseElement : null
10922 );
10923 (0, import_react19.useEffect)(() => {
10924 var _a;
10925 if (!store2) return;
10926 if (!moves) return;
10927 if (!composite) return;
10928 if (!focusOnMove) return;
10929 const { activeId: activeId2 } = store2.getState();
10930 const itemElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
10931 if (!itemElement) return;
10932 focusIntoView(itemElement);
10933 }, [store2, moves, composite, focusOnMove]);
10934 useSafeLayoutEffect(() => {
10935 if (!store2) return;
10936 if (!moves) return;
10937 if (!composite) return;
10938 const { baseElement, activeId: activeId2 } = store2.getState();
10939 const isSelfAcive = activeId2 === null;
10940 if (!isSelfAcive) return;
10941 if (!baseElement) return;
10942 const previousElement = previousElementRef.current;
10943 previousElementRef.current = null;
10944 if (previousElement) {
10945 fireBlurEvent(previousElement, { relatedTarget: baseElement });
10946 }
10947 if (!hasFocus(baseElement)) {
10948 baseElement.focus();
10949 }
10950 }, [store2, moves, composite]);
10951 const activeId = store2.useState("activeId");
10952 const virtualFocus = store2.useState("virtualFocus");
10953 useSafeLayoutEffect(() => {
10954 var _a;
10955 if (!store2) return;
10956 if (!composite) return;
10957 if (!virtualFocus) return;
10958 const previousElement = previousElementRef.current;
10959 previousElementRef.current = null;
10960 if (!previousElement) return;
10961 const activeElement = (_a = getEnabledItem(store2, activeId)) == null ? void 0 : _a.element;
10962 const relatedTarget = activeElement || getActiveElement(previousElement);
10963 if (relatedTarget === previousElement) return;
10964 fireBlurEvent(previousElement, { relatedTarget });
10965 }, [store2, activeId, virtualFocus, composite]);
10966 const onKeyDownCapture = useKeyboardEventProxy(
10967 store2,
10968 props.onKeyDownCapture,
10969 previousElementRef
10970 );
10971 const onKeyUpCapture = useKeyboardEventProxy(
10972 store2,
10973 props.onKeyUpCapture,
10974 previousElementRef
10975 );
10976 const onFocusCaptureProp = props.onFocusCapture;
10977 const onFocusCapture = useEvent((event) => {
10978 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event);
10979 if (event.defaultPrevented) return;
10980 if (!store2) return;
10981 const { virtualFocus: virtualFocus2 } = store2.getState();
10982 if (!virtualFocus2) return;
10983 const previousActiveElement = event.relatedTarget;
10984 const isSilentlyFocused = silentlyFocused(event.currentTarget);
10985 if (isSelfTarget(event) && isSilentlyFocused) {
10986 event.stopPropagation();
10987 previousElementRef.current = previousActiveElement;
10988 }
10989 });
10990 const onFocusProp = props.onFocus;
10991 const onFocus = useEvent((event) => {
10992 onFocusProp == null ? void 0 : onFocusProp(event);
10993 if (event.defaultPrevented) return;
10994 if (!composite) return;
10995 if (!store2) return;
10996 const { relatedTarget } = event;
10997 const { virtualFocus: virtualFocus2 } = store2.getState();
10998 if (virtualFocus2) {
10999 if (isSelfTarget(event) && !isItem(store2, relatedTarget)) {
11000 queueMicrotask(scheduleFocus);
11001 }
11002 } else if (isSelfTarget(event)) {
11003 store2.setActiveId(null);
11004 }
11005 });
11006 const onBlurCaptureProp = props.onBlurCapture;
11007 const onBlurCapture = useEvent((event) => {
11008 var _a;
11009 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event);
11010 if (event.defaultPrevented) return;
11011 if (!store2) return;
11012 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store2.getState();
11013 if (!virtualFocus2) return;
11014 const activeElement = (_a = getEnabledItem(store2, activeId2)) == null ? void 0 : _a.element;
11015 const nextActiveElement = event.relatedTarget;
11016 const nextActiveElementIsItem = isItem(store2, nextActiveElement);
11017 const previousElement = previousElementRef.current;
11018 previousElementRef.current = null;
11019 if (isSelfTarget(event) && nextActiveElementIsItem) {
11020 if (nextActiveElement === activeElement) {
11021 if (previousElement && previousElement !== nextActiveElement) {
11022 fireBlurEvent(previousElement, event);
11023 }
11024 } else if (activeElement) {
11025 fireBlurEvent(activeElement, event);
11026 } else if (previousElement) {
11027 fireBlurEvent(previousElement, event);
11028 }
11029 event.stopPropagation();
11030 } else {
11031 const targetIsItem = isItem(store2, event.target);
11032 if (!targetIsItem && activeElement) {
11033 fireBlurEvent(activeElement, event);
11034 }
11035 }
11036 });
11037 const onKeyDownProp = props.onKeyDown;
11038 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
11039 const onKeyDown = useEvent((event) => {
11040 var _a;
11041 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
11042 if (event.nativeEvent.isComposing) return;
11043 if (event.defaultPrevented) return;
11044 if (!store2) return;
11045 if (!isSelfTarget(event)) return;
11046 const { orientation, renderedItems, activeId: activeId2 } = store2.getState();
11047 const activeItem = getEnabledItem(store2, activeId2);
11048 if ((_a = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a.isConnected) return;
11049 const isVertical = orientation !== "horizontal";
11050 const isHorizontal = orientation !== "vertical";
11051 const grid = isGrid(renderedItems);
11052 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End";
11053 if (isHorizontalKey && isTextField(event.currentTarget)) return;
11054 const up = () => {
11055 if (grid) {
11056 const item = findFirstEnabledItemInTheLastRow(renderedItems);
11057 return item == null ? void 0 : item.id;
11058 }
11059 return store2 == null ? void 0 : store2.last();
11060 };
11061 const keyMap = {
11062 ArrowUp: (grid || isVertical) && up,
11063 ArrowRight: (grid || isHorizontal) && store2.first,
11064 ArrowDown: (grid || isVertical) && store2.first,
11065 ArrowLeft: (grid || isHorizontal) && store2.last,
11066 Home: store2.first,
11067 End: store2.last,
11068 PageUp: store2.first,
11069 PageDown: store2.last
11070 };
11071 const action = keyMap[event.key];
11072 if (action) {
11073 const id = action();
11074 if (id !== void 0) {
11075 if (!moveOnKeyPressProp(event)) return;
11076 event.preventDefault();
11077 store2.move(id);
11078 }
11079 }
11080 });
11081 props = useWrapElement(
11082 props,
11083 (element) => /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(CompositeContextProvider, { value: store2, children: element }),
11084 [store2]
11085 );
11086 const activeDescendant = store2.useState((state) => {
11087 var _a;
11088 if (!store2) return;
11089 if (!composite) return;
11090 if (!state.virtualFocus) return;
11091 return (_a = getEnabledItem(store2, state.activeId)) == null ? void 0 : _a.id;
11092 });
11093 props = {
11094 "aria-activedescendant": activeDescendant,
11095 ...props,
11096 ref: useMergeRefs(ref, setBaseElement, props.ref),
11097 onKeyDownCapture,
11098 onKeyUpCapture,
11099 onFocusCapture,
11100 onFocus,
11101 onBlurCapture,
11102 onKeyDown
11103 };
11104 const focusable = store2.useState(
11105 (state) => composite && (state.virtualFocus || state.activeId === null)
11106 );
11107 props = useFocusable({ focusable, ...props });
11108 return props;
11109 }
11110 );
11111 var Composite5 = forwardRef26(function Composite22(props) {
11112 const htmlProps = useComposite(props);
11113 return createElement3(TagName5, htmlProps);
11114 });
11115
11116 // node_modules/@ariakit/react-core/esm/__chunks/LVDQFHCH.js
11117 var ctx3 = createStoreContext();
11118 var useDisclosureContext = ctx3.useContext;
11119 var useDisclosureScopedContext = ctx3.useScopedContext;
11120 var useDisclosureProviderContext = ctx3.useProviderContext;
11121 var DisclosureContextProvider = ctx3.ContextProvider;
11122 var DisclosureScopedContextProvider = ctx3.ScopedContextProvider;
11123
11124 // node_modules/@ariakit/react-core/esm/__chunks/A62MDFCW.js
11125 var import_react20 = __toESM(require_react(), 1);
11126 var ctx4 = createStoreContext(
11127 [DisclosureContextProvider],
11128 [DisclosureScopedContextProvider]
11129 );
11130 var useDialogContext = ctx4.useContext;
11131 var useDialogScopedContext = ctx4.useScopedContext;
11132 var useDialogProviderContext = ctx4.useProviderContext;
11133 var DialogContextProvider = ctx4.ContextProvider;
11134 var DialogScopedContextProvider = ctx4.ScopedContextProvider;
11135 var DialogHeadingContext = (0, import_react20.createContext)(void 0);
11136 var DialogDescriptionContext = (0, import_react20.createContext)(void 0);
11137
11138 // node_modules/@ariakit/react-core/esm/__chunks/6B3RXHKP.js
11139 var import_react21 = __toESM(require_react(), 1);
11140 var import_react_dom = __toESM(require_react_dom(), 1);
11141 var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);
11142 var TagName6 = "div";
11143 function afterTimeout(timeoutMs, cb) {
11144 const timeoutId = setTimeout(cb, timeoutMs);
11145 return () => clearTimeout(timeoutId);
11146 }
11147 function afterPaint2(cb) {
11148 let raf = requestAnimationFrame(() => {
11149 raf = requestAnimationFrame(cb);
11150 });
11151 return () => cancelAnimationFrame(raf);
11152 }
11153 function parseCSSTime(...times) {
11154 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => {
11155 const multiplier = currentTimeString.endsWith("ms") ? 1 : 1e3;
11156 const currentTime = Number.parseFloat(currentTimeString || "0s") * multiplier;
11157 if (currentTime > longestTime) return currentTime;
11158 return longestTime;
11159 }, 0);
11160 }
11161 function isHidden(mounted, hidden, alwaysVisible) {
11162 return !alwaysVisible && hidden !== false && (!mounted || !!hidden);
11163 }
11164 var useDisclosureContent = createHook(function useDisclosureContent2({ store: store2, alwaysVisible, ...props }) {
11165 const context = useDisclosureProviderContext();
11166 store2 = store2 || context;
11167 invariant(
11168 store2,
11169 "DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component."
11170 );
11171 const ref = (0, import_react21.useRef)(null);
11172 const id = useId5(props.id);
11173 const [transition, setTransition] = (0, import_react21.useState)(null);
11174 const open = store2.useState("open");
11175 const mounted = store2.useState("mounted");
11176 const animated = store2.useState("animated");
11177 const contentElement = store2.useState("contentElement");
11178 const otherElement = useStoreState(store2.disclosure, "contentElement");
11179 useSafeLayoutEffect(() => {
11180 if (!ref.current) return;
11181 store2 == null ? void 0 : store2.setContentElement(ref.current);
11182 }, [store2]);
11183 useSafeLayoutEffect(() => {
11184 let previousAnimated;
11185 store2 == null ? void 0 : store2.setState("animated", (animated2) => {
11186 previousAnimated = animated2;
11187 return true;
11188 });
11189 return () => {
11190 if (previousAnimated === void 0) return;
11191 store2 == null ? void 0 : store2.setState("animated", previousAnimated);
11192 };
11193 }, [store2]);
11194 useSafeLayoutEffect(() => {
11195 if (!animated) return;
11196 if (!(contentElement == null ? void 0 : contentElement.isConnected)) {
11197 setTransition(null);
11198 return;
11199 }
11200 return afterPaint2(() => {
11201 setTransition(open ? "enter" : mounted ? "leave" : null);
11202 });
11203 }, [animated, contentElement, open, mounted]);
11204 useSafeLayoutEffect(() => {
11205 if (!store2) return;
11206 if (!animated) return;
11207 if (!transition) return;
11208 if (!contentElement) return;
11209 const stopAnimation = () => store2 == null ? void 0 : store2.setState("animating", false);
11210 const stopAnimationSync = () => (0, import_react_dom.flushSync)(stopAnimation);
11211 if (transition === "leave" && open) return;
11212 if (transition === "enter" && !open) return;
11213 if (typeof animated === "number") {
11214 const timeout2 = animated;
11215 return afterTimeout(timeout2, stopAnimationSync);
11216 }
11217 const {
11218 transitionDuration,
11219 animationDuration,
11220 transitionDelay,
11221 animationDelay
11222 } = getComputedStyle(contentElement);
11223 const {
11224 transitionDuration: transitionDuration2 = "0",
11225 animationDuration: animationDuration2 = "0",
11226 transitionDelay: transitionDelay2 = "0",
11227 animationDelay: animationDelay2 = "0"
11228 } = otherElement ? getComputedStyle(otherElement) : {};
11229 const delay = parseCSSTime(
11230 transitionDelay,
11231 animationDelay,
11232 transitionDelay2,
11233 animationDelay2
11234 );
11235 const duration = parseCSSTime(
11236 transitionDuration,
11237 animationDuration,
11238 transitionDuration2,
11239 animationDuration2
11240 );
11241 const timeout = delay + duration;
11242 if (!timeout) {
11243 if (transition === "enter") {
11244 store2.setState("animated", false);
11245 }
11246 stopAnimation();
11247 return;
11248 }
11249 const frameRate = 1e3 / 60;
11250 const maxTimeout = Math.max(timeout - frameRate, 0);
11251 return afterTimeout(maxTimeout, stopAnimationSync);
11252 }, [store2, animated, contentElement, otherElement, open, transition]);
11253 props = useWrapElement(
11254 props,
11255 (element) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DialogScopedContextProvider, { value: store2, children: element }),
11256 [store2]
11257 );
11258 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
11259 const styleProp = props.style;
11260 const style = (0, import_react21.useMemo)(() => {
11261 if (hidden) {
11262 return { ...styleProp, display: "none" };
11263 }
11264 return styleProp;
11265 }, [hidden, styleProp]);
11266 props = {
11267 id,
11268 "data-open": open || void 0,
11269 "data-enter": transition === "enter" || void 0,
11270 "data-leave": transition === "leave" || void 0,
11271 hidden,
11272 ...props,
11273 ref: useMergeRefs(id ? store2.setContentElement : null, ref, props.ref),
11274 style
11275 };
11276 return removeUndefinedValues(props);
11277 });
11278 var DisclosureContentImpl = forwardRef26(function DisclosureContentImpl2(props) {
11279 const htmlProps = useDisclosureContent(props);
11280 return createElement3(TagName6, htmlProps);
11281 });
11282 var DisclosureContent = forwardRef26(function DisclosureContent2({
11283 unmountOnHide,
11284 ...props
11285 }) {
11286 const context = useDisclosureProviderContext();
11287 const store2 = props.store || context;
11288 const mounted = useStoreState(
11289 store2,
11290 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted)
11291 );
11292 if (mounted === false) return null;
11293 return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(DisclosureContentImpl, { ...props });
11294 });
11295
11296 // node_modules/@ariakit/core/esm/__chunks/75BJEVSH.js
11297 function createDisclosureStore(props = {}) {
11298 const store2 = mergeStore(
11299 props.store,
11300 omit2(props.disclosure, ["contentElement", "disclosureElement"])
11301 );
11302 throwOnConflictingProps(props, store2);
11303 const syncState = store2 == null ? void 0 : store2.getState();
11304 const open = defaultValue(
11305 props.open,
11306 syncState == null ? void 0 : syncState.open,
11307 props.defaultOpen,
11308 false
11309 );
11310 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false);
11311 const initialState = {
11312 open,
11313 animated,
11314 animating: !!animated && open,
11315 mounted: open,
11316 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null),
11317 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null)
11318 };
11319 const disclosure = createStore(initialState, store2);
11320 setup(
11321 disclosure,
11322 () => sync(disclosure, ["animated", "animating"], (state) => {
11323 if (state.animated) return;
11324 disclosure.setState("animating", false);
11325 })
11326 );
11327 setup(
11328 disclosure,
11329 () => subscribe(disclosure, ["open"], () => {
11330 if (!disclosure.getState().animated) return;
11331 disclosure.setState("animating", true);
11332 })
11333 );
11334 setup(
11335 disclosure,
11336 () => sync(disclosure, ["open", "animating"], (state) => {
11337 disclosure.setState("mounted", state.open || state.animating);
11338 })
11339 );
11340 return {
11341 ...disclosure,
11342 disclosure: props.disclosure,
11343 setOpen: (value) => disclosure.setState("open", value),
11344 show: () => disclosure.setState("open", true),
11345 hide: () => disclosure.setState("open", false),
11346 toggle: () => disclosure.setState("open", (open2) => !open2),
11347 stopAnimation: () => disclosure.setState("animating", false),
11348 setContentElement: (value) => disclosure.setState("contentElement", value),
11349 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value)
11350 };
11351 }
11352
11353 // node_modules/@ariakit/react-core/esm/__chunks/WLZ6H5FH.js
11354 function useDisclosureStoreProps(store2, update2, props) {
11355 useUpdateEffect(update2, [props.store, props.disclosure]);
11356 useStoreProps(store2, props, "open", "setOpen");
11357 useStoreProps(store2, props, "mounted", "setMounted");
11358 useStoreProps(store2, props, "animated");
11359 return Object.assign(store2, { disclosure: props.disclosure });
11360 }
11361
11362 // node_modules/@ariakit/react-core/esm/__chunks/JMU4N4M5.js
11363 var ctx5 = createStoreContext(
11364 [DialogContextProvider],
11365 [DialogScopedContextProvider]
11366 );
11367 var usePopoverContext = ctx5.useContext;
11368 var usePopoverScopedContext = ctx5.useScopedContext;
11369 var usePopoverProviderContext = ctx5.useProviderContext;
11370 var PopoverContextProvider = ctx5.ContextProvider;
11371 var PopoverScopedContextProvider = ctx5.ScopedContextProvider;
11372
11373 // node_modules/@ariakit/core/esm/__chunks/N5XGANPW.js
11374 function getCommonParent(items) {
11375 var _a;
11376 const firstItem = items.find((item) => !!item.element);
11377 const lastItem = [...items].reverse().find((item) => !!item.element);
11378 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement;
11379 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) {
11380 const parent = parentElement;
11381 if (lastItem && parent.contains(lastItem.element)) {
11382 return parentElement;
11383 }
11384 parentElement = parentElement.parentElement;
11385 }
11386 return getDocument(parentElement).body;
11387 }
11388 function getPrivateStore(store2) {
11389 return store2 == null ? void 0 : store2.__unstablePrivateStore;
11390 }
11391 function createCollectionStore(props = {}) {
11392 var _a;
11393 throwOnConflictingProps(props, props.store);
11394 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
11395 const items = defaultValue(
11396 props.items,
11397 syncState == null ? void 0 : syncState.items,
11398 props.defaultItems,
11399 []
11400 );
11401 const itemsMap = new Map(items.map((item) => [item.id, item]));
11402 const initialState = {
11403 items,
11404 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, [])
11405 };
11406 const syncPrivateStore = getPrivateStore(props.store);
11407 const privateStore = createStore(
11408 { items, renderedItems: initialState.renderedItems },
11409 syncPrivateStore
11410 );
11411 const collection = createStore(initialState, props.store);
11412 const sortItems = (renderedItems) => {
11413 const sortedItems = sortBasedOnDOMPosition(renderedItems, (i2) => i2.element);
11414 privateStore.setState("renderedItems", sortedItems);
11415 collection.setState("renderedItems", sortedItems);
11416 };
11417 setup(collection, () => init(privateStore));
11418 setup(privateStore, () => {
11419 return batch(privateStore, ["items"], (state) => {
11420 collection.setState("items", state.items);
11421 });
11422 });
11423 setup(privateStore, () => {
11424 return batch(privateStore, ["renderedItems"], (state) => {
11425 let firstRun = true;
11426 let raf = requestAnimationFrame(() => {
11427 const { renderedItems } = collection.getState();
11428 if (state.renderedItems === renderedItems) return;
11429 sortItems(state.renderedItems);
11430 });
11431 if (typeof IntersectionObserver !== "function") {
11432 return () => cancelAnimationFrame(raf);
11433 }
11434 const ioCallback = () => {
11435 if (firstRun) {
11436 firstRun = false;
11437 return;
11438 }
11439 cancelAnimationFrame(raf);
11440 raf = requestAnimationFrame(() => sortItems(state.renderedItems));
11441 };
11442 const root = getCommonParent(state.renderedItems);
11443 const observer = new IntersectionObserver(ioCallback, { root });
11444 for (const item of state.renderedItems) {
11445 if (!item.element) continue;
11446 observer.observe(item.element);
11447 }
11448 return () => {
11449 cancelAnimationFrame(raf);
11450 observer.disconnect();
11451 };
11452 });
11453 });
11454 const mergeItem = (item, setItems, canDeleteFromMap = false) => {
11455 let prevItem;
11456 setItems((items2) => {
11457 const index = items2.findIndex(({ id }) => id === item.id);
11458 const nextItems = items2.slice();
11459 if (index !== -1) {
11460 prevItem = items2[index];
11461 const nextItem = { ...prevItem, ...item };
11462 nextItems[index] = nextItem;
11463 itemsMap.set(item.id, nextItem);
11464 } else {
11465 nextItems.push(item);
11466 itemsMap.set(item.id, item);
11467 }
11468 return nextItems;
11469 });
11470 const unmergeItem = () => {
11471 setItems((items2) => {
11472 if (!prevItem) {
11473 if (canDeleteFromMap) {
11474 itemsMap.delete(item.id);
11475 }
11476 return items2.filter(({ id }) => id !== item.id);
11477 }
11478 const index = items2.findIndex(({ id }) => id === item.id);
11479 if (index === -1) return items2;
11480 const nextItems = items2.slice();
11481 nextItems[index] = prevItem;
11482 itemsMap.set(item.id, prevItem);
11483 return nextItems;
11484 });
11485 };
11486 return unmergeItem;
11487 };
11488 const registerItem = (item) => mergeItem(
11489 item,
11490 (getItems) => privateStore.setState("items", getItems),
11491 true
11492 );
11493 return {
11494 ...collection,
11495 registerItem,
11496 renderItem: (item) => chain(
11497 registerItem(item),
11498 mergeItem(
11499 item,
11500 (getItems) => privateStore.setState("renderedItems", getItems)
11501 )
11502 ),
11503 item: (id) => {
11504 if (!id) return null;
11505 let item = itemsMap.get(id);
11506 if (!item) {
11507 const { items: items2 } = privateStore.getState();
11508 item = items2.find((item2) => item2.id === id);
11509 if (item) {
11510 itemsMap.set(id, item);
11511 }
11512 }
11513 return item || null;
11514 },
11515 // @ts-expect-error Internal
11516 __unstablePrivateStore: privateStore
11517 };
11518 }
11519
11520 // node_modules/@ariakit/react-core/esm/__chunks/GVAFFF2B.js
11521 function useCollectionStoreProps(store2, update2, props) {
11522 useUpdateEffect(update2, [props.store]);
11523 useStoreProps(store2, props, "items", "setItems");
11524 return store2;
11525 }
11526
11527 // node_modules/@ariakit/core/esm/__chunks/RVTIKFRL.js
11528 var NULL_ITEM = { id: null };
11529 function findFirstEnabledItem2(items, excludeId) {
11530 return items.find((item) => {
11531 if (excludeId) {
11532 return !item.disabled && item.id !== excludeId;
11533 }
11534 return !item.disabled;
11535 });
11536 }
11537 function getEnabledItems(items, excludeId) {
11538 return items.filter((item) => {
11539 if (excludeId) {
11540 return !item.disabled && item.id !== excludeId;
11541 }
11542 return !item.disabled;
11543 });
11544 }
11545 function getItemsInRow(items, rowId) {
11546 return items.filter((item) => item.rowId === rowId);
11547 }
11548 function flipItems(items, activeId, shouldInsertNullItem = false) {
11549 const index = items.findIndex((item) => item.id === activeId);
11550 return [
11551 ...items.slice(index + 1),
11552 ...shouldInsertNullItem ? [NULL_ITEM] : [],
11553 ...items.slice(0, index)
11554 ];
11555 }
11556 function groupItemsByRows2(items) {
11557 const rows = [];
11558 for (const item of items) {
11559 const row = rows.find((currentRow) => {
11560 var _a;
11561 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId;
11562 });
11563 if (row) {
11564 row.push(item);
11565 } else {
11566 rows.push([item]);
11567 }
11568 }
11569 return rows;
11570 }
11571 function getMaxRowLength(array) {
11572 let maxLength = 0;
11573 for (const { length } of array) {
11574 if (length > maxLength) {
11575 maxLength = length;
11576 }
11577 }
11578 return maxLength;
11579 }
11580 function createEmptyItem(rowId) {
11581 return {
11582 id: "__EMPTY_ITEM__",
11583 disabled: true,
11584 rowId
11585 };
11586 }
11587 function normalizeRows(rows, activeId, focusShift) {
11588 const maxLength = getMaxRowLength(rows);
11589 for (const row of rows) {
11590 for (let i2 = 0; i2 < maxLength; i2 += 1) {
11591 const item = row[i2];
11592 if (!item || focusShift && item.disabled) {
11593 const isFirst = i2 === 0;
11594 const previousItem = isFirst && focusShift ? findFirstEnabledItem2(row) : row[i2 - 1];
11595 row[i2] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId);
11596 }
11597 }
11598 }
11599 return rows;
11600 }
11601 function verticalizeItems(items) {
11602 const rows = groupItemsByRows2(items);
11603 const maxLength = getMaxRowLength(rows);
11604 const verticalized = [];
11605 for (let i2 = 0; i2 < maxLength; i2 += 1) {
11606 for (const row of rows) {
11607 const item = row[i2];
11608 if (item) {
11609 verticalized.push({
11610 ...item,
11611 // If there's no rowId, it means that it's not a grid composite, but
11612 // a single row instead. So, instead of verticalizing it, that is,
11613 // assigning a different rowId based on the column index, we keep it
11614 // undefined so they will be part of the same row. This is useful
11615 // when using up/down on one-dimensional composites.
11616 rowId: item.rowId ? `${i2}` : void 0
11617 });
11618 }
11619 }
11620 }
11621 return verticalized;
11622 }
11623 function createCompositeStore(props = {}) {
11624 var _a;
11625 const syncState = (_a = props.store) == null ? void 0 : _a.getState();
11626 const collection = createCollectionStore(props);
11627 const activeId = defaultValue(
11628 props.activeId,
11629 syncState == null ? void 0 : syncState.activeId,
11630 props.defaultActiveId
11631 );
11632 const initialState = {
11633 ...collection.getState(),
11634 id: defaultValue(
11635 props.id,
11636 syncState == null ? void 0 : syncState.id,
11637 `id-${Math.random().toString(36).slice(2, 8)}`
11638 ),
11639 activeId,
11640 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null),
11641 includesBaseElement: defaultValue(
11642 props.includesBaseElement,
11643 syncState == null ? void 0 : syncState.includesBaseElement,
11644 activeId === null
11645 ),
11646 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0),
11647 orientation: defaultValue(
11648 props.orientation,
11649 syncState == null ? void 0 : syncState.orientation,
11650 "both"
11651 ),
11652 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false),
11653 virtualFocus: defaultValue(
11654 props.virtualFocus,
11655 syncState == null ? void 0 : syncState.virtualFocus,
11656 false
11657 ),
11658 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false),
11659 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false),
11660 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false)
11661 };
11662 const composite = createStore(initialState, collection, props.store);
11663 setup(
11664 composite,
11665 () => sync(composite, ["renderedItems", "activeId"], (state) => {
11666 composite.setState("activeId", (activeId2) => {
11667 var _a2;
11668 if (activeId2 !== void 0) return activeId2;
11669 return (_a2 = findFirstEnabledItem2(state.renderedItems)) == null ? void 0 : _a2.id;
11670 });
11671 })
11672 );
11673 const getNextId = (direction = "next", options = {}) => {
11674 var _a2, _b;
11675 const defaultState = composite.getState();
11676 const {
11677 skip = 0,
11678 activeId: activeId2 = defaultState.activeId,
11679 focusShift = defaultState.focusShift,
11680 focusLoop = defaultState.focusLoop,
11681 focusWrap = defaultState.focusWrap,
11682 includesBaseElement = defaultState.includesBaseElement,
11683 renderedItems = defaultState.renderedItems,
11684 rtl = defaultState.rtl
11685 } = options;
11686 const isVerticalDirection = direction === "up" || direction === "down";
11687 const isNextDirection = direction === "next" || direction === "down";
11688 const canReverse = isNextDirection ? rtl && !isVerticalDirection : !rtl || isVerticalDirection;
11689 const canShift = focusShift && !skip;
11690 let items = !isVerticalDirection ? renderedItems : flatten2DArray(
11691 normalizeRows(groupItemsByRows2(renderedItems), activeId2, canShift)
11692 );
11693 items = canReverse ? reverseArray(items) : items;
11694 items = isVerticalDirection ? verticalizeItems(items) : items;
11695 if (activeId2 == null) {
11696 return (_a2 = findFirstEnabledItem2(items)) == null ? void 0 : _a2.id;
11697 }
11698 const activeItem = items.find((item) => item.id === activeId2);
11699 if (!activeItem) {
11700 return (_b = findFirstEnabledItem2(items)) == null ? void 0 : _b.id;
11701 }
11702 const isGrid2 = items.some((item) => item.rowId);
11703 const activeIndex = items.indexOf(activeItem);
11704 const nextItems = items.slice(activeIndex + 1);
11705 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId);
11706 if (skip) {
11707 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2);
11708 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one.
11709 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1];
11710 return nextItem2 == null ? void 0 : nextItem2.id;
11711 }
11712 const canLoop = focusLoop && (isVerticalDirection ? focusLoop !== "horizontal" : focusLoop !== "vertical");
11713 const canWrap = isGrid2 && focusWrap && (isVerticalDirection ? focusWrap !== "horizontal" : focusWrap !== "vertical");
11714 const hasNullItem = isNextDirection ? (!isGrid2 || isVerticalDirection) && canLoop && includesBaseElement : isVerticalDirection ? includesBaseElement : false;
11715 if (canLoop) {
11716 const loopItems = canWrap && !hasNullItem ? items : getItemsInRow(items, activeItem.rowId);
11717 const sortedItems = flipItems(loopItems, activeId2, hasNullItem);
11718 const nextItem2 = findFirstEnabledItem2(sortedItems, activeId2);
11719 return nextItem2 == null ? void 0 : nextItem2.id;
11720 }
11721 if (canWrap) {
11722 const nextItem2 = findFirstEnabledItem2(
11723 // We can use nextItems, which contains all the next items, including
11724 // items from other rows, to wrap between rows. However, if there is a
11725 // null item (the composite container), we'll only use the next items in
11726 // the row. So moving next from the last item will focus on the
11727 // composite container. On grid composites, horizontal navigation never
11728 // focuses on the composite container, only vertical.
11729 hasNullItem ? nextItemsInRow : nextItems,
11730 activeId2
11731 );
11732 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id;
11733 return nextId;
11734 }
11735 const nextItem = findFirstEnabledItem2(nextItemsInRow, activeId2);
11736 if (!nextItem && hasNullItem) {
11737 return null;
11738 }
11739 return nextItem == null ? void 0 : nextItem.id;
11740 };
11741 return {
11742 ...collection,
11743 ...composite,
11744 setBaseElement: (element) => composite.setState("baseElement", element),
11745 setActiveId: (id) => composite.setState("activeId", id),
11746 move: (id) => {
11747 if (id === void 0) return;
11748 composite.setState("activeId", id);
11749 composite.setState("moves", (moves) => moves + 1);
11750 },
11751 first: () => {
11752 var _a2;
11753 return (_a2 = findFirstEnabledItem2(composite.getState().renderedItems)) == null ? void 0 : _a2.id;
11754 },
11755 last: () => {
11756 var _a2;
11757 return (_a2 = findFirstEnabledItem2(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id;
11758 },
11759 next: (options) => {
11760 if (options !== void 0 && typeof options === "number") {
11761 options = { skip: options };
11762 }
11763 return getNextId("next", options);
11764 },
11765 previous: (options) => {
11766 if (options !== void 0 && typeof options === "number") {
11767 options = { skip: options };
11768 }
11769 return getNextId("previous", options);
11770 },
11771 down: (options) => {
11772 if (options !== void 0 && typeof options === "number") {
11773 options = { skip: options };
11774 }
11775 return getNextId("down", options);
11776 },
11777 up: (options) => {
11778 if (options !== void 0 && typeof options === "number") {
11779 options = { skip: options };
11780 }
11781 return getNextId("up", options);
11782 }
11783 };
11784 }
11785
11786 // node_modules/@ariakit/react-core/esm/__chunks/IQYAUKXT.js
11787 function useCompositeStoreOptions(props) {
11788 const id = useId5(props.id);
11789 return { id, ...props };
11790 }
11791 function useCompositeStoreProps(store2, update2, props) {
11792 store2 = useCollectionStoreProps(store2, update2, props);
11793 useStoreProps(store2, props, "activeId", "setActiveId");
11794 useStoreProps(store2, props, "includesBaseElement");
11795 useStoreProps(store2, props, "virtualFocus");
11796 useStoreProps(store2, props, "orientation");
11797 useStoreProps(store2, props, "rtl");
11798 useStoreProps(store2, props, "focusLoop");
11799 useStoreProps(store2, props, "focusWrap");
11800 useStoreProps(store2, props, "focusShift");
11801 return store2;
11802 }
11803
11804 // node_modules/@ariakit/react-core/esm/__chunks/CVCFNOHX.js
11805 var import_react22 = __toESM(require_react(), 1);
11806 var ComboboxListRoleContext = (0, import_react22.createContext)(
11807 void 0
11808 );
11809 var ctx6 = createStoreContext(
11810 [PopoverContextProvider, CompositeContextProvider],
11811 [PopoverScopedContextProvider, CompositeScopedContextProvider]
11812 );
11813 var useComboboxContext = ctx6.useContext;
11814 var useComboboxScopedContext = ctx6.useScopedContext;
11815 var useComboboxProviderContext = ctx6.useProviderContext;
11816 var ComboboxContextProvider = ctx6.ContextProvider;
11817 var ComboboxScopedContextProvider = ctx6.ScopedContextProvider;
11818 var ComboboxItemValueContext = (0, import_react22.createContext)(
11819 void 0
11820 );
11821 var ComboboxItemCheckedContext = (0, import_react22.createContext)(false);
11822
11823 // node_modules/@ariakit/core/esm/__chunks/KMAUV3TY.js
11824 function createDialogStore(props = {}) {
11825 return createDisclosureStore(props);
11826 }
11827
11828 // node_modules/@ariakit/react-core/esm/__chunks/4NYSH4UO.js
11829 function useDialogStoreProps(store2, update2, props) {
11830 return useDisclosureStoreProps(store2, update2, props);
11831 }
11832
11833 // node_modules/@ariakit/core/esm/__chunks/BFGNM53A.js
11834 function createPopoverStore({
11835 popover: otherPopover,
11836 ...props
11837 } = {}) {
11838 const store2 = mergeStore(
11839 props.store,
11840 omit2(otherPopover, [
11841 "arrowElement",
11842 "anchorElement",
11843 "contentElement",
11844 "popoverElement",
11845 "disclosureElement"
11846 ])
11847 );
11848 throwOnConflictingProps(props, store2);
11849 const syncState = store2 == null ? void 0 : store2.getState();
11850 const dialog = createDialogStore({ ...props, store: store2 });
11851 const placement = defaultValue(
11852 props.placement,
11853 syncState == null ? void 0 : syncState.placement,
11854 "bottom"
11855 );
11856 const initialState = {
11857 ...dialog.getState(),
11858 placement,
11859 currentPlacement: placement,
11860 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null),
11861 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null),
11862 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null),
11863 rendered: /* @__PURE__ */ Symbol("rendered")
11864 };
11865 const popover = createStore(initialState, dialog, store2);
11866 return {
11867 ...dialog,
11868 ...popover,
11869 setAnchorElement: (element) => popover.setState("anchorElement", element),
11870 setPopoverElement: (element) => popover.setState("popoverElement", element),
11871 setArrowElement: (element) => popover.setState("arrowElement", element),
11872 render: () => popover.setState("rendered", /* @__PURE__ */ Symbol("rendered"))
11873 };
11874 }
11875
11876 // node_modules/@ariakit/react-core/esm/__chunks/B6FLPFJM.js
11877 function usePopoverStoreProps(store2, update2, props) {
11878 useUpdateEffect(update2, [props.popover]);
11879 useStoreProps(store2, props, "placement");
11880 return useDialogStoreProps(store2, update2, props);
11881 }
11882
11883 // node_modules/@ariakit/react-core/esm/__chunks/4POTBZ2J.js
11884 var TagName7 = "div";
11885 var usePopoverAnchor = createHook(
11886 function usePopoverAnchor2({ store: store2, ...props }) {
11887 const context = usePopoverProviderContext();
11888 store2 = store2 || context;
11889 props = {
11890 ...props,
11891 ref: useMergeRefs(store2 == null ? void 0 : store2.setAnchorElement, props.ref)
11892 };
11893 return props;
11894 }
11895 );
11896 var PopoverAnchor = forwardRef26(function PopoverAnchor2(props) {
11897 const htmlProps = usePopoverAnchor(props);
11898 return createElement3(TagName7, htmlProps);
11899 });
11900
11901 // node_modules/@ariakit/react-core/esm/__chunks/X6LNAU2F.js
11902 var import_react23 = __toESM(require_react(), 1);
11903 var TagName8 = "div";
11904 function getMouseDestination(event) {
11905 const relatedTarget = event.relatedTarget;
11906 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
11907 return relatedTarget;
11908 }
11909 return null;
11910 }
11911 function hoveringInside(event) {
11912 const nextElement = getMouseDestination(event);
11913 if (!nextElement) return false;
11914 return contains(event.currentTarget, nextElement);
11915 }
11916 var symbol2 = /* @__PURE__ */ Symbol("composite-hover");
11917 function movingToAnotherItem(event) {
11918 let dest = getMouseDestination(event);
11919 if (!dest) return false;
11920 do {
11921 if (hasOwnProperty(dest, symbol2) && dest[symbol2]) return true;
11922 dest = dest.parentElement;
11923 } while (dest);
11924 return false;
11925 }
11926 var useCompositeHover = createHook(
11927 function useCompositeHover2({
11928 store: store2,
11929 focusOnHover = true,
11930 blurOnHoverEnd = !!focusOnHover,
11931 ...props
11932 }) {
11933 const context = useCompositeContext();
11934 store2 = store2 || context;
11935 invariant(
11936 store2,
11937 "CompositeHover must be wrapped in a Composite component."
11938 );
11939 const isMouseMoving = useIsMouseMoving();
11940 const onMouseMoveProp = props.onMouseMove;
11941 const focusOnHoverProp = useBooleanEvent(focusOnHover);
11942 const onMouseMove = useEvent((event) => {
11943 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event);
11944 if (event.defaultPrevented) return;
11945 if (!isMouseMoving()) return;
11946 if (!focusOnHoverProp(event)) return;
11947 if (!hasFocusWithin(event.currentTarget)) {
11948 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
11949 if (baseElement && !hasFocus(baseElement)) {
11950 baseElement.focus();
11951 }
11952 }
11953 store2 == null ? void 0 : store2.setActiveId(event.currentTarget.id);
11954 });
11955 const onMouseLeaveProp = props.onMouseLeave;
11956 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd);
11957 const onMouseLeave = useEvent((event) => {
11958 var _a;
11959 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event);
11960 if (event.defaultPrevented) return;
11961 if (!isMouseMoving()) return;
11962 if (hoveringInside(event)) return;
11963 if (movingToAnotherItem(event)) return;
11964 if (!focusOnHoverProp(event)) return;
11965 if (!blurOnHoverEndProp(event)) return;
11966 store2 == null ? void 0 : store2.setActiveId(null);
11967 (_a = store2 == null ? void 0 : store2.getState().baseElement) == null ? void 0 : _a.focus();
11968 });
11969 const ref = (0, import_react23.useCallback)((element) => {
11970 if (!element) return;
11971 element[symbol2] = true;
11972 }, []);
11973 props = {
11974 ...props,
11975 ref: useMergeRefs(ref, props.ref),
11976 onMouseMove,
11977 onMouseLeave
11978 };
11979 return removeUndefinedValues(props);
11980 }
11981 );
11982 var CompositeHover = memo22(
11983 forwardRef26(function CompositeHover2(props) {
11984 const htmlProps = useCompositeHover(props);
11985 return createElement3(TagName8, htmlProps);
11986 })
11987 );
11988
11989 // node_modules/@ariakit/react-core/esm/combobox/combobox.js
11990 var import_react24 = __toESM(require_react(), 1);
11991 var TagName9 = "input";
11992 function isFirstItemAutoSelected(items, activeValue, autoSelect) {
11993 if (!autoSelect) return false;
11994 const firstItem = items.find((item) => !item.disabled && item.value);
11995 return (firstItem == null ? void 0 : firstItem.value) === activeValue;
11996 }
11997 function hasCompletionString(value, activeValue) {
11998 if (!activeValue) return false;
11999 if (value == null) return false;
12000 value = normalizeString(value);
12001 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0;
12002 }
12003 function isInputEvent(event) {
12004 return event.type === "input";
12005 }
12006 function isAriaAutoCompleteValue(value) {
12007 return value === "inline" || value === "list" || value === "both" || value === "none";
12008 }
12009 function getDefaultAutoSelectId(items) {
12010 const item = items.find((item2) => {
12011 var _a;
12012 if (item2.disabled) return false;
12013 return ((_a = item2.element) == null ? void 0 : _a.getAttribute("role")) !== "tab";
12014 });
12015 return item == null ? void 0 : item.id;
12016 }
12017 var useCombobox = createHook(
12018 function useCombobox2({
12019 store: store2,
12020 focusable = true,
12021 autoSelect: autoSelectProp = false,
12022 getAutoSelectId,
12023 setValueOnChange,
12024 showMinLength = 0,
12025 showOnChange,
12026 showOnMouseDown,
12027 showOnClick = showOnMouseDown,
12028 showOnKeyDown,
12029 showOnKeyPress = showOnKeyDown,
12030 blurActiveItemOnClick,
12031 setValueOnClick = true,
12032 moveOnKeyPress = true,
12033 autoComplete = "list",
12034 ...props
12035 }) {
12036 const context = useComboboxProviderContext();
12037 store2 = store2 || context;
12038 invariant(
12039 store2,
12040 "Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component."
12041 );
12042 const ref = (0, import_react24.useRef)(null);
12043 const [valueUpdated, forceValueUpdate] = useForceUpdate();
12044 const canAutoSelectRef = (0, import_react24.useRef)(false);
12045 const composingRef = (0, import_react24.useRef)(false);
12046 const autoSelect = store2.useState(
12047 (state) => state.virtualFocus && autoSelectProp
12048 );
12049 const inline = autoComplete === "inline" || autoComplete === "both";
12050 const [canInline, setCanInline] = (0, import_react24.useState)(inline);
12051 useUpdateLayoutEffect(() => {
12052 if (!inline) return;
12053 setCanInline(true);
12054 }, [inline]);
12055 const storeValue = store2.useState("value");
12056 const prevSelectedValueRef = (0, import_react24.useRef)(void 0);
12057 (0, import_react24.useEffect)(() => {
12058 return sync(store2, ["selectedValue", "activeId"], (_, prev) => {
12059 prevSelectedValueRef.current = prev.selectedValue;
12060 });
12061 }, []);
12062 const inlineActiveValue = store2.useState((state) => {
12063 var _a;
12064 if (!inline) return;
12065 if (!canInline) return;
12066 if (state.activeValue && Array.isArray(state.selectedValue)) {
12067 if (state.selectedValue.includes(state.activeValue)) return;
12068 if ((_a = prevSelectedValueRef.current) == null ? void 0 : _a.includes(state.activeValue)) return;
12069 }
12070 return state.activeValue;
12071 });
12072 const items = store2.useState("renderedItems");
12073 const open = store2.useState("open");
12074 const contentElement = store2.useState("contentElement");
12075 const value = (0, import_react24.useMemo)(() => {
12076 if (!inline) return storeValue;
12077 if (!canInline) return storeValue;
12078 const firstItemAutoSelected = isFirstItemAutoSelected(
12079 items,
12080 inlineActiveValue,
12081 autoSelect
12082 );
12083 if (firstItemAutoSelected) {
12084 if (hasCompletionString(storeValue, inlineActiveValue)) {
12085 const slice = (inlineActiveValue == null ? void 0 : inlineActiveValue.slice(storeValue.length)) || "";
12086 return storeValue + slice;
12087 }
12088 return storeValue;
12089 }
12090 return inlineActiveValue || storeValue;
12091 }, [inline, canInline, items, inlineActiveValue, autoSelect, storeValue]);
12092 (0, import_react24.useEffect)(() => {
12093 const element = ref.current;
12094 if (!element) return;
12095 const onCompositeItemMove = () => setCanInline(true);
12096 element.addEventListener("combobox-item-move", onCompositeItemMove);
12097 return () => {
12098 element.removeEventListener("combobox-item-move", onCompositeItemMove);
12099 };
12100 }, []);
12101 (0, import_react24.useEffect)(() => {
12102 if (!inline) return;
12103 if (!canInline) return;
12104 if (!inlineActiveValue) return;
12105 const firstItemAutoSelected = isFirstItemAutoSelected(
12106 items,
12107 inlineActiveValue,
12108 autoSelect
12109 );
12110 if (!firstItemAutoSelected) return;
12111 if (!hasCompletionString(storeValue, inlineActiveValue)) return;
12112 let cleanup = noop2;
12113 queueMicrotask(() => {
12114 const element = ref.current;
12115 if (!element) return;
12116 const { start: prevStart, end: prevEnd } = getTextboxSelection(element);
12117 const nextStart = storeValue.length;
12118 const nextEnd = inlineActiveValue.length;
12119 setSelectionRange(element, nextStart, nextEnd);
12120 cleanup = () => {
12121 if (!hasFocus(element)) return;
12122 const { start, end } = getTextboxSelection(element);
12123 if (start !== nextStart) return;
12124 if (end !== nextEnd) return;
12125 setSelectionRange(element, prevStart, prevEnd);
12126 };
12127 });
12128 return () => cleanup();
12129 }, [
12130 valueUpdated,
12131 inline,
12132 canInline,
12133 inlineActiveValue,
12134 items,
12135 autoSelect,
12136 storeValue
12137 ]);
12138 const scrollingElementRef = (0, import_react24.useRef)(null);
12139 const getAutoSelectIdProp = useEvent(getAutoSelectId);
12140 const autoSelectIdRef = (0, import_react24.useRef)(null);
12141 (0, import_react24.useEffect)(() => {
12142 if (!open) return;
12143 if (!contentElement) return;
12144 const scrollingElement = getScrollingElement(contentElement);
12145 if (!scrollingElement) return;
12146 scrollingElementRef.current = scrollingElement;
12147 const onUserScroll = () => {
12148 canAutoSelectRef.current = false;
12149 };
12150 const onScroll = () => {
12151 if (!store2) return;
12152 if (!canAutoSelectRef.current) return;
12153 const { activeId } = store2.getState();
12154 if (activeId === null) return;
12155 if (activeId === autoSelectIdRef.current) return;
12156 canAutoSelectRef.current = false;
12157 };
12158 const options = { passive: true, capture: true };
12159 scrollingElement.addEventListener("wheel", onUserScroll, options);
12160 scrollingElement.addEventListener("touchmove", onUserScroll, options);
12161 scrollingElement.addEventListener("scroll", onScroll, options);
12162 return () => {
12163 scrollingElement.removeEventListener("wheel", onUserScroll, true);
12164 scrollingElement.removeEventListener("touchmove", onUserScroll, true);
12165 scrollingElement.removeEventListener("scroll", onScroll, true);
12166 };
12167 }, [open, contentElement, store2]);
12168 useSafeLayoutEffect(() => {
12169 if (!storeValue) return;
12170 if (composingRef.current) return;
12171 canAutoSelectRef.current = true;
12172 }, [storeValue]);
12173 useSafeLayoutEffect(() => {
12174 if (autoSelect !== "always" && open) return;
12175 canAutoSelectRef.current = open;
12176 }, [autoSelect, open]);
12177 const resetValueOnSelect = store2.useState("resetValueOnSelect");
12178 useUpdateEffect(() => {
12179 var _a, _b;
12180 const canAutoSelect = canAutoSelectRef.current;
12181 if (!store2) return;
12182 if (!open) return;
12183 if (!canAutoSelect && !resetValueOnSelect) return;
12184 const { baseElement, contentElement: contentElement2, activeId } = store2.getState();
12185 if (baseElement && !hasFocus(baseElement)) return;
12186 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) {
12187 const observer = new MutationObserver(forceValueUpdate);
12188 observer.observe(contentElement2, { attributeFilter: ["data-placing"] });
12189 return () => observer.disconnect();
12190 }
12191 if (autoSelect && canAutoSelect) {
12192 const userAutoSelectId = getAutoSelectIdProp(items);
12193 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : (_a = getDefaultAutoSelectId(items)) != null ? _a : store2.first();
12194 autoSelectIdRef.current = autoSelectId;
12195 store2.move(autoSelectId != null ? autoSelectId : null);
12196 } else {
12197 const element = (_b = store2.item(activeId || store2.first())) == null ? void 0 : _b.element;
12198 if (element && "scrollIntoView" in element) {
12199 element.scrollIntoView({ block: "nearest", inline: "nearest" });
12200 }
12201 }
12202 return;
12203 }, [
12204 store2,
12205 open,
12206 valueUpdated,
12207 storeValue,
12208 autoSelect,
12209 resetValueOnSelect,
12210 getAutoSelectIdProp,
12211 items
12212 ]);
12213 (0, import_react24.useEffect)(() => {
12214 if (!inline) return;
12215 const combobox = ref.current;
12216 if (!combobox) return;
12217 const elements = [combobox, contentElement].filter(
12218 (value2) => !!value2
12219 );
12220 const onBlur2 = (event) => {
12221 if (elements.every((el) => isFocusEventOutside(event, el))) {
12222 store2 == null ? void 0 : store2.setValue(value);
12223 }
12224 };
12225 for (const element of elements) {
12226 element.addEventListener("focusout", onBlur2);
12227 }
12228 return () => {
12229 for (const element of elements) {
12230 element.removeEventListener("focusout", onBlur2);
12231 }
12232 };
12233 }, [inline, contentElement, store2, value]);
12234 const canShow = (event) => {
12235 const currentTarget = event.currentTarget;
12236 return currentTarget.value.length >= showMinLength;
12237 };
12238 const onChangeProp = props.onChange;
12239 const showOnChangeProp = useBooleanEvent(showOnChange != null ? showOnChange : canShow);
12240 const setValueOnChangeProp = useBooleanEvent(
12241 // If the combobox is combined with tags, the value will be set by the tag
12242 // input component.
12243 setValueOnChange != null ? setValueOnChange : !store2.tag
12244 );
12245 const onChange = useEvent((event) => {
12246 onChangeProp == null ? void 0 : onChangeProp(event);
12247 if (event.defaultPrevented) return;
12248 if (!store2) return;
12249 const currentTarget = event.currentTarget;
12250 const { value: value2, selectionStart, selectionEnd } = currentTarget;
12251 const nativeEvent = event.nativeEvent;
12252 canAutoSelectRef.current = true;
12253 if (isInputEvent(nativeEvent)) {
12254 if (nativeEvent.isComposing) {
12255 canAutoSelectRef.current = false;
12256 composingRef.current = true;
12257 }
12258 if (inline) {
12259 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText";
12260 const caretAtEnd = selectionStart === value2.length;
12261 setCanInline(textInserted && caretAtEnd);
12262 }
12263 }
12264 if (setValueOnChangeProp(event)) {
12265 const isSameValue = value2 === store2.getState().value;
12266 store2.setValue(value2);
12267 queueMicrotask(() => {
12268 setSelectionRange(currentTarget, selectionStart, selectionEnd);
12269 });
12270 if (inline && autoSelect && isSameValue) {
12271 forceValueUpdate();
12272 }
12273 }
12274 if (showOnChangeProp(event)) {
12275 store2.show();
12276 }
12277 if (!autoSelect || !canAutoSelectRef.current) {
12278 store2.setActiveId(null);
12279 }
12280 });
12281 const onCompositionEndProp = props.onCompositionEnd;
12282 const onCompositionEnd = useEvent((event) => {
12283 canAutoSelectRef.current = true;
12284 composingRef.current = false;
12285 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event);
12286 if (event.defaultPrevented) return;
12287 if (!autoSelect) return;
12288 forceValueUpdate();
12289 });
12290 const onMouseDownProp = props.onMouseDown;
12291 const blurActiveItemOnClickProp = useBooleanEvent(
12292 blurActiveItemOnClick != null ? blurActiveItemOnClick : (() => !!(store2 == null ? void 0 : store2.getState().includesBaseElement))
12293 );
12294 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
12295 const showOnClickProp = useBooleanEvent(showOnClick != null ? showOnClick : canShow);
12296 const onMouseDown = useEvent((event) => {
12297 onMouseDownProp == null ? void 0 : onMouseDownProp(event);
12298 if (event.defaultPrevented) return;
12299 if (event.button) return;
12300 if (event.ctrlKey) return;
12301 if (!store2) return;
12302 if (blurActiveItemOnClickProp(event)) {
12303 store2.setActiveId(null);
12304 }
12305 if (setValueOnClickProp(event)) {
12306 store2.setValue(value);
12307 }
12308 if (showOnClickProp(event)) {
12309 queueBeforeEvent(event.currentTarget, "mouseup", store2.show);
12310 }
12311 });
12312 const onKeyDownProp = props.onKeyDown;
12313 const showOnKeyPressProp = useBooleanEvent(showOnKeyPress != null ? showOnKeyPress : canShow);
12314 const onKeyDown = useEvent((event) => {
12315 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
12316 if (!event.repeat) {
12317 canAutoSelectRef.current = false;
12318 }
12319 if (event.defaultPrevented) return;
12320 if (event.ctrlKey) return;
12321 if (event.altKey) return;
12322 if (event.shiftKey) return;
12323 if (event.metaKey) return;
12324 if (!store2) return;
12325 const { open: open2 } = store2.getState();
12326 if (open2) return;
12327 if (event.key === "ArrowUp" || event.key === "ArrowDown") {
12328 if (showOnKeyPressProp(event)) {
12329 event.preventDefault();
12330 store2.show();
12331 }
12332 }
12333 });
12334 const onBlurProp = props.onBlur;
12335 const onBlur = useEvent((event) => {
12336 canAutoSelectRef.current = false;
12337 onBlurProp == null ? void 0 : onBlurProp(event);
12338 if (event.defaultPrevented) return;
12339 });
12340 const id = useId5(props.id);
12341 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0;
12342 const isActiveItem = store2.useState((state) => state.activeId === null);
12343 props = {
12344 id,
12345 role: "combobox",
12346 "aria-autocomplete": ariaAutoComplete,
12347 "aria-haspopup": getPopupRole(contentElement, "listbox"),
12348 "aria-expanded": open,
12349 "aria-controls": contentElement == null ? void 0 : contentElement.id,
12350 "data-active-item": isActiveItem || void 0,
12351 value,
12352 ...props,
12353 ref: useMergeRefs(ref, props.ref),
12354 onChange,
12355 onCompositionEnd,
12356 onMouseDown,
12357 onKeyDown,
12358 onBlur
12359 };
12360 props = useComposite({
12361 store: store2,
12362 focusable,
12363 ...props,
12364 // Enable inline autocomplete when the user moves from the combobox input
12365 // to an item.
12366 moveOnKeyPress: (event) => {
12367 if (isFalsyBooleanCallback(moveOnKeyPress, event)) return false;
12368 if (inline) setCanInline(true);
12369 return true;
12370 }
12371 });
12372 props = usePopoverAnchor({ store: store2, ...props });
12373 return { autoComplete: "off", ...props };
12374 }
12375 );
12376 var Combobox = forwardRef26(function Combobox2(props) {
12377 const htmlProps = useCombobox(props);
12378 return createElement3(TagName9, htmlProps);
12379 });
12380
12381 // node_modules/@ariakit/react-core/esm/__chunks/IBXZ2LQC.js
12382 var import_react25 = __toESM(require_react(), 1);
12383 var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);
12384 var TagName10 = "div";
12385 function isSelected(storeValue, itemValue) {
12386 if (itemValue == null) return;
12387 if (storeValue == null) return false;
12388 if (Array.isArray(storeValue)) {
12389 return storeValue.includes(itemValue);
12390 }
12391 return storeValue === itemValue;
12392 }
12393 function getItemRole(popupRole) {
12394 var _a;
12395 const itemRoleByPopupRole = {
12396 menu: "menuitem",
12397 listbox: "option",
12398 tree: "treeitem"
12399 };
12400 const key = popupRole;
12401 return (_a = itemRoleByPopupRole[key]) != null ? _a : "option";
12402 }
12403 var useComboboxItem = createHook(
12404 function useComboboxItem2({
12405 store: store2,
12406 value,
12407 hideOnClick,
12408 setValueOnClick,
12409 selectValueOnClick = true,
12410 resetValueOnSelect,
12411 focusOnHover = false,
12412 moveOnKeyPress = true,
12413 getItem: getItemProp,
12414 ...props
12415 }) {
12416 var _a;
12417 const context = useComboboxScopedContext();
12418 store2 = store2 || context;
12419 invariant(
12420 store2,
12421 "ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component."
12422 );
12423 const { resetValueOnSelectState, multiSelectable, selected } = useStoreStateObject(store2, {
12424 resetValueOnSelectState: "resetValueOnSelect",
12425 multiSelectable(state) {
12426 return Array.isArray(state.selectedValue);
12427 },
12428 selected(state) {
12429 return isSelected(state.selectedValue, value);
12430 }
12431 });
12432 const getItem = (0, import_react25.useCallback)(
12433 (item) => {
12434 const nextItem = { ...item, value };
12435 if (getItemProp) {
12436 return getItemProp(nextItem);
12437 }
12438 return nextItem;
12439 },
12440 [value, getItemProp]
12441 );
12442 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable;
12443 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable;
12444 const onClickProp = props.onClick;
12445 const setValueOnClickProp = useBooleanEvent(setValueOnClick);
12446 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick);
12447 const resetValueOnSelectProp = useBooleanEvent(
12448 (_a = resetValueOnSelect != null ? resetValueOnSelect : resetValueOnSelectState) != null ? _a : multiSelectable
12449 );
12450 const hideOnClickProp = useBooleanEvent(hideOnClick);
12451 const onClick = useEvent((event) => {
12452 onClickProp == null ? void 0 : onClickProp(event);
12453 if (event.defaultPrevented) return;
12454 if (isDownloading(event)) return;
12455 if (isOpeningInNewTab(event)) return;
12456 if (value != null) {
12457 if (selectValueOnClickProp(event)) {
12458 if (resetValueOnSelectProp(event)) {
12459 store2 == null ? void 0 : store2.resetValue();
12460 }
12461 store2 == null ? void 0 : store2.setSelectedValue((prevValue) => {
12462 if (!Array.isArray(prevValue)) return value;
12463 if (prevValue.includes(value)) {
12464 return prevValue.filter((v2) => v2 !== value);
12465 }
12466 return [...prevValue, value];
12467 });
12468 }
12469 if (setValueOnClickProp(event)) {
12470 store2 == null ? void 0 : store2.setValue(value);
12471 }
12472 }
12473 if (hideOnClickProp(event)) {
12474 store2 == null ? void 0 : store2.hide();
12475 }
12476 });
12477 const onKeyDownProp = props.onKeyDown;
12478 const onKeyDown = useEvent((event) => {
12479 onKeyDownProp == null ? void 0 : onKeyDownProp(event);
12480 if (event.defaultPrevented) return;
12481 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
12482 if (!baseElement) return;
12483 if (hasFocus(baseElement)) return;
12484 const printable = event.key.length === 1;
12485 if (printable || event.key === "Backspace" || event.key === "Delete") {
12486 queueMicrotask(() => baseElement.focus());
12487 if (isTextField(baseElement)) {
12488 store2 == null ? void 0 : store2.setValue(baseElement.value);
12489 }
12490 }
12491 });
12492 if (multiSelectable && selected != null) {
12493 props = {
12494 "aria-selected": selected,
12495 ...props
12496 };
12497 }
12498 props = useWrapElement(
12499 props,
12500 (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 }) }),
12501 [value, selected]
12502 );
12503 const popupRole = (0, import_react25.useContext)(ComboboxListRoleContext);
12504 props = {
12505 role: getItemRole(popupRole),
12506 children: value,
12507 ...props,
12508 onClick,
12509 onKeyDown
12510 };
12511 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress);
12512 props = useCompositeItem({
12513 store: store2,
12514 ...props,
12515 getItem,
12516 // Dispatch a custom event on the combobox input when moving to an item
12517 // with the keyboard so the Combobox component can enable inline
12518 // autocompletion.
12519 moveOnKeyPress: (event) => {
12520 if (!moveOnKeyPressProp(event)) return false;
12521 const moveEvent = new Event("combobox-item-move");
12522 const baseElement = store2 == null ? void 0 : store2.getState().baseElement;
12523 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent);
12524 return true;
12525 }
12526 });
12527 props = useCompositeHover({ store: store2, focusOnHover, ...props });
12528 return props;
12529 }
12530 );
12531 var ComboboxItem = memo22(
12532 forwardRef26(function ComboboxItem2(props) {
12533 const htmlProps = useComboboxItem(props);
12534 return createElement3(TagName10, htmlProps);
12535 })
12536 );
12537
12538 // node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js
12539 var import_react26 = __toESM(require_react(), 1);
12540 var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
12541 var TagName11 = "span";
12542 function normalizeValue(value) {
12543 return normalizeString(value).toLowerCase();
12544 }
12545 function getOffsets(string, values) {
12546 const offsets = [];
12547 for (const value of values) {
12548 let pos = 0;
12549 const length = value.length;
12550 while (string.indexOf(value, pos) !== -1) {
12551 const index = string.indexOf(value, pos);
12552 if (index !== -1) {
12553 offsets.push([index, length]);
12554 }
12555 pos = index + 1;
12556 }
12557 }
12558 return offsets;
12559 }
12560 function filterOverlappingOffsets(offsets) {
12561 return offsets.filter(([offset, length], i2, arr) => {
12562 return !arr.some(
12563 ([o2, l2], j2) => j2 !== i2 && o2 <= offset && o2 + l2 >= offset + length
12564 );
12565 });
12566 }
12567 function sortOffsets(offsets) {
12568 return offsets.sort(([a2], [b2]) => a2 - b2);
12569 }
12570 function splitValue(itemValue, userValue) {
12571 if (!itemValue) return itemValue;
12572 if (!userValue) return itemValue;
12573 const userValues = toArray(userValue).filter(Boolean).map(normalizeValue);
12574 const parts = [];
12575 const span = (value, autocomplete = false) => /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
12576 "span",
12577 {
12578 "data-autocomplete-value": autocomplete ? "" : void 0,
12579 "data-user-value": autocomplete ? void 0 : "",
12580 children: value
12581 },
12582 parts.length
12583 );
12584 const offsets = sortOffsets(
12585 filterOverlappingOffsets(
12586 // Convert userValues into a set to avoid duplicates
12587 getOffsets(normalizeValue(itemValue), new Set(userValues))
12588 )
12589 );
12590 if (!offsets.length) {
12591 parts.push(span(itemValue, true));
12592 return parts;
12593 }
12594 const [firstOffset] = offsets[0];
12595 const values = [
12596 itemValue.slice(0, firstOffset),
12597 ...offsets.flatMap(([offset, length], i2) => {
12598 var _a;
12599 const value = itemValue.slice(offset, offset + length);
12600 const nextOffset = (_a = offsets[i2 + 1]) == null ? void 0 : _a[0];
12601 const nextValue = itemValue.slice(offset + length, nextOffset);
12602 return [value, nextValue];
12603 })
12604 ];
12605 values.forEach((value, i2) => {
12606 if (!value) return;
12607 parts.push(span(value, i2 % 2 === 0));
12608 });
12609 return parts;
12610 }
12611 var useComboboxItemValue = createHook(function useComboboxItemValue2({ store: store2, value, userValue, ...props }) {
12612 const context = useComboboxScopedContext();
12613 store2 = store2 || context;
12614 const itemContext = (0, import_react26.useContext)(ComboboxItemValueContext);
12615 const itemValue = value != null ? value : itemContext;
12616 const inputValue = useStoreState(store2, (state) => userValue != null ? userValue : state == null ? void 0 : state.value);
12617 const children = (0, import_react26.useMemo)(() => {
12618 if (!itemValue) return;
12619 if (!inputValue) return itemValue;
12620 return splitValue(itemValue, inputValue);
12621 }, [itemValue, inputValue]);
12622 props = {
12623 children,
12624 ...props
12625 };
12626 return removeUndefinedValues(props);
12627 });
12628 var ComboboxItemValue = forwardRef26(function ComboboxItemValue2(props) {
12629 const htmlProps = useComboboxItemValue(props);
12630 return createElement3(TagName11, htmlProps);
12631 });
12632
12633 // node_modules/@ariakit/react-core/esm/combobox/combobox-label.js
12634 var TagName12 = "label";
12635 var useComboboxLabel = createHook(
12636 function useComboboxLabel2({ store: store2, ...props }) {
12637 const context = useComboboxProviderContext();
12638 store2 = store2 || context;
12639 invariant(
12640 store2,
12641 "ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component."
12642 );
12643 const comboboxId = store2.useState((state) => {
12644 var _a;
12645 return (_a = state.baseElement) == null ? void 0 : _a.id;
12646 });
12647 props = {
12648 htmlFor: comboboxId,
12649 ...props
12650 };
12651 return removeUndefinedValues(props);
12652 }
12653 );
12654 var ComboboxLabel = memo22(
12655 forwardRef26(function ComboboxLabel2(props) {
12656 const htmlProps = useComboboxLabel(props);
12657 return createElement3(TagName12, htmlProps);
12658 })
12659 );
12660
12661 // node_modules/@ariakit/react-core/esm/__chunks/2G6YEJT4.js
12662 var import_react27 = __toESM(require_react(), 1);
12663 var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
12664 var TagName13 = "div";
12665 var useComboboxList = createHook(
12666 function useComboboxList2({ store: store2, alwaysVisible, ...props }) {
12667 const scopedContext = useComboboxScopedContext(true);
12668 const context = useComboboxContext();
12669 store2 = store2 || context;
12670 const scopedContextSameStore = !!store2 && store2 === scopedContext;
12671 invariant(
12672 store2,
12673 "ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component."
12674 );
12675 const ref = (0, import_react27.useRef)(null);
12676 const id = useId5(props.id);
12677 const mounted = store2.useState("mounted");
12678 const hidden = isHidden(mounted, props.hidden, alwaysVisible);
12679 const style = hidden ? { ...props.style, display: "none" } : props.style;
12680 const multiSelectable = store2.useState(
12681 (state) => Array.isArray(state.selectedValue)
12682 );
12683 const role = useAttribute(ref, "role", props.role);
12684 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid";
12685 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0;
12686 const [hasListboxInside, setHasListboxInside] = (0, import_react27.useState)(false);
12687 const contentElement = store2.useState("contentElement");
12688 useSafeLayoutEffect(() => {
12689 if (!mounted) return;
12690 const element = ref.current;
12691 if (!element) return;
12692 if (contentElement !== element) return;
12693 const callback = () => {
12694 setHasListboxInside(!!element.querySelector("[role='listbox']"));
12695 };
12696 const observer = new MutationObserver(callback);
12697 observer.observe(element, {
12698 subtree: true,
12699 childList: true,
12700 attributeFilter: ["role"]
12701 });
12702 callback();
12703 return () => observer.disconnect();
12704 }, [mounted, contentElement]);
12705 if (!hasListboxInside) {
12706 props = {
12707 role: "listbox",
12708 "aria-multiselectable": ariaMultiSelectable,
12709 ...props
12710 };
12711 }
12712 props = useWrapElement(
12713 props,
12714 (element) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxScopedContextProvider, { value: store2, children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(ComboboxListRoleContext.Provider, { value: role, children: element }) }),
12715 [store2, role]
12716 );
12717 const setContentElement = id && (!scopedContext || !scopedContextSameStore) ? store2.setContentElement : null;
12718 props = {
12719 id,
12720 hidden,
12721 ...props,
12722 ref: useMergeRefs(setContentElement, ref, props.ref),
12723 style
12724 };
12725 return removeUndefinedValues(props);
12726 }
12727 );
12728 var ComboboxList = forwardRef26(function ComboboxList2(props) {
12729 const htmlProps = useComboboxList(props);
12730 return createElement3(TagName13, htmlProps);
12731 });
12732
12733 // node_modules/@ariakit/react-core/esm/__chunks/XSIEPKGA.js
12734 var import_react28 = __toESM(require_react(), 1);
12735 var TagValueContext = (0, import_react28.createContext)(null);
12736 var TagRemoveIdContext = (0, import_react28.createContext)(
12737 null
12738 );
12739 var ctx7 = createStoreContext(
12740 [CompositeContextProvider],
12741 [CompositeScopedContextProvider]
12742 );
12743 var useTagContext = ctx7.useContext;
12744 var useTagScopedContext = ctx7.useScopedContext;
12745 var useTagProviderContext = ctx7.useProviderContext;
12746 var TagContextProvider = ctx7.ContextProvider;
12747 var TagScopedContextProvider = ctx7.ScopedContextProvider;
12748
12749 // node_modules/@ariakit/core/esm/combobox/combobox-store.js
12750 var isTouchSafari = isSafari() && isTouchDevice();
12751 function createComboboxStore({
12752 tag,
12753 ...props
12754 } = {}) {
12755 const store2 = mergeStore(props.store, pick2(tag, ["value", "rtl"]));
12756 throwOnConflictingProps(props, store2);
12757 const tagState = tag == null ? void 0 : tag.getState();
12758 const syncState = store2 == null ? void 0 : store2.getState();
12759 const activeId = defaultValue(
12760 props.activeId,
12761 syncState == null ? void 0 : syncState.activeId,
12762 props.defaultActiveId,
12763 null
12764 );
12765 const composite = createCompositeStore({
12766 ...props,
12767 activeId,
12768 includesBaseElement: defaultValue(
12769 props.includesBaseElement,
12770 syncState == null ? void 0 : syncState.includesBaseElement,
12771 true
12772 ),
12773 orientation: defaultValue(
12774 props.orientation,
12775 syncState == null ? void 0 : syncState.orientation,
12776 "vertical"
12777 ),
12778 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true),
12779 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true),
12780 virtualFocus: defaultValue(
12781 props.virtualFocus,
12782 syncState == null ? void 0 : syncState.virtualFocus,
12783 true
12784 )
12785 });
12786 const popover = createPopoverStore({
12787 ...props,
12788 placement: defaultValue(
12789 props.placement,
12790 syncState == null ? void 0 : syncState.placement,
12791 "bottom-start"
12792 )
12793 });
12794 const value = defaultValue(
12795 props.value,
12796 syncState == null ? void 0 : syncState.value,
12797 props.defaultValue,
12798 ""
12799 );
12800 const selectedValue = defaultValue(
12801 props.selectedValue,
12802 syncState == null ? void 0 : syncState.selectedValue,
12803 tagState == null ? void 0 : tagState.values,
12804 props.defaultSelectedValue,
12805 ""
12806 );
12807 const multiSelectable = Array.isArray(selectedValue);
12808 const initialState = {
12809 ...composite.getState(),
12810 ...popover.getState(),
12811 value,
12812 selectedValue,
12813 resetValueOnSelect: defaultValue(
12814 props.resetValueOnSelect,
12815 syncState == null ? void 0 : syncState.resetValueOnSelect,
12816 multiSelectable
12817 ),
12818 resetValueOnHide: defaultValue(
12819 props.resetValueOnHide,
12820 syncState == null ? void 0 : syncState.resetValueOnHide,
12821 multiSelectable && !tag
12822 ),
12823 activeValue: syncState == null ? void 0 : syncState.activeValue
12824 };
12825 const combobox = createStore(initialState, composite, popover, store2);
12826 if (isTouchSafari) {
12827 setup(
12828 combobox,
12829 () => sync(combobox, ["virtualFocus"], () => {
12830 combobox.setState("virtualFocus", false);
12831 })
12832 );
12833 }
12834 setup(combobox, () => {
12835 if (!tag) return;
12836 return chain(
12837 sync(combobox, ["selectedValue"], (state) => {
12838 if (!Array.isArray(state.selectedValue)) return;
12839 tag.setValues(state.selectedValue);
12840 }),
12841 sync(tag, ["values"], (state) => {
12842 combobox.setState("selectedValue", state.values);
12843 })
12844 );
12845 });
12846 setup(
12847 combobox,
12848 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => {
12849 if (!state.resetValueOnHide) return;
12850 if (state.mounted) return;
12851 combobox.setState("value", value);
12852 })
12853 );
12854 setup(
12855 combobox,
12856 () => sync(combobox, ["open"], (state) => {
12857 if (state.open) return;
12858 combobox.setState("activeId", activeId);
12859 combobox.setState("moves", 0);
12860 })
12861 );
12862 setup(
12863 combobox,
12864 () => sync(combobox, ["moves", "activeId"], (state, prevState) => {
12865 if (state.moves === prevState.moves) {
12866 combobox.setState("activeValue", void 0);
12867 }
12868 })
12869 );
12870 setup(
12871 combobox,
12872 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => {
12873 if (state.moves === prev.moves) return;
12874 const { activeId: activeId2 } = combobox.getState();
12875 const activeItem = composite.item(activeId2);
12876 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value);
12877 })
12878 );
12879 return {
12880 ...popover,
12881 ...composite,
12882 ...combobox,
12883 tag,
12884 setValue: (value2) => combobox.setState("value", value2),
12885 resetValue: () => combobox.setState("value", initialState.value),
12886 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2)
12887 };
12888 }
12889
12890 // node_modules/@ariakit/react-core/esm/__chunks/SVN33SY6.js
12891 function useComboboxStoreOptions(props) {
12892 const tag = useTagContext();
12893 props = {
12894 ...props,
12895 tag: props.tag !== void 0 ? props.tag : tag
12896 };
12897 return useCompositeStoreOptions(props);
12898 }
12899 function useComboboxStoreProps(store2, update2, props) {
12900 useUpdateEffect(update2, [props.tag]);
12901 useStoreProps(store2, props, "value", "setValue");
12902 useStoreProps(store2, props, "selectedValue", "setSelectedValue");
12903 useStoreProps(store2, props, "resetValueOnHide");
12904 useStoreProps(store2, props, "resetValueOnSelect");
12905 return Object.assign(
12906 useCompositeStoreProps(
12907 usePopoverStoreProps(store2, update2, props),
12908 update2,
12909 props
12910 ),
12911 { tag: props.tag }
12912 );
12913 }
12914 function useComboboxStore(props = {}) {
12915 props = useComboboxStoreOptions(props);
12916 const [store2, update2] = useStore(createComboboxStore, props);
12917 return useComboboxStoreProps(store2, update2, props);
12918 }
12919
12920 // node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js
12921 var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);
12922 function ComboboxProvider(props = {}) {
12923 const store2 = useComboboxStore(props);
12924 return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ComboboxContextProvider, { value: store2, children: props.children });
12925 }
12926
12927 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
12928 var import_remove_accents = __toESM(require_remove_accents(), 1);
12929 var import_compose7 = __toESM(require_compose(), 1);
12930 var import_i18n22 = __toESM(require_i18n(), 1);
12931 var import_element43 = __toESM(require_element(), 1);
12932 var import_components20 = __toESM(require_components(), 1);
12933
12934 // packages/dataviews/build-module/components/dataviews-filters/utils.mjs
12935 var EMPTY_ARRAY3 = [];
12936 var getCurrentValue = (filterDefinition, currentFilter) => {
12937 if (filterDefinition.singleSelection) {
12938 return currentFilter?.value;
12939 }
12940 if (Array.isArray(currentFilter?.value)) {
12941 return currentFilter.value;
12942 }
12943 if (!Array.isArray(currentFilter?.value) && !!currentFilter?.value) {
12944 return [currentFilter.value];
12945 }
12946 return EMPTY_ARRAY3;
12947 };
12948
12949 // packages/dataviews/build-module/hooks/use-elements.mjs
12950 var import_element42 = __toESM(require_element(), 1);
12951 var EMPTY_ARRAY4 = [];
12952 function useElements({
12953 elements,
12954 getElements
12955 }) {
12956 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY4;
12957 const [records, setRecords] = (0, import_element42.useState)(staticElements);
12958 const [isLoading, setIsLoading] = (0, import_element42.useState)(false);
12959 (0, import_element42.useEffect)(() => {
12960 if (!getElements) {
12961 setRecords(staticElements);
12962 return;
12963 }
12964 let cancelled = false;
12965 setIsLoading(true);
12966 getElements().then((fetchedElements) => {
12967 if (!cancelled) {
12968 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements;
12969 setRecords(dynamicElements);
12970 }
12971 }).catch(() => {
12972 if (!cancelled) {
12973 setRecords(staticElements);
12974 }
12975 }).finally(() => {
12976 if (!cancelled) {
12977 setIsLoading(false);
12978 }
12979 });
12980 return () => {
12981 cancelled = true;
12982 };
12983 }, [getElements, staticElements]);
12984 return {
12985 elements: records,
12986 isLoading
12987 };
12988 }
12989
12990 // packages/dataviews/build-module/components/dataviews-filters/search-widget.mjs
12991 var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
12992 function normalizeSearchInput(input = "") {
12993 return (0, import_remove_accents.default)(input.trim().toLowerCase());
12994 }
12995 var getNewValue = (filterDefinition, currentFilter, value) => {
12996 if (filterDefinition.singleSelection) {
12997 return value;
12998 }
12999 if (Array.isArray(currentFilter?.value)) {
13000 return currentFilter.value.includes(value) ? currentFilter.value.filter((v2) => v2 !== value) : [...currentFilter.value, value];
13001 }
13002 return [value];
13003 };
13004 function generateFilterElementCompositeItemId(prefix, filterElementValue) {
13005 return `${prefix}-${filterElementValue}`;
13006 }
13007 var MultiSelectionOption = ({ selected }) => {
13008 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13009 "span",
13010 {
13011 className: clsx_default(
13012 "dataviews-filters__search-widget-listitem-multi-selection",
13013 { "is-selected": selected }
13014 ),
13015 children: selected && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Icon, { icon: check_default })
13016 }
13017 );
13018 };
13019 var SingleSelectionOption = ({ selected }) => {
13020 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13021 "span",
13022 {
13023 className: clsx_default(
13024 "dataviews-filters__search-widget-listitem-single-selection",
13025 { "is-selected": selected }
13026 )
13027 }
13028 );
13029 };
13030 function ListBox({ view, filter, onChangeView }) {
13031 const baseId = (0, import_compose7.useInstanceId)(ListBox, "dataviews-filter-list-box");
13032 const [activeCompositeId, setActiveCompositeId] = (0, import_element43.useState)(
13033 // When there are one or less operators, the first item is set as active
13034 // (by setting the initial `activeId` to `undefined`).
13035 // With 2 or more operators, the focus is moved on the operators control
13036 // (by setting the initial `activeId` to `null`), meaning that there won't
13037 // be an active item initially. Focus is then managed via the
13038 // `onFocusVisible` callback.
13039 filter.operators?.length === 1 ? void 0 : null
13040 );
13041 const currentFilter = view.filters?.find(
13042 (f2) => f2.field === filter.field
13043 );
13044 const currentValue = getCurrentValue(filter, currentFilter);
13045 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13046 import_components20.Composite,
13047 {
13048 virtualFocus: true,
13049 focusLoop: true,
13050 activeId: activeCompositeId,
13051 setActiveId: setActiveCompositeId,
13052 role: "listbox",
13053 className: "dataviews-filters__search-widget-listbox",
13054 "aria-label": (0, import_i18n22.sprintf)(
13055 /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */
13056 (0, import_i18n22.__)("List of: %1$s"),
13057 filter.name
13058 ),
13059 onFocusVisible: () => {
13060 if (!activeCompositeId && filter.elements.length) {
13061 setActiveCompositeId(
13062 generateFilterElementCompositeItemId(
13063 baseId,
13064 filter.elements[0].value
13065 )
13066 );
13067 }
13068 },
13069 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_components20.Composite.Typeahead, {}),
13070 children: filter.elements.map((element) => /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
13071 import_components20.Composite.Hover,
13072 {
13073 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13074 import_components20.Composite.Item,
13075 {
13076 id: generateFilterElementCompositeItemId(
13077 baseId,
13078 element.value
13079 ),
13080 render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13081 "div",
13082 {
13083 "aria-label": element.label,
13084 role: "option",
13085 className: "dataviews-filters__search-widget-listitem"
13086 }
13087 ),
13088 onClick: () => {
13089 const newFilters = currentFilter ? [
13090 ...(view.filters ?? []).map(
13091 (_filter) => {
13092 if (_filter.field === filter.field) {
13093 return {
13094 ..._filter,
13095 operator: currentFilter.operator || filter.operators[0],
13096 value: getNewValue(
13097 filter,
13098 currentFilter,
13099 element.value
13100 )
13101 };
13102 }
13103 return _filter;
13104 }
13105 )
13106 ] : [
13107 ...view.filters ?? [],
13108 {
13109 field: filter.field,
13110 operator: filter.operators[0],
13111 value: getNewValue(
13112 filter,
13113 currentFilter,
13114 element.value
13115 )
13116 }
13117 ];
13118 onChangeView({
13119 ...view,
13120 page: 1,
13121 filters: newFilters
13122 });
13123 }
13124 }
13125 ),
13126 children: [
13127 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13128 SingleSelectionOption,
13129 {
13130 selected: currentValue === element.value
13131 }
13132 ),
13133 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13134 MultiSelectionOption,
13135 {
13136 selected: currentValue.includes(element.value)
13137 }
13138 ),
13139 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13140 "span",
13141 {
13142 className: "dataviews-filters__search-widget-listitem-value",
13143 title: element.label,
13144 children: element.label
13145 }
13146 )
13147 ]
13148 },
13149 element.value
13150 ))
13151 }
13152 );
13153 }
13154 function ComboboxList22({ view, filter, onChangeView }) {
13155 const [searchValue, setSearchValue] = (0, import_element43.useState)("");
13156 const deferredSearchValue = (0, import_element43.useDeferredValue)(searchValue);
13157 const currentFilter = view.filters?.find(
13158 (_filter) => _filter.field === filter.field
13159 );
13160 const currentValue = getCurrentValue(filter, currentFilter);
13161 const matches = (0, import_element43.useMemo)(() => {
13162 const normalizedSearch = normalizeSearchInput(deferredSearchValue);
13163 return filter.elements.filter(
13164 (item) => normalizeSearchInput(item.label).includes(normalizedSearch)
13165 );
13166 }, [filter.elements, deferredSearchValue]);
13167 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
13168 ComboboxProvider,
13169 {
13170 selectedValue: currentValue,
13171 setSelectedValue: (value) => {
13172 const newFilters = currentFilter ? [
13173 ...(view.filters ?? []).map((_filter) => {
13174 if (_filter.field === filter.field) {
13175 return {
13176 ..._filter,
13177 operator: currentFilter.operator || filter.operators[0],
13178 value
13179 };
13180 }
13181 return _filter;
13182 })
13183 ] : [
13184 ...view.filters ?? [],
13185 {
13186 field: filter.field,
13187 operator: filter.operators[0],
13188 value
13189 }
13190 ];
13191 onChangeView({
13192 ...view,
13193 page: 1,
13194 filters: newFilters
13195 });
13196 },
13197 setValue: setSearchValue,
13198 children: [
13199 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)("div", { className: "dataviews-filters__search-widget-filter-combobox__wrapper", children: [
13200 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(ComboboxLabel, {}), children: (0, import_i18n22.__)("Search items") }),
13201 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13202 Combobox,
13203 {
13204 autoSelect: "always",
13205 placeholder: (0, import_i18n22.__)("Search"),
13206 className: "dataviews-filters__search-widget-filter-combobox__input"
13207 }
13208 ),
13209 /* @__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 }) })
13210 ] }),
13211 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
13212 ComboboxList,
13213 {
13214 className: "dataviews-filters__search-widget-filter-combobox-list",
13215 alwaysVisible: true,
13216 children: [
13217 matches.map((element) => {
13218 return /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
13219 ComboboxItem,
13220 {
13221 resetValueOnSelect: false,
13222 value: element.value,
13223 className: "dataviews-filters__search-widget-listitem",
13224 hideOnClick: false,
13225 setValueOnClick: false,
13226 focusOnHover: true,
13227 children: [
13228 filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13229 SingleSelectionOption,
13230 {
13231 selected: currentValue === element.value
13232 }
13233 ),
13234 !filter.singleSelection && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13235 MultiSelectionOption,
13236 {
13237 selected: currentValue.includes(
13238 element.value
13239 )
13240 }
13241 ),
13242 /* @__PURE__ */ (0, import_jsx_runtime74.jsxs)(
13243 "span",
13244 {
13245 className: "dataviews-filters__search-widget-listitem-value",
13246 title: element.label,
13247 children: [
13248 /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(
13249 ComboboxItemValue,
13250 {
13251 className: "dataviews-filters__search-widget-filter-combobox-item-value",
13252 value: element.label
13253 }
13254 ),
13255 !!element.description && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("span", { className: "dataviews-filters__search-widget-listitem-description", children: element.description })
13256 ]
13257 }
13258 )
13259 ]
13260 },
13261 element.value
13262 );
13263 }),
13264 !matches.length && /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("p", { children: (0, import_i18n22.__)("No results found") })
13265 ]
13266 }
13267 )
13268 ]
13269 }
13270 );
13271 }
13272 function SearchWidget(props) {
13273 const { elements, isLoading } = useElements({
13274 elements: props.filter.elements,
13275 getElements: props.filter.getElements
13276 });
13277 if (isLoading) {
13278 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, {}) });
13279 }
13280 if (elements.length === 0) {
13281 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)("div", { className: "dataviews-filters__search-widget-no-elements", children: (0, import_i18n22.__)("No elements found") });
13282 }
13283 const Widget = elements.length > 10 ? ComboboxList22 : ListBox;
13284 return /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(Widget, { ...props, filter: { ...props.filter, elements } });
13285 }
13286
13287 // packages/dataviews/build-module/components/dataviews-filters/input-widget.mjs
13288 var import_es6 = __toESM(require_es6(), 1);
13289 var import_compose8 = __toESM(require_compose(), 1);
13290 var import_element44 = __toESM(require_element(), 1);
13291 var import_components21 = __toESM(require_components(), 1);
13292 var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
13293 function InputWidget({
13294 filter,
13295 view,
13296 onChangeView,
13297 fields: fields2
13298 }) {
13299 const currentFilter = view.filters?.find(
13300 (f2) => f2.field === filter.field
13301 );
13302 const currentValue = getCurrentValue(filter, currentFilter);
13303 const field = (0, import_element44.useMemo)(() => {
13304 const currentField = fields2.find((f2) => f2.id === filter.field);
13305 if (currentField) {
13306 return {
13307 ...currentField,
13308 // Deactivate validation for filters.
13309 isValid: {},
13310 // Filter controls are always enabled.
13311 isDisabled: () => false,
13312 // Filter controls are always visible.
13313 isVisible: () => true,
13314 // Configure getValue/setValue as if Item was a plain object.
13315 getValue: ({ item }) => item[currentField.id],
13316 setValue: ({ value }) => ({
13317 [currentField.id]: value
13318 })
13319 };
13320 }
13321 return currentField;
13322 }, [fields2, filter.field]);
13323 const data = (0, import_element44.useMemo)(() => {
13324 return (view.filters ?? []).reduce(
13325 (acc, activeFilter) => {
13326 acc[activeFilter.field] = activeFilter.value;
13327 return acc;
13328 },
13329 {}
13330 );
13331 }, [view.filters]);
13332 const handleChange = (0, import_compose8.useEvent)((updatedData) => {
13333 if (!field || !currentFilter) {
13334 return;
13335 }
13336 const nextValue = field.getValue({ item: updatedData });
13337 if ((0, import_es6.default)(nextValue, currentValue)) {
13338 return;
13339 }
13340 onChangeView({
13341 ...view,
13342 filters: (view.filters ?? []).map(
13343 (_filter) => _filter.field === filter.field ? {
13344 ..._filter,
13345 operator: currentFilter.operator || filter.operators[0],
13346 // Consider empty strings as undefined:
13347 //
13348 // - undefined as value means the filter is unset: the filter widget displays no value and the search returns all records
13349 // - empty string as value means "search empty string": returns only the records that have an empty string as value
13350 //
13351 // In practice, this means the filter will not be able to find an empty string as the value.
13352 value: nextValue === "" ? void 0 : nextValue
13353 } : _filter
13354 )
13355 });
13356 });
13357 if (!field || !field.Edit || !currentFilter) {
13358 return null;
13359 }
13360 return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
13361 import_components21.Flex,
13362 {
13363 className: "dataviews-filters__user-input-widget",
13364 gap: 2.5,
13365 direction: "column",
13366 children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
13367 field.Edit,
13368 {
13369 hideLabelFromVision: true,
13370 data,
13371 field,
13372 operator: currentFilter.operator,
13373 onChange: handleChange
13374 }
13375 )
13376 }
13377 );
13378 }
13379
13380 // node_modules/date-fns/constants.js
13381 var daysInYear = 365.2425;
13382 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3;
13383 var minTime = -maxTime;
13384 var millisecondsInWeek = 6048e5;
13385 var millisecondsInDay = 864e5;
13386 var secondsInHour = 3600;
13387 var secondsInDay = secondsInHour * 24;
13388 var secondsInWeek = secondsInDay * 7;
13389 var secondsInYear = secondsInDay * daysInYear;
13390 var secondsInMonth = secondsInYear / 12;
13391 var secondsInQuarter = secondsInMonth * 3;
13392 var constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
13393
13394 // node_modules/date-fns/constructFrom.js
13395 function constructFrom(date, value) {
13396 if (typeof date === "function") return date(value);
13397 if (date && typeof date === "object" && constructFromSymbol in date)
13398 return date[constructFromSymbol](value);
13399 if (date instanceof Date) return new date.constructor(value);
13400 return new Date(value);
13401 }
13402
13403 // node_modules/date-fns/toDate.js
13404 function toDate(argument, context) {
13405 return constructFrom(context || argument, argument);
13406 }
13407
13408 // node_modules/date-fns/addDays.js
13409 function addDays(date, amount, options) {
13410 const _date = toDate(date, options?.in);
13411 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
13412 if (!amount) return _date;
13413 _date.setDate(_date.getDate() + amount);
13414 return _date;
13415 }
13416
13417 // node_modules/date-fns/addMonths.js
13418 function addMonths(date, amount, options) {
13419 const _date = toDate(date, options?.in);
13420 if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
13421 if (!amount) {
13422 return _date;
13423 }
13424 const dayOfMonth = _date.getDate();
13425 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
13426 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
13427 const daysInMonth = endOfDesiredMonth.getDate();
13428 if (dayOfMonth >= daysInMonth) {
13429 return endOfDesiredMonth;
13430 } else {
13431 _date.setFullYear(
13432 endOfDesiredMonth.getFullYear(),
13433 endOfDesiredMonth.getMonth(),
13434 dayOfMonth
13435 );
13436 return _date;
13437 }
13438 }
13439
13440 // node_modules/date-fns/_lib/defaultOptions.js
13441 var defaultOptions = {};
13442 function getDefaultOptions() {
13443 return defaultOptions;
13444 }
13445
13446 // node_modules/date-fns/startOfWeek.js
13447 function startOfWeek(date, options) {
13448 const defaultOptions2 = getDefaultOptions();
13449 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
13450 const _date = toDate(date, options?.in);
13451 const day = _date.getDay();
13452 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
13453 _date.setDate(_date.getDate() - diff);
13454 _date.setHours(0, 0, 0, 0);
13455 return _date;
13456 }
13457
13458 // node_modules/date-fns/startOfISOWeek.js
13459 function startOfISOWeek(date, options) {
13460 return startOfWeek(date, { ...options, weekStartsOn: 1 });
13461 }
13462
13463 // node_modules/date-fns/getISOWeekYear.js
13464 function getISOWeekYear(date, options) {
13465 const _date = toDate(date, options?.in);
13466 const year = _date.getFullYear();
13467 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
13468 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
13469 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
13470 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
13471 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
13472 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
13473 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
13474 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
13475 if (_date.getTime() >= startOfNextYear.getTime()) {
13476 return year + 1;
13477 } else if (_date.getTime() >= startOfThisYear.getTime()) {
13478 return year;
13479 } else {
13480 return year - 1;
13481 }
13482 }
13483
13484 // node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
13485 function getTimezoneOffsetInMilliseconds(date) {
13486 const _date = toDate(date);
13487 const utcDate = new Date(
13488 Date.UTC(
13489 _date.getFullYear(),
13490 _date.getMonth(),
13491 _date.getDate(),
13492 _date.getHours(),
13493 _date.getMinutes(),
13494 _date.getSeconds(),
13495 _date.getMilliseconds()
13496 )
13497 );
13498 utcDate.setUTCFullYear(_date.getFullYear());
13499 return +date - +utcDate;
13500 }
13501
13502 // node_modules/date-fns/_lib/normalizeDates.js
13503 function normalizeDates(context, ...dates) {
13504 const normalize = constructFrom.bind(
13505 null,
13506 context || dates.find((date) => typeof date === "object")
13507 );
13508 return dates.map(normalize);
13509 }
13510
13511 // node_modules/date-fns/startOfDay.js
13512 function startOfDay(date, options) {
13513 const _date = toDate(date, options?.in);
13514 _date.setHours(0, 0, 0, 0);
13515 return _date;
13516 }
13517
13518 // node_modules/date-fns/differenceInCalendarDays.js
13519 function differenceInCalendarDays(laterDate, earlierDate, options) {
13520 const [laterDate_, earlierDate_] = normalizeDates(
13521 options?.in,
13522 laterDate,
13523 earlierDate
13524 );
13525 const laterStartOfDay = startOfDay(laterDate_);
13526 const earlierStartOfDay = startOfDay(earlierDate_);
13527 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
13528 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
13529 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
13530 }
13531
13532 // node_modules/date-fns/startOfISOWeekYear.js
13533 function startOfISOWeekYear(date, options) {
13534 const year = getISOWeekYear(date, options);
13535 const fourthOfJanuary = constructFrom(options?.in || date, 0);
13536 fourthOfJanuary.setFullYear(year, 0, 4);
13537 fourthOfJanuary.setHours(0, 0, 0, 0);
13538 return startOfISOWeek(fourthOfJanuary);
13539 }
13540
13541 // node_modules/date-fns/addWeeks.js
13542 function addWeeks(date, amount, options) {
13543 return addDays(date, amount * 7, options);
13544 }
13545
13546 // node_modules/date-fns/addYears.js
13547 function addYears(date, amount, options) {
13548 return addMonths(date, amount * 12, options);
13549 }
13550
13551 // node_modules/date-fns/isDate.js
13552 function isDate(value) {
13553 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
13554 }
13555
13556 // node_modules/date-fns/isValid.js
13557 function isValid(date) {
13558 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
13559 }
13560
13561 // node_modules/date-fns/startOfMonth.js
13562 function startOfMonth(date, options) {
13563 const _date = toDate(date, options?.in);
13564 _date.setDate(1);
13565 _date.setHours(0, 0, 0, 0);
13566 return _date;
13567 }
13568
13569 // node_modules/date-fns/startOfYear.js
13570 function startOfYear(date, options) {
13571 const date_ = toDate(date, options?.in);
13572 date_.setFullYear(date_.getFullYear(), 0, 1);
13573 date_.setHours(0, 0, 0, 0);
13574 return date_;
13575 }
13576
13577 // node_modules/date-fns/locale/en-US/_lib/formatDistance.js
13578 var formatDistanceLocale = {
13579 lessThanXSeconds: {
13580 one: "less than a second",
13581 other: "less than {{count}} seconds"
13582 },
13583 xSeconds: {
13584 one: "1 second",
13585 other: "{{count}} seconds"
13586 },
13587 halfAMinute: "half a minute",
13588 lessThanXMinutes: {
13589 one: "less than a minute",
13590 other: "less than {{count}} minutes"
13591 },
13592 xMinutes: {
13593 one: "1 minute",
13594 other: "{{count}} minutes"
13595 },
13596 aboutXHours: {
13597 one: "about 1 hour",
13598 other: "about {{count}} hours"
13599 },
13600 xHours: {
13601 one: "1 hour",
13602 other: "{{count}} hours"
13603 },
13604 xDays: {
13605 one: "1 day",
13606 other: "{{count}} days"
13607 },
13608 aboutXWeeks: {
13609 one: "about 1 week",
13610 other: "about {{count}} weeks"
13611 },
13612 xWeeks: {
13613 one: "1 week",
13614 other: "{{count}} weeks"
13615 },
13616 aboutXMonths: {
13617 one: "about 1 month",
13618 other: "about {{count}} months"
13619 },
13620 xMonths: {
13621 one: "1 month",
13622 other: "{{count}} months"
13623 },
13624 aboutXYears: {
13625 one: "about 1 year",
13626 other: "about {{count}} years"
13627 },
13628 xYears: {
13629 one: "1 year",
13630 other: "{{count}} years"
13631 },
13632 overXYears: {
13633 one: "over 1 year",
13634 other: "over {{count}} years"
13635 },
13636 almostXYears: {
13637 one: "almost 1 year",
13638 other: "almost {{count}} years"
13639 }
13640 };
13641 var formatDistance = (token, count, options) => {
13642 let result;
13643 const tokenValue = formatDistanceLocale[token];
13644 if (typeof tokenValue === "string") {
13645 result = tokenValue;
13646 } else if (count === 1) {
13647 result = tokenValue.one;
13648 } else {
13649 result = tokenValue.other.replace("{{count}}", count.toString());
13650 }
13651 if (options?.addSuffix) {
13652 if (options.comparison && options.comparison > 0) {
13653 return "in " + result;
13654 } else {
13655 return result + " ago";
13656 }
13657 }
13658 return result;
13659 };
13660
13661 // node_modules/date-fns/locale/_lib/buildFormatLongFn.js
13662 function buildFormatLongFn(args) {
13663 return (options = {}) => {
13664 const width = options.width ? String(options.width) : args.defaultWidth;
13665 const format6 = args.formats[width] || args.formats[args.defaultWidth];
13666 return format6;
13667 };
13668 }
13669
13670 // node_modules/date-fns/locale/en-US/_lib/formatLong.js
13671 var dateFormats = {
13672 full: "EEEE, MMMM do, y",
13673 long: "MMMM do, y",
13674 medium: "MMM d, y",
13675 short: "MM/dd/yyyy"
13676 };
13677 var timeFormats = {
13678 full: "h:mm:ss a zzzz",
13679 long: "h:mm:ss a z",
13680 medium: "h:mm:ss a",
13681 short: "h:mm a"
13682 };
13683 var dateTimeFormats = {
13684 full: "{{date}} 'at' {{time}}",
13685 long: "{{date}} 'at' {{time}}",
13686 medium: "{{date}}, {{time}}",
13687 short: "{{date}}, {{time}}"
13688 };
13689 var formatLong = {
13690 date: buildFormatLongFn({
13691 formats: dateFormats,
13692 defaultWidth: "full"
13693 }),
13694 time: buildFormatLongFn({
13695 formats: timeFormats,
13696 defaultWidth: "full"
13697 }),
13698 dateTime: buildFormatLongFn({
13699 formats: dateTimeFormats,
13700 defaultWidth: "full"
13701 })
13702 };
13703
13704 // node_modules/date-fns/locale/en-US/_lib/formatRelative.js
13705 var formatRelativeLocale = {
13706 lastWeek: "'last' eeee 'at' p",
13707 yesterday: "'yesterday at' p",
13708 today: "'today at' p",
13709 tomorrow: "'tomorrow at' p",
13710 nextWeek: "eeee 'at' p",
13711 other: "P"
13712 };
13713 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
13714
13715 // node_modules/date-fns/locale/_lib/buildLocalizeFn.js
13716 function buildLocalizeFn(args) {
13717 return (value, options) => {
13718 const context = options?.context ? String(options.context) : "standalone";
13719 let valuesArray;
13720 if (context === "formatting" && args.formattingValues) {
13721 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
13722 const width = options?.width ? String(options.width) : defaultWidth;
13723 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
13724 } else {
13725 const defaultWidth = args.defaultWidth;
13726 const width = options?.width ? String(options.width) : args.defaultWidth;
13727 valuesArray = args.values[width] || args.values[defaultWidth];
13728 }
13729 const index = args.argumentCallback ? args.argumentCallback(value) : value;
13730 return valuesArray[index];
13731 };
13732 }
13733
13734 // node_modules/date-fns/locale/en-US/_lib/localize.js
13735 var eraValues = {
13736 narrow: ["B", "A"],
13737 abbreviated: ["BC", "AD"],
13738 wide: ["Before Christ", "Anno Domini"]
13739 };
13740 var quarterValues = {
13741 narrow: ["1", "2", "3", "4"],
13742 abbreviated: ["Q1", "Q2", "Q3", "Q4"],
13743 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
13744 };
13745 var monthValues = {
13746 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
13747 abbreviated: [
13748 "Jan",
13749 "Feb",
13750 "Mar",
13751 "Apr",
13752 "May",
13753 "Jun",
13754 "Jul",
13755 "Aug",
13756 "Sep",
13757 "Oct",
13758 "Nov",
13759 "Dec"
13760 ],
13761 wide: [
13762 "January",
13763 "February",
13764 "March",
13765 "April",
13766 "May",
13767 "June",
13768 "July",
13769 "August",
13770 "September",
13771 "October",
13772 "November",
13773 "December"
13774 ]
13775 };
13776 var dayValues = {
13777 narrow: ["S", "M", "T", "W", "T", "F", "S"],
13778 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
13779 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
13780 wide: [
13781 "Sunday",
13782 "Monday",
13783 "Tuesday",
13784 "Wednesday",
13785 "Thursday",
13786 "Friday",
13787 "Saturday"
13788 ]
13789 };
13790 var dayPeriodValues = {
13791 narrow: {
13792 am: "a",
13793 pm: "p",
13794 midnight: "mi",
13795 noon: "n",
13796 morning: "morning",
13797 afternoon: "afternoon",
13798 evening: "evening",
13799 night: "night"
13800 },
13801 abbreviated: {
13802 am: "AM",
13803 pm: "PM",
13804 midnight: "midnight",
13805 noon: "noon",
13806 morning: "morning",
13807 afternoon: "afternoon",
13808 evening: "evening",
13809 night: "night"
13810 },
13811 wide: {
13812 am: "a.m.",
13813 pm: "p.m.",
13814 midnight: "midnight",
13815 noon: "noon",
13816 morning: "morning",
13817 afternoon: "afternoon",
13818 evening: "evening",
13819 night: "night"
13820 }
13821 };
13822 var formattingDayPeriodValues = {
13823 narrow: {
13824 am: "a",
13825 pm: "p",
13826 midnight: "mi",
13827 noon: "n",
13828 morning: "in the morning",
13829 afternoon: "in the afternoon",
13830 evening: "in the evening",
13831 night: "at night"
13832 },
13833 abbreviated: {
13834 am: "AM",
13835 pm: "PM",
13836 midnight: "midnight",
13837 noon: "noon",
13838 morning: "in the morning",
13839 afternoon: "in the afternoon",
13840 evening: "in the evening",
13841 night: "at night"
13842 },
13843 wide: {
13844 am: "a.m.",
13845 pm: "p.m.",
13846 midnight: "midnight",
13847 noon: "noon",
13848 morning: "in the morning",
13849 afternoon: "in the afternoon",
13850 evening: "in the evening",
13851 night: "at night"
13852 }
13853 };
13854 var ordinalNumber = (dirtyNumber, _options) => {
13855 const number = Number(dirtyNumber);
13856 const rem100 = number % 100;
13857 if (rem100 > 20 || rem100 < 10) {
13858 switch (rem100 % 10) {
13859 case 1:
13860 return number + "st";
13861 case 2:
13862 return number + "nd";
13863 case 3:
13864 return number + "rd";
13865 }
13866 }
13867 return number + "th";
13868 };
13869 var localize = {
13870 ordinalNumber,
13871 era: buildLocalizeFn({
13872 values: eraValues,
13873 defaultWidth: "wide"
13874 }),
13875 quarter: buildLocalizeFn({
13876 values: quarterValues,
13877 defaultWidth: "wide",
13878 argumentCallback: (quarter) => quarter - 1
13879 }),
13880 month: buildLocalizeFn({
13881 values: monthValues,
13882 defaultWidth: "wide"
13883 }),
13884 day: buildLocalizeFn({
13885 values: dayValues,
13886 defaultWidth: "wide"
13887 }),
13888 dayPeriod: buildLocalizeFn({
13889 values: dayPeriodValues,
13890 defaultWidth: "wide",
13891 formattingValues: formattingDayPeriodValues,
13892 defaultFormattingWidth: "wide"
13893 })
13894 };
13895
13896 // node_modules/date-fns/locale/_lib/buildMatchFn.js
13897 function buildMatchFn(args) {
13898 return (string, options = {}) => {
13899 const width = options.width;
13900 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
13901 const matchResult = string.match(matchPattern);
13902 if (!matchResult) {
13903 return null;
13904 }
13905 const matchedString = matchResult[0];
13906 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
13907 const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
13908 // [TODO] -- I challenge you to fix the type
13909 findKey(parsePatterns, (pattern) => pattern.test(matchedString))
13910 );
13911 let value;
13912 value = args.valueCallback ? args.valueCallback(key) : key;
13913 value = options.valueCallback ? (
13914 // [TODO] -- I challenge you to fix the type
13915 options.valueCallback(value)
13916 ) : value;
13917 const rest = string.slice(matchedString.length);
13918 return { value, rest };
13919 };
13920 }
13921 function findKey(object, predicate) {
13922 for (const key in object) {
13923 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
13924 return key;
13925 }
13926 }
13927 return void 0;
13928 }
13929 function findIndex(array, predicate) {
13930 for (let key = 0; key < array.length; key++) {
13931 if (predicate(array[key])) {
13932 return key;
13933 }
13934 }
13935 return void 0;
13936 }
13937
13938 // node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
13939 function buildMatchPatternFn(args) {
13940 return (string, options = {}) => {
13941 const matchResult = string.match(args.matchPattern);
13942 if (!matchResult) return null;
13943 const matchedString = matchResult[0];
13944 const parseResult = string.match(args.parsePattern);
13945 if (!parseResult) return null;
13946 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
13947 value = options.valueCallback ? options.valueCallback(value) : value;
13948 const rest = string.slice(matchedString.length);
13949 return { value, rest };
13950 };
13951 }
13952
13953 // node_modules/date-fns/locale/en-US/_lib/match.js
13954 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
13955 var parseOrdinalNumberPattern = /\d+/i;
13956 var matchEraPatterns = {
13957 narrow: /^(b|a)/i,
13958 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
13959 wide: /^(before christ|before common era|anno domini|common era)/i
13960 };
13961 var parseEraPatterns = {
13962 any: [/^b/i, /^(a|c)/i]
13963 };
13964 var matchQuarterPatterns = {
13965 narrow: /^[1234]/i,
13966 abbreviated: /^q[1234]/i,
13967 wide: /^[1234](th|st|nd|rd)? quarter/i
13968 };
13969 var parseQuarterPatterns = {
13970 any: [/1/i, /2/i, /3/i, /4/i]
13971 };
13972 var matchMonthPatterns = {
13973 narrow: /^[jfmasond]/i,
13974 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
13975 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
13976 };
13977 var parseMonthPatterns = {
13978 narrow: [
13979 /^j/i,
13980 /^f/i,
13981 /^m/i,
13982 /^a/i,
13983 /^m/i,
13984 /^j/i,
13985 /^j/i,
13986 /^a/i,
13987 /^s/i,
13988 /^o/i,
13989 /^n/i,
13990 /^d/i
13991 ],
13992 any: [
13993 /^ja/i,
13994 /^f/i,
13995 /^mar/i,
13996 /^ap/i,
13997 /^may/i,
13998 /^jun/i,
13999 /^jul/i,
14000 /^au/i,
14001 /^s/i,
14002 /^o/i,
14003 /^n/i,
14004 /^d/i
14005 ]
14006 };
14007 var matchDayPatterns = {
14008 narrow: /^[smtwf]/i,
14009 short: /^(su|mo|tu|we|th|fr|sa)/i,
14010 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
14011 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
14012 };
14013 var parseDayPatterns = {
14014 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
14015 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
14016 };
14017 var matchDayPeriodPatterns = {
14018 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
14019 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
14020 };
14021 var parseDayPeriodPatterns = {
14022 any: {
14023 am: /^a/i,
14024 pm: /^p/i,
14025 midnight: /^mi/i,
14026 noon: /^no/i,
14027 morning: /morning/i,
14028 afternoon: /afternoon/i,
14029 evening: /evening/i,
14030 night: /night/i
14031 }
14032 };
14033 var match = {
14034 ordinalNumber: buildMatchPatternFn({
14035 matchPattern: matchOrdinalNumberPattern,
14036 parsePattern: parseOrdinalNumberPattern,
14037 valueCallback: (value) => parseInt(value, 10)
14038 }),
14039 era: buildMatchFn({
14040 matchPatterns: matchEraPatterns,
14041 defaultMatchWidth: "wide",
14042 parsePatterns: parseEraPatterns,
14043 defaultParseWidth: "any"
14044 }),
14045 quarter: buildMatchFn({
14046 matchPatterns: matchQuarterPatterns,
14047 defaultMatchWidth: "wide",
14048 parsePatterns: parseQuarterPatterns,
14049 defaultParseWidth: "any",
14050 valueCallback: (index) => index + 1
14051 }),
14052 month: buildMatchFn({
14053 matchPatterns: matchMonthPatterns,
14054 defaultMatchWidth: "wide",
14055 parsePatterns: parseMonthPatterns,
14056 defaultParseWidth: "any"
14057 }),
14058 day: buildMatchFn({
14059 matchPatterns: matchDayPatterns,
14060 defaultMatchWidth: "wide",
14061 parsePatterns: parseDayPatterns,
14062 defaultParseWidth: "any"
14063 }),
14064 dayPeriod: buildMatchFn({
14065 matchPatterns: matchDayPeriodPatterns,
14066 defaultMatchWidth: "any",
14067 parsePatterns: parseDayPeriodPatterns,
14068 defaultParseWidth: "any"
14069 })
14070 };
14071
14072 // node_modules/date-fns/locale/en-US.js
14073 var enUS = {
14074 code: "en-US",
14075 formatDistance,
14076 formatLong,
14077 formatRelative,
14078 localize,
14079 match,
14080 options: {
14081 weekStartsOn: 0,
14082 firstWeekContainsDate: 1
14083 }
14084 };
14085
14086 // node_modules/date-fns/getDayOfYear.js
14087 function getDayOfYear(date, options) {
14088 const _date = toDate(date, options?.in);
14089 const diff = differenceInCalendarDays(_date, startOfYear(_date));
14090 const dayOfYear = diff + 1;
14091 return dayOfYear;
14092 }
14093
14094 // node_modules/date-fns/getISOWeek.js
14095 function getISOWeek(date, options) {
14096 const _date = toDate(date, options?.in);
14097 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
14098 return Math.round(diff / millisecondsInWeek) + 1;
14099 }
14100
14101 // node_modules/date-fns/getWeekYear.js
14102 function getWeekYear(date, options) {
14103 const _date = toDate(date, options?.in);
14104 const year = _date.getFullYear();
14105 const defaultOptions2 = getDefaultOptions();
14106 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
14107 const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
14108 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
14109 firstWeekOfNextYear.setHours(0, 0, 0, 0);
14110 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
14111 const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
14112 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
14113 firstWeekOfThisYear.setHours(0, 0, 0, 0);
14114 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
14115 if (+_date >= +startOfNextYear) {
14116 return year + 1;
14117 } else if (+_date >= +startOfThisYear) {
14118 return year;
14119 } else {
14120 return year - 1;
14121 }
14122 }
14123
14124 // node_modules/date-fns/startOfWeekYear.js
14125 function startOfWeekYear(date, options) {
14126 const defaultOptions2 = getDefaultOptions();
14127 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
14128 const year = getWeekYear(date, options);
14129 const firstWeek = constructFrom(options?.in || date, 0);
14130 firstWeek.setFullYear(year, 0, firstWeekContainsDate);
14131 firstWeek.setHours(0, 0, 0, 0);
14132 const _date = startOfWeek(firstWeek, options);
14133 return _date;
14134 }
14135
14136 // node_modules/date-fns/getWeek.js
14137 function getWeek(date, options) {
14138 const _date = toDate(date, options?.in);
14139 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
14140 return Math.round(diff / millisecondsInWeek) + 1;
14141 }
14142
14143 // node_modules/date-fns/_lib/addLeadingZeros.js
14144 function addLeadingZeros(number, targetLength) {
14145 const sign = number < 0 ? "-" : "";
14146 const output = Math.abs(number).toString().padStart(targetLength, "0");
14147 return sign + output;
14148 }
14149
14150 // node_modules/date-fns/_lib/format/lightFormatters.js
14151 var lightFormatters = {
14152 // Year
14153 y(date, token) {
14154 const signedYear = date.getFullYear();
14155 const year = signedYear > 0 ? signedYear : 1 - signedYear;
14156 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
14157 },
14158 // Month
14159 M(date, token) {
14160 const month = date.getMonth();
14161 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
14162 },
14163 // Day of the month
14164 d(date, token) {
14165 return addLeadingZeros(date.getDate(), token.length);
14166 },
14167 // AM or PM
14168 a(date, token) {
14169 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
14170 switch (token) {
14171 case "a":
14172 case "aa":
14173 return dayPeriodEnumValue.toUpperCase();
14174 case "aaa":
14175 return dayPeriodEnumValue;
14176 case "aaaaa":
14177 return dayPeriodEnumValue[0];
14178 case "aaaa":
14179 default:
14180 return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
14181 }
14182 },
14183 // Hour [1-12]
14184 h(date, token) {
14185 return addLeadingZeros(date.getHours() % 12 || 12, token.length);
14186 },
14187 // Hour [0-23]
14188 H(date, token) {
14189 return addLeadingZeros(date.getHours(), token.length);
14190 },
14191 // Minute
14192 m(date, token) {
14193 return addLeadingZeros(date.getMinutes(), token.length);
14194 },
14195 // Second
14196 s(date, token) {
14197 return addLeadingZeros(date.getSeconds(), token.length);
14198 },
14199 // Fraction of second
14200 S(date, token) {
14201 const numberOfDigits = token.length;
14202 const milliseconds = date.getMilliseconds();
14203 const fractionalSeconds = Math.trunc(
14204 milliseconds * Math.pow(10, numberOfDigits - 3)
14205 );
14206 return addLeadingZeros(fractionalSeconds, token.length);
14207 }
14208 };
14209
14210 // node_modules/date-fns/_lib/format/formatters.js
14211 var dayPeriodEnum = {
14212 am: "am",
14213 pm: "pm",
14214 midnight: "midnight",
14215 noon: "noon",
14216 morning: "morning",
14217 afternoon: "afternoon",
14218 evening: "evening",
14219 night: "night"
14220 };
14221 var formatters = {
14222 // Era
14223 G: function(date, token, localize2) {
14224 const era = date.getFullYear() > 0 ? 1 : 0;
14225 switch (token) {
14226 // AD, BC
14227 case "G":
14228 case "GG":
14229 case "GGG":
14230 return localize2.era(era, { width: "abbreviated" });
14231 // A, B
14232 case "GGGGG":
14233 return localize2.era(era, { width: "narrow" });
14234 // Anno Domini, Before Christ
14235 case "GGGG":
14236 default:
14237 return localize2.era(era, { width: "wide" });
14238 }
14239 },
14240 // Year
14241 y: function(date, token, localize2) {
14242 if (token === "yo") {
14243 const signedYear = date.getFullYear();
14244 const year = signedYear > 0 ? signedYear : 1 - signedYear;
14245 return localize2.ordinalNumber(year, { unit: "year" });
14246 }
14247 return lightFormatters.y(date, token);
14248 },
14249 // Local week-numbering year
14250 Y: function(date, token, localize2, options) {
14251 const signedWeekYear = getWeekYear(date, options);
14252 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
14253 if (token === "YY") {
14254 const twoDigitYear = weekYear % 100;
14255 return addLeadingZeros(twoDigitYear, 2);
14256 }
14257 if (token === "Yo") {
14258 return localize2.ordinalNumber(weekYear, { unit: "year" });
14259 }
14260 return addLeadingZeros(weekYear, token.length);
14261 },
14262 // ISO week-numbering year
14263 R: function(date, token) {
14264 const isoWeekYear = getISOWeekYear(date);
14265 return addLeadingZeros(isoWeekYear, token.length);
14266 },
14267 // Extended year. This is a single number designating the year of this calendar system.
14268 // The main difference between `y` and `u` localizers are B.C. years:
14269 // | Year | `y` | `u` |
14270 // |------|-----|-----|
14271 // | AC 1 | 1 | 1 |
14272 // | BC 1 | 1 | 0 |
14273 // | BC 2 | 2 | -1 |
14274 // Also `yy` always returns the last two digits of a year,
14275 // while `uu` pads single digit years to 2 characters and returns other years unchanged.
14276 u: function(date, token) {
14277 const year = date.getFullYear();
14278 return addLeadingZeros(year, token.length);
14279 },
14280 // Quarter
14281 Q: function(date, token, localize2) {
14282 const quarter = Math.ceil((date.getMonth() + 1) / 3);
14283 switch (token) {
14284 // 1, 2, 3, 4
14285 case "Q":
14286 return String(quarter);
14287 // 01, 02, 03, 04
14288 case "QQ":
14289 return addLeadingZeros(quarter, 2);
14290 // 1st, 2nd, 3rd, 4th
14291 case "Qo":
14292 return localize2.ordinalNumber(quarter, { unit: "quarter" });
14293 // Q1, Q2, Q3, Q4
14294 case "QQQ":
14295 return localize2.quarter(quarter, {
14296 width: "abbreviated",
14297 context: "formatting"
14298 });
14299 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
14300 case "QQQQQ":
14301 return localize2.quarter(quarter, {
14302 width: "narrow",
14303 context: "formatting"
14304 });
14305 // 1st quarter, 2nd quarter, ...
14306 case "QQQQ":
14307 default:
14308 return localize2.quarter(quarter, {
14309 width: "wide",
14310 context: "formatting"
14311 });
14312 }
14313 },
14314 // Stand-alone quarter
14315 q: function(date, token, localize2) {
14316 const quarter = Math.ceil((date.getMonth() + 1) / 3);
14317 switch (token) {
14318 // 1, 2, 3, 4
14319 case "q":
14320 return String(quarter);
14321 // 01, 02, 03, 04
14322 case "qq":
14323 return addLeadingZeros(quarter, 2);
14324 // 1st, 2nd, 3rd, 4th
14325 case "qo":
14326 return localize2.ordinalNumber(quarter, { unit: "quarter" });
14327 // Q1, Q2, Q3, Q4
14328 case "qqq":
14329 return localize2.quarter(quarter, {
14330 width: "abbreviated",
14331 context: "standalone"
14332 });
14333 // 1, 2, 3, 4 (narrow quarter; could be not numerical)
14334 case "qqqqq":
14335 return localize2.quarter(quarter, {
14336 width: "narrow",
14337 context: "standalone"
14338 });
14339 // 1st quarter, 2nd quarter, ...
14340 case "qqqq":
14341 default:
14342 return localize2.quarter(quarter, {
14343 width: "wide",
14344 context: "standalone"
14345 });
14346 }
14347 },
14348 // Month
14349 M: function(date, token, localize2) {
14350 const month = date.getMonth();
14351 switch (token) {
14352 case "M":
14353 case "MM":
14354 return lightFormatters.M(date, token);
14355 // 1st, 2nd, ..., 12th
14356 case "Mo":
14357 return localize2.ordinalNumber(month + 1, { unit: "month" });
14358 // Jan, Feb, ..., Dec
14359 case "MMM":
14360 return localize2.month(month, {
14361 width: "abbreviated",
14362 context: "formatting"
14363 });
14364 // J, F, ..., D
14365 case "MMMMM":
14366 return localize2.month(month, {
14367 width: "narrow",
14368 context: "formatting"
14369 });
14370 // January, February, ..., December
14371 case "MMMM":
14372 default:
14373 return localize2.month(month, { width: "wide", context: "formatting" });
14374 }
14375 },
14376 // Stand-alone month
14377 L: function(date, token, localize2) {
14378 const month = date.getMonth();
14379 switch (token) {
14380 // 1, 2, ..., 12
14381 case "L":
14382 return String(month + 1);
14383 // 01, 02, ..., 12
14384 case "LL":
14385 return addLeadingZeros(month + 1, 2);
14386 // 1st, 2nd, ..., 12th
14387 case "Lo":
14388 return localize2.ordinalNumber(month + 1, { unit: "month" });
14389 // Jan, Feb, ..., Dec
14390 case "LLL":
14391 return localize2.month(month, {
14392 width: "abbreviated",
14393 context: "standalone"
14394 });
14395 // J, F, ..., D
14396 case "LLLLL":
14397 return localize2.month(month, {
14398 width: "narrow",
14399 context: "standalone"
14400 });
14401 // January, February, ..., December
14402 case "LLLL":
14403 default:
14404 return localize2.month(month, { width: "wide", context: "standalone" });
14405 }
14406 },
14407 // Local week of year
14408 w: function(date, token, localize2, options) {
14409 const week = getWeek(date, options);
14410 if (token === "wo") {
14411 return localize2.ordinalNumber(week, { unit: "week" });
14412 }
14413 return addLeadingZeros(week, token.length);
14414 },
14415 // ISO week of year
14416 I: function(date, token, localize2) {
14417 const isoWeek = getISOWeek(date);
14418 if (token === "Io") {
14419 return localize2.ordinalNumber(isoWeek, { unit: "week" });
14420 }
14421 return addLeadingZeros(isoWeek, token.length);
14422 },
14423 // Day of the month
14424 d: function(date, token, localize2) {
14425 if (token === "do") {
14426 return localize2.ordinalNumber(date.getDate(), { unit: "date" });
14427 }
14428 return lightFormatters.d(date, token);
14429 },
14430 // Day of year
14431 D: function(date, token, localize2) {
14432 const dayOfYear = getDayOfYear(date);
14433 if (token === "Do") {
14434 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
14435 }
14436 return addLeadingZeros(dayOfYear, token.length);
14437 },
14438 // Day of week
14439 E: function(date, token, localize2) {
14440 const dayOfWeek = date.getDay();
14441 switch (token) {
14442 // Tue
14443 case "E":
14444 case "EE":
14445 case "EEE":
14446 return localize2.day(dayOfWeek, {
14447 width: "abbreviated",
14448 context: "formatting"
14449 });
14450 // T
14451 case "EEEEE":
14452 return localize2.day(dayOfWeek, {
14453 width: "narrow",
14454 context: "formatting"
14455 });
14456 // Tu
14457 case "EEEEEE":
14458 return localize2.day(dayOfWeek, {
14459 width: "short",
14460 context: "formatting"
14461 });
14462 // Tuesday
14463 case "EEEE":
14464 default:
14465 return localize2.day(dayOfWeek, {
14466 width: "wide",
14467 context: "formatting"
14468 });
14469 }
14470 },
14471 // Local day of week
14472 e: function(date, token, localize2, options) {
14473 const dayOfWeek = date.getDay();
14474 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
14475 switch (token) {
14476 // Numerical value (Nth day of week with current locale or weekStartsOn)
14477 case "e":
14478 return String(localDayOfWeek);
14479 // Padded numerical value
14480 case "ee":
14481 return addLeadingZeros(localDayOfWeek, 2);
14482 // 1st, 2nd, ..., 7th
14483 case "eo":
14484 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
14485 case "eee":
14486 return localize2.day(dayOfWeek, {
14487 width: "abbreviated",
14488 context: "formatting"
14489 });
14490 // T
14491 case "eeeee":
14492 return localize2.day(dayOfWeek, {
14493 width: "narrow",
14494 context: "formatting"
14495 });
14496 // Tu
14497 case "eeeeee":
14498 return localize2.day(dayOfWeek, {
14499 width: "short",
14500 context: "formatting"
14501 });
14502 // Tuesday
14503 case "eeee":
14504 default:
14505 return localize2.day(dayOfWeek, {
14506 width: "wide",
14507 context: "formatting"
14508 });
14509 }
14510 },
14511 // Stand-alone local day of week
14512 c: function(date, token, localize2, options) {
14513 const dayOfWeek = date.getDay();
14514 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
14515 switch (token) {
14516 // Numerical value (same as in `e`)
14517 case "c":
14518 return String(localDayOfWeek);
14519 // Padded numerical value
14520 case "cc":
14521 return addLeadingZeros(localDayOfWeek, token.length);
14522 // 1st, 2nd, ..., 7th
14523 case "co":
14524 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
14525 case "ccc":
14526 return localize2.day(dayOfWeek, {
14527 width: "abbreviated",
14528 context: "standalone"
14529 });
14530 // T
14531 case "ccccc":
14532 return localize2.day(dayOfWeek, {
14533 width: "narrow",
14534 context: "standalone"
14535 });
14536 // Tu
14537 case "cccccc":
14538 return localize2.day(dayOfWeek, {
14539 width: "short",
14540 context: "standalone"
14541 });
14542 // Tuesday
14543 case "cccc":
14544 default:
14545 return localize2.day(dayOfWeek, {
14546 width: "wide",
14547 context: "standalone"
14548 });
14549 }
14550 },
14551 // ISO day of week
14552 i: function(date, token, localize2) {
14553 const dayOfWeek = date.getDay();
14554 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
14555 switch (token) {
14556 // 2
14557 case "i":
14558 return String(isoDayOfWeek);
14559 // 02
14560 case "ii":
14561 return addLeadingZeros(isoDayOfWeek, token.length);
14562 // 2nd
14563 case "io":
14564 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
14565 // Tue
14566 case "iii":
14567 return localize2.day(dayOfWeek, {
14568 width: "abbreviated",
14569 context: "formatting"
14570 });
14571 // T
14572 case "iiiii":
14573 return localize2.day(dayOfWeek, {
14574 width: "narrow",
14575 context: "formatting"
14576 });
14577 // Tu
14578 case "iiiiii":
14579 return localize2.day(dayOfWeek, {
14580 width: "short",
14581 context: "formatting"
14582 });
14583 // Tuesday
14584 case "iiii":
14585 default:
14586 return localize2.day(dayOfWeek, {
14587 width: "wide",
14588 context: "formatting"
14589 });
14590 }
14591 },
14592 // AM or PM
14593 a: function(date, token, localize2) {
14594 const hours = date.getHours();
14595 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
14596 switch (token) {
14597 case "a":
14598 case "aa":
14599 return localize2.dayPeriod(dayPeriodEnumValue, {
14600 width: "abbreviated",
14601 context: "formatting"
14602 });
14603 case "aaa":
14604 return localize2.dayPeriod(dayPeriodEnumValue, {
14605 width: "abbreviated",
14606 context: "formatting"
14607 }).toLowerCase();
14608 case "aaaaa":
14609 return localize2.dayPeriod(dayPeriodEnumValue, {
14610 width: "narrow",
14611 context: "formatting"
14612 });
14613 case "aaaa":
14614 default:
14615 return localize2.dayPeriod(dayPeriodEnumValue, {
14616 width: "wide",
14617 context: "formatting"
14618 });
14619 }
14620 },
14621 // AM, PM, midnight, noon
14622 b: function(date, token, localize2) {
14623 const hours = date.getHours();
14624 let dayPeriodEnumValue;
14625 if (hours === 12) {
14626 dayPeriodEnumValue = dayPeriodEnum.noon;
14627 } else if (hours === 0) {
14628 dayPeriodEnumValue = dayPeriodEnum.midnight;
14629 } else {
14630 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
14631 }
14632 switch (token) {
14633 case "b":
14634 case "bb":
14635 return localize2.dayPeriod(dayPeriodEnumValue, {
14636 width: "abbreviated",
14637 context: "formatting"
14638 });
14639 case "bbb":
14640 return localize2.dayPeriod(dayPeriodEnumValue, {
14641 width: "abbreviated",
14642 context: "formatting"
14643 }).toLowerCase();
14644 case "bbbbb":
14645 return localize2.dayPeriod(dayPeriodEnumValue, {
14646 width: "narrow",
14647 context: "formatting"
14648 });
14649 case "bbbb":
14650 default:
14651 return localize2.dayPeriod(dayPeriodEnumValue, {
14652 width: "wide",
14653 context: "formatting"
14654 });
14655 }
14656 },
14657 // in the morning, in the afternoon, in the evening, at night
14658 B: function(date, token, localize2) {
14659 const hours = date.getHours();
14660 let dayPeriodEnumValue;
14661 if (hours >= 17) {
14662 dayPeriodEnumValue = dayPeriodEnum.evening;
14663 } else if (hours >= 12) {
14664 dayPeriodEnumValue = dayPeriodEnum.afternoon;
14665 } else if (hours >= 4) {
14666 dayPeriodEnumValue = dayPeriodEnum.morning;
14667 } else {
14668 dayPeriodEnumValue = dayPeriodEnum.night;
14669 }
14670 switch (token) {
14671 case "B":
14672 case "BB":
14673 case "BBB":
14674 return localize2.dayPeriod(dayPeriodEnumValue, {
14675 width: "abbreviated",
14676 context: "formatting"
14677 });
14678 case "BBBBB":
14679 return localize2.dayPeriod(dayPeriodEnumValue, {
14680 width: "narrow",
14681 context: "formatting"
14682 });
14683 case "BBBB":
14684 default:
14685 return localize2.dayPeriod(dayPeriodEnumValue, {
14686 width: "wide",
14687 context: "formatting"
14688 });
14689 }
14690 },
14691 // Hour [1-12]
14692 h: function(date, token, localize2) {
14693 if (token === "ho") {
14694 let hours = date.getHours() % 12;
14695 if (hours === 0) hours = 12;
14696 return localize2.ordinalNumber(hours, { unit: "hour" });
14697 }
14698 return lightFormatters.h(date, token);
14699 },
14700 // Hour [0-23]
14701 H: function(date, token, localize2) {
14702 if (token === "Ho") {
14703 return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
14704 }
14705 return lightFormatters.H(date, token);
14706 },
14707 // Hour [0-11]
14708 K: function(date, token, localize2) {
14709 const hours = date.getHours() % 12;
14710 if (token === "Ko") {
14711 return localize2.ordinalNumber(hours, { unit: "hour" });
14712 }
14713 return addLeadingZeros(hours, token.length);
14714 },
14715 // Hour [1-24]
14716 k: function(date, token, localize2) {
14717 let hours = date.getHours();
14718 if (hours === 0) hours = 24;
14719 if (token === "ko") {
14720 return localize2.ordinalNumber(hours, { unit: "hour" });
14721 }
14722 return addLeadingZeros(hours, token.length);
14723 },
14724 // Minute
14725 m: function(date, token, localize2) {
14726 if (token === "mo") {
14727 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
14728 }
14729 return lightFormatters.m(date, token);
14730 },
14731 // Second
14732 s: function(date, token, localize2) {
14733 if (token === "so") {
14734 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
14735 }
14736 return lightFormatters.s(date, token);
14737 },
14738 // Fraction of second
14739 S: function(date, token) {
14740 return lightFormatters.S(date, token);
14741 },
14742 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
14743 X: function(date, token, _localize) {
14744 const timezoneOffset = date.getTimezoneOffset();
14745 if (timezoneOffset === 0) {
14746 return "Z";
14747 }
14748 switch (token) {
14749 // Hours and optional minutes
14750 case "X":
14751 return formatTimezoneWithOptionalMinutes(timezoneOffset);
14752 // Hours, minutes and optional seconds without `:` delimiter
14753 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
14754 // so this token always has the same output as `XX`
14755 case "XXXX":
14756 case "XX":
14757 return formatTimezone(timezoneOffset);
14758 // Hours, minutes and optional seconds with `:` delimiter
14759 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
14760 // so this token always has the same output as `XXX`
14761 case "XXXXX":
14762 case "XXX":
14763 // Hours and minutes with `:` delimiter
14764 default:
14765 return formatTimezone(timezoneOffset, ":");
14766 }
14767 },
14768 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
14769 x: function(date, token, _localize) {
14770 const timezoneOffset = date.getTimezoneOffset();
14771 switch (token) {
14772 // Hours and optional minutes
14773 case "x":
14774 return formatTimezoneWithOptionalMinutes(timezoneOffset);
14775 // Hours, minutes and optional seconds without `:` delimiter
14776 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
14777 // so this token always has the same output as `xx`
14778 case "xxxx":
14779 case "xx":
14780 return formatTimezone(timezoneOffset);
14781 // Hours, minutes and optional seconds with `:` delimiter
14782 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
14783 // so this token always has the same output as `xxx`
14784 case "xxxxx":
14785 case "xxx":
14786 // Hours and minutes with `:` delimiter
14787 default:
14788 return formatTimezone(timezoneOffset, ":");
14789 }
14790 },
14791 // Timezone (GMT)
14792 O: function(date, token, _localize) {
14793 const timezoneOffset = date.getTimezoneOffset();
14794 switch (token) {
14795 // Short
14796 case "O":
14797 case "OO":
14798 case "OOO":
14799 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
14800 // Long
14801 case "OOOO":
14802 default:
14803 return "GMT" + formatTimezone(timezoneOffset, ":");
14804 }
14805 },
14806 // Timezone (specific non-location)
14807 z: function(date, token, _localize) {
14808 const timezoneOffset = date.getTimezoneOffset();
14809 switch (token) {
14810 // Short
14811 case "z":
14812 case "zz":
14813 case "zzz":
14814 return "GMT" + formatTimezoneShort(timezoneOffset, ":");
14815 // Long
14816 case "zzzz":
14817 default:
14818 return "GMT" + formatTimezone(timezoneOffset, ":");
14819 }
14820 },
14821 // Seconds timestamp
14822 t: function(date, token, _localize) {
14823 const timestamp = Math.trunc(+date / 1e3);
14824 return addLeadingZeros(timestamp, token.length);
14825 },
14826 // Milliseconds timestamp
14827 T: function(date, token, _localize) {
14828 return addLeadingZeros(+date, token.length);
14829 }
14830 };
14831 function formatTimezoneShort(offset, delimiter = "") {
14832 const sign = offset > 0 ? "-" : "+";
14833 const absOffset = Math.abs(offset);
14834 const hours = Math.trunc(absOffset / 60);
14835 const minutes = absOffset % 60;
14836 if (minutes === 0) {
14837 return sign + String(hours);
14838 }
14839 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
14840 }
14841 function formatTimezoneWithOptionalMinutes(offset, delimiter) {
14842 if (offset % 60 === 0) {
14843 const sign = offset > 0 ? "-" : "+";
14844 return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
14845 }
14846 return formatTimezone(offset, delimiter);
14847 }
14848 function formatTimezone(offset, delimiter = "") {
14849 const sign = offset > 0 ? "-" : "+";
14850 const absOffset = Math.abs(offset);
14851 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
14852 const minutes = addLeadingZeros(absOffset % 60, 2);
14853 return sign + hours + delimiter + minutes;
14854 }
14855
14856 // node_modules/date-fns/_lib/format/longFormatters.js
14857 var dateLongFormatter = (pattern, formatLong2) => {
14858 switch (pattern) {
14859 case "P":
14860 return formatLong2.date({ width: "short" });
14861 case "PP":
14862 return formatLong2.date({ width: "medium" });
14863 case "PPP":
14864 return formatLong2.date({ width: "long" });
14865 case "PPPP":
14866 default:
14867 return formatLong2.date({ width: "full" });
14868 }
14869 };
14870 var timeLongFormatter = (pattern, formatLong2) => {
14871 switch (pattern) {
14872 case "p":
14873 return formatLong2.time({ width: "short" });
14874 case "pp":
14875 return formatLong2.time({ width: "medium" });
14876 case "ppp":
14877 return formatLong2.time({ width: "long" });
14878 case "pppp":
14879 default:
14880 return formatLong2.time({ width: "full" });
14881 }
14882 };
14883 var dateTimeLongFormatter = (pattern, formatLong2) => {
14884 const matchResult = pattern.match(/(P+)(p+)?/) || [];
14885 const datePattern = matchResult[1];
14886 const timePattern = matchResult[2];
14887 if (!timePattern) {
14888 return dateLongFormatter(pattern, formatLong2);
14889 }
14890 let dateTimeFormat;
14891 switch (datePattern) {
14892 case "P":
14893 dateTimeFormat = formatLong2.dateTime({ width: "short" });
14894 break;
14895 case "PP":
14896 dateTimeFormat = formatLong2.dateTime({ width: "medium" });
14897 break;
14898 case "PPP":
14899 dateTimeFormat = formatLong2.dateTime({ width: "long" });
14900 break;
14901 case "PPPP":
14902 default:
14903 dateTimeFormat = formatLong2.dateTime({ width: "full" });
14904 break;
14905 }
14906 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
14907 };
14908 var longFormatters = {
14909 p: timeLongFormatter,
14910 P: dateTimeLongFormatter
14911 };
14912
14913 // node_modules/date-fns/_lib/protectedTokens.js
14914 var dayOfYearTokenRE = /^D+$/;
14915 var weekYearTokenRE = /^Y+$/;
14916 var throwTokens = ["D", "DD", "YY", "YYYY"];
14917 function isProtectedDayOfYearToken(token) {
14918 return dayOfYearTokenRE.test(token);
14919 }
14920 function isProtectedWeekYearToken(token) {
14921 return weekYearTokenRE.test(token);
14922 }
14923 function warnOrThrowProtectedError(token, format6, input) {
14924 const _message = message(token, format6, input);
14925 console.warn(_message);
14926 if (throwTokens.includes(token)) throw new RangeError(_message);
14927 }
14928 function message(token, format6, input) {
14929 const subject = token[0] === "Y" ? "years" : "days of the month";
14930 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`;
14931 }
14932
14933 // node_modules/date-fns/format.js
14934 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
14935 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
14936 var escapedStringRegExp = /^'([^]*?)'?$/;
14937 var doubleQuoteRegExp = /''/g;
14938 var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
14939 function format(date, formatStr, options) {
14940 const defaultOptions2 = getDefaultOptions();
14941 const locale = options?.locale ?? defaultOptions2.locale ?? enUS;
14942 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
14943 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
14944 const originalDate = toDate(date, options?.in);
14945 if (!isValid(originalDate)) {
14946 throw new RangeError("Invalid time value");
14947 }
14948 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
14949 const firstCharacter = substring[0];
14950 if (firstCharacter === "p" || firstCharacter === "P") {
14951 const longFormatter = longFormatters[firstCharacter];
14952 return longFormatter(substring, locale.formatLong);
14953 }
14954 return substring;
14955 }).join("").match(formattingTokensRegExp).map((substring) => {
14956 if (substring === "''") {
14957 return { isToken: false, value: "'" };
14958 }
14959 const firstCharacter = substring[0];
14960 if (firstCharacter === "'") {
14961 return { isToken: false, value: cleanEscapedString(substring) };
14962 }
14963 if (formatters[firstCharacter]) {
14964 return { isToken: true, value: substring };
14965 }
14966 if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
14967 throw new RangeError(
14968 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
14969 );
14970 }
14971 return { isToken: false, value: substring };
14972 });
14973 if (locale.localize.preprocessor) {
14974 parts = locale.localize.preprocessor(originalDate, parts);
14975 }
14976 const formatterOptions = {
14977 firstWeekContainsDate,
14978 weekStartsOn,
14979 locale
14980 };
14981 return parts.map((part) => {
14982 if (!part.isToken) return part.value;
14983 const token = part.value;
14984 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
14985 warnOrThrowProtectedError(token, formatStr, String(date));
14986 }
14987 const formatter = formatters[token[0]];
14988 return formatter(originalDate, token, locale.localize, formatterOptions);
14989 }).join("");
14990 }
14991 function cleanEscapedString(input) {
14992 const matched = input.match(escapedStringRegExp);
14993 if (!matched) {
14994 return input;
14995 }
14996 return matched[1].replace(doubleQuoteRegExp, "'");
14997 }
14998
14999 // node_modules/date-fns/subDays.js
15000 function subDays(date, amount, options) {
15001 return addDays(date, -amount, options);
15002 }
15003
15004 // node_modules/date-fns/subMonths.js
15005 function subMonths(date, amount, options) {
15006 return addMonths(date, -amount, options);
15007 }
15008
15009 // node_modules/date-fns/subWeeks.js
15010 function subWeeks(date, amount, options) {
15011 return addWeeks(date, -amount, options);
15012 }
15013
15014 // node_modules/date-fns/subYears.js
15015 function subYears(date, amount, options) {
15016 return addYears(date, -amount, options);
15017 }
15018
15019 // packages/dataviews/build-module/utils/operators.mjs
15020 var import_i18n23 = __toESM(require_i18n(), 1);
15021 var import_element45 = __toESM(require_element(), 1);
15022 var import_date = __toESM(require_date(), 1);
15023 var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);
15024 var filterTextWrappers = {
15025 Name: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }),
15026 Value: /* @__PURE__ */ (0, import_jsx_runtime76.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" })
15027 };
15028 function getRelativeDate(value, unit) {
15029 switch (unit) {
15030 case "days":
15031 return subDays(/* @__PURE__ */ new Date(), value);
15032 case "weeks":
15033 return subWeeks(/* @__PURE__ */ new Date(), value);
15034 case "months":
15035 return subMonths(/* @__PURE__ */ new Date(), value);
15036 case "years":
15037 return subYears(/* @__PURE__ */ new Date(), value);
15038 default:
15039 return /* @__PURE__ */ new Date();
15040 }
15041 }
15042 var isNoneOperatorDefinition = {
15043 /* translators: DataViews operator name */
15044 label: (0, import_i18n23.__)("Is none of"),
15045 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15046 (0, import_i18n23.sprintf)(
15047 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */
15048 (0, import_i18n23.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"),
15049 filter.name,
15050 activeElements.map((element) => element.label).join(", ")
15051 ),
15052 filterTextWrappers
15053 ),
15054 filter: ((item, field, filterValue) => {
15055 if (!filterValue?.length) {
15056 return true;
15057 }
15058 const fieldValue = field.getValue({ item });
15059 if (Array.isArray(fieldValue)) {
15060 return !filterValue.some(
15061 (fv) => fieldValue.includes(fv)
15062 );
15063 } else if (typeof fieldValue === "string") {
15064 return !filterValue.includes(fieldValue);
15065 }
15066 return false;
15067 }),
15068 selection: "multi"
15069 };
15070 var OPERATORS = [
15071 {
15072 name: OPERATOR_IS_ANY,
15073 /* translators: DataViews operator name */
15074 label: (0, import_i18n23.__)("Includes"),
15075 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15076 (0, import_i18n23.sprintf)(
15077 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */
15078 (0, import_i18n23.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"),
15079 filter.name,
15080 activeElements.map((element) => element.label).join(", ")
15081 ),
15082 filterTextWrappers
15083 ),
15084 filter(item, field, filterValue) {
15085 if (!filterValue?.length) {
15086 return true;
15087 }
15088 const fieldValue = field.getValue({ item });
15089 if (Array.isArray(fieldValue)) {
15090 return filterValue.some(
15091 (fv) => fieldValue.includes(fv)
15092 );
15093 } else if (typeof fieldValue === "string") {
15094 return filterValue.includes(fieldValue);
15095 }
15096 return false;
15097 },
15098 selection: "multi"
15099 },
15100 {
15101 name: OPERATOR_IS_NONE,
15102 ...isNoneOperatorDefinition
15103 },
15104 {
15105 name: OPERATOR_IS_ALL,
15106 /* translators: DataViews operator name */
15107 label: (0, import_i18n23.__)("Includes all"),
15108 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15109 (0, import_i18n23.sprintf)(
15110 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */
15111 (0, import_i18n23.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"),
15112 filter.name,
15113 activeElements.map((element) => element.label).join(", ")
15114 ),
15115 filterTextWrappers
15116 ),
15117 filter(item, field, filterValue) {
15118 if (!filterValue?.length) {
15119 return true;
15120 }
15121 return filterValue.every((value) => {
15122 return field.getValue({ item })?.includes(value);
15123 });
15124 },
15125 selection: "multi"
15126 },
15127 {
15128 name: OPERATOR_IS_NOT_ALL,
15129 ...isNoneOperatorDefinition
15130 },
15131 {
15132 name: OPERATOR_BETWEEN,
15133 /* translators: DataViews operator name */
15134 label: (0, import_i18n23.__)("Between (inc)"),
15135 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15136 (0, import_i18n23.sprintf)(
15137 /* 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". */
15138 (0, import_i18n23.__)(
15139 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>"
15140 ),
15141 filter.name,
15142 activeElements[0].label[0],
15143 activeElements[0].label[1]
15144 ),
15145 filterTextWrappers
15146 ),
15147 filter(item, field, filterValue) {
15148 if (!Array.isArray(filterValue) || filterValue.length !== 2 || filterValue[0] === void 0 || filterValue[1] === void 0) {
15149 return true;
15150 }
15151 const fieldValue = field.getValue({ item });
15152 if (typeof fieldValue === "number" || fieldValue instanceof Date || typeof fieldValue === "string") {
15153 return fieldValue >= filterValue[0] && fieldValue <= filterValue[1];
15154 }
15155 return false;
15156 },
15157 selection: "custom"
15158 },
15159 {
15160 name: OPERATOR_IN_THE_PAST,
15161 /* translators: DataViews operator name */
15162 label: (0, import_i18n23.__)("In the past"),
15163 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15164 (0, import_i18n23.sprintf)(
15165 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */
15166 (0, import_i18n23.__)(
15167 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>"
15168 ),
15169 filter.name,
15170 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
15171 ),
15172 filterTextWrappers
15173 ),
15174 filter(item, field, filterValue) {
15175 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
15176 return true;
15177 }
15178 const targetDate = getRelativeDate(
15179 filterValue.value,
15180 filterValue.unit
15181 );
15182 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
15183 return fieldValue >= targetDate && fieldValue <= /* @__PURE__ */ new Date();
15184 },
15185 selection: "custom"
15186 },
15187 {
15188 name: OPERATOR_OVER,
15189 /* translators: DataViews operator name */
15190 label: (0, import_i18n23.__)("Over"),
15191 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15192 (0, import_i18n23.sprintf)(
15193 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */
15194 (0, import_i18n23.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"),
15195 filter.name,
15196 `${activeElements[0].value.value} ${activeElements[0].value.unit}`
15197 ),
15198 filterTextWrappers
15199 ),
15200 filter(item, field, filterValue) {
15201 if (filterValue?.value === void 0 || filterValue?.unit === void 0) {
15202 return true;
15203 }
15204 const targetDate = getRelativeDate(
15205 filterValue.value,
15206 filterValue.unit
15207 );
15208 const fieldValue = (0, import_date.getDate)(field.getValue({ item }));
15209 return fieldValue < targetDate;
15210 },
15211 selection: "custom"
15212 },
15213 {
15214 name: OPERATOR_IS,
15215 /* translators: DataViews operator name */
15216 label: (0, import_i18n23.__)("Is"),
15217 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15218 (0, import_i18n23.sprintf)(
15219 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */
15220 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
15221 filter.name,
15222 activeElements[0].label
15223 ),
15224 filterTextWrappers
15225 ),
15226 filter(item, field, filterValue) {
15227 return filterValue === field.getValue({ item }) || filterValue === void 0;
15228 },
15229 selection: "single"
15230 },
15231 {
15232 name: OPERATOR_IS_NOT,
15233 /* translators: DataViews operator name */
15234 label: (0, import_i18n23.__)("Is not"),
15235 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15236 (0, import_i18n23.sprintf)(
15237 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */
15238 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
15239 filter.name,
15240 activeElements[0].label
15241 ),
15242 filterTextWrappers
15243 ),
15244 filter(item, field, filterValue) {
15245 return filterValue !== field.getValue({ item });
15246 },
15247 selection: "single"
15248 },
15249 {
15250 name: OPERATOR_LESS_THAN,
15251 /* translators: DataViews operator name */
15252 label: (0, import_i18n23.__)("Less than"),
15253 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15254 (0, import_i18n23.sprintf)(
15255 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */
15256 (0, import_i18n23.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"),
15257 filter.name,
15258 activeElements[0].label
15259 ),
15260 filterTextWrappers
15261 ),
15262 filter(item, field, filterValue) {
15263 if (filterValue === void 0) {
15264 return true;
15265 }
15266 const fieldValue = field.getValue({ item });
15267 return fieldValue < filterValue;
15268 },
15269 selection: "single"
15270 },
15271 {
15272 name: OPERATOR_GREATER_THAN,
15273 /* translators: DataViews operator name */
15274 label: (0, import_i18n23.__)("Greater than"),
15275 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15276 (0, import_i18n23.sprintf)(
15277 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */
15278 (0, import_i18n23.__)(
15279 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>"
15280 ),
15281 filter.name,
15282 activeElements[0].label
15283 ),
15284 filterTextWrappers
15285 ),
15286 filter(item, field, filterValue) {
15287 if (filterValue === void 0) {
15288 return true;
15289 }
15290 const fieldValue = field.getValue({ item });
15291 return fieldValue > filterValue;
15292 },
15293 selection: "single"
15294 },
15295 {
15296 name: OPERATOR_LESS_THAN_OR_EQUAL,
15297 /* translators: DataViews operator name */
15298 label: (0, import_i18n23.__)("Less than or equal"),
15299 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15300 (0, import_i18n23.sprintf)(
15301 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */
15302 (0, import_i18n23.__)(
15303 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>"
15304 ),
15305 filter.name,
15306 activeElements[0].label
15307 ),
15308 filterTextWrappers
15309 ),
15310 filter(item, field, filterValue) {
15311 if (filterValue === void 0) {
15312 return true;
15313 }
15314 const fieldValue = field.getValue({ item });
15315 return fieldValue <= filterValue;
15316 },
15317 selection: "single"
15318 },
15319 {
15320 name: OPERATOR_GREATER_THAN_OR_EQUAL,
15321 /* translators: DataViews operator name */
15322 label: (0, import_i18n23.__)("Greater than or equal"),
15323 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15324 (0, import_i18n23.sprintf)(
15325 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */
15326 (0, import_i18n23.__)(
15327 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>"
15328 ),
15329 filter.name,
15330 activeElements[0].label
15331 ),
15332 filterTextWrappers
15333 ),
15334 filter(item, field, filterValue) {
15335 if (filterValue === void 0) {
15336 return true;
15337 }
15338 const fieldValue = field.getValue({ item });
15339 return fieldValue >= filterValue;
15340 },
15341 selection: "single"
15342 },
15343 {
15344 name: OPERATOR_BEFORE,
15345 /* translators: DataViews operator name */
15346 label: (0, import_i18n23.__)("Before"),
15347 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15348 (0, import_i18n23.sprintf)(
15349 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */
15350 (0, import_i18n23.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"),
15351 filter.name,
15352 activeElements[0].label
15353 ),
15354 filterTextWrappers
15355 ),
15356 filter(item, field, filterValue) {
15357 if (filterValue === void 0) {
15358 return true;
15359 }
15360 const filterDate = (0, import_date.getDate)(filterValue);
15361 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15362 return fieldDate < filterDate;
15363 },
15364 selection: "single"
15365 },
15366 {
15367 name: OPERATOR_AFTER,
15368 /* translators: DataViews operator name */
15369 label: (0, import_i18n23.__)("After"),
15370 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15371 (0, import_i18n23.sprintf)(
15372 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */
15373 (0, import_i18n23.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"),
15374 filter.name,
15375 activeElements[0].label
15376 ),
15377 filterTextWrappers
15378 ),
15379 filter(item, field, filterValue) {
15380 if (filterValue === void 0) {
15381 return true;
15382 }
15383 const filterDate = (0, import_date.getDate)(filterValue);
15384 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15385 return fieldDate > filterDate;
15386 },
15387 selection: "single"
15388 },
15389 {
15390 name: OPERATOR_BEFORE_INC,
15391 /* translators: DataViews operator name */
15392 label: (0, import_i18n23.__)("Before (inc)"),
15393 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15394 (0, import_i18n23.sprintf)(
15395 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */
15396 (0, import_i18n23.__)(
15397 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>"
15398 ),
15399 filter.name,
15400 activeElements[0].label
15401 ),
15402 filterTextWrappers
15403 ),
15404 filter(item, field, filterValue) {
15405 if (filterValue === void 0) {
15406 return true;
15407 }
15408 const filterDate = (0, import_date.getDate)(filterValue);
15409 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15410 return fieldDate <= filterDate;
15411 },
15412 selection: "single"
15413 },
15414 {
15415 name: OPERATOR_AFTER_INC,
15416 /* translators: DataViews operator name */
15417 label: (0, import_i18n23.__)("After (inc)"),
15418 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15419 (0, import_i18n23.sprintf)(
15420 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */
15421 (0, import_i18n23.__)(
15422 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>"
15423 ),
15424 filter.name,
15425 activeElements[0].label
15426 ),
15427 filterTextWrappers
15428 ),
15429 filter(item, field, filterValue) {
15430 if (filterValue === void 0) {
15431 return true;
15432 }
15433 const filterDate = (0, import_date.getDate)(filterValue);
15434 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15435 return fieldDate >= filterDate;
15436 },
15437 selection: "single"
15438 },
15439 {
15440 name: OPERATOR_CONTAINS,
15441 /* translators: DataViews operator name */
15442 label: (0, import_i18n23.__)("Contains"),
15443 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15444 (0, import_i18n23.sprintf)(
15445 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */
15446 (0, import_i18n23.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"),
15447 filter.name,
15448 activeElements[0].label
15449 ),
15450 filterTextWrappers
15451 ),
15452 filter(item, field, filterValue) {
15453 if (filterValue === void 0) {
15454 return true;
15455 }
15456 const fieldValue = field.getValue({ item });
15457 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
15458 },
15459 selection: "single"
15460 },
15461 {
15462 name: OPERATOR_NOT_CONTAINS,
15463 /* translators: DataViews operator name */
15464 label: (0, import_i18n23.__)("Doesn't contain"),
15465 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15466 (0, import_i18n23.sprintf)(
15467 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */
15468 (0, import_i18n23.__)(
15469 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>"
15470 ),
15471 filter.name,
15472 activeElements[0].label
15473 ),
15474 filterTextWrappers
15475 ),
15476 filter(item, field, filterValue) {
15477 if (filterValue === void 0) {
15478 return true;
15479 }
15480 const fieldValue = field.getValue({ item });
15481 return typeof fieldValue === "string" && filterValue && !fieldValue.toLowerCase().includes(String(filterValue).toLowerCase());
15482 },
15483 selection: "single"
15484 },
15485 {
15486 name: OPERATOR_STARTS_WITH,
15487 /* translators: DataViews operator name */
15488 label: (0, import_i18n23.__)("Starts with"),
15489 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15490 (0, import_i18n23.sprintf)(
15491 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */
15492 (0, import_i18n23.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"),
15493 filter.name,
15494 activeElements[0].label
15495 ),
15496 filterTextWrappers
15497 ),
15498 filter(item, field, filterValue) {
15499 if (filterValue === void 0) {
15500 return true;
15501 }
15502 const fieldValue = field.getValue({ item });
15503 return typeof fieldValue === "string" && filterValue && fieldValue.toLowerCase().startsWith(String(filterValue).toLowerCase());
15504 },
15505 selection: "single"
15506 },
15507 {
15508 name: OPERATOR_ON,
15509 /* translators: DataViews operator name */
15510 label: (0, import_i18n23.__)("On"),
15511 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15512 (0, import_i18n23.sprintf)(
15513 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */
15514 (0, import_i18n23.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"),
15515 filter.name,
15516 activeElements[0].label
15517 ),
15518 filterTextWrappers
15519 ),
15520 filter(item, field, filterValue) {
15521 if (filterValue === void 0) {
15522 return true;
15523 }
15524 const filterDate = (0, import_date.getDate)(filterValue);
15525 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15526 return filterDate.getTime() === fieldDate.getTime();
15527 },
15528 selection: "single"
15529 },
15530 {
15531 name: OPERATOR_NOT_ON,
15532 /* translators: DataViews operator name */
15533 label: (0, import_i18n23.__)("Not on"),
15534 filterText: (filter, activeElements) => (0, import_element45.createInterpolateElement)(
15535 (0, import_i18n23.sprintf)(
15536 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */
15537 (0, import_i18n23.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"),
15538 filter.name,
15539 activeElements[0].label
15540 ),
15541 filterTextWrappers
15542 ),
15543 filter(item, field, filterValue) {
15544 if (filterValue === void 0) {
15545 return true;
15546 }
15547 const filterDate = (0, import_date.getDate)(filterValue);
15548 const fieldDate = (0, import_date.getDate)(field.getValue({ item }));
15549 return filterDate.getTime() !== fieldDate.getTime();
15550 },
15551 selection: "single"
15552 }
15553 ];
15554 var getOperatorByName = (name) => OPERATORS.find((op) => op.name === name);
15555 var getAllOperatorNames = () => OPERATORS.map((op) => op.name);
15556 var isSingleSelectionOperator = (name) => OPERATORS.filter((op) => op.selection === "single").some(
15557 (op) => op.name === name
15558 );
15559 var isRegisteredOperator = (name) => OPERATORS.some((op) => op.name === name);
15560
15561 // packages/dataviews/build-module/components/dataviews-filters/filter.mjs
15562 var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
15563 var ENTER = "Enter";
15564 var SPACE = " ";
15565 var FilterText = ({
15566 activeElements,
15567 filterInView,
15568 filter
15569 }) => {
15570 if (activeElements === void 0 || activeElements.length === 0) {
15571 return filter.name;
15572 }
15573 const operator = getOperatorByName(filterInView?.operator);
15574 if (operator !== void 0) {
15575 return operator.filterText(filter, activeElements);
15576 }
15577 return (0, import_i18n24.sprintf)(
15578 /* translators: 1: Filter name e.g.: "Unknown status for Author". */
15579 (0, import_i18n24.__)("Unknown status for %1$s"),
15580 filter.name
15581 );
15582 };
15583 function OperatorSelector({
15584 filter,
15585 view,
15586 onChangeView
15587 }) {
15588 const operatorOptions = filter.operators?.map((operator) => ({
15589 value: operator,
15590 label: getOperatorByName(operator)?.label || operator
15591 }));
15592 const currentFilter = view.filters?.find(
15593 (_filter) => _filter.field === filter.field
15594 );
15595 const value = currentFilter?.operator || filter.operators[0];
15596 return operatorOptions.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
15597 Stack,
15598 {
15599 direction: "row",
15600 gap: "sm",
15601 justify: "flex-start",
15602 className: "dataviews-filters__summary-operators-container",
15603 align: "center",
15604 children: [
15605 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components22.FlexItem, { className: "dataviews-filters__summary-operators-filter-name", children: filter.name }),
15606 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15607 import_components22.SelectControl,
15608 {
15609 className: "dataviews-filters__summary-operators-filter-select",
15610 label: (0, import_i18n24.__)("Conditions"),
15611 value,
15612 options: operatorOptions,
15613 onChange: (newValue) => {
15614 const newOperator = newValue;
15615 const currentOperator = currentFilter?.operator;
15616 const newFilters = currentFilter ? [
15617 ...(view.filters ?? []).map(
15618 (_filter) => {
15619 if (_filter.field === filter.field) {
15620 const currentOpSelectionModel = getOperatorByName(
15621 currentOperator
15622 )?.selection;
15623 const newOpSelectionModel = getOperatorByName(
15624 newOperator
15625 )?.selection;
15626 const shouldResetValue = currentOpSelectionModel !== newOpSelectionModel || [
15627 currentOpSelectionModel,
15628 newOpSelectionModel
15629 ].includes("custom");
15630 return {
15631 ..._filter,
15632 value: shouldResetValue ? void 0 : _filter.value,
15633 operator: newOperator
15634 };
15635 }
15636 return _filter;
15637 }
15638 )
15639 ] : [
15640 ...view.filters ?? [],
15641 {
15642 field: filter.field,
15643 operator: newOperator,
15644 value: void 0
15645 }
15646 ];
15647 onChangeView({
15648 ...view,
15649 page: 1,
15650 filters: newFilters
15651 });
15652 },
15653 size: "small",
15654 variant: "minimal",
15655 hideLabelFromVision: true
15656 }
15657 )
15658 ]
15659 }
15660 );
15661 }
15662 function Filter({
15663 addFilterRef,
15664 openedFilter,
15665 fields: fields2,
15666 ...commonProps
15667 }) {
15668 const toggleRef = (0, import_element46.useRef)(null);
15669 const { filter, view, onChangeView } = commonProps;
15670 const filterInView = view.filters?.find(
15671 (f2) => f2.field === filter.field
15672 );
15673 let activeElements = [];
15674 const field = (0, import_element46.useMemo)(() => {
15675 const currentField = fields2.find((f2) => f2.id === filter.field);
15676 if (currentField) {
15677 return {
15678 ...currentField,
15679 // Configure getValue as if Item was a plain object.
15680 // See related input-widget.tsx
15681 getValue: ({ item }) => item[currentField.id]
15682 };
15683 }
15684 return currentField;
15685 }, [fields2, filter.field]);
15686 const { elements } = useElements({
15687 elements: filter.elements,
15688 getElements: filter.getElements
15689 });
15690 if (elements.length > 0) {
15691 activeElements = elements.filter((element) => {
15692 if (filter.singleSelection) {
15693 return element.value === filterInView?.value;
15694 }
15695 return filterInView?.value?.includes(element.value);
15696 });
15697 } else if (Array.isArray(filterInView?.value)) {
15698 const label = filterInView.value.map((v2) => {
15699 const formattedValue = field?.getValueFormatted({
15700 item: { [field.id]: v2 },
15701 field
15702 });
15703 return formattedValue || String(v2);
15704 });
15705 activeElements = [
15706 {
15707 value: filterInView.value,
15708 // @ts-ignore
15709 label
15710 }
15711 ];
15712 } else if (typeof filterInView?.value === "object") {
15713 activeElements = [
15714 { value: filterInView.value, label: filterInView.value }
15715 ];
15716 } else if (filterInView?.value !== void 0) {
15717 const label = field !== void 0 ? field.getValueFormatted({
15718 item: { [field.id]: filterInView.value },
15719 field
15720 }) : String(filterInView.value);
15721 activeElements = [
15722 {
15723 value: filterInView.value,
15724 label
15725 }
15726 ];
15727 }
15728 const isPrimary = filter.isPrimary;
15729 const isLocked = filterInView?.isLocked;
15730 const hasValues = !isLocked && filterInView?.value !== void 0;
15731 const canResetOrRemove = !isLocked && (!isPrimary || hasValues);
15732 return /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15733 import_components22.Dropdown,
15734 {
15735 defaultOpen: openedFilter === filter.field,
15736 contentClassName: "dataviews-filters__summary-popover",
15737 popoverProps: { placement: "bottom-start", role: "dialog" },
15738 onClose: () => {
15739 toggleRef.current?.focus();
15740 },
15741 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)("div", { className: "dataviews-filters__summary-chip-container", children: [
15742 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15743 import_components22.Tooltip,
15744 {
15745 text: (0, import_i18n24.sprintf)(
15746 /* translators: 1: Filter name. */
15747 (0, import_i18n24.__)("Filter by: %1$s"),
15748 filter.name.toLowerCase()
15749 ),
15750 placement: "top",
15751 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15752 "div",
15753 {
15754 className: clsx_default(
15755 "dataviews-filters__summary-chip",
15756 {
15757 "has-reset": canResetOrRemove,
15758 "has-values": hasValues,
15759 "is-not-clickable": isLocked
15760 }
15761 ),
15762 role: "button",
15763 tabIndex: isLocked ? -1 : 0,
15764 onClick: () => {
15765 if (!isLocked) {
15766 onToggle();
15767 }
15768 },
15769 onKeyDown: (event) => {
15770 if (!isLocked && [ENTER, SPACE].includes(event.key)) {
15771 onToggle();
15772 event.preventDefault();
15773 }
15774 },
15775 "aria-disabled": isLocked,
15776 "aria-pressed": isOpen,
15777 "aria-expanded": isOpen,
15778 ref: toggleRef,
15779 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15780 FilterText,
15781 {
15782 activeElements,
15783 filterInView,
15784 filter
15785 }
15786 )
15787 }
15788 )
15789 }
15790 ),
15791 canResetOrRemove && /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15792 import_components22.Tooltip,
15793 {
15794 text: isPrimary ? (0, import_i18n24.__)("Reset") : (0, import_i18n24.__)("Remove"),
15795 placement: "top",
15796 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15797 "button",
15798 {
15799 className: clsx_default(
15800 "dataviews-filters__summary-chip-remove",
15801 { "has-values": hasValues }
15802 ),
15803 onClick: () => {
15804 onChangeView({
15805 ...view,
15806 page: 1,
15807 filters: view.filters?.filter(
15808 (_filter) => _filter.field !== filter.field
15809 )
15810 });
15811 if (!isPrimary) {
15812 addFilterRef.current?.focus();
15813 } else {
15814 toggleRef.current?.focus();
15815 }
15816 },
15817 children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_components22.Icon, { icon: close_small_default })
15818 }
15819 )
15820 }
15821 )
15822 ] }),
15823 renderContent: () => {
15824 return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(Stack, { direction: "column", justify: "flex-start", children: [
15825 /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(OperatorSelector, { ...commonProps }),
15826 commonProps.filter.hasElements ? /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(
15827 SearchWidget,
15828 {
15829 ...commonProps,
15830 filter: {
15831 ...commonProps.filter,
15832 elements
15833 }
15834 }
15835 ) : /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(InputWidget, { ...commonProps, fields: fields2 })
15836 ] });
15837 }
15838 }
15839 );
15840 }
15841
15842 // packages/dataviews/build-module/components/dataviews-filters/add-filter.mjs
15843 var import_components23 = __toESM(require_components(), 1);
15844 var import_i18n25 = __toESM(require_i18n(), 1);
15845 var import_element47 = __toESM(require_element(), 1);
15846 var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
15847 var { Menu: Menu4 } = unlock(import_components23.privateApis);
15848 function AddFilterMenu({
15849 filters,
15850 view,
15851 onChangeView,
15852 setOpenedFilter,
15853 triggerProps
15854 }) {
15855 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
15856 return /* @__PURE__ */ (0, import_jsx_runtime78.jsxs)(Menu4, { children: [
15857 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.TriggerButton, { ...triggerProps }),
15858 /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.Popover, { children: inactiveFilters.map((filter) => {
15859 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15860 Menu4.Item,
15861 {
15862 onClick: () => {
15863 setOpenedFilter(filter.field);
15864 onChangeView({
15865 ...view,
15866 page: 1,
15867 filters: [
15868 ...view.filters || [],
15869 {
15870 field: filter.field,
15871 value: void 0,
15872 operator: filter.operators[0]
15873 }
15874 ]
15875 });
15876 },
15877 children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(Menu4.ItemLabel, { children: filter.name })
15878 },
15879 filter.field
15880 );
15881 }) })
15882 ] });
15883 }
15884 function AddFilter({ filters, view, onChangeView, setOpenedFilter }, ref) {
15885 if (!filters.length || filters.every(({ isPrimary }) => isPrimary)) {
15886 return null;
15887 }
15888 const inactiveFilters = filters.filter((filter) => !filter.isVisible);
15889 return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15890 AddFilterMenu,
15891 {
15892 triggerProps: {
15893 render: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
15894 import_components23.Button,
15895 {
15896 accessibleWhenDisabled: true,
15897 size: "compact",
15898 className: "dataviews-filters-button",
15899 variant: "tertiary",
15900 disabled: !inactiveFilters.length,
15901 ref
15902 }
15903 ),
15904 children: (0, import_i18n25.__)("Add filter")
15905 },
15906 ...{ filters, view, onChangeView, setOpenedFilter }
15907 }
15908 );
15909 }
15910 var add_filter_default = (0, import_element47.forwardRef)(AddFilter);
15911
15912 // packages/dataviews/build-module/components/dataviews-filters/reset-filters.mjs
15913 var import_components24 = __toESM(require_components(), 1);
15914 var import_i18n26 = __toESM(require_i18n(), 1);
15915 var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
15916 function ResetFilter({
15917 filters,
15918 view,
15919 onChangeView
15920 }) {
15921 const isPrimary = (field) => filters.some(
15922 (_filter) => _filter.field === field && _filter.isPrimary
15923 );
15924 const isDisabled = !view.search && !view.filters?.some(
15925 (_filter) => !_filter.isLocked && (_filter.value !== void 0 || !isPrimary(_filter.field))
15926 );
15927 return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
15928 import_components24.Button,
15929 {
15930 disabled: isDisabled,
15931 accessibleWhenDisabled: true,
15932 size: "compact",
15933 variant: "tertiary",
15934 className: "dataviews-filters__reset-button",
15935 onClick: () => {
15936 onChangeView({
15937 ...view,
15938 page: 1,
15939 search: "",
15940 filters: view.filters?.filter((f2) => !!f2.isLocked) || []
15941 });
15942 },
15943 children: (0, import_i18n26.__)("Reset")
15944 }
15945 );
15946 }
15947
15948 // packages/dataviews/build-module/components/dataviews-filters/use-filters.mjs
15949 var import_element48 = __toESM(require_element(), 1);
15950 function useFilters(fields2, view) {
15951 return (0, import_element48.useMemo)(() => {
15952 const filters = [];
15953 fields2.forEach((field) => {
15954 if (field.filterBy === false || !field.hasElements && !field.Edit) {
15955 return;
15956 }
15957 const operators = field.filterBy.operators;
15958 const isPrimary = !!field.filterBy?.isPrimary;
15959 const isLocked = view.filters?.some(
15960 (f2) => f2.field === field.id && !!f2.isLocked
15961 ) ?? false;
15962 filters.push({
15963 field: field.id,
15964 name: field.label,
15965 elements: field.elements,
15966 getElements: field.getElements,
15967 hasElements: field.hasElements,
15968 singleSelection: operators.some(
15969 (op) => isSingleSelectionOperator(op)
15970 ),
15971 operators,
15972 isVisible: isLocked || isPrimary || !!view.filters?.some(
15973 (f2) => f2.field === field.id && isRegisteredOperator(f2.operator)
15974 ),
15975 isPrimary,
15976 isLocked
15977 });
15978 });
15979 filters.sort((a2, b2) => {
15980 if (a2.isLocked && !b2.isLocked) {
15981 return -1;
15982 }
15983 if (!a2.isLocked && b2.isLocked) {
15984 return 1;
15985 }
15986 if (a2.isPrimary && !b2.isPrimary) {
15987 return -1;
15988 }
15989 if (!a2.isPrimary && b2.isPrimary) {
15990 return 1;
15991 }
15992 return a2.name.localeCompare(b2.name);
15993 });
15994 return filters;
15995 }, [fields2, view]);
15996 }
15997 var use_filters_default = useFilters;
15998
15999 // packages/dataviews/build-module/components/dataviews-filters/filters.mjs
16000 var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);
16001 function Filters({ className }) {
16002 const { fields: fields2, view, onChangeView, openedFilter, setOpenedFilter } = (0, import_element49.useContext)(dataviews_context_default);
16003 const addFilterRef = (0, import_element49.useRef)(null);
16004 const filters = use_filters_default(fields2, view);
16005 const addFilter = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16006 add_filter_default,
16007 {
16008 filters,
16009 view,
16010 onChangeView,
16011 ref: addFilterRef,
16012 setOpenedFilter
16013 },
16014 "add-filter"
16015 );
16016 const visibleFilters = filters.filter((filter) => filter.isVisible);
16017 if (visibleFilters.length === 0) {
16018 return null;
16019 }
16020 const filterComponents = [
16021 ...visibleFilters.map((filter) => {
16022 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16023 Filter,
16024 {
16025 filter,
16026 view,
16027 fields: fields2,
16028 onChangeView,
16029 addFilterRef,
16030 openedFilter
16031 },
16032 filter.field
16033 );
16034 }),
16035 addFilter
16036 ];
16037 filterComponents.push(
16038 /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16039 ResetFilter,
16040 {
16041 filters,
16042 view,
16043 onChangeView
16044 },
16045 "reset-filters"
16046 )
16047 );
16048 return /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
16049 Stack,
16050 {
16051 direction: "row",
16052 justify: "flex-start",
16053 gap: "sm",
16054 style: { width: "fit-content" },
16055 wrap: "wrap",
16056 className,
16057 children: filterComponents
16058 }
16059 );
16060 }
16061 var filters_default = (0, import_element49.memo)(Filters);
16062
16063 // packages/dataviews/build-module/components/dataviews-filters/toggle.mjs
16064 var import_element50 = __toESM(require_element(), 1);
16065 var import_components25 = __toESM(require_components(), 1);
16066 var import_i18n27 = __toESM(require_i18n(), 1);
16067 var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);
16068 function FiltersToggle() {
16069 const {
16070 filters,
16071 view,
16072 onChangeView,
16073 setOpenedFilter,
16074 isShowingFilter,
16075 setIsShowingFilter
16076 } = (0, import_element50.useContext)(dataviews_context_default);
16077 const buttonRef = (0, import_element50.useRef)(null);
16078 const onChangeViewWithFilterVisibility = (0, import_element50.useCallback)(
16079 (_view) => {
16080 onChangeView(_view);
16081 setIsShowingFilter(true);
16082 },
16083 [onChangeView, setIsShowingFilter]
16084 );
16085 if (filters.length === 0) {
16086 return null;
16087 }
16088 const hasVisibleFilters = filters.some((filter) => filter.isVisible);
16089 const addFilterButtonProps = {
16090 label: (0, import_i18n27.__)("Add filter"),
16091 "aria-expanded": false,
16092 isPressed: false
16093 };
16094 const toggleFiltersButtonProps = {
16095 label: (0, import_i18n27._x)("Filter", "verb"),
16096 "aria-expanded": isShowingFilter,
16097 isPressed: isShowingFilter,
16098 onClick: () => {
16099 if (!isShowingFilter) {
16100 setOpenedFilter(null);
16101 }
16102 setIsShowingFilter(!isShowingFilter);
16103 }
16104 };
16105 const hasPrimaryOrLockedFilters = filters.some(
16106 (filter) => filter.isPrimary || filter.isLocked
16107 );
16108 const buttonComponent = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16109 import_components25.Button,
16110 {
16111 ref: buttonRef,
16112 className: "dataviews-filters__visibility-toggle",
16113 size: "compact",
16114 icon: funnel_default,
16115 disabled: hasPrimaryOrLockedFilters,
16116 accessibleWhenDisabled: true,
16117 ...hasVisibleFilters ? toggleFiltersButtonProps : addFilterButtonProps
16118 }
16119 );
16120 return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "dataviews-filters__container-visibility-toggle", children: !hasVisibleFilters ? /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16121 AddFilterMenu,
16122 {
16123 filters,
16124 view,
16125 onChangeView: onChangeViewWithFilterVisibility,
16126 setOpenedFilter,
16127 triggerProps: { render: buttonComponent }
16128 }
16129 ) : /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
16130 FilterVisibilityToggle,
16131 {
16132 buttonRef,
16133 filtersCount: view.filters?.length,
16134 children: buttonComponent
16135 }
16136 ) });
16137 }
16138 function FilterVisibilityToggle({
16139 buttonRef,
16140 filtersCount,
16141 children
16142 }) {
16143 (0, import_element50.useEffect)(
16144 () => () => {
16145 buttonRef.current?.focus();
16146 },
16147 [buttonRef]
16148 );
16149 return /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
16150 children,
16151 !!filtersCount && /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "dataviews-filters-toggle__count", children: filtersCount })
16152 ] });
16153 }
16154 var toggle_default = FiltersToggle;
16155
16156 // packages/dataviews/build-module/components/dataviews-filters/filters-toggled.mjs
16157 var import_element51 = __toESM(require_element(), 1);
16158 var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
16159 function FiltersToggled(props) {
16160 const { isShowingFilter } = (0, import_element51.useContext)(dataviews_context_default);
16161 if (!isShowingFilter) {
16162 return null;
16163 }
16164 return /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(filters_default, { ...props });
16165 }
16166 var filters_toggled_default = FiltersToggled;
16167
16168 // packages/dataviews/build-module/components/dataviews-layout/index.mjs
16169 var import_element52 = __toESM(require_element(), 1);
16170 var import_components26 = __toESM(require_components(), 1);
16171 var import_i18n28 = __toESM(require_i18n(), 1);
16172 var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
16173 function DataViewsLayout({ className }) {
16174 const {
16175 actions: actions2 = [],
16176 data,
16177 fields: fields2,
16178 getItemId,
16179 getItemLevel,
16180 hasInitiallyLoaded,
16181 isLoading,
16182 view,
16183 onChangeView,
16184 selection,
16185 onChangeSelection,
16186 setOpenedFilter,
16187 onClickItem,
16188 isItemClickable,
16189 renderItemLink,
16190 defaultLayouts,
16191 containerRef,
16192 empty = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("p", { children: (0, import_i18n28.__)("No results") })
16193 } = (0, import_element52.useContext)(dataviews_context_default);
16194 const isDelayedInitialLoading = useDelayedLoading(!hasInitiallyLoaded, {
16195 delay: 200
16196 });
16197 if (!hasInitiallyLoaded) {
16198 if (!isDelayedInitialLoading) {
16199 return null;
16200 }
16201 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, {}) }) });
16202 }
16203 const ViewComponent = VIEW_LAYOUTS.find(
16204 (v2) => v2.type === view.type && defaultLayouts[v2.type]
16205 )?.component;
16206 return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)("div", { className: "dataviews-layout__container", ref: containerRef, children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
16207 ViewComponent,
16208 {
16209 className,
16210 actions: actions2,
16211 data,
16212 fields: fields2,
16213 getItemId,
16214 getItemLevel,
16215 isLoading,
16216 onChangeView,
16217 onChangeSelection,
16218 selection,
16219 setOpenedFilter,
16220 onClickItem,
16221 renderItemLink,
16222 isItemClickable,
16223 view,
16224 empty
16225 }
16226 ) });
16227 }
16228
16229 // packages/dataviews/build-module/components/dataviews-footer/index.mjs
16230 var import_element53 = __toESM(require_element(), 1);
16231 var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);
16232 var EMPTY_ARRAY5 = [];
16233 function DataViewsFooter() {
16234 const {
16235 view,
16236 paginationInfo: { totalItems = 0, totalPages },
16237 data,
16238 actions: actions2 = EMPTY_ARRAY5,
16239 isLoading,
16240 hasInitiallyLoaded
16241 } = (0, import_element53.useContext)(dataviews_context_default);
16242 const isRefreshing = !!isLoading && hasInitiallyLoaded && !!data?.length;
16243 const isDelayedRefreshing = useDelayedLoading(!!isRefreshing);
16244 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions2, data) && [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type);
16245 if (!isRefreshing && (!totalItems || !totalPages || totalPages <= 1 && !hasBulkActions)) {
16246 return null;
16247 }
16248 return (!!totalItems || isRefreshing) && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
16249 "div",
16250 {
16251 className: "dataviews-footer",
16252 inert: isRefreshing ? "true" : void 0,
16253 children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)(
16254 Stack,
16255 {
16256 direction: "row",
16257 justify: "end",
16258 align: "center",
16259 className: clsx_default("dataviews-footer__content", {
16260 "is-refreshing": isDelayedRefreshing
16261 }),
16262 gap: "sm",
16263 children: [
16264 hasBulkActions && /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(BulkActionsFooter, {}),
16265 /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(dataviews_pagination_default, {})
16266 ]
16267 }
16268 )
16269 }
16270 );
16271 }
16272
16273 // packages/dataviews/build-module/components/dataviews-search/index.mjs
16274 var import_i18n29 = __toESM(require_i18n(), 1);
16275 var import_element54 = __toESM(require_element(), 1);
16276 var import_components27 = __toESM(require_components(), 1);
16277 var import_compose9 = __toESM(require_compose(), 1);
16278 var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);
16279 var DataViewsSearch = (0, import_element54.memo)(function Search({ label }) {
16280 const { view, onChangeView } = (0, import_element54.useContext)(dataviews_context_default);
16281 const [search, setSearch, debouncedSearch] = (0, import_compose9.useDebouncedInput)(
16282 view.search
16283 );
16284 (0, import_element54.useEffect)(() => {
16285 if (view.search !== debouncedSearch) {
16286 setSearch(view.search ?? "");
16287 }
16288 }, [view.search, setSearch]);
16289 const onChangeViewRef = (0, import_element54.useRef)(onChangeView);
16290 const viewRef = (0, import_element54.useRef)(view);
16291 (0, import_element54.useEffect)(() => {
16292 onChangeViewRef.current = onChangeView;
16293 viewRef.current = view;
16294 }, [onChangeView, view]);
16295 (0, import_element54.useEffect)(() => {
16296 if (debouncedSearch !== viewRef.current?.search) {
16297 onChangeViewRef.current({
16298 ...viewRef.current,
16299 page: view.page ? 1 : void 0,
16300 startPosition: view.startPosition ? 1 : void 0,
16301 search: debouncedSearch
16302 });
16303 }
16304 }, [debouncedSearch]);
16305 const searchLabel = label || (0, import_i18n29.__)("Search");
16306 return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
16307 import_components27.SearchControl,
16308 {
16309 className: "dataviews-search",
16310 onChange: setSearch,
16311 value: search,
16312 label: searchLabel,
16313 placeholder: searchLabel,
16314 size: "compact"
16315 }
16316 );
16317 });
16318 var dataviews_search_default = DataViewsSearch;
16319
16320 // packages/dataviews/build-module/components/dataviews-view-config/index.mjs
16321 var import_components28 = __toESM(require_components(), 1);
16322 var import_i18n30 = __toESM(require_i18n(), 1);
16323 var import_element55 = __toESM(require_element(), 1);
16324 var import_warning = __toESM(require_warning(), 1);
16325 var import_compose10 = __toESM(require_compose(), 1);
16326 var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);
16327 var { Menu: Menu5 } = unlock(import_components28.privateApis);
16328 var DATAVIEWS_CONFIG_POPOVER_PROPS = {
16329 className: "dataviews-config__popover",
16330 placement: "bottom-end",
16331 offset: 9
16332 };
16333 function ViewTypeMenu() {
16334 const { view, onChangeView, defaultLayouts } = (0, import_element55.useContext)(dataviews_context_default);
16335 const availableLayouts = Object.keys(defaultLayouts);
16336 if (availableLayouts.length <= 1) {
16337 return null;
16338 }
16339 const activeView = VIEW_LAYOUTS.find((v2) => view.type === v2.type);
16340 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Menu5, { children: [
16341 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16342 Menu5.TriggerButton,
16343 {
16344 render: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16345 import_components28.Button,
16346 {
16347 size: "compact",
16348 icon: activeView?.icon,
16349 label: (0, import_i18n30.__)("Layout")
16350 }
16351 )
16352 }
16353 ),
16354 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.Popover, { children: availableLayouts.map((layout) => {
16355 const config = VIEW_LAYOUTS.find(
16356 (v2) => v2.type === layout
16357 );
16358 if (!config) {
16359 return null;
16360 }
16361 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16362 Menu5.RadioItem,
16363 {
16364 value: layout,
16365 name: "view-actions-available-view",
16366 checked: layout === view.type,
16367 hideOnClick: true,
16368 onChange: (e2) => {
16369 switch (e2.target.value) {
16370 case "list":
16371 case "grid":
16372 case "table":
16373 case "pickerGrid":
16374 case "pickerTable":
16375 case "activity":
16376 const viewWithoutLayout = { ...view };
16377 if ("layout" in viewWithoutLayout) {
16378 delete viewWithoutLayout.layout;
16379 }
16380 return onChangeView({
16381 ...viewWithoutLayout,
16382 type: e2.target.value,
16383 ...defaultLayouts[e2.target.value]
16384 });
16385 }
16386 (0, import_warning.default)("Invalid dataview");
16387 },
16388 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Menu5.ItemLabel, { children: config.label })
16389 },
16390 layout
16391 );
16392 }) })
16393 ] });
16394 }
16395 function SortFieldControl() {
16396 const { view, fields: fields2, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
16397 const orderOptions = (0, import_element55.useMemo)(() => {
16398 const sortableFields = fields2.filter(
16399 (field) => field.enableSorting !== false
16400 );
16401 return sortableFields.map((field) => {
16402 return {
16403 label: field.label,
16404 value: field.id
16405 };
16406 });
16407 }, [fields2]);
16408 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16409 import_components28.SelectControl,
16410 {
16411 __next40pxDefaultSize: true,
16412 label: (0, import_i18n30.__)("Sort by"),
16413 value: view.sort?.field,
16414 options: orderOptions,
16415 onChange: (value) => {
16416 onChangeView({
16417 ...view,
16418 sort: {
16419 direction: view?.sort?.direction || "desc",
16420 field: value
16421 },
16422 showLevels: false
16423 });
16424 }
16425 }
16426 );
16427 }
16428 function SortDirectionControl() {
16429 const { view, fields: fields2, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
16430 const sortableFields = fields2.filter(
16431 (field) => field.enableSorting !== false
16432 );
16433 if (sortableFields.length === 0) {
16434 return null;
16435 }
16436 let value = view.sort?.direction;
16437 if (!value && view.sort?.field) {
16438 value = "desc";
16439 }
16440 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16441 import_components28.__experimentalToggleGroupControl,
16442 {
16443 className: "dataviews-view-config__sort-direction",
16444 __next40pxDefaultSize: true,
16445 isBlock: true,
16446 label: (0, import_i18n30.__)("Order"),
16447 value,
16448 onChange: (newDirection) => {
16449 if (newDirection === "asc" || newDirection === "desc") {
16450 onChangeView({
16451 ...view,
16452 sort: {
16453 direction: newDirection,
16454 field: view.sort?.field || // If there is no field assigned as the sorting field assign the first sortable field.
16455 fields2.find(
16456 (field) => field.enableSorting !== false
16457 )?.id || ""
16458 },
16459 showLevels: false
16460 });
16461 return;
16462 }
16463 (0, import_warning.default)("Invalid direction");
16464 },
16465 children: SORTING_DIRECTIONS.map((direction) => {
16466 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16467 import_components28.__experimentalToggleGroupControlOptionIcon,
16468 {
16469 value: direction,
16470 icon: sortIcons[direction],
16471 label: sortLabels[direction]
16472 },
16473 direction
16474 );
16475 })
16476 }
16477 );
16478 }
16479 function ItemsPerPageControl() {
16480 const { view, config, onChangeView } = (0, import_element55.useContext)(dataviews_context_default);
16481 const { infiniteScrollEnabled } = view;
16482 if (!config || !config.perPageSizes || config.perPageSizes.length < 2 || config.perPageSizes.length > 6 || infiniteScrollEnabled) {
16483 return null;
16484 }
16485 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16486 import_components28.__experimentalToggleGroupControl,
16487 {
16488 __next40pxDefaultSize: true,
16489 isBlock: true,
16490 label: (0, import_i18n30.__)("Items per page"),
16491 value: view.perPage || 10,
16492 disabled: !view?.sort?.field,
16493 onChange: (newItemsPerPage) => {
16494 const newItemsPerPageNumber = typeof newItemsPerPage === "number" || newItemsPerPage === void 0 ? newItemsPerPage : parseInt(newItemsPerPage, 10);
16495 onChangeView({
16496 ...view,
16497 perPage: newItemsPerPageNumber,
16498 page: 1
16499 });
16500 },
16501 children: config.perPageSizes.map((value) => {
16502 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16503 import_components28.__experimentalToggleGroupControlOption,
16504 {
16505 value,
16506 label: value.toString()
16507 },
16508 value
16509 );
16510 })
16511 }
16512 );
16513 }
16514 function ResetViewButton() {
16515 const { onReset } = (0, import_element55.useContext)(dataviews_context_default);
16516 if (onReset === void 0) {
16517 return null;
16518 }
16519 const isDisabled = onReset === false;
16520 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16521 import_components28.Button,
16522 {
16523 variant: "tertiary",
16524 size: "compact",
16525 disabled: isDisabled,
16526 accessibleWhenDisabled: true,
16527 className: "dataviews-view-config__reset-button",
16528 onClick: () => {
16529 if (typeof onReset === "function") {
16530 onReset();
16531 }
16532 },
16533 children: (0, import_i18n30.__)("Reset view")
16534 }
16535 );
16536 }
16537 function DataviewsViewConfigDropdown() {
16538 const { view, onReset } = (0, import_element55.useContext)(dataviews_context_default);
16539 const popoverId = (0, import_compose10.useInstanceId)(
16540 _DataViewsViewConfig,
16541 "dataviews-view-config-dropdown"
16542 );
16543 const activeLayout = VIEW_LAYOUTS.find(
16544 (layout) => layout.type === view.type
16545 );
16546 const isModified = typeof onReset === "function";
16547 return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16548 import_components28.Dropdown,
16549 {
16550 expandOnMobile: true,
16551 popoverProps: {
16552 ...DATAVIEWS_CONFIG_POPOVER_PROPS,
16553 id: popoverId
16554 },
16555 renderToggle: ({ onToggle, isOpen }) => {
16556 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "dataviews-view-config__toggle-wrapper", children: [
16557 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16558 import_components28.Button,
16559 {
16560 size: "compact",
16561 icon: cog_default,
16562 label: (0, import_i18n30._x)(
16563 "View options",
16564 "View is used as a noun"
16565 ),
16566 onClick: onToggle,
16567 "aria-expanded": isOpen ? "true" : "false",
16568 "aria-controls": popoverId
16569 }
16570 ),
16571 isModified && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("span", { className: "dataviews-view-config__modified-indicator" })
16572 ] });
16573 },
16574 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16575 import_components28.__experimentalDropdownContentWrapper,
16576 {
16577 paddingSize: "medium",
16578 className: "dataviews-config__popover-content-wrapper",
16579 children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16580 Stack,
16581 {
16582 direction: "column",
16583 className: "dataviews-view-config",
16584 gap: "xl",
16585 children: [
16586 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16587 Stack,
16588 {
16589 direction: "row",
16590 justify: "space-between",
16591 align: "center",
16592 className: "dataviews-view-config__header",
16593 children: [
16594 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
16595 import_components28.__experimentalHeading,
16596 {
16597 level: 2,
16598 className: "dataviews-settings-section__title",
16599 children: (0, import_i18n30.__)("Appearance")
16600 }
16601 ),
16602 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ResetViewButton, {})
16603 ]
16604 }
16605 ),
16606 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16607 /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(
16608 Stack,
16609 {
16610 direction: "row",
16611 gap: "sm",
16612 className: "dataviews-view-config__sort-controls",
16613 children: [
16614 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortFieldControl, {}),
16615 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(SortDirectionControl, {})
16616 ]
16617 }
16618 ),
16619 !!activeLayout?.viewConfigOptions && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(activeLayout.viewConfigOptions, {}),
16620 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ItemsPerPageControl, {}),
16621 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(PropertiesSection, {})
16622 ] })
16623 ]
16624 }
16625 )
16626 }
16627 )
16628 }
16629 );
16630 }
16631 function _DataViewsViewConfig() {
16632 return /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)(import_jsx_runtime86.Fragment, { children: [
16633 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ViewTypeMenu, {}),
16634 /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(DataviewsViewConfigDropdown, {})
16635 ] });
16636 }
16637 var DataViewsViewConfig = (0, import_element55.memo)(_DataViewsViewConfig);
16638 var dataviews_view_config_default = DataViewsViewConfig;
16639
16640 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
16641 var import_components29 = __toESM(require_components(), 1);
16642 var import_element56 = __toESM(require_element(), 1);
16643
16644 // packages/dataviews/build-module/components/dataform-controls/utils/get-custom-validity.mjs
16645 function getCustomValidity(isValid2, validity) {
16646 let customValidity;
16647 if (isValid2?.required && validity?.required) {
16648 customValidity = validity?.required?.message ? validity.required : void 0;
16649 } else if (isValid2?.pattern && validity?.pattern) {
16650 customValidity = validity.pattern;
16651 } else if (isValid2?.min && validity?.min) {
16652 customValidity = validity.min;
16653 } else if (isValid2?.max && validity?.max) {
16654 customValidity = validity.max;
16655 } else if (isValid2?.minLength && validity?.minLength) {
16656 customValidity = validity.minLength;
16657 } else if (isValid2?.maxLength && validity?.maxLength) {
16658 customValidity = validity.maxLength;
16659 } else if (isValid2?.elements && validity?.elements) {
16660 customValidity = validity.elements;
16661 } else if (validity?.custom) {
16662 customValidity = validity.custom;
16663 }
16664 return customValidity;
16665 }
16666
16667 // packages/dataviews/build-module/components/dataform-controls/checkbox.mjs
16668 var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
16669 var { ValidatedCheckboxControl } = unlock(import_components29.privateApis);
16670 function Checkbox({
16671 field,
16672 onChange,
16673 data,
16674 hideLabelFromVision,
16675 markWhenOptional,
16676 validity
16677 }) {
16678 const { getValue, setValue, label, description, isValid: isValid2 } = field;
16679 const disabled2 = field.isDisabled({ item: data, field });
16680 const onChangeControl = (0, import_element56.useCallback)(() => {
16681 onChange(
16682 setValue({ item: data, value: !getValue({ item: data }) })
16683 );
16684 }, [data, getValue, onChange, setValue]);
16685 return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
16686 ValidatedCheckboxControl,
16687 {
16688 required: !!field.isValid?.required,
16689 markWhenOptional,
16690 customValidity: getCustomValidity(isValid2, validity),
16691 hidden: hideLabelFromVision,
16692 label,
16693 help: description,
16694 checked: getValue({ item: data }),
16695 onChange: onChangeControl,
16696 disabled: disabled2
16697 }
16698 );
16699 }
16700
16701 // packages/dataviews/build-module/components/dataform-controls/combobox.mjs
16702 var import_components30 = __toESM(require_components(), 1);
16703 var import_element57 = __toESM(require_element(), 1);
16704 var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);
16705 var { ValidatedComboboxControl } = unlock(import_components30.privateApis);
16706 function Combobox3({
16707 data,
16708 field,
16709 onChange,
16710 hideLabelFromVision,
16711 validity
16712 }) {
16713 const { label, description, placeholder, getValue, setValue, isValid: isValid2 } = field;
16714 const value = getValue({ item: data }) ?? "";
16715 const onChangeControl = (0, import_element57.useCallback)(
16716 (newValue) => onChange(setValue({ item: data, value: newValue ?? "" })),
16717 [data, onChange, setValue]
16718 );
16719 const { elements, isLoading } = useElements({
16720 elements: field.elements,
16721 getElements: field.getElements
16722 });
16723 if (isLoading) {
16724 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_components30.Spinner, {});
16725 }
16726 return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
16727 ValidatedComboboxControl,
16728 {
16729 required: !!field.isValid?.required,
16730 customValidity: getCustomValidity(isValid2, validity),
16731 label,
16732 value,
16733 help: description,
16734 placeholder,
16735 options: elements,
16736 onChange: onChangeControl,
16737 hideLabelFromVision,
16738 allowReset: true,
16739 expandOnFocus: true
16740 }
16741 );
16742 }
16743
16744 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
16745 var import_components32 = __toESM(require_components(), 1);
16746 var import_element60 = __toESM(require_element(), 1);
16747 var import_i18n32 = __toESM(require_i18n(), 1);
16748 var import_date3 = __toESM(require_date(), 1);
16749
16750 // packages/dataviews/build-module/components/dataform-controls/utils/relative-date-control.mjs
16751 var import_components31 = __toESM(require_components(), 1);
16752 var import_element58 = __toESM(require_element(), 1);
16753 var import_i18n31 = __toESM(require_i18n(), 1);
16754 var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);
16755 var TIME_UNITS_OPTIONS = {
16756 [OPERATOR_IN_THE_PAST]: [
16757 { value: "days", label: (0, import_i18n31.__)("Days") },
16758 { value: "weeks", label: (0, import_i18n31.__)("Weeks") },
16759 { value: "months", label: (0, import_i18n31.__)("Months") },
16760 { value: "years", label: (0, import_i18n31.__)("Years") }
16761 ],
16762 [OPERATOR_OVER]: [
16763 { value: "days", label: (0, import_i18n31.__)("Days ago") },
16764 { value: "weeks", label: (0, import_i18n31.__)("Weeks ago") },
16765 { value: "months", label: (0, import_i18n31.__)("Months ago") },
16766 { value: "years", label: (0, import_i18n31.__)("Years ago") }
16767 ]
16768 };
16769 function RelativeDateControl({
16770 className,
16771 data,
16772 field,
16773 onChange,
16774 hideLabelFromVision,
16775 operator
16776 }) {
16777 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"];
16778 const { id, label, description, getValue, setValue } = field;
16779 const disabled2 = field.isDisabled({ item: data, field });
16780 const fieldValue = getValue({ item: data });
16781 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {};
16782 const onChangeValue = (0, import_element58.useCallback)(
16783 (newValue) => onChange(
16784 setValue({
16785 item: data,
16786 value: { value: Number(newValue), unit }
16787 })
16788 ),
16789 [onChange, setValue, data, unit]
16790 );
16791 const onChangeUnit = (0, import_element58.useCallback)(
16792 (newUnit) => onChange(
16793 setValue({
16794 item: data,
16795 value: { value: relValue, unit: newUnit }
16796 })
16797 ),
16798 [onChange, setValue, data, relValue]
16799 );
16800 return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16801 import_components31.BaseControl,
16802 {
16803 id,
16804 className: clsx_default(className, "dataviews-controls__relative-date"),
16805 label,
16806 hideLabelFromVision,
16807 help: description,
16808 children: /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(Stack, { direction: "row", gap: "sm", children: [
16809 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16810 import_components31.__experimentalNumberControl,
16811 {
16812 __next40pxDefaultSize: true,
16813 className: "dataviews-controls__relative-date-number",
16814 spinControls: "none",
16815 min: 1,
16816 step: 1,
16817 value: relValue,
16818 onChange: onChangeValue,
16819 disabled: disabled2
16820 }
16821 ),
16822 /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
16823 import_components31.SelectControl,
16824 {
16825 className: "dataviews-controls__relative-date-unit",
16826 __next40pxDefaultSize: true,
16827 label: (0, import_i18n31.__)("Unit"),
16828 value: unit,
16829 options,
16830 onChange: onChangeUnit,
16831 hideLabelFromVision: true,
16832 disabled: disabled2
16833 }
16834 )
16835 ] })
16836 }
16837 );
16838 }
16839
16840 // packages/dataviews/build-module/components/dataform-controls/utils/use-disabled-date-matchers.mjs
16841 var import_element59 = __toESM(require_element(), 1);
16842 function useDisabledDateMatchers(isValid2, parseDateFn) {
16843 const minConstraint = typeof isValid2.min?.constraint === "string" ? isValid2.min.constraint : void 0;
16844 const maxConstraint = typeof isValid2.max?.constraint === "string" ? isValid2.max.constraint : void 0;
16845 const disabledMatchers = (0, import_element59.useMemo)(() => {
16846 const matchers = [];
16847 if (minConstraint) {
16848 const minDate = parseDateFn(minConstraint);
16849 if (minDate) {
16850 matchers.push({ before: minDate });
16851 }
16852 }
16853 if (maxConstraint) {
16854 const maxDate = parseDateFn(maxConstraint);
16855 if (maxDate) {
16856 matchers.push({ after: maxDate });
16857 }
16858 }
16859 return matchers.length > 0 ? matchers : void 0;
16860 }, [minConstraint, maxConstraint, parseDateFn]);
16861 return { minConstraint, maxConstraint, disabledMatchers };
16862 }
16863
16864 // packages/dataviews/build-module/field-types/utils/parse-date-time.mjs
16865 var import_date2 = __toESM(require_date(), 1);
16866 function parseDateTime(dateTimeString) {
16867 if (!dateTimeString) {
16868 return null;
16869 }
16870 const parsed = (0, import_date2.getDate)(dateTimeString);
16871 return parsed && isValid(parsed) ? parsed : null;
16872 }
16873
16874 // packages/dataviews/build-module/components/dataform-controls/datetime.mjs
16875 var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);
16876 var { DateCalendar, ValidatedInputControl } = unlock(import_components32.privateApis);
16877 var formatDateTime = (value) => {
16878 if (!value) {
16879 return "";
16880 }
16881 return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
16882 };
16883 function CalendarDateTimeControl({
16884 data,
16885 field,
16886 onChange,
16887 hideLabelFromVision,
16888 markWhenOptional,
16889 validity,
16890 config
16891 }) {
16892 const { compact } = config || {};
16893 const { id, label, description, setValue, getValue, isValid: isValid2 } = field;
16894 const disabled2 = field.isDisabled({ item: data, field });
16895 const fieldValue = getValue({ item: data });
16896 const value = typeof fieldValue === "string" ? fieldValue : void 0;
16897 const [calendarMonth, setCalendarMonth] = (0, import_element60.useState)(() => {
16898 const parsedDate = parseDateTime(value);
16899 return parsedDate || /* @__PURE__ */ new Date();
16900 });
16901 const inputControlRef = (0, import_element60.useRef)(null);
16902 const validationTimeoutRef = (0, import_element60.useRef)(void 0);
16903 const previousFocusRef = (0, import_element60.useRef)(null);
16904 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDateTime);
16905 const onChangeCallback = (0, import_element60.useCallback)(
16906 (newValue) => onChange(setValue({ item: data, value: newValue })),
16907 [data, onChange, setValue]
16908 );
16909 (0, import_element60.useEffect)(() => {
16910 return () => {
16911 if (validationTimeoutRef.current) {
16912 clearTimeout(validationTimeoutRef.current);
16913 }
16914 };
16915 }, []);
16916 const onSelectDate = (0, import_element60.useCallback)(
16917 (newDate) => {
16918 let dateTimeValue;
16919 if (newDate) {
16920 const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
16921 let wpTime;
16922 if (value) {
16923 wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
16924 } else {
16925 wpTime = (0, import_date3.dateI18n)("H:i", newDate);
16926 }
16927 const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
16928 dateTimeValue = finalDateTime.toISOString();
16929 onChangeCallback(dateTimeValue);
16930 if (validationTimeoutRef.current) {
16931 clearTimeout(validationTimeoutRef.current);
16932 }
16933 } else {
16934 onChangeCallback(void 0);
16935 }
16936 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement;
16937 validationTimeoutRef.current = setTimeout(() => {
16938 if (inputControlRef.current) {
16939 inputControlRef.current.focus();
16940 inputControlRef.current.blur();
16941 onChangeCallback(dateTimeValue);
16942 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) {
16943 previousFocusRef.current.focus();
16944 }
16945 }
16946 }, 0);
16947 },
16948 [onChangeCallback, value]
16949 );
16950 const handleManualDateTimeChange = (0, import_element60.useCallback)(
16951 (newValue) => {
16952 if (newValue) {
16953 const dateTime = (0, import_date3.getDate)(newValue);
16954 onChangeCallback(dateTime.toISOString());
16955 const parsedDate = parseDateTime(dateTime.toISOString());
16956 if (parsedDate) {
16957 setCalendarMonth(parsedDate);
16958 }
16959 } else {
16960 onChangeCallback(void 0);
16961 }
16962 },
16963 [onChangeCallback]
16964 );
16965 const { format: fieldFormat } = field;
16966 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek;
16967 const {
16968 timezone: { string: timezoneString }
16969 } = (0, import_date3.getSettings)();
16970 let displayLabel = label;
16971 if (isValid2?.required && !markWhenOptional && !hideLabelFromVision) {
16972 displayLabel = `${label} (${(0, import_i18n32.__)("Required")})`;
16973 } else if (!isValid2?.required && markWhenOptional && !hideLabelFromVision) {
16974 displayLabel = `${label} (${(0, import_i18n32.__)("Optional")})`;
16975 }
16976 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16977 import_components32.BaseControl,
16978 {
16979 id,
16980 label: displayLabel,
16981 help: description,
16982 hideLabelFromVision,
16983 children: /* @__PURE__ */ (0, import_jsx_runtime90.jsxs)(Stack, { direction: "column", gap: "lg", children: [
16984 /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
16985 ValidatedInputControl,
16986 {
16987 ref: inputControlRef,
16988 __next40pxDefaultSize: true,
16989 required: !!isValid2?.required,
16990 customValidity: getCustomValidity(isValid2, validity),
16991 type: "datetime-local",
16992 label: (0, import_i18n32.__)("Date time"),
16993 hideLabelFromVision: true,
16994 value: formatDateTime(value),
16995 onChange: handleManualDateTimeChange,
16996 disabled: disabled2,
16997 min: minConstraint ? formatDateTime(minConstraint) : void 0,
16998 max: maxConstraint ? formatDateTime(maxConstraint) : void 0
16999 }
17000 ),
17001 !compact && /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17002 DateCalendar,
17003 {
17004 style: { width: "100%" },
17005 selected: value ? parseDateTime(value) || void 0 : void 0,
17006 onSelect: onSelectDate,
17007 month: calendarMonth,
17008 onMonthChange: setCalendarMonth,
17009 timeZone: timezoneString || void 0,
17010 weekStartsOn,
17011 disabled: disabled2 || disabledMatchers
17012 }
17013 )
17014 ] })
17015 }
17016 );
17017 }
17018 function DateTime({
17019 data,
17020 field,
17021 onChange,
17022 hideLabelFromVision,
17023 markWhenOptional,
17024 operator,
17025 validity,
17026 config
17027 }) {
17028 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
17029 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17030 RelativeDateControl,
17031 {
17032 className: "dataviews-controls__datetime",
17033 data,
17034 field,
17035 onChange,
17036 hideLabelFromVision,
17037 operator
17038 }
17039 );
17040 }
17041 return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(
17042 CalendarDateTimeControl,
17043 {
17044 data,
17045 field,
17046 onChange,
17047 hideLabelFromVision,
17048 markWhenOptional,
17049 validity,
17050 config
17051 }
17052 );
17053 }
17054
17055 // packages/dataviews/build-module/components/dataform-controls/date.mjs
17056 var import_components33 = __toESM(require_components(), 1);
17057 var import_element61 = __toESM(require_element(), 1);
17058 var import_i18n33 = __toESM(require_i18n(), 1);
17059 var import_date4 = __toESM(require_date(), 1);
17060 var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);
17061 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock(import_components33.privateApis);
17062 var DATE_PRESETS = [
17063 {
17064 id: "today",
17065 label: (0, import_i18n33.__)("Today"),
17066 getValue: () => (0, import_date4.getDate)(null)
17067 },
17068 {
17069 id: "yesterday",
17070 label: (0, import_i18n33.__)("Yesterday"),
17071 getValue: () => {
17072 const today = (0, import_date4.getDate)(null);
17073 return subDays(today, 1);
17074 }
17075 },
17076 {
17077 id: "past-week",
17078 label: (0, import_i18n33.__)("Past week"),
17079 getValue: () => {
17080 const today = (0, import_date4.getDate)(null);
17081 return subDays(today, 7);
17082 }
17083 },
17084 {
17085 id: "past-month",
17086 label: (0, import_i18n33.__)("Past month"),
17087 getValue: () => {
17088 const today = (0, import_date4.getDate)(null);
17089 return subMonths(today, 1);
17090 }
17091 }
17092 ];
17093 var DATE_RANGE_PRESETS = [
17094 {
17095 id: "last-7-days",
17096 label: (0, import_i18n33.__)("Last 7 days"),
17097 getValue: () => {
17098 const today = (0, import_date4.getDate)(null);
17099 return [subDays(today, 7), today];
17100 }
17101 },
17102 {
17103 id: "last-30-days",
17104 label: (0, import_i18n33.__)("Last 30 days"),
17105 getValue: () => {
17106 const today = (0, import_date4.getDate)(null);
17107 return [subDays(today, 30), today];
17108 }
17109 },
17110 {
17111 id: "month-to-date",
17112 label: (0, import_i18n33.__)("Month to date"),
17113 getValue: () => {
17114 const today = (0, import_date4.getDate)(null);
17115 return [startOfMonth(today), today];
17116 }
17117 },
17118 {
17119 id: "last-year",
17120 label: (0, import_i18n33.__)("Last year"),
17121 getValue: () => {
17122 const today = (0, import_date4.getDate)(null);
17123 return [subYears(today, 1), today];
17124 }
17125 },
17126 {
17127 id: "year-to-date",
17128 label: (0, import_i18n33.__)("Year to date"),
17129 getValue: () => {
17130 const today = (0, import_date4.getDate)(null);
17131 return [startOfYear(today), today];
17132 }
17133 }
17134 ];
17135 var parseDate = (dateString) => {
17136 if (!dateString) {
17137 return null;
17138 }
17139 const parsed = (0, import_date4.getDate)(dateString);
17140 return parsed && isValid(parsed) ? parsed : null;
17141 };
17142 var formatDate = (date) => {
17143 if (!date) {
17144 return "";
17145 }
17146 return typeof date === "string" ? date : format(date, "yyyy-MM-dd");
17147 };
17148 function ValidatedDateControl({
17149 field,
17150 validity,
17151 inputRefs,
17152 isTouched,
17153 setIsTouched,
17154 children
17155 }) {
17156 const { isValid: isValid2 } = field;
17157 const [customValidity, setCustomValidity] = (0, import_element61.useState)(void 0);
17158 const validateRefs = (0, import_element61.useCallback)(() => {
17159 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
17160 for (const ref of refs) {
17161 const input = ref.current;
17162 if (input && !input.validity.valid) {
17163 setCustomValidity({
17164 type: "invalid",
17165 message: input.validationMessage
17166 });
17167 return;
17168 }
17169 }
17170 setCustomValidity(void 0);
17171 }, [inputRefs]);
17172 (0, import_element61.useEffect)(() => {
17173 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
17174 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
17175 for (const ref of refs) {
17176 const input = ref.current;
17177 if (input) {
17178 input.setCustomValidity(
17179 result?.type === "invalid" && result.message ? result.message : ""
17180 );
17181 }
17182 }
17183 }, [inputRefs, isValid2, validity]);
17184 (0, import_element61.useEffect)(() => {
17185 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs];
17186 const handleInvalid = (event) => {
17187 event.preventDefault();
17188 setIsTouched(true);
17189 };
17190 for (const ref of refs) {
17191 ref.current?.addEventListener("invalid", handleInvalid);
17192 }
17193 return () => {
17194 for (const ref of refs) {
17195 ref.current?.removeEventListener("invalid", handleInvalid);
17196 }
17197 };
17198 }, [inputRefs, setIsTouched]);
17199 (0, import_element61.useEffect)(() => {
17200 if (!isTouched) {
17201 return;
17202 }
17203 const result = validity ? getCustomValidity(isValid2, validity) : void 0;
17204 if (result) {
17205 setCustomValidity(result);
17206 } else {
17207 validateRefs();
17208 }
17209 }, [isTouched, isValid2, validity, validateRefs]);
17210 const onBlur = (event) => {
17211 if (isTouched) {
17212 return;
17213 }
17214 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) {
17215 setIsTouched(true);
17216 }
17217 };
17218 return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { onBlur, children: [
17219 children,
17220 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
17221 "p",
17222 {
17223 className: clsx_default(
17224 "components-validated-control__indicator",
17225 customValidity.type === "invalid" ? "is-invalid" : void 0
17226 ),
17227 children: [
17228 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17229 import_components33.Icon,
17230 {
17231 className: "components-validated-control__indicator-icon",
17232 icon: error_default,
17233 size: 16,
17234 fill: "currentColor"
17235 }
17236 ),
17237 customValidity.message
17238 ]
17239 }
17240 ) })
17241 ] });
17242 }
17243 function CalendarDateControl({
17244 data,
17245 field,
17246 onChange,
17247 hideLabelFromVision,
17248 markWhenOptional,
17249 validity
17250 }) {
17251 const {
17252 id,
17253 label,
17254 description,
17255 setValue,
17256 getValue,
17257 isValid: isValid2,
17258 format: fieldFormat
17259 } = field;
17260 const disabled2 = field.isDisabled({ item: data, field });
17261 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
17262 null
17263 );
17264 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
17265 const fieldValue = getValue({ item: data });
17266 const value = typeof fieldValue === "string" ? fieldValue : void 0;
17267 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
17268 const parsedDate = parseDate(value);
17269 return parsedDate || /* @__PURE__ */ new Date();
17270 });
17271 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
17272 const validityTargetRef = (0, import_element61.useRef)(null);
17273 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
17274 const onChangeCallback = (0, import_element61.useCallback)(
17275 (newValue) => onChange(setValue({ item: data, value: newValue })),
17276 [data, onChange, setValue]
17277 );
17278 const onSelectDate = (0, import_element61.useCallback)(
17279 (newDate) => {
17280 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0;
17281 onChangeCallback(dateValue);
17282 setSelectedPresetId(null);
17283 setIsTouched(true);
17284 },
17285 [onChangeCallback]
17286 );
17287 const handlePresetClick = (0, import_element61.useCallback)(
17288 (preset) => {
17289 const presetDate = preset.getValue();
17290 const dateValue = formatDate(presetDate);
17291 setCalendarMonth(presetDate);
17292 onChangeCallback(dateValue);
17293 setSelectedPresetId(preset.id);
17294 setIsTouched(true);
17295 },
17296 [onChangeCallback]
17297 );
17298 const handleManualDateChange = (0, import_element61.useCallback)(
17299 (newValue) => {
17300 onChangeCallback(newValue);
17301 if (newValue) {
17302 const parsedDate = parseDate(newValue);
17303 if (parsedDate) {
17304 setCalendarMonth(parsedDate);
17305 }
17306 }
17307 setSelectedPresetId(null);
17308 setIsTouched(true);
17309 },
17310 [onChangeCallback]
17311 );
17312 const {
17313 timezone: { string: timezoneString }
17314 } = (0, import_date4.getSettings)();
17315 let displayLabel = label;
17316 if (isValid2?.required && !markWhenOptional) {
17317 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
17318 } else if (!isValid2?.required && markWhenOptional) {
17319 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
17320 }
17321 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17322 ValidatedDateControl,
17323 {
17324 field,
17325 validity,
17326 inputRefs: validityTargetRef,
17327 isTouched,
17328 setIsTouched,
17329 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17330 import_components33.BaseControl,
17331 {
17332 id,
17333 className: "dataviews-controls__date",
17334 label: displayLabel,
17335 help: description,
17336 hideLabelFromVision,
17337 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
17338 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
17339 Stack,
17340 {
17341 direction: "row",
17342 gap: "sm",
17343 wrap: "wrap",
17344 justify: "flex-start",
17345 children: [
17346 DATE_PRESETS.map((preset) => {
17347 const isSelected2 = selectedPresetId === preset.id;
17348 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17349 import_components33.Button,
17350 {
17351 className: "dataviews-controls__date-preset",
17352 variant: "tertiary",
17353 isPressed: isSelected2,
17354 size: "small",
17355 disabled: disabled2,
17356 accessibleWhenDisabled: true,
17357 onClick: () => handlePresetClick(preset),
17358 children: preset.label
17359 },
17360 preset.id
17361 );
17362 }),
17363 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17364 import_components33.Button,
17365 {
17366 className: "dataviews-controls__date-preset",
17367 variant: "tertiary",
17368 isPressed: !selectedPresetId,
17369 size: "small",
17370 disabled: !!selectedPresetId || disabled2,
17371 accessibleWhenDisabled: true,
17372 children: (0, import_i18n33.__)("Custom")
17373 }
17374 )
17375 ]
17376 }
17377 ),
17378 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17379 import_components33.__experimentalInputControl,
17380 {
17381 __next40pxDefaultSize: true,
17382 ref: validityTargetRef,
17383 type: "date",
17384 label: (0, import_i18n33.__)("Date"),
17385 hideLabelFromVision: true,
17386 value,
17387 onChange: handleManualDateChange,
17388 required: !!field.isValid?.required,
17389 disabled: disabled2,
17390 min: minConstraint,
17391 max: maxConstraint
17392 }
17393 ),
17394 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17395 DateCalendar2,
17396 {
17397 style: { width: "100%" },
17398 selected: value ? parseDate(value) || void 0 : void 0,
17399 onSelect: onSelectDate,
17400 month: calendarMonth,
17401 onMonthChange: setCalendarMonth,
17402 timeZone: timezoneString || void 0,
17403 weekStartsOn,
17404 disabled: disabled2 || disabledMatchers,
17405 disableNavigation: disabled2
17406 }
17407 )
17408 ] })
17409 }
17410 )
17411 }
17412 );
17413 }
17414 function CalendarDateRangeControl({
17415 data,
17416 field,
17417 onChange,
17418 hideLabelFromVision,
17419 markWhenOptional,
17420 validity
17421 }) {
17422 const {
17423 id,
17424 label,
17425 description,
17426 getValue,
17427 setValue,
17428 isValid: isValid2,
17429 format: fieldFormat
17430 } = field;
17431 const disabled2 = field.isDisabled({ item: data, field });
17432 let value;
17433 const fieldValue = getValue({ item: data });
17434 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) {
17435 value = fieldValue;
17436 }
17437 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek;
17438 const { minConstraint, maxConstraint, disabledMatchers } = useDisabledDateMatchers(isValid2, parseDate);
17439 const onChangeCallback = (0, import_element61.useCallback)(
17440 (newValue) => {
17441 onChange(
17442 setValue({
17443 item: data,
17444 value: newValue
17445 })
17446 );
17447 },
17448 [data, onChange, setValue]
17449 );
17450 const [selectedPresetId, setSelectedPresetId] = (0, import_element61.useState)(
17451 null
17452 );
17453 const selectedRange = (0, import_element61.useMemo)(() => {
17454 if (!value) {
17455 return { from: void 0, to: void 0 };
17456 }
17457 const [from, to] = value;
17458 return {
17459 from: parseDate(from) || void 0,
17460 to: parseDate(to) || void 0
17461 };
17462 }, [value]);
17463 const [calendarMonth, setCalendarMonth] = (0, import_element61.useState)(() => {
17464 return selectedRange.from || /* @__PURE__ */ new Date();
17465 });
17466 const [isTouched, setIsTouched] = (0, import_element61.useState)(false);
17467 const fromInputRef = (0, import_element61.useRef)(null);
17468 const toInputRef = (0, import_element61.useRef)(null);
17469 const updateDateRange = (0, import_element61.useCallback)(
17470 (fromDate, toDate2) => {
17471 if (fromDate && toDate2) {
17472 onChangeCallback([
17473 formatDate(fromDate),
17474 formatDate(toDate2)
17475 ]);
17476 } else if (!fromDate && !toDate2) {
17477 onChangeCallback(void 0);
17478 }
17479 },
17480 [onChangeCallback]
17481 );
17482 const onSelectCalendarRange = (0, import_element61.useCallback)(
17483 (newRange) => {
17484 updateDateRange(newRange?.from, newRange?.to);
17485 setSelectedPresetId(null);
17486 setIsTouched(true);
17487 },
17488 [updateDateRange]
17489 );
17490 const handlePresetClick = (0, import_element61.useCallback)(
17491 (preset) => {
17492 const [startDate, endDate] = preset.getValue();
17493 setCalendarMonth(startDate);
17494 updateDateRange(startDate, endDate);
17495 setSelectedPresetId(preset.id);
17496 setIsTouched(true);
17497 },
17498 [updateDateRange]
17499 );
17500 const handleManualDateChange = (0, import_element61.useCallback)(
17501 (fromOrTo, newValue) => {
17502 const [currentFrom, currentTo] = value || [
17503 void 0,
17504 void 0
17505 ];
17506 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom;
17507 const updatedTo = fromOrTo === "to" ? newValue : currentTo;
17508 updateDateRange(updatedFrom, updatedTo);
17509 if (newValue) {
17510 const parsedDate = parseDate(newValue);
17511 if (parsedDate) {
17512 setCalendarMonth(parsedDate);
17513 }
17514 }
17515 setSelectedPresetId(null);
17516 setIsTouched(true);
17517 },
17518 [value, updateDateRange]
17519 );
17520 const { timezone } = (0, import_date4.getSettings)();
17521 let displayLabel = label;
17522 if (field.isValid?.required && !markWhenOptional) {
17523 displayLabel = `${label} (${(0, import_i18n33.__)("Required")})`;
17524 } else if (!field.isValid?.required && markWhenOptional) {
17525 displayLabel = `${label} (${(0, import_i18n33.__)("Optional")})`;
17526 }
17527 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17528 ValidatedDateControl,
17529 {
17530 field,
17531 validity,
17532 inputRefs: [fromInputRef, toInputRef],
17533 isTouched,
17534 setIsTouched,
17535 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17536 import_components33.BaseControl,
17537 {
17538 id,
17539 className: "dataviews-controls__date",
17540 label: displayLabel,
17541 help: description,
17542 hideLabelFromVision,
17543 children: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(Stack, { direction: "column", gap: "lg", children: [
17544 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
17545 Stack,
17546 {
17547 direction: "row",
17548 gap: "sm",
17549 wrap: "wrap",
17550 justify: "flex-start",
17551 children: [
17552 DATE_RANGE_PRESETS.map((preset) => {
17553 const isSelected2 = selectedPresetId === preset.id;
17554 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17555 import_components33.Button,
17556 {
17557 className: "dataviews-controls__date-preset",
17558 variant: "tertiary",
17559 isPressed: isSelected2,
17560 size: "small",
17561 disabled: disabled2,
17562 accessibleWhenDisabled: true,
17563 onClick: () => handlePresetClick(preset),
17564 children: preset.label
17565 },
17566 preset.id
17567 );
17568 }),
17569 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17570 import_components33.Button,
17571 {
17572 className: "dataviews-controls__date-preset",
17573 variant: "tertiary",
17574 isPressed: !selectedPresetId,
17575 size: "small",
17576 accessibleWhenDisabled: true,
17577 disabled: !!selectedPresetId || disabled2,
17578 children: (0, import_i18n33.__)("Custom")
17579 }
17580 )
17581 ]
17582 }
17583 ),
17584 /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
17585 Stack,
17586 {
17587 direction: "row",
17588 gap: "sm",
17589 justify: "space-between",
17590 className: "dataviews-controls__date-range-inputs",
17591 children: [
17592 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17593 import_components33.__experimentalInputControl,
17594 {
17595 __next40pxDefaultSize: true,
17596 ref: fromInputRef,
17597 type: "date",
17598 label: (0, import_i18n33.__)("From"),
17599 hideLabelFromVision: true,
17600 value: value?.[0],
17601 onChange: (newValue) => handleManualDateChange("from", newValue),
17602 required: !!field.isValid?.required,
17603 disabled: disabled2,
17604 min: minConstraint,
17605 max: maxConstraint
17606 }
17607 ),
17608 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17609 import_components33.__experimentalInputControl,
17610 {
17611 __next40pxDefaultSize: true,
17612 ref: toInputRef,
17613 type: "date",
17614 label: (0, import_i18n33.__)("To"),
17615 hideLabelFromVision: true,
17616 value: value?.[1],
17617 onChange: (newValue) => handleManualDateChange("to", newValue),
17618 required: !!field.isValid?.required,
17619 disabled: disabled2,
17620 min: minConstraint,
17621 max: maxConstraint
17622 }
17623 )
17624 ]
17625 }
17626 ),
17627 /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17628 DateRangeCalendar,
17629 {
17630 style: { width: "100%" },
17631 selected: selectedRange,
17632 onSelect: onSelectCalendarRange,
17633 month: calendarMonth,
17634 onMonthChange: setCalendarMonth,
17635 timeZone: timezone.string || void 0,
17636 weekStartsOn,
17637 disabled: disabled2 || disabledMatchers
17638 }
17639 )
17640 ] })
17641 }
17642 )
17643 }
17644 );
17645 }
17646 function DateControl({
17647 data,
17648 field,
17649 onChange,
17650 hideLabelFromVision,
17651 markWhenOptional,
17652 operator,
17653 validity
17654 }) {
17655 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) {
17656 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17657 RelativeDateControl,
17658 {
17659 className: "dataviews-controls__date",
17660 data,
17661 field,
17662 onChange,
17663 hideLabelFromVision,
17664 operator
17665 }
17666 );
17667 }
17668 if (operator === OPERATOR_BETWEEN) {
17669 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17670 CalendarDateRangeControl,
17671 {
17672 data,
17673 field,
17674 onChange,
17675 hideLabelFromVision,
17676 markWhenOptional,
17677 validity
17678 }
17679 );
17680 }
17681 return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
17682 CalendarDateControl,
17683 {
17684 data,
17685 field,
17686 onChange,
17687 hideLabelFromVision,
17688 markWhenOptional,
17689 validity
17690 }
17691 );
17692 }
17693
17694 // packages/dataviews/build-module/components/dataform-controls/select.mjs
17695 var import_components34 = __toESM(require_components(), 1);
17696 var import_element62 = __toESM(require_element(), 1);
17697 var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
17698 var { ValidatedSelectControl } = unlock(import_components34.privateApis);
17699 function Select({
17700 data,
17701 field,
17702 onChange,
17703 hideLabelFromVision,
17704 markWhenOptional,
17705 validity
17706 }) {
17707 const { type, label, description, getValue, setValue, isValid: isValid2 } = field;
17708 const disabled2 = field.isDisabled({ item: data, field });
17709 const isMultiple = type === "array";
17710 const value = getValue({ item: data }) ?? (isMultiple ? [] : "");
17711 const onChangeControl = (0, import_element62.useCallback)(
17712 (newValue) => onChange(setValue({ item: data, value: newValue })),
17713 [data, onChange, setValue]
17714 );
17715 const { elements, isLoading } = useElements({
17716 elements: field.elements,
17717 getElements: field.getElements
17718 });
17719 if (isLoading) {
17720 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_components34.Spinner, {});
17721 }
17722 return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
17723 ValidatedSelectControl,
17724 {
17725 required: !!field.isValid?.required,
17726 markWhenOptional,
17727 customValidity: getCustomValidity(isValid2, validity),
17728 label,
17729 value,
17730 help: description,
17731 options: elements,
17732 onChange: onChangeControl,
17733 __next40pxDefaultSize: true,
17734 hideLabelFromVision,
17735 multiple: isMultiple,
17736 disabled: disabled2
17737 }
17738 );
17739 }
17740
17741 // packages/dataviews/build-module/components/dataform-controls/adaptive-select.mjs
17742 var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);
17743 var ELEMENTS_THRESHOLD = 10;
17744 function AdaptiveSelect(props) {
17745 const { field } = props;
17746 const { elements } = useElements({
17747 elements: field.elements,
17748 getElements: field.getElements
17749 });
17750 if (elements.length >= ELEMENTS_THRESHOLD) {
17751 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Combobox3, { ...props });
17752 }
17753 return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Select, { ...props });
17754 }
17755
17756 // packages/dataviews/build-module/components/dataform-controls/email.mjs
17757 var import_components36 = __toESM(require_components(), 1);
17758
17759 // packages/dataviews/build-module/components/dataform-controls/utils/validated-input.mjs
17760 var import_components35 = __toESM(require_components(), 1);
17761 var import_element63 = __toESM(require_element(), 1);
17762 var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
17763 var { ValidatedInputControl: ValidatedInputControl2 } = unlock(import_components35.privateApis);
17764 function ValidatedText({
17765 data,
17766 field,
17767 onChange,
17768 hideLabelFromVision,
17769 markWhenOptional,
17770 type,
17771 prefix,
17772 suffix,
17773 validity
17774 }) {
17775 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
17776 const value = getValue({ item: data });
17777 const disabled2 = field.isDisabled({ item: data, field });
17778 const onChangeControl = (0, import_element63.useCallback)(
17779 (newValue) => onChange(
17780 setValue({
17781 item: data,
17782 value: newValue
17783 })
17784 ),
17785 [data, setValue, onChange]
17786 );
17787 return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
17788 ValidatedInputControl2,
17789 {
17790 required: !!isValid2.required,
17791 markWhenOptional,
17792 customValidity: getCustomValidity(isValid2, validity),
17793 label,
17794 placeholder,
17795 value: value ?? "",
17796 help: description,
17797 onChange: onChangeControl,
17798 hideLabelFromVision,
17799 type,
17800 prefix,
17801 suffix,
17802 disabled: disabled2,
17803 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0,
17804 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
17805 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
17806 __next40pxDefaultSize: true
17807 }
17808 );
17809 }
17810
17811 // packages/dataviews/build-module/components/dataform-controls/email.mjs
17812 var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
17813 function Email({
17814 data,
17815 field,
17816 onChange,
17817 hideLabelFromVision,
17818 markWhenOptional,
17819 validity
17820 }) {
17821 return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
17822 ValidatedText,
17823 {
17824 ...{
17825 data,
17826 field,
17827 onChange,
17828 hideLabelFromVision,
17829 markWhenOptional,
17830 validity,
17831 type: "email",
17832 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 }) })
17833 }
17834 }
17835 );
17836 }
17837
17838 // packages/dataviews/build-module/components/dataform-controls/telephone.mjs
17839 var import_components37 = __toESM(require_components(), 1);
17840 var import_jsx_runtime96 = __toESM(require_jsx_runtime(), 1);
17841 function Telephone({
17842 data,
17843 field,
17844 onChange,
17845 hideLabelFromVision,
17846 markWhenOptional,
17847 validity
17848 }) {
17849 return /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(
17850 ValidatedText,
17851 {
17852 ...{
17853 data,
17854 field,
17855 onChange,
17856 hideLabelFromVision,
17857 markWhenOptional,
17858 validity,
17859 type: "tel",
17860 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 }) })
17861 }
17862 }
17863 );
17864 }
17865
17866 // packages/dataviews/build-module/components/dataform-controls/url.mjs
17867 var import_components38 = __toESM(require_components(), 1);
17868 var import_jsx_runtime97 = __toESM(require_jsx_runtime(), 1);
17869 function Url({
17870 data,
17871 field,
17872 onChange,
17873 hideLabelFromVision,
17874 markWhenOptional,
17875 validity
17876 }) {
17877 return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(
17878 ValidatedText,
17879 {
17880 ...{
17881 data,
17882 field,
17883 onChange,
17884 hideLabelFromVision,
17885 markWhenOptional,
17886 validity,
17887 type: "url",
17888 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 }) })
17889 }
17890 }
17891 );
17892 }
17893
17894 // packages/dataviews/build-module/components/dataform-controls/utils/validated-number.mjs
17895 var import_components39 = __toESM(require_components(), 1);
17896 var import_element64 = __toESM(require_element(), 1);
17897 var import_i18n34 = __toESM(require_i18n(), 1);
17898 var import_jsx_runtime98 = __toESM(require_jsx_runtime(), 1);
17899 var { ValidatedNumberControl } = unlock(import_components39.privateApis);
17900 function toNumberOrEmpty(value) {
17901 if (value === "" || value === void 0) {
17902 return "";
17903 }
17904 const number = Number(value);
17905 return Number.isFinite(number) ? number : "";
17906 }
17907 function BetweenControls({
17908 value,
17909 onChange,
17910 hideLabelFromVision,
17911 step
17912 }) {
17913 const [min = "", max = ""] = value;
17914 const onChangeMin = (0, import_element64.useCallback)(
17915 (newValue) => onChange([toNumberOrEmpty(newValue), max]),
17916 [onChange, max]
17917 );
17918 const onChangeMax = (0, import_element64.useCallback)(
17919 (newValue) => onChange([min, toNumberOrEmpty(newValue)]),
17920 [onChange, min]
17921 );
17922 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17923 import_components39.BaseControl,
17924 {
17925 help: (0, import_i18n34.__)("The max. value must be greater than the min. value."),
17926 children: /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_components39.Flex, { direction: "row", gap: 4, children: [
17927 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17928 import_components39.__experimentalNumberControl,
17929 {
17930 label: (0, import_i18n34.__)("Min."),
17931 value: min,
17932 max: max ? Number(max) - step : void 0,
17933 onChange: onChangeMin,
17934 __next40pxDefaultSize: true,
17935 hideLabelFromVision,
17936 step
17937 }
17938 ),
17939 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
17940 import_components39.__experimentalNumberControl,
17941 {
17942 label: (0, import_i18n34.__)("Max."),
17943 value: max,
17944 min: min ? Number(min) + step : void 0,
17945 onChange: onChangeMax,
17946 __next40pxDefaultSize: true,
17947 hideLabelFromVision,
17948 step
17949 }
17950 )
17951 ] })
17952 }
17953 );
17954 }
17955 function ValidatedNumber({
17956 data,
17957 field,
17958 onChange,
17959 hideLabelFromVision,
17960 markWhenOptional,
17961 operator,
17962 validity
17963 }) {
17964 const decimals = field.format?.decimals ?? 0;
17965 const step = Math.pow(10, Math.abs(decimals) * -1);
17966 const { label, description, getValue, setValue, isValid: isValid2 } = field;
17967 const value = getValue({ item: data }) ?? "";
17968 const disabled2 = field.isDisabled({ item: data, field });
17969 const onChangeControl = (0, import_element64.useCallback)(
17970 (newValue) => {
17971 onChange(
17972 setValue({
17973 item: data,
17974 // Do not convert an empty string or undefined to a number,
17975 // otherwise there's a mismatch between the UI control (empty)
17976 // and the data relied by onChange (0).
17977 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue)
17978 })
17979 );
17980 },
17981 [data, onChange, setValue]
17982 );
17983 const onChangeBetweenControls = (0, import_element64.useCallback)(
17984 (newValue) => {
17985 onChange(
17986 setValue({
17987 item: data,
17988 value: newValue
17989 })
17990 );
17991 },
17992 [data, onChange, setValue]
17993 );
17994 if (operator === OPERATOR_BETWEEN) {
17995 let valueBetween = ["", ""];
17996 if (Array.isArray(value) && value.length === 2 && value.every(
17997 (element) => typeof element === "number" || element === ""
17998 )) {
17999 valueBetween = value;
18000 }
18001 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18002 BetweenControls,
18003 {
18004 value: valueBetween,
18005 onChange: onChangeBetweenControls,
18006 hideLabelFromVision,
18007 step
18008 }
18009 );
18010 }
18011 return /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(
18012 ValidatedNumberControl,
18013 {
18014 required: !!isValid2.required,
18015 markWhenOptional,
18016 customValidity: getCustomValidity(isValid2, validity),
18017 label,
18018 help: description,
18019 value,
18020 onChange: onChangeControl,
18021 __next40pxDefaultSize: true,
18022 hideLabelFromVision,
18023 step,
18024 min: isValid2.min ? isValid2.min.constraint : void 0,
18025 max: isValid2.max ? isValid2.max.constraint : void 0,
18026 disabled: disabled2
18027 }
18028 );
18029 }
18030
18031 // packages/dataviews/build-module/components/dataform-controls/integer.mjs
18032 var import_jsx_runtime99 = __toESM(require_jsx_runtime(), 1);
18033 function Integer(props) {
18034 return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(ValidatedNumber, { ...props });
18035 }
18036
18037 // packages/dataviews/build-module/components/dataform-controls/number.mjs
18038 var import_jsx_runtime100 = __toESM(require_jsx_runtime(), 1);
18039 function Number2(props) {
18040 return /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(ValidatedNumber, { ...props });
18041 }
18042
18043 // packages/dataviews/build-module/components/dataform-controls/radio.mjs
18044 var import_components40 = __toESM(require_components(), 1);
18045 var import_element65 = __toESM(require_element(), 1);
18046 var import_jsx_runtime101 = __toESM(require_jsx_runtime(), 1);
18047 var { ValidatedRadioControl } = unlock(import_components40.privateApis);
18048 function Radio({
18049 data,
18050 field,
18051 onChange,
18052 hideLabelFromVision,
18053 markWhenOptional,
18054 validity
18055 }) {
18056 const { label, description, getValue, setValue, isValid: isValid2 } = field;
18057 const disabled2 = field.isDisabled({ item: data, field });
18058 const { elements, isLoading } = useElements({
18059 elements: field.elements,
18060 getElements: field.getElements
18061 });
18062 const value = getValue({ item: data });
18063 const onChangeControl = (0, import_element65.useCallback)(
18064 (newValue) => onChange(setValue({ item: data, value: newValue })),
18065 [data, onChange, setValue]
18066 );
18067 if (isLoading) {
18068 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_components40.Spinner, {});
18069 }
18070 return /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(
18071 ValidatedRadioControl,
18072 {
18073 required: !!field.isValid?.required,
18074 markWhenOptional,
18075 customValidity: getCustomValidity(isValid2, validity),
18076 label,
18077 help: description,
18078 onChange: onChangeControl,
18079 options: elements,
18080 selected: value,
18081 hideLabelFromVision,
18082 disabled: disabled2
18083 }
18084 );
18085 }
18086
18087 // packages/dataviews/build-module/components/dataform-controls/text.mjs
18088 var import_element66 = __toESM(require_element(), 1);
18089 var import_jsx_runtime102 = __toESM(require_jsx_runtime(), 1);
18090 function Text3({
18091 data,
18092 field,
18093 onChange,
18094 hideLabelFromVision,
18095 markWhenOptional,
18096 config,
18097 validity
18098 }) {
18099 const { prefix, suffix } = config || {};
18100 return /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(
18101 ValidatedText,
18102 {
18103 ...{
18104 data,
18105 field,
18106 onChange,
18107 hideLabelFromVision,
18108 markWhenOptional,
18109 validity,
18110 prefix: prefix ? (0, import_element66.createElement)(prefix) : void 0,
18111 suffix: suffix ? (0, import_element66.createElement)(suffix) : void 0
18112 }
18113 }
18114 );
18115 }
18116
18117 // packages/dataviews/build-module/components/dataform-controls/toggle.mjs
18118 var import_components41 = __toESM(require_components(), 1);
18119 var import_element67 = __toESM(require_element(), 1);
18120 var import_jsx_runtime103 = __toESM(require_jsx_runtime(), 1);
18121 var { ValidatedToggleControl } = unlock(import_components41.privateApis);
18122 function Toggle({
18123 field,
18124 onChange,
18125 data,
18126 hideLabelFromVision,
18127 markWhenOptional,
18128 validity
18129 }) {
18130 const { label, description, getValue, setValue, isValid: isValid2 } = field;
18131 const disabled2 = field.isDisabled({ item: data, field });
18132 const onChangeControl = (0, import_element67.useCallback)(() => {
18133 onChange(
18134 setValue({ item: data, value: !getValue({ item: data }) })
18135 );
18136 }, [onChange, setValue, data, getValue]);
18137 return /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(
18138 ValidatedToggleControl,
18139 {
18140 required: !!isValid2.required,
18141 markWhenOptional,
18142 customValidity: getCustomValidity(isValid2, validity),
18143 hidden: hideLabelFromVision,
18144 label,
18145 help: description,
18146 checked: getValue({ item: data }),
18147 onChange: onChangeControl,
18148 disabled: disabled2
18149 }
18150 );
18151 }
18152
18153 // packages/dataviews/build-module/components/dataform-controls/textarea.mjs
18154 var import_components42 = __toESM(require_components(), 1);
18155 var import_element68 = __toESM(require_element(), 1);
18156 var import_jsx_runtime104 = __toESM(require_jsx_runtime(), 1);
18157 var { ValidatedTextareaControl } = unlock(import_components42.privateApis);
18158 function Textarea({
18159 data,
18160 field,
18161 onChange,
18162 hideLabelFromVision,
18163 markWhenOptional,
18164 config,
18165 validity
18166 }) {
18167 const { rows = 4 } = config || {};
18168 const disabled2 = field.isDisabled({ item: data, field });
18169 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
18170 const value = field.getValue({ item: data });
18171 const onChangeControl = (0, import_element68.useCallback)(
18172 (newValue) => onChange(setValue({ item: data, value: newValue })),
18173 [data, onChange, setValue]
18174 );
18175 return /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(
18176 ValidatedTextareaControl,
18177 {
18178 required: !!isValid2.required,
18179 markWhenOptional,
18180 customValidity: getCustomValidity(isValid2, validity),
18181 label,
18182 placeholder,
18183 value: value ?? "",
18184 help: description,
18185 onChange: onChangeControl,
18186 rows,
18187 disabled: disabled2,
18188 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0,
18189 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0,
18190 __next40pxDefaultSize: true,
18191 hideLabelFromVision
18192 }
18193 );
18194 }
18195
18196 // packages/dataviews/build-module/components/dataform-controls/toggle-group.mjs
18197 var import_components43 = __toESM(require_components(), 1);
18198 var import_element69 = __toESM(require_element(), 1);
18199 var import_jsx_runtime105 = __toESM(require_jsx_runtime(), 1);
18200 var { ValidatedToggleGroupControl } = unlock(import_components43.privateApis);
18201 function ToggleGroup({
18202 data,
18203 field,
18204 onChange,
18205 hideLabelFromVision,
18206 markWhenOptional,
18207 validity
18208 }) {
18209 const { getValue, setValue, isValid: isValid2 } = field;
18210 const disabled2 = field.isDisabled({ item: data, field });
18211 const value = getValue({ item: data });
18212 const onChangeControl = (0, import_element69.useCallback)(
18213 (newValue) => onChange(setValue({ item: data, value: newValue })),
18214 [data, onChange, setValue]
18215 );
18216 const { elements, isLoading } = useElements({
18217 elements: field.elements,
18218 getElements: field.getElements
18219 });
18220 if (isLoading) {
18221 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_components43.Spinner, {});
18222 }
18223 if (elements.length === 0) {
18224 return null;
18225 }
18226 const selectedOption = elements.find((el) => el.value === value);
18227 return /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
18228 ValidatedToggleGroupControl,
18229 {
18230 required: !!field.isValid?.required,
18231 markWhenOptional,
18232 customValidity: getCustomValidity(isValid2, validity),
18233 __next40pxDefaultSize: true,
18234 isBlock: true,
18235 label: field.label,
18236 help: selectedOption?.description || field.description,
18237 onChange: onChangeControl,
18238 value,
18239 hideLabelFromVision,
18240 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(
18241 import_components43.__experimentalToggleGroupControlOption,
18242 {
18243 label: el.label,
18244 value: el.value,
18245 disabled: disabled2
18246 },
18247 el.value
18248 ))
18249 }
18250 );
18251 }
18252
18253 // packages/dataviews/build-module/components/dataform-controls/array.mjs
18254 var import_components44 = __toESM(require_components(), 1);
18255 var import_element70 = __toESM(require_element(), 1);
18256 var import_jsx_runtime106 = __toESM(require_jsx_runtime(), 1);
18257 var { ValidatedFormTokenField } = unlock(import_components44.privateApis);
18258 function ArrayControl({
18259 data,
18260 field,
18261 onChange,
18262 hideLabelFromVision,
18263 markWhenOptional,
18264 validity
18265 }) {
18266 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field;
18267 const value = getValue({ item: data });
18268 const disabled2 = field.isDisabled({ item: data, field });
18269 const { elements, isLoading } = useElements({
18270 elements: field.elements,
18271 getElements: field.getElements
18272 });
18273 const arrayValueAsElements = (0, import_element70.useMemo)(
18274 () => Array.isArray(value) ? value.map((token) => {
18275 const element = elements?.find(
18276 (suggestion) => suggestion.value === token
18277 );
18278 return element || { value: token, label: token };
18279 }) : [],
18280 [value, elements]
18281 );
18282 const onChangeControl = (0, import_element70.useCallback)(
18283 (tokens) => {
18284 const valueTokens = tokens.map((token) => {
18285 if (typeof token === "object" && "value" in token) {
18286 return token.value;
18287 }
18288 return token;
18289 });
18290 onChange(setValue({ item: data, value: valueTokens }));
18291 },
18292 [onChange, setValue, data]
18293 );
18294 if (isLoading) {
18295 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_components44.Spinner, {});
18296 }
18297 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(
18298 ValidatedFormTokenField,
18299 {
18300 required: !!isValid2?.required,
18301 markWhenOptional,
18302 customValidity: getCustomValidity(isValid2, validity),
18303 label: hideLabelFromVision ? void 0 : label,
18304 value: arrayValueAsElements,
18305 onChange: onChangeControl,
18306 placeholder,
18307 suggestions: elements?.map((element) => element.value),
18308 disabled: disabled2,
18309 __experimentalValidateInput: (token) => {
18310 if (field.isValid?.elements && elements) {
18311 return elements.some(
18312 (element) => element.value === token || element.label === token
18313 );
18314 }
18315 return true;
18316 },
18317 __experimentalExpandOnFocus: elements && elements.length > 0,
18318 help: description ?? (field.isValid?.elements ? "" : void 0),
18319 displayTransform: (token) => {
18320 if (typeof token === "object" && "label" in token) {
18321 return token.label;
18322 }
18323 if (typeof token === "string" && elements) {
18324 const element = elements.find(
18325 (el) => el.value === token
18326 );
18327 return element?.label || token;
18328 }
18329 return token;
18330 },
18331 __experimentalRenderItem: ({ item }) => {
18332 if (typeof item === "string" && elements) {
18333 const element = elements.find(
18334 (el) => el.value === item
18335 );
18336 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: element?.label || item });
18337 }
18338 return /* @__PURE__ */ (0, import_jsx_runtime106.jsx)("span", { children: item });
18339 }
18340 }
18341 );
18342 }
18343
18344 // node_modules/colord/index.mjs
18345 var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
18346 var t = function(r3) {
18347 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
18348 };
18349 var n = function(r3, t2, n2) {
18350 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = Math.pow(10, t2)), Math.round(n2 * r3) / n2 + 0;
18351 };
18352 var e = function(r3, t2, n2) {
18353 return void 0 === t2 && (t2 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t2 ? r3 : t2;
18354 };
18355 var u = function(r3) {
18356 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
18357 };
18358 var a = function(r3) {
18359 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
18360 };
18361 var o = function(r3) {
18362 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
18363 };
18364 var i = /^#([0-9a-f]{3,8})$/i;
18365 var s = function(r3) {
18366 var t2 = r3.toString(16);
18367 return t2.length < 2 ? "0" + t2 : t2;
18368 };
18369 var h = function(r3) {
18370 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;
18371 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o2 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
18372 };
18373 var b = function(r3) {
18374 var t2 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
18375 t2 = t2 / 360 * 6, n2 /= 100, e2 /= 100;
18376 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;
18377 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 };
18378 };
18379 var g = function(r3) {
18380 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
18381 };
18382 var d = function(r3) {
18383 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
18384 };
18385 var f = function(r3) {
18386 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 }));
18387 var t2, n2, e2;
18388 };
18389 var c = function(r3) {
18390 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 };
18391 var t2, n2, e2, u2;
18392 };
18393 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
18394 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
18395 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
18396 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
18397 var y = { string: [[function(r3) {
18398 var t2 = i.exec(r3);
18399 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;
18400 }, "hex"], [function(r3) {
18401 var t2 = v.exec(r3) || m.exec(r3);
18402 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;
18403 }, "rgb"], [function(t2) {
18404 var n2 = l.exec(t2) || p.exec(t2);
18405 if (!n2) return null;
18406 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) });
18407 return f(a2);
18408 }, "hsl"]], object: [[function(r3) {
18409 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o2 = r3.a, i2 = void 0 === o2 ? 1 : o2;
18410 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
18411 }, "rgb"], [function(r3) {
18412 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o2 = void 0 === a2 ? 1 : a2;
18413 if (!t(n2) || !t(e2) || !t(u2)) return null;
18414 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o2) });
18415 return f(i2);
18416 }, "hsl"], [function(r3) {
18417 var n2 = r3.h, a2 = r3.s, o2 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
18418 if (!t(n2) || !t(a2) || !t(o2)) return null;
18419 var h2 = (function(r4) {
18420 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
18421 })({ h: Number(n2), s: Number(a2), v: Number(o2), a: Number(s2) });
18422 return b(h2);
18423 }, "hsv"]] };
18424 var N = function(r3, t2) {
18425 for (var n2 = 0; n2 < t2.length; n2++) {
18426 var e2 = t2[n2][0](r3);
18427 if (e2) return [e2, t2[n2][1]];
18428 }
18429 return [null, void 0];
18430 };
18431 var x = function(r3) {
18432 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
18433 };
18434 var M = function(r3, t2) {
18435 var n2 = c(r3);
18436 return { h: n2.h, s: e(n2.s + 100 * t2, 0, 100), l: n2.l, a: n2.a };
18437 };
18438 var H = function(r3) {
18439 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
18440 };
18441 var $ = function(r3, t2) {
18442 var n2 = c(r3);
18443 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t2, 0, 100), a: n2.a };
18444 };
18445 var j = (function() {
18446 function r3(r4) {
18447 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
18448 }
18449 return r3.prototype.isValid = function() {
18450 return null !== this.parsed;
18451 }, r3.prototype.brightness = function() {
18452 return n(H(this.rgba), 2);
18453 }, r3.prototype.isDark = function() {
18454 return H(this.rgba) < 0.5;
18455 }, r3.prototype.isLight = function() {
18456 return H(this.rgba) >= 0.5;
18457 }, r3.prototype.toHex = function() {
18458 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;
18459 var r4, t2, e2, u2, a2, i2;
18460 }, r3.prototype.toRgb = function() {
18461 return o(this.rgba);
18462 }, r3.prototype.toRgbString = function() {
18463 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 + ")";
18464 var r4, t2, n2, e2, u2;
18465 }, r3.prototype.toHsl = function() {
18466 return d(c(this.rgba));
18467 }, r3.prototype.toHslString = function() {
18468 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 + "%)";
18469 var r4, t2, n2, e2, u2;
18470 }, r3.prototype.toHsv = function() {
18471 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
18472 var r4;
18473 }, r3.prototype.invert = function() {
18474 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
18475 var r4;
18476 }, r3.prototype.saturate = function(r4) {
18477 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
18478 }, r3.prototype.desaturate = function(r4) {
18479 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
18480 }, r3.prototype.grayscale = function() {
18481 return w(M(this.rgba, -1));
18482 }, r3.prototype.lighten = function(r4) {
18483 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
18484 }, r3.prototype.darken = function(r4) {
18485 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
18486 }, r3.prototype.rotate = function(r4) {
18487 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
18488 }, r3.prototype.alpha = function(r4) {
18489 return "number" == typeof r4 ? w({ r: (t2 = this.rgba).r, g: t2.g, b: t2.b, a: r4 }) : n(this.rgba.a, 3);
18490 var t2;
18491 }, r3.prototype.hue = function(r4) {
18492 var t2 = c(this.rgba);
18493 return "number" == typeof r4 ? w({ h: r4, s: t2.s, l: t2.l, a: t2.a }) : n(t2.h);
18494 }, r3.prototype.isEqual = function(r4) {
18495 return this.toHex() === w(r4).toHex();
18496 }, r3;
18497 })();
18498 var w = function(r3) {
18499 return r3 instanceof j ? r3 : new j(r3);
18500 };
18501
18502 // packages/dataviews/build-module/components/dataform-controls/color.mjs
18503 var import_components45 = __toESM(require_components(), 1);
18504 var import_element71 = __toESM(require_element(), 1);
18505 var import_i18n35 = __toESM(require_i18n(), 1);
18506 var import_jsx_runtime107 = __toESM(require_jsx_runtime(), 1);
18507 var { ValidatedInputControl: ValidatedInputControl3 } = unlock(import_components45.privateApis);
18508 var ColorPickerDropdown = ({
18509 color,
18510 onColorChange,
18511 disabled: disabled2
18512 }) => {
18513 const validColor = color && w(color).isValid() ? color : "#ffffff";
18514 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18515 import_components45.Dropdown,
18516 {
18517 className: "dataviews-controls__color-picker-dropdown",
18518 popoverProps: { resize: false },
18519 renderToggle: ({ onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18520 import_components45.Button,
18521 {
18522 onClick: onToggle,
18523 "aria-label": (0, import_i18n35.__)("Open color picker"),
18524 size: "small",
18525 disabled: disabled2,
18526 accessibleWhenDisabled: true,
18527 icon: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.ColorIndicator, { colorValue: validColor })
18528 }
18529 ),
18530 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18531 import_components45.ColorPicker,
18532 {
18533 color: validColor,
18534 onChange: onColorChange,
18535 enableAlpha: true
18536 }
18537 ) })
18538 }
18539 );
18540 };
18541 function Color({
18542 data,
18543 field,
18544 onChange,
18545 hideLabelFromVision,
18546 markWhenOptional,
18547 validity
18548 }) {
18549 const { label, placeholder, description, setValue, isValid: isValid2 } = field;
18550 const disabled2 = field.isDisabled({ item: data, field });
18551 const value = field.getValue({ item: data }) || "";
18552 const handleColorChange = (0, import_element71.useCallback)(
18553 (newColor) => {
18554 onChange(setValue({ item: data, value: newColor }));
18555 },
18556 [data, onChange, setValue]
18557 );
18558 const handleInputChange = (0, import_element71.useCallback)(
18559 (newValue) => {
18560 onChange(setValue({ item: data, value: newValue || "" }));
18561 },
18562 [data, onChange, setValue]
18563 );
18564 return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18565 ValidatedInputControl3,
18566 {
18567 required: !!field.isValid?.required,
18568 markWhenOptional,
18569 customValidity: getCustomValidity(isValid2, validity),
18570 label,
18571 placeholder,
18572 value,
18573 help: description,
18574 onChange: handleInputChange,
18575 hideLabelFromVision,
18576 type: "text",
18577 disabled: disabled2,
18578 prefix: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_components45.__experimentalInputControlPrefixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(
18579 ColorPickerDropdown,
18580 {
18581 color: value,
18582 onColorChange: handleColorChange,
18583 disabled: disabled2
18584 }
18585 ) })
18586 }
18587 );
18588 }
18589
18590 // packages/dataviews/build-module/components/dataform-controls/password.mjs
18591 var import_components46 = __toESM(require_components(), 1);
18592 var import_element72 = __toESM(require_element(), 1);
18593 var import_i18n36 = __toESM(require_i18n(), 1);
18594 var import_jsx_runtime108 = __toESM(require_jsx_runtime(), 1);
18595 function Password({
18596 data,
18597 field,
18598 onChange,
18599 hideLabelFromVision,
18600 markWhenOptional,
18601 validity
18602 }) {
18603 const [isVisible2, setIsVisible] = (0, import_element72.useState)(false);
18604 const disabled2 = field.isDisabled({ item: data, field });
18605 const toggleVisibility = (0, import_element72.useCallback)(() => {
18606 setIsVisible((prev) => !prev);
18607 }, []);
18608 return /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
18609 ValidatedText,
18610 {
18611 ...{
18612 data,
18613 field,
18614 onChange,
18615 hideLabelFromVision,
18616 markWhenOptional,
18617 validity,
18618 type: isVisible2 ? "text" : "password",
18619 suffix: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_components46.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(
18620 import_components46.Button,
18621 {
18622 icon: isVisible2 ? unseen_default : seen_default,
18623 onClick: toggleVisibility,
18624 size: "small",
18625 label: isVisible2 ? (0, import_i18n36.__)("Hide password") : (0, import_i18n36.__)("Show password"),
18626 disabled: disabled2,
18627 accessibleWhenDisabled: true
18628 }
18629 ) })
18630 }
18631 }
18632 );
18633 }
18634
18635 // packages/dataviews/build-module/field-types/utils/has-elements.mjs
18636 function hasElements(field) {
18637 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function";
18638 }
18639
18640 // packages/dataviews/build-module/components/dataform-controls/index.mjs
18641 var import_jsx_runtime109 = __toESM(require_jsx_runtime(), 1);
18642 var FORM_CONTROLS = {
18643 adaptiveSelect: AdaptiveSelect,
18644 array: ArrayControl,
18645 checkbox: Checkbox,
18646 color: Color,
18647 combobox: Combobox3,
18648 datetime: DateTime,
18649 date: DateControl,
18650 email: Email,
18651 telephone: Telephone,
18652 url: Url,
18653 integer: Integer,
18654 number: Number2,
18655 password: Password,
18656 radio: Radio,
18657 select: Select,
18658 text: Text3,
18659 toggle: Toggle,
18660 textarea: Textarea,
18661 toggleGroup: ToggleGroup
18662 };
18663 function isEditConfig(value) {
18664 return value && typeof value === "object" && typeof value.control === "string";
18665 }
18666 function createConfiguredControl(config) {
18667 const { control, ...controlConfig } = config;
18668 const BaseControlType = getControlByType(control);
18669 if (BaseControlType === null) {
18670 return null;
18671 }
18672 return function ConfiguredControl(props) {
18673 return /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(BaseControlType, { ...props, config: controlConfig });
18674 };
18675 }
18676 function getControl(field, fallback) {
18677 if (typeof field.Edit === "function") {
18678 return field.Edit;
18679 }
18680 if (typeof field.Edit === "string") {
18681 return getControlByType(field.Edit);
18682 }
18683 if (isEditConfig(field.Edit)) {
18684 return createConfiguredControl(field.Edit);
18685 }
18686 if (hasElements(field) && field.type !== "array") {
18687 return getControlByType("adaptiveSelect");
18688 }
18689 if (fallback === null) {
18690 return null;
18691 }
18692 return getControlByType(fallback);
18693 }
18694 function getControlByType(type) {
18695 if (Object.keys(FORM_CONTROLS).includes(type)) {
18696 return FORM_CONTROLS[type];
18697 }
18698 return null;
18699 }
18700
18701 // packages/dataviews/build-module/field-types/utils/get-filter-by.mjs
18702 function getFilterBy(field, defaultOperators, validOperators) {
18703 if (field.filterBy === false) {
18704 return false;
18705 }
18706 const operators = field.filterBy?.operators?.filter(
18707 (op) => validOperators.includes(op)
18708 ) ?? defaultOperators;
18709 if (operators.length === 0) {
18710 return false;
18711 }
18712 return {
18713 isPrimary: !!field.filterBy?.isPrimary,
18714 operators
18715 };
18716 }
18717 var get_filter_by_default = getFilterBy;
18718
18719 // packages/dataviews/build-module/field-types/utils/get-value-from-id.mjs
18720 var getValueFromId = (id) => ({ item }) => {
18721 const path = id.split(".");
18722 let value = item;
18723 for (const segment of path) {
18724 if (value.hasOwnProperty(segment)) {
18725 value = value[segment];
18726 } else {
18727 value = void 0;
18728 }
18729 }
18730 return value;
18731 };
18732 var get_value_from_id_default = getValueFromId;
18733
18734 // packages/dataviews/build-module/field-types/utils/set-value-from-id.mjs
18735 var setValueFromId = (id) => ({ value }) => {
18736 const path = id.split(".");
18737 const result = {};
18738 let current = result;
18739 for (const segment of path.slice(0, -1)) {
18740 current[segment] = {};
18741 current = current[segment];
18742 }
18743 current[path.at(-1)] = value;
18744 return result;
18745 };
18746 var set_value_from_id_default = setValueFromId;
18747
18748 // packages/dataviews/build-module/field-types/email.mjs
18749 var import_i18n37 = __toESM(require_i18n(), 1);
18750
18751 // packages/dataviews/build-module/field-types/utils/render-from-elements.mjs
18752 function RenderFromElements({
18753 item,
18754 field
18755 }) {
18756 const { elements, isLoading } = useElements({
18757 elements: field.elements,
18758 getElements: field.getElements
18759 });
18760 const value = field.getValue({ item });
18761 if (isLoading) {
18762 return value;
18763 }
18764 if (elements.length === 0) {
18765 return value;
18766 }
18767 return elements?.find((element) => element.value === value)?.label || field.getValue({ item });
18768 }
18769
18770 // packages/dataviews/build-module/field-types/utils/render-default.mjs
18771 var import_jsx_runtime110 = __toESM(require_jsx_runtime(), 1);
18772 function render({
18773 item,
18774 field
18775 }) {
18776 if (field.hasElements) {
18777 return /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(RenderFromElements, { item, field });
18778 }
18779 return field.getValueFormatted({ item, field });
18780 }
18781
18782 // packages/dataviews/build-module/field-types/utils/sort-text.mjs
18783 var sort_text_default = (a2, b2, direction) => {
18784 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2);
18785 };
18786
18787 // packages/dataviews/build-module/field-types/utils/is-valid-required.mjs
18788 function isValidRequired(item, field) {
18789 const value = field.getValue({ item });
18790 return ![void 0, "", null].includes(value);
18791 }
18792
18793 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.mjs
18794 function isValidMinLength(item, field) {
18795 if (typeof field.isValid.minLength?.constraint !== "number") {
18796 return false;
18797 }
18798 const value = field.getValue({ item });
18799 if ([void 0, "", null].includes(value)) {
18800 return true;
18801 }
18802 return String(value).length >= field.isValid.minLength.constraint;
18803 }
18804
18805 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.mjs
18806 function isValidMaxLength(item, field) {
18807 if (typeof field.isValid.maxLength?.constraint !== "number") {
18808 return false;
18809 }
18810 const value = field.getValue({ item });
18811 if ([void 0, "", null].includes(value)) {
18812 return true;
18813 }
18814 return String(value).length <= field.isValid.maxLength.constraint;
18815 }
18816
18817 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.mjs
18818 function isValidPattern(item, field) {
18819 if (field.isValid.pattern?.constraint === void 0) {
18820 return true;
18821 }
18822 try {
18823 const regexp = new RegExp(field.isValid.pattern.constraint);
18824 const value = field.getValue({ item });
18825 if ([void 0, "", null].includes(value)) {
18826 return true;
18827 }
18828 return regexp.test(String(value));
18829 } catch {
18830 return false;
18831 }
18832 }
18833
18834 // packages/dataviews/build-module/field-types/utils/is-valid-elements.mjs
18835 function isValidElements(item, field) {
18836 const elements = field.elements ?? [];
18837 const validValues = elements.map((el) => el.value);
18838 if (validValues.length === 0) {
18839 return true;
18840 }
18841 const value = field.getValue({ item });
18842 return [].concat(value).every((v2) => validValues.includes(v2));
18843 }
18844
18845 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.mjs
18846 function getValueFormatted({
18847 item,
18848 field
18849 }) {
18850 return field.getValue({ item });
18851 }
18852 var get_value_formatted_default_default = getValueFormatted;
18853
18854 // packages/dataviews/build-module/field-types/email.mjs
18855 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])?)*$/;
18856 function isValidCustom(item, field) {
18857 const value = field.getValue({ item });
18858 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) {
18859 return (0, import_i18n37.__)("Value must be a valid email address.");
18860 }
18861 return null;
18862 }
18863 var email_default = {
18864 type: "email",
18865 render,
18866 Edit: "email",
18867 sort: sort_text_default,
18868 enableSorting: true,
18869 enableGlobalSearch: false,
18870 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
18871 validOperators: [
18872 OPERATOR_IS,
18873 OPERATOR_IS_NOT,
18874 OPERATOR_CONTAINS,
18875 OPERATOR_NOT_CONTAINS,
18876 OPERATOR_STARTS_WITH,
18877 // Multiple selection
18878 OPERATOR_IS_ANY,
18879 OPERATOR_IS_NONE,
18880 OPERATOR_IS_ALL,
18881 OPERATOR_IS_NOT_ALL
18882 ],
18883 format: {},
18884 getValueFormatted: get_value_formatted_default_default,
18885 validate: {
18886 required: isValidRequired,
18887 pattern: isValidPattern,
18888 minLength: isValidMinLength,
18889 maxLength: isValidMaxLength,
18890 elements: isValidElements,
18891 custom: isValidCustom
18892 }
18893 };
18894
18895 // packages/dataviews/build-module/field-types/integer.mjs
18896 var import_i18n38 = __toESM(require_i18n(), 1);
18897
18898 // packages/dataviews/build-module/field-types/utils/sort-number.mjs
18899 var sort_number_default = (a2, b2, direction) => {
18900 return direction === "asc" ? a2 - b2 : b2 - a2;
18901 };
18902
18903 // packages/dataviews/build-module/field-types/utils/is-valid-min.mjs
18904 function isValidMin(item, field) {
18905 if (typeof field.isValid.min?.constraint !== "number") {
18906 return false;
18907 }
18908 const value = field.getValue({ item });
18909 if ([void 0, "", null].includes(value)) {
18910 return true;
18911 }
18912 return Number(value) >= field.isValid.min.constraint;
18913 }
18914
18915 // packages/dataviews/build-module/field-types/utils/is-valid-max.mjs
18916 function isValidMax(item, field) {
18917 if (typeof field.isValid.max?.constraint !== "number") {
18918 return false;
18919 }
18920 const value = field.getValue({ item });
18921 if ([void 0, "", null].includes(value)) {
18922 return true;
18923 }
18924 return Number(value) <= field.isValid.max.constraint;
18925 }
18926
18927 // packages/dataviews/build-module/field-types/integer.mjs
18928 var format2 = {
18929 separatorThousand: ","
18930 };
18931 function getValueFormatted2({
18932 item,
18933 field
18934 }) {
18935 let value = field.getValue({ item });
18936 if (value === null || value === void 0) {
18937 return "";
18938 }
18939 value = Number(value);
18940 if (!Number.isFinite(value)) {
18941 return String(value);
18942 }
18943 let formatInteger;
18944 if (field.type !== "integer") {
18945 formatInteger = format2;
18946 } else {
18947 formatInteger = field.format;
18948 }
18949 const { separatorThousand } = formatInteger;
18950 const integerValue = Math.trunc(value);
18951 if (!separatorThousand) {
18952 return String(integerValue);
18953 }
18954 return String(integerValue).replace(
18955 /\B(?=(\d{3})+(?!\d))/g,
18956 separatorThousand
18957 );
18958 }
18959 function isValidCustom2(item, field) {
18960 const value = field.getValue({ item });
18961 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) {
18962 return (0, import_i18n38.__)("Value must be an integer.");
18963 }
18964 return null;
18965 }
18966 var integer_default = {
18967 type: "integer",
18968 render,
18969 Edit: "integer",
18970 sort: sort_number_default,
18971 enableSorting: true,
18972 enableGlobalSearch: false,
18973 defaultOperators: [
18974 OPERATOR_IS,
18975 OPERATOR_IS_NOT,
18976 OPERATOR_LESS_THAN,
18977 OPERATOR_GREATER_THAN,
18978 OPERATOR_LESS_THAN_OR_EQUAL,
18979 OPERATOR_GREATER_THAN_OR_EQUAL,
18980 OPERATOR_BETWEEN
18981 ],
18982 validOperators: [
18983 // Single-selection
18984 OPERATOR_IS,
18985 OPERATOR_IS_NOT,
18986 OPERATOR_LESS_THAN,
18987 OPERATOR_GREATER_THAN,
18988 OPERATOR_LESS_THAN_OR_EQUAL,
18989 OPERATOR_GREATER_THAN_OR_EQUAL,
18990 OPERATOR_BETWEEN,
18991 // Multiple-selection
18992 OPERATOR_IS_ANY,
18993 OPERATOR_IS_NONE,
18994 OPERATOR_IS_ALL,
18995 OPERATOR_IS_NOT_ALL
18996 ],
18997 format: format2,
18998 getValueFormatted: getValueFormatted2,
18999 validate: {
19000 required: isValidRequired,
19001 min: isValidMin,
19002 max: isValidMax,
19003 elements: isValidElements,
19004 custom: isValidCustom2
19005 }
19006 };
19007
19008 // packages/dataviews/build-module/field-types/number.mjs
19009 var import_i18n39 = __toESM(require_i18n(), 1);
19010 var format3 = {
19011 separatorThousand: ",",
19012 separatorDecimal: ".",
19013 decimals: 2
19014 };
19015 function getValueFormatted3({
19016 item,
19017 field
19018 }) {
19019 let value = field.getValue({ item });
19020 if (value === null || value === void 0) {
19021 return "";
19022 }
19023 value = Number(value);
19024 if (!Number.isFinite(value)) {
19025 return String(value);
19026 }
19027 let formatNumber;
19028 if (field.type !== "number") {
19029 formatNumber = format3;
19030 } else {
19031 formatNumber = field.format;
19032 }
19033 const { separatorThousand, separatorDecimal, decimals } = formatNumber;
19034 const fixedValue = value.toFixed(decimals);
19035 const [integerPart, decimalPart] = fixedValue.split(".");
19036 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart;
19037 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart;
19038 }
19039 function isEmpty2(value) {
19040 return value === "" || value === void 0 || value === null;
19041 }
19042 function isValidCustom3(item, field) {
19043 const value = field.getValue({ item });
19044 if (!isEmpty2(value) && !Number.isFinite(value)) {
19045 return (0, import_i18n39.__)("Value must be a number.");
19046 }
19047 return null;
19048 }
19049 var number_default = {
19050 type: "number",
19051 render,
19052 Edit: "number",
19053 sort: sort_number_default,
19054 enableSorting: true,
19055 enableGlobalSearch: false,
19056 defaultOperators: [
19057 OPERATOR_IS,
19058 OPERATOR_IS_NOT,
19059 OPERATOR_LESS_THAN,
19060 OPERATOR_GREATER_THAN,
19061 OPERATOR_LESS_THAN_OR_EQUAL,
19062 OPERATOR_GREATER_THAN_OR_EQUAL,
19063 OPERATOR_BETWEEN
19064 ],
19065 validOperators: [
19066 // Single-selection
19067 OPERATOR_IS,
19068 OPERATOR_IS_NOT,
19069 OPERATOR_LESS_THAN,
19070 OPERATOR_GREATER_THAN,
19071 OPERATOR_LESS_THAN_OR_EQUAL,
19072 OPERATOR_GREATER_THAN_OR_EQUAL,
19073 OPERATOR_BETWEEN,
19074 // Multiple-selection
19075 OPERATOR_IS_ANY,
19076 OPERATOR_IS_NONE,
19077 OPERATOR_IS_ALL,
19078 OPERATOR_IS_NOT_ALL
19079 ],
19080 format: format3,
19081 getValueFormatted: getValueFormatted3,
19082 validate: {
19083 required: isValidRequired,
19084 min: isValidMin,
19085 max: isValidMax,
19086 elements: isValidElements,
19087 custom: isValidCustom3
19088 }
19089 };
19090
19091 // packages/dataviews/build-module/field-types/text.mjs
19092 var text_default = {
19093 type: "text",
19094 render,
19095 Edit: "text",
19096 sort: sort_text_default,
19097 enableSorting: true,
19098 enableGlobalSearch: false,
19099 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
19100 validOperators: [
19101 // Single selection
19102 OPERATOR_IS,
19103 OPERATOR_IS_NOT,
19104 OPERATOR_CONTAINS,
19105 OPERATOR_NOT_CONTAINS,
19106 OPERATOR_STARTS_WITH,
19107 // Multiple selection
19108 OPERATOR_IS_ANY,
19109 OPERATOR_IS_NONE,
19110 OPERATOR_IS_ALL,
19111 OPERATOR_IS_NOT_ALL
19112 ],
19113 format: {},
19114 getValueFormatted: get_value_formatted_default_default,
19115 validate: {
19116 required: isValidRequired,
19117 pattern: isValidPattern,
19118 minLength: isValidMinLength,
19119 maxLength: isValidMaxLength,
19120 elements: isValidElements
19121 }
19122 };
19123
19124 // packages/dataviews/build-module/field-types/datetime.mjs
19125 var import_date7 = __toESM(require_date(), 1);
19126
19127 // packages/dataviews/build-module/field-types/utils/is-valid-date-boundary.mjs
19128 var import_date6 = __toESM(require_date(), 1);
19129 function parseDateLike(value) {
19130 if (!value) {
19131 return null;
19132 }
19133 if (!isValid(new Date(value))) {
19134 return null;
19135 }
19136 const parsed = (0, import_date6.getDate)(value);
19137 return parsed && isValid(parsed) ? parsed : null;
19138 }
19139 function validateDateLikeBoundary(item, field, boundary) {
19140 const constraint = field.isValid[boundary]?.constraint;
19141 if (typeof constraint !== "string") {
19142 return false;
19143 }
19144 const value = field.getValue({ item });
19145 const boundaryValue = Array.isArray(value) ? value[boundary === "min" ? 0 : value.length - 1] : value;
19146 if (boundaryValue === void 0 || boundaryValue === null || boundaryValue === "") {
19147 return true;
19148 }
19149 const parsedConstraint = parseDateLike(constraint);
19150 const parsedValue = parseDateLike(String(boundaryValue));
19151 return !!parsedConstraint && !!parsedValue && (boundary === "min" ? parsedValue.getTime() >= parsedConstraint.getTime() : parsedValue.getTime() <= parsedConstraint.getTime());
19152 }
19153 function isValidMinDate(item, field) {
19154 return validateDateLikeBoundary(item, field, "min");
19155 }
19156 function isValidMaxDate(item, field) {
19157 return validateDateLikeBoundary(item, field, "max");
19158 }
19159
19160 // packages/dataviews/build-module/field-types/datetime.mjs
19161 var format4 = {
19162 datetime: (0, import_date7.getSettings)().formats.datetime,
19163 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek
19164 };
19165 function getValueFormatted4({
19166 item,
19167 field
19168 }) {
19169 const value = field.getValue({ item });
19170 if (["", void 0, null].includes(value)) {
19171 return "";
19172 }
19173 let formatDatetime;
19174 if (field.type !== "datetime") {
19175 formatDatetime = format4;
19176 } else {
19177 formatDatetime = field.format;
19178 }
19179 return (0, import_date7.dateI18n)(formatDatetime.datetime, (0, import_date7.getDate)(value));
19180 }
19181 var sort = (a2, b2, direction) => {
19182 const timeA = new Date(a2).getTime();
19183 const timeB = new Date(b2).getTime();
19184 return direction === "asc" ? timeA - timeB : timeB - timeA;
19185 };
19186 var datetime_default = {
19187 type: "datetime",
19188 render,
19189 Edit: "datetime",
19190 sort,
19191 enableSorting: true,
19192 enableGlobalSearch: false,
19193 defaultOperators: [
19194 OPERATOR_ON,
19195 OPERATOR_NOT_ON,
19196 OPERATOR_BEFORE,
19197 OPERATOR_AFTER,
19198 OPERATOR_BEFORE_INC,
19199 OPERATOR_AFTER_INC,
19200 OPERATOR_IN_THE_PAST,
19201 OPERATOR_OVER
19202 ],
19203 validOperators: [
19204 OPERATOR_ON,
19205 OPERATOR_NOT_ON,
19206 OPERATOR_BEFORE,
19207 OPERATOR_AFTER,
19208 OPERATOR_BEFORE_INC,
19209 OPERATOR_AFTER_INC,
19210 OPERATOR_IN_THE_PAST,
19211 OPERATOR_OVER
19212 ],
19213 format: format4,
19214 getValueFormatted: getValueFormatted4,
19215 validate: {
19216 required: isValidRequired,
19217 elements: isValidElements,
19218 min: isValidMinDate,
19219 max: isValidMaxDate
19220 }
19221 };
19222
19223 // packages/dataviews/build-module/field-types/date.mjs
19224 var import_date8 = __toESM(require_date(), 1);
19225 var format5 = {
19226 date: (0, import_date8.getSettings)().formats.date,
19227 weekStartsOn: (0, import_date8.getSettings)().l10n.startOfWeek
19228 };
19229 function getValueFormatted5({
19230 item,
19231 field
19232 }) {
19233 const value = field.getValue({ item });
19234 if (["", void 0, null].includes(value)) {
19235 return "";
19236 }
19237 let formatDate2;
19238 if (field.type !== "date") {
19239 formatDate2 = format5;
19240 } else {
19241 formatDate2 = field.format;
19242 }
19243 return (0, import_date8.dateI18n)(formatDate2.date, (0, import_date8.getDate)(value));
19244 }
19245 var sort2 = (a2, b2, direction) => {
19246 const timeA = new Date(a2).getTime();
19247 const timeB = new Date(b2).getTime();
19248 return direction === "asc" ? timeA - timeB : timeB - timeA;
19249 };
19250 var date_default = {
19251 type: "date",
19252 render,
19253 Edit: "date",
19254 sort: sort2,
19255 enableSorting: true,
19256 enableGlobalSearch: false,
19257 defaultOperators: [
19258 OPERATOR_ON,
19259 OPERATOR_NOT_ON,
19260 OPERATOR_BEFORE,
19261 OPERATOR_AFTER,
19262 OPERATOR_BEFORE_INC,
19263 OPERATOR_AFTER_INC,
19264 OPERATOR_IN_THE_PAST,
19265 OPERATOR_OVER,
19266 OPERATOR_BETWEEN
19267 ],
19268 validOperators: [
19269 OPERATOR_ON,
19270 OPERATOR_NOT_ON,
19271 OPERATOR_BEFORE,
19272 OPERATOR_AFTER,
19273 OPERATOR_BEFORE_INC,
19274 OPERATOR_AFTER_INC,
19275 OPERATOR_IN_THE_PAST,
19276 OPERATOR_OVER,
19277 OPERATOR_BETWEEN
19278 ],
19279 format: format5,
19280 getValueFormatted: getValueFormatted5,
19281 validate: {
19282 required: isValidRequired,
19283 elements: isValidElements,
19284 min: isValidMinDate,
19285 max: isValidMaxDate
19286 }
19287 };
19288
19289 // packages/dataviews/build-module/field-types/boolean.mjs
19290 var import_i18n40 = __toESM(require_i18n(), 1);
19291
19292 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.mjs
19293 function isValidRequiredForBool(item, field) {
19294 const value = field.getValue({ item });
19295 return value === true;
19296 }
19297
19298 // packages/dataviews/build-module/field-types/boolean.mjs
19299 function getValueFormatted6({
19300 item,
19301 field
19302 }) {
19303 const value = field.getValue({ item });
19304 if (value === true) {
19305 return (0, import_i18n40.__)("True");
19306 }
19307 if (value === false) {
19308 return (0, import_i18n40.__)("False");
19309 }
19310 return "";
19311 }
19312 function isValidCustom4(item, field) {
19313 const value = field.getValue({ item });
19314 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) {
19315 return (0, import_i18n40.__)("Value must be true, false, or undefined");
19316 }
19317 return null;
19318 }
19319 var sort3 = (a2, b2, direction) => {
19320 const boolA = Boolean(a2);
19321 const boolB = Boolean(b2);
19322 if (boolA === boolB) {
19323 return 0;
19324 }
19325 if (direction === "asc") {
19326 return boolA ? 1 : -1;
19327 }
19328 return boolA ? -1 : 1;
19329 };
19330 var boolean_default = {
19331 type: "boolean",
19332 render,
19333 Edit: "checkbox",
19334 sort: sort3,
19335 validate: {
19336 required: isValidRequiredForBool,
19337 elements: isValidElements,
19338 custom: isValidCustom4
19339 },
19340 enableSorting: true,
19341 enableGlobalSearch: false,
19342 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
19343 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
19344 format: {},
19345 getValueFormatted: getValueFormatted6
19346 };
19347
19348 // packages/dataviews/build-module/field-types/media.mjs
19349 var media_default = {
19350 type: "media",
19351 render: () => null,
19352 Edit: null,
19353 sort: () => 0,
19354 enableSorting: false,
19355 enableGlobalSearch: false,
19356 defaultOperators: [],
19357 validOperators: [],
19358 format: {},
19359 getValueFormatted: get_value_formatted_default_default,
19360 // cannot validate any constraint, so
19361 // the only available validation for the field author
19362 // would be providing a custom validator.
19363 validate: {}
19364 };
19365
19366 // packages/dataviews/build-module/field-types/array.mjs
19367 var import_i18n41 = __toESM(require_i18n(), 1);
19368
19369 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.mjs
19370 function isValidRequiredForArray(item, field) {
19371 const value = field.getValue({ item });
19372 return Array.isArray(value) && value.length > 0 && value.every(
19373 (element) => ![void 0, "", null].includes(element)
19374 );
19375 }
19376
19377 // packages/dataviews/build-module/field-types/array.mjs
19378 function getValueFormatted7({
19379 item,
19380 field
19381 }) {
19382 const value = field.getValue({ item });
19383 const arr = Array.isArray(value) ? value : [];
19384 return arr.join(", ");
19385 }
19386 function render2({ item, field }) {
19387 return getValueFormatted7({ item, field });
19388 }
19389 function isValidCustom5(item, field) {
19390 const value = field.getValue({ item });
19391 if (![void 0, "", null].includes(value) && !Array.isArray(value)) {
19392 return (0, import_i18n41.__)("Value must be an array.");
19393 }
19394 if (!value.every((v2) => typeof v2 === "string")) {
19395 return (0, import_i18n41.__)("Every value must be a string.");
19396 }
19397 return null;
19398 }
19399 var sort4 = (a2, b2, direction) => {
19400 const arrA = Array.isArray(a2) ? a2 : [];
19401 const arrB = Array.isArray(b2) ? b2 : [];
19402 if (arrA.length !== arrB.length) {
19403 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length;
19404 }
19405 const joinedA = arrA.join(",");
19406 const joinedB = arrB.join(",");
19407 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA);
19408 };
19409 var array_default = {
19410 type: "array",
19411 render: render2,
19412 Edit: "array",
19413 sort: sort4,
19414 enableSorting: true,
19415 enableGlobalSearch: false,
19416 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
19417 validOperators: [
19418 OPERATOR_IS_ANY,
19419 OPERATOR_IS_NONE,
19420 OPERATOR_IS_ALL,
19421 OPERATOR_IS_NOT_ALL
19422 ],
19423 format: {},
19424 getValueFormatted: getValueFormatted7,
19425 validate: {
19426 required: isValidRequiredForArray,
19427 elements: isValidElements,
19428 custom: isValidCustom5
19429 }
19430 };
19431
19432 // packages/dataviews/build-module/field-types/password.mjs
19433 function getValueFormatted8({
19434 item,
19435 field
19436 }) {
19437 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : "";
19438 }
19439 var password_default = {
19440 type: "password",
19441 render,
19442 Edit: "password",
19443 sort: () => 0,
19444 // Passwords should not be sortable for security reasons
19445 enableSorting: false,
19446 enableGlobalSearch: false,
19447 defaultOperators: [],
19448 validOperators: [],
19449 format: {},
19450 getValueFormatted: getValueFormatted8,
19451 validate: {
19452 required: isValidRequired,
19453 pattern: isValidPattern,
19454 minLength: isValidMinLength,
19455 maxLength: isValidMaxLength,
19456 elements: isValidElements
19457 }
19458 };
19459
19460 // packages/dataviews/build-module/field-types/telephone.mjs
19461 var telephone_default = {
19462 type: "telephone",
19463 render,
19464 Edit: "telephone",
19465 sort: sort_text_default,
19466 enableSorting: true,
19467 enableGlobalSearch: false,
19468 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
19469 validOperators: [
19470 OPERATOR_IS,
19471 OPERATOR_IS_NOT,
19472 OPERATOR_CONTAINS,
19473 OPERATOR_NOT_CONTAINS,
19474 OPERATOR_STARTS_WITH,
19475 // Multiple selection
19476 OPERATOR_IS_ANY,
19477 OPERATOR_IS_NONE,
19478 OPERATOR_IS_ALL,
19479 OPERATOR_IS_NOT_ALL
19480 ],
19481 format: {},
19482 getValueFormatted: get_value_formatted_default_default,
19483 validate: {
19484 required: isValidRequired,
19485 pattern: isValidPattern,
19486 minLength: isValidMinLength,
19487 maxLength: isValidMaxLength,
19488 elements: isValidElements
19489 }
19490 };
19491
19492 // packages/dataviews/build-module/field-types/color.mjs
19493 var import_i18n42 = __toESM(require_i18n(), 1);
19494 var import_jsx_runtime111 = __toESM(require_jsx_runtime(), 1);
19495 function render3({ item, field }) {
19496 if (field.hasElements) {
19497 return /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(RenderFromElements, { item, field });
19498 }
19499 const value = get_value_formatted_default_default({ item, field });
19500 if (!value || !w(value).isValid()) {
19501 return value;
19502 }
19503 return /* @__PURE__ */ (0, import_jsx_runtime111.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
19504 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(
19505 "div",
19506 {
19507 style: {
19508 width: "16px",
19509 height: "16px",
19510 borderRadius: "50%",
19511 backgroundColor: value,
19512 border: "1px solid #ddd",
19513 flexShrink: 0
19514 }
19515 }
19516 ),
19517 /* @__PURE__ */ (0, import_jsx_runtime111.jsx)("span", { children: value })
19518 ] });
19519 }
19520 function isValidCustom6(item, field) {
19521 const value = field.getValue({ item });
19522 if (![void 0, "", null].includes(value) && !w(value).isValid()) {
19523 return (0, import_i18n42.__)("Value must be a valid color.");
19524 }
19525 return null;
19526 }
19527 var sort5 = (a2, b2, direction) => {
19528 const colorA = w(a2);
19529 const colorB = w(b2);
19530 if (!colorA.isValid() && !colorB.isValid()) {
19531 return 0;
19532 }
19533 if (!colorA.isValid()) {
19534 return direction === "asc" ? 1 : -1;
19535 }
19536 if (!colorB.isValid()) {
19537 return direction === "asc" ? -1 : 1;
19538 }
19539 const hslA = colorA.toHsl();
19540 const hslB = colorB.toHsl();
19541 if (hslA.h !== hslB.h) {
19542 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h;
19543 }
19544 if (hslA.s !== hslB.s) {
19545 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s;
19546 }
19547 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l;
19548 };
19549 var color_default = {
19550 type: "color",
19551 render: render3,
19552 Edit: "color",
19553 sort: sort5,
19554 enableSorting: true,
19555 enableGlobalSearch: false,
19556 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
19557 validOperators: [
19558 OPERATOR_IS,
19559 OPERATOR_IS_NOT,
19560 OPERATOR_IS_ANY,
19561 OPERATOR_IS_NONE
19562 ],
19563 format: {},
19564 getValueFormatted: get_value_formatted_default_default,
19565 validate: {
19566 required: isValidRequired,
19567 elements: isValidElements,
19568 custom: isValidCustom6
19569 }
19570 };
19571
19572 // packages/dataviews/build-module/field-types/url.mjs
19573 var url_default = {
19574 type: "url",
19575 render,
19576 Edit: "url",
19577 sort: sort_text_default,
19578 enableSorting: true,
19579 enableGlobalSearch: false,
19580 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE],
19581 validOperators: [
19582 OPERATOR_IS,
19583 OPERATOR_IS_NOT,
19584 OPERATOR_CONTAINS,
19585 OPERATOR_NOT_CONTAINS,
19586 OPERATOR_STARTS_WITH,
19587 // Multiple selection
19588 OPERATOR_IS_ANY,
19589 OPERATOR_IS_NONE,
19590 OPERATOR_IS_ALL,
19591 OPERATOR_IS_NOT_ALL
19592 ],
19593 format: {},
19594 getValueFormatted: get_value_formatted_default_default,
19595 validate: {
19596 required: isValidRequired,
19597 pattern: isValidPattern,
19598 minLength: isValidMinLength,
19599 maxLength: isValidMaxLength,
19600 elements: isValidElements
19601 }
19602 };
19603
19604 // packages/dataviews/build-module/field-types/no-type.mjs
19605 var sort6 = (a2, b2, direction) => {
19606 if (typeof a2 === "number" && typeof b2 === "number") {
19607 return sort_number_default(a2, b2, direction);
19608 }
19609 return sort_text_default(a2, b2, direction);
19610 };
19611 var no_type_default = {
19612 // type: no type for this one
19613 render,
19614 Edit: null,
19615 sort: sort6,
19616 enableSorting: true,
19617 enableGlobalSearch: false,
19618 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT],
19619 validOperators: getAllOperatorNames(),
19620 format: {},
19621 getValueFormatted: get_value_formatted_default_default,
19622 validate: {
19623 required: isValidRequired,
19624 elements: isValidElements
19625 }
19626 };
19627
19628 // packages/dataviews/build-module/field-types/utils/get-is-valid.mjs
19629 function supportsNumericRangeConstraint(type) {
19630 return type === "integer" || type === "number";
19631 }
19632 function supportsDateRangeConstraint(type) {
19633 return type === "date" || type === "datetime";
19634 }
19635 function normalizeRangeRule(value, fieldType, key) {
19636 const validator = fieldType.validate[key];
19637 if (validator && (typeof value === "number" && supportsNumericRangeConstraint(fieldType.type) || typeof value === "string" && supportsDateRangeConstraint(fieldType.type))) {
19638 return { constraint: value, validate: validator };
19639 }
19640 return void 0;
19641 }
19642 function getIsValid(field, fieldType) {
19643 const rules = field.isValid;
19644 let required;
19645 if (rules?.required === true && fieldType.validate.required !== void 0) {
19646 required = {
19647 constraint: true,
19648 validate: fieldType.validate.required
19649 };
19650 }
19651 let elements;
19652 if ((rules?.elements === true || // elements is enabled unless the field opts-out
19653 rules?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) {
19654 elements = {
19655 constraint: true,
19656 validate: fieldType.validate.elements
19657 };
19658 }
19659 const min = normalizeRangeRule(rules?.min, fieldType, "min");
19660 const max = normalizeRangeRule(rules?.max, fieldType, "max");
19661 const minLengthValue = rules?.minLength;
19662 let minLength;
19663 if (typeof minLengthValue === "number" && fieldType.validate.minLength !== void 0) {
19664 minLength = {
19665 constraint: minLengthValue,
19666 validate: fieldType.validate.minLength
19667 };
19668 }
19669 const maxLengthValue = rules?.maxLength;
19670 let maxLength;
19671 if (typeof maxLengthValue === "number" && fieldType.validate.maxLength !== void 0) {
19672 maxLength = {
19673 constraint: maxLengthValue,
19674 validate: fieldType.validate.maxLength
19675 };
19676 }
19677 const patternValue = rules?.pattern;
19678 let pattern;
19679 if (patternValue !== void 0 && fieldType.validate.pattern !== void 0) {
19680 pattern = {
19681 constraint: patternValue,
19682 validate: fieldType.validate.pattern
19683 };
19684 }
19685 const custom = rules?.custom ?? fieldType.validate.custom;
19686 return {
19687 required,
19688 elements,
19689 min,
19690 max,
19691 minLength,
19692 maxLength,
19693 pattern,
19694 custom
19695 };
19696 }
19697
19698 // packages/dataviews/build-module/field-types/utils/get-filter.mjs
19699 function getFilter(fieldType) {
19700 return fieldType.validOperators.reduce((accumulator, operator) => {
19701 const operatorObj = getOperatorByName(operator);
19702 if (operatorObj?.filter) {
19703 accumulator[operator] = operatorObj.filter;
19704 }
19705 return accumulator;
19706 }, {});
19707 }
19708
19709 // packages/dataviews/build-module/field-types/utils/get-format.mjs
19710 function getFormat(field, fieldType) {
19711 return {
19712 ...fieldType.format,
19713 ...field.format
19714 };
19715 }
19716 var get_format_default = getFormat;
19717
19718 // packages/dataviews/build-module/field-types/index.mjs
19719 function getFieldTypeByName(type) {
19720 const found = [
19721 email_default,
19722 integer_default,
19723 number_default,
19724 text_default,
19725 datetime_default,
19726 date_default,
19727 boolean_default,
19728 media_default,
19729 array_default,
19730 password_default,
19731 telephone_default,
19732 color_default,
19733 url_default
19734 ].find((fieldType) => fieldType?.type === type);
19735 if (!!found) {
19736 return found;
19737 }
19738 return no_type_default;
19739 }
19740 function normalizeFields(fields2) {
19741 return fields2.map((field) => {
19742 const fieldType = getFieldTypeByName(field.type);
19743 const getValue = field.getValue || get_value_from_id_default(field.id);
19744 const sort7 = function(a2, b2, direction) {
19745 const aValue = getValue({ item: a2 });
19746 const bValue = getValue({ item: b2 });
19747 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction);
19748 };
19749 return {
19750 id: field.id,
19751 label: field.label || field.id,
19752 header: field.header || field.label || field.id,
19753 description: field.description,
19754 placeholder: field.placeholder,
19755 getValue,
19756 setValue: field.setValue || set_value_from_id_default(field.id),
19757 elements: field.elements,
19758 getElements: field.getElements,
19759 hasElements: hasElements(field),
19760 isVisible: field.isVisible,
19761 isDisabled: typeof field.isDisabled === "function" ? field.isDisabled : () => !!field.isDisabled,
19762 enableHiding: field.enableHiding ?? true,
19763 readOnly: field.readOnly ?? false,
19764 // The type provides defaults for the following props
19765 type: fieldType.type,
19766 render: field.render ?? fieldType.render,
19767 Edit: getControl(field, fieldType.Edit),
19768 sort: sort7,
19769 enableSorting: field.enableSorting ?? fieldType.enableSorting,
19770 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch,
19771 isValid: getIsValid(field, fieldType),
19772 filterBy: get_filter_by_default(
19773 field,
19774 fieldType.defaultOperators,
19775 fieldType.validOperators
19776 ),
19777 filter: getFilter(fieldType),
19778 format: get_format_default(field, fieldType),
19779 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted
19780 };
19781 });
19782 }
19783
19784 // packages/dataviews/build-module/hooks/use-data.mjs
19785 var import_element73 = __toESM(require_element(), 1);
19786 function useData({
19787 view,
19788 data: shownData,
19789 getItemId,
19790 isLoading,
19791 paginationInfo,
19792 selection
19793 }) {
19794 const isInfiniteScrollEnabled = view.infiniteScrollEnabled;
19795 const [hasInitiallyLoaded, setHasInitiallyLoaded] = (0, import_element73.useState)(
19796 !isLoading
19797 );
19798 (0, import_element73.useEffect)(() => {
19799 if (!isLoading) {
19800 setHasInitiallyLoaded(true);
19801 }
19802 }, [isLoading]);
19803 const previousDataRef = (0, import_element73.useRef)(shownData);
19804 const previousPaginationInfoRef = (0, import_element73.useRef)(paginationInfo);
19805 (0, import_element73.useEffect)(() => {
19806 if (!isLoading) {
19807 previousDataRef.current = shownData;
19808 previousPaginationInfoRef.current = paginationInfo;
19809 }
19810 }, [shownData, isLoading, paginationInfo]);
19811 const [visibleEntries, setVisibleEntries] = (0, import_element73.useState)([]);
19812 const positionMapRef = (0, import_element73.useRef)(/* @__PURE__ */ new Map());
19813 const allLoadedRecordsRef = (0, import_element73.useRef)([]);
19814 const prevViewParamsRef = (0, import_element73.useRef)({
19815 search: void 0,
19816 filters: void 0,
19817 perPage: void 0
19818 });
19819 const scrollDirectionRef = (0, import_element73.useRef)(void 0);
19820 const prevStartPositionRef = (0, import_element73.useRef)(void 0);
19821 const hasInitializedRef = (0, import_element73.useRef)(false);
19822 const allLoadedRecords = (0, import_element73.useMemo)(() => {
19823 if (view.startPosition !== void 0 && prevStartPositionRef.current !== void 0) {
19824 if (view.startPosition < prevStartPositionRef.current) {
19825 scrollDirectionRef.current = "up";
19826 } else if (view.startPosition > prevStartPositionRef.current) {
19827 scrollDirectionRef.current = "down";
19828 }
19829 }
19830 prevStartPositionRef.current = view.startPosition;
19831 const currentFiltersKey = JSON.stringify(view.filters ?? []);
19832 const prevFiltersKey = prevViewParamsRef.current.filters;
19833 const shouldReset = !hasInitializedRef.current || !view.infiniteScrollEnabled || view.search !== prevViewParamsRef.current.search || currentFiltersKey !== prevFiltersKey || view.perPage !== prevViewParamsRef.current.perPage;
19834 hasInitializedRef.current = true;
19835 prevViewParamsRef.current = {
19836 search: view.search,
19837 filters: currentFiltersKey,
19838 perPage: view.perPage
19839 };
19840 if (shouldReset) {
19841 positionMapRef.current.clear();
19842 scrollDirectionRef.current = void 0;
19843 const startPosition = view.search ? 1 : view.startPosition ?? 1;
19844 const records = shownData.map((record, index) => {
19845 const position = startPosition + index;
19846 positionMapRef.current.set(getItemId(record), position);
19847 return {
19848 ...record,
19849 position
19850 };
19851 });
19852 allLoadedRecordsRef.current = records;
19853 return records;
19854 }
19855 const prev = allLoadedRecordsRef.current;
19856 const shownDataIds = new Set(shownData.map(getItemId));
19857 const scrollDirection = scrollDirectionRef.current;
19858 const basePosition = view.search ? 1 : view.startPosition ?? 1;
19859 const newRecords = shownData.map((record, index) => {
19860 const itemId = getItemId(record);
19861 const position = view.infiniteScrollEnabled ? basePosition + index : void 0;
19862 if (position !== void 0) {
19863 positionMapRef.current.set(itemId, position);
19864 }
19865 return {
19866 ...record,
19867 position
19868 };
19869 });
19870 if (newRecords.length === 0) {
19871 return prev;
19872 }
19873 const prevWithoutDuplicates = prev.filter(
19874 (record) => !shownDataIds.has(getItemId(record))
19875 );
19876 const allRecords = scrollDirection === "up" ? [...newRecords, ...prevWithoutDuplicates] : [...prevWithoutDuplicates, ...newRecords];
19877 allRecords.sort((a2, b2) => {
19878 const posA = a2.position;
19879 const posB = b2.position;
19880 return posA - posB;
19881 });
19882 let result = allRecords;
19883 if (visibleEntries.length > 0) {
19884 const visibleMin = Math.min(...visibleEntries);
19885 const visibleMax = Math.max(...visibleEntries);
19886 const buffer = 20;
19887 const recordPositions = allRecords.map(
19888 (r3) => r3.position
19889 );
19890 const minRecordPos = Math.min(...recordPositions);
19891 const maxRecordPos = Math.max(...recordPositions);
19892 const hasOverlap = !(maxRecordPos < visibleMin - buffer || minRecordPos > visibleMax + buffer);
19893 if (hasOverlap) {
19894 result = allRecords.filter((record) => {
19895 const itemId = getItemId(record);
19896 const isSelected2 = selection?.includes(itemId);
19897 if (isSelected2) {
19898 return true;
19899 }
19900 const itemPosition = record.position;
19901 if (scrollDirection === "up") {
19902 return itemPosition <= visibleMax + buffer;
19903 } else if (scrollDirection === "down") {
19904 return itemPosition >= visibleMin - buffer;
19905 }
19906 return itemPosition >= visibleMin - buffer && itemPosition <= visibleMax + buffer;
19907 });
19908 }
19909 }
19910 allLoadedRecordsRef.current = result;
19911 return result;
19912 }, [
19913 shownData,
19914 view.search,
19915 view.filters,
19916 view.perPage,
19917 view.startPosition,
19918 view.infiniteScrollEnabled,
19919 visibleEntries,
19920 selection,
19921 getItemId
19922 ]);
19923 if (!isInfiniteScrollEnabled) {
19924 const dataToReturn = isLoading && previousDataRef.current?.length ? previousDataRef.current : shownData;
19925 return {
19926 data: dataToReturn.map((item) => ({
19927 ...item,
19928 position: void 0
19929 })),
19930 paginationInfo: isLoading && previousDataRef.current?.length ? previousPaginationInfoRef.current : paginationInfo,
19931 hasInitiallyLoaded,
19932 setVisibleEntries: void 0
19933 };
19934 }
19935 return {
19936 data: allLoadedRecords,
19937 paginationInfo,
19938 hasInitiallyLoaded,
19939 setVisibleEntries
19940 };
19941 }
19942
19943 // packages/dataviews/build-module/hooks/use-infinite-scroll.mjs
19944 var import_element74 = __toESM(require_element(), 1);
19945 var import_compose11 = __toESM(require_compose(), 1);
19946 function captureAnchorElement(container, anchorElementRef, direction) {
19947 const containerRect = container.getBoundingClientRect();
19948 const centerY = containerRect.top + containerRect.height / 2;
19949 const items = Array.from(container.querySelectorAll("[aria-posinset]"));
19950 if (items.length === 0) {
19951 return false;
19952 }
19953 const bestAnchor = items.reduce((best, item) => {
19954 const itemRect = item.getBoundingClientRect();
19955 const itemCenterY = itemRect.top + itemRect.height / 2;
19956 const distance = Math.abs(itemCenterY - centerY);
19957 const bestRect = best.getBoundingClientRect();
19958 const bestCenterY = bestRect.top + bestRect.height / 2;
19959 const bestDistance = Math.abs(bestCenterY - centerY);
19960 return distance < bestDistance ? item : best;
19961 });
19962 const posinset = Number(bestAnchor.getAttribute("aria-posinset"));
19963 const anchorRect = bestAnchor.getBoundingClientRect();
19964 anchorElementRef.current = {
19965 posinset,
19966 viewportOffset: anchorRect.top - containerRect.top,
19967 direction
19968 };
19969 return true;
19970 }
19971 function useInfiniteScroll({
19972 view,
19973 onChangeView,
19974 isLoading,
19975 paginationInfo,
19976 containerRef,
19977 setVisibleEntries
19978 }) {
19979 const anchorElementRef = (0, import_element74.useRef)(null);
19980 const viewRef = (0, import_element74.useRef)(view);
19981 const isLoadingRef = (0, import_element74.useRef)(isLoading);
19982 const onChangeViewRef = (0, import_element74.useRef)(onChangeView);
19983 const totalItemsRef = (0, import_element74.useRef)(paginationInfo.totalItems);
19984 (0, import_element74.useLayoutEffect)(() => {
19985 viewRef.current = view;
19986 isLoadingRef.current = isLoading;
19987 onChangeViewRef.current = onChangeView;
19988 totalItemsRef.current = paginationInfo.totalItems;
19989 }, [view, isLoading, onChangeView, paginationInfo.totalItems]);
19990 const intersectionObserverCallback = (0, import_element74.useCallback)(
19991 (entries) => {
19992 if (!setVisibleEntries) {
19993 return;
19994 }
19995 setVisibleEntries((prev) => {
19996 const newVisibleEntries = new Set(prev);
19997 let hasChanged = false;
19998 entries.forEach((entry) => {
19999 const posInSet = Number(
20000 entry.target?.attributes?.getNamedItem(
20001 "aria-posinset"
20002 )?.value
20003 );
20004 if (isNaN(posInSet)) {
20005 return;
20006 }
20007 if (entry.isIntersecting) {
20008 if (!newVisibleEntries.has(posInSet)) {
20009 newVisibleEntries.add(posInSet);
20010 hasChanged = true;
20011 }
20012 } else if (newVisibleEntries.has(posInSet)) {
20013 newVisibleEntries.delete(posInSet);
20014 hasChanged = true;
20015 }
20016 });
20017 return hasChanged ? Array.from(newVisibleEntries).sort() : prev;
20018 });
20019 },
20020 [setVisibleEntries]
20021 );
20022 (0, import_element74.useLayoutEffect)(() => {
20023 const container = containerRef.current;
20024 const anchor = anchorElementRef.current;
20025 if (!container || !view.infiniteScrollEnabled || !anchor || isLoading) {
20026 return;
20027 }
20028 const anchorElement = container.querySelector(
20029 `[aria-posinset="${anchor.posinset}"]`
20030 );
20031 if (anchorElement) {
20032 const containerRect = container.getBoundingClientRect();
20033 const anchorRect = anchorElement.getBoundingClientRect();
20034 const currentOffset = anchorRect.top - containerRect.top;
20035 const scrollAdjustment = currentOffset - anchor.viewportOffset;
20036 if (Math.abs(scrollAdjustment) > 1) {
20037 container.scrollTop += scrollAdjustment;
20038 }
20039 }
20040 anchorElementRef.current = null;
20041 }, [containerRef, isLoading, view.infiniteScrollEnabled]);
20042 const intersectionObserverRef = (0, import_element74.useRef)(
20043 null
20044 );
20045 (0, import_element74.useEffect)(() => {
20046 if (!view.infiniteScrollEnabled || !intersectionObserverCallback) {
20047 if (intersectionObserverRef.current) {
20048 intersectionObserverRef.current.disconnect();
20049 intersectionObserverRef.current = null;
20050 }
20051 return;
20052 }
20053 intersectionObserverRef.current = new IntersectionObserver(
20054 intersectionObserverCallback,
20055 { root: null, rootMargin: "0px", threshold: 0.1 }
20056 );
20057 return () => {
20058 if (intersectionObserverRef.current) {
20059 intersectionObserverRef.current.disconnect();
20060 intersectionObserverRef.current = null;
20061 }
20062 };
20063 }, [view.infiniteScrollEnabled, intersectionObserverCallback]);
20064 (0, import_element74.useEffect)(() => {
20065 if (!view.infiniteScrollEnabled || !containerRef.current) {
20066 return;
20067 }
20068 let lastScrollTop = 0;
20069 const BOTTOM_THRESHOLD = 600;
20070 const TOP_THRESHOLD = 800;
20071 const handleScroll = (0, import_compose11.throttle)((event) => {
20072 const currentView = viewRef.current;
20073 const totalItems = totalItemsRef.current;
20074 const target = event.target;
20075 const scrollTop = target.scrollTop;
20076 const scrollHeight = target.scrollHeight;
20077 const clientHeight = target.clientHeight;
20078 const scrollDirection = scrollTop > lastScrollTop ? "down" : "up";
20079 lastScrollTop = scrollTop;
20080 if (isLoadingRef.current) {
20081 return;
20082 }
20083 const currentStartPosition = currentView.startPosition || 1;
20084 const batchSize = currentView.perPage || 10;
20085 const currentEndPosition = Math.min(
20086 currentStartPosition + batchSize,
20087 totalItems
20088 );
20089 if (scrollDirection === "down" && scrollTop + clientHeight >= scrollHeight - BOTTOM_THRESHOLD) {
20090 if (currentEndPosition < totalItems) {
20091 const newStartPosition = currentEndPosition;
20092 captureAnchorElement(target, anchorElementRef, "down");
20093 onChangeViewRef.current({
20094 ...currentView,
20095 startPosition: newStartPosition
20096 });
20097 }
20098 }
20099 if (scrollDirection === "up" && scrollTop <= TOP_THRESHOLD) {
20100 if (currentStartPosition > 1) {
20101 const calculatedStartPosition = currentStartPosition - batchSize;
20102 const newStartPosition = calculatedStartPosition < 6 ? 1 : calculatedStartPosition;
20103 captureAnchorElement(target, anchorElementRef, "up");
20104 onChangeViewRef.current({
20105 ...currentView,
20106 startPosition: newStartPosition
20107 });
20108 }
20109 }
20110 }, 50);
20111 const container = containerRef.current;
20112 container.addEventListener("scroll", handleScroll);
20113 return () => {
20114 container.removeEventListener("scroll", handleScroll);
20115 handleScroll.cancel();
20116 };
20117 }, [containerRef, view.infiniteScrollEnabled]);
20118 return {
20119 intersectionObserver: intersectionObserverRef.current
20120 };
20121 }
20122
20123 // packages/dataviews/build-module/dataviews/index.mjs
20124 var import_jsx_runtime112 = __toESM(require_jsx_runtime(), 1);
20125 var defaultGetItemId = (item) => item.id;
20126 var defaultIsItemClickable = () => true;
20127 var EMPTY_ARRAY6 = [];
20128 var DEFAULT_LAYOUTS = { table: {}, grid: {}, list: {} };
20129 var dataViewsLayouts = VIEW_LAYOUTS.filter(
20130 (viewLayout) => !viewLayout.isPicker
20131 );
20132 function DefaultUI({
20133 header,
20134 search = true,
20135 searchLabel = void 0
20136 }) {
20137 const { view } = (0, import_element75.useContext)(dataviews_context_default);
20138 const isInfiniteScroll = view.infiniteScrollEnabled;
20139 return /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(import_jsx_runtime112.Fragment, { children: [
20140 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
20141 Stack,
20142 {
20143 direction: "row",
20144 align: "top",
20145 justify: "space-between",
20146 className: clsx_default("dataviews__view-actions", {
20147 "dataviews__view-actions--infinite-scroll": isInfiniteScroll
20148 }),
20149 gap: "xs",
20150 children: [
20151 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(
20152 Stack,
20153 {
20154 direction: "row",
20155 justify: "start",
20156 gap: "sm",
20157 className: "dataviews__search",
20158 children: [
20159 search && /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_search_default, { label: searchLabel }),
20160 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(toggle_default, {})
20161 ]
20162 }
20163 ),
20164 /* @__PURE__ */ (0, import_jsx_runtime112.jsxs)(Stack, { direction: "row", gap: "xs", style: { flexShrink: 0 }, children: [
20165 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(dataviews_view_config_default, {}),
20166 header
20167 ] })
20168 ]
20169 }
20170 ),
20171 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(filters_toggled_default, { className: "dataviews-filters__container" }),
20172 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsLayout, {}),
20173 /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(DataViewsFooter, {})
20174 ] });
20175 }
20176 function DataViews({
20177 view,
20178 onChangeView,
20179 fields: fields2,
20180 search = true,
20181 searchLabel = void 0,
20182 actions: actions2 = EMPTY_ARRAY6,
20183 data,
20184 getItemId = defaultGetItemId,
20185 getItemLevel,
20186 isLoading = false,
20187 paginationInfo,
20188 defaultLayouts: defaultLayoutsProperty = DEFAULT_LAYOUTS,
20189 selection: selectionProperty,
20190 onChangeSelection,
20191 onClickItem,
20192 renderItemLink,
20193 isItemClickable = defaultIsItemClickable,
20194 header,
20195 children,
20196 config = { perPageSizes: [10, 20, 50, 100] },
20197 empty,
20198 onReset
20199 }) {
20200 const [selectionState, setSelectionState] = (0, import_element75.useState)([]);
20201 const isUncontrolled = selectionProperty === void 0 || onChangeSelection === void 0;
20202 const selection = isUncontrolled ? selectionState : selectionProperty;
20203 const {
20204 data: displayData,
20205 paginationInfo: displayPaginationInfo,
20206 hasInitiallyLoaded,
20207 setVisibleEntries
20208 } = useData({
20209 view,
20210 data,
20211 getItemId,
20212 isLoading,
20213 selection,
20214 paginationInfo
20215 });
20216 const containerRef = (0, import_element75.useRef)(null);
20217 const [containerWidth, setContainerWidth] = (0, import_element75.useState)(0);
20218 const resizeObserverRef = (0, import_compose12.useResizeObserver)(
20219 (resizeObserverEntries) => {
20220 setContainerWidth(
20221 resizeObserverEntries[0].borderBoxSize[0].inlineSize
20222 );
20223 },
20224 { box: "border-box" }
20225 );
20226 const [openedFilter, setOpenedFilter] = (0, import_element75.useState)(null);
20227 function setSelectionWithChange(value) {
20228 const newValue = typeof value === "function" ? value(selection) : value;
20229 if (isUncontrolled) {
20230 setSelectionState(newValue);
20231 }
20232 if (onChangeSelection) {
20233 onChangeSelection(newValue);
20234 }
20235 }
20236 const _fields = (0, import_element75.useMemo)(() => normalizeFields(fields2), [fields2]);
20237 const _selection = (0, import_element75.useMemo)(() => {
20238 if (view.infiniteScrollEnabled) {
20239 return selection;
20240 }
20241 return selection.filter(
20242 (id) => data.some((item) => getItemId(item) === id)
20243 );
20244 }, [selection, data, getItemId, view.infiniteScrollEnabled]);
20245 const filters = use_filters_default(_fields, view);
20246 const hasPrimaryOrLockedFilters = (0, import_element75.useMemo)(
20247 () => (filters || []).some(
20248 (filter) => filter.isPrimary || filter.isLocked
20249 ),
20250 [filters]
20251 );
20252 const [isShowingFilter, setIsShowingFilter] = (0, import_element75.useState)(
20253 hasPrimaryOrLockedFilters
20254 );
20255 const { intersectionObserver } = useInfiniteScroll({
20256 view,
20257 onChangeView,
20258 isLoading,
20259 paginationInfo,
20260 containerRef,
20261 setVisibleEntries
20262 });
20263 (0, import_element75.useEffect)(() => {
20264 if (hasPrimaryOrLockedFilters && !isShowingFilter) {
20265 setIsShowingFilter(true);
20266 }
20267 }, [hasPrimaryOrLockedFilters, isShowingFilter]);
20268 const defaultLayouts = (0, import_element75.useMemo)(
20269 () => Object.fromEntries(
20270 Object.entries(defaultLayoutsProperty).filter(([layoutType]) => {
20271 return dataViewsLayouts.some(
20272 (viewLayout) => viewLayout.type === layoutType
20273 );
20274 }).map(([key, value]) => [
20275 key,
20276 value === true ? {} : value
20277 ])
20278 ),
20279 [defaultLayoutsProperty]
20280 );
20281 if (!defaultLayouts[view.type]) {
20282 return null;
20283 }
20284 return /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
20285 dataviews_context_default.Provider,
20286 {
20287 value: {
20288 view,
20289 onChangeView,
20290 fields: _fields,
20291 actions: actions2,
20292 data: displayData,
20293 isLoading,
20294 paginationInfo: displayPaginationInfo,
20295 selection: _selection,
20296 onChangeSelection: setSelectionWithChange,
20297 openedFilter,
20298 setOpenedFilter,
20299 getItemId,
20300 getItemLevel,
20301 isItemClickable,
20302 onClickItem,
20303 renderItemLink,
20304 containerWidth,
20305 containerRef,
20306 resizeObserverRef,
20307 defaultLayouts,
20308 filters,
20309 isShowingFilter,
20310 setIsShowingFilter,
20311 config,
20312 empty,
20313 hasInitiallyLoaded,
20314 onReset,
20315 intersectionObserver
20316 },
20317 children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)("div", { className: "dataviews-wrapper", children: children ?? /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(
20318 DefaultUI,
20319 {
20320 header,
20321 search,
20322 searchLabel
20323 }
20324 ) })
20325 }
20326 );
20327 }
20328 var DataViewsSubComponents = DataViews;
20329 DataViewsSubComponents.BulkActionToolbar = BulkActionsFooter;
20330 DataViewsSubComponents.Filters = filters_default;
20331 DataViewsSubComponents.FiltersToggled = filters_toggled_default;
20332 DataViewsSubComponents.FiltersToggle = toggle_default;
20333 DataViewsSubComponents.Layout = DataViewsLayout;
20334 DataViewsSubComponents.LayoutSwitcher = ViewTypeMenu;
20335 DataViewsSubComponents.Pagination = DataViewsPagination;
20336 DataViewsSubComponents.Search = dataviews_search_default;
20337 DataViewsSubComponents.ViewConfig = DataviewsViewConfigDropdown;
20338 DataViewsSubComponents.Footer = DataViewsFooter;
20339 var dataviews_default = DataViewsSubComponents;
20340
20341 // packages/dataviews/build-module/dataform/index.mjs
20342 var import_element87 = __toESM(require_element(), 1);
20343
20344 // packages/dataviews/build-module/components/dataform-context/index.mjs
20345 var import_element76 = __toESM(require_element(), 1);
20346 var import_jsx_runtime113 = __toESM(require_jsx_runtime(), 1);
20347 var DataFormContext = (0, import_element76.createContext)({
20348 fields: []
20349 });
20350 DataFormContext.displayName = "DataFormContext";
20351 function DataFormProvider({
20352 fields: fields2,
20353 children
20354 }) {
20355 return /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(DataFormContext.Provider, { value: { fields: fields2 }, children });
20356 }
20357 var dataform_context_default = DataFormContext;
20358
20359 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
20360 var import_element86 = __toESM(require_element(), 1);
20361
20362 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
20363 var import_element77 = __toESM(require_element(), 1);
20364 var import_components47 = __toESM(require_components(), 1);
20365
20366 // packages/dataviews/build-module/components/dataform-layouts/normalize-form.mjs
20367 var import_i18n43 = __toESM(require_i18n(), 1);
20368 var DEFAULT_LAYOUT = {
20369 type: "regular",
20370 labelPosition: "top"
20371 };
20372 var normalizeCardSummaryField = (sum) => {
20373 if (typeof sum === "string") {
20374 return [{ id: sum, visibility: "when-collapsed" }];
20375 }
20376 return sum.map((item) => {
20377 if (typeof item === "string") {
20378 return { id: item, visibility: "when-collapsed" };
20379 }
20380 return { id: item.id, visibility: item.visibility };
20381 });
20382 };
20383 function normalizeLayout(layout) {
20384 let normalizedLayout = DEFAULT_LAYOUT;
20385 if (layout?.type === "regular") {
20386 normalizedLayout = {
20387 type: "regular",
20388 labelPosition: layout?.labelPosition ?? "top"
20389 };
20390 } else if (layout?.type === "panel") {
20391 const summary = layout.summary ?? [];
20392 const normalizedSummary = Array.isArray(summary) ? summary : [summary];
20393 const openAs = layout?.openAs;
20394 let normalizedOpenAs;
20395 if (typeof openAs === "object" && openAs.type === "modal") {
20396 normalizedOpenAs = {
20397 type: "modal",
20398 applyLabel: openAs.applyLabel?.trim() || (0, import_i18n43.__)("Apply"),
20399 cancelLabel: openAs.cancelLabel?.trim() || (0, import_i18n43.__)("Cancel")
20400 };
20401 } else if (openAs === "modal") {
20402 normalizedOpenAs = {
20403 type: "modal",
20404 applyLabel: (0, import_i18n43.__)("Apply"),
20405 cancelLabel: (0, import_i18n43.__)("Cancel")
20406 };
20407 } else {
20408 normalizedOpenAs = { type: "dropdown" };
20409 }
20410 normalizedLayout = {
20411 type: "panel",
20412 labelPosition: layout?.labelPosition ?? "side",
20413 openAs: normalizedOpenAs,
20414 summary: normalizedSummary,
20415 editVisibility: layout?.editVisibility ?? "on-hover"
20416 };
20417 } else if (layout?.type === "card") {
20418 if (layout.withHeader === false) {
20419 normalizedLayout = {
20420 type: "card",
20421 withHeader: false,
20422 isOpened: true,
20423 summary: [],
20424 isCollapsible: false
20425 };
20426 } else {
20427 const summary = layout.summary ?? [];
20428 normalizedLayout = {
20429 type: "card",
20430 withHeader: true,
20431 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true,
20432 summary: normalizeCardSummaryField(summary),
20433 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible
20434 };
20435 }
20436 } else if (layout?.type === "row") {
20437 normalizedLayout = {
20438 type: "row",
20439 alignment: layout?.alignment ?? "center",
20440 styles: layout?.styles ?? {}
20441 };
20442 } else if (layout?.type === "details") {
20443 normalizedLayout = {
20444 type: "details",
20445 summary: layout?.summary ?? ""
20446 };
20447 }
20448 return normalizedLayout;
20449 }
20450 function normalizeForm(form) {
20451 const normalizedFormLayout = normalizeLayout(form?.layout);
20452 const normalizedFields = (form.fields ?? []).map(
20453 (field) => {
20454 if (typeof field === "string") {
20455 return {
20456 id: field,
20457 layout: normalizedFormLayout
20458 };
20459 }
20460 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout;
20461 return {
20462 id: field.id,
20463 layout: fieldLayout,
20464 ...!!field.label && { label: field.label },
20465 ...!!field.description && {
20466 description: field.description
20467 },
20468 ..."children" in field && Array.isArray(field.children) && {
20469 children: normalizeForm({
20470 fields: field.children,
20471 layout: DEFAULT_LAYOUT
20472 }).fields
20473 }
20474 };
20475 }
20476 );
20477 return {
20478 layout: normalizedFormLayout,
20479 fields: normalizedFields
20480 };
20481 }
20482 var normalize_form_default = normalizeForm;
20483
20484 // packages/dataviews/build-module/components/dataform-layouts/regular/index.mjs
20485 var import_jsx_runtime114 = __toESM(require_jsx_runtime(), 1);
20486 function Header4({ title }) {
20487 return /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20488 Stack,
20489 {
20490 direction: "column",
20491 className: "dataforms-layouts-regular__header",
20492 gap: "lg",
20493 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 }) })
20494 }
20495 );
20496 }
20497 function FormRegularField({
20498 data,
20499 field,
20500 onChange,
20501 hideLabelFromVision,
20502 markWhenOptional,
20503 validity
20504 }) {
20505 const { fields: fields2 } = (0, import_element77.useContext)(dataform_context_default);
20506 const layout = field.layout;
20507 const form = (0, import_element77.useMemo)(
20508 () => ({
20509 layout: DEFAULT_LAYOUT,
20510 fields: !!field.children ? field.children : []
20511 }),
20512 [field]
20513 );
20514 if (!!field.children) {
20515 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(import_jsx_runtime114.Fragment, { children: [
20516 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(Header4, { title: field.label }),
20517 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20518 DataFormLayout,
20519 {
20520 data,
20521 form,
20522 onChange,
20523 validity: validity?.children
20524 }
20525 )
20526 ] });
20527 }
20528 const labelPosition = layout.labelPosition;
20529 const fieldDefinition = fields2.find(
20530 (fieldDef) => fieldDef.id === field.id
20531 );
20532 if (!fieldDefinition || !fieldDefinition.Edit) {
20533 return null;
20534 }
20535 if (labelPosition === "side") {
20536 return /* @__PURE__ */ (0, import_jsx_runtime114.jsxs)(
20537 Stack,
20538 {
20539 direction: "row",
20540 className: "dataforms-layouts-regular__field",
20541 gap: "sm",
20542 children: [
20543 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20544 "div",
20545 {
20546 className: clsx_default(
20547 "dataforms-layouts-regular__field-label",
20548 `dataforms-layouts-regular__field-label--label-position-${labelPosition}`
20549 ),
20550 children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label })
20551 }
20552 ),
20553 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20554 fieldDefinition.render,
20555 {
20556 item: data,
20557 field: fieldDefinition
20558 }
20559 ) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20560 fieldDefinition.Edit,
20561 {
20562 data,
20563 field: fieldDefinition,
20564 onChange,
20565 hideLabelFromVision: true,
20566 markWhenOptional,
20567 validity
20568 },
20569 fieldDefinition.id
20570 ) })
20571 ]
20572 }
20573 );
20574 }
20575 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: [
20576 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_components47.BaseControl.VisualLabel, { children: fieldDefinition.label }),
20577 /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20578 fieldDefinition.render,
20579 {
20580 item: data,
20581 field: fieldDefinition
20582 }
20583 )
20584 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(
20585 fieldDefinition.Edit,
20586 {
20587 data,
20588 field: fieldDefinition,
20589 onChange,
20590 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision,
20591 markWhenOptional,
20592 validity
20593 }
20594 ) });
20595 }
20596
20597 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
20598 var import_deepmerge2 = __toESM(require_cjs(), 1);
20599 var import_components50 = __toESM(require_components(), 1);
20600 var import_element82 = __toESM(require_element(), 1);
20601 var import_compose14 = __toESM(require_compose(), 1);
20602
20603 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
20604 var import_components49 = __toESM(require_components(), 1);
20605 var import_i18n44 = __toESM(require_i18n(), 1);
20606 var import_compose13 = __toESM(require_compose(), 1);
20607 var import_element78 = __toESM(require_element(), 1);
20608
20609 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-classname.mjs
20610 function getLabelClassName(labelPosition, showError) {
20611 return clsx_default(
20612 "dataforms-layouts-panel__field-label",
20613 `dataforms-layouts-panel__field-label--label-position-${labelPosition}`,
20614 { "has-error": showError }
20615 );
20616 }
20617 var get_label_classname_default = getLabelClassName;
20618
20619 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-label-content.mjs
20620 var import_components48 = __toESM(require_components(), 1);
20621 var import_jsx_runtime115 = __toESM(require_jsx_runtime(), 1);
20622 function getLabelContent(showError, errorMessage, fieldLabel) {
20623 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: [
20624 /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_components48.Icon, { icon: error_default, size: 16 }),
20625 fieldLabel
20626 ] }) }) : fieldLabel;
20627 }
20628 var get_label_content_default = getLabelContent;
20629
20630 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/get-first-validation-error.mjs
20631 function getFirstValidationError(validity) {
20632 if (!validity) {
20633 return void 0;
20634 }
20635 const validityRules = Object.keys(validity).filter(
20636 (key) => key !== "children"
20637 );
20638 for (const key of validityRules) {
20639 const rule = validity[key];
20640 if (rule === void 0) {
20641 continue;
20642 }
20643 if (rule.type === "invalid") {
20644 if (rule.message) {
20645 return rule.message;
20646 }
20647 if (key === "required") {
20648 return "A required field is empty";
20649 }
20650 return "Unidentified validation error";
20651 }
20652 }
20653 if (validity.children) {
20654 for (const childValidity of Object.values(validity.children)) {
20655 const childError = getFirstValidationError(childValidity);
20656 if (childError) {
20657 return childError;
20658 }
20659 }
20660 }
20661 return void 0;
20662 }
20663 var get_first_validation_error_default = getFirstValidationError;
20664
20665 // packages/dataviews/build-module/components/dataform-layouts/panel/summary-button.mjs
20666 var import_jsx_runtime116 = __toESM(require_jsx_runtime(), 1);
20667 function SummaryButton({
20668 data,
20669 field,
20670 fieldLabel,
20671 summaryFields,
20672 validity,
20673 touched,
20674 disabled: disabled2,
20675 onClick,
20676 "aria-expanded": ariaExpanded
20677 }) {
20678 const { labelPosition, editVisibility } = field.layout;
20679 const errorMessage = get_first_validation_error_default(validity);
20680 const showError = touched && !!errorMessage;
20681 const labelClassName = get_label_classname_default(labelPosition, showError);
20682 const labelContent = get_label_content_default(showError, errorMessage, fieldLabel);
20683 const className = clsx_default(
20684 "dataforms-layouts-panel__field-trigger",
20685 `dataforms-layouts-panel__field-trigger--label-${labelPosition}`,
20686 {
20687 "is-disabled": disabled2,
20688 "dataforms-layouts-panel__field-trigger--edit-always": editVisibility === "always"
20689 }
20690 );
20691 const controlId = (0, import_compose13.useInstanceId)(
20692 SummaryButton,
20693 "dataforms-layouts-panel__field-control"
20694 );
20695 const ariaLabel = showError ? (0, import_i18n44.sprintf)(
20696 // translators: %s: Field name.
20697 (0, import_i18n44._x)("Edit %s (has errors)", "field"),
20698 fieldLabel || ""
20699 ) : (0, import_i18n44.sprintf)(
20700 // translators: %s: Field name.
20701 (0, import_i18n44._x)("Edit %s", "field"),
20702 fieldLabel || ""
20703 );
20704 const rowRef = (0, import_element78.useRef)(null);
20705 const handleRowClick = () => {
20706 const selection = rowRef.current?.ownerDocument.defaultView?.getSelection();
20707 if (selection && selection.toString().length > 0) {
20708 return;
20709 }
20710 onClick();
20711 };
20712 const handleKeyDown = (event) => {
20713 if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
20714 event.preventDefault();
20715 onClick();
20716 }
20717 };
20718 return /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)(
20719 "div",
20720 {
20721 ref: rowRef,
20722 className,
20723 onClick: !disabled2 ? handleRowClick : void 0,
20724 onKeyDown: !disabled2 ? handleKeyDown : void 0,
20725 children: [
20726 labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("span", { className: labelClassName, children: labelContent }),
20727 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 }) }) }),
20728 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20729 "span",
20730 {
20731 id: `${controlId}`,
20732 className: "dataforms-layouts-panel__field-control",
20733 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20734 "span",
20735 {
20736 style: {
20737 display: "flex",
20738 flexDirection: "column",
20739 alignItems: "flex-start",
20740 width: "100%",
20741 gap: "2px"
20742 },
20743 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20744 "span",
20745 {
20746 style: { width: "100%" },
20747 children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20748 summaryField.render,
20749 {
20750 item: data,
20751 field: summaryField
20752 }
20753 )
20754 },
20755 summaryField.id
20756 ))
20757 }
20758 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20759 summaryField.render,
20760 {
20761 item: data,
20762 field: summaryField
20763 },
20764 summaryField.id
20765 ))
20766 }
20767 ),
20768 !disabled2 && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(
20769 import_components49.Button,
20770 {
20771 className: "dataforms-layouts-panel__field-trigger-icon",
20772 label: ariaLabel,
20773 icon: pencil_default,
20774 size: "small",
20775 "aria-expanded": ariaExpanded,
20776 "aria-haspopup": "dialog",
20777 "aria-describedby": `${controlId}`
20778 }
20779 )
20780 ]
20781 }
20782 );
20783 }
20784
20785 // packages/dataviews/build-module/hooks/use-form-validity.mjs
20786 var import_deepmerge = __toESM(require_cjs(), 1);
20787 var import_es62 = __toESM(require_es6(), 1);
20788 var import_element79 = __toESM(require_element(), 1);
20789 var import_i18n45 = __toESM(require_i18n(), 1);
20790 function isFormValid(formValidity) {
20791 if (!formValidity) {
20792 return true;
20793 }
20794 return Object.values(formValidity).every((fieldValidation) => {
20795 return Object.entries(fieldValidation).every(
20796 ([key, validation]) => {
20797 if (key === "children" && validation && typeof validation === "object") {
20798 return isFormValid(validation);
20799 }
20800 return validation.type !== "invalid" && validation.type !== "validating";
20801 }
20802 );
20803 });
20804 }
20805 function getFormFieldsToValidate(form, fields2) {
20806 const normalizedForm = normalize_form_default(form);
20807 if (normalizedForm.fields.length === 0) {
20808 return [];
20809 }
20810 const fieldsMap = /* @__PURE__ */ new Map();
20811 fields2.forEach((field) => {
20812 fieldsMap.set(field.id, field);
20813 });
20814 function processFormField(formField) {
20815 if ("children" in formField && Array.isArray(formField.children)) {
20816 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null);
20817 if (processedChildren.length === 0) {
20818 return null;
20819 }
20820 const fieldDef2 = fieldsMap.get(formField.id);
20821 if (fieldDef2) {
20822 const [normalizedField2] = normalizeFields([
20823 fieldDef2
20824 ]);
20825 return {
20826 id: formField.id,
20827 children: processedChildren,
20828 field: normalizedField2
20829 };
20830 }
20831 return {
20832 id: formField.id,
20833 children: processedChildren
20834 };
20835 }
20836 const fieldDef = fieldsMap.get(formField.id);
20837 if (!fieldDef) {
20838 return null;
20839 }
20840 const [normalizedField] = normalizeFields([fieldDef]);
20841 return {
20842 id: formField.id,
20843 children: [],
20844 field: normalizedField
20845 };
20846 }
20847 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null);
20848 return toValidate;
20849 }
20850 function setValidityAtPath(formValidity, fieldValidity, path) {
20851 if (!formValidity) {
20852 formValidity = {};
20853 }
20854 if (path.length === 0) {
20855 return formValidity;
20856 }
20857 const result = { ...formValidity };
20858 let current = result;
20859 for (let i2 = 0; i2 < path.length - 1; i2++) {
20860 const segment = path[i2];
20861 if (!current[segment]) {
20862 current[segment] = {};
20863 }
20864 current[segment] = { ...current[segment] };
20865 current = current[segment];
20866 }
20867 const finalKey = path[path.length - 1];
20868 current[finalKey] = {
20869 ...current[finalKey] || {},
20870 ...fieldValidity
20871 };
20872 return result;
20873 }
20874 function removeValidationProperty(formValidity, path, property) {
20875 if (!formValidity || path.length === 0) {
20876 return formValidity;
20877 }
20878 const result = { ...formValidity };
20879 let current = result;
20880 for (let i2 = 0; i2 < path.length - 1; i2++) {
20881 const segment = path[i2];
20882 if (!current[segment]) {
20883 return formValidity;
20884 }
20885 current[segment] = { ...current[segment] };
20886 current = current[segment];
20887 }
20888 const finalKey = path[path.length - 1];
20889 if (!current[finalKey]) {
20890 return formValidity;
20891 }
20892 const fieldValidity = { ...current[finalKey] };
20893 delete fieldValidity[property];
20894 if (Object.keys(fieldValidity).length === 0) {
20895 delete current[finalKey];
20896 } else {
20897 current[finalKey] = fieldValidity;
20898 }
20899 if (Object.keys(result).length === 0) {
20900 return void 0;
20901 }
20902 return result;
20903 }
20904 function handleElementsValidationAsync(promise, formField, promiseHandler) {
20905 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler;
20906 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1;
20907 elementsCounterRef.current[formField.id] = currentToken;
20908 promise.then((result) => {
20909 if (currentToken !== elementsCounterRef.current[formField.id]) {
20910 return;
20911 }
20912 if (!Array.isArray(result)) {
20913 setFormValidity((prev) => {
20914 const newFormValidity = setValidityAtPath(
20915 prev,
20916 {
20917 elements: {
20918 type: "invalid",
20919 message: (0, import_i18n45.__)("Could not validate elements.")
20920 }
20921 },
20922 [...path, formField.id]
20923 );
20924 return newFormValidity;
20925 });
20926 return;
20927 }
20928 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, {
20929 ...formField.field,
20930 elements: result
20931 })) {
20932 setFormValidity((prev) => {
20933 const newFormValidity = setValidityAtPath(
20934 prev,
20935 {
20936 elements: {
20937 type: "invalid",
20938 message: (0, import_i18n45.__)(
20939 "Value must be one of the elements."
20940 )
20941 }
20942 },
20943 [...path, formField.id]
20944 );
20945 return newFormValidity;
20946 });
20947 } else {
20948 setFormValidity((prev) => {
20949 return removeValidationProperty(
20950 prev,
20951 [...path, formField.id],
20952 "elements"
20953 );
20954 });
20955 }
20956 }).catch((error2) => {
20957 if (currentToken !== elementsCounterRef.current[formField.id]) {
20958 return;
20959 }
20960 let errorMessage;
20961 if (error2 instanceof Error) {
20962 errorMessage = error2.message;
20963 } else {
20964 errorMessage = String(error2) || (0, import_i18n45.__)(
20965 "Unknown error when running elements validation asynchronously."
20966 );
20967 }
20968 setFormValidity((prev) => {
20969 const newFormValidity = setValidityAtPath(
20970 prev,
20971 {
20972 elements: {
20973 type: "invalid",
20974 message: errorMessage
20975 }
20976 },
20977 [...path, formField.id]
20978 );
20979 return newFormValidity;
20980 });
20981 });
20982 }
20983 function handleCustomValidationAsync(promise, formField, promiseHandler) {
20984 const { customCounterRef, setFormValidity, path } = promiseHandler;
20985 const currentToken = (customCounterRef.current[formField.id] || 0) + 1;
20986 customCounterRef.current[formField.id] = currentToken;
20987 promise.then((result) => {
20988 if (currentToken !== customCounterRef.current[formField.id]) {
20989 return;
20990 }
20991 if (result === null) {
20992 setFormValidity((prev) => {
20993 return removeValidationProperty(
20994 prev,
20995 [...path, formField.id],
20996 "custom"
20997 );
20998 });
20999 return;
21000 }
21001 if (typeof result === "string") {
21002 setFormValidity((prev) => {
21003 const newFormValidity = setValidityAtPath(
21004 prev,
21005 {
21006 custom: {
21007 type: "invalid",
21008 message: result
21009 }
21010 },
21011 [...path, formField.id]
21012 );
21013 return newFormValidity;
21014 });
21015 return;
21016 }
21017 setFormValidity((prev) => {
21018 const newFormValidity = setValidityAtPath(
21019 prev,
21020 {
21021 custom: {
21022 type: "invalid",
21023 message: (0, import_i18n45.__)("Validation could not be processed.")
21024 }
21025 },
21026 [...path, formField.id]
21027 );
21028 return newFormValidity;
21029 });
21030 }).catch((error2) => {
21031 if (currentToken !== customCounterRef.current[formField.id]) {
21032 return;
21033 }
21034 let errorMessage;
21035 if (error2 instanceof Error) {
21036 errorMessage = error2.message;
21037 } else {
21038 errorMessage = String(error2) || (0, import_i18n45.__)(
21039 "Unknown error when running custom validation asynchronously."
21040 );
21041 }
21042 setFormValidity((prev) => {
21043 const newFormValidity = setValidityAtPath(
21044 prev,
21045 {
21046 custom: {
21047 type: "invalid",
21048 message: errorMessage
21049 }
21050 },
21051 [...path, formField.id]
21052 );
21053 return newFormValidity;
21054 });
21055 });
21056 }
21057 function validateFormField(item, formField, promiseHandler) {
21058 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) {
21059 return {
21060 required: { type: "invalid" }
21061 };
21062 }
21063 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) {
21064 return {
21065 pattern: {
21066 type: "invalid",
21067 message: (0, import_i18n45.__)("Value does not match the required pattern.")
21068 }
21069 };
21070 }
21071 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) {
21072 return {
21073 min: {
21074 type: "invalid",
21075 message: (0, import_i18n45.__)("Value is below the minimum.")
21076 }
21077 };
21078 }
21079 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) {
21080 return {
21081 max: {
21082 type: "invalid",
21083 message: (0, import_i18n45.__)("Value is above the maximum.")
21084 }
21085 };
21086 }
21087 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) {
21088 return {
21089 minLength: {
21090 type: "invalid",
21091 message: (0, import_i18n45.__)("Value is too short.")
21092 }
21093 };
21094 }
21095 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) {
21096 return {
21097 maxLength: {
21098 type: "invalid",
21099 message: (0, import_i18n45.__)("Value is too long.")
21100 }
21101 };
21102 }
21103 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) {
21104 return {
21105 elements: {
21106 type: "invalid",
21107 message: (0, import_i18n45.__)("Value must be one of the elements.")
21108 }
21109 };
21110 }
21111 let customError;
21112 if (!!formField.field && formField.field.isValid.custom) {
21113 try {
21114 const value = formField.field.getValue({ item });
21115 customError = formField.field.isValid.custom(
21116 (0, import_deepmerge.default)(
21117 item,
21118 formField.field.setValue({
21119 item,
21120 value
21121 })
21122 ),
21123 formField.field
21124 );
21125 } catch (error2) {
21126 let errorMessage;
21127 if (error2 instanceof Error) {
21128 errorMessage = error2.message;
21129 } else {
21130 errorMessage = String(error2) || (0, import_i18n45.__)("Unknown error when running custom validation.");
21131 }
21132 return {
21133 custom: {
21134 type: "invalid",
21135 message: errorMessage
21136 }
21137 };
21138 }
21139 }
21140 if (typeof customError === "string") {
21141 return {
21142 custom: {
21143 type: "invalid",
21144 message: customError
21145 }
21146 };
21147 }
21148 const fieldValidity = {};
21149 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") {
21150 handleElementsValidationAsync(
21151 formField.field.getElements(),
21152 formField,
21153 promiseHandler
21154 );
21155 fieldValidity.elements = {
21156 type: "validating",
21157 message: (0, import_i18n45.__)("Validating\u2026")
21158 };
21159 }
21160 if (customError instanceof Promise) {
21161 handleCustomValidationAsync(customError, formField, promiseHandler);
21162 fieldValidity.custom = {
21163 type: "validating",
21164 message: (0, import_i18n45.__)("Validating\u2026")
21165 };
21166 }
21167 if (Object.keys(fieldValidity).length > 0) {
21168 return fieldValidity;
21169 }
21170 if (formField.children.length > 0) {
21171 const result = {};
21172 formField.children.forEach((child) => {
21173 result[child.id] = validateFormField(item, child, {
21174 ...promiseHandler,
21175 path: [...promiseHandler.path, formField.id, "children"]
21176 });
21177 });
21178 const filteredResult = {};
21179 Object.entries(result).forEach(([key, value]) => {
21180 if (value !== void 0) {
21181 filteredResult[key] = value;
21182 }
21183 });
21184 if (Object.keys(filteredResult).length === 0) {
21185 return void 0;
21186 }
21187 return {
21188 children: filteredResult
21189 };
21190 }
21191 return void 0;
21192 }
21193 function getFormFieldValue(formField, item) {
21194 const fieldValue = formField?.field?.getValue({ item });
21195 if (formField.children.length === 0) {
21196 return fieldValue;
21197 }
21198 const childrenValues = formField.children.map(
21199 (child) => getFormFieldValue(child, item)
21200 );
21201 if (!childrenValues) {
21202 return fieldValue;
21203 }
21204 return {
21205 value: fieldValue,
21206 children: childrenValues
21207 };
21208 }
21209 function useFormValidity(item, fields2, form) {
21210 const [formValidity, setFormValidity] = (0, import_element79.useState)();
21211 const customCounterRef = (0, import_element79.useRef)({});
21212 const elementsCounterRef = (0, import_element79.useRef)({});
21213 const previousValuesRef = (0, import_element79.useRef)({});
21214 const validate = (0, import_element79.useCallback)(() => {
21215 const promiseHandler = {
21216 customCounterRef,
21217 elementsCounterRef,
21218 setFormValidity,
21219 path: [],
21220 item
21221 };
21222 const formFieldsToValidate = getFormFieldsToValidate(form, fields2);
21223 if (formFieldsToValidate.length === 0) {
21224 setFormValidity(void 0);
21225 return;
21226 }
21227 const newFormValidity = {};
21228 const untouchedFields = [];
21229 formFieldsToValidate.forEach((formField) => {
21230 const value = getFormFieldValue(formField, item);
21231 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es62.default)(
21232 previousValuesRef.current[formField.id],
21233 value
21234 )) {
21235 untouchedFields.push(formField.id);
21236 return;
21237 }
21238 previousValuesRef.current[formField.id] = value;
21239 const fieldValidity = validateFormField(
21240 item,
21241 formField,
21242 promiseHandler
21243 );
21244 if (fieldValidity !== void 0) {
21245 newFormValidity[formField.id] = fieldValidity;
21246 }
21247 });
21248 setFormValidity((existingFormValidity) => {
21249 let validity = {
21250 ...existingFormValidity,
21251 ...newFormValidity
21252 };
21253 const fieldsToKeep = [
21254 ...untouchedFields,
21255 ...Object.keys(newFormValidity)
21256 ];
21257 Object.keys(validity).forEach((key) => {
21258 if (validity && !fieldsToKeep.includes(key)) {
21259 delete validity[key];
21260 }
21261 });
21262 if (Object.keys(validity).length === 0) {
21263 validity = void 0;
21264 }
21265 const areEqual = (0, import_es62.default)(existingFormValidity, validity);
21266 if (areEqual) {
21267 return existingFormValidity;
21268 }
21269 return validity;
21270 });
21271 }, [item, fields2, form]);
21272 (0, import_element79.useEffect)(() => {
21273 validate();
21274 }, [validate]);
21275 return {
21276 validity: formValidity,
21277 isValid: isFormValid(formValidity)
21278 };
21279 }
21280 var use_form_validity_default = useFormValidity;
21281
21282 // packages/dataviews/build-module/hooks/use-report-validity.mjs
21283 var import_element80 = __toESM(require_element(), 1);
21284 function useReportValidity(ref, shouldReport) {
21285 (0, import_element80.useEffect)(() => {
21286 if (shouldReport && ref.current) {
21287 const inputs = ref.current.querySelectorAll(
21288 "input, textarea, select"
21289 );
21290 inputs.forEach((input) => {
21291 input.reportValidity();
21292 });
21293 }
21294 }, [shouldReport, ref]);
21295 }
21296
21297 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
21298 var import_element81 = __toESM(require_element(), 1);
21299
21300 // packages/dataviews/build-module/components/dataform-layouts/get-summary-fields.mjs
21301 function extractSummaryIds(summary) {
21302 if (Array.isArray(summary)) {
21303 return summary.map(
21304 (item) => typeof item === "string" ? item : item.id
21305 );
21306 }
21307 return [];
21308 }
21309 var getSummaryFields = (summaryField, fields2) => {
21310 if (Array.isArray(summaryField) && summaryField.length > 0) {
21311 const summaryIds = extractSummaryIds(summaryField);
21312 return summaryIds.map(
21313 (summaryId) => fields2.find((_field) => _field.id === summaryId)
21314 ).filter((_field) => _field !== void 0);
21315 }
21316 return [];
21317 };
21318
21319 // packages/dataviews/build-module/components/dataform-layouts/panel/utils/use-field-from-form-field.mjs
21320 var getFieldDefinition = (field, fields2) => {
21321 const fieldDefinition = fields2.find((_field) => _field.id === field.id);
21322 if (!fieldDefinition) {
21323 return fields2.find((_field) => {
21324 if (!!field.children) {
21325 const simpleChildren = field.children.filter(
21326 (child) => !child.children
21327 );
21328 if (simpleChildren.length === 0) {
21329 return false;
21330 }
21331 return _field.id === simpleChildren[0].id;
21332 }
21333 return _field.id === field.id;
21334 });
21335 }
21336 return fieldDefinition;
21337 };
21338 function useFieldFromFormField(field) {
21339 const { fields: fields2 } = (0, import_element81.useContext)(dataform_context_default);
21340 const layout = field.layout;
21341 const summaryFields = getSummaryFields(layout.summary, fields2);
21342 const fieldDefinition = getFieldDefinition(field, fields2);
21343 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label;
21344 if (summaryFields.length === 0) {
21345 return {
21346 summaryFields: fieldDefinition ? [fieldDefinition] : [],
21347 fieldDefinition,
21348 fieldLabel
21349 };
21350 }
21351 return {
21352 summaryFields,
21353 fieldDefinition,
21354 fieldLabel
21355 };
21356 }
21357 var use_field_from_form_field_default = useFieldFromFormField;
21358
21359 // packages/dataviews/build-module/components/dataform-layouts/panel/modal.mjs
21360 var import_jsx_runtime117 = __toESM(require_jsx_runtime(), 1);
21361 function ModalContent({
21362 data,
21363 field,
21364 onChange,
21365 fieldLabel,
21366 onClose,
21367 touched
21368 }) {
21369 const { openAs } = field.layout;
21370 const { applyLabel, cancelLabel } = openAs;
21371 const { fields: fields2 } = (0, import_element82.useContext)(dataform_context_default);
21372 const [changes, setChanges] = (0, import_element82.useState)({});
21373 const modalData = (0, import_element82.useMemo)(() => {
21374 return (0, import_deepmerge2.default)(data, changes, {
21375 arrayMerge: (target, source) => source
21376 });
21377 }, [data, changes]);
21378 const form = (0, import_element82.useMemo)(
21379 () => ({
21380 layout: DEFAULT_LAYOUT,
21381 fields: !!field.children ? field.children : (
21382 // If not explicit children return the field id itself.
21383 [{ id: field.id, layout: DEFAULT_LAYOUT }]
21384 )
21385 }),
21386 [field]
21387 );
21388 const fieldsAsFieldType = fields2.map((f2) => ({
21389 ...f2,
21390 Edit: f2.Edit === null ? void 0 : f2.Edit,
21391 isValid: {
21392 required: f2.isValid.required?.constraint,
21393 elements: f2.isValid.elements?.constraint,
21394 min: f2.isValid.min?.constraint,
21395 max: f2.isValid.max?.constraint,
21396 pattern: f2.isValid.pattern?.constraint,
21397 minLength: f2.isValid.minLength?.constraint,
21398 maxLength: f2.isValid.maxLength?.constraint
21399 }
21400 }));
21401 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form);
21402 const onApply = () => {
21403 onChange(changes);
21404 onClose();
21405 };
21406 const handleOnChange = (newValue) => {
21407 setChanges(
21408 (prev) => (0, import_deepmerge2.default)(prev, newValue, {
21409 arrayMerge: (target, source) => source
21410 })
21411 );
21412 };
21413 const focusOnMountRef = (0, import_compose14.useFocusOnMount)("firstInputElement");
21414 const contentRef = (0, import_element82.useRef)(null);
21415 const mergedRef = (0, import_compose14.useMergeRefs)([focusOnMountRef, contentRef]);
21416 useReportValidity(contentRef, touched);
21417 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
21418 import_components50.Modal,
21419 {
21420 className: "dataforms-layouts-panel__modal",
21421 onRequestClose: onClose,
21422 isFullScreen: false,
21423 title: fieldLabel,
21424 size: "medium",
21425 children: [
21426 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)("div", { ref: mergedRef, children: /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21427 DataFormLayout,
21428 {
21429 data: modalData,
21430 form,
21431 onChange: handleOnChange,
21432 validity,
21433 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21434 FieldLayout,
21435 {
21436 data: modalData,
21437 field: childField,
21438 onChange: handleOnChange,
21439 hideLabelFromVision: form.fields.length < 2,
21440 markWhenOptional,
21441 validity: childFieldValidity
21442 },
21443 childField.id
21444 )
21445 }
21446 ) }),
21447 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(
21448 Stack,
21449 {
21450 direction: "row",
21451 className: "dataforms-layouts-panel__modal-footer",
21452 gap: "md",
21453 children: [
21454 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(import_components50.__experimentalSpacer, { style: { flex: 1 } }),
21455 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21456 import_components50.Button,
21457 {
21458 variant: "tertiary",
21459 onClick: onClose,
21460 __next40pxDefaultSize: true,
21461 children: cancelLabel
21462 }
21463 ),
21464 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21465 import_components50.Button,
21466 {
21467 variant: "primary",
21468 onClick: onApply,
21469 __next40pxDefaultSize: true,
21470 children: applyLabel
21471 }
21472 )
21473 ]
21474 }
21475 )
21476 ]
21477 }
21478 );
21479 }
21480 function PanelModal({
21481 data,
21482 field,
21483 onChange,
21484 validity
21485 }) {
21486 const [touched, setTouched] = (0, import_element82.useState)(false);
21487 const [isOpen, setIsOpen] = (0, import_element82.useState)(false);
21488 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
21489 if (!fieldDefinition) {
21490 return null;
21491 }
21492 const handleClose = () => {
21493 setIsOpen(false);
21494 setTouched(true);
21495 };
21496 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)(import_jsx_runtime117.Fragment, { children: [
21497 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21498 SummaryButton,
21499 {
21500 data,
21501 field,
21502 fieldLabel,
21503 summaryFields,
21504 validity,
21505 touched,
21506 disabled: fieldDefinition.readOnly === true,
21507 onClick: () => setIsOpen(true),
21508 "aria-expanded": isOpen
21509 }
21510 ),
21511 isOpen && /* @__PURE__ */ (0, import_jsx_runtime117.jsx)(
21512 ModalContent,
21513 {
21514 data,
21515 field,
21516 onChange,
21517 fieldLabel: fieldLabel ?? "",
21518 onClose: handleClose,
21519 touched
21520 }
21521 )
21522 ] });
21523 }
21524 var modal_default = PanelModal;
21525
21526 // packages/dataviews/build-module/components/dataform-layouts/panel/dropdown.mjs
21527 var import_components51 = __toESM(require_components(), 1);
21528 var import_i18n46 = __toESM(require_i18n(), 1);
21529 var import_element83 = __toESM(require_element(), 1);
21530 var import_compose15 = __toESM(require_compose(), 1);
21531 var import_jsx_runtime118 = __toESM(require_jsx_runtime(), 1);
21532 function DropdownHeader({
21533 title,
21534 onClose
21535 }) {
21536 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21537 Stack,
21538 {
21539 direction: "column",
21540 className: "dataforms-layouts-panel__dropdown-header",
21541 gap: "lg",
21542 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", children: [
21543 title && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components51.__experimentalHeading, { level: 2, size: 13, children: title }),
21544 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(import_components51.__experimentalSpacer, { style: { flex: 1 } }),
21545 onClose && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21546 import_components51.Button,
21547 {
21548 label: (0, import_i18n46.__)("Close"),
21549 icon: close_small_default,
21550 onClick: onClose,
21551 size: "small"
21552 }
21553 )
21554 ] })
21555 }
21556 );
21557 }
21558 function DropdownContentWithValidation({
21559 touched,
21560 children
21561 }) {
21562 const ref = (0, import_element83.useRef)(null);
21563 useReportValidity(ref, touched);
21564 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)("div", { ref, children });
21565 }
21566 function PanelDropdown({
21567 data,
21568 field,
21569 onChange,
21570 validity
21571 }) {
21572 const [touched, setTouched] = (0, import_element83.useState)(false);
21573 const [popoverAnchor, setPopoverAnchor] = (0, import_element83.useState)(
21574 null
21575 );
21576 const popoverProps = (0, import_element83.useMemo)(
21577 () => ({
21578 // Anchor the popover to the middle of the entire row so that it doesn't
21579 // move around when the label changes.
21580 anchor: popoverAnchor,
21581 placement: "left-start",
21582 offset: 36,
21583 shift: true
21584 }),
21585 [popoverAnchor]
21586 );
21587 const [dialogRef, dialogProps] = (0, import_compose15.__experimentalUseDialog)({
21588 focusOnMount: "firstInputElement"
21589 });
21590 const form = (0, import_element83.useMemo)(
21591 () => ({
21592 layout: DEFAULT_LAYOUT,
21593 fields: !!field.children ? field.children : (
21594 // If not explicit children return the field id itself.
21595 [{ id: field.id, layout: DEFAULT_LAYOUT }]
21596 )
21597 }),
21598 [field]
21599 );
21600 const formValidity = (0, import_element83.useMemo)(() => {
21601 if (validity === void 0) {
21602 return void 0;
21603 }
21604 if (!!field.children) {
21605 return validity?.children;
21606 }
21607 return { [field.id]: validity };
21608 }, [validity, field]);
21609 const { fieldDefinition, fieldLabel, summaryFields } = use_field_from_form_field_default(field);
21610 if (!fieldDefinition) {
21611 return null;
21612 }
21613 return /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21614 "div",
21615 {
21616 ref: setPopoverAnchor,
21617 className: "dataforms-layouts-panel__field-dropdown-anchor",
21618 children: /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21619 import_components51.Dropdown,
21620 {
21621 contentClassName: "dataforms-layouts-panel__field-dropdown",
21622 popoverProps,
21623 focusOnMount: false,
21624 onToggle: (willOpen) => {
21625 if (!willOpen) {
21626 setTouched(true);
21627 }
21628 },
21629 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21630 SummaryButton,
21631 {
21632 data,
21633 field,
21634 fieldLabel,
21635 summaryFields,
21636 validity,
21637 touched,
21638 disabled: fieldDefinition.readOnly === true,
21639 onClick: onToggle,
21640 "aria-expanded": isOpen
21641 }
21642 ),
21643 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(DropdownContentWithValidation, { touched, children: /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { ref: dialogRef, ...dialogProps, children: [
21644 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21645 DropdownHeader,
21646 {
21647 title: fieldLabel,
21648 onClose
21649 }
21650 ),
21651 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21652 DataFormLayout,
21653 {
21654 data,
21655 form,
21656 onChange,
21657 validity: formValidity,
21658 children: (FieldLayout, childField, childFieldValidity, markWhenOptional) => /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(
21659 FieldLayout,
21660 {
21661 data,
21662 field: childField,
21663 onChange,
21664 hideLabelFromVision: (form?.fields ?? []).length < 2,
21665 markWhenOptional,
21666 validity: childFieldValidity
21667 },
21668 childField.id
21669 )
21670 }
21671 )
21672 ] }) })
21673 }
21674 )
21675 }
21676 );
21677 }
21678 var dropdown_default = PanelDropdown;
21679
21680 // packages/dataviews/build-module/components/dataform-layouts/panel/index.mjs
21681 var import_jsx_runtime119 = __toESM(require_jsx_runtime(), 1);
21682 function FormPanelField({
21683 data,
21684 field,
21685 onChange,
21686 validity
21687 }) {
21688 const layout = field.layout;
21689 if (layout.openAs.type === "modal") {
21690 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
21691 modal_default,
21692 {
21693 data,
21694 field,
21695 onChange,
21696 validity
21697 }
21698 );
21699 }
21700 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(
21701 dropdown_default,
21702 {
21703 data,
21704 field,
21705 onChange,
21706 validity
21707 }
21708 );
21709 }
21710
21711 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
21712 var import_element84 = __toESM(require_element(), 1);
21713
21714 // packages/dataviews/build-module/components/dataform-layouts/validation-badge.mjs
21715 var import_i18n47 = __toESM(require_i18n(), 1);
21716 var import_jsx_runtime120 = __toESM(require_jsx_runtime(), 1);
21717 function countInvalidFields(validity) {
21718 if (!validity) {
21719 return 0;
21720 }
21721 let count = 0;
21722 const validityRules = Object.keys(validity).filter(
21723 (key) => key !== "children"
21724 );
21725 for (const key of validityRules) {
21726 const rule = validity[key];
21727 if (rule?.type === "invalid") {
21728 count++;
21729 }
21730 }
21731 if (validity.children) {
21732 for (const childValidity of Object.values(validity.children)) {
21733 count += countInvalidFields(childValidity);
21734 }
21735 }
21736 return count;
21737 }
21738 function ValidationBadge({
21739 validity
21740 }) {
21741 const invalidCount = countInvalidFields(validity);
21742 if (invalidCount === 0) {
21743 return null;
21744 }
21745 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)(Badge, { intent: "high", children: (0, import_i18n47.sprintf)(
21746 /* translators: %d: Number of fields that need attention */
21747 (0, import_i18n47._n)(
21748 "%d field needs attention",
21749 "%d fields need attention",
21750 invalidCount
21751 ),
21752 invalidCount
21753 ) });
21754 }
21755
21756 // packages/dataviews/build-module/components/dataform-layouts/card/index.mjs
21757 var import_jsx_runtime121 = __toESM(require_jsx_runtime(), 1);
21758 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) {
21759 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) {
21760 return false;
21761 }
21762 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig];
21763 const fieldConfig = summaryConfigArray.find((config) => {
21764 if (typeof config === "string") {
21765 return config === summaryField.id;
21766 }
21767 if (typeof config === "object" && "id" in config) {
21768 return config.id === summaryField.id;
21769 }
21770 return false;
21771 });
21772 if (!fieldConfig) {
21773 return false;
21774 }
21775 if (typeof fieldConfig === "string") {
21776 return true;
21777 }
21778 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) {
21779 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen;
21780 }
21781 return true;
21782 }
21783 function HeaderContent({
21784 data,
21785 fields: fields2,
21786 label,
21787 layout,
21788 isOpen,
21789 touched,
21790 validity
21791 }) {
21792 const summaryFields = getSummaryFields(layout.summary, fields2);
21793 const visibleSummaryFields = summaryFields.filter(
21794 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen)
21795 );
21796 const hasBadge = touched && layout.isCollapsible;
21797 const hasSummary = visibleSummaryFields.length > 0 && layout.withHeader;
21798 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
21799 Stack,
21800 {
21801 align: "center",
21802 justify: "space-between",
21803 className: "dataforms-layouts-card__field-header-content",
21804 children: [
21805 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Title, { children: label }),
21806 (hasBadge || hasSummary) && /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(collapsible_card_exports.HeaderDescription, { className: "dataforms-layouts-card__field-header-content-description", children: [
21807 hasBadge && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(ValidationBadge, { validity }),
21808 hasSummary && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21809 summaryField.render,
21810 {
21811 item: data,
21812 field: summaryField
21813 },
21814 summaryField.id
21815 )) })
21816 ] })
21817 ]
21818 }
21819 );
21820 }
21821 function BodyContent({
21822 data,
21823 field,
21824 form,
21825 onChange,
21826 hideLabelFromVision,
21827 markWhenOptional,
21828 validity,
21829 withHeader
21830 }) {
21831 if (field.children) {
21832 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(import_jsx_runtime121.Fragment, { children: [
21833 field.description && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }),
21834 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21835 DataFormLayout,
21836 {
21837 data,
21838 form,
21839 onChange,
21840 validity: validity?.children
21841 }
21842 )
21843 ] });
21844 }
21845 const SingleFieldLayout = getFormFieldLayout("regular")?.component;
21846 if (!SingleFieldLayout) {
21847 return null;
21848 }
21849 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21850 SingleFieldLayout,
21851 {
21852 data,
21853 field,
21854 onChange,
21855 hideLabelFromVision: hideLabelFromVision || withHeader,
21856 markWhenOptional,
21857 validity
21858 }
21859 );
21860 }
21861 function FormCardField({
21862 data,
21863 field,
21864 onChange,
21865 hideLabelFromVision,
21866 markWhenOptional,
21867 validity
21868 }) {
21869 const { fields: fields2 } = (0, import_element84.useContext)(dataform_context_default);
21870 const layout = field.layout;
21871 const contentRef = (0, import_element84.useRef)(null);
21872 const form = (0, import_element84.useMemo)(
21873 () => ({
21874 layout: DEFAULT_LAYOUT,
21875 fields: field.children ?? []
21876 }),
21877 [field]
21878 );
21879 const { isOpened, isCollapsible } = layout;
21880 const [isOpen, setIsOpen] = (0, import_element84.useState)(isOpened);
21881 const [touched, setTouched] = (0, import_element84.useState)(false);
21882 (0, import_element84.useEffect)(() => {
21883 setIsOpen(isOpened);
21884 }, [isOpened]);
21885 const handleOpenChange = (0, import_element84.useCallback)((open) => {
21886 if (!open) {
21887 setTouched(true);
21888 }
21889 setIsOpen(open);
21890 }, []);
21891 const handleBlur = (0, import_element84.useCallback)(() => {
21892 setTouched(true);
21893 }, []);
21894 useReportValidity(
21895 contentRef,
21896 (isCollapsible ? isOpen : true) && touched
21897 );
21898 let label = field.label;
21899 let withHeader;
21900 if (field.children) {
21901 withHeader = !!label && layout.withHeader;
21902 } else {
21903 const fieldDefinition = fields2.find(
21904 (fieldDef) => fieldDef.id === field.id
21905 );
21906 if (!fieldDefinition || !fieldDefinition.Edit) {
21907 return null;
21908 }
21909 label = fieldDefinition.label;
21910 withHeader = !!label && layout.withHeader;
21911 }
21912 const bodyContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21913 BodyContent,
21914 {
21915 data,
21916 field,
21917 form,
21918 onChange,
21919 hideLabelFromVision,
21920 markWhenOptional,
21921 validity,
21922 withHeader
21923 }
21924 );
21925 const headerContent = /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21926 HeaderContent,
21927 {
21928 data,
21929 fields: fields2,
21930 label,
21931 layout,
21932 isOpen: isCollapsible ? !!isOpen : true,
21933 touched,
21934 validity
21935 }
21936 );
21937 if (withHeader && isCollapsible) {
21938 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(
21939 collapsible_card_exports.Root,
21940 {
21941 className: "dataforms-layouts-card__field",
21942 open: isOpen,
21943 onOpenChange: handleOpenChange,
21944 children: [
21945 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(collapsible_card_exports.Header, { children: headerContent }),
21946 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(
21947 collapsible_card_exports.Content,
21948 {
21949 ref: contentRef,
21950 onBlur: handleBlur,
21951 children: bodyContent
21952 }
21953 )
21954 ]
21955 }
21956 );
21957 }
21958 return /* @__PURE__ */ (0, import_jsx_runtime121.jsxs)(card_exports.Root, { className: "dataforms-layouts-card__field", children: [
21959 withHeader && /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Header, { children: headerContent }),
21960 /* @__PURE__ */ (0, import_jsx_runtime121.jsx)(card_exports.Content, { ref: contentRef, onBlur: handleBlur, children: bodyContent })
21961 ] });
21962 }
21963
21964 // packages/dataviews/build-module/components/dataform-layouts/row/index.mjs
21965 var import_components52 = __toESM(require_components(), 1);
21966 var import_jsx_runtime122 = __toESM(require_jsx_runtime(), 1);
21967 function Header5({ title }) {
21968 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21969 Stack,
21970 {
21971 direction: "column",
21972 className: "dataforms-layouts-row__header",
21973 gap: "lg",
21974 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 }) })
21975 }
21976 );
21977 }
21978 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(import_jsx_runtime122.Fragment, { children });
21979 function FormRowField({
21980 data,
21981 field,
21982 onChange,
21983 hideLabelFromVision,
21984 markWhenOptional,
21985 validity
21986 }) {
21987 const layout = field.layout;
21988 if (!!field.children) {
21989 const form = {
21990 layout: DEFAULT_LAYOUT,
21991 fields: field.children
21992 };
21993 return /* @__PURE__ */ (0, import_jsx_runtime122.jsxs)("div", { className: "dataforms-layouts-row__field", children: [
21994 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Header5, { title: field.label }),
21995 /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(Stack, { direction: "row", align: layout.alignment, gap: "lg", children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
21996 DataFormLayout,
21997 {
21998 data,
21999 form,
22000 onChange,
22001 validity: validity?.children,
22002 as: EMPTY_WRAPPER,
22003 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
22004 "div",
22005 {
22006 className: "dataforms-layouts-row__field-control",
22007 style: layout.styles[childField.id],
22008 children: /* @__PURE__ */ (0, import_jsx_runtime122.jsx)(
22009 FieldLayout,
22010 {
22011 data,
22012 field: childField,
22013 onChange,
22014 hideLabelFromVision,
22015 markWhenOptional,
22016 validity: childFieldValidity
22017 }
22018 )
22019 },
22020 childField.id
22021 )
22022 }
22023 ) })
22024 ] });
22025 }
22026 const RegularLayout = getFormFieldLayout("regular")?.component;
22027 if (!RegularLayout) {
22028 return null;
22029 }
22030 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)(
22031 RegularLayout,
22032 {
22033 data,
22034 field,
22035 onChange,
22036 markWhenOptional,
22037 validity
22038 }
22039 ) }) });
22040 }
22041
22042 // packages/dataviews/build-module/components/dataform-layouts/details/index.mjs
22043 var import_element85 = __toESM(require_element(), 1);
22044 var import_i18n48 = __toESM(require_i18n(), 1);
22045 var import_jsx_runtime123 = __toESM(require_jsx_runtime(), 1);
22046 function FormDetailsField({
22047 data,
22048 field,
22049 onChange,
22050 validity
22051 }) {
22052 const { fields: fields2 } = (0, import_element85.useContext)(dataform_context_default);
22053 const detailsRef = (0, import_element85.useRef)(null);
22054 const contentRef = (0, import_element85.useRef)(null);
22055 const [touched, setTouched] = (0, import_element85.useState)(false);
22056 const [isOpen, setIsOpen] = (0, import_element85.useState)(false);
22057 const form = (0, import_element85.useMemo)(
22058 () => ({
22059 layout: DEFAULT_LAYOUT,
22060 fields: field.children ?? []
22061 }),
22062 [field]
22063 );
22064 (0, import_element85.useEffect)(() => {
22065 const details = detailsRef.current;
22066 if (!details) {
22067 return;
22068 }
22069 const handleToggle = () => {
22070 const nowOpen = details.open;
22071 if (!nowOpen) {
22072 setTouched(true);
22073 }
22074 setIsOpen(nowOpen);
22075 };
22076 details.addEventListener("toggle", handleToggle);
22077 return () => {
22078 details.removeEventListener("toggle", handleToggle);
22079 };
22080 }, []);
22081 useReportValidity(contentRef, isOpen && touched);
22082 const handleBlur = (0, import_element85.useCallback)(() => {
22083 setTouched(true);
22084 }, []);
22085 if (!field.children) {
22086 return null;
22087 }
22088 const summaryFieldId = field.layout.summary ?? "";
22089 const summaryField = summaryFieldId ? fields2.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0;
22090 let summaryContent;
22091 if (summaryField && summaryField.render) {
22092 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(summaryField.render, { item: data, field: summaryField });
22093 } else {
22094 summaryContent = field.label || (0, import_i18n48.__)("More details");
22095 }
22096 return /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
22097 "details",
22098 {
22099 ref: detailsRef,
22100 className: "dataforms-layouts-details__details",
22101 children: [
22102 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)("summary", { className: "dataforms-layouts-details__summary", children: /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(
22103 Stack,
22104 {
22105 direction: "row",
22106 align: "center",
22107 gap: "md",
22108 className: "dataforms-layouts-details__summary-content",
22109 children: [
22110 summaryContent,
22111 touched && /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ValidationBadge, { validity })
22112 ]
22113 }
22114 ) }),
22115 /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
22116 "div",
22117 {
22118 ref: contentRef,
22119 className: "dataforms-layouts-details__content",
22120 onBlur: handleBlur,
22121 children: /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(
22122 DataFormLayout,
22123 {
22124 data,
22125 form,
22126 onChange,
22127 validity: validity?.children
22128 }
22129 )
22130 }
22131 )
22132 ]
22133 }
22134 );
22135 }
22136
22137 // packages/dataviews/build-module/components/dataform-layouts/index.mjs
22138 var import_jsx_runtime124 = __toESM(require_jsx_runtime(), 1);
22139 var FORM_FIELD_LAYOUTS = [
22140 {
22141 type: "regular",
22142 component: FormRegularField,
22143 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
22144 Stack,
22145 {
22146 direction: "column",
22147 className: "dataforms-layouts__wrapper",
22148 gap: "lg",
22149 children
22150 }
22151 )
22152 },
22153 {
22154 type: "panel",
22155 component: FormPanelField,
22156 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
22157 Stack,
22158 {
22159 direction: "column",
22160 className: "dataforms-layouts__wrapper",
22161 gap: "md",
22162 children
22163 }
22164 )
22165 },
22166 {
22167 type: "card",
22168 component: FormCardField,
22169 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
22170 Stack,
22171 {
22172 direction: "column",
22173 className: "dataforms-layouts__wrapper",
22174 gap: "xl",
22175 children
22176 }
22177 )
22178 },
22179 {
22180 type: "row",
22181 component: FormRowField,
22182 wrapper: ({
22183 children,
22184 layout
22185 }) => /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
22186 Stack,
22187 {
22188 direction: "column",
22189 className: "dataforms-layouts__wrapper",
22190 gap: "lg",
22191 children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(
22192 Stack,
22193 {
22194 direction: "row",
22195 gap: "lg",
22196 align: layout.alignment,
22197 children
22198 }
22199 ) })
22200 }
22201 )
22202 },
22203 {
22204 type: "details",
22205 component: FormDetailsField
22206 }
22207 ];
22208 function getFormFieldLayout(type) {
22209 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type);
22210 }
22211
22212 // packages/dataviews/build-module/components/dataform-layouts/data-form-layout.mjs
22213 var import_jsx_runtime125 = __toESM(require_jsx_runtime(), 1);
22214 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Stack, { direction: "column", className: "dataforms-layouts__wrapper", gap: "lg", children });
22215 function DataFormLayout({
22216 data,
22217 form,
22218 onChange,
22219 validity,
22220 children,
22221 as
22222 }) {
22223 const { fields: fieldDefinitions } = (0, import_element86.useContext)(dataform_context_default);
22224 const markWhenOptional = (0, import_element86.useMemo)(() => {
22225 const requiredCount = fieldDefinitions.filter(
22226 (f2) => !!f2.isValid?.required
22227 ).length;
22228 const optionalCount = fieldDefinitions.length - requiredCount;
22229 return requiredCount > optionalCount;
22230 }, [fieldDefinitions]);
22231 function getFieldDefinition2(field) {
22232 return fieldDefinitions.find(
22233 (fieldDefinition) => fieldDefinition.id === field.id
22234 );
22235 }
22236 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER;
22237 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => {
22238 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component;
22239 if (!FieldLayout) {
22240 return null;
22241 }
22242 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0;
22243 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) {
22244 return null;
22245 }
22246 if (children) {
22247 return children(
22248 FieldLayout,
22249 formField,
22250 validity?.[formField.id],
22251 markWhenOptional
22252 );
22253 }
22254 return /* @__PURE__ */ (0, import_jsx_runtime125.jsx)(
22255 FieldLayout,
22256 {
22257 data,
22258 field: formField,
22259 onChange,
22260 markWhenOptional,
22261 validity: validity?.[formField.id]
22262 },
22263 formField.id
22264 );
22265 }) });
22266 }
22267
22268 // packages/dataviews/build-module/dataform/index.mjs
22269 var import_jsx_runtime126 = __toESM(require_jsx_runtime(), 1);
22270 function DataForm({
22271 data,
22272 form,
22273 fields: fields2,
22274 onChange,
22275 validity
22276 }) {
22277 const normalizedForm = (0, import_element87.useMemo)(() => normalize_form_default(form), [form]);
22278 const normalizedFields = (0, import_element87.useMemo)(
22279 () => normalizeFields(fields2),
22280 [fields2]
22281 );
22282 if (!form.fields) {
22283 return null;
22284 }
22285 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime126.jsx)(
22286 DataFormLayout,
22287 {
22288 data,
22289 form: normalizedForm,
22290 onChange,
22291 validity
22292 }
22293 ) });
22294 }
22295
22296 // packages/dataviews/build-module/utils/filter-sort-and-paginate.mjs
22297 var import_remove_accents2 = __toESM(require_remove_accents(), 1);
22298 var import_deprecated = __toESM(require_deprecated(), 1);
22299 function normalizeSearchInput2(input = "") {
22300 return (0, import_remove_accents2.default)(input.trim().toLowerCase());
22301 }
22302 var EMPTY_ARRAY7 = [];
22303 function filterSortAndPaginate(data, view, fields2) {
22304 if (!data) {
22305 return {
22306 data: EMPTY_ARRAY7,
22307 paginationInfo: { totalItems: 0, totalPages: 0 }
22308 };
22309 }
22310 const _fields = normalizeFields(fields2);
22311 let filteredData = [...data];
22312 if (view.search) {
22313 const normalizedSearch = normalizeSearchInput2(view.search);
22314 filteredData = filteredData.filter((item) => {
22315 return _fields.filter((field) => field.enableGlobalSearch).some((field) => {
22316 const fieldValue = field.getValue({ item });
22317 const values = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
22318 return values.some(
22319 (value) => normalizeSearchInput2(String(value)).includes(
22320 normalizedSearch
22321 )
22322 );
22323 });
22324 });
22325 }
22326 if (view.filters && view.filters?.length > 0) {
22327 view.filters.forEach((filter) => {
22328 const field = _fields.find(
22329 (_field) => _field.id === filter.field
22330 );
22331 if (field) {
22332 if (filter.operator === OPERATOR_IS_NOT_ALL) {
22333 (0, import_deprecated.default)("The 'isNotAll' filter operator", {
22334 since: "7.0",
22335 alternative: "'isNone'"
22336 });
22337 }
22338 const handler = field.filter[filter.operator];
22339 if (handler) {
22340 filteredData = filteredData.filter(
22341 (item) => handler(item, field, filter.value)
22342 );
22343 }
22344 }
22345 });
22346 }
22347 const sortByField = view.sort?.field ? _fields.find((field) => {
22348 return field.enableSorting !== false && field.id === view.sort?.field;
22349 }) : null;
22350 const groupByField = view.groupBy?.field ? _fields.find((field) => {
22351 return field.enableSorting !== false && field.id === view.groupBy?.field;
22352 }) : null;
22353 if (sortByField || groupByField) {
22354 filteredData.sort((a2, b2) => {
22355 if (groupByField) {
22356 const groupCompare = groupByField.sort(
22357 a2,
22358 b2,
22359 view.groupBy?.direction ?? "asc"
22360 );
22361 if (groupCompare !== 0) {
22362 return groupCompare;
22363 }
22364 }
22365 if (sortByField) {
22366 return sortByField.sort(a2, b2, view.sort?.direction ?? "desc");
22367 }
22368 return 0;
22369 });
22370 }
22371 let totalItems = filteredData.length;
22372 let totalPages = 1;
22373 if (view.infiniteScrollEnabled && view.startPosition !== void 0 && view.perPage !== void 0) {
22374 const start = view.startPosition - 1;
22375 const end = Math.min(start + view.perPage, totalItems);
22376 filteredData = filteredData?.slice(start, end);
22377 } else if (view.page !== void 0 && view.perPage !== void 0) {
22378 const start = (view.page - 1) * view.perPage;
22379 totalItems = filteredData?.length || 0;
22380 totalPages = Math.ceil(totalItems / view.perPage);
22381 filteredData = filteredData?.slice(start, start + view.perPage);
22382 }
22383 return {
22384 data: filteredData,
22385 paginationInfo: {
22386 totalItems,
22387 totalPages
22388 }
22389 };
22390 }
22391
22392 // routes/guidelines/components/guideline-accordion-form.tsx
22393 var import_i18n50 = __toESM(require_i18n());
22394 var import_element88 = __toESM(require_element());
22395 var import_data8 = __toESM(require_data());
22396 var import_notices2 = __toESM(require_notices());
22397
22398 // routes/guidelines/store.ts
22399 var import_data6 = __toESM(require_data());
22400 var STORE_NAME = "core/guidelines";
22401 var DEFAULT_STATE = {
22402 id: null,
22403 status: null,
22404 categories: {
22405 site: "",
22406 copy: "",
22407 images: "",
22408 additional: "",
22409 blocks: {}
22410 }
22411 };
22412 var CATEGORIES = ["site", "copy", "images", "additional", "blocks"];
22413 var actions = {
22414 setFromResponse(response) {
22415 return {
22416 type: "SET_FROM_RESPONSE",
22417 response
22418 };
22419 },
22420 setGuideline(category, value) {
22421 return {
22422 type: "SET_GUIDELINE",
22423 category,
22424 value
22425 };
22426 },
22427 setBlockGuideline(blockName, value) {
22428 return {
22429 type: "SET_BLOCK_GUIDELINE",
22430 blockName,
22431 value
22432 };
22433 }
22434 };
22435 function parseResponse(response) {
22436 if (!response || typeof response !== "object") {
22437 return {};
22438 }
22439 const categoriesFromResponse = response.guideline_categories ?? {};
22440 const result = {
22441 id: response.id ?? null,
22442 status: response.status ?? null,
22443 categories: {
22444 site: "",
22445 copy: "",
22446 images: "",
22447 additional: "",
22448 blocks: {}
22449 }
22450 };
22451 CATEGORIES.forEach((category) => {
22452 const guidelines = categoriesFromResponse?.[category]?.guidelines;
22453 if (typeof guidelines === "string") {
22454 result.categories[category] = guidelines;
22455 } else if (category === "blocks") {
22456 const blocks = categoriesFromResponse?.blocks ?? {};
22457 for (const [blockName, blockData] of Object.entries(blocks)) {
22458 result.categories.blocks[blockName] = blockData?.guidelines;
22459 }
22460 }
22461 });
22462 return result;
22463 }
22464 function reducer(state = DEFAULT_STATE, action) {
22465 switch (action.type) {
22466 case "SET_FROM_RESPONSE":
22467 return {
22468 ...state,
22469 ...parseResponse(action.response)
22470 };
22471 case "SET_GUIDELINE":
22472 return {
22473 ...state,
22474 categories: {
22475 ...state.categories,
22476 [action.category]: action.value
22477 }
22478 };
22479 case "SET_BLOCK_GUIDELINE": {
22480 const blocks = {
22481 ...state.categories.blocks,
22482 [action.blockName]: action.value
22483 };
22484 if (action.value === void 0) {
22485 delete blocks[action.blockName];
22486 }
22487 return {
22488 ...state,
22489 categories: {
22490 ...state.categories,
22491 blocks
22492 }
22493 };
22494 }
22495 default:
22496 return state;
22497 }
22498 }
22499 var selectors = {
22500 getGuideline(state, category) {
22501 return state.categories[category];
22502 },
22503 getAllGuidelines(state) {
22504 return state.categories;
22505 },
22506 getBlockGuidelines(state) {
22507 return state.categories.blocks;
22508 },
22509 getBlockGuideline(state, blockName) {
22510 return state.categories.blocks[blockName] ?? "";
22511 },
22512 getId(state) {
22513 return state.id;
22514 },
22515 getStatus(state) {
22516 return state.status;
22517 }
22518 };
22519 var store = (0, import_data6.createReduxStore)(STORE_NAME, {
22520 reducer,
22521 actions,
22522 selectors
22523 });
22524 (0, import_data6.register)(store);
22525
22526 // routes/guidelines/api.ts
22527 var import_api_fetch = __toESM(require_api_fetch());
22528 var import_blob = __toESM(require_blob());
22529 var import_data7 = __toESM(require_data());
22530 var import_i18n49 = __toESM(require_i18n());
22531 var import_notices = __toESM(require_notices());
22532 var FLAT_CATEGORIES = ["site", "copy", "images", "additional"];
22533 function isValidGuidelinesImport(data) {
22534 return !!data && typeof data === "object" && "guideline_categories" in data && typeof data.guideline_categories === "object" && data.guideline_categories !== null;
22535 }
22536 async function fetchGuidelines() {
22537 const { setFromResponse } = (0, import_data7.dispatch)(store);
22538 const response = await (0, import_api_fetch.default)({
22539 path: "/wp/v2/content-guidelines?context=edit"
22540 });
22541 setFromResponse(response);
22542 return response;
22543 }
22544 async function saveGuidelines() {
22545 const { setFromResponse } = (0, import_data7.dispatch)(store);
22546 const guidelinesStore = (0, import_data7.select)(store);
22547 const id = guidelinesStore.getId();
22548 const status = guidelinesStore.getStatus() || "draft";
22549 const categories = guidelinesStore.getAllGuidelines();
22550 const response = await saveGuidelinesBypassingStore(
22551 id,
22552 status,
22553 categories
22554 );
22555 setFromResponse(response);
22556 return response;
22557 }
22558 async function saveGuidelinesBypassingStore(id, status, categories) {
22559 const data = {
22560 id,
22561 status,
22562 guideline_categories: {
22563 site: {
22564 guidelines: categories.site
22565 },
22566 copy: {
22567 guidelines: categories.copy
22568 },
22569 images: {
22570 guidelines: categories.images
22571 },
22572 additional: {
22573 guidelines: categories.additional
22574 },
22575 blocks: Object.fromEntries(
22576 Object.entries(categories.blocks).map(
22577 ([blockName, guidelines]) => [
22578 blockName,
22579 { guidelines }
22580 ]
22581 )
22582 )
22583 }
22584 };
22585 const path = id ? `/wp/v2/content-guidelines/${id}` : "/wp/v2/content-guidelines";
22586 const method = id ? "PUT" : "POST";
22587 const response = await (0, import_api_fetch.default)({
22588 path,
22589 method,
22590 data
22591 });
22592 return response;
22593 }
22594 async function importGuidelines(file) {
22595 const { setFromResponse } = (0, import_data7.dispatch)(store);
22596 const guidelinesStore = (0, import_data7.select)(store);
22597 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
22598 const parsed = JSON.parse(await file.text());
22599 if (!isValidGuidelinesImport(parsed)) {
22600 throw new Error(
22601 (0, import_i18n49.__)(
22602 "Check that your file contains valid JSON markup and try again."
22603 )
22604 );
22605 }
22606 const existingGuidelines = guidelinesStore.getAllGuidelines();
22607 const newGuidelines = {
22608 /**
22609 * Set empty string to all the simple guidelines so that if the category is not present
22610 * in the parsed data, the category gets removed.
22611 */
22612 ...Object.fromEntries(
22613 FLAT_CATEGORIES.map((category) => [category, ""])
22614 ),
22615 /**
22616 * Set empty string to all the existing block guidelines so that if the block is not present
22617 * in the parsed data, the block gets removed.
22618 */
22619 blocks: Object.fromEntries(
22620 Object.keys(existingGuidelines.blocks).map((block) => [
22621 block,
22622 ""
22623 ])
22624 )
22625 };
22626 for (const cat of FLAT_CATEGORIES) {
22627 const guidelines = parsed.guideline_categories[cat]?.guidelines || "";
22628 newGuidelines[cat] = guidelines;
22629 }
22630 const parsedBlocks = parsed.guideline_categories?.blocks ?? {};
22631 for (const [key, value] of Object.entries(parsedBlocks)) {
22632 newGuidelines.blocks[key] = value?.guidelines || "";
22633 }
22634 const response = await saveGuidelinesBypassingStore(
22635 guidelinesStore.getId(),
22636 guidelinesStore.getStatus() || "draft",
22637 newGuidelines
22638 );
22639 setFromResponse(response);
22640 createSuccessNotice((0, import_i18n49.__)("Guidelines imported."), {
22641 type: "snackbar"
22642 });
22643 }
22644 function exportGuidelines() {
22645 const { createSuccessNotice } = (0, import_data7.dispatch)(import_notices.store);
22646 const guidelinesStore = (0, import_data7.select)(store);
22647 const guidelinesCategories = guidelinesStore.getAllGuidelines();
22648 const blockGuidelines = guidelinesStore.getBlockGuidelines();
22649 const data = {
22650 guideline_categories: {
22651 ...Object.fromEntries(
22652 FLAT_CATEGORIES.map((guidelineCategory) => [
22653 guidelineCategory,
22654 {
22655 guidelines: guidelinesCategories[guidelineCategory] ?? ""
22656 }
22657 ])
22658 ),
22659 blocks: Object.fromEntries(
22660 Object.entries(blockGuidelines).map(
22661 ([blockName, guidelines]) => [
22662 blockName,
22663 { guidelines }
22664 ]
22665 )
22666 )
22667 }
22668 };
22669 const now = /* @__PURE__ */ new Date();
22670 const exportDate = [
22671 now.getFullYear(),
22672 String(now.getMonth() + 1).padStart(2, "0"),
22673 String(now.getDate()).padStart(2, "0")
22674 ].join("-");
22675 (0, import_blob.downloadBlob)(
22676 `guidelines-${exportDate}.json`,
22677 JSON.stringify(data, null, 2),
22678 "application/json"
22679 );
22680 createSuccessNotice((0, import_i18n49.__)("Guidelines exported."), {
22681 type: "snackbar"
22682 });
22683 }
22684 async function fetchGuidelinesRevisions({
22685 guidelinesId,
22686 page = 1,
22687 perPage = 10,
22688 search
22689 }) {
22690 const params = new URLSearchParams({
22691 page: String(page),
22692 per_page: String(perPage),
22693 _embed: "author",
22694 ...search ? { search } : {}
22695 });
22696 const response = await (0, import_api_fetch.default)({
22697 path: `/wp/v2/content-guidelines/${guidelinesId}/revisions?${params}`,
22698 parse: false
22699 });
22700 const revisions = await response.json();
22701 const total = parseInt(response.headers.get("X-WP-Total") ?? "0", 10);
22702 const totalPages = parseInt(
22703 response.headers.get("X-WP-TotalPages") ?? "0",
22704 10
22705 );
22706 return { revisions, total, totalPages };
22707 }
22708 async function restoreGuidelinesRevision(guidelinesId, revisionId) {
22709 return await (0, import_api_fetch.default)({
22710 path: `/wp/v2/content-guidelines/${guidelinesId}/revisions/${revisionId}/restore`,
22711 method: "POST"
22712 });
22713 }
22714
22715 // routes/guidelines/components/guideline-accordion-form.tsx
22716 function GuidelineAccordionForm({ slug }) {
22717 const { setGuideline } = (0, import_data8.useDispatch)(store);
22718 const { createSuccessNotice } = (0, import_data8.useDispatch)(import_notices2.store);
22719 const [loading, setLoading] = (0, import_element88.useState)(false);
22720 const [error2, setError] = (0, import_element88.useState)(null);
22721 const [showClearConfirmation, setShowClearConfirmation] = (0, import_element88.useState)(false);
22722 const { value } = (0, import_data8.useSelect)(
22723 (select2) => ({
22724 value: select2(store).getGuideline(slug)
22725 }),
22726 [slug]
22727 );
22728 const [draft, setDraft] = (0, import_element88.useState)(value);
22729 (0, import_element88.useEffect)(() => setDraft(value), [value]);
22730 const data = (0, import_element88.useMemo)(() => ({ guidelines: draft }), [draft]);
22731 const fields2 = (0, import_element88.useMemo)(
22732 () => [
22733 {
22734 id: "guidelines",
22735 label: (0, import_i18n50.sprintf)(
22736 /* translators: %s: Guideline category. */
22737 (0, import_i18n50.__)("%s guidelines"),
22738 slug
22739 ),
22740 type: "text",
22741 Edit: "textarea"
22742 }
22743 ],
22744 [slug]
22745 );
22746 const form = (0, import_element88.useMemo)(
22747 () => ({
22748 layout: { type: "regular", labelPosition: "none" },
22749 fields: ["guidelines"]
22750 }),
22751 []
22752 );
22753 const handleSave = (event) => {
22754 event.preventDefault();
22755 setGuideline(slug, draft);
22756 setLoading(true);
22757 saveGuidelines().then(() => {
22758 setError(null);
22759 createSuccessNotice((0, import_i18n50.__)("Guidelines saved."), {
22760 type: "snackbar"
22761 });
22762 }).catch(
22763 (e2) => setError(
22764 (0, import_i18n50.sprintf)(
22765 /* translators: %s: Error message. */
22766 (0, import_i18n50.__)("Error saving guidelines: %s"),
22767 e2.message
22768 )
22769 )
22770 ).finally(() => setLoading(false));
22771 };
22772 const handleClearClick = () => setShowClearConfirmation(true);
22773 const handleClearConfirm = () => {
22774 const oldValue = draft;
22775 setGuideline(slug, "");
22776 setLoading(true);
22777 saveGuidelines().then(() => {
22778 setError(null);
22779 createSuccessNotice((0, import_i18n50.__)("Guidelines cleared."), {
22780 type: "snackbar"
22781 });
22782 }).catch((e2) => {
22783 setError(
22784 (0, import_i18n50.sprintf)(
22785 /* translators: %s: Error message. */
22786 (0, import_i18n50.__)("Error clearing guidelines: %s"),
22787 e2.message
22788 )
22789 );
22790 setGuideline(slug, oldValue);
22791 }).finally(() => {
22792 setLoading(false);
22793 setShowClearConfirmation(false);
22794 });
22795 };
22796 return /* @__PURE__ */ React.createElement("form", { onSubmit: handleSave }, /* @__PURE__ */ React.createElement(import_components53.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(
22797 DataForm,
22798 {
22799 data,
22800 fields: fields2,
22801 form,
22802 onChange: (edits) => setDraft(edits.guidelines ?? draft)
22803 }
22804 ), 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(
22805 import_components53.Button,
22806 {
22807 variant: "primary",
22808 type: "submit",
22809 disabled: loading || !draft,
22810 accessibleWhenDisabled: true,
22811 isBusy: loading
22812 },
22813 (0, import_i18n50.__)("Save guidelines")
22814 ), /* @__PURE__ */ React.createElement(
22815 import_components53.Button,
22816 {
22817 variant: "tertiary",
22818 type: "button",
22819 disabled: loading || !value,
22820 accessibleWhenDisabled: true,
22821 isBusy: loading,
22822 onClick: handleClearClick
22823 },
22824 (0, import_i18n50.__)("Clear guidelines")
22825 ))), /* @__PURE__ */ React.createElement(
22826 import_components53.__experimentalConfirmDialog,
22827 {
22828 isOpen: showClearConfirmation,
22829 title: (0, import_i18n50.sprintf)(
22830 /* translators: %s: Guideline category. */
22831 (0, import_i18n50.__)("Clear %s guidelines"),
22832 slug
22833 ),
22834 __experimentalHideHeader: false,
22835 onConfirm: handleClearConfirm,
22836 onCancel: () => setShowClearConfirmation(false),
22837 confirmButtonText: (0, import_i18n50.__)("Clear guidelines"),
22838 isBusy: loading,
22839 size: "small"
22840 },
22841 (0, import_i18n50.sprintf)(
22842 /* translators: %s: Guideline category slug. */
22843 (0, import_i18n50.__)(
22844 "You are about to clear the %s guidelines. This can be undone from revision history."
22845 ),
22846 slug
22847 )
22848 ));
22849 }
22850
22851 // routes/guidelines/components/block-guidelines.tsx
22852 var import_components55 = __toESM(require_components());
22853 var import_i18n52 = __toESM(require_i18n());
22854 var import_element90 = __toESM(require_element());
22855 var import_data10 = __toESM(require_data());
22856 var import_blocks2 = __toESM(require_blocks());
22857 var import_notices4 = __toESM(require_notices());
22858
22859 // routes/guidelines/components/block-guideline-modal.tsx
22860 var import_components54 = __toESM(require_components());
22861 var import_i18n51 = __toESM(require_i18n());
22862 var import_element89 = __toESM(require_element());
22863 var import_data9 = __toESM(require_data());
22864 var import_blocks = __toESM(require_blocks());
22865 var import_notices3 = __toESM(require_notices());
22866
22867 // routes/lock-unlock.ts
22868 var import_private_apis2 = __toESM(require_private_apis());
22869 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
22870 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
22871 "@wordpress/routes"
22872 );
22873
22874 // routes/guidelines/components/block-guideline-modal.scss
22875 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='7c0ecac6c9']")) {
22876 const style = document.createElement("style");
22877 style.setAttribute("data-wp-hash", "7c0ecac6c9");
22878 style.appendChild(document.createTextNode(".block-guideline-modal{width:min(100%,660px)}.block-guideline-modal__actions{margin-top:8px}"));
22879 document.head.appendChild(style);
22880 }
22881
22882 // routes/guidelines/components/block-guideline-modal.tsx
22883 var { isContentBlock } = unlock2(import_blocks.privateApis);
22884 function BlockGuidelineModal({
22885 closeModal,
22886 initialBlock
22887 }) {
22888 const [selectedBlock, setSelectedBlock] = (0, import_element89.useState)(
22889 initialBlock
22890 );
22891 const [isSaving, setIsSaving] = (0, import_element89.useState)(false);
22892 const [error2, setError] = (0, import_element89.useState)(null);
22893 const [showRemoveConfirmation, setShowRemoveConfirmation] = (0, import_element89.useState)(false);
22894 const blockGuidelines = (0, import_data9.useSelect)(
22895 (select2) => select2(store).getBlockGuidelines(),
22896 []
22897 );
22898 const isEditing = !!initialBlock;
22899 const currentGuideline = blockGuidelines[selectedBlock] ?? "";
22900 const [guidelineText, setGuidelineText] = (0, import_element89.useState)(currentGuideline);
22901 const blockOptions = (0, import_data9.useSelect)(
22902 // @ts-ignore
22903 (select2) => select2(import_blocks.store).getBlockTypes(),
22904 []
22905 );
22906 const availableBlockOptions = (0, import_element89.useMemo)(() => {
22907 const set3 = new Set(Object.keys(blockGuidelines));
22908 if (initialBlock) {
22909 set3.delete(initialBlock);
22910 }
22911 if (selectedBlock) {
22912 set3.delete(selectedBlock);
22913 }
22914 return blockOptions.filter(
22915 (block) => isContentBlock(block.name) && !set3.has(block.name)
22916 ).map((block) => ({
22917 value: block.name,
22918 label: block.title
22919 }));
22920 }, [blockGuidelines, blockOptions, initialBlock, selectedBlock]);
22921 const selectedBlockLabel = (0, import_element89.useMemo)(
22922 () => blockOptions.find((block) => block.name === selectedBlock)?.title || "",
22923 [blockOptions, selectedBlock]
22924 );
22925 const { setBlockGuideline } = (0, import_data9.useDispatch)(store);
22926 const { createSuccessNotice } = (0, import_data9.useDispatch)(import_notices3.store);
22927 const handleSave = (value) => {
22928 value = value.trim();
22929 if (!selectedBlock) {
22930 return;
22931 }
22932 setIsSaving(true);
22933 const oldValue = blockGuidelines[selectedBlock];
22934 setBlockGuideline(selectedBlock, value);
22935 saveGuidelines().then(() => {
22936 setError(null);
22937 createSuccessNotice(
22938 value ? (0, import_i18n51.__)("Guidelines saved.") : (0, import_i18n51.__)("Guidelines removed."),
22939 { type: "snackbar" }
22940 );
22941 closeModal();
22942 }).catch((e2) => {
22943 setError(e2.message);
22944 setBlockGuideline(selectedBlock, oldValue);
22945 }).finally(() => setIsSaving(false));
22946 };
22947 const canSubmit = selectedBlock && guidelineText.trim().length > 0;
22948 let submitButtonLabel = (0, import_i18n51.__)("Save guidelines");
22949 if (isSaving) {
22950 submitButtonLabel = (0, import_i18n51.__)("Saving\u2026");
22951 }
22952 return /* @__PURE__ */ React.createElement(
22953 import_components54.Modal,
22954 {
22955 className: "block-guideline-modal",
22956 title: isEditing ? (0, import_i18n51.__)("Edit guidelines") : (0, import_i18n51.__)("Add guidelines"),
22957 onRequestClose: closeModal
22958 },
22959 /* @__PURE__ */ React.createElement(import_components54.__experimentalVStack, { spacing: 4 }, isEditing ? /* @__PURE__ */ React.createElement(
22960 import_components54.TextControl,
22961 {
22962 __next40pxDefaultSize: true,
22963 label: (0, import_i18n51.__)("Block"),
22964 value: selectedBlockLabel,
22965 onChange: () => {
22966 },
22967 disabled: true
22968 }
22969 ) : /* @__PURE__ */ React.createElement(
22970 import_components54.ComboboxControl,
22971 {
22972 __next40pxDefaultSize: true,
22973 label: (0, import_i18n51.__)("Block"),
22974 options: availableBlockOptions,
22975 value: selectedBlock,
22976 onChange: (value) => setSelectedBlock(value ?? void 0),
22977 placeholder: (0, import_i18n51.__)("Search for a block\u2026")
22978 }
22979 ), /* @__PURE__ */ React.createElement(
22980 import_components54.TextareaControl,
22981 {
22982 label: (0, import_i18n51.__)("Guideline text"),
22983 value: guidelineText,
22984 onChange: setGuidelineText,
22985 placeholder: (0, import_i18n51.__)(
22986 "Enter guidelines for how this block should be used\u2026"
22987 ),
22988 rows: 6
22989 }
22990 ), error2 && /* @__PURE__ */ React.createElement(import_components54.Notice, { status: "error", onRemove: () => setError(null) }, (0, import_i18n51.sprintf)(
22991 /* translators: %s: Error message. */
22992 (0, import_i18n51.__)("Error: %s"),
22993 error2
22994 )), /* @__PURE__ */ React.createElement(
22995 import_components54.__experimentalHStack,
22996 {
22997 justify: "flex-end",
22998 spacing: 2,
22999 className: "block-guideline-modal__actions"
23000 },
23001 isEditing && /* @__PURE__ */ React.createElement(
23002 import_components54.Button,
23003 {
23004 variant: "tertiary",
23005 isDestructive: true,
23006 onClick: () => setShowRemoveConfirmation(true),
23007 disabled: isSaving,
23008 accessibleWhenDisabled: true,
23009 type: "button"
23010 },
23011 (0, import_i18n51.__)("Remove")
23012 ),
23013 /* @__PURE__ */ React.createElement(
23014 import_components54.Button,
23015 {
23016 variant: "primary",
23017 onClick: () => handleSave(guidelineText),
23018 disabled: !canSubmit || isSaving,
23019 isBusy: isSaving,
23020 accessibleWhenDisabled: true
23021 },
23022 submitButtonLabel
23023 )
23024 )),
23025 /* @__PURE__ */ React.createElement(
23026 import_components54.__experimentalConfirmDialog,
23027 {
23028 isOpen: showRemoveConfirmation,
23029 title: (0, import_i18n51.__)("Remove block guidelines"),
23030 __experimentalHideHeader: false,
23031 onConfirm: () => {
23032 handleSave("");
23033 setShowRemoveConfirmation(false);
23034 },
23035 onCancel: () => setShowRemoveConfirmation(false),
23036 confirmButtonText: (0, import_i18n51.__)("Remove"),
23037 isBusy: isSaving,
23038 size: "small"
23039 },
23040 (0, import_i18n51.sprintf)(
23041 /* translators: %s: Block name. */
23042 (0, import_i18n51.__)(
23043 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
23044 ),
23045 selectedBlockLabel
23046 )
23047 )
23048 );
23049 }
23050
23051 // routes/guidelines/components/block-guidelines.scss
23052 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='d9583ae8d2']")) {
23053 const style = document.createElement("style");
23054 style.setAttribute("data-wp-hash", "d9583ae8d2");
23055 style.appendChild(document.createTextNode(".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}"));
23056 document.head.appendChild(style);
23057 }
23058
23059 // routes/guidelines/components/block-guidelines.tsx
23060 var PER_PAGE = 5;
23061 var initialView = {
23062 type: "list",
23063 search: "",
23064 page: 1,
23065 perPage: PER_PAGE,
23066 filters: [],
23067 mediaField: "icon",
23068 showMedia: true,
23069 titleField: "label",
23070 layout: {
23071 density: "compact"
23072 }
23073 };
23074 var fields = [
23075 {
23076 id: "icon",
23077 label: (0, import_i18n52.__)("Icon"),
23078 type: "media",
23079 render: ({ item }) => /* @__PURE__ */ React.createElement("div", { className: "block-guidelines__icon" }, /* @__PURE__ */ React.createElement(import_components55.Icon, { icon: item.icon ?? block_default_default, size: 16 }))
23080 },
23081 {
23082 id: "label",
23083 label: (0, import_i18n52.__)("Label"),
23084 type: "text",
23085 enableGlobalSearch: true,
23086 getValue: ({ item }) => item.label,
23087 render: ({ item }) => item.label
23088 }
23089 ];
23090 function BlockGuidelines() {
23091 const [isOpen, setIsOpen] = (0, import_element90.useState)(false);
23092 const [view, setView] = (0, import_element90.useState)(initialView);
23093 const [selectedItem, setSelectedItem] = (0, import_element90.useState)();
23094 const [error2, setError] = (0, import_element90.useState)(null);
23095 const [busy, setBusy] = (0, import_element90.useState)(false);
23096 const [itemToDelete, setItemToDelete] = (0, import_element90.useState)(
23097 null
23098 );
23099 const { createSuccessNotice } = (0, import_data10.useDispatch)(import_notices4.store);
23100 const blockGuidelines = (0, import_data10.useSelect)(
23101 (select2) => select2(store).getBlockGuidelines(),
23102 []
23103 );
23104 const blockTypes = (0, import_data10.useSelect)(
23105 // @ts-ignore
23106 (select2) => select2(import_blocks2.store).getBlockTypes(),
23107 []
23108 );
23109 const rows = (0, import_element90.useMemo)(
23110 () => blockTypes.filter((blockType) => blockGuidelines[blockType.name]).map((blockType) => ({
23111 id: blockType.name,
23112 label: blockType.title,
23113 guidelines: blockGuidelines[blockType.name] ?? "",
23114 icon: blockType.icon?.src
23115 })),
23116 [blockGuidelines, blockTypes]
23117 );
23118 const { setBlockGuideline } = (0, import_data10.useDispatch)(store);
23119 const handleRowClick = (id) => {
23120 setSelectedItem(id);
23121 setIsOpen(true);
23122 };
23123 const actions2 = (0, import_element90.useMemo)(
23124 () => [
23125 {
23126 id: "edit",
23127 label: (0, import_i18n52.__)("Edit"),
23128 callback: (items) => {
23129 const item = items[0];
23130 handleRowClick(item.id);
23131 }
23132 },
23133 {
23134 id: "remove",
23135 label: (0, import_i18n52.__)("Remove"),
23136 callback: (items) => {
23137 const item = items[0];
23138 setItemToDelete(item);
23139 }
23140 }
23141 ],
23142 [setItemToDelete]
23143 );
23144 const handleDelete = () => {
23145 if (!itemToDelete) {
23146 return;
23147 }
23148 const oldValue = blockGuidelines[itemToDelete.id];
23149 setBlockGuideline(itemToDelete.id, "");
23150 setBusy(true);
23151 saveGuidelines().then(() => {
23152 setError(null);
23153 createSuccessNotice((0, import_i18n52.__)("Guidelines removed."), {
23154 type: "snackbar"
23155 });
23156 }).catch((e2) => {
23157 setError(e2.message);
23158 setBlockGuideline(itemToDelete.id, oldValue);
23159 }).finally(() => {
23160 setBusy(false);
23161 setItemToDelete(null);
23162 });
23163 };
23164 const { data: processedData, paginationInfo } = (0, import_element90.useMemo)(
23165 () => filterSortAndPaginate(rows, view, fields),
23166 [rows, view]
23167 );
23168 (0, import_element90.useEffect)(() => {
23169 const lastPage = Math.max(paginationInfo.totalPages, 1);
23170 if (view.page && view.page > lastPage) {
23171 setView(
23172 (currentView) => currentView.page && currentView.page > lastPage ? {
23173 ...currentView,
23174 page: lastPage
23175 } : currentView
23176 );
23177 }
23178 }, [paginationInfo.totalPages, view.page]);
23179 const closeModal = () => {
23180 setIsOpen(false);
23181 setSelectedItem(void 0);
23182 };
23183 const openModal = () => {
23184 setSelectedItem(void 0);
23185 setIsOpen(true);
23186 };
23187 const shouldShowDataViewControls = rows.length > PER_PAGE;
23188 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_i18n52.sprintf)(
23189 /* translators: %s: Error message. */
23190 (0, import_i18n52.__)("Error: %s"),
23191 error2
23192 )), rows.length > 0 && /* @__PURE__ */ React.createElement(
23193 dataviews_default,
23194 {
23195 paginationInfo,
23196 data: processedData,
23197 view,
23198 onChangeView: setView,
23199 fields,
23200 actions: actions2,
23201 config: { perPageSizes: [PER_PAGE] },
23202 onChangeSelection: (items) => {
23203 const id = items[0];
23204 handleRowClick(id);
23205 },
23206 defaultLayouts: {
23207 list: true
23208 }
23209 },
23210 /* @__PURE__ */ React.createElement(import_components55.__experimentalVStack, { spacing: 4 }, shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Search, { label: (0, import_i18n52.__)("Search blocks") }), /* @__PURE__ */ React.createElement(dataviews_default.Layout, null), shouldShowDataViewControls && /* @__PURE__ */ React.createElement(dataviews_default.Footer, null))
23211 ), /* @__PURE__ */ React.createElement(import_components55.__experimentalHStack, null, /* @__PURE__ */ React.createElement(import_components55.Button, { variant: "primary", onClick: openModal }, (0, import_i18n52.__)("Add guidelines"))), isOpen && /* @__PURE__ */ React.createElement(
23212 BlockGuidelineModal,
23213 {
23214 closeModal,
23215 initialBlock: selectedItem
23216 }
23217 ), /* @__PURE__ */ React.createElement(
23218 import_components55.__experimentalConfirmDialog,
23219 {
23220 isOpen: !!itemToDelete,
23221 title: (0, import_i18n52.__)("Remove block guidelines"),
23222 __experimentalHideHeader: false,
23223 onConfirm: handleDelete,
23224 onCancel: () => setItemToDelete(null),
23225 confirmButtonText: (0, import_i18n52.__)("Remove"),
23226 isBusy: busy,
23227 size: "small"
23228 },
23229 (0, import_i18n52.sprintf)(
23230 /* translators: %s: Block name. */
23231 (0, import_i18n52.__)(
23232 "You are about to remove the block guidelines for the %s block. This can be undone from revision history."
23233 ),
23234 itemToDelete?.label ?? ""
23235 )
23236 ));
23237 }
23238
23239 // routes/guidelines/components/guideline-actions-section.tsx
23240 var import_components57 = __toESM(require_components());
23241 var import_i18n53 = __toESM(require_i18n());
23242 var import_element91 = __toESM(require_element());
23243
23244 // routes/guidelines/components/guideline-actions-section.scss
23245 if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='9e2a8265d8']")) {
23246 const style = document.createElement("style");
23247 style.setAttribute("data-wp-hash", "9e2a8265d8");
23248 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}'));
23249 document.head.appendChild(style);
23250 }
23251
23252 // routes/guidelines/components/action-item.tsx
23253 var import_components56 = __toESM(require_components());
23254 function ActionItem({
23255 slug,
23256 title,
23257 description,
23258 buttonLabel,
23259 ariaLabel,
23260 onClick,
23261 disabled: disabled2,
23262 isBusy
23263 }) {
23264 const descriptionId = `guidelines-action-${slug}-description`;
23265 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(
23266 import_components56.__experimentalHeading,
23267 {
23268 level: 3,
23269 size: 13,
23270 weight: 400,
23271 className: "guidelines__action-title"
23272 },
23273 title
23274 ), /* @__PURE__ */ React.createElement(
23275 import_components56.__experimentalText,
23276 {
23277 id: descriptionId,
23278 size: 13,
23279 weight: 400,
23280 variant: "muted",
23281 className: "guidelines__action-description"
23282 },
23283 description
23284 )), /* @__PURE__ */ React.createElement(
23285 import_components56.Button,
23286 {
23287 size: "compact",
23288 variant: "secondary",
23289 className: "guidelines__action-button",
23290 "aria-label": ariaLabel,
23291 "aria-describedby": descriptionId,
23292 onClick,
23293 isBusy,
23294 disabled: disabled2
23295 },
23296 buttonLabel
23297 ));
23298 }
23299
23300 // routes/guidelines/components/guideline-actions-section.tsx
23301 function getErrorMessage(err) {
23302 return err instanceof Error ? err.message : (0, import_i18n53.__)("Unknown error");
23303 }
23304 function GuidelineActionsSection() {
23305 const { goTo } = (0, import_components57.useNavigator)();
23306 const fileInputRef = (0, import_element91.useRef)(null);
23307 const [isImporting, setIsImporting] = (0, import_element91.useState)(false);
23308 const [error2, setError] = (0, import_element91.useState)(null);
23309 const [pendingImport, setPendingImport] = (0, import_element91.useState)(null);
23310 function handleImportClick() {
23311 fileInputRef.current?.click();
23312 }
23313 function handleFileChange(event) {
23314 const file = event.target.files?.[0];
23315 event.target.value = "";
23316 if (!file) {
23317 return;
23318 }
23319 setPendingImport(file);
23320 }
23321 async function handleModalContinue() {
23322 if (!pendingImport) {
23323 return;
23324 }
23325 const file = pendingImport;
23326 setPendingImport(null);
23327 setIsImporting(true);
23328 try {
23329 await importGuidelines(file);
23330 setError(null);
23331 } catch (err) {
23332 setError(
23333 (0, import_i18n53.sprintf)(
23334 /* translators: %s: Error message. */
23335 (0, import_i18n53.__)("We ran into a problem importing your guidelines: %s"),
23336 getErrorMessage(err)
23337 )
23338 );
23339 } finally {
23340 setIsImporting(false);
23341 }
23342 }
23343 async function handleExportClick() {
23344 try {
23345 exportGuidelines();
23346 setError(null);
23347 } catch (err) {
23348 setError(
23349 (0, import_i18n53.sprintf)(
23350 /* translators: %s: Error message. */
23351 (0, import_i18n53.__)("We ran into a problem exporting your guidelines: %s"),
23352 getErrorMessage(err)
23353 )
23354 );
23355 }
23356 }
23357 function navigateToRevisionHistory() {
23358 if (window?.location?.href) {
23359 const url = new URL(window.location.href);
23360 url.searchParams.set("view", "revision-history");
23361 window.history.replaceState({}, "", url.toString());
23362 }
23363 goTo("/revision-history");
23364 }
23365 const ACTIONS = [
23366 {
23367 slug: "import",
23368 title: (0, import_i18n53.__)("Import"),
23369 description: (0, import_i18n53.__)("Upload a JSON file to import your guidelines."),
23370 buttonLabel: (0, import_i18n53.__)("Upload"),
23371 ariaLabel: (0, import_i18n53.__)("Import guidelines"),
23372 onClick: handleImportClick,
23373 isBusy: isImporting,
23374 disabled: isImporting || !!pendingImport
23375 },
23376 {
23377 slug: "export",
23378 title: (0, import_i18n53.__)("Export"),
23379 description: (0, import_i18n53.__)("Export your guidelines to a JSON file."),
23380 buttonLabel: (0, import_i18n53.__)("Download"),
23381 ariaLabel: (0, import_i18n53.__)("Export guidelines"),
23382 onClick: handleExportClick
23383 },
23384 {
23385 slug: "revert",
23386 title: (0, import_i18n53.__)("Revert"),
23387 description: (0, import_i18n53.__)("Use a previous version of your guidelines."),
23388 buttonLabel: (0, import_i18n53.__)("View history"),
23389 ariaLabel: (0, import_i18n53.__)("View history of guidelines"),
23390 onClick: navigateToRevisionHistory
23391 }
23392 ];
23393 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_i18n53.__)("Actions")), /* @__PURE__ */ React.createElement(
23394 "input",
23395 {
23396 type: "file",
23397 accept: ".json",
23398 ref: fileInputRef,
23399 onChange: handleFileChange,
23400 style: { display: "none" }
23401 }
23402 ), error2 && /* @__PURE__ */ React.createElement(
23403 import_components57.Notice,
23404 {
23405 status: "error",
23406 onRemove: () => setError(null),
23407 isDismissible: true
23408 },
23409 error2
23410 ), /* @__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(
23411 "li",
23412 {
23413 key: action.slug,
23414 className: "guidelines__action-list-item"
23415 },
23416 /* @__PURE__ */ React.createElement(ActionItem, { ...action })
23417 )))), /* @__PURE__ */ React.createElement(
23418 import_components57.__experimentalConfirmDialog,
23419 {
23420 isOpen: !!pendingImport,
23421 __experimentalHideHeader: false,
23422 title: (0, import_i18n53.__)("Import guidelines"),
23423 confirmButtonText: (0, import_i18n53.__)("Continue"),
23424 onConfirm: handleModalContinue,
23425 onCancel: () => setPendingImport(null),
23426 size: "small"
23427 },
23428 (0, import_i18n53.__)(
23429 "Importing new guidelines will replace your current guidelines. This can be undone from revision history."
23430 )
23431 ));
23432 }
23433
23434 // routes/guidelines/components/revision-history.tsx
23435 var import_components58 = __toESM(require_components());
23436 var import_i18n54 = __toESM(require_i18n());
23437 var import_element92 = __toESM(require_element());
23438 var import_data11 = __toESM(require_data());
23439 var import_date10 = __toESM(require_date());
23440 var import_notices5 = __toESM(require_notices());
23441 var DEFAULT_VIEW = {
23442 type: "table",
23443 fields: ["date", "author"],
23444 page: 1,
23445 perPage: 10,
23446 layout: {
23447 enableMoving: false
23448 }
23449 };
23450 function RevisionHistory() {
23451 const [view, setView] = (0, import_element92.useState)(DEFAULT_VIEW);
23452 const [revisions, setRevisions] = (0, import_element92.useState)([]);
23453 const [isLoading, setIsLoading] = (0, import_element92.useState)(false);
23454 const [revisionToRestore, setRevisionToRestore] = (0, import_element92.useState)(null);
23455 const [isRestoring, setIsRestoring] = (0, import_element92.useState)(false);
23456 const { createSuccessNotice, createErrorNotice } = (0, import_data11.useDispatch)(import_notices5.store);
23457 const guidelinesId = (0, import_data11.useSelect)(
23458 (select2) => select2(store).getId(),
23459 []
23460 );
23461 const loadRevisions = (0, import_element92.useCallback)(async () => {
23462 if (!guidelinesId) {
23463 return;
23464 }
23465 setIsLoading(true);
23466 try {
23467 const result = await fetchGuidelinesRevisions({
23468 guidelinesId,
23469 page: 1,
23470 perPage: 100
23471 });
23472 setRevisions(result.revisions);
23473 } catch {
23474 createErrorNotice(
23475 (0, import_i18n54.__)("Could not load revision history. Please try again."),
23476 { type: "snackbar" }
23477 );
23478 } finally {
23479 setIsLoading(false);
23480 }
23481 }, [guidelinesId, createErrorNotice]);
23482 (0, import_element92.useEffect)(() => {
23483 loadRevisions();
23484 }, [loadRevisions]);
23485 const authorElements = (0, import_element92.useMemo)(() => {
23486 return [
23487 ...new Set(
23488 revisions.map(
23489 (r3) => r3._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown")
23490 )
23491 )
23492 ].map((name) => ({ value: name, label: name }));
23493 }, [revisions]);
23494 const fields2 = (0, import_element92.useMemo)(
23495 () => [
23496 {
23497 id: "date",
23498 type: "date",
23499 label: (0, import_i18n54.__)("Date"),
23500 getValue: ({ item }) => item.date,
23501 render: ({ item }) => /* @__PURE__ */ React.createElement("time", { dateTime: item.date }, (0, import_date10.dateI18n)(
23502 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
23503 (0, import_date10.getDate)(item.date)
23504 )),
23505 enableSorting: false,
23506 enableHiding: false,
23507 filterBy: {
23508 operators: ["before", "after", "between", "inThePast"]
23509 }
23510 },
23511 {
23512 id: "author",
23513 label: (0, import_i18n54.__)("User"),
23514 getValue: ({ item }) => item._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown"),
23515 render: ({ item }) => /* @__PURE__ */ React.createElement("span", null, item._embedded?.author?.[0]?.name ?? (0, import_i18n54.__)("Unknown")),
23516 enableSorting: false,
23517 enableHiding: false,
23518 enableGlobalSearch: true,
23519 elements: authorElements,
23520 filterBy: {
23521 operators: ["isAny", "isNone"]
23522 }
23523 }
23524 ],
23525 [authorElements]
23526 );
23527 const actions2 = (0, import_element92.useMemo)(
23528 () => [
23529 {
23530 id: "restore-revision",
23531 label: (0, import_i18n54.__)("Restore"),
23532 callback: (items) => setRevisionToRestore(items[0])
23533 }
23534 ],
23535 [setRevisionToRestore]
23536 );
23537 const { data: displayedRevisions, paginationInfo: paginationToShow } = (0, import_element92.useMemo)(
23538 () => filterSortAndPaginate(revisions, view, fields2),
23539 [revisions, view, fields2]
23540 );
23541 async function handleRestore() {
23542 if (!guidelinesId || !revisionToRestore) {
23543 return;
23544 }
23545 setIsRestoring(true);
23546 try {
23547 await restoreGuidelinesRevision(
23548 guidelinesId,
23549 revisionToRestore.id
23550 );
23551 await fetchGuidelines();
23552 setRevisionToRestore(null);
23553 await loadRevisions();
23554 createSuccessNotice((0, import_i18n54.__)("Revision restored."), {
23555 type: "snackbar"
23556 });
23557 } catch {
23558 createErrorNotice(
23559 (0, import_i18n54.__)("Could not restore revision. Please try again."),
23560 { type: "snackbar" }
23561 );
23562 } finally {
23563 setIsRestoring(false);
23564 }
23565 }
23566 const navigateToGuidelines = () => {
23567 if (window?.location?.href) {
23568 const url = new URL(window.location.href);
23569 url.searchParams.delete("view");
23570 window.history.replaceState({}, "", url.toString());
23571 }
23572 };
23573 return /* @__PURE__ */ React.createElement("div", { className: "guidelines__revision-history" }, /* @__PURE__ */ React.createElement(
23574 import_components58.Navigator.BackButton,
23575 {
23576 icon: (0, import_i18n54.isRTL)() ? chevron_right_default : chevron_left_default,
23577 className: "guidelines__revision-history-back",
23578 onClick: navigateToGuidelines
23579 },
23580 (0, import_i18n54.__)("Revision history")
23581 ), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400, variant: "muted" }, (0, import_i18n54.__)("Use a previous version of your guidelines.")), /* @__PURE__ */ React.createElement(
23582 dataviews_default,
23583 {
23584 data: displayedRevisions,
23585 fields: fields2,
23586 view,
23587 onChangeView: setView,
23588 actions: actions2,
23589 isLoading,
23590 paginationInfo: paginationToShow,
23591 defaultLayouts: { table: true },
23592 getItemId: (item) => String(item.id),
23593 empty: isLoading && displayedRevisions.length === 0 ? /* @__PURE__ */ React.createElement(import_components58.Spinner, null) : (0, import_i18n54.__)("No revisions found.")
23594 }
23595 ), revisionToRestore && /* @__PURE__ */ React.createElement(
23596 import_components58.Modal,
23597 {
23598 title: (0, import_i18n54.__)("Restore guidelines"),
23599 onRequestClose: () => setRevisionToRestore(null),
23600 size: "medium"
23601 },
23602 /* @__PURE__ */ React.createElement(import_components58.__experimentalVStack, { spacing: 4 }, /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n54.sprintf)(
23603 /* translators: %s: formatted revision date */
23604 (0, import_i18n54.__)(
23605 "You are about to restore the guidelines from %s."
23606 ),
23607 (0, import_date10.dateI18n)(
23608 (0, import_date10.getSettings)().formats.datetimeAbbreviated,
23609 (0, import_date10.getDate)(revisionToRestore.date)
23610 )
23611 )), /* @__PURE__ */ React.createElement(import_components58.__experimentalText, { size: 13, weight: 400 }, (0, import_i18n54.__)(
23612 "You can undo this anytime from revision history."
23613 ))),
23614 /* @__PURE__ */ React.createElement(
23615 import_components58.__experimentalHStack,
23616 {
23617 justify: "flex-end",
23618 className: "guidelines__restore-modal-actions"
23619 },
23620 /* @__PURE__ */ React.createElement(
23621 import_components58.Button,
23622 {
23623 variant: "tertiary",
23624 onClick: () => setRevisionToRestore(null)
23625 },
23626 (0, import_i18n54.__)("Cancel")
23627 ),
23628 /* @__PURE__ */ React.createElement(
23629 import_components58.Button,
23630 {
23631 variant: "primary",
23632 onClick: handleRestore,
23633 isBusy: isRestoring,
23634 disabled: isRestoring,
23635 __next40pxDefaultSize: true
23636 },
23637 (0, import_i18n54.__)("Restore")
23638 )
23639 )
23640 ));
23641 }
23642
23643 // routes/guidelines/stage.tsx
23644 var GUIDELINE_ITEMS = [
23645 {
23646 title: (0, import_i18n55.__)("Site"),
23647 description: (0, import_i18n55.__)(
23648 "Describe your site's purpose, goals, and primary audience."
23649 ),
23650 slug: "site"
23651 },
23652 {
23653 title: (0, import_i18n55.__)("Copy"),
23654 description: (0, import_i18n55.__)(
23655 "Set your writing standards for tone, voice, style, and formatting."
23656 ),
23657 slug: "copy"
23658 },
23659 {
23660 title: (0, import_i18n55.__)("Images"),
23661 description: (0, import_i18n55.__)(
23662 "Outline your style, dimensions, formats, mood and aesthetic preferences."
23663 ),
23664 slug: "images"
23665 },
23666 {
23667 title: (0, import_i18n55.__)("Blocks"),
23668 description: (0, import_i18n55.__)(
23669 "Create tailored guidelines for specific block types."
23670 ),
23671 slug: "blocks"
23672 },
23673 {
23674 title: (0, import_i18n55.__)("Additional"),
23675 description: (0, import_i18n55.__)("Add additional guidelines."),
23676 slug: "additional"
23677 }
23678 ];
23679 var KNOWN_VIEWS = ["revision-history"];
23680 function getInitialNavigatorPath() {
23681 if (window?.location?.href) {
23682 const url = new URL(window.location.href);
23683 const view = url.searchParams.get("view") ?? "";
23684 if (KNOWN_VIEWS.includes(view)) {
23685 return `/${view}`;
23686 }
23687 }
23688 return "/";
23689 }
23690 function GuidelinesPage() {
23691 const [loading, setLoading] = (0, import_element93.useState)(true);
23692 const [error2, setError] = (0, import_element93.useState)(null);
23693 (0, import_element93.useEffect)(() => {
23694 fetchGuidelines().then(() => setError(null)).catch((e2) => setError(e2.message)).finally(() => setLoading(false));
23695 }, []);
23696 return /* @__PURE__ */ React.createElement(
23697 page_default,
23698 {
23699 title: (0, import_i18n55.__)("Guidelines"),
23700 subTitle: (0, import_i18n55.__)(
23701 "Set content standards that guide your team, inform plugins, and help AI tools generate content that matches your site's voice and requirements."
23702 )
23703 },
23704 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_i18n55.sprintf)(
23705 /* translators: %s: Error message. */
23706 (0, import_i18n55.__)("Error loading guidelines: %s"),
23707 error2
23708 )), /* @__PURE__ */ React.createElement("p", { className: "guidelines__error-description" }, (0, import_i18n55.__)(
23709 "Please try again. If the problem persists, contact support."
23710 )))),
23711 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) => /* @__PURE__ */ React.createElement(
23712 "li",
23713 {
23714 key: item.slug,
23715 className: "guidelines__list-item"
23716 },
23717 /* @__PURE__ */ React.createElement(
23718 GuidelineAccordion,
23719 {
23720 title: item.title,
23721 description: item.description
23722 },
23723 item.slug === "blocks" ? /* @__PURE__ */ React.createElement(BlockGuidelines, null) : /* @__PURE__ */ React.createElement(
23724 GuidelineAccordionForm,
23725 {
23726 slug: item.slug
23727 }
23728 )
23729 )
23730 ))), /* @__PURE__ */ React.createElement(GuidelineActionsSection, null))), /* @__PURE__ */ React.createElement(import_components59.Navigator.Screen, { path: "/revision-history" }, /* @__PURE__ */ React.createElement(RevisionHistory, null)))
23731 );
23732 }
23733 var stage = GuidelinesPage;
23734 export {
23735 stage
23736 };
23737 /*! Bundled license information:
23738
23739 use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
23740 (**
23741 * @license React
23742 * use-sync-external-store-shim.development.js
23743 *
23744 * Copyright (c) Meta Platforms, Inc. and affiliates.
23745 *
23746 * This source code is licensed under the MIT license found in the
23747 * LICENSE file in the root directory of this source tree.
23748 *)
23749 */
23750